diff options
author | Max Kellermann <max@duempel.org> | 2009-01-07 18:53:36 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-07 18:53:36 +0100 |
commit | b40428b3fd284f172da0ae630559176727026599 (patch) | |
tree | fd5399b38e5bf251e5459e01483bbc3cda01f832 | |
parent | 8b19c74e8eb0036c697010d56ed1ee9b92facb72 (diff) | |
download | mpd-b40428b3fd284f172da0ae630559176727026599.tar.gz mpd-b40428b3fd284f172da0ae630559176727026599.tar.xz mpd-b40428b3fd284f172da0ae630559176727026599.zip |
pcm_utils: moved conversion code to pcm_convert.c
All what's left in pcm_utils.h is the pcm_range() utility function,
which is only used internally by pcm_volume and pcm_mix.
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/decoder_internal.h | 2 | ||||
-rw-r--r-- | src/output/alsa_plugin.c | 2 | ||||
-rw-r--r-- | src/output_control.c | 1 | ||||
-rw-r--r-- | src/output_internal.h | 2 | ||||
-rw-r--r-- | src/pcm_convert.c (renamed from src/pcm_utils.c) | 9 | ||||
-rw-r--r-- | src/pcm_convert.h | 44 | ||||
-rw-r--r-- | src/pcm_utils.h | 26 |
8 files changed, 53 insertions, 36 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 00891cfc0..75380ef2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,7 @@ mpd_headers = \ path.h \ mapper.h \ pcm_utils.h \ + pcm_convert.h \ pcm_volume.h \ pcm_mix.h \ pcm_channels.h \ @@ -131,7 +132,7 @@ mpd_SOURCES = \ pipe.c \ path.c \ mapper.c \ - pcm_utils.c \ + pcm_convert.c \ pcm_volume.c \ pcm_mix.c \ pcm_channels.c \ diff --git a/src/decoder_internal.h b/src/decoder_internal.h index bc10475b9..ea9106c8b 100644 --- a/src/decoder_internal.h +++ b/src/decoder_internal.h @@ -20,7 +20,7 @@ #define MPD_DECODER_INTERNAL_H #include "decoder_api.h" -#include "pcm_utils.h" +#include "pcm_convert.h" struct decoder { struct pcm_convert_state conv_state; diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c index 0d97438eb..fc5c56c21 100644 --- a/src/output/alsa_plugin.c +++ b/src/output/alsa_plugin.c @@ -235,7 +235,7 @@ configure_hw: err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, bitformat); if (err == -EINVAL && audioFormat->bits != 16) { - /* fall back to 16 bit, let pcm_utils.c do the conversion */ + /* fall back to 16 bit, let pcm_convert.c do the conversion */ err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, SND_PCM_FORMAT_S16); if (err == 0) { diff --git a/src/output_control.c b/src/output_control.c index c0e7d001a..80cdf71d0 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -20,7 +20,6 @@ #include "output_api.h" #include "output_internal.h" #include "output_thread.h" -#include "pcm_utils.h" #include <assert.h> #include <stdlib.h> diff --git a/src/output_internal.h b/src/output_internal.h index 0cdbbdc2c..17209dd5a 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -20,7 +20,7 @@ #ifndef MPD_OUTPUT_INTERNAL_H #define MPD_OUTPUT_INTERNAL_H -#include "pcm_utils.h" +#include "pcm_convert.h" #include "notify.h" #include <time.h> diff --git a/src/pcm_utils.c b/src/pcm_convert.c index 69add6073..283befd8c 100644 --- a/src/pcm_utils.c +++ b/src/pcm_convert.c @@ -1,6 +1,6 @@ -/* the Music Player Daemon (MPD) - * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) - * This project's homepage is: http://www.musicpd.org +/* + * Copyright (C) 2003-2009 The Music Player Daemon Project + * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,10 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "pcm_utils.h" +#include "pcm_convert.h" #include "pcm_channels.h" #include "pcm_format.h" -#include "conf.h" #include "audio_format.h" #include <assert.h> diff --git a/src/pcm_convert.h b/src/pcm_convert.h new file mode 100644 index 000000000..ac771a5c1 --- /dev/null +++ b/src/pcm_convert.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2003-2009 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PCM_CONVERT_H +#define PCM_CONVERT_H + +#include "pcm_resample.h" +#include "pcm_dither.h" + +struct audio_format; + +struct pcm_convert_state { + struct pcm_resample_state resample; + + struct pcm_dither_24 dither; +}; + +void pcm_convert_init(struct pcm_convert_state *state); + +size_t pcm_convert(const struct audio_format *inFormat, + const char *inBuffer, size_t inSize, + const struct audio_format *outFormat, + char *outBuffer, + struct pcm_convert_state *convState); + +size_t pcm_convert_size(const struct audio_format *inFormat, size_t inSize, + const struct audio_format *outFormat); + +#endif diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 5d29420f3..020cdaceb 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -19,24 +19,9 @@ #ifndef MPD_PCM_UTILS_H #define MPD_PCM_UTILS_H -#include "pcm_resample.h" -#include "pcm_dither.h" - #include <glib.h> #include <stdint.h> -#include <stddef.h> - -struct audio_format; - -struct pcm_convert_state { - struct pcm_resample_state resample; - - struct pcm_dither_24 dither; - - /* Strict C99 doesn't allow empty structs */ - int error; -}; /** * Check if the value is within the range of the provided bit size, @@ -52,15 +37,4 @@ pcm_range(int32_t sample, unsigned bits) return sample; } -void pcm_convert_init(struct pcm_convert_state *state); - -size_t pcm_convert(const struct audio_format *inFormat, - const char *inBuffer, size_t inSize, - const struct audio_format *outFormat, - char *outBuffer, - struct pcm_convert_state *convState); - -size_t pcm_convert_size(const struct audio_format *inFormat, size_t inSize, - const struct audio_format *outFormat); - #endif |