Skip to content

Commit

Permalink
Implement checks for disposed objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Marioalexsan committed Aug 8, 2024
1 parent dbef591 commit eec90a7
Show file tree
Hide file tree
Showing 24 changed files with 408 additions and 389 deletions.
52 changes: 26 additions & 26 deletions src/SFML.Audio/Music.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Music(byte[] bytes) :
////////////////////////////////////////////////////////////
public void Play()
{
sfMusic_play(CPointer);
sfMusic_play(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -115,7 +115,7 @@ public void Play()
////////////////////////////////////////////////////////////
public void Pause()
{
sfMusic_pause(CPointer);
sfMusic_pause(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -129,7 +129,7 @@ public void Pause()
////////////////////////////////////////////////////////////
public void Stop()
{
sfMusic_stop(CPointer);
sfMusic_stop(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -142,7 +142,7 @@ public void Stop()
////////////////////////////////////////////////////////////
public uint SampleRate
{
get { return sfMusic_getSampleRate(CPointer); }
get { return sfMusic_getSampleRate(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -152,7 +152,7 @@ public uint SampleRate
////////////////////////////////////////////////////////////
public uint ChannelCount
{
get { return sfMusic_getChannelCount(CPointer); }
get { return sfMusic_getChannelCount(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -162,7 +162,7 @@ public uint ChannelCount
////////////////////////////////////////////////////////////
public SoundStatus Status
{
get { return sfMusic_getStatus(CPointer); }
get { return sfMusic_getStatus(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -174,7 +174,7 @@ public Time Duration
{
get
{
return sfMusic_getDuration(CPointer);
return sfMusic_getDuration(CPointerChecked);
}
}

Expand All @@ -190,8 +190,8 @@ public Time Duration
////////////////////////////////////////////////////////////
public bool Loop
{
get { return sfMusic_getLoop(CPointer); }
set { sfMusic_setLoop(CPointer, value); }
get { return sfMusic_getLoop(CPointerChecked); }
set { sfMusic_setLoop(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -207,8 +207,8 @@ public bool Loop
////////////////////////////////////////////////////////////
public float Pitch
{
get { return sfMusic_getPitch(CPointer); }
set { sfMusic_setPitch(CPointer, value); }
get { return sfMusic_getPitch(CPointerChecked); }
set { sfMusic_setPitch(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -221,8 +221,8 @@ public float Pitch
////////////////////////////////////////////////////////////
public float Volume
{
get { return sfMusic_getVolume(CPointer); }
set { sfMusic_setVolume(CPointer, value); }
get { return sfMusic_getVolume(CPointerChecked); }
set { sfMusic_setVolume(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -236,8 +236,8 @@ public float Volume
////////////////////////////////////////////////////////////
public Vector3f Position
{
get { return sfMusic_getPosition(CPointer); }
set { sfMusic_setPosition(CPointer, value); }
get { return sfMusic_getPosition(CPointerChecked); }
set { sfMusic_setPosition(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -253,8 +253,8 @@ public Vector3f Position
////////////////////////////////////////////////////////////
public bool RelativeToListener
{
get { return sfMusic_isRelativeToListener(CPointer); }
set { sfMusic_setRelativeToListener(CPointer, value); }
get { return sfMusic_isRelativeToListener(CPointerChecked); }
set { sfMusic_setRelativeToListener(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -271,8 +271,8 @@ public bool RelativeToListener
////////////////////////////////////////////////////////////
public float MinDistance
{
get { return sfMusic_getMinDistance(CPointer); }
set { sfMusic_setMinDistance(CPointer, value); }
get { return sfMusic_getMinDistance(CPointerChecked); }
set { sfMusic_setMinDistance(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -291,8 +291,8 @@ public float MinDistance
////////////////////////////////////////////////////////////
public float Attenuation
{
get { return sfMusic_getAttenuation(CPointer); }
set { sfMusic_setAttenuation(CPointer, value); }
get { return sfMusic_getAttenuation(CPointerChecked); }
set { sfMusic_setAttenuation(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -305,8 +305,8 @@ public float Attenuation
////////////////////////////////////////////////////////////
public Time PlayingOffset
{
get { return sfMusic_getPlayingOffset(CPointer); }
set { sfMusic_setPlayingOffset(CPointer, value); }
get { return sfMusic_getPlayingOffset(CPointerChecked); }
set { sfMusic_setPlayingOffset(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -323,8 +323,8 @@ public Time PlayingOffset
////////////////////////////////////////////////////////////
public TimeSpan LoopPoints
{
get { return sfMusic_getLoopPoints(CPointer); }
set { sfMusic_setLoopPoints(CPointer, value); }
get { return sfMusic_getLoopPoints(CPointerChecked); }
set { sfMusic_setLoopPoints(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -370,7 +370,7 @@ protected override void Destroy(bool disposing)
}
}

sfMusic_destroy(CPointer);
sfMusic_destroy(CPointerChecked);
}

private StreamAdaptor myStream = null;
Expand Down
46 changes: 23 additions & 23 deletions src/SFML.Audio/Sound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Sound(SoundBuffer buffer) :
/// <param name="copy">Sound to copy</param>
////////////////////////////////////////////////////////////
public Sound(Sound copy) :
base(sfSound_copy(copy.CPointer))
base(sfSound_copy(copy.CPointerChecked))
{
SoundBuffer = copy.SoundBuffer;
}
Expand All @@ -76,7 +76,7 @@ public Sound(Sound copy) :
////////////////////////////////////////////////////////////
public void Play()
{
sfSound_play(CPointer);
sfSound_play(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -89,7 +89,7 @@ public void Play()
////////////////////////////////////////////////////////////
public void Pause()
{
sfSound_pause(CPointer);
sfSound_pause(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -103,7 +103,7 @@ public void Pause()
////////////////////////////////////////////////////////////
public void Stop()
{
sfSound_stop(CPointer);
sfSound_stop(CPointerChecked);
}

////////////////////////////////////////////////////////////
Expand All @@ -118,7 +118,7 @@ public void Stop()
public SoundBuffer SoundBuffer
{
get { return myBuffer; }
set { myBuffer = value; sfSound_setBuffer(CPointer, value != null ? value.CPointer : IntPtr.Zero); }
set { myBuffer = value; sfSound_setBuffer(CPointerChecked, value != null ? value.CPointerChecked : IntPtr.Zero); }
}

////////////////////////////////////////////////////////////
Expand All @@ -128,7 +128,7 @@ public SoundBuffer SoundBuffer
////////////////////////////////////////////////////////////
public SoundStatus Status
{
get { return sfSound_getStatus(CPointer); }
get { return sfSound_getStatus(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -143,8 +143,8 @@ public SoundStatus Status
////////////////////////////////////////////////////////////
public bool Loop
{
get { return sfSound_getLoop(CPointer); }
set { sfSound_setLoop(CPointer, value); }
get { return sfSound_getLoop(CPointerChecked); }
set { sfSound_setLoop(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -160,8 +160,8 @@ public bool Loop
////////////////////////////////////////////////////////////
public float Pitch
{
get { return sfSound_getPitch(CPointer); }
set { sfSound_setPitch(CPointer, value); }
get { return sfSound_getPitch(CPointerChecked); }
set { sfSound_setPitch(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -174,8 +174,8 @@ public float Pitch
////////////////////////////////////////////////////////////
public float Volume
{
get { return sfSound_getVolume(CPointer); }
set { sfSound_setVolume(CPointer, value); }
get { return sfSound_getVolume(CPointerChecked); }
set { sfSound_setVolume(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -188,8 +188,8 @@ public float Volume
////////////////////////////////////////////////////////////
public Time PlayingOffset
{
get { return sfSound_getPlayingOffset(CPointer); }
set { sfSound_setPlayingOffset(CPointer, value); }
get { return sfSound_getPlayingOffset(CPointerChecked); }
set { sfSound_setPlayingOffset(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -203,8 +203,8 @@ public Time PlayingOffset
////////////////////////////////////////////////////////////
public Vector3f Position
{
get { return sfSound_getPosition(CPointer); }
set { sfSound_setPosition(CPointer, value); }
get { return sfSound_getPosition(CPointerChecked); }
set { sfSound_setPosition(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -220,8 +220,8 @@ public Vector3f Position
////////////////////////////////////////////////////////////
public bool RelativeToListener
{
get { return sfSound_isRelativeToListener(CPointer); }
set { sfSound_setRelativeToListener(CPointer, value); }
get { return sfSound_isRelativeToListener(CPointerChecked); }
set { sfSound_setRelativeToListener(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -238,8 +238,8 @@ public bool RelativeToListener
////////////////////////////////////////////////////////////
public float MinDistance
{
get { return sfSound_getMinDistance(CPointer); }
set { sfSound_setMinDistance(CPointer, value); }
get { return sfSound_getMinDistance(CPointerChecked); }
set { sfSound_setMinDistance(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand All @@ -258,8 +258,8 @@ public float MinDistance
////////////////////////////////////////////////////////////
public float Attenuation
{
get { return sfSound_getAttenuation(CPointer); }
set { sfSound_setAttenuation(CPointer, value); }
get { return sfSound_getAttenuation(CPointerChecked); }
set { sfSound_setAttenuation(CPointerChecked, value); }
}

////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -294,7 +294,7 @@ public override string ToString()
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfSound_destroy(CPointer);
sfSound_destroy(CPointerChecked);
}

private SoundBuffer myBuffer;
Expand Down
16 changes: 8 additions & 8 deletions src/SFML.Audio/SoundBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public SoundBuffer(short[] samples, uint channelCount, uint sampleRate) :
/// <param name="copy">Sound buffer to copy</param>
////////////////////////////////////////////////////////////
public SoundBuffer(SoundBuffer copy) :
base(sfSoundBuffer_copy(copy.CPointer))
base(sfSoundBuffer_copy(copy.CPointerChecked))
{
}

Expand All @@ -137,7 +137,7 @@ public SoundBuffer(SoundBuffer copy) :
////////////////////////////////////////////////////////////
public bool SaveToFile(string filename)
{
return sfSoundBuffer_saveToFile(CPointer, filename);
return sfSoundBuffer_saveToFile(CPointerChecked, filename);
}

////////////////////////////////////////////////////////////
Expand All @@ -150,7 +150,7 @@ public bool SaveToFile(string filename)
////////////////////////////////////////////////////////////
public uint SampleRate
{
get { return sfSoundBuffer_getSampleRate(CPointer); }
get { return sfSoundBuffer_getSampleRate(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -160,7 +160,7 @@ public uint SampleRate
////////////////////////////////////////////////////////////
public uint ChannelCount
{
get { return sfSoundBuffer_getChannelCount(CPointer); }
get { return sfSoundBuffer_getChannelCount(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -170,7 +170,7 @@ public uint ChannelCount
////////////////////////////////////////////////////////////
public Time Duration
{
get { return sfSoundBuffer_getDuration(CPointer); }
get { return sfSoundBuffer_getDuration(CPointerChecked); }
}

////////////////////////////////////////////////////////////
Expand All @@ -185,8 +185,8 @@ public short[] Samples
{
get
{
short[] SamplesArray = new short[sfSoundBuffer_getSampleCount(CPointer)];
Marshal.Copy(sfSoundBuffer_getSamples(CPointer), SamplesArray, 0, SamplesArray.Length);
short[] SamplesArray = new short[sfSoundBuffer_getSampleCount(CPointerChecked)];
Marshal.Copy(sfSoundBuffer_getSamples(CPointerChecked), SamplesArray, 0, SamplesArray.Length);
return SamplesArray;
}
}
Expand Down Expand Up @@ -216,7 +216,7 @@ public override string ToString()
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfSoundBuffer_destroy(CPointer);
sfSoundBuffer_destroy(CPointerChecked);
}

#region Imports
Expand Down
Loading

0 comments on commit eec90a7

Please sign in to comment.