| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/text_renderer.h" | 5 #include "media/base/text_renderer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 if (pending_read_count_ == 0) { | 286 if (pending_read_count_ == 0) { |
| 287 DCHECK_EQ(state_, kPausePending) << "state_ " << state_; | 287 DCHECK_EQ(state_, kPausePending) << "state_ " << state_; |
| 288 state_ = kPaused; | 288 state_ = kPaused; |
| 289 base::ResetAndReturn(&pause_cb_).Run(); | 289 base::ResetAndReturn(&pause_cb_).Run(); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 void TextRenderer::OnAddTextTrackDone(DemuxerStream* text_stream, | 293 void TextRenderer::OnAddTextTrackDone(DemuxerStream* text_stream, |
| 294 scoped_ptr<TextTrack> text_track) { | 294 std::unique_ptr<TextTrack> text_track) { |
| 295 DCHECK(task_runner_->BelongsToCurrentThread()); | 295 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 296 DCHECK_NE(state_, kUninitialized); | 296 DCHECK_NE(state_, kUninitialized); |
| 297 DCHECK(text_stream); | 297 DCHECK(text_stream); |
| 298 DCHECK(text_track); | 298 DCHECK(text_track); |
| 299 | 299 |
| 300 scoped_ptr<TextTrackState> state(new TextTrackState(std::move(text_track))); | 300 std::unique_ptr<TextTrackState> state( |
| 301 new TextTrackState(std::move(text_track))); |
| 301 text_track_state_map_[text_stream] = state.release(); | 302 text_track_state_map_[text_stream] = state.release(); |
| 302 pending_eos_set_.insert(text_stream); | 303 pending_eos_set_.insert(text_stream); |
| 303 | 304 |
| 304 if (state_ == kPlaying) | 305 if (state_ == kPlaying) |
| 305 Read(text_track_state_map_[text_stream], text_stream); | 306 Read(text_track_state_map_[text_stream], text_stream); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void TextRenderer::Read( | 309 void TextRenderer::Read( |
| 309 TextTrackState* state, | 310 TextTrackState* state, |
| 310 DemuxerStream* text_stream) { | 311 DemuxerStream* text_stream) { |
| 311 DCHECK_NE(state->read_state, TextTrackState::kReadPending); | 312 DCHECK_NE(state->read_state, TextTrackState::kReadPending); |
| 312 | 313 |
| 313 state->read_state = TextTrackState::kReadPending; | 314 state->read_state = TextTrackState::kReadPending; |
| 314 ++pending_read_count_; | 315 ++pending_read_count_; |
| 315 | 316 |
| 316 text_stream->Read(base::Bind( | 317 text_stream->Read(base::Bind( |
| 317 &TextRenderer::BufferReady, weak_factory_.GetWeakPtr(), text_stream)); | 318 &TextRenderer::BufferReady, weak_factory_.GetWeakPtr(), text_stream)); |
| 318 } | 319 } |
| 319 | 320 |
| 320 TextRenderer::TextTrackState::TextTrackState(scoped_ptr<TextTrack> tt) | 321 TextRenderer::TextTrackState::TextTrackState(std::unique_ptr<TextTrack> tt) |
| 321 : read_state(kReadIdle), text_track(std::move(tt)) {} | 322 : read_state(kReadIdle), text_track(std::move(tt)) {} |
| 322 | 323 |
| 323 TextRenderer::TextTrackState::~TextTrackState() { | 324 TextRenderer::TextTrackState::~TextTrackState() { |
| 324 } | 325 } |
| 325 | 326 |
| 326 } // namespace media | 327 } // namespace media |
| OLD | NEW |