Lines Matching refs:vswap

12 int CWVSwapLoad(CWVSwap *vswap, const char *path)  in CWVSwapLoad()  argument
25 vswap->data = malloc(fsize); in CWVSwapLoad()
26 if (fread(vswap->data, 1, fsize, f) != (size_t)fsize) in CWVSwapLoad()
32 memcpy(&vswap->head, vswap->data, sizeof vswap->head); in CWVSwapLoad()
33 vswap->chunkOffset = (uint32_t *)(vswap->data + sizeof vswap->head); in CWVSwapLoad()
34 vswap->chunkLength = (uint16_t *)(vswap->chunkOffset + vswap->head.chunkCount); in CWVSwapLoad()
39 for (int i = vswap->head.firstSound; i < vswap->head.chunkCount - 1; i++) in CWVSwapLoad()
41 const int size = vswap->chunkLength[i]; in CWVSwapLoad()
44 vswap->nSounds++; in CWVSwapLoad()
47 vswap->sounds = calloc(vswap->nSounds, sizeof(CWVSwapSound)); in CWVSwapLoad()
48 for (int i = vswap->head.firstSound, sound = 0; i < vswap->head.chunkCount - 1; i++, sound++) in CWVSwapLoad()
50 const uint32_t off = vswap->chunkOffset[i]; in CWVSwapLoad()
51 uint16_t size = vswap->chunkLength[i]; in CWVSwapLoad()
52 vswap->sounds[sound].off = off; in CWVSwapLoad()
53 vswap->sounds[sound].len = size; in CWVSwapLoad()
57 size = vswap->chunkLength[i]; in CWVSwapLoad()
58 vswap->sounds[sound].len += size; in CWVSwapLoad()
70 void CWVSwapFree(CWVSwap *vswap) in CWVSwapFree() argument
72 free(vswap->data); in CWVSwapFree()
73 free(vswap->sounds); in CWVSwapFree()
76 int CWVSwapGetNumSounds(const CWVSwap *vswap) in CWVSwapGetNumSounds() argument
78 return vswap->head.chunkCount - vswap->head.firstSound; in CWVSwapGetNumSounds()
81 const CWVSwap *vswap, const int i, const char **data, size_t *len) in CWVSwapGetSound() argument
84 if (vswap->sounds[i].off == 0) in CWVSwapGetSound()
89 *len = vswap->sounds[i].len; in CWVSwapGetSound()
90 *data = &vswap->data[vswap->sounds[i].off]; in CWVSwapGetSound()