parent
8ca77f27a1
commit
6dcf4dffa6
|
@ -94,7 +94,7 @@ set(BASE_SOURCES
|
||||||
common/resources/outputstreambuffer.cpp
|
common/resources/outputstreambuffer.cpp
|
||||||
common/resources/resourcemanager.cpp
|
common/resources/resourcemanager.cpp
|
||||||
common/resources/sdl_file_wrapper.cpp
|
common/resources/sdl_file_wrapper.cpp
|
||||||
common/resources/sndfile.cpp
|
common/resources/sndfile_wrapper.cpp
|
||||||
common/restext.cpp
|
common/restext.cpp
|
||||||
common/stringutils.cpp
|
common/stringutils.cpp
|
||||||
graphics/core/color.cpp
|
graphics/core/color.cpp
|
||||||
|
|
|
@ -112,9 +112,9 @@ std::unique_ptr<CSDLFileWrapper> CResourceManager::GetSDLFileHandler(const std::
|
||||||
return std::unique_ptr<CSDLFileWrapper>(new CSDLFileWrapper(CleanPath(filename)));
|
return std::unique_ptr<CSDLFileWrapper>(new CSDLFileWrapper(CleanPath(filename)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CSNDFile> CResourceManager::GetSNDFileHandler(const std::string &filename)
|
std::unique_ptr<CSNDFileWrapper> CResourceManager::GetSNDFileHandler(const std::string &filename)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<CSNDFile>(new CSNDFile(CleanPath(filename)));
|
return std::unique_ptr<CSNDFileWrapper>(new CSNDFileWrapper(CleanPath(filename)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/resources/sndfile.h"
|
#include "common/resources/sndfile_wrapper.h"
|
||||||
#include "common/resources/sdl_file_wrapper.h"
|
#include "common/resources/sdl_file_wrapper.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
static std::string GetSaveLocation();
|
static std::string GetSaveLocation();
|
||||||
|
|
||||||
static std::unique_ptr<CSDLFileWrapper> GetSDLFileHandler(const std::string &filename);
|
static std::unique_ptr<CSDLFileWrapper> GetSDLFileHandler(const std::string &filename);
|
||||||
static std::unique_ptr<CSNDFile> GetSNDFileHandler(const std::string &filename);
|
static std::unique_ptr<CSNDFileWrapper> GetSNDFileHandler(const std::string &filename);
|
||||||
|
|
||||||
//! Check if file exists
|
//! Check if file exists
|
||||||
static bool Exists(const std::string &filename);
|
static bool Exists(const std::string &filename);
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
* along with this program. If not, see http://gnu.org/licenses
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/resources/sndfile.h"
|
#include "common/resources/sndfile_wrapper.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
CSNDFile::CSNDFile(const std::string& filename)
|
CSNDFileWrapper::CSNDFileWrapper(const std::string& filename)
|
||||||
: m_file_info{}
|
: m_file_info{}
|
||||||
, m_snd_file{nullptr}
|
, m_snd_file{nullptr}
|
||||||
, m_file{nullptr}
|
, m_file{nullptr}
|
||||||
|
@ -52,7 +52,7 @@ CSNDFile::CSNDFile(const std::string& filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CSNDFile::~CSNDFile()
|
CSNDFileWrapper::~CSNDFileWrapper()
|
||||||
{
|
{
|
||||||
if (m_file)
|
if (m_file)
|
||||||
{
|
{
|
||||||
|
@ -65,43 +65,43 @@ CSNDFile::~CSNDFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CSNDFile::IsOpen()
|
bool CSNDFileWrapper::IsOpen()
|
||||||
{
|
{
|
||||||
return m_file && m_snd_file;
|
return m_file && m_snd_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SF_INFO &CSNDFile::GetFileInfo()
|
SF_INFO &CSNDFileWrapper::GetFileInfo()
|
||||||
{
|
{
|
||||||
return m_file_info;
|
return m_file_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string& CSNDFile::GetLastError()
|
std::string& CSNDFileWrapper::GetLastError()
|
||||||
{
|
{
|
||||||
return m_last_error;
|
return m_last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::Read(short int *ptr, sf_count_t items)
|
sf_count_t CSNDFileWrapper::Read(short int *ptr, sf_count_t items)
|
||||||
{
|
{
|
||||||
return sf_read_short(m_snd_file, ptr, items);
|
return sf_read_short(m_snd_file, ptr, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::SNDLength(void *data)
|
sf_count_t CSNDFileWrapper::SNDLength(void *data)
|
||||||
{
|
{
|
||||||
return PHYSFS_fileLength(static_cast<PHYSFS_File *>(data));
|
return PHYSFS_fileLength(static_cast<PHYSFS_File *>(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::SNDRead(void *ptr, sf_count_t count, void *data)
|
sf_count_t CSNDFileWrapper::SNDRead(void *ptr, sf_count_t count, void *data)
|
||||||
{
|
{
|
||||||
return PHYSFS_read(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
return PHYSFS_read(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::SNDSeek(sf_count_t offset, int whence, void *data)
|
sf_count_t CSNDFileWrapper::SNDSeek(sf_count_t offset, int whence, void *data)
|
||||||
{
|
{
|
||||||
PHYSFS_File *file = static_cast<PHYSFS_File *>(data);
|
PHYSFS_File *file = static_cast<PHYSFS_File *>(data);
|
||||||
switch(whence)
|
switch(whence)
|
||||||
|
@ -121,13 +121,13 @@ sf_count_t CSNDFile::SNDSeek(sf_count_t offset, int whence, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::SNDTell(void *data)
|
sf_count_t CSNDFileWrapper::SNDTell(void *data)
|
||||||
{
|
{
|
||||||
return PHYSFS_tell(static_cast<PHYSFS_File *>(data));
|
return PHYSFS_tell(static_cast<PHYSFS_File *>(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sf_count_t CSNDFile::SNDWrite(const void *ptr, sf_count_t count, void *data)
|
sf_count_t CSNDFileWrapper::SNDWrite(const void *ptr, sf_count_t count, void *data)
|
||||||
{
|
{
|
||||||
return PHYSFS_write(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
return PHYSFS_write(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
||||||
}
|
}
|
|
@ -20,15 +20,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
|
||||||
|
|
||||||
class CSNDFile
|
class CSNDFileWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSNDFile(const std::string &filename);
|
CSNDFileWrapper(const std::string &filename);
|
||||||
virtual ~CSNDFile();
|
virtual ~CSNDFileWrapper();
|
||||||
|
|
||||||
|
CSNDFileWrapper(const CSNDFileWrapper&) = delete;
|
||||||
|
CSNDFileWrapper& operator=(const CSNDFileWrapper&) = delete;
|
||||||
|
|
||||||
SF_INFO &GetFileInfo();
|
SF_INFO &GetFileInfo();
|
||||||
bool IsOpen();
|
bool IsOpen();
|
|
@ -23,7 +23,6 @@
|
||||||
#include "sound/oalsound/check.h"
|
#include "sound/oalsound/check.h"
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
#include "common/resources/sndfile.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ bool Buffer::LoadFromFile(std::string filename, SoundType sound)
|
||||||
m_sound = sound;
|
m_sound = sound;
|
||||||
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
||||||
|
|
||||||
std::unique_ptr<CSNDFile> file = CResourceManager::GetSNDFileHandler(filename);
|
auto file = CResourceManager::GetSNDFileHandler(filename);
|
||||||
|
|
||||||
GetLogger()->Trace(" channels %d\n", file->GetFileInfo().channels);
|
GetLogger()->Trace(" channels %d\n", file->GetFileInfo().channels);
|
||||||
GetLogger()->Trace(" format %d\n", file->GetFileInfo().format);
|
GetLogger()->Trace(" format %d\n", file->GetFileInfo().format);
|
||||||
|
|
Loading…
Reference in New Issue