mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-26 07:00:13 -05:00
alsa: use timerfd
Use timerfd instead of period events to wake up alsa. module-autolink: fix crash Some cleanups
This commit is contained in:
parent
c86673b557
commit
46928cbc04
8 changed files with 197 additions and 139 deletions
|
|
@ -1,54 +0,0 @@
|
|||
#!/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)
|
||||
|
|
@ -170,7 +170,6 @@ core_event_update_types (void *object,
|
|||
|
||||
for (i = 0; i < n_types; i++, first_id++) {
|
||||
SpaType this_id = spa_type_map_get_id (this->type.map, types[i]);
|
||||
printf ("update %d %s -> %d\n", first_id, types[i], this_id);
|
||||
if (!pinos_map_insert_at (&this->types, first_id, SPA_UINT32_TO_PTR (this_id)))
|
||||
pinos_log_error ("can't add type for client");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -675,10 +675,14 @@ gst_pinos_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
|||
|
||||
if (buffer->pool != GST_BUFFER_POOL_CAST (pinossink->pool)) {
|
||||
GstBuffer *b = NULL;
|
||||
GstMapInfo info = { 0, };
|
||||
|
||||
gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL_CAST (pinossink->pool), &b, NULL);
|
||||
|
||||
/* FIXME, copy */
|
||||
gst_buffer_map (b, &info, GST_MAP_WRITE);
|
||||
gst_buffer_extract (buffer, 0, info.data, info.size);
|
||||
gst_buffer_unmap (b, &info);
|
||||
gst_buffer_resize (b, 0, info.size);
|
||||
buffer = b;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ typedef struct {
|
|||
PinosListener global_added;
|
||||
PinosListener global_removed;
|
||||
|
||||
SpaList node_list;
|
||||
SpaList client_list;
|
||||
} ModuleImpl;
|
||||
|
||||
|
|
@ -45,6 +44,7 @@ typedef struct {
|
|||
SpaList link;
|
||||
PinosListener resource_added;
|
||||
PinosListener resource_removed;
|
||||
SpaList node_list;
|
||||
} ClientInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -61,11 +61,11 @@ typedef struct {
|
|||
} NodeInfo;
|
||||
|
||||
static NodeInfo *
|
||||
find_node_info (ModuleImpl *impl, PinosNode *node)
|
||||
find_node_info (ClientInfo *cinfo, PinosNode *node)
|
||||
{
|
||||
NodeInfo *info;
|
||||
|
||||
spa_list_for_each (info, &impl->node_list, link) {
|
||||
spa_list_for_each (info, &cinfo->node_list, link) {
|
||||
if (info->node == node)
|
||||
return info;
|
||||
}
|
||||
|
|
@ -99,9 +99,15 @@ node_info_free (NodeInfo *info)
|
|||
static void
|
||||
client_info_free (ClientInfo *cinfo)
|
||||
{
|
||||
NodeInfo *info, *tmp;
|
||||
|
||||
spa_list_remove (&cinfo->link);
|
||||
pinos_signal_remove (&cinfo->resource_added);
|
||||
pinos_signal_remove (&cinfo->resource_removed);
|
||||
|
||||
spa_list_for_each_safe (info, tmp, &cinfo->node_list, link)
|
||||
node_info_free (info);
|
||||
|
||||
free (cinfo);
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +291,7 @@ on_node_added (ModuleImpl *impl,
|
|||
info->node = node;
|
||||
info->resource = resource;
|
||||
info->info = cinfo;
|
||||
spa_list_insert (impl->node_list.prev, &info->link);
|
||||
spa_list_insert (cinfo->node_list.prev, &info->link);
|
||||
|
||||
spa_list_init (&info->port_unlinked.link);
|
||||
spa_list_init (&info->link_state_changed.link);
|
||||
|
|
@ -325,7 +331,7 @@ on_resource_removed (PinosListener *listener,
|
|||
PinosClientNode *cnode = resource->object;
|
||||
NodeInfo *ninfo;
|
||||
|
||||
if ((ninfo = find_node_info (impl, cnode->node)))
|
||||
if ((ninfo = find_node_info (cinfo, cnode->node)))
|
||||
node_info_free (ninfo);
|
||||
|
||||
pinos_log_debug ("module %p: node %p removed", impl, cnode->node);
|
||||
|
|
@ -346,6 +352,8 @@ on_global_added (PinosListener *listener,
|
|||
cinfo = calloc (1, sizeof (ClientInfo));
|
||||
cinfo->impl = impl;
|
||||
cinfo->client = global->object;
|
||||
spa_list_init (&cinfo->node_list);
|
||||
|
||||
spa_list_insert (impl->client_list.prev, &cinfo->link);
|
||||
|
||||
pinos_signal_add (&client->resource_added, &cinfo->resource_added, on_resource_added);
|
||||
|
|
@ -394,7 +402,6 @@ module_new (PinosCore *core,
|
|||
impl->core = core;
|
||||
impl->properties = properties;
|
||||
|
||||
spa_list_init (&impl->node_list);
|
||||
spa_list_init (&impl->client_list);
|
||||
|
||||
pinos_signal_add (&core->global_added, &impl->global_added, on_global_added);
|
||||
|
|
|
|||
|
|
@ -215,7 +215,6 @@ core_update_types (void *object,
|
|||
|
||||
for (i = 0; i < n_types; i++, first_id++) {
|
||||
uint32_t this_id = spa_type_map_get_id (this->type.map, types[i]);
|
||||
printf ("update %d %s -> %d\n", first_id, types[i], this_id);
|
||||
if (!pinos_map_insert_at (&client->types, first_id, SPA_UINT32_TO_PTR (this_id)))
|
||||
pinos_log_error ("can't add type for client");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 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 <sys/syscall.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/*
|
||||
* No glibc wrappers exist for memfd_create(2), so provide our own.
|
||||
*
|
||||
* Also define memfd fcntl sealing macros. While they are already
|
||||
* defined in the kernel header file <linux/fcntl.h>, that file as
|
||||
* a whole conflicts with the original glibc header <fnctl.h>.
|
||||
*/
|
||||
|
||||
static inline int memfd_create(const char *name, unsigned int flags) {
|
||||
return syscall(SYS_memfd_create, name, flags);
|
||||
}
|
||||
|
||||
/* memfd_create(2) flags */
|
||||
|
||||
#ifndef MFD_CLOEXEC
|
||||
#define MFD_CLOEXEC 0x0001U
|
||||
#endif
|
||||
|
||||
#ifndef MFD_ALLOW_SEALING
|
||||
#define MFD_ALLOW_SEALING 0x0002U
|
||||
#endif
|
||||
|
||||
/* fcntl() seals-related flags */
|
||||
|
||||
#ifndef F_LINUX_SPECIFIC_BASE
|
||||
#define F_LINUX_SPECIFIC_BASE 1024
|
||||
#endif
|
||||
|
||||
#ifndef F_ADD_SEALS
|
||||
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
|
||||
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
|
||||
|
||||
#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
|
||||
#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
|
||||
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
|
||||
#define F_SEAL_WRITE 0x0008 /* prevent writes */
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue