@@ -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-
31733070int
31743071audiounit_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 =*/
0 commit comments