Hopefully fixed weird gstreamer traceback.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2026 Stormux
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
|
||||
"""Compatibility helpers for GStreamer GI bindings."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def gst_init_check_available(gst: Any) -> bool:
|
||||
"""Return Gst.init_check(None) availability across GI variants."""
|
||||
|
||||
initCheckResult = gst.init_check(None)
|
||||
if isinstance(initCheckResult, tuple):
|
||||
return bool(initCheckResult[0])
|
||||
|
||||
return bool(initCheckResult)
|
||||
@@ -48,6 +48,7 @@ cthulhu_python_sources = files([
|
||||
'formatting.py',
|
||||
'focus_manager.py',
|
||||
'generator.py',
|
||||
'gstreamer_support.py',
|
||||
'guilabels.py',
|
||||
'highlighter.py',
|
||||
'input_event.py',
|
||||
|
||||
@@ -31,6 +31,9 @@ import threading
|
||||
|
||||
import gi
|
||||
from gi.repository import GLib
|
||||
from . import debug
|
||||
from . import gstreamer_support
|
||||
from . import sound_sink
|
||||
|
||||
try:
|
||||
gi.require_version('Gst', '1.0')
|
||||
@@ -38,10 +41,7 @@ try:
|
||||
except Exception:
|
||||
_gstreamerAvailable = False
|
||||
else:
|
||||
_gstreamerAvailable, args = Gst.init_check(None)
|
||||
|
||||
from . import debug
|
||||
from . import sound_sink
|
||||
_gstreamerAvailable = gstreamer_support.gst_init_check_available(Gst)
|
||||
|
||||
|
||||
class PiperAudioPlayer:
|
||||
|
||||
@@ -39,6 +39,11 @@ import threading
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
import gi
|
||||
from . import debug
|
||||
from . import gstreamer_support
|
||||
from . import settings
|
||||
from . import sound_sink
|
||||
from .sound_generator import Icon, Tone
|
||||
|
||||
try:
|
||||
gi.require_version('Gst', '1.0')
|
||||
@@ -46,12 +51,7 @@ try:
|
||||
except Exception:
|
||||
_gstreamerAvailable: bool = False
|
||||
else:
|
||||
_gstreamerAvailable, _args = Gst.init_check(None)
|
||||
|
||||
from . import debug
|
||||
from . import settings
|
||||
from . import sound_sink
|
||||
from .sound_generator import Icon, Tone
|
||||
_gstreamerAvailable = gstreamer_support.gst_init_check_available(Gst)
|
||||
|
||||
_soundSystemFailureReason: Optional[str] = None
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ gi.require_version('GLib', '2.0')
|
||||
gi.require_version('Gst', '1.0')
|
||||
from gi.repository import GLib, Gst
|
||||
|
||||
from . import gstreamer_support
|
||||
from . import settings
|
||||
from . import sound_sink
|
||||
|
||||
@@ -75,7 +76,7 @@ class SoundWorker:
|
||||
"""Runs a long-lived GStreamer worker for icon and tone playback."""
|
||||
|
||||
def __init__(self, soundSink: Optional[str] = None) -> None:
|
||||
available, _args = Gst.init_check(None)
|
||||
available = gstreamer_support.gst_init_check_available(Gst)
|
||||
if not available:
|
||||
raise RuntimeError("GStreamer is not available")
|
||||
|
||||
@@ -371,7 +372,7 @@ def play_file_once(
|
||||
soundSink: Optional[str] = None,
|
||||
volume: float = 1.0,
|
||||
) -> int:
|
||||
available, _args = Gst.init_check(None)
|
||||
available = gstreamer_support.gst_init_check_available(Gst)
|
||||
if not available:
|
||||
print("GStreamer is not available", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
@@ -19,6 +19,8 @@ from __future__ import annotations
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
import gi
|
||||
from . import gstreamer_support
|
||||
from . import settings
|
||||
|
||||
try:
|
||||
gi.require_version('Gst', '1.0')
|
||||
@@ -26,9 +28,7 @@ try:
|
||||
except Exception:
|
||||
_gstreamerAvailable: bool = False
|
||||
else:
|
||||
_gstreamerAvailable, _args = Gst.init_check(None)
|
||||
|
||||
from . import settings
|
||||
_gstreamerAvailable = gstreamer_support.gst_init_check_available(Gst)
|
||||
|
||||
_SINK_ELEMENT_BY_SETTING = {
|
||||
settings.SOUND_SINK_PIPEWIRE: "pipewiresink",
|
||||
|
||||
Reference in New Issue
Block a user