We study the Mediastreamer2 VoIP engine. Part 3

Article material taken from my zen channel .



Improving the tone generator example


In a previous article, we wrote a tone generator application and with it we extracted sound from a computer speaker. Now we pay attention to the fact that our program, upon terminating work, does not return memory back to the heap. The time has come to clarify this issue.


After we no longer need the circuit, freeing up the memory should begin by stopping the data pipeline. To do this, you need to disconnect the clock source, the ticker from the circuit using the ms_ticker_detach () function . In our case, we must disconnect the ticker from the input of the voidsource filter :


ms_ticker_detach(ticker, voidsource)

By the way, after the conveyor stops, we can change its scheme and put it back into operation, again connecting the ticker.


Now we can remove it using the ms_ticker_destroy () function :


ms_ticker_destroy(ticker)

The conveyor is stopped and we can proceed to disassemble it by disconnecting the filters. To do this, use the ms_filter_unlink () function :


ms_filter_unlink(voidsource, 0, dtmfgen, 0);
ms_filter_unlink(dtmfgen, 0, snd_card_write, 0);

the purpose of the arguments is the same as the function ms_filter_link () .


, , c ms_filter_destroy():


ms_filter_destroy(voidsource);
ms_filter_destroy(dtmfgen);
ms_filter_destroy(snd_card_write);

, , .


, , . , . , .


. , , "" . - ?


The developers of the media streamer did not provide software tools to facilitate the manipulation of filters during assembly / disassembly of circuits. Nevertheless, there is a helper that allows you to quickly insert / remove a filter from the circuit.


We will return to solving this issue later, when the number of filters in our examples exceeds a couple of dozen.


In the next article, we will assemble the circuit of the signal level meter and learn how to read the measurement result from the filter. Estimate the accuracy of the measurement.


All Articles