Skip to content

Commit 2b369ae

Browse files
committed
Remove cubeb_stream_get_current_device
Signed-off-by: Marcin Serwin <[email protected]>
1 parent fdb3bc1 commit 2b369ae

17 files changed

+0
-361
lines changed

include/cubeb/cubeb.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,6 @@ typedef struct {
285285
WASAPI backend; others should use cubeb_set_input_processing_params. */
286286
} cubeb_stream_params;
287287

288-
/** Audio device description */
289-
typedef struct {
290-
char * output_name; /**< The name of the output device */
291-
char * input_name; /**< The name of the input device */
292-
} cubeb_device;
293-
294288
/** Stream states signaled via state_callback. */
295289
typedef enum {
296290
CUBEB_STATE_STARTED, /**< Stream started. */
@@ -670,17 +664,6 @@ cubeb_stream_set_volume(cubeb_stream * stream, float volume);
670664
CUBEB_EXPORT int
671665
cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name);
672666

673-
/** Get the current output device for this stream.
674-
@param stm the stream for which to query the current output device
675-
@param device a pointer in which the current output device will be stored.
676-
@retval CUBEB_OK in case of success
677-
@retval CUBEB_ERROR_INVALID_PARAMETER if either stm, device or count are
678-
invalid pointers
679-
@retval CUBEB_ERROR_NOT_SUPPORTED */
680-
CUBEB_EXPORT int
681-
cubeb_stream_get_current_device(cubeb_stream * stm,
682-
cubeb_device ** const device);
683-
684667
/** Set input mute state for this stream. Some platforms notify the user when an
685668
application is accessing audio input. When all inputs are muted they can
686669
prove to the user that the application is not actively capturing any input.
@@ -705,15 +688,6 @@ CUBEB_EXPORT int
705688
cubeb_stream_set_input_processing_params(cubeb_stream * stream,
706689
cubeb_input_processing_params params);
707690

708-
/** Destroy a cubeb_device structure.
709-
@param stream the stream passed in cubeb_stream_get_current_device
710-
@param devices the devices to destroy
711-
@retval CUBEB_OK in case of success
712-
@retval CUBEB_ERROR_INVALID_PARAMETER if devices is an invalid pointer
713-
@retval CUBEB_ERROR_NOT_SUPPORTED */
714-
CUBEB_EXPORT int
715-
cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * devices);
716-
717691
/** Set a callback to be notified when the output device changes.
718692
@param stream the stream for which to set the callback.
719693
@param device_changed_callback a function called whenever the device has

src/cubeb-internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,9 @@ struct cubeb_ops {
6262
int (*stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);
6363
int (*stream_set_volume)(cubeb_stream * stream, float volumes);
6464
int (*stream_set_name)(cubeb_stream * stream, char const * stream_name);
65-
int (*stream_get_current_device)(cubeb_stream * stream,
66-
cubeb_device ** const device);
6765
int (*stream_set_input_mute)(cubeb_stream * stream, int mute);
6866
int (*stream_set_input_processing_params)(
6967
cubeb_stream * stream, cubeb_input_processing_params params);
70-
int (*stream_device_destroy)(cubeb_stream * stream, cubeb_device * device);
7168
int (*stream_register_device_changed_callback)(
7269
cubeb_stream * stream,
7370
cubeb_device_changed_callback device_changed_callback);

src/cubeb.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -557,21 +557,6 @@ cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name)
557557
return stream->context->ops->stream_set_name(stream, stream_name);
558558
}
559559

560-
int
561-
cubeb_stream_get_current_device(cubeb_stream * stream,
562-
cubeb_device ** const device)
563-
{
564-
if (!stream || !device) {
565-
return CUBEB_ERROR_INVALID_PARAMETER;
566-
}
567-
568-
if (!stream->context->ops->stream_get_current_device) {
569-
return CUBEB_ERROR_NOT_SUPPORTED;
570-
}
571-
572-
return stream->context->ops->stream_get_current_device(stream, device);
573-
}
574-
575560
int
576561
cubeb_stream_set_input_mute(cubeb_stream * stream, int mute)
577562
{
@@ -602,20 +587,6 @@ cubeb_stream_set_input_processing_params(cubeb_stream * stream,
602587
params);
603588
}
604589

605-
int
606-
cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
607-
{
608-
if (!stream || !device) {
609-
return CUBEB_ERROR_INVALID_PARAMETER;
610-
}
611-
612-
if (!stream->context->ops->stream_device_destroy) {
613-
return CUBEB_ERROR_NOT_SUPPORTED;
614-
}
615-
616-
return stream->context->ops->stream_device_destroy(stream, device);
617-
}
618-
619590
int
620591
cubeb_stream_register_device_changed_callback(
621592
cubeb_stream * stream,

src/cubeb_aaudio.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,8 @@ const static struct cubeb_ops aaudio_ops = {
19541954
/*.stream_get_input_latency =*/aaudio_stream_get_input_latency,
19551955
/*.stream_set_volume =*/aaudio_stream_set_volume,
19561956
/*.stream_set_name =*/nullptr,
1957-
/*.stream_get_current_device =*/nullptr,
19581957
/*.stream_set_input_mute =*/nullptr,
19591958
/*.stream_set_input_processing_params =*/nullptr,
1960-
/*.stream_device_destroy =*/nullptr,
19611959
/*.stream_register_device_changed_callback =*/nullptr,
19621960
/*.register_device_collection_changed =*/nullptr};
19631961

src/cubeb_alsa.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,9 +1485,7 @@ static struct cubeb_ops const alsa_ops = {
14851485
.stream_get_input_latency = NULL,
14861486
.stream_set_volume = alsa_stream_set_volume,
14871487
.stream_set_name = NULL,
1488-
.stream_get_current_device = NULL,
14891488
.stream_set_input_mute = NULL,
14901489
.stream_set_input_processing_params = NULL,
1491-
.stream_device_destroy = NULL,
14921490
.stream_register_device_changed_callback = NULL,
14931491
.register_device_collection_changed = NULL};

src/cubeb_audiotrack.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,7 @@ static struct cubeb_ops const audiotrack_ops = {
467467
.stream_get_input_latency = NULL,
468468
.stream_set_volume = audiotrack_stream_set_volume,
469469
.stream_set_name = NULL,
470-
.stream_get_current_device = NULL,
471470
.stream_set_input_mute = NULL,
472471
.stream_set_input_processing_params = NULL,
473-
.stream_device_destroy = NULL,
474472
.stream_register_device_changed_callback = NULL,
475473
.register_device_collection_changed = NULL};

src/cubeb_audiounit.cpp

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,109 +3067,6 @@ audiounit_stream_set_volume(cubeb_stream * stm, float volume)
30673067
return CUBEB_OK;
30683068
}
30693069

3070-
unique_ptr<char[]>
3071-
convert_uint32_into_string(UInt32 data)
3072-
{
3073-
// Simply create an empty string if no data.
3074-
size_t size = data == 0 ? 0 : 4; // 4 bytes for uint32.
3075-
auto str = unique_ptr<char[]>{new char[size + 1]}; // + 1 for '\0'.
3076-
str[size] = '\0';
3077-
if (size < 4) {
3078-
return str;
3079-
}
3080-
3081-
// Reverse 0xWXYZ into 0xZYXW.
3082-
str[0] = (char)(data >> 24);
3083-
str[1] = (char)(data >> 16);
3084-
str[2] = (char)(data >> 8);
3085-
str[3] = (char)(data);
3086-
return str;
3087-
}
3088-
3089-
int
3090-
audiounit_get_default_device_datasource(cubeb_device_type type, UInt32 * data)
3091-
{
3092-
AudioDeviceID id = audiounit_get_default_device_id(type);
3093-
if (id == kAudioObjectUnknown) {
3094-
return CUBEB_ERROR;
3095-
}
3096-
3097-
UInt32 size = sizeof(*data);
3098-
/* This fails with some USB headsets (e.g., Plantronic .Audio 628). */
3099-
OSStatus r = AudioObjectGetPropertyData(
3100-
id,
3101-
type == CUBEB_DEVICE_TYPE_INPUT ? &INPUT_DATA_SOURCE_PROPERTY_ADDRESS
3102-
: &OUTPUT_DATA_SOURCE_PROPERTY_ADDRESS,
3103-
0, NULL, &size, data);
3104-
if (r != noErr) {
3105-
*data = 0;
3106-
}
3107-
3108-
return CUBEB_OK;
3109-
}
3110-
3111-
int
3112-
audiounit_get_default_device_name(cubeb_stream * stm,
3113-
cubeb_device * const device,
3114-
cubeb_device_type type)
3115-
{
3116-
assert(stm);
3117-
assert(device);
3118-
3119-
UInt32 data;
3120-
int r = audiounit_get_default_device_datasource(type, &data);
3121-
if (r != CUBEB_OK) {
3122-
return r;
3123-
}
3124-
char ** name = type == CUBEB_DEVICE_TYPE_INPUT ? &device->input_name
3125-
: &device->output_name;
3126-
*name = convert_uint32_into_string(data).release();
3127-
if (!strlen(*name)) { // empty string.
3128-
LOG("(%p) name of %s device is empty!", stm,
3129-
type == CUBEB_DEVICE_TYPE_INPUT ? "input" : "output");
3130-
}
3131-
return CUBEB_OK;
3132-
}
3133-
3134-
int
3135-
audiounit_stream_get_current_device(cubeb_stream * stm,
3136-
cubeb_device ** const device)
3137-
{
3138-
#if TARGET_OS_IPHONE
3139-
// TODO
3140-
return CUBEB_ERROR_NOT_SUPPORTED;
3141-
#else
3142-
*device = new cubeb_device;
3143-
if (!*device) {
3144-
return CUBEB_ERROR;
3145-
}
3146-
PodZero(*device, 1);
3147-
3148-
int r =
3149-
audiounit_get_default_device_name(stm, *device, CUBEB_DEVICE_TYPE_OUTPUT);
3150-
if (r != CUBEB_OK) {
3151-
return r;
3152-
}
3153-
3154-
r = audiounit_get_default_device_name(stm, *device, CUBEB_DEVICE_TYPE_INPUT);
3155-
if (r != CUBEB_OK) {
3156-
return r;
3157-
}
3158-
3159-
return CUBEB_OK;
3160-
#endif
3161-
}
3162-
3163-
int
3164-
audiounit_stream_device_destroy(cubeb_stream * /* stream */,
3165-
cubeb_device * device)
3166-
{
3167-
delete[] device->output_name;
3168-
delete[] device->input_name;
3169-
delete device;
3170-
return CUBEB_OK;
3171-
}
3172-
31733070
int
31743071
audiounit_stream_register_device_changed_callback(
31753072
cubeb_stream * stream,
@@ -3698,10 +3595,8 @@ cubeb_ops const audiounit_ops = {
36983595
/*.stream_get_input_latency =*/NULL,
36993596
/*.stream_set_volume =*/audiounit_stream_set_volume,
37003597
/*.stream_set_name =*/NULL,
3701-
/*.stream_get_current_device =*/audiounit_stream_get_current_device,
37023598
/*.stream_set_input_mute =*/NULL,
37033599
/*.stream_set_input_processing_params =*/NULL,
3704-
/*.stream_device_destroy =*/audiounit_stream_device_destroy,
37053600
/*.stream_register_device_changed_callback =*/
37063601
audiounit_stream_register_device_changed_callback,
37073602
/*.register_device_collection_changed =*/

src/cubeb_jack.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ cbjack_deinterleave_playback_refill_float(cubeb_stream * stream,
124124
float ** bufs_in, float ** bufs_out,
125125
jack_nframes_t nframes);
126126
static int
127-
cbjack_stream_device_destroy(cubeb_stream * stream, cubeb_device * device);
128-
static int
129-
cbjack_stream_get_current_device(cubeb_stream * stm,
130-
cubeb_device ** const device);
131-
static int
132127
cbjack_enumerate_devices(cubeb * context, cubeb_device_type type,
133128
cubeb_device_collection * collection);
134129
static int
@@ -173,10 +168,8 @@ static struct cubeb_ops const cbjack_ops = {
173168
.stream_get_input_latency = NULL,
174169
.stream_set_volume = cbjack_stream_set_volume,
175170
.stream_set_name = NULL,
176-
.stream_get_current_device = cbjack_stream_get_current_device,
177171
.stream_set_input_mute = NULL,
178172
.stream_set_input_processing_params = NULL,
179-
.stream_device_destroy = cbjack_stream_device_destroy,
180173
.stream_register_device_changed_callback = NULL,
181174
.register_device_collection_changed = NULL};
182175

@@ -1073,43 +1066,6 @@ cbjack_stream_set_volume(cubeb_stream * stm, float volume)
10731066
return CUBEB_OK;
10741067
}
10751068

1076-
static int
1077-
cbjack_stream_get_current_device(cubeb_stream * stm,
1078-
cubeb_device ** const device)
1079-
{
1080-
*device = (cubeb_device *)calloc(1, sizeof(cubeb_device));
1081-
if (*device == NULL)
1082-
return CUBEB_ERROR;
1083-
1084-
const char * j_in = JACK_DEFAULT_IN;
1085-
const char * j_out = JACK_DEFAULT_OUT;
1086-
const char * empty = "";
1087-
1088-
if (stm->devs == DUPLEX) {
1089-
(*device)->input_name = strdup(j_in);
1090-
(*device)->output_name = strdup(j_out);
1091-
} else if (stm->devs == IN_ONLY) {
1092-
(*device)->input_name = strdup(j_in);
1093-
(*device)->output_name = strdup(empty);
1094-
} else if (stm->devs == OUT_ONLY) {
1095-
(*device)->input_name = strdup(empty);
1096-
(*device)->output_name = strdup(j_out);
1097-
}
1098-
1099-
return CUBEB_OK;
1100-
}
1101-
1102-
static int
1103-
cbjack_stream_device_destroy(cubeb_stream * /*stream*/, cubeb_device * device)
1104-
{
1105-
if (device->input_name)
1106-
free(device->input_name);
1107-
if (device->output_name)
1108-
free(device->output_name);
1109-
free(device);
1110-
return CUBEB_OK;
1111-
}
1112-
11131069
static int
11141070
cbjack_enumerate_devices(cubeb * context, cubeb_device_type type,
11151071
cubeb_device_collection * collection)

src/cubeb_kai.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,7 @@ static struct cubeb_ops const kai_ops = {
364364
/*.stream_get_input_latency = */ NULL,
365365
/*.stream_set_volume =*/kai_stream_set_volume,
366366
/*.stream_set_name =*/NULL,
367-
/*.stream_get_current_device =*/NULL,
368367
/*.stream_set_input_mute =*/NULL,
369368
/*.stream_set_input_processing_params =*/NULL,
370-
/*.stream_device_destroy =*/NULL,
371369
/*.stream_register_device_changed_callback=*/NULL,
372370
/*.register_device_collection_changed=*/NULL};

src/cubeb_opensl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,9 +1950,7 @@ struct cubeb_ops const opensl_ops = {
19501950
.stream_get_input_latency = nullptr,
19511951
.stream_set_volume = opensl_stream_set_volume,
19521952
.stream_set_name = nullptr,
1953-
.stream_get_current_device = nullptr,
19541953
.stream_set_input_mute = nullptr,
19551954
.stream_set_input_processing_params = nullptr,
1956-
.stream_device_destroy = nullptr,
19571955
.stream_register_device_changed_callback = nullptr,
19581956
.register_device_collection_changed = nullptr};

0 commit comments

Comments
 (0)