| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/protocol/audio_decode_scheduler.h" | 5 #include "remoting/protocol/audio_decode_scheduler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
| 13 #include "remoting/codec/audio_decoder.h" | 13 #include "remoting/codec/audio_decoder.h" |
| 14 #include "remoting/proto/audio.pb.h" | 14 #include "remoting/proto/audio.pb.h" |
| 15 #include "remoting/protocol/audio_stub.h" | 15 #include "remoting/protocol/audio_stub.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 namespace protocol { | 18 namespace protocol { |
| 19 | 19 |
| 20 AudioDecodeScheduler::AudioDecodeScheduler( | 20 AudioDecodeScheduler::AudioDecodeScheduler( |
| 21 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner, | 21 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_task_runner, |
| 22 base::WeakPtr<protocol::AudioStub> audio_consumer) | 22 base::WeakPtr<protocol::AudioStub> audio_consumer) |
| 23 : audio_decode_task_runner_(audio_decode_task_runner), | 23 : audio_decode_task_runner_(audio_decode_task_runner), |
| 24 audio_consumer_(audio_consumer), | 24 audio_consumer_(audio_consumer), |
| 25 weak_factory_(this) {} | 25 weak_factory_(this) {} |
| 26 | 26 |
| 27 AudioDecodeScheduler::~AudioDecodeScheduler() { | 27 AudioDecodeScheduler::~AudioDecodeScheduler() { |
| 28 DCHECK(thread_checker_.CalledOnValidThread()); |
| 28 audio_decode_task_runner_->DeleteSoon(FROM_HERE, decoder_.release()); | 29 audio_decode_task_runner_->DeleteSoon(FROM_HERE, decoder_.release()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void AudioDecodeScheduler::Initialize(const protocol::SessionConfig& config) { | 32 void AudioDecodeScheduler::Initialize(const protocol::SessionConfig& config) { |
| 32 DCHECK(thread_checker_.CalledOnValidThread()); | 33 DCHECK(thread_checker_.CalledOnValidThread()); |
| 33 DCHECK(!decoder_); | 34 DCHECK(!decoder_); |
| 34 decoder_ = AudioDecoder::CreateAudioDecoder(config); | 35 decoder_ = AudioDecoder::CreateAudioDecoder(config); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void AudioDecodeScheduler::ProcessAudioPacket( | 38 void AudioDecodeScheduler::ProcessAudioPacket( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 if (!packet || !audio_consumer_) { | 56 if (!packet || !audio_consumer_) { |
| 56 done.Run(); | 57 done.Run(); |
| 57 return; | 58 return; |
| 58 } | 59 } |
| 59 | 60 |
| 60 audio_consumer_->ProcessAudioPacket(std::move(packet), done); | 61 audio_consumer_->ProcessAudioPacket(std::move(packet), done); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace protocol | 64 } // namespace protocol |
| 64 } // namespace remoting | 65 } // namespace remoting |
| OLD | NEW |