/programs/media/ac97snd/ac97snd/ac97snd.vcproj |
---|
14,7 → 14,7 |
</Platforms> |
<ToolFiles> |
<ToolFile |
RelativePath="../fasm.rules" |
RelativePath="..\..\..\VStudio 8\Common7\IDE\fasm.rules" |
/> |
</ToolFiles> |
<Configurations> |
141,7 → 141,8 |
<Tool |
Name="VCCLCompilerTool" |
Optimization="2" |
EnableIntrinsicFunctions="true" |
InlineFunctionExpansion="0" |
EnableIntrinsicFunctions="false" |
FavorSizeOrSpeed="1" |
OmitFramePointers="true" |
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" |
166,7 → 167,7 |
/> |
<Tool |
Name="VCLinkerTool" |
AdditionalDependencies="$(OutDir)\sound.lib $(OutDir)\mpg.lib" |
AdditionalDependencies="$(OutDir)\sound.lib $(OutDir)\mpg.lib $(OutDir)\ufmod.obj" |
LinkIncremental="1" |
GenerateManifest="false" |
IgnoreAllDefaultLibraries="true" |
221,6 → 222,17 |
<File |
RelativePath=".\ac97wav.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="2" |
InlineFunctionExpansion="0" |
EnableIntrinsicFunctions="true" |
FavorSizeOrSpeed="1" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\crt.c" |
/programs/media/ac97snd/ac97snd/ac97wav.c |
---|
18,8 → 18,9 |
#include "ac97wav.h" |
#include "../mpg/mpg123.h" |
#include "../sound.h" |
#include "../ufmod-codec.h" /* uFMOD integration */ |
void exit(); /* uFMOD integration */ |
#define MP3_ERROR_OUT_OF_BUFFER 5 |
int m_last_error; |
31,6 → 32,9 |
int mp3FindSync(byte* buf, int size, int* sync); |
int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
int __cdecl _stricmp (const char * dst, const char * src); |
char *__cdecl strrchr (const char * string,int ch); |
char *fname; |
struct reader rd; |
43,6 → 47,8 |
CTRL_INFO info; |
FILEINFO fileinfo; |
const char *filename; |
const char *fileext; |
int m_vol; |
int l_vol=-700; //-7db |
64,12 → 70,16 |
int done; |
char header[] = "AC97 MP3 player"; |
char buttons_text[]=" Play Stop << >> Vol- Vol+"; |
char buttons_xm[] = " Play Stop Vol- Vol+"; /* uFMOD integration */ |
char buttons_wav[] = " Play Stop << >> Vol- Vol+"; /* uFMOD integration */ |
char *buttons_text = buttons_wav; /* uFMOD integration */ |
void play_xm(); /* uFMOD integration */ |
void (*snd_play)(); |
void draw_window() |
{ |
int len; /* uFMOD integration */ |
BeginDraw(); |
DrawWindow(100,100,299,72,0x404040,3,0,0,0); |
85,12 → 95,13 |
draw_bar(7,41,286,11,0x404040); |
draw_bar(7,55,286,11,0x404040); |
write_text(12,58,0x004000|FONT0, fname, strlen(fname)); |
write_text(11,57,0x00FF20|FONT0, fname, strlen(fname)); |
len = strlen(filename); /* uFMOD integration */ |
if(len > 47) len = 47; /* uFMOD integration */ |
write_text(11,57,0x00FF20|FONT0, filename, len); /* uFMOD integration */ |
write_text(8,8,0xFFFFFF|FONT0, header, strlen(header)); |
write_text(12,28,0x404040|FONT0,buttons_text,strlen(buttons_text)); |
write_text(11,27,0xA0FFA0|FONT0,buttons_text,strlen(buttons_text)); |
write_text(8,8,FONT0, header, sizeof(header)-1); /* uFMOD integration */ |
write_text(12,28,0x404040|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
write_text(11,27,0xA0FFA0|FONT0,buttons_text,sizeof(buttons_wav)-1); /* uFMOD integration */ |
EndDraw(); |
}; |
97,7 → 108,7 |
void draw_progress_bar() |
{ DWORD x; |
x = 287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size; |
x = (DWORD)(287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size); /* uFMOD integration */ |
if(x==0) return; |
draw_bar(7,41,x,11,0xA0A0A0); |
draw_bar(x+7,41,287-x,11,0x404040); |
119,6 → 130,7 |
int retval; |
int err; |
int ver; |
unsigned char *ttl, *cur; /* uFMOD integration */ |
fname = argv[1]; |
debug_out_str("\n\rPlay file "); |
158,19 → 170,19 |
create_reader(&rd, inpbuf, 0x10000); |
init_reader(&rd,fname); |
fmt = test_wav((WAVEHEADER*)testbuff); |
if (fmt != 0) |
filename = strrchr(fname,'/')+1; |
if( !(fileext = strrchr(filename,'.'))) |
return 0; |
if(!_stricmp(fileext,".mp3")) |
{ |
snd_play = &play_wave; |
set_reader(&rd, 44); |
outbuf = UserAlloc(32*1024); |
touch(outbuf, 32768); |
} |
else |
{ fmt = test_mp3(testbuff); |
if(fmt ==0) return 0; |
fmt = test_mp3(testbuff); |
if(!fmt) |
{ |
debug_out_str("\n\rInvalid MP3 file"); |
return 0; |
}; |
snd_play = &play_mp3; |
outremain = 0x40000 ; |
outbuf = UserAlloc(outremain); |
touch(outbuf, outremain); |
178,8 → 190,54 |
init_layer2(); |
init_layer3(32); |
fr.single = -1; |
goto play; |
}; |
if(!_stricmp(fileext,".xm")) |
{ |
if(uFMOD_LoadSong(fname)) |
{ |
buttons_text = buttons_xm; /* uFMOD integration */ |
fmt = PCM_2_16_48; /* uFMOD integration */ |
snd_play = &play_xm; /* uFMOD integration */ |
ttl = uFMOD_GetTitle(); /* uFMOD integration */ |
cur = ttl; /* uFMOD integration */ |
err = 0; /* uFMOD integration */ |
while(*cur && *cur++ != ' ') err++; /* uFMOD integration */ |
if(err){ /* uFMOD integration */ |
cur = fname; /* uFMOD integration */ |
while(*cur) cur++; /* uFMOD integration */ |
*cur++ = ' '; /* uFMOD integration */ |
*cur++ = '|'; /* uFMOD integration */ |
*cur++ = ' '; /* uFMOD integration */ |
while(*ttl) *cur++ = *ttl++; /* uFMOD integration */ |
} |
goto play; |
} |
debug_out_str("\n\rInvalid XM file"); |
return 0; |
}; |
if(!_stricmp(fileext, ".wav")) |
{ |
fmt = test_wav((WAVEHEADER*)testbuff); |
if(fmt) |
{ |
snd_play = &play_wave; |
set_reader(&rd, 44); |
outbuf = UserAlloc(32*1024); |
touch(outbuf, 32768); |
goto play; |
} |
debug_out_str("\n\rInvalid WAV file"); |
return 0; |
}; |
debug_out_str("\n\rUsupported file"); |
return 0; |
play: |
status = ST_PLAY; |
if (err = CreateBuffer(fmt,0, &hBuff)) |
206,6 → 264,7 |
continue; |
case ST_EXIT: |
uFMOD_StopSong(); /* uFMOD integration */ |
StopBuffer(hBuff); |
DestroyBuffer(hBuff); |
return 0; |
217,7 → 276,7 |
void touch(char *buf, int size) |
{ int i; |
char a; |
for ( i = 0;i < size; i+=4096) |
for ( i = 0;i < size; i+=4096) //alloc all pages |
a = buf[i]; |
}; |
231,7 → 290,14 |
if(!rd.head_read(&rd,&hdr)) |
return 0; |
if(!decode_header(&fr,hdr)) |
{ rd.strpos-=3; |
{ |
if((hdr & 0xffffff00) == 0x49443300) |
{ |
int id3length = 0; |
id3length = parse_new_id3(&rd, hdr); |
continue; |
}; |
rd.strpos-=3; |
rd.stream-=3; |
rd.strremain+=3; |
continue; |
245,7 → 311,7 |
whdr.riff_format = 0x45564157; |
whdr.wFormatTag = 0x01; |
whdr.nSamplesPerSec = freqs[fr.sampling_frequency]; |
whdr.nChannels = 2; //mpginfo.channels; |
whdr.nChannels = 2; |
whdr.wBitsPerSample = 16; |
return test_wav(&whdr); |
324,26 → 390,35 |
}; |
void play_wave() |
{ int retval; |
{ int count; |
set_reader(&rd,44); |
retval = 0; |
while(1) |
{ |
if(status!=ST_PLAY) |
break; |
if( !stream_read_raw(&rd,outbuf,32768)) |
{ done = 1; |
if( count=stream_read_raw(&rd,outbuf,32768)) |
{ |
WaveOut(hBuff,outbuf,count); |
continue; |
} |
done = 1; |
break; |
}; |
WaveOut(hBuff,outbuf,32768); |
}; |
if(status != ST_EXIT) |
status = ST_STOP; |
}; |
void play_xm(){ /* uFMOD integration */ |
while(status == ST_PLAY){ /* uFMOD integration */ |
uFMOD_WaveOut(hBuff); /* uFMOD integration */ |
delay(8); /* uFMOD integration */ |
} /* uFMOD integration */ |
if(status != ST_EXIT) status = ST_STOP; /* uFMOD integration */ |
} /* uFMOD integration */ |
void snd_stop() |
{ |
StopBuffer(hBuff); |
519,7 → 594,7 |
}; |
///********* |
void *memmove ( void * dst, void * src, int count) |
void *memmove ( void * dst, void * src, unsigned int count) /* uFMOD integration */ |
{ void *ret; |
ret = dst; |
555,6 → 630,40 |
return(ret); |
} |
char * __cdecl strrchr (const char * string,int ch) |
{ |
char *start = (char *)string; |
while (*string++) /* find end of string */ |
; |
/* search towards front */ |
while (--string != start && *string != (char)ch) |
; |
if (*string == (char)ch) /* char found ? */ |
return( (char *)string ); |
return(NULL); |
} |
int __cdecl _stricmp (const char * dst, const char * src) |
{ |
int f, l; |
do |
{ |
if ( ((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z') ) |
f -= 'A' - 'a'; |
if ( ((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z') ) |
l -= 'A' - 'a'; |
} |
while ( f && (f == l) ); |
return(f - l); |
} |
// debug_out_str(formats[fmt]); |
// debug_out_str("\x0D\x0A\x00"); |
584,6 → 693,3 |
// debug_out_hex(fmt); |
// debug_out_str("\x0D\x0A\x00"); |
/programs/media/ac97snd/ac97snd.sln |
---|
1,22 → 1,24 |
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
# Visual Studio 2005 |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg", "mpg\mpg.vcproj", "{6BB005B0-3277-4C8C-950F-38E15A4E440C}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97snd", "ac97snd\ac97snd.vcproj", "{5146AAEE-C15C-47C5-A245-64050C820145}" |
ProjectSection(ProjectDependencies) = postProject |
{6BB005B0-3277-4C8C-950F-38E15A4E440C} = {6BB005B0-3277-4C8C-950F-38E15A4E440C} |
EndProjectSection |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg", "mpg\mpg.vcproj", "{6BB005B0-3277-4C8C-950F-38E15A4E440C}" |
EndProject |
Global |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
Debug|Win32 = Debug|Win32 |
Release|Win32 = Release|Win32 |
EndGlobalSection |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Debug|Win32.ActiveCfg = Debug|Win32 |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Debug|Win32.Build.0 = Debug|Win32 |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Release|Win32.ActiveCfg = Release|Win32 |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Release|Win32.Build.0 = Release|Win32 |
{5146AAEE-C15C-47C5-A245-64050C820145}.Debug|Win32.ActiveCfg = Debug|Win32 |
{5146AAEE-C15C-47C5-A245-64050C820145}.Debug|Win32.Build.0 = Debug|Win32 |
{5146AAEE-C15C-47C5-A245-64050C820145}.Release|Win32.ActiveCfg = Release|Win32 |
{5146AAEE-C15C-47C5-A245-64050C820145}.Release|Win32.Build.0 = Release|Win32 |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Release|Win32.ActiveCfg = Release|Win32 |
{6BB005B0-3277-4C8C-950F-38E15A4E440C}.Release|Win32.Build.0 = Release|Win32 |
EndGlobalSection |
GlobalSection(SolutionProperties) = preSolution |
HideSolutionNode = FALSE |
/programs/media/ac97snd/mpg/mpg.vcproj |
---|
14,7 → 14,7 |
</Platforms> |
<ToolFiles> |
<ToolFile |
RelativePath="../fasm.rules" |
RelativePath="..\..\..\VStudio 8\Common7\IDE\fasm.rules" |
/> |
</ToolFiles> |
<Configurations> |
229,6 → 229,16 |
<File |
RelativePath=".\readers.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCLCompilerTool" |
EnableIntrinsicFunctions="true" |
WholeProgramOptimization="true" |
AssemblerOutput="1" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\tabinit.c" |
/programs/media/ac97snd/mpg/readers.c |
---|
79,35 → 79,42 |
rd->strpos = 0; |
retval=read_file (file,rd->buffer,0,0x10000,&bytes); |
if (retval) return 0; |
if( (retval==0)||(retval==6)) |
{ |
rd->strremain = bytes; |
rd->filepos = bytes; |
rd->strpos = 0; |
return 1; |
}; |
return 0; |
}; |
static int fill_reader(struct reader *rd) |
{ int retval; |
int bytes; |
if(rd->strremain > 0) |
mem_cpy(rd->buffer,rd->stream,rd->strremain); |
rd->stream = rd->buffer; |
retval=read_file (rd->hFile,rd->buffer+rd->strremain,rd->filepos, |
0x10000-rd->strremain,&bytes); |
if (retval) return 0; |
if(!bytes) return 0; |
if( (retval==0)||(retval==6)) |
{ |
rd->strremain+=bytes; |
rd->filepos+=bytes; |
rd->strpos = 0; |
return 1; |
return bytes; |
}; |
return 0; |
}; |
int __stdcall set_reader(struct reader *rd, unsigned int filepos) |
{ int retval; |
unsigned int bytes; |
retval=read_file (rd->hFile,rd->buffer,filepos,0x10000,&bytes); |
if (retval) return 0; |
if( (retval==0)||(retval==6)) |
{ |
rd->stream = rd->buffer; |
rd->strremain=bytes; |
rd->filepos=filepos+bytes; |
123,6 → 130,8 |
memset(bsspace,0,sizeof(bsspace)); |
return 1; |
}; |
return 0; |
}; |
static int stream_head_read(struct reader *rd,unsigned long *newhead) |
{ |
139,16 → 148,21 |
int stream_read_raw(struct reader *rd,unsigned char *buf, int size) |
{ |
if(rd->strremain < size) |
if( !fill_reader(rd)) |
return 0; |
if(rd->strremain < size) fill_reader(rd); |
if(size > rd->strremain) size=rd->strremain; |
if(size>0) |
{ |
mem_cpy(buf,rd->stream,size); |
rd->strpos+=size; |
rd->stream+=size; |
rd->strremain-=size; |
return 1; |
return size; |
}; |
return 0; |
}; |
void set_pointer(long backstep) |
{ |
491,7 → 505,7 |
/* read main data into memory */ |
/* 0 is error! */ |
if(!rd->read_frame_body(rd,bsbuf,fr->framesize)) |
if(rd->read_frame_body(rd,bsbuf,fr->framesize) < fr->framesize) |
return 0; |
#if 0 |
921,7 → 935,7 |
if(major == 0xff) return -1; |
if (!rd->read_frame_body(rd,buf,6)) |
if (rd->read_frame_body(rd,buf,6)<6) |
return 0; |
if(buf[0] == 0xff) /* major version, will never be 0xff */ |
return -1; |
/programs/media/ac97snd/ufmod-codec.h |
---|
0,0 → 1,90 |
/* |
uFMOD AC97SND codec header file |
Target OS: KolibriOS |
Compiler: Visual C |
NOTE: ufmod.obj should be rebuilt setting UF_MODE=AC97SND |
in order to make it usable in AC97SND player. |
The Infinity Sound driver handle should be available as |
a public symbol named hSound. It is so when using Serge's |
sound.lib. |
*/ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* HANDLE uFMOD_LoadSong(char *lpXM); |
--- |
Description: |
--- |
Loads the given XM song and starts playing it as soon as you |
call uFMOD_WaveOut for the first time. It will stop any |
currently playing song before loading the new one. Heap should |
be initialized before calling this function! |
--- |
Parameters: |
--- |
lpXM |
Specifies the filename of the song to load. |
--- |
Return Values: |
--- |
On success, returns a non zero value. Returns 0 on failure. |
*/ |
int __cdecl uFMOD_LoadSong(char*); |
/* int uFMOD_WaveOut(SNDBUF hBuff) |
--- |
Description: |
--- |
Updates the internal playback buffer. |
--- |
Parameters: |
--- |
hBuff |
The Infinity Sound buffer to update. |
--- |
Remarks: |
--- |
Playback doesn't actually begin when calling uFMOD_LoadSong, |
but when calling uFMOD_WaveOut after a successful uFMOD_LoadSong |
call. Afterwards, you should call uFMOD_WaveOut repeatedly at |
least once every 250 ms to prevent "buffer underruns". |
uFMOD_WaveOut is a non-blocking function. |
--- |
Return Values: |
--- |
Returns non zero on error. |
*/ |
int __cdecl uFMOD_WaveOut(unsigned int); |
/* void uFMOD_StopSong(void) |
--- |
Description: |
--- |
Stops the currently playing song, freeing the associated |
resources. |
--- |
Remarks: |
--- |
Does nothing if no song is playing at the time the call is made. |
*/ |
void __cdecl uFMOD_StopSong(); |
/* unsigned char* _uFMOD_GetTitle(void) |
--- |
Description: |
--- |
Returns the current song's title. |
--- |
Remarks: |
--- |
Not every song has a title, so be prepared to get an empty string. |
*/ |
unsigned char* __cdecl uFMOD_GetTitle(); |
#ifdef __cplusplus |
} |
#endif |