Bug 74624 - pa_stream_disconnect() is broken
Summary: pa_stream_disconnect() is broken
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: clients (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
Depends on:
Reported: 2014-02-06 16:08 UTC by Tanu Kaskinen
Modified: 2018-07-30 10:09 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description Tanu Kaskinen 2014-02-06 16:08:46 UTC
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.
Comment 1 GitLab Migration User 2018-07-30 10:09:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.