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

Unified Diff: media/audio/android/audio_track_output_stream.h

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..dd4880462cd7a8f7f5eb04d8ca44b3fc540e009c
--- /dev/null
+++ b/media/audio/android/audio_track_output_stream.h
@@ -0,0 +1,65 @@
+// Copyright 2016 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_;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698