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 7, 2024
1 parent dbef591 commit 98b2e71
Show file tree
Hide file tree
Showing 22 changed files with 1,072 additions and 176 deletions.
130 changes: 109 additions & 21 deletions src/SFML.Audio/Music.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public Music(byte[] bytes) :
////////////////////////////////////////////////////////////
public void Play()
{
ThrowIfDisposed();
sfMusic_play(CPointer);
}

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

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

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

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

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

////////////////////////////////////////////////////////////
Expand All @@ -174,6 +189,7 @@ public Time Duration
{
get
{
ThrowIfDisposed();
return sfMusic_getDuration(CPointer);
}
}
Expand All @@ -190,8 +206,16 @@ public Time Duration
////////////////////////////////////////////////////////////
public bool Loop
{
get { return sfMusic_getLoop(CPointer); }
set { sfMusic_setLoop(CPointer, value); }
get
{
ThrowIfDisposed();
return sfMusic_getLoop(CPointer);
}
set
{
ThrowIfDisposed();
sfMusic_setLoop(CPointer, value);
}
}

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

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

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

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

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

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

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

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

////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 98b2e71

Please sign in to comment.