Changeset - r5988:7f6f0097eeb1
[Not reviewed]
master
0 14 0
Darkvater - 17 years ago 2007-02-12 21:55:10
darkvater@openttd.org
(svn r8691) -Cleanup: Some proper #endif comments for sound/music/video files, and a little elimination of magic numbers in Win32SoundStart
14 files changed with 22 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/music/dmusic.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 

	
 
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT
 

	
 
#include "../openttd.h"
 
#include "../debug.h"
 
#include "../win32.h"
 
#include "dmusic.h"
 

	
 
#include <windows.h>
 
#include <dmksctrl.h>
 
#include <dmusici.h>
 
#include <dmusicc.h>
 
#include <dmusicf.h>
 

	
 

	
 
// the performance object controls manipulation of the segments
 
@@ -209,22 +208,22 @@ static bool DMusicMidiIsSongPlaying(void
 
	}
 
}
 

	
 

	
 
static void DMusicMidiSetVolume(byte vol)
 
{
 
	// 0 - 127 -> -2000 - 0
 
	long db = vol * 2000 / 127 - 2000;
 
	performance->SetGlobalParam(GUID_PerfMasterVolume, &db, sizeof(db));
 
}
 

	
 

	
 
extern "C" const HalMusicDriver _dmusic_midi_driver = {
 
const HalMusicDriver _dmusic_midi_driver = {
 
	DMusicMidiStart,
 
	DMusicMidiStop,
 
	DMusicMidiPlaySong,
 
	DMusicMidiStopSong,
 
	DMusicMidiIsSongPlaying,
 
	DMusicMidiSetVolume,
 
};
 

	
 
#endif
 
#endif /* WIN32_ENABLE_DIRECTMUSIC_SUPPORT */
src/music/dmusic.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef MUSIC_DMUSIC_H
 
#define MUSIC_DMUSIC_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _dmusic_midi_driver;
 

	
 
#endif
 
#endif /* MUSIC_DMUSIC_H */
src/music/null_m.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef MUSIC_NULL_H
 
#define MUSIC_NULL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _null_music_driver;
 

	
 
#endif
 
#endif /* MUSIC_NULL_H */
src/music/win32_m.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef MUSIC_WIN32_H
 
#define MUSIC_WIN32_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _win32_music_driver;
 

	
 
#endif
 
#endif /* MUSIC_WIN32_H */
src/sound/null_s.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "null_s.h"
 

	
 
static const char *NullSoundStart(const char * const *parm) { return NULL; }
 
static void NullSoundStop(void) {}
 

	
 
const HalSoundDriver _null_sound_driver = {
 
	NullSoundStart,
 
	NullSoundStop,
 
};
src/sound/null_s.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef SOUND_NULL_H
 
#define SOUND_NULL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalSoundDriver _null_sound_driver;
 

	
 
#endif
 
#endif /* SOUND_NULL_H */
src/sound/sdl_s.cpp
Show inline comments
 
@@ -35,13 +35,13 @@ static const char *SdlSoundStart(const c
 

	
 
static void SdlSoundStop(void)
 
{
 
	SDL_CALL SDL_CloseAudio();
 
	SdlClose(SDL_INIT_AUDIO);
 
}
 

	
 
const HalSoundDriver _sdl_sound_driver = {
 
	SdlSoundStart,
 
	SdlSoundStop,
 
};
 

	
 
#endif
 
#endif /* WITH_SDL */
src/sound/sdl_s.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef SOUND_SDL_H
 
#define SOUND_SDL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalSoundDriver _sdl_sound_driver;
 

	
 
#endif
 
#endif /* SOUND_SDL_H */
src/sound/win32_s.cpp
Show inline comments
 
@@ -33,47 +33,45 @@ static void FillHeaders(void)
 
			MxMixSamples(hdr->lpData, hdr->dwBufferLength / 4);
 
			if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
 
				error("waveOutWrite failed");
 
		}
 
	}
 
}
 

	
 
static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
 
	DWORD dwParam1, DWORD dwParam2)
 
{
 
	switch (uMsg) {
 
		case WOM_DONE:
 
			if (_waveout) FillHeaders();
 
			if (_waveout != NULL) FillHeaders();
 
			break;
 

	
 
		default:
 
			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();
 
	return NULL;
 
}
 

	
 
static void Win32SoundStop(void)
 
{
 
	HWAVEOUT waveout = _waveout;
 

	
 
	_waveout = NULL;
 
	waveOutReset(waveout);
src/video/dedicated_v.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef VIDEO_DEDICATED_H
 
#define VIDEO_DEDICATED_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalVideoDriver _dedicated_video_driver;
 

	
 
#endif
 
#endif /* VIDEO_DEDICATED_H */
src/video/null_v.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef VIDEO_NULL_H
 
#define VIDEO_NULL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalVideoDriver _null_video_driver;
 

	
 
#endif
 
#endif /* VIDEO_NULL_H */
src/video/sdl_v.cpp
Show inline comments
 
@@ -501,13 +501,13 @@ static void SdlVideoFullScreen(bool full
 
	}
 
}
 

	
 
const HalVideoDriver _sdl_video_driver = {
 
	SdlVideoStart,
 
	SdlVideoStop,
 
	SdlVideoMakeDirty,
 
	SdlVideoMainLoop,
 
	SdlVideoChangeRes,
 
	SdlVideoFullScreen,
 
};
 

	
 
#endif
 
#endif /* WITH_SDL */
src/video/sdl_v.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef VIDEO_SDL_H
 
#define VIDEO_SDL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalVideoDriver _sdl_video_driver;
 

	
 
#endif
 
#endif /* VIDEO_SDL_H */
src/video/win32_v.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef VIDEO_WIN32_H
 
#define VIDEO_WIN32_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalVideoDriver _win32_video_driver;
 

	
 
#endif
 
#endif /* VIDEO_WIN32_H */
0 comments (0 inline, 0 general)