[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.12-109-g33b186e
Lennart Poettering
gitmailer-noreply at 0pointer.de
Thu Oct 2 17:38:05 PDT 2008
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from ea82dec294310b83be25b4e0c940fd2cd2c7eeb3 (commit)
- Log -----------------------------------------------------------------
33b186e... user lrint() and friends in inner loops instead of normal C casts to speed up a few things
1bb5e58... use PA_FLOAT32_SWAP where useful
7d442e3... optimize mixing routines a bit by pulling the multiplication with the global volume out of the inner loop by applying it first to the per-stream volumes
a0f4ffd... make sure we call pa_sink_process_rewind() if a rewind was requested under all circumstances
-----------------------------------------------------------------------
Summary of changes:
src/modules/module-null-sink.c | 9 ++-
src/pulse/volume.c | 2 +-
src/pulsecore/sample-util.c | 197 +++++++++++++++++-----------------------
src/pulsecore/sconv-s16le.c | 20 ++---
src/pulsecore/sconv.c | 4 +-
src/pulsecore/time-smoother.c | 8 +-
6 files changed, 107 insertions(+), 133 deletions(-)
-----------------------------------------------------------------------
commit a0f4ffd3e12c0274ca05a577d03914270370b724
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Oct 2 03:07:54 2008 +0200
make sure we call pa_sink_process_rewind() if a rewind was requested under all circumstances
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index 9162960..470c622 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -137,13 +137,13 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
if (u->timestamp <= now)
- return;
+ goto do_nothing;
delay = u->timestamp - now;
in_buffer = pa_usec_to_bytes(delay, &u->sink->sample_spec);
if (in_buffer <= 0)
- return;
+ goto do_nothing;
if (rewind_nbytes > in_buffer)
rewind_nbytes = in_buffer;
@@ -152,6 +152,11 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
u->timestamp -= pa_bytes_to_usec(rewind_nbytes, &u->sink->sample_spec);
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
+ return;
+
+do_nothing:
+
+ pa_sink_process_rewind(u->sink, 0);
}
static void process_render(struct userdata *u, pa_usec_t now) {
commit 7d442e32769cfcf2e286f32be33821fbf8de2c7d
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Oct 3 01:53:34 2008 +0200
optimize mixing routines a bit by pulling the multiplication with the global volume out of the inner loop by applying it first to the per-stream volumes
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 25178a8..b4e8bf4 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -98,56 +98,62 @@ void* pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec) {
return p;
}
-static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_sample_spec *spec) {
- unsigned k;
-
- pa_assert(streams);
- pa_assert(spec);
+static void calc_linear_integer_volume(int32_t linear[], const pa_cvolume *volume) {
+ unsigned channel;
- for (k = 0; k < nstreams; k++) {
- unsigned channel;
+ pa_assert(linear);
+ pa_assert(volume);
- for (channel = 0; channel < spec->channels; channel++) {
- pa_mix_info *m = streams + k;
- m->linear[channel].i = (int32_t) (pa_sw_volume_to_linear(m->volume.values[channel]) * 0x10000);
- }
- }
+ for (channel = 0; channel < volume->channels; channel++)
+ linear[channel] = (int32_t) (pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
}
-static void calc_linear_integer_volume(int32_t linear[], const pa_cvolume *volume) {
+static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
unsigned channel;
pa_assert(linear);
pa_assert(volume);
for (channel = 0; channel < volume->channels; channel++)
- linear[channel] = (int32_t) (pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
+ linear[channel] = (float) pa_sw_volume_to_linear(volume->values[channel]);
}
-static void calc_linear_float_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_sample_spec *spec) {
- unsigned k;
+static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_cvolume *volume, const pa_sample_spec *spec) {
+ unsigned k, channel;
+ float linear[PA_CHANNELS_MAX];
pa_assert(streams);
pa_assert(spec);
+ pa_assert(volume);
+
+ calc_linear_float_volume(linear, volume);
for (k = 0; k < nstreams; k++) {
- unsigned channel;
for (channel = 0; channel < spec->channels; channel++) {
pa_mix_info *m = streams + k;
- m->linear[channel].f = (float) pa_sw_volume_to_linear(m->volume.values[channel]);
+ m->linear[channel].i = (int32_t) (pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel] * 0x10000);
}
}
}
-static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
- unsigned channel;
+static void calc_linear_float_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_cvolume *volume, const pa_sample_spec *spec) {
+ unsigned k, channel;
+ float linear[PA_CHANNELS_MAX];
- pa_assert(linear);
+ pa_assert(streams);
+ pa_assert(spec);
pa_assert(volume);
- for (channel = 0; channel < volume->channels; channel++)
- linear[channel] = (float) pa_sw_volume_to_linear(volume->values[channel]);
+ calc_linear_float_volume(linear, volume);
+
+ for (k = 0; k < nstreams; k++) {
+
+ for (channel = 0; channel < spec->channels; channel++) {
+ pa_mix_info *m = streams + k;
+ m->linear[channel].f = (float) (pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel]);
+ }
+ }
}
size_t pa_mix(
@@ -190,10 +196,8 @@ size_t pa_mix(
case PA_SAMPLE_S16NE:{
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int32_t sum = 0;
@@ -203,19 +207,17 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
int32_t v, cv = m->linear[channel].i;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = *((int16_t*) m->ptr);
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = *((int16_t*) m->ptr);
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
}
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- sum = (sum * linear[channel]) / 0x10000;
*((int16_t*) data) = (int16_t) sum;
data = (uint8_t*) data + sizeof(int16_t);
@@ -229,10 +231,8 @@ size_t pa_mix(
case PA_SAMPLE_S16RE:{
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int32_t sum = 0;
@@ -242,19 +242,17 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
int32_t v, cv = m->linear[channel].i;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = PA_INT16_SWAP(*((int16_t*) m->ptr));
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = PA_INT16_SWAP(*((int16_t*) m->ptr));
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
}
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- sum = (sum * linear[channel]) / 0x10000;
*((int16_t*) data) = PA_INT16_SWAP((int16_t) sum);
data = (uint8_t*) data + sizeof(int16_t);
@@ -268,10 +266,8 @@ size_t pa_mix(
case PA_SAMPLE_S32NE:{
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int64_t sum = 0;
@@ -279,21 +275,19 @@ size_t pa_mix(
for (i = 0; i < nstreams; i++) {
pa_mix_info *m = streams + i;
- int64_t v;
int32_t cv = m->linear[channel].i;
+ int64_t v;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = *((int32_t*) m->ptr);
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = *((int32_t*) m->ptr);
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(int32_t);
}
- sum = (sum * linear[channel]) / 0x10000;
sum = PA_CLAMP_UNLIKELY(sum, -0x80000000LL, 0x7FFFFFFFLL);
*((int32_t*) data) = (int32_t) sum;
@@ -308,10 +302,8 @@ size_t pa_mix(
case PA_SAMPLE_S32RE:{
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int64_t sum = 0;
@@ -319,21 +311,19 @@ size_t pa_mix(
for (i = 0; i < nstreams; i++) {
pa_mix_info *m = streams + i;
- int64_t v;
int32_t cv = m->linear[channel].i;
+ int64_t v;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = PA_INT32_SWAP(*((int32_t*) m->ptr));
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = PA_INT32_SWAP(*((int32_t*) m->ptr));
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(int32_t);
}
- sum = (sum * linear[channel]) / 0x10000;
sum = PA_CLAMP_UNLIKELY(sum, -0x80000000LL, 0x7FFFFFFFLL);
*((int32_t*) data) = PA_INT32_SWAP((int32_t) sum);
@@ -348,10 +338,8 @@ size_t pa_mix(
case PA_SAMPLE_U8: {
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int32_t sum = 0;
@@ -361,18 +349,16 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
int32_t v, cv = m->linear[channel].i;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = (int32_t) *((uint8_t*) m->ptr) - 0x80;
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = (int32_t) *((uint8_t*) m->ptr) - 0x80;
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + 1;
}
- sum = (sum * linear[channel]) / 0x10000;
sum = PA_CLAMP_UNLIKELY(sum, -0x80, 0x7F);
*((uint8_t*) data) = (uint8_t) (sum + 0x80);
@@ -387,10 +373,8 @@ size_t pa_mix(
case PA_SAMPLE_ULAW: {
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int32_t sum = 0;
@@ -400,19 +384,17 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
int32_t v, cv = m->linear[channel].i;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = (int32_t) st_ulaw2linear16(*((uint8_t*) m->ptr));
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = (int32_t) st_ulaw2linear16(*((uint8_t*) m->ptr));
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + 1;
}
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- sum = (sum * linear[channel]) / 0x10000;
*((uint8_t*) data) = (uint8_t) st_14linear2ulaw((int16_t) sum >> 2);
data = (uint8_t*) data + 1;
@@ -426,10 +408,8 @@ size_t pa_mix(
case PA_SAMPLE_ALAW: {
unsigned channel = 0;
- int32_t linear[PA_CHANNELS_MAX];
- calc_linear_integer_stream_volumes(streams, nstreams, spec);
- calc_linear_integer_volume(linear, volume);
+ calc_linear_integer_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
int32_t sum = 0;
@@ -439,19 +419,17 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
int32_t v, cv = m->linear[channel].i;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = (int32_t) st_alaw2linear16(*((uint8_t*) m->ptr));
- v = (v * cv) / 0x10000;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = (int32_t) st_alaw2linear16(*((uint8_t*) m->ptr));
+ v = (v * cv) / 0x10000;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + 1;
}
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- sum = (sum * linear[channel]) / 0x10000;
*((uint8_t*) data) = (uint8_t) st_13linear2alaw((int16_t) sum >> 3);
data = (uint8_t*) data + 1;
@@ -465,10 +443,8 @@ size_t pa_mix(
case PA_SAMPLE_FLOAT32NE: {
unsigned channel = 0;
- float linear[PA_CHANNELS_MAX];
- calc_linear_float_stream_volumes(streams, nstreams, spec);
- calc_linear_float_volume(linear, volume);
+ calc_linear_float_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
float sum = 0;
@@ -478,18 +454,16 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
float v, cv = m->linear[channel].f;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else {
- v = *((float*) m->ptr);
- v *= cv;
- }
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = *((float*) m->ptr);
+ v *= cv;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(float);
}
- sum *= linear[channel];
*((float*) data) = sum;
data = (uint8_t*) data + sizeof(float);
@@ -505,8 +479,7 @@ size_t pa_mix(
unsigned channel = 0;
float linear[PA_CHANNELS_MAX];
- calc_linear_float_stream_volumes(streams, nstreams, spec);
- calc_linear_float_volume(linear, volume);
+ calc_linear_float_stream_volumes(streams, nstreams, volume, spec);
while (data < end) {
float sum = 0;
@@ -516,16 +489,16 @@ size_t pa_mix(
pa_mix_info *m = streams + i;
float v, cv = m->linear[channel].f;
- if (PA_UNLIKELY(cv <= 0) || PA_UNLIKELY(linear[channel] <= 0))
- v = 0;
- else
- v = PA_FLOAT32_SWAP(*(float*) m->ptr) *cv;
+ if (PA_UNLIKELY(cv <= 0))
+ continue;
+ v = PA_FLOAT32_SWAP(*(float*) m->ptr);
+ v *= cv;
sum += v;
+
m->ptr = (uint8_t*) m->ptr + sizeof(float);
}
- sum *= linear[channel];
*((float*) data) = PA_FLOAT32_SWAP(sum);
data = (uint8_t*) data + sizeof(float);
commit 1bb5e58fb38f3cd4b2c389dd3da294b004eade56
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Oct 3 02:33:44 2008 +0200
use PA_FLOAT32_SWAP where useful
diff --git a/src/pulsecore/sconv-s16le.c b/src/pulsecore/sconv-s16le.c
index 693d529..1a7448e 100644
--- a/src/pulsecore/sconv-s16le.c
+++ b/src/pulsecore/sconv-s16le.c
@@ -153,8 +153,7 @@ void pa_sconv_s16le_to_float32re(unsigned n, const int16_t *a, float *b) {
for (; n > 0; n--) {
int16_t s = *(a++);
float k = ((float) INT16_FROM(s))/0x7FFF;
- uint32_t *j = (uint32_t*) &k;
- *j = PA_UINT32_SWAP(*j);
+ k = PA_FLOAT32_SWAP(k);
*(b++) = k;
}
}
@@ -166,8 +165,7 @@ void pa_sconv_s32le_to_float32re(unsigned n, const int32_t *a, float *b) {
for (; n > 0; n--) {
int32_t s = *(a++);
float k = (float) (((double) INT32_FROM(s))/0x7FFFFFFF);
- uint32_t *j = (uint32_t*) &k;
- *j = PA_UINT32_SWAP(*j);
+ k = PA_FLOAT32_SWAP(k);
*(b++) = k;
}
}
@@ -179,8 +177,7 @@ void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
for (; n > 0; n--) {
int16_t s;
float v = *(a++);
- uint32_t *j = (uint32_t*) &v;
- *j = PA_UINT32_SWAP(*j);
+ v = PA_FLOAT32_SWAP(v);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int16_t) (v * 0x7FFF);
*(b++) = INT16_TO(s);
@@ -194,8 +191,7 @@ void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b) {
for (; n > 0; n--) {
int32_t s;
float v = *(a++);
- uint32_t *j = (uint32_t*) &v;
- *j = PA_UINT32_SWAP(*j);
+ v = PA_FLOAT32_SWAP(v);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int32_t) ((double) v * 0x7FFFFFFF);
*(b++) = INT32_TO(s);
commit 33b186e74dc2de6fa363d10d3450c354ec99f864
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Oct 3 02:34:59 2008 +0200
user lrint() and friends in inner loops instead of normal C casts to speed up a few things
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 15938cb..6907dc8 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -96,7 +96,7 @@ pa_volume_t pa_sw_volume_from_dB(double dB) {
if (isinf(dB) < 0 || dB <= -USER_DECIBEL_RANGE)
return PA_VOLUME_MUTED;
- return (pa_volume_t) ((dB/USER_DECIBEL_RANGE+1)*PA_VOLUME_NORM);
+ return (pa_volume_t) lrint((dB/USER_DECIBEL_RANGE+1)*PA_VOLUME_NORM);
}
double pa_sw_volume_to_dB(pa_volume_t v) {
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index b4e8bf4..5119ebd 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -105,7 +105,7 @@ static void calc_linear_integer_volume(int32_t linear[], const pa_cvolume *volum
pa_assert(volume);
for (channel = 0; channel < volume->channels; channel++)
- linear[channel] = (int32_t) (pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
+ linear[channel] = lrint(pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
}
static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
@@ -132,7 +132,7 @@ static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned n
for (channel = 0; channel < spec->channels; channel++) {
pa_mix_info *m = streams + k;
- m->linear[channel].i = (int32_t) (pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel] * 0x10000);
+ m->linear[channel].i = lrint(pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel] * 0x10000);
}
}
}
diff --git a/src/pulsecore/sconv-s16le.c b/src/pulsecore/sconv-s16le.c
index 1a7448e..159c465 100644
--- a/src/pulsecore/sconv-s16le.c
+++ b/src/pulsecore/sconv-s16le.c
@@ -111,7 +111,7 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {
float v = *(a++);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.f);
- s = (int16_t) (v * 0x7FFF);
+ s = (int16_t) lrintf(v * 0x7FFF);
*(b++) = INT16_TO(s);
}
@@ -134,7 +134,7 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {
float v = *(a++);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
- s = (int32_t) ((double) v * (double) 0x7FFFFFFF);
+ s = (int32_t) lrint((double) v * (double) 0x7FFFFFFF);
*(b++) = INT32_TO(s);
}
@@ -179,7 +179,7 @@ void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
float v = *(a++);
v = PA_FLOAT32_SWAP(v);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
- s = (int16_t) (v * 0x7FFF);
+ s = (int16_t) lrintf(v * 0x7FFF);
*(b++) = INT16_TO(s);
}
}
@@ -193,7 +193,7 @@ void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b) {
float v = *(a++);
v = PA_FLOAT32_SWAP(v);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
- s = (int32_t) ((double) v * 0x7FFFFFFF);
+ s = (int32_t) lrint((double) v * 0x7FFFFFFF);
*(b++) = INT32_TO(s);
}
}
diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c
index 733a46a..6c4d420 100644
--- a/src/pulsecore/sconv.c
+++ b/src/pulsecore/sconv.c
@@ -130,7 +130,7 @@ static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
float v = *(a++);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
v *= 0x1FFF;
- *(b++) = st_14linear2ulaw((int16_t) v);
+ *(b++) = st_14linear2ulaw((int16_t) lrintf(v));
}
}
@@ -168,7 +168,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
float v = *a;
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
v *= 0xFFF;
- *b = st_13linear2alaw((int16_t) v);
+ *b = st_13linear2alaw((int16_t) lrintf(v));
}
}
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index b165f4a..6a2ffaa 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -284,7 +284,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
/* The requested point is right of the point where we wanted
* to be on track again, thus just linearly estimate */
- t = (int64_t) s->py + (int64_t) (s->dp * (double) (x - s->px));
+ t = (int64_t) s->py + (int64_t) llrint(s->dp * (double) (x - s->px));
if (t < 0)
t = 0;
@@ -313,7 +313,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
/* Move back from origin */
ty += (double) s->ey;
- *y = ty >= 0 ? (pa_usec_t) ty : 0;
+ *y = ty >= 0 ? (pa_usec_t) lrint(ty) : 0;
/* Horner scheme */
if (deriv)
@@ -360,7 +360,7 @@ void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y) {
/* And calculate when we want to be on track again */
s->px = s->ex + s->adjust_time;
- s->py = s->ry + (pa_usec_t) (s->dp * (double) s->adjust_time);
+ s->py = s->ry + (pa_usec_t) lrint(s->dp * (double) s->adjust_time);
s->abc_valid = FALSE;
@@ -456,7 +456,7 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
/* pa_log_debug("translate(%llu) = %llu (%0.2f)", (unsigned long long) y_delay, (unsigned long long) ((double) y_delay / nde), nde); */
- return (pa_usec_t) ((double) y_delay / nde);
+ return (pa_usec_t) lrint((double) y_delay / nde);
}
void pa_smoother_reset(pa_smoother *s) {
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list