mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
stream: remove client-stream
Use an adapter instead of the client-stream. This means we run the audioconverters and resamplers in the client instead of the pipewire daemon. It also allows us to implement the audio mixing correctly in the capture client. The only pending piece is that we now wake up the client with the period of the server. Maybe we can later optimize that and accumulate/split buffers before waking the client. This probably needs fixing with video..
This commit is contained in:
parent
01d9f4eb3a
commit
0cdc3dce0b
6 changed files with 55 additions and 1427 deletions
|
|
@ -27,7 +27,6 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
|||
[ 'module-client-node.c',
|
||||
'module-client-node/remote-node.c',
|
||||
'module-client-node/client-node.c',
|
||||
'module-client-node/client-stream.c',
|
||||
'module-client-node/protocol-native.c',
|
||||
'spa/spa-node.c', ],
|
||||
c_args : pipewire_module_c_args,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <pipewire/pipewire.h>
|
||||
|
||||
#include "module-client-node/client-node.h"
|
||||
#include "module-client-node/client-stream.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
|
|
@ -79,12 +78,7 @@ static void *create_object(void *_data,
|
|||
|
||||
parent = pw_client_get_global(client);
|
||||
|
||||
if (properties && pw_properties_get(properties, PW_KEY_NODE_STREAM) != NULL) {
|
||||
result = pw_client_stream_new(node_resource, parent, properties);
|
||||
}
|
||||
else {
|
||||
result = pw_client_node_new(node_resource, parent, properties, true);
|
||||
}
|
||||
result = pw_client_node_new(node_resource, parent, properties, true);
|
||||
if (result == NULL) {
|
||||
res = -errno;
|
||||
goto error_node;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,54 +0,0 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2018 Wim Taymans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIPEWIRE_CLIENT_STREAM_H
|
||||
#define PIPEWIRE_CLIENT_STREAM_H
|
||||
|
||||
#include <pipewire/node.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \class pw_client_stream
|
||||
*
|
||||
* PipeWire client stream interface
|
||||
*/
|
||||
struct pw_client_stream {
|
||||
struct pw_node *node;
|
||||
};
|
||||
|
||||
struct pw_client_stream *
|
||||
pw_client_stream_new(struct pw_resource *resource,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties);
|
||||
|
||||
void
|
||||
pw_client_stream_destroy(struct pw_client_stream *stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PIPEWIRE_CLIENT_STREAM_H */
|
||||
|
|
@ -215,6 +215,7 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
|
|||
|
||||
pw_module_load(core, "libpipewire-module-rtkit", NULL, NULL, NULL, NULL);
|
||||
pw_module_load(core, "libpipewire-module-client-node", NULL, NULL, NULL, NULL);
|
||||
pw_module_load(core, "libpipewire-module-adapter", NULL, NULL, NULL, NULL);
|
||||
|
||||
spa_list_append(&core->remote_list, &this->link);
|
||||
|
||||
|
|
|
|||
|
|
@ -959,37 +959,55 @@ static const struct pw_node_proxy_events node_events = {
|
|||
static int handle_connect(struct pw_stream *stream)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
struct pw_factory *factory;
|
||||
struct pw_properties *props;
|
||||
struct pw_node *slave;
|
||||
const char *str;
|
||||
int res;
|
||||
|
||||
pw_log_debug("stream %p: creating node", stream);
|
||||
impl->node = pw_node_new(impl->core, stream->name,
|
||||
pw_properties_copy(stream->properties), 0);
|
||||
if (impl->node == NULL)
|
||||
props = pw_properties_copy(stream->properties);
|
||||
|
||||
if ((str = pw_properties_get(props, PW_KEY_STREAM_MONITOR)) &&
|
||||
pw_properties_parse_bool(str)) {
|
||||
pw_properties_set(props, "resample.peaks", "1");
|
||||
}
|
||||
|
||||
slave = pw_node_new(impl->core, stream->name,
|
||||
pw_properties_copy(props), 0);
|
||||
if (slave == NULL) {
|
||||
res = -errno;
|
||||
goto error_node;
|
||||
}
|
||||
|
||||
impl->node_methods = impl_node;
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||
impl->node_methods.process = impl_node_process_input;
|
||||
else
|
||||
impl->node_methods.process = impl_node_process_output;
|
||||
|
||||
impl->impl_node.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Node,
|
||||
SPA_VERSION_NODE,
|
||||
&impl->node_methods, impl);
|
||||
|
||||
pw_node_set_implementation(impl->node, &impl->impl_node);
|
||||
|
||||
pw_node_register(impl->node, NULL, NULL, NULL);
|
||||
pw_node_set_implementation(slave, &impl->impl_node);
|
||||
if (!SPA_FLAG_CHECK(impl->flags, PW_STREAM_FLAG_INACTIVE))
|
||||
pw_node_set_active(impl->node, true);
|
||||
pw_node_set_active(slave, true);
|
||||
|
||||
factory = pw_core_find_factory(impl->core, "adapter");
|
||||
if (factory == NULL) {
|
||||
pw_log_error("no adapter factory found");
|
||||
res = -ENOENT;
|
||||
goto error_node;
|
||||
}
|
||||
pw_properties_setf(props, "adapt.slave.node", "pointer:%p", slave);
|
||||
impl->node = pw_factory_create_object(factory,
|
||||
NULL,
|
||||
PW_TYPE_INTERFACE_Node,
|
||||
PW_VERSION_NODE_PROXY,
|
||||
props,
|
||||
0);
|
||||
if (impl->node == NULL) {
|
||||
res = -errno;
|
||||
goto error_node;
|
||||
}
|
||||
pw_log_debug("stream %p: export node %p", stream, impl->node);
|
||||
stream->proxy = pw_remote_export(stream->remote,
|
||||
PW_TYPE_INTERFACE_Node, NULL, impl->node, 0);
|
||||
if (stream->proxy == NULL)
|
||||
if (stream->proxy == NULL) {
|
||||
res = -errno;
|
||||
goto error_proxy;
|
||||
}
|
||||
|
||||
pw_proxy_add_listener(stream->proxy, &stream->proxy_listener, &proxy_events, stream);
|
||||
pw_node_proxy_add_listener((struct pw_node_proxy*)stream->proxy,
|
||||
|
|
@ -998,12 +1016,10 @@ static int handle_connect(struct pw_stream *stream)
|
|||
return 0;
|
||||
|
||||
error_node:
|
||||
res = -errno;
|
||||
pw_log_error("stream %p: can't make node: %m", stream);
|
||||
pw_log_error("stream %p: can't make node: %s", stream, spa_strerror(res));
|
||||
return res;
|
||||
error_proxy:
|
||||
res = -errno;
|
||||
pw_log_error("stream %p: can't make proxy: %m", stream);
|
||||
pw_log_error("stream %p: can't make proxy: %s", stream, spa_strerror(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1302,6 +1318,17 @@ pw_stream_connect(struct pw_stream *stream,
|
|||
impl->direction =
|
||||
direction == PW_DIRECTION_INPUT ? SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT;
|
||||
impl->flags = flags;
|
||||
impl->node_methods = impl_node;
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||
impl->node_methods.process = impl_node_process_input;
|
||||
else
|
||||
impl->node_methods.process = impl_node_process_output;
|
||||
|
||||
impl->impl_node.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Node,
|
||||
SPA_VERSION_NODE,
|
||||
&impl->node_methods, impl);
|
||||
|
||||
impl->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, 0);
|
||||
impl->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, 0);
|
||||
|
|
@ -1321,13 +1348,14 @@ pw_stream_connect(struct pw_stream *stream,
|
|||
pw_properties_setf(stream->properties, PW_KEY_NODE_TARGET, "%d", target_id);
|
||||
if (flags & PW_STREAM_FLAG_AUTOCONNECT)
|
||||
pw_properties_set(stream->properties, PW_KEY_NODE_AUTOCONNECT, "1");
|
||||
pw_properties_set(stream->properties, PW_KEY_NODE_STREAM, "1");
|
||||
if (flags & PW_STREAM_FLAG_DRIVER)
|
||||
pw_properties_set(stream->properties, PW_KEY_NODE_DRIVER, "1");
|
||||
if (flags & PW_STREAM_FLAG_EXCLUSIVE)
|
||||
pw_properties_set(stream->properties, PW_KEY_NODE_EXCLUSIVE, "1");
|
||||
if (flags & PW_STREAM_FLAG_DONT_RECONNECT)
|
||||
pw_properties_set(stream->properties, PW_KEY_NODE_DONT_RECONNECT, "1");
|
||||
pw_properties_setf(stream->properties, PW_KEY_MEDIA_CLASS, "Stream/%s/Audio",
|
||||
direction == PW_DIRECTION_INPUT ? "Input" : "Output");
|
||||
|
||||
state = pw_remote_get_state(stream->remote, NULL);
|
||||
impl->async_connect = (state == PW_REMOTE_STATE_UNCONNECTED ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue