diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2009-01-05 02:29:58 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2009-01-05 02:29:58 +0000 |
commit | 6920a5be449b258ebbde6e709607dddb00511a6b (patch) | |
tree | b09e3560a3b19ae1dad59c9c92ea15878cd683e3 /apps | |
parent | 96474e3b4d889690286d7bea049d594338b27afd (diff) |
rockdoom: Mixing 512 samples in an interrupt handler is too much. Gigabeast FIFOs are very tight and it will channel swap and crackle. It's better to minimize time in the audio callback anyway so change it to 128. It should probably even be 64. Use faster saturation code too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19679 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/doom/i_sound.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/plugins/doom/i_sound.c b/apps/plugins/doom/i_sound.c index 2f4f594077..35cecd8abb 100644 --- a/apps/plugins/doom/i_sound.c +++ b/apps/plugins/doom/i_sound.c @@ -48,7 +48,7 @@ // mixing buffer, and the samplerate of the raw data. // Needed for calling the actual sound output. -#define SAMPLECOUNT 512 +#define SAMPLECOUNT 128 #define NUM_CHANNELS 24 // It is 2 for 16bit, and 2 for two channels. @@ -99,6 +99,13 @@ int *vol_lookup; // Volume lookups. int *steptable; // Pitch to stepping lookup. (Not setup properly right now) +static inline int32_t clip_sample16(int32_t sample) +{ + if ((int16_t)sample != sample) + sample = 0x7fff ^ (sample >> 31); + return sample; +} + // // This function loads the sound data from the WAD lump for single sound. // It is used to cache all the sounddata at startup. @@ -371,7 +378,7 @@ void I_UpdateSound( void ) signed short* leftend; // Step in mixbuffer, left and right, thus two. - int step; + const int step = 2; // Mixing channel index. int chan; @@ -380,7 +387,6 @@ void I_UpdateSound( void ) // are in global mixbuffer, alternating. leftout = mixbuffer; rightout = mixbuffer +1; - step = 2; // Determine end, for left channel only // (right channel is implicit). @@ -431,20 +437,10 @@ void I_UpdateSound( void ) // else if (dl < -128) *leftout = -128; // else *leftout = dl; - if (dl > 0x7fff) - *leftout = 0x7fff; - else if (dl < -0x8000) - *leftout = -0x8000; - else - *leftout = (signed short)dl; + *leftout = clip_sample16(dl); // Same for right hardware channel. - if (dr > 0x7fff) - *rightout = 0x7fff; - else if (dr < -0x8000) - *rightout = -0x8000; - else - *rightout = (signed short)dr; + *rightout = clip_sample16(dr); // Increment current pointers in mixbuffer. leftout += step; |