summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-08-08 16:49:16 -0400
committerSolomon Peachy <pizza@shaftnet.org>2019-08-13 17:07:07 +0200
commit22c63269749aa6471235f9547e53bc9d6f8ce41b (patch)
tree124f52e0a3341a88b44ac7bc6c4ca6731f49f1a7 /apps
parentc46147c6b2a70068e71f4baa34e4ca0892ca4f92 (diff)
downloadrockbox-22c63269749aa6471235f9547e53bc9d6f8ce41b.tar.gz
rockbox-22c63269749aa6471235f9547e53bc9d6f8ce41b.zip
Improvements for vbrfix plugin:
* Properly account for ID3v1 tags * Play time computation fixes * Add speech feedback Patch by Igor Poretsky Change-Id: Ia6df8fb171882a88527cfa9d3b76b705f09becdd
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/plugins/vbrfix.c22
2 files changed, 43 insertions, 7 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 23b5fa62a1..5b04b13bfa 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -16390,3 +16390,31 @@ id: VOICE_BAT_BENCH_KEYS
16390 lcd_bitmap: "Error writing config" 16390 lcd_bitmap: "Error writing config"
16391 </voice> 16391 </voice>
16392</phrase> 16392</phrase>
16393<phrase>
16394 id: LANG_NOT_A_VBR_FILE
16395 desc: in vbrfix plugin
16396 user: core
16397 <source>
16398 *: "Not a VBR file"
16399 </source>
16400 <dest>
16401 *: "Not a VBR file"
16402 </dest>
16403 <voice>
16404 *: "Not a VBR file"
16405 </voice>
16406</phrase>
16407<phrase>
16408 id: LANG_FILE_ERROR
16409 desc: in vbrfix plugin
16410 user: core
16411 <source>
16412 *: "File error: %d"
16413 </source>
16414 <dest>
16415 *: "File error: %d"
16416 </dest>
16417 <voice>
16418 *: "File error"
16419 </voice>
16420</phrase>
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index af7b817002..768ec9d99f 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -26,11 +26,21 @@ static char *audiobuf;
26static size_t audiobuflen; 26static size_t audiobuflen;
27unsigned char xingbuf[1500]; 27unsigned char xingbuf[1500];
28char tmpname[MAX_PATH]; 28char tmpname[MAX_PATH];
29static long last_talk = 0;
29 30
30static void xingupdate(int percent) 31static void xingupdate(int percent)
31{ 32{
32 rb->lcd_putsf(0, 1, "%d%%", percent); 33 rb->lcd_putsf(0, 1, "%d%%", percent);
33 rb->lcd_update(); 34 rb->lcd_update();
35 if (rb->global_settings->talk_menu)
36 {
37 long now = *(rb->current_tick) / HZ;
38 if (now - last_talk >= 5)
39 {
40 rb->talk_value(percent, UNIT_PERCENT, false);
41 last_talk = now;
42 }
43 }
34} 44}
35 45
36static int insert_data_in_file(const char *fname, int fpos, char *buf, int num_bytes) 46static int insert_data_in_file(const char *fname, int fpos, char *buf, int num_bytes)
@@ -114,7 +124,7 @@ static int insert_data_in_file(const char *fname, int fpos, char *buf, int num_b
114 124
115static void fileerror(int rc) 125static void fileerror(int rc)
116{ 126{
117 rb->splashf(HZ*2, "File error: %d", rc); 127 rb->splashf(HZ*2, ID2P(LANG_FILE_ERROR), rc);
118} 128}
119 129
120static const unsigned char empty_id3_header[] = 130static const unsigned char empty_id3_header[] =
@@ -128,7 +138,6 @@ static bool vbr_fix(const char *selected_file)
128 struct mp3entry entry; 138 struct mp3entry entry;
129 int fd; 139 int fd;
130 int rc; 140 int rc;
131 int flen;
132 int num_frames; 141 int num_frames;
133 int numbytes; 142 int numbytes;
134 int framelen; 143 int framelen;
@@ -152,18 +161,16 @@ static bool vbr_fix(const char *selected_file)
152 return true; 161 return true;
153 } 162 }
154 163
155 flen = rb->lseek(fd, 0, SEEK_END);
156
157 xingupdate(0); 164 xingupdate(0);
158 165
159 num_frames = rb->count_mp3_frames(fd, entry.first_frame_offset, 166 num_frames = rb->count_mp3_frames(fd, entry.first_frame_offset,
160 flen, xingupdate, audiobuf, audiobuflen); 167 entry.filesize, xingupdate, audiobuf, audiobuflen);
161 168
162 if(num_frames) { 169 if(num_frames) {
163 /* Note: We don't need to pass a template header because it will be 170 /* Note: We don't need to pass a template header because it will be
164 taken from the mpeg stream */ 171 taken from the mpeg stream */
165 framelen = rb->create_xing_header(fd, entry.first_frame_offset, 172 framelen = rb->create_xing_header(fd, entry.first_frame_offset,
166 flen, xingbuf, num_frames, 0, 173 entry.filesize, xingbuf, num_frames, 0,
167 0, xingupdate, true, 174 0, xingupdate, true,
168 audiobuf, audiobuflen); 175 audiobuf, audiobuflen);
169 176
@@ -253,7 +260,7 @@ static bool vbr_fix(const char *selected_file)
253 { 260 {
254 /* Not a VBR file */ 261 /* Not a VBR file */
255 DEBUGF("Not a VBR file\n"); 262 DEBUGF("Not a VBR file\n");
256 rb->splash(HZ*2, "Not a VBR file"); 263 rb->splash(HZ*2, ID2P(LANG_NOT_A_VBR_FILE));
257 } 264 }
258 265
259 return false; 266 return false;
@@ -261,6 +268,7 @@ static bool vbr_fix(const char *selected_file)
261 268
262enum plugin_status plugin_start(const void *parameter) 269enum plugin_status plugin_start(const void *parameter)
263{ 270{
271 last_talk = *(rb->current_tick) / HZ;
264 272
265 if (!parameter) 273 if (!parameter)
266 return PLUGIN_ERROR; 274 return PLUGIN_ERROR;