Пример #1
0
int main ( int argc, char*argv[] )
{
	int i;
	char projectM_data[1024];

	QApplication app ( argc, argv );

	setlocale(LC_NUMERIC, "C");  // Fix
	std::string config_file;
	config_file = read_config();

	
	QMutex audioMutex;
	
	QProjectM_MainWindow * mainWindow = new QProjectM_MainWindow ( config_file, &audioMutex);
	
	QAction pulseAction("Pulse audio settings...", mainWindow);
	
	
      	mainWindow->registerSettingsAction(&pulseAction);
	mainWindow->show();
	
	QPulseAudioThread * pulseThread = new QPulseAudioThread(argc, argv, mainWindow);

	pulseThread->start();
		
	//QApplication::connect
	//		(mainWindow->qprojectMWidget(), SIGNAL(projectM_Initialized(QProjectM *)), pulseThread, SLOT(setQrojectMWidget(QProjectMWidget*)));
	
	QPulseAudioDeviceChooser devChooser(pulseThread, mainWindow);	
	QApplication::connect(&pulseAction, SIGNAL(triggered()), &devChooser, SLOT(open())); 
	//QApplication::connect(pulseThread, SIGNAL(threadCleanedUp()), mainWindow, SLOT(close()));
	
	//QApplication::connect(mainWindow, SIGNAL(shuttingDown()), pulseThread, SLOT(cleanup()), Qt::DirectConnection);
 	int ret = app.exec();
	devChooser.writeSettings();
	
	if (mainWindow)
        	mainWindow->unregisterSettingsAction(&pulseAction);

	pulseThread->cleanup();
	
	delete(pulseThread);
	return ret;
}
Пример #2
0
int main (int argc, char **argv) {
	const char **ports;
	const char *client_name;
	const char *server_name = NULL;
	jack_options_t options = JackNullOption;
	jack_status_t status;
	int i;
	char projectM_data[1024];

	// Start a new application
	ProjectMApplication app(argc, argv);
	setlocale(LC_NUMERIC, "C");  // Fix

	std::string config_file;
	config_file = read_config();


	QProjectM_MainWindow * mainWindow = new QProjectM_MainWindow(config_file, 0);
	mainWindow->show();

	globalPM = mainWindow->GetProjectM();



	//JACK INIT
	//----------------------------------------------
	if (argc >= 2) {		/* client name specified? */
		client_name = argv[1];
		if (argc >= 3) {	/* server name specified? */
			server_name = argv[2];
			//			options |= JackServerName;
		}
	} else {			/* use basename of argv[0] */
		client_name = strrchr(argv[0], '/');
		if (client_name == 0) {
			client_name = argv[0];
		} else {
			client_name++;
		}
	}

	/* open a client connection to the JACK server */

	client = jack_client_open (client_name, options, &status, server_name);
	if (client == NULL) {
		fprintf (stderr, "jack_client_open() failed, "
			 "status = 0x%2.0x\n", status);
		if (status & JackServerFailed) {
			fprintf (stderr, "Unable to connect to JACK server\n");
		}
		exit (1);
	}

	if (status & JackServerStarted) {
		fprintf (stderr, "JACK server started\n");
	}

	if (status & JackNameNotUnique) {
		client_name = jack_get_client_name(client);
		fprintf (stderr, "unique name `%s' assigned\n", client_name);
	}

	/* tell the JACK server to call `process()' whenever
	   there is work to be done.
	*/

	if (jack_set_process_callback (client, process, 0)) {
		std::cerr << "qprojectM-jack: failed to set process callbank!. quitting..." << std::endl;
		exit(EXIT_FAILURE);
	}

	/* tell the JACK server to call `jack_shutdown()' if
	   it ever shuts down, either entirely, or if it
	   just decides to stop calling us.
	*/

	jack_on_shutdown (client, jack_shutdown, 0);

	/* display the current sample rate.
	 */

	printf ("engine sample rate: %d\n",
		jack_get_sample_rate (client));

	/* create two ports */

	input_port = jack_port_register (client, "input",
					 JACK_DEFAULT_AUDIO_TYPE,
					 JackPortIsInput, 0);

	if (input_port == NULL) {
		fprintf(stderr, "no more JACK ports available\n");
		exit (1);
	}

	/* Tell the JACK server that we are ready to roll.  Our
	 * process() callback will start running now. */

	// END JACK INIT ----------------------------------

        //JACK BEGIN-----------------------------

	if (jack_activate (client)) {
		fprintf (stderr, "cannot activate client");
		exit (1);
	}

	/* Connect the ports.  You can't do this before the client is
	 * activated, because we can't make connections to clients
	 * that aren't running.  Note the confusing (but necessary)
	 * orientation of the driver backend ports: playback ports are
	 * "input" to the backend, and capture ports are "output" from
	 * it.
	 */

	ports = jack_get_ports (client, NULL, NULL, JackPortIsOutput);
	if (ports == NULL) {
		fprintf(stderr, "no physical capture ports\n");
		exit (1);
	}


        i=0;
        while (ports[i]!=NULL)
	 {
            printf("Connecting to Jack port %s\n",ports[i]);
	    if (jack_connect (client, ports[i], jack_port_name (input_port))) {
	      fprintf (stderr, "cannot connect input ports\n");
	    }
	      i++;
	     }

	free (ports);
	
	
#ifdef HTTP_REMOTE_CONTROL
  uint port=qgetenv("HTTP_PORT").toUInt();
  QxtHttpServerConnector connector;

  QxtHttpSessionManager session;
  printf("session.setPort(%i\n", port); fflush(stdout);
  session.setPort(port);
  session.setConnector(&connector);

  HTTPRemoteControl s1(&session, mainWindow->qprojectM());
  session.setStaticContentService ( &s1);

  printf("session.start()\n"); fflush(stdout);
  if(port>0) { // I think it didn't work when the conditional was further up
    session.start();
  }
#endif


	//----------------------------------END

	//return 1;
	return app.exec();
}