#include "lin_time.h"
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <SDL/SDL_mixer.h>
#include <unistd.h>
#include <stdio.h>
#include <pwd.h>
#include <string>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "inet_file.h"
Go to the source code of this file.
void changehome |
( |
bool |
to, |
|
|
bool |
linuxhome = true |
|
) |
| |
Definition at line 257 of file soundserver.segfault.cpp.
259 static std::vector< std::string >paths;
261 char mycurpath[8192];
262 getcwd( mycurpath, 8191 );
263 mycurpath[8191] =
'\0';
264 paths.push_back( std::string( mycurpath ) );
267 struct passwd *pwent;
268 pwent = getpwuid( getuid() );
269 chdir( pwent->pw_dir );
272 chdir(
".vegastrike" );
273 }
else if ( !paths.empty() ) {
274 chdir( paths.back().c_str() );
void cleanExit |
( |
char * |
str, |
|
|
|
... |
|
) |
| |
void errorv |
( |
char * |
str, |
|
|
va_list |
ap |
|
) |
| |
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 355 of file soundserver.segfault.cpp.
References cleanExit(), done, fadein, fadeout, fNET_AcceptFrom(), fNET_cleanup(), fNET_close(), fNET_fgetc(), fNET_startup(), GetMaxVolume(), i, Music::m, music_finished(), mysocket_write, PlayMusic(), Music::SetMasterVolume(), and TakeLotsOfPriority().
359 int audio_rate, audio_channels,
362 audio_buffers = 4096;
366 if (SDL_Init( SDL_INIT_AUDIO ) < 0)
371 if ( !FSOUND_Init( 44100, 64, FSOUND_INIT_GLOBALFOCUS ) ) {
372 printf(
"SOUND Error %d\n", FSOUND_GetError() );
381 if (Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, audio_buffers ) < 0)
384 Mix_QuerySpec( &audio_rate, &audio_format, &audio_channels );
385 bits = audio_format&0xFF;
387 printf(
"Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
388 bits, audio_channels > 1 ?
"stereo" :
"mono", audio_buffers );
391 printf(
"argv %d\n\n\n", argc );
397 if (mysocket_write == -1)
400 mysocket_write = open( argv[2], O_WRONLY|O_SHLOCK|O_CREAT, 0xffffffff );
401 mysocket_read = open( argv[1], O_RDONLY|O_SHLOCK|O_CREAT, 0xffffffff );
403 printf(
"\n[CONNECTED]\n" );
404 char ministr[2] = {
'\0',
'\0'};
416 while (arg !=
'\0' && arg !=
'\n') {
423 printf(
"%s", str.c_str() );
426 || ( !Mix_PlayingMusic() )
431 printf(
"\n[PLAYING %s WITH %d FADEIN AND %d FADEOUT]\n", str.c_str(),
fadein,
fadeout );
435 printf(
"\n[UNABLE TO PLAY %s WITH %d FADEIN AND %d FADEOUT]\n", str.c_str(),
fadein,
fadeout );
439 printf(
"\n[%s WITH %d FADEIN AND %d FADEOUT IS ALREADY PLAYING]\n", str.c_str(),
fadein,
fadeout );
445 while (arg !=
'\0' && arg !=
'\n') {
452 printf(
"%s", str.c_str() );
453 fadein = atoi( str.c_str() );
454 printf(
"\n[SETTING FADEIN TO %d]\n", fadein );
459 while (arg !=
'\0' && arg !=
'\n') {
466 printf(
"%s", str.c_str() );
468 printf(
"\n[SETTING FADEOUT TO %d]\n", fadeout );
473 while (arg !=
'\0' && arg !=
'\n') {
480 printf(
"%s", str.c_str() );
481 volume = atof( str.c_str() );
482 printf(
"\n[SETTING VOLUME TO %f]\n", volume );
492 printf(
"\n[TERMINATING MUSIC SERVER]\n" );
Music PlayMusic |
( |
const char * |
file, |
|
|
Music & |
oldmusic |
|
) |
| |
void TakeLotsOfPriority |
( |
) | |
|
Definition at line 321 of file soundserver.segfault.cpp.
References error.
Referenced by main().
327 thread_extended_policy_data_t extendedPolicy;
328 thread_precedence_policy_data_t precedencePolicy;
330 extendedPolicy.timeshare = 0;
331 error = thread_policy_set( mach_thread_self(),
332 THREAD_EXTENDED_POLICY,
333 (thread_policy_t) &extendedPolicy,
334 THREAD_EXTENDED_POLICY_COUNT );
335 if (error != KERN_SUCCESS) {
337 mach_error(
"Couldn't set feeder thread's extended policy",
341 precedencePolicy.importance = 1;
342 error = thread_policy_set( mach_thread_self(),
343 THREAD_PRECEDENCE_POLICY,
344 (thread_policy_t) &precedencePolicy,
345 THREAD_PRECEDENCE_POLICY_COUNT );
346 if (error != KERN_SUCCESS) {
348 mach_error(
"Couldn't set feeder thread's precedence policy",
bool invalid_string = true |