1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 16:24:35 +01:00

Add ogg vorbis support

This commit is contained in:
Ted John
2022-05-14 03:05:03 +01:00
parent 73ac7954f1
commit 274bd921b3
8 changed files with 261 additions and 14 deletions

View File

@@ -12,6 +12,8 @@
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../audio/AudioContext.h"
#include "../audio/AudioSource.h"
#include "../core/IStream.hpp"
#include "../core/Json.hpp"
#include "../core/Path.hpp"
@@ -30,10 +32,30 @@ void MusicObject::Load()
GetStringTable().Sort();
NameStringId = language_allocate_object_string(GetName());
auto audioContext = GetContext()->GetAudioContext();
for (auto& track : _tracks)
{
track.BytesPerTick = DEFAULT_BYTES_PER_TICK;
track.Size = track.Asset.GetSize();
auto stream = track.Asset.GetStream();
if (stream != nullptr)
{
auto source = audioContext->CreateStreamFromWAV(std::move(stream));
if (source != nullptr)
{
track.BytesPerTick = source->GetBytesPerSecond() / 40;
track.Size = source->GetLength();
source->Release();
}
else
{
track.BytesPerTick = DEFAULT_BYTES_PER_TICK;
track.Size = track.Asset.GetSize();
}
}
else
{
track.BytesPerTick = DEFAULT_BYTES_PER_TICK;
track.Size = track.Asset.GetSize();
}
}
}