- Fixed spurious warnings on 32-bit VC++ debug builds.

- Made the subsong (order) number a proper parameter to MusInfo::Play()
  instead of requiring a separate SetPosition() call to do it.



SVN r1104 (trunk)
This commit is contained in:
Randy Heit 2008-08-03 03:54:48 +00:00
parent 8d3e67ac88
commit 9f21b22cc5
16 changed files with 133 additions and 93 deletions

View file

@ -1,3 +1,8 @@
August 2, 2008
- Fixed spurious warnings on 32-bit VC++ debug builds.
- Made the subsong (order) number a proper parameter to MusInfo::Play()
instead of requiring a separate SetPosition() call to do it.
August 2, 2008 (Changes by Graf Zahl)
- Added Gez's submission for custom bridge things.
- Fixed: ASpecialSpot must check the array's size before dividing by it.

View file

@ -78,7 +78,7 @@
struct MusPlayingInfo
{
FString name;
void *handle;
MusInfo *handle;
int baseorder;
bool loop;
};
@ -1838,8 +1838,10 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
{
if (order != mus_playing.baseorder)
{
mus_playing.baseorder =
(I_SetSongPosition (mus_playing.handle, order) ? order : 0);
if (mus_playing.handle->SetSubsong(order))
{
mus_playing.baseorder = order;
}
}
return true;
}
@ -1862,7 +1864,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
int lumpnum = -1;
int offset = 0, length = 0;
int device = MDEV_DEFAULT;
void *handle = NULL;
MusInfo *handle = NULL;
int *devp = MidiDevices.CheckKey(FName(musicname));
if (devp != NULL) device = *devp;
@ -1932,7 +1934,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
{
mus_playing.loop = looping;
mus_playing.name = "";
mus_playing.baseorder = 0;
mus_playing.baseorder = order;
LastSong = musicname;
return true;
}
@ -1956,13 +1958,13 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
mus_playing.loop = looping;
mus_playing.name = musicname;
mus_playing.baseorder = 0;
LastSong = "";
if (mus_playing.handle != 0)
{ // play it
I_PlaySong (mus_playing.handle, looping, S_GetMusicVolume (musicname));
mus_playing.baseorder =
(I_SetSongPosition (mus_playing.handle, order) ? order : 0);
I_PlaySong (mus_playing.handle, looping, S_GetMusicVolume (musicname), order);
mus_playing.baseorder = order;
return true;
}
return false;

View file

@ -454,21 +454,16 @@ public:
Volume = volume;
}
// Sets the current order number for a MOD-type song, or the position in ms
// for anything else.
bool SetPosition(int pos)
// Sets the position in ms.
bool SetPosition(unsigned int ms_pos)
{
FMOD_SOUND_TYPE type;
return FMOD_OK == Channel->setPosition(ms_pos, FMOD_TIMEUNIT_MS);
}
if (FMOD_OK == Stream->getFormat(&type, NULL, NULL, NULL) &&
(type == FMOD_SOUND_TYPE_IT ||
type == FMOD_SOUND_TYPE_MOD ||
type == FMOD_SOUND_TYPE_S3M ||
type == FMOD_SOUND_TYPE_XM))
{
return FMOD_OK == Channel->setPosition(pos, FMOD_TIMEUNIT_MODORDER);
}
return FMOD_OK == Channel->setPosition(pos, FMOD_TIMEUNIT_MS);
// Sets the order number for MOD formats.
bool SetOrder(int order_pos)
{
return FMOD_OK == Channel->setPosition(order_pos, FMOD_TIMEUNIT_MODORDER);
}
FString GetStats()

View file

@ -121,7 +121,12 @@ MusInfo::~MusInfo ()
{
}
bool MusInfo::SetPosition (int order)
bool MusInfo::SetPosition (unsigned int ms)
{
return false;
}
bool MusInfo::SetSubsong (int subsong)
{
return false;
}
@ -197,7 +202,7 @@ void I_ShutdownMusic(void)
}
void I_PlaySong (void *handle, int _looping, float rel_vol)
void I_PlaySong (void *handle, int _looping, float rel_vol, int subsong)
{
MusInfo *info = (MusInfo *)handle;
@ -206,7 +211,7 @@ void I_PlaySong (void *handle, int _looping, float rel_vol)
saved_relative_volume = relative_volume = rel_vol;
info->Stop ();
info->Play (_looping ? true : false);
info->Play (!!_looping, subsong);
info->m_NotStartedYet = false;
if (info->m_Status == MusInfo::STATE_Playing)
@ -256,7 +261,7 @@ void I_UnRegisterSong (void *handle)
}
}
void *I_RegisterURLSong (const char *url)
MusInfo *I_RegisterURLSong (const char *url)
{
StreamSong *song;
@ -269,7 +274,7 @@ void *I_RegisterURLSong (const char *url)
return NULL;
}
void *I_RegisterSong (const char *filename, char *musiccache, int offset, int len, int device)
MusInfo *I_RegisterSong (const char *filename, char *musiccache, int offset, int len, int device)
{
FILE *file;
MusInfo *info = NULL;
@ -539,7 +544,7 @@ void *I_RegisterSong (const char *filename, char *musiccache, int offset, int le
return info;
}
void *I_RegisterCDSong (int track, int id)
MusInfo *I_RegisterCDSong (int track, int id)
{
MusInfo *info = new CDSong (track, id);
@ -635,7 +640,7 @@ CCMD (writeopl)
}
else
{
dumper->Play(false);
dumper->Play(false, 0); // FIXME: Remember subsong.
delete dumper;
}
}
@ -673,7 +678,7 @@ CCMD (writewave)
}
else
{
dumper->Play(false);
dumper->Play(false, 0); // FIXME: Remember subsong
delete dumper;
}
}

View file

@ -54,14 +54,15 @@ void I_PauseSong (void *handle);
void I_ResumeSong (void *handle);
// Registers a song handle to song data.
void *I_RegisterSong (const char *file, char * musiccache, int offset, int length, int device);
void *I_RegisterCDSong (int track, int cdid = 0);
void *I_RegisterURLSong (const char *url);
class MusInfo;
MusInfo *I_RegisterSong (const char *file, char * musiccache, int offset, int length, int device);
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
MusInfo *I_RegisterURLSong (const char *url);
// Called by anything that wishes to start music.
// Plays a song, and when the song is done,
// starts playing it again in an endless loop.
void I_PlaySong (void *handle, int looping, float relative_vol=1.f);
void I_PlaySong (void *handle, int looping, float relative_vol=1.f, int subsong=0);
// Stops a song.
void I_StopSong (void *handle);
@ -75,4 +76,38 @@ bool I_SetSongPosition (void *handle, int order);
// Is the song still playing?
bool I_QrySongPlaying (void *handle);
// The base music class. Everything is derived from this --------------------
class MusInfo
{
public:
MusInfo ();
virtual ~MusInfo ();
virtual void MusicVolumeChanged(); // snd_musicvolume changed
virtual void TimidityVolumeChanged(); // timidity_mastervolume changed
virtual void Play (bool looping, int subsong) = 0;
virtual void Pause () = 0;
virtual void Resume () = 0;
virtual void Stop () = 0;
virtual bool IsPlaying () = 0;
virtual bool IsMIDI () const = 0;
virtual bool IsValid () const = 0;
virtual bool SetPosition (unsigned int ms);
virtual bool SetSubsong (int subsong);
virtual void Update();
virtual FString GetStats();
virtual MusInfo *GetOPLDumper(const char *filename);
virtual MusInfo *GetWaveDumper(const char *filename, int rate);
enum EState
{
STATE_Stopped,
STATE_Playing,
STATE_Paused
} m_Status;
bool m_Looping;
bool m_NotStartedYet; // Song has been created but not yet played
};
#endif //__I_MUSIC_H__

View file

@ -20,6 +20,7 @@
#include "c_cvars.h"
#include "mus2midi.h"
#include "i_sound.h"
#include "i_music.h"
void I_InitMusicWin32 ();
void I_ShutdownMusicWin32 ();
@ -29,38 +30,6 @@ extern float relative_volume;
EXTERN_CVAR (Float, timidity_mastervolume)
// The base music class. Everything is derived from this --------------------
class MusInfo
{
public:
MusInfo ();
virtual ~MusInfo ();
virtual void MusicVolumeChanged(); // snd_musicvolume changed
virtual void TimidityVolumeChanged(); // timidity_mastervolume changed
virtual void Play (bool looping) = 0;
virtual void Pause () = 0;
virtual void Resume () = 0;
virtual void Stop () = 0;
virtual bool IsPlaying () = 0;
virtual bool IsMIDI () const = 0;
virtual bool IsValid () const = 0;
virtual bool SetPosition (int order);
virtual void Update();
virtual FString GetStats();
virtual MusInfo *GetOPLDumper(const char *filename);
virtual MusInfo *GetWaveDumper(const char *filename, int rate);
enum EState
{
STATE_Stopped,
STATE_Playing,
STATE_Paused
} m_Status;
bool m_Looping;
bool m_NotStartedYet; // Song has been created but not yet played
};
// A device that provides a WinMM-like MIDI streaming interface -------------
#ifndef _WIN32
@ -302,7 +271,7 @@ public:
void MusicVolumeChanged();
void TimidityVolumeChanged();
void Play(bool looping);
void Play(bool looping, int subsong);
void Pause();
void Resume();
void Stop();
@ -441,14 +410,15 @@ class StreamSong : public MusInfo
public:
StreamSong (const char *file, int offset, int length);
~StreamSong ();
void Play (bool looping);
void Play (bool looping, int subsong);
void Pause ();
void Resume ();
void Stop ();
bool IsPlaying ();
bool IsMIDI () const { return false; }
bool IsValid () const { return m_Stream != NULL; }
bool SetPosition (int order);
bool SetPosition (unsigned int pos);
bool SetSubsong (int subsong);
FString GetStats();
protected:
@ -464,7 +434,7 @@ class TimiditySong : public StreamSong
public:
TimiditySong (FILE *file, char * musiccache, int length);
~TimiditySong ();
void Play (bool looping);
void Play (bool looping, int subsong);
void Stop ();
bool IsPlaying ();
bool IsValid () const { return CommandLine.Len() > 0; }
@ -502,7 +472,7 @@ class OPLMUSSong : public StreamSong
public:
OPLMUSSong (FILE *file, char *musiccache, int length);
~OPLMUSSong ();
void Play (bool looping);
void Play (bool looping, int subsong);
bool IsPlaying ();
bool IsValid () const;
void ResetChips ();
@ -530,7 +500,7 @@ class CDSong : public MusInfo
public:
CDSong (int track, int id);
~CDSong ();
void Play (bool looping);
void Play (bool looping, int subsong);
void Pause ();
void Resume ();
void Stop ();

View file

@ -302,7 +302,12 @@ SoundStream::~SoundStream ()
{
}
bool SoundStream::SetPosition(int pos)
bool SoundStream::SetPosition(unsigned int pos)
{
return false;
}
bool SoundStream::SetOrder(int order)
{
return false;
}

View file

@ -65,7 +65,8 @@ public:
virtual bool SetPaused(bool paused) = 0;
virtual unsigned int GetPosition() = 0;
virtual bool IsEnded() = 0;
virtual bool SetPosition(int pos);
virtual bool SetPosition(unsigned int pos);
virtual bool SetOrder(int order);
virtual FString GetStats();
};

View file

@ -1,7 +1,7 @@
#include "i_musicinterns.h"
#include "i_cd.h"
void CDSong::Play (bool looping)
void CDSong::Play (bool looping, int subsong)
{
m_Status = STATE_Stopped;
m_Looping = looping;

View file

@ -45,8 +45,9 @@ class input_mod : public StreamSong
public:
input_mod(DUH *myduh);
~input_mod();
bool SetPosition(int order);
void Play(bool looping);
//bool SetPosition(int ms);
bool SetSubsong(int subsong);
void Play(bool looping, int subsong);
FString GetStats();
FString Codec;
@ -1153,11 +1154,12 @@ input_mod::~input_mod()
//
//==========================================================================
void input_mod::Play(bool looping)
void input_mod::Play(bool looping, int order)
{
m_Status = STATE_Stopped;
m_Looping = looping;
start_order = order;
if (open2(0) && m_Stream->Play(m_Looping, 1))
{
m_Status = STATE_Playing;
@ -1166,15 +1168,11 @@ void input_mod::Play(bool looping)
//==========================================================================
//
// input_mod :: SetPosition
//
// FIXME: Pass the order number as a subsong parameter to Play, so we don't
// need to start playback at one position and then immediately throw that
// playback structure away and create a new one to go to the new order.
// input_mod :: SetSubsong
//
//==========================================================================
bool input_mod::SetPosition(int order)
bool input_mod::SetSubsong(int order)
{
if (order == start_order)
{

View file

@ -85,7 +85,7 @@ CUSTOM_CVAR (Int, timidity_frequency, 22050, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
self = 65000;
}
void TimiditySong::Play (bool looping)
void TimiditySong::Play (bool looping, int subsong)
{
m_Status = STATE_Stopped;
m_Looping = looping;

View file

@ -182,7 +182,7 @@ void MIDIStreamer::CheckCaps()
//
//==========================================================================
void MIDIStreamer::Play(bool looping)
void MIDIStreamer::Play(bool looping, int subsong)
{
DWORD tid;

View file

@ -52,7 +52,7 @@ bool OPLMUSSong::IsPlaying ()
return m_Status == STATE_Playing;
}
void OPLMUSSong::Play (bool looping)
void OPLMUSSong::Play (bool looping, int subsong)
{
m_Status = STATE_Stopped;
m_Looping = looping;

View file

@ -1,12 +1,16 @@
#include "i_musicinterns.h"
void StreamSong::Play (bool looping)
void StreamSong::Play (bool looping, int subsong)
{
m_Status = STATE_Stopped;
m_Looping = looping;
if (m_Stream->Play (m_Looping, 1))
{
if (subsong != 0)
{
m_Stream->SetOrder (subsong);
}
m_Status = STATE_Playing;
}
}
@ -70,14 +74,25 @@ bool StreamSong::IsPlaying ()
//
// StreamSong :: SetPosition
//
// Sets the current order number for a MOD-type song, or the position in ms
// for anything else.
// Sets the position in ms.
bool StreamSong::SetPosition(int order)
bool StreamSong::SetPosition(unsigned int pos)
{
if (m_Stream != NULL)
{
return m_Stream->SetPosition(order);
return m_Stream->SetPosition(pos);
}
else
{
return false;
}
}
bool StreamSong::SetSubsong(int subsong)
{
if (m_Stream != NULL)
{
return m_Stream->SetOrder(subsong);
}
else
{

View file

@ -139,8 +139,17 @@ public:
operator const char *() const { return Chars; }
const char *GetChars() const { return Chars; }
const char &operator[] (int index) const { return Chars[index]; }
#if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER)
// Compiling 32-bit Windows source with MSVC: size_t is typedefed to an
// unsigned int with the 64-bit portability warning attribute, so the
// prototype cannot substitute unsigned int for size_t, or you get
// spurious warnings.
const char &operator[] (size_t index) const { return Chars[index]; }
#else
const char &operator[] (unsigned int index) const { return Chars[index]; }
#endif
const char &operator[] (unsigned long index) const { return Chars[index]; }
const char &operator[] (unsigned long long index) const { return Chars[index]; }

View file

@ -465,7 +465,7 @@
</References>
<Files>
<Filter
Name="A Source Files"
Name="!Source Files"
Filter="c;cpp"
>
<File
@ -1078,7 +1078,7 @@
</Filter>
</Filter>
<Filter
Name="A Header Files"
Name="!Header Files"
Filter="h"
>
<File