File npv/audio/filt/local/code.frag.c changed (mode: 100644) (index 4d044b9..d361d3e) |
|
1 |
|
STATIC void fatal(u8 *fmt, ...) |
|
2 |
|
{ |
|
3 |
|
va_list ap; |
|
4 |
|
|
|
5 |
|
npv_perr("audio:filter:"); |
|
6 |
|
va_start(ap, fmt); |
|
7 |
|
npv_vfatal(fmt, ap); |
|
8 |
|
va_end(ap); |
|
9 |
|
} |
|
10 |
|
STATIC void warning(u8 *fmt, ...) |
|
11 |
|
{ |
|
12 |
|
va_list ap; |
|
13 |
|
|
|
14 |
|
npv_perr("audio:filter:"); |
|
15 |
|
va_start(ap, fmt); |
|
16 |
|
npv_vwarning(fmt, ap); |
|
17 |
|
va_end(ap); |
|
18 |
|
} |
|
19 |
|
STATIC void pout(u8 *fmt, ...) |
|
20 |
|
{ |
|
21 |
|
va_list ap; |
|
22 |
|
|
|
23 |
|
npv_pout("audio:filter:"); |
|
24 |
|
va_start(ap, fmt); |
|
25 |
|
npv_vpout(fmt, ap); |
|
26 |
|
va_end(ap); |
|
27 |
|
} |
1 |
28 |
STATIC void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
STATIC void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
2 |
29 |
uint64_t chans_layout, bool print_info) |
uint64_t chans_layout, bool print_info) |
3 |
30 |
{ |
{ |
|
... |
... |
STATIC void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
7 |
34 |
|
|
8 |
35 |
abufsrc_l = avfilter_get_by_name("abuffer"); |
abufsrc_l = avfilter_get_by_name("abuffer"); |
9 |
36 |
if (abufsrc_l == 0) |
if (abufsrc_l == 0) |
10 |
|
FATALAF("audio buffer source:could not find the filter\n"); |
|
|
37 |
|
fatal("audio buffer source:could not find the filter\n"); |
11 |
38 |
abufsrc_ctx_l = avfilter_graph_alloc_filt(graph_l, abufsrc_l, |
abufsrc_ctx_l = avfilter_graph_alloc_filt(graph_l, abufsrc_l, |
12 |
39 |
"src_abuf"); |
"src_abuf"); |
13 |
40 |
if (abufsrc_ctx_l == 0) |
if (abufsrc_ctx_l == 0) |
14 |
|
FATALAF("audio buffer source context:could not allocate the instance in the filter graph\n"); |
|
|
41 |
|
fatal("audio buffer source context:could not allocate the instance in the filter graph\n"); |
15 |
42 |
r = avutil_opt_set(abufsrc_ctx_l, "sample_fmt", |
r = avutil_opt_set(abufsrc_ctx_l, "sample_fmt", |
16 |
43 |
avutil_get_audio_fr_fmt_name(fmt), |
avutil_get_audio_fr_fmt_name(fmt), |
17 |
44 |
AVUTIL_OPT_SEARCH_CHILDREN); |
AVUTIL_OPT_SEARCH_CHILDREN); |
18 |
45 |
if (r < 0) |
if (r < 0) |
19 |
|
FATALAF("audio buffer source context:unable to set the decoder frame format option\n"); |
|
|
46 |
|
fatal("audio buffer source context:unable to set the decoder frame format option\n"); |
20 |
47 |
r = avutil_opt_set_int(abufsrc_ctx_l, "sample_rate", |
r = avutil_opt_set_int(abufsrc_ctx_l, "sample_rate", |
21 |
48 |
rate, AVUTIL_OPT_SEARCH_CHILDREN); |
rate, AVUTIL_OPT_SEARCH_CHILDREN); |
22 |
49 |
if (r < 0) |
if (r < 0) |
23 |
|
FATALAF("audio buffer source context:unable to set the decoder rate option\n"); |
|
|
50 |
|
fatal("audio buffer source context:unable to set the decoder rate option\n"); |
24 |
51 |
/* |
/* |
25 |
52 |
* XXX: at the time of coding, bug for 1 chans layout... or I did miss |
* XXX: at the time of coding, bug for 1 chans layout... or I did miss |
26 |
53 |
* some valuable information |
* some valuable information |
|
... |
... |
STATIC void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
28 |
55 |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
29 |
56 |
chans_n, chans_layout); |
chans_n, chans_layout); |
30 |
57 |
if (print_info) |
if (print_info) |
31 |
|
POUTAF("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n); |
|
|
58 |
|
pout("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n); |
32 |
59 |
r = avutil_opt_set(abufsrc_ctx_l, "channel_layout", chans_layout_str, |
r = avutil_opt_set(abufsrc_ctx_l, "channel_layout", chans_layout_str, |
33 |
60 |
AVUTIL_OPT_SEARCH_CHILDREN); |
AVUTIL_OPT_SEARCH_CHILDREN); |
34 |
61 |
if (r < 0) |
if (r < 0) |
35 |
|
FATALAF("audio buffer source context:unable to set the decoder channel layout option\n"); |
|
|
62 |
|
fatal("audio buffer source context:unable to set the decoder channel layout option\n"); |
36 |
63 |
r = avfilter_init_str(abufsrc_ctx_l, 0); |
r = avfilter_init_str(abufsrc_ctx_l, 0); |
37 |
64 |
if (r < 0) |
if (r < 0) |
38 |
|
FATALAF("audio buffer source context:unable to initialize\n"); |
|
|
65 |
|
fatal("audio buffer source context:unable to initialize\n"); |
39 |
66 |
} |
} |
40 |
67 |
STATIC void vol_cfg(bool muted, double vol_cfg) |
STATIC void vol_cfg(bool muted, double vol_cfg) |
41 |
68 |
{ |
{ |
|
... |
... |
STATIC void vol_cfg(bool muted, double vol_cfg) |
45 |
72 |
|
|
46 |
73 |
vol_l = avfilter_get_by_name("volume"); |
vol_l = avfilter_get_by_name("volume"); |
47 |
74 |
if (vol_l == 0) |
if (vol_l == 0) |
48 |
|
FATALAF("volume:could not find the filter\n"); |
|
|
75 |
|
fatal("volume:could not find the filter\n"); |
49 |
76 |
vol_ctx_l = avfilter_graph_alloc_filt(graph_l, vol_l, "vol"); |
vol_ctx_l = avfilter_graph_alloc_filt(graph_l, vol_l, "vol"); |
50 |
77 |
if (vol_ctx_l == 0) |
if (vol_ctx_l == 0) |
51 |
|
FATALAF("volume context:could not allocate the instance in the filter graph\n"); |
|
|
78 |
|
fatal("volume context:could not allocate the instance in the filter graph\n"); |
52 |
79 |
if (muted) |
if (muted) |
53 |
80 |
vol = 0.0; |
vol = 0.0; |
54 |
81 |
else |
else |
|
... |
... |
STATIC void vol_cfg(bool muted, double vol_cfg) |
58 |
85 |
r = avutil_opt_set(vol_ctx_l, "volume", vol_l10n_str, |
r = avutil_opt_set(vol_ctx_l, "volume", vol_l10n_str, |
59 |
86 |
AVUTIL_OPT_SEARCH_CHILDREN); |
AVUTIL_OPT_SEARCH_CHILDREN); |
60 |
87 |
if (r < 0) |
if (r < 0) |
61 |
|
FATALAF("volume context:unable to set the volume option\n"); |
|
|
88 |
|
fatal("volume context:unable to set the volume option\n"); |
62 |
89 |
r = avfilter_init_str(vol_ctx_l, 0); |
r = avfilter_init_str(vol_ctx_l, 0); |
63 |
90 |
if (r < 0) |
if (r < 0) |
64 |
|
FATALAF("volume buffer context:unable to initialize\n"); |
|
|
91 |
|
fatal("volume buffer context:unable to initialize\n"); |
65 |
92 |
} |
} |
66 |
93 |
STATIC void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
STATIC void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
67 |
94 |
uint64_t chans_layout, bool print_info) |
uint64_t chans_layout, bool print_info) |
|
... |
... |
STATIC void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n, |
72 |
99 |
|
|
73 |
100 |
afmt_l = avfilter_get_by_name("aformat"); |
afmt_l = avfilter_get_by_name("aformat"); |
74 |
101 |
if (afmt_l == 0) |
if (afmt_l == 0) |
75 |
|
FATALAF("audio format:could not find the filter"); |
|
|
102 |
|
fatal("audio format:could not find the filter"); |
76 |
103 |
afmt_ctx_l = avfilter_graph_alloc_filt(graph_l, afmt_l, "afmt"); |
afmt_ctx_l = avfilter_graph_alloc_filt(graph_l, afmt_l, "afmt"); |
77 |
104 |
if (afmt_ctx_l == 0) |
if (afmt_ctx_l == 0) |
78 |
|
FATALAF("audio format:could not allocate the instance in the filter graph\n"); |
|
|
105 |
|
fatal("audio format:could not allocate the instance in the filter graph\n"); |
79 |
106 |
r = avutil_opt_set(afmt_ctx_l, "sample_fmts", |
r = avutil_opt_set(afmt_ctx_l, "sample_fmts", |
80 |
107 |
avutil_get_audio_fr_fmt_name(fmt), AVUTIL_OPT_SEARCH_CHILDREN); |
avutil_get_audio_fr_fmt_name(fmt), AVUTIL_OPT_SEARCH_CHILDREN); |
81 |
108 |
if (r < 0) |
if (r < 0) |
82 |
|
FATALAF("audio format context:could to set the pcm sample format\n"); |
|
|
109 |
|
fatal("audio format context:could to set the pcm sample format\n"); |
83 |
110 |
snprintf(rate_str, sizeof(rate_str), "%d", rate); |
snprintf(rate_str, sizeof(rate_str), "%d", rate); |
84 |
111 |
r = avutil_opt_set(afmt_ctx_l, "sample_rates", rate_str, |
r = avutil_opt_set(afmt_ctx_l, "sample_rates", rate_str, |
85 |
112 |
AVUTIL_OPT_SEARCH_CHILDREN); |
AVUTIL_OPT_SEARCH_CHILDREN); |
86 |
113 |
if (r < 0) |
if (r < 0) |
87 |
|
FATALAF("audio format context:could not set the pcm rate\n"); |
|
|
114 |
|
fatal("audio format context:could not set the pcm rate\n"); |
88 |
115 |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
89 |
116 |
chans_n, chans_layout); |
chans_n, chans_layout); |
90 |
117 |
r = avutil_opt_set(afmt_ctx_l, "channel_layouts", chans_layout_str, |
r = avutil_opt_set(afmt_ctx_l, "channel_layouts", chans_layout_str, |
91 |
118 |
AVUTIL_OPT_SEARCH_CHILDREN); |
AVUTIL_OPT_SEARCH_CHILDREN); |
92 |
119 |
if (r < 0) |
if (r < 0) |
93 |
|
FATALAF("audio format context:could not set the layout of channels\n"); |
|
|
120 |
|
fatal("audio format context:could not set the layout of channels\n"); |
94 |
121 |
if (print_info) |
if (print_info) |
95 |
|
POUTAF("audio format context:channel layout is \"%s\"\n", chans_layout_str); |
|
|
122 |
|
pout("audio format context:channel layout is \"%s\"\n", chans_layout_str); |
96 |
123 |
r = avfilter_init_str(afmt_ctx_l, 0); |
r = avfilter_init_str(afmt_ctx_l, 0); |
97 |
124 |
if (r < 0) |
if (r < 0) |
98 |
|
FATALAF("audio format context:unable to initialize\n"); |
|
|
125 |
|
fatal("audio format context:unable to initialize\n"); |
99 |
126 |
} |
} |
100 |
127 |
STATIC void abufsink_cfg(void) |
STATIC void abufsink_cfg(void) |
101 |
128 |
{ |
{ |
|
... |
... |
STATIC void abufsink_cfg(void) |
103 |
130 |
|
|
104 |
131 |
abufsink_l = avfilter_get_by_name("abuffersink"); |
abufsink_l = avfilter_get_by_name("abuffersink"); |
105 |
132 |
if (abufsink_l == 0) |
if (abufsink_l == 0) |
106 |
|
FATALAF("audio buffer sink:could not find the filter\n"); |
|
|
133 |
|
fatal("audio buffer sink:could not find the filter\n"); |
107 |
134 |
abufsink_ctx_l = avfilter_graph_alloc_filt(graph_l, abufsink_l, |
abufsink_ctx_l = avfilter_graph_alloc_filt(graph_l, abufsink_l, |
108 |
135 |
"sink_abuf"); |
"sink_abuf"); |
109 |
136 |
if (abufsink_ctx_l == 0) |
if (abufsink_ctx_l == 0) |
110 |
|
FATALAF("audio buffer sink context:could not allocate the instance in the filter graph\n"); |
|
|
137 |
|
fatal("audio buffer sink context:could not allocate the instance in the filter graph\n"); |
111 |
138 |
r = avfilter_init_str(abufsink_ctx_l, 0); |
r = avfilter_init_str(abufsink_ctx_l, 0); |
112 |
139 |
if (r < 0) |
if (r < 0) |
113 |
|
FATALAF("audio buffer sink context:unable to initialize\n"); |
|
|
140 |
|
fatal("audio buffer sink context:unable to initialize\n"); |
114 |
141 |
} |
} |
115 |
142 |
STATIC void init_once_local(void) |
STATIC void init_once_local(void) |
116 |
143 |
{ |
{ |
|
... |
... |
STATIC void init_once_public(double initial_vol) |
131 |
158 |
{ |
{ |
132 |
159 |
filt_p.set = avutil_audio_set_ref_alloc(); |
filt_p.set = avutil_audio_set_ref_alloc(); |
133 |
160 |
if (filt_p.set == 0) |
if (filt_p.set == 0) |
134 |
|
FATALAF("ffmpeg:unable to allocate a reference on set of frames for the public part of the interactive latency filter\n"); |
|
|
161 |
|
fatal("ffmpeg:unable to allocate a reference on set of frames for the public part of the interactive latency filter\n"); |
135 |
162 |
filt_p.pcm_written_ufrs_n = 0; |
filt_p.pcm_written_ufrs_n = 0; |
136 |
163 |
filt_p.vol = initial_vol; |
filt_p.vol = initial_vol; |
137 |
164 |
filt_p.muted = false; |
filt_p.muted = false; |
File npv/audio/filt/public/code.frag.c changed (mode: 100644) (index 5578e6c..9fb7eae) |
... |
... |
STATIC u8 filt_push_dec_sets(void) |
15 |
15 |
0, AVFILTER_BUFSRC_FLAG_PUSH |
0, AVFILTER_BUFSRC_FLAG_PUSH |
16 |
16 |
| AVFILTER_BUFSRC_FLAG_KEEP_REF); |
| AVFILTER_BUFSRC_FLAG_KEEP_REF); |
17 |
17 |
if (ri < 0) |
if (ri < 0) |
18 |
|
FATALAF("ffmpeg:unable to notify the end of data to the filter source audio buffer context\n"); |
|
19 |
|
POUTAF("ffmpeg:interactive filter switched to draining\n"); |
|
|
18 |
|
fatal("ffmpeg:unable to notify the end of data to the filter source audio buffer context\n"); |
|
19 |
|
pout("ffmpeg:interactive filter switched to draining\n"); |
20 |
20 |
r8 = FILT_SWITCHED_TO_DRAINING; |
r8 = FILT_SWITCHED_TO_DRAINING; |
21 |
21 |
goto unlock; |
goto unlock; |
22 |
22 |
} |
} |
|
... |
... |
STATIC u8 filt_push_dec_sets(void) |
44 |
44 |
r8 = AGAIN; |
r8 = AGAIN; |
45 |
45 |
goto unlock; |
goto unlock; |
46 |
46 |
} |
} |
47 |
|
FATALAF("ffmpeg:unable to submit a decoder set of frames to the filter source audio buffer context\n"); |
|
|
47 |
|
fatal("ffmpeg:unable to submit a decoder set of frames to the filter source audio buffer context\n"); |
48 |
48 |
unlock: |
unlock: |
49 |
49 |
npv_audio_dec_sets_unlock(); |
npv_audio_dec_sets_unlock(); |
50 |
50 |
return r8; |
return r8; |
|
... |
... |
STATIC u8 filt_set_try_get(void) |
73 |
73 |
} else if (r == AVUTIL_AVERROR_EOF) { |
} else if (r == AVUTIL_AVERROR_EOF) { |
74 |
74 |
return EOF_FILT; |
return EOF_FILT; |
75 |
75 |
} |
} |
76 |
|
FATALAF("ffmpeg:error while getting frames from the filter\n"); |
|
|
76 |
|
fatal("ffmpeg:error while getting frames from the filter\n"); |
77 |
77 |
} |
} |
78 |
78 |
#undef AGAIN |
#undef AGAIN |
79 |
79 |
#undef HAVE_FILT_SET |
#undef HAVE_FILT_SET |
|
... |
... |
STATIC void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate, |
118 |
118 |
|
|
119 |
119 |
graph_l = avfilter_graph_alloc(); |
graph_l = avfilter_graph_alloc(); |
120 |
120 |
if (graph_l == 0) |
if (graph_l == 0) |
121 |
|
FATALAF("unable to create filter graph\n"); |
|
|
121 |
|
fatal("unable to create filter graph\n"); |
122 |
122 |
abufsrc_cfg(src_fmt, src_rate, src_chans_n, src_chans_layout, |
abufsrc_cfg(src_fmt, src_rate, src_chans_n, src_chans_layout, |
123 |
123 |
print_info); |
print_info); |
124 |
124 |
vol_cfg(muted, vol); |
vol_cfg(muted, vol); |
|
... |
... |
STATIC void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate, |
126 |
126 |
abufsink_cfg(); |
abufsink_cfg(); |
127 |
127 |
r = avfilter_link(abufsrc_ctx_l, 0, vol_ctx_l, 0); |
r = avfilter_link(abufsrc_ctx_l, 0, vol_ctx_l, 0); |
128 |
128 |
if (r < 0) |
if (r < 0) |
129 |
|
FATALAF("unable to connect the audio buffer source filter to the volume filter\n"); |
|
|
129 |
|
fatal("unable to connect the audio buffer source filter to the volume filter\n"); |
130 |
130 |
r = avfilter_link(vol_ctx_l, 0, afmt_ctx_l, 0); |
r = avfilter_link(vol_ctx_l, 0, afmt_ctx_l, 0); |
131 |
131 |
if (r < 0) |
if (r < 0) |
132 |
|
FATALAF("unable to connect the volume filter to the audio format filter\n"); |
|
|
132 |
|
fatal("unable to connect the volume filter to the audio format filter\n"); |
133 |
133 |
r = avfilter_link(afmt_ctx_l, 0, abufsink_ctx_l, 0); |
r = avfilter_link(afmt_ctx_l, 0, abufsink_ctx_l, 0); |
134 |
134 |
if (r < 0) |
if (r < 0) |
135 |
|
FATALAF("unable to connect the audio format filter to the audio buffer sink filter\n"); |
|
|
135 |
|
fatal("unable to connect the audio format filter to the audio buffer sink filter\n"); |
136 |
136 |
r = avfilter_graph_config(graph_l, 0); |
r = avfilter_graph_config(graph_l, 0); |
137 |
137 |
if (r < 0) |
if (r < 0) |
138 |
|
FATALAF("unable to configure the filter graph\n"); |
|
|
138 |
|
fatal("unable to configure the filter graph\n"); |
139 |
139 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
140 |
140 |
if (!print_info) |
if (!print_info) |
141 |
141 |
return; |
return; |
142 |
142 |
dump_str = avfilter_graph_dump(graph_l, 0); |
dump_str = avfilter_graph_dump(graph_l, 0); |
143 |
143 |
if (dump_str == 0) { |
if (dump_str == 0) { |
144 |
|
WARNINGAF("unable to get a filter graph description\n"); |
|
|
144 |
|
warning("unable to get a filter graph description\n"); |
145 |
145 |
return; |
return; |
146 |
146 |
} |
} |
147 |
|
POUTAF("GRAPH START-------------------------------------------------------\n"); |
|
148 |
|
POUT("%s", dump_str); |
|
|
147 |
|
pout("GRAPH START-------------------------------------------------------\n"); |
|
148 |
|
npv_pout("%s", dump_str); |
149 |
149 |
avutil_free(dump_str); |
avutil_free(dump_str); |
150 |
|
POUTAF("GRAPH END---------------------------------------------------------\n"); |
|
|
150 |
|
pout("GRAPH END---------------------------------------------------------\n"); |
151 |
151 |
} |
} |
152 |
152 |
STATIC void npv_audio_filt_cmd_mute(void) |
STATIC void npv_audio_filt_cmd_mute(void) |
153 |
153 |
{ |
{ |
|
... |
... |
STATIC void npv_audio_filt_cmd_mute(void) |
156 |
156 |
u8 resp[STR_SZ]; |
u8 resp[STR_SZ]; |
157 |
157 |
|
|
158 |
158 |
if (filt_p.muted) { |
if (filt_p.muted) { |
159 |
|
POUTAF("COMMAND:unmuting\n"); |
|
|
159 |
|
pout("COMMAND:unmuting\n"); |
160 |
160 |
|
|
161 |
161 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
162 |
162 |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
163 |
163 |
vol_l10n_str, resp, sizeof(resp), 0); |
vol_l10n_str, resp, sizeof(resp), 0); |
164 |
164 |
if (r < 0) { |
if (r < 0) { |
165 |
|
WARNINGAF("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", resp); |
|
|
165 |
|
warning("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", resp); |
166 |
166 |
} else { |
} else { |
167 |
167 |
filt_p.muted = false; |
filt_p.muted = false; |
168 |
168 |
} |
} |
169 |
169 |
} else { |
} else { |
170 |
|
POUTAF("COMMAND:muting\n"); |
|
|
170 |
|
pout("COMMAND:muting\n"); |
171 |
171 |
|
|
172 |
172 |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
173 |
173 |
double_zero_l10n_str_l, resp, sizeof(resp), 0); |
double_zero_l10n_str_l, resp, sizeof(resp), 0); |
174 |
174 |
if (r < 0) { |
if (r < 0) { |
175 |
|
WARNINGAF("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", resp); |
|
|
175 |
|
warning("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", resp); |
176 |
176 |
} else { |
} else { |
177 |
177 |
filt_p.muted = true; |
filt_p.muted = true; |
178 |
178 |
} |
} |
|
... |
... |
STATIC void npv_audio_filt_cmd_vol_down(void) |
188 |
188 |
if (filt_p.vol < 0.) |
if (filt_p.vol < 0.) |
189 |
189 |
filt_p.vol = 0.; |
filt_p.vol = 0.; |
190 |
190 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
191 |
|
POUTAF("COMMAND:volume down to value %s\n", vol_l10n_str); |
|
|
191 |
|
pout("COMMAND:volume down to value %s\n", vol_l10n_str); |
192 |
192 |
if (!filt_p.muted) { |
if (!filt_p.muted) { |
193 |
193 |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
194 |
194 |
vol_l10n_str, resp, sizeof(resp), 0); |
vol_l10n_str, resp, sizeof(resp), 0); |
195 |
195 |
if (r < 0) |
if (r < 0) |
196 |
|
WARNINGAF("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", resp); |
|
|
196 |
|
warning("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", resp); |
197 |
197 |
} |
} |
198 |
198 |
} |
} |
199 |
199 |
STATIC void npv_audio_filt_cmd_vol_up(void) |
STATIC void npv_audio_filt_cmd_vol_up(void) |
|
... |
... |
STATIC void npv_audio_filt_cmd_vol_up(void) |
206 |
206 |
if (filt_p.vol > 1.) |
if (filt_p.vol > 1.) |
207 |
207 |
filt_p.vol = 1.; |
filt_p.vol = 1.; |
208 |
208 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_p.vol); |
209 |
|
POUTAF("COMMAND:volume up to value %s\n", vol_l10n_str); |
|
|
209 |
|
pout("COMMAND:volume up to value %s\n", vol_l10n_str); |
210 |
210 |
if (!filt_p.muted) { |
if (!filt_p.muted) { |
211 |
211 |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
r = avfilter_graph_send_cmd(graph_l, "vol", "volume", |
212 |
212 |
vol_l10n_str, resp, sizeof(resp), 0); |
vol_l10n_str, resp, sizeof(resp), 0); |
213 |
213 |
if (r < 0) |
if (r < 0) |
214 |
|
WARNINGAF("ffmpeg:volume context:unable to set the volume up to \"%s\":response from volume filter:\"%s\"\n", resp); |
|
|
214 |
|
warning("ffmpeg:volume context:unable to set the volume up to \"%s\":response from volume filter:\"%s\"\n", resp); |
215 |
215 |
} |
} |
216 |
216 |
} |
} |
File npv/audio/local/code.frag.c changed (mode: 100644) (index 5b27e36..fe5fda0) |
|
1 |
|
STATIC void fatal(u8 *fmt, ...) |
|
2 |
|
{ |
|
3 |
|
va_list ap; |
|
4 |
|
|
|
5 |
|
npv_perr("audio:"); |
|
6 |
|
va_start(ap, fmt); |
|
7 |
|
npv_vfatal(fmt, ap); |
|
8 |
|
va_end(ap); /* unreachable */ |
|
9 |
|
} |
|
10 |
|
STATIC void warning(u8 *fmt, ...) |
|
11 |
|
{ |
|
12 |
|
va_list ap; |
|
13 |
|
|
|
14 |
|
npv_perr("audio:"); |
|
15 |
|
va_start(ap, fmt); |
|
16 |
|
npv_vwarning(fmt, ap); |
|
17 |
|
va_end(ap); |
|
18 |
|
} |
|
19 |
|
STATIC void pout(u8 *fmt, ...) |
|
20 |
|
{ |
|
21 |
|
va_list ap; |
|
22 |
|
|
|
23 |
|
npv_pout("audio:"); |
|
24 |
|
va_start(ap, fmt); |
|
25 |
|
npv_vpout(fmt, ap); |
|
26 |
|
va_end(ap); |
|
27 |
|
} |
1 |
28 |
STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt, |
STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt, |
2 |
29 |
snd_pcm_fmt_t *alsa_fmt, snd_pcm_access_t *alsa_access) |
snd_pcm_fmt_t *alsa_fmt, snd_pcm_access_t *alsa_access) |
3 |
30 |
{ |
{ |
|
... |
... |
STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt, |
40 |
67 |
*alsa_access = SND_PCM_ACCESS_RW_NONINTERLEAVED; |
*alsa_access = SND_PCM_ACCESS_RW_NONINTERLEAVED; |
41 |
68 |
break; |
break; |
42 |
69 |
default: |
default: |
43 |
|
POUTA("best effort:unable to wire ffmpeg sample format \"%sbits\" to alsa sample format, \n,", ff_fmt_str); |
|
|
70 |
|
pout("best effort:unable to wire ffmpeg sample format \"%sbits\" to alsa sample format, \n,", ff_fmt_str); |
44 |
71 |
return false; |
return false; |
45 |
72 |
} |
} |
46 |
|
POUTA("best effort:ffmpeg format \"%sbits\" (%u bytes) to alsa layout \"%s\" and access \"%s\"\n", ff_fmt_str, av_get_bytes_per_sample(ff_fmt), snd_pcm_fmt_desc(*alsa_fmt), snd_pcm_access_name(*alsa_access)); |
|
|
73 |
|
pout("best effort:ffmpeg format \"%sbits\" (%u bytes) to alsa layout \"%s\" and access \"%s\"\n", ff_fmt_str, av_get_bytes_per_sample(ff_fmt), snd_pcm_fmt_desc(*alsa_fmt), snd_pcm_access_name(*alsa_access)); |
47 |
74 |
return true; |
return true; |
48 |
75 |
} |
} |
49 |
76 |
STATIC void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
STATIC void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
|
... |
... |
STATIC void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
57 |
84 |
if (r == 0) { |
if (r == 0) { |
58 |
85 |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, chans_n); |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, chans_n); |
59 |
86 |
if (r != 0) |
if (r != 0) |
60 |
|
FATALA("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n); |
|
61 |
|
POUTA("alsa:using %u channels\n", chans_n); |
|
|
87 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n); |
|
88 |
|
pout("alsa:using %u channels\n", chans_n); |
62 |
89 |
return; |
return; |
63 |
90 |
} |
} |
64 |
|
POUTA("alsa:unable to use %u channels\n", chans_n); |
|
|
91 |
|
pout("alsa:unable to use %u channels\n", chans_n); |
65 |
92 |
/* try to use the max chans n the pcm can */ |
/* try to use the max chans n the pcm can */ |
66 |
93 |
r = snd_pcm_hw_params_get_chans_n_max(pcm_hw_params, &chans_n_max); |
r = snd_pcm_hw_params_get_chans_n_max(pcm_hw_params, &chans_n_max); |
67 |
94 |
if (r != 0) |
if (r != 0) |
68 |
|
FATALA("alsa:unable to get the maximum count of pcm device channels\n"); |
|
|
95 |
|
fatal("alsa:unable to get the maximum count of pcm device channels\n"); |
69 |
96 |
r = snd_pcm_hw_params_test_chans_n(pcm, pcm_hw_params, chans_n_max); |
r = snd_pcm_hw_params_test_chans_n(pcm, pcm_hw_params, chans_n_max); |
70 |
97 |
if (r == 0) { |
if (r == 0) { |
71 |
98 |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, |
72 |
99 |
chans_n_max); |
chans_n_max); |
73 |
100 |
if (r != 0) |
if (r != 0) |
74 |
|
FATALA("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_max); |
|
75 |
|
POUTA("alsa:using pcm maximum %u channels\n", chans_n_max); |
|
|
101 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_max); |
|
102 |
|
pout("alsa:using pcm maximum %u channels\n", chans_n_max); |
76 |
103 |
return; |
return; |
77 |
104 |
} |
} |
78 |
105 |
/* ok... last try, the pcm dev min chans n */ |
/* ok... last try, the pcm dev min chans n */ |
79 |
106 |
r = snd_pcm_hw_params_get_chans_n_min(pcm_hw_params, &chans_n_min); |
r = snd_pcm_hw_params_get_chans_n_min(pcm_hw_params, &chans_n_min); |
80 |
107 |
if (r != 0) |
if (r != 0) |
81 |
|
FATALA("alsa:unable to get the minimum count of pcm device channels\n"); |
|
|
108 |
|
fatal("alsa:unable to get the minimum count of pcm device channels\n"); |
82 |
109 |
r = snd_pcm_hw_params_test_chans_n(pcm, pcm_hw_params, chans_n_min); |
r = snd_pcm_hw_params_test_chans_n(pcm, pcm_hw_params, chans_n_min); |
83 |
110 |
if (r == 0) { |
if (r == 0) { |
84 |
111 |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_chans_n(pcm, pcm_hw_params, |
85 |
112 |
chans_n_min); |
chans_n_min); |
86 |
113 |
if (r != 0) |
if (r != 0) |
87 |
|
FATALA("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_min); |
|
88 |
|
POUTA("alsa:using pcm device minimum %u channels\n", chans_n_min); |
|
|
114 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_min); |
|
115 |
|
pout("alsa:using pcm device minimum %u channels\n", chans_n_min); |
89 |
116 |
return; |
return; |
90 |
117 |
} |
} |
91 |
|
FATALA("alsa:unable to find a suitable count of channels\n"); |
|
|
118 |
|
fatal("alsa:unable to find a suitable count of channels\n"); |
92 |
119 |
} |
} |
93 |
120 |
STATIC void pcm_hw_rate_decide(snd_pcm_t *pcm, |
STATIC void pcm_hw_rate_decide(snd_pcm_t *pcm, |
94 |
121 |
snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate) |
snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate) |
|
... |
... |
STATIC void pcm_hw_rate_decide(snd_pcm_t *pcm, |
104 |
131 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate, |
105 |
132 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
106 |
133 |
if (r != 0) |
if (r != 0) |
107 |
|
FATALA("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate); |
|
108 |
|
POUTA("alsa:using %uHz\n", rate); |
|
|
134 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate); |
|
135 |
|
pout("alsa:using %uHz\n", rate); |
109 |
136 |
return; |
return; |
110 |
137 |
} |
} |
111 |
|
POUTA("alsa:unable to use %uHz\n", rate); |
|
|
138 |
|
pout("alsa:unable to use %uHz\n", rate); |
112 |
139 |
/* try to use the max rate the pcm can */ |
/* try to use the max rate the pcm can */ |
113 |
140 |
r = snd_pcm_hw_params_get_rate_max(pcm_hw_params, &rate_max, |
r = snd_pcm_hw_params_get_rate_max(pcm_hw_params, &rate_max, |
114 |
141 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
115 |
142 |
if (r != 0) |
if (r != 0) |
116 |
|
FATALA("alsa:unable to get the maximum rate of pcm device\n"); |
|
|
143 |
|
fatal("alsa:unable to get the maximum rate of pcm device\n"); |
117 |
144 |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_max, |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_max, |
118 |
145 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
119 |
146 |
if (r == 0) { |
if (r == 0) { |
120 |
147 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_max, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_max, |
121 |
148 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
122 |
149 |
if (r != 0) |
if (r != 0) |
123 |
|
FATALA("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_max); |
|
124 |
|
POUTA("alsa:using pcm device %uHz\n", rate_max); |
|
|
150 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_max); |
|
151 |
|
pout("alsa:using pcm device %uHz\n", rate_max); |
125 |
152 |
return; |
return; |
126 |
153 |
} |
} |
127 |
154 |
/* try to use a rate "near" of what the pcm dev can */ |
/* try to use a rate "near" of what the pcm dev can */ |
|
... |
... |
STATIC void pcm_hw_rate_decide(snd_pcm_t *pcm, |
129 |
156 |
r = snd_pcm_hw_params_set_rate_near(pcm, pcm_hw_params, &rate_near, |
r = snd_pcm_hw_params_set_rate_near(pcm, pcm_hw_params, &rate_near, |
130 |
157 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
131 |
158 |
if (r == 0) { |
if (r == 0) { |
132 |
|
POUTA("alsa:using pcm device %uHz\n", rate_near); |
|
|
159 |
|
pout("alsa:using pcm device %uHz\n", rate_near); |
133 |
160 |
return; |
return; |
134 |
161 |
} |
} |
135 |
162 |
/* even a "near" rate did failed... try the min */ |
/* even a "near" rate did failed... try the min */ |
136 |
163 |
r = snd_pcm_hw_params_get_rate_min(pcm_hw_params, &rate_min, |
r = snd_pcm_hw_params_get_rate_min(pcm_hw_params, &rate_min, |
137 |
164 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
138 |
165 |
if (r != 0) |
if (r != 0) |
139 |
|
FATALA("alsa:unable to get the minimum rate of pcm device\n"); |
|
|
166 |
|
fatal("alsa:unable to get the minimum rate of pcm device\n"); |
140 |
167 |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_min, |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_min, |
141 |
168 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
142 |
169 |
if (r == 0) { |
if (r == 0) { |
143 |
170 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_min, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_min, |
144 |
171 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
145 |
172 |
if (r != 0) |
if (r != 0) |
146 |
|
FATALA("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_min); |
|
147 |
|
POUTA("alsa:using pcm device %uHz\n", rate_min); |
|
|
173 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_min); |
|
174 |
|
pout("alsa:using pcm device %uHz\n", rate_min); |
148 |
175 |
return; |
return; |
149 |
176 |
} |
} |
150 |
|
FATALA("alsa:unable to find a suitable rate\n"); |
|
|
177 |
|
fatal("alsa:unable to find a suitable rate\n"); |
151 |
178 |
} |
} |
152 |
179 |
STATIC bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
STATIC bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
153 |
180 |
snd_pcm_hw_params_t *pcm_hw_params, snd_pcm_fmt_t fmt) |
snd_pcm_hw_params_t *pcm_hw_params, snd_pcm_fmt_t fmt) |
|
... |
... |
STATIC bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
159 |
186 |
return false; |
return false; |
160 |
187 |
r = snd_pcm_hw_params_set_fmt(pcm, pcm_hw_params, fmt); |
r = snd_pcm_hw_params_set_fmt(pcm, pcm_hw_params, fmt); |
161 |
188 |
if (r != 0) |
if (r != 0) |
162 |
|
FATALA("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_fmt_desc(fmt)); |
|
163 |
|
POUTA("alsa:using \"%s\" format\n", snd_pcm_fmt_desc(fmt)); |
|
|
189 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_fmt_desc(fmt)); |
|
190 |
|
pout("alsa:using \"%s\" format\n", snd_pcm_fmt_desc(fmt)); |
164 |
191 |
return true; |
return true; |
165 |
192 |
} |
} |
166 |
193 |
#define PCM_HW_FMT_DECIDE_X(fmt) pcm_hw_fmt_decide_x(pcm, pcm_hw_params, fmt) |
#define PCM_HW_FMT_DECIDE_X(fmt) pcm_hw_fmt_decide_x(pcm, pcm_hw_params, fmt) |
|
... |
... |
STATIC void pcm_hw_fmt_decide(snd_pcm_t *pcm, |
177 |
204 |
r = snd_pcm_hw_params_set_fmt(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_fmt(pcm, pcm_hw_params, |
178 |
205 |
forced_fmt); |
forced_fmt); |
179 |
206 |
if (r != 0) |
if (r != 0) |
180 |
|
FATALA("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_fmt_desc(forced_fmt)); |
|
181 |
|
POUTA("alsa:using forced \"%s\" format\n", snd_pcm_fmt_desc(forced_fmt)); |
|
|
207 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_fmt_desc(forced_fmt)); |
|
208 |
|
pout("alsa:using forced \"%s\" format\n", snd_pcm_fmt_desc(forced_fmt)); |
182 |
209 |
return; |
return; |
183 |
210 |
} |
} |
184 |
211 |
} |
} |
|
... |
... |
STATIC void pcm_hw_fmt_decide(snd_pcm_t *pcm, |
206 |
233 |
return; |
return; |
207 |
234 |
if (PCM_HW_FMT_DECIDE_X(SND_PCM_FMT_S8)) |
if (PCM_HW_FMT_DECIDE_X(SND_PCM_FMT_S8)) |
208 |
235 |
return; |
return; |
209 |
|
FATALA("alsa:unable to find a suitable format\n"); |
|
|
236 |
|
fatal("alsa:unable to find a suitable format\n"); |
210 |
237 |
} |
} |
211 |
238 |
#undef PCM_HW_FMT_DECIDE_X |
#undef PCM_HW_FMT_DECIDE_X |
212 |
239 |
STATIC bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
STATIC bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
|
... |
... |
STATIC bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
219 |
246 |
return false; |
return false; |
220 |
247 |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, access); |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, access); |
221 |
248 |
if (r != 0) |
if (r != 0) |
222 |
|
FATALA("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(access)); |
|
223 |
|
POUTA("alsa:using \"%s\" access\n", snd_pcm_access_name(access)); |
|
|
249 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(access)); |
|
250 |
|
pout("alsa:using \"%s\" access\n", snd_pcm_access_name(access)); |
224 |
251 |
return true; |
return true; |
225 |
252 |
} |
} |
226 |
253 |
#define PCM_HW_ACCESS_DECIDE_X(access) \ |
#define PCM_HW_ACCESS_DECIDE_X(access) \ |
|
... |
... |
STATIC void pcm_hw_access_decide(snd_pcm_t *pcm, |
240 |
267 |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, |
241 |
268 |
forced_access); |
forced_access); |
242 |
269 |
if (r != 0) |
if (r != 0) |
243 |
|
FATALA("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(forced_access)); |
|
244 |
|
POUTA("alsa:using forced \"%s\" access\n", snd_pcm_access_name(forced_access)); |
|
|
270 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(forced_access)); |
|
271 |
|
pout("alsa:using forced \"%s\" access\n", snd_pcm_access_name(forced_access)); |
245 |
272 |
return; |
return; |
246 |
273 |
} |
} |
247 |
274 |
} |
} |
|
... |
... |
STATIC void pcm_hw_access_decide(snd_pcm_t *pcm, |
250 |
277 |
return; |
return; |
251 |
278 |
if (PCM_HW_ACCESS_DECIDE_X(SND_PCM_ACCESS_RW_NONINTERLEAVED)) |
if (PCM_HW_ACCESS_DECIDE_X(SND_PCM_ACCESS_RW_NONINTERLEAVED)) |
252 |
279 |
return; |
return; |
253 |
|
FATALA("alsa:unable to find a suitable access\n"); |
|
|
280 |
|
fatal("alsa:unable to find a suitable access\n"); |
254 |
281 |
} |
} |
255 |
282 |
#undef PCM_HW_ACCESS_DECIDE_X |
#undef PCM_HW_ACCESS_DECIDE_X |
256 |
283 |
/* |
/* |
|
... |
... |
STATIC void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm, |
273 |
300 |
|
|
274 |
301 |
r = snd_pcm_hw_params_get_rate(pcm_hw_params, &rate, 0); |
r = snd_pcm_hw_params_get_rate(pcm_hw_params, &rate, 0); |
275 |
302 |
if (r < 0) { |
if (r < 0) { |
276 |
|
WARNINGA("alsa:latency control:DISABLING LATENCY CONTROL:unable to get the decided rate from the current device parameters\n"); |
|
|
303 |
|
warning("alsa:latency control:DISABLING LATENCY CONTROL:unable to get the decided rate from the current device parameters\n"); |
277 |
304 |
return; |
return; |
278 |
305 |
} |
} |
279 |
306 |
latency_control_target_buf_ufrs_n = (snd_pcm_ufrs_t)rate; |
latency_control_target_buf_ufrs_n = (snd_pcm_ufrs_t)rate; |
|
... |
... |
STATIC void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm, |
282 |
309 |
r = snd_pcm_hw_params_set_buf_sz_near(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_buf_sz_near(pcm, pcm_hw_params, |
283 |
310 |
&latency_control_buf_ufrs_n); |
&latency_control_buf_ufrs_n); |
284 |
311 |
if (r < 0) { |
if (r < 0) { |
285 |
|
WARNINGA("alsa:latency control:DISABLING_LATENCY_CONTROL:unable to set the audio buffer size (count of frames) to %u periods for the current device parameters\n", latency_control_buf_ufrs_n); |
|
|
312 |
|
warning("alsa:latency control:DISABLING_LATENCY_CONTROL:unable to set the audio buffer size (count of frames) to %u periods for the current device parameters\n", latency_control_buf_ufrs_n); |
286 |
313 |
return; |
return; |
287 |
314 |
} |
} |
288 |
|
POUTA("alsa:latency control:target buffer frame count is %u (~0.25 sec), got an audio buffer size set to %u frames\n", latency_control_target_buf_ufrs_n, latency_control_buf_ufrs_n); |
|
|
315 |
|
pout("alsa:latency control:target buffer frame count is %u (~0.25 sec), got an audio buffer size set to %u frames\n", latency_control_target_buf_ufrs_n, latency_control_buf_ufrs_n); |
289 |
316 |
} |
} |
290 |
317 |
/* |
/* |
291 |
318 |
* this function will "decide" the pcm dev cfg: |
* this function will "decide" the pcm dev cfg: |
|
... |
... |
STATIC void pcm_cfg_hw_core(snd_pcm_t *pcm, snd_pcm_hw_params_t *pcm_hw_params, |
308 |
335 |
/* the return value is from a first refine of the raw hw params */ |
/* the return value is from a first refine of the raw hw params */ |
309 |
336 |
r = snd_pcm_hw_params_any(pcm, pcm_hw_params); |
r = snd_pcm_hw_params_any(pcm, pcm_hw_params); |
310 |
337 |
if (r < 0) |
if (r < 0) |
311 |
|
FATALA("alsa:unable to populate the hardware parameters context\n"); |
|
|
338 |
|
fatal("alsa:unable to populate the hardware parameters context\n"); |
312 |
339 |
pcm_hw_chans_n_decide(pcm, pcm_hw_params, (unsigned int)chans_n); |
pcm_hw_chans_n_decide(pcm, pcm_hw_params, (unsigned int)chans_n); |
313 |
340 |
pcm_hw_rate_decide(pcm, pcm_hw_params, (unsigned int)rate); |
pcm_hw_rate_decide(pcm, pcm_hw_params, (unsigned int)rate); |
314 |
341 |
/* try our best */ |
/* try our best */ |
|
... |
... |
STATIC void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
337 |
364 |
snd_pcm_access_t access; |
snd_pcm_access_t access; |
338 |
365 |
snd_pcm_hw_params_t *hw_params; |
snd_pcm_hw_params_t *hw_params; |
339 |
366 |
|
|
340 |
|
POUTA("ALSA:HW_PARAMS START------------------------------------------------------------\n"); |
|
|
367 |
|
pout("ALSA:HW_PARAMS START------------------------------------------------------------\n"); |
341 |
368 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
342 |
369 |
if (r < 0) |
if (r < 0) |
343 |
|
FATALA("alsa:unable to allocate hardware parameters context\n"); |
|
|
370 |
|
fatal("alsa:unable to allocate hardware parameters context\n"); |
344 |
371 |
|
|
345 |
372 |
pcm_cfg_hw_core(pcm, hw_params, chans_n, rate, ff_fmt); |
pcm_cfg_hw_core(pcm, hw_params, chans_n, rate, ff_fmt); |
346 |
373 |
|
|
347 |
374 |
r = snd_pcm_hw_params(pcm, hw_params); |
r = snd_pcm_hw_params(pcm, hw_params); |
348 |
375 |
if (r != 0) |
if (r != 0) |
349 |
|
FATALA("alsa:unable to install the hardware parameters\n"); |
|
|
376 |
|
fatal("alsa:unable to install the hardware parameters\n"); |
350 |
377 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
351 |
378 |
if (r != 0) |
if (r != 0) |
352 |
|
FATALA("alsa:unable to get current hardware parameters\n"); |
|
|
379 |
|
fatal("alsa:unable to get current hardware parameters\n"); |
353 |
380 |
snd_pcm_hw_params_dump(hw_params, pcm_pout_l); |
snd_pcm_hw_params_dump(hw_params, pcm_pout_l); |
354 |
381 |
|
|
355 |
382 |
i = 0; |
i = 0; |
|
... |
... |
STATIC void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
360 |
387 |
r = snd_pcm_hw_params_supports_audio_ts_type(hw_params, i); |
r = snd_pcm_hw_params_supports_audio_ts_type(hw_params, i); |
361 |
388 |
if (r == 1) { |
if (r == 1) { |
362 |
389 |
selected_ts_type_p = i; |
selected_ts_type_p = i; |
363 |
|
POUTA("kernel audio timestamp type \"%s\" is supported for the current configuration\n", kernel_ts_types_str[i]); |
|
|
390 |
|
pout("kernel audio timestamp type \"%s\" is supported for the current configuration\n", kernel_ts_types_str[i]); |
364 |
391 |
} |
} |
365 |
392 |
++i; |
++i; |
366 |
393 |
} |
} |
|
... |
... |
STATIC void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
368 |
395 |
* we selected the most accurate, namely with the highest idx, audio ts |
* we selected the most accurate, namely with the highest idx, audio ts |
369 |
396 |
* type |
* type |
370 |
397 |
*/ |
*/ |
371 |
|
POUTA("%s will be used for the audio based clock\n", kernel_ts_types_str[selected_ts_type_p]); |
|
|
398 |
|
pout("%s will be used for the audio based clock\n", kernel_ts_types_str[selected_ts_type_p]); |
372 |
399 |
snd_pcm_hw_params_free(hw_params); |
snd_pcm_hw_params_free(hw_params); |
373 |
|
POUTA("ALSA:HW_PARAMS END--------------------------------------------------------------\n"); |
|
|
400 |
|
pout("ALSA:HW_PARAMS END--------------------------------------------------------------\n"); |
374 |
401 |
} |
} |
375 |
402 |
STATIC void pcm_cfg_sw(snd_pcm_t *pcm) |
STATIC void pcm_cfg_sw(snd_pcm_t *pcm) |
376 |
403 |
{ |
{ |
377 |
404 |
int r; |
int r; |
378 |
405 |
snd_pcm_sw_params_t *sw_params; |
snd_pcm_sw_params_t *sw_params; |
379 |
406 |
|
|
380 |
|
POUTA("ALSA:SW_PARAMS START------------------------------------------------------------\n"); |
|
|
407 |
|
pout("ALSA:SW_PARAMS START------------------------------------------------------------\n"); |
381 |
408 |
r = snd_pcm_sw_params_malloc(&sw_params); |
r = snd_pcm_sw_params_malloc(&sw_params); |
382 |
409 |
if (r != 0) |
if (r != 0) |
383 |
|
FATALA("alsa:unable to allocate software parameters structure\n"); |
|
|
410 |
|
fatal("alsa:unable to allocate software parameters structure\n"); |
384 |
411 |
r = snd_pcm_sw_params_current(pcm, sw_params); |
r = snd_pcm_sw_params_current(pcm, sw_params); |
385 |
412 |
if (r != 0) |
if (r != 0) |
386 |
|
FATALA("alsa:unable to get current software parameters\n"); |
|
|
413 |
|
fatal("alsa:unable to get current software parameters\n"); |
387 |
414 |
r = snd_pcm_sw_params_set_period_evt(pcm, sw_params, 1); |
r = snd_pcm_sw_params_set_period_evt(pcm, sw_params, 1); |
388 |
415 |
if (r != 0) |
if (r != 0) |
389 |
|
FATALA("alsa:unable to enable period event\n"); |
|
|
416 |
|
fatal("alsa:unable to enable period event\n"); |
390 |
417 |
/* enable ts to be sure */ |
/* enable ts to be sure */ |
391 |
418 |
r = snd_pcm_sw_params_set_tstamp_mode(pcm, sw_params, |
r = snd_pcm_sw_params_set_tstamp_mode(pcm, sw_params, |
392 |
419 |
SND_PCM_TSTAMP_ENABLE); |
SND_PCM_TSTAMP_ENABLE); |
393 |
420 |
if (r < 0) |
if (r < 0) |
394 |
|
FATALA("unable to set timestamp mode:%s\n", snd_strerror(r)); |
|
|
421 |
|
fatal("unable to set timestamp mode:%s\n", snd_strerror(r)); |
395 |
422 |
r = snd_pcm_sw_params(pcm, sw_params); |
r = snd_pcm_sw_params(pcm, sw_params); |
396 |
423 |
if (r != 0) |
if (r != 0) |
397 |
|
FATALA("alsa:unable to install sotfware parameters\n"); |
|
|
424 |
|
fatal("alsa:unable to install sotfware parameters\n"); |
398 |
425 |
snd_pcm_sw_params_dump(sw_params, pcm_pout_l); |
snd_pcm_sw_params_dump(sw_params, pcm_pout_l); |
399 |
426 |
snd_pcm_sw_params_free(sw_params); |
snd_pcm_sw_params_free(sw_params); |
400 |
|
POUTA("ALSA:SW_PARAMS END--------------------------------------------------------------\n"); |
|
|
427 |
|
pout("ALSA:SW_PARAMS END--------------------------------------------------------------\n"); |
401 |
428 |
} |
} |
402 |
429 |
STATIC void dec_a_grow(void) |
STATIC void dec_a_grow(void) |
403 |
430 |
{ |
{ |
|
... |
... |
STATIC void dec_a_grow(void) |
407 |
434 |
dec_sets_p.a = realloc(dec_sets_p.a, sizeof(*dec_sets_p.a) |
dec_sets_p.a = realloc(dec_sets_p.a, sizeof(*dec_sets_p.a) |
408 |
435 |
* (dec_sets_p.n_max + 1)); |
* (dec_sets_p.n_max + 1)); |
409 |
436 |
if (dec_sets_p.a == 0) |
if (dec_sets_p.a == 0) |
410 |
|
FATALA("unable to allocate memory for an additional pointer on a reference of a decoder set of frames\n"); |
|
|
437 |
|
fatal("unable to allocate memory for an additional pointer on a reference of a decoder set of frames\n"); |
411 |
438 |
dec_sets_p.a[new_idx] = avutil_audio_set_ref_alloc(); |
dec_sets_p.a[new_idx] = avutil_audio_set_ref_alloc(); |
412 |
439 |
if (dec_sets_p.a[new_idx] == 0) |
if (dec_sets_p.a[new_idx] == 0) |
413 |
|
FATALA("ffmpeg:unable to allocate a reference of a decoder set of frames\n"); |
|
|
440 |
|
fatal("ffmpeg:unable to allocate a reference of a decoder set of frames\n"); |
414 |
441 |
++dec_sets_p.n_max; |
++dec_sets_p.n_max; |
415 |
442 |
} |
} |
416 |
443 |
#define AGAIN 0 |
#define AGAIN 0 |
|
... |
... |
STATIC u8 alsa_recover(snd_pcm_sfrs_t r) |
429 |
456 |
|
|
430 |
457 |
r_recovered = snd_pcm_recover(pcm_p, (int)r, 0); |
r_recovered = snd_pcm_recover(pcm_p, (int)r, 0); |
431 |
458 |
if (r_recovered == 0) { |
if (r_recovered == 0) { |
432 |
|
WARNINGA("alsa:pcm recovered\n"); |
|
|
459 |
|
warning("alsa:pcm recovered\n"); |
433 |
460 |
return RECOVERED; |
return RECOVERED; |
434 |
461 |
} |
} |
435 |
|
FATALA("alsa:unable to recover from suspend/underrun\n"); |
|
|
462 |
|
fatal("alsa:unable to recover from suspend/underrun\n"); |
436 |
463 |
} |
} |
437 |
|
FATALA("alsa:fatal/unhandled error\n"); |
|
|
464 |
|
fatal("alsa:fatal/unhandled error\n"); |
438 |
465 |
} |
} |
439 |
466 |
#undef AGAIN |
#undef AGAIN |
440 |
467 |
#undef RECOVERED |
#undef RECOVERED |
|
... |
... |
STATIC void draining_state_handle(void) |
541 |
568 |
*/ |
*/ |
542 |
569 |
state = snd_pcm_state(pcm_p); |
state = snd_pcm_state(pcm_p); |
543 |
570 |
if (state != SND_PCM_STATE_SETUP) |
if (state != SND_PCM_STATE_SETUP) |
544 |
|
FATALA("alsa:an error occured switching to/checking the pcm draining state\n"); |
|
|
571 |
|
fatal("alsa:an error occured switching to/checking the pcm draining state\n"); |
545 |
572 |
/* here pcm state is SND_PCM_STATE_SETUP */ |
/* here pcm state is SND_PCM_STATE_SETUP */ |
546 |
573 |
} |
} |
547 |
|
EXIT("alsa pcm drained or similar, exiting\n"); |
|
|
574 |
|
npv_exit("alsa pcm drained or similar, exiting\n"); |
548 |
575 |
} |
} |
549 |
576 |
STATIC void draining_state_switch(void) |
STATIC void draining_state_switch(void) |
550 |
577 |
{ |
{ |
|
... |
... |
STATIC void draining_state_switch(void) |
563 |
590 |
r = epoll_ctl(npv_ep_fd_p, EPOLL_CTL_DEL, pcm_pollfds_p[i].fd, |
r = epoll_ctl(npv_ep_fd_p, EPOLL_CTL_DEL, pcm_pollfds_p[i].fd, |
564 |
591 |
0); |
0); |
565 |
592 |
if (r == -1) |
if (r == -1) |
566 |
|
FATALA("unable to remove the alsa file descriptors from epoll\n"); |
|
|
593 |
|
fatal("unable to remove the alsa file descriptors from epoll\n"); |
567 |
594 |
++i; |
++i; |
568 |
595 |
} |
} |
569 |
596 |
/* start the draining timer */ |
/* start the draining timer */ |
|
... |
... |
STATIC void draining_state_switch(void) |
573 |
600 |
t.it_interval.tv_nsec = DRAINING_TIMER_INTERVAL_NSECS_N; |
t.it_interval.tv_nsec = DRAINING_TIMER_INTERVAL_NSECS_N; |
574 |
601 |
r = timerfd_settime(draining_timer_fd_p, 0, &t, 0); |
r = timerfd_settime(draining_timer_fd_p, 0, &t, 0); |
575 |
602 |
if (r == -1) |
if (r == -1) |
576 |
|
FATALA("unable to arm the draining timer\n"); |
|
|
603 |
|
fatal("unable to arm the draining timer\n"); |
577 |
604 |
} |
} |
578 |
605 |
#define NO 0 |
#define NO 0 |
579 |
606 |
#define AGAIN 0 |
#define AGAIN 0 |
|
... |
... |
STATIC void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt, |
713 |
740 |
*ff_fmt = AVUTIL_AUDIO_FR_FMT_U8P; |
*ff_fmt = AVUTIL_AUDIO_FR_FMT_U8P; |
714 |
741 |
break; |
break; |
715 |
742 |
default: |
default: |
716 |
|
FATALA("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access)); |
|
|
743 |
|
fatal("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access)); |
717 |
744 |
} |
} |
718 |
745 |
if (print_info) { |
if (print_info) { |
719 |
746 |
u8 ff_fmt_str[STR_SZ]; |
u8 ff_fmt_str[STR_SZ]; |
720 |
747 |
|
|
721 |
748 |
avutil_get_audio_fr_fmt_str(ff_fmt_str, sizeof(ff_fmt_str), |
avutil_get_audio_fr_fmt_str(ff_fmt_str, sizeof(ff_fmt_str), |
722 |
749 |
*ff_fmt); |
*ff_fmt); |
723 |
|
POUTA("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); |
|
|
750 |
|
pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); |
724 |
751 |
} |
} |
725 |
752 |
} |
} |
726 |
753 |
/* |
/* |
|
... |
... |
STATIC uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm, |
738 |
765 |
pcm_chmap = snd_pcm_get_chmap(pcm); |
pcm_chmap = snd_pcm_get_chmap(pcm); |
739 |
766 |
if (pcm_chmap == 0) { |
if (pcm_chmap == 0) { |
740 |
767 |
if (print_info) |
if (print_info) |
741 |
|
POUTA("alsa:no pcm channel map available, wiring to default ffmpeg channel layout\n"); |
|
|
768 |
|
pout("alsa:no pcm channel map available, wiring to default ffmpeg channel layout\n"); |
742 |
769 |
} else { |
} else { |
743 |
770 |
if (print_info) |
if (print_info) |
744 |
|
POUTA("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n"); |
|
|
771 |
|
pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n"); |
745 |
772 |
free(pcm_chmap); |
free(pcm_chmap); |
746 |
773 |
} |
} |
747 |
774 |
ff_chans_layout = avutil_get_default_chans_layout((int)pcm_chans_n); |
ff_chans_layout = avutil_get_default_chans_layout((int)pcm_chans_n); |
748 |
775 |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str), |
749 |
776 |
(int)pcm_chans_n, ff_chans_layout); |
(int)pcm_chans_n, ff_chans_layout); |
750 |
777 |
if (print_info) |
if (print_info) |
751 |
|
POUTA("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); |
|
|
778 |
|
pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); |
752 |
779 |
return ff_chans_layout; |
return ff_chans_layout; |
753 |
780 |
} |
} |
754 |
781 |
STATIC void init_pcm_once_public(u8 *pcm_str) |
STATIC void init_pcm_once_public(u8 *pcm_str) |
|
... |
... |
STATIC void init_pcm_once_public(u8 *pcm_str) |
759 |
786 |
SND_PCM_NONBLOCK); |
SND_PCM_NONBLOCK); |
760 |
787 |
if (r < 0) { |
if (r < 0) { |
761 |
788 |
if (r == -EAGAIN) |
if (r == -EAGAIN) |
762 |
|
FATALA("alsa:\"%s\" pcm is already in use\n", pcm_str); |
|
|
789 |
|
fatal("alsa:\"%s\" pcm is already in use\n", pcm_str); |
763 |
790 |
else |
else |
764 |
|
FATALA("alsa:unable to open \"%s\" pcm for playback\n", pcm_str); |
|
|
791 |
|
fatal("alsa:unable to open \"%s\" pcm for playback\n", pcm_str); |
765 |
792 |
} |
} |
766 |
793 |
|
|
767 |
794 |
r = snd_pcm_poll_descriptors_n(pcm_p); |
r = snd_pcm_poll_descriptors_n(pcm_p); |
768 |
|
POUTA("alsa:have %d poll file descriptors\n", r); |
|
|
795 |
|
pout("alsa:have %d poll file descriptors\n", r); |
769 |
796 |
if ((r <= 0) || (r > pcm_pollfds_n_max)) |
if ((r <= 0) || (r > pcm_pollfds_n_max)) |
770 |
|
FATALA("alsa:invalid count of alsa poll file descriptors\n"); |
|
|
797 |
|
fatal("alsa:invalid count of alsa poll file descriptors\n"); |
771 |
798 |
pcm_pollfds_n_p =(u8)r; |
pcm_pollfds_n_p =(u8)r; |
772 |
799 |
memset(pcm_pollfds_p, 0, sizeof(pcm_pollfds_p)); |
memset(pcm_pollfds_p, 0, sizeof(pcm_pollfds_p)); |
773 |
800 |
snd_pcm_poll_descriptors(pcm_p, pcm_pollfds_p, pcm_pollfds_n_max); |
snd_pcm_poll_descriptors(pcm_p, pcm_pollfds_p, pcm_pollfds_n_max); |
|
... |
... |
STATIC void init_once_public(u8 *pcm_str) |
789 |
816 |
errno = 0; |
errno = 0; |
790 |
817 |
draining_timer_fd_p = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
draining_timer_fd_p = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
791 |
818 |
if (draining_timer_fd_p == -1) |
if (draining_timer_fd_p == -1) |
792 |
|
FATALA("unable to get a draining timer file descriptor:%s\n", strerror(errno)); |
|
|
819 |
|
fatal("unable to get a draining timer file descriptor:%s\n", strerror(errno)); |
793 |
820 |
draining_p = false; |
draining_p = false; |
794 |
821 |
r = pthread_mutex_init(&dec_ctx_mutex_l, 0); |
r = pthread_mutex_init(&dec_ctx_mutex_l, 0); |
795 |
822 |
if (r != 0) |
if (r != 0) |
796 |
|
FATALA("%d:unable to init the decoder mutex\n", r); |
|
|
823 |
|
fatal("%d:unable to init the decoder mutex\n", r); |
797 |
824 |
r = pthread_mutex_init(&dec_sets_p.mutex, 0); |
r = pthread_mutex_init(&dec_sets_p.mutex, 0); |
798 |
825 |
if (r != 0) |
if (r != 0) |
799 |
|
FATALA("%d:unable to init the mutex for the array of decoder sets\n", r); |
|
|
826 |
|
fatal("%d:unable to init the mutex for the array of decoder sets\n", r); |
800 |
827 |
} |
} |
801 |
828 |
STATIC void init_once_local(void) |
STATIC void init_once_local(void) |
802 |
829 |
{ |
{ |
|
... |
... |
STATIC void init_once_local(void) |
805 |
832 |
dec_l = 0; |
dec_l = 0; |
806 |
833 |
r = snd_output_stdio_attach(&pcm_pout_l, stdout, 0); |
r = snd_output_stdio_attach(&pcm_pout_l, stdout, 0); |
807 |
834 |
if (r < 0) |
if (r < 0) |
808 |
|
FATALA("alsa:unable to attach stdout\n"); |
|
|
835 |
|
fatal("alsa:unable to attach stdout\n"); |
809 |
836 |
r = snd_output_stdio_attach(&pcm_perr_l, stderr, 0); |
r = snd_output_stdio_attach(&pcm_perr_l, stderr, 0); |
810 |
837 |
if (r < 0) |
if (r < 0) |
811 |
|
FATALA("alsa:unable to attach stderr\n"); |
|
|
838 |
|
fatal("alsa:unable to attach stderr\n"); |
812 |
839 |
memset(pcm_silence_bufs_l, 0, sizeof(pcm_silence_bufs_l)); |
memset(pcm_silence_bufs_l, 0, sizeof(pcm_silence_bufs_l)); |
813 |
840 |
} |
} |
814 |
841 |
STATIC void dec_a_unref_all(void) |
STATIC void dec_a_unref_all(void) |
File npv/audio/public/code.frag.c changed (mode: 100644) (index aff40c1..bbd0bc9) |
... |
... |
STATIC void dec_ctx_cfg(avcodec_params_t *params) |
4 |
4 |
|
|
5 |
5 |
dec_l = avcodec_find_dec(params->codec_id); |
dec_l = avcodec_find_dec(params->codec_id); |
6 |
6 |
if (dec_l == 0) |
if (dec_l == 0) |
7 |
|
FATALA("ffmpeg:unable to find a proper decoder\n"); |
|
|
7 |
|
fatal("ffmpeg:unable to find a proper decoder\n"); |
8 |
8 |
avcodec_free_context(&dec_ctx_p); |
avcodec_free_context(&dec_ctx_p); |
9 |
9 |
dec_ctx_p = avcodec_alloc_ctx(dec_l); |
dec_ctx_p = avcodec_alloc_ctx(dec_l); |
10 |
10 |
if (dec_ctx_p == 0) |
if (dec_ctx_p == 0) |
11 |
|
FATALA("ffmpeg:unable to allocate a decoder context\n"); |
|
|
11 |
|
fatal("ffmpeg:unable to allocate a decoder context\n"); |
12 |
12 |
/* XXX: useless ? */ |
/* XXX: useless ? */ |
13 |
13 |
r = avcodec_params_to_ctx(dec_ctx_p, params); |
r = avcodec_params_to_ctx(dec_ctx_p, params); |
14 |
14 |
if (r < 0) |
if (r < 0) |
15 |
|
FATALA("ffmpeg:unable to apply stream codec parameters in codec context\n"); |
|
|
15 |
|
fatal("ffmpeg:unable to apply stream codec parameters in codec context\n"); |
16 |
16 |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
17 |
17 |
dec_ctx_p->thread_count = 0; |
dec_ctx_p->thread_count = 0; |
18 |
18 |
r = avcodec_open2(dec_ctx_p, dec_l, 0); |
r = avcodec_open2(dec_ctx_p, dec_l, 0); |
19 |
19 |
if (r < 0) |
if (r < 0) |
20 |
|
FATALA("ffmpeg:unable to open the decoder context\n"); |
|
|
20 |
|
fatal("ffmpeg:unable to open the decoder context\n"); |
21 |
21 |
} |
} |
22 |
22 |
#define AGAIN 0 |
#define AGAIN 0 |
23 |
23 |
#define HAVE_DEC_SET 1 |
#define HAVE_DEC_SET 1 |
|
... |
... |
STATIC u8 dec_set_try_receive(void) |
40 |
40 |
++dec_sets_p.n; |
++dec_sets_p.n; |
41 |
41 |
return HAVE_DEC_SET; |
return HAVE_DEC_SET; |
42 |
42 |
} else if (r == AVUTIL_AVERROR_EOF) { |
} else if (r == AVUTIL_AVERROR_EOF) { |
43 |
|
POUTA("ffmpeg:last decoder set of frames reached (receiving)\n"); |
|
|
43 |
|
pout("ffmpeg:last decoder set of frames reached (receiving)\n"); |
44 |
44 |
dec_sets_p.eof_receive = true; |
dec_sets_p.eof_receive = true; |
45 |
45 |
return EOF_DEC; |
return EOF_DEC; |
46 |
46 |
} |
} |
47 |
|
FATALA("ffmpeg:error while receiving a set of frames from the decoder\n"); |
|
|
47 |
|
fatal("ffmpeg:error while receiving a set of frames from the decoder\n"); |
48 |
48 |
} |
} |
49 |
49 |
#undef AGAIN |
#undef AGAIN |
50 |
50 |
#undef HAVE_DEC_SET |
#undef HAVE_DEC_SET |
|
... |
... |
STATIC void draining_state_evt(void) |
80 |
80 |
|
|
81 |
81 |
r = read(draining_timer_fd_p, &exps_n, sizeof(exps_n)); |
r = read(draining_timer_fd_p, &exps_n, sizeof(exps_n)); |
82 |
82 |
if (r == -1) |
if (r == -1) |
83 |
|
FATALA("unable to read the number of draining state timer expirations\n"); |
|
|
83 |
|
fatal("unable to read the number of draining state timer expirations\n"); |
84 |
84 |
draining_state_handle(); |
draining_state_handle(); |
85 |
85 |
} |
} |
86 |
86 |
#define AGAIN 0 |
#define AGAIN 0 |
|
... |
... |
STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
116 |
116 |
|
|
117 |
117 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
118 |
118 |
if (r < 0) |
if (r < 0) |
119 |
|
FATALA("silence:alsa:unable to allocate memory for a hardware parameters container\n"); |
|
|
119 |
|
fatal("silence:alsa:unable to allocate memory for a hardware parameters container\n"); |
120 |
120 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
121 |
121 |
if (r != 0) |
if (r != 0) |
122 |
|
FATALA("silence:alsa:unable to get the pcm hardware parameters\n"); |
|
|
122 |
|
fatal("silence:alsa:unable to get the pcm hardware parameters\n"); |
123 |
123 |
r = snd_pcm_hw_params_get_buf_sz(hw_params, &buf_ufrs_n); |
r = snd_pcm_hw_params_get_buf_sz(hw_params, &buf_ufrs_n); |
124 |
124 |
if (r < 0) |
if (r < 0) |
125 |
|
FATALA("silence:alsa:unable to get the number of frames in the pcm buffer\n"); |
|
|
125 |
|
fatal("silence:alsa:unable to get the number of frames in the pcm buffer\n"); |
126 |
126 |
r = snd_pcm_hw_params_get_format(hw_params, &fmt); |
r = snd_pcm_hw_params_get_format(hw_params, &fmt); |
127 |
127 |
if (r < 0) |
if (r < 0) |
128 |
|
FATALA("silence:alsa:unable to get the pcm format\n"); |
|
|
128 |
|
fatal("silence:alsa:unable to get the pcm format\n"); |
129 |
129 |
r = snd_pcm_hw_params_get_access(hw_params, &access); |
r = snd_pcm_hw_params_get_access(hw_params, &access); |
130 |
130 |
if (r < 0) |
if (r < 0) |
131 |
|
FATALA("silence:alsa:unable to get the pcm access mode\n"); |
|
|
131 |
|
fatal("silence:alsa:unable to get the pcm access mode\n"); |
132 |
132 |
r = snd_pcm_hw_params_get_channels(hw_params, &chans_n); |
r = snd_pcm_hw_params_get_channels(hw_params, &chans_n); |
133 |
133 |
if (r < 0) |
if (r < 0) |
134 |
|
FATALA("silence:alsa:unable to get the pcm number of channels\n"); |
|
|
134 |
|
fatal("silence:alsa:unable to get the pcm number of channels\n"); |
135 |
135 |
|
|
136 |
136 |
/* wipe silence bufs first */ |
/* wipe silence bufs first */ |
137 |
137 |
c = 0; |
c = 0; |
|
... |
... |
STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
151 |
151 |
buf_bytes_n = snd_pcm_frames_to_bytes(pcm, |
buf_bytes_n = snd_pcm_frames_to_bytes(pcm, |
152 |
152 |
(snd_pcm_sframes_t)buf_ufrs_n); |
(snd_pcm_sframes_t)buf_ufrs_n); |
153 |
153 |
if (buf_bytes_n <= 0) |
if (buf_bytes_n <= 0) |
154 |
|
FATALA("silence:alsa:interleaved:unable to get the pcm number of bytes of all buffer frames\n"); |
|
|
154 |
|
fatal("silence:alsa:interleaved:unable to get the pcm number of bytes of all buffer frames\n"); |
155 |
155 |
pcm_silence_bufs_l[0] = malloc((size_t)buf_bytes_n); |
pcm_silence_bufs_l[0] = malloc((size_t)buf_bytes_n); |
156 |
156 |
if (pcm_silence_bufs_l[0] == 0) |
if (pcm_silence_bufs_l[0] == 0) |
157 |
|
FATALA("silence:interleaved:unable to allocate the silence buffer of %d bytes\n", (int)buf_bytes_n); |
|
|
157 |
|
fatal("silence:interleaved:unable to allocate the silence buffer of %d bytes\n", (int)buf_bytes_n); |
158 |
158 |
if (print_info) |
if (print_info) |
159 |
|
POUTA("silence:interleaved:buffer of %d bytes is allocated\n", (int)buf_bytes_n); |
|
|
159 |
|
pout("silence:interleaved:buffer of %d bytes is allocated\n", (int)buf_bytes_n); |
160 |
160 |
r = snd_pcm_format_set_silence(fmt, pcm_silence_bufs_l[0], |
r = snd_pcm_format_set_silence(fmt, pcm_silence_bufs_l[0], |
161 |
161 |
(unsigned int)buf_ufrs_n); |
(unsigned int)buf_ufrs_n); |
162 |
162 |
if (r < 0) |
if (r < 0) |
163 |
|
FATALA("silence:interleaved:unable to fill with silence the buffer\n"); |
|
164 |
|
POUTA("silence:interleaved:silence buffer filled with %u silence frames\n", buf_ufrs_n); |
|
|
163 |
|
fatal("silence:interleaved:unable to fill with silence the buffer\n"); |
|
164 |
|
pout("silence:interleaved:silence buffer filled with %u silence frames\n", buf_ufrs_n); |
165 |
165 |
} else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED |
} else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED |
166 |
166 |
|| access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED) { |
|| access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED) { |
167 |
167 |
ssize_t buf_bytes_n; |
ssize_t buf_bytes_n; |
|
... |
... |
STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
170 |
170 |
buf_samples_n = (long)buf_ufrs_n; |
buf_samples_n = (long)buf_ufrs_n; |
171 |
171 |
buf_bytes_n = snd_pcm_samples_to_bytes(pcm, buf_samples_n); |
buf_bytes_n = snd_pcm_samples_to_bytes(pcm, buf_samples_n); |
172 |
172 |
if (buf_bytes_n <= 0) |
if (buf_bytes_n <= 0) |
173 |
|
FATALA("silence:alsa:non interleaved:unable to get the pcm number of total bytes of all buffer samples\n"); |
|
|
173 |
|
fatal("silence:alsa:non interleaved:unable to get the pcm number of total bytes of all buffer samples\n"); |
174 |
174 |
c = 0; |
c = 0; |
175 |
175 |
loop { |
loop { |
176 |
176 |
if (c == chans_n) |
if (c == chans_n) |
177 |
177 |
break; |
break; |
178 |
178 |
pcm_silence_bufs_l[c] = malloc((size_t)buf_bytes_n); |
pcm_silence_bufs_l[c] = malloc((size_t)buf_bytes_n); |
179 |
179 |
if (pcm_silence_bufs_l[c] == 0) |
if (pcm_silence_bufs_l[c] == 0) |
180 |
|
FATALA("silence:non interleaved:unable to allocate silence buffer %u of %d bytes\n", c, (int)buf_bytes_n); |
|
|
180 |
|
fatal("silence:non interleaved:unable to allocate silence buffer %u of %d bytes\n", c, (int)buf_bytes_n); |
181 |
181 |
r = snd_pcm_format_set_silence(fmt, |
r = snd_pcm_format_set_silence(fmt, |
182 |
182 |
pcm_silence_bufs_l[c], |
pcm_silence_bufs_l[c], |
183 |
183 |
(unsigned int)buf_samples_n); |
(unsigned int)buf_samples_n); |
184 |
184 |
if (r < 0) |
if (r < 0) |
185 |
|
FATALA("silence:non interleaved:unable to fill with silence the buffer\n"); |
|
|
185 |
|
fatal("silence:non interleaved:unable to fill with silence the buffer\n"); |
186 |
186 |
if (print_info) |
if (print_info) |
187 |
|
POUTA("silence:non interleaved:buffer[%u] of %d bytes is allocated\n", c, (int)buf_bytes_n); |
|
|
187 |
|
pout("silence:non interleaved:buffer[%u] of %d bytes is allocated\n", c, (int)buf_bytes_n); |
188 |
188 |
++c; |
++c; |
189 |
189 |
} |
} |
190 |
190 |
if (print_info) |
if (print_info) |
191 |
|
POUTA("silence:non interleaved:allocated %u silence buffers for %u frames\n", chans_n, (unsigned int)buf_ufrs_n); |
|
|
191 |
|
pout("silence:non interleaved:allocated %u silence buffers for %u frames\n", chans_n, (unsigned int)buf_ufrs_n); |
192 |
192 |
} else |
} else |
193 |
|
FATALA("silence:the pcm access type is not supported\n"); |
|
|
193 |
|
fatal("silence:the pcm access type is not supported\n"); |
194 |
194 |
snd_pcm_hw_params_free(hw_params); |
snd_pcm_hw_params_free(hw_params); |
195 |
195 |
} |
} |
196 |
196 |
STATIC void init_once(u8 *pcm_str) |
STATIC void init_once(u8 *pcm_str) |
|
... |
... |
STATIC void dec_ctx_lock(void) |
211 |
211 |
|
|
212 |
212 |
r = pthread_mutex_lock(&dec_ctx_mutex_l); |
r = pthread_mutex_lock(&dec_ctx_mutex_l); |
213 |
213 |
if (r != 0) |
if (r != 0) |
214 |
|
FATALA("%d:unable to lock the decoder context\n", r); |
|
|
214 |
|
fatal("%d:unable to lock the decoder context\n", r); |
215 |
215 |
} |
} |
216 |
216 |
STATIC void dec_ctx_unlock(void) |
STATIC void dec_ctx_unlock(void) |
217 |
217 |
{ |
{ |
|
... |
... |
STATIC void dec_ctx_unlock(void) |
219 |
219 |
|
|
220 |
220 |
r = pthread_mutex_unlock(&dec_ctx_mutex_l); |
r = pthread_mutex_unlock(&dec_ctx_mutex_l); |
221 |
221 |
if (r != 0) |
if (r != 0) |
222 |
|
FATALA("%d:unable to unlock the decoder context\n", r); |
|
|
222 |
|
fatal("%d:unable to unlock the decoder context\n", r); |
223 |
223 |
} |
} |
224 |
224 |
STATIC void dec_sets_lock(void) |
STATIC void dec_sets_lock(void) |
225 |
225 |
{ |
{ |
|
... |
... |
STATIC void dec_sets_lock(void) |
227 |
227 |
|
|
228 |
228 |
r = pthread_mutex_lock(&dec_sets_p.mutex); |
r = pthread_mutex_lock(&dec_sets_p.mutex); |
229 |
229 |
if (r != 0) |
if (r != 0) |
230 |
|
FATALA("%d:unable to lock the array of decoder sets\n", r); |
|
|
230 |
|
fatal("%d:unable to lock the array of decoder sets\n", r); |
231 |
231 |
} |
} |
232 |
232 |
STATIC void dec_sets_unlock(void) |
STATIC void dec_sets_unlock(void) |
233 |
233 |
{ |
{ |
|
... |
... |
STATIC void dec_sets_unlock(void) |
235 |
235 |
|
|
236 |
236 |
r = pthread_mutex_unlock(&dec_sets_p.mutex); |
r = pthread_mutex_unlock(&dec_sets_p.mutex); |
237 |
237 |
if (r != 0) |
if (r != 0) |
238 |
|
FATALA("%d:unable to unlock the array of decoder sets\n", r); |
|
|
238 |
|
fatal("%d:unable to unlock the array of decoder sets\n", r); |
239 |
239 |
} |
} |
240 |
240 |
STATIC void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
STATIC void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
241 |
241 |
enum avutil_audio_fr_fmt_t ff_fmt) |
enum avutil_audio_fr_fmt_t ff_fmt) |
242 |
242 |
{ |
{ |
243 |
243 |
pcm_cfg_hw(pcm, chans_n, rate, ff_fmt); |
pcm_cfg_hw(pcm, chans_n, rate, ff_fmt); |
244 |
244 |
pcm_cfg_sw(pcm); |
pcm_cfg_sw(pcm); |
245 |
|
POUTA("ALSA PCM DUMP START-------------------------------------------------------------\n"); |
|
|
245 |
|
pout("ALSA PCM DUMP START-------------------------------------------------------------\n"); |
246 |
246 |
snd_pcm_dump(pcm, pcm_pout_l); |
snd_pcm_dump(pcm, pcm_pout_l); |
247 |
|
POUTA("ALSA PCM DUMP END---------------------------------------------------------------\n"); |
|
|
247 |
|
pout("ALSA PCM DUMP END---------------------------------------------------------------\n"); |
248 |
248 |
} |
} |
249 |
249 |
STATIC void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt, |
STATIC void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt, |
250 |
250 |
int *ff_rate, int *ff_chans_n, uint64_t *ff_chans_layout, |
int *ff_rate, int *ff_chans_n, uint64_t *ff_chans_layout, |
|
... |
... |
STATIC void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt, |
259 |
259 |
|
|
260 |
260 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
261 |
261 |
if (r < 0) |
if (r < 0) |
262 |
|
FATALA("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n"); |
|
|
262 |
|
fatal("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n"); |
263 |
263 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
264 |
264 |
if (r != 0) |
if (r != 0) |
265 |
|
FATALA("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n"); |
|
|
265 |
|
fatal("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n"); |
266 |
266 |
r = snd_pcm_hw_params_get_access(hw_params, &pcm_access); |
r = snd_pcm_hw_params_get_access(hw_params, &pcm_access); |
267 |
267 |
if (r < 0) |
if (r < 0) |
268 |
|
FATALA("alsa:unable to get the pcm access for ffmpeg filter wiring\n"); |
|
|
268 |
|
fatal("alsa:unable to get the pcm access for ffmpeg filter wiring\n"); |
269 |
269 |
r = snd_pcm_hw_params_get_fmt(hw_params, &pcm_fmt); |
r = snd_pcm_hw_params_get_fmt(hw_params, &pcm_fmt); |
270 |
270 |
if (r < 0) |
if (r < 0) |
271 |
|
FATALA("alsa:unable to get the pcm format for ffmpeg filter wiring\n"); |
|
|
271 |
|
fatal("alsa:unable to get the pcm format for ffmpeg filter wiring\n"); |
272 |
272 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
273 |
273 |
pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info); |
pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info); |
274 |
274 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
275 |
275 |
r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate, |
r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate, |
276 |
276 |
SND_PCM_ST_PLAYBACK); |
SND_PCM_ST_PLAYBACK); |
277 |
277 |
if (r < 0) |
if (r < 0) |
278 |
|
FATALA("alsa:unable to get the pcm rate for ffmpeg filter wiring\n"); |
|
|
278 |
|
fatal("alsa:unable to get the pcm rate for ffmpeg filter wiring\n"); |
279 |
279 |
*ff_rate = (int)pcm_rate; |
*ff_rate = (int)pcm_rate; |
280 |
280 |
r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n); |
r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n); |
281 |
281 |
if (r < 0) |
if (r < 0) |
282 |
|
FATALA("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); |
|
|
282 |
|
fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); |
283 |
283 |
*ff_chans_n = (int)pcm_chans_n; |
*ff_chans_n = (int)pcm_chans_n; |
284 |
284 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
285 |
285 |
*ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n, |
*ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n, |
|
... |
... |
STATIC void pkts_send(void) { loop |
306 |
306 |
else if (r == AVUTIL_AVERROR_EOF) /* the dec is in draining mode */ |
else if (r == AVUTIL_AVERROR_EOF) /* the dec is in draining mode */ |
307 |
307 |
goto unlock_and_return; |
goto unlock_and_return; |
308 |
308 |
else if (r != 0) |
else if (r != 0) |
309 |
|
FATALA("error while sending a packet to the decoder\n"); |
|
|
309 |
|
fatal("error while sending a packet to the decoder\n"); |
310 |
310 |
/* r == 0 */ |
/* r == 0 */ |
311 |
311 |
npv_pipeline_limits_lock(); |
npv_pipeline_limits_lock(); |
312 |
312 |
npv_pipeline_limits_p.pkts.audio_bytes_n -= pr->sz; |
npv_pipeline_limits_p.pkts.audio_bytes_n -= pr->sz; |
File npv/local/code.frag.c changed (mode: 100644) (index 333beb0..4ba09e8) |
... |
... |
STATIC void sigs_init_once(void) |
13 |
13 |
|
|
14 |
14 |
r = sigfillset(&sset); |
r = sigfillset(&sset); |
15 |
15 |
if (r == -1) |
if (r == -1) |
16 |
|
FATAL("unable to get a full signal mask\n"); |
|
|
16 |
|
fatal("unable to get a full signal mask\n"); |
17 |
17 |
|
|
18 |
18 |
/* the "controlling terminal" line asks for a core dump, leave it be */ |
/* the "controlling terminal" line asks for a core dump, leave it be */ |
19 |
19 |
r = sigdelset(&sset, SIGQUIT); |
r = sigdelset(&sset, SIGQUIT); |
20 |
20 |
if (r == -1) |
if (r == -1) |
21 |
|
FATAL("unable to remove SIGQUIT from our signal mask\n"); |
|
|
21 |
|
fatal("unable to remove SIGQUIT from our signal mask\n"); |
22 |
22 |
|
|
23 |
23 |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
24 |
24 |
if (r != 0) |
if (r != 0) |
25 |
|
FATAL("unable to \"block\" \"all\" signals\n"); |
|
|
25 |
|
fatal("unable to \"block\" \"all\" signals\n"); |
26 |
26 |
|
|
27 |
27 |
/* from here, we "steal" signals with signalfd */ |
/* from here, we "steal" signals with signalfd */ |
28 |
28 |
|
|
29 |
29 |
r = sigemptyset(&sset); |
r = sigemptyset(&sset); |
30 |
30 |
if (r == -1) |
if (r == -1) |
31 |
|
FATAL("unable to get an empty signal mask\n"); |
|
|
31 |
|
fatal("unable to get an empty signal mask\n"); |
32 |
32 |
/* we are asked nicely to terminate */ |
/* we are asked nicely to terminate */ |
33 |
33 |
r = sigaddset(&sset, SIGTERM); |
r = sigaddset(&sset, SIGTERM); |
34 |
34 |
if (r == -1) |
if (r == -1) |
35 |
|
FATAL("unable to add SIGTERM to our signal mask\n"); |
|
|
35 |
|
fatal("unable to add SIGTERM to our signal mask\n"); |
36 |
36 |
/* the "controlling terminal" line (^c) asks nicely to terminate */ |
/* the "controlling terminal" line (^c) asks nicely to terminate */ |
37 |
37 |
r = sigaddset(&sset, SIGINT); |
r = sigaddset(&sset, SIGINT); |
38 |
38 |
if (r == -1) |
if (r == -1) |
39 |
|
FATAL("unable to add SIGINT to our signal mask\n"); |
|
|
39 |
|
fatal("unable to add SIGINT to our signal mask\n"); |
40 |
40 |
|
|
41 |
41 |
r = signalfd(-1, &sset, SFD_NONBLOCK); |
r = signalfd(-1, &sset, SFD_NONBLOCK); |
42 |
42 |
if (r == -1) |
if (r == -1) |
43 |
|
FATAL("unable to get a signalfd file descriptor\n"); |
|
|
43 |
|
fatal("unable to get a signalfd file descriptor\n"); |
44 |
44 |
sig_fd_l = r; |
sig_fd_l = r; |
45 |
45 |
} |
} |
46 |
46 |
STATIC void prefill_wait(void) { loop |
STATIC void prefill_wait(void) { loop |
|
... |
... |
STATIC void prefill_wait(void) { loop |
67 |
67 |
if (r == 0) |
if (r == 0) |
68 |
68 |
break; |
break; |
69 |
69 |
if (r != EINTR) |
if (r != EINTR) |
70 |
|
FATAL("prefill wait timer failed:%d\n", r); |
|
|
70 |
|
fatal("prefill wait timer failed:%d\n", r); |
71 |
71 |
/* r == EINTR */ |
/* r == EINTR */ |
72 |
72 |
memcpy(&wanted, &rem, sizeof(wanted)); |
memcpy(&wanted, &rem, sizeof(wanted)); |
73 |
73 |
memset(&rem, 0, sizeof(rem)); |
memset(&rem, 0, sizeof(rem)); |
|
... |
... |
STATIC void predecode_wait(void) |
90 |
90 |
if (r == 0) |
if (r == 0) |
91 |
91 |
break; |
break; |
92 |
92 |
if (r != EINTR) |
if (r != EINTR) |
93 |
|
FATAL("predecoding wait timer failed:%d\n", r); |
|
|
93 |
|
fatal("predecoding wait timer failed:%d\n", r); |
94 |
94 |
/* r == EINTR */ |
/* r == EINTR */ |
95 |
95 |
memcpy(&wanted, &rem, sizeof(wanted)); |
memcpy(&wanted, &rem, sizeof(wanted)); |
96 |
96 |
memset(&rem, 0, sizeof(rem)); |
memset(&rem, 0, sizeof(rem)); |
|
... |
... |
STATIC void evt_init_once(void) |
100 |
100 |
{ |
{ |
101 |
101 |
ep_fd_p = epoll_create1(0); |
ep_fd_p = epoll_create1(0); |
102 |
102 |
if (ep_fd_p == -1) |
if (ep_fd_p == -1) |
103 |
|
FATAL("unable to create the epoll file descriptor\n"); |
|
|
103 |
|
fatal("unable to create the epoll file descriptor\n"); |
104 |
104 |
} |
} |
105 |
105 |
STATIC void evt_add_all_fds(void) |
STATIC void evt_add_all_fds(void) |
106 |
106 |
{ |
{ |
|
... |
... |
STATIC void evt_add_all_fds(void) |
113 |
113 |
evt.data.fd = sig_fd_l; |
evt.data.fd = sig_fd_l; |
114 |
114 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, sig_fd_l, &evt); |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, sig_fd_l, &evt); |
115 |
115 |
if (r == -1) |
if (r == -1) |
116 |
|
FATAL("unable to add the signalfd file descriptior to the epoll file descriptor\n"); |
|
|
116 |
|
fatal("unable to add the signalfd file descriptior to the epoll file descriptor\n"); |
117 |
117 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
118 |
118 |
/* the video timer */ |
/* the video timer */ |
119 |
119 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
120 |
120 |
evt.data.fd = npv_video_timer_fd_p; |
evt.data.fd = npv_video_timer_fd_p; |
121 |
121 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_video_timer_fd_p, &evt); |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_video_timer_fd_p, &evt); |
122 |
122 |
if (r == -1) |
if (r == -1) |
123 |
|
FATAL("unable to add the video timer file descriptor\n"); |
|
|
123 |
|
fatal("unable to add the video timer file descriptor\n"); |
124 |
124 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
125 |
125 |
/* the x11 xcb file descriptor */ |
/* the x11 xcb file descriptor */ |
126 |
126 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
127 |
127 |
evt.data.fd = npv_xcb_p.fd; |
evt.data.fd = npv_xcb_p.fd; |
128 |
128 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_xcb_p.fd, &evt); |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_xcb_p.fd, &evt); |
129 |
129 |
if (r == -1) |
if (r == -1) |
130 |
|
FATAL("unable to add the x11 xcb file descriptor\n"); |
|
|
130 |
|
fatal("unable to add the x11 xcb file descriptor\n"); |
131 |
131 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
132 |
132 |
/* alsa pcm poll file descriptors */ |
/* alsa pcm poll file descriptors */ |
133 |
133 |
i = 0; |
i = 0; |
|
... |
... |
STATIC void evt_add_all_fds(void) |
139 |
139 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
140 |
140 |
npv_audio_pcm_pollfds_p[i].fd, &evt); |
npv_audio_pcm_pollfds_p[i].fd, &evt); |
141 |
141 |
if (r == -1) |
if (r == -1) |
142 |
|
FATAL("unable to add alsa poll file descriptor index %d to epoll file descriptor\n", i); |
|
|
142 |
|
fatal("unable to add alsa poll file descriptor index %d to epoll file descriptor\n", i); |
143 |
143 |
++i; |
++i; |
144 |
144 |
} |
} |
145 |
145 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
|
... |
... |
STATIC void evt_add_all_fds(void) |
149 |
149 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_audio_draining_timer_fd_p, |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_audio_draining_timer_fd_p, |
150 |
150 |
&evt); |
&evt); |
151 |
151 |
if (r == -1) |
if (r == -1) |
152 |
|
FATAL("unable to add the draining timer file descriptor\n"); |
|
|
152 |
|
fatal("unable to add the draining timer file descriptor\n"); |
153 |
153 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
154 |
154 |
/* the xcb screensaver heartbeat timer */ |
/* the xcb screensaver heartbeat timer */ |
155 |
155 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
|
... |
... |
STATIC void evt_add_all_fds(void) |
157 |
157 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
158 |
158 |
npv_xcb_p.screensaver_heartbeat_timer_fd, &evt); |
npv_xcb_p.screensaver_heartbeat_timer_fd, &evt); |
159 |
159 |
if (r == -1) |
if (r == -1) |
160 |
|
FATAL("unable to add the xcb screensaver heartbeat timer file descriptor\n"); |
|
|
160 |
|
fatal("unable to add the xcb screensaver heartbeat timer file descriptor\n"); |
161 |
161 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
162 |
162 |
/* the xcb mouse visibility timer */ |
/* the xcb mouse visibility timer */ |
163 |
163 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
|
... |
... |
STATIC void evt_add_all_fds(void) |
165 |
165 |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, |
166 |
166 |
npv_xcb_p.mouse_visibility_timer_fd, &evt); |
npv_xcb_p.mouse_visibility_timer_fd, &evt); |
167 |
167 |
if (r == -1) |
if (r == -1) |
168 |
|
FATAL("unable to add the xcb screensaver heartbeat timer file descriptor\n"); |
|
|
168 |
|
fatal("unable to add the xcb screensaver heartbeat timer file descriptor\n"); |
169 |
169 |
} |
} |
170 |
170 |
STATIC void evt_sigs(void) |
STATIC void evt_sigs(void) |
171 |
171 |
{ |
{ |
|
... |
... |
STATIC void evt_sigs(void) |
175 |
175 |
/* no short reads */ |
/* no short reads */ |
176 |
176 |
r = read(sig_fd_l, &siginfo, sizeof(siginfo)); |
r = read(sig_fd_l, &siginfo, sizeof(siginfo)); |
177 |
177 |
if (r != sizeof(siginfo)) |
if (r != sizeof(siginfo)) |
178 |
|
FATAL("unable to read signal information\n"); |
|
|
178 |
|
fatal("unable to read signal information\n"); |
179 |
179 |
|
|
180 |
180 |
switch (siginfo.ssi_signo) { |
switch (siginfo.ssi_signo) { |
181 |
181 |
case SIGTERM: |
case SIGTERM: |
182 |
|
EXIT("received SIGTERM\n"); |
|
|
182 |
|
exit_ok("received SIGTERM\n"); |
183 |
183 |
case SIGINT: |
case SIGINT: |
184 |
|
EXIT("received SIGINT\n"); |
|
|
184 |
|
exit_ok("received SIGINT\n"); |
185 |
185 |
default: |
default: |
186 |
|
WARNING("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo); |
|
|
186 |
|
warning("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo); |
187 |
187 |
} |
} |
188 |
188 |
} |
} |
189 |
189 |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
|
... |
... |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
198 |
198 |
*have_evt_sigs = true; |
*have_evt_sigs = true; |
199 |
199 |
return; |
return; |
200 |
200 |
} |
} |
201 |
|
FATAL("event loop wait:signal:unexpected event\n"); |
|
|
201 |
|
fatal("event loop wait:signal:unexpected event\n"); |
202 |
202 |
} |
} |
203 |
203 |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
204 |
204 |
/* only update alsa fds */ |
/* only update alsa fds */ |
|
... |
... |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
225 |
225 |
*have_evt_video = true; |
*have_evt_video = true; |
226 |
226 |
return; |
return; |
227 |
227 |
} |
} |
228 |
|
FATAL("event loop wait:video:unexpected event\n"); |
|
|
228 |
|
fatal("event loop wait:video:unexpected event\n"); |
229 |
229 |
} |
} |
230 |
230 |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
231 |
231 |
if (evt->data.fd == npv_audio_draining_timer_fd_p) { |
if (evt->data.fd == npv_audio_draining_timer_fd_p) { |
|
... |
... |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
233 |
233 |
*have_evt_pcm_draining = true; |
*have_evt_pcm_draining = true; |
234 |
234 |
return; |
return; |
235 |
235 |
} |
} |
236 |
|
FATAL("event loop wait:audio draining timer:unexpected event\n"); |
|
|
236 |
|
fatal("event loop wait:audio draining timer:unexpected event\n"); |
237 |
237 |
} |
} |
238 |
238 |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
239 |
239 |
if (evt->data.fd == npv_xcb_p.screensaver_heartbeat_timer_fd) { |
if (evt->data.fd == npv_xcb_p.screensaver_heartbeat_timer_fd) { |
|
... |
... |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
241 |
241 |
*have_evt_xcb_screensaver_heartbeat = true; |
*have_evt_xcb_screensaver_heartbeat = true; |
242 |
242 |
return; |
return; |
243 |
243 |
} |
} |
244 |
|
FATAL("event loop wait:xcb screensaver heartbeat timer:unexpected event\n"); |
|
|
244 |
|
fatal("event loop wait:xcb screensaver heartbeat timer:unexpected event\n"); |
245 |
245 |
} |
} |
246 |
246 |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
247 |
247 |
if (evt->data.fd == npv_xcb_p.mouse_visibility_timer_fd) { |
if (evt->data.fd == npv_xcb_p.mouse_visibility_timer_fd) { |
|
... |
... |
STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs, |
249 |
249 |
*have_evt_xcb_mouse_visibility = true; |
*have_evt_xcb_mouse_visibility = true; |
250 |
250 |
return; |
return; |
251 |
251 |
} |
} |
252 |
|
FATAL("event loop wait:xcb mouse visibility timer:unexpected event\n"); |
|
|
252 |
|
fatal("event loop wait:xcb mouse visibility timer:unexpected event\n"); |
253 |
253 |
} |
} |
254 |
254 |
} |
} |
255 |
255 |
/* |
/* |
|
... |
... |
STATIC void evts_loop(void) |
278 |
278 |
fds_n = epoll_wait(ep_fd_p, evts, EPOLL_EVTS_N, -1); |
fds_n = epoll_wait(ep_fd_p, evts, EPOLL_EVTS_N, -1); |
279 |
279 |
if (fds_n == -1) { |
if (fds_n == -1) { |
280 |
280 |
if (errno == EINTR) { |
if (errno == EINTR) { |
281 |
|
WARNING("event loop wait:was interrupted by a signal\n"); |
|
|
281 |
|
warning("event loop wait:was interrupted by a signal\n"); |
282 |
282 |
return; |
return; |
283 |
283 |
} |
} |
284 |
|
FATAL("event loop wait:an error occured\n"); |
|
|
284 |
|
fatal("event loop wait:an error occured\n"); |
285 |
285 |
} |
} |
286 |
286 |
|
|
287 |
287 |
have_evt_sigs = false; |
have_evt_sigs = false; |
|
... |
... |
STATIC void evts_loop(void) |
327 |
327 |
npv_audio_pcm_pollfds_p, npv_audio_pcm_pollfds_n_p, |
npv_audio_pcm_pollfds_p, npv_audio_pcm_pollfds_n_p, |
328 |
328 |
&pcm_evts); |
&pcm_evts); |
329 |
329 |
if (r != 0) |
if (r != 0) |
330 |
|
FATAL("alsa:error processing the poll file descriptors\n"); |
|
|
330 |
|
fatal("alsa:error processing the poll file descriptors\n"); |
331 |
331 |
if ((pcm_evts & ~POLLOUT) != 0) |
if ((pcm_evts & ~POLLOUT) != 0) |
332 |
|
FATAL("alsa:unexpected events\n"); |
|
|
332 |
|
fatal("alsa:unexpected events\n"); |
333 |
333 |
if ((pcm_evts & POLLOUT) != 0) |
if ((pcm_evts & POLLOUT) != 0) |
334 |
334 |
npv_audio_evt_pcm_write(); |
npv_audio_evt_pcm_write(); |
335 |
335 |
} |
} |
|
... |
... |
STATIC void ff_log_stdout(void *a, int b, const char *fmt, va_list ap) |
350 |
350 |
} |
} |
351 |
351 |
STATIC void usage(void) |
STATIC void usage(void) |
352 |
352 |
{ |
{ |
353 |
|
POUT("\ |
|
|
353 |
|
pout("\ |
354 |
354 |
npv [-f send a fullscreen message to the window manager at start] [-p alsa pcm]\n\ |
npv [-f send a fullscreen message to the window manager at start] [-p alsa pcm]\n\ |
355 |
355 |
[-v volume(0..100)] [-h window height in pixels] [-w window width in pixels]\n\ |
[-v volume(0..100)] [-h window height in pixels] [-w window width in pixels]\n\ |
356 |
356 |
[-b packet buffer prefill wait(0..100)] [-help] url\n"); |
[-b packet buffer prefill wait(0..100)] [-help] url\n"); |
|
... |
... |
STATIC void opts_parse(int argc, u8 **args, u8 **url, bool* start_fullscreen, |
371 |
371 |
++i; |
++i; |
372 |
372 |
} else if (strcmp("-p", args[i]) == 0) { |
} else if (strcmp("-p", args[i]) == 0) { |
373 |
373 |
*pcm_str = args[i + 1]; |
*pcm_str = args[i + 1]; |
374 |
|
POUT("-p:alsa pcm \"%s\"\n", *pcm_str); |
|
|
374 |
|
pout("-p:alsa pcm \"%s\"\n", *pcm_str); |
375 |
375 |
i += 2; |
i += 2; |
376 |
376 |
} else if (strcmp("-v", args[i]) == 0) { |
} else if (strcmp("-v", args[i]) == 0) { |
377 |
377 |
unsigned long vol_ul; |
unsigned long vol_ul; |
378 |
378 |
|
|
379 |
379 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
380 |
|
FATAL("-v:initial volume is missing\n"); |
|
|
380 |
|
fatal("-v:initial volume is missing\n"); |
381 |
381 |
vol_ul = strtoul(args[i + 1], 0, 10); |
vol_ul = strtoul(args[i + 1], 0, 10); |
382 |
382 |
if (vol_ul < 0 || 100 < vol_ul) |
if (vol_ul < 0 || 100 < vol_ul) |
383 |
|
FATAL("-v:invalid volume value %lu (0..100)\n", vol_ul); |
|
|
383 |
|
fatal("-v:invalid volume value %lu (0..100)\n", vol_ul); |
384 |
384 |
*vol = (double)vol_ul / 100.; |
*vol = (double)vol_ul / 100.; |
385 |
|
POUT("-v:using initial volume %f\n", *vol); |
|
|
385 |
|
pout("-v:using initial volume %f\n", *vol); |
386 |
386 |
i += 2; |
i += 2; |
387 |
387 |
} else if (strcmp("-h", args[i]) == 0) { |
} else if (strcmp("-h", args[i]) == 0) { |
388 |
388 |
unsigned long h_ul; |
unsigned long h_ul; |
389 |
389 |
|
|
390 |
390 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
391 |
|
FATAL("-h:initial window pixel height is missing\n"); |
|
|
391 |
|
fatal("-h:initial window pixel height is missing\n"); |
392 |
392 |
h_ul = strtoul(args[i + 1], 0, 10); |
h_ul = strtoul(args[i + 1], 0, 10); |
393 |
393 |
if (h_ul == 0 || h_ul > U16_MAX) |
if (h_ul == 0 || h_ul > U16_MAX) |
394 |
|
FATAL("-h:invalid window pixel height %lu (1..%lu)\n", h_ul, U16_MAX); |
|
|
394 |
|
fatal("-h:invalid window pixel height %lu (1..%lu)\n", h_ul, U16_MAX); |
395 |
395 |
*h = (u16)h_ul; |
*h = (u16)h_ul; |
396 |
|
POUT("-h:using initial window height %lu pixels\n", h_ul); |
|
|
396 |
|
pout("-h:using initial window height %lu pixels\n", h_ul); |
397 |
397 |
i += 2; |
i += 2; |
398 |
398 |
} else if (strcmp("-w", args[i]) == 0) { |
} else if (strcmp("-w", args[i]) == 0) { |
399 |
399 |
unsigned long w_ul; |
unsigned long w_ul; |
400 |
400 |
|
|
401 |
401 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
402 |
|
FATAL("-h:initial window pixel width is missing\n"); |
|
|
402 |
|
fatal("-h:initial window pixel width is missing\n"); |
403 |
403 |
w_ul = strtoul(args[i + 1], 0, 10); |
w_ul = strtoul(args[i + 1], 0, 10); |
404 |
404 |
if (w_ul == 0 || w_ul > U16_MAX) |
if (w_ul == 0 || w_ul > U16_MAX) |
405 |
|
FATAL("-w:invalid window pixel width %lu (1..%lu)\n", w_ul, U16_MAX); |
|
|
405 |
|
fatal("-w:invalid window pixel width %lu (1..%lu)\n", w_ul, U16_MAX); |
406 |
406 |
*w = (u16)w_ul; |
*w = (u16)w_ul; |
407 |
|
POUT("-w:using initial window width %lu pixels\n", w_ul); |
|
|
407 |
|
pout("-w:using initial window width %lu pixels\n", w_ul); |
408 |
408 |
i += 2; |
i += 2; |
409 |
409 |
} else if (strcmp("-b", args[i]) == 0) { |
} else if (strcmp("-b", args[i]) == 0) { |
410 |
410 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
411 |
|
FATAL("-b:percent value for prefill of buffer of packet queues is missing\n"); |
|
|
411 |
|
fatal("-b:percent value for prefill of buffer of packet queues is missing\n"); |
412 |
412 |
*pkts_prefill_percent = (u8)strtoul(args[i + 1], 0, 10); |
*pkts_prefill_percent = (u8)strtoul(args[i + 1], 0, 10); |
413 |
|
POUT("-v:using a %u prefilled buffer of packet queues\n", *pkts_prefill_percent); |
|
|
413 |
|
pout("-v:using a %u prefilled buffer of packet queues\n", *pkts_prefill_percent); |
414 |
414 |
i += 2; |
i += 2; |
415 |
415 |
} else if (strcmp("-help", args[i]) == 0) { |
} else if (strcmp("-help", args[i]) == 0) { |
416 |
416 |
usage(); |
usage(); |
|
... |
... |
STATIC void opts_parse(int argc, u8 **args, u8 **url, bool* start_fullscreen, |
421 |
421 |
} |
} |
422 |
422 |
} |
} |
423 |
423 |
if (url_idx == -1) |
if (url_idx == -1) |
424 |
|
FATAL("missing url\n"); |
|
|
424 |
|
fatal("missing url\n"); |
425 |
425 |
*url = args[url_idx]; |
*url = args[url_idx]; |
426 |
|
POUT("url-->####%s####\n", *url); |
|
|
426 |
|
pout("url-->####%s####\n", *url); |
427 |
427 |
} |
} |
428 |
428 |
#define WIDTH_NOT_DEFINED 0 |
#define WIDTH_NOT_DEFINED 0 |
429 |
429 |
#define HEIGHT_NOT_DEFINED 0 |
#define HEIGHT_NOT_DEFINED 0 |
|
... |
... |
STATIC u8 *ts_to_str(int64_t ts, avutil_rational_t time_base, |
560 |
560 |
} |
} |
561 |
561 |
return str; |
return str; |
562 |
562 |
} |
} |
563 |
|
#define RED if (stdout_is_tty) POUT("\x1b[38;2;255;0;0m") |
|
564 |
|
#define GREEN if (stdout_is_tty) POUT("\x1b[38;2;0;255;0m") |
|
565 |
|
#define BLUE if (stdout_is_tty) POUT("\x1b[38;2;0;0;255m") |
|
566 |
|
#define PURPLE if (stdout_is_tty) POUT("\x1b[38;2;255;0;255m") |
|
567 |
|
#define RESTORE if (stdout_is_tty) POUT("\x1b[39;49m"); |
|
|
563 |
|
#define RED if (stdout_is_tty) pout("\x1b[38;2;255;0;0m") |
|
564 |
|
#define GREEN if (stdout_is_tty) pout("\x1b[38;2;0;255;0m") |
|
565 |
|
#define BLUE if (stdout_is_tty) pout("\x1b[38;2;0;0;255m") |
|
566 |
|
#define PURPLE if (stdout_is_tty) pout("\x1b[38;2;255;0;255m") |
|
567 |
|
#define RESTORE if (stdout_is_tty) pout("\x1b[39;49m"); |
568 |
568 |
#define TS_FROM_CLK_OK 0 |
#define TS_FROM_CLK_OK 0 |
569 |
569 |
/* we don't lock anything as an act of faith */ |
/* we don't lock anything as an act of faith */ |
570 |
570 |
STATIC void npv_cmd_info(void) |
STATIC void npv_cmd_info(void) |
|
... |
... |
STATIC void npv_cmd_info(void) |
584 |
584 |
stdout_is_tty = true; |
stdout_is_tty = true; |
585 |
585 |
|
|
586 |
586 |
RESTORE; |
RESTORE; |
587 |
|
GREEN;POUT("================================================================================\n");RESTORE; |
|
588 |
|
PURPLE;POUT("%s\n", npv_fmt_ctx_p->url);RESTORE; |
|
|
587 |
|
GREEN;pout("================================================================================\n");RESTORE; |
|
588 |
|
PURPLE;pout("%s\n", npv_fmt_ctx_p->url);RESTORE; |
589 |
589 |
|
|
590 |
590 |
r8 = npv_clk_get_audio_st_ts(&audio_now); |
r8 = npv_clk_get_audio_st_ts(&audio_now); |
591 |
591 |
if (r8 != TS_FROM_CLK_OK) { |
if (r8 != TS_FROM_CLK_OK) { |
592 |
|
POUT("information unavailable at the time of the command due to an unavailable audio clock\n"); |
|
|
592 |
|
pout("information unavailable at the time of the command due to an unavailable audio clock\n"); |
593 |
593 |
return; |
return; |
594 |
594 |
} |
} |
595 |
595 |
ts_str = ts_to_str(audio_now, npv_audio_st_p.tb, &remaining); |
ts_str = ts_to_str(audio_now, npv_audio_st_p.tb, &remaining); |
596 |
|
RED;POUT("%s", ts_str);RESTORE; |
|
|
596 |
|
RED;pout("%s", ts_str);RESTORE; |
597 |
597 |
if (remaining != 0) |
if (remaining != 0) |
598 |
|
POUT(" remaining %"PRId64" time base units", remaining); |
|
|
598 |
|
pout(" remaining %"PRId64" time base units", remaining); |
599 |
599 |
else |
else |
600 |
|
POUT("\n"); |
|
601 |
|
POUT("\t%"PRId64" stream time base units (%d/%d seconds)\n", |
|
|
600 |
|
pout("\n"); |
|
601 |
|
pout("\t%"PRId64" stream time base units (%d/%d seconds)\n", |
602 |
602 |
audio_now, npv_audio_st_p.tb.num, npv_audio_st_p.tb.den); |
audio_now, npv_audio_st_p.tb.num, npv_audio_st_p.tb.den); |
603 |
|
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
|
604 |
|
POUT("format:"); |
|
|
603 |
|
BLUE;pout("--------------------------------------------------------------------------------\n");RESTORE; |
|
604 |
|
pout("format:"); |
605 |
605 |
if (npv_fmt_ctx_p->duration == AV_NOPTS_VALUE) { |
if (npv_fmt_ctx_p->duration == AV_NOPTS_VALUE) { |
606 |
|
POUT("duration is not provided\n"); |
|
|
606 |
|
pout("duration is not provided\n"); |
607 |
607 |
} else { |
} else { |
608 |
608 |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, |
609 |
609 |
npv_fmt_ctx_p->duration); |
npv_fmt_ctx_p->duration); |
610 |
610 |
ts_str = ts_to_str(npv_fmt_ctx_p->duration, AV_TIME_BASE_Q, |
ts_str = ts_to_str(npv_fmt_ctx_p->duration, AV_TIME_BASE_Q, |
611 |
611 |
&remaining); |
&remaining); |
612 |
|
POUT("duration=");RED;POUT("%s", ts_str);RESTORE; |
|
|
612 |
|
pout("duration=");RED;pout("%s", ts_str);RESTORE; |
613 |
613 |
if (remaining != 0) |
if (remaining != 0) |
614 |
|
POUT(" remaining %"PRId64" av_time_base units\n", |
|
|
614 |
|
pout(" remaining %"PRId64" av_time_base units\n", |
615 |
615 |
remaining); |
remaining); |
616 |
616 |
else |
else |
617 |
|
POUT("\n"); |
|
618 |
|
POUT("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n", |
|
|
617 |
|
pout("\n"); |
|
618 |
|
pout("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n", |
619 |
619 |
duration_str, AV_TIME_BASE, duration_estimate_to_str( |
duration_str, AV_TIME_BASE, duration_estimate_to_str( |
620 |
620 |
npv_fmt_ctx_p->duration_estimation_method)); |
npv_fmt_ctx_p->duration_estimation_method)); |
621 |
621 |
} |
} |
622 |
|
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
|
623 |
|
POUT("stream:audio_id=%d", npv_audio_st_p.id); |
|
|
622 |
|
BLUE;pout("--------------------------------------------------------------------------------\n");RESTORE; |
|
623 |
|
pout("stream:audio_id=%d", npv_audio_st_p.id); |
624 |
624 |
if (npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration == AV_NOPTS_VALUE) { |
if (npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration == AV_NOPTS_VALUE) { |
625 |
|
POUT(";duration is not provided\n"); |
|
|
625 |
|
pout(";duration is not provided\n"); |
626 |
626 |
} else { |
} else { |
627 |
627 |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, |
628 |
628 |
npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration); |
npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration); |
629 |
629 |
ts_str = ts_to_str( |
ts_str = ts_to_str( |
630 |
630 |
npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration, |
npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration, |
631 |
631 |
npv_audio_st_p.tb, &remaining); |
npv_audio_st_p.tb, &remaining); |
632 |
|
POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE; |
|
|
632 |
|
pout(";duration=");RED;pout("%s\n", ts_str);RESTORE; |
633 |
633 |
if (remaining != 0) |
if (remaining != 0) |
634 |
|
POUT(" remaining %"PRId64" stream time base units\n", |
|
|
634 |
|
pout(" remaining %"PRId64" stream time base units\n", |
635 |
635 |
remaining); |
remaining); |
636 |
636 |
else |
else |
637 |
|
POUT("\n"); |
|
638 |
|
POUT("\t%s stream time base units (%d/%d seconds)\n", |
|
|
637 |
|
pout("\n"); |
|
638 |
|
pout("\t%s stream time base units (%d/%d seconds)\n", |
639 |
639 |
duration_str, npv_audio_st_p.tb.num, |
duration_str, npv_audio_st_p.tb.num, |
640 |
640 |
npv_audio_st_p.tb.den); |
npv_audio_st_p.tb.den); |
641 |
641 |
} |
} |
642 |
|
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
|
643 |
|
GREEN;POUT("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE; |
|
|
642 |
|
BLUE;pout("--------------------------------------------------------------------------------\n");RESTORE; |
|
643 |
|
GREEN;pout("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE; |
644 |
644 |
} |
} |
645 |
645 |
#undef TS_FROM_CLK_OK |
#undef TS_FROM_CLK_OK |
646 |
646 |
#undef RED |
#undef RED |
|
... |
... |
STATIC void npv_cmd_info(void) |
651 |
651 |
/*==== while waiting for the osd -- end ======================================*/ |
/*==== while waiting for the osd -- end ======================================*/ |
652 |
652 |
STATIC void npv_cmd_quit(void) |
STATIC void npv_cmd_quit(void) |
653 |
653 |
{ |
{ |
654 |
|
EXIT("quit command received\n"); |
|
|
654 |
|
exit_ok("quit command received\n"); |
655 |
655 |
} |
} |
656 |
656 |
STATIC void seek_lock(void) |
STATIC void seek_lock(void) |
657 |
657 |
{ |
{ |
|
... |
... |
STATIC void seek_x(s64 delta) |
694 |
694 |
s64 video_now; |
s64 video_now; |
695 |
695 |
|
|
696 |
696 |
if (npv_audio_draining_p) { |
if (npv_audio_draining_p) { |
697 |
|
WARNING("seek:audio is draining, seeking disable\n"); |
|
|
697 |
|
warning("seek:audio is draining, seeking disable\n"); |
698 |
698 |
return; |
return; |
699 |
699 |
} |
} |
700 |
700 |
if (paused_p) /* we don't seek in pause */ |
if (paused_p) /* we don't seek in pause */ |
|
... |
... |
STATIC void seek_x(s64 delta) |
706 |
706 |
|
|
707 |
707 |
r = npv_clk_get_audio_st_ts(&audio_now); |
r = npv_clk_get_audio_st_ts(&audio_now); |
708 |
708 |
if (r != TS_FROM_CLK_OK) { |
if (r != TS_FROM_CLK_OK) { |
709 |
|
WARNING("seek:audio:clock timestamp unavailable, ignoring command\n"); |
|
|
709 |
|
warning("seek:audio:clock timestamp unavailable, ignoring command\n"); |
710 |
710 |
seek_unlock(); |
seek_unlock(); |
711 |
711 |
return; |
return; |
712 |
712 |
} |
} |
713 |
713 |
r = npv_clk_get_video_st_ts(&video_now); |
r = npv_clk_get_video_st_ts(&video_now); |
714 |
714 |
if (r != TS_FROM_CLK_OK) { |
if (r != TS_FROM_CLK_OK) { |
715 |
|
WARNING("seek:video:clock timestamp unavailable, ignoring command\n"); |
|
|
715 |
|
warning("seek:video:clock timestamp unavailable, ignoring command\n"); |
716 |
716 |
seek_unlock(); |
seek_unlock(); |
717 |
717 |
return; |
return; |
718 |
718 |
} |
} |
|
... |
... |
STATIC void seek_x(s64 delta) |
728 |
728 |
if (npv_audio_st_p.start_time != AV_NOPTS_VALUE) |
if (npv_audio_st_p.start_time != AV_NOPTS_VALUE) |
729 |
729 |
if (new_audio_ts < npv_audio_st_p.start_time) |
if (new_audio_ts < npv_audio_st_p.start_time) |
730 |
730 |
new_audio_ts = npv_audio_st_p.start_time; |
new_audio_ts = npv_audio_st_p.start_time; |
731 |
|
POUT("trying to seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
|
|
731 |
|
pout("trying to seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
732 |
732 |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, new_audio_ts, |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, new_audio_ts, |
733 |
733 |
0); |
0); |
734 |
734 |
if (a < 0) { |
if (a < 0) { |
735 |
|
POUT("unable to seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
|
|
735 |
|
pout("unable to seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
736 |
736 |
goto try_restore_audio; |
goto try_restore_audio; |
737 |
737 |
} |
} |
738 |
|
POUT("audio seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
|
|
738 |
|
pout("audio seek to %"PRId64" audio stream time base units\n", new_audio_ts); |
739 |
739 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
740 |
740 |
new_video_ts = video_now + delta * npv_video_st_p.tb.den |
new_video_ts = video_now + delta * npv_video_st_p.tb.den |
741 |
741 |
/ npv_video_st_p.tb.num; |
/ npv_video_st_p.tb.num; |
|
... |
... |
STATIC void seek_x(s64 delta) |
743 |
743 |
if (npv_video_st_p.start_time != AV_NOPTS_VALUE) |
if (npv_video_st_p.start_time != AV_NOPTS_VALUE) |
744 |
744 |
if (new_video_ts < npv_video_st_p.start_time) |
if (new_video_ts < npv_video_st_p.start_time) |
745 |
745 |
new_video_ts = npv_video_st_p.start_time; |
new_video_ts = npv_video_st_p.start_time; |
746 |
|
POUT("trying to seek to %"PRId64" video stream time base units\n", new_video_ts); |
|
|
746 |
|
pout("trying to seek to %"PRId64" video stream time base units\n", new_video_ts); |
747 |
747 |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, new_video_ts, |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, new_video_ts, |
748 |
748 |
0); |
0); |
749 |
749 |
if (a < 0) { |
if (a < 0) { |
750 |
|
POUT("unable to seek to %"PRId64" video stream time base units but audio was seeked)\n", new_video_ts); |
|
|
750 |
|
pout("unable to seek to %"PRId64" video stream time base units but audio was seeked)\n", new_video_ts); |
751 |
751 |
goto try_restore_video; |
goto try_restore_video; |
752 |
752 |
} |
} |
753 |
|
POUT("video seek to %"PRId64" video stream time base units\n", new_video_ts); |
|
|
753 |
|
pout("video seek to %"PRId64" video stream time base units\n", new_video_ts); |
754 |
754 |
flush: |
flush: |
755 |
755 |
npv_video_dec_flush(); |
npv_video_dec_flush(); |
756 |
756 |
npv_audio_dec_flush(); |
npv_audio_dec_flush(); |
|
... |
... |
flush: |
761 |
761 |
npv_pipeline_prefill_reset(npv_pipeline_limits_p.pkts.prefill.percent); |
npv_pipeline_prefill_reset(npv_pipeline_limits_p.pkts.prefill.percent); |
762 |
762 |
seek_unlock(); |
seek_unlock(); |
763 |
763 |
|
|
764 |
|
POUT("prefilling audio and video buffers..."); |
|
|
764 |
|
pout("prefilling audio and video buffers..."); |
765 |
765 |
prefill_wait(); /* use the lock on the pipeline limits */ |
prefill_wait(); /* use the lock on the pipeline limits */ |
766 |
|
POUT("done\n"); |
|
767 |
|
POUT("predecoding audio and video..."); |
|
|
766 |
|
pout("done\n"); |
|
767 |
|
pout("predecoding audio and video..."); |
768 |
768 |
predecode_wait(); /* use the lock on the pipeline limits */ |
predecode_wait(); /* use the lock on the pipeline limits */ |
769 |
|
POUT("done\n"); |
|
|
769 |
|
pout("done\n"); |
770 |
770 |
(void)snd_pcm_prepare(npv_audio_pcm_p); |
(void)snd_pcm_prepare(npv_audio_pcm_p); |
771 |
771 |
return; |
return; |
772 |
772 |
|
|
773 |
773 |
try_restore_video: |
try_restore_video: |
774 |
774 |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, video_now, 0); |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, video_now, 0); |
775 |
775 |
if (a < 0) /* we don't send an application error */ |
if (a < 0) /* we don't send an application error */ |
776 |
|
EXIT("unable to restore video to %"PRId64" video stream time base units\n", video_now); |
|
|
776 |
|
exit_ok("unable to restore video to %"PRId64" video stream time base units\n", video_now); |
777 |
777 |
try_restore_audio: |
try_restore_audio: |
778 |
778 |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, audio_now, 0); |
a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, audio_now, 0); |
779 |
779 |
if (a < 0) /* we don't send an application error */ |
if (a < 0) /* we don't send an application error */ |
780 |
|
EXIT("unable to restore audio to %"PRId64" audio stream time base units\n", audio_now); |
|
|
780 |
|
exit_ok("unable to restore audio to %"PRId64" audio stream time base units\n", audio_now); |
781 |
781 |
goto flush; |
goto flush; |
782 |
782 |
} |
} |
783 |
783 |
#undef TS_FROM_CLK_OK |
#undef TS_FROM_CLK_OK |
784 |
784 |
STATIC void npv_cmd_rewind(void) |
STATIC void npv_cmd_rewind(void) |
785 |
785 |
{ |
{ |
786 |
|
POUT("COMMAND:rewind\n"); |
|
|
786 |
|
pout("COMMAND:rewind\n"); |
787 |
787 |
seek_x(-SEEK_DELTA); |
seek_x(-SEEK_DELTA); |
788 |
788 |
} |
} |
789 |
789 |
|
|
790 |
790 |
STATIC void npv_cmd_rewind_big(void) |
STATIC void npv_cmd_rewind_big(void) |
791 |
791 |
{ |
{ |
792 |
|
POUT("COMMAND:rewind big\n"); |
|
|
792 |
|
pout("COMMAND:rewind big\n"); |
793 |
793 |
seek_x(-SEEK_DELTA_BIG); |
seek_x(-SEEK_DELTA_BIG); |
794 |
794 |
} |
} |
795 |
795 |
|
|
796 |
796 |
STATIC void npv_cmd_fastforward(void) |
STATIC void npv_cmd_fastforward(void) |
797 |
797 |
{ |
{ |
798 |
|
POUT("COMMAND:fastforward\n"); |
|
|
798 |
|
pout("COMMAND:fastforward\n"); |
799 |
799 |
seek_x(SEEK_DELTA); |
seek_x(SEEK_DELTA); |
800 |
800 |
} |
} |
801 |
801 |
|
|
802 |
802 |
STATIC void npv_cmd_fastforward_big(void) |
STATIC void npv_cmd_fastforward_big(void) |
803 |
803 |
{ |
{ |
804 |
|
POUT("COMMAND:fastforward big\n"); |
|
|
804 |
|
pout("COMMAND:fastforward big\n"); |
805 |
805 |
seek_x(SEEK_DELTA_BIG); |
seek_x(SEEK_DELTA_BIG); |
806 |
806 |
} |
} |
807 |
807 |
|
|
808 |
808 |
STATIC void npv_cmd_pause(void) |
STATIC void npv_cmd_pause(void) |
809 |
809 |
{ |
{ |
810 |
810 |
if (npv_audio_draining_p) { |
if (npv_audio_draining_p) { |
811 |
|
WARNING("pause:audio is draining, toggling pause is disable\n"); |
|
|
811 |
|
warning("pause:audio is draining, toggling pause is disable\n"); |
812 |
812 |
return; |
return; |
813 |
813 |
} |
} |
814 |
814 |
if (paused_p) { |
if (paused_p) { |
815 |
815 |
int r; |
int r; |
816 |
816 |
|
|
817 |
|
POUT("COMMAND:unpause\n"); |
|
|
817 |
|
pout("COMMAND:unpause\n"); |
818 |
818 |
paused_p = false; |
paused_p = false; |
819 |
819 |
npv_fmt_ctx_lock(); |
npv_fmt_ctx_lock(); |
820 |
820 |
avformat_read_play(npv_fmt_ctx_p); |
avformat_read_play(npv_fmt_ctx_p); |
|
... |
... |
STATIC void npv_cmd_pause(void) |
824 |
824 |
} else { |
} else { |
825 |
825 |
int r; |
int r; |
826 |
826 |
|
|
827 |
|
POUT("COMMAND:pause\n"); |
|
|
827 |
|
pout("COMMAND:pause\n"); |
828 |
828 |
paused_p = true; |
paused_p = true; |
829 |
829 |
npv_fmt_ctx_lock(); |
npv_fmt_ctx_lock(); |
830 |
830 |
avformat_read_pause(npv_fmt_ctx_p); |
avformat_read_pause(npv_fmt_ctx_p); |
|
... |
... |
int main(int argc, u8 **args) |
883 |
883 |
avutil_log_set_callback(avutil_log_default_callback); |
avutil_log_set_callback(avutil_log_default_callback); |
884 |
884 |
|
|
885 |
885 |
npv_pipeline_read_thd_start(); |
npv_pipeline_read_thd_start(); |
886 |
|
POUT("prefilling audio and video buffers..."); |
|
|
886 |
|
pout("prefilling audio and video buffers..."); |
887 |
887 |
prefill_wait(); |
prefill_wait(); |
888 |
|
POUT("done\n"); |
|
|
888 |
|
pout("done\n"); |
889 |
889 |
npv_pipeline_audio_thd_start(); |
npv_pipeline_audio_thd_start(); |
890 |
890 |
npv_pipeline_video_thd_start(); |
npv_pipeline_video_thd_start(); |
891 |
|
POUT("predecoding audio and video..."); |
|
|
891 |
|
pout("predecoding audio and video..."); |
892 |
892 |
predecode_wait(); |
predecode_wait(); |
893 |
|
POUT("done\n"); |
|
|
893 |
|
pout("done\n"); |
894 |
894 |
npv_video_timer_start(); |
npv_video_timer_start(); |
895 |
895 |
npv_xcb_screensaver_heartbeat_timer_start(); |
npv_xcb_screensaver_heartbeat_timer_start(); |
896 |
896 |
|
|
File npv/video/public/code.frag.c changed (mode: 100644) (index 0087c16..b2604be) |
... |
... |
STATIC void init_once_public(void) |
7 |
7 |
errno = 0; |
errno = 0; |
8 |
8 |
timer_fd_p = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
timer_fd_p = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
9 |
9 |
if (timer_fd_p == -1) |
if (timer_fd_p == -1) |
10 |
|
FATALV("unable to get a timer file descriptor:%s\n", strerror(errno)); |
|
|
10 |
|
fatal("unable to get a timer file descriptor:%s\n", strerror(errno)); |
11 |
11 |
memset(&st_p, 0, sizeof(st_p)); |
memset(&st_p, 0, sizeof(st_p)); |
12 |
12 |
pkt_q_p = npv_pkt_q_new("video"); |
pkt_q_p = npv_pkt_q_new("video"); |
13 |
13 |
dec_ctx_p = 0; |
dec_ctx_p = 0; |
14 |
14 |
r = pthread_mutex_init(&dec_ctx_mutex_l, 0); |
r = pthread_mutex_init(&dec_ctx_mutex_l, 0); |
15 |
15 |
if (r != 0) |
if (r != 0) |
16 |
|
FATALV("unable to create the mutex for the decoder context\n"); |
|
|
16 |
|
fatal("unable to create the mutex for the decoder context\n"); |
17 |
17 |
|
|
18 |
18 |
dec_frs_p.eof_receive = false; |
dec_frs_p.eof_receive = false; |
19 |
19 |
dec_frs_p.n_max = 0; |
dec_frs_p.n_max = 0; |
|
... |
... |
STATIC void init_once_public(void) |
22 |
22 |
dec_frs_p.priv_a = 0; |
dec_frs_p.priv_a = 0; |
23 |
23 |
r = pthread_mutex_init(&dec_frs_p.mutex, 0); |
r = pthread_mutex_init(&dec_frs_p.mutex, 0); |
24 |
24 |
if (r != 0) |
if (r != 0) |
25 |
|
FATALV("unable to create the mutex for the array of frames\n"); |
|
|
25 |
|
fatal("unable to create the mutex for the array of frames\n"); |
26 |
26 |
|
|
27 |
27 |
scaler_p.img.vk = 0; |
scaler_p.img.vk = 0; |
28 |
28 |
memset(&scaler_p.img.layout, 0, sizeof(scaler_p.img.layout)); |
memset(&scaler_p.img.layout, 0, sizeof(scaler_p.img.layout)); |
|
... |
... |
STATIC void init_once_public(void) |
38 |
38 |
/* we are targetting AVUTIL_PIX_FMT_RGB32/sRGB */ |
/* we are targetting AVUTIL_PIX_FMT_RGB32/sRGB */ |
39 |
39 |
scaler_p.ctx = npv_thdsws_init_once(); |
scaler_p.ctx = npv_thdsws_init_once(); |
40 |
40 |
if (scaler_p.ctx == 0) |
if (scaler_p.ctx == 0) |
41 |
|
FATALVFF("scaler:unable to initialize\n"); |
|
|
41 |
|
fatalff("scaler:unable to initialize\n"); |
42 |
42 |
} |
} |
43 |
43 |
#undef NO_FR |
#undef NO_FR |
44 |
44 |
STATIC void init_once(void) |
STATIC void init_once(void) |
|
... |
... |
STATIC void dec_ctx_cfg(avcodec_params_t *params) |
52 |
52 |
|
|
53 |
53 |
dec_l = avcodec_find_dec(params->codec_id); |
dec_l = avcodec_find_dec(params->codec_id); |
54 |
54 |
if (dec_l == 0) |
if (dec_l == 0) |
55 |
|
FATALVFF("unable to find a proper decoder\n"); |
|
|
55 |
|
fatalff("unable to find a proper decoder\n"); |
56 |
56 |
avcodec_free_context(&dec_ctx_p); |
avcodec_free_context(&dec_ctx_p); |
57 |
57 |
dec_ctx_p = avcodec_alloc_ctx(dec_l); |
dec_ctx_p = avcodec_alloc_ctx(dec_l); |
58 |
58 |
if (dec_ctx_p == 0) |
if (dec_ctx_p == 0) |
59 |
|
FATALVFF("unable to allocate an decoder context\n"); |
|
|
59 |
|
fatalff("unable to allocate an decoder context\n"); |
60 |
60 |
/* XXX: useless ? */ |
/* XXX: useless ? */ |
61 |
61 |
r = avcodec_params_to_ctx(dec_ctx_p, params); |
r = avcodec_params_to_ctx(dec_ctx_p, params); |
62 |
62 |
if (r < 0) |
if (r < 0) |
63 |
|
FATALVFF("unable to apply stream codec parameters in codec context\n"); |
|
|
63 |
|
fatalff("unable to apply stream codec parameters in codec context\n"); |
64 |
64 |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
65 |
65 |
dec_ctx_p->thread_count = 0; |
dec_ctx_p->thread_count = 0; |
66 |
66 |
r = avcodec_open2(dec_ctx_p, dec_l, 0); |
r = avcodec_open2(dec_ctx_p, dec_l, 0); |
67 |
67 |
if (r < 0) |
if (r < 0) |
68 |
|
FATALVFF("unable to open the decoder context\n"); |
|
|
68 |
|
fatalff("unable to open the decoder context\n"); |
69 |
69 |
|
|
70 |
70 |
/* we will define the video aspect ratio with those values */ |
/* we will define the video aspect ratio with those values */ |
71 |
71 |
aspect_ratio.width = params->width; |
aspect_ratio.width = params->width; |
|
... |
... |
STATIC void timer_start(void) |
82 |
82 |
t.it_interval.tv_nsec = 2000000; /* 2ms */ |
t.it_interval.tv_nsec = 2000000; /* 2ms */ |
83 |
83 |
r = timerfd_settime(timer_fd_p, 0, &t, 0); |
r = timerfd_settime(timer_fd_p, 0, &t, 0); |
84 |
84 |
if (r == -1) |
if (r == -1) |
85 |
|
FATALV("unable to arm the timer\n"); |
|
|
85 |
|
fatal("unable to arm the timer\n"); |
86 |
86 |
} |
} |
87 |
87 |
STATIC void timer_slow_start(void) |
STATIC void timer_slow_start(void) |
88 |
88 |
{ |
{ |
|
... |
... |
STATIC void timer_slow_start(void) |
95 |
95 |
t.it_interval.tv_nsec = 100000000; /* 100ms */ |
t.it_interval.tv_nsec = 100000000; /* 100ms */ |
96 |
96 |
r = timerfd_settime(timer_fd_p, 0, &t, 0); |
r = timerfd_settime(timer_fd_p, 0, &t, 0); |
97 |
97 |
if (r == -1) |
if (r == -1) |
98 |
|
FATALV("unable to arm the timer\n"); |
|
|
98 |
|
fatal("unable to arm the timer\n"); |
99 |
99 |
} |
} |
100 |
100 |
#define AGAIN 0 |
#define AGAIN 0 |
101 |
101 |
#define HAVE_FR 1 |
#define HAVE_FR 1 |
|
... |
... |
STATIC u8 dec_fr_try_receive(void) |
122 |
122 |
dec_frs_unlock(); |
dec_frs_unlock(); |
123 |
123 |
return HAVE_FR; |
return HAVE_FR; |
124 |
124 |
} else if (r == AVUTIL_AVERROR_EOF) { |
} else if (r == AVUTIL_AVERROR_EOF) { |
125 |
|
POUTVFF("last decoder frame reached (receiving)\n"); |
|
|
125 |
|
poutff("last decoder frame reached (receiving)\n"); |
126 |
126 |
dec_frs_lock(); |
dec_frs_lock(); |
127 |
127 |
dec_frs_p.eof_receive = true; |
dec_frs_p.eof_receive = true; |
128 |
128 |
dec_frs_unlock(); |
dec_frs_unlock(); |
129 |
129 |
return EOF_DEC; |
return EOF_DEC; |
130 |
130 |
} |
} |
131 |
|
FATALVFF("error while receiving frame from the decoder\n"); |
|
|
131 |
|
fatalff("error while receiving frame from the decoder\n"); |
132 |
132 |
} |
} |
133 |
133 |
#undef AGAIN |
#undef AGAIN |
134 |
134 |
#undef HAVE_FR |
#undef HAVE_FR |
|
... |
... |
STATIC void dec_ctx_lock(void) |
165 |
165 |
|
|
166 |
166 |
r = pthread_mutex_lock(&dec_ctx_mutex_l); |
r = pthread_mutex_lock(&dec_ctx_mutex_l); |
167 |
167 |
if (r != 0) |
if (r != 0) |
168 |
|
FATALV("%d:unable to lock the video decoder context\n", r); |
|
|
168 |
|
fatal("%d:unable to lock the video decoder context\n", r); |
169 |
169 |
} |
} |
170 |
170 |
STATIC void dec_ctx_unlock(void) |
STATIC void dec_ctx_unlock(void) |
171 |
171 |
{ |
{ |
|
... |
... |
STATIC void dec_ctx_unlock(void) |
173 |
173 |
|
|
174 |
174 |
r = pthread_mutex_unlock(&dec_ctx_mutex_l); |
r = pthread_mutex_unlock(&dec_ctx_mutex_l); |
175 |
175 |
if (r != 0) |
if (r != 0) |
176 |
|
FATALV("%d:unable to unlock the video decoder context\n", r); |
|
|
176 |
|
fatal("%d:unable to unlock the video decoder context\n", r); |
177 |
177 |
} |
} |
178 |
178 |
STATIC void dec_frs_lock(void) |
STATIC void dec_frs_lock(void) |
179 |
179 |
{ |
{ |
|
... |
... |
STATIC void dec_frs_lock(void) |
181 |
181 |
|
|
182 |
182 |
r = pthread_mutex_lock(&dec_frs_p.mutex); |
r = pthread_mutex_lock(&dec_frs_p.mutex); |
183 |
183 |
if (r != 0) |
if (r != 0) |
184 |
|
FATALV("%d:unable to lock the array of decoder frames\n", r); |
|
|
184 |
|
fatal("%d:unable to lock the array of decoder frames\n", r); |
185 |
185 |
} |
} |
186 |
186 |
STATIC void dec_frs_unlock(void) |
STATIC void dec_frs_unlock(void) |
187 |
187 |
{ |
{ |
|
... |
... |
STATIC void dec_frs_unlock(void) |
189 |
189 |
|
|
190 |
190 |
r = pthread_mutex_unlock(&dec_frs_p.mutex); |
r = pthread_mutex_unlock(&dec_frs_p.mutex); |
191 |
191 |
if (r != 0) |
if (r != 0) |
192 |
|
FATALV("%d:unable to unlock the array of decoder frames\n", r); |
|
|
192 |
|
fatal("%d:unable to unlock the array of decoder frames\n", r); |
193 |
193 |
} |
} |
194 |
194 |
/* go non-blocking or a worker thread is needed */ |
/* go non-blocking or a worker thread is needed */ |
195 |
195 |
#define NO_FR 0 |
#define NO_FR 0 |
|
... |
... |
STATIC void pkts_send(void) { loop |
269 |
269 |
else if (r == AVUTIL_AVERROR_EOF) /* the dec is in draining mode */ |
else if (r == AVUTIL_AVERROR_EOF) /* the dec is in draining mode */ |
270 |
270 |
goto unlock_and_return; |
goto unlock_and_return; |
271 |
271 |
else if (r != 0) |
else if (r != 0) |
272 |
|
FATALV("error while sending a packet to the decoder\n"); |
|
|
272 |
|
fatal("error while sending a packet to the decoder\n"); |
273 |
273 |
/* r == 0 */ |
/* r == 0 */ |
274 |
274 |
npv_pipeline_limits_lock(); |
npv_pipeline_limits_lock(); |
275 |
275 |
npv_pipeline_limits_p.pkts.video_bytes_n -= pr->sz; |
npv_pipeline_limits_p.pkts.video_bytes_n -= pr->sz; |
File npv/vk/local/code.frag.c changed (mode: 100644) (index 28b0c34..dd5e2ee) |
|
1 |
|
STATIC void pout(u8 *fmt, ...) |
|
2 |
|
{ |
|
3 |
|
va_list ap; |
|
4 |
|
|
|
5 |
|
npv_pout("vulkan:"); |
|
6 |
|
va_start(ap, fmt); |
|
7 |
|
npv_vpout(fmt, ap); |
|
8 |
|
va_end(ap); |
|
9 |
|
} |
1 |
10 |
#define INSTANCE_STATIC_SYM(x,y) \ |
#define INSTANCE_STATIC_SYM(x,y) \ |
2 |
11 |
npv_dl_##y = vk_get_instance_proc_addr(0, #x); \ |
npv_dl_##y = vk_get_instance_proc_addr(0, #x); \ |
3 |
12 |
if (npv_dl_##y == 0) \ |
if (npv_dl_##y == 0) \ |
4 |
|
FATALVK("unable to find vulkan " #x "\n"); |
|
|
13 |
|
fatal("unable to find vulkan " #x "\n"); |
5 |
14 |
STATIC void instance_static_syms(void) |
STATIC void instance_static_syms(void) |
6 |
15 |
{ |
{ |
7 |
16 |
INSTANCE_STATIC_SYM(vkEnumerateInstanceVersion, |
INSTANCE_STATIC_SYM(vkEnumerateInstanceVersion, |
|
... |
... |
STATIC void instance_static_syms(void) |
17 |
26 |
#define INSTANCE_SYM(x,y) \ |
#define INSTANCE_SYM(x,y) \ |
18 |
27 |
npv_dl_##y = vk_get_instance_proc_addr(instance_l, #x); \ |
npv_dl_##y = vk_get_instance_proc_addr(instance_l, #x); \ |
19 |
28 |
if (npv_dl_##y == 0) \ |
if (npv_dl_##y == 0) \ |
20 |
|
FATALVK("unable to find vulkan " #x "\n"); |
|
|
29 |
|
fatal("unable to find vulkan " #x "\n"); |
21 |
30 |
STATIC void instance_syms(void) |
STATIC void instance_syms(void) |
22 |
31 |
{ |
{ |
23 |
32 |
INSTANCE_SYM(vkEnumeratePhysicalDevices, vk_enumerate_phydevs); |
INSTANCE_SYM(vkEnumeratePhysicalDevices, vk_enumerate_phydevs); |
|
... |
... |
STATIC void instance_syms(void) |
46 |
55 |
#define DEV_SYM(x,y) \ |
#define DEV_SYM(x,y) \ |
47 |
56 |
surf_p.dev.dl_##y = vk_get_dev_proc_addr(surf_p.dev.vk, #x); \ |
surf_p.dev.dl_##y = vk_get_dev_proc_addr(surf_p.dev.vk, #x); \ |
48 |
57 |
if (surf_p.dev.dl_##y == 0) \ |
if (surf_p.dev.dl_##y == 0) \ |
49 |
|
FATALVK("unable to find vulkan device " #x "\n"); |
|
|
58 |
|
fatal("unable to find vulkan device " #x "\n"); |
50 |
59 |
STATIC void dev_syms(void) |
STATIC void dev_syms(void) |
51 |
60 |
{ |
{ |
52 |
61 |
DEV_SYM(vkGetDeviceQueue, vk_get_dev_q); |
DEV_SYM(vkGetDeviceQueue, vk_get_dev_q); |
|
... |
... |
STATIC void dev_syms(void) |
81 |
90 |
#define DLSYM(x, y) \ |
#define DLSYM(x, y) \ |
82 |
91 |
npv_dl_##y = dlsym(loader_l, #x); \ |
npv_dl_##y = dlsym(loader_l, #x); \ |
83 |
92 |
if (npv_dl_##y == 0) \ |
if (npv_dl_##y == 0) \ |
84 |
|
FATALVK("%s:unable to find " #x "\n", dlerror()); |
|
|
93 |
|
fatal("%s:unable to find " #x "\n", dlerror()); |
85 |
94 |
STATIC void loader_syms(void) |
STATIC void loader_syms(void) |
86 |
95 |
{ |
{ |
87 |
96 |
DLSYM(vkGetInstanceProcAddr, vk_get_instance_proc_addr); |
DLSYM(vkGetInstanceProcAddr, vk_get_instance_proc_addr); |
|
... |
... |
STATIC void load_vk_loader(void) |
94 |
103 |
/* no '/' in the shared dynamic lib path name, then standard lookup */ |
/* no '/' in the shared dynamic lib path name, then standard lookup */ |
95 |
104 |
loader_l = dlopen("libvulkan.so.1", RTLD_LAZY); |
loader_l = dlopen("libvulkan.so.1", RTLD_LAZY); |
96 |
105 |
if (loader_l == 0) |
if (loader_l == 0) |
97 |
|
FATALVK("%s:unable to load the vulkan loader dynamic shared library\n", dlerror()); |
|
|
106 |
|
fatal("%s:unable to load the vulkan loader dynamic shared library\n", dlerror()); |
98 |
107 |
} |
} |
99 |
108 |
STATIC void check_vk_version(void) |
STATIC void check_vk_version(void) |
100 |
109 |
{ |
{ |
|
... |
... |
STATIC void check_vk_version(void) |
103 |
112 |
|
|
104 |
113 |
vk_enumerate_instance_version(&api_version); |
vk_enumerate_instance_version(&api_version); |
105 |
114 |
if (r != vk_success) |
if (r != vk_success) |
106 |
|
FATALVK("%d:unable to enumerate instance version\n", r); |
|
107 |
|
POUTVK("vulkan instance version %#x = %u.%u.%u\n", api_version, VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), VK_VERSION_PATCH(api_version)); |
|
|
115 |
|
fatal("%d:unable to enumerate instance version\n", r); |
|
116 |
|
pout("vulkan instance version %#x = %u.%u.%u\n", api_version, VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), VK_VERSION_PATCH(api_version)); |
108 |
117 |
if (VK_VERSION_MAJOR(api_version) == 1 |
if (VK_VERSION_MAJOR(api_version) == 1 |
109 |
118 |
&& VK_VERSION_MINOR(api_version) == 0) |
&& VK_VERSION_MINOR(api_version) == 0) |
110 |
|
FATALVK("instance version too old\n"); |
|
|
119 |
|
fatal("instance version too old\n"); |
111 |
120 |
} |
} |
112 |
121 |
#define EXTS_N_MAX 256 |
#define EXTS_N_MAX 256 |
113 |
122 |
/* in theory, this could change on the fly */ |
/* in theory, this could change on the fly */ |
|
... |
... |
STATIC void instance_exts_dump(void) |
121 |
130 |
n = EXTS_N_MAX; |
n = EXTS_N_MAX; |
122 |
131 |
vk_enumerate_instance_ext_props(&n, exts); |
vk_enumerate_instance_ext_props(&n, exts); |
123 |
132 |
if (r != vk_success && r != vk_incomplete) { |
if (r != vk_success && r != vk_incomplete) { |
124 |
|
WARNINGVK("%d:unable to enumerate instance extension(s)\n", r); |
|
|
133 |
|
warning("%d:unable to enumerate instance extension(s)\n", r); |
125 |
134 |
return; |
return; |
126 |
135 |
} |
} |
127 |
136 |
if (r == vk_incomplete) { |
if (r == vk_incomplete) { |
128 |
|
WARNINGVK("too many extensions (%u/%u), dumping disabled", n, EXTS_N_MAX); |
|
|
137 |
|
warning("too many extensions (%u/%u), dumping disabled", n, EXTS_N_MAX); |
129 |
138 |
return; |
return; |
130 |
139 |
} |
} |
131 |
140 |
/* vk_success */ |
/* vk_success */ |
132 |
|
POUTVK("have %u instance extension(s)\n", n); |
|
|
141 |
|
pout("have %u instance extension(s)\n", n); |
133 |
142 |
loop { |
loop { |
134 |
143 |
if (n == 0) |
if (n == 0) |
135 |
144 |
break; |
break; |
136 |
|
POUTVK("instance extension:name=%s:specification version=%u\n", exts[n - 1].name, exts[n - 1].spec_version); |
|
|
145 |
|
pout("instance extension:name=%s:specification version=%u\n", exts[n - 1].name, exts[n - 1].spec_version); |
137 |
146 |
n--; |
n--; |
138 |
147 |
} |
} |
139 |
148 |
} |
} |
|
... |
... |
STATIC void instance_layers_dump(void) |
150 |
159 |
n = LAYERS_N_MAX; |
n = LAYERS_N_MAX; |
151 |
160 |
vk_enumerate_instance_layer_props(&n, layers); |
vk_enumerate_instance_layer_props(&n, layers); |
152 |
161 |
if (r != vk_success && r != vk_incomplete) { |
if (r != vk_success && r != vk_incomplete) { |
153 |
|
WARNINGVK("%d:unable to enumerate instance layer(s)\n", r); |
|
|
162 |
|
warning("%d:unable to enumerate instance layer(s)\n", r); |
154 |
163 |
return; |
return; |
155 |
164 |
} |
} |
156 |
165 |
if (r == vk_incomplete) { |
if (r == vk_incomplete) { |
157 |
|
WARNINGVK("too many layers (%u/%u), dumping disabled", n, LAYERS_N_MAX); |
|
|
166 |
|
warning("too many layers (%u/%u), dumping disabled", n, LAYERS_N_MAX); |
158 |
167 |
return; |
return; |
159 |
168 |
} |
} |
160 |
169 |
/* vk_success */ |
/* vk_success */ |
161 |
|
POUTVK("have %u instance layer(s)\n", n); |
|
|
170 |
|
pout("have %u instance layer(s)\n", n); |
162 |
171 |
loop { |
loop { |
163 |
172 |
if (n == 0) |
if (n == 0) |
164 |
173 |
break; |
break; |
165 |
|
POUTVK("instance layer:%u:name=%s:specification version=%u:implementation version=%u:description=%s\n", n, layers[n].name, layers[n].spec_version, layers[n].implementation_version, layers[n].desc); |
|
|
174 |
|
pout("instance layer:%u:name=%s:specification version=%u:implementation version=%u:description=%s\n", n, layers[n].name, layers[n].spec_version, layers[n].implementation_version, layers[n].desc); |
166 |
175 |
n--; |
n--; |
167 |
176 |
} |
} |
168 |
177 |
} |
} |
|
... |
... |
STATIC void instance_create(void) |
191 |
200 |
loop { |
loop { |
192 |
201 |
if (i == ARRAY_N(exts)) |
if (i == ARRAY_N(exts)) |
193 |
202 |
break; |
break; |
194 |
|
POUTVK("will use instance extension %s\n", exts[i]); |
|
|
203 |
|
pout("will use instance extension %s\n", exts[i]); |
195 |
204 |
++i; |
++i; |
196 |
205 |
} |
} |
197 |
206 |
memset(&info, 0, sizeof(info)); |
memset(&info, 0, sizeof(info)); |
|
... |
... |
STATIC void instance_create(void) |
200 |
209 |
info.enabled_ext_names = exts; |
info.enabled_ext_names = exts; |
201 |
210 |
vk_create_instance(&info); |
vk_create_instance(&info); |
202 |
211 |
IF_FATALVK("%d:unable to create an instance\n", r); |
IF_FATALVK("%d:unable to create an instance\n", r); |
203 |
|
POUTVK("instance handle %p\n", instance_l); |
|
|
212 |
|
pout("instance handle %p\n", instance_l); |
204 |
213 |
} |
} |
205 |
214 |
STATIC void tmp_phydevs_get(void) |
STATIC void tmp_phydevs_get(void) |
206 |
215 |
{ |
{ |
|
... |
... |
STATIC void tmp_phydevs_get(void) |
212 |
221 |
n = tmp_phydevs_n_max; |
n = tmp_phydevs_n_max; |
213 |
222 |
vk_enumerate_phydevs(&n, phydevs); |
vk_enumerate_phydevs(&n, phydevs); |
214 |
223 |
if (r != vk_success && r != vk_incomplete) |
if (r != vk_success && r != vk_incomplete) |
215 |
|
FATALVK("%ld:unable to enumerate physical devices\n", r); |
|
|
224 |
|
fatal("%ld:unable to enumerate physical devices\n", r); |
216 |
225 |
if (r == vk_incomplete) |
if (r == vk_incomplete) |
217 |
|
FATALVK("too many vulkan physical devices %u/%u for our temporary storage\n", n, tmp_phydevs_n_max); |
|
|
226 |
|
fatal("too many vulkan physical devices %u/%u for our temporary storage\n", n, tmp_phydevs_n_max); |
218 |
227 |
/* vk_success */ |
/* vk_success */ |
219 |
|
POUTVK("detected %u physical devices\n", n); |
|
|
228 |
|
pout("detected %u physical devices\n", n); |
220 |
229 |
if (n == 0) |
if (n == 0) |
221 |
|
FATALVK("no vulkan physical devices, exiting\n"); |
|
|
230 |
|
fatal("no vulkan physical devices, exiting\n"); |
222 |
231 |
tmp_phydevs_n_l = n; |
tmp_phydevs_n_l = n; |
223 |
232 |
memset(tmp_phydevs_l, 0, sizeof(tmp_phydevs_l)); |
memset(tmp_phydevs_l, 0, sizeof(tmp_phydevs_l)); |
224 |
233 |
n = 0; |
n = 0; |
|
... |
... |
STATIC void phydev_exts_dump(void *phydev) |
240 |
249 |
n = EXTS_N_MAX; |
n = EXTS_N_MAX; |
241 |
250 |
vk_enumerate_dev_ext_props(phydev, &n, exts); |
vk_enumerate_dev_ext_props(phydev, &n, exts); |
242 |
251 |
if (r != vk_success && r != vk_incomplete) { |
if (r != vk_success && r != vk_incomplete) { |
243 |
|
WARNINGVK("physical device:%p:%d:unable to enumerate device extension(s)\n", phydev, r); |
|
|
252 |
|
warning("physical device:%p:%d:unable to enumerate device extension(s)\n", phydev, r); |
244 |
253 |
return; |
return; |
245 |
254 |
} |
} |
246 |
255 |
if (r == vk_incomplete) { |
if (r == vk_incomplete) { |
247 |
|
WARNINGVK("physical device:%p:too many extensions (%u/%u), dumping disabled", phydev, n, EXTS_N_MAX); |
|
|
256 |
|
warning("physical device:%p:too many extensions (%u/%u), dumping disabled", phydev, n, EXTS_N_MAX); |
248 |
257 |
return; |
return; |
249 |
258 |
} |
} |
250 |
259 |
/* vk_success */ |
/* vk_success */ |
251 |
|
POUTVK("physical device:%p:have %u device extension(s)\n", phydev, n); |
|
|
260 |
|
pout("physical device:%p:have %u device extension(s)\n", phydev, n); |
252 |
261 |
loop { |
loop { |
253 |
262 |
if (n == 0) |
if (n == 0) |
254 |
263 |
break; |
break; |
255 |
|
POUTVK("physical device:%p:device extension:name=%s:specification version=%u\n", phydev, exts[n - 1].name, exts[n - 1].spec_version); |
|
|
264 |
|
pout("physical device:%p:device extension:name=%s:specification version=%u\n", phydev, exts[n - 1].name, exts[n - 1].spec_version); |
256 |
265 |
n--; |
n--; |
257 |
266 |
} |
} |
258 |
267 |
} |
} |
|
... |
... |
STATIC void tmp_phydevs_props_dump(void) |
317 |
326 |
memset(&props, 0, sizeof(props)); |
memset(&props, 0, sizeof(props)); |
318 |
327 |
props.type = vk_struct_type_phydev_props; |
props.type = vk_struct_type_phydev_props; |
319 |
328 |
vk_get_phydev_props(p->vk, &props); |
vk_get_phydev_props(p->vk, &props); |
320 |
|
POUTVK("physical device:%p:properties:api version=%#x=%u.%u.%u\n", p->vk, props.core.api_version, VK_VERSION_MAJOR(props.core.api_version), VK_VERSION_MINOR(props.core.api_version), VK_VERSION_PATCH(props.core.api_version)); |
|
321 |
|
POUTVK("physical device:%p:properties:driver version=%#x=%u.%u.%u\n", p->vk, props.core.driver_version, VK_VERSION_MAJOR(props.core.driver_version), VK_VERSION_MINOR(props.core.driver_version), VK_VERSION_PATCH(props.core.driver_version)); |
|
322 |
|
POUTVK("physical device:%p:properties:vendor id=%#x\n", p->vk, props.core.vendor_id); |
|
323 |
|
POUTVK("physical device:%p:properties:device id=%#x\n", p->vk, props.core.dev_id); |
|
324 |
|
POUTVK("physical device:%p:properties:type=%s\n", p->vk, dev_type_str(props.core.dev_type)); |
|
|
329 |
|
pout("physical device:%p:properties:api version=%#x=%u.%u.%u\n", p->vk, props.core.api_version, VK_VERSION_MAJOR(props.core.api_version), VK_VERSION_MINOR(props.core.api_version), VK_VERSION_PATCH(props.core.api_version)); |
|
330 |
|
pout("physical device:%p:properties:driver version=%#x=%u.%u.%u\n", p->vk, props.core.driver_version, VK_VERSION_MAJOR(props.core.driver_version), VK_VERSION_MINOR(props.core.driver_version), VK_VERSION_PATCH(props.core.driver_version)); |
|
331 |
|
pout("physical device:%p:properties:vendor id=%#x\n", p->vk, props.core.vendor_id); |
|
332 |
|
pout("physical device:%p:properties:device id=%#x\n", p->vk, props.core.dev_id); |
|
333 |
|
pout("physical device:%p:properties:type=%s\n", p->vk, dev_type_str(props.core.dev_type)); |
325 |
334 |
if (props.core.dev_type == vk_phydev_type_discrete_gpu) |
if (props.core.dev_type == vk_phydev_type_discrete_gpu) |
326 |
335 |
p->is_discret_gpu = true; |
p->is_discret_gpu = true; |
327 |
336 |
else |
else |
328 |
337 |
p->is_discret_gpu = false; |
p->is_discret_gpu = false; |
329 |
|
POUTVK("physical device:%p:properties:name=%s\n", p->vk, props.core.name); |
|
330 |
|
POUTVK("physical device:%p:properties:pipeline cache uuid=%s\n", p->vk, uuid_str(props.core.pl_cache_uuid)); |
|
|
338 |
|
pout("physical device:%p:properties:name=%s\n", p->vk, props.core.name); |
|
339 |
|
pout("physical device:%p:properties:pipeline cache uuid=%s\n", p->vk, uuid_str(props.core.pl_cache_uuid)); |
331 |
340 |
/* disp the limits and sparse props at "higher log lvl", if needed in the end */ |
/* disp the limits and sparse props at "higher log lvl", if needed in the end */ |
332 |
341 |
++i; |
++i; |
333 |
342 |
} |
} |
|
... |
... |
STATIC void tmp_phydevs_mem_props_get(void) |
353 |
362 |
STATIC void phydev_mem_type_dump(void *phydev, u8 i, |
STATIC void phydev_mem_type_dump(void *phydev, u8 i, |
354 |
363 |
struct vk_mem_type_t *type) |
struct vk_mem_type_t *type) |
355 |
364 |
{ |
{ |
356 |
|
POUTVK("physical device:%p:memory type:%u:heap:%u\n", phydev, i, type->heap); |
|
357 |
|
POUTVK("physical device:%p:memory type:%u:flags:%#08x\n", phydev, i, type->prop_flags); |
|
|
365 |
|
pout("physical device:%p:memory type:%u:heap:%u\n", phydev, i, type->heap); |
|
366 |
|
pout("physical device:%p:memory type:%u:flags:%#08x\n", phydev, i, type->prop_flags); |
358 |
367 |
if ((type->prop_flags & vk_mem_prop_dev_local_bit) != 0) |
if ((type->prop_flags & vk_mem_prop_dev_local_bit) != 0) |
359 |
|
POUTVK("physical device:%p:memory type:%u:device local\n", phydev, i); |
|
|
368 |
|
pout("physical device:%p:memory type:%u:device local\n", phydev, i); |
360 |
369 |
if ((type->prop_flags & vk_mem_prop_host_visible_bit) != 0) |
if ((type->prop_flags & vk_mem_prop_host_visible_bit) != 0) |
361 |
|
POUTVK("physical device:%p:memory type:%u:host visible\n", phydev, i); |
|
|
370 |
|
pout("physical device:%p:memory type:%u:host visible\n", phydev, i); |
362 |
371 |
if ((type->prop_flags & vk_mem_prop_host_cached_bit) != 0) |
if ((type->prop_flags & vk_mem_prop_host_cached_bit) != 0) |
363 |
|
POUTVK("physical device:%p:memory type:%u:host cached\n", phydev, i); |
|
|
372 |
|
pout("physical device:%p:memory type:%u:host cached\n", phydev, i); |
364 |
373 |
} |
} |
365 |
374 |
STATIC void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p) |
STATIC void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p) |
366 |
375 |
{ |
{ |
367 |
376 |
u8 i; |
u8 i; |
368 |
377 |
|
|
369 |
|
POUTVK("physical device:%p:%u memory types\n", p->vk, p->mem_props.core.mem_types_n); |
|
|
378 |
|
pout("physical device:%p:%u memory types\n", p->vk, p->mem_props.core.mem_types_n); |
370 |
379 |
i = 0; |
i = 0; |
371 |
380 |
loop { |
loop { |
372 |
381 |
if (i == p->mem_props.core.mem_types_n) |
if (i == p->mem_props.core.mem_types_n) |
|
... |
... |
STATIC void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p) |
379 |
388 |
STATIC void phydev_mem_heap_dump(void *phydev, u8 i, |
STATIC void phydev_mem_heap_dump(void *phydev, u8 i, |
380 |
389 |
struct vk_mem_heap_t *heap) |
struct vk_mem_heap_t *heap) |
381 |
390 |
{ |
{ |
382 |
|
POUTVK("physical device:%p:memory heap:%u:size:%u bytes\n", phydev, i, heap->sz); |
|
383 |
|
POUTVK("physical device:%p:memory heap:%u:flags:%#08x\n", phydev, i, heap->flags); |
|
|
391 |
|
pout("physical device:%p:memory heap:%u:size:%u bytes\n", phydev, i, heap->sz); |
|
392 |
|
pout("physical device:%p:memory heap:%u:flags:%#08x\n", phydev, i, heap->flags); |
384 |
393 |
if ((heap->flags & vk_mem_heap_dev_local_bit) != 0) |
if ((heap->flags & vk_mem_heap_dev_local_bit) != 0) |
385 |
|
POUTVK("physical device:%p:memory heap:%u:device local\n", phydev, i); |
|
|
394 |
|
pout("physical device:%p:memory heap:%u:device local\n", phydev, i); |
386 |
395 |
if ((heap->flags & vk_mem_heap_multi_instance_bit) != 0) |
if ((heap->flags & vk_mem_heap_multi_instance_bit) != 0) |
387 |
|
POUTVK("physical device:%p:memory type:%u:multi instance\n", phydev, i); |
|
|
396 |
|
pout("physical device:%p:memory type:%u:multi instance\n", phydev, i); |
388 |
397 |
} |
} |
389 |
398 |
STATIC void tmp_phydev_mem_heaps_dump(struct tmp_phydev_t *p) |
STATIC void tmp_phydev_mem_heaps_dump(struct tmp_phydev_t *p) |
390 |
399 |
{ |
{ |
391 |
400 |
u8 i; |
u8 i; |
392 |
401 |
|
|
393 |
|
POUTVK("physical device:%p:%u memory heaps\n", p->vk, p->mem_props.core.mem_heaps_n); |
|
|
402 |
|
pout("physical device:%p:%u memory heaps\n", p->vk, p->mem_props.core.mem_heaps_n); |
394 |
403 |
i = 0; |
i = 0; |
395 |
404 |
loop { |
loop { |
396 |
405 |
if (i == p->mem_props.core.mem_heaps_n) |
if (i == p->mem_props.core.mem_heaps_n) |
|
... |
... |
STATIC void tmp_phydev_q_fams_get(struct tmp_phydev_t *p) |
426 |
435 |
n = 0; |
n = 0; |
427 |
436 |
vk_get_phydev_q_fam_props(p->vk, &n, 0); |
vk_get_phydev_q_fam_props(p->vk, &n, 0); |
428 |
437 |
if (n > tmp_phydev_q_fams_n_max) |
if (n > tmp_phydev_q_fams_n_max) |
429 |
|
FATALVK("physical device:%p:too many queue families %u/%u\n", p->vk, n, tmp_phydev_q_fams_n_max); |
|
|
438 |
|
fatal("physical device:%p:too many queue families %u/%u\n", p->vk, n, tmp_phydev_q_fams_n_max); |
430 |
439 |
memset(p->q_fams, 0, sizeof(p->q_fams)); |
memset(p->q_fams, 0, sizeof(p->q_fams)); |
431 |
440 |
i = 0; |
i = 0; |
432 |
441 |
loop { |
loop { |
|
... |
... |
STATIC void tmp_phydev_q_fams_get(struct tmp_phydev_t *p) |
437 |
446 |
} |
} |
438 |
447 |
vk_get_phydev_q_fam_props(p->vk, &n, p->q_fams); |
vk_get_phydev_q_fam_props(p->vk, &n, p->q_fams); |
439 |
448 |
p->q_fams_n = n; |
p->q_fams_n = n; |
440 |
|
POUTVK("physical device:%p:have %u queue families\n", p->vk, p->q_fams_n); |
|
|
449 |
|
pout("physical device:%p:have %u queue families\n", p->vk, p->q_fams_n); |
441 |
450 |
} |
} |
442 |
451 |
STATIC void tmp_phydevs_q_fams_get(void) |
STATIC void tmp_phydevs_q_fams_get(void) |
443 |
452 |
{ |
{ |
|
... |
... |
STATIC void tmp_phydev_q_fams_dump(struct tmp_phydev_t *p) |
460 |
469 |
if (i == p->q_fams_n) |
if (i == p->q_fams_n) |
461 |
470 |
break; |
break; |
462 |
471 |
if ((p->q_fams[i].core.flags & vk_q_gfx_bit) != 0) |
if ((p->q_fams[i].core.flags & vk_q_gfx_bit) != 0) |
463 |
|
POUTVK("physical device:%p:queue family:%u:flags:graphics\n", p->vk, i); |
|
|
472 |
|
pout("physical device:%p:queue family:%u:flags:graphics\n", p->vk, i); |
464 |
473 |
if ((p->q_fams[i].core.flags & vk_q_compute_bit) != 0) |
if ((p->q_fams[i].core.flags & vk_q_compute_bit) != 0) |
465 |
|
POUTVK("physical device:%p:queue family:%u:flags:compute\n", p->vk, i); |
|
|
474 |
|
pout("physical device:%p:queue family:%u:flags:compute\n", p->vk, i); |
466 |
475 |
if ((p->q_fams[i].core.flags & vk_q_transfer_bit) != 0) |
if ((p->q_fams[i].core.flags & vk_q_transfer_bit) != 0) |
467 |
|
POUTVK("physical device:%p:queue family:%u:flags:transfer\n", p->vk, i); |
|
|
476 |
|
pout("physical device:%p:queue family:%u:flags:transfer\n", p->vk, i); |
468 |
477 |
if ((p->q_fams[i].core.flags & vk_q_sparse_binding_bit) != 0) |
if ((p->q_fams[i].core.flags & vk_q_sparse_binding_bit) != 0) |
469 |
|
POUTVK("physical device:%p:queue family:%u:flags:sparse binding\n", p->vk, i); |
|
|
478 |
|
pout("physical device:%p:queue family:%u:flags:sparse binding\n", p->vk, i); |
470 |
479 |
if ((p->q_fams[i].core.flags & vk_q_protected_bit) != 0) |
if ((p->q_fams[i].core.flags & vk_q_protected_bit) != 0) |
471 |
|
POUTVK("physical device:%p:queue family:%u:flags:protected\n", p->vk, i); |
|
472 |
|
POUTVK("physical device:%p:queue family:%u:%u queues\n", p->vk, i, p->q_fams[i].core.qs_n); |
|
473 |
|
POUTVK("physical device:%p:queue family:%u:%u bits timestamps\n", p->vk, i, p->q_fams[i].core.timestamp_valid_bits); |
|
474 |
|
POUTVK("physical device:%p:queue family:%u:(width=%u,height=%u,depth=%u) minimum image transfer granularity\n", p->vk, i, p->q_fams[i].core.min_img_transfer_granularity.width, p->q_fams[i].core.min_img_transfer_granularity.height, p->q_fams[i].core.min_img_transfer_granularity.depth); |
|
|
480 |
|
pout("physical device:%p:queue family:%u:flags:protected\n", p->vk, i); |
|
481 |
|
pout("physical device:%p:queue family:%u:%u queues\n", p->vk, i, p->q_fams[i].core.qs_n); |
|
482 |
|
pout("physical device:%p:queue family:%u:%u bits timestamps\n", p->vk, i, p->q_fams[i].core.timestamp_valid_bits); |
|
483 |
|
pout("physical device:%p:queue family:%u:(width=%u,height=%u,depth=%u) minimum image transfer granularity\n", p->vk, i, p->q_fams[i].core.min_img_transfer_granularity.width, p->q_fams[i].core.min_img_transfer_granularity.height, p->q_fams[i].core.min_img_transfer_granularity.depth); |
475 |
484 |
++i; |
++i; |
476 |
485 |
} |
} |
477 |
486 |
} |
} |
|
... |
... |
STATIC void tmp_phydevs_q_fams_surf_support_get(void) |
517 |
526 |
vk_get_phydev_surf_support(p->vk, j, &supported); |
vk_get_phydev_surf_support(p->vk, j, &supported); |
518 |
527 |
IF_FATALVK("%d:physical device:%p:queue family:%u:surface:%p:unable to query queue family wsi/(image presentation to our surface) support\n", r, p->vk, j, surf_p.vk); |
IF_FATALVK("%d:physical device:%p:queue family:%u:surface:%p:unable to query queue family wsi/(image presentation to our surface) support\n", r, p->vk, j, surf_p.vk); |
519 |
528 |
if (supported == vk_true) { |
if (supported == vk_true) { |
520 |
|
POUTVK("physical device:%p:queue family:%u:surface:%p:does support wsi/(image presentation to our surface) \n", p->vk, j, surf_p.vk); |
|
|
529 |
|
pout("physical device:%p:queue family:%u:surface:%p:does support wsi/(image presentation to our surface) \n", p->vk, j, surf_p.vk); |
521 |
530 |
p->q_fams_surf_support[j] = true; |
p->q_fams_surf_support[j] = true; |
522 |
531 |
} else { |
} else { |
523 |
|
POUTVK("physical device:%p:queue family:%u:surface:%p:does not support wsi/(image presentation to our surface)\n", p->vk, j, surf_p.vk); |
|
|
532 |
|
pout("physical device:%p:queue family:%u:surface:%p:does not support wsi/(image presentation to our surface)\n", p->vk, j, surf_p.vk); |
524 |
533 |
p->q_fams_surf_support[j] = false; |
p->q_fams_surf_support[j] = false; |
525 |
534 |
} |
} |
526 |
535 |
++j; |
++j; |
|
... |
... |
STATIC void tmp_phydev_and_q_fam_select(void) |
572 |
581 |
!= 0) { |
!= 0) { |
573 |
582 |
surf_p.dev.phydev.q_fam = j; |
surf_p.dev.phydev.q_fam = j; |
574 |
583 |
tmp_selected_phydev_cherry_pick(i); |
tmp_selected_phydev_cherry_pick(i); |
575 |
|
POUTVK("physical device %p selected for (wsi/image presentation to our surface %p) using its queue family %u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.q_fam); |
|
|
584 |
|
pout("physical device %p selected for (wsi/image presentation to our surface %p) using its queue family %u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.q_fam); |
576 |
585 |
return; |
return; |
577 |
586 |
} |
} |
578 |
587 |
++j; |
++j; |
|
... |
... |
STATIC void texel_mem_blk_confs_dump(u32 confs_n, |
589 |
598 |
loop { |
loop { |
590 |
599 |
if (i == confs_n) |
if (i == confs_n) |
591 |
600 |
break; |
break; |
592 |
|
POUTVK("physical device:%p:surface:%p:texel memory block configuration:format=%u color_space=%u\n", surf_p.dev.phydev.vk, surf_p.vk, confs[i].core.fmt, confs[i].core.color_space); |
|
|
601 |
|
pout("physical device:%p:surface:%p:texel memory block configuration:format=%u color_space=%u\n", surf_p.dev.phydev.vk, surf_p.vk, confs[i].core.fmt, confs[i].core.color_space); |
593 |
602 |
++i; |
++i; |
594 |
603 |
} |
} |
595 |
604 |
} |
} |
|
... |
... |
STATIC void phydev_surf_texel_mem_blk_conf_select(void) |
613 |
622 |
vk_get_phydev_surf_texel_mem_blk_confs(&info, &confs_n, 0); |
vk_get_phydev_surf_texel_mem_blk_confs(&info, &confs_n, 0); |
614 |
623 |
IF_FATALVK("%d:physical device:%p:surface:%p:unable get the count of valid surface texel memory block configurations\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
IF_FATALVK("%d:physical device:%p:surface:%p:unable get the count of valid surface texel memory block configurations\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
615 |
624 |
if (confs_n > CONFS_N_MAX) |
if (confs_n > CONFS_N_MAX) |
616 |
|
FATALVK("physical device:%p:surface:%p:too many surface texel memory block configurations %u/%u\n", surf_p.dev.phydev.vk, surf_p.vk, confs_n, CONFS_N_MAX); |
|
|
625 |
|
fatal("physical device:%p:surface:%p:too many surface texel memory block configurations %u/%u\n", surf_p.dev.phydev.vk, surf_p.vk, confs_n, CONFS_N_MAX); |
617 |
626 |
|
|
618 |
627 |
memset(confs, 0, sizeof(confs[0]) * confs_n); |
memset(confs, 0, sizeof(confs[0]) * confs_n); |
619 |
628 |
i = 0; |
i = 0; |
|
... |
... |
STATIC void phydev_surf_texel_mem_blk_conf_select(void) |
626 |
635 |
vk_get_phydev_surf_texel_mem_blk_confs(&info, &confs_n, confs); |
vk_get_phydev_surf_texel_mem_blk_confs(&info, &confs_n, confs); |
627 |
636 |
IF_FATALVK("%d:physical device:%p:surface:%p:unable get the valid surface texel memory block configurations\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
IF_FATALVK("%d:physical device:%p:surface:%p:unable get the valid surface texel memory block configurations\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
628 |
637 |
if (confs_n == 0) |
if (confs_n == 0) |
629 |
|
FATALVK("physical device:%p:surface:%p:no valid surface texel memory block configuration\n", surf_p.dev.phydev.vk, surf_p.vk); |
|
|
638 |
|
fatal("physical device:%p:surface:%p:no valid surface texel memory block configuration\n", surf_p.dev.phydev.vk, surf_p.vk); |
630 |
639 |
texel_mem_blk_confs_dump(confs_n, confs); |
texel_mem_blk_confs_dump(confs_n, confs); |
631 |
640 |
|
|
632 |
641 |
cc = &surf_p.dev.phydev.selected_texel_mem_blk_conf_core; |
cc = &surf_p.dev.phydev.selected_texel_mem_blk_conf_core; |
|
... |
... |
STATIC void phydev_surf_texel_mem_blk_conf_select(void) |
635 |
644 |
* get from ff scaler |
* get from ff scaler |
636 |
645 |
*/ |
*/ |
637 |
646 |
cc->fmt = vk_texel_mem_blk_fmt_b8g8r8a8_srgb; |
cc->fmt = vk_texel_mem_blk_fmt_b8g8r8a8_srgb; |
638 |
|
POUTVK("physical device:%p:surface:%p:using our surface texel memory block format %u\n", surf_p.dev.phydev.vk, surf_p.vk, cc->fmt); |
|
|
647 |
|
pout("physical device:%p:surface:%p:using our surface texel memory block format %u\n", surf_p.dev.phydev.vk, surf_p.vk, cc->fmt); |
639 |
648 |
cc->color_space = vk_color_space_srgb_nonlinear; |
cc->color_space = vk_color_space_srgb_nonlinear; |
640 |
|
POUTVK("physical device:%p:surface:%p:using prefered surface texel memory block color space %u\n", surf_p.dev.phydev.vk, surf_p.vk, cc->color_space); |
|
|
649 |
|
pout("physical device:%p:surface:%p:using prefered surface texel memory block color space %u\n", surf_p.dev.phydev.vk, surf_p.vk, cc->color_space); |
641 |
650 |
} |
} |
642 |
651 |
#undef CONFS_N_MAX |
#undef CONFS_N_MAX |
643 |
652 |
STATIC void phydev_surf_caps_get(void) |
STATIC void phydev_surf_caps_get(void) |
|
... |
... |
STATIC void phydev_surf_caps_get(void) |
655 |
664 |
IF_FATALVK("%d:physical device:%p:surface:%p:unable to get our surface capabilities in the context of the selected physical device\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
IF_FATALVK("%d:physical device:%p:surface:%p:unable to get our surface capabilities in the context of the selected physical device\n", r, surf_p.dev.phydev.vk, surf_p.vk); |
656 |
665 |
/* we have room for a maximum of 3 images per swapchain */ |
/* we have room for a maximum of 3 images per swapchain */ |
657 |
666 |
if (surf_p.dev.phydev.surf_caps.core.imgs_n_min > swpchn_imgs_n_max) |
if (surf_p.dev.phydev.surf_caps.core.imgs_n_min > swpchn_imgs_n_max) |
658 |
|
FATALVK("physical device:%p:surface:%p:we have room for %u images per swapchain, but this swapchain requires a minimum of %u images\n", surf_p.dev.phydev.vk, surf_p.vk, swpchn_imgs_n_max, surf_p.dev.phydev.surf_caps.core.imgs_n_min); |
|
|
667 |
|
fatal("physical device:%p:surface:%p:we have room for %u images per swapchain, but this swapchain requires a minimum of %u images\n", surf_p.dev.phydev.vk, surf_p.vk, swpchn_imgs_n_max, surf_p.dev.phydev.surf_caps.core.imgs_n_min); |
659 |
668 |
} |
} |
660 |
669 |
STATIC void phydev_surf_caps_dump(void) |
STATIC void phydev_surf_caps_dump(void) |
661 |
670 |
{ |
{ |
662 |
|
POUTVK("physical device:%p:surface:%p:imgs_n_min=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.imgs_n_min); |
|
663 |
|
POUTVK("physical device:%p:surface:%p:imgs_n_max=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.imgs_n_max); |
|
664 |
|
POUTVK("physical device:%p:surface:%p:current extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.current_extent.width, surf_p.dev.phydev.surf_caps.core.current_extent.height); |
|
665 |
|
POUTVK("physical device:%p:surface:%p:minimal extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_extent_min.width, surf_p.dev.phydev.surf_caps.core.img_extent_min.height); |
|
666 |
|
POUTVK("physical device:%p:surface:%p:maximal extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_extent_max.width, surf_p.dev.phydev.surf_caps.core.img_extent_max.height); |
|
667 |
|
POUTVK("physical device:%p:surface:%p:img_array_layers_n_max=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_array_layers_n_max); |
|
668 |
|
POUTVK("physical device:%p:surface:%p:supported_transforms=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_transforms); |
|
669 |
|
POUTVK("physical device:%p:surface:%p:current_transform=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.current_transform); |
|
670 |
|
POUTVK("physical device:%p:surface:%p:supported_composite_alpha=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_composite_alpha); |
|
671 |
|
POUTVK("physical device:%p:surface:%p:supported_img_usage_flags=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_img_usage_flags); |
|
|
671 |
|
pout("physical device:%p:surface:%p:imgs_n_min=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.imgs_n_min); |
|
672 |
|
pout("physical device:%p:surface:%p:imgs_n_max=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.imgs_n_max); |
|
673 |
|
pout("physical device:%p:surface:%p:current extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.current_extent.width, surf_p.dev.phydev.surf_caps.core.current_extent.height); |
|
674 |
|
pout("physical device:%p:surface:%p:minimal extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_extent_min.width, surf_p.dev.phydev.surf_caps.core.img_extent_min.height); |
|
675 |
|
pout("physical device:%p:surface:%p:maximal extent=(width=%u, height=%u)\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_extent_max.width, surf_p.dev.phydev.surf_caps.core.img_extent_max.height); |
|
676 |
|
pout("physical device:%p:surface:%p:img_array_layers_n_max=%u\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.img_array_layers_n_max); |
|
677 |
|
pout("physical device:%p:surface:%p:supported_transforms=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_transforms); |
|
678 |
|
pout("physical device:%p:surface:%p:current_transform=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.current_transform); |
|
679 |
|
pout("physical device:%p:surface:%p:supported_composite_alpha=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_composite_alpha); |
|
680 |
|
pout("physical device:%p:surface:%p:supported_img_usage_flags=%#08x\n", surf_p.dev.phydev.vk, surf_p.vk, surf_p.dev.phydev.surf_caps.core.supported_img_usage_flags); |
672 |
681 |
} |
} |
673 |
682 |
STATIC void tmp_phydev_surf_present_modes_get(void) |
STATIC void tmp_phydev_surf_present_modes_get(void) |
674 |
683 |
{ |
{ |
|
... |
... |
STATIC void tmp_phydev_surf_present_modes_dump(void) |
698 |
707 |
u8 i; |
u8 i; |
699 |
708 |
|
|
700 |
709 |
i = 0; |
i = 0; |
701 |
|
POUTVK("physical device:%p:surface:%p:%u present modes\n", surf_p.dev.phydev.vk, surf_p.vk, tmp_present_modes_n_l); |
|
|
710 |
|
pout("physical device:%p:surface:%p:%u present modes\n", surf_p.dev.phydev.vk, surf_p.vk, tmp_present_modes_n_l); |
702 |
711 |
loop { |
loop { |
703 |
712 |
if (i == (u8)tmp_present_modes_n_l) |
if (i == (u8)tmp_present_modes_n_l) |
704 |
713 |
break; |
break; |
705 |
|
POUTVK("physical device:%p:surface:%p:present mode=%s\n", surf_p.dev.phydev.vk, surf_p.vk, present_mode_to_str(tmp_present_modes_l[i])); |
|
|
714 |
|
pout("physical device:%p:surface:%p:present mode=%s\n", surf_p.dev.phydev.vk, surf_p.vk, present_mode_to_str(tmp_present_modes_l[i])); |
706 |
715 |
++i; |
++i; |
707 |
716 |
} |
} |
708 |
717 |
} |
} |
|
... |
... |
STATIC void dev_create(void) |
763 |
772 |
info.enabled_ext_names = exts; |
info.enabled_ext_names = exts; |
764 |
773 |
vk_create_dev(&info); |
vk_create_dev(&info); |
765 |
774 |
IF_FATALVK("%d:physical device:%p:unable to create a vulkan device\n", r, surf_p.dev.phydev.vk); |
IF_FATALVK("%d:physical device:%p:unable to create a vulkan device\n", r, surf_p.dev.phydev.vk); |
766 |
|
POUTVK("physical device:%p:vulkan device created with one proper queue:%p\n", surf_p.dev.phydev.vk, surf_p.dev.vk); |
|
|
775 |
|
pout("physical device:%p:vulkan device created with one proper queue:%p\n", surf_p.dev.phydev.vk, surf_p.dev.vk); |
767 |
776 |
} |
} |
768 |
777 |
STATIC void q_get(void) |
STATIC void q_get(void) |
769 |
778 |
{ |
{ |
770 |
|
POUTVK("device:%p:getting queue:family=%u queue=0\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam); |
|
|
779 |
|
pout("device:%p:getting queue:family=%u queue=0\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam); |
771 |
780 |
vk_get_dev_q(); |
vk_get_dev_q(); |
772 |
|
POUTVK("device:%p:got queue:%p\n", surf_p.dev.vk, surf_p.dev.q); |
|
|
781 |
|
pout("device:%p:got queue:%p\n", surf_p.dev.vk, surf_p.dev.q); |
773 |
782 |
} |
} |
774 |
783 |
STATIC void cp_create(void) |
STATIC void cp_create(void) |
775 |
784 |
{ |
{ |
|
... |
... |
STATIC void cp_create(void) |
782 |
791 |
info.q_fam = surf_p.dev.phydev.q_fam; |
info.q_fam = surf_p.dev.phydev.q_fam; |
783 |
792 |
vk_create_cp(&info); |
vk_create_cp(&info); |
784 |
793 |
IF_FATALVK("%d:unable create the commmand pool\n", r); |
IF_FATALVK("%d:unable create the commmand pool\n", r); |
785 |
|
POUTVK("device:%p:queue family:%u:created command pool %p\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam, surf_p.dev.cp); |
|
|
794 |
|
pout("device:%p:queue family:%u:created command pool %p\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam, surf_p.dev.cp); |
786 |
795 |
} |
} |
787 |
796 |
STATIC void dev_init(void) |
STATIC void dev_init(void) |
788 |
797 |
{ |
{ |
|
... |
... |
STATIC void surf_create(xcb_connection_t *c, u32 win_id) |
806 |
815 |
vk_xcb_info.win = win_id; |
vk_xcb_info.win = win_id; |
807 |
816 |
vk_create_xcb_surf(&vk_xcb_info); |
vk_create_xcb_surf(&vk_xcb_info); |
808 |
817 |
IF_FATALVK("%d:xcb:%p:window id:%#x:unable to create a vulkan surface from this x11 window\n", r, c, win_id); |
IF_FATALVK("%d:xcb:%p:window id:%#x:unable to create a vulkan surface from this x11 window\n", r, c, win_id); |
809 |
|
POUTVK("xcb:%p:window id:%#x:created vk_surface=%p\n", c, win_id, surf_p.vk); |
|
|
818 |
|
pout("xcb:%p:window id:%#x:created vk_surface=%p\n", c, win_id, surf_p.vk); |
810 |
819 |
} |
} |
811 |
820 |
STATIC void swpchn_init_once(void) |
STATIC void swpchn_init_once(void) |
812 |
821 |
{ |
{ |
|
... |
... |
STATIC void sems_create(void) |
876 |
885 |
info.type = vk_struct_type_sem_create_info; |
info.type = vk_struct_type_sem_create_info; |
877 |
886 |
vk_create_sem(&info, &surf_p.dev.sems[sem]); |
vk_create_sem(&info, &surf_p.dev.sems[sem]); |
878 |
887 |
IF_FATALVK("%d:device:%p:unable to create a semaphore %u for the synchronization of the swapchain\n", r, surf_p.dev.vk, sem); |
IF_FATALVK("%d:device:%p:unable to create a semaphore %u for the synchronization of the swapchain\n", r, surf_p.dev.vk, sem); |
879 |
|
POUTVK("device:%p:semaphore %u for the synchronization of the swapchain created %p\n", surf_p.dev.vk, sem, surf_p.dev.sems[sem]); |
|
|
888 |
|
pout("device:%p:semaphore %u for the synchronization of the swapchain created %p\n", surf_p.dev.vk, sem, surf_p.dev.sems[sem]); |
880 |
889 |
++sem; |
++sem; |
881 |
890 |
} |
} |
882 |
891 |
} |
} |
|
... |
... |
STATIC void swpchn_imgs_cbs_init_once(void) |
892 |
901 |
alloc_info.cbs_n = swpchn_imgs_n_max; |
alloc_info.cbs_n = swpchn_imgs_n_max; |
893 |
902 |
vk_alloc_cbs(&alloc_info); |
vk_alloc_cbs(&alloc_info); |
894 |
903 |
IF_FATALVK("%d:device:%p:unable to allocate command buffers for our swapchain images from %p command pool\n", r, surf_p.dev.vk, surf_p.dev.cp); |
IF_FATALVK("%d:device:%p:unable to allocate command buffers for our swapchain images from %p command pool\n", r, surf_p.dev.vk, surf_p.dev.cp); |
895 |
|
POUTVK("device:%p:allocated %u command buffers for our swapchain images from %p command pool\n", surf_p.dev.vk, surf_p.dev.swpchn.imgs_n, surf_p.dev.cp); |
|
|
904 |
|
pout("device:%p:allocated %u command buffers for our swapchain images from %p command pool\n", surf_p.dev.vk, surf_p.dev.swpchn.imgs_n, surf_p.dev.cp); |
896 |
905 |
} |
} |
File npv/xcb/local/code.frag.c changed (mode: 100644) (index 600e27e..1695161) |
|
1 |
|
STATIC void npv_xcb_fatal(u8 *fmt, ...) |
|
2 |
|
{ |
|
3 |
|
va_list ap; |
|
4 |
|
|
|
5 |
|
npv_perr("xcb:"); |
|
6 |
|
va_start(ap, fmt); |
|
7 |
|
npv_vfatal(fmt, ap); |
|
8 |
|
va_end(ap); /* unreachable */ |
|
9 |
|
} |
|
10 |
|
STATIC void npv_xcb_warning(u8 *fmt, ...) |
|
11 |
|
{ |
|
12 |
|
va_list ap; |
|
13 |
|
|
|
14 |
|
npv_perr("xcb:"); |
|
15 |
|
va_start(ap, fmt); |
|
16 |
|
npv_vwarning(fmt, ap); |
|
17 |
|
va_end(ap); |
|
18 |
|
} |
|
19 |
|
STATIC void npv_xcb_pout(u8 *fmt, ...) |
|
20 |
|
{ |
|
21 |
|
va_list ap; |
|
22 |
|
|
|
23 |
|
npv_pout("xcb:"); |
|
24 |
|
va_start(ap, fmt); |
|
25 |
|
npv_vpout(fmt, ap); |
|
26 |
|
va_end(ap); |
|
27 |
|
} |
1 |
28 |
STATIC void npv_xcb_libs_load(void) |
STATIC void npv_xcb_libs_load(void) |
2 |
29 |
{ |
{ |
3 |
30 |
npv_xcb_lib_l = dlopen("libxcb.so.1", RTLD_LAZY); |
npv_xcb_lib_l = dlopen("libxcb.so.1", RTLD_LAZY); |
4 |
31 |
if (npv_xcb_lib_l == 0) |
if (npv_xcb_lib_l == 0) |
5 |
|
FATALX("%s:unable to load the xcb dynamic shared library\n", dlerror()); |
|
|
32 |
|
npv_xcb_fatal("%s:unable to load the xcb dynamic shared library\n", dlerror()); |
6 |
33 |
npv_xcb_xfixes_lib_l = dlopen("libxcb-xfixes.so.0", RTLD_LAZY); |
npv_xcb_xfixes_lib_l = dlopen("libxcb-xfixes.so.0", RTLD_LAZY); |
7 |
34 |
if (npv_xcb_xfixes_lib_l == 0) |
if (npv_xcb_xfixes_lib_l == 0) |
8 |
|
FATALX("%s:unable to load the xcb xfixes dynamic shared library\n", dlerror()); |
|
|
35 |
|
npv_xcb_fatal("%s:unable to load the xcb xfixes dynamic shared library\n", dlerror()); |
9 |
36 |
} |
} |
10 |
37 |
#define XCB_DLSYM(x) \ |
#define XCB_DLSYM(x) \ |
11 |
38 |
npv_dl_##x = dlsym(npv_xcb_lib_l, #x); \ |
npv_dl_##x = dlsym(npv_xcb_lib_l, #x); \ |
12 |
39 |
if (npv_dl_##x == 0) \ |
if (npv_dl_##x == 0) \ |
13 |
|
FATALX("%s:unable to find " #x "\n", dlerror()); |
|
|
40 |
|
npv_xcb_fatal("%s:unable to find " #x "\n", dlerror()); |
14 |
41 |
#define XCB_XFIXES_DLSYM(x) \ |
#define XCB_XFIXES_DLSYM(x) \ |
15 |
42 |
npv_dl_##x = dlsym(npv_xcb_xfixes_lib_l, #x); \ |
npv_dl_##x = dlsym(npv_xcb_xfixes_lib_l, #x); \ |
16 |
43 |
if (npv_dl_##x == 0) \ |
if (npv_dl_##x == 0) \ |
17 |
|
FATALX("%s:unable to find " #x "\n", dlerror()); |
|
|
44 |
|
npv_xcb_fatal("%s:unable to find " #x "\n", dlerror()); |
18 |
45 |
STATIC void npv_xcb_syms(void) |
STATIC void npv_xcb_syms(void) |
19 |
46 |
{ |
{ |
20 |
47 |
XCB_DLSYM(xcb_connect); |
XCB_DLSYM(xcb_connect); |
|
... |
... |
STATIC void npv_xcb_win_create(void) |
53 |
80 |
u32 value_list[2]; |
u32 value_list[2]; |
54 |
81 |
|
|
55 |
82 |
npv_xcb_p.win_id = npv_dl_xcb_generate_id(npv_xcb_p.c); |
npv_xcb_p.win_id = npv_dl_xcb_generate_id(npv_xcb_p.c); |
56 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:window id=%#x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
|
|
83 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:window id=%#x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
57 |
84 |
|
|
58 |
85 |
value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
59 |
86 |
value_list[0] = npv_xcb_p.scr->black_pixel; |
value_list[0] = npv_xcb_p.scr->black_pixel; |
|
... |
... |
STATIC void npv_xcb_win_map(void) |
78 |
105 |
xcb_generic_error_t *e; |
xcb_generic_error_t *e; |
79 |
106 |
|
|
80 |
107 |
cookie = npv_dl_xcb_map_window_checked(npv_xcb_p.c, npv_xcb_p.win_id); |
cookie = npv_dl_xcb_map_window_checked(npv_xcb_p.c, npv_xcb_p.win_id); |
81 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:map window request cookie=%#x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id, cookie); |
|
|
108 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:map window request cookie=%#x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id, cookie); |
82 |
109 |
|
|
83 |
110 |
e = npv_dl_xcb_request_check(npv_xcb_p.c, cookie); |
e = npv_dl_xcb_request_check(npv_xcb_p.c, cookie); |
84 |
111 |
if (e != 0) |
if (e != 0) |
85 |
|
FATALX("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:unable to map window\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
|
86 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:window mapped\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
|
|
112 |
|
npv_xcb_fatal("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:unable to map window\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
|
113 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:window mapped\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); |
87 |
114 |
} |
} |
88 |
115 |
/* |
/* |
89 |
116 |
* a disp is n scrs and 1 [set of] keyboard[s] and 1 [set of] mouse[s] |
* a disp is n scrs and 1 [set of] keyboard[s] and 1 [set of] mouse[s] |
|
... |
... |
STATIC void npv_xcb_connect(void) |
97 |
124 |
|
|
98 |
125 |
npv_xcb_p.disp_env = getenv("DISPLAY"); |
npv_xcb_p.disp_env = getenv("DISPLAY"); |
99 |
126 |
if (npv_xcb_p.disp_env == 0 || npv_xcb_p.disp_env[0] == 0) |
if (npv_xcb_p.disp_env == 0 || npv_xcb_p.disp_env[0] == 0) |
100 |
|
FATALX("no x11 DISPLAY environment variable, exiting\n"); |
|
|
127 |
|
npv_xcb_fatal("no x11 DISPLAY environment variable, exiting\n"); |
101 |
128 |
|
|
102 |
129 |
npv_xcb_p.scr_idx = 0; |
npv_xcb_p.scr_idx = 0; |
103 |
130 |
/* should be 0 though */ |
/* should be 0 though */ |
104 |
131 |
npv_xcb_p.c = npv_dl_xcb_connect(0, &npv_xcb_p.scr_idx); |
npv_xcb_p.c = npv_dl_xcb_connect(0, &npv_xcb_p.scr_idx); |
105 |
132 |
r = npv_dl_xcb_connection_has_error(npv_xcb_p.c); |
r = npv_dl_xcb_connection_has_error(npv_xcb_p.c); |
106 |
133 |
if (r > 0) |
if (r > 0) |
107 |
|
FATALX("%d:%s:error while connecting to the x11 server\n", r, npv_xcb_p.disp_env); |
|
108 |
|
POUTX("'%s':connection=%p, default screen index is %d (should be 0)\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx); |
|
|
134 |
|
npv_xcb_fatal("%d:%s:error while connecting to the x11 server\n", r, npv_xcb_p.disp_env); |
|
135 |
|
npv_xcb_pout("'%s':connection=%p, default screen index is %d (should be 0)\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx); |
109 |
136 |
|
|
110 |
137 |
npv_xcb_p.fd = npv_dl_xcb_get_file_descriptor(npv_xcb_p.c); |
npv_xcb_p.fd = npv_dl_xcb_get_file_descriptor(npv_xcb_p.c); |
111 |
138 |
if (npv_xcb_p.fd == -1) |
if (npv_xcb_p.fd == -1) |
112 |
|
FATALX("'%s':unable to get the connection file descriptor for epoll\n", npv_xcb_p.disp_env); |
|
113 |
|
POUTX("'%s':connection:%p:file descriptor %d\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.fd); |
|
|
139 |
|
npv_xcb_fatal("'%s':unable to get the connection file descriptor for epoll\n", npv_xcb_p.disp_env); |
|
140 |
|
npv_xcb_pout("'%s':connection:%p:file descriptor %d\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.fd); |
114 |
141 |
} |
} |
115 |
142 |
STATIC void npv_xcb_scr_get(void) |
STATIC void npv_xcb_scr_get(void) |
116 |
143 |
{ |
{ |
|
... |
... |
STATIC void npv_xcb_scr_get(void) |
121 |
148 |
npv_xcb_p.setup = npv_dl_xcb_get_setup(npv_xcb_p.c); |
npv_xcb_p.setup = npv_dl_xcb_get_setup(npv_xcb_p.c); |
122 |
149 |
|
|
123 |
150 |
scrs_n = npv_dl_xcb_setup_roots_length(npv_xcb_p.setup); |
scrs_n = npv_dl_xcb_setup_roots_length(npv_xcb_p.setup); |
124 |
|
POUTX("'%s':connection:%p:has %d screens (should be 1)\n", npv_xcb_p.disp_env, npv_xcb_p.c, scrs_n); |
|
|
151 |
|
npv_xcb_pout("'%s':connection:%p:has %d screens (should be 1)\n", npv_xcb_p.disp_env, npv_xcb_p.c, scrs_n); |
125 |
152 |
|
|
126 |
153 |
iter = npv_dl_xcb_setup_roots_iterator(npv_xcb_p.setup); |
iter = npv_dl_xcb_setup_roots_iterator(npv_xcb_p.setup); |
127 |
154 |
i = 0; |
i = 0; |
|
... |
... |
STATIC void npv_xcb_scr_get(void) |
136 |
163 |
} |
} |
137 |
164 |
npv_dl_xcb_screen_next(&iter); |
npv_dl_xcb_screen_next(&iter); |
138 |
165 |
} |
} |
139 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:width=%d pixels\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->width_in_pixels); |
|
140 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:height=%d pixels\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->height_in_pixels); |
|
141 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:white pixel=0x%08x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->white_pixel); |
|
142 |
|
POUTX("'%s':connection:%p:screen:%d:root window id:%#x:black pixel=0x%08x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->black_pixel); |
|
|
166 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:width=%d pixels\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->width_in_pixels); |
|
167 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:height=%d pixels\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->height_in_pixels); |
|
168 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:white pixel=0x%08x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->white_pixel); |
|
169 |
|
npv_xcb_pout("'%s':connection:%p:screen:%d:root window id:%#x:black pixel=0x%08x\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.scr->black_pixel); |
143 |
170 |
} |
} |
144 |
171 |
#define MIN_SZ_BIT (1 << 4) |
#define MIN_SZ_BIT (1 << 4) |
145 |
172 |
#define MAX_SZ_BIT (1 << 5) |
#define MAX_SZ_BIT (1 << 5) |
|
... |
... |
STATIC void npv_xcb_evt_key_release(xcb_generic_event_t *evt) |
229 |
256 |
if (b == ARRAY_N(npv_x11_binds)) |
if (b == ARRAY_N(npv_x11_binds)) |
230 |
257 |
break; |
break; |
231 |
258 |
if (key->detail == npv_x11_binds[b].keycode) { |
if (key->detail == npv_x11_binds[b].keycode) { |
232 |
|
POUTX("'%s':connection:%p:event:key release:keycode:%#02x:running command for bind \"%s\"\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail, npv_x11_binds[b].name); |
|
|
259 |
|
npv_xcb_pout("'%s':connection:%p:event:key release:keycode:%#02x:running command for bind \"%s\"\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail, npv_x11_binds[b].name); |
233 |
260 |
npv_x11_binds[b].cmd(); |
npv_x11_binds[b].cmd(); |
234 |
261 |
return; |
return; |
235 |
262 |
} |
} |
236 |
263 |
++b; |
++b; |
237 |
264 |
} |
} |
238 |
|
POUTX("'%s':connection:%p:event:key release:keycode:%#02x\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail); |
|
|
265 |
|
npv_xcb_pout("'%s':connection:%p:event:key release:keycode:%#02x\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail); |
239 |
266 |
} |
} |
240 |
267 |
STATIC void npv_xcb_evt_leave_win(xcb_generic_event_t *evt) |
STATIC void npv_xcb_evt_leave_win(xcb_generic_event_t *evt) |
241 |
268 |
{ |
{ |
|
... |
... |
STATIC void npv_xcb_mouse_visibility_timer_start(void) |
256 |
283 |
t.it_value.tv_sec = npv_xcb_mouse_visibility_interval_s; |
t.it_value.tv_sec = npv_xcb_mouse_visibility_interval_s; |
257 |
284 |
r = timerfd_settime(npv_xcb_p.mouse_visibility_timer_fd, 0, &t, 0); |
r = timerfd_settime(npv_xcb_p.mouse_visibility_timer_fd, 0, &t, 0); |
258 |
285 |
if (r == -1) |
if (r == -1) |
259 |
|
FATALX("unable to arm the mouse visibility timer to %u seconds\n", npv_xcb_mouse_visibility_interval_s); |
|
|
286 |
|
npv_xcb_fatal("unable to arm the mouse visibility timer to %u seconds\n", npv_xcb_mouse_visibility_interval_s); |
260 |
287 |
} |
} |
261 |
288 |
STATIC void npv_xcb_evt_enter_win(xcb_generic_event_t *evt) |
STATIC void npv_xcb_evt_enter_win(xcb_generic_event_t *evt) |
262 |
289 |
{ |
{ |
|
... |
... |
STATIC void npv_xcb_screensaver_heartbeat_timer_init_once(void) |
348 |
375 |
npv_xcb_p.screensaver_heartbeat_timer_fd = timerfd_create( |
npv_xcb_p.screensaver_heartbeat_timer_fd = timerfd_create( |
349 |
376 |
CLOCK_MONOTONIC, TFD_NONBLOCK); |
CLOCK_MONOTONIC, TFD_NONBLOCK); |
350 |
377 |
if (npv_xcb_p.screensaver_heartbeat_timer_fd == -1) |
if (npv_xcb_p.screensaver_heartbeat_timer_fd == -1) |
351 |
|
FATALX("unable to get a timer file descriptor for the screensaver heartbeat:%s\n", strerror(errno)); |
|
|
378 |
|
npv_xcb_fatal("unable to get a timer file descriptor for the screensaver heartbeat:%s\n", strerror(errno)); |
352 |
379 |
} |
} |
353 |
380 |
STATIC void npv_xcb_mouse_visibilty_init_once(void) |
STATIC void npv_xcb_mouse_visibilty_init_once(void) |
354 |
381 |
{ |
{ |
|
... |
... |
STATIC void npv_xcb_mouse_visibilty_init_once(void) |
358 |
385 |
xfixes = npv_dl_xcb_get_extension_data(npv_xcb_p.c, |
xfixes = npv_dl_xcb_get_extension_data(npv_xcb_p.c, |
359 |
386 |
npv_dl_xcb_xfixes_id); |
npv_dl_xcb_xfixes_id); |
360 |
387 |
if (xfixes->response_type != 1 || xfixes->present == 0) |
if (xfixes->response_type != 1 || xfixes->present == 0) |
361 |
|
WARNINGX("the server is missing xfixes extension\n"); |
|
|
388 |
|
npv_xcb_warning("the server is missing xfixes extension\n"); |
362 |
389 |
/* the hice/show cursor is supported from version 4 */ |
/* the hice/show cursor is supported from version 4 */ |
363 |
390 |
npv_dl_xcb_xfixes_query_version(npv_xcb_p.c, 4, 0); |
npv_dl_xcb_xfixes_query_version(npv_xcb_p.c, 4, 0); |
364 |
391 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
|
... |
... |
STATIC void npv_xcb_mouse_visibilty_init_once(void) |
370 |
397 |
npv_xcb_p.mouse_visibility_timer_fd = timerfd_create(CLOCK_MONOTONIC, |
npv_xcb_p.mouse_visibility_timer_fd = timerfd_create(CLOCK_MONOTONIC, |
371 |
398 |
TFD_NONBLOCK); |
TFD_NONBLOCK); |
372 |
399 |
if (npv_xcb_p.mouse_visibility_timer_fd == -1) |
if (npv_xcb_p.mouse_visibility_timer_fd == -1) |
373 |
|
FATALX("unable to get a timer file descriptor for the mouse visibility management:%s\n", strerror(errno)); |
|
|
400 |
|
npv_xcb_fatal("unable to get a timer file descriptor for the mouse visibility management:%s\n", strerror(errno)); |
374 |
401 |
} |
} |
375 |
402 |
#define NET_WM_STATE "_NET_WM_STATE" |
#define NET_WM_STATE "_NET_WM_STATE" |
376 |
403 |
#define NET_WM_STATE_FULLSCREEN "_NET_WM_STATE_FULLSCREEN" |
#define NET_WM_STATE_FULLSCREEN "_NET_WM_STATE_FULLSCREEN" |
|
... |
... |
STATIC void npv_xcb_fullscreen_action(u32 action) |
395 |
422 |
reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c, cookie_net_wm_state, |
reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c, cookie_net_wm_state, |
396 |
423 |
&err); |
&err); |
397 |
424 |
if (reply == 0) { |
if (reply == 0) { |
398 |
|
WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE atom:%d\n", err->error_code); |
|
|
425 |
|
npv_xcb_warning("unable to set fullscreen:unable to get the _NET_WM_STATE atom:%d\n", err->error_code); |
399 |
426 |
free(err); |
free(err); |
400 |
427 |
return; |
return; |
401 |
428 |
} |
} |
|
... |
... |
STATIC void npv_xcb_fullscreen_action(u32 action) |
405 |
432 |
reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c, |
reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c, |
406 |
433 |
cookie_net_wm_state_fullscreen, &err); |
cookie_net_wm_state_fullscreen, &err); |
407 |
434 |
if (reply == 0) { |
if (reply == 0) { |
408 |
|
WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE_FULLSCREEN atom:%d\n", err->error_code); |
|
|
435 |
|
npv_xcb_warning("unable to set fullscreen:unable to get the _NET_WM_STATE_FULLSCREEN atom:%d\n", err->error_code); |
409 |
436 |
free(err); |
free(err); |
410 |
437 |
return; |
return; |
411 |
438 |
} |
} |