Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / media / media_stream_audio_sink_owner.cc
blob04500499b6bd3625c70bf3a95986d03f619fdc4f
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
3 // found in the LICENSE file.
5 #include "content/renderer/media/media_stream_audio_sink_owner.h"
7 #include "content/public/renderer/media_stream_audio_sink.h"
8 #include "media/audio/audio_parameters.h"
10 namespace content {
12 MediaStreamAudioSinkOwner::MediaStreamAudioSinkOwner(MediaStreamAudioSink* sink)
13 : delegate_(sink) {
16 void MediaStreamAudioSinkOwner::OnData(const media::AudioBus& audio_bus,
17 base::TimeTicks estimated_capture_time) {
18 base::AutoLock lock(lock_);
19 if (delegate_)
20 delegate_->OnData(audio_bus, estimated_capture_time);
23 void MediaStreamAudioSinkOwner::OnSetFormat(
24 const media::AudioParameters& params) {
25 base::AutoLock lock(lock_);
26 if (delegate_)
27 delegate_->OnSetFormat(params);
30 void MediaStreamAudioSinkOwner::OnReadyStateChanged(
31 blink::WebMediaStreamSource::ReadyState state) {
32 base::AutoLock lock(lock_);
33 if (delegate_)
34 delegate_->OnReadyStateChanged(state);
37 void MediaStreamAudioSinkOwner::Reset() {
38 base::AutoLock lock(lock_);
39 delegate_ = NULL;
42 bool MediaStreamAudioSinkOwner::IsEqual(
43 const MediaStreamAudioSink* other) const {
44 DCHECK(other);
45 base::AutoLock lock(lock_);
46 return (other == delegate_);
49 } // namespace content