view release on metacpan or search on metacpan
lib/App/MHFS.pm view on Meta::CPAN
$contentlength = $end - $start + 1;
}
elsif(defined $size) {
say 'Implicitly setting end to size';
$end = $size - 1;
$contentlength = $end - $start + 1;
}
# no end and size unknown. we have 4 choices:
# set end to the current end (the satisfiable range on RFC 7233 2.1). Dumb clients don't attempt to request the rest of the data ...
# send non partial response (200). This will often disable range requests.
# send multipart. "A server MUST NOT generate a multipart response to a request for a single range"(RFC 7233 4.1) guess not
# LIE, use a large value to signify infinite size. RFC 8673 suggests doing so when client signifies it can.
# Current clients don't however, so lets hope they can.
else {
say 'Implicitly setting end to 999999999999 to signify unknown end';
$end = 999999999999;
}
if($end < $start) {
say "_SendDataItem, end < start";
share/public_html/static/hls.js view on Meta::CPAN
var lastCurrentTime = this.lastCurrentTime,
hls = this.hls;
this.stopLoad();
this.setInterval(100);
this.level = -1;
this.fragLoadError = 0;
if (!this.startFragRequested) {
// determine load level
var startLevel = hls.startLevel;
if (startLevel === -1) {
// -1 : guess start Level by doing a bitrate test by loading first fragment of lowest quality level
startLevel = 0;
this.bitrateTest = true;
}
// set new level to playlist loader : this will trigger start level load
// hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded
this.level = hls.nextLoadLevel = startLevel;
this.loadedmetadata = false;
}
// if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
if (lastCurrentTime > 0 && startPosition === -1) {
share/public_html/static/jsmpeg.min.js view on Meta::CPAN
var JSMpeg={Player:null,VideoElement:null,BitBuffer:null,Source:{},Demuxer:{},Decoder:{},Renderer:{},AudioOutput:{},Now:function(){return window.performance?window.performance.now()/1e3:Date.now()/1e3},CreateVideoElements:function(){var elements=docu...
src++;y|=sY[src]<<16;src++;y|=sY[src]<<24;src++;dY[dest++]=y}dest+=scan>>2;src+=scan}}}width=this.halfWidth;scan=width-8;H=motionH/2>>1;V=motionV/2>>1;oddH=(motionH/2&1)===1;oddV=(motionV/2&1)===1;src=((this.mbRow<<3)+V)*width+(this.mbCol<<3)+H;dest=...
gl.uniform1i(gl.getUniformLocation(this.program,name),index);return texture};WebGLRenderer.prototype.createProgram=function(vsh,fsh){var gl=this.gl;var program=gl.createProgram();gl.attachShader(program,this.compileShader(gl.VERTEX_SHADER,vsh));gl.at...
share/public_html/static/music_inc/src/miniaudio.h view on Meta::CPAN
{
pChannelMap[0] = MA_CHANNEL_MONO;
} break;
case 2:
{
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
} break;
case 3: /* Not defined, but best guess. */
{
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
} break;
case 4:
{
#ifndef MA_USE_QUAD_MICROSOFT_CHANNEL_MAP
/* Surround. Using the Surround profile has the advantage of the 3rd channel (MA_CHANNEL_FRONT_CENTER) mapping nicely with higher channel counts. */
share/public_html/static/music_inc/src/miniaudio.h view on Meta::CPAN
pChannelMap[3] = MA_CHANNEL_BACK_CENTER;
#else
/* Quad. */
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
#endif
} break;
case 5: /* Not defined, but best guess. */
{
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
} break;
case 6:
{
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
pChannelMap[3] = MA_CHANNEL_LFE;
pChannelMap[4] = MA_CHANNEL_SIDE_LEFT;
pChannelMap[5] = MA_CHANNEL_SIDE_RIGHT;
} break;
case 7: /* Not defined, but best guess. */
{
pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
pChannelMap[3] = MA_CHANNEL_LFE;
pChannelMap[4] = MA_CHANNEL_BACK_CENTER;
pChannelMap[5] = MA_CHANNEL_SIDE_LEFT;
pChannelMap[6] = MA_CHANNEL_SIDE_RIGHT;
} break;
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
*/
MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
/*
Calculates an appropriate buffer size from a descriptor, native sample rate and performance profile.
This function is used by backends for helping determine an appropriately sized buffer to use with
the device depending on the values of `periodSizeInFrames` and `periodSizeInMilliseconds` in the
`pDescriptor` object. Since buffer size calculations based on time depends on the sample rate, a
best guess at the device's native sample rate is also required which is where `nativeSampleRate`
comes in. In addition, the performance profile is also needed for cases where both the period size
in frames and milliseconds are both zero.
Parameters
----------
pDescriptor (in)
A pointer to device descriptor whose `periodSizeInFrames` and `periodSizeInMilliseconds` members
will be used for the calculation of the buffer size.
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
This becomes a problem when stopping and then restarting the device. When the device is stopped, it's drained, which requires us to *not*
write anything to the stream. But then, since we didn't write anything to it, the write callback will *never* get called again if we just
resume the stream naively. This means that starting the stream requires us to write data to the stream from outside the callback. This
disconnect is something PulseAudio has got seriously wrong - there should only ever be a single source of data delivery, that being the
callback. (I have tried using `pa_stream_flush()` to trigger the write callback to fire, but this just doesn't work for some reason.)
Once you've created the stream, you need to connect it which involves the whole waiting procedure. This is the same process as the context,
only this time you'll poll for the state with `pa_stream_get_status()`. The starting and stopping of a streaming is referred to as
"corking" in PulseAudio. The analogy is corking a barrel. To start the stream, you uncork it, to stop it you cork it. Personally I think
it's silly - why would you not just call it "starting" and "stopping" like any other normal audio API? Anyway, the act of corking is, you
guessed it, asynchronous. This means you'll need our waiting loop as usual. Again, why this asynchronous design is the default is
absolutely beyond me. Would it really be that hard to just make it run synchronously?
Teardown is pretty simple (what?!). It's just a matter of calling the relevant `_unref()` function on each object in reverse order that
they were initialized in.
That's about it from the PulseAudio side. A bit ranty, I know, but they really need to fix that main loop and callback system. They're
embarrassingly unpractical. The main loop thing is an easy fix - have synchronous versions of all APIs. If an application wants these to
run asynchronously, they can execute them in a separate thread themselves. The desire to run these asynchronously is such a niche
requirement - it makes no sense to make it the default. The stream write callback needs to be change, or an alternative provided, that is
constantly fired, regardless of whether or not `pa_stream_write()` has been called, and it needs to take a pointer to a buffer as a
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
{
if (pDescriptor == NULL) {
return 0;
}
/*
We must have a non-0 native sample rate, but some backends don't allow retrieval of this at the
time when the size of the buffer needs to be determined. In this case we need to just take a best
guess and move on. We'll try using the sample rate in pDescriptor first. If that's not set we'll
just fall back to MA_DEFAULT_SAMPLE_RATE.
*/
if (nativeSampleRate == 0) {
nativeSampleRate = pDescriptor->sampleRate;
}
if (nativeSampleRate == 0) {
nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
}
MA_ASSERT(nativeSampleRate != 0);
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
if (pConverter->hasPostFormatConversion) {
if (frameCountOutThisIteration > tempBufferOutCap) {
frameCountOutThisIteration = tempBufferOutCap;
}
}
/* We need to ensure we don't try to process too many input frames that we run out of room in the output buffer. If this happens we'll end up glitching. */
/*
We need to try to predict how many input frames will be required for the resampler. If the
resampler can tell us, we'll use that. Otherwise we'll need to make a best guess. The further
off we are from this, the more wasted format conversions we'll end up doing.
*/
#if 1
{
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) {
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
}
/*
Before doing any processing we need to determine how many frames we should try processing
this iteration, for both input and output. The resampler requires us to perform format and
channel conversion before passing any data into it. If we get our input count wrong, we'll
end up peforming redundant pre-processing. This isn't the end of the world, but it does
result in some inefficiencies proportionate to how far our estimates are off.
If the resampler has a means to calculate exactly how much we'll need, we'll use that.
Otherwise we'll make a best guess. In order to do this, we'll need to calculate the output
frame count first.
*/
frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
if (frameCountOutThisIteration > tempBufferMidCap) {
frameCountOutThisIteration = tempBufferMidCap;
}
if (pConverter->hasPostFormatConversion) {
if (frameCountOutThisIteration > tempBufferOutCap) {
frameCountOutThisIteration = tempBufferOutCap;
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
if (frameCountInThisIteration > tempBufferMidCap) {
frameCountInThisIteration = tempBufferMidCap;
}
#if 1
{
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
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
} break;
case 2:
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
}
} break;
case 3: /* No defined, but best guess. */
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_FRONT_CENTER;
}
} break;
case 4:
{
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
#else
/* Quad. */
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_BACK_LEFT;
case 3: return MA_CHANNEL_BACK_RIGHT;
#endif
}
} break;
case 5: /* Not defined, but best guess. */
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_FRONT_CENTER;
case 3: return MA_CHANNEL_BACK_LEFT;
case 4: return MA_CHANNEL_BACK_RIGHT;
}
} break;
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_FRONT_CENTER;
case 3: return MA_CHANNEL_LFE;
case 4: return MA_CHANNEL_SIDE_LEFT;
case 5: return MA_CHANNEL_SIDE_RIGHT;
}
} break;
case 7: /* Not defined, but best guess. */
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_FRONT_CENTER;
case 3: return MA_CHANNEL_LFE;
case 4: return MA_CHANNEL_BACK_CENTER;
case 5: return MA_CHANNEL_SIDE_LEFT;
case 6: return MA_CHANNEL_SIDE_RIGHT;
}
share/public_html/static/music_worklet_inprogress/decoder/deps/miniaudio/miniaudio.h view on Meta::CPAN
} break;
case 2:
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
}
} break;
case 3: /* No defined, but best guess. */
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_FRONT_CENTER;
}
} break;
case 4:
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_BACK_LEFT;
case 3: return MA_CHANNEL_BACK_RIGHT;
}
} break;
case 5: /* Not defined, but best guess. */
{
switch (channelIndex) {
case 0: return MA_CHANNEL_FRONT_LEFT;
case 1: return MA_CHANNEL_FRONT_RIGHT;
case 2: return MA_CHANNEL_BACK_LEFT;
case 3: return MA_CHANNEL_BACK_RIGHT;
case 4: return MA_CHANNEL_FRONT_CENTER;
}
} break;
share/public_html/static/music_worklet_inprogress/decoder/src/mhfs_cl_track.h view on Meta::CPAN
}
if(retval == MHFS_CL_SUCCESS)
{
pTrack->meta_initialized = true;
}
pTrack->vf.fileoffset = savefileoffset;
return retval;
}
static inline ma_encoding_format mhfs_cl_guess_codec(const uint8_t *id, const char *mime, const char *fullfilename)
{
const size_t namelen = strlen(fullfilename);
const char *lastFourChars = (namelen >= 4) ? (fullfilename + namelen - 4) : "";
const uint32_t uMagic = unaligned_beu32_to_native(id);
if(memcmp(id, "fLaC", 4) == 0)
{
return ma_encoding_format_flac;
}
else if(memcmp(id, "RIFF", 4) == 0)
{
return ma_encoding_format_wav;
}
// check mpeg sync and verify the audio version id isn't reserved
else if(((uMagic & 0xFFE00000) == 0xFFE00000) && ((uMagic & 0x00180000) != 0x80000))
{
return ma_encoding_format_mp3;
}
// fallback, attempt to speed up guesses by mime
else if(strcmp(mime, "audio/flac") == 0)
{
return ma_encoding_format_flac;
}
else if((strcmp(mime, "audio/wave") == 0) || (strcmp(mime, "audio/wav") == 0))
{
return ma_encoding_format_wav;
}
else if(strcmp(mime, "audio/mpeg") == 0)
{
return ma_encoding_format_mp3;
}
// fallback, fallback attempt to speed up guesses with file extension
else if(strcmp(lastFourChars, "flac") == 0)
{
return ma_encoding_format_flac;
}
else if(strcmp(lastFourChars, ".wav") == 0)
{
return ma_encoding_format_wav;
}
else if(strcmp(lastFourChars, ".mp3") == 0)
{
return ma_encoding_format_mp3;
}
else
{
MHFSCLTR_PRINT("warning: unable to guess format\n");
return ma_encoding_format_unknown;
}
}
typedef struct {
bool initialized;
mhfs_cl_error res;
uint32_t neededOffset;
} mhfs_cl_track_io_error;
share/public_html/static/music_worklet_inprogress/decoder/src/mhfs_cl_track.h view on Meta::CPAN
{
return parseError;
}
if(BLOCKVF_SUCCESS != blockvf_seek(&pTrack->vf, tagSize, blockvf_seek_origin_current))
{
return MHFS_CL_ERROR;
}
}
pTrack->afterID3Offset = pTrack->vf.fileoffset - 4;
// attempt to guess the codec to determine what codec to try first
ma_encoding_format encFmt;
if(pTrack->decoderConfig.encodingFormat == ma_encoding_format_unknown)
{
encFmt = mhfs_cl_guess_codec(id, mime, fullfilename);
}
else
{
encFmt = pTrack->decoderConfig.encodingFormat;
}
ma_encoding_format tryorder[] = { ma_encoding_format_flac, ma_encoding_format_mp3, ma_encoding_format_wav};
const unsigned max_try_count = sizeof(tryorder) / sizeof(tryorder[0]);
if(encFmt == ma_encoding_format_mp3)
{
mhfs_cl_track_swap_tryorder(&tryorder[DAF_MP3], &tryorder[0]);
share/public_html/static/music_worklet_inprogress/player/mhfsplayer.js view on Meta::CPAN
that.artDB = ArtDB();
that.trackdb = {};
that.guiarturl = {};
that.foldermap = FolderMap();
const cdimage = new Blob ([CDIMAGE], { type: 'image/svg+xml' });
that.cdimage = URL.createObjectURL(cdimage);
const SetTrackArt = function(track, url) {
// update the foldermap so we can guess the art for other tracks in the folder / album
that.foldermap.AddArtIfNotExists(track.md.trackname, url);
// set this as definite art for trackname
track.md.artbloburl = url;
// gui needs to reload track art urls
that.gui.UpdateTrackImage(track);
};
const LoadTrackArt = function(track, dectrack) {
if(! track.md.artbloburl) {
let urlToSet;