summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/utility/media_galleries/ipc_data_source.cc3
-rw-r--r--chrome/utility/media_galleries/ipc_data_source.h2
-rw-r--r--content/renderer/media/buffered_data_source.cc3
-rw-r--r--content/renderer/media/buffered_data_source.h2
-rw-r--r--content/renderer/media/buffered_data_source_unittest.cc29
-rw-r--r--media/base/data_source.h2
-rw-r--r--media/filters/blocking_url_protocol_unittest.cc5
-rw-r--r--media/filters/ffmpeg_demuxer.cc36
-rw-r--r--media/filters/ffmpeg_demuxer.h3
-rw-r--r--media/filters/file_data_source.cc3
-rw-r--r--media/filters/file_data_source.h2
-rw-r--r--media/filters/file_data_source_unittest.cc2
-rw-r--r--media/tools/player_x11/data_source_logger.cc11
-rw-r--r--media/tools/player_x11/data_source_logger.h2
14 files changed, 30 insertions, 75 deletions
diff --git a/chrome/utility/media_galleries/ipc_data_source.cc b/chrome/utility/media_galleries/ipc_data_source.cc
index c44670a..c65a898 100644
--- a/chrome/utility/media_galleries/ipc_data_source.cc
+++ b/chrome/utility/media_galleries/ipc_data_source.cc
@@ -21,9 +21,8 @@ IPCDataSource::~IPCDataSource() {
DCHECK(utility_thread_checker_.CalledOnValidThread());
}
-void IPCDataSource::Stop(const base::Closure& callback) {
+void IPCDataSource::Stop() {
DCHECK(data_source_thread_checker_.CalledOnValidThread());
- callback.Run();
}
void IPCDataSource::Read(int64 position, int size, uint8* data,
diff --git a/chrome/utility/media_galleries/ipc_data_source.h b/chrome/utility/media_galleries/ipc_data_source.h
index c65c457..6fb3b76 100644
--- a/chrome/utility/media_galleries/ipc_data_source.h
+++ b/chrome/utility/media_galleries/ipc_data_source.h
@@ -32,7 +32,7 @@ class IPCDataSource: public media::DataSource,
// Implementation of DataSource. These methods may be called on any single
// thread. First usage of these methods attaches a thread checker.
- virtual void Stop(const base::Closure& callback) OVERRIDE;
+ virtual void Stop() OVERRIDE;
virtual void Read(int64 position, int size, uint8* data,
const ReadCB& read_cb) OVERRIDE;
virtual bool GetSize(int64* size_out) OVERRIDE;
diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc
index f4a3094..e05ec43 100644
--- a/content/renderer/media/buffered_data_source.cc
+++ b/content/renderer/media/buffered_data_source.cc
@@ -207,12 +207,11 @@ void BufferedDataSource::MediaIsPaused() {
/////////////////////////////////////////////////////////////////////////////
// media::DataSource implementation.
-void BufferedDataSource::Stop(const base::Closure& closure) {
+void BufferedDataSource::Stop() {
{
base::AutoLock auto_lock(lock_);
StopInternal_Locked();
}
- closure.Run();
render_loop_->PostTask(
FROM_HERE,
diff --git a/content/renderer/media/buffered_data_source.h b/content/renderer/media/buffered_data_source.h
index de44e3c..9a4db0f 100644
--- a/content/renderer/media/buffered_data_source.h
+++ b/content/renderer/media/buffered_data_source.h
@@ -98,7 +98,7 @@ class CONTENT_EXPORT BufferedDataSource : public media::DataSource {
// media::DataSource implementation.
// Called from demuxer thread.
- virtual void Stop(const base::Closure& closure) OVERRIDE;
+ virtual void Stop() OVERRIDE;
virtual void Read(int64 position, int size, uint8* data,
const media::DataSource::ReadCB& read_cb) OVERRIDE;
diff --git a/content/renderer/media/buffered_data_source_unittest.cc b/content/renderer/media/buffered_data_source_unittest.cc
index 403a93b..73f8c3f 100644
--- a/content/renderer/media/buffered_data_source_unittest.cc
+++ b/content/renderer/media/buffered_data_source_unittest.cc
@@ -178,7 +178,7 @@ class BufferedDataSourceTest : public testing::Test {
message_loop_.RunUntilIdle();
}
- data_source_->Stop(media::NewExpectedClosure());
+ data_source_->Stop();
message_loop_.RunUntilIdle();
}
@@ -505,31 +505,6 @@ TEST_F(BufferedDataSourceTest, File_Successful) {
Stop();
}
-static void SetTrue(bool* value) {
- *value = true;
-}
-
-// This test makes sure that Stop() does not require a task to run on
-// |message_loop_| before it calls its callback. This prevents accidental
-// introduction of a pipeline teardown deadlock. The pipeline owner blocks
-// the render message loop while waiting for Stop() to complete. Since this
-// object runs on the render message loop, Stop() will not complete if it
-// requires a task to run on the the message loop that is being blocked.
-TEST_F(BufferedDataSourceTest, StopDoesNotUseMessageLoopForCallback) {
- InitializeWith206Response();
-
- // Stop() the data source, using a callback that lets us verify that it was
- // called before Stop() returns. This is to make sure that the callback does
- // not require |message_loop_| to execute tasks before being called.
- bool stop_done_called = false;
- EXPECT_TRUE(data_source_->loading());
- data_source_->Stop(base::Bind(&SetTrue, &stop_done_called));
-
- // Verify that the callback was called inside the Stop() call.
- EXPECT_TRUE(stop_done_called);
- message_loop_.RunUntilIdle();
-}
-
TEST_F(BufferedDataSourceTest, StopDuringRead) {
InitializeWith206Response();
@@ -541,7 +516,7 @@ TEST_F(BufferedDataSourceTest, StopDuringRead) {
{
InSequence s;
EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
- data_source_->Stop(media::NewExpectedClosure());
+ data_source_->Stop();
}
message_loop_.RunUntilIdle();
}
diff --git a/media/base/data_source.h b/media/base/data_source.h
index dca1dd3..e0b7373 100644
--- a/media/base/data_source.h
+++ b/media/base/data_source.h
@@ -28,7 +28,7 @@ class MEDIA_EXPORT DataSource {
// Stops the DataSource. Once this is called all future Read() calls will
// return an error.
- virtual void Stop(const base::Closure& callback) = 0;
+ virtual void Stop() = 0;
// Returns true and the file size, false if the file size could not be
// retrieved.
diff --git a/media/filters/blocking_url_protocol_unittest.cc b/media/filters/blocking_url_protocol_unittest.cc
index d8d1dfc3..ec55a00 100644
--- a/media/filters/blocking_url_protocol_unittest.cc
+++ b/media/filters/blocking_url_protocol_unittest.cc
@@ -24,10 +24,7 @@ class BlockingUrlProtocolTest : public testing::Test {
}
virtual ~BlockingUrlProtocolTest() {
- base::WaitableEvent stop_event(false, false);
- data_source_.Stop(base::Bind(
- &base::WaitableEvent::Signal, base::Unretained(&stop_event)));
- stop_event.Wait();
+ data_source_.Stop();
}
MOCK_METHOD0(OnDataSourceError, void());
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 3ff8c3c..15b6a51 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -558,11 +558,22 @@ FFmpegDemuxer::~FFmpegDemuxer() {}
void FFmpegDemuxer::Stop(const base::Closure& callback) {
DCHECK(task_runner_->BelongsToCurrentThread());
url_protocol_->Abort();
- data_source_->Stop(
- BindToCurrentLoop(base::Bind(&FFmpegDemuxer::OnDataSourceStopped,
- weak_factory_.GetWeakPtr(),
- BindToCurrentLoop(callback))));
+ data_source_->Stop();
+
+ // This will block until all tasks complete. Note that after this returns it's
+ // possible for reply tasks (e.g., OnReadFrameDone()) to be queued on this
+ // thread. Each of the reply task methods must check whether we've stopped the
+ // thread and drop their results on the floor.
+ blocking_thread_.Stop();
+
+ StreamVector::iterator iter;
+ for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
+ if (*iter)
+ (*iter)->Stop();
+ }
+
data_source_ = NULL;
+ task_runner_->PostTask(FROM_HERE, callback);
}
void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
@@ -1148,23 +1159,6 @@ void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) {
ReadFrameIfNeeded();
}
-void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) {
- // This will block until all tasks complete. Note that after this returns it's
- // possible for reply tasks (e.g., OnReadFrameDone()) to be queued on this
- // thread. Each of the reply task methods must check whether we've stopped the
- // thread and drop their results on the floor.
- DCHECK(task_runner_->BelongsToCurrentThread());
- blocking_thread_.Stop();
-
- StreamVector::iterator iter;
- for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
- if (*iter)
- (*iter)->Stop();
- }
-
- callback.Run();
-}
-
bool FFmpegDemuxer::StreamsHaveAvailableCapacity() {
DCHECK(task_runner_->BelongsToCurrentThread());
StreamVector::iterator iter;
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h
index 14351c6..1ec8cfe 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -198,9 +198,6 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
void ReadFrameIfNeeded();
void OnReadFrameDone(ScopedAVPacket packet, int result);
- // DataSource callbacks during stopping.
- void OnDataSourceStopped(const base::Closure& callback);
-
// Returns true iff any stream has additional capacity. Note that streams can
// go over capacity depending on how the file is muxed.
bool StreamsHaveAvailableCapacity();
diff --git a/media/filters/file_data_source.cc b/media/filters/file_data_source.cc
index e8b3292..5aad3f9 100644
--- a/media/filters/file_data_source.cc
+++ b/media/filters/file_data_source.cc
@@ -26,8 +26,7 @@ bool FileDataSource::Initialize(const base::FilePath& file_path) {
return file_.Initialize(file_path);
}
-void FileDataSource::Stop(const base::Closure& callback) {
- callback.Run();
+void FileDataSource::Stop() {
}
void FileDataSource::Read(int64 position, int size, uint8* data,
diff --git a/media/filters/file_data_source.h b/media/filters/file_data_source.h
index 739bc2e..78884ea 100644
--- a/media/filters/file_data_source.h
+++ b/media/filters/file_data_source.h
@@ -25,7 +25,7 @@ class MEDIA_EXPORT FileDataSource : public DataSource {
bool Initialize(const base::FilePath& file_path);
// Implementation of DataSource.
- virtual void Stop(const base::Closure& callback) OVERRIDE;
+ virtual void Stop() OVERRIDE;
virtual void Read(int64 position, int size, uint8* data,
const DataSource::ReadCB& read_cb) OVERRIDE;
virtual bool GetSize(int64* size_out) OVERRIDE;
diff --git a/media/filters/file_data_source_unittest.cc b/media/filters/file_data_source_unittest.cc
index 5eb94ca..0d57ae7 100644
--- a/media/filters/file_data_source_unittest.cc
+++ b/media/filters/file_data_source_unittest.cc
@@ -77,7 +77,7 @@ TEST(FileDataSourceTest, ReadData) {
&ReadCBHandler::ReadCB, base::Unretained(&handler)));
EXPECT_EQ('5', ten_bytes[0]);
- data_source.Stop(NewExpectedClosure());
+ data_source.Stop();
}
} // namespace media
diff --git a/media/tools/player_x11/data_source_logger.cc b/media/tools/player_x11/data_source_logger.cc
index 204d8b3..d09b6bf 100644
--- a/media/tools/player_x11/data_source_logger.cc
+++ b/media/tools/player_x11/data_source_logger.cc
@@ -6,11 +6,6 @@
#include "base/logging.h"
#include "media/tools/player_x11/data_source_logger.h"
-static void LogAndRunStopClosure(const base::Closure& closure) {
- VLOG(1) << "Stop() finished";
- closure.Run();
-}
-
static void LogAndRunReadCB(
int64 position, int size,
const media::DataSource::ReadCB& read_cb, int result) {
@@ -25,9 +20,9 @@ DataSourceLogger::DataSourceLogger(
streaming_(streaming) {
}
-void DataSourceLogger::Stop(const base::Closure& closure) {
- VLOG(1) << "Stop() started";
- data_source_->Stop(base::Bind(&LogAndRunStopClosure, closure));
+void DataSourceLogger::Stop() {
+ VLOG(1) << "Stop()";
+ data_source_->Stop();
}
void DataSourceLogger::Read(
diff --git a/media/tools/player_x11/data_source_logger.h b/media/tools/player_x11/data_source_logger.h
index 5fdd9d4..1cb0a80 100644
--- a/media/tools/player_x11/data_source_logger.h
+++ b/media/tools/player_x11/data_source_logger.h
@@ -22,7 +22,7 @@ class DataSourceLogger : public media::DataSource {
virtual ~DataSourceLogger();
// media::DataSource implementation.
- virtual void Stop(const base::Closure& closure) OVERRIDE;
+ virtual void Stop() OVERRIDE;
virtual void Read(
int64 position, int size, uint8* data,
const media::DataSource::ReadCB& read_cb) OVERRIDE;