Index: media/audio/android/audio_track_output_stream.h |
diff --git a/media/audio/android/audio_track_output_stream.h b/media/audio/android/audio_track_output_stream.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..30b704dae789902e2fb44fe695b77cc310f8670d |
--- /dev/null |
+++ b/media/audio/android/audio_track_output_stream.h |
@@ -0,0 +1,65 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_AUDIO_ANDROID_AUDIO_TRACK_OUTPUT_STREAM_H_ |
+#define MEDIA_AUDIO_ANDROID_AUDIO_TRACK_OUTPUT_STREAM_H_ |
+ |
+#include <memory> |
+ |
+#include "base/android/jni_android.h" |
+#include "base/time/tick_clock.h" |
+#include "media/audio/android/muteable_audio_output_stream.h" |
+#include "media/base/audio_parameters.h" |
+ |
+namespace media { |
+ |
+class AudioManagerBase; |
+ |
+// A MuteableAudioOutputStream implementation based on the Android AudioTrack |
+// API. |
+class MEDIA_EXPORT AudioTrackOutputStream : public MuteableAudioOutputStream { |
+ public: |
+ AudioTrackOutputStream(AudioManagerBase* manager, |
+ const AudioParameters& params); |
+ ~AudioTrackOutputStream() override; |
+ |
+ // AudioOutputStream implementation. |
+ bool Open() override; |
+ void Start(AudioSourceCallback* callback) override; |
+ void Stop() override; |
+ void SetVolume(double volume) override; |
+ void GetVolume(double* volume) override; |
+ void Close() override; |
+ |
+ // MuteableAudioOutputStream implementation. |
+ void SetMute(bool muted) override; |
+ |
+ // JNI registry. |
+ static bool RegisterAudioTrackOutputStream(JNIEnv* env); |
+ |
+ // AudioOutputStream::SourceCallback implementation methods called from Java. |
+ int OnMoreData(JNIEnv* env, jobject obj, jobject audio_data, int delay); |
+ void OnError(JNIEnv* env, jobject obj); |
+ |
+ private: |
+ const AudioParameters params_; |
+ |
+ AudioManagerBase* audio_manager_; |
+ AudioSourceCallback* callback_; |
+ std::unique_ptr<AudioBus> audio_bus_; |
+ bool muted_; |
+ double volume_; |
+ int total_read_frames_; |
chcunningham
2017/06/14 20:27:21
At sample rate of 44.1 you can only do about 13 ho
AndyWu
2017/08/02 01:43:39
Done.
|
+ |
+ std::unique_ptr<base::TickClock> tick_clock_; |
+ |
+ // Java AudioTrackOutputStream instance. |
+ base::android::ScopedJavaGlobalRef<jobject> j_audio_output_stream_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioTrackOutputStream); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_AUDIO_ANDROID_AUDIO_TRACK_OUTPUT_STREAM_H_ |