Esempio n. 1
0
static void plugin_seek(struct playerHandles *ph, int modtime){
	int newtime;
	int seconds;
	struct vorbisHandles *h;

	if(ph->dechandle==NULL)
		return;

	h=(struct vorbisHandles *)ph->dechandle;
	if(modtime==0){
		ov_time_seek(h->vf,0);
		*h->total=0;
		snd_clear(ph);
		return;
	}

	seconds=(*h->total)/((h->rate)*(h->sizemod));
	seconds+=modtime;

	if(ov_time_seek(h->vf,seconds)!=0)
		return;
	newtime=seconds*((h->rate)*(h->sizemod));

	if(newtime<0)
		newtime=0;

	*h->total=newtime;
	snd_clear(ph);
}
Esempio n. 2
0
// ---------------------------------------------------------------------------------------
// Initialize the game sound system
// 
// Initialize the game sound system.  Depending on what sound library is being used,
// call the appropriate low-level initiailizations
//
// returns:     1		=> init success
//              0		=> init failed
//
int snd_init(int use_a3d, int use_eax)
{
	int rval;

	if ( Cmdline_freespace_no_sound )
		return 0;

	if (ds_initialized)	{
		nprintf(( "Sound", "SOUND => Direct Sound is already initialized!\n" ));
		return 1;
	}

	snd_clear();

	// Init DirectSound 

	// Connect to DirectSound
	int num_tries=0;
	int gave_warning = 0;
	while(1) {
		rval = ds_init(use_a3d, use_eax);

		if( rval != 0 ) {
			nprintf(( "Sound", "SOUND ==> Error initializing DirectSound, trying again in 1 second.\n"));
			Sleep(1000);
		} else {
			break;
		}

		if ( num_tries++ > 5 ) {
			if ( !gave_warning ) {
				MessageBox(NULL, XSTR("DirectSound could not be initialized.  If you are running any applications playing sound in the background, you should stop them before continuing.",971), NULL, MB_OK);
				gave_warning = 1;
			} else {
				goto Failure;
			}
		}
	}

	// Init the Audio Compression Manager
	if ( ACM_init() == -1 ) {
		HWND hwnd = (HWND)os_get_window();
		MessageBox(hwnd, XSTR("Could not properly initialize the Microsoft ADPCM codec.\n\nPlease see the readme.txt file for detailed instructions on installing the Microsoft ADPCM codec.",972), NULL, MB_OK);
//		Warning(LOCATION, "Could not properly initialize the Microsoft ADPCM codec.\nPlease see the readme.txt file for detailed instructions on installing the Microsoft ADPCM codec.");
	}

	// Init the audio streaming stuff
	audiostream_init();
			
	ds_initialized = 1;
	return 1;

Failure:
//	Warning(LOCATION, "Sound system was unable to be initialized.  If you continue, sound will be disabled.\n");
	nprintf(( "Sound", "SOUND => Direct Sound init unsuccessful, continuing without sound.\n" ));
	return 0;
}
Esempio n. 3
0
// ---------------------------------------------------------------------------------------
// Initialize the game sound system
// 
// Initialize the game sound system.  Depending on what sound library is being used,
// call the appropriate low-level initiailizations
//
// returns:     1		=> init success
//              0		=> init failed
//
int snd_init()
{
	int rval;

	if ( Cmdline_freespace_no_sound )
		return 0;

	if (ds_initialized)	{
		nprintf(( "Sound", "SOUND => Audio is already initialized!\n" ));
		return 1;
	}

	snd_clear();


	rval = ds_init();

	if ( rval != 0 ) {
		nprintf(( "Sound", "SOUND ==> Fatal error initializing audio device, turn sound off.\n" ));
		Cmdline_freespace_no_sound = Cmdline_freespace_no_music = 1;
		goto Failure;
	}

	if ( OGG_init() == -1 ) {
		mprintf(("Could not initialize the OGG vorbis converter.\n"));
	}

	snd_aav_init();

	// Init the audio streaming stuff
	audiostream_init();
			
	ds_initialized = 1;
	Sound_enabled = TRUE;
	return 1;

Failure:
//	Warning(LOCATION, "Sound system was unable to be initialized.  If you continue, sound will be disabled.\n");
	nprintf(( "Sound", "SOUND => Audio init unsuccessful, continuing without sound.\n" ));
	return 0;
}
Esempio n. 4
0
void plugin_seek(struct playerHandles *ph, int modtime){
	if(ph->dechandle==NULL){
		fprintf(stderr,"no dechandle");
		return;
	}

pthread_mutex_lock(&dechandle_lock);
	struct mp3Handles *h=(struct mp3Handles *)ph->dechandle;
	mpg123_seek_frame(h->m,mpg123_timeframe(h->m,(int)modtime),modtime?SEEK_CUR:SEEK_SET);


	if(modtime){
		h->total+=modtime;
		if(h->total<0)h->total=0;
	}
	else
		h->total=0;
pthread_mutex_unlock(&dechandle_lock);

	snd_clear(ph);
}