mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-30 20:03:44 +01:00
Fix segfault when resetting non-looping Vorbis/MPEG files
Also, apparently reset shouldn't reset the streamfiles
This commit is contained in:
parent
e5f2ab0236
commit
54d1995dc8
@ -411,7 +411,14 @@ void free_fsb_vorbis(vorbis_codec_data * data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset_fsb_vorbis(VGMSTREAM *vgmstream) {
|
void reset_fsb_vorbis(VGMSTREAM *vgmstream) {
|
||||||
seek_fsb_vorbis(vgmstream, 0);
|
#if FSB_VORBIS_ON
|
||||||
|
vorbis_codec_data *data = vgmstream->codec_data;
|
||||||
|
|
||||||
|
/* Seeking is provided by the Ogg layer, so with raw vorbis we need seek tables instead.
|
||||||
|
* To avoid having to parse different formats we'll just discard until the expected sample */
|
||||||
|
vorbis_synthesis_restart(&data->vd);
|
||||||
|
data->samples_to_discard = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void seek_fsb_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
void seek_fsb_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
||||||
@ -422,7 +429,8 @@ void seek_fsb_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
|||||||
* To avoid having to parse different formats we'll just discard until the expected sample */
|
* To avoid having to parse different formats we'll just discard until the expected sample */
|
||||||
vorbis_synthesis_restart(&data->vd);
|
vorbis_synthesis_restart(&data->vd);
|
||||||
data->samples_to_discard = num_sample;
|
data->samples_to_discard = num_sample;
|
||||||
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset;
|
if (vgmstream->loop_ch)
|
||||||
|
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,7 +685,6 @@ void reset_mpeg(VGMSTREAM *vgmstream) {
|
|||||||
int i;
|
int i;
|
||||||
for (i=0; i < data->ms_size; i++) {
|
for (i=0; i < data->ms_size; i++) {
|
||||||
mpg123_feedseek(data->ms[i],0,SEEK_SET,&input_offset);
|
mpg123_feedseek(data->ms[i],0,SEEK_SET,&input_offset);
|
||||||
vgmstream->loop_ch[i].offset = vgmstream->loop_ch[i].channel_start_offset + input_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data->bytes_in_interleave_buffer = 0;
|
data->bytes_in_interleave_buffer = 0;
|
||||||
@ -701,13 +700,15 @@ void seek_mpeg(VGMSTREAM *vgmstream, int32_t num_sample) {
|
|||||||
/* seek multistream */
|
/* seek multistream */
|
||||||
if (!data->interleaved) {
|
if (!data->interleaved) {
|
||||||
mpg123_feedseek(data->m, num_sample,SEEK_SET,&input_offset);
|
mpg123_feedseek(data->m, num_sample,SEEK_SET,&input_offset);
|
||||||
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset + input_offset;
|
if (vgmstream->loop_ch)
|
||||||
|
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset + input_offset;
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
/* re-start from 0 */
|
/* re-start from 0 */
|
||||||
for (i=0; i < data->ms_size; i++) {
|
for (i=0; i < data->ms_size; i++) {
|
||||||
mpg123_feedseek(data->ms[i],0,SEEK_SET,&input_offset);
|
mpg123_feedseek(data->ms[i],0,SEEK_SET,&input_offset);
|
||||||
vgmstream->loop_ch[i].offset = vgmstream->loop_ch[i].channel_start_offset;
|
if (vgmstream->loop_ch)
|
||||||
|
vgmstream->loop_ch[i].offset = vgmstream->loop_ch[i].channel_start_offset;
|
||||||
}
|
}
|
||||||
/* manually add skip samples, since we don't really know the correct offset */
|
/* manually add skip samples, since we don't really know the correct offset */
|
||||||
data->samples_to_discard = num_sample;
|
data->samples_to_discard = num_sample;
|
||||||
|
@ -294,7 +294,14 @@ void free_wwise_vorbis(vorbis_codec_data * data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset_wwise_vorbis(VGMSTREAM *vgmstream) {
|
void reset_wwise_vorbis(VGMSTREAM *vgmstream) {
|
||||||
seek_wwise_vorbis(vgmstream, 0);
|
#if WWISE_VORBIS_ON
|
||||||
|
vorbis_codec_data *data = vgmstream->codec_data;
|
||||||
|
|
||||||
|
/* Seeking is provided by the Ogg layer, so with raw vorbis we need seek tables instead.
|
||||||
|
* To avoid having to parse different formats we'll just discard until the expected sample */
|
||||||
|
vorbis_synthesis_restart(&data->vd);
|
||||||
|
data->samples_to_discard = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void seek_wwise_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
void seek_wwise_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
||||||
@ -305,7 +312,8 @@ void seek_wwise_vorbis(VGMSTREAM *vgmstream, int32_t num_sample) {
|
|||||||
* To avoid having to parse different formats we'll just discard until the expected sample */
|
* To avoid having to parse different formats we'll just discard until the expected sample */
|
||||||
vorbis_synthesis_restart(&data->vd);
|
vorbis_synthesis_restart(&data->vd);
|
||||||
data->samples_to_discard = num_sample;
|
data->samples_to_discard = num_sample;
|
||||||
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset;
|
if (vgmstream->loop_ch) /* this func is only using for looping though */
|
||||||
|
vgmstream->loop_ch[0].offset = vgmstream->loop_ch[0].channel_start_offset;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user