The problem of sound delay in record.cpp

Hello, I am using record.cpp demo to develop record sound function, the record code is right running and my headphone also and listen playback, but, these is a serious problem, the playback sound is about 10% delay compare to my recording voice, it result in my record music experience is disorder, some relate code is underline:

        lastPlayPos = playPos;
        samplesPlayed += playDelta;

        /*
            Compensate for any drift.
        */
        int latency = samplesRecorded - samplesPlayed;
        actualLatency = (0.97f * actualLatency) + (0.03f * latency);

        int playbackRate = nativeRate;
        if (actualLatency < (int) (adjustedLatency - driftThreshold)) {
            /* Play position is catching up to the record position, slow playback down by 2% */
            playbackRate = nativeRate - (nativeRate / 50);
        } else if (actualLatency > (int) (adjustedLatency + driftThreshold)) {
            /* Play position is falling behind the record position, speed playback up by 2% */
            playbackRate = nativeRate + (nativeRate / 50);
        }

        channel->setFrequency((float) playbackRate);
        ERRCHECK(result);

Is someone has met such problem? hope you can tell me how to adjust the playback delay, it is appreciateļ¼

Do you get the delay when using the example without any changes?
Are you using a bluetooth headset?
What version of FMOD are you using?