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

Unified Diff: remoting/host/audio_capturer_win.cc

Issue 10827324: Changed AudioPacket data to a repeated field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/codec/audio_encoder_verbatim.cc ('k') | remoting/proto/audio.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/audio_capturer_win.cc
diff --git a/remoting/host/audio_capturer_win.cc b/remoting/host/audio_capturer_win.cc
index b450a9a543e770582de73cfc94e0c95800b49e33..c648a0ab0727c5c776e51a9bf66db3c4100bc8e4 100644
--- a/remoting/host/audio_capturer_win.cc
+++ b/remoting/host/audio_capturer_win.cc
@@ -53,7 +53,7 @@ class AudioCapturerWin : public AudioCapturer {
// to the network.
void DoCapture();
- static bool IsPacketOfSilence(const AudioPacket* packet);
+ static bool IsPacketOfSilence(const int16* samples, int number_of_samples);
PacketCapturedCallback callback_;
@@ -274,15 +274,19 @@ void AudioCapturerWin::DoCapture() {
return;
}
- scoped_ptr<AudioPacket> packet = scoped_ptr<AudioPacket>(new AudioPacket());
- packet->set_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);
+ if (!IsPacketOfSilence(
+ reinterpret_cast<const int16*>(data),
+ frames * kChannels)) {
+ 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);
- if (!IsPacketOfSilence(packet.get()))
callback_.Run(packet.Pass());
+ }
hr = audio_capture_client_->ReleaseBuffer(frames);
if (FAILED(hr)) {
@@ -295,14 +299,10 @@ void AudioCapturerWin::DoCapture() {
// Detects whether there is audio playing in a packet of samples.
// Windows can give nonzero samples, even when there is no audio playing, so
// extremely low amplitude samples are counted as silence.
-bool AudioCapturerWin::IsPacketOfSilence(const AudioPacket* packet) {
- DCHECK_EQ(static_cast<AudioPacket::BytesPerSample>(sizeof(int16)),
- packet->bytes_per_sample());
- const int16* data = reinterpret_cast<const int16*>(packet->data().data());
- int number_of_samples = packet->data().size() * kBitsPerByte / kBitsPerSample;
-
+bool AudioCapturerWin::IsPacketOfSilence(
+ const int16* samples, int number_of_samples) {
for (int i = 0; i < number_of_samples; i++) {
- if (abs(data[i]) > kSilenceThreshold)
+ if (abs(samples[i]) > kSilenceThreshold)
return false;
}
return true;
« no previous file with comments | « remoting/codec/audio_encoder_verbatim.cc ('k') | remoting/proto/audio.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698