Exemplo n.º 1
0
OGGFILE *open_ogg_file(char *filename) {
  OGGFILE *p = NULL;
  PACKFILE *f = NULL;
  ALOGG_OGGSTREAM *s = NULL;
  char data[DATASZ];
  int len;

  if (!(p = (OGGFILE *)malloc(sizeof(OGGFILE))))
    goto error;
  if (!(f = pack_fopen(filename, F_READ)))
    goto error;
  if ((len = pack_fread(data, DATASZ, f)) <= 0)
    goto error;
  if (len < DATASZ) {
    if (!(s = alogg_create_oggstream(data, len, TRUE)))
      goto error;
  }
  else {
    if (!(s = alogg_create_oggstream(data, DATASZ, FALSE)))
      goto error;
  }
  p->f = f;
  p->s = s;
  return p;

  error:
  pack_fclose(f);
  free(p);
  return NULL;
}
Exemplo n.º 2
0
SOUNDCLIP *my_load_ogg(const char *filname, int voll)
{

  mp3in = pack_fopen(filname, "rb");
  if (mp3in == NULL)
    return NULL;

  char *tmpbuffer = (char *)malloc(MP3CHUNKSIZE);
  if (tmpbuffer == NULL) {
    pack_fclose(mp3in);
    return NULL;
  }

  thisogg = new MYOGG();
  thisogg->in = mp3in;
  thisogg->vol = voll;
  thisogg->chunksize = MP3CHUNKSIZE;
  thisogg->done = 0;
  thisogg->last_but_one = 0;
  thisogg->last_ms_offs = 0;
  thisogg->last_but_one_but_one = 0;

  if (thisogg->chunksize > mp3in->todo)
    thisogg->chunksize = mp3in->todo;

  pack_fread(tmpbuffer, thisogg->chunksize, mp3in);

  thisogg->buffer = (char *)tmpbuffer;
  thisogg->stream = alogg_create_oggstream(tmpbuffer, thisogg->chunksize, (mp3in->todo < 1));

  if (thisogg->stream == NULL) {
    free(tmpbuffer);
    pack_fclose(mp3in);
    delete thisogg;
    return NULL;
  }

  return thisogg;
}