-9986 internal PortAudio error on mac mini 2014

I have -9986 internal PortAudio error on my mac mini 2014,
after when goto sleep my mac while running Audacity program,
then wakeup it and try to start recording from internal S/PDIF audio input.
(PortAudio V19.6.0-devel, revision unknown)
I can not record anymore until I do re-scan audio device from the Audacity menu.

Problem is that I can not use Timer recording function of Audacity over sleep and wake.
I have mac mini 2014, 2012, 2011, 2010 and this problem occurs only on mac mini 2014,
but not on my older mac minis.

May I have any workaround ?

Audacity 3.0.0 on MacOS 12.6.2, Mac mini 2014 => PortAudio error after sleep-wake
Audacity 3.0.0 on MacOS 10.14.6, Mac mini 2014 => PortAudio error after sleep-wake
Audacity 3.0.0 on MacOS 10.14.6, Mac mini 2012 => OK
Audacity 2.0.0 on MacOS 10.7.5, Mac mini 2011 => OK
Audacity 2.0.0 on MacOS 10.6.8, Mac mini 2010 => OK

Windows user here.

After searching on the web, I see any number of Mac users reporting difficulties with various audio devices working properly after waking up after sleeping. Here is one that might be useful: https://discussions.apple.com/thread/253002396
which suggests:

Go to Apple > System Preferences > Energy Saver
check “Prevent computer from sleeping automatically…” and uncheck the remaining “boxes”
then restart the M1 and test to see if your sounds device return when waking the display from sleep mode.

Thank you for your reply.
I have tried as suggested, but it was not a solution for my problem.

After the computer wakes up, try Transport (menu) > Rescan Audio Devices.
– Bill

Thank you for your reply.
It works, but I can not do this for “Timer recording”, because usually I’m absent at the time of Timer recording.

Then you’ll need to turn off sleep in System Preferences.
– Bill