Commit c208b05a authored by Eric Wong's avatar Eric Wong

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
parent e2e7d113
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment