fix dial frequencies
This commit is contained in:
@ -3,6 +3,7 @@ from itertools import groupby
|
||||
import threading
|
||||
from owrx.audio import ProfileSourceSubscriber
|
||||
from owrx.audio.wav import AudioWriter
|
||||
from owrx.audio.queue import QueueJob
|
||||
from csdr.chain import Chain
|
||||
import pickle
|
||||
|
||||
@ -16,6 +17,7 @@ class AudioChopper(threading.Thread, Chain, ProfileSourceSubscriber):
|
||||
# TODO parser typing
|
||||
def __init__(self, mode_str: str, parser):
|
||||
self.parser = parser
|
||||
self.dialFrequency = None
|
||||
self.doRun = True
|
||||
self.writers = []
|
||||
mode = Modes.findByModulation(mode_str)
|
||||
@ -72,7 +74,14 @@ class AudioChopper(threading.Thread, Chain, ProfileSourceSubscriber):
|
||||
logger.debug("profile change received, resetting writers...")
|
||||
self.setup_writers()
|
||||
|
||||
def send(self, profile, line):
|
||||
data = self.parser.parse(profile, line)
|
||||
if data is not None and self.writer is not None:
|
||||
self.writer.write(pickle.dumps(data))
|
||||
def setDialFrequency(self, frequency: int) -> None:
|
||||
self.dialFrequency = frequency
|
||||
|
||||
def createJob(self, profile, filename):
|
||||
return QueueJob(profile, self.dialFrequency, self, filename)
|
||||
|
||||
def sendResult(self, result):
|
||||
for line in result.lines:
|
||||
data = self.parser.parse(result.profile, result.frequency, line)
|
||||
if data is not None and self.writer is not None:
|
||||
self.writer.write(pickle.dumps(data))
|
||||
|
@ -12,9 +12,17 @@ logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class QueueJob(object):
|
||||
def __init__(self, profile, writer, file):
|
||||
class QueueJobResult:
|
||||
def __init__(self, profile, frequency, lines):
|
||||
self.profile = profile
|
||||
self.frequency = frequency
|
||||
self.lines = lines
|
||||
|
||||
|
||||
class QueueJob(object):
|
||||
def __init__(self, profile, frequency, writer, file):
|
||||
self.profile = profile
|
||||
self.frequency = frequency
|
||||
self.writer = writer
|
||||
self.file = file
|
||||
|
||||
@ -27,13 +35,18 @@ class QueueJob(object):
|
||||
cwd=tmp_dir,
|
||||
close_fds=True,
|
||||
)
|
||||
lines = None
|
||||
try:
|
||||
for line in decoder.stdout:
|
||||
self.writer.send(self.profile, line)
|
||||
except (OSError, AttributeError):
|
||||
lines = [l for l in decoder.stdout]
|
||||
except OSError:
|
||||
decoder.stdout.flush()
|
||||
# TODO uncouple parsing from the output so that decodes can still go to the map and the spotters
|
||||
logger.debug("output has gone away while decoding job.")
|
||||
|
||||
# keep this out of the try/except
|
||||
if lines is not None:
|
||||
self.writer.sendResult(QueueJobResult(self.profile, self.frequency, lines))
|
||||
|
||||
try:
|
||||
rc = decoder.wait(timeout=10)
|
||||
if rc != 0:
|
||||
|
@ -1,6 +1,6 @@
|
||||
from owrx.config.core import CoreConfig
|
||||
from owrx.audio import AudioChopperProfile
|
||||
from owrx.audio.queue import QueueJob, DecoderQueue
|
||||
from owrx.audio.queue import DecoderQueue
|
||||
import threading
|
||||
import wave
|
||||
import os
|
||||
@ -47,8 +47,8 @@ class WaveFile(object):
|
||||
|
||||
|
||||
class AudioWriter(object):
|
||||
def __init__(self, outputWriter, interval, profiles: List[AudioChopperProfile]):
|
||||
self.outputWriter = outputWriter
|
||||
def __init__(self, chopper, interval, profiles: List[AudioChopperProfile]):
|
||||
self.chopper = chopper
|
||||
self.interval = interval
|
||||
self.profiles = profiles
|
||||
self.wavefile = None
|
||||
@ -101,7 +101,7 @@ class AudioWriter(object):
|
||||
logger.exception("Error while linking job files")
|
||||
continue
|
||||
|
||||
job = QueueJob(profile, self.outputWriter, filename)
|
||||
job = self.chopper.createJob(profile, filename)
|
||||
try:
|
||||
DecoderQueue.getSharedInstance().put(job)
|
||||
except Full:
|
||||
|
Reference in New Issue
Block a user