54#define MOD_NAME "[JACK playback] "
90 "Runtime change is not supported in UG and will likely "
91 "cause malfunctioning. ",
107 int req_len = s->
desc.
ch_count * nframes *
sizeof(float);
108 int nframes_available = nframes;
111 if (
len != req_len) {
117 jack_default_audio_sample_t *out =
137 if(!available_devices)
141 printf(
"\t-r jack[:first_channel=<f>][:name=<n>][:<device>]\n");
143 printf(
"\t\t<f> - index of first channel to capture (default: 0)\n");
144 printf(
"\t\t<n> - name of the JACK client (default: %s)\n", PACKAGE_NAME);
147 printf(
"Available devices:\n");
148 for(i = 0; i <
count; i++){
149 printf(
"\t%s\n", available_devices[i].
name);
151 free(available_devices);
160 const char *source_name =
"";
162 client_name = alloca(
MAX(strlen(PACKAGE_NAME), strlen(cfg)) + 1);
163 strcpy(client_name, PACKAGE_NAME);
177 char *dup = strdup(cfg);
179 char *
tmp = dup, *
item, *save_ptr;
180 while ((
item = strtok_r(
tmp,
":", &save_ptr)) != NULL) {
181 if (strcmp(
item,
"help") == 0) {
186 }
else if (strstr(
item,
"first_channel=") ==
item) {
188 char *
val =
item + strlen(
"first_channel=");
191 if (errno == ERANGE || *endptr !=
'\0' || s->
first_channel < 0) {
195 }
else if (strstr(
item,
"name=") ==
item) {
196 strcpy(client_name,
item + strlen(
"name="));
198 source_name = cfg + (
item - dup);
209 if(
status & JackFailure) {
244 snprintf(
name, 30,
"playback_%02u", i);
327 assert(buf_len_ms > 0 && buf_len_ms <
MAX_LEN_MS);
330 int buf_len =
desc.bps *
desc.ch_count * (
desc.sample_rate * buf_len_ms / 1000);
340 for(i = 0; i <
desc.ch_count; ++i) {
359 for(i = 0; i <
desc.ch_count; ++i) {
373 assert(
frame->bps == 4);
struct video_frame * frame
int void(** deleter)(void *))
This file contains definition of some common audio types.
struct audio_buffer_api audio_buffer_fns
struct audio_buffer * audio_buffer_init(int sample_rate, int bps, int ch_count, int suggested_latency_ms)
#define AUDIO_PLAYBACK_CTL_QUERY_FORMAT
#define AUDIO_PLAYBACK_ABI_VERSION
static int jack_process_callback(jack_nframes_t nframes, void *arg)
static int jack_samplerate_changed_callback(jack_nframes_t nframes, void *arg)
void log_msg(int level, const char *format,...)
void bug_msg(int level, const char *format,...)
prints the error with the advice to report the bug
#define LOG_LEVEL_NOTICE
information that may be interesting
#define LOG_LEVEL_INFO
normal reporting
#define LOG_LEVEL_ERROR
general errors
#define LOG_LEVEL_WARNING
less severe errors
const char * get_commandline_param(const char *key)
static struct device_info * audio_jack_probe(const char *client_name, unsigned long port_flags, int *count)
static void close_libjack(struct libjack_connection *s)
static struct libjack_connection * open_libjack(void)
@ LIBRARY_CLASS_AUDIO_PLAYBACK
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
static bool audio_play_jack_ctl(void *state, int request, void *data, size_t *len)
static void audio_play_jack_done(void *state)
static void audio_play_jack_probe(struct device_info **available_devices, int *count, void(**deleter)(void *))
static void audio_play_jack_help(const char *client_name)
static const struct audio_playback_info aplay_jack_info
static bool audio_play_jack_reconfigure(void *state, struct audio_desc desc)
static void * audio_play_jack_init(const char *cfg)
static void audio_play_jack_put_frame(void *state, const struct audio_frame *frame)
@ DEFAULT_AUDIO_BUF_LEN_MS
static bool audio_play_jack_query_format(struct state_jack_playback *s, void *data, size_t *len)
struct audio_buffer_api ring_buffer_fns
struct ring_buffer * ring_buffer_init(int size)
int(* read)(void *buf, char *out, int max_len)
void(* write)(void *buf, const char *in, int len)
void(* destroy)(void *buf)
struct used to comunicate with audio capture/playback device
jack_client_close_t client_close
jack_port_register_t port_register
jack_set_sample_rate_callback_t set_sample_rate_callback
jack_get_sample_rate_t get_sample_rate
jack_client_open_t client_open
jack_port_name_t port_name
jack_deactivate_t deactivate
jack_port_get_buffer_t port_get_buffer
jack_get_ports_t get_ports
jack_disconnect_t disconnect
jack_set_process_callback_t set_process_callback
jack_port_t * output_port[MAX_PORTS]
struct audio_buffer_api * buffer_fns
struct libjack_connection * libjack
int max_channel_len
maximal length of channel data that is processed at once
char * tmp
temporary buffer used to demux data
float * converted
temporery buffer for int2float (put_frame)
char * jack_ports_pattern
void demux_channel(char *out, char *in, int bps, int in_len, int in_stream_channels, int pos_in_stream)
void int2float(char *out, const char *in, int len)