Skip to content
Snippets Groups Projects
Commit 55725a8a authored by David Trattnig's avatar David Trattnig
Browse files

More flexible Liquidsoap mixer handling. #44

parent 119c4017
No related branches found
No related tags found
No related merge requests found
...@@ -27,13 +27,15 @@ from multiprocessing import Lock ...@@ -27,13 +27,15 @@ from multiprocessing import Lock
from modules.base.exceptions import LQConnectionError from modules.base.exceptions import LQConnectionError
from modules.base.utils import TerminalColors from modules.base.utils import TerminalColors
"""
LiquidSoapClient Class
Connects to a LiquidSoap instance over a socket and sends commands to it
"""
class LiquidSoapClient: class LiquidSoapClient:
"""
LiquidSoapClient Class
Connects to a LiquidSoap instance over a socket and sends commands to it
"""
mutex = None mutex = None
logger = None logger = None
debug = False debug = False
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# FIXME Refactor to avoid use of Channel Class here
from modules.core.channels import Channel
from modules.core.liquidsoap.client import LiquidSoapClient from modules.core.liquidsoap.client import LiquidSoapClient
...@@ -28,37 +26,37 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -28,37 +26,37 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
# Mixer # Mixer
# #
def mixer(self, command, *args): # def mixer(self, mixer_id, command, *args):
if command == "status": # if command == "status":
return self.mixerstatus(*args) # return self.mixer_status(mixer_id, *args)
if command == "inputs": # if command == "inputs":
return self.mixerinputs() # return self.mixer_inputs(mixer_id)
if command == "volume": # if command == "volume":
return self.mixer_volume(*args) # return self.mixer_volume(mixer_id, *args)
if command == "select": # if command == "select":
if len(args) == 2: # if len(args) == 2:
return self.mixer_select(args[0], args[1]) # return self.mixer_select(mixer_id, args[0], args[1])
if command == "activate": # if command == "activate":
if len(args) == 2: # if len(args) == 2:
return self.mixer_activate(args[0], args[1]) # return self.mixer_activate(mixer_id, args[0], args[1])
return "LiquidSoapPlayerClient does not understand mixer."+command+str(args) # return "LiquidSoapPlayerClient does not understand mixer."+command+str(args)
# ------------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------------ #
def mixerinputs(self): def mixer_inputs(self, mixer_id):
# send command # send command
self.command("mixer", "inputs") self.command(mixer_id, "inputs")
# convert to list and return it # convert to list and return it
return self.message.strip().split(' ') return self.message.strip().split(' ')
# ------------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------------ #
def mixerstatus(self, pos=""): def mixer_status(self, mixer_id, pos=""):
""" """
Get state of a source in the mixer Get state of a source in the mixer
@type pos: string @type pos: string
...@@ -66,11 +64,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -66,11 +64,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
@rtype: string @rtype: string
@return: Response from LiquidSoap @return: Response from LiquidSoap
""" """
self.command("mixer", "status", str(pos)) self.command(mixer_id, "status", str(pos))
return self.message return self.message
def mixer_volume(self, pos, volume): def mixer_volume(self, mixer_id, pos, volume):
""" """
Sets some mixer channel to the given volume Sets some mixer channel to the given volume
...@@ -81,11 +79,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -81,11 +79,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
(String): Liquidsoap server response (String): Liquidsoap server response
""" """
self.command("mixer", "volume", str(pos) + " " + str(volume)) self.command(mixer_id, "volume", str(pos) + " " + str(volume))
return self.message return self.message
def mixer_select(self, pos, select): def mixer_select(self, mixer_id, pos, select):
""" """
Selects some mixer channel or vice versa. Selects some mixer channel or vice versa.
...@@ -96,11 +94,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -96,11 +94,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
(String): Liquidsoap server response (String): Liquidsoap server response
""" """
self.command("mixer", "select", str(pos) + " " + str(select).lower()) self.command(mixer_id, "select", str(pos) + " " + str(select).lower())
return self.message return self.message
def mixer_activate(self, pos, activate): def mixer_activate(self, mixer_id, pos, activate):
""" """
Selects some mixer channel and increases the volume to 100 or vice versa. Selects some mixer channel and increases the volume to 100 or vice versa.
...@@ -111,7 +109,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -111,7 +109,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
(String): Liquidsoap server response (String): Liquidsoap server response
""" """
self.command("mixer", "activate", str(pos) + " " + str(activate).lower()) self.command(mixer_id, "activate", str(pos) + " " + str(activate).lower())
return self.message return self.message
...@@ -176,11 +174,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -176,11 +174,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
Liquidsoap server response Liquidsoap server response
""" """
if channel == Channel.SCHEDULED_FALLBACK.value: self.command(channel, 'uri', uri)
self.command(channel, 'uri', uri)
else:
return "Invalid filesystem channel '%s'" % channel
return self.message return self.message
...@@ -195,11 +189,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -195,11 +189,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
Liquidsoap server response Liquidsoap server response
""" """
if channel == Channel.SCHEDULED_FALLBACK.value: self.command(channel, 'clear')
self.command(channel, 'clear')
else:
return "Invalid filesystem channel '%s'" % channel
return self.message return self.message
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment