Rework support

Load the mapper from the support plugin
Move the support setup in pw_init
This commit is contained in:
Wim Taymans 2017-06-14 11:48:41 +02:00
parent b9c719ac7e
commit f55f1739e1
18 changed files with 192 additions and 278 deletions

View file

@ -1,9 +0,0 @@
spa_logger_sources = ['logger.c', 'plugin.c']
spa_logger_lib = shared_library('spa-logger',
spa_logger_sources,
include_directories : [ spa_inc, spa_libinc],
dependencies : threads_dep,
link_with : spalib,
install : true,
install_dir : '@0@/spa'.format(get_option('libdir')))

View file

@ -1,38 +0,0 @@
/* Spa Video Test Source plugin
* Copyright (C) 2016 Axis Communications AB
*
* 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 <spa/plugin.h>
#include <spa/node.h>
extern const struct spa_handle_factory spa_logger_factory;
int
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
{
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:
*factory = &spa_logger_factory;
break;
default:
return SPA_RESULT_ENUM_END;
}
return SPA_RESULT_OK;
}

View file

@ -2,7 +2,6 @@ subdir('alsa')
subdir('audiomixer')
subdir('audiotestsrc')
subdir('ffmpeg')
subdir('logger')
subdir('support')
subdir('test')
subdir('videotestsrc')

View file

@ -77,24 +77,26 @@ static uint32_t
impl_type_map_get_id(struct spa_type_map *map, const char *type)
{
struct impl *impl = SPA_CONTAINER_OF(map, struct impl, map);
uint32_t i = 0, len;
uint32_t i, len;
void *p;
off_t o, *off;
if (type != NULL) {
for (i = 0; i < impl->types.size / sizeof(off_t); i++) {
o = ((off_t *)impl->types.data)[i];
if (strcmp(SPA_MEMBER(impl->strings.data, o, char), type) == 0)
return i;
}
len = strlen(type);
p = alloc_size(&impl->strings, len+1, 1024);
memcpy(p, type, len + 1);
if (type == NULL)
return SPA_ID_INVALID;
off = alloc_size(&impl->types, sizeof(off_t), 128);
*off = SPA_PTRDIFF(p, impl->strings.data);
i = SPA_PTRDIFF(off, impl->types.data) / sizeof(off_t);
for (i = 0; i < impl->types.size / sizeof(off_t); i++) {
o = ((off_t *)impl->types.data)[i];
if (strcmp(SPA_MEMBER(impl->strings.data, o, char), type) == 0)
return i;
}
len = strlen(type);
p = alloc_size(&impl->strings, len+1, 1024);
memcpy(p, type, len + 1);
off = alloc_size(&impl->types, sizeof(off_t), 128);
*off = SPA_PTRDIFF(p, impl->strings.data);
i = SPA_PTRDIFF(off, impl->types.data) / sizeof(off_t);
return i;
}

View file

@ -1,4 +1,6 @@
spa_support_sources = ['mapper.c', 'plugin.c']
spa_support_sources = ['mapper.c',
'logger.c',
'plugin.c']
spa_support_lib = shared_library('spa-support',
spa_support_sources,

View file

@ -20,6 +20,7 @@
#include <spa/plugin.h>
#include <spa/node.h>
extern const struct spa_handle_factory spa_logger_factory;
extern const struct spa_handle_factory spa_type_map_factory;
int
@ -31,6 +32,9 @@ spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t inde
case 0:
*factory = &spa_type_map_factory;
break;
case 1:
*factory = &spa_logger_factory;
break;
default:
return SPA_RESULT_ENUM_END;
}