Add audio stretching support
This commit is contained in:
parent
9cd79c25ed
commit
a6efff8b02
15 changed files with 50 additions and 0 deletions
|
@ -24,6 +24,7 @@ add_library(audio_core STATIC
|
|||
create_target_directory_groups(audio_core)
|
||||
|
||||
target_link_libraries(audio_core PUBLIC common core)
|
||||
target_link_libraries(audio_core PRIVATE SoundTouch)
|
||||
|
||||
if(ENABLE_CUBEB)
|
||||
target_link_libraries(audio_core PRIVATE cubeb)
|
||||
|
|
|
@ -85,6 +85,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
size_t SamplesInQueue(u32 num_channels) const {
|
||||
if (!ctx)
|
||||
return 0;
|
||||
|
||||
return queue.size() / num_channels;
|
||||
}
|
||||
|
||||
u32 GetNumChannels() const {
|
||||
return num_channels;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ public:
|
|||
private:
|
||||
struct NullSinkStreamImpl final : SinkStream {
|
||||
void EnqueueSamples(u32 /*num_channels*/, const std::vector<s16>& /*samples*/) override {}
|
||||
|
||||
size_t SamplesInQueue(u32 /*num_channels*/) const override {
|
||||
return 0;
|
||||
}
|
||||
} null_sink_stream;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ public:
|
|||
* @param samples Samples in interleaved stereo PCM16 format.
|
||||
*/
|
||||
virtual void EnqueueSamples(u32 num_channels, const std::vector<s16>& samples) = 0;
|
||||
|
||||
virtual std::size_t SamplesInQueue(u32 num_channels) const = 0;
|
||||
};
|
||||
|
||||
using SinkStreamPtr = std::unique_ptr<SinkStream>;
|
||||
|
|
|
@ -90,6 +90,7 @@ void Stream::PlayNextBuffer() {
|
|||
queued_buffers.pop();
|
||||
|
||||
VolumeAdjustSamples(active_buffer->Samples());
|
||||
|
||||
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
|
||||
|
||||
CoreTiming::ScheduleEventThreadsafe(GetBufferReleaseCycles(*active_buffer), release_event, {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue