handle set_format with existing format

If one calls set-format with the current format, we return success
Remove some unused utils now
Work on cleanup of buffers
This commit is contained in:
Wim Taymans 2016-08-11 11:20:12 +02:00
parent 55c3262a6a
commit ab0537305f
9 changed files with 82 additions and 143 deletions

View file

@ -212,7 +212,6 @@ libpinoscore_@PINOS_MAJORMINOR@_la_SOURCES = \
server/node.c server/node.h \
server/port.c server/port.h \
server/node-factory.c server/node-factory.h \
server/utils.c server/utils.h \
modules/gst/gst-manager.c modules/gst/gst-manager.h \
modules/gst/gst-source.c modules/gst/gst-source.h \
modules/gst/gst-sink.c modules/gst/gst-sink.h \

View file

@ -37,7 +37,6 @@
#include "pinos/server/daemon.h"
#include "pinos/server/client-node.h"
#include "pinos/server/utils.h"
#include "pinos/server/link.h"
#include "pinos/dbus/org-pinos.h"

View file

@ -267,12 +267,22 @@ do_allocation (PinosLink *this)
{
PinosLinkPrivate *priv = this->priv;
SpaResult res;
const SpaPortInfo *iinfo, *oinfo;
g_debug ("link %p: doing alloc buffers", this);
/* find out what's possible */
if ((res = spa_node_port_get_info (priv->output_node, priv->output_port, &oinfo)) < 0) {
g_warning ("error get port info: %d", res);
return res;
}
if ((res = spa_node_port_get_info (priv->input_node, priv->input_port, &iinfo)) < 0) {
g_warning ("error get port info: %d", res);
return res;
}
priv->n_buffers = 16;
if ((res = spa_node_port_alloc_buffers (priv->output_node, priv->output_port,
NULL, 0,
iinfo->params, iinfo->n_params,
priv->buffers, &priv->n_buffers)) < 0) {
g_warning ("error alloc buffers: %d", res);
return res;

View file

@ -105,7 +105,7 @@ node_add_port (PinosNode *node,
"id", id,
NULL);
if (port) {
g_hash_table_insert (priv->ports, GUINT_TO_POINTER (id), port);
g_hash_table_insert (priv->ports, GUINT_TO_POINTER (port->id), port);
g_signal_connect (port, "remove", (GCallback) do_remove_port, node);
g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, port);
}

View file

@ -26,7 +26,6 @@
#include "pinos/server/port.h"
#include "pinos/server/node.h"
#include "pinos/server/utils.h"
#define PINOS_PORT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_PORT, PinosPortPrivate))

View file

@ -1,84 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include <gst/gst.h>
#include <gio/gio.h>
#include "pinos/server/utils.h"
GBytes *
pinos_format_filter (GBytes *format,
GBytes *filter,
GError **error)
{
GstCaps *tmp, *caps, *cfilter;
gchar *str;
GBytes *res;
if (filter) {
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
if (cfilter == NULL)
goto invalid_filter;
} else {
cfilter = NULL;
}
if (format)
caps = gst_caps_from_string (g_bytes_get_data (format, NULL));
else
caps = gst_caps_new_any ();
if (caps && cfilter) {
tmp = gst_caps_intersect_full (caps, cfilter, GST_CAPS_INTERSECT_FIRST);
gst_caps_take (&caps, tmp);
}
g_clear_pointer (&cfilter, gst_caps_unref);
if (caps == NULL || gst_caps_is_empty (caps))
goto no_format;
str = gst_caps_to_string (caps);
gst_caps_unref (caps);
res = g_bytes_new_take (str, strlen (str) + 1);
return res;
invalid_filter:
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
"Invalid filter received");
return NULL;
}
no_format:
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"No compatible format found");
if (cfilter)
gst_caps_unref (cfilter);
if (caps)
gst_caps_unref (caps);
return NULL;
}
}

View file

@ -1,31 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_UTILS_H__
#define __PINOS_UTILS_H__
#include <glib-object.h>
G_BEGIN_DECLS
GBytes * pinos_format_filter (GBytes *format1, GBytes *format2, GError **error);
G_END_DECLS
#endif /* __PINOS_UTILS_H__ */