summaryrefslogtreecommitdiff
path: root/apps/plugins/vbrfix.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/vbrfix.c')
-rw-r--r--apps/plugins/vbrfix.c22
1 files changed, 15 insertions, 7 deletions
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;