Cinnamon audio library
Revision | b92bdd25bc3e9df684639484084ec0addaf33800 (tree) |
---|---|
Zeit | 2019-07-08 02:43:16 |
Autor | AlaskanEmily <emily@alas...> |
Commiter | AlaskanEmily |
Fix off-by-one error in DirectSound backend
@@ -105,10 +105,16 @@ Cin_Sound::Cin_Sound(IDirectSound8 *dsound, const Cin_Loader &ld) | ||
105 | 105 | fmt.Format.wBitsPerSample = bytes_per_sample << 3; |
106 | 106 | |
107 | 107 | // Check the size of the loader data. |
108 | - unsigned byte_size = 0; | |
109 | - for(const struct Cin_LoaderData *i = ld.first, *const end = ld.last; i != end; i = i->next){ | |
110 | - byte_size += i->len; | |
108 | + const unsigned byte_size = ld.bytes_placed; | |
109 | +#ifndef NDEBUG | |
110 | + { | |
111 | + unsigned debug_byte_size = 0; | |
112 | + for(const struct Cin_LoaderData *i = ld.first; i != NULL; i = i->next){ | |
113 | + debug_byte_size += i->len; | |
114 | + } | |
115 | + assert(debug_byte_size == byte_size); | |
111 | 116 | } |
117 | +#endif | |
112 | 118 | |
113 | 119 | DSBUFFERDESC descriptor; |
114 | 120 | descriptor.dwSize = sizeof(DSBUFFERDESC); |