pcm: Better understandable locking code

The newly added locking code seems to have confused quite a few
people, as "thread_safe=1" may be considered as if the thread-safety
lock has to be turned on.  (It meant that the plugin _is_ thread-safe,
i.e. it needs no extra locking.)

For avoiding such a misunderstanding, this commit renames the relevant
pcm fields and give more comments to explain what is for what.
The former single pcm->thread_safe flag is now split to two boolean
flags, pcm->need_lock and pcm->lock_enabled.  It consumes a few more
bytes, but this would be (hopefully) better understandable.

No functional change by this commit.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2016-09-01 14:05:00 +02:00
parent 3b08152f68
commit 0fc4b4d17b
3 changed files with 34 additions and 11 deletions

View file

@ -1514,7 +1514,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
pcm->tstamp_type = tstamp_type;
#ifdef THREAD_SAFE_API
pcm->thread_safe = 1;
pcm->need_lock = 0; /* hw plugin is thread-safe */
#endif
ret = snd_pcm_hw_mmap_status(pcm);