diff --git a/include/zmusic.h b/include/zmusic.h index ec5b41c..f82aca7 100644 --- a/include/zmusic.h +++ b/include/zmusic.h @@ -65,14 +65,14 @@ typedef struct ZMusicSoundStreamInfo_ typedef enum EZMusicSampleType_ { - SampleType_UInt8, - SampleType_Int16 + ZMusic_Decoder_SampleType_UInt8, + ZMusic_Decoder_SampleType_Int16 } EZMusicSampleType; typedef enum EZMusicChannelConfig_ { - ChannelConfig_Mono, - ChannelConfig_Stereo + ZMusic_Decoder_ChannelConfig_Mono, + ZMusic_Decoder_ChannelConfig_Stereo } EZMusicChannelConfig; typedef enum EZMusicIntConfigKey_ @@ -319,58 +319,46 @@ extern "C" ZMUSIC_DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, ZMusicSoundStreamInfo *info); // 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. - ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); - ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingFloat(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); - ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingString(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_ChangeSettingInt(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_ChangeSettingFloat(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_ChangeSettingString(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); ZMUSIC_DLL_IMPORT const char *ZMusic_GetStats(ZMusic_MusicStream song); - ZMUSIC_DLL_IMPORT struct SoundDecoder* CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic); - ZMUSIC_DLL_IMPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); - ZMUSIC_DLL_IMPORT size_t SoundDecoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length); - ZMUSIC_DLL_IMPORT void SoundDecoder_Close(struct SoundDecoder* decoder); - ZMUSIC_DLL_IMPORT void FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); + ZMUSIC_DLL_IMPORT struct SoundDecoder* ZMusic_CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic); + ZMUSIC_DLL_IMPORT void ZMusic_Decoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); + ZMUSIC_DLL_IMPORT size_t ZMusic_Decoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length); + ZMUSIC_DLL_IMPORT void ZMusic_Decoder_Close(struct SoundDecoder* decoder); + ZMUSIC_DLL_IMPORT void ZMusic_FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); // The rest of the decoder interface is only useful for streaming music. ZMUSIC_DLL_IMPORT const ZMusicMidiOutDevice *ZMusic_GetMidiDevices(int *pAmount); ZMUSIC_DLL_IMPORT int ZMusic_GetADLBanks(const char* const** pNames); // Direct access to the CD drive. - // Stops playing the CD - ZMUSIC_DLL_IMPORT void CD_Stop(); - - // Pauses CD playing - ZMUSIC_DLL_IMPORT void CD_Pause(); - - // Resumes CD playback after pausing - ZMUSIC_DLL_IMPORT zmusic_bool CD_Resume(); - - // Eject the CD tray - ZMUSIC_DLL_IMPORT void CD_Eject(); - - // Close the CD tray - ZMUSIC_DLL_IMPORT zmusic_bool CD_UnEject(); - - // Closes a CD device previously opened with CD_Init - ZMUSIC_DLL_IMPORT void CD_Close(); - - ZMUSIC_DLL_IMPORT zmusic_bool CD_Enable(const char* drive); + ZMUSIC_DLL_IMPORT void ZMusic_CD_Stop(); + ZMUSIC_DLL_IMPORT void ZMusic_CD_Pause(); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_CD_Resume(); + ZMUSIC_DLL_IMPORT void ZMusic_CD_Eject(); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_CD_UnEject(); + ZMUSIC_DLL_IMPORT void ZMusic_CD_Close(); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_CD_Enable(const char* drive); #ifdef __cplusplus } -inline bool ChangeMusicSetting(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue = NULL) +inline bool ZMusic_ChangeSetting(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue = NULL) { - return ChangeMusicSettingInt(key, song, value, pRealValue); + return ZMusic_ChangeSettingInt(key, song, value, pRealValue); } -inline bool ChangeMusicSetting(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue = NULL) +inline bool ZMusic_ChangeSetting(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue = NULL) { - return ChangeMusicSettingFloat(key, song, value, pRealValue); + return ZMusic_ChangeSettingFloat(key, song, value, pRealValue); } -inline bool ChangeMusicSetting(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value) +inline bool ZMusic_ChangeSetting(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value) { - return ChangeMusicSettingString(key, song, value); + return ZMusic_ChangeSettingString(key, song, value); } #endif @@ -404,14 +392,14 @@ typedef zmusic_bool (*pfn_ZMusic_IsMIDI)(ZMusic_MusicStream song); typedef void (*pfn_ZMusic_VolumeChanged)(ZMusic_MusicStream song); typedef zmusic_bool (*pfn_ZMusic_WriteSMF)(ZMusic_MidiSource source, const char* fn, int looplimit); typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, ZMusicSoundStreamInfo *info); -typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); -typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); -typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); +typedef zmusic_bool (*pfn_ZMusic_ChangeSettingInt)(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); +typedef zmusic_bool (*pfn_ZMusic_ChangeSettingFloat)(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); +typedef zmusic_bool (*pfn_ZMusic_ChangeSettingString)(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); typedef const char *(*pfn_ZMusic_GetStats)(ZMusic_MusicStream song); -typedef struct SoundDecoder* (*pfn_CreateDecoder)(const uint8_t* data, size_t size, zmusic_bool isstatic); -typedef void (*pfn_SoundDecoder_GetInfo)(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); -typedef size_t (*pfn_SoundDecoder_Read)(struct SoundDecoder* decoder, void* buffer, size_t length); -typedef void (*pfn_SoundDecoder_Close)(struct SoundDecoder* decoder); +typedef struct SoundDecoder* (*pfn_ZMusic_CreateDecoder)(const uint8_t* data, size_t size, zmusic_bool isstatic); +typedef void (*pfn_ZMusic_Decoder_GetInfo)(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); +typedef size_t (*pfn_ZMusic_Decoder_Read)(struct SoundDecoder* decoder, void* buffer, size_t length); +typedef void (*pfn_ZMusic_Decoder_Close)(struct SoundDecoder* decoder); typedef void (*pfn_FindLoopTags)(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); typedef const ZMusicMidiOutDevice *(*pfn_ZMusic_GetMidiDevices)(int *pAmount); diff --git a/source/decoder/mpg123_decoder.cpp b/source/decoder/mpg123_decoder.cpp index a7286e5..f8857eb 100644 --- a/source/decoder/mpg123_decoder.cpp +++ b/source/decoder/mpg123_decoder.cpp @@ -162,11 +162,11 @@ void MPG123Decoder::getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMusi *samplerate = srate; if(channels == 2) - *chans = ChannelConfig_Stereo; + *chans = ZMusic_Decoder_ChannelConfig_Stereo; else - *chans = ChannelConfig_Mono; + *chans = ZMusic_Decoder_ChannelConfig_Mono; - *type = SampleType_Int16; + *type = ZMusic_Decoder_SampleType_Int16; } size_t MPG123Decoder::read(char *buffer, size_t bytes) diff --git a/source/decoder/sndfile_decoder.cpp b/source/decoder/sndfile_decoder.cpp index db0407b..23e3d5b 100644 --- a/source/decoder/sndfile_decoder.cpp +++ b/source/decoder/sndfile_decoder.cpp @@ -138,11 +138,11 @@ void SndFileDecoder::getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMus *samplerate = SndInfo.samplerate; if(SndInfo.channels == 2) - *chans = ChannelConfig_Stereo; + *chans = ZMusic_Decoder_ChannelConfig_Stereo; else - *chans = ChannelConfig_Mono; + *chans = ZMusic_Decoder_ChannelConfig_Mono; - *type = SampleType_Int16; + *type = ZMusic_Decoder_SampleType_Int16; } size_t SndFileDecoder::read(char *buffer, size_t bytes) diff --git a/source/decoder/sounddecoder.cpp b/source/decoder/sounddecoder.cpp index ebc71e2..9a2257a 100644 --- a/source/decoder/sounddecoder.cpp +++ b/source/decoder/sounddecoder.cpp @@ -37,7 +37,7 @@ #include "sndfile_decoder.h" #include "mpg123_decoder.h" -SoundDecoder *SoundDecoder::CreateDecoder(MusicIO::FileInterface *reader) +SoundDecoder *SoundDecoder::ZMusic_CreateDecoder(MusicIO::FileInterface *reader) { SoundDecoder *decoder = NULL; auto pos = reader->tell(); @@ -97,7 +97,7 @@ short* dumb_decode_vorbis(int outlen, const void* oggstream, int sizebytes) // The decoder will take ownership of the reader if it succeeds so this may not be a local variable. MusicIO::MemoryReader* reader = new MusicIO::MemoryReader((const uint8_t*)oggstream, sizebytes); - SoundDecoder* decoder = SoundDecoder::CreateDecoder(reader); + SoundDecoder* decoder = SoundDecoder::ZMusic_CreateDecoder(reader); if (!decoder) { reader->close(); @@ -105,7 +105,7 @@ short* dumb_decode_vorbis(int outlen, const void* oggstream, int sizebytes) } decoder->getInfo(&srate, &chans, &type); - if (chans != ChannelConfig_Mono || type != SampleType_Int16) + if (chans != ZMusic_Decoder_ChannelConfig_Mono || type != ZMusic_Decoder_SampleType_Int16) { delete decoder; return samples; @@ -116,29 +116,29 @@ short* dumb_decode_vorbis(int outlen, const void* oggstream, int sizebytes) return samples; } -DLL_EXPORT struct SoundDecoder* CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic) +DLL_EXPORT struct SoundDecoder* ZMusic_CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic) { MusicIO::FileInterface* reader; if (isstatic) reader = new MusicIO::MemoryReader(data, (long)size); else reader = new MusicIO::VectorReader(data, size); - auto res = SoundDecoder::CreateDecoder(reader); + auto res = SoundDecoder::ZMusic_CreateDecoder(reader); if (!res) reader->close(); return res; } -DLL_EXPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type) +DLL_EXPORT void ZMusic_Decoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type) { if (decoder) decoder->getInfo(samplerate, chans, type); else if (samplerate) *samplerate = 0; } -DLL_EXPORT size_t SoundDecoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length) +DLL_EXPORT size_t ZMusic_Decoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length) { if (decoder) return decoder->read((char*)buffer, length); else return 0; } -DLL_EXPORT void SoundDecoder_Close(struct SoundDecoder* decoder) +DLL_EXPORT void ZMusic_Decoder_Close(struct SoundDecoder* decoder) { if (decoder) delete decoder; } diff --git a/source/musicformats/win32/i_cd.cpp b/source/musicformats/win32/i_cd.cpp index 5eb8b41..5c0f83d 100644 --- a/source/musicformats/win32/i_cd.cpp +++ b/source/musicformats/win32/i_cd.cpp @@ -414,13 +414,13 @@ static void KillThread () // //========================================================================== -DLL_EXPORT zmusic_bool CD_Enable (const char *cd_drive) +DLL_EXPORT zmusic_bool ZMusic_CD_Enable (const char *cd_drive) { if (!cd_drive) { // lock the CD system. Enabled = false; - CD_Close(); + ZMusic_CD_Close(); return false; } Enabled = true; // this must have been called at least once to consider the use of the CD system @@ -452,7 +452,7 @@ bool CD_Init (int device) if (Inited != device) { - CD_Close (); + ZMusic_CD_Close (); if (CDThread->SendMessage (CDM_Init, device, 0, 0, true)) { @@ -487,7 +487,7 @@ bool CD_InitID (unsigned int id, int guess) { return true; } - CD_Close (); + ZMusic_CD_Close (); } for (drive = 'V'; drive < 'Z'; drive++) @@ -502,7 +502,7 @@ bool CD_InitID (unsigned int id, int guess) { return true; } - CD_Close (); + ZMusic_CD_Close (); } } return false; @@ -510,11 +510,11 @@ bool CD_InitID (unsigned int id, int guess) //========================================================================== // -// CD_Close +// ZMusic_CD_Close // //========================================================================== -DLL_EXPORT void CD_Close () +DLL_EXPORT void ZMusic_CD_Close () { if (Inited != NOT_INITED) { @@ -525,11 +525,11 @@ DLL_EXPORT void CD_Close () //========================================================================== // -// CD_Eject +// ZMusic_CD_Eject // //========================================================================== -DLL_EXPORT void CD_Eject () +DLL_EXPORT void ZMusic_CD_Eject () { if (Inited != NOT_INITED) CDThread->SendMessage (CDM_Eject, 0, 0, 0, false); @@ -537,11 +537,11 @@ DLL_EXPORT void CD_Eject () //========================================================================== // -// CD_UnEject +// ZMusic_CD_UnEject // //========================================================================== -DLL_EXPORT zmusic_bool CD_UnEject () +DLL_EXPORT zmusic_bool ZMusic_CD_UnEject () { if (Inited == NOT_INITED) return false; @@ -551,11 +551,11 @@ DLL_EXPORT zmusic_bool CD_UnEject () //========================================================================== // -// CD_Stop +// ZMusic_CD_Stop // //========================================================================== -DLL_EXPORT void CD_Stop () +DLL_EXPORT void ZMusic_CD_Stop () { if (Inited != NOT_INITED) CDThread->SendMessage (CDM_Stop, 0, 0, 0, false); @@ -615,11 +615,11 @@ void CD_PlayCDNoWait (bool looping) //========================================================================== // -// CD_Pause +// ZMusic_CD_Pause // //========================================================================== -DLL_EXPORT void CD_Pause () +DLL_EXPORT void ZMusic_CD_Pause () { if (Inited != NOT_INITED) CDThread->SendMessage (CDM_Pause, 0, 0, 0, false); @@ -627,11 +627,11 @@ DLL_EXPORT void CD_Pause () //========================================================================== // -// CD_Resume +// ZMusic_CD_Resume // //========================================================================== -DLL_EXPORT zmusic_bool CD_Resume () +DLL_EXPORT zmusic_bool ZMusic_CD_Resume () { if (Inited == NOT_INITED) return false; diff --git a/source/streamsources/music_libsndfile.cpp b/source/streamsources/music_libsndfile.cpp index 76288b0..1a1728f 100644 --- a/source/streamsources/music_libsndfile.cpp +++ b/source/streamsources/music_libsndfile.cpp @@ -364,7 +364,7 @@ static void FindOggComments(MusicIO::FileInterface *fr, uint32_t *loop_start, zm } } -void FindLoopTags(MusicIO::FileInterface *fr, uint32_t *start, zmusic_bool *startass, uint32_t *end, zmusic_bool *endass) +void ZMusic_FindLoopTags(MusicIO::FileInterface *fr, uint32_t *start, zmusic_bool *startass, uint32_t *end, zmusic_bool *endass) { uint8_t signature[4]; @@ -375,10 +375,10 @@ void FindLoopTags(MusicIO::FileInterface *fr, uint32_t *start, zmusic_bool *star FindOggComments(fr, start, startass, end, endass); } -DLL_EXPORT void FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass) +DLL_EXPORT void ZMusic_FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass) { MusicIO::FileInterface* reader = new MusicIO::MemoryReader(data, (long)size); - FindLoopTags(reader, start, startass, end, endass); + ZMusic_FindLoopTags(reader, start, startass, end, endass); reader->close(); } @@ -394,10 +394,10 @@ StreamSource *SndFile_OpenSong(MusicIO::FileInterface *fr) uint32_t loop_start = 0, loop_end = ~0u; zmusic_bool startass = false, endass = false; - FindLoopTags(fr, &loop_start, &startass, &loop_end, &endass); + ZMusic_FindLoopTags(fr, &loop_start, &startass, &loop_end, &endass); fr->seek(0, SEEK_SET); - auto decoder = SoundDecoder::CreateDecoder(fr); + auto decoder = SoundDecoder::ZMusic_CreateDecoder(fr); if (decoder == nullptr) return nullptr; // If this fails the file reader has not been taken over and the caller needs to clean up. This is to allow further analysis of the passed file. return new SndFileSong(decoder, loop_start, loop_end, startass, endass); } @@ -427,7 +427,7 @@ SndFileSong::SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t lo Loop_Start = loop_start; Loop_End = sampleLength == 0 ? loop_end : std::min(loop_end, sampleLength); Decoder = decoder; - Channels = iChannels == ChannelConfig_Stereo? 2:1; + Channels = iChannels == ZMusic_Decoder_ChannelConfig_Stereo? 2:1; } ZMusicSoundStreamInfo SndFileSong::GetFormat() diff --git a/source/zmusic/configuration.cpp b/source/zmusic/configuration.cpp index d32a5fb..08e1f27 100644 --- a/source/zmusic/configuration.cpp +++ b/source/zmusic/configuration.cpp @@ -320,7 +320,7 @@ static void TimidityPlus_SetReverb() // //========================================================================== -DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EZMusicIntConfigKey key, MusInfo *currSong, int value, int *pRealValue) +DLL_EXPORT zmusic_bool ZMusic_ChangeSettingInt(EZMusicIntConfigKey key, MusInfo *currSong, int value, int *pRealValue) { switch (key) { @@ -651,7 +651,7 @@ DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EZMusicIntConfigKey key, MusInfo *c return false; } -DLL_EXPORT zmusic_bool ChangeMusicSettingFloat(EZMusicFloatConfigKey key, MusInfo* currSong, float value, float *pRealValue) +DLL_EXPORT zmusic_bool ZMusic_ChangeSettingFloat(EZMusicFloatConfigKey key, MusInfo* currSong, float value, float *pRealValue) { switch (key) { @@ -805,7 +805,7 @@ DLL_EXPORT zmusic_bool ChangeMusicSettingFloat(EZMusicFloatConfigKey key, MusInf return false; } -DLL_EXPORT zmusic_bool ChangeMusicSettingString(EZMusicStringConfigKey key, MusInfo* currSong, const char *value) +DLL_EXPORT zmusic_bool ZMusic_ChangeSettingString(EZMusicStringConfigKey key, MusInfo* currSong, const char *value) { switch (key) {