mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
More hacking
Add beginnings of Xv plugin Add Poll event Clean up props handling V4l2 add beginnings of poll event
This commit is contained in:
parent
a1a27328e2
commit
a31eb56663
14 changed files with 842 additions and 79 deletions
|
|
@ -69,6 +69,20 @@ struct _SpaEvent {
|
|||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* SpaEventPoll:
|
||||
* @fd: a file descriptor to watch
|
||||
* @events: events to watch for
|
||||
* @revents: result events
|
||||
* @callback: callback called when there was activity on @fd
|
||||
*/
|
||||
typedef struct {
|
||||
int fd;
|
||||
short events;
|
||||
short revents;
|
||||
SpaNotify callback;
|
||||
} SpaEventPoll;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ project('spa', 'c')
|
|||
|
||||
alsa_dep = dependency('alsa')
|
||||
v4l2_dep = dependency('libv4l2')
|
||||
xv_dep = dependency('x11')
|
||||
dl_lib = find_library('dl', required : true)
|
||||
|
||||
inc = include_directories('include')
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ struct _ALSABuffer {
|
|||
struct _SpaALSASink {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaALSASinkProps tmp_props;
|
||||
SpaALSASinkProps props;
|
||||
SpaALSASinkProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -182,8 +181,8 @@ spa_alsa_sink_node_get_props (SpaHandle *handle,
|
|||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->tmp_props, &this->props, sizeof (this->props));
|
||||
*props = &this->tmp_props.props;
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -193,7 +192,7 @@ spa_alsa_sink_node_set_props (SpaHandle *handle,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaALSASink *this = (SpaALSASink *) handle;
|
||||
SpaALSASinkProps *p = &this->props;
|
||||
SpaALSASinkProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
|
|
@ -564,11 +563,11 @@ spa_alsa_sink_new (void)
|
|||
handle->get_interface = spa_alsa_sink_get_interface;
|
||||
|
||||
this = (SpaALSASink *) handle;
|
||||
this->props.props.n_prop_info = PROP_ID_LAST;
|
||||
this->props.props.prop_info = prop_info;
|
||||
this->props.props.set_prop = spa_props_generic_set_prop;
|
||||
this->props.props.get_prop = spa_props_generic_get_prop;
|
||||
reset_alsa_sink_props (&this->props);
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_alsa_sink_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ set_hwparams (SpaALSASink *this)
|
|||
snd_pcm_t *handle = state->handle;
|
||||
unsigned int buffer_time;
|
||||
unsigned int period_time;
|
||||
SpaALSASinkProps *props = &this->props[1];
|
||||
|
||||
snd_pcm_hw_params_alloca (¶ms);
|
||||
/* choose all parameters */
|
||||
|
|
@ -99,13 +100,13 @@ set_hwparams (SpaALSASink *this)
|
|||
return -EINVAL;
|
||||
}
|
||||
/* set the buffer time */
|
||||
buffer_time = this->props.buffer_time;
|
||||
buffer_time = props->buffer_time;
|
||||
CHECK (snd_pcm_hw_params_set_buffer_time_near (handle, params, &buffer_time, &dir), "set_buffer_time_near");
|
||||
CHECK (snd_pcm_hw_params_get_buffer_size (params, &size), "get_buffer_size");
|
||||
state->buffer_size = size;
|
||||
|
||||
/* set the period time */
|
||||
period_time = this->props.period_time;
|
||||
period_time = props->period_time;
|
||||
CHECK (snd_pcm_hw_params_set_period_time_near (handle, params, &period_time, &dir), "set_period_time_near");
|
||||
CHECK (snd_pcm_hw_params_get_period_size (params, &size, &dir), "get_period_size");
|
||||
state->period_size = size;
|
||||
|
|
@ -123,6 +124,7 @@ set_swparams (SpaALSASink *this)
|
|||
snd_pcm_t *handle = state->handle;
|
||||
int err = 0;
|
||||
snd_pcm_sw_params_t *params;
|
||||
SpaALSASinkProps *props = &this->props[1];
|
||||
|
||||
snd_pcm_sw_params_alloca (¶ms);
|
||||
|
||||
|
|
@ -136,9 +138,9 @@ set_swparams (SpaALSASink *this)
|
|||
/* allow the transfer when at least period_size samples can be processed */
|
||||
/* or disable this mechanism when period event is enabled (aka interrupt like style processing) */
|
||||
CHECK (snd_pcm_sw_params_set_avail_min (handle, params,
|
||||
this->props.period_event ? state->buffer_size : state->period_size), "set_avail_min");
|
||||
props->period_event ? state->buffer_size : state->period_size), "set_avail_min");
|
||||
/* enable period events when requested */
|
||||
if (this->props.period_event) {
|
||||
if (props->period_event) {
|
||||
CHECK (snd_pcm_sw_params_set_period_event (handle, params, 1), "set_period_event");
|
||||
}
|
||||
/* write the parameters to the playback device */
|
||||
|
|
@ -309,15 +311,16 @@ spa_alsa_open (SpaALSASink *this)
|
|||
{
|
||||
SpaALSAState *state = &this->state;
|
||||
int err;
|
||||
SpaALSASinkProps *props = &this->props[1];
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
||||
CHECK (snd_output_stdio_attach (&state->output, stdout, 0), "attach failed");
|
||||
|
||||
printf ("Playback device is '%s'\n", this->props.device);
|
||||
printf ("Playback device is '%s'\n", props->device);
|
||||
CHECK (snd_pcm_open (&state->handle,
|
||||
this->props.device,
|
||||
props->device,
|
||||
SND_PCM_STREAM_PLAYBACK,
|
||||
SND_PCM_NONBLOCK |
|
||||
SND_PCM_NO_AUTO_RESAMPLE |
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct _MixerBuffer {
|
|||
|
||||
typedef struct {
|
||||
bool valid;
|
||||
SpaAudioMixerPortProps props;
|
||||
SpaAudioMixerPortProps props[2];
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
SpaBuffer *buffer;
|
||||
|
|
@ -60,8 +60,7 @@ typedef struct {
|
|||
struct _SpaAudioMixer {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaAudioMixerProps props;
|
||||
SpaAudioMixerProps tmp_props;
|
||||
SpaAudioMixerProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -98,8 +97,8 @@ spa_audiomixer_node_get_props (SpaHandle *handle,
|
|||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->tmp_props, &this->props, sizeof (this->tmp_props));
|
||||
*props = &this->tmp_props.props;
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -109,7 +108,7 @@ spa_audiomixer_node_set_props (SpaHandle *handle,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaAudioMixer *this = (SpaAudioMixer *) handle;
|
||||
SpaAudioMixerProps *p = &this->props;
|
||||
SpaAudioMixerProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
|
|
@ -724,11 +723,11 @@ spa_audiomixer_new (void)
|
|||
handle->get_interface = spa_audiomixer_get_interface;
|
||||
|
||||
this = (SpaAudioMixer *) handle;
|
||||
this->props.props.n_prop_info = PROP_ID_LAST;
|
||||
this->props.props.prop_info = prop_info;
|
||||
this->props.props.set_prop = spa_props_generic_set_prop;
|
||||
this->props.props.get_prop = spa_props_generic_get_prop;
|
||||
reset_audiomixer_props (&this->props);
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_audiomixer_props (&this->props[1]);
|
||||
|
||||
this->ports[0].valid = true;
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_GIVE_BUFFER |
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ typedef struct {
|
|||
struct _SpaAudioTestSrc {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaAudioTestSrcProps props;
|
||||
SpaAudioTestSrcProps tmp_props;
|
||||
SpaAudioTestSrcProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -130,8 +129,8 @@ spa_audiotestsrc_node_get_props (SpaHandle *handle,
|
|||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->tmp_props, &this->props, sizeof (this->tmp_props));
|
||||
*props = &this->tmp_props.props;
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -141,7 +140,7 @@ spa_audiotestsrc_node_set_props (SpaHandle *handle,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaAudioTestSrc *this = (SpaAudioTestSrc *) handle;
|
||||
SpaAudioTestSrcProps *p = &this->props;
|
||||
SpaAudioTestSrcProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
|
|
@ -510,11 +509,11 @@ spa_audiotestsrc_new (void)
|
|||
handle->get_interface = spa_audiotestsrc_get_interface;
|
||||
|
||||
this = (SpaAudioTestSrc *) handle;
|
||||
this->props.props.n_prop_info = PROP_ID_LAST;
|
||||
this->props.props.prop_info = prop_info;
|
||||
this->props.props.set_prop = spa_props_generic_set_prop;
|
||||
this->props.props.get_prop = spa_props_generic_get_prop;
|
||||
reset_audiotestsrc_props (&this->props);
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_audiotestsrc_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@ subdir('audiomixer')
|
|||
subdir('audiotestsrc')
|
||||
subdir('volume')
|
||||
subdir('v4l2')
|
||||
subdir('xv')
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ reset_v4l2_source_props (SpaV4l2SourceProps *props)
|
|||
|
||||
#define MAX_BUFFERS 256
|
||||
|
||||
typedef struct {
|
||||
SpaEventPoll poll;
|
||||
SpaV4l2Source *source;
|
||||
} V4l2EventPoll;
|
||||
|
||||
typedef struct _V4l2Buffer V4l2Buffer;
|
||||
|
||||
struct _V4l2Buffer {
|
||||
|
|
@ -77,8 +82,7 @@ typedef struct {
|
|||
struct _SpaV4l2Source {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaV4l2SourceProps tmp_props;
|
||||
SpaV4l2SourceProps props;
|
||||
SpaV4l2SourceProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -150,8 +154,8 @@ spa_v4l2_source_node_get_props (SpaHandle *handle,
|
|||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->tmp_props, &this->props, sizeof (this->props));
|
||||
*props = &this->tmp_props.props;
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -161,7 +165,7 @@ spa_v4l2_source_node_set_props (SpaHandle *handle,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaV4l2Source *this = (SpaV4l2Source *) handle;
|
||||
SpaV4l2SourceProps *p = &this->props;
|
||||
SpaV4l2SourceProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
|
|
@ -552,11 +556,11 @@ spa_v4l2_source_new (void)
|
|||
handle->get_interface = spa_v4l2_source_get_interface;
|
||||
|
||||
this = (SpaV4l2Source *) handle;
|
||||
this->props.props.n_prop_info = PROP_ID_LAST;
|
||||
this->props.props.prop_info = prop_info;
|
||||
this->props.props.set_prop = spa_props_generic_set_prop;
|
||||
this->props.props.get_prop = spa_props_generic_get_prop;
|
||||
reset_v4l2_source_props (&this->props);
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_v4l2_source_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -26,28 +26,29 @@ spa_v4l2_open (SpaV4l2Source *this)
|
|||
{
|
||||
SpaV4l2State *state = &this->state;
|
||||
struct stat st;
|
||||
SpaV4l2SourceProps *props = &this->props[1];
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
||||
fprintf (stderr, "Playback device is '%s'\n", this->props.device);
|
||||
fprintf (stderr, "Playback device is '%s'\n", props->device);
|
||||
|
||||
if (stat (this->props.device, &st) < 0) {
|
||||
if (stat (props->device, &st) < 0) {
|
||||
fprintf(stderr, "Cannot identify '%s': %d, %s\n",
|
||||
this->props.device, errno, strerror (errno));
|
||||
props->device, errno, strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!S_ISCHR (st.st_mode)) {
|
||||
fprintf(stderr, "%s is no device\n", this->props.device);
|
||||
fprintf(stderr, "%s is no device\n", props->device);
|
||||
return -1;
|
||||
}
|
||||
|
||||
state->fd = open (this->props.device, O_RDWR | O_NONBLOCK, 0);
|
||||
state->fd = open (props->device, O_RDWR | O_NONBLOCK, 0);
|
||||
|
||||
if (state->fd == -1) {
|
||||
fprintf (stderr, "Cannot open '%s': %d, %s\n",
|
||||
this->props.device, errno, strerror (errno));
|
||||
props->device, errno, strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +58,7 @@ spa_v4l2_open (SpaV4l2Source *this)
|
|||
}
|
||||
|
||||
if ((state->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
|
||||
fprintf (stderr, "%s is no video capture device\n", this->props.device);
|
||||
fprintf (stderr, "%s is no video capture device\n", props->device);
|
||||
return -1;
|
||||
}
|
||||
state->opened = true;
|
||||
|
|
@ -352,20 +353,44 @@ mmap_read (SpaV4l2Source *this)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
v4l2_on_fd_events (void *user_data)
|
||||
{
|
||||
V4l2EventPoll *poll = user_data;
|
||||
SpaV4l2Source *this = poll->source;
|
||||
SpaEvent event;
|
||||
|
||||
mmap_read (this);
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_CAN_PULL_OUTPUT;
|
||||
event.port_id = 0;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
}
|
||||
|
||||
static void *
|
||||
v4l2_loop (void *user_data)
|
||||
{
|
||||
SpaV4l2Source *this = user_data;
|
||||
SpaV4l2State *state = &this->state;
|
||||
struct pollfd fds[1];
|
||||
SpaEvent event;
|
||||
int r;
|
||||
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_CAN_PULL_OUTPUT;
|
||||
event.port_id = 0;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
|
||||
fds[0].fd = state->fd;
|
||||
fds[0].events = POLLIN | POLLPRI | POLLERR;
|
||||
fds[0].revents = 0;
|
||||
|
||||
while (state->running) {
|
||||
int r;
|
||||
|
||||
r = poll (fds, 1, 2000);
|
||||
if (r < 0) {
|
||||
if (errno == EINTR)
|
||||
|
|
@ -380,18 +405,8 @@ v4l2_loop (void *user_data)
|
|||
if (mmap_read (this) < 0)
|
||||
break;
|
||||
|
||||
{
|
||||
SpaEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_CAN_PULL_OUTPUT;
|
||||
event.port_id = 0;
|
||||
event.size = 0;
|
||||
event.data = NULL;
|
||||
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
}
|
||||
event.refcount = 1;
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -525,6 +540,8 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
SpaV4l2State *state = &this->state;
|
||||
int err;
|
||||
enum v4l2_buf_type type;
|
||||
SpaEvent event;
|
||||
V4l2EventPoll poll;
|
||||
|
||||
if (spa_v4l2_open (this) < 0)
|
||||
return -1;
|
||||
|
|
@ -539,6 +556,20 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
} else
|
||||
return -1;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_ADD_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &poll.poll;
|
||||
event.size = sizeof (poll.poll);
|
||||
|
||||
poll.poll.fd = state->fd;
|
||||
poll.poll.events = POLLIN | POLLPRI | POLLERR;
|
||||
poll.poll.revents = 0;
|
||||
poll.poll.callback = v4l2_on_fd_events;
|
||||
poll.source = this;
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl (state->fd, VIDIOC_STREAMON, &type) < 0) {
|
||||
perror ("VIDIOC_STREAMON");
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ typedef struct {
|
|||
struct _SpaVolume {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaVolumeProps props;
|
||||
SpaVolumeProps tmp_props;
|
||||
SpaVolumeProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -108,8 +107,8 @@ spa_volume_node_get_props (SpaHandle *handle,
|
|||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->tmp_props, &this->props, sizeof (this->tmp_props));
|
||||
*props = &this->tmp_props.props;
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -119,7 +118,7 @@ spa_volume_node_set_props (SpaHandle *handle,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaVolume *this = (SpaVolume *) handle;
|
||||
SpaVolumeProps *p = &this->props;
|
||||
SpaVolumeProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
|
|
@ -477,7 +476,7 @@ spa_volume_node_pull_port_output (SpaHandle *handle,
|
|||
if (this->input_buffer == NULL)
|
||||
return SPA_RESULT_NEED_MORE_INPUT;
|
||||
|
||||
volume = this->props.volume;
|
||||
volume = this->props[1].volume;
|
||||
|
||||
sbuf = this->input_buffer;
|
||||
dbuf = info->buffer ? info->buffer : this->input_buffer;
|
||||
|
|
@ -584,11 +583,11 @@ spa_volume_new (void)
|
|||
handle->get_interface = spa_volume_get_interface;
|
||||
|
||||
this = (SpaVolume *) handle;
|
||||
this->props.props.n_prop_info = PROP_ID_LAST;
|
||||
this->props.props.prop_info = prop_info;
|
||||
this->props.props.set_prop = spa_props_generic_set_prop;
|
||||
this->props.props.get_prop = spa_props_generic_get_prop;
|
||||
reset_volume_props (&this->props);
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_volume_props (&this->props[1]);
|
||||
|
||||
this->ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFER |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
|
|
|
|||
9
spa/plugins/xv/meson.build
Normal file
9
spa/plugins/xv/meson.build
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
xv_sources = ['xv.c',
|
||||
'xv-sink.c']
|
||||
|
||||
xvlib = shared_library('spa-xv',
|
||||
xv_sources,
|
||||
include_directories : inc,
|
||||
dependencies : xv_dep,
|
||||
link_with : spalib,
|
||||
install : true)
|
||||
564
spa/plugins/xv/xv-sink.c
Normal file
564
spa/plugins/xv/xv-sink.c
Normal file
|
|
@ -0,0 +1,564 @@
|
|||
/* Spa Xv Sink
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* 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 <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
typedef struct _SpaXvSink SpaXvSink;
|
||||
|
||||
static const char default_device[] = "/dev/video0";
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
char device[64];
|
||||
char device_name[128];
|
||||
int device_fd;
|
||||
} SpaXvSinkProps;
|
||||
|
||||
static void
|
||||
reset_xv_sink_props (SpaXvSinkProps *props)
|
||||
{
|
||||
strncpy (props->device, default_device, 64);
|
||||
}
|
||||
|
||||
#define MAX_BUFFERS 256
|
||||
|
||||
typedef struct {
|
||||
SpaEventPoll poll;
|
||||
SpaXvSink *sink;
|
||||
} XvEventPoll;
|
||||
|
||||
typedef struct _XvBuffer XvBuffer;
|
||||
|
||||
struct _XvBuffer {
|
||||
SpaBuffer buffer;
|
||||
SpaMeta meta[1];
|
||||
SpaMetaHeader header;
|
||||
SpaData data[1];
|
||||
XvBuffer *next;
|
||||
uint32_t index;
|
||||
SpaXvSink *sink;
|
||||
bool outstanding;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
bool opened;
|
||||
int fd;
|
||||
pthread_t thread;
|
||||
bool running;
|
||||
XvBuffer buffers[MAX_BUFFERS];
|
||||
XvBuffer *ready;
|
||||
uint32_t ready_count;
|
||||
} SpaXvState;
|
||||
|
||||
struct _SpaXvSink {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaXvSinkProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
SpaVideoRawFormat raw_format[2];
|
||||
SpaFormat *current_format;
|
||||
|
||||
SpaXvState state;
|
||||
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
|
||||
};
|
||||
|
||||
#include "xv-utils.c"
|
||||
|
||||
static const uint32_t min_uint32 = 1;
|
||||
static const uint32_t max_uint32 = UINT32_MAX;
|
||||
|
||||
static const SpaPropRangeInfo uint32_range[] = {
|
||||
{ "min", "Minimum value", 4, &min_uint32 },
|
||||
{ "max", "Maximum value", 4, &max_uint32 },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_DEVICE_FD,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_DEVICE, "device", "Xv device location",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_STRING, 63,
|
||||
strlen (default_device)+1, default_device,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL,
|
||||
offsetof (SpaXvSinkProps, device),
|
||||
0, 0,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_NAME, "device-name", "Human-readable name of the device",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
0, NULL,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL,
|
||||
offsetof (SpaXvSinkProps, device_name),
|
||||
0, 0,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_FD, "device-fd", "Device file descriptor",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
0, NULL,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL,
|
||||
offsetof (SpaXvSinkProps, device_fd),
|
||||
0, 0,
|
||||
NULL },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_props (SpaHandle *handle,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_set_props (SpaHandle *handle,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
SpaXvSinkProps *p = &this->props[1];
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (props == NULL) {
|
||||
reset_xv_sink_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
res = spa_props_copy (props, &p->props);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_send_command (SpaHandle *handle,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (command->type) {
|
||||
case SPA_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_COMMAND_START:
|
||||
spa_xv_start (this);
|
||||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STARTED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
case SPA_COMMAND_STOP:
|
||||
spa_xv_stop (this);
|
||||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STOPPED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPA_COMMAND_FLUSH:
|
||||
case SPA_COMMAND_DRAIN:
|
||||
case SPA_COMMAND_MARKER:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_set_event_callback (SpaHandle *handle,
|
||||
SpaEventCallback event,
|
||||
void *user_data)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this->event_cb = event;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_n_ports (SpaHandle *handle,
|
||||
unsigned int *n_input_ports,
|
||||
unsigned int *max_input_ports,
|
||||
unsigned int *n_output_ports,
|
||||
unsigned int *max_output_ports)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_port_ids (SpaHandle *handle,
|
||||
unsigned int n_input_ports,
|
||||
uint32_t *input_ids,
|
||||
unsigned int n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_output_ports > 0)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_add_port (SpaHandle *handle,
|
||||
SpaDirection direction,
|
||||
uint32_t *port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_remove_port (SpaHandle *handle,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_enum_port_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&this->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->raw_format[0].format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_set_port_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
SpaResult res;
|
||||
SpaFormat *f, *tf;
|
||||
size_t fs;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (format == NULL) {
|
||||
this->current_format = NULL;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if (format->media_type == SPA_MEDIA_TYPE_VIDEO) {
|
||||
if (format->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
|
||||
if ((res = spa_video_raw_format_parse (format, &this->raw_format[0]) < 0))
|
||||
return res;
|
||||
|
||||
f = &this->raw_format[0].format;
|
||||
tf = &this->raw_format[1].format;
|
||||
fs = sizeof (SpaVideoRawFormat);
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (spa_xv_set_format (this, f, test_only) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
memcpy (tf, f, fs);
|
||||
this->current_format = tf;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_port_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaFormat **format)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (this->current_format == NULL)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = this->current_format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_port_info (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortInfo **info)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_port_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaProps **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_set_port_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaProps *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_get_port_status (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
|
||||
if (handle == NULL || status == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->status;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_push_port_input (SpaHandle *handle,
|
||||
unsigned int n_info,
|
||||
SpaInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_pull_port_output (SpaHandle *handle,
|
||||
unsigned int n_info,
|
||||
SpaOutputInfo *info)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
SpaXvState *state;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (handle == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
state = &this->state;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
XvBuffer *b;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
if (this->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
if (state->ready_count == 0) {
|
||||
info[i].status = SPA_RESULT_UNEXPECTED;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
b = state->ready;
|
||||
state->ready = b->next;
|
||||
state->ready_count--;
|
||||
|
||||
b->outstanding = true;
|
||||
|
||||
info[i].buffer = &b->buffer;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode xvsink_node = {
|
||||
sizeof (SpaNode),
|
||||
spa_xv_sink_node_get_props,
|
||||
spa_xv_sink_node_set_props,
|
||||
spa_xv_sink_node_send_command,
|
||||
spa_xv_sink_node_set_event_callback,
|
||||
spa_xv_sink_node_get_n_ports,
|
||||
spa_xv_sink_node_get_port_ids,
|
||||
spa_xv_sink_node_add_port,
|
||||
spa_xv_sink_node_remove_port,
|
||||
spa_xv_sink_node_enum_port_formats,
|
||||
spa_xv_sink_node_set_port_format,
|
||||
spa_xv_sink_node_get_port_format,
|
||||
spa_xv_sink_node_get_port_info,
|
||||
spa_xv_sink_node_get_port_props,
|
||||
spa_xv_sink_node_set_port_props,
|
||||
spa_xv_sink_node_get_port_status,
|
||||
spa_xv_sink_node_push_port_input,
|
||||
spa_xv_sink_node_pull_port_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_get_interface (SpaHandle *handle,
|
||||
uint32_t interface_id,
|
||||
const void **interface)
|
||||
{
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &xvsink_node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaHandle *
|
||||
spa_xv_sink_new (void)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaXvSink *this;
|
||||
|
||||
handle = calloc (1, sizeof (SpaXvSink));
|
||||
handle->get_interface = spa_xv_sink_get_interface;
|
||||
|
||||
this = (SpaXvSink *) handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_xv_sink_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
return handle;
|
||||
}
|
||||
62
spa/plugins/xv/xv-utils.c
Normal file
62
spa/plugins/xv/xv-utils.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <poll.h>
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
|
||||
static int
|
||||
spa_xv_open (SpaXvSink *this)
|
||||
{
|
||||
SpaXvState *state = &this->state;
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
||||
state->opened = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_set_format (SpaXvSink *this, SpaFormat *format, bool try_only)
|
||||
{
|
||||
if (spa_xv_open (this) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_close (SpaXvSink *this)
|
||||
{
|
||||
SpaXvState *state = &this->state;
|
||||
|
||||
if (!state->opened)
|
||||
return 0;
|
||||
|
||||
state->opened = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_start (SpaXvSink *this)
|
||||
{
|
||||
if (spa_xv_open (this) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_stop (SpaXvSink *this)
|
||||
{
|
||||
spa_xv_close (this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
78
spa/plugins/xv/xv.c
Normal file
78
spa/plugins/xv/xv.c
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/* Spa Xv support
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* 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>
|
||||
|
||||
SpaHandle * spa_xv_sink_new (void);
|
||||
|
||||
static SpaResult
|
||||
xv_sink_instantiate (const SpaHandleFactory *factory,
|
||||
SpaHandle **handle)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
*handle = spa_xv_sink_new ();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo xv_sink_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
xv_sink_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &xv_sink_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaHandleFactory factories[] =
|
||||
{
|
||||
{ "xv-sink",
|
||||
NULL,
|
||||
xv_sink_instantiate,
|
||||
xv_sink_enum_interface_info,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*factory = &factories[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue