mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
remove last glib bits
Improve pinossink
This commit is contained in:
parent
ee67929a7c
commit
046c2b1cae
8 changed files with 162 additions and 109 deletions
|
|
@ -52,10 +52,10 @@ libpinos = shared_library('pinos', pinos_sources,
|
||||||
include_directories : [configinc, spa_inc],
|
include_directories : [configinc, spa_inc],
|
||||||
link_with : spalib,
|
link_with : spalib,
|
||||||
install : true,
|
install : true,
|
||||||
dependencies : [glib_dep, dbus_dep, mathlib, pthread_lib],
|
dependencies : [dbus_dep, mathlib, pthread_lib],
|
||||||
)
|
)
|
||||||
|
|
||||||
pinos_dep = declare_dependency(link_with : libpinos,
|
pinos_dep = declare_dependency(link_with : libpinos,
|
||||||
include_directories : [configinc, spa_inc],
|
include_directories : [configinc, spa_inc],
|
||||||
dependencies : [glib_dep, pthread_lib],
|
dependencies : [pthread_lib],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,45 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/properties.h"
|
#include "pinos/client/properties.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *key;
|
||||||
|
char *value;
|
||||||
|
} PropItem;
|
||||||
|
|
||||||
struct _PinosProperties {
|
struct _PinosProperties {
|
||||||
GHashTable *hashtable;
|
PinosArray items;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
copy_func (const char *key, const char *value, GHashTable *copy)
|
add_func (PinosProperties *props, char *key, char *value)
|
||||||
{
|
{
|
||||||
g_hash_table_insert (copy, g_strdup (key), g_strdup (value));
|
PropItem *item;
|
||||||
|
item = pinos_array_add (&props->items, sizeof (PropItem));
|
||||||
|
item->key = key;
|
||||||
|
item->value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clear_item (PropItem *item)
|
||||||
|
{
|
||||||
|
free (item->key);
|
||||||
|
free (item->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
find_index (PinosProperties *props, const char *key)
|
||||||
|
{
|
||||||
|
int i, len = pinos_array_get_len (&props->items, PropItem);
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
PropItem *item = pinos_array_get_unchecked (&props->items, i, PropItem);
|
||||||
|
if (strcmp (item->key, key) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,13 +74,13 @@ pinos_properties_new (const char *key, ...)
|
||||||
va_list varargs;
|
va_list varargs;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
props = g_new (PinosProperties, 1);
|
props = calloc (1, sizeof (PinosProperties));
|
||||||
props->hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
pinos_array_init (&props->items);
|
||||||
|
|
||||||
va_start (varargs, key);
|
va_start (varargs, key);
|
||||||
while (key != NULL) {
|
while (key != NULL) {
|
||||||
value = va_arg (varargs, char *);
|
value = va_arg (varargs, char *);
|
||||||
copy_func (key, value, props->hashtable);
|
add_func (props, strdup (key), strdup (value));
|
||||||
key = va_arg (varargs, char *);
|
key = va_arg (varargs, char *);
|
||||||
}
|
}
|
||||||
va_end (varargs);
|
va_end (varargs);
|
||||||
|
|
@ -74,11 +100,11 @@ PinosProperties *
|
||||||
pinos_properties_copy (PinosProperties *properties)
|
pinos_properties_copy (PinosProperties *properties)
|
||||||
{
|
{
|
||||||
PinosProperties *copy;
|
PinosProperties *copy;
|
||||||
|
PropItem *item;
|
||||||
g_return_val_if_fail (properties != NULL, NULL);
|
|
||||||
|
|
||||||
copy = pinos_properties_new (NULL, NULL);
|
copy = pinos_properties_new (NULL, NULL);
|
||||||
g_hash_table_foreach (properties->hashtable, (GHFunc) copy_func, copy->hashtable);
|
pinos_array_for_each (item, &properties->items)
|
||||||
|
add_func (copy, strdup (item->key), strdup (item->value));
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
@ -119,10 +145,40 @@ pinos_properties_merge (PinosProperties *oldprops,
|
||||||
void
|
void
|
||||||
pinos_properties_free (PinosProperties *properties)
|
pinos_properties_free (PinosProperties *properties)
|
||||||
{
|
{
|
||||||
g_return_if_fail (properties != NULL);
|
PropItem *item;
|
||||||
|
|
||||||
g_hash_table_unref (properties->hashtable);
|
pinos_array_for_each (item, &properties->items)
|
||||||
g_free (properties);
|
clear_item (item);
|
||||||
|
|
||||||
|
pinos_array_clear (&properties->items);
|
||||||
|
free (properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_replace (PinosProperties *properties,
|
||||||
|
char *key,
|
||||||
|
char *value)
|
||||||
|
{
|
||||||
|
int index = find_index (properties, key);
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
add_func (properties, key, value);
|
||||||
|
} else {
|
||||||
|
PropItem *item = pinos_array_get_unchecked (&properties->items, index, PropItem);
|
||||||
|
|
||||||
|
clear_item (item);
|
||||||
|
if (value == NULL) {
|
||||||
|
PropItem *other = pinos_array_get_unchecked (&properties->items,
|
||||||
|
pinos_array_get_len (&properties->items, PropItem) - 1,
|
||||||
|
PropItem);
|
||||||
|
item->key = other->key;
|
||||||
|
item->value = other->value;
|
||||||
|
properties->items.size -= sizeof (PropItem);
|
||||||
|
} else {
|
||||||
|
item->key = key;
|
||||||
|
item->value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -140,13 +196,7 @@ pinos_properties_set (PinosProperties *properties,
|
||||||
const char *key,
|
const char *key,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_return_if_fail (properties != NULL);
|
do_replace (properties, strdup (key), value ? strdup (value) : NULL);
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
|
|
||||||
if (value == NULL)
|
|
||||||
g_hash_table_remove (properties->hashtable, key);
|
|
||||||
else
|
|
||||||
g_hash_table_replace (properties->hashtable, g_strdup (key), g_strdup (value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -166,16 +216,13 @@ pinos_properties_setf (PinosProperties *properties,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
va_list varargs;
|
va_list varargs;
|
||||||
|
char *value;
|
||||||
g_return_if_fail (properties != NULL);
|
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
g_return_if_fail (format != NULL);
|
|
||||||
|
|
||||||
va_start (varargs, format);
|
va_start (varargs, format);
|
||||||
g_hash_table_replace (properties->hashtable,
|
vasprintf (&value, format, varargs);
|
||||||
g_strdup (key),
|
|
||||||
g_strdup_vprintf (format, varargs));
|
|
||||||
va_end (varargs);
|
va_end (varargs);
|
||||||
|
|
||||||
|
do_replace (properties, strdup (key), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -191,10 +238,12 @@ const char *
|
||||||
pinos_properties_get (PinosProperties *properties,
|
pinos_properties_get (PinosProperties *properties,
|
||||||
const char *key)
|
const char *key)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (properties != NULL, NULL);
|
int index = find_index (properties, key);
|
||||||
g_return_val_if_fail (key != NULL, NULL);
|
|
||||||
|
|
||||||
return g_hash_table_lookup (properties->hashtable, key);
|
if (index == -1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return pinos_array_get_unchecked (&properties->items, index, PropItem)->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -215,29 +264,17 @@ const char *
|
||||||
pinos_properties_iterate (PinosProperties *properties,
|
pinos_properties_iterate (PinosProperties *properties,
|
||||||
void **state)
|
void **state)
|
||||||
{
|
{
|
||||||
static void * dummy = GINT_TO_POINTER (1);
|
unsigned int index;
|
||||||
const char *res = NULL;
|
|
||||||
GList *items;
|
|
||||||
|
|
||||||
g_return_val_if_fail (properties != NULL, NULL);
|
if (*state == NULL)
|
||||||
g_return_val_if_fail (state != NULL, NULL);
|
index = 0;
|
||||||
|
else
|
||||||
|
index = SPA_PTR_TO_INT (*state);
|
||||||
|
|
||||||
if (*state == dummy)
|
if (!pinos_array_check_index (&properties->items, index, PropItem))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (*state == NULL) {
|
*state = SPA_INT_TO_PTR (index + 1);
|
||||||
items = g_hash_table_get_keys (properties->hashtable);
|
|
||||||
} else {
|
|
||||||
items = *state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (items) {
|
return pinos_array_get_unchecked (&properties->items, index, PropItem)->key;
|
||||||
res = items->data;
|
|
||||||
items = g_list_delete_link (items, items);
|
|
||||||
if (items == NULL)
|
|
||||||
items = dummy;
|
|
||||||
}
|
|
||||||
*state = items;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,13 +118,20 @@ gst_pinos_sink_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstPinosSink *pinossink = GST_PINOS_SINK (object);
|
GstPinosSink *pinossink = GST_PINOS_SINK (object);
|
||||||
|
|
||||||
|
g_object_unref (pinossink->pool);
|
||||||
|
|
||||||
|
pinos_thread_main_loop_destroy (pinossink->main_loop);
|
||||||
|
pinossink->main_loop = NULL;
|
||||||
|
|
||||||
|
pinos_loop_destroy (pinossink->loop);
|
||||||
|
pinossink->loop = NULL;
|
||||||
|
|
||||||
if (pinossink->properties)
|
if (pinossink->properties)
|
||||||
gst_structure_free (pinossink->properties);
|
gst_structure_free (pinossink->properties);
|
||||||
g_object_unref (pinossink->allocator);
|
g_object_unref (pinossink->allocator);
|
||||||
g_object_unref (pinossink->pool);
|
|
||||||
g_hash_table_unref (pinossink->buf_ids);
|
|
||||||
g_free (pinossink->path);
|
g_free (pinossink->path);
|
||||||
g_free (pinossink->client_name);
|
g_free (pinossink->client_name);
|
||||||
|
g_hash_table_unref (pinossink->buf_ids);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
@ -222,6 +229,10 @@ gst_pinos_sink_init (GstPinosSink * sink)
|
||||||
|
|
||||||
sink->buf_ids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
|
sink->buf_ids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
|
||||||
(GDestroyNotify) gst_buffer_unref);
|
(GDestroyNotify) gst_buffer_unref);
|
||||||
|
|
||||||
|
sink->loop = pinos_loop_new ();
|
||||||
|
sink->main_loop = pinos_thread_main_loop_new (sink->loop, "pinos-sink-loop");
|
||||||
|
GST_DEBUG ("loop %p %p", sink->loop, sink->main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
|
|
@ -710,7 +721,8 @@ gst_pinos_sink_stop (GstBaseSink * basesink)
|
||||||
if (pinossink->stream) {
|
if (pinossink->stream) {
|
||||||
pinos_stream_stop (pinossink->stream);
|
pinos_stream_stop (pinossink->stream);
|
||||||
pinos_stream_disconnect (pinossink->stream);
|
pinos_stream_disconnect (pinossink->stream);
|
||||||
g_clear_object (&pinossink->stream);
|
pinos_stream_destroy (pinossink->stream);
|
||||||
|
pinossink->stream = NULL;
|
||||||
pinossink->pool->stream = NULL;
|
pinossink->pool->stream = NULL;
|
||||||
}
|
}
|
||||||
pinos_thread_main_loop_unlock (pinossink->main_loop);
|
pinos_thread_main_loop_unlock (pinossink->main_loop);
|
||||||
|
|
@ -746,10 +758,6 @@ on_ctx_state_changed (PinosListener *listener,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_pinos_sink_open (GstPinosSink * pinossink)
|
gst_pinos_sink_open (GstPinosSink * pinossink)
|
||||||
{
|
{
|
||||||
pinossink->loop = pinos_loop_new ();
|
|
||||||
GST_DEBUG ("loop %p", pinossink->loop);
|
|
||||||
|
|
||||||
pinossink->main_loop = pinos_thread_main_loop_new (pinossink->loop, "pinos-sink-loop");
|
|
||||||
if (pinos_thread_main_loop_start (pinossink->main_loop) != SPA_RESULT_OK)
|
if (pinos_thread_main_loop_start (pinossink->main_loop) != SPA_RESULT_OK)
|
||||||
goto mainloop_error;
|
goto mainloop_error;
|
||||||
|
|
||||||
|
|
@ -758,7 +766,7 @@ gst_pinos_sink_open (GstPinosSink * pinossink)
|
||||||
|
|
||||||
pinos_signal_add (&pinossink->ctx->state_changed, &pinossink->ctx_state_changed, on_ctx_state_changed);
|
pinos_signal_add (&pinossink->ctx->state_changed, &pinossink->ctx_state_changed, on_ctx_state_changed);
|
||||||
|
|
||||||
pinos_context_connect(pinossink->ctx);
|
pinos_context_connect (pinossink->ctx);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
PinosContextState state = pinossink->ctx->state;
|
PinosContextState state = pinossink->ctx->state;
|
||||||
|
|
@ -814,11 +822,16 @@ gst_pinos_sink_close (GstPinosSink * pinossink)
|
||||||
pinos_thread_main_loop_unlock (pinossink->main_loop);
|
pinos_thread_main_loop_unlock (pinossink->main_loop);
|
||||||
|
|
||||||
pinos_thread_main_loop_stop (pinossink->main_loop);
|
pinos_thread_main_loop_stop (pinossink->main_loop);
|
||||||
pinos_thread_main_loop_destroy (pinossink->main_loop);
|
|
||||||
|
if (pinossink->stream) {
|
||||||
pinos_stream_destroy (pinossink->stream);
|
pinos_stream_destroy (pinossink->stream);
|
||||||
|
pinossink->stream = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pinossink->ctx) {
|
||||||
pinos_context_destroy (pinossink->ctx);
|
pinos_context_destroy (pinossink->ctx);
|
||||||
pinos_loop_destroy (pinossink->loop);
|
pinossink->ctx = NULL;
|
||||||
pinossink->loop = NULL;
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include <spa/lib/debug.h>
|
#include <spa/lib/debug.h>
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/enumtypes.h"
|
|
||||||
|
|
||||||
#include "pinos/server/link.h"
|
#include "pinos/server/link.h"
|
||||||
|
|
||||||
|
|
@ -315,7 +314,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
in_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
in_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||||
impl->n_buffers = this->output->n_buffers;
|
impl->n_buffers = this->output->n_buffers;
|
||||||
impl->buffers = this->output->buffers;
|
impl->buffers = this->output->buffers;
|
||||||
impl->allocated = FALSE;
|
impl->allocated = false;
|
||||||
pinos_log_debug ("reusing %d output buffers %p", impl->n_buffers, impl->buffers);
|
pinos_log_debug ("reusing %d output buffers %p", impl->n_buffers, impl->buffers);
|
||||||
} else {
|
} else {
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
@ -409,7 +408,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pinos_log_debug ("allocated %d buffers %p %zd", impl->n_buffers, impl->buffers, minsize);
|
pinos_log_debug ("allocated %d buffers %p %zd", impl->n_buffers, impl->buffers, minsize);
|
||||||
impl->allocated = TRUE;
|
impl->allocated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
if (out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
||||||
|
|
@ -424,9 +423,9 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
pinos_main_loop_defer (this->core->main_loop, this->output->node, res, NULL, NULL);
|
pinos_main_loop_defer (this->core->main_loop, this->output->node, res, NULL, NULL);
|
||||||
this->output->buffers = impl->buffers;
|
this->output->buffers = impl->buffers;
|
||||||
this->output->n_buffers = impl->n_buffers;
|
this->output->n_buffers = impl->n_buffers;
|
||||||
this->output->allocated = TRUE;
|
this->output->allocated = true;
|
||||||
this->output->buffer_mem = impl->buffer_mem;
|
this->output->buffer_mem = impl->buffer_mem;
|
||||||
impl->allocated = FALSE;
|
impl->allocated = false;
|
||||||
pinos_log_debug ("allocated %d buffers %p from output port", impl->n_buffers, impl->buffers);
|
pinos_log_debug ("allocated %d buffers %p from output port", impl->n_buffers, impl->buffers);
|
||||||
} else if (in_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
} else if (in_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
||||||
if ((res = spa_node_port_alloc_buffers (this->input->node->node,
|
if ((res = spa_node_port_alloc_buffers (this->input->node->node,
|
||||||
|
|
@ -440,9 +439,9 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
pinos_main_loop_defer (this->core->main_loop, this->input->node, res, NULL, NULL);
|
pinos_main_loop_defer (this->core->main_loop, this->input->node, res, NULL, NULL);
|
||||||
this->input->buffers = impl->buffers;
|
this->input->buffers = impl->buffers;
|
||||||
this->input->n_buffers = impl->n_buffers;
|
this->input->n_buffers = impl->n_buffers;
|
||||||
this->input->allocated = TRUE;
|
this->input->allocated = true;
|
||||||
this->input->buffer_mem = impl->buffer_mem;
|
this->input->buffer_mem = impl->buffer_mem;
|
||||||
impl->allocated = FALSE;
|
impl->allocated = false;
|
||||||
pinos_log_debug ("allocated %d buffers %p from input port", impl->n_buffers, impl->buffers);
|
pinos_log_debug ("allocated %d buffers %p from input port", impl->n_buffers, impl->buffers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +459,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
pinos_main_loop_defer (this->core->main_loop, this->input->node, res, NULL, NULL);
|
pinos_main_loop_defer (this->core->main_loop, this->input->node, res, NULL, NULL);
|
||||||
this->input->buffers = impl->buffers;
|
this->input->buffers = impl->buffers;
|
||||||
this->input->n_buffers = impl->n_buffers;
|
this->input->n_buffers = impl->n_buffers;
|
||||||
this->input->allocated = FALSE;
|
this->input->allocated = false;
|
||||||
}
|
}
|
||||||
else if (out_flags & SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS) {
|
else if (out_flags & SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS) {
|
||||||
pinos_log_debug ("using %d buffers %p on output port", impl->n_buffers, impl->buffers);
|
pinos_log_debug ("using %d buffers %p on output port", impl->n_buffers, impl->buffers);
|
||||||
|
|
@ -475,7 +474,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
pinos_main_loop_defer (this->core->main_loop, this->output->node, res, NULL, NULL);
|
pinos_main_loop_defer (this->core->main_loop, this->output->node, res, NULL, NULL);
|
||||||
this->output->buffers = impl->buffers;
|
this->output->buffers = impl->buffers;
|
||||||
this->output->n_buffers = impl->n_buffers;
|
this->output->n_buffers = impl->n_buffers;
|
||||||
this->output->allocated = FALSE;
|
this->output->allocated = false;
|
||||||
} else {
|
} else {
|
||||||
asprintf (&error, "no common buffer alloc found");
|
asprintf (&error, "no common buffer alloc found");
|
||||||
goto error;
|
goto error;
|
||||||
|
|
@ -487,10 +486,10 @@ error:
|
||||||
{
|
{
|
||||||
this->output->buffers = NULL;
|
this->output->buffers = NULL;
|
||||||
this->output->n_buffers = 0;
|
this->output->n_buffers = 0;
|
||||||
this->output->allocated = FALSE;
|
this->output->allocated = false;
|
||||||
this->input->buffers = NULL;
|
this->input->buffers = NULL;
|
||||||
this->input->n_buffers = 0;
|
this->input->n_buffers = 0;
|
||||||
this->input->allocated = FALSE;
|
this->input->allocated = false;
|
||||||
pinos_link_report_error (this, error);
|
pinos_link_report_error (this, error);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -520,7 +519,7 @@ do_start (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||||
|
|
||||||
static SpaResult
|
static SpaResult
|
||||||
check_states (PinosLink *this,
|
check_states (PinosLink *this,
|
||||||
gpointer user_data,
|
void *user_data,
|
||||||
SpaResult res)
|
SpaResult res)
|
||||||
{
|
{
|
||||||
SpaNodeState in_state, out_state;
|
SpaNodeState in_state, out_state;
|
||||||
|
|
@ -586,7 +585,7 @@ on_output_async_complete_notify (PinosListener *listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_port_unlinked (PinosPort *port, PinosLink *this, SpaResult res, gulong id)
|
on_port_unlinked (PinosPort *port, PinosLink *this, SpaResult res, uint32_t id)
|
||||||
{
|
{
|
||||||
pinos_signal_emit (&this->core->port_unlinked, this, port);
|
pinos_signal_emit (&this->core->port_unlinked, this, port);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
|
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
#include "spa/include/spa/list.h"
|
#include "spa/include/spa/list.h"
|
||||||
#include "spa/include/spa/ringbuffer.h"
|
#include "spa/include/spa/ringbuffer.h"
|
||||||
#include "pinos/client/log.h"
|
#include "pinos/client/log.h"
|
||||||
|
|
@ -113,11 +111,11 @@ main_loop_defer (PinosMainLoop *loop,
|
||||||
pinos_log_debug ("main-loop %p: wait sync object %p", loop, obj);
|
pinos_log_debug ("main-loop %p: wait sync object %p", loop, obj);
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
have_work = TRUE;
|
have_work = true;
|
||||||
} else {
|
} else {
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
have_work = TRUE;
|
have_work = true;
|
||||||
pinos_log_debug ("main-loop %p: defer object %p", loop, obj);
|
pinos_log_debug ("main-loop %p: defer object %p", loop, obj);
|
||||||
}
|
}
|
||||||
spa_list_insert (impl->work_list.prev, &item->link);
|
spa_list_insert (impl->work_list.prev, &item->link);
|
||||||
|
|
@ -164,7 +162,7 @@ main_loop_defer_complete (PinosMainLoop *loop,
|
||||||
pinos_log_debug ("main-loop %p: found defered %d for object %p", loop, seq, obj);
|
pinos_log_debug ("main-loop %p: found defered %d for object %p", loop, seq, obj);
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
have_work = TRUE;
|
have_work = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!have_work) {
|
if (!have_work) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <glib.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/utils.h"
|
#include "pinos/client/utils.h"
|
||||||
|
|
@ -42,42 +45,47 @@ static char *
|
||||||
find_module (const char * path, const char *name)
|
find_module (const char * path, const char *name)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
GDir *dir;
|
struct dirent *entry;
|
||||||
const gchar *entry;
|
struct stat s;
|
||||||
GError *err = NULL;
|
DIR *dir;
|
||||||
|
|
||||||
filename = g_strconcat (path, G_DIR_SEPARATOR_S, name, ".", G_MODULE_SUFFIX, NULL);
|
asprintf (&filename, "%s/%s.so", path, name);
|
||||||
|
|
||||||
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
|
if (stat (filename, &s) == 0 && S_ISREG (s.st_mode)) {
|
||||||
/* found a regular file with name */
|
/* found a regular file with name */
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_pointer (&filename, g_free);
|
free (filename);
|
||||||
|
filename = NULL;
|
||||||
|
|
||||||
/* now recurse down in subdirectories and look for it there */
|
/* now recurse down in subdirectories and look for it there */
|
||||||
|
|
||||||
dir = g_dir_open (path, 0, &err);
|
dir = opendir (path);
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
pinos_log_warn ("could not open %s: %s", path, err->message);
|
pinos_log_warn ("could not open %s: %s", path, strerror (errno));
|
||||||
g_error_free (err);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((entry = g_dir_read_name (dir))) {
|
while ((entry = readdir (dir))) {
|
||||||
gchar *newpath;
|
char *newpath;
|
||||||
|
|
||||||
newpath = g_build_filename (path, entry, NULL);
|
if (strcmp (entry->d_name, ".") == 0 ||
|
||||||
if (g_file_test (newpath, G_FILE_TEST_IS_DIR)) {
|
strcmp (entry->d_name, "..") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
asprintf (&newpath, "%s/%s", path, entry->d_name);
|
||||||
|
|
||||||
|
if (stat (newpath, &s) == 0 && S_ISDIR (s.st_mode)) {
|
||||||
filename = find_module (newpath, name);
|
filename = find_module (newpath, name);
|
||||||
}
|
}
|
||||||
g_free (newpath);
|
free (newpath);
|
||||||
|
|
||||||
if (filename != NULL)
|
if (filename != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_dir_close (dir);
|
closedir (dir);
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
@ -95,8 +103,8 @@ find_module (const char * path, const char *name)
|
||||||
*/
|
*/
|
||||||
PinosModule *
|
PinosModule *
|
||||||
pinos_module_load (PinosCore *core,
|
pinos_module_load (PinosCore *core,
|
||||||
const gchar *name,
|
const char *name,
|
||||||
const gchar *args,
|
const char *args,
|
||||||
char **err)
|
char **err)
|
||||||
{
|
{
|
||||||
PinosModule *this;
|
PinosModule *this;
|
||||||
|
|
@ -113,7 +121,7 @@ pinos_module_load (PinosCore *core,
|
||||||
|
|
||||||
pinos_log_debug ("PINOS_MODULE_DIR set to: %s", module_dir);
|
pinos_log_debug ("PINOS_MODULE_DIR set to: %s", module_dir);
|
||||||
|
|
||||||
l = pinos_split_strv (module_dir, G_SEARCHPATH_SEPARATOR_S, 0, &n_paths);
|
l = pinos_split_strv (module_dir, "/", 0, &n_paths);
|
||||||
for (i = 0; l[i] != NULL; i++) {
|
for (i = 0; l[i] != NULL; i++) {
|
||||||
filename = find_module (l[i], name);
|
filename = find_module (l[i], name);
|
||||||
if (filename != NULL)
|
if (filename != NULL)
|
||||||
|
|
@ -147,7 +155,7 @@ pinos_module_load (PinosCore *core,
|
||||||
this->name = strdup (name);
|
this->name = strdup (name);
|
||||||
this->core = core;
|
this->core = core;
|
||||||
|
|
||||||
if (!init_func (this, (gchar *) args))
|
if (!init_func (this, (char *) args))
|
||||||
goto init_failed;
|
goto init_failed;
|
||||||
|
|
||||||
pinos_log_debug ("loaded module: %s", this->name);
|
pinos_log_debug ("loaded module: %s", this->name);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/enumtypes.h"
|
|
||||||
|
|
||||||
#include "pinos/server/node.h"
|
#include "pinos/server/node.h"
|
||||||
#include "pinos/server/data-loop.h"
|
#include "pinos/server/data-loop.h"
|
||||||
|
|
@ -639,10 +638,10 @@ pinos_node_get_free_port (PinosNode *node,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_state_complete (PinosNode *node,
|
on_state_complete (PinosNode *node,
|
||||||
gpointer data,
|
void *data,
|
||||||
SpaResult res)
|
SpaResult res)
|
||||||
{
|
{
|
||||||
PinosNodeState state = GPOINTER_TO_INT (data);
|
PinosNodeState state = SPA_PTR_TO_INT (data);
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
pinos_log_debug ("node %p: state complete %d", node, res);
|
pinos_log_debug ("node %p: state complete %d", node, res);
|
||||||
|
|
@ -702,7 +701,7 @@ pinos_node_set_state (PinosNode *node,
|
||||||
node,
|
node,
|
||||||
res,
|
res,
|
||||||
(PinosDeferFunc) on_state_complete,
|
(PinosDeferFunc) on_state_complete,
|
||||||
GINT_TO_POINTER (state));
|
SPA_INT_TO_PTR (state));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/enumtypes.h"
|
|
||||||
|
|
||||||
#include "pinos/server/port.h"
|
#include "pinos/server/port.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue