1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Linus Nielsen Feltzing 2004-07-08 10:12:39 +00:00
parent c685b35611
commit 4242a34ad6
5 changed files with 37 additions and 16 deletions

View file

@ -38,6 +38,8 @@
#include "usb.h"
#include "file.h"
#include "hwcompat.h"
#else
#include "mpegplay.h"
#endif /* #ifndef SIMULATOR */
extern void bitswap(unsigned char *data, int length);
@ -2447,6 +2449,9 @@ void mpeg_play(int offset)
break;
continue;
}
#ifdef HAVE_MPEG_PLAY
real_mpeg_play(trackname);
#endif
playlist_next(steps);
taginfo.offset = offset;
set_elapsed(&taginfo);

View file

@ -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 */

View file

@ -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 */

View file

@ -101,6 +101,14 @@ else
endif
COMMONSRCS = io.c
ifeq ($(HAVE_MPEG_PLAY),1)
SOUNDSRC = mpegplay.c oss_sound.c
LDFLAGS += $(SOUND_LDFLAGS)
CFLAGS += $(SOUND_CFLAGS) -DHAVE_MPEG_PLAY
else
SOUNDSRC =
endif
FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\
powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c
@ -117,7 +125,7 @@ endif
SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \
button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \
$(COMMONSRCS) lcd-common.c fmradio.c
$(COMMONSRCS) $(SOUNDSRC) lcd-common.c fmradio.c
ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c)
ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock)
@ -321,6 +329,9 @@ $(OBJDIR)/lcd-player.o: $(DRIVERS)/lcd-player.c
$(OBJDIR)/radio.o: $(RECDIR)/radio.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/mpegplay.o: $(SIMCOMMON)/mpegplay.c
$(CC) $(CFLAGS) -c $< -o $@
# these ones are simulator-specific
$(OBJDIR)/%.o: %.c

View file

@ -21,7 +21,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <linux/soundcard.h>
#include <sys/soundcard.h>
#include "../common/sound.h"
/* We want to use the "real" open in this file */
@ -39,7 +39,7 @@ int init_sound(sound_t* sound) {
}
int config_sound(sound_t* sound, int sound_freq, int channels) {
int format=AFMT_U16_LE;
int format=AFMT_S16_NE;
int setting=0x000C000D; // 12 fragments size 8kb ? WHAT IS THIS?
sound->freq=sound_freq;