<p><br>
><br>
> If we know if a certain port is available/unavailable, we can print<br>
> that out, as a help to the user (and as debugging for ourselves).</p>
<p>but the port has three state: yes, no and unknown</p>
<p>> A profile is also available/unavailable if all ports which have that<br>
> profile is available/unavailable.</p>
<p>for surround 5.1, does it meant that pulseaudio have to check the availability of the green, black and orange</p>
<p>many professional sound card does not support jack detection since it produce noise during the detection</p>
<p>spdif jack does not has any jack detection</p>
<p>><br>
> Credit goes to David Henningson for the original idea and some of the code.<br>
> ---<br>
>  src/cardwidget.h  |  1 +<br>
>  src/mainwindow.cc | 66 +++++++++++++++++++++++++++++++++++++++++++------------<br>
>  2 files changed, 53 insertions(+), 14 deletions(-)<br>
><br>
> diff --git a/src/cardwidget.h b/src/cardwidget.h<br>
> index 7c63681..821aae5 100644<br>
> --- a/src/cardwidget.h<br>
> +++ b/src/cardwidget.h<br>
> @@ -31,6 +31,7 @@ public:<br>
>        int available;<br>
>        int direction;<br>
>        int64_t latency_offset;<br>
> +      std::vector<Glib::ustring> profiles;<br>
>  };<br>
><br>
>  class CardWidget : public Gtk::VBox {<br>
> diff --git a/src/mainwindow.cc b/src/mainwindow.cc<br>
> index 1041eab..524d1a7 100644<br>
> --- a/src/mainwindow.cc<br>
> +++ b/src/mainwindow.cc<br>
> @@ -255,6 +255,22 @@ static void set_icon_name_fallback(Gtk::Image *i, const char *name, Gtk::IconSiz<br>
>  static void updatePorts(DeviceWidget *w, std::map<Glib::ustring, PortInfo> &ports) {<br>
>      std::map<Glib::ustring, PortInfo>::iterator it;<br>
><br>
> +    w->ports.clear();<br>
> +    for (it = ports.begin(); it != ports.end(); it++) {<br>
> +        PortInfo p = (*it).second;<br>
> +        Glib::ustring desc = p.description;<br>
> +<br>
> +        if (p.available == PA_PORT_AVAILABLE_YES)<br>
> +            desc += " (plugged in)";<br>
> +        else if (p.available == PA_PORT_AVAILABLE_NO)<br>
> +            desc += " (unplugged)";<br>
> +<br>
> +        if ((typeid(*w) == typeid(SinkWidget)) && (p.direction == PA_DIRECTION_OUTPUT))<br>
> +            w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(<a href="http://p.name">p.name</a>, desc));<br>
> +        else if ((typeid(*w) == typeid(SourceWidget)) && (p.direction == PA_DIRECTION_INPUT))<br>
> +            w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(<a href="http://p.name">p.name</a>, desc));<br>
> +    }<br>
> +<br>
>      it = ports.find(w->activePort);<br>
><br>
>      if (it != ports.end()) {<br>
> @@ -295,12 +311,6 @@ void MainWindow::updateCard(const pa_card_info &info) {<br>
>          profile_priorities.insert(info.profiles[i]);<br>
>      }<br>
><br>
> -    w->profiles.clear();<br>
> -    for (std::set<pa_card_profile_info>::iterator i = profile_priorities.begin(); i != profile_priorities.end(); ++i)<br>
> -        w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description));<br>
> -<br>
> -    w->activeProfile = info.active_profile ? info.active_profile->name : "";<br>
> -<br>
>      w->ports.clear();<br>
>      for (uint32_t i = 0; i < info.n_ports; ++i) {<br>
>          PortInfo p;<br>
> @@ -311,10 +321,46 @@ void MainWindow::updateCard(const pa_card_info &info) {<br>
>          p.available = info.ports[i]->available;<br>
>          p.direction = info.ports[i]->direction;<br>
>          p.latency_offset = info.ports[i]->latency_offset;<br>
> +        for (uint32_t j = 0; j < info.ports[i]->n_profiles; j++)<br>
> +            p.profiles.push_back(info.ports[i]->profiles[j]->name);<br>
><br>
>          w->ports[<a href="http://p.name">p.name</a>] = p;<br>
>      }<br>
><br>
> +    w->profiles.clear();<br>
> +    for (std::set<pa_card_profile_info>::iterator profileIt = profile_priorities.begin(); profileIt != profile_priorities.end(); ++profileIt) {<br>
> +        bool hasYes = false, hasNo = false, hasOther = false;<br>
> +        std::map<Glib::ustring, PortInfo>::iterator portIt;<br>
> +        Glib::ustring desc = profileIt->description;<br>
> +<br>
> +        for (portIt = w->ports.begin(); portIt != w->ports.end(); portIt++) {<br>
> +            PortInfo port = (*portIt).second;<br>
> +<br>
> +            if (std::find(port.profiles.begin(), port.profiles.end(), profileIt->name) == port.profiles.end())<br>
> +                continue;<br>
> +<br>
> +            switch (port.available) {<br>
> +                case PA_PORT_AVAILABLE_YES:<br>
> +                    hasYes = true;<br>
> +                    break;<br>
> +                case PA_PORT_AVAILABLE_NO:<br>
> +                    hasNo = true;<br>
> +                    break;<br>
> +                default:<br>
> +                    hasOther = true;<br>
> +                    break;<br>
> +            }<br>
> +        }<br>
> +        if (hasNo && !hasYes && !hasOther)<br>
> +            desc += " (unplugged)";<br>
> +        else if (hasYes && !hasNo && !hasOther)<br>
> +            desc += " (plugged in)";<br>
> +<br>
> +        w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(profileIt->name, desc));<br>
> +    }<br>
> +<br>
> +    w->activeProfile = info.active_profile ? info.active_profile->name : "";<br>
> +<br>
>      /* Because the port info for sinks and sources is discontinued we need<br>
>       * to update the port info for them here. */<br>
><br>
> @@ -399,10 +445,6 @@ bool MainWindow::updateSink(const pa_sink_info &info) {<br>
>          port_priorities.insert(*info.ports[i]);<br>
>      }<br>
><br>
> -    w->ports.clear();<br>
> -    for (std::set<pa_sink_port_info>::iterator i = port_priorities.begin(); i != port_priorities.end(); ++i)<br>
> -        w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description));<br>
> -<br>
>      w->activePort = info.active_port ? info.active_port->name : "";<br>
><br>
>      cw = cardWidgets.find(info.card);<br>
> @@ -554,10 +596,6 @@ void MainWindow::updateSource(const pa_source_info &info) {<br>
>          port_priorities.insert(*info.ports[i]);<br>
>      }<br>
><br>
> -    w->ports.clear();<br>
> -    for (std::set<pa_source_port_info>::iterator i = port_priorities.begin(); i != port_priorities.end(); ++i)<br>
> -        w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description));<br>
> -<br>
>      w->activePort = info.active_port ? info.active_port->name : "";<br>
><br>
>      cw = cardWidgets.find(info.card);<br>
> --<br>
> 1.8.0<br>
><br>
> _______________________________________________<br>
> pulseaudio-discuss mailing list<br>
> <a href="mailto:pulseaudio-discuss@lists.freedesktop.org">pulseaudio-discuss@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss">http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss</a><br>
</p>