Changing output buffer size in dsp plugin

From: languy (jn_at_online.stofanet.dk)
Date: 08/26/04


Date: Thu, 26 Aug 2004 11:14:18 +0200

Hi There,

I have created a plugin which is able both to increase and decrease the
speed of an audio sample. In addition to this it will have influenze of the
length of the buffer. I.e. if the speed is increased, then the stream will
be shorter and opposite if the the speed is decreased the length of stream
will be longer. If the speed is slowed down it will unfortunately have the
side effect that the output buffer is overwritten - a buffer overrun -
therefore I need to find a way to realloc this output stream so it matches
the actual length of the stream.

>From the MSDN: "The Player allocates both an input buffer and an output
buffer and gives the plug-in access to both buffers."

What I can understand so far is that both buffers are allocated by the
player before they reach the plugin, which makes it much more complicated to
perform a realloc on them because the plugin doesn't have full control of
all pointers pointing to the buffers. I have already tried a couple of ways
but unfortunately not with a good result. I.e.:

1) performing the realloc in the DoProcessOutput
1.1) both by increasing the existing allocation (realloc) and
destroying/freeing the old and allocating with the new larger size
2) deallocating and allocating in the AllocateStreamingResources
2.1) both by increasing the existing allocation (realloc) and
destroying/freeing the old and allocating with the new larger size
2.2) when allocating, coping all properties from the old buffer into the new
allocated object

Does any one know a way around this, so it is possible to realloc the
buffers and prevent such a buffer overrun?

Thanks in regards,
Jess



Relevant Pages

  • Re: Buffer or Realloc?
    ... better to allocate memory and realloc it for the size of the what is ... between deciding to use a fixed size buffer or allocating memory ...
    (comp.lang.c)
  • Re: Changing output buffer size in dsp plugin
    ... HRESULT ProcessOutput( ... into it, process it, and return the new buffer to ProcessOutput. ... > therefore I need to find a way to realloc this output stream so it matches ... > 2) deallocating and allocating in the AllocateStreamingResources ...
    (microsoft.public.windowsmedia.sdk)
  • Re: slurping in binary data
    ... single-line buffer which I realloc() to a larger size whenever a line ... comes in which is too big for the current buffer size. ... want to waste time allocating a brand new buffer for every single line ... *LINEPTR and *N are updated appropriately. ...
    (comp.lang.c)
  • Re: Buffer or Realloc?
    ... better to allocate memory and realloc it for the size of the what is ... between deciding to use a fixed size buffer or allocating memory ... Fixed size arrays are good for things that whose contents *CANNOT* ... becomes extremely small when I realloc it. ...
    (comp.lang.c)
  • Re: DSP Plugin and threading
    ... > plugin is threaded. ... > for the plugin to continue processing after DoProcessOutput has returned? ... > I.e. if the DoProcessOutput methods takes n bytes, ... > not go beyond n bytes in the outbuffer due to buffer overruns etc. etc. ...
    (microsoft.public.windowsmedia.sdk)