diff options
author | Matthew Gregan <[email protected]> | 2021-11-09 12:49:38 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2021-11-09 12:57:23 +1300 |
commit | af916565fd99e2577b050fe6515ad78e5cd5a8b5 (patch) | |
tree | 099121e35f3affdf2042255bc8fc7111057c55e1 /src | |
parent | 07c352c65a95cb0ed44353859b83ee494458ca63 (diff) | |
download | cubeb-get_max_req_size.tar.gz cubeb-get_max_req_size.zip |
WIP: Add cubeb_stream_get_max_request_size API.get_max_req_size
This is intended to support https://github.com/mozilla/audioipc-2/issues/124
Diffstat (limited to 'src')
-rw-r--r-- | src/cubeb-internal.h | 2 | ||||
-rw-r--r-- | src/cubeb.c | 16 | ||||
-rw-r--r-- | src/cubeb_aaudio.cpp | 1 | ||||
-rw-r--r-- | src/cubeb_alsa.c | 1 | ||||
-rw-r--r-- | src/cubeb_audiounit.cpp | 1 | ||||
-rw-r--r-- | src/cubeb_jack.cpp | 1 | ||||
-rw-r--r-- | src/cubeb_kai.c | 1 | ||||
-rw-r--r-- | src/cubeb_opensl.c | 1 | ||||
-rw-r--r-- | src/cubeb_oss.c | 1 | ||||
-rw-r--r-- | src/cubeb_pulse.c | 1 | ||||
-rw-r--r-- | src/cubeb_sndio.c | 1 | ||||
-rw-r--r-- | src/cubeb_sun.c | 1 | ||||
-rw-r--r-- | src/cubeb_wasapi.cpp | 18 | ||||
-rw-r--r-- | src/cubeb_winmm.c | 1 |
14 files changed, 47 insertions, 0 deletions
diff --git a/src/cubeb-internal.h b/src/cubeb-internal.h index 79326e1..3e03003 100644 --- a/src/cubeb-internal.h +++ b/src/cubeb-internal.h @@ -66,6 +66,8 @@ struct cubeb_ops { int (*stream_register_device_changed_callback)( cubeb_stream * stream, cubeb_device_changed_callback device_changed_callback); + int (*stream_get_max_request_size)(cubeb_stream * stream, + uint32_t * max_request_size); int (*register_device_collection_changed)( cubeb * context, cubeb_device_type devtype, cubeb_device_collection_changed_callback callback, void * user_ptr); diff --git a/src/cubeb.c b/src/cubeb.c index b3d32ee..6b542fc 100644 --- a/src/cubeb.c +++ b/src/cubeb.c @@ -501,6 +501,22 @@ cubeb_stream_get_current_device(cubeb_stream * stream, } int +cubeb_stream_get_max_request_size(cubeb_stream * stream, + uint32_t * max_request_size) +{ + if (!stream || !max_request_size) { + return CUBEB_ERROR_INVALID_PARAMETER; + } + + if (!stream->context->ops->stream_get_max_request_size) { + return CUBEB_ERROR_NOT_SUPPORTED; + } + + return stream->context->ops->stream_get_max_request_size(stream, + max_request_size); +} + +int cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * device) { if (!stream || !device) { diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp index 448ea91..a72e671 100644 --- a/src/cubeb_aaudio.cpp +++ b/src/cubeb_aaudio.cpp @@ -1460,6 +1460,7 @@ const static struct cubeb_ops aaudio_ops = { /*.stream_get_current_device =*/NULL, /*.stream_device_destroy =*/NULL, /*.stream_register_device_changed_callback =*/NULL, + /*.stream_get_max_request_size =*/NULL, /*.register_device_collection_changed =*/NULL}; extern "C" /*static*/ int diff --git a/src/cubeb_alsa.c b/src/cubeb_alsa.c index 08772dd..e367ced 100644 --- a/src/cubeb_alsa.c +++ b/src/cubeb_alsa.c @@ -1487,4 +1487,5 @@ static struct cubeb_ops const alsa_ops = { .stream_get_current_device = NULL, .stream_device_destroy = NULL, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp index 02cd134..2c5ec8b 100644 --- a/src/cubeb_audiounit.cpp +++ b/src/cubeb_audiounit.cpp @@ -3666,5 +3666,6 @@ cubeb_ops const audiounit_ops = { /*.stream_device_destroy =*/audiounit_stream_device_destroy, /*.stream_register_device_changed_callback =*/ audiounit_stream_register_device_changed_callback, + /*.stream_get_max_request_size = */ NULL, /*.register_device_collection_changed =*/ audiounit_register_device_collection_changed}; diff --git a/src/cubeb_jack.cpp b/src/cubeb_jack.cpp index 3590235..70d0581 100644 --- a/src/cubeb_jack.cpp +++ b/src/cubeb_jack.cpp @@ -175,6 +175,7 @@ static struct cubeb_ops const cbjack_ops = { .stream_get_current_device = cbjack_stream_get_current_device, .stream_device_destroy = cbjack_stream_device_destroy, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; struct cubeb_stream { diff --git a/src/cubeb_kai.c b/src/cubeb_kai.c index 0a0d676..a88ad72 100644 --- a/src/cubeb_kai.c +++ b/src/cubeb_kai.c @@ -366,4 +366,5 @@ static struct cubeb_ops const kai_ops = { /*.stream_get_current_device =*/NULL, /*.stream_device_destroy =*/NULL, /*.stream_register_device_changed_callback=*/NULL, + /*.stream_get_max_request_size =*/NULL, /*.register_device_collection_changed=*/NULL}; diff --git a/src/cubeb_opensl.c b/src/cubeb_opensl.c index 78096d5..68c2570 100644 --- a/src/cubeb_opensl.c +++ b/src/cubeb_opensl.c @@ -1792,4 +1792,5 @@ static struct cubeb_ops const opensl_ops = { .stream_get_current_device = NULL, .stream_device_destroy = NULL, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; diff --git a/src/cubeb_oss.c b/src/cubeb_oss.c index 083c37f..80e66da 100644 --- a/src/cubeb_oss.c +++ b/src/cubeb_oss.c @@ -1326,4 +1326,5 @@ static struct cubeb_ops const oss_ops = { .stream_get_current_device = oss_get_current_device, .stream_device_destroy = oss_stream_device_destroy, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; diff --git a/src/cubeb_pulse.c b/src/cubeb_pulse.c index 31a2f93..aafb616 100644 --- a/src/cubeb_pulse.c +++ b/src/cubeb_pulse.c @@ -1696,5 +1696,6 @@ static struct cubeb_ops const pulse_ops = { .stream_get_current_device = pulse_stream_get_current_device, .stream_device_destroy = pulse_stream_device_destroy, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = pulse_register_device_collection_changed}; diff --git a/src/cubeb_sndio.c b/src/cubeb_sndio.c index d7fb792..db563b4 100644 --- a/src/cubeb_sndio.c +++ b/src/cubeb_sndio.c @@ -666,4 +666,5 @@ static struct cubeb_ops const sndio_ops = { .stream_get_current_device = NULL, .stream_device_destroy = NULL, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; diff --git a/src/cubeb_sun.c b/src/cubeb_sun.c index 3b7bef7..eeca190 100644 --- a/src/cubeb_sun.c +++ b/src/cubeb_sun.c @@ -730,4 +730,5 @@ static struct cubeb_ops const sun_ops = { .stream_get_current_device = sun_get_current_device, .stream_device_destroy = sun_stream_device_destroy, .stream_register_device_changed_callback = NULL, + .stream_get_max_request_size = NULL, .register_device_collection_changed = NULL}; diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp index 9cc8a26..6f42436 100644 --- a/src/cubeb_wasapi.cpp +++ b/src/cubeb_wasapi.cpp @@ -2965,6 +2965,23 @@ wasapi_stream_set_volume(cubeb_stream * stm, float volume) return CUBEB_OK; } +// TODO: Need to implement stream_register_device_changed_callback. +int +wasapi_stream_get_max_request_size(cubeb_stream * stm, + uint32_t * max_request_size) +{ + auto_lock lock(stm->stream_reset_lock); + + if (!stm->output_client && !stm->input_client) { + return CUBEB_ERROR; + } + + *max_request_size = + std::max(stm->output_buffer_frame_count, stm->input_buffer_frame_count); + + return CUBEB_OK; +} + static char const * wstr_to_utf8(LPCWSTR str) { @@ -3382,6 +3399,7 @@ cubeb_ops const wasapi_ops = { /*.stream_get_current_device =*/NULL, /*.stream_device_destroy =*/NULL, /*.stream_register_device_changed_callback =*/NULL, + /*.stream_get_max_request_size =*/wasapi_stream_get_max_request_size, /*.register_device_collection_changed =*/ wasapi_register_device_collection_changed, }; diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c index 169b743..1052da7 100644 --- a/src/cubeb_winmm.c +++ b/src/cubeb_winmm.c @@ -1179,4 +1179,5 @@ static struct cubeb_ops const winmm_ops = { /*.stream_get_current_device =*/NULL, /*.stream_device_destroy =*/NULL, /*.stream_register_device_changed_callback=*/NULL, + /*.stream_get_max_request_size = */ NULL, /*.register_device_collection_changed =*/NULL}; |