/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3970 by schoenebeck, Thu Jun 24 11:49:31 2021 UTC revision 3977 by schoenebeck, Mon Jul 19 14:31:43 2021 UTC
# Line 1346  namespace { Line 1346  namespace {
1346    
1347          // if this is the last write, update the checksum chunk in the          // if this is the last write, update the checksum chunk in the
1348          // file          // file
1349          if (pCkData->GetPos() == pCkData->GetSize()) {          if (pCkData->GetPos() == std::min(pCkData->GetSize(), pCkData->GetNewSize())) {
1350              __finalizeCRC(crc);              __finalizeCRC(crc);
1351              File* pFile = static_cast<File*>(GetParent());              File* pFile = static_cast<File*>(GetParent());
1352              pFile->SetSampleChecksum(this, crc);              pFile->SetSampleChecksum(this, crc);
# Line 5353  namespace { Line 5353  namespace {
5353          if (!lrgn)  lrgn = pCkInstrument->AddSubList(LIST_TYPE_LRGN);          if (!lrgn)  lrgn = pCkInstrument->AddSubList(LIST_TYPE_LRGN);
5354          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);
5355          Region* pNewRegion = new Region(this, rgn);          Region* pNewRegion = new Region(this, rgn);
5356            const size_t idxIt = RegionsIterator - pRegions->begin();
5357          pRegions->push_back(pNewRegion);          pRegions->push_back(pNewRegion);
5358            RegionsIterator = pRegions->begin() + std::min(idxIt, pRegions->size()); // avoid iterator invalidation
5359          Regions = (uint32_t) pRegions->size();          Regions = (uint32_t) pRegions->size();
5360          // update Region key table for fast lookup          // update Region key table for fast lookup
5361          UpdateRegionKeyTable();          UpdateRegionKeyTable();
# Line 6389  namespace { Line 6391  namespace {
6391         wave->AddSubChunk(CHUNK_ID_FMT, 16);         wave->AddSubChunk(CHUNK_ID_FMT, 16);
6392         wave->AddSubList(LIST_TYPE_INFO);         wave->AddSubList(LIST_TYPE_INFO);
6393    
6394           const size_t idxIt = SamplesIterator - pSamples->begin();
6395         pSamples->push_back(pSample);         pSamples->push_back(pSample);
6396           SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation
6397         return pSample;         return pSample;
6398      }      }
6399    
# Line 6406  namespace { Line 6410  namespace {
6410          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");
6411          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);
6412          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");
6413          if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation          const size_t idxIt = SamplesIterator - pSamples->begin();
6414          pSamples->erase(iter);          pSamples->erase(iter);
6415            SamplesIterator = pSamples->begin() + std::min(idxIt, pSamples->size()); // avoid iterator invalidation
6416          pSample->DeleteChunks();          pSample->DeleteChunks();
6417          delete pSample;          delete pSample;
6418    

Legend:
Removed from v.3970  
changed lines
  Added in v.3977

  ViewVC Help
Powered by ViewVC