118
116
if (u->source->thread_info.state == PA_SOURCE_RUNNING)
119
117
pa_source_post(u->source, chunk);
121
u->saved_frame_time = offset;
119
u->saved_frame_time = (jack_nframes_t) offset;
122
120
u->saved_frame_time_valid = TRUE;
279
277
u->saved_frame_time_valid = FALSE;
281
pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
282
279
u->rtpoll = pa_rtpoll_new();
283
pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
280
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
285
282
u->jack_msgq = pa_asyncmsgq_new(0);
286
u->rtpoll_item = pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY-1, u->jack_msgq);
283
u->rtpoll_item = pa_rtpoll_item_new_asyncmsgq_read(u->rtpoll, PA_RTPOLL_EARLY-1, u->jack_msgq);
288
285
if (!(u->client = jack_client_open(client_name, server_name ? JackServerName : JackNullOption, &status, server_name))) {
289
286
pa_log("jack_client_open() failed.");
307
pa_assert_se(pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_AUX));
308
pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_ALSA);
304
pa_channel_map_init_extend(&map, channels, PA_CHANNEL_MAP_ALSA);
309
305
if (pa_modargs_get_channel_map(ma, NULL, &map) < 0 || map.channels != channels) {
310
306
pa_log("failed to parse channel_map= argument.");
314
310
pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client));
316
ss.channels = u->channels = channels;
312
u->channels = ss.channels = (uint8_t) channels;
317
313
ss.rate = jack_get_sample_rate(u->client);
318
314
ss.format = PA_SAMPLE_FLOAT32NE;
329
if (!(u->source = pa_source_new(m->core, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
330
pa_log("failed to create source.");
325
pa_source_new_data_init(&data);
326
data.driver = __FILE__;
328
pa_source_new_data_set_name(&data, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME));
329
pa_source_new_data_set_sample_spec(&data, &ss);
330
pa_source_new_data_set_channel_map(&data, &map);
331
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_API, "jack");
333
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, server_name);
334
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Jack source (%s)", jack_get_client_name(u->client));
335
pa_proplist_sets(data.proplist, "jack.client_name", jack_get_client_name(u->client));
337
u->source = pa_source_new(m->core, &data, PA_SOURCE_LATENCY);
338
pa_source_new_data_done(&data);
341
pa_log("Failed to create source.");
334
345
u->source->parent.process_msg = source_process_msg;
335
346
u->source->userdata = u;
336
u->source->flags = PA_SOURCE_LATENCY;
338
pa_source_set_module(u->source, m);
339
348
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
340
349
pa_source_set_rtpoll(u->source, u->rtpoll);
341
pa_source_set_description(u->source, t = pa_sprintf_malloc("Jack source (%s)", jack_get_client_name(u->client)));
344
351
jack_set_process_callback(u->client, jack_process, u);
345
352
jack_on_shutdown(u->client, jack_shutdown, u);