mardi 14 décembre 2021

Error Reading a return of a function from main

I have the following function which reads the header of specific .WAV files using RIFF fmt.

WORD CWav::Read_Header(FILE* WAVF) {

    //Checking For PCM TRUE/FALSE  
    fseek(WAVF, 48, SEEK_SET);
    int16_t num_bytes_in_ext;
    fread(&num_bytes_in_ext, sizeof int16_t, 1, WAVF);
    if (num_bytes_in_ext == 0)
    {
        PCM = true;
    }
    else if (num_bytes_in_ext != 0) PCM = false;

    if (PCM == false) {
        fread(&FCD, 1, sizeof(FMT_CHUNCK_DISCRIPTOR), WAVF);

    }
    else if (PCM == true) fread(&FCD_PCM, 1, sizeof(FMT_CHUNCK_DISCRIPTOR_PCM), WAVF);
    char FMT[5] = "fmt ";
    if (PCM == false && memcmp(FCD.fmt, FMT, sizeof(FCD.fmt)) != 0 || PCM == true && memcmp(FCD_PCM.fmt, FMT, sizeof(FCD_PCM.fmt)) != 0) {
        fseek(WAVF, 24, SEEK_SET);
        fread(&FCD_PCM, 1, sizeof(FMT_CHUNCK_DISCRIPTOR_PCM), WAVF);
        fread(&FCD, 1, sizeof(FMT_CHUNCK_DISCRIPTOR), WAVF);

        if (PCM != true) {
            while (memcmp(FCD.fmt, FMT, sizeof(FCD.fmt)) != 0) {
                fseek(WAVF, FCDSeek++, SEEK_CUR);
                fread(&FCD, 1, sizeof(FMT_CHUNCK_DISCRIPTOR_PCM), WAVF);
            }
        }
        else {
            while (memcmp(FCD_PCM.fmt, FMT, sizeof(FCD_PCM.fmt)) != 0) {
                fseek(WAVF, FCDSeek++, SEEK_CUR);
                fread(&FCD_PCM, 1, sizeof(FMT_CHUNCK_DISCRIPTOR_PCM), WAVF);
            }
        }
    if (PCM == false) {
        BUFFER_SIZE = DSC.Subchunk2Size / (FCD.NumOfChan * (FCD.bitsPerSample / 8));
        SampelsPerSec = FCD.SamplesPerSec;
    }
    else {
        BUFFER_SIZE = DSC.Subchunk2Size / (FCD_PCM.NumOfChan * (FCD_PCM.bitsPerSample / 8));
        SampelsPerSec = FCD_PCM.SamplesPerSec;
    }
    return BUFFER_SIZE;
}

    }

Using the debugger I saw that BUFFER_SIZE was assigned the value 2612 enter image description here

However whenever I call the function Read header from main I never get a return

main.cpp

Wavptr->Read_Header(InFile);
WORD BUFFER_SIZE = Wavptr->Read_Header(InFile);

enter image description here

Aucun commentaire:

Enregistrer un commentaire