Rename apps/openmw/mwsound files and classes to follow naming conventions

This commit is contained in:
Alexei Kotov 2025-02-22 23:45:51 +03:00
parent fc850cfe69
commit 72cbf61b43
17 changed files with 185 additions and 194 deletions

View file

@ -1,9 +0,0 @@
apps/openmw/mwsound/efx-presets.h
apps/openmw/mwsound/ffmpeg_decoder.cpp
apps/openmw/mwsound/ffmpeg_decoder.hpp
apps/openmw/mwsound/openal_output.cpp
apps/openmw/mwsound/openal_output.hpp
apps/openmw/mwsound/sound_buffer.cpp
apps/openmw/mwsound/sound_buffer.hpp
apps/openmw/mwsound/sound_decoder.hpp
apps/openmw/mwsound/sound_output.hpp

View file

@ -71,8 +71,8 @@ add_openmw_dir (mwlua
) )
add_openmw_dir (mwsound add_openmw_dir (mwsound
soundmanagerimp openal_output ffmpeg_decoder sound sound_buffer sound_decoder sound_output soundmanagerimp openaloutput ffmpegdecoder sound soundbuffer sounddecoder soundoutput
loudness movieaudiofactory alext efx efx-presets regionsoundselector watersoundupdater loudness movieaudiofactory alext efx efxpresets regionsoundselector watersoundupdater
) )
add_openmw_dir (mwworld add_openmw_dir (mwworld

View file

@ -39,8 +39,8 @@ namespace MWSound
class Sound; class Sound;
class Stream; class Stream;
struct Sound_Decoder; struct SoundDecoder;
typedef std::shared_ptr<Sound_Decoder> DecoderPtr; typedef std::shared_ptr<SoundDecoder> DecoderPtr;
/* These must all fit together */ /* These must all fit together */
enum class PlayMode enum class PlayMode

View file

@ -1,7 +1,7 @@
/* Reverb presets for EFX */ /* Reverb presets for EFX */
#ifndef EFX_PRESETS_H #ifndef GAME_SOUND_EFXPRESETS_H
#define EFX_PRESETS_H #define GAME_SOUND_EFXPRESETS_H
#ifndef EFXEAXREVERBPROPERTIES_DEFINED #ifndef EFXEAXREVERBPROPERTIES_DEFINED
#define EFXEAXREVERBPROPERTIES_DEFINED #define EFXEAXREVERBPROPERTIES_DEFINED
@ -852,4 +852,4 @@ typedef struct
0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 \ 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 \
} }
#endif /* EFX_PRESETS_H */ #endif

View file

@ -1,4 +1,4 @@
#include "ffmpeg_decoder.hpp" #include "ffmpegdecoder.hpp"
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
@ -44,11 +44,11 @@ namespace MWSound
av_frame_free(&ptr); av_frame_free(&ptr);
} }
int FFmpeg_Decoder::readPacket(void* user_data, uint8_t* buf, int buf_size) int FFmpegDecoder::readPacket(void* user_data, uint8_t* buf, int buf_size)
{ {
try try
{ {
std::istream& stream = *static_cast<FFmpeg_Decoder*>(user_data)->mDataStream; std::istream& stream = *static_cast<FFmpegDecoder*>(user_data)->mDataStream;
stream.clear(); stream.clear();
stream.read((char*)buf, buf_size); stream.read((char*)buf, buf_size);
std::streamsize count = stream.gcount(); std::streamsize count = stream.gcount();
@ -65,18 +65,18 @@ namespace MWSound
} }
#if OPENMW_FFMPEG_CONST_WRITEPACKET #if OPENMW_FFMPEG_CONST_WRITEPACKET
int FFmpeg_Decoder::writePacket(void*, const uint8_t*, int) int FFmpegDecoder::writePacket(void*, const uint8_t*, int)
#else #else
int FFmpeg_Decoder::writePacket(void*, uint8_t*, int) int FFmpegDecoder::writePacket(void*, uint8_t*, int)
#endif #endif
{ {
Log(Debug::Error) << "can't write to read-only stream"; Log(Debug::Error) << "can't write to read-only stream";
return -1; return -1;
} }
int64_t FFmpeg_Decoder::seek(void* user_data, int64_t offset, int whence) int64_t FFmpegDecoder::seek(void* user_data, int64_t offset, int whence)
{ {
std::istream& stream = *static_cast<FFmpeg_Decoder*>(user_data)->mDataStream; std::istream& stream = *static_cast<FFmpegDecoder*>(user_data)->mDataStream;
whence &= ~AVSEEK_FORCE; whence &= ~AVSEEK_FORCE;
@ -106,7 +106,7 @@ namespace MWSound
/* Used by getAV*Data to search for more compressed data, and buffer it in the /* Used by getAV*Data to search for more compressed data, and buffer it in the
* correct stream. It won't buffer data for streams that the app doesn't have a * correct stream. It won't buffer data for streams that the app doesn't have a
* handle for. */ * handle for. */
bool FFmpeg_Decoder::getNextPacket() bool FFmpegDecoder::getNextPacket()
{ {
if (!mStream) if (!mStream)
return false; return false;
@ -129,7 +129,7 @@ namespace MWSound
return false; return false;
} }
bool FFmpeg_Decoder::getAVAudioData() bool FFmpegDecoder::getAVAudioData()
{ {
bool got_frame = false; bool got_frame = false;
@ -192,7 +192,7 @@ namespace MWSound
return true; return true;
} }
size_t FFmpeg_Decoder::readAVAudioData(void* data, size_t length) size_t FFmpegDecoder::readAVAudioData(void* data, size_t length)
{ {
size_t dec = 0; size_t dec = 0;
@ -227,7 +227,7 @@ namespace MWSound
return dec; return dec;
} }
void FFmpeg_Decoder::open(VFS::Path::NormalizedView fname) void FFmpegDecoder::open(VFS::Path::NormalizedView fname)
{ {
close(); close();
mDataStream = mResourceMgr->get(fname); mDataStream = mResourceMgr->get(fname);
@ -317,7 +317,7 @@ namespace MWSound
mStream = stream; mStream = stream;
} }
void FFmpeg_Decoder::close() void FFmpegDecoder::close()
{ {
mStream = nullptr; mStream = nullptr;
mCodecCtx.reset(); mCodecCtx.reset();
@ -332,7 +332,7 @@ namespace MWSound
mDataStream.reset(); mDataStream.reset();
} }
std::string FFmpeg_Decoder::getName() std::string FFmpegDecoder::getName()
{ {
// In the FFMpeg 4.0 a "filename" field was replaced by "url" // In the FFMpeg 4.0 a "filename" field was replaced by "url"
#if LIBAVCODEC_VERSION_INT < 3805796 #if LIBAVCODEC_VERSION_INT < 3805796
@ -342,7 +342,7 @@ namespace MWSound
#endif #endif
} }
void FFmpeg_Decoder::getInfo(int* samplerate, ChannelConfig* chans, SampleType* type) void FFmpegDecoder::getInfo(int* samplerate, ChannelConfig* chans, SampleType* type)
{ {
if (!mStream) if (!mStream)
throw std::runtime_error("No audio stream info"); throw std::runtime_error("No audio stream info");
@ -459,7 +459,7 @@ namespace MWSound
} }
} }
size_t FFmpeg_Decoder::read(char* buffer, size_t bytes) size_t FFmpegDecoder::read(char* buffer, size_t bytes)
{ {
if (!mStream) if (!mStream)
{ {
@ -469,7 +469,7 @@ namespace MWSound
return readAVAudioData(buffer, bytes); return readAVAudioData(buffer, bytes);
} }
void FFmpeg_Decoder::readAll(std::vector<char>& output) void FFmpegDecoder::readAll(std::vector<char>& output)
{ {
if (!mStream) if (!mStream)
{ {
@ -490,7 +490,7 @@ namespace MWSound
} }
} }
size_t FFmpeg_Decoder::getSampleOffset() size_t FFmpegDecoder::getSampleOffset()
{ {
#if OPENMW_FFMPEG_5_OR_GREATER #if OPENMW_FFMPEG_5_OR_GREATER
std::size_t delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels std::size_t delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels
@ -501,8 +501,8 @@ namespace MWSound
return static_cast<std::size_t>(mNextPts * mCodecCtx->sample_rate) - delay; return static_cast<std::size_t>(mNextPts * mCodecCtx->sample_rate) - delay;
} }
FFmpeg_Decoder::FFmpeg_Decoder(const VFS::Manager* vfs) FFmpegDecoder::FFmpegDecoder(const VFS::Manager* vfs)
: Sound_Decoder(vfs) : SoundDecoder(vfs)
, mStream(nullptr) , mStream(nullptr)
, mFrameSize(0) , mFrameSize(0)
, mFramePos(0) , mFramePos(0)
@ -534,7 +534,7 @@ namespace MWSound
} }
} }
FFmpeg_Decoder::~FFmpeg_Decoder() FFmpegDecoder::~FFmpegDecoder()
{ {
close(); close();
} }

View file

@ -1,5 +1,5 @@
#ifndef GAME_SOUND_FFMPEG_DECODER_H #ifndef GAME_SOUND_FFMPEGDECODER_H
#define GAME_SOUND_FFMPEG_DECODER_H #define GAME_SOUND_FFMPEGDECODER_H
#include <cstdint> #include <cstdint>
@ -31,7 +31,7 @@ extern "C"
#include <string> #include <string>
#include "sound_decoder.hpp" #include "sounddecoder.hpp"
namespace MWSound namespace MWSound
{ {
@ -63,7 +63,7 @@ namespace MWSound
using AVFramePtr = std::unique_ptr<AVFrame, AVFrameDeleter>; using AVFramePtr = std::unique_ptr<AVFrame, AVFrameDeleter>;
class FFmpeg_Decoder final : public Sound_Decoder class FFmpegDecoder final : public SoundDecoder
{ {
AVIOContextPtr mIoCtx; AVIOContextPtr mIoCtx;
AVFormatContextPtr mFormatCtx; AVFormatContextPtr mFormatCtx;
@ -114,13 +114,13 @@ namespace MWSound
void readAll(std::vector<char>& output) override; void readAll(std::vector<char>& output) override;
size_t getSampleOffset() override; size_t getSampleOffset() override;
FFmpeg_Decoder& operator=(const FFmpeg_Decoder& rhs); FFmpegDecoder& operator=(const FFmpegDecoder& rhs);
FFmpeg_Decoder(const FFmpeg_Decoder& rhs); FFmpegDecoder(const FFmpegDecoder& rhs);
public: public:
explicit FFmpeg_Decoder(const VFS::Manager* vfs); explicit FFmpegDecoder(const VFS::Manager* vfs);
virtual ~FFmpeg_Decoder(); virtual ~FFmpegDecoder();
friend class SoundManager; friend class SoundManager;
}; };

View file

@ -4,7 +4,7 @@
#include <deque> #include <deque>
#include <vector> #include <vector>
#include "sound_decoder.hpp" #include "sounddecoder.hpp"
namespace MWSound namespace MWSound
{ {

View file

@ -7,17 +7,17 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "sound_decoder.hpp" #include "sounddecoder.hpp"
namespace MWSound namespace MWSound
{ {
class MovieAudioDecoder; class MovieAudioDecoder;
class MWSoundDecoderBridge final : public Sound_Decoder class MWSoundDecoderBridge final : public SoundDecoder
{ {
public: public:
MWSoundDecoderBridge(MWSound::MovieAudioDecoder* decoder) MWSoundDecoderBridge(MWSound::MovieAudioDecoder* decoder)
: Sound_Decoder(nullptr) : SoundDecoder(nullptr)
, mDecoder(decoder) , mDecoder(decoder)
{ {
} }

View file

@ -17,14 +17,13 @@
#include <components/misc/thread.hpp> #include <components/misc/thread.hpp>
#include <components/vfs/manager.hpp> #include <components/vfs/manager.hpp>
#include "efxpresets.h"
#include "loudness.hpp" #include "loudness.hpp"
#include "openal_output.hpp" #include "openaloutput.hpp"
#include "sound.hpp" #include "sound.hpp"
#include "sound_decoder.hpp" #include "sounddecoder.hpp"
#include "soundmanagerimp.hpp" #include "soundmanagerimp.hpp"
#include "efx-presets.h"
#ifndef ALC_ALL_DEVICES_SPECIFIER #ifndef ALC_ALL_DEVICES_SPECIFIER
#define ALC_ALL_DEVICES_SPECIFIER 0x1013 #define ALC_ALL_DEVICES_SPECIFIER 0x1013
#endif #endif
@ -301,7 +300,7 @@ namespace MWSound
OpenAL_SoundStream(const OpenAL_SoundStream& rhs); OpenAL_SoundStream(const OpenAL_SoundStream& rhs);
OpenAL_SoundStream& operator=(const OpenAL_SoundStream& rhs); OpenAL_SoundStream& operator=(const OpenAL_SoundStream& rhs);
friend class OpenAL_Output; friend class OpenALOutput;
public: public:
OpenAL_SoundStream(ALuint src, DecoderPtr decoder); OpenAL_SoundStream(ALuint src, DecoderPtr decoder);
@ -323,7 +322,7 @@ namespace MWSound
// //
// A background streaming thread (keeps active streams processed) // A background streaming thread (keeps active streams processed)
// //
struct OpenAL_Output::StreamThread struct OpenALOutput::StreamThread
{ {
std::vector<OpenAL_SoundStream*> mStreams; std::vector<OpenAL_SoundStream*> mStreams;
@ -393,13 +392,13 @@ namespace MWSound
StreamThread& operator=(const StreamThread& rhs) = delete; StreamThread& operator=(const StreamThread& rhs) = delete;
}; };
class OpenAL_Output::DefaultDeviceThread class OpenALOutput::DefaultDeviceThread
{ {
public: public:
std::basic_string<ALCchar> mCurrentName; std::basic_string<ALCchar> mCurrentName;
private: private:
OpenAL_Output& mOutput; OpenALOutput& mOutput;
std::atomic<bool> mQuitNow; std::atomic<bool> mQuitNow;
std::mutex mMutex; std::mutex mMutex;
@ -433,7 +432,7 @@ namespace MWSound
} }
public: public:
DefaultDeviceThread(OpenAL_Output& output, std::basic_string_view<ALCchar> name = {}) DefaultDeviceThread(OpenALOutput& output, std::basic_string_view<ALCchar> name = {})
: mCurrentName(name) : mCurrentName(name)
, mOutput(output) , mOutput(output)
, mQuitNow(false) , mQuitNow(false)
@ -655,7 +654,7 @@ namespace MWSound
// //
// An OpenAL output device // An OpenAL output device
// //
std::vector<std::string> OpenAL_Output::enumerate() std::vector<std::string> OpenALOutput::enumerate()
{ {
std::vector<std::string> devlist; std::vector<std::string> devlist;
const ALCchar* devnames; const ALCchar* devnames;
@ -672,14 +671,14 @@ namespace MWSound
return devlist; return devlist;
} }
void OpenAL_Output::eventCallback( void OpenALOutput::eventCallback(
ALenum eventType, ALuint object, ALuint param, ALsizei length, const ALchar* message, void* userParam) ALenum eventType, ALuint object, ALuint param, ALsizei length, const ALchar* message, void* userParam)
{ {
if (eventType == AL_EVENT_TYPE_DISCONNECTED_SOFT) if (eventType == AL_EVENT_TYPE_DISCONNECTED_SOFT)
static_cast<OpenAL_Output*>(userParam)->onDisconnect(); static_cast<OpenALOutput*>(userParam)->onDisconnect();
} }
void OpenAL_Output::onDisconnect() void OpenALOutput::onDisconnect()
{ {
if (!mInitialized || !alcReopenDeviceSOFT) if (!mInitialized || !alcReopenDeviceSOFT)
return; return;
@ -702,7 +701,7 @@ namespace MWSound
} }
} }
bool OpenAL_Output::init(const std::string& devname, const std::string& hrtfname, HrtfMode hrtfmode) bool OpenALOutput::init(const std::string& devname, const std::string& hrtfname, HrtfMode hrtfmode)
{ {
deinit(); deinit();
std::lock_guard<std::mutex> lock(mReopenMutex); std::lock_guard<std::mutex> lock(mReopenMutex);
@ -802,7 +801,7 @@ namespace MWSound
{ {
static const std::array<ALenum, 1> events{ { AL_EVENT_TYPE_DISCONNECTED_SOFT } }; static const std::array<ALenum, 1> events{ { AL_EVENT_TYPE_DISCONNECTED_SOFT } };
alEventControlSOFT(events.size(), events.data(), AL_TRUE); alEventControlSOFT(events.size(), events.data(), AL_TRUE);
alEventCallbackSOFT(&OpenAL_Output::eventCallback, this); alEventCallbackSOFT(&OpenALOutput::eventCallback, this);
} }
else else
Log(Debug::Warning) << "Cannot detect audio device changes"; Log(Debug::Warning) << "Cannot detect audio device changes";
@ -970,7 +969,7 @@ namespace MWSound
return true; return true;
} }
void OpenAL_Output::deinit() void OpenALOutput::deinit()
{ {
mStreamThread->removeAll(); mStreamThread->removeAll();
mDefaultDeviceThread.reset(); mDefaultDeviceThread.reset();
@ -1006,7 +1005,7 @@ namespace MWSound
mInitialized = false; mInitialized = false;
} }
std::vector<std::string> OpenAL_Output::enumerateHrtf() std::vector<std::string> OpenALOutput::enumerateHrtf()
{ {
std::vector<std::string> ret; std::vector<std::string> ret;
@ -1028,7 +1027,7 @@ namespace MWSound
return ret; return ret;
} }
std::pair<Sound_Handle, size_t> OpenAL_Output::loadSound(VFS::Path::NormalizedView fname) std::pair<Sound_Handle, size_t> OpenALOutput::loadSound(VFS::Path::NormalizedView fname)
{ {
getALError(); getALError();
@ -1076,7 +1075,7 @@ namespace MWSound
return std::make_pair(MAKE_PTRID(buf), size); return std::make_pair(MAKE_PTRID(buf), size);
} }
size_t OpenAL_Output::unloadSound(Sound_Handle data) size_t OpenALOutput::unloadSound(Sound_Handle data)
{ {
ALuint buffer = GET_PTRID(data); ALuint buffer = GET_PTRID(data);
if (!buffer) if (!buffer)
@ -1105,7 +1104,7 @@ namespace MWSound
return size; return size;
} }
void OpenAL_Output::initCommon2D( void OpenALOutput::initCommon2D(
ALuint source, const osg::Vec3f& pos, ALfloat gain, ALfloat pitch, bool loop, bool useenv) ALuint source, const osg::Vec3f& pos, ALfloat gain, ALfloat pitch, bool loop, bool useenv)
{ {
alSourcef(source, AL_REFERENCE_DISTANCE, 1.0f); alSourcef(source, AL_REFERENCE_DISTANCE, 1.0f);
@ -1143,7 +1142,7 @@ namespace MWSound
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
} }
void OpenAL_Output::initCommon3D(ALuint source, const osg::Vec3f& pos, ALfloat mindist, ALfloat maxdist, void OpenALOutput::initCommon3D(ALuint source, const osg::Vec3f& pos, ALfloat mindist, ALfloat maxdist,
ALfloat gain, ALfloat pitch, bool loop, bool useenv) ALfloat gain, ALfloat pitch, bool loop, bool useenv)
{ {
alSourcef(source, AL_REFERENCE_DISTANCE, mindist); alSourcef(source, AL_REFERENCE_DISTANCE, mindist);
@ -1183,7 +1182,7 @@ namespace MWSound
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
} }
void OpenAL_Output::updateCommon( void OpenALOutput::updateCommon(
ALuint source, const osg::Vec3f& pos, ALfloat maxdist, ALfloat gain, ALfloat pitch, bool useenv) ALuint source, const osg::Vec3f& pos, ALfloat maxdist, ALfloat gain, ALfloat pitch, bool useenv)
{ {
if (useenv && mListenerEnv == Env_Underwater && !mWaterFilter) if (useenv && mListenerEnv == Env_Underwater && !mWaterFilter)
@ -1199,7 +1198,7 @@ namespace MWSound
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
} }
bool OpenAL_Output::playSound(Sound* sound, Sound_Handle data, float offset) bool OpenALOutput::playSound(Sound* sound, Sound_Handle data, float offset)
{ {
ALuint source; ALuint source;
@ -1238,7 +1237,7 @@ namespace MWSound
return true; return true;
} }
bool OpenAL_Output::playSound3D(Sound* sound, Sound_Handle data, float offset) bool OpenALOutput::playSound3D(Sound* sound, Sound_Handle data, float offset)
{ {
ALuint source; ALuint source;
@ -1277,7 +1276,7 @@ namespace MWSound
return true; return true;
} }
void OpenAL_Output::finishSound(Sound* sound) void OpenALOutput::finishSound(Sound* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return; return;
@ -1294,7 +1293,7 @@ namespace MWSound
mActiveSounds.erase(std::find(mActiveSounds.begin(), mActiveSounds.end(), sound)); mActiveSounds.erase(std::find(mActiveSounds.begin(), mActiveSounds.end(), sound));
} }
bool OpenAL_Output::isSoundPlaying(Sound* sound) bool OpenALOutput::isSoundPlaying(Sound* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return false; return false;
@ -1307,7 +1306,7 @@ namespace MWSound
return state == AL_PLAYING || state == AL_PAUSED; return state == AL_PLAYING || state == AL_PAUSED;
} }
void OpenAL_Output::updateSound(Sound* sound) void OpenALOutput::updateSound(Sound* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return; return;
@ -1318,7 +1317,7 @@ namespace MWSound
getALError(); getALError();
} }
bool OpenAL_Output::streamSound(DecoderPtr decoder, Stream* sound, bool getLoudnessData) bool OpenALOutput::streamSound(DecoderPtr decoder, Stream* sound, bool getLoudnessData)
{ {
if (mFreeSources.empty()) if (mFreeSources.empty())
{ {
@ -1349,7 +1348,7 @@ namespace MWSound
return true; return true;
} }
bool OpenAL_Output::streamSound3D(DecoderPtr decoder, Stream* sound, bool getLoudnessData) bool OpenALOutput::streamSound3D(DecoderPtr decoder, Stream* sound, bool getLoudnessData)
{ {
if (mFreeSources.empty()) if (mFreeSources.empty())
{ {
@ -1380,7 +1379,7 @@ namespace MWSound
return true; return true;
} }
void OpenAL_Output::finishStream(Stream* sound) void OpenALOutput::finishStream(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return; return;
@ -1402,7 +1401,7 @@ namespace MWSound
delete stream; delete stream;
} }
double OpenAL_Output::getStreamDelay(Stream* sound) double OpenALOutput::getStreamDelay(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return 0.0; return 0.0;
@ -1410,7 +1409,7 @@ namespace MWSound
return stream->getStreamDelay(); return stream->getStreamDelay();
} }
double OpenAL_Output::getStreamOffset(Stream* sound) double OpenALOutput::getStreamOffset(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return 0.0; return 0.0;
@ -1419,7 +1418,7 @@ namespace MWSound
return stream->getStreamOffset(); return stream->getStreamOffset();
} }
float OpenAL_Output::getStreamLoudness(Stream* sound) float OpenALOutput::getStreamLoudness(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return 0.0; return 0.0;
@ -1428,7 +1427,7 @@ namespace MWSound
return stream->getCurrentLoudness(); return stream->getCurrentLoudness();
} }
bool OpenAL_Output::isStreamPlaying(Stream* sound) bool OpenALOutput::isStreamPlaying(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return false; return false;
@ -1437,7 +1436,7 @@ namespace MWSound
return stream->isPlaying(); return stream->isPlaying();
} }
void OpenAL_Output::updateStream(Stream* sound) void OpenALOutput::updateStream(Stream* sound)
{ {
if (!sound->mHandle) if (!sound->mHandle)
return; return;
@ -1449,17 +1448,17 @@ namespace MWSound
getALError(); getALError();
} }
void OpenAL_Output::startUpdate() void OpenALOutput::startUpdate()
{ {
alcSuspendContext(alcGetCurrentContext()); alcSuspendContext(alcGetCurrentContext());
} }
void OpenAL_Output::finishUpdate() void OpenALOutput::finishUpdate()
{ {
alcProcessContext(alcGetCurrentContext()); alcProcessContext(alcGetCurrentContext());
} }
void OpenAL_Output::updateListener( void OpenALOutput::updateListener(
const osg::Vec3f& pos, const osg::Vec3f& atdir, const osg::Vec3f& updir, Environment env) const osg::Vec3f& pos, const osg::Vec3f& atdir, const osg::Vec3f& updir, Environment env)
{ {
if (mContext) if (mContext)
@ -1501,7 +1500,7 @@ namespace MWSound
mListenerEnv = env; mListenerEnv = env;
} }
void OpenAL_Output::pauseSounds(int types) void OpenALOutput::pauseSounds(int types)
{ {
std::vector<ALuint> sources; std::vector<ALuint> sources;
for (Sound* sound : mActiveSounds) for (Sound* sound : mActiveSounds)
@ -1524,7 +1523,7 @@ namespace MWSound
} }
} }
void OpenAL_Output::pauseActiveDevice() void OpenALOutput::pauseActiveDevice()
{ {
if (mDevice == nullptr) if (mDevice == nullptr)
return; return;
@ -1540,7 +1539,7 @@ namespace MWSound
alListenerf(AL_GAIN, 0.0f); alListenerf(AL_GAIN, 0.0f);
} }
void OpenAL_Output::resumeActiveDevice() void OpenALOutput::resumeActiveDevice()
{ {
if (mDevice == nullptr) if (mDevice == nullptr)
return; return;
@ -1556,7 +1555,7 @@ namespace MWSound
alListenerf(AL_GAIN, 1.0f); alListenerf(AL_GAIN, 1.0f);
} }
void OpenAL_Output::resumeSounds(int types) void OpenALOutput::resumeSounds(int types)
{ {
std::vector<ALuint> sources; std::vector<ALuint> sources;
for (Sound* sound : mActiveSounds) for (Sound* sound : mActiveSounds)
@ -1579,8 +1578,8 @@ namespace MWSound
} }
} }
OpenAL_Output::OpenAL_Output(SoundManager& mgr) OpenALOutput::OpenALOutput(SoundManager& mgr)
: Sound_Output(mgr) : SoundOutput(mgr)
, mDevice(nullptr) , mDevice(nullptr)
, mContext(nullptr) , mContext(nullptr)
, mListenerPos(0.0f, 0.0f, 0.0f) , mListenerPos(0.0f, 0.0f, 0.0f)
@ -1593,12 +1592,12 @@ namespace MWSound
{ {
} }
OpenAL_Output::~OpenAL_Output() OpenALOutput::~OpenALOutput()
{ {
OpenAL_Output::deinit(); OpenALOutput::deinit();
} }
float OpenAL_Output::getTimeScaledPitch(SoundBase* sound) float OpenALOutput::getTimeScaledPitch(SoundBase* sound)
{ {
const bool shouldScale = !(sound->mParams.mFlags & PlayMode::NoScaling); const bool shouldScale = !(sound->mParams.mFlags & PlayMode::NoScaling);
return shouldScale ? sound->getPitch() * mManager.getSimulationTimeScale() : sound->getPitch(); return shouldScale ? sound->getPitch() * mManager.getSimulationTimeScale() : sound->getPitch();

View file

@ -1,5 +1,5 @@
#ifndef GAME_SOUND_OPENAL_OUTPUT_H #ifndef GAME_SOUND_OPENALOUTPUT_H
#define GAME_SOUND_OPENAL_OUTPUT_H #define GAME_SOUND_OPENALOUTPUT_H
#include <deque> #include <deque>
#include <map> #include <map>
@ -13,7 +13,7 @@
#include "alc.h" #include "alc.h"
#include "alext.h" #include "alext.h"
#include "sound_output.hpp" #include "soundoutput.hpp"
namespace MWSound namespace MWSound
{ {
@ -22,7 +22,7 @@ namespace MWSound
class Sound; class Sound;
class Stream; class Stream;
class OpenAL_Output : public Sound_Output class OpenALOutput : public SoundOutput
{ {
ALCdevice* mDevice; ALCdevice* mDevice;
ALCcontext* mContext; ALCcontext* mContext;
@ -72,8 +72,8 @@ namespace MWSound
float getTimeScaledPitch(SoundBase* sound); float getTimeScaledPitch(SoundBase* sound);
OpenAL_Output& operator=(const OpenAL_Output& rhs); OpenALOutput& operator=(const OpenALOutput& rhs);
OpenAL_Output(const OpenAL_Output& rhs); OpenALOutput(const OpenALOutput& rhs);
static void eventCallback( static void eventCallback(
ALenum eventType, ALuint object, ALuint param, ALsizei length, const ALchar* message, void* userParam); ALenum eventType, ALuint object, ALuint param, ALsizei length, const ALchar* message, void* userParam);
@ -117,8 +117,8 @@ namespace MWSound
void pauseActiveDevice() override; void pauseActiveDevice() override;
void resumeActiveDevice() override; void resumeActiveDevice() override;
OpenAL_Output(SoundManager& mgr); OpenALOutput(SoundManager& mgr);
virtual ~OpenAL_Output(); virtual ~OpenALOutput();
}; };
} }

View file

@ -3,7 +3,7 @@
#include <algorithm> #include <algorithm>
#include "sound_output.hpp" #include "soundoutput.hpp"
namespace MWSound namespace MWSound
{ {
@ -53,7 +53,7 @@ namespace MWSound
protected: protected:
Sound_Instance mHandle = nullptr; Sound_Instance mHandle = nullptr;
friend class OpenAL_Output; friend class OpenALOutput;
public: public:
void setPosition(const osg::Vec3f& pos) { mParams.mPos = pos; } void setPosition(const osg::Vec3f& pos) { mParams.mPos = pos; }

View file

@ -1,4 +1,4 @@
#include "sound_buffer.hpp" #include "soundbuffer.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
@ -35,7 +35,7 @@ namespace MWSound
} }
} }
SoundBufferPool::SoundBufferPool(Sound_Output& output) SoundBufferPool::SoundBufferPool(SoundOutput& output)
: mOutput(&output) : mOutput(&output)
, mBufferCacheMax(Settings::sound().mBufferCacheMax * 1024 * 1024) , mBufferCacheMax(Settings::sound().mBufferCacheMax * 1024 * 1024)
, mBufferCacheMin( , mBufferCacheMin(
@ -48,31 +48,31 @@ namespace MWSound
clear(); clear();
} }
Sound_Buffer* SoundBufferPool::lookup(const ESM::RefId& soundId) const SoundBuffer* SoundBufferPool::lookup(const ESM::RefId& soundId) const
{ {
const auto it = mBufferNameMap.find(soundId); const auto it = mBufferNameMap.find(soundId);
if (it != mBufferNameMap.end()) if (it != mBufferNameMap.end())
{ {
Sound_Buffer* sfx = it->second; SoundBuffer* sfx = it->second;
if (sfx->getHandle() != nullptr) if (sfx->getHandle() != nullptr)
return sfx; return sfx;
} }
return nullptr; return nullptr;
} }
Sound_Buffer* SoundBufferPool::lookup(std::string_view fileName) const SoundBuffer* SoundBufferPool::lookup(std::string_view fileName) const
{ {
const auto it = mBufferFileNameMap.find(std::string(fileName)); const auto it = mBufferFileNameMap.find(std::string(fileName));
if (it != mBufferFileNameMap.end()) if (it != mBufferFileNameMap.end())
{ {
Sound_Buffer* sfx = it->second; SoundBuffer* sfx = it->second;
if (sfx->getHandle() != nullptr) if (sfx->getHandle() != nullptr)
return sfx; return sfx;
} }
return nullptr; return nullptr;
} }
Sound_Buffer* SoundBufferPool::loadSfx(Sound_Buffer* sfx) SoundBuffer* SoundBufferPool::loadSfx(SoundBuffer* sfx)
{ {
if (sfx->getHandle() != nullptr) if (sfx->getHandle() != nullptr)
return sfx; return sfx;
@ -95,7 +95,7 @@ namespace MWSound
return sfx; return sfx;
} }
Sound_Buffer* SoundBufferPool::load(const ESM::RefId& soundId) SoundBuffer* SoundBufferPool::load(const ESM::RefId& soundId)
{ {
if (mBufferNameMap.empty()) if (mBufferNameMap.empty())
{ {
@ -103,7 +103,7 @@ namespace MWSound
insertSound(sound.mId, sound); insertSound(sound.mId, sound);
} }
Sound_Buffer* sfx; SoundBuffer* sfx;
const auto it = mBufferNameMap.find(soundId); const auto it = mBufferNameMap.find(soundId);
if (it != mBufferNameMap.end()) if (it != mBufferNameMap.end())
sfx = it->second; sfx = it->second;
@ -118,9 +118,9 @@ namespace MWSound
return loadSfx(sfx); return loadSfx(sfx);
} }
Sound_Buffer* SoundBufferPool::load(std::string_view fileName) SoundBuffer* SoundBufferPool::load(std::string_view fileName)
{ {
Sound_Buffer* sfx; SoundBuffer* sfx;
const auto it = mBufferFileNameMap.find(std::string(fileName)); const auto it = mBufferFileNameMap.find(std::string(fileName));
if (it != mBufferFileNameMap.end()) if (it != mBufferFileNameMap.end())
sfx = it->second; sfx = it->second;
@ -146,7 +146,7 @@ namespace MWSound
mUnusedBuffers.clear(); mUnusedBuffers.clear();
} }
Sound_Buffer* SoundBufferPool::insertSound(std::string_view fileName) SoundBuffer* SoundBufferPool::insertSound(std::string_view fileName)
{ {
static const AudioParams audioParams static const AudioParams audioParams
= makeAudioParams(MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>()); = makeAudioParams(MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>());
@ -158,13 +158,13 @@ namespace MWSound
min = std::max(min, 1.0f); min = std::max(min, 1.0f);
max = std::max(min, max); max = std::max(min, max);
Sound_Buffer& sfx = mSoundBuffers.emplace_back(fileName, volume, min, max); SoundBuffer& sfx = mSoundBuffers.emplace_back(fileName, volume, min, max);
mBufferFileNameMap.emplace(fileName, &sfx); mBufferFileNameMap.emplace(fileName, &sfx);
return &sfx; return &sfx;
} }
Sound_Buffer* SoundBufferPool::insertSound(const ESM::RefId& soundId, const ESM::Sound& sound) SoundBuffer* SoundBufferPool::insertSound(const ESM::RefId& soundId, const ESM::Sound& sound)
{ {
static const AudioParams audioParams static const AudioParams audioParams
= makeAudioParams(MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>()); = makeAudioParams(MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>());
@ -183,7 +183,7 @@ namespace MWSound
min = std::max(min, 1.0f); min = std::max(min, 1.0f);
max = std::max(min, max); max = std::max(min, max);
Sound_Buffer& sfx = mSoundBuffers.emplace_back( SoundBuffer& sfx = mSoundBuffers.emplace_back(
Misc::ResourceHelpers::correctSoundPath(VFS::Path::Normalized(sound.mSound)), volume, min, max); Misc::ResourceHelpers::correctSoundPath(VFS::Path::Normalized(sound.mSound)), volume, min, max);
mBufferNameMap.emplace(soundId, &sfx); mBufferNameMap.emplace(soundId, &sfx);
@ -194,7 +194,7 @@ namespace MWSound
{ {
while (!mUnusedBuffers.empty() && mBufferCacheSize > mBufferCacheMin) while (!mUnusedBuffers.empty() && mBufferCacheSize > mBufferCacheMin)
{ {
Sound_Buffer* const unused = mUnusedBuffers.back(); SoundBuffer* const unused = mUnusedBuffers.back();
mBufferCacheSize -= mOutput->unloadSound(unused->getHandle()); mBufferCacheSize -= mOutput->unloadSound(unused->getHandle());
unused->mHandle = nullptr; unused->mHandle = nullptr;

View file

@ -1,14 +1,15 @@
#ifndef GAME_SOUND_SOUND_BUFFER_H #ifndef GAME_SOUND_SOUNDBUFFER_H
#define GAME_SOUND_SOUND_BUFFER_H #define GAME_SOUND_SOUNDBUFFER_H
#include <algorithm> #include <algorithm>
#include <deque> #include <deque>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "sound_output.hpp"
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include "soundoutput.hpp"
namespace ESM namespace ESM
{ {
struct Sound; struct Sound;
@ -23,11 +24,11 @@ namespace MWSound
{ {
class SoundBufferPool; class SoundBufferPool;
class Sound_Buffer class SoundBuffer
{ {
public: public:
template <class T> template <class T>
Sound_Buffer(T&& resname, float volume, float mindist, float maxdist) SoundBuffer(T&& resname, float volume, float mindist, float maxdist)
: mResourceName(std::forward<T>(resname)) : mResourceName(std::forward<T>(resname))
, mVolume(volume) , mVolume(volume)
, mMinDist(mindist) , mMinDist(mindist)
@ -59,7 +60,7 @@ namespace MWSound
class SoundBufferPool class SoundBufferPool
{ {
public: public:
SoundBufferPool(Sound_Output& output); SoundBufferPool(SoundOutput& output);
SoundBufferPool(const SoundBufferPool&) = delete; SoundBufferPool(const SoundBufferPool&) = delete;
@ -67,20 +68,20 @@ namespace MWSound
/// Lookup a soundId for its sound data (resource name, local volume, /// Lookup a soundId for its sound data (resource name, local volume,
/// minRange, and maxRange) /// minRange, and maxRange)
Sound_Buffer* lookup(const ESM::RefId& soundId) const; SoundBuffer* lookup(const ESM::RefId& soundId) const;
/// Lookup a sound by file name for its sound data (resource name, local volume, /// Lookup a sound by file name for its sound data (resource name, local volume,
/// minRange, and maxRange) /// minRange, and maxRange)
Sound_Buffer* lookup(std::string_view fileName) const; SoundBuffer* lookup(std::string_view fileName) const;
/// Lookup a soundId for its sound data (resource name, local volume, /// Lookup a soundId for its sound data (resource name, local volume,
/// minRange, and maxRange), and ensure it's ready for use. /// minRange, and maxRange), and ensure it's ready for use.
Sound_Buffer* load(const ESM::RefId& soundId); SoundBuffer* load(const ESM::RefId& soundId);
// Lookup for a sound by file name, and ensure it's ready for use. // Lookup for a sound by file name, and ensure it's ready for use.
Sound_Buffer* load(std::string_view fileName); SoundBuffer* load(std::string_view fileName);
void use(Sound_Buffer& sfx) void use(SoundBuffer& sfx)
{ {
if (sfx.mUses++ == 0) if (sfx.mUses++ == 0)
{ {
@ -90,7 +91,7 @@ namespace MWSound
} }
} }
void release(Sound_Buffer& sfx) void release(SoundBuffer& sfx)
{ {
if (--sfx.mUses == 0) if (--sfx.mUses == 0)
mUnusedBuffers.push_front(&sfx); mUnusedBuffers.push_front(&sfx);
@ -99,23 +100,23 @@ namespace MWSound
void clear(); void clear();
private: private:
Sound_Buffer* loadSfx(Sound_Buffer* sfx); SoundBuffer* loadSfx(SoundBuffer* sfx);
Sound_Output* mOutput; SoundOutput* mOutput;
std::deque<Sound_Buffer> mSoundBuffers; std::deque<SoundBuffer> mSoundBuffers;
std::unordered_map<ESM::RefId, Sound_Buffer*> mBufferNameMap; std::unordered_map<ESM::RefId, SoundBuffer*> mBufferNameMap;
std::unordered_map<std::string, Sound_Buffer*> mBufferFileNameMap; std::unordered_map<std::string, SoundBuffer*> mBufferFileNameMap;
std::size_t mBufferCacheMax; std::size_t mBufferCacheMax;
std::size_t mBufferCacheMin; std::size_t mBufferCacheMin;
std::size_t mBufferCacheSize = 0; std::size_t mBufferCacheSize = 0;
// NOTE: unused buffers are stored in front-newest order. // NOTE: unused buffers are stored in front-newest order.
std::deque<Sound_Buffer*> mUnusedBuffers; std::deque<SoundBuffer*> mUnusedBuffers;
inline Sound_Buffer* insertSound(const ESM::RefId& soundId, const ESM::Sound& sound); inline SoundBuffer* insertSound(const ESM::RefId& soundId, const ESM::Sound& sound);
inline Sound_Buffer* insertSound(std::string_view fileName); inline SoundBuffer* insertSound(std::string_view fileName);
inline void unloadUnused(); inline void unloadUnused();
}; };
} }
#endif /* GAME_SOUND_SOUND_BUFFER_H */ #endif /* GAME_SOUND_SOUNDBUFFER_H */

View file

@ -1,5 +1,5 @@
#ifndef GAME_SOUND_SOUND_DECODER_H #ifndef GAME_SOUND_SOUNDDECODER_H
#define GAME_SOUND_SOUND_DECODER_H #define GAME_SOUND_SOUNDDECODER_H
#include <components/vfs/pathutil.hpp> #include <components/vfs/pathutil.hpp>
@ -34,7 +34,7 @@ namespace MWSound
size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type); size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type);
size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type); size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type);
struct Sound_Decoder struct SoundDecoder
{ {
const VFS::Manager* mResourceMgr; const VFS::Manager* mResourceMgr;
@ -48,15 +48,15 @@ namespace MWSound
virtual void readAll(std::vector<char>& output); virtual void readAll(std::vector<char>& output);
virtual size_t getSampleOffset() = 0; virtual size_t getSampleOffset() = 0;
Sound_Decoder(const VFS::Manager* resourceMgr) SoundDecoder(const VFS::Manager* resourceMgr)
: mResourceMgr(resourceMgr) : mResourceMgr(resourceMgr)
{ {
} }
virtual ~Sound_Decoder() {} virtual ~SoundDecoder() {}
private: private:
Sound_Decoder(const Sound_Decoder& rhs); SoundDecoder(const SoundDecoder& rhs);
Sound_Decoder& operator=(const Sound_Decoder& rhs); SoundDecoder& operator=(const SoundDecoder& rhs);
}; };
} }

View file

@ -26,12 +26,12 @@
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "ffmpeg_decoder.hpp" #include "ffmpegdecoder.hpp"
#include "openal_output.hpp" #include "openaloutput.hpp"
#include "sound.hpp" #include "sound.hpp"
#include "sound_buffer.hpp" #include "soundbuffer.hpp"
#include "sound_decoder.hpp" #include "sounddecoder.hpp"
#include "sound_output.hpp" #include "soundoutput.hpp"
namespace MWSound namespace MWSound
{ {
@ -57,7 +57,7 @@ namespace MWSound
return settings; return settings;
} }
float initialFadeVolume(float squaredDist, Sound_Buffer* sfx, Type type, PlayMode mode) float initialFadeVolume(float squaredDist, SoundBuffer* sfx, Type type, PlayMode mode)
{ {
// If a sound is farther away than its maximum distance, start playing it with a zero fade volume. // If a sound is farther away than its maximum distance, start playing it with a zero fade volume.
// It can still become audible once the player moves closer. // It can still become audible once the player moves closer.
@ -111,7 +111,7 @@ namespace MWSound
SoundManager::SoundManager(const VFS::Manager* vfs, bool useSound) SoundManager::SoundManager(const VFS::Manager* vfs, bool useSound)
: mVFS(vfs) : mVFS(vfs)
, mOutput(std::make_unique<OpenAL_Output>(*this)) , mOutput(std::make_unique<OpenALOutput>(*this))
, mWaterSoundUpdater(makeWaterSoundUpdaterSettings()) , mWaterSoundUpdater(makeWaterSoundUpdaterSettings())
, mSoundBuffers(*mOutput) , mSoundBuffers(*mOutput)
, mMusicType(MWSound::MusicType::Normal) , mMusicType(MWSound::MusicType::Normal)
@ -169,7 +169,7 @@ namespace MWSound
// Return a new decoder instance, used as needed by the output implementations // Return a new decoder instance, used as needed by the output implementations
DecoderPtr SoundManager::getDecoder() DecoderPtr SoundManager::getDecoder()
{ {
return std::make_shared<FFmpeg_Decoder>(mVFS); return std::make_shared<FFmpegDecoder>(mVFS);
} }
DecoderPtr SoundManager::loadVoice(VFS::Path::NormalizedView voicefile) DecoderPtr SoundManager::loadVoice(VFS::Path::NormalizedView voicefile)
@ -459,7 +459,7 @@ namespace MWSound
return false; return false;
} }
Sound* SoundManager::playSound(Sound_Buffer* sfx, float volume, float pitch, Type type, PlayMode mode, float offset) Sound* SoundManager::playSound(SoundBuffer* sfx, float volume, float pitch, Type type, PlayMode mode, float offset)
{ {
if (!mOutput->isInitialized()) if (!mOutput->isInitialized())
return nullptr; return nullptr;
@ -495,7 +495,7 @@ namespace MWSound
if (!mVFS->exists(normalizedName)) if (!mVFS->exists(normalizedName))
return nullptr; return nullptr;
Sound_Buffer* sfx = mSoundBuffers.load(normalizedName); SoundBuffer* sfx = mSoundBuffers.load(normalizedName);
if (!sfx) if (!sfx)
return nullptr; return nullptr;
@ -508,14 +508,14 @@ namespace MWSound
if (!mOutput->isInitialized()) if (!mOutput->isInitialized())
return nullptr; return nullptr;
Sound_Buffer* sfx = mSoundBuffers.load(soundId); SoundBuffer* sfx = mSoundBuffers.load(soundId);
if (!sfx) if (!sfx)
return nullptr; return nullptr;
return playSound(sfx, volume, pitch, type, mode, offset); return playSound(sfx, volume, pitch, type, mode, offset);
} }
Sound* SoundManager::playSound3D(const MWWorld::ConstPtr& ptr, Sound_Buffer* sfx, float volume, float pitch, Sound* SoundManager::playSound3D(const MWWorld::ConstPtr& ptr, SoundBuffer* sfx, float volume, float pitch,
Type type, PlayMode mode, float offset) Type type, PlayMode mode, float offset)
{ {
if (!mOutput->isInitialized()) if (!mOutput->isInitialized())
@ -576,7 +576,7 @@ namespace MWSound
return nullptr; return nullptr;
// Look up the sound in the ESM data // Look up the sound in the ESM data
Sound_Buffer* sfx = mSoundBuffers.load(soundId); SoundBuffer* sfx = mSoundBuffers.load(soundId);
if (!sfx) if (!sfx)
return nullptr; return nullptr;
@ -594,7 +594,7 @@ namespace MWSound
if (!mVFS->exists(normalizedName)) if (!mVFS->exists(normalizedName))
return nullptr; return nullptr;
Sound_Buffer* sfx = mSoundBuffers.load(normalizedName); SoundBuffer* sfx = mSoundBuffers.load(normalizedName);
if (!sfx) if (!sfx)
return nullptr; return nullptr;
@ -608,7 +608,7 @@ namespace MWSound
return nullptr; return nullptr;
// Look up the sound in the ESM data // Look up the sound in the ESM data
Sound_Buffer* sfx = mSoundBuffers.load(soundId); SoundBuffer* sfx = mSoundBuffers.load(soundId);
if (!sfx) if (!sfx)
return nullptr; return nullptr;
@ -642,7 +642,7 @@ namespace MWSound
mOutput->finishSound(sound); mOutput->finishSound(sound);
} }
void SoundManager::stopSound(Sound_Buffer* sfx, const MWWorld::ConstPtr& ptr) void SoundManager::stopSound(SoundBuffer* sfx, const MWWorld::ConstPtr& ptr)
{ {
SoundMap::iterator snditer = mActiveSounds.find(ptr.mRef); SoundMap::iterator snditer = mActiveSounds.find(ptr.mRef);
if (snditer != mActiveSounds.end()) if (snditer != mActiveSounds.end())
@ -660,7 +660,7 @@ namespace MWSound
if (!mOutput->isInitialized()) if (!mOutput->isInitialized())
return; return;
Sound_Buffer* sfx = mSoundBuffers.lookup(soundId); SoundBuffer* sfx = mSoundBuffers.lookup(soundId);
if (!sfx) if (!sfx)
return; return;
@ -673,7 +673,7 @@ namespace MWSound
return; return;
std::string normalizedName = VFS::Path::normalizeFilename(fileName); std::string normalizedName = VFS::Path::normalizeFilename(fileName);
Sound_Buffer* sfx = mSoundBuffers.lookup(normalizedName); SoundBuffer* sfx = mSoundBuffers.lookup(normalizedName);
if (!sfx) if (!sfx)
return; return;
@ -725,7 +725,7 @@ namespace MWSound
SoundMap::iterator snditer = mActiveSounds.find(ptr.mRef); SoundMap::iterator snditer = mActiveSounds.find(ptr.mRef);
if (snditer != mActiveSounds.end()) if (snditer != mActiveSounds.end())
{ {
Sound_Buffer* sfx = mSoundBuffers.lookup(soundId); SoundBuffer* sfx = mSoundBuffers.lookup(soundId);
if (sfx == nullptr) if (sfx == nullptr)
return; return;
for (SoundBufferRefPair& sndbuf : snditer->second.mList) for (SoundBufferRefPair& sndbuf : snditer->second.mList)
@ -743,7 +743,7 @@ namespace MWSound
SoundMap::const_iterator snditer = mActiveSounds.find(ptr.mRef); SoundMap::const_iterator snditer = mActiveSounds.find(ptr.mRef);
if (snditer != mActiveSounds.end()) if (snditer != mActiveSounds.end())
{ {
Sound_Buffer* sfx = mSoundBuffers.lookup(normalizedName); SoundBuffer* sfx = mSoundBuffers.lookup(normalizedName);
if (!sfx) if (!sfx)
return false; return false;
@ -761,7 +761,7 @@ namespace MWSound
SoundMap::const_iterator snditer = mActiveSounds.find(ptr.mRef); SoundMap::const_iterator snditer = mActiveSounds.find(ptr.mRef);
if (snditer != mActiveSounds.end()) if (snditer != mActiveSounds.end())
{ {
Sound_Buffer* sfx = mSoundBuffers.lookup(soundId); SoundBuffer* sfx = mSoundBuffers.lookup(soundId);
if (!sfx) if (!sfx)
return false; return false;
@ -846,7 +846,7 @@ namespace MWSound
const auto update = mWaterSoundUpdater.update(player, *world); const auto update = mWaterSoundUpdater.update(player, *world);
WaterSoundAction action; WaterSoundAction action;
Sound_Buffer* sfx; SoundBuffer* sfx;
std::tie(action, sfx) = getWaterSoundAction(update, curcell); std::tie(action, sfx) = getWaterSoundAction(update, curcell);
switch (action) switch (action)
@ -870,7 +870,7 @@ namespace MWSound
mLastCell = curcell; mLastCell = curcell;
} }
std::pair<SoundManager::WaterSoundAction, Sound_Buffer*> SoundManager::getWaterSoundAction( std::pair<SoundManager::WaterSoundAction, SoundBuffer*> SoundManager::getWaterSoundAction(
const WaterSoundUpdate& update, const MWWorld::Cell* cell) const const WaterSoundUpdate& update, const MWWorld::Cell* cell) const
{ {
if (mNearWaterSound) if (mNearWaterSound)
@ -880,7 +880,7 @@ namespace MWSound
bool soundIdChanged = false; bool soundIdChanged = false;
Sound_Buffer* sfx = mSoundBuffers.lookup(update.mId); SoundBuffer* sfx = mSoundBuffers.lookup(update.mId);
if (mLastCell != cell) if (mLastCell != cell)
{ {
const auto snditer = mActiveSounds.find(nullptr); const auto snditer = mActiveSounds.find(nullptr);
@ -1168,7 +1168,7 @@ namespace MWSound
// Default readAll implementation, for decoders that can't do anything // Default readAll implementation, for decoders that can't do anything
// better // better
void Sound_Decoder::readAll(std::vector<char>& output) void SoundDecoder::readAll(std::vector<char>& output)
{ {
size_t total = output.size(); size_t total = output.size();
size_t got; size_t got;

View file

@ -15,7 +15,7 @@
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "regionsoundselector.hpp" #include "regionsoundselector.hpp"
#include "sound_buffer.hpp" #include "soundbuffer.hpp"
#include "type.hpp" #include "type.hpp"
#include "watersoundupdater.hpp" #include "watersoundupdater.hpp"
@ -37,8 +37,8 @@ namespace MWWorld
namespace MWSound namespace MWSound
{ {
class Sound_Output; class SoundOutput;
struct Sound_Decoder; struct SoundDecoder;
class SoundBase; class SoundBase;
class Sound; class Sound;
class Stream; class Stream;
@ -50,7 +50,7 @@ namespace MWSound
{ {
const VFS::Manager* mVFS; const VFS::Manager* mVFS;
std::unique_ptr<Sound_Output> mOutput; std::unique_ptr<SoundOutput> mOutput;
WaterSoundUpdater mWaterSoundUpdater; WaterSoundUpdater mWaterSoundUpdater;
@ -60,7 +60,7 @@ namespace MWSound
Misc::ObjectPool<Stream> mStreams; Misc::ObjectPool<Stream> mStreams;
typedef std::pair<SoundPtr, Sound_Buffer*> SoundBufferRefPair; typedef std::pair<SoundPtr, SoundBuffer*> SoundBufferRefPair;
typedef std::vector<SoundBufferRefPair> SoundBufferRefPairList; typedef std::vector<SoundBufferRefPair> SoundBufferRefPairList;
struct ActiveSound struct ActiveSound
@ -109,7 +109,7 @@ namespace MWSound
Sound* mCurrentRegionSound; Sound* mCurrentRegionSound;
Sound_Buffer* insertSound(const std::string& soundId, const ESM::Sound* sound); SoundBuffer* insertSound(const std::string& soundId, const ESM::Sound* sound);
// returns a decoder to start streaming, or nullptr if the sound was not found // returns a decoder to start streaming, or nullptr if the sound was not found
DecoderPtr loadVoice(VFS::Path::NormalizedView voicefile); DecoderPtr loadVoice(VFS::Path::NormalizedView voicefile);
@ -126,9 +126,9 @@ namespace MWSound
bool remove3DSoundAtDistance(PlayMode mode, const MWWorld::ConstPtr& ptr) const; bool remove3DSoundAtDistance(PlayMode mode, const MWWorld::ConstPtr& ptr) const;
Sound* playSound(Sound_Buffer* sfx, float volume, float pitch, Type type = Type::Sfx, Sound* playSound(SoundBuffer* sfx, float volume, float pitch, Type type = Type::Sfx,
PlayMode mode = PlayMode::Normal, float offset = 0); PlayMode mode = PlayMode::Normal, float offset = 0);
Sound* playSound3D(const MWWorld::ConstPtr& ptr, Sound_Buffer* sfx, float volume, float pitch, Type type, Sound* playSound3D(const MWWorld::ConstPtr& ptr, SoundBuffer* sfx, float volume, float pitch, Type type,
PlayMode mode, float offset); PlayMode mode, float offset);
void updateSounds(float duration); void updateSounds(float duration);
@ -144,7 +144,7 @@ namespace MWSound
PlaySound, PlaySound,
}; };
std::pair<WaterSoundAction, Sound_Buffer*> getWaterSoundAction( std::pair<WaterSoundAction, SoundBuffer*> getWaterSoundAction(
const WaterSoundUpdate& update, const MWWorld::Cell* cell) const; const WaterSoundUpdate& update, const MWWorld::Cell* cell) const;
SoundManager(const SoundManager& rhs); SoundManager(const SoundManager& rhs);
@ -152,9 +152,9 @@ namespace MWSound
protected: protected:
DecoderPtr getDecoder(); DecoderPtr getDecoder();
friend class OpenAL_Output; friend class OpenALOutput;
void stopSound(Sound_Buffer* sfx, const MWWorld::ConstPtr& ptr); void stopSound(SoundBuffer* sfx, const MWWorld::ConstPtr& ptr);
///< Stop the given object from playing given sound buffer. ///< Stop the given object from playing given sound buffer.
public: public:

View file

@ -1,5 +1,5 @@
#ifndef GAME_SOUND_SOUND_OUTPUT_H #ifndef GAME_SOUND_SOUNDOUTPUT_H
#define GAME_SOUND_SOUND_OUTPUT_H #define GAME_SOUND_SOUNDOUTPUT_H
#include <memory> #include <memory>
#include <string> #include <string>
@ -13,7 +13,7 @@
namespace MWSound namespace MWSound
{ {
class SoundManager; class SoundManager;
struct Sound_Decoder; struct SoundDecoder;
class Sound; class Sound;
class Stream; class Stream;
@ -30,7 +30,7 @@ namespace MWSound
using HrtfMode = Settings::HrtfMode; using HrtfMode = Settings::HrtfMode;
class Sound_Output class SoundOutput
{ {
SoundManager& mManager; SoundManager& mManager;
@ -71,24 +71,24 @@ namespace MWSound
virtual void pauseActiveDevice() = 0; virtual void pauseActiveDevice() = 0;
virtual void resumeActiveDevice() = 0; virtual void resumeActiveDevice() = 0;
Sound_Output& operator=(const Sound_Output& rhs); SoundOutput& operator=(const SoundOutput& rhs);
Sound_Output(const Sound_Output& rhs); SoundOutput(const SoundOutput& rhs);
protected: protected:
bool mInitialized; bool mInitialized;
Sound_Output(SoundManager& mgr) SoundOutput(SoundManager& mgr)
: mManager(mgr) : mManager(mgr)
, mInitialized(false) , mInitialized(false)
{ {
} }
public: public:
virtual ~Sound_Output() {} virtual ~SoundOutput() {}
bool isInitialized() const { return mInitialized; } bool isInitialized() const { return mInitialized; }
friend class OpenAL_Output; friend class OpenALOutput;
friend class SoundManager; friend class SoundManager;
friend class SoundBufferPool; friend class SoundBufferPool;
}; };