Skip to content

Commit

Permalink
Use base::TimeDelta in DecoderBuffer::Allocator
Browse files Browse the repository at this point in the history
Now its member function GetBufferGarbageCollectionDurationThreshold()
returns base::TimeDelta instead of int64_t.

b/319904866

Change-Id: Id6547d66630357421031170165683fa80c11b183
  • Loading branch information
xiaomings committed Jan 12, 2024
1 parent 9028632 commit b4e1123
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions cobalt/media/decoder_buffer_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion cobalt/media/decoder_buffer_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <memory>

#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"
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion third_party/chromium/media/base/decoder_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions third_party/chromium/media/filters/source_buffer_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b4e1123

Please sign in to comment.