本文整理汇总了C++中Sound::DecRef方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::DecRef方法的具体用法?C++ Sound::DecRef怎么用?C++ Sound::DecRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sound
的用法示例。
在下文中一共展示了Sound::DecRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDLSound
Sound *Sound::Create(float *inData, int len, bool inForceMusic) {
if (!Init())
return 0;
Sound *sound = inForceMusic ? 0 : new SDLSound(inData, len);
if (!sound || !sound->ok())
{
if (sound) sound->DecRef();
sound = new SDLMusic(inData, len);
}
return sound;
}
示例2: SDLSound
Sound *Sound::Create(const std::string &inFilename,bool inForceMusic)
{
if (!Init())
return 0;
Sound *sound = inForceMusic ? 0 : new SDLSound(inFilename);
if (!sound || !sound->ok())
{
if (sound) sound->DecRef();
sound = new SDLMusic(inFilename);
}
return sound;
}
示例3: ReadAndCreate
Sound *Sound::FromFile(const std::string &inFilename, bool inForceMusic, const std::string &inEngine)
{
Sound *result = 0;
#ifdef HX_ANDROID
if (inEngine=="opensl")
result = ReadAndCreate(inFilename, inForceMusic, CreateOpenSlSound);
else
result = CreateAndroidSound(inFilename,inForceMusic);
#elif defined(IPHONE)
AudioFormat format = determineFormatFromFile(inFilename);
if (format==eAF_mp3 || (inForceMusic && format!=eAF_ogg && format!=eAF_mid ) || inEngine=="avplayer" )
result = CreateAvPlayerSound(inFilename);
else
result = ReadAndCreate(inFilename, inForceMusic, CreateOpenAlSound);
#elif defined(EMSCRIPTEN)
result = ReadAndCreate(inFilename, inForceMusic, CreateOpenAlSound);
#else
#ifdef HX_MACOS
if (inEngine=="openal")
result = ReadAndCreate(inFilename, inForceMusic, CreateOpenAlSound);
else
#endif
result = CreateSdlSound(inFilename,inForceMusic);
#endif
if (result && !result->ok())
{
result->DecRef();
result = 0;
}
if (!result)
ELOG("Error creating sound from filename %s", inFilename.c_str() );
return result;
}
示例4: CreateOpenSlSound
Sound *Sound::FromEncodedBytes(const unsigned char *inData, int inLen, bool inForceMusic, const std::string &inEngine)
{
Sound *result = 0;
#ifdef HX_ANDROID
// Maybe use opensl here ....
if (inEngine=="opensl")
result = CreateOpenSlSound(inData, inLen, inForceMusic);
else
result = CreateAndroidSound(inData, inLen, inForceMusic);
#elif defined(IPHONE)
// AVPlayer must be used to play mp3 files
// OpenAl must be used to play ogg and mid
// OpenAl allows small files to be cached in buffers
// AVPlayer as better hardware pathways
AudioFormat format = determineFormatFromBytes(inData, inLen);
if (format==eAF_mp3 || (inForceMusic && format!=eAF_ogg && format!=eAF_mid ) )
result = CreateAvPlayerSound(inData,inLen);
else
result = CreateOpenAlSound(inData, inLen, inForceMusic);
#elif defined(EMSCRIPTEN)
result = CreateOpenAlSound(inData, inLen, inForceMusic);
if (!result || !result->ok())
{
if (result)
result->DecRef();
result = CreateSdlSound(inData, inLen, inForceMusic);
}
#else
#ifdef HX_MACOS
// Openal can be tested on mac
if (inEngine=="openal")
{
result = CreateOpenAlSound(inData, inLen, inForceMusic);
}
else
#endif
result = CreateSdlSound(inData, inLen, inForceMusic);
#endif
if (result && !result->ok())
{
result->DecRef();
result = 0;
}
if (!result)
ELOG("Error creating sound from %d bytes", inLen);
return result;
}