mirror of https://github.com/mpv-player/mpv
ao_coreaudio: revert to original device format on digital uninit
This is not done automatically by CoreAudio. I am told that it would a PITA to have to switch back the format manually on the device (especially if the same device is used for lpcm output).
This commit is contained in:
parent
c11c744998
commit
df39121206
|
@ -70,6 +70,7 @@ struct priv_d {
|
|||
// format we changed the stream to: for the digital case each application
|
||||
// sets the stream format for a device to what it needs
|
||||
AudioStreamBasicDescription stream_asbd;
|
||||
AudioStreamBasicDescription original_asbd;
|
||||
|
||||
bool changed_mixing;
|
||||
int stream_asbd_changed;
|
||||
|
@ -493,6 +494,12 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
|
|||
bool digital = ca_stream_supports_digital(streams[i]);
|
||||
|
||||
if (digital) {
|
||||
err = CA_GET(streams[i], kAudioStreamPropertyPhysicalFormat,
|
||||
&d->original_asbd);
|
||||
if (!CHECK_CA_WARN("could not get stream's physical format to "
|
||||
"revert to, getting the next one"))
|
||||
continue;
|
||||
|
||||
AudioStreamRangedDescription *formats;
|
||||
size_t n_formats;
|
||||
|
||||
|
@ -500,10 +507,8 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
|
|||
kAudioStreamPropertyAvailablePhysicalFormats,
|
||||
&formats, &n_formats);
|
||||
|
||||
if (err != noErr) {
|
||||
ca_msg(MSGL_WARN, "could not get number of stream formats\n");
|
||||
if (!CHECK_CA_WARN("could not get number of stream formats"))
|
||||
continue; // try next one
|
||||
}
|
||||
|
||||
int req_rate_format = -1;
|
||||
int max_rate_format = -1;
|
||||
|
@ -654,6 +659,9 @@ static void uninit(struct ao *ao, bool immed)
|
|||
err = AudioDeviceDestroyIOProcID(p->device, d->render_cb);
|
||||
CHECK_CA_WARN("failed to remove device render callback");
|
||||
|
||||
if (!ca_change_format(d->stream, d->original_asbd))
|
||||
ca_msg(MSGL_WARN, "can't revert to original device format");
|
||||
|
||||
err = ca_enable_mixing(p->device, d->changed_mixing);
|
||||
CHECK_CA_WARN("can't re-enable mixing");
|
||||
|
||||
|
|
Loading…
Reference in New Issue