<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - pa_stream_disconnect() is broken"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=74624">74624</a>
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>lennart@poettering.net
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>pulseaudio-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>pa_stream_disconnect() is broken
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>pulseaudio-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>major
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tanuk@iki.fi
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>clients
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>PulseAudio
          </td>
        </tr></table>
      <p>
        <div>
        <pre>pa_stream_disconnect() doesn't work in all situations. In at least two
situations it's clearly broken:

1) When it's called while the stream state is CREATING, s->channel_valid is
false, which causes the function to return with -PA_ERR_BADSTATE. The stream
creation isn't cancelled, contrary to what would be the expected behaviour.

2) Normally, when an application calls pa_stream_disconnect() while the stream
state is FAILED, the function will return with -PA_ERR_BADSTATE because
s->channel_valid is false. However, when the stream state is just changing to
FAILED, and the application calls pa_stream_disconnect() from the stream state
callback, channel_valid has not yet been set to false, and the function
continues as if everything is fine. This can reportedly result in a crash,
although I haven't investigated this enough to explain the exact cause of the
crash.

pa_stream_disconnect() works asynchronously, which I believe is a bad idea. I
think it would be better if pa_stream_disconnect() would immediately cancel all
in-flight operations, reset the stream object to a safe state, and finally
notify the application that the state changed to TERMINATED.
pa_stream_disconnect() could then become a void function that is safe to call
in all situations, like pa_context_disconnect() is.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>