check that the systems are started before trying to stop them, duh.
This commit is contained in:
+9
-4
@@ -45,6 +45,8 @@
|
||||
enum am_state { am_inactive, am_active, am_timing_out } state;
|
||||
enum ps_state { ps_inactive, ps_active } player_state;
|
||||
|
||||
int activity_monitor_running = 0;
|
||||
|
||||
pthread_t activity_monitor_thread;
|
||||
pthread_mutex_t activity_monitor_mutex;
|
||||
pthread_cond_t activity_monitor_cv;
|
||||
@@ -218,11 +220,14 @@ void *activity_monitor_thread_code(void *arg) {
|
||||
void activity_monitor_start() {
|
||||
// debug(1,"activity_monitor_start");
|
||||
pthread_create(&activity_monitor_thread, NULL, activity_monitor_thread_code, NULL);
|
||||
activity_monitor_running = 1;
|
||||
}
|
||||
|
||||
void activity_monitor_stop() {
|
||||
debug(1, "activity_monitor_stop start...");
|
||||
pthread_cancel(activity_monitor_thread);
|
||||
pthread_join(activity_monitor_thread, NULL);
|
||||
debug(1, "activity_monitor_stop complete");
|
||||
if (activity_monitor_running) {
|
||||
debug(1, "activity_monitor_stop start...");
|
||||
pthread_cancel(activity_monitor_thread);
|
||||
pthread_join(activity_monitor_thread, NULL);
|
||||
debug(1, "activity_monitor_stop complete");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ typedef struct {
|
||||
void *port_monitor_private_storage;
|
||||
} dacp_server_record;
|
||||
|
||||
int dacp_monitor_initialised = 0;
|
||||
pthread_t dacp_monitor_thread;
|
||||
dacp_server_record dacp_server;
|
||||
void *mdns_dacp_monitor_private_storage_pointer;
|
||||
@@ -888,15 +889,18 @@ void dacp_monitor_start() {
|
||||
memset(&dacp_server, 0, sizeof(dacp_server_record));
|
||||
|
||||
pthread_create(&dacp_monitor_thread, NULL, dacp_monitor_thread_code, NULL);
|
||||
dacp_monitor_initialised = 1;
|
||||
}
|
||||
|
||||
void dacp_monitor_stop() {
|
||||
debug(1, "dacp_monitor_stop");
|
||||
pthread_cancel(dacp_monitor_thread);
|
||||
pthread_join(dacp_monitor_thread, NULL);
|
||||
pthread_mutex_destroy(&dacp_server_information_lock);
|
||||
debug(1, "DACP Conversation Lock Mutex Destroyed");
|
||||
pthread_mutex_destroy(&dacp_conversation_lock);
|
||||
if (dacp_monitor_initialised) { // only if it's been started and initialised
|
||||
debug(1, "dacp_monitor_stop");
|
||||
pthread_cancel(dacp_monitor_thread);
|
||||
pthread_join(dacp_monitor_thread, NULL);
|
||||
pthread_mutex_destroy(&dacp_server_information_lock);
|
||||
debug(1, "DACP Conversation Lock Mutex Destroyed");
|
||||
pthread_mutex_destroy(&dacp_conversation_lock);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t dacp_tlv_crawl(char **p, int32_t *length) {
|
||||
|
||||
+14
-9
@@ -58,6 +58,8 @@
|
||||
#include <openssl/md5.h>
|
||||
#endif
|
||||
|
||||
int metadata_hub_initialised = 0;
|
||||
|
||||
pthread_rwlock_t metadata_hub_re_lock = PTHREAD_RWLOCK_INITIALIZER;
|
||||
struct track_metadata_bundle *track_metadata; // used for a temporary track metadata store
|
||||
|
||||
@@ -100,18 +102,21 @@ void metadata_hub_init(void) {
|
||||
// debug(1, "Metadata bundle initialisation.");
|
||||
memset(&metadata_store, 0, sizeof(metadata_store));
|
||||
track_metadata = NULL;
|
||||
metadata_hub_initialised = 1;
|
||||
}
|
||||
|
||||
void metadata_hub_stop(void) {
|
||||
debug(1, "metadata_hub_stop.");
|
||||
metadata_hub_release_track_artwork();
|
||||
if (metadata_store.track_metadata) {
|
||||
metadata_hub_release_track_metadata(metadata_store.track_metadata);
|
||||
metadata_store.track_metadata = NULL;
|
||||
}
|
||||
if (track_metadata) {
|
||||
metadata_hub_release_track_metadata(track_metadata);
|
||||
track_metadata = NULL;
|
||||
if (metadata_hub_initialised) {
|
||||
debug(1, "metadata_hub_stop.");
|
||||
metadata_hub_release_track_artwork();
|
||||
if (metadata_store.track_metadata) {
|
||||
metadata_hub_release_track_metadata(metadata_store.track_metadata);
|
||||
metadata_store.track_metadata = NULL;
|
||||
}
|
||||
if (track_metadata) {
|
||||
metadata_hub_release_track_metadata(track_metadata);
|
||||
track_metadata = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ enum rtsp_read_request_response {
|
||||
|
||||
// Mike Brady's part...
|
||||
|
||||
int metadata_running = 0;
|
||||
|
||||
// always lock use this when accessing the playing conn value
|
||||
static pthread_mutex_t playing_conn_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@@ -1454,12 +1456,15 @@ void metadata_init(void) {
|
||||
int ret = pthread_create(&metadata_thread, NULL, metadata_thread_function, NULL);
|
||||
if (ret)
|
||||
debug(1, "Failed to create metadata thread!");
|
||||
metadata_running = 1;
|
||||
}
|
||||
|
||||
void metadata_stop(void) {
|
||||
debug(1, "metadata_stop called.");
|
||||
pthread_cancel(metadata_thread);
|
||||
pthread_join(metadata_thread, NULL);
|
||||
if (metadata_running) {
|
||||
debug(1, "metadata_stop called.");
|
||||
pthread_cancel(metadata_thread);
|
||||
pthread_join(metadata_thread, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int send_metadata(uint32_t type, uint32_t code, char *data, uint32_t length, rtsp_message *carrier,
|
||||
|
||||
+8
-6
@@ -1075,7 +1075,7 @@ int parse_options(int argc, char **argv) {
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DBUS_INTERFACE) || defined(CONFIG_MPRIS_INTERFACE)
|
||||
GMainLoop *g_main_loop;
|
||||
static GMainLoop *g_main_loop = NULL;
|
||||
|
||||
pthread_t dbus_thread;
|
||||
void *dbus_thread_func(__attribute__((unused)) void *arg) {
|
||||
@@ -1138,7 +1138,7 @@ const char *pid_file_proc(void) {
|
||||
#endif
|
||||
|
||||
void main_cleanup_handler(__attribute__((unused)) void *arg) {
|
||||
// it doesn't look like this is called when the main function terminates.
|
||||
// it doesn't look like this is called when the main function is cancelled eith a pthread cancel.
|
||||
debug(1, "main cleanup handler called.");
|
||||
#ifdef CONFIG_MQTT
|
||||
if (config.mqtt_enabled) {
|
||||
@@ -1153,9 +1153,11 @@ void main_cleanup_handler(__attribute__((unused)) void *arg) {
|
||||
#ifdef CONFIG_DBUS_INTERFACE
|
||||
stop_dbus_service();
|
||||
#endif
|
||||
debug(1, "Stopping DBUS Loop Thread");
|
||||
g_main_loop_quit(g_main_loop);
|
||||
pthread_join(dbus_thread, NULL);
|
||||
if (g_main_loop) {
|
||||
debug(1, "Stopping DBUS Loop Thread");
|
||||
g_main_loop_quit(g_main_loop);
|
||||
pthread_join(dbus_thread, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DACP_CLIENT
|
||||
@@ -1174,7 +1176,7 @@ void main_cleanup_handler(__attribute__((unused)) void *arg) {
|
||||
|
||||
activity_monitor_stop(0);
|
||||
|
||||
if (config.output->deinit) {
|
||||
if ((config.output) && (config.output->deinit)) {
|
||||
debug(1, "Deinitialise the audio backend.");
|
||||
config.output->deinit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user