<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - module-switch-on-port-available will only select unavailable ports when a new sink or source appears"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=100451#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - module-switch-on-port-available will only select unavailable ports when a new sink or source appears"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=100451">bug 100451</a>
              from <span class="vcard"><a class="email" href="mailto:klausenbusk@hotmail.com" title="Kristian Klausen <klausenbusk@hotmail.com>"> <span class="fn">Kristian Klausen</span></a>
</span></b>
        <pre>(In reply to Tanu Kaskinen from <a href="show_bug.cgi?id=100451#c1">comment #1</a>)
<span class="quote">> I believe you misunderstood the intention of the code (which is no wonder -
> comments would be very welcome here).

> If the name parameter of new_sink_source() is set, then that means that some
> other module has already chosen the initial port. If so,
> module-switch-on-port-available shouldn't override that, unless the chosen
> port is unavailable.

> The function works correctly as far as I can tell. In the bug title you say
> that the function selects unavailable ports, but to me that seems to be
> possible only if all ports are unavailable.</span >

I'm experiencing what you are describing (PulseAudio selecting as unavailable
port, even through there is a available port), see attachment:
<a href="https://bugs.freedesktop.org/attachment.cgi?id=131228">https://bugs.freedesktop.org/attachment.cgi?id=131228</a> .
As you can see online line 469, it set hdmi-output-0 to no (available: no)
(   0.234|   0.000) D: [pulseaudio] device-port.c: Setting port hdmi-output-0
to status no
On line 477, it set hdmi-output-1 to yes (available: yes)
(   0.234|   0.000) D: [pulseaudio] device-port.c: Setting port hdmi-output-1
to status yes

But even through it know hdmi-output-0 is unavailable and hdmi-output-1 is
available it choose hdmi-output-0. (Line 508)
(   0.252|   0.000) D: [pulseaudio] module-switch-on-port-available.c:
Switching initial port for sink 'alsa_output.pci-0000_00_1f.3.hdmi-stereo' to
'hdmi-output-0'

As I understand the "initial port" logic, it will always choose a unavailable
port? But maybe I'm misunderstanding something.

<a href="https://github.com/pulseaudio/pulseaudio/blob/master/src/modules/module-switch-on-port-available.c#L340">https://github.com/pulseaudio/pulseaudio/blob/master/src/modules/module-switch-on-port-available.c#L340</a>

<span class="quote">> 
> The code seems a bit weird if the only purpose is to prevent other modules
> from selecting unavailable ports, and if that's indeed the only purpose, I
> think it would be better to fix those other modules and not worry about the
> initial port at all in module-switch-on-port-available.

> I don't understand how your change could result in better port choices.
> Details about what ports exist on your system, the availability status of
> the ports, and the choices made before and after your change would be
> helpful.</span ></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>