Example #1
0
static off_t pnm_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) {
  pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen;

  xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
           "input_pnm: seek %" PRIdMAX " bytes, origin %d\n", (intmax_t)offset,
           origin);

  /* only realtive forward-seeking is implemented */

  if ((origin == SEEK_CUR) && (offset >= 0)) {

    for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) {
      off_t n = pnm_plugin_read (this_gen, this->scratch, BUFSIZE);
      if (n <= 0)
	return this->curpos;
      this->curpos += n;
    }

    off_t n = pnm_plugin_read (this_gen, this->scratch, offset);
    if (n <= 0)
      return this->curpos;
    this->curpos += n;
  }

  return this->curpos;
}
Example #2
0
static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen, 
                                             fifo_buffer_t *fifo, off_t todo) {
  /*pnm_input_plugin_t   *this = (pnm_input_plugin_t *) this_gen; */
  buf_element_t        *buf = fifo->buffer_pool_alloc (fifo);
  int                   total_bytes;

#ifdef LOG
  printf ("pnm_plugin_read_block: %lld bytes...\n",
          todo);
#endif

  buf->content = buf->mem;
  buf->type = BUF_DEMUX_BLOCK;
  
  total_bytes = pnm_plugin_read (this_gen, buf->content, todo);

  if (total_bytes != todo) {
    buf->free_buffer (buf);
    return NULL;
  }

  buf->size = total_bytes;

  return buf;
}
Example #3
0
static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen,
                                             fifo_buffer_t *fifo, off_t todo) {
  /*pnm_input_plugin_t   *this = (pnm_input_plugin_t *) this_gen; */
  buf_element_t        *buf = fifo->buffer_pool_alloc (fifo);
  int                   total_bytes;

  lprintf ("pnm_plugin_read_block: %"PRId64" bytes...\n", todo);

  if (todo > buf->max_size)
    todo = buf->max_size;
  if (todo < 0) {
    buf->free_buffer (buf);
    return NULL;
  }

  buf->content = buf->mem;
  buf->type = BUF_DEMUX_BLOCK;

  total_bytes = pnm_plugin_read (this_gen, (char*)buf->content, todo);

  if (total_bytes != todo) {
    buf->free_buffer (buf);
    return NULL;
  }

  buf->size = total_bytes;

  return buf;
}
Example #4
0
static off_t pnm_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) {
  pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen;

  printf ("input_pnm: seek %lld bytes, origin %d\n",
	  offset, origin);

  /* only realtive forward-seeking is implemented */

  if ((origin == SEEK_CUR) && (offset >= 0)) {

    for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) {
      this->curpos += pnm_plugin_read (this_gen, this->scratch, BUFSIZE);
    }

    this->curpos += pnm_plugin_read (this_gen, this->scratch, offset);
  }

  return this->curpos;
}