Subversion Repositories Kolibri OS

Rev

Rev 1505 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1505 Rev 1689
Line 157... Line 157...
157
input      equ  IOCTL.input
157
input      equ  IOCTL.input
158
inp_size   equ  IOCTL.inp_size
158
inp_size   equ  IOCTL.inp_size
159
output     equ  IOCTL.output
159
output     equ  IOCTL.output
160
out_size   equ  IOCTL.out_size
160
out_size   equ  IOCTL.out_size
Line -... Line 161...
-
 
161
 
-
 
162
 
161
 
163
 
-
 
164
align 4
-
 
165
 
-
 
166
srv_calls  dd service_proc.srv_getversion       ; 0
-
 
167
           dd service_proc.snd_create_buff      ; 1
-
 
168
           dd service_proc.snd_destroy_buff     ; 2
-
 
169
           dd service_proc.snd_setformat        ; 3
-
 
170
           dd service_proc.snd_getformat        ; 4
-
 
171
           dd service_proc.snd_reset            ; 5
-
 
172
           dd service_proc.snd_setpos           ; 6
-
 
173
           dd service_proc.snd_getpos           ; 7
-
 
174
           dd service_proc.snd_setbuff          ; 8
-
 
175
           dd service_proc.snd_out              ; 9
-
 
176
           dd service_proc.snd_play             ; 10
-
 
177
           dd service_proc.snd_stop             ; 11
-
 
178
           dd service_proc.snd_setvolume        ; 12
-
 
179
           dd service_proc.snd_getvolume        ; 13
-
 
180
           dd service_proc.snd_setpan           ; 14
-
 
181
           dd service_proc.snd_getpan           ; 15
-
 
182
           dd service_proc.snd_getbuffsize      ; 16
-
 
183
           dd service_proc.snd_getfreespace     ; 17
-
 
184
           dd service_proc.snd_settimebase      ; 18
-
 
185
           dd service_proc.snd_gettimestamp     ; 19
-
 
186
srv_calls_end:
162
align 4
187
 
Line 163... Line 188...
163
proc service_proc stdcall, ioctl:dword
188
proc service_proc stdcall, ioctl:dword
164
 
189
 
Line -... Line 190...
-
 
190
           mov edi, [ioctl]
-
 
191
           mov eax, [edi+io_code]
-
 
192
 
165
           mov edi, [ioctl]
193
           cmp eax, (srv_calls_end-srv_calls)/4
166
           mov eax, [edi+io_code]
194
           ja  .fail
-
 
195
 
-
 
196
           cmp eax, SND_CREATE_BUFF
-
 
197
           ja @F
-
 
198
 
-
 
199
           jmp [srv_calls+eax*4]
-
 
200
@@:
-
 
201
           mov ebx, [edi+input]
-
 
202
           mov edx, [ebx]
-
 
203
 
-
 
204
           cmp [edx+STREAM.magic], 'WAVE'
-
 
205
           jne .fail
-
 
206
 
-
 
207
           cmp [edx+STREAM.size], STREAM.sizeof
-
 
208
           jne .fail
-
 
209
 
-
 
210
           jmp [srv_calls+eax*4]
-
 
211
.fail:
-
 
212
           mov eax, -1
-
 
213
           ret
167
 
214
 
168
           cmp eax, SRV_GETVERSION
215
align 4
169
           jne @F
216
.srv_getversion:
170
           mov eax, [edi+output]
217
           mov eax, [edi+output]
171
           cmp [edi+out_size], 4
218
           cmp [edi+out_size], 4
172
           jne .fail
219
           jne .fail
173
           mov eax, [eax]
220
           mov eax, [eax]
174
           mov [eax], dword API_VERSION
221
           mov [eax], dword API_VERSION
175
           xor eax, eax
222
           xor eax, eax
176
           ret
223
           ret
177
@@:
224
 
178
           cmp eax, SND_CREATE_BUFF
225
align 4
179
           jne @F
226
.snd_create_buff:
180
           mov ebx, [edi+input]
227
           mov ebx, [edi+input]
181
           stdcall CreateBuffer,[ebx],[ebx+4]
228
           stdcall CreateBuffer,[ebx],[ebx+4]
182
           mov edi, [ioctl]
229
           mov edi, [ioctl]
183
           mov ecx, [edi+output]
230
           mov ecx, [edi+output]
184
           mov ecx, [ecx]
-
 
185
           mov [ecx], ebx
-
 
186
           ret
-
 
187
@@:
-
 
188
           mov ebx, [edi+input]
-
 
189
           mov edx, [ebx]
-
 
190
 
-
 
191
           cmp [edx+STREAM.magic], 'WAVE'
-
 
192
           jne .fail
-
 
Line 193... Line 231...
193
 
231
           mov ecx, [ecx]
194
           cmp [edx+STREAM.size], STREAM_SIZE
232
           mov [ecx], ebx
195
           jne .fail
233
           ret
196
 
234
 
197
           cmp eax, SND_DESTROY_BUFF
235
align 4
198
           jne @F
236
.snd_destroy_buff:
199
           mov eax, edx
237
           mov eax, edx
200
           call DestroyBuffer    ;edx= stream
238
           call DestroyBuffer
201
           ret
239
           ret
202
@@:
240
 
203
           cmp eax, SND_SETFORMAT
-
 
204
           jne @F
-
 
205
           stdcall SetFormat,edx,[ebx+4]
-
 
Line -... Line 241...
-
 
241
align 4
-
 
242
.snd_setformat:
206
           ret
243
           stdcall SetFormat, edx,[ebx+4]
207
@@:
244
           ret
208
           cmp eax, SND_GETFORMAT
245
 
209
           jne @F
246
align 4
210
 
247
.snd_getformat:
211
           movzx eax, word [edx+STREAM.format]
248
           movzx eax, word [edx+STREAM.format]
212
           mov ecx, [edi+output]
249
           mov ecx, [edi+output]
213
           mov ecx, [ecx]
250
           mov ecx, [ecx]
214
           mov [ecx], eax
251
           mov [ecx], eax
215
           xor eax, eax
252
           xor eax, eax
216
           ret
253
           ret
217
@@:
254
 
218
           cmp eax, SND_RESET
255
align 4
219
           jne @F
256
.snd_reset:
220
           stdcall ResetBuffer,edx,[ebx+4]
257
           stdcall ResetBuffer,edx,[ebx+4]
221
           ret
258
           ret
222
@@:
259
 
223
           cmp eax, SND_SETPOS
260
align 4
224
           jne @F
261
.snd_setpos:
225
           stdcall SetBufferPos,edx,[ebx+4]
262
           stdcall SetBufferPos,edx,[ebx+4]
226
           ret
263
           ret
227
@@:
264
 
228
           cmp eax, SND_GETPOS
265
align 4
229
           jne @F
266
.snd_getpos:
230
           stdcall GetBufferPos, edx
267
           stdcall GetBufferPos, edx
231
           mov edi, [ioctl]
268
           mov edi, [ioctl]
232
           mov ecx, [edi+output]
269
           mov ecx, [edi+output]
233
           mov ecx, [ecx]
270
           mov ecx, [ecx]
234
           mov [ecx], ebx
271
           mov [ecx], ebx
235
           ret
272
           ret
236
@@:
273
 
237
           cmp eax, SND_SETBUFF
274
align 4
-
 
275
.snd_setbuff:
-
 
276
           mov eax, [ebx+4]
238
           jne @F
277
           stdcall set_buffer, edx,eax,[ebx+8],[ebx+12]
-
 
278
           ret
-
 
279
 
-
 
280
align 4
-
 
281
.snd_out:
-
 
282
           mov eax, [ebx+4]
-
 
283
           stdcall wave_out, edx,eax,[ebx+8]
-
 
284
           ret
-
 
285
 
-
 
286
align 4
-
 
287
.snd_play:
-
 
288
           stdcall play_buffer, edx,[ebx+4]
239
           mov eax, [ebx+4]
289
           ret
-
 
290
 
-
 
291
align 4
-
 
292
.snd_stop:
240
           stdcall set_buffer, edx,eax,[ebx+8],[ebx+12]
293
           stdcall stop_buffer, edx
241
           ret
294
           ret
242
@@:
-
 
243
           cmp eax, SND_SETVOLUME
-
 
244
           jne @F
-
 
Line -... Line 295...
-
 
295
 
-
 
296
align 4
245
           stdcall SetBufferVol,edx,[ebx+4],[ebx+8]
297
.snd_setvolume:
246
           ret
298
           stdcall SetBufferVol,edx,[ebx+4],[ebx+8]
247
@@:
299
           ret
248
           cmp eax, SND_GETVOLUME
300
 
249
           jne @F
301
align 4
250
 
302
.snd_getvolume:
251
           mov eax, [edi+output]
-
 
252
           mov ecx, [eax]
303
           mov eax, [edi+output]
253
           mov eax, [eax+4]
304
           mov ecx, [eax]
254
           stdcall GetBufferVol,edx,ecx,eax
305
           mov eax, [eax+4]
255
           ret
306
           stdcall GetBufferVol,edx,ecx,eax
256
@@:
307
           ret
257
           cmp eax, SND_SETPAN
308
align 4
258
           jne @F
309
.snd_setpan:
259
           stdcall SetBufferPan,edx,[ebx+4]
310
           stdcall SetBufferPan,edx,[ebx+4]
260
           ret
311
           ret
261
@@:
312
 
262
           cmp eax, SND_GETPAN
313
align 4
263
           jne @F
314
.snd_getpan:
264
           mov eax, [edx+STREAM.pan]
-
 
265
           mov ebx, [edi+output]
-
 
266
           mov ebx, [ebx]
-
 
267
           mov [ebx], eax
-
 
268
           xor eax, eax
-
 
269
           ret
-
 
270
@@:
-
 
271
           cmp eax, SND_OUT
-
 
272
           jne @F
-
 
273
 
-
 
274
           mov eax, [ebx+4]
-
 
275
           stdcall wave_out, edx,eax,[ebx+8]
-
 
276
           ret
-
 
277
@@:
-
 
278
           cmp eax, SND_PLAY
-
 
279
           jne @F
-
 
Line 280... Line -...
280
 
-
 
281
           stdcall play_buffer, edx,[ebx+4]
-
 
282
           ret
315
           mov eax, [edx+STREAM.pan]
283
@@:
-
 
284
           cmp eax, SND_STOP
316
           mov ebx, [edi+output]
285
           jne @F
317
           mov ebx, [ebx]
286
 
318
           mov [ebx], eax
287
           stdcall stop_buffer, edx
319
           xor eax, eax
288
           ret
320
           ret
289
@@:
321
 
290
           cmp eax, SND_GETBUFFSIZE
322
align 4
291
           jne @F
-
 
292
           mov eax, [edx+STREAM.in_size]
-
 
293
           mov ecx, [edi+output]
-
 
Line -... Line 323...
-
 
323
.snd_getbuffsize:
-
 
324
           mov eax, [edx+STREAM.in_size]
294
           mov ecx, [ecx]
325
           mov ecx, [edi+output]
295
           mov [ecx], eax
326
           mov ecx, [ecx]
Line 296... Line 327...
296
           xor eax, eax
327
           mov [ecx], eax
297
           ret
328
           xor eax, eax
298
@@:
329
           ret
299
           cmp eax, SND_GETFREESPACE
330
 
300
           jne @F
331
align 4
-
 
332
.snd_getfreespace:
-
 
333
           test [edx+STREAM.format], PCM_OUT
-
 
334
           jz .fail
-
 
335
 
301
 
336
           mov ebx, [edx+STREAM.in_free]
-
 
337
           mov ecx, [edi+output]
-
 
338
           mov [ecx], ebx
-
 
339
           xor eax, eax
-
 
340
           ret
-
 
341
align 4
-
 
342
.snd_settimebase:
-
 
343
           cmp [edi+inp_size], 8
-
 
344
           jne .fail
-
 
345
 
-
 
346
           mov edi, [edi+input]
302
           test [edx+STREAM.format], PCM_OUT
347
           mov eax, [edi]
-
 
348
           mov ebx, [edi+4]
-
 
349
           mov dword [edx+STREAM.time_base], eax
-
 
350
           mov dword [edx+STREAM.time_base+4], ebx
-
 
351
           xor eax, eax
-
 
352
           ret
-
 
353
 
-
 
354
.snd_gettimestamp:
-
 
355
           cmp [edi+out_size], 8
-
 
356
           jne .fail
-
 
357
 
-
 
358
           mov edi, [edi+output]
303
           jz .fail
359
 
304
 
360
           push 48
305
           mov ebx, [edx+STREAM.in_free]
361
           emms
Line -... Line 362...
-
 
362
           fild  qword [edx+STREAM.time_stamp]
306
           mov ecx, [edi+output]
363
           fidiv dword [esp]
307
           mov [ecx], ebx
364
           fadd  qword [edx+STREAM.time_base]
308
           xor eax, eax
365
           fstp  qword [edi]
309
           ret
366
           add esp, 4
310
@@:
367
 
Line 350... Line 407...
350
           jnz .fail
407
           jnz .fail
351
.test_ok:
408
.test_ok:
Line 352... Line 409...
352
 
409
 
353
           call GetPid
410
           call GetPid
354
           mov ebx, eax
411
           mov ebx, eax
Line 355... Line 412...
355
           mov eax, STREAM_SIZE
412
           mov eax, STREAM.sizeof
356
 
413
 
357
           call CreateObject
414
           call CreateObject
358
           test eax, eax
415
           test eax, eax
Line 410... Line 467...
410
           mov edi, [str]
467
           mov edi, [str]
411
           mov ecx, [ring_size]
468
           mov ecx, [ring_size]
412
           mov [edi+STREAM.in_base], eax
469
           mov [edi+STREAM.in_base], eax
413
           mov [edi+STREAM.in_size], ecx
470
           mov [edi+STREAM.in_size], ecx
414
           add eax, 128
471
           add eax, 128
415
        ;   sub ecx, 128
-
 
416
           mov [edi+STREAM.in_wp], eax
472
           mov [edi+STREAM.in_wp], eax
417
           mov [edi+STREAM.in_rp], eax
473
           mov [edi+STREAM.in_rp], eax
418
           mov [edi+STREAM.in_count], 0
474
           mov [edi+STREAM.in_count], 0
Line 419... Line 475...
419
 
475
 
Line 441... Line 497...
441
 
497
 
442
.out_buff:
498
.out_buff:
Line 443... Line 499...
443
           stdcall AllocKernelSpace, dword 128*1024
499
           stdcall AllocKernelSpace, dword 128*1024
-
 
500
 
-
 
501
           mov edi, [str]
444
 
502
           xor ebx, ebx
445
           mov edi, [str]
503
 
446
           mov [edi+STREAM.out_base], eax
504
           mov [edi+STREAM.out_base], eax
447
           mov [edi+STREAM.out_wp], eax
505
           mov [edi+STREAM.out_wp], eax
448
           mov [edi+STREAM.out_rp], eax
506
           mov [edi+STREAM.out_rp], eax
449
           mov [edi+STREAM.out_count], 0
507
           mov [edi+STREAM.out_count], ebx
Line -... Line 508...
-
 
508
           add eax, 64*1024
-
 
509
           mov [edi+STREAM.out_top], eax
-
 
510
 
-
 
511
           mov dword [edi+STREAM.time_base],   ebx
-
 
512
           mov dword [edi+STREAM.time_base+4], ebx
-
 
513
 
450
           add eax, 64*1024
514
           mov dword [edi+STREAM.time_stamp],   ebx
451
           mov [edi+STREAM.out_top], eax
515
           mov dword [edi+STREAM.time_stamp+4], ebx
452
 
516
 
453
           stdcall AllocPages, dword 64/4
517
           stdcall AllocPages, dword 64/4
454
           mov edi, [str]
518
           mov edi, [str]
Line 486... Line 550...
486
           mov [ebx+STREAM.notify_event], eax
550
           mov [ebx+STREAM.notify_event], eax
487
           mov [ebx+STREAM.notify_id], edx
551
           mov [ebx+STREAM.notify_id], edx
Line 488... Line 552...
488
 
552
 
489
           mov [ebx+STREAM.magic], 'WAVE'
553
           mov [ebx+STREAM.magic], 'WAVE'
490
           mov [ebx+STREAM.destroy], DestroyBuffer.destroy
554
           mov [ebx+STREAM.destroy], DestroyBuffer.destroy
491
           mov [ebx+STREAM.size], STREAM_SIZE
555
           mov [ebx+STREAM.size], STREAM.sizeof
Line 492... Line 556...
492
           mov [ebx+STREAM.flags], SND_STOP
556
           mov [ebx+STREAM.flags], SND_STOP
493
 
557
 
494
           pushf
558
           pushf
Line 1037... Line 1101...
1037
           je .done
1101
           je .done
Line 1038... Line 1102...
1038
 
1102
 
1039
           cmp [ebx+STREAM.magic], 'WAVE'
1103
           cmp [ebx+STREAM.magic], 'WAVE'
Line 1040... Line 1104...
1040
           jne .next
1104
           jne .next
1041
 
1105
 
Line 1042... Line 1106...
1042
           cmp [ebx+STREAM.size], STREAM_SIZE
1106
           cmp [ebx+STREAM.size], STREAM.sizeof
1043
           jne .next
1107
           jne .next
Line 1106... Line 1170...
1106
           je .done
1170
           je .done
Line 1107... Line 1171...
1107
 
1171
 
1108
           cmp [edi+STREAM.magic], 'WAVE'
1172
           cmp [edi+STREAM.magic], 'WAVE'
Line 1109... Line 1173...
1109
           jne .next
1173
           jne .next
1110
 
1174
 
Line 1111... Line 1175...
1111
           cmp [edi+STREAM.size], STREAM_SIZE
1175
           cmp [edi+STREAM.size], STREAM.sizeof
1112
           jne .next
1176
           jne .next