From 4d4c1e05053b18a4fe3f1645567abf947b5fee0d Mon Sep 17 00:00:00 2001 From: Darkvater Date: Mon, 12 Feb 2007 21:55:10 +0000 Subject: (svn r8691) -Cleanup: Some proper #endif comments for sound/music/video files, and a little elimination of magic numbers in Win32SoundStart --- src/music/dmusic.cpp | 5 ++--- src/music/dmusic.h | 2 +- src/music/null_m.h | 2 +- src/music/win32_m.h | 2 +- src/sound/null_s.cpp | 1 - src/sound/null_s.h | 2 +- src/sound/sdl_s.cpp | 2 +- src/sound/sdl_s.h | 2 +- src/sound/win32_s.cpp | 20 +++++++++----------- src/video/dedicated_v.h | 2 +- src/video/null_v.h | 2 +- src/video/sdl_v.cpp | 2 +- src/video/sdl_v.h | 2 +- src/video/win32_v.h | 2 +- 14 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index 1c5b1d200..9c2c6a2cd 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -4,7 +4,6 @@ #ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT -#include "../openttd.h" #include "../debug.h" #include "../win32.h" #include "dmusic.h" @@ -218,7 +217,7 @@ static void DMusicMidiSetVolume(byte vol) } -extern "C" const HalMusicDriver _dmusic_midi_driver = { +const HalMusicDriver _dmusic_midi_driver = { DMusicMidiStart, DMusicMidiStop, DMusicMidiPlaySong, @@ -227,4 +226,4 @@ extern "C" const HalMusicDriver _dmusic_midi_driver = { DMusicMidiSetVolume, }; -#endif +#endif /* WIN32_ENABLE_DIRECTMUSIC_SUPPORT */ diff --git a/src/music/dmusic.h b/src/music/dmusic.h index 5d0990137..a01269e1d 100644 --- a/src/music/dmusic.h +++ b/src/music/dmusic.h @@ -7,4 +7,4 @@ extern const HalMusicDriver _dmusic_midi_driver; -#endif +#endif /* MUSIC_DMUSIC_H */ diff --git a/src/music/null_m.h b/src/music/null_m.h index 0f3e2cfa5..d6edfb71d 100644 --- a/src/music/null_m.h +++ b/src/music/null_m.h @@ -7,4 +7,4 @@ extern const HalMusicDriver _null_music_driver; -#endif +#endif /* MUSIC_NULL_H */ diff --git a/src/music/win32_m.h b/src/music/win32_m.h index 83893ed1e..162be9d97 100644 --- a/src/music/win32_m.h +++ b/src/music/win32_m.h @@ -7,4 +7,4 @@ extern const HalMusicDriver _win32_music_driver; -#endif +#endif /* MUSIC_WIN32_H */ diff --git a/src/sound/null_s.cpp b/src/sound/null_s.cpp index f68c4b13a..e2c5ce2d8 100644 --- a/src/sound/null_s.cpp +++ b/src/sound/null_s.cpp @@ -1,7 +1,6 @@ /* $Id$ */ #include "../stdafx.h" -#include "../openttd.h" #include "null_s.h" static const char *NullSoundStart(const char * const *parm) { return NULL; } diff --git a/src/sound/null_s.h b/src/sound/null_s.h index 6ccd19aed..204c58376 100644 --- a/src/sound/null_s.h +++ b/src/sound/null_s.h @@ -7,4 +7,4 @@ extern const HalSoundDriver _null_sound_driver; -#endif +#endif /* SOUND_NULL_H */ diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp index 4b1da52d6..8ec31e9fb 100644 --- a/src/sound/sdl_s.cpp +++ b/src/sound/sdl_s.cpp @@ -44,4 +44,4 @@ const HalSoundDriver _sdl_sound_driver = { SdlSoundStop, }; -#endif +#endif /* WITH_SDL */ diff --git a/src/sound/sdl_s.h b/src/sound/sdl_s.h index 6fc2b6dc0..a667e137a 100644 --- a/src/sound/sdl_s.h +++ b/src/sound/sdl_s.h @@ -7,4 +7,4 @@ extern const HalSoundDriver _sdl_sound_driver; -#endif +#endif /* SOUND_SDL_H */ diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp index 68194ad39..77d688eb4 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -42,29 +42,27 @@ static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, { switch (uMsg) { case WOM_DONE: - if (_waveout) FillHeaders(); - break; - - default: + if (_waveout != NULL) FillHeaders(); break; + default: break; } } static const char *Win32SoundStart(const char* const* parm) { WAVEFORMATEX wfex; - int hz; - - _bufsize = GetDriverParamInt(parm, "bufsize", 1024); - hz = GetDriverParamInt(parm, "hz", 11025); wfex.wFormatTag = WAVE_FORMAT_PCM; wfex.nChannels = 2; - wfex.nSamplesPerSec = hz; - wfex.nAvgBytesPerSec = hz * 2 * 2; - wfex.nBlockAlign = 4; wfex.wBitsPerSample = 16; + wfex.nSamplesPerSec = GetDriverParamInt(parm, "hz", 11025); + wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8; + wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; + + _bufsize = GetDriverParamInt(parm, "bufsize", 1024); + if (waveOutOpen(&_waveout, WAVE_MAPPER, &wfex, (DWORD_PTR)&waveOutProc, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return "waveOutOpen failed"; + PrepareHeader(&_wave_hdr[0]); PrepareHeader(&_wave_hdr[1]); FillHeaders(); diff --git a/src/video/dedicated_v.h b/src/video/dedicated_v.h index 9ba1223d3..5b752643e 100644 --- a/src/video/dedicated_v.h +++ b/src/video/dedicated_v.h @@ -7,4 +7,4 @@ extern const HalVideoDriver _dedicated_video_driver; -#endif +#endif /* VIDEO_DEDICATED_H */ diff --git a/src/video/null_v.h b/src/video/null_v.h index 56922d9b3..21f1af7a9 100644 --- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -7,4 +7,4 @@ extern const HalVideoDriver _null_video_driver; -#endif +#endif /* VIDEO_NULL_H */ diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 1f9910565..628ffaf63 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -510,4 +510,4 @@ const HalVideoDriver _sdl_video_driver = { SdlVideoFullScreen, }; -#endif +#endif /* WITH_SDL */ diff --git a/src/video/sdl_v.h b/src/video/sdl_v.h index 07ba50f3c..2868b1c5c 100644 --- a/src/video/sdl_v.h +++ b/src/video/sdl_v.h @@ -7,4 +7,4 @@ extern const HalVideoDriver _sdl_video_driver; -#endif +#endif /* VIDEO_SDL_H */ diff --git a/src/video/win32_v.h b/src/video/win32_v.h index c3b23a61a..d63a526f8 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -7,4 +7,4 @@ extern const HalVideoDriver _win32_video_driver; -#endif +#endif /* VIDEO_WIN32_H */ -- cgit v1.2.3-70-g09d2