diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2017-12-18 00:05:40 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2018-02-13 18:50:48 +0100 |
commit | 72cced49a72d334640af832344ea917da46b8548 (patch) | |
tree | 5b6413698aef2aa7001a67736012d82e2e5b34f3 /decoders | |
parent | 8accc30bf5d98aa958af839511d57e0e1ddefe94 (diff) | |
download | libsigrokdecode-72cced49a72d334640af832344ea917da46b8548.tar.gz libsigrokdecode-72cced49a72d334640af832344ea917da46b8548.zip |
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.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/i2s/pd.py | 9 |
1 files changed, 2 insertions, 7 deletions
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: <value>: 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('<I', self.data) def decode(self): - if not self.samplerate: - raise SamplerateError('Cannot decode without samplerate.') while True: # Wait for a rising edge on the SCK pin. sck, ws, sd = self.wait({0: 'r'}) |