/[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 3941 by schoenebeck, Fri Jun 18 14:06:20 2021 UTC revision 3946 by schoenebeck, Fri Jun 18 15:51:32 2021 UTC
# Line 6412  namespace { Line 6412  namespace {
6412          pSample->DeleteChunks();          pSample->DeleteChunks();
6413          delete pSample;          delete pSample;
6414    
         SampleList::iterator tmp = SamplesIterator;  
6415          // remove all references to the sample          // remove all references to the sample
6416          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          size_t iIns = 0;
6417               instrument = GetNextInstrument()) {          for (Instrument* instrument = GetInstrument(iIns); instrument;
6418                             instrument = GetInstrument(++iIns))
6419            {
6420              size_t iRgn = 0;              size_t iRgn = 0;
6421              for (Region* region = instrument->GetRegionAt(iRgn); region;              for (Region* region = instrument->GetRegionAt(iRgn); region;
6422                   region = instrument->GetRegionAt(++iRgn))                   region = instrument->GetRegionAt(++iRgn))
# Line 6428  namespace { Line 6429  namespace {
6429                  }                  }
6430              }              }
6431          }          }
         SamplesIterator = tmp; // restore iterator  
6432      }      }
6433    
6434      void File::LoadSamples() {      void File::LoadSamples() {
# Line 6546  namespace { Line 6546  namespace {
6546              __notify_progress(pProgress, 1.0); // notify done              __notify_progress(pProgress, 1.0); // notify done
6547      }      }
6548    
6549        /**
6550         * Returns a pointer to the first <i>Instrument</i> object of the file,
6551         * <i>NULL</i> otherwise.
6552         *
6553         * @deprecated  This method is not reentrant-safe, use GetInstrument()
6554         *              instead.
6555         */
6556      Instrument* File::GetFirstInstrument() {      Instrument* File::GetFirstInstrument() {
6557          if (!pInstruments) LoadInstruments();          if (!pInstruments) LoadInstruments();
6558          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
# Line 6553  namespace { Line 6560  namespace {
6560          return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL );          return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL );
6561      }      }
6562    
6563        /**
6564         * Returns a pointer to the next <i>Instrument</i> object of the file,
6565         * <i>NULL</i> otherwise.
6566         *
6567         * @deprecated  This method is not reentrant-safe, use GetInstrument()
6568         *              instead.
6569         */
6570      Instrument* File::GetNextInstrument() {      Instrument* File::GetNextInstrument() {
6571          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
6572          InstrumentsIterator++;          InstrumentsIterator++;
# Line 6580  namespace { Line 6594  namespace {
6594       * @param pProgress - optional: callback function for progress notification       * @param pProgress - optional: callback function for progress notification
6595       * @returns  sought instrument or NULL if there's no such instrument       * @returns  sought instrument or NULL if there's no such instrument
6596       */       */
6597      Instrument* File::GetInstrument(uint index, progress_t* pProgress) {      Instrument* File::GetInstrument(size_t index, progress_t* pProgress) {
6598          if (!pInstruments) {          if (!pInstruments) {
6599              // TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM)              // TODO: hack - we simply load ALL samples here, it would have been done in the Region constructor anyway (ATM)
6600    
# Line 6611  namespace { Line 6625  namespace {
6625              }              }
6626          }          }
6627          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
6628          InstrumentsIterator = pInstruments->begin();          if (index >= pInstruments->size()) return NULL;
6629          for (uint i = 0; InstrumentsIterator != pInstruments->end(); i++) {          return static_cast<gig::Instrument*>( (*pInstruments)[index] );
             if (i == index) return static_cast<gig::Instrument*>( *InstrumentsIterator );  
             InstrumentsIterator++;  
         }  
         return NULL;  
6630      }      }
6631    
6632      /** @brief Add a new instrument definition.      /** @brief Add a new instrument definition.
# Line 7315  namespace { Line 7325  namespace {
7325    
7326              memset(&pData[48], 0, sublen - 48);              memset(&pData[48], 0, sublen - 48);
7327    
7328              for (Instrument* instrument = GetFirstInstrument() ; instrument ;              size_t iIns = 0;
7329                   instrument = GetNextInstrument()) {              for (Instrument* instrument = GetInstrument(iIns); instrument;
7330                                 instrument = GetInstrument(++iIns))
7331                {
7332                  int nbusedsamples = 0;                  int nbusedsamples = 0;
7333                  int nbusedchannels = 0;                  int nbusedchannels = 0;
7334                  int nbdimregions = 0;                  int nbdimregions = 0;
# Line 7421  namespace { Line 7433  namespace {
7433      void File::UpdateFileOffsets() {      void File::UpdateFileOffsets() {
7434          DLS::File::UpdateFileOffsets();          DLS::File::UpdateFileOffsets();
7435    
7436          for (Instrument* instrument = GetFirstInstrument(); instrument;          size_t i = 0;
7437               instrument = GetNextInstrument())          for (Instrument* instrument = GetInstrument(i); instrument;
7438                             instrument = GetInstrument(++i))
7439          {          {
7440              instrument->UpdateScriptFileOffsets();              instrument->UpdateScriptFileOffsets();
7441          }          }

Legend:
Removed from v.3941  
changed lines
  Added in v.3946

  ViewVC Help
Powered by ViewVC