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.
This commit is contained in:
Max Kellermann 2009-01-07 18:53:36 +01:00
parent 8b19c74e8e
commit b40428b3fd
8 changed files with 53 additions and 36 deletions

View File

@ -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 \

View File

@ -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;

View File

@ -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) {

View File

@ -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>

View File

@ -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>

View File

@ -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>

44
src/pcm_convert.h Normal file
View File

@ -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

View File

@ -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