Use normalized path for sound decoder

pull/3235/head
elsid 1 month ago
parent e11a5a4352
commit 40cc16046b
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -208,7 +208,7 @@ namespace MWSound
return dec;
}
void FFmpeg_Decoder::open(const std::string& fname)
void FFmpeg_Decoder::open(VFS::Path::NormalizedView fname)
{
close();
mDataStream = mResourceMgr->get(fname);
@ -224,7 +224,7 @@ namespace MWSound
formatCtx->pb = ioCtx.get();
// avformat_open_input frees user supplied AVFormatContext on failure
if (avformat_open_input(&formatCtx, fname.c_str(), nullptr, nullptr) != 0)
if (avformat_open_input(&formatCtx, fname.value().data(), nullptr, nullptr) != 0)
throw std::runtime_error("Failed to open input");
AVFormatContextPtr formatCtxPtr(std::exchange(formatCtx, nullptr));

@ -93,7 +93,7 @@ namespace MWSound
bool getAVAudioData();
size_t readAVAudioData(void* data, size_t length);
void open(const std::string& fname) override;
void open(VFS::Path::NormalizedView fname) override;
void close() override;
std::string getName() override;

@ -24,8 +24,10 @@ namespace MWSound
private:
MWSound::MovieAudioDecoder* mDecoder;
void open(const std::string& fname) override;
void close() override;
void open(VFS::Path::NormalizedView fname) override { throw std::runtime_error("Method not implemented"); }
void close() override {}
std::string getName() override;
void getInfo(int* samplerate, ChannelConfig* chans, SampleType* type) override;
size_t read(char* buffer, size_t bytes) override;
@ -92,12 +94,6 @@ namespace MWSound
std::shared_ptr<MWSoundDecoderBridge> mDecoderBridge;
};
void MWSoundDecoderBridge::open(const std::string& fname)
{
throw std::runtime_error("Method not implemented");
}
void MWSoundDecoderBridge::close() {}
std::string MWSoundDecoderBridge::getName()
{
return mDecoder->getStreamName();

@ -1,6 +1,8 @@
#ifndef GAME_SOUND_SOUND_DECODER_H
#define GAME_SOUND_SOUND_DECODER_H
#include <components/vfs/pathutil.hpp>
#include <string>
#include <vector>
@ -36,7 +38,7 @@ namespace MWSound
{
const VFS::Manager* mResourceMgr;
virtual void open(const std::string& fname) = 0;
virtual void open(VFS::Path::NormalizedView fname) = 0;
virtual void close() = 0;
virtual std::string getName() = 0;

@ -267,7 +267,7 @@ namespace MWSound
DecoderPtr decoder = getDecoder();
try
{
decoder->open(filename);
decoder->open(VFS::Path::Normalized(filename));
}
catch (std::exception& e)
{

Loading…
Cancel
Save