Browse Source

pulse-server: split out extension handling

Part of !776.
lines
Barnabás Pőcze 1 year ago
parent
commit
c49ae39888
5 changed files with 84 additions and 29 deletions
  1. +1
    -0
      src/modules/meson.build
  2. +6
    -15
      src/modules/module-protocol-pulse/extension.c
  3. +47
    -0
      src/modules/module-protocol-pulse/extension.h
  4. +27
    -10
      src/modules/module-protocol-pulse/extensions/ext-stream-restore.c
  5. +3
    -4
      src/modules/module-protocol-pulse/pulse-server.c

+ 1
- 0
src/modules/meson.build View File

@ -136,6 +136,7 @@ pipewire_module_protocol_pulse_sources = [
'module-protocol-pulse/client.c',
'module-protocol-pulse/collect.c',
'module-protocol-pulse/dbus-name.c',
'module-protocol-pulse/extension.c',
'module-protocol-pulse/format.c',
'module-protocol-pulse/manager.c',
'module-protocol-pulse/media-roles.c',


+ 6
- 15
src/modules/module-protocol-pulse/extension.c View File

@ -22,21 +22,10 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/utils/defs.h>
#include <spa/utils/string.h>
struct extension_sub {
const char *name;
uint32_t command;
int (*process)(struct client *client, uint32_t command, uint32_t tag, struct message *m);
};
struct extension {
const char *name;
uint32_t idx;
int (*process)(struct client *client, uint32_t tag, struct message *m);
};
#include "ext-stream-restore.c"
#include "extension.h"
static int do_extension_device_restore(struct client *client, uint32_t tag, struct message *m)
{
@ -48,13 +37,15 @@ static int do_extension_device_manager(struct client *client, uint32_t tag, stru
return -ENOTSUP;
}
struct extension extensions[] = {
#include "extensions/ext-stream-restore.c"
static const struct extension extensions[] = {
{ "module-stream-restore", 0 | EXTENSION_FLAG, do_extension_stream_restore, },
{ "module-device-restore", 1 | EXTENSION_FLAG, do_extension_device_restore, },
{ "module-device-manager", 2 | EXTENSION_FLAG, do_extension_device_manager, },
};
static struct extension *find_extension(uint32_t idx, const char *name)
const struct extension *extension_find(uint32_t idx, const char *name)
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(extensions); i++) {


+ 47
- 0
src/modules/module-protocol-pulse/extension.h View File

@ -0,0 +1,47 @@
/* PipeWire
*
* Copyright © 2020 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 PULSE_SERVER_EXTENSION_H
#define PULSE_SERVER_EXTENSION_H
#include <stdint.h>
struct client;
struct message;
struct extension_sub {
const char *name;
uint32_t command;
int (*process)(struct client *client, uint32_t command, uint32_t tag, struct message *m);
};
struct extension {
const char *name;
uint32_t idx;
int (*process)(struct client *client, uint32_t tag, struct message *m);
};
const struct extension *extension_find(uint32_t idx, const char *name);
#endif /* PULSE_SERVER_EXTENSION_H */

src/modules/module-protocol-pulse/ext-stream-restore.c → src/modules/module-protocol-pulse/extensions/ext-stream-restore.c View File


+ 3
- 4
src/modules/module-protocol-pulse/pulse-server.c View File

@ -63,6 +63,7 @@
#include "commands.h"
#include "dbus-name.h"
#include "defs.h"
#include "extension.h"
#include "format.h"
#include "internal.h"
#include "message.h"
@ -121,8 +122,6 @@ static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *n
return NULL;
}
#include "extension.c"
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id)
{
struct server *s;
@ -4225,7 +4224,7 @@ static int do_extension(struct client *client, uint32_t command, uint32_t tag, s
struct impl *impl = client->impl;
uint32_t idx;
const char *name;
struct extension *ext;
const struct extension *ext;
if (message_get(m,
TAG_U32, &idx,
@ -4240,7 +4239,7 @@ static int do_extension(struct client *client, uint32_t command, uint32_t tag, s
(idx != SPA_ID_INVALID && name != NULL))
return -EINVAL;
ext = find_extension(idx, name);
ext = extension_find(idx, name);
if (ext == NULL)
return -ENOENT;


Loading…
Cancel
Save