Skip to content

Any open sdl audio device seem to prevent windows from sleeping #9601

Open
@nico-abram

Description

@nico-abram

Running powercfg /requests on windows while running the sample below prints

SYSTEM:
[DRIVER] Realtek High Definition Audio (HDAUDIO\{REDACTED})
An audio stream is currently in use.

Note: The sample must be ran in a folder containing a sample.wav file such as the ./test/sample.wav in the repo.

This prevents windows from going to sleep. I've tried setting SDL_HINT_VIDEO_ALLOW_SCREENSAVER and pausing via SDL_PauseAudioDevice

I'm not sure if this is intended behaviour or a bug.

#include "SDL.h"

int main() {
    Uint8 *sound;
    Uint32 soundlen;
    SDL_AudioSpec spec;

    SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS);
    SDL_LoadWAV("sample.wav", &spec, &sound, &soundlen);
    
    SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
    SDL_AudioDeviceID device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &spec, NULL, 0);

    SDL_PauseAudioDevice(device, SDL_FALSE);
    SDL_PauseAudioDevice(device, SDL_TRUE);

    while(1) {}
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions