Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Issue: Multiple issues in WaveMixerStream32 [16351]

$
0
0
In AddInputStream, the following code:
...
// get to the right point in this input file
this.Position = Position;
...
seems wrong to me. It should be:
...
// get to the right point in this input file
waveStream.Position = this.Position;
...
in order to set the position of the new stream correctly, so it is in sync with other streams.

In RemoveInputStream, the field length is updated multiple times and this can cause problems in multi-threaded scenario as an observer in another thread may see invalid values for the Length property. Making the calculation in a local variable instead and storing the result in the length field only once would solve this issue.

Always in RemoveInputStream, the code:
...
this.length = Math.Max(this.length, waveStream.Length);
...
should be:
...
this.length = Math.Max(this.length, inputStream.Length);
...
otherwise the length of the mixer stream is always set to the length of the removed input stream, and not to the maximum length among remaining streams.

In the Read method, the code should be in a lock() statement for thread safety, otherwise the AutoStop-related code may proceed incorrectly if the Length property is changed by another thread, and the foreach statement may raise an exception if the collection is changed by another thread (both are common scenarios when a mixer object is modified during playback).
Comments: have finally got round to fixing this, thanks for reporting

Viewing all articles
Browse latest Browse all 738

Trending Articles