summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-11-03 17:50:26 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-11-03 17:50:26 +0200
commit8412207d21af9b94c5bc6d36bbf850a80f7856a4 (patch)
treee78d3747ab258fe9c0154770d25a18a25fa489dc
parent8e32205c9b4f81c77d56a357760b021b7f39730e (diff)
check that device has been started
-rw-r--r--src/pcm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pcm.c b/src/pcm.c
index 7b33a1b..56e1cca 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -458,6 +458,11 @@ snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
return 0;
}
+ if (!pcm->started) {
+ WARNX1("playback hasn't been started");
+ return 0;
+ }
+
const struct io io = { .read = cb_buffer_read, .write = cb_sio_write };
struct io_state state = { .pcm = pcm, .ptr = buffer, .end = (unsigned char*)buffer + snd_pcm_frames_to_bytes(pcm, size) };
@@ -499,6 +504,11 @@ snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
return 0;
}
+ if (!pcm->started) {
+ WARNX1("recording hasn't been started");
+ return 0;
+ }
+
const struct io io = { .read = cb_sio_read, .write = cb_buffer_write };
struct io_state state = { .pcm = pcm, .ptr = buffer, .end = (unsigned char*)buffer + snd_pcm_frames_to_bytes(pcm, size) };