summaryrefslogtreecommitdiffstats
path: root/uisimulator/common
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-07-08 10:12:39 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-07-08 10:12:39 +0000
commit4242a34ad6f569d2a135e272c8beb95af2aea127 (patch)
treed779ca10bc00d9353adfe63f6365ecf5702ba9d4 /uisimulator/common
parentc685b35611e9be2a761d863de8d7c5124576a12d (diff)
downloadrockbox-4242a34ad6f569d2a135e272c8beb95af2aea127.tar.gz
rockbox-4242a34ad6f569d2a135e272c8beb95af2aea127.tar.bz2
rockbox-4242a34ad6f569d2a135e272c8beb95af2aea127.zip
Patch #961687 by Eric Lassauge, MP3 playback using libmad in the X11 simulator
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4849 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r--uisimulator/common/mpegplay.c25
-rw-r--r--uisimulator/common/mpegplay.h6
2 files changed, 18 insertions, 13 deletions
diff --git a/uisimulator/common/mpegplay.c b/uisimulator/common/mpegplay.c
index f48fc699f6..c7e2552b35 100644
--- a/uisimulator/common/mpegplay.c
+++ b/uisimulator/common/mpegplay.c
@@ -21,7 +21,8 @@
*
****************************************************************************/
-#ifdef MPEG_PLAY
+#ifdef HAVE_MPEG_PLAY
+#ifdef HAVE_LIBMAD
#include <string.h>
#include <stdlib.h>
@@ -119,7 +120,7 @@ signed int dither(mad_fixed_t sample, struct dither *dither)
#define INPUT_BUFFER_SIZE (5*8192)
#define OUTPUT_BUFFER_SIZE 8192 /* Must be an integer multiple of 4. */
-void mpeg_play(char* fname)
+void real_mpeg_play(char* fname)
{
unsigned char InputBuffer[INPUT_BUFFER_SIZE],
OutputBuffer[OUTPUT_BUFFER_SIZE],
@@ -128,9 +129,9 @@ void mpeg_play(char* fname)
int Status=0, i, fd;
unsigned long FrameCount=0;
sound_t sound;
- mp3entry mp3;
- register signed int s0, s1;
+ struct mp3entry mp3;
static struct dither d0, d1;
+ int key=0;
mp3info(&mp3, fname);
@@ -152,9 +153,6 @@ void mpeg_play(char* fname)
mad_timer_reset(&Timer);
do {
- if (button_get())
- break;
-
if (Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN) {
size_t ReadSize,Remaining;
unsigned char *ReadStart;
@@ -170,7 +168,7 @@ void mpeg_play(char* fname)
Remaining=0;
}
- if ((ReadSize=read(fd,ReadStart,ReadSize)) < 0) {
+ if ((int)(ReadSize=read(fd,ReadStart,ReadSize)) < 0) {
fprintf(stderr,"end of input stream\n");
break;
}
@@ -229,6 +227,12 @@ void mpeg_play(char* fname)
OutputPtr=OutputBuffer;
}
}
+
+ if ((key=button_get(0))==BUTTON_STOP)
+ {
+ break;
+ }
+
}while(1);
/* Mad is no longer used, the structures that were initialized must
@@ -244,7 +248,7 @@ void mpeg_play(char* fname)
{
size_t BufferSize=OutputPtr-OutputBuffer;
- if(write(sound,OutputBuffer,1,BufferSize)!=BufferSize)
+ if (output_sound(&sound, OutputPtr, BufferSize)!=(int)BufferSize)
{
fprintf(stderr,"PCM write error\n");
Status=2;
@@ -267,4 +271,5 @@ void mpeg_play(char* fname)
}
-#endif
+#endif /* HAVE_LIBMAD */
+#endif /* HAVE_MPEG_PLAY */
diff --git a/uisimulator/common/mpegplay.h b/uisimulator/common/mpegplay.h
index d0c100c45b..f513125253 100644
--- a/uisimulator/common/mpegplay.h
+++ b/uisimulator/common/mpegplay.h
@@ -16,8 +16,8 @@
*
****************************************************************************/
-#ifdef MPEG_PLAY
+#ifdef HAVE_MPEG_PLAY
-void mpeg_play(char* fname);
+void real_mpeg_play(char* fname);
-#endif
+#endif /* HAVE_MPEG_PLAY */