--- libgig/trunk/src/gig.cpp 2021/06/15 11:00:50 3927
+++ libgig/trunk/src/gig.cpp 2021/06/15 11:38:38 3928
@@ -6270,6 +6270,14 @@
}
}
+ /**
+ * Returns a pointer to the first Sample object of the file,
+ * NULL otherwise.
+ *
+ * @param pProgress - optional: callback function for progress notification
+ * @deprecated This method is not reentrant-safe, use GetSample()
+ * instead.
+ */
Sample* File::GetFirstSample(progress_t* pProgress) {
if (!pSamples) LoadSamples(pProgress);
if (!pSamples) return NULL;
@@ -6277,6 +6285,13 @@
return static_cast( (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL );
}
+ /**
+ * Returns a pointer to the next Sample object of the file,
+ * NULL otherwise.
+ *
+ * @deprecated This method is not reentrant-safe, use GetSample()
+ * instead.
+ */
Sample* File::GetNextSample() {
if (!pSamples) return NULL;
SamplesIterator++;
@@ -6286,18 +6301,15 @@
/**
* Returns Sample object of @a index.
*
+ * @param index - position of sample in sample list (0..n)
+ * @param pProgress - optional: callback function for progress notification
* @returns sample object or NULL if index is out of bounds
*/
- Sample* File::GetSample(uint index) {
- if (!pSamples) LoadSamples();
+ Sample* File::GetSample(size_t index, progress_t* pProgress) {
+ if (!pSamples) LoadSamples(pProgress);
if (!pSamples) return NULL;
- DLS::File::SampleList::iterator it = pSamples->begin();
- for (int i = 0; i < index; ++i) {
- ++it;
- if (it == pSamples->end()) return NULL;
- }
- if (it == pSamples->end()) return NULL;
- return static_cast( *it );
+ if (index >= pSamples->size()) return NULL;
+ return static_cast( (*pSamples)[index] );
}
/**