Propose to fix AVI index
authorClément Stenac <zorglub@videolan.org>
Mon, 12 Dec 2005 18:02:27 +0000 (18:02 +0000)
committerClément Stenac <zorglub@videolan.org>
Mon, 12 Dec 2005 18:02:27 +0000 (18:02 +0000)
modules/demux/avi/avi.c
src/interface/interaction.c

index 878b3fe..a8b190a 100644 (file)
@@ -28,6 +28,8 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
+#include <vlc_interaction.h>
+
 #include "vlc_meta.h"
 #include "codecs.h"
 
@@ -198,6 +200,8 @@ static int Open( vlc_object_t * p_this )
     demux_t  *p_demux = (demux_t *)p_this;
     demux_sys_t     *p_sys;
 
+    vlc_bool_t       b_index = VLC_FALSE;
+
     avi_chunk_t         ck_riff;
     avi_chunk_list_t    *p_riff = (avi_chunk_list_t*)&ck_riff;
     avi_chunk_list_t    *p_hdrl, *p_movi;
@@ -509,6 +513,7 @@ static int Open( vlc_object_t * p_this )
 
     if( config_GetInt( p_demux, "avi-index" ) )
     {
+aviindex:
         if( p_sys->b_seekable )
         {
             AVI_IndexCreate( p_demux );
@@ -530,8 +535,29 @@ static int Open( vlc_object_t * p_this )
                           (mtime_t)p_avih->i_microsecperframe /
                           (mtime_t)1000000 )
     {
-        msg_Warn( p_demux, "broken or missing index, 'seek' will be axproximative or will have strange behavour" );
+        msg_Warn( p_demux, "broken or missing index, 'seek' will be axproximative or will have "
+                           "strange behavour" );
+        if( !b_index )
+        {
+            int i_create;
+            i_create = intf_UserYesNo( p_demux, "AVI Index", _("This AVI file is broken. Seeking will not "
+                                       "work correctly.\nDo you want to "
+                                       "try to repair it (this might take a long time) ?" ) );
+            if( i_create == DIALOG_OK_YES )
+            {
+                b_index = VLC_TRUE;
+                msg_Dbg( p_demux, "Fixing AVI index" );
+                goto aviindex;
+            }
+            else if( i_create == DIALOG_CANCELLED )
+            {
+                /* Kill input */
+                p_demux->p_parent->b_die = VLC_TRUE;
+                goto error;
+            }
+        }
     }
+
     /* fix some BeOS MediaKit generated file */
     for( i = 0 ; i < p_sys->i_track; i++ )
     {
index 7b6545c..cc0929c 100644 (file)
@@ -139,8 +139,6 @@ void intf_InteractionManage( playlist_t *p_playlist )
             p_dialog->i_return = DIALOG_DEFAULT;
             if( p_dialog->i_flags & DIALOG_OK_CANCEL )
                 p_dialog->i_return = DIALOG_CANCELLED;
-            if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
-                p_dialog->i_return = DIALOG_CANCELLED;
 
             // Pretend we have hidden and destroyed it
             if( p_dialog->i_status == HIDDEN_DIALOG )