mirror of
https://github.com/mpv-player/mpv
synced 2025-03-24 20:31:37 +00:00
audio/out: remove old things
Remove the unnecessary indirection through ao fields. Also fix the inverted result of AOCONTROL_HAS_TEMP_VOLUME. Hopefully the change is equivalent. But actually, it looks like the old code did it wrong.
This commit is contained in:
parent
197f18402e
commit
439a05d8c3
@ -248,7 +248,7 @@ static void probe_softvol(struct mixer *mixer)
|
|||||||
if (mixer->opts->softvol == SOFTVOL_AUTO) {
|
if (mixer->opts->softvol == SOFTVOL_AUTO) {
|
||||||
// No system-wide volume => fine with AO volume control.
|
// No system-wide volume => fine with AO volume control.
|
||||||
mixer->softvol =
|
mixer->softvol =
|
||||||
ao_control(mixer->ao, AOCONTROL_HAS_TEMP_VOLUME, 0) != 1 ||
|
ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) != 1 &&
|
||||||
ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) != 1;
|
ao_control(mixer->ao, AOCONTROL_HAS_PER_APP_VOLUME, 0) != 1;
|
||||||
} else {
|
} else {
|
||||||
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
|
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
|
||||||
@ -283,7 +283,7 @@ static void restore_volume(struct mixer *mixer)
|
|||||||
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
|
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
|
||||||
|
|
||||||
bool restore =
|
bool restore =
|
||||||
mixer->softvol || ao_control(ao, AOCONTROL_HAS_TEMP_VOLUME, 0) == 1;
|
mixer->softvol || ao_control(ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
|
||||||
|
|
||||||
// Restore old parameters if volume won't survive reinitialization.
|
// Restore old parameters if volume won't survive reinitialization.
|
||||||
// But not if volume scale is possibly different.
|
// But not if volume scale is possibly different.
|
||||||
|
@ -259,16 +259,7 @@ int ao_play(struct ao *ao, void **data, int samples, int flags)
|
|||||||
|
|
||||||
int ao_control(struct ao *ao, enum aocontrol cmd, void *arg)
|
int ao_control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
{
|
{
|
||||||
switch (cmd) {
|
return ao->api->control ? ao->api->control(ao, cmd, arg) : CONTROL_UNKNOWN;
|
||||||
case AOCONTROL_HAS_TEMP_VOLUME:
|
|
||||||
return !ao->no_persistent_volume;
|
|
||||||
case AOCONTROL_HAS_PER_APP_VOLUME:
|
|
||||||
return !!ao->per_application_mixer;
|
|
||||||
default:
|
|
||||||
if (ao->api->control)
|
|
||||||
return ao->api->control(ao, cmd, arg);
|
|
||||||
}
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return size of the buffered data in seconds. Can include the device latency.
|
// Return size of the buffered data in seconds. Can include the device latency.
|
||||||
|
@ -36,7 +36,9 @@ enum aocontrol {
|
|||||||
AOCONTROL_SET_MUTE,
|
AOCONTROL_SET_MUTE,
|
||||||
// Has char* as argument, which contains the desired stream title.
|
// Has char* as argument, which contains the desired stream title.
|
||||||
AOCONTROL_UPDATE_STREAM_TITLE,
|
AOCONTROL_UPDATE_STREAM_TITLE,
|
||||||
AOCONTROL_HAS_TEMP_VOLUME,
|
// the AO does the equivalent of af_volume (return CONTROL_TRUE if yes)
|
||||||
|
AOCONTROL_HAS_SOFT_VOLUME,
|
||||||
|
// like above, but volume persists (per app), mpv won't restore volume
|
||||||
AOCONTROL_HAS_PER_APP_VOLUME,
|
AOCONTROL_HAS_PER_APP_VOLUME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,6 +136,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
return get_volume(ao, arg);
|
return get_volume(ao, arg);
|
||||||
case AOCONTROL_SET_VOLUME:
|
case AOCONTROL_SET_VOLUME:
|
||||||
return set_volume(ao, arg);
|
return set_volume(ao, arg);
|
||||||
|
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
|
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -149,9 +153,6 @@ static int init(struct ao *ao)
|
|||||||
|
|
||||||
if (p->opt_list) ca_print_device_list(ao);
|
if (p->opt_list) ca_print_device_list(ao);
|
||||||
|
|
||||||
ao->per_application_mixer = true;
|
|
||||||
ao->no_persistent_volume = true;
|
|
||||||
|
|
||||||
OSStatus err = ca_select_device(ao, p->opt_device_id, &p->device);
|
OSStatus err = ca_select_device(ao, p->opt_device_id, &p->device);
|
||||||
CHECK_CA_ERROR("failed to select device");
|
CHECK_CA_ERROR("failed to select device");
|
||||||
|
|
||||||
|
@ -351,6 +351,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
IDirectSoundBuffer_SetVolume(p->hdsbuf, volume);
|
IDirectSoundBuffer_SetVolume(p->hdsbuf, volume);
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
}
|
}
|
||||||
|
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -371,7 +373,6 @@ static int init(struct ao *ao)
|
|||||||
if (!InitDirectSound(ao))
|
if (!InitDirectSound(ao))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ao->no_persistent_volume = true;
|
|
||||||
p->audio_volume = 100;
|
p->audio_volume = 100;
|
||||||
|
|
||||||
// ok, now create the buffers
|
// ok, now create the buffers
|
||||||
|
@ -76,6 +76,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
vol->left = vol->right = volume * 100;
|
vol->left = vol->right = volume * 100;
|
||||||
return CONTROL_TRUE;
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
|
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -132,7 +134,6 @@ static int init(struct ao *ao)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ao_data = ao;
|
ao_data = ao;
|
||||||
ao->no_persistent_volume = true;
|
|
||||||
struct mp_chmap_sel sel = {0};
|
struct mp_chmap_sel sel = {0};
|
||||||
for (i = 0; speaker_pos[i].id != -1; i++)
|
for (i = 0; speaker_pos[i].id != -1; i++)
|
||||||
mp_chmap_sel_add_speaker(&sel, speaker_pos[i].id);
|
mp_chmap_sel_add_speaker(&sel, speaker_pos[i].id);
|
||||||
|
@ -178,8 +178,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
struct priv *p = ao->priv;
|
struct priv *p = ao->priv;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case AOCONTROL_GET_VOLUME:
|
case AOCONTROL_GET_VOLUME:
|
||||||
case AOCONTROL_SET_VOLUME:
|
case AOCONTROL_SET_VOLUME: {
|
||||||
{
|
|
||||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||||
int fd, v, devs;
|
int fd, v, devs;
|
||||||
|
|
||||||
@ -210,9 +209,13 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return CONTROL_ERROR;
|
return CONTROL_ERROR;
|
||||||
}
|
}
|
||||||
|
#ifdef SNDCTL_DSP_GETPLAYVOL
|
||||||
|
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,10 +226,6 @@ static int init(struct ao *ao)
|
|||||||
struct priv *p = ao->priv;
|
struct priv *p = ao->priv;
|
||||||
int oss_format;
|
int oss_format;
|
||||||
|
|
||||||
#ifdef SNDCTL_DSP_GETPLAYVOL
|
|
||||||
ao->no_persistent_volume = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *mchan = NULL;
|
const char *mchan = NULL;
|
||||||
if (p->cfg_oss_mixer_channel && p->cfg_oss_mixer_channel[0])
|
if (p->cfg_oss_mixer_channel && p->cfg_oss_mixer_channel[0])
|
||||||
mchan = p->cfg_oss_mixer_channel;
|
mchan = p->cfg_oss_mixer_channel;
|
||||||
|
@ -284,8 +284,6 @@ static int init(struct ao *ao)
|
|||||||
pthread_mutex_init(&priv->wakeup_lock, NULL);
|
pthread_mutex_init(&priv->wakeup_lock, NULL);
|
||||||
pthread_cond_init(&priv->wakeup, NULL);
|
pthread_cond_init(&priv->wakeup, NULL);
|
||||||
|
|
||||||
ao->per_application_mixer = true;
|
|
||||||
|
|
||||||
if (!(priv->mainloop = pa_threaded_mainloop_new())) {
|
if (!(priv->mainloop = pa_threaded_mainloop_new())) {
|
||||||
MP_ERR(ao, "Failed to allocate main loop\n");
|
MP_ERR(ao, "Failed to allocate main loop\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -644,6 +642,9 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
|
|
||||||
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
||||||
char *title = (char *)arg;
|
char *title = (char *)arg;
|
||||||
pa_threaded_mainloop_lock(priv->mainloop);
|
pa_threaded_mainloop_lock(priv->mainloop);
|
||||||
|
@ -60,6 +60,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
return CONTROL_FALSE;
|
return CONTROL_FALSE;
|
||||||
sio_setvol(p->hdl, vol->left * SIO_MAXVOL / 100);
|
sio_setvol(p->hdl, vol->left * SIO_MAXVOL / 100);
|
||||||
break;
|
break;
|
||||||
|
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
default:
|
default:
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -193,7 +195,6 @@ static int init(struct ao *ao)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ao->bps = p->par.bps * p->par.pchan * p->par.rate;
|
ao->bps = p->par.bps * p->par.pchan * p->par.rate;
|
||||||
ao->no_persistent_volume = true;
|
|
||||||
p->havevol = sio_onvol(p->hdl, volcb, p);
|
p->havevol = sio_onvol(p->hdl, volcb, p);
|
||||||
sio_onmove(p->hdl, movecb, p);
|
sio_onmove(p->hdl, movecb, p);
|
||||||
p->delay = 0;
|
p->delay = 0;
|
||||||
|
@ -194,7 +194,6 @@ static int init(struct ao *ao)
|
|||||||
wasapi_enumerate_devices(state->log);
|
wasapi_enumerate_devices(state->log);
|
||||||
}
|
}
|
||||||
|
|
||||||
ao->per_application_mixer = true;
|
|
||||||
if (state->opt_exclusive) {
|
if (state->opt_exclusive) {
|
||||||
state->share_mode = AUDCLNT_SHAREMODE_EXCLUSIVE;
|
state->share_mode = AUDCLNT_SHAREMODE_EXCLUSIVE;
|
||||||
} else {
|
} else {
|
||||||
@ -284,6 +283,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||||||
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
||||||
|
|
||||||
return CONTROL_OK;
|
return CONTROL_OK;
|
||||||
|
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||||
|
return CONTROL_TRUE;
|
||||||
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
||||||
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
|
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
|
||||||
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
|
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
|
||||||
|
@ -41,8 +41,6 @@ struct ao {
|
|||||||
int num_planes;
|
int num_planes;
|
||||||
bool probing; // if true, don't fail loudly on init
|
bool probing; // if true, don't fail loudly on init
|
||||||
bool untimed; // don't assume realtime playback
|
bool untimed; // don't assume realtime playback
|
||||||
bool no_persistent_volume; // the AO does the equivalent of af_volume
|
|
||||||
bool per_application_mixer; // like above, but volume persists (per app)
|
|
||||||
int device_buffer; // device buffer in samples (guessed by
|
int device_buffer; // device buffer in samples (guessed by
|
||||||
// common init code if not set by driver)
|
// common init code if not set by driver)
|
||||||
const struct ao_driver *api; // entrypoints to the wrapper (push.c/pull.c)
|
const struct ao_driver *api; // entrypoints to the wrapper (push.c/pull.c)
|
||||||
|
Loading…
Reference in New Issue
Block a user