<p>I spent some time coming up with a draft-patch that fixes the issues described in the earlier post.</p>
<p>The process was quite straight forward (even though mind numbing), and most modules were fixed with very small patches. Very few required more work, as detailed in the upcoming sections.</p>
<p>I do not want to pollute <code>vlc-devel</code> with another patch-bomb (17 commits) prior to getting some input on patch.</p>
<ul>
<li>What do you guys think?</li>
</ul>
<h2 id="modulesservices_discoveryupnp.cpp"><code>modules/services_discovery/upnp.cpp</code></h2>
<p>The most dramatic change happend in <code>modules/services_discovery/upnp.cpp</code> where we, in order to have functions with the correct linkage, have to move <code>SD::{Open,Close}</code> as well as <code>Access::{Open,Close}</code> from within their respective namespace.</p>
<p>This in turn means that the functions, in order to have proper linkage, had to be renamed to <code>SD_{Open,Close}</code> and <code>Access_{Open,Close}</code> to avoid name-collision in the global scope.</p>
<p>An alternative solution would be to introduce simple wrapper functions with proper linkage, that only calls the affected ones.</p>
<h2 id="modulesdemuxadaptiveplaylistmanager.h"><code>modules/demux/adaptive/PlaylistManager.h</code></h2>
<p><code>demux/adaptive</code> uses <code>static</code> <em>member-functions</em> when supplying <code>libvlc</code> with callbacks. The problem with such approach is that it is impossible to declare such functions with <code>extern "C"</code> on the normal point of declaration (since the standard says that <em>linkage-specifications</em> belong in namespace scope).</p>
<p>In order to circumvent the issue the following approach has been applied:</p>
<pre><code>namespace Foo {
  extern "C" {
    typedef int(*callback_t)(demux_t*);
  }

  class Bar {
    static callback_t baz_cb;
  };
}</code></pre>
<p>In the above <code>Foo::baz_cb</code> will have C linkage, but disregarding that it is directly equivalent to the below:</p>
<pre><code>namespace Foo {
  class Bar {
    static int baz_cb (demux_t*);
  };
}</code></pre>
<hr style="height:1px;margin-bottom:20px;background-color:#ddd;color:#ddd" />
<p>On 16/02/22 13:37, Filip Roséen wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>We currently have an issue with C++ modules not utilizing the proper linkage for the callbacks set when declaring the plugin. Since the given callbacks are invoked from code compiled as C, the callbacks shall have C linkage.</p>
</blockquote>