Halving the volume of a WAV buffer results in all zeros


I’m using SDL2 on different GNU/Linux platforms and I have found something I don’t understand regarding audio.
I am uing the function SDL_MixAudioFormat() to halve the volume of a WAV file.
The WAV file content is loaded to the data buffer, then that buffer is supossed to be processed by SDL_MixAudioFormat() and the result should be stored in the data_vol bufer, with the halved volume.
The problem is that I get all zeros in the data_vol buffer. No errors that I can see. If I bypass this volume halving and use the data buffer directly, it works fine.
But all there is in the data_vol buffer are zeros. Any idea on what am I doing wrong here?


   if( SDL_LoadWAV(filename, &wave, &data, &length) == NULL)
        wavfile.loaded = 0;
    int i;
    for (i = 0; i < length; i++)    
            printf ("WAV pos %d data %d\n", i, data[i]);


    // Halve Volume Of Wav File
    uint8_t* data_vol = new uint8_t[length];
    //SDL_MixAudio(data_vol, data, length, SDL_MIX_MAXVOLUME / 2);
    SDL_MixAudioFormat(data_vol, data, length, wave.format, SDL_MIX_MAXVOLUME / 2);

    // This outputs all zeros...
    for (i = 0; i < length; i++)    
            printf ("WAV VOL HALVED pos %d data_vol %d\n", i, data_vol[i]);