Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Unified Diff: media/filters/blocking_url_protocol.h

Issue 2710133003: Replace FFmpegDemuxer thread per element with base::TaskScheduler. (Closed)
Patch Set: Give WeakPtr to URLProtocol. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/blocking_url_protocol.h
diff --git a/media/filters/blocking_url_protocol.h b/media/filters/blocking_url_protocol.h
index 4f9ef4f3507490cf957186a8c937db5da498d42f..7e6a1eb4f314c61d2bee23eb9c2db117d8d0e386 100644
--- a/media/filters/blocking_url_protocol.h
+++ b/media/filters/blocking_url_protocol.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "media/filters/ffmpeg_glue.h"
@@ -17,19 +18,19 @@ namespace media {
class DataSource;
// An implementation of FFmpegURLProtocol that blocks until the underlying
-// asynchronous DataSource::Read() operation completes.
+// asynchronous DataSource::Read() operation completes. Generally constructed on
+// the media thread and used by ffmpeg through the AVIO interface from a
+// sequenced blocking pool.
class MEDIA_EXPORT BlockingUrlProtocol : public FFmpegURLProtocol {
public:
// Implements FFmpegURLProtocol using the given |data_source|. |error_cb| is
// fired any time DataSource::Read() returns an error.
- //
- // TODO(scherkus): After all blocking operations are isolated on a separate
- // thread we should be able to eliminate |error_cb|.
BlockingUrlProtocol(DataSource* data_source, const base::Closure& error_cb);
virtual ~BlockingUrlProtocol();
// Aborts any pending reads by returning a read error. After this method
- // returns all subsequent calls to Read() will immediately fail.
+ // returns all subsequent calls to Read() will immediately fail. May be called
+ // from any thread and upon return ensures no further use of |data_source_|.
void Abort();
// FFmpegURLProtocol implementation.
@@ -44,8 +45,14 @@ class MEDIA_EXPORT BlockingUrlProtocol : public FFmpegURLProtocol {
// has completed.
void SignalReadCompleted(int size);
+ // |data_source_lock_| allows Abort() to be called from any thread and stop
+ // all outstanding access to |data_source_|. Typically Abort() is called from
+ // the media thread while ffmpeg is operating on another thread.
+ base::Lock data_source_lock_;
DataSource* data_source_;
+
base::Closure error_cb_;
+ const bool is_streaming_;
// Used to unblock the thread during shutdown and when reads complete.
base::WaitableEvent aborted_;

Powered by Google App Engine
This is Rietveld 408576698