From fe58e2d938524c6636c21f52d4b3e8e17417db6b Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Fri, 11 May 2018 09:26:18 -0400 Subject: [PATCH] Fixed QR code bug --- source/camera.c | 3 +++ source/loading.c | 3 ++- source/music.c | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/camera.c b/source/camera.c index ea4b78c..a38bfea 100644 --- a/source/camera.c +++ b/source/camera.c @@ -46,9 +46,11 @@ static u16 * camera_buf = NULL; void exit_qr(qr_data *data) { + DEBUG("Exiting QR"); svcSignalEvent(data->cancel); while(!data->finished) svcSleepThread(1000000); + svcCloseHandle(data->cancel); data->capturing = false; free(data->camera_buffer); @@ -87,6 +89,7 @@ void capture_cam_thread(void *arg) svcWaitSynchronizationN(&index, events, 3, false, U64_MAX); switch(index) { case 0: + DEBUG("Cancel event received\n"); cancel = true; break; case 1: diff --git a/source/loading.c b/source/loading.c index 0ff19dd..2db4f6d 100644 --- a/source/loading.c +++ b/source/loading.c @@ -471,7 +471,8 @@ Result load_audio(Entry_s entry, audio_s *audio) } audio->mix[0] = audio->mix[1] = 1.0f; // Determines volume for the 12 (?) different outputs. See http://smealum.github.io/ctrulib/channel_8h.html#a30eb26f1972cc3ec28370263796c0444 - + svcCreateEvent(&audio->finished, RESET_STICKY); + ndspChnSetInterp(0, NDSP_INTERP_LINEAR); ndspChnSetRate(0, 44100); ndspChnSetFormat(0, NDSP_FORMAT_STEREO_PCM16); // Tremor outputs ogg files in 16 bit PCM stereo diff --git a/source/music.c b/source/music.c index 07eb114..f4f0c52 100644 --- a/source/music.c +++ b/source/music.c @@ -30,8 +30,6 @@ // Play a given audio struct Result update_audio(audio_s *audio) { - svcCreateEvent(&audio->finished, RESET_STICKY); - long size = audio->wave_buf[audio->buf_pos].nsamples * 4 - audio->data_read; char size_info[50] = {0}; sprintf(size_info, "Audio Size: %ld\n", size); @@ -78,6 +76,8 @@ void thread_audio(void* data) { linearFree(audio->wave_buf[1].data_vaddr); while (audio->wave_buf[0].status != NDSP_WBUF_DONE || audio->wave_buf[1].status != NDSP_WBUF_DONE) svcSleepThread(1e7); svcSignalEvent(audio->finished); + svcSleepThread(1e8); + svcCloseHandle(audio->finished); free(audio); }