[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available |
Date: |
Tue, 15 Dec 2015 11:18:27 +0100 |
From: Peter Maydell <address@hidden>
Use the new-in-OSX 10.6 API AudioObjectGetPropertyData() instead
of the deprecated AudioDeviceGetProperty() and AudioDeviceSetProperty()
functions when possible.
Signed-off-by: Peter Maydell <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
audio/coreaudio.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 106 insertions(+), 1 deletion(-)
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index c7e31ea..32a997b 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -73,6 +73,111 @@ static OSStatus coreaudio_get_voice(AudioDeviceID *id)
&size,
id);
}
+
+static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
+ AudioValueRange *framerange)
+{
+ UInt32 size = sizeof(*framerange);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyBufferFrameSizeRange,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectGetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ &size,
+ framerange);
+}
+
+static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
+{
+ UInt32 size = sizeof(*framesize);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyBufferFrameSize,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectGetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ &size,
+ framesize);
+}
+
+static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
+{
+ UInt32 size = sizeof(*framesize);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyBufferFrameSize,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectSetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ size,
+ framesize);
+}
+
+static OSStatus coreaudio_get_streamformat(AudioDeviceID id,
+ AudioStreamBasicDescription *d)
+{
+ UInt32 size = sizeof(*d);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyStreamFormat,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectGetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ &size,
+ d);
+}
+
+static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
+ AudioStreamBasicDescription *d)
+{
+ UInt32 size = sizeof(*d);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyStreamFormat,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectSetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ size,
+ d);
+}
+
+static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
+{
+ UInt32 size = sizeof(*result);
+ AudioObjectPropertyAddress addr = {
+ kAudioDevicePropertyDeviceIsRunning,
+ kAudioDevicePropertyScopeOutput,
+ kAudioObjectPropertyElementMaster
+ };
+
+ return AudioObjectGetPropertyData(id,
+ &addr,
+ 0,
+ NULL,
+ &size,
+ result);
+}
#else
/* Legacy versions of functions using deprecated APIs */
@@ -85,7 +190,6 @@ static OSStatus coreaudio_get_voice(AudioDeviceID *id)
&size,
id);
}
-#endif
static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
AudioValueRange *framerange)
@@ -169,6 +273,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id,
UInt32 *result)
&size,
result);
}
+#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 <=
- [Qemu-devel] [PULL 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice, Gerd Hoffmann, 2015/12/15
- [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