summaryrefslogtreecommitdiff
path: root/asdcplib/src/PCMParserList.cpp
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-01-05 15:32:10 +0000
committerCarl Hetherington <cth@carlh.net>2016-01-05 15:32:10 +0000
commit3ec4338ce90ea0549409312f24f8b28c07a5d2da (patch)
tree09aaaff66dd860abbeacc20793145e1a27f4defd /asdcplib/src/PCMParserList.cpp
parent342aad2ddf893aaaafa9a2c9980579d2dc4ec125 (diff)
asdcplib 2.5.11
Diffstat (limited to 'asdcplib/src/PCMParserList.cpp')
-rwxr-xr-xasdcplib/src/PCMParserList.cpp60
1 files changed, 40 insertions, 20 deletions
diff --git a/asdcplib/src/PCMParserList.cpp b/asdcplib/src/PCMParserList.cpp
index 444b8838..ee5dd3ec 100755
--- a/asdcplib/src/PCMParserList.cpp
+++ b/asdcplib/src/PCMParserList.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2004-2012, John Hurst
+Copyright (c) 2004-2015, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file PCMParserList.cpp
- \version $Id: PCMParserList.cpp,v 1.9 2012/02/21 02:09:31 jhurst Exp $
+ \version $Id: PCMParserList.cpp,v 1.12 2015/02/19 19:06:57 jhurst Exp $
\brief Read WAV file(s), multiplex multiple PCM frame buffers into one
*/
@@ -48,10 +48,8 @@ ASDCP::ParserInstance::~ParserInstance()
// PCM::CalcSampleSize(ADesc);
Result_t
-ASDCP::ParserInstance::OpenRead(const char* filename, const Rational& PictureRate)
+ASDCP::ParserInstance::OpenRead(const std::string& filename, const Rational& PictureRate)
{
- ASDCP_TEST_NULL_STR(filename);
-
Result_t result = Parser.OpenRead(filename, PictureRate);
if ( ASDCP_SUCCESS(result) )
@@ -74,11 +72,18 @@ ASDCP::ParserInstance::PutSample(byte_t* p)
{
ASDCP_TEST_NULL(p);
- memcpy(p, m_p, m_SampleSize);
- m_p += m_SampleSize;
- return RESULT_OK;
-}
+ if ( m_p != 0 )
+ {
+ if ( m_p < ( FB.RoData() + FB.Size() ) )
+ {
+ memcpy(p, m_p, m_SampleSize);
+ m_p += m_SampleSize;
+ return RESULT_OK;
+ }
+ }
+ return RESULT_ENDOFFILE;
+}
//
Result_t
@@ -112,11 +117,14 @@ ASDCP::PCMParserList::~PCMParserList()
Result_t
ASDCP::PCMParserList::OpenRead(ui32_t argc, const char** argv, const Rational& PictureRate)
{
- ASDCP_TEST_NULL_STR(argv);
+ ASDCP_TEST_NULL(argv);
PathList_t TmpFileList;
for ( ui32_t i = 0; i < argc; ++i )
- TmpFileList.push_back(argv[i]);
+ {
+ ASDCP_TEST_NULL(argv[i]);
+ TmpFileList.push_back(argv[i]);
+ }
return OpenRead(TmpFileList, PictureRate);
}
@@ -246,21 +254,23 @@ ASDCP::PCMParserList::ReadFrame(PCM::FrameBuffer& OutFB)
Result_t result = RESULT_OK;
if ( size() == 1 )
- return front()->Parser.ReadFrame(OutFB);
+ {
+ return front()->Parser.ReadFrame(OutFB);
+ }
PCMParserList::iterator self_i;
assert(PCM::CalcFrameBufferSize(m_ADesc) <= OutFB.Capacity());
for ( self_i = begin(); self_i != end() && ASDCP_SUCCESS(result) ; self_i++ )
- result = (*self_i)->ReadFrame();
+ {
+ result = (*self_i)->ReadFrame();
+ }
if ( ASDCP_SUCCESS(result) )
{
- OutFB.Size(PCM::CalcFrameBufferSize(m_ADesc));
-
- // ui32_t sample_size = (PCM::CalcSampleSize(m_ADesc));
byte_t* Out_p = OutFB.Data();
- byte_t* End_p = Out_p + OutFB.Size();
+ byte_t* End_p = Out_p + OutFB.Capacity();
+ ui64_t total_sample_bytes = 0;
while ( Out_p < End_p && ASDCP_SUCCESS(result) )
{
@@ -269,12 +279,22 @@ ASDCP::PCMParserList::ReadFrame(PCM::FrameBuffer& OutFB)
while ( self_i != end() && ASDCP_SUCCESS(result) )
{
result = (*self_i)->PutSample(Out_p);
- Out_p += (*self_i)->SampleSize();
- self_i++;
+
+ if ( ASDCP_SUCCESS(result) )
+ {
+ Out_p += (*self_i)->SampleSize();
+ total_sample_bytes += (*self_i)->SampleSize();
+ self_i++;
+ }
}
}
- assert(Out_p == End_p);
+ OutFB.Size(total_sample_bytes);
+
+ if ( result == RESULT_ENDOFFILE )
+ {
+ result = RESULT_OK;
+ }
}
return result;