[wdmaudiodev] Microsoft guys please fix this bug in DMusic.dll

  • From: Waldemar Haszlakiewicz <waldemar.haszlakiewicz@xxxxxxxx>
  • To: wdmaudiodev <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 13 Jan 2005 01:33:54 +0100

After a lot of work and some golden info from Stephan I found a problem to our 
DirectX Midi In
problem. It's a small mistake form the Microsoft guys so please can you fix 
this.

Below it's my representation of InputWorkerDataReady routine(from DMusic.dll).
I've loaded the pdb that was available at the Microsoft's site so the name of 
the routine should be
valid. Read about the dead-end loop below.

Because of the code below the only way the driver can successfully send data to 
directX app. is if
it defines all data as cbSize = 8 (set 2 DX events first with real data and 
second with just Active
Sensing).
Unfortunately for me this is still not the final solution as Miditest still 
doesn't get any data ->
it should probably return false because of Active Sensing and other Cubase 
doesn't even manage to
open Midi In port.

Anyway may I ask why DirectMusic tries to open an audio channel when we are 
opening just MIDI
channels??

Well that's enough for now.

Peace
Waldemar



void __thiscall CDirectMusicPort::InputWorkerDataReady
(
     __int64             PresentationTime,
     unsigned char*      pData,
     unsigned long       Dataused
)
{
     DMUS_EVENTHEADER*   pEvent = (DMUS_EVENTHEADER*)pData;
     DMUS_EVENTHEADER*   pEventCopy;
     char*               pMemory;

     SyncClocks();
     SlaveToMaster( PresentationTime );

     while ( DataUsed != 0 )
     {
          unsigned long  eventSize = DMUS_EVENT_SIZE( pEvent->cbEvent );
          if ( eventSize > DataUsed )
          {
               continue;

              BUG CODE:
              In lower level driver we get bufferSize of 64bytes.
              Now let us check if we define a few 3 bytes events.
              1st event
              cbSize = 3
              sizeofWholeEvent = DMUS_EVENT_SIZE( 3 ) = ( 3 + 0x1B ) & 
0xFFFFFFF8 = 0x18
              DataUsed -= 0x18 => = 40bytes

              2nd event
              cbSize = 3
              sizeofWholeEvent = DMUS_EVENT_SIZE( 3 ) = ( 3 + 0x1B ) & 
0xFFFFFFF8 = 0x18
              DataUsed -= 0x18 => = 16bytes

              3rd event
              cbSize = 3
              sizeofWholeEvent = DMUS_EVENT_SIZE( 3 ) = ( 3 + 0x1B ) & 
0xFFFFFFF8 = 0x18

              Here we'll lend into a dead-end loop -> eventSize = 0x18 when 
DataUsed = 0x10

          }

          Dataused -= eventSize;
          pData += eventSize;


          EnterCriticalSection(..);

          //GetMemory -> gets eventSize +4.
               if ( NULL != ( pMemory = GetMemory(..) ) )
               {
                    pEventCopy = (DMUS_EVENTHEADER*)(pMemory + 4);
                    CopyMemory( pMemory + 4, pEvent, eventSize );

                    pEventCopy->rtDelta += PresentationTime;

                    ThruEvent( (DMEVENT*)pMemory );

                    some class stuff
               }

          LeaveCriticalSection(..);
     }

     return;
}


******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/

Other related posts:

  • » [wdmaudiodev] Microsoft guys please fix this bug in DMusic.dll