static void ClearDupBuffers( Channel* channel ) { Channel* dupChannel, *prevChannel; if( channel == NULL) return; dupChannel = channel->nextDup; prevChannel = channel; while( dupChannel ) { if( !ChannelPlaying( dupChannel ) ) { prevChannel->nextDup = dupChannel->nextDup; IDirectSound_Release(dupChannel->buffer); // free( dupChannel ); geRam_Free(dupChannel); dupChannel = prevChannel->nextDup; } else { prevChannel = dupChannel; dupChannel = dupChannel->nextDup; } } }
//===================================================================================== // Sound_SoundIsPlaying //===================================================================================== GENESISAPI geBoolean geSound_SoundIsPlaying(geSound_System *SoundS, geSound *Sound) { Channel* Channel; assert(SoundS != NULL); assert(Sound != NULL); Channel = GetChannel(SoundS->SoundM, (unsigned int)Sound); if (!Channel) return GE_FALSE; return ChannelPlaying(Channel); }
//===================================================================================== // Sound_SoundIsPlaying //===================================================================================== GENESISAPI geBoolean geSound_SoundIsPlaying(geSound_System *SoundS, geSound *Sound) { Channel* Channel; assert(SoundS != NULL); if(Sound == NULL) return GE_FALSE; // eaa3 05/29/2000 don't assert if NULL handle! Channel = GetChannel(SoundS->SoundM, (unsigned int)Sound); if (!Channel) return GE_FALSE; return ChannelPlaying(Channel); }
static BOOL StartSoundChannel( SoundManager *sm, unsigned int Handle, geSound_Cfg *cfg, int loop, unsigned int* sfx) { HRESULT hres; Channel* channel, *dupChannel; if( Handle == 0 ) return( FALSE ); channel = GetChannel( sm, Handle ); //Clear all non-playing duplicate buffers. ClearDupBuffers(channel); //If the main buffer is playing and all non-playing dups have been cleared //we need a new duplicate. if( ChannelPlaying( channel ) ) { if(!DupChannel( sm,channel, &dupChannel ) ) return( FALSE ); channel = dupChannel; } if( !ModifyChannel( channel, cfg ) ) return( FALSE ); IDirectSoundBuffer_SetCurrentPosition(channel->buffer, 0); hres = IDirectSoundBuffer_Play( channel->buffer, 0, 0, loop ? DSBPLAY_LOOPING : 0); if (hres == DS_OK) { if( sfx ) *sfx = channel->ID; return TRUE; } geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; }
void ship_death (ELEMENT *ShipPtr) { STARSHIP *StarShipPtr; STARSHIP *VictoriousStarShipPtr; HELEMENT hElement, hNextElement; ELEMENT *ElementPtr; StopDitty (); StopMusic (); GetElementStarShip (ShipPtr, &StarShipPtr); // JMS: Make sure the Foon-foon's spinning blade sound ends when the ship dies. if (StarShipPtr->SpeciesID == FOONFOON_ID) { COUNT i; for (i = FIRST_SFX_CHANNEL; i <= LAST_SFX_CHANNEL; ++i) { ELEMENT *posobj; if (!ChannelPlaying(i)) continue; posobj = GetPositionalObject (i); if (posobj) StopSource (i); } } if (ShipPtr->mass_points <= MAX_SHIP_MASS) { // Not running away and not reincarnating (Pkunk) // When a ship tries to run away, it is (dis)counted in DoRunAway(), // so when it dies while running away, we will not count it again assert (StarShipPtr->playerNr >= 0); battle_counter[StarShipPtr->playerNr]--; } VictoriousStarShipPtr = NULL; for (hElement = GetHeadElement (); hElement; hElement = hNextElement) { LockElement (hElement, &ElementPtr); if ((ElementPtr->state_flags & PLAYER_SHIP) && ElementPtr != ShipPtr /* and not running away */ && ElementPtr->mass_points <= MAX_SHIP_MASS) { GetElementStarShip (ElementPtr, &VictoriousStarShipPtr); if (VictoriousStarShipPtr->RaceDescPtr->ship_info.crew_level == 0) VictoriousStarShipPtr = NULL; UnlockElement (hElement); break; } hNextElement = GetSuccElement (ElementPtr); UnlockElement (hElement); } StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY; DeltaEnergy (ShipPtr, -(SIZE)StarShipPtr->RaceDescPtr->ship_info.energy_level); ShipPtr->life_span = NUM_EXPLOSION_FRAMES * 3; ShipPtr->state_flags &= ~DISAPPEARING; ShipPtr->state_flags |= FINITE_LIFE | NONSOLID; ShipPtr->postprocess_func = PostProcessStatus; ShipPtr->death_func = cleanup_dead_ship; ShipPtr->hTarget = 0; ZeroVelocityComponents (&ShipPtr->velocity); if (ShipPtr->crew_level) /* only happens for shofixti self-destruct */ { PlaySound (SetAbsSoundIndex ( StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); DeltaCrew (ShipPtr, -(SIZE)ShipPtr->crew_level); if (VictoriousStarShipPtr == NULL) { // No ships left alive after a Shofixti Glory device, // thus Shofixti wins VictoriousStarShipPtr = StarShipPtr; } } else { ShipPtr->preprocess_func = explosion_preprocess; PlaySound (SetAbsSoundIndex (GameSounds, SHIP_EXPLODES), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); } if (VictoriousStarShipPtr != NULL) VictoriousStarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY; // The winner is set once per battle. If both ships die, this function is // called twice, once for each ship. We need to preserve the winner // determined on the first call. if (winnerStarShip == NULL) winnerStarShip = VictoriousStarShipPtr; if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) MeleeShipDeath (StarShipPtr); }