summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch')
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch146
1 files changed, 146 insertions, 0 deletions
diff --git a/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch b/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch
new file mode 100755
index 00000000..7d8492b7
--- /dev/null
+++ b/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch
@@ -0,0 +1,146 @@
1From 6f778c21ee357a662cdd758cff578a3e4b85eedf Mon Sep 17 00:00:00 2001
2From: Zhang Peng <peng.zhang_8@nxp.com>
3Date: Tue, 4 Aug 2020 15:29:29 +0800
4Subject: [PATCH] cplay: Add pause feature
5
6Add option: -p pause
7
8Upstream-Status: Inappropriate [i.MX specific]
9Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
10---
11 src/utils/cplay.c | 56 +++++++++++++++++++++++++++++++++++++++++++----
12 1 file changed, 52 insertions(+), 4 deletions(-)
13
14diff --git a/src/utils/cplay.c b/src/utils/cplay.c
15index 8882f4d..8e3dcbb 100644
16--- a/src/utils/cplay.c
17+++ b/src/utils/cplay.c
18@@ -117,6 +117,9 @@ static void usage(void)
19 "-f\tfragments\n\n"
20 "-v\tverbose mode\n"
21 "-h\tPrints this help list\n\n"
22+ "-p\tpause\n"
23+ "-m\tpause blocks\n"
24+ "-n\tpause time duration\n"
25 "Example:\n"
26 "\tcplay -c 1 -d 2 test.mp3\n"
27 "\tcplay -f 5 test.mp3\n\n"
28@@ -133,7 +136,8 @@ static void usage(void)
29
30 void play_samples(char *name, unsigned int card, unsigned int device,
31 unsigned long buffer_size, unsigned int frag,
32- unsigned long codec_id);
33+ unsigned long codec_id, int pause_count, int pause_block,
34+ int pause_duration);
35
36 struct mp3_header {
37 uint16_t sync;
38@@ -262,12 +266,15 @@ int main(int argc, char **argv)
39 int c, i;
40 unsigned int card = 0, device = 0, frag = 0;
41 unsigned int codec_id = SND_AUDIOCODEC_MP3;
42+ int pause_count = 0;
43+ int pause_block = 6;
44+ int pause_duration = 10;
45
46 if (argc < 2)
47 usage();
48
49 verbose = 0;
50- while ((c = getopt(argc, argv, "hvb:f:c:d:I:")) != -1) {
51+ while ((c = getopt(argc, argv, "hvb:f:c:d:I:p:m:n:")) != -1) {
52 switch (c) {
53 case 'h':
54 usage();
55@@ -306,6 +313,23 @@ int main(int argc, char **argv)
56 case 'v':
57 verbose = 1;
58 break;
59+ case 'p':
60+ pause_count = strtol(optarg, NULL, 10);
61+ break;
62+ case 'm':
63+ pause_block = strtol(optarg, NULL, 10);
64+ if (pause_duration < 0) {
65+ printf("Set wrong paramter! Set duration default 6.\n");
66+ pause_duration = 6;
67+ }
68+ break;
69+ case 'n':
70+ pause_duration = strtol(optarg, NULL, 10);
71+ if (pause_duration < 0) {
72+ printf("Set wrong paramter! Set duration default 10.\n");
73+ pause_duration = 10;
74+ }
75+ break;
76 default:
77 exit(EXIT_FAILURE);
78 }
79@@ -315,7 +339,7 @@ int main(int argc, char **argv)
80
81 file = argv[optind];
82
83- play_samples(file, card, device, buffer_size, frag, codec_id);
84+ play_samples(file, card, device, buffer_size, frag, codec_id, pause_count, pause_block, pause_duration);
85
86 fprintf(stderr, "Finish Playing.... Close Normally\n");
87 exit(EXIT_SUCCESS);
88@@ -491,7 +515,8 @@ void get_codec_pcm(FILE *file, struct compr_config *config,
89
90 void play_samples(char *name, unsigned int card, unsigned int device,
91 unsigned long buffer_size, unsigned int frag,
92- unsigned long codec_id)
93+ unsigned long codec_id, int pause_count, int pause_block,
94+ int pause_duration)
95 {
96 struct compr_config config;
97 struct snd_codec codec;
98@@ -499,6 +524,7 @@ void play_samples(char *name, unsigned int card, unsigned int device,
99 FILE *file;
100 char *buffer;
101 int size, num_read, wrote;
102+ int write_count = 0;
103
104 if (verbose)
105 printf("%s: entry\n", __func__);
106@@ -574,6 +600,13 @@ void play_samples(char *name, unsigned int card, unsigned int device,
107 if (verbose)
108 printf("%s: You should hear audio NOW!!!\n", __func__);
109
110+ if (pause_count > 0) {
111+ printf("sleep...\n");
112+ compress_pause(compress);
113+ sleep(pause_duration);
114+ compress_resume(compress);
115+ }
116+
117 do {
118 num_read = fread(buffer, 1, size, file);
119 if (num_read > 0) {
120@@ -592,8 +625,23 @@ void play_samples(char *name, unsigned int card, unsigned int device,
121 printf("%s: wrote %d\n", __func__, wrote);
122 }
123 }
124+ write_count++;
125+ if ((pause_count > 0) && (write_count % pause_block == 0)) {
126+ printf("pause...\n");
127+ compress_pause(compress);
128+ sleep(pause_duration);
129+ printf("pause release...\n");
130+ compress_resume(compress);
131+ pause_count--;
132+ }
133 } while (num_read > 0);
134
135+ if (pause_count > 0) {
136+ compress_pause(compress);
137+ sleep(5);
138+ compress_resume(compress);
139+ }
140+
141 if (verbose)
142 printf("%s: exit success\n", __func__);
143 /* issue drain if it supports */
144--
1452.17.1
146