Commit d640a937 authored by Sam Hocevar's avatar Sam Hocevar

* ./plugins/lirc/lirc.c: the lirc interface now works again.

parent ff5b6b2b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lirc.c : lirc plugin for vlc * lirc.c : lirc plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: lirc.c,v 1.11 2002/06/01 12:31:59 sam Exp $ * $Id: lirc.c,v 1.12 2002/07/01 17:40:27 sam Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -42,6 +42,8 @@ struct intf_sys_s ...@@ -42,6 +42,8 @@ struct intf_sys_s
{ {
struct lirc_config *config; struct lirc_config *config;
vlc_mutex_t change_lock; vlc_mutex_t change_lock;
input_thread_t * p_input;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -117,6 +119,8 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -117,6 +119,8 @@ static int intf_Open( intf_thread_t *p_intf )
return 1; return 1;
} }
p_intf->p_sys->p_input = NULL;
return 0; return 0;
} }
...@@ -125,6 +129,11 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -125,6 +129,11 @@ static int intf_Open( intf_thread_t *p_intf )
*****************************************************************************/ *****************************************************************************/
static void intf_Close( intf_thread_t *p_intf ) static void intf_Close( intf_thread_t *p_intf )
{ {
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
}
/* Destroy structure */ /* Destroy structure */
lirc_freeconfig( p_intf->p_sys->config ); lirc_freeconfig( p_intf->p_sys->config );
lirc_deinit(); lirc_deinit();
...@@ -136,18 +145,27 @@ static void intf_Close( intf_thread_t *p_intf ) ...@@ -136,18 +145,27 @@ static void intf_Close( intf_thread_t *p_intf )
*****************************************************************************/ *****************************************************************************/
static void intf_Run( intf_thread_t *p_intf ) static void intf_Run( intf_thread_t *p_intf )
{ {
char *code; char *code, *c;
char *c; playlist_t *p_playlist;
input_thread_t *p_input;
/* Manage core vlc functions through the callback */
p_intf->pf_manage( p_intf );
while( !p_intf->p_vlc->b_die ) while( !p_intf->p_vlc->b_die )
{ {
/* Manage core vlc functions through the callback */ /* Sleep a bit */
p_intf->pf_manage( p_intf );
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
{
p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
}
else if( p_intf->p_sys->p_input->b_dead )
{
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
}
/* We poll the lircsocket */ /* We poll the lircsocket */
if( lirc_nextcode(&code) != 0 ) if( lirc_nextcode(&code) != 0 )
{ {
...@@ -171,100 +189,79 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -171,100 +189,79 @@ static void intf_Run( intf_thread_t *p_intf )
if( !strcmp( c, "FULLSCREEN" ) ) if( !strcmp( c, "FULLSCREEN" ) )
{ {
vlc_mutex_lock( &p_intf->p_vlc->p_vout_bank->lock ); vout_thread_t *p_vout;
/* XXX: only fullscreen the first video output */ p_vout = vlc_object_find( p_intf->p_sys->p_input,
if( p_intf->p_vlc->p_vout_bank->i_count ) VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{ {
p_intf->p_vlc->p_vout_bank->pp_vout[0]->i_changes p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
|= VOUT_FULLSCREEN_CHANGE; vlc_object_release( p_vout );
} }
vlc_mutex_unlock( &p_intf->p_vlc->p_vout_bank->lock );
continue; continue;
} }
vlc_mutex_lock( &p_intf->p_vlc->p_input_bank->lock );
if( !strcmp( c, "PLAY" ) ) if( !strcmp( c, "PLAY" ) )
{ {
if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL ) p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
{ FIND_ANYWHERE );
input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], if( p_playlist )
INPUT_STATUS_PLAY );
p_intf->p_vlc->p_playlist->b_stopped = 0;
}
else
{ {
vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock ); vlc_mutex_lock( &p_playlist->object_lock );
if( p_playlist->i_size )
if( p_intf->p_vlc->p_playlist->b_stopped
&& p_intf->p_vlc->p_playlist->i_size )
{
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
intf_PlaylistJumpto( p_intf->p_vlc->p_playlist,
p_intf->p_vlc->p_playlist->i_index );
}
else
{ {
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
} }
} }
} }
else if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL ) else if( p_intf->p_sys->p_input )
{ {
p_input = p_intf->p_sys->p_input;
if( !strcmp( c, "PAUSE" ) ) if( !strcmp( c, "PAUSE" ) )
{ {
input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], input_SetStatus( p_input, INPUT_STATUS_PAUSE );
INPUT_STATUS_PAUSE );
vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock );
p_intf->p_vlc->p_playlist->b_stopped = 0;
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
} }
else if( !strcmp( c, "NEXT" ) ) else if( !strcmp( c, "NEXT" ) )
{ {
p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1; p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Next( p_playlist );
vlc_object_release( p_playlist );
}
} }
else if( !strcmp( c, "LAST" ) ) else if( !strcmp( c, "PREV" ) )
{ {
/* FIXME: temporary hack */ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
intf_PlaylistPrev( p_intf->p_vlc->p_playlist ); FIND_ANYWHERE );
intf_PlaylistPrev( p_intf->p_vlc->p_playlist ); if( p_playlist )
p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1; {
playlist_Prev( p_playlist );
vlc_object_release( p_playlist );
}
} }
else if( !strcmp( c, "STOP" ) ) else if( !strcmp( c, "STOP" ) )
{ {
/* end playing item */ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1; FIND_ANYWHERE );
if( p_playlist )
/* update playlist */ {
vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock ); playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
p_intf->p_vlc->p_playlist->i_index--; }
p_intf->p_vlc->p_playlist->b_stopped = 1;
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
} }
else if( !strcmp( c, "FAST" ) ) else if( !strcmp( c, "FAST" ) )
{ {
input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], input_SetStatus( p_input, INPUT_STATUS_FASTER );
INPUT_STATUS_FASTER );
vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock );
p_intf->p_vlc->p_playlist->b_stopped = 0;
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
} }
else if( !strcmp( c, "SLOW" ) ) else if( !strcmp( c, "SLOW" ) )
{ {
input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], input_SetStatus( p_input, INPUT_STATUS_SLOWER );
INPUT_STATUS_SLOWER );
vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock );
p_intf->p_vlc->p_playlist->b_stopped = 0;
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
} }
} }
vlc_mutex_unlock( &p_intf->p_vlc->p_input_bank->lock );
} }
free( code ); free( code );
......
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