Bug #581

oss4: fix high CPU usage (infinite loop) on pause.

Added by Dmitry Vagin almost 2 years ago. Updated almost 2 years ago.

Status:Closed Start date:October 19, 2015
Priority:Minor Due date:
Assignee:- % Done:

100%

Category:core
Target version:3.7
Affects version:

Description

Infinite loop in oss4 when music on pause.

oss.cc Magnifier (3.9 kB) Dmitry Vagin, October 19, 2015 08:26

oss.h Magnifier (504 Bytes) Dmitry Vagin, October 19, 2015 08:26

oss.h Magnifier (485 Bytes) Dmitry Vagin, October 19, 2015 21:51

oss.cc Magnifier (3.9 kB) Dmitry Vagin, October 20, 2015 14:52

oss.h Magnifier (542 Bytes) Dmitry Vagin, October 20, 2015 14:52

Associated revisions

Revision 22bd7931
Added by John Lindgren almost 2 years ago

Stop calling write_audio() while paused. Closes: #581.

History

#1 Updated by John Lindgren almost 2 years ago

It would be more helpful if you posted steps to reproduce the problem instead of a huge patch with no explanation of what it does.

#2 Updated by Dmitry Vagin almost 2 years ago

for playing music do loop { write_audio(); period_wait(); }

old code:
period_wait = poll 2 descriptors #1 pipe descriptor #2 /dev/pcm descriptor (all descriptors in nonblock mode),
on normal play = all ok, but on pause poll not wait descriptor #2 always ready for write (infinite loop).

new code:
period_wait check if paused when wait pthread_cond_wait(), and /dev/pcm descriptor in block mode (poll not need).
pipe not need it replace pthread condition.

#3 Updated by Dmitry Vagin almost 2 years ago

Little update for oss.h

#4 Updated by John Lindgren almost 2 years ago

Blocking mode is not an option since write_audio() needs to return immediately. So your patch will not be accepted as-is. Please post steps to reproduce the problem, so that we can work towards a viable solution.

#5 Updated by Dmitry Vagin almost 2 years ago

John Lindgren wrote:

Blocking mode is not an option since write_audio() needs to return immediately. So your patch will not be accepted as-is.

In what situations write_audio() needs to return immediately?

Please post steps to reproduce the problem, so that we can work towards a viable solution.

Pause playing music and problem reproduce.

#6 Updated by Dmitry Vagin almost 2 years ago

fd in nonblock mode

poll(fd);
write(fd);

==

fd in block mode
write(fd)

#7 Updated by Dmitry Vagin almost 2 years ago

updated patch with poll().

#8 Updated by John Lindgren almost 2 years ago

The new patch still breaks drain() because you removed poll_wake(). Read the documentation and stop making changes without understanding what was there before.

#9 Updated by John Lindgren almost 2 years ago

Dmitry Vagin wrote:

In what situations write_audio() needs to return immediately?

Always.

#10 Updated by Dmitry Vagin almost 2 years ago

John Lindgren wrote:

The new patch still breaks drain() because you removed poll_wake(). Read the documentation and stop making changes without understanding what was there before.

which documentation to read?

#11 Updated by John Lindgren almost 2 years ago

Look at libaudcore/plugin.h for starters.

#12 Updated by John Lindgren almost 2 years ago

  • Category set to core
  • Status changed from New to Closed
  • Target version set to 3.7
  • % Done changed from 0 to 100

Actually this can be fixed more cleanly in core.

Also available in: Atom PDF