mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
fix a call to pa_sink_suspend() from an incorrect thread
The alsa sink calls pa_sink_suspend() from the set_port() callback. pa_sink_suspend() can only be called from the main thread, but the set_port() callback was often called from the IO thread. That caused an assertion to be hit in pa_sink_suspend() when switching ports. Another issue was that pa_sink_suspend() called the set_port() callback, and if the callback calls pa_sink_suspend() again recursively, nothing good can be expected from that, so the thread mismatch was not the only problem. This patch moves the mixer syncing logic out of pa_sink/source_suspend() to be handled internally by the alsa sink/source. This removes the recursive pa_sink_suspend() call. This also removes the need to have the mixer_dirty flag in pa_sink/source, so the flag and the pa_sink/source_set_mixer_dirty() functions can be removed. This patch also changes the threading rules of set_port(). Previously it was called sometimes from the main thread and sometimes from the IO thread. Now it's always called from the main thread. When deferred volumes are used, the alsa sink and source still have to update the mixer from the IO thread when switching ports, but the thread synchronization is now handled internally by the alsa sink and source. The SET_PORT messages are not needed any more and can be removed. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=104761
This commit is contained in:
parent
ad0616d4c9
commit
ad15e6e50e
6 changed files with 156 additions and 150 deletions
|
|
@ -116,7 +116,6 @@ struct pa_source {
|
|||
|
||||
pa_hashmap *ports;
|
||||
pa_device_port *active_port;
|
||||
pa_atomic_t mixer_dirty;
|
||||
|
||||
/* The latency offset is inherited from the currently active port */
|
||||
int64_t port_latency_offset;
|
||||
|
|
@ -215,8 +214,8 @@ struct pa_source {
|
|||
* thread context. */
|
||||
pa_source_cb_t update_requested_latency; /* may be NULL */
|
||||
|
||||
/* Called whenever the port shall be changed. Called from IO
|
||||
* thread if deferred volumes are enabled, and main thread otherwise. */
|
||||
/* Called whenever the port shall be changed. Called from the main
|
||||
* thread. */
|
||||
int (*set_port)(pa_source *s, pa_device_port *port); /*ditto */
|
||||
|
||||
/* Called to get the list of formats supported by the source, sorted
|
||||
|
|
@ -294,7 +293,6 @@ typedef enum pa_source_message {
|
|||
PA_SOURCE_MESSAGE_GET_FIXED_LATENCY,
|
||||
PA_SOURCE_MESSAGE_GET_MAX_REWIND,
|
||||
PA_SOURCE_MESSAGE_SET_MAX_REWIND,
|
||||
PA_SOURCE_MESSAGE_SET_PORT,
|
||||
PA_SOURCE_MESSAGE_UPDATE_VOLUME_AND_MUTE,
|
||||
PA_SOURCE_MESSAGE_SET_PORT_LATENCY_OFFSET,
|
||||
PA_SOURCE_MESSAGE_MAX
|
||||
|
|
@ -415,7 +413,6 @@ bool pa_source_get_mute(pa_source *source, bool force_refresh);
|
|||
bool pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p);
|
||||
|
||||
int pa_source_set_port(pa_source *s, const char *name, bool save);
|
||||
void pa_source_set_mixer_dirty(pa_source *s, bool is_dirty);
|
||||
|
||||
int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, bool passthrough);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue