MediaExtractor: fix cache size computation for audio
Untested. If audio is not decoding well, try increasing the constant. Change-Id: I151764e6bb3e69088904d33bfeb683bf0569bd23 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3605 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
parent
437df0a3fb
commit
d753645e3f
@ -438,13 +438,20 @@ MediaExtractor::_ExtractorEntry(void* extractor)
|
||||
size_t
|
||||
MediaExtractor::_CalculateChunkBuffer(int32 stream)
|
||||
{
|
||||
const media_format* format = EncodedFormat(stream);
|
||||
size_t cacheSize = 3 * 1024 * 1024;
|
||||
int32 rowSize = BPrivate::get_bytes_per_row(format->ColorSpace(),
|
||||
format->Width());
|
||||
if (rowSize > 0) {
|
||||
// Frame size, multipled by 2 for good measure
|
||||
cacheSize = rowSize * format->Height() * 2;
|
||||
|
||||
const media_format* format = EncodedFormat(stream);
|
||||
if (format->IsVideo()) {
|
||||
// For video, have space for at least two frames
|
||||
int32 rowSize = BPrivate::get_bytes_per_row(format->ColorSpace(),
|
||||
format->Width());
|
||||
if (rowSize > 0) {
|
||||
cacheSize = rowSize * format->Height() * 2;
|
||||
}
|
||||
} else if (format->IsAudio()) {
|
||||
// For audio, have space for 2000 "frames" (that's 2000/44100 = 45ms
|
||||
// at 44100Hz for example)
|
||||
cacheSize = format->AudioFrameSize() * 2000;
|
||||
}
|
||||
return ROUND_UP_TO_PAGE(cacheSize);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user