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:
Sergey Semyonov (Serge) 2010-10-26 15:41:23 +00:00
parent 6cb25c9e01
commit 82eba545cd
3 changed files with 176 additions and 101 deletions

View File

@ -159,31 +159,44 @@ inp_size equ IOCTL.inp_size
output equ IOCTL.output output equ IOCTL.output
out_size equ IOCTL.out_size out_size equ IOCTL.out_size
align 4 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 proc service_proc stdcall, ioctl:dword
mov edi, [ioctl] mov edi, [ioctl]
mov eax, [edi+io_code] mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION cmp eax, (srv_calls_end-srv_calls)/4
jne @F ja .fail
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, SND_CREATE_BUFF cmp eax, SND_CREATE_BUFF
jne @F ja @F
mov ebx, [edi+input]
stdcall CreateBuffer,[ebx],[ebx+4] jmp [srv_calls+eax*4]
mov edi, [ioctl]
mov ecx, [edi+output]
mov ecx, [ecx]
mov [ecx], ebx
ret
@@: @@:
mov ebx, [edi+input] mov ebx, [edi+input]
mov edx, [ebx] mov edx, [ebx]
@ -191,114 +204,132 @@ proc service_proc stdcall, ioctl:dword
cmp [edx+STREAM.magic], 'WAVE' cmp [edx+STREAM.magic], 'WAVE'
jne .fail jne .fail
cmp [edx+STREAM.size], STREAM_SIZE cmp [edx+STREAM.size], STREAM.sizeof
jne .fail jne .fail
cmp eax, SND_DESTROY_BUFF jmp [srv_calls+eax*4]
jne @F .fail:
mov eax, edx mov eax, -1
call DestroyBuffer ;edx= stream
ret ret
@@:
cmp eax, SND_SETFORMAT
jne @F
stdcall SetFormat,edx,[ebx+4]
ret
@@:
cmp eax, SND_GETFORMAT
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
align 4
.snd_getformat:
movzx eax, word [edx+STREAM.format] movzx eax, word [edx+STREAM.format]
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx], eax mov [ecx], eax
xor eax, eax xor eax, eax
ret ret
@@:
cmp eax, SND_RESET align 4
jne @F .snd_reset:
stdcall ResetBuffer,edx,[ebx+4] stdcall ResetBuffer,edx,[ebx+4]
ret ret
@@:
cmp eax, SND_SETPOS align 4
jne @F .snd_setpos:
stdcall SetBufferPos,edx,[ebx+4] stdcall SetBufferPos,edx,[ebx+4]
ret ret
@@:
cmp eax, SND_GETPOS align 4
jne @F .snd_getpos:
stdcall GetBufferPos, edx stdcall GetBufferPos, edx
mov edi, [ioctl] mov edi, [ioctl]
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx], ebx mov [ecx], ebx
ret ret
@@:
cmp eax, SND_SETBUFF align 4
jne @F .snd_setbuff:
mov eax, [ebx+4] mov eax, [ebx+4]
stdcall set_buffer, edx,eax,[ebx+8],[ebx+12] stdcall set_buffer, edx,eax,[ebx+8],[ebx+12]
ret ret
@@:
cmp eax, SND_SETVOLUME align 4
jne @F .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] stdcall SetBufferVol,edx,[ebx+4],[ebx+8]
ret ret
@@:
cmp eax, SND_GETVOLUME
jne @F
align 4
.snd_getvolume:
mov eax, [edi+output] mov eax, [edi+output]
mov ecx, [eax] mov ecx, [eax]
mov eax, [eax+4] mov eax, [eax+4]
stdcall GetBufferVol,edx,ecx,eax stdcall GetBufferVol,edx,ecx,eax
ret ret
@@: align 4
cmp eax, SND_SETPAN .snd_setpan:
jne @F
stdcall SetBufferPan,edx,[ebx+4] stdcall SetBufferPan,edx,[ebx+4]
ret ret
@@:
cmp eax, SND_GETPAN align 4
jne @F .snd_getpan:
mov eax, [edx+STREAM.pan] mov eax, [edx+STREAM.pan]
mov ebx, [edi+output] mov ebx, [edi+output]
mov ebx, [ebx] mov ebx, [ebx]
mov [ebx], eax mov [ebx], eax
xor eax, eax xor eax, eax
ret ret
@@:
cmp eax, SND_OUT
jne @F
mov eax, [ebx+4] align 4
stdcall wave_out, edx,eax,[ebx+8] .snd_getbuffsize:
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
mov eax, [edx+STREAM.in_size] mov eax, [edx+STREAM.in_size]
mov ecx, [edi+output] mov ecx, [edi+output]
mov ecx, [ecx] mov ecx, [ecx]
mov [ecx], eax mov [ecx], eax
xor eax, eax xor eax, eax
ret ret
@@:
cmp eax, SND_GETFREESPACE
jne @F
align 4
.snd_getfreespace:
test [edx+STREAM.format], PCM_OUT test [edx+STREAM.format], PCM_OUT
jz .fail jz .fail
@ -307,12 +338,38 @@ proc service_proc stdcall, ioctl:dword
mov [ecx], ebx mov [ecx], ebx
xor eax, eax xor eax, eax
ret ret
@@: align 4
.fail: .snd_settimebase:
or eax, -1 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 ret
endp endp
restore handle restore handle
restore io_code restore io_code
restore input restore input
@ -352,7 +409,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
call GetPid call GetPid
mov ebx, eax mov ebx, eax
mov eax, STREAM_SIZE mov eax, STREAM.sizeof
call CreateObject call CreateObject
test eax, eax test eax, eax
@ -412,7 +469,6 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov [edi+STREAM.in_base], eax mov [edi+STREAM.in_base], eax
mov [edi+STREAM.in_size], ecx mov [edi+STREAM.in_size], ecx
add eax, 128 add eax, 128
; sub ecx, 128
mov [edi+STREAM.in_wp], eax mov [edi+STREAM.in_wp], eax
mov [edi+STREAM.in_rp], eax mov [edi+STREAM.in_rp], eax
mov [edi+STREAM.in_count], 0 mov [edi+STREAM.in_count], 0
@ -443,13 +499,21 @@ proc CreateBuffer stdcall, format:dword, size:dword
stdcall AllocKernelSpace, dword 128*1024 stdcall AllocKernelSpace, dword 128*1024
mov edi, [str] mov edi, [str]
xor ebx, ebx
mov [edi+STREAM.out_base], eax mov [edi+STREAM.out_base], eax
mov [edi+STREAM.out_wp], eax mov [edi+STREAM.out_wp], eax
mov [edi+STREAM.out_rp], eax mov [edi+STREAM.out_rp], eax
mov [edi+STREAM.out_count], 0 mov [edi+STREAM.out_count], ebx
add eax, 64*1024 add eax, 64*1024
mov [edi+STREAM.out_top], eax 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 stdcall AllocPages, dword 64/4
mov edi, [str] mov edi, [str]
mov ebx, [edi+STREAM.out_base] 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.magic], 'WAVE'
mov [ebx+STREAM.destroy], DestroyBuffer.destroy mov [ebx+STREAM.destroy], DestroyBuffer.destroy
mov [ebx+STREAM.size], STREAM_SIZE mov [ebx+STREAM.size], STREAM.sizeof
mov [ebx+STREAM.flags], SND_STOP mov [ebx+STREAM.flags], SND_STOP
pushf pushf
@ -1039,7 +1103,7 @@ do_mix_list:
cmp [ebx+STREAM.magic], 'WAVE' cmp [ebx+STREAM.magic], 'WAVE'
jne .next jne .next
cmp [ebx+STREAM.size], STREAM_SIZE cmp [ebx+STREAM.size], STREAM.sizeof
jne .next jne .next
cmp [ebx+STREAM.flags], SND_PLAY; cmp [ebx+STREAM.flags], SND_PLAY;
@ -1108,7 +1172,7 @@ prepare_playlist:
cmp [edi+STREAM.magic], 'WAVE' cmp [edi+STREAM.magic], 'WAVE'
jne .next jne .next
cmp [edi+STREAM.size], STREAM_SIZE cmp [edi+STREAM.size], STREAM.sizeof
jne .next jne .next
cmp [edi+STREAM.flags], SND_PLAY; cmp [edi+STREAM.flags], SND_PLAY;

View File

@ -91,6 +91,8 @@ SND_SETPAN equ 14
SND_GETPAN equ 15 SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16 SND_GETBUFFSIZE equ 16
SND_GETFREESPACE equ 17 SND_GETFREESPACE equ 17
SND_SETTIMEBASE equ 18
SND_GETTIMESTAMP equ 19
struc STREAM struc STREAM
{ {
@ -113,6 +115,22 @@ struc STREAM
.out_count dd ? .out_count dd ?
.out_top dd ? ;16*4 .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_size dd ?
.r_dt dd ? .r_dt dd ?
.r_silence dd ? .r_silence dd ?
@ -125,19 +143,9 @@ struc STREAM
.l_amp_f dd ? ;float point left .l_amp_f dd ? ;float point left
.r_amp_f dd ? ;float point right .r_amp_f dd ? ;float point right
.in_base dd ? .sizeof:
.in_size dd ?
.in_wp dd ?
.in_rp dd ?
.in_count dd ?
.in_free dd ?
.in_top dd ?
.notify_event dd ?
.notify_id dd ?
} }
STREAM_SIZE equ 36*4
FD_OFFSET equ 24 FD_OFFSET equ 24
virtual at 0 virtual at 0

View File

@ -29,7 +29,7 @@ proc new_mix stdcall, output:dword
and eax, -16 ;must be 16b aligned and eax, -16 ;must be 16b aligned
call FpuSave call FpuSave
call update_stream call update_streams
.mix: .mix:
lea eax, [mix_list] lea eax, [mix_list]
call do_mix_list call do_mix_list
@ -87,7 +87,7 @@ end if
endp endp
align 4 align 4
proc update_stream proc update_streams
locals locals
stream_index dd ? stream_index dd ?
event rd 6 event rd 6
@ -98,6 +98,9 @@ proc update_stream
mov edx, [stream_index] mov edx, [stream_index]
mov esi, [play_list+edx*4] 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] mov eax, [esi+STREAM.out_rp]
cmp eax, [esi+STREAM.out_top] cmp eax, [esi+STREAM.out_top]
jb @f jb @f