MCPcopy Create free account
hub / github.com/Illation/ETEngine / LoadFromMemory

Method LoadFromMemory

Engine/source/EtFramework/Audio/AudioData.cpp:62–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60// Load audio data from binary asset content
61//
62bool AudioAsset::LoadFromMemory(std::vector<uint8> const& data)
63{
64 std::string extension = core::FileUtil::ExtractExtension(GetName());
65
66 bool dataLoaded = false;
67 AudioBufferData bufferData;
68
69 if (extension == "wav")
70 {
71 dataLoaded = LoadWavFile(bufferData, data);
72 }
73 else if (extension == "ogg")
74 {
75 dataLoaded = LoadOggFile(bufferData, data);
76 }
77 else
78 {
79 LOG("AudioAsset::LoadFromMemory > Cannot load audio data with this extension! Supported exensions: [.wav/.ogg]", core::LogLevel::Warning);
80 return false;
81 }
82
83 if (!dataLoaded)
84 {
85 LOG("AudioAsset::LoadFromMemory > Failed to load audio buffer data!", core::LogLevel::Warning);
86 return false;
87 }
88
89 if (m_IsMonoForced)
90 {
91 ConvertToMono(bufferData);
92 }
93
94 ALuint buffer;
95 alGenBuffers(1, &buffer);
96 alBufferData(buffer, bufferData.format, bufferData.data, bufferData.size, bufferData.frequency);
97
98 if (AudioManager::GetInstance()->TestALError("Audio Loader alBufferData error"))
99 {
100 LOG("AudioAsset::LoadFromMemory > Failed - open AL error!", core::LogLevel::Warning);
101 return false;
102 }
103
104 delete[] bufferData.data;
105
106 m_Data = new AudioData(buffer);
107
108 // all done
109 return true;
110}
111
112//---------------------------------
113// AudioAsset::LoadWavFile

Callers

nothing calls this directly

Calls 1

TestALErrorMethod · 0.80

Tested by

no test coverage detected