aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/android/cubeb_media_library.h
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2023-08-17 17:09:14 +0200
committerPaul Adenot <[email protected]>2023-08-25 20:09:58 +0200
commit33ade008b5befa3a56871e61078d5a5d923bcbf8 (patch)
tree8915e355e16088197747e9659234f42218299913 /src/android/cubeb_media_library.h
parentac8474a5929e9de3bce84f16f8c589240eb9f7c4 (diff)
downloadcubeb-33ade008b5befa3a56871e61078d5a5d923bcbf8.tar.gz
cubeb-33ade008b5befa3a56871e61078d5a5d923bcbf8.zip
OpenSLES: compile as C++
Diffstat (limited to 'src/android/cubeb_media_library.h')
-rw-r--r--src/android/cubeb_media_library.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/android/cubeb_media_library.h b/src/android/cubeb_media_library.h
index 27fbc86..c7aecc5 100644
--- a/src/android/cubeb_media_library.h
+++ b/src/android/cubeb_media_library.h
@@ -1,9 +1,15 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <cassert>
+#include <cstdint>
#ifndef _CUBEB_MEDIA_LIBRARY_H_
#define _CUBEB_MEDIA_LIBRARY_H_
+typedef int32_t (*get_output_latency_ptr)(uint32_t * latency, int stream_type);
+
struct media_lib {
void * libmedia;
- int32_t (*get_output_latency)(uint32_t * latency, int stream_type);
+ get_output_latency_ptr get_output_latency;
};
typedef struct media_lib media_lib;
@@ -11,30 +17,30 @@ typedef struct media_lib media_lib;
media_lib *
cubeb_load_media_library()
{
- media_lib ml = {0};
+ media_lib ml = {};
ml.libmedia = dlopen("libmedia.so", RTLD_LAZY);
if (!ml.libmedia) {
- return NULL;
+ return nullptr;
}
// Get the latency, in ms, from AudioFlinger. First, try the most recent
// signature. status_t AudioSystem::getOutputLatency(uint32_t* latency,
// audio_stream_type_t streamType)
- ml.get_output_latency = dlsym(
+ ml.get_output_latency = (get_output_latency_ptr)dlsym(
ml.libmedia,
"_ZN7android11AudioSystem16getOutputLatencyEPj19audio_stream_type_t");
if (!ml.get_output_latency) {
// In case of failure, try the signature from legacy version.
// status_t AudioSystem::getOutputLatency(uint32_t* latency, int streamType)
ml.get_output_latency =
- dlsym(ml.libmedia, "_ZN7android11AudioSystem16getOutputLatencyEPji");
+ (get_output_latency_ptr)dlsym(ml.libmedia, "_ZN7android11AudioSystem16getOutputLatencyEPji");
if (!ml.get_output_latency) {
- return NULL;
+ return nullptr;
}
}
- media_lib * rv = NULL;
- rv = calloc(1, sizeof(media_lib));
+ media_lib * rv = nullptr;
+ rv = (media_lib*) calloc(1, sizeof(media_lib));
assert(rv);
*rv = ml;
return rv;