mirror of
https://codeberg.org/noisytoot/notnotdnethack.git
synced 2025-04-06 08:30:41 +01:00
Fix playing sounds sometimes interfering with prompts
The signal handler was interrupting read(). Register it with SA_RESTART so it doesn't interrupt syscalls. Also close stdin/stdout just in case (portaudio only uses stderr).
This commit is contained in:
parent
11ca7cd6e2
commit
a1db2bb9b8
1 changed files with 4 additions and 2 deletions
|
@ -130,7 +130,7 @@ play_usersound(const char *filename, int volume)
|
|||
kill(nowplayingpid, SIGTERM);
|
||||
/* Register signal handler */
|
||||
struct sigaction handler = {
|
||||
.sa_flags = SA_SIGINFO,
|
||||
.sa_flags = SA_SIGINFO|SA_RESTART,
|
||||
.sa_sigaction = usersound_sigchld_handler
|
||||
};
|
||||
sigaction(SIGCHLD, &handler, &orig_handler);
|
||||
|
@ -147,7 +147,9 @@ play_usersound(const char *filename, int volume)
|
|||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
/* portaudio prints junk to stderr, close it so it doesn't mess up the display */
|
||||
/* Close stdin/stdout/stderr so it doesn't mess up the display */
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
fclose(stderr);
|
||||
/* Finally, play sound and exit */
|
||||
play_usersound_blocking(filename, volume);
|
||||
|
|
Loading…
Add table
Reference in a new issue