Add mapper

Ger rid of static ids for interfaces and replace with something we can
register dynamically
Implement logger.
This commit is contained in:
Wim Taymans 2016-10-07 13:14:32 +02:00
parent a68e5d5124
commit fc4fd1424a
43 changed files with 997 additions and 360 deletions

View file

@ -485,7 +485,7 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
case SPA_DATA_TYPE_DMABUF:
case SPA_DATA_TYPE_MEMPTR:
if (buffers[i]->datas[0].data == NULL) {
fprintf (stderr, "alsa-source: need mapped memory\n");
spa_log_error (this->log, "alsa-source: need mapped memory\n");
continue;
}
break;
@ -729,16 +729,13 @@ spa_alsa_source_get_interface (SpaHandle *handle,
this = (SpaALSASource *) handle;
switch (interface_id) {
case SPA_INTERFACE_ID_NODE:
*interface = &this->node;
break;
case SPA_INTERFACE_ID_CLOCK:
*interface = &this->clock;
break;
default:
return SPA_RESULT_UNKNOWN_INTERFACE;
}
if (interface_id == this->uri.node)
*interface = &this->node;
else if (interface_id == this->uri.clock)
*interface = &this->clock;
else
return SPA_RESULT_UNKNOWN_INTERFACE;
return SPA_RESULT_OK;
}
@ -752,7 +749,7 @@ static SpaResult
alsa_source_init (const SpaHandleFactory *factory,
SpaHandle *handle,
const SpaDict *info,
const SpaSupport **support,
const SpaSupport *support,
unsigned int n_support)
{
SpaALSASource *this;
@ -765,6 +762,20 @@ alsa_source_init (const SpaHandleFactory *factory,
handle->clear = alsa_source_clear;
this = (SpaALSASource *) handle;
for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_ID_MAP_URI) == 0)
this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_LOG_URI) == 0)
this->log = support[i].data;
}
if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR;
}
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
this->node = alsasource_node;
this->node.handle = handle;
this->clock = alsasource_clock;
@ -790,14 +801,8 @@ alsa_source_init (const SpaHandleFactory *factory,
static const SpaInterfaceInfo alsa_source_interfaces[] =
{
{ SPA_INTERFACE_ID_NODE,
SPA_INTERFACE_ID_NODE_NAME,
SPA_INTERFACE_ID_NODE_DESCRIPTION,
},
{ SPA_INTERFACE_ID_CLOCK,
SPA_INTERFACE_ID_CLOCK_NAME,
SPA_INTERFACE_ID_CLOCK_DESCRIPTION,
},
{ SPA_NODE_URI, },
{ SPA_CLOCK_URI, },
};
static SpaResult