Hi,
I've been stuck on this dmix problem for the past week and have tried everything under the sun. Please any help or comment is much appreciated. Thanks a lot.
Background info. ----------------------- In my ALSA driver I have thread that keeps track of hw_ptr(dmix) appl_ptr(for all other cases) and copies the incoming data from kernal buffer into device circular buffer(which is monitored by the device). I allocate 64KB kernal buffer in my module_init function . (See allocation below) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 64*1024 , 64*1024);
So I monitor this kernal buffer and copy data from this to my device circular buffer which is also 64KB.
My period size is defined as 32KB. (See below) substream->runtime->hw.period_bytes_min = 1024*32; substream->runtime->hw.period_bytes_max = 1024*32; substream->runtime->hw.periods_min = 2; substream->runtime->hw.periods_max = 2;
My asound.conf file pcm.mix { type dmix ipc_key 1024 slave { pcm "hw:0,0" rate 48000 } } pcm.!default { type plug slave.pcm "mix" }
Everything was working fine until I noticed something weird. When I am playing a long wav file by invoking aplay and then try and play another small wav file simultaneously, the second file never gets mixed if the file is less than 64KB(my buffer size). If the second file is larger than 64KB then the second file gets mixed with the first one as it should since I am using dmix plugin.
So in order to debug this I tried to decrease my period_size = 4KB but when I do this my hw_ptr never moves.
My question. 1. Why do you think a file smaller than 64KB does not get mixed. (Obviously it has something to do with my buffer size but I dont get why?) 2. When I decrease my period_size to 4KB while keeping my buffer size at 64KB, why doesnt my hw_ptr move? 3. How else would I debug this?
Thanks in advance. I would really appreciate any help.
Regards Prabhu.