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
This commit is contained in:
Eric Wong 2006-04-05 09:54:43 +00:00
parent e2e7d113ad
commit c208b05a0e
2 changed files with 8 additions and 3 deletions

View File

@ -62,8 +62,13 @@ void copyAudioFormat(AudioFormat * dest, AudioFormat * src) {
memcpy(dest, src, sizeof(AudioFormat)); memcpy(dest, src, sizeof(AudioFormat));
} }
int cmpAudioFormat(AudioFormat * f1, AudioFormat * f2) { int cmpAudioFormat(AudioFormat * f1, AudioFormat * f2)
return memcmp(f1, f2, sizeof(AudioFormat)); {
if (f1 && f2 && (f1->sampleRate == f2->sampleRate) &&
(f1->bits == f2->bits) &&
(f1->channels == f2->channels))
return 0;
return 1;
} }
extern AudioOutputPlugin alsaPlugin; extern AudioOutputPlugin alsaPlugin;

View File

@ -74,7 +74,7 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
static char * convBuffer = NULL; static char * convBuffer = NULL;
static long convBufferLen = 0; static long convBufferLen = 0;
if(memcmp(&(cb->audioFormat),&(dc->audioFormat),sizeof(AudioFormat))==0) if(cmpAudioFormat(&(cb->audioFormat),&(dc->audioFormat))==0)
{ {
data = dataIn; data = dataIn;
datalen = dataInLen; datalen = dataInLen;