Ignore:
Timestamp:
Feb 26, 2001, 9:14:40 PM (25 years ago)
Author:
sandervl
Message:

fs corruption fixes for rtmidi class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/winmm/IRTMidi.cpp

    r2812 r5269  
    1 /* $Id: IRTMidi.cpp,v 1.6 2000-02-17 14:09:29 sandervl Exp $ */
     1/* $Id: IRTMidi.cpp,v 1.7 2001-02-26 20:14:38 sandervl Exp $ */
    22
    33/*******************************************************************************
     
    6161  iSetup.hqueueCallback         = 0;
    6262  if ( rc == 0 )
    63     rc = (*MidiSetup)( &iSetup, 0 );
     63    rc = MidiSetup( &iSetup, 0 );
    6464//fprintf( stderr, "MidiSetup rc=%d\n", rc );
    6565
     
    9393  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDICreateInstance", &modAddr );
    9494  if ( rc ) return rc;
    95   MidiCreateInstance =  (ULONG(*APIENTRY )( ULONG, MINSTANCE*, PSZ, ULONG)) modAddr;
     95  pfnMidiCreateInstance =  (ULONG(*APIENTRY )( ULONG, MINSTANCE*, PSZ, ULONG)) modAddr;
    9696
    9797  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIDeleteInstance", &modAddr );
    9898  if ( rc ) return rc;
    99   MidiDeleteInstance =  (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
     99  pfnMidiDeleteInstance =  (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
    100100
    101101  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIEnableInstance", &modAddr );
    102102  if ( rc ) return rc;
    103   MidiEnableInstance =  (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
     103  pfnMidiEnableInstance =  (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
    104104
    105105  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIDisableInstance", &modAddr );
    106106  if ( rc ) return rc;
    107   MidiDisableInstance = (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
     107  pfnMidiDisableInstance = (ULONG(*APIENTRY )(MINSTANCE, ULONG)) modAddr;
    108108
    109109  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIAddLink", &modAddr );
    110110  if ( rc ) return rc;
    111   MidiAddLink =         (ULONG(*APIENTRY )(MINSTANCE, MINSTANCE, ULONG, ULONG)) modAddr;
     111  pfnMidiAddLink =         (ULONG(*APIENTRY )(MINSTANCE, MINSTANCE, ULONG, ULONG)) modAddr;
    112112
    113113  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIRemoveLink", &modAddr );
    114114  if ( rc ) return rc;
    115   MidiRemoveLink =      (ULONG(*APIENTRY )(MINSTANCE, MINSTANCE, ULONG, ULONG)) modAddr;
     115  pfnMidiRemoveLink =      (ULONG(*APIENTRY )(MINSTANCE, MINSTANCE, ULONG, ULONG)) modAddr;
    116116
    117117  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIQueryClassList", &modAddr );
    118118  if ( rc ) return rc;
    119   MidiQueryClassList    = (ULONG(*APIENTRY )(ULONG, PMIDICLASSINFO, ULONG)) modAddr;
     119  pfnMidiQueryClassList    = (ULONG(*APIENTRY )(ULONG, PMIDICLASSINFO, ULONG)) modAddr;
    120120
    121121  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIQueryInstanceList", &modAddr );
    122122  if ( rc ) return rc;
    123   MidiQueryInstanceList = (ULONG(*APIENTRY )(ULONG, PMIDIINSTANCEINFO, ULONG)) modAddr;
     123  pfnMidiQueryInstanceList = (ULONG(*APIENTRY )(ULONG, PMIDIINSTANCEINFO, ULONG)) modAddr;
    124124
    125125  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIQueryNumClasses", &modAddr );
    126126  if ( rc ) return rc;
    127   MidiQueryNumClasses   = (ULONG(*APIENTRY )(PULONG, ULONG)) modAddr;
     127  pfnMidiQueryNumClasses   = (ULONG(*APIENTRY )(PULONG, ULONG)) modAddr;
    128128
    129129  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIQueryNumInstances", &modAddr );
    130130  if ( rc ) return rc;
    131   MidiQueryNumInstances = (ULONG(*APIENTRY )(PULONG, ULONG)) modAddr;
     131  pfnMidiQueryNumInstances = (ULONG(*APIENTRY )(PULONG, ULONG)) modAddr;
    132132
    133133  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDISendMessages", &modAddr );
    134134  if ( rc ) return rc;
    135   MidiSendMessages      = (ULONG(*APIENTRY )(PMESSAGE, ULONG, ULONG)) modAddr;
     135  pfnMidiSendMessages      = (ULONG(*APIENTRY )(PMESSAGE, ULONG, ULONG)) modAddr;
    136136
    137137  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDISendSysexMessage", &modAddr );
    138138  if ( rc ) return rc;
    139   MidiSendSysexMessage  = (ULONG(*APIENTRY )(PMESSAGE, ULONG, ULONG)) modAddr;
     139  pfnMidiSendSysexMessage  = (ULONG(*APIENTRY )(PMESSAGE, ULONG, ULONG)) modAddr;
    140140
    141141  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDIRetrieveMessages", &modAddr );
    142142  if ( rc ) return rc;
    143   MidiRetrieveMessages  = (ULONG(*APIENTRY )(MINSTANCE, PVOID, PULONG, ULONG)) modAddr;
     143  pfnMidiRetrieveMessages  = (ULONG(*APIENTRY )(MINSTANCE, PVOID, PULONG, ULONG)) modAddr;
    144144
    145145  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDISetup", &modAddr );
    146146  if ( rc ) return rc;
    147   MidiSetup             = (ULONG(*APIENTRY)(PMIDISETUP, ULONG)) modAddr;
     147  pfnMidiSetup             = (ULONG(*APIENTRY)(PMIDISETUP, ULONG)) modAddr;
    148148
    149149  rc = DosQueryProcAddr( iRTMidiModule, 0L, "MIDITimer", &modAddr );
    150150  if ( rc ) return rc;
    151   MidiTimer             = (ULONG(*APIENTRY )(ULONG, ULONG)) modAddr;
     151  pfnMidiTimer             = (ULONG(*APIENTRY )(ULONG, ULONG)) modAddr;
    152152
    153153  return 0;
     
    267267
    268268   // Query classes and get the Hardware & Application class numbers
    269    rc = (*MidiQueryNumClasses)( &nc, 0 );
     269   rc = MidiQueryNumClasses( &nc, 0 );
    270270   if ( rc == 0 && nc > 0 )
    271271   {
    272272      ci = new MIDICLASSINFO[ nc ];
    273       rc = (*MidiQueryClassList)( nc, ci, 0 );
     273      rc = MidiQueryClassList( nc, ci, 0 );
    274274   }
    275275   if ( rc == 0 && ci )
     
    313313
    314314   // Add new instance
    315    rc = (*MidiCreateInstance)( classNum,
     315   rc = MidiCreateInstance( classNum,
    316316                            &newInstance,
    317317                            instanceName,
     
    320320   if ( rc == 0 )
    321321   {
    322       rc = (*MidiQueryNumInstances)( &ni, 0 );
     322      rc = MidiQueryNumInstances( &ni, 0 );
    323323      if ( rc == 0 && ni > 0 )
    324324      {
    325325         ci = new MIDIINSTANCEINFO[ ni ];
    326          rc = (*MidiQueryInstanceList)( ni, ci, 0 );
     326         rc = MidiQueryInstanceList( ni, ci, 0 );
    327327      }
    328328   }
     
    363363
    364364   // Delete MIDI Instance
    365    rc = (*MidiDeleteInstance)( theInstance->instance(), 0 );
     365   rc = MidiDeleteInstance( theInstance->instance(), 0 );
    366366   setLastRC( rc );
    367367}
     
    397397
    398398  // Query instances and post them
    399   rc = (*MidiQueryNumInstances)( &ni, 0 );
     399  rc = MidiQueryNumInstances( &ni, 0 );
    400400  if ( rc == 0 && ni > 0 )
    401401  {
    402402    ci = new MIDIINSTANCEINFO[ ni ];
    403     rc = (*MidiQueryInstanceList)( ni, ci, 0 );
     403    rc = MidiQueryInstanceList( ni, ci, 0 );
    404404  }
    405405  if ( rc == 0 && ci )
     
    432432}
    433433
    434 void IRTMidi::startTimer() const
    435 {
    436   ((IRTMidi*)this)->setLastRC( (*MidiTimer)( MIDI_START_TIMER, 0 ) );
    437 }
    438 
    439 void IRTMidi::stopTimer() const
    440 {
    441   ((IRTMidi*)this)->setLastRC( (*MidiTimer)( MIDI_STOP_TIMER, 0 ) );
     434void IRTMidi::startTimer()
     435{
     436  ((IRTMidi*)this)->setLastRC( MidiTimer( MIDI_START_TIMER, 0 ) );
     437}
     438
     439void IRTMidi::stopTimer()
     440{
     441  ((IRTMidi*)this)->setLastRC( MidiTimer( MIDI_STOP_TIMER, 0 ) );
    442442}
    443443
     
    458458  if ( iTheIRTMidiSingleton != NULL )
    459459    delete iTheIRTMidiSingleton;
     460}
     461
     462ULONG IRTMidi::MidiCreateInstance( ULONG a, MINSTANCE* b, PSZ c, ULONG d)
     463{
     464  ULONG ret;
     465  USHORT sel = GetFS();
     466  ret = (*pfnMidiCreateInstance)(a,b,c,d);
     467  SetFS(sel);
     468  return ret;
     469}
     470ULONG IRTMidi::MidiDeleteInstance( MINSTANCE a, ULONG b)
     471{
     472  ULONG ret;
     473  USHORT sel = GetFS();
     474  ret = (*pfnMidiDeleteInstance)(a,b);
     475  SetFS(sel);
     476  return ret;
     477}
     478ULONG IRTMidi::MidiEnableInstance( MINSTANCE a, ULONG b )
     479{
     480  ULONG ret;
     481  USHORT sel = GetFS();
     482  ret = (*pfnMidiEnableInstance)(a,b);
     483  SetFS(sel);
     484  return ret;
     485}
     486ULONG IRTMidi::MidiDisableInstance( MINSTANCE a, ULONG b)
     487{
     488  ULONG ret;
     489  USHORT sel = GetFS();
     490  ret = (*pfnMidiDisableInstance)(a,b);
     491  SetFS(sel);
     492  return ret;
     493}
     494ULONG IRTMidi::MidiAddLink( MINSTANCE a, MINSTANCE b, ULONG c, ULONG d )
     495{
     496  ULONG ret;
     497  USHORT sel = GetFS();
     498  ret = (*pfnMidiAddLink)(a,b,c,d);
     499  SetFS(sel);
     500  return ret;
     501}
     502ULONG IRTMidi::MidiRemoveLink( MINSTANCE a, MINSTANCE b, ULONG c, ULONG d )
     503{
     504  ULONG ret;
     505  USHORT sel = GetFS();
     506  ret = (*pfnMidiRemoveLink)(a,b,c,d);
     507  SetFS(sel);
     508  return ret;
     509}
     510ULONG IRTMidi::MidiQueryClassList( ULONG a, PMIDICLASSINFO b, ULONG c)
     511{
     512  ULONG ret;
     513  USHORT sel = GetFS();
     514  ret = (*pfnMidiQueryClassList)(a,b,c);
     515  SetFS(sel);
     516  return ret;
     517}
     518ULONG IRTMidi::MidiQueryInstanceList ( ULONG a, PMIDIINSTANCEINFO b, ULONG c)
     519{
     520  ULONG ret;
     521  USHORT sel = GetFS();
     522  ret = (*pfnMidiQueryInstanceList)(a,b,c);
     523  SetFS(sel);
     524  return ret;
     525}
     526ULONG IRTMidi::MidiQueryNumClasses   ( PULONG a, ULONG b)
     527{
     528  ULONG ret;
     529  USHORT sel = GetFS();
     530  ret = (*pfnMidiQueryNumClasses)(a,b);
     531  SetFS(sel);
     532  return ret;
     533}
     534ULONG IRTMidi::MidiQueryNumInstances ( PULONG a, ULONG b)
     535{
     536  ULONG ret;
     537  USHORT sel = GetFS();
     538  ret = (*pfnMidiQueryNumInstances)(a,b);
     539  SetFS(sel);
     540  return ret;
     541}
     542ULONG IRTMidi::MidiSendMessages( PMESSAGE a, ULONG b, ULONG c )
     543{
     544  ULONG ret;
     545  USHORT sel = GetFS();
     546  ret = (*pfnMidiSendMessages)(a,b,c);
     547  SetFS(sel);
     548  return ret;
     549}
     550ULONG IRTMidi::MidiSendSysexMessage( PMESSAGE a, ULONG b, ULONG c )
     551{
     552  ULONG ret;
     553  USHORT sel = GetFS();
     554  ret = (*pfnMidiSendSysexMessage)(a,b,c);
     555  SetFS(sel);
     556  return ret;
     557}
     558ULONG IRTMidi::MidiRetrieveMessages( MINSTANCE a, PVOID b, PULONG c, ULONG d)
     559{
     560  ULONG ret;
     561  USHORT sel = GetFS();
     562  ret = (*pfnMidiRetrieveMessages)(a,b,c,d);
     563  SetFS(sel);
     564  return ret;
     565}
     566ULONG IRTMidi::MidiSetup( PMIDISETUP a, ULONG b)
     567{
     568  ULONG ret;
     569  USHORT sel = GetFS();
     570  ret = (*pfnMidiSetup)(a,b);
     571  SetFS(sel);
     572  return ret;
     573}
     574
     575ULONG IRTMidi::MidiTimer( ULONG a, ULONG b )
     576{
     577  ULONG ret;
     578  USHORT sel = GetFS();
     579  ret = (*pfnMidiTimer)(a,b);
     580  SetFS(sel);
     581  return ret;
    460582}
    461583
     
    525647    {
    526648      // Enable send
    527       rc = (*IRTMIDI->MidiEnableInstance)( instance(), MIDI_ENABLE_SEND );
     649      rc = IRTMIDI->MidiEnableInstance( instance(), MIDI_ENABLE_SEND );
    528650      if ( rc == 0 )
    529651         iInfo.ulAttributes |= MIDI_INST_ATTR_ENABLE_S;
     
    532654    {
    533655      // Disable send
    534       rc = (*IRTMIDI->MidiDisableInstance)( instance(), MIDI_DISABLE_SEND );
     656      rc = IRTMIDI->MidiDisableInstance( instance(), MIDI_DISABLE_SEND );
    535657      if ( rc == 0 )
    536658         iInfo.ulAttributes &= ~MIDI_INST_ATTR_ENABLE_S;
     
    554676    {
    555677      // Enable receive
    556       rc = (*IRTMIDI->MidiEnableInstance)( instance(), MIDI_ENABLE_RECEIVE );
     678      rc = IRTMIDI->MidiEnableInstance( instance(), MIDI_ENABLE_RECEIVE );
    557679      if ( rc == 0 )
    558680         iInfo.ulAttributes |= MIDI_INST_ATTR_ENABLE_R;
     
    561683    {
    562684      // Disable receive
    563       rc = (*IRTMIDI->MidiDisableInstance)( instance(), MIDI_DISABLE_RECEIVE );
     685      rc = IRTMIDI->MidiDisableInstance( instance(), MIDI_DISABLE_RECEIVE );
    564686      if ( rc == 0 )
    565687         iInfo.ulAttributes &= ~MIDI_INST_ATTR_ENABLE_R;
     
    585707  {
    586708    IRTMIDI->setLastRC(
    587          (*IRTMIDI->MidiRemoveLink)( instance(), toLink->instance(),
     709         IRTMIDI->MidiRemoveLink( instance(), toLink->instance(),
    588710                      0,       // slot?
    589711                      0 ) );
     
    605727    }
    606728    IRTMIDI->setLastRC(
    607        (*IRTMIDI->MidiAddLink)( instance(), toLink->instance(),
     729       IRTMIDI->MidiAddLink( instance(), toLink->instance(),
    608730                    0,       // slot ?
    609731                    0 ) );
     
    626748   msg.msg.abData[2]    = b3;
    627749   msg.msg.abData[3]    = b4;
    628    IRTMIDI->setLastRC( (*IRTMIDI->MidiSendMessages)( &msg, 1, 0 ) );
     750   IRTMIDI->setLastRC( IRTMIDI->MidiSendMessages( &msg, 1, 0 ) );
    629751}
    630752
     
    640762   msg.ulTrack          = 0;
    641763   msg.msg.ulMessage    = inMsg;
    642    IRTMIDI->setLastRC( (*IRTMIDI->MidiSendMessages)( &msg, 1, 0 ) );
     764   IRTMIDI->setLastRC( IRTMIDI->MidiSendMessages( &msg, 1, 0 ) );
    643765}
    644766
     
    657779   msg->ulTrack          = 0;
    658780   memcpy( msg->msg.abData, theMsg, outLen );
    659    IRTMIDI->setLastRC( (*IRTMIDI->MidiSendSysexMessage)( msg, outLen, 0 ) );
     781   IRTMIDI->setLastRC( IRTMIDI->MidiSendSysexMessage( msg, outLen, 0 ) );
    660782   free(msg);
    661783}
     
    667789   unsigned long rc = 0;
    668790   numUCHARs = sizeof( theMessage );
    669    rc = (*IRTMIDI->MidiRetrieveMessages)( instance(), &theMessage, &numUCHARs, 0 );
     791   rc = IRTMIDI->MidiRetrieveMessages( instance(), &theMessage, &numUCHARs, 0 );
    670792   if ( rc == 0 )
    671793   {
Note: See TracChangeset for help on using the changeset viewer.