Skip to content

Commit

Permalink
fix: reference counting on winrt decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
zznty committed Apr 26, 2024
1 parent 04f0f42 commit 6985b5f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions MusicX/Services/Player/Sources/BoomMediaSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public override async Task<bool> OpenWithMediaPlayerAsync(MediaPlayer player, Pl
["headers"] = $"Authorization: {_boomService.Client.DefaultRequestHeaders.Authorization}"
}, cancellationToken);

RegisterSourceObjectReference(player, rtMediaSource);

await rtMediaSource.OpenWithMediaPlayerAsync(player).AsTask(cancellationToken);

RegisterSourceObjectReference(player, rtMediaSource);
}
catch (Exception e)
{
Expand Down
3 changes: 0 additions & 3 deletions MusicX/Services/Player/Sources/MediaSourceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ protected static void RegisterSourceObjectReference(MediaPlayer player, IWinRTOb

void PlayerOnSourceChanged(MediaPlayer sender, object args)
{
if (!ReferenceEquals(player.Source, rtObject))
return;

player.SourceChanged -= PlayerOnSourceChanged;

if (rtObject is IDisposable disposable)
Expand Down
4 changes: 2 additions & 2 deletions MusicX/Services/Player/Sources/VkMediaSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public override async Task<bool> OpenWithMediaPlayerAsync(MediaPlayer player, Pl
try
{
var rtMediaSource = await CreateWinRtMediaSource(vkData, cancellationToken: cancellationToken);

RegisterSourceObjectReference(player, rtMediaSource);

await rtMediaSource.OpenWithMediaPlayerAsync(player).AsTask(cancellationToken);

RegisterSourceObjectReference(player, rtMediaSource);
}
catch (Exception e)
{
Expand Down

0 comments on commit 6985b5f

Please sign in to comment.