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

Commented Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

Dictionary<int, WaveOut> _WaveOutCollections = null;


// Init the 4 output device, and assign to a difference output device
private void InitDevice()
{

_WaveOutCollections = new Dictionary<int, WaveOut>();

for (int i = 0; i< 4;i++)
{
WaveOut waveOut = new WaveOut();
waveOut.deviceNumber = i; // Assign to a different device number
waveOut.WaveFormat = new WaveFormat(8000, 16, 1);

_WaveOutCollection.Add(i, waveOut); // add the waveOut object into a container to be use later in playing sound
}

}


// This function will be use on playing the received voice buffer from 4 different input source to 4 different output devices

private void PlaySound(byte[] buffer, int deviceNumber)
{
IWaveProvider waveProvider = new BufferedWaveProvider();
waveProvider.AddSamples(buffer, 0, buffer.Length);

WaveOut waveOut = null;
if (_WaveOutCollections.TryGetValue(deviceNumber, out WaveOut))
{
if (waveOut!=null)
{
waveOut.Init(waveProvider); // The Error happens on the 4th initiating....

if (waveOut.PlayBackState != PlayBackState.Playing)
waveOut.Play();

}
}
}



I traced the error it happen on interop call on winmm.dll at "WaveInterop.cs", The Error result is "UnSpecified Error"

[DllImport("winmm.dll")]
public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
[DllImport("winmm.dll", EntryPoint = "waveOutOpen")]
public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);



thanks,

Comments: sounds like an issue with your soundcard drivers

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>