convert sound types
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
void GetCopies( RageSound &snd, vector<RageSound *> &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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user