mirror of
https://github.com/ha7ilm/openwebrx.git
synced 2026-04-10 08:53:44 +00:00
restore DRM functionality
This commit is contained in:
parent
f3b05c6318
commit
9ca5e0ebd6
5 changed files with 74 additions and 33 deletions
|
|
@ -4,6 +4,7 @@ from pycsdr.types import Format
|
|||
from abc import ABCMeta, abstractmethod
|
||||
from threading import Thread
|
||||
from io import BytesIO
|
||||
from subprocess import Popen, PIPE
|
||||
import pickle
|
||||
|
||||
|
||||
|
|
@ -89,3 +90,39 @@ class PickleModule(ThreadModule):
|
|||
@abstractmethod
|
||||
def process(self, input):
|
||||
pass
|
||||
|
||||
|
||||
class PopenModule(AutoStartModule, metaclass=ABCMeta):
|
||||
def __init__(self):
|
||||
self.process = None
|
||||
super().__init__()
|
||||
|
||||
@abstractmethod
|
||||
def getCommand(self):
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
self.process = Popen(self.getCommand(), stdin=PIPE, stdout=PIPE)
|
||||
Thread(target=self.pump(self.reader.read, self.process.stdin.write)).start()
|
||||
Thread(target=self.pump(self.process.stdout.read, self.writer.write)).start()
|
||||
|
||||
def stop(self):
|
||||
if self.process is not None:
|
||||
self.process.terminate()
|
||||
self.process.wait()
|
||||
self.process = None
|
||||
self.reader.stop()
|
||||
|
||||
def pump(self, read, write):
|
||||
def copy():
|
||||
while True:
|
||||
data = None
|
||||
try:
|
||||
data = read()
|
||||
except ValueError:
|
||||
pass
|
||||
if data is None or isinstance(data, bytes) and len(data) == 0:
|
||||
break
|
||||
write(data)
|
||||
|
||||
return copy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue