aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-05-12 22:37:21 -0700
committerChris Robinson <[email protected]>2022-05-13 15:40:15 -0700
commit82c8e87ec77f4dff522d9ab62fdc0bd70f8214fb (patch)
tree5bb4bcff770d6135f6aabf2c57edb2f1bcc2c34c /alc/backends
parentdbf5306828f811286feb7e45774cfc46b117da05 (diff)
Keep some variables local to where they're needed
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/pipewire.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 165579b2..3cef0b2a 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -1533,11 +1533,10 @@ bool PipeWirePlayback::reset()
"Error connecting PipeWire stream (res: %d)", res};
/* Wait for the stream to become paused (ready to start streaming). */
- pw_stream_state state{};
- const char *error{};
- plock.wait([stream=mStream.get(),&state,&error]()
+ plock.wait([stream=mStream.get()]()
{
- state = pw_stream_get_state(stream, &error);
+ const char *error{};
+ pw_stream_state state{pw_stream_get_state(stream, &error)};
if(state == PW_STREAM_STATE_ERROR)
throw al::backend_exception{al::backend_error::DeviceError,
"Error connecting PipeWire stream: \"%s\"", error};
@@ -1568,18 +1567,17 @@ void PipeWirePlayback::start()
/* Wait for the stream to start playing (would be nice to not, but we need
* the actual update size which is only available after starting).
*/
- pw_stream_state state{};
- const char *error{};
- plock.wait([stream=mStream.get(),&state,&error]()
+ plock.wait([stream=mStream.get()]()
{
- state = pw_stream_get_state(stream, &error);
- return state != PW_STREAM_STATE_PAUSED;
+ const char *error{};
+ pw_stream_state state{pw_stream_get_state(stream, &error)};
+ if(state == PW_STREAM_STATE_ERROR)
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "PipeWire stream error: %s", error ? error : "(unknown)"};
+ return state == PW_STREAM_STATE_STREAMING;
});
- if(state == PW_STREAM_STATE_ERROR)
- throw al::backend_exception{al::backend_error::DeviceError,
- "PipeWire stream error: %s", error ? error : "(unknown)"};
- if(state == PW_STREAM_STATE_STREAMING && mRateMatch && mRateMatch->size)
+ if(mRateMatch && mRateMatch->size)
{
mDevice->UpdateSize = mRateMatch->size;
mDevice->BufferSize = mDevice->UpdateSize * 2;
@@ -1902,11 +1900,10 @@ void PipeWireCapture::open(const char *name)
"Error connecting PipeWire stream (res: %d)", res};
/* Wait for the stream to become paused (ready to start streaming). */
- pw_stream_state state{};
- const char *error{};
- plock.wait([stream=mStream.get(),&state,&error]()
+ plock.wait([stream=mStream.get()]()
{
- state = pw_stream_get_state(stream, &error);
+ const char *error{};
+ pw_stream_state state{pw_stream_get_state(stream, &error)};
if(state == PW_STREAM_STATE_ERROR)
throw al::backend_exception{al::backend_error::DeviceError,
"Error connecting PipeWire stream: \"%s\"", error};
@@ -1929,17 +1926,15 @@ void PipeWireCapture::start()
throw al::backend_exception{al::backend_error::DeviceError,
"Failed to start PipeWire stream (res: %d)", res};
- pw_stream_state state{};
- const char *error{};
- plock.wait([stream=mStream.get(),&state,&error]()
+ plock.wait([stream=mStream.get()]()
{
- state = pw_stream_get_state(stream, &error);
- return state != PW_STREAM_STATE_PAUSED;
+ const char *error{};
+ pw_stream_state state{pw_stream_get_state(stream, &error)};
+ if(state == PW_STREAM_STATE_ERROR)
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "PipeWire stream error: %s", error ? error : "(unknown)"};
+ return state == PW_STREAM_STATE_STREAMING;
});
-
- if(state == PW_STREAM_STATE_ERROR)
- throw al::backend_exception{al::backend_error::DeviceError,
- "PipeWire stream error: %s", error ? error : "(unknown)"};
}
void PipeWireCapture::stop()