Debian Codegraph @

core/jni/android_media_AudioAttributes.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #pragma once
18
19 #include "jni.h"
20
21 #include <memory.h>
22
23 #include <system/audio.h>
24
25 namespace android {
26
27 class JNIAudioAttributeHelper
28 {
29 public:
30 struct FreeDeleter {
31 void operator()(void *p) const { ::free(p); }
32 };
33
34 using UniqueAaPtr = std::unique_ptr<audio_attributes_t, FreeDeleter>;
35
36 /**
37 * @brief makeUnique helper to prevent leak
38 * @return a unique ptr of 0-initialized native audio attributes structure
39 */
40 static UniqueAaPtr makeUnique();
41
42 /**
43 * @brief nativeFromJava Gets the underlying AudioAttributes from an AudioAttributes Java
44 * object.
45 * @param env
46 * @param jAudioAttributes JAVA AudioAttribute object
47 * @param paa native AudioAttribute pointer
48 * @return AUDIO_JAVA_SUCCESS on success, error code otherwise
49 */
50 static jint nativeFromJava(
51 JNIEnv* env, jobject jAudioAttributes, audio_attributes_t *attributes);
52
53 /**
54 * @brief nativeToJava AudioAttributes Java object from a native AudioAttributes.
55 * @param env
56 * @param jAudioAttributes JAVA AudioAttribute object
57 * @param attributes native AudioAttribute
58 * @return AUDIO_JAVA_SUCCESS on success, error code otherwise
59 */
60 static jint nativeToJava(
61 JNIEnv* env, jobject *jAudioAttributes, const audio_attributes_t &attributes);
62
63 /**
64 * @brief getJavaArray: creates an array of JAVA AudioAttributes objects
65 * @param env
66 * @param jAudioAttributeArray
67 * @param numAudioAttributes
68 * @return Array of AudioAttributes objects
69 */
70 static jint getJavaArray(
71 JNIEnv* env, jobjectArray *jAudioAttributeArray, jint numAudioAttributes);
72 };
73
74 }; // namespace android