Commit 4d60f5b6 authored by Laurent Aimar's avatar 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.
parent 39868b92
......@@ -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 */
......
......@@ -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 );
......
......@@ -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()
......
......@@ -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();
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment