#pragma once

#include "kmp_pi.h"
#include "kpi_decoder.h"
#include "kpi_impl.h"
#include "WavPack/sources/include/wavpack.h"

class KbWavPackDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    enum{
        TEMP_BUFSIZE_SAMPLE = 1024
    };
    KPI_MEDIAINFO   m_MediaInfo;
    WavpackContext *m_pContext;
    int32_t  *m_pTempBuf;
    IKpiFile *m_pFile;
    IKpiFile *m_pFileWvc;
    DWORD     m_dwBlockAlign;
    UINT64    m_qwDecodeSample;
    BOOL      m_bDecodeDone;
public:
    DWORD __fastcall Open(const KPI_MEDIAINFO *cpRequest,
                          IKpiFile   *pFile,
                          IKpiFolder *pFolder);
    DWORD  WINAPI Select(DWORD dwNumber,
                         const KPI_MEDIAINFO **ppMediaInfo,
                         IKpiTagInfo *pTagInfo,
                         DWORD dwTagGetFlags);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    void __fastcall GetTagInfo(IKpiTagInfo *pTagInfo, DWORD dwTagGetFlags);
    KbWavPackDecoder(void);
    ~KbWavPackDecoder(void);
};
