From 2b44d289cf5a074ccaa80aebcb663f68b02358fb Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Tue, 8 Jul 2008 22:07:15 +0000 Subject: [PATCH] LOOPSTART, LOOPLENGTH tag pair for ogg git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@298 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/meta/ogg_vorbis_file.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/meta/ogg_vorbis_file.c b/src/meta/ogg_vorbis_file.c index 77605d64..bfc94124 100644 --- a/src/meta/ogg_vorbis_file.c +++ b/src/meta/ogg_vorbis_file.c @@ -83,6 +83,8 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { int loop_flag = 0; int32_t loop_start = 0; + int loop_length_found = 0; + int32_t loop_length = 0; /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); @@ -146,12 +148,20 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { strstr(comment->user_comments[i],"LOOP_START=")== comment->user_comments[i] || strstr(comment->user_comments[i],"COMMENT=LOOPPOINT=")== + comment->user_comments[i] || + strstr(comment->user_comments[i],"LOOPSTART=")== comment->user_comments[i] ) { loop_start=atol(strrchr(comment->user_comments[i],'=')+1); loop_flag=1; break; } + else if (strstr(comment->user_comments[i],"LOOPLENGTH=")== + comment->user_comments[i]) { + loop_length=atol(strrchr(comment->user_comments[i],'=')+1); + loop_length_found=1; + break; + } } } @@ -171,7 +181,10 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) { if (loop_flag) { vgmstream->loop_start_sample = loop_start; - vgmstream->loop_end_sample = vgmstream->num_samples; + if (loop_length_found) + vgmstream->loop_end_sample = loop_start+loop_length; + else + vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_flag = loop_flag; } vgmstream->coding_type = coding_ogg_vorbis;