How to relink components from VoIP example

Ismael
Posts: 20
Joined: Thu Mar 05, 2020 7:35 am

How to relink components from VoIP example

Postby Ismael » Thu Mar 12, 2020 5:15 pm

Hello,

In my project I want to mix MP3 audios with VoIP (not at the same time) with the codec. The board used is LyraT v4.3.

So after I realice that the read and write pipelines must be relinked (as the flexible_pipeline example shows) I implement the same steps used but with the filter / raw and I2S components.

Steps followed:
- Initialization:
1.- Init board
2.- Init I2S reader and writer -> register it into the pipelines
3.- Init filter and raw stream -> register it into the reader pipeline
4.- Init reader event and set it as a listener.
5.- Init filter and raw stream -> register it into the writer pipeline
6.- Init writer event and set it as a listener.

- Start process (reader)
1.- invoke audio_pipeline_breakup_elements to clean all elements (due to compatibility with MP3)
2.- Relink components: {"i2s_r", "filter_r", "raw_r"}
3.- Set listener
4.- Reset ringbuffer, elements and change state to AEL_STATE_INIT
5.- run and resume pipeline

- Start process (writer)
1.- invoke audio_pipeline_breakup_elements to clean all elements (due to compatibility with MP3)
2.- Relink components: "raw_w", "filter_w", "i2s_w"}
3.- Set listener
4.- Reset ringbuffer, elements and change state to AEL_STATE_INIT
5.- run and resume pipeline

- Read from microphone and reproduce it over the speaker

- Stop process (writer)
1.- pause element
2.- pause pipeline

- Stop process (reader)
1.- pause element
2.- pause pipeline

At this point i'm trying to reopen it from the start processes.

I got the microphone enable again but the speaker doesn't turned on again.

Have anyone any idea how it can be?

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: How to relink components from VoIP example

Postby shabtronic » Fri Mar 13, 2020 7:26 pm

HI
I had a few problems with this also, don't know if I'm doing it correctly - but this worked for me,
and I tried many different things.

Code: Select all

	
	audio_pipeline_terminate(pipeline);

	if (strstr(Mp3Files[Mp3Stack[Mp3StackPos]].c_str(), (const char*)".mp3"))
		{
		audio_decoder = mp3_decoder;
		const char * boomer[]{ "FatReader", "mp3Decoder","DspOutput", "i2s-out" };
		audio_pipeline_link(pipeline, boomer, 4);
		SongExt = "MP3";
		}
	else
		{
		audio_decoder = flac_decoder;
		const char * boomer[]{ "FatReader", "flacDecoder", "DspOutput","i2s-out" };
		audio_pipeline_link(pipeline, boomer, 4);
		SongExt = "FLC";

		}
	audio_pipeline_set_listener(pipeline, evt);
	audio_element_set_uri(PlayFatStream, ("/sdcard" + filename).c_str());

	audio_pipeline_run(pipeline);
	audio_pipeline_resume(pipeline);
Hope that helps!!

Ismael
Posts: 20
Joined: Thu Mar 05, 2020 7:35 am

Re: How to relink components from VoIP example

Postby Ismael » Mon Mar 16, 2020 1:21 pm

Hello shabtronic, thanks so much for your reply.

From your answer I just to add some lines to make it work.

audio_pipeline_reset_ringbuffer(pipeline_audio_writer);
audio_pipeline_reset_elements(pipeline_audio_writer);
audio_pipeline_change_state(pipeline_audio_writer, AEL_STATE_INIT);

After this, there is no neeed to reset the module after all.

Thanks so much.

Who is online

Users browsing this forum: No registered users and 46 guests