Index: src/sound/sdl_s.cpp
===================================================================
--- src/sound/sdl_s.cpp	(Revision 11909)
+++ src/sound/sdl_s.cpp	(Arbeitskopie)
@@ -9,6 +9,9 @@
 #include "../sdl.h"
 #include "sdl_s.h"
 #include <SDL.h>
+#ifdef WITH_SDL_MIXER
+#include <SDL_mixer.h>
+#endif
 
 static FSoundDriver_SDL iFSoundDriver_SDL;
 
@@ -28,15 +31,30 @@
 	spec.format = AUDIO_S16SYS;
 	spec.channels = 2;
 	spec.samples = 512;
+
+#ifdef WITH_SDL_MIXER
+ 	// Open Mixer Audio
+	if (Mix_OpenAudio(spec.freq, spec.format, spec.channels, spec.samples) == -1)
+		return Mix_GetError();
+
+	// Use OpenTTD mixer as postmix processor
+	Mix_SetPostMix(fill_sound_buffer, NULL);
+#else
 	spec.callback = fill_sound_buffer;
 	SDL_CALL SDL_OpenAudio(&spec, &spec);
 	SDL_CALL SDL_PauseAudio(0);
+#endif
+	
 	return NULL;
 }
 
 void SoundDriver_SDL::Stop()
 {
+#ifdef WITH_SDL_MIXER
+	SDL_CALL Mix_CloseAudio();
+#else
 	SDL_CALL SDL_CloseAudio();
+#endif
 	SdlClose(SDL_INIT_AUDIO);
 }
 
Index: src/music/sdl_m.cpp
===================================================================
--- src/music/sdl_m.cpp	(Revision 0)
+++ src/music/sdl_m.cpp	(Revision 0)
@@ -0,0 +1,80 @@
+/* $Id$ */
+#ifdef WITH_SDL_MIXER
+#include "../stdafx.h"
+#include "../mixer.h"
+#include "../sdl.h"
+#include "sdl_m.h"
+
+#include <SDL.h>
+#include <SDL_mixer.h>
+
+enum MidiState {
+	MIDI_STOPPED = 0,
+	MIDI_PLAYING = 1,
+};
+
+static struct {
+	Mix_Music *music;
+	MidiState status;
+} _midi;
+
+static FMusicDriver_SDL iFMusicDriver_SDL;
+
+void MusicDriver_SDL::PlaySong(const char *filename)
+{
+	// First stop playing Song
+	StopSong();
+	
+	// Load Music
+	_midi.music = Mix_LoadMUS(filename);
+	if (!_midi.music) {
+		DEBUG(driver, 0, "sdl_mixer: %s", Mix_GetError());
+		return;
+	}	
+	
+	// Play Music
+	if (Mix_PlayMusic(_midi.music, 0) == -1) {
+		DEBUG(driver, 0, "sdl_mixer: %s", Mix_GetError());
+		return;
+	}
+	
+	// Sucessfully started playing music
+	_midi.status = MIDI_PLAYING;
+}
+
+void MusicDriver_SDL::StopSong()
+{
+	if (_midi.status == MIDI_PLAYING) {
+		_midi.status = MIDI_STOPPED;
+
+		// Halt Music
+		Mix_HaltMusic();
+		
+		// Free Music
+		Mix_FreeMusic(_midi.music);
+		_midi.music = NULL;
+	}
+}
+
+void MusicDriver_SDL::SetVolume(byte vol)
+{
+	Mix_VolumeMusic(vol);
+}
+
+bool MusicDriver_SDL::IsSongPlaying()
+{
+	return (_midi.status == MIDI_PLAYING && Mix_PlayingMusic());
+}
+
+const char *MusicDriver_SDL::Start(const char * const *parm)
+{
+	_midi.status = MIDI_STOPPED;
+	return 0;
+}
+
+void MusicDriver_SDL::Stop()
+{
+	if (_midi.status == MIDI_PLAYING)
+		StopSong();
+}
+#endif /* WITH_SDL_MIXER */
Index: src/music/sdl_m.h
===================================================================
--- src/music/sdl_m.h	(Revision 0)
+++ src/music/sdl_m.h	(Revision 0)
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+#ifndef MUSIC_SDL_H
+#define MUSIC_SDL_H
+
+#include "music_driver.hpp"
+
+class MusicDriver_SDL: public MusicDriver {
+public:
+	/* virtual */ const char *Start(const char * const *param);
+
+	/* virtual */ void Stop();
+
+	/* virtual */ void PlaySong(const char *filename);
+
+	/* virtual */ void StopSong();
+
+	/* virtual */ bool IsSongPlaying();
+
+	/* virtual */ void SetVolume(byte vol);
+};
+
+class FMusicDriver_SDL: public MusicDriverFactory<FMusicDriver_SDL> {
+public:
+	static const int priority = 5;
+	/* virtual */ const char *GetName() { return "sdl"; }
+	/* virtual */ const char *GetDescription() { return "SDL Music Driver"; }
+	/* virtual */ Driver *CreateInstance() { return new MusicDriver_SDL(); }
+};
+
+#endif /* MUSIC_SDL_H */
Index: src/mixer.cpp
===================================================================
--- src/mixer.cpp	(Revision 11909)
+++ src/mixer.cpp	(Arbeitskopie)
@@ -82,7 +82,9 @@
 	MixerChannel *mc;
 
 	/* Clear the buffer */
+#ifdef !WITH_SDL_MIXER
 	memset(buffer, 0, sizeof(int16) * 2 * samples);
+#endif
 
 	/* Mix each channel */
 	for (mc = _channels; mc != endof(_channels); mc++) {
Index: source.list
===================================================================
--- source.list	(Revision 11909)
+++ source.list	(Arbeitskopie)
@@ -180,6 +180,7 @@
 road_cmd.h
 saveload.h
 screenshot.h
+music/sdl_m.h
 sound/sdl_s.h
 video/sdl_v.h
 settings.h
@@ -451,6 +452,9 @@
 	music/dmusic.cpp
 #end
 music/null_m.cpp
+#if SDL
+	music/sdl_m.cpp
+#end
 #if WIN32
 	music/win32_m.cpp
 #else
Index: config.lib
===================================================================
--- config.lib	(Revision 11909)
+++ config.lib	(Arbeitskopie)
@@ -49,6 +49,7 @@
 	with_osx_sysroot="1"
 	with_application_bundle="1"
 	with_sdl="1"
+	with_sdl_mixer="1"
 	with_cocoa="1"
 	with_zlib="1"
 	with_png="1"
@@ -106,6 +107,7 @@
 		with_osx_sysroot
 		with_application_bundle
 		with_sdl
+		with_sdl_mixer
 		with_cocoa
 		with_zlib
 		with_png
@@ -247,6 +249,10 @@
 			--without-sdl)                with_sdl="0";;
 			--with-sdl=*)                 with_sdl="$optarg";;
 
+                        --with-sdl-mixer)             with_sdl_mixer="2";;
+                        --without-sdl-mixer)          with_sdl_mixer="0";;
+                        --with-sdl-mixer=*)           with_sdl_mixer="$optarg";;
+
 			--with-cocoa)                 with_cocoa="2";;
 			--without-cocoa)              with_cocoa="0";;
 			--with-cocoa=*)               with_cocoa="$optarg";;
@@ -511,6 +517,7 @@
 	fi
 
 	detect_sdl
+	detect_sdl_mixer
 	detect_cocoa
 
 	if [ "$enable_dedicated" != "0" ]; then
@@ -1042,6 +1049,11 @@
 		fi
 	fi
 
+	if [ "$with_sdl_mixer" != "0" ]; then
+		LIBS="$LIBS -lSDL_mixer"
+		CFLAGS="$CFLAGS -DWITH_SDL_MIXER"
+	fi
+
 	if [ "$with_cocoa" != "0" ]; then
 		CFLAGS="$CFLAGS -DWITH_COCOA"
 		LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit"
@@ -1629,6 +1641,13 @@
 	log 1 "checking SDL... found"
 }
 
+detect_sdl_mixer() {
+	# XXX does not work
+	# detect_library "$with_sdl_mixer" "SDL_mixer" "SDL_mixer.a" "SDL/SDL_mixer.h"
+	log 1 "checking SDL_mixer... found"
+	with_sdl_mixer="1"
+}
+
 detect_cocoa() {
 	# 0 means no, 1 is auto-detect, 2 is force
 	if [ "$with_cocoa" = "0" ]; then

