mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-22 08:56:52 -05:00
refactor stream attaching/detaching
Move repetitive code into convenience functions. No changes in behaviour.
This commit is contained in:
parent
d404d8d1ab
commit
f825239887
6 changed files with 112 additions and 63 deletions
|
|
@ -2034,11 +2034,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
|
|||
pa_hashmap_put(o->thread_info.direct_on_input->thread_info.direct_outputs, PA_UINT32_TO_PTR(o->index), o);
|
||||
}
|
||||
|
||||
pa_assert(!o->thread_info.attached);
|
||||
o->thread_info.attached = true;
|
||||
|
||||
if (o->attach)
|
||||
o->attach(o);
|
||||
pa_source_output_attach(o);
|
||||
|
||||
pa_source_output_set_state_within_thread(o, o->state);
|
||||
|
||||
|
|
@ -2062,12 +2058,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
|
|||
|
||||
pa_source_output_set_state_within_thread(o, o->state);
|
||||
|
||||
if (o->thread_info.attached) {
|
||||
o->thread_info.attached = false;
|
||||
|
||||
if (o->detach)
|
||||
o->detach(o);
|
||||
}
|
||||
pa_source_output_detach(o);
|
||||
|
||||
if (o->thread_info.direct_on_input) {
|
||||
pa_hashmap_remove(o->thread_info.direct_on_input->thread_info.direct_outputs, PA_UINT32_TO_PTR(o->index));
|
||||
|
|
@ -2289,14 +2280,8 @@ void pa_source_detach_within_thread(pa_source *s) {
|
|||
pa_source_assert_io_context(s);
|
||||
pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
|
||||
|
||||
PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state) {
|
||||
if (o->thread_info.attached) {
|
||||
o->thread_info.attached = false;
|
||||
|
||||
if (o->detach)
|
||||
o->detach(o);
|
||||
}
|
||||
}
|
||||
PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state)
|
||||
pa_source_output_detach(o);
|
||||
}
|
||||
|
||||
/* Called from IO thread */
|
||||
|
|
@ -2308,13 +2293,8 @@ void pa_source_attach_within_thread(pa_source *s) {
|
|||
pa_source_assert_io_context(s);
|
||||
pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
|
||||
|
||||
PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state) {
|
||||
pa_assert(!o->thread_info.attached);
|
||||
o->thread_info.attached = true;
|
||||
|
||||
if (o->attach)
|
||||
o->attach(o);
|
||||
}
|
||||
PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state)
|
||||
pa_source_output_attach(o);
|
||||
}
|
||||
|
||||
/* Called from IO thread */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue