Skip to content

Commit

Permalink
Merge branch 'master' into v3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Nov 30, 2019
2 parents ed9ad73 + f9dbf8d commit 7cbc94d
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 149 deletions.
143 changes: 119 additions & 24 deletions scripts/fpp_boot
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ then
${SCRIPTDIR}/git_pull
fi


${SCRIPTDIR}/upgrade_config

${SCRIPTDIR}/timezone_sync
Expand All @@ -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"
Expand All @@ -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
103 changes: 1 addition & 102 deletions scripts/init_pre_network
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} ]
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 10 additions & 4 deletions src/NetworkMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,25 @@ void NetworkMonitor::Init(std::map<int, std::function<bool(int)>> &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:
case RTM_DELADDR:
{
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;
Expand Down
2 changes: 1 addition & 1 deletion src/PixelOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/channeloutput/channeloutputthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/playlist/Playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::recursive_mutex> lck (m_playlistMutex);

if ((m_status == FPP_STATUS_PLAYLIST_PLAYING) ||
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/playlist/PlaylistEntryDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -217,7 +218,7 @@ int PlaylistEntryDynamic::Stop(void)
return 1;
}

return 0;
return PlaylistEntryBase::Stop();
}

/*
Expand Down Expand Up @@ -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")
Expand Down
Loading

0 comments on commit 7cbc94d

Please sign in to comment.