summaryrefslogtreecommitdiff
path: root/uisimulator
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
parentc685b35611e9be2a761d863de8d7c5124576a12d (diff)
downloadrockbox-4242a34ad6f569d2a135e272c8beb95af2aea127.tar.gz
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')
-rw-r--r--uisimulator/common/mpegplay.c25
-rw-r--r--uisimulator/common/mpegplay.h6
-rw-r--r--uisimulator/x11/Makefile13
-rw-r--r--uisimulator/x11/oss_sound.c4
4 files changed, 32 insertions, 16 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 @@
21 * 21 *
22 ****************************************************************************/ 22 ****************************************************************************/
23 23
24#ifdef MPEG_PLAY 24#ifdef HAVE_MPEG_PLAY
25#ifdef HAVE_LIBMAD
25 26
26#include <string.h> 27#include <string.h>
27#include <stdlib.h> 28#include <stdlib.h>
@@ -119,7 +120,7 @@ signed int dither(mad_fixed_t sample, struct dither *dither)
119 120
120#define INPUT_BUFFER_SIZE (5*8192) 121#define INPUT_BUFFER_SIZE (5*8192)
121#define OUTPUT_BUFFER_SIZE 8192 /* Must be an integer multiple of 4. */ 122#define OUTPUT_BUFFER_SIZE 8192 /* Must be an integer multiple of 4. */
122void mpeg_play(char* fname) 123void real_mpeg_play(char* fname)
123{ 124{
124 unsigned char InputBuffer[INPUT_BUFFER_SIZE], 125 unsigned char InputBuffer[INPUT_BUFFER_SIZE],
125 OutputBuffer[OUTPUT_BUFFER_SIZE], 126 OutputBuffer[OUTPUT_BUFFER_SIZE],
@@ -128,9 +129,9 @@ void mpeg_play(char* fname)
128 int Status=0, i, fd; 129 int Status=0, i, fd;
129 unsigned long FrameCount=0; 130 unsigned long FrameCount=0;
130 sound_t sound; 131 sound_t sound;
131 mp3entry mp3; 132 struct mp3entry mp3;
132 register signed int s0, s1;
133 static struct dither d0, d1; 133 static struct dither d0, d1;
134 int key=0;
134 135
135 mp3info(&mp3, fname); 136 mp3info(&mp3, fname);
136 137
@@ -152,9 +153,6 @@ void mpeg_play(char* fname)
152 mad_timer_reset(&Timer); 153 mad_timer_reset(&Timer);
153 154
154 do { 155 do {
155 if (button_get())
156 break;
157
158 if (Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN) { 156 if (Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN) {
159 size_t ReadSize,Remaining; 157 size_t ReadSize,Remaining;
160 unsigned char *ReadStart; 158 unsigned char *ReadStart;
@@ -170,7 +168,7 @@ void mpeg_play(char* fname)
170 Remaining=0; 168 Remaining=0;
171 } 169 }
172 170
173 if ((ReadSize=read(fd,ReadStart,ReadSize)) < 0) { 171 if ((int)(ReadSize=read(fd,ReadStart,ReadSize)) < 0) {
174 fprintf(stderr,"end of input stream\n"); 172 fprintf(stderr,"end of input stream\n");
175 break; 173 break;
176 } 174 }
@@ -229,6 +227,12 @@ void mpeg_play(char* fname)
229 OutputPtr=OutputBuffer; 227 OutputPtr=OutputBuffer;
230 } 228 }
231 } 229 }
230
231 if ((key=button_get(0))==BUTTON_STOP)
232 {
233 break;
234 }
235
232 }while(1); 236 }while(1);
233 237
234 /* Mad is no longer used, the structures that were initialized must 238 /* Mad is no longer used, the structures that were initialized must
@@ -244,7 +248,7 @@ void mpeg_play(char* fname)
244 { 248 {
245 size_t BufferSize=OutputPtr-OutputBuffer; 249 size_t BufferSize=OutputPtr-OutputBuffer;
246 250
247 if(write(sound,OutputBuffer,1,BufferSize)!=BufferSize) 251 if (output_sound(&sound, OutputPtr, BufferSize)!=(int)BufferSize)
248 { 252 {
249 fprintf(stderr,"PCM write error\n"); 253 fprintf(stderr,"PCM write error\n");
250 Status=2; 254 Status=2;
@@ -267,4 +271,5 @@ void mpeg_play(char* fname)
267} 271}
268 272
269 273
270#endif 274#endif /* HAVE_LIBMAD */
275#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 @@
16 * 16 *
17 ****************************************************************************/ 17 ****************************************************************************/
18 18
19#ifdef MPEG_PLAY 19#ifdef HAVE_MPEG_PLAY
20 20
21void mpeg_play(char* fname); 21void real_mpeg_play(char* fname);
22 22
23#endif 23#endif /* HAVE_MPEG_PLAY */
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 8076686f52..36e814e121 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -101,6 +101,14 @@ else
101endif 101endif
102COMMONSRCS = io.c 102COMMONSRCS = io.c
103 103
104ifeq ($(HAVE_MPEG_PLAY),1)
105 SOUNDSRC = mpegplay.c oss_sound.c
106 LDFLAGS += $(SOUND_LDFLAGS)
107 CFLAGS += $(SOUND_CFLAGS) -DHAVE_MPEG_PLAY
108else
109 SOUNDSRC =
110endif
111
104FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ 112FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\
105 powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c 113 powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c
106 114
@@ -117,7 +125,7 @@ endif
117 125
118SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ 126SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \
119 button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \ 127 button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \
120 $(COMMONSRCS) lcd-common.c fmradio.c 128 $(COMMONSRCS) $(SOUNDSRC) lcd-common.c fmradio.c
121 129
122ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) 130ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c)
123ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) 131ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock)
@@ -321,6 +329,9 @@ $(OBJDIR)/lcd-player.o: $(DRIVERS)/lcd-player.c
321$(OBJDIR)/radio.o: $(RECDIR)/radio.c 329$(OBJDIR)/radio.o: $(RECDIR)/radio.c
322 $(CC) $(APPCFLAGS) -c $< -o $@ 330 $(CC) $(APPCFLAGS) -c $< -o $@
323 331
332$(OBJDIR)/mpegplay.o: $(SIMCOMMON)/mpegplay.c
333 $(CC) $(CFLAGS) -c $< -o $@
334
324# these ones are simulator-specific 335# these ones are simulator-specific
325 336
326$(OBJDIR)/%.o: %.c 337$(OBJDIR)/%.o: %.c
diff --git a/uisimulator/x11/oss_sound.c b/uisimulator/x11/oss_sound.c
index e69c403acd..51d85470e7 100644
--- a/uisimulator/x11/oss_sound.c
+++ b/uisimulator/x11/oss_sound.c
@@ -21,7 +21,7 @@
21#include <stdio.h> 21#include <stdio.h>
22#include <fcntl.h> 22#include <fcntl.h>
23 23
24#include <linux/soundcard.h> 24#include <sys/soundcard.h>
25#include "../common/sound.h" 25#include "../common/sound.h"
26 26
27/* We want to use the "real" open in this file */ 27/* We want to use the "real" open in this file */
@@ -39,7 +39,7 @@ int init_sound(sound_t* sound) {
39} 39}
40 40
41int config_sound(sound_t* sound, int sound_freq, int channels) { 41int config_sound(sound_t* sound, int sound_freq, int channels) {
42 int format=AFMT_U16_LE; 42 int format=AFMT_S16_NE;
43 int setting=0x000C000D; // 12 fragments size 8kb ? WHAT IS THIS? 43 int setting=0x000C000D; // 12 fragments size 8kb ? WHAT IS THIS?
44 44
45 sound->freq=sound_freq; 45 sound->freq=sound_freq;