output/Thread: move code to BeginPause(), IteratePause()

This commit is contained in:
Max Kellermann
2017-04-28 22:01:20 +02:00
parent 2a831fa547
commit 59181ac5fb
2 changed files with 31 additions and 14 deletions

View File

@@ -516,6 +516,9 @@ private:
*/
bool Play();
void BeginPause();
bool IteratePause();
void Pause();
/**

View File

@@ -365,7 +365,7 @@ AudioOutput::Play()
}
inline void
AudioOutput::Pause()
AudioOutput::BeginPause()
{
{
const ScopeUnlock unlock(mutex);
@@ -373,13 +373,13 @@ AudioOutput::Pause()
}
pause = true;
CommandFinished();
do {
if (!WaitForDelay())
break;
}
inline bool
AudioOutput::IteratePause()
{
bool success;
try {
const ScopeUnlock unlock(mutex);
success = ao_plugin_pause(*this);
@@ -389,10 +389,24 @@ AudioOutput::Pause()
success = false;
}
if (!success) {
if (!success)
Close(false);
return success;
}
inline void
AudioOutput::Pause()
{
BeginPause();
CommandFinished();
do {
if (!WaitForDelay())
break;
if (!IteratePause())
break;
}
} while (command == Command::NONE);
pause = false;