]> git.sesse.net Git - vlc/blobdiff - modules/demux/avi/avi.c
ps: fix division by zero when seeking (fixes #2633)
[vlc] / modules / demux / avi / avi.c
index 7d398e8550f960377fe8647463b244e897b03ad7..ec31313e0e831b88ba83bbb41996ba62b199a08e 100644 (file)
@@ -32,7 +32,7 @@
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
 
-#include <vlc_interface.h>
+#include <vlc_dialog.h>
 
 #include <vlc_meta.h>
 #include <vlc_codecs.h>
@@ -68,10 +68,10 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_INPUT_DEMUX )
 
     add_bool( "avi-interleaved", 0, NULL,
-              INTERLEAVE_TEXT, INTERLEAVE_LONGTEXT, true );
+              INTERLEAVE_TEXT, INTERLEAVE_LONGTEXT, true )
     add_integer( "avi-index", 0, NULL,
-              INDEX_TEXT, INDEX_LONGTEXT, false );
-        change_integer_list( pi_index, ppsz_indexes, NULL );
+              INDEX_TEXT, INDEX_LONGTEXT, false )
+        change_integer_list( pi_index, ppsz_indexes, NULL )
 
     set_callbacks( Open, Close )
 vlc_module_end ()
@@ -675,23 +675,20 @@ aviindex:
                 b_index = true;
                 goto aviindex;
             }
-            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?\n\nThis might take a long time." ),
-                        _( "Repair" ), _( "Don't repair" ), _( "Cancel") );
-            if( i_create == DIALOG_OK_YES )
+            switch( dialog_Question( p_demux, _("AVI Index") ,
+               _( "This AVI file is broken. Seeking will not work correctly.\n"
+                  "Do you want to try to fix it?\n\n"
+                  "This might take a long time." ),
+                  _( "Repair" ), _( "Don't repair" ), _( "Cancel") ) )
             {
-                b_index = true;
-                msg_Dbg( p_demux, "Fixing AVI index" );
-                goto aviindex;
-            }
-            else if( i_create == DIALOG_CANCELLED )
-            {
-                /* Kill input */
-                vlc_object_kill( p_demux->p_parent );
-                goto error;
+                case 1:
+                    b_index = true;
+                    msg_Dbg( p_demux, "Fixing AVI index" );
+                    goto aviindex;
+                case 3:
+                    /* Kill input */
+                    vlc_object_kill( p_demux->p_parent );
+                    goto error;
             }
         }
     }
@@ -2375,7 +2372,7 @@ static void AVI_IndexCreate( demux_t *p_demux )
     off_t i_movi_end;
 
     mtime_t i_dialog_update;
-    int     i_dialog_id;
+    dialog_progress_bar_t *p_dialog = NULL;
 
     p_riff = AVI_ChunkFind( &p_sys->ck_root, AVIFOURCC_RIFF, 0);
     p_movi = AVI_ChunkFind( p_riff, AVIFOURCC_movi, 0);
@@ -2400,10 +2397,10 @@ static void AVI_IndexCreate( demux_t *p_demux )
 
 
     /* Only show dialog if AVI is > 10MB */
-    i_dialog_id = -1;
     i_dialog_update = mdate();
     if( stream_Size( p_demux->s ) > 10000000 )
-        i_dialog_id = intf_IntfProgress( p_demux, _("Fixing AVI Index..."), 0.0 );
+        p_dialog = dialog_ProgressCreate( p_demux, NULL,
+                                       _("Fixing AVI Index..."), _("Cancel") );
 
     for( ;; )
     {
@@ -2413,15 +2410,14 @@ static void AVI_IndexCreate( demux_t *p_demux )
             break;
 
         /* Don't update/check dialog too often */
-        if( i_dialog_id > 0 && mdate() - i_dialog_update > 100000 )
+        if( p_dialog && mdate() - i_dialog_update > 100000 )
         {
-            if( intf_ProgressIsCancelled( p_demux, i_dialog_id ) )
+            if( dialog_ProgressCancelled( p_dialog ) )
                 break;
 
-            double f_pos = 100.0 * stream_Tell( p_demux->s ) /
-                           stream_Size( p_demux->s );
-            intf_ProgressUpdate( p_demux, i_dialog_id,
-                                 _( "Fixing AVI Index..." ), f_pos, -1 );
+            float f_pos = (float)stream_Tell( p_demux->s ) /
+                          (float)stream_Size( p_demux->s );
+            dialog_ProgressSet( p_dialog, NULL, f_pos );
 
             i_dialog_update = mdate();
         }
@@ -2484,8 +2480,8 @@ static void AVI_IndexCreate( demux_t *p_demux )
     }
 
 print_stat:
-    if( i_dialog_id > 0 )
-        intf_UserHide( p_demux, i_dialog_id );
+    if( p_dialog != NULL )
+        dialog_ProgressDestroy( p_dialog );
 
     for( i_stream = 0; i_stream < p_sys->i_track; i_stream++ )
     {