/*****************************************************************************
* 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
/*****************************************************************************
* 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 */
if( psz_device )
{
- if( p_sys->psz_videodev )
- free( p_sys->psz_videodev );
+ free( p_sys->psz_videodev );
p_sys->psz_videodev = psz_device;
}
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;
}
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" );
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;
}
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
{
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
{
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
{
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;
if( i_ret < 0 )
{
- msg_Err( p_access, "Select error (%s).", strerror( errno ) );
+ msg_Err( p_access, "Polling error (%m)." );
return -1;
}
case ACCESS_SET_TITLE:
case ACCESS_SET_SEEKPOINT:
case ACCESS_SET_PRIVATE_ID_STATE:
+ case ACCESS_GET_CONTENT_TYPE:
return VLC_EGENERIC;
default: