Update of /cvsroot/pure-data/externals/unauthorized/mp3live~
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28467/mp3live~
Modified Files:
mp3fileout~.c mp3streamin~.c mp3streamout~.c
Log Message:
making mp3*~ work on windows
Index: mp3streamin~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/unauthorized/mp3live~/mp3streamin~.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mp3streamin~.c 25 Sep 2003 20:58:54 -0000 1.3
--- mp3streamin~.c 22 May 2004 14:04:17 -0000 1.4
***************
*** 52,67 ****
#include <fcntl.h>
#include <stdio.h>
- #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */
- #include "mpglib.h" /* mpglib decoding library from lame 3.92 */
- #include "interface.h" /* mpglib decoding library from lame 3.92 */
#define SOCKET_ERROR -1
#else
#include <winsock.h>
#endif
!
! #ifdef NT
! #pragma warning( disable : 4244 )
! #pragma warning( disable : 4305 )
! #endif
#define MIN_AUDIO_INPUT 8064 // we must a least have 8 chunks to play a correct sound
--- 52,64 ----
#include <fcntl.h>
#include <stdio.h>
#define SOCKET_ERROR -1
#else
#include <winsock.h>
+ #define MSG_NOSIGNAL 0
+ #define SOL_TCP IPPROTO_TCP
#endif
! #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */
! #include "mpglib.h" /* mpglib decoding library from lame 3.92 */
! #include "interface.h" /* mpglib decoding library from lame 3.92 */
#define MIN_AUDIO_INPUT 8064 // we must a least have 8 chunks to play a correct sound
Index: mp3fileout~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/unauthorized/mp3live~/mp3fileout~.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mp3fileout~.c 25 Sep 2003 20:58:54 -0000 1.3
--- mp3fileout~.c 22 May 2004 14:04:17 -0000 1.4
***************
*** 48,63 ****
#include <fcntl.h>
#include <stdio.h>
- #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */
- #include "mpglib.h" /* mpglib decoding library from lame 3.92 */
- #include "interface.h" /* mpglib decoding library from lame 3.92 */
#define SOCKET_ERROR -1
#else
#include <winsock.h>
#endif
!
! #ifdef NT
! #pragma warning( disable : 4244 )
! #pragma warning( disable : 4305 )
! #endif
#define INPUT_BUFFER_SIZE 32768
--- 48,61 ----
#include <fcntl.h>
#include <stdio.h>
#define SOCKET_ERROR -1
#else
#include <winsock.h>
+ #include <io.h>
+ #include <fcntl.h>
+ #define MSG_NOSIGNAL 0
#endif
! #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */
! #include "mpglib.h" /* mpglib decoding library from lame 3.92 */
! #include "interface.h" /* mpglib decoding library from lame 3.92 */
#define INPUT_BUFFER_SIZE 32768
***************
*** 91,96 ****
#ifdef NT
closesocket(fd);
! #endif
sys_rmpollfn(fd);
}
--- 89,95 ----
#ifdef NT
closesocket(fd);
! #else
sys_rmpollfn(fd);
+ #endif
}
***************
*** 391,394 ****
--- 390,394 ----
outlet_float( x->x_frames, x->x_outframes );
}
+
if ( ( x->x_fd = open( filename->s_name, O_RDONLY ) ) < 0 )
{
Index: mp3streamout~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/unauthorized/mp3live~/mp3streamout~.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mp3streamout~.c 25 Sep 2003 20:58:54 -0000 1.3
--- mp3streamout~.c 22 May 2004 14:04:17 -0000 1.4
***************
*** 30,40 ****
/* ---------------------------------------------------------------------------- */
-
-
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include <sys/types.h>
#include <string.h>
--- 30,33 ----
***************
*** 55,59 ****
#include <time.h>
#include <sys/time.h>
- #include <lame/lame.h> /* lame encoder stuff */
#define SOCKET_ERROR -1
#else
--- 48,51 ----
***************
*** 62,67 ****
#include <winsock.h>
#include <windef.h>
! #include "lame_enc.h" /* lame encoder stuff */
#endif
#include "m_pd.h" /* standard pd stuff */
--- 54,60 ----
#include <winsock.h>
#include <windef.h>
! #define MSG_NOSIGNAL 0
#endif
+ #include <lame/lame.h> /* lame encoder stuff */
#include "m_pd.h" /* standard pd stuff */
***************
*** 82,95 ****
static char *mp3streamout_version = "mp3streamout~: mp3 peer-to-peer streamer version 0.3, written by ydegoyon(a)free.fr";
- #ifndef UNIX
- static HINSTANCE dll = NULL;
- static BEINITSTREAM initStream = NULL;
- static BEENCODECHUNK encodeChunk = NULL;
- static BEDEINITSTREAM deinitStream = NULL;
- static BECLOSESTREAM closeStream = NULL;
- static BEVERSION dllVersion = NULL;
- static BEWRITEVBRHEADER writeVBRHeader = NULL;
- #endif
-
static t_class *mp3streamout_class;
--- 75,78 ----
***************
*** 124,130 ****
t_float x_f; /* float needed for signal input */
- #ifdef UNIX
lame_global_flags* lgfp;
- #endif
} t_mp3streamout;
--- 107,111 ----
***************
*** 191,197 ****
/* encode mp3 data */
! #ifndef UNIX
! err = encodeChunk(x->x_lame, x->x_lamechunk, x->x_mp3inbuf, x->x_mp3outbuf, &x->x_mp3size);
! #else
x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf,
x->x_lamechunk/lame_get_num_channels(x->lgfp),
--- 172,176 ----
/* encode mp3 data */
!
x->x_mp3size = lame_encode_buffer_interleaved(x->lgfp, x->x_mp3inbuf,
x->x_lamechunk/lame_get_num_channels(x->lgfp),
***************
*** 199,216 ****
x->x_mp3size+=lame_encode_flush( x->lgfp, x->x_mp3outbuf+x->x_mp3size, MY_MP3_MALLOC_OUT_SIZE-x->x_mp3size );
// post( "mp3streamout~ : encoding returned %d frames", x->x_mp3size );
- #endif
/* check result */
- #ifndef UNIX
- if(err != BE_ERR_SUCCESSFUL)
- {
- closeStream(x->x_lame);
- error("mp3streamout~: lameEncodeChunk() failed (%lu)", err);
- #else
if(x->x_mp3size<0)
{
lame_close( x->lgfp );
error("mp3streamout~: lame_encode_buffer_interleaved failed (%d)", x->x_mp3size);
- #endif
x->x_lame = -1;
}
--- 178,187 ----
***************
*** 238,246 ****
{
error("mp3streamout~: could not send encoded data to the peer (%d)", count);
- #ifndef UNIX
- closeStream(x->x_lame);
- #else
lame_close( x->lgfp );
- #endif
x->x_lame = -1;
#ifndef UNIX
--- 209,213 ----
***************
*** 369,385 ****
static void mp3streamout_tilde_lame_init(t_mp3streamout *x)
{
- #ifndef UNIX
- /* encoder related stuff (calculating buffer size) */
- BE_VERSION lameVersion = {0,}; /* version number of LAME */
- BE_CONFIG lameConfig = {0,}; /* config structure of LAME */
- unsigned int ret;
- #else
int ret;
x->lgfp = lame_init(); /* set default parameters for now */
- #endif
#ifndef UNIX
/* load lame_enc.dll library */
!
dll=LoadLibrary("lame_enc.dll");
if(dll==NULL)
--- 336,345 ----
static void mp3streamout_tilde_lame_init(t_mp3streamout *x)
{
int ret;
x->lgfp = lame_init(); /* set default parameters for now */
#ifndef UNIX
/* load lame_enc.dll library */
! HINSTANCE dll;
dll=LoadLibrary("lame_enc.dll");
if(dll==NULL)
***************
*** 392,464 ****
return;
}
!
! /* get Interface functions */
! initStream = (BEINITSTREAM) GetProcAddress(dll, TEXT_BEINITSTREAM);
! encodeChunk = (BEENCODECHUNK) GetProcAddress(dll, TEXT_BEENCODECHUNK);
! deinitStream = (BEDEINITSTREAM) GetProcAddress(dll, TEXT_BEDEINITSTREAM);
! closeStream = (BECLOSESTREAM) GetProcAddress(dll, TEXT_BECLOSESTREAM);
! dllVersion = (BEVERSION) GetProcAddress(dll, TEXT_BEVERSION);
! writeVBRHeader = (BEWRITEVBRHEADER) GetProcAddress(dll,TEXT_BEWRITEVBRHEADER);
!
! /* check if all interfaces are present */
! if(!initStream || !encodeChunk || !deinitStream || !closeStream || !dllVersion || !writeVBRHeader)
! {
!
! error("mp3streamout~: unable to get LAME interfaces");
! closesocket(x->x_fd);
! x->x_fd = -1;
! outlet_float(x->x_obj.ob_outlet, 0);
! post("mp3streamout~: connection closed");
! return;
! }
!
! /* get LAME version number */
! dllVersion(&lameVersion);
!
! post( "mp3streamout~: lame_enc.dll version %u.%02u (%u/%u/%u)\n"
! " lame_enc engine %u.%02u",
! lameVersion.byDLLMajorVersion, lameVersion.byDLLMinorVersion,
! lameVersion.byDay, lameVersion.byMonth, lameVersion.wYear,
! lameVersion.byMajorVersion, lameVersion.byMinorVersion);
!
! memset(&lameConfig,0,sizeof(lameConfig)); /* clear all fields */
! #else
{
const char *lameVersion = get_lame_version();
post( "mp3streamout~ : using lame version : %s", lameVersion );
}
- #endif
-
- #ifndef UNIX
-
- /* use the LAME config structure */
- lameConfig.dwConfig = BE_CONFIG_LAME;
-
- /* set the mpeg format flags */
- lameConfig.format.LHV1.dwStructVersion = 1;
- lameConfig.format.LHV1.dwStructSize = sizeof(lameConfig);
- lameConfig.format.LHV1.dwSampleRate = (int)sys_getsr(); /* input frequency - pd's sample rate */
- lameConfig.format.LHV1.dwReSampleRate = x->x_samplerate; /* output s/r - resample if necessary */
- lameConfig.format.LHV1.nMode = x->x_mp3mode; /* output mode */
- lameConfig.format.LHV1.dwBitrate = x->x_bitrate; /* mp3 bitrate */
- lameConfig.format.LHV1.nPreset = x->x_mp3quality; /* mp3 encoding quality */
- lameConfig.format.LHV1.dwMpegVersion = MPEG1; /* use MPEG1 */
- lameConfig.format.LHV1.dwPsyModel = 0; /* USE DEFAULT PSYCHOACOUSTIC MODEL */
- lameConfig.format.LHV1.dwEmphasis = 0; /* NO EMPHASIS TURNED ON */
- lameConfig.format.LHV1.bOriginal = TRUE; /* SET ORIGINAL FLAG */
- lameConfig.format.LHV1.bCopyright = TRUE; /* SET COPYRIGHT FLAG */
- lameConfig.format.LHV1.bNoRes = TRUE; /* no bit resorvoir */
-
- /* init the MP3 stream */
- ret = initStream(&lameConfig, &x->x_lamechunk, &x->x_mp3size, &x->x_lame);
-
- /* check result */
- if(ret != BE_ERR_SUCCESSFUL)
- {
- post("mp3streamout~: error opening encoding stream (%lu)", ret);
- return;
- }
- #else
/* setting lame parameters */
lame_set_num_channels( x->lgfp, 2);
--- 352,361 ----
return;
}
! #endif
{
const char *lameVersion = get_lame_version();
post( "mp3streamout~ : using lame version : %s", lameVersion );
}
/* setting lame parameters */
lame_set_num_channels( x->lgfp, 2);
***************
*** 484,490 ****
}
lame_init_bitstream( x->lgfp );
- #endif
-
-
}
--- 381,384 ----
***************
*** 568,582 ****
if(x->x_lame >= 0)
{
- #ifndef UNIX
- /* deinit the stream */
- err = deinitStream(x->x_lame, x->x_mp3outbuf, &x->x_mp3size);
-
- /* check result */
- if(err != BE_ERR_SUCCESSFUL)
- {
- error("exiting mp3 stream failed (%lu)", err);
- }
- closeStream(x->x_lame); /* close mp3 encoder stream */
- #else
/* ignore remaining bytes */
if ( x->x_mp3size = lame_encode_flush( x->lgfp, x->x_mp3outbuf, 0) < 0 ) {
--- 462,465 ----
***************
*** 584,588 ****
}
lame_close( x->lgfp );
- #endif
x->x_lame = -1;
post("mp3streamout~: encoder stream closed");
--- 467,470 ----
***************
*** 677,685 ****
if(x->x_lame >= 0)
- #ifndef UNIX
- closeStream(x->x_lame);
- #else
lame_close( x->lgfp );
! #endif
if(x->x_fd >= 0)
#ifndef UNIX
--- 559,564 ----
if(x->x_lame >= 0)
lame_close( x->lgfp );
!
if(x->x_fd >= 0)
#ifndef UNIX