Beispiel #1
0
static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, 
				    const char *data) {

  /* pnm_input_class_t  *cls = (pnm_input_class_t *) cls_gen; */
  pnm_input_plugin_t *this;
  char               *mrl = strdup(data);

  if (strncasecmp (mrl, "pnm://", 6)) {
    free (mrl);
    return NULL;
  }

  this = (pnm_input_plugin_t *) xine_xmalloc (sizeof (pnm_input_plugin_t));

  this->stream = stream;
  this->pnm    = NULL;
  this->mrl    = mrl; 
  this->nbc    = nbc_init (this->stream);
  
  this->input_plugin.open              = pnm_plugin_open;
  this->input_plugin.get_capabilities  = pnm_plugin_get_capabilities;
  this->input_plugin.read              = pnm_plugin_read;
  this->input_plugin.read_block        = pnm_plugin_read_block;
  this->input_plugin.seek              = pnm_plugin_seek;
  this->input_plugin.get_current_pos   = pnm_plugin_get_current_pos;
  this->input_plugin.get_length        = pnm_plugin_get_length;
  this->input_plugin.get_blocksize     = pnm_plugin_get_blocksize;
  this->input_plugin.get_mrl           = pnm_plugin_get_mrl;
  this->input_plugin.dispose           = pnm_plugin_dispose;
  this->input_plugin.get_optional_data = pnm_plugin_get_optional_data;
  this->input_plugin.input_class       = cls_gen;
  
  return &this->input_plugin;
}
Beispiel #2
0
ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input) {
  ebml_parser_t *ebml;

  ebml = xine_xmalloc(sizeof(ebml_parser_t));
  ebml->xine                 = xine;
  ebml->input                = input;

  return ebml;
}
Beispiel #3
0
void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) {

  char *ptr;
  
  *base = ptr = xine_xmalloc (size+alignment);
  
  while ((size_t) ptr % alignment)
    ptr++;
    
  return ptr;
}
Beispiel #4
0
/*
 * create a new, empty list
 */
xine_list_t *xine_list_new (void) {
  xine_list_t *list;

  list = (xine_list_t *) xine_xmalloc(sizeof(xine_list_t));

  list->first=NULL;
  list->last =NULL;
  list->cur  =NULL;

  return list;
}
Beispiel #5
0
static char *copy_string (const char *str) {

  char *cpy;
  int   len;

  len = strlen (str);

  cpy = xine_xmalloc (len+256);

  strncpy (cpy, str, len);

  return cpy;
}
Beispiel #6
0
static img_buf_fifo_t *vo_new_img_buf_queue () {

  img_buf_fifo_t *queue;

  queue = (img_buf_fifo_t *) xine_xmalloc (sizeof (img_buf_fifo_t));
  if( queue ) {
    queue->first       = NULL;
    queue->last        = NULL;
    queue->num_buffers = 0;
    queue->locked_for_read = 0;
    pthread_mutex_init (&queue->mutex, NULL);
    pthread_cond_init  (&queue->not_empty, NULL);
  }
  return queue;
}
Beispiel #7
0
void xine_list_append_priority_content (xine_list_t *l, void *content, int priority) {
  xine_node_t *node;

  node = (xine_node_t *) xine_xmalloc(sizeof(xine_node_t));
  node->content = content;
  node->priority = priority;

  if (l->first) {
    xine_node_t *cur;

    cur = l->first;

    while(1) {
      if( priority >= cur->priority ) {
        node->next = cur;
        node->prev = cur->prev;

        if( node->prev )
          node->prev->next = node;
        else
          l->first = node;
        cur->prev = node;

        l->cur = node;
        break;
      }

      if( !cur->next ) {
        node->next = NULL;
        node->prev = cur;
        cur->next = node;

        l->cur = node;
        l->last = node;
        break;
      }
     
      cur = cur->next;
    }
  } 
  else {
    l->first = l->last = l->cur = node;
    node->prev = node->next = NULL;
  }
}
Beispiel #8
0
static void *init_class (xine_t *xine, void *data) {

  pnm_input_class_t  *this;

  this = (pnm_input_class_t *) xine_xmalloc (sizeof (pnm_input_class_t));

  this->xine   = xine;

  this->input_class.get_instance       = pnm_class_get_instance;
  this->input_class.get_identifier     = pnm_class_get_identifier;
  this->input_class.get_description    = pnm_class_get_description;
  this->input_class.get_dir            = NULL;
  this->input_class.get_autoplay_list  = NULL;
  this->input_class.dispose            = pnm_class_dispose;
  this->input_class.eject_media        = NULL;

  return this;
}
Beispiel #9
0
void xine_list_append_content (xine_list_t *l, void *content) {
  xine_node_t *node;

  node = (xine_node_t *) xine_xmalloc(sizeof(xine_node_t));
  node->content = content;

  if (l->last) {
    node->next = NULL;
    node->prev = l->last;
    l->last->next = node;
    l->last = node;
    l->cur = node;
  } 
  else {
    l->first = l->last = l->cur = node;
    node->prev = node->next = NULL;
  }
}
Beispiel #10
0
void xine_list_insert_content (xine_list_t *l, void *content) {
  xine_node_t *nodecur, *nodenext, *nodenew;
  
  if(l->cur->next) {
    nodenew = (xine_node_t *) xine_xmalloc(sizeof(xine_node_t));

    nodenew->content = content;
    nodecur = l->cur;
    nodenext = l->cur->next;
    nodecur->next = nodenew;
    nodenext->prev = nodenew;
    nodenew->prev = nodecur;
    nodenew->next = nodenext;
    l->cur = nodenew;
  }
  else { /* current is last, append to the list */
    xine_list_append_content(l, content);
  }

}
Beispiel #11
0
static void nsf_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {

  nsf_decoder_t *this = (nsf_decoder_t *) this_gen;
  audio_buffer_t *audio_buffer;

  if (buf->decoder_flags & BUF_FLAG_HEADER) {

    /* When the engine sends a BUF_FLAG_HEADER flag, it is time to initialize
     * the decoder. The buffer element type has 4 decoder_info fields,
     * 0..3. Field 1 is the sample rate. Field 2 is the bits/sample. Field
     * 3 is the number of channels. */
    this->sample_rate = buf->decoder_info[1];
    this->bits_per_sample = buf->decoder_info[2];
    this->channels = buf->decoder_info[3];

    /* take this opportunity to initialize stream/meta information */
    this->stream->meta_info[XINE_META_INFO_AUDIOCODEC] = strdup("NES Music (Nosefart)");

    this->song_number = buf->content[4];
    /* allocate a buffer for the file */
    this->nsf_size = BE_32(&buf->content[0]);
    this->nsf_file = xine_xmalloc(this->nsf_size);
    this->nsf_index = 0;

    /* peform any other required initialization */
    this->last_pts = -1;
    this->iteration = 0;

    return;
  }

  /* accumulate chunks from the NSF file until whole file is received */
  if (this->nsf_index < this->nsf_size) {
    xine_fast_memcpy(&this->nsf_file[this->nsf_index], buf->content,
      buf->size);
    this->nsf_index += buf->size;

    if (this->nsf_index == this->nsf_size) {
      /* file has been received, proceed to initialize engine */
      nsf_init();
      this->nsf = nsf_load(NULL, this->nsf_file, this->nsf_size);
      if (!this->nsf) {
        printf ("nsf: could not initialize NSF\n");
        /* make the decoder return on every subsequent buffer */
        this->nsf_index = 0;
      }
      this->nsf->current_song = this->song_number;
      nsf_playtrack(this->nsf, this->nsf->current_song, this->sample_rate,
        this->bits_per_sample, this->channels);
    }
    return;
  }

  /* if the audio output is not open yet, open the audio output */
  if (!this->output_open) {
    this->output_open = this->stream->audio_out->open(
      this->stream->audio_out,
      this->stream,
      this->bits_per_sample,
      this->sample_rate,
      (this->channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO);
  }

  /* if the audio still isn't open, do not go any further with the decode */
  if (!this->output_open)
    return;

  /* check if a song change was requested */
  if (buf->decoder_info[1]) {
    this->nsf->current_song = buf->decoder_info[1];
    nsf_playtrack(this->nsf, this->nsf->current_song, this->sample_rate,
      this->bits_per_sample, this->channels);
  }

  /* time to decode a frame */
  if (this->last_pts != -1) {

    /* process a frame */
    nsf_frame(this->nsf);

    /* get an audio buffer */
    audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
    if (audio_buffer->mem_size == 0) {
       printf ("nsf: Help! Allocated audio buffer with nothing in it!\n");
       return;
    }

    apu_process(audio_buffer->mem, this->sample_rate / this->nsf->playback_rate);
    audio_buffer->vpts = buf->pts;
    audio_buffer->num_frames = this->sample_rate / this->nsf->playback_rate;
    this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream);
  }
  this->last_pts = buf->pts;
}
Beispiel #12
0
void *xine_memdup0 (const void *src, size_t length)
{
  char *dst = xine_xmalloc (length + 1);
  dst[length] = 0;
  return xine_fast_memcpy (dst, src, length);
}
Beispiel #13
0
pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) {
  
  char *mrl_ptr=strdup(mrl);
  char *slash, *colon;
  int pathbegin, hostend;
  pnm_t *p;
  int fd;
  int need_response=0;
  
  if (strncmp(mrl,"pnm://",6))
  {
    return NULL;
  }
  
  mrl_ptr+=6;

  p=xine_xmalloc(sizeof(pnm_t));
  p->stream = stream;
  p->port=7070;
  p->url=strdup(mrl);
  p->packet=0;

  slash=strchr(mrl_ptr,'/');
  colon=strchr(mrl_ptr,':');

  if(!slash) slash=mrl_ptr+strlen(mrl_ptr)+1;
  if(!colon) colon=slash; 
  if(colon > slash) colon=slash;

  pathbegin=slash-mrl_ptr;
  hostend=colon-mrl_ptr;

  p->host=malloc(sizeof(char)*hostend+1);
  strncpy(p->host, mrl_ptr, hostend);
  p->host[hostend]=0;

  if (pathbegin < strlen(mrl_ptr)) p->path=strdup(mrl_ptr+pathbegin+1);
  if (colon != slash) {
    strncpy(p->buffer,mrl_ptr+hostend+1, pathbegin-hostend-1);
    p->buffer[pathbegin-hostend-1]=0;
    p->port=atoi(p->buffer);
  }

  free(mrl_ptr-6);

#ifdef LOG
  printf("input_pnm: got mrl: %s %i %s\n",p->host,p->port,p->path);
#endif
  
  fd = host_connect (p->host, p->port);

  if (fd == -1) {
    printf ("input_pnm: failed to connect '%s'\n", p->host);
    free(p->path);
    free(p->host);
    free(p->url);
    free(p);
    return NULL;
  }
  p->s=fd;

  pnm_send_request(p,pnm_available_bandwidths[10]);
  if (!pnm_get_headers(p, &need_response)) {
    printf ("input_pnm: failed to set up stream\n");
    free(p->path);
    free(p->host);
    free(p->url);
    free(p);
    return NULL;
  }
  if (need_response)
    pnm_send_response(p, pnm_response);
  p->ts_last[0]=0;
  p->ts_last[1]=0;
  
  /* copy header to recv */

  memcpy(p->recv, p->header, p->header_len);
  p->recv_size = p->header_len;
  p->recv_read = 0;

  return p;
}
Beispiel #14
0
  int i = 0;
  
  while (known_section[i])
    if (strcmp(sect, known_section[i++]) == 0)
      return i;
  return i + 1;
}

static cfg_entry_t *xine_config_add (config_values_t *this, const char *key) {

  cfg_entry_t *entry, *cur, *prev;
  char *new_parse, *new_section, *new_plugin, *new_name;
  char *cur_parse, *cur_section, *cur_plugin, *cur_name;
  char *tmp;

  entry = (cfg_entry_t *) xine_xmalloc (sizeof (cfg_entry_t));
  entry->config        = this;
  entry->key           = copy_string (key);
  entry->type          = CONFIG_TYPE_UNKNOWN;
  entry->unknown_value = NULL;
  entry->str_value     = NULL;

  /* extract parts of the new key */
  new_parse = strdup(key);
  cur_parse = NULL;
  if ((tmp = strchr(new_parse, '.'))) {
    new_section = new_parse;
    *tmp        = '\0';
    tmp++;
    if ((new_name = strchr(tmp, '.'))) {
      new_plugin = tmp;