Fix a crash that occurred if metadata support is enabled during compilation but turned off in the configuration file.
Fix a crash that occurred playing from AirPower on Android.
This commit is contained in:
@@ -445,9 +445,13 @@ void set_dacp_server_information(rtsp_conn_info *conn) {
|
||||
}
|
||||
if (dacp_server.active_remote_id)
|
||||
free(dacp_server.active_remote_id);
|
||||
dacp_server.active_remote_id =
|
||||
strdup(conn->dacp_active_remote); // even if the dacp_id remains the same,
|
||||
// the active remote will change.
|
||||
if (conn->dacp_active_remote)
|
||||
dacp_server.active_remote_id =
|
||||
strdup(conn->dacp_active_remote); // even if the dacp_id remains the same,
|
||||
// the active remote will change.
|
||||
else
|
||||
dacp_server.active_remote_id = NULL;
|
||||
|
||||
debug(3, "set_dacp_server_information set active-remote id to %s.", dacp_server.active_remote_id);
|
||||
pthread_cond_signal(&dacp_server_information_cv);
|
||||
debug_mutex_unlock(&dacp_server_information_lock, 3);
|
||||
|
||||
@@ -1587,7 +1587,6 @@ void metadata_hub_thread_cleanup_function(__attribute__((unused)) void *arg) {
|
||||
}
|
||||
|
||||
void *metadata_hub_thread_function(__attribute__((unused)) void *ignore) {
|
||||
|
||||
// create a pc_queue for passing information to a threaded metadata handler
|
||||
pc_queue_init(&metadata_hub_queue, (char *)&metadata_hub_queue_items, sizeof(metadata_package),
|
||||
metadata_hub_queue_size, "hub");
|
||||
@@ -1653,41 +1652,41 @@ void *metadata_mqtt_thread_function(__attribute__((unused)) void *ignore) {
|
||||
#endif
|
||||
|
||||
void metadata_init(void) {
|
||||
int ret;
|
||||
if (config.metadata_enabled) {
|
||||
// create the metadata pipe, if necessary
|
||||
size_t pl = strlen(config.metadata_pipename) + 1;
|
||||
char *path = malloc(pl + 1);
|
||||
snprintf(path, pl + 1, "%s", config.metadata_pipename);
|
||||
mode_t oldumask = umask(000);
|
||||
if (mkfifo(path, 0666) && errno != EEXIST)
|
||||
die("Could not create metadata pipe \"%s\".", path);
|
||||
umask(oldumask);
|
||||
debug(1, "metadata pipe name is \"%s\".", path);
|
||||
|
||||
// create the metadata pipe, if necessary
|
||||
size_t pl = strlen(config.metadata_pipename) + 1;
|
||||
char *path = malloc(pl + 1);
|
||||
snprintf(path, pl + 1, "%s", config.metadata_pipename);
|
||||
// try to open it
|
||||
fd = try_to_open_pipe_for_writing(path);
|
||||
// we check that it's not a "real" error. From the "man 2 open" page:
|
||||
// "ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO, and no process has the FIFO
|
||||
// open for reading." Which is okay.
|
||||
if ((fd == -1) && (errno != ENXIO)) {
|
||||
char errorstring[1024];
|
||||
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
|
||||
debug(1, "metadata_hub_thread_function -- error %d (\"%s\") opening pipe: \"%s\".", errno,
|
||||
(char *)errorstring, path);
|
||||
warn("can not open metadata pipe -- error %d (\"%s\") opening pipe: \"%s\".", errno,
|
||||
(char *)errorstring, path);
|
||||
}
|
||||
free(path);
|
||||
int ret;
|
||||
ret = pthread_create(&metadata_thread, NULL, metadata_thread_function, NULL);
|
||||
if (ret)
|
||||
debug(1, "Failed to create metadata thread!");
|
||||
|
||||
mode_t oldumask = umask(000);
|
||||
if (mkfifo(path, 0666) && errno != EEXIST)
|
||||
die("Could not create metadata pipe \"%s\".", path);
|
||||
umask(oldumask);
|
||||
debug(1, "metadata pipe name is \"%s\".", path);
|
||||
|
||||
// try to open it
|
||||
fd = try_to_open_pipe_for_writing(path);
|
||||
// we check that it's not a "real" error. From the "man 2 open" page:
|
||||
// "ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO, and no process has the FIFO
|
||||
// open for reading." Which is okay.
|
||||
if ((fd == -1) && (errno != ENXIO)) {
|
||||
char errorstring[1024];
|
||||
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
|
||||
debug(1, "metadata_hub_thread_function -- error %d (\"%s\") opening pipe: \"%s\".", errno,
|
||||
(char *)errorstring, path);
|
||||
warn("can not open metadata pipe -- error %d (\"%s\") opening pipe: \"%s\".", errno,
|
||||
(char *)errorstring, path);
|
||||
ret = pthread_create(&metadata_multicast_thread, NULL, metadata_multicast_thread_function, NULL);
|
||||
if (ret)
|
||||
debug(1, "Failed to create metadata multicast thread!");
|
||||
}
|
||||
free(path);
|
||||
|
||||
int ret = pthread_create(&metadata_thread, NULL, metadata_thread_function, NULL);
|
||||
if (ret)
|
||||
debug(1, "Failed to create metadata thread!");
|
||||
|
||||
ret = pthread_create(&metadata_multicast_thread, NULL, metadata_multicast_thread_function, NULL);
|
||||
if (ret)
|
||||
debug(1, "Failed to create metadata multicast thread!");
|
||||
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
ret = pthread_create(&metadata_hub_thread, NULL, metadata_hub_thread_function, NULL);
|
||||
if (ret)
|
||||
@@ -1716,15 +1715,20 @@ void metadata_stop(void) {
|
||||
pthread_join(metadata_hub_thread, NULL);
|
||||
// debug(2, "metadata stop hub done.");
|
||||
#endif
|
||||
// debug(2, "metadata stop multicast thread.");
|
||||
pthread_cancel(metadata_multicast_thread);
|
||||
pthread_join(metadata_multicast_thread, NULL);
|
||||
// debug(2, "metadata stop multicast done.");
|
||||
|
||||
// debug(2, "metadata stop metadata_thread thread.");
|
||||
pthread_cancel(metadata_thread);
|
||||
pthread_join(metadata_thread, NULL);
|
||||
// debug(2, "metadata_stop finished successfully.");
|
||||
if (config.metadata_enabled) {
|
||||
// debug(2, "metadata stop multicast thread.");
|
||||
if (metadata_multicast_thread) {
|
||||
pthread_cancel(metadata_multicast_thread);
|
||||
pthread_join(metadata_multicast_thread, NULL);
|
||||
// debug(2, "metadata stop multicast done.");
|
||||
}
|
||||
if (metadata_thread) {
|
||||
// debug(2, "metadata stop metadata_thread thread.");
|
||||
pthread_cancel(metadata_thread);
|
||||
pthread_join(metadata_thread, NULL);
|
||||
// debug(2, "metadata_stop finished successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1794,7 +1798,10 @@ int send_metadata_to_queue(pc_queue *queue, uint32_t type, uint32_t code, char *
|
||||
int send_metadata(uint32_t type, uint32_t code, char *data, uint32_t length, rtsp_message *carrier,
|
||||
int block) {
|
||||
int rc;
|
||||
rc = send_metadata_to_queue(&metadata_queue, type, code, data, length, carrier, block);
|
||||
if (config.metadata_enabled) {
|
||||
rc = send_metadata_to_queue(&metadata_queue, type, code, data, length, carrier, block);
|
||||
rc = send_metadata_to_queue(&metadata_multicast_queue, type, code, data, length, carrier, block);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_METADATA_HUB
|
||||
rc = send_metadata_to_queue(&metadata_hub_queue, type, code, data, length, carrier, block);
|
||||
|
||||
Reference in New Issue
Block a user