diff --git a/cobalt/media/decoder_buffer_allocator.cc b/cobalt/media/decoder_buffer_allocator.cc index 55e2dcfd4462..d92c8b60e248 100644 --- a/cobalt/media/decoder_buffer_allocator.cc +++ b/cobalt/media/decoder_buffer_allocator.cc @@ -176,9 +176,10 @@ int DecoderBufferAllocator::GetBufferPadding() const { #endif // SB_API_VERSION >= 14 } -int64_t DecoderBufferAllocator::GetBufferGarbageCollectionDurationThreshold() - const { - return SbMediaGetBufferGarbageCollectionDurationThreshold(); +base::TimeDelta +DecoderBufferAllocator::GetBufferGarbageCollectionDurationThreshold() const { + return base::TimeDelta::FromMicroseconds( + SbMediaGetBufferGarbageCollectionDurationThreshold()); } int DecoderBufferAllocator::GetProgressiveBufferBudget( diff --git a/cobalt/media/decoder_buffer_allocator.h b/cobalt/media/decoder_buffer_allocator.h index 7a5b806a762b..d969a2693cfb 100644 --- a/cobalt/media/decoder_buffer_allocator.h +++ b/cobalt/media/decoder_buffer_allocator.h @@ -18,6 +18,7 @@ #include #include "base/compiler_specific.h" +#include "base/time/time.h" #include "cobalt/media/bidirectional_fit_reuse_allocator.h" #include "cobalt/media/decoder_buffer_memory_info.h" #include "cobalt/media/starboard_memory_allocator.h" @@ -46,7 +47,7 @@ class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator, int GetAudioBufferBudget() const override; int GetBufferAlignment() const override; int GetBufferPadding() const override; - int64_t GetBufferGarbageCollectionDurationThreshold() const override; + base::TimeDelta GetBufferGarbageCollectionDurationThreshold() const override; int GetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_width, int resolution_height, int bits_per_pixel) const override; diff --git a/third_party/chromium/media/base/decoder_buffer.h b/third_party/chromium/media/base/decoder_buffer.h index e9e60861268f..35435d666f9b 100644 --- a/third_party/chromium/media/base/decoder_buffer.h +++ b/third_party/chromium/media/base/decoder_buffer.h @@ -59,7 +59,7 @@ class MEDIA_EXPORT DecoderBuffer virtual int GetAudioBufferBudget() const = 0; virtual int GetBufferAlignment() const = 0; virtual int GetBufferPadding() const = 0; - virtual int64_t GetBufferGarbageCollectionDurationThreshold() const = 0; + virtual base::TimeDelta GetBufferGarbageCollectionDurationThreshold() const = 0; virtual int GetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_width, int resolution_height, diff --git a/third_party/chromium/media/filters/source_buffer_stream.cc b/third_party/chromium/media/filters/source_buffer_stream.cc index 9f0355d30bb4..f086c3898cd0 100644 --- a/third_party/chromium/media/filters/source_buffer_stream.cc +++ b/third_party/chromium/media/filters/source_buffer_stream.cc @@ -848,11 +848,11 @@ bool SourceBufferStream::GarbageCollectIfNeeded(base::TimeDelta media_time, #if defined(STARBOARD) // Address duration based GC. base::TimeDelta duration = GetBufferedDurationForGarbageCollection(); - const int64_t duration_gc_threadold = + base::TimeDelta duration_gc_threadold = DecoderBuffer::Allocator::GetInstance() ->GetBufferGarbageCollectionDurationThreshold(); - if (duration.InMicroseconds() > duration_gc_threadold) { - effective_memory_limit = ranges_size * duration_gc_threadold / + if (duration > duration_gc_threadold) { + effective_memory_limit = ranges_size * duration_gc_threadold.InMicroseconds() / duration.InMicroseconds(); } #endif // defined(STARBOARD)