]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Make it possible to add fake v4l adapters -- basically a mpeg PS file
authorAndreas Öman <andreas@lonelycoder.com>
Sun, 5 Sep 2010 10:19:38 +0000 (10:19 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Sun, 5 Sep 2010 10:19:38 +0000 (10:19 +0000)
Can be useful when testing

src/v4l.c
src/v4l.h

index 01921f59966de1fd412a9d90f448aef25bf3ad53..d17ba1a9d1bf664019c5e6fe73a2b5a6a4d250cc 100644 (file)
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -59,6 +59,7 @@ v4l_input(v4l_adapter_t *va)
   int len, l, r;
 
   len = read(va->va_fd, buf, 4000);
+  usleep(10000);
   if(len < 1)
     return;
 
@@ -190,30 +191,32 @@ v4l_transport_start(th_transport_t *t, unsigned int weight, int force_start)
     return -1;
   }
 
-  result = ioctl(fd, VIDIOC_S_STD, &std);
-  if(result < 0) {
-    tvhlog(LOG_ERR, "v4l",
-          "%s: Unable to set PAL -- %s", va->va_path, strerror(errno));
-    close(fd);
-    return -1;
-  }
+  if(!va->va_file) {
 
-  memset(&vf, 0, sizeof(vf));
-
-  vf.tuner = 0;
-  vf.type = V4L2_TUNER_ANALOG_TV;
-  vf.frequency = (frequency * 16) / 1000000;
-  result = ioctl(fd, VIDIOC_S_FREQUENCY, &vf);
-  if(result < 0) {
-    tvhlog(LOG_ERR, "v4l",
-          "%s: Unable to tune to %dHz", va->va_path, frequency);
-    close(fd);
-    return -1;
-  }
+    result = ioctl(fd, VIDIOC_S_STD, &std);
+    if(result < 0) {
+      tvhlog(LOG_ERR, "v4l",
+            "%s: Unable to set PAL -- %s", va->va_path, strerror(errno));
+      close(fd);
+      return -1;
+    }
 
-  tvhlog(LOG_INFO, "v4l",
-        "%s: Tuned to %dHz", va->va_path, frequency);
+    memset(&vf, 0, sizeof(vf));
+
+    vf.tuner = 0;
+    vf.type = V4L2_TUNER_ANALOG_TV;
+    vf.frequency = (frequency * 16) / 1000000;
+    result = ioctl(fd, VIDIOC_S_FREQUENCY, &vf);
+    if(result < 0) {
+      tvhlog(LOG_ERR, "v4l",
+            "%s: Unable to tune to %dHz", va->va_path, frequency);
+      close(fd);
+      return -1;
+    }
 
+    tvhlog(LOG_INFO, "v4l",
+          "%s: Tuned to %dHz", va->va_path, frequency);
+  }
   if(pipe(va->va_pipe)) {
     tvhlog(LOG_ERR, "v4l",
           "%s: Unable to create control pipe", va->va_path, strerror(errno));
@@ -390,7 +393,7 @@ v4l_transport_find(v4l_adapter_t *va, const char *id, int create)
  */
 static void
 v4l_adapter_add(const char *path, const char *displayname, 
-               const char *devicename)
+               const char *devicename, int file)
 {
   v4l_adapter_t *va;
   int i, r;
@@ -407,6 +410,7 @@ v4l_adapter_add(const char *path, const char *displayname,
   va->va_displayname = strdup(displayname);
   va->va_path = path ? strdup(path) : NULL;
   va->va_devicename = devicename ? strdup(devicename) : NULL;
+  va->va_file = file;
 
   TAILQ_INSERT_TAIL(&v4l_adapters, va, va_global_link);
 }
@@ -546,7 +550,7 @@ v4l_adapter_check(const char *path, int fd)
   tvhlog(LOG_INFO, "v4l",
         "%s: Using adapter", devicename);
 
-  v4l_adapter_add(path, devicename, devicename);
+  v4l_adapter_add(path, devicename, devicename, 0);
 }
 
 
index 87bea72d4e01849544a3632490dd115c648d966f..80ad9108553602beab951e5d833cef86f48b5370 100644 (file)
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -40,6 +40,8 @@ typedef struct v4l_adapter {
 
   char *va_devicename;
 
+  int va_file;
+
   uint32_t va_logging;
 
   //  struct v4l2_capability va_caps;