mirror of https://github.com/OpenTTD/OpenTTD
(svn r18520) -Fix [FS#3272]: allegro doesn't like to work with extmidi; it causes 'random' (looks like a racing condition in allegro) crashes when songs are stopped.
parent
51cb9cc43f
commit
b0f1fcbead
|
@ -32,7 +32,15 @@ public:
|
||||||
|
|
||||||
class FMusicDriver_Allegro: public MusicDriverFactory<FMusicDriver_Allegro> {
|
class FMusicDriver_Allegro: public MusicDriverFactory<FMusicDriver_Allegro> {
|
||||||
public:
|
public:
|
||||||
|
#if !defined(WITH_SDL) && defined(WITH_ALLEGRO)
|
||||||
|
/* If SDL is not compiled in but Allegro is, chances are quite big
|
||||||
|
* that Allegro is going to be used. Then favour this sound driver
|
||||||
|
* over extmidi because with extmidi we get crashes. */
|
||||||
|
static const int priority = 9;
|
||||||
|
#else
|
||||||
static const int priority = 2;
|
static const int priority = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* virtual */ const char *GetName() { return "allegro"; }
|
/* virtual */ const char *GetName() { return "allegro"; }
|
||||||
/* virtual */ const char *GetDescription() { return "Allegro MIDI Driver"; }
|
/* virtual */ const char *GetDescription() { return "Allegro MIDI Driver"; }
|
||||||
/* virtual */ Driver *CreateInstance() { return new MusicDriver_Allegro(); }
|
/* virtual */ Driver *CreateInstance() { return new MusicDriver_Allegro(); }
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef __MORPHOS__
|
#ifndef __MORPHOS__
|
||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
#include "../sound/sound_driver.hpp"
|
||||||
|
#include "../video/video_driver.hpp"
|
||||||
#include "extmidi.h"
|
#include "extmidi.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -29,6 +31,11 @@ static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
|
||||||
|
|
||||||
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
|
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
|
||||||
{
|
{
|
||||||
|
if (strcmp(_video_driver->GetName(), "allegro") == 0 ||
|
||||||
|
strcmp(_sound_driver->GetName(), "allegro") == 0) {
|
||||||
|
return "the extmidi driver does not work when Allegro is loaded.";
|
||||||
|
}
|
||||||
|
|
||||||
const char *command = GetDriverParam(parm, "cmd");
|
const char *command = GetDriverParam(parm, "cmd");
|
||||||
if (StrEmpty(command)) command = EXTERNAL_PLAYER;
|
if (StrEmpty(command)) command = EXTERNAL_PLAYER;
|
||||||
|
|
||||||
|
|
|
@ -642,15 +642,6 @@ int ttd_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
free(sounddriver);
|
free(sounddriver);
|
||||||
|
|
||||||
if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = strdup(_ini_musicdriver);
|
|
||||||
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
|
||||||
if (_music_driver == NULL) {
|
|
||||||
StrEmpty(musicdriver) ?
|
|
||||||
usererror("Failed to autoprobe music driver") :
|
|
||||||
usererror("Failed to select requested music driver '%s'", musicdriver);
|
|
||||||
}
|
|
||||||
free(musicdriver);
|
|
||||||
|
|
||||||
if (videodriver == NULL && _ini_videodriver != NULL) videodriver = strdup(_ini_videodriver);
|
if (videodriver == NULL && _ini_videodriver != NULL) videodriver = strdup(_ini_videodriver);
|
||||||
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
|
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
|
||||||
if (_video_driver == NULL) {
|
if (_video_driver == NULL) {
|
||||||
|
@ -660,6 +651,15 @@ int ttd_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
free(videodriver);
|
free(videodriver);
|
||||||
|
|
||||||
|
if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = strdup(_ini_musicdriver);
|
||||||
|
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
||||||
|
if (_music_driver == NULL) {
|
||||||
|
StrEmpty(musicdriver) ?
|
||||||
|
usererror("Failed to autoprobe music driver") :
|
||||||
|
usererror("Failed to select requested music driver '%s'", musicdriver);
|
||||||
|
}
|
||||||
|
free(musicdriver);
|
||||||
|
|
||||||
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
|
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
|
||||||
/* Initialize the zoom level of the screen to normal */
|
/* Initialize the zoom level of the screen to normal */
|
||||||
_screen.zoom = ZOOM_LVL_NORMAL;
|
_screen.zoom = ZOOM_LVL_NORMAL;
|
||||||
|
|
Loading…
Reference in New Issue