mpc123-0.2.4/0002755000175000000620000000000010771026613011635 5ustar bucciastaffmpc123-0.2.4/TODO0000644000175000000620000000106110771022476012324 0ustar bucciastaffmpc123 TODO list Started: Fernando Vezzosi , Sat Dec 3 22:48:02 CET 2005 For version 1.0: - command line option to loop playlist (repeat functionality) - show playback times at runtime (maybe only in -v output) - make it usable by frontends - add all commands like forward, backward, pause, .. - conform to other similar programs, but only if there is a widely-used way - make a decent localization system, and localize in few languages Hypotesis: - maybe create a logo ? - add support for id3 tags ? (do mpc files support it?) mpc123-0.2.4/ao.c0000644000175000000620000001526010771022476012405 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mpc123.h" #include typedef struct mpc123_ao_data { ao_device * ao_dev; void * output_buffer; unsigned int output_buffer_size; } mpc123_ao_data; /* free a linked-list of ao_option's */ static void walk_free(ao_option * elem){ if(elem->next){ walk_free(elem->next); } free(elem); } void mpc123_choose_default_dev_by_driver(){ /* device is already specified? then we don't need work here */ if ( options.ao_dev ){ debugf("WARNING: device already present (\"%s\"), but they want me" " to find another one .. why ??", options.ao_dev); return; } /* default device for oss is /dev/dsp */ if ( !strcmp(options.ao_driver, "oss") ){ options.ao_dev="/dev/dsp"; return; } /* this matches "alsa" as well as "alsa09", use default card */ if ( !strncmp(options.ao_driver, "alsa", strlen("alsa")) ){ options.ao_dev="default"; return; } /* other drivers don't need special device specs */ } int mpc123_ao_init(void ** d, mpc_streaminfo * streaminfo){ int ao_drvnum=-1; ao_sample_format ao_fmt; ao_info * ao_dinfo=NULL; ao_option * opt_head=NULL; int i; *d=malloc(sizeof(mpc123_ao_data)); mpc123_ao_data * data=(mpc123_ao_data *) *d; data->output_buffer=NULL; data->output_buffer_size=0U; ao_initialize(); ao_drvnum=ao_driver_id(options.ao_driver); if( ao_drvnum < 0 ) die("No suitable output driver\n"); /* set esd options */ if( !strcmp(options.ao_driver, "esd") ){ opt_head=malloc(sizeof(ao_option)); opt_head->key="esd"; opt_head->value=options.ao_dev; opt_head->next=NULL; debugf("[ESD] ao_opts{%s}=%s", opt_head->key, opt_head->value); } /* set oss options */ if( !strcmp(options.ao_driver, "oss") ){ opt_head=malloc(sizeof(ao_option)); opt_head->key="dsp"; opt_head->value=options.ao_dev; opt_head->next=NULL; debugf("[OSS] ao_opts{%s}=%s", opt_head->key, opt_head->value); } /* set alsa options */ if( !strcmp(options.ao_driver, "alsa09") ){ opt_head=malloc(sizeof(ao_option)); opt_head->key="dev"; opt_head->value=options.ao_dev; opt_head->next=NULL; debugf("[ALSA] ao_opts{%s}=%s", opt_head->key, opt_head->value); } ao_dinfo=ao_driver_info(ao_drvnum); debugf(" type=%s", ao_dinfo->type == AO_TYPE_LIVE ? "live" : ao_dinfo->type == AO_TYPE_FILE ? "file" : "unknown"); debugf(" name=%s", ao_dinfo->name); debugf(" sname=%s", ao_dinfo->short_name); debugf(" comment=%s", ao_dinfo->comment); debug(" options={"); for(i=0; ioption_count; i++){ debugf(" %s", ao_dinfo->options[i]); } debug("}"); sayf(2, "Using ao driver \"%s\" (libao id %d)\n", ao_dinfo->name, ao_drvnum); /* initialize ao_format struct */ /* XXX VERY WRONG */ ao_fmt.bits=16; /*tmp_stream_info.average_bitrate;*/ ao_fmt.rate=streaminfo->sample_freq; ao_fmt.channels=streaminfo->channels; ao_fmt.byte_format=AO_FMT_LITTLE; /* output audio params */ debugf(" bits = %d", ao_fmt.bits); debugf(" rate = %d", ao_fmt.rate); debugf(" channels = %d", ao_fmt.channels); debugf(" byte_format = %d", ao_fmt.byte_format); #if 0 if(strcmp(options.ao_driver,"wav") /* ao_driver IS NOT wav */ && strcmp(options.ao_driver,"raw") /* NOR raw */ && strcmp(options.ao_driver,"au")){ /* NOR au */ #endif if(ao_dinfo->type == AO_TYPE_LIVE){ /* live playing! */ data->ao_dev=ao_open_live(ao_drvnum, &ao_fmt, opt_head); }else{ /* output to file (act as a decoder) */ data->ao_dev=ao_open_file(ao_drvnum, options.foutput, TRUE, &ao_fmt, NULL); } if( !data->ao_dev ){ dief(_("Could not open audio output: [%d] %s\n"), errno, strerror(errno)); } if(opt_head) walk_free(opt_head); return 0; } #ifdef MPC_FIXED_POINT inline static int shift_signed(MPC_SAMPLE_FORMAT val, int shift) { if (shift > 0) val <<= shift; else if (shift < 0) val >>= -shift; return (int) val; } #endif /* play buffer[samples * 2] on device data->ao_dev */ int mpc123_ao_play(void * d, MPC_SAMPLE_FORMAT * buffer, unsigned samples){ mpc123_ao_data * data=(mpc123_ao_data *) d; unsigned n; int val; unsigned char * output; unsigned bytes=samples * 2; /* 16 bit == 2 bytes */ const unsigned pSize = 16; const int clip_min = -1 << (pSize - 1); const int clip_max = (1 << (pSize - 1)) - 1; const int float_scale = 1 << (pSize - 1); /* if the buffer is already allocated, use it */ output = data->output_buffer ? (unsigned char *) data->output_buffer : (data->output_buffer = (unsigned char *) malloc(bytes)); /* realloc if the size changed */ if(data->output_buffer_size != bytes){ debugf("osize=%d nsize=%d", data->output_buffer_size, bytes); output = data->output_buffer = realloc(data->output_buffer, bytes); data->output_buffer_size = bytes; } if(!output){ dief(_("Out of memory (needed 0x%08x bytes)\n"), bytes); } /* code stolen from xmms-musepack */ for (n = 0; n < samples; n++) { #ifdef MPC_FIXED_POINT val = shift_signed(buffer[n], pSize - MPC_FIXED_POINT_SCALE_SHIFT); #else /* adjust gain */ buffer[n] *= options.volume; /* convert to pcm */ val = (int) (buffer[n] * float_scale); #endif if (val < clip_min) val = clip_min; else if (val > clip_max) val = clip_max; /* store pcm bytes in buffer, in the right order */ output[n * 2] = (unsigned char) (val & 0xFF); output[n * 2 + 1] = (unsigned char) ((val >> 8) & 0xFF); } /* ao_play(ao_device *, void *, uint_32); */ val=ao_play(data->ao_dev, (void *)output, bytes); return val; } /* called when done playing */ int mpc123_ao_done(void * d){ mpc123_ao_data * data=(mpc123_ao_data *) d; ao_close(data->ao_dev); free(data); return 0; } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/Makefile0000644000175000000620000000370410771022476013302 0ustar bucciastaff#!/usr/bin/make -f # mpc123 - Musepack Console audio player # Copyright (C) 2005-2007 Fernando Vezzosi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. CC := $(shell which colorgcc || which cc) TAGSPRG := ctags CFLAGS += -Wall LDFLAGS += -lao -lmpcdec # in case of DEBUG, we shall add these flags ifneq ($(DEBUG), ) CPPFLAGS += -DDEBUG=$(DEBUG) CFLAGS += -ggdb LDFLAGS += -rdynamic # LDFLAGS += -lefence # LDFLAGS += -lmudflap else CFLAGS += -O2 endif TARGET := mpc123 MAJOR := 0 MINOR := 2 POS := $(wildcard LOCALES/*/LC_MESSAGES/*.po) MOS := $(POS:%.po=%.mo) # very rudimentary dependency checking DEPS := $(patsubst %.c, %.o, $(filter-out $(TARGET).c, $(wildcard *.c))) # exclude gnuarch files, precious files and .dotfiles TAR_EXCLUDED += \\{arch} .arch-ids $(wildcard ++*) $(wildcard .?*) $(TARGET): $(DEPS) $(TARGET).c $(MOS) @echo Building mpc123 version $(MAJOR).$(MINOR) ... $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(DEPS) $(TARGET).c .PHONY: clean tarball clean: $(RM) tags $(DEPS) $(TARGET) $(MOS) tags: $(wildcard *.[ch]) $(TAGSPRG) -R --exclude=\{arch} ./ tarball: clean cd ../ &&\ tar zcf ./mpc123-$$(date "+%Y%m%d").tar.gz $(foreach f, ${TAR_EXCLUDED}, --exclude=${f}) $${OLDPWD##*/} $(MOS): $(POS) $(foreach po, $(POS), msgfmt $(po) -o $(po:%.po=%.mo);) mpc123-0.2.4/playlist.c0000644000175000000620000001220510771026605013641 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include "mpc123.h" /* populate playlist from file */ int populate_playlist_from_file(playlist_t *pl, const char *fname){ FILE *fd = fopen(fname, "r"); char *strFile; size_t strSize = 128; int sl,i=0; if(!fd) dief("Could not open playlist \"%s\": %s\n", fname, strerror(errno)); /* allocating initial buffer for getline*/ strFile = (char *)malloc(strSize); /* allocating initial playlist */ pl->files = (char **)malloc(0); while(getline(&strFile, &strSize, fd) != -1){ /* get a playlist element */ sl=strlen(strFile); strFile[sl-1] = '\0'; /* remove \n */ if(sl==1) /* empty line*/ continue; debugf("Read string: \"%s\"", strFile); /* allocate and strcpy each element */ pl->files = realloc(pl->files, (i+1)*sizeof(char*)); pl->files[i]=(char*)malloc(sl+1); strncpy(pl->files[i], strFile, sl); debugf(" \"%s\"", pl->files[i]); i++; } pl->files[i]=NULL; /* insert info about playlist length */ pl->n_elems=i; if(options.verbosity) printf("Playlist has %d elements\n", pl->n_elems); fclose(fd); free(strFile); return 0; } /* populate array from argv[optind], n elements */ int populate_playlist_from_argv(playlist_t * pl, char ** argv, int optind, int n){ int i=0; int sl=0; debugf("before black magic: argv[0]=\"%s\", optind=%d, n=%d", argv[0], optind, n); /* black magic */ argv=&argv[optind]; debugf("after black magic: argv[0]=\"%s\", optind=%d, n=%d", argv[0], optind, n); /* allocate main array (n elements + NULL) */ pl->files=(char **)malloc(sizeof(char*) * n+1); /* scramble playlist */ if(options.shuffle && !options.random){ i = shuffle(pl->files, n, argv); debug("shuffle done"); } else { /* otherwise just allocate and strcpy each element */ for(i=0; ifiles[i]=(char*)malloc(sl+1); strncpy(pl->files[i], argv[i], sl+1); debugf(" \"%s\"", pl->files[i]); } } pl->files[i]=NULL; /* insert info about playlist length */ pl->n_elems=i; sayf(2, "Playlist has %d elements\n", pl->n_elems); return 0; } /* do the real job: * - select next file to play * - consider options */ int do_play_playlist(playlist_t *pl){ reader_data data; mpc_reader * mpc123_general_reader; int ret=0; int current=0; /* we play pl->files[current] */ if(options.random){ srand(time(NULL)); /* in case we want to use rand() */ current=rand() % pl->n_elems; /* first item to be played */ } /* main playing loop */ while(1){ if(!pl->files[current]) return 1; sayf(1, "Playing Musepack audio stream from \"%s\"...\n", pl->files[current]); data.length=0; data.curr_pos=0; if( (reader_choose_and_prepare(pl->files[current], &mpc123_general_reader, &data)) == 0){ /* play it ;) */ ret=do_play_stream(mpc123_general_reader, &data); debugf("Stream play returned [%d] %s", ret, ret ? " !!" : ""); /* clean up (close fds, etc..) */ do_cleanup_stream(mpc123_general_reader, &data); }else{ sayf(0, "Error choosing method for stream: \"%s\"\n", pl->files[current]); } /* couldn't play the stream; it's likely * we won't be able to play the next either */ if(ret) break; /* no more stuff to play? break; */ debugf("random=%d, pl->files[%d+1]=\"%s\", willstop=%d", options.random, current, pl->files[current+1], mpc123_flag_isset(MPC123_FL_STOP)); if((!options.random && !pl->files[current+1]) || mpc123_flag_isset(MPC123_FL_STOP) ) break; /* select next playlist element */ if(options.random){ current=rand() % pl->n_elems; }else{ current++; } } return 0; } /* free playlist mallocated memory */ int free_playlist(playlist_t *pl){ int i; for(i=pl->n_elems;i!=0;i--){ debugf("Freeing Memory: %s", pl->files[i-1]); free(pl->files[i-1]); /* free each single elements */ } free(pl->files); /* free main array */ return 0; } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/LICENSE0000644000175000000620000004310510771022476012646 0ustar bucciastaff GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. mpc123-0.2.4/README0000644000175000000620000001213010771022476012513 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2007 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ * Installation: !!! Compilation requires libmpcdec-dev and libao-dev; !!! Normal use requires libmpcdec and libao; You can find those packages in your apt repository: # apt-get install libmpcdec{3,-dev} libao{,-dev} Or on their respective websites: % links http://www.musepack.net/ % links http://xiph.org/ao/ * Downloading the bits: * Latest Development version (possibly heavily broken) Visit http://mpc123.sf.net/ for a detailed description * Latest Stable version Visit http://sf.net/projects/mpc123 to see released files, then click the download link * Compiling the bits: * Under GNU/Linux type ``make'' * Under other OSs: * type ``make'' * if any error occurs, please try to solve it and submit a patch for the Makefile or the sources At this point you should have a ``mpc123'' binary. Place it where you want it to live. * Use of the player: mpc123 can play files from command line arguments and from playlists. A brief usage message is shown if you use the -h flag. There are currently two methods to play a given mpc file: * Specify it on the command line Just type mpc123 /path/to/file /example/stream.mpc mpc123 will play the files in the specified order * Include it into a playlist file Just type mpc123 -@ /path/to/playlist mpc123 will play files specified in the file /path/to/playlist. The format is trivial (each line identifies a stream), you can easily generate a playlist with the find(1) command: find /path/to/musicroot -iname \*.mpc -fprint /path/to/playlist During playback, you can have the player pass to the next playlist element (or a random one if the -z or -Z options were specified), by sending SIGINT to the process (this usually happens with ^C). * Useful command line options Each -v option increases the program verbosity. The default verbosity is 0, which means mpc123 will produce output only in case of errors; The -g option modifies the output volume. Allowed values range from 0 (silent) to 100 (default value, sounds at full power); If you for example want to play at half the sample's original gain, just use "-g 50"; The -z option randomly sorts the playlist once in the program lifetime (it is called ``shuffle''); The -Z option selects a random playlist element each time (this feature instead is called ``random''); The -q option resets the verbosity level to its default 0; The -@ option requires an argument, specifying the path to the playlist; * AO (Audio Output) command line options These options control the behavior of the audio output layer; The -o option selects the desired audio output driver (defaults to "oss"). Examples: mpc123 -o oss -a /dev/dsp1 # to select the second OSS sound card mpc123 -o alsa09 # use alsa09 as output driver, sets the output device to "default" mpc123 -o esd # use the esd daemon for output (the daemon must be running, of course ..) mpc123 -o null # for debugging purposes, outputs nothing The -a option specifies the output device for the selected driver (defaults to "/dev/dsp") Of course -o and -a options are related. You _can_ use only the -o option to select the alsa09 (for example) driver, and the program will default the output device to some usable value ("/dev/dsp" for oss, "default" for alsa) * Hacking with mpc123 Before you start hacking with mpc123, be sure you can use tla or bazaar; a good starting point is the arch wiki at http://wiki.gnuarch.org/ When hacking (programming and testing mpc123), be sure to turn the debug flags on. This can be done in a couple of ways: 1 - % make DEBUG=1 .. compiler output .. % 2 - % export DEBUG=1 % make .. compiler output .. % The binary file ``mpc123'' will be compiled with debugging symbols enabled, and some useful debugging macros defined; the macros are: - debug() Is to be used to produce output with debugging activated. Takes only one argument, which is the string to print. - debugf() The same as debug(), only it takes a format string as its first argument. You can use it just like printf(). Both debugging macros automatically add a newline at the end of the given string, so you don't need to add "\n". # vi:tw=78: mpc123-0.2.4/LOCALES/0000755000175000000620000000000010771022476012720 5ustar bucciastaffmpc123-0.2.4/LOCALES/it/0000755000175000017500000000000010771022476013464 5ustar bucciabucciampc123-0.2.4/LOCALES/it/LC_MESSAGES/0000755000175000017500000000000010771022476015251 5ustar bucciabucciampc123-0.2.4/LOCALES/it/LC_MESSAGES/mpc123.po0000644000175000017500000001301410771022476016615 0ustar bucciabuccia# /* # * mpc123 - Musepack Console audio player # * Copyright (C) 2005 Fernando Vezzosi # * # * i18n support by Piero Bozzolo # * # * This program is free software; you can redistribute it and/or modify # * it under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2 of the License, or # * (at your option) any later version. # * # * This program is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # * GNU General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software Foundation, # * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # */ # Begin italian translation msgid "Using ao driver \"%s\" (libao id %d)\n" msgstr "Driver selezionato \"%s\" (libao id %d)\n" msgid "Could not open audio output: [%d] %s\n" msgstr "Impossibile aprire la periferica di output: [%d] %s\n" msgid "Out of memory (needed 0x%08x bytes)\n" msgstr "Memoria terminata (necessari 0x%08x bytes)\n" msgid "mpc123 version %d.%d.%d\n" msgstr "mpc123 versione %d.%d.%d\n" msgid "Options supported:\n" msgstr "Opzioni supportate:\n" msgid "\nUsage: %s [options] [file1 [file2 [..]]]\n\n" "Options supported:\n" " --verbose or -v Increase verbosity\n" " --quiet or -q Quiet mode (no title or boilerplate)\n" " --gain N or -g N Set gain (audio volume) to N (0-100)\n" " -o dt Set output devicetype to dt\n" " --audiodevice N or -a N Use N for audio-out\n" " --au N or -u N Use au file N for output\n" " --cdr N or -c N Use raw file N for output\n" " --wav N or -w N Use wave file N for output\n" " --list N or -@ N Use playlist N as list of Musepack files\n" " --random or -Z Play files randomly until interrupted\n" " --shuffle or -z Shuffle list of files before playing\n" " --help or -h Print this help screen\n" " --version or -V Print mpc123 version string\n" msgstr "\nUtilizzo: %s [opzioni] [file1 [file2 [..]]]\n\n" " --quiet or -q Modalita' silenziosa (nessun output a video)\n" " --verbose or -v Aumenta informazioni\n" " --gain N or -g N Imposta guadagno (volume audio) ad N (0-100)\n" " -o dt Imposta il tipo di device a dt\n" " --audiodevice N or -a N Utilizza n come device audio\n" " --au N or -u N Utilizza il formato file au N come output\n" " --cdr N or -c N Utilizza il formato file raw N come output\n" " --wav N or -w N Utilizza il formato file wav N come output\n" " --list N or -@ N Utilizza la playlist N come lista di file Musepack\n" " --random or -Z Riproduce i brani a caso\n" " --shuffle or -z Mescola la playlist\n" " --help or -h Visualizza questa schermata\n" " --version or -V Visualizza la versione di mpc123\n" msgid "Not a valid musepack file\n" msgstr "File musepack non valido\n" msgid "Error initializing decoder\n" msgstr "Errore nell'inizializzazione del decoder\n" msgid "Could not initialize audio library: error %d\n" msgstr "Impossibile inizializzare la libreria audio: error %d\n" msgid "End of file after %d samples" msgstr "Fine del file dopo %d parti" msgid "Error while decoding -- maybe corrupted data?\n" msgstr "Errore durante la decodifica -- dati corrotti?\n" msgid "Total samples decoded: %u\n" msgstr "Totale parti decodificate: %u\n" msgid "Couldn't open file \"%s\": [%d] %s\n" msgstr "Impossibile aprire il file \"%s\": [%d] %s\n" msgid "Unknown reason" msgstr "Errore sconosciuto" msgid "Segmentation Fault. Backtrace follows.\n" "NOTE: if you didn't compile with ``make DEBUG=1'', then\n" " * this info is probably mostly useless;\n" " * recompile with debug activated and try to crash\n" " * mpc123 again :)\n\n" msgstr "Errore di segmentazione. Segue analisi traccie.\n" "ATTENZIONE: Se non compili con ``make DEBUG=1'', queste\n" " * informazioni saranno del tutto inutili;\n" " * ricompila mpc123 con il debugging attivato, e\n" " * prova a riprodurre l'errore :)\n\n" msgid "Aborting\n" msgstr "Annulando\n" msgid "Got signal %d.." msgstr "Ricevuto segnale %d.." msgid "Value %s out of range, try values between 0 and 100\n" msgstr "Il valore %s e` fuori intervallo, prova valori tra 0 e 100\n" msgid "Error populating playlist from file \"%s\": error %d\n" msgstr "Errore durante il riempimento della playlist dal file \"%s\": errore n. %d\n" msgid "Error populating playlist from command line: error %d\n" msgstr "Errore durante il riempimento della playlist dalla linea di comando: errore n. %d\n" msgid "Could not open playlist \"%s\": %s\n" msgstr "Impossibile aprire la playlist \"%s\": %s\n" msgid "Playlist has %d elements\n" msgstr "La playlist ha %d elementi\n" msgid "Playing Musepack audio stream from \"%s\"...\n" msgstr "Riproduzione traccia Musepack da \"%s\"...\n" msgid "Stream play returned [%d] %s" msgstr "La riproduzione dello stream ha ritornato [%d] %s" msgid "Error choosing method for stream: \"%s\"\n" msgstr "Errore durante la scelta del metodo di stream: \"%s\"\n" msgid "Can't open %s, unable to shuffle the playlist" msgstr "Impossibile aprire %s, impossibile mescolare la playlist" msgid "Can't read 4 bytes from %s\n" msgstr "Non posso leggere 4 bytes da %s\n" mpc123-0.2.4/shuffle.c0000644000175000000620000000330010771022476013432 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Daniele Sempione * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include "mpc123.h" int shuffle(char **files, int n, char **argv) { char *shuffletable; unsigned int i, sl, shuffind; srand(time(NULL)); shuffletable = (char *) calloc(n, sizeof(char)); for(i=0; i; Fernando Vezzosi made some edits mpc123-0.2.4/mpc123.c0000644000175000000620000001524110771022476013012 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* is this portable ? */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include "mpc123.h" #ifdef DEBUG # include #endif #define ARG_YES 1 #define ARG_NO 0 #define ARG_MAYBE 2 /* (hopefully) sane defaults */ opts_t options={ .shuffle=0, .random=0, .verbosity=0, .foutput=NULL, .playlist=NULL, .ao_driver=NULL, .ao_dev=NULL, .volume=1.0 }; static void version(){ fprintf(stderr, _("mpc123 version %d.%d.%d\n"), VERS_MAJOR, VERS_MINOR, VERS_REV); fprintf(stderr, "Copyright %s\n", COPYRIGHT); } static void usage(const char *name){ version(); sayf(0, "\nUsage: %s [options] [file1 [file2 [..]]]\n\n" "Options supported:\n" " --verbose or -v Increase verbosity\n" " --quiet or -q Quiet mode (no title or boilerplate)\n" " --gain N or -g N Set gain (audio volume) to N (0-100)\n" " -o dt Set output devicetype to dt\n" " --audiodevice N or -a N Use N for audio-out\n" " --au N or -u N Use au file N for output\n" " --cdr N or -c N Use raw file N for output\n" " --wav N or -w N Use wave file N for output\n" " --list N or -@ N Use playlist N as list of Musepack files\n" " --random or -Z Play files randomly until interrupted\n" " --shuffle or -z Shuffle list of files before playing\n" " --help or -h Print this help screen\n" " --version or -V Print mpc123 version string\n", name); } int main(int argc, char ** argv){ int c=0; int ret=0; playlist_t pl; /* mpc_bool_t mpc_ret=FALSE;*/ struct option myOpt[] = { {"verbose", ARG_NO, 0, 'v'}, {"quiet", ARG_NO, 0, 'q'}, {"gain", ARG_YES, 0, 'g'}, {"audiodevice", ARG_YES, 0, 'a'}, {"au", ARG_YES, 0, 'u'}, {"cdr", ARG_YES, 0, 'c'}, {"wav", ARG_YES, 0, 'w'}, {"list", ARG_YES, 0, '@'}, {"random", ARG_NO, 0, 'Z'}, {"shuffle", ARG_NO, 0, 'z'}, {"help", ARG_NO, 0, 'h'}, {"version", ARG_NO, 0, 'V'}, {NULL, 0, 0, '\0'} }; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #ifdef DEBUG /* see glibc-doc, chapter "Debugging Memory Allocation" * for the use of mcheck.h, mtrace(), MALLOC_TRACE and mtrace(1); */ mtrace(); debugf("mpc123 compiled with DEBUG=%d enabled", DEBUG); if(!getenv("MALLOC_TRACE")){ debug("WARNING: you have not set a MALLOC_TRACE destination file"); }else{ debug("* * malloc_trace activated; to check mpc123 for memory leaks,"); debugf("* * type the following command: \"mtrace %s %s\"", argv[0], getenv("MALLOC_TRACE")); } #endif while ((c=getopt_long(argc, argv, _GETOPT_FLAGS, myOpt, NULL)) != -1){ switch(c){ case 'z': /* shuffle the pl once */ options.shuffle=1; break; case 'Z': /* choose a random entry from pl each time */ options.random=1; break; case 'v': /* be logorroical */ options.verbosity++; break; case 'q': /* be asocial */ options.verbosity=0; break; case '@': /* playlist */ options.playlist=optarg; break; case 'o': /* output driver */ options.ao_driver=optarg; break; case 'a': /* libao device to use */ options.ao_dev=optarg; break; case 'w': /* output to .wav */ options.ao_driver="wav"; options.foutput=optarg; break; case 'u': /* output to .au */ options.ao_driver="au"; options.foutput=optarg; break; case 'c': /* output to raw pcm */ options.ao_driver="raw"; options.foutput=optarg; case 'g': /* set gain */ options.volume=atof(optarg)/100.0; if(options.volume<0.0 || options.volume>1.0){ dief("Value %s out of range, try values between 0 and 100\n", optarg); } break; case 'V': version(); exit(0); break; case 'h': /* need help */ default: usage(argv[0]); exit(1); } } /* intialize singals' hendler */ mpc123_initsigh(); /* set default ao_driver and ao_device if none were * specified on the command line */ if( !options.ao_driver ){ options.ao_driver="oss"; } if( !options.ao_dev ){ /* if the driver is set, but not the output device, use * the default devices */ mpc123_choose_default_dev_by_driver(); } /* no playlist? and no files on the command line either? too bad! */ if( !(argv[optind] || options.playlist) ){ usage(argv[0]); exit(1); } say(1, COPYRIGHT_NOTICE "\n"); /* dump options */ debugf("opts.shuffle=%d\n" " opts.random=%d\n" " opts.verbosity=%d\n" " opts.foutput=\"%s\"\n" " opts.playlist=\"%s\"\n" " opts.ao_driver=\"%s\"\n" " opts.ao_dev=\"%s\"\n" " opts.volume=%f", options.shuffle, options.random, options.verbosity, options.foutput, options.playlist, options.ao_driver, options.ao_dev, options.volume); /* optind? :) */ debugf("argv[optind (%d)]=\"%s\"", optind, argv[optind]); /* prepare the playlist */ if(options.playlist){ if((ret=populate_playlist_from_file(&pl, options.playlist))) dief("Error populating playlist from file \"%s\": error %d\n", options.playlist, ret); }else{ if((ret=populate_playlist_from_argv(&pl, argv, optind, argc-optind))) dief("Error populating playlist from command line: error %d\n", ret); } do_play_playlist(&pl); free_playlist(&pl); return 0; } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/mpc123.h0000644000175000000620000001217210771022476013017 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _MPC123_H # define _MPC123_H 1 # include # include # include # include # include # include # include # include # ifndef LOCALEDIR # define LOCALEDIR "/usr/share/locale" /* this is the Debian default */ # endif # define PACKAGE "mpc123" # define VERS_NAME "mpc123" # define COPYRIGHT "(C) 2005-2008 Fernando Vezzosi " /* don't touch these fields, as they are automatically * changed by the Makefile building process */ # define VERS_MAJOR 0 # define VERS_MINOR 2 # define VERS_REV 4 # define COPYRIGHT_NOTICE VERS_NAME " Copyright " COPYRIGHT "\n" \ "This is free software, meaning it comes under the terms of the\n" \ "GNU General Public License (GNU GPL) version 2 or above, see\n" \ "http://www.gnu.org/ and http://mpc123.sourceforge.net/ for \n" \ "+ info about the lack of any kind of warranty,\n" \ "+ source code, and\n" \ "+ license details\n" # define _GETOPT_FLAGS "zZvhqV@:o:a:g:w:u:c:" # define _(x) gettext(x) /* # define _(x) (x) */ /* macros for debugging output. * they add the trailing newline. */ # ifdef DEBUG # define debug(x) printf(" " x "\n") # define debugf(x, ...) printf(" " x "\n", __VA_ARGS__) # else # define debug(x) do { } while (0) # define debugf(x, ...) do { } while (0) # endif /* macros for normal output. * use these instead of printf()s */ # define say(n, txt) do { \ if(options.verbosity >= n){ \ fprintf(stdout, _(txt)); \ } \ } while (0) # define sayf(n, txt, ...) do { \ if(options.verbosity >= n){ \ fprintf(stdout, _(txt), __VA_ARGS__); \ } \ } while (0) /* macros for necrophiles. they add the trailing newline. * die, die with format */ # define die(x) do { \ fprintf(stderr, _(x)); \ return 1; \ } while (0) # define dief(x, ...) do { \ fprintf(stderr, _(x), __VA_ARGS__); \ return 1; \ } while (0) typedef struct opts_t { int shuffle; /* produces a randomly-sorted playlist */ int random; /* playlist entries are randomly chosen */ unsigned int verbosity; /* program verbosity */ char * foutput; /* target file for file output (wav, au...)*/ char * playlist; /* list of files to play */ char * ao_driver; /* libao driver name eg "oss" "alsa09" "esd" */ char * ao_dev; /* libao output device eg "/dev/dsp" "default" */ float volume; /* volume multiplier. the output gets multiplied by * this, so it is a float going from 0 (mute volume) * to 1 (100% volume) */ /* runtime flags */ uint32_t flags; /* 32 bit space for flags. see MPC123_FL_* */ } opts_t; # define MPC123_FL_PLAYNEXT (1 << 0) # define MPC123_FL_STOP (1 << 1) # define mpc123_flag_set(flag) do { \ options.flags |= (flag); \ debugf("flags now look like 0x%08x", options.flags); \ } while (0) # define mpc123_flag_unset(flag) do { \ options.flags &= ~(flag); \ debugf("flags now look like 0x%08x", options.flags); \ } while (0) # define mpc123_flag_isset(flag) ((options.flags & (flag)) ? 1 : 0) typedef struct playlist { char **files; /* *files[] */ /* the file list terminates when (pl->files[i] == NULL) */ int n_elems; } playlist_t; /* this is passed between reader functions */ typedef struct reader_data { int fd; unsigned int length; off_t curr_pos; } reader_data; /* global data */ mpc_reader mpc123_file_reader; opts_t options; /* function declaration */ /* reader.c */ int reader_choose_and_prepare(const char *, mpc_reader **, reader_data *); void do_cleanup_stream(mpc_reader *, reader_data *); /* player.c */ int do_play_stream(mpc_reader *, reader_data *); /* playlist.c */ int populate_playlist_from_file(playlist_t *, const char *); int populate_playlist_from_argv(playlist_t *, char **, int, int); int do_play_playlist(playlist_t *); int free_playlist(playlist_t *); /* shuffle.c */ int shuffle(char **, int, char **); /* ao.c */ void mpc123_choose_default_dev_by_driver(void); int mpc123_ao_init(void **, mpc_streaminfo *); int mpc123_ao_play(void *, MPC_SAMPLE_FORMAT *, unsigned); int mpc123_ao_done(void *); /* signals.c */ void mpc123_initsigh(void); void signal_handler(int); #endif /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/AUTHORS0000644000175000000620000000064110771022476012707 0ustar bucciastaffThe mpc123 project is developed by the mpc123 development team :) which coordinates via the mpc123-devel mailing list mpc123-devel@lists.sourceforge.net The core developers (listed at http://mpc123.sourceforge.net/contact.php): - Fernando Vezzosi - Daniele Sempione - Piero Bozzolo Visit http://mpc123.sourceforge.net/ for more details; mpc123-0.2.4/player.c0000644000175000000620000000646110771022476013305 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include "mpc123.h" /* * do the actual playing job * things learned from libmpcdec/src/sample.cpp */ int do_play_stream(mpc_reader * the_reader, reader_data * data){ mpc_streaminfo tmp_stream_info; mpc_decoder mpc123_decoder; mpc_int32_t mpc_ret; mpc_uint32_t vbrAcc=0, vbrUpd=0; int played=0; void * ao_data=NULL; /* decode-phase stuff */ MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; unsigned decoded_samples=0, total_decoded=0; unsigned bytes_from_decoder=0; /* read file's streaminfo data */ mpc_streaminfo_init(&tmp_stream_info); if( (mpc_ret=mpc_streaminfo_read(&tmp_stream_info, the_reader)) != ERROR_CODE_OK){ debugf("mpc_streaminfo_read()=%d", mpc_ret); die("Not a valid musepack file\n"); } /* initialize decoder with the appropriate file reader */ mpc_decoder_setup(&mpc123_decoder, the_reader); if( !(mpc_ret=mpc_decoder_initialize(&mpc123_decoder, &tmp_stream_info)) ){ debugf("mpc_decoder_initialize()=%d", mpc_ret); die("Error initializing decoder\n"); } if( mpc123_ao_init(&ao_data, &tmp_stream_info) != 0 ){ dief("Could not initialize audio library: error %d\n", errno); } /* decoding loop */ while(1){ decoded_samples=mpc_decoder_decode(&mpc123_decoder, buffer, &vbrAcc, &vbrUpd); if( !decoded_samples ){ /* eof */ debugf("End of file after %d samples", total_decoded); break; } if( decoded_samples == -1 ){ /* decoding error */ debug("Error decoding stream."); say(0, "Error while decoding -- maybe corrupted data?\n"); break; } /* debug(" <%d %d %d>", vbrAcc, vbrUpd, vbrUpd * 44100 / 1152 / 100);*/ total_decoded += decoded_samples; bytes_from_decoder = decoded_samples * sizeof(float) * 2; played=mpc123_ao_play(ao_data, (void *)buffer, decoded_samples * 2); /* we can't play */ if( !played ) break; /* next cycle if no flag is set */ if( options.flags == 0 ) continue; /* we don't want to play anymore .. */ if( mpc123_flag_isset(MPC123_FL_PLAYNEXT) ){ mpc123_flag_unset(MPC123_FL_PLAYNEXT); break; } /* break out of loop and leave flag handling to the upper level */ if( mpc123_flag_isset(MPC123_FL_STOP) ) break; } sayf(1, "Total samples decoded: %u\n", total_decoded); mpc123_ao_done(ao_data); return 0; } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/ChangeLog0000644000175000000620000003636210771022476013422 0ustar bucciastaff# do not edit -- automatically generated by arch changelog # arch-tag: automatic-ChangeLog--bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.1 # 2006-08-02 11:26:35 GMT Fernando Vezzosi patch-33 Summary: minor tweaks for release 0.2 Revision: mpc123--main--0.1--patch-33 * added info about the mailing list * cleaned Makefile out of useless stuff * updated TODO to reflect the actual TODO :) modified files: AUTHORS ChangeLog Makefile TODO 2006-08-02 10:20:20 GMT Daniele Sempione patch-32 Summary: major/minor fix Revision: mpc123--main--0.1--patch-32 * changed major/minor for the release :) modified files: ChangeLog Makefile mpc123.h 2006-07-31 18:32:42 GMT Fernando Vezzosi patch-31 Summary: exit if two sigints are sent in a short time window Revision: mpc123--main--0.1--patch-31 * now it exits if two ^C's are pressed in a rapid succession * fixed some bugs in the implementation ;) modified files: ChangeLog mpc123.c player.c playlist.c signals.c 2006-07-31 16:59:58 GMT Daniele Sempione patch-30 Summary: sighandler is thread-safe Revision: mpc123--main--0.1--patch-30 * now SIGINT is thread-safe * added support for terminating program via double SIGINT. now set to 0.7 secs, let's test it .. (still needed buccia's cleanup code, right now it only sets the flag) modified files: ChangeLog signals.c 2006-07-31 15:42:24 GMT Fernando Vezzosi patch-29 Summary: Updated documentation (README and manpage) Revision: mpc123--main--0.1--patch-29 * added info about esd * updated info about program behavior (SIGINT handling and choosing of default ao device) modified files: ChangeLog README mpc123.1 2006-07-31 15:11:09 GMT Daniele Sempione patch-28 Summary: added 2006 to some copyrights Revision: mpc123--main--0.1--patch-28 * ... modified files: ChangeLog Makefile README 2006-07-31 14:40:01 GMT Daniele Sempione patch-27 Summary: SIGINT = next song Revision: mpc123--main--0.1--patch-27 * now this feature works!! :)) * ported signal handling to sigaction new files: .arch-ids/signals.c.id signals.c modified files: ChangeLog mpc123.c mpc123.h 2006-07-31 13:54:37 GMT Fernando Vezzosi patch-26 Summary: reverted my stupid edits Revision: mpc123--main--0.1--patch-26 * i will not mess with a thing i shouldn't have been messing with again * i will not use wrong string format specifiers again sorry world modified files: ChangeLog mpc123.h reader_file.c 2006-07-31 13:47:38 GMT Fernando Vezzosi patch-25 Summary: fixed "next-song" bug, added vim modelines Revision: mpc123--main--0.1--patch-25 * fixed a dumb bug of my previous commit, which made the player skip all playlist elements, when it should have skipped only the currently played one.. * added the modeline "ft=c:tw=78:ts=2:et:cin" to all source files modified files: ChangeLog ao.c mpc123.c mpc123.h player.c playlist.c reader.c reader_file.c shuffle.c 2006-07-31 13:13:19 GMT Fernando Vezzosi patch-24 Summary: Added macro functions for flag handling Revision: mpc123--main--0.1--patch-24 * added flags global variable * added macros for flag handling * player loop stops if correct flags are set modified files: ChangeLog mpc123.h player.c 2006-07-30 10:17:38 GMT Daniele Sempione patch-23 Summary: Makefile comment Revision: mpc123--main--0.1--patch-23 * disables the -lefence linking option I forgot in the Makefile modified files: ChangeLog Makefile 2006-07-30 02:19:04 GMT Fernando Vezzosi patch-22 Summary: Fixes in view of new release Revision: mpc123--main--0.1--patch-22 * removed generation of locales in Makefile * better support for all sound systems, including working support for: - alsa09 - esd * decent libao defaults are now set at runtime * improved man page with content and appearance * improved debugging output * cosmetic changes modified files: ChangeLog Makefile ao.c mpc123.1 mpc123.c mpc123.h 2006-07-29 13:38:47 GMT Daniele Sempione patch-21 Summary: removed bugged l10n support Revision: mpc123--main--0.1--patch-21 * l10n was too buggy, we'll re-add in the future * updated copyrights' year modified files: ChangeLog Makefile ao.c mpc123.c mpc123.h player.c playlist.c reader.c reader_file.c shuffle.c 2006-07-28 13:33:57 GMT Fernando Vezzosi patch-20 Summary: fixed segfault when using inappropriate commandline flags Revision: mpc123--main--0.1--patch-20 * a crappy bug that lead to sigsegv upon invocation modified files: ChangeLog mpc123.c 2006-07-28 13:28:17 GMT Fernando Vezzosi patch-19 Summary: Revision: mpc123--main--0.1--patch-19 modified files: ChangeLog Makefile mpc123.h 2006-06-06 18:39:42 GMT Daniele Sempione patch-18 Summary: added '\n' to some strings Revision: mpc123--main--0.1--patch-18 * ... modified files: ChangeLog ao.c mpc123.c mpc123.h player.c reader.c 2006-03-22 18:07:36 GMT Fernando Vezzosi patch-17 Summary: Maybe corrected cheesy bug? Revision: mpc123--main--0.1--patch-17 * nasty bug in gettext implementation, we are trying to solve it -- Fernando Vezzosi modified files: ChangeLog Makefile ao.c mpc123.c mpc123.h 2006-02-20 16:33:04 GMT Piero Bozzolo patch-16 Summary: Added i18n support Revision: mpc123--main--0.1--patch-16 Added i18n support for all print function (but not for debug function), added it_IT locale, changed the makefile for compile all i18n po file. -- Piero Bozzolo new files: LOCALES/.arch-ids/=id LOCALES/it_IT/.arch-ids/=id LOCALES/it_IT/LC_MESSAGES/.arch-ids/=id LOCALES/it_IT/LC_MESSAGES/.arch-ids/mpc123.po.id LOCALES/it_IT/LC_MESSAGES/mpc123.po modified files: ChangeLog Makefile TODO mpc123.h new directories: LOCALES LOCALES/.arch-ids LOCALES/it_IT LOCALES/it_IT/.arch-ids LOCALES/it_IT/LC_MESSAGES LOCALES/it_IT/LC_MESSAGES/.arch-ids 2006-02-20 14:27:11 GMT Daniele Sempione patch-15 Summary: rewrote shuffle.c Revision: mpc123--main--0.1--patch-15 * fixed up shuffle.c modified files: ChangeLog mpc123.h shuffle.c 2006-02-18 11:35:47 GMT Piero Bozzolo patch-14 Summary: Revision: mpc123--main--0.1--patch-14 modified files: ChangeLog TODO mpc123.c mpc123.h 2006-01-20 22:55:10 GMT Fernando Vezzosi patch-13 Summary: Automatic versioning, debug warning Revision: mpc123--main--0.1--patch-13 * The mpc123 version (-V flag) is now updated automatically by the Makefile rules, and some awk/sed black magic * added a loud warning if one doesn't debug correctly :) -- Fernando Vezzosi modified files: ChangeLog Makefile mpc123.c mpc123.h 2006-01-20 16:24:55 GMT Fernando Vezzosi patch-12 Summary: Temporary fix for the infinite-loop bug when unable to play files Revision: mpc123--main--0.1--patch-12 * this is a quick hack, we will see how long it will last -- Fernando Vezzosi modified files: ChangeLog playlist.c 2006-01-17 15:25:29 GMT Fernando Vezzosi patch-11 Summary: Patch by Piotr 'Pedrito' Pass: ESD support Revision: mpc123--main--0.1--patch-11 * Added ESD support for audio output (thanks to Piotr 'Pedrito' Pass) -- Fernando Vezzosi modified files: ChangeLog TODO ao.c 2006-01-13 21:37:25 GMT Fernando Vezzosi patch-10 Summary: Beautified for 0.1.9 release Revision: mpc123--main--0.1--patch-10 * minor edit to documentation (namely AUTHORS file and man page) -- Fernando Vezzosi modified files: AUTHORS ChangeLog Makefile mpc123.1 2006-01-10 14:05:59 GMT Daniele Sempione patch-9 Summary: mv Authors AUTHORS Revision: mpc123--main--0.1--patch-9 .. modified files: ChangeLog renamed files: .arch-ids/Authors.id ==> .arch-ids/AUTHORS.id Authors ==> AUTHORS 2006-01-08 13:58:49 GMT Fernando Vezzosi patch-8 Summary: added --version|-V option Revision: mpc123--main--0.1--patch-8 * prints mpc123 version and quits -- Fernando Vezzosi modified files: ChangeLog TODO mpc123.c mpc123.h 2006-01-08 13:46:25 GMT Fernando Vezzosi patch-7 Summary: Completed manpage, cosmetic changes Revision: mpc123--main--0.1--patch-7 * removed "MP3" string around (wtf did it came from ??!?) * changed some output strings -- Fernando Vezzosi modified files: ChangeLog mpc123.1 mpc123.c 2006-01-08 12:45:50 GMT Fernando Vezzosi patch-6 Summary: added tla ChangeLog Revision: mpc123--main--0.1--patch-6 * hopefully automatized ChangeLog handling -- Fernando Vezzosi new files: .arch-ids/ChangeLog.id ChangeLog removed files: .arch-ids/ChangeLog.id ChangeLog modified files: TODO 2006-01-06 20:02:23 GMT Daniele Sempione patch-5 Summary: added manpage, grammar fixes Revision: mpc123--main--0.1--patch-5 * added mpc123.1 * fixed usage in mpc123.c * fixed minor version number (set to 1 -> version 0.1.0) new files: .arch-ids/mpc123.1.id mpc123.1 2006-01-06 19:58:35 GMT Daniele Sempione patch-4 Summary: added manpage, grammar fixes Revision: mpc123--main--0.1--patch-4 * added mpc123.1 * fixed usage in mpc123.c * fixed minor version number (set to 1 -> version 0.1.0) modified files: mpc123.c mpc123.h 2006-01-06 14:56:01 GMT Daniele Sempione patch-3 Summary: Added my name in `Authors' Revision: mpc123--main--0.1--patch-3 see above. modified files: Authors 2006-01-05 21:55:08 GMT Fernando Vezzosi patch-2 Summary: added Authors file Revision: mpc123--main--0.1--patch-2 * add your name there if you want to appear -- Fernando Vezzosi new files: .arch-ids/Authors.id Authors 2006-01-05 21:41:32 GMT Fernando Vezzosi patch-1 Summary: added ChangeLog Revision: mpc123--main--0.1--patch-1 * the automatic ChangeLog went away with the version change; fixed. -- Fernando Vezzosi modified files: ChangeLog TODO 2006-01-05 21:27:25 GMT Fernando Vezzosi base-0 Summary: Version 0.1 release Revision: mpc123--main--0.1--base-0 This is the stable release of mpc123 version 0.1; it is the same as mpc123--main--0.0--patch-36 Development and adding of new features will continue on this branch; -- Fernando Vezzosi new files: COPYING ChangeLog LICENSE Makefile README TODO ao.c mpc123.c mpc123.h player.c playlist.c reader.c reader_file.c shuffle.c new patches: bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--base-0 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-1 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-2 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-3 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-4 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-5 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-6 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-7 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-8 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-9 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-10 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-11 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-12 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-13 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-14 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-15 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-16 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-17 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-18 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-19 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-20 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-21 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-22 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-23 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-24 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-25 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-26 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-27 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-28 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-29 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-30 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-31 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-32 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-33 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-34 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-35 bucciarati@users.sourceforge.net--2005--mpc123/mpc123--main--0.0--patch-36 mpc123-0.2.4/reader_file.c0000644000175000000620000000424010771022476014243 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "mpc123.h" #include #include /* read wrapper */ static mpc_int32_t mpc123_file_read(void *t, void *ptr, mpc_int32_t size){ reader_data *data=(reader_data*) t; return read(data->fd, ptr, size); } /* seek wrapper */ static mpc_bool_t mpc123_file_seek(void *t, mpc_int32_t offset){ reader_data *data=(reader_data*) t; lseek(data->fd, offset, SEEK_SET); return TRUE; } static mpc_int32_t mpc123_file_tell(void *t){ reader_data *data=(reader_data*) t; return lseek(data->fd, 0, SEEK_CUR); } /* get filesize */ static mpc_int32_t mpc123_file_get_size(void *t){ reader_data *data=(reader_data*) t; off_t old_offset=lseek(data->fd, 0, SEEK_CUR); /* save old pos */ mpc_int32_t toret=lseek(data->fd, 0, SEEK_END); /* restore old situation */ lseek(data->fd, old_offset, SEEK_SET); return toret; } /* on an empty disk, you can seek() forever */ static mpc_bool_t mpc123_file_canseek(void *t){ return TRUE; } /* * this provides raw data to the decoder library * handles plain files */ mpc_reader mpc123_file_reader={ .read=mpc123_file_read, .seek=mpc123_file_seek, .tell=mpc123_file_tell, .get_size=mpc123_file_get_size, .canseek=mpc123_file_canseek, .data=NULL /* reader_data * data */ }; /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/reader.c0000644000175000000620000000350610771022476013250 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2005-2008 Fernando Vezzosi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include "mpc123.h" /* * select which mpc_reader to use, based on filename * currently it knows about: * - plain file */ int reader_choose_and_prepare(const char * fname, mpc_reader ** ret, reader_data * data){ /* default to plain file reader */ debugf("choosing plain file reader for \"%s\"", fname); data->fd=open(fname, O_RDONLY); if(data->fd == -1){ dief("Couldn't open file \"%s\": [%d] %s\n", fname, errno, (errno == 0 ? "Unknown reason" : strerror(errno) )); } *ret=&mpc123_file_reader; (*ret)->data=data; return 0; } /* * cleans up things needed for each reader * knows about: * - plain files */ void do_cleanup_stream(mpc_reader * the_reader, reader_data * the_data){ /* * plain file reader, * nothing special */ if(the_reader == &mpc123_file_reader){ close(the_data->fd); the_data->fd = -1; } } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/signals.c0000644000175000000620000000650110771022476013444 0ustar bucciastaff/* * mpc123 - Musepack Console audio player * Copyright (C) 2006-2008 Daniele Sempione * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include "mpc123.h" struct sigaction mpc123_signals; sigset_t mpc123_sigset; struct timeval tlast, tnew; int handled_signals[]={ SIGSEGV, /* mem problems */ SIGFPE, /* math problems */ SIGILL, /* function pointer problems */ SIGINT, /* play next song */ 0 /* terminator */ }; int mpc123_setsigh(int currsig) { sigintr: if(sigaction(currsig, &mpc123_signals, NULL) == -1) { if(errno == EINTR) goto sigintr; else return 1; } return 0; } void mpc123_initsigh(void) { int i; gettimeofday(&tlast, NULL); mpc123_signals.sa_handler = signal_handler; mpc123_signals.sa_flags = 0; sigemptyset(&mpc123_signals.sa_mask); sigemptyset(&mpc123_sigset); sigaddset(&mpc123_sigset, SIGINT); for(i=0; handled_signals[i]; i++) if(mpc123_setsigh(handled_signals[i])) sayf(0, "Can't handle %s. errno [%d]\n", strsignal(handled_signals[i]), errno); } /* who needs more backtrace symbols ? */ #ifdef DEBUG # define MPC123_BT_SYMBOLS 50 #else # define MPC123_BT_SYMBOLS 10 #endif void signal_handler(int signo){ void * ary[MPC123_BT_SYMBOLS]; char ** strings; int i=0, size=0; switch(signo){ case SIGINT: sigprocmask(SIG_BLOCK, &mpc123_sigset, NULL); gettimeofday(&tnew, NULL); if(((tnew.tv_sec - tlast.tv_sec) * 1000000 + (tnew.tv_usec - tlast.tv_usec)) < 700000) mpc123_flag_set(MPC123_FL_STOP); else mpc123_flag_set(MPC123_FL_PLAYNEXT); tlast.tv_sec = tnew.tv_sec; tlast.tv_usec = tnew.tv_usec; sigprocmask(SIG_UNBLOCK, &mpc123_sigset, NULL); break; case SIGSEGV: say(0, "Segmentation Fault. Backtrace follows.\n" "NOTE: if you didn't compile with ``make DEBUG=1'', then\n" " * this info is probably mostly useless;\n" " * recompile with debug activated and try to crash\n" " * mpc123 again :)\n\n"); size=backtrace(ary, MPC123_BT_SYMBOLS); strings=backtrace_symbols(ary, size); if(!strings) /* unlikely */ return; for(i=0; i < size; i++){ sayf(0, "%2d: %s\n", i, strings[i]); } free(strings); fprintf(stderr, "Aborting\n"); abort(); break; /* useless, anyway */ /* XXX: case SIGFPE SIGILL ?? */ default: /* .. */ break; } } /* vim:ft=c:tw=78:ts=2:et:cin: */ mpc123-0.2.4/COPYING0000777000175000000620000000000010771022476013673 2LICENSEustar bucciastaff