mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
AP_Notify: fixed recursion bug in tone player
This commit is contained in:
parent
56be3788ec
commit
27abff56ea
libraries/AP_Notify
@ -21,7 +21,7 @@ void MMLPlayer::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMLPlayer::play(const char* string)
|
void MMLPlayer::prepare_to_play_string(const char* string)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -36,6 +36,12 @@ void MMLPlayer::play(const char* string)
|
|||||||
_repeat = false;
|
_repeat = false;
|
||||||
|
|
||||||
_playing = true;
|
_playing = true;
|
||||||
|
_note_duration_us = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MMLPlayer::play(const char* string)
|
||||||
|
{
|
||||||
|
prepare_to_play_string(string);
|
||||||
next_action();
|
next_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +139,11 @@ void MMLPlayer::next_action()
|
|||||||
char c = next_char();
|
char c = next_char();
|
||||||
if (c == '\0') {
|
if (c == '\0') {
|
||||||
if (_repeat) {
|
if (_repeat) {
|
||||||
play(_string);
|
// don't "play" here, as we may have been called from
|
||||||
|
// there, and it turns out infinite recursion on
|
||||||
|
// invalid strings is suboptimal. The next call to
|
||||||
|
// update() will push things out as appropriate.
|
||||||
|
prepare_to_play_string(_string);
|
||||||
} else {
|
} else {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,10 @@ public:
|
|||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// initialise ready to play string
|
||||||
|
void prepare_to_play_string(const char* string);
|
||||||
|
|
||||||
bool _playing;
|
bool _playing;
|
||||||
|
|
||||||
uint32_t _note_duration_us;
|
uint32_t _note_duration_us;
|
||||||
|
Loading…
Reference in New Issue
Block a user