mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-11 09:36:37 +00:00
Finished merge, created AudiereFile test
This commit is contained in:
parent
165952f916
commit
c54301fc1c
@ -23,9 +23,17 @@ using namespace Mangle::Sound;
|
||||
|
||||
// --- InputManager ---
|
||||
|
||||
AudiereInput::AudiereInput()
|
||||
{
|
||||
canLoadStream = false;
|
||||
}
|
||||
|
||||
InputSource *AudiereInput::load(const std::string &file)
|
||||
{ return new AudiereSource(file); }
|
||||
|
||||
InputSource *AudiereInput::load(Stream::InputStream *input)
|
||||
{ assert(0 && "not implemented yet"); }
|
||||
|
||||
// --- InputSource ---
|
||||
|
||||
AudiereSource::AudiereSource(const std::string &file)
|
||||
|
@ -12,7 +12,13 @@ namespace Sound {
|
||||
class AudiereInput : public InputManager
|
||||
{
|
||||
public:
|
||||
AudiereInput();
|
||||
|
||||
/// Load a source from a file
|
||||
InputSource *load(const std::string &file);
|
||||
|
||||
/// Load a source from a stream
|
||||
virtual InputSource *load(Stream::InputStream *input);
|
||||
};
|
||||
|
||||
/// Audiere InputSource implementation
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "../input.h"
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -75,6 +75,7 @@ OpenAL_Manager::OpenAL_Manager()
|
||||
canRepeatStream = false;
|
||||
canLoadFile = false;
|
||||
canLoadSource = true;
|
||||
canLoadStream = false;
|
||||
|
||||
// Set up sound system
|
||||
Device = alcOpenDevice(NULL);
|
||||
|
@ -13,7 +13,7 @@ namespace Stream {
|
||||
This lets Audiere read sound files from any generic archive or
|
||||
file manager that supports Mangle streams.
|
||||
*/
|
||||
class AudiereFile : public audiere::File, _IWrapper
|
||||
class AudiereFile : public audiere::RefImplementation<audiere::File>, _IWrapper
|
||||
{
|
||||
public:
|
||||
AudiereFile(InputStream *inp, bool autoDel=false)
|
||||
@ -24,7 +24,7 @@ class AudiereFile : public audiere::File, _IWrapper
|
||||
{ return inp->read(buf,count); }
|
||||
|
||||
/// Seek, relative to specified seek mode. Returns true if successful.
|
||||
bool seek(int pos, audiere::SeekMode mode);
|
||||
bool seek(int pos, audiere::File::SeekMode mode);
|
||||
|
||||
/// Get current position
|
||||
int tell()
|
||||
|
@ -1,13 +1,17 @@
|
||||
GCC=g++ -I../ -I../imp_client/
|
||||
|
||||
all: ogre_client_test dummy_test
|
||||
all: ogre_client_test dummy_test audiere_client_test
|
||||
|
||||
I_OGRE=$(shell pkg-config --cflags OGRE)
|
||||
L_OGRE=$(shell pkg-config --libs OGRE)
|
||||
L_AUDIERE=-laudiere
|
||||
|
||||
ogre_client_test: ogre_client_test.cpp dummy_input.cpp ../input.h ../imp_client/iwrapper.h ../imp_client/ogre_datastream.h
|
||||
$(GCC) $< -o $@ $(I_OGRE) $(L_OGRE)
|
||||
|
||||
audiere_client_test: audiere_client_test.cpp dummy_input.cpp ../input.h ../imp_client/iwrapper.h ../imp_client/audiere_file.h ../imp_client/audiere_file.cpp
|
||||
$(GCC) $< -o $@ ../imp_client/audiere_file.cpp $(L_AUDIERE)
|
||||
|
||||
dummy_test: dummy_test.cpp dummy_input.cpp ../input.h
|
||||
$(GCC) $< -o $@
|
||||
|
||||
|
33
stream/tests/audiere_client_test.cpp
Normal file
33
stream/tests/audiere_client_test.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "dummy_input.cpp"
|
||||
#include "../imp_client/audiere_file.h"
|
||||
#include <audiere.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace audiere;
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
char str[12];
|
||||
memset(str, 0, 12);
|
||||
InputStream *inp = new DummyInput();
|
||||
FilePtr p(new AudiereFile(inp, true));
|
||||
cout << "pos=" << p->tell() << endl;
|
||||
p->read(str, 2);
|
||||
cout << "2 bytes: " << str << endl;
|
||||
cout << "pos=" << p->tell() << endl;
|
||||
p->seek(4, File::BEGIN);
|
||||
cout << "pos=" << p->tell() << endl;
|
||||
p->read(str, 3);
|
||||
cout << "3 bytes: " << str << endl;
|
||||
p->seek(-1, File::CURRENT);
|
||||
cout << "pos=" << p->tell() << endl;
|
||||
p->seek(-4, File::END);
|
||||
cout << "pos=" << p->tell() << endl;
|
||||
p->read(str, 4);
|
||||
cout << "last 4 bytes: " << str << endl;
|
||||
p->seek(0, File::BEGIN);
|
||||
p->read(str, 11);
|
||||
cout << "entire stream: " << str << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user