fix audio chopper mode timestamp problem
This commit is contained in:
parent
3057c3ffd7
commit
7fc7fe5e82
@ -15,9 +15,16 @@ logger.setLevel(logging.INFO)
|
|||||||
|
|
||||||
|
|
||||||
class WaveFile(object):
|
class WaveFile(object):
|
||||||
def __init__(self, filename):
|
def __init__(self, writer_id):
|
||||||
self.filename = filename
|
self.timestamp = datetime.utcnow()
|
||||||
self.waveFile = wave.open(filename, "wb")
|
self.writer_id = writer_id
|
||||||
|
tmp_dir = CoreConfig().get_temporary_directory()
|
||||||
|
self.filename = "{tmp_dir}/openwebrx-audiochopper-master-{id}-{timestamp}.wav".format(
|
||||||
|
tmp_dir=tmp_dir,
|
||||||
|
id=self.writer_id,
|
||||||
|
timestamp=self.timestamp.strftime("%y%m%d_%H%M%S"),
|
||||||
|
)
|
||||||
|
self.waveFile = wave.open(self.filename, "wb")
|
||||||
self.waveFile.setnchannels(1)
|
self.waveFile.setnchannels(1)
|
||||||
self.waveFile.setsampwidth(2)
|
self.waveFile.setsampwidth(2)
|
||||||
self.waveFile.setframerate(12000)
|
self.waveFile.setframerate(12000)
|
||||||
@ -28,6 +35,9 @@ class WaveFile(object):
|
|||||||
def getFileName(self):
|
def getFileName(self):
|
||||||
return self.filename
|
return self.filename
|
||||||
|
|
||||||
|
def getTimestamp(self):
|
||||||
|
return self.timestamp
|
||||||
|
|
||||||
def writeframes(self, data):
|
def writeframes(self, data):
|
||||||
return self.waveFile.writeframes(data)
|
return self.waveFile.writeframes(data)
|
||||||
|
|
||||||
@ -47,13 +57,7 @@ class AudioWriter(object):
|
|||||||
self.timer = None
|
self.timer = None
|
||||||
|
|
||||||
def getWaveFile(self):
|
def getWaveFile(self):
|
||||||
tmp_dir = CoreConfig().get_temporary_directory()
|
return WaveFile(id(self))
|
||||||
filename = "{tmp_dir}/openwebrx-audiochopper-master-{id}-{timestamp}.wav".format(
|
|
||||||
tmp_dir=tmp_dir,
|
|
||||||
id=id(self),
|
|
||||||
timestamp=datetime.utcnow().strftime("%y%m%d_%H%M%S"),
|
|
||||||
)
|
|
||||||
return WaveFile(filename)
|
|
||||||
|
|
||||||
def getNextDecodingTime(self):
|
def getNextDecodingTime(self):
|
||||||
# add one second to have the intervals tick over one second earlier
|
# add one second to have the intervals tick over one second earlier
|
||||||
@ -90,7 +94,7 @@ class AudioWriter(object):
|
|||||||
filename = "{tmp_dir}/openwebrx-audiochopper-{pid}-{timestamp}.wav".format(
|
filename = "{tmp_dir}/openwebrx-audiochopper-{pid}-{timestamp}.wav".format(
|
||||||
tmp_dir=tmp_dir,
|
tmp_dir=tmp_dir,
|
||||||
pid=id(profile),
|
pid=id(profile),
|
||||||
timestamp=datetime.utcnow().strftime(profile.getFileTimestampFormat()),
|
timestamp=file.getTimestamp().strftime(profile.getFileTimestampFormat()),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
os.link(file.getFileName(), filename)
|
os.link(file.getFileName(), filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user