``` [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4464, channels 2, frames 558. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4456, channels 2, frames 557. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:860: (0x13b2d0000) Audio device changed, 1 events. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:868: Event[0] - mSelector == kAudioHardwarePropertyDefaultOutputDevice for id=1 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3363: (0x13b2d0000) Create output device info failed. This can happen when last media device is unplugged [Child 8864, Unnamed thread 136a3a080] WARNING: 13b25c820 StateCallback() state 1 cubeb error: file /Users/cchang/Work/gecko/dom/media/AudioStream.cpp, line 624 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3445: (0x13b2d0000) Could not reopen the stream after switching. [Child 8864, MediaDecoderStateMachine #1] WARNING: Decoder=136437000 [OnMediaSinkAudioError]: file /Users/cchang/Work/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3639 ``` After invastigating the problem, I found the [`audiounit_get_default_device_id`][audiounit_get_default_device_id] will return `kAudioObjectUnknown` without any error in this case (which means [`AudioObjectGetPropertyData`][AudioObjectGetPropertyData] will return `NoErr`). What `$ cargo test test_reinit_output_stream_by_unplugging_a_default_output_device -- --ignored --nocapture` does is faking pluging a device into the system and then unplugging it. And there are still more than one output devices in my macOS, so getting `kAudioObjectUnknown` from [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is really weird. Since [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is not reliable, we should probably save the used devices and keep using them if they still exist after the device changing, instead of querying the device from [`audiounit_get_default_device_id`][audiounit_get_default_device_id] every time. [audiounit_get_default_device_id]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1201 [AudioObjectGetPropertyData]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1214 (In reply to C.M.Chang[:chunmin] from comment #1) > I haven't checked the log or trace the code yet, but I suspect the cause might be same as bug 1572273. I had a wrong guess. It's not.
Bug 1586379 Comment 2 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
``` [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4464, channels 2, frames 558. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4456, channels 2, frames 557. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:860: (0x13b2d0000) Audio device changed, 1 events. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:868: Event[0] - mSelector == kAudioHardwarePropertyDefaultOutputDevice for id=1 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3363: (0x13b2d0000) Create output device info failed. This can happen when last media device is unplugged [Child 8864, Unnamed thread 136a3a080] WARNING: 13b25c820 StateCallback() state 1 cubeb error: file /Users/cchang/Work/gecko/dom/media/AudioStream.cpp, line 624 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3445: (0x13b2d0000) Could not reopen the stream after switching. [Child 8864, MediaDecoderStateMachine #1] WARNING: Decoder=136437000 [OnMediaSinkAudioError]: file /Users/cchang/Work/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3639 ``` After invastigating the problem, I found the [`audiounit_get_default_device_id`][audiounit_get_default_device_id] will return `kAudioObjectUnknown` without any error in this case (which means [`AudioObjectGetPropertyData`][AudioObjectGetPropertyData] will return `NoErr`). What `$ cargo test test_reinit_output_stream_by_unplugging_a_default_output_device -- --ignored --nocapture` does is faking pluging a device into the system and then unplugging it. And there are still more than one output devices in my macOS, so getting `kAudioObjectUnknown` from [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is really weird. Since [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is not reliable, we should probably use one random device in the available devices. Or we need to find how to refresh the default device in the system, so [`audiounit_get_default_device_id`][audiounit_get_default_device_id] can return something useful. (In reply to C.M.Chang[:chunmin] from comment #1) > I haven't checked the log or trace the code yet, but I suspect the cause might be same as bug 1572273. I had a wrong guess. It's not. [audiounit_get_default_device_id]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1201 [AudioObjectGetPropertyData]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1214
``` [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4464, channels 2, frames 558. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:636: (0x13b2d0000) output: buffers 1, size 4456, channels 2, frames 557. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:860: (0x13b2d0000) Audio device changed, 1 events. [Child 8864: Unnamed thread 0x10fb03710]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:868: Event[0] - mSelector == kAudioHardwarePropertyDefaultOutputDevice for id=1 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3363: (0x13b2d0000) Create output device info failed. This can happen when last media device is unplugged [Child 8864, Unnamed thread 136a3a080] WARNING: 13b25c820 StateCallback() state 1 cubeb error: file /Users/cchang/Work/gecko/dom/media/AudioStream.cpp, line 624 [Child 8864: Unnamed thread 0x136a3a080]: E/cubeb media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs:3445: (0x13b2d0000) Could not reopen the stream after switching. [Child 8864, MediaDecoderStateMachine #1] WARNING: Decoder=136437000 [OnMediaSinkAudioError]: file /Users/cchang/Work/gecko/dom/media/MediaDecoderStateMachine.cpp, line 3639 ``` After invastigating the problem, I found the [`audiounit_get_default_device_id`][audiounit_get_default_device_id] will return `kAudioObjectUnknown` without any error in this case (which means [`AudioObjectGetPropertyData`][AudioObjectGetPropertyData] will return `NoErr`). What `$ cargo test test_reinit_output_stream_by_unplugging_a_default_output_device -- --ignored --nocapture` does is faking pluging an output device into the system, set it to the default output device, and then unplugging it. During my test, there are still 4 output devices in my macOS, so getting `kAudioObjectUnknown` from [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is really weird. Since [`audiounit_get_default_device_id`][audiounit_get_default_device_id] is not reliable, we should probably use one random device in the available devices. Or we need to find how to refresh the default device in the system, so [`audiounit_get_default_device_id`][audiounit_get_default_device_id] can return something useful. (In reply to C.M.Chang[:chunmin] from comment #1) > I haven't checked the log or trace the code yet, but I suspect the cause might be same as bug 1572273. I had a wrong guess. It's not. [audiounit_get_default_device_id]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1201 [AudioObjectGetPropertyData]: https://searchfox.org/mozilla-central/rev/7cc0f0e89cb40e43bf5c96906f13d44705401042/media/libcubeb/src/cubeb_audiounit.cpp#1214