summaryrefslogtreecommitdiffstats
path: root/src/sources/audiosourcestereoproxy.h
blob: e94e7ba7b46910a00cdd6f59341363b18c6b10bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "sources/audiosourceproxy.h"

namespace mixxx {

class AudioSourceStereoProxy : public AudioSourceProxy {
  public:
    static AudioSourcePointer create(
            AudioSourcePointer pAudioSource,
            SINT maxReadableFrames) {
        return std::make_shared<AudioSourceStereoProxy>(
                pAudioSource,
                maxReadableFrames);
    }

    // Create an instance with its own temporary buffer
    AudioSourceStereoProxy(
            AudioSourcePointer pAudioSource,
            SINT maxReadableFrames);
    // Create an instance that borrows a writable slice of a
    // temporary buffer owned by the caller
    AudioSourceStereoProxy(
            AudioSourcePointer pAudioSource,
            SampleBuffer::WritableSlice tempWritableSlice);
    ~AudioSourceStereoProxy() override = default;

  protected:
    ReadableSampleFrames readSampleFramesClamped(
            const WritableSampleFrames& writableSampleFrames) override;

  private:
    SampleBuffer m_tempSampleBuffer;
    SampleBuffer::WritableSlice m_tempWritableSlice;
};

} // namespace mixxx