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..8cc1b8caf18fc3bef4d3959d524af42f2d9740f9 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_; |
@@ -275,14 +275,17 @@ void AudioCapturerWin::DoCapture() { |
} |
scoped_ptr<AudioPacket> packet = scoped_ptr<AudioPacket>(new AudioPacket()); |
- packet->set_data(data, frames * wave_format_ex_->nBlockAlign); |
+ 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())) |
+ if (!IsPacketOfSilence( |
Sergey Ulanov
2012/08/15 00:47:20
Now you can move this above, before |packet| is cr
kxing
2012/08/15 16:00:05
Done.
|
+ reinterpret_cast<const int16*>(packet->data(0).data()), |
+ packet->data(0).size() * kBitsPerByte / kBitsPerSample)) { |
callback_.Run(packet.Pass()); |
+ } |
hr = audio_capture_client_->ReleaseBuffer(frames); |
if (FAILED(hr)) { |
@@ -295,14 +298,11 @@ 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; |