Ejemplo n.º 1
0
/*
 * NAME:	decoder->run()
 * DESCRIPTION:	run the decoder thread either synchronously or asynchronously
 */
int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
{
  int result;
  int (*run)(struct mad_decoder *) = 0;

  switch (decoder->mode = mode) {
  case MAD_DECODER_MODE_SYNC:
    run = run_sync;
    break;

  case MAD_DECODER_MODE_ASYNC:
# if defined(USE_ASYNC)
    run = run_async;
# endif
    break;
  }

  if (run == 0)
    return -1;

  decoder->sync = mp3_malloc(sizeof(*decoder->sync));
  if (decoder->sync == 0)
    return -1;

  result = run(decoder);

  mp3_free(decoder->sync);
  decoder->sync = 0;

  return result;
}
Ejemplo n.º 2
0
static void stop()
{
	f_close( &file );
	puts("File closed.");
	
	// wait until both buffers are empty
  while(dac_busy_buffers() > 0);
	dac_reset();
	
	mp3_free();
	aac_free();
	
  state = STOPPED;
}