mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 08:46:32 +01:00
aplay: Fix to handle pause when system is suspended/Resumed
If PCM is paused and then we do system supend-resume, the stream throws error(EBADF) when stream is paused released. Check the pcm state before pause/release and if stream is suspended, call snd_pcm_resume to resume the stream. Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Jeeja KP <jeeja.kp@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e61f35ba4d
commit
d24a60b781
1 changed files with 7 additions and 0 deletions
|
@ -166,6 +166,8 @@ static void end_wave(int fd);
|
||||||
static void begin_au(int fd, size_t count);
|
static void begin_au(int fd, size_t count);
|
||||||
static void end_au(int fd);
|
static void end_au(int fd);
|
||||||
|
|
||||||
|
static void suspend(void);
|
||||||
|
|
||||||
static const struct fmt_capture {
|
static const struct fmt_capture {
|
||||||
void (*start) (int fd, size_t count);
|
void (*start) (int fd, size_t count);
|
||||||
void (*end) (int fd);
|
void (*end) (int fd);
|
||||||
|
@ -1487,6 +1489,9 @@ static void do_pause(void)
|
||||||
fprintf(stderr, _("\rPAUSE command ignored (no hw support)\n"));
|
fprintf(stderr, _("\rPAUSE command ignored (no hw support)\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
|
||||||
|
suspend();
|
||||||
|
|
||||||
err = snd_pcm_pause(handle, 1);
|
err = snd_pcm_pause(handle, 1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
error(_("pause push error: %s"), snd_strerror(err));
|
error(_("pause push error: %s"), snd_strerror(err));
|
||||||
|
@ -1496,6 +1501,8 @@ static void do_pause(void)
|
||||||
while (read(fileno(stdin), &b, 1) != 1);
|
while (read(fileno(stdin), &b, 1) != 1);
|
||||||
if (b == ' ' || b == '\r') {
|
if (b == ' ' || b == '\r') {
|
||||||
while (read(fileno(stdin), &b, 1) == 1);
|
while (read(fileno(stdin), &b, 1) == 1);
|
||||||
|
if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
|
||||||
|
suspend();
|
||||||
err = snd_pcm_pause(handle, 0);
|
err = snd_pcm_pause(handle, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
error(_("pause release error: %s"), snd_strerror(err));
|
error(_("pause release error: %s"), snd_strerror(err));
|
||||||
|
|
Loading…
Reference in a new issue