ac97snd update

git-svn-id: svn://kolibrios.org@570 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-07-07 23:41:14 +00:00
parent 390d9aa3a7
commit 184e090541
6 changed files with 271 additions and 106 deletions

View File

@ -5,8 +5,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pe2kos", "pe2kos\pe2kos.vcp
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp3dec", "mp3dec\mp3dec.vcproj", "{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pow_test", "pow_test\pow_test.vcproj", "{9FE40739-2ADC-4241-8182-20E1B3C661A7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97", "ac97\ac97.vcproj", "{1C94A897-DA4F-45B2-B8A6-B97AD837828E}"
ProjectSection(ProjectDependencies) = postProject
{CF807B93-2860-41DF-A4D2-5B92B52DFD96} = {CF807B93-2860-41DF-A4D2-5B92B52DFD96}
@ -29,8 +27,6 @@ Global
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.ActiveCfg = Debug|Win32
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.ActiveCfg = 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}.Release|Win32.ActiveCfg = Release|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.ActiveCfg = Debug|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.ActiveCfg = Release|Win32
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.Build.0 = Release|Win32

View File

@ -22,7 +22,10 @@
#define MP3_ERROR_OUT_OF_BUFFER 5
int m_last_error;
void thread_proc();
void _stdcall thread_proc(void *param);
void _stdcall create_thread(void *proc, void *param, int stack_size);
void _stdcall send_ipc(int dst, DWORD code);
void touch(char *buf, int size);
int mp3FindSync(byte* buf, int size, int* sync);
int stream_read_raw(struct reader *rd,unsigned char *buf, int size);
@ -41,8 +44,8 @@ CTRL_INFO info;
FILEINFO fileinfo;
int m_vol;
int l_vol=-500;
int r_vol=-500;
int l_vol=-700; //-7db
int r_vol=-700;
int pan =0;
DWORD status;
@ -110,20 +113,23 @@ void debug_out_str(char* str)
}
int main(int argc, char *argv[]) //int argc, char *argv[])
{ DWORD fmt;
char *thread_stack;
{
DWORD fmt;
DWORD r_bytes;
int retval;
int err;
int ver;
fname = argv[1];
//debug_out_str(fname);
debug_out_str("\n\rPlay file ");
debug_out_str(fname);
debug_out_str("\n\r");
InitHeap(1024*1024);
if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND)
{ debug_out_str("\n\rfile not found\n\r");
return 0;
};
if(err = InitSound(&ver))
{
@ -131,7 +137,8 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
return 0;
}
if( ver != SOUND_VERSION)
if( (SOUND_VERSION>(ver&0xFFFF)) ||
(SOUND_VERSION<(ver >> 16)))
{
debug_out_str("Sound service version mismatch\n\r");
return 0;
@ -176,14 +183,13 @@ int main(int argc, char *argv[]) //int argc, char *argv[])
if (err = CreateBuffer(fmt,0, &hBuff))
{
debug_out_str("create buffer return error\n\r");
return 0;
; return 0;
}
SetVolume(hBuff,l_vol,r_vol);
thread_stack = UserAlloc(4096);
thread_stack+=4092;
GetVolume(hBuff,&l_vol,&r_vol);
CreateThread(thread_proc, thread_stack);
create_thread(thread_proc, 0, 4096);
while(1)
{ delay(10);
@ -289,17 +295,6 @@ void play_mp3()
else
if(totalout < 8192)
continue;
/*
_asm
{ push edx
push eax
mov eax, 0xFF
mov edx, 0x400
out dx, al
pop eax
pop edx
};
*/
outPtr = outbuf;
while (totalout >= 4096)
{
@ -351,7 +346,7 @@ void snd_stop()
StopBuffer(hBuff);
};
void thread_proc()
void _stdcall thread_proc(void *param)
{ int evnt;
int pos;
int key;

View File

@ -14,28 +14,11 @@
// GNU General Public License for more details.
#define ST_DONE 0x0
#define ST_PLAY 0x1
#define ST_EXIT 0x2
#define ST_STOP 0x4
#define ST_DONE 0x0
#define ST_PLAY 0x1
#define ST_EXIT 0x2
#define ST_STOP 0x4
typedef struct
{ DWORD riff_id;
DWORD riff_size;
DWORD riff_format;
DWORD fmt_id;
DWORD fmt_size;
WORD wFormatTag;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
WORD nBlockAlign;
WORD wBitsPerSample;
DWORD data_id;
DWORD data_size;
} WAVEHEADER;
DWORD test_mp3(char *buf);

View File

@ -18,6 +18,8 @@ public _draw_bar@20
public _write_text@20
public _debug_out@4
public _debug_out_hex@4
public _create_thread@12
public _memset
@ -31,6 +33,49 @@ struc FILEIO
.name dd ?
};
align 4
_create_thread@12:
.thr_proc equ esp+4
.param equ esp+8
.stack_size equ esp+12
mov eax, 68
mov ebx, 12
mov ecx, [.stack_size]
add ecx, 4095
and ecx, -4096
int 0x40
test eax, eax
jz .fail
lea edx, [eax+ecx-12]
mov [edx], dword .exit_point
mov ebx, [.param]
mov [edx+4], ebx
mov [edx+8], ecx
mov eax, 51
mov ebx, 1
mov ecx, [.thr_proc]
int 0x40
ret 12
.fail:
not eax
ret 12
align 4
.exit_point:
pop ecx
mov eax, 68
mov ebx, 13
int 0x40
mov eax, -1
int 0x40
restore .thr_proc
restore .param
restore .stack_size
align 4
proc _get_button_id
mov eax,17

View File

@ -4,6 +4,7 @@ extern "C"
{
#endif
#define FONT0 0x00000000
#define FONT1 0x10000000
@ -15,6 +16,7 @@ extern "C"
#define EV_REDRAW 1
#define EV_KEY 2
#define EV_BUTTON 3
#define EV_IPC 7
#define REL_SCREEN 0
#define REL_WINDOW 1
@ -22,9 +24,9 @@ extern "C"
#define FILE_NOT_FOUND 5
#define FILE_EOF 6
typedef unsigned int DWORD;
typedef unsigned short int WORD;
typedef unsigned int size_t;
typedef struct
{ DWORD pci_cmd;
@ -61,26 +63,37 @@ typedef struct
DWORD size_high;
} FILEINFO;
void _stdcall InitHeap(size_t heap_size);
void* _stdcall UserAlloc(size_t size);
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(void *event);
void _stdcall CreateThread(void *fn, char *p_stack);
DWORD _stdcall GetMousePos(DWORD rel_type);
void _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str);
int _stdcall get_fileinfo(char *name,FILEINFO* pinfo);
int _stdcall read_file (char *name,char*buff,int offset,int count,int *reads);
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall create_file(const char *name);
int _stdcall read_file (const char *name,char*buff,DWORD offset, DWORD count,DWORD *reads);
int _stdcall write_file(const char *name,char*buff,int offset,int count,int *writes);
void exit();
//void exit();
int _stdcall get_key(int *key);
int _stdcall remap_key(int key);
int _cdecl get_button_id();
void delay(int val);
int wait_for_event(int time);
int wait_for_event_infinite();
void BeginDraw(void);
void EndDraw(void);
void _stdcall GetScreenSize(int *x, int*y);
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
int captioncolor,int windowtype,int bordercolor);
void _stdcall debug_out(int ch);

View File

@ -0,0 +1,133 @@
#ifndef _SOUND_H_
#define _SOUND_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define SOUND_VERSION 0x0100
#define PCM_ALL 0
#define PCM_OUT 0x08000000
#define PCM_RING 0x10000000
#define PCM_STATIC 0x20000000
#define PCM_FLOAT 0x40000000
#define PCM_FILTER 0x80000000
#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 SRV_GETVERSION 0
#define SND_CREATE_BUFF 1
#define SND_DESTROY_BUFF 2
#define SND_SETFORMAT 3
#define SND_GETFORMAT 4
#define SND_RESET 5
#define SND_SETPOS 6
#define SND_GETPOS 7
#define SND_SETBUFF 8
#define SND_OUT 9
#define SND_PLAY 10
#define SND_STOP 11
#define SND_SETVOLUME 12
#define SND_GETVOLUME 13
#define SND_SETPAN 14
#define SND_GETPAN 15
#define SND_GETBUFFSIZE 16
#define PLAY_SYNC 0x80000000
typedef unsigned int SNDBUF;
int _stdcall InitSound(int *version);
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
int _stdcall DestroyBuffer(SNDBUF hBuff);
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
int offs, int size);
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
int _stdcall StopBuffer(SNDBUF hBuff);
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff, int *pan);
int _stdcall GetMasterVol(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);
#ifdef __cplusplus
extern "C"
}
#endif
#endif //_SOUND_H_