| 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/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DVLOG(1) << "StartWaitingForSeek()"; | 182 DVLOG(1) << "StartWaitingForSeek()"; |
| 183 ReadCBQueue read_cbs; | 183 ReadCBQueue read_cbs; |
| 184 { | 184 { |
| 185 base::AutoLock auto_lock(lock_); | 185 base::AutoLock auto_lock(lock_); |
| 186 ChangeState_Locked(WAITING_FOR_SEEK); | 186 ChangeState_Locked(WAITING_FOR_SEEK); |
| 187 | 187 |
| 188 std::swap(read_cbs_, read_cbs); | 188 std::swap(read_cbs_, read_cbs); |
| 189 } | 189 } |
| 190 | 190 |
| 191 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) | 191 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) |
| 192 it->Run(scoped_refptr<Buffer>()); | 192 it->Run(NULL); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void ChunkDemuxerStream::Seek(base::TimeDelta time) { | 195 void ChunkDemuxerStream::Seek(base::TimeDelta time) { |
| 196 base::AutoLock auto_lock(lock_); | 196 base::AutoLock auto_lock(lock_); |
| 197 | 197 |
| 198 DCHECK(read_cbs_.empty()); | 198 DCHECK(read_cbs_.empty()); |
| 199 | 199 |
| 200 if (state_ == WAITING_FOR_SEEK) | 200 if (state_ == WAITING_FOR_SEEK) |
| 201 ChangeState_Locked(RETURNING_DATA_FOR_READS); | 201 ChangeState_Locked(RETURNING_DATA_FOR_READS); |
| 202 } | 202 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 224 | 224 |
| 225 // Pass end of stream buffers to all callbacks to signal that no more data | 225 // Pass end of stream buffers to all callbacks to signal that no more data |
| 226 // will be sent. | 226 // will be sent. |
| 227 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) | 227 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) |
| 228 it->Run(StreamParserBuffer::CreateEOSBuffer()); | 228 it->Run(StreamParserBuffer::CreateEOSBuffer()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 // Helper function that makes sure |read_cb| runs on |message_loop|. | 231 // Helper function that makes sure |read_cb| runs on |message_loop|. |
| 232 static void RunOnMessageLoop(const DemuxerStream::ReadCB& read_cb, | 232 static void RunOnMessageLoop(const DemuxerStream::ReadCB& read_cb, |
| 233 MessageLoop* message_loop, | 233 MessageLoop* message_loop, |
| 234 const scoped_refptr<Buffer>& buffer) { | 234 const scoped_refptr<DecoderBuffer>& buffer) { |
| 235 if (MessageLoop::current() != message_loop) { | 235 if (MessageLoop::current() != message_loop) { |
| 236 message_loop->PostTask(FROM_HERE, base::Bind( | 236 message_loop->PostTask(FROM_HERE, base::Bind( |
| 237 &RunOnMessageLoop, read_cb, message_loop, buffer)); | 237 &RunOnMessageLoop, read_cb, message_loop, buffer)); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 read_cb.Run(buffer); | 241 read_cb.Run(buffer); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // DemuxerStream methods. | 244 // DemuxerStream methods. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 return true; | 769 return true; |
| 770 } | 770 } |
| 771 | 771 |
| 772 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data, | 772 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data, |
| 773 int init_data_size) { | 773 int init_data_size) { |
| 774 client_->KeyNeeded(init_data.Pass(), init_data_size); | 774 client_->KeyNeeded(init_data.Pass(), init_data_size); |
| 775 return true; | 775 return true; |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace media | 778 } // namespace media |
| OLD | NEW |