npv: tidy mutex locking
[nyanmp.git] / npv / lock_hierarchy
blob5236908dee6293bd778bab64859b55aa29950ea5
1 When several mutexes happen to be locked at the same time in any thread, they
2 must be locked in the same order in all threads. This is the dangerous nested
3 locking. Nested locking is accounted for using uppercase letters.
4 --------
5 MAIN_THD
6 --------
7 main
8         npv_prefill_wait
9                 npv_pipeline_limits_lock
10                 npv_pipeline_limits_unlock
11         evts_loop
12                 |npv_xcb_evt
13                 |       npv_xcb_evt_handle
14                 |               npv_xcb_evt_key_release
15                 |                       |(npv_cmd_rewind | npv_cmd_rewind_big | npv_cmd_fastforward | npv_cmd_fastforward_big)
16                 |                       |       seek_x
17                 |                       |               |seek_lock
18                 |                       |               |       A npv_pkt_q_lock(npv_video_pkt_q_p)
19                 |                       |               |       B npv_video_dec_ctx_lock
20                 |                       |               |       C npv_video_dec_frs_lock
21                 |                       |               |       D npv_pkt_q_lock(npv_audio_pkt_q_p)
22                 |                       |               |       E npv_audio_dec_ctx_lock
23                 |                       |               |       F npv_audio_dec_sets_lock
24                 |                       |               |       G npv_pipeline_limits_lock
25                 |                       |               |       H npv_fmt_ctx_lock
26                 |                       |               |seek_unlock
27                 |                       |               |       npv_pkt_q_unlock(npv_video_pkt_q_p)
28                 |                       |               |       npv_video_dec_ctx_unlock
29                 |                       |               |       npv_video_dec_frs_unlock
30                 |                       |               |       npv_pkt_q_unlock(npv_audio_pkt_q_p)
31                 |                       |               |       npv_audio_dec_ctx_unlock
32                 |                       |               |       npv_audio_dec_sets_unlock
33                 |                       |               |       npv_pipeline_limits_unlock
34                 |                       |               |       npv_fmt_ctx_unlock
35                 |                       |               |npv_prefill_wait
36                 |                       |                       npv_pipeline_limits_lock
37                 |                       |                       npv_pipeline_limits_unlock
38                 |                       |npv_cmd_pause
39                 |                                       npv_fmt_ctx_lock
40                 |                                       npv_fmt_ctx_unlock
41                 |npv_audio_evt_pcm_write
42                 |       npv_audio_pcm_filt_frs_write
43                 |               npv_audio_filt_push_decs_sets
44                 |                       npv_audio_dec_sets_lock 
45                 |                       npv_audio_dec_sets_unlock
46                 |npv_video_timer_evt
47                         npv_video_dec_frs_lock
48                         npv_video_dec_frs_unlock
49                         npv_video_start_scaling
50                                 npv_thdsws_run
51                                         npv_thdsws_state_lock
52                                         npv_thdsws_state_unlock
53                                         cond_signal on npv_thdsws_state_(un)lock mutex
54 ---------
55 VIDEO_THD
56 ---------
57 npv_pipeline_video_thd_entry
58         npv_pipeline_video
59                 have_enough_predecoded_video_frs
60                         npv_video_dec_frs_lock
61                         npv_video_dec_frs_unlock
62                 npv_video_pkts_send
63                         A npv_pkt_q_lock(npv_video_pkt_q_p)
64                         B npv_video_dec_ctx_lock
65                         npv_video_dec_ctx_unlock
66                         G npv_pipeline_limits_lock
67                         npv_pipeline_limits_unlock
68                         npv_pkt_q_unlock(npv_video_pkt_q_p)
69                 npv_video_dec_frs_receive_avail
70                         npv_video_dec_fr_try_receive
71                                 npv_video_dec_ctx_lock
72                                 npv_video_dec_ctx_unlock
73                                 npv_video_dec_frs_lock
74                                 npv_video_dec_frs_unlock
75 -------
76 SWS_THD
77 -------
78 npv_thdsws_worker_entry
79         npv_thdsws_state_lock
80         npv_thdsws_worker
81                 npv_thdsws_state_unlock
82                 npv_thdsws_state_lock
83                 cond_wait on npv_thdsws_state_(un)lock mutex
84 ---------
85 AUDIO_THD
86 ---------
87 npv_pipeline_audio_thd_entry
88         npv_pipeline_audio
89                 have_enough_predecoded_audio_frs
90                         npv_audio_dec_sets_lock
91                         npv_audio_dec_sets_unlock
92                 npv_audio_pkts_send     
93                         D npv_pkt_q_lock(npv_audio_pkt_q_p)
94                         E npv_audio_dec_ctx_lock
95                         npv_audio_dec_ctx_unlock
96                         G npv_pipeline_limits_lock
97                         npv_pipeline_limits_unlock
98                         npv_pkt_q_unlock(npv_audio_pkt_q_p)
99                 npv_audio_dec_sets_receive_avail
100                         E npv_audio_dec_ctx_lock
101                         F npv_audio_dec_sets_lock
102                         npv_audio_dec_sets_unlock
103                         npv_audio_dec_ctx_unlock
104 --------
105 READ_THD
106 --------
107 npv_pipeline_read_thd_entry
108         npv_pipeline_read_
109                 npv_fmt_pkts_read_and_q
110                         npv_fmt_did_reached_limits
111                                 npv_pipeline_limits_lock        
112                                 npv_pipeline_limits_unlock
113                         npv_fmt_ctx_lock
114                         npv_fmt_ctx_unlock
115                         npv_pipeline_limits_lock
116                         npv_pipeline_limits_unlock 
117                         npv_pkt_q_lock(npv_audio_pkt_q_p)   | npv_pkt_q_lock(npv_video_pkt_q_p)
118                         npv_pkt_q_unlock(npv_audio_pkt_q_p) | npv_pkt_q_unlock(npv_video_pkt_q_p)