Exemplo n.º 1
0
/* Opens primary device */
int init_notify(int login_cooldown, int notification_timeout)
{
#ifdef _SOUND_NOTIFY
    alutInitWithoutContext(NULL, NULL);
    if (open_primary_device(output, &Control.device_idx, 48000, 20, 1) != de_None)
        return -1;
#endif /* _SOUND_NOTIFY */
        
#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY)
    pthread_mutex_init(Control.poll_mutex, NULL);
    pthread_t thread;
    if (pthread_create(&thread, NULL, do_playing, NULL) != 0 || pthread_detach(thread) != 0 ) {
        pthread_mutex_destroy(Control.poll_mutex);
        return -1;
    }
    Control.poll_active = 1;
#endif
    
    Control.cooldown = time(NULL) + login_cooldown;
#ifdef _X11
    Control.display = XOpenDisplay(NULL);
    Control.this_window = get_focused_window_id();
#else
    Control.this_window = 1;
#endif /* _X11 */
    
    
#ifdef _BOX_NOTIFY
    notify_init("toxic");
#endif
    Control.notif_timeout = notification_timeout;
    return 1;
}
Exemplo n.º 2
0
/* Opens primary device */
int init_notify(int login_cooldown, int notification_timeout)
{
#ifdef SOUND_NOTIFY
    alutInitWithoutContext(NULL, NULL);
#endif /* SOUND_NOTIFY */

#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY)
    if (pthread_mutex_init(Control.poll_mutex, NULL) != 0)
        return -1;

    Control.poll_active = 1;
    pthread_t thread;

    if (pthread_create(&thread, NULL, do_playing, NULL) != 0 || pthread_detach(thread) != 0 ) {
        pthread_mutex_destroy(Control.poll_mutex);
        Control.poll_active = 0;
        return -1;
    }

#endif
    Control.cooldown = time(NULL) + login_cooldown;


#ifdef BOX_NOTIFY
    notify_init("Toxic");
#endif
    Control.notif_timeout = notification_timeout;
    return 1;
}
Exemplo n.º 3
0
Arquivo: bind.cpp Projeto: Qard/jsgame
Handle<Value> ALUTInitWithoutContextCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 2)
		return v8::Undefined();
	
	//get arguments
	Handle<Array> arg0 = Array::Cast(args[0]);
	String::Utf8Value value1(args[1]);
	char* arg1 = *value1;

	//make call
	alutInitWithoutContext((int*)arg0, (char**)arg1);
	
	return v8::Undefined();
}
Exemplo n.º 4
0
bool C4MusicSystem::InitializeMOD()
{
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
	SDL_version compile_version;
	const SDL_version * link_version;
	MIX_VERSION(&compile_version);
	link_version=Mix_Linked_Version();
	LogF("SDL_mixer runtime version is %d.%d.%d (compiled with %d.%d.%d)",
	     link_version->major, link_version->minor, link_version->patch,
	     compile_version.major, compile_version.minor, compile_version.patch);
	if (!SDL_WasInit(SDL_INIT_AUDIO) && SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE))
	{
		LogF("SDL: %s", SDL_GetError());
		return false;
	}
	//frequency, format, stereo, chunksize
	if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024))
	{
		LogF("SDL_mixer: %s", SDL_GetError());
		return false;
	}
	MODInitialized = true;
	return true;
#elif AUDIO_TK == AUDIO_TK_OPENAL
	alcDevice = alcOpenDevice(NULL);
	if (!alcDevice)
	{
		LogF("Sound system: OpenAL create context error");
		return false;
	}
	alcContext = alcCreateContext(alcDevice, NULL);
	if (!alcContext)
	{
		LogF("Sound system: OpenAL create context error");
		return false;
	}
#ifndef __APPLE__
	if (!alutInitWithoutContext(NULL, NULL))
	{
		LogF("Sound system: ALUT init error");
		return false;
	}
#endif
	MODInitialized = true;
	return true;
#endif
	return false;
}
Exemplo n.º 5
0
SonicDog::SonicDog( size_t threads ) {
	num_threads_ = threads;

	// alutInit( NULL, NULL );
	// checkError( "clearing messages", AL );
	alutGetError();
	if ( alutInitWithoutContext( NULL, NULL ) == AL_FALSE ) {
		checkError( "alutInitWithoutContext", ALUT );
	}

	device_ = alcOpenDevice( NULL );
	if ( device_ ) {
		context_ = alcCreateContext( device_, NULL );
		if ( context_ ) {
			alcMakeContextCurrent( context_ );
		} else {
			checkError( "alcCreateContext", AL );
		}
	} else {
		checkError( "alcOpenDevice", AL );
	}

	// set the position of the listener at the origin
	alListener3f( AL_POSITION, 0.0f, 0.0f, 0.0f );
	alListener3f( AL_VELOCITY, 0.0f, 0.0f, 0.0f );
	// ALfloat ori[] = { 0.0f, 0.0f, 1.0f };
	// alListenerfv( AL_ORIENTATION, ori );

	// initialize the object id
	object_id_ = 1;

	// initialize the locks
	pthread_mutex_init( &play_lock_, NULL );
	pthread_mutex_init( &sources_lock_, NULL );
	pthread_mutex_init( &remove_lock_, NULL );
	pthread_mutex_init( &pause_lock_, NULL );
	pthread_mutex_init( &q_lock_, NULL );
	pthread_mutex_init( &turns_lock_, NULL );
	pthread_cond_init( &empty_q_lock_, NULL );
	pthread_cond_init( &pause_cond_lock_, NULL );

	// boolean to toggle regions on or off
	regions_ = true;
	cutoff_ = false;
	front_only_ = false;
}
Exemplo n.º 6
0
Audio :: Audio()
{
    auto l = lock();
    //alutInit(0, NULL);
    alutInitWithoutContext(0, NULL);
    m_pDevice = alcOpenDevice(NULL);
    if(not m_pDevice)
        throw std::runtime_error("failed to open OpenAL audio device");
    m_pContext = alcCreateContext(m_pDevice, NULL);
    if(not m_pContext)
        alcCloseDevice(m_pDevice);
    try {
        set_context();
    } catch(...) {
        alcDestroyContext(m_pContext);
        alcCloseDevice(m_pDevice);
        throw;
    }
}
ALSequencer::ALSequencer()
{
	bInitialised = false;
	bDestroying = false;

	fileCount = 0;
	startPos =
	endPos = 0;
	curPos = MAX_SEQUENCE;
	sfxPos = 0;

	pWaveLoader = NULL;

	bPlay = false;

	flEffectSends[0] = 
	flEffectSends[1] = 
	flEffectSends[2] = 
	flEffectSends[3] = 0.0f;

	ulOutputChannels = 0;
	ulNumEffects = 0;
	ulNumSamples = 0;
	ulBuffersProcessed = 0;

	pOutput = 0;
	pEffectOutput[0] = 
	pEffectOutput[1] = 
	pEffectOutput[2] = 
	pEffectOutput[3] = 0;

	if (InitializeOpenAL(NULL, 2, 4, 10240, 44100)) {
		alutInitWithoutContext(NULL, NULL);

		ulOutputChannels = GetNumOutputChannels();
		ulNumEffects = GetNumEffects();
		ulNumSamples = GetNumSamplesPerBuffer();

		bOutOfMemory = false;
		pOutput = malloc(ulOutputChannels * ulNumSamples * 2);
		for (unsigned long ulLoop = 0; ulLoop < ulNumEffects; ulLoop++)
		{
			pEffectOutput[ulLoop] = malloc(ulNumSamples * 2);
			if (pEffectOutput[ulLoop] == NULL)
				bOutOfMemory = true;
		}

		pWaveLoader = new CWaves();

		bInitialised = true;

		if (pWaveLoader && pOutput && !bOutOfMemory) {
			Start();

			EFXEAXREVERBPROPERTIES EFXEAXReverb[1] = { EFX_EAX_REVERB_HANGAR };

			SetEFXEAXReverbProperties(&EFXEAXReverb[0], 0);

			hThread = CreateThread(NULL, 0, ALSequencer::ThreadFuncWrapper, this, 0, &dwThreadId);
		}
	}
}