Commit 56fbad8e authored by Laurent Aimar's avatar Laurent Aimar

Reworked how the event thread works in mkv demuxer.

It now uses vlc_clone()
It is started only when needed.
It does not uselessly poll every 100 or 10 milliseconds anymore...
parent b98e1a87
This diff is collapsed.
...@@ -295,18 +295,37 @@ typedef struct { ...@@ -295,18 +295,37 @@ typedef struct {
class virtual_segment_c; class virtual_segment_c;
class chapter_item_c; class chapter_item_c;
typedef struct class event_thread_t
{ {
VLC_COMMON_MEMBERS public:
event_thread_t(demux_t *);
virtual ~event_thread_t();
void SetPci(const pci_t *data);
void ResetPci();
private:
void EventThread();
static void *EventThread(void *);
static int EventMouse( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );
static int EventKey( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );
static int EventInput( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );
demux_t *p_demux; demux_t *p_demux;
vlc_mutex_t lock;
bool is_running;
vlc_thread_t thread;
vlc_mutex_t lock;
vlc_cond_t wait;
bool b_abort;
bool b_moved; bool b_moved;
bool b_clicked; bool b_clicked;
int i_key_action; int i_key_action;
bool b_vout;
} event_thread_t; pci_t pci_packet;
};
class demux_sys_t class demux_sys_t
...@@ -322,9 +341,7 @@ public: ...@@ -322,9 +341,7 @@ public:
,p_current_segment(NULL) ,p_current_segment(NULL)
,dvd_interpretor( *this ) ,dvd_interpretor( *this )
,f_duration(-1.0) ,f_duration(-1.0)
,b_ui_hooked(false)
,p_input(NULL) ,p_input(NULL)
,b_pci_packet_set(false)
,p_ev(NULL) ,p_ev(NULL)
{ {
vlc_mutex_init( &lock_demuxer ); vlc_mutex_init( &lock_demuxer );
...@@ -369,27 +386,16 @@ public: ...@@ -369,27 +386,16 @@ public:
matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false ); matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
void JumpTo( virtual_segment_c & p_segment, chapter_item_c * p_chapter ); void JumpTo( virtual_segment_c & p_segment, chapter_item_c * p_chapter );
void StartUiThread(); void InitUi();
void StopUiThread(); void CleanUi();
bool b_ui_hooked;
void SwapButtons();
/* for spu variables */ /* for spu variables */
input_thread_t *p_input; input_thread_t *p_input;
pci_t pci_packet;
bool b_pci_packet_set;
uint8_t palette[4][4]; uint8_t palette[4][4];
vlc_mutex_t lock_demuxer; vlc_mutex_t lock_demuxer;
/* event */ /* event */
event_thread_t *p_ev; event_thread_t *p_ev;
static void * EventThread( vlc_object_t *p_this );
static int EventMouse( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
static int EventKey( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
protected: protected:
virtual_segment_c *VirtualFromSegments( matroska_segment_c *p_segment ) const; virtual_segment_c *VirtualFromSegments( matroska_segment_c *p_segment ) const;
......
...@@ -807,7 +807,6 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) ...@@ -807,7 +807,6 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
{ {
/* add all es */ /* add all es */
msg_Dbg( &sys.demuxer, "found %d es", (int)tracks.size() ); msg_Dbg( &sys.demuxer, "found %d es", (int)tracks.size() );
sys.b_pci_packet_set = false;
for( size_t i_track = 0; i_track < tracks.size(); i_track++ ) for( size_t i_track = 0; i_track < tracks.size(); i_track++ )
{ {
...@@ -1253,6 +1252,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) ...@@ -1253,6 +1252,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
void matroska_segment_c::UnSelect( ) void matroska_segment_c::UnSelect( )
{ {
sys.p_ev->ResetPci();
for( size_t i_track = 0; i_track < tracks.size(); i_track++ ) for( size_t i_track = 0; i_track < tracks.size(); i_track++ )
{ {
if ( tracks[i_track]->p_es != NULL ) if ( tracks[i_track]->p_es != NULL )
......
...@@ -245,7 +245,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -245,7 +245,7 @@ static int Open( vlc_object_t * p_this )
goto error; goto error;
} }
p_sys->StartUiThread(); p_sys->InitUi();
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -565,15 +565,8 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock ...@@ -565,15 +565,8 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
if ( tk->fmt.i_cat == NAV_ES ) if ( tk->fmt.i_cat == NAV_ES )
{ {
// TODO handle the start/stop times of this packet // TODO handle the start/stop times of this packet
if ( p_sys->b_ui_hooked ) p_sys->p_ev->SetPci( (const pci_t *)&p_block->p_buffer[1]);
{
vlc_mutex_lock( &p_sys->p_ev->lock );
memcpy( &p_sys->pci_packet, &p_block->p_buffer[1], sizeof(pci_t) );
p_sys->SwapButtons();
p_sys->b_pci_packet_set = true;
vlc_mutex_unlock( &p_sys->p_ev->lock );
block_Release( p_block ); block_Release( p_block );
}
return; return;
} }
// correct timestamping when B frames are used // correct timestamping when B frames are used
......
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