mpd: ensure emit is called after state changes
This commit is contained in:
@@ -96,19 +96,16 @@ bool Idle::on_io(Glib::IOCondition const&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx_->fetchState();
|
ctx_->fetchState();
|
||||||
|
ctx_->emit();
|
||||||
mpd_state state = ctx_->state();
|
mpd_state state = ctx_->state();
|
||||||
|
|
||||||
if (state == MPD_STATE_STOP) {
|
if (state == MPD_STATE_STOP) {
|
||||||
ctx_->emit();
|
|
||||||
ctx_->setState(std::make_unique<Stopped>(ctx_));
|
ctx_->setState(std::make_unique<Stopped>(ctx_));
|
||||||
} else if (state == MPD_STATE_PLAY) {
|
} else if (state == MPD_STATE_PLAY) {
|
||||||
ctx_->emit();
|
|
||||||
ctx_->setState(std::make_unique<Playing>(ctx_));
|
ctx_->setState(std::make_unique<Playing>(ctx_));
|
||||||
} else if (state == MPD_STATE_PAUSE) {
|
} else if (state == MPD_STATE_PAUSE) {
|
||||||
ctx_->emit();
|
|
||||||
ctx_->setState(std::make_unique<Paused>(ctx_));
|
ctx_->setState(std::make_unique<Paused>(ctx_));
|
||||||
} else {
|
} else {
|
||||||
ctx_->emit();
|
|
||||||
// self transition
|
// self transition
|
||||||
ctx_->setState(std::make_unique<Idle>(ctx_));
|
ctx_->setState(std::make_unique<Idle>(ctx_));
|
||||||
}
|
}
|
||||||
@@ -177,6 +174,7 @@ bool Playing::on_timer() {
|
|||||||
ctx_->fetchState();
|
ctx_->fetchState();
|
||||||
|
|
||||||
if (!ctx_->is_playing()) {
|
if (!ctx_->is_playing()) {
|
||||||
|
ctx_->emit();
|
||||||
if (ctx_->is_paused()) {
|
if (ctx_->is_paused()) {
|
||||||
ctx_->setState(std::make_unique<Paused>(ctx_));
|
ctx_->setState(std::make_unique<Paused>(ctx_));
|
||||||
} else {
|
} else {
|
||||||
@@ -212,6 +210,7 @@ bool Playing::on_io(Glib::IOCondition const&) {
|
|||||||
ctx_->fetchState();
|
ctx_->fetchState();
|
||||||
|
|
||||||
if (!ctx_->is_playing()) {
|
if (!ctx_->is_playing()) {
|
||||||
|
ctx_->emit();
|
||||||
if (ctx_->is_paused()) {
|
if (ctx_->is_paused()) {
|
||||||
ctx_->setState(std::make_unique<Paused>(ctx_));
|
ctx_->setState(std::make_unique<Paused>(ctx_));
|
||||||
} else {
|
} else {
|
||||||
@@ -293,7 +292,6 @@ bool Paused::on_timer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx_->fetchState();
|
ctx_->fetchState();
|
||||||
|
|
||||||
ctx_->emit();
|
ctx_->emit();
|
||||||
|
|
||||||
if (ctx_->is_paused()) {
|
if (ctx_->is_paused()) {
|
||||||
@@ -364,7 +362,6 @@ bool Stopped::on_timer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx_->fetchState();
|
ctx_->fetchState();
|
||||||
|
|
||||||
ctx_->emit();
|
ctx_->emit();
|
||||||
|
|
||||||
if (ctx_->is_stopped()) {
|
if (ctx_->is_stopped()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user