diff options
Diffstat (limited to 'uisimulator/common/mpegplay.c')
-rw-r--r-- | uisimulator/common/mpegplay.c | 25 |
1 files changed, 15 insertions, 10 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. */ |
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 */ | ||