Commit 3a347e04 authored by David Reid's avatar David Reid

Fix a bug where a sound is never marked as not playing.

parent ecb139a7
...@@ -98,7 +98,7 @@ int main(int argc, char** argv) ...@@ -98,7 +98,7 @@ int main(int argc, char** argv)
ma_sound_start(&sound); ma_sound_start(&sound);
//ma_sleep(1000); //ma_sleep(1000);
ma_sound_set_looping(&sound2, MA_TRUE); //ma_sound_set_looping(&sound2, MA_TRUE);
ma_sound_set_volume(&sound2, 0.5f); ma_sound_set_volume(&sound2, 0.5f);
ma_sound_start(&sound2); ma_sound_start(&sound2);
......
...@@ -999,6 +999,7 @@ MA_API ma_result ma_sound_set_fade_point_in_milliseconds(ma_sound* pSound, ma_ui ...@@ -999,6 +999,7 @@ MA_API ma_result ma_sound_set_fade_point_in_milliseconds(ma_sound* pSound, ma_ui
MA_API ma_result ma_sound_set_fade_point_auto_reset(ma_sound* pSound, ma_uint32 fadePointIndex, ma_bool32 autoReset); MA_API ma_result ma_sound_set_fade_point_auto_reset(ma_sound* pSound, ma_uint32 fadePointIndex, ma_bool32 autoReset);
MA_API ma_result ma_sound_set_start_delay(ma_sound* pSound, ma_uint64 delayInMilliseconds); MA_API ma_result ma_sound_set_start_delay(ma_sound* pSound, ma_uint64 delayInMilliseconds);
MA_API ma_result ma_sound_set_stop_delay(ma_sound* pSound, ma_uint64 delayInMilliseconds); MA_API ma_result ma_sound_set_stop_delay(ma_sound* pSound, ma_uint64 delayInMilliseconds);
MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound);
MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound); MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound);
MA_API ma_result ma_sound_get_time_in_frames(const ma_sound* pSound, ma_uint64* pTimeInFrames); MA_API ma_result ma_sound_get_time_in_frames(const ma_sound* pSound, ma_uint64* pTimeInFrames);
MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex); /* Just a wrapper around ma_data_source_seek_to_pcm_frame(). */ MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex); /* Just a wrapper around ma_data_source_seek_to_pcm_frame(). */
...@@ -5356,6 +5357,12 @@ static void ma_engine_mix_sound(ma_engine* pEngine, ma_sound_group* pGroup, ma_s ...@@ -5356,6 +5357,12 @@ static void ma_engine_mix_sound(ma_engine* pEngine, ma_sound_group* pGroup, ma_s
*/ */
result = ma_mixer_mix_data_source(&pGroup->mixer, pSound->pDataSource, offsetInFrames, (frameCount - offsetInFrames), &framesProcessed, pSound->volume, &pSound->effect, pSound->isLooping); result = ma_mixer_mix_data_source(&pGroup->mixer, pSound->pDataSource, offsetInFrames, (frameCount - offsetInFrames), &framesProcessed, pSound->volume, &pSound->effect, pSound->isLooping);
/* If we reached the end of the sound we'll want to mark it as at the end and stop it. This should never be returned for looping sounds. */
if (result == MA_AT_END) {
ma_sound_stop_internal(pSound);
c89atomic_exchange_32(&pSound->atEnd, MA_TRUE); /* This will be set to false in ma_sound_start(). */
}
/* /*
For the benefit of the main effect we need to ensure the local time is updated explicitly. This is required for allowing time-based effects to For the benefit of the main effect we need to ensure the local time is updated explicitly. This is required for allowing time-based effects to
support loop transitions properly. support loop transitions properly.
...@@ -5365,12 +5372,6 @@ static void ma_engine_mix_sound(ma_engine* pEngine, ma_sound_group* pGroup, ma_s ...@@ -5365,12 +5372,6 @@ static void ma_engine_mix_sound(ma_engine* pEngine, ma_sound_group* pGroup, ma_s
ma_engine_effect_set_time(&pSound->effect, currentTimeInFrames); ma_engine_effect_set_time(&pSound->effect, currentTimeInFrames);
} }
/* If we reached the end of the sound we'll want to mark it as at the end and stop it. This should never be returned for looping sounds. */
if (result == MA_AT_END) {
ma_sound_stop_internal(pSound);
c89atomic_exchange_32(&pSound->atEnd, MA_TRUE); /* This will be set to false in ma_sound_start(). */
}
pSound->runningTimeInEngineFrames += offsetInFrames + framesProcessed; pSound->runningTimeInEngineFrames += offsetInFrames + framesProcessed;
} else { } else {
/* The sound hasn't started yet. Just keep advancing time forward, but leave the data source alone. */ /* The sound hasn't started yet. Just keep advancing time forward, but leave the data source alone. */
...@@ -6339,6 +6340,15 @@ MA_API ma_result ma_sound_set_stop_delay(ma_sound* pSound, ma_uint64 delayInMill ...@@ -6339,6 +6340,15 @@ MA_API ma_result ma_sound_set_stop_delay(ma_sound* pSound, ma_uint64 delayInMill
return MA_SUCCESS; return MA_SUCCESS;
} }
MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound)
{
if (pSound == NULL) {
return MA_FALSE;
}
return pSound->isPlaying;
}
MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound) MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound)
{ {
if (pSound == NULL) { if (pSound == NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment