]> git.sesse.net Git - vlc/blobdiff - plugins/lirc/lirc.c
* ./plugins/lirc/lirc.c: fixed my mistakes from yesterday.
[vlc] / plugins / lirc / lirc.c
index f3a09cbb0730b7f8c8b32160a0e76b4cab93ee69..fe5c45de26f888e21d3b372ebc1857f86319c91b 100644 (file)
@@ -2,7 +2,7 @@
  * lirc.c : lirc plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: lirc.c,v 1.1 2002/02/06 02:37:18 sam Exp $
+ * $Id: lirc.c,v 1.5 2002/02/20 01:47:01 sam Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -54,7 +54,6 @@ typedef struct intf_sys_s
  *****************************************************************************/
 static void intf_getfunctions( function_list_t * p_function_list );
 
-static int  intf_Probe     ( probedata_t *p_data );
 static int  intf_Open      ( intf_thread_t *p_intf );
 static void intf_Close     ( intf_thread_t *p_intf );
 static void intf_Run       ( intf_thread_t *p_intf );
@@ -86,28 +85,16 @@ MODULE_DEACTIVATE_STOP
  *****************************************************************************/
 static void intf_getfunctions( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = intf_Probe;
     p_function_list->functions.intf.pf_open  = intf_Open;
     p_function_list->functions.intf.pf_close = intf_Close;
     p_function_list->functions.intf.pf_run   = intf_Run;
 }
 
-/*****************************************************************************
- * intf_Probe: probe the interface and return a score
- *****************************************************************************/
-static int intf_Probe( probedata_t *p_data )
-{
-    return( 1 );
-}
-
 /*****************************************************************************
  * intf_Open: initialize dummy interface
  *****************************************************************************/
 static int intf_Open( intf_thread_t *p_intf )
 {
-    /* Non-buffered stdout */
-    setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
-
     /* Allocate instance and initialize some members */
     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
     if( p_intf->p_sys == NULL )
@@ -130,6 +117,7 @@ static int intf_Open( intf_thread_t *p_intf )
         free( p_intf->p_sys );
         return 1;
     }
+
     return 0;
 }
 
@@ -144,144 +132,144 @@ static void intf_Close( intf_thread_t *p_intf )
     free( p_intf->p_sys );
 }
 
-
 /*****************************************************************************
  * intf_Run: main loop
  *****************************************************************************/
 static void intf_Run( intf_thread_t *p_intf )
 {
-    intf_Msg("%i items in playlist", p_main->p_playlist->i_size);
-    while( !p_intf->b_die )
-    {
-        char *code;
-        char *c;
-        int ret;
+    char *code;
+    char *c;
 
-        /* Manage core vlc functions through the callback */
-        p_intf->pf_manage( p_intf );
+    /* Manage core vlc functions through the callback */
+    p_intf->pf_manage( p_intf );
+
+    while( !p_intf->b_die && lirc_nextcode(&code) == 0 )
+    {
+printf("code\n");
+        if( code == NULL )
+        {
+            continue;
+        }
 
         while( !p_intf->b_die 
-               && lirc_nextcode(&code) == 0 )
+                && lirc_code2char( p_intf->p_sys->config, code, &c ) == 0
+                && c != NULL )
         {
-            if( code == NULL )
+            if( !strcmp( c, "QUIT" ) )
             {
+                p_intf->b_die = 1;
                 continue;
             }
 
-            while( (ret = lirc_code2char(p_intf->p_sys->config,code,&c)) == 0
-                   && c != NULL
-                   && !p_intf->b_die )
+            if( !strcmp( c, "FULLSCREEN" ) )
             {
-                intf_Msg("Got config \"%s\"",c);
-                //handle configstrings from .lircrc
+                vlc_mutex_lock( &p_vout_bank->lock );
+                /* XXX: only fullscreen the first video output */
+                if( p_vout_bank->i_count )
+                {
+                    p_vout_bank->pp_vout[0]->i_changes
+                        |= VOUT_FULLSCREEN_CHANGE;
+                }
+                vlc_mutex_unlock( &p_vout_bank->lock );
+                continue;
+            }
 
-                vlc_mutex_lock( &p_input_bank->lock );
+            vlc_mutex_lock( &p_input_bank->lock );
 
-                if( !strcmp( c, "PLAY" ) )
+            if( !strcmp( c, "PLAY" ) )
+            {
+                if( p_input_bank->pp_input[0] != NULL )
                 {
-                    if( p_input_bank->pp_input[0] != NULL )
-                    {
-                        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
-                        p_main->p_playlist->b_stopped = 0;
-                    }
-                    else
-                    {
-                        vlc_mutex_lock( &p_main->p_playlist->change_lock );
+                    input_SetStatus( p_input_bank->pp_input[0],
+                                     INPUT_STATUS_PLAY );
+                    p_main->p_playlist->b_stopped = 0;
+                }
+                else
+                {
+                    vlc_mutex_lock( &p_main->p_playlist->change_lock );
 
-                        if( p_main->p_playlist->b_stopped )
+                    if( p_main->p_playlist->b_stopped )
+                    {
+                        if( p_main->p_playlist->i_size )
                         {
-                            if( p_main->p_playlist->i_size )
-                            {
-                                vlc_mutex_unlock( &p_main->p_playlist->change_lock );
-                                intf_PlaylistJumpto( p_main->p_playlist,
-                                                     p_main->p_playlist->i_index );
-                            }
+                            vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+                            intf_PlaylistJumpto( p_main->p_playlist,
+                                                 p_main->p_playlist->i_index );
                         }
                         else
                         {
-
                             vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                         }
-
+                    }
+                    else
+                    {
+                        vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                     }
                 }
-
-                if( !strcmp( c, "PAUSE" ) && p_input_bank->pp_input[0] != NULL )
+            }
+            else if( p_input_bank->pp_input[0] != NULL )
+            {
+                if( !strcmp( c, "PAUSE" ) )
                 {
-                    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
-                        
+                    input_SetStatus( p_input_bank->pp_input[0],
+                                     INPUT_STATUS_PAUSE );
+
                     vlc_mutex_lock( &p_main->p_playlist->change_lock );
                     p_main->p_playlist->b_stopped = 0;
-                        vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+                    vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                 }
-
-                if( !strcmp( c, "NEXT" ) && p_input_bank->pp_input[0] != NULL )
+                else if( !strcmp( c, "NEXT" ) )
                 {
                     p_input_bank->pp_input[0]->b_eof = 1;
                 }
-
-                if( !strcmp( c, "LAST" ) && p_input_bank->pp_input[0] != NULL )
+                else if( !strcmp( c, "LAST" ) )
                 {
                     /* FIXME: temporary hack */
                     intf_PlaylistPrev( p_main->p_playlist );
                     intf_PlaylistPrev( p_main->p_playlist );
                     p_input_bank->pp_input[0]->b_eof = 1;
                 }
-
-                if( !strcmp( c, "STOP" ) && p_input_bank->pp_input[0] != NULL )
+                else if( !strcmp( c, "STOP" ) )
                 {
                     /* end playing item */
                     p_input_bank->pp_input[0]->b_eof = 1;
-                            
+    
                     /* update playlist */
                     vlc_mutex_lock( &p_main->p_playlist->change_lock );
-                            
+    
                     p_main->p_playlist->i_index--;
                     p_main->p_playlist->b_stopped = 1;
-                            
+    
                     vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                 }
-
-                if( !strcmp( c, "QUIT" ) )
-                {
-                    p_intf->b_die = 1;
-                }
-
-                if( !strcmp( c, "FULLSCREEN" ) )
+                else if( !strcmp( c, "FAST" ) )
                 {
-                    vlc_mutex_lock( &p_vout_bank->lock );
-                    /* XXX: only fullscreen the first video output */
-                    if( p_vout_bank->i_count )
-                    {
-                        p_vout_bank->pp_vout[0]->i_changes
-                            |= VOUT_FULLSCREEN_CHANGE;
-                    }
-                    vlc_mutex_unlock( &p_vout_bank->lock );
-                }
-
-                if( !strcmp( c, "FAST" ) && p_input_bank->pp_input[0] != NULL )
-                {
-                    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_FASTER );
-                        
+                    input_SetStatus( p_input_bank->pp_input[0],
+                                     INPUT_STATUS_FASTER );
+    
                     vlc_mutex_lock( &p_main->p_playlist->change_lock );
                     p_main->p_playlist->b_stopped = 0;
                     vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                 }
-
-                if( !strcmp( c, "SLOW" ) && p_input_bank->pp_input[0] != NULL )
+                else if( !strcmp( c, "SLOW" ) )
                 {
-                    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_SLOWER );
-                        
+                    input_SetStatus( p_input_bank->pp_input[0],
+                                     INPUT_STATUS_SLOWER );
+    
                     vlc_mutex_lock( &p_main->p_playlist->change_lock );
                     p_main->p_playlist->b_stopped = 0;
                     vlc_mutex_unlock( &p_main->p_playlist->change_lock );
                 }
-
-                vlc_mutex_unlock( &p_input_bank->lock );
             }
 
-            free( code );
+            vlc_mutex_unlock( &p_input_bank->lock );
         }
+
+        free( code );
+
+        /* Manage core vlc functions through the callback */
+        p_intf->pf_manage( p_intf );
     }
+printf("end of intf\n");
 }