|
@@ -28,6 +28,7 @@ import queue
|
|
|
import platform
|
|
|
from select import select
|
|
|
from time import sleep
|
|
|
+from urllib.parse import urlparse
|
|
|
|
|
|
# ABCMeta
|
|
|
from abc import ABCMeta, abstractmethod
|
|
@@ -59,6 +60,11 @@ from alsaaudio import Mixer
|
|
|
from smb.SMBConnection import SMBConnection
|
|
|
from nmb.NetBIOS import NetBIOS
|
|
|
|
|
|
+# sdlib
|
|
|
+from sdlib import simpleSMB
|
|
|
+from sdlib import castQueue
|
|
|
+from sdlib import SDTimer
|
|
|
+
|
|
|
# LCD spec.
|
|
|
LCD_WIDTH = 128
|
|
|
LCD_HEIGHT = 160
|
|
@@ -93,78 +99,6 @@ VOLUME_FILE='/var/tmp/.superdac.volume'
|
|
|
# Openning Logo Image
|
|
|
LOGO_FILE = '/home/mpd/scripts/logo.jpg'
|
|
|
|
|
|
-class SDTimer(threading.Thread):
|
|
|
-
|
|
|
- __active = False
|
|
|
-
|
|
|
- def __init__(self, sec, callback):
|
|
|
- super(SDTimer, self).__init__()
|
|
|
- self.daemon = True
|
|
|
- self.__sec = sec
|
|
|
- self.__callback = callback
|
|
|
-
|
|
|
- def getRemaining(self):
|
|
|
- return self.__sec
|
|
|
-
|
|
|
- def setRemaining(self, sec):
|
|
|
- self.__sec = sec
|
|
|
-
|
|
|
- def getActive(self):
|
|
|
- return self.__active
|
|
|
-
|
|
|
- def cancel(self):
|
|
|
- self.__active = False
|
|
|
-
|
|
|
- def run(self):
|
|
|
- self.__active = True
|
|
|
-
|
|
|
- while self.__sec != 0:
|
|
|
- sleep(1)
|
|
|
- self.__sec -= 1
|
|
|
- if self.__active == False:
|
|
|
- break
|
|
|
-
|
|
|
- if self.__active:
|
|
|
- self.__callback()
|
|
|
- self.__active = False
|
|
|
-
|
|
|
- return
|
|
|
-
|
|
|
-
|
|
|
-class castQueue(queue.Queue):
|
|
|
-
|
|
|
- __depth = 5
|
|
|
-
|
|
|
- def __init__(self, depth):
|
|
|
- super(castQueue, self).__init__()
|
|
|
- self.__depth = depth
|
|
|
- self.__semaphore = BoundedSemaphore()
|
|
|
-
|
|
|
- def put(self, obj):
|
|
|
- self.__semaphore.acquire()
|
|
|
- while self.qsize() > self.__depth:
|
|
|
- try:
|
|
|
- t = super().get_nowait()
|
|
|
- except queue.Empty:
|
|
|
- pass
|
|
|
- super().put(obj)
|
|
|
- self.__semaphore.release()
|
|
|
- return
|
|
|
-
|
|
|
- def get_nowait(self):
|
|
|
- self.__semaphore.acquire()
|
|
|
- r = None
|
|
|
- try:
|
|
|
- r = super().get_nowait()
|
|
|
- except Exception as e:
|
|
|
- self.__semaphore.release()
|
|
|
- raise e
|
|
|
- self.__semaphore.release()
|
|
|
- return r
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
# Message class
|
|
|
class Message():
|
|
|
|
|
@@ -194,7 +128,6 @@ class Message():
|
|
|
def getParam(self):
|
|
|
return self.__param
|
|
|
|
|
|
-
|
|
|
# LCD Display Item
|
|
|
class LCDItem():
|
|
|
|
|
@@ -278,7 +211,6 @@ class Switches(Worker):
|
|
|
|
|
|
return True
|
|
|
|
|
|
-
|
|
|
# Playlist manage worker
|
|
|
class Playlist(Worker):
|
|
|
|
|
@@ -865,8 +797,6 @@ class AlbumArt(Worker, threading.Thread):
|
|
|
param = LCDItem(image, pos=LCDItem.TOP)
|
|
|
msg = Message(self, Message.DISPLAY, param)
|
|
|
self.sendMessage(msg)
|
|
|
- # インジケータ再描画
|
|
|
-# self.sendMessage(Message(self, Message.INDICATOR, None))
|
|
|
|
|
|
return
|
|
|
|
|
@@ -887,8 +817,9 @@ class AlbumArt(Worker, threading.Thread):
|
|
|
except queue.Empty:
|
|
|
sleep(0.05)
|
|
|
return
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+# SongTitle
|
|
|
class SongTitle(Worker, threading.Thread):
|
|
|
|
|
|
term = False
|