Rev 576 | Rev 646 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 576 | Rev 577 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | #include "string.h" |
17 | #include "string.h" |
18 | #include "ac97wav.h" |
18 | #include "ac97wav.h" |
19 | #include "../mpg/mpg123.h" |
19 | #include "../mpg/mpg123.h" |
20 | #include "../sound.h" |
20 | #include "../sound.h" |
Line 21... | Line -... | ||
21 | - | ||
22 | typedef struct |
- | |
23 | { |
- | |
24 | int sender; |
- | |
25 | int size; |
- | |
26 | int code; |
- | |
27 | char data[1]; |
- | |
28 | } IPC; |
- | |
29 | - | ||
Line 30... | Line 21... | ||
30 | int ipc_client = 0; |
21 | |
31 | 22 | ||
Line 32... | Line 23... | ||
32 | #define MP3_ERROR_OUT_OF_BUFFER 5 |
23 | #define MP3_ERROR_OUT_OF_BUFFER 5 |
33 | int m_last_error; |
24 | int m_last_error; |
34 | - | ||
35 | void _stdcall thread_proc(void *param); |
25 | |
36 | void _stdcall create_thread(void *proc, void *param, int stack_size); |
- | |
Line 37... | Line 26... | ||
37 | void _stdcall init_ipc(void); |
26 | void _stdcall thread_proc(void *param); |
38 | void _stdcall send_ipc(int dst, DWORD code); |
27 | void _stdcall create_thread(void *proc, void *param, int stack_size); |
39 | IPC * _stdcall recieve_ipc(void); |
28 | void _stdcall send_ipc(int dst, DWORD code); |
Line 40... | Line 29... | ||
40 | 29 | ||
Line 41... | Line 30... | ||
41 | void touch(char *buf, int size); |
30 | void touch(char *buf, int size); |
42 | int mp3FindSync(byte* buf, int size, int* sync); |
31 | int mp3FindSync(byte* buf, int size, int* sync); |
Line 43... | Line -... | ||
43 | int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
- | |
44 | - | ||
45 | char *fname; |
- | |
46 | - | ||
47 | struct reader rd; |
- | |
48 | struct frame fr; |
- | |
49 | 32 | int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
|
50 | void draw_window(); |
33 | |
51 | void draw_progress_bar(); |
34 | char *fname; |
52 | void do_ipc(); |
- | |
Line 53... | Line 35... | ||
53 | void exit(); |
35 | |
Line 54... | Line 36... | ||
54 | 36 | struct reader rd; |
|
Line 66... | Line 48... | ||
66 | int l_vol=-700; //-7db |
48 | int l_vol=-700; //-7db |
67 | int r_vol=-700; |
49 | int r_vol=-700; |
68 | int pan =0; |
50 | int pan =0; |
Line 69... | Line 51... | ||
69 | 51 | ||
70 | DWORD status; |
- | |
71 | DWORD offset; |
52 | DWORD status; |
Line 72... | Line 53... | ||
72 | DWORD first_sync; |
53 | DWORD first_sync; |
73 | 54 | ||
74 | unsigned char *testbuff; |
55 | unsigned char *testbuff; |
Line 79... | Line 60... | ||
79 | int inpsize; |
60 | int inpsize; |
80 | int outsize; |
61 | int outsize; |
81 | int outremain; |
62 | int outremain; |
82 | int totalout; |
63 | int totalout; |
83 | int done; |
64 | int done; |
84 | char path[1024]; |
- | |
- | 65 | ||
85 | char header[] = "AC97 MP3 player"; |
66 | char header[] = "AC97 MP3 player"; |
86 | char buttons_text[]=" Play Stop << >> Vol- Vol+"; |
67 | char buttons_text[]=" Play Stop << >> Vol- Vol+"; |
Line 87... | Line 68... | ||
87 | 68 | ||
Line 88... | Line -... | ||
88 | void (*snd_play)(); |
- | |
89 | - | ||
90 | - | ||
91 | int main(int argc, char *argv[]) //int argc, char *argv[]) |
- | |
92 | { |
- | |
93 | int err; |
- | |
94 | int ver; |
- | |
95 | int evnt; |
- | |
96 | int key; |
- | |
97 | int pos; |
- | |
98 | int msg; |
- | |
99 | int cnt; |
- | |
100 | IPC *incom; |
- | |
101 | - | ||
102 | _asm |
- | |
103 | { |
- | |
104 | mov eax, 40 |
- | |
105 | mov ebx, 0x47 ;recieve ipc |
- | |
106 | int 0x40 |
- | |
107 | mov eax, 66 |
- | |
108 | mov ebx, 1 |
- | |
109 | mov ecx, 1 |
- | |
110 | int 0x40 |
- | |
111 | }; |
- | |
112 | init_ipc(); |
- | |
113 | InitHeap(0); |
- | |
114 | - | ||
115 | if(err = InitSound(&ver)) |
- | |
116 | { debug_out_str("Sound service not installed\n\r"); |
- | |
117 | return 0; |
- | |
118 | } |
- | |
119 | - | ||
120 | if( (SOUND_VERSION>(ver&0xFFFF)) || |
- | |
121 | (SOUND_VERSION<(ver >> 16))) |
- | |
122 | { debug_out_str("Sound service version mismatch\n\r"); |
- | |
123 | return 0; |
- | |
124 | } |
- | |
125 | - | ||
126 | make_decode_tables(32767); |
- | |
127 | init_layer2(); |
- | |
128 | init_layer3(32); |
- | |
129 | fr.single = -1; |
- | |
130 | - | ||
131 | outremain = 0x40000 ; |
- | |
132 | if( !(outbuf=UserAlloc(outremain))) |
- | |
133 | return 0; |
- | |
134 | - | ||
135 | touch(outbuf, outremain); |
- | |
136 | - | ||
137 | if ( !(testbuff=UserAlloc(4096))) |
- | |
138 | return 0; |
- | |
139 | - | ||
140 | if (! (inpbuf=UserAlloc(0x10000))) |
- | |
141 | return 0; |
- | |
142 | - | ||
143 | touch(inpbuf, 0x10000); |
- | |
144 | create_reader(&rd, inpbuf, 0x10000); |
- | |
145 | - | ||
146 | fname = argv[1]; |
- | |
147 | - | ||
148 | if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) |
- | |
149 | { |
- | |
150 | _asm |
- | |
151 | { |
- | |
152 | mov eax, 23 |
- | |
153 | mov ebx, 100 |
- | |
154 | int 0x40 |
- | |
155 | mov [msg], eax |
- | |
156 | } |
- | |
157 | if (msg != 7) |
- | |
158 | { |
- | |
159 | debug_out_str("\n\rfile not found\n\r"); |
- | |
160 | return 0; |
- | |
161 | }; |
- | |
162 | incom = recieve_ipc(); |
- | |
163 | if(incom->code != 'CNCT') |
- | |
164 | { |
- | |
165 | debug_out_str("\n\rinvalid ipc code\n\r"); |
- | |
166 | status = ST_EXIT; |
- | |
167 | return 0; |
- | |
168 | }; |
- | |
169 | ipc_client = incom->sender; |
- | |
170 | send_ipc(ipc_client,'CNCT'); |
- | |
171 | }; |
- | |
172 | - | ||
173 | - | ||
174 | snd_init=0; |
- | |
175 | create_thread(thread_proc, 0, 4096); |
- | |
176 | - | ||
177 | for(snd_init=0,cnt=100; (snd_init==0)&&(cnt!=0); cnt--) |
- | |
178 | delay(10); |
- | |
179 | - | ||
180 | if (!snd_init) |
- | |
181 | return 0; |
- | |
182 | - | ||
183 | draw_window(); |
- | |
184 | - | ||
185 | while(1) |
- | |
186 | { if(status==ST_PLAY) |
- | |
187 | { draw_progress_bar(); |
- | |
188 | evnt = wait_for_event(80); |
- | |
189 | } |
- | |
190 | else |
- | |
191 | evnt = wait_for_event_infinite(); |
- | |
192 | - | ||
193 | switch(evnt) |
- | |
194 | { |
- | |
195 | case EV_REDRAW: |
- | |
196 | draw_window(); |
- | |
197 | break; |
- | |
198 | - | ||
199 | case EV_KEY: |
- | |
200 | if(!get_key(&key)) |
- | |
201 | { |
- | |
202 | - | ||
203 | switch(key) |
- | |
204 | { case 0xE0: |
- | |
205 | case 0xE1: |
- | |
206 | break; |
- | |
207 | default: |
- | |
208 | switch (key) |
- | |
209 | { |
- | |
210 | case 0x01: //Esc |
- | |
211 | status = ST_EXIT; |
- | |
212 | exit(); |
- | |
213 | break; |
- | |
214 | - | ||
215 | case 0x47: //Home |
- | |
216 | if(l_vol < 0) |
- | |
217 | { l_vol+=100; |
- | |
218 | r_vol+=100; |
- | |
219 | SetVolume(hBuff,l_vol,r_vol); |
- | |
220 | }; |
- | |
221 | break; |
- | |
222 | case 0x4F: //End |
- | |
223 | if(l_vol > -10000) |
- | |
224 | { l_vol-=100; |
- | |
225 | r_vol-=100; |
- | |
226 | SetVolume(hBuff,l_vol,r_vol); |
- | |
227 | }; |
- | |
228 | break; |
- | |
229 | case 0x53: |
- | |
230 | if(pan > -10000) |
- | |
231 | { pan -=100; |
- | |
232 | SetPan(hBuff,pan); |
- | |
233 | }; |
- | |
234 | break; |
- | |
235 | case 0x51: |
- | |
236 | if(pan < 10000) |
- | |
237 | { pan +=100; |
- | |
238 | SetPan(hBuff,pan); |
- | |
239 | }; |
- | |
240 | break; |
- | |
241 | } |
- | |
242 | }; |
- | |
243 | }; |
- | |
244 | break; |
- | |
245 | - | ||
246 | case EV_BUTTON: |
- | |
247 | switch(get_button_id()) |
- | |
248 | { case 1: |
- | |
249 | status = ST_EXIT; |
- | |
250 | exit(); |
- | |
251 | break; |
- | |
252 | - | ||
253 | case 0x10: |
- | |
254 | status = ST_PLAY; |
- | |
255 | continue; |
- | |
256 | - | ||
257 | case 0x11: |
- | |
258 | status = ST_STOP; |
- | |
259 | break; |
- | |
260 | // case 0x12: |
- | |
261 | // case 0x13: |
- | |
262 | case 0x14: |
- | |
263 | if(l_vol > -10000) |
- | |
264 | { |
- | |
265 | l_vol-=100; |
- | |
266 | r_vol-=100; |
- | |
267 | SetVolume(hBuff,l_vol,r_vol); |
- | |
268 | }; |
- | |
269 | break; |
- | |
270 | - | ||
271 | case 0x15: |
- | |
272 | if(l_vol < 0) |
- | |
273 | { l_vol+=100; |
- | |
274 | r_vol+=100; |
- | |
275 | SetVolume(hBuff,l_vol,r_vol); |
- | |
276 | }; |
- | |
277 | break; |
- | |
278 | - | ||
279 | case 0x30: |
- | |
280 | if(status==ST_DONE) |
- | |
281 | break; |
- | |
282 | pos = (GetMousePos(REL_WINDOW)>>16)-7; |
- | |
283 | offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; |
- | |
284 | set_reader(&rd, offset); |
- | |
285 | draw_progress_bar(); |
- | |
286 | break; |
- | |
287 | }; |
- | |
288 | break; |
- | |
289 | case EV_IPC: |
- | |
290 | do_ipc(); |
- | |
291 | break; |
- | |
292 | }; |
- | |
293 | }; |
- | |
294 | - | ||
295 | - | ||
296 | - | ||
297 | - | ||
298 | return 0; |
- | |
299 | }; |
- | |
300 | 69 | void (*snd_play)(); |
|
301 | 70 | ||
302 | void draw_window() |
71 | void draw_window() |
Line 303... | Line 72... | ||
303 | { |
72 | { |
Line 341... | Line 110... | ||
341 | debug_out(*str); |
110 | debug_out(*str); |
342 | str++; |
111 | str++; |
343 | } |
112 | } |
344 | } |
113 | } |
Line -... | Line 114... | ||
- | 114 | ||
- | 115 | int main(int argc, char *argv[]) //int argc, char *argv[]) |
|
- | 116 | { |
|
- | 117 | DWORD fmt; |
|
- | 118 | DWORD r_bytes; |
|
- | 119 | int retval; |
|
- | 120 | int err; |
|
- | 121 | int ver; |
|
- | 122 | ||
- | 123 | fname = argv[1]; |
|
- | 124 | debug_out_str("\n\rPlay file "); |
|
- | 125 | debug_out_str(fname); |
|
- | 126 | debug_out_str("\n\r"); |
|
- | 127 | ||
- | 128 | InitHeap(1024*1024); |
|
- | 129 | if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) |
|
- | 130 | { debug_out_str("\n\rfile not found\n\r"); |
|
- | 131 | return 0; |
|
- | 132 | }; |
|
- | 133 | ||
- | 134 | if(err = InitSound(&ver)) |
|
- | 135 | { |
|
- | 136 | debug_out_str("Sound service not installed\n\r"); |
|
- | 137 | return 0; |
|
- | 138 | } |
|
- | 139 | ||
- | 140 | if( (SOUND_VERSION>(ver&0xFFFF)) || |
|
- | 141 | (SOUND_VERSION<(ver >> 16))) |
|
- | 142 | { |
|
- | 143 | debug_out_str("Sound service version mismatch\n\r"); |
|
- | 144 | return 0; |
|
- | 145 | } |
|
- | 146 | ||
- | 147 | testbuff = UserAlloc(4096); |
|
- | 148 | ||
- | 149 | get_fileinfo(fname, &fileinfo); |
|
- | 150 | r_bytes=0; |
|
- | 151 | retval=read_file (fname,testbuff,0,2048,&r_bytes); |
|
- | 152 | if ( retval && (r_bytes==0)) |
|
- | 153 | return 0; |
|
- | 154 | ||
- | 155 | inpbuf = UserAlloc(0x10000); |
|
- | 156 | touch(inpbuf, 0x10000); |
|
- | 157 | ||
- | 158 | create_reader(&rd, inpbuf, 0x10000); |
|
- | 159 | init_reader(&rd,fname); |
|
- | 160 | ||
- | 161 | fmt = test_wav((WAVEHEADER*)testbuff); |
|
- | 162 | if (fmt != 0) |
|
- | 163 | { |
|
- | 164 | snd_play = &play_wave; |
|
- | 165 | set_reader(&rd, 44); |
|
- | 166 | outbuf = UserAlloc(32*1024); |
|
- | 167 | touch(outbuf, 32768); |
|
- | 168 | } |
|
- | 169 | else |
|
- | 170 | { fmt = test_mp3(testbuff); |
|
- | 171 | if(fmt ==0) return 0; |
|
- | 172 | snd_play = &play_mp3; |
|
- | 173 | ||
- | 174 | outremain = 0x40000 ; |
|
- | 175 | outbuf = UserAlloc(outremain); |
|
- | 176 | touch(outbuf, outremain); |
|
- | 177 | make_decode_tables(32767); |
|
- | 178 | init_layer2(); |
|
- | 179 | init_layer3(32); |
|
- | 180 | fr.single = -1; |
|
- | 181 | }; |
|
- | 182 | ||
- | 183 | status = ST_PLAY; |
|
- | 184 | ||
- | 185 | if (err = CreateBuffer(fmt,0, &hBuff)) |
|
- | 186 | { |
|
- | 187 | debug_out_str("create buffer return error\n\r"); |
|
- | 188 | ; return 0; |
|
- | 189 | } |
|
- | 190 | ||
- | 191 | SetVolume(hBuff,l_vol,r_vol); |
|
- | 192 | GetVolume(hBuff,&l_vol,&r_vol); |
|
- | 193 | ||
- | 194 | create_thread(thread_proc, 0, 4096); |
|
- | 195 | ||
- | 196 | while(1) |
|
- | 197 | { delay(10); |
|
- | 198 | switch(status) |
|
- | 199 | { case ST_PLAY: |
|
- | 200 | snd_play(); |
|
- | 201 | continue; |
|
- | 202 | ||
- | 203 | case ST_STOP: |
|
- | 204 | StopBuffer(hBuff); |
|
- | 205 | status = ST_DONE; |
|
- | 206 | continue; |
|
- | 207 | ||
- | 208 | case ST_EXIT: |
|
- | 209 | StopBuffer(hBuff); |
|
- | 210 | DestroyBuffer(hBuff); |
|
- | 211 | return 0; |
|
- | 212 | }; |
|
- | 213 | }; |
|
- | 214 | return 0; |
|
Line 345... | Line 215... | ||
345 | 215 | }; |
|
346 | 216 | ||
347 | void touch(char *buf, int size) |
217 | void touch(char *buf, int size) |
348 | { int i; |
218 | { int i; |
Line 359... | Line 229... | ||
359 | { if(rd.filepos > 102400) |
229 | { if(rd.filepos > 102400) |
360 | return 0; |
230 | return 0; |
361 | if(!rd.head_read(&rd,&hdr)) |
231 | if(!rd.head_read(&rd,&hdr)) |
362 | return 0; |
232 | return 0; |
363 | if(!decode_header(&fr,hdr)) |
233 | if(!decode_header(&fr,hdr)) |
364 | { |
- | |
365 | if((hdr & 0xffffff00) == 0x49443300) |
- | |
366 | { |
- | |
367 | int id3length = 0; |
- | |
368 | id3length = parse_new_id3(&rd, hdr); |
- | |
369 | continue; |
- | |
370 | }; |
- | |
371 | - | ||
372 | rd.strpos-=3; |
234 | { rd.strpos-=3; |
373 | rd.stream-=3; |
235 | rd.stream-=3; |
374 | rd.strremain+=3; |
236 | rd.strremain+=3; |
375 | continue; |
237 | continue; |
376 | }; |
238 | }; |
377 | break; |
239 | break; |
Line 393... | Line 255... | ||
393 | void play_mp3() |
255 | void play_mp3() |
394 | { char *outPtr; |
256 | { char *outPtr; |
395 | int totalout; |
257 | int totalout; |
396 | int outcount; |
258 | int outcount; |
Line -... | Line 259... | ||
- | 259 | ||
397 | 260 | // memset(&fr,0,sizeof(fr)); |
|
398 | fr.down_sample_sblimit = 32; |
261 | fr.down_sample_sblimit = 32; |
399 | fr.single = -1; |
262 | fr.single = -1; |
Line 400... | Line 263... | ||
400 | reset_mpg(); |
263 | reset_mpg(); |
Line 429... | Line 292... | ||
429 | { if(totalout < 4096) |
292 | { if(totalout < 4096) |
430 | { memset(outPtr,0,4096-totalout); |
293 | { memset(outPtr,0,4096-totalout); |
431 | totalout = 4096; |
294 | totalout = 4096; |
432 | }; |
295 | }; |
433 | } |
296 | } |
- | 297 | else |
|
434 | else if(totalout < 8192) continue; |
298 | if(totalout < 8192) |
- | 299 | continue; |
|
Line 435... | Line 300... | ||
435 | 300 | ||
436 | outPtr = outbuf; |
301 | outPtr = outbuf; |
437 | while (totalout >= 4096) |
302 | while (totalout >= 4096) |
- | 303 | { |
|
438 | { |
304 | |
439 | WaveOut(hBuff,outPtr,4096); |
305 | WaveOut(hBuff,outPtr,4096); |
- | 306 | if(status!=ST_PLAY) |
|
440 | if(status!=ST_PLAY) |
307 | { if(status != ST_EXIT) |
441 | { StopBuffer(hBuff); |
308 | status = ST_STOP; |
442 | return; |
309 | return; |
443 | }; |
310 | }; |
444 | totalout-=4096; |
311 | totalout-=4096; |
445 | outPtr+=4096; |
312 | outPtr+=4096; |
446 | outremain+=4096; |
313 | outremain+=4096; |
447 | }; |
- | |
448 | 314 | }; |
|
449 | if(done) |
315 | if(done) |
Line 450... | Line -... | ||
450 | { status = ST_STOP; |
- | |
451 | - | ||
452 | if( ipc_client) |
- | |
453 | send_ipc(ipc_client,'DONE'); |
- | |
454 | return; |
316 | break; |
455 | } |
317 | |
456 | memmove(outbuf,outPtr, totalout); |
- | |
457 | outPtr = outbuf+totalout; |
- | |
458 | }; |
- | |
459 | }; |
- | |
460 | - | ||
461 | - | ||
462 | int play_track(char *path) |
- | |
463 | { |
- | |
464 | DWORD fmt; |
- | |
465 | DWORD r_bytes; |
- | |
466 | int retval; |
- | |
467 | int err; |
- | |
468 | // int err; |
- | |
469 | - | ||
470 | retval = ST_DONE; |
- | |
471 | - | ||
472 | get_fileinfo(path, &fileinfo); |
- | |
473 | offset = 0; |
- | |
474 | err=read_file (path,testbuff,0,2048,&r_bytes); |
- | |
475 | if (err) |
- | |
476 | return ST_DONE; |
- | |
477 | - | ||
478 | init_reader(&rd,path); |
- | |
479 | - | ||
480 | fmt = test_wav((WAVEHEADER*)testbuff); |
- | |
481 | if (fmt != 0) |
- | |
482 | { |
- | |
483 | snd_play = &play_wave; |
- | |
484 | set_reader(&rd, 44); |
318 | memmove(outbuf,outPtr, totalout); |
485 | retval = ST_PLAY; |
- | |
486 | } |
- | |
487 | else |
- | |
488 | { fmt = test_mp3(testbuff); |
- | |
489 | if(fmt ==0) |
- | |
490 | return ST_DONE; |
- | |
491 | - | ||
492 | snd_play = &play_mp3; |
- | |
493 | outremain = 0x40000; |
- | |
Line 494... | Line 319... | ||
494 | retval = ST_PLAY; |
319 | outPtr = outbuf+totalout; |
495 | }; |
320 | } |
496 | 321 | ||
Line 497... | Line -... | ||
497 | SetFormat(hBuff, fmt); |
- | |
498 | return retval; |
322 | if(status != ST_EXIT) |
499 | }; |
323 | status = ST_STOP; |
Line 500... | Line 324... | ||
500 | 324 | }; |
|
501 | 325 | ||
Line 523... | Line 347... | ||
523 | void snd_stop() |
347 | void snd_stop() |
524 | { |
348 | { |
525 | StopBuffer(hBuff); |
349 | StopBuffer(hBuff); |
526 | }; |
350 | }; |
Line -... | Line 351... | ||
- | 351 | ||
- | 352 | void _stdcall thread_proc(void *param) |
|
527 | 353 | { int evnt; |
|
- | 354 | int pos; |
|
- | 355 | int key; |
|
- | 356 | DWORD offset; |
|
- | 357 | ||
528 | void do_ipc() |
358 | _asm |
529 | { |
359 | { |
530 | IPC *incom; |
- | |
531 | incom = recieve_ipc(); |
- | |
532 | switch(incom->code) |
- | |
533 | { |
360 | mov eax, 66 |
534 | case 'PLAY': |
361 | mov ebx, 1 |
535 | fname = incom->data; |
362 | mov ecx, 1 |
536 | status = ST_TRACK; |
363 | int 0x40 |
Line 537... | Line 364... | ||
537 | return; |
364 | }; |
538 | - | ||
539 | case 'STOP': |
- | |
Line 540... | Line 365... | ||
540 | status = ST_STOP; |
365 | |
541 | return; |
366 | draw_window(); |
542 | 367 | ||
- | 368 | while(1) |
|
543 | case 'EXIT': |
369 | { if(status==ST_PLAY) |
544 | status = ST_EXIT; |
370 | { draw_progress_bar(); |
- | 371 | evnt = wait_for_event(80); |
|
Line 545... | Line 372... | ||
545 | exit(); |
372 | } |
546 | }; |
373 | else |
- | 374 | evnt = wait_for_event_infinite(); |
|
- | 375 | ||
547 | }; |
376 | switch(evnt) |
Line -... | Line 377... | ||
- | 377 | { |
|
548 | 378 | case EV_REDRAW: |
|
549 | void _stdcall thread_proc(void *param) |
379 | draw_window(); |
- | 380 | break; |
|
- | 381 | ||
- | 382 | case EV_KEY: |
|
- | 383 | if(!get_key(&key)) |
|
- | 384 | { |
|
- | 385 | ||
- | 386 | switch(key) |
|
- | 387 | { case 0xE0: |
|
- | 388 | case 0xE1: |
|
550 | { |
389 | break; |
551 | int err; |
390 | default: |
552 | 391 | switch (key) |
|
Line -... | Line 392... | ||
- | 392 | { |
|
- | 393 | case 0x01: //Esc |
|
- | 394 | status = ST_EXIT; |
|
- | 395 | exit(); |
|
553 | if (err = CreateBuffer(PCM_ALL|PCM_OUT,0, &hBuff)) |
396 | break; |
- | 397 | ||
- | 398 | case 0x47: //Home |
|
- | 399 | if(l_vol < 0) |
|
- | 400 | { l_vol+=100; |
|
- | 401 | r_vol+=100; |
|
- | 402 | SetVolume(hBuff,l_vol,r_vol); |
|
554 | { |
403 | }; |
- | 404 | break; |
|
555 | debug_out_str("create buffer return error\n\r"); |
405 | case 0x4F: //End |
556 | exit(); |
406 | if(l_vol > -10000) |
- | 407 | { l_vol-=100; |
|
- | 408 | r_vol-=100; |
|
- | 409 | SetVolume(hBuff,l_vol,r_vol); |
|
- | 410 | }; |
|
557 | }; |
411 | break; |
558 | 412 | case 0x53: |
|
559 | SetVolume(hBuff,l_vol,r_vol); |
- | |
- | 413 | if(pan > -10000) |
|
- | 414 | { pan -=100; |
|
- | 415 | SetPan(hBuff,pan); |
|
560 | GetVolume(hBuff,&l_vol,&r_vol); |
416 | }; |
561 | // debug_out_hex(l_vol); |
417 | break; |
- | 418 | case 0x51: |
|
- | 419 | if(pan < 10000) |
|
- | 420 | { pan +=100; |
|
- | 421 | SetPan(hBuff,pan); |
|
Line -... | Line 422... | ||
- | 422 | }; |
|
562 | // debug_out_str("\n\r"); |
423 | break; |
- | 424 | } |
|
- | 425 | }; |
|
563 | // debug_out_hex(r_vol); |
426 | }; |
564 | // debug_out_str("\n\r"); |
427 | break; |
Line 565... | Line 428... | ||
565 | 428 | ||
- | 429 | case EV_BUTTON: |
|
- | 430 | switch(get_button_id()) |
|
Line 566... | Line 431... | ||
566 | if(fname[0] !='/0') |
431 | { case 1: |
- | 432 | status = ST_EXIT; |
|
567 | status = play_track(fname); |
433 | exit(); |
- | 434 | break; |
|
- | 435 | ||
568 | 436 | case 0x10: |
|
- | 437 | status = ST_PLAY; |
|
569 | debug_out_str("\n\rPlay file "); |
438 | continue; |
570 | debug_out_str(fname); |
439 | |
571 | debug_out_str("\n\r"); |
440 | case 0x11: |
572 | - | ||
573 | snd_init = 1; |
- | |
574 | 441 | status = ST_STOP; |
|
575 | while(1) |
- | |
576 | { delay(10); |
442 | break; |
- | 443 | // case 0x12: |
|
Line 577... | Line 444... | ||
577 | switch(status) |
444 | // case 0x13: |
578 | { |
445 | case 0x14: |
579 | case ST_TRACK: |
446 | if(l_vol > -10000) |
580 | strcpy(path, fname); |
- | |
581 | status = play_track(fname); |
447 | { |
582 | if( ipc_client & (status == ST_DONE)) |
448 | l_vol-=100; |
583 | { send_ipc(ipc_client,'DONE'); |
449 | r_vol-=100; |
584 | continue; |
450 | SetVolume(hBuff,l_vol,r_vol); |
Line 585... | Line 451... | ||
585 | }; |
451 | }; |
586 | 452 | break; |
|
587 | case ST_PLAY: |
453 | |
- | 454 | case 0x15: |
|
- | 455 | if(l_vol < 0) |
|
588 | snd_play(); |
456 | { l_vol+=100; |
589 | continue; |
457 | r_vol+=100; |
590 | 458 | SetVolume(hBuff,l_vol,r_vol); |
|
- | 459 | }; |
|
591 | case ST_STOP: |
460 | break; |
592 | StopBuffer(hBuff); |
461 | |
593 | status = ST_DONE; |
- | |
594 | continue; |
- | |
595 | 462 | case 0x30: |
|
Line 596... | Line 463... | ||
596 | case ST_EXIT: |
463 | if(status==ST_DONE) |
597 | StopBuffer(hBuff); |
464 | break; |
598 | DestroyBuffer(hBuff); |
465 | pos = (GetMousePos(REL_WINDOW)>>16)-7; |