vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / plugins / ape_reader / MAClib / APECompress.h
bloba9bbe5679d9981786abe811190bafd1a9ec5864d
1 #ifndef APE_APECOMPRESS_H
2 #define APE_APECOMPRESS_H
4 #include "MACLib.h"
5 class CAPECompressCreate;
7 /*************************************************************************************************
8 CAPECompress - uses the CAPECompressHub to provide a simpler compression interface (with buffering, etc)
9 *************************************************************************************************/
10 class CAPECompress : public IAPECompress
12 public:
14 CAPECompress();
15 ~CAPECompress();
17 // start encoding
18 int Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
19 int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
21 // add data / compress data
23 // allows linear, immediate access to the buffer (fast)
24 int GetBufferBytesAvailable();
25 int UnlockBuffer(int nBytesAdded, BOOL bProcess = TRUE);
26 unsigned char * LockBuffer(int * pBytesAvailable);
28 // slower, but easier than locking and unlocking (copies data)
29 int AddData(unsigned char * pData, int nBytes);
31 // use a CIO (input source) to add data
32 int AddDataFromInputSource(CInputSource * pInputSource, int nMaxBytes = -1, int * pBytesAdded = NULL);
34 // finish / kill
35 int Finish(unsigned char * pTerminatingData, int nTerminatingBytes, int nWAVTerminatingBytes);
36 int Kill();
38 private:
40 int ProcessBuffer(BOOL bFinalize = FALSE);
42 CSmartPtr<CAPECompressCreate> m_spAPECompressCreate;
44 int m_nBufferHead;
45 int m_nBufferTail;
46 int m_nBufferSize;
47 unsigned char * m_pBuffer;
48 BOOL m_bBufferLocked;
50 CIO * m_pioOutput;
51 BOOL m_bOwnsOutputIO;
52 WAVEFORMATEX m_wfeInput;
56 #endif // #ifndef APE_APECOMPRESS_H