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 #include "webrtc/base/checks.h" | 11 #include "webrtc/modules/audio_device/android/helpers_android.h" |
12 #include "webrtc/modules/utility/include/helpers_android.h" | |
13 | 12 |
14 #include <android/log.h> | 13 #include <android/log.h> |
15 #include <assert.h> | 14 #include <assert.h> |
16 #include <pthread.h> | 15 #include <pthread.h> |
17 #include <stddef.h> | 16 #include <stddef.h> |
18 #include <unistd.h> | 17 #include <unistd.h> |
19 | 18 |
20 #define TAG "HelpersAndroid" | 19 #define TAG "HelpersAndroid" |
21 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) | 20 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) |
22 | 21 |
(...skipping 15 matching lines...) Expand all Loading... |
38 static_assert(sizeof(intptr_t) <= sizeof(jlong), | 37 static_assert(sizeof(intptr_t) <= sizeof(jlong), |
39 "Time to rethink the use of jlongs"); | 38 "Time to rethink the use of jlongs"); |
40 // Going through intptr_t to be obvious about the definedness of the | 39 // Going through intptr_t to be obvious about the definedness of the |
41 // conversion from pointer to integral type. intptr_t to jlong is a standard | 40 // conversion from pointer to integral type. intptr_t to jlong is a standard |
42 // widening by the static_assert above. | 41 // widening by the static_assert above. |
43 jlong ret = reinterpret_cast<intptr_t>(ptr); | 42 jlong ret = reinterpret_cast<intptr_t>(ptr); |
44 RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr); | 43 RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr); |
45 return ret; | 44 return ret; |
46 } | 45 } |
47 | 46 |
48 jmethodID GetMethodID ( | 47 jmethodID GetMethodID( |
49 JNIEnv* jni, jclass c, const char* name, const char* signature) { | 48 JNIEnv* jni, jclass c, const char* name, const char* signature) { |
50 jmethodID m = jni->GetMethodID(c, name, signature); | 49 jmethodID m = jni->GetMethodID(c, name, signature); |
51 CHECK_EXCEPTION(jni) << "Error during GetMethodID: " << name << ", " | 50 CHECK_EXCEPTION(jni) << "Error during GetMethodID: " << name << ", " |
52 << signature; | 51 << signature; |
53 RTC_CHECK(m) << name << ", " << signature; | 52 RTC_CHECK(m) << name << ", " << signature; |
54 return m; | 53 return m; |
55 } | 54 } |
56 | 55 |
57 jmethodID GetStaticMethodID ( | 56 jmethodID GetStaticMethodID( |
58 JNIEnv* jni, jclass c, const char* name, const char* signature) { | 57 JNIEnv* jni, jclass c, const char* name, const char* signature) { |
59 jmethodID m = jni->GetStaticMethodID(c, name, signature); | 58 jmethodID m = jni->GetStaticMethodID(c, name, signature); |
60 CHECK_EXCEPTION(jni) << "Error during GetStaticMethodID: " << name << ", " | 59 CHECK_EXCEPTION(jni) << "Error during GetStaticMethodID: " << name << ", " |
61 << signature; | 60 << signature; |
62 RTC_CHECK(m) << name << ", " << signature; | 61 RTC_CHECK(m) << name << ", " << signature; |
63 return m; | 62 return m; |
64 } | 63 } |
65 | 64 |
66 jclass FindClass(JNIEnv* jni, const char* name) { | 65 jclass FindClass(JNIEnv* jni, const char* name) { |
67 jclass c = jni->FindClass(name); | 66 jclass c = jni->FindClass(name); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ALOGD("Detaching thread from JVM%s", GetThreadInfo().c_str()); | 113 ALOGD("Detaching thread from JVM%s", GetThreadInfo().c_str()); |
115 jint res = jvm_->DetachCurrentThread(); | 114 jint res = jvm_->DetachCurrentThread(); |
116 RTC_CHECK(res == JNI_OK) << "DetachCurrentThread failed: " << res; | 115 RTC_CHECK(res == JNI_OK) << "DetachCurrentThread failed: " << res; |
117 RTC_CHECK(!GetEnv(jvm_)); | 116 RTC_CHECK(!GetEnv(jvm_)); |
118 } | 117 } |
119 } | 118 } |
120 | 119 |
121 JNIEnv* AttachThreadScoped::env() { return env_; } | 120 JNIEnv* AttachThreadScoped::env() { return env_; } |
122 | 121 |
123 } // namespace webrtc | 122 } // namespace webrtc |
OLD | NEW |