diff mbox series

[v4,10/13] audio/coreaudio: Remove a deprecation warning on macOS 12

Message ID 20220211163434.58423-11-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series host: Support macOS 12 | expand

Commit Message

Philippe Mathieu-Daudé Feb. 11, 2022, 4:34 p.m. UTC
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.

Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Suggested-by: Roman Bolshakov <roman@roolebo.dev>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 audio/coreaudio.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Christian Schoenebeck Feb. 12, 2022, 1:15 p.m. UTC | #1
On Freitag, 11. Februar 2022 17:34:31 CET Philippe Mathieu-Daudé via 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/Framewor
> ks/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.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---

Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

>  audio/coreaudio.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index d8a21d3e50..5b3aeaced0 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>      bool enabled;
>  } coreaudioVoiceOut;
> 
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> +#endif
> +
>  static const AudioObjectPropertyAddress voice_addr = {
>      kAudioHardwarePropertyDefaultOutputDevice,
>      kAudioObjectPropertyScopeGlobal,
> -    kAudioObjectPropertyElementMaster
> +    kAudioObjectPropertyElementMain
>  };
> 
>  static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> @@ -69,7 +74,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID
> id, AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSizeRange,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,
> @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id,
> UInt32 *framesize) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSize,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,
> @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID
> id, UInt32 *framesize) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyBufferFrameSize,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectSetPropertyData(id,
> @@ -121,7 +126,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID
> id, AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyStreamFormat,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectSetPropertyData(id,
> @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID
> id, UInt32 *result) AudioObjectPropertyAddress addr = {
>          kAudioDevicePropertyDeviceIsRunning,
>          kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>      };
> 
>      return AudioObjectGetPropertyData(id,
Akihiko Odaki Feb. 12, 2022, 3:23 p.m. UTC | #2
On 2022/02/12 1:34, Philippe Mathieu-Daudé via 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.
> 
> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>   audio/coreaudio.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index d8a21d3e50..5b3aeaced0 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>       bool enabled;
>   } coreaudioVoiceOut;
>   
> +#if !defined(MAC_OS_VERSION_12_0) \
> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> +#endif
> +

Unless I have missed something, we have found 
MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the 
following thread:
https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/

Regards,
Akihiko Odaki

>   static const AudioObjectPropertyAddress voice_addr = {
>       kAudioHardwarePropertyDefaultOutputDevice,
>       kAudioObjectPropertyScopeGlobal,
> -    kAudioObjectPropertyElementMaster
> +    kAudioObjectPropertyElementMain
>   };
>   
>   static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> @@ -69,7 +74,7 @@ static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSizeRange,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,
> @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSize,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,
> @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyBufferFrameSize,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectSetPropertyData(id,
> @@ -121,7 +126,7 @@ static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyStreamFormat,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectSetPropertyData(id,
> @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
>       AudioObjectPropertyAddress addr = {
>           kAudioDevicePropertyDeviceIsRunning,
>           kAudioDevicePropertyScopeOutput,
> -        kAudioObjectPropertyElementMaster
> +        kAudioObjectPropertyElementMain
>       };
>   
>       return AudioObjectGetPropertyData(id,
Christian Schoenebeck Feb. 12, 2022, 5:27 p.m. UTC | #3
On Samstag, 12. Februar 2022 16:23:49 CET Akihiko Odaki wrote:
> On 2022/02/12 1:34, Philippe Mathieu-Daudé via 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/Fram
> >    eworks/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.
> > 
> > Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > ---
> > 
> >   audio/coreaudio.c | 17 +++++++++++------
> >   1 file changed, 11 insertions(+), 6 deletions(-)
> > 
> > diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> > index d8a21d3e50..5b3aeaced0 100644
> > --- a/audio/coreaudio.c
> > +++ b/audio/coreaudio.c
> > @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
> > 
> >       bool enabled;
> >   
> >   } coreaudioVoiceOut;
> > 
> > +#if !defined(MAC_OS_VERSION_12_0) \
> > +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> > +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
> > +#endif
> > +
> 
> Unless I have missed something, we have found
> MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the
> following thread:
> https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/
> 
> Regards,
> Akihiko Odaki

Well, MAC_OS_X_VERSION_MIN_REQUIRED would work as well, note though that it 
would effectively result with older SDKs (Xcode <= 13.0) to this:

enum {
  MAIN,
  MASTER = MAIN
};

#define MAIN MASTER

int main() {
   int k = MAIN;
}

Which compiles and works (as both enums reflect the same value anyway), but 
strictly the defined preprocessor macro would mask (with older SDKs) the 
already existing enum. Not that I would care, just noting.

On practical side though, your solution (MAC_OS_X_VERSION_MIN_REQUIRED) would 
avoid deprecation warnings in future. So yes, maybe it's a bit better.

Best regards,
Christian Schoenebeck

> 
> >   static const AudioObjectPropertyAddress voice_addr = {
> >   
> >       kAudioHardwarePropertyDefaultOutputDevice,
> >       kAudioObjectPropertyScopeGlobal,
> > 
> > -    kAudioObjectPropertyElementMaster
> > +    kAudioObjectPropertyElementMain
> > 
> >   };
> >   
> >   static OSStatus coreaudio_get_voice(AudioDeviceID *id)
> > 
> > @@ -69,7 +74,7 @@ static OSStatus
> > coreaudio_get_framesizerange(AudioDeviceID id,> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSizeRange,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,
> > 
> > @@ -86,7 +91,7 @@ static OSStatus coreaudio_get_framesize(AudioDeviceID
> > id, UInt32 *framesize)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSize,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,
> > 
> > @@ -103,7 +108,7 @@ static OSStatus coreaudio_set_framesize(AudioDeviceID
> > id, UInt32 *framesize)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyBufferFrameSize,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectSetPropertyData(id,
> > 
> > @@ -121,7 +126,7 @@ static OSStatus
> > coreaudio_set_streamformat(AudioDeviceID id,> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyStreamFormat,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectSetPropertyData(id,
> > 
> > @@ -138,7 +143,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID
> > id, UInt32 *result)> 
> >       AudioObjectPropertyAddress addr = {
> >       
> >           kAudioDevicePropertyDeviceIsRunning,
> >           kAudioDevicePropertyScopeOutput,
> > 
> > -        kAudioObjectPropertyElementMaster
> > +        kAudioObjectPropertyElementMain
> > 
> >       };
> >       
> >       return AudioObjectGetPropertyData(id,
Christian Schoenebeck Feb. 12, 2022, 5:41 p.m. UTC | #4
On Samstag, 12. Februar 2022 18:27:18 CET Christian Schoenebeck wrote:
> On Samstag, 12. Februar 2022 16:23:49 CET Akihiko Odaki wrote:
> > On 2022/02/12 1:34, Philippe Mathieu-Daudé via 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/Fr
> > >    am
> > >    eworks/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.
> > > 
> > > Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > > Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > Suggested-by: Roman Bolshakov <roman@roolebo.dev>
> > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > > Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > ---
> > > 
> > >   audio/coreaudio.c | 17 +++++++++++------
> > >   1 file changed, 11 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> > > index d8a21d3e50..5b3aeaced0 100644
> > > --- a/audio/coreaudio.c
> > > +++ b/audio/coreaudio.c
> > > @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
> > > 
> > >       bool enabled;
> > >   
> > >   } coreaudioVoiceOut;
> > > 
> > > +#if !defined(MAC_OS_VERSION_12_0) \
> > > +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
> > > +#define kAudioObjectPropertyElementMain
> > > kAudioObjectPropertyElementMaster
> > > +#endif
> > > +
> > 
> > Unless I have missed something, we have found
> > MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the
> > following thread:
> > https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com
> > /
> > 
> > Regards,
> > Akihiko Odaki
> 
> Well, MAC_OS_X_VERSION_MIN_REQUIRED would work as well, note though that it
> would effectively result with older SDKs (Xcode <= 13.0) to this:
> 
> enum {
>   MAIN,
>   MASTER = MAIN
> };
> 
> #define MAIN MASTER
> 
> int main() {
>    int k = MAIN;
> }
> 
> Which compiles and works (as both enums reflect the same value anyway), but
> strictly the defined preprocessor macro would mask (with older SDKs) the
> already existing enum. Not that I would care, just noting.
> 
> On practical side though, your solution (MAC_OS_X_VERSION_MIN_REQUIRED)
> would avoid deprecation warnings in future. So yes, maybe it's a bit
> better.

Correction: it would result in this masking scenario with recent SDK (e.g. 
Xcode 13.2.1) and targeting a minimum deployment target macOs <12.0 (not when 
compiling directly with Xcode <13.1).

Best regards,
Christian Schoenebeck
Philippe Mathieu-Daudé Feb. 14, 2022, 12:43 p.m. UTC | #5
On 12/2/22 16:23, Akihiko Odaki wrote:
> On 2022/02/12 1:34, Philippe Mathieu-Daudé via 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.
>>
>> Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
>> Suggested-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
>> Suggested-by: Roman Bolshakov <roman@roolebo.dev>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
>> ---
>>   audio/coreaudio.c | 17 +++++++++++------
>>   1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
>> index d8a21d3e50..5b3aeaced0 100644
>> --- a/audio/coreaudio.c
>> +++ b/audio/coreaudio.c
>> @@ -44,10 +44,15 @@ typedef struct coreaudioVoiceOut {
>>       bool enabled;
>>   } coreaudioVoiceOut;
>> +#if !defined(MAC_OS_VERSION_12_0) \
>> +    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
>> +#define kAudioObjectPropertyElementMain 
>> kAudioObjectPropertyElementMaster
>> +#endif
>> +
> 
> Unless I have missed something, we have found 
> MAC_OS_X_VERSION_MIN_REQUIRED is better even for a constant in the 
> following thread:
> https://lore.kernel.org/all/524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com/

I was reading the v3 comments and missed the v2 ones.
diff mbox series

Patch

diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index d8a21d3e50..5b3aeaced0 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -44,10 +44,15 @@  typedef struct coreaudioVoiceOut {
     bool enabled;
 } coreaudioVoiceOut;
 
+#if !defined(MAC_OS_VERSION_12_0) \
+    || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
+#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
+#endif
+
 static const AudioObjectPropertyAddress voice_addr = {
     kAudioHardwarePropertyDefaultOutputDevice,
     kAudioObjectPropertyScopeGlobal,
-    kAudioObjectPropertyElementMaster
+    kAudioObjectPropertyElementMain
 };
 
 static OSStatus coreaudio_get_voice(AudioDeviceID *id)
@@ -69,7 +74,7 @@  static OSStatus coreaudio_get_framesizerange(AudioDeviceID id,
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSizeRange,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,
@@ -86,7 +91,7 @@  static OSStatus coreaudio_get_framesize(AudioDeviceID id, UInt32 *framesize)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSize,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,
@@ -103,7 +108,7 @@  static OSStatus coreaudio_set_framesize(AudioDeviceID id, UInt32 *framesize)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyBufferFrameSize,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectSetPropertyData(id,
@@ -121,7 +126,7 @@  static OSStatus coreaudio_set_streamformat(AudioDeviceID id,
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyStreamFormat,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectSetPropertyData(id,
@@ -138,7 +143,7 @@  static OSStatus coreaudio_get_isrunning(AudioDeviceID id, UInt32 *result)
     AudioObjectPropertyAddress addr = {
         kAudioDevicePropertyDeviceIsRunning,
         kAudioDevicePropertyScopeOutput,
-        kAudioObjectPropertyElementMaster
+        kAudioObjectPropertyElementMain
     };
 
     return AudioObjectGetPropertyData(id,