summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-03-25 00:40:12 +0100
committerLennart Poettering <lennart@poettering.net>2009-03-25 00:40:12 +0100
commit171c88f1324acc85a71d13a386f05aa8e38895a6 (patch)
tree8f2b8e6ae999c840c532904117cf9058eda67641
parent892a83945e7cd56039fcbbefc4c16ffdb3a7d722 (diff)
link jack modules's max_request to the jack buffer size
-rw-r--r--src/modules/module-jack-sink.c21
-rw-r--r--src/modules/module-jack-source.c9
2 files changed, 22 insertions, 8 deletions
diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c
index 63fdd2db..31b8a96e 100644
--- a/src/modules/module-jack-sink.c
+++ b/src/modules/module-jack-sink.c
@@ -112,6 +112,7 @@ static const char* const valid_modargs[] = {
enum {
SINK_MESSAGE_RENDER = PA_SINK_MESSAGE_MAX,
+ SINK_MESSAGE_BUFFER_SIZE,
SINK_MESSAGE_ON_SHUTDOWN
};
@@ -158,6 +159,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
return 0;
+ case SINK_MESSAGE_BUFFER_SIZE:
+ pa_sink_set_max_request_within_thread(u->sink, (size_t) offset * pa_frame_size(&u->sink->sample_spec));
+ return 0;
+
case SINK_MESSAGE_ON_SHUTDOWN:
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
return 0;
@@ -184,6 +189,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
return 0;
}
+
}
return pa_sink_process_msg(o, code, data, offset, memchunk);
@@ -263,10 +269,18 @@ static void jack_init(void *arg) {
static void jack_shutdown(void* arg) {
struct userdata *u = arg;
- pa_log_info("JACK thread shutting down..");
+ pa_log_info("JACK thread shutting down.");
pa_asyncmsgq_post(u->jack_msgq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_ON_SHUTDOWN, NULL, 0, NULL, NULL);
}
+static int jack_buffer_size(jack_nframes_t nframes, void *arg) {
+ struct userdata *u = arg;
+
+ pa_log_info("JACK buffer size changed.");
+ pa_asyncmsgq_post(u->jack_msgq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_BUFFER_SIZE, NULL, nframes, NULL, NULL);
+ return 0;
+}
+
int pa__init(pa_module*m) {
struct userdata *u = NULL;
pa_sample_spec ss;
@@ -297,10 +311,9 @@ int pa__init(pa_module*m) {
server_name = pa_modargs_get_value(ma, "server_name", NULL);
client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio JACK Sink");
- u = pa_xnew0(struct userdata, 1);
+ m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->module = m;
- m->userdata = u;
u->saved_frame_time_valid = FALSE;
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
@@ -386,10 +399,12 @@ int pa__init(pa_module*m) {
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
+ pa_sink_set_max_request(u->sink, jack_get_buffer_size(u->client) * pa_frame_size(&u->sink->sample_spec));
jack_set_process_callback(u->client, jack_process, u);
jack_on_shutdown(u->client, jack_shutdown, u);
jack_set_thread_init_callback(u->client, jack_init, u);
+ jack_set_buffer_size_callback(u->client, jack_buffer_size, u);
if (!(u->thread = pa_thread_new(thread_func, u))) {
pa_log("Failed to create thread.");
diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c
index c77c9581..41f09a8a 100644
--- a/src/modules/module-jack-source.c
+++ b/src/modules/module-jack-source.c
@@ -270,12 +270,11 @@ int pa__init(pa_module*m) {
server_name = pa_modargs_get_value(ma, "server_name", NULL);
client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio JACK Source");
- u = pa_xnew0(struct userdata, 1);
+ m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->module = m;
m->userdata = u;
u->saved_frame_time_valid = FALSE;
-
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
@@ -372,14 +371,14 @@ int pa__init(pa_module*m) {
for (i = 0, p = ports; i < ss.channels; i++, p++) {
if (!*p) {
- pa_log("not enough physical output ports, leaving unconnected.");
+ pa_log("Not enough physical output ports, leaving unconnected.");
break;
}
- pa_log_info("connecting %s to %s", jack_port_name(u->port[i]), *p);
+ pa_log_info("Connecting %s to %s", jack_port_name(u->port[i]), *p);
if (jack_connect(u->client, *p, jack_port_name(u->port[i]))) {
- pa_log("failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p);
+ pa_log("Failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p);
break;
}
}