| 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 "media/audio/win/audio_low_latency_output_win.h" | 5 #include "media/audio/win/audio_low_latency_output_win.h" |
| 6 | 6 |
| 7 #include <Functiondiscoverykeys_devpkey.h> | 7 #include <Functiondiscoverykeys_devpkey.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/win/scoped_propvariant.h" | 15 #include "base/win/scoped_propvariant.h" |
| 16 #include "media/audio/audio_util.h" | |
| 17 #include "media/audio/win/audio_manager_win.h" | 16 #include "media/audio/win/audio_manager_win.h" |
| 18 #include "media/audio/win/avrt_wrapper_win.h" | 17 #include "media/audio/win/avrt_wrapper_win.h" |
| 19 #include "media/audio/win/core_audio_util_win.h" | 18 #include "media/audio/win/core_audio_util_win.h" |
| 20 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
| 21 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 22 | 21 |
| 23 using base::win::ScopedComPtr; | 22 using base::win::ScopedComPtr; |
| 24 using base::win::ScopedCOMInitializer; | 23 using base::win::ScopedCOMInitializer; |
| 25 using base::win::ScopedCoMem; | 24 using base::win::ScopedCoMem; |
| 26 | 25 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 | 573 |
| 575 int frames_filled = source_->OnMoreData( | 574 int frames_filled = source_->OnMoreData( |
| 576 audio_bus_.get(), AudioBuffersState(0, audio_delay_bytes)); | 575 audio_bus_.get(), AudioBuffersState(0, audio_delay_bytes)); |
| 577 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; | 576 uint32 num_filled_bytes = frames_filled * format_.Format.nBlockAlign; |
| 578 DCHECK_LE(num_filled_bytes, packet_size_bytes_); | 577 DCHECK_LE(num_filled_bytes, packet_size_bytes_); |
| 579 | 578 |
| 580 // Note: If this ever changes to output raw float the data must be | 579 // Note: If this ever changes to output raw float the data must be |
| 581 // clipped and sanitized since it may come from an untrusted | 580 // clipped and sanitized since it may come from an untrusted |
| 582 // source such as NaCl. | 581 // source such as NaCl. |
| 583 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; | 582 const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; |
| 583 audio_bus_->AdjustVolume(volume_); |
| 584 audio_bus_->ToInterleaved( | 584 audio_bus_->ToInterleaved( |
| 585 frames_filled, bytes_per_sample, audio_data); | 585 frames_filled, bytes_per_sample, audio_data); |
| 586 | 586 |
| 587 // Perform in-place, software-volume adjustments. | |
| 588 media::AdjustVolume(audio_data, | |
| 589 num_filled_bytes, | |
| 590 audio_bus_->channels(), | |
| 591 bytes_per_sample, | |
| 592 volume_); | |
| 593 | 587 |
| 594 // Release the buffer space acquired in the GetBuffer() call. | 588 // Release the buffer space acquired in the GetBuffer() call. |
| 595 // Render silence if we were not able to fill up the buffer totally. | 589 // Render silence if we were not able to fill up the buffer totally. |
| 596 DWORD flags = (num_filled_bytes < packet_size_bytes_) ? | 590 DWORD flags = (num_filled_bytes < packet_size_bytes_) ? |
| 597 AUDCLNT_BUFFERFLAGS_SILENT : 0; | 591 AUDCLNT_BUFFERFLAGS_SILENT : 0; |
| 598 audio_render_client_->ReleaseBuffer(packet_size_frames_, flags); | 592 audio_render_client_->ReleaseBuffer(packet_size_frames_, flags); |
| 599 | 593 |
| 600 num_written_frames_ += packet_size_frames_; | 594 num_written_frames_ += packet_size_frames_; |
| 601 } | 595 } |
| 602 } | 596 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 VLOG(1) << "IAudioClient::GetBufferSize: " << std::hex << hr; | 676 VLOG(1) << "IAudioClient::GetBufferSize: " << std::hex << hr; |
| 683 return hr; | 677 return hr; |
| 684 } | 678 } |
| 685 | 679 |
| 686 *endpoint_buffer_size = buffer_size_in_frames; | 680 *endpoint_buffer_size = buffer_size_in_frames; |
| 687 VLOG(2) << "endpoint buffer size: " << buffer_size_in_frames; | 681 VLOG(2) << "endpoint buffer size: " << buffer_size_in_frames; |
| 688 return hr; | 682 return hr; |
| 689 } | 683 } |
| 690 | 684 |
| 691 } // namespace media | 685 } // namespace media |
| OLD | NEW |