void decoder_initialized(G_GNUC_UNUSED struct decoder * decoder, const struct audio_format *audio_format, bool seekable, float total_time) { assert(dc.state == DECODE_STATE_START); assert(decoder != NULL); assert(decoder->stream_tag == NULL); assert(decoder->decoder_tag == NULL); assert(!decoder->seeking); assert(audio_format != NULL); assert(audio_format_defined(audio_format)); assert(audio_format_valid(audio_format)); dc.in_audio_format = *audio_format; getOutputAudioFormat(audio_format, &dc.out_audio_format); dc.seekable = seekable; dc.total_time = total_time; dc.state = DECODE_STATE_DECODE; notify_signal(&pc.notify); g_debug("audio_format=%u:%u:%u, seekable=%s", dc.in_audio_format.sample_rate, dc.in_audio_format.bits, dc.in_audio_format.channels, seekable ? "true" : "false"); if (!audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) g_debug("converting to %u:%u:%u", dc.out_audio_format.sample_rate, dc.out_audio_format.bits, dc.out_audio_format.channels); }
int mod_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { mod_Data * data; float time = 0.0; int ret; float secPerByte; if(mod_initMikMod() < 0) return -1; if(!(data = mod_open(path))) { ERROR("failed to open mod: %s\n", path); MikMod_Exit(); return -1; } dc->audioFormat.bits = 16; dc->audioFormat.sampleRate = 44100; dc->audioFormat.channels = 2; getOutputAudioFormat(&(dc->audioFormat),&(cb->audioFormat)); secPerByte = 1.0/((dc->audioFormat.bits*dc->audioFormat.channels/8.0)* (float)dc->audioFormat.sampleRate); dc->state = DECODE_STATE_DECODE; while(1) { if(dc->seek) { dc->seekError = 1; dc->seek = 0; } if(dc->stop) break; if(!Player_Active()) break; ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE); time += ret*secPerByte; sendDataToOutputBuffer(cb, NULL, dc, 0, (char *)data->audio_buffer, ret, time, 0, NULL); } flushOutputBuffer(cb); mod_close(data); MikMod_Exit(); if(dc->stop) { dc->state = DECODE_STATE_STOP; dc->stop = 0; } else dc->state = DECODE_STATE_STOP; return 0; }
void decoder_initialized(struct decoder *decoder, const struct audio_format *audio_format, bool seekable, float total_time) { struct decoder_control *dc = decoder->dc; struct audio_format_string af_string; assert(dc->state == DECODE_STATE_START); assert(dc->pipe != NULL); assert(decoder != NULL); assert(decoder->stream_tag == NULL); assert(decoder->decoder_tag == NULL); assert(!decoder->seeking); assert(audio_format != NULL); assert(audio_format_defined(audio_format)); assert(audio_format_valid(audio_format)); dc->in_audio_format = *audio_format; getOutputAudioFormat(audio_format, &dc->out_audio_format); dc->seekable = seekable; dc->total_time = total_time; decoder_lock(dc); dc->state = DECODE_STATE_DECODE; decoder_unlock(dc); player_lock_signal(); g_debug("audio_format=%s, seekable=%s", audio_format_to_string(&dc->in_audio_format, &af_string), seekable ? "true" : "false"); if (!audio_format_equals(&dc->in_audio_format, &dc->out_audio_format)) g_debug("converting to %s", audio_format_to_string(&dc->out_audio_format, &af_string)); }