mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Add mapper
Ger rid of static ids for interfaces and replace with something we can register dynamically Implement logger.
This commit is contained in:
parent
a68e5d5124
commit
fc4fd1424a
43 changed files with 997 additions and 360 deletions
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include <libudev.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/poll.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <spa/debug.h>
|
||||
|
|
@ -41,10 +43,18 @@ typedef struct {
|
|||
SpaDictItem info_items[32];
|
||||
} ALSAItem;
|
||||
|
||||
typedef struct {
|
||||
uint32_t monitor;
|
||||
} URI;
|
||||
|
||||
struct _SpaALSAMonitor {
|
||||
SpaHandle handle;
|
||||
SpaMonitor monitor;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaMonitorEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
|
|
@ -360,13 +370,11 @@ spa_alsa_monitor_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaALSAMonitor *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_MONITOR:
|
||||
*interface = &this->monitor;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -380,10 +388,11 @@ static SpaResult
|
|||
alsa_monitor_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaALSAMonitor *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -392,6 +401,19 @@ alsa_monitor_init (const SpaHandleFactory *factory,
|
|||
handle->clear = alsa_monitor_clear,
|
||||
|
||||
this = (SpaALSAMonitor *) 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.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI);
|
||||
|
||||
this->monitor = alsamonitor;
|
||||
this->monitor.handle = handle;
|
||||
|
||||
|
|
@ -400,10 +422,7 @@ alsa_monitor_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo alsa_monitor_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_MONITOR,
|
||||
SPA_INTERFACE_ID_MONITOR_NAME,
|
||||
SPA_INTERFACE_ID_MONITOR_DESCRIPTION,
|
||||
},
|
||||
{ SPA_MONITOR_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -579,13 +579,11 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaALSASink *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -599,10 +597,11 @@ static SpaResult
|
|||
alsa_sink_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -611,6 +610,19 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
handle->clear = alsa_sink_clear;
|
||||
|
||||
this = (SpaALSASink *) 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->node = alsasink_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
@ -627,10 +639,7 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo alsa_sink_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
{ SPA_NODE_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
#include "alsa-utils.h"
|
||||
|
||||
static int verbose = 0; /* verbose flag */
|
||||
|
||||
#define CHECK(s,msg) if ((err = (s)) < 0) { printf (msg ": %s\n", snd_strerror(err)); return err; }
|
||||
#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error (state->log, msg ": %s\n", snd_strerror(err)); return err; }
|
||||
|
||||
static int
|
||||
spa_alsa_open (SpaALSAState *state)
|
||||
|
|
@ -24,7 +22,7 @@ spa_alsa_open (SpaALSAState *state)
|
|||
|
||||
CHECK (snd_output_stdio_attach (&state->output, stderr, 0), "attach failed");
|
||||
|
||||
printf ("ALSA device open '%s'\n", props->device);
|
||||
spa_log_info (state->log, "ALSA device open '%s'\n", props->device);
|
||||
CHECK (snd_pcm_open (&state->hndl,
|
||||
props->device,
|
||||
state->stream,
|
||||
|
|
@ -46,7 +44,7 @@ spa_alsa_close (SpaALSAState *state)
|
|||
if (!state->opened)
|
||||
return 0;
|
||||
|
||||
printf ("Playback device closing\n");
|
||||
spa_log_info (state->log, "Playback device closing\n");
|
||||
CHECK (snd_pcm_close (state->hndl), "close failed");
|
||||
|
||||
state->opened = false;
|
||||
|
|
@ -134,14 +132,14 @@ spa_alsa_set_format (SpaALSAState *state, SpaFormatAudio *fmt, SpaPortFormatFlag
|
|||
|
||||
/* set the sample format */
|
||||
format = spa_alsa_format_to_alsa (info->format);
|
||||
printf ("Stream parameters are %iHz, %s, %i channels\n", info->rate, snd_pcm_format_name(format), info->channels);
|
||||
spa_log_info (state->log, "Stream parameters are %iHz, %s, %i channels\n", info->rate, snd_pcm_format_name(format), info->channels);
|
||||
CHECK (snd_pcm_hw_params_set_format (hndl, params, format), "set_format");
|
||||
|
||||
/* set the count of channels */
|
||||
rchannels = info->channels;
|
||||
CHECK (snd_pcm_hw_params_set_channels_near (hndl, params, &rchannels), "set_channels");
|
||||
if (rchannels != info->channels) {
|
||||
fprintf (stderr, "Channels doesn't match (requested %u, get %u\n", info->channels, rchannels);
|
||||
spa_log_info (state->log, "Channels doesn't match (requested %u, get %u\n", info->channels, rchannels);
|
||||
if (flags & SPA_PORT_FORMAT_FLAG_NEAREST)
|
||||
info->channels = rchannels;
|
||||
else
|
||||
|
|
@ -152,7 +150,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaFormatAudio *fmt, SpaPortFormatFlag
|
|||
rrate = info->rate;
|
||||
CHECK (snd_pcm_hw_params_set_rate_near (hndl, params, &rrate, 0), "set_rate_near");
|
||||
if (rrate != info->rate) {
|
||||
fprintf (stderr, "Rate doesn't match (requested %iHz, get %iHz)\n", info->rate, rrate);
|
||||
spa_log_info (state->log, "Rate doesn't match (requested %iHz, get %iHz)\n", info->rate, rrate);
|
||||
if (flags & SPA_PORT_FORMAT_FLAG_NEAREST)
|
||||
info->rate = rrate;
|
||||
else
|
||||
|
|
@ -220,14 +218,12 @@ set_swparams (SpaALSAState *state)
|
|||
* Underrun and suspend recovery
|
||||
*/
|
||||
static int
|
||||
xrun_recovery (snd_pcm_t *hndl, int err)
|
||||
xrun_recovery (SpaALSAState *state, snd_pcm_t *hndl, int err)
|
||||
{
|
||||
if (verbose)
|
||||
printf("stream recovery\n");
|
||||
if (err == -EPIPE) { /* under-run */
|
||||
err = snd_pcm_prepare(hndl);
|
||||
if (err < 0)
|
||||
printf("Can't recovery from underrun, prepare failed: %s\n", snd_strerror(err));
|
||||
spa_log_error (state->log, "Can't recovery from underrun, prepare failed: %s\n", snd_strerror(err));
|
||||
return 0;
|
||||
} else if (err == -ESTRPIPE) {
|
||||
while ((err = snd_pcm_resume(hndl)) == -EAGAIN)
|
||||
|
|
@ -235,7 +231,7 @@ xrun_recovery (snd_pcm_t *hndl, int err)
|
|||
if (err < 0) {
|
||||
err = snd_pcm_prepare(hndl);
|
||||
if (err < 0)
|
||||
printf("Can't recovery from suspend, prepare failed: %s\n", snd_strerror(err));
|
||||
spa_log_error (state->log, "Can't recovery from suspend, prepare failed: %s\n", snd_strerror(err));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -265,8 +261,8 @@ mmap_write (SpaALSAState *state)
|
|||
const snd_pcm_channel_area_t *my_areas;
|
||||
|
||||
if ((avail = snd_pcm_avail_update (hndl)) < 0) {
|
||||
if ((err = xrun_recovery (hndl, avail)) < 0) {
|
||||
printf ("Write error: %s\n", snd_strerror (err));
|
||||
if ((err = xrun_recovery (state, hndl, avail)) < 0) {
|
||||
spa_log_error (state->log, "Write error: %s\n", snd_strerror (err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -275,8 +271,8 @@ mmap_write (SpaALSAState *state)
|
|||
while (size > 0) {
|
||||
frames = size;
|
||||
if ((err = snd_pcm_mmap_begin (hndl, &my_areas, &offset, &frames)) < 0) {
|
||||
if ((err = xrun_recovery(hndl, err)) < 0) {
|
||||
printf("MMAP begin avail error: %s\n", snd_strerror(err));
|
||||
if ((err = xrun_recovery (state, hndl, err)) < 0) {
|
||||
spa_log_error (state->log, "MMAP begin avail error: %s\n", snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -287,8 +283,8 @@ mmap_write (SpaALSAState *state)
|
|||
|
||||
commitres = snd_pcm_mmap_commit (hndl, offset, frames);
|
||||
if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames) {
|
||||
if ((err = xrun_recovery (hndl, commitres >= 0 ? -EPIPE : commitres)) < 0) {
|
||||
printf("MMAP commit error: %s\n", snd_strerror(err));
|
||||
if ((err = xrun_recovery (state, hndl, commitres >= 0 ? -EPIPE : commitres)) < 0) {
|
||||
spa_log_error (state->log, "MMAP commit error: %s\n", snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -326,7 +322,7 @@ mmap_read (SpaALSAState *state)
|
|||
|
||||
SPA_QUEUE_POP_HEAD (&state->free, SpaALSABuffer, next, b);
|
||||
if (b == NULL) {
|
||||
fprintf (stderr, "no more buffers\n");
|
||||
spa_log_warn (state->log, "no more buffers\n");
|
||||
} else {
|
||||
dest = SPA_MEMBER (b->outbuf->datas[0].data, b->outbuf->datas[0].offset, void);
|
||||
destsize = b->outbuf->datas[0].size;
|
||||
|
|
@ -345,8 +341,8 @@ mmap_read (SpaALSAState *state)
|
|||
while (size > 0) {
|
||||
frames = size;
|
||||
if ((err = snd_pcm_mmap_begin (hndl, &my_areas, &offset, &frames)) < 0) {
|
||||
if ((err = xrun_recovery(hndl, err)) < 0) {
|
||||
printf("MMAP begin avail error: %s\n", snd_strerror (err));
|
||||
if ((err = xrun_recovery (state, hndl, err)) < 0) {
|
||||
spa_log_error (state->log, "MMAP begin avail error: %s\n", snd_strerror (err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -364,8 +360,8 @@ mmap_read (SpaALSAState *state)
|
|||
|
||||
commitres = snd_pcm_mmap_commit (hndl, offset, frames);
|
||||
if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames) {
|
||||
if ((err = xrun_recovery (hndl, commitres >= 0 ? -EPIPE : commitres)) < 0) {
|
||||
printf("MMAP commit error: %s\n", snd_strerror(err));
|
||||
if ((err = xrun_recovery (state, hndl, commitres >= 0 ? -EPIPE : commitres)) < 0) {
|
||||
spa_log_error (state->log, "MMAP commit error: %s\n", snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -409,12 +405,12 @@ alsa_on_fd_events (SpaPollNotifyData *data)
|
|||
if (snd_pcm_state (hndl) == SND_PCM_STATE_XRUN ||
|
||||
snd_pcm_state (hndl) == SND_PCM_STATE_SUSPENDED) {
|
||||
err = snd_pcm_state (hndl) == SND_PCM_STATE_XRUN ? -EPIPE : -ESTRPIPE;
|
||||
if ((err = xrun_recovery (hndl, err)) < 0) {
|
||||
printf ("error: %s\n", snd_strerror (err));
|
||||
if ((err = xrun_recovery (state, hndl, err)) < 0) {
|
||||
spa_log_error (state->log, "error: %s\n", snd_strerror (err));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
printf("Wait for poll failed\n");
|
||||
spa_log_error (state->log, "Wait for poll failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -451,11 +447,11 @@ spa_alsa_start (SpaALSAState *state)
|
|||
snd_pcm_dump (state->hndl, state->output);
|
||||
|
||||
if ((state->poll.n_fds = snd_pcm_poll_descriptors_count (state->hndl)) <= 0) {
|
||||
printf ("Invalid poll descriptors count\n");
|
||||
spa_log_error (state->log, "Invalid poll descriptors count\n");
|
||||
return state->poll.n_fds;
|
||||
}
|
||||
if ((err = snd_pcm_poll_descriptors (state->hndl, (struct pollfd *)state->fds, state->poll.n_fds)) < 0) {
|
||||
printf ("Unable to obtain poll descriptors for playback: %s\n", snd_strerror(err));
|
||||
spa_log_error (state->log, "Unable to obtain poll descriptors for playback: %s\n", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ extern "C" {
|
|||
|
||||
#include <asoundlib.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/audio/format.h>
|
||||
|
|
@ -54,11 +56,20 @@ struct _SpaALSABuffer {
|
|||
SpaALSABuffer *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
} URI;
|
||||
|
||||
struct _SpaALSAState {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
snd_pcm_stream_t stream;
|
||||
snd_output_t *output;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/audio/format.h>
|
||||
|
||||
|
|
@ -62,10 +64,18 @@ typedef struct {
|
|||
SpaBuffer *buffer;
|
||||
} SpaAudioMixerPort;
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaAudioMixer {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaAudioMixerProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -692,7 +702,7 @@ spa_audiomixer_node_port_pull_output (SpaNode *node,
|
|||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if ((info[i].status = mix_data (this, &info[i])) < 0) {
|
||||
printf ("error mixing: %d\n", info[i].status);
|
||||
spa_log_error (this->log, "error mixing: %d\n", info[i].status);
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -760,13 +770,11 @@ spa_audiomixer_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaAudioMixer *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -780,10 +788,11 @@ static SpaResult
|
|||
spa_audiomixer_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -792,6 +801,19 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
handle->clear = spa_audiomixer_clear;
|
||||
|
||||
this = (SpaAudioMixer *) 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->node = audiomixer_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
@ -807,10 +829,7 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo audiomixer_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
{ SPA_NODE_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include <sys/timerfd.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/audio/format.h>
|
||||
|
|
@ -55,11 +57,20 @@ struct _ATSBuffer {
|
|||
size_t size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
} URI;
|
||||
|
||||
struct _SpaAudioTestSrc {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaAudioTestSrcProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -528,7 +539,7 @@ static SpaResult
|
|||
clear_buffers (SpaAudioTestSrc *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
fprintf (stderr, "audiotestsrc %p: clear buffers\n", this);
|
||||
spa_log_info (this->log, "audiotestsrc %p: clear buffers\n", this);
|
||||
this->n_buffers = 0;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
|
|
@ -692,7 +703,7 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
case SPA_DATA_TYPE_MEMFD:
|
||||
case SPA_DATA_TYPE_DMABUF:
|
||||
if (d[0].data == NULL) {
|
||||
fprintf (stderr, "audiotestsrc %p: invalid memory on buffer %p\n", this, buffers[i]);
|
||||
spa_log_error (this->log, "audiotestsrc %p: invalid memory on buffer %p\n", this, buffers[i]);
|
||||
continue;
|
||||
}
|
||||
b->ptr = SPA_MEMBER (d[0].data, d[0].offset, void);
|
||||
|
|
@ -957,16 +968,13 @@ spa_audiotestsrc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaAudioTestSrc *) 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;
|
||||
}
|
||||
|
||||
|
|
@ -989,10 +997,11 @@ static SpaResult
|
|||
audiotestsrc_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -1001,6 +1010,20 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
handle->clear = audiotestsrc_clear;
|
||||
|
||||
this = (SpaAudioTestSrc *) 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 = audiotestsrc_node;
|
||||
this->node.handle = handle;
|
||||
this->clock = audiotestsrc_clock;
|
||||
|
|
@ -1041,14 +1064,8 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo audiotestsrc_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
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
|
|
@ -58,10 +60,18 @@ typedef struct {
|
|||
SpaPortStatus status;
|
||||
} SpaFFMpegPort;
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaFFMpegDec {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaFFMpegDecProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -537,24 +547,39 @@ spa_ffmpeg_dec_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaFFMpegDec *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_ffmpeg_dec_init (SpaHandle *handle)
|
||||
spa_ffmpeg_dec_init (SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
unsigned int i;
|
||||
|
||||
handle->get_interface = spa_ffmpeg_dec_get_interface;
|
||||
|
||||
this = (SpaFFMpegDec *) 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->node = ffmpeg_dec_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
|
|
@ -63,10 +65,19 @@ typedef struct {
|
|||
SpaPortStatus status;
|
||||
} SpaFFMpegPort;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaFFMpegEnc {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaFFMpegEncProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -545,24 +556,39 @@ spa_ffmpeg_enc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaFFMpegEnc *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_ffmpeg_enc_init (SpaHandle *handle)
|
||||
spa_ffmpeg_enc_init (SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
unsigned int i;
|
||||
|
||||
handle->get_interface = spa_ffmpeg_enc_get_interface;
|
||||
|
||||
this = (SpaFFMpegEnc *) 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->node = ffmpeg_enc_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
|
|||
|
|
@ -25,40 +25,38 @@
|
|||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
SpaResult spa_ffmpeg_dec_init (SpaHandle *handle);
|
||||
SpaResult spa_ffmpeg_enc_init (SpaHandle *handle);
|
||||
SpaResult spa_ffmpeg_dec_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, unsigned int n_support);
|
||||
SpaResult spa_ffmpeg_enc_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, unsigned int n_support);
|
||||
|
||||
static SpaResult
|
||||
ffmpeg_dec_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
return spa_ffmpeg_dec_init (handle);
|
||||
return spa_ffmpeg_dec_init (handle, info, support, n_support);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
ffmpeg_enc_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
return spa_ffmpeg_enc_init (handle);
|
||||
return spa_ffmpeg_enc_init (handle, info, support, n_support);
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo ffmpeg_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
{ SPA_NODE_URI,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
#include <spa/control.h>
|
||||
#include <spa/debug.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/queue.h>
|
||||
#include "../lib/memfd-wrappers.h"
|
||||
|
||||
|
|
@ -88,10 +89,18 @@ typedef struct {
|
|||
SpaQueue ready;
|
||||
} SpaProxyPort;
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaProxy {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaProxyProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -176,7 +185,7 @@ static SpaResult
|
|||
clear_buffers (SpaProxy *this, SpaProxyPort *port)
|
||||
{
|
||||
if (port->n_buffers) {
|
||||
fprintf (stderr, "proxy %p: clear buffers\n", this);
|
||||
spa_log_info (this->log, "proxy %p: clear buffers\n", this);
|
||||
|
||||
munmap (port->buffer_mem_ptr, port->buffer_mem_size);
|
||||
close (port->buffer_mem_fd);
|
||||
|
|
@ -273,7 +282,7 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
spa_control_builder_end (&builder, &control);
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control %d\n", this, res);
|
||||
spa_log_error (this->log, "proxy %p: error writing control %d\n", this, res);
|
||||
|
||||
spa_control_clear (&control);
|
||||
|
||||
|
|
@ -295,7 +304,7 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
spa_control_builder_end (&builder, &control);
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control %d\n", this, res);
|
||||
spa_log_error (this->log, "proxy %p: error writing control %d\n", this, res);
|
||||
|
||||
spa_control_clear (&control);
|
||||
break;
|
||||
|
|
@ -421,7 +430,7 @@ do_update_port (SpaProxy *this,
|
|||
}
|
||||
|
||||
if (!port->valid) {
|
||||
fprintf (stderr, "proxy %p: adding port %d\n", this, pu->port_id);
|
||||
spa_log_info (this->log, "proxy %p: adding port %d\n", this, pu->port_id);
|
||||
port->format = NULL;
|
||||
port->valid = true;
|
||||
|
||||
|
|
@ -462,7 +471,7 @@ do_uninit_port (SpaProxy *this,
|
|||
{
|
||||
SpaProxyPort *port;
|
||||
|
||||
fprintf (stderr, "proxy %p: removing port %d\n", this, port_id);
|
||||
spa_log_info (this->log, "proxy %p: removing port %d\n", this, port_id);
|
||||
if (direction == SPA_DIRECTION_INPUT) {
|
||||
port = &this->in_ports[port_id];
|
||||
this->n_inputs--;
|
||||
|
|
@ -581,7 +590,7 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
spa_control_builder_end (&builder, &control);
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing control\n", this);
|
||||
|
||||
spa_control_clear (&control);
|
||||
|
||||
|
|
@ -709,7 +718,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = (SpaProxy *) node->handle;
|
||||
fprintf (stderr, "proxy %p: use buffers %p %u\n", this, buffers, n_buffers);
|
||||
spa_log_info (this->log, "proxy %p: use buffers %p %u\n", this, buffers, n_buffers);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
|
@ -770,7 +779,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
b->buffer.datas[j].type = SPA_DATA_TYPE_INVALID;
|
||||
b->buffer.datas[j].data = 0;
|
||||
fprintf (stderr, "invalid memory type %d\n", d->type);
|
||||
spa_log_error (this->log, "invalid memory type %d\n", d->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -783,7 +792,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
port->buffer_mem_fd = memfd_create ("spa-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||
|
||||
if (ftruncate (port->buffer_mem_fd, size) < 0) {
|
||||
fprintf (stderr, "Failed to truncate temporary file: %s\n", strerror (errno));
|
||||
spa_log_error (this->log, "Failed to truncate temporary file: %s\n", strerror (errno));
|
||||
close (port->buffer_mem_fd);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
|
@ -791,7 +800,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
{
|
||||
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
|
||||
if (fcntl (port->buffer_mem_fd, F_ADD_SEALS, seals) == -1) {
|
||||
fprintf (stderr, "Failed to add seals: %s\n", strerror (errno));
|
||||
spa_log_error (this->log, "Failed to add seals: %s\n", strerror (errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -848,7 +857,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
spa_control_builder_end (&builder, &control);
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing control\n", this);
|
||||
|
||||
spa_control_clear (&control);
|
||||
|
||||
|
|
@ -897,7 +906,7 @@ copy_meta_in (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
for (i = 0; i < b->outbuf->n_datas; i++) {
|
||||
b->outbuf->datas[i].size = b->buffer.datas[i].size;
|
||||
if (b->outbuf->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
|
||||
fprintf (stderr, "memcpy in %zd\n", b->buffer.datas[i].size);
|
||||
spa_log_info (this->log, "memcpy in %zd\n", b->buffer.datas[i].size);
|
||||
memcpy (b->outbuf->datas[i].data, b->datas[i].data, b->buffer.datas[i].size);
|
||||
}
|
||||
}
|
||||
|
|
@ -917,7 +926,7 @@ copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
for (i = 0; i < b->outbuf->n_datas; i++) {
|
||||
b->buffer.datas[i].size = b->outbuf->datas[i].size;
|
||||
if (b->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
|
||||
fprintf (stderr, "memcpy out %zd\n", b->outbuf->datas[i].size);
|
||||
spa_log_info (this->log, "memcpy out %zd\n", b->outbuf->datas[i].size);
|
||||
memcpy (b->datas[i].data, b->outbuf->datas[i].data, b->outbuf->datas[i].size);
|
||||
}
|
||||
}
|
||||
|
|
@ -948,7 +957,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, info[i].port_id)) {
|
||||
printf ("invalid port %d\n", info[i].port_id);
|
||||
spa_log_warn (this->log, "invalid port %d\n", info[i].port_id);
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -986,7 +995,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
return SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing control\n", this);
|
||||
|
||||
spa_control_clear (&control);
|
||||
|
||||
|
|
@ -1011,7 +1020,7 @@ spa_proxy_node_port_pull_output (SpaNode *node,
|
|||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info[i].port_id)) {
|
||||
fprintf (stderr, "invalid port %u\n", info[i].port_id);
|
||||
spa_log_warn (this->log, "invalid port %u\n", info[i].port_id);
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -1072,7 +1081,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
spa_control_builder_end (&builder, &control);
|
||||
|
||||
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
|
||||
fprintf (stderr, "proxy %p: error writing control %d\n", this, res);
|
||||
spa_log_error (this->log, "proxy %p: error writing control %d\n", this, res);
|
||||
|
||||
spa_control_clear (&control);
|
||||
|
||||
|
|
@ -1085,12 +1094,16 @@ spa_proxy_node_port_push_event (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaNodeEvent *event)
|
||||
{
|
||||
SpaProxy *this;
|
||||
|
||||
if (node == NULL || node->handle == NULL || event == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = (SpaProxy *) node->handle;
|
||||
|
||||
switch (event->type) {
|
||||
default:
|
||||
fprintf (stderr, "unhandled event %d\n", event->type);
|
||||
spa_log_warn (this->log, "unhandled event %d\n", event->type);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
@ -1141,7 +1154,7 @@ parse_control (SpaProxy *this,
|
|||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
fprintf (stderr, "proxy %p: got unexpected control %d\n", this, cmd);
|
||||
spa_log_error (this->log, "proxy %p: got unexpected control %d\n", this, cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
|
|
@ -1156,7 +1169,7 @@ parse_control (SpaProxy *this,
|
|||
if (nu.change_mask & SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS)
|
||||
this->max_outputs = nu.max_output_ports;
|
||||
|
||||
fprintf (stderr, "proxy %p: got node update %d, max_in %u, max_out %u\n", this, cmd,
|
||||
spa_log_info (this->log, "proxy %p: got node update %d, max_in %u, max_out %u\n", this, cmd,
|
||||
this->max_inputs, this->max_outputs);
|
||||
|
||||
break;
|
||||
|
|
@ -1167,7 +1180,7 @@ parse_control (SpaProxy *this,
|
|||
SpaControlCmdPortUpdate pu;
|
||||
bool remove;
|
||||
|
||||
fprintf (stderr, "proxy %p: got port update %d\n", this, cmd);
|
||||
spa_log_info (this->log, "proxy %p: got port update %d\n", this, cmd);
|
||||
if (spa_control_iter_parse_cmd (&it, &pu) < 0)
|
||||
break;
|
||||
|
||||
|
|
@ -1186,7 +1199,7 @@ parse_control (SpaProxy *this,
|
|||
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
{
|
||||
fprintf (stderr, "proxy %p: command not implemented %d\n", this, cmd);
|
||||
spa_log_warn (this->log, "proxy %p: command not implemented %d\n", this, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1198,7 +1211,7 @@ parse_control (SpaProxy *this,
|
|||
if (spa_control_iter_parse_cmd (&it, &sc) < 0)
|
||||
break;
|
||||
|
||||
fprintf (stderr, "proxy %p: got node state change %d -> %d\n", this, old, sc.state);
|
||||
spa_log_info (this->log, "proxy %p: got node state change %d -> %d\n", this, old, sc.state);
|
||||
this->node.state = sc.state;
|
||||
if (old == SPA_NODE_STATE_INIT)
|
||||
send_async_complete (this, 0, SPA_RESULT_OK);
|
||||
|
|
@ -1227,7 +1240,7 @@ parse_control (SpaProxy *this,
|
|||
port = cmd.direction == SPA_DIRECTION_INPUT ? &this->in_ports[cmd.port_id] : &this->out_ports[cmd.port_id];
|
||||
|
||||
if (port->buffer_id != SPA_ID_INVALID)
|
||||
fprintf (stderr, "proxy %p: unprocessed buffer: %d\n", this, port->buffer_id);
|
||||
spa_log_warn (this->log, "proxy %p: unprocessed buffer: %d\n", this, port->buffer_id);
|
||||
|
||||
copy_meta_in (this, port, cmd.buffer_id);
|
||||
|
||||
|
|
@ -1263,7 +1276,7 @@ proxy_on_fd_events (SpaPollNotifyData *data)
|
|||
int fds[16];
|
||||
|
||||
if ((res = spa_control_read (&control, data->fds[0].fd, buf, 1024, fds, 16)) < 0) {
|
||||
fprintf (stderr, "proxy %p: failed to read control: %d\n", this, res);
|
||||
spa_log_error (this->log, "proxy %p: failed to read control: %d\n", this, res);
|
||||
return 0;
|
||||
}
|
||||
parse_control (this, &control);
|
||||
|
|
@ -1310,14 +1323,11 @@ spa_proxy_get_interface (SpaHandle *handle,
|
|||
if (handle == NULL || interface == 0)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1348,10 +1358,11 @@ static SpaResult
|
|||
proxy_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaProxy *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -1360,6 +1371,19 @@ proxy_init (const SpaHandleFactory *factory,
|
|||
handle->clear = proxy_clear;
|
||||
|
||||
this = (SpaProxy *) 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->node = proxy_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
@ -1384,10 +1408,7 @@ proxy_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo proxy_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
{ SPA_NODE_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include <libudev.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/poll.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <spa/debug.h>
|
||||
|
|
@ -41,10 +43,18 @@ typedef struct {
|
|||
SpaDictItem info_items[32];
|
||||
} V4l2Item;
|
||||
|
||||
typedef struct {
|
||||
uint32_t monitor;
|
||||
} URI;
|
||||
|
||||
struct _SpaV4l2Monitor {
|
||||
SpaHandle handle;
|
||||
SpaMonitor monitor;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaMonitorEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
|
|
@ -331,13 +341,11 @@ spa_v4l2_monitor_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaV4l2Monitor *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_MONITOR:
|
||||
*interface = &this->monitor;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -351,10 +359,11 @@ static SpaResult
|
|||
v4l2_monitor_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaV4l2Monitor *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -363,6 +372,19 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
|
|||
handle->clear = v4l2_monitor_clear,
|
||||
|
||||
this = (SpaV4l2Monitor *) 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.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI);
|
||||
|
||||
this->monitor = v4l2monitor;
|
||||
this->monitor.handle = handle;
|
||||
|
||||
|
|
@ -371,10 +393,7 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo v4l2_monitor_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_MONITOR,
|
||||
SPA_INTERFACE_ID_MONITOR_NAME,
|
||||
SPA_INTERFACE_ID_MONITOR_DESCRIPTION,
|
||||
},
|
||||
{ SPA_MONITOR_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <spa/debug.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
|
||||
typedef struct _SpaV4l2Source SpaV4l2Source;
|
||||
|
||||
|
|
@ -79,6 +80,13 @@ struct _V4l2Format {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
} URI;
|
||||
|
||||
typedef struct {
|
||||
SpaLog *log;
|
||||
|
||||
bool export_buf;
|
||||
bool started;
|
||||
|
||||
|
|
@ -112,8 +120,6 @@ typedef struct {
|
|||
SpaAllocParamMetaEnable param_meta;
|
||||
SpaPortStatus status;
|
||||
|
||||
SpaLog *log;
|
||||
|
||||
int64_t last_ticks;
|
||||
int64_t last_monotonic;
|
||||
} SpaV4l2State;
|
||||
|
|
@ -123,6 +129,10 @@ struct _SpaV4l2Source {
|
|||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaV4l2SourceProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -808,16 +818,13 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaV4l2Source *) 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;
|
||||
}
|
||||
|
||||
|
|
@ -831,7 +838,7 @@ static SpaResult
|
|||
v4l2_source_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
|
|
@ -844,6 +851,20 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
handle->clear = v4l2_source_clear,
|
||||
|
||||
this = (SpaV4l2Source *) 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 = v4l2source_node;
|
||||
this->node.handle = handle;
|
||||
this->clock = v4l2source_clock;
|
||||
|
|
@ -854,7 +875,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
|
||||
SPA_QUEUE_INIT (&this->state[0].ready);
|
||||
|
||||
this->state[0].log = NULL;
|
||||
this->state[0].log = this->log;
|
||||
this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE;
|
||||
this->state[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
|
|
@ -874,14 +895,8 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo v4l2_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
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <sys/timerfd.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/queue.h>
|
||||
#include <spa/video/format.h>
|
||||
|
|
@ -38,6 +40,11 @@
|
|||
#define STATE_GET_IMAGE_SIZE(this) \
|
||||
(this->bpp * STATE_GET_IMAGE_WIDTH(this) * STATE_GET_IMAGE_HEIGHT(this))
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
} URI;
|
||||
|
||||
typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -63,6 +70,10 @@ struct _SpaVideoTestSrc {
|
|||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
URI uri;
|
||||
|
||||
SpaVideoTestSrcProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -476,7 +487,7 @@ static SpaResult
|
|||
clear_buffers (SpaVideoTestSrc *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
fprintf (stderr, "videotestsrc %p: clear buffers\n", this);
|
||||
spa_log_info (this->log, "videotestsrc %p: clear buffers\n", this);
|
||||
this->n_buffers = 0;
|
||||
SPA_QUEUE_INIT (&this->empty);
|
||||
SPA_QUEUE_INIT (&this->ready);
|
||||
|
|
@ -641,7 +652,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
case SPA_DATA_TYPE_MEMFD:
|
||||
case SPA_DATA_TYPE_DMABUF:
|
||||
if (d[0].data == NULL) {
|
||||
fprintf (stderr, "videotestsrc %p: invalid memory on buffer %p\n", this, buffers[i]);
|
||||
spa_log_error (this->log, "videotestsrc %p: invalid memory on buffer %p\n", this, buffers[i]);
|
||||
continue;
|
||||
}
|
||||
b->ptr = SPA_MEMBER (d[0].data, d[0].offset, void);
|
||||
|
|
@ -905,16 +916,13 @@ spa_videotestsrc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaVideoTestSrc *) 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;
|
||||
}
|
||||
|
||||
|
|
@ -937,10 +945,11 @@ static SpaResult
|
|||
videotestsrc_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -949,6 +958,20 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
handle->clear = videotestsrc_clear;
|
||||
|
||||
this = (SpaVideoTestSrc *) 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 = videotestsrc_node;
|
||||
this->node.handle = handle;
|
||||
this->clock = videotestsrc_clock;
|
||||
|
|
@ -989,14 +1012,8 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo videotestsrc_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
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/audio/format.h>
|
||||
|
||||
|
|
@ -40,10 +42,18 @@ typedef struct {
|
|||
SpaBuffer *buffer;
|
||||
} SpaVolumePort;
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaVolume {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaVolumeProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -656,14 +666,11 @@ spa_volume_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaVolume *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -677,10 +684,11 @@ static SpaResult
|
|||
volume_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaVolume *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -689,6 +697,19 @@ volume_init (const SpaHandleFactory *factory,
|
|||
handle->clear = volume_clear;
|
||||
|
||||
this = (SpaVolume *) 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->node = volume_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
@ -709,10 +730,7 @@ volume_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo volume_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
{ SPA_NODE_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
|
|
@ -67,10 +69,18 @@ typedef struct {
|
|||
uint32_t ready_count;
|
||||
} SpaXvState;
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
||||
struct _SpaXvSink {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaXvSinkProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
|
|
@ -538,13 +548,11 @@ spa_xv_sink_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaXvSink *) handle;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &this->node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
if (interface_id == this->uri.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -558,10 +566,11 @@ static SpaResult
|
|||
xv_sink_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle,
|
||||
const SpaDict *info,
|
||||
const SpaSupport **support,
|
||||
const SpaSupport *support,
|
||||
unsigned int n_support)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
unsigned int i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -570,6 +579,19 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
handle->clear = xv_sink_clear;
|
||||
|
||||
this = (SpaXvSink *) 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->node = xvsink_node;
|
||||
this->node.handle = handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
|
|
@ -584,10 +606,7 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
|
||||
static const SpaInterfaceInfo xv_sink_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
{ SPA_NODE_URI, },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue