[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v3 5/7] audio/coreaudio: Remove a deprecation warning on
From: |
Roman Bolshakov |
Subject: |
Re: [RFC PATCH v3 5/7] audio/coreaudio: Remove a deprecation warning on macOS 12 |
Date: |
Tue, 11 Jan 2022 21:36:37 +0300 |
On Mon, Jan 10, 2022 at 02:09:59PM +0100, Philippe Mathieu-Daudé wrote:
> When building on macOS 12 we get:
>
> audio/coreaudio.c:50:5: error: 'kAudioObjectPropertyElementMaster' is
> deprecated: first deprecated in macOS 12.0 [-Werror,-Wdeprecated-declarations]
> kAudioObjectPropertyElementMaster
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> kAudioObjectPropertyElementMain
>
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5:
> note: 'kAudioObjectPropertyElementMaster' has been explicitly marked
> deprecated here
> kAudioObjectPropertyElementMaster
> API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain",
> macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) =
> kAudioObjectPropertyElementMain
> ^
>
> Replace by kAudioObjectPropertyElementMain, redefining it to
> kAudioObjectPropertyElementMaster if not available, using
> Clang __is_identifier() feature (coreaudio is restricted to
> macOS).
>
As of now it breaks the build on Catalina/10.15:
FAILED: libcommon.fa.p/audio_coreaudio.c.o
cc <...>
../audio/coreaudio.c:54:5: error: use of undeclared identifier
'kAudioObjectPropertyElementMain'; did you mean
'kAudioObjectPropertyElementName'?
kAudioObjectPropertyElementMain
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kAudioObjectPropertyElementName
But __is_identifier itself works... Weird.
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Checkpatch:
>
> WARNING: architecture specific defines should be avoided
> #10: FILE: audio/coreaudio.c:47:
> +#if !__is_identifier(kAudioObjectPropertyElementMain) /* macOS >= 12.0 */
>
> Should we define __is_identifier() to 0 for GCC on macOS?
Clang documentation has this snippet:
#ifdef __is_identifier // Compatibility with non-clang compilers.
#if __is_identifier(__wchar_t)
typedef wchar_t __wchar_t;
#endif
#endif
We can also add ifdef around just to be nice to GCC if it ever comes back on
macOS :)
Regards,
Roman
> ---
> audio/coreaudio.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index d8a21d3e507..73cbfd479ac 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -44,10 +44,14 @@ typedef struct coreaudioVoiceOut {
> bool enabled;
> } coreaudioVoiceOut;
>
> +#if !__is_identifier(kAudioObjectPropertyElementMain) /* macOS >= 12.0 */
> +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> +#endif
> +
> static const AudioObjectPropertyAddress voice_addr = {
> kAudioHardwarePropertyDefaultOutputDevice,
> kAudioObjectPropertyScopeGlobal,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> @@ -69,7 +73,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID
> id,
> AudioObjectPropertyAddress addr = {
> kAudioDevicePropertyBufferFrameSizeRange,
> kAudioDevicePropertyScopeOutput,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> return AudioObjectGetPropertyData(id,
> @@ -86,7 +90,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id,
> UInt32 *framesize)
> AudioObjectPropertyAddress addr = {
> kAudioDevicePropertyBufferFrameSize,
> kAudioDevicePropertyScopeOutput,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> return AudioObjectGetPropertyData(id,
> @@ -103,7 +107,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID id,
> UInt32 *framesize)
> AudioObjectPropertyAddress addr = {
> kAudioDevicePropertyBufferFrameSize,
> kAudioDevicePropertyScopeOutput,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> return AudioObjectSetPropertyData(id,
> @@ -121,7 +125,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID
> id,
> AudioObjectPropertyAddress addr = {
> kAudioDevicePropertyStreamFormat,
> kAudioDevicePropertyScopeOutput,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> return AudioObjectSetPropertyData(id,
> @@ -138,7 +142,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id,
> UInt32 *result)
> AudioObjectPropertyAddress addr = {
> kAudioDevicePropertyDeviceIsRunning,
> kAudioDevicePropertyScopeOutput,
> - kAudioObjectPropertyElementMaster
> + kAudioObjectPropertyElementMain
> };
>
> return AudioObjectGetPropertyData(id,
> --
> 2.33.1
- Re: [RFC PATCH v3 1/7] configure: Allow passing extra Objective C compiler flags, (continued)
- [RFC PATCH v3 2/7] ui/cocoa: Remove allowedFileTypes restriction in SavePanel, Philippe Mathieu-Daudé, 2022/01/10
- [RFC PATCH v3 3/7] hvf: Make hvf_get_segments() / hvf_put_segments() local, Philippe Mathieu-Daudé, 2022/01/10
- [RFC PATCH v3 4/7] hvf: Remove deprecated hv_vcpu_flush() calls, Philippe Mathieu-Daudé, 2022/01/10
- [RFC PATCH v3 5/7] audio/coreaudio: Remove a deprecation warning on macOS 12, Philippe Mathieu-Daudé, 2022/01/10
- [RFC PATCH v3 6/7] block/file-posix: Remove a deprecation warning on macOS 12, Philippe Mathieu-Daudé, 2022/01/10
- [RFC PATCH v3 7/7] gitlab-ci: Support macOS 12 via cirrus-run, Philippe Mathieu-Daudé, 2022/01/10
- Re: [RFC PATCH v3 0/7] host: Support macOS 12, Roman Bolshakov, 2022/01/10