]> git.sesse.net Git - nageru/blobdiff - nageru/audio_mixer.cpp
On errors, abort() instead of exit(1); exit() in a multithreaded program just gives...
[nageru] / nageru / audio_mixer.cpp
index d62f1e180ff7f8a2f14fef69c44b9145763bfa44..9b588d704d63303dccd354a40bafcbc7431f6d69 100644 (file)
@@ -65,8 +65,8 @@ void convert_fixed24_to_fp32(float *dst, size_t out_channel, size_t out_num_chan
                uint32_t s1 = src[0];
                uint32_t s2 = src[1];
                uint32_t s3 = src[2];
-               uint32_t s = s1 | (s1 << 8) | (s2 << 16) | (s3 << 24);
-               *dst = int(s) * (1.0f / 2147483648.0f);
+               uint32_t s = (s1 << 8) | (s2 << 16) | (s3 << 24);  // Note: The bottom eight bits are zero; s3 includes the sign bit.
+               *dst = int(s) * (1.0f / (256.0f * 8388608.0f));  // 256 for signed down-shift by 8, then 2^23 for the actual conversion.
 
                src += 3 * in_num_channels;
                dst += out_num_channels;
@@ -206,7 +206,7 @@ AudioMixer::AudioMixer(unsigned num_capture_cards, unsigned num_ffmpeg_inputs)
                                                  &new_input_mapping)) {
                        fprintf(stderr, "Failed to load input mapping from '%s', exiting.\n",
                                global_flags.input_mapping_filename.c_str());
-                       exit(1);
+                       abort();
                }
                set_input_mapping(new_input_mapping);
        } else {