Help - Search - Members - Calendar
Full Version: Can I no longer call insert_chunk from flush in a DSP component?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
psasidisrcum
Hi all,

The dsp_tutorial component from foosion's site (http://foosion.foobar2000.org/0.9.5/foo_dsp_tutorial-1.0.1-20080904-src.zip) has a DSP component that simply buffers some frames and outputs it. This crashes with latest foobar (0.9.6.9) when flush() is invoked, eg. by a simple seek during playback.

The flush() is implemented like this:
CODE
    virtual void flush() {
        // Flush the buffered chunk.
        if (m_chunk_valid) {
            audio_chunk * out = insert_chunk(m_chunk.get_sample_count());
            out->copy(m_chunk);
        }
        // Clear the buffer.
        m_chunk.reset();
        m_chunk_valid = false;
    }


and it crashes at insert_chunk(). Just for reference, on_chunk() looks like this:
CODE
virtual bool on_chunk(audio_chunk * chunk, abort_callback & p_abort) {
        // Output the buffered chunk.
        if (m_chunk_valid) {
            audio_chunk * out = insert_chunk(m_chunk.get_sample_count());
            out->copy(m_chunk);
        }

        // Copy the input chunk to our buffer.
        m_chunk.copy(*chunk);
        m_chunk_valid = true;

        // Return false to keep the input chunk from being added to the output.
        return false;
    }


I also see this comment in the header:
CODE
audio_chunk * insert_chunk(t_size p_hint_size = 0)    //call only from on_endoftrack / on_endofplayback / on_chunk


So, can I not call insert_chunk() from flush()? If so, how do I output any data that I may have saved in my m_chunk?
With the exception of the flush() from insert_chunk(), is the tutorial still a good example of how to do buffering?

Thanks!
Zao
CODE
//! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc.
virtual void flush() = 0;


Rather self-explaining.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.