Ticket #14875: patch-autojack.diff

File patch-autojack.diff, 6.9 KB (added by eu@…, 16 years ago)
  • main.c

    diff -ur ../moc-2.4.3.orig/main.c ./main.c
    old new  
    264264        printf (PACKAGE_STRING"\n"
    265265"Usage:\n"
    266266"%s [OPTIONS]... [FILE]...\n"
    267 "-V --version           Print program version and exit.\n"
    268 "-h --help              Print usage and exit.\n"
     267"-V --version                 Print program version and exit.\n"
     268"-h --help                    Print usage and exit.\n"
    269269#ifndef NDEBUG
    270 "-D --debug             Turn on logging to a file.\n"
     270"-D --debug                   Turn on logging to a file.\n"
    271271#endif
    272 "-S --server            Run only the server.\n"
    273 "-F --foreground        Run server in foreground, log to stdout.\n"
    274 "-R --sound-driver NAME Use the specified sound driver (oss, alsa, jack, null).\n"
    275 "-m --music-dir         Start in MusicDir.\n"
    276 "-a --append            Append the files/directories/playlists passed in\n"
    277 "                       the command line to playlist and exit.\n"
    278 "-c --clear             Clear the playlist and exit.\n"
    279 "-p --play              Start playing from the first item on the playlist.\n"
    280 "-l --playit            Play files given on command line without modifing the\n"
    281 "                       playlist.\n"
    282 "-s --stop              Stop playing.\n"
    283 "-f --next              Play next song.\n"
    284 "-r --previous          Play previous song.\n"
    285 "-x --exit              Shutdown the server.\n"
    286 "-T --theme theme       Use selected theme file (read from ~/.moc/themes if\n"
    287 "                       the path is not absolute.\n"
    288 "-C --config FILE       Use the specified config file instead of the default.\n"
    289 "-M --moc-dir DIR       Use the specified MOC directory instead of the default.\n"
    290 "-P --pause             Pause.\n"
    291 "-U --unpause           Unpause.\n"
    292 "-G --toggle-pause      Toggle between play/pause.\n"
    293 "-y --sync              Synchronize the playlist with other clients.\n"
    294 "-n --nosync            Don't synchronize the playlist with other clients.\n"
    295 "-A --ascii             Use ASCII characters to draw lines.\n"
    296 "-i --info              Print the information about the currently played file.\n"
    297 "-e --recursively       Alias for -a.\n"
    298 "-k --seek N            Seek by N seconds (can be negative).\n"
     272"-S --server                  Run only the server.\n"
     273"-F --foreground              Run server in foreground, log to stdout.\n"
     274"-R --sound-driver NAME       Use the specified sound driver (oss, alsa, jack, null).\n"
     275"-j --autostart-jackd         Start jackd on server init, and close it on server exit.\n"
     276"-J --no-autostart-jackd      Do not start jackd on server init, and not close it on server exit.\n"
     277"-m --music-dir               Start in MusicDir.\n"
     278"-a --append                  Append the files/directories/playlists passed in\n"
     279"                             the command line to playlist and exit.\n"
     280"-c --clear                   Clear the playlist and exit.\n"
     281"-p --play                    Start playing from the first item on the playlist.\n"
     282"-l --playit                  Play files given on command line without modifing the\n"
     283"                             playlist.\n"
     284"-s --stop                    Stop playing.\n"
     285"-f --next                    Play next song.\n"
     286"-r --previous                Play previous song.\n"
     287"-x --exit                    Shutdown the server.\n"
     288"-T --theme theme             Use selected theme file (read from ~/.moc/themes if\n"
     289"                             the path is not absolute.\n"
     290"-C --config FILE             Use the specified config file instead of the default.\n"
     291"-M --moc-dir DIR             Use the specified MOC directory instead of the default.\n"
     292"-P --pause                   Pause.\n"
     293"-U --unpause                 Unpause.\n"
     294"-G --toggle-pause            Toggle between play/pause.\n"
     295"-y --sync                    Synchronize the playlist with other clients.\n"
     296"-n --nosync                  Don't synchronize the playlist with other clients.\n"
     297"-A --ascii                   Use ASCII characters to draw lines.\n"
     298"-i --info                    Print the information about the currently played file.\n"
     299"-e --recursively             Alias for -a.\n"
     300"-k --seek N                  Seek by N seconds (can be negative).\n"
    299301, prg_name);
    300302}
    301303
     
    410412                { "info",               0, NULL, 'i' },
    411413                { "recursively",        0, NULL, 'e' },
    412414                { "seek",               1, NULL, 'k' },
     415                { "autostart-jackd",            0, NULL, 'j' },
     416                { "no-autostart-jackd",         0, NULL, 'J' },
    413417                { 0, 0, 0, 0 }
    414418        };
    415419        int ret, opt_index = 0;
     
    420424        options_init ();
    421425
    422426        while ((ret = getopt_long(argc, argv,
    423                                         "VhDSFR:macpsxT:C:M:PUynArfiGelk:",
     427                                        "VhDSFR:macpsxT:C:M:PUynArfiGelk:jJ",
    424428                                        long_options, &opt_index)) != -1) {
    425429                switch (ret) {
    426430                        case 'V':
     
    446450                                option_set_str ("SoundDriver", optarg);
    447451                                option_ignore_config ("SoundDriver");
    448452                                break;
     453                        case 'j':
     454                                option_set_int ("AutoStartJackd", 1);
     455                                option_ignore_config ("AutoStartJackd");
     456                                break;
     457                        case 'J':
     458                                option_set_int ("AutoStartJackd", 0);
     459                                option_ignore_config ("AutoStartJackd");
     460                                break;
    449461                        case 'm':
    450462                                option_set_int ("StartInMusicDir", 1);
    451463                                option_ignore_config ("StartInMusicDir");
  • options.c

    diff -ur ../moc-2.4.3.orig/options.c ./options.c
    old new  
    217217        option_add_int ("SetXtermTitle", 1);
    218218        option_add_int ("PlaylistFullPaths", 1);
    219219        option_add_int ("Allow24bitOutput", 0);
     220       
     221        // Option to start Jackd on server init
     222        option_add_int ("AutoStartJackd", 1);
     223       
    220224}
    221225
    222226/* Return 1 if a parameter to an integer option is valid. */
     
    243247                        || !strcasecmp(name, "SetXtermTitle")
    244248                        || !strcasecmp(name, "PlaylistFullPaths")
    245249                        || !strcasecmp(name, "Allow24bitOutput")
     250                        || !strcasecmp(name, "AutoStartJackd")
    246251                        ) {
    247252                if (!(val == 1 || val == 0))
    248253                        return 0;
  • server.c

    diff -ur ../moc-2.4.3.orig/server.c ./server.c
    old new  
    4848
    4949#define SERVER_LOG      "mocp_server_log"
    5050#define PID_FILE        "pid"
     51#define JACKD_PATH "/opt/local/bin/jackd"
    5152
    5253struct client
    5354{
     
    324325        if (listen(server_sock, 1) == -1)
    325326                fatal ("listen() failed: %s", strerror(errno));
    326327
     328
     329        /******* JACKd init ********/
     330        if(options_get_int ("AutoStartJackd")){
     331                int res;
     332                pid_t pid;
     333
     334                pid = fork();
     335                if (pid == (pid_t)-1) {
     336                        perror("I can't start JACK\n");
     337                                        res=1;
     338                }
     339                if (pid == 0) {
     340                        printf("Starting JACKd");
     341                        execl(JACKD_PATH,JACKD_PATH,"-R","-T","--silent","-d", "coreaudio",0);
     342
     343                                        _exit(1);
     344                }
     345                        else{
     346                                res=0;
     347                        }
     348
     349                        if(!res){
     350                                sleep(1);
     351                        }
     352        }
     353        /***************************************/
     354
     355
    327356        audio_initialize ();
    328357        tags_cache_init (&tags_cache, options_get_int("TagsCacheSize") * 1024);
    329358        tags_cache_load (&tags_cache, create_file_name("tags_cache"));