From: Gerhard Sittig Date: Sun, 17 Dec 2017 23:05:40 +0000 (+0100) Subject: i2s: make samplerate meta data optional X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=72cced49a72d334640af832344ea917da46b8548;p=libsigrokdecode.git i2s: make samplerate meta data optional Only emit sound samplerate information when an input stream sample rate was specified. Cope with the absence of a sample rate for the input stream. Decoding is still possible, it's just that no timing information is available. --- diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index 91801b4..bfb2c9e 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -33,9 +33,6 @@ Packet: : integer ''' -class SamplerateError(Exception): - pass - class Decoder(srd.Decoder): api_version = 3 id = 'i2s' @@ -92,12 +89,12 @@ class Decoder(srd.Decoder): self.put(self.ss_block, self.samplenum, self.out_ann, data) def report(self): - # Calculate the sample rate. samplerate = '?' if self.ss_block is not None and \ self.first_sample is not None and \ - self.ss_block > self.first_sample: + self.ss_block > self.first_sample and \ + self.samplerate: samplerate = '%d' % (self.samplesreceived * self.samplerate / (self.ss_block - self.first_sample)) @@ -128,8 +125,6 @@ class Decoder(srd.Decoder): return struct.pack('