Ejemplo n.º 1
0
void jack_session_cb(jack_session_event_t *event, void *arg) {
	char filename[256];
	char command[256];
	if (interaction_override&OVR_JSESSION) {
		/* DO NOT SAVE SESSION 
		 * e.g. if xjadeo will be restored by wrapper-program
		 * f.i. ardour3+videotimeline
		 */
	  jack_session_reply(jack_client, event);
	  jack_session_event_free(event);
		return;
	}

	snprintf(filename, sizeof(filename), "%sxjadeo.state", event->session_dir );
	snprintf(command,  sizeof(command),  "xjadeo -U %s --rc ${SESSION_DIR}xjadeo.state", event->client_uuid );

	//TODO save-state in filename
	saveconfig(filename);

	event->command_line = strdup(command);
	jack_session_reply( jack_client, event );
  if(event->type == JackSessionSaveAndQuit)
		loop_flag=0;
	jack_session_event_free(event);
}
Ejemplo n.º 2
0
static void
_ui_saved(void *data, int status)
{
	bin_t *bin = data;
	prog_t *handle = (void *)bin - offsetof(prog_t, bin);

	//printf("_ui_saved: %i\n", status);
	if(handle->save_state == SAVE_STATE_NSM)
	{
		synthpod_nsm_saved(bin->nsm, status);
	}
	else if(handle->save_state == SAVE_STATE_JACK)
	{
		jack_session_event_t *ev = handle->session_event;
		if(ev)
		{
			if(status != 0)
				ev->flags |= JackSessionSaveError;
			jack_session_reply(handle->client, ev);
			jack_session_event_free(ev);
		}
		handle->session_event = NULL;
	}
	handle->save_state = SAVE_STATE_INTERNAL;

	if(atomic_load_explicit(&handle->kill, memory_order_relaxed))
	{
		elm_exit();
	}
}
Ejemplo n.º 3
0
/*
 * Callback function for JS
 */
void session_callback(jack_session_event_t *ev, void *args) {
    char command[256];

    snprintf(command,  sizeof(command),  
             "/home/httpd/html/LinuxSound/Sampled/SessionManagement/delay -u %s", 
	     ev->client_uuid);
    ev->flags = JackSessionNeedTerminal;
    ev->command_line = strdup(command);
    jack_session_reply(client, ev);

    if(ev->type == JackSessionSaveAndQuit)
         jack_shutdown(NULL);

    jack_session_event_free(ev);
}
Ejemplo n.º 4
0
// JACK session event handler.
void samplv1_jack::sessionEvent ( void *pvSessionArg )
{
    jack_session_event_t *pJackSessionEvent
        = (jack_session_event_t *) pvSessionArg;

#ifdef CONFIG_DEBUG
    qDebug("samplv1_jack::sessionEvent()"
           " type=%d client_uuid=\"%s\" session_dir=\"%s\"",
           int(pJackSessionEvent->type),
           pJackSessionEvent->client_uuid,
           pJackSessionEvent->session_dir);
#endif

    const bool bQuit = (pJackSessionEvent->type == JackSessionSaveAndQuit);

    const QString sSessionDir
        = QString::fromUtf8(pJackSessionEvent->session_dir);
    const QString sSessionName
        = QFileInfo(QFileInfo(sSessionDir).canonicalPath()).completeBaseName();
    const QString sSessionFile = sSessionName + '.' + SAMPLV1_TITLE;

    QStringList args;
    args << QCoreApplication::applicationFilePath();
    args << QString("\"${SESSION_DIR}%1\"").arg(sSessionFile);

    samplv1_param::savePreset(this,
                              QFileInfo(sSessionDir, sSessionFile).absoluteFilePath());

    const QByteArray aCmdLine = args.join(" ").toUtf8();
    pJackSessionEvent->command_line = ::strdup(aCmdLine.constData());

    jack_session_reply(m_client, pJackSessionEvent);
    jack_session_event_free(pJackSessionEvent);

    if (bQuit)
        QCoreApplication::quit();
}
Ejemplo n.º 5
0
void JackOutput::jack_session_callback_impl(jack_session_event_t *event)
{
	INFOLOG("jack session calback");
	enum session_events{
		SAVE_SESSION,
		SAVE_AND_QUIT,
		SAVE_TEMPLATE
	};

	Hydrogen* H = Hydrogen::get_instance();
	Song* S = H->getSong();
	Preferences* P = Preferences::get_instance();
	EventQueue* EQ = EventQueue::get_instance();

	jack_session_event_t *ev = (jack_session_event_t *) event;

	QString jackSessionDirectory = (QString) ev->session_dir;
	QString retval = P->getJackSessionApplicationPath() + " --jacksessionid " + ev->client_uuid;

	/* Playlist mode */
	if ( H->m_PlayList.size() > 0 ) {
		Playlist* PL = Playlist::get_instance();

		if ( PL->get_filename().isEmpty() ) PL->set_filename( "untitled.h2playlist" );

		QString FileName = baseName ( PL->get_filename() );
		FileName.replace ( QString(" "), QString("_") );
		retval += " -p \"${SESSION_DIR}" + FileName + "\"";

		/* Copy all songs to Session Directory and update playlist */
		SongReader reader;
		for ( uint i = 0; i < H->m_PlayList.size(); ++i ) {
			QString BaseName = baseName ( H->m_PlayList[i].m_hFile );
			QString newName = jackSessionDirectory + BaseName;
			QString SongPath = reader.getPath ( H->m_PlayList[i].m_hFile );
			if ( SongPath != NULL && QFile::copy ( SongPath, newName ) ) {
				/* Keep only filename on list for relative read */
				H->m_PlayList[i].m_hFile = BaseName;
				//H->m_PlayList[i].m_hScript;
			} else {
				/* Note - we leave old path in playlist */
				ERRORLOG ( "Can't copy " + H->m_PlayList[i].m_hFile + " to " + newName );
				ev->flags = JackSessionSaveError;
			}
		}

		/* Save updated playlist */
		if ( ! PL->save ( jackSessionDirectory + FileName ) )
			ev->flags = JackSessionSaveError;
		/* Song Mode */
	} else {
		/* Valid Song is needed */
		if ( S->get_filename().isEmpty() ) S->set_filename("untitled.h2song");

		QString FileName = baseName ( S->get_filename() );
		FileName.replace ( QString(" "), QString("_") );
		S->set_filename(jackSessionDirectory + FileName);

		/* SongReader will look into SESSION DIR anyway */
		retval += " -s \"" + FileName + "\"";

		switch (ev->type) {
			case JackSessionSave:
				EQ->push_event(EVENT_JACK_SESSION, SAVE_SESSION);
				break;
			case JackSessionSaveAndQuit:
				EQ->push_event(EVENT_JACK_SESSION, SAVE_SESSION);
				EQ->push_event(EVENT_JACK_SESSION, SAVE_AND_QUIT);
				break;
			default:
				ERRORLOG( "JackSession: Unknown event type" );
				ev->flags = JackSessionSaveError;
		}
	}

	ev->command_line = strdup( retval.toUtf8().constData() );
	jack_session_reply (client, ev );
	jack_session_event_free (ev);
}