Prevent to start streaming if the processor has only 1 core.

This commit is contained in:
Pecusx
2017-05-09 20:26:26 +02:00
committed by GitHub
parent bbe52b4cf6
commit 80d5530cfc
3 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ class MyDaemon(Daemon):
mpd_version = radio.execMpcCommand("version")
log.message(mpd_version, log.INFO)
lcd.line3(mpd_version)
lcd.line4("GPIO version " + str(GPIO.VERSION))
lcd.line4("GPIO: " + str(GPIO.VERSION) + " cores:"+str(radio.cores))
time.sleep(2.0)
reload(lcd,radio)
+22 -9
View File
@@ -116,6 +116,7 @@ class Radio:
version = "0.0"
boardrevision = 2 # Raspberry board version type
cores = 0 # number of processor cores
udphost = 'localhost' # Remote IR listener UDP Host
udpport = 5100 # Remote IR listener UDP port number
mpdport = 6600 # MPD port number
@@ -405,6 +406,7 @@ class Radio:
config.display()
# Get Configuration parameters /etc/radiod.conf
self.boardrevision = self.getBoardRevision()
self.cores = self.getCores()
self.mpdport = config.getMpdPort()
self.udpport = config.getRemoteUdpPort()
self.udphost = config.getRemoteListenHost()
@@ -436,6 +438,7 @@ class Radio:
log.message("radio.start current ID " + str(self.current_id), log.DEBUG)
self.volume = self.getStoredVolume()
self.setVolume(self.volume)
self.execCommand ("killall pianobar") # Necessary after restart problems
# Alarm and timer settings
self.timeTimer = int(time.time())
@@ -842,6 +845,12 @@ class Radio:
log.message("Board revision " + str(self.boardrevision), log.INFO)
return self.boardrevision
# Get number of processor cores from /proc/cpuinfo
def getCores(self):
cores_text = self.execCommand("cat /proc/cpuinfo | grep -c processor")
self.cores = int(cores_text)
return self.cores
# Get the MPD port number
def getMpdPort(self):
port = 6600
@@ -1400,13 +1409,17 @@ class Radio:
# Switch on Icecast2 streaming
def streamingOn(self):
output_id = 2
self.streaming = True
self.execCommand("service icecast2 start")
self.execCommand("service darkice start")
self.execMpcCommand("enable " + str(output_id))
self.storeStreaming("on")
self.streamingStatus()
if self.streamingAvailable():
output_id = 2
self.streaming = True
self.execCommand("service icecast2 start")
self.execCommand("service darkice start")
self.execMpcCommand("enable " + str(output_id))
self.storeStreaming("on")
self.streamingStatus()
else:
self.streaming = False
self.storeStreaming("off")
self.streammetadata = ''
return self.streaming
@@ -1430,10 +1443,10 @@ class Radio:
log.message(status, log.INFO)
return
# Check if icecast streaming installed
# Check if icecast streaming installed and pocessor has more than 1 core
def streamingAvailable(self):
fpath = "/usr/bin/icecast2"
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
return os.path.isfile(fpath) and os.access(fpath, os.X_OK) and (self.cores>1)
# Store stram on or off in streaming file
def storeStreaming(self,onoff):
+1 -1
View File
@@ -1 +1 @@
5.5e
5.5f