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:
Wim Taymans 2016-07-07 09:30:18 +02:00
parent a1a27328e2
commit a31eb56663
14 changed files with 842 additions and 79 deletions

View file

@ -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;

View file

@ -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 (&params);
/* 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 (&params);
@ -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 |