diff options
author | Chris Robinson <[email protected]> | 2022-05-07 17:42:37 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-05-07 17:42:37 -0700 |
commit | 97ed5a870de114ee8735d1850b36790791091c38 (patch) | |
tree | cddc833810fd7ecbc670c01bef75557ee2f8a9d2 /examples/alffplay.cpp | |
parent | 96756acc5249a6b7e733b3098c7dca37fcf847cb (diff) |
Drain audio frames when stopping playback in alffplay
Diffstat (limited to 'examples/alffplay.cpp')
-rw-r--r-- | examples/alffplay.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index c3f4c505..f0f7b651 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -1299,19 +1299,28 @@ int AudioState::handler() while(1) { + if(mMovie.mQuit.load(std::memory_order_relaxed)) + { + /* If mQuit is set, drain frames until we can't get more audio, + * indicating we've reached the flush packet and the packet sender + * will also quit. + */ + do { + mSamplesLen = decodeFrame(); + mSamplesPos = mSamplesLen; + } while(mSamplesLen > 0); + goto finish; + } + ALenum state; if(mBufferDataSize > 0) { alGetSourcei(mSource, AL_SOURCE_STATE, &state); - /* If mQuit is set, don't actually quit until we can't get more - * audio, indicating we've reached the flush packet and the packet - * sender will also quit. - * - * If mQuit is not set, don't quit even if there's no more audio, + + /* If mQuit is not set, don't quit even if there's no more audio, * so what's buffered has a chance to play to the real end. */ - if(!readAudio(getSync()) && mMovie.mQuit.load(std::memory_order_relaxed)) - goto finish; + readAudio(getSync()); } else { |