[alsa-devel] Query regarding pcm->private_data
Hi
I am reading 'Wring an alsa driver'. It says following about the private_data:
You can allocate a record for the substream and store it in runtime->private_data. Usually, this is done in the open callback. Don't mix this with pcm->private_data. The pcm->private_data usually points the chip instance assigned statically at the creation of PCM, while the runtime->private_data points a dynamic data created at the PCM open callback.
What does static and dynamic mean here? Apologies for this question if it sounds very novice, since my understanding is it doesn't mean static and dynamic in the usual way like stack and heap etc. Why I am being so paranoid about this has reason:
In my ALSA driver I am assigning pcm->private_data = mychip, but it is NULL in the snd_pcm_attach_substream() function. I have checked my code many times and I tried with another driver which was working when tested using ALSA utils. Currently I am testing using the OSS emulation i.e. simply cat /dev/audio.
Pharaoh . wrote:
I am reading 'Wring an alsa driver'. It says following about the private_data:
You can allocate a record for the substream and store it in runtime->private_data. Usually, this is done in the open callback. Don't mix this with pcm->private_data. The pcm->private_data usually points the chip instance assigned statically at the creation of PCM, while the runtime->private_data points a dynamic data created at the PCM open callback.
What does static and dynamic mean here?
Nothing much. "Static" just means that this is not allocated/freed together with a stream's runtime. The my_chip data is usually allocated from the heap, but the runtime->private_data is _more_ dynamic because it is allocated every time a stream is opened.
HTH Clemens
participants (2)
-
Clemens Ladisch
-
Pharaoh .