Exemplo n.º 1
0
 void deactivate_audio(void)
 {
     if (is_active) {
         jack_deactivate(client);
         is_active = false;
     }
 }
Exemplo n.º 2
0
PRIVATE void clock_handler(AClock *clock, AClockReason reason) {

    switch (reason) {
	case CLOCK_DISABLE:
	    jack_deactivate( jack_client );
	    break;

	case CLOCK_ENABLE:
	    jack_set_process_callback( jack_client, (JackProcessCallback) process_callback, NULL ); 
	    jack_on_shutdown (jack_client, jack_shutdown, 0);

	    jack_activate( jack_client );

	    lash_event_t *event;
	    if( lash_enabled( galan_lash_get_client() ) ) {
		event = lash_event_new_with_type(LASH_Jack_Client_Name);
		lash_event_set_string(event, jack_get_client_name( jack_client ) );
		lash_send_event( galan_lash_get_client(), event);
	    }
	    break;

	default:
	    g_message("Unreachable code reached (jack_output)... reason = %d", reason);
	    break;
    }
}
Exemplo n.º 3
0
void
process_info_destroy (process_info_t * procinfo)
{
  jack_deactivate (procinfo->jack_client);
  jack_client_close (procinfo->jack_client);
  g_free (procinfo);
}
Exemplo n.º 4
0
void JackCpp::AudioIO::stop()
	throw(std::runtime_error)
{
	if (jack_deactivate(mJackClient) != 0)
		throw std::runtime_error("cannot deactivate the client");
	mJackState = notActive;
}
Exemplo n.º 5
0
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);
}
bool JackAudioInterface::stop()
{
    if (m_client)
    {
        int result = jack_deactivate(m_client);
        if (result != 0)
        {
            qDebug("JackAudioInterface::~JackAudioInterface() couldn't deactivate jack client");
        }
    }
    
     // free input ports
    if (m_inputPorts)
    {
        for (unsigned int ch = 0; ch < m_channels; ch++)
        {
            if (m_inputPorts[ch])
            {
                jack_port_unregister(m_client, m_inputPorts[ch]);
                m_inputPorts[ch] = NULL;
            }
        }
        delete[] m_inputPorts;
        m_inputPorts = NULL;
    }
    
    if (!close_jack_client())
    {
        qDebug() << "JackAudioInterface::~JackAudioInterface() couldn't close JACK client" << endl;
    }
    
    return true;
}
Exemplo n.º 7
0
static int instream_pause_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
    SoundIoInStreamJack *isj = &is->backend_data.jack;
    SoundIoInStream *instream = &is->pub;
    SoundIoJack *sij = &si->backend_data.jack;
    if (sij->is_shutdown)
        return SoundIoErrorBackendDisconnected;

    int err;
    if (pause) {
        if ((err = jack_deactivate(isj->client)))
            return SoundIoErrorStreaming;
    } else {
        if ((err = jack_activate(isj->client)))
            return SoundIoErrorStreaming;

        for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
            SoundIoInStreamJackPort *isjp = &isj->ports[ch];
            const char *source_port_name = isjp->source_port_name;
            // allow unconnected ports
            if (!source_port_name)
                continue;
            const char *dest_port_name = jack_port_name(isjp->dest_port);
            if ((err = jack_connect(isj->client, source_port_name, dest_port_name)))
                return SoundIoErrorStreaming;
        }
    }

    return 0;
}
Exemplo n.º 8
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");
}
Exemplo n.º 9
0
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);
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
Arquivo: Client.C Projeto: 0mk/non
    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;
    }
Exemplo n.º 12
0
    ~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);
    }
Exemplo n.º 13
0
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);
        }
}
Exemplo n.º 14
0
void Jasmine::Impl::cleanup()
	{
	jack_deactivate(m_client);
	ports_destroy(m_ports_out);
	ports_destroy(m_ports_in);
	jack_client_close(m_client);
	}
Exemplo n.º 15
0
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();
	}
}
Exemplo n.º 16
0
void JackClosePlay(void *port){
  int lokke;
  struct Jackplay *jackplay=(struct Jackplay *)port;

  while(jackplay->unread>0){
    usleep(100);
  }

  for(lokke=0;lokke<jackplay->fftsound->samps_per_frame;lokke++){
    jack_disconnect(
		    jackplay->client,
		    jack_port_name(jackplay->jpc[lokke].output_port),
		    outportnames[lokke]
		    );
    
    jack_port_unregister(
			 jackplay->client,jackplay->jpc[lokke].output_port
			 );

  }

  jack_deactivate(jackplay->client);

  //  fprintf(stderr,"closing client\n");
  //  jack_client_close (jackplay->client);
  //  globalclient=NULL;
  free(jackplay);
}
Exemplo n.º 17
0
//-----------------------------------------------------------------------------------------
void JackVST::Close()
{
	fStatus = kIsOff;
	list<JackVST*>::iterator it;
	
	printf("actually there are %ld instances.\n",JackVST::fPlugInList.size());
	JackVST::fPlugInList.remove(this);
	printf("now there are %ld instances.\n",JackVST::fPlugInList.size());
	
	for(int i = 0; i < fInPortsNum; i++) {
		RingBuffer_Flush(&fRingBufferIn[i]);	
		free(fRBufferIn[i]);
		jack_port_unregister(JackVST::fJackClient,fInPorts[i]);
		printf("unregistering in port %d.\n",i);
	}
	free(fInPorts);
	
	for(int i = 0; i < fOutPortsNum; i++) {
		RingBuffer_Flush(&fRingBufferIn[i]);	
		free(fRBufferOut[i]);
		jack_port_unregister(JackVST::fJackClient,fOutPorts[i]);
		printf("unregistering out port %d.\n",i);
	}
	free(fOutPorts);
				
	if(JackVST::fPlugInList.size() == 0) { 
		printf("closing client.\n"); 
		jack_deactivate(JackVST::fJackClient); 
		jack_client_close(JackVST::fJackClient);
		JackVST::fJackClient = NULL;
		JackVST::fInstances = 0;
	} 
}
Exemplo n.º 18
0
void cleanup() {
  if (j_client) {
    jack_deactivate(j_client);
    jack_client_close (j_client);
  }
  j_client=NULL;
}
Exemplo n.º 19
0
 int JackProxyDriver::Stop()
 {
     if (fClient && (jack_deactivate(fClient) != 0)) {
         jack_error("Cannot deactivate jack client.");
         return -1;
     }
     return 0;
 }
Exemplo n.º 20
0
Arquivo: Client.C Projeto: 0mk/non
    /** Tell JACK to stop calling process callback. This MUST be called in
     * an inheriting class' destructor */
    void
    Client::deactivate ( )
    {
        if ( _active )
            jack_deactivate( _client );

        _active = false;
    }
Exemplo n.º 21
0
Arquivo: mfp_jack.c Projeto: wrl/mfp
void
mfp_jack_shutdown(mfp_context * ctxt) 
{
    printf("jack_shutdown: closing client, good-bye!\n");
    jack_deactivate(ctxt->info.jack->client);
    jack_client_close(ctxt->info.jack->client);
    ctxt->info.jack->client = NULL;
}
Exemplo n.º 22
0
    int JackAudioSystem::deactivate(QString *err_msg)
    {
	int rv = 0;
	if(_client) {
	    rv = jack_deactivate(_client);
	}
	return rv;
    }
Exemplo n.º 23
0
int
Server_jack_stop(Server *self) {
    PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
    int ret = jack_deactivate(be_data->jack_client);
    if (ret)
        Server_error(self, "Jack error: cannot deactivate jack client.\n");
    self->server_started = 0;
    return ret;
}
Exemplo n.º 24
0
bool Out_JACK::Stop()
{
	// Stop!
	if(jack_deactivate(JackClient) != 0) {printf("ERROR: out_jack: Couldn't deactivate JACK client.\n"); return false; }

	jack_client_close(JackClient);

	return true;
}
Exemplo n.º 25
0
ExternalMetro::~ExternalMetro()
{
    jack_deactivate(client);
    jack_port_unregister(client, input_port);
    jack_port_unregister(client, output_port);
    jack_client_close(client);
    free(amp);
    free(wave);
}
Exemplo n.º 26
0
void close_jack(void)
{
	if (jack_client) {
		jack_client_t *b = jack_client;
		jack_client=NULL;
		jack_deactivate (b);
		jack_client_close (b);
	}
	jack_client=NULL;
}
Exemplo n.º 27
0
void dev_jack_shutdown(void *arg) {
  SoundDevice *dev = (SoundDevice*)arg;
  // close the jack channels
  dev->jack = false;
  jack_port_unregister(dev->get_jack_client(), dev->get_jack_in_port());
  jack_port_unregister(dev->get_jack_client(), dev->get_jack_out_port());
  jack_deactivate(dev->get_jack_client());
  delete dev->get_jack_in_pipe();
  delete dev->get_jack_out_pipe();
}
Exemplo n.º 28
0
int engine_jack_stop(engine_t* engine){
  
  if (jack_deactivate(client)) 
    return -1;

  /*engine is now inactive*/
  engine->state = ENGINE_STATE_INACTIVE;

  return 0;
}
Exemplo n.º 29
0
static void
jack_shutdown (void *arg)
{
  error("JACK: server shut down");

  jack_deactivate (jack_client);
  //jack_client_close(jack_client); /* likely to hang if the server shut down */
  jack_client = NULL;

  glob_audio_setapi(NULL, API_NONE); // set pd_whichapi 0
}
Exemplo n.º 30
0
void jack_raw_output::start ()
{
    check_idle ();

    jack_activate (_client);
    auto grd_activate = base::make_guard ([&] { jack_deactivate (_client); });

    connect_ports ();
    
    grd_activate.dismiss ();
    set_state (async_state::running);
}