2007-03-26 14:18:08 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2008-01-12 08:54:11 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
|
2007-03-26 14:18:08 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2008-01-12 08:54:11 +01:00
|
|
|
; Serge 2006-2008
|
|
|
|
; email: infinity_sound@mail.ru
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
format MS COFF
|
|
|
|
|
2007-07-09 03:05:41 +02:00
|
|
|
|
|
|
|
CURRENT_API equ 0x0101 ;1.01
|
|
|
|
COMPATIBLE_API equ 0x0100 ;1.00
|
|
|
|
|
|
|
|
API_VERSION equ (COMPATIBLE_API shl 16) or CURRENT_API
|
|
|
|
SOUND_VERSION equ CURRENT_API
|
2007-04-18 08:37:14 +02:00
|
|
|
|
|
|
|
|
2006-10-07 11:47:03 +02:00
|
|
|
include 'proc32.inc'
|
2007-05-24 09:36:48 +02:00
|
|
|
|
|
|
|
;include 'system.inc'
|
2006-10-07 11:47:03 +02:00
|
|
|
include 'main.inc'
|
2007-05-24 09:36:48 +02:00
|
|
|
|
2007-01-19 04:58:46 +01:00
|
|
|
include 'imports.inc'
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
FORCE_MMX equ 0 ;set to 1 to force use mmx or
|
|
|
|
FORCE_MMX_128 equ 0 ;integer sse2 extensions
|
2008-01-12 08:54:11 +01:00
|
|
|
;and reduce driver size
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
;USE_SSE equ 0
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2008-01-12 08:54:11 +01:00
|
|
|
USE_SSE2_MIXER equ 0 ;floating point mixer. Disabled by default
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
DEBUG equ 1
|
2007-01-23 15:55:03 +01:00
|
|
|
|
2007-01-24 16:51:55 +01:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
OS_BASE equ 0x80000000
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
CAPS_SSE2 equ 26
|
|
|
|
PG_SW equ 0x003
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
public START
|
2006-10-20 16:02:26 +02:00
|
|
|
public service_proc
|
2006-12-02 09:18:48 +01:00
|
|
|
public version
|
2006-10-20 16:02:26 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
RT_INP_EMPTY equ 0xFF000001
|
|
|
|
RT_OUT_EMPTY equ 0xFF000002
|
|
|
|
RT_INP_FULL equ 0xFF000003
|
|
|
|
RT_OUT_FULL equ 0xFF000004
|
|
|
|
|
|
|
|
EVENT_WATCHED equ 0x10000000
|
|
|
|
EVENT_SIGNALED equ 0x20000000
|
|
|
|
MANUAL_RESET equ 0x40000000
|
|
|
|
MANUAL_DESTROY equ 0x80000000
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
DEV_PLAY equ 1
|
|
|
|
DEV_STOP equ 2
|
|
|
|
DEV_CALLBACK equ 3
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
struc IOCTL
|
2007-02-27 12:47:52 +01:00
|
|
|
{ .handle dd ?
|
|
|
|
.io_code dd ?
|
|
|
|
.input dd ?
|
|
|
|
.inp_size dd ?
|
|
|
|
.output dd ?
|
|
|
|
.out_size dd ?
|
2006-10-07 11:47:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual at 0
|
|
|
|
IOCTL IOCTL
|
|
|
|
end virtual
|
|
|
|
|
2006-10-20 16:02:26 +02:00
|
|
|
section '.flat' code readable align 16
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-11-20 08:06:00 +01:00
|
|
|
proc START stdcall, state:dword
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
cmp [state], 1
|
|
|
|
jne .exit
|
|
|
|
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall GetService, szSound
|
2006-10-07 11:47:03 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
mov [hSound], eax
|
|
|
|
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall KernelAlloc, 16*512
|
2006-10-07 11:47:03 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .out_of_mem
|
|
|
|
mov [mix_buff], eax
|
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
mov eax, str.fd-FD_OFFSET
|
|
|
|
mov [str.fd], eax
|
|
|
|
mov [str.bk], eax
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-24 16:51:55 +01:00
|
|
|
if FORCE_MMX
|
|
|
|
if FORCE_MMX_128
|
|
|
|
display 'Use only FORCE_MMX or FORCE_MMX_128 not both together',13,10
|
|
|
|
stop
|
|
|
|
end if
|
|
|
|
mov [mix_2_core], mmx_mix_2
|
|
|
|
mov [mix_3_core], mmx_mix_3
|
|
|
|
mov [mix_4_core], mmx_mix_4
|
|
|
|
end if
|
|
|
|
|
|
|
|
if FORCE_MMX_128
|
|
|
|
if FORCE_MMX
|
|
|
|
display 'Use only FORCE_MMX or FORCE_MMX_128 not both together',13,10
|
|
|
|
stop
|
|
|
|
end if
|
|
|
|
mov [mix_2_core], mmx128_mix_2
|
|
|
|
mov [mix_3_core], mmx128_mix_3
|
|
|
|
mov [mix_4_core], mmx128_mix_4
|
|
|
|
end if
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
if 0
|
|
|
|
|
2007-01-24 16:51:55 +01:00
|
|
|
if ~(FORCE_MMX or FORCE_MMX_128) ;autodetect
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
bt edx, CAPS_SSE2
|
|
|
|
jc .mmx128
|
|
|
|
;old 64-bit mmx
|
|
|
|
mov [mix_2_core], mmx_mix_2
|
|
|
|
mov [mix_3_core], mmx_mix_3
|
|
|
|
mov [mix_4_core], mmx_mix_4
|
|
|
|
jmp @F
|
2007-02-08 02:02:14 +01:00
|
|
|
.mmx128: ;128-bit integer sse2 extensions
|
2007-01-24 16:51:55 +01:00
|
|
|
mov [mix_2_core], mmx128_mix_2
|
|
|
|
mov [mix_3_core], mmx128_mix_3
|
|
|
|
mov [mix_4_core], mmx128_mix_4
|
|
|
|
@@:
|
2007-02-27 12:47:52 +01:00
|
|
|
end if
|
|
|
|
|
2007-01-24 16:51:55 +01:00
|
|
|
end if
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall set_handler, [hSound], new_mix
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [eng_state], SND_STOP
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall RegService, szInfinity, service_proc
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
|
|
|
if DEBUG
|
2006-12-02 09:18:48 +01:00
|
|
|
mov esi, msgFail
|
2006-10-20 16:02:26 +02:00
|
|
|
call SysMsgBoardStr
|
2006-10-07 11:47:03 +02:00
|
|
|
end if
|
2006-11-20 08:06:00 +01:00
|
|
|
.exit:
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
.out_of_mem:
|
|
|
|
if DEBUG
|
|
|
|
mov esi, msgMem
|
2006-10-20 16:02:26 +02:00
|
|
|
call SysMsgBoardStr
|
2006-10-07 11:47:03 +02:00
|
|
|
end if
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
2006-10-20 16:02:26 +02:00
|
|
|
ret
|
2006-11-20 08:06:00 +01:00
|
|
|
endp
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
handle equ IOCTL.handle
|
|
|
|
io_code equ IOCTL.io_code
|
|
|
|
input equ IOCTL.input
|
|
|
|
inp_size equ IOCTL.inp_size
|
|
|
|
output equ IOCTL.output
|
|
|
|
out_size equ IOCTL.out_size
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc service_proc stdcall, ioctl:dword
|
|
|
|
|
|
|
|
mov edi, [ioctl]
|
|
|
|
mov eax, [edi+io_code]
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp eax, SRV_GETVERSION
|
|
|
|
jne @F
|
|
|
|
mov eax, [edi+output]
|
2007-04-18 08:37:14 +02:00
|
|
|
cmp [edi+out_size], 4
|
|
|
|
jne .fail
|
2007-02-27 12:47:52 +01:00
|
|
|
mov eax, [eax]
|
2007-07-09 03:05:41 +02:00
|
|
|
mov [eax], dword API_VERSION
|
2007-02-27 12:47:52 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
@@:
|
2006-12-02 09:18:48 +01:00
|
|
|
cmp eax, SND_CREATE_BUFF
|
|
|
|
jne @F
|
2006-10-07 11:47:03 +02:00
|
|
|
mov ebx, [edi+input]
|
2007-02-27 12:47:52 +01:00
|
|
|
stdcall CreateBuffer,[ebx],[ebx+4]
|
2007-07-01 17:18:55 +02:00
|
|
|
mov edi, [ioctl]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, [edi+output]
|
|
|
|
mov ecx, [ecx]
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ecx], ebx
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
@@:
|
|
|
|
mov ebx, [edi+input]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edx, [ebx]
|
|
|
|
|
|
|
|
cmp [edx+STREAM.magic], 'WAVE'
|
|
|
|
jne .fail
|
|
|
|
|
|
|
|
cmp [edx+STREAM.size], STREAM_SIZE
|
|
|
|
jne .fail
|
|
|
|
|
|
|
|
cmp eax, SND_DESTROY_BUFF
|
|
|
|
jne @F
|
|
|
|
mov eax, edx
|
|
|
|
call DestroyBuffer ;edx= stream
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
@@:
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp eax, SND_SETFORMAT
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall SetFormat,edx,[ebx+4]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETFORMAT
|
2006-12-02 09:18:48 +01:00
|
|
|
jne @F
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
movzx eax, word [edx+STREAM.format]
|
|
|
|
mov ecx, [edi+output]
|
|
|
|
mov ecx, [ecx]
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ecx], eax
|
2007-02-27 12:47:52 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_RESET
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall ResetBuffer,edx,[ebx+4]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_SETPOS
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall SetBufferPos,edx,[ebx+4]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETPOS
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall GetBufferPos, edx
|
2007-07-01 17:18:55 +02:00
|
|
|
mov edi, [ioctl]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, [edi+output]
|
|
|
|
mov ecx, [ecx]
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ecx], ebx
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
@@:
|
2006-12-02 09:18:48 +01:00
|
|
|
cmp eax, SND_SETBUFF
|
|
|
|
jne @F
|
|
|
|
mov eax, [ebx+4]
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall set_buffer, edx,eax,[ebx+8],[ebx+12]
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
@@:
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp eax, SND_SETVOLUME
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall SetBufferVol,edx,[ebx+4],[ebx+8]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETVOLUME
|
2006-12-02 09:18:48 +01:00
|
|
|
jne @F
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov eax, [edi+output]
|
|
|
|
mov ecx, [eax]
|
|
|
|
mov eax, [eax+4]
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall GetBufferVol,edx,ecx,eax
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
@@:
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp eax, SND_SETPAN
|
|
|
|
jne @F
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall SetBufferPan,edx,[ebx+4]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETPAN
|
|
|
|
jne @F
|
|
|
|
mov eax, [edx+STREAM.pan]
|
|
|
|
mov ebx, [edi+output]
|
|
|
|
mov ebx, [ebx]
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ebx], eax
|
2007-02-27 12:47:52 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_OUT
|
|
|
|
jne @F
|
|
|
|
|
|
|
|
mov eax, [ebx+4]
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall wave_out, edx,eax,[ebx+8]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_PLAY
|
|
|
|
jne @F
|
|
|
|
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall play_buffer, edx,[ebx+4]
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_STOP
|
|
|
|
jne @F
|
|
|
|
|
2007-07-08 21:25:07 +02:00
|
|
|
stdcall stop_buffer, edx
|
2007-02-27 12:47:52 +01:00
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETBUFFSIZE
|
|
|
|
jne @F
|
|
|
|
mov eax, [edx+STREAM.in_size]
|
|
|
|
mov ecx, [edi+output]
|
|
|
|
mov ecx, [ecx]
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ecx], eax
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2007-07-08 21:25:07 +02:00
|
|
|
@@:
|
|
|
|
cmp eax, SND_GETFREESPACE
|
|
|
|
jne @F
|
|
|
|
|
|
|
|
test [edx+STREAM.format], PCM_OUT
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
mov ebx, [edx+STREAM.in_free]
|
|
|
|
mov ecx, [edi+output]
|
|
|
|
mov [ecx], ebx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
2007-02-27 12:47:52 +01:00
|
|
|
@@:
|
|
|
|
.fail:
|
|
|
|
or eax, -1
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
endp
|
|
|
|
|
|
|
|
restore handle
|
|
|
|
restore io_code
|
|
|
|
restore input
|
|
|
|
restore inp_size
|
|
|
|
restore output
|
|
|
|
restore out_size
|
|
|
|
|
2007-02-08 02:02:14 +01:00
|
|
|
align 4
|
2007-02-27 12:47:52 +01:00
|
|
|
proc CreateBuffer stdcall, format:dword, size:dword
|
2006-12-02 09:18:48 +01:00
|
|
|
locals
|
2007-02-27 12:47:52 +01:00
|
|
|
str dd ?
|
|
|
|
ring_size dd ?
|
|
|
|
ring_pages dd ?
|
2006-12-02 09:18:48 +01:00
|
|
|
endl
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov eax, [format]
|
|
|
|
cmp ax, PCM_1_8_8
|
|
|
|
ja .fail
|
|
|
|
|
|
|
|
test eax, PCM_OUT
|
|
|
|
jnz .test_out
|
|
|
|
test eax, PCM_RING
|
|
|
|
jnz .test_ring
|
|
|
|
;staic
|
2007-07-07 09:25:17 +02:00
|
|
|
test eax, PCM_STATIC
|
2007-07-07 13:13:26 +02:00
|
|
|
jz .test_out ;use PCM_OUT as default format
|
2007-02-27 12:47:52 +01:00
|
|
|
jmp .test_ok
|
|
|
|
.test_out:
|
|
|
|
test eax, PCM_RING+PCM_STATIC
|
|
|
|
jnz .fail
|
2007-07-07 13:13:26 +02:00
|
|
|
or [format], PCM_OUT ;force set
|
2007-02-27 12:47:52 +01:00
|
|
|
jmp .test_ok
|
|
|
|
.test_ring:
|
|
|
|
test eax, PCM_OUT+PCM_STATIC
|
|
|
|
jnz .fail
|
|
|
|
.test_ok:
|
2007-05-24 09:36:48 +02:00
|
|
|
|
|
|
|
call GetPid
|
|
|
|
mov ebx, eax
|
2007-01-23 15:55:03 +01:00
|
|
|
mov eax, STREAM_SIZE
|
|
|
|
|
|
|
|
call CreateObject
|
|
|
|
test eax, eax
|
2006-12-02 09:18:48 +01:00
|
|
|
jz .fail
|
|
|
|
mov [str], eax
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ebx, [format]
|
|
|
|
mov [eax+STREAM.format], ebx
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
xor ecx, ecx
|
|
|
|
movzx ebx, bx
|
|
|
|
cmp ebx, 19
|
|
|
|
jb @f
|
|
|
|
mov ecx, 0x80808080
|
|
|
|
@@:
|
|
|
|
mov [eax+STREAM.r_silence], ecx
|
|
|
|
|
|
|
|
shl ebx, 2
|
|
|
|
lea ebx, [ebx+ebx*2] ;ebx*=12
|
|
|
|
|
|
|
|
mov ecx, [resampler_params+ebx]
|
|
|
|
mov edx, [resampler_params+ebx+4]
|
|
|
|
mov esi, [resampler_params+ebx+8]
|
|
|
|
|
|
|
|
mov [eax+STREAM.r_size],ecx
|
|
|
|
mov [eax+STREAM.r_dt], edx
|
|
|
|
mov [eax+STREAM.resample], esi
|
|
|
|
xor ecx, ecx
|
|
|
|
mov [eax+STREAM.l_vol], ecx
|
|
|
|
mov [eax+STREAM.r_vol], ecx
|
|
|
|
mov dword [eax+STREAM.l_amp], 0x7FFF7FFF
|
|
|
|
mov [eax+STREAM.pan], ecx
|
|
|
|
|
|
|
|
test [format], PCM_STATIC
|
|
|
|
jnz .static
|
|
|
|
|
|
|
|
; ring and waveout
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
mov ebx, 0x10000
|
2007-02-27 12:47:52 +01:00
|
|
|
test [format], PCM_RING
|
|
|
|
jz .waveout
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
mov ebx, [eax+STREAM.r_size]
|
|
|
|
add ebx, 4095
|
|
|
|
and ebx, -4096
|
|
|
|
add ebx, ebx
|
2007-02-27 12:47:52 +01:00
|
|
|
.waveout:
|
2007-04-18 08:37:14 +02:00
|
|
|
mov [ring_size], ebx
|
|
|
|
mov eax, ebx
|
2007-02-27 12:47:52 +01:00
|
|
|
shr ebx, 12
|
|
|
|
mov [ring_pages], ebx
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
stdcall CreateRingBuffer, eax, PG_SW
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
mov edi, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, [ring_size]
|
|
|
|
mov [edi+STREAM.in_base], eax
|
|
|
|
mov [edi+STREAM.in_size], ecx
|
|
|
|
add eax, 128
|
2007-07-01 17:18:55 +02:00
|
|
|
; sub ecx, 128
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edi+STREAM.in_wp], eax
|
|
|
|
mov [edi+STREAM.in_rp], eax
|
|
|
|
mov [edi+STREAM.in_count], 0
|
|
|
|
|
|
|
|
mov [edi+STREAM.in_free], ecx
|
|
|
|
add eax, ecx
|
|
|
|
mov [edi+STREAM.in_top], eax
|
|
|
|
|
|
|
|
jmp .out_buff
|
|
|
|
.static:
|
|
|
|
mov ecx, [size]
|
|
|
|
add ecx, 128 ;resampler required
|
|
|
|
mov [eax+STREAM.in_size], ecx
|
|
|
|
stdcall KernelAlloc, ecx
|
2007-02-08 02:02:14 +01:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, [str]
|
|
|
|
mov [edi+STREAM.in_base], eax
|
|
|
|
add eax, 128
|
|
|
|
mov [edi+STREAM.in_wp], eax
|
|
|
|
mov [edi+STREAM.in_rp], eax
|
|
|
|
mov ebx, [size]
|
|
|
|
mov [edi+STREAM.in_count], ebx
|
|
|
|
mov [edi+STREAM.in_free], ebx
|
|
|
|
add eax, ebx
|
|
|
|
mov [edi+STREAM.in_top], eax
|
|
|
|
|
|
|
|
.out_buff:
|
2007-02-08 02:02:14 +01:00
|
|
|
stdcall AllocKernelSpace, dword 128*1024
|
|
|
|
|
|
|
|
mov edi, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edi+STREAM.out_base], eax
|
|
|
|
mov [edi+STREAM.out_wp], eax
|
|
|
|
mov [edi+STREAM.out_rp], eax
|
|
|
|
mov [edi+STREAM.out_count], 0
|
2007-02-08 02:02:14 +01:00
|
|
|
add eax, 64*1024
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edi+STREAM.out_top], eax
|
2006-12-02 09:18:48 +01:00
|
|
|
|
2007-02-08 02:02:14 +01:00
|
|
|
stdcall AllocPages, dword 64/4
|
|
|
|
mov edi, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ebx, [edi+STREAM.out_base]
|
2007-02-08 02:02:14 +01:00
|
|
|
mov ecx, 16
|
|
|
|
or eax, PG_SW
|
|
|
|
push eax
|
|
|
|
push ebx
|
|
|
|
call CommitPages ;eax, ebx, ecx
|
|
|
|
mov ecx, 16
|
|
|
|
pop ebx
|
|
|
|
pop eax
|
|
|
|
add ebx, 64*1024
|
|
|
|
call CommitPages ;double mapped
|
|
|
|
|
|
|
|
mov edi, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, [edi+STREAM.in_top]
|
|
|
|
mov edi, [edi+STREAM.in_base]
|
|
|
|
sub ecx, edi
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
2007-02-27 12:47:52 +01:00
|
|
|
shr ecx, 2
|
2007-02-08 02:02:14 +01:00
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
mov edi, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, [edi+STREAM.out_base]
|
2007-02-08 02:02:14 +01:00
|
|
|
mov ecx, (64*1024)/4
|
2006-12-02 09:18:48 +01:00
|
|
|
rep stosd
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
xor edx, edx
|
|
|
|
mov ebx, MANUAL_DESTROY
|
|
|
|
call CreateEvent
|
|
|
|
|
|
|
|
mov ebx, [str]
|
|
|
|
mov [ebx+STREAM.notify_event], eax
|
|
|
|
mov [ebx+STREAM.notify_id], edx
|
|
|
|
|
|
|
|
mov [ebx+STREAM.magic], 'WAVE'
|
|
|
|
mov [ebx+STREAM.destroy], DestroyBuffer.destroy
|
|
|
|
mov [ebx+STREAM.size], STREAM_SIZE
|
|
|
|
mov [ebx+STREAM.flags], SND_STOP
|
|
|
|
|
|
|
|
pushf
|
|
|
|
cli
|
|
|
|
mov eax, str.fd-FD_OFFSET
|
|
|
|
mov edx, [eax+STREAM.str_fd]
|
|
|
|
mov [ebx+STREAM.str_fd], edx
|
|
|
|
mov [ebx+STREAM.str_bk], eax
|
|
|
|
mov [eax+STREAM.str_fd], ebx
|
|
|
|
mov [edx+STREAM.str_bk], ebx
|
|
|
|
popf
|
|
|
|
|
|
|
|
xor eax, eax
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
2007-02-27 12:47:52 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
or eax, -1
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
endp
|
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
;param
|
|
|
|
; eax= buffer handle
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
align 4
|
|
|
|
DestroyBuffer:
|
2007-02-08 02:02:14 +01:00
|
|
|
.handle equ esp ;local
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [eax+STREAM.flags], SND_STOP
|
2007-01-23 15:55:03 +01:00
|
|
|
.destroy:
|
2007-02-08 02:02:14 +01:00
|
|
|
push eax
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
pushfd
|
2007-01-23 15:55:03 +01:00
|
|
|
cli
|
|
|
|
mov ebx, [eax+STREAM.str_fd]
|
|
|
|
mov ecx, [eax+STREAM.str_bk]
|
|
|
|
mov [ebx+STREAM.str_bk], ecx
|
|
|
|
mov [ecx+STREAM.str_fd], ebx
|
|
|
|
popf
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
stdcall KernelFree, [eax+STREAM.in_base]
|
2007-02-08 02:02:14 +01:00
|
|
|
mov eax, [.handle]
|
2007-02-27 12:47:52 +01:00
|
|
|
stdcall KernelFree, [eax+STREAM.out_base]
|
2007-02-08 02:02:14 +01:00
|
|
|
|
|
|
|
pop eax ;restore stack
|
2007-02-27 12:47:52 +01:00
|
|
|
call DestroyObject ;eax= stream
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
2007-02-27 12:47:52 +01:00
|
|
|
or eax, -1
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2007-02-27 12:47:52 +01:00
|
|
|
restore .handle
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
align 4
|
2007-02-27 12:47:52 +01:00
|
|
|
proc SetFormat stdcall, str:dword, format:dword
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp word [format], PCM_1_8_8
|
|
|
|
ja .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edx, [str]
|
|
|
|
mov [edx+STREAM.flags], SND_STOP
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
test [edx+STREAM.format], PCM_RING
|
|
|
|
jnz .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
; mov eax,[edx+STREAM.out_base]
|
|
|
|
; mov [edx+STREAM.out_wp], eax
|
|
|
|
; mov [edx+STREAM.out_rp], eax
|
|
|
|
; mov [edx+STREAM.out_count], 0
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
movzx eax, word [format]
|
|
|
|
mov word [edx+STREAM.format], ax
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
cmp eax, 19
|
|
|
|
jb @f
|
|
|
|
mov ebx, 0x80808080
|
|
|
|
@@:
|
|
|
|
mov [edx+STREAM.r_silence], ebx
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
shl eax, 2
|
|
|
|
lea eax, [eax+eax*2] ;eax*=12
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, [resampler_params+eax]
|
|
|
|
mov ecx, [resampler_params+eax+4]
|
|
|
|
mov ebx, [resampler_params+eax+8]
|
2007-01-20 08:48:13 +01:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edx+STREAM.r_size],edi
|
|
|
|
mov [edx+STREAM.r_dt], ecx
|
|
|
|
mov [edx+STREAM.resample], ebx
|
|
|
|
|
|
|
|
mov edi, [edx+STREAM.in_base]
|
|
|
|
mov ecx, 128/4
|
|
|
|
mov eax, [edx+STREAM.r_silence]
|
2007-01-20 08:48:13 +01:00
|
|
|
cld
|
|
|
|
rep stosd
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
2007-02-27 12:47:52 +01:00
|
|
|
or eax, -1
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
endp
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
; for static buffers only
|
|
|
|
; use waveout for streams
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
align 4
|
|
|
|
proc set_buffer stdcall, str:dword,src:dword,offs:dword,size:dword
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edx, [str]
|
|
|
|
test [edx+STREAM.format], PCM_OUT
|
|
|
|
jnz .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov esi, [src]
|
|
|
|
mov edi, [offs]
|
|
|
|
add edi, [edx+STREAM.in_base]
|
|
|
|
add edi, 128
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp edi, [edx+STREAM.in_top]
|
|
|
|
jae .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ecx, [size]
|
|
|
|
lea ebx, [ecx+edi]
|
|
|
|
sub ebx, [edx+STREAM.in_top]
|
|
|
|
jb @F
|
|
|
|
sub ecx, ebx
|
|
|
|
@@:
|
|
|
|
shr ecx, 2
|
|
|
|
cld
|
|
|
|
rep movsd
|
|
|
|
xor eax,eax
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
2007-02-27 12:47:52 +01:00
|
|
|
or eax, -1
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
endp
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
; for stream buffers only
|
|
|
|
|
2006-10-07 11:47:03 +02:00
|
|
|
align 4
|
2007-02-27 12:47:52 +01:00
|
|
|
proc wave_out stdcall, str:dword,src:dword,size:dword
|
|
|
|
locals
|
|
|
|
state_saved dd ?
|
|
|
|
fpu_state rb 528
|
|
|
|
endl
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
mov edx, [str]
|
2007-02-27 12:47:52 +01:00
|
|
|
mov eax, [edx+STREAM.format]
|
2007-07-07 13:13:26 +02:00
|
|
|
test eax, PCM_OUT
|
|
|
|
jz .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp ax, PCM_ALL
|
|
|
|
je .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
mov esi,[src]
|
|
|
|
test esi, esi
|
|
|
|
jz .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
cmp esi, OS_BASE
|
2007-07-09 14:30:20 +02:00
|
|
|
jae .fail
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [state_saved], 0
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
.main_loop:
|
|
|
|
mov edx, [str]
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov ebx, [size]
|
|
|
|
test ebx, ebx
|
|
|
|
jz .done
|
|
|
|
|
|
|
|
cmp [edx+STREAM.flags], SND_STOP
|
|
|
|
jne .fill
|
|
|
|
|
|
|
|
mov edi, [edx+STREAM.in_base]
|
|
|
|
mov ecx, 128/4
|
|
|
|
mov eax, [edx+STREAM.r_silence]
|
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
mov ecx, [edx+STREAM.in_size]
|
|
|
|
sub ecx, 128
|
|
|
|
mov [edx+STREAM.in_wp], edi
|
|
|
|
mov [edx+STREAM.in_rp], edi
|
|
|
|
mov [edx+STREAM.in_count], 0
|
|
|
|
mov [edx+STREAM.in_free], ecx
|
|
|
|
|
|
|
|
mov eax,[edx+STREAM.out_base]
|
|
|
|
mov [edx+STREAM.out_wp], eax
|
|
|
|
mov [edx+STREAM.out_rp], eax
|
|
|
|
mov [edx+STREAM.out_count], 0
|
|
|
|
.fill:
|
|
|
|
mov ecx, [edx+STREAM.in_free]
|
|
|
|
test ecx, ecx
|
|
|
|
jz .wait
|
|
|
|
|
|
|
|
cmp ecx, ebx
|
|
|
|
jbe @F
|
|
|
|
|
|
|
|
mov ecx, ebx
|
|
|
|
@@:
|
2007-01-20 08:48:13 +01:00
|
|
|
sub [size], ecx
|
2007-02-27 12:47:52 +01:00
|
|
|
add [edx+STREAM.in_count], ecx
|
|
|
|
sub [edx+STREAM.in_free], ecx
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
shr ecx, 2
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, [edx+STREAM.in_wp]
|
|
|
|
mov esi, [src]
|
2006-10-07 11:47:03 +02:00
|
|
|
cld
|
2006-12-02 09:18:48 +01:00
|
|
|
rep movsd
|
2007-02-27 12:47:52 +01:00
|
|
|
|
|
|
|
mov [src], esi
|
|
|
|
cmp edi, [edx+STREAM.in_top]
|
|
|
|
jb @F
|
|
|
|
sub edi, [edx+STREAM.in_size]
|
2007-01-20 08:48:13 +01:00
|
|
|
@@:
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edx+STREAM.in_wp], edi
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp [edx+STREAM.out_count], 32768
|
|
|
|
jae .skip
|
|
|
|
|
|
|
|
cmp [state_saved], 0
|
|
|
|
jne @F
|
|
|
|
lea eax, [fpu_state+15]
|
|
|
|
and eax, -16
|
|
|
|
call FpuSave
|
|
|
|
mov [state_saved], 1
|
|
|
|
@@:
|
|
|
|
stdcall refill, edx
|
|
|
|
.skip:
|
2007-07-09 14:30:20 +02:00
|
|
|
mov edx, [str]
|
|
|
|
mov [edx+STREAM.flags], SND_PLAY
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp [eng_state], SND_PLAY
|
|
|
|
je .main_loop
|
|
|
|
|
|
|
|
stdcall dev_play, [hSound]
|
|
|
|
mov [eng_state], SND_PLAY
|
|
|
|
jmp .main_loop
|
|
|
|
.wait:
|
|
|
|
mov edx, [str]
|
|
|
|
mov eax, [edx+STREAM.notify_event]
|
|
|
|
mov ebx, [edx+STREAM.notify_id]
|
|
|
|
call WaitEvent ;eax ebx
|
|
|
|
jmp .main_loop
|
2007-01-20 08:48:13 +01:00
|
|
|
.done:
|
2007-02-27 12:47:52 +01:00
|
|
|
cmp [state_saved], 1
|
|
|
|
jne @F
|
|
|
|
|
|
|
|
lea eax, [fpu_state+15]
|
|
|
|
and eax, -16
|
|
|
|
call FpuRestore
|
|
|
|
@@:
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
.fail:
|
|
|
|
or eax, -1
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
; both static and stream
|
|
|
|
; reset all but not clear buffers
|
|
|
|
|
|
|
|
|
|
|
|
; flags reserved
|
|
|
|
; RESET_INPUT equ 1 ;reserved reset and clear input buffer
|
|
|
|
; RESET_OUTPUT equ 2 ;reserved reset and clear output buffer
|
|
|
|
; RESET_ALL equ 3
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc ResetBuffer stdcall, str:dword, flags:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
mov [edx+STREAM.flags], SND_STOP
|
|
|
|
|
|
|
|
mov edi, [edx+STREAM.in_base]
|
|
|
|
mov ecx, 128/4
|
|
|
|
mov eax, [edx+STREAM.r_silence]
|
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
mov [edx+STREAM.in_wp], edi
|
|
|
|
mov [edx+STREAM.in_rp], edi
|
|
|
|
|
2007-07-07 09:25:17 +02:00
|
|
|
test [edx+STREAM.flags], PCM_STATIC
|
|
|
|
jnz .static
|
2007-02-27 12:47:52 +01:00
|
|
|
mov [edx+STREAM.in_count], 0
|
2007-07-07 09:25:17 +02:00
|
|
|
jmp @F
|
|
|
|
.static:
|
|
|
|
mov eax, [edx+STREAM.in_size]
|
|
|
|
mov [edx+STREAM.in_count], eax
|
|
|
|
@@:
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
mov eax, [edx+STREAM.in_size]
|
|
|
|
sub eax, 128
|
|
|
|
mov [edx+STREAM.in_free], eax
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
mov ebx,[edx+STREAM.out_base]
|
|
|
|
mov [edx+STREAM.out_wp], ebx
|
|
|
|
mov [edx+STREAM.out_rp], ebx
|
|
|
|
mov [edx+STREAM.out_count], eax
|
|
|
|
ret
|
|
|
|
.fail:
|
|
|
|
or eax, -1
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
; for static buffers only
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc SetBufferPos stdcall, str:dword, pos:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
2007-07-07 13:13:26 +02:00
|
|
|
test [edx+STREAM.format], PCM_STATIC
|
|
|
|
jz .fail
|
2007-02-27 12:47:52 +01:00
|
|
|
|
|
|
|
mov [edx+STREAM.flags], SND_STOP
|
|
|
|
|
|
|
|
mov eax, [pos]
|
|
|
|
add eax, [edx+STREAM.in_base]
|
|
|
|
mov ebx, [edx+STREAM.in_top]
|
|
|
|
add eax, 128
|
|
|
|
|
|
|
|
cmp eax, ebx
|
|
|
|
jae .fail
|
|
|
|
|
|
|
|
mov [edx+STREAM.in_rp], eax
|
|
|
|
sub ebx, eax
|
|
|
|
mov [edx+STREAM.in_count], ebx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
.fail:
|
|
|
|
or eax, -1
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc GetBufferPos stdcall, str:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
2007-07-07 13:13:26 +02:00
|
|
|
test [edx+STREAM.format], PCM_STATIC
|
|
|
|
jz .fail
|
2007-02-27 12:47:52 +01:00
|
|
|
|
|
|
|
mov ebx, [edx+STREAM.in_rp]
|
2007-07-07 09:25:17 +02:00
|
|
|
sub ebx, [edx+STREAM.in_base]
|
|
|
|
sub ebx, 128
|
2007-02-27 12:47:52 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
.fail:
|
|
|
|
xor ebx,ebx
|
|
|
|
or eax, -1
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
; both
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc SetBufferVol stdcall, str:dword,l_vol:dword,r_vol:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
stdcall set_vol_param,[l_vol],[r_vol],[edx+STREAM.pan]
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword
|
|
|
|
locals
|
|
|
|
_600 dd ?
|
|
|
|
_32767 dd ?
|
|
|
|
state rb 108
|
|
|
|
endl
|
|
|
|
|
|
|
|
mov [_600], 0x44160000 ;600.0
|
|
|
|
mov [_32767], 32767
|
|
|
|
|
|
|
|
lea ebx, [state]
|
|
|
|
fnsave [ebx]
|
|
|
|
|
|
|
|
movq mm0, qword [l_vol]
|
|
|
|
pminsw mm0, qword [vol_max]
|
|
|
|
pmaxsw mm0, qword [vol_min]
|
|
|
|
movq qword [l_vol], mm0
|
|
|
|
movq qword [edx+STREAM.l_vol], mm0
|
|
|
|
|
|
|
|
movd mm1,[pan]
|
|
|
|
pminsw mm1, qword [pan_max]
|
|
|
|
pmaxsw mm1, qword [vol_min]
|
|
|
|
movd [edx+STREAM.pan], mm1
|
|
|
|
|
|
|
|
cmp word [edx+STREAM.pan], 0
|
|
|
|
jl @F
|
|
|
|
|
|
|
|
psubsw mm0,mm1
|
|
|
|
pminsw mm0, qword [vol_max]
|
|
|
|
pmaxsw mm0, qword [vol_min]
|
|
|
|
movd [l_vol],mm0
|
|
|
|
jmp .calc_amp
|
|
|
|
@@:
|
|
|
|
punpckhdq mm0,mm0
|
|
|
|
paddsw mm0,mm1
|
|
|
|
pminsw mm0, qword [vol_max]
|
|
|
|
pmaxsw mm0, qword [vol_min]
|
|
|
|
movd [r_vol], mm0
|
|
|
|
.calc_amp:
|
|
|
|
emms
|
|
|
|
fild word [l_vol]
|
|
|
|
|
|
|
|
call .calc
|
|
|
|
|
|
|
|
fistp word [edx+STREAM.l_amp]
|
2008-01-12 08:54:11 +01:00
|
|
|
fstp dword [edx+STREAM.l_amp_f]
|
2007-02-27 12:47:52 +01:00
|
|
|
fstp st0
|
|
|
|
|
|
|
|
fild word [r_vol]
|
|
|
|
|
|
|
|
call .calc
|
|
|
|
|
|
|
|
fistp word [edx+STREAM.r_amp]
|
2008-01-12 08:54:11 +01:00
|
|
|
fstp dword [edx+STREAM.r_amp_f]
|
2007-02-27 12:47:52 +01:00
|
|
|
fstp st0
|
|
|
|
|
|
|
|
fnclex
|
|
|
|
lea ebx, [state]
|
|
|
|
frstor [ebx]
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
|
|
|
inc eax
|
|
|
|
ret
|
2007-02-27 12:47:52 +01:00
|
|
|
.calc:
|
|
|
|
fdiv dword [_600]
|
|
|
|
fld st0
|
|
|
|
frndint
|
|
|
|
fxch st1
|
|
|
|
fsub st, st1
|
|
|
|
f2xm1
|
|
|
|
fld1
|
|
|
|
faddp st1, st0
|
|
|
|
fscale
|
2008-01-12 08:54:11 +01:00
|
|
|
fld st0
|
2007-02-27 12:47:52 +01:00
|
|
|
fimul dword [_32767]
|
|
|
|
ret 0
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc GetBufferVol stdcall, str:dword,p_lvol:dword,p_rvol:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
mov eax, [p_lvol]
|
|
|
|
movsx ecx, word [edx+STREAM.l_vol]
|
|
|
|
mov [eax], ecx
|
|
|
|
|
|
|
|
mov eax, [p_rvol]
|
|
|
|
movsx ecx, word [edx+STREAM.r_vol]
|
|
|
|
mov [eax], ecx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc SetBufferPan stdcall, str:dword,pan:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
stdcall set_vol_param,[edx+STREAM.l_vol],\
|
|
|
|
[edx+STREAM.r_vol],[pan]
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
; for static and ring buffers only
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc play_buffer stdcall, str:dword, flags:dword
|
|
|
|
|
|
|
|
mov ebx, [str]
|
|
|
|
mov eax, [ebx+STREAM.format]
|
|
|
|
test eax, PCM_OUT
|
|
|
|
jnz .fail
|
|
|
|
|
|
|
|
cmp ax, PCM_ALL
|
|
|
|
je .fail
|
|
|
|
|
|
|
|
mov [ebx+STREAM.flags], SND_PLAY
|
|
|
|
cmp [eng_state], SND_PLAY
|
|
|
|
je .done
|
|
|
|
|
|
|
|
stdcall dev_play, [hSound]
|
|
|
|
mov [eng_state], SND_PLAY
|
|
|
|
.done:
|
|
|
|
test [flags], PLAY_SYNC
|
|
|
|
jz @F
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
.wait:
|
|
|
|
mov eax, [edx+STREAM.notify_event]
|
|
|
|
mov ebx, [edx+STREAM.notify_id]
|
|
|
|
call WaitEvent ;eax ebx
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
cmp [edx+STREAM.flags], SND_STOP
|
|
|
|
jne .wait
|
|
|
|
@@:
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
.fail:
|
2007-02-27 12:47:52 +01:00
|
|
|
or eax, -1
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2007-07-07 09:25:17 +02:00
|
|
|
; for static and ring buffers only
|
2007-02-27 12:47:52 +01:00
|
|
|
|
|
|
|
align 4
|
|
|
|
proc stop_buffer stdcall, str:dword
|
|
|
|
|
|
|
|
mov edx, [str]
|
|
|
|
test [edx+STREAM.format], PCM_STATIC+PCM_RING
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
mov [edx+STREAM.flags], SND_STOP
|
|
|
|
|
|
|
|
; stdcall [ServiceHandler], [hSound], dword DEV_STOP, 0
|
|
|
|
|
|
|
|
mov eax, [edx+STREAM.notify_event]
|
|
|
|
mov ebx, [edx+STREAM.notify_id]
|
|
|
|
call ClearEvent ;eax ebx
|
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2007-02-27 12:47:52 +01:00
|
|
|
.fail:
|
|
|
|
or eax, -1
|
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
endp
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
; parm
|
|
|
|
; eax= mix_list
|
|
|
|
|
|
|
|
align 4
|
|
|
|
do_mix_list:
|
|
|
|
|
|
|
|
xor edx, edx
|
|
|
|
mov esi, str.fd-FD_OFFSET
|
|
|
|
mov ebx, [esi+STREAM.str_fd]
|
|
|
|
@@:
|
|
|
|
cmp ebx, esi
|
|
|
|
je .done
|
|
|
|
|
|
|
|
cmp [ebx+STREAM.magic], 'WAVE'
|
|
|
|
jne .next
|
|
|
|
|
|
|
|
cmp [ebx+STREAM.size], STREAM_SIZE
|
|
|
|
jne .next
|
|
|
|
|
|
|
|
cmp [ebx+STREAM.flags], SND_PLAY;
|
|
|
|
jne .next
|
|
|
|
|
|
|
|
mov ecx, [ebx+STREAM.out_count]
|
|
|
|
test ecx, ecx
|
|
|
|
jnz .l1
|
|
|
|
|
|
|
|
test [ebx+STREAM.format], PCM_RING
|
|
|
|
jnz .next
|
|
|
|
mov [ebx+STREAM.flags], SND_STOP
|
|
|
|
jmp .next
|
|
|
|
.l1:
|
|
|
|
cmp ecx, 512
|
|
|
|
jae .add_buff
|
|
|
|
|
|
|
|
mov edi, [ebx+STREAM.out_rp]
|
|
|
|
add edi, ecx
|
|
|
|
sub ecx, 512
|
|
|
|
neg ecx
|
|
|
|
push eax
|
|
|
|
xor eax, eax
|
|
|
|
cld
|
|
|
|
rep stosb
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
mov [ebx+STREAM.out_count], 512
|
|
|
|
|
|
|
|
.add_buff:
|
|
|
|
mov ecx, [ebx+STREAM.out_rp]
|
|
|
|
mov [eax],ecx
|
2008-01-12 08:54:11 +01:00
|
|
|
|
|
|
|
if USE_SSE2_MIXER
|
|
|
|
mov edi, dword [ebx+STREAM.l_amp_f]
|
|
|
|
mov [eax+4], edi
|
|
|
|
mov edi, dword [ebx+STREAM.r_amp_f]
|
|
|
|
mov [eax+8], edi
|
|
|
|
else
|
2007-02-27 12:47:52 +01:00
|
|
|
mov edi, dword [ebx+STREAM.l_amp]
|
|
|
|
mov [eax+4], edi
|
2008-01-12 08:54:11 +01:00
|
|
|
end if
|
2007-02-27 12:47:52 +01:00
|
|
|
add [ebx+STREAM.out_rp], 512
|
|
|
|
sub [ebx+STREAM.out_count], 512
|
|
|
|
|
2008-01-12 08:54:11 +01:00
|
|
|
add eax, 12
|
2007-02-27 12:47:52 +01:00
|
|
|
inc edx
|
|
|
|
.next:
|
|
|
|
mov ebx, [ebx+STREAM.str_fd]
|
|
|
|
jmp @B
|
|
|
|
.done:
|
|
|
|
mov eax, edx
|
|
|
|
ret
|
|
|
|
|
2006-10-07 11:47:03 +02:00
|
|
|
align 4
|
2007-01-23 15:55:03 +01:00
|
|
|
prepare_playlist:
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2006-12-02 09:18:48 +01:00
|
|
|
xor edx, edx
|
2007-01-23 15:55:03 +01:00
|
|
|
mov [play_count], edx
|
|
|
|
mov esi, str.fd-FD_OFFSET
|
|
|
|
mov edi, [esi+STREAM.str_fd]
|
|
|
|
@@:
|
|
|
|
cmp edi, esi
|
|
|
|
je .done
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
cmp [edi+STREAM.magic], 'WAVE'
|
2006-10-07 11:47:03 +02:00
|
|
|
jne .next
|
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
cmp [edi+STREAM.size], STREAM_SIZE
|
2006-10-07 11:47:03 +02:00
|
|
|
jne .next
|
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
cmp [edi+STREAM.flags], SND_PLAY;
|
2006-12-02 09:18:48 +01:00
|
|
|
jne .next
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
mov [play_list+edx], edi
|
2006-12-02 09:18:48 +01:00
|
|
|
inc [play_count]
|
|
|
|
add edx, 4
|
2006-10-07 11:47:03 +02:00
|
|
|
.next:
|
2007-01-23 15:55:03 +01:00
|
|
|
mov edi, [edi+STREAM.str_fd]
|
|
|
|
jmp @B
|
|
|
|
.done:
|
2006-12-02 09:18:48 +01:00
|
|
|
ret
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
align 4
|
|
|
|
proc set_handler stdcall, hsrv:dword, handler_proc:dword
|
|
|
|
locals
|
|
|
|
handler dd ?
|
|
|
|
io_code dd ?
|
|
|
|
input dd ?
|
|
|
|
inp_size dd ?
|
|
|
|
output dd ?
|
|
|
|
out_size dd ?
|
|
|
|
val dd ?
|
|
|
|
endl
|
|
|
|
|
|
|
|
mov eax, [hsrv]
|
|
|
|
lea ecx, [handler_proc]
|
|
|
|
xor ebx, ebx
|
|
|
|
|
|
|
|
mov [handler], eax
|
|
|
|
mov [io_code], DEV_CALLBACK
|
|
|
|
mov [input], ecx
|
|
|
|
mov [inp_size], 4
|
|
|
|
mov [output], ebx
|
|
|
|
mov [out_size], 0
|
|
|
|
|
|
|
|
lea eax, [handler]
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall ServiceHandler, eax
|
2006-10-07 11:47:03 +02:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
align 4
|
|
|
|
proc dev_play stdcall, hsrv:dword
|
|
|
|
locals
|
|
|
|
handle dd ?
|
|
|
|
io_code dd ?
|
|
|
|
input dd ?
|
|
|
|
inp_size dd ?
|
|
|
|
output dd ?
|
|
|
|
out_size dd ?
|
|
|
|
val dd ?
|
|
|
|
endl
|
|
|
|
|
|
|
|
mov eax, [hsrv]
|
|
|
|
xor ebx, ebx
|
|
|
|
|
|
|
|
mov [handle], eax
|
|
|
|
mov [io_code], DEV_PLAY
|
|
|
|
mov [input], ebx
|
|
|
|
mov [inp_size], ebx
|
|
|
|
mov [output], ebx
|
|
|
|
mov [out_size], ebx
|
|
|
|
|
|
|
|
lea eax, [handle]
|
2006-10-20 16:02:26 +02:00
|
|
|
stdcall ServiceHandler, eax
|
2006-10-07 11:47:03 +02:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
if 0
|
|
|
|
align 4
|
|
|
|
dword2str:
|
|
|
|
mov esi, hex_buff
|
|
|
|
mov ecx, -8
|
|
|
|
@@:
|
|
|
|
rol eax, 4
|
|
|
|
mov ebx, eax
|
|
|
|
and ebx, 0x0F
|
|
|
|
mov bl, [ebx+hexletters]
|
|
|
|
mov [8+esi+ecx], bl
|
|
|
|
inc ecx
|
|
|
|
jnz @B
|
|
|
|
ret
|
|
|
|
|
|
|
|
hexletters db '0123456789ABCDEF'
|
|
|
|
hex_buff db 8 dup(0),13,10,0
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
2006-10-07 11:47:03 +02:00
|
|
|
include 'mixer.asm'
|
2007-01-24 16:51:55 +01:00
|
|
|
include 'mix_mmx.inc'
|
|
|
|
include 'mix_sse2.inc'
|
2007-01-23 15:55:03 +01:00
|
|
|
|
|
|
|
;if USE_SSE
|
|
|
|
; include 'mix_sse.inc'
|
|
|
|
;end if
|
|
|
|
|
2006-10-07 11:47:03 +02:00
|
|
|
align 16
|
|
|
|
resampler_params:
|
2007-02-27 12:47:52 +01:00
|
|
|
;r_size r_dt resampler_func
|
|
|
|
dd 0,0,0 ; 0 PCM_ALL
|
|
|
|
dd 16384, 0, copy_stream ; 1 PCM_2_16_48
|
|
|
|
dd 16384, 0, m16_stereo ; 2 PCM_1_16_48
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 16384, 30109, resample_2 ; 3 PCM_2_16_44
|
|
|
|
dd 8192, 30109, resample_1 ; 4 PCM_1_16_44
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 16384, 21846, resample_2 ; 5 PCM_2_16_32
|
|
|
|
dd 8192, 21846, resample_1 ; 6 PCM_1_16_32
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 16384, 16384, resample_2 ; 7 PCM_2_16_24
|
|
|
|
dd 8192, 16384, resample_1 ; 8 PCM_1_16_24
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 15052, resample_2 ; 9 PCM_2_16_22
|
|
|
|
dd 4096, 15052, resample_1 ;10 PCM_1_16_22
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 10923, resample_2 ;11 PCM_2_16_16
|
|
|
|
dd 4096, 10923, resample_1 ;12 PCM_1_16_16
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 8192, resample_2 ;13 PCM_2_16_12
|
|
|
|
dd 4096, 8192, resample_1 ;14 PCM_1_16_12
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 4096, 7527, resample_2 ;15 PCM_2_16_11
|
|
|
|
dd 2048, 7527, resample_1 ;16 PCM_1_16_11
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 4096, 5462, resample_2 ;17 PCM_2_16_8
|
|
|
|
dd 2048, 5462, resample_1 ;18 PCM_1_16_8
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 16384, 0, s8_stereo ;19 PCM_2_8_48
|
|
|
|
dd 8192, 0, m8_stereo ;20 PCM_1_8_48
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 30109, resample_28 ;21 PCM_2_8_44
|
|
|
|
dd 4096, 30109, resample_18 ;22 PCM_1_8_44
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 21846, resample_28 ;23 PCM_2_8_32
|
|
|
|
dd 4096, 21846, resample_18 ;24 PCM_1_8_32
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 8192, 16384, resample_28 ;25 PCM_2_8_24
|
|
|
|
dd 4096, 16384, resample_18 ;26 PCM_1_8_24
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 4096, 15052, resample_28 ;27 PCM_2_8_22
|
|
|
|
dd 2048, 15052, resample_18 ;28 PCM_1_8_22
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 4096, 10923, resample_28 ;29 PCM_2_8_16
|
|
|
|
dd 2048, 10923, resample_18 ;30 PCM_1_8_16
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 4096, 8192, resample_28 ;31 PCM_2_8_12
|
|
|
|
dd 2048, 8192, resample_18 ;32 PCM_1_8_12
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 2048, 7527, resample_28 ;33 PCM_2_8_11
|
|
|
|
dd 1024, 7527, resample_18 ;34 PCM_1_8_11
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
dd 2048, 5462, resample_28 ;35 PCM_2_8_8
|
|
|
|
dd 1024, 5462, resample_18 ;36 PCM_1_8_8
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-19 04:58:46 +01:00
|
|
|
m7 dw 0x8000,0x8000,0x8000,0x8000
|
|
|
|
mm80 dq 0x8080808080808080
|
|
|
|
mm_mask dq 0xFF00FF00FF00FF00
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-02-27 12:47:52 +01:00
|
|
|
vol_max dd 0x00000000,0x00000000
|
|
|
|
vol_min dd 0x0000D8F0,0x0000D8F0
|
|
|
|
pan_max dd 0x00002710,0x00002710
|
|
|
|
|
2007-01-23 15:55:03 +01:00
|
|
|
;stream_map dd 0xFFFF ; 16
|
2007-07-09 03:05:41 +02:00
|
|
|
version dd (5 shl 16) or SOUND_VERSION
|
2006-10-07 11:47:03 +02:00
|
|
|
|
2007-01-19 04:58:46 +01:00
|
|
|
szInfinity db 'INFINITY',0
|
|
|
|
szSound db 'SOUND',0
|
2006-10-07 11:47:03 +02:00
|
|
|
|
|
|
|
if DEBUG
|
2007-01-19 04:58:46 +01:00
|
|
|
msgFail db 'Sound service not loaded',13,10,0
|
|
|
|
msgPlay db 'Play buffer',13,10,0
|
|
|
|
msgStop db 'Stop',13,10,0
|
|
|
|
msgUser db 'User callback',13,10,0
|
|
|
|
msgMem db 'Not enough memory',13,10,0
|
2007-01-23 15:55:03 +01:00
|
|
|
msgDestroy db 'Destroy sound buffer', 13,10,0
|
2007-02-27 12:47:52 +01:00
|
|
|
msgWaveout db 'Play waveout', 13,10,0
|
|
|
|
msgSetVolume db 'Set volume',13,10,0
|
2006-10-07 11:47:03 +02:00
|
|
|
end if
|
2006-10-20 16:02:26 +02:00
|
|
|
|
|
|
|
section '.data' data readable writable align 16
|
|
|
|
|
2007-01-19 04:58:46 +01:00
|
|
|
play_list rd 16
|
|
|
|
mix_input rd 16
|
|
|
|
play_count rd 1
|
|
|
|
hSound rd 1
|
2007-02-27 12:47:52 +01:00
|
|
|
eng_state rd 1
|
2007-01-19 04:58:46 +01:00
|
|
|
mix_buff rd 1
|
|
|
|
mix_buff_map rd 1
|
2007-01-23 15:55:03 +01:00
|
|
|
str.fd rd 1
|
|
|
|
str.bk rd 1
|
|
|
|
|
2007-01-24 16:51:55 +01:00
|
|
|
mix_2_core rd 1
|
|
|
|
mix_3_core rd 1
|
|
|
|
mix_4_core rd 1
|
2006-10-20 16:02:26 +02:00
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|