audio_format: added audio_format_clear() and audio_format_defined()
audio_format_clear() sets an audio_format struct to an cleared (undefined) state, which is both faster and smaller than memset(0). audio_format_defined() checks if the audio_format struct actually has a defined value (i.e. non-zero). Both can be used to avoid pointers to audio_format, replacing the "NULL" value with an "undefined" audio_format.
This commit is contained in:
parent
9ceadb0561
commit
d92543698c
@ -231,7 +231,7 @@ static void syncAudioDeviceStates(void)
|
|||||||
struct audio_output *audioOutput;
|
struct audio_output *audioOutput;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!audio_format.channels)
|
if (!audio_format_defined(&audio_format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < audioOutputArraySize; ++i) {
|
for (i = 0; i < audioOutputArraySize; ++i) {
|
||||||
|
@ -27,6 +27,18 @@ struct audio_format {
|
|||||||
mpd_sint8 channels;
|
mpd_sint8 channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline void audio_format_clear(struct audio_format *af)
|
||||||
|
{
|
||||||
|
af->sampleRate = 0;
|
||||||
|
af->bits = 0;
|
||||||
|
af->channels = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int audio_format_defined(const struct audio_format *af)
|
||||||
|
{
|
||||||
|
return af->sampleRate != 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int audio_format_equals(const struct audio_format *a,
|
static inline int audio_format_equals(const struct audio_format *a,
|
||||||
const struct audio_format *b)
|
const struct audio_format *b)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user