| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/media/media_stream_audio_source.h" | 5 #include "content/renderer/media/media_stream_audio_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "content/renderer/media/media_stream_audio_track.h" | 10 #include "content/renderer/media/media_stream_audio_track.h" |
| 9 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 11 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 | 15 |
| 14 MediaStreamAudioSource::MediaStreamAudioSource(bool is_local_source) | 16 MediaStreamAudioSource::MediaStreamAudioSource(bool is_local_source) |
| 15 : is_local_source_(is_local_source), | 17 : is_local_source_(is_local_source), |
| 16 is_stopped_(false), | 18 is_stopped_(false), |
| 19 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 17 weak_factory_(this) { | 20 weak_factory_(this) { |
| 18 DVLOG(1) << "MediaStreamAudioSource@" << this << "::MediaStreamAudioSource(" | 21 DVLOG(1) << "MediaStreamAudioSource@" << this << "::MediaStreamAudioSource(" |
| 19 << (is_local_source_ ? "local" : "remote") << " source)"; | 22 << (is_local_source_ ? "local" : "remote") << " source)"; |
| 20 } | 23 } |
| 21 | 24 |
| 22 MediaStreamAudioSource::~MediaStreamAudioSource() { | 25 MediaStreamAudioSource::~MediaStreamAudioSource() { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); | 26 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 DVLOG(1) << "MediaStreamAudioSource@" << this << " is being destroyed."; | 27 DVLOG(1) << "MediaStreamAudioSource@" << this << " is being destroyed."; |
| 25 } | 28 } |
| 26 | 29 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 const bool did_remove_last_track = deliverer_.RemoveConsumer(track); | 132 const bool did_remove_last_track = deliverer_.RemoveConsumer(track); |
| 130 DVLOG(1) << "Removed MediaStreamAudioTrack@" << track | 133 DVLOG(1) << "Removed MediaStreamAudioTrack@" << track |
| 131 << " as a consumer of MediaStreamAudioSource@" << this << '.'; | 134 << " as a consumer of MediaStreamAudioSource@" << this << '.'; |
| 132 | 135 |
| 133 // The W3C spec requires a source automatically stop when the last track is | 136 // The W3C spec requires a source automatically stop when the last track is |
| 134 // stopped. | 137 // stopped. |
| 135 if (!is_stopped_ && did_remove_last_track) | 138 if (!is_stopped_ && did_remove_last_track) |
| 136 MediaStreamSource::StopSource(); | 139 MediaStreamSource::StopSource(); |
| 137 } | 140 } |
| 138 | 141 |
| 142 void MediaStreamAudioSource::OnAudioCaptureError(const std::string& why) { |
| 143 VLOG(1) << why; |
| 144 |
| 145 // Stop source when error occurs. |
| 146 task_runner_->PostTask( |
| 147 FROM_HERE, base::Bind(&MediaStreamSource::StopSource, GetWeakPtr())); |
| 148 } |
| 149 |
| 139 } // namespace content | 150 } // namespace content |
| OLD | NEW |