1 Jan 2012 19:13
Real time playback in Denemo
I think the next big step for Denemo will be to get the playback working in its own thread. Below are some ideas for how to do this, first there are some notes which you can cut out if you already know how the soc code is working. 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< 8>< I have studied the soc branch code and made the following notes: The playback works by using two threads, one is the process_thread_func() of the backend chosen (I see alsabackend.c and dummybackend.c so far) and the other is the queue_thread_func() in audiointerface.c The process_thread_func() creates a mutex and then runs a loop: the loop gets the system time g_get_current_time() and to it adds 5ms (a compiler constant called PLAYBACK_INTERVAL). This time is then used for a timed wait on a condition with the mutex, that is a call to g_cond_timed_wait(). This means that the thread waits for the condition process_cond to be signalled or until the 5ms have elapsed. The g_cond_timed_wait() unlocks the mutex before the thread sleeps and locks it when it continues. ***Question*** is it ok that the mutex has not been locked for the first time (and correspondingly, at the end g_mutex_free() is called without unlocking the mutex, is that ok?). Next a check is made for quitting the loop - this is done by making an atomic access to an int which is set by the alsa_seq_destroy() call. ***Question*** does that need to be an atomic access? The int in question is just a boolean, so in C it just means that if any of the(Continue reading)
RSS Feed