aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-04-05 09:54:43 +0000
committerEric Wong <normalperson@yhbt.net>2006-04-05 09:54:43 +0000
commitc208b05a0e9f2bfb0ae02410f34cf3431cab4dde (patch)
treee9a510154bb11288a56c376931fc6eba017378a2
parente2e7d113ad085e276fbf3803934416c8ac7a70d1 (diff)
downloadmpd-c208b05a0e9f2bfb0ae02410f34cf3431cab4dde.tar.gz
mpd-c208b05a0e9f2bfb0ae02410f34cf3431cab4dde.tar.xz
mpd-c208b05a0e9f2bfb0ae02410f34cf3431cab4dde.zip
Don't rely on memcmp() for structs, padding bits are random
git-svn-id: https://svn.musicpd.org/mpd/trunk@4016 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/audio.c9
-rw-r--r--src/outputBuffer.c2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/audio.c b/src/audio.c
index dfc209b32..dc5b26e50 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -62,8 +62,13 @@ void copyAudioFormat(AudioFormat * dest, AudioFormat * src) {
memcpy(dest, src, sizeof(AudioFormat));
}
-int cmpAudioFormat(AudioFormat * f1, AudioFormat * f2) {
- return memcmp(f1, f2, sizeof(AudioFormat));
+int cmpAudioFormat(AudioFormat * f1, AudioFormat * f2)
+{
+ if (f1 && f2 && (f1->sampleRate == f2->sampleRate) &&
+ (f1->bits == f2->bits) &&
+ (f1->channels == f2->channels))
+ return 0;
+ return 1;
}
extern AudioOutputPlugin alsaPlugin;
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 46b98c479..f6c9e0ab6 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -74,7 +74,7 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
static char * convBuffer = NULL;
static long convBufferLen = 0;
- if(memcmp(&(cb->audioFormat),&(dc->audioFormat),sizeof(AudioFormat))==0)
+ if(cmpAudioFormat(&(cb->audioFormat),&(dc->audioFormat))==0)
{
data = dataIn;
datalen = dataInLen;