Skip to content

Commit

Permalink
[media] Clean ups on initialization order, etc. (youtube#3851)
Browse files Browse the repository at this point in the history
1. Refined ctor initialization orders.
2. Removed unused variables.
3. Removed unused header files.
4. Added missing override to virtual functions.

b/276483058

Change-Id: I1c07f47c0efca49d4ac35aff806e103eb54605b1
  • Loading branch information
xiaomings authored Jul 18, 2024
1 parent a344283 commit f265a38
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions starboard/android/shared/media_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ MediaDecoder::MediaDecoder(Host* host,
: media_type_(kSbMediaTypeAudio),
host_(host),
drm_system_(static_cast<DrmSystem*>(drm_system)),
condition_variable_(mutex_),
tunnel_mode_enabled_(false) {
tunnel_mode_enabled_(false),
condition_variable_(mutex_) {
SB_DCHECK(host_);

jobject j_media_crypto = drm_system_ ? drm_system_->GetMediaCrypto() : NULL;
Expand Down
2 changes: 0 additions & 2 deletions starboard/android/shared/player_components_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::

const int kAudioSinkFramesAlignment = 256;
const int kDefaultAudioSinkMinFramesPerAppend = 1024;
const int kDefaultAudioSinkMaxCachedFrames =
8 * kDefaultAudioSinkMinFramesPerAppend;

static int AlignUp(int value, int alignment) {
return (value + alignment - 1) / alignment * alignment;
Expand Down
2 changes: 2 additions & 0 deletions starboard/android/shared/thread_create_priority.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ SbThreadPriority NiceToSbPriority(int nice) {
if (nice == -19) {
return kSbThreadPriorityRealTime;
}
SB_NOTREACHED();
return kSbThreadPriorityNormal;
}

} // namespace
Expand Down
10 changes: 4 additions & 6 deletions starboard/android/shared/video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
#include <functional>
#include <list>

#include "starboard/android/shared/application_android.h"
#include "starboard/android/shared/decode_target_create.h"
#include "starboard/android/shared/decode_target_internal.h"
#include "starboard/android/shared/jni_env_ext.h"
#include "starboard/android/shared/jni_utils.h"
#include "starboard/android/shared/media_common.h"
#include "starboard/android/shared/video_render_algorithm.h"
#include "starboard/android/shared/window_internal.h"
#include "starboard/common/media.h"
#include "starboard/common/player.h"
#include "starboard/common/string.h"
Expand Down Expand Up @@ -365,18 +363,18 @@ VideoDecoder::VideoDecoder(const VideoStreamInfo& video_stream_info,
decode_target_graphics_context_provider_(
decode_target_graphics_context_provider),
max_video_capabilities_(max_video_capabilities),
require_software_codec_(IsSoftwareDecodeRequired(max_video_capabilities)),
force_big_endian_hdr_metadata_(force_big_endian_hdr_metadata),
tunnel_mode_audio_session_id_(tunnel_mode_audio_session_id),
max_video_input_size_(max_video_input_size),
enable_flush_during_seek_(enable_flush_during_seek),
force_reset_surface_under_tunnel_mode_(
force_reset_surface_under_tunnel_mode),
is_video_frame_tracker_enabled_(IsFrameRenderedCallbackEnabled() ||
tunnel_mode_audio_session_id != -1),
has_new_texture_available_(false),
surface_condition_variable_(surface_destroy_mutex_),
require_software_codec_(IsSoftwareDecodeRequired(max_video_capabilities)),
force_big_endian_hdr_metadata_(force_big_endian_hdr_metadata),
number_of_preroll_frames_(kInitialPrerollFrameCount),
enable_flush_during_seek_(enable_flush_during_seek) {
number_of_preroll_frames_(kInitialPrerollFrameCount) {
SB_DCHECK(error_message);

if (force_secure_pipeline_under_tunnel_mode) {
Expand Down
2 changes: 1 addition & 1 deletion starboard/android/shared/video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class VideoDecoder
void WriteInputBuffersInternal(const InputBuffers& input_buffers);
void ProcessOutputBuffer(MediaCodecBridge* media_codec_bridge,
const DequeueOutputResult& output) override;
void OnEndOfStreamWritten(MediaCodecBridge* media_codec_bridge);
void OnEndOfStreamWritten(MediaCodecBridge* media_codec_bridge) override;
void RefreshOutputFormat(MediaCodecBridge* media_codec_bridge) override;
bool Tick(MediaCodecBridge* media_codec_bridge) override;
void OnFlushing() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ class StubAudioSink : public SbAudioSinkPrivate {
void AudioThreadFunc();

Type* type_;
const int sampling_frequency_hz_;
SbAudioSinkUpdateSourceStatusFunc update_source_status_func_;
ConsumeFramesFunc consume_frames_func_;
void* context_;

int sampling_frequency_hz_;

pthread_t audio_out_thread_;
::starboard::Mutex mutex_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ AudioRendererPcm::AudioRendererPcm(
int min_frames_per_append)
: max_cached_frames_(max_cached_frames),
min_frames_per_append_(min_frames_per_append),
decoder_(std::move(decoder)),
frames_consumed_set_at_(CurrentMonotonicTime()),
channels_(audio_stream_info.number_of_channels),
sink_sample_type_(GetSinkAudioSampleType(audio_renderer_sink.get())),
bytes_per_frame_(media::GetBytesPerSample(sink_sample_type_) * channels_),
frame_buffer_(max_cached_frames_ * bytes_per_frame_),
frames_consumed_set_at_(CurrentMonotonicTime()),
decoder_(std::move(decoder)),
process_audio_data_job_(
std::bind(&AudioRendererPcm::ProcessAudioData, this)),
audio_renderer_sink_(std::move(audio_renderer_sink)) {
Expand Down
12 changes: 4 additions & 8 deletions starboard/shared/starboard/player/filter/audio_resampler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class AudioResamplerImpl : public AudioResampler {
SbMediaAudioFrameStorageType destination_storage_type,
int destination_sample_rate,
int channels)
: source_sample_type_(source_sample_type),
source_storage_type_(source_storage_type),
destination_sample_type_(destination_sample_type),
: destination_sample_type_(destination_sample_type),
destination_storage_type_(destination_storage_type),
interleaved_resampler_(static_cast<double>(source_sample_rate) /
static_cast<double>(destination_sample_rate),
Expand All @@ -54,12 +52,10 @@ class AudioResamplerImpl : public AudioResampler {
scoped_refptr<DecodedAudio> WriteEndOfStream() override;

private:
InterleavedSincResampler interleaved_resampler_;
const SbMediaAudioSampleType destination_sample_type_;
const SbMediaAudioFrameStorageType destination_storage_type_;

SbMediaAudioSampleType source_sample_type_;
SbMediaAudioFrameStorageType source_storage_type_;
SbMediaAudioSampleType destination_sample_type_;
SbMediaAudioFrameStorageType destination_storage_type_;
InterleavedSincResampler interleaved_resampler_;

std::deque<scoped_refptr<DecodedAudio>> audio_inputs_;

Expand Down
2 changes: 0 additions & 2 deletions starboard/shared/starboard/player/filter/player_components.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ namespace {

const int kAudioSinkFramesAlignment = 256;
const int kDefaultAudioSinkMinFramesPerAppend = 1024;
const int kDefaultAudioSinkMaxCachedFrames =
8 * kDefaultAudioSinkMinFramesPerAppend;

typedef MediaTimeProviderImpl::MonotonicSystemTimeProvider
MonotonicSystemTimeProvider;
Expand Down

0 comments on commit f265a38

Please sign in to comment.