summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-05 19:34:34 +0100
committerwm4 <wm4@nowhere>2016-01-05 19:34:34 +0100
commit8fda7247ff89db8dd26abfafc0ada02090374699 (patch)
tree4e6285cc7d2f124632a62e1cc001116603cf28c4 /audio
parent172ce98433d4336448ddf7360c4a465c3614820e (diff)
downloadmpv-8fda7247ff89db8dd26abfafc0ada02090374699.tar.bz2
mpv-8fda7247ff89db8dd26abfafc0ada02090374699.tar.xz
ao_pulse: move format setting into a function
No real functional changes.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_pulse.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 78d8ac2561..177f02e0a5 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -376,22 +376,8 @@ fail:
return -1;
}
-static int init(struct ao *ao)
+static bool set_format(struct ao *ao, pa_format_info *format)
{
- struct pa_channel_map map;
- pa_proplist *proplist = NULL;
- pa_format_info *format = NULL;
- struct priv *priv = ao->priv;
- char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
-
- if (pa_init_boilerplate(ao) < 0)
- return -1;
-
- pa_threaded_mainloop_lock(priv->mainloop);
-
- if (!(format = pa_format_info_new()))
- goto unlock_and_fail;
-
ao->format = af_fmt_from_planar(ao->format);
format->encoding = map_digital_format(ao->format);
@@ -411,8 +397,29 @@ static int init(struct ao *ao)
pa_format_info_set_sample_format(format, fmt_map->pa_format);
}
+ struct pa_channel_map map;
+
if (!select_chmap(ao, &map))
- goto unlock_and_fail;
+ return false;
+
+ pa_format_info_set_rate(format, ao->samplerate);
+ pa_format_info_set_channels(format, ao->channels.num);
+ pa_format_info_set_channel_map(format, &map);
+
+ return pa_format_info_valid(format);
+}
+
+static int init(struct ao *ao)
+{
+ pa_proplist *proplist = NULL;
+ pa_format_info *format = NULL;
+ struct priv *priv = ao->priv;
+ char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
+
+ if (pa_init_boilerplate(ao) < 0)
+ return -1;
+
+ pa_threaded_mainloop_lock(priv->mainloop);
if (!(proplist = pa_proplist_new())) {
MP_ERR(ao, "Failed to allocate proplist\n");
@@ -420,11 +427,10 @@ static int init(struct ao *ao)
}
(void)pa_proplist_sets(proplist, PA_PROP_MEDIA_ICON_NAME, ao->client_name);
- pa_format_info_set_rate(format, ao->samplerate);
- pa_format_info_set_channels(format, ao->channels.num);
- pa_format_info_set_channel_map(format, &map);
+ if (!(format = pa_format_info_new()))
+ goto unlock_and_fail;
- if (!pa_format_info_valid(format)) {
+ if (!set_format(ao, format)) {
MP_ERR(ao, "Invalid audio format\n");
goto unlock_and_fail;
}