--- libgig/trunk/src/gig.cpp 2021/06/15 12:22:26 3929 +++ libgig/trunk/src/gig.cpp 2021/06/17 09:21:11 3933 @@ -6122,6 +6122,26 @@ } /** + * Returns Sample object at @a index of this sample group. + * + * @param index - position of sample in this sample group's sample list + * (0..n) + * @returns sample object or NULL if index is out of bounds + */ + Sample* Group::GetSample(size_t index) { + if (pFile->pSamples && index >= pFile->pSamples->size()) return NULL; + size_t indexInFile = 0; + size_t indexInGroup = 0; + for (Sample* pSample = pFile->GetSample(indexInFile); pSample; + pSample = pFile->GetSample(++indexInFile)) + { + if (pSample->GetGroup() != this) continue; + if (indexInGroup++ == index) return pSample; + } + return NULL; + } + + /** * Returns the first Sample of this Group. You have to call this method * once before you use GetNextSample(). * @@ -6131,6 +6151,8 @@ * @returns pointer address to first Sample or NULL if there is none * applied to this Group * @see GetNextSample() + * @deprecated This method is not reentrant-safe, use GetSample() + * instead. */ Sample* Group::GetFirstSample() { size_t& i = this->SamplesIterator; @@ -6153,6 +6175,8 @@ * @returns pointer address to the next Sample of this Group or NULL if * end reached * @see GetFirstSample() + * @deprecated This method is not reentrant-safe, use GetSample() + * instead. */ Sample* Group::GetNextSample() { size_t& i = this->SamplesIterator;