]> git.sesse.net Git - vlc/blobdiff - modules/access/file.c
XCB: do not look for static color visuals
[vlc] / modules / access / file.c
index 9b3315bd97f745b303b5e067811a117954e4da3f..91f2a84da0c1de0b88f2e73d6d7e37f69ac2f23f 100644 (file)
@@ -97,6 +97,7 @@ vlc_module_end ()
  * Exported prototypes
  *****************************************************************************/
 static int  Seek( access_t *, int64_t );
+static int  NoSeek( access_t *, int64_t );
 static ssize_t Read( access_t *, uint8_t *, size_t );
 static int  Control( access_t *, int, va_list );
 
@@ -109,7 +110,6 @@ struct access_sys_t
     int fd;
 
     /* */
-    bool b_seekable;
     bool b_pace_control;
 };
 
@@ -130,15 +130,9 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_nb_reads = 0;
 
     if (!strcasecmp (p_access->psz_access, "stream"))
-    {
-        p_sys->b_seekable = false;
         p_sys->b_pace_control = false;
-    }
     else
-    {
-        p_sys->b_seekable = true;
         p_sys->b_pace_control = true;
-    }
 
     /* Open file */
     msg_Dbg (p_access, "opening file `%s'", p_access->psz_path);
@@ -166,12 +160,13 @@ static int Open( vlc_object_t *p_this )
         msg_Dbg (p_access, "ignoring directory");
         goto error;
     }
-
-    p_access->info.i_size = st.st_size;
-    if (!S_ISREG (st.st_mode))
-        p_sys->b_seekable = false;
+    if (S_ISREG (st.st_mode))
+        p_access->info.i_size = st.st_size;
+    else if (!S_ISBLK (st.st_mode))
+        p_access->pf_seek = NoSeek;
 #else
-    p_sys->b_seekable = !b_stdin;
+    if (b_stdin)
+        p_access->pf_seek = NoSeek;
 # warning File size not known!
 #endif
 
@@ -210,10 +205,11 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
     ssize_t i_ret;
 
 #ifndef WIN32
-    i_ret = net_Read (p_access, fd, NULL, p_buffer, i_len, false);
-#else
-    i_ret = read (fd, p_buffer, i_len);
+    if (p_access->pf_seek == NoSeek)
+        i_ret = net_Read (p_access, fd, NULL, p_buffer, i_len, false);
+    else
 #endif
+        i_ret = read (fd, p_buffer, i_len);
 
     if( i_ret < 0 )
     {
@@ -268,6 +264,13 @@ static int Seek (access_t *p_access, int64_t i_pos)
     return VLC_SUCCESS;
 }
 
+static int NoSeek (access_t *p_access, int64_t i_pos)
+{
+    /* assert(0); ?? */
+    (void) p_access; (void) i_pos;
+    return VLC_EGENERIC;
+}
+
 /*****************************************************************************
  * Control:
  *****************************************************************************/
@@ -283,7 +286,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_CAN_SEEK:
         case ACCESS_CAN_FASTSEEK:
             pb_bool = (bool*)va_arg( args, bool* );
-            *pb_bool = p_sys->b_seekable;
+            *pb_bool = (p_access->pf_seek != NoSeek);
             break;
 
         case ACCESS_CAN_PAUSE: