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/plugin/pepper_audio_player.h" | 5 #include "remoting/client/plugin/pepper_audio_player.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 if (!success) | 69 if (!success) |
70 LOG(ERROR) << "Failed to start Pepper audio player"; | 70 LOG(ERROR) << "Failed to start Pepper audio player"; |
71 return success; | 71 return success; |
72 } | 72 } |
73 | 73 |
74 void PepperAudioPlayer::ProcessAudioPacket(scoped_ptr<AudioPacket> packet) { | 74 void PepperAudioPlayer::ProcessAudioPacket(scoped_ptr<AudioPacket> packet) { |
75 // TODO(kxing): Limit the size of the queue so that latency doesn't grow | 75 // TODO(kxing): Limit the size of the queue so that latency doesn't grow |
76 // too large. | 76 // too large. |
77 | 77 |
78 // Drop null packets. | 78 // Drop null packets. |
79 if (!packet.get()) | 79 if (!packet.get()) |
Sergey Ulanov
2012/08/20 22:26:20
I think I already mentioned in one of the previous
kxing
2012/08/20 22:48:22
Done.
| |
80 return; | 80 return; |
81 | 81 |
82 CHECK_EQ(1, packet->data_size()); | 82 CHECK_EQ(1, packet->data_size()); |
83 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); | 83 DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); |
84 DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate()); | |
85 DCHECK_NE(AudioPacket::BYTES_PER_SAMPLE_INVALID, packet->bytes_per_sample()); | |
Sergey Ulanov
2012/08/20 22:26:20
check that bytes_per_sample() == kSampleSizeBytes?
kxing
2012/08/20 22:48:22
Done.
| |
86 DCHECK_NE(AudioPacket::CHANNELS_INVALID, packet->channels()); | |
Sergey Ulanov
2012/08/20 22:26:20
I think you want to check that channels()==kChanne
kxing
2012/08/20 22:48:22
Done.
| |
84 if (packet->data(0).size() % (kChannels * kSampleSizeBytes) != 0) { | 87 if (packet->data(0).size() % (kChannels * kSampleSizeBytes) != 0) { |
Sergey Ulanov
2012/08/20 22:26:20
add empty line above this one.
kxing
2012/08/20 22:48:22
Done.
| |
85 LOG(WARNING) << "Received corrupted packet."; | 88 LOG(WARNING) << "Received corrupted packet."; |
86 return; | 89 return; |
87 } | 90 } |
88 base::AutoLock auto_lock(lock_); | 91 base::AutoLock auto_lock(lock_); |
89 | 92 |
90 // No-op if the Pepper player won't start. | 93 // No-op if the Pepper player won't start. |
91 if (start_failed_) { | 94 if (start_failed_) { |
92 return; | 95 return; |
93 } | 96 } |
94 | 97 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 bytes_needed - bytes_extracted); | 152 bytes_needed - bytes_extracted); |
150 memcpy(next_sample, packet_data.data() + bytes_consumed_, bytes_to_copy); | 153 memcpy(next_sample, packet_data.data() + bytes_consumed_, bytes_to_copy); |
151 | 154 |
152 next_sample += bytes_to_copy; | 155 next_sample += bytes_to_copy; |
153 bytes_consumed_ += bytes_to_copy; | 156 bytes_consumed_ += bytes_to_copy; |
154 bytes_extracted += bytes_to_copy; | 157 bytes_extracted += bytes_to_copy; |
155 } | 158 } |
156 } | 159 } |
157 | 160 |
158 } // namespace remoting | 161 } // namespace remoting |
OLD | NEW |