MIDI drivers keeping Windows 10 from sleeping?

Feb 2, 2021 6:31 AM

Half an hour after I turned off my computer monitor and laid in bed for the night, I noted the light, continuous humming of my desktop’s fan and the rattling of the hard-drive platters. It obviously didn’t get the memo — it’s time for sleep, not idle spinning. I couldn’t be bothered to leave the warm embrace of bed, but I was curious enough to see what was keeping it awake later that morning.

I opened an administrative command prompt on my Windows 10 machine and typed the following:

powercfg -requests

This command shows processes that might be keeping the computer awake. I had used this earlier in the week to diagnose my computer’s insomnia caused by an open Spotify window, even when paused. It’s a feature, not a bug. 😉

DISPLAY:
None.

SYSTEM:
[DRIVER] Realtek High Definition Audio (HDAUDIOFUNC_01&VEN_10EC&DEV_1220&SUBSYS_1458A182&REV_10005&5e7edb7&0&0001)
An audio stream is currently in use.

AWAYMODE:
None.

EXECUTION:
[PROCESS] DeviceHarddiskVolume4Program FilesWindowsAppsSpotifyAB.SpotifyMusic_1.151.382.0_x86__zpdnekdrzrea0Spotify.exe
Background Audio Playback

PERFBOOST:
None.

ACTIVELOCKSCREEN:
None.

So what could it be this time? I quickly noticed something peculiar:

SYSTEM:
[DRIVER] Realtek High Definition Audio (HDAUDIOFUNC_01&VEN_10EC&DEV_1220&SUBSYS_1458A182&REV_10005&5e7edb7&0&0001)
An audio stream is currently in use.
[DRIVER] CASIO USB MIDI (USBVID_07CF&PID_68027&36e288da&0&2)
An audio stream is currently in use.
[DRIVER] CASIO USB MIDI (USBVID_07CF&PID_68027&36e288da&0&2)
An audio stream is currently in use.
[DRIVER] CASIO USB MIDI (USBVID_07CF&PID_68027&36e288da&0&2)
An audio stream is currently in use.

It turns out it was the keyboard I was recently playing with was showing up as multiple active connections. That couldn’t be right; it was certainly powered off with a single cord plugged into the USB hub. I played around with LMMS and realized that I could reproduce this issue by doing the following:

  • Start LMMS with my keyboard on.
  • Attach the keyboard to an instrument.
  • Turn off the keyboard while it’s being used as a MIDI input.
  • Close LMMS and run powercfg -requests.

I can create an indefinite number of open audio streams by repeating these steps. These active streams will keep my computer awake until I restart it. Is this an issue with LMMS not closing MIDI resources properly? An issue with the the Casio audio drivers not interfacing with Windows properly? Poor design decisions in the Windows Multimedia APIs? I can’t put my finger on the exact issue without more investigation. I filed LMMS/lmms#5900 on the Github repository; maybe I’ll try my hand to see if I can fix the problem for my use case.

For now, I’ll just have to work around the issue and make sure that the keyboard is always on when I work with my recordings.