Skip to content

Commit

Permalink
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCa…
Browse files Browse the repository at this point in the history
…llback] for the ScheduledAudioFileRegionCallback function. (#12948)

Ref #10470.
  • Loading branch information
rolfbjarne committed Oct 8, 2021
1 parent 7a46df3 commit 9f2ff42
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/AudioUnit/AUScheduledAudioFileRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class AUScheduledAudioFileRegion : IDisposable {
internal struct ScheduledAudioFileRegion
{
public AudioTimeStamp TimeStamp;
#if NET
public unsafe delegate* unmanaged<IntPtr, IntPtr, AudioUnitStatus, void> CompletionHandler;
#else
public ScheduledAudioFileRegionCompletionHandler CompletionHandler;
#endif
public /* void * */ IntPtr CompletionHandlerUserData;
public IntPtr AudioFile;
public uint LoopCount;
Expand All @@ -51,17 +55,21 @@ public AUScheduledAudioFileRegion (AudioFile audioFile, AUScheduledAudioFileRegi
this.completionHandler = completionHandler;
}

#if !NET
internal delegate void ScheduledAudioFileRegionCompletionHandler (
/* void * */IntPtr userData,
/* ScheduledAudioFileRegion * */ref ScheduledAudioFileRegion fileRegion,
/* ScheduledAudioFileRegion * */ IntPtr fileRegion,
/* OSStatus */ AudioUnitStatus result);

static readonly ScheduledAudioFileRegionCompletionHandler static_ScheduledAudioFileRegionCompletionHandler = new ScheduledAudioFileRegionCompletionHandler (ScheduledAudioFileRegionCallback);

#if !MONOMAC
[MonoPInvokeCallback (typeof (ScheduledAudioFileRegionCompletionHandler))]
#endif
static void ScheduledAudioFileRegionCallback (IntPtr userData, ref ScheduledAudioFileRegion fileRegion, AudioUnitStatus status)
#else
[UnmanagedCallersOnly]
#endif
static void ScheduledAudioFileRegionCallback (IntPtr userData, IntPtr fileRegion, AudioUnitStatus status)
{
if (userData == IntPtr.Zero)
return;
Expand All @@ -85,13 +93,22 @@ internal ScheduledAudioFileRegion GetAudioFileRegion ()
var ret = new ScheduledAudioFileRegion {
TimeStamp = TimeStamp,
CompletionHandlerUserData = ptr,
CompletionHandler = ptr != IntPtr.Zero ? static_ScheduledAudioFileRegionCompletionHandler : null,
AudioFile = AudioFile.Handle,
LoopCount = LoopCount,
StartFrame = StartFrame,
FramesToPlay = FramesToPlay
};

if (ptr != IntPtr.Zero) {
unsafe {
#if NET
ret.CompletionHandler = &ScheduledAudioFileRegionCallback;
#else
ret.CompletionHandler = static_ScheduledAudioFileRegionCompletionHandler;
#endif
}
}

alreadyUsed = true;
return ret;
}
Expand Down

7 comments on commit 9f2ff42

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on Build (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ [CI Build] Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (only version changes)

Packages generated

View packages

🎉 All 218 tests passed 🎉

Pipeline on Agent XAMBOT-1027.BigSur'
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests tvOS 🔥

Not enough free space in the host.

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Tests passed on macOS M1 - Mac Big Sur (11.5) ✅

Tests passed

All tests on macOS X M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on macOS Mac Mojave (10.14) ❌

Tests failed on Mac Mojave (10.14).

Failed tests are:

  • introspection
  • linksdk

Pipeline on Agent
[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] for the ScheduledAudioFileRegionCallback function. (#12948)

Please sign in to comment.