Subversion Repositories Kolibri OS

Rev

Rev 801 | Rev 1843 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 801 Rev 1842
Line 19... Line 19...
19
#include "../mpg/mpg123.h"
19
#include "../mpg/mpg123.h"
20
#include "../sound.h"
20
#include "../sound.h"
21
#include "../ufmod-codec.h"                   /* uFMOD integration */
21
#include "../ufmod-codec.h"                   /* uFMOD integration */
22
void exit();                                  /* uFMOD integration */
22
void exit();                                  /* uFMOD integration */
Line -... Line 23...
-
 
23
 
23
 
24
#define DOCKABLE_WINDOW
24
#define MP3_ERROR_OUT_OF_BUFFER  5
25
#define MP3_ERROR_OUT_OF_BUFFER  5
Line 25... Line 26...
25
int m_last_error;
26
int m_last_error;
26
 
27
 
-
 
28
void _stdcall thread_proc(void *param);
-
 
29
int _stdcall create_thread(void *proc, void *param, int stack_size);
27
void _stdcall thread_proc(void *param);
30
 
-
 
31
#ifdef DOCKABLE_WINDOW
Line 28... Line 32...
28
void _stdcall create_thread(void *proc, void *param, int stack_size);
32
void GetThreadInfo (char *info, int slot); //Asper+
29
void _stdcall send_ipc(int dst, DWORD code);
33
#endif
30
 
34
 
Line 31... Line 35...
31
void touch(char *buf, int size);
35
void touch(char *buf, int size);
32
int mp3FindSync(byte* buf, int size, int* sync);
36
int mp3FindSync(byte* buf, int size, int* sync);
33
int stream_read_raw(struct reader *rd,unsigned char *buf, int size);
-
 
-
 
37
int stream_read_raw(struct reader *rd,unsigned char *buf, int size);
34
 
38
 
-
 
39
int __cdecl _stricmp (const char * dst, const char * src);
Line 35... Line 40...
35
int __cdecl _stricmp (const char * dst, const char * src);
40
char *__cdecl strrchr (const char * string,int ch);
36
char *__cdecl strrchr (const char * string,int ch);
41
int _strncmp(char *src, char *dst, DWORD n); //Asper+
Line 37... Line 42...
37
 
42
int _strncpy (char *dst, char *src, int n); //Asper+
Line 45... Line 50...
45
SNDBUF hBuff;
50
SNDBUF hBuff;
Line 46... Line 51...
46
 
51
 
Line 47... Line 52...
47
CTRL_INFO info;
52
CTRL_INFO info;
48
 
53
 
49
FILEINFO   fileinfo;
54
FILEINFO   fileinfo;
-
 
55
const char filename[256];
Line 50... Line 56...
50
const char *filename;
56
const char *fileext;
51
const char *fileext;
57
char full_filename[4096];
52
 
58
 
53
int m_vol;
59
int m_vol;
Line 54... Line 60...
54
int l_vol=-700;     //-7db
60
int l_vol=-700;     //-7db
55
int r_vol=-700;
61
int r_vol=-700;
-
 
62
int pan =0;
-
 
63
 
-
 
64
DWORD status;
-
 
65
DWORD first_sync;
-
 
66
DWORD PLStatus=0; //Asper+
-
 
67
 
-
 
68
#ifdef DOCKABLE_WINDOW
-
 
69
byte thread_info[1024]; //Asper+
-
 
70
#endif
-
 
71
 
-
 
72
int tid, pl_tid;
-
 
73
const DWORD main_wh=92, pl_ww=300, pl_wh=382; //Asper+
Line 56... Line 74...
56
int pan =0;
74
DWORD pl_wx=100, pl_wy=101+92;  //Asper+
57
 
75
//DWORD main_wc=0x404040, main_bc=0x808080;  //Asper+ ac97snd Classic style
58
DWORD status;
76
//DWORD main_wc=0x002040, main_bc=0x008080, main_ic=0x002040, selected_ic=0x1010F0;  //Asper+
59
DWORD first_sync;
77
DWORD main_wc=0x101030, main_bc=0x008080, main_ic=0x000000, selected_ic=0x1010F0;  //Asper+
Line 68... Line 86...
68
int outremain;
86
int outremain;
69
int totalout;
87
int totalout;
70
int done;
88
int done;
Line 71... Line 89...
71
 
89
 
-
 
90
char header[] = "AC97 MP3 player";
72
char header[] = "AC97 MP3 player";
91
char header_PL[] = "PLAYLIST";
73
char buttons_xm[]  = " Play    Stop                    Vol-    Vol+"; /* uFMOD integration */
92
char buttons_xm[]  = " Play    Stop                    Vol-    Vol+"; /* uFMOD integration */
-
 
93
char buttons_wav[] = " Play    Stop     <<      >>     Vol-    Vol+"; /* uFMOD integration */
74
char buttons_wav[] = " Play    Stop     <<      >>     Vol-    Vol+"; /* uFMOD integration */
94
char button_PL[] = "PL"; //Asper+
Line 75... Line 95...
75
char *buttons_text = buttons_wav;                                     /* uFMOD integration */
95
char *buttons_text = buttons_wav;                                     /* uFMOD integration */
76
 
96
 
Line -... Line 97...
-
 
97
void play_xm();                                                       /* uFMOD integration */
-
 
98
void (*snd_play)();
-
 
99
 
-
 
100
 
-
 
101
//Asper_____________________Play List code start_____________________________
-
 
102
#define PLI_BUTTON_HEIGHT    13
-
 
103
#define PL_MAX_SHOWN_ITEMS   (pl_wh-PLI_BUTTON_HEIGHT-40)/PLI_BUTTON_HEIGHT
-
 
104
#define MAX_TEXT_WIDTH       46
-
 
105
 
-
 
106
int currSelected, currActive, currFirstShowed;
-
 
107
unsigned char *pl_buff;
-
 
108
char pl_path[4096];
-
 
109
int pl_items_number;
-
 
110
 
-
 
111
int ShowPLContent(char *filebuffer);
77
void play_xm();                                                       /* uFMOD integration */
112
int GetFileNameFromPL(const char *fbuff, int index, char *name);
78
void (*snd_play)();
113
void Win2Dos (char *st, int len);
79
 
-
 
80
void draw_window()
114
 
-
 
115
void HidePLWindow()
-
 
116
{
-
 
117
   BeginDraw();
Line 81... Line 118...
81
{
118
   ResizeReplaceWindow(pl_wx,pl_wy,0,0);
-
 
119
   EndDraw();
-
 
120
}
Line 82... Line 121...
82
	int len;                                                          /* uFMOD integration */
121
 
83
   BeginDraw();
122
void ShowPLWindow()
84
 
-
 
85
   DrawWindow(100,100,299,72,0x404040,3,0,0,0);
-
 
86
 
-
 
87
   make_button(7,24,45,13, 0x10|BT_NORMAL,0x808080);
-
 
Line 88... Line 123...
88
   make_button(56,24,45,13, 0x11|BT_NORMAL,0x808080);
123
{
89
   make_button(104,24,45,13, 0x12|BT_NORMAL,0x808080);
124
   unsigned int i;
Line -... Line 125...
-
 
125
 
-
 
126
   BeginDraw();
-
 
127
   DrawWindow(pl_wx,pl_wy,pl_ww,pl_wh,main_ic,4,0,0,0);
-
 
128
 
-
 
129
   for (i=0; i
-
 
130
	   make_button(7,24+i*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, (0x10+i)|BT_NORMAL|BT_NOFRAME, main_ic);
-
 
131
 
-
 
132
   write_text(8,8,FONT0, header_PL, sizeof(header_PL)-1);
-
 
133
   ShowPLContent(pl_buff);
-
 
134
   EndDraw();
-
 
135
}
-
 
136
 
-
 
137
int LoadTrack(int i)
-
 
138
{
-
 
139
	if (GetFileNameFromPL(pl_buff, i, filename))
-
 
140
	{
-
 
141
		strcpy (full_filename, pl_path);
-
 
142
		strcat (full_filename, filename);
-
 
143
		return 1;
-
 
144
	}
-
 
145
	return 0;
-
 
146
}
-
 
147
 
-
 
148
void _stdcall pl_thread_proc(void *param)
-
 
149
{  int evnt;
-
 
150
   int key, button;
-
 
151
   DWORD tmp_x, tmp_y, i; //Asper+
-
 
152
   char ipc_buff[16]="";
-
 
153
 
-
 
154
   set_event_mask(0x47); //Asper + IPC event
-
 
155
   ipc_init(ipc_buff, 16);
-
 
156
   
-
 
157
  _asm
-
 
158
  {
-
 
159
    mov eax, 66
-
 
160
    mov ebx, 1
-
 
161
    mov ecx, 1
-
 
162
    int 0x40
-
 
163
  };
-
 
164
    
-
 
165
  ShowPLWindow();
-
 
166
 
-
 
167
  while(1)
-
 
168
  {
-
 
169
	if (PLStatus&0xF0) 
-
 
170
    {
-
 
171
		switch(PLStatus)
-
 
172
		{
-
 
173
			case 0x11:
-
 
174
				HidePLWindow();
-
 
175
			break;
-
 
176
			case 0x12:
-
 
177
				ResizeReplaceWindow(pl_wx,pl_wy,pl_ww,pl_wh);			
-
 
178
			break;
-
 
179
		}
-
 
180
		PLStatus&=0x0F;
-
 
181
	}
-
 
182
	switch (status)
-
 
183
	{
-
 
184
		case ST_TRACK:
-
 
185
			break;
-
 
186
		case ST_EXIT:
-
 
187
			PLStatus=0x00;
-
 
188
			exit();
-
 
189
	}
-
 
190
 
-
 
191
#ifdef DOCKABLE_WINDOW
-
 
192
	tmp_x = (DWORD)thread_info[35]*0x100+(DWORD)thread_info[34];
-
 
193
	tmp_y = (DWORD)thread_info[38]+main_wh+1;
-
 
194
	if (pl_wx!= tmp_x || pl_wy!=tmp_y)
-
 
195
	{
-
 
196
		pl_wx=tmp_x;
-
 
197
		pl_wy=tmp_y;
-
 
198
		ResizeReplaceWindow(pl_wx,pl_wy,-1,-1);
-
 
199
	}
-
 
200
#endif
-
 
201
 
-
 
202
    evnt = wait_for_event(20);
-
 
203
 
-
 
204
    switch(evnt)
-
 
205
    {
-
 
206
      case EV_REDRAW:
-
 
207
			  ShowPLWindow();
-
 
208
        break;
-
 
209
 
-
 
210
      case EV_KEY:
-
 
211
        if(!get_key(&key))
-
 
212
        { 
-
 
213
        
-
 
214
          switch(key)
-
 
215
          {  case 0xE0:
-
 
216
             case 0xE1:
-
 
217
               break;
-
 
218
             default:
-
 
219
               switch (key)
-
 
220
               {
-
 
221
                 case 0x01:  //Esc
-
 
222
					 PLStatus=0x00;
-
 
223
					 exit();
-
 
224
					 break;
-
 
225
 
-
 
226
				 case 0x1C:  //Enter                   
-
 
227
					 currActive=currFirstShowed+currSelected-1;
-
 
228
					 status = ST_TRACK; 
-
 
229
					 break; 
-
 
230
                 case 0x47:  //Home
-
 
231
					 if(l_vol < 0)
-
 
232
					 { l_vol+=100;
-
 
233
					   r_vol+=100;  
-
 
234
					   SetVolume(hBuff,l_vol,r_vol);
-
 
235
					 };
-
 
236
				   break;
-
 
237
                 case 0x48:  //Up
-
 
238
					 if (currSelected==0) 
-
 
239
					 {
-
 
240
						 if (currFirstShowed>0)
-
 
241
							 currFirstShowed--;
-
 
242
						 ShowPLContent(pl_buff);
-
 
243
						 break;
-
 
244
					 }
-
 
245
					 currSelected--;
-
 
246
					 ShowPLContent(pl_buff);
-
 
247
					 break;
-
 
248
                 case 0x50:  //Down
-
 
249
					 if (currSelected+currFirstShowed > pl_items_number-2) break;
-
 
250
					 if (currSelected==PL_MAX_SHOWN_ITEMS-1)
-
 
251
					 {
-
 
252
						 //if (currFirstShowed
-
 
253
							 currFirstShowed++;
-
 
254
						 ShowPLContent(pl_buff);
-
 
255
						 break;
-
 
256
					 }
-
 
257
					 //if (currSelected
-
 
258
					 currSelected++;
-
 
259
					 ShowPLContent(pl_buff);
-
 
260
					 break;
-
 
261
                 case 0x4F:  //End                
-
 
262
					 if(l_vol > -10000)
-
 
263
					 { l_vol-=100;
-
 
264
					   r_vol-=100;  
-
 
265
					   SetVolume(hBuff,l_vol,r_vol);
-
 
266
					 }; 
-
 
267
					 break;
-
 
268
                 case 0x53:
-
 
269
					 if(pan > -10000)
-
 
270
					 { pan -=100;
-
 
271
					   SetPan(hBuff,pan);
-
 
272
					 };
-
 
273
					 break;   
-
 
274
                 case 0x51:
-
 
275
					 if(pan < 10000)
-
 
276
					 { pan +=100;
-
 
277
					   SetPan(hBuff,pan);
-
 
278
					 };
-
 
279
					 break;   
-
 
280
			   } 
-
 
281
		  };     
-
 
282
		};  
-
 
283
		break;
-
 
284
 
-
 
285
      case EV_BUTTON:
-
 
286
		  button=get_button_id();
-
 
287
		  if (button==1)
-
 
288
		  {
-
 
289
			  PLStatus=0x00;
-
 
290
			  exit();
-
 
291
		  }
-
 
292
		  for (i=0;i
-
 
293
		  {
-
 
294
			  if (button==0x10+i)
-
 
295
			  {
-
 
296
				  currActive=currFirstShowed+i-1;
-
 
297
				  status = ST_TRACK; 
-
 
298
				  break;
-
 
299
			  }
-
 
300
		  }
-
 
301
		  break;
-
 
302
	  case EV_IPC:
-
 
303
  		  *ipc_buff='\0';
-
 
304
		  ShowPLContent(pl_buff);
-
 
305
		  break;
-
 
306
 
-
 
307
	}
-
 
308
  }
-
 
309
}
-
 
310
 
-
 
311
void Win2Dos (char *st, int len) 
-
 
312
{
-
 
313
	int i;
-
 
314
	unsigned char ch;
-
 
315
 
-
 
316
	for (i=0; i
-
 
317
	{
-
 
318
		ch = st[i];
-
 
319
		if (ch>=192)
-
 
320
		{
-
 
321
			if (ch>=240) ch-=16;
-
 
322
			else ch-=64;
-
 
323
		}
-
 
324
		else
-
 
325
		{
-
 
326
			if (ch==168) ch = 240;
-
 
327
			if (ch==184) ch = 241;
-
 
328
			if (ch==185) ch = 252;
-
 
329
			if ((ch==147) || (ch==148) || (ch==171) || (ch==187)) ch = 34;
-
 
330
			if ((ch==150) || (ch==151)) ch = 45;
-
 
331
		}
-
 
332
		st[i]=ch;
-
 
333
	}
-
 
334
}
-
 
335
 
-
 
336
int GetFileNameFromPL(const char *plbuff, int index, char *name)
-
 
337
{
-
 
338
	int count=0,i=0,j=0;
-
 
339
	char ch;
-
 
340
 
-
 
341
	do{		
-
 
342
		ch=plbuff[i];
-
 
343
		if (ch!='#' && i && plbuff[i-1]=='\n')
-
 
344
			count++;
-
 
345
		if (count-1==index) 
-
 
346
		{
-
 
347
			if (j>MAX_TEXT_WIDTH || ch=='\n')
-
 
348
			{
-
 
349
				name[j-1]='\0';
-
 
350
				break;
-
 
351
			}
-
 
352
			if (ch=='\\') ch='/';
-
 
353
			name[j++]=ch;
-
 
354
		}
-
 
355
		else if (count-1>index) break;
-
 
356
		i++;
-
 
357
	}while (ch);
-
 
358
	if (!ch) return 0;
-
 
359
	return j;
-
 
360
}
-
 
361
 
-
 
362
int CountFileNamesInPL(const char *plbuff)
-
 
363
{
-
 
364
	int count=0,i=0;
-
 
365
	char ch;
-
 
366
 
-
 
367
	do{		
-
 
368
		ch=plbuff[i];
-
 
369
		if (ch!='#' && i && plbuff[i-1]=='\n')
-
 
370
			count++;
-
 
371
		i++;
-
 
372
	}while (ch);
-
 
373
	if (count) count--;
-
 
374
	return count;
-
 
375
}
-
 
376
 
-
 
377
int ShowPLContent(char *filebuffer)
-
 
378
{
-
 
379
	char st[MAX_TEXT_WIDTH+10]="", tmp[MAX_TEXT_WIDTH+1]="";
-
 
380
	unsigned int len=8,i;
-
 
381
	DWORD text_color;
-
 
382
 
-
 
383
	draw_bar(7,24,285,PLI_BUTTON_HEIGHT*(PL_MAX_SHOWN_ITEMS+2), main_ic);
-
 
384
	draw_bar(7,24+currSelected*(PLI_BUTTON_HEIGHT+1),285,PLI_BUTTON_HEIGHT, selected_ic);
-
 
385
	for (i=0; i
-
 
386
	{
-
 
387
		text_color = (currFirstShowed+i==currActive?0xFFFFFF|FONT0:0x00FF20|FONT0);
-
 
388
		if (!GetFileNameFromPL(filebuffer, i+currFirstShowed, tmp)) break;
-
 
389
		uint2str(currFirstShowed+i+1, st);
-
 
390
		strcat(st, ". ");
-
 
391
		strcat(st, tmp);
-
 
392
		len = strlen(st);
-
 
393
		if (len > MAX_TEXT_WIDTH) 
-
 
394
			len = MAX_TEXT_WIDTH;
-
 
395
		write_text(11,i*(PLI_BUTTON_HEIGHT+1)+27,text_color, st, len);
-
 
396
	}
-
 
397
	return 1;
-
 
398
}
90
   make_button(152,24,45,13, 0x13|BT_NORMAL,0x808080);
399
//Asper_____________________Play List code end_____________________________ 
91
   make_button(200,24,45,13, 0x14|BT_NORMAL,0x808080);
400
 
92
   make_button(248,24,45,13, 0x15|BT_NORMAL,0x808080);
401
void update_dinamic_content() //Asper +
93
 
402
{
-
 
403
	int len;                                                          /* uFMOD integration */
Line -... Line 404...
-
 
404
	draw_bar(7,41,286,11,main_wc);
-
 
405
	
-
 
406
	draw_bar(7,55,286,11,main_wc);
-
 
407
	len = strlen(filename);                                                /* uFMOD integration */
-
 
408
	if(len > 47) len = 47;                                              /* uFMOD integration */
-
 
409
	write_text(11,57,0x00FF20|FONT0, filename, len);                        /* uFMOD integration */
-
 
410
}
-
 
411
 
-
 
412
void draw_window()
-
 
413
{
-
 
414
   BeginDraw();
-
 
415
 
-
 
416
   DrawWindow(100,100,299,main_wh,main_wc,4,0,0,0); //Asper+   
-
 
417
 
-
 
418
   make_button(7,24,45,13, 0x10|BT_NORMAL,main_bc);
-
 
419
   make_button(56,24,45,13, 0x11|BT_NORMAL,main_bc);
-
 
420
   make_button(104,24,45,13, 0x12|BT_NORMAL,main_bc);
-
 
421
   make_button(152,24,45,13, 0x13|BT_NORMAL,main_bc);
94
   make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,0x404040);
422
   make_button(200,24,45,13, 0x14|BT_NORMAL,main_bc);
95
   draw_bar(7,41,286,11,0x404040);
423
   make_button(248,24,45,13, 0x15|BT_NORMAL,main_bc);
96
 
424
 
Line -... Line 425...
-
 
425
   make_button(268,70,25,13, 0x16|BT_NORMAL,main_bc); //Asper+ PL button
-
 
426
 
97
   draw_bar(7,55,286,11,0x404040);
427
   make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,main_wc);
98
	 len = strlen(filename);                                                /* uFMOD integration */
428
 
Line 99... Line 429...
99
	 if(len > 47) len = 47;                                              /* uFMOD integration */
429
   update_dinamic_content();
100
   write_text(11,57,0x00FF20|FONT0, filename, len);                        /* uFMOD integration */
430
   write_text(8,8,FONT0, header, sizeof(header)-1);                     /* uFMOD integration */
101
 
431
   write_text(12,28,main_wc|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */
102
   write_text(8,8,FONT0, header, sizeof(header)-1);                     /* uFMOD integration */
432
   write_text(11,27,0xA0FFA0|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */
103
   write_text(12,28,0x404040|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */
433
 
104
   write_text(11,27,0xA0FFA0|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */
434
   write_text(276,74,main_wc|FONT0,button_PL,sizeof(button_PL)-1); //Asper+ PL button text
105
 
435
   write_text(275,73,0xA0FFA0|FONT0,button_PL,sizeof(button_PL)-1); //Asper+
Line 106... Line 436...
106
   EndDraw();
436
   EndDraw();
107
};
437
};
108
 
438
 
109
void draw_progress_bar()
439
void draw_progress_bar()
110
{  DWORD x;
440
{  DWORD x;
111
   x = (DWORD)(287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size); /* uFMOD integration */
441
   x = (DWORD)(287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size); /* uFMOD integration */
112
   if(x==0) return;
442
   if(x==0) return;
113
   draw_bar(7,41,x,11,0xA0A0A0);
443
   draw_bar(7,41,x,11,0xA0A0A0);
Line -... Line 444...
-
 
444
   draw_bar(x+7,41,287-x,11,main_wc);
-
 
445
};
-
 
446
 
-
 
447
void debug_out_str(const char* str)
-
 
448
{
-
 
449
  while (*str != 0)
-
 
450
  {
-
 
451
    debug_out(*str);
-
 
452
    str++;
-
 
453
  }
-
 
454
}
-
 
455
 
-
 
456
int LoadPL(char *fname)
-
 
457
{
-
 
458
	DWORD fmt;
-
 
459
	DWORD r_bytes;
-
 
460
	int retval;
-
 
461
	int i;
-
 
462
//		char st[100]="";
-
 
463
 
-
 
464
	char *pch;
-
 
465
 
-
 
466
	r_bytes=0;
-
 
467
	pch=strrchr(fname, '/');
-
 
468
	if (pch)
-
 
469
		i=pch-fname+1;
-
 
470
	else
-
 
471
		i=strlen(fname);
-
 
472
 
-
 
473
	_strncpy (pl_path, fname, i);
114
   draw_bar(x+7,41,287-x,11,0x404040);
474
	pl_path[i]='\0';
-
 
475
 
-
 
476
	if (!pl_buff)
-
 
477
		pl_buff = UserAlloc(0x40000);
-
 
478
	retval=read_file (fname,pl_buff,0,0x40000,&r_bytes);
-
 
479
 
-
 
480
	if ( retval && (r_bytes==0))
-
 
481
		return 0;
-
 
482
 
-
 
483
	Win2Dos(pl_buff, r_bytes);
-
 
484
	pl_items_number=CountFileNamesInPL(pl_buff);
-
 
485
/*
-
 
486
	debug_out_str("\n\rPlay List files number = ");
-
 
487
	itoa(pl_items_number, st, 10);
-
 
488
	debug_out_str(st);
-
 
489
*/
-
 
490
	fmt = test_m3u(pl_buff);
-
 
491
 
115
};
492
	if(!fmt)
116
 
493
	{
117
void debug_out_str(char* str)
494
		debug_out_str("\n\rInvalid M3U file");
118
{
495
		return 0;
119
  while (*str != 0)
496
	}
120
  {
-
 
121
    debug_out(*str);
497
	debug_out_str("\n\rValid M3U file");
Line 122... Line -...
122
    str++;
-
 
123
  }
498
	currSelected=currFirstShowed=0;
124
}
499
	currActive=-1;
125
 
500
	return 1;
Line 126... Line -...
126
int main(int argc, char *argv[])      //int argc, char *argv[])
-
 
127
{
501
}
128
   DWORD fmt;
502
 
129
   DWORD r_bytes;
503
int LoadFile(char *fname)
130
   int retval;
504
{
Line -... Line 505...
-
 
505
   DWORD fmt;
131
   int err;
506
   DWORD r_bytes;
132
   int ver;
-
 
133
   unsigned char *ttl, *cur;               /* uFMOD integration */
507
   int retval;
134
    
508
   int err;
135
   fname = argv[1];
-
 
Line 136... Line 509...
136
   debug_out_str("\n\rPlay file ");
509
   unsigned char *ttl, *cur;               /* uFMOD integration */
137
   debug_out_str(fname); 
-
 
138
   debug_out_str("\n\r");
510
 
-
 
511
   debug_out_str("\n\rPlay file ");
139
    
512
   debug_out_str(fname); 
140
   InitHeap(1024*1024);
513
   debug_out_str("\n\r");
141
   if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND)
514
 
Line -... Line 515...
-
 
515
   if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND)
142
   {  debug_out_str("\n\rfile not found\n\r"); 
516
   {  debug_out_str("\n\rfile not found\n\r");
Line 143... Line -...
143
      return 0;
-
 
144
   };
-
 
145
   
517
      return 0;
146
   if(err = InitSound(&ver))
518
   }
147
   {  
519
 
Line -... Line 520...
-
 
520
   r_bytes=0;
-
 
521
   strcpy(filename, strrchr(fname,'/')+1);
148
     debug_out_str("Sound service not installed\n\r"); 
522
   if( !(fileext = strrchr(filename,'.')))
149
     return 0;
523
	   return 0;
150
   }
524
 
151
   
525
   if(!_stricmp(fileext,".m3u"))
152
   if( (SOUND_VERSION>(ver&0xFFFF)) ||
526
   {
Line 153... Line -...
153
       (SOUND_VERSION<(ver >> 16)))
-
 
154
   {  
-
 
155
     debug_out_str("Sound service version mismatch\n\r"); 
-
 
156
     return 0;
-
 
157
   }
527
	   LoadPL(fname);
158
   
528
	   status=ST_TRACK;
159
   testbuff = UserAlloc(4096); 
529
	   return 1;
160
   
530
   }
161
   get_fileinfo(fname, &fileinfo);
531
 
162
   r_bytes=0;
532
   if (!testbuff)
163
   retval=read_file (fname,testbuff,0,2048,&r_bytes);
533
	   testbuff = UserAlloc(4096);
164
   if ( retval && (r_bytes==0)) 
534
 
165
     return 0;
535
   retval=read_file (fname,testbuff,0,2048,&r_bytes);
166
    
536
   if ( retval && (r_bytes==0))
-
 
537
	   return 0;
-
 
538
 
167
   inpbuf = UserAlloc(0x10000);
539
   if (!inpbuf)
168
   touch(inpbuf, 0x10000);
540
   {
-
 
541
	   inpbuf = UserAlloc(0x10000);
169
   
542
	   touch(inpbuf, 0x10000);
170
   create_reader(&rd, inpbuf, 0x10000);
543
   }
171
   init_reader(&rd,fname);
544
   create_reader(&rd, inpbuf, 0x10000);
172
   
545
   init_reader(&rd,fname);
173
   filename = strrchr(fname,'/')+1;
546
 
Line 231... Line 604...
231
		 }
604
		 }
232
     debug_out_str("\n\rInvalid WAV file");
605
     debug_out_str("\n\rInvalid WAV file");
233
     return 0;
606
     return 0;
234
	 };	
607
	 };	
Line 235... Line 608...
235
 
608
 
236
   debug_out_str("\n\rUsupported file");
609
   debug_out_str("\n\rUnsupported file");
Line 237... Line 610...
237
   return 0;
610
   return 0;
Line 238... Line 611...
238
 
611
 
-
 
612
play:
-
 
613
 
-
 
614
   status = ST_PLAY;
Line -... Line 615...
-
 
615
   SetFormat(hBuff, fmt);
-
 
616
   SetVolume(hBuff,l_vol,r_vol);
-
 
617
   GetVolume(hBuff,&l_vol,&r_vol);
239
play:
618
 
240
 
619
   return 1;
-
 
620
}
-
 
621
 
-
 
622
int main(int argc, char *argv[])
-
 
623
{
-
 
624
   int err, ver;
-
 
625
   int i;
-
 
626
   char ipc_msg[2]="\0\0";
-
 
627
    
-
 
628
   strcpy (full_filename, argv[1]);
-
 
629
   pl_items_number=0;
-
 
630
    
241
   status = ST_PLAY;
631
   InitHeap(1024*1024);
242
   
632
   
243
   if (err = CreateBuffer(fmt,0, &hBuff))
633
   if(err = InitSound(&ver))
Line -... Line 634...
-
 
634
   {  
244
   {
635
     debug_out_str("Sound service not installed\n\r"); 
-
 
636
     return 0;
-
 
637
   }
-
 
638
   
-
 
639
   if( (SOUND_VERSION>(ver&0xFFFF)) ||
-
 
640
       (SOUND_VERSION<(ver >> 16)))
245
     debug_out_str("create buffer return error\n\r"); 
641
   {  
-
 
642
     debug_out_str("Sound service version mismatch\n\r"); 
-
 
643
     return 0;
-
 
644
   }
-
 
645
 
Line -... Line 646...
-
 
646
   if (err = CreateBuffer(PCM_2_16_48, 0, &hBuff))
-
 
647
   {
246
    ; return 0;
648
     debug_out_str("create buffer return error\n\r"); 
Line 247... Line 649...
247
   }
649
     return 0;
248
       
650
   }
249
   SetVolume(hBuff,l_vol,r_vol);
651
 
250
   GetVolume(hBuff,&l_vol,&r_vol); 
652
   if (!LoadFile(full_filename))
-
 
653
	   return 0;
-
 
654
   tid=create_thread(thread_proc, 0, 4096);
-
 
655
   
-
 
656
   while(1)
-
 
657
   {  delay(10);
-
 
658
      switch(status)
-
 
659
      {  case ST_TRACK:
-
 
660
			StopBuffer(hBuff);
-
 
661
			if (LoadTrack(++currActive))
-
 
662
			{
-
 
663
				if (LoadFile(full_filename))
-
 
664
					status = ST_PLAY;
-
 
665
			}
-
 
666
			else status = ST_STOP;
-
 
667
 
-
 
668
			//Update ac97snd and PL windows
-
 
669
			i=currActive-currFirstShowed;
251
 
670
			if (i>PL_MAX_SHOWN_ITEMS-1)
252
   create_thread(thread_proc, 0, 4096);
671
				currFirstShowed = currActive - PL_MAX_SHOWN_ITEMS/2;
Line 253... Line 672...
253
   
672
			ipc_send_msg(tid, ipc_msg);
254
   while(1)
673
			ipc_send_msg(pl_tid, ipc_msg);
Line 278... Line 697...
278
   char a;
697
   char a;
279
    for ( i = 0;i < size; i+=4096)     //alloc all pages
698
    for ( i = 0;i < size; i+=4096)     //alloc all pages
280
      a = buf[i]; 
699
      a = buf[i]; 
281
};
700
};
Line -... Line 701...
-
 
701
 
-
 
702
DWORD test_m3u(char *buf) //Asper+
-
 
703
{
-
 
704
	char  *sign="#EXTM3U";
-
 
705
	return _strncmp(buf, sign, 7);
-
 
706
}
282
 
707
 
283
DWORD test_mp3(char *buf)
708
DWORD test_mp3(char *buf)
284
{  unsigned long hdr; 
709
{  unsigned long hdr; 
Line 285... Line 710...
285
    WAVEHEADER whdr; 
710
    WAVEHEADER whdr; 
Line 368... Line 793...
368
    while (totalout >= 4096)
793
    while (totalout >= 4096)
369
    { 
794
    { 
Line 370... Line 795...
370
    
795
    
371
      WaveOut(hBuff,outPtr,4096);
796
      WaveOut(hBuff,outPtr,4096);
372
      if(status!=ST_PLAY)
797
      if(status!=ST_PLAY)
373
      { if(status != ST_EXIT)
798
      { if ((status != ST_EXIT) && (status != ST_STOP))
374
         status =  ST_STOP;
799
         status = ST_TRACK;
375
        return; 
800
        return; 
376
      };
801
      };
377
      totalout-=4096; 
802
      totalout-=4096; 
378
      outPtr+=4096;
803
      outPtr+=4096;
Line 383... Line 808...
383
      
808
      
384
    memmove(outbuf,outPtr, totalout);
809
    memmove(outbuf,outPtr, totalout);
385
    outPtr = outbuf+totalout;
810
    outPtr = outbuf+totalout;
Line 386... Line 811...
386
   } 
811
   } 
387
  
812
  
388
    if(status != ST_EXIT)
813
    if ((status != ST_EXIT) && (status != ST_STOP))
Line 389... Line 814...
389
      status =  ST_STOP;
814
      status =  ST_TRACK;
390
};
815
};
Line 405... Line 830...
405
      }
830
      }
406
      done = 1;
831
      done = 1;
407
      break; 
832
      break; 
408
   };
833
   };
Line 409... Line 834...
409
 
834
 
410
   if(status != ST_EXIT)
835
   if ((status != ST_EXIT) && (status != ST_STOP))
411
     status =  ST_STOP;
836
     status =  ST_TRACK;
Line 412... Line 837...
412
};
837
};
413
 
838
 
414
void play_xm(){                             /* uFMOD integration */
839
void play_xm(){                             /* uFMOD integration */
415
	while(status == ST_PLAY){                 /* uFMOD integration */
840
	while(status == ST_PLAY){                 /* uFMOD integration */
416
		uFMOD_WaveOut(hBuff);                   /* uFMOD integration */
841
		uFMOD_WaveOut(hBuff);                   /* uFMOD integration */
417
		delay(8);                               /* uFMOD integration */
842
		delay(8);                               /* uFMOD integration */
418
	}                                         /* uFMOD integration */
843
	}                                         /* uFMOD integration */
Line 419... Line 844...
419
	if(status != ST_EXIT) status = ST_STOP;   /* uFMOD integration */
844
	if ((status != ST_EXIT) && (status != ST_STOP)) status = ST_TRACK;   /* uFMOD integration */
420
}                                           /* uFMOD integration */
845
}                                           /* uFMOD integration */
421
 
846
 
Line 427... Line 852...
427
void _stdcall thread_proc(void *param)
852
void _stdcall thread_proc(void *param)
428
{  int evnt;
853
{  int evnt;
429
   int pos;
854
   int pos;
430
   int key;
855
   int key;
431
   DWORD offset;
856
   DWORD offset;
-
 
857
   char ipc_buff[16];
-
 
858
 
-
 
859
   set_event_mask(0x47); //Asper + IPC event
-
 
860
   ipc_init(ipc_buff, 16);
Line 432... Line 861...
432
 
861
 
433
  _asm
862
  _asm
434
  {
863
  {
435
    mov eax, 66
864
    mov eax, 66
Line 439... Line 868...
439
  };
868
  };
Line 440... Line 869...
440
    
869
    
Line 441... Line 870...
441
  draw_window();
870
  draw_window();
-
 
871
 
442
 
872
  while(1)
443
  while(1)
873
  {
444
  {  if(status==ST_PLAY)
874
	 if(status==ST_PLAY)
445
     {  draw_progress_bar();
875
     {  draw_progress_bar();
446
        evnt = wait_for_event(80);
876
        evnt = wait_for_event(80);		
447
     }
877
     }
Line -... Line 878...
-
 
878
     else
-
 
879
		 evnt = wait_for_event_infinite();
-
 
880
 
-
 
881
#ifdef DOCKABLE_WINDOW
448
     else
882
     GetThreadInfo(thread_info, -1);
449
        evnt = wait_for_event_infinite();
883
#endif
450
 
884
 
451
    switch(evnt)
885
    switch(evnt)
452
    {
886
    {
Line 513... Line 947...
513
             continue;
947
             continue;
Line 514... Line 948...
514
 
948
 
515
           case 0x11:
949
           case 0x11:
516
             status = ST_STOP;
950
             status = ST_STOP;
517
             break;
951
             break;
-
 
952
           case 0x12:
-
 
953
			   currActive-=2;
-
 
954
			   status = ST_TRACK;
518
//           case 0x12:
955
			   break;
-
 
956
           case 0x13:
-
 
957
			   status = ST_TRACK;
519
//           case 0x13:
958
			   break;
520
           case 0x14:
959
           case 0x14:
521
            if(l_vol > -10000)
960
            if(l_vol > -10000)
522
            {
961
            {
523
              l_vol-=100;
962
              l_vol-=100;
Line 532... Line 971...
532
              r_vol+=100;  
971
              r_vol+=100;  
533
              SetVolume(hBuff,l_vol,r_vol);
972
              SetVolume(hBuff,l_vol,r_vol);
534
            };
973
            };
535
            break;
974
            break;
Line -... Line 975...
-
 
975
 
-
 
976
           case 0x16: //Asper+ PL button action
-
 
977
			   switch (PLStatus)
-
 
978
			   {    case 0x00: //PL not started.
-
 
979
						pl_tid=create_thread(pl_thread_proc, 0, 4096);              
-
 
980
						PLStatus=0x12;
-
 
981
				    break;
-
 
982
					case 0x01: //PL started, but hidden.
-
 
983
						PLStatus=0x12;
-
 
984
				    break;
-
 
985
					case 0x02: //PL started and showed.
-
 
986
						PLStatus=0x11;
-
 
987
					break;
-
 
988
			   }
-
 
989
            break;
536
 
990
 
537
           case 0x30:
991
           case 0x30:
538
            if(status==ST_DONE)
992
            if(status==ST_DONE)
539
              break;
993
              break;
540
            pos = (GetMousePos(REL_WINDOW)>>16)-7;
994
            pos = (GetMousePos(REL_WINDOW)>>16)-7;
541
            offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC;
995
            offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC;
542
            set_reader(&rd, offset); 
996
            set_reader(&rd, offset); 
543
            draw_progress_bar();
997
            draw_progress_bar();
544
            break;
998
            break;
-
 
999
        };
-
 
1000
		break;
-
 
1001
 
-
 
1002
	  case EV_IPC:
-
 
1003
		  *ipc_buff='\0';
-
 
1004
		  update_dinamic_content();
-
 
1005
		  break;
545
        };
1006
 
546
    };
1007
    };
547
  };
1008
  };
Line 548... Line 1009...
548
};
1009
};
Line 596... Line 1057...
596
    mov   ebx, 2
1057
    mov   ebx, 2
597
    int   0x40
1058
    int   0x40
598
  };  
1059
  };  
599
};
1060
};
Line -... Line 1061...
-
 
1061
 
-
 
1062
//Asper+_______start KolibriOS sys functions___________________
-
 
1063
void ResizeReplaceWindow (DWORD x, DWORD y, DWORD w, DWORD h) //Asper+
-
 
1064
{
-
 
1065
  _asm
-
 
1066
 {    
-
 
1067
      mov   eax, 67
-
 
1068
      mov   ebx, [x]
-
 
1069
      mov   ecx, [y]
-
 
1070
      mov   edx, [w]
-
 
1071
      mov   esi, [h]
-
 
1072
      int   0x40
-
 
1073
  };  
-
 
1074
}
-
 
1075
 
-
 
1076
#ifdef DOCKABLE_WINDOW
-
 
1077
void GetThreadInfo (char *info, int slot) //Asper+
-
 
1078
{
-
 
1079
	_asm
-
 
1080
	{    
-
 
1081
		mov   eax, 9
-
 
1082
		mov   ebx, [info]
-
 
1083
		mov   ecx, [slot]
-
 
1084
		int   0x40
-
 
1085
	}  
-
 
1086
}
-
 
1087
#endif
-
 
1088
 
-
 
1089
void set_event_mask(int mask)
-
 
1090
{
-
 
1091
	_asm
-
 
1092
	{   
-
 
1093
		mov  eax, 40
-
 
1094
		mov  ebx, [mask]
-
 
1095
		int  0x40     
-
 
1096
	}
-
 
1097
}
-
 
1098
 
-
 
1099
void ipc_init(char *buf, int bufsize)
-
 
1100
{
-
 
1101
	_asm
-
 
1102
	{   
-
 
1103
		mov  eax, 60
-
 
1104
		mov  ebx, 1
-
 
1105
		mov  ecx, [buf]
-
 
1106
		mov  edx, [bufsize]
-
 
1107
		int  0x40     
-
 
1108
	}
-
 
1109
}
-
 
1110
 
-
 
1111
int ipc_send_msg(int PID, char *msg)
-
 
1112
{
-
 
1113
	int len = strlen(msg);
-
 
1114
	int retval;
-
 
1115
	_asm
-
 
1116
	{   
-
 
1117
		mov  eax, 60
-
 
1118
		mov  ebx, 2
-
 
1119
		mov  ecx, [PID]
-
 
1120
		mov  edx, [msg]
-
 
1121
		mov  esi, [len]
-
 
1122
		int  0x40     
-
 
1123
		mov [retval], eax 
-
 
1124
	}
-
 
1125
}
-
 
1126
//Asper+_______end KolibriOS sys functions___________________
-
 
1127
 
-
 
1128
//Asper+_______start strings routines___________________
-
 
1129
int _strncmp(char *src, char *dst, DWORD n)
-
 
1130
{
-
 
1131
	_asm{
-
 
1132
		mov		esi, src
-
 
1133
		mov		edi, dst
-
 
1134
		mov		ecx, n
-
 
1135
	}
-
 
1136
 l1:
-
 
1137
	_asm{
-
 
1138
		cmpsb
-
 
1139
		jne 	err
-
 
1140
		loop 	l1	
-
 
1141
	}
-
 
1142
	return 1;
-
 
1143
 err:
-
 
1144
	return 0;
-
 
1145
}
-
 
1146
 
-
 
1147
int _strncpy (char *dst, char *src, int n)
-
 
1148
{
-
 
1149
	int  i;
-
 
1150
	for (i=0; i
-
 
1151
	{
-
 
1152
		dst[i]=src[i];
-
 
1153
		if (src[i]=='\0') break;
-
 
1154
	}
-
 
1155
	return 0;
-
 
1156
}
-
 
1157
 
-
 
1158
void uint2str(unsigned int value, char *string)
-
 
1159
{
-
 
1160
  char tmp[33];
-
 
1161
  int i, j;
-
 
1162
  unsigned v;
-
 
1163
 
-
 
1164
  v = (unsigned)value;
-
 
1165
  j = 0;
-
 
1166
  do{
-
 
1167
    i = v % 10;
-
 
1168
    v = v / 10;
-
 
1169
    if (i < 10)
-
 
1170
      tmp[j] = i+'0';
-
 
1171
    else
-
 
1172
      tmp[j] = i + 'a' - 10;
-
 
1173
	j++;
-
 
1174
  }while (v);
-
 
1175
 
-
 
1176
  for (i=0; i
-
 
1177
    string[i] = tmp[j-i-1];
-
 
1178
  string[i] = '\0';
-
 
1179
}
-
 
1180
 
-
 
1181
//Asper+_______end strings routines___________________
-
 
1182
 
600
 
1183
 
601
///*********
1184
///*********
602
void *memmove ( void * dst, void * src, unsigned int count)  /* uFMOD integration */
1185
void *memmove ( void * dst, void * src, unsigned int count)  /* uFMOD integration */
603
{ void *ret;
1186
{ void *ret;