| 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 22 matching lines...) Expand all Loading... |
| 33 // Maximum number of output streams that can be open simultaneously. | 33 // Maximum number of output streams that can be open simultaneously. |
| 34 static const int kMaxOutputStreams = 50; | 34 static const int kMaxOutputStreams = 50; |
| 35 | 35 |
| 36 // Define bounds for for low-latency input and output streams. | 36 // Define bounds for for low-latency input and output streams. |
| 37 static const int kMinimumInputOutputBufferSize = 128; | 37 static const int kMinimumInputOutputBufferSize = 128; |
| 38 static const int kMaximumInputOutputBufferSize = 4096; | 38 static const int kMaximumInputOutputBufferSize = 4096; |
| 39 | 39 |
| 40 // Default sample-rate on most Apple hardware. | 40 // Default sample-rate on most Apple hardware. |
| 41 static const int kFallbackSampleRate = 44100; | 41 static const int kFallbackSampleRate = 44100; |
| 42 | 42 |
| 43 const char kAudioManagerName[] = "Mac"; |
| 44 |
| 43 // Helper method to construct AudioObjectPropertyAddress structure given | 45 // Helper method to construct AudioObjectPropertyAddress structure given |
| 44 // property selector and scope. The property element is always set to | 46 // property selector and scope. The property element is always set to |
| 45 // kAudioObjectPropertyElementMaster. | 47 // kAudioObjectPropertyElementMaster. |
| 46 static AudioObjectPropertyAddress GetAudioObjectPropertyAddress( | 48 static AudioObjectPropertyAddress GetAudioObjectPropertyAddress( |
| 47 AudioObjectPropertySelector selector, | 49 AudioObjectPropertySelector selector, |
| 48 bool is_input) { | 50 bool is_input) { |
| 49 AudioObjectPropertyScope scope = is_input ? kAudioObjectPropertyScopeInput | 51 AudioObjectPropertyScope scope = is_input ? kAudioObjectPropertyScopeInput |
| 50 : kAudioObjectPropertyScopeOutput; | 52 : kAudioObjectPropertyScopeOutput; |
| 51 AudioObjectPropertyAddress property_address = { | 53 AudioObjectPropertyAddress property_address = { |
| 52 selector, scope, kAudioObjectPropertyElementMaster}; | 54 selector, scope, kAudioObjectPropertyElementMaster}; |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 associated_devices.begin(); | 598 associated_devices.begin(); |
| 597 iter != associated_devices.end(); ++iter) { | 599 iter != associated_devices.end(); ++iter) { |
| 598 if (default_device == *iter) | 600 if (default_device == *iter) |
| 599 return *iter; | 601 return *iter; |
| 600 } | 602 } |
| 601 | 603 |
| 602 // Failed to figure out which is the matching device, return an empty string. | 604 // Failed to figure out which is the matching device, return an empty string. |
| 603 return std::string(); | 605 return std::string(); |
| 604 } | 606 } |
| 605 | 607 |
| 608 const char* AudioManagerMac::GetName() { |
| 609 return kAudioManagerName; |
| 610 } |
| 611 |
| 606 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( | 612 AudioOutputStream* AudioManagerMac::MakeLinearOutputStream( |
| 607 const AudioParameters& params, | 613 const AudioParameters& params, |
| 608 const LogCallback& log_callback) { | 614 const LogCallback& log_callback) { |
| 609 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 615 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 610 return MakeLowLatencyOutputStream(params, std::string(), log_callback); | 616 return MakeLowLatencyOutputStream(params, std::string(), log_callback); |
| 611 } | 617 } |
| 612 | 618 |
| 613 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( | 619 AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( |
| 614 const AudioParameters& params, | 620 const AudioParameters& params, |
| 615 const std::string& device_id, | 621 const std::string& device_id, |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 ScopedAudioManagerPtr CreateAudioManager( | 1086 ScopedAudioManagerPtr CreateAudioManager( |
| 1081 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 1087 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 1082 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 1088 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 1083 AudioLogFactory* audio_log_factory) { | 1089 AudioLogFactory* audio_log_factory) { |
| 1084 return ScopedAudioManagerPtr( | 1090 return ScopedAudioManagerPtr( |
| 1085 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), | 1091 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), |
| 1086 audio_log_factory)); | 1092 audio_log_factory)); |
| 1087 } | 1093 } |
| 1088 | 1094 |
| 1089 } // namespace media | 1095 } // namespace media |
| OLD | NEW |