Commit f1dd9c20 authored by Max Kellermann's avatar Max Kellermann

audio_format: converted typedef AudioFormat to struct audio_format

Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
parent bd81fd8b
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include "audio.h" #include "audio.h"
#include "audio_format.h"
#include "audioOutput.h" #include "audioOutput.h"
#include "log.h" #include "log.h"
#include "path.h" #include "path.h"
...@@ -27,9 +28,9 @@ ...@@ -27,9 +28,9 @@
#define AUDIO_DEVICE_STATE_LEN (sizeof(AUDIO_DEVICE_STATE)-1) #define AUDIO_DEVICE_STATE_LEN (sizeof(AUDIO_DEVICE_STATE)-1)
#define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX #define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX
static AudioFormat audio_format; static struct audio_format audio_format;
static AudioFormat *audio_configFormat; static struct audio_format *audio_configFormat;
static AudioOutput *audioOutputArray; static AudioOutput *audioOutputArray;
static unsigned int audioOutputArraySize; static unsigned int audioOutputArraySize;
...@@ -63,15 +64,15 @@ static unsigned int audio_output_count(void) ...@@ -63,15 +64,15 @@ static unsigned int audio_output_count(void)
return nr; return nr;
} }
void copyAudioFormat(AudioFormat * dest, const AudioFormat * src) void copyAudioFormat(struct audio_format *dest, const struct audio_format *src)
{ {
if (!src) if (!src)
return; return;
memcpy(dest, src, sizeof(AudioFormat)); memcpy(dest, src, sizeof(*dest));
} }
int cmpAudioFormat(const AudioFormat * f1, const AudioFormat * f2) int cmpAudioFormat(const struct audio_format *f1, const struct audio_format *f2)
{ {
if (f1 && f2 && (f1->sampleRate == f2->sampleRate) && if (f1 && f2 && (f1->sampleRate == f2->sampleRate) &&
(f1->bits == f2->bits) && (f1->channels == f2->channels)) (f1->bits == f2->bits) && (f1->channels == f2->channels))
...@@ -141,8 +142,8 @@ void initAudioDriver(void) ...@@ -141,8 +142,8 @@ void initAudioDriver(void)
} }
} }
void getOutputAudioFormat(const AudioFormat * inAudioFormat, void getOutputAudioFormat(const struct audio_format *inAudioFormat,
AudioFormat * outAudioFormat) struct audio_format *outAudioFormat)
{ {
if (audio_configFormat) { if (audio_configFormat) {
copyAudioFormat(outAudioFormat, audio_configFormat); copyAudioFormat(outAudioFormat, audio_configFormat);
...@@ -157,7 +158,7 @@ void initAudioConfig(void) ...@@ -157,7 +158,7 @@ void initAudioConfig(void)
if (NULL == param || NULL == param->value) if (NULL == param || NULL == param->value)
return; return;
audio_configFormat = xmalloc(sizeof(AudioFormat)); audio_configFormat = xmalloc(sizeof(*audio_configFormat));
if (0 != parseAudioConfig(audio_configFormat, param->value)) { if (0 != parseAudioConfig(audio_configFormat, param->value)) {
FATAL("error parsing \"%s\" at line %i\n", FATAL("error parsing \"%s\" at line %i\n",
...@@ -165,11 +166,11 @@ void initAudioConfig(void) ...@@ -165,11 +166,11 @@ void initAudioConfig(void)
} }
} }
int parseAudioConfig(AudioFormat * audioFormat, char *conf) int parseAudioConfig(struct audio_format *audioFormat, char *conf)
{ {
char *test; char *test;
memset(audioFormat, 0, sizeof(AudioFormat)); memset(audioFormat, 0, sizeof(*audioFormat));
audioFormat->sampleRate = strtol(conf, &test, 10); audioFormat->sampleRate = strtol(conf, &test, 10);
...@@ -251,7 +252,7 @@ void finishAudioDriver(void) ...@@ -251,7 +252,7 @@ void finishAudioDriver(void)
audioOutputArraySize = 0; audioOutputArraySize = 0;
} }
int isCurrentAudioFormat(const AudioFormat * audioFormat) int isCurrentAudioFormat(const struct audio_format *audioFormat)
{ {
if (!audioFormat) if (!audioFormat)
return 1; return 1;
...@@ -320,7 +321,7 @@ static int flushAudioBuffer(void) ...@@ -320,7 +321,7 @@ static int flushAudioBuffer(void)
return ret; return ret;
} }
int openAudioDevice(const AudioFormat * audioFormat) int openAudioDevice(const struct audio_format *audioFormat)
{ {
int ret = -1; int ret = -1;
unsigned int i; unsigned int i;
......
...@@ -20,21 +20,21 @@ ...@@ -20,21 +20,21 @@
#define AUDIO_H #define AUDIO_H
#include "os_compat.h" #include "os_compat.h"
#include "audio_format.h"
#define AUDIO_AO_DRIVER_DEFAULT "default" #define AUDIO_AO_DRIVER_DEFAULT "default"
struct audio_format;
struct tag; struct tag;
struct client; struct client;
void copyAudioFormat(AudioFormat * dest, const AudioFormat * src); void copyAudioFormat(struct audio_format *dest, const struct audio_format *src);
int cmpAudioFormat(const AudioFormat * dest, const AudioFormat * src); int cmpAudioFormat(const struct audio_format *dest, const struct audio_format *src);
void getOutputAudioFormat(const AudioFormat * inFormat, void getOutputAudioFormat(const struct audio_format *inFormat,
AudioFormat * outFormat); struct audio_format *outFormat);
int parseAudioConfig(AudioFormat * audioFormat, char *conf); int parseAudioConfig(struct audio_format *audioFormat, char *conf);
/* make sure initPlayerData is called before this function!! */ /* make sure initPlayerData is called before this function!! */
void initAudioConfig(void); void initAudioConfig(void);
...@@ -45,7 +45,7 @@ void initAudioDriver(void); ...@@ -45,7 +45,7 @@ void initAudioDriver(void);
void finishAudioDriver(void); void finishAudioDriver(void);
int openAudioDevice(const AudioFormat * audioFormat); int openAudioDevice(const struct audio_format *audioFormat);
int playAudio(const char *playChunk, size_t size); int playAudio(const char *playChunk, size_t size);
...@@ -55,7 +55,7 @@ void closeAudioDevice(void); ...@@ -55,7 +55,7 @@ void closeAudioDevice(void);
int isAudioDeviceOpen(void); int isAudioDeviceOpen(void);
int isCurrentAudioFormat(const AudioFormat * audioFormat); int isCurrentAudioFormat(const struct audio_format *audioFormat);
void sendMetadataToAudioDevice(const struct tag *tag); void sendMetadataToAudioDevice(const struct tag *tag);
......
...@@ -130,9 +130,9 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param) ...@@ -130,9 +130,9 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
ao->convBuffer = NULL; ao->convBuffer = NULL;
ao->convBufferLen = 0; ao->convBufferLen = 0;
memset(&ao->inAudioFormat, 0, sizeof(AudioFormat)); memset(&ao->inAudioFormat, 0, sizeof(ao->inAudioFormat));
memset(&ao->outAudioFormat, 0, sizeof(AudioFormat)); memset(&ao->outAudioFormat, 0, sizeof(ao->outAudioFormat));
memset(&ao->reqAudioFormat, 0, sizeof(AudioFormat)); memset(&ao->reqAudioFormat, 0, sizeof(ao->reqAudioFormat));
memset(&ao->convState, 0, sizeof(ConvState)); memset(&ao->convState, 0, sizeof(ConvState));
if (format) { if (format) {
...@@ -152,7 +152,7 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param) ...@@ -152,7 +152,7 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
} }
int openAudioOutput(AudioOutput * audioOutput, int openAudioOutput(AudioOutput * audioOutput,
const AudioFormat * audioFormat) const struct audio_format *audioFormat)
{ {
int ret = 0; int ret = 0;
......
...@@ -65,9 +65,9 @@ struct _AudioOutput { ...@@ -65,9 +65,9 @@ struct _AudioOutput {
AudioOutputSendMetadataFunc sendMetdataFunc; AudioOutputSendMetadataFunc sendMetdataFunc;
int convertAudioFormat; int convertAudioFormat;
AudioFormat inAudioFormat; struct audio_format inAudioFormat;
AudioFormat outAudioFormat; struct audio_format outAudioFormat;
AudioFormat reqAudioFormat; struct audio_format reqAudioFormat;
ConvState convState; ConvState convState;
char *convBuffer; char *convBuffer;
size_t convBufferLen; size_t convBufferLen;
...@@ -97,7 +97,7 @@ void unloadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin); ...@@ -97,7 +97,7 @@ void unloadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin);
int initAudioOutput(AudioOutput *, ConfigParam * param); int initAudioOutput(AudioOutput *, ConfigParam * param);
int openAudioOutput(AudioOutput * audioOutput, int openAudioOutput(AudioOutput * audioOutput,
const AudioFormat * audioFormat); const struct audio_format *audioFormat);
int playAudioOutput(AudioOutput * audioOutput, int playAudioOutput(AudioOutput * audioOutput,
const char *playChunk, size_t size); const char *playChunk, size_t size);
void dropBufferedAudioOutput(AudioOutput * audioOutput); void dropBufferedAudioOutput(AudioOutput * audioOutput);
......
...@@ -123,7 +123,7 @@ static int alsa_testDefault(void) ...@@ -123,7 +123,7 @@ static int alsa_testDefault(void)
static int alsa_openDevice(AudioOutput * audioOutput) static int alsa_openDevice(AudioOutput * audioOutput)
{ {
AlsaData *ad = audioOutput->data; AlsaData *ad = audioOutput->data;
AudioFormat *audioFormat = &audioOutput->outAudioFormat; struct audio_format *audioFormat = &audioOutput->outAudioFormat;
snd_pcm_format_t bitformat; snd_pcm_format_t bitformat;
snd_pcm_hw_params_t *hwparams; snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams; snd_pcm_sw_params_t *swparams;
......
...@@ -118,7 +118,7 @@ static void jack_finishDriver(AudioOutput *audioOutput) ...@@ -118,7 +118,7 @@ static void jack_finishDriver(AudioOutput *audioOutput)
static int srate(mpd_unused jack_nframes_t rate, void *data) static int srate(mpd_unused jack_nframes_t rate, void *data)
{ {
JackData *jd = (JackData *) ((AudioOutput*) data)->data; JackData *jd = (JackData *) ((AudioOutput*) data)->data;
AudioFormat *audioFormat = &(((AudioOutput*) data)->outAudioFormat); struct audio_format *audioFormat = &(((AudioOutput*) data)->outAudioFormat);
audioFormat->sampleRate = (int)jack_get_sample_rate(jd->client); audioFormat->sampleRate = (int)jack_get_sample_rate(jd->client);
...@@ -183,7 +183,7 @@ static void shutdown_callback(void *arg) ...@@ -183,7 +183,7 @@ static void shutdown_callback(void *arg)
static void set_audioformat(AudioOutput *audioOutput) static void set_audioformat(AudioOutput *audioOutput)
{ {
JackData *jd = audioOutput->data; JackData *jd = audioOutput->data;
AudioFormat *audioFormat = &audioOutput->outAudioFormat; struct audio_format *audioFormat = &audioOutput->outAudioFormat;
audioFormat->sampleRate = (int) jack_get_sample_rate(jd->client); audioFormat->sampleRate = (int) jack_get_sample_rate(jd->client);
DEBUG("samplerate = %d\n", audioFormat->sampleRate); DEBUG("samplerate = %d\n", audioFormat->sampleRate);
......
...@@ -484,7 +484,7 @@ static int oss_openDevice(AudioOutput * audioOutput) ...@@ -484,7 +484,7 @@ static int oss_openDevice(AudioOutput * audioOutput)
{ {
int ret; int ret;
OssData *od = audioOutput->data; OssData *od = audioOutput->data;
AudioFormat *audioFormat = &audioOutput->outAudioFormat; struct audio_format *audioFormat = &audioOutput->outAudioFormat;
od->channels = (mpd_sint8)audioFormat->channels; od->channels = (mpd_sint8)audioFormat->channels;
od->sampleRate = audioFormat->sampleRate; od->sampleRate = audioFormat->sampleRate;
......
...@@ -112,7 +112,7 @@ static int pulse_testDefault(void) ...@@ -112,7 +112,7 @@ static int pulse_testDefault(void)
static int pulse_openDevice(AudioOutput * audioOutput) static int pulse_openDevice(AudioOutput * audioOutput)
{ {
PulseData *pd; PulseData *pd;
AudioFormat *audioFormat; struct audio_format *audioFormat;
pa_sample_spec ss; pa_sample_spec ss;
time_t t; time_t t;
int error; int error;
......
...@@ -66,7 +66,7 @@ typedef struct _ShoutData { ...@@ -66,7 +66,7 @@ typedef struct _ShoutData {
Timer *timer; Timer *timer;
/* just a pointer to audioOutput->outAudioFormat */ /* just a pointer to audioOutput->outAudioFormat */
AudioFormat *audioFormat; struct audio_format *audioFormat;
} ShoutData; } ShoutData;
static ShoutData *newShoutData(void) static ShoutData *newShoutData(void)
......
...@@ -21,18 +21,18 @@ ...@@ -21,18 +21,18 @@
#include "mpd_types.h" #include "mpd_types.h"
typedef struct _AudioFormat { struct audio_format {
mpd_sint8 channels; mpd_sint8 channels;
mpd_uint32 sampleRate; mpd_uint32 sampleRate;
mpd_sint8 bits; mpd_sint8 bits;
} AudioFormat; };
static inline double audio_format_time_to_size(const AudioFormat * af) static inline double audio_format_time_to_size(const struct audio_format *af)
{ {
return af->sampleRate * af->bits * af->channels / 8.0; return af->sampleRate * af->bits * af->channels / 8.0;
} }
static inline double audioFormatSizeToTime(const AudioFormat * af) static inline double audioFormatSizeToTime(const struct audio_format *af)
{ {
return 8.0 / af->bits / af->channels / af->sampleRate; return 8.0 / af->bits / af->channels / af->sampleRate;
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "pcm_utils.h" #include "pcm_utils.h"
unsigned cross_fade_calc(float duration, float total_time, unsigned cross_fade_calc(float duration, float total_time,
const AudioFormat * af, const struct audio_format *af,
unsigned max_chunks) unsigned max_chunks)
{ {
unsigned int chunks; unsigned int chunks;
...@@ -46,7 +46,7 @@ unsigned cross_fade_calc(float duration, float total_time, ...@@ -46,7 +46,7 @@ unsigned cross_fade_calc(float duration, float total_time,
} }
void cross_fade_apply(ob_chunk * a, const ob_chunk * b, void cross_fade_apply(ob_chunk * a, const ob_chunk * b,
const AudioFormat * format, const struct audio_format *format,
unsigned int current_chunk, unsigned int num_chunks) unsigned int current_chunk, unsigned int num_chunks)
{ {
assert(current_chunk <= num_chunks); assert(current_chunk <= num_chunks);
......
...@@ -20,15 +20,16 @@ ...@@ -20,15 +20,16 @@
#ifndef CROSSFADE_H #ifndef CROSSFADE_H
#define CROSSFADE_H #define CROSSFADE_H
#include "audio_format.h"
#include "outputBuffer.h" #include "outputBuffer.h"
struct audio_format;
unsigned cross_fade_calc(float duration, float total_time, unsigned cross_fade_calc(float duration, float total_time,
const AudioFormat * af, const struct audio_format *af,
unsigned max_chunks); unsigned max_chunks);
void cross_fade_apply(ob_chunk * a, const ob_chunk * b, void cross_fade_apply(ob_chunk * a, const ob_chunk * b,
const AudioFormat * format, const struct audio_format *format,
unsigned int current_chunk, unsigned int num_chunks); unsigned int current_chunk, unsigned int num_chunks);
#endif #endif
...@@ -39,7 +39,7 @@ void decoder_plugin_unregister(struct decoder_plugin *plugin) ...@@ -39,7 +39,7 @@ void decoder_plugin_unregister(struct decoder_plugin *plugin)
} }
void decoder_initialized(struct decoder * decoder, void decoder_initialized(struct decoder * decoder,
const AudioFormat * audio_format, const struct audio_format *audio_format,
float total_time) float total_time)
{ {
assert(dc.state == DECODE_STATE_START); assert(dc.state == DECODE_STATE_START);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "replayGain.h" #include "replayGain.h"
#include "tag.h" #include "tag.h"
#include "tag_id3.h" #include "tag_id3.h"
#include "audio_format.h"
#include "playerData.h" #include "playerData.h"
...@@ -112,7 +113,7 @@ struct decoder; ...@@ -112,7 +113,7 @@ struct decoder;
* that it has read the song's meta data. * that it has read the song's meta data.
*/ */
void decoder_initialized(struct decoder * decoder, void decoder_initialized(struct decoder * decoder,
const AudioFormat * audio_format, const struct audio_format *audio_format,
float total_time); float total_time);
const char *decoder_get_url(struct decoder * decoder, char * buffer); const char *decoder_get_url(struct decoder * decoder, char * buffer);
......
...@@ -48,7 +48,7 @@ struct decoder_control { ...@@ -48,7 +48,7 @@ struct decoder_control {
volatile mpd_sint8 seekError; volatile mpd_sint8 seekError;
volatile mpd_sint8 seekable; volatile mpd_sint8 seekable;
volatile double seekWhere; volatile double seekWhere;
AudioFormat audioFormat; struct audio_format audioFormat;
Song *current_song; Song *current_song;
Song *volatile next_song; Song *volatile next_song;
volatile float totalTime; volatile float totalTime;
......
...@@ -143,7 +143,7 @@ typedef struct { ...@@ -143,7 +143,7 @@ typedef struct {
size_t chunk_length; size_t chunk_length;
float time; float time;
unsigned int bitRate; unsigned int bitRate;
AudioFormat audio_format; struct audio_format audio_format;
float total_time; float total_time;
FLAC__uint64 position; FLAC__uint64 position;
struct decoder *decoder; struct decoder *decoder;
......
...@@ -310,7 +310,7 @@ static int aac_stream_decode(struct decoder * mpd_decoder, ...@@ -310,7 +310,7 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
faacDecFrameInfo frameInfo; faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config; faacDecConfigurationPtr config;
long bread; long bread;
AudioFormat audio_format; struct audio_format audio_format;
uint32_t sampleRate; uint32_t sampleRate;
unsigned char channels; unsigned char channels;
unsigned int sampleCount; unsigned int sampleCount;
...@@ -444,7 +444,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path) ...@@ -444,7 +444,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
faacDecFrameInfo frameInfo; faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config; faacDecConfigurationPtr config;
long bread; long bread;
AudioFormat audio_format; struct audio_format audio_format;
uint32_t sampleRate; uint32_t sampleRate;
unsigned char channels; unsigned char channels;
unsigned int sampleCount; unsigned int sampleCount;
......
...@@ -48,7 +48,7 @@ static int audiofile_decode(struct decoder * decoder, char *path) ...@@ -48,7 +48,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
int fs, frame_count; int fs, frame_count;
AFfilehandle af_fp; AFfilehandle af_fp;
int bits; int bits;
AudioFormat audio_format; struct audio_format audio_format;
float total_time; float total_time;
mpd_uint16 bitRate; mpd_uint16 bitRate;
struct stat st; struct stat st;
......
...@@ -171,7 +171,7 @@ static void mod_close(mod_Data * data) ...@@ -171,7 +171,7 @@ static void mod_close(mod_Data * data)
static int mod_decode(struct decoder * decoder, char *path) static int mod_decode(struct decoder * decoder, char *path)
{ {
mod_Data *data; mod_Data *data;
AudioFormat audio_format; struct audio_format audio_format;
float total_time = 0.0; float total_time = 0.0;
int ret; int ret;
float secPerByte; float secPerByte;
......
...@@ -1021,7 +1021,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo) ...@@ -1021,7 +1021,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
} }
static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
AudioFormat * af) struct audio_format * af)
{ {
af->bits = 16; af->bits = 16;
af->sampleRate = (data->frame).header.samplerate; af->sampleRate = (data->frame).header.samplerate;
...@@ -1033,7 +1033,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream) ...@@ -1033,7 +1033,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
mp3DecodeData data; mp3DecodeData data;
struct tag *tag = NULL; struct tag *tag = NULL;
ReplayGainInfo *replayGainInfo = NULL; ReplayGainInfo *replayGainInfo = NULL;
AudioFormat audio_format; struct audio_format audio_format;
if (openMp3FromInputStream(inStream, &data, decoder, if (openMp3FromInputStream(inStream, &data, decoder,
&tag, &replayGainInfo) < 0) { &tag, &replayGainInfo) < 0) {
......
...@@ -88,7 +88,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -88,7 +88,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
faacDecHandle decoder; faacDecHandle decoder;
faacDecFrameInfo frameInfo; faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config; faacDecConfigurationPtr config;
AudioFormat audio_format; struct audio_format audio_format;
unsigned char *mp4Buffer; unsigned char *mp4Buffer;
unsigned int mp4BufferSize; unsigned int mp4BufferSize;
uint32_t sampleRate; uint32_t sampleRate;
......
...@@ -102,7 +102,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -102,7 +102,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
mpc_decoder decoder; mpc_decoder decoder;
mpc_reader reader; mpc_reader reader;
mpc_streaminfo info; mpc_streaminfo info;
AudioFormat audio_format; struct audio_format audio_format;
MpcCallbackData data; MpcCallbackData data;
......
...@@ -210,7 +210,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) ...@@ -210,7 +210,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
OggVorbis_File vf; OggVorbis_File vf;
ov_callbacks callbacks; ov_callbacks callbacks;
OggCallbackData data; OggCallbackData data;
AudioFormat audio_format; struct audio_format audio_format;
int current_section; int current_section;
int prev_section = -1; int prev_section = -1;
long ret; long ret;
......
...@@ -131,7 +131,7 @@ static void wavpack_decode(struct decoder * decoder, ...@@ -131,7 +131,7 @@ static void wavpack_decode(struct decoder * decoder,
WavpackContext *wpc, int canseek, WavpackContext *wpc, int canseek,
ReplayGainInfo *replayGainInfo) ReplayGainInfo *replayGainInfo)
{ {
AudioFormat audio_format; struct audio_format audio_format;
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt); void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
float file_time; float file_time;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "normalize.h" #include "normalize.h"
#include "compress.h" #include "compress.h"
#include "conf.h" #include "conf.h"
#include "audio_format.h"
#define DEFAULT_VOLUME_NORMALIZATION 0 #define DEFAULT_VOLUME_NORMALIZATION 0
...@@ -39,7 +40,8 @@ void finishNormalization(void) ...@@ -39,7 +40,8 @@ void finishNormalization(void)
if (normalizationEnabled) CompressFree(); if (normalizationEnabled) CompressFree();
} }
void normalizeData(char *buffer, int bufferSize, const AudioFormat *format) void normalizeData(char *buffer, int bufferSize,
const struct audio_format *format)
{ {
if ((format->bits != 16) || (format->channels != 2)) return; if ((format->bits != 16) || (format->channels != 2)) return;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#ifndef NORMALIZE_H #ifndef NORMALIZE_H
#define NORMALIZE_H #define NORMALIZE_H
#include "audio_format.h" struct audio_format;
extern int normalizationEnabled; extern int normalizationEnabled;
...@@ -27,6 +27,7 @@ void initNormalization(void); ...@@ -27,6 +27,7 @@ void initNormalization(void);
void finishNormalization(void); void finishNormalization(void);
void normalizeData(char *buffer, int bufferSize, const AudioFormat *format); void normalizeData(char *buffer, int bufferSize,
const struct audio_format *format);
#endif /* !NORMALIZE_H */ #endif /* !NORMALIZE_H */
...@@ -51,7 +51,7 @@ struct output_buffer { ...@@ -51,7 +51,7 @@ struct output_buffer {
the buffer becomes non-empty */ the buffer becomes non-empty */
int lazy; int lazy;
AudioFormat audioFormat; struct audio_format audioFormat;
Notify *notify; Notify *notify;
}; };
......
...@@ -22,9 +22,11 @@ ...@@ -22,9 +22,11 @@
#include "log.h" #include "log.h"
#include "utils.h" #include "utils.h"
#include "conf.h" #include "conf.h"
#include "audio_format.h"
#include "os_compat.h" #include "os_compat.h"
void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format, void pcm_volumeChange(char *buffer, int bufferSize,
const struct audio_format *format,
int volume) int volume)
{ {
mpd_sint32 temp32; mpd_sint32 temp32;
...@@ -76,7 +78,7 @@ void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format, ...@@ -76,7 +78,7 @@ void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format,
static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1, static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
size_t bufferSize2, int vol1, int vol2, size_t bufferSize2, int vol1, int vol2,
const AudioFormat * format) const struct audio_format *format)
{ {
mpd_sint32 temp32; mpd_sint32 temp32;
mpd_sint8 *buffer8_1 = (mpd_sint8 *) buffer1; mpd_sint8 *buffer8_1 = (mpd_sint8 *) buffer1;
...@@ -130,7 +132,8 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1, ...@@ -130,7 +132,8 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1,
} }
void pcm_mix(char *buffer1, const char *buffer2, size_t bufferSize1, void pcm_mix(char *buffer1, const char *buffer2, size_t bufferSize1,
size_t bufferSize2, const AudioFormat * format, float portion1) size_t bufferSize2, const struct audio_format *format,
float portion1)
{ {
int vol1; int vol1;
float s = sin(M_PI_2 * portion1); float s = sin(M_PI_2 * portion1);
...@@ -392,9 +395,9 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer, ...@@ -392,9 +395,9 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
} }
/* outFormat bits must be 16 and channels must be 1 or 2! */ /* outFormat bits must be 16 and channels must be 1 or 2! */
size_t pcm_convertAudioFormat(const AudioFormat * inFormat, size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
const char *inBuffer, size_t inSize, const char *inBuffer, size_t inSize,
const AudioFormat * outFormat, const struct audio_format *outFormat,
char *outBuffer, ConvState *convState) char *outBuffer, ConvState *convState)
{ {
const char *buf; const char *buf;
...@@ -430,8 +433,8 @@ size_t pcm_convertAudioFormat(const AudioFormat * inFormat, ...@@ -430,8 +433,8 @@ size_t pcm_convertAudioFormat(const AudioFormat * inFormat,
return len; return len;
} }
size_t pcm_sizeOfConvBuffer(const AudioFormat * inFormat, size_t inSize, size_t pcm_sizeOfConvBuffer(const struct audio_format *inFormat, size_t inSize,
const AudioFormat * outFormat) const struct audio_format *outFormat)
{ {
const double ratio = (double)outFormat->sampleRate / const double ratio = (double)outFormat->sampleRate /
(double)inFormat->sampleRate; (double)inFormat->sampleRate;
......
...@@ -21,13 +21,15 @@ ...@@ -21,13 +21,15 @@
#include "../config.h" #include "../config.h"
#include "audio_format.h" #include "mpd_types.h"
#include "os_compat.h" #include "os_compat.h"
#ifdef HAVE_LIBSAMPLERATE #ifdef HAVE_LIBSAMPLERATE
#include <samplerate.h> #include <samplerate.h>
#endif #endif
struct audio_format;
typedef struct _ConvState { typedef struct _ConvState {
#ifdef HAVE_LIBSAMPLERATE #ifdef HAVE_LIBSAMPLERATE
SRC_STATE *state; SRC_STATE *state;
...@@ -42,17 +44,17 @@ typedef struct _ConvState { ...@@ -42,17 +44,17 @@ typedef struct _ConvState {
int error; int error;
} ConvState; } ConvState;
void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format, void pcm_volumeChange(char *buffer, int bufferSize, const struct audio_format *format,
int volume); int volume);
void pcm_mix(char *buffer1, const char *buffer2, size_t bufferSize1, void pcm_mix(char *buffer1, const char *buffer2, size_t bufferSize1,
size_t bufferSize2, const AudioFormat * format, float portion1); size_t bufferSize2, const struct audio_format *format, float portion1);
size_t pcm_convertAudioFormat(const AudioFormat * inFormat, size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
const char *inBuffer, size_t inSize, const char *inBuffer, size_t inSize,
const AudioFormat * outFormat, const struct audio_format *outFormat,
char *outBuffer, ConvState *convState); char *outBuffer, ConvState *convState);
size_t pcm_sizeOfConvBuffer(const AudioFormat * inFormat, size_t inSize, size_t pcm_sizeOfConvBuffer(const struct audio_format *inFormat, size_t inSize,
const AudioFormat * outFormat); const struct audio_format *outFormat);
#endif #endif
...@@ -158,7 +158,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r, ...@@ -158,7 +158,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
} }
static int playChunk(ob_chunk * chunk, static int playChunk(ob_chunk * chunk,
const AudioFormat * format, double sizeToTime) const struct audio_format *format, double sizeToTime)
{ {
pc.elapsedTime = chunk->times; pc.elapsedTime = chunk->times;
pc.bitRate = chunk->bitRate; pc.bitRate = chunk->bitRate;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "log.h" #include "log.h"
#include "conf.h" #include "conf.h"
#include "audio_format.h"
#include "mpd_types.h"
#include "os_compat.h" #include "os_compat.h"
/* Added 4/14/2004 by AliasMrJones */ /* Added 4/14/2004 by AliasMrJones */
...@@ -104,7 +106,7 @@ void freeReplayGainInfo(ReplayGainInfo * info) ...@@ -104,7 +106,7 @@ void freeReplayGainInfo(ReplayGainInfo * info)
} }
void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize, void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
const AudioFormat * format) const struct audio_format *format)
{ {
mpd_sint16 *buffer16; mpd_sint16 *buffer16;
mpd_sint8 *buffer8; mpd_sint8 *buffer8;
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#ifndef REPLAYGAIN_H #ifndef REPLAYGAIN_H
#define REPLAYGAIN_H #define REPLAYGAIN_H
#include "audio_format.h"
#define REPLAYGAIN_OFF 0 #define REPLAYGAIN_OFF 0
#define REPLAYGAIN_TRACK 1 #define REPLAYGAIN_TRACK 1
#define REPLAYGAIN_ALBUM 2 #define REPLAYGAIN_ALBUM 2
struct audio_format;
extern int replayGainState; extern int replayGainState;
typedef struct _ReplayGainInfo { typedef struct _ReplayGainInfo {
...@@ -45,6 +45,6 @@ void freeReplayGainInfo(ReplayGainInfo * info); ...@@ -45,6 +45,6 @@ void freeReplayGainInfo(ReplayGainInfo * info);
void initReplayGainState(void); void initReplayGainState(void);
void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize, void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
const AudioFormat * format); const struct audio_format *format);
#endif #endif
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "timer.h" #include "timer.h"
#include "utils.h" #include "utils.h"
#include "audio_format.h"
#include "os_compat.h" #include "os_compat.h"
static uint64_t now(void) static uint64_t now(void)
...@@ -29,7 +30,7 @@ static uint64_t now(void) ...@@ -29,7 +30,7 @@ static uint64_t now(void)
return ((uint64_t)tv.tv_sec * 1000000) + tv.tv_usec; return ((uint64_t)tv.tv_sec * 1000000) + tv.tv_usec;
} }
Timer *timer_new(AudioFormat *af) Timer *timer_new(struct audio_format *af)
{ {
Timer *timer; Timer *timer;
......
...@@ -19,16 +19,17 @@ ...@@ -19,16 +19,17 @@
#ifndef MPD_TIMER_H #ifndef MPD_TIMER_H
#define MPD_TIMER_H #define MPD_TIMER_H
#include "audio_format.h"
#include "os_compat.h" #include "os_compat.h"
struct audio_format;
typedef struct _Timer { typedef struct _Timer {
uint64_t time; uint64_t time;
int started; int started;
int rate; int rate;
} Timer; } Timer;
Timer *timer_new(AudioFormat *af); Timer *timer_new(struct audio_format *af);
void timer_free(Timer *timer); void timer_free(Timer *timer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment