MHFS-XS
view release on metacpan or search on metacpan
miniaudio/miniaudio.h view on Meta::CPAN
ma_uint64 requiredInputFrameCount;
framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
framesToReadThisIterationIn = framesToReadThisIterationOut;
if (framesToReadThisIterationIn > intermediaryBufferCap) {
framesToReadThisIterationIn = intermediaryBufferCap;
}
ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, framesToReadThisIterationOut, &requiredInputFrameCount);
if (framesToReadThisIterationIn > requiredInputFrameCount) {
framesToReadThisIterationIn = requiredInputFrameCount;
}
if (framesToReadThisIterationIn > 0) {
ma_device__handle_data_callback(pDevice, pIntermediaryBuffer, NULL, (ma_uint32)framesToReadThisIterationIn);
}
/*
At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
input frames, we still want to try processing frames because there may some output frames generated from cached input data.
*/
miniaudio/miniaudio.h view on Meta::CPAN
if (resultALSA < 0) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_poll_descriptors_revents() failed.");
return ma_result_from_errno(-resultALSA);
}
if ((revents & POLLERR) != 0) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] POLLERR detected.");
return ma_result_from_errno(errno);
}
if ((revents & requiredEvent) == requiredEvent) {
break; /* We're done. Data available for reading or writing. */
}
}
return MA_SUCCESS;
}
static ma_result ma_device_wait_read__alsa(ma_device* pDevice)
{
return ma_device_wait__alsa(pDevice, (ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, (struct pollfd*)pDevice->alsa.pPollDescriptorsCapture, pDevice->alsa.pollDescriptorCountCapture + 1, POLLIN); /* +1 to account for the wakeup descriptor. */
miniaudio/miniaudio.h view on Meta::CPAN
if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
continue;
}
bits = caps->enc[iEncoding].bits;
bps = caps->enc[iEncoding].bps;
sig = caps->enc[iEncoding].sig;
le = caps->enc[iEncoding].le;
msb = caps->enc[iEncoding].msb;
format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
if (format != requiredFormat) {
continue;
}
/* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
unsigned int chan = 0;
unsigned int channels;
if (deviceType == ma_device_type_playback) {
chan = caps->confs[iConfig].pchan;
miniaudio/miniaudio.h view on Meta::CPAN
if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
continue;
}
bits = caps->enc[iEncoding].bits;
bps = caps->enc[iEncoding].bps;
sig = caps->enc[iEncoding].sig;
le = caps->enc[iEncoding].le;
msb = caps->enc[iEncoding].msb;
format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
if (format != requiredFormat) {
continue;
}
/* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
unsigned int chan = 0;
unsigned int channels;
unsigned int iRate;
if (deviceType == ma_device_type_playback) {
miniaudio/miniaudio.h view on Meta::CPAN
if ((chan & (1UL << iChannel)) == 0) {
continue;
}
if (deviceType == ma_device_type_playback) {
channels = caps->pchan[iChannel];
} else {
channels = caps->rchan[iChannel];
}
if (channels != requiredChannels) {
continue;
}
/* Getting here means we have found a compatible encoding/channel pair. */
for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) {
ma_uint32 rate = (ma_uint32)caps->rate[iRate];
ma_uint32 ratePriority;
if (firstSampleRate == 0) {
firstSampleRate = rate;
miniaudio/miniaudio.h view on Meta::CPAN
{
ma_uint64 requiredInputFrameCount;
result = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration, &requiredInputFrameCount);
if (result != MA_SUCCESS) {
/* Fall back to a best guess. */
requiredInputFrameCount = (frameCountOutThisIteration * pConverter->resampler.sampleRateIn) / pConverter->resampler.sampleRateOut;
}
if (frameCountInThisIteration > requiredInputFrameCount) {
frameCountInThisIteration = requiredInputFrameCount;
}
}
#endif
if (pConverter->hasPreFormatConversion) {
if (pFramesIn != NULL) {
ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode);
pResampleBufferIn = pTempBufferIn;
} else {
pResampleBufferIn = NULL;
miniaudio/miniaudio.h view on Meta::CPAN
{
ma_uint64 requiredInputFrameCount;
result = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration, &requiredInputFrameCount);
if (result != MA_SUCCESS) {
/* Fall back to a best guess. */
requiredInputFrameCount = (frameCountOutThisIteration * pConverter->resampler.sampleRateIn) / pConverter->resampler.sampleRateOut;
}
if (frameCountInThisIteration > requiredInputFrameCount) {
frameCountInThisIteration = requiredInputFrameCount;
}
}
#endif
/* Pre format conversion. */
if (pConverter->hasPreFormatConversion) {
if (pRunningFramesIn != NULL) {
ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pRunningFramesIn, pConverter->formatIn, frameCountInThisIteration, pConverter->channelsIn, pConverter->ditherMode);
pChannelsBufferIn = pTempBufferIn;
miniaudio/miniaudio.h view on Meta::CPAN
ma_uint64 requiredInputFrameCount;
framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
framesToReadThisIterationIn = framesToReadThisIterationOut;
if (framesToReadThisIterationIn > intermediaryBufferCap) {
framesToReadThisIterationIn = intermediaryBufferCap;
}
ma_data_converter_get_required_input_frame_count(&pDecoder->converter, framesToReadThisIterationOut, &requiredInputFrameCount);
if (framesToReadThisIterationIn > requiredInputFrameCount) {
framesToReadThisIterationIn = requiredInputFrameCount;
}
if (requiredInputFrameCount > 0) {
result = ma_data_source_read_pcm_frames(pDecoder->pBackend, pIntermediaryBuffer, framesToReadThisIterationIn, &framesReadThisIterationIn);
} else {
framesReadThisIterationIn = 0;
}
/*
At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
( run in 0.287 second using v1.01-cache-2.11-cpan-05444aca049 )