/** * @brief Resets the BufferQueue producer queue for a given track * * @param element The Track element from the list * @param user_data Unused, for compatibility with g_list_foreach(). * * @see bq_producer_reset_queue */ static void r_track_producer_reset_queue(gpointer element, ATTR_UNUSED gpointer user_data) { Track *t = (Track*)element; if ( t->producer ) bq_producer_reset_queue(t->producer); }
/** * @brief Create a new producer for the bufferqueue or return one previously * allocated with the same key * * @param free_function Function to call when removing buffers from * the queue. * @param key producer's unique id, NULL if not shared. * * @return A new BufferQueue_Producer object that needs to be freed * with @ref bq_producer_unref. */ BufferQueue_Producer *bq_producer_new(GDestroyNotify free_function, gchar *key, gint *is_new) { BufferQueue_Producer *ret = NULL; *is_new = FALSE; if (key) { g_mutex_lock(bq_shared_producers_lock); ret = g_hash_table_lookup(bq_shared_producers, key); } if (!ret) { ret = g_slice_new0(BufferQueue_Producer); ret->ref_count = 1; ret->lock = g_mutex_new(); ret->free_function = free_function; ret->last_consumer = g_cond_new(); ret->fd_set = fd_set_new(); ret->max_backlog = DEFAULT_MAX_BACKLOG; ret->user_data = NULL; if (key) { ret->key = g_strdup(key); g_hash_table_insert(bq_shared_producers, ret->key, ret); } bq_producer_reset_queue(ret); *is_new = TRUE; } else { bq_producer_ref(ret); } if (key) g_mutex_unlock(bq_shared_producers_lock); return ret; }