mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
update properties
This commit is contained in:
parent
dbae2e3f96
commit
9dd826136d
11 changed files with 287 additions and 491 deletions
|
|
@ -52,79 +52,60 @@ update_state (SpaALSASink *this, SpaNodeState state)
|
|||
this->node.state = state;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const uint32_t min_uint32 = 1;
|
||||
static const uint32_t max_uint32 = UINT32_MAX;
|
||||
|
||||
static const SpaPropRangeInfo uint32_range[] = {
|
||||
{ "min", { 4, &min_uint32 } },
|
||||
{ "max", { 4, &max_uint32 } },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_NONE,
|
||||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_CARD_NAME,
|
||||
PROP_ID_PERIOD_SIZE,
|
||||
PROP_ID_PERIODS,
|
||||
PROP_ID_PERIOD_EVENT,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_DEVICE, offsetof (SpaALSAProps, device),
|
||||
"device",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_STRING, 63,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_NAME, offsetof (SpaALSAProps, device_name),
|
||||
"device-name",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_CARD_NAME, offsetof (SpaALSAProps, card_name),
|
||||
"card-name",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_PERIOD_SIZE, offsetof (SpaALSAProps, period_size),
|
||||
"period-size",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, uint32_range,
|
||||
NULL },
|
||||
{ PROP_ID_PERIODS, offsetof (SpaALSAProps, periods),
|
||||
"periods",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, uint32_range,
|
||||
NULL },
|
||||
{ PROP_ID_PERIOD_EVENT, offsetof (SpaALSAProps, period_event),
|
||||
"period-event",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaPODBuilder b = { NULL, };
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
b.data = this->props_buffer;
|
||||
b.size = sizeof (this->props_buffer);
|
||||
|
||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
||||
this->props.device, sizeof (this->props.device),
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_DEVICE_NAME, SPA_POD_TYPE_STRING,
|
||||
this->props.device_name, sizeof (this->props.device_name),
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_CARD_NAME, SPA_POD_TYPE_STRING,
|
||||
this->props.card_name, sizeof (this->props.card_name),
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_PERIOD_SIZE, SPA_POD_TYPE_INT,
|
||||
this->props.period_size,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
PROP_ID_PERIODS, SPA_POD_TYPE_INT,
|
||||
this->props.periods,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
PROP_ID_PERIOD_EVENT, SPA_POD_TYPE_BOOL,
|
||||
this->props.period_event,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
0), SpaProps);
|
||||
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -134,23 +115,36 @@ spa_alsa_sink_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaALSAProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_alsa_sink_props (p);
|
||||
reset_alsa_sink_props (&this->props);
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
SpaPODProp *pr;
|
||||
|
||||
SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) {
|
||||
switch (pr->body.key) {
|
||||
case PROP_ID_DEVICE:
|
||||
strncpy (this->props.device, SPA_POD_CONTENTS (SpaPODProp, pr), 63);
|
||||
break;
|
||||
case PROP_ID_PERIOD_SIZE:
|
||||
this->props.period_size = ((SpaPODInt*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_PERIODS:
|
||||
this->props.periods = ((SpaPODInt*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_PERIOD_EVENT:
|
||||
this->props.period_event = ((SpaPODBool*)&pr->body.value)->value;
|
||||
break;
|
||||
}
|
||||
|
||||
//res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -831,19 +825,14 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = alsasink_node;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
reset_alsa_sink_props (&this->props[1]);
|
||||
reset_alsa_sink_props (&this->props);
|
||||
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp (info->items[i].key, "alsa.card")) {
|
||||
snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value);
|
||||
// this->props[1].props.unset_mask &= ~1;
|
||||
snprintf (this->props.device, 63, "hw:%s", info->items[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,79 +52,59 @@ reset_alsa_props (SpaALSAProps *props)
|
|||
props->period_event = default_period_event;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const uint32_t min_uint32 = 1;
|
||||
static const uint32_t max_uint32 = UINT32_MAX;
|
||||
|
||||
static const SpaPropRangeInfo uint32_range[] = {
|
||||
{ "min", { 4, &min_uint32 } },
|
||||
{ "max", { 4, &max_uint32 } },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_NONE,
|
||||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_CARD_NAME,
|
||||
PROP_ID_PERIOD_SIZE,
|
||||
PROP_ID_PERIODS,
|
||||
PROP_ID_PERIOD_EVENT,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_DEVICE, offsetof (SpaALSAProps, device),
|
||||
"device",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_STRING, 63,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_NAME, offsetof (SpaALSAProps, device_name),
|
||||
"device-name",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_CARD_NAME, offsetof (SpaALSAProps, card_name),
|
||||
"card-name",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_PERIOD_SIZE, offsetof (SpaALSAProps, period_size),
|
||||
"period-size",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, uint32_range,
|
||||
NULL },
|
||||
{ PROP_ID_PERIODS, offsetof (SpaALSAProps, periods),
|
||||
"periods",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, uint32_range,
|
||||
NULL },
|
||||
{ PROP_ID_PERIOD_EVENT, offsetof (SpaALSAProps, period_event),
|
||||
"period-event",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
SpaPODBuilder b = { NULL, };
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
b.data = this->props_buffer;
|
||||
b.size = sizeof (this->props_buffer);
|
||||
|
||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
||||
this->props.device, sizeof (this->props.device),
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_DEVICE_NAME, SPA_POD_TYPE_STRING,
|
||||
this->props.device_name, sizeof (this->props.device_name),
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_CARD_NAME, SPA_POD_TYPE_STRING,
|
||||
this->props.card_name, sizeof (this->props.card_name),
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_PERIOD_SIZE, SPA_POD_TYPE_INT,
|
||||
this->props.period_size,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
PROP_ID_PERIODS, SPA_POD_TYPE_INT,
|
||||
this->props.periods,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
1, INT32_MAX,
|
||||
PROP_ID_PERIOD_EVENT, SPA_POD_TYPE_BOOL,
|
||||
this->props.period_event,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
0), SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -134,23 +114,37 @@ spa_alsa_source_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
SpaALSAProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_alsa_props (p);
|
||||
reset_alsa_props (&this->props);
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
SpaPODProp *pr;
|
||||
|
||||
SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) {
|
||||
switch (pr->body.key) {
|
||||
case PROP_ID_DEVICE:
|
||||
strncpy (this->props.device, SPA_POD_CONTENTS (SpaPODProp, pr), 63);
|
||||
break;
|
||||
case PROP_ID_PERIOD_SIZE:
|
||||
this->props.period_size = ((SpaPODInt*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_PERIODS:
|
||||
this->props.periods = ((SpaPODInt*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_PERIOD_EVENT:
|
||||
this->props.period_event = ((SpaPODBool*)&pr->body.value)->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -897,20 +891,15 @@ alsa_source_init (const SpaHandleFactory *factory,
|
|||
|
||||
this->node = alsasource_node;
|
||||
this->clock = alsasource_clock;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
this->stream = SND_PCM_STREAM_CAPTURE;
|
||||
reset_alsa_props (&this->props[1]);
|
||||
reset_alsa_props (&this->props);
|
||||
|
||||
spa_list_init (&this->free);
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp (info->items[i].key, "alsa.card")) {
|
||||
snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value);
|
||||
// this->props[1].props.unset_mask &= ~1;
|
||||
snprintf (this->props.device, 63, "hw:%s", info->items[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ static int
|
|||
spa_alsa_open (SpaALSAState *state)
|
||||
{
|
||||
int err;
|
||||
SpaALSAProps *props = &state->props[1];
|
||||
SpaALSAProps *props = &state->props;
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
|
@ -118,7 +118,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags
|
|||
SpaAudioInfoRaw *info = &fmt->info.raw;
|
||||
snd_pcm_t *hndl;
|
||||
unsigned int periods;
|
||||
SpaALSAProps *props = &state->props[1];
|
||||
SpaALSAProps *props = &state->props;
|
||||
|
||||
if ((err = spa_alsa_open (state)) < 0)
|
||||
return err;
|
||||
|
|
@ -195,7 +195,7 @@ set_swparams (SpaALSAState *state)
|
|||
snd_pcm_t *hndl = state->hndl;
|
||||
int err = 0;
|
||||
snd_pcm_sw_params_t *params;
|
||||
SpaALSAProps *props = &state->props[1];
|
||||
SpaALSAProps *props = &state->props;
|
||||
|
||||
snd_pcm_sw_params_alloca (¶ms);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ typedef struct _SpaALSAState SpaALSAState;
|
|||
typedef struct _SpaALSABuffer SpaALSABuffer;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
char device[64];
|
||||
char device_name[128];
|
||||
char card_name[128];
|
||||
|
|
@ -84,7 +83,8 @@ struct _SpaALSAState {
|
|||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
SpaALSAProps props[2];
|
||||
uint8_t props_buffer[1024];
|
||||
SpaALSAProps props;
|
||||
|
||||
bool opened;
|
||||
snd_pcm_t *hndl;
|
||||
|
|
|
|||
|
|
@ -30,14 +30,6 @@
|
|||
|
||||
typedef struct _SpaAudioMixer SpaAudioMixer;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
} SpaAudioMixerProps;
|
||||
|
||||
typedef struct {
|
||||
SpaProps prop;
|
||||
} SpaAudioMixerPortProps;
|
||||
|
||||
typedef struct _MixerBuffer MixerBuffer;
|
||||
|
||||
struct _MixerBuffer {
|
||||
|
|
@ -52,7 +44,6 @@ typedef struct {
|
|||
bool valid;
|
||||
bool have_format;
|
||||
SpaAudioInfo format;
|
||||
SpaAudioMixerPortProps props[2];
|
||||
SpaPortInfo info;
|
||||
size_t buffer_index;
|
||||
size_t buffer_offset;
|
||||
|
|
@ -77,8 +68,6 @@ struct _SpaAudioMixer {
|
|||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaAudioMixerProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
|
|
@ -97,47 +86,18 @@ enum {
|
|||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static void
|
||||
reset_audiomixer_props (SpaAudioMixerProps *props)
|
||||
{
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_set_props (SpaNode *node,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaAudioMixerProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_audiomixer_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -307,7 +267,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
|
|||
unsigned int index)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaAudioMixerPort *port;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -317,8 +276,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
break;
|
||||
|
|
@ -748,11 +705,6 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = audiomixer_node;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_audiomixer_props (&this->props[1]);
|
||||
|
||||
this->out_ports[0].valid = true;
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS |
|
||||
|
|
|
|||
|
|
@ -44,11 +44,10 @@ typedef struct {
|
|||
typedef struct _SpaAudioTestSrc SpaAudioTestSrc;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
bool live;
|
||||
uint32_t wave;
|
||||
double freq;
|
||||
double volume;
|
||||
bool live;
|
||||
} SpaAudioTestSrcProps;
|
||||
|
||||
#define MAX_BUFFERS 16
|
||||
|
|
@ -74,7 +73,8 @@ struct _SpaAudioTestSrc {
|
|||
SpaLog *log;
|
||||
SpaLoop *data_loop;
|
||||
|
||||
SpaAudioTestSrcProps props[2];
|
||||
uint8_t props_buffer[512];
|
||||
SpaAudioTestSrcProps props;
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
|
@ -106,81 +106,29 @@ struct _SpaAudioTestSrc {
|
|||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
||||
#define DEFAULT_WAVE 0
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
#define DEFAULT_FREQ 440.0
|
||||
#define DEFAULT_LIVE true
|
||||
|
||||
#if 0
|
||||
static const double min_volume = 0.0;
|
||||
static const double max_volume = 10.0;
|
||||
static const double min_freq = 0.0;
|
||||
static const double max_freq = 50000000.0;
|
||||
#define DEFAULT_WAVE 0
|
||||
#define DEFAULT_FREQ 440.0
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
|
||||
static const uint32_t wave_val_sine = 0;
|
||||
static const uint32_t wave_val_square = 1;
|
||||
|
||||
static const SpaPropRangeInfo volume_range[] = {
|
||||
{ "min", { sizeof (double), &min_volume } },
|
||||
{ "max", { sizeof (double), &max_volume } },
|
||||
};
|
||||
|
||||
static const SpaPropRangeInfo wave_range[] = {
|
||||
{ "sine", { sizeof (uint32_t), &wave_val_sine } },
|
||||
{ "square", { sizeof (uint32_t), &wave_val_square } },
|
||||
};
|
||||
|
||||
static const SpaPropRangeInfo freq_range[] = {
|
||||
{ "min", { sizeof (double), &min_freq } },
|
||||
{ "max", { sizeof (double), &max_freq } },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_NONE,
|
||||
PROP_ID_LIVE,
|
||||
PROP_ID_WAVE,
|
||||
PROP_ID_FREQ,
|
||||
PROP_ID_VOLUME,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_LIVE, offsetof (SpaAudioTestSrcProps, live),
|
||||
"live",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_WAVE, offsetof (SpaAudioTestSrcProps, wave),
|
||||
"wave",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_ENUM, SPA_N_ELEMENTS (wave_range), wave_range,
|
||||
NULL },
|
||||
{ PROP_ID_FREQ, offsetof (SpaAudioTestSrcProps, freq),
|
||||
"freq",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_DOUBLE, sizeof (double),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, freq_range,
|
||||
NULL },
|
||||
{ PROP_ID_VOLUME, offsetof (SpaAudioTestSrcProps, volume),
|
||||
"volume",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_DOUBLE, sizeof (double),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, volume_range,
|
||||
NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
static SpaResult
|
||||
static void
|
||||
reset_audiotestsrc_props (SpaAudioTestSrcProps *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->wave = DEFAULT_WAVE;
|
||||
props->freq = DEFAULT_FREQ;
|
||||
props->volume = DEFAULT_VOLUME;
|
||||
props->live = DEFAULT_LIVE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -188,13 +136,40 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
|
|||
SpaProps **props)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
SpaPODBuilder b = { NULL, };
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
b.data = this->props_buffer;
|
||||
b.size = sizeof (this->props_buffer);
|
||||
|
||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||
PROP_ID_LIVE, SPA_POD_TYPE_BOOL,
|
||||
this->props.live,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
PROP_ID_WAVE, SPA_POD_TYPE_INT,
|
||||
this->props.wave,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_ENUM, 2,
|
||||
wave_val_sine,
|
||||
wave_val_square,
|
||||
PROP_ID_FREQ, SPA_POD_TYPE_DOUBLE,
|
||||
this->props.freq,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
0.0,
|
||||
50000000.0,
|
||||
PROP_ID_VOLUME, SPA_POD_TYPE_DOUBLE,
|
||||
this->props.volume,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
0.0,
|
||||
10.0,
|
||||
0), SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -204,27 +179,41 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
SpaAudioTestSrcProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
res = reset_audiotestsrc_props (p);
|
||||
reset_audiotestsrc_props (&this->props);
|
||||
} else {
|
||||
// res = spa_props_copy_values (props, &p->props);
|
||||
SpaPODProp *pr;
|
||||
|
||||
SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) {
|
||||
switch (pr->body.key) {
|
||||
case PROP_ID_LIVE:
|
||||
this->props.live = ((SpaPODBool*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_WAVE:
|
||||
this->props.wave = ((SpaPODInt*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_FREQ:
|
||||
this->props.freq = ((SpaPODDouble*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_VOLUME:
|
||||
this->props.volume = ((SpaPODDouble*)&pr->body.value)->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->props[1].live)
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
else
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -258,7 +247,7 @@ static void
|
|||
set_timer (SpaAudioTestSrc *this, bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
if (this->props[1].live) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
|
|
@ -346,7 +335,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
|
||||
clock_gettime (CLOCK_MONOTONIC, &now);
|
||||
if (this->props[1].live)
|
||||
if (this->props.live)
|
||||
this->start_time = SPA_TIMESPEC_TO_TIME (&now);
|
||||
else
|
||||
this->start_time = 0;
|
||||
|
|
@ -518,7 +507,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -809,7 +798,7 @@ spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
|
|||
b->outstanding = false;
|
||||
spa_list_insert (this->empty.prev, &b->link);
|
||||
|
||||
if (!this->props[1].live)
|
||||
if (!this->props.live)
|
||||
set_timer (this, true);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -989,11 +978,7 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
|
||||
this->node = audiotestsrc_node;
|
||||
this->clock = audiotestsrc_clock;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_audiotestsrc_props (&this->props[1]);
|
||||
reset_audiotestsrc_props (&this->props);
|
||||
|
||||
spa_list_init (&this->empty);
|
||||
|
||||
|
|
@ -1009,7 +994,7 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props[1].live)
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
this->node.state = SPA_NODE_STATE_CONFIGURE;
|
||||
|
|
|
|||
|
|
@ -30,15 +30,6 @@
|
|||
|
||||
typedef struct _SpaFFMpegDec SpaFFMpegDec;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
} SpaFFMpegDecProps;
|
||||
|
||||
static void
|
||||
reset_ffmpeg_dec_props (SpaFFMpegDecProps *props)
|
||||
{
|
||||
}
|
||||
|
||||
#define IS_VALID_PORT(this,d,id) ((id) == 0)
|
||||
#define MAX_BUFFERS 32
|
||||
|
||||
|
|
@ -52,7 +43,6 @@ struct _FFMpegBuffer {
|
|||
|
||||
typedef struct {
|
||||
bool have_format;
|
||||
SpaVideoInfo query_format;
|
||||
SpaVideoInfo current_format;
|
||||
bool have_buffers;
|
||||
FFMpegBuffer buffers[MAX_BUFFERS];
|
||||
|
|
@ -74,8 +64,6 @@ struct _SpaFFMpegDec {
|
|||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaFFMpegDecProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
|
|
@ -91,41 +79,14 @@ static SpaResult
|
|||
spa_ffmpeg_dec_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_set_props (SpaNode *node,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
SpaFFMpegDecProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_ffmpeg_dec_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
//res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -283,6 +244,7 @@ spa_ffmpeg_dec_node_port_set_format (SpaNode *node,
|
|||
SpaFFMpegDec *this;
|
||||
SpaFFMpegPort *port;
|
||||
SpaResult res;
|
||||
SpaVideoInfo query_format;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -299,11 +261,11 @@ spa_ffmpeg_dec_node_port_set_format (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if ((res = spa_format_video_parse (format, &port->query_format) < 0))
|
||||
if ((res = spa_format_video_parse (format, &query_format) < 0))
|
||||
return res;
|
||||
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (&port->current_format, &port->query_format, sizeof (SpaVideoInfo));
|
||||
memcpy (&port->current_format, &query_format, sizeof (SpaVideoInfo));
|
||||
port->have_format = true;
|
||||
}
|
||||
|
||||
|
|
@ -576,11 +538,6 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = ffmpeg_dec_node;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_ffmpeg_dec_props (&this->props[1]);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -30,15 +30,6 @@
|
|||
|
||||
typedef struct _SpaFFMpegEnc SpaFFMpegEnc;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
} SpaFFMpegEncProps;
|
||||
|
||||
static void
|
||||
reset_ffmpeg_enc_props (SpaFFMpegEncProps *props)
|
||||
{
|
||||
}
|
||||
|
||||
#define IS_VALID_PORT(this,d,id) ((id) == 0)
|
||||
#define MAX_BUFFERS 32
|
||||
|
||||
|
|
@ -56,8 +47,8 @@ struct _FFMpegBuffer {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
SpaVideoInfo format[2];
|
||||
SpaFormat *current_format;
|
||||
bool have_format;
|
||||
SpaVideoInfo current_format;
|
||||
bool have_buffers;
|
||||
FFMpegBuffer buffers[MAX_BUFFERS];
|
||||
SpaPortInfo info;
|
||||
|
|
@ -78,8 +69,6 @@ struct _SpaFFMpegEnc {
|
|||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaFFMpegEncProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
|
|
@ -101,41 +90,14 @@ static SpaResult
|
|||
spa_ffmpeg_enc_node_get_props (SpaNode *node,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_set_props (SpaNode *node,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegEncProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_ffmpeg_enc_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
//res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -287,6 +249,7 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
|
|||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegPort *port;
|
||||
SpaResult res;
|
||||
SpaVideoInfo query_format;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -299,7 +262,7 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
|
|||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->current_format = NULL;
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -307,12 +270,12 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
|
|||
format->body.media_subtype.value != SPA_MEDIA_SUBTYPE_RAW)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if ((res = spa_format_video_parse (format, &port->format[0]) < 0))
|
||||
if ((res = spa_format_video_parse (format, &query_format) < 0))
|
||||
return res;
|
||||
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (&port->format[1], &port->format[0], sizeof (SpaVideoInfo));
|
||||
port->current_format = NULL;
|
||||
memcpy (&port->current_format, &query_format, sizeof (SpaVideoInfo));
|
||||
port->have_format = true;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -337,10 +300,10 @@ spa_ffmpeg_enc_node_port_get_format (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (port->current_format == NULL)
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = port->current_format;
|
||||
*format = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -500,7 +463,7 @@ spa_ffmpeg_enc_node_process_output (SpaNode *node)
|
|||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if (port->current_format == NULL) {
|
||||
if (!port->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
|
@ -583,7 +546,6 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
reset_ffmpeg_enc_props (&this->props[1]);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -116,36 +116,11 @@ enum {
|
|||
PROP_ID_PATTERN,
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const SpaPropRangeInfo pattern_range[] = {
|
||||
{ "smpte-snow", { sizeof (uint32_t), &pattern_val_smpte_snow } },
|
||||
{ "snow", { sizeof (uint32_t), &pattern_val_snow } },
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_LIVE, offsetof (SpaVideoTestSrcProps, live),
|
||||
"live",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_PATTERN, offsetof (SpaVideoTestSrcProps, pattern),
|
||||
"pattern",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_ENUM, SPA_N_ELEMENTS (pattern_range), pattern_range,
|
||||
NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
static SpaResult
|
||||
static void
|
||||
reset_videotestsrc_props (SpaVideoTestSrcProps *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->pattern = DEFAULT_PATTERN;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -184,17 +159,14 @@ spa_videotestsrc_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
SpaVideoTestSrcProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
p = &this->props;
|
||||
|
||||
if (props == NULL) {
|
||||
res = reset_videotestsrc_props (p);
|
||||
reset_videotestsrc_props (&this->props);
|
||||
} else {
|
||||
SpaPODProp *pr;
|
||||
|
||||
|
|
@ -215,7 +187,7 @@ spa_videotestsrc_node_set_props (SpaNode *node,
|
|||
else
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -503,7 +475,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = SPA_MEMBER (this->format_buffer, 0, SpaFormat);
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -989,10 +961,6 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
|
||||
this->node = videotestsrc_node;
|
||||
this->clock = videotestsrc_clock;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_videotestsrc_props (&this->props);
|
||||
|
||||
spa_list_init (&this->empty);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
typedef struct _SpaVolume SpaVolume;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
double volume;
|
||||
bool mute;
|
||||
} SpaVolumeProps;
|
||||
|
|
@ -75,11 +74,13 @@ struct _SpaVolume {
|
|||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaVolumeProps props[2];
|
||||
uint8_t props_buffer[512];
|
||||
SpaVolumeProps props;
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
uint8_t format_buffer[1024];
|
||||
SpaAudioInfo current_format;
|
||||
|
||||
SpaVolumePort in_ports[1];
|
||||
|
|
@ -93,39 +94,12 @@ struct _SpaVolume {
|
|||
static const double default_volume = 1.0;
|
||||
static const bool default_mute = false;
|
||||
|
||||
#if 0
|
||||
static const double min_volume = 0.0;
|
||||
static const double max_volume = 10.0;
|
||||
|
||||
static const SpaPropRangeInfo volume_range[] = {
|
||||
{ "min", { sizeof (double), &min_volume } },
|
||||
{ "max", { sizeof (double), &max_volume } },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_NONE,
|
||||
PROP_ID_VOLUME,
|
||||
PROP_ID_MUTE,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_VOLUME, offsetof (SpaVolumeProps, volume),
|
||||
"volume",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_DOUBLE, sizeof (double),
|
||||
SPA_PROP_RANGE_TYPE_MIN_MAX, 2, volume_range,
|
||||
NULL },
|
||||
{ PROP_ID_MUTE, offsetof (SpaVolumeProps, mute),
|
||||
"mute",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
reset_volume_props (SpaVolumeProps *props)
|
||||
{
|
||||
|
|
@ -144,14 +118,28 @@ spa_volume_node_get_props (SpaNode *node,
|
|||
SpaProps **props)
|
||||
{
|
||||
SpaVolume *this;
|
||||
SpaPODBuilder b = { NULL, };
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
b.data = this->props_buffer;
|
||||
b.size = sizeof (this->props_buffer);
|
||||
|
||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||
PROP_ID_VOLUME, SPA_POD_TYPE_DOUBLE,
|
||||
this->props.volume,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
0.0,
|
||||
10.0,
|
||||
PROP_ID_MUTE, SPA_POD_TYPE_BOOL,
|
||||
this->props.mute,
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
0), SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -161,22 +149,29 @@ spa_volume_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaVolume *this;
|
||||
SpaVolumeProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_volume_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
//res = spa_props_copy_values (props, &p->props);
|
||||
reset_volume_props (&this->props);
|
||||
} else {
|
||||
SpaPODProp *pr;
|
||||
|
||||
return res;
|
||||
SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) {
|
||||
switch (pr->body.key) {
|
||||
case PROP_ID_VOLUME:
|
||||
this->props.volume = ((SpaPODDouble*)&pr->body.value)->value;
|
||||
break;
|
||||
case PROP_ID_MUTE:
|
||||
this->props.mute = ((SpaPODBool*)&pr->body.value)->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -334,10 +329,14 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
if ((res = spa_format_filter (fmt, filter, NULL)) != SPA_RESULT_OK)
|
||||
b.data = this->format_buffer;
|
||||
b.size = sizeof (this->format_buffer);
|
||||
b.offset = 0;
|
||||
|
||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = NULL;
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -671,7 +670,7 @@ do_volume (SpaVolume *this, SpaBuffer *dbuf, SpaBuffer *sbuf)
|
|||
uint16_t *src, *dst;
|
||||
double volume;
|
||||
|
||||
volume = this->props[1].volume;
|
||||
volume = this->props.volume;
|
||||
|
||||
si = di = 0;
|
||||
soff = doff = 0;
|
||||
|
|
@ -852,11 +851,7 @@ volume_init (const SpaHandleFactory *factory,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = volume_node;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_volume_props (&this->props[1]);
|
||||
reset_volume_props (&this->props);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ 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;
|
||||
|
|
@ -82,12 +81,14 @@ struct _SpaXvSink {
|
|||
SpaIDMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaXvSinkProps props[2];
|
||||
uint8_t props_buffer[512];
|
||||
SpaXvSinkProps props;
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
bool have_format;
|
||||
uint8_t format_buffer[1024];
|
||||
SpaVideoInfo current_format;
|
||||
|
||||
SpaPortInfo info;
|
||||
|
|
@ -101,36 +102,12 @@ struct _SpaXvSink {
|
|||
#include "xv-utils.c"
|
||||
|
||||
enum {
|
||||
PROP_ID_NONE,
|
||||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_DEVICE_FD,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ PROP_ID_DEVICE, offsetof (SpaXvSinkProps, device),
|
||||
"device",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_STRING, 63,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_NAME, offsetof (SpaXvSinkProps, device_name),
|
||||
"device-name",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_DEVICE_FD, offsetof (SpaXvSinkProps, device_fd),
|
||||
"device-fd",
|
||||
SPA_PROP_FLAG_READABLE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
static void
|
||||
update_state (SpaXvSink *this, SpaNodeState state)
|
||||
{
|
||||
|
|
@ -142,13 +119,33 @@ spa_xv_sink_node_get_props (SpaNode *node,
|
|||
SpaProps **props)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
SpaPODBuilder b = { NULL, };
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
b.data = this->props_buffer;
|
||||
b.size = sizeof (this->props_buffer);
|
||||
|
||||
*props = SPA_MEMBER (b.data, spa_pod_builder_props (&b,
|
||||
|
||||
PROP_ID_DEVICE, SPA_POD_TYPE_STRING,
|
||||
this->props.device, sizeof (this->props.device),
|
||||
SPA_POD_PROP_FLAG_READWRITE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
|
||||
PROP_ID_DEVICE_NAME, SPA_POD_TYPE_STRING,
|
||||
this->props.device_name, sizeof (this->props.device_name),
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
|
||||
PROP_ID_DEVICE_FD, SPA_POD_TYPE_INT,
|
||||
this->props.device_fd,
|
||||
SPA_POD_PROP_FLAG_READABLE |
|
||||
SPA_POD_PROP_RANGE_NONE,
|
||||
0), SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -158,20 +155,26 @@ spa_xv_sink_node_set_props (SpaNode *node,
|
|||
const SpaProps *props)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
SpaXvSinkProps *p;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
p = &this->props[1];
|
||||
|
||||
if (props == NULL) {
|
||||
reset_xv_sink_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
reset_xv_sink_props (&this->props);
|
||||
} else {
|
||||
SpaPODProp *pr;
|
||||
|
||||
SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) {
|
||||
switch (pr->body.key) {
|
||||
case PROP_ID_DEVICE:
|
||||
strncpy (this->props.device, SPA_POD_CONTENTS (SpaPODProp, pr), 63);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -582,11 +585,7 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = xvsink_node;
|
||||
#if 0
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
#endif
|
||||
reset_xv_sink_props (&this->props[1]);
|
||||
reset_xv_sink_props (&this->props);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue