Ejemplo n.º 1
0
int
main (int argc, char * argv [])
{
   int ch, i;
   char * file_name, * autoconnect_port_name = NULL;
   g_thread_init(NULL);

#ifdef WITH_LASH
   lash_args_t * lash_args = lash_extract_args(&argc, &argv);
#endif

   g_log_set_default_handler(log_handler, NULL);
   while ((ch = getopt(argc, argv, "a:V")) != -1)
   {
      switch (ch)
      {
         case 'a':
            autoconnect_port_name = strdup(optarg);
            break;

         case 'V':
            show_version();
            break;

         case '?':
         default:
            usage();
      }
   }
   argc -= optind;
   argv += optind;
   if (argc == 0)
      usage();

   file_name = argv[0];
   smf = smf_new();
   if (smf == NULL)
      exit(-1);

   for (i = 0; i < 16; ++i)
   {
      tracks[i] = smf_track_new();
      if (tracks[i] == NULL)
         exit(-1);

      smf_add_track(smf, tracks[i]);
   }

#ifdef WITH_LASH
   init_lash(lash_args);
#endif

   init_jack();
   if (autoconnect_port_name)
   {
      if (connect_to_output_port(autoconnect_port_name))
      {
         g_critical("Couldn't connect to '%s', exiting.", autoconnect_port_name);
         exit(EX_UNAVAILABLE);
      }
   }
   g_timeout_add(100, writer_timeout, (gpointer)argv[0]);
   signal(SIGINT, ctrl_c_handler);
   g_message
   (
      "Recording will start at the first received note; "
      "press ^C to write the file and exit."
   );
   g_main_loop_run(g_main_loop_new(NULL, TRUE));

   /* Not reached. */

   return 0;
}
Ejemplo n.º 2
0
int 
main(int argc, char *argv[])
{
	int		ch;
	char		*file_name, *autoconnect_port_name = NULL;


#ifdef WITH_LASH
	lash_args_t *lash_args;
#endif

	g_thread_init(NULL);

#ifdef WITH_LASH
	lash_args = lash_extract_args(&argc, &argv);
#endif

	g_log_set_default_handler(log_handler, NULL);

	while ((ch = getopt(argc, argv, "a:dnqr:stVx")) != -1) {
		switch (ch) {
			case 'a':
				autoconnect_port_name = strdup(optarg);
				break;

			case 'd':
				debug = 1;
				break;

			case 'n':
				start_stopped = 1;
				break;

			case 'q':
				be_quiet = 1;
				break;

			case 'r':
				rate_limit = strtod(optarg, NULL);
				if (rate_limit <= 0.0) {
					g_critical("Invalid rate limit specified.\n");

					exit(EX_USAGE);
				}

				break;

			case 's':
				just_one_output = 1;
				break;

			case 't':
				use_transport = 0;
				break;

            case 'x':
                    remote_control = 1;
                    break;

			case 'V':
				show_version();
				break;

			case '?':
			default:
				usage();
				break;
		}
	}

	argc -= optind;
	argv += optind;

	if (argv[0] == NULL) {
		g_critical("No file name given.");
		usage();
	}

	file_name = argv[0];

	if (!remote_control) {
	smf_vol = smf = smf_load(file_name);

	if (smf == NULL) {
		g_critical("Loading SMF file failed.");

		exit(-1);
	}

	if (!be_quiet)
		g_message("%s.", smf_decode(smf));

	if (smf->number_of_tracks > MAX_NUMBER_OF_TRACKS) {
		g_warning("Number of tracks (%d) exceeds maximum for per-track output; implying '-s' option.", smf->number_of_tracks);
		just_one_output = 1;
	}
	}

#ifdef WITH_LASH
	init_lash(lash_args);
#endif

	g_timeout_add(1000, emergency_exit_timeout, (gpointer)0);
	signal(SIGINT, ctrl_c_handler);

	init_jack();

	if (autoconnect_port_name) {
		if (connect_to_input_port(autoconnect_port_name)) {
			g_critical("Couldn't connect to '%s', exiting.", autoconnect_port_name);
			exit(EX_UNAVAILABLE);
		}
	}

	if (use_transport && !start_stopped) {
		jack_transport_locate(jack_client, 0);
		jack_transport_start(jack_client);
	}

	if (!use_transport)
		playback_started = jack_frame_time(jack_client);

	if (remote_control)
		remote_control_start(argv[0]);

	g_main_loop_run(g_main_loop_new(NULL, TRUE));

	/* Not reached. */

	return 0;
}