Skip to content

Commit

Permalink
changed all handles to IntPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
tebjan committed Dec 21, 2014
1 parent 89b1c0c commit ab7fc95
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Documentation.xml
obj/
bin/Debug/SequencerDemo.vshost.exe.manifest
bin/
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public partial class InputDevice

private SysCommonMessageBuilder scBuilder = new SysCommonMessageBuilder();

private int handle = 0;
private IntPtr handle = IntPtr.Zero;

private volatile bool resetting = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Sanford.Multimedia.Midi
{
public partial class InputDevice : MidiDevice
{
private void HandleMessage(int handle, int msg, int instance, int param1, int param2)
private void HandleMessage(IntPtr handle, int msg, int instance, int param1, int param2)
{
if(msg == MIM_OPEN)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Sanford.Multimedia.Midi
{
public partial class InputDevice
{
public override int Handle
public override IntPtr Handle
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,36 @@ namespace Sanford.Multimedia.Midi
public partial class InputDevice
{
// Represents the method that handles messages from Windows.
private delegate void MidiInProc(int handle, int msg, int instance, int param1, int param2);
private delegate void MidiInProc(IntPtr handle, int msg, int instance, int param1, int param2);

#region Win32 MIDI Input Functions and Constants

[DllImport("winmm.dll")]
private static extern int midiInOpen(ref int handle, int deviceID,
private static extern int midiInOpen(ref IntPtr handle, int deviceID,
MidiInProc proc, int instance, int flags);

[DllImport("winmm.dll")]
private static extern int midiInClose(int handle);
private static extern int midiInClose(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiInStart(int handle);
private static extern int midiInStart(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiInStop(int handle);
private static extern int midiInStop(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiInReset(int handle);
private static extern int midiInReset(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiInPrepareHeader(int handle,
private static extern int midiInPrepareHeader(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
private static extern int midiInUnprepareHeader(int handle,
private static extern int midiInUnprepareHeader(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
private static extern int midiInAddBuffer(int handle,
private static extern int midiInAddBuffer(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
Expand Down
8 changes: 4 additions & 4 deletions Midi/Sanford.Multimedia.Midi/Device Classes/MidiDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public abstract class MidiDevice : Device
#region Win32 Midi Device Functions

[DllImport("winmm.dll")]
private static extern int midiConnect(int handleA, int handleB, int reserved);
private static extern int midiConnect(IntPtr handleA, IntPtr handleB, int reserved);

[DllImport("winmm.dll")]
private static extern int midiDisconnect(int handleA, int handleB, int reserved);
private static extern int midiDisconnect(IntPtr handleA, IntPtr handleB, int reserved);

#endregion

Expand Down Expand Up @@ -82,7 +82,7 @@ public MidiDevice(int deviceID) : base(deviceID)
/// <exception cref="DeviceException">
/// If an error occurred while connecting the two devices.
/// </exception>
public static void Connect(int handleA, int handleB)
public static void Connect(IntPtr handleA, IntPtr handleB)
{
int result = midiConnect(handleA, handleB, 0);

Expand All @@ -105,7 +105,7 @@ public static void Connect(int handleA, int handleB)
/// <exception cref="DeviceException">
/// If an error occurred while disconnecting the two devices.
/// </exception>
public static void Disconnect(int handleA, int handleB)
public static void Disconnect(IntPtr handleA, IntPtr handleB)
{
int result = midiDisconnect(handleA, handleB, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public sealed class OutputDevice : OutputDeviceBase
#region Win32 Midi Output Functions and Constants

[DllImport("winmm.dll")]
private static extern int midiOutOpen(ref int handle, int deviceID,
private static extern int midiOutOpen(ref IntPtr handle, int deviceID,
MidiOutProc proc, int instance, int flags);

[DllImport("winmm.dll")]
private static extern int midiOutClose(int handle);
private static extern int midiOutClose(IntPtr handle);

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ namespace Sanford.Multimedia.Midi
public abstract class OutputDeviceBase : MidiDevice
{
[DllImport("winmm.dll")]
protected static extern int midiOutReset(int handle);
protected static extern int midiOutReset(IntPtr handle);

[DllImport("winmm.dll")]
protected static extern int midiOutShortMsg(int handle, int message);
protected static extern int midiOutShortMsg(IntPtr handle, int message);

[DllImport("winmm.dll")]
protected static extern int midiOutPrepareHeader(int handle,
protected static extern int midiOutPrepareHeader(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
protected static extern int midiOutUnprepareHeader(int handle,
protected static extern int midiOutUnprepareHeader(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
protected static extern int midiOutLongMsg(int handle,
protected static extern int midiOutLongMsg(IntPtr handle,
IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
Expand Down Expand Up @@ -89,7 +89,7 @@ protected static extern int midiOutGetDevCaps(int deviceID,
private MidiHeaderBuilder headerBuilder = new MidiHeaderBuilder();

// The device handle.
protected int hndle = 0;
protected IntPtr hndle = IntPtr.Zero;

public OutputDeviceBase(int deviceID) : base(deviceID)
{
Expand Down Expand Up @@ -322,8 +322,8 @@ public override void Dispose()
Close();
}
}
public override int Handle

public override IntPtr Handle
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@ namespace Sanford.Multimedia.Midi
public sealed class OutputStream : OutputDeviceBase
{
[DllImport("winmm.dll")]
private static extern int midiStreamOpen(ref int handle, ref int deviceID, int reserved,
private static extern int midiStreamOpen(ref IntPtr handle, ref int deviceID, int reserved,
OutputDevice.MidiOutProc proc, int instance, uint flag);

[DllImport("winmm.dll")]
private static extern int midiStreamClose(int handle);
private static extern int midiStreamClose(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiStreamOut(int handle, IntPtr headerPtr, int sizeOfMidiHeader);
private static extern int midiStreamOut(IntPtr handle, IntPtr headerPtr, int sizeOfMidiHeader);

[DllImport("winmm.dll")]
private static extern int midiStreamPause(int handle);
private static extern int midiStreamPause(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiStreamPosition(int handle, ref Time t, int sizeOfTime);
private static extern int midiStreamPosition(IntPtr handle, ref Time t, int sizeOfTime);

[DllImport("winmm.dll")]
private static extern int midiStreamProperty(int handle, ref Property p, uint flags);
private static extern int midiStreamProperty(IntPtr handle, ref Property p, uint flags);

[DllImport("winmm.dll")]
private static extern int midiStreamRestart(int handle);
private static extern int midiStreamRestart(IntPtr handle);

[DllImport("winmm.dll")]
private static extern int midiStreamStop(int handle);
private static extern int midiStreamStop(IntPtr handle);

[StructLayout(LayoutKind.Sequential)]
private struct Property
Expand Down
2 changes: 1 addition & 1 deletion Midi/Sanford.Multimedia/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected virtual void OnError(ErrorEventArgs e)
/// <summary>
/// Gets the device handle.
/// </summary>
public abstract int Handle
public abstract IntPtr Handle
{
get;
}
Expand Down

0 comments on commit ab7fc95

Please sign in to comment.