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

Side by Side Diff: media/audio/android/opensles_input.h

Issue 9655023: Adding input and output audio backend to Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased && addressed qinmin's comments Created 8 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_AUDIO_ANDROID_OPENSLES_INPUT_H_
6 #define MEDIA_AUDIO_ANDROID_OPENSLES_INPUT_H_
7
8 #include "base/compiler_specific.h"
9 #include "media/audio/audio_io.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/audio/android/opensles_util.h"
12 #include <SLES/OpenSLES_Android.h>
13
14 class AudioManagerAndroid;
15
16 // Implements PCM audio input support for Android using the OpenSLES API.
17 class OpenSLESInputStream : public AudioInputStream {
18 public:
19 static const int kNumOfQueuesInBuffer = 2;
20
21 OpenSLESInputStream(AudioManagerAndroid* manager,
22 const AudioParameters& params);
23
24 virtual ~OpenSLESInputStream();
25
26 // Implementation of AudioInputStream.
27 virtual bool Open() OVERRIDE;
28 virtual void Start(AudioInputCallback* callback) OVERRIDE;
29 virtual void Stop() OVERRIDE;
30 virtual void Close() OVERRIDE;
31 virtual double GetMaxVolume() OVERRIDE;
32 virtual void SetVolume(double volume) OVERRIDE;
33 virtual double GetVolume() OVERRIDE;
34 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
35 virtual bool GetAutomaticGainControl() OVERRIDE;
36
37 private:
38 bool CreateRecorder();
39
40 static void SimpleBufferQueueCallback(
41 SLAndroidSimpleBufferQueueItf buffer_queue, void* instance);
42
43 void ReadBufferQueue();
44
45 // If OpenSLES reports an error this function handles it and passes it to
46 // the attached AudioInputCallback::OnError().
47 void HandleError(SLresult error);
48
49 AudioManagerAndroid* audio_manager_;
50
51 AudioInputCallback* callback_;
52
53 // Shared engine interfaces for the app.
54 media::ScopedSLObjectItf recorder_object_;
55 media::ScopedSLObjectItf engine_object_;
56
57 SLRecordItf recorder_;
58
59 // Buffer queue recorder interface.
60 SLAndroidSimpleBufferQueueItf simple_buffer_queue_;
61
62 SLDataFormat_PCM format_;
63
64 // Audio buffers that are allocated in the constructor based on
65 // info from audio parameters.
66 uint8* audio_data_[kNumOfQueuesInBuffer];
67
68 int active_queue_;
69 int buffer_size_bytes_;
70
71 bool started_;
72
73 DISALLOW_COPY_AND_ASSIGN(OpenSLESInputStream);
74 };
75
76 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_INPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698