Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: media/audio/ios/audio_manager_ios.mm

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/ios/audio_manager_ios.h ('k') | media/audio/linux/audio_manager_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/ios/audio_manager_ios.h" 5 #include "media/audio/ios/audio_manager_ios.h"
6 6
7 #import <AudioToolbox/AudioToolbox.h> 7 #import <AudioToolbox/AudioToolbox.h>
8 #import <AVFoundation/AVFoundation.h> 8 #import <AVFoundation/AVFoundation.h>
9 9
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
11 #include "media/audio/audio_parameters.h"
11 #include "media/audio/fake_audio_input_stream.h" 12 #include "media/audio/fake_audio_input_stream.h"
12 #include "media/audio/ios/audio_session_util_ios.h" 13 #include "media/audio/ios/audio_session_util_ios.h"
13 #include "media/audio/mac/audio_input_mac.h" 14 #include "media/audio/mac/audio_input_mac.h"
15 #include "media/base/channel_layout.h"
14 #include "media/base/limits.h" 16 #include "media/base/limits.h"
15 17
16 namespace media { 18 namespace media {
17 19
18 enum { kMaxInputChannels = 2 }; 20 enum { kMaxInputChannels = 2 };
19 21
20 AudioManagerIOS::AudioManagerIOS() { 22 AudioManagerIOS::AudioManagerIOS() {
21 } 23 }
22 24
23 AudioManagerIOS::~AudioManagerIOS() { 25 AudioManagerIOS::~AudioManagerIOS() {
(...skipping 16 matching lines...) Expand all
40 if (error != kAudioSessionNoError) 42 if (error != kAudioSessionNoError)
41 return false; 43 return false;
42 UInt32 audio_input_is_available = false; 44 UInt32 audio_input_is_available = false;
43 DCHECK(property_size == sizeof(audio_input_is_available)); 45 DCHECK(property_size == sizeof(audio_input_is_available));
44 error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, 46 error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable,
45 &property_size, 47 &property_size,
46 &audio_input_is_available); 48 &audio_input_is_available);
47 return error == kAudioSessionNoError ? audio_input_is_available : false; 49 return error == kAudioSessionNoError ? audio_input_is_available : false;
48 } 50 }
49 51
52 AudioParameters AudioManagerIOS::GetInputStreamParameters(
53 const std::string& device_id) {
54 // TODO(xians): figure out the right input sample rate and buffer size to
55 // achieve the best audio performance for iOS devices.
56 // TODO(xians): query the native channel layout for the specific device.
57 static const int kDefaultSampleRate = 48000;
58 static const int kDefaultBufferSize = 2048;
59 return AudioParameters(
60 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
61 kDefaultSampleRate, 16, kDefaultBufferSize);
62 }
63
50 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream( 64 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream(
51 const AudioParameters& params) { 65 const AudioParameters& params) {
52 NOTIMPLEMENTED(); // Only input is supported on iOS. 66 NOTIMPLEMENTED(); // Only input is supported on iOS.
53 return NULL; 67 return NULL;
54 } 68 }
55 69
56 AudioInputStream* AudioManagerIOS::MakeAudioInputStream( 70 AudioInputStream* AudioManagerIOS::MakeAudioInputStream(
57 const AudioParameters& params, const std::string& device_id) { 71 const AudioParameters& params, const std::string& device_id) {
58 // Current line of iOS devices has only one audio input. 72 // Current line of iOS devices has only one audio input.
59 // Ignore the device_id (unittest uses a test value in it). 73 // Ignore the device_id (unittest uses a test value in it).
(...skipping 23 matching lines...) Expand all
83 const AudioParameters& params, const std::string& device_id) { 97 const AudioParameters& params, const std::string& device_id) {
84 return MakeAudioInputStream(params, device_id); 98 return MakeAudioInputStream(params, device_id);
85 } 99 }
86 100
87 AudioInputStream* AudioManagerIOS::MakeLowLatencyInputStream( 101 AudioInputStream* AudioManagerIOS::MakeLowLatencyInputStream(
88 const AudioParameters& params, const std::string& device_id) { 102 const AudioParameters& params, const std::string& device_id) {
89 NOTIMPLEMENTED(); // Only linear audio input is supported on iOS. 103 NOTIMPLEMENTED(); // Only linear audio input is supported on iOS.
90 return MakeAudioInputStream(params, device_id); 104 return MakeAudioInputStream(params, device_id);
91 } 105 }
92 106
107
108 AudioParameters AudioManagerIOS::GetPreferredOutputStreamParameters(
109 const AudioParameters& input_params) {
110 // TODO(xians): handle the case when input_params is valid.
111 // TODO(xians): figure out the right output sample rate and sample rate to
112 // achieve the best audio performance for iOS devices.
113 static const int kDefaultSampleRate = 48000;
114 static const int kDefaultBufferSize = 2048;
115 if (input_params.IsValid()) {
116 NOTREACHED();
117 }
118 return AudioParameters(
119 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
120 kDefaultSampleRate, 16, kDefaultBufferSize);
121 }
122
93 // Called by the stream when it has been released by calling Close(). 123 // Called by the stream when it has been released by calling Close().
94 void AudioManagerIOS::ReleaseOutputStream(AudioOutputStream* stream) { 124 void AudioManagerIOS::ReleaseOutputStream(AudioOutputStream* stream) {
95 NOTIMPLEMENTED(); // Only input is supported on iOS. 125 NOTIMPLEMENTED(); // Only input is supported on iOS.
96 } 126 }
97 127
98 // Called by the stream when it has been released by calling Close(). 128 // Called by the stream when it has been released by calling Close().
99 void AudioManagerIOS::ReleaseInputStream(AudioInputStream* stream) { 129 void AudioManagerIOS::ReleaseInputStream(AudioInputStream* stream) {
100 delete stream; 130 delete stream;
101 } 131 }
102 132
103 // static 133 // static
104 AudioManager* CreateAudioManager() { 134 AudioManager* CreateAudioManager() {
105 return new AudioManagerIOS(); 135 return new AudioManagerIOS();
106 } 136 }
107 137
108 } // namespace media 138 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/ios/audio_manager_ios.h ('k') | media/audio/linux/audio_manager_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698