MCPcopy Create free account
hub / github.com/EasyRPG/Player / n3ds_audio_thread

Function n3ds_audio_thread

src/platform/3ds/audio.cpp:336–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void n3ds_audio_thread(void* userdata) {
337 CtrAudio* audio = static_cast<CtrAudio*>(userdata);
338 float mix[12] = {0};
339
340 while (!term_stream) {
341 LightEvent_Wait(&audio_event);
342
343 int target_block = fill_block;
344 ++fill_block;
345 fill_block %= bgm.num_bufs;
346
347 audio->LockMutex();
348 if (bgm.decoder) {
349 bgm.decoder->Decode(
350 reinterpret_cast<uint8_t*>(bgm.buf[target_block].data_pcm16),
351 bgm.buf_size);
352 DSP_FlushDataCache(bgm.buf[target_block].data_pcm16, bgm.buf_size);
353 mix[0] = mix[1] = bgm.decoder->GetVolume() / 100.0f * audio->GetConfig().music_volume.Get() / 100.0f;
354 ndspChnSetMix(bgm.channel, mix);
355 ndspChnWaveBufAdd(bgm.channel, &bgm.buf[target_block]);
356 } else {
357 bgm.buf[target_block].status = NDSP_WBUF_DONE;
358 }
359 audio->UnlockMutex();
360 }
361 threadExit(0);
362}
363
364CtrAudio::CtrAudio(const Game_ConfigAudio& cfg) : AudioInterface(cfg) {
365 LightLock_Init(&audio_mutex);

Callers

nothing calls this directly

Calls 6

LockMutexMethod · 0.45
DecodeMethod · 0.45
GetVolumeMethod · 0.45
GetMethod · 0.45
GetConfigMethod · 0.45
UnlockMutexMethod · 0.45

Tested by

no test coverage detected