[haiku-commits] Change in haiku[master]: MediaExtractor: go back to 3MB min cache size

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 13 Jan 2021 14:45:31 +0000

From Máximo Castañeda <antiswen@xxxxxxxx>:

Máximo Castañeda has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3628 ;)


Change subject: MediaExtractor: go back to 3MB min cache size
......................................................................

MediaExtractor: go back to 3MB min cache size

Should allow us to at least play the same files we could play before.

Fixes #16738, though not its cause

Change-Id: I2d23011696b730a891c802e8c2bfc23afe0041cf
---
M src/kits/media/MediaExtractor.cpp
1 file changed, 6 insertions(+), 5 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/28/3628/1

diff --git a/src/kits/media/MediaExtractor.cpp 
b/src/kits/media/MediaExtractor.cpp
index 3019b4d..b17491c 100644
--- a/src/kits/media/MediaExtractor.cpp
+++ b/src/kits/media/MediaExtractor.cpp
@@ -444,6 +444,11 @@
 size_t
 MediaExtractor::_CalculateChunkBuffer(int32 stream)
 {
+       // WARNING: magic
+       // Your A/V may skip frames, chunks or not play at all if the cache size
+       // is insufficient. Unfortunately there's currently no safe way to
+       // calculate it.
+
        size_t cacheSize = 3 * 1024 * 1024;

        const media_format* format = EncodedFormat(stream);
@@ -452,12 +457,8 @@
                int32 rowSize = 
BPrivate::get_bytes_per_row(format->ColorSpace(),
                        format->Width());
                if (rowSize > 0) {
-                       cacheSize = rowSize * format->Height() * 2;
+                       cacheSize = max_c(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/+/3628
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I2d23011696b730a891c802e8c2bfc23afe0041cf
Gerrit-Change-Number: 3628
Gerrit-PatchSet: 1
Gerrit-Owner: Máximo Castañeda <antiswen@xxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: MediaExtractor: go back to 3MB min cache size - Gerrit