Skip to content

Commit

Permalink
Add framework for managing Plexamp as a renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
moodeaudio committed Jun 3, 2024
1 parent 86add4b commit b03ac74
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 115 deletions.
8 changes: 4 additions & 4 deletions usr/local/bin/moodeutl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $features = array(
FEAT_UPNPSYNC => 'UPnP volume sync',
FEAT_SPOTIFY => 'Spotify Connect renderer',
FEAT_GPIO => 'GPIO button handler',
FEAT_RESERVED => 'Reserved for future use',
FEAT_PLEXAMP => 'Plexamp renderer',
FEAT_BLUETOOTH => 'Bluetooth renderer',
FEAT_DEVTWEAKS => 'Developer tweaks',
FEAT_MULTIROOM => 'Multiroom audio'
Expand Down Expand Up @@ -170,7 +170,7 @@ With no OPTION print the help text and exit.
-o\t\tList audio overlays
-q\t\tQuery sql database
-r\t\tRestart servers
-R\t\tRestart renderer [--bluetooth | --airplay | --spotify | --squeezelite | --roonbridge]
-R\t\tRestart renderer [--bluetooth | --airplay | --spotify | --squeezelite | --plexamp | --roonbridge]
-t\t\tPrint last 10 lines of moode log and wait
-u\t\tCheck radio station urls for playability
-U\t\tCheck station urls, list only unplayable
Expand Down Expand Up @@ -404,7 +404,7 @@ function restartServers() {

function restartRenderer($argv) {
$renderers = array('--bluetooth' => 'btsvc', '--airplay' => 'airplaysvc', '--spotify' => 'spotifysvc',
'--squeezelite' => 'slsvc', '--roonbridge' => 'rbsvc');
'--squeezelite' => 'slsvc', '--plexamp' => 'pasvc', '--roonbridge' => 'rbsvc');

if (!isset($argv[2])) {
echo 'Missing 2nd argument [renderer name]' . "\n";
Expand All @@ -420,7 +420,7 @@ function restartRenderer($argv) {
}
else {
echo 'Invalid renderer name' . "\n";
echo 'Valid names are: --bluetooth, --airplay, --spotify, --squeezelite, --roonbridge' . "\n";
echo 'Valid names are: --bluetooth, --airplay, --spotify, --squeezelite, --plexamp, --roonbridge' . "\n";
return;
}

Expand Down
6 changes: 3 additions & 3 deletions var/local/www/db/moode-sqlite3.db.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- File generated with SQLiteStudio v3.1.0 on Sat May 25 14:17:33 2024
-- File generated with SQLiteStudio v3.1.0 on Mon Jun 3 18:16:08 2024
--
-- Text encoding used: UTF-8
--
Expand Down Expand Up @@ -397,7 +397,7 @@ INSERT INTO cfg_system (id, param, value) VALUES (60, 'toggle_songid', '');
INSERT INTO cfg_system (id, param, value) VALUES (61, 'slsvc', '0');
INSERT INTO cfg_system (id, param, value) VALUES (62, 'ap_network_addr', '172.24.1.1/24');
INSERT INTO cfg_system (id, param, value) VALUES (63, 'cpugov', 'ondemand');
INSERT INTO cfg_system (id, param, value) VALUES (64, 'RESERVED_64', '');
INSERT INTO cfg_system (id, param, value) VALUES (64, 'pasvc', '0');
INSERT INTO cfg_system (id, param, value) VALUES (65, 'pkgid_suffix', '');
INSERT INTO cfg_system (id, param, value) VALUES (66, 'lib_pos', '-1,-1,-1');
INSERT INTO cfg_system (id, param, value) VALUES (67, 'mpdcrossfade', '0');
Expand Down Expand Up @@ -448,7 +448,7 @@ INSERT INTO cfg_system (id, param, value) VALUES (111, 'cover_scale', '1.25');
INSERT INTO cfg_system (id, param, value) VALUES (112, 'rsmafterrb', 'No');
INSERT INTO cfg_system (id, param, value) VALUES (113, 'library_tagview_artist', 'Artist');
INSERT INTO cfg_system (id, param, value) VALUES (114, 'scnsaver_style', 'Gradient (Linear)');
INSERT INTO cfg_system (id, param, value) VALUES (115, 'RESERVED_115', '');
INSERT INTO cfg_system (id, param, value) VALUES (115, 'rsmafterpa', 'No');
INSERT INTO cfg_system (id, param, value) VALUES (116, 'mpd_httpd', '0');
INSERT INTO cfg_system (id, param, value) VALUES (117, 'mpd_httpd_port', '8000');
INSERT INTO cfg_system (id, param, value) VALUES (118, 'mpd_httpd_encoder', 'lame');
Expand Down
9 changes: 9 additions & 0 deletions www/daemon/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@
workerLog('worker: -- Special configs');
workerLog('worker: --');
//----------------------------------------------------------------------------//
// Plexamp: TBD
if (file_exists('somefile') === true) {
$_SESSION['plexamp_installed'] = 'yes';
} else {
$_SESSION['plexamp_installed'] = 'no';
$msg = 'not installed';
}
workerLog('worker: Plexamp: ' . $msg);

// RoonBridge
// Their installer sets the systemd unit to enabled but we need it disabled because we start/stop it via System Config setting
if (file_exists('/opt/RoonBridge/start.sh') === true) {
Expand Down
11 changes: 6 additions & 5 deletions www/inc/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@
const NOTIFY_DURATION_MEDIUM = 10;
const NOTIFY_DURATION_LONG = 30;
const NOTIFY_DURATION_INFINITE = 8640000; // 100 days
// Component names
// Component names (for notification messages)
const NAME_AIRPLAY = 'AirPlay';
const NAME_BLUETOOTH = 'Bluetooth Controller';
const NAME_BLUETOOTH_PAIRING_AGENT = 'Pairing Agent';
const NAME_SPOTIFY = 'Spotify Connect';
const NAME_SQUEEZELITE = 'Squeezelite';
const NAME_ROONBRIDGE = 'RoonBridge';
const NAME_UPNP = 'UPnP';
const NAME_DLNA = 'DLNA';
const NAME_PLEXAMP = 'Plexamp';
const NAME_ROONBRIDGE = 'RoonBridge';
const NAME_GPIO = 'GPIO Controller';
const NAME_LOCAL_DISPLAY = 'Local Display';

Expand Down Expand Up @@ -117,8 +118,8 @@

// Features availability bitmask
// NOTE: Updates must also be made to matching code blocks in playerlib.js, sysinfo.sh, moodeutl, and footer.php
// sqlite3 /var/local/www/db/moode-sqlite3.db "SELECT value FROM cfg_system WHERE param='feat_bitmask'"
// sqlite3 /var/local/www/db/moode-sqlite3.db "UPDATE cfg_system SET value='97206' WHERE param='feat_bitmask'"
// moodeutl -q "SELECT value FROM cfg_system WHERE param='feat_bitmask'"
// moodeutl -q "UPDATE cfg_system SET value='97207' WHERE param='feat_bitmask'"
const FEAT_HTTPS = 1; // y HTTPS mode
const FEAT_AIRPLAY = 2; // y AirPlay renderer
const FEAT_MINIDLNA = 4; // y DLNA server
Expand All @@ -132,7 +133,7 @@
const FEAT_UPNPSYNC = 1024; // UPnP volume sync
const FEAT_SPOTIFY = 2048; // y Spotify Connect renderer
const FEAT_GPIO = 4096; // y GPIO button handler
const FEAT_RESERVED = 8192; // y Reserved for future use
const FEAT_PLEXAMP = 8192; // y Plexamp renderer
const FEAT_BLUETOOTH = 16384; // y Bluetooth renderer
const FEAT_DEVTWEAKS = 32768; // Developer tweaks
const FEAT_MULTIROOM = 65536; // y Multiroom audio
Expand Down
33 changes: 24 additions & 9 deletions www/inc/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function stopBluetooth() {
sysCmd('killall -s 9 bluealsa-aplay');
}

// AirPlay
function startAirPlay() {
sysCmd('systemctl start nqptp');

Expand All @@ -63,7 +64,6 @@ function startAirPlay() {
debugLog('startAirPlay(): (' . $cmd . ')');
sysCmd($cmd);
}

function stopAirPlay() {
$maxRetries = 3;
for ($i = 0; $i < $maxRetries; $i++) {
Expand Down Expand Up @@ -93,6 +93,7 @@ function stopAirPlay() {
sendFECmd('aplactive0');
}

// Spotify Connect
function startSpotify() {
$result = sqlRead('cfg_spotify', sqlConnect());
$cfgSpotify = array();
Expand Down Expand Up @@ -146,7 +147,6 @@ function startSpotify() {
debugLog('startSpotify(): (' . $cmd . ')');
sysCmd($cmd);
}

function stopSpotify() {
sysCmd('killall librespot');

Expand All @@ -165,6 +165,7 @@ function stopSpotify() {
sendFECmd('spotactive0');
}

// Squeezelite
function startSqueezeLite() {
sysCmd('mpc stop');

Expand All @@ -174,7 +175,6 @@ function startSqueezeLite() {

sysCmd('systemctl start squeezelite');
}

function stopSqueezeLite() {
sysCmd('systemctl stop squeezelite');

Expand All @@ -187,7 +187,6 @@ function stopSqueezeLite() {
$GLOBALS['slactive'] = '0';
sendFECmd('slactive0');
}

function cfgSqueezelite() {
$result = sqlRead('cfg_sl', sqlConnect());

Expand All @@ -200,19 +199,35 @@ function cfgSqueezelite() {
fclose($fh);
}

// UPnP
function startUPnP() {
sysCmd('systemctl start upmpdcli');
}

// Plexamp
function startPlexamp() {
sysCmd('mpc stop');
sysCmd('systemctl start nodejs');
sysCmd('systemctl start plexamp');
}
function stopPlexamp() {
sysCmd('systemctl stop plexamp');
sysCmd('systemctl stop nodejs');
sysCmd('/var/www/util/vol.sh -restore');
phpSession('write', 'paactive', '0');
$GLOBALS['paactive'] = '0';
sendFECmd('paactive0');
}

// RoonBridge
function startRoonBridge() {
sysCmd('mpc stop');
sysCmd('systemctl start roonbridge');
}

function stopRoonBridge() {
sysCmd('systemctl stop roonbridge');
sysCmd('/var/www/util/vol.sh -restore');
phpSession('write', 'rbactive', '0');
$GLOBALS['rbactive'] = '0';
sendFECmd('rbactive0');
}

function startUPnP() {
sysCmd('systemctl start upmpdcli');
}
2 changes: 1 addition & 1 deletion www/js/playerlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const FEAT_INPSOURCE = 512; // y Input source select
const FEAT_UPNPSYNC = 1024; // UPnP volume sync
const FEAT_SPOTIFY = 2048; // y Spotify Connect renderer
const FEAT_GPIO = 4096; // y GPIO button handler
const FEAT_RESERVED = 8192; // y Reserved for future use
const FEAT_PLEXAMP = 8192; // y Plexamp renderer
const FEAT_BLUETOOTH = 16384; // y Bluetooth renderer
const FEAT_DEVTWEAKS = 32768; // Developer tweaks
const FEAT_MULTIROOM = 65536; // y Multiroom audio
Expand Down
90 changes: 61 additions & 29 deletions www/ren-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,6 @@
submitJob('slrestart', '', NOTIFY_TITLE_INFO, NAME_SQUEEZELITE . NOTIFY_MSG_SVC_MANUAL_RESTART);
}

// RoonBridge
if (isset($_POST['update_rb_settings'])) {
if (isset($_POST['rbsvc']) && $_POST['rbsvc'] != $_SESSION['rbsvc']) {
$update = true;
phpSession('write', 'rbsvc', $_POST['rbsvc']);
}
if (isset($update)) {
submitJob('rbsvc');
}
}
if (isset($_POST['update_rsmafterrb'])) {
phpSession('write', 'rsmafterrb', $_POST['rsmafterrb']);
}
if (isset($_POST['rbrestart']) && $_POST['rbrestart'] == 1) {
submitJob('rbrestart', '', NOTIFY_TITLE_INFO, NAME_ROONBRIDGE . NOTIFY_MSG_SVC_MANUAL_RESTART);
}

// UPnP client for MPD
if (isset($_POST['update_upnp_settings'])) {
$currentUpnpName = $_SESSION['upnpname'];
Expand All @@ -157,6 +140,40 @@
submitJob('upnpsvc', '', NOTIFY_TITLE_INFO, NAME_UPNP . NOTIFY_MSG_SVC_MANUAL_RESTART);
}

// Plexamp
if (isset($_POST['update_pa_settings'])) {
if (isset($_POST['pasvc']) && $_POST['pasvc'] != $_SESSION['pasvc']) {
$update = true;
phpSession('write', 'pasvc', $_POST['pasvc']);
}
if (isset($update)) {
submitJob('pasvc');
}
}
if (isset($_POST['update_rsmafterpa'])) {
phpSession('write', 'rsmafterpa', $_POST['rsmafterpa']);
}
if (isset($_POST['parestart']) && $_POST['parestart'] == 1) {
submitJob('parestart', '', NOTIFY_TITLE_INFO, NAME_ROONBRIDGE . NOTIFY_MSG_SVC_MANUAL_RESTART);
}

// RoonBridge
if (isset($_POST['update_rb_settings'])) {
if (isset($_POST['rbsvc']) && $_POST['rbsvc'] != $_SESSION['rbsvc']) {
$update = true;
phpSession('write', 'rbsvc', $_POST['rbsvc']);
}
if (isset($update)) {
submitJob('rbsvc');
}
}
if (isset($_POST['update_rsmafterrb'])) {
phpSession('write', 'rsmafterrb', $_POST['rsmafterrb']);
}
if (isset($_POST['rbrestart']) && $_POST['rbrestart'] == 1) {
submitJob('rbrestart', '', NOTIFY_TITLE_INFO, NAME_ROONBRIDGE . NOTIFY_MSG_SVC_MANUAL_RESTART);
}

phpSession('close');

// Bluetooth
Expand Down Expand Up @@ -219,8 +236,34 @@
$_select['rsmaftersl_on'] .= "<input type=\"radio\" name=\"rsmaftersl\" id=\"toggle-rsmaftersl-1\" value=\"Yes\" " . (($_SESSION['rsmaftersl'] == 'Yes') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['rsmaftersl_off'] .= "<input type=\"radio\" name=\"rsmaftersl\" id=\"toggle-rsmaftersl-2\" value=\"No\" " . (($_SESSION['rsmaftersl'] == 'No') ? "checked=\"checked\"" : "") . $autoClick . ">\n";

// UPnP client for MPD
$_feat_upmpdcli = $_SESSION['feat_bitmask'] & FEAT_UPMPDCLI ? '' : 'hide';
$_SESSION['upnpsvc'] == '1' ? $_upnp_btn_disable = '' : $_upnp_btn_disable = 'disabled';
$_SESSION['upnpsvc'] == '1' ? $_upnp_link_disable = '' : $_upnp_link_disable = 'onclick="return false;"';
$_SESSION['dlnasvc'] == '1' ? $_dlna_btn_disable = '' : $_dlna_btn_disable = 'disabled';
$_SESSION['dlnasvc'] == '1' ? $_dlna_link_disable = '' : $_dlna_link_disable = 'onclick="return false;"';
$autoClick = " onchange=\"autoClick('#btn-set-upnpsvc');\"";
$_select['upnpsvc_on'] .= "<input type=\"radio\" name=\"upnpsvc\" id=\"toggle-upnpsvc-1\" value=\"1\" " . (($_SESSION['upnpsvc'] == '1') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['upnpsvc_off'] .= "<input type=\"radio\" name=\"upnpsvc\" id=\"toggle-upnpsvc-2\" value=\"0\" " . (($_SESSION['upnpsvc'] == '0') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['upnpname'] = $_SESSION['upnpname'];

// Plexamp
if (($_SESSION['feat_bitmask'] & FEAT_PLEXAMP)) {
$_feat_plexamp = '';
$_SESSION['plexamp_installed'] == 'yes' ? $_pa_svcbtn_disable = '' : $_pa_svcbtn_disable = 'disabled';
$_SESSION['pasvc'] == '1' ? $_pa_btn_disable = '' : $_pa_btn_disable = 'disabled';
$_SESSION['pasvc'] == '1' ? $_pa_link_disable = '' : $_pa_link_disable = 'onclick="return false;"';
$autoClick = " onchange=\"autoClick('#btn-set-pasvc');\" " . $_pa_svcbtn_disable;
$_select['pasvc_on'] .= "<input type=\"radio\" name=\"pasvc\" id=\"toggle-pasvc-1\" value=\"1\" " . (($_SESSION['pasvc'] == '1') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['pasvc_off'] .= "<input type=\"radio\" name=\"pasvc\" id=\"toggle-pasvc-2\" value=\"0\" " . (($_SESSION['pasvc'] == '0') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$autoClick = " onchange=\"autoClick('#btn-set-rsmafterpa');\" " . $_pa_btn_disable;
$_select['rsmafterpa_on'] .= "<input type=\"radio\" name=\"rsmafterpa\" id=\"toggle-rsmafterpa-1\" value=\"Yes\" " . (($_SESSION['rsmafterpa'] == 'Yes') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['rsmafterpa_off'] .= "<input type=\"radio\" name=\"rsmafterpa\" id=\"toggle-rsmafterpa-2\" value=\"No\" " . (($_SESSION['rsmafterpa'] == 'No') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
} else {
$_feat_plexamp = 'hide';
}

// RoonBridge
//DELETE:if (($_SESSION['feat_bitmask'] & FEAT_ROONBRIDGE) && $_SESSION['roonbridge_installed'] == 'yes') {
if (($_SESSION['feat_bitmask'] & FEAT_ROONBRIDGE)) {
$_feat_roonbridge = '';
$_SESSION['roonbridge_installed'] == 'yes' ? $_rb_svcbtn_disable = '' : $_rb_svcbtn_disable = 'disabled';
Expand All @@ -236,17 +279,6 @@
$_feat_roonbridge = 'hide';
}

// UPnP client for MPD
$_feat_upmpdcli = $_SESSION['feat_bitmask'] & FEAT_UPMPDCLI ? '' : 'hide';
$_SESSION['upnpsvc'] == '1' ? $_upnp_btn_disable = '' : $_upnp_btn_disable = 'disabled';
$_SESSION['upnpsvc'] == '1' ? $_upnp_link_disable = '' : $_upnp_link_disable = 'onclick="return false;"';
$_SESSION['dlnasvc'] == '1' ? $_dlna_btn_disable = '' : $_dlna_btn_disable = 'disabled';
$_SESSION['dlnasvc'] == '1' ? $_dlna_link_disable = '' : $_dlna_link_disable = 'onclick="return false;"';
$autoClick = " onchange=\"autoClick('#btn-set-upnpsvc');\"";
$_select['upnpsvc_on'] .= "<input type=\"radio\" name=\"upnpsvc\" id=\"toggle-upnpsvc-1\" value=\"1\" " . (($_SESSION['upnpsvc'] == '1') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['upnpsvc_off'] .= "<input type=\"radio\" name=\"upnpsvc\" id=\"toggle-upnpsvc-2\" value=\"0\" " . (($_SESSION['upnpsvc'] == '0') ? "checked=\"checked\"" : "") . $autoClick . ">\n";
$_select['upnpname'] = $_SESSION['upnpname'];

waitWorker('ren-config');

$tpl = "ren-config.html";
Expand Down
11 changes: 6 additions & 5 deletions www/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,12 @@ To run it type /var/www/util/coverview.php -on | -off
restart-renderer.php
This command restarts the specified renderer.
To run it type /var/www/util/restart-renderer.php --renderer
--bluetooth Restart bluetooth
--airplay Restart airplay
--spotify Restart spotify
--squeezelite Restart squeezelite
--roonbridge Restart roonbridge
--bluetooth Restart Bluetooth
--airplay Restart AirPlay
--spotify Restart Spotify Connect
--squeezelite Restart Squeezelite
--plexamp Restart Plexamp
--roonbridge Restart RoonBridge

################################################################################
# Post questions regarding this guide to http://moodeaudio.org/forum
Expand Down
Loading

0 comments on commit b03ac74

Please sign in to comment.