mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 01:38:36 +00:00
TESTBED: added code to enable the mixer to simultaneously play channels, pause/unpause some of them using GUI, couple of fixes as well
svn-id: r51515
This commit is contained in:
parent
a6e84128c9
commit
9d6d0f8b35
@ -88,6 +88,7 @@ bool FStests::testReadFile() {
|
||||
|
||||
dirName.toLowercase();
|
||||
fileName.toLowercase();
|
||||
delete directory;
|
||||
directory = gameRoot.getSubDirectory(dirName);
|
||||
|
||||
if (!readDataFromFile(directory, fileName.c_str())) {
|
||||
@ -97,12 +98,14 @@ bool FStests::testReadFile() {
|
||||
|
||||
dirName.toUppercase();
|
||||
fileName.toUppercase();
|
||||
delete directory;
|
||||
directory = gameRoot.getSubDirectory(dirName);
|
||||
|
||||
if (!readDataFromFile(directory, fileName.c_str())) {
|
||||
Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
|
||||
numFailed++;
|
||||
}
|
||||
delete directory;
|
||||
}
|
||||
|
||||
Testsuite::logDetailedPrintf("Failed %d out of 15\n", numFailed);
|
||||
|
@ -22,10 +22,10 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "sound/mixer.h"
|
||||
#include "testbed/sound.h"
|
||||
#include "sound/softsynth/pcspk.h"
|
||||
|
||||
#include "testbed/sound.h"
|
||||
|
||||
namespace Testbed {
|
||||
|
||||
enum {
|
||||
@ -46,54 +46,109 @@ SoundSubsystemDialog::SoundSubsystemDialog() : TestbedInteractionDialog(80, 60,
|
||||
addButton(200, 20, "Play Channel #2", kPlayChannel2);
|
||||
addButton(200, 20, "Play Channel #3", kPlayChannel3);
|
||||
addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15);
|
||||
|
||||
_mixer = g_system->getMixer();
|
||||
|
||||
// the three streams to be mixed
|
||||
Audio::PCSpeaker *s1 = new Audio::PCSpeaker();
|
||||
Audio::PCSpeaker *s2 = new Audio::PCSpeaker();
|
||||
Audio::PCSpeaker *s3 = new Audio::PCSpeaker();
|
||||
|
||||
s1->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
||||
s2->play(Audio::PCSpeaker::kWaveFormSquare, 500, -1);
|
||||
s3->play(Audio::PCSpeaker::kWaveFormSaw, 200, -1);
|
||||
|
||||
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_h1, s1);
|
||||
_mixer->pauseHandle(_h1, true);
|
||||
|
||||
_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_h2, s2);
|
||||
_mixer->pauseHandle(_h2, true);
|
||||
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_h3, s3);
|
||||
_mixer->pauseHandle(_h3, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SoundSubsystemDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
|
||||
switch (cmd) {
|
||||
case kPlayChannel1:
|
||||
_buttonArray[0]->setLabel("Pause Channel #1");
|
||||
_buttonArray[0]->setCmd(kPauseChannel1);
|
||||
// TODO: Play music #1 here
|
||||
_mixer->pauseHandle(_h1, false);
|
||||
break;
|
||||
case kPlayChannel2:
|
||||
_buttonArray[1]->setLabel("Pause Channel #2");
|
||||
_buttonArray[1]->setCmd(kPauseChannel2);
|
||||
_mixer->pauseHandle(_h2, false);
|
||||
break;
|
||||
case kPlayChannel3:
|
||||
_buttonArray[2]->setLabel("Pause Channel #3");
|
||||
_buttonArray[2]->setCmd(kPauseChannel3);
|
||||
_mixer->pauseHandle(_h3, false);
|
||||
break;
|
||||
case kPauseChannel1:
|
||||
_buttonArray[0]->setLabel("Play Channel #1");
|
||||
_buttonArray[0]->setCmd(kPlayChannel1);
|
||||
_mixer->pauseHandle(_h1, true);
|
||||
break;
|
||||
case kPauseChannel2:
|
||||
_buttonArray[1]->setLabel("Play Channel #2");
|
||||
_buttonArray[1]->setCmd(kPlayChannel2);
|
||||
_mixer->pauseHandle(_h2, true);
|
||||
break;
|
||||
case kPauseChannel3:
|
||||
_buttonArray[2]->setLabel("Play Channel #3");
|
||||
_buttonArray[2]->setCmd(kPlayChannel3);
|
||||
_mixer->pauseHandle(_h3, true);
|
||||
break;
|
||||
default:
|
||||
_mixer->stopAll();
|
||||
GUI::Dialog::handleCommand(sender, cmd, data);
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundSubsystem::playPCSpkSound() {
|
||||
bool SoundSubsystem::playBeeps() {
|
||||
Testsuite::clearScreen();
|
||||
bool passed = true;
|
||||
Common::String info = "Testing Sound Output by generating beeps\n"
|
||||
"You should hear a left beep followed by a right beep\n";
|
||||
|
||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
||||
Testsuite::logPrintf("Info! Skipping test : Play Beeps\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
|
||||
Audio::Mixer *mixer = g_system->getMixer();
|
||||
Audio::SoundHandle handle;
|
||||
mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, speaker);
|
||||
speaker->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
||||
g_system->delayMillis(1000);
|
||||
|
||||
// Left Beep
|
||||
Testsuite::writeOnScreen("Left Beep", Common::Point(0, 100));
|
||||
mixer->setChannelBalance(handle, -127);
|
||||
g_system->delayMillis(1000);
|
||||
speaker->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
||||
g_system->delayMillis(500);
|
||||
mixer->pauseHandle(handle, true);
|
||||
|
||||
if (Testsuite::handleInteractiveInput("Were you able to hear the left beep?", "Yes", "No", kOptionRight)) {
|
||||
Testsuite::logDetailedPrintf("Error! Left Beep couldn't be detected : Error with Mixer::setChannelBalance()\n");
|
||||
passed = false;
|
||||
}
|
||||
|
||||
// Right Beep
|
||||
Testsuite::writeOnScreen("Right Beep", Common::Point(0, 100));
|
||||
mixer->setChannelBalance(handle, 127);
|
||||
g_system->delayMillis(1000);
|
||||
mixer->pauseHandle(handle, false);
|
||||
g_system->delayMillis(500);
|
||||
mixer->stopAll();
|
||||
return true;
|
||||
|
||||
if (Testsuite::handleInteractiveInput("Were you able to hear the right beep?", "Yes", "No", kOptionRight)) {
|
||||
Testsuite::logDetailedPrintf("Error! Right Beep couldn't be detected : Error with Mixer::setChannelBalance()\n");
|
||||
passed = false;
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
bool SoundSubsystem::mixSounds() {
|
||||
@ -103,7 +158,7 @@ bool SoundSubsystem::mixSounds() {
|
||||
}
|
||||
|
||||
SoundSubsystemTestSuite::SoundSubsystemTestSuite() {
|
||||
addTest("PCSpkrSound", &SoundSubsystem::playPCSpkSound, true);
|
||||
addTest("SimpleBeeps", &SoundSubsystem::playBeeps, true);
|
||||
addTest("MixSounds", &SoundSubsystem::mixSounds, true);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define TESTBED_SOUND_H
|
||||
|
||||
#include "gui/dialog.h"
|
||||
#include "sound/mixer.h"
|
||||
#include "testbed/config.h"
|
||||
#include "testbed/testsuite.h"
|
||||
|
||||
@ -36,6 +37,8 @@ public:
|
||||
SoundSubsystemDialog();
|
||||
~SoundSubsystemDialog() {}
|
||||
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
|
||||
Audio::Mixer *_mixer;
|
||||
Audio::SoundHandle _h1, _h2, _h3;
|
||||
};
|
||||
|
||||
namespace SoundSubsystem {
|
||||
@ -43,7 +46,7 @@ namespace SoundSubsystem {
|
||||
// Helper functions for SoundSubsystem tests
|
||||
|
||||
// will contain function declarations for SoundSubsystem tests
|
||||
bool playPCSpkSound();
|
||||
bool playBeeps();
|
||||
bool mixSounds();
|
||||
}
|
||||
|
||||
|
@ -296,6 +296,7 @@ void Testsuite::updateStats(const char *prefix, const char *info, uint testNum,
|
||||
}
|
||||
g_system->copyRectToScreen(buffer, wRect, pt.x, pt.y, wRect, lRect);
|
||||
g_system->updateScreen();
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
bool Testsuite::enableTest(const Common::String &testName, bool toEnable) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user