changeset 26218:29387b9ccfbb

Fix audiodevinfo recording when using 24-bit samples (bug #52228). * audiodevinfo.cc (octave_record_callback, portaudio_record_callback): Set the 32-bit data sample_l32, sample_r32 to 0 at the start of each loop to clear any high bits > 24.
author Rik <rik@octave.org>
date Wed, 12 Dec 2018 21:19:46 -0800
parents 31267a10f8a9
children 471513a016ec
files libinterp/dldfcn/audiodevinfo.cc
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/audiodevinfo.cc	Wed Dec 12 20:56:58 2018 -0800
+++ b/libinterp/dldfcn/audiodevinfo.cc	Wed Dec 12 21:19:46 2018 -0800
@@ -1346,13 +1346,14 @@
       // FIXME: Is there a better way?
       const uint8_t *input24 = static_cast<const uint8_t *> (input);
 
-      int32_t sample_l32 = 0, sample_r32 = 0;
+      int32_t sample_l32, sample_r32;
 
       uint8_t *sample_l = reinterpret_cast<uint8_t *> (&sample_l32);
       uint8_t *sample_r = reinterpret_cast<uint8_t *> (&sample_r32);
 
       for (unsigned long i = 0; i < frames; i++)
         {
+          sample_l32 = sample_r32 = 0;
           for (int j = 0; j < 3; j++)
             {
               sample_l[j] = input24[i*channels*3 + j];
@@ -1423,13 +1424,14 @@
       // FIXME: Is there a better way?
       const uint8_t *input24 = static_cast<const uint8_t *> (input);
 
-      int32_t sample_l32 = 0, sample_r32 = 0;
+      int32_t sample_l32, sample_r32;
 
       uint8_t *sample_l = reinterpret_cast<uint8_t *> (&sample_l32);
       uint8_t *sample_r = reinterpret_cast<uint8_t *> (&sample_r32);
 
       for (unsigned long i = 0; i < frames; i++)
         {
+          sample_l32 = sample_r32 = 0;
           for (int j = 0; j < 3; j++)
             {
               sample_l[j] = input24[i*channels*3 + j];