Skip to content

Commit

Permalink
Cleanup mime attribute of enablepcmcontenttypemovie
Browse files Browse the repository at this point in the history
Remove this attribute as it is not used.

b/216483296
  • Loading branch information
borongc committed Sep 12, 2023
1 parent f0f9b5a commit 47d829a
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ AudioTrackBridge createAudioTrackBridge(
int sampleRate,
int channelCount,
int preferredBufferSizeInBytes,
boolean enablePcmContentTypeMovie,
int tunnelModeAudioSessionId,
boolean isWebAudio) {
AudioTrackBridge audioTrackBridge =
Expand All @@ -69,7 +68,6 @@ AudioTrackBridge createAudioTrackBridge(
sampleRate,
channelCount,
preferredBufferSizeInBytes,
enablePcmContentTypeMovie,
tunnelModeAudioSessionId,
isWebAudio);
if (!audioTrackBridge.isAudioTrackValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public AudioTrackBridge(
int sampleRate,
int channelCount,
int preferredBufferSizeInBytes,
boolean enablePcmContentTypeMovie,
int tunnelModeAudioSessionId,
boolean isWebAudio) {

Expand Down Expand Up @@ -119,7 +118,7 @@ public AudioTrackBridge(
// TODO: Support ENCODING_E_AC3_JOC for api level 28 or later.
final boolean isSurround =
sampleType == AudioFormat.ENCODING_AC3 || sampleType == AudioFormat.ENCODING_E_AC3;
final boolean useContentTypeMovie = isSurround || (!isWebAudio && enablePcmContentTypeMovie);
final boolean useContentTypeMovie = isSurround || !isWebAudio;
attributes =
new AudioAttributes.Builder()
.setContentType(
Expand Down
3 changes: 1 addition & 2 deletions starboard/android/shared/audio_renderer_passthrough.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ void AudioRendererPassthrough::CreateAudioTrackAndStartProcessing() {
optional<SbMediaAudioSampleType>(), // Not required in passthrough mode
audio_stream_info_.number_of_channels,
audio_stream_info_.samples_per_second, kPreferredBufferSizeInBytes,
false /* enable_pcm_content_type_movie */, kTunnelModeAudioSessionId,
false /* is_web_audio */));
kTunnelModeAudioSessionId, false /* is_web_audio */));

if (!audio_track_bridge->is_valid()) {
error_cb_(kSbPlayerErrorDecode, "Error creating AudioTrackBridge");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void MinRequiredFramesTester::TesterThreadFunc() {
GetSampleSize(task.sample_type),
&MinRequiredFramesTester::UpdateSourceStatusFunc,
&MinRequiredFramesTester::ConsumeFramesFunc,
&MinRequiredFramesTester::ErrorFunc, 0, -1, false, false, this);
&MinRequiredFramesTester::ErrorFunc, 0, -1, false, this);
{
ScopedLock scoped_lock(mutex_);
wait_timeout = !condition_variable_.WaitTimed(kSbTimeSecond * 5);
Expand Down
11 changes: 2 additions & 9 deletions starboard/android/shared/audio_track_audio_sink_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ AudioTrackAudioSink::AudioTrackAudioSink(
SbAudioSinkPrivate::ErrorFunc error_func,
SbTime start_time,
int tunnel_mode_audio_session_id,
bool enable_pcm_content_type_movie,
bool is_web_audio,
void* context)
: type_(type),
Expand All @@ -106,7 +105,6 @@ AudioTrackAudioSink::AudioTrackAudioSink(
channels,
sampling_frequency_hz,
preferred_buffer_size_in_bytes,
enable_pcm_content_type_movie,
tunnel_mode_audio_session_id,
is_web_audio) {
SB_DCHECK(update_source_status_func_);
Expand Down Expand Up @@ -432,13 +430,10 @@ SbAudioSink AudioTrackAudioSinkType::Create(
// Disable tunnel mode.
const int kTunnelModeAudioSessionId = -1;
const bool kIsWebAudio = true;
// Disable AudioAttributes::CONTENT_TYPE_MOVIE for WebAudio.
const bool kEnablePcmContentTypeMovie = false;
return Create(channels, sampling_frequency_hz, audio_sample_type,
audio_frame_storage_type, frame_buffers, frames_per_channel,
update_source_status_func, consume_frames_func, error_func,
kStartTime, kTunnelModeAudioSessionId,
kEnablePcmContentTypeMovie, kIsWebAudio, context);
kStartTime, kTunnelModeAudioSessionId, kIsWebAudio, context);
}

SbAudioSink AudioTrackAudioSinkType::Create(
Expand All @@ -453,7 +448,6 @@ SbAudioSink AudioTrackAudioSinkType::Create(
SbAudioSinkPrivate::ErrorFunc error_func,
SbTime start_media_time,
int tunnel_mode_audio_session_id,
bool enable_pcm_content_type_movie,
bool is_web_audio,
void* context) {
int min_required_frames = SbAudioSinkGetMinBufferSizeInFrames(
Expand All @@ -465,8 +459,7 @@ SbAudioSink AudioTrackAudioSinkType::Create(
this, channels, sampling_frequency_hz, audio_sample_type, frame_buffers,
frames_per_channel, preferred_buffer_size_in_bytes,
update_source_status_func, consume_frames_func, error_func,
start_media_time, tunnel_mode_audio_session_id,
enable_pcm_content_type_movie, is_web_audio, context);
start_media_time, tunnel_mode_audio_session_id, is_web_audio, context);
if (!audio_sink->IsAudioTrackValid()) {
SB_DLOG(ERROR)
<< "AudioTrackAudioSinkType::Create failed to create audio track";
Expand Down
2 changes: 0 additions & 2 deletions starboard/android/shared/audio_track_audio_sink_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class AudioTrackAudioSinkType : public SbAudioSinkPrivate::Type {
SbAudioSinkPrivate::ErrorFunc error_func,
SbTime start_time,
int tunnel_mode_audio_session_id,
bool enable_pcm_content_type_movie,
bool is_web_audio,
void* context);

Expand Down Expand Up @@ -113,7 +112,6 @@ class AudioTrackAudioSink : public SbAudioSinkPrivate {
SbAudioSinkPrivate::ErrorFunc error_func,
SbTime start_media_time,
int tunnel_mode_audio_session_id,
bool enable_pcm_content_type_movie,
bool is_web_audio,
void* context);
~AudioTrackAudioSink() override;
Expand Down
7 changes: 3 additions & 4 deletions starboard/android/shared/audio_track_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ AudioTrackBridge::AudioTrackBridge(SbMediaAudioCodingType coding_type,
int channels,
int sampling_frequency_hz,
int preferred_buffer_size_in_bytes,
bool enable_pcm_content_type_movie,
int tunnel_mode_audio_session_id,
bool is_web_audio) {
if (coding_type == kSbMediaAudioCodingTypePcm) {
Expand All @@ -64,10 +63,10 @@ AudioTrackBridge::AudioTrackBridge(SbMediaAudioCodingType coding_type,
"getAudioOutputManager", "()Ldev/cobalt/media/AudioOutputManager;"));
jobject j_audio_track_bridge = env->CallObjectMethodOrAbort(
j_audio_output_manager.Get(), "createAudioTrackBridge",
"(IIIIZIZ)Ldev/cobalt/media/AudioTrackBridge;",
"(IIIIIZ)Ldev/cobalt/media/AudioTrackBridge;",
GetAudioFormatSampleType(coding_type, sample_type), sampling_frequency_hz,
channels, preferred_buffer_size_in_bytes, enable_pcm_content_type_movie,
tunnel_mode_audio_session_id, is_web_audio);
channels, preferred_buffer_size_in_bytes, tunnel_mode_audio_session_id,
is_web_audio);
if (!j_audio_track_bridge) {
// One of the cases that this may hit is when output happened to be switched
// to a device that doesn't support tunnel mode.
Expand Down
1 change: 0 additions & 1 deletion starboard/android/shared/audio_track_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class AudioTrackBridge {
int channels,
int sampling_frequency_hz,
int preferred_buffer_size_in_bytes,
bool enable_pcm_content_type_movie,
int tunnel_mode_audio_session_id,
bool is_web_audio);
~AudioTrackBridge();
Expand Down
7 changes: 0 additions & 7 deletions starboard/android/shared/media_is_audio_supported.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec,
}
enable_audio_passthrough =
mime_type->GetParamBoolValue("audiopassthrough", true);

// Allows for disabling the CONTENT_TYPE_MOVIE AudioAttribute for
// non-tunneled playbacks with PCM audio. Enabled by default.
// (https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_MOVIE)
if (!mime_type->ValidateBoolParameter("enablepcmcontenttypemovie")) {
return false;
}
}

if (enable_tunnel_mode && !SbAudioSinkIsAudioSampleTypeSupported(
Expand Down
20 changes: 5 additions & 15 deletions starboard/android/shared/player_components_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ constexpr bool kForceResetSurfaceUnderTunnelMode = true;
class AudioRendererSinkAndroid : public ::starboard::shared::starboard::player::
filter::AudioRendererSinkImpl {
public:
explicit AudioRendererSinkAndroid(bool enable_pcm_content_type_movie,
int tunnel_mode_audio_session_id = -1)
explicit AudioRendererSinkAndroid(int tunnel_mode_audio_session_id = -1)
: AudioRendererSinkImpl(
[=](SbTime start_media_time,
int channels,
Expand All @@ -96,8 +95,7 @@ class AudioRendererSinkAndroid : public ::starboard::shared::starboard::player::
audio_frame_storage_type, frame_buffers,
frame_buffers_size_in_frames, update_source_status_func,
consume_frames_func, error_func, start_media_time,
tunnel_mode_audio_session_id, enable_pcm_content_type_movie,
false, /* is_web_audio */
tunnel_mode_audio_session_id, false, /* is_web_audio */
context);
}),
tunnel_mode_audio_session_id_(tunnel_mode_audio_session_id) {}
Expand Down Expand Up @@ -294,8 +292,7 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
MimeType audio_mime_type(audio_mime);
if (!audio_mime.empty()) {
if (!audio_mime_type.is_valid() ||
!audio_mime_type.ValidateBoolParameter("tunnelmode") ||
!audio_mime_type.ValidateBoolParameter("enablepcmcontenttypemovie")) {
!audio_mime_type.ValidateBoolParameter("tunnelmode")) {
*error_message =
"Invalid audio MIME: '" + std::string(audio_mime) + "'";
return false;
Expand Down Expand Up @@ -414,12 +411,6 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
creation_parameters.audio_stream_info(),
creation_parameters.drm_system(), decoder_creator));

bool enable_pcm_content_type_movie =
audio_mime_type.GetParamBoolValue("enablepcmcontenttypemovie", true);
SB_LOG(INFO) << "AudioAttributes::CONTENT_TYPE_MOVIE is "
<< (enable_pcm_content_type_movie ? "enabled" : "disabled")
<< " for non-tunneled PCM audio playback.";

if (tunnel_mode_audio_session_id != -1) {
*audio_renderer_sink = TryToCreateTunnelModeAudioRendererSink(
tunnel_mode_audio_session_id, creation_parameters);
Expand All @@ -428,8 +419,7 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
}
}
if (!*audio_renderer_sink) {
audio_renderer_sink->reset(
new AudioRendererSinkAndroid(enable_pcm_content_type_movie));
audio_renderer_sink->reset(new AudioRendererSinkAndroid());
}
}

Expand Down Expand Up @@ -616,7 +606,7 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player::
int tunnel_mode_audio_session_id,
const CreationParameters& creation_parameters) {
scoped_ptr<AudioRendererSink> audio_sink(
new AudioRendererSinkAndroid(true, tunnel_mode_audio_session_id));
new AudioRendererSinkAndroid(tunnel_mode_audio_session_id));
// We need to double check if the audio sink can actually be created.
int max_cached_frames, min_frames_per_append;
GetAudioRendererParams(creation_parameters, &max_cached_frames,
Expand Down

0 comments on commit 47d829a

Please sign in to comment.