audio: moved cmpAudioFormat() to audio_format.h
Rename it to audio_format_equals() and return "true" if they are equal.
This commit is contained in:
parent
7f1cccb3ea
commit
be9212ba84
17
src/audio.c
17
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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user