mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
fix some mistakes on switch audren
This commit is contained in:
parent
198c6e18cc
commit
ec4959c57e
31
src/Audio.c
31
src/Audio.c
@ -1044,15 +1044,16 @@ cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 data
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf->data_pcm16 = chunk;
|
buf->data_pcm16 = chunk;
|
||||||
buf->size = dataSize / (sizeof(cc_int16) * (ctx->stereo ? 2 : 1));
|
buf->size = dataSize;
|
||||||
buf->start_sample_offset = 0;
|
buf->start_sample_offset = 0;
|
||||||
buf->end_sample_offset = dataSize/2;
|
buf->end_sample_offset = dataSize/2;
|
||||||
//Platform_Log1("PLAYING ON: %i", &ctx->chanID);
|
//Platform_Log1("PLAYING ON: %i", &ctx->chanID);
|
||||||
armDCacheFlush(buf->data_pcm16, dataSize);
|
armDCacheFlush(buf->data_pcm16, dataSize);
|
||||||
audrvVoiceInit(&drv, ctx->chanID, 1, PcmFormat_Int16, ctx->sampleRate);
|
audrvVoiceStop(&drv, ctx->chanID);
|
||||||
|
audrvVoiceInit(&drv, ctx->chanID, ctx->channels, PcmFormat_Int16, ctx->sampleRate);
|
||||||
audrvVoiceSetDestinationMix(&drv, ctx->chanID, AUDREN_FINAL_MIX_ID);
|
audrvVoiceSetDestinationMix(&drv, ctx->chanID, AUDREN_FINAL_MIX_ID);
|
||||||
audrvVoiceSetMixFactor(&drv, ctx->chanID, 1.0f, 0, 0);
|
//audrvVoiceSetMixFactor(&drv, ctx->chanID, 1.0f, 0, 0);
|
||||||
audrvVoiceSetMixFactor(&drv, ctx->chanID, 1.0f, 0, 1);
|
//audrvVoiceSetMixFactor(&drv, ctx->chanID, 1.0f, 0, 1);
|
||||||
audrvVoiceAddWaveBuf(&drv, ctx->chanID, buf);
|
audrvVoiceAddWaveBuf(&drv, ctx->chanID, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1159,31 +1160,33 @@ void Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) {
|
|||||||
}*/
|
}*/
|
||||||
size = (size + 0xFFF) & ~0xFFF; // round up to nearest multiple of 0x1000
|
size = (size + 0xFFF) & ~0xFFF; // round up to nearest multiple of 0x1000
|
||||||
cc_uint8* dst = (cc_uint8*)memalign(0x1000, size * numChunks);
|
cc_uint8* dst = (cc_uint8*)memalign(0x1000, size * numChunks);
|
||||||
armDCacheFlush(dst, size * numChunks);
|
//armDCacheFlush(dst, size * numChunks);
|
||||||
|
|
||||||
for (int i = 0; i < numChunks; i++) {
|
for (int i = 0; i < numChunks; i++) {
|
||||||
int mpid = audrvMemPoolAdd(&drv, dst + size * i, size);
|
int mpid = audrvMemPoolAdd(&drv, dst + size * i, size);
|
||||||
audrvMemPoolAttach(&drv, mpid);
|
audrvMemPoolAttach(&drv, mpid);
|
||||||
|
|
||||||
|
chunks[i] = dst ? (dst + size * i) : NULL;
|
||||||
|
|
||||||
for (int j = 0; j < 64; j++) {
|
for (int j = 0; j < 64; j++) {
|
||||||
if (audioPools[j].chunk != NULL) continue;
|
if (audioPools[j].chunk != NULL) continue;
|
||||||
audioPools[j].chunk = chunks[0];
|
audioPools[j].chunk = chunks[i];
|
||||||
audioPools[j].mpid = mpid;
|
audioPools[j].mpid = mpid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunks[i] = dst ? (dst + size * i) : NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio_FreeChunks(void** chunks, int numChunks) {
|
void Audio_FreeChunks(void** chunks, int numChunks) {
|
||||||
// remove memory pool from audren
|
// remove memory pool from audren
|
||||||
for (int i=0; i<64; i++) {
|
for (int i=0; i<numChunks; i++) {
|
||||||
if (audioPools[i].chunk == chunks[0]) {
|
for (int j=0; j<64; j++) {
|
||||||
audrvMemPoolDetach(&drv, audioPools[i].mpid);
|
if (audioPools[j].chunk == chunks[i]) {
|
||||||
audrvMemPoolRemove(&drv, audioPools[i].mpid);
|
audrvMemPoolDetach(&drv, audioPools[j].mpid);
|
||||||
Mem_Set(&audioPools[i], 0, sizeof(struct AudioMemPools));
|
audrvMemPoolRemove(&drv, audioPools[j].mpid);
|
||||||
break;
|
Mem_Set(&audioPools[j], 0, sizeof(struct AudioMemPools));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user