/[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 3945 by schoenebeck, Fri Jun 18 15:46:44 2021 UTC
# Line 6414  namespace { Line 6414  namespace {
6414    
6415          SampleList::iterator tmp = SamplesIterator;          SampleList::iterator tmp = SamplesIterator;
6416          // remove all references to the sample          // remove all references to the sample
6417          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          size_t iIns = 0;
6418               instrument = GetNextInstrument()) {          for (Instrument* instrument = GetInstrument(iIns); instrument;
6419                             instrument = GetInstrument(++iIns))
6420            {
6421              size_t iRgn = 0;              size_t iRgn = 0;
6422              for (Region* region = instrument->GetRegionAt(iRgn); region;              for (Region* region = instrument->GetRegionAt(iRgn); region;
6423                   region = instrument->GetRegionAt(++iRgn))                   region = instrument->GetRegionAt(++iRgn))
# Line 6546  namespace { Line 6548  namespace {
6548              __notify_progress(pProgress, 1.0); // notify done              __notify_progress(pProgress, 1.0); // notify done
6549      }      }
6550    
6551        /**
6552         * Returns a pointer to the first <i>Instrument</i> object of the file,
6553         * <i>NULL</i> otherwise.
6554         *
6555         * @deprecated  This method is not reentrant-safe, use GetInstrument()
6556         *              instead.
6557         */
6558      Instrument* File::GetFirstInstrument() {      Instrument* File::GetFirstInstrument() {
6559          if (!pInstruments) LoadInstruments();          if (!pInstruments) LoadInstruments();
6560          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
# Line 6553  namespace { Line 6562  namespace {
6562          return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL );          return static_cast<gig::Instrument*>( (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL );
6563      }      }
6564    
6565        /**
6566         * Returns a pointer to the next <i>Instrument</i> object of the file,
6567         * <i>NULL</i> otherwise.
6568         *
6569         * @deprecated  This method is not reentrant-safe, use GetInstrument()
6570         *              instead.
6571         */
6572      Instrument* File::GetNextInstrument() {      Instrument* File::GetNextInstrument() {
6573          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
6574          InstrumentsIterator++;          InstrumentsIterator++;
# Line 6580  namespace { Line 6596  namespace {
6596       * @param pProgress - optional: callback function for progress notification       * @param pProgress - optional: callback function for progress notification
6597       * @returns  sought instrument or NULL if there's no such instrument       * @returns  sought instrument or NULL if there's no such instrument
6598       */       */
6599      Instrument* File::GetInstrument(uint index, progress_t* pProgress) {      Instrument* File::GetInstrument(size_t index, progress_t* pProgress) {
6600          if (!pInstruments) {          if (!pInstruments) {
6601              // 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)
6602    
# Line 6611  namespace { Line 6627  namespace {
6627              }              }
6628          }          }
6629          if (!pInstruments) return NULL;          if (!pInstruments) return NULL;
6630          InstrumentsIterator = pInstruments->begin();          if (index >= pInstruments->size()) return NULL;
6631          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;  
6632      }      }
6633    
6634      /** @brief Add a new instrument definition.      /** @brief Add a new instrument definition.
# Line 7315  namespace { Line 7327  namespace {
7327    
7328              memset(&pData[48], 0, sublen - 48);              memset(&pData[48], 0, sublen - 48);
7329    
7330              for (Instrument* instrument = GetFirstInstrument() ; instrument ;              size_t iIns = 0;
7331                   instrument = GetNextInstrument()) {              for (Instrument* instrument = GetInstrument(iIns); instrument;
7332                                 instrument = GetInstrument(++iIns))
7333                {
7334                  int nbusedsamples = 0;                  int nbusedsamples = 0;
7335                  int nbusedchannels = 0;                  int nbusedchannels = 0;
7336                  int nbdimregions = 0;                  int nbdimregions = 0;
# Line 7421  namespace { Line 7435  namespace {
7435      void File::UpdateFileOffsets() {      void File::UpdateFileOffsets() {
7436          DLS::File::UpdateFileOffsets();          DLS::File::UpdateFileOffsets();
7437    
7438          for (Instrument* instrument = GetFirstInstrument(); instrument;          size_t i = 0;
7439               instrument = GetNextInstrument())          for (Instrument* instrument = GetInstrument(i); instrument;
7440                             instrument = GetInstrument(++i))
7441          {          {
7442              instrument->UpdateScriptFileOffsets();              instrument->UpdateScriptFileOffsets();
7443          }          }

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

  ViewVC Help
Powered by ViewVC