diff options
author | Chris Robinson <[email protected]> | 2021-09-13 14:30:38 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-09-13 14:30:38 -0700 |
commit | 302d662c0a597fe328b5c81492103e34f208c38a (patch) | |
tree | b8d60f6c71db53de7a377a9ddbf5c279d362b994 /alc | |
parent | 9c136bb3b4e7651cd67c1661c31ac7ed730c4646 (diff) |
Wait for the pipewire capture stream to start before returning
Diffstat (limited to 'alc')
-rw-r--r-- | alc/backends/pipewire.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 6501a194..a56e05b9 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -1629,6 +1629,15 @@ void PipeWireCapture::start() if(int res{pw_stream_set_active(mStream.get(), true)}) throw al::backend_exception{al::backend_error::DeviceError, "Failed to start PipeWire stream (res: %d)", res}; + + pw_stream_state state{}; + const char *error{}; + while((state=pw_stream_get_state(mStream.get(), &error)) == PW_STREAM_STATE_PAUSED) + mLoop.wait(); + + if(state == PW_STREAM_STATE_ERROR) + throw al::backend_exception{al::backend_error::DeviceError, + "PipeWire stream error: %s", error ? error : "(unknown)"}; } void PipeWireCapture::stop() @@ -1638,7 +1647,6 @@ void PipeWireCapture::stop() throw al::backend_exception{al::backend_error::DeviceError, "Failed to stop PipeWire stream (res: %d)", res}; - /* Wait for the stream to stop playing. */ pw_stream_state state{}; while((state=pw_stream_get_state(mStream.get(), nullptr)) == PW_STREAM_STATE_STREAMING) mLoop.wait(); |