MCPcopy Create free account
hub / github.com/JACoders/OpenJK / S_HandleDynamicMusicStateChange

Function S_HandleDynamicMusicStateChange

code/client/snd_dma.cpp:4343–4492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4341
4342
4343static void S_HandleDynamicMusicStateChange( void )
4344{
4345 if (eMusic_StateRequest != eMusic_StateActual)
4346 {
4347 // check whether or not the new request can be honoured, given what's currently playing...
4348 //
4349 if (Music_StateCanBeInterrupted( eMusic_StateActual, eMusic_StateRequest ))
4350 {
4351 LP_MP3STREAM pMP3StreamActual = &tMusic_Info[ eMusic_StateActual ].chMP3_Bgrnd.MP3StreamHeader;
4352
4353 switch (eMusic_StateRequest)
4354 {
4355 case eBGRNDTRACK_EXPLORE: // ... from action or silence
4356 {
4357 switch (eMusic_StateActual)
4358 {
4359 case eBGRNDTRACK_ACTION: // action->explore
4360 {
4361 // find the transition track to play, and the entry point for explore when we get there,
4362 // and also see if we're at a permitted exit point to switch at all...
4363 //
4364 float fPlayingTimeElapsed = MP3Stream_GetPlayingTimeInSeconds( pMP3StreamActual ) - MP3Stream_GetRemainingTimeInSeconds( pMP3StreamActual );
4365
4366 // supply:
4367 //
4368 // playing point in float seconds
4369 // enum of track being queried
4370 //
4371 // get:
4372 //
4373 // enum of transition track to switch to
4374 // float time of entry point of new track *after* transition
4375
4376 MusicState_e eTransition;
4377 float fNewTrackEntryTime = 0.0f;
4378 if (Music_AllowedToTransition( fPlayingTimeElapsed, eBGRNDTRACK_ACTION, &eTransition, &fNewTrackEntryTime))
4379 {
4380 S_SwitchDynamicTracks( eMusic_StateActual, eTransition, qfalse ); // qboolean bNewTrackStartsFullVolume
4381
4382 tMusic_Info[eTransition].Rewind();
4383 tMusic_Info[eTransition].bTrackSwitchPending = qtrue;
4384 tMusic_Info[eTransition].eTS_NewState = eMusic_StateRequest;
4385 tMusic_Info[eTransition].fTS_NewTime = fNewTrackEntryTime;
4386 }
4387 }
4388 break;
4389
4390 case eBGRNDTRACK_SILENCE: // silence->explore
4391 {
4392 S_SwitchDynamicTracks( eMusic_StateActual, eMusic_StateRequest, qfalse ); // qboolean bNewTrackStartsFullVolume
4393
4394// float fEntryTime = Music_GetRandomEntryTime( eMusic_StateRequest );
4395// tMusic_Info[ eMusic_StateRequest ].SeekTo(fEntryTime);
4396 tMusic_Info[ eMusic_StateRequest ].Rewind();
4397 }
4398 break;
4399
4400 default: // trying to transition from some state I wasn't aware you could transition from (shouldn't happen), so ignore

Callers 1

S_CheckDynamicMusicStateFunction · 0.70

Calls 8

RewindMethod · 0.80
SeekToMethod · 0.80
S_SwitchDynamicTracksFunction · 0.70
Music_GetRandomEntryTimeFunction · 0.70

Tested by

no test coverage detected