From 6c1a16e61d37610e4a2ec21ca7880b20f60a5985 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 8 Jun 2005 04:16:03 +0000 Subject: [PATCH] assertions -> warnings --- stepmania/src/RageSound.cpp | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 3f94889fea..6cf68ba66a 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -638,7 +638,12 @@ void RageSound::SoundIsFinishedPlaying() RageSound *RageSound::Play( const RageSoundParams *params ) { - ASSERT( Sample ); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::Play: sound not loaded" ); + return NULL; + } + return SOUNDMAN->PlaySound( *this, params ); } @@ -649,14 +654,24 @@ void RageSound::Stop() bool RageSound::Pause( bool bPause ) { - ASSERT( Sample ); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::Pause: sound not loaded" ); + return false; + } + return SOUNDMAN->Pause( this, bPause ); } float RageSound::GetLengthSeconds() { - ASSERT(Sample); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::GetLengthSeconds: sound not loaded" ); + return -1; + } + int len = Sample->GetLength(); if(len < 0) @@ -745,20 +760,35 @@ float RageSound::GetPositionSeconds( bool *approximate, RageTimer *Timestamp ) c bool RageSound::SetPositionSeconds( float fSeconds ) { - ASSERT( Sample ); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::SetPositionSeconds(%f): sound not loaded", fSeconds ); + return false; + } + return SetPositionFrames( int(fSeconds * samplerate()) ); } /* This is always the desired sample rate of the current driver. */ int RageSound::GetSampleRate() const { - ASSERT( Sample ); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::GetSampleRate(): sound not loaded" ); + return 44100; + } + return Sample->GetSampleRate(); } bool RageSound::IsStreamingFromDisk() const { - ASSERT( Sample ); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::IsStreamingFromDisk: sound not loaded" ); + return false; + } + return Sample->IsStreamingFromDisk(); } @@ -766,6 +796,12 @@ bool RageSound::SetPositionFrames( int frames ) { LockMut(m_Mutex); + if( Sample == NULL ) + { + LOG->Warn( "RageSound::SetPositionFrames(%f): sound not loaded", frames ); + return false; + } + { /* "decode_position" records the number of frames we've output to the * speaker. If the rate isn't 1.0, this will be different from the @@ -789,8 +825,6 @@ bool RageSound::SetPositionFrames( int frames ) databuf.clear(); - ASSERT(Sample); - int ret; if( m_Param.AccurateSync ) ret = Sample->SetPosition_Accurate(ms);