Skip to content

How to reduce max playback speed to avoid AudioTrack OOM #2905

@nift4

Description

@nift4

Due to too high max speed, buffer size is too large and AudioTrack creation fails due to out of memory.

11-21 20:13:45.982 11934 18111 E AF::TrackBase: TrackBase(275): not enough memory for AudioTrack size=12583144
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Primary:
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Dedicated Pool Allocator Dump:
11-21 20:13:45.982 11934 18111 E AF::TrackBase:   HeapID    Size  Offset   Order   Name
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Secondary:
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Primary:
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Large Shared Allocator Dump:
11-21 20:13:45.982 11934 18111 E AF::TrackBase:   HeapID    Size  Offset   Order   Name
11-21 20:13:45.982 11934 18111 E AF::TrackBase:       3512587008       0       0   Track ID: 272
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Secondary:
11-21 20:13:45.982 11934 18111 E AF::TrackBase: Small Shared Allocator Dump:
11-21 20:13:45.982 11934 18111 E AF::TrackBase:   HeapID    Size  Offset   Order   Name
11-21 20:13:45.985 11934 18111 E AudioFlinger: createTrack_l() initCheck failed -12; no control block?

ExoPlayer already applies 4x multiplier to PCM for all playbacks:


but due to 12 channel audio file it also applies 6x multiplier compared to stereo due to more channels and audio playback params for speed change applies another 8x multiplier compared to other player with it disabled.
usePlaybackParameters ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);

So we have 6*8=48x the buffer size for speed adjustment enabled 12ch compared to speed adjustment disabled stereo and that leads to buffer out of memory.

In my testing affected device works fine with max speed reduced to 4x (which is already more than enough and also the maximum I expose in UI) and pcm multiplication reduced to 2x. While PCM multiplication is easy to configure (with setPcmBufferMultiplicationFactor), is there a way to change max playback speed? And is it a good idea to apply this on a global level (also to stereo playbacks)?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions