comparison libmpdemux/cue_read.c @ 16967:32e2c59c8e86

[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
author reynaldo
date Thu, 10 Nov 2005 21:33:12 +0000
parents c4af653727eb
children 6ff3379a0862
comparison
equal deleted inserted replaced
16966:46490266341d 16967:32e2c59c8e86
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
11 11
12 #include "config.h" 12 #include "config.h"
13 #include "mp_msg.h" 13 #include "mp_msg.h"
14 //#include "help_mp.h" 14 #include "help_mp.h"
15 15
16 #include "stream.h" 16 #include "stream.h"
17 17
18 #include "cue_read.h" 18 #include "cue_read.h"
19 #include "help_mp.h" 19 #include "help_mp.h"
148 } 148 }
149 } 149 }
150 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ } 150 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ }
151 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ } 151 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ }
152 else mp_msg (MSGT_OPEN,MSGL_INFO, 152 else mp_msg (MSGT_OPEN,MSGL_INFO,
153 "[bincue] Unexpected cuefile line: %s\n", Line); 153 MSGTR_MPDEMUX_CUEREAD_UnexpectedCuefileLine, Line);
154 } 154 }
155 return(0); 155 return(0);
156 } 156 }
157 157
158 158
199 199
200 /* now try to open that file, without path */ 200 /* now try to open that file, without path */
201 fd_bin = open (bin_filename, O_RDONLY); 201 fd_bin = open (bin_filename, O_RDONLY);
202 if (fd_bin == -1) 202 if (fd_bin == -1)
203 { 203 {
204 mp_msg(MSGT_OPEN,MSGL_STATUS, "[bincue] bin filename tested: %s\n", 204 mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,
205 bin_filename); 205 bin_filename);
206 206
207 /* now try to find it with the path of the cue file */ 207 /* now try to find it with the path of the cue file */
208 snprintf(s,sizeof( s ),"%s/%s",bincue_path,bin_filename); 208 snprintf(s,sizeof( s ),"%s/%s",bincue_path,bin_filename);
209 fd_bin = open (s, O_RDONLY); 209 fd_bin = open (s, O_RDONLY);
210 if (fd_bin == -1) 210 if (fd_bin == -1)
211 { 211 {
212 mp_msg(MSGT_OPEN,MSGL_STATUS, 212 mp_msg(MSGT_OPEN,MSGL_STATUS,
213 "[bincue] bin filename tested: %s\n", s); 213 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
214 /* now I would say the whole filename is shit, build our own */ 214 /* now I would say the whole filename is shit, build our own */
215 strncpy(s, cue_filename, strlen(cue_filename) - 3 ); 215 strncpy(s, cue_filename, strlen(cue_filename) - 3 );
216 s[strlen(cue_filename) - 3] = '\0'; 216 s[strlen(cue_filename) - 3] = '\0';
217 strcat(s, "bin"); 217 strcat(s, "bin");
218 fd_bin = open (s, O_RDONLY); 218 fd_bin = open (s, O_RDONLY);
219 if (fd_bin == -1) 219 if (fd_bin == -1)
220 { 220 {
221 mp_msg(MSGT_OPEN,MSGL_STATUS, 221 mp_msg(MSGT_OPEN,MSGL_STATUS,
222 "[bincue] bin filename tested: %s\n", s); 222 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
223 223
224 /* ok try it with path */ 224 /* ok try it with path */
225 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s); 225 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
226 fd_bin = open (t, O_RDONLY); 226 fd_bin = open (t, O_RDONLY);
227 if (fd_bin == -1) 227 if (fd_bin == -1)
228 { 228 {
229 mp_msg(MSGT_OPEN,MSGL_STATUS, 229 mp_msg(MSGT_OPEN,MSGL_STATUS,
230 "[bincue] bin filename tested: %s\n",t); 230 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,t);
231 /* now I would say the whole filename is shit, build our own */ 231 /* now I would say the whole filename is shit, build our own */
232 strncpy(s, cue_filename, strlen(cue_filename) - 3 ); 232 strncpy(s, cue_filename, strlen(cue_filename) - 3 );
233 s[strlen(cue_filename) - 3] = '\0'; 233 s[strlen(cue_filename) - 3] = '\0';
234 strcat(s, "img"); 234 strcat(s, "img");
235 fd_bin = open (s, O_RDONLY); 235 fd_bin = open (s, O_RDONLY);
236 if (fd_bin == -1) 236 if (fd_bin == -1)
237 { 237 {
238 mp_msg(MSGT_OPEN,MSGL_STATUS, 238 mp_msg(MSGT_OPEN,MSGL_STATUS,
239 "[bincue] bin filename tested: %s \n", s); 239 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
240 /* ok try it with path */ 240 /* ok try it with path */
241 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s); 241 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
242 fd_bin = open (t, O_RDONLY); 242 fd_bin = open (t, O_RDONLY);
243 if (fd_bin == -1) 243 if (fd_bin == -1)
244 { 244 {
245 mp_msg(MSGT_OPEN,MSGL_STATUS, 245 mp_msg(MSGT_OPEN,MSGL_STATUS,
246 "[bincue] bin filename tested: %s\n", s); 246 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
247 247
248 /* I'll give up */ 248 /* I'll give up */
249 mp_msg(MSGT_OPEN,MSGL_ERR, 249 mp_msg(MSGT_OPEN,MSGL_ERR,
250 "[bincue] couldn't find the bin file - giving up\n"); 250 MSGTR_MPDEMUX_CUEREAD_CannotFindBinFile);
251 return -1; 251 return -1;
252 } 252 }
253 } 253 }
254 } else strcpy(bin_filename, t); 254 } else strcpy(bin_filename, t);
255 255
258 } else strcpy(bin_filename, s); 258 } else strcpy(bin_filename, s);
259 259
260 } 260 }
261 261
262 mp_msg(MSGT_OPEN,MSGL_INFO, 262 mp_msg(MSGT_OPEN,MSGL_INFO,
263 "[bincue] using bin file %s\n", bin_filename); 263 MSGTR_MPDEMUX_CUEREAD_UsingBinFile, bin_filename);
264 return 0; 264 return 0;
265 } 265 }
266 266
267 static inline int cue_msf_2_sector(int minute, int second, int frame) { 267 static inline int cue_msf_2_sector(int minute, int second, int frame) {
268 return frame + (second + minute * 60 ) * 75; 268 return frame + (second + minute * 60 ) * 75;
292 case MODE2_2352: return SIZEISO_MODE2_RAW; 292 case MODE2_2352: return SIZEISO_MODE2_RAW;
293 case MODE2_2336: return SIZEISO_MODE2_FORM2; 293 case MODE2_2336: return SIZEISO_MODE2_FORM2;
294 294
295 default: 295 default:
296 mp_msg(MSGT_OPEN,MSGL_FATAL, 296 mp_msg(MSGT_OPEN,MSGL_FATAL,
297 "[bincue] unknown mode for binfile. should not happen. aborting\n"); 297 MSGTR_MPDEMUX_CUEREAD_UnknownModeForBinfile);
298 abort(); 298 abort();
299 } 299 }
300 300
301 } 301 }
302 302
343 /* open the cue file */ 343 /* open the cue file */
344 fd_cue = fopen (in_cue_filename, "r"); 344 fd_cue = fopen (in_cue_filename, "r");
345 if (fd_cue == NULL) 345 if (fd_cue == NULL)
346 { 346 {
347 mp_msg(MSGT_OPEN,MSGL_ERR, 347 mp_msg(MSGT_OPEN,MSGL_ERR,
348 "[bincue] cannot open %s\n", in_cue_filename); 348 MSGTR_MPDEMUX_CUEREAD_CannotOpenCueFile, in_cue_filename);
349 return -1; 349 return -1;
350 } 350 }
351 351
352 /* read the first line and hand it to find_bin, which will 352 /* read the first line and hand it to find_bin, which will
353 test more than one possible name of the file */ 353 test more than one possible name of the file */
354 354
355 if(! fgets( sLine, 256, fd_cue ) ) 355 if(! fgets( sLine, 256, fd_cue ) )
356 { 356 {
357 mp_msg(MSGT_OPEN,MSGL_ERR, 357 mp_msg(MSGT_OPEN,MSGL_ERR,
358 "[bincue] error reading from %s\n", in_cue_filename); 358 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
359 fclose (fd_cue); 359 fclose (fd_cue);
360 return -1; 360 return -1;
361 } 361 }
362 362
363 if (cue_find_bin(sLine)) { 363 if (cue_find_bin(sLine)) {
369 /* now build the track list */ 369 /* now build the track list */
370 /* red the next line and call our track finder */ 370 /* red the next line and call our track finder */
371 if(! fgets( sLine, 256, fd_cue ) ) 371 if(! fgets( sLine, 256, fd_cue ) )
372 { 372 {
373 mp_msg(MSGT_OPEN,MSGL_ERR, 373 mp_msg(MSGT_OPEN,MSGL_ERR,
374 "[bincue] error reading from %s\n", in_cue_filename); 374 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
375 fclose (fd_cue); 375 fclose (fd_cue);
376 return -1; 376 return -1;
377 } 377 }
378 378
379 while(!feof(fd_cue)) 379 while(!feof(fd_cue))
380 { 380 {
381 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0) 381 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0)
382 { 382 {
383 mp_msg(MSGT_OPEN,MSGL_ERR, 383 mp_msg(MSGT_OPEN,MSGL_ERR,
384 "[bincue] error reading from %s\n", in_cue_filename); 384 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
385 fclose (fd_cue); 385 fclose (fd_cue);
386 return -1; 386 return -1;
387 } 387 }
388 } 388 }
389 389
390 /* make a fake track with stands for the Lead out */ 390 /* make a fake track with stands for the Lead out */
391 if (fstat (fd_bin, &filestat) == -1) { 391 if (fstat (fd_bin, &filestat) == -1) {
392 mp_msg(MSGT_OPEN,MSGL_ERR, 392 mp_msg(MSGT_OPEN,MSGL_ERR,
393 "[bincue] error getting size of bin file\n"); 393 MSGTR_MPDEMUX_CUEREAD_ErrGettingBinFileSize);
394 fclose (fd_cue); 394 fclose (fd_cue);
395 return -1; 395 return -1;
396 } 396 }
397 397
398 sect = filestat.st_size / 2352; 398 sect = filestat.st_size / 2352;
483 static void cue_vcd_read_toc(){ 483 static void cue_vcd_read_toc(){
484 int i; 484 int i;
485 for (i = 0; i < nTracks; ++i) { 485 for (i = 0; i < nTracks; ++i) {
486 486
487 mp_msg(MSGT_OPEN,MSGL_INFO, 487 mp_msg(MSGT_OPEN,MSGL_INFO,
488 "track %02d: format=%d %02d:%02d:%02d\n", 488 MSGTR_MPDEMUX_CUEREAD_InfoTrackFormat,
489 i+1, 489 i+1,
490 tracks[i].mode, 490 tracks[i].mode,
491 tracks[i].minute, 491 tracks[i].minute,
492 tracks[i].second, 492 tracks[i].second,
493 tracks[i].frame 493 tracks[i].frame
509 509
510 if(position >= tracks[track+1].start_offset) 510 if(position >= tracks[track+1].start_offset)
511 return 0; 511 return 0;
512 512
513 if(lseek(fd_bin, position+VCD_SECTOR_OFFS, SEEK_SET) == -1) { 513 if(lseek(fd_bin, position+VCD_SECTOR_OFFS, SEEK_SET) == -1) {
514 mp_msg(MSGT_OPEN,MSGL_ERR, "[bincue] unexpected end of bin file\n"); 514 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_UnexpectedBinFileEOF);
515 return 0; 515 return 0;
516 } 516 }
517 517
518 if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) { 518 if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) {
519 mp_msg(MSGT_OPEN,MSGL_ERR, "[bincue] couldn't read %d bytes of payload\n", VCD_SECTOR_DATA); 519 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_CannotReadNBytesOfPayload, VCD_SECTOR_DATA);
520 return 0; 520 return 0;
521 } 521 }
522 522
523 cue_current_pos.frame++; 523 cue_current_pos.frame++;
524 if (cue_current_pos.frame==75){ 524 if (cue_current_pos.frame==75){
573 ret=cue_vcd_seek_to_track(track); 573 ret=cue_vcd_seek_to_track(track);
574 if(ret<0){ 574 if(ret<0){
575 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n"); 575 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
576 return STREAM_UNSUPORTED; 576 return STREAM_UNSUPORTED;
577 } 577 }
578 mp_msg(MSGT_OPEN,MSGL_INFO,"CUE stream_open, filename=%s, track=%d, available tracks: %d -> %d\n", filename, track, ret, ret2); 578 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CUEREAD_CueStreamInfo_FilenameTrackTracksavail, filename, track, ret, ret2);
579 579
580 stream->fd = f; 580 stream->fd = f;
581 stream->type = STREAMTYPE_VCDBINCUE; 581 stream->type = STREAMTYPE_VCDBINCUE;
582 stream->sector_size = VCD_SECTOR_DATA; 582 stream->sector_size = VCD_SECTOR_DATA;
583 stream->flags = STREAM_READ | STREAM_SEEK_FW; 583 stream->flags = STREAM_READ | STREAM_SEEK_FW;