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

Side by Side Diff: media/audio/android/opensles_output.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_OUTPUT_H_
6 #define MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_
7
8 #include <vector>
9
10 #include "base/compiler_specific.h"
11 #include "media/audio/android/opensles_util.h"
12 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_parameters.h"
14 #include <SLES/OpenSLES_Android.h>
15
16 class AudioManagerAndroid;
17
18 // Implements PCM audio output support for Android using the OpenSLES API.
19 class OpenSLESOutputStream : public AudioOutputStream {
20 public:
21 static const int kNumOfQueuesInBuffer = 2;
22
23 OpenSLESOutputStream(AudioManagerAndroid* manager,
24 const AudioParameters& params);
25
26 virtual ~OpenSLESOutputStream();
27
28 // Implementation of AudioOutputStream.
29 virtual bool Open() OVERRIDE;
30 virtual void Close() OVERRIDE;
31 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
32 virtual void Stop() OVERRIDE;
33 virtual void SetVolume(double volume) OVERRIDE;
34 virtual void GetVolume(double* volume) OVERRIDE;
35
36 private:
37 bool CreatePlayer();
38
39 static void SimpleBufferQueueCallback(
40 SLAndroidSimpleBufferQueueItf buffer_queue, void* instance);
41
42 void FillBufferQueue();
43
44 // If OpenSLES reports an error this function handles it and passes it to
45 // the attached AudioOutputCallback::OnError().
46 void HandleError(SLresult error);
47
48 AudioManagerAndroid* audio_manager_;
49
50 AudioSourceCallback* callback_;
51
52 // Shared engine interfaces for the app.
53 media::ScopedSLObjectItf engine_object_;
54 media::ScopedSLObjectItf player_object_;
55 media::ScopedSLObjectItf output_mixer_;
56
57 SLPlayItf player_;
58
59 // Buffer queue recorder interface.
60 SLAndroidSimpleBufferQueueItf simple_buffer_queue_;
61
62 SLDataFormat_PCM format_;
63
64 // Audio buffer arrays that are allocated in the constructor.
65 uint8* audio_data_[kNumOfQueuesInBuffer];
66
67 int active_queue_;
68 size_t buffer_size_bytes_;
69
70 bool started_;
71
72 // Volume level from 0 to 1.
73 float volume_;
74
75 DISALLOW_COPY_AND_ASSIGN(OpenSLESOutputStream);
76 };
77
78 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_INPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698