]> git.sesse.net Git - vlc/blobdiff - modules/access/pvr.c
Remove useless test before a delete.
[vlc] / modules / access / pvr.c
index ab80c7f5cedb873a7fab9db917e984bd3553bf4e..848276bb9b3498934d1327d5d01e6f458e2e08f6 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_access.h>
 
-#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/poll.h>
 #ifdef HAVE_NEW_LINUX_VIDEODEV2_H
-#include VIDEODEV2_H_FILE
+#   ifdef VIDEODEV2_H_FILE
+#   include VIDEODEV2_H_FILE
+#   else
+#   include <linux/videodev2.h>
+#   endif
 #else
 #include "videodev2.h"
 #endif
@@ -163,7 +170,7 @@ vlc_module_end();
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
-static int Read   ( access_t *, uint8_t *, int );
+static ssize_t Read   ( access_t *, uint8_t *, size_t );
 static int Control( access_t *, int, va_list );
 
 /* ivtv specific ioctls */
@@ -819,8 +826,7 @@ static int Open( vlc_object_t * p_this )
 
     if( psz_device )
     {
-        if( p_sys->psz_videodev )
-            free( p_sys->psz_videodev );
+        free( p_sys->psz_videodev );
         p_sys->psz_videodev = psz_device;
     }
 
@@ -828,7 +834,7 @@ static int Open( vlc_object_t * p_this )
     p_sys->i_fd = open( p_sys->psz_videodev, O_RDWR );
     if( p_sys->i_fd < 0 )
     {
-        msg_Err( p_access, "Cannot open device (%s).", strerror( errno ) );
+        msg_Err( p_access, "Cannot open device (%m)." );
         Close( VLC_OBJECT(p_access) );
         return VLC_EGENERIC;
     }
@@ -838,17 +844,21 @@ static int Open( vlc_object_t * p_this )
     result = ioctl( p_sys->i_fd, VIDIOC_QUERYCAP, &device_capability );
     if( result < 0 )
     {
-        msg_Err( p_access, "unknown ivtv driver version in use" );
+        msg_Err( p_access, "unknown ivtv/pvr driver version in use" );
         Close( VLC_OBJECT(p_access) );
         return VLC_EGENERIC;
     }
 
-    msg_Dbg( p_access, "ivtv driver version %02x.%02x.%02x",
+    msg_Dbg( p_access, "%s driver (%s on %s) version %02x.%02x.%02x",
+              device_capability.driver,
+              device_capability.card,
+              device_capability.bus_info,
             ( device_capability.version >> 16 ) & 0xff,
             ( device_capability.version >>  8 ) & 0xff,
             ( device_capability.version       ) & 0xff);
 
-    if ( device_capability.version >= 0x000800 )
+    if ( strncmp( (char *) device_capability.driver, "ivtv", 4 )
+           || device_capability.version >= 0x000800 )
     {
         /* Drivers > 0.8.0 use v4l2 API instead of IVTV ioctls */
         msg_Dbg( p_access, "this driver uses the v4l2 API" );
@@ -933,8 +943,7 @@ static int Open( vlc_object_t * p_this )
             p_sys->i_radio_fd = open( p_sys->psz_radiodev, O_RDWR );
             if( p_sys->i_radio_fd < 0 )
             {
-                msg_Err( p_access, "Cannot open radio device (%s).",
-                         strerror( errno ) );
+                msg_Err( p_access, "Cannot open radio device (%m)." );
                 Close( VLC_OBJECT(p_access) );
                 return VLC_EGENERIC;
             }
@@ -951,8 +960,7 @@ static int Open( vlc_object_t * p_this )
         result = ioctl( i_fd, VIDIOC_G_TUNER, &vt );
         if ( result < 0 )
         {
-            msg_Warn( p_access, "Failed to read tuner information (%s).",
-                      strerror( errno ) );
+            msg_Warn( p_access, "Failed to read tuner information (%m)." );
         }
         else
         {
@@ -964,8 +972,7 @@ static int Open( vlc_object_t * p_this )
             result = ioctl( i_fd, VIDIOC_G_FREQUENCY, &vf );
             if ( result < 0 )
             {
-                msg_Warn( p_access, "Failed to read tuner frequency (%s).",
-                          strerror( errno ) );
+                msg_Warn( p_access, "Failed to read tuner frequency (%m)." );
             }
             else
             {
@@ -977,8 +984,7 @@ static int Open( vlc_object_t * p_this )
                 result = ioctl( i_fd, VIDIOC_S_FREQUENCY, &vf );
                 if( result < 0 )
                 {
-                    msg_Warn( p_access, "Failed to set tuner frequency (%s).",
-                              strerror( errno ) );
+                    msg_Warn( p_access, "Failed to set tuner frequency (%m)." );
                 }
                 else
                 {
@@ -1054,17 +1060,15 @@ static void Close( vlc_object_t * p_this )
         close( p_sys->i_fd );
     if ( p_sys->i_radio_fd != -1 )
         close( p_sys->i_radio_fd );
-    if ( p_sys->psz_videodev )
-        free( p_sys->psz_videodev );
-    if ( p_sys->psz_radiodev )
-        free( p_sys->psz_radiodev );
+    free( p_sys->psz_videodev );
+    free( p_sys->psz_radiodev );
     free( p_sys );
 }
 
 /*****************************************************************************
  * Read
  *****************************************************************************/
-static int Read( access_t * p_access, uint8_t * p_buffer, int i_len )
+static ssize_t Read( access_t * p_access, uint8_t * p_buffer, size_t i_len )
 {
     access_sys_t *p_sys = (access_sys_t *) p_access->p_sys;
     struct pollfd ufd;
@@ -1087,7 +1091,7 @@ static int Read( access_t * p_access, uint8_t * p_buffer, int i_len )
 
     if( i_ret < 0 )
     {
-        msg_Err( p_access, "Select error (%s).", strerror( errno ) );
+        msg_Err( p_access, "Polling error (%m)." );
         return -1;
     }
 
@@ -1150,6 +1154,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_SET_TITLE:
         case ACCESS_SET_SEEKPOINT:
         case ACCESS_SET_PRIVATE_ID_STATE:
+        case ACCESS_GET_CONTENT_TYPE:
             return VLC_EGENERIC;
 
         default: