summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/client/audio_decode_scheduler.cc4
-rw-r--r--remoting/client/plugin/pepper_audio_player.cc8
-rw-r--r--remoting/codec/audio_decoder.h2
-rw-r--r--remoting/codec/audio_decoder_verbatim.cc4
-rw-r--r--remoting/codec/audio_encoder_verbatim.cc3
-rw-r--r--remoting/host/audio_capturer_win.cc6
6 files changed, 18 insertions, 9 deletions
diff --git a/remoting/client/audio_decode_scheduler.cc b/remoting/client/audio_decode_scheduler.cc
index 7dc0d3c..940eb66 100644
--- a/remoting/client/audio_decode_scheduler.cc
+++ b/remoting/client/audio_decode_scheduler.cc
@@ -51,7 +51,9 @@ void AudioDecodeScheduler::DecodePacket(scoped_ptr<AudioPacket> packet,
void AudioDecodeScheduler::ProcessDecodedPacket(scoped_ptr<AudioPacket> packet,
const base::Closure& done) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
- audio_player_->ProcessAudioPacket(packet.Pass());
+ // Only process |packet| if it is non-NULL.
+ if (packet.get())
+ audio_player_->ProcessAudioPacket(packet.Pass());
done.Run();
}
diff --git a/remoting/client/plugin/pepper_audio_player.cc b/remoting/client/plugin/pepper_audio_player.cc
index dae8c1e..d9c53a5 100644
--- a/remoting/client/plugin/pepper_audio_player.cc
+++ b/remoting/client/plugin/pepper_audio_player.cc
@@ -75,12 +75,12 @@ void PepperAudioPlayer::ProcessAudioPacket(scoped_ptr<AudioPacket> packet) {
// TODO(kxing): Limit the size of the queue so that latency doesn't grow
// too large.
- // Drop null packets.
- if (!packet.get())
- return;
-
CHECK_EQ(1, packet->data_size());
DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
+ DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
+ DCHECK_EQ(kSampleSizeBytes, packet->bytes_per_sample());
+ DCHECK_EQ(static_cast<int>(kChannels), packet->channels());
+
if (packet->data(0).size() % (kChannels * kSampleSizeBytes) != 0) {
LOG(WARNING) << "Received corrupted packet.";
return;
diff --git a/remoting/codec/audio_decoder.h b/remoting/codec/audio_decoder.h
index 72eedf2..f5088bc 100644
--- a/remoting/codec/audio_decoder.h
+++ b/remoting/codec/audio_decoder.h
@@ -22,6 +22,8 @@ class AudioDecoder {
virtual ~AudioDecoder() {}
+ // Returns the decoded packet. If the packet is invalid, then a NULL
+ // scoped_ptr is returned.
virtual scoped_ptr<AudioPacket> Decode(scoped_ptr<AudioPacket> packet) = 0;
};
diff --git a/remoting/codec/audio_decoder_verbatim.cc b/remoting/codec/audio_decoder_verbatim.cc
index 903cb3f..e8143fa 100644
--- a/remoting/codec/audio_decoder_verbatim.cc
+++ b/remoting/codec/audio_decoder_verbatim.cc
@@ -21,7 +21,9 @@ scoped_ptr<AudioPacket> AudioDecoderVerbatim::Decode(
if ((packet->encoding() != AudioPacket::ENCODING_RAW) ||
(packet->data_size() != 1) ||
(packet->sampling_rate() == AudioPacket::SAMPLING_RATE_INVALID) ||
- (packet->bytes_per_sample() == AudioPacket::BYTES_PER_SAMPLE_INVALID)) {
+ (packet->bytes_per_sample() != AudioPacket::BYTES_PER_SAMPLE_2) ||
+ (packet->channels() != AudioPacket::CHANNELS_STEREO)) {
+ LOG(WARNING) << "Verbatim decoder received an invalid packet.";
return scoped_ptr<AudioPacket>();
}
return packet.Pass();
diff --git a/remoting/codec/audio_encoder_verbatim.cc b/remoting/codec/audio_encoder_verbatim.cc
index 52e578a..696035e 100644
--- a/remoting/codec/audio_encoder_verbatim.cc
+++ b/remoting/codec/audio_encoder_verbatim.cc
@@ -17,6 +17,9 @@ scoped_ptr<AudioPacket> AudioEncoderVerbatim::Encode(
scoped_ptr<AudioPacket> packet) {
DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
DCHECK_EQ(1, packet->data_size());
+ DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
+ DCHECK_NE(AudioPacket::BYTES_PER_SAMPLE_INVALID, packet->bytes_per_sample());
+ DCHECK_NE(AudioPacket::CHANNELS_INVALID, packet->channels());
return packet.Pass();
}
diff --git a/remoting/host/audio_capturer_win.cc b/remoting/host/audio_capturer_win.cc
index 03bd426..4dfc174 100644
--- a/remoting/host/audio_capturer_win.cc
+++ b/remoting/host/audio_capturer_win.cc
@@ -294,10 +294,10 @@ void AudioCapturerWin::DoCapture() {
scoped_ptr<AudioPacket> packet =
scoped_ptr<AudioPacket>(new AudioPacket());
packet->add_data(data, frames * wave_format_ex_->nBlockAlign);
- packet->set_sampling_rate(sampling_rate_);
- packet->set_bytes_per_sample(
- static_cast<AudioPacket::BytesPerSample>(sizeof(int16)));
packet->set_encoding(AudioPacket::ENCODING_RAW);
+ packet->set_sampling_rate(sampling_rate_);
+ packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2);
+ packet->set_channels(AudioPacket::CHANNELS_STEREO);
callback_.Run(packet.Pass());
}