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

Unified Diff: content/renderer/media/local_media_stream_audio_source.cc

Issue 2416123002: Stop media stream source when audio capture error occurs. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « content/renderer/media/local_media_stream_audio_source.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/local_media_stream_audio_source.cc
diff --git a/content/renderer/media/local_media_stream_audio_source.cc b/content/renderer/media/local_media_stream_audio_source.cc
index f2075b97723c950424a5c49de547843d276ac3c5..78ea116288c5f92b2de25cc30fb561361d196e0f 100644
--- a/content/renderer/media/local_media_stream_audio_source.cc
+++ b/content/renderer/media/local_media_stream_audio_source.cc
@@ -4,6 +4,8 @@
#include "content/renderer/media/local_media_stream_audio_source.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
#include "content/common/media/media_stream_options.h"
#include "content/renderer/media/audio_device_factory.h"
#include "content/renderer/render_frame_impl.h"
@@ -14,7 +16,8 @@ LocalMediaStreamAudioSource::LocalMediaStreamAudioSource(
int consumer_render_frame_id,
const StreamDeviceInfo& device_info)
: MediaStreamAudioSource(true /* is_local_source */),
- consumer_render_frame_id_(consumer_render_frame_id) {
+ consumer_render_frame_id_(consumer_render_frame_id),
+ task_runner_(base::ThreadTaskRunnerHandle::Get()) {
DVLOG(1) << "LocalMediaStreamAudioSource::LocalMediaStreamAudioSource()";
MediaStreamSource::SetDeviceInfo(device_info);
@@ -99,10 +102,11 @@ void LocalMediaStreamAudioSource::Capture(const media::AudioBus* audio_bus,
}
void LocalMediaStreamAudioSource::OnCaptureError(const std::string& why) {
- // As of this writing, this method doesn't get called for anything useful,
- // and all other implementors just log the message, but don't disconnect sinks
- // or take any other action. So, just log the error.
- LOG(ERROR) << why;
+ VLOG(1) << why;
+
+ // Stop source when error occurs.
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&MediaStreamSource::StopSource, AsWeakPtr()));
miu 2016/10/14 05:38:26 Why do we need the task runner? Isn't OnCaptureErr
xjz 2016/10/14 17:32:53 When tab is closed, this is called on io thread, n
}
} // namespace content
« no previous file with comments | « content/renderer/media/local_media_stream_audio_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698