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

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: Created 7 years, 10 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
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::GetDefaultOutputStreamParameters() {
53 // TODO(xians): figure out the right output sample rate and sample rate to
54 // achieve the best audio performance for iOS devices.
55 static const int kDefaultSampleRate = 48000;
56 static const int kDefaultBufferSize = 2048
57 return AudioParameters(
58 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
59 kDefaultSampleRate, 16, kDefaultBufferSize);
60 }
61
62 AudioParameters AudioManagerIOS::GetDefaultInputStreamParameters(
63 const std::string& device_id) {
64 // TODO(xians): figure out the right input sample rate and buffer size to
65 // achieve the best audio performance for iOS devices.
66 // TODO(xians): query the native channel layout for the specific device.
67 static const int kDefaultSampleRate = 48000;
68 static const int kDefaultBufferSize = 2048
69 return AudioParameters(
70 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
71 kDefaultSampleRate, 16, kDefaultBufferSize);
72 }
73
50 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream( 74 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream(
51 const AudioParameters& params) { 75 const AudioParameters& params) {
52 NOTIMPLEMENTED(); // Only input is supported on iOS. 76 NOTIMPLEMENTED(); // Only input is supported on iOS.
53 return NULL; 77 return NULL;
54 } 78 }
55 79
56 AudioInputStream* AudioManagerIOS::MakeAudioInputStream( 80 AudioInputStream* AudioManagerIOS::MakeAudioInputStream(
57 const AudioParameters& params, const std::string& device_id) { 81 const AudioParameters& params, const std::string& device_id) {
58 // Current line of iOS devices has only one audio input. 82 // Current line of iOS devices has only one audio input.
59 // Ignore the device_id (unittest uses a test value in it). 83 // Ignore the device_id (unittest uses a test value in it).
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void AudioManagerIOS::ReleaseInputStream(AudioInputStream* stream) { 123 void AudioManagerIOS::ReleaseInputStream(AudioInputStream* stream) {
100 delete stream; 124 delete stream;
101 } 125 }
102 126
103 // static 127 // static
104 AudioManager* CreateAudioManager() { 128 AudioManager* CreateAudioManager() {
105 return new AudioManagerIOS(); 129 return new AudioManagerIOS();
106 } 130 }
107 131
108 } // namespace media 132 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698