port to meson

This commit is contained in:
Wim Taymans 2016-09-26 12:15:52 +02:00
parent 924824d0a3
commit 67dd3adb87
69 changed files with 1056 additions and 999 deletions

54
pinos/client/build_mkenum.py Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env python3
# This is in its own file rather than inside meson.build
# because a) mixing the two is ugly and b) trying to
# make special characters such as \n go through all
# backends is a fool's errand.
import sys, os, shutil, subprocess
h_array = ['--fhead',
"#ifndef __PINOS_ENUM_TYPES_H__\n#define __PINOS_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n",
'--fprod',
"\n/* enumerations from \"@filename@\" */\n",
'--vhead',
"GType @enum_name@_get_type (void);\n#define PINOS_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
'--ftail',
"G_END_DECLS\n\n#endif /* __PINOS_ENUM_TYPES_H__ */"]
c_array = [
'--fhead',
"#include \"pinos.h\"\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n ",
'--fprod',
"\n/* enumerations from \"@filename@\" */",
'--vhead',
"GType\n@enum_name@_get_type (void)\n{\n static gsize id = 0;\n static const G@Type@Value values[] = {",
'--vprod',
" { C_@TYPE@(@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
'--vtail',
" { 0, NULL, NULL }\n };\n\n if (g_once_init_enter (&id)) {\n GType tmp = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&id, tmp);\n }\n\n return (GType) id;\n}"
]
cmd = []
argn = 1
# Find the full command needed to run glib-mkenums
# On UNIX-like, this is just the full path to glib-mkenums
# On Windows, this is the full path to interpreter + full path to glib-mkenums
for arg in sys.argv[1:]:
cmd.append(arg)
argn += 1
if arg.endswith('glib-mkenums'):
break
ofilename = sys.argv[argn]
headers = sys.argv[argn + 1:]
if ofilename.endswith('.h'):
arg_array = h_array
else:
arg_array = c_array
pc = subprocess.Popen(cmd + arg_array + headers, stdout=subprocess.PIPE)
(stdo, _) = pc.communicate()
if pc.returncode != 0:
sys.exit(pc.returncode)
open(ofilename, 'wb').write(stdo)

View file

@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
#include <pinos/client/pinos.h>
#include <pinos/client/format.h>
static SpaFormat *

View file

@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "pinos.h"
#include "mainloop.h"
struct _PinosMainLoopPrivate

69
pinos/client/meson.build Normal file
View file

@ -0,0 +1,69 @@
pinos_headers = [
'context.h',
'format.h',
'introspect.h',
'mainloop.h',
'pinos.h',
'properties.h',
'stream.h',
'ringbuffer.h',
'subscribe.h',
]
pinos_sources = [
'context.c',
'format.c',
'introspect.c',
'mainloop.c',
'properties.c',
'stream.c',
'pinos.c',
'ringbuffer.c',
'subscribe.c',
]
install_headers(pinos_headers, subdir : 'pinos/client')
mkenums = find_program('build_mkenum.py')
glib_mkenums = find_program('glib-mkenums')
enumtypes_h = custom_target('enumtypes_h',
output : 'enumtypes.h',
input : pinos_headers,
install : true,
install_dir : 'include/pinos/client',
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
enumtypes_c = custom_target('enumtypes_c',
output : 'enumtypes.c',
input : pinos_headers,
depends : [enumtypes_h],
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
libpinos_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
'-DG_LOG_DOMAIN=g_log_domain_pinos',
]
pinos_gen_sources = [enumtypes_h]
libpinos = shared_library('pinos', pinos_sources,
enumtypes_h, enumtypes_c,
version : libversion,
soversion : soversion,
c_args : libpinos_c_args,
include_directories : [configinc, spa_inc],
link_with : spalib,
install : true,
dependencies : [gobject_dep, gmodule_dep, glib_dep, gio_dep, mathlib],
)
pinos_dep = declare_dependency(link_with : libpinos,
include_directories : [configinc, spa_inc],
dependencies : [glib_dep, gobject_dep, gmodule_dep],
# Everything that uses libpinos needs this built to compile
sources : pinos_gen_sources,
)

View file

@ -22,6 +22,8 @@
#include "pinos/client/pinos.h"
#include "spa/include/spa/memory.h"
const gchar g_log_domain_pinos[] = "Pinos";
GQuark
pinos_error_quark (void)
{

View file

@ -20,6 +20,8 @@
#ifndef __PINOS_H__
#define __PINOS_H__
extern const char g_log_domain_pinos[];
#include <pinos/client/context.h>
#include <pinos/client/enumtypes.h>
#include <pinos/client/introspect.h>

View file

@ -19,6 +19,7 @@
#include <glib-object.h>
#include "pinos/client/pinos.h"
#include "pinos/client/properties.h"
struct _PinosProperties {

View file

@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
@ -28,6 +26,7 @@
#include <gio/gio.h>
#include <glib-object.h>
#include <pinos/client/pinos.h>
#include <pinos/client/enumtypes.h>
#include <pinos/client/ringbuffer.h>

View file

@ -632,8 +632,10 @@ add_state_change (PinosStream *stream, SpaControlBuilder *builder, SpaNodeState
PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeStateChange sc;
sc.state = priv->node_state = state;
spa_control_builder_add_cmd (builder, SPA_CONTROL_CMD_NODE_STATE_CHANGE, &sc);
if (priv->node_state != state) {
sc.state = priv->node_state = state;
spa_control_builder_add_cmd (builder, SPA_CONTROL_CMD_NODE_STATE_CHANGE, &sc);
}
}
static void
@ -1504,27 +1506,7 @@ pinos_stream_start (PinosStream *stream)
static gboolean
do_stop (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
SpaControlBuilder builder;
SpaControl control;
SpaControlCmdNodeCommand cnc;
SpaNodeCommand nc;
control_builder_init (stream, &builder);
cnc.command = &nc;
nc.type = SPA_NODE_COMMAND_PAUSE;
nc.data = NULL;
nc.size = 0;
spa_control_builder_add_cmd (&builder, SPA_CONTROL_CMD_NODE_COMMAND, &cnc);
spa_control_builder_end (&builder, &control);
if (spa_control_write (&control, priv->fd) < 0)
g_warning ("stream %p: failed to write control", stream);
spa_control_clear (&control);
g_object_unref (stream);
return FALSE;
}

View file

@ -25,7 +25,8 @@
#include <glib.h>
#include <string.h>
#include <server/command.h>
#include <pinos/client/pinos.h>
#include <pinos/server/command.h>
#include "pinos/daemon/daemon-config.h"

View file

@ -25,7 +25,7 @@
G_BEGIN_DECLS
#include <server/daemon.h>
#include <pinos/server/daemon.h>
#define PINOS_TYPE_DAEMON_CONFIG (pinos_daemon_config_get_type ())

View file

@ -20,9 +20,9 @@
#include <gio/gio.h>
#include <glib.h>
#include <client/pinos.h>
#include <server/daemon.h>
#include <server/module.h>
#include <pinos/client/pinos.h>
#include <pinos/server/daemon.h>
#include <pinos/server/module.h>
#include <spa/include/spa/memory.h>
#include "daemon-config.h"

22
pinos/daemon/meson.build Normal file
View file

@ -0,0 +1,22 @@
pinos_sources = [
'main.c',
'daemon-config.c',
]
pinos_headers = [
'daemon-config.h',
]
pinos_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
'-DG_LOG_DOMAIN=g_log_domain_pinos',
]
executable('pinos',
pinos_sources,
install: true,
c_args : pinos_c_args,
include_directories : [configinc, spa_inc],
dependencies : [glib_dep, gobject_dep, gmodule_dep, pinos_dep, pinoscore_dep],
)

15
pinos/dbus/meson.build Normal file
View file

@ -0,0 +1,15 @@
gdbus_codegen = find_program('gdbus-codegen')
org_pinos_files = ['org-pinos.c', 'org-pinos.h']
gdbus_target = custom_target('org-pinos',
output : org_pinos_files,
input : 'org.pinos.xml',
command : [gdbus_codegen,
'--interface-prefix', 'org.pinos.',
'--generate-c-code', 'pinos/dbus/org-pinos',
'--c-namespace', 'Pinos',
'--c-generate-object-manager',
'@INPUT@'],
)

View file

@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <client/pinos.h>
#include <pinos/client/pinos.h>
G_BEGIN_DECLS

View file

@ -28,7 +28,7 @@
#include "config.h"
#endif
#include <client/pinos.h>
#include <pinos/client/pinos.h>
#include <gst/gst.h>

View file

@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <client/pinos.h>
#include <pinos/client/pinos.h>
G_BEGIN_DECLS

View file

@ -23,8 +23,8 @@
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
#include <client/pinos.h>
#include <gst/gstpinospool.h>
#include <pinos/client/pinos.h>
#include <pinos/gst/gstpinospool.h>
G_BEGIN_DECLS

View file

@ -23,7 +23,7 @@
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
#include <client/pinos.h>
#include <pinos/client/pinos.h>
G_BEGIN_DECLS

31
pinos/gst/meson.build Normal file
View file

@ -0,0 +1,31 @@
pinos_gst_sources = [
'gstpinos.c',
'gstpinosclock.c',
'gstpinosdeviceprovider.c',
'gstpinosformat.c',
'gstpinospool.c',
'gstpinossink.c',
'gstpinossrc.c',
]
pinos_gst_headers = [
'gstpinosclock.h',
'gstpinosdeviceprovider.h',
'gstpinosformat.h',
'gstpinospool.h',
'gstpinossink.h',
'gstpinossrc.h',
]
pinos_gst_c_args = [
'-DHAVE_CONFIG_H',
]
pinos_gst = shared_library('gstpinos',
pinos_gst_sources,
c_args : pinos_gst_c_args,
include_directories : [configinc, spa_inc],
dependencies : [gobject_dep, glib_dep, gio_dep, gst_dep, pinos_dep, pinoscore_dep],
install : true,
install_dir : '@0@/gstreamer-1.0'.format(get_option('libdir')),
)

8
pinos/meson.build Normal file
View file

@ -0,0 +1,8 @@
subdir('dbus')
subdir('client')
subdir('server')
subdir('daemon')
subdir('tools')
subdir('modules')
subdir('gst')

View file

@ -0,0 +1,27 @@
pinos_module_spa_headers = [
'spa-alsa-monitor.h',
'spa-audiotestsrc.h',
'spa-v4l2-monitor.h',
'spa-videotestsrc.h',
]
pinos_module_spa_sources = [
'module.c',
'spa-alsa-monitor.c',
'spa-audiotestsrc.c',
'spa-v4l2-monitor.c',
'spa-videotestsrc.c',
]
pinos_module_spa_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
]
pinos_module_spa = shared_library('pinos-module-spa', pinos_module_spa_sources,
c_args : pinos_module_spa_c_args,
include_directories : [configinc, pinosinc, spa_inc],
link_with : spalib,
dependencies : [gobject_dep, gmodule_dep, glib_dep, gio_dep, mathlib, dl_lib, pinos_dep, pinoscore_dep],
)

View file

@ -0,0 +1,2 @@
#subdir('gst')
subdir('spa')

View file

@ -0,0 +1,29 @@
pinos_module_spa_headers = [
'spa-alsa-monitor.h',
'spa-audiotestsrc.h',
'spa-v4l2-monitor.h',
'spa-videotestsrc.h',
]
pinos_module_spa_sources = [
'module.c',
'spa-alsa-monitor.c',
'spa-audiotestsrc.c',
'spa-v4l2-monitor.c',
'spa-videotestsrc.c',
]
pinos_module_spa_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
]
pinos_module_spa = shared_library('pinos-module-spa', pinos_module_spa_sources,
c_args : pinos_module_spa_c_args,
include_directories : [configinc, pinosinc, spa_inc],
link_with : spalib,
install : true,
install_dir : '@0@/pinos-0.1'.format(get_option('libdir')),
dependencies : [gobject_dep, gmodule_dep, glib_dep, gio_dep, mathlib, dl_lib, pinos_dep, pinoscore_dep],
)

View file

@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <poll.h>

View file

@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <poll.h>

View file

@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <spa/include/spa/node.h>

View file

@ -17,8 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include <string.h>
#include <sys/socket.h>
#include <errno.h>

View file

@ -21,7 +21,8 @@
#include <glib.h>
#include <string.h>
#include <server/module.h>
#include <pinos/client/pinos.h>
#include <pinos/server/module.h>
#include "command.h"

View file

@ -25,7 +25,7 @@
G_BEGIN_DECLS
#include <server/daemon.h>
#include <pinos/server/daemon.h>
typedef struct _PinosCommand PinosCommand;

View file

@ -554,11 +554,17 @@ do_start (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
} else {
pinos_link_update_state (this, PINOS_LINK_STATE_PAUSED);
if (in_state == SPA_NODE_STATE_PAUSED)
if (in_state == SPA_NODE_STATE_PAUSED) {
pinos_node_set_state (this->input_node, PINOS_NODE_STATE_RUNNING);
if (pinos_node_get_state (this->input_node) != PINOS_NODE_STATE_RUNNING)
res = SPA_RESULT_RETURN_ASYNC (0);
}
if (out_state == SPA_NODE_STATE_PAUSED)
if (out_state == SPA_NODE_STATE_PAUSED) {
pinos_node_set_state (this->output_node, PINOS_NODE_STATE_RUNNING);
if (pinos_node_get_state (this->output_node) != PINOS_NODE_STATE_RUNNING)
res = SPA_RESULT_RETURN_ASYNC (0);
}
}
return res;
}

42
pinos/server/meson.build Normal file
View file

@ -0,0 +1,42 @@
pinoscore_headers = [
'client.h',
'client-node.h',
'command.h',
'daemon.h',
'link.h',
'module.h',
'node.h',
'node-factory.h',
]
pinoscore_sources = [
'client.c',
'client-node.c',
'command.c',
'daemon.c',
'link.c',
'module.c',
'node.c',
'node-factory.c',
]
libpinoscore_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
]
libpinoscore = shared_library('pinoscore', pinoscore_sources, gdbus_target,
version : libversion,
soversion : soversion,
c_args : libpinoscore_c_args,
include_directories : [configinc, spa_inc],
link_with : spalib,
install : true,
dependencies : [gobject_dep, gmodule_dep, glib_dep, gio_dep, mathlib, dl_lib, pinos_dep],
)
pinoscore_dep = declare_dependency(link_with : libpinoscore,
include_directories : [configinc, spa_inc],
dependencies : [glib_dep, gobject_dep, gmodule_dep, pinos_dep],
)

View file

@ -25,6 +25,7 @@
#include <glib.h>
#include <gmodule.h>
#include "pinos/client/pinos.h"
#include "pinos/server/module.h"
#define PINOS_SYMBOL_MODULE_INIT "pinos__module_init"

View file

@ -28,7 +28,7 @@ typedef struct _PinosNodeFactory PinosNodeFactory;
typedef struct _PinosNodeFactoryClass PinosNodeFactoryClass;
typedef struct _PinosNodeFactoryPrivate PinosNodeFactoryPrivate;
#include <server/daemon.h>
#include <pinos/server/daemon.h>
#define PINOS_TYPE_NODE_FACTORY (pinos_node_factory_get_type ())
#define PINOS_IS_NODE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE_FACTORY))

View file

@ -80,6 +80,8 @@ struct _PinosNodePrivate
guint n_used_input_links;
SpaNodeEventAsyncComplete ac;
uint32_t pending_state_seq;
PinosNodeState pending_state;
};
G_DEFINE_TYPE (PinosNode, pinos_node, G_TYPE_OBJECT);
@ -359,13 +361,20 @@ start_node (PinosNode *this)
static SpaResult
suspend_node (PinosNode *this)
{
SpaResult res;
PinosNodePrivate *priv = this->priv;
SpaResult res = SPA_RESULT_OK;
guint i;
g_debug ("node %p: suspend node", this);
if ((res = spa_node_port_set_format (this->node, 0, 0, NULL)) < 0)
g_warning ("error unset format output: %d", res);
for (i = 0; i < priv->n_input_ports; i++) {
if ((res = spa_node_port_set_format (this->node, priv->input_port_ids[i], 0, NULL)) < 0)
g_warning ("error unset format output: %d", res);
}
for (i = 0; i < priv->n_output_ports; i++) {
if ((res = spa_node_port_set_format (this->node, priv->output_port_ids[i], 0, NULL)) < 0)
g_warning ("error unset format output: %d", res);
}
return res;
}
@ -404,6 +413,7 @@ static gboolean
node_set_state (PinosNode *this,
PinosNodeState state)
{
PinosNodePrivate *priv = this->priv;
SpaResult res = SPA_RESULT_OK;
g_debug ("node %p: set state %s", this, pinos_node_state_as_string (state));
@ -434,7 +444,12 @@ node_set_state (PinosNode *this,
if (SPA_RESULT_IS_ERROR (res))
return FALSE;
pinos_node_update_state (this, state);
if (SPA_RESULT_IS_ASYNC (res)) {
priv->pending_state_seq = SPA_RESULT_ASYNC_SEQ (res);
priv->pending_state = state;
} else {
pinos_node_update_state (this, state);
}
return TRUE;
}
@ -482,6 +497,9 @@ do_handle_async_complete (PinosNode *this)
init_complete (this);
priv->async_init = FALSE;
}
if (priv->pending_state_seq == ac->seq) {
pinos_node_update_state (this, priv->pending_state);
}
g_signal_emit (this, signals[SIGNAL_ASYNC_COMPLETE], 0, ac->seq, ac->res);
}
@ -1029,6 +1047,7 @@ pinos_node_init (PinosNode * node)
(GCallback) handle_remove,
node);
priv->state = PINOS_NODE_STATE_CREATING;
priv->pending_state_seq = SPA_ID_INVALID;
pinos_node1_set_state (priv->iface, priv->state);
priv->input_links = g_array_new (FALSE, TRUE, sizeof (NodeLink));

5
pinos/tools/meson.build Normal file
View file

@ -0,0 +1,5 @@
executable('pinos-monitor',
'pinos-monitor.c',
install: true,
dependencies : [glib_dep, gobject_dep, gmodule_dep, pinos_dep],
)

View file

@ -17,7 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
#include <client/pinos.h>
#include <pinos/client/pinos.h>
static GMainLoop *loop;