]> git.sesse.net Git - vlc/blob - modules/gui/qt4/adapters/seekpoints.cpp
bf4037ab3885b633afddf4c47f73abee54ab4d3d
[vlc] / modules / gui / qt4 / adapters / seekpoints.cpp
1 /*****************************************************************************
2  * seekpoints.cpp : Chapters & Bookmarks (menu)
3  *****************************************************************************
4  * Copyright © 2011 the VideoLAN team
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * ( at your option ) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20  *****************************************************************************/
21
22
23 #include "recents.hpp"
24 #include "dialogs_provider.hpp"
25 #include "menus.hpp"
26
27 #include "seekpoints.hpp"
28
29 #include "qt4.hpp"
30 #include "input_manager.hpp"
31
32 SeekPoints::SeekPoints( QObject *parent, intf_thread_t *p_intf_ ) :
33     QObject( parent ), p_intf( p_intf_ )
34 {}
35
36 void SeekPoints::update()
37 {
38     input_title_t *p_title = NULL;
39     input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
40     int i_title_id = -1;
41     if( !p_input_thread ) { pointsList.clear(); return; }
42
43     if ( input_Control( p_input_thread, INPUT_GET_TITLE_INFO, &p_title, &i_title_id )
44         != VLC_SUCCESS )
45     {
46         vlc_object_release( p_input_thread );
47         pointsList.clear();
48         return;
49     }
50
51     vlc_object_release( p_input_thread );
52
53     /* lock here too, as update event is triggered by an external thread */
54     if ( !access() ) return;
55     pointsList.clear();
56     for ( int i=0; i<p_title->i_seekpoint ; i++ )
57         pointsList << SeekPoint( p_title->seekpoint[i] );
58
59     vlc_input_title_Delete( p_title );
60     release();
61 }
62
63 QList<SeekPoint> const SeekPoints::getPoints()
64 {
65     QList<SeekPoint> copy;
66     if ( access() )
67     {
68         copy = pointsList;
69         release();
70     }
71     return copy;
72 }
73