From 23ae3c69b5ffb5ac24567e618df2b0404e37748d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 17 Jun 2011 13:21:02 -0700 Subject: Handle the device's disconnected status earlier when playing a source --- OpenAL32/alSource.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index fd163804..9486915e 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -1357,7 +1357,9 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) BufferList = BufferList->next; } - if(!BufferList) + /* If there's nothing to play, or device is disconnected, go right to + * stopped */ + if(!BufferList || !Context->Device->Connected) { Source->state = AL_STOPPED; Source->BuffersPlayed = Source->BuffersInQueue; @@ -1394,24 +1396,13 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) if(Source->lOffset) ApplyOffset(Source); - // If device is disconnected, go right to stopped - if(!Context->Device->Connected) + for(j = 0;j < Context->ActiveSourceCount;j++) { - Source->state = AL_STOPPED; - Source->BuffersPlayed = Source->BuffersInQueue; - Source->position = 0; - Source->position_fraction = 0; - } - else - { - for(j = 0;j < Context->ActiveSourceCount;j++) - { - if(Context->ActiveSources[j] == Source) - break; - } - if(j == Context->ActiveSourceCount) - Context->ActiveSources[Context->ActiveSourceCount++] = Source; + if(Context->ActiveSources[j] == Source) + break; } + if(j == Context->ActiveSourceCount) + Context->ActiveSources[Context->ActiveSourceCount++] = Source; } done: -- cgit v1.2.3