void liveScanner (dsd_opts * opts, dsd_state * state) { if (opts->audio_in_fd == -1) { if (pthread_mutex_lock(&state->input_mutex)) { printf("liveScanner -> Unable to lock mutex\n"); } } while (1) { noCarrier (opts, state); state->synctype = getFrameSync (opts, state); // recalibrate center/umid/lmid state->center = ((state->max) + (state->min)) / 2; state->umid = (((state->max) - state->center) * 5 / 8) + state->center; state->lmid = (((state->min) - state->center) * 5 / 8) + state->center; while (state->synctype != -1) { processFrame (opts, state); state->synctype = getFrameSync (opts, state); // recalibrate center/umid/lmid state->center = ((state->max) + (state->min)) / 2; state->umid = (((state->max) - state->center) * 5 / 8) + state->center; state->lmid = (((state->min) - state->center) * 5 / 8) + state->center; } } }
// This function is a supplement to the loadHeader // function, the only purpose is to detect if the // header loaded by loadHeader is a valid header // or just four different chars BOOL CFrameHeader::isValidHeader() { return ( ((getFrameSync() & 2047)==2047) && ((getVersionIndex() & 3)!= 1) && ((getLayerIndex() & 3)!= 0) && ((getBitrateIndex() & 15)!= 0) && // due to lack of support of the .mp3 format // no "public" .mp3's should contain information // like this anyway... :) ((getBitrateIndex() & 15)!= 15) && ((getFrequencyIndex() & 3)!= 3) && ((getEmphasisIndex() & 3)!= 2) ); }