Finished merge, created AudiereFile test

actorid
Nicolay Korslund 15 years ago
parent 165952f916
commit c54301fc1c

@ -23,9 +23,17 @@ using namespace Mangle::Sound;
// --- InputManager --- // --- InputManager ---
AudiereInput::AudiereInput()
{
canLoadStream = false;
}
InputSource *AudiereInput::load(const std::string &file) InputSource *AudiereInput::load(const std::string &file)
{ return new AudiereSource(file); } { return new AudiereSource(file); }
InputSource *AudiereInput::load(Stream::InputStream *input)
{ assert(0 && "not implemented yet"); }
// --- InputSource --- // --- InputSource ---
AudiereSource::AudiereSource(const std::string &file) AudiereSource::AudiereSource(const std::string &file)

@ -12,7 +12,13 @@ namespace Sound {
class AudiereInput : public InputManager class AudiereInput : public InputManager
{ {
public: public:
AudiereInput();
/// Load a source from a file
InputSource *load(const std::string &file); InputSource *load(const std::string &file);
/// Load a source from a stream
virtual InputSource *load(Stream::InputStream *input);
}; };
/// Audiere InputSource implementation /// Audiere InputSource implementation

@ -4,6 +4,7 @@
#include "../input.h" #include "../input.h"
#include <exception> #include <exception>
#include <vector> #include <vector>
#include <assert.h>
extern "C" extern "C"
{ {

@ -75,6 +75,7 @@ OpenAL_Manager::OpenAL_Manager()
canRepeatStream = false; canRepeatStream = false;
canLoadFile = false; canLoadFile = false;
canLoadSource = true; canLoadSource = true;
canLoadStream = false;
// Set up sound system // Set up sound system
Device = alcOpenDevice(NULL); Device = alcOpenDevice(NULL);

@ -13,7 +13,7 @@ namespace Stream {
This lets Audiere read sound files from any generic archive or This lets Audiere read sound files from any generic archive or
file manager that supports Mangle streams. file manager that supports Mangle streams.
*/ */
class AudiereFile : public audiere::File, _IWrapper class AudiereFile : public audiere::RefImplementation<audiere::File>, _IWrapper
{ {
public: public:
AudiereFile(InputStream *inp, bool autoDel=false) AudiereFile(InputStream *inp, bool autoDel=false)
@ -24,7 +24,7 @@ class AudiereFile : public audiere::File, _IWrapper
{ return inp->read(buf,count); } { return inp->read(buf,count); }
/// Seek, relative to specified seek mode. Returns true if successful. /// 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 /// Get current position
int tell() int tell()

@ -1,13 +1,17 @@
GCC=g++ -I../ -I../imp_client/ 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) I_OGRE=$(shell pkg-config --cflags OGRE)
L_OGRE=$(shell pkg-config --libs 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 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) $(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 dummy_test: dummy_test.cpp dummy_input.cpp ../input.h
$(GCC) $< -o $@ $(GCC) $< -o $@

@ -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…
Cancel
Save