]> git.sesse.net Git - vlc/blobdiff - modules/access/dvb/access.c
Improvements to preferences
[vlc] / modules / access / dvb / access.c
index 26f125e2450b467c2d43707af7e9f5423e4eb888..e98e79326cd384e98d49402ee38a9e8d99d067ac 100644 (file)
@@ -52,9 +52,6 @@ static void Close( vlc_object_t *p_this );
     "Allows you to modify the default caching value for dvb streams. This " \
     "value should be set in millisecond units." )
 
-#define PROGRAM_TEXT N_("Program to decode")
-#define PROGRAM_LONGTEXT N_("This is a workaround for a bug in the input")
-
 #define ADAPTER_TEXT N_("Adapter card to tune")
 #define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
 
@@ -124,6 +121,8 @@ static void Close( vlc_object_t *p_this );
 vlc_module_begin();
     set_shortname( _("DVB") );
     set_description( N_("DVB input with v4l2 support") );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_ACCESS );
 
     add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
                  CACHING_LONGTEXT, VLC_TRUE );
@@ -189,7 +188,7 @@ vlc_module_end();
 static block_t *Block( access_t * );
 static int Control( access_t *, int, va_list );
 
-#define SATELLITE_READ_ONCE 3
+#define DVB_READ_ONCE 3
 #define TS_PACKET_SIZE 188
 
 static void FilterUnset( access_t *, int i_max );
@@ -273,6 +272,8 @@ static int Open( vlc_object_t *p_this )
         FilterSet( p_access, 0x0, OTHER_TYPE );
     }
 
+    E_(CAMOpen)( p_access );
+
     return VLC_SUCCESS;
 }
 
@@ -288,6 +289,8 @@ static void Close( vlc_object_t *p_this )
 
     E_(DVRClose)( p_access );
     E_(FrontendClose)( p_access );
+    E_(CAMClose)( p_access );
+
     free( p_sys );
 }
 
@@ -297,40 +300,52 @@ static void Close( vlc_object_t *p_this )
 static block_t *Block( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
-    struct timeval timeout;
-    fd_set fds;
-    int i_ret;
     block_t *p_block;
 
-    /* Initialize file descriptor set */
-    FD_ZERO( &fds );
-    FD_SET( p_sys->i_handle, &fds );
-
-    /* We'll wait 0.5 second if nothing happens */
-    timeout.tv_sec = 0;
-    timeout.tv_usec = 500000;
-
-    /* Find if some data is available */
-    while( (i_ret = select( p_sys->i_handle + 1, &fds, NULL, NULL, &timeout )) == 0 ||
-           (i_ret < 0 && errno == EINTR) )
+    for ( ; ; )
     {
+        struct timeval timeout;
+        fd_set fds;
+        int i_ret;
+
+        /* Initialize file descriptor set */
         FD_ZERO( &fds );
         FD_SET( p_sys->i_handle, &fds );
+
+        /* We'll wait 0.5 second if nothing happens */
         timeout.tv_sec = 0;
         timeout.tv_usec = 500000;
 
-        if( p_access->b_die )
+        /* Find if some data is available */
+        i_ret = select( p_sys->i_handle + 1, &fds, NULL, NULL, &timeout );
+
+        if ( p_access->b_die )
             return NULL;
-    }
 
-    if ( i_ret < 0 )
-    {
-        msg_Err( p_access, "select error (%s)", strerror(errno) );
-        return NULL;
+        if ( i_ret < 0 && errno == EINTR )
+            continue;
+
+        if ( i_ret < 0 )
+        {
+            msg_Err( p_access, "select error (%s)", strerror(errno) );
+            return NULL;
+        }
+
+        if ( p_sys->i_ca_handle && mdate() > p_sys->i_ca_next_event )
+        {
+            E_(CAMPoll)( p_access );
+            p_sys->i_ca_next_event = mdate() + p_sys->i_ca_timeout;
+        }
+
+        if ( FD_ISSET( p_sys->i_handle, &fds ) )
+        {
+            break;
+        }
     }
 
-    p_block = block_New( p_access, SATELLITE_READ_ONCE * TS_PACKET_SIZE );
-    if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer, SATELLITE_READ_ONCE * TS_PACKET_SIZE ) ) <= 0 )
+    p_block = block_New( p_access, DVB_READ_ONCE * TS_PACKET_SIZE );
+    if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer,
+                                    DVB_READ_ONCE * TS_PACKET_SIZE ) ) <= 0 )
     {
         msg_Err( p_access, "read failed (%s)", strerror(errno) );
         block_Release( p_block );
@@ -363,7 +378,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         /* */
         case ACCESS_GET_MTU:
             pi_int = (int*)va_arg( args, int * );
-            *pi_int = SATELLITE_READ_ONCE * TS_PACKET_SIZE;
+            *pi_int = DVB_READ_ONCE * TS_PACKET_SIZE;
             break;
 
         case ACCESS_GET_PTS_DELAY:
@@ -379,8 +394,8 @@ static int Control( access_t *p_access, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case ACCESS_SET_PRIVATE_ID_STATE:
-            b_bool = (vlc_bool_t)va_arg( args, vlc_bool_t ); /* b_selected */
             i_int  = (int)va_arg( args, int );               /* Private data (pid for now)*/
+            b_bool = (vlc_bool_t)va_arg( args, vlc_bool_t ); /* b_selected */
             if( !p_sys->b_budget_mode )
             {
                 /* FIXME we may want to give the real type (me ?, I don't ;) */
@@ -391,8 +406,19 @@ static int Control( access_t *p_access, int i_query, va_list args )
             }
             break;
 
+        case ACCESS_SET_PRIVATE_ID_CA:
+        {
+            uint8_t **pp_capmts;
+            int i_nb_capmts;
+
+            pp_capmts = (uint8_t **)va_arg( args, uint8_t ** );
+            i_nb_capmts = (int)va_arg( args, int );
+
+            E_(CAMSet)( p_access, pp_capmts, i_nb_capmts );
+            break;
+        }
         default:
-            msg_Err( p_access, "unimplemented query in control" );
+            msg_Warn( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;
 
     }
@@ -513,8 +539,9 @@ static int ParseMRL( access_t *p_access )
 #define GET_OPTION_INT( option )                                            \
     if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
     {                                                                       \
-        val.i_int = strtol( psz_parser+strlen(option "="), &psz_parser, 0 );\
-        var_Set( p_access, "dvb-" option, val );                             \
+        val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser,   \
+                            0 );                                            \
+        var_Set( p_access, "dvb-" option, val );                            \
     }
 
 #define GET_OPTION_BOOL( option )                                           \
@@ -522,7 +549,7 @@ static int ParseMRL( access_t *p_access )
     {                                                                       \
         val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser,  \
                              0 );                                           \
-        var_Set( p_access, "dvb-" option, val );                             \
+        var_Set( p_access, "dvb-" option, val );                            \
     }
 
     /* Test for old syntax */
@@ -597,7 +624,8 @@ static int ParseMRL( access_t *p_access )
             return VLC_EGENERIC;
         }
 
-        psz_parser++;
+        if ( *psz_parser )
+            psz_parser++;
     }
 #undef GET_OPTION_INT
 #undef GET_OPTION_BOOL