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

Unified Diff: media/filters/audio_renderer_base.cc

Issue 113611: Handle end of stream for media... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/audio_renderer_base.cc
===================================================================
--- media/filters/audio_renderer_base.cc (revision 17564)
+++ media/filters/audio_renderer_base.cc (working copy)
@@ -71,22 +71,30 @@
bool initialization_complete = false;
{
AutoLock auto_lock(lock_);
- if (!stopped_) {
+ // If we have stopped don't enqueue, same for end of stream buffer since
+ // it has no data.
+ if (!stopped_ && !buffer_in->IsEndOfStream()) {
queue_.push_back(buffer_in);
DCHECK(queue_.size() <= max_queue_size_);
}
- // See if we're finally initialized.
- // TODO(scherkus): handle end of stream cases where we'll never reach max
- // queue size.
- if (!initialized_ && queue_.size() == max_queue_size_) {
- initialization_complete = true;
+ if (!initialized_) {
+ // We have completed the initialization when we preroll enough and hit
+ // the target queue size or the stream has ended.
+ if (queue_.size() == max_queue_size_ || buffer_in->IsEndOfStream())
+ initialization_complete = true;
}
}
if (initialization_complete) {
- initialized_ = true;
- host_->InitializationComplete();
+ if (queue_.empty()) {
+ // If we say we have initialized but buffer queue is empty, raise an
+ // error.
+ host_->Error(PIPELINE_ERROR_NO_DATA);
+ } else {
+ initialized_ = true;
+ host_->InitializationComplete();
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698