From patchwork Sat Nov 28 21:55:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 57386 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp618293lbb; Sat, 28 Nov 2015 13:55:27 -0800 (PST) X-Received: by 10.28.182.134 with SMTP id g128mr19387567wmf.95.1448747727039; Sat, 28 Nov 2015 13:55:27 -0800 (PST) Return-Path: Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id n123si19142563wmd.67.2015.11.28.13.55.26 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 28 Nov 2015 13:55:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1a2nSm-00043l-MG; Sat, 28 Nov 2015 21:55:24 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , John Arbuckle , Gerd Hoffmann Subject: [PATCH 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice Date: Sat, 28 Nov 2015 21:55:21 +0000 Message-Id: <1448747724-15572-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org> References: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org> If we're building for OSX 10.6 or better, use the new API AudioObjectGetPropertyData for getting the default voice. Signed-off-by: Peter Maydell --- audio/coreaudio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.6.2 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 433e009..2211e17 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -32,6 +32,10 @@ #define AUDIO_CAP "coreaudio" #include "audio_int.h" +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif + static int isAtexit; typedef struct { @@ -50,6 +54,28 @@ typedef struct coreaudioVoiceOut { int rpos; } coreaudioVoiceOut; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +/* The APIs used here only become available from 10.6 */ + +static OSStatus coreaudio_get_voice(AudioDeviceID *id) +{ + UInt32 size = sizeof(*id); + AudioObjectPropertyAddress addr = { + kAudioHardwarePropertyDefaultOutputDevice, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster + }; + + return AudioObjectGetPropertyData(kAudioObjectSystemObject, + &addr, + 0, + NULL, + &size, + id); +} +#else +/* Legacy versions of functions using deprecated APIs */ + static OSStatus coreaudio_get_voice(AudioDeviceID *id) { UInt32 size = sizeof(*id); @@ -59,6 +85,7 @@ static OSStatus coreaudio_get_voice(AudioDeviceID *id) &size, id); } +#endif static void coreaudio_logstatus (OSStatus status) {