mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
improve error reporting
Move signals from core to the objects themselves Use per object info to track object signals Use periods in alsasink and source
This commit is contained in:
parent
fb69758251
commit
cae971e106
23 changed files with 573 additions and 384 deletions
|
|
@ -32,16 +32,16 @@
|
|||
typedef struct _SpaALSAState SpaALSASink;
|
||||
|
||||
static const char default_device[] = "default";
|
||||
static const uint32_t default_buffer_time = 4000;
|
||||
static const uint32_t default_period_time = 100;
|
||||
static const uint32_t default_period_size = 128;
|
||||
static const uint32_t default_periods = 2;
|
||||
static const bool default_period_event = 0;
|
||||
|
||||
static void
|
||||
reset_alsa_sink_props (SpaALSAProps *props)
|
||||
{
|
||||
strncpy (props->device, default_device, 64);
|
||||
props->buffer_time = default_buffer_time;
|
||||
props->period_time = default_period_time;
|
||||
props->period_size = default_period_size;
|
||||
props->periods = default_periods;
|
||||
props->period_event = default_period_event;
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ enum {
|
|||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_CARD_NAME,
|
||||
PROP_ID_BUFFER_TIME,
|
||||
PROP_ID_PERIOD_TIME,
|
||||
PROP_ID_PERIOD_SIZE,
|
||||
PROP_ID_PERIODS,
|
||||
PROP_ID_PERIOD_EVENT,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
|
@ -90,14 +90,14 @@ static const SpaPropInfo prop_info[] =
|
|||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_BUFFER_TIME, offsetof (SpaALSAProps, buffer_time),
|
||||
"buffer-time",
|
||||
{ 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_PERIOD_TIME, offsetof (SpaALSAProps, period_time),
|
||||
"period-time",
|
||||
{ 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,
|
||||
|
|
|
|||
|
|
@ -39,16 +39,16 @@ update_state (SpaALSASource *this, SpaNodeState state)
|
|||
}
|
||||
|
||||
static const char default_device[] = "hw:0";
|
||||
static const uint32_t default_buffer_time = 10000;
|
||||
static const uint32_t default_period_time = 1000;
|
||||
static const uint32_t default_period_size = 128;
|
||||
static const uint32_t default_periods = 2;
|
||||
static const bool default_period_event = 0;
|
||||
|
||||
static void
|
||||
reset_alsa_props (SpaALSAProps *props)
|
||||
{
|
||||
strncpy (props->device, default_device, 64);
|
||||
props->buffer_time = default_buffer_time;
|
||||
props->period_time = default_period_time;
|
||||
props->period_size = default_period_size;
|
||||
props->periods = default_periods;
|
||||
props->period_event = default_period_event;
|
||||
props->props.unset_mask = 0xf;
|
||||
}
|
||||
|
|
@ -65,8 +65,8 @@ enum {
|
|||
PROP_ID_DEVICE,
|
||||
PROP_ID_DEVICE_NAME,
|
||||
PROP_ID_CARD_NAME,
|
||||
PROP_ID_BUFFER_TIME,
|
||||
PROP_ID_PERIOD_TIME,
|
||||
PROP_ID_PERIOD_SIZE,
|
||||
PROP_ID_PERIODS,
|
||||
PROP_ID_PERIOD_EVENT,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
|
@ -91,14 +91,14 @@ static const SpaPropInfo prop_info[] =
|
|||
SPA_PROP_TYPE_STRING, 127,
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_BUFFER_TIME, offsetof (SpaALSAProps, buffer_time),
|
||||
"buffer-time",
|
||||
{ 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_PERIOD_TIME, offsetof (SpaALSAProps, period_time),
|
||||
"period-time",
|
||||
{ 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,
|
||||
|
|
|
|||
|
|
@ -111,14 +111,13 @@ int
|
|||
spa_alsa_set_format (SpaALSAState *state, SpaFormatAudio *fmt, SpaPortFormatFlags flags)
|
||||
{
|
||||
unsigned int rrate, rchannels;
|
||||
snd_pcm_uframes_t size;
|
||||
snd_pcm_uframes_t period_size;
|
||||
int err, dir;
|
||||
snd_pcm_hw_params_t *params;
|
||||
snd_pcm_format_t format;
|
||||
SpaAudioInfoRaw *info = &fmt->info.raw;
|
||||
snd_pcm_t *hndl;
|
||||
unsigned int buffer_time;
|
||||
unsigned int period_time;
|
||||
unsigned int periods;
|
||||
SpaALSAProps *props = &state->props[1];
|
||||
|
||||
if ((err = spa_alsa_open (state)) < 0)
|
||||
|
|
@ -166,17 +165,31 @@ spa_alsa_set_format (SpaALSAState *state, SpaFormatAudio *fmt, SpaPortFormatFlag
|
|||
state->rate = info->rate;
|
||||
state->frame_size = info->channels * 2;
|
||||
|
||||
period_size = props->period_size;
|
||||
CHECK (snd_pcm_hw_params_set_period_size_near (hndl, params, &period_size, &dir), "set_period_size");
|
||||
state->period_frames = period_size;
|
||||
|
||||
periods = props->periods;
|
||||
CHECK (snd_pcm_hw_params_set_periods_near (hndl, params, &periods, &dir), "set_periods_near");
|
||||
state->buffer_frames = periods * state->period_frames;
|
||||
|
||||
CHECK (snd_pcm_hw_params_set_buffer_size (hndl, params, state->buffer_frames), "set_buffer_size");
|
||||
|
||||
#if 0
|
||||
/* set the buffer time */
|
||||
buffer_time = props->buffer_time;
|
||||
CHECK (snd_pcm_hw_params_set_buffer_time_near (hndl, params, &buffer_time, &dir), "set_buffer_time_near");
|
||||
|
||||
CHECK (snd_pcm_hw_params_get_buffer_size (params, &size), "get_buffer_size");
|
||||
state->buffer_frames = size;
|
||||
|
||||
/* set the period time */
|
||||
period_time = props->period_time;
|
||||
CHECK (snd_pcm_hw_params_set_period_time_near (hndl, params, &period_time, &dir), "set_period_time_near");
|
||||
|
||||
CHECK (snd_pcm_hw_params_get_period_size (params, &size, &dir), "get_period_size");
|
||||
state->period_frames = size;
|
||||
#endif
|
||||
|
||||
spa_log_info (state->log, "buffer frames %zd, period frames %zd", state->buffer_frames, state->period_frames);
|
||||
|
||||
|
|
@ -391,10 +404,12 @@ mmap_write (SpaALSAState *state)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
ni.event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
|
||||
ni.event.size = sizeof (ni);
|
||||
ni.port_id = 0;
|
||||
state->event_cb (&state->node, &ni.event, state->user_data);
|
||||
#endif
|
||||
|
||||
size = avail;
|
||||
while (size > 0) {
|
||||
|
|
@ -536,7 +551,6 @@ alsa_on_fd_events (SpaSource *source)
|
|||
if (revents & SPA_IO_ERR) {
|
||||
if ((err = xrun_recovery (state, hndl, err)) < 0) {
|
||||
spa_log_error (state->log, "error: %s", snd_strerror (err));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ typedef struct {
|
|||
char device[64];
|
||||
char device_name[128];
|
||||
char card_name[128];
|
||||
uint32_t buffer_time;
|
||||
uint32_t period_time;
|
||||
uint32_t period_size;
|
||||
uint32_t periods;
|
||||
bool period_event;
|
||||
} SpaALSAProps;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue