Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

50 linhas
982B

  1. package gpudemod
  2. type batchSlot struct {
  3. job ExtractJob
  4. out []complex64
  5. rate int
  6. active bool
  7. }
  8. type BatchRunner struct {
  9. eng *Engine
  10. slots []batchSlot
  11. }
  12. func NewBatchRunner(maxSamples int, sampleRate int) (*BatchRunner, error) {
  13. eng, err := New(maxSamples, sampleRate)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return &BatchRunner{eng: eng}, nil
  18. }
  19. func (r *BatchRunner) Close() {
  20. if r == nil || r.eng == nil {
  21. return
  22. }
  23. r.eng.Close()
  24. r.eng = nil
  25. r.slots = nil
  26. }
  27. func (r *BatchRunner) prepare(jobs []ExtractJob) {
  28. if cap(r.slots) < len(jobs) {
  29. r.slots = make([]batchSlot, len(jobs))
  30. } else {
  31. r.slots = r.slots[:len(jobs)]
  32. }
  33. for i, job := range jobs {
  34. r.slots[i] = batchSlot{job: job, active: true}
  35. }
  36. }
  37. func (r *BatchRunner) ShiftFilterDecimateBatch(iq []complex64, jobs []ExtractJob) ([][]complex64, []int, error) {
  38. if r == nil || r.eng == nil {
  39. return nil, nil, ErrUnavailable
  40. }
  41. r.prepare(jobs)
  42. return r.shiftFilterDecimateBatchImpl(iq)
  43. }