?? mpg123.c
字號:
ret = control_generic(&fr); clear_icy(); exit_id3(); safe_exit(ret); }#endif init_icy(); init_id3(); /* prepare id3 memory */ while ((fname = get_next_file())) { char *dirname, *filename; long leftFrames,newFrame; if(!*fname || !strcmp(fname, "-")) fname = NULL; if (open_stream(fname,-1) < 0) continue; if (!param.quiet) { if (split_dir_file(fname ? fname : "standard input", &dirname, &filename)) fprintf(stderr, "\nDirectory: %s", dirname); fprintf(stderr, "\nPlaying MPEG stream %lu of %lu: %s ...\n", (unsigned long)pl.pos, (unsigned long)pl.fill, filename);#if !defined(GENERIC){ const char *term_type; term_type = getenv("TERM"); if (term_type && param.xterm_title && (!strncmp(term_type,"xterm",5) || !strncmp(term_type,"rxvt",4))) { fprintf(stderr, "\033]0;%s\007", filename); }}#endif }#if !defined(WIN32) && !defined(GENERIC)#ifdef HAVE_TERMIOS if(!param.term_ctrl)#endif gettimeofday (&start_time, NULL);#endif read_frame_init(&fr); init = 1; #ifdef GAPLESS pre_init = 1; #endif newFrame = startFrame; #ifdef HAVE_TERMIOS debug1("param.term_ctrl: %i", param.term_ctrl); if(param.term_ctrl) term_init();#endif leftFrames = numframes; /* read_frame is counting the frames! */ for(;read_frame(&fr) && leftFrames && !intflag;) {#ifdef HAVE_TERMIOS tc_hack:#endif if(fr.num < startFrame || (param.doublespeed && (fr.num % param.doublespeed))) { if(fr.lay == 3) { set_pointer(512); #ifdef GAPLESS if(param.gapless) { if(pre_init) { prepare_audioinfo(&fr, &pre_ai); pre_init = 0; } /* keep track... */ layer3_gapless_set_position(fr.num, &fr, &pre_ai); } #endif } continue; } if(leftFrames > 0) leftFrames--; if(!play_frame(init,&fr)) { error("frame playback failed, skipping rest of track"); break; } init = 0; if(param.verbose) {#ifndef NOXFERMEM if (param.verbose > 1 || !(fr.num & 0x7)) print_stat(&fr,fr.num,xfermem_get_usedspace(buffermem),&ai); if(param.verbose > 2 && param.usebuffer) fprintf(stderr,"[%08x %08x]",buffermem->readindex,buffermem->freeindex);#else if (param.verbose > 1 || !(fr.num & 0x7)) print_stat(&fr,fr.num,0,&ai);#endif }#ifdef HAVE_TERMIOS if(!param.term_ctrl) { continue; } else { long offset; if((offset=term_control(&fr,&ai))) { if(!rd->back_frame(rd, &fr, -offset)) { debug1("seeked to %lu", fr.num); #ifdef GAPLESS if(param.gapless && (fr.lay == 3)) layer3_gapless_set_position(fr.num, &fr, &ai); #endif } else { error("seek failed!"); } } }#endif } #ifdef GAPLESS /* make sure that the correct padding is skipped after track ended */ if(param.gapless) audio_flush(param.outmode, &ai); #endif#ifndef NOXFERMEM if(param.usebuffer) { int s; while ((s = xfermem_get_usedspace(buffermem))) { struct timeval wait170 = {0, 170000}; buffer_ignore_lowmem(); if(param.verbose) print_stat(&fr,fr.num,s,&ai);#ifdef HAVE_TERMIOS if(param.term_ctrl) { long offset; if((offset=term_control(&fr,&ai))) { if((!rd->back_frame(rd, &fr, -offset)) && read_frame(&fr)) { debug1("seeked to %lu", fr.num); #ifdef GAPLESS if(param.gapless && (fr.lay == 3)) layer3_gapless_set_position(fr.num, &fr, &ai); #endif goto tc_hack; /* Doh! Gag me with a spoon! */ } else { error("seek failed!"); } } }#endif select(0, NULL, NULL, NULL, &wait170); } }#endif if(param.verbose) print_stat(&fr,fr.num,xfermem_get_usedspace(buffermem),&ai); #ifdef HAVE_TERMIOS if(param.term_ctrl) term_restore();#endif if (!param.quiet) { /* * This formula seems to work at least for * MPEG 1.0/2.0 layer 3 streams. */ int secs = get_songlen(&fr,fr.num); fprintf(stderr,"\n[%d:%02d] Decoding of %s finished.\n", secs / 60, secs % 60, filename); } rd->close(rd);#if 0 if(param.remote) fprintf(stderr,"@R MPG123\n"); if (remflag) { intflag = FALSE; remflag = FALSE; }#endif if (intflag) {/* * When HAVE_TERMIOS is defined, there is 'q' to terminate a list of songs, so * no pressing need to keep up this first second SIGINT hack that was too * often mistaken as a bug. [dk] * ThOr: Yep, I deactivated the Ctrl+C hack for active control modes. */#if !defined(WIN32) && !defined(GENERIC)#ifdef HAVE_TERMIOS if(!param.term_ctrl)#endif { gettimeofday (&now, NULL); secdiff = (now.tv_sec - start_time.tv_sec) * 1000; if (now.tv_usec >= start_time.tv_usec) secdiff += (now.tv_usec - start_time.tv_usec) / 1000; else secdiff -= (start_time.tv_usec - now.tv_usec) / 1000; if (secdiff < 1000) break; }#endif intflag = FALSE;#ifndef NOXFERMEM if(param.usebuffer) buffer_resync();#endif } } /* end of loop over input files */ clear_icy(); exit_id3(); /* free id3 memory */#ifndef NOXFERMEM if (param.usebuffer) { buffer_end(); xfermem_done_writer (buffermem); waitpid (buffer_pid, NULL, 0); xfermem_done (buffermem); } else {#endif audio_flush(param.outmode, &ai); free (pcm_sample);#ifndef NOXFERMEM }#endif switch(param.outmode) { case DECODE_AUDIO: audio_close(&ai); break; case DECODE_WAV: wav_close(); break; case DECODE_AU: au_close(); break; case DECODE_CDR: cdr_close(); break; } if(!param.remote) free_playlist(); return 0;}static void print_title(FILE *o){ fprintf(o, "High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3\n"); fprintf(o, "\tversion %s; written and copyright by Michael Hipp and others\n", PACKAGE_VERSION); fprintf(o, "\tfree software (LGPL/GPL) without any warranty but with best wishes\n");}static void usage(int err) /* print syntax & exit */{ FILE* o = stdout; if(err) { o = stderr; fprintf(o, "You made some mistake in program usage... let me briefly remind you:\n\n"); } print_title(o); fprintf(o,"\nusage: %s [option(s)] [file(s) | URL(s) | -]\n", prgName); fprintf(o,"supported options [defaults in brackets]:\n"); fprintf(o," -v increase verbosity level -q quiet (don't print title)\n"); fprintf(o," -t testmode (no output) -s write to stdout\n"); fprintf(o," -w <filename> write Output as WAV file\n"); fprintf(o," -k n skip first n frames [0] -n n decode only n frames [all]\n"); fprintf(o," -c check range violations -y DISABLE resync on errors\n"); fprintf(o," -b n output buffer: n Kbytes [0] -f n change scalefactor [32768]\n"); fprintf(o," -r n set/force samplerate [auto] -g n set audio hardware output gain\n"); fprintf(o," -os,-ol,-oh output to built-in speaker,line-out connector,headphones\n"); #ifdef NAS fprintf(o," -a d set NAS server\n"); #elif defined(SGI) fprintf(o," -a [1..4] set RAD device\n"); #else fprintf(o," -a d set audio device\n"); #endif fprintf(o," -2 downsample 1:2 (22 kHz) -4 downsample 1:4 (11 kHz)\n"); fprintf(o," -d n play every n'th frame only -h n play every frame n times\n"); fprintf(o," -0 decode channel 0 (left) only -1 decode channel 1 (right) only\n"); fprintf(o," -m mix both channels (mono) -p p use HTTP proxy p [$HTTP_PROXY]\n"); #ifdef HAVE_SCHED_SETSCHEDULER fprintf(o," -@ f read filenames/URLs from f -T get realtime priority\n"); #else fprintf(o," -@ f read filenames/URLs from f\n"); #endif fprintf(o," -z shuffle play (with wildcards) -Z random play\n"); fprintf(o," -u a HTTP authentication string -E f Equalizer, data from file\n"); #ifdef GAPLESS fprintf(o," -C enable control keys --gapless skip junk/padding in some mp3s\n"); #else fprintf(o," -C enable control keys\n"); #endif fprintf(o," -? this help --version print name + version\n"); fprintf(o,"See the manpage %s(1) or call %s with --longhelp for more parameters and information.\n", prgName,prgName); safe_exit(err);}static void want_usage(char* arg){ usage(0);}static void long_usage(int err){ FILE* o = stdout; if(err) { o = stderr; fprintf(o, "You made some mistake in program usage... let me remind you:\n\n"); } print_title(o); fprintf(o,"\nusage: %s [option(s)] [file(s) | URL(s) | -]\n", prgName); fprintf(o,"\ninput options\n\n"); fprintf(o," -k <n> --skip <n> skip n frames at beginning\n"); fprintf(o," -n --frames <n> play only <n> frames of every stream\n"); fprintf(o," -y --resync DISABLES resync on error\n"); fprintf(o," -p <f> --proxy <f> set WWW proxy\n"); fprintf(o," -u --auth set auth values for HTTP access\n"); fprintf(o," -@ <f> --list <f> play songs in playlist <f> (plain list, m3u, pls (shoutcast))\n"); fprintf(o," -l <n> --listentry <n> play nth title in playlist; show whole playlist for n < 0\n"); fprintf(o," -z --shuffle shuffle song-list before playing\n"); fprintf(o," -Z --random full random play\n"); fprintf(o,"\noutput/processing options\n\n"); fprintf(o," -a <d> --audiodevice <d> select audio device\n"); fprintf(o," -s --stdout write raw audio to stdout (host native format)\n"); fprintf(o," -S --STDOUT play AND output stream (not implemented yet)\n"); fprintf(o," -w <f> --wav <f> write samples as WAV file in <f> (- is stdout)\n"); fprintf(o," --au <f> write samples as Sun AU file in <f> (- is stdout)\n"); fprintf(o," --cdr <f> write samples as CDR file in <f> (- is stdout)\n"); fprintf(o," --reopen force close/open on audiodevice\n"); fprintf(o," -g --gain set audio hardware output gain\n"); fprintf(o," -f <n> --scale <n> scale output samples (soft gain, default=%li)\n", outscale); fprintf(o," --rva-mix,\n"); fprintf(o," --rva-radio use RVA2/ReplayGain values for mix/radio mode\n"); fprintf(o," --rva-album,\n"); fprintf(o," --rva-audiophile use RVA2/ReplayGain values for album/audiophile mode\n"); fprintf(o," --reopen force close/open on audiodevice\n"); fprintf(o," -0 --left --single0 play only left channel\n"); fprintf(o," -1 --right --single1 play only right channel\n"); fprintf(o," -m --mono --mix mix stereo to mono\n"); fprintf(o," --stereo duplicate mono channel\n"); fprintf(o," -r --rate force a specific audio output rate\n"); fprintf(o," -2 --2to1 2:1 downsampling\n"); fprintf(o," -4 --4to1 4:1 downsampling\n"); fprintf(o," --8bit force 8 bit output\n"); fprintf(o," -d --doublespeed play only every second frame\n"); fprintf(o," -h --halfspeed play every frame twice\n"); fprintf(o," --equalizer exp.: scales freq. bands acrd. to 'equalizer.dat'\n"); #ifdef GAPLESS fprintf(o," --gapless remove padding/junk added by encoder/decoder\n"); #endif fprintf(o," (experimental, needs Lame tag, layer 3 only)\n"); fprintf(o," -o h --headphones (aix/hp/sun) output on headphones\n"); fprintf(o," -o s --speaker (aix/hp/sun) output on speaker\n"); fprintf(o," -o l --lineout (aix/hp/sun) output to lineout\n"); fprintf(o," -b <n> --buffer <n> set play buffer (\"output cache\")\n"); fprintf(o,"\nmisc options\n\n"); fprintf(o," -t --test only decode, no output (benchmark)\n"); fprintf(o," -c --check count and display clipped samples\n"); fprintf(o," -v[*] --verbose increase verboselevel\n"); fprintf(o," -q --quiet quiet mode\n"); #ifdef HAVE_TERMIOS fprintf(o," -C --control enable terminal control keys\n"); #endif #ifndef GENERIG fprintf(o," --title set xterm/rxvt title to filename\n"); #endif fprintf(o," --long-tag spacy id3 display with every item on a separate line\n"); fprintf(o," -R --remote generic remote interface\n"); fprintf(o," --remote-err use stderr for generic remote interface\n"); #ifdef HAVE_SETPRIORITY fprintf(o," --aggressive tries to get higher priority (nice)\n"); #endif #ifdef HAVE_SCHED_SETSCHEDULER fprintf(o," -T --realtime tries to get realtime priority\n"); #endif #ifdef USE_3DNOW fprintf(o," --test-3dnow display result of 3DNow! autodetect and exit\n"); fprintf(o," --force-3dnow force use of 3DNow! optimized routine\n"); fprintf(o," --no-3dnow force use of floating-pointer routine\n"); #endif fprintf(o," -? --help give compact help\n"); fprintf(o," --longhelp give this long help listing\n"); fprintf(o," --version give name / version string\n"); fprintf(o,"\nSee the manpage %s(1) for more information.\n", prgName); safe_exit(err);}static void want_long_usage(char* arg){ long_usage(0);}static void give_version(char* arg){ fprintf(stdout, PACKAGE_NAME" "PACKAGE_VERSION"\n"); safe_exit(0);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -