Skip to content

feat: implement pull buffering #334

Description

@Zekfad

Description

My use case is audio book files which could span more than a few gigabytes data of MP3.

Using normal buffer will not work because you cant load 2GB MP3 on a low-end phone into RAM (and that's not even decoded samples, which requires way more memory), so I think releasing buffer is a great choice here, but you can't seek such a buffer.

Currently streaming in implemented in a push way: user pushes data as soon as it is available for engine to use.

I think that adding API for pull style buffering will solve this issue: audio engine can ask for data it's missing.
For example supplying data on demand using HTTP Range requests or reading from NAS.

There is also a case of using decryption on-the-fly, so this feature not limited to HTTP.

Requirements

  • Allow seek in releasing buffer or make a releasing pull buffer with different semantic.
  • Make an API for engine to request specific data range when buffering.
  • Add configurable defaults when to ask for data e.g. 10 seconds before end of buffer while playing.
  • Add configurable defaults for how much of data to ask in a single chunk.
  • Copy supplied data, to allow reusing Uint8List on Dart side.

Additional Context

There is need for an additional logic during initial playback in case user ask to seek from the start, since you must first request file header with metadata and then you can seek to desired position. (Iff we're not supplying raw PCM)

I'm planning to cache played parts of file, but not download entire 2GB over a mobile network. For example first megabyte with metadata and then wherever user seeks to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions