Skip to content

Commit

Permalink
Reset stream position when returning raw track
Browse files Browse the repository at this point in the history
Also slightly adjusts one of the new methods I added, I don't see a return to return the same stream since the one sent in as a parameter is the one being modified
  • Loading branch information
TrevTV committed Aug 22, 2024
1 parent d933b12 commit 1dd2701
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions DeezNET/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task<Stream> GetRawTrackStream(long trackId, Bitrate bitrate, Bitra

stream.Dispose();

outStream.Seek(0, SeekOrigin.Begin);
return outStream;
}

Expand Down Expand Up @@ -77,8 +78,7 @@ public async Task WriteRawTrackToFile(long trackId, string trackPath, Bitrate bi
/// </summary>
/// <param name="trackId">The track ID to base metadata on.</param>
/// <param name="trackStream">The track stream to apply the metadata to. Must be seekable.</param>
/// <returns>A new stream with the applied metadata.</returns>
public async Task<Stream> ApplyMetadataToTrackStream(long trackId, Stream trackStream, int coverResolution = 512, string lyrics = "", CancellationToken token = default)
public async Task ApplyMetadataToTrackStream(long trackId, Stream trackStream, int coverResolution = 512, string lyrics = "", CancellationToken token = default)
{
byte[] magicBuffer = new byte[4];
await trackStream.ReadAsync(magicBuffer.AsMemory(0, 4), token);
Expand All @@ -91,8 +91,6 @@ public async Task<Stream> ApplyMetadataToTrackStream(long trackId, Stream trackS
await ApplyMetadataToTagLibFile(file, trackId, coverResolution, lyrics, token);

trackStream.Seek(0, SeekOrigin.Begin);

return trackStream;
}

/// <summary>
Expand Down

0 comments on commit 1dd2701

Please sign in to comment.