-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed MacOS build plus some random bug fixes (#6)
* Fixes for MacOS build * MacOS Fixes * Added a first rudimentary implementation for bundleEntry and bundleExit in NPlugFactory. * Reverted back to DllImport to not pollute the project with unnecessary unsafe code. * Get the PluginClassInfo category dynamically based on the type, instead of always returning an AudioProcessor
- Loading branch information
Showing
8 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace NPlug.Interop; | ||
|
||
/// <summary> | ||
/// This class is responsible for exporting the current registered factory in <see cref="AudioPluginFactoryExporter.Instance"/>. | ||
/// </summary> | ||
internal static partial class NPlugFactoryExport | ||
{ | ||
private static readonly List<nint> BundleRefs = []; | ||
|
||
[DllImport("/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/Resources/BridgeSupport/CoreFoundation.dylib")] | ||
private static extern nint CFRetain(nint theArrayRef); | ||
|
||
[DllImport("/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/Resources/BridgeSupport/CoreFoundation.dylib")] | ||
private static extern void CFRelease(nint theArrayRef); | ||
|
||
[UnmanagedCallersOnly(EntryPoint = nameof(bundleEntry))] | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Exported function required by VST3 API")] | ||
// ReSharper disable once InconsistentNaming | ||
private static bool bundleEntry(nint bundlePointer) | ||
{ | ||
if (bundlePointer != 0) | ||
{ | ||
BundleRefs.Add(CFRetain(bundlePointer)); | ||
} | ||
return true; | ||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = nameof(bundleExit))] | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Exported function required by VST3 API")] | ||
// ReSharper disable once InconsistentNaming | ||
private static bool bundleExit(nint bundlePointer) | ||
{ | ||
if (bundlePointer != 0) | ||
{ | ||
BundleRefs.Remove(bundlePointer); | ||
CFRelease(bundlePointer); | ||
} | ||
return BundleRefs.Count > 0; | ||
} | ||
} |