Browse Source

Flush IQ buffer on FFT reconfig

master
Jan Svabenik 4 days ago
parent
commit
5443bf3f97
4 changed files with 20 additions and 0 deletions
  1. +4
    -0
      cmd/sdrd/main.go
  2. +2
    -0
      internal/mock/source.go
  3. +4
    -0
      internal/sdr/source.go
  4. +10
    -0
      internal/sdrplay/sdrplay.go

+ 4
- 0
cmd/sdrd/main.go View File

@@ -436,6 +436,10 @@ func runDSP(ctx context.Context, src sdr.Source, cfg config.Config, det *detecto
dcEnabled = upd.dcBlock
iqEnabled = upd.iqBalance
if cfg.FFTSize != prevFFT || cfg.UseGPUFFT != prevUseGPU {
if flushable, ok := src.(sdr.Flushable); ok {
flushable.Flush()
}
gotSamples = false
if gpuEngine != nil {
gpuEngine.Close()
gpuEngine = nil


+ 2
- 0
internal/mock/source.go View File

@@ -61,3 +61,5 @@ func (s *Source) ReadIQ(n int) ([]complex64, error) {
func (s *Source) Stats() sdr.SourceStats {
return sdr.SourceStats{}
}

func (s *Source) Flush() {}

+ 4
- 0
internal/sdr/source.go View File

@@ -22,4 +22,8 @@ type StatsProvider interface {
Stats() SourceStats
}

type Flushable interface {
Flush()
}

var ErrNotImplemented = errors.New("sdrplay support not built; build with -tags sdrplay or use --mock")

+ 10
- 0
internal/sdrplay/sdrplay.go View File

@@ -287,6 +287,16 @@ func (s *Source) Stats() sdr.SourceStats {
return sdr.SourceStats{BufferSamples: s.size, Dropped: s.dropped, Resets: s.resets}
}

func (s *Source) Flush() {
s.mu.Lock()
s.head = 0
s.size = 0
s.mu.Unlock()
if s.cond != nil {
s.cond.Broadcast()
}
}

func min(a, b int) int {
if a < b {
return a


Loading…
Cancel
Save