fix incorrect CoreAudio api usage on Darwin

also enumerate inputs and outputs separately to find the correct type
This commit is contained in:
dbj 2016-02-02 06:12:10 +00:00
parent b249edf8fc
commit 7ea557eb43
3 changed files with 48 additions and 3 deletions

View file

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.62 2015/05/25 19:06:24 bsiegert Exp $
# $NetBSD: Makefile,v 1.63 2016/02/02 06:12:10 dbj Exp $
DISTNAME= sox-14.4.2
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= audio
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=sox/}

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.27 2015/11/03 01:12:51 agc Exp $
$NetBSD: distinfo,v 1.28 2016/02/02 06:12:10 dbj Exp $
SHA1 (sox-14.4.2.tar.gz) = f69f38f8a7ad6a88ecab3862d74db4edcd796695
RMD160 (sox-14.4.2.tar.gz) = 2fd48904a7d8c7d85e194a001020901d061ced98
@ -6,5 +6,6 @@ SHA512 (sox-14.4.2.tar.gz) = b5c6203f4f5577503a034fe5b3d6a033ee97fe4d171c533933e
Size (sox-14.4.2.tar.gz) = 1134299 bytes
SHA1 (patch-aa) = e6f3d06450862795648622a017b2c696328872f5
SHA1 (patch-ak) = 28675f56a0e2969d0facd98282667c53eb10c0ed
SHA1 (patch-src_coreaudio.c) = baee5596ec5efdc12f99ea9dab9e9c691a17b08d
SHA1 (patch-src_oss.c) = dca4dcf55d4bfa1da80b789cbddb48a9302e694b
SHA1 (patch-src_sunaudio.c) = 286ad890a32d69d499f76faa255473889b091d56

View file

@ -0,0 +1,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.
*/