aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/pcmi.cpp16
-rw-r--r--bin/pcmi.h6
-rw-r--r--bin/synthpod_alsa.c19
-rw-r--r--bin/synthpod_jack.c4
4 files changed, 43 insertions, 2 deletions
diff --git a/bin/pcmi.cpp b/bin/pcmi.cpp
index 187b9687..ddf6c468 100644
--- a/bin/pcmi.cpp
+++ b/bin/pcmi.cpp
@@ -127,6 +127,14 @@ pcmi_capt_done(pcmi_t *pcmi, uint32_t frsize)
_pcmi->capt_done(frsize);
}
+float
+pcmi_capt_xrun(pcmi_t *pcmi)
+{
+ Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;
+
+ return _pcmi->capt_xrun();
+}
+
void
pcmi_play_init(pcmi_t *pcmi, uint32_t frsize)
{
@@ -158,3 +166,11 @@ pcmi_play_done(pcmi_t *pcmi, uint32_t frsize)
_pcmi->play_done(frsize);
}
+
+float
+pcmi_play_xrun(pcmi_t *pcmi)
+{
+ Alsa_pcmi *_pcmi = (Alsa_pcmi *)pcmi;
+
+ return _pcmi->play_xrun();
+}
diff --git a/bin/pcmi.h b/bin/pcmi.h
index e6bb1801..a330db1f 100644
--- a/bin/pcmi.h
+++ b/bin/pcmi.h
@@ -61,6 +61,9 @@ pcmi_capt_chan(pcmi_t *pcmi, uint32_t channel, float *dst, uint32_t frsize);
void
pcmi_capt_done(pcmi_t *pcmi, uint32_t frsize);
+float
+pcmi_capt_xrun(pcmi_t *pcmi);
+
void
pcmi_play_init(pcmi_t *pcmi, uint32_t frsize);
@@ -73,6 +76,9 @@ pcmi_play_chan(pcmi_t *pcmi, uint32_t channel, const float *src, uint32_t frsize
void
pcmi_play_done(pcmi_t *pcmi, uint32_t frsize);
+float
+pcmi_play_xrun(pcmi_t *pcmi);
+
#ifdef __cplusplus
}
#endif
diff --git a/bin/synthpod_alsa.c b/bin/synthpod_alsa.c
index d8c1cd73..2ef3c569 100644
--- a/bin/synthpod_alsa.c
+++ b/bin/synthpod_alsa.c
@@ -160,11 +160,30 @@ _process(prog_t *handle)
snd_seq_real_time_t ref_time;
snd_seq_queue_status_malloc(&stat);
+ float last_capt_xrun = 0.f;
+ float last_play_xrun = 0.f;
+
pcmi_pcm_start(handle->pcmi);
while(!atomic_load_explicit(&handle->kill, memory_order_relaxed))
{
uint32_t na = pcmi_pcm_wait(pcmi);
+ // detect Xruns
+ const float capt_xrun = pcmi_capt_xrun(pcmi);
+ const float play_xrun = pcmi_play_xrun(pcmi);
+
+ if(capt_xrun != last_capt_xrun)
+ {
+ sp_app_xrun_report(app);
+ last_capt_xrun = capt_xrun;
+ }
+
+ if(play_xrun != last_play_xrun)
+ {
+ sp_app_xrun_report(app);
+ last_play_xrun = play_xrun;
+ }
+
// current time is next time from last cycle
_ntp_clone(&handle->cur_ntp, &handle->nxt_ntp);
diff --git a/bin/synthpod_jack.c b/bin/synthpod_jack.c
index 3d52bca5..7f93a9c5 100644
--- a/bin/synthpod_jack.c
+++ b/bin/synthpod_jack.c
@@ -735,9 +735,9 @@ _xrun(void *data)
{
prog_t *handle = data;
bin_t *bin = &handle->bin;
+ sp_app_t *app = bin->app;
- //TODO do this asynchronously?
- bin_log_warning(bin, "JACK XRun\n");
+ sp_app_xrun_report(app);
return 0;
}