-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from A-tG/dev
Dev
- Loading branch information
Showing
18 changed files
with
171 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace VoicemeeterOsdProgram.Core.Types; | ||
|
||
unsafe static internal class VmParamsMemory | ||
{ | ||
internal static byte* ParamNamesBuffer { get; private set; } | ||
|
||
internal static void Allocate(nuint len) | ||
{ | ||
ParamNamesBuffer = (byte*)NativeMemory.Realloc(ParamNamesBuffer, len); | ||
} | ||
} |
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
52 changes: 25 additions & 27 deletions
52
VoicemeeterOsdProgram/Core/Types/VoicemeeterParameterBase.cs
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 |
---|---|---|
@@ -1,50 +1,48 @@ | ||
using AtgDev.Voicemeeter; | ||
using System.Text; | ||
using System; | ||
|
||
namespace VoicemeeterOsdProgram.Core.Types; | ||
|
||
public abstract class VoicemeeterParameterBase | ||
{ | ||
protected readonly string m_name; | ||
protected readonly RemoteApiExtender m_api; | ||
protected readonly RemoteApiWrapper m_api; | ||
|
||
protected readonly byte[] m_nameBuffer; | ||
public string Name { get; private set; } | ||
|
||
public VoicemeeterParameterBase(RemoteApiExtender api, string command) | ||
public bool IsEnabled { get; set; } = true; | ||
|
||
internal int NameIndex { get; private set; } = 0; | ||
internal int NameLength { get; private set; } = 0; | ||
internal unsafe byte* NamesBuffer { get; private set; } | ||
internal unsafe byte* NameBuffer { get; private set; } | ||
internal bool IsOptimized { get; private set; } = false; | ||
|
||
public VoicemeeterParameterBase(RemoteApiWrapper api, string command) | ||
{ | ||
m_api = api; | ||
m_name = command; | ||
ArgumentNullException.ThrowIfNull(api); | ||
ArgumentException.ThrowIfNullOrWhiteSpace(command); | ||
|
||
m_nameBuffer = GetNullTermAsciiBuffFromString(command); | ||
m_api = api; | ||
Name = command; | ||
|
||
Read(); | ||
} | ||
|
||
public string Name { get => m_name; } | ||
|
||
public bool IsEnabled { get; set; } = true; | ||
|
||
public void ReadNotifyChanges() | ||
{ | ||
ReadIsNotifyChanges(true); | ||
} | ||
public void ReadNotifyChanges() => ReadIsNotifyChanges(true); | ||
|
||
public void Read() | ||
{ | ||
ReadIsNotifyChanges(false); | ||
} | ||
public void Read() => ReadIsNotifyChanges(false); | ||
|
||
public abstract void ReadIsNotifyChanges(bool isNotify); | ||
|
||
public abstract void ClearEvents(); | ||
|
||
protected byte[] GetNullTermAsciiBuffFromString(string str) | ||
|
||
internal unsafe void SetupNameBufferP(byte* buff, int index, int len) | ||
{ | ||
var len = str.Length; | ||
var buff = new byte[str.Length + 1]; | ||
Encoding.ASCII.GetBytes(str, 0, len, buff, 0); | ||
buff[^1] = 0; | ||
return buff; | ||
NamesBuffer = buff; | ||
NameIndex = index; | ||
NameLength = len; | ||
NameBuffer = &buff[index]; | ||
IsOptimized = true; | ||
} | ||
|
||
} |
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
Oops, something went wrong.