Skip to content

Commit

Permalink
Revert "Disable MediaPlaybackService by default" (#2211)
Browse files Browse the repository at this point in the history
Reverts #2184

I saw this error when I cherry pick the code to LTS branch.
https://screenshot.googleplex.com/Az5j2K3DwR7fi9s

Revert the submit to fix the problem.

b/319146388
  • Loading branch information
zhongqiliang authored Jan 13, 2024
1 parent 5b54516 commit 1f2d96b
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 245 deletions.

This file was deleted.

1 change: 0 additions & 1 deletion cobalt/media/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ target(gtest_target_type, "media_test") {
"base/decoder_buffer_cache_test.cc",
"bidirectional_fit_reuse_allocator_test.cc",
"file_data_source_test.cc",
"media_module_test.cc",
"progressive/demuxer_extension_wrapper_test.cc",
"progressive/mock_data_source_reader.h",
"progressive/mp4_map_unittest.cc",
Expand Down
15 changes: 0 additions & 15 deletions cobalt/media/media_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "base/synchronization/waitable_event.h"
#include "cobalt/media/base/format_support_query_metrics.h"
#include "starboard/common/string.h"
#include "starboard/extension/h5vcc_config.h"
#include "starboard/media.h"
#include "starboard/window.h"
#include "third_party/chromium/media/base/mime_util.h"
Expand Down Expand Up @@ -199,20 +198,6 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) {
LOG(INFO) << (value ? "Enabling" : "Disabling")
<< " media metrics collection.";
return true;
} else if (name == "BackgroundPlaybackEnabled") {
const StarboardExtensionH5vccConfigApi* h5vcc_config_api =
static_cast<const StarboardExtensionH5vccConfigApi*>(
SbSystemGetExtension(kStarboardExtensionH5vccConfigName));
if (h5vcc_config_api &&
strcmp(h5vcc_config_api->name, kStarboardExtensionH5vccConfigName) ==
0 &&
h5vcc_config_api->version >= 1) {
bool enable_background_playback = value;
LOG(INFO) << "Set BackgroundPlaybackEnabled to "
<< (enable_background_playback ? "enabled" : "disabled");
h5vcc_config_api->EnableBackgroundPlayback(enable_background_playback);
}
return true;
#if SB_API_VERSION >= 15
} else if (name == "AudioWriteDurationLocal" && value > 0) {
audio_write_duration_local_ = value;
Expand Down
29 changes: 0 additions & 29 deletions cobalt/media/media_module_test.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public void run() {
private static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getTimeZone("America/Los_Angeles");
private final long timeNanosecondsPerMicrosecond = 1000;

public static boolean enableBackgroundPlayback = false;

public StarboardBridge(
Context appContext,
Holder<Activity> activityHolder,
Expand Down Expand Up @@ -191,11 +189,6 @@ protected void onServiceDestroy(Service service) {
@SuppressWarnings("unused")
@UsedByNative
protected void startMediaPlaybackService() {
if (!enableBackgroundPlayback) {
Log.v(TAG, "Media Playback Service is disabled. Skip startMediaPlaybackService().");
return;
}

if (cobaltMediaSession == null || !cobaltMediaSession.isActive()) {
Log.w(TAG, "Do not start a MediaPlaybackService when the MediSsession is null or inactive.");
return;
Expand All @@ -215,18 +208,13 @@ protected void startMediaPlaybackService() {
} else {
appContext.startService(intent);
}
} catch (RuntimeException e) {
} catch (SecurityException e) {
Log.e(TAG, "Failed to start MediaPlaybackService with intent.", e);
return;
}
} else {
Log.i(TAG, "Warm start - Restarting the MediaPlaybackService.");
try {
((MediaPlaybackService) service).startService();
} catch (RuntimeException e) {
Log.e(TAG, "Failed to restart MediaPlaybackService.", e);
return;
}
((MediaPlaybackService) service).startService();
}
}

Expand All @@ -236,12 +224,7 @@ protected void stopMediaPlaybackService() {
Service service = serviceHolder.get();
if (service != null) {
Log.i(TAG, "Stopping the MediaPlaybackService.");
try {
((MediaPlaybackService) service).stopService();
} catch (RuntimeException e) {
Log.e(TAG, "Failed to stop MediaPlaybackService.", e);
return;
}
((MediaPlaybackService) service).stopService();
}
}

Expand Down Expand Up @@ -863,11 +846,4 @@ protected boolean getIsAmatiDevice() {
protected String getBuildFingerprint() {
return Build.FINGERPRINT;
}

@SuppressWarnings("unused")
@UsedByNative
protected void enableBackgroundPlayback(boolean value) {
enableBackgroundPlayback = value;
Log.v(TAG, "StarboardBridge set enableBackgroundPlayback: %b", value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import android.support.v4.media.session.PlaybackStateCompat;
import android.view.WindowManager;
import androidx.annotation.RequiresApi;
import dev.cobalt.coat.StarboardBridge;
import dev.cobalt.util.Holder;
import dev.cobalt.util.Log;

Expand Down Expand Up @@ -130,10 +129,6 @@ public CobaltMediaSession(
}

public boolean isActive() {
if (!StarboardBridge.enableBackgroundPlayback) {
return false;
}

if (this.mediaSession == null) {
return false;
} else {
Expand Down Expand Up @@ -259,9 +254,7 @@ private void configureMediaFocus(int playbackState, long positionMs, float speed
Log.i(TAG, "MediaSession already released");
return;
}
if (StarboardBridge.enableBackgroundPlayback) {
mediaSession.setActive(playbackState != PLAYBACK_STATE_NONE);
}
mediaSession.setActive(playbackState != PLAYBACK_STATE_NONE);
if (lifecycleCallback != null) {
lifecycleCallback.onMediaSessionLifecycle(
this.mediaSession.isActive(), this.mediaSession.getSessionToken());
Expand Down
2 changes: 0 additions & 2 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ static_library("starboard_platform") {
"get_home_directory.cc",
"graphics.cc",
"graphics.h",
"h5vcc_config.cc",
"h5vcc_config.h",
"input_events_generator.cc",
"input_events_generator.h",
"jni_env_ext.cc",
Expand Down
50 changes: 0 additions & 50 deletions starboard/android/shared/h5vcc_config.cc

This file was deleted.

28 changes: 0 additions & 28 deletions starboard/android/shared/h5vcc_config.h

This file was deleted.

5 changes: 0 additions & 5 deletions starboard/android/shared/system_get_extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "starboard/android/shared/android_media_session_client.h"
#include "starboard/android/shared/configuration.h"
#include "starboard/android/shared/graphics.h"
#include "starboard/android/shared/h5vcc_config.h"
#include "starboard/android/shared/platform_info.h"
#include "starboard/android/shared/platform_service.h"
#include "starboard/common/log.h"
Expand All @@ -31,7 +30,6 @@
#include "starboard/extension/configuration.h"
#include "starboard/extension/crash_handler.h"
#include "starboard/extension/graphics.h"
#include "starboard/extension/h5vcc_config.h"
#include "starboard/extension/media_session.h"
#include "starboard/extension/platform_info.h"
#include "starboard/extension/platform_service.h"
Expand Down Expand Up @@ -70,8 +68,5 @@ const void* SbSystemGetExtension(const char* name) {
if (strcmp(name, kCobaltExtensionPlatformInfoName) == 0) {
return starboard::android::shared::GetPlatformInfoApi();
}
if (strcmp(name, kStarboardExtensionH5vccConfigName) == 0) {
return starboard::android::shared::GetH5vccConfigApi();
}
return NULL;
}
21 changes: 0 additions & 21 deletions starboard/extension/extension_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "starboard/extension/font.h"
#include "starboard/extension/free_space.h"
#include "starboard/extension/graphics.h"
#include "starboard/extension/h5vcc_config.h"
#include "starboard/extension/ifa.h"
#include "starboard/extension/installation_manager.h"
#include "starboard/extension/javascript_cache.h"
Expand Down Expand Up @@ -482,25 +481,5 @@ TEST(ExtensionTest, Ifa) {
<< "Extension struct should be a singleton";
}

TEST(ExtensionTest, H5vccConfig) {
typedef StarboardExtensionH5vccConfigApi ExtensionApi;
const char* kExtensionName = kStarboardExtensionH5vccConfigName;

const ExtensionApi* extension_api =
static_cast<const ExtensionApi*>(SbSystemGetExtension(kExtensionName));
if (!extension_api) {
return;
}

EXPECT_STREQ(extension_api->name, kExtensionName);
EXPECT_EQ(extension_api->version, 1u);
EXPECT_NE(extension_api->EnableBackgroundPlayback, nullptr);

const ExtensionApi* second_extension_api =
static_cast<const ExtensionApi*>(SbSystemGetExtension(kExtensionName));
EXPECT_EQ(second_extension_api, extension_api)
<< "Extension struct should be a singleton";
}

} // namespace extension
} // namespace starboard
43 changes: 0 additions & 43 deletions starboard/extension/h5vcc_config.h

This file was deleted.

0 comments on commit 1f2d96b

Please sign in to comment.