1.1 --- a/ao.c Mon Jul 28 19:26:26 2008 +0200
1.2 +++ b/ao.c Thu Mar 26 02:17:06 2009 +0100
1.3 @@ -144,9 +144,9 @@
1.4 data->ao_dev=ao_open_live(ao_drvnum, &ao_fmt, opt_head);
1.5 }else{
1.6 /* output to file (act as a decoder) */
1.7 - data->ao_dev=ao_open_file(ao_drvnum, options.foutput, TRUE, &ao_fmt, NULL);
1.8 + data->ao_dev=ao_open_file(ao_drvnum, options.foutput, MPC_TRUE, &ao_fmt, NULL);
1.9 }
1.10 -
1.11 +
1.12 if( !data->ao_dev ){
1.13 dief(_("Could not open audio output: [%d] %s\n"), errno, strerror(errno));
1.14 }
1.15 @@ -175,6 +175,9 @@
1.16 unsigned char * output;
1.17 unsigned bytes=samples * 2; /* 16 bit == 2 bytes */
1.18
1.19 + if(!bytes)
1.20 + return 0;
1.21 +
1.22 const unsigned pSize = 16;
1.23 const int clip_min = -1 << (pSize - 1);
1.24 const int clip_max = (1 << (pSize - 1)) - 1;
1.25 @@ -192,7 +195,8 @@
1.26 }
1.27
1.28 if(!output){
1.29 - dief(_("Out of memory (needed 0x%08x bytes)\n"), bytes);
1.30 + sayf(0, "Out of memory (needed 0x%08x bytes)\n", bytes);
1.31 + return 0;
1.32 }
1.33
1.34 /* code stolen from xmms-musepack */
2.1 --- a/mpc123.h Mon Jul 28 19:26:26 2008 +0200
2.2 +++ b/mpc123.h Thu Mar 26 02:17:06 2009 +0100
2.3 @@ -29,8 +29,9 @@
2.4
2.5 # include <libintl.h>
2.6
2.7 -# include <mpcdec/config_types.h>
2.8 -# include <mpcdec/mpcdec.h>
2.9 +# include <mpc/mpcdec.h>
2.10 +# include <mpc/streaminfo.h>
2.11 +# include <mpc/mpc_types.h>
2.12
2.13 # ifndef LOCALEDIR
2.14 # define LOCALEDIR "/usr/share/locale" /* this is the Debian default */
2.15 @@ -44,7 +45,7 @@
2.16 */
2.17 # define VERS_MAJOR 0
2.18 # define VERS_MINOR 2
2.19 -# define VERS_REV 4
2.20 +# define VERS_REV 5
2.21
2.22 # define COPYRIGHT_NOTICE VERS_NAME " Copyright " COPYRIGHT "\n" \
2.23 "This is free software, meaning it comes under the terms of the\n" \
3.1 --- a/player.c Mon Jul 28 19:26:26 2008 +0200
3.2 +++ b/player.c Thu Mar 26 02:17:06 2009 +0100
3.3 @@ -31,9 +31,9 @@
3.4 */
3.5 int do_play_stream(mpc_reader * the_reader, reader_data * data){
3.6 mpc_streaminfo tmp_stream_info;
3.7 - mpc_decoder mpc123_decoder;
3.8 - mpc_int32_t mpc_ret;
3.9 - mpc_uint32_t vbrAcc=0, vbrUpd=0;
3.10 + mpc_demux *mpc123_decoder = NULL;
3.11 + mpc_frame_info frame;
3.12 + mpc_status err;
3.13 int played=0;
3.14
3.15 void * ao_data=NULL;
3.16 @@ -44,19 +44,12 @@
3.17 unsigned bytes_from_decoder=0;
3.18
3.19 /* read file's streaminfo data */
3.20 - mpc_streaminfo_init(&tmp_stream_info);
3.21 - if( (mpc_ret=mpc_streaminfo_read(&tmp_stream_info, the_reader))
3.22 - != ERROR_CODE_OK){
3.23 - debugf("mpc_streaminfo_read()=%d", mpc_ret);
3.24 + mpc123_decoder = mpc_demux_init(the_reader);
3.25 + if( !mpc123_decoder ){
3.26 die("Not a valid musepack file\n");
3.27 }
3.28
3.29 - /* initialize decoder with the appropriate file reader */
3.30 - mpc_decoder_setup(&mpc123_decoder, the_reader);
3.31 - if( !(mpc_ret=mpc_decoder_initialize(&mpc123_decoder, &tmp_stream_info)) ){
3.32 - debugf("mpc_decoder_initialize()=%d", mpc_ret);
3.33 - die("Error initializing decoder\n");
3.34 - }
3.35 + mpc_demux_get_info(mpc123_decoder, &tmp_stream_info);
3.36
3.37 if( mpc123_ao_init(&ao_data, &tmp_stream_info) != 0 ){
3.38 dief("Could not initialize audio library: error %d\n", errno);
3.39 @@ -64,21 +57,21 @@
3.40
3.41 /* decoding loop */
3.42 while(1){
3.43 - decoded_samples=mpc_decoder_decode(&mpc123_decoder, buffer,
3.44 - &vbrAcc, &vbrUpd);
3.45 + frame.buffer = buffer;
3.46 + err = mpc_demux_decode(mpc123_decoder, &frame);
3.47
3.48 - if( !decoded_samples ){ /* eof */
3.49 + if( err != MPC_STATUS_OK ){ /* eof */
3.50 debugf("End of file after %d samples", total_decoded);
3.51 break;
3.52 }
3.53
3.54 - if( decoded_samples == -1 ){ /* decoding error */
3.55 + if( err == -1 ){ /* decoding error */
3.56 debug("Error decoding stream.");
3.57 say(0, "Error while decoding -- maybe corrupted data?\n");
3.58 break;
3.59 }
3.60
3.61 -/* debug(" <%d %d %d>", vbrAcc, vbrUpd, vbrUpd * 44100 / 1152 / 100);*/
3.62 + decoded_samples = frame.samples;
3.63 total_decoded += decoded_samples;
3.64 bytes_from_decoder = decoded_samples * sizeof(float) * 2;
3.65
4.1 --- a/reader_file.c Mon Jul 28 19:26:26 2008 +0200
4.2 +++ b/reader_file.c Thu Mar 26 02:17:06 2009 +0100
4.3 @@ -22,30 +22,27 @@
4.4
4.5 #include "mpc123.h"
4.6
4.7 -#include <mpcdec/config_types.h>
4.8 -#include <mpcdec/mpcdec.h>
4.9 -
4.10 /* read wrapper */
4.11 -static mpc_int32_t mpc123_file_read(void *t, void *ptr, mpc_int32_t size){
4.12 - reader_data *data=(reader_data*) t;
4.13 +static mpc_int32_t mpc123_file_read(mpc_reader *t, void *ptr, mpc_int32_t size){
4.14 + reader_data *data=(reader_data*) t->data;
4.15 return read(data->fd, ptr, size);
4.16 }
4.17
4.18 /* seek wrapper */
4.19 -static mpc_bool_t mpc123_file_seek(void *t, mpc_int32_t offset){
4.20 - reader_data *data=(reader_data*) t;
4.21 +static mpc_bool_t mpc123_file_seek(mpc_reader *t, mpc_int32_t offset){
4.22 + reader_data *data=(reader_data*) t->data;
4.23 lseek(data->fd, offset, SEEK_SET);
4.24 - return TRUE;
4.25 + return MPC_TRUE;
4.26 }
4.27
4.28 -static mpc_int32_t mpc123_file_tell(void *t){
4.29 - reader_data *data=(reader_data*) t;
4.30 +static mpc_int32_t mpc123_file_tell(mpc_reader *t){
4.31 + reader_data *data=(reader_data*) t->data;
4.32 return lseek(data->fd, 0, SEEK_CUR);
4.33 }
4.34
4.35 /* get filesize */
4.36 -static mpc_int32_t mpc123_file_get_size(void *t){
4.37 - reader_data *data=(reader_data*) t;
4.38 +static mpc_int32_t mpc123_file_get_size(mpc_reader *t){
4.39 + reader_data *data=(reader_data*) t->data;
4.40 off_t old_offset=lseek(data->fd, 0, SEEK_CUR); /* save old pos */
4.41 mpc_int32_t toret=lseek(data->fd, 0, SEEK_END);
4.42
4.43 @@ -56,8 +53,8 @@
4.44 }
4.45
4.46 /* on an empty disk, you can seek() forever */
4.47 -static mpc_bool_t mpc123_file_canseek(void *t){
4.48 - return TRUE;
4.49 +static mpc_bool_t mpc123_file_canseek(mpc_reader *t){
4.50 + return MPC_TRUE;
4.51 }
4.52
4.53 /*
4.54 @@ -65,12 +62,12 @@
4.55 * handles plain files
4.56 */
4.57 mpc_reader mpc123_file_reader={
4.58 - .read=mpc123_file_read,
4.59 - .seek=mpc123_file_seek,
4.60 - .tell=mpc123_file_tell,
4.61 - .get_size=mpc123_file_get_size,
4.62 - .canseek=mpc123_file_canseek,
4.63 - .data=NULL /* reader_data * data */
4.64 + .read = mpc123_file_read,
4.65 + .seek = mpc123_file_seek,
4.66 + .tell = mpc123_file_tell,
4.67 + .get_size = mpc123_file_get_size,
4.68 + .canseek = mpc123_file_canseek,
4.69 + .data = NULL /* reader_data * data */
4.70 };
4.71
4.72 /* vim:ft=c:tw=78:ts=2:et:cin: