Skip to content

Commit

Permalink
Fix: Library downmixed AAC audios produce whitenoise when played.
Browse files Browse the repository at this point in the history
MOC asks the FAAD2 library to downmix 5.1 audios to stereo, but MOC
did not adjust the channel count from that of the original audio.

git-svn-id: svn://svn.daper.net/moc/trunk@3003 910807d9-36e0-0310-a014-e9ea483e2ba4
  • Loading branch information
jcf committed Sep 14, 2019
1 parent 4d6188c commit 1be01a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions decoder_plugins/aac/aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static int aac_count_time (struct aac_data *data)
return -1;

samples /= frames;
samples /= data->channels;
samples /= MIN(2, data->channels);
bytes /= frames;

return ((file_size / bytes) * samples) / data->sample_rate;
Expand Down Expand Up @@ -314,7 +314,15 @@ static void *aac_open_internal (struct io_stream *stream, const char *fname)
return data;
}

logit ("sample rate %dHz, channels %d", data->sample_rate, data->channels);
if (data->channels == 6) {
logit ("sample rate %dHz, channels %d (downmixed to stereo)",
data->sample_rate, data->channels);
data->channels = 2;
}
else
logit ("sample rate %dHz, channels %d", data->sample_rate,
data->channels);

if (!data->sample_rate || !data->channels) {
decoder_error (&data->error, ERROR_FATAL, 0,
"Invalid AAC sound parameters");
Expand Down

0 comments on commit 1be01a2

Please sign in to comment.