summaryrefslogtreecommitdiff
path: root/streamer.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-30 21:14:25 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-30 21:14:25 +0100
commit907ed40fd1b1a1298e5d339f51e68df5f0b63872 (patch)
treeb8802e5191a621b11c108ee322db00407b03ab23 /streamer.c
parentbe472188fde7aa235c426486c42ae4e2278c9093 (diff)
few minor optimizations
Diffstat (limited to 'streamer.c')
-rw-r--r--streamer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/streamer.c b/streamer.c
index 8737ee3d..79106a9b 100644
--- a/streamer.c
+++ b/streamer.c
@@ -2099,10 +2099,12 @@ streamer_read (char *bytes, int size) {
mutex_unlock (audio_mem_mutex);
if (!output->has_volume) {
+ int mult = 1-audio_is_mute ();
char *stream = bytes;
int bytesread = sz;
if (output->fmt.bps == 16) {
- int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000;
+ mult *= 1000;
+ int16_t ivolume = volume_get_amp () * mult;
for (int i = 0; i < bytesread/2; i++) {
int16_t sample = *((int16_t*)stream);
*((int16_t*)stream) = (int16_t)(((int32_t)sample) * ivolume / 1000);
@@ -2110,14 +2112,16 @@ streamer_read (char *bytes, int size) {
}
}
else if (output->fmt.bps == 8) {
- int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 255;
+ mult *= 255;
+ int16_t ivolume = volume_get_amp () * mult;
for (int i = 0; i < bytesread; i++) {
*stream = (int8_t)(((int32_t)(*stream)) * ivolume / 1000);
stream++;
}
}
else if (output->fmt.bps == 24) {
- int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000;
+ mult *= 1000;
+ int16_t ivolume = volume_get_amp () * mult;
for (int i = 0; i < bytesread/3; i++) {
int32_t sample = ((unsigned char)stream[0]) | ((unsigned char)stream[1]<<8) | (stream[2]<<16);
int32_t newsample = (int64_t)sample * ivolume / 1000;
@@ -2128,7 +2132,8 @@ streamer_read (char *bytes, int size) {
}
}
else if (output->fmt.bps == 32 && !output->fmt.is_float) {
- int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000;
+ mult *= 1000;
+ int16_t ivolume = volume_get_amp () * mult;
for (int i = 0; i < bytesread/4; i++) {
int32_t sample = *((int32_t*)stream);
int32_t newsample = (int64_t)sample * ivolume / 1000;