mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge commit '008b4c'
This commit is contained in:
commit
165952f916
@ -27,6 +27,7 @@ AudiereManager::AudiereManager()
|
|||||||
canRepeatStream = true;
|
canRepeatStream = true;
|
||||||
canLoadFile = true;
|
canLoadFile = true;
|
||||||
canLoadSource = false;
|
canLoadSource = false;
|
||||||
|
canLoadStream = false;
|
||||||
|
|
||||||
device = OpenDevice("");
|
device = OpenDevice("");
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ class AudiereManager : public Manager
|
|||||||
|
|
||||||
virtual Sound *load(const std::string &file, bool stream=false);
|
virtual Sound *load(const std::string &file, bool stream=false);
|
||||||
|
|
||||||
|
/// not implemented yet
|
||||||
|
virtual Sound *load(Stream::InputStream *input, bool stream=false)
|
||||||
|
{ assert(0); }
|
||||||
|
|
||||||
/// disabled
|
/// disabled
|
||||||
virtual Sound *load(InputSource *input, bool stream=false)
|
virtual Sound *load(InputSource *input, bool stream=false)
|
||||||
{ assert(0); }
|
{ assert(0); }
|
||||||
|
@ -32,6 +32,8 @@ FFM_InputManager::FFM_InputManager()
|
|||||||
av_log_set_level(AV_LOG_ERROR);
|
av_log_set_level(AV_LOG_ERROR);
|
||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canLoadStream = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputSource *FFM_InputManager::load(const std::string &file)
|
InputSource *FFM_InputManager::load(const std::string &file)
|
||||||
|
@ -34,6 +34,9 @@ class FFM_InputManager : public InputManager
|
|||||||
public:
|
public:
|
||||||
FFM_InputManager();
|
FFM_InputManager();
|
||||||
virtual InputSource *load(const std::string &file);
|
virtual InputSource *load(const std::string &file);
|
||||||
|
|
||||||
|
/// not supported
|
||||||
|
virtual InputSource *load(Stream::InputStream *input) { assert(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// FFMpeg implementation of InputSource
|
/// FFMpeg implementation of InputSource
|
||||||
|
@ -43,26 +43,31 @@ class InputFilter : public Manager
|
|||||||
|
|
||||||
/// Assign an input manager and a sound manager to this object
|
/// Assign an input manager and a sound manager to this object
|
||||||
void set(Manager *_snd, InputManager *_inp)
|
void set(Manager *_snd, InputManager *_inp)
|
||||||
{
|
{
|
||||||
inp = _inp;
|
inp = _inp;
|
||||||
snd = _snd;
|
snd = _snd;
|
||||||
|
|
||||||
needsUpdate = snd->needsUpdate;
|
// Set capabilities
|
||||||
has3D = snd->has3D;
|
needsUpdate = snd->needsUpdate;
|
||||||
canRepeatStream = snd->canRepeatStream;
|
has3D = snd->has3D;
|
||||||
|
canRepeatStream = snd->canRepeatStream;
|
||||||
|
canLoadStream = inp->canLoadStream;
|
||||||
|
|
||||||
// Both these should be true, or the use of this class is pretty
|
// Both these should be true, or the use of this class is pretty
|
||||||
// pointless
|
// pointless
|
||||||
canLoadSource = snd->canLoadSource;
|
canLoadSource = snd->canLoadSource;
|
||||||
canLoadFile = canLoadSource;
|
canLoadFile = canLoadSource;
|
||||||
assert(canLoadSource && canLoadFile);
|
assert(canLoadSource && canLoadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Sound *load(const std::string &file, bool stream=false)
|
virtual Sound *load(const std::string &file, bool stream=false)
|
||||||
{ return load(inp->load(file), stream); }
|
{ return load(inp->load(file), stream); }
|
||||||
|
|
||||||
|
virtual Sound *load(Stream::InputStream *input, bool stream=false)
|
||||||
|
{ return load(inp->load(input), stream); }
|
||||||
|
|
||||||
virtual Sound *load(InputSource *input, bool stream=false)
|
virtual Sound *load(InputSource *input, bool stream=false)
|
||||||
{ return snd->load(input, stream); }
|
{ return snd->load(input, stream); }
|
||||||
|
|
||||||
virtual void update() { snd->update(); }
|
virtual void update() { snd->update(); }
|
||||||
virtual void setListenerPos(float x, float y, float z,
|
virtual void setListenerPos(float x, float y, float z,
|
||||||
|
@ -97,6 +97,9 @@ OpenAL_Manager::~OpenAL_Manager()
|
|||||||
Sound *OpenAL_Manager::load(const std::string &file, bool stream)
|
Sound *OpenAL_Manager::load(const std::string &file, bool stream)
|
||||||
{ assert(0 && "OpenAL cannot decode files"); }
|
{ assert(0 && "OpenAL cannot decode files"); }
|
||||||
|
|
||||||
|
Sound *OpenAL_Manager::load(Stream::InputStream*,bool)
|
||||||
|
{ assert(0 && "OpenAL cannot decode streams"); }
|
||||||
|
|
||||||
Sound *OpenAL_Manager::load(InputSource *source, bool stream)
|
Sound *OpenAL_Manager::load(InputSource *source, bool stream)
|
||||||
{ return new OpenAL_Sound(source, this, stream); }
|
{ return new OpenAL_Sound(source, this, stream); }
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
void remove_stream(LST::iterator);
|
void remove_stream(LST::iterator);
|
||||||
|
|
||||||
virtual Sound *load(const std::string &file, bool stream=false);
|
virtual Sound *load(const std::string &file, bool stream=false);
|
||||||
|
virtual Sound *load(Stream::InputStream *input, bool stream=false);
|
||||||
virtual Sound *load(InputSource* input, bool stream=false);
|
virtual Sound *load(InputSource* input, bool stream=false);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
virtual void setListenerPos(float x, float y, float z,
|
virtual void setListenerPos(float x, float y, float z,
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../stream/input.h"
|
||||||
|
|
||||||
namespace Mangle {
|
namespace Mangle {
|
||||||
namespace Sound {
|
namespace Sound {
|
||||||
|
|
||||||
@ -64,9 +66,15 @@ class InputSource
|
|||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// If true, the stream version of load() works
|
||||||
|
bool canLoadStream;
|
||||||
|
|
||||||
/// Load a sound input source from file
|
/// Load a sound input source from file
|
||||||
virtual InputSource *load(const std::string &file) = 0;
|
virtual InputSource *load(const std::string &file) = 0;
|
||||||
|
|
||||||
|
/// Load a sound input source from stream (if canLoadStream is true)
|
||||||
|
virtual InputSource *load(Stream::InputStream *input) = 0;
|
||||||
|
|
||||||
/// Virtual destructor
|
/// Virtual destructor
|
||||||
virtual ~InputManager() {}
|
virtual ~InputManager() {}
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
|
#include "../stream/input.h"
|
||||||
|
|
||||||
namespace Mangle {
|
namespace Mangle {
|
||||||
namespace Sound {
|
namespace Sound {
|
||||||
|
|
||||||
@ -115,6 +117,9 @@ class Manager
|
|||||||
/// true if we can load sounds from an InputSource
|
/// true if we can load sounds from an InputSource
|
||||||
bool canLoadSource;
|
bool canLoadSource;
|
||||||
|
|
||||||
|
/// If true, we can lound sound files from a Stream
|
||||||
|
bool canLoadStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load a sound from an input source. Only valid if
|
@brief Load a sound from an input source. Only valid if
|
||||||
canLoadSource is true.
|
canLoadSource is true.
|
||||||
@ -132,6 +137,16 @@ class Manager
|
|||||||
*/
|
*/
|
||||||
virtual Sound *load(InputSource *input, bool stream=false) = 0;
|
virtual Sound *load(InputSource *input, bool stream=false) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Load a sound directly from file. Only valid if canLoadStream
|
||||||
|
is true.
|
||||||
|
|
||||||
|
@param input audio file stream
|
||||||
|
@param stream true if the file should be streamed
|
||||||
|
@see load(InputSource*,bool)
|
||||||
|
*/
|
||||||
|
virtual Sound *load(Stream::InputStream *input, bool stream=false) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load a sound directly from file. Only valid if canLoadFile
|
@brief Load a sound directly from file. Only valid if canLoadFile
|
||||||
is true.
|
is true.
|
||||||
|
39
stream/imp_client/audiere_file.cpp
Normal file
39
stream/imp_client/audiere_file.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "audiere_file.h"
|
||||||
|
|
||||||
|
using namespace audiere;
|
||||||
|
using namespace Mangle::Stream;
|
||||||
|
|
||||||
|
bool AudiereFile::seek(int pos, SeekMode mode)
|
||||||
|
{
|
||||||
|
assert(inp->isSeekable);
|
||||||
|
assert(inp->hasPosition);
|
||||||
|
|
||||||
|
if(mode == BEGIN)
|
||||||
|
{
|
||||||
|
// Absolute position
|
||||||
|
inp->seek(pos);
|
||||||
|
return inp->tell() == pos;
|
||||||
|
}
|
||||||
|
if(mode == CURRENT)
|
||||||
|
{
|
||||||
|
// Current position
|
||||||
|
int cpos = inp->tell();
|
||||||
|
|
||||||
|
// Seek to a elative position
|
||||||
|
inp->seek(cpos + pos);
|
||||||
|
return inp->tell() == (pos+cpos);
|
||||||
|
}
|
||||||
|
if(mode == END)
|
||||||
|
{
|
||||||
|
// Seeking from the end. This requires that we're able to get
|
||||||
|
// the entire size of the file. The pos also has to be
|
||||||
|
// non-positive.
|
||||||
|
assert(inp->hasSize);
|
||||||
|
assert(pos <= 0);
|
||||||
|
|
||||||
|
size_t epos = inp->size();
|
||||||
|
inp->seek(epos + pos);
|
||||||
|
return inp->tell() == (epos+pos);
|
||||||
|
}
|
||||||
|
assert(0 && "invalid seek mode");
|
||||||
|
}
|
35
stream/imp_client/audiere_file.h
Normal file
35
stream/imp_client/audiere_file.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef MANGLE_STREAM_AUDIERECLIENT_H
|
||||||
|
#define MANGLE_STREAM_AUDIERECLIENT_H
|
||||||
|
|
||||||
|
#include <audiere.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "iwrapper.h"
|
||||||
|
|
||||||
|
namespace Mangle {
|
||||||
|
namespace Stream {
|
||||||
|
|
||||||
|
/** @brief An Audiere::File that wraps a Mangle::Stream input.
|
||||||
|
|
||||||
|
This lets Audiere read sound files from any generic archive or
|
||||||
|
file manager that supports Mangle streams.
|
||||||
|
*/
|
||||||
|
class AudiereFile : public audiere::File, _IWrapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AudiereFile(InputStream *inp, bool autoDel=false)
|
||||||
|
: _IWrapper(inp, autoDel) {}
|
||||||
|
|
||||||
|
/// Read 'count' bytes, return bytes successfully read
|
||||||
|
int read(void *buf, int count)
|
||||||
|
{ return inp->read(buf,count); }
|
||||||
|
|
||||||
|
/// Seek, relative to specified seek mode. Returns true if successful.
|
||||||
|
bool seek(int pos, audiere::SeekMode mode);
|
||||||
|
|
||||||
|
/// Get current position
|
||||||
|
int tell()
|
||||||
|
{ assert(inp->hasPosition); return inp->tell(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespaces
|
||||||
|
#endif
|
35
stream/imp_server/ogre_datastream.h
Normal file
35
stream/imp_server/ogre_datastream.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef MANGLE_STREAM_OGRESERVER_H
|
||||||
|
#define MANGLE_STREAM_OGRESERVER_H
|
||||||
|
|
||||||
|
#include <OgreDataStream.h>
|
||||||
|
|
||||||
|
namespace Mangle {
|
||||||
|
namespace Stream {
|
||||||
|
|
||||||
|
/** A Stream wrapping an OGRE DataStream.
|
||||||
|
|
||||||
|
This has been built and tested against OGRE 1.6.2. You might have
|
||||||
|
to make your own modifications if you're working with newer (or
|
||||||
|
older) versions.
|
||||||
|
*/
|
||||||
|
class OgreStream : public InputStream
|
||||||
|
{
|
||||||
|
Ogre::DataStreamPtr inp;
|
||||||
|
|
||||||
|
public:
|
||||||
|
OgreStream(Ogre::DataStreamPtr _inp) : inp(_inp)
|
||||||
|
{
|
||||||
|
isSeekable = true;
|
||||||
|
hasPosition = true;
|
||||||
|
hasSize = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t read(void *buf, size_t count) { return inp->read(buf,count); }
|
||||||
|
void seek(size_t pos) { inp->seek(pos); }
|
||||||
|
size_t tell() const { return inp->tell(); }
|
||||||
|
size_t size() const { return inp->size(); }
|
||||||
|
bool eof() const { return inp->eof(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespaces
|
||||||
|
#endif
|
@ -18,7 +18,6 @@ namespace VFS {
|
|||||||
class MangleArchive : public Ogre::Archive, _Wrapper
|
class MangleArchive : public Ogre::Archive, _Wrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructor without name
|
|
||||||
MangleArchive(VFS *vfs, const std::string &name,
|
MangleArchive(VFS *vfs, const std::string &name,
|
||||||
const std::string &archType = "Mangle",
|
const std::string &archType = "Mangle",
|
||||||
bool autoDel=false)
|
bool autoDel=false)
|
||||||
|
62
vfs/imp_server/ogre_vfs.h
Normal file
62
vfs/imp_server/ogre_vfs.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#ifndef MANGLE_VFS_OGRECLIENT_H
|
||||||
|
#define MANGLE_VFS_OGRECLIENT_H
|
||||||
|
|
||||||
|
#include <OgreArchive.h>
|
||||||
|
|
||||||
|
namespace Mangle {
|
||||||
|
namespace VFS {
|
||||||
|
|
||||||
|
/** @brief An interface into the OGRE VFS system.
|
||||||
|
|
||||||
|
This class does not wrap a single Ogre::Archive, but rather the
|
||||||
|
entire resource set available to Ogre. You can use this class to
|
||||||
|
tap into all paths, Zip files, custom archives on so on that have
|
||||||
|
been inserted into Ogre as resource locations.
|
||||||
|
|
||||||
|
This class is currently a work in progres, it will not compile as
|
||||||
|
it stands.
|
||||||
|
|
||||||
|
This has been built and tested against OGRE 1.6.2. You might have
|
||||||
|
to make your own modifications if you're working with newer (or
|
||||||
|
older) versions.
|
||||||
|
*/
|
||||||
|
class OgreVFS : public VFS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OgreVFS()
|
||||||
|
{
|
||||||
|
hasFind = true;
|
||||||
|
isCaseSensitive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Open a new data stream. Deleting the object should be enough to
|
||||||
|
/// close it.
|
||||||
|
virtual Stream::InputStream *open(const std::string &name);
|
||||||
|
|
||||||
|
/// Check for the existence of a file
|
||||||
|
virtual bool isFile(const std::string &name) const;
|
||||||
|
|
||||||
|
/// Check for the existence of a directory
|
||||||
|
virtual bool isDir(const std::string &name) const;
|
||||||
|
|
||||||
|
/// Get info about a single file
|
||||||
|
virtual FileInfo stat(const std::string &name) const;
|
||||||
|
|
||||||
|
/// List all entries in a given directory. A blank dir should be
|
||||||
|
/// interpreted as a the root/current directory of the archive. If
|
||||||
|
/// dirs is true, list directories instead of files.
|
||||||
|
virtual FileInfoList list(const std::string& dir = "",
|
||||||
|
bool recurse=true,
|
||||||
|
bool dirs=false) const;
|
||||||
|
|
||||||
|
/// Find files after a given pattern. Wildcards (*) are
|
||||||
|
/// supported. Only valid if 'hasFind' is true. Don't implement your
|
||||||
|
/// own pattern matching here if the backend doesn't support it
|
||||||
|
/// natively; use a filter instead (not implemented yet.)
|
||||||
|
virtual FileInfoList find(const std::string& pattern,
|
||||||
|
bool recursive=true,
|
||||||
|
bool dirs=false) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespaces
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user