Ejemplo n.º 1
0
pBuffer RenderOperationDesc::Operation::
        process(pBuffer b)
{
    Signal::Interval input = b?b->getInterval ():Signal::Interval();

    b = wrapped_->process (b);

    Signal::Interval output = b?b->getInterval ():Signal::Interval();

    render_target_.write ()->processedData (input, output);

    return b;
}
Ejemplo n.º 2
0
    pBuffer process(pBuffer b) override
    {
        Interval I = b->getInterval ();

        Signal::IntervalType i = std::max(0ll, I.first);
        FLAC__stream_decoder_seek_absolute(decoder, i);
        while (true)
        {
            fmt->block->set_sample_offset (i);
            *b |= *fmt->block;
            i += fmt->last_blocksize;

            if (i>=I.last)
                break;

            if (!FLAC__stream_decoder_process_single (decoder))
            {
                Log("flacfile: failed reading at %d") % i;
                break;
            }
        }

        // if reading before start, zeros
        if (I.first < 0)
            *b |= Buffer(Signal::Interval(I.first, 0), b->sample_rate (), b->number_of_channels ());

        // if b extends EOF, zeros
        if (i < I.last)
            *b |= Buffer(Interval(i,I.last), b->sample_rate (), b->number_of_channels ());

        return b;
    }
Ejemplo n.º 3
0
void Step::
        finishTask(Step::ptr step, int taskid, pBuffer result)
{
    Interval result_interval;
    if (result)
        result_interval = result->getInterval ();

    TASKINFO TaskInfo ti(format("Step::finishTask %2% on %1%")
              % step.raw ()->operation_name()
              % result_interval);

    if (result) {
        // Result must have the same number of channels and sample rate as previous cache.
        // Call deprecateCache(Interval::Interval_ALL) to erase the cache when chainging number of channels or sample rate.
        step.raw ()->cache_->put (result);
    }

    auto self = step.write ();
    int matched_task = self->running_tasks.count (taskid);
    if (1 != matched_task) {
        Log("C = %d, taskid = %x on %s") % matched_task % taskid % self->operation_name ();
        EXCEPTION_ASSERT_EQUALS( 1, matched_task );
    }

    Intervals expected_output = self->running_tasks[ taskid ];

    Intervals update_miss = expected_output - result_interval;
    self->not_started_ |= update_miss;

    if (!result) {
        TASKINFO TaskInfo(format("The task was cancelled. Restoring %1% for %2%")
                 % update_miss
                 % self->operation_name());
    } else {
        if (update_miss) {
            TaskInfo(format("These samples were supposed to be updated by the task but missed: %1% by %2%")
                     % update_miss
                     % self->operation_name());
        }
        if (result_interval - expected_output) {
            // These samples were not supposed to be updated by the task but were calculated anyway
            TaskInfo(format("Unexpected extras: %1% = (%2%) - (%3%) from %4%")
                     % (result_interval - expected_output)
                     % result_interval
                     % expected_output
                     % self->operation_name());

            // The samples are still marked as invalid. Would need to remove the
            // extra calculated samples from not_started_ but that would fail
            // in a situation where deprecatedCache is called after the task has
            // been created. So not_started_ can't be modified here (unless calls
            // to deprecatedCache were tracked).
        }
    }

    self->running_tasks.erase ( taskid );
    self.unlock ();

    step.raw ()->wait_for_tasks_.notify_all ();
}
Ejemplo n.º 4
0
void SinkSource::
        put( pBuffer b )
{
    TIME_SINKSOURCE TaskTimer tt("%s %s", __FUNCTION__, b->getInterval().toString().c_str());

    /* CANONICAL {
        QMutexLocker l(&_mutex);

        // Simply remove previous overlapping buffer, don't bother merging.
        foreach( pBuffer& s, _cache) {
        {
            if (!s)
                s = b;
            else if (s->sample_offset < b->sample_offset+b->number_of_samples() && s->sample_offset + s->number_of_samples() > b->sample_offset)
            {
                s = b;
                b.reset(); // If copied more than once, set others to 0
            }
        }
    }

    _cache.push_back( b );
    */

    merge(b);
}
Ejemplo n.º 5
0
void SinkSource::
        putExpectedSamples( pBuffer buffer, const Intervals& expected )
{
    BufferSource bs( buffer );

    const Intervals I = expected & buffer->getInterval();
    BOOST_FOREACH( const Interval& i, I )
    {
        pBuffer s = bs.readFixedLength( i );
        put( s );
    }
Ejemplo n.º 6
0
pBuffer OperationSetSilent::Operation::
        process (pBuffer b)
{
    Signal::Interval i = section_ & b->getInterval ();

    if (i) {
        Buffer zero(i, b->sample_rate(), b->number_of_channels ());
        *b |= zero;
    }

    return b;
}