[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for g
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice |
Date: |
Tue, 15 Dec 2015 11:18:25 +0100 |
From: Peter Maydell <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
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)
{
--
1.8.3.1
- [Qemu-devel] [PULL 0/5] coreaudio: use new-in-OSX-10.6 APIs, cleanups., Gerd Hoffmann, 2015/12/15
- [Qemu-devel] [PULL 5/5] audio/coreaudio.c: Avoid deprecated AudioDeviceAdd/RemoveIOProc APIs, Gerd Hoffmann, 2015/12/15
- [Qemu-devel] [PULL 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available, Gerd Hoffmann, 2015/12/15
- [Qemu-devel] [PULL 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 3/5] audio/coreaudio.c: Factor out uses of AudioDeviceGet/SetProperty, Gerd Hoffmann, 2015/12/15
- [Qemu-devel] [PULL 1/5] audio/coreaudio.c: Factor out use of AudioHardwareGetProperty, Gerd Hoffmann, 2015/12/15
- Re: [Qemu-devel] [PULL 0/5] coreaudio: use new-in-OSX-10.6 APIs, cleanups., Peter Maydell, 2015/12/17