Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Avfoundation] Add support for xcode14.1 #16408

Open
wants to merge 9 commits into
base: xcode14.1
Choose a base branch
from
35 changes: 35 additions & 0 deletions src/AVFoundation/AVSpeechUtterance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

using Foundation;
using CoreFoundation;
using ObjCRuntime;
using AudioToolbox;

#nullable enable

namespace AVFoundation {

public partial class AVSpeechUtterance {

public AVSpeechUtterance (string speechString, bool isSsmlRepresentation = false) : base (NSObjectFlag.Empty)
{
if (isSsmlRepresentation) {
#if IOS || __MACCATALYST__ || TVOS
if (SystemVersion.CheckiOS (16, 0)) {
#elif WATCH
if (SystemVersion.CheckwatchOS (9, 0)) {
#else
if (SystemVersion.CheckmacOS (13, 0)) {
#endif
InitializeHandle (_InitFromSsmlRepresentation (speechString), "initWithSSMLRepresentation:");
} else {
throw new PlatformNotSupportedException ("initWithSSMLRepresentation: is not supported in this version of the OS.");
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
InitializeHandle (_InitFromString (speechString), "initWithString:");
}
}

}

}
7 changes: 3 additions & 4 deletions src/AVFoundation/AVTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@ public struct AVSampleCursorChunkInfo {
}
#endif

#if MONOMAC || __MACCATALYST__

#if NET
[SupportedOSPlatform ("macos10.15")]
[SupportedOSPlatform ("maccatalyst15.0")]
[SupportedOSPlatform ("ios16.0")]
[SupportedOSPlatform ("tvos16.0")]
#else
[Mac (10,15)]
[Watch (9, 0), TV (16, 0), Mac (10, 15), iOS (16, 0), MacCatalyst (16, 0)]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct AVSampleCursorAudioDependencyInfo {
Expand All @@ -424,7 +424,6 @@ public struct AVSampleCursorAudioDependencyInfo {

public nint PacketRefreshCount;
}
#endif

#if MONOMAC

Expand Down
11 changes: 8 additions & 3 deletions src/AVFoundation/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ public enum AVError : long {
RosettaNotInstalled = -11877,
OperationCancelled = -11878,
RequestCancelled = -11879,

InvalidSampleCursor = -11880,
FailedToLoadSampleData = -11881,
AirPlayReceiverTemporarilyUnavailable = -11882,
}

[Watch (6, 0)]
Expand Down Expand Up @@ -666,7 +670,8 @@ public enum AVCaptureSessionInterruptionReason : long {
[Native]
public enum AVSpeechSynthesisVoiceQuality : long {
Default = 1,
Enhanced
Enhanced,
Premium,
}

[iOS (9, 0)]
Expand Down Expand Up @@ -1025,6 +1030,7 @@ public enum AVAudioEngineManualRenderingStatus : long {
[Native]
public enum AVAudioSessionRouteSharingPolicy : ulong {
Default = 0,
[Deprecated (PlatformName.MacOSX, 13, 0)]
LongForm = 1,
Independent = 2,
[iOS (14, 0)]
Expand Down Expand Up @@ -1236,8 +1242,7 @@ public enum AVSpeechSynthesisVoiceGender : long {
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[NoWatch]
[NoTV]
[NoMac]
[iOS (13, 0)]
[iOS (13, 0), Mac (13, 0)]
[Native]
public enum AVCapturePhotoQualityPrioritization : long {
Speed = 1,
Expand Down
45 changes: 45 additions & 0 deletions src/CoreMidi/MidiStructs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Runtime.InteropServices;

using ObjCRuntime;
using CoreFoundation;
using Foundation;


namespace CoreMidi {

#if NET
[SupportedOSPlatform ("ios14.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos14.0")]
[SupportedOSPlatform ("macos11.0")]
#else
[iOS (14,0), Mac (11,0), Watch (8,0), TV (14,0)]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct MidiEventList
{
#if !COREBUILD
public MidiProtocolId protocol;
#endif
Comment on lines +22 to +24
Copy link
Member

Choose a reason for hiding this comment

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

There are a couple of issues here:

  1. Structs must have the same size between COREBUILD and !COREBUILD.
  2. Public API must not start with a lower-cased letter.
  3. It's often best to have private fields and public property accessors for structs, because it makes things easier if Apple changes their structs, and also if we need to adjust due to marshalling reasons (which is even more important for this struct, since it contains a variable-length array).

So something like this instead.

		int protocol;
		...

#if !COREBUILD
		public MidiProtocolId Protocol {
			get => (MidiProtocolId) protocol;
			set => protocol = (int) value;
		}
#endif

public uint NumPackets;
public MidiEventPacket[] packet;
}

#if NET
[SupportedOSPlatform ("ios14.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos14.0")]
[SupportedOSPlatform ("macos11.0")]
#else
[iOS (14,0), Mac (11,0), Watch (8,0), TV (14,0)]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct MidiEventPacket
Copy link
Member

Choose a reason for hiding this comment

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

Same as for previous struct: private fields + public accessors.

{
public ulong TimeStamp;
public uint WordCount;
public uint[] Words;
}

}
Loading