diff options
author | Max Kellermann <max@duempel.org> | 2008-09-09 10:05:15 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-09 10:05:15 +0200 |
commit | be9212ba84a43a1c7ce4c4dcf179bb9ef08929f7 (patch) | |
tree | bf06342ae83b5b2b960b6e9a1776c8c952ed1b8b | |
parent | 7f1cccb3ea2c94d27b1964530405c953d474bfd0 (diff) | |
download | mpd-be9212ba84a43a1c7ce4c4dcf179bb9ef08929f7.tar.gz mpd-be9212ba84a43a1c7ce4c4dcf179bb9ef08929f7.tar.xz mpd-be9212ba84a43a1c7ce4c4dcf179bb9ef08929f7.zip |
audio: moved cmpAudioFormat() to audio_format.h
Rename it to audio_format_equals() and return "true" if they are
equal.
-rw-r--r-- | src/audio.c | 17 | ||||
-rw-r--r-- | src/audio.h | 2 | ||||
-rw-r--r-- | src/audio_format.h | 8 | ||||
-rw-r--r-- | src/decoder_api.c | 2 | ||||
-rw-r--r-- | src/output_control.c | 7 |
5 files changed, 14 insertions, 22 deletions
diff --git a/src/audio.c b/src/audio.c index 7bec92437..839052dc2 100644 --- a/src/audio.c +++ b/src/audio.c @@ -66,14 +66,6 @@ static unsigned int audio_output_count(void) return nr; } -int cmpAudioFormat(const struct audio_format *f1, const struct audio_format *f2) -{ - if (f1 && f2 && (f1->sampleRate == f2->sampleRate) && - (f1->bits == f2->bits) && (f1->channels == f2->channels)) - return 0; - return 1; -} - /* make sure initPlayerData is called before this function!! */ void initAudioDriver(void) { @@ -230,13 +222,8 @@ void finishAudioDriver(void) int isCurrentAudioFormat(const struct audio_format *audioFormat) { - if (!audioFormat) - return 1; - - if (cmpAudioFormat(audioFormat, &audio_format) != 0) - return 0; - - return 1; + return audioFormat == NULL || + audio_format_equals(audioFormat, &audio_format); } static void syncAudioDeviceStates(void) diff --git a/src/audio.h b/src/audio.h index 0b7ecea88..6e8db5944 100644 --- a/src/audio.h +++ b/src/audio.h @@ -27,8 +27,6 @@ struct audio_format; struct tag; struct client; -int cmpAudioFormat(const struct audio_format *dest, const struct audio_format *src); - void getOutputAudioFormat(const struct audio_format *inFormat, struct audio_format *outFormat); diff --git a/src/audio_format.h b/src/audio_format.h index b4b40c69f..1cfb258ae 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -27,6 +27,14 @@ struct audio_format { mpd_sint8 channels; }; +static inline int audio_format_equals(const struct audio_format *a, + const struct audio_format *b) +{ + return a->sampleRate == b->sampleRate && + a->bits == b->bits && + a->channels == b->channels; +} + static inline double audio_format_time_to_size(const struct audio_format *af) { return af->sampleRate * af->bits * af->channels / 8.0; diff --git a/src/decoder_api.c b/src/decoder_api.c index db1820db4..236fe5029 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -162,7 +162,7 @@ decoder_data(struct decoder *decoder, InputStream * inStream, int seekable, static size_t convBufferLen; int ret; - if (cmpAudioFormat(&(ob.audioFormat), &(dc.audioFormat)) == 0) { + if (audio_format_equals(&ob.audioFormat, &dc.audioFormat)) { data = dataIn; datalen = dataInLen; } else { diff --git a/src/output_control.c b/src/output_control.c index 3459a9047..df330ee21 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -20,7 +20,6 @@ #include "output_api.h" #include "pcm_utils.h" #include "utils.h" -#include "audio.h" int audio_output_open(struct audio_output *audioOutput, const struct audio_format *audioFormat) @@ -28,7 +27,7 @@ int audio_output_open(struct audio_output *audioOutput, int ret = 0; if (audioOutput->open && - 0 == cmpAudioFormat(audioFormat, &audioOutput->inAudioFormat)) { + audio_format_equals(audioFormat, &audioOutput->inAudioFormat)) { return 0; } @@ -46,8 +45,8 @@ int audio_output_open(struct audio_output *audioOutput, ret = audioOutput->plugin->open(audioOutput); audioOutput->sameInAndOutFormats = - !cmpAudioFormat(&audioOutput->inAudioFormat, - &audioOutput->outAudioFormat); + audio_format_equals(&audioOutput->inAudioFormat, + &audioOutput->outAudioFormat); return ret; } |