Skip to content

Commit

Permalink
[media] Add SingleThreadTaskExecutor to web_media_player_sandbox
Browse files Browse the repository at this point in the history
b/350582446
  • Loading branch information
osagie98 committed Oct 24, 2024
1 parent 1e7bfb9 commit 5e99757
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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

0 comments on commit 5e99757

Please sign in to comment.