Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
fix initialization of local blockAlign with default values.
Browse files Browse the repository at this point in the history
Set default values to local `blockAlign` before asigning the value to
the member field `this.blockAlign`.

fix #791
  • Loading branch information
nkast committed Sep 5, 2016
1 parent 378f529 commit bc90539
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Source/SharpDX/Multimedia/WaveFormatAdpcm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,19 @@ internal WaveFormatAdpcm()
/// <param name="blockAlign">The block align. If 0, then 256 for [0, 11KHz], 512 for ]11KHz, 22Khz], 1024 for ]22Khz, +inf]</param>
public WaveFormatAdpcm(int rate, int channels, int blockAlign = 0) : base(rate, 4, channels)
{
waveFormatTag = WaveFormatEncoding.Adpcm;
this.blockAlign = (short)blockAlign;

if (blockAlign == 0)
{
if (rate <= 11025)
{
blockAlign = 256;
}
else if (rate <= 22050)
{
blockAlign = 512;
}
else
{
blockAlign = 1024;
}
}

waveFormatTag = WaveFormatEncoding.Adpcm;
this.blockAlign = (short)blockAlign;

SamplesPerBlock = (ushort)(blockAlign * 2 / channels - 12);
averageBytesPerSecond = (SampleRate * blockAlign) / SamplesPerBlock;

Expand Down

0 comments on commit bc90539

Please sign in to comment.