0

I have a proprietary library lets say libX.

libX is a Speech Recognition and has a function to write to a wav(In my case it's pcm).

The function let's libX write has this definition:

void Write
(
    FILE * const p,
    const float * const * const buffer,
    const float range,
    const size_t frameToBeWritten,
    size_t * const frameWritten
);

I have managed to fill a buffer which is float **, however I still get segmentation fault.

My question How would one go about fixing this problem.

I have a working example of this function, however that example doesn't do justice to the implementation,checked gdb with function PrintArray, since I investigated how the working example float ** is being filled :

void PrintArray(float ** a,int channels,int buffer_length){
      int i;
      int j; 
        for (i=0; i<channels; i++)
        {
            printf("===========================");
            printf("Channel %d \n",i);
            for (j=0; j<buffer_length; j++)
            {
                printf("%f  ", a[i][j]);
            }
            printf("\n");
        }
}

In both my code and the example code, the arrays are being filled correctly I couldn't find any differences betweem my float ** and the working example float **

For more code please refer to: Filling up float ** from int16_t *

Gent Binaku
  • 55
  • 11
  • Using a VLA: `void PrintArray(int channels, int buffer_length, float (*a)[buffer_length]){` notice the order of the arguments changed. – David Ranieri Jun 25 '20 at 08:39
  • I understand that, but this is trying to print out values I need to see how the buffer is being filled. I didn't notice any differences between my buffer and the working example buffer – Gent Binaku Jun 25 '20 at 08:40
  • That `Write` API looks rather questionable. I wouldn't trust code written by people who spam pointless qualifiers all over the place, just because they can. This is _not_ proper const correctness, it's just obfuscation. – Lundin Jun 25 '20 at 11:52

0 Answers0