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

Side by Side Diff: remoting/client/plugin/pepper_audio_player.cc

Issue 10823420: Added more error checking for audio packets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | remoting/codec/audio_decoder_verbatim.cc » ('j') | remoting/codec/audio_decoder_verbatim.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698