Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: AW: Problem with DVD-AC3-Playback and VDR0.98




On Tue, Nov 20, 2001 at 02:40:19PM +0100, Stephan Schreiber wrote:
> 
> > With VDR0.98 and DVD-Playback come Error-Message:
> > ** CRC failed - skipping frame ** ... unbroken up to break of
> > DVD-Playback!
> > The VDR0.98 and VDR-Recording-Files with AC3 is ok
> > and AC3-Playback works..
> 
> Andreas wrote, it is ac3dec's fault because it expects the ac3 frames to be
> complete, but in the case of DVD it seems syncing makes them arrive only
> partially and thus they have to be reassembled by the ac3 -> spdif tool.
> 
> ac3dec and ac3play show the same behaviour there, and I couldn't get
> ac3iec958 to work either.

To get ac3iec958 to work you may try the appended patch ...

        Werner

-----------------------------------------------------------------------------
--- ac3spdif.cpp
+++ ac3spdif.cpp	Mon Nov 19 17:26:52 2001
@@ -10,6 +10,8 @@
 // COPYING that is shipped together with this file.
 //
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
@@ -36,6 +38,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
 #define CACHE_SIZE 16384
 #define BUFF_SIZE  2048
 
@@ -45,6 +51,35 @@
 typedef unsigned short u16;
 typedef unsigned int   u32;
 
+static inline ssize_t safein  (int fd, u8 *ptr, size_t s)
+{
+    ssize_t r = 0;
+    do {
+	r = read (fd, ptr, s);
+    } while (r < 0 && (errno == EINTR || errno == EAGAIN));
+
+    return r;
+}
+
+static inline ssize_t safeout (int fd, const u8 *ptr, size_t s)
+{
+    ssize_t p = 0;
+    while (s > 0) {
+	p = write (fd, ptr, s);
+	if (p < 0) {
+	    if (errno == EPIPE)
+		exit (0);
+	    if (errno == EINTR || errno == EAGAIN)
+		continue;
+	    goto out;
+	}
+	ptr += p;
+	s -= p;
+    }
+out:
+    return p;
+}
+
 static inline bool strequ (char const *a, char const *b)
 {
     return strcmp (a, b) == 0;
@@ -59,7 +94,7 @@
     u8    buff[CACHE_SIZE];
     int   fd;
     bool  eos;
-    int   count;
+    ssize_t   count;
     int   ptr;
 
 public:
@@ -77,7 +112,7 @@
             return;
         if (ptr >= count)
         {
-            count= read (fd, buff, CACHE_SIZE);
+            count= safein (fd, buff, CACHE_SIZE);
             if (count <= 0)
                 eos= true;
 
@@ -135,7 +170,7 @@
             swab (buff, buff, ptr);
 #endif
 
-        int count= write (fd, buff, ptr);
+        ssize_t count= safeout (fd, buff, ptr);
         if (count < 0)
             err= true;
 
@@ -355,6 +390,7 @@
 
     void put (AC3SyncInfo const &si, u8 const *data)
     {
+	// output data length
         int byte_length=  si.frame_size * 2;
         int total_length= 4 + byte_length;
         int pad_count=    1536 * 4 - total_length;
@@ -397,7 +433,7 @@
 
         /* AC3 Sync Frame */
         out.put16 (0x0b77); /* sync word of the AC3 sync frame */
-        for (int i= 2; i < si.frame_size * 2; i++)
+        for (int i= 2; i < byte_length; i++)
             out.put (*data++);
 
         /* Zero padding */



Home | Main Index | Thread Index