# Path: sippy/Time/clock_dtime.py
# def clock_getdtime(type):
#     ts = clock_getitime(type)
#     return float(ts[0]) + float(ts[1] * 1e-09)
# 
# CLOCK_MONOTONIC = 4 # see <linux/time.h> / <include/time.h>


from threading import Thread, Lock
from math import floor
from elperiodic.ElPeriodic import ElPeriodic
from rtpsynth.RtpSynth import RtpSynth
from sippy.Core.EventDispatcher import ED2
from sippy.Time.clock_dtime import clock_getdtime, CLOCK_MONOTONIC
    from time import sleep

    def start(self, userv, target):
        self.state_lock.acquire()
        self.target = target
        self.userv = userv
        if self.state == RTPGenSuspend:
            self.state = RTPGenRun
            self.state_lock.release()
            return
        self.state_lock.release()
        pfreq = 1.0 / self.ptime
        self.elp = ElPeriodic(pfreq)
        self.rsth = RtpSynth(8000, 30)
        Thread.start(self)

    def enqueue(self, pload):
        self.plq_lock.acquire()
        self.pl_queue.append(pload)
        self.plq_lock.release()

    def dequeue(self):
        self.plq_lock.acquire()
        if len(self.pl_queue) > 0:
            rval = self.pl_queue.pop(0)
        else:
            rval = None
        self.plq_lock.release()
        return rval

    def run(self):

# Path: sippy/Time/clock_dtime.py
# def clock_getdtime(type):
#     ts = clock_getitime(type)
#     return float(ts[0]) + float(ts[1] * 1e-09)
# 
# CLOCK_MONOTONIC = 4 # see <linux/time.h> / <include/time.h>


# Path: apps/iot/RTPGen.py
from threading import Thread, Lock
from math import floor
from elperiodic.ElPeriodic import ElPeriodic
from rtpsynth.RtpSynth import RtpSynth
from sippy.Core.EventDispatcher import ED2
from sippy.Time.clock_dtime import clock_getdtime, CLOCK_MONOTONIC
    from time import sleep


    def start(self, userv, target):
        self.state_lock.acquire()
        self.target = target
        self.userv = userv
        if self.state == RTPGenSuspend:
            self.state = RTPGenRun
            self.state_lock.release()
            return
        self.state_lock.release()
        pfreq = 1.0 / self.ptime
        self.elp = ElPeriodic(pfreq)
        self.rsth = RtpSynth(8000, 30)
        Thread.start(self)

    def enqueue(self, pload):
        self.plq_lock.acquire()
        self.pl_queue.append(pload)
        self.plq_lock.release()

    def dequeue(self):
        self.plq_lock.acquire()
        if len(self.pl_queue) > 0:
            rval = self.pl_queue.pop(0)
        else:
            rval = None
        self.plq_lock.release()
        return rval

    def run(self):

        stime = clock_getdtime(CLOCK_MONOTONIC)