Merge branch 'master' into wordWrappingEndOfScreenBell
This commit is contained in:
commit
e0906aa05d
Binary file not shown.
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
#!/bin/python
|
||||
|
||||
import time
|
||||
|
||||
from sound.gstreamer import sound
|
||||
|
||||
s = sound()
|
||||
s.playSoundFile('/home/chrys/Projekte/fenrir/fenrir/src/fenrir-package/1ChangeTTY.opus')
|
||||
time.sleep(10)
|
@ -6,8 +6,9 @@
|
||||
|
||||
from core import debug
|
||||
import gi
|
||||
import time
|
||||
from gi.repository import GLib
|
||||
import time, threading
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
try:
|
||||
gi.require_version('Gst', '1.0')
|
||||
@ -23,12 +24,12 @@ class driver:
|
||||
self._source = None
|
||||
self._sink = None
|
||||
self.volume = 1
|
||||
if not _gstreamerAvailable:
|
||||
return
|
||||
def initialize(self, environment):
|
||||
if self._initialized:
|
||||
return
|
||||
global _gstreamerAvailable
|
||||
if not _gstreamerAvailable:
|
||||
self.environment['runtime']['debug'].writeDebugOut('Gstreamer not available',debug.debugLevel.ERROR)
|
||||
return
|
||||
self.env = environment
|
||||
self._player = Gst.ElementFactory.make('playbin', 'player')
|
||||
@ -48,12 +49,14 @@ class driver:
|
||||
self._source.link(self._sink)
|
||||
|
||||
self._initialized = True
|
||||
return
|
||||
self.thread = threading.Thread(target=self.main)
|
||||
self.thread.start()
|
||||
def shutdown(self):
|
||||
global _gstreamerAvailable
|
||||
global _gstreamerAvailable
|
||||
if not _gstreamerAvailable:
|
||||
return
|
||||
self.cancel()
|
||||
Gtk.main_quit()
|
||||
self._initialized = False
|
||||
_gstreamerAvailable = False
|
||||
|
||||
@ -63,27 +66,25 @@ class driver:
|
||||
elif message.type == Gst.MessageType.ERROR:
|
||||
self._player.set_state(Gst.State.NULL)
|
||||
error, info = message.parse_error()
|
||||
print(error, info)
|
||||
print('_onPlayerMessage')
|
||||
self.env['runtime']['debug'].writeDebugOut('GSTREAMER: _onPlayerMessage'+ str(error) + str(info),debug.debugLevel.WARNING)
|
||||
|
||||
def _onPipelineMessage(self, bus, message):
|
||||
if message.type == Gst.MessageType.EOS:
|
||||
self._pipeline.set_state(Gst.State.NULL)
|
||||
elif message.type == Gst.MessageType.ERROR:
|
||||
self._pipeline.set_state(Gst.State.NULL)
|
||||
error, info = message.parse_error()
|
||||
print(error, info)
|
||||
print('_onPipelineMessage')
|
||||
self.env['runtime']['debug'].writeDebugOut('GSTREAMER: _onPipelineMessage'+ str(error) + str(info),debug.debugLevel.WARNING)
|
||||
|
||||
def _onTimeout(self, element):
|
||||
element.set_state(Gst.State.NULL)
|
||||
return False
|
||||
|
||||
def playSoundFile(self, fileName, interrupt=True):
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
self._player.set_property('uri', 'file://%s' % fileName)
|
||||
self._player.set_state(Gst.State.PLAYING)
|
||||
print('playSoundFile')
|
||||
|
||||
def playFrequence(self, frequence, duration, adjustVolume, interrupt=True):
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
@ -93,8 +94,10 @@ class driver:
|
||||
self._pipeline.set_state(Gst.State.PLAYING)
|
||||
duration = int(1000 * tone.duration)
|
||||
GLib.timeout_add(duration, self._onTimeout, self._pipeline)
|
||||
|
||||
def main(self):
|
||||
Gtk.main()
|
||||
def cancel(self, element=None):
|
||||
global _gstreamerAvailable
|
||||
if not _gstreamerAvailable:
|
||||
return
|
||||
if element:
|
||||
|
Loading…
Reference in New Issue
Block a user