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

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: merged GetPreferredLowLatencyOutputStreamParameters to GetDefaultOutputStreamParameters 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
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(
DaleCurtis 2013/03/02 01:53:56 Shouldn't these just be NOTREACHED() right now?
no longer working on chromium 2013/03/04 14:55:04 I am not sure here. audio_util.cc methods cover th
53 const AudioParameters& input_params) {
54 // TODO(xians): handle the case when input_params is valid.
55 // TODO(xians): figure out the right output sample rate and sample rate to
56 // achieve the best audio performance for iOS devices.
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
64 AudioParameters AudioManagerIOS::GetInputStreamParameters(
65 const std::string& device_id) {
66 // TODO(xians): figure out the right input sample rate and buffer size to
67 // achieve the best audio performance for iOS devices.
68 // TODO(xians): query the native channel layout for the specific device.
69 static const int kDefaultSampleRate = 48000;
70 static const int kDefaultBufferSize = 2048
71 return AudioParameters(
72 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
73 kDefaultSampleRate, 16, kDefaultBufferSize);
74 }
75
50 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream( 76 AudioOutputStream* AudioManagerIOS::MakeAudioOutputStream(
51 const AudioParameters& params) { 77 const AudioParameters& params) {
52 NOTIMPLEMENTED(); // Only input is supported on iOS. 78 NOTIMPLEMENTED(); // Only input is supported on iOS.
53 return NULL; 79 return NULL;
54 } 80 }
55 81
56 AudioInputStream* AudioManagerIOS::MakeAudioInputStream( 82 AudioInputStream* AudioManagerIOS::MakeAudioInputStream(
57 const AudioParameters& params, const std::string& device_id) { 83 const AudioParameters& params, const std::string& device_id) {
58 // Current line of iOS devices has only one audio input. 84 // Current line of iOS devices has only one audio input.
59 // Ignore the device_id (unittest uses a test value in it). 85 // 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) { 125 void AudioManagerIOS::ReleaseInputStream(AudioInputStream* stream) {
100 delete stream; 126 delete stream;
101 } 127 }
102 128
103 // static 129 // static
104 AudioManager* CreateAudioManager() { 130 AudioManager* CreateAudioManager() {
105 return new AudioManagerIOS(); 131 return new AudioManagerIOS();
106 } 132 }
107 133
108 } // namespace media 134 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698