diff --git a/linux/alsa/alsa_driver.c b/linux/alsa/alsa_driver.c index 7b425669..b1d1c7bd 100644 --- a/linux/alsa/alsa_driver.c +++ b/linux/alsa/alsa_driver.c @@ -57,6 +57,12 @@ char* strcasestr(const char* haystack, const char* needle); /* Delay (in process calls) before jackd will report an xrun */ #define XRUN_REPORT_DELAY 0 + +// ============== tracing edit - start ============================================= +static int trace_fd = -1; +static int marker_fd = -1; +// ============== tracing edit - stop ============================================== + void jack_driver_init (jack_driver_t *driver) { @@ -981,6 +987,10 @@ alsa_driver_get_channel_addresses (alsa_driver_t *driver, return 0; } + + + + int alsa_driver_start (alsa_driver_t *driver) { @@ -988,6 +998,30 @@ alsa_driver_start (alsa_driver_t *driver) snd_pcm_uframes_t poffset, pavail; channel_t chn; + // ============== tracing edit - start ============================================= + char *debugfs; + char path[256]; + + strcpy(path, "/sys/kernel/debug"); + strcat(path,"/tracing/tracing_on"); + if (trace_fd == -1) { + trace_fd = open(path, O_WRONLY); + jack_info("Goli: Opened tracing_on file."); + } else { + jack_info("Goli: tracing_on file already open."); + } + + strcpy(path, "/sys/kernel/debug"); + strcat(path, "/tracing/trace_marker"); + if (marker_fd == -1) { + marker_fd = open(path, O_WRONLY); + jack_info("Goli: Opened trace_marker file."); + } else { + jack_info("Goli: trace_marker file already open."); + } + // ============== tracing edit - stop ============================================== + + driver->poll_last = 0; driver->poll_next = 0; @@ -1230,7 +1264,27 @@ alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs) snd_pcm_status_get_trigger_tstamp(status, &tstamp); timersub(&now, &tstamp, &diff); *delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec; - jack_log("**** alsa_pcm: xrun of at least %.3f msecs",*delayed_usecs / 1000.0); + jack_info("**** alsa_pcm: xrun of at least %.3f msecs",*delayed_usecs / 1000.0); + + // ========== tracing edit - start =========================================================== + char buf[256]; + int n; + + if (marker_fd >= 0) { + // Write trace_marker + n = snprintf(buf, 256, "**** alsa_pcm: xrun of at least %.3f msecs\n",*delayed_usecs / 1000.0); + write(marker_fd, buf, n); + jack_info("Goli: Write to trace_marker."); + } + + if (trace_fd >= 0) { + // Stop tracing + write(trace_fd, "0", 1); + jack_info("Goli: Stopped tracing."); + } + + // ========== tracing edit - stop ============================================================ + if (driver->capture_handle) { jack_log("Repreparing capture"); if ((res = snd_pcm_prepare(driver->capture_handle)) < 0) {