From b14d706a72c706c9c59dbdf64a9e41f32465e060 Mon Sep 17 00:00:00 2001 From: jhurst Date: Tue, 13 Apr 2021 15:50:50 -0700 Subject: o Added a Clone() method to InterchangeObject and derivatives that allows making a descriptor copy that is not owned by any other strucure. The caller must arrange to delete the object pointer returned. o While implementing the above it became obvious that the reference-to-a-pointer-to-the-dictionary idiom that is used throughout the lower levels of the MXF library was the cause of much more grief than it was originally designed to prevent. This was made even more obvious when I replaced all of it with simple pointers, which revealed several shadow instances of m_Dict that were only reliable while the object that held them was valid. --- src/AS_DCP_PCM.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/AS_DCP_PCM.cpp') diff --git a/src/AS_DCP_PCM.cpp b/src/AS_DCP_PCM.cpp index 6241d15..01b02ba 100755 --- a/src/AS_DCP_PCM.cpp +++ b/src/AS_DCP_PCM.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2004-2016, John Hurst +Copyright (c) 2004-2021, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -250,7 +250,7 @@ class ASDCP::PCM::MXFReader::h__Reader : public ASDCP::h__ASDCPReader public: AudioDescriptor m_ADesc; - h__Reader(const Dictionary& d) : ASDCP::h__ASDCPReader(d) {} + h__Reader(const Dictionary *d) : ASDCP::h__ASDCPReader(d) {} virtual ~h__Reader() {} Result_t OpenRead(const std::string&); Result_t ReadFrame(ui32_t, FrameBuffer&, AESDecContext*, HMACContext*); @@ -368,7 +368,7 @@ ASDCP::PCM::FrameBuffer::Dump(FILE* stream, ui32_t dump_len) const ASDCP::PCM::MXFReader::MXFReader() { - m_Reader = new h__Reader(DefaultCompositeDict()); + m_Reader = new h__Reader(&DefaultCompositeDict()); } @@ -523,7 +523,7 @@ public: AudioDescriptor m_ADesc; byte_t m_EssenceUL[SMPTE_UL_LENGTH]; - h__Writer(const Dictionary& d) : ASDCP::h__ASDCPWriter(d) { + h__Writer(const Dictionary *d) : ASDCP::h__ASDCPWriter(d) { memset(m_EssenceUL, 0, SMPTE_UL_LENGTH); } @@ -718,9 +718,9 @@ ASDCP::PCM::MXFWriter::OpenWrite(const std::string& filename, const WriterInfo& const AudioDescriptor& ADesc, ui32_t HeaderSize) { if ( Info.LabelSetType == LS_MXF_SMPTE ) - m_Writer = new h__Writer(DefaultSMPTEDict()); + m_Writer = new h__Writer(&DefaultSMPTEDict()); else - m_Writer = new h__Writer(DefaultInteropDict()); + m_Writer = new h__Writer(&DefaultInteropDict()); m_Writer->m_Info = Info; -- cgit v1.2.3