Eliminate some warnings

This commit is contained in:
Thomas Goyne 2014-07-14 08:55:47 -07:00
parent 771525ae6f
commit 897f9d1254
4 changed files with 18 additions and 9 deletions

View File

@ -31,7 +31,7 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
auto buffer = static_cast<int16_t *>(buf);
for (size_t i = 0; i < (size_t)count; ++i)
buffer[i] = util::mid<int>(-0x8000, buffer[i] * volume + 0.5, 0x7FFF);
buffer[i] = util::mid(-0x8000, static_cast<int>(buffer[i] * volume + 0.5), 0x7FFF);
}
void AudioProvider::ZeroFill(void *buf, int64_t count) const {

View File

@ -39,7 +39,10 @@ public:
bytes_per_sample = sizeof(Target);
}
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
void FillBuffer(void *buf, int64_t start, int64_t count64) const override {
auto count = static_cast<size_t>(count64);
assert(count == count64);
src_buf.resize(count * src_bytes_per_sample * channels);
source->GetAudio(src_buf.data(), start, count);
@ -60,9 +63,9 @@ public:
}
if (static_cast<size_t>(src_bytes_per_sample) > sizeof(Target))
sample /= 1 << (src_bytes_per_sample - sizeof(Target)) * 8;
sample /= 1LL << (src_bytes_per_sample - sizeof(Target)) * 8;
else if (static_cast<size_t>(src_bytes_per_sample) < sizeof(Target))
sample *= 1 << (sizeof(Target) - src_bytes_per_sample ) * 8;
sample *= 1LL << (sizeof(Target) - src_bytes_per_sample ) * 8;
dest[i] = static_cast<Target>(sample);
}
@ -80,7 +83,10 @@ public:
float_samples = false;
}
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
void FillBuffer(void *buf, int64_t start, int64_t count64) const override {
auto count = static_cast<size_t>(count64);
assert(count == count64);
src_buf.resize(count * channels);
source->GetAudio(&src_buf[0], start, count);
@ -111,7 +117,10 @@ public:
channels = 1;
}
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
void FillBuffer(void *buf, int64_t start, int64_t count64) const override {
auto count = static_cast<size_t>(count64);
assert(count == count64);
src_buf.resize(count * src_channels);
source->GetAudio(&src_buf[0], start, count);

View File

@ -52,11 +52,11 @@ class DummyAudioProvider final : public AudioProvider {
if (noise) {
std::default_random_engine e;
std::uniform_int_distribution<int16_t> uniform_dist(-5000, 5000);
for (size_t i = 0; i < count; ++i)
for (int64_t i = 0; i < count; ++i)
static_cast<short *>(buf)[i] = uniform_dist(e);
}
else
memset(buf, 0, count * bytes_per_sample);
memset(buf, 0, static_cast<size_t>(count) * bytes_per_sample);
}
public:

View File

@ -1200,7 +1200,7 @@ static Instruction *fix_l (lua_State *L, int t) {
}
lua_pushvalue(L, base + 2); /* get initial rule */
lua_gettable(L, base + 1); /* get its position in postions table */
i = lua_tonumber(L, -1); /* convert to number */
i = lua_tointeger(L, -1); /* convert to number */
lua_pop(L, 1);
if (i == 0) /* is it defined? */
luaL_error(L, "initial rule not defined in given grammar");