From 181e9c6d5d11cb1e5d36a2777eeb233ad8ed00e5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 9 Oct 2008 18:15:23 +0200 Subject: big pile of updates to match more what happened with libcanberra --- src/converter.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'src/converter.c') diff --git a/src/converter.c b/src/converter.c index 90dba34..1fd1bf7 100644 --- a/src/converter.c +++ b/src/converter.c @@ -1,3 +1,23 @@ +/*** + This file is part of libsydney. + + Copyright 2007-2008 Lennart Poettering + + libsydney is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 2.1 of the + License, or (at your option) any later version. + + libsydney is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libsydney. If not, see + . +***/ + #ifdef HAVE_CONFIG_H #include #endif @@ -5,7 +25,7 @@ #include #include -#include "speex/speex_resampler.h" +#include #include "converter.h" #include "sydney.h" @@ -172,12 +192,10 @@ static sa_pcm_format_t fix_work_format_for_resample(sa_pcm_format_t f) { case SA_PCM_FORMAT_U8: case SA_PCM_FORMAT_S16_NE: return SA_PCM_FORMAT_S16_NE; - break; case SA_PCM_FORMAT_S32_NE: case SA_PCM_FORMAT_FLOAT32_NE: return SA_PCM_FORMAT_FLOAT32_NE; - break; default: ; @@ -222,14 +240,14 @@ int sa_converter_init( if (u != t) c->remap_required = TRUE; - c->channel_map_table[u * (from->nchannels+1) + k++] += t; + c->channel_map_table[u * (from->nchannels+1) + k++] += (int) t; } } if (k > 1) c->sum_required = TRUE; - c->channel_map_table[k] = (unsigned) -1; + c->channel_map_table[k] = (int) -1; } if (c->from_nchannels != c->to_nchannels) @@ -310,7 +328,7 @@ int sa_converter_init( if (!(c->volume_divisor = sa_new(int32_t, c->from_nchannels))) goto fail; - c->no_volume = 1; + c->no_volume = TRUE; /* Initialize bounce buffers */ @@ -333,8 +351,6 @@ int sa_converter_init( if (sa_bbuffer_init(&c->bb_tmp, 1, 1) < 0) goto fail; - if (c - return 0; fail: @@ -400,7 +416,7 @@ int sa_converter_go( size_t* stride; void** process_data; sa_bool_t is_bounce; - sa_bool_t interleave; + sa_interleave_t interleave; unsigned i; sa_assert(c); @@ -693,6 +709,7 @@ void sa_converter_set_volume(sa_converter_t *c, const int32_t vol[]) { sa_bool_t no_volume = TRUE; sa_assert(c); + sa_assert(vol); for (i = 0; i < c->from_nchannels; i++) { int num, denom; @@ -705,7 +722,7 @@ void sa_converter_set_volume(sa_converter_t *c, const int32_t vol[]) { c->volume_divisor[i] = 1; no_volume = 0; } else { - float f = powf(10.0, (float) vol[i] / 2000); + float f = volume_to_linear(vol[i]); sa_continued_fraction(f, 0x7FFF, &num, &denom); @@ -723,12 +740,17 @@ void sa_converter_set_volume(sa_converter_t *c, const int32_t vol[]) { int sa_converter_go_interleaved( sa_converter_t *c, const void *const data, - void **dst[], size_t *dstr[], sa_bool_t dinterleave, + void **dst[], size_t *dstr[], sa_interleave_t dinterleave, size_t *size) { unsigned i; const uint8_t *d = data; - unsigned stride = c->from_nchannels * c->from_sample_size; + size_t stride; + + sa_assert(c); + sa_assert(data); + + stride = c->from_nchannels * c->from_sample_size; for (i = 0; i < c->from_nchannels; i++) { c->from_process_data[i] = (void*) d; -- cgit