Commit cfaf2ed0 authored by Max Kellermann's avatar Max Kellermann

output/pipewire: move code to CheckThrowError()

parent 60159608
...@@ -78,6 +78,11 @@ public: ...@@ -78,6 +78,11 @@ public:
} }
private: private:
void CheckThrowError() {
if (disconnected)
throw std::runtime_error("Disconnected from PipeWire");
}
void StateChanged(enum pw_stream_state state, void StateChanged(enum pw_stream_state state,
[[maybe_unused]] const char *error) noexcept { [[maybe_unused]] const char *error) noexcept {
const bool was_disconnected = disconnected; const bool was_disconnected = disconnected;
...@@ -298,8 +303,7 @@ PipeWireOutput::Play(const void *chunk, size_t size) ...@@ -298,8 +303,7 @@ PipeWireOutput::Play(const void *chunk, size_t size)
const PipeWire::ThreadLoopLock lock(thread_loop); const PipeWire::ThreadLoopLock lock(thread_loop);
while (true) { while (true) {
if (disconnected) CheckThrowError();
throw std::runtime_error("Disconnected from PipeWire");
std::size_t bytes_written = std::size_t bytes_written =
ring_buffer->push((const std::byte *)chunk, size); ring_buffer->push((const std::byte *)chunk, size);
......
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