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/mac/audio_manager_mac.h" | 5 #include "media/audio/mac/audio_manager_mac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 } | 598 } |
599 | 599 |
600 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( | 600 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( |
601 const AudioParameters& params) { | 601 const AudioParameters& params) { |
602 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 602 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
603 return MakeLowLatencyOutputStream(params, std::string()); | 603 return MakeLowLatencyOutputStream(params, std::string()); |
604 } | 604 } |
605 | 605 |
606 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( | 606 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( |
607 const AudioParameters& params, | 607 const AudioParameters& params, |
608 const std::string& device_id) { | 608 const std::string& device_id, |
609 const StatisticsCallback& statistics_callback) { | |
609 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 610 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
610 bool device_listener_first_init = false; | 611 bool device_listener_first_init = false; |
611 // Lazily create the audio device listener on the first stream creation, | 612 // Lazily create the audio device listener on the first stream creation, |
612 // even if getting an audio device fails. Otherwise, if we have 0 audio | 613 // even if getting an audio device fails. Otherwise, if we have 0 audio |
613 // devices, the listener will never be initialized, and new valid devices | 614 // devices, the listener will never be initialized, and new valid devices |
614 // will never be detected. | 615 // will never be detected. |
615 if (!output_device_listener_) { | 616 if (!output_device_listener_) { |
616 // NOTE: Use BindToCurrentLoop() to ensure the callback is always PostTask'd | 617 // NOTE: Use BindToCurrentLoop() to ensure the callback is always PostTask'd |
617 // even if OSX calls us on the right thread. Some CoreAudio drivers will | 618 // even if OSX calls us on the right thread. Some CoreAudio drivers will |
618 // fire the callbacks during stream creation, leading to re-entrancy issues | 619 // fire the callbacks during stream creation, leading to re-entrancy issues |
(...skipping 14 matching lines...) Expand all Loading... | |
633 // listener. | 634 // listener. |
634 if (device_listener_first_init) { | 635 if (device_listener_first_init) { |
635 // Only set the current output device for the default device. | 636 // Only set the current output device for the default device. |
636 if (AudioDeviceDescription::IsDefaultDevice(device_id)) | 637 if (AudioDeviceDescription::IsDefaultDevice(device_id)) |
637 current_output_device_ = device; | 638 current_output_device_ = device; |
638 // Just use the current sample rate since we don't allow non-native sample | 639 // Just use the current sample rate since we don't allow non-native sample |
639 // rates on OSX. | 640 // rates on OSX. |
640 current_sample_rate_ = params.sample_rate(); | 641 current_sample_rate_ = params.sample_rate(); |
641 } | 642 } |
642 | 643 |
643 AUHALStream* stream = new AUHALStream(this, params, device); | 644 AUHALStream* stream = |
645 new AUHALStream(this, params, device, statistics_callback); | |
644 output_streams_.push_back(stream); | 646 output_streams_.push_back(stream); |
645 return stream; | 647 return stream; |
646 } | 648 } |
647 | 649 |
648 std::string AudioManagerMac::GetDefaultOutputDeviceID() { | 650 std::string AudioManagerMac::GetDefaultOutputDeviceID() { |
649 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 651 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
650 AudioDeviceID device_id = kAudioObjectUnknown; | 652 AudioDeviceID device_id = kAudioObjectUnknown; |
651 if (!GetDefaultOutputDevice(&device_id)) | 653 if (!GetDefaultOutputDevice(&device_id)) |
652 return std::string(); | 654 return std::string(); |
653 | 655 |
(...skipping 30 matching lines...) Expand all Loading... | |
684 | 686 |
685 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( | 687 AudioInputStream* AudioManagerMac::MakeLowLatencyInputStream( |
686 const AudioParameters& params, const std::string& device_id) { | 688 const AudioParameters& params, const std::string& device_id) { |
687 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 689 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
688 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 690 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
689 // Gets the AudioDeviceID that refers to the AudioInputDevice with the device | 691 // Gets the AudioDeviceID that refers to the AudioInputDevice with the device |
690 // unique id. This AudioDeviceID is used to set the device for Audio Unit. | 692 // unique id. This AudioDeviceID is used to set the device for Audio Unit. |
691 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); | 693 AudioDeviceID audio_device_id = GetAudioDeviceIdByUId(true, device_id); |
692 AUAudioInputStream* stream = NULL; | 694 AUAudioInputStream* stream = NULL; |
693 if (audio_device_id != kAudioObjectUnknown) { | 695 if (audio_device_id != kAudioObjectUnknown) { |
694 stream = new AUAudioInputStream(this, params, audio_device_id); | 696 stream = new AUAudioInputStream(this, params, audio_device_id); |
o1ka
2016/05/18 14:00:17
This does not seem to match the modified AUAudioIn
Henrik Grunell
2016/05/23 17:13:55
Fixed.
| |
695 low_latency_input_streams_.push_back(stream); | 697 low_latency_input_streams_.push_back(stream); |
696 } | 698 } |
697 | 699 |
698 return stream; | 700 return stream; |
699 } | 701 } |
700 | 702 |
701 AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( | 703 AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( |
702 const std::string& output_device_id, | 704 const std::string& output_device_id, |
703 const AudioParameters& input_params) { | 705 const AudioParameters& input_params) { |
704 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 706 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 ScopedAudioManagerPtr CreateAudioManager( | 1061 ScopedAudioManagerPtr CreateAudioManager( |
1060 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 1062 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
1061 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 1063 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
1062 AudioLogFactory* audio_log_factory) { | 1064 AudioLogFactory* audio_log_factory) { |
1063 return ScopedAudioManagerPtr( | 1065 return ScopedAudioManagerPtr( |
1064 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), | 1066 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), |
1065 audio_log_factory)); | 1067 audio_log_factory)); |
1066 } | 1068 } |
1067 | 1069 |
1068 } // namespace media | 1070 } // namespace media |
OLD | NEW |