From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Gerd Hoffmann <kraxel@redhat.com>
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 [thread overview]
Message-ID: <1450174708-20499-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1450174708-20499-1-git-send-email-kraxel@redhat.com>
From: Peter Maydell <peter.maydell@linaro.org>
Use the new-in-OSX 10.6 API AudioObjectGetPropertyData() instead
of the deprecated AudioDeviceGetProperty() and AudioDeviceSetProperty()
functions when possible.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1448747724-15572-5-git-send-email-peter.maydell@linaro.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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
next prev parent reply other threads:[~2015-12-15 10:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 10:18 [Qemu-devel] [PULL 0/5] coreaudio: use new-in-OSX-10.6 APIs, cleanups Gerd Hoffmann
2015-12-15 10:18 ` [Qemu-devel] [PULL 1/5] audio/coreaudio.c: Factor out use of AudioHardwareGetProperty Gerd Hoffmann
2015-12-15 10:18 ` [Qemu-devel] [PULL 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice Gerd Hoffmann
2015-12-15 10:18 ` [Qemu-devel] [PULL 3/5] audio/coreaudio.c: Factor out uses of AudioDeviceGet/SetProperty Gerd Hoffmann
2015-12-15 10:18 ` Gerd Hoffmann [this message]
2015-12-15 10:18 ` [Qemu-devel] [PULL 5/5] audio/coreaudio.c: Avoid deprecated AudioDeviceAdd/RemoveIOProc APIs Gerd Hoffmann
2015-12-17 11:31 ` [Qemu-devel] [PULL 0/5] coreaudio: use new-in-OSX-10.6 APIs, cleanups Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450174708-20499-5-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).