android_os_MessageQueue: move looper prototypes to header, fix incorrect prototype

This commit is contained in:
Mis012
2024-04-15 23:11:24 +02:00
parent a1df6a43e5
commit f52a221c73
3 changed files with 14 additions and 9 deletions

View File

@@ -7,15 +7,9 @@
#include <glib.h>
#include "../libandroid/looper.h"
#include "generated_headers/android_os_MessageQueue.h"
/* TODO put these in a header */
typedef void ALooper;
ALooper * ALooper_prepare(void);
void ALooper_wake(ALooper *looper);
bool ALooper_isPolling(ALooper *looper);
int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData);
struct native_message_queue {
ALooper *looper;
bool in_callback;
@@ -40,7 +34,7 @@ JNIEXPORT jlong JNICALL Java_android_os_MessageQueue_nativeInit(JNIEnv *env, jcl
struct native_message_queue *message_queue = malloc(sizeof(struct native_message_queue));
message_queue->in_callback = false;
message_queue->looper = ALooper_prepare();
message_queue->looper = ALooper_prepare(0);
message_queue->is_main_thread = g_thread_self() == main_thread_id;
return _INTPTR(message_queue);

View File

@@ -2,7 +2,8 @@
#include <stddef.h>
#include <stdio.h>
typedef void ALooper;
#include "looper.h"
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
// dummy strong pointer class

10
src/libandroid/looper.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef LOOPER_H
#define LOOPER_H
typedef void ALooper;
ALooper * ALooper_prepare(int opts);
void ALooper_wake(ALooper *looper);
bool ALooper_isPolling(ALooper *looper);
int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData);
#endif