OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ |
13 | 13 |
| 14 #include <memory> |
| 15 |
14 #include <jni.h> | 16 #include <jni.h> |
15 | 17 |
16 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
17 #include "webrtc/modules/audio_device/android/audio_common.h" | 19 #include "webrtc/modules/audio_device/android/audio_common.h" |
18 #include "webrtc/modules/audio_device/android/audio_manager.h" | 20 #include "webrtc/modules/audio_device/android/audio_manager.h" |
19 #include "webrtc/modules/audio_device/include/audio_device_defines.h" | 21 #include "webrtc/modules/audio_device/include/audio_device_defines.h" |
20 #include "webrtc/modules/audio_device/audio_device_generic.h" | 22 #include "webrtc/modules/audio_device/audio_device_generic.h" |
21 #include "webrtc/modules/utility/include/helpers_android.h" | 23 #include "webrtc/modules/utility/include/helpers_android.h" |
22 #include "webrtc/modules/utility/include/jvm_android.h" | 24 #include "webrtc/modules/utility/include/jvm_android.h" |
23 | 25 |
(...skipping 11 matching lines...) Expand all Loading... |
35 // | 37 // |
36 // This class uses AttachCurrentThreadIfNeeded to attach to a Java VM if needed | 38 // This class uses AttachCurrentThreadIfNeeded to attach to a Java VM if needed |
37 // and detach when the object goes out of scope. Additional thread checking | 39 // and detach when the object goes out of scope. Additional thread checking |
38 // guarantees that no other (possibly non attached) thread is used. | 40 // guarantees that no other (possibly non attached) thread is used. |
39 class AudioTrackJni { | 41 class AudioTrackJni { |
40 public: | 42 public: |
41 // Wraps the Java specific parts of the AudioTrackJni into one helper class. | 43 // Wraps the Java specific parts of the AudioTrackJni into one helper class. |
42 class JavaAudioTrack { | 44 class JavaAudioTrack { |
43 public: | 45 public: |
44 JavaAudioTrack(NativeRegistration* native_registration, | 46 JavaAudioTrack(NativeRegistration* native_registration, |
45 rtc::scoped_ptr<GlobalRef> audio_track); | 47 std::unique_ptr<GlobalRef> audio_track); |
46 ~JavaAudioTrack(); | 48 ~JavaAudioTrack(); |
47 | 49 |
48 void InitPlayout(int sample_rate, int channels); | 50 void InitPlayout(int sample_rate, int channels); |
49 bool StartPlayout(); | 51 bool StartPlayout(); |
50 bool StopPlayout(); | 52 bool StopPlayout(); |
51 bool SetStreamVolume(int volume); | 53 bool SetStreamVolume(int volume); |
52 int GetStreamMaxVolume(); | 54 int GetStreamMaxVolume(); |
53 int GetStreamVolume(); | 55 int GetStreamVolume(); |
54 | 56 |
55 private: | 57 private: |
56 rtc::scoped_ptr<GlobalRef> audio_track_; | 58 std::unique_ptr<GlobalRef> audio_track_; |
57 jmethodID init_playout_; | 59 jmethodID init_playout_; |
58 jmethodID start_playout_; | 60 jmethodID start_playout_; |
59 jmethodID stop_playout_; | 61 jmethodID stop_playout_; |
60 jmethodID set_stream_volume_; | 62 jmethodID set_stream_volume_; |
61 jmethodID get_stream_max_volume_; | 63 jmethodID get_stream_max_volume_; |
62 jmethodID get_stream_volume_; | 64 jmethodID get_stream_volume_; |
63 }; | 65 }; |
64 | 66 |
65 explicit AudioTrackJni(AudioManager* audio_manager); | 67 explicit AudioTrackJni(AudioManager* audio_manager); |
66 ~AudioTrackJni(); | 68 ~AudioTrackJni(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 108 |
107 // Stores thread ID in first call to OnGetPlayoutData() from high-priority | 109 // Stores thread ID in first call to OnGetPlayoutData() from high-priority |
108 // thread in Java. Detached during construction of this object. | 110 // thread in Java. Detached during construction of this object. |
109 rtc::ThreadChecker thread_checker_java_; | 111 rtc::ThreadChecker thread_checker_java_; |
110 | 112 |
111 // Calls AttachCurrentThread() if this thread is not attached at construction. | 113 // Calls AttachCurrentThread() if this thread is not attached at construction. |
112 // Also ensures that DetachCurrentThread() is called at destruction. | 114 // Also ensures that DetachCurrentThread() is called at destruction. |
113 AttachCurrentThreadIfNeeded attach_thread_if_needed_; | 115 AttachCurrentThreadIfNeeded attach_thread_if_needed_; |
114 | 116 |
115 // Wraps the JNI interface pointer and methods associated with it. | 117 // Wraps the JNI interface pointer and methods associated with it. |
116 rtc::scoped_ptr<JNIEnvironment> j_environment_; | 118 std::unique_ptr<JNIEnvironment> j_environment_; |
117 | 119 |
118 // Contains factory method for creating the Java object. | 120 // Contains factory method for creating the Java object. |
119 rtc::scoped_ptr<NativeRegistration> j_native_registration_; | 121 std::unique_ptr<NativeRegistration> j_native_registration_; |
120 | 122 |
121 // Wraps the Java specific parts of the AudioTrackJni class. | 123 // Wraps the Java specific parts of the AudioTrackJni class. |
122 rtc::scoped_ptr<AudioTrackJni::JavaAudioTrack> j_audio_track_; | 124 std::unique_ptr<AudioTrackJni::JavaAudioTrack> j_audio_track_; |
123 | 125 |
124 // Contains audio parameters provided to this class at construction by the | 126 // Contains audio parameters provided to this class at construction by the |
125 // AudioManager. | 127 // AudioManager. |
126 const AudioParameters audio_parameters_; | 128 const AudioParameters audio_parameters_; |
127 | 129 |
128 // Cached copy of address to direct audio buffer owned by |j_audio_track_|. | 130 // Cached copy of address to direct audio buffer owned by |j_audio_track_|. |
129 void* direct_buffer_address_; | 131 void* direct_buffer_address_; |
130 | 132 |
131 // Number of bytes in the direct audio buffer owned by |j_audio_track_|. | 133 // Number of bytes in the direct audio buffer owned by |j_audio_track_|. |
132 size_t direct_buffer_capacity_in_bytes_; | 134 size_t direct_buffer_capacity_in_bytes_; |
(...skipping 11 matching lines...) Expand all Loading... |
144 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the | 146 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the |
145 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). | 147 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). |
146 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance | 148 // The AudioDeviceBuffer is a member of the AudioDeviceModuleImpl instance |
147 // and therefore outlives this object. | 149 // and therefore outlives this object. |
148 AudioDeviceBuffer* audio_device_buffer_; | 150 AudioDeviceBuffer* audio_device_buffer_; |
149 }; | 151 }; |
150 | 152 |
151 } // namespace webrtc | 153 } // namespace webrtc |
152 | 154 |
153 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ | 155 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_TRACK_JNI_H_ |
OLD | NEW |