Print a warning when plugin rank cannot be changed

This commit is contained in:
Rafostar
2021-04-25 22:00:00 +02:00
parent a98ca53dfb
commit e92ad68220
2 changed files with 27 additions and 11 deletions

View File

@@ -31,14 +31,23 @@ const ytDebugger = new Debug.Debugger('YouTube', {
high_precision: true,
});
function _debug(msg, debuggerName)
function _logStructured(debuggerName, msg, level)
{
GLib.log_structured(
debuggerName, level, {
MESSAGE: msg,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
});
}
function _debug(debuggerName, msg)
{
if(msg.message) {
GLib.log_structured(
debuggerName, GLib.LogLevelFlags.LEVEL_CRITICAL, {
MESSAGE: msg.message,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
});
_logStructured(
debuggerName,
msg.message,
GLib.LogLevelFlags.LEVEL_CRITICAL
);
return;
}
@@ -55,10 +64,15 @@ function _debug(msg, debuggerName)
function debug(msg)
{
_debug(msg, 'Clapper');
_debug('Clapper', msg);
}
function ytDebug(msg)
{
_debug(msg, 'YouTube');
_debug('YouTube', msg);
}
function warn(msg)
{
_logStructured('Clapper', msg, GLib.LogLevelFlags.LEVEL_WARNING);
}

View File

@@ -6,7 +6,7 @@ const YouTube = imports.src.youtube;
const { PlaylistWidget } = imports.src.playlist;
const { WebApp } = imports.src.webApp;
const { debug } = Debug;
const { debug, warn } = Debug;
const { settings } = Misc;
let WebServer;
@@ -119,8 +119,10 @@ class ClapperPlayer extends GstClapper.Clapper
{
const gstRegistry = Gst.Registry.get();
const feature = gstRegistry.lookup_feature(name);
if(!feature)
return debug(`plugin unavailable: ${name}`);
if(!feature) {
warn(`cannot change rank of unavailable plugin: ${name}`);
return;
}
const oldRank = feature.get_rank();
if(rank === oldRank)