Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[media] Add SingleThreadTaskExecutor to web_media_player_sandbox #4309

Draft
wants to merge 1 commit into
base: 25.lts.1+
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cobalt/media/sandbox/format_guesstimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ std::string ExtractCodecs(const std::string& content_type) {
} // namespace

FormatGuesstimator::FormatGuesstimator(const std::string& path_or_url,
MediaModule* media_module) {
MediaModule* media_module)
: task_runner_(base::SequencedTaskRunner::GetCurrentDefault()) {
DCHECK(task_runner_);
GURL url(path_or_url);
if (url.is_valid()) {
// If it is a url, assume that it is a progressive video.
Expand Down Expand Up @@ -189,7 +191,7 @@ void FormatGuesstimator::InitializeAsAdaptive(const base::FilePath& path,
// during initialization of |web_media_player_helper|. Wait until it is set
// before proceeding.
while (!chunk_demuxer) {
base::RunLoop().RunUntilIdle();
task_runner_->RunsTasksInCurrentSequence();
}

const std::string id = "stream";
Expand Down
2 changes: 2 additions & 0 deletions cobalt/media/sandbox/format_guesstimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/task/sequenced_task_runner.h"
#include "cobalt/media/media_module.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -66,6 +67,7 @@ class FormatGuesstimator {
GURL progressive_url_;
base::FilePath adaptive_path_;
std::string mime_type_;
base::SequencedTaskRunner* task_runner_;
};

} // namespace sandbox
Expand Down
7 changes: 6 additions & 1 deletion cobalt/media/sandbox/web_media_player_sandbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_executor.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "cobalt/base/wrap_main.h"
Expand Down Expand Up @@ -113,6 +113,9 @@ class Application {
media_sandbox_(argc, argv,
base::FilePath(FILE_PATH_LITERAL(
"media_source_sandbox_trace.json"))) {
base::SingleThreadTaskExecutor task_executor(base::MessagePumpType::UI);
base::RunLoop run_loop;
run_loop.BeforeRun();
if (argc > 1) {
FormatGuesstimator guesstimator1(argv[argc - 1],
media_sandbox_.GetMediaModule());
Expand Down Expand Up @@ -147,6 +150,8 @@ class Application {
}
}

run_loop.AfterRun();
run_loop.Quit();
PrintUsage(argv[0]);
SbSystemRequestStop(0);
}
Expand Down
Loading