diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-01-16 12:02:39 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-01-16 12:02:39 +0100 |
commit | 9423c636a25dcdc2531d51551aff33cf93abc095 (patch) | |
tree | 522f898c6d68ce0153e23db1c1696a2c461a7623 /tools.c | |
parent | 62390837ff4e4fab3bb837ca745219fc70d4ef3e (diff) | |
download | vdr-9423c636a25dcdc2531d51551aff33cf93abc095.tar.gz vdr-9423c636a25dcdc2531d51551aff33cf93abc095.tar.bz2 |
Fixed playing files with PES packets longer than 2048 byte through the full featured DVB card
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.87 2005/01/04 11:06:45 kls Exp $ + * $Id: tools.c 1.88 2005/01/16 11:47:44 kls Exp $ */ #include "tools.h" @@ -65,6 +65,30 @@ void writechar(int filedes, char c) safe_write(filedes, &c, sizeof(c)); } +int WriteAllOrNothing(int fd, const uchar *Data, int Length, int TimeoutMs, int RetryMs) +{ + int written = 0; + while (Length > 0) { + int w = write(fd, Data + written, Length); + if (w > 0) { + Length -= w; + written += w; + } + else if (written > 0 && !FATALERRNO) { + // we've started writing, so we must finish it! + cTimeMs t; + cPoller Poller(fd, true); + Poller.Poll(RetryMs); + if (TimeoutMs > 0 && (TimeoutMs -= t.Elapsed()) <= 0) + break; + } + else + // nothing written yet (or fatal error), so we can just return the error code: + return w; + } + return written; +} + char *strcpyrealloc(char *dest, const char *src) { if (src) { |