From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "John Arbuckle" <programmingkidx@gmail.com>,
"Andreas Färber" <andreas.faerber@web.de>,
"Gerd Hoffmann" <kraxel@redhat.com>,
patches@linaro.org
Subject: [Qemu-devel] [PATCH 5/5] audio/coreaudio.c: Avoid deprecated AudioDeviceAdd/RemoveIOProc APIs
Date: Sat, 28 Nov 2015 21:55:24 +0000 [thread overview]
Message-ID: <1448747724-15572-6-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org>
The AudioDeviceAddIOProc() and AudioDeviceRemoveIOProc() functions were
deprecated in OSX 10.5. Since we don't support any earlier versions of
OSX, we can simply replace them with the new APIs
AudioDeviceCreateIOProcID() and AudioDeviceRemoveIOProcID().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
audio/coreaudio.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index 32a997b..7150604 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -49,6 +49,7 @@ typedef struct coreaudioVoiceOut {
AudioDeviceID outputDeviceID;
UInt32 audioDevicePropertyBufferFrameSize;
AudioStreamBasicDescription outputStreamBasicDescription;
+ AudioDeviceIOProcID ioprocid;
int live;
int decr;
int rpos;
@@ -598,8 +599,12 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
}
/* set Callback */
- status = AudioDeviceAddIOProc(core->outputDeviceID, audioDeviceIOProc, hw);
- if (status != kAudioHardwareNoError) {
+ core->ioprocid = NULL;
+ status = AudioDeviceCreateIOProcID(core->outputDeviceID,
+ audioDeviceIOProc,
+ hw,
+ &core->ioprocid);
+ if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
coreaudio_logerr2 (status, typ, "Could not set IOProc\n");
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
@@ -607,10 +612,10 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
/* start Playback */
if (!isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStart(core->outputDeviceID, audioDeviceIOProc);
+ status = AudioDeviceStart(core->outputDeviceID, core->ioprocid);
if (status != kAudioHardwareNoError) {
coreaudio_logerr2 (status, typ, "Could not start playback\n");
- AudioDeviceRemoveIOProc(core->outputDeviceID, audioDeviceIOProc);
+ AudioDeviceDestroyIOProcID(core->outputDeviceID, core->ioprocid);
core->outputDeviceID = kAudioDeviceUnknown;
return -1;
}
@@ -628,15 +633,15 @@ static void coreaudio_fini_out (HWVoiceOut *hw)
if (!isAtexit) {
/* stop playback */
if (isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStop(core->outputDeviceID, audioDeviceIOProc);
+ status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
if (status != kAudioHardwareNoError) {
coreaudio_logerr (status, "Could not stop playback\n");
}
}
/* remove callback */
- status = AudioDeviceRemoveIOProc(core->outputDeviceID,
- audioDeviceIOProc);
+ status = AudioDeviceDestroyIOProcID(core->outputDeviceID,
+ core->ioprocid);
if (status != kAudioHardwareNoError) {
coreaudio_logerr (status, "Could not remove IOProc\n");
}
@@ -659,7 +664,7 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd, ...)
case VOICE_ENABLE:
/* start playback */
if (!isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStart(core->outputDeviceID, audioDeviceIOProc);
+ status = AudioDeviceStart(core->outputDeviceID, core->ioprocid);
if (status != kAudioHardwareNoError) {
coreaudio_logerr (status, "Could not resume playback\n");
}
@@ -670,7 +675,8 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd, ...)
/* stop playback */
if (!isAtexit) {
if (isPlaying(core->outputDeviceID)) {
- status = AudioDeviceStop(core->outputDeviceID, audioDeviceIOProc);
+ status = AudioDeviceStop(core->outputDeviceID,
+ core->ioprocid);
if (status != kAudioHardwareNoError) {
coreaudio_logerr (status, "Could not pause playback\n");
}
--
2.6.2
next prev parent reply other threads:[~2015-11-28 21:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-28 21:55 [Qemu-devel] [PATCH 0/5] audio/coreaudio.c: Fix deprecation warnings Peter Maydell
2015-11-28 21:55 ` [Qemu-devel] [PATCH 1/5] audio/coreaudio.c: Factor out use of AudioHardwareGetProperty Peter Maydell
2015-11-28 21:55 ` [Qemu-devel] [PATCH 2/5] audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice Peter Maydell
2015-11-28 21:55 ` [Qemu-devel] [PATCH 3/5] audio/coreaudio.c: Factor out uses of AudioDeviceGet/SetProperty Peter Maydell
2015-11-28 21:55 ` [Qemu-devel] [PATCH 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available Peter Maydell
2015-11-28 21:55 ` Peter Maydell [this message]
2015-12-01 16:27 ` [Qemu-devel] [PATCH 0/5] audio/coreaudio.c: Fix deprecation warnings Programmingkid
2015-12-01 16:39 ` 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=1448747724-15572-6-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=andreas.faerber@web.de \
--cc=kraxel@redhat.com \
--cc=patches@linaro.org \
--cc=programmingkidx@gmail.com \
--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).