AudioSource v2

Registered by Uwe Klotz on 2017-07-08

The AudioSource interface that emerged from the infamous SoundSource interface in Mixxx <= 2.0.0 has become a bloated mess. Too many functions with too many responsibilities like up-/downsampling to stereo on demand have been added. This is not only hard to use, but also difficult to implement.

Instead I propose a new AudioSource v2 interface, where audio decoders only need to implement a single function:

IndexRange readSampleFrames(IndexRange frameIndexRange, SampleBuffer::WritableSlice* pOutputBuffer);
// pOutputBuffer == null -> omit writing, i.e. discard decoded sample frames instantly or skip them prematurely during decoding

Improvements:
- No explicit seek operations. Seeking is done as required by each implementation behind the scenes. Mixxx assumes that reading continuously in forward direction does not require any seek operations.
- Clear contract between caller and callee: The source promises only to touch/write that range of the output buffer, which is finally returned as the result range. The result identifies a continuous range of decoded sample frames and is a sub-range of the requested range.
- Instead of identifying ranges of samples/frames separately by both an offset and a count a dedicated range class will be used. This class provides various utility functions for intersecting, joining and generally working with index ranges. It is also testable :)
- If the source is not able to perform up- or downsampling to stereo in-place this is accomplished by a post-processing proxy layer. This approach requires an additional memory copy operation, but is much cleaner and more concise. Remember, premature optimization is evil!! The majority of files is stereo and some decoders support up-/downsampling to stereo out of the box anyway.

Tasks:
- A default implementation of the v2 interface will be provided in the base class that implements the v2 interface on top of the existing (legacy) interface. The legacy interface will be stripped down and the visibility of the functions is reduced from public to protected. All decoders will keep working and might be migrated to a native v2 interface step by step later.
- All calling code in Mixxx will be migrated to the range-based v2 interface. The most effort is needed for the CachingReader component.

Most of the work is done, I'm already testing it.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Uwe Klotz
Direction:
Needs approval
Assignee:
Uwe Klotz
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.