Added option to disable local music playback and to change client socket path

This commit is contained in:
2026-03-15 08:43:32 +10:00
parent 4752ea62d3
commit 57069c8c0e
2 changed files with 29 additions and 0 deletions
+25
View File
@@ -5,6 +5,8 @@
* Info: Configuration Handler * Info: Configuration Handler
*/ */
// TODO REFACTOR with OSS_P*oj
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -68,7 +70,9 @@ int configHandler_Read(configHandler_config_t** configObj) {
(*configObj)->lv2_parax32_frequency_left = NULL; (*configObj)->lv2_parax32_frequency_left = NULL;
(*configObj)->lv2_parax32_frequency_right = NULL; (*configObj)->lv2_parax32_frequency_right = NULL;
(*configObj)->lv2_reverb_filter_name = NULL; (*configObj)->lv2_reverb_filter_name = NULL;
(*configObj)->local_enable = false;
(*configObj)->local_rootdir = NULL; (*configObj)->local_rootdir = NULL;
(*configObj)->client_socket_path = NULL;
// Set internal configuration values // Set internal configuration values
(*configObj)->internal_opensubsonic_version = strdup("1.8.0"); (*configObj)->internal_opensubsonic_version = strdup("1.8.0");
@@ -474,11 +478,31 @@ int configHandler_Read(configHandler_config_t** configObj) {
return 1; return 1;
} }
cJSON* local_enable = cJSON_GetObjectItemCaseSensitive(scrobbler_root, "enable");
if (cJSON_IsBool(local_enable)) {
if (cJSON_IsTrue(local_enable)) {
(*configObj)->local_enable = true;
}
}
cJSON* local_root_directory = cJSON_GetObjectItemCaseSensitive(local_root, "rootDirectory"); cJSON* local_root_directory = cJSON_GetObjectItemCaseSensitive(local_root, "rootDirectory");
if (cJSON_IsString(local_root_directory) && local_root_directory->valuestring != NULL) { if (cJSON_IsString(local_root_directory) && local_root_directory->valuestring != NULL) {
(*configObj)->local_rootdir = strdup(local_root_directory->valuestring); (*configObj)->local_rootdir = strdup(local_root_directory->valuestring);
} }
// Make an object from client
cJSON* client_root = cJSON_GetObjectItemCaseSensitive(root, "client");
if (client_root == NULL) {
logger_log_error(__func__, "Error parsing JSON - client does not exist.");
cJSON_Delete(root);
return 1;
}
cJSON* client_socket_path = cJSON_GetObjectItemCaseSensitive(client_root, "socketPath");
if (cJSON_IsString(client_socket_path) && client_socket_path->valuestring != NULL) {
(*configObj)->client_socket_path = strdup(client_socket_path->valuestring);
}
cJSON_Delete(root); cJSON_Delete(root);
logger_log_general(__func__, "Successfully read configuration file."); logger_log_general(__func__, "Successfully read configuration file.");
return 0; return 0;
@@ -512,5 +536,6 @@ void configHandler_Free(configHandler_config_t** configObj) {
if ((*configObj)->lv2_parax32_frequency_right != NULL) { free((*configObj)->lv2_parax32_frequency_right); } if ((*configObj)->lv2_parax32_frequency_right != NULL) { free((*configObj)->lv2_parax32_frequency_right); }
if ((*configObj)->lv2_reverb_filter_name != NULL) { free((*configObj)->lv2_reverb_filter_name); } if ((*configObj)->lv2_reverb_filter_name != NULL) { free((*configObj)->lv2_reverb_filter_name); }
if ((*configObj)->local_rootdir != NULL) { free((*configObj)->local_rootdir); } if ((*configObj)->local_rootdir != NULL) { free((*configObj)->local_rootdir); }
if ((*configObj)->client_socket_path != NULL) { free((*configObj)->client_socket_path); }
if (*configObj != NULL) { free(*configObj); } if (*configObj != NULL) { free(*configObj); }
} }
+4
View File
@@ -67,7 +67,11 @@ typedef struct {
char* lv2_reverb_filter_name; // LV2 Calf Reverb LV2 Name char* lv2_reverb_filter_name; // LV2 Calf Reverb LV2 Name
// Local Settings // Local Settings
bool local_enable; // Enable Local Music Playback
char* local_rootdir; // Local Music Root Directory char* local_rootdir; // Local Music Root Directory
// Client Settings
char* client_socket_path; // Socket Path for client
} configHandler_config_t; } configHandler_config_t;
int configHandler_Read(configHandler_config_t** config); int configHandler_Read(configHandler_config_t** config);