aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-09 10:04:42 +0200
committerMax Kellermann <max@duempel.org>2008-09-09 10:04:42 +0200
commit7f1cccb3ea2c94d27b1964530405c953d474bfd0 (patch)
tree85e9b51210a70e686b5c689fd13ac72707bf4f8b
parentf9316fbbbef04206be703ff3e7a2e175a958bff3 (diff)
downloadmpd-7f1cccb3ea2c94d27b1964530405c953d474bfd0.tar.gz
mpd-7f1cccb3ea2c94d27b1964530405c953d474bfd0.tar.xz
mpd-7f1cccb3ea2c94d27b1964530405c953d474bfd0.zip
audio: replaced copyAudioFormat() with simple assignment
The "!src" check in copyAudioFormat() used to hide bugs - one should never pass NULL to it. There is one caller which might pass NULL, add a check in this caller. Instead of doing mempcy(), we can simply assign the structures, which looks more natural.
Diffstat (limited to '')
-rw-r--r--src/audio.c18
-rw-r--r--src/audio.h2
-rw-r--r--src/output_control.c8
-rw-r--r--src/output_init.c2
4 files changed, 9 insertions, 21 deletions
diff --git a/src/audio.c b/src/audio.c
index 532db5f37..7bec92437 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -66,14 +66,6 @@ static unsigned int audio_output_count(void)
return nr;
}
-void copyAudioFormat(struct audio_format *dest, const struct audio_format *src)
-{
- if (!src)
- return;
-
- memcpy(dest, src, sizeof(*dest));
-}
-
int cmpAudioFormat(const struct audio_format *f1, const struct audio_format *f2)
{
if (f1 && f2 && (f1->sampleRate == f2->sampleRate) &&
@@ -130,10 +122,9 @@ void initAudioDriver(void)
void getOutputAudioFormat(const struct audio_format *inAudioFormat,
struct audio_format *outAudioFormat)
{
- if (audio_configFormat) {
- copyAudioFormat(outAudioFormat, audio_configFormat);
- } else
- copyAudioFormat(outAudioFormat, inAudioFormat);
+ *outAudioFormat = audio_configFormat != NULL
+ ? *audio_configFormat
+ : *inAudioFormat;
}
void initAudioConfig(void)
@@ -316,7 +307,8 @@ int openAudioDevice(const struct audio_format *audioFormat)
if (!audioOpened || !isCurrentAudioFormat(audioFormat)) {
flushAudioBuffer();
- copyAudioFormat(&audio_format, audioFormat);
+ if (audioFormat != NULL)
+ audio_format = *audioFormat;
audioBufferSize = (audio_format.bits >> 3) *
audio_format.channels;
audioBufferSize *= audio_format.sampleRate >> 5;
diff --git a/src/audio.h b/src/audio.h
index 54c91fa3f..0b7ecea88 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -27,8 +27,6 @@ struct audio_format;
struct tag;
struct client;
-void copyAudioFormat(struct audio_format *dest, const struct audio_format *src);
-
int cmpAudioFormat(const struct audio_format *dest, const struct audio_format *src);
void getOutputAudioFormat(const struct audio_format *inFormat,
diff --git a/src/output_control.c b/src/output_control.c
index 8a5e14e00..3459a9047 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -32,14 +32,12 @@ int audio_output_open(struct audio_output *audioOutput,
return 0;
}
- copyAudioFormat(&audioOutput->inAudioFormat, audioFormat);
+ audioOutput->inAudioFormat = *audioFormat;
if (audioOutput->convertAudioFormat) {
- copyAudioFormat(&audioOutput->outAudioFormat,
- &audioOutput->reqAudioFormat);
+ audioOutput->outAudioFormat = audioOutput->reqAudioFormat;
} else {
- copyAudioFormat(&audioOutput->outAudioFormat,
- &audioOutput->inAudioFormat);
+ audioOutput->outAudioFormat = audioOutput->inAudioFormat;
if (audioOutput->open)
audio_output_close(audioOutput);
}
diff --git a/src/output_init.c b/src/output_init.c
index 33352ca2a..d339f3540 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -103,7 +103,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
FATAL("error parsing format at line %i\n", bp->line);
}
- copyAudioFormat(&ao->outAudioFormat, &ao->reqAudioFormat);
+ ao->outAudioFormat = ao->reqAudioFormat;
}
if (plugin->init(ao, param) != 0)