remove last glib bits

Improve pinossink
This commit is contained in:
Wim Taymans 2016-11-26 19:18:51 +01:00
parent ee67929a7c
commit 046c2b1cae
8 changed files with 162 additions and 109 deletions

View file

@ -23,7 +23,6 @@
#include <spa/lib/debug.h>
#include "pinos/client/pinos.h"
#include "pinos/client/enumtypes.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;
impl->n_buffers = this->output->n_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);
} else {
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);
impl->allocated = TRUE;
impl->allocated = true;
}
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);
this->output->buffers = impl->buffers;
this->output->n_buffers = impl->n_buffers;
this->output->allocated = TRUE;
this->output->allocated = true;
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);
} else if (in_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
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);
this->input->buffers = impl->buffers;
this->input->n_buffers = impl->n_buffers;
this->input->allocated = TRUE;
this->input->allocated = true;
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);
}
}
@ -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);
this->input->buffers = impl->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) {
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);
this->output->buffers = impl->buffers;
this->output->n_buffers = impl->n_buffers;
this->output->allocated = FALSE;
this->output->allocated = false;
} else {
asprintf (&error, "no common buffer alloc found");
goto error;
@ -487,10 +486,10 @@ error:
{
this->output->buffers = NULL;
this->output->n_buffers = 0;
this->output->allocated = FALSE;
this->output->allocated = false;
this->input->buffers = NULL;
this->input->n_buffers = 0;
this->input->allocated = FALSE;
this->input->allocated = false;
pinos_link_report_error (this, error);
return res;
}
@ -520,7 +519,7 @@ do_start (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
static SpaResult
check_states (PinosLink *this,
gpointer user_data,
void *user_data,
SpaResult res)
{
SpaNodeState in_state, out_state;
@ -586,7 +585,7 @@ on_output_async_complete_notify (PinosListener *listener,
}
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);

View file

@ -22,8 +22,6 @@
#include <errno.h>
#include <sys/eventfd.h>
#include <gio/gio.h>
#include "spa/include/spa/list.h"
#include "spa/include/spa/ringbuffer.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);
item->seq = SPA_ID_INVALID;
item->res = res;
have_work = TRUE;
have_work = true;
} else {
item->seq = SPA_ID_INVALID;
item->res = res;
have_work = TRUE;
have_work = true;
pinos_log_debug ("main-loop %p: defer object %p", loop, obj);
}
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);
item->seq = SPA_ID_INVALID;
item->res = res;
have_work = TRUE;
have_work = true;
}
}
if (!have_work) {

View file

@ -23,7 +23,10 @@
#endif
#include <dlfcn.h>
#include <glib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
#include "pinos/client/pinos.h"
#include "pinos/client/utils.h"
@ -42,42 +45,47 @@ static char *
find_module (const char * path, const char *name)
{
char *filename;
GDir *dir;
const gchar *entry;
GError *err = NULL;
struct dirent *entry;
struct stat s;
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 */
return filename;
}
g_clear_pointer (&filename, g_free);
free (filename);
filename = NULL;
/* now recurse down in subdirectories and look for it there */
dir = g_dir_open (path, 0, &err);
dir = opendir (path);
if (dir == NULL) {
pinos_log_warn ("could not open %s: %s", path, err->message);
g_error_free (err);
pinos_log_warn ("could not open %s: %s", path, strerror (errno));
return NULL;
}
while ((entry = g_dir_read_name (dir))) {
gchar *newpath;
while ((entry = readdir (dir))) {
char *newpath;
newpath = g_build_filename (path, entry, NULL);
if (g_file_test (newpath, G_FILE_TEST_IS_DIR)) {
if (strcmp (entry->d_name, ".") == 0 ||
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);
}
g_free (newpath);
free (newpath);
if (filename != NULL)
break;
}
g_dir_close (dir);
closedir (dir);
return filename;
}
@ -95,8 +103,8 @@ find_module (const char * path, const char *name)
*/
PinosModule *
pinos_module_load (PinosCore *core,
const gchar *name,
const gchar *args,
const char *name,
const char *args,
char **err)
{
PinosModule *this;
@ -113,7 +121,7 @@ pinos_module_load (PinosCore *core,
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++) {
filename = find_module (l[i], name);
if (filename != NULL)
@ -147,7 +155,7 @@ pinos_module_load (PinosCore *core,
this->name = strdup (name);
this->core = core;
if (!init_func (this, (gchar *) args))
if (!init_func (this, (char *) args))
goto init_failed;
pinos_log_debug ("loaded module: %s", this->name);

View file

@ -22,7 +22,6 @@
#include <errno.h>
#include "pinos/client/pinos.h"
#include "pinos/client/enumtypes.h"
#include "pinos/server/node.h"
#include "pinos/server/data-loop.h"
@ -639,10 +638,10 @@ pinos_node_get_free_port (PinosNode *node,
static void
on_state_complete (PinosNode *node,
gpointer data,
void *data,
SpaResult res)
{
PinosNodeState state = GPOINTER_TO_INT (data);
PinosNodeState state = SPA_PTR_TO_INT (data);
char *error = NULL;
pinos_log_debug ("node %p: state complete %d", node, res);
@ -702,7 +701,7 @@ pinos_node_set_state (PinosNode *node,
node,
res,
(PinosDeferFunc) on_state_complete,
GINT_TO_POINTER (state));
SPA_INT_TO_PTR (state));
return res;
}

View file

@ -22,7 +22,6 @@
#include <errno.h>
#include "pinos/client/pinos.h"
#include "pinos/client/enumtypes.h"
#include "pinos/server/port.h"