diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/input/input_dvd.c | 15 | ||||
-rw-r--r-- | src/input/input_file.c | 8 | ||||
-rw-r--r-- | src/input/input_net.c | 3 | ||||
-rw-r--r-- | src/input/input_stdin_fifo.c | 4 | ||||
-rw-r--r-- | src/input/read_cache.c | 32 |
5 files changed, 44 insertions, 18 deletions
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index c22031a1d..2835b045d 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_dvd.c,v 1.27 2001/10/05 14:49:32 heikos Exp $ + * $Id: input_dvd.c,v 1.28 2001/10/05 17:36:28 jkeil Exp $ */ #ifdef HAVE_CONFIG_H @@ -252,6 +252,7 @@ static off_t dvd_plugin_read (input_plugin_t *this_gen, char *buf, off_t nlen) { dvd_input_plugin_t *this = (dvd_input_plugin_t *) this_gen; + int bytes_read; if (nlen != DVD_VIDEO_LB_LEN) { @@ -264,15 +265,19 @@ static off_t dvd_plugin_read (input_plugin_t *this_gen, if (this->file_size_left < nlen) return 0; - if (read (this->raw_fd, buf, DVD_VIDEO_LB_LEN)) { + bytes_read = read (this->raw_fd, buf, DVD_VIDEO_LB_LEN); + if (bytes_read == DVD_VIDEO_LB_LEN) { this->file_lbcur++; this->file_size_left -= DVD_VIDEO_LB_LEN; return DVD_VIDEO_LB_LEN; - } else - fprintf (stderr, "read error in input_dvd plugin\n"); - + } else if (bytes_read < 0) + fprintf (stderr, "read error in input_dvd plugin (%s)\n", + strerror (errno)); + else + fprintf (stderr, "short read in input_dvd (%d != %d)\n", + bytes_read, DVD_VIDEO_LB_LEN); return 0; } diff --git a/src/input/input_file.c b/src/input/input_file.c index 024974155..128d2781e 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_file.c,v 1.23 2001/09/10 00:47:37 miguelfreitas Exp $ + * $Id: input_file.c,v 1.24 2001/10/05 17:36:28 jkeil Exp $ */ #ifdef HAVE_CONFIG_H @@ -306,12 +306,14 @@ static buf_element_t *file_plugin_read_block (input_plugin_t *this_gen, fifo_buf while (total_bytes < todo) { pthread_testcancel(); num_bytes = read (this->fh, buf->mem + total_bytes, todo-total_bytes); - total_bytes += num_bytes; - if (!num_bytes) { + if (num_bytes <= 0) { + if (num_bytes < 0) + fprintf (stderr, "input_file: read error (%s)\n", strerror (errno)); buf->free_buffer (buf); buf = NULL; break; } + total_bytes += num_bytes; } if( buf != NULL ) diff --git a/src/input/input_net.c b/src/input/input_net.c index e6cd76f14..6266fd305 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -196,7 +196,8 @@ static off_t net_plugin_read (input_plugin_t *this_gen, n = read (this->fh, buf, nlen); - this->curpos += n; + if (n > 0) + this->curpos += n; return n; } diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index 5969d28bb..57abf7005 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_stdin_fifo.c,v 1.12 2001/09/08 00:44:40 guenter Exp $ + * $Id: input_stdin_fifo.c,v 1.13 2001/10/05 17:36:28 jkeil Exp $ */ #ifdef HAVE_CONFIG_H @@ -116,7 +116,7 @@ static off_t stdin_plugin_read (input_plugin_t *this_gen, num_bytes = read (this->fh, &buf[total_bytes], todo - total_bytes); if(num_bytes < 0) { - this->curpos += num_bytes; + this->curpos += total_bytes; return num_bytes; } else if (!num_bytes) { diff --git a/src/input/read_cache.c b/src/input/read_cache.c index 2fd18310b..2eee53d2b 100644 --- a/src/input/read_cache.c +++ b/src/input/read_cache.c @@ -17,12 +17,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: read_cache.c,v 1.4 2001/10/03 15:09:47 jkeil Exp $ + * $Id: read_cache.c,v 1.5 2001/10/05 17:36:28 jkeil Exp $ */ #include <sys/types.h> -#include <stdlib.h> #include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> #include "utils.h" @@ -41,6 +43,7 @@ struct macro_buf_s { off_t adr; uint8_t *data; + int size_valid; /* amount of valid data bytes in 'data' */ read_cache_t *source; }; @@ -177,6 +180,7 @@ buf_element_t *read_cache_read_block (read_cache_t *this, buf_element_t *buf; off_t madr; int badr; + int bytes_read; pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); @@ -191,7 +195,8 @@ buf_element_t *read_cache_read_block (read_cache_t *this, /* find or create macroblock that contains this block */ - if ( !this->cur_mbuf || (this->cur_mbuf->adr != madr) ) { + if ( !this->cur_mbuf || (this->cur_mbuf->adr != madr) || + (this->cur_mbuf->size_valid <= badr) ) { if (this->cur_mbuf && (!this->cur_mbuf->ref)) { @@ -210,11 +215,21 @@ buf_element_t *read_cache_read_block (read_cache_t *this, mbuf->adr = madr; mbuf->ref = 0; + mbuf->size_valid = 0; - /* FIXME: error checking */ - lseek (this->fd, madr, SEEK_SET) ; - pthread_testcancel(); - read ( this->fd, mbuf->data, 2048*16); + if (lseek (this->fd, madr, SEEK_SET) < 0) { + fprintf(stderr, "read_cache: can't seek to offset %lld (%s)\n", + (long long)madr, strerror (errno)); + } else { + pthread_testcancel(); + if ((bytes_read = read (this->fd, mbuf->data, 2048*16)) != 2048*16) { + if (bytes_read < 0) /* reading encrypted dvd without authentication? */ + fprintf(stderr, "read_cache: read error (%s)\n", strerror (errno)); + else + fprintf(stderr, "read_cache: short read (%d != %d)\n", bytes_read, 2048*16); + } + mbuf->size_valid = bytes_read; + } this->cur_mbuf = mbuf; @@ -222,6 +237,9 @@ buf_element_t *read_cache_read_block (read_cache_t *this, mbuf = this->cur_mbuf; } + /* check for read errors */ + if ( badr > mbuf->size_valid ) + return NULL; /* create buf */ |