diff --git a/sound/imp/input_audiere.cpp b/sound/imp/input_audiere.cpp index 5ca85ffd9..624b2050b 100644 --- a/sound/imp/input_audiere.cpp +++ b/sound/imp/input_audiere.cpp @@ -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) diff --git a/sound/imp/input_audiere.h b/sound/imp/input_audiere.h index 5acc1a73d..344c07735 100644 --- a/sound/imp/input_audiere.h +++ b/sound/imp/input_audiere.h @@ -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 diff --git a/sound/imp/input_ffmpeg.h b/sound/imp/input_ffmpeg.h index cc8feffd4..ae25732b5 100644 --- a/sound/imp/input_ffmpeg.h +++ b/sound/imp/input_ffmpeg.h @@ -4,6 +4,7 @@ #include "../input.h" #include #include +#include extern "C" { diff --git a/sound/imp/output_openal.cpp b/sound/imp/output_openal.cpp index 190d0638d..e36981836 100644 --- a/sound/imp/output_openal.cpp +++ b/sound/imp/output_openal.cpp @@ -75,6 +75,7 @@ OpenAL_Manager::OpenAL_Manager() canRepeatStream = false; canLoadFile = false; canLoadSource = true; + canLoadStream = false; // Set up sound system Device = alcOpenDevice(NULL); diff --git a/stream/imp_client/audiere_file.h b/stream/imp_client/audiere_file.h index 201a7629a..a1910d274 100644 --- a/stream/imp_client/audiere_file.h +++ b/stream/imp_client/audiere_file.h @@ -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, _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() diff --git a/stream/tests/Makefile b/stream/tests/Makefile index 7d7041469..3d2a730b8 100644 --- a/stream/tests/Makefile +++ b/stream/tests/Makefile @@ -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 $@ diff --git a/stream/tests/audiere_client_test.cpp b/stream/tests/audiere_client_test.cpp new file mode 100644 index 000000000..7a5b5afc2 --- /dev/null +++ b/stream/tests/audiere_client_test.cpp @@ -0,0 +1,33 @@ +#include "dummy_input.cpp" +#include "../imp_client/audiere_file.h" +#include +#include + +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; +}