MediaPlayer race condition in audio annunciator
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- java
- Domain
- audio-video-rtc, desktop
Research direction
Start by locating speakAlone and the MediaPlayer::stop and MediaPlayer::play calls mentioned in the issue, then trace how player status changes are handled. Reproduce with a 1-second nag period and a 100ms beep, checking whether play runs before the player reaches STOPPED. Done means repeated short beeps are no longer missed and the playback transition is handled reliably.
Written by the indexing model from the issue text.
Description
I am trying to get the audio annunciator to work with a very short nag period (1 second) and a short clip (100ms) of a beep sound. I have encountered an issue where beeps are frequently missed. I traced this to what appears to be a race condition between MediaPlayer::stop and MediaPlayer::play. In speakAlone, stop is called on every alarm media player, and then play is called on the correct media player. This is all well and good except it would appear that stop does not actually appear to block until the media player status has transitioned to stopped even if the audio clip has finished playing.
Adding a log statement just before play is called e.g.
try {
logger.log(Level.SEVERE, "grioejgoijq " + alarm.getStatus());
alarm.play();
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to play alarm sound", e);
}
does two things: firstly it more or less randomly logs 'PLAYING' or 'STOPPED' indicating the race condition, and secondly it stops beeps from being missed (yes - adding a log statement fixes the bug). I think this is just because there is more time for the player to stop and so by the time it gets to play it has actually been stopped.
I have looked into fixing this but really not sure how to do it in a simple way - ideally I think we'd just block until the status returns to stopped which can be done with completable futures but it feels like there should be an easier solution - so please let me know any thoughts
- Dominant language
- Java
- Stars
- 130
- Forks
- 132
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ControlSystemStudio/phoebus
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ControlSystemStudio/phoebus#3983 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ControlSystemStudio/phoebus#3979 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ControlSystemStudio/phoebus#3962 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ControlSystemStudio/phoebus#3865 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
ControlSystemStudio/phoebus#3980 ·
Maintainers usually reply within 2 days
All issues in ControlSystemStudio/phoebus
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ballerina-platform/static-code-analysis-tool#140 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
atomityhq/blog-cms#82 · 1 comment ·
Maintainers usually reply within 1 day
-
ready-for-triage triaged
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
RedHatInsights/notifications-backend#5080 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eclipse-4diac/4diac-ide#3103 ·
Maintainers usually reply within 1 day