12#include "stream/MemInputStream.h"
13#include "wav/WavStreamReader.h"
17class OboeAudioPlayer final :
public SkAudioPlayer, oboe::AudioStreamCallback {
21 , fMemInputStream(const_cast<unsigned char *>
22 (static_cast<const unsigned char *>(fData->
data())), static_cast<int32_t>(fData->
size()))
25 fReader = std::make_unique<parselib::WavStreamReader>(&fMemInputStream);
28 fNumSampleFrames = fReader->getNumSampleFrames();
30 oboe::AudioStreamBuilder
builder;
31 builder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
32 builder.setSharingMode(oboe::SharingMode::Exclusive);
33 builder.setSampleRate(fReader->getSampleRate());
34 builder.setChannelCount(fReader->getNumChannels());
36 builder.setFormat(oboe::AudioFormat::Float);
44 oboe::DataCallbackResult
45 onAudioReady(oboe::AudioStream *oboeStream,
void *audioData, int32_t numFrames)
override {
47 float *outBuffer =
static_cast<float *
>(audioData);
48 int framesRead = fReader->getDataFloat(outBuffer, numFrames);
49 fReadFrameIndex += framesRead;
50 int remainingFrames = numFrames - framesRead;
51 if (remainingFrames > 0) {
54 fReader->positionToAudio();
55 fReader->getDataFloat(&outBuffer[framesRead * fReader->getNumChannels()],
57 fReadFrameIndex += remainingFrames;
60 renderSilence(&outBuffer[framesRead * fReader->getNumChannels()], remainingFrames);
61 return oboe::DataCallbackResult::Stop;
64 return oboe::DataCallbackResult::Continue;
67 void renderSilence(
float *
start,
int numFrames) {
68 for (
int i = 0;
i < numFrames * fReader->getNumChannels(); ++
i) {
73 return fNumSampleFrames * fStream->getChannelCount() / fStream->getSampleRate();
77 return (fReadFrameIndex * fStream->getChannelCount()) / fStream->getSampleRate();
81 fReadFrameIndex = (t * fStream->getSampleRate()) / fStream->getChannelCount();
107 std::shared_ptr<oboe::AudioStream> fStream;
108 std::unique_ptr<parselib::WavStreamReader> fReader;
109 parselib::MemInputStream fMemInputStream;
110 int32_t fReadFrameIndex {0};
111 int fNumSampleFrames;
112 bool fIsLooping {
false};
118 return std::unique_ptr<SkAudioPlayer>(
new OboeAudioPlayer(std::move(
src)));
virtual double onSetTime(double)=0
static std::unique_ptr< SkAudioPlayer > Make(sk_sp< SkData >)
virtual double onGetDuration() const =0
virtual double onGetTime() const =0
virtual float onSetVolume(float)=0
virtual State onSetState(State)=0
virtual float onSetRate(float)=0
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data