X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Fchunk_compressor.h;h=265e1362438a39c9238fe9d67657d65cf2d59f27;hp=b902038a393b2556b07a80f1836a5d8dbd3a9a29;hb=5fce6aa92826ec69fdeeea13e28292fa1fbb43a8;hpb=f675c45459508d058aeda4869e2928be4b7ffd99 diff --git a/include/wimlib/chunk_compressor.h b/include/wimlib/chunk_compressor.h index b902038a..265e1362 100644 --- a/include/wimlib/chunk_compressor.h +++ b/include/wimlib/chunk_compressor.h @@ -7,7 +7,7 @@ #ifndef _WIMLIB_CHUNK_COMPRESSOR_H #define _WIMLIB_CHUNK_COMPRESSOR_H -#include +#include "wimlib/types.h" /* Interface for chunk compression. Users can submit chunks of data to be * compressed, then retrieve them later in order. This interface can be @@ -23,16 +23,20 @@ struct chunk_compressor { /* Free the chunk compressor. */ void (*destroy)(struct chunk_compressor *); - /* Submit a chunk of uncompressed data for compression. + /* Try to borrow a buffer into which the uncompressed data for the next + * chunk should be prepared. * - * The chunk must have size greater than 0 and less than or equal to - * @out_chunk_size. + * Only one buffer can be borrowed at a time. * - * The return value is %true if the chunk was successfully submitted, or - * %false if the chunk compressor does not have space for the chunk at - * the present time. In the latter case, get_chunk() must be called to - * retrieve a compressed chunk before trying again. */ - bool (*submit_chunk)(struct chunk_compressor *, const void *, size_t); + * Returns a pointer to the buffer, or NULL if no buffer is available. + * If no buffer is available, you must call ->get_compression_result() + * to retrieve a compressed chunk before trying again. */ + void *(*get_chunk_buffer)(struct chunk_compressor *); + + /* Signals to the chunk compressor that the buffer which was loaned out + * from ->get_chunk_buffer() has finished being filled and contains the + * specified number of bytes of uncompressed data. */ + void (*signal_chunk_filled)(struct chunk_compressor *, u32); /* Get the next chunk of compressed data. * @@ -52,8 +56,8 @@ struct chunk_compressor { * The return value is %true if a chunk of compressed data was * successfully retrieved, or %false if there are no chunks currently * being compressed. */ - bool (*get_chunk)(struct chunk_compressor *, - const void **, u32 *, u32 *); + bool (*get_compression_result)(struct chunk_compressor *, + const void **, u32 *, u32 *); };