From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2nSz-0004jV-21 for qemu-devel@nongnu.org; Sat, 28 Nov 2015 16:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2nSx-0006ll-Kw for qemu-devel@nongnu.org; Sat, 28 Nov 2015 16:55:36 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:58995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2nSx-0006kf-Eh for qemu-devel@nongnu.org; Sat, 28 Nov 2015 16:55:35 -0500 From: Peter Maydell Date: Sat, 28 Nov 2015 21:55:21 +0000 Message-Id: <1448747724-15572-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org> References: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: John Arbuckle , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gerd Hoffmann , patches@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(+) 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) { -- 2.6.2