Configurable Snapcast buffer size, fixes #408

This commit is contained in:
James Barnsley
2019-07-02 08:16:54 +12:00
parent f68a756aa4
commit 23780ef3ef
3 changed files with 5 additions and 3 deletions

View File

@ -40,6 +40,7 @@ class Extension( ext.Extension ):
schema['snapcast_enabled'] = config.Boolean()
schema['snapcast_host'] = config.String()
schema['snapcast_port'] = config.Integer()
schema['snapcast_buffer_size'] = config.Integer()
return schema
def setup(self, registry):

View File

@ -8,3 +8,4 @@ genius_authorization_url = https://jamesbarnsley.co.nz/iris/auth_genius.php
snapcast_enabled = false
snapcast_host = localhost
snapcast_port = 1705
snapcast_buffer_size = 8192

View File

@ -46,6 +46,7 @@ class IrisSnapcast(object):
self.connect()
self.listen = True
buffer_size = int(self.config['iris']['snapcast_buffer_size'])
logger.info("Established Snapcast listener")
broadcast(data={'method':'snapcast_connected'})
@ -67,9 +68,8 @@ class IrisSnapcast(object):
# Rread and print the available data on any of the read list
for socket in readlist:
# Allow a relatively large buffer size to handle large JSON payloads
message = socket.recv(8192)
message = socket.recv(buffer_size)
try:
message = json.loads(message)