Hi, I've been working with oggvorbis-win32sdk-1.0.1 and have a semi-hypothetical question. Let's suppose that, for whatever reason, I've allocated a block of memory, and I've loaded into this memory a perfectly valid ogg vorbis file. Now I'd like to decode this vorbis data, but I'm stuck calling ov_open() because I don't have a FILE*, I have a block of memory. (This may in fact be an ignorant stdio question on my part; if so, I apologize). But - what do I do? (Sure, I could push this memory back down into a temp file and decode that, but that seems terribly wasteful....) Certainly the capability exists to decode a block of vorbis data in memory that's not necessarily backed by a file on disk? I haven't been able to find an example, though. Please help me. Thanks, M. Szinger
On 6/30/05, Szinger, Martin R. <Martin.Szinger@gd-ais.com> wrote:> Hi, > > I've been working with oggvorbis-win32sdk-1.0.1 and have a > semi-hypothetical question. > > Let's suppose that, for whatever reason, I've allocated a block of > memory, and I've loaded into this memory a perfectly valid ogg vorbis > file. > > Now I'd like to decode this vorbis data, but I'm stuck calling ov_open() > because I don't have a FILE*, I have a block of memory. (This may in > fact be an ignorant stdio question on my part; if so, I apologize). But > - what do I do?This is what ov_open_callbacks() is for (ov_open is in fact just a simple wrapper around ov_open_callbacks() that passes appropriate file-based callbacks). This function lets you pass a structure containing a set of callbacks (4 of them: one to read data, one to seek, one to tell the current stream position, and one to close the stream). If you have a memory buffer, these callbacks are really easy to write (shouldn't be more than a few minutes work). Mike
> Let's suppose that, for whatever reason, I've allocated a block of > memory, and I've loaded into this memory a perfectly valid ogg vorbis > file. > > Now I'd like to decode this vorbis data, but I'm stuck calling ov_open() > because I don't have a FILE*, I have a block of memory. (This may in > fact be an ignorant stdio question on my part; if so, I apologize). But > - what do I do?Use ov_open_callbacks. jack.