From 0d671d46f84d71d6751ca7aef03d08b5a205ec98 Mon Sep 17 00:00:00 2001 From: fduncanh Date: Sat, 4 Dec 2021 05:37:59 -0500 Subject: [PATCH] new format in API for setting plist variables --- lib/raop.c | 31 +++++++++++++++++++++++-------- lib/raop.h | 3 +-- uxplay.cpp | 8 ++++++-- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/raop.c b/lib/raop.c index 4076838..81a8c14 100755 --- a/lib/raop.c +++ b/lib/raop.c @@ -401,15 +401,30 @@ raop_set_log_level(raop_t *raop, int level) { logger_set_level(raop->logger, level); } -void raop_set_display(raop_t *raop, unsigned short width, unsigned short height, - unsigned short refreshRate, unsigned short maxFPS, unsigned short overscanned){ +int raop_set_plist(raop_t *raop, const char *plist_item, const int value) { + int retval = 0; assert(raop); - - if (width) raop->width = (uint16_t) width; - if (height) raop->height = (uint16_t) height; - if (refreshRate && refreshRate < 256) raop->refreshRate = (uint8_t) refreshRate; - if (maxFPS && maxFPS < 256) raop->maxFPS = (uint8_t) maxFPS; - if (overscanned) raop->overscanned = 1; + assert(plist_item); + + if (strcmp(plist_item,"width") == 0) { + raop->width = (uint16_t) value; + if ((int) raop->width != value) retval = 1; + } else if (strcmp(plist_item,"height") == 0) { + raop->height = (uint16_t) value; + if ((int) raop->height != value) retval = 1; + } else if (strcmp(plist_item,"refreshRate") == 0) { + raop->refreshRate = (uint8_t) value; + if ((int) raop->refreshRate != value) retval = 1; + } else if (strcmp(plist_item,"maxFPS") == 0) { + raop->maxFPS = (uint8_t) value; + if ((int) raop->maxFPS != value) retval = 1; + } else if (strcmp(plist_item,"overscanned") == 0) { + raop->overscanned = (uint8_t) (value ? 1 : 0); + if ((int) raop->overscanned != value) retval = 1; + } else { + retval = -1; + } + return retval; } void diff --git a/lib/raop.h b/lib/raop.h index 3fc7063..8154606 100755 --- a/lib/raop.h +++ b/lib/raop.h @@ -57,8 +57,7 @@ RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks); RAOP_API void raop_set_log_level(raop_t *raop, int level); RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls); -RAOP_API void raop_set_display(raop_t *raop, unsigned short width, unsigned short height, - unsigned short refreshRate, unsigned short maxFPS, unsigned short overscanned); +RAOP_API int raop_set_plist(raop_t *raop, const char *plist_item, const int value); RAOP_API void raop_set_port(raop_t *raop, unsigned short port); RAOP_API void raop_set_udp_ports(raop_t *raop, unsigned short port[3]); RAOP_API void raop_set_tcp_ports(raop_t *raop, unsigned short port[2]); diff --git a/uxplay.cpp b/uxplay.cpp index c565d75..6e08a47 100755 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -603,8 +603,12 @@ int start_raop_server (std::vector hw_addr, std::string name, unsigned sho /* write desired display pixel width, pixel height, refresh_rate, max_fps, overscanned. */ /* use 0 for default values 1920,1080,60,30,0; these are sent to the Airplay client */ - - raop_set_display(raop, display[0], display[1], display[2], display[3], display[4]); + + if (display[0]) raop_set_plist(raop, "width", (int) display[0]); + if (display[1]) raop_set_plist(raop, "height", (int) display[1]); + if (display[2]) raop_set_plist(raop, "refreshRate", (int) display[2]); + if (display[3]) raop_set_plist(raop, "maxFPS", (int) display[3]); + if (display[4]) raop_set_plist(raop, "overscanned", (int) display[4]); /* network port selection (ports listed as "0" will be dynamically assigned) */ raop_set_tcp_ports(raop, tcp);