void setup_port_out (int sources, char *source_name, jack_thread_info_t *info) { size_t in_size; portout = (jack_port_t *) malloc (sizeof (jack_port_t *)); in_size = sizeof (jack_default_audio_sample_t *); out = (jack_default_audio_sample_t *) malloc (in_size); memset(out, 0, in_size); char name[64]; sprintf (name, "output%d", 1); if ((portout = jack_port_register (info->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == 0) { fprintf (stderr, "cannot register output port \"%s\"!\n", name); jack_client_close (info->client); exit (1); } if (jack_connect (info->client, jack_port_name( portout ), source_name )) { fprintf (stderr, "cannot connect output port %s to %s\n", jack_port_name( portout ), source_name ); jack_client_close (info->client); exit (1); } info->ready = 1; }
int main (int argc, char *argv[]) { jack_client_t *client; char *my_name = strrchr(argv[0], '/'); if (my_name == 0) { my_name = argv[0]; } else { my_name ++; } if (argc != 2) { fprintf (stderr, "Usage: %s client\n", my_name); return 1; } if ((client = jack_client_open ("input monitoring", JackNullOption, NULL)) == 0) { fprintf (stderr, "JACK server not running?\n"); return 1; } if (jack_port_request_monitor_by_name (client, argv[1], TRUE)) { fprintf (stderr, "could not enable monitoring for %s\n", argv[1]); jack_client_close (client); return 1; } sleep (30); if (jack_port_request_monitor_by_name (client, argv[1], FALSE)) { fprintf (stderr, "could not disable monitoring for %s\n", argv[1]); } jack_client_close (client); exit (0); }
static int start_jack(AVFormatContext *context, AVFormatParameters *params) { JackData *self = context->priv_data; jack_status_t status; int i, test; double o, period; /* Register as a JACK client, using the context filename as client name. */ self->client = jack_client_open(context->filename, JackNullOption, &status); if (!self->client) { av_log(context, AV_LOG_ERROR, "Unable to register as a JACK client\n"); return AVERROR(EIO); } sem_init(&self->packet_count, 0, 0); self->sample_rate = jack_get_sample_rate(self->client); self->nports = params->channels; self->ports = av_malloc(self->nports * sizeof(*self->ports)); self->buffer_size = jack_get_buffer_size(self->client); /* Register JACK ports */ for (i = 0; i < self->nports; i++) { char str[16]; snprintf(str, sizeof(str), "input_%d", i + 1); self->ports[i] = jack_port_register(self->client, str, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); if (!self->ports[i]) { av_log(context, AV_LOG_ERROR, "Unable to register port %s:%s\n", context->filename, str); jack_client_close(self->client); return AVERROR(EIO); } } /* Register JACK callbacks */ jack_set_process_callback(self->client, process_callback, self); jack_on_shutdown(self->client, shutdown_callback, self); jack_set_xrun_callback(self->client, xrun_callback, self); /* Create time filter */ period = (double) self->buffer_size / self->sample_rate; o = 2 * M_PI * 1.5 * period; /// bandwidth: 1.5Hz self->timefilter = ff_timefilter_new (1.0 / self->sample_rate, sqrt(2 * o), o * o); /* Create FIFO buffers */ self->filled_pkts = av_fifo_alloc(FIFO_PACKETS_NUM * sizeof(AVPacket)); /* New packets FIFO with one extra packet for safety against underruns */ self->new_pkts = av_fifo_alloc((FIFO_PACKETS_NUM + 1) * sizeof(AVPacket)); if ((test = supply_new_packets(self, context))) { jack_client_close(self->client); return test; } return 0; }
aubio_jack_t * new_aubio_jack(uint_t ichan, uint_t ochan, aubio_process_func_t callback) { aubio_jack_t * jack_setup = aubio_jack_alloc (ichan, ochan); uint_t i; char * client_name = "aubio"; char name[64]; /* initial jack client setup */ if ((jack_setup->client = jack_client_new (client_name)) == 0) { AUBIO_ERR ("jack server not running?\n"); AUBIO_QUIT(AUBIO_FAIL); } /* set callbacks */ jack_set_process_callback (jack_setup->client, aubio_jack_process, (void*) jack_setup); jack_on_shutdown (jack_setup->client, aubio_jack_shutdown, (void*) jack_setup); /* register jack output ports */ for (i = 0; i < ochan; i++) { AUBIO_SPRINTF(name, "out_%d", i+1); AUBIO_MSG("%s\n", name); if ((jack_setup->oports[i] = jack_port_register (jack_setup->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == 0) { AUBIO_ERR("failed registering output port \"%s\"!\n", name); jack_client_close (jack_setup->client); AUBIO_QUIT(AUBIO_FAIL); } } /* register jack input ports */ for (i = 0; i < ichan; i++) { AUBIO_SPRINTF(name, "in_%d", i+1); AUBIO_MSG("%s\n", name); if ((jack_setup->iports[i] = jack_port_register (jack_setup->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)) == 0) { AUBIO_ERR("failed registering input port \"%s\"!\n", name); jack_client_close (jack_setup->client); AUBIO_QUIT(AUBIO_FAIL); } } /* set processing callback */ jack_setup->callback = callback; return jack_setup; }
int listDevices(CSOUND *csound, CS_AUDIODEVICE *list, int isOutput){ char **portNames = (char**) NULL, port[64]; unsigned long portFlags; int i, n, cnt=0; jack_client_t *jackClient; RtJackGlobals* p = (RtJackGlobals*) csound->QueryGlobalVariableNoCheck(csound, "_rtjackGlobals"); if(p->listclient == NULL) p->listclient = jack_client_open("list", JackNoStartServer, NULL); jackClient = p->listclient; if(jackClient == NULL) return 0; portFlags = (isOutput ? (unsigned long) JackPortIsInput : (unsigned long) JackPortIsOutput); portNames = (char**) jack_get_ports(jackClient, (char*) NULL, JACK_DEFAULT_AUDIO_TYPE, portFlags); if(portNames == NULL) { jack_client_close(jackClient); p->listclient = NULL; return 0; } memset(port, '\0', 64); for(i=0; portNames[i] != NULL; i++) { n = (int) strlen(portNames[i]); do { n--; } while (n > 0 && isdigit(portNames[i][n])); n++; if(strncmp(portNames[i], port, n)==0) continue; strncpy(port, portNames[i], n); port[n] = '\0'; if (list != NULL) { strncpy(list[cnt].device_name, port, 63); snprintf(list[cnt].device_id, 63, "%s%s", isOutput ? "dac:" : "adc:",port); list[cnt].max_nchnls = -1; list[cnt].isOutput = isOutput; } cnt++; } jack_client_close(jackClient); p->listclient = NULL; return cnt; }
void Jasmine::Impl::cleanup() { jack_deactivate(m_client); ports_destroy(m_ports_out); ports_destroy(m_ports_in); jack_client_close(m_client); }
static void ja_free(void *data) { int i; jack_t *jd = (jack_t*)data; jd->shutdown = true; if (jd->client != NULL) { jack_deactivate(jd->client); jack_client_close(jd->client); } for (i = 0; i < 2; i++) if (jd->buffer[i] != NULL) jack_ringbuffer_free(jd->buffer[i]); #ifdef HAVE_THREADS if (jd->cond_lock) slock_free(jd->cond_lock); if (jd->cond) scond_free(jd->cond); #endif free(jd); }
//================================================================ void osc_error_handler(int num, const char *msg, const char *path) { if(close_on_incomp==1 && shutdown_in_progress==0) { fprintf(stderr,"/!\\ liblo server error %d: %s %s\n", num, path, msg); fprintf(stderr,"telling sender to pause.\n"); //lo_address loa=lo_address_new(sender_host,sender_port); lo_address loa=lo_address_new_with_proto(lo_proto, sender_host,sender_port); lo_message msg=lo_message_new(); lo_send_message(loa, "/pause", msg); lo_message_free(msg); io_quit("incompatible_jack_settings"); fprintf(stderr,"cleaning up..."); jack_client_close(client); //lo_server_thread_free(lo_st); jack_ringbuffer_free(rb); jack_ringbuffer_free(rb_helper); fprintf(stderr," done.\n"); exit(1); } else if(shutdown_in_progress==0) { fprintf(stderr,"\r/!\\ liblo server error %d: %s %s\n", num, path, msg); //should be a param } }//end osc_error_handler
void process_info_destroy (process_info_t * procinfo) { jack_deactivate (procinfo->jack_client); jack_client_close (procinfo->jack_client); g_free (procinfo); }
JackAudioSystem::~JackAudioSystem() { QMutexLocker lock(&qmWait); if (client) { int err = 0; err = jack_deactivate(client); if (err != 0) { qWarning("JackAudioSystem: unable to remove client from the process graph - jack_deactivate() returned %i", err); } bActive = false; err = jack_client_close(client); if (err != 0) { qWarning("JackAudioSystem: unable to disconnect from the server - jack_client_close() returned %i", err); } delete [] output_buffer; output_buffer = NULL; client = NULL; } bJackIsGood = false; }
void JackCpp::AudioIO::close() throw(std::runtime_error) { if (jack_client_close(mJackClient) != 0) throw std::runtime_error("cannot close the client"); mJackState = closed; }
static void ja_terminate(void *arg) { (void) arg; if (ja_status != JA_STOPPED) { int i; ja_status = JA_STOPPED; if (client != NULL) { jack_deactivate(client); jack_client_close(client); client = NULL; } ja_free(ja_inputs); ja_free(ja_outputs); ja_free(input_ports); ja_free(output_ports); for (i = 0; i < ja_in_channels; i++) free(input_port_names[i]); ja_free(input_port_names); for (i = 0; i < ja_out_channels; i++) free(output_port_names[i]); ja_free(output_port_names); } }
/*------------------------------------------------------------------------------ * Close the audio source *----------------------------------------------------------------------------*/ void JackDspSource :: close ( void ) throw ( Exception ) { unsigned int i; if ( !isOpen() ) { return; } for(i = 0; i < getChannel(); i++) { // Close the port for channel if ( ports[i] ) { jack_port_unregister( client, ports[i] ); ports[i] = NULL; } // Free up the ring buffer for channel if ( rb[i] ) { jack_ringbuffer_free( rb[i] ); rb[i] = NULL; } } /* Leave the jack graph */ if (client) { jack_client_close(client); client = NULL; } }
void cleanup() { if (j_client) { jack_deactivate(j_client); jack_client_close (j_client); } j_client=NULL; }
void process_cleanup(J2STL *j2stl) { int ret; void *res; /* Threads termination */ if (j2stl->status.verbose) fprintf(stderr, "Threads termination\n"); ret = pthread_cancel(j2stl->status.fftw_thread); if (ret) { fprintf(stderr, "Unable to cancel fftw_thead: %s\n", strerror(ret)); exit(EXIT_FAILURE); } ret = pthread_join(j2stl->status.fftw_thread, &res); if (ret) { fprintf(stderr, "Unable to join fftw thread: %s\n", strerror(ret)); exit(EXIT_FAILURE); } if (res != PTHREAD_CANCELED) { fprintf(stderr, "fftw thread cancel() failed\n"); exit(EXIT_FAILURE); } jack_client_close(j2stl->jack.client); /* Free memory & library close() */ if (j2stl->status.verbose) fprintf(stderr, "Memory cleanup\n"); free(j2stl->audio.data); pthread_cond_destroy(&j2stl->memsync.cond); pthread_mutex_destroy(&j2stl->memsync.mutex); stlseries_close(); }
const char * Client::name ( const char *s ) { /* Because the JACK API does not provide a mechanism for renaming * clients, we have to save connections, destroy our client, * create a client with the new name, and restore our * connections. Lovely. */ freeze_ports(); jack_deactivate( _client ); jack_client_close( _client ); _client = NULL; _frozen.lock(); s = init( s ); thaw_ports(); _frozen.unlock(); return s; }
~PluginJack() { if (fClient == nullptr) return; jack_deactivate(fClient); #if DISTRHO_PLUGIN_IS_SYNTH jack_port_unregister(fClient, fPortMidiIn); fPortMidiIn = nullptr; #endif #if DISTRHO_PLUGIN_NUM_INPUTS > 0 for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i) { jack_port_unregister(fClient, fPortAudioIns[i]); fPortAudioIns[i] = nullptr; } #endif #if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 for (uint32_t i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) { jack_port_unregister(fClient, fPortAudioOuts[i]); fPortAudioOuts[i] = nullptr; } #endif jack_client_close(fClient); }
void ezjack_close(ezjack_bundle_t *bun) { int i; jack_deactivate(bun->client); for(i = 0; i < bun->portstack.incount; i++) { jack_ringbuffer_free(bun->portstack.inrb[i]); free(bun->portstack.inbuf[i]); } for(i = 0; i < bun->portstack.outcount; i++) { jack_ringbuffer_free(bun->portstack.outrb[i]); free(bun->portstack.outbuf[i]); } if(bun->fbuf != NULL) free(bun->fbuf); jack_client_close(bun->client); free(bun); }
void shutdown_all(int sig) { fprintf(stdout,"Leaving...\n"); if (0 != talker) { send_process('L'); /** send leave */ } send_process('M'); /** mrp disconnect */ close(control_socket); if (NULL != handle) { pcap_breakloop(handle); pcap_close(handle); } #ifdef LIBSND if (NULL != snd_file) { sf_write_sync(snd_file); sf_close(snd_file); } #endif if (NULL != client) { fprintf(stdout, "jack\n"); jack_client_close(client); jack_ringbuffer_free(ringbuffer); } exit(0); }
void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); if (!(u = m->userdata)) return; if (u->client) jack_client_close(u->client); if (u->sink) pa_sink_unlink(u->sink); if (u->thread) { pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL); pa_thread_free(u->thread); } pa_thread_mq_done(&u->thread_mq); if (u->sink) pa_sink_unref(u->sink); if (u->rtpoll_item) pa_rtpoll_item_free(u->rtpoll_item); if (u->jack_msgq) pa_asyncmsgq_unref(u->jack_msgq); if (u->rtpoll) pa_rtpoll_free(u->rtpoll); pa_xfree(u); }
int main (int argc, char *argv[]) { jack_client_t *client; char jack_client_name[] = "scope"; jack_status_t jack_status; jack_options_t jack_options = JackNullOption; if ((client = jack_client_open(jack_client_name, jack_options, &jack_status)) == 0) { fprintf (stderr, "jack server not running?\n"); return 1; } jack_set_process_callback (client, process, 0); jack_set_buffer_size_callback (client, bufsize, 0); jack_set_sample_rate_callback (client, srate, 0); jack_on_shutdown (client, jack_shutdown, 0); in_l = jack_port_register (client, "in_l", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); in_r = jack_port_register (client, "in_r", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); out_x = jack_port_register (client, "out_x", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); out_y = jack_port_register (client, "out_y", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); out_w = jack_port_register (client, "out_w", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); if (jack_activate (client)) { fprintf (stderr, "cannot activate client"); return 1; } while (1) sleep(1); jack_client_close (client); exit (0); }
static CS_NOINLINE void rtclose_(CSOUND *csound) { RtJackGlobals p; RtJackGlobals *pp; int i; pp = (RtJackGlobals*) csound->QueryGlobalVariable(csound, "_rtjackGlobals"); if (pp == NULL) return; *(csound->GetRtPlayUserData(csound)) = NULL; *(csound->GetRtRecordUserData(csound)) = NULL; memcpy(&p, pp, sizeof(RtJackGlobals)); /* free globals */ if (p.client != (jack_client_t*) NULL) { /* deactivate client */ //if (p.jackState != 2) { //if (p.jackState == 0) // csound->Sleep((size_t) // ((int) ((double) (p.bufSize * p.nBuffers) // * 1000.0 / (double) p.sampleRate + 0.999))); jack_deactivate(p.client); //} csound->Sleep((size_t) 50); /* unregister and free all ports */ if (p.inPorts != NULL) { for (i = 0; i < p.nChannels; i++) { if (p.inPorts[i] != NULL && p.jackState != 2) jack_port_unregister(p.client, p.inPorts[i]); } } if (p.outPorts != NULL) { for (i = 0; i < p.nChannels; i++) { if (p.outPorts[i] != NULL && p.jackState != 2) jack_port_unregister(p.client, p.outPorts[i]); } } /* close connection */ if (p.jackState != 2) { jack_client_close(p.client); } } /* free copy of input and output device name */ if (p.inDevName != NULL) free(p.inDevName); if (p.outDevName != NULL) free(p.outDevName); /* free ports and port buffer pointers */ if (p.inPorts != NULL) free(p.inPorts); if (p.inPortBufs != NULL) free(p.inPortBufs); if (p.outPorts != NULL) free(p.outPorts); if (p.outPortBufs != NULL) free(p.outPortBufs); /* free ring buffers */ rtJack_DeleteBuffers(&p); csound->DestroyGlobalVariable(csound, "_rtjackGlobals"); }
int main (int argc, char *argv[]) { parse_arguments (argc, argv); /* become a JACK client */ if ((client = jack_client_open ("freewheel", JackNullOption, NULL)) == 0) { fprintf (stderr, "JACK server not running?\n"); exit(1); } signal (SIGQUIT, signal_handler); signal (SIGTERM, signal_handler); signal (SIGHUP, signal_handler); signal (SIGINT, signal_handler); jack_on_shutdown (client, jack_shutdown, 0); if (jack_set_freewheel (client, onoff)) { fprintf (stderr, "failed to reset freewheel mode\n"); } jack_client_close(client); return 0; }
int main(int argc, char *argv[]) { int rc; parse_arguments(argc, argv); /* become a JACK client */ if ((client = jack_client_open(package, JackNullOption, NULL)) == 0) { fprintf(stderr, "JACK server not running?\n"); exit(1); } #ifndef WIN32 signal(SIGQUIT, signal_handler); signal(SIGHUP, signal_handler); #endif signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); jack_on_shutdown(client, jack_shutdown, 0); if (just_print_bufsize) { fprintf(stdout, "buffer size = %d sample rate = %d\n", jack_get_buffer_size(client), jack_get_sample_rate(client)); rc=0; } else { rc = jack_set_buffer_size(client, nframes); if (rc) fprintf(stderr, "jack_set_buffer_size(): %s\n", strerror(rc)); } jack_client_close(client); return rc; }
void cbox_jackio_destroy(struct cbox_io_impl *impl) { struct cbox_jack_io_impl *jii = (struct cbox_jack_io_impl *)impl; struct cbox_io *io = impl->pio; if (jii->client) { if (jii->error_str) { g_free(jii->error_str); jii->error_str = NULL; } else { for (int i = 0; i < io->io_env.input_count; i++) jack_port_unregister(jii->client, jii->inputs[i]); free(jii->inputs); for (int i = 0; i < io->io_env.output_count; i++) jack_port_unregister(jii->client, jii->outputs[i]); free(jii->outputs); if (jii->midi) jack_port_unregister(jii->client, jii->midi); } if (jii->client_name) { free(jii->client_name); jii->client_name = NULL; } cbox_io_destroy_all_midi_ports(io); jack_ringbuffer_free(jii->rb_autoconnect); jack_client_close(jii->client); } free(jii); }
static void cleanup(void) { if (jack_client != NULL) jack_client_close(jack_client); jack_client = NULL; if (fixed_cauldron != NULL) free(fixed_cauldron); fixed_cauldron = NULL; return; }
MidiJack::~MidiJack() { if(jackClient()) { if( jack_port_unregister( jackClient(), m_input_port) != 0){ printf("Failed to unregister jack midi input\n"); } if( jack_port_unregister( jackClient(), m_output_port) != 0){ printf("Failed to unregister jack midi output\n"); } if(m_jackClient) { // an m_jackClient means we are handling the jack connection if( jack_deactivate(m_jackClient) != 0){ printf("Failed to deactivate jack midi client\n"); } if( jack_client_close(m_jackClient) != 0){ printf("Failed close jack midi client\n"); } } } if( isRunning() ) { m_quit = true; wait( 1000 ); terminate(); } }
void closeJack1(void) { if (client != NULL) { jack_client_close(client); client = NULL; } }
void close_client(void) { if (client) { jack_client_close(client); client = NULL; } }
AudioDevJack::~AudioDevJack() { this->uninit(); if (this->m_client) jack_client_close(this->m_client); }