2 void changehome(
bool to,
bool linuxhome =
true );
21 void Cleanup(
int sockets_to_be_cleaned )
25 if (sockets_to_be_cleaned != -1)
28 signed char endcallback( FSOUND_STREAM *stream,
void *buf,
int len,
int param )
45 if (
m) FSOUND_Stream_Stop(
m );
49 if (
m) FSOUND_Stream_Close(
m );
52 bool SimpleLoad(
const char *
file )
54 m = FSOUND_Stream_OpenFile( file, FSOUND_NORMAL|FSOUND_MPEGACCURATE, 0 );
61 assert( AllDone ==
false );
62 FSOUND_Stream_SetEndCallback(
m, endcallback, 0 );
63 FSOUND_Stream_SetSynchCallback(
m, endcallback, 0 );
64 channel = FSOUND_Stream_Play( FSOUND_FREE,
m );
67 for (
unsigned int i = 0;
i < fadeout*10;
i++) {
73 void FadeOut(
float fadeout )
77 for (
unsigned int i = 0;
i < fadeout*10;
i++) {
78 SetVolume( 1-( i/( (
float) fadeout*10 ) ) );
87 F_API FSOUND_SetVolume( this->channel, (
int) ( vol*
GetMaxVolume() ) );
100 if ( waitpid( p, &status, WNOHANG ) ) {
115 if ( (arg !=
'\r') && (arg !=
'\n') && (arg !=
'\0') )
117 }
while ( (arg !=
'\n') && (arg !=
'\0') );
123 printf(
"initing device drivers\n" );
124 if ( !FSOUND_Init( 44100, 64, FSOUND_INIT_GLOBALFOCUS ) ) {
125 printf(
"SOUND Error %d\n", FSOUND_GetError() );
133 printf(
"f0rked playing %s\n", file );
136 printf(
"song done\n" );
146 printf(
"playing %s", file );
147 int filedes[2] = {-1, -1};
153 printf(
"f0rking subprocess\n" );
155 Cleanup( filedes[0] );
159 printf(
"forking main loop\n" );
166 printf(
"send e ratio %d\n", (
int) sende );
170 printf(
"\ne\n[SONG DONE]\n" );
176 if (open_file != -1) {
184 int main(
int argc,
char **argv )
191 for (
int i = 0;
i < 10 && mysocket == -1;
i++) {
194 port = atoi( argv[1] );
199 printf(
"\n[CONNECTED]\n" );
200 char ministr[2] = {
'\0',
'\0'};
213 printf(
"%s", str.c_str() );
219 printf(
"\n[%s WITH %d FADEIN AND %d FADEOUT IS ALREADY PLAYING]\n", str.c_str(),
fadein,
fadeout );
226 printf(
"%s", str.c_str() );
227 fadein = atoi( str.c_str() );
228 printf(
"\n[SETTING FADEIN TO %d]\n", fadein );
234 printf(
"%s", str.c_str() );
235 fadeout = atoi( str.c_str() );
236 printf(
"\n[SETTING FADEOUT TO %d]\n", fadeout );
243 printf(
"%s", str.c_str() );
248 volume = (
float) atof( str.c_str() );
254 printf(
"%s", str.c_str() );
257 printf(
"\n[SETTING VOLUME TO %f]\n", volume*
soft_volume );
263 printf(
"\n[STOPPING ALL MUSIC]\n" );
278 printf(
"\n[TERMINATING MUSIC SERVER]\n" );
283 Cleanup( open_file );
290 if ( !SimpleLoad( file ) ) {
307 static std::vector< std::string >paths;
309 char mycurpath[8192];
310 getcwd( mycurpath, 8191 );
311 mycurpath[8191] =
'\0';
312 paths.push_back( std::string( mycurpath ) );
315 struct passwd *pwent;
316 pwent = getpwuid( getuid() );
317 chdir( pwent->pw_dir );
320 chdir(
".vegastrike" );
321 }
else if ( !paths.empty() ) {
322 chdir( paths.back().c_str() );
330 static int maxVol = FSOUND_GetSFXMasterVolume();