aplay: Fix type for signal flag
PATCH 1/2 aplay: Fix type for signal flag
A flag used in signal handlers has to be a special atomic type, volatile sig_atomic_t.
Signed-off-by Takashi Iwai <[email protected]>
--- aplay/aplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
aplay/aplay.c +1 -1
@@ -107,7 +107,7 @@ static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;static int mmap_flag =0 ;static int interleaved =1 ;static int nonblock =0 ; -static int in_aborting =0 ; +static volatile sig_atomic_t in_aborting =0 ;static u_char *audiobuf =NULL ;static snd_pcm_uframes_t chunk_size =0 ;static unsigned period_time =0 ;
Signature · 1 line
2.3.6
PATCH 2/2 aplay: Fix uninterruptible aplay
When aplay is invoked to play from stdin, it can't be terminated by normal signals like SIGTERM or SIGINT. It's because our signal handler tries to trap as much as possible while the stalling point is not in the PCM loop but rather the file I/O.
For fixing this, leave our signal handler once when a signal is received and snd_pcm_abort() is called. At the next hit, it shall be handled normally.
Signed-off-by Takashi Iwai <[email protected]>
--- aplay/aplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
aplay/aplay.c +1 -1
@@ -399,7 +399,7 @@ static void signal_handler(int sig) handle =NULL ;prg_exit (EXIT_FAILURE ); } -signal (sig, signal_handler); +signal (sig,SIG_DFL ); }/* call on SIGUSR1 signal. */
Signature · 1 line
2.3.6