Skip to content

Commit

Permalink
support wavpack v5 alpha 3 API
Browse files Browse the repository at this point in the history
  • Loading branch information
nu774 committed Sep 21, 2016
1 parent 90db1f7 commit 54d41ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wvpacksrc.cpp
Expand Up @@ -27,10 +27,12 @@ WavpackModule::WavpackModule(const std::wstring &path)
CHECK(GetMode = m_dl.fetch( "WavpackGetMode"));
CHECK(GetNumChannels = m_dl.fetch( "WavpackGetNumChannels"));
CHECK(GetNumSamples = m_dl.fetch( "WavpackGetNumSamples"));
GetNumSamples64 = m_dl.fetch( "WavpackGetNumSamples64");
CHECK(GetNumTagItems = m_dl.fetch( "WavpackGetNumTagItems"));
CHECK(GetNumBinaryTagItems =
m_dl.fetch( "WavpackGetNumBinaryTagItems"));
CHECK(GetSampleIndex = m_dl.fetch( "WavpackGetSampleIndex"));
GetSampleIndex64 = m_dl.fetch( "WavpackGetSampleIndex64");
CHECK(GetSampleRate = m_dl.fetch( "WavpackGetSampleRate"));
CHECK(GetTagItem = m_dl.fetch( "WavpackGetTagItem"));
CHECK(GetBinaryTagItem = m_dl.fetch( "WavpackGetBinaryTagItem"));
Expand All @@ -39,6 +41,7 @@ WavpackModule::WavpackModule(const std::wstring &path)
m_dl.fetch( "WavpackGetBinaryTagItemIndexed"));
CHECK(GetWrapperLocation = m_dl.fetch( "WavpackGetWrapperLocation"));
CHECK(SeekSample = m_dl.fetch( "WavpackSeekSample"));
SeekSample64 = m_dl.fetch( "WavpackSeekSample64");
CHECK(UnpackSamples = m_dl.fetch( "WavpackUnpackSamples"));
} catch (...) {
m_dl.reset();
Expand Down Expand Up @@ -148,7 +151,8 @@ WavpackSource::WavpackSource(const WavpackModule &module,
else
m_readSamples = &WavpackSource::readSamples32;

m_length = m_module.GetNumSamples(wpc);
m_length = m_module.GetNumSamples64 ? m_module.GetNumSamples64(wpc)
: m_module.GetNumSamples(wpc);

unsigned mask = m_module.GetChannelMask(wpc);
chanmap::getChannels(mask, &m_chanmap, m_asbd.mChannelsPerFrame);
Expand All @@ -158,13 +162,15 @@ WavpackSource::WavpackSource(const WavpackModule &module,

void WavpackSource::seekTo(int64_t count)
{
if (!m_module.SeekSample(m_wpc.get(), static_cast<int32_t>(count)))
throw std::runtime_error("WavpackSeekSample()");
int rc = m_module.SeekSample64 ? m_module.SeekSample64(m_wpc.get(), count)
: m_module.SeekSample(m_wpc.get(), count);
if (!rc) throw std::runtime_error("WavpackSeekSample()");
}

int64_t WavpackSource::getPosition()
{
return m_module.GetSampleIndex(m_wpc.get());
return m_module.GetSampleIndex64 ? m_module.GetSampleIndex64(m_wpc.get())
: m_module.GetSampleIndex(m_wpc.get());
}

bool WavpackSource::parseWrapper()
Expand Down
3 changes: 3 additions & 0 deletions wvpacksrc.h
Expand Up @@ -29,16 +29,19 @@ class WavpackModule {
int (*GetMode)(WavpackContext *);
int (*GetNumChannels)(WavpackContext *);
uint32_t (*GetNumSamples)(WavpackContext *);
int64_t (*GetNumSamples64)(WavpackContext *);
int (*GetNumTagItems)(WavpackContext *);
int (*GetNumBinaryTagItems)(WavpackContext *);
uint32_t (*GetSampleIndex)(WavpackContext *);
int64_t (*GetSampleIndex64)(WavpackContext *);
uint32_t (*GetSampleRate)(WavpackContext *);
int (*GetTagItem)(WavpackContext *, const char *, char *, int);
int (*GetBinaryTagItem)(WavpackContext *, const char *, char *, int);
int (*GetTagItemIndexed)(WavpackContext *, int, char *, int);
int (*GetBinaryTagItemIndexed)(WavpackContext *, int, char *, int);
void *(*GetWrapperLocation)(void *first_block, uint32_t *size);
int (*SeekSample)(WavpackContext *, uint32_t);
int (*SeekSample64)(WavpackContext *, int64_t);
uint32_t (*UnpackSamples)(WavpackContext *, int32_t *, uint32_t);
};

Expand Down

0 comments on commit 54d41ae

Please sign in to comment.