I just wanted to use the DmoResamplerStream and I tested it in a Console application. So the default apartment mode is MTA. The result was that it does its job.
But if I chance the main thread to an STA thread it throws exceptions in the read method.
I would guess that the problem is, that I create the com interfaces on a sta-thread and use it in a mta-thread(e.g. directsound calls read on a mta-thread).
Just take a look at this code:
But if I chance the main thread to an STA thread it throws exceptions in the read method.
I would guess that the problem is, that I create the com interfaces on a sta-thread and use it in a mta-thread(e.g. directsound calls read on a mta-thread).
Just take a look at this code:
[MTAThread]
static void Main(string[] args)
{
DirectSoundOut dsound = new DirectSoundOut();
Mp3FileReader reader = new Mp3FileReader(@"C:\Temp\test.mp3");
dsound.Init(new ResamplerDmoStream(reader, new WaveFormat(48000, 16, 2)));
dsound.Play();
Console.ReadKey();
}
Now if you change the MTAThreadAttribute to STAThreadAttribute what would equals to a gui-thread it throws an exception in the read-"callback".