| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 AUDCLNT_SHAREMODE WASAPIAudioOutputStream::GetShareMode() { | 379 AUDCLNT_SHAREMODE WASAPIAudioOutputStream::GetShareMode() { |
| 380 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 380 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 381 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) | 381 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) |
| 382 return AUDCLNT_SHAREMODE_EXCLUSIVE; | 382 return AUDCLNT_SHAREMODE_EXCLUSIVE; |
| 383 return AUDCLNT_SHAREMODE_SHARED; | 383 return AUDCLNT_SHAREMODE_SHARED; |
| 384 } | 384 } |
| 385 | 385 |
| 386 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, | 386 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, |
| 387 const AudioParameters& params, | 387 const AudioParameters& params, |
| 388 ERole device_role) | 388 ERole device_role) |
| 389 : com_init_(ScopedCOMInitializer::kMTA), | 389 : creating_thread_id_(base::PlatformThread::CurrentId()), |
| 390 creating_thread_id_(base::PlatformThread::CurrentId()), | |
| 391 manager_(manager), | 390 manager_(manager), |
| 392 opened_(false), | 391 opened_(false), |
| 393 started_(false), | 392 started_(false), |
| 394 restart_rendering_mode_(false), | 393 restart_rendering_mode_(false), |
| 395 volume_(1.0), | 394 volume_(1.0), |
| 396 endpoint_buffer_size_frames_(0), | 395 endpoint_buffer_size_frames_(0), |
| 397 device_role_(device_role), | 396 device_role_(device_role), |
| 398 share_mode_(GetShareMode()), | 397 share_mode_(GetShareMode()), |
| 399 client_channel_count_(params.channels()), | 398 client_channel_count_(params.channels()), |
| 400 num_written_frames_(0), | 399 num_written_frames_(0), |
| 401 source_(NULL), | 400 source_(NULL), |
| 402 audio_bus_(AudioBus::Create(params)) { | 401 audio_bus_(AudioBus::Create(params)) { |
| 403 CHECK(com_init_.succeeded()); | |
| 404 DCHECK(manager_); | 402 DCHECK(manager_); |
| 405 | 403 |
| 406 // Load the Avrt DLL if not already loaded. Required to support MMCSS. | 404 // Load the Avrt DLL if not already loaded. Required to support MMCSS. |
| 407 bool avrt_init = avrt::Initialize(); | 405 bool avrt_init = avrt::Initialize(); |
| 408 DCHECK(avrt_init) << "Failed to load the avrt.dll"; | 406 DCHECK(avrt_init) << "Failed to load the avrt.dll"; |
| 409 | 407 |
| 410 if (share_mode_ == AUDCLNT_SHAREMODE_EXCLUSIVE) { | 408 if (share_mode_ == AUDCLNT_SHAREMODE_EXCLUSIVE) { |
| 411 VLOG(1) << ">> Note that EXCLUSIVE MODE is enabled <<"; | 409 VLOG(1) << ">> Note that EXCLUSIVE MODE is enabled <<"; |
| 412 } | 410 } |
| 413 | 411 |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 // are now re-initiated and it is now possible to re-start audio rendering. | 1425 // are now re-initiated and it is now possible to re-start audio rendering. |
| 1428 | 1426 |
| 1429 // Start rendering again using the new default audio endpoint. | 1427 // Start rendering again using the new default audio endpoint. |
| 1430 hr = audio_client_->Start(); | 1428 hr = audio_client_->Start(); |
| 1431 | 1429 |
| 1432 restart_rendering_mode_ = false; | 1430 restart_rendering_mode_ = false; |
| 1433 return SUCCEEDED(hr); | 1431 return SUCCEEDED(hr); |
| 1434 } | 1432 } |
| 1435 | 1433 |
| 1436 } // namespace media | 1434 } // namespace media |
| OLD | NEW |