Combined OpenAL+Audiere sound test now compiles and runs, but segfaults
parent
9e332c4067
commit
56f9daed96
@ -1,19 +1,13 @@
|
||||
GCC=g++ -I../
|
||||
|
||||
all: audiere_test ffmpeg_openal_test openal_audiere_test
|
||||
all: openal_audiere_test
|
||||
|
||||
L_FFMPEG=$(shell pkg-config --libs libavcodec libavformat)
|
||||
#L_FFMPEG=$(shell pkg-config --libs libavcodec libavformat)
|
||||
L_OPENAL=$(shell pkg-config --libs openal)
|
||||
L_AUDIERE=-laudiere
|
||||
|
||||
ffmpeg_openal_test: ffmpeg_openal_test.cpp ../servers/input_ffmpeg.cpp ../servers/output_openal.cpp
|
||||
$(GCC) $^ -o $@ $(L_FFMPEG) $(L_OPENAL)
|
||||
|
||||
openal_audiere_test: openal_audiere_test.cpp ../servers/input_audiere.cpp ../servers/output_openal.cpp ../../stream/clients/audiere_file.cpp
|
||||
openal_audiere_test: openal_audiere_test.cpp ../sources/audiere_source.cpp ../outputs/openal_out.cpp ../../stream/clients/audiere_file.cpp
|
||||
$(GCC) $^ -o $@ $(L_AUDIERE) $(L_OPENAL)
|
||||
|
||||
audiere_test: audiere_test.cpp ../servers/audiere_imp.cpp
|
||||
$(GCC) $^ -o $@ $(L_AUDIERE)
|
||||
|
||||
clean:
|
||||
rm *_test
|
||||
|
@ -1,89 +0,0 @@
|
||||
// This file is included directly into the test programs
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <exception>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class TestStream : public Mangle::Stream::Stream
|
||||
{
|
||||
ifstream io;
|
||||
|
||||
public:
|
||||
|
||||
TestStream(const char* name)
|
||||
{
|
||||
io.open(name, ios::binary);
|
||||
isSeekable = true;
|
||||
hasPosition = true;
|
||||
hasSize = false;
|
||||
}
|
||||
|
||||
size_t read(void* buf, size_t len)
|
||||
{
|
||||
io.read((char*)buf, len);
|
||||
return io.gcount();
|
||||
}
|
||||
|
||||
void seek(size_t pos)
|
||||
{
|
||||
io.seekg(pos);
|
||||
}
|
||||
|
||||
size_t tell() const
|
||||
{ return ((TestStream*)this)->io.tellg(); }
|
||||
|
||||
size_t size() const
|
||||
{ return 0; }
|
||||
|
||||
bool eof() const
|
||||
{ return io.eof(); }
|
||||
};
|
||||
|
||||
void play(const char* name, bool music=false, bool stream=false)
|
||||
{
|
||||
// Only load streams if the backend supports it
|
||||
if(stream && !mg.canLoadStream)
|
||||
return;
|
||||
|
||||
cout << "Playing " << name;
|
||||
if(stream) cout << " (from stream)";
|
||||
cout << "\n";
|
||||
|
||||
Sound *snd = NULL;
|
||||
Instance *s = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
if(stream)
|
||||
snd = mg.load(new TestStream(name), music);
|
||||
else
|
||||
snd = mg.load(name, music);
|
||||
|
||||
|
||||
s = snd->getInstance(false, false);
|
||||
s->play();
|
||||
|
||||
while(s->isPlaying())
|
||||
{
|
||||
usleep(10000);
|
||||
if(mg.needsUpdate) mg.update();
|
||||
}
|
||||
}
|
||||
catch(exception &e)
|
||||
{
|
||||
cout << " ERROR: " << e.what() << "\n";
|
||||
}
|
||||
|
||||
if(s) s->drop();
|
||||
if(snd) snd->drop();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
play("cow.wav");
|
||||
play("owl.ogg", true);
|
||||
play("cow.wav", false, true);
|
||||
return 0;
|
||||
}
|
@ -1,7 +1,54 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <exception>
|
||||
|
||||
#include "../../stream/servers/file_stream.h"
|
||||
#include "../../stream/filters/buffer_stream.h"
|
||||
#include "../filters/openal_audiere.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Mangle::Stream;
|
||||
using namespace Mangle::Sound;
|
||||
|
||||
OpenAL_Audiere_Factory mg;
|
||||
|
||||
#include "common.cpp"
|
||||
void play(const char* name, bool stream=false)
|
||||
{
|
||||
// Only load streams if the backend supports it
|
||||
if(stream && !mg.canLoadStream)
|
||||
return;
|
||||
|
||||
cout << "Playing " << name;
|
||||
if(stream) cout << " (from stream)";
|
||||
cout << "\n";
|
||||
|
||||
SoundPtr snd;
|
||||
|
||||
try
|
||||
{
|
||||
if(stream)
|
||||
snd = mg.load(StreamPtr(new FileStream(name)));
|
||||
else
|
||||
snd = mg.load(name);
|
||||
|
||||
snd->play();
|
||||
|
||||
while(snd->isPlaying())
|
||||
{
|
||||
usleep(10000);
|
||||
if(mg.needsUpdate) mg.update();
|
||||
}
|
||||
}
|
||||
catch(exception &e)
|
||||
{
|
||||
cout << " ERROR: " << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
play("cow.wav");
|
||||
play("owl.ogg");
|
||||
play("cow.wav", true);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue