mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- sound player uses new FS
This commit is contained in:
parent
28f0263298
commit
cab8955d8f
@ -106,9 +106,6 @@ void CSoundHandler::init()
|
||||
if (initialized)
|
||||
{
|
||||
// Load sounds
|
||||
sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/Heroes3.snd"));
|
||||
sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/Heroes3-cd2.snd"), false);
|
||||
sndh.add_file(std::string(GameConstants::DATA_DIR + "/Data/H3ab_ahd.snd"));
|
||||
Mix_ChannelFinished(soundFinishedCallbackC);
|
||||
}
|
||||
}
|
||||
@ -140,12 +137,9 @@ Mix_Chunk *CSoundHandler::GetSoundChunk(soundBase::soundID soundID)
|
||||
return NULL;
|
||||
|
||||
// Load and insert
|
||||
int size;
|
||||
const char *data = sndh.extract(it->second, size);
|
||||
if (!data)
|
||||
return NULL;
|
||||
auto data = CResourceHandler::get()->loadData(ResourceID(std::string("SOUNDS/") + it->second, EResType::SOUND));
|
||||
|
||||
SDL_RWops *ops = SDL_RWFromConstMem(data, size);
|
||||
SDL_RWops *ops = SDL_RWFromMem(data.first.release(), data.second);
|
||||
Mix_Chunk *chunk;
|
||||
chunk = Mix_LoadWAV_RW(ops, 1); // will free ops
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "CConfigHandler.h"
|
||||
#include "CSoundBase.h"
|
||||
#include "../lib/CCreatureHandler.h"
|
||||
#include "CSndHandler.h"
|
||||
|
||||
/*
|
||||
* CMusicHandler.h, part of VCMI engine
|
||||
@ -63,7 +62,6 @@ public:
|
||||
class CSoundHandler: public CAudioBase
|
||||
{
|
||||
private:
|
||||
CSndHandler sndh;
|
||||
soundBase::soundID getSoundID(const std::string &fileName);
|
||||
//update volume on configuration change
|
||||
SettingsListener listener;
|
||||
|
@ -89,31 +89,6 @@ void CMediaHandler::extract(std::string srcfile, std::string dstfile, bool caseS
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// unused and not sure what it's supposed to do
|
||||
MemberFile CMediaHandler::getFile(std::string name)
|
||||
{
|
||||
MemberFile ret;
|
||||
std::transform(name.begin(),name.end(),name.begin(),tolower);
|
||||
for (size_t i=0;i<entries.size();++i)
|
||||
{
|
||||
if (entries[i].name==name)
|
||||
{
|
||||
std::string por = entries[i].name;
|
||||
std::transform(por.begin(),por.end(),por.begin(),tolower);
|
||||
if (por==name)
|
||||
{
|
||||
ret.length=entries[i].size;
|
||||
file.seekg(entries[i].offset,std::ios_base::beg);
|
||||
ret.ifs=&file;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char * CMediaHandler::extract (int index, int & size)
|
||||
{
|
||||
Entry &entry = entries[index];
|
||||
@ -139,36 +114,6 @@ const char * CMediaHandler::extract (std::string srcName, int &size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CSndHandler::add_file(std::string fname, bool important /*= true*/)
|
||||
{
|
||||
boost::iostreams::mapped_file_source *mfile = NULL;
|
||||
try
|
||||
{
|
||||
mfile = CMediaHandler::add_file(fname, important);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char *data = mfile->data();
|
||||
ui32 numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]);
|
||||
struct soundEntry *se = (struct soundEntry *)&data[4];
|
||||
|
||||
for (ui32 i=0; i<numFiles; i++, se++)
|
||||
{
|
||||
Entry entry;
|
||||
|
||||
entry.name = se->filename;
|
||||
entry.offset = SDL_SwapLE32(se->offset);
|
||||
entry.size = SDL_SwapLE32(se->size);
|
||||
entry.data = mfile->data() + entry.offset;
|
||||
|
||||
entries.push_back(entry);
|
||||
fimap[entry.name] = i;
|
||||
}
|
||||
}
|
||||
|
||||
void CVidHandler::add_file(std::string fname)
|
||||
{
|
||||
boost::iostreams::mapped_file_source *mfile = NULL;
|
||||
|
@ -28,14 +28,6 @@ struct MemberFile
|
||||
int length;
|
||||
};
|
||||
|
||||
// sound entry structure in catalog
|
||||
struct soundEntry
|
||||
{
|
||||
char filename[40];
|
||||
Uint32 offset; /* little endian */
|
||||
Uint32 size; /* little endian */
|
||||
};
|
||||
|
||||
// video entry structure in catalog
|
||||
struct videoEntry
|
||||
{
|
||||
@ -64,16 +56,9 @@ public:
|
||||
void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
|
||||
const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
|
||||
void extract(int index, std::string dstfile); //saves selected file
|
||||
MemberFile getFile(std::string name);//nie testowane - sprawdzic
|
||||
const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
|
||||
};
|
||||
|
||||
class CSndHandler: public CMediaHandler
|
||||
{
|
||||
public:
|
||||
void add_file(std::string fname, bool important = true); //if not important, then we don't print warning when the file is missing
|
||||
};
|
||||
|
||||
class CVidHandler: public CMediaHandler
|
||||
{
|
||||
public:
|
||||
|
@ -124,7 +124,8 @@ void CLodArchiveLoader::initVIDArchive(CFileInputStream & fileStream)
|
||||
else
|
||||
{
|
||||
VideoEntryBlock nextVidEntry = vidEntries[i + 1];
|
||||
entry.size = SDL_SwapLE32(nextVidEntry.offset) - entry.offset;
|
||||
entry.realSize = SDL_SwapLE32(nextVidEntry.offset) - entry.offset;
|
||||
entry.size = 0;
|
||||
}
|
||||
|
||||
entries[entry.name] = entry;
|
||||
@ -160,10 +161,15 @@ void CLodArchiveLoader::initSNDArchive(CFileInputStream & fileStream)
|
||||
SoundEntryBlock sndEntry = sndEntries[i];
|
||||
ArchiveEntry entry;
|
||||
|
||||
entry.name = sndEntry.filename;
|
||||
entry.offset = SDL_SwapLE32(sndEntry.offset);
|
||||
entry.size = SDL_SwapLE32(sndEntry.size);
|
||||
//for some reason entries in snd have format NAME\0WAV\0\0\0....
|
||||
//we need to replace first \0 with dot and trim line
|
||||
entry.name = std::string(sndEntry.filename, 40);
|
||||
entry.name[entry.name.find_first_of('\0')] = '.';
|
||||
entry.name.resize(entry.name.find_first_of('\0'));
|
||||
|
||||
entry.offset = SDL_SwapLE32(sndEntry.offset);
|
||||
entry.realSize = SDL_SwapLE32(sndEntry.size);
|
||||
entry.size = 0;
|
||||
entries[entry.name] = entry;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,6 @@ void CResourceHandler::loadFileSystem(const std::string fsConfigURI)
|
||||
|
||||
void CResourceHandler::loadModsFilesystems()
|
||||
{
|
||||
|
||||
auto iterator = initialLoader->getIterator([](const ResourceID & ident) -> bool
|
||||
{
|
||||
std::string name = ident.getName();
|
||||
|
Loading…
Reference in New Issue
Block a user