Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions include/cubeb/cubeb.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ typedef struct {
WASAPI backend; others should use cubeb_set_input_processing_params. */
} cubeb_stream_params;

/** Audio device description */
typedef struct {
char * output_name; /**< The name of the output device */
char * input_name; /**< The name of the input device */
} cubeb_device;

/** Stream states signaled via state_callback. */
typedef enum {
CUBEB_STATE_STARTED, /**< Stream started. */
Expand Down Expand Up @@ -670,17 +664,6 @@ cubeb_stream_set_volume(cubeb_stream * stream, float volume);
CUBEB_EXPORT int
cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name);

/** Get the current output device for this stream.
@param stm the stream for which to query the current output device
@param device a pointer in which the current output device will be stored.
@retval CUBEB_OK in case of success
@retval CUBEB_ERROR_INVALID_PARAMETER if either stm, device or count are
invalid pointers
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int
cubeb_stream_get_current_device(cubeb_stream * stm,
cubeb_device ** const device);

/** Set input mute state for this stream. Some platforms notify the user when an
application is accessing audio input. When all inputs are muted they can
prove to the user that the application is not actively capturing any input.
Expand All @@ -705,15 +688,6 @@ CUBEB_EXPORT int
cubeb_stream_set_input_processing_params(cubeb_stream * stream,
cubeb_input_processing_params params);

/** Destroy a cubeb_device structure.
@param stream the stream passed in cubeb_stream_get_current_device
@param devices the devices to destroy
@retval CUBEB_OK in case of success
@retval CUBEB_ERROR_INVALID_PARAMETER if devices is an invalid pointer
@retval CUBEB_ERROR_NOT_SUPPORTED */
CUBEB_EXPORT int
cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * devices);

/** Set a callback to be notified when the output device changes.
@param stream the stream for which to set the callback.
@param device_changed_callback a function called whenever the device has
Expand Down
3 changes: 0 additions & 3 deletions src/cubeb-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ struct cubeb_ops {
int (*stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);
int (*stream_set_volume)(cubeb_stream * stream, float volumes);
int (*stream_set_name)(cubeb_stream * stream, char const * stream_name);
int (*stream_get_current_device)(cubeb_stream * stream,
cubeb_device ** const device);
int (*stream_set_input_mute)(cubeb_stream * stream, int mute);
int (*stream_set_input_processing_params)(
cubeb_stream * stream, cubeb_input_processing_params params);
int (*stream_device_destroy)(cubeb_stream * stream, cubeb_device * device);
int (*stream_register_device_changed_callback)(
cubeb_stream * stream,
cubeb_device_changed_callback device_changed_callback);
Expand Down
29 changes: 0 additions & 29 deletions src/cubeb.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,21 +557,6 @@ cubeb_stream_set_name(cubeb_stream * stream, char const * stream_name)
return stream->context->ops->stream_set_name(stream, stream_name);
}

int
cubeb_stream_get_current_device(cubeb_stream * stream,
cubeb_device ** const device)
{
if (!stream || !device) {
return CUBEB_ERROR_INVALID_PARAMETER;
}

if (!stream->context->ops->stream_get_current_device) {
return CUBEB_ERROR_NOT_SUPPORTED;
}

return stream->context->ops->stream_get_current_device(stream, device);
}

int
cubeb_stream_set_input_mute(cubeb_stream * stream, int mute)
{
Expand Down Expand Up @@ -602,20 +587,6 @@ cubeb_stream_set_input_processing_params(cubeb_stream * stream,
params);
}

int
cubeb_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
{
if (!stream || !device) {
return CUBEB_ERROR_INVALID_PARAMETER;
}

if (!stream->context->ops->stream_device_destroy) {
return CUBEB_ERROR_NOT_SUPPORTED;
}

return stream->context->ops->stream_device_destroy(stream, device);
}

int
cubeb_stream_register_device_changed_callback(
cubeb_stream * stream,
Expand Down
2 changes: 0 additions & 2 deletions src/cubeb_aaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,8 @@ const static struct cubeb_ops aaudio_ops = {
/*.stream_get_input_latency =*/aaudio_stream_get_input_latency,
/*.stream_set_volume =*/aaudio_stream_set_volume,
/*.stream_set_name =*/nullptr,
/*.stream_get_current_device =*/nullptr,
/*.stream_set_input_mute =*/nullptr,
/*.stream_set_input_processing_params =*/nullptr,
/*.stream_device_destroy =*/nullptr,
/*.stream_register_device_changed_callback =*/nullptr,
/*.register_device_collection_changed =*/nullptr};

Expand Down
2 changes: 0 additions & 2 deletions src/cubeb_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,9 +1485,7 @@ static struct cubeb_ops const alsa_ops = {
.stream_get_input_latency = NULL,
.stream_set_volume = alsa_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_set_input_mute = NULL,
.stream_set_input_processing_params = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,
.register_device_collection_changed = NULL};
2 changes: 0 additions & 2 deletions src/cubeb_audiotrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@ static struct cubeb_ops const audiotrack_ops = {
.stream_get_input_latency = NULL,
.stream_set_volume = audiotrack_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = NULL,
.stream_set_input_mute = NULL,
.stream_set_input_processing_params = NULL,
.stream_device_destroy = NULL,
.stream_register_device_changed_callback = NULL,
.register_device_collection_changed = NULL};
105 changes: 0 additions & 105 deletions src/cubeb_audiounit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3067,109 +3067,6 @@ audiounit_stream_set_volume(cubeb_stream * stm, float volume)
return CUBEB_OK;
}

unique_ptr<char[]>
convert_uint32_into_string(UInt32 data)
{
// Simply create an empty string if no data.
size_t size = data == 0 ? 0 : 4; // 4 bytes for uint32.
auto str = unique_ptr<char[]>{new char[size + 1]}; // + 1 for '\0'.
str[size] = '\0';
if (size < 4) {
return str;
}

// Reverse 0xWXYZ into 0xZYXW.
str[0] = (char)(data >> 24);
str[1] = (char)(data >> 16);
str[2] = (char)(data >> 8);
str[3] = (char)(data);
return str;
}

int
audiounit_get_default_device_datasource(cubeb_device_type type, UInt32 * data)
{
AudioDeviceID id = audiounit_get_default_device_id(type);
if (id == kAudioObjectUnknown) {
return CUBEB_ERROR;
}

UInt32 size = sizeof(*data);
/* This fails with some USB headsets (e.g., Plantronic .Audio 628). */
OSStatus r = AudioObjectGetPropertyData(
id,
type == CUBEB_DEVICE_TYPE_INPUT ? &INPUT_DATA_SOURCE_PROPERTY_ADDRESS
: &OUTPUT_DATA_SOURCE_PROPERTY_ADDRESS,
0, NULL, &size, data);
if (r != noErr) {
*data = 0;
}

return CUBEB_OK;
}

int
audiounit_get_default_device_name(cubeb_stream * stm,
cubeb_device * const device,
cubeb_device_type type)
{
assert(stm);
assert(device);

UInt32 data;
int r = audiounit_get_default_device_datasource(type, &data);
if (r != CUBEB_OK) {
return r;
}
char ** name = type == CUBEB_DEVICE_TYPE_INPUT ? &device->input_name
: &device->output_name;
*name = convert_uint32_into_string(data).release();
if (!strlen(*name)) { // empty string.
LOG("(%p) name of %s device is empty!", stm,
type == CUBEB_DEVICE_TYPE_INPUT ? "input" : "output");
}
return CUBEB_OK;
}

int
audiounit_stream_get_current_device(cubeb_stream * stm,
cubeb_device ** const device)
{
#if TARGET_OS_IPHONE
// TODO
return CUBEB_ERROR_NOT_SUPPORTED;
#else
*device = new cubeb_device;
if (!*device) {
return CUBEB_ERROR;
}
PodZero(*device, 1);

int r =
audiounit_get_default_device_name(stm, *device, CUBEB_DEVICE_TYPE_OUTPUT);
if (r != CUBEB_OK) {
return r;
}

r = audiounit_get_default_device_name(stm, *device, CUBEB_DEVICE_TYPE_INPUT);
if (r != CUBEB_OK) {
return r;
}

return CUBEB_OK;
#endif
}

int
audiounit_stream_device_destroy(cubeb_stream * /* stream */,
cubeb_device * device)
{
delete[] device->output_name;
delete[] device->input_name;
delete device;
return CUBEB_OK;
}

int
audiounit_stream_register_device_changed_callback(
cubeb_stream * stream,
Expand Down Expand Up @@ -3698,10 +3595,8 @@ cubeb_ops const audiounit_ops = {
/*.stream_get_input_latency =*/NULL,
/*.stream_set_volume =*/audiounit_stream_set_volume,
/*.stream_set_name =*/NULL,
/*.stream_get_current_device =*/audiounit_stream_get_current_device,
/*.stream_set_input_mute =*/NULL,
/*.stream_set_input_processing_params =*/NULL,
/*.stream_device_destroy =*/audiounit_stream_device_destroy,
/*.stream_register_device_changed_callback =*/
audiounit_stream_register_device_changed_callback,
/*.register_device_collection_changed =*/
Expand Down
44 changes: 0 additions & 44 deletions src/cubeb_jack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ cbjack_deinterleave_playback_refill_float(cubeb_stream * stream,
float ** bufs_in, float ** bufs_out,
jack_nframes_t nframes);
static int
cbjack_stream_device_destroy(cubeb_stream * stream, cubeb_device * device);
static int
cbjack_stream_get_current_device(cubeb_stream * stm,
cubeb_device ** const device);
static int
cbjack_enumerate_devices(cubeb * context, cubeb_device_type type,
cubeb_device_collection * collection);
static int
Expand Down Expand Up @@ -173,10 +168,8 @@ static struct cubeb_ops const cbjack_ops = {
.stream_get_input_latency = NULL,
.stream_set_volume = cbjack_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = cbjack_stream_get_current_device,
.stream_set_input_mute = NULL,
.stream_set_input_processing_params = NULL,
.stream_device_destroy = cbjack_stream_device_destroy,
.stream_register_device_changed_callback = NULL,
.register_device_collection_changed = NULL};

Expand Down Expand Up @@ -1073,43 +1066,6 @@ cbjack_stream_set_volume(cubeb_stream * stm, float volume)
return CUBEB_OK;
}

static int
cbjack_stream_get_current_device(cubeb_stream * stm,
cubeb_device ** const device)
{
*device = (cubeb_device *)calloc(1, sizeof(cubeb_device));
if (*device == NULL)
return CUBEB_ERROR;

const char * j_in = JACK_DEFAULT_IN;
const char * j_out = JACK_DEFAULT_OUT;
const char * empty = "";

if (stm->devs == DUPLEX) {
(*device)->input_name = strdup(j_in);
(*device)->output_name = strdup(j_out);
} else if (stm->devs == IN_ONLY) {
(*device)->input_name = strdup(j_in);
(*device)->output_name = strdup(empty);
} else if (stm->devs == OUT_ONLY) {
(*device)->input_name = strdup(empty);
(*device)->output_name = strdup(j_out);
}

return CUBEB_OK;
}

static int
cbjack_stream_device_destroy(cubeb_stream * /*stream*/, cubeb_device * device)
{
if (device->input_name)
free(device->input_name);
if (device->output_name)
free(device->output_name);
free(device);
return CUBEB_OK;
}

static int
cbjack_enumerate_devices(cubeb * context, cubeb_device_type type,
cubeb_device_collection * collection)
Expand Down
2 changes: 0 additions & 2 deletions src/cubeb_kai.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ static struct cubeb_ops const kai_ops = {
/*.stream_get_input_latency = */ NULL,
/*.stream_set_volume =*/kai_stream_set_volume,
/*.stream_set_name =*/NULL,
/*.stream_get_current_device =*/NULL,
/*.stream_set_input_mute =*/NULL,
/*.stream_set_input_processing_params =*/NULL,
/*.stream_device_destroy =*/NULL,
/*.stream_register_device_changed_callback=*/NULL,
/*.register_device_collection_changed=*/NULL};
2 changes: 0 additions & 2 deletions src/cubeb_opensl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,9 +1950,7 @@ struct cubeb_ops const opensl_ops = {
.stream_get_input_latency = nullptr,
.stream_set_volume = opensl_stream_set_volume,
.stream_set_name = nullptr,
.stream_get_current_device = nullptr,
.stream_set_input_mute = nullptr,
.stream_set_input_processing_params = nullptr,
.stream_device_destroy = nullptr,
.stream_register_device_changed_callback = nullptr,
.register_device_collection_changed = nullptr};
26 changes: 0 additions & 26 deletions src/cubeb_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,30 +1305,6 @@ oss_stream_set_volume(cubeb_stream * stream, float volume)
return CUBEB_OK;
}

static int
oss_get_current_device(cubeb_stream * stream, cubeb_device ** const device)
{
*device = calloc(1, sizeof(cubeb_device));
if (*device == NULL) {
return CUBEB_ERROR;
}
(*device)->input_name =
stream->record.fd != -1 ? strdup(stream->record.name) : NULL;
(*device)->output_name =
stream->play.fd != -1 ? strdup(stream->play.name) : NULL;
return CUBEB_OK;
}

static int
oss_stream_device_destroy(cubeb_stream * stream, cubeb_device * device)
{
(void)stream;
free(device->input_name);
free(device->output_name);
free(device);
return CUBEB_OK;
}

static struct cubeb_ops const oss_ops = {
.init = oss_init,
.get_backend_id = oss_get_backend_id,
Expand All @@ -1348,9 +1324,7 @@ static struct cubeb_ops const oss_ops = {
.stream_get_input_latency = NULL,
.stream_set_volume = oss_stream_set_volume,
.stream_set_name = NULL,
.stream_get_current_device = oss_get_current_device,
.stream_set_input_mute = NULL,
.stream_set_input_processing_params = NULL,
.stream_device_destroy = oss_stream_device_destroy,
.stream_register_device_changed_callback = NULL,
.register_device_collection_changed = NULL};
Loading