Commit e616be0a authored by Max Kellermann's avatar Max Kellermann

output/Thread: move code to InternalOpen()

parent 5eef1468
......@@ -340,6 +340,12 @@ public:
private:
/**
* Runs inside the OutputThread. Handles exceptions.
*/
void InternalOpen(AudioFormat audio_format,
const MusicPipe &pipe) noexcept;
/**
* Wait until the output's delay reaches zero.
*
* @return true if playback should be continued, false if a
......
......@@ -203,6 +203,22 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
}
}
inline void
AudioOutputControl::InternalOpen(const AudioFormat audio_format,
const MusicPipe &pipe) noexcept
{
last_error = nullptr;
fail_timer.Reset();
try {
output->Open(audio_format, pipe);
} catch (const std::runtime_error &e) {
LogError(e);
fail_timer.Update();
last_error = std::current_exception();
}
}
void
AudioOutput::Close(bool drain)
{
......@@ -452,18 +468,7 @@ AudioOutputControl::Task()
break;
case Command::OPEN:
last_error = nullptr;
fail_timer.Reset();
try {
output->Open(request.audio_format,
*request.pipe);
} catch (const std::runtime_error &e) {
LogError(e);
fail_timer.Update();
last_error = std::current_exception();
}
InternalOpen(request.audio_format, *request.pipe);
CommandFinished();
break;
......
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