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;
|
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!! */
|
/* make sure initPlayerData is called before this function!! */
|
||||||
void initAudioDriver(void)
|
void initAudioDriver(void)
|
||||||
{
|
{
|
||||||
@ -230,13 +222,8 @@ void finishAudioDriver(void)
|
|||||||
|
|
||||||
int isCurrentAudioFormat(const struct audio_format *audioFormat)
|
int isCurrentAudioFormat(const struct audio_format *audioFormat)
|
||||||
{
|
{
|
||||||
if (!audioFormat)
|
return audioFormat == NULL ||
|
||||||
return 1;
|
audio_format_equals(audioFormat, &audio_format);
|
||||||
|
|
||||||
if (cmpAudioFormat(audioFormat, &audio_format) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void syncAudioDeviceStates(void)
|
static void syncAudioDeviceStates(void)
|
||||||
|
@ -27,8 +27,6 @@ struct audio_format;
|
|||||||
struct tag;
|
struct tag;
|
||||||
struct client;
|
struct client;
|
||||||
|
|
||||||
int cmpAudioFormat(const struct audio_format *dest, const struct audio_format *src);
|
|
||||||
|
|
||||||
void getOutputAudioFormat(const struct audio_format *inFormat,
|
void getOutputAudioFormat(const struct audio_format *inFormat,
|
||||||
struct audio_format *outFormat);
|
struct audio_format *outFormat);
|
||||||
|
|
||||||
|
@ -27,6 +27,14 @@ struct audio_format {
|
|||||||
mpd_sint8 channels;
|
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)
|
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;
|
||||||
|
@ -162,7 +162,7 @@ decoder_data(struct decoder *decoder, InputStream * inStream, int seekable,
|
|||||||
static size_t convBufferLen;
|
static size_t convBufferLen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (cmpAudioFormat(&(ob.audioFormat), &(dc.audioFormat)) == 0) {
|
if (audio_format_equals(&ob.audioFormat, &dc.audioFormat)) {
|
||||||
data = dataIn;
|
data = dataIn;
|
||||||
datalen = dataInLen;
|
datalen = dataInLen;
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "output_api.h"
|
#include "output_api.h"
|
||||||
#include "pcm_utils.h"
|
#include "pcm_utils.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "audio.h"
|
|
||||||
|
|
||||||
int audio_output_open(struct audio_output *audioOutput,
|
int audio_output_open(struct audio_output *audioOutput,
|
||||||
const struct audio_format *audioFormat)
|
const struct audio_format *audioFormat)
|
||||||
@ -28,7 +27,7 @@ int audio_output_open(struct audio_output *audioOutput,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (audioOutput->open &&
|
if (audioOutput->open &&
|
||||||
0 == cmpAudioFormat(audioFormat, &audioOutput->inAudioFormat)) {
|
audio_format_equals(audioFormat, &audioOutput->inAudioFormat)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +45,8 @@ int audio_output_open(struct audio_output *audioOutput,
|
|||||||
ret = audioOutput->plugin->open(audioOutput);
|
ret = audioOutput->plugin->open(audioOutput);
|
||||||
|
|
||||||
audioOutput->sameInAndOutFormats =
|
audioOutput->sameInAndOutFormats =
|
||||||
!cmpAudioFormat(&audioOutput->inAudioFormat,
|
audio_format_equals(&audioOutput->inAudioFormat,
|
||||||
&audioOutput->outAudioFormat);
|
&audioOutput->outAudioFormat);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user