Ignore:
Timestamp:
Apr 20, 2001, 3:22:38 PM (24 years ago)
Author:
phaller
Message:

Fix crashes in PowerDVD 3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dsound/dart.cpp

    r5285 r5553  
    1 /* $Id: dart.cpp,v 1.4 2001-03-06 20:11:16 mike Exp $ */
     1/* $Id: dart.cpp,v 1.5 2001-04-20 13:22:37 phaller Exp $ */
    22/*
    33 *  Dart Interface..
     
    5151     )
    5252   {
    53       lLastBuff++;
    54       if (lLastBuff == ulNumDartBuffs){
    55          lLastBuff = 0;
    56       }
    57 
    58       if( fIsPlaying == FALSE /*&& lLastBuff == 0*/ ){
    59          mciSendCommand(usDeviceID, MCI_STOP, MCI_WAIT, NULL, 0);
    60          return TRUE;
    61       }
     53     // wrap last buffer index
     54     lLastBuff++;
     55     if (lLastBuff >= ulNumDartBuffs)
     56     {
     57       lLastBuff = 0;
     58     }
     59
     60     if( fIsPlaying == FALSE /*&& lLastBuff == 0*/ )
     61     {
     62       mciSendCommand(usDeviceID, MCI_STOP, MCI_WAIT, NULL, 0);
     63       return TRUE;
     64     }
    6265
    6366      /* Now mix sound from all playing secondary SoundBuffers into the primary buffer */
     
    370373long Dart_Play(USHORT usDeviceID, void *vpMixSetup, void *vpMixBuffer, long playing)
    371374{
    372    ULONG   rc;
    373    MCI_MIXSETUP_PARMS  *MixSetup;
    374    MCI_MIX_BUFFER      *MixBuffer;
    375 
    376    MixSetup  = (MCI_MIXSETUP_PARMS*)vpMixSetup;
    377    MixBuffer = (MCI_MIX_BUFFER*)vpMixBuffer;
    378 
    379    dprintf(("DSOUND-DART: Dart_Play"));
    380 
    381    if (playing == TRUE) {
    382       rc = mciSendCommand(usDeviceID, MCI_RESUME, MCI_WAIT, NULL, 0);
    383       if (rc != MCIERR_SUCCESS) {
    384          dprintf(("DSOUND-DART: MCI_RESUME %d", rc));
    385          return DSERR_GENERIC;
    386       }
    387    } else { //if (playing==FALSE)
    388       dprintf(("DSOUND-DART: Playback started!!!!"));
    389 
    390       /* Mix the first buffer before playing */
     375  ULONG   rc;
     376  MCI_MIXSETUP_PARMS  *MixSetup;
     377  MCI_MIX_BUFFER      *MixBuffer;
     378
     379  MixSetup  = (MCI_MIXSETUP_PARMS*)vpMixSetup;
     380  MixBuffer = (MCI_MIX_BUFFER*)vpMixBuffer;
     381
     382  dprintf(("DSOUND-DART: Dart_Play"));
     383
     384  if (playing == TRUE)
     385  {
     386    rc = mciSendCommand(usDeviceID, MCI_RESUME, MCI_WAIT, NULL, 0);
     387    if (rc != MCIERR_SUCCESS)
     388    {
     389      dprintf(("DSOUND-DART: MCI_RESUME %d", rc));
     390      return DSERR_GENERIC;
     391    }
     392  }
     393  else
     394  { //if (playing==FALSE)
     395    dprintf(("DSOUND-DART: Playback started!!!!"));
     396   
     397    // verify if buffers have actually been allocated
     398    // PH 2001-04-20 Power DVD 3 seens to come in here
     399    // with ulNumDartBuffs == 0 and also pmixWrite==NULL.
     400    // However pmixEvent is != NULL. So I assume (!)
     401    // this might fix the cause.
     402    //
     403    // Does fix the crash actually. I suspect DART cannot
     404    // deliver mixing functions for the requested sound format:
     405    // 16-Bit, 4-channel?, 48kHz.
     406    if( (MixSetup->pmixWrite != NULL) &&
     407        (MixSetup->ulNumBuffers > 0) )
     408    {
     409
     410    /* Mix the first buffer before playing */
    391411      MixCallback(BUFFER_SIZE/ulNumDartBuffs);
    392412      memcpy(MixBuffer[lLastBuff].pBuffer, &pDSoundBuff[lLastBuff*(BUFFER_SIZE/ulNumDartBuffs)], BUFFER_SIZE/ulNumDartBuffs);
     
    398418      SetFS(sel);
    399419      fIsPlaying = TRUE;
    400    }
    401 
    402    return DS_OK;
    403 }
     420    }
     421  }
     422
     423  return DS_OK;
     424}
Note: See TracChangeset for help on using the changeset viewer.