Browse Source

add a latency callback to the ALSA backend, and ensure that the backend's latency callback, if it exists, is called after a buffer size change

tags/0.124.0
Paul Davis 12 years ago
parent
commit
6ddbf81d14
5 changed files with 43 additions and 9 deletions
  1. +31
    -1
      drivers/alsa/alsa_driver.c
  2. +1
    -1
      jack
  3. +5
    -2
      jackd/engine.c
  4. +5
    -4
      libjack/client.c
  5. +1
    -1
      tools

+ 31
- 1
drivers/alsa/alsa_driver.c View File

@@ -33,6 +33,7 @@
#include "internal.h"
#include "engine.h"
#include "messagebuffer.h"
#include "libjack/local.h"

#include <sysdeps/time.h>

@@ -1721,6 +1722,33 @@ alsa_driver_run_cycle (alsa_driver_t *driver)
return engine->run_cycle (engine, nframes, delayed_usecs);
}

static void
alsa_driver_latency_callback (jack_latency_callback_mode_t mode, void* arg)
{
alsa_driver_t* driver = (alsa_driver_t*) arg;
jack_client_t* client = driver->client;
jack_latency_range_t range;
JSList* node;

if (mode == JackPlaybackLatency) {
range.min = range.max = driver->frames_per_cycle + driver->playback_frame_latency;
} else {
range.min = range.max = driver->frames_per_cycle + driver->capture_frame_latency;
}

for (node = client->ports; node; node = jack_slist_next (node)) {
jack_port_t *port = node->data;

if ((jack_port_flags (port) & JackPortIsOutput) && (mode == JackPlaybackLatency)) {
jack_port_set_latency_range (port, JackPlaybackLatency, &range);
}

if ((jack_port_flags (port) & JackPortIsInput) && (mode == JackCaptureLatency)) {
jack_port_set_latency_range (port, JackCaptureLatency, &range);
}
}
}

static int
alsa_driver_attach (alsa_driver_t *driver)
{
@@ -2367,7 +2395,9 @@ alsa_driver_new (char *name, char *playback_alsa_device,
driver->capture_and_playback_not_synced = TRUE;
}
}

jack_set_latency_callback (client, alsa_driver_latency_callback, driver);
driver->client = client;

return (jack_driver_t *) driver;


+ 1
- 1
jack

@@ -1 +1 @@
Subproject commit 66b41b24b448053a73aebc383745b0f4549eb5bd
Subproject commit 433a4ab01fa84ff04e7753e80f5bfce04ad38810

+ 5
- 2
jackd/engine.c View File

@@ -1385,7 +1385,10 @@ do_request (jack_engine_t *engine, jack_request_t *req, int *reply_fd)

case SetBufferSize:
req->status = jack_set_buffer_size_request (engine,
req->x.nframes);
req->x.nframes);
jack_lock_graph (engine);
jack_compute_new_latency (engine);
jack_unlock_graph (engine);
break;

case IntClientHandle:
@@ -2959,7 +2962,7 @@ jack_deliver_event (jack_engine_t *engine, jack_client_internal_t *client,

/* caller must hold the graph lock */

DEBUG ("delivering event (type %d)", event->type);
DEBUG ("delivering event (type %s)", jack_event_type_name (event->type));

/* we are not RT-constrained here, so use kill(2) to beef up
our check on a client's continued well-being


+ 5
- 4
libjack/client.c View File

@@ -589,13 +589,14 @@ jack_client_handle_latency_callback (jack_client_t *client, jack_event_t *event,
}
}

/* for a driver invocation, this is enough.
/* for a driver invocation without its own latency callback, this is enough.
* input and output ports do not depend on each other.
*/
if (is_driver)
if (is_driver && !client->control->latency_cbset) {
return 0;
if (! client->control->latency_cbset) {
}

if (!client->control->latency_cbset) {
/*
* default action is to assume all ports depend on each other.
* then always take the maximum latency.


+ 1
- 1
tools

@@ -1 +1 @@
Subproject commit c6b4b572f543ce25588eec4d471905dffe52d196
Subproject commit 840bbbf8cfe33a59a5b1b4a33e72f2aa6221d0b7

Loading…
Cancel
Save