当前位置: 首页>>代码示例>>C++>>正文


C++ alcGetError函数代码示例

本文整理汇总了C++中alcGetError函数的典型用法代码示例。如果您正苦于以下问题:C++ alcGetError函数的具体用法?C++ alcGetError怎么用?C++ alcGetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了alcGetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: audio_setup

static void audio_setup()
{
    clog << "Initializing audio." << endl;

    device = alcOpenDevice(NULL);
    if (device==NULL)
    {
        Exception(alcGetString(NULL, alcGetError(NULL)));
    }
    
    int attr[] = { ALC_FREQUENCY, 22050, ALC_INVALID };

    context = alcCreateContext(device, attr);
    if (context==NULL)
    {
        string error = string(alcGetString(device, alcGetError(device)));
        alcCloseDevice(device);
        Exception(error);
    }
    alcMakeContextCurrent(context);

    int major=0, minor=0;
    alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
    alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);

    clog << " * Version    : " << major << '.' << minor << endl
         << " * Vendor     : " << alGetString(AL_VENDOR) << endl
         << " * Renderer   : " << alGetString(AL_RENDERER) << endl
         << " * Device     : " << alcGetString(device, ALC_DEVICE_SPECIFIER) << endl
         << " * Extensions : " << alcGetString(device, ALC_EXTENSIONS) << endl;
}
开发者ID:mmozeiko,项目名称:Squares3D-iPad,代码行数:31,代码来源:audio.cpp

示例2: recAndSend

void* recAndSend(void * param){
  ALshort alrecBuffer[SAMPLESIZE];
  ALint alSample;
  ALCdevice* device = alcOpenDevice(NULL);
  ALCcontext* context = alcCreateContext(device,  NULL);
  alcMakeContextCurrent(context);
  ALCdevice* alDevice = alcCaptureOpenDevice(NULL, SRATE, AL_FORMAT_MONO16, SAMPLESIZE);
  alcGetError(alDevice);
  alcCaptureStart(alDevice);
  alcGetError(alDevice);
  while (1){
    alcGetIntegerv(alDevice, ALC_CAPTURE_SAMPLES, (ALCsizei)sizeof(ALint), &alSample);
    alcGetError(alDevice);
    if(alSample > SAMPLESIZE/2) {
      alcCaptureSamples(alDevice, (ALCvoid *)alrecBuffer, alSample);
      int n;
      socklen_t addrlen = sizeof(senderinfo);
      int i;
      for(i=0; i<alSample; i++){
        if(abs((int)alrecBuffer[i]) > (0.8*INT16_MAX) ) break;
      }
      if(i==alSample) continue;
      if((n = sendto(sock, alrecBuffer, alSample*2, 0, (struct sockaddr *)&senderinfo, addrlen)) != alSample*2){
        perror("sendto");
        exit(1);
      }
    }
    if(callFlag==OFF) break;
  }
  alcCaptureCloseDevice(alDevice);
  alcCaptureStop(alDevice);
  alcCloseDevice(device);
//  fprintf(stderr, "close recAndSend\n");
}
开发者ID:vetus-rector,项目名称:Code,代码行数:34,代码来源:main.c

示例3: qWarning

bool
QALContext::create()
{
    if ((d->alcDevice = alcOpenDevice(d->requestedAttributes.deviceSpecifier().toAscii())) == false) {
        qWarning() << Q_FUNC_INFO << "Failed to open the device:" << d->requestedAttributes.deviceSpecifier();
        return false;
    }

    ALCenum error;
    if ((error = alcGetError(d->alcDevice)) != ALC_NO_ERROR) {
        qWarning() << Q_FUNC_INFO << "Error before trying to create the context:" << alcGetString(d->alcDevice, error);
    };

    ALCint attributes[] = {
        ALC_FREQUENCY, d->requestedAttributes.frequency(),
        ALC_MONO_SOURCES, d->requestedAttributes.monoSources(),
        ALC_REFRESH, d->requestedAttributes.refresh(),
        ALC_STEREO_SOURCES, d->requestedAttributes.stereoSources(),
        ALC_SYNC, d->requestedAttributes.sync(),
        0
    };

    d->alcContext = alcCreateContext(d->alcDevice, attributes);
    if ((error = alcGetError(d->alcDevice)) != ALC_NO_ERROR) {
        qWarning() << Q_FUNC_INFO << "Failed to create the context:" << alcGetString(d->alcDevice, error);
        alcCloseDevice(d->alcDevice);
        d->alcDevice = 0;
        return false;
    }

    return true;
}
开发者ID:qtproject,项目名称:playground-qtaudio3d,代码行数:32,代码来源:qalcontext.cpp

示例4: alcOpenDevice

	void SoundManager::init() {
		m_device = alcOpenDevice(NULL);

		if (!m_device || alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Could not open audio device - deactivating audio module");
			m_device = NULL;
			return;
		}

		m_context = alcCreateContext(m_device, NULL);
		if (!m_context || alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Couldn't create audio context - deactivating audio module");
			m_device = NULL;
			return;
		}

		alcMakeContextCurrent(m_context);
		if (alcGetError(m_device) != ALC_NO_ERROR) {
			FL_ERR(_log, LMsg() << "Couldn't change current audio context - deactivating audio module");
			m_device = NULL;
			return;
		}

		// set listener position
		alListener3f(AL_POSITION, 0.0, 0.0, 0.0);
		ALfloat vec1[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
		alListenerfv(AL_ORIENTATION, vec1);

		// set volume
		alListenerf(AL_GAIN, m_volume);
	}
开发者ID:mgeorgehansen,项目名称:FIFE_Technomage,代码行数:31,代码来源:soundmanager.cpp

示例5: alureInitDevice

    /* Function: alureInitDevice
     *
     * Opens the named device, creates a context with the given attributes, and
     * sets that context as current. The name and attribute list would be the same
     * as what's passed to alcOpenDevice and alcCreateContext respectively.
     *
     * Returns:
     * AL_FALSE on error.
     *
     * See Also:
     * <alureShutdownDevice>
     */
    ALURE_API ALboolean ALURE_APIENTRY alureInitDevice(const ALCchar *name, const ALCint *attribs)
    {
        ALCdevice *device = alcOpenDevice(name);
        if(!device)
        {
            alcGetError(NULL);

            SetError("Device open failed");
            return AL_FALSE;
        }

        ALCcontext *context = alcCreateContext(device, attribs);
        if(!context || alcMakeContextCurrent(context) == ALC_FALSE)
        {
            if(context)
                alcDestroyContext(context);
            alcCloseDevice(device);

            SetError("Context setup failed");
            return AL_FALSE;
        }
        alcGetError(device);

        return AL_TRUE;
    }
开发者ID:JoshDreamland,项目名称:enigma-dev-fat,代码行数:37,代码来源:alure.cpp

示例6: alcOpenDevice

void AudioController::initialize()
{
    _alcDevice = alcOpenDevice(NULL);
    if (!_alcDevice)
    {
        GP_ERROR("Unable to open OpenAL device.\n");
        return;
    }
    
    _alcContext = alcCreateContext(_alcDevice, NULL);
    ALCenum alcErr = alcGetError(_alcDevice);
    if (!_alcContext || alcErr != ALC_NO_ERROR)
    {
        alcCloseDevice(_alcDevice);
        GP_ERROR("Unable to create OpenAL context. Error: %d\n", alcErr);
        return;
    }
    
    alcMakeContextCurrent(_alcContext);
    alcErr = alcGetError(_alcDevice);
    if (alcErr != ALC_NO_ERROR)
    {
        GP_ERROR("Unable to make OpenAL context current. Error: %d\n", alcErr);
    }
}
开发者ID:5guo,项目名称:GamePlay,代码行数:25,代码来源:AudioController.cpp

示例7: frequency

AudioAnalyzer::AudioAnalyzer(int frequency_, int captureSize_) :
	frequency(frequency_), captureSize(captureSize_), initialized(false)
{
	ALenum errorCode=0;
	inputDevice = alcCaptureOpenDevice(NULL, frequency, AL_FORMAT_MONO16, frequency/2);
	if (inputDevice == NULL) {
		Logger::Instance()->OutputString("Error: alcCaptureOpenDevice");
		return;
	}

	errorCode = alcGetError(inputDevice);
	if (errorCode != AL_NO_ERROR) {
		Logger::Instance()->OutputString("Error: alcCaptureOpenDevice -- ?");
		return;
	}
	alcCaptureStart(inputDevice); // Begin capturing
	errorCode = alcGetError(inputDevice);
	if (errorCode != AL_NO_ERROR) {
		Logger::Instance()->OutputString("Error: alcCaptureStart");
		alcCaptureCloseDevice(inputDevice);
		return;
	}

	capturedBuffer = new  short[captureSize];
	ffted = new float[captureSize];
	ar = new float[captureSize];
	ai = new float[captureSize];

	initialized = true;

	Logger::Instance()->OutputString("OpenAL succeeded");
}
开发者ID:HsienYu,项目名称:Live-Coder,代码行数:32,代码来源:AudioAnalyzer.cpp

示例8: OpenALSoundManager

	OpenALSoundManager(OnDemandSoundFetcher *fetcher):
		m_fetcher(fetcher),
		m_device(NULL),
		m_context(NULL),
		m_can_vorbis(false),
		m_next_id(1),
		m_is_initialized(false)
	{
		ALCenum error = ALC_NO_ERROR;
		
		infostream<<"Audio: Initializing..."<<std::endl;

		m_device = alcOpenDevice(NULL);
		if(!m_device){
			infostream<<"Audio: No audio device available, audio system "
				<<"not initialized"<<std::endl;
			return;
		}

		if(alcIsExtensionPresent(m_device, "EXT_vorbis")){
			infostream<<"Audio: Vorbis extension present"<<std::endl;
			m_can_vorbis = true;
		} else{
			infostream<<"Audio: Vorbis extension NOT present"<<std::endl;
			m_can_vorbis = false;
		}

		m_context = alcCreateContext(m_device, NULL);
		if(!m_context){
			error = alcGetError(m_device);
			infostream<<"Audio: Unable to initialize audio context, "
					<<"aborting audio initialization ("<<alcErrorString(error)
					<<")"<<std::endl;
			alcCloseDevice(m_device);
			m_device = NULL;
			return;
		}

		if(!alcMakeContextCurrent(m_context) ||
				(error = alcGetError(m_device) != ALC_NO_ERROR))
		{
			infostream<<"Audio: Error setting audio context, aborting audio "
					<<"initialization ("<<alcErrorString(error)<<")"<<std::endl;
			alcDestroyContext(m_context);
			m_context = NULL;
			alcCloseDevice(m_device);
			m_device = NULL;
			return;
		}

		alDistanceModel(AL_EXPONENT_DISTANCE);

		infostream<<"Audio: Initialized: OpenAL "<<alGetString(AL_VERSION)
				<<", using "<<alcGetString(m_device, ALC_DEVICE_SPECIFIER)
				<<std::endl;

		m_is_initialized = true;
	}
开发者ID:nikkuang,项目名称:minetest,代码行数:58,代码来源:sound_openal.cpp

示例9: alcOpenDevice

Status CSoundManager::AlcInit()
{	
	Status ret = INFO::OK;

	m_Device = alcOpenDevice(NULL);
	if (m_Device)
	{
		ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0};
		m_Context = alcCreateContext(m_Device, &attribs[0]);

		if (m_Context)
		{
			alcMakeContextCurrent(m_Context);
			m_ALSourceBuffer = new ALSourceHolder[SOURCE_NUM];
			ALuint* sourceList = new ALuint[SOURCE_NUM];

			alGenSources(SOURCE_NUM, sourceList);
			ALCenum err = alcGetError(m_Device);

			if (err == ALC_NO_ERROR)
			{
				for (int x = 0; x < SOURCE_NUM; x++)
				{
					m_ALSourceBuffer[x].ALSource = sourceList[x];
					m_ALSourceBuffer[x].SourceItem = NULL;
				}
				m_Enabled = true;
			}
			else
			{
				LOGERROR("error in gensource = %d", err);
			}
			delete[] sourceList;
		}
	}

	// check if init succeeded.
	// some OpenAL implementations don't indicate failure here correctly;
	// we need to check if the device and context pointers are actually valid.
	ALCenum err = alcGetError(m_Device);
	const char* dev_name = (const char*)alcGetString(m_Device, ALC_DEVICE_SPECIFIER);

	if (err == ALC_NO_ERROR && m_Device && m_Context)
		debug_printf("Sound: AlcInit success, using %s\n", dev_name);
	else
	{
		LOGERROR("Sound: AlcInit failed, m_Device=%p m_Context=%p dev_name=%s err=%x\n", (void *)m_Device, (void *)m_Context, dev_name, err);

// FIXME Hack to get around exclusive access to the sound device
#if OS_UNIX
		ret = INFO::OK;
#else
		ret = ERR::FAIL;
#endif // !OS_UNIX
	}

	return ret;
}
开发者ID:righnatios,项目名称:0ad,代码行数:58,代码来源:SoundManager.cpp

示例10: lock

void csSndSysRendererOpenAL::Open()
{
  ScopedRendererLock lock (*this);

  // First assume we have both a config and a device, but no context.
  CS_ASSERT (m_Config != 0);
  CS_ASSERT (m_Device != 0);
  CS_ASSERT (m_Context == 0);

  Report (CS_REPORTER_SEVERITY_DEBUG, "Opening OpenAL sound system");

  // Clear any error condition
  alcGetError (m_Device);

  // Setup the attribute list for the OpenAL context
  const ALCint attr[] =
  {
    ALC_REFRESH,   m_Config->GetInt ("SndSys.OpenALRefresh", 10),    // How often do we update the mixahead buffer (hz).
    ALC_SYNC,      AL_FALSE,                                         // We want an asynchronous context.
    ALC_STEREO_SOURCES, 12,
    ALC_MONO_SOURCES, 120,
    0
  };
  // Note: If the sound is choppy, it may be because your OpenAL
  //       implementation does not implement async (threaded) contexts and
  //       your framerate is below SndSys.OpenALRefresh. If this is the case,
  //       please try to decrease SndSys.OpenALRefresh to below your
  //       framerate. This however will increase sound latency. Alternatively
  //       you may attempt to implement the async operation in CS.

  // Get an OpenAL context
  m_Context = alcCreateContext (m_Device, attr);
  if (m_Context == 0)
  {
    Report (CS_REPORTER_SEVERITY_ERROR, "Unable to get OpenAL context");
    CS_ASSERT (m_Context != 0);
  }

  // Make our new context current
  alcMakeContextCurrent (m_Context);

  // Set the context processing
  alcProcessContext (m_Context);

  // Check for any errors
  ALCenum err = alcGetError (m_Device);
  if (err != ALC_NO_ERROR)
  {
    Report (CS_REPORTER_SEVERITY_ERROR, "An OpenAL error occured: %s", alcGetString (m_Device, err));
    CS_ASSERT (err == ALC_NO_ERROR);
  }

  // Query available extensions
  QueryExtensions ();

  // Create a listener
  m_Listener.AttachNew(new SndSysListenerOpenAL());
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:58,代码来源:renderer.cpp

示例11: alcGetError

String ALDevice::getName(PlaybackDeviceName type) const
{
    if(type == PlaybackDeviceName::Complete && !alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
        type = PlaybackDeviceName::Basic;
    alcGetError(mDevice);
    const ALCchar *name = alcGetString(mDevice, (ALenum)type);
    if(alcGetError(mDevice) != ALC_NO_ERROR || !name)
        name = alcGetString(mDevice, (ALenum)PlaybackDeviceName::Basic);
    return name ? String(name) : String();
}
开发者ID:cpp-mirrors,项目名称:alure,代码行数:10,代码来源:device.cpp

示例12: alcGetIntegerv

void OpenALCapture::grabSamples()
{
    alcGetIntegerv(this->capDevice, ALC_CAPTURE_SAMPLES, (ALCsizei)sizeof(ALint), &numAvailSamples);
    this->error(alcGetError(this->capDevice));
    if (numAvailSamples >= this->BUFFER_SIZE)
    {
        alcCaptureSamples(this->capDevice, &(this->tempBuffer), this->BUFFER_SIZE);
        this->error(alcGetError(this->capDevice));
        this->softWave();
    }
}
开发者ID:jarbasjacome,项目名称:ViMus,代码行数:11,代码来源:OpenALCapture.cpp

示例13: InicializarAudio

int InicializarAudio(){

	/* Asignamos el mejor dispositivo de audio disponible */
#ifdef _LINUX

	if (( Device = alcOpenDevice ((ALubyte* ) "waveOut" )) == NULL){
		fprintf ( logs,"No existe WaveOut Backend\n");
		if (( Device = alcOpenDevice (( ALubyte* ) "SDL" )) == NULL ){
			fprintf ( logs,"No existe SDL Backend\n");
			if (( Device = alcOpenDevice (( ALubyte* ) "arts" )) == NULL ){
				fprintf ( logs,"No existe arts Backend\n");
				if (( Device = alcOpenDevice ( NULL )) == NULL ){
					fprintf ( logs,"No hay disponible ningun dispositivo de audio\n");
					return -1;
				}
			}
		}
	}
#endif
#ifdef _WIN32
	if (( Device = alcOpenDevice ((ALubyte* ) "DirectSound3D" )) == NULL ){
		fprintf ( logs,"No existe DirectSound3D Backend\n");
		if (( Device = alcOpenDevice (( ALubyte* ) "DirectSound" )) == NULL ){
			fprintf ( logs,"No existe DirectSound Backend\n");
			if (( Device = alcOpenDevice (( ALubyte* ) "WaveOut" )) == NULL ){
				fprintf ( logs,"No existe WaveOut Backend\n");
				if (( Device = alcOpenDevice ( NULL )) == NULL ){
					fprintf ( logs,"No hay disponible ningun dispositivo de audio\n");
					return -1;
				}
			}
		}
	}
#endif

	/* Creamos un contexto y lo asignamos (comprobando si hay errores)*/
	if ( Device != NULL ){
		Context = alcCreateContext ( Device , NULL ); /* Creamos */
	    if ( alcGetError ( Device ) != ALC_NO_ERROR ){
			fprintf ( logs, "No se puede crear un contexto para el sistema de audio\n");
			return -1;
		}

		alcMakeContextCurrent ( Context ); /* Asignamos */
	    if ( alcGetError ( Device ) != ALC_NO_ERROR ){
			fprintf ( logs, "No se puede asignar el contexto para el sistema de audio\n");
			return -1;
		}
	}
  audio_on = 1;
  return 0;
}
开发者ID:BackupTheBerlios,项目名称:worldspace,代码行数:52,代码来源:audio.c

示例14: _openal_open

/* The open method starts up the driver and should lock the device, using the
   previously set paramters, or defaults. It shouldn't need to start sending
   audio data to the device yet, however. */
static int _openal_open(void)
{
   ALenum openal_err;
   ALCenum alc_err;

   ALLEGRO_INFO("Starting OpenAL\n");

   /* clear the error state */
   openal_err = alGetError();

   /* pick default device. always a good choice */
   openal_dev = alcOpenDevice(NULL);

   alc_err = ALC_NO_ERROR;
   if (!openal_dev || (alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not open audio device: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   openal_context = alcCreateContext(openal_dev, NULL);
   alc_err = ALC_NO_ERROR;
   if (!openal_context || (alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not create current device context: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   alcMakeContextCurrent(openal_context);
#if !defined ALLEGRO_IPHONE
   if ((alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not make context current: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   alDistanceModel(AL_NONE);
   if ((openal_err = alGetError()) != AL_NO_ERROR) {
      ALLEGRO_ERROR("Could not set distance model: %s\n",
         openal_get_err_str(openal_err));
      return 1;
   }
#endif

   ALLEGRO_DEBUG("Vendor: %s\n", alGetString(AL_VENDOR));
   ALLEGRO_DEBUG("Version: %s\n", alGetString(AL_VERSION));
   ALLEGRO_DEBUG("Renderer: %s\n", alGetString(AL_RENDERER));
   ALLEGRO_DEBUG("Extensions: %s\n", alGetString(AL_EXTENSIONS));

   return 0;
}
开发者ID:allefant,项目名称:allegro5,代码行数:54,代码来源:openal.c

示例15: alcOpenDevice

//TODO: ENABLE OPTIONS FOR AUDIO
bool SoundManager::_initAL()
{
	SingletonLogMgr::Instance()->AddNewLine("SoundManager::InitAL","Initializing sound system...",LOGNORMAL);
	
	ALenum error;
	ALCdevice* pDevice;
	ALCcontext* pContext;

	SingletonLogMgr::Instance()->AddNewLine("SoundManager::InitAL","Opening default sound device...",LOGNORMAL);
	// Get handle to default device.
	pDevice = alcOpenDevice(NULL);

	if(pDevice == NULL)
		throw GenericException("Cant open default sound device. Reinstall drivers and check audio device configuration",GenericException::LIBRARY_ERROR);

	SingletonLogMgr::Instance()->AddNewLine("SoundManager::InitAL","Default sound device opened",LOGNORMAL);

	// Create audio context.
	pContext = alcCreateContext(pDevice, NULL);
	if(pContext == NULL)
		throw GenericException("Cant open default sound device. Reinstall drivers and check audio device configuration",GenericException::LIBRARY_ERROR);
	// Set active context.
	alcMakeContextCurrent(pContext);

	// Check for an error.
	if ((error=alcGetError(pDevice)) != ALC_NO_ERROR)
	{
		SingletonLogMgr::Instance()->AddNewLine("SoundManager::InitAL","Can't create openAL context (" + GetALErrorString(error,true) + ")",LOGEXCEPTION);
		throw(GenericException("Can't create openAL context (" + GetALErrorString(error,true) + ")",GenericException::LIBRARY_ERROR));
	}

	SingletonLogMgr::Instance()->AddNewLine("SoundManager::InitAL","Sound system initialized correctly",LOGNORMAL);
	return true;
}
开发者ID:DarthMike,项目名称:Monkey-Madness,代码行数:35,代码来源:SoundManager.cpp


注:本文中的alcGetError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。