From 8a6ff3db12aed355959074a04c20d36922c544d5 Mon Sep 17 00:00:00 2001 From: EinTim23 Date: Tue, 5 Nov 2024 11:33:18 +0100 Subject: [PATCH] mac os --- src/backends/darwin.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backends/darwin.mm b/src/backends/darwin.mm index fc8f1ec..e9fb827 100644 --- a/src/backends/darwin.mm +++ b/src/backends/darwin.mm @@ -1,24 +1,31 @@ #ifdef __APPLE__ #include #include +#include #include "../MediaRemote.hpp" #include "../backend.hpp" std::shared_ptr backend::getMediaInformation() { + std::string appName = ""; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); MRMediaRemoteGetNowPlayingApplicationPID(dispatch_get_main_queue(), ^(pid_t pid) { if (pid > 0) { NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:pid]; - if (app) { - NSLog(@"%@", app.bundleIdentifier); - } + if (app) + appName = app.bundleIdentifier } + dispatch_semaphore_signal(semaphore); }); MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(CFDictionaryRef result) { if (result) { NSDictionary *playingInfo = (__bridge NSDictionary *)(result); NSLog(@"Now Playing Info: %@", playingInfo); } + dispatch_semaphore_signal(semaphore); }); + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + dispatch_release(semaphore); return nullptr; } bool backend::toggleAutostart(bool enabled) { return false; }