[vlc-devel] commit: Added a new INPUT_GET_BOOKMARK to allow future safe bookmark. ( Laurent Aimar )

git version control git at videolan.org
Thu Dec 4 20:48:04 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Dec  2 20:01:02 2008 +0100| [4d60f5b6a736b07736e6f1c83bd3f59962a1adcc] | committer: Laurent Aimar 

Added a new INPUT_GET_BOOKMARK to allow future safe bookmark.

 It removes the need of INPUT_GET_BYTE_POSITION/INPUT_SET_BYTE_SIZE which where
not thread safe.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4d60f5b6a736b07736e6f1c83bd3f59962a1adcc
---

 include/vlc_input.h                         |    3 +--
 modules/gui/macosx/bookmarks.m              |   17 ++++++-----------
 modules/gui/qt4/dialogs/bookmarks.cpp       |   16 ++++++----------
 modules/gui/wxwidgets/dialogs/bookmarks.cpp |   17 ++++++-----------
 src/input/control.c                         |   25 +++++++++++++------------
 5 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 53213f3..94ce851 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -617,11 +617,10 @@ enum input_query_e
     INPUT_ADD_OPTION,      /* arg1= char * arg2= char *  res=can fail*/
 
     /* Input properties */
-    INPUT_GET_BYTE_POSITION,     /* arg1= int64_t *       res=    */
-    INPUT_SET_BYTE_SIZE,         /* arg1= int64_t *       res=    */
     INPUT_GET_VIDEO_FPS,         /* arg1= double *        res=can fail */
 
     /* bookmarks */
+    INPUT_GET_BOOKMARK,    /* arg1= seekpoint_t *               res=can fail */
     INPUT_GET_BOOKMARKS,   /* arg1= seekpoint_t *** arg2= int * res=can fail */
     INPUT_CLEAR_BOOKMARKS, /* res=can fail */
     INPUT_ADD_BOOKMARK,    /* arg1= seekpoint_t *  res=can fail   */
diff --git a/modules/gui/macosx/bookmarks.m b/modules/gui/macosx/bookmarks.m
index f0fb02e..754899b 100644
--- a/modules/gui/macosx/bookmarks.m
+++ b/modules/gui/macosx/bookmarks.m
@@ -120,17 +120,12 @@ static VLCBookmarks *_o_sharedInstance = nil;
     if( !p_input ) return;
  
     seekpoint_t bookmark;
-    vlc_value_t pos;
-    bookmark.psz_name = NULL;
-    bookmark.i_byte_offset = 0;
-    bookmark.i_time_offset = 0;
- 
-    var_Get( VLCIntf, "position", &pos);
-    bookmark.psz_name = _("Untitled");
-    input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset );
-    var_Get( p_input, "time", &pos );
-    bookmark.i_time_offset = pos.i_time;
-    input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+
+    if( !input_Control( p_input, INPUT_GET_BOOKMARK, &bookmark ) )
+	{
+		bookmark.psz_name = _("Untitled");
+		input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+	}
  
     vlc_object_release( p_input );
  
diff --git a/modules/gui/qt4/dialogs/bookmarks.cpp b/modules/gui/qt4/dialogs/bookmarks.cpp
index 7503338..e84cb4f 100644
--- a/modules/gui/qt4/dialogs/bookmarks.cpp
+++ b/modules/gui/qt4/dialogs/bookmarks.cpp
@@ -146,19 +146,15 @@ void BookmarksDialog::add()
     if( !p_input ) return;
 
     seekpoint_t bookmark;
-    vlc_value_t pos;
-    bookmark.psz_name = qtu( THEMIM->getIM()->getName() +
-                    QString("_%1" ).arg( bookmarksList->topLevelItemCount() ) );
-    bookmark.i_byte_offset = 0;
-    bookmark.i_time_offset = 0;
 
-    input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset );
-    var_Get( p_input, "time", &pos );
-    bookmark.i_time_offset = pos.i_time;
-    input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+    if( !input_Control( p_input, INPUT_GET_BOOKMARK, &bookmark ) )
+    {
+        bookmark.psz_name = qtu( THEMIM->getIM()->getName() +
+                                 QString("_%1" ).arg( bookmarksList->topLevelItemCount() ) );
 
+        input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+    }
     update();
-
 }
 
 void BookmarksDialog::del()
diff --git a/modules/gui/wxwidgets/dialogs/bookmarks.cpp b/modules/gui/wxwidgets/dialogs/bookmarks.cpp
index fb980c1..622c8f1 100644
--- a/modules/gui/wxwidgets/dialogs/bookmarks.cpp
+++ b/modules/gui/wxwidgets/dialogs/bookmarks.cpp
@@ -283,17 +283,12 @@ void BookmarksDialog::OnAdd( wxCommandEvent& event )
     if( !p_input ) return;
 
     seekpoint_t bookmark;
-    vlc_value_t pos;
-    bookmark.psz_name = NULL;
-    bookmark.i_byte_offset = 0;
-    bookmark.i_time_offset = 0;
-
-    var_Get( p_input, "position", &pos );
-    bookmark.psz_name = NULL;
-    input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset );
-    var_Get( p_input, "time", &pos );
-    bookmark.i_time_offset = pos.i_time;
-    input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+
+    if( !input_Control( p_input, INPUT_GET_BOOKMARK, &bookmark ) )
+    {
+        bookmark.psz_name = NULL;
+        input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+    }
     vlc_object_release( p_input );
 
     Update();
diff --git a/src/input/control.c b/src/input/control.c
index d796037..838a602 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -384,6 +384,19 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
             break;
 
+        case INPUT_GET_BOOKMARK:
+            p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
+
+            memset( p_bkmk, 0, sizeof(*p_bkmk) );
+            p_bkmk->psz_name = NULL;
+            p_bkmk->i_level = 0;
+            p_bkmk->i_byte_offset = 0;
+            /* FIXME not safe at all ! */
+            if( p_input->p->input.p_stream )
+                p_bkmk->i_byte_offset = stream_Tell( p_input->p->input.p_stream );
+            p_bkmk->i_time_offset = var_GetTime( p_input, "time" );
+            return VLC_SUCCESS;
+
         case INPUT_ADD_OPTION:
         {
             const char *psz_option = va_arg( args, const char * );
@@ -400,18 +413,6 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             return i;
         }
 
-        case INPUT_GET_BYTE_POSITION:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = !p_input->p->input.p_stream ? 0 :
-                stream_Tell( p_input->p->input.p_stream );
-            return VLC_SUCCESS;
-
-        case INPUT_SET_BYTE_SIZE:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = !p_input->p->input.p_stream ? 0 :
-                stream_Size( p_input->p->input.p_stream );
-            return VLC_SUCCESS;
-
         case INPUT_GET_VIDEO_FPS:
         {
             int i;




More information about the vlc-devel mailing list