Beispiel #1
0
static Bool gf_af_get_config(GF_AudioInterface *ai, Bool for_reconf)
{
	GF_AudioFilterItem *af = (GF_AudioFilterItem *)ai->callback;
	
	Bool res = af->src->GetConfig(af->src, for_reconf);
	if (!res) return 0;
	if (!for_reconf) return 1;


	af->input.bps = af->src->bps;
	af->input.samplerate = af->src->samplerate;

	af->input.ch_cfg = af->src->ch_cfg;
	af->input.chan = af->src->chan;

	if (gf_afc_setup(&af->filter_chain, af->input.bps, af->input.samplerate, af->src->chan, af->src->ch_cfg, &af->input.chan, &af->input.ch_cfg)!=GF_OK) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_AUDIO, ("[Audio Input] Failed to configure audio filter chain\n"));

		return 0;
	}
	return 1;
}
Beispiel #2
0
static GF_Err gf_ar_setup_output_format(GF_AudioRenderer *ar)
{
	GF_Err e;
	u32 freq, nb_bits, nb_chan, ch_cfg;
	u32 in_ch, in_cfg, in_bps, in_freq;

	gf_mixer_get_config(ar->mixer, &freq, &nb_chan, &nb_bits, &ch_cfg);

	/*user disabled multichannel audio*/
	if (ar->disable_multichannel && (nb_chan>2) ) nb_chan = 2;

	in_ch = nb_chan;
	in_cfg = ch_cfg;
	in_bps = nb_bits;
	in_freq = freq;

	if (ar->filter_chain.filters) {
		u32 osr, obps, och, ocfg;

		e = gf_afc_setup(&ar->filter_chain, nb_bits, freq, nb_chan, ch_cfg, &och, &ocfg);
		osr = freq;
		obps = nb_bits;
		nb_chan = och;

		/*try to reconfigure audio output*/
		if (!e)
			e = ar->audio_out->ConfigureOutput(ar->audio_out, &osr, &och, &obps, ocfg);

		/*output module cannot support filter output, disable it ...*/
		if (e || (osr != freq) || (och != nb_chan) || (obps != nb_bits)) {
			nb_bits = in_bps;
			freq = in_freq;
			nb_chan = in_ch;
			ar->filter_chain.enable_filters = GF_FALSE;
			e = ar->audio_out->ConfigureOutput(ar->audio_out, &freq, &nb_chan, &nb_bits, ch_cfg);
		}
	} else {
		e = ar->audio_out->ConfigureOutput(ar->audio_out, &freq, &nb_chan, &nb_bits, ch_cfg);
	}

	if (e) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[AudioRender] reconfigure error %d\n", e));
		if (nb_chan>2) {
			nb_chan=2;
			in_ch=2;
			ch_cfg=0;
			e = ar->audio_out->ConfigureOutput(ar->audio_out, &freq, &nb_chan, &nb_bits, ch_cfg);
		}
		if (e) return e;
	}
	gf_mixer_set_config(ar->mixer, freq, nb_chan, nb_bits, in_cfg);
	ar->audio_delay = ar->audio_out->GetAudioDelay(ar->audio_out);

	ar->audio_out->SetVolume(ar->audio_out, ar->volume);
	ar->audio_out->SetPan(ar->audio_out, ar->pan);

	ar->time_at_last_config = ar->current_time;
	ar->bytes_requested = 0;
	ar->bytes_per_second = freq * nb_chan * nb_bits / 8;

	if (ar->audio_listeners) {
		u32 k=0;
		GF_AudioListener *l;
		while ((l = (GF_AudioListener*)gf_list_enum(ar->audio_listeners, &k))) {
			l->on_audio_reconfig(l->udta, in_freq, in_bps, in_ch, in_cfg);
		}
	}
	return GF_OK;
}