OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_AUDIO_TRACK_OUTPUT_STREAM_H_ |
| 6 #define MEDIA_AUDIO_ANDROID_AUDIO_TRACK_OUTPUT_STREAM_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/android/jni_android.h" |
| 11 #include "base/time/tick_clock.h" |
| 12 #include "media/audio/android/muteable_audio_output_stream.h" |
| 13 #include "media/base/audio_parameters.h" |
| 14 |
| 15 namespace media { |
| 16 |
| 17 class AudioManagerBase; |
| 18 |
| 19 // A MuteableAudioOutputStream implementation based on the Android AudioTrack |
| 20 // API. |
| 21 class MEDIA_EXPORT AudioTrackOutputStream : public MuteableAudioOutputStream { |
| 22 public: |
| 23 AudioTrackOutputStream(AudioManagerBase* manager, |
| 24 const AudioParameters& params); |
| 25 ~AudioTrackOutputStream() override; |
| 26 |
| 27 // AudioOutputStream implementation. |
| 28 bool Open() override; |
| 29 void Start(AudioSourceCallback* callback) override; |
| 30 void Stop() override; |
| 31 void SetVolume(double volume) override; |
| 32 void GetVolume(double* volume) override; |
| 33 void Close() override; |
| 34 |
| 35 // MuteableAudioOutputStream implementation. |
| 36 void SetMute(bool muted) override; |
| 37 |
| 38 // JNI registry. |
| 39 static bool RegisterAudioTrackOutputStream(JNIEnv* env); |
| 40 |
| 41 // AudioOutputStream::SourceCallback implementation methods called from Java. |
| 42 int OnMoreData(JNIEnv* env, jobject obj, jobject audio_data, int delay); |
| 43 void OnError(JNIEnv* env, jobject obj); |
| 44 |
| 45 private: |
| 46 const AudioParameters params_; |
| 47 |
| 48 AudioManagerBase* audio_manager_; |
| 49 AudioSourceCallback* callback_; |
| 50 std::unique_ptr<AudioBus> audio_bus_; |
| 51 bool muted_; |
| 52 double volume_; |
| 53 int total_read_frames_; |
| 54 |
| 55 std::unique_ptr<base::TickClock> tick_clock_; |
| 56 |
| 57 // Java AudioTrackOutputStream instance. |
| 58 base::android::ScopedJavaGlobalRef<jobject> j_audio_output_stream_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(AudioTrackOutputStream); |
| 61 }; |
| 62 |
| 63 } // namespace media |
| 64 |
| 65 #endif // MEDIA_AUDIO_ANDROID_AUDIO_TRACK_OUTPUT_STREAM_H_ |
OLD | NEW |