1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-09 16:04:33 +00:00

Use normalized path for sound decoder

This commit is contained in:
elsid 2024-04-14 19:51:10 +02:00
parent e11a5a4352
commit 40cc16046b
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
5 changed files with 11 additions and 13 deletions

View file

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

View file

@ -93,7 +93,7 @@ namespace MWSound
bool getAVAudioData(); bool getAVAudioData();
size_t readAVAudioData(void* data, size_t length); 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; void close() override;
std::string getName() override; std::string getName() override;

View file

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

View file

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

View file

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