audio_core: Implement Sink and SinkStream interfaces with cubeb.
This commit is contained in:
parent
f1f3a65391
commit
0ba0cdbed9
10 changed files with 269 additions and 6 deletions
|
@ -7,6 +7,8 @@
|
|||
#include "core/core_timing.h"
|
||||
#include "core/core_timing_util.h"
|
||||
|
||||
#include "audio_core/sink.h"
|
||||
#include "audio_core/sink_details.h"
|
||||
#include "audio_core/stream.h"
|
||||
|
||||
namespace AudioCore {
|
||||
|
@ -31,6 +33,11 @@ u32 Stream::GetSampleSize() const {
|
|||
return GetNumChannels() * 2;
|
||||
}
|
||||
|
||||
Stream::Stream(u32 sample_rate, Format format, ReleaseCallback&& release_callback,
|
||||
SinkStream& sink_stream)
|
||||
: sample_rate{sample_rate}, format{format}, release_callback{std::move(release_callback)},
|
||||
sink_stream{sink_stream} {
|
||||
|
||||
release_event = CoreTiming::RegisterEvent(
|
||||
"Stream::Release", [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); });
|
||||
}
|
||||
|
@ -68,6 +75,10 @@ void Stream::PlayNextBuffer() {
|
|||
active_buffer = queued_buffers.front();
|
||||
queued_buffers.pop();
|
||||
|
||||
sink_stream.EnqueueSamples(GetNumChannels(),
|
||||
reinterpret_cast<const s16*>(active_buffer->GetData().data()),
|
||||
active_buffer->GetData().size() / GetSampleSize());
|
||||
|
||||
CoreTiming::ScheduleEventThreadsafe(GetBufferReleaseCycles(*active_buffer), release_event, {});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue