Made separate tests for audiere and openal. Fixed segfault. Everything is peachy.
parent
56f9daed96
commit
f8d3a35cf8
@ -0,0 +1,69 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../../stream/servers/file_stream.h"
|
||||
#include "../sources/audiere_source.h"
|
||||
#include "../../stream/filters/buffer_stream.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Mangle::Stream;
|
||||
using namespace Mangle::Sound;
|
||||
|
||||
// Contents and size of cow.raw
|
||||
void *orig;
|
||||
size_t orig_size;
|
||||
|
||||
void run(SampleSourcePtr &src)
|
||||
{
|
||||
size_t ss = src->size();
|
||||
assert(ss == orig_size);
|
||||
|
||||
cout << "Source size: " << ss << endl;
|
||||
int rate, channels, bits;
|
||||
src->getInfo(&rate, &channels, &bits);
|
||||
cout << "rate=" << rate << "\nchannels=" << channels
|
||||
<< "\nbits=" << bits << endl;
|
||||
|
||||
cout << "Reading entire buffer into memory\n";
|
||||
void *buf = malloc(ss);
|
||||
src->read(buf, ss);
|
||||
|
||||
cout << "Comparing...\n";
|
||||
if(memcmp(buf, orig, ss) != 0)
|
||||
{
|
||||
cout << "Oops!\n";
|
||||
assert(0);
|
||||
}
|
||||
|
||||
cout << "Done\n";
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
cout << "Reading cow.raw first\n";
|
||||
FileStream tmp("cow.raw");
|
||||
orig_size = tmp.size();
|
||||
cout << "Size: " << orig_size << endl;
|
||||
orig = malloc(orig_size);
|
||||
tmp.read(orig, orig_size);
|
||||
cout << "Done\n";
|
||||
}
|
||||
|
||||
{
|
||||
cout << "\nLoading cow.wav by filename:\n";
|
||||
SampleSourcePtr cow_file( new AudiereSource("cow.wav") );
|
||||
run(cow_file);
|
||||
}
|
||||
|
||||
{
|
||||
cout << "\nLoading cow.wav by stream:\n";
|
||||
StreamPtr inp( new FileStream("cow.wav") );
|
||||
SampleSourcePtr cow_stream( new AudiereSource(inp) );
|
||||
run(cow_stream);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include "../../stream/servers/file_stream.h"
|
||||
#include "../sources/stream_source.h"
|
||||
#include "../outputs/openal_out.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Mangle::Stream;
|
||||
using namespace Mangle::Sound;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Loading cow.raw\n";
|
||||
|
||||
int rate = 11025;
|
||||
int chan = 1;
|
||||
int bits = 16;
|
||||
|
||||
cout << " rate=" << rate << "\n channels=" << chan
|
||||
<< "\n bits=" << bits << endl;
|
||||
|
||||
StreamPtr file( new FileStream("cow.raw") );
|
||||
SampleSourcePtr source( new Stream2Samples( file, rate, chan, bits));
|
||||
|
||||
cout << "Playing\n";
|
||||
|
||||
// This initializes OpenAL for us, and serves no other purpose.
|
||||
OpenAL_Factory mg;
|
||||
|
||||
OpenAL_Sound snd(source);
|
||||
try
|
||||
{
|
||||
snd.play();
|
||||
|
||||
while(snd.isPlaying())
|
||||
{
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
catch(exception &e)
|
||||
{
|
||||
cout << " ERROR: " << e.what() << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue