Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protection against multiple AsioOut initializations doesn't work if no waveProvider presented #147

Closed
vsoldatkin opened this issue Dec 22, 2016 · 0 comments

Comments

@vsoldatkin
Copy link

vsoldatkin commented Dec 22, 2016

As far as I was able to understand an AsioOut instance must be initialized only once, as suggested by this helpful check:

public void InitRecordAndPlayback(IWaveProvider waveProvider, int recordChannels, int recordOnlySampleRate)
{
if (this.sourceStream != null)
{
throw new InvalidOperationException("Already initialised this instance of AsioOut - dispose and create a new one");
}
int desiredSampleRate = waveProvider != null ? waveProvider.WaveFormat.SampleRate : recordOnlySampleRate;
if (waveProvider != null)
{
sourceStream = waveProvider;

public void InitRecordAndPlayback(IWaveProvider waveProvider, int recordChannels, int recordOnlySampleRate)
{
    if (this.sourceStream != null)
    {
        throw new InvalidOperationException("Already initialised this instance of AsioOut - dispose and create a new one");
    }
  
...

    if (waveProvider != null)
    {
        sourceStream = waveProvider;
...
    }

The problem though is that this check doesn't work well when no waveProvider was initialy provided (as for recording only application) and sourceStream is always null. Seems like a boolean flag might be a better idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant