{"id":87065,"date":"2020-07-03T07:42:01","date_gmt":"2020-07-03T05:42:01","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3"},"modified":"2020-07-03T07:42:01","modified_gmt":"2020-07-03T05:42:01","slug":"izuchaem-voip-dvizhok-mediastreamer2-chast-3","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3","title":{"rendered":"Exploring the VoIP engine Mediastreamer2. Part 3","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>The article material is taken from my <noindex><a rel=\"nofollow\" href=\"https:\/\/zen.yandex.ru\/id\/5e3f8e0751f5346faab4fc7a\">Zen channel<\/a><\/noindex>.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Exploring the VoIP engine Mediastreamer2. Part 3\" src=\"\/wp-content\/uploads\/2020\/07\/7c688fd21de37d61722c681961442e33.png\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h2 id=\"uluchshaem-primer-tonalnogo-generatora\">Improving the tone generator example<\/h2>\n<p><\/p>\n<p>In the previous <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/495728\/\">article<\/a><\/noindex> We wrote a tone generator app that extracts sound from the computer speakers. Now let's focus on the fact that our program, upon completion, does not return memory back to the heap. It's time to clarify this issue.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<p>Once the schema is no longer needed, memory release should begin with stopping the data pipeline. For this, we need to disconnect the clock source from the schema using the function <em>ms_ticker_detach()<\/em>. In our case, we need to disconnect the ticker from the input of the filter <em>voidsource<\/em>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">ms_ticker_detach(ticker, voidsource)<\/code><\/pre>\n<p><\/p>\n<p>By the way, after stopping the pipeline, we can change its schema and restart it, reconnecting the ticker again.<\/p>\n<p><\/p>\n<p>Now we can remove it using the function <em>ms_ticker_destroy()<\/em>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">ms_ticker_destroy(ticker)<\/code><\/pre>\n<p><\/p>\n<p>The pipeline is stopped and we can begin dismantling its parts by unlinking the filters. The function used for this is <em>ms_filter_unlink()<\/em>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">ms_filter_unlink(voidsource, 0, dtmfgen, 0);\nms_filter_unlink(dtmfgen, 0, snd_card_write, 0);<\/code><\/pre>\n<p><\/p>\n<p>The argument assignment is the same as for the function <em>ms_filter_link()<\/em>.<\/p>\n<p><\/p>\n<p>Now we remove the unlinked filters using <em>ms_filter_destroy()<\/em>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">ms_filter_destroy(voidsource);\nms_filter_destroy(dtmfgen);\nms_filter_destroy(snd_card_write);<\/code><\/pre>\n<p><\/p>\n<p>By adding these lines to our example, we will achieve a proper program termination in terms of memory management.<\/p>\n<p><\/p>\n<p>As we can see, properly terminating the program required us to add about the same number of lines of code as at its beginning; on average, we need four lines of code for each filter. This means that the size of the program code will increase proportionally to the number of filters used in the project. If there are a thousand filters in the schema, then your code will expand by four thousand lines of routine operations for their creation and destruction.<\/p>\n<p><\/p>\n<p>Now you know how to properly terminate a program using a media streamer. In the following examples, for the sake of brevity, I will \"forget\" to do this. But you won't forget, right?<\/p>\n<p><\/p>\n<p>The media streamer developers did not provide software tools to facilitate filter manipulation during schema assembly\/disassembly. Nevertheless, there is a helper that allows for quickly inserting\/removing a filter from the schema.<\/p>\n<p><\/p>\n<p>We will return to this issue later, when the number of filters in our examples exceeds a couple dozen.<\/p>\n<p><\/p>\n<p>In the next <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/495982\/\">article<\/a><\/noindex> We will assemble a signal level meter schematic and learn to read the measurement result from the filter. We will evaluate the measurement accuracy.<\/p>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/495780\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442 \u0441 \u043c\u043e\u0435\u0433\u043e \u0434\u0437\u0435\u043d-\u043a\u0430\u043d\u0430\u043b\u0430. \u0423\u043b\u0443\u0447\u0448\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438 \u0437\u0432\u0443\u043a \u0438\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043a\u0443\u0447\u0443. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u043d\u0435\u0441\u0442\u0438 \u044f\u0441\u043d\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u043f\u0440\u043e\u0441. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0445\u0435\u043c\u0430 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":87066,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-87065","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442 \u0441 \u043c\u043e\u0435\u0433\u043e \u0434\u0437\u0435\u043d-\u043a\u0430\u043d\u0430\u043b\u0430.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0418\u0437\u0443\u0447\u0430\u0435\u043c VoIP-\u0434\u0432\u0438\u0436\u043e\u043a Mediastreamer2. \u0427\u0430\u0441\u0442\u044c 3 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442 \u0441 \u043c\u043e\u0435\u0433\u043e \u0434\u0437\u0435\u043d-\u043a\u0430\u043d\u0430\u043b\u0430.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-07-03T05:42:01+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-07-03T05:42:01+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47 Exploring the VoIP engine Mediastreamer2. Part 3 | ProHoster","description":"The content of the article is taken from my Zen channel.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0418\u0437\u0443\u0447\u0430\u0435\u043c VoIP-\u0434\u0432\u0438\u0436\u043e\u043a Mediastreamer2. \u0427\u0430\u0441\u0442\u044c 3 | ProHoster","og:description":"\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442 \u0441 \u043c\u043e\u0435\u0433\u043e \u0434\u0437\u0435\u043d-\u043a\u0430\u043d\u0430\u043b\u0430.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/izuchaem-voip-dvizhok-mediastreamer2-chast-3","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-07-03T05:42:01+00:00","article:modified_time":"2020-07-03T05:42:01+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"87065","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 13:59:55","updated":"2022-10-02 12:50:43","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/87065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=87065"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/87065\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/87066"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=87065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=87065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=87065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}