pass through programme information
This commit is contained in:
parent
41bbdef15c
commit
df6fe8971a
|
|
@ -1,8 +1,8 @@
|
||||||
from csdr.chain.demodulator import BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain, HdAudio
|
from csdr.chain.demodulator import BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain, HdAudio, MetaProvider
|
||||||
from csdr.module import PickleModule
|
from csdr.module import PickleModule
|
||||||
from csdreti.modules import EtiDecoder
|
from csdreti.modules import EtiDecoder
|
||||||
from owrx.dab.dablin import DablinModule
|
from owrx.dab.dablin import DablinModule
|
||||||
from pycsdr.modules import Downmix, Buffer, Shift
|
from pycsdr.modules import Downmix, Buffer, Shift, Writer
|
||||||
from pycsdr.types import Format
|
from pycsdr.types import Format
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from random import random
|
from random import random
|
||||||
|
|
@ -21,6 +21,7 @@ class MetaProcessor(PickleModule):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def process(self, data):
|
def process(self, data):
|
||||||
|
result = {}
|
||||||
if "coarse_frequency_shift" in data:
|
if "coarse_frequency_shift" in data:
|
||||||
value = int(data["coarse_frequency_shift"])
|
value = int(data["coarse_frequency_shift"])
|
||||||
if value > 0:
|
if value > 0:
|
||||||
|
|
@ -36,9 +37,13 @@ class MetaProcessor(PickleModule):
|
||||||
logger.debug("ffs: %f", value)
|
logger.debug("ffs: %f", value)
|
||||||
logger.debug("fine adjustment - new shift: %f", self.shift)
|
logger.debug("fine adjustment - new shift: %f", self.shift)
|
||||||
self.shifter.setRate(self.shift)
|
self.shifter.setRate(self.shift)
|
||||||
|
if "programmes" in data:
|
||||||
|
result["programmes"] = data["programmes"]
|
||||||
|
# don't send out data if there was nothing interesting for the client
|
||||||
|
return result if result else None
|
||||||
|
|
||||||
|
|
||||||
class Dablin(BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain, HdAudio):
|
class Dablin(BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain, HdAudio, MetaProvider):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
shift = Shift(0)
|
shift = Shift(0)
|
||||||
decoder = EtiDecoder()
|
decoder = EtiDecoder()
|
||||||
|
|
@ -47,6 +52,8 @@ class Dablin(BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain,
|
||||||
decoder.setMetaWriter(metaBuffer)
|
decoder.setMetaWriter(metaBuffer)
|
||||||
self.processor = MetaProcessor(shift)
|
self.processor = MetaProcessor(shift)
|
||||||
self.processor.setReader(metaBuffer.getReader())
|
self.processor.setReader(metaBuffer.getReader())
|
||||||
|
# use a dummy to start with. it won't run without.
|
||||||
|
# will be replaced by setMetaWriter().
|
||||||
self.processor.setWriter(Buffer(Format.CHAR))
|
self.processor.setWriter(Buffer(Format.CHAR))
|
||||||
|
|
||||||
workers = [
|
workers = [
|
||||||
|
|
@ -71,3 +78,6 @@ class Dablin(BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain,
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.processor.stop()
|
self.processor.stop()
|
||||||
|
|
||||||
|
def setMetaWriter(self, writer: Writer) -> None:
|
||||||
|
self.processor.setWriter(writer)
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@ class ThreadModule(AutoStartModule, Thread, metaclass=ABCMeta):
|
||||||
self.reader.stop()
|
self.reader.stop()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
# don't start twice.
|
||||||
|
if self.is_alive():
|
||||||
|
return
|
||||||
Thread.start(self)
|
Thread.start(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue