Skip to content

Commit

Permalink
Add some safety checks
Browse files Browse the repository at this point in the history
Because all kind of streams are allowed
  • Loading branch information
mcraiha committed Nov 12, 2024
1 parent dddb320 commit 0f2878e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/QOA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,16 @@ public short[] qoa_decode(Stream inputStream, out QOA_Desc qoa)
/// <param name="outputSteam">Output stream (WAV)</param>
public void DecodeToWav(Stream inputStream, Stream outputSteam)
{
if (!inputStream.CanRead)
{
throw new IOException("Input stream must be readable!");
}

if (!outputSteam.CanWrite)
{
throw new IOException("Output stream must be writable!");
}

short[] sampleData = qoa_decode(inputStream, out QOA_Desc qoa);
WriteWav(outputSteam, sampleData, qoa);
}
Expand Down

0 comments on commit 0f2878e

Please sign in to comment.