コード例 #1
0
ファイル: device.cpp プロジェクト: cpp-mirrors/alure
void ALDevice::reset(const Vector<AttributePair> &attributes)
{
    if(!hasExtension(SOFT_HRTF))
        throw std::runtime_error("ALC_SOFT_HRTF not supported");
    auto do_reset = [this, &attributes]() -> ALCboolean
    {
        if(attributes.empty())
        {
            /* No explicit attributes. */
            return alcResetDeviceSOFT(mDevice, nullptr);
        }
        auto attr_end = std::find_if(attributes.begin(), attributes.end(),
            [](const AttributePair &attr) -> bool
            { return std::get<0>(attr) == 0; }
        );
        if(attr_end == attributes.end())
        {
            /* Attribute list was not properly terminated. Copy the attribute
             * list and add the 0 sentinel.
             */
            Vector<AttributePair> attrs = attributes;
            attrs.push_back({0, 0});
            return alcResetDeviceSOFT(mDevice, &std::get<0>(attrs.front()));
        }
        return alcResetDeviceSOFT(mDevice, &std::get<0>(attributes.front()));
    };
    if(!do_reset())
        throw std::runtime_error("Device reset error");
}
コード例 #2
0
ファイル: Audio.cpp プロジェクト: nemerle/lutefisk3d
 bool recreateContext(int freq)
 {
     if (!device)
     {
         URHO3D_LOGERROR("Failed to create OpenAL context, device is not open");
         return false;
     }
     if (freq == 0)
     {
         ALCint dev_rate = 0;
         alcGetIntegerv(device, ALC_FREQUENCY, 1, &dev_rate);
         if (ALC_NO_ERROR == alcGetError(device))
             freq = dev_rate;
     }
     ALCint attrvalues[] = {ALC_FREQUENCY, freq, 0};
     alGetError();
     if (!context)
     {
         context = alcCreateContext(device, attrvalues);
     }
     else
     {
         assert(alcResetDeviceSOFT!=nullptr);
         alcResetDeviceSOFT(device, attrvalues);
     }
     if (!alcMakeContextCurrent(context))
     {
         auto errorcode = alGetError();
         URHO3D_LOGERROR(QString("Failed to create OpenAL context: alerror = %1").arg(errorcode));
         return false;
     }
     return true;
 }
コード例 #3
0
	void audio_device::reset_device(audio_settings settings) {
#if BUILD_OPENAL
		ALCint attrs[] = {
			ALC_HRTF_SOFT, settings.enable_hrtf, /* request HRTF */
			ALC_MONO_SOURCES, static_cast<ALCint>(settings.max_number_of_sound_sources),
		   	0	/* end of list */
		};

		alcResetDeviceSOFT(device, attrs);
		AL_CHECK_DEVICE(device);
		log_hrtf_status();
#else
		(void)settings;
#endif
	}