0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

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).
This commit is contained in:
wm4 2014-11-07 15:54:35 +01:00
parent 01141198be
commit b814b7ca84
6 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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;