diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-15 08:18:50 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-22 21:53:18 +0200 |
commit | df39121206c8d3d3d87b1bfb3ad7afa850bcecf1 (patch) | |
tree | 2aa8aa18784b1c67897e2521c75ed77fe63c9963 /audio/out/ao_coreaudio.c | |
parent | c11c744998a28d582ec9d6139f2bf6c927000e3a (diff) | |
download | mpv-df39121206c8d3d3d87b1bfb3ad7afa850bcecf1.tar.bz2 mpv-df39121206c8d3d3d87b1bfb3ad7afa850bcecf1.tar.xz |
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).
Diffstat (limited to 'audio/out/ao_coreaudio.c')
-rw-r--r-- | audio/out/ao_coreaudio.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index ee0a042d2a..de858f357c 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -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"); |