public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea <mariofutire@googlemail.com>
To: linux-dvb@linuxtv.org
Subject: [linux-dvb] [PATCH 1/2] make gnutv more resilient to temporary slow reads.
Date: Thu, 10 Jul 2008 23:29:02 +0100	[thread overview]
Message-ID: <g562if$ij9$1@ger.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]

I have been using gnutv to save data to my network drive.
Event if the average speed required to save is way less than the bandwidth, gnutv sometimes does not
read fast enough to avoid overflow of the dvb ring buffer.

In that case gnutv prints an error message and stops recording.

In my opinion, it would be better to bite the bullet, loose a bit of the stream, and carry on, in
the hope that the system will not be too busy.

Here is the patch

diff -r 73b910014d07 util/gnutv/gnutv_data.c
--- a/util/gnutv/gnutv_data.c   Sat Jul 05 16:38:32 2008 +0200
+++ b/util/gnutv/gnutv_data.c   Thu Jul 10 23:19:48 2008 +0100
@@ -222,19 +238,26 @@
          while(!outputthread_shutdown) {
                  if (poll(&pollfd, 1, 1000) != 1)
                          continue;
+
+               // in case of read error, we should not abort in order to minimize the loss of data.
+
                  if (pollfd.revents & POLLERR) {
                          if (errno == EINTR)
                                  continue;
-                       fprintf(stderr, "DVR device read failure\n");
-                       return 0;
+                       fprintf(stderr, "DVR device poll failure\n");
+
+                       // This is tipically EOVERFLOW, i.e. dvb internal buffer run out of space
+
+                       // The next read will fail too, but it will also clear the error flag in the
driver
+                       // so that following reads will succeed
                  }

                  int size = read(dvrfd, buf, sizeof(buf));
                  if (size < 0) {
                          if (errno == EINTR)
                                  continue;
-                       fprintf(stderr, "DVR device read failure\n");
-                       return 0;
+                       fprintf(stderr, "DVR device read failure. Possible loss of data.\n");
+                       // The error flag has been cleared, next read should succeed.
                  }

                  written = 0;
@@ -243,6 +266,7 @@
                          if (tmp == -1) {
                                  if (errno != EINTR) {
                                          fprintf(stderr, "Write error: %m\n");
+                                       // abort loop
                                          break;
                                  }
                          } else {



[-- Attachment #2: gnutv.diff3 --]
[-- Type: text/plain, Size: 1270 bytes --]

diff -r 73b910014d07 util/gnutv/gnutv_data.c
--- a/util/gnutv/gnutv_data.c	Sat Jul 05 16:38:32 2008 +0200
+++ b/util/gnutv/gnutv_data.c	Thu Jul 10 23:19:48 2008 +0100
@@ -222,19 +238,26 @@
 	while(!outputthread_shutdown) {
 		if (poll(&pollfd, 1, 1000) != 1)
 			continue;
+
+		// in case of read error, we should not abort in order to minimize the loss of data.
+
 		if (pollfd.revents & POLLERR) {
 			if (errno == EINTR)
 				continue;
-			fprintf(stderr, "DVR device read failure\n");
-			return 0;
+			fprintf(stderr, "DVR device poll failure\n");
+
+			// This is tipically EOVERFLOW, i.e. dvb internal buffer run out of space
+
+			// The next read will fail too, but it will also clear the error flag in the driver
+			// so that following reads will succeed
 		}
 
 		int size = read(dvrfd, buf, sizeof(buf));
 		if (size < 0) {
 			if (errno == EINTR)
 				continue;
-			fprintf(stderr, "DVR device read failure\n");
-			return 0;
+			fprintf(stderr, "DVR device read failure. Possible loss of data.\n");
+			// The error flag has been cleared, next read should succeed.
 		}
 
 		written = 0;
@@ -243,6 +266,7 @@
 			if (tmp == -1) {
 				if (errno != EINTR) {
 					fprintf(stderr, "Write error: %m\n");
+					// abort loop
 					break;
 				}
 			} else {


[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

                 reply	other threads:[~2008-07-10 22:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='g562if$ij9$1@ger.gmane.org' \
    --to=mariofutire@googlemail.com \
    --cc=linux-dvb@linuxtv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox