From Adrien Destugues <pulkomandy@xxxxxxxxx>:
Adrien Destugues has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/3605 ;)
Change subject: MediaExtractor: fix cache size computation for audio
......................................................................
MediaExtractor: fix cache size computation for audio
Untested. If audio is not decoding well, try increasing the constant.
---
M src/kits/media/MediaExtractor.cpp
1 file changed, 13 insertions(+), 6 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/05/3605/1
diff --git a/src/kits/media/MediaExtractor.cpp
b/src/kits/media/MediaExtractor.cpp
index 15d0451..517d8ca 100644
--- a/src/kits/media/MediaExtractor.cpp
+++ b/src/kits/media/MediaExtractor.cpp
@@ -438,13 +438,20 @@
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);
}
--
To view, visit https://review.haiku-os.org/c/haiku/+/3605
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I151764e6bb3e69088904d33bfeb683bf0569bd23
Gerrit-Change-Number: 3605
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange