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

Unified Diff: remoting/protocol/webrtc_audio_sink_adapter.cc

Issue 2653563004: Revert 25680c62320767f590d037d301edfe15e9c55650 (Closed)
Patch Set: . Created 3 years, 11 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 | « remoting/protocol/webrtc_audio_sink_adapter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_audio_sink_adapter.cc
diff --git a/remoting/protocol/webrtc_audio_sink_adapter.cc b/remoting/protocol/webrtc_audio_sink_adapter.cc
index 651d4eec82ab2d5a624337b28ca3507584cd2727..5e2da715ad11d8dd500ef5806365400d430555a9 100644
--- a/remoting/protocol/webrtc_audio_sink_adapter.cc
+++ b/remoting/protocol/webrtc_audio_sink_adapter.cc
@@ -4,7 +4,6 @@
#include "remoting/protocol/webrtc_audio_sink_adapter.h"
-#include "base/bind.h"
#include "base/callback.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/protocol/audio_stub.h"
@@ -14,17 +13,20 @@ namespace protocol {
WebrtcAudioSinkAdapter::WebrtcAudioSinkAdapter(
scoped_refptr<webrtc::MediaStreamInterface> stream,
- base::WeakPtr<AudioStub> audio_stub)
- : task_runner_(base::ThreadTaskRunnerHandle::Get()),
- audio_stub_(audio_stub),
- media_stream_(std::move(stream)) {
+ base::WeakPtr<AudioStub> audio_stub) {
+ audio_stub_ = audio_stub;
+
+ media_stream_ = std::move(stream);
+
webrtc::AudioTrackVector audio_tracks = media_stream_->GetAudioTracks();
// Caller must verify that the media stream contains audio tracks.
DCHECK(!audio_tracks.empty());
+
if (audio_tracks.size() > 1U) {
LOG(WARNING) << "Received media stream with multiple audio tracks.";
}
+
audio_track_ = audio_tracks[0];
audio_track_->GetSource()->AddSink(this);
}
@@ -38,6 +40,9 @@ void WebrtcAudioSinkAdapter::OnData(const void* audio_data,
int sample_rate,
size_t number_of_channels,
size_t number_of_frames) {
+ if (!audio_stub_)
+ return;
+
std::unique_ptr<AudioPacket> audio_packet(new AudioPacket());
audio_packet->set_encoding(AudioPacket::ENCODING_RAW);
@@ -68,10 +73,7 @@ void WebrtcAudioSinkAdapter::OnData(const void* audio_data,
size_t data_size =
number_of_frames * number_of_channels * (bits_per_sample / 8);
audio_packet->add_data(reinterpret_cast<const char*>(audio_data), data_size);
-
- task_runner_->PostTask(
- FROM_HERE, base::Bind(&AudioStub::ProcessAudioPacket, audio_stub_,
- base::Passed(&audio_packet), base::Closure()));
+ audio_stub_->ProcessAudioPacket(std::move(audio_packet), base::Closure());
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/webrtc_audio_sink_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698