| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/blocking_url_protocol.h" | 5 #include "media/filters/blocking_url_protocol.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "media/base/data_source.h" | 11 #include "media/base/data_source.h" |
| 12 #include "media/ffmpeg/ffmpeg_common.h" | 12 #include "media/ffmpeg/ffmpeg_common.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 BlockingUrlProtocol::BlockingUrlProtocol( | 16 BlockingUrlProtocol::BlockingUrlProtocol(DataSource* data_source, |
| 17 DataSource* data_source, | 17 const base::Closure& error_cb) |
| 18 const base::Closure& error_cb) | |
| 19 : data_source_(data_source), | 18 : data_source_(data_source), |
| 20 error_cb_(error_cb), | 19 error_cb_(error_cb), |
| 21 aborted_(true, false), // We never want to reset |aborted_|. | 20 aborted_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 22 read_complete_(false, false), | 21 base::WaitableEvent::InitialState::NOT_SIGNALED), // We never |
| 22 // want to |
| 23 // reset |
| 24 // |aborted_|. |
| 25 read_complete_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 26 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 23 last_read_bytes_(0), | 27 last_read_bytes_(0), |
| 24 read_position_(0) { | 28 read_position_(0) {} |
| 25 } | |
| 26 | 29 |
| 27 BlockingUrlProtocol::~BlockingUrlProtocol() {} | 30 BlockingUrlProtocol::~BlockingUrlProtocol() {} |
| 28 | 31 |
| 29 void BlockingUrlProtocol::Abort() { | 32 void BlockingUrlProtocol::Abort() { |
| 30 aborted_.Signal(); | 33 aborted_.Signal(); |
| 31 } | 34 } |
| 32 | 35 |
| 33 int BlockingUrlProtocol::Read(int size, uint8_t* data) { | 36 int BlockingUrlProtocol::Read(int size, uint8_t* data) { |
| 34 // Read errors are unrecoverable. | 37 // Read errors are unrecoverable. |
| 35 if (aborted_.IsSignaled()) | 38 if (aborted_.IsSignaled()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 bool BlockingUrlProtocol::IsStreaming() { | 89 bool BlockingUrlProtocol::IsStreaming() { |
| 87 return data_source_->IsStreaming(); | 90 return data_source_->IsStreaming(); |
| 88 } | 91 } |
| 89 | 92 |
| 90 void BlockingUrlProtocol::SignalReadCompleted(int size) { | 93 void BlockingUrlProtocol::SignalReadCompleted(int size) { |
| 91 last_read_bytes_ = size; | 94 last_read_bytes_ = size; |
| 92 read_complete_.Signal(); | 95 read_complete_.Signal(); |
| 93 } | 96 } |
| 94 | 97 |
| 95 } // namespace media | 98 } // namespace media |
| OLD | NEW |