diff mbox series

[2/2] pq_alsa.c: print error message if device init fails

Message ID 20170902143403.14185-2-axilirator@gmail.com
State New
Headers show
Series [1/2] pq_alsa.c: handle output buffer underrun | expand

Commit Message

Vadim Yanitskiy Sept. 2, 2017, 2:34 p.m. UTC
---
 src/pq_alsa.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/pq_alsa.c b/src/pq_alsa.c
index a3435dd..cad76ca 100644
--- a/src/pq_alsa.c
+++ b/src/pq_alsa.c
@@ -85,13 +85,16 @@  pq_queue_alsa_op(struct pq *pq, const char *alsa_dev, unsigned int blk_len, int
 	int rc = -1;
 
 	state = calloc(1, sizeof(struct pq_state_alsa));
-	if (!state)
-		return -ENOMEM;
+	if (!state) {
+		rc = -ENOMEM;
+		goto out_print;
+	}
 
 	rc = snd_pcm_open(&state->pcm_handle, alsa_dev,
 			  in_out_n ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, 0);
 	if (rc < 0)
-		return rc;
+		goto out_print;
+
 	state->blk_len = blk_len;
 
 	rc = snd_pcm_hw_params_malloc(&hw_params);
@@ -143,6 +146,9 @@  out_free_par:
 out_close:
 	snd_pcm_close(state->pcm_handle);
 	free(state);
+out_print:
+	fprintf(stderr, "[!] Couldn't init ALSA device '%s': %s\n",
+		alsa_dev, snd_strerror(rc));
 	return rc;
 }