mirror of https://github.com/mpv-player/mpv
ao_pipewire: small cleanups and restructring
* Remove unneeded braces. * Don't use non-standard %m in printf. * Organize struct priv a bit.
This commit is contained in:
parent
cc65b3892d
commit
a1e29f1555
|
@ -54,10 +54,13 @@ struct priv {
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
struct spa_hook stream_listener;
|
struct spa_hook stream_listener;
|
||||||
|
|
||||||
int buffer_msec;
|
|
||||||
bool muted;
|
bool muted;
|
||||||
float volume[2];
|
float volume[2];
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int buffer_msec;
|
||||||
|
} options;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct pw_registry *registry;
|
struct pw_registry *registry;
|
||||||
struct spa_hook registry_listener;
|
struct spa_hook registry_listener;
|
||||||
|
@ -134,7 +137,7 @@ static void on_process(void *userdata)
|
||||||
void *data[MP_NUM_CHANNELS];
|
void *data[MP_NUM_CHANNELS];
|
||||||
|
|
||||||
if ((b = pw_stream_dequeue_buffer(p->stream)) == NULL) {
|
if ((b = pw_stream_dequeue_buffer(p->stream)) == NULL) {
|
||||||
MP_WARN(ao, "out of buffers: %m\n");
|
MP_WARN(ao, "out of buffers: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +443,7 @@ static int init(struct ao *ao)
|
||||||
if (pipewire_init_boilerplate(ao) < 0)
|
if (pipewire_init_boilerplate(ao) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ao->device_buffer = p->buffer_msec * ao->samplerate / 1000;
|
ao->device_buffer = p->options.buffer_msec * ao->samplerate / 1000;
|
||||||
|
|
||||||
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", ao->device_buffer, ao->samplerate);
|
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", ao->device_buffer, ao->samplerate);
|
||||||
pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", ao->samplerate);
|
pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", ao->samplerate);
|
||||||
|
@ -661,9 +664,8 @@ static void hotplug_registry_global_remove_cb(void *data, uint32_t id)
|
||||||
done:
|
done:
|
||||||
pw_thread_loop_unlock(priv->loop);
|
pw_thread_loop_unlock(priv->loop);
|
||||||
|
|
||||||
if (removed_sink) {
|
if (removed_sink)
|
||||||
ao_hotplug_event(ao);
|
ao_hotplug_event(ao);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_registry_events hotplug_registry_events = {
|
static const struct pw_registry_events hotplug_registry_events = {
|
||||||
|
@ -749,11 +751,11 @@ const struct ao_driver audio_out_pipewire = {
|
||||||
{
|
{
|
||||||
.loop = NULL,
|
.loop = NULL,
|
||||||
.stream = NULL,
|
.stream = NULL,
|
||||||
.buffer_msec = 20,
|
.options.buffer_msec = 20,
|
||||||
},
|
},
|
||||||
.options_prefix = "pipewire",
|
.options_prefix = "pipewire",
|
||||||
.options = (const struct m_option[]) {
|
.options = (const struct m_option[]) {
|
||||||
{"buffer", OPT_INT(buffer_msec), M_RANGE(1, 2000)},
|
{"buffer", OPT_INT(options.buffer_msec), M_RANGE(1, 2000)},
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue