From patchwork Tue Dec 15 10:18:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 58423 Delivered-To: patch@linaro.org Received: by 10.112.129.4 with SMTP id ns4csp101717lbb; Tue, 15 Dec 2015 02:20:15 -0800 (PST) X-Received: by 10.55.74.71 with SMTP id x68mr49357073qka.101.1450174815619; Tue, 15 Dec 2015 02:20:15 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v16si500732qka.127.2015.12.15.02.20.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 Dec 2015 02:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:36045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8miN-0003j3-6y for patch@linaro.org; Tue, 15 Dec 2015 05:20:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8mgm-0001pv-EC for qemu-devel@nongnu.org; Tue, 15 Dec 2015 05:18:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8mgj-0001K7-9m for qemu-devel@nongnu.org; Tue, 15 Dec 2015 05:18:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8mgj-0001Ji-3D for qemu-devel@nongnu.org; Tue, 15 Dec 2015 05:18:33 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9114237C38A; Tue, 15 Dec 2015 10:18:32 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBFAIV5m000433; Tue, 15 Dec 2015 05:18:31 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E6BCB80ABB; Tue, 15 Dec 2015 11:18:30 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 15 Dec 2015 11:18:27 +0100 Message-Id: <1450174708-20499-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1450174708-20499-1-git-send-email-kraxel@redhat.com> References: <1450174708-20499-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Gerd Hoffmann Subject: [Qemu-devel] [PULL 4/5] audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell Use the new-in-OSX 10.6 API AudioObjectGetPropertyData() instead of the deprecated AudioDeviceGetProperty() and AudioDeviceSetProperty() functions when possible. Signed-off-by: Peter Maydell Message-id: 1448747724-15572-5-git-send-email-peter.maydell@linaro.org Signed-off-by: Gerd Hoffmann --- audio/coreaudio.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) -- 1.8.3.1 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) {