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: fix channel layout handling and a tad more 88f74f181a567d108874a936fe3d306d34cfefb7 Sylvain BERTRAND 2020-09-19 23:12:04
npv: dynamic audio filter configuration d8a0ff688ddb2abcde22c01a2ae52ea74e9f0f2f Sylvain BERTRAND 2020-09-19 20:54:04
npv:protection against tantrum of media audio 78589150b7c6f1f3cae49b4b4bc8b572c6d8e6b7 Sylvain BERTRAND 2020-09-18 15:26:17
npv/npa:finish to workaround null channel layout 314788563e01d7ffb364a1775ba68619ee3f6c5c Sylvain BERTRAND 2020-09-15 22:50:57
npv: handle empty channel layout 5b5794fc4d5300b671b684a2f41196f66bd1fc4a Sylvain BERTRAND 2020-09-15 22:11:07
npv: tidy mutex locking 1962092d9675f76604414086200e88f6c857346f Sylvain BERTRAND 2020-09-15 00:51:12
npv: less incorrect reprogramming of blits b319e79f4f1b79670f6eef754142cc65c891ad4b Sylvain BERTRAND 2020-09-12 15:14:27
npv:fix osd restoration 8c64f703eca6b8c54b4cb5c95231dd02aa394135 Sylvain BERTRAND 2020-08-29 20:36:12
npv:osd:solo compilation modulo a few warnings 7805bd8f34f913b1535cc81c5be2a3132bd7e0e5 Sylvain BERTRAND 2020-08-29 14:51:35
npv: cleanup and color component fix 44f294e1de96c7974740f1187ebdbe12204884ae Sylvain BERTRAND 2020-08-28 23:48:18
npv:osd:timer, will add more if pertinent 6d34403c2c49bfa6ccf8e7a72e35a69e6f0527c5 Sylvain BERTRAND 2020-08-28 22:47:18
npv/npa: document properly snd_pcm_drain behavior 510ca39ee6a9ac9fcd646484793b7556eaa5972f Sylvain BERTRAND 2020-08-26 17:36:29
npv:remove locale layout dependent key binds f69bbbe529045b4243ece8957c838cb1465352da Sylvain BERTRAND 2020-08-24 21:27:08
npv: global seek based on audio timeline only 3c8fd60fa0a67143fa16ac90565bfcc35a193b6b Sylvain BERTRAND 2020-08-24 18:41:16
npv:_reasonable_ "pedanticage" of the code c5f2644d6eba84bcbcc9b0599c41e1f6733ea95c Sylvain BERTRAND 2020-08-20 16:25:50
npa:some amount of pedanticage 554bd5b07b1a82eabb2622cbf565031bf7af5c6d Sylvain BERTRAND 2020-08-18 19:33:47
hacking again on it after a rather long time cc09df4f340c9f906e0de9520d2c803ea6936769 Sylvain BERTRAND 2020-08-16 18:14:14
npv:fix initial volume not being stored ef66775061157e5af7d6938d06f38e6e7d06a873 Sylvain BERTRAND 2020-08-15 16:59:23
npv:fixing the fix 2043d3ae57ff8b4c26acfd1ee2ff8958cb887ab8 Sylvain BERTRAND 2020-07-17 19:11:14
npv:fixing minor annoyances 2b1895f92933d41a7eb6b7638a94f526e1b5e7cd Sylvain BERTRAND 2020-07-17 19:03:47
Commit 88f74f181a567d108874a936fe3d306d34cfefb7 - npv: fix channel layout handling and a tad more
Author: Sylvain BERTRAND
Author date (UTC): 2020-09-19 23:12
Committer name: Sylvain BERTRAND
Committer date (UTC): 2020-09-19 23:12
Parent(s): d8a0ff688ddb2abcde22c01a2ae52ea74e9f0f2f
Signing key:
Tree: 2e9e8fd3ef062f5ec010489ae3820bb9401a42b1
File Lines added Lines deleted
npv/audio/filt/public/code.frag.c 3 21
npv/audio/local/code.frag.c 86 49
npv/audio/namespace/main.c 2 1
npv/audio/namespace/public.h 0 2
npv/audio/public.h 0 3
npv/audio/public/code.frag.c 0 41
File npv/audio/filt/public/code.frag.c changed (mode: 100644) (index 2fd1fef..77bd9c9)
1 /*NSPC*/
2 1 #define AGAIN 0 #define AGAIN 0
3 2 #define PUSHED_ONE_SET 1 #define PUSHED_ONE_SET 1
4 3 #define NO_DEC_SET 2 #define NO_DEC_SET 2
 
... ... STATIC u8 filt_push_dec_set(int *new_chans_n, uint64_t *new_chans_layout,
30 29 * XXX: this is were dynamic audio recfg is triggered and we get out of * XXX: this is were dynamic audio recfg is triggered and we get out of
31 30 * the critical section asap * the critical section asap
32 31 */ */
32 if (a[0]->chans_layout == 0) /* choose one for the filter */
33 a[0]->chans_layout = avutil_get_default_chans_layout(
34 a[0]->chans_n);
33 35 if (is_recfg_required(a[0])) { if (is_recfg_required(a[0])) {
34 36 /* because we are in a critical section */ /* because we are in a critical section */
35 37 *new_chans_n = a[0]->chans_n; *new_chans_n = a[0]->chans_n;
 
... ... STATIC u8 filt_set_get(void)
93 95 #define DONT_PRINT_INFO false #define DONT_PRINT_INFO false
94 96 STATIC void filt_flush(void) STATIC void filt_flush(void)
95 97 { {
96 int dst_chans_n;
97 enum avutil_audio_fr_fmt_t dst_fmt;
98 uint64_t src_chans_layout;
99 uint64_t dst_chans_layout;
100 int dst_rate;
101
102 98 avutil_audio_set_unref(filt_p.set); avutil_audio_set_unref(filt_p.set);
103 99 filt_p.pcm_written_ufrs_n = 0; filt_p.pcm_written_ufrs_n = 0;
104
105 npv_audio_pcm2ff_strict(npv_audio_pcm_p, &dst_chans_n,
106 &dst_chans_layout, &dst_rate, &dst_fmt, DONT_PRINT_INFO);
107 /* the audio dec ctx may not have a valid chans layout */
108 if (npv_audio_dec_ctx_p->chans_layout == 0)
109 src_chans_layout = avutil_get_default_chans_layout(
110 npv_audio_dec_ctx_p->chans_n);
111 else
112 src_chans_layout = npv_audio_dec_ctx_p->chans_layout;
113 cfg(npv_audio_dec_ctx_p->chans_n, src_chans_layout,
114 npv_audio_dec_ctx_p->fr_rate, npv_audio_dec_ctx_p->fr_fmt,
115 filt_p.muted, filt_p.vol,
116 dst_chans_n, dst_chans_layout, dst_rate, dst_fmt,
117 DONT_PRINT_INFO);
118 100 } }
119 101 #undef DONT_PRINT_INFO #undef DONT_PRINT_INFO
120 102 STATIC void init_once(double initial_vol) STATIC void init_once(double initial_vol)
File npv/audio/local/code.frag.c changed (mode: 100644) (index 48f17da..3f827fe)
... ... STATIC void draining_state_switch(void)
568 568 if (r == -1) if (r == -1)
569 569 fatal("unable to arm the draining timer\n"); fatal("unable to arm the draining timer\n");
570 570 } }
571 /* fatal if the wiring cannot be done */
572 STATIC void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
573 snd_pcm_access_t alsa_access, enum avutil_audio_fr_fmt_t *ff_fmt,
574 bool print_info)
575 {
576 /*
577 * ff fmt byte order is always native.
578 * here we handle little endian only
579 */
580 switch (alsa_fmt) {
581 case SND_PCM_FMT_FLOAT:
582 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
583 *ff_fmt = AVUTIL_AUDIO_FR_FMT_FLT;
584 else
585 *ff_fmt = AVUTIL_AUDIO_FR_FMT_FLTP;
586 break;
587 case SND_PCM_FMT_S32:
588 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
589 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S32;
590 else
591 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S32P;
592 break;
593 case SND_PCM_FMT_S16:
594 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
595 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S16;
596 else
597 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S16P;
598 break;
599 case SND_PCM_FMT_U8:
600 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
601 *ff_fmt = AVUTIL_AUDIO_FR_FMT_U8;
602 else
603 *ff_fmt = AVUTIL_AUDIO_FR_FMT_U8P;
604 break;
605 default:
606 fatal("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access));
607 }
608 if (print_info) {
609 u8 ff_fmt_str[STR_SZ];
610
611 avutil_get_audio_fr_fmt_str(ff_fmt_str, sizeof(ff_fmt_str),
612 *ff_fmt);
613 pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str);
614 }
615 }
616 STATIC void pcm2ff_strict(snd_pcm_t *pcm, int *ff_chans_n,
617 uint64_t *ff_chans_layout, int *ff_rate,
618 enum avutil_audio_fr_fmt_t *ff_fmt, bool print_info)
619 {
620 int r;
621 snd_pcm_hw_params_t *hw_params;
622 unsigned int pcm_chans_n;
623 unsigned int pcm_rate;
624 snd_pcm_fmt_t pcm_fmt;
625 snd_pcm_access_t pcm_access;
626
627 r = snd_pcm_hw_params_malloc(&hw_params);
628 if (r < 0)
629 fatal("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n");
630 r = snd_pcm_hw_params_current(pcm, hw_params);
631 if (r != 0)
632 fatal("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n");
633 r = snd_pcm_hw_params_get_access(hw_params, &pcm_access);
634 if (r < 0)
635 fatal("alsa:unable to get the pcm access for ffmpeg filter wiring\n");
636 r = snd_pcm_hw_params_get_fmt(hw_params, &pcm_fmt);
637 if (r < 0)
638 fatal("alsa:unable to get the pcm format for ffmpeg filter wiring\n");
639 /*--------------------------------------------------------------------*/
640 pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info);
641 /*--------------------------------------------------------------------*/
642 r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate,
643 SND_PCM_ST_PLAYBACK);
644 if (r < 0)
645 fatal("alsa:unable to get the pcm rate for ffmpeg filter wiring\n");
646 *ff_rate = (int)pcm_rate;
647 r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n);
648 if (r < 0)
649 fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n");
650 *ff_chans_n = (int)pcm_chans_n;
651 /*--------------------------------------------------------------------*/
652 *ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n,
653 print_info);
654 /*--------------------------------------------------------------------*/
655 snd_pcm_hw_params_free(hw_params);
656 }
571 657 #define NO_DEC_SET 2 #define NO_DEC_SET 2
572 658 #define FILT_RECFG_REQUIRED 4 #define FILT_RECFG_REQUIRED 4
573 659 #define EOF_FILT 2 #define EOF_FILT 2
 
... ... STATIC u8 dec_set_filter(void)
600 686 /* FILT_RECFG_REQUIRED */ /* FILT_RECFG_REQUIRED */
601 687 pcm2ff_strict(npv_audio_pcm_p, &dst_chans_n, &dst_chans_layout, pcm2ff_strict(npv_audio_pcm_p, &dst_chans_n, &dst_chans_layout,
602 688 &dst_rate, &dst_fmt, PRINT_INFO); &dst_rate, &dst_fmt, PRINT_INFO);
603 /* may not have a valid src chans layout, "fix it" */
604 if (new_chans_layout == 0)
605 new_chans_layout = avutil_get_default_chans_layout(
606 new_chans_n);
607 689 filt_cfg(new_chans_n, new_chans_layout, new_rate, new_fmt, filt_cfg(new_chans_n, new_chans_layout, new_rate, new_fmt,
608 690 filt_p.muted, filt_p.vol, filt_p.muted, filt_p.vol,
609 691 dst_chans_n, dst_chans_layout, dst_rate, dst_fmt, dst_chans_n, dst_chans_layout, dst_rate, dst_fmt,
 
... ... STATIC void dec_a_unref_all(void)
794 876 } }
795 877 dec_sets_p.n = 0; dec_sets_p.n = 0;
796 878 } }
797 /* fatal if the wiring cannot be done */
798 STATIC void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
799 snd_pcm_access_t alsa_access, enum avutil_audio_fr_fmt_t *ff_fmt,
800 bool print_info)
801 {
802 /*
803 * ff fmt byte order is always native.
804 * here we handle little endian only
805 */
806 switch (alsa_fmt) {
807 case SND_PCM_FMT_FLOAT:
808 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
809 *ff_fmt = AVUTIL_AUDIO_FR_FMT_FLT;
810 else
811 *ff_fmt = AVUTIL_AUDIO_FR_FMT_FLTP;
812 break;
813 case SND_PCM_FMT_S32:
814 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
815 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S32;
816 else
817 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S32P;
818 break;
819 case SND_PCM_FMT_S16:
820 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
821 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S16;
822 else
823 *ff_fmt = AVUTIL_AUDIO_FR_FMT_S16P;
824 break;
825 case SND_PCM_FMT_U8:
826 if (alsa_access == SND_PCM_ACCESS_RW_INTERLEAVED)
827 *ff_fmt = AVUTIL_AUDIO_FR_FMT_U8;
828 else
829 *ff_fmt = AVUTIL_AUDIO_FR_FMT_U8P;
830 break;
831 default:
832 fatal("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access));
833 }
834 if (print_info) {
835 u8 ff_fmt_str[STR_SZ];
836
837 avutil_get_audio_fr_fmt_str(ff_fmt_str, sizeof(ff_fmt_str),
838 *ff_fmt);
839 pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str);
840 }
841 }
File npv/audio/namespace/main.c changed (mode: 100644) (index 6601cff..25d4459)
12 12 #define draining_state_switch npv_audio_draining_state_switch #define draining_state_switch npv_audio_draining_state_switch
13 13 #define fatal npv_audio_fatal #define fatal npv_audio_fatal
14 14 #define ff_fmt2pcm_layout_best_effort npv_audio_ff_fmt2pcm_layout_best_effort #define ff_fmt2pcm_layout_best_effort npv_audio_ff_fmt2pcm_layout_best_effort
15 #define pcm2ff_strict npv_audio_pcm2ff_strict
15 16 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
16 17 /* from audio/filt */ /* from audio/filt */
17 18 #define filt_cfg npv_audio_filt_cfg #define filt_cfg npv_audio_filt_cfg
 
79 80 #undef pcm_perr_l #undef pcm_perr_l
80 81 #undef pcm_silence_bufs_l #undef pcm_silence_bufs_l
81 82 #undef pcm_silence_frs_write #undef pcm_silence_frs_write
82 #undef pcm2ff
83 #undef pcm2ff_strict
83 84 #undef pout #undef pout
84 85 #undef warning #undef warning
85 86 #endif #endif
File npv/audio/namespace/public.h changed (mode: 100644) (index 4ee24f8..a60ed5e)
21 21 #define pcm_pollfds_n_p npv_audio_pcm_pollfds_n_p #define pcm_pollfds_n_p npv_audio_pcm_pollfds_n_p
22 22 #define pcm_pollfds_n_max npv_audio_pcm_pollfds_n_max #define pcm_pollfds_n_max npv_audio_pcm_pollfds_n_max
23 23 #define pcm_silence_bufs_cfg npv_audio_pcm_silence_bufs_cfg #define pcm_silence_bufs_cfg npv_audio_pcm_silence_bufs_cfg
24 #define pcm2ff_strict npv_audio_pcm2ff_strict
25 24 #define pkt_q_p npv_audio_pkt_q_p #define pkt_q_p npv_audio_pkt_q_p
26 25 #define pkts_send npv_audio_pkts_send #define pkts_send npv_audio_pkts_send
27 26 #define prepare npv_audio_prepare #define prepare npv_audio_prepare
 
51 50 #undef pcm_pollfds_n_p #undef pcm_pollfds_n_p
52 51 #undef pcm_pollfds_n_max #undef pcm_pollfds_n_max
53 52 #undef pcm_silence_bufs_cfg #undef pcm_silence_bufs_cfg
54 #undef pcm2ff_strict
55 53 #undef pkt_q_p #undef pkt_q_p
56 54 #undef pkts_send #undef pkts_send
57 55 #undef prepare #undef prepare
File npv/audio/public.h changed (mode: 100644) (index 651616e..01a0351)
... ... STATIC void pkts_send(void);
41 41 STATIC void prepare(int override_initial_ff_chans_n, STATIC void prepare(int override_initial_ff_chans_n,
42 42 int override_initial_ff_rate, int override_initial_ff_rate,
43 43 enum avutil_audio_fr_fmt_t override_initial_ff_fmt); enum avutil_audio_fr_fmt_t override_initial_ff_fmt);
44 STATIC void pcm2ff_strict(snd_pcm_t *pcm, int *ff_chans_n,
45 uint64_t *ff_chans_layout, int *ff_rate,
46 enum avutil_audio_fr_fmt_t *ff_fmt, bool print_info);
47 44 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
48 45 #define CLEANUP #define CLEANUP
49 46 #include "npv/namespace/ffmpeg.h" #include "npv/namespace/ffmpeg.h"
File npv/audio/public/code.frag.c changed (mode: 100644) (index 9ac9f70..8a2da33)
... ... STATIC void npv_audio_prepare(int override_initial_ff_chans_n,
397 397 #undef RATE_NOT_OVERRIDDEN #undef RATE_NOT_OVERRIDDEN
398 398 #undef AUDIO_FR_FMT_NOT_OVERRIDDEN #undef AUDIO_FR_FMT_NOT_OVERRIDDEN
399 399 #undef PRINT_INFO #undef PRINT_INFO
400 STATIC void pcm2ff_strict(snd_pcm_t *pcm, int *ff_chans_n,
401 uint64_t *ff_chans_layout, int *ff_rate,
402 enum avutil_audio_fr_fmt_t *ff_fmt, bool print_info)
403 {
404 int r;
405 snd_pcm_hw_params_t *hw_params;
406 unsigned int pcm_chans_n;
407 unsigned int pcm_rate;
408 snd_pcm_fmt_t pcm_fmt;
409 snd_pcm_access_t pcm_access;
410
411 r = snd_pcm_hw_params_malloc(&hw_params);
412 if (r < 0)
413 fatal("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n");
414 r = snd_pcm_hw_params_current(pcm, hw_params);
415 if (r != 0)
416 fatal("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n");
417 r = snd_pcm_hw_params_get_access(hw_params, &pcm_access);
418 if (r < 0)
419 fatal("alsa:unable to get the pcm access for ffmpeg filter wiring\n");
420 r = snd_pcm_hw_params_get_fmt(hw_params, &pcm_fmt);
421 if (r < 0)
422 fatal("alsa:unable to get the pcm format for ffmpeg filter wiring\n");
423 /*--------------------------------------------------------------------*/
424 pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info);
425 /*--------------------------------------------------------------------*/
426 r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate,
427 SND_PCM_ST_PLAYBACK);
428 if (r < 0)
429 fatal("alsa:unable to get the pcm rate for ffmpeg filter wiring\n");
430 *ff_rate = (int)pcm_rate;
431 r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n);
432 if (r < 0)
433 fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n");
434 *ff_chans_n = (int)pcm_chans_n;
435 /*--------------------------------------------------------------------*/
436 *ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n,
437 print_info);
438 /*--------------------------------------------------------------------*/
439 snd_pcm_hw_params_free(hw_params);
440 }
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