From 9dfcb5b7e1f31d49a64eb7abcb3e70381a9d21df Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 11 May 2004 20:32:55 +0000 Subject: [PATCH] convert sound types --- stepmania/src/RageSoundManager.cpp | 16 ++++++++-------- stepmania/src/RageSoundManager.h | 8 ++++---- stepmania/src/arch/Sound/ALSA9Helpers.cpp | 2 +- stepmania/src/arch/Sound/ALSA9Helpers.h | 2 +- .../src/arch/Sound/RageSoundDriver_ALSA9.cpp | 8 ++++---- .../Sound/RageSoundDriver_ALSA9_Software.cpp | 6 +++--- .../Sound/RageSoundDriver_Generic_Software.cpp | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index f636bfa6cb..1f6cf9f533 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -363,11 +363,11 @@ void RageSoundManager::SetPrefs(float MixVol) } /* Standalone helpers: */ -void RageSoundManager::AttenuateBuf( Sint16 *buf, int samples, float vol ) +void RageSoundManager::AttenuateBuf( int16_t *buf, int samples, float vol ) { while( samples-- ) { - *buf = Sint16( (*buf) * vol ); + *buf = int16_t( (*buf) * vol ); ++buf; } } @@ -390,7 +390,7 @@ void SoundMixBuffer::SetVolume( float f ) vol = int(256*f); } -void SoundMixBuffer::write( const Sint16 *buf, unsigned size, float volume, int offset ) +void SoundMixBuffer::write( const int16_t *buf, unsigned size, float volume, int offset ) { int factor = vol; if( volume != -1 ) @@ -399,13 +399,13 @@ void SoundMixBuffer::write( const Sint16 *buf, unsigned size, float volume, int const unsigned realsize = size+offset; if( bufsize < realsize ) { - mixbuf = (Sint32 *) realloc( mixbuf, sizeof(Sint32) * realsize ); + mixbuf = (int32_t *) realloc( mixbuf, sizeof(int32_t) * realsize ); bufsize = realsize; } if( used < realsize ) { - memset( mixbuf + used, 0, (realsize - used) * sizeof(Sint32) ); + memset( mixbuf + used, 0, (realsize - used) * sizeof(int32_t) ); used = realsize; } @@ -414,12 +414,12 @@ void SoundMixBuffer::write( const Sint16 *buf, unsigned size, float volume, int mixbuf[pos+offset] += buf[pos] * factor; } -void SoundMixBuffer::read(Sint16 *buf) +void SoundMixBuffer::read(int16_t *buf) { for( unsigned pos = 0; pos < used; ++pos ) { - Sint32 out = (mixbuf[pos]) / 256; - buf[pos] = (Sint16) clamp( out, -32768, 32767 ); + int32_t out = (mixbuf[pos]) / 256; + buf[pos] = (int16_t) clamp( out, -32768, 32767 ); } used = 0; } diff --git a/stepmania/src/RageSoundManager.h b/stepmania/src/RageSoundManager.h index 59962558a1..92c809c338 100644 --- a/stepmania/src/RageSoundManager.h +++ b/stepmania/src/RageSoundManager.h @@ -69,7 +69,7 @@ public: void GetCopies( RageSound &snd, vector &snds, bool bLockSounds=false ); - static void AttenuateBuf( Sint16 *buf, int samples, float vol ); + static void AttenuateBuf( int16_t *buf, int samples, float vol ); private: void FlushPosMapQueue(); @@ -79,14 +79,14 @@ private: /* This inputs and outputs 16-bit 44khz stereo input. */ class SoundMixBuffer { - Sint32 *mixbuf; + int32_t *mixbuf; unsigned bufsize; /* actual allocated samples */ unsigned used; /* used samples */ int vol; /* vol * 256 */ public: - void write( const Sint16 *buf, unsigned size, float volume = -1, int offset = 0 ); - void read(Sint16 *buf); + void write( const int16_t *buf, unsigned size, float volume = -1, int offset = 0 ); + void read(int16_t *buf); void read( float *buf ); unsigned size() const { return used; } void SetVolume(float f); diff --git a/stepmania/src/arch/Sound/ALSA9Helpers.cpp b/stepmania/src/arch/Sound/ALSA9Helpers.cpp index 936a7c4006..52afe52ebc 100644 --- a/stepmania/src/arch/Sound/ALSA9Helpers.cpp +++ b/stepmania/src/arch/Sound/ALSA9Helpers.cpp @@ -318,7 +318,7 @@ bool Alsa9Buf::WaitUntilFramesCanBeFilled( int timeout_ms ) return err == 1; } -void Alsa9Buf::Write( const Sint16 *buffer, int frames ) +void Alsa9Buf::Write( const int16_t *buffer, int frames ) { /* We should be able to write it all. If we don't, treat it as an error. */ int wrote = dsnd_pcm_mmap_writei( pcm, (const char *) buffer, frames ); diff --git a/stepmania/src/arch/Sound/ALSA9Helpers.h b/stepmania/src/arch/Sound/ALSA9Helpers.h index 62f79a77c8..c7191a9f70 100644 --- a/stepmania/src/arch/Sound/ALSA9Helpers.h +++ b/stepmania/src/arch/Sound/ALSA9Helpers.h @@ -38,7 +38,7 @@ public: int GetNumFramesToFill(); bool WaitUntilFramesCanBeFilled( int timeout_ms ); - void Write( const Sint16 *buffer, int frames ); + void Write( const int16_t *buffer, int frames ); unsigned FindSampleRate( unsigned rate ); void Play(); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp index 2489758d5e..d03809da83 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp @@ -11,7 +11,7 @@ const int channels = 2; const int samplerate = 44100; const int samples_per_frame = channels; -const int bytes_per_frame = sizeof(Sint16) * samples_per_frame; +const int bytes_per_frame = sizeof(int16_t) * samples_per_frame; const unsigned max_writeahead = 1024*8; const int num_chunks = 8; @@ -92,9 +92,9 @@ bool RageSound_ALSA9::stream::GetData( bool &bEOF ) if( frames_to_fill < chunksize ) return false; - static Sint16 *buf = NULL; + static int16_t *buf = NULL; if ( !buf ) - buf = new Sint16[max_writeahead*samples_per_frame]; + buf = new int16_t[max_writeahead*samples_per_frame]; char *cbuf = (char*) buf; const int64_t play_pos = pcm->GetPlayPos(); @@ -130,7 +130,7 @@ bool RageSound_ALSA9::stream::GetData( bool &bEOF ) bytes_read += got; bytes_left -= got; - RageSoundManager::AttenuateBuf( buf, got/sizeof(Sint16), snd->GetVolume() ); + RageSoundManager::AttenuateBuf( buf, got/sizeof(int16_t), snd->GetVolume() ); if( bytes_left > 0 ) { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp index 24f83b57f6..959d04d74d 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp @@ -18,7 +18,7 @@ static const int channels = 2; int samplerate = 44100; static const int samples_per_frame = channels; -static const int bytes_per_frame = sizeof(Sint16) * samples_per_frame; +static const int bytes_per_frame = sizeof(int16_t) * samples_per_frame; /* Linux 2.6 has a fine-grained scheduler. We can almost always use a smaller buffer * size than in 2.4. XXX: Some cards can handle smaller buffer sizes than others. */ @@ -57,9 +57,9 @@ bool RageSound_ALSA9_Software::GetData() if( frames_to_fill <= 0 ) return false; - static Sint16 *buf = NULL; + static int16_t *buf = NULL; if (!buf) - buf = new Sint16[max_writeahead*samples_per_frame]; + buf = new int16_t[max_writeahead*samples_per_frame]; const int64_t play_pos = pcm->GetPlayPos(); const int64_t cur_play_pos = pcm->GetPosition(); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp index cb36a14767..1614a625f3 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp @@ -109,7 +109,7 @@ void RageSound_Generic_Software::Mix( int16_t *buf, int frames, int64_t frameno, /* Note that, until we call advance_read_pointer, we can safely write to p[0]. */ const int frames_to_read = min( frames_left, p[0]->frames_in_buffer ); - mix.write( (Sint16*)p[0]->p, frames_to_read * channels, s.volume, got_frames*channels ); + mix.write( p[0]->p, frames_to_read * channels, s.volume, got_frames*channels ); SOUNDMAN->CommitPlayingPosition( s.sound_id, frameno+got_frames, p[0]->position, frames_to_read ); @@ -133,7 +133,7 @@ void RageSound_Generic_Software::Mix( int16_t *buf, int frames, int64_t frameno, } memset( buf, 0, frames*bytes_per_frame ); - mix.read( (Sint16*)buf ); + mix.read( buf ); }