Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/AudioUnit/AUEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using AudioToolbox;
using ObjCRuntime;
Expand Down Expand Up @@ -189,7 +190,20 @@ public enum AudioObjectPropertySelector : uint
TranslateUIDToBox = 1969841250, // 'uidb'
ClockDeviceList = 1668049699, //'clk#'
TranslateUidToClockDevice = 1969841251, // 'uidc',
[Deprecated (PlatformName.iOS, 15,0, message : "Use the 'ProcessIsMain' element instead.")]
[Deprecated (PlatformName.MacCatalyst, 15,0, message : "Use the 'ProcessIsMain' element instead.")]
[Deprecated (PlatformName.MacOSX, 12,0, message : "Use the 'ProcessIsMain' element instead.")]
[Obsolete ("Use the 'ProcessIsMain' element instead.")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the deprecated attrs:

[Deprecated (PlatformName.TvOS, 15,0)]

you will have to add them for each of the supported platforms.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlike the other enum this one has a different value so it's useful to know when it should be avoided

ProcessIsMaster = 1835103092, // 'mast'
#if !NET
[iOS (15,0), MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
#else
[SupportedOSPlatform ("ios15.0")]
[SupportedOSPlatform ("maccatalyst15.0")]
[SupportedOSPlatform ("macos12.0")]
[UnsupportedOSPlatform ("tvos")]
#endif
ProcessIsMain = 1835100526, // 'main'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we should say when it was added.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a comment?

IsInitingOrExiting = 1768845172, // 'inot'
UserIDChanged = 1702193508, // 'euid'
ProcessIsAudible = 1886221684, // 'pmut'
Expand All @@ -202,6 +216,15 @@ public enum AudioObjectPropertySelector : uint
ActualSampleRate = 1634955892,// 'asrt',
ClockDevice = 1634755428, // 'apcd',
IOThreadOSWorkgroup = 1869838183, // 'oswg'
#if !NET
[iOS (15,0), MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
#else
[SupportedOSPlatform ("ios15.0")]
[SupportedOSPlatform ("maccatalyst15.0")]
[SupportedOSPlatform ("macos12.0")]
[UnsupportedOSPlatform ("tvos")]
#endif
ProcessMute = 1634758765, // 'appm'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ needs availability attributes - for both NET and legacy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's not available in tvOS then it needs [NoTV] and [SupportedOSPlatform ("tvos")]
unless the enum type itself is not available ?

otherwise it implies availability for tvOS 9 (for legacy) or tvOS 10 (for net6)

}

public enum AudioObjectPropertyScope : uint
Expand All @@ -214,7 +237,11 @@ public enum AudioObjectPropertyScope : uint

public enum AudioObjectPropertyElement : uint
{
#if !XAMCORE_4_0
[Obsolete ("Use the 'Main' element instead.")]
Comment thread
spouliot marked this conversation as resolved.
Master = 0, // 0
#endif
Main = 0, // 0
}
#endif // !XAMCORE_3_0 || MONOMAC

Expand Down
17 changes: 14 additions & 3 deletions src/AudioUnit/AudioUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using ObjCRuntime;
using CoreFoundation;
using Foundation;
using System.Runtime.Versioning;

namespace AudioUnit
{
Expand Down Expand Up @@ -389,10 +390,15 @@ public uint GetCurrentDevice (AudioUnitScopeType scope, uint audioUnitElement =
#if !XAMCORE_3_0 || MONOMAC
#if !MONOMAC
[Obsolete ("This API is not available on iOS.")]
#endif
#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
public static uint GetCurrentInputDevice ()
{
#if MONOMAC
#if MONOMAC || __MACCATALYST__
// We need to replace AudioHardwareGetProperty since it has been deprecated since OS X 10.6 and iOS 2.0
// Replacing with the following implementation recommended in the following doc
// See Listing 4 New - Getting the default input device.
Expand All @@ -403,7 +409,7 @@ public static uint GetCurrentInputDevice ()
var theAddress = new AudioObjectPropertyAddress (
AudioObjectPropertySelector.DefaultInputDevice,
AudioObjectPropertyScope.Global,
AudioObjectPropertyElement.Master);
AudioObjectPropertyElement.Main);
Comment thread
spouliot marked this conversation as resolved.
uint inQualifierDataSize = 0;
IntPtr inQualifierData = IntPtr.Zero;

Expand Down Expand Up @@ -864,7 +870,12 @@ static extern AudioUnitStatus AudioUnitSetParameter (IntPtr inUnit, AudioUnitPar
[DllImport (Constants.AudioUnitLibrary)]
static extern AudioUnitStatus AudioUnitScheduleParameters (IntPtr inUnit, AudioUnitParameterEvent inParameterEvent, uint inNumParamEvents);

#if MONOMAC
#if MONOMAC || __MACCATALYST__
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[DllImport (Constants.AudioUnitLibrary)]
static extern int AudioObjectGetPropertyData (
uint inObjectID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
!missing-pinvoke! AudioHardwareUnload is not bound
!missing-pinvoke! AudioObjectAddPropertyListener is not bound
!missing-pinvoke! AudioObjectAddPropertyListenerBlock is not bound
!missing-pinvoke! AudioObjectGetPropertyData is not bound
!missing-pinvoke! AudioObjectGetPropertyDataSize is not bound
!missing-pinvoke! AudioObjectHasProperty is not bound
!missing-pinvoke! AudioObjectIsPropertySettable is not bound
Expand Down