forked from KolibriOS/kolibrios
Infinity: get streams time stamp. Low precision version.
git-svn-id: svn://kolibrios.org@1679 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
6cb25c9e01
commit
82eba545cd
@ -159,31 +159,44 @@ inp_size equ IOCTL.inp_size
|
||||
output equ IOCTL.output
|
||||
out_size equ IOCTL.out_size
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
srv_calls dd service_proc.srv_getversion ; 0
|
||||
dd service_proc.snd_create_buff ; 1
|
||||
dd service_proc.snd_destroy_buff ; 2
|
||||
dd service_proc.snd_setformat ; 3
|
||||
dd service_proc.snd_getformat ; 4
|
||||
dd service_proc.snd_reset ; 5
|
||||
dd service_proc.snd_setpos ; 6
|
||||
dd service_proc.snd_getpos ; 7
|
||||
dd service_proc.snd_setbuff ; 8
|
||||
dd service_proc.snd_out ; 9
|
||||
dd service_proc.snd_play ; 10
|
||||
dd service_proc.snd_stop ; 11
|
||||
dd service_proc.snd_setvolume ; 12
|
||||
dd service_proc.snd_getvolume ; 13
|
||||
dd service_proc.snd_setpan ; 14
|
||||
dd service_proc.snd_getpan ; 15
|
||||
dd service_proc.snd_getbuffsize ; 16
|
||||
dd service_proc.snd_getfreespace ; 17
|
||||
dd service_proc.snd_settimebase ; 18
|
||||
dd service_proc.snd_gettimestamp ; 19
|
||||
srv_calls_end:
|
||||
|
||||
proc service_proc stdcall, ioctl:dword
|
||||
|
||||
mov edi, [ioctl]
|
||||
mov eax, [edi+io_code]
|
||||
|
||||
cmp eax, SRV_GETVERSION
|
||||
jne @F
|
||||
mov eax, [edi+output]
|
||||
cmp [edi+out_size], 4
|
||||
jne .fail
|
||||
mov eax, [eax]
|
||||
mov [eax], dword API_VERSION
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, (srv_calls_end-srv_calls)/4
|
||||
ja .fail
|
||||
|
||||
cmp eax, SND_CREATE_BUFF
|
||||
jne @F
|
||||
mov ebx, [edi+input]
|
||||
stdcall CreateBuffer,[ebx],[ebx+4]
|
||||
mov edi, [ioctl]
|
||||
mov ecx, [edi+output]
|
||||
mov ecx, [ecx]
|
||||
mov [ecx], ebx
|
||||
ret
|
||||
ja @F
|
||||
|
||||
jmp [srv_calls+eax*4]
|
||||
@@:
|
||||
mov ebx, [edi+input]
|
||||
mov edx, [ebx]
|
||||
@ -191,114 +204,132 @@ proc service_proc stdcall, ioctl:dword
|
||||
cmp [edx+STREAM.magic], 'WAVE'
|
||||
jne .fail
|
||||
|
||||
cmp [edx+STREAM.size], STREAM_SIZE
|
||||
cmp [edx+STREAM.size], STREAM.sizeof
|
||||
jne .fail
|
||||
|
||||
cmp eax, SND_DESTROY_BUFF
|
||||
jne @F
|
||||
mov eax, edx
|
||||
call DestroyBuffer ;edx= stream
|
||||
jmp [srv_calls+eax*4]
|
||||
.fail:
|
||||
mov eax, -1
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_SETFORMAT
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.srv_getversion:
|
||||
mov eax, [edi+output]
|
||||
cmp [edi+out_size], 4
|
||||
jne .fail
|
||||
mov eax, [eax]
|
||||
mov [eax], dword API_VERSION
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_create_buff:
|
||||
mov ebx, [edi+input]
|
||||
stdcall CreateBuffer,[ebx],[ebx+4]
|
||||
mov edi, [ioctl]
|
||||
mov ecx, [edi+output]
|
||||
mov ecx, [ecx]
|
||||
mov [ecx], ebx
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_destroy_buff:
|
||||
mov eax, edx
|
||||
call DestroyBuffer
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_setformat:
|
||||
stdcall SetFormat, edx,[ebx+4]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETFORMAT
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_getformat:
|
||||
movzx eax, word [edx+STREAM.format]
|
||||
mov ecx, [edi+output]
|
||||
mov ecx, [ecx]
|
||||
mov [ecx], eax
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_RESET
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_reset:
|
||||
stdcall ResetBuffer,edx,[ebx+4]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_SETPOS
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_setpos:
|
||||
stdcall SetBufferPos,edx,[ebx+4]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETPOS
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_getpos:
|
||||
stdcall GetBufferPos, edx
|
||||
mov edi, [ioctl]
|
||||
mov ecx, [edi+output]
|
||||
mov ecx, [ecx]
|
||||
mov [ecx], ebx
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_SETBUFF
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_setbuff:
|
||||
mov eax, [ebx+4]
|
||||
stdcall set_buffer, edx,eax,[ebx+8],[ebx+12]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_SETVOLUME
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_out:
|
||||
mov eax, [ebx+4]
|
||||
stdcall wave_out, edx,eax,[ebx+8]
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_play:
|
||||
stdcall play_buffer, edx,[ebx+4]
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_stop:
|
||||
stdcall stop_buffer, edx
|
||||
ret
|
||||
|
||||
align 4
|
||||
.snd_setvolume:
|
||||
stdcall SetBufferVol,edx,[ebx+4],[ebx+8]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETVOLUME
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_getvolume:
|
||||
mov eax, [edi+output]
|
||||
mov ecx, [eax]
|
||||
mov eax, [eax+4]
|
||||
stdcall GetBufferVol,edx,ecx,eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_SETPAN
|
||||
jne @F
|
||||
align 4
|
||||
.snd_setpan:
|
||||
stdcall SetBufferPan,edx,[ebx+4]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETPAN
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_getpan:
|
||||
mov eax, [edx+STREAM.pan]
|
||||
mov ebx, [edi+output]
|
||||
mov ebx, [ebx]
|
||||
mov [ebx], eax
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_OUT
|
||||
jne @F
|
||||
|
||||
mov eax, [ebx+4]
|
||||
stdcall wave_out, edx,eax,[ebx+8]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_PLAY
|
||||
jne @F
|
||||
|
||||
stdcall play_buffer, edx,[ebx+4]
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_STOP
|
||||
jne @F
|
||||
|
||||
stdcall stop_buffer, edx
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETBUFFSIZE
|
||||
jne @F
|
||||
align 4
|
||||
.snd_getbuffsize:
|
||||
mov eax, [edx+STREAM.in_size]
|
||||
mov ecx, [edi+output]
|
||||
mov ecx, [ecx]
|
||||
mov [ecx], eax
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
cmp eax, SND_GETFREESPACE
|
||||
jne @F
|
||||
|
||||
align 4
|
||||
.snd_getfreespace:
|
||||
test [edx+STREAM.format], PCM_OUT
|
||||
jz .fail
|
||||
|
||||
@ -307,12 +338,38 @@ proc service_proc stdcall, ioctl:dword
|
||||
mov [ecx], ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
@@:
|
||||
.fail:
|
||||
or eax, -1
|
||||
align 4
|
||||
.snd_settimebase:
|
||||
cmp [edi+inp_size], 8
|
||||
jne .fail
|
||||
|
||||
mov edi, [edi+input]
|
||||
mov eax, [edi]
|
||||
mov ebx, [edi+4]
|
||||
mov dword [edx+STREAM.time_base], eax
|
||||
mov dword [edx+STREAM.time_base+4], ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.snd_gettimestamp:
|
||||
cmp [edi+out_size], 8
|
||||
jne .fail
|
||||
|
||||
mov edi, [edi+output]
|
||||
|
||||
push 48
|
||||
emms
|
||||
fild qword [edx+STREAM.time_stamp]
|
||||
fidiv dword [esp]
|
||||
fadd qword [edx+STREAM.time_base]
|
||||
fstp qword [edi]
|
||||
add esp, 4
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
restore handle
|
||||
restore io_code
|
||||
restore input
|
||||
@ -352,7 +409,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
|
||||
|
||||
call GetPid
|
||||
mov ebx, eax
|
||||
mov eax, STREAM_SIZE
|
||||
mov eax, STREAM.sizeof
|
||||
|
||||
call CreateObject
|
||||
test eax, eax
|
||||
@ -412,7 +469,6 @@ proc CreateBuffer stdcall, format:dword, size:dword
|
||||
mov [edi+STREAM.in_base], eax
|
||||
mov [edi+STREAM.in_size], ecx
|
||||
add eax, 128
|
||||
; sub ecx, 128
|
||||
mov [edi+STREAM.in_wp], eax
|
||||
mov [edi+STREAM.in_rp], eax
|
||||
mov [edi+STREAM.in_count], 0
|
||||
@ -443,13 +499,21 @@ proc CreateBuffer stdcall, format:dword, size:dword
|
||||
stdcall AllocKernelSpace, dword 128*1024
|
||||
|
||||
mov edi, [str]
|
||||
xor ebx, ebx
|
||||
|
||||
mov [edi+STREAM.out_base], eax
|
||||
mov [edi+STREAM.out_wp], eax
|
||||
mov [edi+STREAM.out_rp], eax
|
||||
mov [edi+STREAM.out_count], 0
|
||||
mov [edi+STREAM.out_count], ebx
|
||||
add eax, 64*1024
|
||||
mov [edi+STREAM.out_top], eax
|
||||
|
||||
mov dword [edi+STREAM.time_base], ebx
|
||||
mov dword [edi+STREAM.time_base+4], ebx
|
||||
|
||||
mov dword [edi+STREAM.time_stamp], ebx
|
||||
mov dword [edi+STREAM.time_stamp+4], ebx
|
||||
|
||||
stdcall AllocPages, dword 64/4
|
||||
mov edi, [str]
|
||||
mov ebx, [edi+STREAM.out_base]
|
||||
@ -488,7 +552,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
|
||||
|
||||
mov [ebx+STREAM.magic], 'WAVE'
|
||||
mov [ebx+STREAM.destroy], DestroyBuffer.destroy
|
||||
mov [ebx+STREAM.size], STREAM_SIZE
|
||||
mov [ebx+STREAM.size], STREAM.sizeof
|
||||
mov [ebx+STREAM.flags], SND_STOP
|
||||
|
||||
pushf
|
||||
@ -1039,7 +1103,7 @@ do_mix_list:
|
||||
cmp [ebx+STREAM.magic], 'WAVE'
|
||||
jne .next
|
||||
|
||||
cmp [ebx+STREAM.size], STREAM_SIZE
|
||||
cmp [ebx+STREAM.size], STREAM.sizeof
|
||||
jne .next
|
||||
|
||||
cmp [ebx+STREAM.flags], SND_PLAY;
|
||||
@ -1108,7 +1172,7 @@ prepare_playlist:
|
||||
cmp [edi+STREAM.magic], 'WAVE'
|
||||
jne .next
|
||||
|
||||
cmp [edi+STREAM.size], STREAM_SIZE
|
||||
cmp [edi+STREAM.size], STREAM.sizeof
|
||||
jne .next
|
||||
|
||||
cmp [edi+STREAM.flags], SND_PLAY;
|
||||
|
@ -91,6 +91,8 @@ SND_SETPAN equ 14
|
||||
SND_GETPAN equ 15
|
||||
SND_GETBUFFSIZE equ 16
|
||||
SND_GETFREESPACE equ 17
|
||||
SND_SETTIMEBASE equ 18
|
||||
SND_GETTIMESTAMP equ 19
|
||||
|
||||
struc STREAM
|
||||
{
|
||||
@ -113,6 +115,22 @@ struc STREAM
|
||||
.out_count dd ?
|
||||
.out_top dd ? ;16*4
|
||||
|
||||
.in_base dd ?
|
||||
.in_size dd ?
|
||||
.in_wp dd ?
|
||||
.in_rp dd ?
|
||||
.in_count dd ?
|
||||
.in_free dd ?
|
||||
.in_top dd ?
|
||||
|
||||
align 8
|
||||
|
||||
.time_base dq ?
|
||||
.time_stamp dq ?
|
||||
|
||||
.notify_event dd ?
|
||||
.notify_id dd ?
|
||||
|
||||
.r_size dd ?
|
||||
.r_dt dd ?
|
||||
.r_silence dd ?
|
||||
@ -125,19 +143,9 @@ struc STREAM
|
||||
.l_amp_f dd ? ;float point left
|
||||
.r_amp_f dd ? ;float point right
|
||||
|
||||
.in_base dd ?
|
||||
.in_size dd ?
|
||||
.in_wp dd ?
|
||||
.in_rp dd ?
|
||||
.in_count dd ?
|
||||
.in_free dd ?
|
||||
.in_top dd ?
|
||||
|
||||
.notify_event dd ?
|
||||
.notify_id dd ?
|
||||
.sizeof:
|
||||
}
|
||||
|
||||
STREAM_SIZE equ 36*4
|
||||
FD_OFFSET equ 24
|
||||
|
||||
virtual at 0
|
||||
|
@ -29,7 +29,7 @@ proc new_mix stdcall, output:dword
|
||||
and eax, -16 ;must be 16b aligned
|
||||
call FpuSave
|
||||
|
||||
call update_stream
|
||||
call update_streams
|
||||
.mix:
|
||||
lea eax, [mix_list]
|
||||
call do_mix_list
|
||||
@ -87,7 +87,7 @@ end if
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc update_stream
|
||||
proc update_streams
|
||||
locals
|
||||
stream_index dd ?
|
||||
event rd 6
|
||||
@ -98,6 +98,9 @@ proc update_stream
|
||||
mov edx, [stream_index]
|
||||
mov esi, [play_list+edx*4]
|
||||
|
||||
add dword [esi+STREAM.time_stamp], 4096
|
||||
adc dword [esi+STREAM.time_stamp+4], 0
|
||||
|
||||
mov eax, [esi+STREAM.out_rp]
|
||||
cmp eax, [esi+STREAM.out_top]
|
||||
jb @f
|
||||
|
Loading…
Reference in New Issue
Block a user