- ZMusic interface refactoring.
Use global functions instead of the class interface which exposed too many implementation details.
This commit is contained in:
parent
30f2ac1e89
commit
dc32c2148a
9 changed files with 173 additions and 97 deletions
|
|
@ -454,8 +454,11 @@ bool ChangeMusicSetting(ZMusic::EIntConfigKey key, MusInfo *currSong, int value,
|
|||
return false;
|
||||
|
||||
case snd_mididevice:
|
||||
{
|
||||
bool change = miscConfig.snd_mididevice != value;
|
||||
miscConfig.snd_mididevice = value;
|
||||
return false;
|
||||
return change;
|
||||
}
|
||||
|
||||
case snd_outputrate:
|
||||
miscConfig.snd_outputrate = value;
|
||||
|
|
|
|||
|
|
@ -37,5 +37,4 @@ public:
|
|||
STATE_Paused
|
||||
} m_Status = STATE_Stopped;
|
||||
bool m_Looping = false;
|
||||
bool m_NotStartedYet = false; // Song has been created but not yet played
|
||||
};
|
||||
|
|
|
|||
|
|
@ -306,3 +306,102 @@ MusInfo *ZMusic_OpenCDSong (int track, int id)
|
|||
return info;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// streaming callback
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool ZMusic_FillStream(MusInfo* stream, void* buff, int len)
|
||||
{
|
||||
if (stream == nullptr) return false;
|
||||
return stream->ServiceStream(buff, len);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// starts playback
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void ZMusic_Start(MusInfo *song, int subsong, bool loop)
|
||||
{
|
||||
if (!song) return;
|
||||
song->Play(loop, subsong);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void ZMusic_Pause(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
song->Pause();
|
||||
}
|
||||
|
||||
void ZMusic_Resume(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
song->Resume();
|
||||
}
|
||||
|
||||
void ZMusic_Update(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
song->Update();
|
||||
}
|
||||
|
||||
bool ZMusic_IsPlaying(MusInfo *song)
|
||||
{
|
||||
if (!song) return false;
|
||||
return song->IsPlaying();
|
||||
}
|
||||
|
||||
void ZMusic_Stop(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
song->Stop();
|
||||
}
|
||||
|
||||
bool ZMusic_SetSubsong(MusInfo *song, int subsong)
|
||||
{
|
||||
if (!song) return false;
|
||||
return song->SetSubsong(subsong);
|
||||
}
|
||||
|
||||
bool ZMusic_IsLooping(MusInfo *song)
|
||||
{
|
||||
if (!song) return false;
|
||||
return song->m_Looping;
|
||||
}
|
||||
|
||||
bool ZMusic_IsMIDI(MusInfo *song)
|
||||
{
|
||||
if (!song) return false;
|
||||
return song->IsMIDI();
|
||||
}
|
||||
|
||||
SoundStreamInfo ZMusic_GetStreamInfo(MusInfo *song)
|
||||
{
|
||||
if (!song) return {};
|
||||
return song->GetStreamInfo();
|
||||
}
|
||||
|
||||
void ZMusic_Close(MusInfo *song)
|
||||
{
|
||||
if (song) delete song;
|
||||
}
|
||||
|
||||
void ZMusic_VolumeChanged(MusInfo *song)
|
||||
{
|
||||
if (song) song->MusicVolumeChanged();
|
||||
}
|
||||
|
||||
std::string ZMusic_GetStats(MusInfo *song)
|
||||
{
|
||||
if (!song) return "";
|
||||
return song->GetStats();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,21 @@ void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, c
|
|||
MusInfo *ZMusic_OpenSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args);
|
||||
MusInfo *ZMusic_OpenCDSong (int track, int cdid = 0);
|
||||
|
||||
class MusInfo;
|
||||
bool ZMusic_FillStream(MusInfo* stream, void* buff, int len);
|
||||
void ZMusic_Start(MusInfo *song, int subsong, bool loop);
|
||||
void ZMusic_Pause(MusInfo *song);
|
||||
void ZMusic_Resume(MusInfo *song);
|
||||
void ZMusic_Update(MusInfo *song);
|
||||
bool ZMusic_IsPlaying(MusInfo *song);
|
||||
void ZMusic_Stop(MusInfo *song);
|
||||
void ZMusic_Close(MusInfo *song);
|
||||
bool ZMusic_SetSubsong(MusInfo *song, int subsong);
|
||||
bool ZMusic_IsLooping(MusInfo *song);
|
||||
bool ZMusic_IsMIDI(MusInfo *song);
|
||||
void ZMusic_VolumeChanged(MusInfo *song);
|
||||
SoundStreamInfo ZMusic_GetStreamInfo(MusInfo *song);
|
||||
std::string ZMusic_GetStats(MusInfo *song);
|
||||
|
||||
// Configuration interface. The return value specifies if a music restart is needed.
|
||||
// RealValue should be written back to the CVAR or whatever other method the client uses to store configuration state.
|
||||
bool ChangeMusicSetting(ZMusic::EIntConfigKey key, MusInfo *song, int value, int *pRealValue = nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue