X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fkaeru.cpp;h=32b497d200f924c7289c146759094e75bd9c199e;hb=7afceebf4b8feb5e72fb4b894686deb2b7527502;hp=9d9738391082a484cf3338361c2746aff1aa5ec7;hpb=b2313d869262960aa3bcaaf3f45f2a3b90d1fc18;p=nageru diff --git a/nageru/kaeru.cpp b/nageru/kaeru.cpp index 9d97383..32b497d 100644 --- a/nageru/kaeru.cpp +++ b/nageru/kaeru.cpp @@ -104,17 +104,18 @@ void video_frame_callback(FFmpegCapture *video, X264Encoder *x264_encoder, Audio size_t num_samples = audio_frame.len / (audio_format.bits_per_sample / 8); vector float_samples; float_samples.resize(num_samples); + if (audio_format.bits_per_sample == 16) { const int16_t *src = (const int16_t *)audio_frame.data; float *dst = &float_samples[0]; for (size_t i = 0; i < num_samples; ++i) { - *dst++ = le16toh(*src++) * (1.0f / 32768.0f); + *dst++ = int16_t(le16toh(*src++)) * (1.0f / 32768.0f); } } else if (audio_format.bits_per_sample == 32) { const int32_t *src = (const int32_t *)audio_frame.data; float *dst = &float_samples[0]; for (size_t i = 0; i < num_samples; ++i) { - *dst++ = le32toh(*src++) * (1.0f / 2147483648.0f); + *dst++ = int32_t(le32toh(*src++)) * (1.0f / 2147483648.0f); } } else { assert(false); @@ -172,7 +173,7 @@ int main(int argc, char *argv[]) parse_flags(PROGRAM_KAERU, argc, argv); if (optind + 1 != argc) { usage(PROGRAM_KAERU); - exit(1); + abort(); } global_flags.num_cards = 1; // For latency metrics. @@ -209,7 +210,7 @@ int main(int argc, char *argv[]) } video.configure_card(); video.start_bm_capture(); - video.change_rate(2.0); // Be sure never to really fall behind, but also don't dump huge amounts of stuff onto x264. + video.change_rate(10.0); // Play as fast as possible. BasicStats basic_stats(/*verbose=*/false, /*use_opengl=*/false); global_basic_stats = &basic_stats;