MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / LoadSound

Method LoadSound

LuaSTGPlus/ResourceMgr.cpp:907–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

905}
906
907bool ResourcePool::LoadSound(const char* name, const std::wstring& path)LNOEXCEPT
908{
909 LDEBUG_RESOURCETIMER;
910
911 {
912 LDEBUG_RESOURCESCOPE;
913
914 LASSERT(LAPP.GetSoundSys());
915
916 fcyRefPointer<fcyMemStream> tDataBuf;
917 if (!m_pMgr->LoadFile(path.c_str(), tDataBuf))
918 return false;
919
920 try
921 {
922 fcyRefPointer<f2dSoundDecoder> tDecoder;
923 if (FCYFAILED(LAPP.GetSoundSys()->CreateWaveDecoder(tDataBuf, &tDecoder)))
924 {
925 tDataBuf->SetPosition(FCYSEEKORIGIN_BEG, 0);
926 if (FCYFAILED(LAPP.GetSoundSys()->CreateOGGVorbisDecoder(tDataBuf, &tDecoder)))
927 {
928 LERROR("LoadSound: �޷������ļ�'%s'", path.c_str());
929 return false;
930 }
931 }
932
933 fcyRefPointer<f2dSoundBuffer> tBuffer;
934 if (FCYFAILED(LAPP.GetSoundSys()->CreateStaticBuffer(tDecoder, LSOUNDGLOBALFOCUS, &tBuffer)))
935 {
936 LERROR("LoadSound: �޷�������Ƶ���������ļ�'%s' (f2dSoundSys::CreateStaticBuffer failed.)", path.c_str());
937 return false;
938 }
939
940 fcyRefPointer<ResSound> tRes;
941 tRes.DirectSet(new ResSound(name, tBuffer));
942 m_SoundSpritePool.emplace(name, tRes);
943 }
944 catch (const fcyException& e)
945 {
946 LERROR("LoadSound: �����ļ�'%s'����Ƶ����ʱ�������󣬸�ʽ��֧�֣� (�쳣��Ϣ'%m' Դ'%m')", path.c_str(), e.GetDesc(), e.GetSrc());
947 return false;
948 }
949 catch (const bad_alloc&)
950 {
951 LERROR("LoadSound: �ڴ治��");
952 return false;
953 }
954
955#ifdef LSHOWRESLOADINFO
956 LINFO("LoadSound: ��Ч'%m'��װ�� (%s)", name, getResourcePoolTypeName());
957#endif
958 }
959
960 LDEBUG_RESOURCEHINT(ResourceType::SoundEffect, path.c_str());
961 return true;
962}
963
964LNOINLINE bool ResourcePool::LoadSound(const char* name, const char* path)LNOEXCEPT

Callers

nothing calls this directly

Calls 3

GetSoundSysMethod · 0.80
LoadFileMethod · 0.80
SetPositionMethod · 0.80

Tested by

no test coverage detected