A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5using ManagedBass;
6using osu.Framework.Allocation;
7using osu.Framework.Platform;
8
9namespace osu.Framework.Audio.Callbacks
10{
11 /// <summary>
12 /// Wrapper on <see cref="SyncProcedure"/> to provide functionality in <see cref="BassCallback"/>.
13 /// </summary>
14 public class SyncCallback : BassCallback
15 {
16 public SyncProcedure Callback => RuntimeInfo.SupportsJIT ? Sync : syncCallback;
17
18 public readonly SyncProcedure Sync;
19
20 public SyncCallback(SyncProcedure proc)
21 {
22 Sync = proc;
23 }
24
25 [MonoPInvokeCallback(typeof(SyncProcedure))]
26 private static void syncCallback(int handle, int channel, int data, IntPtr user)
27 {
28 var ptr = new ObjectHandle<SyncCallback>(user);
29 if (ptr.GetTarget(out SyncCallback target))
30 target.Sync(handle, channel, data, user);
31 }
32 }
33}