From 2565b0e28ff2c58dd3f34624a71c7a2acaac0a0a Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Fri, 9 Dec 2022 11:43:18 +1100 Subject: Initial working Obj-C sound (leak) It seems to memory leak so needs to be fixed, but this was before I had to return my work MacBook - until I get my own! --- platform/darwin.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'platform/darwin.c') diff --git a/platform/darwin.c b/platform/darwin.c index 820c012..3189a5d 100644 --- a/platform/darwin.c +++ b/platform/darwin.c @@ -3,6 +3,7 @@ #include #include +#include "darwin-native.bridging.h" #include "platform.h" #include "../board/board.h" @@ -11,24 +12,18 @@ extern void keyboard_on_down(void); extern void keyboard_on_up(void); -static float volume = 0; static IOHIDManagerRef hid_manager = NULL; -bool sound_init(float _volume) +bool sound_init(float volume) { - volume = _volume; - - /* TODO: Init sound, NSCache probably too via bridge? */ - - return true; + /* Call Obj-C function */ + return macos_sound_init(volume); } void sound_play(unsigned char *buffer, unsigned int buffer_len) { - (void) buffer; - (void) buffer_len; - - /* TODO: Play the sound via obj-c for now */ + /* Call Obj-C function */ + macos_sound_play(buffer, buffer_len); } /* TODO: Maybe merge some of this stuff with linux, lots of overlap */ @@ -97,7 +92,7 @@ void hid_callback(void *context, IOReturn result, void *sender, IOHIDValueRef va /* seems like getting 'int value' is if it is key up or down * true(1) = down */ bool key_down = IOHIDValueGetIntegerValue(value) == 1; - printf(">>> value: %d, down: %d\n", scancode, key_down); + // printf(">>> value: %d, down: %d\n", scancode, key_down); if (key_down) keyboard_on_down(); else -- cgit