diff -ur ../moc-2.4.3.orig/main.c ./main.c --- ../moc-2.4.3.orig/main.c 2006-02-12 12:55:10.000000000 +0100 +++ ./main.c 2008-03-26 22:48:14.000000000 +0100 @@ -264,38 +264,40 @@ printf (PACKAGE_STRING"\n" "Usage:\n" "%s [OPTIONS]... [FILE]...\n" -"-V --version Print program version and exit.\n" -"-h --help Print usage and exit.\n" +"-V --version Print program version and exit.\n" +"-h --help Print usage and exit.\n" #ifndef NDEBUG -"-D --debug Turn on logging to a file.\n" +"-D --debug Turn on logging to a file.\n" #endif -"-S --server Run only the server.\n" -"-F --foreground Run server in foreground, log to stdout.\n" -"-R --sound-driver NAME Use the specified sound driver (oss, alsa, jack, null).\n" -"-m --music-dir Start in MusicDir.\n" -"-a --append Append the files/directories/playlists passed in\n" -" the command line to playlist and exit.\n" -"-c --clear Clear the playlist and exit.\n" -"-p --play Start playing from the first item on the playlist.\n" -"-l --playit Play files given on command line without modifing the\n" -" playlist.\n" -"-s --stop Stop playing.\n" -"-f --next Play next song.\n" -"-r --previous Play previous song.\n" -"-x --exit Shutdown the server.\n" -"-T --theme theme Use selected theme file (read from ~/.moc/themes if\n" -" the path is not absolute.\n" -"-C --config FILE Use the specified config file instead of the default.\n" -"-M --moc-dir DIR Use the specified MOC directory instead of the default.\n" -"-P --pause Pause.\n" -"-U --unpause Unpause.\n" -"-G --toggle-pause Toggle between play/pause.\n" -"-y --sync Synchronize the playlist with other clients.\n" -"-n --nosync Don't synchronize the playlist with other clients.\n" -"-A --ascii Use ASCII characters to draw lines.\n" -"-i --info Print the information about the currently played file.\n" -"-e --recursively Alias for -a.\n" -"-k --seek N Seek by N seconds (can be negative).\n" +"-S --server Run only the server.\n" +"-F --foreground Run server in foreground, log to stdout.\n" +"-R --sound-driver NAME Use the specified sound driver (oss, alsa, jack, null).\n" +"-j --autostart-jackd Start jackd on server init, and close it on server exit.\n" +"-J --no-autostart-jackd Do not start jackd on server init, and not close it on server exit.\n" +"-m --music-dir Start in MusicDir.\n" +"-a --append Append the files/directories/playlists passed in\n" +" the command line to playlist and exit.\n" +"-c --clear Clear the playlist and exit.\n" +"-p --play Start playing from the first item on the playlist.\n" +"-l --playit Play files given on command line without modifing the\n" +" playlist.\n" +"-s --stop Stop playing.\n" +"-f --next Play next song.\n" +"-r --previous Play previous song.\n" +"-x --exit Shutdown the server.\n" +"-T --theme theme Use selected theme file (read from ~/.moc/themes if\n" +" the path is not absolute.\n" +"-C --config FILE Use the specified config file instead of the default.\n" +"-M --moc-dir DIR Use the specified MOC directory instead of the default.\n" +"-P --pause Pause.\n" +"-U --unpause Unpause.\n" +"-G --toggle-pause Toggle between play/pause.\n" +"-y --sync Synchronize the playlist with other clients.\n" +"-n --nosync Don't synchronize the playlist with other clients.\n" +"-A --ascii Use ASCII characters to draw lines.\n" +"-i --info Print the information about the currently played file.\n" +"-e --recursively Alias for -a.\n" +"-k --seek N Seek by N seconds (can be negative).\n" , prg_name); } @@ -410,6 +412,8 @@ { "info", 0, NULL, 'i' }, { "recursively", 0, NULL, 'e' }, { "seek", 1, NULL, 'k' }, + { "autostart-jackd", 0, NULL, 'j' }, + { "no-autostart-jackd", 0, NULL, 'J' }, { 0, 0, 0, 0 } }; int ret, opt_index = 0; @@ -420,7 +424,7 @@ options_init (); while ((ret = getopt_long(argc, argv, - "VhDSFR:macpsxT:C:M:PUynArfiGelk:", + "VhDSFR:macpsxT:C:M:PUynArfiGelk:jJ", long_options, &opt_index)) != -1) { switch (ret) { case 'V': @@ -446,6 +450,14 @@ option_set_str ("SoundDriver", optarg); option_ignore_config ("SoundDriver"); break; + case 'j': + option_set_int ("AutoStartJackd", 1); + option_ignore_config ("AutoStartJackd"); + break; + case 'J': + option_set_int ("AutoStartJackd", 0); + option_ignore_config ("AutoStartJackd"); + break; case 'm': option_set_int ("StartInMusicDir", 1); option_ignore_config ("StartInMusicDir"); diff -ur ../moc-2.4.3.orig/options.c ./options.c --- ../moc-2.4.3.orig/options.c 2007-05-22 20:24:34.000000000 +0200 +++ ./options.c 2008-03-26 20:02:14.000000000 +0100 @@ -217,6 +217,10 @@ option_add_int ("SetXtermTitle", 1); option_add_int ("PlaylistFullPaths", 1); option_add_int ("Allow24bitOutput", 0); + + // Option to start Jackd on server init + option_add_int ("AutoStartJackd", 1); + } /* Return 1 if a parameter to an integer option is valid. */ @@ -243,6 +247,7 @@ || !strcasecmp(name, "SetXtermTitle") || !strcasecmp(name, "PlaylistFullPaths") || !strcasecmp(name, "Allow24bitOutput") + || !strcasecmp(name, "AutoStartJackd") ) { if (!(val == 1 || val == 0)) return 0; diff -ur ../moc-2.4.3.orig/server.c ./server.c --- ../moc-2.4.3.orig/server.c 2006-02-12 12:55:10.000000000 +0100 +++ server.c 2008-03-26 23:48:34.000000000 +0100 @@ -48,6 +48,7 @@ #define SERVER_LOG "mocp_server_log" #define PID_FILE "pid" +#define JACKD_PATH "/opt/local/bin/jackd" struct client { @@ -324,6 +325,34 @@ if (listen(server_sock, 1) == -1) fatal ("listen() failed: %s", strerror(errno)); + + /******* JACKd init ********/ + if(options_get_int ("AutoStartJackd")){ + int res; + pid_t pid; + + pid = fork(); + if (pid == (pid_t)-1) { + perror("I can't start JACK\n"); + res=1; + } + if (pid == 0) { + printf("Starting JACKd"); + execl(JACKD_PATH,JACKD_PATH,"-R","-T","--silent","-d", "coreaudio",0); + + _exit(1); + } + else{ + res=0; + } + + if(!res){ + sleep(1); + } + } + /***************************************/ + + audio_initialize (); tags_cache_init (&tags_cache, options_get_int("TagsCacheSize") * 1024); tags_cache_load (&tags_cache, create_file_name("tags_cache"));