Skip to content

Commit

Permalink
plugout_alsa: only use pause support when hardware supports it
Browse files Browse the repository at this point in the history
Don't try to pause the ALSA sound device if the device does not
support the pause operation.

Also report errors on pause/resume.
  • Loading branch information
mmitch committed Apr 30, 2024
1 parent 069bf2a commit e41223a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugout_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/* Handle for the PCM device */
snd_pcm_t *pcm_handle;

bool can_pause;

#if GBS_BYTE_ORDER == GBS_ORDER_LITTLE_ENDIAN
#define SND_PCM_FORMAT_S16_NE SND_PCM_FORMAT_S16_LE
#else
Expand Down Expand Up @@ -98,12 +100,16 @@ static long alsa_open(enum plugout_endian *endian, long rate, long *buffer_bytes

*buffer_bytes = buffer_frames * 4;

can_pause = snd_pcm_hw_params_can_pause(hwparams);

return 0;
}

static void alsa_pause(int pause)
{
snd_pcm_pause(pcm_handle, pause);
int err;
if (can_pause && (err = snd_pcm_pause(pcm_handle, pause)))
fprintf(stderr, _("snd_pcm_pause failed: %s\n"), snd_strerror(err));
}

static long is_suspended(snd_pcm_sframes_t retval)
Expand Down

0 comments on commit e41223a

Please sign in to comment.