aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChun-Min Chang <[email protected]>2022-03-22 13:48:44 -0700
committerMatthew Gregan <[email protected]>2022-03-24 10:27:52 +1300
commit2f50db3669bdef605f6ccc10a3f9d0e9246e1374 (patch)
tree56339e3488eda880fdd1dbade6deb3039b788728
parent4bca265fdcbff5b4b2baef922164e0d4c6f6511d (diff)
downloadcubeb-2f50db3669bdef605f6ccc10a3f9d0e9246e1374.tar.gz
cubeb-2f50db3669bdef605f6ccc10a3f9d0e9246e1374.zip
Fire error callback when reinit fails
-rw-r--r--src/cubeb_wasapi.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index 2fbbf47..ca183db 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -946,16 +946,15 @@ refill(cubeb_stream * stm, void * input_buffer, long input_frames_count,
return out_frames;
}
-int
+bool
trigger_async_reconfigure(cubeb_stream * stm)
{
XASSERT(stm && stm->reconfigure_event);
BOOL ok = SetEvent(stm->reconfigure_event);
if (!ok) {
LOG("SetEvent on reconfigure_event failed: %lx", GetLastError());
- return CUBEB_ERROR;
}
- return CUBEB_OK;
+ return static_cast<bool>(ok);
}
/* This helper grabs all the frames available from a capture client, put them in
@@ -985,7 +984,10 @@ get_input_buffer(cubeb_stream * stm)
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
- trigger_async_reconfigure(stm);
+ if (!trigger_async_reconfigure(stm)) {
+ stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
+ return false;
+ }
return true;
}
@@ -1091,7 +1093,10 @@ get_output_buffer(cubeb_stream * stm, void *& buffer, size_t & frame_count)
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
- trigger_async_reconfigure(stm);
+ if (!trigger_async_reconfigure(stm)) {
+ stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
+ return false;
+ }
return true;
}