From 30b55db6812d826e792d61c95ee12dc7bd0b4e4e Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 17 Jan 2021 18:38:17 +1000 Subject: [PATCH] Fix a bug with looping streaming sounds. --- research/miniaudio_engine.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/research/miniaudio_engine.h b/research/miniaudio_engine.h index 93fdd4d3..86ce476b 100644 --- a/research/miniaudio_engine.h +++ b/research/miniaudio_engine.h @@ -6859,14 +6859,8 @@ static void ma_resource_manager_data_stream_fill_pages(ma_resource_manager_data_ MA_ASSERT(pDataStream != NULL); - /* For each page... */ for (iPage = 0; iPage < 2; iPage += 1) { ma_resource_manager_data_stream_fill_page(pDataStream, iPage); - - /* If we reached the end make sure we get out of the loop to prevent us from trying to load the second page. */ - if (ma_resource_manager_data_stream_is_decoder_at_end(pDataStream)) { - break; - } } } @@ -7084,6 +7078,9 @@ MA_API ma_result ma_resource_manager_data_stream_seek_to_pcm_frame(ma_resource_m c89atomic_exchange_32(&pDataStream->isPageValid[0], MA_FALSE); c89atomic_exchange_32(&pDataStream->isPageValid[1], MA_FALSE); + /* Make sure the data stream is not marked as at the end or else if we seek in response to hitting the end, we won't be able to read any more data. */ + c89atomic_exchange_32(&pDataStream->isDecoderAtEnd, MA_FALSE); + /* The public API is not allowed to touch the internal decoder so we need to use a job to perform the seek. When seeking, the job thread will assume both pages are invalid and any content contained within them will be discarded and replaced with newly decoded data.