diff --git a/scripts/fpp_boot b/scripts/fpp_boot index be62e437a..814b6b746 100755 --- a/scripts/fpp_boot +++ b/scripts/fpp_boot @@ -24,6 +24,7 @@ then ${SCRIPTDIR}/git_pull fi + ${SCRIPTDIR}/upgrade_config ${SCRIPTDIR}/timezone_sync @@ -45,36 +46,106 @@ WaitForInterfacesUp MaybeEnableTethering -# Print/Say the IP address -if [ -f /usr/bin/flite ] -then - _IP=$(hostname -I) || true - if [ "$_IP" ]; then - echo "FPP - Found IP(s): $_IP" - - DISABLEIPANN=$(getSetting disableIPAnnouncement) - if [ "x${DISABLEIPANN}" != "x1" ] - then - arrHost=(${_IP// / }) - FLITESTR="I Have Found The Following I P Addresses, ${arrHost[0]}, ${arrHost[1]}, ${arrHost[2]}" - if [ "${FPPPLATFORM}" = "BeagleBone Black" ] - then - (flite -voice awb -o /var/tmp/flite.wav "${FLITESTR}" && mplayer -ao alsa /var/tmp/flite.wav) & - else - flite -voice awb "${FLITESTR}" & - fi - fi - else - echo "FPP - No IP(s) found" - fi -fi - SLEEPSECS=$(getSetting bootDelay) if [ "x${SLEEPSECS}" != "x" ] then + echo "FPP - Sleeping for ${SLEEPSECS} seconds" sleep ${SLEEPSECS} fi + +checkAudioConfig + +aplay -l 2>&1 | grep -q "no soundcards" +HASSOUND=$? +echo "FPP - Configuring Audio: ${HASSOUND}" +if [ ${HASSOUND} -eq 1 ]; then + CARDID=0 + if [ -e /root/.asoundrc ]; then + CARDID=$(grep card /root/.asoundrc | head -n 1 | awk '{print $2}') + fi + + AUDIOOUTPUT=$(getSetting AudioOutput) + if [ "x${AUDIOOUTPUT}" != "x${CARDID}" -a -n "${AUDIOOUTPUT}" ] + then + echo "Resetting /root/.asoundrc to use card id ${AUDIOOUTPUT}" + sed -i "s/card [0-9]/card ${AUDIOOUTPUT}/" /root/.asoundrc + fi + + HASCARD=$(amixer -c ${CARDID} cset numid=3 1 2>&1 >/dev/null) + ## if invlid, we can wait a few seconds to see if the card appears + if [[ $HASCARD == *"Invalid "* ]]; then + sleep 1 + HASCARD=$(amixer -c ${CARDID} cset numid=3 1 2>&1 >/dev/null) + fi + if [[ $HASCARD == *"Invalid "* ]]; then + sleep 1 + HASCARD=$(amixer -c ${CARDID} cset numid=3 1 2>&1 >/dev/null) + fi + if [[ $HASCARD == *"Invalid "* ]]; then + sleep 1 + HASCARD=$(amixer -c ${CARDID} cset numid=3 1 2>&1 >/dev/null) + fi + if [[ $HASCARD == *"Invalid "* ]]; then + if [ "${CARDID}" != "0" ]; then + echo "Resetting /root/.asoundrc to use card id 0" + fi + sed -i "s/card [0-9]/card 0/" /root/.asoundrc + CARDID=0 + setSetting "AudioOutput" "0" + fi + VOLUME=$(getSetting volume) + if [ "x${VOLUME}" = "x" ]; then + setSetting volume 70 + VOLUME=70 + fi + + # Pi needs a volume adjustment, in reality a lot of sound cards do, but we + # don't want to put in a lot of special cases here so only handle the Pi + if [ "${FPPPLATFORM}" = "Raspberry Pi" ]; then + if [ "$CARDID" = "0" ]; then + CARD0STR=$(aplay -l | grep '^card 0' | sed -e 's/^card //' -e 's/:[^\[]*\[/:/' -e 's/\].*\[.*\].*//' | uniq | colrm 1 2 | colrm 5) + if [ "$CARD0STR" == "bcm2" ]; then + # Switch to this more accurate setting for or after v0.3.0 + VOLUME=$(echo "scale=2 ; ${VOLUME} / 2.0 + 50" | bc) + fi + setSetting AudioCard0Type $CARD0STR + else + setSetting AudioCard0Type "unknown" + fi + else + setSetting AudioCard0Type "unknown" + fi + + MIXERDEVICES=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") + if [ "x${MIXERDEVICES}" == "x" ]; then + # for some sound cards, the mixer devices won't show up + # until something is played. Play one second of silence + aplay -d 1 /opt/fpp/media/silence_5sec.wav >> /dev/null 2>&1 & + sleep 0.2 + MIXERDEVICES=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") + fi + + MIXERDEVICES=$(amixer -c $CARDID scontrols | cut -f2 -d"'") + MIXERDEVICE=$(getSetting AudioMixerDevice) + if [ -z ${MIXERDEVICE} ] + then + MIXERDEVICE=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") + setSetting AudioMixerDevice $MIXERDEVICE + else + MD=$(echo $MIXERDEVICES | xargs -n1 echo | grep $MIXERDEVICE) + if [ "$MD" != "$MIXERDEVICE" ]; then + echo "Did not find mixer device $MIXERDEVICE, resetting to default" + MIXERDEVICE=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") + setSetting AudioMixerDevice $MIXERDEVICE + fi + fi + + amixer -c ${CARDID} set ${MIXERDEVICE} ${VOLUME}% > /dev/null 2>&1 +fi + + + if [ "${FPPPLATFORM}" = "Raspberry Pi" ] then echo "FPP - Setting up SPI" @@ -93,5 +164,29 @@ then detectFalconHardware fi +# Print/Say the IP address +if [ -f /usr/bin/flite ] +then + _IP=$(hostname -I) || true + if [ "$_IP" ]; then + echo "FPP - Found IP(s): $_IP" + + DISABLEIPANN=$(getSetting disableIPAnnouncement) + if [ "x${DISABLEIPANN}" != "x1" ] + then + arrHost=(${_IP// / }) + FLITESTR="I Have Found The Following I P Addresses, ${arrHost[0]}, ${arrHost[1]}, ${arrHost[2]}" + if [ "${FPPPLATFORM}" = "BeagleBone Black" ] + then + (flite -voice awb -o /var/tmp/flite.wav "${FLITESTR}" && mplayer -ao alsa /var/tmp/flite.wav) & + else + flite -voice awb "${FLITESTR}" & + fi + fi + else + echo "FPP - No IP(s) found" + fi +fi + # set the Source port for outgoing ARTNET packets to match the spec /sbin/iptables -t nat -I POSTROUTING -p udp --dport 6454 -j SNAT --to-source :6454 diff --git a/scripts/init_pre_network b/scripts/init_pre_network index a30aee8e0..940ee9960 100755 --- a/scripts/init_pre_network +++ b/scripts/init_pre_network @@ -20,8 +20,6 @@ teeOutput echo "FPP - Setting up for the Falcon Player on the ${FPPPLATFORM} platform" -checkAudioConfig - grep -q "/home/fpp/media" /etc/fstab if [ $? -eq 1 ] then @@ -33,38 +31,10 @@ EOF fi -# Check to make sure media is mounted -grep -q "^[^#].*${FPPHOME}/media" /etc/fstab -MOUNTMEDIA=$? -COUNTER=0 -while [ ${MOUNTMEDIA} -eq 0 ] -do - let COUNTER+=1 - - # max of 60 seconds - if [ $COUNTER -gt 12 ]; then - break; - fi - - if [ "$(df -h ${MEDIADIR} | tail -n 1 | awk '{print $1}')" == "$(df -h / | tail -n 1 | awk '{print $1}')" ]; - then - echo "FPP - Checking for mounted flash drive, Flash Media Is Missing. Please Insert."; - aplay -l > /dev/null 2>&1 - HASSOUND=$? - if [ ${HASSOUND} -eq 1 -a -f "/usr/bin/flite" ]; then - flite -voice kal "Boot Stalled, Flash Media Is Missing. Please Insert." - fi - sleep 5; - mount -a; - else - echo "FPP - Checking for mounted flash drive, Flash Media mounted."; - break - fi -done - DIRS="config effects events logs music playlists scripts sequences upload videos plugins plugindata exim4 images cache tmp" echo "FPP - Checking for required directories" +chown ${FPPUSER}.${FPPUSER} ${FPPHOME}/media for DIR in ${DIRS} do if [ ! -d ${FPPHOME}/media/${DIR} ] @@ -112,78 +82,7 @@ fi echo "FPP - Configuring DNS" ${BINDIR}/config_dns -aplay -l 2>&1 | grep -q "no soundcards" -HASSOUND=$? -echo "FPP - Configuring Audio: ${HASSOUND}" -if [ ${HASSOUND} -eq 1 ]; then - CARDID=0 - if [ -e /root/.asoundrc ]; then - CARDID=$(grep card /root/.asoundrc | head -n 1 | awk '{print $2}') - fi - AUDIOOUTPUT=$(getSetting AudioOutput) - if [ "x${AUDIOOUTPUT}" != "x${CARDID}" -a -n "${AUDIOOUTPUT}" ] - then - echo "Resetting /root/.asoundrc to use card id ${AUDIOOUTPUT}" - sed -i "s/card [0-9]/card ${AUDIOOUTPUT}/" /root/.asoundrc - fi - HASCARD=$(amixer -c ${CARDID} cset numid=3 1 2>&1 >/dev/null) - if [[ $HASCARD == *"Invalid "* ]]; then - if [ "${CARDID}" != "0" ]; then - echo "Resetting /root/.asoundrc to use card id 0" - fi - sed -i "s/card [0-9]/card 0/" /root/.asoundrc - CARDID=0 - fi - VOLUME=$(getSetting volume) - if [ "x${VOLUME}" = "x" ]; then - setSetting volume 70 - VOLUME=70 - fi - - # Pi needs a volume adjustment, in reality a lot of sound cards do, but we - # don't want to put in a lot of special cases here so only handle the Pi - if [ "${FPPPLATFORM}" = "Raspberry Pi" ]; then - if [ "$CARDID" = "0" ]; then - CARD0STR=$(aplay -l | grep '^card 0' | sed -e 's/^card //' -e 's/:[^\[]*\[/:/' -e 's/\].*\[.*\].*//' | uniq | colrm 1 2 | colrm 5) - if [ "$CARD0STR" == "bcm2" ]; then - # Switch to this more accurate setting for or after v0.3.0 - VOLUME=$(echo "scale=2 ; ${VOLUME} / 2.0 + 50" | bc) - fi - setSetting AudioCard0Type $CARD0STR - else - setSetting AudioCard0Type "unknown" - fi - else - setSetting AudioCard0Type "unknown" - fi - - MIXERDEVICES=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") - if [ "x${MIXERDEVICES}" == "x" ]; then - # for some sound cards, the mixer devices won't show up - # until something is played. Play one second of silence - aplay -d 1 /opt/fpp/media/silence_5sec.wav >> /dev/null 2>&1 & - sleep 0.2 - MIXERDEVICES=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") - fi - - MIXERDEVICES=$(amixer -c $CARDID scontrols | cut -f2 -d"'") - MIXERDEVICE=$(getSetting AudioMixerDevice) - if [ -z ${MIXERDEVICE} ] - then - MIXERDEVICE=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") - setSetting AudioMixerDevice $MIXERDEVICE - else - MD=$(echo $MIXERDEVICES | xargs -n1 echo | grep $MIXERDEVICE) - if [ "$MD" != "$MIXERDEVICE" ]; then - echo "Did not find mixer device $MIXERDEVICE, resetting to default" - MIXERDEVICE=$(amixer -c $CARDID scontrols | head -1 | cut -f2 -d"'") - setSetting AudioMixerDevice $MIXERDEVICE - fi - fi - - amixer -c ${CARDID} set ${MIXERDEVICE} ${VOLUME}% > /dev/null 2>&1 -fi # Clear any restart/reboot flags echo "FPP - Clearing reboot flags" diff --git a/src/NetworkMonitor.cpp b/src/NetworkMonitor.cpp index 071753cd1..4cf6d431a 100644 --- a/src/NetworkMonitor.cpp +++ b/src/NetworkMonitor.cpp @@ -73,9 +73,12 @@ void NetworkMonitor::Init(std::map> &callbacks) { case RTM_DELLINK: { struct ifinfomsg *ifi = (ifinfomsg*)NLMSG_DATA(h); + std::string strName; + if (if_indextoname(ifi->ifi_index, name)) { + strName = name; + } callCallbacks(h->nlmsg_type == RTM_NEWLINK ? NetEventType::NEW_LINK : NetEventType::DEL_LINK, - (ifi->ifi_flags & IFF_RUNNING) ? 1 : 0, - if_indextoname(ifi->ifi_index, name)); + (ifi->ifi_flags & IFF_RUNNING) ? 1 : 0, strName); } break; case RTM_NEWADDR: @@ -83,9 +86,12 @@ void NetworkMonitor::Init(std::map> &callbacks) { { struct ifaddrmsg *ifi = (ifaddrmsg*)NLMSG_DATA(h); if (ifi->ifa_family == AF_INET) { + std::string strName; + if (if_indextoname(ifi->ifa_index, name)) { + strName = name; + } callCallbacks(h->nlmsg_type == RTM_NEWADDR ? NetEventType::NEW_ADDR : NetEventType::DEL_ADDR, - h->nlmsg_type == RTM_NEWADDR ? 1 : 0, - if_indextoname(ifi->ifa_index, name)); + h->nlmsg_type == RTM_NEWADDR ? 1 : 0, strName); } } break; diff --git a/src/PixelOverlay.cpp b/src/PixelOverlay.cpp index 15470e675..e1784a94e 100644 --- a/src/PixelOverlay.cpp +++ b/src/PixelOverlay.cpp @@ -361,7 +361,7 @@ void PixelOverlayModel::copyImageData(int xoff, int yoff) { void PixelOverlayModel::getDataJson(Json::Value &v) { for (int c = 0; c < block->channelCount; c++) { - int i = chanDataMap[pixelMap[block->startChannel + c - 1]]; + unsigned char i = chanDataMap[pixelMap[block->startChannel + c - 1]]; v.append(i); } } diff --git a/src/channeloutput/channeloutputthread.c b/src/channeloutput/channeloutputthread.c index c5520ea8d..399877965 100644 --- a/src/channeloutput/channeloutputthread.c +++ b/src/channeloutput/channeloutputthread.c @@ -218,9 +218,9 @@ void *RunChannelOutputThread(void *data) if (onceMore) { onceMore--; } else { - //we will wait up to 1000ms to see if the thread is still needed + //we will wait up to 2500ms to see if the thread is still needed ThreadIsExiting = 1; - if (outputThreadSatusCond.wait_for(statusLock, std::chrono::milliseconds(1000)) == std::cv_status::no_timeout) { + if (outputThreadSatusCond.wait_for(statusLock, std::chrono::milliseconds(2500)) == std::cv_status::no_timeout) { //signal to keep going ThreadIsExiting = 0; statusLock.unlock(); diff --git a/src/playlist/Playlist.cpp b/src/playlist/Playlist.cpp index ed706003f..bd9cb53ca 100644 --- a/src/playlist/Playlist.cpp +++ b/src/playlist/Playlist.cpp @@ -855,7 +855,6 @@ int Playlist::Play(const char *filename, const int position, const int repeat, c LogDebug(VB_PLAYLIST, "Playlist::Play('%s', %d, %d, %d)\n", filename, position, repeat, scheduled); - m_scheduled = scheduled; std::unique_lock lck (m_playlistMutex); if ((m_status == FPP_STATUS_PLAYLIST_PLAYING) || @@ -887,7 +886,7 @@ int Playlist::Play(const char *filename, const int position, const int repeat, c sleep(1); } } - + m_scheduled = scheduled; m_forceStop = 0; Load(filename); diff --git a/src/playlist/PlaylistEntryDynamic.cpp b/src/playlist/PlaylistEntryDynamic.cpp index fa4c35393..5ff761aee 100644 --- a/src/playlist/PlaylistEntryDynamic.cpp +++ b/src/playlist/PlaylistEntryDynamic.cpp @@ -32,6 +32,7 @@ #include "common.h" #include "log.h" #include "PlaylistEntryBoth.h" +#include "PlaylistEntryCommand.h" #include "PlaylistEntryEffect.h" #include "PlaylistEntryEvent.h" #include "PlaylistEntryMedia.h" @@ -217,7 +218,7 @@ int PlaylistEntryDynamic::Stop(void) return 1; } - return 0; + return PlaylistEntryBase::Stop(); } /* @@ -369,6 +370,8 @@ int PlaylistEntryDynamic::ReadFromString(std::string jsonStr) if (pe["type"].asString() == "both") playlistEntry = new PlaylistEntryBoth(); + else if (pe["type"].asString() == "command") + playlistEntry = new PlaylistEntryCommand(); else if (pe["type"].asString() == "effect") playlistEntry = new PlaylistEntryEffect(); else if (pe["type"].asString() == "event") diff --git a/www/fppjson.php b/www/fppjson.php index 6b8e81270..70360265e 100644 --- a/www/fppjson.php +++ b/www/fppjson.php @@ -1669,33 +1669,45 @@ function GetFPPSystems() function SetAudioOutput($card) { - global $args, $SUDO, $debug; + global $args, $SUDO, $debug, $settings; - if ($card != 0 && file_exists("/proc/asound/card$card")) - { + if ($card != 0 && file_exists("/proc/asound/card$card")) { exec($SUDO . " sed -i 's/card [0-9]/card ".$card."/' /root/.asoundrc", $output, $return_val); unset($output); - if ($return_val) - { + if ($return_val) { error_log("Failed to set audio to card $card!"); return; } - if ( $debug ) + if ( $debug ) { error_log("Setting to audio output $card"); - } - else if ($card == 0) - { + } + } else if ($card == 0) { exec($SUDO . " sed -i 's/card [0-9]/card ".$card."/' /root/.asoundrc", $output, $return_val); unset($output); - if ($return_val) - { + if ($return_val) { error_log("Failed to set audio back to default!"); return; } if ( $debug ) error_log("Setting default audio"); } - + // need to also reset mixer device + $AudioMixerDevice = exec("sudo amixer -c $card scontrols | head -1 | cut -f2 -d\"'\"", $output, $return_val); + unset($output); + if ($return_val == 0) { + WriteSettingToFile("AudioMixerDevice", $AudioMixerDevice); + if ($settings['Platform'] == "Raspberry Pi" && $card == 0) { + $type = exec("sudo aplay -l | grep \"card $card\"", $output, $return_val); + if (strpos($type, '[bcm') !== false) { + WriteSettingToFile("AudioCard0Type", "bcm"); + } else { + WriteSettingToFile("AudioCard0Type", "unknown"); + } + unset($output); + } else { + WriteSettingToFile("AudioCard0Type", "unknown"); + } + } return $card; } diff --git a/www/settings.php b/www/settings.php index 44fac1398..237e7c274 100644 --- a/www/settings.php +++ b/www/settings.php @@ -384,6 +384,7 @@ function SetAudio() { $.get("fppjson.php?command=setSetting&key=AudioOutput&value=" + $('#AudioOutput').val()).fail(function() { alert("Failed to change audio output!") }); + location.reload(); } function SetMixerDevice() @@ -454,7 +455,7 @@ function ToggleLCDNow() ?> OMXPlayer (mp4 playback) Audio Output: - "alsa", "HDMI" => "hdmi", "Local" => "local", "Both" => "both", "Disabled" => "disabled")); ?>