Skip to content

Instantly share code, notes, and snippets.

@oneman
Created October 28, 2010 09:04
Show Gist options
  • Select an option

  • Save oneman/650959 to your computer and use it in GitHub Desktop.

Select an option

Save oneman/650959 to your computer and use it in GitHub Desktop.
Patch for xmms2 Dr. No to stabilize Jack Output and prevent xruns on track skipping.
diff --git a/src/include/xmms/xmms_outputplugin.h b/src/include/xmms/xmms_outputplugin.h
index 11016d0..768844d 100644
--- a/src/include/xmms/xmms_outputplugin.h
+++ b/src/include/xmms/xmms_outputplugin.h
@@ -311,6 +311,16 @@ void xmms_output_stream_type_add (xmms_output_t *output, ...);
gint xmms_output_read (xmms_output_t *output, char *buffer, gint len);
/**
+ * determine there is enough data in the ringbuffer to fill out a peroid
+ *
+ * @param output an output object
+ * @param len the number of bytes to read
+ * @return 0 yes, -1 no
+ */
+
+gint output_is_ready_for_period (xmms_output_t *output, gint len);
+
+/**
* Set an error.
*
* When an error occurs in an asynchronous function, the error can be
diff --git a/src/plugins/jack/jack.c b/src/plugins/jack/jack.c
index 926fd54..87aea6d 100644
--- a/src/plugins/jack/jack.c
+++ b/src/plugins/jack/jack.c
@@ -146,6 +146,8 @@ xmms_jack_new (xmms_output_t *output)
jack_get_sample_rate (data->jack));
/* we should connect the ports here? */
+
+ xmms_log_info ("Started Patched xmms2 jack output");
return TRUE;
}
@@ -266,7 +268,12 @@ xmms_jack_process (jack_nframes_t frames, void *arg)
t = MIN (toread * CHANNELS * sizeof (xmms_samplefloat_t),
sizeof (tbuf));
- res = xmms_output_read (output, (gchar *)tbuf, t);
+ if (output_is_ready_for_period(output, t) == 0) {
+ res = xmms_output_read (output, (gchar *)tbuf, t);
+ } else {
+ /* xmms_log_info ("Not Enough Bits in the Ring Buffer, its going to be a silent period..."); */
+ break;
+ }
if (res <= 0) {
XMMS_DBG ("output_read returned %d", res);
diff --git a/src/xmms/output.c b/src/xmms/output.c
index 53c6d6d..18a862c 100644
--- a/src/xmms/output.c
+++ b/src/xmms/output.c
@@ -526,6 +526,18 @@ xmms_output_filler (void *arg)
}
gint
+output_is_ready_for_period(xmms_output_t *output, gint len)
+{
+
+ if (xmms_ringbuf_bytes_used(output->filler_buffer) >= len) {
+ return 0;
+ } else {
+ return -1;
+ }
+
+}
+
+gint
xmms_output_read (xmms_output_t *output, char *buffer, gint len)
{
gint ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment