Bug 40698

Summary: cannot restart mainloop if this was stopped before
Product: PulseAudio Reporter: Art Tevs <tevs>
Component: coreAssignee: pulseaudio-bugs
Status: RESOLVED NOTABUG QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Art Tevs 2011-09-07 14:28:59 UTC
Hi,

following appears to me as a bug and might be a subject for solving/discussing.

The internal state of the mainloop is wrong, after one do restarts it. Following example illustrates it:

// start and stop for the first time
pa_threaded_mainloop_start(m); 
pa_threaded_mainloop_stop(m);  // stop causes m->state = STATE_QUIT

// start and stop for the second time fails, because of an assertion
pa_threaded_mainloop_start(m);

this fails, since this assertion assert(m->state == STATE_PASSIVE) : mainloop.c:827 fires. 

The problem here is that the internal state hasn't been changed back to STATE_PASSIVE, as soon as it was restarted and remains STATE_QUIT, hence assertion fails. A solution might be to change the state accordingly in pa_mainloop_run, i.e.:

int pa_mainloop_run(pa_mainloop *m, int *retval) {
    int r;

    m->state = STATE_PASSIVE; // ADD THIS HERE
    while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0);
...
Comment 1 Arun Raghavan 2012-02-08 23:19:10 UTC
The threaded mainloop is not intended to be started/stopped multiple times. Out of curiosity, though, why would you want to do this?

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.