diff --git a/src/input.c b/src/input.c index c96e73f8..5d7dbba4 100644 --- a/src/input.c +++ b/src/input.c @@ -217,7 +217,7 @@ metadata_get(struct input_source *source) if (!inputs[source->type]->metadata_get) return NULL; - metadata = calloc(1, sizeof(struct input_metadata)); + CHECK_NULL(L_PLAYER, metadata = calloc(1, sizeof(struct input_metadata))); ret = inputs[source->type]->metadata_get(metadata, source); if (ret < 0) @@ -890,8 +890,8 @@ input_init(void) int i; // Prepare input buffer - pthread_mutex_init(&input_buffer.mutex, NULL); - pthread_cond_init(&input_buffer.cond, NULL); + CHECK_ERR(L_PLAYER, mutex_init(&input_buffer.mutex)); + CHECK_ERR(L_PLAYER, pthread_cond_init(&input_buffer.cond, NULL)); CHECK_NULL(L_PLAYER, evbase_input = event_base_new()); CHECK_NULL(L_PLAYER, input_buffer.evbuf = evbuffer_new()); diff --git a/src/inputs/pipe.c b/src/inputs/pipe.c index c7d925f9..d04b2f2b 100644 --- a/src/inputs/pipe.c +++ b/src/inputs/pipe.c @@ -180,7 +180,7 @@ pipe_create(const char *path, int id, enum pipetype type, event_callback_fn cb) { struct pipe *pipe; - pipe = calloc(1, sizeof(struct pipe)); + CHECK_NULL(L_PLAYER, pipe = calloc(1, sizeof(struct pipe))); pipe->path = strdup(path); pipe->id = id; pipe->fd = -1; @@ -916,9 +916,6 @@ pipe_metadata_watch_add(void *arg) pipe_metadata_watch_del(NULL); // Just in case we somehow already have a metadata pipe open pipe_metadata.pipe = pipe_create(path, 0, PIPE_METADATA, pipe_metadata_read_cb); - if (!pipe_metadata.pipe) - return; - pipe_metadata.evbuf = evbuffer_new(); ret = watch_add(pipe_metadata.pipe); @@ -948,13 +945,18 @@ pipe_thread_start(void) static void pipe_thread_stop(void) { + int ret; + if (!tid_pipe) return; commands_exec_sync(cmdbase, pipe_watch_update, NULL, NULL); - commands_base_destroy(cmdbase); - pthread_join(tid_pipe, NULL); + + ret = pthread_join(tid_pipe, NULL); + if (ret != 0) + DPRINTF(E_LOG, L_PLAYER, "Could not join pipe thread: %s\n", strerror(errno)); + event_base_free(evbase_pipe); tid_pipe = 0; } @@ -1037,9 +1039,10 @@ setup(struct input_source *source) if (fd < 0) return -1; - CHECK_NULL(L_PLAYER, pipe = pipe_create(source->path, source->id, PIPE_PCM, NULL)); CHECK_NULL(L_PLAYER, source->evbuf = evbuffer_new()); + pipe = pipe_create(source->path, source->id, PIPE_PCM, NULL); + pipe->fd = fd; pipe->is_autostarted = (source->id == pipe_autostart_id);