MOHAWK: Display a GUI error message when no audio devices are available

This commit is contained in:
Bastien Bouclet 2018-06-07 20:14:27 +02:00
parent b4ae4bcd8c
commit 3b794d2633
7 changed files with 19 additions and 3 deletions

View file

@ -42,6 +42,8 @@ static String errorToString(ErrorCode errorCode) {
return _s("Game id not supported"); return _s("Game id not supported");
case kUnsupportedColorMode: case kUnsupportedColorMode:
return _s("Unsupported color mode"); return _s("Unsupported color mode");
case kAudioDeviceInitFailed:
return _s("Audio device initialization failed");
case kReadPermissionDenied: case kReadPermissionDenied:
return _s("Read permission denied"); return _s("Read permission denied");

View file

@ -46,6 +46,7 @@ enum ErrorCode {
kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location
kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine
kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode
kAudioDeviceInitFailed, ///< Engine initialization: Audio device initialization failed
kReadPermissionDenied, ///< Unable to read data due to missing read permission kReadPermissionDenied, ///< Unable to read data due to missing read permission
kWritePermissionDenied, ///< Unable to write data due to missing write permission kWritePermissionDenied, ///< Unable to write data due to missing write permission

View file

@ -77,6 +77,10 @@ MohawkEngine_CSTime::~MohawkEngine_CSTime() {
Common::Error MohawkEngine_CSTime::run() { Common::Error MohawkEngine_CSTime::run() {
MohawkEngine::run(); MohawkEngine::run();
if (!_mixer->isReady()) {
return Common::kAudioDeviceInitFailed;
}
_console = new CSTimeConsole(this); _console = new CSTimeConsole(this);
_gfx = new CSTimeGraphics(this); _gfx = new CSTimeGraphics(this);
_video = new VideoManager(this); _video = new VideoManager(this);

View file

@ -170,6 +170,10 @@ MohawkEngine_LivingBooks::~MohawkEngine_LivingBooks() {
Common::Error MohawkEngine_LivingBooks::run() { Common::Error MohawkEngine_LivingBooks::run() {
MohawkEngine::run(); MohawkEngine::run();
if (!_mixer->isReady()) {
return Common::kAudioDeviceInitFailed;
}
_console = new LivingBooksConsole(this); _console = new LivingBooksConsole(this);
// Load the book info from the detected file // Load the book info from the detected file
loadBookInfo(getBookInfoFileName()); loadBookInfo(getBookInfoFileName());

View file

@ -35,9 +35,6 @@
namespace Mohawk { namespace Mohawk {
MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) { MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
if (!_mixer->isReady())
error ("Sound initialization failed");
// Setup mixer // Setup mixer
syncSoundSettings(); syncSoundSettings();

View file

@ -347,6 +347,10 @@ void MohawkEngine_Myst::playSoundBlocking(uint16 id) {
Common::Error MohawkEngine_Myst::run() { Common::Error MohawkEngine_Myst::run() {
MohawkEngine::run(); MohawkEngine::run();
if (!_mixer->isReady()) {
return Common::kAudioDeviceInitFailed;
}
_gfx = new MystGraphics(this); _gfx = new MystGraphics(this);
_video = new VideoManager(this); _video = new VideoManager(this);
_sound = new MystSound(this); _sound = new MystSound(this);

View file

@ -114,6 +114,10 @@ GUI::Debugger *MohawkEngine_Riven::getDebugger() {
Common::Error MohawkEngine_Riven::run() { Common::Error MohawkEngine_Riven::run() {
MohawkEngine::run(); MohawkEngine::run();
if (!_mixer->isReady()) {
return Common::kAudioDeviceInitFailed;
}
// Let's try to open the installer file (it holds extras.mhk) // Let's try to open the installer file (it holds extras.mhk)
// Though, we set a low priority to prefer the extracted version // Though, we set a low priority to prefer the extracted version
if (_installerArchive.open("arcriven.z")) if (_installerArchive.open("arcriven.z"))