output/Thread: move common code to method Failure()
This commit is contained in:
@@ -420,6 +420,17 @@ public:
|
|||||||
void LockAllowPlay() noexcept;
|
void LockAllowPlay() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* An error has occurred and this output is defunct.
|
||||||
|
*/
|
||||||
|
void Failure(std::exception_ptr e) noexcept {
|
||||||
|
last_error = e;
|
||||||
|
|
||||||
|
/* don't automatically reopen this device for 10
|
||||||
|
seconds */
|
||||||
|
fail_timer.Update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs inside the OutputThread.
|
* Runs inside the OutputThread.
|
||||||
* Caller must lock the mutex.
|
* Caller must lock the mutex.
|
||||||
|
@@ -109,8 +109,7 @@ AudioOutputControl::InternalEnable() noexcept
|
|||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LogError(std::current_exception());
|
LogError(std::current_exception());
|
||||||
fail_timer.Update();
|
Failure(std::current_exception());
|
||||||
last_error = std::current_exception();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,8 +161,7 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
|
|||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LogError(std::current_exception());
|
LogError(std::current_exception());
|
||||||
fail_timer.Update();
|
Failure(std::current_exception());
|
||||||
last_error = std::current_exception();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f != in_audio_format || f != output->out_audio_format)
|
if (f != in_audio_format || f != output->out_audio_format)
|
||||||
@@ -234,13 +232,8 @@ try {
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
FormatError(std::current_exception(),
|
FormatError(std::current_exception(),
|
||||||
"Failed to filter for %s", GetLogName());
|
"Failed to filter for %s", GetLogName());
|
||||||
last_error = std::current_exception();
|
Failure(std::current_exception());
|
||||||
|
|
||||||
InternalClose(false);
|
InternalClose(false);
|
||||||
|
|
||||||
/* don't automatically reopen this device for 10
|
|
||||||
seconds */
|
|
||||||
fail_timer.Update();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,15 +273,9 @@ AudioOutputControl::PlayChunk() noexcept
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
FormatError(std::current_exception(),
|
FormatError(std::current_exception(),
|
||||||
"Failed to play on %s", GetLogName());
|
"Failed to play on %s", GetLogName());
|
||||||
last_error = std::current_exception();
|
Failure(std::current_exception());
|
||||||
|
|
||||||
InternalClose(false);
|
InternalClose(false);
|
||||||
|
|
||||||
/* don't automatically reopen this device for
|
|
||||||
10 seconds */
|
|
||||||
assert(!fail_timer.IsDefined());
|
|
||||||
fail_timer.Update();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user