Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sound_play/scripts/soundplay_node.py] updates states and force stop after play #78

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion sound_play/scripts/soundplay_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, file, volume = 1.0):

def on_stream_end(self, bus, message):
if message.type == gst.MESSAGE_EOS:
self.state = self.STOPPED
self.stop()

def __del__(self):
# stop our GST object so that it gets garbage-collected
Expand Down Expand Up @@ -188,6 +188,14 @@ def stopall(self):
self.stopdict(self.filesounds)
self.stopdict(self.voicesounds)

def update(self):
for sound in self.builtinsounds.values():
sound.update()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanupdict() is already iterating through all of the sounds looking for things that need to be cleaned up; it seems like it would be better to call update there instead of introducing a new code path.

for sound in self.filesounds.values():
sound.update()
for sound in self.voicesounds.values():
sound.update()

def select_sound(self, data):
if data.sound == SoundRequest.PLAY_FILE:
if not data.arg2:
Expand Down Expand Up @@ -437,6 +445,7 @@ def idle_loop(self):
#print "idle_loop"
self.diagnostics(0)
self.sleep(1)
self.update()
self.cleanup()
#print "idle_exiting"

Expand Down