Prefer PyQt6 QtMultimedia as an audio backend + misc. log/comment/doc corrections
This commit is contained in:
parent
82c0d38a3b
commit
c8a8097673
5 changed files with 50 additions and 31 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,13 +1,17 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
(This document uses YYYY-MM-DD)
|
(This document uses YYYY-MM-DD)
|
||||||
|
|
||||||
## [v2.4.4] - 2022-09-10
|
## [v2.4.4] - 2022-10-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Desync check, verify connection is alive when system time changes by multiple minutes.
|
- Desync check, verify connection is alive when system time changes by multiple minutes.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Made outgoing irc.py functions do an extra check if connection/cli exists.
|
- Made outgoing irc.py functions do an extra check if connection/cli exists.
|
||||||
|
- Slightly less spammy logging.
|
||||||
|
- Qt6.4 introduced a platform-independent FFmpeg backend for QtMultimedia, which is a useful alternative so GStreamer on Linux. As such, the audio backend/module preference and import attempt order is now:
|
||||||
|
- Windows/MacOS: PyQt6 QtMultimedia > PyQt5 QtMultimedia > pygame (used to be PyQt6 QtMultimedia > pygame, PyQt5 QtMultimedia was never imported)
|
||||||
|
- Linux/Unknown: PyQt6 QtMultimedia > pygame > PyQt5 QtMultimedia (used to be pygame > PyQt6 QtMultimedia > PyQt5 QtMultimedia)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- The string for the distraughtfirman smilie being ":distraughtfirman" instead of ":distraughtfirman:".
|
- The string for the distraughtfirman smilie being ":distraughtfirman" instead of ":distraughtfirman:".
|
||||||
|
@ -28,7 +32,7 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
- Error when setting quirk with PyQt5.
|
- Error when setting quirk with PyQt5.
|
||||||
|
|
||||||
### Depreciated
|
### Deprecated
|
||||||
- Disabled the console for now since no one seems to use it and it caused an issue on import.
|
- Disabled the console for now since no one seems to use it and it caused an issue on import.
|
||||||
- Logging.config/configparser logging configuration, not aware of anyone that actually used this. Logging level can still be specified with command line arguments. (-l --logging)
|
- Logging.config/configparser logging configuration, not aware of anyone that actually used this. Logging level can still be specified with command line arguments. (-l --logging)
|
||||||
|
|
||||||
|
@ -63,7 +67,7 @@
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
- Removed the weird metadata support timeout thingy, I think ought to just get the full 005 before we try to get moods.
|
- Removed the weird metadata support timeout thingy, I think ought to just get the full 005 before we try to get moods.
|
||||||
- Replaced instances of socket.error excepts with OSError, since it's depreciated.
|
- Replaced instances of socket.error excepts with OSError, since it's deprecated.
|
||||||
|
|
||||||
## [v2.4] - 2022-06-30
|
## [v2.4] - 2022-06-30
|
||||||
|
|
||||||
|
|
|
@ -282,11 +282,11 @@ class IRCClient:
|
||||||
IndexError,
|
IndexError,
|
||||||
ValueError,
|
ValueError,
|
||||||
Exception) as e:
|
Exception) as e:
|
||||||
PchumLog.warning("Unkown error in conn, " + str(e))
|
PchumLog.debug("Miscellaneous exception in conn, " + str(e))
|
||||||
if tries >= 9:
|
if tries >= 9:
|
||||||
raise e
|
raise e
|
||||||
tries += 1
|
tries += 1
|
||||||
PchumLog.warning("Retrying recv. (attempt %s)" % str(tries))
|
PchumLog.debug("Possibly retrying recv. (attempt %s)" % str(tries))
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
except socket.timeout as e:
|
except socket.timeout as e:
|
||||||
|
|
|
@ -163,7 +163,7 @@ class hyperlink(lexercon.Chunk):
|
||||||
return self.string
|
return self.string
|
||||||
|
|
||||||
class hyperlink_lazy(hyperlink):
|
class hyperlink_lazy(hyperlink):
|
||||||
"""Depreciated since it doesn't seem to turn the full url into a link,
|
"""Deprecated since it doesn't seem to turn the full url into a link,
|
||||||
probably not required anyway, best to require a protocol prefix."""
|
probably not required anyway, best to require a protocol prefix."""
|
||||||
def __init__(self, string):
|
def __init__(self, string):
|
||||||
self.string = "http://" + string
|
self.string = "http://" + string
|
||||||
|
|
|
@ -133,33 +133,48 @@ QString = str
|
||||||
_ARGUMENTS = parser.parse_args()
|
_ARGUMENTS = parser.parse_args()
|
||||||
|
|
||||||
# Import audio module
|
# Import audio module
|
||||||
if ostools.isLinux():
|
# Qt6.4's ffmpeg audio backend makes using QtMultimedia on linux less risky
|
||||||
# QtMultimedia on linux requires GStreamer + a plugin for decoding wave,
|
|
||||||
# so using pygame is prefered.
|
|
||||||
# I think Ubuntu does have this out of the box though.
|
|
||||||
# We could possibly check for the availability of a plugin via the gstreamer python bindings,
|
|
||||||
# but I'm not sure if that'd be worth it, as that'd introduce another dependency.
|
|
||||||
try:
|
|
||||||
import pygame
|
|
||||||
except ImportError:
|
|
||||||
print("Failed to import pygame, falling back to QtMultimedia. "
|
|
||||||
+ "This should also work fine, but for QtMultimedia to work "
|
|
||||||
+ "on Linux you need GStreamer"
|
|
||||||
+ " + a plugin for decoding the wave format.")
|
|
||||||
try:
|
try:
|
||||||
|
# PyQt6, QtMultimedia is prefered.
|
||||||
from PyQt6 import QtMultimedia
|
from PyQt6 import QtMultimedia
|
||||||
|
#print("Audio module is PyQt6 QtMultimedia.")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Failed to import QtMultimedia, no audio module availible.")
|
if ostools.isWin32() or ostools.isOSX():
|
||||||
else:
|
# PyQt5 QtMultimedia has native backends for MacOS and Windows
|
||||||
# On Mac and Windows, QtMultimedia should be prefered.
|
|
||||||
try:
|
try:
|
||||||
from PyQt6 import QtMultimedia
|
from PyQt5 import QtMultimedia
|
||||||
|
print("Using PyQt5 QtMultimedia as sound module. (fallback, PyQt6 QtMultimedia not availible)")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Failed to import QtMultimedia, falling back to pygame.")
|
|
||||||
try:
|
try:
|
||||||
|
try:
|
||||||
|
# Mute pygame support print
|
||||||
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import pygame
|
import pygame
|
||||||
|
print("Using pygame as sound module. (fallback, PyQt6 QtMultimedia and PyQt5 QtMultimedia not availible)")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Failed to import QtMultimedia, no audio module availible.")
|
print("All possible audio modules failed to import."
|
||||||
|
"\nPossible audio modules in order of preference (Windows/MacOS): PyQt6 QtMultimedia > PyQt5 QtMultimedia > pygame")
|
||||||
|
elif ostools.isLinux() or True:
|
||||||
|
# PyQt5 QtMultimedia needs gstreamer on linux, so pygame is prefered.
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
# Mute pygame support print
|
||||||
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
import pygame
|
||||||
|
print("Using pygame as sound module. (fallback, PyQt6 QtMultimedia not availible)")
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
from PyQt5 import QtMultimedia
|
||||||
|
print("Using PyQt5 QtMultimedia as sound module. (fallback, PyQt6 QtMultimedia and pygame not availible)")
|
||||||
|
print("PyQt5 Multimedia will silently fail without GStreamer with relevant"
|
||||||
|
" plugins on Linux, pygame is prefered when using PyQt5.")
|
||||||
|
except ImportError:
|
||||||
|
print("All possible audio modules failed to import."
|
||||||
|
"\nLPossible audio modules in order of preference (Linux/Unknown): PyQt6 QtMultimedia > pygame > PyQt5 QtMultimedia")
|
||||||
|
|
||||||
class waitingMessageHolder(object):
|
class waitingMessageHolder(object):
|
||||||
def __init__(self, mainwindow, **msgfuncs):
|
def __init__(self, mainwindow, **msgfuncs):
|
||||||
|
@ -1449,7 +1464,7 @@ class PesterWindow(MovingWindow):
|
||||||
self.updatemenu.activateWindow()
|
self.updatemenu.activateWindow()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Depreciated
|
Deprecated
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def updatePC(self):
|
def updatePC(self):
|
||||||
|
@ -1497,7 +1512,7 @@ class PesterWindow(MovingWindow):
|
||||||
self.parent.irc.unresponsive = False
|
self.parent.irc.unresponsive = False
|
||||||
if hasattr(self, 'loadingscreen'):
|
if hasattr(self, 'loadingscreen'):
|
||||||
if self.loadingscreen != None:
|
if self.loadingscreen != None:
|
||||||
PchumLog.warning("Server alive !! :O")
|
PchumLog.info("Server alive !! :O")
|
||||||
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
|
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
|
||||||
self.loadingscreen = None
|
self.loadingscreen = None
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ PchumLog = logging.getLogger('pchumLogger')
|
||||||
|
|
||||||
class PythonQuirks(ScriptQuirks):
|
class PythonQuirks(ScriptQuirks):
|
||||||
def loadModule(self, name, filename):
|
def loadModule(self, name, filename):
|
||||||
# imp is depreciated since Python 3.4
|
# imp is deprecated since Python 3.4
|
||||||
#return imp.load_source(name, filename)
|
#return imp.load_source(name, filename)
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location(name, filename)
|
spec = importlib.util.spec_from_file_location(name, filename)
|
||||||
|
|
Loading…
Reference in a new issue