Chromium Code Reviews| Index: media/audio/win/audio_low_latency_output_win.cc |
| diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc |
| index 847a5a2b029bc08dbf0999fa852098b82053576e..f9ae3eb498102d3e074bf9ff78b2caf4e8ee6266 100644 |
| --- a/media/audio/win/audio_low_latency_output_win.cc |
| +++ b/media/audio/win/audio_low_latency_output_win.cc |
| @@ -18,6 +18,7 @@ |
| #include "media/audio/win/audio_manager_win.h" |
| #include "media/audio/win/avrt_wrapper_win.h" |
| #include "media/audio/win/core_audio_util_win.h" |
| +#include "media/base/audio_sample_types.h" |
| #include "media/base/limits.h" |
| #include "media/base/media_switches.h" |
| @@ -72,7 +73,14 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, |
| share_mode_(GetShareMode()), |
| num_written_frames_(0), |
| source_(NULL), |
| - audio_bus_(AudioBus::Create(params)) { |
| + audio_bus_(AudioBus::Create(AudioParameters( |
| + params.format(), |
| + params.channel_layout(), |
| + params.sample_rate(), |
| + // Ignore the given bits per sample; we want 32 because |
| + // we're outputting floats. |
| + 32, |
| + params.frames_per_buffer()))) { |
| DCHECK(manager_); |
| // The empty string is used to indicate a default device and the |
| @@ -98,15 +106,16 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, |
| format->wFormatTag = WAVE_FORMAT_EXTENSIBLE; |
| format->nChannels = params.channels(); |
| format->nSamplesPerSec = params.sample_rate(); |
| - format->wBitsPerSample = params.bits_per_sample(); |
| + // Always want 32 bits because we're using floats. |
| + format->wBitsPerSample = 32; |
|
tommi (sloooow) - chröme
2016/11/02 20:23:04
nit: Add a constant at the top of the file for thi
Raymond Toy
2016/11/02 21:26:14
Done. Please up choose a good name if you don't li
|
| format->nBlockAlign = (format->wBitsPerSample / 8) * format->nChannels; |
| format->nAvgBytesPerSec = format->nSamplesPerSec * format->nBlockAlign; |
| format->cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); |
| // Add the parts which are unique to WAVE_FORMAT_EXTENSIBLE. |
| - format_.Samples.wValidBitsPerSample = params.bits_per_sample(); |
| + format_.Samples.wValidBitsPerSample = 32; |
| format_.dwChannelMask = CoreAudioUtil::GetChannelConfig(device_id, eRender); |
| - format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; |
| + format_.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; |
|
tommi (sloooow) - chröme
2016/11/02 20:23:04
that's it? :-|
Raymond Toy
2016/11/02 21:26:14
I think so. :-) I can hear output now that wasn't
|
| // Store size (in different units) of audio packets which we expect to |
| // get from the audio endpoint device in each render event. |
| @@ -549,8 +558,8 @@ bool WASAPIAudioOutputStream::RenderAudioFromSource(UINT64 device_frequency) { |
| // source such as NaCl. |
| const int bytes_per_sample = format_.Format.wBitsPerSample >> 3; |
| audio_bus_->Scale(volume_); |
| - audio_bus_->ToInterleaved( |
| - frames_filled, bytes_per_sample, audio_data); |
| + audio_bus_->ToInterleaved<Float32SampleTypeTraits>( |
| + frames_filled, reinterpret_cast<float*>(audio_data)); |
| // Release the buffer space acquired in the GetBuffer() call. |
| // Render silence if we were not able to fill up the buffer totally. |