mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 04:23:53 +00:00
Added tests for 3d sound and pausing.
This commit is contained in:
parent
e2e5a2138d
commit
2aa41dfffe
5 changed files with 83 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
GCC=g++ -I../
|
||||
|
||||
all: sound_manager_test
|
||||
all: sound_manager_test sound_3d_test
|
||||
|
||||
L_FFMPEG=$(shell pkg-config --libs libavcodec libavformat)
|
||||
L_OPENAL=$(shell pkg-config --libs openal)
|
||||
|
@ -9,5 +9,8 @@ L_AUDIERE=-laudiere
|
|||
sound_manager_test: sound_manager_test.cpp ../../mangle/sound/sources/audiere_source.cpp ../../mangle/sound/outputs/openal_out.cpp ../../mangle/stream/clients/audiere_file.cpp ../sndmanager.cpp
|
||||
$(GCC) $^ -o $@ $(L_AUDIERE) $(L_OPENAL) -I../..
|
||||
|
||||
sound_3d_test: sound_3d_test.cpp ../../mangle/sound/sources/audiere_source.cpp ../../mangle/sound/outputs/openal_out.cpp ../../mangle/stream/clients/audiere_file.cpp ../sndmanager.cpp
|
||||
$(GCC) $^ -o $@ $(L_AUDIERE) $(L_OPENAL) -I../..
|
||||
|
||||
clean:
|
||||
rm *_test
|
||||
|
|
3
sound/tests/output/sound_3d_test.out
Normal file
3
sound/tests/output/sound_3d_test.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
Playing at 0,0,0
|
||||
Playing at 1,1,0
|
||||
Playing at -1,0,0
|
5
sound/tests/output/sound_manager_test.out
Normal file
5
sound/tests/output/sound_manager_test.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
Playing ../../mangle/sound/tests/cow.wav
|
||||
Replaying
|
||||
pause
|
||||
restart
|
||||
Done playing.
|
46
sound/tests/sound_3d_test.cpp
Normal file
46
sound/tests/sound_3d_test.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <assert.h>
|
||||
|
||||
#include <mangle/stream/servers/file_stream.hpp>
|
||||
#include <mangle/sound/filters/openal_audiere.hpp>
|
||||
|
||||
#include <sound/sndmanager.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Mangle::Stream;
|
||||
using namespace Mangle::Sound;
|
||||
using namespace OEngine::Sound;
|
||||
|
||||
const std::string sound = "../../mangle/sound/tests/cow.wav";
|
||||
|
||||
SoundManagerPtr m;
|
||||
|
||||
// Play and wait for finish
|
||||
void play(float x, float y, float z)
|
||||
{
|
||||
cout << "Playing at " << x << "," << y << "," << z << endl;
|
||||
|
||||
SoundPtr snd = m->play3D(sound,x,y,z);
|
||||
|
||||
while(snd->isPlaying())
|
||||
{
|
||||
usleep(10000);
|
||||
m->update();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
SoundFactoryPtr oaf(new OpenAL_Audiere_Factory);
|
||||
SoundManagerPtr mg(new SoundManager(oaf));
|
||||
m = mg;
|
||||
|
||||
mg->setListenerPos(0,0,0,0,1,0,0,0,1);
|
||||
|
||||
play(0,0,0);
|
||||
play(1,1,0);
|
||||
play(-1,0,0);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -33,15 +33,38 @@ int main()
|
|||
assert(mg->numSounds() == 1);
|
||||
|
||||
// Loop while there are still sounds to manage
|
||||
int i=0;
|
||||
while(mg->numSounds() != 0)
|
||||
{
|
||||
i++;
|
||||
assert(mg->numSounds() == 1);
|
||||
usleep(10000);
|
||||
if(mg->needsUpdate)
|
||||
mg->update();
|
||||
}
|
||||
|
||||
SoundPtr snd = mg->play(sound);
|
||||
cout << "Replaying\n";
|
||||
int i = 0;
|
||||
while(mg->numSounds() != 0)
|
||||
{
|
||||
assert(mg->numSounds() == 1);
|
||||
usleep(10000);
|
||||
if(mg->needsUpdate)
|
||||
mg->update();
|
||||
|
||||
if(i++ == 70)
|
||||
{
|
||||
cout << "pause\n";
|
||||
snd->pause();
|
||||
}
|
||||
if(i == 130)
|
||||
{
|
||||
cout << "restart\n";
|
||||
snd->play();
|
||||
// Let the sound go out of scope
|
||||
snd.reset();
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Done playing.\n";
|
||||
|
||||
assert(mg->numSounds() == 0);
|
||||
|
|
Loading…
Reference in a new issue