mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
AudioLib: Fix improper matching of loop tags with initial substrings of them, and add proper support for LOOP as a synonym of LOOP_START.
git-svn-id: https://svn.eduke32.com/eduke32@5899 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8169365820
commit
c9de8faefb
4 changed files with 32 additions and 18 deletions
|
@ -194,7 +194,7 @@ extern const int16_t *MV_RightVolume;
|
|||
extern int32_t MV_SampleSize;
|
||||
extern int32_t MV_RightChannelOffset;
|
||||
|
||||
#define loopStartTagCount 2
|
||||
#define loopStartTagCount 3
|
||||
extern const char *loopStartTags[loopStartTagCount];
|
||||
#define loopEndTagCount 2
|
||||
extern const char *loopEndTags[loopEndTagCount];
|
||||
|
|
|
@ -553,7 +553,6 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
|
|||
if (tags->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
|
||||
{
|
||||
FLAC__uint32 comment;
|
||||
uint8_t loopTagCount;
|
||||
for (comment = 0; comment < tags->data.vorbis_comment.num_comments; ++comment)
|
||||
{
|
||||
const char *entry = (const char *)tags->data.vorbis_comment.comments[comment].entry;
|
||||
|
@ -563,23 +562,29 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
|
|||
const size_t field = value - entry;
|
||||
value += 1;
|
||||
|
||||
for (loopTagCount = 0; loopTagCount < loopStartTagCount && vc_loopstart == NULL;
|
||||
++loopTagCount)
|
||||
if (strncasecmp(entry, loopStartTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopStartTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_loopstart = strdup(value);
|
||||
}
|
||||
|
||||
for (loopTagCount = 0; loopTagCount < loopEndTagCount && vc_loopend == NULL;
|
||||
++loopTagCount)
|
||||
if (strncasecmp(entry, loopEndTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopEndTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_loopend = strdup(value);
|
||||
}
|
||||
|
||||
for (loopTagCount = 0; loopTagCount < loopLengthTagCount && vc_looplength == NULL;
|
||||
++loopTagCount)
|
||||
if (strncasecmp(entry, loopLengthTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopLengthTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_looplength = strdup(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__metadata_object_delete(
|
||||
tags); // If it were not for this, I would assign pointers instead of strdup().
|
||||
|
|
|
@ -1014,6 +1014,6 @@ int32_t MV_Shutdown(void)
|
|||
|
||||
void MV_SetPrintf(void (*function)(const char *, ...)) { MV_Printf = function; }
|
||||
|
||||
const char *loopStartTags[loopStartTagCount] = { "LOOP_START", "LOOPSTART" };
|
||||
const char *loopStartTags[loopStartTagCount] = { "LOOP_START", "LOOPSTART", "LOOP" };
|
||||
const char *loopEndTags[loopEndTagCount] = { "LOOP_END", "LOOPEND" };
|
||||
const char *loopLengthTags[loopLengthTagCount] = { "LOOP_LENGTH", "LOOPLENGTH" };
|
||||
|
|
|
@ -83,19 +83,28 @@ static void MV_GetVorbisCommentLoops(VoiceNode *voice, vorbis_comment *vc)
|
|||
const size_t field = value - entry;
|
||||
value += 1;
|
||||
|
||||
for (uint8_t loopTagCount = 0; loopTagCount < loopStartTagCount && vc_loopstart == NULL; ++loopTagCount)
|
||||
if (strncasecmp(entry, loopStartTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopStartTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_loopstart = value;
|
||||
}
|
||||
|
||||
for (uint8_t loopTagCount = 0; loopTagCount < loopEndTagCount && vc_loopend == NULL; ++loopTagCount)
|
||||
if (strncasecmp(entry, loopEndTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopEndTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_loopend = value;
|
||||
}
|
||||
|
||||
for (uint8_t loopTagCount = 0; loopTagCount < loopLengthTagCount && vc_looplength == NULL; ++loopTagCount)
|
||||
if (strncasecmp(entry, loopLengthTags[loopTagCount], field) == 0)
|
||||
for (size_t t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopLengthTags[t];
|
||||
if (field == strlen(tag) && strncasecmp(entry, tag, field) == 0)
|
||||
vc_looplength = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vc_loopstart != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue