Ejemplo n.º 1
0
static adv_error mp3_read_id(unsigned char* id, unsigned channel, unsigned char* data, unsigned* pos, unsigned* run)
{
	if (mp3_read(id+0, channel, data, pos, run) != 0)
		return -1;
	if (mp3_read(id+1, channel, data, pos, run) != 0)
		return -1;
	if (mp3_read(id+2, channel, data, pos, run) != 0)
		return -1;
	if (mp3_read(id+3, channel, data, pos, run) != 0)
		return -1;
	return 0;
}
Ejemplo n.º 2
0
LOCAL int stream_head_read(unsigned char *hbuf,uint32_t *newhead){
  if(mp3_read(hbuf,4) != 4) return FALSE;
#ifdef ARCH_X86
  *newhead = bswap_32(*((uint32_t*)hbuf));
#else
  /*
   * we may not be able to address unaligned 32-bit data on non-x86 cpus.
   * Fall back to some portable code.
   */
  *newhead = 
      hbuf[0] << 24 |
      hbuf[1] << 16 |
      hbuf[2] <<  8 |
      hbuf[3];
#endif
  return TRUE;
}
Ejemplo n.º 3
0
static void
mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
{
	struct mp3_data data;
	GError *error = NULL;
	struct tag *tag = NULL;
	struct audio_format audio_format;

	if (!mp3_open(input_stream, &data, decoder, &tag)) {
		if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
			g_warning
			    ("Input does not appear to be a mp3 bit stream.\n");
		return;
	}

	if (!audio_format_init_checked(&audio_format,
				       data.frame.header.samplerate,
				       SAMPLE_FORMAT_S24_P32,
				       MAD_NCHANNELS(&data.frame.header),
				       &error)) {
		g_warning("%s", error->message);
		g_error_free(error);

		if (tag != NULL)
			tag_free(tag);
		mp3_data_finish(&data);
		return;
	}

	decoder_initialized(decoder, &audio_format,
			    data.input_stream->seekable, data.total_time);

	if (tag != NULL) {
		decoder_tag(decoder, input_stream, tag);
		tag_free(tag);
	}

	while (mp3_read(&data)) ;

	mp3_data_finish(&data);
}
Ejemplo n.º 4
0
static void
mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
{
	struct mp3_data data;
	struct tag *tag = NULL;
	struct replay_gain_info *replay_gain_info = NULL;
	struct audio_format audio_format;

	if (!mp3_open(input_stream, &data, decoder, &tag, &replay_gain_info)) {
		if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
			g_warning
			    ("Input does not appear to be a mp3 bit stream.\n");
		return;
	}

	mp3_audio_format(&data, &audio_format);

	decoder_initialized(decoder, &audio_format,
			    data.input_stream->seekable, data.total_time);

	if (tag != NULL) {
		decoder_tag(decoder, input_stream, tag);
		tag_free(tag);
	}

	while (mp3_read(&data, &replay_gain_info)) ;

	if (replay_gain_info)
		replay_gain_info_free(replay_gain_info);

	if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
	    data.mute_frame == MUTEFRAME_SEEK)
		decoder_command_finished(decoder);

	mp3_data_finish(&data);
}