[directmusic] Re: DirectMusic and multiple threads

  • From: "Vytautas Leonavicius" <vytas@xxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Thu, 10 Jun 2004 17:18:19 +0200

Todor,

Thanks for your reply. But in my application CoInitializeEx is called
exactly the way you suggested. If not, I get an error.

But I was wrong about that segments caused problems. I found out recently,
that the problem is with performance object. If I create performance object
in loader thread, sound is not played, however, if performance object is
created in main thread, everything goes well. Here is the code of
Performance object creation:

CPerformance::CPerformance( HWND owner ) : mPerformance( 0 ), mVolume(
1.0f )
{
    // Create performance object
    HRESULT hr = CoCreateInstance
                                ( CLSID_DirectMusicPerformance, 0,
                                  CLSCTX_INPROC,
                                  IID_IDirectMusicPerformance8,
                                reinterpret_cast< void** >(
&mPerformance ) );

if( FAILED( hr ) ) {

THROW_DXERROR( hr, "Failed to intialize IDirectMusicPerformance8" );

}

ffects.

hr = mPerformance->InitAudio( 0, 0, owner, DMUS_APATH_DYNAMIC_STEREO, 128,
DMUS_AUDIOF_ALL, 0 );

if ( FAILED( hr ) ) {

if( hr == DSERR_NODRIVER ) {

THROW_DXERROR( hr, "No sound card found." );

}

THROW_DXERROR( hr, "Failed to intialize IDirectMusicPerformance8" );

}

    // Set maximum volume.
    setVolume( mVolume );
}


----- Original Message ----- 
From: "Todor Fay" <todor@xxxxxxxxxxxxx>
To: <directmusic@xxxxxxxxxxxxx>
Sent: Wednesday, June 09, 2004 3:22 PM
Subject: [directmusic] Re: DirectMusic and multiple threads


> This almost sounds like a COM initialization issue. Are you calling
> CoInitializeEx(NULL,COINIT_MULTITHREADED) at the start of your program?
>
> Todor
>
> -----Original Message-----
> From: directmusic-bounce@xxxxxxxxxxxxx
> [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Vytautas
> Leonavicius
> Sent: Thursday, June 10, 2004 5:50 AM
> To: directmusic@xxxxxxxxxxxxx
> Subject: [directmusic] DirectMusic and multiple threads
>
> Hello Group,
> I am having trouble with DirectMusic. Our app. uses 2 separate threads,
> one for resource loading another for main flow. IDirectMusicSegment
> objects, loaded on loader thread are not playing in main thread. No
> errors are returned, just silence.
>
> If I try to play sound in loader thread (immidiately after load) sound's
> playing well. Please help!
>
> Vytautas
>
>
>
>



Other related posts: