1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--- transfer in progress (rec_dma_transfer_size = 4096) ---

1/ thread A : pcm_rec_lock()

2/ DMA interrupt -> rec_dma_callback
    rec_dma_size -= 4096
    rec_dma_start_addr -= 4096
    mono2stereo(rec_dma_start_addr)
    //locked
      --> rec_callback_pending = is_recording = true;
      --> return // no transfer of recorded PCM until pcm_rec_unlock() is called

3/ thread A : pcm_rec_unlock()
  // rec_callback_pending == true
    --> rec_dma_callback
      rec_dma_size -= 4096
      rec_dma_start_addr -= 4096
      --> wrong, we already did that