2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file loader library * |
* libgig - C++ cross-platform Gigasampler format file loader library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003 by Christian Schoenebeck * |
* Copyright (C) 2003-2005 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
192 |
#if DEBUG |
#if DEBUG |
193 |
std::cout << "Chunk::Read(void*,ulong,ulong)" << std::endl; |
std::cout << "Chunk::Read(void*,ulong,ulong)" << std::endl; |
194 |
#endif // DEBUG |
#endif // DEBUG |
195 |
if (ChunkSize - ulPos <= 0) return 0; |
if (ulPos >= ChunkSize) return 0; |
196 |
if (ulPos + WordCount * WordSize >= ChunkSize) WordCount = (ChunkSize - ulPos) / WordSize; |
if (ulPos + WordCount * WordSize >= ChunkSize) WordCount = (ChunkSize - ulPos) / WordSize; |
197 |
#if POSIX |
#if POSIX |
198 |
if (lseek(hFile, ulStartPos + ulPos, SEEK_SET) < 0) return 0; |
if (lseek(hFile, ulStartPos + ulPos, SEEK_SET) < 0) return 0; |
642 |
} |
} |
643 |
|
|
644 |
/** |
/** |
645 |
* Returns number subchunks within the list. |
* Returns number of subchunks within the list. |
646 |
*/ |
*/ |
647 |
unsigned int List::CountSubChunks() { |
unsigned int List::CountSubChunks() { |
648 |
if (!pSubChunks) LoadSubChunks(); |
if (!pSubChunks) LoadSubChunks(); |
721 |
if (!pSubChunks) { |
if (!pSubChunks) { |
722 |
pSubChunks = new ChunkList(); |
pSubChunks = new ChunkList(); |
723 |
pSubChunksMap = new ChunkMap(); |
pSubChunksMap = new ChunkMap(); |
724 |
|
unsigned long uiOriginalPos = GetPos(); |
725 |
|
SetPos(0); // jump to beginning of list chunk body |
726 |
while (RemainingBytes() >= CHUNK_HEADER_SIZE) { |
while (RemainingBytes() >= CHUNK_HEADER_SIZE) { |
727 |
Chunk* ck; |
Chunk* ck; |
728 |
uint32_t ckid; |
uint32_t ckid; |
742 |
(*pSubChunksMap)[ckid] = ck; |
(*pSubChunksMap)[ckid] = ck; |
743 |
if (GetPos() % 2 != 0) SetPos(1, RIFF::stream_curpos); // jump over pad byte |
if (GetPos() % 2 != 0) SetPos(1, RIFF::stream_curpos); // jump over pad byte |
744 |
} |
} |
745 |
|
SetPos(uiOriginalPos); // restore position before this call |
746 |
} |
} |
747 |
} |
} |
748 |
|
|