mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 03:11:15 +03:00
Expose dBFS when doing audio analysis (#6979)
* Expose dBFS when doing audio analysis * Implement metadata communicator * revert test changes * Reverting the tests changes. For real this time * Address feedback * Address feedback * Address feedback * Address feedback
This commit is contained in:
@@ -86,6 +86,8 @@ class Dispatcher:
|
||||
return
|
||||
elif topic == "restart":
|
||||
restart_frigate()
|
||||
else:
|
||||
self.publish(topic, payload, retain=False)
|
||||
|
||||
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
||||
"""Handle publishing to communicators."""
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import multiprocessing as mp
|
||||
import queue
|
||||
import threading
|
||||
from multiprocessing.synchronize import Event as MpEvent
|
||||
from typing import Callable
|
||||
|
||||
from faster_fifo import Queue
|
||||
|
||||
from frigate.comms.dispatcher import Communicator
|
||||
|
||||
|
||||
class InterProcessCommunicator(Communicator):
|
||||
def __init__(self, queue: Queue) -> None:
|
||||
self.queue = queue
|
||||
self.stop_event: MpEvent = mp.Event()
|
||||
|
||||
def publish(self, topic: str, payload: str, retain: bool) -> None:
|
||||
"""There is no communication back to the processes."""
|
||||
pass
|
||||
|
||||
def subscribe(self, receiver: Callable) -> None:
|
||||
self._dispatcher = receiver
|
||||
self.reader_thread = threading.Thread(target=self.read)
|
||||
self.reader_thread.start()
|
||||
|
||||
def read(self) -> None:
|
||||
while not self.stop_event.is_set():
|
||||
try:
|
||||
(
|
||||
topic,
|
||||
value,
|
||||
) = self.queue.get(True, 1)
|
||||
except queue.Empty:
|
||||
continue
|
||||
|
||||
self._dispatcher(topic, value)
|
||||
|
||||
def stop(self) -> None:
|
||||
self.stop_event.set()
|
||||
self.reader_thread.join()
|
||||
Reference in New Issue
Block a user