BOOL LLAudioEngine_OpenAL::init(const S32 num_channels) { LLAudioEngine::init(num_channels); if(!alutInit(NULL, NULL)) { llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << alutGetErrorString (alutGetError ()) << llendl; return FALSE; } initInternetStream(); llinfos << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << llendl; llinfos << "LLAudioEngine_OpenAL::init() Speed of sound is: " << alGetFloat(AL_SPEED_OF_SOUND) << llendl; return TRUE; }
bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) { mFadeIn = -10000; LLAudioEngine::init(num_channels, userdata); // Reserve one extra channel for the http stream. if (!FSOUND_SetMinHardwareChannels(num_channels + 1)) { LL_WARNS("AppInit") << "FMOD::init[0](), error: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; } LL_DEBUGS("AppInit") << "LLAudioEngine_FMOD::init() initializing FMOD" << LL_ENDL; F32 version = FSOUND_GetVersion(); if (version < FMOD_VERSION) { LL_WARNS("AppInit") << "Error : You are using the wrong FMOD version (" << version << ")! You should be using FMOD " << FMOD_VERSION << LL_ENDL; //return false; } U32 fmod_flags = 0x0; #if LL_WINDOWS // Windows needs to know which window is frontmost. // This must be called before FSOUND_Init() per the FMOD docs. // This could be used to let FMOD handle muting when we lose focus, // but we don't actually want to do that because we want to distinguish // between minimized and not-focused states. if (!FSOUND_SetHWND(userdata)) { LL_WARNS("AppInit") << "Error setting FMOD window: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; return false; } // Play audio when we don't have focus. // (For example, IM client on top of us.) // This means we also try to play audio when minimized, // so we manually handle muting in that case. JC fmod_flags |= FSOUND_INIT_GLOBALFOCUS; #endif #if LL_LINUX // initialize the FMOD engine // This is a hack to use only FMOD's basic FPU mixer // when the LL_VALGRIND environmental variable is set, // otherwise valgrind will fall over on FMOD's MMX detection if (getenv("LL_VALGRIND")) /*Flawfinder: ignore*/ { LL_INFOS("AppInit") << "Pacifying valgrind in FMOD init." << LL_ENDL; FSOUND_SetMixer(FSOUND_MIXER_QUALITY_FPU); } // If we don't set an output method, Linux FMOD always // decides on OSS and fails otherwise. So we'll manually // try ESD, then OSS, then ALSA. // Why this order? See SL-13250, but in short, OSS emulated // on top of ALSA is ironically more reliable than raw ALSA. // Ack, and ESD has more reliable failure modes - but has worse // latency - than all of them, so wins for now. bool audio_ok = false; if (!audio_ok) if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL; if(FSOUND_SetOutput(FSOUND_OUTPUT_ESD) && FSOUND_Init(44100, num_channels, fmod_flags)) { LL_DEBUGS("AppInit") << "ESD audio output initialized OKAY" << LL_ENDL; audio_ok = true; } else { LL_WARNS("AppInit") << "ESD audio output FAILED to initialize: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; } } else { LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL; } if (!audio_ok) if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL; if(FSOUND_SetOutput(FSOUND_OUTPUT_OSS) && FSOUND_Init(44100, num_channels, fmod_flags)) { LL_DEBUGS("AppInit") << "OSS audio output initialized OKAY" << LL_ENDL; audio_ok = true; } else { LL_WARNS("AppInit") << "OSS audio output FAILED to initialize: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; } } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } if (!audio_ok) if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; if(FSOUND_SetOutput(FSOUND_OUTPUT_ALSA) && FSOUND_Init(44100, num_channels, fmod_flags)) { LL_DEBUGS("AppInit") << "ALSA audio output initialized OKAY" << LL_ENDL; audio_ok = true; } else { LL_WARNS("AppInit") << "ALSA audio output FAILED to initialize: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; } } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } if (!audio_ok) { LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL; return false; } // On Linux, FMOD causes a SIGPIPE for some netstream error // conditions (an FMOD bug); ignore SIGPIPE so it doesn't crash us. // NOW FIXED in FMOD 3.x since 2006-10-01. //signal(SIGPIPE, SIG_IGN); // We're interested in logging which output method we // ended up with, for QA purposes. switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: LL_DEBUGS("AppInit") << "Audio output: NoSound" << LL_ENDL; break; case FSOUND_OUTPUT_OSS: LL_DEBUGS("AppInit") << "Audio output: OSS" << LL_ENDL; break; case FSOUND_OUTPUT_ESD: LL_DEBUGS("AppInit") << "Audio output: ESD" << LL_ENDL; break; case FSOUND_OUTPUT_ALSA: LL_DEBUGS("AppInit") << "Audio output: ALSA" << LL_ENDL; break; default: LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break; }; #else // LL_LINUX // initialize the FMOD engine if (!FSOUND_Init(44100, num_channels, fmod_flags)) { LL_WARNS("AppInit") << "Error initializing FMOD: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; return false; } #endif initInternetStream(); LL_DEBUGS("AppInit") << "LLAudioEngine_FMOD::init() FMOD initialized correctly" << LL_ENDL; mInited = true; return true; }