Project

General

Profile

Bug #581

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

Added by Dmitry Vagin about 9 years ago. Updated about 9 years ago.

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

100%

Estimated time:
Affects version:

Description

Infinite loop in oss4 when music on pause.

oss.cc (3.94 KB) oss.cc Dmitry Vagin, October 19, 2015 08:26
oss.h (504 Bytes) oss.h Dmitry Vagin, October 19, 2015 08:26
oss.h (485 Bytes) oss.h Dmitry Vagin, October 19, 2015 21:51
oss.cc (3.94 KB) oss.cc Dmitry Vagin, October 20, 2015 14:52
oss.h (542 Bytes) oss.h Dmitry Vagin, October 20, 2015 14:52

History

#1 Updated by John Lindgren about 9 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 about 9 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 about 9 years ago

Little update for oss.h

#4 Updated by John Lindgren about 9 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 about 9 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 about 9 years ago

fd in nonblock mode

poll(fd);
write(fd);

==

fd in block mode
write(fd)

#7 Updated by Dmitry Vagin about 9 years ago

updated patch with poll().

#8 Updated by John Lindgren about 9 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 about 9 years ago

Dmitry Vagin wrote:

In what situations write_audio() needs to return immediately?

Always.

#10 Updated by Dmitry Vagin about 9 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 about 9 years ago

Look at libaudcore/plugin.h for starters.

#12 Updated by John Lindgren about 9 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