| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 packet_size_bytes_(0), | 65 packet_size_bytes_(0), |
| 66 endpoint_buffer_size_frames_(0), | 66 endpoint_buffer_size_frames_(0), |
| 67 device_id_(device_id), | 67 device_id_(device_id), |
| 68 device_role_(device_role), | 68 device_role_(device_role), |
| 69 share_mode_(GetShareMode()), | 69 share_mode_(GetShareMode()), |
| 70 num_written_frames_(0), | 70 num_written_frames_(0), |
| 71 source_(NULL), | 71 source_(NULL), |
| 72 audio_bus_(AudioBus::Create(params)) { | 72 audio_bus_(AudioBus::Create(params)) { |
| 73 DCHECK(manager_); | 73 DCHECK(manager_); |
| 74 | 74 |
| 75 // The empty string is used to indicate a default device and the |
| 76 // |device_role_| member controls whether that's the default or default |
| 77 // communications device. |
| 78 DCHECK_NE(device_id_, AudioManagerBase::kDefaultDeviceId); |
| 79 DCHECK_NE(device_id_, AudioManagerBase::kCommunicationsDeviceId); |
| 80 |
| 75 DVLOG(1) << "WASAPIAudioOutputStream::WASAPIAudioOutputStream()"; | 81 DVLOG(1) << "WASAPIAudioOutputStream::WASAPIAudioOutputStream()"; |
| 76 DVLOG_IF(1, share_mode_ == AUDCLNT_SHAREMODE_EXCLUSIVE) | 82 DVLOG_IF(1, share_mode_ == AUDCLNT_SHAREMODE_EXCLUSIVE) |
| 77 << "Core Audio (WASAPI) EXCLUSIVE MODE is enabled."; | 83 << "Core Audio (WASAPI) EXCLUSIVE MODE is enabled."; |
| 78 | 84 |
| 79 // Load the Avrt DLL if not already loaded. Required to support MMCSS. | 85 // Load the Avrt DLL if not already loaded. Required to support MMCSS. |
| 80 bool avrt_init = avrt::Initialize(); | 86 bool avrt_init = avrt::Initialize(); |
| 81 DCHECK(avrt_init) << "Failed to load the avrt.dll"; | 87 DCHECK(avrt_init) << "Failed to load the avrt.dll"; |
| 82 | 88 |
| 83 // Set up the desired render format specified by the client. We use the | 89 // Set up the desired render format specified by the client. We use the |
| 84 // WAVE_FORMAT_EXTENSIBLE structure to ensure that multiple channel ordering | 90 // WAVE_FORMAT_EXTENSIBLE structure to ensure that multiple channel ordering |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 139 |
| 134 DCHECK(!audio_client_.get()); | 140 DCHECK(!audio_client_.get()); |
| 135 DCHECK(!audio_render_client_.get()); | 141 DCHECK(!audio_render_client_.get()); |
| 136 | 142 |
| 137 // Will be set to true if we ended up opening the default communications | 143 // Will be set to true if we ended up opening the default communications |
| 138 // device. | 144 // device. |
| 139 bool communications_device = false; | 145 bool communications_device = false; |
| 140 | 146 |
| 141 // Create an IAudioClient interface for the default rendering IMMDevice. | 147 // Create an IAudioClient interface for the default rendering IMMDevice. |
| 142 ScopedComPtr<IAudioClient> audio_client; | 148 ScopedComPtr<IAudioClient> audio_client; |
| 143 if (device_id_.empty() || | 149 if (device_id_.empty()) { |
| 144 CoreAudioUtil::DeviceIsDefault(eRender, device_role_, device_id_)) { | |
| 145 audio_client = CoreAudioUtil::CreateDefaultClient(eRender, device_role_); | 150 audio_client = CoreAudioUtil::CreateDefaultClient(eRender, device_role_); |
| 146 communications_device = (device_role_ == eCommunications); | 151 communications_device = (device_role_ == eCommunications); |
| 147 } else { | 152 } else { |
| 148 ScopedComPtr<IMMDevice> device(CoreAudioUtil::CreateDevice(device_id_)); | 153 ScopedComPtr<IMMDevice> device(CoreAudioUtil::CreateDevice(device_id_)); |
| 149 DLOG_IF(ERROR, !device.get()) << "Failed to open device: " << device_id_; | 154 DLOG_IF(ERROR, !device.get()) << "Failed to open device: " << device_id_; |
| 150 if (device.get()) | 155 if (device.get()) |
| 151 audio_client = CoreAudioUtil::CreateClient(device.get()); | 156 audio_client = CoreAudioUtil::CreateClient(device.get()); |
| 152 } | 157 } |
| 153 | 158 |
| 154 if (!audio_client.get()) | 159 if (!audio_client.get()) |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 629 |
| 625 // Ensure that we don't quit the main thread loop immediately next | 630 // Ensure that we don't quit the main thread loop immediately next |
| 626 // time Start() is called. | 631 // time Start() is called. |
| 627 ResetEvent(stop_render_event_.Get()); | 632 ResetEvent(stop_render_event_.Get()); |
| 628 } | 633 } |
| 629 | 634 |
| 630 source_ = NULL; | 635 source_ = NULL; |
| 631 } | 636 } |
| 632 | 637 |
| 633 } // namespace media | 638 } // namespace media |
| OLD | NEW |