コード例 #1
0
ファイル: nosefart_xmms.c プロジェクト: nesouri/nosefart
static void nosefart_play(char *filename)
{
  char c[1024];
  snprintf(c, 1023, "nosefart -a 2 %s &", filename);

  system(c);

  return;

#if 0
  nsf_t * nsf = 0;

  pdebug("nsf : play [%s]\n", filename);

  /* Load disk. */
  nsf = load(filename);
  if (!nsf) {
    goto error;
  }

  while (app.nsf) {
    pdebug("nsf : busy, wait for end of previous thread !\n");
    xmms_usleep(30000);
  }

  if (SetNsf(nsf) < 0) {
    goto error;
  }

  /* open XMMS audio stream */
  pdebug("nsf : open audio\n");
  audio_open = FALSE;
  if (nosefart_ip.output->open_audio(FMT_S16_LE, 44100, 1) == 0) {
    pdebug("nsf : open audio error\n");
    goto error;
  }
  audio_open = TRUE;
  pdebug("nsf : open audio success\n");

  going = TRUE;
  pthread_create((pthread_t *)&play_thread, NULL, play_loop, 0);
  return;

error:
  going = FALSE;
  pdebug("nsf : play failed\n");
  if (nsf) {
    nsf_free(&nsf);
  }

#endif
}
コード例 #2
0
ファイル: nosefart_xmms.c プロジェクト: nesouri/nosefart
static void nosefart_song_info(char *filename, char **title, int *length)
{
  nsf_t * nsf;

  *length = -1;
  *title = 0;
  nsf = load(filename);
  if (nsf) {
    *title = make_name(nsf->song_name, nsf->artist_name, -1, nsf->num_songs);
    *length = nsf->song_frames[0] * 1000u / (unsigned int)nsf->playback_rate;
    nsf_free(&nsf);
  }
}
コード例 #3
0
ファイル: nsf.c プロジェクト: OS2World/MM-SOUND-xine
/* This function closes the audio output and frees the private audio decoder
 * structure. */
static void nsf_dispose (audio_decoder_t *this_gen) {

  nsf_decoder_t *this = (nsf_decoder_t *) this_gen;

  /* close the audio output */
  if (this->output_open)
    this->stream->audio_out->close (this->stream->audio_out, this->stream);
  this->output_open = 0;

  /* free anything that was allocated during operation */
  nsf_free(&this->nsf);
  free(this->nsf_file);
  free(this);
}
コード例 #4
0
ファイル: nosefart_xmms.c プロジェクト: nesouri/nosefart
static nsf_t * load(char * filename)
{
  int i;
  nsf_t * nsf;
  unsigned int total;

  pdebug("nsf : load [%s]\n", filename);

  nsf = nsf_load(filename,0,0);
  if (!nsf) {
    pdebug("nsf : [%s] load error.\n", filename);
    return 0;
  }
  /* create missing frame info */
  if (!nsf->song_frames) {
    pdebug("nsf : no play time info, alloc buffer\n");
    nsf->song_frames = calloc(nsf->num_songs + 1, sizeof (*nsf->song_frames));
  }

  if (!nsf->song_frames) {
    pdebug ("nsf : [%s] malloc song playing tine buffer failed.\n", filename);
    nsf_free(&nsf);
    return 0;
  }

  for (i=1, total=0; i <= nsf->num_songs; ++i) {
    unsigned int t = nsf->song_frames[i];
    if (!t) {
      t = 2 * 60 * nsf->playback_rate; /* default 2 minutes */
      pdebug("nsf : track #%02d, set default time [%u frames]\n", i, t);
    }
    if (t / nsf->playback_rate < 5) {
      pdebug("nsf : skipping track #%02d (short play time)\n", i);
      t = 0; /* Avoid short time songs (sound FX) */
    }
    nsf->song_frames[i] = t;
    total += t;
  }
  nsf->song_frames[0] = total;

  return nsf;
}
コード例 #5
0
ファイル: nosefart_xmms.c プロジェクト: nesouri/nosefart
static void * play_loop(void *arg)
{
  nsf_t * nsf = app.nsf;

  pdebug("nsf : play-thread\n");

  if (!app.nsf) {
    going = FALSE;
  }
  pdebug("nsf : going [%s]\n", going ? "Yes" : "No");

  app.cur_track = 0;
  nsf->cur_frame = nsf->cur_frame_end = 0;
  while (going) {
    if (nsf->cur_frame >= nsf->cur_frame_end) {
      int next_track = app.cur_track+1;
      pdebug("nsf : frame elapsed [%u > %u] -> track #%02d\n",
	     nsf->cur_frame,nsf->cur_frame_end, next_track);
      
      if (next_track > app.n_tracks) {
	pdebug("nsf : reach last song\n");
	going = FALSE;
	break;
      }
      SetChangeTrack(next_track, -1);
    }
    
    if (ApplyChangeTrack() < 0) {
      going = FALSE;
      break;
    }
    
    if (!app.bufcnt) {
      /* Run a frame. */
      nsf_frame(nsf);
      apu_process(app.buffer, app.buflen);
      app.bufptr = app.buffer;
      app.bufcnt = app.buflen;
    }

    if (going) {
      int tosend = app.bufcnt << 1;
      while (nosefart_ip.output->buffer_free() < tosend && going) {
        xmms_usleep(30000);
      }
      nosefart_ip.add_vis_pcm(nosefart_ip.output->written_time(),
			      FMT_S16_LE, 1, tosend, app.bufptr);
      nosefart_ip.output->write_audio(app.bufptr, tosend);
      tosend >>= 1;
      app.bufcnt -= tosend; 
      app.bufptr += tosend; 
    }
  }
  pdebug("nsf : decoder loop end\n");
  SetChangeTrack(0, -1);
  ApplyChangeTrack();

  if (app.nsf) {
    nsf_free(&app.nsf);
    app.nsf = nsf = 0;
  }

  /* Make sure the output plugin stops prebuffering */
  if (nosefart_ip.output) {
    pdebug("nsf : free audio buffer.\n");
    nosefart_ip.output->buffer_free();
  }
  going = FALSE;
  pdebug("nsf : decode finish\n");
  play_thread = 0;
  pthread_exit(NULL);
}
コード例 #6
0
ファイル: NoseFartDLL.cpp プロジェクト: 1c0n/xbmc
 void __declspec(dllexport) DLL_FreeNSF(void* nsf)
 {
   nsf_t* pNsf = (nsf_t*)nsf;
   nsf_free(&pNsf);
 }