From patchwork Sat Nov 28 21:55:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 57388 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp618320lbb; Sat, 28 Nov 2015 13:55:31 -0800 (PST) X-Received: by 10.112.138.38 with SMTP id qn6mr16018225lbb.29.1448747727508; Sat, 28 Nov 2015 13:55:27 -0800 (PST) Return-Path: Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id d197si24843428lfe.94.2015.11.28.13.55.27 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 28 Nov 2015 13:55:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1a2nSm-00043t-Pi; Sat, 28 Nov 2015 21:55:24 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , John Arbuckle , Gerd Hoffmann Subject: [PATCH 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available Date: Sat, 28 Nov 2015 21:55:23 +0000 Message-Id: <1448747724-15572-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1448747724-15572-1-git-send-email-peter.maydell@linaro.org> References: <1448747724-15572-1-git-send-email-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 --- audio/coreaudio.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) -- 2.6.2 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) {