Skip to content

Commit

Permalink
Player: Fixed bug with releasing channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Mar 20, 2013
1 parent 7239175 commit ecce309
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions MPfm/MPfm.Player/Player.cs
Expand Up @@ -1395,7 +1395,7 @@ public void Stop()
}

// Stop decoding the current file (doesn't throw an exception if decode has finished)
Playlist.CurrentItem.CancelDecode();
//Playlist.CurrentItem.CancelDecode();

// Remove syncs
RemoveSyncCallbacks();
Expand Down Expand Up @@ -1433,7 +1433,7 @@ public void GoTo(int index)
currentMixPlaylistIndex = index;

// Get audio file (to raise event later)
AudioFile audioFileStarted = Playlist.Items[index].AudioFile;
//AudioFile audioFileStarted = Playlist.Items[index].AudioFile;

// Start playback
Play();
Expand Down
20 changes: 17 additions & 3 deletions MPfm/MPfm.Sound/Playlists/PlaylistItem.cs
Expand Up @@ -401,14 +401,28 @@ public void Dispose()
// Check if a channel already exists
if (channel != null)
{
// Check if the channel is in use
if (channel.IsActive() == BASSActive.BASS_ACTIVE_PLAYING)
try
{
// Stop and free channel
// Stop and free channel
Console.WriteLine("Freeing channel " + AudioFile.FilePath + "...");
channel.Stop();
channel.Free();
channel = null;
}
catch(Exception ex)
{
if(audioFile != null)
Console.WriteLine("Could not dispose channel " + AudioFile.FilePath + ": " + ex.Message);
}

// // Check if the channel is in use
// if (channel.IsActive() == BASSActive.BASS_ACTIVE_PLAYING)
// {
// // Stop and free channel
// channel.Stop();
// channel.Free();
// channel = null;
// }
}

// Set flags
Expand Down

0 comments on commit ecce309

Please sign in to comment.