On Wed, Jun 12, 2013 at 8:10 PM, ssm <salmin01010@gmail.com> wrote:
> I know it's a long post, but even if you can help with a part of it, I'll be greatly benefited.

Hi Salmin,

You are using the ALSA API directly: if you're *sure* you want to do that, disregard the next bit.
Most pro-audio applications on linux use JACK, which simplifies writing audio programs as it does all the backend stuff, and lets you get on with writing something useful :)

There's a repository of "open-audio-programming-tutorials" online, of which one is directed at writing a simple JACK client:
https://github.com/harryhaaren/openAudioProgrammingTutorials/tree/master/jackClient

Hope that sets you off in the right direction :) -Harry