Chromium Code Reviews| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 | 368 |
| 369 return ((out_channels / static_cast<double> (in_channels)) * | 369 return ((out_channels / static_cast<double> (in_channels)) * |
| 370 number_of_input_bytes); | 370 number_of_input_bytes); |
| 371 } | 371 } |
| 372 | 372 |
| 373 LOG(ERROR) << "Down-mixing " << out_channels << "->" | 373 LOG(ERROR) << "Down-mixing " << out_channels << "->" |
| 374 << in_channels << " is not supported."; | 374 << in_channels << " is not supported."; |
| 375 return 0; | 375 return 0; |
| 376 } | 376 } |
| 377 | 377 |
| 378 static bool ChannelMixingSupported(int bytes_per_sample, int in_channels, | |
| 379 int out_channels) { | |
| 380 return bytes_per_sample == 2 && | |
| 381 ((in_channels == 1 && out_channels == 2) || | |
| 382 (in_channels == 1 && out_channels == 8) || | |
| 383 (in_channels == 2 && out_channels == 6) || | |
| 384 (in_channels == 2 && out_channels == 8) || | |
| 385 (in_channels == 2 && out_channels == 1)); | |
| 386 } | |
| 387 | |
| 378 // static | 388 // static |
| 379 AUDCLNT_SHAREMODE WASAPIAudioOutputStream::GetShareMode() { | 389 AUDCLNT_SHAREMODE WASAPIAudioOutputStream::GetShareMode() { |
| 380 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 390 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 381 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) | 391 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) |
| 382 return AUDCLNT_SHAREMODE_EXCLUSIVE; | 392 return AUDCLNT_SHAREMODE_EXCLUSIVE; |
| 383 return AUDCLNT_SHAREMODE_SHARED; | 393 return AUDCLNT_SHAREMODE_SHARED; |
| 384 } | 394 } |
| 385 | 395 |
| 386 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, | 396 WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager, |
| 387 const AudioParameters& params, | 397 const AudioParameters& params, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 DCHECK(stream_switch_event_.IsValid()); | 496 DCHECK(stream_switch_event_.IsValid()); |
| 487 } | 497 } |
| 488 | 498 |
| 489 WASAPIAudioOutputStream::~WASAPIAudioOutputStream() {} | 499 WASAPIAudioOutputStream::~WASAPIAudioOutputStream() {} |
| 490 | 500 |
| 491 bool WASAPIAudioOutputStream::Open() { | 501 bool WASAPIAudioOutputStream::Open() { |
| 492 DCHECK_EQ(GetCurrentThreadId(), creating_thread_id_); | 502 DCHECK_EQ(GetCurrentThreadId(), creating_thread_id_); |
| 493 if (opened_) | 503 if (opened_) |
| 494 return true; | 504 return true; |
| 495 | 505 |
| 496 // Down-mixing is currently not supported. The number of channels provided | 506 if (format_.Format.nChannels != client_channel_count_ && |
|
henrika (OOO until Aug 14)
2012/11/08 08:27:42
We could perhaps keep some comments. You removed t
DaleCurtis
2012/11/08 18:39:30
The old ones are out of date and the LOG(ERROR) ex
| |
| 497 // by the audio source must be less than or equal to the number of native | 507 !ChannelMixingSupported( |
| 498 // channels (given by endpoint_channel_count()) which is the channel count | 508 format_.Format.wBitsPerSample / 8, client_channel_count_, |
| 499 // used when opening the default endpoint device. | 509 format_.Format.nChannels)) { |
| 500 if (channel_factor() < 1 && channel_factor() != 0.5f) { | 510 LOG(ERROR) << "Channel mixing is not supported."; |
| 501 LOG(ERROR) << "Channel down-mixing is not supported"; | |
| 502 RecordFallbackStats(); | |
| 503 return false; | |
| 504 } | |
| 505 | |
| 506 // Only 16-bit audio is supported in combination with channel up-mixing. | |
| 507 if (channel_factor() > 1 && (format_.Format.wBitsPerSample != 16)) { | |
| 508 LOG(ERROR) << "16-bit audio is required when channel up-mixing is active."; | |
| 509 RecordFallbackStats(); | 511 RecordFallbackStats(); |
| 510 return false; | 512 return false; |
| 511 } | 513 } |
| 512 | 514 |
| 513 // Create an IMMDeviceEnumerator interface and obtain a reference to | 515 // Create an IMMDeviceEnumerator interface and obtain a reference to |
| 514 // the IMMDevice interface of the default rendering device with the | 516 // the IMMDevice interface of the default rendering device with the |
| 515 // specified role. | 517 // specified role. |
| 516 HRESULT hr = SetRenderDevice(); | 518 HRESULT hr = SetRenderDevice(); |
| 517 if (FAILED(hr)) { | 519 if (FAILED(hr)) { |
| 518 RecordFallbackStats(); | 520 RecordFallbackStats(); |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 // are now re-initiated and it is now possible to re-start audio rendering. | 1415 // are now re-initiated and it is now possible to re-start audio rendering. |
| 1414 | 1416 |
| 1415 // Start rendering again using the new default audio endpoint. | 1417 // Start rendering again using the new default audio endpoint. |
| 1416 hr = audio_client_->Start(); | 1418 hr = audio_client_->Start(); |
| 1417 | 1419 |
| 1418 restart_rendering_mode_ = false; | 1420 restart_rendering_mode_ = false; |
| 1419 return SUCCEEDED(hr); | 1421 return SUCCEEDED(hr); |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 } // namespace media | 1424 } // namespace media |
| OLD | NEW |