aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_wasapi.cpp
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2021-07-06 16:05:00 +0200
committerPaul Adenot <[email protected]>2021-07-13 13:51:30 +0200
commit1437a53f8b492ed08830b9f60f27bb48a923c426 (patch)
tree9b9e14d6cf7ee7cf39735e7468963848a34532e5 /src/cubeb_wasapi.cpp
parentb6a7dee491e19b7da17098563df4c81f4c1b1f4d (diff)
downloadcubeb-1437a53f8b492ed08830b9f60f27bb48a923c426.tar.gz
cubeb-1437a53f8b492ed08830b9f60f27bb48a923c426.zip
Grab input frames on input available event and not on output available event
Diffstat (limited to 'src/cubeb_wasapi.cpp')
-rw-r--r--src/cubeb_wasapi.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index 25d9838..e0b931f 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -911,8 +911,8 @@ int trigger_async_reconfigure(cubeb_stream * stm)
/* This helper grabs all the frames available from a capture client, put them in
- * linear_input_buffer. linear_input_buffer should be cleared before the
- * callback exits. This helper does not work with exclusive mode streams. */
+ * the linear_input_buffer. This helper does not work with exclusive mode
+ * streams. */
bool get_input_buffer(cubeb_stream * stm)
{
XASSERT(has_input(stm));
@@ -1023,6 +1023,8 @@ bool get_input_buffer(cubeb_stream * stm)
offset += input_stream_samples;
}
+ ALOGV("get_input_buffer: got %d frames", offset);
+
XASSERT(stm->linear_input_buffer->length() >= offset);
return true;
@@ -1091,11 +1093,6 @@ refill_callback_duplex(cubeb_stream * stm)
XASSERT(has_input(stm) && has_output(stm));
- rv = get_input_buffer(stm);
- if (!rv) {
- return rv;
- }
-
input_frames = stm->linear_input_buffer->length() / stm->input_stream_params.channels;
rv = get_output_buffer(stm, output_buffer, output_frames);
@@ -1363,10 +1360,18 @@ wasapi_stream_render_loop(LPVOID stream)
(!has_input(stm) && has_output(stm)));
is_playing = stm->refill_callback(stm);
break;
- case WAIT_OBJECT_0 + 3: /* input available */
- if (has_input(stm) && has_output(stm)) { continue; }
- is_playing = stm->refill_callback(stm);
+ case WAIT_OBJECT_0 + 3: { /* input available */
+ HRESULT rv = get_input_buffer(stm);
+ if (FAILED(rv)) {
+ return rv;
+ }
+
+ if (!has_output(stm)) {
+ is_playing = stm->refill_callback(stm);
+ }
+
break;
+ }
case WAIT_TIMEOUT:
XASSERT(stm->shutdown_event == wait_array[0]);
if (++timeout_count >= timeout_limit) {