Bladeren bron

Fix numerical overflow in audio CPU usage measurement

https://forum.pjrc.com/threads/61412
main
PaulStoffregen 4 jaren geleden
bovenliggende
commit
232ace26ff
2 gewijzigde bestanden met toevoegingen van 3 en 3 verwijderingen
  1. +2
    -2
      teensy4/AudioStream.cpp
  2. +1
    -1
      teensy4/AudioStream.h

+ 2
- 2
teensy4/AudioStream.cpp Bestand weergeven

@@ -321,13 +321,13 @@ void software_isr(void) // AudioStream::update_all()
p->update();
// TODO: traverse inputQueueArray and release
// any input blocks that weren't consumed?
cycles = (ARM_DWT_CYCCNT - cycles) >> 4;
cycles = (ARM_DWT_CYCCNT - cycles) >> 6;
p->cpu_cycles = cycles;
if (cycles > p->cpu_cycles_max) p->cpu_cycles_max = cycles;
}
}
//digitalWriteFast(2, LOW);
totalcycles = (ARM_DWT_CYCCNT - totalcycles) >> 4;;
totalcycles = (ARM_DWT_CYCCNT - totalcycles) >> 6;
AudioStream::cpu_cycles_total = totalcycles;
if (totalcycles > AudioStream::cpu_cycles_total_max)
AudioStream::cpu_cycles_total_max = totalcycles;

+ 1
- 1
teensy4/AudioStream.h Bestand weergeven

@@ -105,7 +105,7 @@ protected:
AudioStream::initialize_memory(data, num); \
})

#define CYCLE_COUNTER_APPROX_PERCENT(n) (((n) + (F_CPU_ACTUAL / 32 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100)) / (F_CPU_ACTUAL / 16 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100))
#define CYCLE_COUNTER_APPROX_PERCENT(n) (((n) + (F_CPU_ACTUAL / 128 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100)) / (F_CPU_ACTUAL / 64 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100))

#define AudioProcessorUsage() (CYCLE_COUNTER_APPROX_PERCENT(AudioStream::cpu_cycles_total))
#define AudioProcessorUsageMax() (CYCLE_COUNTER_APPROX_PERCENT(AudioStream::cpu_cycles_total_max))

Laden…
Annuleren
Opslaan