1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
$NetBSD: patch-src_coreaudio.c,v 1.1 2016/02/02 06:12:10 dbj Exp $
CoreAudio may return the same device multiple times as separate
input and output devices. Only try to use the appropriate direction when matching.
--- src/coreaudio.c.orig 2014-10-06 01:59:34.000000000 +0000
+++ src/coreaudio.c
@@ -140,22 +140,33 @@ static int setup(sox_format_t *ft, int i
if (status == noErr)
{
- int device_count = property_size/sizeof(AudioDeviceID);
AudioDeviceID *devices;
devices = malloc(property_size);
- status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &property_size, devices);
+ status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &property_size, devices);
if (status == noErr)
{
int i;
+ int device_count = property_size/sizeof(AudioDeviceID);
for (i = 0; i < device_count; i++)
{
char name[256];
- status = AudioDeviceGetProperty(devices[i],0,false,kAudioDevicePropertyDeviceName,&property_size,&name);
+ property_size = sizeof(name);
+ status = AudioDeviceGetProperty(devices[i], 0, is_input, kAudioDevicePropertyDeviceName, &property_size, &name);
+ if (status != noErr) {
+ continue;
+ }
+ name[property_size-1] = '\0';
lsx_report("Found Audio Device \"%s\"\n",name);
+ status = AudioDeviceGetPropertyInfo(devices[i], 0, is_input, kAudioDevicePropertyStreamFormat, NULL, NULL);
+ if (status != noErr) {
+ lsx_report("Audio Device \"%s\" at index %d is not an %s device", name, i, is_input ? "input" : "output");
+ continue;
+ }
+
/* String returned from OS is truncated so only compare
* as much as returned.
*/
|