]> git.sesse.net Git - vlc/blobdiff - modules/access/dvb/linux_dvb.c
Use dialog_Fatal, fix a bunch (but not all) interaction crashes
[vlc] / modules / access / dvb / linux_dvb.c
index 99d12206acf7c00c2e9a4b52431262c96b3a3e92..ae8ed7198f37cffbe374dc0323293645aea45955 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA    02111, USA.
  *****************************************************************************/
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include <vlc_access.h>
 #include <sys/ioctl.h>
 #include <errno.h>
@@ -51,6 +55,8 @@
 #   include <dvbpsi/pmt.h>
 #   include <dvbpsi/dr.h>
 #   include <dvbpsi/psi.h>
+#   include <dvbpsi/demux.h>
+#   include <dvbpsi/sdt.h>
 #else
 #   include "dvbpsi.h"
 #   include "descriptor.h"
@@ -58,6 +64,8 @@
 #   include "tables/pmt.h"
 #   include "descriptors/dr.h"
 #   include "psi.h"
+#   include "demux.h"
+#   include "tables/sdt.h"
 #endif
 
 #ifdef ENABLE_HTTPD
@@ -87,12 +95,12 @@ static int FrontendSetATSC( access_t * );
 /*****************************************************************************
  * FrontendOpen : Determine frontend device information and capabilities
  *****************************************************************************/
-int E_(FrontendOpen)( access_t *p_access )
+int FrontendOpen( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     frontend_t * p_frontend;
     unsigned int i_adapter, i_device;
-    vlc_bool_t b_probe;
+    bool b_probe;
     char frontend[128];
 
     i_adapter = var_GetInteger( p_access, "dvb-adapter" );
@@ -106,12 +114,13 @@ int E_(FrontendOpen)( access_t *p_access )
     }
 
     p_sys->p_frontend = p_frontend = malloc( sizeof(frontend_t) );
+    if( !p_frontend )
+        return VLC_ENOMEM;
 
     msg_Dbg( p_access, "Opening device %s", frontend );
     if( (p_sys->i_frontend_handle = open(frontend, O_RDWR | O_NONBLOCK)) < 0 )
     {
-        msg_Err( p_access, "FrontEndOpen: opening device failed (%s)",
-                 strerror(errno) );
+        msg_Err( p_access, "FrontEndOpen: opening device failed (%m)" );
         free( p_frontend );
         return VLC_EGENERIC;
     }
@@ -209,7 +218,7 @@ int E_(FrontendOpen)( access_t *p_access )
 /*****************************************************************************
  * FrontendClose : Close the frontend
  *****************************************************************************/
-void E_(FrontendClose)( access_t *p_access )
+void FrontendClose( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
@@ -225,7 +234,7 @@ void E_(FrontendClose)( access_t *p_access )
 /*****************************************************************************
  * FrontendSet : Tune !
  *****************************************************************************/
-int E_(FrontendSet)( access_t *p_access )
+int FrontendSet( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
@@ -280,7 +289,7 @@ int E_(FrontendSet)( access_t *p_access )
 /*****************************************************************************
  * FrontendPoll : Poll for frontend events
  *****************************************************************************/
-void E_(FrontendPoll)( access_t *p_access )
+void FrontendPoll( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     frontend_t * p_frontend = p_sys->p_frontend;
@@ -296,8 +305,8 @@ void E_(FrontendPoll)( access_t *p_access )
             if( errno == EWOULDBLOCK )
                 return; /* no more events */
 
-            msg_Err( p_access, "reading frontend event failed (%d) %s",
-                     i_ret, strerror(errno) );
+            msg_Err( p_access, "reading frontend event failed (%d): %m",
+                     i_ret );
             return;
         }
 
@@ -334,17 +343,21 @@ void E_(FrontendPoll)( access_t *p_access )
 
             IF_UP( FE_HAS_LOCK )
             {
-                int32_t i_value = 0;
+                frontend_statistic_t stat;
+
                 msg_Dbg( p_access, "frontend has acquired lock" );
                 p_sys->i_frontend_timeout = 0;
 
                 /* Read some statistics */
-                if( ioctl( p_sys->i_frontend_handle, FE_READ_BER, &i_value ) >= 0 )
-                    msg_Dbg( p_access, "- Bit error rate: %d", i_value );
-                if( ioctl( p_sys->i_frontend_handle, FE_READ_SIGNAL_STRENGTH, &i_value ) >= 0 )
-                    msg_Dbg( p_access, "- Signal strength: %d", i_value );
-                if( ioctl( p_sys->i_frontend_handle, FE_READ_SNR, &i_value ) >= 0 )
-                    msg_Dbg( p_access, "- SNR: %d", i_value );
+                if( !FrontendGetStatistic( p_access, &stat ) )
+                {
+                    if( stat.i_ber >= 0 )
+                        msg_Dbg( p_access, "- Bit error rate: %d", stat.i_ber );
+                    if( stat.i_signal_strenth >= 0 )
+                        msg_Dbg( p_access, "- Signal strength: %d", stat.i_signal_strenth );
+                    if( stat.i_snr >= 0 )
+                        msg_Dbg( p_access, "- SNR: %d", stat.i_snr );
+                }
             }
             else
             {
@@ -356,18 +369,102 @@ void E_(FrontendPoll)( access_t *p_access )
             {
                 /* The frontend was reinited. */
                 msg_Warn( p_access, "reiniting frontend");
-                E_(FrontendSet)( p_access );
+                FrontendSet( p_access );
             }
         }
 #undef IF_UP
     }
 }
+int FrontendGetStatistic( access_t *p_access, frontend_statistic_t *p_stat )
+{
+    access_sys_t *p_sys = p_access->p_sys;
+    frontend_t * p_frontend = p_sys->p_frontend;
+
+    if( (p_frontend->i_last_status & FE_HAS_LOCK) == 0 )
+        return VLC_EGENERIC;
+
+    memset( p_stat, 0, sizeof(*p_stat) );
+    if( ioctl( p_sys->i_frontend_handle, FE_READ_BER, &p_stat->i_ber ) < 0 )
+        p_stat->i_ber = -1;
+    if( ioctl( p_sys->i_frontend_handle, FE_READ_SIGNAL_STRENGTH, &p_stat->i_signal_strenth ) < 0 )
+        p_stat->i_signal_strenth = -1;
+    if( ioctl( p_sys->i_frontend_handle, FE_READ_SNR, &p_stat->i_snr ) < 0 )
+        p_stat->i_snr = -1;
+
+    return VLC_SUCCESS;
+}
+void FrontendGetStatus( access_t *p_access, frontend_status_t *p_status )
+{
+    access_sys_t *p_sys = p_access->p_sys;
+    frontend_t * p_frontend = p_sys->p_frontend;
+
+    p_status->b_has_signal = (p_frontend->i_last_status & FE_HAS_SIGNAL) != 0;
+    p_status->b_has_carrier = (p_frontend->i_last_status & FE_HAS_CARRIER) != 0;
+    p_status->b_has_lock = (p_frontend->i_last_status & FE_HAS_LOCK) != 0;
+}
+static int ScanParametersDvbC( access_t *p_access, scan_parameter_t *p_scan )
+{
+    const frontend_t *p_frontend = p_access->p_sys->p_frontend;
+
+
+    memset( p_scan, 0, sizeof(*p_scan) );
+    p_scan->type = SCAN_DVB_C;
+    p_scan->b_exhaustive = false;
+
+    /* */
+    p_scan->frequency.i_min = p_frontend->info.frequency_min;
+    p_scan->frequency.i_max = p_frontend->info.frequency_max;
+    p_scan->frequency.i_step = p_frontend->info.frequency_stepsize;
+    p_scan->frequency.i_count = (p_scan->frequency.i_max-p_scan->frequency.i_min)/p_scan->frequency.i_step;
+
+    /* */
+    p_scan->bandwidth.i_min  = 6;
+    p_scan->bandwidth.i_max  = 8;
+    p_scan->bandwidth.i_step = 1;
+    p_scan->bandwidth.i_count = 3;
+    return VLC_SUCCESS;
+}
+static int ScanParametersDvbT( access_t *p_access, scan_parameter_t *p_scan )
+{
+    const frontend_t *p_frontend = p_access->p_sys->p_frontend;
+
+
+    memset( p_scan, 0, sizeof(*p_scan) );
+    p_scan->type = SCAN_DVB_T;
+    p_scan->b_exhaustive = false;
+
+    /* */
+    p_scan->frequency.i_min = p_frontend->info.frequency_min;
+    p_scan->frequency.i_max = p_frontend->info.frequency_max;
+    p_scan->frequency.i_step = p_frontend->info.frequency_stepsize;
+    p_scan->frequency.i_count = (p_scan->frequency.i_max-p_scan->frequency.i_min)/p_scan->frequency.i_step;
+
+    /* */
+    p_scan->bandwidth.i_min  = 6;
+    p_scan->bandwidth.i_max  = 8;
+    p_scan->bandwidth.i_step = 1;
+    p_scan->bandwidth.i_count = 3;
+    return VLC_SUCCESS;
+}
+int  FrontendGetScanParameter( access_t *p_access, scan_parameter_t *p_scan )
+{
+    access_sys_t *p_sys = p_access->p_sys;
+    const frontend_t *p_frontend = p_sys->p_frontend;
+
+    if( p_frontend->info.type == FE_OFDM )  // DVB-T
+        return ScanParametersDvbT( p_access, p_scan );
+    else if( p_frontend->info.type == FE_QAM )  // DVB-C
+        return ScanParametersDvbC( p_access, p_scan );
+
+    msg_Err( p_access, "Frontend type not supported for scanning" );
+    return VLC_EGENERIC;
+}
 
 #ifdef ENABLE_HTTPD
 /*****************************************************************************
  * FrontendStatus : Read frontend status
  *****************************************************************************/
-void E_(FrontendStatus)( access_t *p_access )
+void FrontendStatus( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     frontend_t *p_frontend = p_sys->p_frontend;
@@ -379,8 +476,9 @@ void E_(FrontendStatus)( access_t *p_access )
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_GET_INFO,
                         &p_frontend->info )) < 0 )
     {
-        p += sprintf( p, "ioctl FE_GET_INFO failed (%d) %s\n", i_ret,
-                      strerror(errno) );
+        char buf[1000];
+        strerror_r( errno, buf, sizeof( buf ) );
+        p += sprintf( p, "ioctl FE_GET_INFO failed (%d) %s\n", i_ret, buf );
         goto out;
     }
 
@@ -466,8 +564,10 @@ void E_(FrontendStatus)( access_t *p_access )
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_READ_STATUS, &i_status ))
            < 0 )
     {
-        p += sprintf( p, "</table>ioctl FE_READ_STATUS failed (%d) %s\n", i_ret,
-                      strerror(errno) );
+        char buf[1000];
+        strerror_r( errno, buf, sizeof( buf ) );
+        p += sprintf( p, "</table>ioctl FE_READ_STATUS failed (%d) %s\n",
+                      i_ret, buf );
         goto out;
     }
 
@@ -504,7 +604,7 @@ void E_(FrontendStatus)( access_t *p_access )
 
 out:
     vlc_mutex_lock( &p_sys->httpd_mutex );
-    p_sys->b_request_frontend_info = VLC_FALSE;
+    p_sys->b_request_frontend_info = false;
     vlc_cond_signal( &p_sys->httpd_cond );
     vlc_mutex_unlock( &p_sys->httpd_mutex );
 }
@@ -523,8 +623,7 @@ static int FrontendInfo( access_t *p_access )
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_GET_INFO,
                         &p_frontend->info )) < 0 )
     {
-        msg_Err( p_access, "ioctl FE_GET_INFO failed (%d) %s", i_ret,
-                 strerror(errno) );
+        msg_Err( p_access, "ioctl FE_GET_INFO failed (%d): %m", i_ret );
         return VLC_EGENERIC;
     }
 
@@ -719,8 +818,13 @@ static fe_modulation_t DecodeModulationATSC( access_t *p_access )
 {
     switch( var_GetInteger( p_access, "dvb-modulation" ) )
     {
+        case 0:     return QAM_AUTO;
         case 8:     return VSB_8;
         case 16:    return VSB_16;
+        case 32:    return QAM_32;
+        case 64:    return QAM_64;
+        case 128:   return QAM_128;
+        case 256:   return QAM_256;
         default:
             msg_Dbg( p_access, "ATSC modulation not set, using VSB 8");
             return VSB_8;
@@ -807,17 +911,16 @@ static int DoDiseqc( access_t *p_access )
     /* Switch off continuous tone. */
     if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, SEC_TONE_OFF )) < 0 )
     {
-        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %s",
-                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err,
-                 strerror(errno) );
+        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",
+                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err );
         return i_err;
     }
 
     /* Configure LNB voltage. */
     if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_VOLTAGE, fe_voltage )) < 0 )
     {
-        msg_Err( p_access, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %s",
-                 fe_voltage, i_err, strerror(errno) );
+        msg_Err( p_access, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %m",
+                 fe_voltage, i_err );
         return i_err;
     }
 
@@ -826,8 +929,8 @@ static int DoDiseqc( access_t *p_access )
                         val.b_bool )) < 0 && val.b_bool )
     {
         msg_Err( p_access,
-                 "ioctl FE_ENABLE_HIGH_LNB_VOLTAGE failed, val=%d (%d) %s",
-                 val.b_bool, i_err, strerror(errno) );
+                 "ioctl FE_ENABLE_HIGH_LNB_VOLTAGE failed, val=%d (%d) %m",
+                 val.b_bool, i_err );
     }
 
     /* Wait for at least 15 ms. */
@@ -854,8 +957,8 @@ static int DoDiseqc( access_t *p_access )
         if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_MASTER_CMD,
                            &cmd.cmd )) < 0 )
         {
-            msg_Err( p_access, "ioctl FE_SEND_MASTER_CMD failed (%d) %s",
-                     i_err, strerror(errno) );
+            msg_Err( p_access, "ioctl FE_SEND_MASTER_CMD failed (%d) %m",
+                     i_err );
             return i_err;
         }
 
@@ -865,8 +968,8 @@ static int DoDiseqc( access_t *p_access )
         if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_BURST,
                       ((val.i_int - 1) % 2) ? SEC_MINI_B : SEC_MINI_A )) < 0 )
         {
-            msg_Err( p_access, "ioctl FE_SEND_BURST failed (%d) %s",
-                     i_err, strerror(errno) );
+            msg_Err( p_access, "ioctl FE_SEND_BURST failed (%d) %m",
+                     i_err );
             return i_err;
         }
 
@@ -875,9 +978,8 @@ static int DoDiseqc( access_t *p_access )
 
     if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, fe_tone )) < 0 )
     {
-        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %s",
-                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err,
-                 strerror(errno) );
+        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",
+                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err );
         return i_err;
     }
 
@@ -990,8 +1092,7 @@ static int FrontendSetQPSK( access_t *p_access )
     /* Now send it all to the frontend device */
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )
     {
-        msg_Err( p_access, "DVB-S: setting frontend failed (%d) %s", i_ret,
-                 strerror(errno) );
+        msg_Err( p_access, "DVB-S: setting frontend failed (%d) %m", i_ret );
         return VLC_EGENERIC;
     }
 
@@ -1035,8 +1136,7 @@ static int FrontendSetQAM( access_t *p_access )
     /* Now send it all to the frontend device */
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )
     {
-        msg_Err( p_access, "DVB-C: setting frontend failed (%d) %s", i_ret,
-                 strerror(errno) );
+        msg_Err( p_access, "DVB-C: setting frontend failed (%d): %m", i_ret );
         return VLC_EGENERIC;
     }
 
@@ -1171,8 +1271,7 @@ static int FrontendSetOFDM( access_t * p_access )
     /* Now send it all to the frontend device */
     if( (ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )
     {
-        msg_Err( p_access, "DVB-T: setting frontend failed (%d) %s", ret,
-                 strerror(errno) );
+        msg_Err( p_access, "DVB-T: setting frontend failed (%d): %m", ret );
         return -1;
     }
 
@@ -1208,8 +1307,7 @@ static int FrontendSetATSC( access_t *p_access )
     /* Now send it all to the frontend device */
     if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )
     {
-        msg_Err( p_access, "ATSC: setting frontend failed (%d) %s", i_ret,
-                 strerror(errno) );
+        msg_Err( p_access, "ATSC: setting frontend failed (%d): %m", i_ret );
         return VLC_EGENERIC;
     }
 
@@ -1224,7 +1322,7 @@ static int FrontendSetATSC( access_t *p_access )
 /*****************************************************************************
  * DMXSetFilter : controls the demux to add a filter
  *****************************************************************************/
-int E_(DMXSetFilter)( access_t * p_access, int i_pid, int * pi_fd, int i_type )
+int DMXSetFilter( access_t * p_access, int i_pid, int * pi_fd, int i_type )
 {
     struct dmx_pes_filter_params s_filter_params;
     int i_ret;
@@ -1247,8 +1345,7 @@ int E_(DMXSetFilter)( access_t * p_access, int i_pid, int * pi_fd, int i_type )
     msg_Dbg( p_access, "Opening device %s", dmx );
     if( (*pi_fd = open(dmx, O_RDWR)) < 0 )
     {
-        msg_Err( p_access, "DMXSetFilter: opening device failed (%s)",
-                 strerror(errno) );
+        msg_Err( p_access, "DMXSetFilter: opening device failed (%m)" );
         return VLC_EGENERIC;
     }
 
@@ -1354,8 +1451,7 @@ int E_(DMXSetFilter)( access_t * p_access, int i_pid, int * pi_fd, int i_type )
     /* We then give the order to the device : */
     if( (i_ret = ioctl( *pi_fd, DMX_SET_PES_FILTER, &s_filter_params )) < 0 )
     {
-        msg_Err( p_access, "DMXSetFilter: failed with %d (%s)", i_ret,
-                 strerror(errno) );
+        msg_Err( p_access, "DMXSetFilter: failed with %d (%m)", i_ret );
         return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
@@ -1364,14 +1460,13 @@ int E_(DMXSetFilter)( access_t * p_access, int i_pid, int * pi_fd, int i_type )
 /*****************************************************************************
  * DMXUnsetFilter : removes a filter
  *****************************************************************************/
-int E_(DMXUnsetFilter)( access_t * p_access, int i_fd )
+int DMXUnsetFilter( access_t * p_access, int i_fd )
 {
     int i_ret;
 
     if( (i_ret = ioctl( i_fd, DMX_STOP )) < 0 )
     {
-        msg_Err( p_access, "DMX_STOP failed for demux (%d) %s",
-                 i_ret, strerror(errno) );
+        msg_Err( p_access, "DMX_STOP failed for demux (%d): %m", i_ret );
         return i_ret;
     }
 
@@ -1388,7 +1483,7 @@ int E_(DMXUnsetFilter)( access_t * p_access, int i_fd )
 /*****************************************************************************
  * DVROpen :
  *****************************************************************************/
-int E_(DVROpen)( access_t * p_access )
+int DVROpen( access_t * p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     unsigned int i_adapter, i_device;
@@ -1410,15 +1505,13 @@ int E_(DVROpen)( access_t * p_access )
     msg_Dbg( p_access, "Opening device %s", dvr );
     if( (p_sys->i_handle = open(dvr, O_RDONLY)) < 0 )
     {
-        msg_Err( p_access, "DVROpen: opening device failed (%s)",
-                 strerror(errno) );
+        msg_Err( p_access, "DVROpen: opening device failed (%m)" );
         return VLC_EGENERIC;
     }
 
     if( fcntl( p_sys->i_handle, F_SETFL, O_NONBLOCK ) == -1 )
     {
-        msg_Warn( p_access, "DVROpen: couldn't set non-blocking mode (%s)",
-                  strerror(errno) );
+        msg_Warn( p_access, "DVROpen: couldn't set non-blocking mode (%m)" );
     }
 
     return VLC_SUCCESS;
@@ -1427,7 +1520,7 @@ int E_(DVROpen)( access_t * p_access )
 /*****************************************************************************
  * DVRClose :
  *****************************************************************************/
-void E_(DVRClose)( access_t * p_access )
+void DVRClose( access_t * p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
@@ -1442,7 +1535,7 @@ void E_(DVRClose)( access_t * p_access )
 /*****************************************************************************
  * CAMOpen :
  *****************************************************************************/
-int E_(CAMOpen)( access_t *p_access )
+int CAMOpen( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     char ca[128];
@@ -1462,8 +1555,7 @@ int E_(CAMOpen)( access_t *p_access )
     msg_Dbg( p_access, "Opening device %s", ca );
     if( (p_sys->i_ca_handle = open(ca, O_RDWR | O_NONBLOCK)) < 0 )
     {
-        msg_Warn( p_access, "CAMInit: opening CAM device failed (%s)",
-                  strerror(errno) );
+        msg_Warn( p_access, "CAMInit: opening CAM device failed (%m)" );
         p_sys->i_ca_handle = 0;
         return VLC_EGENERIC;
     }
@@ -1477,7 +1569,7 @@ int E_(CAMOpen)( access_t *p_access )
     }
 
     /* Output CA capabilities */
-    msg_Dbg( p_access, "CAMInit: CA interface with %d %s", caps.slot_num, 
+    msg_Dbg( p_access, "CAMInit: CA interface with %d %s", caps.slot_num,
         caps.slot_num == 1 ? "slot" : "slots" );
     if ( caps.slot_type & CA_CI )
         msg_Dbg( p_access, "CAMInit: CI high level interface type" );
@@ -1515,7 +1607,8 @@ int E_(CAMOpen)( access_t *p_access )
     {
         p_sys->i_ca_type = CA_CI;
     }
-    else {
+    else
+    {
         p_sys->i_ca_type = -1;
         msg_Err( p_access, "CAMInit: incompatible CAM interface" );
         close( p_sys->i_ca_handle );
@@ -1524,18 +1617,18 @@ int E_(CAMOpen)( access_t *p_access )
     }
 
     p_sys->i_nb_slots = caps.slot_num;
-    memset( p_sys->pb_active_slot, 0, sizeof(vlc_bool_t) * MAX_CI_SLOTS );
-    memset( p_sys->pb_slot_mmi_expected, 0, sizeof(vlc_bool_t) * MAX_CI_SLOTS );
+    memset( p_sys->pb_active_slot, 0, sizeof(bool) * MAX_CI_SLOTS );
+    memset( p_sys->pb_slot_mmi_expected, 0, sizeof(bool) * MAX_CI_SLOTS );
     memset( p_sys->pb_slot_mmi_undisplayed, 0,
-            sizeof(vlc_bool_t) * MAX_CI_SLOTS );
+            sizeof(bool) * MAX_CI_SLOTS );
 
-    return E_(en50221_Init)( p_access );
+    return en50221_Init( p_access );
 }
 
 /*****************************************************************************
  * CAMPoll :
  *****************************************************************************/
-int E_(CAMPoll)( access_t * p_access )
+int CAMPoll( access_t * p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     int i_ret = VLC_EGENERIC;
@@ -1548,7 +1641,7 @@ int E_(CAMPoll)( access_t * p_access )
     switch( p_sys->i_ca_type )
     {
     case CA_CI_LINK:
-        i_ret = E_(en50221_Poll)( p_access );
+        i_ret = en50221_Poll( p_access );
         break;
     case CA_CI:
         i_ret = VLC_SUCCESS;
@@ -1565,7 +1658,7 @@ int E_(CAMPoll)( access_t * p_access )
 /*****************************************************************************
  * CAMStatus :
  *****************************************************************************/
-void E_(CAMStatus)( access_t * p_access )
+void CAMStatus( access_t * p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
     char *p;
@@ -1578,7 +1671,7 @@ void E_(CAMStatus)( access_t * p_access )
          * the user input to avoid confusing the CAM. */
         for ( i_slot = 0; i_slot < p_sys->i_nb_slots; i_slot++ )
         {
-            if ( p_sys->pb_slot_mmi_undisplayed[i_slot] == VLC_TRUE )
+            if ( p_sys->pb_slot_mmi_undisplayed[i_slot] == true )
             {
                 p_sys->psz_request = NULL;
                 msg_Dbg( p_access,
@@ -1595,11 +1688,11 @@ void E_(CAMStatus)( access_t * p_access )
         char *psz_request = p_sys->psz_request;
         char psz_value[255];
         int i_slot;
-        vlc_bool_t b_ok = VLC_FALSE;
+        bool b_ok = false;
 
         p_sys->psz_request = NULL;
 
-        if ( E_(HTTPExtractValue)( psz_request, "slot", psz_value,
+        if ( HTTPExtractValue( psz_request, "slot", psz_value,
                                    sizeof(psz_value) ) == NULL )
         {
             p_sys->psz_mmi_info = strdup( "invalid request parameter\n" );
@@ -1607,27 +1700,27 @@ void E_(CAMStatus)( access_t * p_access )
         }
         i_slot = atoi(psz_value);
 
-        if ( E_(HTTPExtractValue)( psz_request, "open", psz_value,
+        if ( HTTPExtractValue( psz_request, "open", psz_value,
                                    sizeof(psz_value) ) != NULL )
         {
-            E_(en50221_OpenMMI)( p_access, i_slot );
+            en50221_OpenMMI( p_access, i_slot );
             return;
         }
 
-        if ( E_(HTTPExtractValue)( psz_request, "close", psz_value,
+        if ( HTTPExtractValue( psz_request, "close", psz_value,
                                    sizeof(psz_value) ) != NULL )
         {
-            E_(en50221_CloseMMI)( p_access, i_slot );
+            en50221_CloseMMI( p_access, i_slot );
             return;
         }
 
-        if ( E_(HTTPExtractValue)( psz_request, "cancel", psz_value,
+        if ( HTTPExtractValue( psz_request, "cancel", psz_value,
                                    sizeof(psz_value) ) == NULL )
         {
-            b_ok = VLC_TRUE;
+            b_ok = true;
         }
 
-        if ( E_(HTTPExtractValue)( psz_request, "type", psz_value,
+        if ( HTTPExtractValue( psz_request, "type", psz_value,
                                    sizeof(psz_value) ) == NULL )
         {
             p_sys->psz_mmi_info = strdup( "invalid request parameter\n" );
@@ -1638,13 +1731,13 @@ void E_(CAMStatus)( access_t * p_access )
         {
             mmi_object.i_object_type = EN50221_MMI_ANSW;
             mmi_object.u.answ.b_ok = b_ok;
-            if ( b_ok == VLC_FALSE )
+            if ( b_ok == false )
             {
                 mmi_object.u.answ.psz_answ = strdup("");
             }
             else
             {
-                if ( E_(HTTPExtractValue)( psz_request, "answ", psz_value,
+                if ( HTTPExtractValue( psz_request, "answ", psz_value,
                                            sizeof(psz_value) ) == NULL )
                 {
                     p_sys->psz_mmi_info = strdup( "invalid request parameter\n" );
@@ -1657,13 +1750,13 @@ void E_(CAMStatus)( access_t * p_access )
         else
         {
             mmi_object.i_object_type = EN50221_MMI_MENU_ANSW;
-            if ( b_ok == VLC_FALSE )
+            if ( b_ok == false )
             {
                 mmi_object.u.menu_answ.i_choice = 0;
             }
             else
             {
-                if ( E_(HTTPExtractValue)( psz_request, "choice", psz_value,
+                if ( HTTPExtractValue( psz_request, "choice", psz_value,
                                            sizeof(psz_value) ) == NULL )
                     mmi_object.u.menu_answ.i_choice = 0;
                 else
@@ -1671,14 +1764,14 @@ void E_(CAMStatus)( access_t * p_access )
             }
         }
 
-        E_(en50221_SendMMIObject)( p_access, i_slot, &mmi_object );
+        en50221_SendMMIObject( p_access, i_slot, &mmi_object );
         return;
     }
 
     /* Check that we have all necessary MMI information. */
     for ( i_slot = 0; i_slot < p_sys->i_nb_slots; i_slot++ )
     {
-        if ( p_sys->pb_slot_mmi_expected[i_slot] == VLC_TRUE )
+        if ( p_sys->pb_slot_mmi_expected[i_slot] == true )
             return;
     }
 
@@ -1686,8 +1779,9 @@ void E_(CAMStatus)( access_t * p_access )
 
     if ( ioctl( p_sys->i_ca_handle, CA_GET_CAP, &caps ) != 0 )
     {
-        p += sprintf( p, "ioctl CA_GET_CAP failed (%s)\n",
-                      strerror(errno) );
+        char buf[1000];
+        strerror_r( errno, buf, sizeof( buf ) );
+        p += sprintf( p, "ioctl CA_GET_CAP failed (%s)\n", buf );
         goto out;
     }
 
@@ -1722,14 +1816,15 @@ void E_(CAMStatus)( access_t * p_access )
     {
         ca_slot_info_t sinfo;
 
-        p_sys->pb_slot_mmi_undisplayed[i_slot] = VLC_FALSE;
+        p_sys->pb_slot_mmi_undisplayed[i_slot] = false;
         p += sprintf( p, "<p>CA slot #%d: ", i_slot );
 
         sinfo.num = i_slot;
         if ( ioctl( p_sys->i_ca_handle, CA_GET_SLOT_INFO, &sinfo ) != 0 )
         {
-            p += sprintf( p, "ioctl CA_GET_SLOT_INFO failed (%s)<br>\n",
-                          strerror(errno) );
+            char buf[1000];
+            strerror_r( errno, buf, sizeof( buf ) );
+            p += sprintf( p, "ioctl CA_GET_SLOT_INFO failed (%s)<br>\n", buf );
             continue;
         }
 
@@ -1744,7 +1839,7 @@ void E_(CAMStatus)( access_t * p_access )
 
         if ( sinfo.flags & CA_CI_MODULE_READY )
         {
-            en50221_mmi_object_t *p_object = E_(en50221_GetMMIObject)( p_access,
+            en50221_mmi_object_t *p_object = en50221_GetMMIObject( p_access,
                                                                        i_slot );
 
             p += sprintf( p, "module present and ready<p>\n" );
@@ -1764,7 +1859,7 @@ void E_(CAMStatus)( access_t * p_access )
                     p += sprintf( p, "<input type=hidden name=type value=enq>\n" );
                     p += sprintf( p, "<table border=1><tr><th>%s</th></tr>\n",
                                   p_object->u.enq.psz_text );
-                    if ( p_object->u.enq.b_blind == VLC_FALSE )
+                    if ( p_object->u.enq.b_blind == false )
                         p += sprintf( p, "<tr><td><input type=text name=answ></td></tr>\n" );
                     else
                         p += sprintf( p, "<tr><td><input type=password name=answ></td></tr>\n" );
@@ -1814,7 +1909,7 @@ void E_(CAMStatus)( access_t * p_access )
 
 out:
     vlc_mutex_lock( &p_sys->httpd_mutex );
-    p_sys->b_request_mmi_info = VLC_FALSE;
+    p_sys->b_request_mmi_info = false;
     vlc_cond_signal( &p_sys->httpd_cond );
     vlc_mutex_unlock( &p_sys->httpd_mutex );
 }
@@ -1823,7 +1918,7 @@ out:
 /*****************************************************************************
  * CAMSet :
  *****************************************************************************/
-int E_(CAMSet)( access_t * p_access, dvbpsi_pmt_t *p_pmt )
+int CAMSet( access_t * p_access, dvbpsi_pmt_t *p_pmt )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
@@ -1833,7 +1928,7 @@ int E_(CAMSet)( access_t * p_access, dvbpsi_pmt_t *p_pmt )
         return VLC_EGENERIC;
     }
 
-    E_(en50221_SetCAPMT)( p_access, p_pmt );
+    en50221_SetCAPMT( p_access, p_pmt );
 
     return VLC_SUCCESS;
 }
@@ -1841,11 +1936,11 @@ int E_(CAMSet)( access_t * p_access, dvbpsi_pmt_t *p_pmt )
 /*****************************************************************************
  * CAMClose :
  *****************************************************************************/
-void E_(CAMClose)( access_t * p_access )
+void CAMClose( access_t * p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
-    E_(en50221_End)( p_access );
+    en50221_End( p_access );
 
     if ( p_sys->i_ca_handle )
     {