Skip to content

Android Audio Best Practices (Google I/O 17)Β #66

@rpattabi

Description

@rpattabi

Recently at Google I/O 17, Android Audio team put forth some recommendations to improve audio performance: https://youtu.be/C0BPXZIvG-Q?t=10m13s

I am wondering if pd-for-android can take advantage of these recommendations and how. I have summarized the best practices here.

Obtain low latency audio paths

Check for audio.pro hardware flag, which means that the device is capable of less than 20ms latency

Recording

  • use VOICE_RECOGNITION preset to by pass system effects
  • use PCM16 format which avoids any format shifting

Playback

Meet audio deadlines

Additional recommendations for the callback implementation to avoid glitches

  • avoid logging. use systrace instead.
  • avoid memory allocation
  • don't wait on other threads
  • don't do file i/o. Instead, use another thread to do read file and transfer the data using circular buffer or non-blocking queue
  • don't sleep
  • prevent cpu core migration by setting thread affinity, or using getExclusiveCores()
  • prevent cpu frequency scaling by adding a stabilizing load
  • use Sustained Performance Mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions