output/Thread: move Enable() call to InternalEnable()
This commit is contained in:
@@ -360,6 +360,13 @@ public:
|
|||||||
void LockAllowPlay() noexcept;
|
void LockAllowPlay() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Runs inside the OutputThread. Handles exceptions.
|
||||||
|
*
|
||||||
|
* @return true on success
|
||||||
|
*/
|
||||||
|
bool InternalEnable() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs inside the OutputThread. Handles exceptions.
|
* Runs inside the OutputThread. Handles exceptions.
|
||||||
*/
|
*/
|
||||||
|
@@ -197,6 +197,22 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
AudioOutputControl::InternalEnable() noexcept
|
||||||
|
{
|
||||||
|
last_error = nullptr;
|
||||||
|
|
||||||
|
try {
|
||||||
|
output->Enable();
|
||||||
|
return true;
|
||||||
|
} catch (const std::runtime_error &e) {
|
||||||
|
LogError(e);
|
||||||
|
fail_timer.Update();
|
||||||
|
last_error = std::current_exception();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
AudioOutputControl::InternalDisable() noexcept
|
AudioOutputControl::InternalDisable() noexcept
|
||||||
{
|
{
|
||||||
@@ -210,14 +226,15 @@ inline void
|
|||||||
AudioOutputControl::InternalOpen(const AudioFormat audio_format,
|
AudioOutputControl::InternalOpen(const AudioFormat audio_format,
|
||||||
const MusicPipe &pipe) noexcept
|
const MusicPipe &pipe) noexcept
|
||||||
{
|
{
|
||||||
|
/* enable the device (just in case the last enable has failed) */
|
||||||
|
if (!InternalEnable())
|
||||||
|
return;
|
||||||
|
|
||||||
last_error = nullptr;
|
last_error = nullptr;
|
||||||
fail_timer.Reset();
|
fail_timer.Reset();
|
||||||
skip_delay = true;
|
skip_delay = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* enable the device (just in case the last enable has failed) */
|
|
||||||
output->Enable();
|
|
||||||
|
|
||||||
output->Open(audio_format, pipe);
|
output->Open(audio_format, pipe);
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
LogError(e);
|
LogError(e);
|
||||||
@@ -459,16 +476,7 @@ AudioOutputControl::Task()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Command::ENABLE:
|
case Command::ENABLE:
|
||||||
last_error = nullptr;
|
InternalEnable();
|
||||||
|
|
||||||
try {
|
|
||||||
output->Enable();
|
|
||||||
} catch (const std::runtime_error &e) {
|
|
||||||
LogError(e);
|
|
||||||
fail_timer.Update();
|
|
||||||
last_error = std::current_exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandFinished();
|
CommandFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user