aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2021-02-17 13:28:51 +1300
committerMatthew Gregan <[email protected]>2021-02-17 22:05:37 +1300
commit8942382280721117900072945767cece14eef046 (patch)
tree8eaf1f4f11b14da73a6e62b017755e97f800f31a
parent9beb8ed0c91f1b6ed7769d2c28c94a1d78b6c6f1 (diff)
downloadcubeb-8942382280721117900072945767cece14eef046.tar.gz
cubeb-8942382280721117900072945767cece14eef046.zip
Remove cubeb_stream_reset_default_device API.
-rw-r--r--include/cubeb/cubeb.h8
-rw-r--r--src/cubeb-internal.h1
-rw-r--r--src/cubeb.c14
-rw-r--r--src/cubeb_aaudio.cpp1
-rw-r--r--src/cubeb_alsa.c1
-rw-r--r--src/cubeb_audiotrack.c1
-rw-r--r--src/cubeb_audiounit.cpp1
-rw-r--r--src/cubeb_jack.cpp1
-rw-r--r--src/cubeb_kai.c1
-rw-r--r--src/cubeb_opensl.c1
-rw-r--r--src/cubeb_oss.c1
-rw-r--r--src/cubeb_pulse.c1
-rw-r--r--src/cubeb_sndio.c1
-rw-r--r--src/cubeb_sun.c1
-rw-r--r--src/cubeb_wasapi.cpp28
-rw-r--r--src/cubeb_winmm.c1
-rw-r--r--test/test_sanity.cpp59
17 files changed, 13 insertions, 109 deletions
diff --git a/include/cubeb/cubeb.h b/include/cubeb/cubeb.h
index afe7c8e..b678f73 100644
--- a/include/cubeb/cubeb.h
+++ b/include/cubeb/cubeb.h
@@ -552,14 +552,6 @@ CUBEB_EXPORT int cubeb_stream_start(cubeb_stream * stream);
@retval CUBEB_ERROR */
CUBEB_EXPORT int cubeb_stream_stop(cubeb_stream * stream);
-/** Reset stream to the default device.
- @param stream
- @retval CUBEB_OK
- @retval CUBEB_ERROR_INVALID_PARAMETER
- @retval CUBEB_ERROR_NOT_SUPPORTED
- @retval CUBEB_ERROR */
-CUBEB_EXPORT int cubeb_stream_reset_default_device(cubeb_stream * stream);
-
/** Get the current stream playback position.
@param stream
@param position Playback position in frames.
diff --git a/src/cubeb-internal.h b/src/cubeb-internal.h
index 9d3d1dd..406dca4 100644
--- a/src/cubeb-internal.h
+++ b/src/cubeb-internal.h
@@ -60,7 +60,6 @@ struct cubeb_ops {
void (* stream_destroy)(cubeb_stream * stream);
int (* stream_start)(cubeb_stream * stream);
int (* stream_stop)(cubeb_stream * stream);
- int (* stream_reset_default_device)(cubeb_stream * stream);
int (* stream_get_position)(cubeb_stream * stream, uint64_t * position);
int (* stream_get_latency)(cubeb_stream * stream, uint32_t * latency);
int (* stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);
diff --git a/src/cubeb.c b/src/cubeb.c
index 8757440..c43c996 100644
--- a/src/cubeb.c
+++ b/src/cubeb.c
@@ -405,20 +405,6 @@ cubeb_stream_stop(cubeb_stream * stream)
}
int
-cubeb_stream_reset_default_device(cubeb_stream * stream)
-{
- if (!stream) {
- return CUBEB_ERROR_INVALID_PARAMETER;
- }
-
- if (!stream->context->ops->stream_reset_default_device) {
- return CUBEB_ERROR_NOT_SUPPORTED;
- }
-
- return stream->context->ops->stream_reset_default_device(stream);
-}
-
-int
cubeb_stream_get_position(cubeb_stream * stream, uint64_t * position)
{
if (!stream || !position) {
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index f00f228..0ac6dd2 100644
--- a/src/cubeb_aaudio.cpp
+++ b/src/cubeb_aaudio.cpp
@@ -1450,7 +1450,6 @@ const static struct cubeb_ops aaudio_ops = {
/*.stream_destroy =*/aaudio_stream_destroy,
/*.stream_start =*/aaudio_stream_start,
/*.stream_stop =*/aaudio_stream_stop,
- /*.stream_reset_default_device =*/NULL,
/*.stream_get_position =*/aaudio_stream_get_position,
/*.stream_get_latency =*/aaudio_stream_get_latency,
/*.stream_get_input_latency =*/aaudio_stream_get_input_latency,
diff --git a/src/cubeb_alsa.c b/src/cubeb_alsa.c
index deac271..cbed0df 100644
--- a/src/cubeb_alsa.c
+++ b/src/cubeb_alsa.c
@@ -1441,7 +1441,6 @@ static struct cubeb_ops const alsa_ops = {
.stream_destroy = alsa_stream_destroy,
.stream_start = alsa_stream_start,
.stream_stop = alsa_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = alsa_stream_get_position,
.stream_get_latency = alsa_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_audiotrack.c b/src/cubeb_audiotrack.c
index 6496df0..6c7e176 100644
--- a/src/cubeb_audiotrack.c
+++ b/src/cubeb_audiotrack.c
@@ -430,7 +430,6 @@ static struct cubeb_ops const audiotrack_ops = {
.stream_destroy = audiotrack_stream_destroy,
.stream_start = audiotrack_stream_start,
.stream_stop = audiotrack_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = audiotrack_stream_get_position,
.stream_get_latency = audiotrack_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp
index f0586a1..9d800fb 100644
--- a/src/cubeb_audiounit.cpp
+++ b/src/cubeb_audiounit.cpp
@@ -3618,7 +3618,6 @@ cubeb_ops const audiounit_ops = {
/*.stream_destroy =*/ audiounit_stream_destroy,
/*.stream_start =*/ audiounit_stream_start,
/*.stream_stop =*/ audiounit_stream_stop,
- /*.stream_reset_default_device =*/ nullptr,
/*.stream_get_position =*/ audiounit_stream_get_position,
/*.stream_get_latency =*/ audiounit_stream_get_latency,
/*.stream_get_input_latency =*/ NULL,
diff --git a/src/cubeb_jack.cpp b/src/cubeb_jack.cpp
index 4d5b722..1a1305f 100644
--- a/src/cubeb_jack.cpp
+++ b/src/cubeb_jack.cpp
@@ -135,7 +135,6 @@ static struct cubeb_ops const cbjack_ops = {
.stream_destroy = cbjack_stream_destroy,
.stream_start = cbjack_stream_start,
.stream_stop = cbjack_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = cbjack_stream_get_position,
.stream_get_latency = cbjack_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_kai.c b/src/cubeb_kai.c
index 36eaf12..c563896 100644
--- a/src/cubeb_kai.c
+++ b/src/cubeb_kai.c
@@ -358,7 +358,6 @@ static struct cubeb_ops const kai_ops = {
/*.stream_destroy =*/ kai_stream_destroy,
/*.stream_start =*/ kai_stream_start,
/*.stream_stop =*/ kai_stream_stop,
- /*.stream_reset_default_device =*/ NULL,
/*.stream_get_position =*/ kai_stream_get_position,
/*.stream_get_latency = */ kai_stream_get_latency,
/*.stream_get_input_latency = */ NULL,
diff --git a/src/cubeb_opensl.c b/src/cubeb_opensl.c
index a680019..8058ff8 100644
--- a/src/cubeb_opensl.c
+++ b/src/cubeb_opensl.c
@@ -1747,7 +1747,6 @@ static struct cubeb_ops const opensl_ops = {
.stream_destroy = opensl_stream_destroy,
.stream_start = opensl_stream_start,
.stream_stop = opensl_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = opensl_stream_get_position,
.stream_get_latency = opensl_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_oss.c b/src/cubeb_oss.c
index 8c44c9e..c3b5221 100644
--- a/src/cubeb_oss.c
+++ b/src/cubeb_oss.c
@@ -1282,7 +1282,6 @@ static struct cubeb_ops const oss_ops = {
.stream_destroy = oss_stream_destroy,
.stream_start = oss_stream_start,
.stream_stop = oss_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = oss_stream_get_position,
.stream_get_latency = oss_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_pulse.c b/src/cubeb_pulse.c
index c7e9d1c..6ab2091 100644
--- a/src/cubeb_pulse.c
+++ b/src/cubeb_pulse.c
@@ -1625,7 +1625,6 @@ static struct cubeb_ops const pulse_ops = {
.stream_destroy = pulse_stream_destroy,
.stream_start = pulse_stream_start,
.stream_stop = pulse_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = pulse_stream_get_position,
.stream_get_latency = pulse_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_sndio.c b/src/cubeb_sndio.c
index 41fa59a..dfa4137 100644
--- a/src/cubeb_sndio.c
+++ b/src/cubeb_sndio.c
@@ -658,7 +658,6 @@ static struct cubeb_ops const sndio_ops = {
.stream_destroy = sndio_stream_destroy,
.stream_start = sndio_stream_start,
.stream_stop = sndio_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = sndio_stream_get_position,
.stream_get_latency = sndio_stream_get_latency,
.stream_set_volume = sndio_stream_set_volume,
diff --git a/src/cubeb_sun.c b/src/cubeb_sun.c
index 206de44..dda0919 100644
--- a/src/cubeb_sun.c
+++ b/src/cubeb_sun.c
@@ -718,7 +718,6 @@ static struct cubeb_ops const sun_ops = {
.stream_destroy = sun_stream_destroy,
.stream_start = sun_stream_start,
.stream_stop = sun_stream_stop,
- .stream_reset_default_device = NULL,
.stream_get_position = sun_stream_get_position,
.stream_get_latency = sun_stream_get_latency,
.stream_get_input_latency = NULL,
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index f460a09..535a7ae 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -861,7 +861,17 @@ refill(cubeb_stream * stm, void * input_buffer, long input_frames_count,
return out_frames;
}
-int wasapi_stream_reset_default_device(cubeb_stream * stm);
+int 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;
+}
+
/* 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
@@ -890,7 +900,7 @@ bool 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");
- wasapi_stream_reset_default_device(stm);
+ trigger_async_reconfigure(stm);
return true;
}
@@ -993,7 +1003,7 @@ bool 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");
- wasapi_stream_reset_default_device(stm);
+ trigger_async_reconfigure(stm);
return true;
}
@@ -2743,17 +2753,6 @@ int wasapi_stream_stop(cubeb_stream * stm)
return CUBEB_OK;
}
-int wasapi_stream_reset_default_device(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;
-}
-
int wasapi_stream_get_position(cubeb_stream * stm, uint64_t * position)
{
XASSERT(stm && position);
@@ -3253,7 +3252,6 @@ cubeb_ops const wasapi_ops = {
/*.stream_destroy =*/ wasapi_stream_destroy,
/*.stream_start =*/ wasapi_stream_start,
/*.stream_stop =*/ wasapi_stream_stop,
- /*.stream_reset_default_device =*/ wasapi_stream_reset_default_device,
/*.stream_get_position =*/ wasapi_stream_get_position,
/*.stream_get_latency =*/ wasapi_stream_get_latency,
/*.stream_get_input_latency =*/ wasapi_stream_get_input_latency,
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c
index a94c2a1..6498196 100644
--- a/src/cubeb_winmm.c
+++ b/src/cubeb_winmm.c
@@ -1056,7 +1056,6 @@ static struct cubeb_ops const winmm_ops = {
/*.stream_destroy =*/ winmm_stream_destroy,
/*.stream_start =*/ winmm_stream_start,
/*.stream_stop =*/ winmm_stream_stop,
- /*.stream_reset_default_device =*/ NULL,
/*.stream_get_position =*/ winmm_stream_get_position,
/*.stream_get_latency = */ winmm_stream_get_latency,
/*.stream_get_input_latency = */ NULL,
diff --git a/test/test_sanity.cpp b/test/test_sanity.cpp
index e1a60d0..42a591d 100644
--- a/test/test_sanity.cpp
+++ b/test/test_sanity.cpp
@@ -642,65 +642,6 @@ TEST(cubeb, drain)
do_drain = 0;
}
-TEST(cubeb, device_reset)
-{
- int r;
- cubeb * ctx;
- cubeb_stream * stream;
- cubeb_stream_params params;
- uint64_t position;
-
- r = common_init(&ctx, "test_sanity");
- ASSERT_EQ(r, CUBEB_OK);
- ASSERT_NE(ctx, nullptr);
-
- if (strcmp(cubeb_get_backend_id(ctx), "wasapi")) {
- // cubeb_stream_reset_default_device is only useful and implemented in the
- // WASAPI backend.
- return;
- }
-
- params.format = STREAM_FORMAT;
- params.rate = STREAM_RATE;
- params.channels = STREAM_CHANNELS;
- params.layout = STREAM_LAYOUT;
- params.prefs = CUBEB_STREAM_PREF_NONE;
-
- r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
- test_data_callback, test_state_callback, &dummy);
- ASSERT_EQ(r, CUBEB_OK);
- ASSERT_NE(stream, nullptr);
-
- r = cubeb_stream_start(stream);
- ASSERT_EQ(r, CUBEB_OK);
-
- uint32_t iterations = 5;
- uint64_t previous_position = 0;
- while (iterations--) {
- r = cubeb_stream_get_position(stream, &position);
- ASSERT_EQ(r, CUBEB_OK);
- ASSERT_GE(position, previous_position);
- previous_position = position;
- delay(100);
- }
-
- r = cubeb_stream_reset_default_device(stream);
- ASSERT_EQ(r, CUBEB_OK);
-
- iterations = 5;
- while (iterations--) {
- r = cubeb_stream_get_position(stream, &position);
- ASSERT_EQ(r, CUBEB_OK);
- ASSERT_GE(position, previous_position);
- previous_position = position;
- delay(100);
- }
-
- cubeb_stream_stop(stream);
- cubeb_stream_destroy(stream);
- cubeb_destroy(ctx);
-}
-
TEST(cubeb, DISABLED_eos_during_prefill)
{
// This test needs to be implemented.