From 40e445aae6889f9160caa30e826aa277e8b6a2a9 Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Fri, 16 May 2008 21:13:19 +0000 Subject: [PATCH] hopefully make seeking backwards a little safer git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@136 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- winamp/in_vgmstream.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 21cccef3..a5571df4 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -361,13 +361,21 @@ DWORD WINAPI __stdcall decode(void *arg) { if (seek_needed_samples != -1) { /* reset if we need to seek backwards */ if (seek_needed_samples < decode_pos_samples) { - VGMSTREAM * temp; - temp = vgmstream; - vgmstream = NULL; - close_vgmstream(temp); + VGMSTREAM * new_temp; + VGMSTREAM * old_temp; - temp = init_vgmstream(lastfn); - vgmstream = temp; + new_temp = init_vgmstream(lastfn); + if (!new_temp) { + PostMessage(input_module.hMainWindow, /* message dest */ + WM_WA_MPEG_EOF, /* message id */ + 0,0); /* no parameters */ + return 0; + } + + old_temp = vgmstream; + vgmstream = new_temp; + + close_vgmstream(old_temp); decode_pos_samples = 0; decode_pos_ms = 0;