updated soundlib, DOOM, ac97snd

git-svn-id: svn://kolibrios.org@376 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-02-26 12:12:22 +00:00
parent b07dfce332
commit 6cf25c8bd8
23 changed files with 496 additions and 1090 deletions

View File

@ -76,18 +76,18 @@ extern "C"
typedef unsigned int SNDBUF; typedef unsigned int SNDBUF;
int _stdcall InitSound(); int _stdcall InitSound(int *version);
SNDBUF _stdcall CreateBuffer(unsigned int format,int size); int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
int _stdcall DestroyBuffer(SNDBUF hBuff); int _stdcall DestroyBuffer(SNDBUF hBuff);
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff); int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset); int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
int _stdcall GetBufferPos(SNDBUF hBuff); int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
int _stdcall GetBufferSize(SNDBUF hBuff); int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
int _stdcall SetBuffer(SNDBUF hBuff,void* buff, int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
int offs, int size); int offs, int size);
@ -98,11 +98,32 @@ int _stdcall StopBuffer(SNDBUF hBuff);
int _stdcall SetVolume(SNDBUF hBuff, int left, int right); int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan); int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff); int _stdcall GetPan(SNDBUF hBuff, int *pan);
int _stdcall GetMasterVol(int* vol); int _stdcall GetMasterVol(int* vol);
int _stdcall SetMasterVol(int vol); int _stdcall SetMasterVol(int vol);
typedef struct
{
unsigned int riff_id;
unsigned int riff_size;
unsigned int riff_format;
unsigned int fmt_id;
unsigned int fmt_size;
unsigned short int wFormatTag;
unsigned short int nChannels;
unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec;
unsigned short int nBlockAlign;
unsigned short int wBitsPerSample;
unsigned int data_id;
unsigned int data_size;
} WAVEHEADER;
unsigned int _stdcall test_wav(WAVEHEADER *hdr); unsigned int _stdcall test_wav(WAVEHEADER *hdr);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -5,23 +5,16 @@ include "proc32.inc"
section '.text' align 16 code readable executable section '.text' align 16 code readable executable
public _InitSound@0 public _InitSound@4
public _CreateBuffer@8 public _CreateBuffer@12
public _DestroyBuffer@4 public _DestroyBuffer@4
align 4 align 4
proc _InitSound@0 _InitSound@4: ;p_ver:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, 68 mov eax, 68
mov ebx, 16 mov ebx, 16
mov ecx, szInfinity mov ecx, szInfinity
@ -36,95 +29,80 @@ proc _InitSound@0
int 0x40 int 0x40
mov [hrdwSound], eax mov [hrdwSound], eax
mov eax, [hSound] lea eax, [esp+12] ;p_ver
xor ebx, ebx xor ebx, ebx
mov [handle], eax push 4 ;.out_size
mov [io_code], SRV_GETVERSION push eax ;.output
mov [input], ebx push ebx ;.inp_size
mov [inp_size], ebx push ebx ;.input
mov [output], ebx push SRV_GETVERSION ;.code
mov [out_size], ebx push [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp ;[handle]
int 0x40 int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
.fail: .fail:
or eax, -1
.done:
pop ecx pop ecx
pop ebx pop ebx
ret ret 4
endp
align 4 align 4
proc _CreateBuffer@8 stdcall, format:dword, size:dword _CreateBuffer@12: ;format:dword,size:dword,p_str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound] lea eax, [esp+20] ;p_str
lea ebx, [format] lea ebx, [esp+12] ;format
xor ecx, ecx
mov [handle], eax push 4 ;.out_size
mov [io_code], SND_CREATE_BUFF push eax ;.output
mov [input], ebx push 8 ;.inp_size
mov [inp_size], 4 push ebx ;.input
mov [output], ecx push SND_CREATE_BUFF;.code
mov [out_size], ecx push [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24 ;io_cintrol
pop ecx pop ecx
pop ebx pop ebx
ret ret 12
endp
align 4 align 4
proc _DestroyBuffer@4 stdcall, str:dword _DestroyBuffer@4: ;str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound] xor eax, eax
lea ebx, [str] lea ebx, [esp+12] ;[stream]
xor ecx, ecx
mov [handle], eax push eax ;.out_size
mov [io_code], SND_DESTROY_BUFF push eax ;.output
mov [input], ebx push 4 ;.inp_size
mov [inp_size], 4 push ebx ;.input
mov [output], ecx push SND_DESTROY_BUFF;.code
mov [out_size], ecx push [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp ;[handle]
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 4
endp
section '.data' align 16 data readable writable section '.data' align 16 data readable writable

View File

@ -11,67 +11,52 @@ public _SetBuffer@16
public _PlayBuffer@8 public _PlayBuffer@8
align 4 align 4
proc _SetBuffer@16 stdcall,str:dword, src:dword, offs:dword, size:dword _SetBuffer@16: ;str:dword, src:dword, offs:dword, size:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_SETBUFF lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 16 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 16 ;.inp_size
push ebx ;.input
push SND_SETBUFF ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 16
endp
align 4 align 4
proc _PlayBuffer@8 stdcall, str:dword,flags:dword _PlayBuffer@8: ;str:dword,flags:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_PLAY lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 8 ;.inp_size
push ebx ;.input
push SND_PLAY ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -7,37 +7,29 @@ section '.text' align 16 code readable executable
extrn hSound extrn hSound
public _GetFormat@4 public _GetFormat@8
align 4 align 4
proc _GetFormat@4 stdcall, str:dword _GetFormat@8: ;str:dword, p_fmt:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax lea eax, [esp+16] ;p_fmt
mov [io_code], SND_GETFORMAT lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push 4 ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push SND_GETFORMAT ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -5,39 +5,31 @@ include "proc32.inc"
section '.text' align 16 code readable executable section '.text' align 16 code readable executable
public _GetPan@4 public _GetPan@8
extrn hSound extrn hSound
align 4 align 4
proc _GetPan@4 stdcall, str:dword _GetPan@8: ;str:dword, p_pan:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax lea eax, [esp+16]
mov [io_code], SND_GETPAN lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push 4 ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push SND_GETPAN ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -7,37 +7,30 @@ section '.text' align 16 code readable executable
extrn hSound extrn hSound
public _GetBufferPos@4 public _GetBufferPos@8
align 4 align 4
proc _GetBufferPos@4 stdcall, str:dword _GetBufferPos@8: ;str:dword, p_pos:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax lea eax, [esp+16]
mov [io_code], SND_GETPOS lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push 4 ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push SND_GETPOS ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -5,39 +5,32 @@ include "proc32.inc"
section '.text' align 16 code readable executable section '.text' align 16 code readable executable
public _GetBufferSize@4 public _GetBufferSize@8
extrn hSound extrn hSound
align 4 align 4
proc _GetBufferSize@4 stdcall, str:dword _GetBufferSize@8: ;str:dword, p_size:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax lea eax, [esp+16]
mov [io_code], SND_GETBUFFSIZE lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push 4 ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push SND_GETBUFFSIZE;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -10,34 +10,25 @@ extrn hSound
public _WaveOut@12 public _WaveOut@12
align 4 align 4
proc _WaveOut@12 stdcall,str:dword, src:dword, size:dword _WaveOut@12: ;str:dword, src:dword, size:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_OUT lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 12 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 12 ;.inp_size
push ebx ;.input
push SND_OUT ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 12
endp

View File

@ -10,34 +10,27 @@ extrn hSound
public _ResetBuffer@8 public _ResetBuffer@8
align 4 align 4
proc _ResetBuffer@8 stdcall, str:dword, flags:dword _ResetBuffer@8: ;str:dword, flags:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_RESET lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 8 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 12 ;.inp_size
push ebx ;.input
push SND_RESET ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -10,34 +10,26 @@ extrn hSound
public _SetFormat@8 public _SetFormat@8
align 4 align 4
proc _SetFormat@8 stdcall, str:dword, fmt:dword _SetFormat@8: ;str:dword, fmt:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_SETFORMAT lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 8 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 8 ;.inp_size
push ebx ;.input
push SND_SETFORMAT ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -10,35 +10,27 @@ public _SetMasterVol@4
extrn hrdwSound extrn hrdwSound
align 4 align 4
proc _SetMasterVol@4 stdcall,vol:dword _SetMasterVol@4: ;vol:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hrdwSound]
lea ebx, [vol]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], DEV_SET_MASTERVOL lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push DEV_SET_MASTERVOL ;.code
push dword [hrdwSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 4
endp

View File

@ -10,34 +10,25 @@ public _SetPan@8
extrn hSound extrn hSound
align 4 align 4
proc _SetPan@8 stdcall, str:dword, pan:dword _SetPan@8: ;str:dword, pan:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_SETPAN lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 8 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 12 ;.inp_size
push ebx ;.input
push SND_SETPAN ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -10,34 +10,27 @@ extrn hSound
public _SetBufferPos@8 public _SetBufferPos@8
align 4 align 4
proc _SetBufferPos@8 stdcall, str:dword, offs:dword _SetBufferPos@8: ;str:dword, offs:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_SETPOS lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 8 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 8 ;.inp_size
push ebx ;.input
push SND_SETPOS ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 8
endp

View File

@ -10,35 +10,27 @@ public _SetVolume@12
extrn hSound extrn hSound
align 4 align 4
proc _SetVolume@12 stdcall, str:dword, lvol:dword,rvol:dword _SetVolume@12: ;str:dword, lvol:dword,rvol:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_SETVOLUME lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 12 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 12 ;.inp_size
push ebx ;.input
push SND_SETVOLUME ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 12
endp

View File

@ -10,34 +10,28 @@ extrn hSound
public _StopBuffer@4 public _StopBuffer@4
align 4 align 4
proc _StopBuffer@4 stdcall, str:dword _StopBuffer@4: ;str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx push ebx
push ecx push ecx
mov eax, [hSound]
lea ebx, [str]
xor ecx, ecx
mov [handle], eax xor eax, eax
mov [io_code], SND_STOP lea ebx, [esp+12] ;[stream]
mov [input], ebx
mov [inp_size], 4 push eax ;.out_size
mov [output], ecx push eax ;.output
mov [out_size], ecx push 4 ;.inp_size
push ebx ;.input
push SND_STOP ;.code
push dword [hSound] ;.handle
mov eax, 68 mov eax, 68
mov ebx, 17 mov ebx, 17
lea ecx, [handle] mov ecx, esp
int 0x40 int 0x40
add esp, 24
pop ecx pop ecx
pop ebx pop ebx
ret ret 4
endp

View File

@ -456,8 +456,6 @@ void I_UpdateSound( void )
// Mixing channel index. // Mixing channel index.
int chan; int chan;
int i; int i;
int flags;
int size = 0;
// Left and right channel // Left and right channel
// are in global mixbuffer, alternating. // are in global mixbuffer, alternating.
@ -481,15 +479,12 @@ void I_UpdateSound( void )
// Love thy L2 chache - made this a loop. // Love thy L2 chache - made this a loop.
// Now more channels could be set at compile time // Now more channels could be set at compile time
// as well. Thus loop those channels. // as well. Thus loop those channels.
// flags=0;
for ( chan = 0; chan < NUM_CHANNELS; chan++ ) for ( chan = 0; chan < NUM_CHANNELS; chan++ )
{ {
// Check channel, if active. // Check channel, if active.
if (channels[ chan ]) if (channels[ chan ])
{ {
// flags=1;
// Get the raw data from the channel. // Get the raw data from the channel.
sample = *channels[ chan ]; sample = *channels[ chan ];
// Add left and right part // Add left and right part
@ -535,22 +530,9 @@ void I_UpdateSound( void )
// Increment current pointers in mixbuffer. // Increment current pointers in mixbuffer.
leftout += step; leftout += step;
rightout += step; rightout += step;
// if (flags)
// size+=4;
} }
SetBuffer(hMixBuff,mixbuffer,mix_offset,mix_size); SetBuffer(hMixBuff,mixbuffer,mix_offset,mix_size);
// WaveOut(hMixBuff,(char*)&mixbuffer[0],4096);
// if(size)
// {
// WaveOut(hMixBuff,(char*)&mixbuffer[0],size);
// SetBufferPos(hMixBuff, 0);
// SetBuffer(hMixBuff,(char*)&mixbuffer[0],mix_offset,4096);
// PlayBuffer(hMixBuff, PCM_SYNC);
// };
} }

View File

@ -76,18 +76,18 @@ extern "C"
typedef unsigned int SNDBUF; typedef unsigned int SNDBUF;
int _stdcall InitSound(); int _stdcall InitSound(int *version);
SNDBUF _stdcall CreateBuffer(unsigned int format,int size); int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
int _stdcall DestroyBuffer(SNDBUF hBuff); int _stdcall DestroyBuffer(SNDBUF hBuff);
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff); int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset); int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
int _stdcall GetBufferPos(SNDBUF hBuff); int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
int _stdcall GetBufferSize(SNDBUF hBuff); int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
int _stdcall SetBuffer(SNDBUF hBuff,void* buff, int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
int offs, int size); int offs, int size);
@ -98,7 +98,7 @@ int _stdcall StopBuffer(SNDBUF hBuff);
int _stdcall SetVolume(SNDBUF hBuff, int left, int right); int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan); int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff, int pan); int _stdcall GetPan(SNDBUF hBuff, int *pan);
int _stdcall GetMasterVol(int* vol); int _stdcall GetMasterVol(int* vol);
int _stdcall SetMasterVol(int vol); int _stdcall SetMasterVol(int vol);

View File

@ -178,7 +178,6 @@ void S_Init
{ {
int i; int i;
char *thread_stack; char *thread_stack;
int ver;
numChannels = NUM_CHANNELS; numChannels = NUM_CHANNELS;
@ -243,21 +242,26 @@ extern signed short *mixbuffer;
void sound_proc(void) void sound_proc(void)
{ {
int ver; int ver;
int err;
SND_EVENT evnt; SND_EVENT evnt;
int i; int i;
if((ver = InitSound())< SOUND_VERSION ) if(err = InitSound(&ver))
{
printf("Error %x Sound service not installed\n\r", err);
_asm
{
mov eax, -1
int 0x40
};
}
if(ver< SOUND_VERSION)
{ {
printf("Sound service version mismatch\n\r"); printf("Sound service version mismatch\n\r");
printf("Installed version: %d, required version %d\n\r", printf("Installed version: %d, required version %d\n\r",
ver, SOUND_VERSION); ver, SOUND_VERSION);
};
hMixBuff=CreateBuffer(PCM_2_16_11|PCM_RING,0);
if(!hMixBuff)
{
printf("sound not available\n\r");
_asm _asm
{ {
mov eax, -1 mov eax, -1
@ -265,12 +269,43 @@ void sound_proc(void)
}; };
}; };
mix_size=GetBufferSize(hMixBuff)/2; if (err = CreateBuffer(PCM_2_16_11|PCM_RING,0, &hMixBuff))
{
printf("Error %x sound not available\n\r", err);
printf("handle = %x\n\r", hMixBuff);
_asm
{
mov eax, -1
int 0x40
};
}
if(err = GetBufferSize(hMixBuff, &mix_size))
{
printf("Error %x get buffer size\n\r", err);
printf("size = %x\n\r", mix_size);
_asm
{
mov eax, -1
int 0x40
};
};
mix_size= mix_size/2;
printf("mixer size %d\n\r", mix_size); printf("mixer size %d\n\r", mix_size);
if(err=PlayBuffer(hMixBuff, 0))
{
printf("Error %x play buffer\n\r", err);
_asm
{
mov eax, -1
int 0x40
};
}
mixbuffer = malloc(mix_size); mixbuffer = malloc(mix_size);
PlayBuffer(hMixBuff, 0);
while(sound_state) while(sound_state)
{ {
GetNotify(&evnt); GetNotify(&evnt);

View File

@ -10,10 +10,13 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97", "ac97\ac97.vcproj", "{1C94A897-DA4F-45B2-B8A6-B97AD837828E}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97", "ac97\ac97.vcproj", "{1C94A897-DA4F-45B2-B8A6-B97AD837828E}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{CF807B93-2860-41DF-A4D2-5B92B52DFD96} = {CF807B93-2860-41DF-A4D2-5B92B52DFD96} {CF807B93-2860-41DF-A4D2-5B92B52DFD96} = {CF807B93-2860-41DF-A4D2-5B92B52DFD96}
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1} = {C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg", "mpg\mpg.vcproj", "{CF807B93-2860-41DF-A4D2-5B92B52DFD96}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg", "mpg\mpg.vcproj", "{CF807B93-2860-41DF-A4D2-5B92B52DFD96}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sound", "sound\sound.vcproj", "{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -23,23 +26,21 @@ Global
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.ActiveCfg = Debug|Win32 {50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.ActiveCfg = Debug|Win32
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.Build.0 = Debug|Win32 {50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.Build.0 = Debug|Win32
{50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.ActiveCfg = Release|Win32 {50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.ActiveCfg = Release|Win32
{50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.Build.0 = Release|Win32
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.ActiveCfg = Debug|Win32 {97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.ActiveCfg = Debug|Win32
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.Build.0 = Debug|Win32
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.ActiveCfg = Release|Win32 {97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.ActiveCfg = Release|Win32
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.Build.0 = Release|Win32 {97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.Build.0 = Release|Win32
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Debug|Win32.ActiveCfg = Debug|Win32 {9FE40739-2ADC-4241-8182-20E1B3C661A7}.Debug|Win32.ActiveCfg = Debug|Win32
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Debug|Win32.Build.0 = Debug|Win32
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Release|Win32.ActiveCfg = Release|Win32 {9FE40739-2ADC-4241-8182-20E1B3C661A7}.Release|Win32.ActiveCfg = Release|Win32
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Release|Win32.Build.0 = Release|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.ActiveCfg = Debug|Win32 {1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.ActiveCfg = Debug|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.Build.0 = Debug|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.ActiveCfg = Release|Win32 {1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.ActiveCfg = Release|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.Build.0 = Release|Win32 {1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.Build.0 = Release|Win32
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Debug|Win32.ActiveCfg = Debug|Win32 {CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Debug|Win32.ActiveCfg = Debug|Win32
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Debug|Win32.Build.0 = Debug|Win32
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.ActiveCfg = Release|Win32 {CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.ActiveCfg = Release|Win32
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.Build.0 = Release|Win32 {CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.Build.0 = Release|Win32
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Debug|Win32.ActiveCfg = Debug|Win32
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Debug|Win32.Build.0 = Debug|Win32
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Release|Win32.ActiveCfg = Release|Win32
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -14,10 +14,10 @@
// GNU General Public License for more details. // GNU General Public License for more details.
#include "kolibri.h" #include "kolibri.h"
//#include "stdio.h"
#include "string.h" #include "string.h"
#include "ac97wav.h" #include "ac97wav.h"
#include "mpg/mpg123.h" #include "mpg/mpg123.h"
#include "sound.h"
#define MP3_ERROR_OUT_OF_BUFFER 5 #define MP3_ERROR_OUT_OF_BUFFER 5
int m_last_error; int m_last_error;
@ -29,37 +29,22 @@ int stream_read_raw(struct reader *rd,unsigned char *buf, int size);
char *fname; char *fname;
//extern char __path;
/***** for debug output only
char formats[37][12] =
{ "PCM_ALL",
"PCM_2_16_48","PCM_1_16_48","PCM_2_16_44","PCM_1_16_44",
"PCM_2_16_32","PCM_1_16_32","PCM_2_16_24","PCM_1_16_24",
"PCM_2_16_22","PCM_1_16_22","PCM_2_16_16","PCM_1_16_16",
"PCM_2_16_12","PCM_1_16_12","PCM_2_16_11","PCM_1_16_11",
"PCM_2_16_8","PCM_1_16_8","PCM_2_8_48","PCM_1_8_48",
"PCM_2_8_44","PCM_1_8_44","PCM_2_8_32","PCM_1_8_32",
"PCM_2_8_24","PCM_1_8_24","PCM_2_8_22","PCM_1_8_22",
"PCM_2_8_16","PCM_1_8_16","PCM_2_8_12","PCM_1_8_12",
"PCM_2_8_11","PCM_1_8_11","PCM_2_8_8","PCM_1_8_8"
};
*******/
//int freqs[9] = {44100,48000,32000,22050,24000,16000 ,11025 ,12000 ,8000};
struct reader rd; struct reader rd;
struct frame fr; struct frame fr;
DWORD hDrv; DWORD hDrv;
DWORD hSound; DWORD hSound;
DWORD hBuff; SNDBUF hBuff;
DWORD event[2];
CTRL_INFO info; CTRL_INFO info;
FILEINFO fileinfo; FILEINFO fileinfo;
int m_vol; int m_vol;
int l_vol=-500;
int r_vol=-500;
int pan =0;
DWORD status; DWORD status;
DWORD offset; DWORD offset;
DWORD first_sync; DWORD first_sync;
@ -75,8 +60,6 @@ int outremain;
int totalout; int totalout;
int done; int done;
char srv_name[] = "INFINITY";
char srv_intel[] = "SOUND";
char header[] = "AC97 MP3 player"; char header[] = "AC97 MP3 player";
char buttons_text[]=" Play Stop << >> Vol- Vol+"; char buttons_text[]=" Play Stop << >> Vol- Vol+";
@ -111,10 +94,10 @@ void draw_window()
void draw_progress_bar() void draw_progress_bar()
{ DWORD x; { DWORD x;
x = 286.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size; x = 287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size;
if(x==0) return; if(x==0) return;
draw_bar(7,41,x,11,0xA0A0A0); draw_bar(7,41,x,11,0xA0A0A0);
draw_bar(x+7,41,286-x,11,0x404040); draw_bar(x+7,41,287-x,11,0x404040);
}; };
void debug_out_str(char* str) void debug_out_str(char* str)
@ -131,6 +114,8 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
char *thread_stack; char *thread_stack;
DWORD r_bytes; DWORD r_bytes;
int retval; int retval;
int err;
int ver;
fname = argv[1]; fname = argv[1];
//debug_out_str(fname); //debug_out_str(fname);
@ -139,19 +124,18 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND)
return 0; return 0;
if((hDrv=GetService(srv_intel))==0)
if(err = InitSound(&ver))
{
debug_out_str("Sound service not installed\n\r");
return 0; return 0;
}
if ((hSound=GetService(srv_name))==0) if( ver != SOUND_VERSION)
{
debug_out_str("Sound service version mismatch\n\r");
return 0; return 0;
}
GetDevInfo(hDrv, &info);
m_vol = GetMasterVol(hDrv,&m_vol);
if (m_vol > 85)
{ m_vol = 85;
SetMasterVol(hDrv,m_vol);
};
testbuff = UserAlloc(4096); testbuff = UserAlloc(4096);
get_fileinfo(fname, &fileinfo); get_fileinfo(fname, &fileinfo);
@ -189,8 +173,13 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
status = ST_PLAY; status = ST_PLAY;
hBuff = CreateBuffer(hSound,fmt); if (err = CreateBuffer(fmt,0, &hBuff))
if (hBuff == 0) return 0; {
debug_out_str("create buffer return error\n\r");
return 0;
}
SetVolume(hBuff,l_vol,r_vol);
thread_stack = UserAlloc(4096); thread_stack = UserAlloc(4096);
thread_stack+=4092; thread_stack+=4092;
@ -204,13 +193,13 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
continue; continue;
case ST_STOP: case ST_STOP:
StopBuffer(hSound, hBuff); StopBuffer(hBuff);
status = ST_DONE; status = ST_DONE;
continue; continue;
case ST_EXIT: case ST_EXIT:
StopBuffer(hSound, hBuff); StopBuffer(hBuff);
DestroyBuffer(hSound, hBuff); DestroyBuffer(hBuff);
return 0; return 0;
}; };
}; };
@ -254,12 +243,6 @@ DWORD test_mp3(char *buf)
return test_wav(&whdr); return test_wav(&whdr);
}; };
void wave_out(char* buff)
{ DWORD ev[6];
GetNotify(&ev[0]);
SetBuffer(hSound,hBuff,buff,ev[1],0x8000);
}
void play_mp3() void play_mp3()
{ char *outPtr; { char *outPtr;
@ -277,11 +260,7 @@ void play_mp3()
outremain=0x40000; outremain=0x40000;
memset(outbuf,0,0x40000); memset(outbuf,0,0x40000);
set_reader(&rd, 0); //;first_sync); set_reader(&rd, 0); //;first_sync);
SetBuffer(hSound,hBuff,outbuf,0,0x8000);
SetBuffer(hSound,hBuff,outbuf,0x8000,0x8000);
PlayBuffer(hSound, hBuff);
while(1) while(1)
{ if(status!=ST_PLAY) { if(status!=ST_PLAY)
@ -302,12 +281,13 @@ void play_mp3()
}; };
if(done) if(done)
{ if(totalout < 32768) { if(totalout < 4096)
{ memset(outPtr,0,32768-totalout); { memset(outPtr,0,4096-totalout);
totalout = 32768; totalout = 4096;
}; };
}; }
if(totalout < 32768) else
if(totalout < 8192)
continue; continue;
/* /*
_asm _asm
@ -321,13 +301,22 @@ void play_mp3()
}; };
*/ */
outPtr = outbuf; outPtr = outbuf;
while (totalout > 32768) while (totalout >= 4096)
{ wave_out(outPtr); {
totalout-=0x8000;
outPtr+=0x8000; WaveOut(hBuff,outPtr,4096);
outremain+=0x8000; if(status!=ST_PLAY)
{ if(status != ST_EXIT)
status = ST_STOP;
return;
}; };
if(done) break; totalout-=4096;
outPtr+=4096;
outremain+=4096;
};
if(done)
break;
memmove(outbuf,outPtr, totalout); memmove(outbuf,outPtr, totalout);
outPtr = outbuf+totalout; outPtr = outbuf+totalout;
} }
@ -337,23 +326,9 @@ void play_mp3()
}; };
void play_wave() void play_wave()
{ DWORD ev[6]; { int retval;
int retval;
int remain;
int i;
// offset = 44;
// read_file (fname,outbuf,offset,32*1024,0);
// offset+=32*1024;
set_reader(&rd,44); set_reader(&rd,44);
stream_read_raw(&rd,outbuf,32768);
SetBuffer(hSound,hBuff,outbuf,0,0x8000);
stream_read_raw(&rd,outbuf,32768);
SetBuffer(hSound,hBuff,outbuf,0x8000,0x8000);
PlayBuffer(hSound, hBuff);
retval = 0; retval = 0;
while(1) while(1)
{ {
@ -364,7 +339,7 @@ void play_wave()
{ done = 1; { done = 1;
break; break;
}; };
wave_out(outbuf); WaveOut(hBuff,outbuf,32768);
}; };
if(status != ST_EXIT) if(status != ST_EXIT)
@ -373,7 +348,7 @@ void play_wave()
void snd_stop() void snd_stop()
{ {
StopBuffer(hSound, hBuff); StopBuffer(hBuff);
}; };
void thread_proc() void thread_proc()
@ -381,8 +356,13 @@ void thread_proc()
int pos; int pos;
int key; int key;
_asm { fninit }; _asm
{
mov eax, 66
mov ebx, 1
mov ecx, 1
int 0x40
};
draw_window(); draw_window();
@ -390,7 +370,6 @@ void thread_proc()
{ if(status==ST_PLAY) { if(status==ST_PLAY)
{ draw_progress_bar(); { draw_progress_bar();
evnt = wait_for_event(80); evnt = wait_for_event(80);
// debug_out_str("BIG ERROR...\x0D\x0A\x00");
} }
else else
evnt = wait_for_event_infinite(); evnt = wait_for_event_infinite();
@ -402,22 +381,48 @@ void thread_proc()
break; break;
case EV_KEY: case EV_KEY:
key = get_key(); if(!get_key(&key))
if(key==27) {
{ status = ST_EXIT;
switch(key)
{ case 0xE0:
case 0xE1:
break;
default:
switch (key)
{
case 0x01: //Esc
status = ST_EXIT;
exit(); exit();
}; break;
if((key==45)||key==54)
{ if(m_vol > 0) case 0x47: //Home
{ m_vol--; if(l_vol < 0)
SetMasterVol(hDrv,m_vol); { l_vol+=100;
r_vol+=100;
SetVolume(hBuff,l_vol,r_vol);
}; };
break; break;
case 0x4F: //End
if(l_vol > -10000)
{ l_vol-=100;
r_vol-=100;
SetVolume(hBuff,l_vol,r_vol);
}; };
if((key==61)||key==56) break;
{ if(m_vol < 90) case 0x53:
{ m_vol++; if(pan > -10000)
SetMasterVol(hDrv,m_vol); { pan -=100;
SetPan(hBuff,pan);
};
break;
case 0x51:
if(pan < 10000)
{ pan +=100;
SetPan(hBuff,pan);
};
break;
}
}; };
}; };
break; break;
@ -439,24 +444,25 @@ void thread_proc()
// case 0x12: // case 0x12:
// case 0x13: // case 0x13:
case 0x14: case 0x14:
if(m_vol > 0) if(l_vol > -10000)
{ m_vol--; {
SetMasterVol(hDrv,m_vol); l_vol-=100;
r_vol-=100;
SetVolume(hBuff,l_vol,r_vol);
}; };
break; break;
case 0x15: case 0x15:
if(m_vol < 90) if(l_vol < 0)
{ m_vol++; { l_vol+=100;
SetMasterVol(hDrv,m_vol); r_vol+=100;
SetVolume(hBuff,l_vol,r_vol);
}; };
break; break;
case 0x30: case 0x30:
if(status==ST_DONE) if(status==ST_DONE)
break; break;
// if(snd_play == play_mp3)
// continue;
pos = (GetMousePos(REL_WINDOW)>>16)-7; pos = (GetMousePos(REL_WINDOW)>>16)-7;
offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC;
set_reader(&rd, offset); set_reader(&rd, offset);
@ -467,157 +473,6 @@ void thread_proc()
}; };
}; };
DWORD test_wav(WAVEHEADER *hdr)
{
if(hdr->riff_id != 0x46464952)
return 0;
if(hdr->riff_format != 0x45564157)
return 0;
if (hdr->wFormatTag != 0x01)
return 0;
switch(hdr->nSamplesPerSec)
{ case 48000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_48;
else
return PCM_1_8_48;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_48;
else
return PCM_2_8_48;
};
case 44100:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_44;
else
return PCM_1_8_44;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_44;
else
return PCM_2_8_44;
};
case 32000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_32;
else
return PCM_1_8_32;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_32;
else
return PCM_2_8_32;
};
case 24000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_24;
else
return PCM_1_8_24;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_24;
else
return PCM_2_8_24;
};
case 22050:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_22;
else
return PCM_1_8_22;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_22;
else
return PCM_2_8_22;
};
case 16000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_16;
else
return PCM_1_8_16;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_16;
else
return PCM_2_8_16;
};
case 12000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_12;
else
return PCM_1_8_12;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_12;
else
return PCM_2_8_12;
};
case 11025:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_11;
else
return PCM_1_8_11;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_11;
else
return PCM_2_8_11;
};
case 8000:
switch (hdr->nChannels)
{ case 1:
if(hdr->wBitsPerSample == 16)
return PCM_1_16_8;
else
return PCM_1_8_8;
case 2:
if(hdr->wBitsPerSample == 16)
return PCM_2_16_8;
else
return PCM_2_8_8;
};
default:
return 0;
};
};
void delay (int val) void delay (int val)
{ {
_asm _asm
@ -639,8 +494,7 @@ int wait_for_event(int time)
}; };
int wait_for_event_infinite() int wait_for_event_infinite()
{ void *a; { int retval;
int retval;
_asm _asm
{ mov eax,10 { mov eax,10
int 0x40 int 0x40

View File

@ -14,43 +14,6 @@
// GNU General Public License for more details. // GNU General Public License for more details.
#define PCM_2_16_48 1
#define PCM_1_16_48 2
#define PCM_2_16_44 3
#define PCM_1_16_44 4
#define PCM_2_16_32 5
#define PCM_1_16_32 6
#define PCM_2_16_24 7
#define PCM_1_16_24 8
#define PCM_2_16_22 9
#define PCM_1_16_22 10
#define PCM_2_16_16 11
#define PCM_1_16_16 12
#define PCM_2_16_12 13
#define PCM_1_16_12 14
#define PCM_2_16_11 15
#define PCM_1_16_11 16
#define PCM_2_16_8 17
#define PCM_1_16_8 18
#define PCM_2_8_48 19
#define PCM_1_8_48 20
#define PCM_2_8_44 21
#define PCM_1_8_44 22
#define PCM_2_8_32 23
#define PCM_1_8_32 24
#define PCM_2_8_24 25
#define PCM_1_8_24 26
#define PCM_2_8_22 27
#define PCM_1_8_22 28
#define PCM_2_8_16 29
#define PCM_1_8_16 30
#define PCM_2_8_12 31
#define PCM_1_8_12 32
#define PCM_2_8_11 33
#define PCM_1_8_11 34
#define PCM_2_8_8 35
#define PCM_1_8_8 36
#define ST_DONE 0x0 #define ST_DONE 0x0
#define ST_PLAY 0x1 #define ST_PLAY 0x1
#define ST_EXIT 0x2 #define ST_EXIT 0x2
@ -74,7 +37,6 @@ typedef struct
DWORD data_size; DWORD data_size;
} WAVEHEADER; } WAVEHEADER;
DWORD test_wav(WAVEHEADER *hdr);
DWORD test_mp3(char *buf); DWORD test_mp3(char *buf);
//void (*snd_play)(); //void (*snd_play)();

View File

@ -4,24 +4,13 @@ include "proc32.inc"
section '.text' code readable executable section '.text' code readable executable
public _GetService@4
public _GetDevInfo@8
public _GetMasterVol@8
public _SetMasterVol@8
public _CreateBuffer@8
public _DestroyBuffer@8
public _SetBuffer@20
public _PlayBuffer@8
public _StopBuffer@8
public _InitHeap@4 public _InitHeap@4
public _UserAlloc@4 public _UserAlloc@4
public _GetNotify@4
public _CreateThread@8 public _CreateThread@8
public _GetMousePos@4 public _GetMousePos@4
public _get_fileinfo@8 public _get_fileinfo@8
public _read_file@20 public _read_file@20
public _get_key public _get_key@4
public _get_button_id public _get_button_id
public _DrawWindow@36 public _DrawWindow@36
public _make_button@24 public _make_button@24
@ -42,34 +31,6 @@ struc FILEIO
.name dd ? .name dd ?
}; };
struc CTRL_INFO
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
}
CTRL_INFO_SIZE equ 9*4
SND_CREATE_DEV equ 1
SND_CREATE_BUFF equ 2
SND_PLAY equ 3
SND_STOP equ 4
SND_SETBUFF equ 5
SND_DESTROY_BUFF equ 6
DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8
align 4 align 4
proc _get_button_id proc _get_button_id
mov eax,17 mov eax,17
@ -145,13 +106,22 @@ proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\
endp endp
align 4 align 4
proc _get_key proc _get_key@4 stdcall, key:dword
push ebx
push ecx
mov eax, 2 mov eax, 2
int 0x40 int 0x40
shr eax, 8 mov ebx, [key]
mov ecx, eax
shr ecx, 8
mov [ebx], ecx
movzx eax, al
pop ecx
pop ebx
ret ret
endp endp
align 4 align 4
proc _InitHeap@4 stdcall, heap_size:dword proc _InitHeap@4 stdcall, heap_size:dword
push ebx push ebx
@ -174,28 +144,6 @@ proc _UserAlloc@4 stdcall, alloc_size:dword
ret ret
endp endp
;align 4
;proc _GetNotify@4 stdcall, p_ev:dword
; push ebx
; mov eax, 68
; mov ebx, 14
; mov ecx, [p_ev]
; int 0x40
; pop ebx
; ret
;endp
align 4
proc _GetNotify@4 stdcall, p_ev:dword
push ebx
mov eax, 68
mov ebx, 14
mov ecx, [p_ev]
int 0x40
pop ebx
ret
endp
align 4 align 4
proc _CreateThread@8 stdcall, fn:dword, p_stack:dword proc _CreateThread@8 stdcall, fn:dword, p_stack:dword
push ebx push ebx
@ -218,258 +166,6 @@ proc _GetMousePos@4 stdcall,rel_type:dword
ret ret
endp endp
align 4
proc CallServiceEx stdcall, ioctl:dword
push ebx
mov eax, 68
mov ebx, 17
mov ecx, [ioctl]
int 0x40
pop ebx
ret
endp
align 4
proc _GetService@4 stdcall, name:dword
push ebx
mov eax, 68
mov ebx, 16
mov ecx, [name]
int 0x40
pop ebx
ret
endp
align 4
proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSrv]
xor ebx, ebx
mov ecx, [p_info]
mov [handle], eax
mov [io_code], DEV_GET_INFO
mov [input], ebx
mov [inp_size], ebx
mov [output], ecx
mov [out_size], CTRL_INFO_SIZE
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _GetMasterVol@8 stdcall, hSrv:dword,pvol:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSrv]
mov ecx, [pvol]
xor ebx, ebx
mov [handle], eax
mov [io_code], DEV_GET_MASTERVOL
mov [input], ebx
mov [inp_size], ebx
mov [output], ecx
mov [out_size], 4
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _SetMasterVol@8 stdcall,hSrv:dword,vol:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSrv]
lea ecx, [vol]
xor ebx, ebx
mov [handle], eax
mov [io_code], DEV_SET_MASTERVOL
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _CreateBuffer@8 stdcall, hSound:dword,format:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSound]
lea ecx, [format]
xor ebx, ebx
mov [handle], eax
mov [io_code], SND_CREATE_BUFF
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _DestroyBuffer@8 stdcall, hSound:dword, str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSound]
lea ecx, [str]
xor ebx, ebx
mov [handle], eax
mov [io_code], SND_DESTROY_BUFF
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _SetBuffer@20 stdcall,hSound:dword, str:dword, src:dword, offs:dword, size:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSound]
lea ecx, [str]
xor ebx, ebx
mov [handle], eax
mov [io_code], SND_SETBUFF
mov [input], ecx
mov [inp_size], 16
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _PlayBuffer@8 stdcall, hSound:dword, str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSound]
lea ecx, [str]
xor ebx, ebx
mov [handle], eax
mov [io_code], SND_PLAY
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4
proc _StopBuffer@8 stdcall, hSound:dword, str:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSound]
lea ecx, [str]
xor ebx, ebx
mov [handle], eax
mov [io_code], SND_STOP
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], 0
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
align 4 align 4
proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\ proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\

View File

@ -1,17 +1,8 @@
//
// This file is part of the AC97 mp3 player. #ifdef __cplusplus
// (C) copyright Serge 2006 extern "C"
// email: infinity_sound@mail.ru {
// #endif
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#define FONT0 0x00000000 #define FONT0 0x00000000
#define FONT1 0x10000000 #define FONT1 0x10000000
@ -31,9 +22,9 @@
#define FILE_NOT_FOUND 5 #define FILE_NOT_FOUND 5
#define FILE_EOF 6 #define FILE_EOF 6
typedef unsigned int DWORD; typedef unsigned int DWORD;
typedef unsigned short int WORD; typedef unsigned short int WORD;
typedef unsigned int size_t;
typedef struct typedef struct
{ DWORD pci_cmd; { DWORD pci_cmd;
@ -70,22 +61,11 @@ typedef struct
DWORD size_high; DWORD size_high;
} FILEINFO; } FILEINFO;
void _stdcall InitHeap(int heap_size); void _stdcall InitHeap(size_t heap_size);
void* _stdcall UserAlloc(int size); void* _stdcall UserAlloc(size_t size);
void _stdcall GetNotify(DWORD *event);
void _stdcall CreateThread(void *fn, char *p_stack); void _stdcall CreateThread(void *fn, char *p_stack);
DWORD _stdcall GetMousePos(DWORD rel_type); DWORD _stdcall GetMousePos(DWORD rel_type);
int _stdcall GetService(char *srv_name);
void _stdcall GetDevInfo(DWORD hSrv,CTRL_INFO *pInfo);
int _stdcall GetMasterVol(DWORD hSrv,int* vol);
int _stdcall SetMasterVol(DWORD hSrv, int vol);
DWORD _stdcall CreateBuffer(DWORD hSrv, DWORD format);
int _stdcall DestroyBuffer(DWORD hSrv, DWORD hBuff);
int _stdcall SetBuffer(DWORD hSrv, DWORD hBuff,char* buff,
DWORD offs, int size);
int _stdcall PlayBuffer(DWORD hSrv, DWORD hBuff);
int _stdcall StopBuffer(DWORD hSrv, DWORD hBuff);
void _stdcall debug_out_hex(DWORD val); void _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str); void debug_out_str(char* str);
@ -94,7 +74,7 @@ int _stdcall get_fileinfo(char *name,FILEINFO* pinfo);
int _stdcall read_file (char *name,char*buff,int offset,int count,int *reads); int _stdcall read_file (char *name,char*buff,int offset,int count,int *reads);
void exit(); void exit();
int _cdecl get_key(void); int _stdcall get_key(int *key);
int _cdecl get_button_id(); int _cdecl get_button_id();
void delay(int val); void delay(int val);
int wait_for_event(int time); int wait_for_event(int time);
@ -108,3 +88,7 @@ void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color)
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color); void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color);
void _stdcall write_text(int x,int y,int color,char* text,int len); void _stdcall write_text(int x,int y,int color,char* text,int len);
#ifdef __cplusplus
extern "C"
}
#endif