]> git.sesse.net Git - vlc/blobdiff - modules/access/oss.c
Move libs/loader to modules/codec/loader
[vlc] / modules / access / oss.c
index 5d069dcd977b56523615bfbb42fdfe1e7dc92031..7590cac1dc7008345de05b034e4a29f40af4b125 100644 (file)
@@ -38,6 +38,7 @@
 #include <vlc_demux.h>
 #include <vlc_fs.h>
 
+#include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
@@ -67,11 +68,6 @@ static void DemuxClose( vlc_object_t * );
 #define SAMPLERATE_LONGTEXT N_( \
     "Samplerate of the captured audio stream, in Hz (eg: 11025, 22050, 44100, 48000)" )
 
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
-    "Caching value for OSS captures. This " \
-    "value should be set in milliseconds." )
-
 #define OSS_DEFAULT "/dev/dsp"
 
 #define CFG_PREFIX "oss-"
@@ -86,12 +82,10 @@ vlc_module_begin ()
     set_capability( "access_demux", 10 )
     set_callbacks( DemuxOpen, DemuxClose )
 
-    add_bool( CFG_PREFIX "stereo", true, NULL, STEREO_TEXT, STEREO_LONGTEXT,
+    add_bool( CFG_PREFIX "stereo", true, STEREO_TEXT, STEREO_LONGTEXT,
                 true )
-    add_integer( CFG_PREFIX "samplerate", 48000, NULL, SAMPLERATE_TEXT,
+    add_integer( CFG_PREFIX "samplerate", 48000, SAMPLERATE_TEXT,
                 SAMPLERATE_LONGTEXT, true )
-    add_integer( CFG_PREFIX "caching", DEFAULT_PTS_DELAY / 1000, NULL,
-                CACHING_TEXT, CACHING_LONGTEXT, true )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -121,7 +115,6 @@ struct demux_sys_t
     int  i_fd;
 
     /* Audio */
-    int i_cache;
     unsigned int i_sample_rate;
     bool b_stereo;
     size_t i_max_frame_size;
@@ -170,16 +163,15 @@ static int DemuxOpen( vlc_object_t *p_this )
     p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
     if( p_sys == NULL ) return VLC_ENOMEM;
 
-    p_sys->i_sample_rate = var_CreateGetInteger( p_demux, CFG_PREFIX "samplerate" );
-    p_sys->b_stereo = var_CreateGetBool( p_demux, CFG_PREFIX "stereo" );
-    p_sys->i_cache = var_CreateGetInteger( p_demux, CFG_PREFIX "caching" );
+    p_sys->i_sample_rate = var_InheritInteger( p_demux, CFG_PREFIX "samplerate" );
+    p_sys->b_stereo = var_InheritBool( p_demux, CFG_PREFIX "stereo" );
     p_sys->i_fd = -1;
     p_sys->p_es = NULL;
     p_sys->p_block = NULL;
     p_sys->i_next_demux_date = -1;
 
-    if( p_demux->psz_path && *p_demux->psz_path )
-        p_sys->psz_device = p_demux->psz_path;
+    if( p_demux->psz_location && *p_demux->psz_location )
+        p_sys->psz_device = p_demux->psz_location;
     else
         p_sys->psz_device = OSS_DEFAULT;
 
@@ -227,7 +219,8 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_PTS_DELAY:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            *pi64 = (int64_t)p_sys->i_cache * 1000;
+            *pi64 = INT64_C(1000)
+                  * var_InheritInteger( p_demux, "live-caching" );
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME:
@@ -272,6 +265,8 @@ static int Demux( demux_t *p_demux )
         /* Wait for data */
         if( poll( &fd, 1, 10 ) ) /* Timeout after 0.01 seconds. Bigger delays are an issue when used with/as an input-slave since all the inputs run in the same thread. */
         {
+            if( errno == EINTR )
+                continue;
             if( fd.revents & (POLLIN|POLLPRI) )
             {
                 p_block = GrabAudio( p_demux );
@@ -304,7 +299,7 @@ static block_t* GrabAudio( demux_t *p_demux )
     if( !p_block )
     {
         msg_Warn( p_demux, "cannot get block" );
-        return 0;
+        return NULL;
     }
 
     p_sys->p_block = p_block;
@@ -312,10 +307,10 @@ static block_t* GrabAudio( demux_t *p_demux )
     i_read = read( p_sys->i_fd, p_block->p_buffer,
                 p_sys->i_max_frame_size );
 
-    if( i_read <= 0 ) return 0;
+    if( i_read <= 0 ) return NULL;
 
     p_block->i_buffer = i_read;
-    p_sys->p_block = 0;
+    p_sys->p_block = NULL;
 
     /* Correct the date because of kernel buffering */
     i_correct = i_read;
@@ -340,7 +335,7 @@ static int OpenAudioDevOss( demux_t *p_demux )
     int i_fd;
     int i_format;
 
-    i_fd = utf8_open( p_demux->p_sys->psz_device, O_RDONLY | O_NONBLOCK );
+    i_fd = vlc_open( p_demux->p_sys->psz_device, O_RDONLY | O_NONBLOCK );
 
     if( i_fd < 0 )
     {
@@ -416,7 +411,7 @@ static int OpenAudioDev( demux_t *p_demux )
 static bool ProbeAudioDevOss( demux_t *p_demux, const char *psz_device )
 {
     int i_caps;
-    int i_fd = utf8_open( psz_device, O_RDONLY | O_NONBLOCK );
+    int i_fd = vlc_open( psz_device, O_RDONLY | O_NONBLOCK );
 
     if( i_fd < 0 )
     {