summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-07 15:54:35 +0100
committerwm4 <wm4@nowhere>2014-11-07 15:54:35 +0100
commitb814b7ca84a85a6c17c4ab85ae9855afb62bc237 (patch)
treeced176126a7a58f9b8a6d034d27889f380164d11
parent01141198be2beaec58928355b59ce5882027866e (diff)
downloadmpv-b814b7ca84a85a6c17c4ab85ae9855afb62bc237.tar.bz2
mpv-b814b7ca84a85a6c17c4ab85ae9855afb62bc237.tar.xz
audio: add --audio-client-name option
The main need I see for this is with libmpv - it would be confusing if some application showed up as "mpv" on whateverthehell PulseAudio uses it for (generally it does show up on various PA GUI tools).
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--audio/out/ao.c2
-rw-r--r--audio/out/ao_pulse.c7
-rw-r--r--audio/out/internal.h3
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
6 files changed, 15 insertions, 5 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 440647f448..1e5ae746ca 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1007,6 +1007,11 @@ Audio
maximum amplification, i.e. amplify by 200%. The default volume (no
change in volume) will be ``50`` in this case.
+``--audio-client-name=<name>``
+ The application name the player reports to the audio API. Can be useful
+ if you want to force a different audio profile (e.g. with PulseAudio),
+ or to set your own application name when using libmpv.
+
``--volume-restore-data=<string>``
Used internally for use by playback resume (e.g. with ``quit_watch_later``).
Restoring value has to be done carefully, because different AOs as well as
diff --git a/audio/out/ao.c b/audio/out/ao.c
index b94e459091..baf6db1e45 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -207,6 +207,8 @@ static struct ao *ao_alloc_pb(bool probing, struct mpv_global *global,
match_ao_driver(ao->driver->name, opts->audio_device, &ao->device);
ao->device = talloc_strdup(ao, ao->device);
+ ao->client_name = talloc_strdup(ao, opts->audio_client_name);
+
return ao;
}
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index e1f339f20b..f9fe64d84d 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -35,8 +35,6 @@
#include "ao.h"
#include "internal.h"
-#define PULSE_CLIENT_NAME "mpv"
-
#define VOL_PA2MP(v) ((v) * 100 / PA_VOLUME_NORM)
#define VOL_MP2PA(v) ((v) * PA_VOLUME_NORM / 100)
@@ -308,7 +306,7 @@ static int pa_init_boilerplate(struct ao *ao)
locked = true;
if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api(
- priv->mainloop), PULSE_CLIENT_NAME)))
+ priv->mainloop), ao->client_name)))
{
MP_ERR(ao, "Failed to allocate context\n");
goto fail;
@@ -396,8 +394,7 @@ static int init(struct ao *ao)
goto unlock_and_fail;
}
(void)pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, "video");
- (void)pa_proplist_sets(proplist, PA_PROP_MEDIA_ICON_NAME,
- PULSE_CLIENT_NAME);
+ (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);
diff --git a/audio/out/internal.h b/audio/out/internal.h
index fd45a4a581..8ba789f603 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -49,6 +49,9 @@ struct ao {
// default device should be used, this is set to NULL.
char *device;
+ // Application name to report to the audio API.
+ char *client_name;
+
// Used during init: if init fails, redirect to this ao
char *redirect;
diff --git a/options/options.c b/options/options.c
index ef1a383450..c15482fd05 100644
--- a/options/options.c
+++ b/options/options.c
@@ -352,6 +352,7 @@ const m_option_t mp_opts[] = {
OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list),
OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list),
OPT_STRING("audio-device", audio_device, 0),
+ OPT_STRING("audio-client-name", audio_client_name, 0),
OPT_FLAG("fixed-vo", fixed_vo, CONF_GLOBAL),
OPT_FLAG("force-window", force_vo, CONF_GLOBAL),
OPT_FLAG("ontop", vo.ontop, M_OPT_FIXED),
@@ -572,6 +573,7 @@ const struct MPOpts mp_default_opts = {
.gapless_audio = -1,
.audio_buffer = 0.2,
.audio_device = "auto",
+ .audio_client_name = "mpv",
.vo = {
.video_driver_list = NULL,
.monitor_pixel_aspect = 1.0,
diff --git a/options/options.h b/options/options.h
index 9dddf9b94e..f67a3a5c95 100644
--- a/options/options.h
+++ b/options/options.h
@@ -65,6 +65,7 @@ typedef struct MPOpts {
struct m_obj_settings *audio_driver_list, *ao_defs;
char *audio_device;
+ char *audio_client_name;
int fixed_vo;
int force_vo;
int softvol;