sylware / nyanmp (public) (License: AGPLv3) (since 2020-02-12) (hash sha1)
intended to become a collection of media players for gnu/linux based on ffmpeg, alsa, vulkan, x11, wayland, etc.
List of commits:
Subject Hash Author Date (UTC)
npv:namespace cleanup, don't need that many short identifiers 86d95bbd53a6c9264a44ae98038db9bf4d195e29 Sylvain BERTRAND 2020-06-06 22:44:11
npv:aspect ratio handling 946f160f000a6def790ea64cde5fd31a284f2bd7 Sylvain BERTRAND 2020-06-05 22:21:40
npv:vulkan refactoring to prepare resize handling e6ce6ebf7540d3e7ac2587400e3c0b5289369d19 Sylvain BERTRAND 2020-06-03 17:48:39
npv: x11 wm sugar, fullscreen 7801421eea4849e855916665ede8e9b325520118 Sylvain BERTRAND 2020-06-02 13:39:16
npa: fix initial scheduling bd228fb06dda312888dc6425ebc08dfb2c1d06ae Sylvain BERTRAND 2020-06-02 10:17:42
npv: x11 fixes and more sugar 043ef16cabacaddada9c322fa39871048ef95aae Sylvain BERTRAND 2020-06-01 22:18:22
npv:x11 sugar acd88647f348333fee796a6062963e9cea847d2f Sylvain BERTRAND 2020-05-30 21:26:47
npv: video timer names 8ab20e0c91538f9f84c09c78ee2d5242b5b74607 Sylvain BERTRAND 2020-05-30 17:14:56
npv:less worse pause support, some cleanup ded1666c8970d67bba8f5d0d2ee25230403bc9c3 Sylvain BERTRAND 2020-05-30 16:26:21
npv:fix dynamic loading of xcb lib 0235137068f40277460c4b6ea340bc5674d8dc7d Sylvain BERTRAND 2020-05-29 21:21:01
npv:x11/xcb screensaver heartbeat bd293398599beae694bd3f862c374489067a9f53 Sylvain BERTRAND 2020-05-29 21:06:00
npa: don't slow down too much the audio thread 1b8f1e2dd1d5272cd04a8fa711f26cdc3b6e1049 Sylvain BERTRAND 2020-05-29 03:00:23
npv/npa: lockless madness and much more 368cb50098ac824cc5cb603c3e1539adfeda7e1d Sylvain BERTRAND 2020-05-29 02:20:19
npv:restore pause/seeking, add tmp info command cf4da499db3123561aacd8732cd1eb97b9146e55 Sylvain BERTRAND 2020-05-27 17:31:56
npv:bugs, finer-grained locking, pthread_cond, etc 8bd06c28483adc9986b8b51612e609115948943d Sylvain BERTRAND 2020-05-26 23:59:16
npv: fix obvious multithread bug db4f3801c2185b8da1d9fb3f4b3da3d2ab92ea13 Sylvain BERTRAND 2020-05-24 21:42:08
remove old commented code d3701c5734aceda5c46cd5f60281cc524c55e4a3 Sylvain BERTRAND 2020-05-24 19:29:04
npv: video: handle latency spikes on main thread f629068cb27b47530058f81fc2b065b0786b4afa Sylvain BERTRAND 2020-05-24 18:11:07
npv: media pipeline 30efa7c8f2574c676d9d41b8bf5678d5725b8721 Sylvain BERTRAND 2020-05-24 17:40:23
alsa-lib warning 54b6dc9b912bb9509ba35405f15a623632adf784 Sylvain BERTRAND 2020-05-19 14:32:04
Commit 86d95bbd53a6c9264a44ae98038db9bf4d195e29 - npv:namespace cleanup, don't need that many short identifiers
Author: Sylvain BERTRAND
Author date (UTC): 2020-06-06 22:44
Committer name: Sylvain BERTRAND
Committer date (UTC): 2020-06-06 22:44
Parent(s): 946f160f000a6def790ea64cde5fd31a284f2bd7
Signer:
Signing key:
Signing status: N
Tree: 12098867f246d1ccac12e3accd85cbdd6124319f
File Lines added Lines deleted
npv/README 6 2
npv/audio/filt/local/code.frag.c 6 6
npv/audio/filt/namespace/main.c 17 15
npv/audio/filt/namespace/public.h 6 6
npv/audio/filt/public.h 9 9
npv/audio/filt/public/code.frag.c 21 21
npv/audio/filt/public/state.frag.h 1 1
npv/audio/local/code.frag.c 62 56
npv/audio/local/state.frag.c 5 5
npv/audio/namespace/main.c 35 33
npv/audio/namespace/public.h 26 26
npv/audio/public.h 15 15
npv/audio/public/code.frag.c 23 23
npv/audio/public/state.frag.h 10 10
npv/clk/local/state.frag.c 3 3
npv/clk/public.h 7 7
npv/clk/public/code.frag.c 47 46
npv/config.h 24 24
npv/fmt/local/code.frag.c 17 18
npv/fmt/local/state.frag.c 2 2
npv/fmt/main.c 4 0
npv/fmt/namespace/main.c 6 4
npv/fmt/namespace/public.h 12 12
npv/fmt/public.h 7 7
npv/fmt/public/code.frag.c 39 39
npv/fmt/public/state.frag.h 1 1
npv/local/code.frag.c 172 176
npv/local/state.frag.c 1 1
npv/main.c 2 0
npv/namespace/main.c 37 1
npv/nyanvk/syms_global.h 18 18
npv/pipeline/local/code.frag.c 42 42
npv/pipeline/local/state.frag.c 1 1
npv/pipeline/namespace/main.c 16 12
npv/pipeline/namespace/public.h 10 10
npv/pipeline/public.h 8 8
npv/pipeline/public/code.frag.c 8 8
npv/pipeline/public/state.frag.h 1 1
npv/pkt_q/local/code.frag.c 1 1
npv/pkt_q/namespace/main.c 1 1
npv/pkt_q/namespace/public.h 8 8
npv/pkt_q/public.h 7 7
npv/pkt_q/public/code.frag.c 7 7
npv/public/state.frag.h 2 2
npv/thdsws/local/code.frag.c 5 7
npv/thdsws/main.c 2 0
npv/thdsws/namespace/main.c 7 3
npv/thdsws/namespace/public.h 13 0
npv/thdsws/public.h 6 4
npv/thdsws/public/code.frag.c 4 4
npv/video/local/code.frag.c 29 29
npv/video/local/state.frag.c 6 9
npv/video/main.c 1 1
npv/video/namespace/main.c 36 28
npv/video/namespace/public.h 22 20
npv/video/public.h 14 14
npv/video/public/code.frag.c 36 36
npv/video/public/state.frag.h 9 10
npv/vk/api_usage.h 42 38
npv/vk/local/code.frag.c 59 103
npv/vk/local/state.frag.c 6 12
npv/vk/main.c 1 1
npv/vk/namespace/main.c 107 9
npv/vk/public.h 4 4
npv/vk/public/code.frag.c 3 3
npv/vk/public/state.frag.h 1 1
npv/xcb/local/code.frag.c 59 57
npv/xcb/local/state.frag.c 35 34
npv/xcb/main.c 6 2
npv/xcb/public.h 7 6
npv/xcb/public/code.frag.c 15 14
npv/xcb/public/state.frag.h 1 1
File npv/README changed (mode: 100644) (index a9d4f93..aa5beda)
... ... BUILDING:
8 8 output file to your ffmpeg libs, your alsa lib (we should make this output file to your ffmpeg libs, your alsa lib (we should make this
9 9 dynamically loaded). the vulkan loader lib and x11 xcb libs will be dynamically loaded). the vulkan loader lib and x11 xcb libs will be
10 10 dynamically loaded. dynamically loaded.
11 you have to define the preprocessor macro STATIC as empty or "static".
12 you will probably have to define the _GNU_SOURCE macro on most
13 GNU/Linux systems.
11 14 HACKING: HACKING:
12 15 *.c and *.h files, except the fragments *.frag.c *.frag.h, must *.c and *.h files, except the fragments *.frag.c *.frag.h, must
13 16 "successfully" individually compile (cc -c modulo a few warnings). "successfully" individually compile (cc -c modulo a few warnings).
 
... ... HACKING:
42 45 namespace and know where the things are actually going) namespace and know where the things are actually going)
43 46 - to lookup for the real symbols, use the output from the preprocessor, - to lookup for the real symbols, use the output from the preprocessor,
44 47 or have a quick look at the header files or have a quick look at the header files
48 - to check your namespaces: define an empty STATIC macro and look at
49 the symbols in the output of the compiler, for instance using the
50 "objdump" or "readelf" tools.
45 51 - we are using our custom vulkan headers. - we are using our custom vulkan headers.
46 52 - av*_ (avfilter_, avformat, etc) prefixes are reserved for ffmpeg libs - av*_ (avfilter_, avformat, etc) prefixes are reserved for ffmpeg libs
47 53 (and the av_* prefix:we don't see it after tidying, but it is still (and the av_* prefix:we don't see it after tidying, but it is still
 
... ... HACKING:
50 56 - snd_* prefix is reserved for the alsa lib - snd_* prefix is reserved for the alsa lib
51 57 - vk_* prefix is reserved for the vulkan api - vk_* prefix is reserved for the vulkan api
52 58 - xcb_* prefix is reserved for x11 xcb client lib - xcb_* prefix is reserved for x11 xcb client lib
53 - dl_* prefix is reserved for dynamically resolved symbols
54 - cmd_* prefix is reserved for player commands
55 59 - all the prefixes from the operating system facilities: epoll_*, - all the prefixes from the operating system facilities: epoll_*,
56 60 pthread_*, etc. pthread_*, etc.
57 61 - _t suffix is reserved for non primitive types (namespace noise and - _t suffix is reserved for non primitive types (namespace noise and
File npv/audio/filt/local/code.frag.c changed (mode: 100644) (index 78a1b4b..6c167bb)
1 static void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
1 STATIC void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
2 2 uint64_t chans_layout, bool print_info) uint64_t chans_layout, bool print_info)
3 3 { {
4 4 int r; int r;
 
... ... static void abufsrc_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
37 37 if (r < 0) if (r < 0)
38 38 FATALAF("audio buffer source context:unable to initialize\n"); FATALAF("audio buffer source context:unable to initialize\n");
39 39 } }
40 static void vol_cfg(bool muted, double vol_cfg)
40 STATIC void vol_cfg(bool muted, double vol_cfg)
41 41 { {
42 42 double vol; double vol;
43 43 u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */ u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */
 
... ... static void vol_cfg(bool muted, double vol_cfg)
63 63 if (r < 0) if (r < 0)
64 64 FATALAF("volume buffer context:unable to initialize\n"); FATALAF("volume buffer context:unable to initialize\n");
65 65 } }
66 static void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
66 STATIC void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
67 67 uint64_t chans_layout, bool print_info) uint64_t chans_layout, bool print_info)
68 68 { {
69 69 int r; int r;
 
... ... static void afmt_cfg(enum avutil_audio_fr_fmt_t fmt, int rate, int chans_n,
97 97 if (r < 0) if (r < 0)
98 98 FATALAF("audio format context:unable to initialize\n"); FATALAF("audio format context:unable to initialize\n");
99 99 } }
100 static void abufsink_cfg(void)
100 STATIC void abufsink_cfg(void)
101 101 { {
102 102 int r; int r;
103 103
 
... ... static void abufsink_cfg(void)
112 112 if (r < 0) if (r < 0)
113 113 FATALAF("audio buffer sink context:unable to initialize\n"); FATALAF("audio buffer sink context:unable to initialize\n");
114 114 } }
115 static void init_once_local(void)
115 STATIC void init_once_local(void)
116 116 { {
117 117 graph_l = 0; graph_l = 0;
118 118 abufsrc_ctx_l = 0; abufsrc_ctx_l = 0;
 
... ... static void init_once_local(void)
127 127 snprintf(double_zero_l10n_str_l, sizeof(double_zero_l10n_str_l), snprintf(double_zero_l10n_str_l, sizeof(double_zero_l10n_str_l),
128 128 "%f", 0.); "%f", 0.);
129 129 } }
130 static void init_once_public(void)
130 STATIC void init_once_public(void)
131 131 { {
132 132 filt_p.set = avutil_audio_set_ref_alloc(); filt_p.set = avutil_audio_set_ref_alloc();
133 133 if (filt_p.set == 0) if (filt_p.set == 0)
File npv/audio/filt/namespace/main.c changed (mode: 100644) (index 7c0aefa..d33df01)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define abufsink_cfg audio_filt_abufsink_cfg
3 #define abufsink_ctx_l audio_filt_abufsink_ctx_l
4 #define abufsink_l audio_filt_abufsink_l
5 #define abufsrc_cfg audio_filt_abufsrc_cfg
6 #define abufsrc_ctx_l audio_filt_abufsrc_ctx_l
7 #define abufsrc_l audio_filt_abufsrc_l
8 #define afmt_cfg audio_filt_afm_cfg
9 #define afmt_ctx_l audio_filt_afmt_ctx_l
10 #define afmt_l audio_filt_afmt_l
11 #define double_zero_l10n_str audio_filt_double_zero_l10n_str
12 #define graph_l audio_filt_graph_l
13 #define init_once_public audio_filt_init_once_public
14 #define vol_cfg audio_filt_vol_cfg
15 #define vol_ctx_l audio_filt_vol_ctx_l
16 #define vol_l audio_filt_vol_l
2 #define abufsink_cfg npv_audio_filt_abufsink_cfg
3 #define abufsink_ctx_l npv_audio_filt_abufsink_ctx_l
4 #define abufsink_l npv_audio_filt_abufsink_l
5 #define abufsrc_cfg npv_audio_filt_abufsrc_cfg
6 #define abufsrc_ctx_l npv_audio_filt_abufsrc_ctx_l
7 #define abufsrc_l npv_audio_filt_abufsrc_l
8 #define afmt_cfg npv_audio_filt_afm_cfg
9 #define afmt_ctx_l npv_audio_filt_afmt_ctx_l
10 #define afmt_l npv_audio_filt_afmt_l
11 #define double_zero_l10n_str_l npv_audio_filt_double_zero_l10n_str_l
12 #define graph_l npv_audio_filt_graph_l
13 #define init_once_local npv_audio_filt_init_once_local
14 #define init_once_public npv_audio_filt_init_once_public
15 #define vol_cfg npv_audio_filt_vol_cfg
16 #define vol_ctx_l npv_audio_filt_vol_ctx_l
17 #define vol_l npv_audio_filt_vol_l
17 18 /*============================================================================*/ /*============================================================================*/
18 19 #else #else
19 20 #undef abufsink_cfg #undef abufsink_cfg
 
27 28 #undef afmt_l #undef afmt_l
28 29 #undef double_zero_l10n_str_l #undef double_zero_l10n_str_l
29 30 #undef graph_l #undef graph_l
31 #undef init_once_local
30 32 #undef init_once_public #undef init_once_public
31 33 #undef vol_cfg #undef vol_cfg
32 34 #undef vol_ctx_l #undef vol_ctx_l
File npv/audio/filt/namespace/public.h changed (mode: 100644) (index f6d482b..7387274)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define cfg audio_filt_cfg
3 #define filt_flush audio_filt_flush
4 #define filt_p audio_filt_p
5 #define filt_push_dec_sets audio_filt_push_dec_sets
6 #define filt_set_try_get audio_filt_set_try_get
7 #define init_once audio_filt_init_once
2 #define cfg npv_audio_filt_cfg
3 #define filt_flush npv_audio_filt_flush
4 #define filt_p npv_audio_filt_p
5 #define filt_push_dec_sets npv_audio_filt_push_dec_sets
6 #define filt_set_try_get npv_audio_filt_set_try_get
7 #define init_once npv_audio_filt_init_once
8 8 /*============================================================================*/ /*============================================================================*/
9 9 #else #else
10 10 #undef cfg #undef cfg
File npv/audio/filt/public.h changed (mode: 100644) (index d9319ef..0191466)
18 18 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
19 19 #include "npv/audio/filt/public/state.frag.h" #include "npv/audio/filt/public/state.frag.h"
20 20 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
21 static void init_once(void);
22 static void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate,
21 STATIC void init_once(void);
22 STATIC void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate,
23 23 int src_chans_n, uint64_t src_chans_layout, int src_chans_n, uint64_t src_chans_layout,
24 24 bool muted, double vol, bool muted, double vol,
25 25 enum avutil_audio_fr_fmt_t dst_fmt, int dst_rate, enum avutil_audio_fr_fmt_t dst_fmt, int dst_rate,
26 26 int dst_chans_n, uint64_t dst_chans_layout, int dst_chans_n, uint64_t dst_chans_layout,
27 27 bool print_info); bool print_info);
28 static u8 filt_push_dec_sets(void);
29 static u8 filt_set_try_get(void);
30 static void filt_flush(void);
31 /* out of audio filt namespace to avoid collision with cmd_* prefix */
32 static void audio_filt_cmd_mute(void);
33 static void audio_filt_cmd_vol_up(void);
34 static void audio_filt_cmd_vol_down(void);
28 STATIC u8 filt_push_dec_sets(void);
29 STATIC u8 filt_set_try_get(void);
30 STATIC void filt_flush(void);
31 /* out of audio filt namespace to avoid collision with npv_cmd_* prefix */
32 STATIC void npv_audio_filt_cmd_mute(void);
33 STATIC void npv_audio_filt_cmd_vol_up(void);
34 STATIC void npv_audio_filt_cmd_vol_down(void);
35 35 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
36 36 #define CLEANUP #define CLEANUP
37 37 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/audio/filt/public/code.frag.c changed (mode: 100644) (index 92abc98..0fbb8b1)
2 2 #define PUSHED_ONE_SET 1 #define PUSHED_ONE_SET 1
3 3 #define NO_DEC_SET 2 #define NO_DEC_SET 2
4 4 #define FILT_SWITCHED_TO_DRAINING 3 #define FILT_SWITCHED_TO_DRAINING 3
5 static u8 filt_push_dec_sets(void)
5 STATIC u8 filt_push_dec_sets(void)
6 6 { {
7 7 u8 r8; u8 r8;
8 8 int ri; int ri;
9 9 avutil_audio_set_ref_t **a; avutil_audio_set_ref_t **a;
10 10
11 audio_dec_sets_lock();
12 if (audio_dec_sets_p.n == 0) {
13 if (audio_dec_sets_p.eof_receive) {
11 npv_audio_dec_sets_lock();
12 if (npv_audio_dec_sets_p.n == 0) {
13 if (npv_audio_dec_sets_p.eof_receive) {
14 14 ri = avfilter_bufsrc_add_audio_set_flags(abufsrc_ctx_l, ri = avfilter_bufsrc_add_audio_set_flags(abufsrc_ctx_l,
15 15 0, AVFILTER_BUFSRC_FLAG_PUSH 0, AVFILTER_BUFSRC_FLAG_PUSH
16 16 | AVFILTER_BUFSRC_FLAG_KEEP_REF); | AVFILTER_BUFSRC_FLAG_KEEP_REF);
 
... ... static u8 filt_push_dec_sets(void)
23 23 r8 = NO_DEC_SET; r8 = NO_DEC_SET;
24 24 goto unlock; goto unlock;
25 25 } }
26 a = audio_dec_sets_p.a;
26 a = npv_audio_dec_sets_p.a;
27 27 /* the dec_sets_p bufs will be unref in avcodec_audio_receive_set */ /* the dec_sets_p bufs will be unref in avcodec_audio_receive_set */
28 28 ri = avfilter_bufsrc_add_audio_set_flags(abufsrc_ctx_l, a[0], ri = avfilter_bufsrc_add_audio_set_flags(abufsrc_ctx_l, a[0],
29 29 AVFILTER_BUFSRC_FLAG_PUSH | AVFILTER_BUFSRC_FLAG_KEEP_REF); AVFILTER_BUFSRC_FLAG_PUSH | AVFILTER_BUFSRC_FLAG_KEEP_REF);
30 30 if (ri >= 0) { if (ri >= 0) {
31 31 /* rotate the ptrs if needed */ /* rotate the ptrs if needed */
32 if (audio_dec_sets_p.n > 1) {
32 if (npv_audio_dec_sets_p.n > 1) {
33 33 avutil_audio_set_ref_t *save; avutil_audio_set_ref_t *save;
34 34
35 35 save = a[0]; save = a[0];
36 36 memmove(&a[0], &a[1], sizeof(*a) memmove(&a[0], &a[1], sizeof(*a)
37 * (audio_dec_sets_p.n - 1));
38 a[audio_dec_sets_p.n - 1] = save;
37 * (npv_audio_dec_sets_p.n - 1));
38 a[npv_audio_dec_sets_p.n - 1] = save;
39 39 } }
40 audio_dec_sets_p.n--;
40 npv_audio_dec_sets_p.n--;
41 41 r8 = PUSHED_ONE_SET; r8 = PUSHED_ONE_SET;
42 42 goto unlock; goto unlock;
43 43 } else if (ri == AVERROR(EAGAIN)) { } else if (ri == AVERROR(EAGAIN)) {
 
... ... static u8 filt_push_dec_sets(void)
46 46 } }
47 47 FATALAF("ffmpeg:unable to submit a decoder set of frames to the filter source audio buffer context\n"); FATALAF("ffmpeg:unable to submit a decoder set of frames to the filter source audio buffer context\n");
48 48 unlock: unlock:
49 audio_dec_sets_unlock();
49 npv_audio_dec_sets_unlock();
50 50 return r8; return r8;
51 51 } }
52 52 #undef AGAIN #undef AGAIN
 
... ... unlock:
57 57 #define AGAIN 0 #define AGAIN 0
58 58 #define HAVE_FILT_SET 1 #define HAVE_FILT_SET 1
59 59 #define EOF_FILT 2 #define EOF_FILT 2
60 static u8 filt_set_try_get(void)
60 STATIC u8 filt_set_try_get(void)
61 61 { {
62 62 int r; int r;
63 63 /* /*
 
... ... static u8 filt_set_try_get(void)
79 79 #undef HAVE_FILT_SET #undef HAVE_FILT_SET
80 80 #undef EOF_FILT #undef EOF_FILT
81 81 #define DONT_PRINT_INFO false #define DONT_PRINT_INFO false
82 static void filt_flush(void)
82 STATIC void filt_flush(void)
83 83 { {
84 84 enum avutil_audio_fr_fmt_t dst_fmt; enum avutil_audio_fr_fmt_t dst_fmt;
85 85 int dst_rate; int dst_rate;
 
... ... static void filt_flush(void)
89 89 avutil_audio_set_unref(filt_p.set); avutil_audio_set_unref(filt_p.set);
90 90 filt_p.pcm_written_ufrs_n = 0; filt_p.pcm_written_ufrs_n = 0;
91 91
92 audio_pcm2ff(audio_pcm_p, &dst_fmt, &dst_rate, &dst_chans_n,
92 npv_audio_pcm2ff(npv_audio_pcm_p, &dst_fmt, &dst_rate, &dst_chans_n,
93 93 &dst_chans_layout, DONT_PRINT_INFO); &dst_chans_layout, DONT_PRINT_INFO);
94 audio_filt_cfg(
95 audio_dec_ctx_p->fr_fmt, audio_dec_ctx_p->fr_rate,
96 audio_dec_ctx_p->chans_n, audio_dec_ctx_p->chans_layout,
94 npv_audio_filt_cfg(
95 npv_audio_dec_ctx_p->fr_fmt, npv_audio_dec_ctx_p->fr_rate,
96 npv_audio_dec_ctx_p->chans_n, npv_audio_dec_ctx_p->chans_layout,
97 97 filt_p.muted, filt_p.vol, filt_p.muted, filt_p.vol,
98 98 dst_fmt, dst_rate, dst_chans_n, dst_chans_layout, dst_fmt, dst_rate, dst_chans_n, dst_chans_layout,
99 99 DONT_PRINT_INFO); DONT_PRINT_INFO);
100 100 } }
101 101 #undef DONT_PRINT_INFO #undef DONT_PRINT_INFO
102 static void init_once(void)
102 STATIC void init_once(void)
103 103 { {
104 104 init_once_local(); init_once_local();
105 105 init_once_public(); init_once_public();
106 106 } }
107 static void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate,
107 STATIC void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate,
108 108 int src_chans_n, uint64_t src_chans_layout, int src_chans_n, uint64_t src_chans_layout,
109 109 bool muted, double vol, bool muted, double vol,
110 110 enum avutil_audio_fr_fmt_t dst_fmt, int dst_rate, enum avutil_audio_fr_fmt_t dst_fmt, int dst_rate,
 
... ... static void cfg(enum avutil_audio_fr_fmt_t src_fmt, int src_rate,
149 149 avutil_free(dump_str); avutil_free(dump_str);
150 150 POUTAF("GRAPH END---------------------------------------------------------\n"); POUTAF("GRAPH END---------------------------------------------------------\n");
151 151 } }
152 static void audio_filt_cmd_mute(void)
152 STATIC void npv_audio_filt_cmd_mute(void)
153 153 { {
154 154 int r; int r;
155 155 u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */ u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */
 
... ... static void audio_filt_cmd_mute(void)
178 178 } }
179 179 } }
180 180 } }
181 static void audio_filt_cmd_vol_down(void)
181 STATIC void npv_audio_filt_cmd_vol_down(void)
182 182 { {
183 183 int r; int r;
184 184 u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */ u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */
 
... ... static void audio_filt_cmd_vol_down(void)
194 194 if (r < 0) if (r < 0)
195 195 WARNINGAF("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", resp); WARNINGAF("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", resp);
196 196 } }
197 static void audio_filt_cmd_vol_up(void)
197 STATIC void npv_audio_filt_cmd_vol_up(void)
198 198 { {
199 199 int r; int r;
200 200 u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */ u8 vol_l10n_str[sizeof("xxx.xx")]; /* should be overkill */
File npv/audio/filt/public/state.frag.h changed (mode: 100644) (index e996366..1144830)
3 3 * resampling is made interactive instead of being in a non-interactive filt. * resampling is made interactive instead of being in a non-interactive filt.
4 4 * this is the public part * this is the public part
5 5 */ */
6 static struct {
6 STATIC struct {
7 7 avutil_audio_set_ref_t *set; avutil_audio_set_ref_t *set;
8 8 snd_pcm_ufrs_t pcm_written_ufrs_n; snd_pcm_ufrs_t pcm_written_ufrs_n;
9 9
File npv/audio/local/code.frag.c changed (mode: 100644) (index a2f53ea..b973b7d)
1 static bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt,
1 STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt,
2 2 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 3 { {
4 4 static u8 ff_fmt_str[STR_SZ]; static u8 ff_fmt_str[STR_SZ];
 
... ... static bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt,
46 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)); 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));
47 47 return true; return true;
48 48 } }
49 static void pcm_hw_chans_n_decide(snd_pcm_t *pcm,
49 STATIC void pcm_hw_chans_n_decide(snd_pcm_t *pcm,
50 50 snd_pcm_hw_params_t *pcm_hw_params, unsigned int chans_n) snd_pcm_hw_params_t *pcm_hw_params, unsigned int chans_n)
51 51 { {
52 52 int r; int r;
 
... ... static void pcm_hw_chans_n_decide(snd_pcm_t *pcm,
90 90 } }
91 91 FATALA("alsa:unable to find a suitable count of channels\n"); FATALA("alsa:unable to find a suitable count of channels\n");
92 92 } }
93 static void pcm_hw_rate_decide(snd_pcm_t *pcm,
93 STATIC void pcm_hw_rate_decide(snd_pcm_t *pcm,
94 94 snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate) snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate)
95 95 { {
96 96 int r; int r;
 
... ... static void pcm_hw_rate_decide(snd_pcm_t *pcm,
149 149 } }
150 150 FATALA("alsa:unable to find a suitable rate\n"); FATALA("alsa:unable to find a suitable rate\n");
151 151 } }
152 static bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm,
152 STATIC bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm,
153 153 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)
154 154 { {
155 155 int r; int r;
 
... ... static bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm,
164 164 return true; return true;
165 165 } }
166 166 #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)
167 static void pcm_hw_fmt_decide(snd_pcm_t *pcm,
167 STATIC void pcm_hw_fmt_decide(snd_pcm_t *pcm,
168 168 snd_pcm_hw_params_t *pcm_hw_params, bool force, snd_pcm_hw_params_t *pcm_hw_params, bool force,
169 169 snd_pcm_fmt_t forced_fmt) snd_pcm_fmt_t forced_fmt)
170 170 { {
 
... ... static void pcm_hw_fmt_decide(snd_pcm_t *pcm,
209 209 FATALA("alsa:unable to find a suitable format\n"); FATALA("alsa:unable to find a suitable format\n");
210 210 } }
211 211 #undef PCM_HW_FMT_DECIDE_X #undef PCM_HW_FMT_DECIDE_X
212 static bool pcm_hw_access_decide_x(snd_pcm_t *pcm,
212 STATIC bool pcm_hw_access_decide_x(snd_pcm_t *pcm,
213 213 snd_pcm_hw_params_t *pcm_hw_params, snd_pcm_access_t access) snd_pcm_hw_params_t *pcm_hw_params, snd_pcm_access_t access)
214 214 { {
215 215 int r; int r;
 
... ... static bool pcm_hw_access_decide_x(snd_pcm_t *pcm,
226 226 #define PCM_HW_ACCESS_DECIDE_X(access) \ #define PCM_HW_ACCESS_DECIDE_X(access) \
227 227 pcm_hw_access_decide_x(pcm, pcm_hw_params, access) pcm_hw_access_decide_x(pcm, pcm_hw_params, access)
228 228 /* XXX: only classic non-mmap ones */ /* XXX: only classic non-mmap ones */
229 static void pcm_hw_access_decide(snd_pcm_t *pcm,
229 STATIC void pcm_hw_access_decide(snd_pcm_t *pcm,
230 230 snd_pcm_hw_params_t *pcm_hw_params, bool force, snd_pcm_hw_params_t *pcm_hw_params, bool force,
231 231 snd_pcm_access_t forced_access) snd_pcm_access_t forced_access)
232 232 { {
 
... ... static void pcm_hw_access_decide(snd_pcm_t *pcm,
263 263 * n. * n.
264 264 * we choose roughly 0.25 secs, or roughly (rate / 4) frs. * we choose roughly 0.25 secs, or roughly (rate / 4) frs.
265 265 */ */
266 static void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm,
266 STATIC void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm,
267 267 snd_pcm_hw_params_t *pcm_hw_params) snd_pcm_hw_params_t *pcm_hw_params)
268 268 { {
269 269 int r; int r;
 
... ... static void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm,
297 297 * *
298 298 * we try to use a sensible restrict order regarding audio props * we try to use a sensible restrict order regarding audio props
299 299 */ */
300 static void pcm_cfg_hw_core(snd_pcm_t *pcm, snd_pcm_hw_params_t *pcm_hw_params,
300 STATIC void pcm_cfg_hw_core(snd_pcm_t *pcm, snd_pcm_hw_params_t *pcm_hw_params,
301 301 int chans_n, int rate, enum avutil_audio_fr_fmt_t ff_fmt) int chans_n, int rate, enum avutil_audio_fr_fmt_t ff_fmt)
302 302 { {
303 303 int r; int r;
 
... ... static void pcm_cfg_hw_core(snd_pcm_t *pcm, snd_pcm_hw_params_t *pcm_hw_params,
321 321 pcm_hw_buf_sz_cfg(pcm, pcm_hw_params); pcm_hw_buf_sz_cfg(pcm, pcm_hw_params);
322 322 } }
323 323 /* base on kernel api at the time we wrote this code */ /* base on kernel api at the time we wrote this code */
324 static u8 *kernel_ts_types_str[] = {
324 STATIC u8 *kernel_ts_types_str[] = {
325 325 "compat", "compat",
326 326 "default", "default",
327 327 "link", "link",
 
... ... static u8 *kernel_ts_types_str[] = {
329 329 "link estimated", "link estimated",
330 330 "link synchonized" "link synchonized"
331 331 }; };
332 static void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
332 STATIC void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
333 333 enum avutil_audio_fr_fmt_t ff_fmt) enum avutil_audio_fr_fmt_t ff_fmt)
334 334 { {
335 335 int r; int r;
 
... ... static void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
372 372 snd_pcm_hw_params_free(hw_params); snd_pcm_hw_params_free(hw_params);
373 373 POUTA("ALSA:HW_PARAMS END--------------------------------------------------------------\n"); POUTA("ALSA:HW_PARAMS END--------------------------------------------------------------\n");
374 374 } }
375 static void pcm_cfg_sw(snd_pcm_t *pcm)
375 STATIC void pcm_cfg_sw(snd_pcm_t *pcm)
376 376 { {
377 377 int r; int r;
378 378 snd_pcm_sw_params_t *sw_params; snd_pcm_sw_params_t *sw_params;
 
... ... static void pcm_cfg_sw(snd_pcm_t *pcm)
399 399 snd_pcm_sw_params_free(sw_params); snd_pcm_sw_params_free(sw_params);
400 400 POUTA("ALSA:SW_PARAMS END--------------------------------------------------------------\n"); POUTA("ALSA:SW_PARAMS END--------------------------------------------------------------\n");
401 401 } }
402 static void dec_a_grow(void)
402 STATIC void dec_a_grow(void)
403 403 { {
404 404 u32 new_idx; u32 new_idx;
405 405
 
... ... static void dec_a_grow(void)
416 416 #define AGAIN 0 #define AGAIN 0
417 417 #define RECOVERED 1 #define RECOVERED 1
418 418 #define CONTINUE 2 #define CONTINUE 2
419 static u8 alsa_recover(snd_pcm_sfrs_t r)
419 STATIC u8 alsa_recover(snd_pcm_sfrs_t r)
420 420 { {
421 421 if (r >= 0) if (r >= 0)
422 422 return CONTINUE; return CONTINUE;
 
... ... static u8 alsa_recover(snd_pcm_sfrs_t r)
442 442 #define NO 0 #define NO 0
443 443 #define AGAIN 0 #define AGAIN 0
444 444 #define RECOVERED 1 #define RECOVERED 1
445 static void pcm_silence_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
445 STATIC void pcm_silence_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
446 446 { {
447 447 int alsa_r; int alsa_r;
448 448 u8 r_recover; u8 r_recover;
 
... ... static void pcm_silence_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
450 450
451 451 if (ufrs_n == 0) if (ufrs_n == 0)
452 452 break; break;
453 is_planar_fmt = avutil_audio_fr_fmt_is_planar(audio_filt_p.set->fmt);
453 is_planar_fmt = avutil_audio_fr_fmt_is_planar(
454 npv_audio_filt_p.set->fmt);
454 455 if (is_planar_fmt == NO) if (is_planar_fmt == NO)
455 456 alsa_r = snd_pcm_writei(pcm_p, pcm_silence_bufs_l[0], ufrs_n); alsa_r = snd_pcm_writei(pcm_p, pcm_silence_bufs_l[0], ufrs_n);
456 457 else else
 
... ... static void pcm_silence_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
467 468 #undef AGAIN #undef AGAIN
468 469 #undef RECOVERED #undef RECOVERED
469 470 #define NO 0 #define NO 0
470 static void chans_buf_init(u8 **chans_buf, int start_fr_idx)
471 STATIC void chans_buf_init(u8 **chans_buf, int start_fr_idx)
471 472 { {
472 473 int is_planar_fmt; int is_planar_fmt;
473 474 int sample_bytes_n; int sample_bytes_n;
474 475
475 sample_bytes_n = avutil_get_bytes_per_sample(audio_filt_p.set->fmt);
476 is_planar_fmt = avutil_audio_fr_fmt_is_planar(audio_filt_p.set->fmt);
476 sample_bytes_n = avutil_get_bytes_per_sample(npv_audio_filt_p.set->fmt);
477 is_planar_fmt = avutil_audio_fr_fmt_is_planar(
478 npv_audio_filt_p.set->fmt);
477 479 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
478 480 int fr_bytes_n; int fr_bytes_n;
479 481
480 fr_bytes_n = sample_bytes_n * audio_filt_p.set->chans_n;
481 chans_buf[0] = (u8*)audio_filt_p.set->data[0] + start_fr_idx
482 fr_bytes_n = sample_bytes_n * npv_audio_filt_p.set->chans_n;
483 chans_buf[0] = (u8*)npv_audio_filt_p.set->data[0] + start_fr_idx
482 484 * fr_bytes_n; * fr_bytes_n;
483 485 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
484 486 int p; int p;
485 487
486 488 p = 0; p = 0;
487 489 loop { loop {
488 if (p == audio_filt_p.set->chans_n)
490 if (p == npv_audio_filt_p.set->chans_n)
489 491 break; break;
490 chans_buf[p] = (u8*)audio_filt_p.set->data[p]
492 chans_buf[p] = (u8*)npv_audio_filt_p.set->data[p]
491 493 + start_fr_idx * sample_bytes_n; + start_fr_idx * sample_bytes_n;
492 494 ++p; ++p;
493 495 } }
 
... ... static void chans_buf_init(u8 **chans_buf, int start_fr_idx)
496 498 #undef NO #undef NO
497 499 #define NO 0 #define NO 0
498 500 /*NSPC*/ /*NSPC*/
499 static void chans_buf_inc(u8 **chans_buf, int inc)
501 STATIC void chans_buf_inc(u8 **chans_buf, int inc)
500 502 { {
501 503 int is_planar_fmt; int is_planar_fmt;
502 504 int sample_bytes_n; int sample_bytes_n;
503 505
504 sample_bytes_n = avutil_get_bytes_per_sample(audio_filt_p.set->fmt);
505 is_planar_fmt = avutil_audio_fr_fmt_is_planar(audio_filt_p.set->fmt);
506 sample_bytes_n = avutil_get_bytes_per_sample(npv_audio_filt_p.set->fmt);
507 is_planar_fmt = avutil_audio_fr_fmt_is_planar(
508 npv_audio_filt_p.set->fmt);
506 509 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
507 510 int fr_bytes_n; int fr_bytes_n;
508 511
509 fr_bytes_n = sample_bytes_n * audio_filt_p.set->chans_n;
512 fr_bytes_n = sample_bytes_n * npv_audio_filt_p.set->chans_n;
510 513 chans_buf[0] = (u8*)chans_buf[0] + inc * fr_bytes_n; chans_buf[0] = (u8*)chans_buf[0] + inc * fr_bytes_n;
511 514 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
512 515 int p; int p;
513 516
514 517 p = 0; p = 0;
515 518 loop { loop {
516 if (p == audio_filt_p.set->chans_n)
519 if (p == npv_audio_filt_p.set->chans_n)
517 520 break; break;
518 521 chans_buf[p] = (u8*)chans_buf[p] + inc * sample_bytes_n; chans_buf[p] = (u8*)chans_buf[p] + inc * sample_bytes_n;
519 522 ++p; ++p;
 
... ... static void chans_buf_inc(u8 **chans_buf, int inc)
521 524 } }
522 525 } }
523 526 #undef NO #undef NO
524 static void draining_state_handle(void)
527 STATIC void draining_state_handle(void)
525 528 { {
526 529 int r; int r;
527 530
 
... ... static void draining_state_handle(void)
544 547 } }
545 548 EXIT("alsa pcm drained or similar, exiting\n"); EXIT("alsa pcm drained or similar, exiting\n");
546 549 } }
547 static void draining_state_switch(void)
550 STATIC void draining_state_switch(void)
548 551 { {
549 552 int r; int r;
550 553 u8 i; u8 i;
 
... ... static void draining_state_switch(void)
580 583 #define HAVE_FILT_SET 1 #define HAVE_FILT_SET 1
581 584 #define EOF_FILT 2 #define EOF_FILT 2
582 585 #define NO_DEC_SET 2 #define NO_DEC_SET 2
583 static void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
586 STATIC void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
584 587 { {
585 588 u8 chan_buf; u8 chan_buf;
586 589 u8 *chans_buf[AVUTIL_DATA_PTRS_N]; u8 *chans_buf[AVUTIL_DATA_PTRS_N];
 
... ... static void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
595 598 * in this loop we try to get some filt frs from what we got from the * in this loop we try to get some filt frs from what we got from the
596 599 * dec * dec
597 600 */ */
598 if (audio_filt_p.set->frs_n == 0) loop {
601 if (npv_audio_filt_p.set->frs_n == 0) loop {
599 602 u8 r; u8 r;
600 603
601 604 /* we _really_ want audio data */ /* we _really_ want audio data */
602 605 (void)filt_push_dec_sets(); (void)filt_push_dec_sets();
603 r = audio_filt_set_try_get();
606 r = npv_audio_filt_set_try_get();
604 607 if (r == EOF_FILT) { if (r == EOF_FILT) {
605 608 draining_state_switch(); draining_state_switch();
606 609 return; return;
607 610 } else if (r == HAVE_FILT_SET) { } else if (r == HAVE_FILT_SET) {
608 audio_filt_p.pcm_written_ufrs_n = 0;
611 npv_audio_filt_p.pcm_written_ufrs_n = 0;
609 612 break; break;
610 613 } }
611 614 /* r == AGAIN */ /* r == AGAIN */
612 615 } }
613 chans_buf_init(chans_buf, (int)audio_filt_p.pcm_written_ufrs_n);
614 filt_set_remaining_ufrs_n = (snd_pcm_ufrs_t)audio_filt_p.set->frs_n
615 - audio_filt_p.pcm_written_ufrs_n;
616 chans_buf_init(chans_buf, (int)npv_audio_filt_p.pcm_written_ufrs_n);
617 filt_set_remaining_ufrs_n = (snd_pcm_ufrs_t)npv_audio_filt_p.set->frs_n
618 - npv_audio_filt_p.pcm_written_ufrs_n;
616 619 if (filt_set_remaining_ufrs_n > ufrs_n) if (filt_set_remaining_ufrs_n > ufrs_n)
617 620 ufrs_to_write_n = ufrs_n; ufrs_to_write_n = ufrs_n;
618 621 else else
619 622 ufrs_to_write_n = filt_set_remaining_ufrs_n; ufrs_to_write_n = filt_set_remaining_ufrs_n;
620 is_planar_fmt = avutil_audio_fr_fmt_is_planar(audio_filt_p.set->fmt);
623 is_planar_fmt = avutil_audio_fr_fmt_is_planar(
624 npv_audio_filt_p.set->fmt);
621 625 written_ufrs_n = 0; written_ufrs_n = 0;
622 626 loop { /* short write loop */ loop { /* short write loop */
623 627 snd_pcm_sfrs_t alsa_r; snd_pcm_sfrs_t alsa_r;
 
... ... static void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
634 638 continue; continue;
635 639 else if (r_recover == RECOVERED) { else if (r_recover == RECOVERED) {
636 640 /* account for the written frs anyway */ /* account for the written frs anyway */
637 if (audio_filt_p.pcm_written_ufrs_n == 0)
638 clk_ref_time_point_update(audio_filt_p.set->pts,
641 if (npv_audio_filt_p.pcm_written_ufrs_n == 0)
642 npv_clk_ref_time_point_update(
643 npv_audio_filt_p.set->pts,
639 644 written_ufrs_n); written_ufrs_n);
640 audio_filt_p.pcm_written_ufrs_n += written_ufrs_n;
641 if ((int)audio_filt_p.pcm_written_ufrs_n ==
642 audio_filt_p.set->frs_n)
645 npv_audio_filt_p.pcm_written_ufrs_n += written_ufrs_n;
646 if ((int)npv_audio_filt_p.pcm_written_ufrs_n ==
647 npv_audio_filt_p.set->frs_n)
643 648 /* set audio_filt_p.set->frs_n = 0 */ /* set audio_filt_p.set->frs_n = 0 */
644 avutil_audio_set_unref(audio_filt_p.set);
649 avutil_audio_set_unref(npv_audio_filt_p.set);
645 650 return; return;
646 651 } }
647 652 /* r_recover == CONTINUE */ /* r_recover == CONTINUE */
 
... ... static void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
656 661 * *
657 662 * XXX: getting the "right" ts from ff is convoluted * XXX: getting the "right" ts from ff is convoluted
658 663 */ */
659 if (audio_filt_p.pcm_written_ufrs_n == 0)
660 clk_ref_time_point_update(audio_filt_p.set->pts,
664 if (npv_audio_filt_p.pcm_written_ufrs_n == 0)
665 npv_clk_ref_time_point_update(npv_audio_filt_p.set->pts,
661 666 written_ufrs_n); written_ufrs_n);
662 audio_filt_p.pcm_written_ufrs_n += written_ufrs_n;
667 npv_audio_filt_p.pcm_written_ufrs_n += written_ufrs_n;
663 668 ufrs_n -= written_ufrs_n; ufrs_n -= written_ufrs_n;
664 669
665 if ((int)audio_filt_p.pcm_written_ufrs_n == audio_filt_p.set->frs_n)
670 if ((int)npv_audio_filt_p.pcm_written_ufrs_n
671 == npv_audio_filt_p.set->frs_n)
666 672 /* set audio_filt_p.av->frs_n = 0 */ /* set audio_filt_p.av->frs_n = 0 */
667 avutil_audio_set_unref(audio_filt_p.set);
673 avutil_audio_set_unref(npv_audio_filt_p.set);
668 674 }} }}
669 675 #undef NO #undef NO
670 676 #undef AGAIN #undef AGAIN
 
... ... static void pcm_filt_frs_write(snd_pcm_ufrs_t ufrs_n) { loop
674 680 #undef EOF_FILT #undef EOF_FILT
675 681 #undef NO_DEC_SET #undef NO_DEC_SET
676 682 /* fatal if the wiring cannot be done */ /* fatal if the wiring cannot be done */
677 static void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
683 STATIC void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
678 684 snd_pcm_access_t alsa_access, enum avutil_audio_fr_fmt_t *ff_fmt, snd_pcm_access_t alsa_access, enum avutil_audio_fr_fmt_t *ff_fmt,
679 685 bool print_info) bool print_info)
680 686 { {
 
... ... static void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
722 728 * XXX: if it is ever used significantly, a fine granularity wiring strategy * XXX: if it is ever used significantly, a fine granularity wiring strategy
723 729 * will be implemented instead of using the default wiring * will be implemented instead of using the default wiring
724 730 */ */
725 static uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
731 STATIC uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
726 732 unsigned int pcm_chans_n, bool print_info) unsigned int pcm_chans_n, bool print_info)
727 733 { {
728 734 int r; int r;
 
... ... static uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
746 752 POUTA("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); POUTA("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n);
747 753 return ff_chans_layout; return ff_chans_layout;
748 754 } }
749 static void init_pcm_once_public(u8 *pcm_str)
755 STATIC void init_pcm_once_public(u8 *pcm_str)
750 756 { {
751 757 int r; int r;
752 758
 
... ... static void init_pcm_once_public(u8 *pcm_str)
767 773 memset(pcm_pollfds_p, 0, sizeof(pcm_pollfds_p)); memset(pcm_pollfds_p, 0, sizeof(pcm_pollfds_p));
768 774 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);
769 775 } }
770 static void init_once_public(u8 *pcm_str)
776 STATIC void init_once_public(u8 *pcm_str)
771 777 { {
772 778 int r; int r;
773 779
774 780 memset(&st_p, 0, sizeof(st_p)); memset(&st_p, 0, sizeof(st_p));
775 pkt_q_p = pkt_q_new("audio");
781 pkt_q_p = npv_pkt_q_new("audio");
776 782 dec_ctx_p = 0; dec_ctx_p = 0;
777 783 dec_sets_p.eof_receive = false; dec_sets_p.eof_receive = false;
778 784 dec_sets_p.n_max = 0; dec_sets_p.n_max = 0;
 
... ... static void init_once_public(u8 *pcm_str)
793 799 if (r != 0) if (r != 0)
794 800 FATALA("%d:unable to init the mutex for the array of decoder sets\n", r); FATALA("%d:unable to init the mutex for the array of decoder sets\n", r);
795 801 } }
796 static void init_once_local(void)
802 STATIC void init_once_local(void)
797 803 { {
798 804 int r; int r;
799 805
 
... ... static void init_once_local(void)
806 812 FATALA("alsa:unable to attach stderr\n"); FATALA("alsa:unable to attach stderr\n");
807 813 memset(pcm_silence_bufs_l, 0, sizeof(pcm_silence_bufs_l)); memset(pcm_silence_bufs_l, 0, sizeof(pcm_silence_bufs_l));
808 814 } }
809 static void dec_a_unref_all(void)
815 STATIC void dec_a_unref_all(void)
810 816 { {
811 817 u16 set; u16 set;
812 818
File npv/audio/local/state.frag.c changed (mode: 100644) (index cef7b74..2bf76ec)
1 1 /* ff dec */ /* ff dec */
2 static avcodec_codec_t *dec_l; /* same mutex than dec_ctx_p */
3 static pthread_mutex_t dec_ctx_mutex_l;
2 STATIC avcodec_codec_t *dec_l; /* same mutex than dec_ctx_p */
3 STATIC pthread_mutex_t dec_ctx_mutex_l;
4 4 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
5 5 /* alsa */ /* alsa */
6 static snd_output_t *pcm_pout_l;
7 static snd_output_t *pcm_perr_l;
6 STATIC snd_output_t *pcm_pout_l;
7 STATIC snd_output_t *pcm_perr_l;
8 8 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
9 9 /* we will inject silence frs while paused */ /* we will inject silence frs while paused */
10 static void *pcm_silence_bufs_l[AVUTIL_DATA_PTRS_N];
10 STATIC void *pcm_silence_bufs_l[AVUTIL_DATA_PTRS_N];
File npv/audio/namespace/main.c changed (mode: 100644) (index d038c5a..8b235ea)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define chans_buf_init audio_chans_buf_init
3 #define chans_buf_inc audio_chans_buf_inc
4 #define dec_a_grow audio_dec_a_grow
5 #define dec_a_unref_all audio_dec_a_unref_all
6 #define dec_ctx_mutex_l audio_dec_ctx_mutex_l
7 #define dec_flush audio_dec_flush
8 #define dec_l audio_dec_l
9 #define draining_state_handle audio_draining_state_handle
10 #define draining_state_switch audio_draining_state_switch
11 #define ff_fmt2pcm_layout_best_effort audio_ff_fmt2pcm_layout_best_effort
12 #define filt_push_dec_sets audio_filt_push_dec_sets
13 #define init_once_local audio_init_once_local
14 #define init_once_public audio_init_once_public
15 #define init_pcm_once_public audio_init_pcm_once_public
16 #define kernel_ts_types_str audio_kernel_ts_types_str
17 #define pcm_chmaps2ff_chans_layout audio_pcm_chmaps2ff_chans_layout
18 #define pcm_cfg_hw audio_pcm_cfg_hw
19 #define pcm_cfg_hw_core audio_pcm_cfg_hw_core
20 #define pcm_cfg_sw audio_pcm_cfg_sw
21 #define pcm_filt_frs_write audio_pcm_filt_frs_write
22 #define pcm_hw_access_decide audio_pcm_hw_access_decide
23 #define pcm_hw_access_decide_x audio_pcm_hw_access_decide_x
24 #define pcm_hw_buf_sz_cfg audio_pcm_hw_buf_sz_cfg
25 #define pcm_hw_chans_n_decide audio_pcm_hw_chans_n_decide
26 #define pcm_hw_fmt_decide audio_pcm_hw_fmt_decide
27 #define pcm_hw_fmt_decide_x audio_pcm_hw_fmt_decide_x
28 #define pcm_hw_rate_decide audio_pcm_hw_rate_decide
29 #define pcm_layout2ff_fmt_strict audio_pcm_layout2ff_fmt_strict
30 #define pcm_name_l audio_pcm_name_l
31 #define pcm_pout_l audio_pcm_pout_l
32 #define pcm_perr_l audio_pcm_perr_l
33 #define pcm_silence_bufs_l audio_pcm_silence_bufs_l
34 #define pcm_silence_frs_write audio_pcm_silence_frs_write
2 #define alsa_recover npv_audio_alsa_recover
3 #define chans_buf_init npv_audio_chans_buf_init
4 #define chans_buf_inc npv_audio_chans_buf_inc
5 #define dec_a_grow npv_audio_dec_a_grow
6 #define dec_a_unref_all npv_audio_dec_a_unref_all
7 #define dec_ctx_mutex_l npv_audio_dec_ctx_mutex_l
8 #define dec_flush npv_audio_dec_flush
9 #define dec_l npv_audio_dec_l
10 #define draining_state_handle npv_audio_draining_state_handle
11 #define draining_state_switch npv_audio_draining_state_switch
12 #define ff_fmt2pcm_layout_best_effort npv_audio_ff_fmt2pcm_layout_best_effort
13 #define filt_push_dec_sets npv_audio_filt_push_dec_sets
14 #define init_once_local npv_audio_init_once_local
15 #define init_once_public npv_audio_init_once_public
16 #define init_pcm_once_public npv_audio_init_pcm_once_public
17 #define kernel_ts_types_str npv_audio_kernel_ts_types_str
18 #define pcm_chmaps2ff_chans_layout npv_audio_pcm_chmaps2ff_chans_layout
19 #define pcm_cfg_hw npv_audio_pcm_cfg_hw
20 #define pcm_cfg_hw_core npv_audio_pcm_cfg_hw_core
21 #define pcm_cfg_sw npv_audio_pcm_cfg_sw
22 #define pcm_filt_frs_write npv_audio_pcm_filt_frs_write
23 #define pcm_hw_access_decide npv_audio_pcm_hw_access_decide
24 #define pcm_hw_access_decide_x npv_audio_pcm_hw_access_decide_x
25 #define pcm_hw_buf_sz_cfg npv_audio_pcm_hw_buf_sz_cfg
26 #define pcm_hw_chans_n_decide npv_audio_pcm_hw_chans_n_decide
27 #define pcm_hw_fmt_decide npv_audio_pcm_hw_fmt_decide
28 #define pcm_hw_fmt_decide_x npv_audio_pcm_hw_fmt_decide_x
29 #define pcm_hw_rate_decide npv_audio_pcm_hw_rate_decide
30 #define pcm_layout2ff_fmt_strict npv_audio_pcm_layout2ff_fmt_strict
31 #define pcm_name_l npv_audio_pcm_name_l
32 #define pcm_pout_l npv_audio_pcm_pout_l
33 #define pcm_perr_l npv_audio_pcm_perr_l
34 #define pcm_silence_bufs_l npv_audio_pcm_silence_bufs_l
35 #define pcm_silence_frs_write npv_audio_pcm_silence_frs_write
35 36 /*============================================================================*/ /*============================================================================*/
36 37 #else #else
38 #undef alsa_recover
37 39 #undef chans_buf_init #undef chans_buf_init
38 40 #undef chans_buf_inc #undef chans_buf_inc
39 41 #undef dec_a_grow #undef dec_a_grow
File npv/audio/namespace/public.h changed (mode: 100644) (index 816c928..180ba4d)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define dec_ctx_cfg audio_dec_ctx_cfg
3 #define dec_ctx_lock audio_dec_ctx_lock
4 #define dec_ctx_p audio_dec_ctx_p
5 #define dec_ctx_unlock audio_dec_ctx_unlock
6 #define dec_flush audio_dec_flush
7 #define dec_sets_lock audio_dec_sets_lock
8 #define dec_sets_p audio_dec_sets_p
9 #define dec_sets_unlock audio_dec_sets_unlock
10 #define dec_sets_receive_avail audio_dec_sets_receive_avail
11 #define dec_set_try_receive audio_dec_set_try_receive
12 #define draining_p audio_draining_p
13 #define draining_state_evt audio_draining_state_evt
14 #define draining_timer_fd_p audio_draining_timer_fd_p
15 #define evt_pcm_write audio_evt_pcm_write
16 #define init_once audio_init_once
17 #define pcm2ff audio_pcm2ff
18 #define pcm_cfg audio_pcm_cfg
19 #define pcm_p audio_pcm_p
20 #define pcm_pollfds_p audio_pcm_pollfds_p
21 #define pcm_pollfds_n_p audio_pcm_pollfds_n_p
22 #define pcm_pollfds_n_max audio_pcm_pollfds_n_max
23 #define pcm_silence_bufs_cfg audio_pcm_silence_bufs_cfg
24 #define pkt_q_p audio_pkt_q_p
25 #define pkts_send audio_pkts_send
26 #define selected_ts_type_p audio_selected_ts_type_p
27 #define st_p audio_st_p
2 #define dec_ctx_cfg npv_audio_dec_ctx_cfg
3 #define dec_ctx_lock npv_audio_dec_ctx_lock
4 #define dec_ctx_p npv_audio_dec_ctx_p
5 #define dec_ctx_unlock npv_audio_dec_ctx_unlock
6 #define dec_flush npv_audio_dec_flush
7 #define dec_sets_lock npv_audio_dec_sets_lock
8 #define dec_sets_p npv_audio_dec_sets_p
9 #define dec_sets_unlock npv_audio_dec_sets_unlock
10 #define dec_sets_receive_avail npv_audio_dec_sets_receive_avail
11 #define dec_set_try_receive npv_audio_dec_set_try_receive
12 #define draining_p npv_audio_draining_p
13 #define draining_state_evt npv_audio_draining_state_evt
14 #define draining_timer_fd_p npv_audio_draining_timer_fd_p
15 #define evt_pcm_write npv_audio_evt_pcm_write
16 #define init_once npv_audio_init_once
17 #define pcm2ff npv_audio_pcm2ff
18 #define pcm_cfg npv_audio_pcm_cfg
19 #define pcm_p npv_audio_pcm_p
20 #define pcm_pollfds_p npv_audio_pcm_pollfds_p
21 #define pcm_pollfds_n_p npv_audio_pcm_pollfds_n_p
22 #define pcm_pollfds_n_max npv_audio_pcm_pollfds_n_max
23 #define pcm_silence_bufs_cfg npv_audio_pcm_silence_bufs_cfg
24 #define pkt_q_p npv_audio_pkt_q_p
25 #define pkts_send npv_audio_pkts_send
26 #define selected_ts_type_p npv_audio_selected_ts_type_p
27 #define st_p npv_audio_st_p
28 28 /*============================================================================*/ /*============================================================================*/
29 29 #else #else
30 30 #undef dec_ctx_cfg #undef dec_ctx_cfg
File npv/audio/public.h changed (mode: 100644) (index f7d2916..cdeed9c)
22 22 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
23 23 #include "npv/audio/public/state.frag.h" #include "npv/audio/public/state.frag.h"
24 24 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
25 static void dec_ctx_cfg(avcodec_params_t *params);
26 static void dec_ctx_lock(void);
27 static void dec_ctx_unlock(void);
28 static void dec_sets_lock(void);
29 static void dec_sets_unlock(void);
30 static void dec_flush(void);
31 static u8 dec_set_try_receive(void);
32 static void dec_sets_receive_avail(void);
33 static void draining_state_evt(void);
34 static void evt_pcm_write(void);
35 static void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info);
36 static void init_once(u8 *pcm_str);
37 static void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
25 STATIC void dec_ctx_cfg(avcodec_params_t *params);
26 STATIC void dec_ctx_lock(void);
27 STATIC void dec_ctx_unlock(void);
28 STATIC void dec_sets_lock(void);
29 STATIC void dec_sets_unlock(void);
30 STATIC void dec_flush(void);
31 STATIC u8 dec_set_try_receive(void);
32 STATIC void dec_sets_receive_avail(void);
33 STATIC void draining_state_evt(void);
34 STATIC void evt_pcm_write(void);
35 STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info);
36 STATIC void init_once(u8 *pcm_str);
37 STATIC void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
38 38 enum avutil_audio_fr_fmt_t ff_fmt); enum avutil_audio_fr_fmt_t ff_fmt);
39 static void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt,
39 STATIC void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt,
40 40 int *ff_rate, int *ff_chans_n, uint64_t *ff_chans_layout, int *ff_rate, int *ff_chans_n, uint64_t *ff_chans_layout,
41 41 bool print_info); bool print_info);
42 static void pkts_send(void);
42 STATIC void pkts_send(void);
43 43 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
44 44 #define CLEANUP #define CLEANUP
45 45 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/audio/public/code.frag.c changed (mode: 100644) (index 9a5d9f3..aff40c1)
1 static void dec_ctx_cfg(avcodec_params_t *params)
1 STATIC void dec_ctx_cfg(avcodec_params_t *params)
2 2 { {
3 3 int r; int r;
4 4
 
... ... static void dec_ctx_cfg(avcodec_params_t *params)
22 22 #define AGAIN 0 #define AGAIN 0
23 23 #define HAVE_DEC_SET 1 #define HAVE_DEC_SET 1
24 24 #define EOF_DEC 2 #define EOF_DEC 2
25 static u8 dec_set_try_receive(void)
25 STATIC u8 dec_set_try_receive(void)
26 26 { {
27 27 int r; int r;
28 28 u32 last; u32 last;
 
... ... static u8 dec_set_try_receive(void)
56 56 * this can be long and we don't want to lock that long the q of audio frs * this can be long and we don't want to lock that long the q of audio frs
57 57 * for the alsa writer, then do finer-grained locking here * for the alsa writer, then do finer-grained locking here
58 58 */ */
59 static void dec_sets_receive_avail(void) { loop
59 STATIC void dec_sets_receive_avail(void) { loop
60 60 { {
61 61 u8 r; u8 r;
62 62
 
... ... static void dec_sets_receive_avail(void) { loop
73 73 #undef AGAIN #undef AGAIN
74 74 #undef HAVE_DEC_SET #undef HAVE_DEC_SET
75 75 #undef EOF_DEC #undef EOF_DEC
76 static void draining_state_evt(void)
76 STATIC void draining_state_evt(void)
77 77 { {
78 78 int r; int r;
79 79 uint64_t exps_n; uint64_t exps_n;
 
... ... static void draining_state_evt(void)
85 85 } }
86 86 #define AGAIN 0 #define AGAIN 0
87 87 #define RECOVERED 1 #define RECOVERED 1
88 static void evt_pcm_write(void)
88 STATIC void evt_pcm_write(void)
89 89 { {
90 90 snd_pcm_sfrs_t alsa_r; snd_pcm_sfrs_t alsa_r;
91 91 snd_pcm_ufrs_t ufrs_n; snd_pcm_ufrs_t ufrs_n;
 
... ... static void evt_pcm_write(void)
104 104 } }
105 105 #undef AGAIN #undef AGAIN
106 106 #undef RECOVERED #undef RECOVERED
107 static void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info)
107 STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info)
108 108 { {
109 109 int r; int r;
110 110 snd_pcm_hw_params_t *hw_params; snd_pcm_hw_params_t *hw_params;
 
... ... static void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info)
193 193 FATALA("silence:the pcm access type is not supported\n"); FATALA("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 static void init_once(u8 *pcm_str)
196 STATIC void init_once(u8 *pcm_str)
197 197 { {
198 198 init_once_local(); init_once_local();
199 199 init_once_public(pcm_str); init_once_public(pcm_str);
200 200 } }
201 static void dec_flush(void)
201 STATIC void dec_flush(void)
202 202 { {
203 pkt_q_unref_all(pkt_q_p);
203 npv_pkt_q_unref_all(pkt_q_p);
204 204 dec_a_unref_all(); dec_a_unref_all();
205 205 dec_sets_p.eof_receive = false; dec_sets_p.eof_receive = false;
206 206 avcodec_flush_bufs(dec_ctx_p); avcodec_flush_bufs(dec_ctx_p);
207 207 } }
208 static void dec_ctx_lock(void)
208 STATIC void dec_ctx_lock(void)
209 209 { {
210 210 int r; int r;
211 211
 
... ... static void dec_ctx_lock(void)
213 213 if (r != 0) if (r != 0)
214 214 FATALA("%d:unable to lock the decoder context\n", r); FATALA("%d:unable to lock the decoder context\n", r);
215 215 } }
216 static void dec_ctx_unlock(void)
216 STATIC void dec_ctx_unlock(void)
217 217 { {
218 218 int r; int r;
219 219
 
... ... static void dec_ctx_unlock(void)
221 221 if (r != 0) if (r != 0)
222 222 FATALA("%d:unable to unlock the decoder context\n", r); FATALA("%d:unable to unlock the decoder context\n", r);
223 223 } }
224 static void dec_sets_lock(void)
224 STATIC void dec_sets_lock(void)
225 225 { {
226 226 int r; int r;
227 227
 
... ... static void dec_sets_lock(void)
229 229 if (r != 0) if (r != 0)
230 230 FATALA("%d:unable to lock the array of decoder sets\n", r); FATALA("%d:unable to lock the array of decoder sets\n", r);
231 231 } }
232 static void dec_sets_unlock(void)
232 STATIC void dec_sets_unlock(void)
233 233 { {
234 234 int r; int r;
235 235
 
... ... static void dec_sets_unlock(void)
237 237 if (r != 0) if (r != 0)
238 238 FATALA("%d:unable to unlock the array of decoder sets\n", r); FATALA("%d:unable to unlock the array of decoder sets\n", r);
239 239 } }
240 static void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
240 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);
 
... ... static void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate,
246 246 snd_pcm_dump(pcm, pcm_pout_l); snd_pcm_dump(pcm, pcm_pout_l);
247 247 POUTA("ALSA PCM DUMP END---------------------------------------------------------------\n"); POUTA("ALSA PCM DUMP END---------------------------------------------------------------\n");
248 248 } }
249 static void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt,
249 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,
251 251 bool print_info) bool print_info)
252 252 { {
 
... ... static void pcm2ff(snd_pcm_t *pcm, enum avutil_audio_fr_fmt_t *ff_fmt,
289 289 } }
290 290 /* we do per-loop fine-grained locking */ /* we do per-loop fine-grained locking */
291 291 #define sz size #define sz size
292 static void pkts_send(void) { loop
292 STATIC void pkts_send(void) { loop
293 293 { {
294 294 int r; int r;
295 295 avcodec_pkt_ref_t *pr; avcodec_pkt_ref_t *pr;
296 296
297 pkt_q_lock(pkt_q_p);
297 npv_pkt_q_lock(pkt_q_p);
298 298 if (pkt_q_p->n == 0) if (pkt_q_p->n == 0)
299 299 goto unlock_and_return; goto unlock_and_return;
300 300 pr = pkt_q_p->q[0]; pr = pkt_q_p->q[0];
 
... ... static void pkts_send(void) { loop
308 308 else if (r != 0) else if (r != 0)
309 309 FATALA("error while sending a packet to the decoder\n"); FATALA("error while sending a packet to the decoder\n");
310 310 /* r == 0 */ /* r == 0 */
311 pipeline_limits_lock();
312 pipeline_limits_p.pkts.audio_bytes_n -= pr->sz;
313 pipeline_limits_unlock();
311 npv_pipeline_limits_lock();
312 npv_pipeline_limits_p.pkts.audio_bytes_n -= pr->sz;
313 npv_pipeline_limits_unlock();
314 314
315 pkt_q_deq(pkt_q_p);
315 npv_pkt_q_deq(pkt_q_p);
316 316 avcodec_pkt_unref(pr); avcodec_pkt_unref(pr);
317 pkt_q_unlock(pkt_q_p);
317 npv_pkt_q_unlock(pkt_q_p);
318 318 continue; continue;
319 319
320 320 unlock_and_return: unlock_and_return:
321 pkt_q_unlock(pkt_q_p);
321 npv_pkt_q_unlock(pkt_q_p);
322 322 return; return;
323 323 }} }}
324 324 #undef sz #undef sz
File npv/audio/public/state.frag.h changed (mode: 100644) (index 4a009ad..60d54e3)
1 static avcodec_codec_ctx_t *dec_ctx_p;
2 static struct {
1 STATIC avcodec_codec_ctx_t *dec_ctx_p;
2 STATIC struct {
3 3 pthread_mutex_t mutex; pthread_mutex_t mutex;
4 4
5 5 bool eof_receive; /* "receiving" from the dec returned eof */ bool eof_receive; /* "receiving" from the dec returned eof */
 
... ... static struct {
7 7 u32 n; u32 n;
8 8 avutil_audio_set_ref_t **a; avutil_audio_set_ref_t **a;
9 9 } dec_sets_p; } dec_sets_p;
10 static struct pkt_q_t *pkt_q_p;
10 STATIC struct npv_pkt_q_t *pkt_q_p;
11 11 /* /*
12 12 * we copy some stream data in the case the stream does vanish or is replaced * we copy some stream data in the case the stream does vanish or is replaced
13 13 * (don't know how ffmpeg does handle this) * (don't know how ffmpeg does handle this)
14 14 */ */
15 static struct {
15 STATIC struct {
16 16 int idx; int idx;
17 17 int id; int id;
18 18 avutil_rational_t tb; avutil_rational_t tb;
 
... ... static struct {
20 20 } st_p; } st_p;
21 21 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
22 22 /* alsa -- start */ /* alsa -- start */
23 static snd_pcm_t *pcm_p;
23 STATIC snd_pcm_t *pcm_p;
24 24 constant_u32 { constant_u32 {
25 25 pcm_pollfds_n_max = 16 /* banzai */ pcm_pollfds_n_max = 16 /* banzai */
26 26 }; };
27 static bool draining_p;
28 static int draining_timer_fd_p;
29 static u8 pcm_pollfds_n_p;
30 static struct pollfd pcm_pollfds_p[pcm_pollfds_n_max];
31 static s8 selected_ts_type_p;
27 STATIC bool draining_p;
28 STATIC int draining_timer_fd_p;
29 STATIC u8 pcm_pollfds_n_p;
30 STATIC struct pollfd pcm_pollfds_p[pcm_pollfds_n_max];
31 STATIC s8 selected_ts_type_p;
32 32 /* alsa -- end */ /* alsa -- end */
33 33 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
File npv/clk/local/state.frag.c changed (mode: 100644) (index 18572f9..209a0de)
2 2 * considered to be shared by all the thds: we spin because it is supposed to * considered to be shared by all the thds: we spin because it is supposed to
3 3 * be short * be short
4 4 */ */
5 static struct {
5 STATIC struct {
6 6 /* /*
7 7 * 2 points in the time domain: * 2 points in the time domain:
8 8 * - ref * - ref
 
... ... static struct {
29 29 struct { struct {
30 30 snd_pcm_status_t *status; snd_pcm_status_t *status;
31 31 } now; } now;
32 } clk_l;
33 static snd_pcm_hw_params_t *clk_pcm_hw_params_l;
32 } npv_clk_l;
33 STATIC snd_pcm_hw_params_t *npv_clk_pcm_hw_params_l;
File npv/clk/public.h changed (mode: 100644) (index 2e6640c..bae0b52)
6 6 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
7 7 #include "npv/namespace/alsa.h" #include "npv/namespace/alsa.h"
8 8 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
9 static void clk_init_once(void);
10 static u8 clk_get_audio_st_ts(s64 *ts);
11 static u8 clk_get_video_st_ts(s64 *ts);
12 static void clk_ref_time_point_update(s64 audio_ts,
9 STATIC void npv_clk_init_once(void);
10 STATIC u8 npv_clk_get_audio_st_ts(s64 *ts);
11 STATIC u8 npv_clk_get_video_st_ts(s64 *ts);
12 STATIC void npv_clk_ref_time_point_update(s64 audio_ts,
13 13 snd_pcm_ufrs_t written_ufrs_n); snd_pcm_ufrs_t written_ufrs_n);
14 static void clk_invalidate(void);
15 static void clk_pause(void);
16 static void clk_unpause(void);
14 STATIC void npv_clk_invalidate(void);
15 STATIC void npv_clk_pause(void);
16 STATIC void npv_clk_unpause(void);
17 17 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
18 18 #define CLEANUP #define CLEANUP
19 19 #include "npv/namespace/alsa.h" #include "npv/namespace/alsa.h"
File npv/clk/public/code.frag.c changed (mode: 100644) (index 90df049..bbdb09a)
1 static void clk_init_once(void)
1 STATIC void npv_clk_init_once(void)
2 2 { {
3 3 int r; int r;
4 4
5 r = snd_pcm_status_malloc(&clk_l.ref.status);
5 r = snd_pcm_status_malloc(&npv_clk_l.ref.status);
6 6 if (r != 0) if (r != 0)
7 7 FATALCLK("alsa:unable to allocate an alsa status structure\n"); FATALCLK("alsa:unable to allocate an alsa status structure\n");
8 r = snd_pcm_status_malloc(&clk_l.now.status);
8 r = snd_pcm_status_malloc(&npv_clk_l.now.status);
9 9 if (r != 0) if (r != 0)
10 10 FATALCLK("alsa:unable to allocate an alsa status structure\n"); FATALCLK("alsa:unable to allocate an alsa status structure\n");
11 11 /* we pre-allocate alsa pcm hw_params container */ /* we pre-allocate alsa pcm hw_params container */
12 r = snd_pcm_hw_params_malloc(&clk_pcm_hw_params_l);
12 r = snd_pcm_hw_params_malloc(&npv_clk_pcm_hw_params_l);
13 13 if (r < 0) if (r < 0)
14 14 FATALCLK("alsa:unable to allocate hardware parameters context\n"); FATALCLK("alsa:unable to allocate hardware parameters context\n");
15 clk_l.paused = false;
15 npv_clk_l.paused = false;
16 16 } }
17 17 #define NO_REF_TIME_POINT 1 #define NO_REF_TIME_POINT 1
18 static u8 clk_get_audio_st_ts(s64 *ts)
18 STATIC u8 npv_clk_get_audio_st_ts(s64 *ts)
19 19 { {
20 20 int r; int r;
21 21 snd_pcm_audio_tstamp_config_t ac; snd_pcm_audio_tstamp_config_t ac;
 
... ... static u8 clk_get_audio_st_ts(s64 *ts)
35 35 f64 now_audio_ts; f64 now_audio_ts;
36 36 f64 now_video_ts; f64 now_video_ts;
37 37
38 if (!clk_l.ref_valid)
38 if (!npv_clk_l.ref_valid)
39 39 return NO_REF_TIME_POINT; return NO_REF_TIME_POINT;
40 if (!clk_l.paused) {
41 memset(clk_l.now.status, 0, snd_pcm_status_sizeof());
40 if (!npv_clk_l.paused) {
41 memset(npv_clk_l.now.status, 0, snd_pcm_status_sizeof());
42 42 ac.report_delay = 0; ac.report_delay = 0;
43 ac.type_requested = (unsigned int)audio_selected_ts_type_p;
44 snd_pcm_status_set_audio_htstamp_config(clk_l.now.status, &ac);
45 r = snd_pcm_status(audio_pcm_p, clk_l.now.status);
43 ac.type_requested = (unsigned int)npv_audio_selected_ts_type_p;
44 snd_pcm_status_set_audio_htstamp_config(npv_clk_l.now.status,
45 &ac);
46 r = snd_pcm_status(npv_audio_pcm_p, npv_clk_l.now.status);
46 47 if (r < 0) if (r < 0)
47 48 FATALCLK("alsa:unable to sample timing information for 'now' time point\n"); FATALCLK("alsa:unable to sample timing information for 'now' time point\n");
48 49 } }
49 snd_pcm_status_get_audio_htstamp(clk_l.now.status, &hts);
50 snd_pcm_status_get_audio_htstamp(npv_clk_l.now.status, &hts);
50 51 now_ns = (f64)hts.tv_sec * 1e9 + (f64)hts.tv_nsec; now_ns = (f64)hts.tv_sec * 1e9 + (f64)hts.tv_nsec;
51 52
52 snd_pcm_status_get_audio_htstamp(clk_l.ref.status, &hts);
53 snd_pcm_status_get_audio_htstamp(npv_clk_l.ref.status, &hts);
53 54 ref_status_ns = (f64)hts.tv_sec * 1e9 + (f64)hts.tv_nsec; ref_status_ns = (f64)hts.tv_sec * 1e9 + (f64)hts.tv_nsec;
54 55
55 ref_audio_ts = (f64)clk_l.ref.audio_st_ts;
56 ref_delay_frs_n = (f64)snd_pcm_status_get_delay(clk_l.ref.status);
57 audio_tb_num = (f64)audio_st_p.tb.num;
58 audio_tb_den = (f64)audio_st_p.tb.den;
56 ref_audio_ts = (f64)npv_clk_l.ref.audio_st_ts;
57 ref_delay_frs_n = (f64)snd_pcm_status_get_delay(npv_clk_l.ref.status);
58 audio_tb_num = (f64)npv_audio_st_p.tb.num;
59 audio_tb_den = (f64)npv_audio_st_p.tb.den;
59 60 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
60 r = snd_pcm_hw_params_current(audio_pcm_p, clk_pcm_hw_params_l);
61 r = snd_pcm_hw_params_current(npv_audio_pcm_p, npv_clk_pcm_hw_params_l);
61 62 if (r != 0) if (r != 0)
62 63 FATALCLK("alsa:unable to get current hardware parameters\n"); FATALCLK("alsa:unable to get current hardware parameters\n");
63 r = snd_pcm_hw_params_get_rate_numden(clk_pcm_hw_params_l,
64 r = snd_pcm_hw_params_get_rate_numden(npv_clk_pcm_hw_params_l,
64 65 &audio_rate_num_ui, &audio_rate_den_ui); &audio_rate_num_ui, &audio_rate_den_ui);
65 66 if (r < 0) if (r < 0)
66 67 FATALCLK("alsa:unable to get exact rate\n"); FATALCLK("alsa:unable to get exact rate\n");
67 68 audio_rate_num = (f64)audio_rate_num_ui; audio_rate_num = (f64)audio_rate_num_ui;
68 69 audio_rate_den = (f64)audio_rate_den_ui; audio_rate_den = (f64)audio_rate_den_ui;
69 70 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
70 written_frs_n = (f64)clk_l.ref.written_ufrs_n;
71 written_frs_n = (f64)npv_clk_l.ref.written_ufrs_n;
71 72
72 73 /* time translation */ /* time translation */
73 74 ref_ns = ref_status_ns + (ref_delay_frs_n - written_frs_n) ref_ns = ref_status_ns + (ref_delay_frs_n - written_frs_n)
 
... ... static u8 clk_get_audio_st_ts(s64 *ts)
79 80 return TS_RETURNED; return TS_RETURNED;
80 81 } }
81 82 #undef NO_REF_TIME_POINT #undef NO_REF_TIME_POINT
82 static u8 clk_get_video_st_ts(s64 *ts)
83 STATIC u8 npv_clk_get_video_st_ts(s64 *ts)
83 84 { {
84 85 f64 audio_tb_num; f64 audio_tb_num;
85 86 f64 audio_tb_den; f64 audio_tb_den;
 
... ... static u8 clk_get_video_st_ts(s64 *ts)
90 91 f64 now_video_ts; f64 now_video_ts;
91 92 u8 r; u8 r;
92 93
93 audio_tb_num = (f64)audio_st_p.tb.num;
94 audio_tb_den = (f64)audio_st_p.tb.den;
95 video_tb_num = (f64)video_st_p.tb.num;
96 video_tb_den = (f64)video_st_p.tb.den;
94 audio_tb_num = (f64)npv_audio_st_p.tb.num;
95 audio_tb_den = (f64)npv_audio_st_p.tb.den;
96 video_tb_num = (f64)npv_video_st_p.tb.num;
97 video_tb_den = (f64)npv_video_st_p.tb.den;
97 98
98 r = clk_get_audio_st_ts(&now_audio_ts_s64);
99 r = npv_clk_get_audio_st_ts(&now_audio_ts_s64);
99 100 if (r != TS_RETURNED) if (r != TS_RETURNED)
100 101 return r; return r;
101 102 now_audio_ts = (f64)now_audio_ts_s64; now_audio_ts = (f64)now_audio_ts_s64;
 
... ... static u8 clk_get_video_st_ts(s64 *ts)
105 106 *ts = (s64)lrint(now_video_ts); *ts = (s64)lrint(now_video_ts);
106 107 return TS_RETURNED; return TS_RETURNED;
107 108 } }
108 static void clk_ref_time_point_update(s64 audio_ts,
109 STATIC void npv_clk_ref_time_point_update(s64 audio_ts,
109 110 snd_pcm_ufrs_t written_ufrs_n) snd_pcm_ufrs_t written_ufrs_n)
110 111 { {
111 112 int r; int r;
112 113 snd_pcm_audio_tstamp_config_t ac; snd_pcm_audio_tstamp_config_t ac;
113 114
114 memset(clk_l.ref.status, 0, snd_pcm_status_sizeof());
115 memset(npv_clk_l.ref.status, 0, snd_pcm_status_sizeof());
115 116 ac.report_delay = 0; ac.report_delay = 0;
116 ac.type_requested = (unsigned int)audio_selected_ts_type_p;
117 snd_pcm_status_set_audio_htstamp_config(clk_l.ref.status, &ac);
118 r = snd_pcm_status(audio_pcm_p, clk_l.ref.status);
117 ac.type_requested = (unsigned int)npv_audio_selected_ts_type_p;
118 snd_pcm_status_set_audio_htstamp_config(npv_clk_l.ref.status, &ac);
119 r = snd_pcm_status(npv_audio_pcm_p, npv_clk_l.ref.status);
119 120 if (r < 0) if (r < 0)
120 121 FATALCLK("unable to sample timing information for reference time point\n"); FATALCLK("unable to sample timing information for reference time point\n");
121 clk_l.ref.audio_st_ts = audio_ts;
122 clk_l.ref.written_ufrs_n = written_ufrs_n;
123 clk_l.ref_valid = true;
122 npv_clk_l.ref.audio_st_ts = audio_ts;
123 npv_clk_l.ref.written_ufrs_n = written_ufrs_n;
124 npv_clk_l.ref_valid = true;
124 125 } }
125 static void clk_invalidate(void)
126 STATIC void npv_clk_invalidate(void)
126 127 { {
127 clk_l.ref_valid = false;
128 npv_clk_l.ref_valid = false;
128 129 } }
129 static void clk_pause(void)
130 STATIC void npv_clk_pause(void)
130 131 { {
131 132 int r; int r;
132 133 snd_pcm_audio_tstamp_config_t ac; snd_pcm_audio_tstamp_config_t ac;
133 134
134 clk_l.paused = true;
135 memset(clk_l.now.status, 0, snd_pcm_status_sizeof());
135 npv_clk_l.paused = true;
136 memset(npv_clk_l.now.status, 0, snd_pcm_status_sizeof());
136 137 ac.report_delay = 0; ac.report_delay = 0;
137 ac.type_requested = (unsigned int)audio_selected_ts_type_p;
138 snd_pcm_status_set_audio_htstamp_config(clk_l.now.status, &ac);
139 r = snd_pcm_status(audio_pcm_p, clk_l.now.status);
138 ac.type_requested = (unsigned int)npv_audio_selected_ts_type_p;
139 snd_pcm_status_set_audio_htstamp_config(npv_clk_l.now.status, &ac);
140 r = snd_pcm_status(npv_audio_pcm_p, npv_clk_l.now.status);
140 141 if (r < 0) if (r < 0)
141 142 FATALCLK("alsa:unable to sample timing information for 'paused' time point\n"); FATALCLK("alsa:unable to sample timing information for 'paused' time point\n");
142 143 } }
143 static void clk_unpause(void)
144 STATIC void npv_clk_unpause(void)
144 145 { {
145 clk_l.paused = false;
146 clk_invalidate();
146 npv_clk_l.paused = false;
147 npv_clk_invalidate();
147 148 } }
File npv/config.h changed (mode: 100644) (index e32c808..8aadf23)
4 4 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
5 5 /* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */ /* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */
6 6 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
7 static void cmd_quit(void);
8 static void cmd_rewind(void);
9 static void cmd_fastforward(void);
10 static void cmd_rewind_big(void);
11 static void cmd_fastforward_big(void);
12 static void cmd_vol_up(void);
13 static void cmd_vol_down(void);
14 static void cmd_mute(void);
15 static void cmd_info(void);
16 static void cmd_pause(void);
17 static void cmd_fullscreen_toggle(void);
7 STATIC void npv_cmd_quit(void);
8 STATIC void npv_cmd_rewind(void);
9 STATIC void npv_cmd_fastforward(void);
10 STATIC void npv_cmd_rewind_big(void);
11 STATIC void npv_cmd_fastforward_big(void);
12 STATIC void npv_cmd_vol_up(void);
13 STATIC void npv_cmd_vol_down(void);
14 STATIC void npv_cmd_mute(void);
15 STATIC void npv_cmd_info(void);
16 STATIC void npv_cmd_pause(void);
17 STATIC void npv_cmd_fullscreen_toggle(void);
18 18 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
19 19 /* for documentation and example */ /* for documentation and example */
20 20 #define LINUX_KEY_ESC 0x01 #define LINUX_KEY_ESC 0x01
 
... ... static void cmd_fullscreen_toggle(void);
23 23 #define X11_KEYCODE_ESC (LINUX_KEY_ESC + 8) #define X11_KEYCODE_ESC (LINUX_KEY_ESC + 8)
24 24 #define X11_KEYCODE_SPACE (LINUX_KEY_SPACE + 8) #define X11_KEYCODE_SPACE (LINUX_KEY_SPACE + 8)
25 25 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
26 struct x11_bind_t {
26 struct npv_x11_bind_t {
27 27 u8 keycode; /* the 8bits truncated raw keycode */ u8 keycode; /* the 8bits truncated raw keycode */
28 28 u8 *name; /* friendly name */ u8 *name; /* friendly name */
29 29 void (*cmd)(void); /* bound cmd */ void (*cmd)(void); /* bound cmd */
30 30 }; };
31 31 #define X11_BIND(x, y, z) {.keycode = x, .name = y, .cmd = z} #define X11_BIND(x, y, z) {.keycode = x, .name = y, .cmd = z}
32 struct x11_bind_t x11_binds[] = {
33 X11_BIND(X11_KEYCODE_ESC, "escape", cmd_quit),
34 X11_BIND(X11_KEYCODE_SPACE, "space", cmd_pause),
35 X11_BIND(0x71, "arrow left", cmd_rewind),
36 X11_BIND(0x72, "arrow right", cmd_fastforward),
37 X11_BIND(0x6e, "home", cmd_rewind_big),
38 X11_BIND(0x73, "end", cmd_fastforward_big),
39 X11_BIND(0x6f, "arrow up", cmd_vol_up),
40 X11_BIND(0x74, "arrow down", cmd_vol_down),
41 X11_BIND(0x3a, "arrow down", cmd_mute),
42 X11_BIND(0x2a, "letter i", cmd_info),
43 X11_BIND(0x5f, "f11", cmd_fullscreen_toggle)
32 struct npv_x11_bind_t npv_x11_binds[] = {
33 X11_BIND(X11_KEYCODE_ESC, "escape", npv_cmd_quit),
34 X11_BIND(X11_KEYCODE_SPACE, "space", npv_cmd_pause),
35 X11_BIND(0x71, "arrow left", npv_cmd_rewind),
36 X11_BIND(0x72, "arrow right", npv_cmd_fastforward),
37 X11_BIND(0x6e, "home", npv_cmd_rewind_big),
38 X11_BIND(0x73, "end", npv_cmd_fastforward_big),
39 X11_BIND(0x6f, "arrow up", npv_cmd_vol_up),
40 X11_BIND(0x74, "arrow down", npv_cmd_vol_down),
41 X11_BIND(0x3a, "arrow down", npv_cmd_mute),
42 X11_BIND(0x2a, "letter i", npv_cmd_info),
43 X11_BIND(0x5f, "f11", npv_cmd_fullscreen_toggle)
44 44 }; };
45 45 #undef X11_BIND #undef X11_BIND
46 46 #undef LINUX_KEY_ESC #undef LINUX_KEY_ESC
File npv/fmt/local/code.frag.c changed (mode: 100644) (index 9b8a611..8fc394e)
1 static void init_once_public(u8 *url)
1 STATIC bool did_reached_limits(void)
2 {
3 bool r;
4
5 npv_pipeline_limits_lock();
6 if (npv_pipeline_limits_p.pkts.audio_bytes_n
7 >= npv_pipeline_limits_p.pkts.limit.audio_bytes_n
8 && npv_pipeline_limits_p.pkts.video_bytes_n
9 >= npv_pipeline_limits_p.pkts.limit.video_bytes_n)
10 r = true;
11 else
12 r = false;
13 npv_pipeline_limits_unlock();
14 return false;
15 }
16 STATIC void init_once_public(u8 *url)
2 17 { {
3 18 int r; int r;
4 19
 
... ... static void init_once_public(u8 *url)
10 25 if (r != 0) if (r != 0)
11 26 FATALF("unable to init the format mutex\n"); FATALF("unable to init the format mutex\n");
12 27 } }
13 static void init_once_local(void)
28 STATIC void init_once_local(void)
14 29 { {
15 30 pkt_l = avcodec_pkt_ref_alloc(); pkt_l = avcodec_pkt_ref_alloc();
16 31 if (pkt_l == 0) if (pkt_l == 0)
17 32 FATALF("ffmpeg:unable to allocate a reference on a packet for encoded/compressed audio/video\n"); FATALF("ffmpeg:unable to allocate a reference on a packet for encoded/compressed audio/video\n");
18 33 } }
19 static void ctx_lock(void)
20 {
21 int r;
22
23 r = pthread_mutex_lock(&ctx_mutex_l);
24 if (r != 0)
25 FATALF("%d:unable to lock the format context\n", r);
26 }
27 static void ctx_unlock(void)
28 {
29 int r;
30
31 r = pthread_mutex_unlock(&ctx_mutex_l);
32 if (r != 0)
33 FATALF("%d:unable to unlock the format context\n", r);
34 }
File npv/fmt/local/state.frag.c changed (mode: 100644) (index 15fd6ab..833da34)
1 static avcodec_pkt_ref_t *pkt_l;
2 static pthread_mutex_t ctx_mutex_l;
1 STATIC avcodec_pkt_ref_t *pkt_l;
2 STATIC pthread_mutex_t ctx_mutex_l;
File npv/fmt/main.c changed (mode: 100644) (index e01fc75..f5b0c4d)
27 27 #include "npv/fmt/local/code.frag.c" #include "npv/fmt/local/code.frag.c"
28 28 #include "npv/fmt/public/code.frag.c" #include "npv/fmt/public/code.frag.c"
29 29 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
30 #undef FATALF
31 #undef WARNINGF
32 #undef POUTF
33 /*----------------------------------------------------------------------------*/
30 34 #define CLEANUP #define CLEANUP
31 35 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
32 36 #include "npv/fmt/namespace/public.h" #include "npv/fmt/namespace/public.h"
File npv/fmt/namespace/main.c changed (mode: 100644) (index 1399a6c..c35dab9)
8 8 #define sts_n nb_streams #define sts_n nb_streams
9 9 #define sz size #define sz size
10 10 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
11 #define audio fmt_break_on_audio
12 #define ctx_mutex_l fmt_ctx_mutex_l
13 #define pkt_l fmt_pkt_l
14 #define video fmt_break_on_video
11 #define audio npv_fmt_break_on_audio
12 #define ctx_mutex_l npv_fmt_ctx_mutex_l
13 #define did_reached_limits npv_fmt_did_reached_limits
14 #define pkt_l npv_fmt_pkt_l
15 #define video npv_fmt_break_on_video
15 16 /*============================================================================*/ /*============================================================================*/
16 17 #else #else
17 18 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
 
24 25 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
25 26 #undef audio #undef audio
26 27 #undef ctx_mutex_l #undef ctx_mutex_l
28 #undef did_reached_limits
27 29 #undef pkt_l #undef pkt_l
28 30 #undef video #undef video
29 31 #endif #endif
File npv/fmt/namespace/public.h changed (mode: 100644) (index 83e463a..ce9683c)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define break_on_audio fmt_break_on_audio
3 #define break_on_video fmt_break_on_video
4 #define ctx_lock fmt_ctx_lock
5 #define ctx_p fmt_ctx_p
6 #define ctx_unlock fmt_ctx_unlock
7 #define duration_estimate_to_str fmt_duration_estimate_to_str
8 #define flush fmt_flush
9 #define init_once fmt_init_once
10 #define init_once_local fmt_init_once_local
11 #define init_once_public fmt_init_once_public
12 #define pkts_read_and_q fmt_pkts_read_and_q
13 #define probe_best_sts fmt_probe_best_sts
2 #define break_on_audio npv_fmt_break_on_audio
3 #define break_on_video npv_fmt_break_on_video
4 #define ctx_lock npv_fmt_ctx_lock
5 #define ctx_p npv_fmt_ctx_p
6 #define ctx_unlock npv_fmt_ctx_unlock
7 #define duration_estimate_to_str npv_fmt_duration_estimate_to_str
8 #define flush npv_fmt_flush
9 #define init_once npv_fmt_init_once
10 #define init_once_local npv_fmt_init_once_local
11 #define init_once_public npv_fmt_init_once_public
12 #define pkts_read_and_q npv_fmt_pkts_read_and_q
13 #define probe_best_sts npv_fmt_probe_best_sts
14 14 /*============================================================================*/ /*============================================================================*/
15 15 #else #else
16 16 #undef break_on_audio #undef break_on_audio
File npv/fmt/public.h changed (mode: 100644) (index 24b6b9d..3363f9e)
13 13 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
14 14 #include "npv/fmt/public/state.frag.h" #include "npv/fmt/public/state.frag.h"
15 15 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
16 static u8 *duration_estimate_to_str(
16 STATIC u8 *duration_estimate_to_str(
17 17 enum avformat_duration_estimation_method_t m); enum avformat_duration_estimation_method_t m);
18 static void probe_best_sts(
18 STATIC void probe_best_sts(
19 19 int *best_v_idx, int *best_v_id, avutil_rational_t **best_v_tb, int *best_v_idx, int *best_v_id, avutil_rational_t **best_v_tb,
20 20 int64_t *best_v_start_time, avcodec_params_t **best_v_codec_params, int64_t *best_v_start_time, avcodec_params_t **best_v_codec_params,
21 21 int *best_a_idx, int *best_a_id, avutil_rational_t **best_a_tb, int *best_a_idx, int *best_a_id, avutil_rational_t **best_a_tb,
22 22 int64_t *best_a_start_time, avcodec_params_t **best_a_codec_params); int64_t *best_a_start_time, avcodec_params_t **best_a_codec_params);
23 static void init_once(u8 *url);
24 static u8 pkts_read_and_q(void);
25 static void flush(void);
26 static void fmt_ctx_lock(void);
27 static void fmt_ctx_unlock(void);
23 STATIC void init_once(u8 *url);
24 STATIC u8 pkts_read_and_q(void);
25 STATIC void flush(void);
26 STATIC void ctx_lock(void);
27 STATIC void ctx_unlock(void);
28 28 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
29 29 #define CLEANUP #define CLEANUP
30 30 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/fmt/public/code.frag.c changed (mode: 100644) (index 8370517..243f6e1)
1 static u8 *duration_estimate_to_str(enum avformat_duration_estimation_method_t
1 STATIC void ctx_lock(void)
2 {
3 int r;
4
5 r = pthread_mutex_lock(&ctx_mutex_l);
6 if (r != 0)
7 FATALF("%d:unable to lock the format context\n", r);
8 }
9 STATIC void ctx_unlock(void)
10 {
11 int r;
12
13 r = pthread_mutex_unlock(&ctx_mutex_l);
14 if (r != 0)
15 FATALF("%d:unable to unlock the format context\n", r);
16 }
17 STATIC u8 *duration_estimate_to_str(enum avformat_duration_estimation_method_t
2 18 m) m)
3 19 { {
4 20 switch (m) { switch (m) {
 
... ... static u8 *duration_estimate_to_str(enum avformat_duration_estimation_method_t
12 28 return "unkwown"; return "unkwown";
13 29 } }
14 30 } }
15 /*NSPC*/
16 static bool did_reached_limits(void)
17 {
18 bool r;
19
20 pipeline_limits_lock();
21 if (pipeline_limits_p.pkts.audio_bytes_n
22 >= pipeline_limits_p.pkts.limit.audio_bytes_n
23 && pipeline_limits_p.pkts.video_bytes_n
24 >= pipeline_limits_p.pkts.limit.video_bytes_n)
25 r = true;
26 else
27 r = false;
28 pipeline_limits_unlock();
29 return false;
30 }
31 31 #define AGAIN 0 #define AGAIN 0
32 32 #define LIMITS_REACHED 1 #define LIMITS_REACHED 1
33 33 #define EOF_FMT 2 #define EOF_FMT 2
 
... ... static bool did_reached_limits(void)
35 35 * we don't want to lock any pkt q for too long, then we do finer-grained * we don't want to lock any pkt q for too long, then we do finer-grained
36 36 * locking here * locking here
37 37 */ */
38 static u8 pkts_read_and_q(void) { loop
38 STATIC u8 pkts_read_and_q(void) { loop
39 39 { {
40 40 int r; int r;
41 41
 
... ... static u8 pkts_read_and_q(void) { loop
52 52 else if (r != 0) else if (r != 0)
53 53 FATALF("ffmpeg:error while reading coded/compressed data into packets\n"); FATALF("ffmpeg:error while reading coded/compressed data into packets\n");
54 54 /* r == 0 */ /* r == 0 */
55 if (pkt_l->st_idx == audio_st_p.idx) {
56 pipeline_limits_lock();
57 pipeline_limits_p.pkts.audio_bytes_n += (u64)pkt_l->sz;
58 if (pipeline_limits_p.pkts.prefill.audio_bytes_rem > 0)
59 pipeline_limits_p.pkts.prefill.audio_bytes_rem -=
55 if (pkt_l->st_idx == npv_audio_st_p.idx) {
56 npv_pipeline_limits_lock();
57 npv_pipeline_limits_p.pkts.audio_bytes_n += (u64)pkt_l->sz;
58 if (npv_pipeline_limits_p.pkts.prefill.audio_bytes_rem > 0)
59 npv_pipeline_limits_p.pkts.prefill.audio_bytes_rem -=
60 60 (s64)pkt_l->sz; (s64)pkt_l->sz;
61 pipeline_limits_unlock();
61 npv_pipeline_limits_unlock();
62 62
63 pkt_q_lock(audio_pkt_q_p);
63 npv_pkt_q_lock(npv_audio_pkt_q_p);
64 64 /* will "steal" the pkt */ /* will "steal" the pkt */
65 pkt_q_enq(audio_pkt_q_p, pkt_l);
66 pkt_q_unlock(audio_pkt_q_p);
67 } else if (pkt_l->st_idx == video_st_p.idx) {
68 pipeline_limits_lock();
69 pipeline_limits_p.pkts.video_bytes_n += (u64)pkt_l->sz;
70 if (pipeline_limits_p.pkts.prefill.video_bytes_rem > 0)
71 pipeline_limits_p.pkts.prefill.video_bytes_rem -=
65 npv_pkt_q_enq(npv_audio_pkt_q_p, pkt_l);
66 npv_pkt_q_unlock(npv_audio_pkt_q_p);
67 } else if (pkt_l->st_idx == npv_video_st_p.idx) {
68 npv_pipeline_limits_lock();
69 npv_pipeline_limits_p.pkts.video_bytes_n += (u64)pkt_l->sz;
70 if (npv_pipeline_limits_p.pkts.prefill.video_bytes_rem > 0)
71 npv_pipeline_limits_p.pkts.prefill.video_bytes_rem -=
72 72 (s64)pkt_l->sz; (s64)pkt_l->sz;
73 pipeline_limits_unlock();
73 npv_pipeline_limits_unlock();
74 74
75 pkt_q_lock(video_pkt_q_p);
75 npv_pkt_q_lock(npv_video_pkt_q_p);
76 76 /* will "steal" the pkt */ /* will "steal" the pkt */
77 pkt_q_enq(video_pkt_q_p, pkt_l);
78 pkt_q_unlock(video_pkt_q_p);
77 npv_pkt_q_enq(npv_video_pkt_q_p, pkt_l);
78 npv_pkt_q_unlock(npv_video_pkt_q_p);
79 79 } else /* data, subtitles, non active sts, etc */ } else /* data, subtitles, non active sts, etc */
80 80 avcodec_pkt_unref(pkt_l); avcodec_pkt_unref(pkt_l);
81 81 }} }}
82 82 #undef AGAIN #undef AGAIN
83 83 #undef LIMITS_REACHED #undef LIMITS_REACHED
84 84 #undef EOF_FMT #undef EOF_FMT
85 static void probe_best_sts(
85 STATIC void probe_best_sts(
86 86 int *best_v_idx, int *best_v_id, avutil_rational_t **best_v_tb, int *best_v_idx, int *best_v_id, avutil_rational_t **best_v_tb,
87 87 int64_t *best_v_start_time, avcodec_params_t **best_v_codec_params, int64_t *best_v_start_time, avcodec_params_t **best_v_codec_params,
88 88 int *best_a_idx, int *best_a_id, avutil_rational_t **best_a_tb, int *best_a_idx, int *best_a_id, avutil_rational_t **best_a_tb,
 
... ... static void probe_best_sts(
118 118 POUTF("####%s#### probing: %u streams and %u programs\n", ctx_p->url, ctx_p->sts_n, ctx_p->programs_n); POUTF("####%s#### probing: %u streams and %u programs\n", ctx_p->url, ctx_p->sts_n, ctx_p->programs_n);
119 119 POUTF("####%s#### probing: best video stream index=%d/id=%d, best audio stream index=%d/id=%d\n", ctx_p->url, *best_v_idx, *best_v_id, *best_a_idx, *best_a_id); POUTF("####%s#### probing: best video stream index=%d/id=%d, best audio stream index=%d/id=%d\n", ctx_p->url, *best_v_idx, *best_v_id, *best_a_idx, *best_a_id);
120 120 } }
121 static void flush(void)
121 STATIC void flush(void)
122 122 { {
123 123 avformat_flush(ctx_p); avformat_flush(ctx_p);
124 124 avio_flush(ctx_p->pb); avio_flush(ctx_p->pb);
125 125 } }
126 static void init_once(u8 *url)
126 STATIC void init_once(u8 *url)
127 127 { {
128 128 init_once_public(url); init_once_public(url);
129 129 init_once_local(); init_once_local();
File npv/fmt/public/state.frag.h changed (mode: 100644) (index 200fb63..c4edad5)
1 static avformat_ctx_t *ctx_p;
1 STATIC avformat_ctx_t *ctx_p;
File npv/local/code.frag.c changed (mode: 100644) (index 73bce97..4a8a174)
6 6 * always presume the process "controlling terminal" is different than the * always presume the process "controlling terminal" is different than the
7 7 * terminal connected on standard input and standard output * terminal connected on standard input and standard output
8 8 */ */
9 /*NSPC*/
10 static void sigs_init_once(void)
9 STATIC void sigs_init_once(void)
11 10 { {
12 11 int r; int r;
13 12 sigset_t sset; sigset_t sset;
 
... ... static void sigs_init_once(void)
44 43 FATAL("unable to get a signalfd file descriptor\n"); FATAL("unable to get a signalfd file descriptor\n");
45 44 sig_fd_l = r; sig_fd_l = r;
46 45 } }
47 /*NSPC*/
48 static void prefill_wait(void) { loop
46 STATIC void prefill_wait(void) { loop
49 47 { {
50 48 struct timespec wanted; struct timespec wanted;
51 49 struct timespec rem; struct timespec rem;
52 50 s64 prefill_audio; s64 prefill_audio;
53 51 s64 prefill_video; s64 prefill_video;
54 52
55 pipeline_limits_lock();
56 prefill_audio = pipeline_limits_p.pkts.prefill.audio_bytes_rem;
57 prefill_video = pipeline_limits_p.pkts.prefill.video_bytes_rem;
58 pipeline_limits_unlock();
53 npv_pipeline_limits_lock();
54 prefill_audio = npv_pipeline_limits_p.pkts.prefill.audio_bytes_rem;
55 prefill_video = npv_pipeline_limits_p.pkts.prefill.video_bytes_rem;
56 npv_pipeline_limits_unlock();
59 57 if (prefill_audio <= 0 && prefill_video <= 0) if (prefill_audio <= 0 && prefill_video <= 0)
60 58 break; break;
61 59 memset(&wanted, 0, sizeof(wanted)); memset(&wanted, 0, sizeof(wanted));
 
... ... static void prefill_wait(void) { loop
75 73 memset(&rem, 0, sizeof(rem)); memset(&rem, 0, sizeof(rem));
76 74 } }
77 75 }} }}
78 /*NSPC*/
79 static void predecode_wait(void)
76 STATIC void predecode_wait(void)
80 77 { {
81 78 struct timespec wanted; struct timespec wanted;
82 79 struct timespec rem; struct timespec rem;
 
... ... static void predecode_wait(void)
99 96 memset(&rem, 0, sizeof(rem)); memset(&rem, 0, sizeof(rem));
100 97 } }
101 98 } }
102 /*NSPC*/
103 static void evt_init_once(void)
99 STATIC void evt_init_once(void)
104 100 { {
105 101 ep_fd_p = epoll_create1(0); ep_fd_p = epoll_create1(0);
106 102 if (ep_fd_p == -1) if (ep_fd_p == -1)
107 103 FATAL("unable to create the epoll file descriptor\n"); FATAL("unable to create the epoll file descriptor\n");
108 104 } }
109 /*NSPC*/
110 static void evt_add_all_fds(void)
105 STATIC void evt_add_all_fds(void)
111 106 { {
112 107 int r; int r;
113 108 u8 i; u8 i;
 
... ... static void evt_add_all_fds(void)
122 117 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
123 118 /* the video timer */ /* the video timer */
124 119 evt.events = EPOLLIN; evt.events = EPOLLIN;
125 evt.data.fd = video_timer_fd_p;
126 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, video_timer_fd_p, &evt);
120 evt.data.fd = npv_video_timer_fd_p;
121 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_video_timer_fd_p, &evt);
127 122 if (r == -1) if (r == -1)
128 123 FATAL("unable to add the video timer file descriptor\n"); FATAL("unable to add the video timer file descriptor\n");
129 124 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
 
... ... static void evt_add_all_fds(void)
137 132 /* alsa pcm poll file descriptors */ /* alsa pcm poll file descriptors */
138 133 i = 0; i = 0;
139 134 loop { loop {
140 if (i == audio_pcm_pollfds_n_p)
135 if (i == npv_audio_pcm_pollfds_n_p)
141 136 break; break;
142 evt.events = audio_pcm_pollfds_p[i].events;
143 evt.data.fd = audio_pcm_pollfds_p[i].fd;
144 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, audio_pcm_pollfds_p[i].fd,
145 &evt);
137 evt.events = npv_audio_pcm_pollfds_p[i].events;
138 evt.data.fd = npv_audio_pcm_pollfds_p[i].fd;
139 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD,
140 npv_audio_pcm_pollfds_p[i].fd, &evt);
146 141 if (r == -1) if (r == -1)
147 142 FATAL("unable to add alsa poll file descriptor index %d to epoll file descriptor\n", i); FATAL("unable to add alsa poll file descriptor index %d to epoll file descriptor\n", i);
148 143 ++i; ++i;
 
... ... static void evt_add_all_fds(void)
150 145 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
151 146 /* the draining timer */ /* the draining timer */
152 147 evt.events = EPOLLIN; evt.events = EPOLLIN;
153 evt.data.fd = audio_draining_timer_fd_p;
154 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, audio_draining_timer_fd_p, &evt);
148 evt.data.fd = npv_audio_draining_timer_fd_p;
149 r = epoll_ctl(ep_fd_p, EPOLL_CTL_ADD, npv_audio_draining_timer_fd_p,
150 &evt);
155 151 if (r == -1) if (r == -1)
156 152 FATAL("unable to add the draining timer file descriptor\n"); FATAL("unable to add the draining timer file descriptor\n");
157 153 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
 
... ... static void evt_add_all_fds(void)
171 167 if (r == -1) if (r == -1)
172 168 FATAL("unable to add the xcb screensaver heartbeat timer file descriptor\n"); FATAL("unable to add the xcb screensaver heartbeat timer file descriptor\n");
173 169 } }
174 /*NSPC*/
175 static void evt_sigs(void)
170 STATIC void evt_sigs(void)
176 171 { {
177 172 int r; int r;
178 173 struct signalfd_siginfo siginfo; struct signalfd_siginfo siginfo;
 
... ... static void evt_sigs(void)
191 186 WARNING("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo); WARNING("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo);
192 187 } }
193 188 } }
194 /*NSPC*/
195 static void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
189 STATIC void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
196 190 bool *have_evt_pcm, bool *have_evt_video, bool *have_evt_pcm_draining, bool *have_evt_pcm, bool *have_evt_video, bool *have_evt_pcm_draining,
197 191 bool *have_evt_x11, bool *have_evt_xcb_screensaver_heartbeat, bool *have_evt_x11, bool *have_evt_xcb_screensaver_heartbeat,
198 192 bool *have_evt_xcb_mouse_visibility) bool *have_evt_xcb_mouse_visibility)
 
... ... static void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
210 204 /* only update alsa fds */ /* only update alsa fds */
211 205 i = 0; i = 0;
212 206 loop { loop {
213 if (i == audio_pcm_pollfds_n_p)
207 if (i == npv_audio_pcm_pollfds_n_p)
214 208 break; break;
215 if (evt->data.fd == audio_pcm_pollfds_p[i].fd) {
216 audio_pcm_pollfds_p[i].revents = evt->events;
209 if (evt->data.fd == npv_audio_pcm_pollfds_p[i].fd) {
210 npv_audio_pcm_pollfds_p[i].revents = evt->events;
217 211 *have_evt_pcm = true; *have_evt_pcm = true;
218 212 return; return;
219 213 } }
 
... ... static void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
226 220 return; return;
227 221 } }
228 222 /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
229 if (evt->data.fd == video_timer_fd_p) {
223 if (evt->data.fd == npv_video_timer_fd_p) {
230 224 if ((evt->events & EPOLLIN) != 0) { if ((evt->events & EPOLLIN) != 0) {
231 225 *have_evt_video = true; *have_evt_video = true;
232 226 return; return;
 
... ... static void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
234 228 FATAL("event loop wait:video:unexpected event\n"); FATAL("event loop wait:video:unexpected event\n");
235 229 } }
236 230 /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
237 if (evt->data.fd == audio_draining_timer_fd_p) {
231 if (evt->data.fd == npv_audio_draining_timer_fd_p) {
238 232 if ((evt->events & EPOLLIN) != 0) { if ((evt->events & EPOLLIN) != 0) {
239 233 *have_evt_pcm_draining = true; *have_evt_pcm_draining = true;
240 234 return; return;
 
... ... static void evt_accumulate(struct epoll_event *evt, bool *have_evt_sigs,
264 258 * "blocking", "expensive" work should be offloaded to other threads. * "blocking", "expensive" work should be offloaded to other threads.
265 259 */ */
266 260 #define EPOLL_EVTS_N 32 /* why not */ #define EPOLL_EVTS_N 32 /* why not */
267 /*NSPC*/
268 static void evts_loop(void)
261 STATIC void evts_loop(void)
269 262 { {
270 263 int fds_n; int fds_n;
271 264 int fd_idx; int fd_idx;
 
... ... static void evts_loop(void)
330 323 * pollfds were properly updated we can actually know we got * pollfds were properly updated we can actually know we got
331 324 * something from alsa * something from alsa
332 325 */ */
333 r = snd_pcm_poll_descriptors_revents(audio_pcm_p,
334 audio_pcm_pollfds_p, audio_pcm_pollfds_n_p, &pcm_evts);
326 r = snd_pcm_poll_descriptors_revents(npv_audio_pcm_p,
327 npv_audio_pcm_pollfds_p, npv_audio_pcm_pollfds_n_p,
328 &pcm_evts);
335 329 if (r != 0) if (r != 0)
336 330 FATAL("alsa:error processing the poll file descriptors\n"); FATAL("alsa:error processing the poll file descriptors\n");
337
338 331 if ((pcm_evts & ~POLLOUT) != 0) if ((pcm_evts & ~POLLOUT) != 0)
339 332 FATAL("alsa:unexpected events\n"); FATAL("alsa:unexpected events\n");
340
341 333 if ((pcm_evts & POLLOUT) != 0) if ((pcm_evts & POLLOUT) != 0)
342 audio_evt_pcm_write();
334 npv_audio_evt_pcm_write();
343 335 } }
344 336 if (have_evt_video) if (have_evt_video)
345 video_timer_evt();
337 npv_video_timer_evt();
346 338 /* while audio is draining, video fr may need to be displayed */ /* while audio is draining, video fr may need to be displayed */
347 339 if (have_evt_pcm_draining) if (have_evt_pcm_draining)
348 audio_draining_state_evt();
340 npv_audio_draining_state_evt();
349 341 if (have_evt_xcb_screensaver_heartbeat) if (have_evt_xcb_screensaver_heartbeat)
350 342 npv_xcb_screensaver_heartbeat_timer_evt(); npv_xcb_screensaver_heartbeat_timer_evt();
351 343 if (have_evt_xcb_mouse_visibility) if (have_evt_xcb_mouse_visibility)
352 344 npv_xcb_mouse_visibility_timer_evt(); npv_xcb_mouse_visibility_timer_evt();
353 345 } }
354 346 #undef EPOLL_EVTS_N #undef EPOLL_EVTS_N
355 /*NSPC*/
356 static void ff_log_stdout(void *a, int b, const char *fmt, va_list ap)
347 STATIC void ff_log_stdout(void *a, int b, const char *fmt, va_list ap)
357 348 { {
358 349 vprintf(fmt, ap); vprintf(fmt, ap);
359 350 } }
360 /*NSPC*/
361 static void usage(void)
351 STATIC void usage(void)
362 352 { {
363 353 POUT("\ POUT("\
364 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\
365 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\
366 356 [-b packet buffer prefill wait(0..100)] [-help] url\n"); [-b packet buffer prefill wait(0..100)] [-help] url\n");
367 357 } }
368 /*NSPC*/
369 static void opts_parse(int argc, u8 **args, u8 **url, bool* start_fullscreen,
358 STATIC void opts_parse(int argc, u8 **args, u8 **url, bool* start_fullscreen,
370 359 u16 *w, u16 *h, u8 **pcm_str, double *vol, u8 *pkts_prefill_percent) u16 *w, u16 *h, u8 **pcm_str, double *vol, u8 *pkts_prefill_percent)
371 360 { {
372 361 int i; int i;
 
... ... static void opts_parse(int argc, u8 **args, u8 **url, bool* start_fullscreen,
436 425 *url = args[url_idx]; *url = args[url_idx];
437 426 POUT("url-->####%s####\n", *url); POUT("url-->####%s####\n", *url);
438 427 } }
439 /*NSPC*/
440 428 #define WIDTH_NOT_DEFINED 0 #define WIDTH_NOT_DEFINED 0
441 429 #define HEIGHT_NOT_DEFINED 0 #define HEIGHT_NOT_DEFINED 0
442 static void init_once(u8 *url, bool start_fullscreen,
430 STATIC void init_once(u8 *url, bool start_fullscreen,
443 431 u16 win_width, u16 win_height, u8 *pcm_str, u16 win_width, u16 win_height, u8 *pcm_str,
444 432 avcodec_params_t **audio_codec_params, avcodec_params_t **audio_codec_params,
445 433 avcodec_params_t **video_codec_params) avcodec_params_t **video_codec_params)
 
... ... static void init_once(u8 *url, bool start_fullscreen,
450 438 evt_init_once(); evt_init_once();
451 439 sigs_init_once(); sigs_init_once();
452 440 npv_vk_init_once(); /* generic plumbing */ npv_vk_init_once(); /* generic plumbing */
453 audio_filt_init_once();
454 audio_init_once(pcm_str); /* before audio_st_idx_p is actually used */
455 video_init_once(); /* before video_st_idx_p is actually used */
456 clk_init_once();
457 pipeline_init_once();
458
459 fmt_init_once(url);
441 npv_audio_filt_init_once();
442 /* before audio_st_idx_p is actually used */
443 npv_audio_init_once(pcm_str);
444 npv_video_init_once(); /* before video_st_idx_p is actually used */
445 npv_clk_init_once();
446 npv_pipeline_init_once();
447
448 npv_fmt_init_once(url);
460 449 /* we need something to start with */ /* we need something to start with */
461 fmt_probe_best_sts(
462 &video_st_p.idx, &video_st_p.id, &video_st_tb,
463 &video_st_p.start_time, video_codec_params,
464 &audio_st_p.idx, &audio_st_p.id, &audio_st_tb,
465 &audio_st_p.start_time, audio_codec_params);
466 memcpy(&audio_st_p.tb, audio_st_tb, sizeof(*audio_st_tb));
467 memcpy(&video_st_p.tb, video_st_tb, sizeof(*video_st_tb));
450 npv_fmt_probe_best_sts(
451 &npv_video_st_p.idx, &npv_video_st_p.id, &video_st_tb,
452 &npv_video_st_p.start_time, video_codec_params,
453 &npv_audio_st_p.idx, &npv_audio_st_p.id, &audio_st_tb,
454 &npv_audio_st_p.start_time, audio_codec_params);
455 memcpy(&npv_audio_st_p.tb, audio_st_tb, sizeof(*audio_st_tb));
456 memcpy(&npv_video_st_p.tb, video_st_tb, sizeof(*video_st_tb));
468 457 if (win_width == WIDTH_NOT_DEFINED) if (win_width == WIDTH_NOT_DEFINED)
469 458 win_width = (*video_codec_params)->width; win_width = (*video_codec_params)->width;
470 459 if (win_height == HEIGHT_NOT_DEFINED) if (win_height == HEIGHT_NOT_DEFINED)
 
... ... static void init_once(u8 *url, bool start_fullscreen,
474 463 } }
475 464 #undef WIDTH_NOT_DEFINED #undef WIDTH_NOT_DEFINED
476 465 #undef HEIGHT_NOT_DEFINED #undef HEIGHT_NOT_DEFINED
477 /*NSPC*/
478 466 #define PRINT_INFO true #define PRINT_INFO true
479 static void prepare(double initial_vol, u8 pkts_prefill_percent,
467 STATIC void prepare(double initial_vol, u8 pkts_prefill_percent,
480 468 avcodec_params_t *audio_codec_params, avcodec_params_t *audio_codec_params,
481 469 avcodec_params_t *video_codec_params) avcodec_params_t *video_codec_params)
482 470 { {
 
... ... static void prepare(double initial_vol, u8 pkts_prefill_percent,
485 473 int dst_chans_n; int dst_chans_n;
486 474 uint64_t dst_chans_layout; uint64_t dst_chans_layout;
487 475
488 pipeline_limits_reset();
489 pipeline_prefill_reset(pkts_prefill_percent);
476 npv_pipeline_limits_reset();
477 npv_pipeline_prefill_reset(pkts_prefill_percent);
490 478
491 audio_dec_ctx_cfg(audio_codec_params);
492 video_dec_ctx_cfg(video_codec_params);
479 npv_audio_dec_ctx_cfg(audio_codec_params);
480 npv_video_dec_ctx_cfg(video_codec_params);
493 481 /* /*
494 482 * do our best to match the pcm cfg to audio ff dec output, BUT we don't * do our best to match the pcm cfg to audio ff dec output, BUT we don't
495 483 * expect to match it "exactly": see right below why * expect to match it "exactly": see right below why
496 484 */ */
497 audio_pcm_cfg(audio_pcm_p, audio_dec_ctx_p->chans_n,
498 audio_dec_ctx_p->fr_rate, audio_dec_ctx_p->fr_fmt);
485 npv_audio_pcm_cfg(npv_audio_pcm_p, npv_audio_dec_ctx_p->chans_n,
486 npv_audio_dec_ctx_p->fr_rate, npv_audio_dec_ctx_p->fr_fmt);
499 487 /* use a ff filt to fill in the gap between the pcm and audio ff dec */ /* use a ff filt to fill in the gap between the pcm and audio ff dec */
500 audio_pcm2ff(audio_pcm_p, &dst_fmt, &dst_rate, &dst_chans_n,
488 npv_audio_pcm2ff(npv_audio_pcm_p, &dst_fmt, &dst_rate, &dst_chans_n,
501 489 &dst_chans_layout, PRINT_INFO); &dst_chans_layout, PRINT_INFO);
502 audio_filt_cfg(
503 audio_dec_ctx_p->fr_fmt, audio_dec_ctx_p->fr_rate,
504 audio_dec_ctx_p->chans_n, audio_dec_ctx_p->chans_layout,
490 npv_audio_filt_cfg(
491 npv_audio_dec_ctx_p->fr_fmt, npv_audio_dec_ctx_p->fr_rate,
492 npv_audio_dec_ctx_p->chans_n, npv_audio_dec_ctx_p->chans_layout,
505 493 false, initial_vol, false, initial_vol,
506 494 dst_fmt, dst_rate, dst_chans_n, dst_chans_layout, dst_fmt, dst_rate, dst_chans_n, dst_chans_layout,
507 495 PRINT_INFO); PRINT_INFO);
508 audio_pcm_silence_bufs_cfg(audio_pcm_p, PRINT_INFO);
496 npv_audio_pcm_silence_bufs_cfg(npv_audio_pcm_p, PRINT_INFO);
509 497
510 498 evt_add_all_fds(); evt_add_all_fds();
511 499 } }
512 500 /*==== while waiting for the osd -- start ====================================*/ /*==== while waiting for the osd -- start ====================================*/
513 /*NSPC*/
514 static u8 *duration_estimate_to_str(enum AVDurationEstimationMethod m)
501 STATIC u8 *duration_estimate_to_str(enum AVDurationEstimationMethod m)
515 502 { {
516 503 switch (m) { switch (m) {
517 504 case AVFMT_DURATION_FROM_PTS: case AVFMT_DURATION_FROM_PTS:
 
... ... static u8 *duration_estimate_to_str(enum AVDurationEstimationMethod m)
524 511 return "unkwown"; return "unkwown";
525 512 } }
526 513 } }
527 /*NSPC*/
528 static u8 *ts_to_str(int64_t ts, avutil_rational_t time_base,
514 STATIC u8 *ts_to_str(int64_t ts, avutil_rational_t time_base,
529 515 int64_t *remaining) int64_t *remaining)
530 516 { {
531 517 static u8 str[sizeof("~S00:00:00.000 remains S9223372036854775807 time base units")]; static u8 str[sizeof("~S00:00:00.000 remains S9223372036854775807 time base units")];
 
... ... static u8 *ts_to_str(int64_t ts, avutil_rational_t time_base,
581 567 #define RESTORE if (stdout_is_tty) POUT("\x1b[39;49m"); #define RESTORE if (stdout_is_tty) POUT("\x1b[39;49m");
582 568 #define TS_FROM_CLK_OK 0 #define TS_FROM_CLK_OK 0
583 569 /* we don't lock anything as an act of faith */ /* we don't lock anything as an act of faith */
584 static void cmd_info(void)
570 STATIC void npv_cmd_info(void)
585 571 { {
586 572 int ri; int ri;
587 573 u8 r8; u8 r8;
 
... ... static void cmd_info(void)
599 585
600 586 RESTORE; RESTORE;
601 587 GREEN;POUT("================================================================================\n");RESTORE; GREEN;POUT("================================================================================\n");RESTORE;
602 PURPLE;POUT("%s\n", fmt_ctx_p->url);RESTORE;
588 PURPLE;POUT("%s\n", npv_fmt_ctx_p->url);RESTORE;
603 589
604 r8 = clk_get_audio_st_ts(&audio_now);
590 r8 = npv_clk_get_audio_st_ts(&audio_now);
605 591 if (r8 != TS_FROM_CLK_OK) { if (r8 != TS_FROM_CLK_OK) {
606 592 POUT("information unavailable at the time of the command due to an unavailable audio clock\n"); POUT("information unavailable at the time of the command due to an unavailable audio clock\n");
607 593 return; return;
608 594 } }
609 ts_str = ts_to_str(audio_now, audio_st_p.tb, &remaining);
595 ts_str = ts_to_str(audio_now, npv_audio_st_p.tb, &remaining);
610 596 RED;POUT("%s", ts_str);RESTORE; RED;POUT("%s", ts_str);RESTORE;
611 597 if (remaining != 0) if (remaining != 0)
612 598 POUT(" remaining %"PRId64" time base units", remaining); POUT(" remaining %"PRId64" time base units", remaining);
613 599 else else
614 600 POUT("\n"); POUT("\n");
615 POUT("\t%"PRId64" stream time base units (%d/%d seconds)\n", audio_now, audio_st_p.tb.num, audio_st_p.tb.den);
601 POUT("\t%"PRId64" stream time base units (%d/%d seconds)\n",
602 audio_now, npv_audio_st_p.tb.num, npv_audio_st_p.tb.den);
616 603 BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE;
617 604 POUT("format:"); POUT("format:");
618 if (fmt_ctx_p->duration == AV_NOPTS_VALUE) {
605 if (npv_fmt_ctx_p->duration == AV_NOPTS_VALUE) {
619 606 POUT("duration is not provided\n"); POUT("duration is not provided\n");
620 607 } else { } else {
621 snprintf(duration_str, sizeof(duration_str), "%"PRId64, fmt_ctx_p->duration);
622 ts_str = ts_to_str(fmt_ctx_p->duration, AV_TIME_BASE_Q,
608 snprintf(duration_str, sizeof(duration_str), "%"PRId64,
609 npv_fmt_ctx_p->duration);
610 ts_str = ts_to_str(npv_fmt_ctx_p->duration, AV_TIME_BASE_Q,
623 611 &remaining); &remaining);
624 612 POUT("duration=");RED;POUT("%s", ts_str);RESTORE; POUT("duration=");RED;POUT("%s", ts_str);RESTORE;
625 613 if (remaining != 0) if (remaining != 0)
626 POUT(" remaining %"PRId64" av_time_base units\n", remaining);
614 POUT(" remaining %"PRId64" av_time_base units\n",
615 remaining);
627 616 else else
628 617 POUT("\n"); POUT("\n");
629 POUT("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n", duration_str, AV_TIME_BASE, duration_estimate_to_str(fmt_ctx_p->duration_estimation_method));
618 POUT("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n",
619 duration_str, AV_TIME_BASE, duration_estimate_to_str(
620 npv_fmt_ctx_p->duration_estimation_method));
630 621 } }
631 622 BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE;
632 POUT("stream:audio_id=%d", audio_st_p.id);
633 if (fmt_ctx_p->streams[audio_st_p.idx]->duration == AV_NOPTS_VALUE) {
623 POUT("stream:audio_id=%d", npv_audio_st_p.id);
624 if (npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration == AV_NOPTS_VALUE) {
634 625 POUT(";duration is not provided\n"); POUT(";duration is not provided\n");
635 626 } else { } else {
636 snprintf(duration_str, sizeof(duration_str), "%"PRId64, fmt_ctx_p->streams[audio_st_p.idx]->duration);
637 ts_str = ts_to_str(fmt_ctx_p->streams[audio_st_p.idx]->duration, audio_st_p.tb, &remaining);
627 snprintf(duration_str, sizeof(duration_str), "%"PRId64,
628 npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration);
629 ts_str = ts_to_str(
630 npv_fmt_ctx_p->streams[npv_audio_st_p.idx]->duration,
631 npv_audio_st_p.tb, &remaining);
638 632 POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE; POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE;
639 633 if (remaining != 0) if (remaining != 0)
640 POUT(" remaining %"PRId64" stream time base units\n", remaining);
634 POUT(" remaining %"PRId64" stream time base units\n",
635 remaining);
641 636 else else
642 637 POUT("\n"); POUT("\n");
643 POUT("\t%s stream time base units (%d/%d seconds)\n", duration_str, audio_st_p.tb.num, audio_st_p.tb.den);
638 POUT("\t%s stream time base units (%d/%d seconds)\n",
639 duration_str, npv_audio_st_p.tb.num,
640 npv_audio_st_p.tb.den);
644 641 } }
645 642 BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE;
646 643 GREEN;POUT("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE; GREEN;POUT("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE;
 
... ... static void cmd_info(void)
652 649 #undef PURPLE #undef PURPLE
653 650 #undef RESTORE #undef RESTORE
654 651 /*==== while waiting for the osd -- end ======================================*/ /*==== while waiting for the osd -- end ======================================*/
655 static void cmd_quit(void)
652 STATIC void npv_cmd_quit(void)
656 653 { {
657 654 EXIT("quit command received\n"); EXIT("quit command received\n");
658 655 } }
659 /*NSPC*/
660 static void seek_lock(void)
656 STATIC void seek_lock(void)
661 657 { {
662 658 /* fmt */ /* fmt */
663 fmt_ctx_lock();
659 npv_fmt_ctx_lock();
664 660 /* video */ /* video */
665 pkt_q_lock(video_pkt_q_p);
666 video_dec_frs_lock();
667 video_dec_ctx_lock();
661 npv_pkt_q_lock(npv_video_pkt_q_p);
662 npv_video_dec_frs_lock();
663 npv_video_dec_ctx_lock();
668 664 /* audio (useless from the main thd though) */ /* audio (useless from the main thd though) */
669 pkt_q_lock(audio_pkt_q_p);
670 audio_dec_sets_lock();
671 audio_dec_ctx_lock();
665 npv_pkt_q_lock(npv_audio_pkt_q_p);
666 npv_audio_dec_sets_lock();
667 npv_audio_dec_ctx_lock();
672 668
673 pipeline_limits_lock();
669 npv_pipeline_limits_lock();
674 670 } }
675 /*NSPC*/
676 static void seek_unlock(void)
671 STATIC void seek_unlock(void)
677 672 { {
678 pipeline_limits_unlock();
673 npv_pipeline_limits_unlock();
679 674
680 675 /* audio */ /* audio */
681 audio_dec_ctx_unlock();
682 audio_dec_sets_unlock();
683 pkt_q_unlock(audio_pkt_q_p);
676 npv_audio_dec_ctx_unlock();
677 npv_audio_dec_sets_unlock();
678 npv_pkt_q_unlock(npv_audio_pkt_q_p);
684 679 /* video */ /* video */
685 video_dec_ctx_unlock();
686 video_dec_frs_unlock();
687 pkt_q_unlock(video_pkt_q_p);
680 npv_video_dec_ctx_unlock();
681 npv_video_dec_frs_unlock();
682 npv_pkt_q_unlock(npv_video_pkt_q_p);
688 683 /* fmt */ /* fmt */
689 fmt_ctx_unlock();
684 npv_fmt_ctx_unlock();
690 685 } }
691 /*NSPC*/
692 686 #define TS_FROM_CLK_OK 0 #define TS_FROM_CLK_OK 0
693 static void seek_x(s64 delta)
687 STATIC void seek_x(s64 delta)
694 688 { {
695 689 int a; int a;
696 690 u8 r; u8 r;
 
... ... static void seek_x(s64 delta)
699 693 s64 audio_now; s64 audio_now;
700 694 s64 video_now; s64 video_now;
701 695
702 if (audio_draining_p) {
696 if (npv_audio_draining_p) {
703 697 WARNING("seek:audio is draining, seeking disable\n"); WARNING("seek:audio is draining, seeking disable\n");
704 698 return; return;
705 699 } }
706 700 if (paused_p) /* we don't seek in pause */ if (paused_p) /* we don't seek in pause */
707 701 return; return;
708 702
709 thdsws_wait_for_idle(video_scaler_p.ctx);
703 npv_thdsws_wait_for_idle(npv_video_scaler_p.ctx);
710 704
711 705 seek_lock(); seek_lock();
712 706
713 r = clk_get_audio_st_ts(&audio_now);
707 r = npv_clk_get_audio_st_ts(&audio_now);
714 708 if (r != TS_FROM_CLK_OK) { if (r != TS_FROM_CLK_OK) {
715 709 WARNING("seek:audio:clock timestamp unavailable, ignoring command\n"); WARNING("seek:audio:clock timestamp unavailable, ignoring command\n");
716 710 seek_unlock(); seek_unlock();
717 711 return; return;
718 712 } }
719 r = clk_get_video_st_ts(&video_now);
713 r = npv_clk_get_video_st_ts(&video_now);
720 714 if (r != TS_FROM_CLK_OK) { if (r != TS_FROM_CLK_OK) {
721 715 WARNING("seek:video:clock timestamp unavailable, ignoring command\n"); WARNING("seek:video:clock timestamp unavailable, ignoring command\n");
722 716 seek_unlock(); seek_unlock();
723 717 return; return;
724 718 } }
725 (void)snd_pcm_drop(audio_pcm_p);
719 (void)snd_pcm_drop(npv_audio_pcm_p);
726 720 /* /*
727 721 * XXX: a set of sts can share the same id for seeking. if they share * XXX: a set of sts can share the same id for seeking. if they share
728 722 * the same id then the tbs should be the same. * the same id then the tbs should be the same.
729 723 */ */
730 724 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
731 new_audio_ts = audio_now + delta * audio_st_p.tb.den
732 / audio_st_p.tb.num;
725 new_audio_ts = audio_now + delta * npv_audio_st_p.tb.den
726 / npv_audio_st_p.tb.num;
733 727 /* rewind capping if possible */ /* rewind capping if possible */
734 if (audio_st_p.start_time != AV_NOPTS_VALUE)
735 if (new_audio_ts < audio_st_p.start_time)
736 new_audio_ts = audio_st_p.start_time;
728 if (npv_audio_st_p.start_time != AV_NOPTS_VALUE)
729 if (new_audio_ts < npv_audio_st_p.start_time)
730 new_audio_ts = npv_audio_st_p.start_time;
737 731 POUT("trying to seek to %"PRId64" audio stream time base units\n", new_audio_ts); POUT("trying to seek to %"PRId64" audio stream time base units\n", new_audio_ts);
738 a = avformat_seek_pkt(fmt_ctx_p, audio_st_p.id, new_audio_ts, 0);
732 a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, new_audio_ts,
733 0);
739 734 if (a < 0) { if (a < 0) {
740 735 POUT("unable to seek to %"PRId64" audio stream time base units\n", new_audio_ts); POUT("unable to seek to %"PRId64" audio stream time base units\n", new_audio_ts);
741 736 goto try_restore_audio; goto try_restore_audio;
742 737 } }
743 738 POUT("audio seek to %"PRId64" audio stream time base units\n", new_audio_ts); POUT("audio seek to %"PRId64" audio stream time base units\n", new_audio_ts);
744 739 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
745 new_video_ts = video_now + delta * video_st_p.tb.den
746 / video_st_p.tb.num;
740 new_video_ts = video_now + delta * npv_video_st_p.tb.den
741 / npv_video_st_p.tb.num;
747 742 /* rewind capping if possible */ /* rewind capping if possible */
748 if (video_st_p.start_time != AV_NOPTS_VALUE)
749 if (new_video_ts < video_st_p.start_time)
750 new_video_ts = video_st_p.start_time;
743 if (npv_video_st_p.start_time != AV_NOPTS_VALUE)
744 if (new_video_ts < npv_video_st_p.start_time)
745 new_video_ts = npv_video_st_p.start_time;
751 746 POUT("trying to seek to %"PRId64" video stream time base units\n", new_video_ts); POUT("trying to seek to %"PRId64" video stream time base units\n", new_video_ts);
752 a = avformat_seek_pkt(fmt_ctx_p, video_st_p.id, new_video_ts, 0);
747 a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, new_video_ts,
748 0);
753 749 if (a < 0) { if (a < 0) {
754 750 POUT("unable to seek to %"PRId64" video stream time base units but audio was seeked)\n", new_video_ts); POUT("unable to seek to %"PRId64" video stream time base units but audio was seeked)\n", new_video_ts);
755 751 goto try_restore_video; goto try_restore_video;
756 752 } }
757 753 POUT("video seek to %"PRId64" video stream time base units\n", new_video_ts); POUT("video seek to %"PRId64" video stream time base units\n", new_video_ts);
758 754 flush: flush:
759 video_dec_flush();
760 audio_dec_flush();
761 audio_filt_flush();
762 fmt_flush();
763 clk_invalidate();
764 pipeline_limits_reset();
765 pipeline_prefill_reset(pipeline_limits_p.pkts.prefill.percent);
755 npv_video_dec_flush();
756 npv_audio_dec_flush();
757 npv_audio_filt_flush();
758 npv_fmt_flush();
759 npv_clk_invalidate();
760 npv_pipeline_limits_reset();
761 npv_pipeline_prefill_reset(npv_pipeline_limits_p.pkts.prefill.percent);
766 762 seek_unlock(); seek_unlock();
767 763
768 764 POUT("prefilling audio and video buffers..."); POUT("prefilling audio and video buffers...");
 
... ... flush:
771 767 POUT("predecoding audio and video..."); POUT("predecoding audio and video...");
772 768 predecode_wait(); /* use the lock on the pipeline limits */ predecode_wait(); /* use the lock on the pipeline limits */
773 769 POUT("done\n"); POUT("done\n");
774 (void)snd_pcm_prepare(audio_pcm_p);
770 (void)snd_pcm_prepare(npv_audio_pcm_p);
775 771 return; return;
776 772
777 773 try_restore_video: try_restore_video:
778 a = avformat_seek_pkt(fmt_ctx_p, video_st_p.id, video_now, 0);
774 a = avformat_seek_pkt(npv_fmt_ctx_p, npv_video_st_p.id, video_now, 0);
779 775 if (a < 0) /* we don't send an application error */ if (a < 0) /* we don't send an application error */
780 776 EXIT("unable to restore video to %"PRId64" video stream time base units\n", video_now); EXIT("unable to restore video to %"PRId64" video stream time base units\n", video_now);
781 777 try_restore_audio: try_restore_audio:
782 a = avformat_seek_pkt(fmt_ctx_p, audio_st_p.id, audio_now, 0);
778 a = avformat_seek_pkt(npv_fmt_ctx_p, npv_audio_st_p.id, audio_now, 0);
783 779 if (a < 0) /* we don't send an application error */ if (a < 0) /* we don't send an application error */
784 780 EXIT("unable to restore audio to %"PRId64" audio stream time base units\n", audio_now); EXIT("unable to restore audio to %"PRId64" audio stream time base units\n", audio_now);
785 781 goto flush; goto flush;
786 782 } }
787 783 #undef TS_FROM_CLK_OK #undef TS_FROM_CLK_OK
788 static void cmd_rewind(void)
784 STATIC void npv_cmd_rewind(void)
789 785 { {
790 786 POUT("COMMAND:rewind\n"); POUT("COMMAND:rewind\n");
791 787 seek_x(-SEEK_DELTA); seek_x(-SEEK_DELTA);
792 788 } }
793 789
794 static void cmd_rewind_big(void)
790 STATIC void npv_cmd_rewind_big(void)
795 791 { {
796 792 POUT("COMMAND:rewind big\n"); POUT("COMMAND:rewind big\n");
797 793 seek_x(-SEEK_DELTA_BIG); seek_x(-SEEK_DELTA_BIG);
798 794 } }
799 795
800 static void cmd_fastforward(void)
796 STATIC void npv_cmd_fastforward(void)
801 797 { {
802 798 POUT("COMMAND:fastforward\n"); POUT("COMMAND:fastforward\n");
803 799 seek_x(SEEK_DELTA); seek_x(SEEK_DELTA);
804 800 } }
805 801
806 static void cmd_fastforward_big(void)
802 STATIC void npv_cmd_fastforward_big(void)
807 803 { {
808 804 POUT("COMMAND:fastforward big\n"); POUT("COMMAND:fastforward big\n");
809 805 seek_x(SEEK_DELTA_BIG); seek_x(SEEK_DELTA_BIG);
810 806 } }
811 807
812 static void cmd_pause(void)
808 STATIC void npv_cmd_pause(void)
813 809 { {
814 if (audio_draining_p) {
810 if (npv_audio_draining_p) {
815 811 WARNING("pause:audio is draining, toggling pause is disable\n"); WARNING("pause:audio is draining, toggling pause is disable\n");
816 812 return; return;
817 813 } }
 
... ... static void cmd_pause(void)
820 816
821 817 POUT("COMMAND:unpause\n"); POUT("COMMAND:unpause\n");
822 818 paused_p = false; paused_p = false;
823 fmt_ctx_lock();
824 avformat_read_play(fmt_ctx_p);
825 fmt_ctx_unlock();
826 clk_unpause();
827 video_timer_start();
819 npv_fmt_ctx_lock();
820 avformat_read_play(npv_fmt_ctx_p);
821 npv_fmt_ctx_unlock();
822 npv_clk_unpause();
823 npv_video_timer_start();
828 824 } else { } else {
829 825 int r; int r;
830 826
831 827 POUT("COMMAND:pause\n"); POUT("COMMAND:pause\n");
832 828 paused_p = true; paused_p = true;
833 fmt_ctx_lock();
834 avformat_read_pause(fmt_ctx_p);
835 fmt_ctx_unlock();
836 clk_pause();
837 video_timer_slow_start();
829 npv_fmt_ctx_lock();
830 avformat_read_pause(npv_fmt_ctx_p);
831 npv_fmt_ctx_unlock();
832 npv_clk_pause();
833 npv_video_timer_slow_start();
838 834 } }
839 835 } }
840 static void cmd_vol_up(void)
836 STATIC void npv_cmd_vol_up(void)
841 837 { {
842 audio_filt_cmd_vol_up();
838 npv_audio_filt_cmd_vol_up();
843 839 } }
844 static void cmd_vol_down(void)
840 STATIC void npv_cmd_vol_down(void)
845 841 { {
846 audio_filt_cmd_vol_down();
842 npv_audio_filt_cmd_vol_down();
847 843 } }
848 static void cmd_mute(void)
844 STATIC void npv_cmd_mute(void)
849 845 { {
850 audio_filt_cmd_mute();
846 npv_audio_filt_cmd_mute();
851 847 } }
852 848 #define WIDTH_NOT_DEFINED 0 #define WIDTH_NOT_DEFINED 0
853 849 #define HEIGHT_NOT_DEFINED 0 #define HEIGHT_NOT_DEFINED 0
 
... ... int main(int argc, u8 **args)
872 868 pcm_str = "default"; pcm_str = "default";
873 869 url = 0; url = 0;
874 870 initial_vol = 1.; initial_vol = 1.;
875 pipeline_limits_p.pkts.prefill.percent = 0;
871 npv_pipeline_limits_p.pkts.prefill.percent = 0;
876 872 opts_parse(argc, args, &url, &start_fullscreen, &win_width, &win_height, opts_parse(argc, args, &url, &start_fullscreen, &win_width, &win_height,
877 873 &pcm_str, &initial_vol, &pcm_str, &initial_vol,
878 &pipeline_limits_p.pkts.prefill.percent);
874 &npv_pipeline_limits_p.pkts.prefill.percent);
879 875 init_once(url, start_fullscreen, win_width, win_height, pcm_str, init_once(url, start_fullscreen, win_width, win_height, pcm_str,
880 876 &audio_codec_params, &video_codec_params); &audio_codec_params, &video_codec_params);
881 prepare(initial_vol, pipeline_limits_p.pkts.prefill.percent,
877 prepare(initial_vol, npv_pipeline_limits_p.pkts.prefill.percent,
882 878 audio_codec_params, video_codec_params); audio_codec_params, video_codec_params);
883 879
884 880 /* switch the ffmpeg log to stdout for metadata/etc dump */ /* switch the ffmpeg log to stdout for metadata/etc dump */
885 881 avutil_log_set_callback(ff_log_stdout); avutil_log_set_callback(ff_log_stdout);
886 avformat_dump_fmt(fmt_ctx_p, 0, url, 0);
882 avformat_dump_fmt(npv_fmt_ctx_p, 0, url, 0);
887 883 avutil_log_set_callback(avutil_log_default_callback); avutil_log_set_callback(avutil_log_default_callback);
888 884
889 pipeline_read_thd_start();
885 npv_pipeline_read_thd_start();
890 886 POUT("prefilling audio and video buffers..."); POUT("prefilling audio and video buffers...");
891 887 prefill_wait(); prefill_wait();
892 888 POUT("done\n"); POUT("done\n");
893 pipeline_audio_thd_start();
894 pipeline_video_thd_start();
889 npv_pipeline_audio_thd_start();
890 npv_pipeline_video_thd_start();
895 891 POUT("predecoding audio and video..."); POUT("predecoding audio and video...");
896 892 predecode_wait(); predecode_wait();
897 893 POUT("done\n"); POUT("done\n");
898 video_timer_start();
894 npv_video_timer_start();
899 895 npv_xcb_screensaver_heartbeat_timer_start(); npv_xcb_screensaver_heartbeat_timer_start();
900 896
901 897 loop evts_loop(); loop evts_loop();
File npv/local/state.frag.c changed (mode: 100644) (index b8dba04..06d6261)
1 1 /* linux and compatible */ /* linux and compatible */
2 static int sig_fd_l;
2 STATIC int sig_fd_l;
File npv/main.c changed (mode: 100644) (index 82ca2ea..c7bfb0b)
45 45 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
46 46 #include "npv/audio/namespace/ffmpeg.h" #include "npv/audio/namespace/ffmpeg.h"
47 47 #include "npv/namespace/public.h" #include "npv/namespace/public.h"
48 #include "npv/namespace/main.c"
48 49 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
49 50 #include "config.h" #include "config.h"
50 51 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
 
55 56 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
56 57 #include "npv/audio/namespace/ffmpeg.h" #include "npv/audio/namespace/ffmpeg.h"
57 58 #include "npv/namespace/public.h" #include "npv/namespace/public.h"
59 #include "npv/namespace/main.c"
58 60 #undef CLEANUP #undef CLEANUP
59 61 /*============================================================================*/ /*============================================================================*/
60 62 #include "npv/pkt_q/main.c" #include "npv/pkt_q/main.c"
File npv/namespace/main.c changed (mode: 100644) (index c1e568e..df6ad30)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define sig_fd_l npv_sig_fd_l
2 #define duration_estimate_to_str npv_duration_estimate_to_str
3 #define evt_accumulate npv_evt_accumulate
4 #define evt_add_all_fds npv_evt_add_all_fds
5 #define evt_init_once npv_evt_init_once
6 #define evt_sigs npv_evt_sigs
7 #define evts_loop npv_evts_loop
8 #define ff_log_stdout npv_ff_log_stdout
9 #define init_once npv_init_once
10 #define opts_parse npv_opts_parse
11 #define predecode_wait npv_predecode_wait
12 #define prefill_wait npv_prefill_wait
13 #define prepare npv_prepare
14 #define seek_lock npv_seek_lock
15 #define seek_unlock npv_seek_unlock
16 #define seek_x npv_seek_x
17 #define sig_fd_l npv_sig_fd_l
18 #define sigs_init_once npv_sigs_init_once
19 #define ts_to_str npv_ts_to_str
20 #define usage npv_usage
3 21 /*============================================================================*/ /*============================================================================*/
4 22 #else #else
23 #undef duration_estimate_to_str
24 #undef evt_accumulate
25 #undef evt_add_all_fds
26 #undef evt_init_once
27 #undef evt_sigs
28 #undef evts_loop
29 #undef ff_log_stdout
30 #undef init_once
31 #undef opts_parse
32 #undef predecode_wait
33 #undef prefill_wait
34 #undef prepare
35 #undef seek_lock
36 #undef seek_unlock
37 #undef seek_x
5 38 #undef sig_fd_l #undef sig_fd_l
39 #undef sigs_init_once
40 #undef ts_to_str
41 #undef usage
6 42 #endif #endif
File npv/nyanvk/syms_global.h changed (mode: 100644) (index 9f3694e..b92590c)
6 6 */ */
7 7 /* XXX: define VK_GLOBAL_SYMS and cherry pick what you actually use */ /* XXX: define VK_GLOBAL_SYMS and cherry pick what you actually use */
8 8 #define VK_GLOBAL_SYMS_FULL \ #define VK_GLOBAL_SYMS_FULL \
9 static void *(*dl_vk_get_instance_proc_addr)(struct vk_instance_t *instance, u8 *name);\
10 static void *(*dl_vk_get_dev_proc_addr)(struct vk_dev_t *dev, u8 *name);\
9 STATIC void *(*dl_vk_get_instance_proc_addr)(struct vk_instance_t *instance, u8 *name);\
10 STATIC void *(*dl_vk_get_dev_proc_addr)(struct vk_dev_t *dev, u8 *name);\
11 11 \ \
12 static s32 (*dl_vk_enumerate_instance_version)(u32 *version);\
13 static s32 (*dl_vk_enumerate_instance_layer_props)(\
12 STATIC s32 (*dl_vk_enumerate_instance_version)(u32 *version);\
13 STATIC s32 (*dl_vk_enumerate_instance_layer_props)(\
14 14 u32 *props_n,\ u32 *props_n,\
15 15 struct vk_layer_props_t *props);\ struct vk_layer_props_t *props);\
16 static s32 (*dl_vk_enumerate_instance_ext_props)(\
16 STATIC s32 (*dl_vk_enumerate_instance_ext_props)(\
17 17 u8 *layer_name,\ u8 *layer_name,\
18 18 u32 *props_n,\ u32 *props_n,\
19 19 struct vk_ext_props_t *props);\ struct vk_ext_props_t *props);\
20 static s32 (*dl_vk_create_instance)(\
20 STATIC s32 (*dl_vk_create_instance)(\
21 21 struct vk_instance_create_info_t *info,\ struct vk_instance_create_info_t *info,\
22 22 void *allocator,\ void *allocator,\
23 23 struct vk_instance_t **instance);\ struct vk_instance_t **instance);\
24 static s32 (*dl_vk_enumerate_phydevs)(\
24 STATIC s32 (*dl_vk_enumerate_phydevs)(\
25 25 struct vk_instance_t *instance,\ struct vk_instance_t *instance,\
26 26 u32 *phydevs_n,\ u32 *phydevs_n,\
27 27 struct vk_phydev_t **phydevs);\ struct vk_phydev_t **phydevs);\
28 static s32 (*dl_vk_enumerate_dev_ext_props)(\
28 STATIC s32 (*dl_vk_enumerate_dev_ext_props)(\
29 29 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
30 30 u8 *layer_name,\ u8 *layer_name,\
31 31 u32 *props_n,\ u32 *props_n,\
32 32 struct vk_ext_props_t *props);\ struct vk_ext_props_t *props);\
33 static void (*dl_vk_get_phydev_props)(\
33 STATIC void (*dl_vk_get_phydev_props)(\
34 34 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
35 35 struct vk_phydev_props_t *props);\ struct vk_phydev_props_t *props);\
36 static s32 (*dl_vk_create_dev)(\
36 STATIC s32 (*dl_vk_create_dev)(\
37 37 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
38 38 struct vk_dev_create_info_t *create_info,\ struct vk_dev_create_info_t *create_info,\
39 39 void *allocator,\ void *allocator,\
40 40 struct vk_dev_t **dev);\ struct vk_dev_t **dev);\
41 static void (*dl_vk_get_phydev_q_fam_props)(\
41 STATIC void (*dl_vk_get_phydev_q_fam_props)(\
42 42 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
43 43 u32 *q_fam_props_n,\ u32 *q_fam_props_n,\
44 44 struct vk_q_fam_props_t *props);\ struct vk_q_fam_props_t *props);\
45 static s32 (*dl_vk_create_xcb_surf)(\
45 STATIC s32 (*dl_vk_create_xcb_surf)(\
46 46 struct vk_instance_t *instance,\ struct vk_instance_t *instance,\
47 47 struct vk_xcb_surf_create_info_t *info,\ struct vk_xcb_surf_create_info_t *info,\
48 48 void *allocator,\ void *allocator,\
49 49 struct vk_surf_t **surf);\ struct vk_surf_t **surf);\
50 static void (*dl_vk_destroy_surf)(\
50 STATIC void (*dl_vk_destroy_surf)(\
51 51 struct vk_instance_t *instance,\ struct vk_instance_t *instance,\
52 52 struct vk_surf_t *surf,\ struct vk_surf_t *surf,\
53 53 void *allocator); \ void *allocator); \
54 static s32 (*dl_vk_get_phydev_surf_support)(\
54 STATIC s32 (*dl_vk_get_phydev_surf_support)(\
55 55 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
56 56 u32 q_fam,\ u32 q_fam,\
57 57 struct vk_surf_t *surf,\ struct vk_surf_t *surf,\
58 58 u32 *supported);\ u32 *supported);\
59 static s32 (*dl_vk_get_phydev_surf_texel_mem_blk_confs)(\
59 STATIC s32 (*dl_vk_get_phydev_surf_texel_mem_blk_confs)(\
60 60 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
61 61 struct vk_phydev_surf_info_t *info,\ struct vk_phydev_surf_info_t *info,\
62 62 u32 *confs_n,\ u32 *confs_n,\
63 63 struct vk_surf_texel_mem_blk_conf_t *confs);\ struct vk_surf_texel_mem_blk_conf_t *confs);\
64 static void (*dl_vk_get_phydev_mem_props)(\
64 STATIC void (*dl_vk_get_phydev_mem_props)(\
65 65 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
66 66 struct vk_phydev_mem_props_t *props);\ struct vk_phydev_mem_props_t *props);\
67 static s32 (*dl_vk_get_phydev_surf_caps)(\
67 STATIC s32 (*dl_vk_get_phydev_surf_caps)(\
68 68 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
69 69 struct vk_phydev_surf_info_t *info,\ struct vk_phydev_surf_info_t *info,\
70 70 struct vk_surf_caps_t *caps);\ struct vk_surf_caps_t *caps);\
71 static s32 (*dl_vk_get_phydev_surf_present_modes)(\
71 STATIC s32 (*dl_vk_get_phydev_surf_present_modes)(\
72 72 struct vk_phydev_t *phydev,\ struct vk_phydev_t *phydev,\
73 73 struct vk_surf_t *surf,\ struct vk_surf_t *surf,\
74 74 u32 *modes_n,\ u32 *modes_n,\
File npv/pipeline/local/code.frag.c changed (mode: 100644) (index 4754901..8557e17)
1 static void wait(long ns)
1 STATIC void wait(long ns)
2 2 { {
3 3 struct timespec wanted; struct timespec wanted;
4 4 struct timespec rem; struct timespec rem;
 
... ... static void wait(long ns)
21 21 } }
22 22 } }
23 23 #define EOF_FMT 2 #define EOF_FMT 2
24 static void read(void) { loop /* infinite loop */
24 STATIC void read(void) { loop /* infinite loop */
25 25 { {
26 26 u8 r; u8 r;
27 27 /* /*
28 28 * we do finer-grained locking in there, since we do not want to lock * we do finer-grained locking in there, since we do not want to lock
29 29 * the pkt qs during slow access * the pkt qs during slow access
30 30 */ */
31 r = fmt_pkts_read_and_q();
31 r = npv_fmt_pkts_read_and_q();
32 32 if (r == EOF_FMT) { if (r == EOF_FMT) {
33 pkt_q_lock(audio_pkt_q_p);
34 if (!pkt_q_has_eof(audio_pkt_q_p))
35 pkt_q_enq(audio_pkt_q_p, eof_pkt_l);
36 pkt_q_unlock(audio_pkt_q_p);
33 npv_pkt_q_lock(npv_audio_pkt_q_p);
34 if (!npv_pkt_q_has_eof(npv_audio_pkt_q_p))
35 npv_pkt_q_enq(npv_audio_pkt_q_p, eof_pkt_l);
36 npv_pkt_q_unlock(npv_audio_pkt_q_p);
37 37
38 pkt_q_lock(video_pkt_q_p);
39 if (!pkt_q_has_eof(video_pkt_q_p))
40 pkt_q_enq(video_pkt_q_p, eof_pkt_l);
41 pkt_q_unlock(video_pkt_q_p);
38 npv_pkt_q_lock(npv_video_pkt_q_p);
39 if (!npv_pkt_q_has_eof(npv_video_pkt_q_p))
40 npv_pkt_q_enq(npv_video_pkt_q_p, eof_pkt_l);
41 npv_pkt_q_unlock(npv_video_pkt_q_p);
42 42 } }
43 43 /* r == LIMITS_REACHED || EAGAIN */ /* r == LIMITS_REACHED || EAGAIN */
44 44 /* should be enough to avoid non kept-alive network connexion */ /* should be enough to avoid non kept-alive network connexion */
45 45 wait(100000000); /* 100ms */ wait(100000000); /* 100ms */
46 46 }} }}
47 47 #undef EOF_FMT #undef EOF_FMT
48 static void *read_thd_entry(void *arg)
48 STATIC void *read_thd_entry(void *arg)
49 49 { {
50 50 int r; int r;
51 51 sigset_t sset; sigset_t sset;
 
... ... static void *read_thd_entry(void *arg)
66 66 * the audio dec is fine grained enough in order to base our calculation on the * the audio dec is fine grained enough in order to base our calculation on the
67 67 * pts-es of 2 sets of audio frs. * pts-es of 2 sets of audio frs.
68 68 */ */
69 /*NPSC*/
70 static bool have_enough_predecoded_audio_frs(void)
69 STATIC bool have_enough_predecoded_audio_frs(void)
71 70 { {
72 71 int64_t pts_min; int64_t pts_min;
73 72 int64_t pts_max; int64_t pts_max;
74 73 int64_t pts_delta; int64_t pts_delta;
75 74 int64_t pts_delta_limit; int64_t pts_delta_limit;
76 75
77 audio_dec_sets_lock();
78 if (audio_dec_sets_p.eof_receive) {
79 audio_dec_sets_unlock();
76 npv_audio_dec_sets_lock();
77 if (npv_audio_dec_sets_p.eof_receive) {
78 npv_audio_dec_sets_unlock();
80 79 return true; return true;
81 } else if (audio_dec_sets_p.n == 0) {
82 audio_dec_sets_unlock();
80 } else if (npv_audio_dec_sets_p.n == 0) {
81 npv_audio_dec_sets_unlock();
83 82 return false; return false;
84 83 } }
85 84 /* from here we have at least 1 sets of audio frs */ /* from here we have at least 1 sets of audio frs */
86 85 /* we presume the audio sets are in pts order */ /* we presume the audio sets are in pts order */
87 pts_min = audio_dec_sets_p.a[0]->pts;
88 pts_max = audio_dec_sets_p.a[audio_dec_sets_p.n - 1]->pts;
89 audio_dec_sets_unlock();
86 pts_min = npv_audio_dec_sets_p.a[0]->pts;
87 pts_max = npv_audio_dec_sets_p.a[npv_audio_dec_sets_p.n - 1]->pts;
88 npv_audio_dec_sets_unlock();
90 89
91 90 pts_delta = pts_max - pts_min; pts_delta = pts_max - pts_min;
92 91 /* 2 * 0.25s = 500 ms */ /* 2 * 0.25s = 500 ms */
93 pts_delta_limit = 500 * audio_st_p.tb.den / audio_st_p.tb.num / 1000;
92 pts_delta_limit = 500 * npv_audio_st_p.tb.den / npv_audio_st_p.tb.num
93 / 1000;
94 94 if (pts_delta >= pts_delta_limit) if (pts_delta >= pts_delta_limit)
95 95 return true; return true;
96 96 return false; return false;
97 97 } }
98 static void audio(void) { loop /* infinite loop */
98 STATIC void audio(void) { loop /* infinite loop */
99 99 { {
100 100 if (have_enough_predecoded_audio_frs()) { if (have_enough_predecoded_audio_frs()) {
101 101 wait(250000000); /* (rate/4)~0.25s */ wait(250000000); /* (rate/4)~0.25s */
102 102 continue; continue;
103 103 } }
104 104 /* can be long, finer-grained locking is done in there */ /* can be long, finer-grained locking is done in there */
105 audio_pkts_send();
106 audio_dec_sets_receive_avail();
105 npv_audio_pkts_send();
106 npv_audio_dec_sets_receive_avail();
107 107
108 108 }} }}
109 static void *audio_thd_entry(void *arg)
109 STATIC void *audio_thd_entry(void *arg)
110 110 { {
111 111 int r; int r;
112 112 sigset_t sset; sigset_t sset;
 
... ... static void *audio_thd_entry(void *arg)
124 124 * same heuristics than for audio. there is some sort of sync due to video fr * same heuristics than for audio. there is some sort of sync due to video fr
125 125 * dropping based on "audio now" in the main thd * dropping based on "audio now" in the main thd
126 126 */ */
127 /*NSPC*/
128 static bool have_enough_predecoded_video_frs(void)
127 STATIC bool have_enough_predecoded_video_frs(void)
129 128 { {
130 129 int64_t pts_min; int64_t pts_min;
131 130 int64_t pts_max; int64_t pts_max;
132 131 int64_t pts_delta; int64_t pts_delta;
133 132 int64_t pts_delta_limit; int64_t pts_delta_limit;
134 133
135 video_dec_frs_lock();
136 if (video_dec_frs_p.eof_receive) {
137 video_dec_frs_unlock();
134 npv_video_dec_frs_lock();
135 if (npv_video_dec_frs_p.eof_receive) {
136 npv_video_dec_frs_unlock();
138 137 return true; return true;
139 } else if (video_dec_frs_p.n == 0) {
140 video_dec_frs_unlock();
138 } else if (npv_video_dec_frs_p.n == 0) {
139 npv_video_dec_frs_unlock();
141 140 return false; return false;
142 141 } }
143 142 /* from here we have at least 1 video fr */ /* from here we have at least 1 video fr */
144 143 /* we presume the video frs are in pts order */ /* we presume the video frs are in pts order */
145 pts_min = video_dec_frs_p.a[0]->pts;
146 pts_max = video_dec_frs_p.a[video_dec_frs_p.n - 1]->pts;
147 video_dec_frs_unlock();
144 pts_min = npv_video_dec_frs_p.a[0]->pts;
145 pts_max = npv_video_dec_frs_p.a[npv_video_dec_frs_p.n - 1]->pts;
146 npv_video_dec_frs_unlock();
148 147
149 148 pts_delta = pts_max - pts_min; pts_delta = pts_max - pts_min;
150 149 /* 2 * 0.25s = 500 ms */ /* 2 * 0.25s = 500 ms */
151 pts_delta_limit = 500 * video_st_p.tb.den / video_st_p.tb.num / 1000;
150 pts_delta_limit = 500 * npv_video_st_p.tb.den / npv_video_st_p.tb.num
151 / 1000;
152 152 if (pts_delta >= pts_delta_limit) if (pts_delta >= pts_delta_limit)
153 153 return true; return true;
154 154 return false; return false;
155 155 } }
156 static void video(void) { loop /* infinite loop */
156 STATIC void video(void) { loop /* infinite loop */
157 157 { {
158 158 if (have_enough_predecoded_video_frs()) { if (have_enough_predecoded_video_frs()) {
159 159 wait(250000000); /* (audio rate/4)~0.25s */ wait(250000000); /* (audio rate/4)~0.25s */
160 160 continue; continue;
161 161 } }
162 162 /* can be long, finer-grained locking is done in there */ /* can be long, finer-grained locking is done in there */
163 video_pkts_send();
164 video_dec_frs_receive_avail();
163 npv_video_pkts_send();
164 npv_video_dec_frs_receive_avail();
165 165 }} }}
166 static void *video_thd_entry(void *arg)
166 STATIC void *video_thd_entry(void *arg)
167 167 { {
168 168 int r; int r;
169 169 sigset_t sset; sigset_t sset;
File npv/pipeline/local/state.frag.c changed (mode: 100644) (index 7c7ba37..c537fb4)
1 static avcodec_pkt_ref_t *eof_pkt_l;
1 STATIC avcodec_pkt_ref_t *eof_pkt_l;
File npv/pipeline/namespace/main.c changed (mode: 100644) (index 60ff3b0..3b29232)
3 3 /* some struct fields */ /* some struct fields */
4 4 #define sz size #define sz size
5 5 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
6 #define audio pipeline_audio
7 #define audio_thd_entry pipeline_audio_thd_entry
8 #define eof_pkt_l pipeline_eof_pkt_l
9 #define read pipeline_read
10 #define read_thd_entry pipeline_read_thd_entry
11 #define timer_ack pipeline_timer_ack
12 #define timer_init_once pipeline_timer_init_once
13 #define video pipeline_video
14 #define video_thd_entry pipeline_video_thd_entry
15 #define wait pipeline_wait
6 #define audio npv_pipeline_audio
7 #define audio_thd_entry npv_pipeline_audio_thd_entry
8 #define eof_pkt_l npv_pipeline_eof_pkt_l
9 #define have_enough_predecoded_audio_frs npv_pipeline_have_enough_predecoded_audio_frs
10 #define have_enough_predecoded_video_frs npv_pipeline_have_enough_predecoded_video_frs
11 #define read npv_pipeline_read
12 #define read_thd_entry npv_pipeline_read_thd_entry
13 #define timer_ack npv_pipeline_timer_ack
14 #define timer_init_once npv_pipeline_timer_init_once
15 #define video npv_pipeline_video
16 #define video_thd_entry npv_pipeline_video_thd_entry
17 #define wait npv_pipeline_wait
16 18 /*============================================================================*/ /*============================================================================*/
17 19 #else #else
20 #undef audio
21 #undef audio_thd_entry
18 22 #undef eof_pkt_l #undef eof_pkt_l
23 #undef have_enough_predecoded_audio_frs
24 #undef have_enough_predecoded_video_frs
19 25 #undef read #undef read
20 26 #undef read_thd_entry #undef read_thd_entry
21 #undef audio
22 #undef audio_thd_entry
23 27 #undef timer_ack #undef timer_ack
24 28 #undef timer_init_once #undef timer_init_once
25 29 #undef video #undef video
File npv/pipeline/namespace/public.h changed (mode: 100644) (index 860a58c..f8f4917)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define audio_thd_start pipeline_audio_thd_start
3 #define init_once pipeline_init_once
4 #define limits_lock pipeline_limits_lock
5 #define limits_p pipeline_limits_p
6 #define limits_t pipeline_limits_t
7 #define limits_unlock pipeline_limits_unlock
8 #define limits_reset pipeline_limits_reset
9 #define prefill_reset pipeline_prefill_reset
10 #define read_thd_start pipeline_read_thd_start
11 #define video_thd_start pipeline_video_thd_start
2 #define audio_thd_start npv_pipeline_audio_thd_start
3 #define init_once npv_pipeline_init_once
4 #define limits_lock npv_pipeline_limits_lock
5 #define limits_p npv_pipeline_limits_p
6 #define limits_t npv_pipeline_limits_t
7 #define limits_unlock npv_pipeline_limits_unlock
8 #define limits_reset npv_pipeline_limits_reset
9 #define prefill_reset npv_pipeline_prefill_reset
10 #define read_thd_start npv_pipeline_read_thd_start
11 #define video_thd_start npv_pipeline_video_thd_start
12 12 /*============================================================================*/ /*============================================================================*/
13 13 #else #else
14 14 #undef audio_thd_start #undef audio_thd_start
File npv/pipeline/public.h changed (mode: 100644) (index dfc672a..4a3affe)
... ... struct limits_t {
28 28 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
29 29 #include "npv/pipeline/public/state.frag.h" #include "npv/pipeline/public/state.frag.h"
30 30 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
31 static void limits_reset(void);
32 static void prefill_reset(u8 percent);
33 static void init_once(void);
34 static void limits_lock(void);
35 static void limits_unlock(void);
36 static void read_thd_start(void);
37 static void audio_thd_start(void);
38 static void video_thd_start(void);
31 STATIC void limits_reset(void);
32 STATIC void prefill_reset(u8 percent);
33 STATIC void init_once(void);
34 STATIC void limits_lock(void);
35 STATIC void limits_unlock(void);
36 STATIC void read_thd_start(void);
37 STATIC void audio_thd_start(void);
38 STATIC void video_thd_start(void);
39 39 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
40 40 #define CLEANUP #define CLEANUP
41 41 #include "npv/pipeline/namespace/public.h" #include "npv/pipeline/namespace/public.h"
File npv/pipeline/public/code.frag.c changed (mode: 100644) (index cfb684b..4cbc664)
1 static void limits_reset(void)
1 STATIC void limits_reset(void)
2 2 { {
3 3 limits_p.pkts.audio_bytes_n = 0; limits_p.pkts.audio_bytes_n = 0;
4 4 limits_p.pkts.video_bytes_n = 0; limits_p.pkts.video_bytes_n = 0;
 
... ... static void limits_reset(void)
8 8 /* ~8s of 10Mb video */ /* ~8s of 10Mb video */
9 9 limits_p.pkts.limit.video_bytes_n = 10000000 / 8 * 8; limits_p.pkts.limit.video_bytes_n = 10000000 / 8 * 8;
10 10 } }
11 static void prefill_reset(u8 percent)
11 STATIC void prefill_reset(u8 percent)
12 12 { {
13 13 if (percent > 100) if (percent > 100)
14 14 FATALP("invalid prefill of %u%% for the buffer of packet queues\n", percent); FATALP("invalid prefill of %u%% for the buffer of packet queues\n", percent);
 
... ... static void prefill_reset(u8 percent)
25 25 POUTP("prefill for the packet queue buffers is disabled\n"); POUTP("prefill for the packet queue buffers is disabled\n");
26 26 } }
27 27 } }
28 static void init_once(void)
28 STATIC void init_once(void)
29 29 { {
30 30 int r; int r;
31 31
 
... ... static void init_once(void)
39 39 if (r != 0) if (r != 0)
40 40 FATALP("unable to initialize the mutex to guard the accounting of limits\n"); FATALP("unable to initialize the mutex to guard the accounting of limits\n");
41 41 } }
42 static void limits_lock(void)
42 STATIC void limits_lock(void)
43 43 { {
44 44 int r; int r;
45 45
 
... ... static void limits_lock(void)
47 47 if (r != 0) if (r != 0)
48 48 FATALP("unable to lock the limits\n"); FATALP("unable to lock the limits\n");
49 49 } }
50 static void limits_unlock(void)
50 STATIC void limits_unlock(void)
51 51 { {
52 52 int r; int r;
53 53
 
... ... static void limits_unlock(void)
55 55 if (r != 0) if (r != 0)
56 56 FATALP("unable to unlock the limits\n"); FATALP("unable to unlock the limits\n");
57 57 } }
58 static void read_thd_start(void)
58 STATIC void read_thd_start(void)
59 59 { {
60 60 int r; int r;
61 61 pthread_t id; pthread_t id;
 
... ... static void read_thd_start(void)
73 73 POUTP("read thread %lu\n", (unsigned long)id); POUTP("read thread %lu\n", (unsigned long)id);
74 74 pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
75 75 } }
76 static void audio_thd_start(void)
76 STATIC void audio_thd_start(void)
77 77 { {
78 78 int r; int r;
79 79 pthread_t id; pthread_t id;
 
... ... static void audio_thd_start(void)
91 91 POUTP("audio thread %lu\n", (unsigned long)id); POUTP("audio thread %lu\n", (unsigned long)id);
92 92 pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
93 93 } }
94 static void video_thd_start(void)
94 STATIC void video_thd_start(void)
95 95 { {
96 96 int r; int r;
97 97 pthread_t id; pthread_t id;
File npv/pipeline/public/state.frag.h changed (mode: 100644) (index 658187e..7850854)
1 static struct pipeline_limits_t limits_p;
1 STATIC struct limits_t limits_p;
File npv/pkt_q/local/code.frag.c changed (mode: 100644) (index 9d70250..d1d4c92)
1 static void grow(struct pkt_q_t *this)
1 STATIC void grow(struct pkt_q_t *this)
2 2 { {
3 3 u32 p; u32 p;
4 4 u32 new_idx; u32 new_idx;
File npv/pkt_q/namespace/main.c changed (mode: 100644) (index 4199cba..c7f494e)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define grow pkt_q_grow
2 #define grow npv_pkt_q_grow
3 3 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
4 4 /* some struct field names */ /* some struct field names */
5 5 #define sz size #define sz size
File npv/pkt_q/namespace/public.h changed (mode: 100644) (index f9f0b15..78726a3)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define deq pkt_q_deq
3 #define enq pkt_q_enq
4 #define has_eof pkt_q_has_eof
5 #define lock pkt_q_lock
6 #define new pkt_q_new
7 #define pkt_q_t pkt_q_t
8 #define unlock pkt_q_unlock
9 #define unref_all pkt_q_unref_all
2 #define deq npv_pkt_q_deq
3 #define enq npv_pkt_q_enq
4 #define has_eof npv_pkt_q_has_eof
5 #define lock npv_pkt_q_lock
6 #define new npv_pkt_q_new
7 #define pkt_q_t npv_pkt_q_t
8 #define unlock npv_pkt_q_unlock
9 #define unref_all npv_pkt_q_unref_all
10 10 /*============================================================================*/ /*============================================================================*/
11 11 #else #else
12 12 #undef lock #undef lock
File npv/pkt_q/public.h changed (mode: 100644) (index 0eea2d0..63b40eb)
... ... struct pkt_q_t {
16 16 avcodec_pkt_ref_t **q; avcodec_pkt_ref_t **q;
17 17 u8 *msg_hdr; u8 *msg_hdr;
18 18 }; };
19 static void lock(struct pkt_q_t *this);
20 static void unlock(struct pkt_q_t *this);
21 static void enq(struct pkt_q_t *this, avcodec_pkt_ref_t *pr);
22 static void deq(struct pkt_q_t *this);
23 static void unref_all(struct pkt_q_t *this);
24 static struct pkt_q_t *new(u8 *msg_hdr);
25 static bool has_eof(struct pkt_q_t *this);
19 STATIC void lock(struct pkt_q_t *this);
20 STATIC void unlock(struct pkt_q_t *this);
21 STATIC void enq(struct pkt_q_t *this, avcodec_pkt_ref_t *pr);
22 STATIC void deq(struct pkt_q_t *this);
23 STATIC void unref_all(struct pkt_q_t *this);
24 STATIC struct pkt_q_t *new(u8 *msg_hdr);
25 STATIC bool has_eof(struct pkt_q_t *this);
26 26 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
27 27 #define CLEANUP #define CLEANUP
28 28 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/pkt_q/public/code.frag.c changed (mode: 100644) (index 5377ed1..73121c9)
1 static void lock(struct pkt_q_t *this)
1 STATIC void lock(struct pkt_q_t *this)
2 2 { {
3 3 int r; int r;
4 4
 
... ... static void lock(struct pkt_q_t *this)
6 6 if (r != 0) if (r != 0)
7 7 FATALXPQ("%d:unable to lock packet queue\n", r); FATALXPQ("%d:unable to lock packet queue\n", r);
8 8 } }
9 static void unlock(struct pkt_q_t *this)
9 STATIC void unlock(struct pkt_q_t *this)
10 10 { {
11 11 int r; int r;
12 12
 
... ... static void unlock(struct pkt_q_t *this)
15 15 FATALXPQ("%d:unable to unlock packet queue\n", r); FATALXPQ("%d:unable to unlock packet queue\n", r);
16 16 } }
17 17 /* actually rotate the pkt ref ptrs */ /* actually rotate the pkt ref ptrs */
18 static void deq(struct pkt_q_t *this)
18 STATIC void deq(struct pkt_q_t *this)
19 19 { {
20 20 if (this->n > 1) { if (this->n > 1) {
21 21 avcodec_pkt_ref_t *save; avcodec_pkt_ref_t *save;
 
... ... static void deq(struct pkt_q_t *this)
28 28 this->n--; this->n--;
29 29 } }
30 30 /* steal the pkt reference */ /* steal the pkt reference */
31 static void enq(struct pkt_q_t *this, avcodec_pkt_ref_t *pr)
31 STATIC void enq(struct pkt_q_t *this, avcodec_pkt_ref_t *pr)
32 32 { {
33 33 if (this->n == this->n_max) if (this->n == this->n_max)
34 34 grow(this); grow(this);
35 35 avcodec_pkt_move_ref(this->q[this->n], pr); avcodec_pkt_move_ref(this->q[this->n], pr);
36 36 ++this->n; ++this->n;
37 37 } }
38 static void unref_all(struct pkt_q_t *this)
38 STATIC void unref_all(struct pkt_q_t *this)
39 39 { {
40 40 u32 pr; u32 pr;
41 41
 
... ... static void unref_all(struct pkt_q_t *this)
48 48 } }
49 49 this->n = 0; this->n = 0;
50 50 } }
51 static struct pkt_q_t *new(u8 *msg_hdr)
51 STATIC struct pkt_q_t *new(u8 *msg_hdr)
52 52 { {
53 53 int r; int r;
54 54 struct pkt_q_t *this; struct pkt_q_t *this;
 
... ... static struct pkt_q_t *new(u8 *msg_hdr)
65 65 FATALPQ("unable to init the mutex for the %s packet queue\n", msg_hdr); FATALPQ("unable to init the mutex for the %s packet queue\n", msg_hdr);
66 66 return this; return this;
67 67 } }
68 static bool has_eof(struct pkt_q_t *this)
68 STATIC bool has_eof(struct pkt_q_t *this)
69 69 { {
70 70 if (this->n != 0) { if (this->n != 0) {
71 71 avcodec_pkt_ref_t *last; avcodec_pkt_ref_t *last;
File npv/public/state.frag.h changed (mode: 100644) (index 5764407..d42064a)
1 static int ep_fd_p;
2 static bool paused_p;
1 STATIC int ep_fd_p;
2 STATIC bool paused_p;
File npv/thdsws/local/code.frag.c changed (mode: 100644) (index cc7d041..9edf3ed)
... ... struct thdsws_ctx_private_t {
4 4 pthread_cond_t have_fr_to_scale; pthread_cond_t have_fr_to_scale;
5 5 struct SwsContext *sws; struct SwsContext *sws;
6 6 }; };
7 /*NSPC*/
8 static void state_lock(struct thdsws_ctx_private_t *ctx_priv)
7 STATIC void state_lock(struct thdsws_ctx_private_t *ctx_priv)
9 8 { {
10 9 int r; int r;
11 10
 
... ... static void state_lock(struct thdsws_ctx_private_t *ctx_priv)
13 12 if (r != 0) if (r != 0)
14 13 FATALTS("unable to lock the state\n"); FATALTS("unable to lock the state\n");
15 14 } }
16 /*NSPC*/
17 static void state_unlock(struct thdsws_ctx_private_t *ctx_priv)
15 STATIC void state_unlock(struct thdsws_ctx_private_t *ctx_priv)
18 16 { {
19 17 int r; int r;
20 18
 
... ... static void state_unlock(struct thdsws_ctx_private_t *ctx_priv)
22 20 if (r != 0) if (r != 0)
23 21 FATALTS("unable to unlock the state\n"); FATALTS("unable to unlock the state\n");
24 22 } }
25 static void do_work(struct thdsws_ctx_t *ctx, struct thdsws_ctx_private_t *ctx_priv)
23 STATIC void do_work(struct thdsws_ctx_t *ctx, struct thdsws_ctx_private_t *ctx_priv)
26 24 { {
27 25 ctx_priv->sws = sws_get_cached_ctx(ctx_priv->sws, ctx_priv->sws = sws_get_cached_ctx(ctx_priv->sws,
28 26 (int)ctx->cfg.width, (int)ctx->cfg.height, ctx->cfg.src_fmt, (int)ctx->cfg.width, (int)ctx->cfg.height, ctx->cfg.src_fmt,
 
... ... static void do_work(struct thdsws_ctx_t *ctx, struct thdsws_ctx_private_t *ctx_p
41 39 } }
42 40 #define IDLE 0 #define IDLE 0
43 41 #define RUNNING 1 #define RUNNING 1
44 static void worker(struct thdsws_ctx_t *ctx,
42 STATIC void worker(struct thdsws_ctx_t *ctx,
45 43 struct thdsws_ctx_private_t *ctx_priv) struct thdsws_ctx_private_t *ctx_priv)
46 44 { {
47 45 /* on entry the state must be locked */ /* on entry the state must be locked */
 
... ... static void worker(struct thdsws_ctx_t *ctx,
68 66 } }
69 67 #undef IDLE #undef IDLE
70 68 #undef RUNNING #undef RUNNING
71 static void *worker_entry(void *arg)
69 STATIC void *worker_entry(void *arg)
72 70 { {
73 71 int r; int r;
74 72 sigset_t sset; sigset_t sset;
File npv/thdsws/main.c changed (mode: 100644) (index 1a7d68c..b9b1c00)
16 16 #include "npv/thdsws/public.h" #include "npv/thdsws/public.h"
17 17 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
18 18 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
19 #include "npv/thdsws/namespace/public.h"
19 20 #include "npv/thdsws/namespace/main.c" #include "npv/thdsws/namespace/main.c"
20 21 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
21 22 #define FATALTS(fmt, ...) FATAL("scaler:" fmt, ##__VA_ARGS__) #define FATALTS(fmt, ...) FATAL("scaler:" fmt, ##__VA_ARGS__)
 
29 30 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
30 31 #define CLEANUP #define CLEANUP
31 32 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
33 #include "npv/thdsws/namespace/public.h"
32 34 #include "npv/thdsws/namespace/main.c" #include "npv/thdsws/namespace/main.c"
33 35 #undef CLEANUP #undef CLEANUP
34 36 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
File npv/thdsws/namespace/main.c changed (mode: 100644) (index 9b7fb3d..6bc4dbc)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define worker_entry thdsws_worker_entry
3 #define worker thdsws_worker
4 #define do_work thdsws_do_work
2 #define worker_entry npv_thdsws_worker_entry
3 #define worker npv_thdsws_worker
4 #define do_work npv_thdsws_do_work
5 #define state_lock npv_thdsws_state_lock
6 #define state_unlock npv_thdsws_state_unlock
5 7 #else #else
6 8 #undef worker_entry #undef worker_entry
7 9 #undef worker #undef worker
8 10 #undef do_work #undef do_work
11 #undef state_lock
12 #undef state_unlock
9 13 #endif #endif
File npv/thdsws/namespace/public.h added (mode: 100644) (index 0000000..a183b54)
1 #ifndef CLEANUP
2 #define thdsws_ctx_t npv_thdsws_ctx_t
3 #define thdsws_init_once npv_thdsws_init_once
4 #define thdsws_is_busy npv_thdsws_is_busy
5 #define thdsws_run npv_thdsws_run
6 #define thdsws_wait_for_idle npv_thdsws_wait_for_idle
7 #else
8 #undef thdsws_ctx_t
9 #undef thdsws_init_once
10 #undef thdsws_is_busy
11 #undef thdsws_run
12 #undef thdsws_wait_for_idle
13 #endif
File npv/thdsws/public.h changed (mode: 100644) (index d1eb1e3..bbdb6a1)
11 11 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
12 12 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
13 13 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
14 #include "npv/thdsws/namespace/public.h"
14 15 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
15 16 struct thdsws_ctx_t { struct thdsws_ctx_t {
16 17 /* XXX: we use the scaler only for pix fmt conv */ /* XXX: we use the scaler only for pix fmt conv */
 
... ... struct thdsws_ctx_t {
33 34
34 35 void *private; void *private;
35 36 }; };
36 static struct thdsws_ctx_t *thdsws_init_once(void);
37 static bool thdsws_is_busy(struct thdsws_ctx_t *ctx);
38 static void thdsws_run(struct thdsws_ctx_t *ctx);
39 static void thdsws_wait_for_idle(struct thdsws_ctx_t *ctx);
37 STATIC struct thdsws_ctx_t *thdsws_init_once(void);
38 STATIC bool thdsws_is_busy(struct thdsws_ctx_t *ctx);
39 STATIC void thdsws_run(struct thdsws_ctx_t *ctx);
40 STATIC void thdsws_wait_for_idle(struct thdsws_ctx_t *ctx);
40 41 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
41 42 #define CLEANUP #define CLEANUP
42 43 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
44 #include "npv/thdsws/namespace/public.h"
43 45 #undef CLEANUP #undef CLEANUP
44 46 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
45 47 #endif #endif
File npv/thdsws/public/code.frag.c changed (mode: 100644) (index 92102bb..f993791)
1 1 #define RUNNING 1 #define RUNNING 1
2 static void thdsws_run(struct thdsws_ctx_t *ctx)
2 STATIC void thdsws_run(struct thdsws_ctx_t *ctx)
3 3 { {
4 4 int r; int r;
5 5 struct thdsws_ctx_private_t *ctx_priv; struct thdsws_ctx_private_t *ctx_priv;
 
... ... static void thdsws_run(struct thdsws_ctx_t *ctx)
17 17 } }
18 18 #undef RUNNING #undef RUNNING
19 19 #define RUNNING 1 #define RUNNING 1
20 static bool thdsws_is_busy(struct thdsws_ctx_t *ctx)
20 STATIC bool thdsws_is_busy(struct thdsws_ctx_t *ctx)
21 21 { {
22 22 struct thdsws_ctx_private_t *ctx_priv; struct thdsws_ctx_private_t *ctx_priv;
23 23 bool r; bool r;
 
... ... static bool thdsws_is_busy(struct thdsws_ctx_t *ctx)
33 33 } }
34 34 #undef RUNNING #undef RUNNING
35 35 #define IDLE 0 #define IDLE 0
36 static struct thdsws_ctx_t *thdsws_init_once(void)
36 STATIC struct thdsws_ctx_t *thdsws_init_once(void)
37 37 { {
38 38 int r; int r;
39 39 pthread_t worker; pthread_t worker;
 
... ... static struct thdsws_ctx_t *thdsws_init_once(void)
75 75 #undef IDLE #undef IDLE
76 76 #define TIME_UNIT_NS 1000000 /* 1ms */ #define TIME_UNIT_NS 1000000 /* 1ms */
77 77 #define TIMEOUT_UNITS_N 100 /* 100 * 1 ms = 100 ms */ #define TIMEOUT_UNITS_N 100 /* 100 * 1 ms = 100 ms */
78 static void thdsws_wait_for_idle(struct thdsws_ctx_t *ctx)
78 STATIC void thdsws_wait_for_idle(struct thdsws_ctx_t *ctx)
79 79 { {
80 80 u8 nanoloops_n; u8 nanoloops_n;
81 81
File npv/video/local/code.frag.c changed (mode: 100644) (index f2f6f2a..8115561)
1 static void init_once_local(void)
1 STATIC void init_once_local(void)
2 2 { {
3 3 u8 i; u8 i;
4 4
 
... ... static void init_once_local(void)
18 18 blit_l[i].vp.bottom_right.z = -1; blit_l[i].vp.bottom_right.z = -1;
19 19 ++i; ++i;
20 20 } }
21 receive_fr = avutil_video_fr_ref_alloc();
21 receive_fr_l = avutil_video_fr_ref_alloc();
22 22 } }
23 static void scaler_img_create(avutil_video_fr_ref_t *fr)
23 STATIC void scaler_img_create(avutil_video_fr_ref_t *fr)
24 24 { {
25 25 struct vk_img_create_info_t info; struct vk_img_create_info_t info;
26 26 s32 r; s32 r;
 
... ... static void scaler_img_create(avutil_video_fr_ref_t *fr)
42 42 vk_create_img(&info, &scaler_p.img.vk); vk_create_img(&info, &scaler_p.img.vk);
43 43 IF_FATALVVK("%d:device:%p:unable to create scaler frame image\n", r, npv_vk_surf_p.dev.vk); IF_FATALVVK("%d:device:%p:unable to create scaler frame image\n", r, npv_vk_surf_p.dev.vk);
44 44 } }
45 static void img_mem_barrier_run_once(struct vk_img_mem_barrier_t *b)
45 STATIC void img_mem_barrier_run_once(struct vk_img_mem_barrier_t *b)
46 46 { {
47 47 s32 r; s32 r;
48 48 struct vk_cb_begin_info_t begin_info; struct vk_cb_begin_info_t begin_info;
 
... ... static void img_mem_barrier_run_once(struct vk_img_mem_barrier_t *b)
78 78 IF_FATALVVK("%d:command buffer:%p:unable to reset the initial layout transition command buffer\n", r, npv_vk_surf_p.dev.cbs[0]); IF_FATALVVK("%d:command buffer:%p:unable to reset the initial layout transition command buffer\n", r, npv_vk_surf_p.dev.cbs[0]);
79 79 } }
80 80 /* once in general layout, the dev sees the img */ /* once in general layout, the dev sees the img */
81 static void scaler_img_layout_to_general(void)
81 STATIC void scaler_img_layout_to_general(void)
82 82 { {
83 83 struct vk_img_mem_barrier_t b; struct vk_img_mem_barrier_t b;
84 84 struct vk_img_subrsrc_range_t *r; struct vk_img_subrsrc_range_t *r;
 
... ... static void scaler_img_layout_to_general(void)
96 96 r->array_layers_n = 1; r->array_layers_n = 1;
97 97 img_mem_barrier_run_once(&b); img_mem_barrier_run_once(&b);
98 98 } }
99 static void scaler_img_subrsrc_layout_get(void)
99 STATIC void scaler_img_subrsrc_layout_get(void)
100 100 { {
101 101 struct vk_img_subrsrc_t s; struct vk_img_subrsrc_t s;
102 102
 
... ... static void scaler_img_subrsrc_layout_get(void)
105 105 s.aspect = vk_img_aspect_color_bit; s.aspect = vk_img_aspect_color_bit;
106 106 vk_get_img_subrsrc_layout(scaler_p.img.vk, &s, &scaler_p.img.layout); vk_get_img_subrsrc_layout(scaler_p.img.vk, &s, &scaler_p.img.layout);
107 107 } }
108 static void tmp_scaler_img_mem_rqmts_get(void)
108 STATIC void tmp_scaler_img_mem_rqmts_get(void)
109 109 { {
110 110 struct vk_img_mem_rqmts_info_t info; struct vk_img_mem_rqmts_info_t info;
111 111 struct vk_mem_rqmts_t *rqmts; struct vk_mem_rqmts_t *rqmts;
 
... ... static void tmp_scaler_img_mem_rqmts_get(void)
123 123 #define WANTED_MEM_PROPS (vk_mem_prop_host_visible_bit \ #define WANTED_MEM_PROPS (vk_mem_prop_host_visible_bit \
124 124 | vk_mem_prop_host_cached_bit) | vk_mem_prop_host_cached_bit)
125 125 #define IS_DEV_LOCAL(x) (((x)->prop_flags & vk_mem_prop_dev_local_bit) != 0) #define IS_DEV_LOCAL(x) (((x)->prop_flags & vk_mem_prop_dev_local_bit) != 0)
126 static bool match_mem_type(u8 mem_type_idx,
126 STATIC bool match_mem_type(u8 mem_type_idx,
127 127 struct vk_mem_rqmts_t *img_rqmts, bool ignore_gpu_is_discret) struct vk_mem_rqmts_t *img_rqmts, bool ignore_gpu_is_discret)
128 128 { {
129 129 struct vk_mem_type_t *mem_type; struct vk_mem_type_t *mem_type;
 
... ... static bool match_mem_type(u8 mem_type_idx,
142 142 } }
143 143 #undef WANTED_MEM_PROPS #undef WANTED_MEM_PROPS
144 144 #undef IS_DEV_LOCAL #undef IS_DEV_LOCAL
145 static bool try_alloc_scaler_img_dev_mem(struct vk_mem_rqmts_t *img_rqmts,
145 STATIC bool try_alloc_scaler_img_dev_mem(struct vk_mem_rqmts_t *img_rqmts,
146 146 u8 mem_type_idx) u8 mem_type_idx)
147 147 { {
148 148 struct vk_mem_alloc_info_t info; struct vk_mem_alloc_info_t info;
 
... ... static bool try_alloc_scaler_img_dev_mem(struct vk_mem_rqmts_t *img_rqmts,
167 167 * retry with only host visible and host cached mem. * retry with only host visible and host cached mem.
168 168 */ */
169 169 #define IGNORE_GPU_IS_DISCRET true #define IGNORE_GPU_IS_DISCRET true
170 static void scaler_img_dev_mem_alloc(void)
170 STATIC void scaler_img_dev_mem_alloc(void)
171 171 { {
172 172 struct vk_mem_rqmts_t *img_rqmts; struct vk_mem_rqmts_t *img_rqmts;
173 173 u8 mem_type; u8 mem_type;
 
... ... static void scaler_img_dev_mem_alloc(void)
200 200 FATALVVK("physical device:%p:unable to find proper memory type or to allocate memory\n", npv_vk_surf_p.dev.phydev.vk); FATALVVK("physical device:%p:unable to find proper memory type or to allocate memory\n", npv_vk_surf_p.dev.phydev.vk);
201 201 } }
202 202 #undef IGNORE_GPU_IS_DISCRET #undef IGNORE_GPU_IS_DISCRET
203 static void scaler_img_dev_mem_bind(void)
203 STATIC void scaler_img_dev_mem_bind(void)
204 204 { {
205 205 struct vk_bind_img_mem_info_t info; struct vk_bind_img_mem_info_t info;
206 206 s32 r; s32 r;
 
... ... static void scaler_img_dev_mem_bind(void)
216 216 vk_bind_img_mem(&info); vk_bind_img_mem(&info);
217 217 IF_FATALVVK("%d:device:%p:scaler image:unable to bind device memory to image\n", r, npv_vk_surf_p.dev.vk); IF_FATALVVK("%d:device:%p:scaler image:unable to bind device memory to image\n", r, npv_vk_surf_p.dev.vk);
218 218 } }
219 static void scaler_img_dev_mem_map(void)
219 STATIC void scaler_img_dev_mem_map(void)
220 220 { {
221 221 s32 r; s32 r;
222 222
223 223 vk_map_mem(scaler_p.img.dev_mem, &scaler_p.img.data); vk_map_mem(scaler_p.img.dev_mem, &scaler_p.img.data);
224 224 IF_FATALVVK("%d:device:%p:scaler image:unable to map image memory\n", r, npv_vk_surf_p.dev.vk); IF_FATALVVK("%d:device:%p:scaler image:unable to map image memory\n", r, npv_vk_surf_p.dev.vk);
225 225 } }
226 static void dec_a_grow(void)
226 STATIC void dec_a_grow(void)
227 227 { {
228 228 u16 new_idx; u16 new_idx;
229 229
 
... ... static void dec_a_grow(void)
248 248 } }
249 249 #define NO_FR 0 #define NO_FR 0
250 250 /* extract a fr ref, shift the a, push it back at the e, and unref its bufs */ /* extract a fr ref, shift the a, push it back at the e, and unref its bufs */
251 static void fr_drop(u16 fr)
251 STATIC void fr_drop(u16 fr)
252 252 { {
253 253 struct dec_fr_priv_t *priv_save; struct dec_fr_priv_t *priv_save;
254 254 avutil_video_fr_ref_t *save; avutil_video_fr_ref_t *save;
 
... ... static void fr_drop(u16 fr)
275 275 } }
276 276 #undef NO_FR #undef NO_FR
277 277 #define NO_FR 0 #define NO_FR 0
278 static void frs_drop(s64 now)
278 STATIC void frs_drop(s64 now)
279 279 { {
280 280 s64 low; s64 low;
281 281 s64 threshold; s64 threshold;
 
... ... static void frs_drop(s64 now)
297 297
298 298 /* keep the fr the scaler is related to */ /* keep the fr the scaler is related to */
299 299 if ((dec_frs_p.a[fr] != scaler_p.img.fr) && (pts < low)) { if ((dec_frs_p.a[fr] != scaler_p.img.fr) && (pts < low)) {
300 if (dec_frs_p.a[fr] == last_fr_sent_to_pe)
301 last_fr_sent_to_pe = NO_FR;
300 if (dec_frs_p.a[fr] == last_fr_sent_to_pe_l)
301 last_fr_sent_to_pe_l = NO_FR;
302 302 fr_drop(fr); /* do not advance */ fr_drop(fr); /* do not advance */
303 303 } else } else
304 304 ++fr; ++fr;
 
... ... static void frs_drop(s64 now)
306 306 } }
307 307 #undef NO_FR #undef NO_FR
308 308 #define NO_FR 0 #define NO_FR 0
309 static void select_fr(s64 now, avutil_video_fr_ref_t **selected_fr,
309 STATIC void select_fr(s64 now, avutil_video_fr_ref_t **selected_fr,
310 310 struct dec_fr_priv_t **selected_fr_priv) struct dec_fr_priv_t **selected_fr_priv)
311 311 { {
312 312 u16 fr_idx; u16 fr_idx;
 
... ... static void select_fr(s64 now, avutil_video_fr_ref_t **selected_fr,
332 332 } }
333 333 } }
334 334 #undef NO_FR #undef NO_FR
335 static void frs_reset(void)
335 STATIC void frs_reset(void)
336 336 { {
337 337 u16 fr; u16 fr;
338 338
 
... ... static void frs_reset(void)
346 346 } }
347 347 dec_frs_p.n = 0; dec_frs_p.n = 0;
348 348 } }
349 static void scaler_img_destroy(void)
349 STATIC void scaler_img_destroy(void)
350 350 { {
351 351 vk_destroy_img(scaler_p.img.vk); vk_destroy_img(scaler_p.img.vk);
352 352 scaler_p.img.vk = 0; scaler_p.img.vk = 0;
 
... ... static void scaler_img_destroy(void)
355 355 vk_free_mem(scaler_p.img.dev_mem); vk_free_mem(scaler_p.img.dev_mem);
356 356 scaler_p.img.dev_mem = 0; scaler_p.img.dev_mem = 0;
357 357 } }
358 static void blit_compute_offsets(u8 swpchn_img,
358 STATIC void blit_compute_offsets(u8 swpchn_img,
359 359 struct vk_extent_2d_t *new_vp) struct vk_extent_2d_t *new_vp)
360 360 { {
361 361 struct blit_vp_t *vp; struct blit_vp_t *vp;
 
... ... static void blit_compute_offsets(u8 swpchn_img,
368 368 * INTEGER BOUNDS FOR TEXELS COORDS WHICH ARE TAKEN AT THE CENTER OF * INTEGER BOUNDS FOR TEXELS COORDS WHICH ARE TAKEN AT THE CENTER OF
369 369 * EACH PIXEL: NAMELY LAST TEXEL INTEGER BOUND = LAST PIXEL OFFSET + 1. * EACH PIXEL: NAMELY LAST TEXEL INTEGER BOUND = LAST PIXEL OFFSET + 1.
370 370 */ */
371 want_width = new_vp->height * aspect.width / aspect.height;
372 want_height = new_vp->width * aspect.height / aspect.width;
371 want_width = new_vp->height * aspect_ratio.width / aspect_ratio.height;
372 want_height = new_vp->width * aspect_ratio.height / aspect_ratio.width;
373 373 if (want_width < new_vp->width) { if (want_width < new_vp->width) {
374 374 s32 gap; s32 gap;
375 375
 
... ... static void blit_compute_offsets(u8 swpchn_img,
398 398 vp->width = new_vp->width; vp->width = new_vp->width;
399 399 vp->height = new_vp->height; vp->height = new_vp->height;
400 400 } }
401 static void blit_setup(u8 swpchn_img, bool scaler_dims_changed)
401 STATIC void blit_setup(u8 swpchn_img, bool scaler_dims_changed)
402 402 { {
403 403 s32 r; s32 r;
404 404 struct vk_cb_begin_info_t begin_info; struct vk_cb_begin_info_t begin_info;
 
... ... static void blit_setup(u8 swpchn_img, bool scaler_dims_changed)
475 475 } }
476 476 #define READY 0 #define READY 0
477 477 #define NOT_READY 1 #define NOT_READY 1
478 static u8 swpchn_next_img(u32 *swpchn_img) { loop
478 STATIC u8 swpchn_next_img(u32 *swpchn_img) { loop
479 479 { {
480 480 struct vk_acquire_next_img_info_t info; struct vk_acquire_next_img_info_t info;
481 481 s32 r; s32 r;
 
... ... static u8 swpchn_next_img(u32 *swpchn_img) { loop
500 500 #undef NOT_READY #undef NOT_READY
501 501 #define SENT 0 #define SENT 0
502 502 #define SWPCHN_UPDATED 1 #define SWPCHN_UPDATED 1
503 static u8 send_to_pe(u32 swpchn_img)
503 STATIC u8 send_to_pe(u32 swpchn_img)
504 504 { {
505 505 struct vk_submit_info_t submit_info; struct vk_submit_info_t submit_info;
506 506 struct vk_present_info_t present_info; struct vk_present_info_t present_info;
 
... ... static u8 send_to_pe(u32 swpchn_img)
542 542 } }
543 543 #undef SENT #undef SENT
544 544 #undef SWPCHN_UPDATED #undef SWPCHN_UPDATED
545 static void start_scaling(avutil_video_fr_ref_t *fr,
545 STATIC void start_scaling(avutil_video_fr_ref_t *fr,
546 546 struct dec_fr_priv_t *fr_priv, bool *scaler_dims_changed) struct dec_fr_priv_t *fr_priv, bool *scaler_dims_changed)
547 547 { {
548 548 u32 scaled_line_bytes_n; u32 scaled_line_bytes_n;
 
... ... static void start_scaling(avutil_video_fr_ref_t *fr,
573 573 scaler_p.ctx->scale.src_strides = fr->linesize; scaler_p.ctx->scale.src_strides = fr->linesize;
574 574 scaler_p.ctx->scale.dst_slice = scaler_p.img.data; scaler_p.ctx->scale.dst_slice = scaler_p.img.data;
575 575 scaler_p.ctx->scale.dst_stride = scaled_line_bytes_n; scaler_p.ctx->scale.dst_stride = scaled_line_bytes_n;
576 thdsws_run(scaler_p.ctx);
576 npv_thdsws_run(scaler_p.ctx);
577 577 scaler_p.img.fr = fr; scaler_p.img.fr = fr;
578 578 } }
579 static void timer_ack(void)
579 STATIC void timer_ack(void)
580 580 { {
581 581 int r; int r;
582 582 uint64_t exps_n; uint64_t exps_n;
File npv/video/local/state.frag.c changed (mode: 100644) (index 80399e9..6ae80a5)
... ... struct dec_fr_priv_t {
2 2 bool was_qed_to_pe; bool was_qed_to_pe;
3 3 }; };
4 4 /*===========================================================================*/ /*===========================================================================*/
5 static pthread_mutex_t dec_ctx_mutex_l;
6 /*NSPC*/
7 static avutil_video_fr_ref_t *receive_fr;
8 static avcodec_codec_t *dec_l;
9 static struct vk_mem_rqmts_t tmp_mem_rqmts_l;
10 /*NSPC for the types*/
11 static struct {
5 STATIC pthread_mutex_t dec_ctx_mutex_l;
6 STATIC avutil_video_fr_ref_t *receive_fr_l;
7 STATIC avcodec_codec_t *dec_l;
8 STATIC struct vk_mem_rqmts_t tmp_mem_rqmts_l;
9 STATIC struct {
12 10 struct blit_vp_t { struct blit_vp_t {
13 11 s32 width; s32 width;
14 12 s32 height; s32 height;
 
... ... static struct {
16 14 struct vk_offset_3d_t bottom_right; struct vk_offset_3d_t bottom_right;
17 15 } vp; } vp;
18 16 } blit_l[npv_vk_swpchn_imgs_n_max]; } blit_l[npv_vk_swpchn_imgs_n_max];
19 /*NSPC*/
20 static avutil_video_fr_ref_t *last_fr_sent_to_pe;
17 STATIC avutil_video_fr_ref_t *last_fr_sent_to_pe_l;
File npv/video/main.c changed (mode: 100644) (index eedf25e..6ed4966)
9 9 #include <unistd.h> #include <unistd.h>
10 10 #include <stdlib.h> #include <stdlib.h>
11 11 #include <sys/timerfd.h> #include <sys/timerfd.h>
12 #include <xcb.h>
12 #include <xcb/xcb.h>
13 13 #include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
14 14 #include <libavutil/frame.h> #include <libavutil/frame.h>
15 15 #include <libavutil/pixdesc.h> #include <libavutil/pixdesc.h>
File npv/video/namespace/main.c changed (mode: 100644) (index dd8729b..dd118e0)
4 4 #define avutil_video_fr_ref_alloc av_frame_alloc #define avutil_video_fr_ref_alloc av_frame_alloc
5 5 #define avutil_video_fr_unref av_frame_unref #define avutil_video_fr_unref av_frame_unref
6 6 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
7 #define blit_l video_blit_l
8 #define blit_setup video_blit_setup
9 #define dec_a_grow video_dec_a_grow
10 #define dec_ctx_mutex_l video_dec_ctx_mutex_l
11 #define dec_l video_dec_l
12 #define fr_drop video_fr_drop
13 #define frs_drop video_frs_drop
14 #define frs_clear_last_qed_to_pe video_frs_clear_last_qed_to_pe
15 #define frs_reset video_frs_reset
16 #define img_mem_barrier_run_once video_img_mem_barrier_run_once
17 #define init_once_local video_init_once_local
18 #define init_once_public video_init_once_public
19 #define match_mem_type video_match_mem_type
20 #define scaler_img_create video_scaler_img_create
21 #define scaler_img_destroy video_scaler_img_destroy
22 #define scaler_img_dev_mem_alloc video_scaler_img_dev_mem_alloc
23 #define scaler_img_dev_mem_bind video_scaler_img_dev_mem_bind
24 #define scaler_img_dev_mem_map video_scaler_img_dev_mem_map
25 #define scaler_img_layout_to_general video_scaler_img_layout_to_general
26 #define scaler_img_subrsrc_layout_get video_scaler_img_subrsrc_layout_get
27 #define select_fr video_select_fr
28 #define send_to_pe video_send_to_pe
29 #define start_scaling video_start_scaling
30 #define swpchn_next_img video_swpchn_next_img
31 #define timer_ack video_timer_ack
32 #define tmp_mem_rqmts_l video_tmp_mem_rqmts_l
33 #define tmp_scaler_img_mem_rqmts_get video_tmp_scaler_img_mem_rqmts_get
34 #define try_alloc_scaler_img_dev_mem video_try_alloc_scaler_img_dev_mem
7 #define blit_compute_offsets npv_video_blit_compute_offsets
8 #define blit_l npv_video_blit_l
9 #define blit_vp_t npv_video_blit_vp_t
10 #define blit_setup npv_video_blit_setup
11 #define dec_a_grow npv_video_dec_a_grow
12 #define dec_ctx_mutex_l npv_video_dec_ctx_mutex_l
13 #define dec_l npv_video_dec_l
14 #define fr_drop npv_video_fr_drop
15 #define frs_drop npv_video_frs_drop
16 #define frs_clear_last_qed_to_pe npv_video_frs_clear_last_qed_to_pe
17 #define frs_reset npv_video_frs_reset
18 #define img_mem_barrier_run_once npv_video_img_mem_barrier_run_once
19 #define init_once_local npv_video_init_once_local
20 #define init_once_public npv_video_init_once_public
21 #define last_fr_sent_to_pe_l npv_video_last_fr_sent_to_pe_l
22 #define match_mem_type npv_video_match_mem_type
23 #define receive_fr_l npv_video_receive_fr_l
24 #define scaler_img_create npv_video_scaler_img_create
25 #define scaler_img_destroy npv_video_scaler_img_destroy
26 #define scaler_img_dev_mem_alloc npv_video_scaler_img_dev_mem_alloc
27 #define scaler_img_dev_mem_bind npv_video_scaler_img_dev_mem_bind
28 #define scaler_img_dev_mem_map npv_video_scaler_img_dev_mem_map
29 #define scaler_img_layout_to_general npv_video_scaler_img_layout_to_general
30 #define scaler_img_subrsrc_layout_get npv_video_scaler_img_subrsrc_layout_get
31 #define select_fr npv_video_select_fr
32 #define send_to_pe npv_video_send_to_pe
33 #define start_scaling npv_video_start_scaling
34 #define swpchn_next_img npv_video_swpchn_next_img
35 #define timer_ack npv_video_timer_ack
36 #define tmp_mem_rqmts_l npv_video_tmp_mem_rqmts_l
37 #define tmp_scaler_img_mem_rqmts_get npv_video_tmp_scaler_img_mem_rqmts_get
38 #define try_alloc_scaler_img_dev_mem npv_video_try_alloc_scaler_img_dev_mem
35 39 /*============================================================================*/ /*============================================================================*/
36 40 #else #else
37 41 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
 
39 43 #undef avutil_video_fr_ref_alloc #undef avutil_video_fr_ref_alloc
40 44 #undef avutil_video_fr_unref #undef avutil_video_fr_unref
41 45 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
46 #undef blit_compute_offsets
42 47 #undef blit_l #undef blit_l
48 #undef blit_vp_t
43 49 #undef blit_setup #undef blit_setup
44 50 #undef dec_a_grow #undef dec_a_grow
45 51 #undef dec_ctx_mutex_l #undef dec_ctx_mutex_l
 
51 57 #undef img_mem_barrier_run_once #undef img_mem_barrier_run_once
52 58 #undef init_once_local #undef init_once_local
53 59 #undef init_once_public #undef init_once_public
60 #undef last_fr_sent_to_pe_l
54 61 #undef match_mem_type #undef match_mem_type
62 #undef receive_fr_l
55 63 #undef scaler_img_create #undef scaler_img_create
56 64 #undef scaler_img_destroy #undef scaler_img_destroy
57 65 #undef scaler_img_dev_mem_alloc #undef scaler_img_dev_mem_alloc
File npv/video/namespace/public.h changed (mode: 100644) (index cbcd966..15d3149)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define dec_ctx_cfg video_dec_ctx_cfg
3 #define dec_ctx_lock video_dec_ctx_lock
4 #define dec_ctx_p video_dec_ctx_p
5 #define dec_ctx_unlock video_dec_ctx_unlock
6 #define dec_flush video_dec_flush
7 #define dec_fr_priv_t video_dec_fr_priv
8 #define dec_fr_try_receive video_dec_fr_try_receive
9 #define dec_frs_receive_avail video_dec_frs_receive_avail
10 #define dec_frs_lock video_dec_frs_lock
11 #define dec_frs_p video_dec_frs_p
12 #define dec_frs_unlock video_dec_frs_unlock
13 #define init_once video_init_once
14 #define pkt_q_p video_pkt_q_p
15 #define pkts_send video_pkts_send
16 #define scaler_p video_scaler_p
17 #define st_p video_st_p
18 #define timer_fd_p video_timer_fd_p
19 #define timer_slow_start video_timer_slow_start
20 #define timer_start video_timer_start
21 #define timer_evt video_timer_evt
2 #define aspect_ratio npv_video_aspect_ratio
3 #define dec_ctx_cfg npv_video_dec_ctx_cfg
4 #define dec_ctx_lock npv_video_dec_ctx_lock
5 #define dec_ctx_p npv_video_dec_ctx_p
6 #define dec_ctx_unlock npv_video_dec_ctx_unlock
7 #define dec_flush npv_video_dec_flush
8 #define dec_fr_priv_t npv_video_dec_fr_priv
9 #define dec_fr_try_receive npv_video_dec_fr_try_receive
10 #define dec_frs_receive_avail npv_video_dec_frs_receive_avail
11 #define dec_frs_lock npv_video_dec_frs_lock
12 #define dec_frs_p npv_video_dec_frs_p
13 #define dec_frs_unlock npv_video_dec_frs_unlock
14 #define init_once npv_video_init_once
15 #define pkt_q_p npv_video_pkt_q_p
16 #define pkts_send npv_video_pkts_send
17 #define scaler_p npv_video_scaler_p
18 #define st_p npv_video_st_p
19 #define timer_fd_p npv_video_timer_fd_p
20 #define timer_slow_start npv_video_timer_slow_start
21 #define timer_start npv_video_timer_start
22 #define timer_evt npv_video_timer_evt
22 23 /*============================================================================*/ /*============================================================================*/
23 24 #else #else
25 #undef aspect_ratio
24 26 #undef dec_ctx_cfg #undef dec_ctx_cfg
25 27 #undef dec_ctx_lock #undef dec_ctx_lock
26 28 #undef dec_ctx_p #undef dec_ctx_p
File npv/video/public.h changed (mode: 100644) (index b417dac..0fc67ec)
5 5 * copyright (C) 2020 Sylvain BERTRAND * copyright (C) 2020 Sylvain BERTRAND
6 6 */ */
7 7 #include <stdbool.h> #include <stdbool.h>
8 #include <xcb.h>
8 #include <xcb/xcb.h>
9 9 #include <libavformat/avformat.h> #include <libavformat/avformat.h>
10 10 #include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
11 11 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
 
18 18 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
19 19 #include "npv/video/public/state.frag.h" #include "npv/video/public/state.frag.h"
20 20 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
21 static void dec_ctx_cfg(avcodec_params_t *params);
22 static void dec_flush(void);
23 static u8 dec_fr_try_receive(void);
24 static void dec_frs_receive_avail(void);
25 static void init_once(void);
26 static void timer_evt(void);
27 static void timer_start(void);
28 static void timer_slow_start(void);
29 static void dec_ctx_lock(void);
30 static void dec_ctx_unlock(void);
31 static void dec_frs_lock(void);
32 static void dec_frs_unlock(void);
33 static void pkts_send(void);
21 STATIC void dec_ctx_cfg(avcodec_params_t *params);
22 STATIC void dec_flush(void);
23 STATIC u8 dec_fr_try_receive(void);
24 STATIC void dec_frs_receive_avail(void);
25 STATIC void init_once(void);
26 STATIC void timer_evt(void);
27 STATIC void timer_start(void);
28 STATIC void timer_slow_start(void);
29 STATIC void dec_ctx_lock(void);
30 STATIC void dec_ctx_unlock(void);
31 STATIC void dec_frs_lock(void);
32 STATIC void dec_frs_unlock(void);
33 STATIC void pkts_send(void);
34 34 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
35 35 #define CLEANUP #define CLEANUP
36 36 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/video/public/code.frag.c changed (mode: 100644) (index 94fbe1f..0087c16)
1 1 #define NO_FR 0 #define NO_FR 0
2 static void init_once_public(void)
2 STATIC void init_once_public(void)
3 3 { {
4 4 int r; int r;
5 5
 
... ... static void init_once_public(void)
9 9 if (timer_fd_p == -1) if (timer_fd_p == -1)
10 10 FATALV("unable to get a timer file descriptor:%s\n", strerror(errno)); FATALV("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 pkt_q_p = pkt_q_new("video");
12 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)
 
... ... static void init_once_public(void)
30 30 scaler_p.img.data = 0; scaler_p.img.data = 0;
31 31 scaler_p.img.fr = NO_FR; scaler_p.img.fr = NO_FR;
32 32
33 last_fr_sent_to_pe = NO_FR;
33 last_fr_sent_to_pe_l = NO_FR;
34 34
35 aspect.width = 0;
36 aspect.height = 0;
35 aspect_ratio.width = 0;
36 aspect_ratio.height = 0;
37 37
38 38 /* we are targetting AVUTIL_PIX_FMT_RGB32/sRGB */ /* we are targetting AVUTIL_PIX_FMT_RGB32/sRGB */
39 scaler_p.ctx = thdsws_init_once();
39 scaler_p.ctx = npv_thdsws_init_once();
40 40 if (scaler_p.ctx == 0) if (scaler_p.ctx == 0)
41 41 FATALVFF("scaler:unable to initialize\n"); FATALVFF("scaler:unable to initialize\n");
42 42 } }
43 43 #undef NO_FR #undef NO_FR
44 static void init_once(void)
44 STATIC void init_once(void)
45 45 { {
46 46 init_once_public(); init_once_public();
47 47 init_once_local(); init_once_local();
48 48 } }
49 static void dec_ctx_cfg(avcodec_params_t *params)
49 STATIC void dec_ctx_cfg(avcodec_params_t *params)
50 50 { {
51 51 int r; int r;
52 52
 
... ... static void dec_ctx_cfg(avcodec_params_t *params)
68 68 FATALVFF("unable to open the decoder context\n"); FATALVFF("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 aspect.width = params->width;
72 aspect.height = params->height;
71 aspect_ratio.width = params->width;
72 aspect_ratio.height = params->height;
73 73 } }
74 static void timer_start(void)
74 STATIC void timer_start(void)
75 75 { {
76 76 struct itimerspec t; struct itimerspec t;
77 77 int r; int r;
 
... ... static void timer_start(void)
84 84 if (r == -1) if (r == -1)
85 85 FATALV("unable to arm the timer\n"); FATALV("unable to arm the timer\n");
86 86 } }
87 static void timer_slow_start(void)
87 STATIC void timer_slow_start(void)
88 88 { {
89 89 struct itimerspec t; struct itimerspec t;
90 90 int r; int r;
 
... ... static void timer_slow_start(void)
100 100 #define AGAIN 0 #define AGAIN 0
101 101 #define HAVE_FR 1 #define HAVE_FR 1
102 102 #define EOF_DEC 2 #define EOF_DEC 2
103 static u8 dec_fr_try_receive(void)
103 STATIC u8 dec_fr_try_receive(void)
104 104 { {
105 105 int r; int r;
106 106
107 107 dec_ctx_lock(); dec_ctx_lock();
108 r = avcodec_receive_video_fr(dec_ctx_p, receive_fr);
108 r = avcodec_receive_video_fr(dec_ctx_p, receive_fr_l);
109 109 dec_ctx_unlock(); dec_ctx_unlock();
110 110 if (r == AVUTIL_AVERROR(EAGAIN)) if (r == AVUTIL_AVERROR(EAGAIN))
111 111 return AGAIN; return AGAIN;
 
... ... static u8 dec_fr_try_receive(void)
116 116 if (dec_frs_p.n == dec_frs_p.n_max) if (dec_frs_p.n == dec_frs_p.n_max)
117 117 dec_a_grow(); dec_a_grow();
118 118 last = dec_frs_p.n; last = dec_frs_p.n;
119 avutil_video_fr_ref_move(dec_frs_p.a[last], receive_fr);
119 avutil_video_fr_ref_move(dec_frs_p.a[last], receive_fr_l);
120 120 memset(dec_frs_p.priv_a[last], 0, sizeof(**dec_frs_p.priv_a)); memset(dec_frs_p.priv_a[last], 0, sizeof(**dec_frs_p.priv_a));
121 121 ++dec_frs_p.n; ++dec_frs_p.n;
122 122 dec_frs_unlock(); dec_frs_unlock();
 
... ... static u8 dec_fr_try_receive(void)
136 136 #define AGAIN 0 #define AGAIN 0
137 137 #define HAVE_FR 1 #define HAVE_FR 1
138 138 #define EOF_DEC 2 #define EOF_DEC 2
139 static void dec_frs_receive_avail(void) { loop
139 STATIC void dec_frs_receive_avail(void) { loop
140 140 { {
141 141 u8 r; u8 r;
142 142
 
... ... static void dec_frs_receive_avail(void) { loop
150 150 #undef HAVE_FR #undef HAVE_FR
151 151 #undef EOF_DEC #undef EOF_DEC
152 152 #define NO_FR 0 #define NO_FR 0
153 static void dec_flush(void)
153 STATIC void dec_flush(void)
154 154 { {
155 pkt_q_unref_all(pkt_q_p);
155 npv_pkt_q_unref_all(pkt_q_p);
156 156 frs_reset(); frs_reset();
157 157 dec_frs_p.eof_receive = false; dec_frs_p.eof_receive = false;
158 last_fr_sent_to_pe = NO_FR;
158 last_fr_sent_to_pe_l = NO_FR;
159 159 avcodec_flush_bufs(dec_ctx_p); avcodec_flush_bufs(dec_ctx_p);
160 160 } }
161 161 #undef NO_FR #undef NO_FR
162 static void dec_ctx_lock(void)
162 STATIC void dec_ctx_lock(void)
163 163 { {
164 164 int r; int r;
165 165
 
... ... static void dec_ctx_lock(void)
167 167 if (r != 0) if (r != 0)
168 168 FATALV("%d:unable to lock the video decoder context\n", r); FATALV("%d:unable to lock the video decoder context\n", r);
169 169 } }
170 static void dec_ctx_unlock(void)
170 STATIC void dec_ctx_unlock(void)
171 171 { {
172 172 int r; int r;
173 173
 
... ... static void dec_ctx_unlock(void)
175 175 if (r != 0) if (r != 0)
176 176 FATALV("%d:unable to unlock the video decoder context\n", r); FATALV("%d:unable to unlock the video decoder context\n", r);
177 177 } }
178 static void dec_frs_lock(void)
178 STATIC void dec_frs_lock(void)
179 179 { {
180 180 int r; int r;
181 181
 
... ... static void dec_frs_lock(void)
183 183 if (r != 0) if (r != 0)
184 184 FATALV("%d:unable to lock the array of decoder frames\n", r); FATALV("%d:unable to lock the array of decoder frames\n", r);
185 185 } }
186 static void dec_frs_unlock(void)
186 STATIC void dec_frs_unlock(void)
187 187 { {
188 188 int r; int r;
189 189
 
... ... static void dec_frs_unlock(void)
198 198 #define NOT_READY 1 #define NOT_READY 1
199 199 #define SENT 0 #define SENT 0
200 200 /* XXX: we do want to lock the frs q the least amount of time as possible */ /* XXX: we do want to lock the frs q the least amount of time as possible */
201 static void timer_evt(void)
201 STATIC void timer_evt(void)
202 202 { {
203 203 u8 r; u8 r;
204 204 s64 now; s64 now;
 
... ... static void timer_evt(void)
208 208 u32 swpchn_img; u32 swpchn_img;
209 209
210 210 timer_ack(); timer_ack();
211 r = clk_get_video_st_ts(&now);
211 r = npv_clk_get_video_st_ts(&now);
212 212 if (r != TS_FROM_CLK_OK) if (r != TS_FROM_CLK_OK)
213 213 return; return;
214 214 /* lock --------------------------------------------------------------*/ /* lock --------------------------------------------------------------*/
 
... ... static void timer_evt(void)
224 224 if (fr == NO_FR) if (fr == NO_FR)
225 225 return; return;
226 226 /* in pause, we "redraw" the same img all the time */ /* in pause, we "redraw" the same img all the time */
227 if (!npv_paused_p && fr == last_fr_sent_to_pe)
227 if (!npv_paused_p && fr == last_fr_sent_to_pe_l)
228 228 return; return;
229 if (thdsws_is_busy(scaler_p.ctx))
229 if (npv_thdsws_is_busy(scaler_p.ctx))
230 230 return; return;
231 231 if (scaler_p.img.fr != fr) { if (scaler_p.img.fr != fr) {
232 232 start_scaling(fr, fr_priv, &scaler_dims_changed); start_scaling(fr, fr_priv, &scaler_dims_changed);
 
... ... static void timer_evt(void)
242 242 break; break;
243 243 /* r == SWPCHN_UPDATED */ /* r == SWPCHN_UPDATED */
244 244 } }
245 last_fr_sent_to_pe = fr;
245 last_fr_sent_to_pe_l = fr;
246 246 fr_priv->was_qed_to_pe = true; /* drop detection */ fr_priv->was_qed_to_pe = true; /* drop detection */
247 247 } }
248 248 #undef NO_FR #undef NO_FR
 
... ... static void timer_evt(void)
252 252 #undef SENT #undef SENT
253 253 /* we do per-loop fine-grained locking */ /* we do per-loop fine-grained locking */
254 254 #define sz size #define sz size
255 static void pkts_send(void) { loop
255 STATIC void pkts_send(void) { loop
256 256 { {
257 257 int r; int r;
258 258 avcodec_pkt_ref_t *pr; avcodec_pkt_ref_t *pr;
259 259
260 pkt_q_lock(pkt_q_p);
260 npv_pkt_q_lock(pkt_q_p);
261 261 if (pkt_q_p->n == 0) if (pkt_q_p->n == 0)
262 262 goto unlock_and_return; goto unlock_and_return;
263 263 pr = pkt_q_p->q[0]; pr = pkt_q_p->q[0];
 
... ... static void pkts_send(void) { loop
271 271 else if (r != 0) else if (r != 0)
272 272 FATALV("error while sending a packet to the decoder\n"); FATALV("error while sending a packet to the decoder\n");
273 273 /* r == 0 */ /* r == 0 */
274 pipeline_limits_lock();
275 pipeline_limits_p.pkts.video_bytes_n -= pr->sz;
276 pipeline_limits_unlock();
274 npv_pipeline_limits_lock();
275 npv_pipeline_limits_p.pkts.video_bytes_n -= pr->sz;
276 npv_pipeline_limits_unlock();
277 277
278 pkt_q_deq(pkt_q_p);
278 npv_pkt_q_deq(pkt_q_p);
279 279 avcodec_pkt_unref(pr); avcodec_pkt_unref(pr);
280 pkt_q_unlock(pkt_q_p);
280 npv_pkt_q_unlock(pkt_q_p);
281 281 continue; continue;
282 282
283 283 unlock_and_return: unlock_and_return:
284 pkt_q_unlock(pkt_q_p);
284 npv_pkt_q_unlock(pkt_q_p);
285 285 return; return;
286 286 }} }}
287 287 #undef sz #undef sz
File npv/video/public/state.frag.h changed (mode: 100644) (index f0e632b..fb499a9)
1 static avcodec_codec_ctx_t *dec_ctx_p;
2 static struct pkt_q_t *pkt_q_p;
1 STATIC avcodec_codec_ctx_t *dec_ctx_p;
2 STATIC struct npv_pkt_q_t *pkt_q_p;
3 3 /* /*
4 4 * we copy some stream data in the case the stream does vanish or is replaced * we copy some stream data in the case the stream does vanish or is replaced
5 5 * (don't know how ffmpeg does handle this) * (don't know how ffmpeg does handle this)
6 6 */ */
7 static struct {
7 STATIC struct {
8 8 int idx; int idx;
9 9 int id; int id;
10 10 avutil_rational_t tb; avutil_rational_t tb;
11 11 int64_t start_time; int64_t start_time;
12 12 } st_p; } st_p;
13 static int timer_fd_p;
13 STATIC int timer_fd_p;
14 14 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
15 15 struct dec_fr_priv_t; struct dec_fr_priv_t;
16 static struct {
16 STATIC struct {
17 17 pthread_mutex_t mutex; pthread_mutex_t mutex;
18 18
19 19 bool eof_receive; /* "receiving" from the dec returned eof */ bool eof_receive; /* "receiving" from the dec returned eof */
 
... ... static struct {
25 25 struct dec_fr_priv_t **priv_a; struct dec_fr_priv_t **priv_a;
26 26 } dec_frs_p; } dec_frs_p;
27 27 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
28 static struct {
28 STATIC struct {
29 29 pthread_mutex_t mutex; pthread_mutex_t mutex;
30 30 struct { struct {
31 31 struct vk_img_t *vk; struct vk_img_t *vk;
 
... ... static struct {
34 34 void *data; void *data;
35 35 avutil_video_fr_ref_t *fr; avutil_video_fr_ref_t *fr;
36 36 } img; } img;
37 struct thdsws_ctx_t *ctx;
37 struct npv_thdsws_ctx_t *ctx;
38 38 } scaler_p; } scaler_p;
39 39 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
40 /*NSPC*/
41 static struct {
40 STATIC struct {
42 41 u32 width; u32 width;
43 42 u32 height; u32 height;
44 } aspect;
43 } aspect_ratio;
File npv/vk/api_usage.h changed (mode: 100644) (index feaf54e..3668ad1)
... ... r = npv_vk_surf_p.dev.dl_vk_create_sem(npv_vk_surf_p.dev.vk, info, 0, sem)
97 97 /******************************************************************************/ /******************************************************************************/
98 98 /* cherry picked from nyanvk/syms_global.h */ /* cherry picked from nyanvk/syms_global.h */
99 99 #define VK_GLOBAL_SYMS \ #define VK_GLOBAL_SYMS \
100 static void *(*dl_vk_get_instance_proc_addr)(struct vk_instance_t *instance, u8 *name); \
101 static void *(*dl_vk_get_dev_proc_addr)(struct vk_dev_t *dev, u8 *name); \
102 static s32 (*dl_vk_enumerate_instance_version)(u32 *version); \
103 static s32 (*dl_vk_enumerate_instance_layer_props)( \
100 STATIC void *(*npv_dl_vk_get_instance_proc_addr)(\
101 struct vk_instance_t *instance,\
102 u8 *name);\
103 STATIC void *(*npv_dl_vk_get_dev_proc_addr)(\
104 struct vk_dev_t *dev,\
105 u8 *name);\
106 STATIC s32 (*npv_dl_vk_enumerate_instance_version)(u32 *version); \
107 STATIC s32 (*npv_dl_vk_enumerate_instance_layer_props)( \
104 108 u32 *props_n, \ u32 *props_n, \
105 109 struct vk_layer_props_t *props); \ struct vk_layer_props_t *props); \
106 static s32 (*dl_vk_enumerate_instance_ext_props)( \
110 STATIC s32 (*npv_dl_vk_enumerate_instance_ext_props)( \
107 111 u8 *layer_name, \ u8 *layer_name, \
108 112 u32 *props_n, \ u32 *props_n, \
109 113 struct vk_ext_props_t *props); \ struct vk_ext_props_t *props); \
110 static s32 (*dl_vk_create_instance)( \
114 STATIC s32 (*npv_dl_vk_create_instance)( \
111 115 struct vk_instance_create_info_t *info, \ struct vk_instance_create_info_t *info, \
112 116 void *allocator, \ void *allocator, \
113 117 struct vk_instance_t **instance); \ struct vk_instance_t **instance); \
114 static s32 (*dl_vk_enumerate_phydevs)( \
118 STATIC s32 (*npv_dl_vk_enumerate_phydevs)( \
115 119 struct vk_instance_t *instance, \ struct vk_instance_t *instance, \
116 120 u32 *phydevs_n, \ u32 *phydevs_n, \
117 121 struct vk_phydev_t **phydevs); \ struct vk_phydev_t **phydevs); \
118 static s32 (*dl_vk_enumerate_dev_ext_props)( \
122 STATIC s32 (*npv_dl_vk_enumerate_dev_ext_props)( \
119 123 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
120 124 u8 *layer_name, \ u8 *layer_name, \
121 125 u32 *props_n, \ u32 *props_n, \
122 126 struct vk_ext_props_t *props); \ struct vk_ext_props_t *props); \
123 static void (*dl_vk_get_phydev_props)( \
127 STATIC void (*npv_dl_vk_get_phydev_props)( \
124 128 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
125 129 struct vk_phydev_props_t *props); \ struct vk_phydev_props_t *props); \
126 static s32 (*dl_vk_create_dev)( \
130 STATIC s32 (*npv_dl_vk_create_dev)( \
127 131 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
128 132 struct vk_dev_create_info_t *create_info, \ struct vk_dev_create_info_t *create_info, \
129 133 void *allocator, \ void *allocator, \
130 134 struct vk_dev_t **dev); \ struct vk_dev_t **dev); \
131 static void (*dl_vk_get_phydev_q_fam_props)( \
135 STATIC void (*npv_dl_vk_get_phydev_q_fam_props)( \
132 136 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
133 137 u32 *q_fam_props_n, \ u32 *q_fam_props_n, \
134 138 struct vk_q_fam_props_t *props); \ struct vk_q_fam_props_t *props); \
135 static s32 (*dl_vk_create_xcb_surf)( \
139 STATIC s32 (*npv_dl_vk_create_xcb_surf)( \
136 140 struct vk_instance_t *instance, \ struct vk_instance_t *instance, \
137 141 struct vk_xcb_surf_create_info_t *info, \ struct vk_xcb_surf_create_info_t *info, \
138 142 void *allocator, \ void *allocator, \
139 143 struct vk_surf_t **surf); \ struct vk_surf_t **surf); \
140 static void (*dl_vk_destroy_surf)(\
141 struct vk_instance_t *instance,\
142 struct vk_surf_t *surf,\
143 void *allocator); \
144 static s32 (*dl_vk_get_phydev_surf_support)( \
144 STATIC void (*npv_dl_vk_destroy_surf)(\
145 struct vk_instance_t *instance,\
146 struct vk_surf_t *surf,\
147 void *allocator); \
148 STATIC s32 (*npv_dl_vk_get_phydev_surf_support)( \
145 149 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
146 150 u32 q_fam, \ u32 q_fam, \
147 151 struct vk_surf_t *surf, \ struct vk_surf_t *surf, \
148 152 u32 *supported); \ u32 *supported); \
149 static s32 (*dl_vk_get_phydev_surf_texel_mem_blk_confs)( \
153 STATIC s32 (*npv_dl_vk_get_phydev_surf_texel_mem_blk_confs)( \
150 154 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
151 155 struct vk_phydev_surf_info_t *info, \ struct vk_phydev_surf_info_t *info, \
152 156 u32 *confs_n, \ u32 *confs_n, \
153 157 struct vk_surf_texel_mem_blk_conf_t *confs); \ struct vk_surf_texel_mem_blk_conf_t *confs); \
154 static void (*dl_vk_get_phydev_mem_props)( \
158 STATIC void (*npv_dl_vk_get_phydev_mem_props)( \
155 159 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
156 160 struct vk_phydev_mem_props_t *props); \ struct vk_phydev_mem_props_t *props); \
157 static s32 (*dl_vk_get_phydev_surf_caps)( \
161 STATIC s32 (*npv_dl_vk_get_phydev_surf_caps)( \
158 162 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
159 163 struct vk_phydev_surf_info_t *info, \ struct vk_phydev_surf_info_t *info, \
160 164 struct vk_surf_caps_t *caps); \ struct vk_surf_caps_t *caps); \
161 static s32 (*dl_vk_get_phydev_surf_present_modes)( \
165 STATIC s32 (*npv_dl_vk_get_phydev_surf_present_modes)( \
162 166 struct vk_phydev_t *phydev, \ struct vk_phydev_t *phydev, \
163 167 struct vk_surf_t *surf, \ struct vk_surf_t *surf, \
164 168 u32 *modes_n, \ u32 *modes_n, \
165 169 u32 *modes); u32 *modes);
166 170 /******************************************************************************/ /******************************************************************************/
167 #define vk_get_instance_proc_addr dl_vk_get_instance_proc_addr
171 #define vk_get_instance_proc_addr npv_dl_vk_get_instance_proc_addr
168 172
169 #define vk_get_dev_proc_addr dl_vk_get_dev_proc_addr
173 #define vk_get_dev_proc_addr npv_dl_vk_get_dev_proc_addr
170 174
171 175 #define vk_enumerate_instance_version \ #define vk_enumerate_instance_version \
172 r = dl_vk_enumerate_instance_version
176 r = npv_dl_vk_enumerate_instance_version
173 177
174 178 #define vk_enumerate_instance_layer_props \ #define vk_enumerate_instance_layer_props \
175 r = dl_vk_enumerate_instance_layer_props
179 r = npv_dl_vk_enumerate_instance_layer_props
176 180
177 181 #define vk_enumerate_instance_ext_props(...) \ #define vk_enumerate_instance_ext_props(...) \
178 r = dl_vk_enumerate_instance_ext_props(0,##__VA_ARGS__)
182 r = npv_dl_vk_enumerate_instance_ext_props(0,##__VA_ARGS__)
179 183
180 184 #define vk_create_instance(info) \ #define vk_create_instance(info) \
181 r = dl_vk_create_instance(info, 0, &npv_vk_instance_l)
185 r = npv_dl_vk_create_instance(info, 0, &npv_vk_instance_l)
182 186
183 187 #define vk_enumerate_phydevs(...) \ #define vk_enumerate_phydevs(...) \
184 r = dl_vk_enumerate_phydevs(npv_vk_instance_l,##__VA_ARGS__)
188 r = npv_dl_vk_enumerate_phydevs(npv_vk_instance_l,##__VA_ARGS__)
185 189
186 190 #define vk_enumerate_dev_ext_props(phydev, props_n, props) \ #define vk_enumerate_dev_ext_props(phydev, props_n, props) \
187 r = dl_vk_enumerate_dev_ext_props(phydev, 0, props_n, props)
191 r = npv_dl_vk_enumerate_dev_ext_props(phydev, 0, props_n, props)
188 192
189 #define vk_get_phydev_props dl_vk_get_phydev_props
193 #define vk_get_phydev_props npv_dl_vk_get_phydev_props
190 194
191 195 #define vk_create_dev(info) \ #define vk_create_dev(info) \
192 r = dl_vk_create_dev(npv_vk_surf_p.dev.phydev.vk, info, 0, &npv_vk_surf_p.dev.vk)
196 r = npv_dl_vk_create_dev(npv_vk_surf_p.dev.phydev.vk, info, 0, &npv_vk_surf_p.dev.vk)
193 197
194 #define vk_get_phydev_q_fam_props dl_vk_get_phydev_q_fam_props
198 #define vk_get_phydev_q_fam_props npv_dl_vk_get_phydev_q_fam_props
195 199
196 200 #define vk_create_xcb_surf(info) \ #define vk_create_xcb_surf(info) \
197 r = dl_vk_create_xcb_surf(npv_vk_instance_l, info, 0, &npv_vk_surf_p.vk)
201 r = npv_dl_vk_create_xcb_surf(npv_vk_instance_l, info, 0, &npv_vk_surf_p.vk)
198 202
199 203 #define vk_get_phydev_surf_support(phydev, q_fam, supported) \ #define vk_get_phydev_surf_support(phydev, q_fam, supported) \
200 r = dl_vk_get_phydev_surf_support(phydev, q_fam, npv_vk_surf_p.vk, supported)
204 r = npv_dl_vk_get_phydev_surf_support(phydev, q_fam, npv_vk_surf_p.vk, supported)
201 205
202 206 #define vk_get_phydev_surf_texel_mem_blk_confs(info, ...) \ #define vk_get_phydev_surf_texel_mem_blk_confs(info, ...) \
203 r = dl_vk_get_phydev_surf_texel_mem_blk_confs(npv_vk_surf_p.dev.phydev.vk, info, ##__VA_ARGS__)
207 r = npv_dl_vk_get_phydev_surf_texel_mem_blk_confs(npv_vk_surf_p.dev.phydev.vk, info, ##__VA_ARGS__)
204 208
205 #define vk_get_phydev_mem_props dl_vk_get_phydev_mem_props
209 #define vk_get_phydev_mem_props npv_dl_vk_get_phydev_mem_props
206 210
207 211 #define vk_get_phydev_surf_caps(info, caps) \ #define vk_get_phydev_surf_caps(info, caps) \
208 r = dl_vk_get_phydev_surf_caps(npv_vk_surf_p.dev.phydev.vk, info, caps)
212 r = npv_dl_vk_get_phydev_surf_caps(npv_vk_surf_p.dev.phydev.vk, info, caps)
209 213
210 214 #define vk_get_phydev_surf_present_modes() \ #define vk_get_phydev_surf_present_modes() \
211 r = dl_vk_get_phydev_surf_present_modes(npv_vk_surf_p.dev.phydev.vk, npv_vk_surf_p.vk, &npv_vk_tmp_present_modes_n_l, npv_vk_tmp_present_modes_l)
215 r = npv_dl_vk_get_phydev_surf_present_modes(npv_vk_surf_p.dev.phydev.vk, npv_vk_surf_p.vk, &npv_vk_tmp_present_modes_n_l, npv_vk_tmp_present_modes_l)
212 216 #endif #endif
File npv/vk/local/code.frag.c changed (mode: 100644) (index 3280653..28b0c34)
1 1 #define INSTANCE_STATIC_SYM(x,y) \ #define INSTANCE_STATIC_SYM(x,y) \
2 dl_##y = vk_get_instance_proc_addr(0, #x); \
3 if (dl_##y == 0) \
2 npv_dl_##y = vk_get_instance_proc_addr(0, #x); \
3 if (npv_dl_##y == 0) \
4 4 FATALVK("unable to find vulkan " #x "\n"); FATALVK("unable to find vulkan " #x "\n");
5 static void instance_static_syms(void)
5 STATIC void instance_static_syms(void)
6 6 { {
7 7 INSTANCE_STATIC_SYM(vkEnumerateInstanceVersion, INSTANCE_STATIC_SYM(vkEnumerateInstanceVersion,
8 8 vk_enumerate_instance_version); vk_enumerate_instance_version);
 
... ... static void instance_static_syms(void)
15 15 #undef INSTANCE_STATIC_SYM #undef INSTANCE_STATIC_SYM
16 16 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
17 17 #define INSTANCE_SYM(x,y) \ #define INSTANCE_SYM(x,y) \
18 dl_##y = vk_get_instance_proc_addr(instance_l, #x); \
19 if (dl_##y == 0) \
18 npv_dl_##y = vk_get_instance_proc_addr(instance_l, #x); \
19 if (npv_dl_##y == 0) \
20 20 FATALVK("unable to find vulkan " #x "\n"); FATALVK("unable to find vulkan " #x "\n");
21 static void instance_syms(void)
21 STATIC void instance_syms(void)
22 22 { {
23 23 INSTANCE_SYM(vkEnumeratePhysicalDevices, vk_enumerate_phydevs); INSTANCE_SYM(vkEnumeratePhysicalDevices, vk_enumerate_phydevs);
24 24 INSTANCE_SYM(vkEnumerateDeviceExtensionProperties, INSTANCE_SYM(vkEnumerateDeviceExtensionProperties,
 
... ... static void instance_syms(void)
47 47 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 48 if (surf_p.dev.dl_##y == 0) \ if (surf_p.dev.dl_##y == 0) \
49 49 FATALVK("unable to find vulkan device " #x "\n"); FATALVK("unable to find vulkan device " #x "\n");
50 static void dev_syms(void)
50 STATIC void dev_syms(void)
51 51 { {
52 52 DEV_SYM(vkGetDeviceQueue, vk_get_dev_q); DEV_SYM(vkGetDeviceQueue, vk_get_dev_q);
53 53 DEV_SYM(vkCreateCommandPool, vk_create_cp); DEV_SYM(vkCreateCommandPool, vk_create_cp);
 
... ... static void dev_syms(void)
79 79 #undef DEVICE_SYM #undef DEVICE_SYM
80 80 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
81 81 #define DLSYM(x, y) \ #define DLSYM(x, y) \
82 dl_##y = dlsym(loader_l, #x); \
83 if (dl_##y == 0) \
82 npv_dl_##y = dlsym(loader_l, #x); \
83 if (npv_dl_##y == 0) \
84 84 FATALVK("%s:unable to find " #x "\n", dlerror()); FATALVK("%s:unable to find " #x "\n", dlerror());
85 static void loader_syms(void)
85 STATIC void loader_syms(void)
86 86 { {
87 87 DLSYM(vkGetInstanceProcAddr, vk_get_instance_proc_addr); DLSYM(vkGetInstanceProcAddr, vk_get_instance_proc_addr);
88 88 DLSYM(vkGetDeviceProcAddr, vk_get_dev_proc_addr); DLSYM(vkGetDeviceProcAddr, vk_get_dev_proc_addr);
89 89 } }
90 90 #undef DLSYM #undef DLSYM
91 91 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
92 /*NSPC*/
93 static void load_vk_loader(void)
92 STATIC void load_vk_loader(void)
94 93 { {
95 94 /* no '/' in the shared dynamic lib path name, then standard lookup */ /* no '/' in the shared dynamic lib path name, then standard lookup */
96 95 loader_l = dlopen("libvulkan.so.1", RTLD_LAZY); loader_l = dlopen("libvulkan.so.1", RTLD_LAZY);
97 96 if (loader_l == 0) if (loader_l == 0)
98 97 FATALVK("%s:unable to load the vulkan loader dynamic shared library\n", dlerror()); FATALVK("%s:unable to load the vulkan loader dynamic shared library\n", dlerror());
99 98 } }
100 /*NSPC*/
101 static void check_vk_version(void)
99 STATIC void check_vk_version(void)
102 100 { {
103 101 u32 api_version; u32 api_version;
104 102 s32 r; s32 r;
 
... ... static void check_vk_version(void)
112 110 FATALVK("instance version too old\n"); FATALVK("instance version too old\n");
113 111 } }
114 112 #define EXTS_N_MAX 256 #define EXTS_N_MAX 256
115 /*NSPC*/
116 113 /* in theory, this could change on the fly */ /* in theory, this could change on the fly */
117 static void instance_exts_dump(void)
114 STATIC void instance_exts_dump(void)
118 115 { {
119 116 struct vk_ext_props_t exts[EXTS_N_MAX]; struct vk_ext_props_t exts[EXTS_N_MAX];
120 117 u32 n; u32 n;
 
... ... static void instance_exts_dump(void)
142 139 } }
143 140 #undef EXTS_N_MAX #undef EXTS_N_MAX
144 141 #define LAYERS_N_MAX 32 #define LAYERS_N_MAX 32
145 /*NSPC*/
146 142 /* in theory, this could change on the fly */ /* in theory, this could change on the fly */
147 static void instance_layers_dump(void)
143 STATIC void instance_layers_dump(void)
148 144 { {
149 145 struct vk_layer_props_t layers[LAYERS_N_MAX]; struct vk_layer_props_t layers[LAYERS_N_MAX];
150 146 u32 n; u32 n;
 
... ... static void instance_layers_dump(void)
171 167 } }
172 168 } }
173 169 #undef LAYERS_N_MAX #undef LAYERS_N_MAX
174 /*NSPC*/
175 static void instance_create(void)
170 STATIC void instance_create(void)
176 171 { {
177 172 s32 r; s32 r;
178 173 struct vk_instance_create_info_t info; struct vk_instance_create_info_t info;
 
... ... static void instance_create(void)
207 202 IF_FATALVK("%d:unable to create an instance\n", r); IF_FATALVK("%d:unable to create an instance\n", r);
208 203 POUTVK("instance handle %p\n", instance_l); POUTVK("instance handle %p\n", instance_l);
209 204 } }
210 /*NSPC*/
211 static void tmp_phydevs_get(void)
205 STATIC void tmp_phydevs_get(void)
212 206 { {
213 207 struct vk_phydev_t *phydevs[tmp_phydevs_n_max]; struct vk_phydev_t *phydevs[tmp_phydevs_n_max];
214 208 u32 n; u32 n;
 
... ... static void tmp_phydevs_get(void)
236 230 }; };
237 231 } }
238 232 #define EXTS_N_MAX 512 #define EXTS_N_MAX 512
239 /*NSPC*/
240 static void phydev_exts_dump(void *phydev)
233 STATIC void phydev_exts_dump(void *phydev)
241 234 { {
242 235 struct vk_ext_props_t exts[EXTS_N_MAX]; struct vk_ext_props_t exts[EXTS_N_MAX];
243 236 u32 n; u32 n;
 
... ... static void phydev_exts_dump(void *phydev)
264 257 } }
265 258 } }
266 259 #undef EXTS_N_MAX #undef EXTS_N_MAX
267 /*NSPC*/
268 static void tmp_phydevs_exts_dump(void)
260 STATIC void tmp_phydevs_exts_dump(void)
269 261 { {
270 262 u8 i; u8 i;
271 263
 
... ... static void tmp_phydevs_exts_dump(void)
277 269 ++i; ++i;
278 270 } }
279 271 } }
280 /*NSPC*/
281 static u8 *dev_type_str(u32 type)
272 STATIC u8 *dev_type_str(u32 type)
282 273 { {
283 274 switch (type) { switch (type) {
284 275 case vk_phydev_type_other: case vk_phydev_type_other:
 
... ... static u8 *dev_type_str(u32 type)
295 286 return "UNKNOWN"; return "UNKNOWN";
296 287 } }
297 288 } }
298 /*NSPC*/
299 static u8 *uuid_str(u8 *uuid)
289 STATIC u8 *uuid_str(u8 *uuid)
300 290 { {
301 static u8 uuid_str[VK_UUID_SZ * 2 + 1];
291 static u8 uuid_str_buf[VK_UUID_SZ * 2 + 1];
302 292 u8 i; u8 i;
303 293
304 memset(uuid_str, 0, sizeof(uuid_str));
294 memset(uuid_str_buf, 0, sizeof(uuid_str_buf));
305 295 i = 0; i = 0;
306 296 loop { loop {
307 297 if (i == VK_UUID_SZ) if (i == VK_UUID_SZ)
308 298 break; break;
309 299 /* XXX: always write a terminating 0, truncated or not */ /* XXX: always write a terminating 0, truncated or not */
310 snprintf(uuid_str + i * 2, 3, "%02x", uuid[i]);
300 snprintf(uuid_str_buf + i * 2, 3, "%02x", uuid[i]);
311 301 ++i; ++i;
312 302 } }
313 return uuid_str;
303 return uuid_str_buf;
314 304 } }
315 /*NSPC*/
316 static void tmp_phydevs_props_dump(void)
305 STATIC void tmp_phydevs_props_dump(void)
317 306 { {
318 307 u32 i; u32 i;
319 308
 
... ... static void tmp_phydevs_props_dump(void)
343 332 ++i; ++i;
344 333 } }
345 334 } }
346 /*NSPC*/
347 static void tmp_phydev_mem_props_get(struct tmp_phydev_t *p)
335 STATIC void tmp_phydev_mem_props_get(struct tmp_phydev_t *p)
348 336 { {
349 337 memset(&p->mem_props, 0, sizeof(p->mem_props)); memset(&p->mem_props, 0, sizeof(p->mem_props));
350 338 p->mem_props.type = vk_struct_type_phydev_mem_props; p->mem_props.type = vk_struct_type_phydev_mem_props;
351 339 vk_get_phydev_mem_props(p->vk, &p->mem_props); vk_get_phydev_mem_props(p->vk, &p->mem_props);
352 340 } }
353 /*NSPC*/
354 static void tmp_phydevs_mem_props_get(void)
341 STATIC void tmp_phydevs_mem_props_get(void)
355 342 { {
356 343 u8 i; u8 i;
357 344
 
... ... static void tmp_phydevs_mem_props_get(void)
363 350 ++i; ++i;
364 351 } }
365 352 } }
366 /*NSPC*/
367 static void phydev_mem_type_dump(void *phydev, u8 i,
353 STATIC void phydev_mem_type_dump(void *phydev, u8 i,
368 354 struct vk_mem_type_t *type) struct vk_mem_type_t *type)
369 355 { {
370 356 POUTVK("physical device:%p:memory type:%u:heap:%u\n", phydev, i, type->heap); POUTVK("physical device:%p:memory type:%u:heap:%u\n", phydev, i, type->heap);
 
... ... static void phydev_mem_type_dump(void *phydev, u8 i,
376 362 if ((type->prop_flags & vk_mem_prop_host_cached_bit) != 0) if ((type->prop_flags & vk_mem_prop_host_cached_bit) != 0)
377 363 POUTVK("physical device:%p:memory type:%u:host cached\n", phydev, i); POUTVK("physical device:%p:memory type:%u:host cached\n", phydev, i);
378 364 } }
379 /*NSPC*/
380 static void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p)
365 STATIC void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p)
381 366 { {
382 367 u8 i; u8 i;
383 368
 
... ... static void tmp_phydev_mem_types_dump(struct tmp_phydev_t *p)
391 376 ++i; ++i;
392 377 } }
393 378 } }
394 /*NSPC*/
395 static void phydev_mem_heap_dump(void *phydev, u8 i,
379 STATIC void phydev_mem_heap_dump(void *phydev, u8 i,
396 380 struct vk_mem_heap_t *heap) struct vk_mem_heap_t *heap)
397 381 { {
398 382 POUTVK("physical device:%p:memory heap:%u:size:%u bytes\n", phydev, i, heap->sz); POUTVK("physical device:%p:memory heap:%u:size:%u bytes\n", phydev, i, heap->sz);
 
... ... static void phydev_mem_heap_dump(void *phydev, u8 i,
402 386 if ((heap->flags & vk_mem_heap_multi_instance_bit) != 0) if ((heap->flags & vk_mem_heap_multi_instance_bit) != 0)
403 387 POUTVK("physical device:%p:memory type:%u:multi instance\n", phydev, i); POUTVK("physical device:%p:memory type:%u:multi instance\n", phydev, i);
404 388 } }
405 /*NSPC*/
406 static void tmp_phydev_mem_heaps_dump(struct tmp_phydev_t *p)
389 STATIC void tmp_phydev_mem_heaps_dump(struct tmp_phydev_t *p)
407 390 { {
408 391 u8 i; u8 i;
409 392
 
... ... static void tmp_phydev_mem_heaps_dump(struct tmp_phydev_t *p)
418 401 } }
419 402
420 403 } }
421 /*NSPC*/
422 static void tmp_phydev_mem_props_dump(struct tmp_phydev_t *p)
404 STATIC void tmp_phydev_mem_props_dump(struct tmp_phydev_t *p)
423 405 { {
424 406 tmp_phydev_mem_types_dump(p); tmp_phydev_mem_types_dump(p);
425 407 tmp_phydev_mem_heaps_dump(p); tmp_phydev_mem_heaps_dump(p);
426 408 } }
427 /*NSPC*/
428 static void tmp_phydevs_mem_props_dump(void)
409 STATIC void tmp_phydevs_mem_props_dump(void)
429 410 { {
430 411 u8 i; u8 i;
431 412
 
... ... static void tmp_phydevs_mem_props_dump(void)
437 418 ++i; ++i;
438 419 } }
439 420 } }
440 /*NSPC*/
441 static void tmp_phydev_q_fams_get(struct tmp_phydev_t *p)
421 STATIC void tmp_phydev_q_fams_get(struct tmp_phydev_t *p)
442 422 { {
443 423 u8 i; u8 i;
444 424 u32 n; u32 n;
 
... ... static void tmp_phydev_q_fams_get(struct tmp_phydev_t *p)
459 439 p->q_fams_n = n; p->q_fams_n = n;
460 440 POUTVK("physical device:%p:have %u queue families\n", p->vk, p->q_fams_n); POUTVK("physical device:%p:have %u queue families\n", p->vk, p->q_fams_n);
461 441 } }
462 /*NSPC*/
463 static void tmp_phydevs_q_fams_get(void)
442 STATIC void tmp_phydevs_q_fams_get(void)
464 443 { {
465 444 u8 i; u8 i;
466 445
 
... ... static void tmp_phydevs_q_fams_get(void)
472 451 ++i; ++i;
473 452 } }
474 453 } }
475 /*NSPC*/
476 static void tmp_phydev_q_fams_dump(struct tmp_phydev_t *p)
454 STATIC void tmp_phydev_q_fams_dump(struct tmp_phydev_t *p)
477 455 { {
478 456 u8 i; u8 i;
479 457
 
... ... static void tmp_phydev_q_fams_dump(struct tmp_phydev_t *p)
497 475 ++i; ++i;
498 476 } }
499 477 } }
500 /*NSPC*/
501 static void tmp_phydevs_q_fams_dump(void)
478 STATIC void tmp_phydevs_q_fams_dump(void)
502 479 { {
503 480 u8 i; u8 i;
504 481
 
... ... static void tmp_phydevs_q_fams_dump(void)
517 494 * really the case on AMD hardware, but if vk abstraction insists on this, it * really the case on AMD hardware, but if vk abstraction insists on this, it
518 495 * probably means it is important on some hardware of other vendors. * probably means it is important on some hardware of other vendors.
519 496 */ */
520 /*NSPC*/
521 static void tmp_phydevs_q_fams_surf_support_get(void)
497 STATIC void tmp_phydevs_q_fams_surf_support_get(void)
522 498 { {
523 499 u8 i; u8 i;
524 500
 
... ... static void tmp_phydevs_q_fams_surf_support_get(void)
552 528 ++i; ++i;
553 529 } }
554 530 } }
555 /*NSPC*/
556 static void tmp_selected_phydev_cherry_pick(u8 i)
531 STATIC void tmp_selected_phydev_cherry_pick(u8 i)
557 532 { {
558 533 struct tmp_phydev_t *p; struct tmp_phydev_t *p;
559 534
 
... ... static void tmp_selected_phydev_cherry_pick(u8 i)
570 545 * select basically the first q from the first phydev fitting what we are * select basically the first q from the first phydev fitting what we are
571 546 * looking for. * looking for.
572 547 */ */
573 /*NSPC*/
574 static void tmp_phydev_and_q_fam_select(void)
548 STATIC void tmp_phydev_and_q_fam_select(void)
575 549 { {
576 550 u8 i; u8 i;
577 551
 
... ... static void tmp_phydev_and_q_fam_select(void)
606 580 ++i; ++i;
607 581 } }
608 582 } }
609 /*NSPC*/
610 static void texel_mem_blk_confs_dump(u32 confs_n,
583 STATIC void texel_mem_blk_confs_dump(u32 confs_n,
611 584 struct vk_surf_texel_mem_blk_conf_t *confs) struct vk_surf_texel_mem_blk_conf_t *confs)
612 585 { {
613 586 u32 i; u32 i;
 
... ... static void texel_mem_blk_confs_dump(u32 confs_n,
625 598 * pe surf. Here we choose the cfg of textel blk * pe surf. Here we choose the cfg of textel blk
626 599 */ */
627 600 #define CONFS_N_MAX 1024 #define CONFS_N_MAX 1024
628 /*NSPC*/
629 static void phydev_surf_texel_mem_blk_conf_select(void)
601 STATIC void phydev_surf_texel_mem_blk_conf_select(void)
630 602 { {
631 603 struct vk_phydev_surf_info_t info; struct vk_phydev_surf_info_t info;
632 604 struct vk_surf_texel_mem_blk_conf_t confs[CONFS_N_MAX]; struct vk_surf_texel_mem_blk_conf_t confs[CONFS_N_MAX];
 
... ... static void phydev_surf_texel_mem_blk_conf_select(void)
668 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); 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);
669 641 } }
670 642 #undef CONFS_N_MAX #undef CONFS_N_MAX
671 /*NSPC*/
672 static void phydev_surf_caps_get(void)
643 STATIC void phydev_surf_caps_get(void)
673 644 { {
674 645 s32 r; s32 r;
675 646 struct vk_phydev_surf_info_t info; struct vk_phydev_surf_info_t info;
 
... ... static void phydev_surf_caps_get(void)
686 657 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)
687 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); 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);
688 659 } }
689 /*NSPC*/
690 static void phydev_surf_caps_dump(void)
660 STATIC void phydev_surf_caps_dump(void)
691 661 { {
692 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); 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);
693 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); 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);
 
... ... static void phydev_surf_caps_dump(void)
700 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); 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);
701 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); 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);
702 672 } }
703 /*NSPC*/
704 static void tmp_phydev_surf_present_modes_get(void)
673 STATIC void tmp_phydev_surf_present_modes_get(void)
705 674 { {
706 675 s32 r; s32 r;
707 676
 
... ... static void tmp_phydev_surf_present_modes_get(void)
709 678 vk_get_phydev_surf_present_modes(); vk_get_phydev_surf_present_modes();
710 679 IF_FATALVK("%d:physical device:%p:surface:%p:unable to get the physical device present mode for our surface\n", r, surf_p.dev.phydev.vk, surf_p.vk); IF_FATALVK("%d:physical device:%p:surface:%p:unable to get the physical device present mode for our surface\n", r, surf_p.dev.phydev.vk, surf_p.vk);
711 680 } }
712 /*NSPC*/
713 static u8 *present_mode_to_str(u32 mode)
681 STATIC u8 *present_mode_to_str(u32 mode)
714 682 { {
715 683 switch (mode) { switch (mode) {
716 684 case vk_present_mode_immediate: case vk_present_mode_immediate:
 
... ... static u8 *present_mode_to_str(u32 mode)
725 693 return "unknown"; return "unknown";
726 694 } }
727 695 } }
728 /*NSPC*/
729 static void tmp_phydev_surf_present_modes_dump(void)
696 STATIC void tmp_phydev_surf_present_modes_dump(void)
730 697 { {
731 698 u8 i; u8 i;
732 699
 
... ... static void tmp_phydev_surf_present_modes_dump(void)
739 706 ++i; ++i;
740 707 } }
741 708 } }
742 /*NSPC*/
743 static void phydev_init(void)
709 STATIC void phydev_init(void)
744 710 { {
745 711 tmp_phydevs_get(); tmp_phydevs_get();
746 712 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
 
... ... static void phydev_init(void)
767 733 tmp_phydev_surf_present_modes_dump(); tmp_phydev_surf_present_modes_dump();
768 734 } }
769 735 /* the phydev q fam selected */ /* the phydev q fam selected */
770 /*NSPC*/
771 static void dev_create(void)
736 STATIC void dev_create(void)
772 737 { {
773 738 struct vk_dev_create_info_t info; struct vk_dev_create_info_t info;
774 739 struct vk_dev_q_create_info_t q_info; struct vk_dev_q_create_info_t q_info;
775 740 float q_prio; float q_prio;
776 static u8 *exts[] = {
741 STATIC u8 *exts[] = {
777 742 /* 1.1 promoted */ /* 1.1 promoted */
778 743 "VK_KHR_bind_memory2", "VK_KHR_bind_memory2",
779 744 /* 1.1 promoted */ /* 1.1 promoted */
 
... ... static void dev_create(void)
800 765 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);
801 766 POUTVK("physical device:%p:vulkan device created with one proper queue:%p\n", surf_p.dev.phydev.vk, surf_p.dev.vk); POUTVK("physical device:%p:vulkan device created with one proper queue:%p\n", surf_p.dev.phydev.vk, surf_p.dev.vk);
802 767 } }
803 /*NSPC*/
804 static void q_get(void)
768 STATIC void q_get(void)
805 769 { {
806 770 POUTVK("device:%p:getting queue:family=%u queue=0\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam); POUTVK("device:%p:getting queue:family=%u queue=0\n", surf_p.dev.vk, surf_p.dev.phydev.q_fam);
807 771 vk_get_dev_q(); vk_get_dev_q();
808 772 POUTVK("device:%p:got queue:%p\n", surf_p.dev.vk, surf_p.dev.q); POUTVK("device:%p:got queue:%p\n", surf_p.dev.vk, surf_p.dev.q);
809 773 } }
810 /*NSPC*/
811 static void cp_create(void)
774 STATIC void cp_create(void)
812 775 { {
813 776 s32 r; s32 r;
814 777 struct vk_cp_create_info_t info; struct vk_cp_create_info_t info;
 
... ... static void cp_create(void)
821 784 IF_FATALVK("%d:unable create the commmand pool\n", r); IF_FATALVK("%d:unable create the commmand pool\n", r);
822 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); 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);
823 786 } }
824 /*NSPC*/
825 static void dev_init(void)
787 STATIC void dev_init(void)
826 788 { {
827 789 phydev_init(); phydev_init();
828 790 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
 
... ... static void dev_init(void)
832 794 cp_create(); cp_create();
833 795 } }
834 796 /* XXX: the surf is an obj at the instance lvl, NOT THE [PHYSICAL] * DEV LVL */ /* XXX: the surf is an obj at the instance lvl, NOT THE [PHYSICAL] * DEV LVL */
835 /*NSPC*/
836 static void surf_create(xcb_connection_t *c, u32 win_id)
797 STATIC void surf_create(xcb_connection_t *c, u32 win_id)
837 798 { {
838 799 struct vk_xcb_surf_create_info_t vk_xcb_info; struct vk_xcb_surf_create_info_t vk_xcb_info;
839 800 s32 r; s32 r;
 
... ... static void surf_create(xcb_connection_t *c, u32 win_id)
847 808 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);
848 809 POUTVK("xcb:%p:window id:%#x:created vk_surface=%p\n", c, win_id, surf_p.vk); POUTVK("xcb:%p:window id:%#x:created vk_surface=%p\n", c, win_id, surf_p.vk);
849 810 } }
850 /*NSPC*/
851 static void swpchn_init_once(void)
811 STATIC void swpchn_init_once(void)
852 812 { {
853 813 memset(&surf_p.dev.swpchn, 0, sizeof(surf_p.dev.swpchn)); memset(&surf_p.dev.swpchn, 0, sizeof(surf_p.dev.swpchn));
854 814 } }
855 /*NSPC*/
856 static void swpchn_reinit(void)
815 STATIC void swpchn_reinit(void)
857 816 { {
858 817 struct vk_swpchn_t *old_swpchn; struct vk_swpchn_t *old_swpchn;
859 818 struct vk_swpchn_create_info_t info; struct vk_swpchn_create_info_t info;
 
... ... static void swpchn_reinit(void)
891 850 if (old_swpchn != 0) if (old_swpchn != 0)
892 851 vk_destroy_swpchn(old_swpchn); vk_destroy_swpchn(old_swpchn);
893 852 } }
894 /*NSPC*/
895 static void swpchn_imgs_get(void)
853 STATIC void swpchn_imgs_get(void)
896 854 { {
897 855 s32 r; s32 r;
898 856 u8 target_imgs_n; u8 target_imgs_n;
 
... ... static void swpchn_imgs_get(void)
904 862 vk_get_swpchn_imgs(); vk_get_swpchn_imgs();
905 863 IF_FATALVK("%d:device:%p:surface:%p:swapchain:%p:unable to get the swapchain images\n", r, surf_p.dev.vk, surf_p.vk, surf_p.dev.swpchn.vk); IF_FATALVK("%d:device:%p:surface:%p:swapchain:%p:unable to get the swapchain images\n", r, surf_p.dev.vk, surf_p.vk, surf_p.dev.swpchn.vk);
906 864 } }
907 /*NSPC*/
908 static void sems_create(void)
865 STATIC void sems_create(void)
909 866 { {
910 867 s32 r; s32 r;
911 868 struct vk_sem_create_info_t info; struct vk_sem_create_info_t info;
 
... ... static void sems_create(void)
923 880 ++sem; ++sem;
924 881 } }
925 882 } }
926 /*NSPC*/
927 static void swpchn_imgs_cbs_init_once(void)
883 STATIC void swpchn_imgs_cbs_init_once(void)
928 884 { {
929 885 s32 r; s32 r;
930 886 struct vk_cb_alloc_info_t alloc_info; struct vk_cb_alloc_info_t alloc_info;
File npv/vk/local/state.frag.c changed (mode: 100644) (index 032778d..6aa7566)
1 /*NSPC*/
2 1 constant_u32 { constant_u32 {
3 2 tmp_phydevs_n_max = 16, tmp_phydevs_n_max = 16,
4 3 tmp_phydev_q_fams_n_max = 16, tmp_phydev_q_fams_n_max = 16,
5 4 tmp_present_modes_n_max = 16 tmp_present_modes_n_max = 16
6 5 }; };
7 /*NSPC*/
8 6 struct tmp_phydev_t { struct tmp_phydev_t {
9 7 struct vk_phydev_t *vk; struct vk_phydev_t *vk;
10 8 u8 q_fams_n; u8 q_fams_n;
 
... ... struct tmp_phydev_t {
14 12 bool q_fams_surf_support[tmp_phydev_q_fams_n_max]; bool q_fams_surf_support[tmp_phydev_q_fams_n_max];
15 13 }; };
16 14 /*============================================================================*/ /*============================================================================*/
17 static void *loader_l;
18 static struct vk_instance_t *instance_l;
15 STATIC void *loader_l;
16 STATIC struct vk_instance_t *instance_l;
19 17 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
20 /*NSPC*/
21 static struct tmp_phydev_t tmp_phydevs_l[tmp_phydevs_n_max];
22 /*NSPC*/
23 static u32 tmp_phydevs_n_l;
24 /*NSPC*/
25 static u32 tmp_present_modes_l[tmp_present_modes_n_max];
26 /*NSPC*/
27 static u32 tmp_present_modes_n_l;
18 STATIC struct tmp_phydev_t tmp_phydevs_l[tmp_phydevs_n_max];
19 STATIC u32 tmp_phydevs_n_l;
20 STATIC u32 tmp_present_modes_l[tmp_present_modes_n_max];
21 STATIC u32 tmp_present_modes_n_l;
File npv/vk/main.c changed (mode: 100644) (index 8876cde..187ac30)
9 9 #include <dlfcn.h> #include <dlfcn.h>
10 10 #include <stdlib.h> #include <stdlib.h>
11 11 #include <string.h> #include <string.h>
12 #include <xcb.h>
12 #include <xcb/xcb.h>
13 13 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
14 14 #include "npv/nyanvk/consts.h" #include "npv/nyanvk/consts.h"
15 15 #include "npv/nyanvk/types.h" #include "npv/nyanvk/types.h"
File npv/vk/namespace/main.c changed (mode: 100644) (index 6277a1d..11a6a2a)
1 1 #ifndef CLEANUP #ifndef CLEANUP
2 #define dev_syms npv_vk_devs_syms
3 #define instance_l npv_vk_instance_l
4 #define instance_static_syms npv_vk_instance_static_syms
5 #define instance_syms npv_vk_instance_syms
6 #define loader_l npv_vk_loader_l
7 #define loader_syms npv_vk_loader_syms
8 #define load_vk_loader npv_vk_load_vk_loader
9 #define tmp_present_modes_l npv_vk_tmp_present_modes_l
10 #define tmp_present_modes_n_l npv_vk_tmp_present_modes_n_l
2 #define check_vk_version npv_vk_check_vk_version
3 #define cp_create npv_vk_cp_create
4 #define dev_create npv_vk_dev_create
5 #define dev_init npv_vk_dev_init
6 #define dev_syms npv_vk_devs_syms
7 #define dev_type_str npv_vk_dev_type_str
8 #define instance_create npv_vk_instance_create
9 #define instance_exts_dump npv_vk_instance_exts_dump
10 #define instance_l npv_vk_instance_l
11 #define instance_layers_dump npv_vk_instance_layers_dump
12 #define instance_static_syms npv_vk_instance_static_syms
13 #define instance_syms npv_vk_instance_syms
14 #define loader_l npv_vk_loader_l
15 #define loader_syms npv_vk_loader_syms
16 #define load_vk_loader npv_vk_load_vk_loader
17 #define phydev_exts_dump npv_vk_phydev_exts_dump
18 #define phydev_init npv_vk_phydev_init
19 #define phydev_mem_type_dump npv_vk_phydev_mem_type_dump
20 #define phydev_mem_heap_dump npv_vk_phydev_mem_heap_dump
21 #define phydev_surf_caps_dump npv_vk_phydev_surf_caps_dump
22 #define phydev_surf_caps_get npv_vk_phydev_surf_caps_get
23 #define phydev_surf_texel_mem_blk_conf_select npv_vk_phydev_surf_texel_mem_blk_conf_select
24 #define present_mode_to_str npv_vk_present_mode_to_str
25 #define q_get npv_vk_q_get
26 #define sems_create npv_vk_sems_create
27 #define surf_create npv_vk_surf_create
28 #define swpchn_imgs_cbs_init_once npv_vk_swpchn_imgs_cbs_init_once
29 #define swpchn_imgs_get npv_vk_swpchn_imgs_get
30 #define swpchn_init_once npv_vk_swpchn_init_once
31 #define swpchn_reinit npv_vk_swpchn_reinit
32 #define texel_mem_blk_confs_dump npv_vk_texel_mem_blk_confs_dump
33 #define tmp_phydev_and_q_fam_select npv_vk_tmp_phydev_and_q_fam_select
34 #define tmp_phydev_mem_heaps_dump npv_vk_tmp_phydev_mem_heaps_dump
35 #define tmp_phydev_mem_props_dump npv_vk_tmp_phydev_mem_props_dump
36 #define tmp_phydev_mem_props_get npv_vk_tmp_phydev_mem_props_get
37 #define tmp_phydev_mem_types_dump npv_vk_tmp_phydev_mem_types_dump
38 #define tmp_phydev_q_fams_dump npv_vk_tmp_phydev_q_fams_dump
39 #define tmp_phydev_q_fams_get npv_vk_tmp_phydev_q_fams_get
40 #define tmp_phydev_q_fams_n_max npv_vk_tmp_phydev_q_fams_n_max
41 #define tmp_phydev_surf_present_modes_dump npv_vk_tmp_phydev_surf_present_modes_dump
42 #define tmp_phydev_surf_present_modes_get npv_vk_tmp_phydev_surf_present_modes_get
43 #define tmp_phydev_t npv_vk_tmp_phydev_t
44 #define tmp_phydevs_exts_dump npv_vk_tmp_phydevs_exts_dump
45 #define tmp_phydevs_get npv_vk_tmp_phydevs_get
46 #define tmp_phydevs_l npv_vk_tmp_phydevs_l
47 #define tmp_phydevs_mem_props_dump npv_vk_tmp_phydevs_mem_props_dump
48 #define tmp_phydevs_mem_props_get npv_vk_tmp_phydevs_mem_props_get
49 #define tmp_phydevs_n_l npv_vk_tmp_phydevs_n_l
50 #define tmp_phydevs_n_max npv_vk_tmp_phydevs_n_max
51 #define tmp_phydevs_props_dump npv_vk_tmp_phydevs_props_dump
52 #define tmp_phydevs_q_fams_dump npv_vk_tmp_phydevs_q_fams_dump
53 #define tmp_phydevs_q_fams_get npv_vk_tmp_phydevs_q_fams_get
54 #define tmp_phydevs_q_fams_surf_support_get npv_vk_tmp_phydevs_q_fams_surf_support_get
55 #define tmp_present_modes_l npv_vk_tmp_present_modes_l
56 #define tmp_present_modes_n_l npv_vk_tmp_present_modes_n_l
57 #define tmp_present_modes_n_max npv_vk_tmp_present_modes_n_max
58 #define tmp_selected_phydev_cherry_pick npv_vk_tmp_selected_phydev_cherry_pick
59 #define uuid_str npv_vk_uuid_str
11 60 /******************************************************************************/ /******************************************************************************/
12 61 #else #else
62 #undef check_vk_version
63 #undef cp_create
64 #undef dev_create
65 #undef dev_init
13 66 #undef dev_syms #undef dev_syms
67 #undef dev_type_str
68 #undef instance_create
69 #undef instance_exts_dump
14 70 #undef instance_l #undef instance_l
71 #undef instance_layers_dump
15 72 #undef instance_static_syms #undef instance_static_syms
16 73 #undef instance_syms #undef instance_syms
17 74 #undef loader_l #undef loader_l
18 75 #undef loader_syms #undef loader_syms
19 76 #undef load_vk_loader #undef load_vk_loader
77 #undef phydev_exts_dump
78 #undef phydev_init
79 #undef phydev_mem_type_dump
80 #undef phydev_mem_heap_dump
81 #undef phydev_surf_caps_dump
82 #undef phydev_surf_caps_get
83 #undef phydev_surf_texel_mem_blk_conf_select
84 #undef present_mode_to_str
85 #undef q_get
86 #undef sems_create
87 #undef surf_create
88 #undef swpchn_imgs_cbs_init_once
89 #undef swpchn_imgs_get
90 #undef swpchn_init_once
91 #undef swpchn_reinit
92 #undef texel_mem_blk_confs_dump
93 #undef tmp_phydev_and_q_fam_select
94 #undef tmp_phydev_mem_heaps_dump
95 #undef tmp_phydev_mem_props_dump
96 #undef tmp_phydev_mem_props_get
97 #undef tmp_phydev_mem_types_dump
98 #undef tmp_phydev_q_fams_dump
99 #undef tmp_phydev_q_fams_get
100 #undef tmp_phydev_q_fams_n_max
101 #undef tmp_phydev_surf_present_modes_dump
102 #undef tmp_phydev_surf_present_modes_get
103 #undef tmp_phydev_t
104 #undef tmp_phydevs_exts_dump
105 #undef tmp_phydevs_get
106 #undef tmp_phydevs_l
107 #undef tmp_phydevs_mem_props_dump
108 #undef tmp_phydevs_mem_props_get
109 #undef tmp_phydevs_n_l
110 #undef tmp_phydevs_n_max
111 #undef tmp_phydevs_props_dump
112 #undef tmp_phydevs_q_fams_dump
113 #undef tmp_phydevs_q_fams_get
114 #undef tmp_phydevs_q_fams_surf_support_get
20 115 #undef tmp_present_modes_l #undef tmp_present_modes_l
21 116 #undef tmp_present_modes_n_l #undef tmp_present_modes_n_l
117 #undef tmp_present_modes_n_max
118 #undef tmp_selected_phydev_cherry_pick
119 #undef uuid_str
22 120 #endif #endif
File npv/vk/public.h changed (mode: 100644) (index 5dfe70c..8837c61)
6 6 */ */
7 7 #include <stdbool.h> #include <stdbool.h>
8 8 #include <stddef.h> #include <stddef.h>
9 #include <xcb.h>
9 #include <xcb/xcb.h>
10 10 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
11 11 #include "npv/nyanvk/types.h" #include "npv/nyanvk/types.h"
12 12 #include "npv/nyanvk/syms_dev.h" #include "npv/nyanvk/syms_dev.h"
 
16 16 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
17 17 #include "npv/vk/public/state.frag.h" #include "npv/vk/public/state.frag.h"
18 18 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
19 static void init_once(void);
20 static void surf_init_once(xcb_connection_t *c, u32 wind_id);
21 static void swpchn_update(void);
19 STATIC void init_once(void);
20 STATIC void surf_init_once(xcb_connection_t *c, u32 wind_id);
21 STATIC void swpchn_update(void);
22 22 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
23 23 #define CLEANUP #define CLEANUP
24 24 #include "npv/vk/namespace/public.h" #include "npv/vk/namespace/public.h"
File npv/vk/public/code.frag.c changed (mode: 100644) (index a4bad16..fa53616)
1 static void swpchn_update(void)
1 STATIC void swpchn_update(void)
2 2 { {
3 3 phydev_surf_caps_get(); phydev_surf_caps_get();
4 4 swpchn_reinit(); /* handle any previous swpchn */ swpchn_reinit(); /* handle any previous swpchn */
5 5 swpchn_imgs_get(); swpchn_imgs_get();
6 6 } }
7 static void surf_init_once(xcb_connection_t *c, u32 win_id)
7 STATIC void surf_init_once(xcb_connection_t *c, u32 win_id)
8 8 { {
9 9 surf_create(c, win_id); surf_create(c, win_id);
10 10 dev_init(); dev_init();
 
... ... static void surf_init_once(xcb_connection_t *c, u32 win_id)
14 14 swpchn_imgs_cbs_init_once(); swpchn_imgs_cbs_init_once();
15 15 swpchn_update(); swpchn_update();
16 16 } }
17 static void init_once(void)
17 STATIC void init_once(void)
18 18 { {
19 19 load_vk_loader(); load_vk_loader();
20 20 loader_syms(); loader_syms();
File npv/vk/public/state.frag.h changed (mode: 100644) (index 09fb7ab..8c40139)
... ... struct dev_t {
33 33 VK_DEV_SYMS_FULL /* TODO:should cherry pick the syms we use */ VK_DEV_SYMS_FULL /* TODO:should cherry pick the syms we use */
34 34 }; };
35 35 /*============================================================================*/ /*============================================================================*/
36 static struct {
36 STATIC struct {
37 37 struct vk_surf_t *vk; struct vk_surf_t *vk;
38 38 struct dev_t dev; struct dev_t dev;
39 39 } surf_p; } surf_p;
File npv/xcb/local/code.frag.c changed (mode: 100644) (index edc05ed..600e27e)
1 static void npv_xcb_libs_load(void)
1 STATIC void npv_xcb_libs_load(void)
2 2 { {
3 3 npv_xcb_lib_l = dlopen("libxcb.so.1", RTLD_LAZY); npv_xcb_lib_l = dlopen("libxcb.so.1", RTLD_LAZY);
4 4 if (npv_xcb_lib_l == 0) if (npv_xcb_lib_l == 0)
 
... ... static void npv_xcb_libs_load(void)
8 8 FATALX("%s:unable to load the xcb xfixes dynamic shared library\n", dlerror()); FATALX("%s:unable to load the xcb xfixes dynamic shared library\n", dlerror());
9 9 } }
10 10 #define XCB_DLSYM(x) \ #define XCB_DLSYM(x) \
11 dl_##x = dlsym(npv_xcb_lib_l, #x); \
12 if (dl_##x == 0) \
11 npv_dl_##x = dlsym(npv_xcb_lib_l, #x); \
12 if (npv_dl_##x == 0) \
13 13 FATALX("%s:unable to find " #x "\n", dlerror()); FATALX("%s:unable to find " #x "\n", dlerror());
14 14 #define XCB_XFIXES_DLSYM(x) \ #define XCB_XFIXES_DLSYM(x) \
15 dl_##x = dlsym(npv_xcb_xfixes_lib_l, #x); \
16 if (dl_##x == 0) \
15 npv_dl_##x = dlsym(npv_xcb_xfixes_lib_l, #x); \
16 if (npv_dl_##x == 0) \
17 17 FATALX("%s:unable to find " #x "\n", dlerror()); FATALX("%s:unable to find " #x "\n", dlerror());
18 static void npv_xcb_syms(void)
18 STATIC void npv_xcb_syms(void)
19 19 { {
20 20 XCB_DLSYM(xcb_connect); XCB_DLSYM(xcb_connect);
21 21 XCB_DLSYM(xcb_get_file_descriptor); XCB_DLSYM(xcb_get_file_descriptor);
 
... ... static void npv_xcb_syms(void)
47 47 XCB_XFIXES_DLSYM(xcb_xfixes_hide_cursor); XCB_XFIXES_DLSYM(xcb_xfixes_hide_cursor);
48 48 } }
49 49 #undef XCB_DLSYM #undef XCB_DLSYM
50 static void npv_xcb_win_create(void)
50 STATIC void npv_xcb_win_create(void)
51 51 { {
52 52 u32 value_mask; u32 value_mask;
53 53 u32 value_list[2]; u32 value_list[2];
54 54
55 npv_xcb_p.win_id = dl_xcb_generate_id(npv_xcb_p.c);
55 npv_xcb_p.win_id = npv_dl_xcb_generate_id(npv_xcb_p.c);
56 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); 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);
57 57
58 58 value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
 
... ... static void npv_xcb_win_create(void)
63 63 | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_BUTTON_MOTION
64 64 | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW
65 65 | XCB_EVENT_MASK_ENTER_WINDOW; | XCB_EVENT_MASK_ENTER_WINDOW;
66 dl_xcb_create_window(npv_xcb_p.c, XCB_COPY_FROM_PARENT,
66 npv_dl_xcb_create_window(npv_xcb_p.c, XCB_COPY_FROM_PARENT,
67 67 npv_xcb_p.win_id, npv_xcb_p.win_id,
68 68 npv_xcb_p.scr->root, 0, 0, npv_xcb_p.scr->root, 0, 0,
69 69 npv_xcb_p.width, npv_xcb_p.height, npv_xcb_p.width, npv_xcb_p.height,
 
... ... static void npv_xcb_win_create(void)
72 72 npv_xcb_p.scr->root_visual, npv_xcb_p.scr->root_visual,
73 73 value_mask, value_list); value_mask, value_list);
74 74 } }
75 static void npv_xcb_win_map(void)
75 STATIC void npv_xcb_win_map(void)
76 76 { {
77 77 xcb_void_cookie_t cookie; xcb_void_cookie_t cookie;
78 78 xcb_generic_error_t *e; xcb_generic_error_t *e;
79 79
80 cookie = dl_xcb_map_window_checked(npv_xcb_p.c, npv_xcb_p.win_id);
80 cookie = npv_dl_xcb_map_window_checked(npv_xcb_p.c, npv_xcb_p.win_id);
81 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); 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);
82 82
83 e = dl_xcb_request_check(npv_xcb_p.c, cookie);
83 e = npv_dl_xcb_request_check(npv_xcb_p.c, cookie);
84 84 if (e != 0) if (e != 0)
85 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); 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 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); 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);
 
... ... static void npv_xcb_win_map(void)
91 91 * nowdays: usually 1 scr per display * nowdays: usually 1 scr per display
92 92 * 1 scr has 1 root win * 1 scr has 1 root win
93 93 */ */
94 static void npv_xcb_connect(void)
94 STATIC void npv_xcb_connect(void)
95 95 { {
96 96 int r; int r;
97 97
 
... ... static void npv_xcb_connect(void)
100 100 FATALX("no x11 DISPLAY environment variable, exiting\n"); FATALX("no x11 DISPLAY environment variable, exiting\n");
101 101
102 102 npv_xcb_p.scr_idx = 0; npv_xcb_p.scr_idx = 0;
103 npv_xcb_p.c = dl_xcb_connect(0, &npv_xcb_p.scr_idx); /* should be 0 though */
104 r = dl_xcb_connection_has_error(npv_xcb_p.c);
103 /* should be 0 though */
104 npv_xcb_p.c = npv_dl_xcb_connect(0, &npv_xcb_p.scr_idx);
105 r = npv_dl_xcb_connection_has_error(npv_xcb_p.c);
105 106 if (r > 0) if (r > 0)
106 107 FATALX("%d:%s:error while connecting to the x11 server\n", r, npv_xcb_p.disp_env); FATALX("%d:%s:error while connecting to the x11 server\n", r, npv_xcb_p.disp_env);
107 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); 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);
108 109
109 npv_xcb_p.fd = dl_xcb_get_file_descriptor(npv_xcb_p.c);
110 npv_xcb_p.fd = npv_dl_xcb_get_file_descriptor(npv_xcb_p.c);
110 111 if (npv_xcb_p.fd == -1) if (npv_xcb_p.fd == -1)
111 112 FATALX("'%s':unable to get the connection file descriptor for epoll\n", npv_xcb_p.disp_env); FATALX("'%s':unable to get the connection file descriptor for epoll\n", npv_xcb_p.disp_env);
112 113 POUTX("'%s':connection:%p:file descriptor %d\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.fd); POUTX("'%s':connection:%p:file descriptor %d\n", npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.fd);
113 114 } }
114 static void npv_xcb_scr_get(void)
115 STATIC void npv_xcb_scr_get(void)
115 116 { {
116 117 xcb_screen_iterator_t iter; xcb_screen_iterator_t iter;
117 118 int scrs_n; int scrs_n;
118 119 int i; int i;
119 120
120 npv_xcb_p.setup = dl_xcb_get_setup(npv_xcb_p.c);
121 npv_xcb_p.setup = npv_dl_xcb_get_setup(npv_xcb_p.c);
121 122
122 scrs_n = dl_xcb_setup_roots_length(npv_xcb_p.setup);
123 scrs_n = npv_dl_xcb_setup_roots_length(npv_xcb_p.setup);
123 124 POUTX("'%s':connection:%p:has %d screens (should be 1)\n", npv_xcb_p.disp_env, npv_xcb_p.c, scrs_n); POUTX("'%s':connection:%p:has %d screens (should be 1)\n", npv_xcb_p.disp_env, npv_xcb_p.c, scrs_n);
124 125
125 iter = dl_xcb_setup_roots_iterator(npv_xcb_p.setup);
126 iter = npv_dl_xcb_setup_roots_iterator(npv_xcb_p.setup);
126 127 i = 0; i = 0;
127 128 npv_xcb_p.scr = 0; npv_xcb_p.scr = 0;
128 129 loop { loop {
 
... ... static void npv_xcb_scr_get(void)
133 134 npv_xcb_p.scr = iter.data; npv_xcb_p.scr = iter.data;
134 135 break; break;
135 136 } }
136 dl_xcb_screen_next(&iter);
137 npv_dl_xcb_screen_next(&iter);
137 138 } }
138 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); 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);
139 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); 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);
 
... ... static void npv_xcb_scr_get(void)
152 153 #define BASE_WIDTH 15 #define BASE_WIDTH 15
153 154 #define BASE_HEIGHT 16 #define BASE_HEIGHT 16
154 155 #define DWORDS_N 18 #define DWORDS_N 18
155 static void npv_xcb_wm_hints(void)
156 STATIC void npv_xcb_wm_hints(void)
156 157 { {
157 158 #if 0 #if 0
158 159 /* the following will tell the wm the win is not resizable */ /* the following will tell the wm the win is not resizable */
 
... ... static void npv_xcb_wm_hints(void)
170 171 data[MIN_HEIGHT] = npv_xcb_p.height; data[MIN_HEIGHT] = npv_xcb_p.height;
171 172 data[MAX_WIDTH] = npv_xcb_p.width; data[MAX_WIDTH] = npv_xcb_p.width;
172 173 data[MAX_HEIGHT] = npv_xcb_p.height; data[MAX_HEIGHT] = npv_xcb_p.height;
173 dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
174 npv_dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
174 175 npv_xcb_p.win_id, XCB_ATOM_WM_NORMAL_HINTS, npv_xcb_p.win_id, XCB_ATOM_WM_NORMAL_HINTS,
175 176 XCB_ATOM_WM_SIZE_HINTS, 32, DWORDS_N, data); XCB_ATOM_WM_SIZE_HINTS, 32, DWORDS_N, data);
176 177 #endif #endif
 
... ... static void npv_xcb_wm_hints(void)
183 184 data[BASE_WIDTH] = npv_xcb_p.width; data[BASE_WIDTH] = npv_xcb_p.width;
184 185 data[BASE_HEIGHT] = npv_xcb_p.height; data[BASE_HEIGHT] = npv_xcb_p.height;
185 186
186 dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
187 npv_dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
187 188 npv_xcb_p.win_id, XCB_ATOM_WM_NORMAL_HINTS, npv_xcb_p.win_id, XCB_ATOM_WM_NORMAL_HINTS,
188 189 XCB_ATOM_WM_SIZE_HINTS, 32, DWORDS_N, data); XCB_ATOM_WM_SIZE_HINTS, 32, DWORDS_N, data);
189 190 #endif #endif
 
... ... static void npv_xcb_wm_hints(void)
200 201 #undef BASE_HEIGHT #undef BASE_HEIGHT
201 202 #undef DWORDS_N #undef DWORDS_N
202 203 #define NPV_WM_CLASS "npv\0npv" #define NPV_WM_CLASS "npv\0npv"
203 static void npv_xcb_wm_class(void)
204 STATIC void npv_xcb_wm_class(void)
204 205 { {
205 dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
206 npv_dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
206 207 npv_xcb_p.win_id, XCB_ATOM_WM_CLASS, npv_xcb_p.win_id, XCB_ATOM_WM_CLASS,
207 208 XCB_ATOM_STRING, 8, sizeof(NPV_WM_CLASS), XCB_ATOM_STRING, 8, sizeof(NPV_WM_CLASS),
208 209 NPV_WM_CLASS); NPV_WM_CLASS);
209 210 } }
210 211 #undef NPV_WM_CLASS #undef NPV_WM_CLASS
211 212 #define NPV_WM_NAME "npv" #define NPV_WM_NAME "npv"
212 static void npv_xcb_wm_name(void)
213 STATIC void npv_xcb_wm_name(void)
213 214 { {
214 dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
215 npv_dl_xcb_change_property(npv_xcb_p.c, XCB_PROP_MODE_REPLACE,
215 216 npv_xcb_p.win_id, XCB_ATOM_WM_NAME, npv_xcb_p.win_id, XCB_ATOM_WM_NAME,
216 217 XCB_ATOM_STRING, 8, strlen(NPV_WM_NAME), XCB_ATOM_STRING, 8, strlen(NPV_WM_NAME),
217 218 NPV_WM_NAME); NPV_WM_NAME);
218 219 } }
219 220 #undef NPV_WM_NAME #undef NPV_WM_NAME
220 static void npv_xcb_evt_key_release(xcb_generic_event_t *evt)
221 STATIC void npv_xcb_evt_key_release(xcb_generic_event_t *evt)
221 222 { {
222 223 u8 b; u8 b;
223 224 xcb_key_release_event_t *key; xcb_key_release_event_t *key;
 
... ... static void npv_xcb_evt_key_release(xcb_generic_event_t *evt)
225 226 key = (xcb_key_release_event_t*)evt; key = (xcb_key_release_event_t*)evt;
226 227 b = 0; b = 0;
227 228 loop { loop {
228 if (b == ARRAY_N(x11_binds))
229 if (b == ARRAY_N(npv_x11_binds))
229 230 break; break;
230 if (key->detail == x11_binds[b].keycode) {
231 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, x11_binds[b].name);
232 x11_binds[b].cmd();
231 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);
233 npv_x11_binds[b].cmd();
233 234 return; return;
234 235 } }
235 236 ++b; ++b;
236 237 } }
237 238 POUTX("'%s':connection:%p:event:key release:keycode:%#02x\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail); POUTX("'%s':connection:%p:event:key release:keycode:%#02x\n", npv_xcb_p.disp_env, npv_xcb_p.c, key->detail);
238 239 } }
239 static void npv_xcb_evt_leave_win(xcb_generic_event_t *evt)
240 STATIC void npv_xcb_evt_leave_win(xcb_generic_event_t *evt)
240 241 { {
241 242 if (npv_xcb_p.mouse_hidden) { if (npv_xcb_p.mouse_hidden) {
242 dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
243 dl_xcb_flush(npv_xcb_p.c);
243 npv_dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
244 npv_dl_xcb_flush(npv_xcb_p.c);
244 245 } }
245 246 npv_xcb_p.mouse_hidden = false; npv_xcb_p.mouse_hidden = false;
246 247 npv_xcb_p.last_root_x = -1; npv_xcb_p.last_root_x = -1;
247 248 npv_xcb_p.last_root_y = -1; npv_xcb_p.last_root_y = -1;
248 249 } }
249 static void npv_xcb_mouse_visibility_timer_start(void)
250 STATIC void npv_xcb_mouse_visibility_timer_start(void)
250 251 { {
251 252 struct itimerspec t; struct itimerspec t;
252 253 int r; int r;
 
... ... static void npv_xcb_mouse_visibility_timer_start(void)
257 258 if (r == -1) if (r == -1)
258 259 FATALX("unable to arm the mouse visibility timer to %u seconds\n", npv_xcb_mouse_visibility_interval_s); FATALX("unable to arm the mouse visibility timer to %u seconds\n", npv_xcb_mouse_visibility_interval_s);
259 260 } }
260 static void npv_xcb_evt_enter_win(xcb_generic_event_t *evt)
261 STATIC void npv_xcb_evt_enter_win(xcb_generic_event_t *evt)
261 262 { {
262 263 xcb_enter_notify_event_t *ene; xcb_enter_notify_event_t *ene;
263 264
264 265 ene = (xcb_enter_notify_event_t*)evt; ene = (xcb_enter_notify_event_t*)evt;
265 dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
266 dl_xcb_flush(npv_xcb_p.c);
266 npv_dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
267 npv_dl_xcb_flush(npv_xcb_p.c);
267 268 npv_xcb_p.mouse_hidden = false; npv_xcb_p.mouse_hidden = false;
268 269 npv_xcb_p.last_root_x = ene->root_x; npv_xcb_p.last_root_x = ene->root_x;
269 270 npv_xcb_p.last_root_y = ene->root_y; npv_xcb_p.last_root_y = ene->root_y;
270 271 npv_xcb_mouse_visibility_timer_start(); npv_xcb_mouse_visibility_timer_start();
271 272 } }
272 static void npv_xcb_evt_motion(xcb_generic_event_t *evt)
273 STATIC void npv_xcb_evt_motion(xcb_generic_event_t *evt)
273 274 { {
274 275 xcb_motion_notify_event_t *mne; xcb_motion_notify_event_t *mne;
275 276
276 277 mne = (xcb_motion_notify_event_t*)evt; mne = (xcb_motion_notify_event_t*)evt;
277 278 if (npv_xcb_p.mouse_hidden) { if (npv_xcb_p.mouse_hidden) {
278 dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
279 dl_xcb_flush(npv_xcb_p.c);
279 npv_dl_xcb_xfixes_show_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
280 npv_dl_xcb_flush(npv_xcb_p.c);
280 281 } }
281 282 npv_xcb_p.mouse_hidden = false; npv_xcb_p.mouse_hidden = false;
282 283 npv_xcb_p.last_root_x = mne->root_x; npv_xcb_p.last_root_x = mne->root_x;
 
... ... typedef struct xcb_configure_notify_event_t {
300 301 uint8_t pad1; uint8_t pad1;
301 302 } xcb_configure_notify_event_t; } xcb_configure_notify_event_t;
302 303 #endif #endif
303 static void npv_xcb_evt_cfg_notify(xcb_generic_event_t *evt)
304 STATIC void npv_xcb_evt_cfg_notify(xcb_generic_event_t *evt)
304 305 { {
305 306 xcb_configure_notify_event_t *cne; xcb_configure_notify_event_t *cne;
306 307
 
... ... static void npv_xcb_evt_cfg_notify(xcb_generic_event_t *evt)
311 312 PERR("CFG_NOTIFY_EVT:x=%d y=%d w=%u h=%u bw=%u\n", cne->x, cne->y, cne->width, cne->height, cne->border_width); PERR("CFG_NOTIFY_EVT:x=%d y=%d w=%u h=%u bw=%u\n", cne->x, cne->y, cne->width, cne->height, cne->border_width);
312 313 #endif #endif
313 314 } }
314 static void npv_xcb_evt_handle(xcb_generic_event_t *evt)
315 STATIC void npv_xcb_evt_handle(xcb_generic_event_t *evt)
315 316 { {
316 317 u8 evt_code; u8 evt_code;
317 318 /* /*
 
... ... static void npv_xcb_evt_handle(xcb_generic_event_t *evt)
341 342 break; break;
342 343 } }
343 344 } }
344 static void npv_xcb_screensaver_heartbeat_timer_init_once(void)
345 STATIC void npv_xcb_screensaver_heartbeat_timer_init_once(void)
345 346 { {
346 347 errno = 0; errno = 0;
347 348 npv_xcb_p.screensaver_heartbeat_timer_fd = timerfd_create( npv_xcb_p.screensaver_heartbeat_timer_fd = timerfd_create(
 
... ... static void npv_xcb_screensaver_heartbeat_timer_init_once(void)
349 350 if (npv_xcb_p.screensaver_heartbeat_timer_fd == -1) if (npv_xcb_p.screensaver_heartbeat_timer_fd == -1)
350 351 FATALX("unable to get a timer file descriptor for the screensaver heartbeat:%s\n", strerror(errno)); FATALX("unable to get a timer file descriptor for the screensaver heartbeat:%s\n", strerror(errno));
351 352 } }
352 static void npv_xcb_mouse_visibilty_init_once(void)
353 STATIC void npv_xcb_mouse_visibilty_init_once(void)
353 354 { {
354 355 struct xcb_query_extension_reply_t const *xfixes; struct xcb_query_extension_reply_t const *xfixes;
355 356 xcb_xfixes_query_version_cookie_t qec; xcb_xfixes_query_version_cookie_t qec;
356 357
357 xfixes = dl_xcb_get_extension_data(npv_xcb_p.c, dl_xcb_xfixes_id);
358 xfixes = npv_dl_xcb_get_extension_data(npv_xcb_p.c,
359 npv_dl_xcb_xfixes_id);
358 360 if (xfixes->response_type != 1 || xfixes->present == 0) if (xfixes->response_type != 1 || xfixes->present == 0)
359 361 WARNINGX("the server is missing xfixes extension\n"); WARNINGX("the server is missing xfixes extension\n");
360 362 /* the hice/show cursor is supported from version 4 */ /* the hice/show cursor is supported from version 4 */
361 dl_xcb_xfixes_query_version(npv_xcb_p.c, 4, 0);
363 npv_dl_xcb_xfixes_query_version(npv_xcb_p.c, 4, 0);
362 364 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
363 365 npv_xcb_p.mouse_hidden = false; npv_xcb_p.mouse_hidden = false;
364 366 npv_xcb_p.last_root_x = -1; npv_xcb_p.last_root_x = -1;
 
... ... static void npv_xcb_mouse_visibilty_init_once(void)
375 377 #define SOURCE_NORMAL_APP 1 #define SOURCE_NORMAL_APP 1
376 378 #define STRLEN(x) (sizeof(x)-1) #define STRLEN(x) (sizeof(x)-1)
377 379 #define DONT_PROPAGATE_TO_ANCESTORS 0 #define DONT_PROPAGATE_TO_ANCESTORS 0
378 static void npv_xcb_fullscreen_action(u32 action)
380 STATIC void npv_xcb_fullscreen_action(u32 action)
379 381 { {
380 382 xcb_intern_atom_cookie_t cookie_net_wm_state; xcb_intern_atom_cookie_t cookie_net_wm_state;
381 383 xcb_intern_atom_cookie_t cookie_net_wm_state_fullscreen; xcb_intern_atom_cookie_t cookie_net_wm_state_fullscreen;
 
... ... static void npv_xcb_fullscreen_action(u32 action)
385 387 xcb_atom_t net_wm_state_fullscreen; xcb_atom_t net_wm_state_fullscreen;
386 388 xcb_client_message_event_t cm_evt; xcb_client_message_event_t cm_evt;
387 389
388 cookie_net_wm_state = dl_xcb_intern_atom(npv_xcb_p.c, 1,
390 cookie_net_wm_state = npv_dl_xcb_intern_atom(npv_xcb_p.c, 1,
389 391 STRLEN(NET_WM_STATE), NET_WM_STATE); STRLEN(NET_WM_STATE), NET_WM_STATE);
390 cookie_net_wm_state_fullscreen = dl_xcb_intern_atom(npv_xcb_p.c, 1,
392 cookie_net_wm_state_fullscreen = npv_dl_xcb_intern_atom(npv_xcb_p.c, 1,
391 393 STRLEN(NET_WM_STATE_FULLSCREEN), NET_WM_STATE_FULLSCREEN); STRLEN(NET_WM_STATE_FULLSCREEN), NET_WM_STATE_FULLSCREEN);
392 394 err = 0; err = 0;
393 reply = dl_xcb_intern_atom_reply(npv_xcb_p.c, cookie_net_wm_state,
395 reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c, cookie_net_wm_state,
394 396 &err); &err);
395 397 if (reply == 0) { if (reply == 0) {
396 398 WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE atom:%d\n", err->error_code); WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE atom:%d\n", err->error_code);
 
... ... static void npv_xcb_fullscreen_action(u32 action)
400 402 net_wm_state = reply->atom; net_wm_state = reply->atom;
401 403 free(reply); free(reply);
402 404 err = 0; err = 0;
403 reply = dl_xcb_intern_atom_reply(npv_xcb_p.c,
405 reply = npv_dl_xcb_intern_atom_reply(npv_xcb_p.c,
404 406 cookie_net_wm_state_fullscreen, &err); cookie_net_wm_state_fullscreen, &err);
405 407 if (reply == 0) { if (reply == 0) {
406 408 WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE_FULLSCREEN atom:%d\n", err->error_code); WARNINGX("unable to set fullscreen:unable to get the _NET_WM_STATE_FULLSCREEN atom:%d\n", err->error_code);
 
... ... static void npv_xcb_fullscreen_action(u32 action)
422 424 * client message send event req must use the evt mask below and must * client message send event req must use the evt mask below and must
423 425 * not propagate the evt, see ewmh specs * not propagate the evt, see ewmh specs
424 426 */ */
425 dl_xcb_send_event(npv_xcb_p.c, DONT_PROPAGATE_TO_ANCESTORS,
427 npv_dl_xcb_send_event(npv_xcb_p.c, DONT_PROPAGATE_TO_ANCESTORS,
426 428 npv_xcb_p.scr->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY npv_xcb_p.scr->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY
427 429 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT , (u8*)&cm_evt); | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT , (u8*)&cm_evt);
428 dl_xcb_flush(npv_xcb_p.c);
430 npv_dl_xcb_flush(npv_xcb_p.c);
429 431 } }
430 432 #undef NET_WM_STATE #undef NET_WM_STATE
431 433 #undef NET_WM_STATE_FULLSCREEN #undef NET_WM_STATE_FULLSCREEN
 
... ... static void npv_xcb_fullscreen_action(u32 action)
434 436 #undef STRLEN #undef STRLEN
435 437 #undef DONT_PROPAGATE_TO_ANCESTORS #undef DONT_PROPAGATE_TO_ANCESTORS
436 438 #define NET_WM_STATE_ADD 1 #define NET_WM_STATE_ADD 1
437 static void npv_xcb_fullscreen_init_once(bool start_fullscreen)
439 STATIC void npv_xcb_fullscreen_init_once(bool start_fullscreen)
438 440 { {
439 441 xcb_intern_atom_cookie_t cookie_net_wm_state; xcb_intern_atom_cookie_t cookie_net_wm_state;
440 442 xcb_intern_atom_cookie_t cookie_net_wm_state_fullscreen; xcb_intern_atom_cookie_t cookie_net_wm_state_fullscreen;
File npv/xcb/local/state.frag.c changed (mode: 100644) (index c714e02..9061d61)
1 static void *npv_xcb_lib_l;
2 static void *npv_xcb_xfixes_lib_l;
1 STATIC void *npv_xcb_lib_l;
2 STATIC void *npv_xcb_xfixes_lib_l;
3 3 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
4 static xcb_connection_t *(*dl_xcb_connect)(u8 *displayname, int *scr);
5 static int (*dl_xcb_get_file_descriptor)(xcb_connection_t *c);
6 static u32 (*dl_xcb_generate_id)(xcb_connection_t *c);
7 static int (*dl_xcb_connection_has_error)(xcb_connection_t *c);
8 static xcb_setup_t *(*dl_xcb_get_setup)(xcb_connection_t *c);
9 static int (*dl_xcb_setup_roots_length)(xcb_setup_t *s);
10 static xcb_screen_iterator_t (*dl_xcb_setup_roots_iterator)(xcb_setup_t *s);
11 static void (*dl_xcb_screen_next)(xcb_screen_iterator_t *iter);
12 static void (*dl_xcb_create_window)(xcb_connection_t *c, u8 depth,
4 STATIC xcb_connection_t *(*npv_dl_xcb_connect)(u8 *displayname, int *scr);
5 STATIC int (*npv_dl_xcb_get_file_descriptor)(xcb_connection_t *c);
6 STATIC u32 (*npv_dl_xcb_generate_id)(xcb_connection_t *c);
7 STATIC int (*npv_dl_xcb_connection_has_error)(xcb_connection_t *c);
8 STATIC xcb_setup_t *(*npv_dl_xcb_get_setup)(xcb_connection_t *c);
9 STATIC int (*npv_dl_xcb_setup_roots_length)(xcb_setup_t *s);
10 STATIC xcb_screen_iterator_t (*npv_dl_xcb_setup_roots_iterator)(xcb_setup_t *s);
11 STATIC void (*npv_dl_xcb_screen_next)(xcb_screen_iterator_t *iter);
12 STATIC void (*npv_dl_xcb_create_window)(xcb_connection_t *c, u8 depth,
13 13 xcb_window_t wid, xcb_window_t parent, s16 x, s16 y, u16 width, xcb_window_t wid, xcb_window_t parent, s16 x, s16 y, u16 width,
14 14 u16 heigth, u16 border_width, u16 class, xcb_visualid_t visual, u16 heigth, u16 border_width, u16 class, xcb_visualid_t visual,
15 15 u32 value_mask, u32 *value_list); u32 value_mask, u32 *value_list);
16 static xcb_void_cookie_t (*dl_xcb_map_window)(xcb_connection_t *c,
16 STATIC xcb_void_cookie_t (*npv_dl_xcb_map_window)(xcb_connection_t *c,
17 17 xcb_window_t win); xcb_window_t win);
18 static xcb_void_cookie_t (*dl_xcb_map_window_checked)(xcb_connection_t *c,
18 STATIC xcb_void_cookie_t (*npv_dl_xcb_map_window_checked)(xcb_connection_t *c,
19 19 xcb_window_t win); xcb_window_t win);
20 static xcb_generic_error_t *(*dl_xcb_request_check)(xcb_connection_t *c,
20 STATIC xcb_generic_error_t *(*npv_dl_xcb_request_check)(xcb_connection_t *c,
21 21 xcb_void_cookie_t cookie); xcb_void_cookie_t cookie);
22 static int (*dl_xcb_flush)(xcb_connection_t *c);
23 static xcb_generic_event_t *(*dl_xcb_wait_for_event)(xcb_connection_t *c);
24 static xcb_generic_event_t *(*dl_xcb_poll_for_event)(xcb_connection_t *c);
25 static void (*dl_xcb_disconnect)(xcb_connection_t *c);
26 static xcb_void_cookie_t (*dl_xcb_change_property)(xcb_connection_t *c, u8 mode,
27 xcb_window_t window, xcb_atom_t property, xcb_atom_t type, u8 format,
28 u32 data_len, void *data);
29 static xcb_void_cookie_t (*dl_xcb_force_screen_saver)(xcb_connection_t *c,
22 STATIC int (*npv_dl_xcb_flush)(xcb_connection_t *c);
23 STATIC xcb_generic_event_t *(*npv_dl_xcb_wait_for_event)(xcb_connection_t *c);
24 STATIC xcb_generic_event_t *(*npv_dl_xcb_poll_for_event)(xcb_connection_t *c);
25 STATIC void (*npv_dl_xcb_disconnect)(xcb_connection_t *c);
26 STATIC xcb_void_cookie_t (*npv_dl_xcb_change_property)(xcb_connection_t *c,
27 u8 mode, xcb_window_t window, xcb_atom_t property, xcb_atom_t type,
28 u8 format, u32 data_len, void *data);
29 STATIC xcb_void_cookie_t (*npv_dl_xcb_force_screen_saver)(xcb_connection_t *c,
30 30 u8 mode); u8 mode);
31 static struct xcb_query_extension_reply_t const *(*dl_xcb_get_extension_data)(
32 xcb_connection_t *c, xcb_extension_t *ext);
33 static xcb_extension_t *dl_xcb_xfixes_id;
34 static xcb_void_cookie_t (*dl_xcb_xfixes_show_cursor)(xcb_connection_t *c,
31 STATIC struct xcb_query_extension_reply_t const
32 *(*npv_dl_xcb_get_extension_data)(xcb_connection_t *c,
33 xcb_extension_t *ext);
34 STATIC xcb_extension_t *npv_dl_xcb_xfixes_id;
35 STATIC xcb_void_cookie_t (*npv_dl_xcb_xfixes_show_cursor)(xcb_connection_t *c,
35 36 xcb_window_t window); xcb_window_t window);
36 static xcb_void_cookie_t (*dl_xcb_xfixes_hide_cursor)(xcb_connection_t *c,
37 STATIC xcb_void_cookie_t (*npv_dl_xcb_xfixes_hide_cursor)(xcb_connection_t *c,
37 38 xcb_window_t window); xcb_window_t window);
38 static xcb_query_pointer_reply_t *(*dl_xcb_query_pointer_reply)(
39 STATIC xcb_query_pointer_reply_t *(*npv_dl_xcb_query_pointer_reply)(
39 40 xcb_connection_t *c, xcb_query_pointer_cookie_t cookie, xcb_connection_t *c, xcb_query_pointer_cookie_t cookie,
40 41 xcb_generic_error_t **e); xcb_generic_error_t **e);
41 static xcb_query_pointer_cookie_t (*dl_xcb_query_pointer)(xcb_connection_t *c,
42 xcb_window_t window);
43 static xcb_xfixes_query_version_cookie_t (*dl_xcb_xfixes_query_version)(
42 STATIC xcb_query_pointer_cookie_t (*npv_dl_xcb_query_pointer)(
43 xcb_connection_t *c, xcb_window_t window);
44 STATIC xcb_xfixes_query_version_cookie_t (*npv_dl_xcb_xfixes_query_version)(
44 45 xcb_connection_t *c, u32 client_major_version, xcb_connection_t *c, u32 client_major_version,
45 46 u32 client_minor_version); u32 client_minor_version);
46 xcb_void_cookie_t (*dl_xcb_send_event)(xcb_connection_t *c, u8 propagate,
47 xcb_void_cookie_t (*npv_dl_xcb_send_event)(xcb_connection_t *c, u8 propagate,
47 48 xcb_window_t destination, u32 event_mask, u8 *event); xcb_window_t destination, u32 event_mask, u8 *event);
48 xcb_intern_atom_cookie_t (*dl_xcb_intern_atom)(xcb_connection_t *c,
49 xcb_intern_atom_cookie_t (*npv_dl_xcb_intern_atom)(xcb_connection_t *c,
49 50 u8 only_if_exists, u16 name_len, u8 *name); u8 only_if_exists, u16 name_len, u8 *name);
50 xcb_intern_atom_reply_t *(*dl_xcb_intern_atom_reply)(xcb_connection_t *c,
51 xcb_intern_atom_reply_t *(*npv_dl_xcb_intern_atom_reply)(xcb_connection_t *c,
51 52 xcb_intern_atom_cookie_t cookie, xcb_generic_error_t **e); xcb_intern_atom_cookie_t cookie, xcb_generic_error_t **e);
File npv/xcb/main.c changed (mode: 100644) (index e672f5e..470d0bc)
4 4 * code protected with a GNU affero GPLv3 license * code protected with a GNU affero GPLv3 license
5 5 * copyright (C) 2020 Sylvain BERTRAND * copyright (C) 2020 Sylvain BERTRAND
6 6 */ */
7 #include <stdbool.h>
7 8 #include <string.h> #include <string.h>
8 9 #include <stdlib.h> #include <stdlib.h>
9 10 #include <stdio.h> #include <stdio.h>
11 #include <unistd.h>
10 12 #include <dlfcn.h> #include <dlfcn.h>
11 #include <xcb.h>
12 #include <xfixes.h>
13 #include <sys/timerfd.h>
14 #include <xcb/xcb.h>
15 #include <xcb/xfixes.h>
13 16 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
14 17 #include "npv/global.h" #include "npv/global.h"
18 #include "npv/public.h"
15 19 #include "npv/xcb/public.h" #include "npv/xcb/public.h"
16 20 #include "npv/video/public.h" #include "npv/video/public.h"
17 21 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
File npv/xcb/public.h changed (mode: 100644) (index a9478cf..6c3556d)
4 4 * code protected with a GNU affero GPLv3 license * code protected with a GNU affero GPLv3 license
5 5 * copyright (C) 2020 Sylvain BERTRAND * copyright (C) 2020 Sylvain BERTRAND
6 6 */ */
7 #include <xcb.h>
7 #include <stdbool.h>
8 #include <xcb/xcb.h>
8 9 #include "npv/c_fixing.h" #include "npv/c_fixing.h"
9 10 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
10 11 #include "npv/xcb/public/state.frag.h" #include "npv/xcb/public/state.frag.h"
11 12 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
12 static void npv_xcb_init_once(u16 width, u16 height, bool start_fullscreen);
13 static void npv_xcb_evt(void);
14 static void npv_xcb_screensaver_heartbeat_timer_start(void);
15 static void npv_xcb_screensaver_heartbeat_timer_evt(void);
16 static void npv_xcb_mouse_visibility_timer_evt(void);
13 STATIC void npv_xcb_init_once(u16 width, u16 height, bool start_fullscreen);
14 STATIC void npv_xcb_evt(void);
15 STATIC void npv_xcb_screensaver_heartbeat_timer_start(void);
16 STATIC void npv_xcb_screensaver_heartbeat_timer_evt(void);
17 STATIC void npv_xcb_mouse_visibility_timer_evt(void);
17 18 #endif #endif
File npv/xcb/public/code.frag.c changed (mode: 100644) (index a5d52a4..0713bf3)
1 static void npv_xcb_evt(void) { loop
1 STATIC void npv_xcb_evt(void) { loop
2 2 { {
3 3 /* draining evts */ /* draining evts */
4 4 xcb_generic_event_t *e; xcb_generic_event_t *e;
5 5
6 e = dl_xcb_poll_for_event(npv_xcb_p.c);
6 e = npv_dl_xcb_poll_for_event(npv_xcb_p.c);
7 7 if (e == 0) if (e == 0)
8 8 break; break;
9 9 npv_xcb_evt_handle(e); npv_xcb_evt_handle(e);
10 10 free(e); free(e);
11 11 }} }}
12 static void npv_xcb_init_once(u16 win_width, u16 win_height,
12 STATIC void npv_xcb_init_once(u16 win_width, u16 win_height,
13 13 bool start_fullscreen) bool start_fullscreen)
14 14 { {
15 15 int r; int r;
 
... ... static void npv_xcb_init_once(u16 win_width, u16 win_height,
31 31 npv_xcb_wm_hints(); /* before the win is mapped */ npv_xcb_wm_hints(); /* before the win is mapped */
32 32 npv_xcb_win_map(); npv_xcb_win_map();
33 33
34 r = dl_xcb_flush(npv_xcb_p.c);
34 r = npv_dl_xcb_flush(npv_xcb_p.c);
35 35 if (r <= 0) if (r <= 0)
36 36 FATALX("%d:xcb:'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:unable to flush the connection\n", r, npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id); FATALX("%d:xcb:'%s':connection:%p:screen:%d:root window id:%#x:window id:%#x:unable to flush the connection\n", r, npv_xcb_p.disp_env, npv_xcb_p.c, npv_xcb_p.scr_idx, npv_xcb_p.scr->root, npv_xcb_p.win_id);
37 37 POUTX("'%s':connection:%p:connection flushed\n", npv_xcb_p.disp_env, npv_xcb_p.c); POUTX("'%s':connection:%p:connection flushed\n", npv_xcb_p.disp_env, npv_xcb_p.c);
38 38 npv_xcb_fullscreen_init_once(start_fullscreen); npv_xcb_fullscreen_init_once(start_fullscreen);
39 39 } }
40 static void npv_xcb_screensaver_heartbeat_timer_start(void)
40 STATIC void npv_xcb_screensaver_heartbeat_timer_start(void)
41 41 { {
42 42 struct itimerspec t; struct itimerspec t;
43 43 int r; int r;
 
... ... static void npv_xcb_screensaver_heartbeat_timer_start(void)
49 49 if (r == -1) if (r == -1)
50 50 FATALX("unable to arm the screensaver heartbeat timer to %u seconds\n", npv_xcb_screensaver_heartbeat_timeout_s); FATALX("unable to arm the screensaver heartbeat timer to %u seconds\n", npv_xcb_screensaver_heartbeat_timeout_s);
51 51 } }
52 static void npv_xcb_screensaver_heartbeat_timer_evt(void)
52 STATIC void npv_xcb_screensaver_heartbeat_timer_evt(void)
53 53 { {
54 54 int r; int r;
55 55 uint64_t exps_n; uint64_t exps_n;
 
... ... static void npv_xcb_screensaver_heartbeat_timer_evt(void)
60 60 if (r == -1) if (r == -1)
61 61 FATALX("unable to read the number of timer expirations related to the xcb screensaver heartbeat\n"); FATALX("unable to read the number of timer expirations related to the xcb screensaver heartbeat\n");
62 62 if (!npv_paused_p) { if (!npv_paused_p) {
63 (void)dl_xcb_force_screen_saver(npv_xcb_p.c, XCB_SCREEN_SAVER_RESET);
64 (void)dl_xcb_flush(npv_xcb_p.c);
63 npv_dl_xcb_force_screen_saver(npv_xcb_p.c,
64 XCB_SCREEN_SAVER_RESET);
65 npv_dl_xcb_flush(npv_xcb_p.c);
65 66 } }
66 67 } }
67 static void npv_xcb_mouse_visibility_timer_evt(void)
68 STATIC void npv_xcb_mouse_visibility_timer_evt(void)
68 69 { {
69 70 int r; int r;
70 71 uint64_t exps_n; uint64_t exps_n;
 
... ... static void npv_xcb_mouse_visibility_timer_evt(void)
78 79 FATALX("unable to read the number of timer expirations related to the xcb mouse visibility\n"); FATALX("unable to read the number of timer expirations related to the xcb mouse visibility\n");
79 80 if (npv_xcb_p.mouse_hidden) if (npv_xcb_p.mouse_hidden)
80 81 return; return;
81 cookie = dl_xcb_query_pointer(npv_xcb_p.c, npv_xcb_p.win_id);
82 cookie = npv_dl_xcb_query_pointer(npv_xcb_p.c, npv_xcb_p.win_id);
82 83 err = 0; err = 0;
83 reply = dl_xcb_query_pointer_reply(npv_xcb_p.c, cookie, &err);
84 reply = npv_dl_xcb_query_pointer_reply(npv_xcb_p.c, cookie, &err);
84 85 if (reply == 0) { if (reply == 0) {
85 86 WARNINGX("an error occured while handling the mouse pointer visibility:%d\n", err->error_code); WARNINGX("an error occured while handling the mouse pointer visibility:%d\n", err->error_code);
86 87 free(err); free(err);
 
... ... static void npv_xcb_mouse_visibility_timer_evt(void)
88 89 } }
89 90 if (reply->root_x == npv_xcb_p.last_root_x if (reply->root_x == npv_xcb_p.last_root_x
90 91 && reply->root_y == npv_xcb_p.last_root_y) { && reply->root_y == npv_xcb_p.last_root_y) {
91 dl_xcb_xfixes_hide_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
92 dl_xcb_flush(npv_xcb_p.c);
92 npv_dl_xcb_xfixes_hide_cursor(npv_xcb_p.c, npv_xcb_p.win_id);
93 npv_dl_xcb_flush(npv_xcb_p.c);
93 94 npv_xcb_p.mouse_hidden = true; npv_xcb_p.mouse_hidden = true;
94 95 } }
95 96 free(reply); free(reply);
96 97 } }
97 98 #define NET_WM_STATE_TOGGLE 2 #define NET_WM_STATE_TOGGLE 2
98 static void cmd_fullscreen_toggle(void)
99 STATIC void npv_cmd_fullscreen_toggle(void)
99 100 { {
100 101 npv_xcb_fullscreen_action(NET_WM_STATE_TOGGLE); npv_xcb_fullscreen_action(NET_WM_STATE_TOGGLE);
101 102 } }
File npv/xcb/public/state.frag.h changed (mode: 100644) (index 1a5e7f6..9fc8031)
... ... constant_u32 {
2 2 npv_xcb_screensaver_heartbeat_timeout_s = 30, npv_xcb_screensaver_heartbeat_timeout_s = 30,
3 3 npv_xcb_mouse_visibility_interval_s = 3 npv_xcb_mouse_visibility_interval_s = 3
4 4 }; };
5 static struct {
5 STATIC struct {
6 6 u8 *disp_env; u8 *disp_env;
7 7 xcb_connection_t *c; xcb_connection_t *c;
8 8 int fd; int fd;
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/nyanmp

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/nyanmp

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/nyanmp

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main