Tidy up turntable events

This commit is contained in:
Correl Roush 2020-09-02 17:00:13 -04:00
parent da4dd3e161
commit 713af582ec

View file

@ -132,6 +132,8 @@ class Turntable(Process):
results[0][dejavu.config.settings.SONG_NAME].decode("utf-8") results[0][dejavu.config.settings.SONG_NAME].decode("utf-8")
) )
) )
else:
self.events_out.put(NewMetadata("Unknown Artist - Unknown Album"))
self.identified = True self.identified = True
elif ( elif (
now - self.last_update >= FINGERPRINT_DELAY + FINGERPRINT_STORE_SECONDS now - self.last_update >= FINGERPRINT_DELAY + FINGERPRINT_STORE_SECONDS
@ -156,7 +158,8 @@ class Turntable(Process):
self.transition(State.idle, now) self.transition(State.idle, now)
def transition(self, to_state: State, updated_at: float) -> None: def transition(self, to_state: State, updated_at: float) -> None:
logger.debug("Transition: %s => %s", self.state, to_state) from_state = self.state
logger.debug("Transition: %s => %s", from_state, to_state)
self.state = to_state self.state = to_state
self.last_update = updated_at self.last_update = updated_at
@ -164,5 +167,5 @@ class Turntable(Process):
self.events_out.put(StoppedPlaying()) self.events_out.put(StoppedPlaying())
self.identified = False self.identified = False
self.captured = False self.captured = False
elif to_state == State.playing: elif from_state == State.idle and to_state == State.playing:
self.events_out.put(StartedPlaying()) self.events_out.put(StartedPlaying())