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

Fix timer #275

Merged
merged 3 commits into from Oct 27, 2020
Merged

Fix timer #275

merged 3 commits into from Oct 27, 2020

Conversation

eginhard
Copy link

Description

These changes fix various warnings and errors that occurred when using the timer and prevented it from ringing.

How Has This Been Tested?

I confirmed that the warnings disappeared and the timer can now ring, using both gstreamer or pyglet if that is available.

There is a threading issue when using pyglet and closing Gourmet after the timer has gone off, but I don't know how to solve that for now.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@cydanil cydanil left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to work on this!
I think that you can mitigate the threading issue with the following:

Class Player:
    def __init__(self):
        Gst.init()
        self.player = Gst.ElementFactory.make('playbin', 'player')
        self.player.connect('about-to-finish', self.stop_play)

     def stop_play(self):
           self.player.set_state(Gst.State.NULL)

Would you mind testing that?

Also, could you clean the imports such that it's

from gi.repository import Gst

and add to gourmet/__init__.py

require_version("Gst", "1.0")

gourmet/sound_gst.py Outdated Show resolved Hide resolved
self.player.set_state(Gst.State.PLAYING)

def stop_play (self,path):
def stop_play(self,path):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def stop_play(self,path):
def stop_play(self):

Copy link
Author

Choose a reason for hiding this comment

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

I removed the stop_play methods as they are not used.

requirements.txt Outdated Show resolved Hide resolved
@eginhard
Copy link
Author

Thanks, I made those changes. With sound_gst.py (when pyglet is not available) there are no issues, it's from sound_pyglet.py. After pyglet has played the timer (the sound also seems cut off compared to gst) and I want to close Gourmet, a dialog with "Another process is in progress - Exit program anyway?" appears and selecting "Quit" logs the following:

DEBUG: gourmet/gourmet/GourmetRecipeManager.py: 466 Unable to terminate thread <GLibMainLoopThread(Thread-1, started daemon 140028434503424)>

Are all the different ways to play sound actually necessary (there's also sound_windows.py) or is there something that works well across platforms?

gourmet/__init__.py Outdated Show resolved Hide resolved
@cydanil
Copy link
Collaborator

cydanil commented Oct 27, 2020

I think only Gst should be used: the historical reason for having different players was that back in the days, sound handling was not that well integrated between user applications and the OS.

Indeed, you could remove the other sound handlers.

@eginhard
Copy link
Author

Great, that simplified things.

Copy link
Collaborator

@cydanil cydanil left a comment

Choose a reason for hiding this comment

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

Cracking, thanks a lot!

@cydanil cydanil merged commit 7bb7cc8 into kirienko:master Oct 27, 2020
@eginhard eginhard deleted the fix-timer branch October 27, 2020 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants