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

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

Issue 8718014: Upstream: Media implementation for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years 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) 2011 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_AUDIO_TRACK_OUTPUT_ANDROID_H_
6 #define MEDIA_AUDIO_AUDIO_TRACK_OUTPUT_ANDROID_H_
7
8 #include <jni.h>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/timer.h"
14 #include "media/audio/audio_io.h"
15 #include "media/audio/audio_parameters.h"
16
17 class AudioManagerAndroid;
18
19 // Implements PCM audio output support for Android using the AudioTrack API.
20 class AudioTrackOutputStream : public AudioOutputStream {
21 public:
22 enum Status {
23 IDLE,
24 OPENED,
25 PLAYING,
26 INVALID
27 };
28
29 AudioTrackOutputStream(const AudioParameters& params);
scherkus (not reviewing) 2011/12/01 19:01:14 explicit
michaelbai 2011/12/01 20:48:18 Done.
30
31 virtual ~AudioTrackOutputStream();
32
33 // Implementation of AudioOutputStream.
34 virtual bool Open() OVERRIDE;
35 virtual void Close() OVERRIDE;
36 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
37 virtual void Stop() OVERRIDE;
38 virtual void SetVolume(double volume) OVERRIDE;
39 virtual void GetVolume(double* volume) OVERRIDE;
40
41 static AudioOutputStream* MakeStream(AudioManagerAndroid* manager,
42 const AudioParameters& params);
43
44 private:
45 // Helper methods to invoke Java methods on |j_audio_track_|.
46 void CallVoidMethod(std::string method_name);
47
48 // Get the value of static field.
49 jint GetStaticIntField(std::string class_name, std::string field_name);
50
51 // Feed more data to AudioTrack.
52 void FillAudioBufferTask();
53
54 AudioSourceCallback* source_callback_;
55 AudioParameters params_;
56
57 class StreamBuffer;
58 scoped_ptr<StreamBuffer> data_buffer_;
59 Status status_;
60 double volume_;
61 int buffer_size_;
62
63 // Java AudioTrack class and instance.
64 jclass j_class_;
65 jobject j_audio_track_;
66
67 base::RepeatingTimer<AudioTrackOutputStream> timer_;
68
69 DISALLOW_COPY_AND_ASSIGN(AudioTrackOutputStream);
70 };
71
72 #endif // MEDIA_AUDIO_AUDIO_TRACK_OUTPUT_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698