OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/client/audio_player.h" | 5 #include "remoting/client/audio_player.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 start_failed_(false), | 24 start_failed_(false), |
25 queued_bytes_(0), | 25 queued_bytes_(0), |
26 bytes_consumed_(0) { | 26 bytes_consumed_(0) { |
27 } | 27 } |
28 | 28 |
29 AudioPlayer::~AudioPlayer() { | 29 AudioPlayer::~AudioPlayer() { |
30 base::AutoLock auto_lock(lock_); | 30 base::AutoLock auto_lock(lock_); |
31 ResetQueue(); | 31 ResetQueue(); |
32 } | 32 } |
33 | 33 |
34 void AudioPlayer::ProcessAudioPacket(scoped_ptr<AudioPacket> packet) { | 34 void AudioPlayer::ProcessAudioPacket(std::unique_ptr<AudioPacket> packet) { |
35 CHECK_EQ(1, packet->data_size()); | 35 CHECK_EQ(1, packet->data_size()); |
36 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); | 36 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); |
37 DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate()); | 37 DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate()); |
38 DCHECK_EQ(kSampleSizeBytes, packet->bytes_per_sample()); | 38 DCHECK_EQ(kSampleSizeBytes, packet->bytes_per_sample()); |
39 DCHECK_EQ(static_cast<int>(kChannels), packet->channels()); | 39 DCHECK_EQ(static_cast<int>(kChannels), packet->channels()); |
40 DCHECK_EQ(packet->data(0).size() % (kChannels * kSampleSizeBytes), 0u); | 40 DCHECK_EQ(packet->data(0).size() % (kChannels * kSampleSizeBytes), 0u); |
41 | 41 |
42 // No-op if the Pepper player won't start. | 42 // No-op if the Pepper player won't start. |
43 if (start_failed_) { | 43 if (start_failed_) { |
44 return; | 44 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 next_sample += bytes_to_copy; | 129 next_sample += bytes_to_copy; |
130 bytes_consumed_ += bytes_to_copy; | 130 bytes_consumed_ += bytes_to_copy; |
131 bytes_extracted += bytes_to_copy; | 131 bytes_extracted += bytes_to_copy; |
132 queued_bytes_ -= bytes_to_copy; | 132 queued_bytes_ -= bytes_to_copy; |
133 DCHECK_GE(queued_bytes_, 0); | 133 DCHECK_GE(queued_bytes_, 0); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace remoting | 137 } // namespace remoting |
OLD | NEW |