diff options
-rw-r--r-- | firmware/mpeg.c | 5 | ||||
-rw-r--r-- | uisimulator/common/mpegplay.c | 25 | ||||
-rw-r--r-- | uisimulator/common/mpegplay.h | 6 | ||||
-rw-r--r-- | uisimulator/x11/Makefile | 13 | ||||
-rw-r--r-- | uisimulator/x11/oss_sound.c | 4 |
5 files changed, 37 insertions, 16 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 2e5464eb03..8f0612c693 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include "usb.h" | 38 | #include "usb.h" |
39 | #include "file.h" | 39 | #include "file.h" |
40 | #include "hwcompat.h" | 40 | #include "hwcompat.h" |
41 | #else | ||
42 | #include "mpegplay.h" | ||
41 | #endif /* #ifndef SIMULATOR */ | 43 | #endif /* #ifndef SIMULATOR */ |
42 | 44 | ||
43 | extern void bitswap(unsigned char *data, int length); | 45 | extern void bitswap(unsigned char *data, int length); |
@@ -2447,6 +2449,9 @@ void mpeg_play(int offset) | |||
2447 | break; | 2449 | break; |
2448 | continue; | 2450 | continue; |
2449 | } | 2451 | } |
2452 | #ifdef HAVE_MPEG_PLAY | ||
2453 | real_mpeg_play(trackname); | ||
2454 | #endif | ||
2450 | playlist_next(steps); | 2455 | playlist_next(steps); |
2451 | taginfo.offset = offset; | 2456 | taginfo.offset = offset; |
2452 | set_elapsed(&taginfo); | 2457 | set_elapsed(&taginfo); |
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. */ |
122 | void mpeg_play(char* fname) | 123 | void 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 | ||
21 | void mpeg_play(char* fname); | 21 | void 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 | |||
101 | endif | 101 | endif |
102 | COMMONSRCS = io.c | 102 | COMMONSRCS = io.c |
103 | 103 | ||
104 | ifeq ($(HAVE_MPEG_PLAY),1) | ||
105 | SOUNDSRC = mpegplay.c oss_sound.c | ||
106 | LDFLAGS += $(SOUND_LDFLAGS) | ||
107 | CFLAGS += $(SOUND_CFLAGS) -DHAVE_MPEG_PLAY | ||
108 | else | ||
109 | SOUNDSRC = | ||
110 | endif | ||
111 | |||
104 | FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ | 112 | FIRMSRCS = $(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 | ||
118 | SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ | 126 | SRCS = 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 | ||
122 | ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) | 130 | ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c) |
123 | ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock) | 131 | ROCKS := $(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 | ||
41 | int config_sound(sound_t* sound, int sound_freq, int channels) { | 41 | int 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; |