Audio driver on beagleboard

I want to use the beagleboard to measure the distance between the
beagleboard and wall. the idea was here: speaker send one signal and
echoed back will be captured by microphone. Through analysis of the
audio signal, we can measure the distance.

how to read the signal from audio driver on beagleboard? any person
has this source code I can refer.