Bug 469628 - Playing 8-bit Wave files can block writing to the audio backend - r=doublec sr=roc

This commit is contained in:
Matthew Gregan 2008-12-16 12:37:42 +13:00
Родитель 1b324bbec5
Коммит 6efa8eee37
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -537,8 +537,9 @@ nsWaveStateMachine::Run()
// completely fill the audio backend's buffers with data. This // completely fill the audio backend's buffers with data. This
// allows us plenty of time to wake up and refill the buffers // allows us plenty of time to wake up and refill the buffers
// without an underrun occurring. // without an underrun occurring.
PRUint32 sampleSize = mSampleFormat == nsAudioStream::FORMAT_U8 ? 1 : 2;
PRUint32 len = RoundDownToSample(NS_MIN(mStream->Available(), PRUint32 len = RoundDownToSample(NS_MIN(mStream->Available(),
PRUint32(mAudioStream->Available() * sizeof(short)))); PRUint32(mAudioStream->Available() * sampleSize)));
if (len) { if (len) {
nsAutoArrayPtr<char> buf(new char[len]); nsAutoArrayPtr<char> buf(new char[len]);
PRUint32 got = 0; PRUint32 got = 0;