annotate stream/stream_cue.c @ 30760:937621eaa290

Avoid code duplication and excessively deep nesting in cue_find_bin
author reimar
date Mon, 01 Mar 2010 19:20:32 +0000
parents 76a6338e5e71
children b41ac9f6e26f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30426
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
1 /*
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
2 * VideoCD BinCue
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
3 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
4 * This file is part of MPlayer.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
5 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
7 * it under the terms of the GNU General Public License as published by
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
9 * (at your option) any later version.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
10 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
14 * GNU General Public License for more details.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
15 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
16 * You should have received a copy of the GNU General Public License along
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
19 */
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
20
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
21 #include <stdio.h>
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
22 #include <stdlib.h>
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
23 #include <string.h>
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
24
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
25 #include <sys/types.h>
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
26 #include <sys/stat.h>
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
27 #include <unistd.h>
8812
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
28 #include <fcntl.h>
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
29
8812
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
30 #include "config.h"
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
31 #include "mp_msg.h"
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
32 #include "help_mp.h"
8812
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
33
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
34 #include "stream.h"
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
35
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
36 #include "help_mp.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16967
diff changeset
37 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16967
diff changeset
38 #include "m_struct.h"
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 19298
diff changeset
39 #include "libavutil/avstring.h"
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
40
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
41 #define byte unsigned char
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
42 #define SIZERAW 2352
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
43 #define SIZEISO_MODE1 2048
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
44 #define SIZEISO_MODE2_RAW 2352
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
45 #define SIZEISO_MODE2_FORM1 2048
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
46 #define SIZEISO_MODE2_FORM2 2336
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
47 #define AUDIO 0
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
48 #define MODE1 1
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
49 #define MODE2 2
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
50 #define MODE1_2352 10
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
51 #define MODE2_2352 20
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
52 #define MODE1_2048 30
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
53 #define MODE2_2336 40
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
54 #define UNKNOWN -1
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
55
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
56 static struct stream_priv_s {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
57 char* filename;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
58 } stream_priv_dflts = {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
59 NULL
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
60 };
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
61
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
62 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
63 /// URL definition
25242
371a40dcc1cc stream_opts arrays should be const
reimar
parents: 25211
diff changeset
64 static const m_option_t stream_opts_fields[] = {
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
65 { "string", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL},
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
66 { NULL, NULL, 0, 0, 0, 0, NULL }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
67 };
25691
68015115f63a stream_opts should be const
reimar
parents: 25242
diff changeset
68 static const struct m_struct_st stream_opts = {
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
69 "cue",
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
70 sizeof(struct stream_priv_s),
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
71 &stream_priv_dflts,
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
72 stream_opts_fields
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
73 };
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
74
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
75 static FILE* fd_cue;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
76 static int fd_bin = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
77
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
78 static char bin_filename[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
79
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
80 static char cue_filename[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
81 static char bincue_path[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
82
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
83
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
84 typedef struct track
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
85 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
86 unsigned short mode;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
87 unsigned short minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
88 unsigned short second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
89 unsigned short frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
90
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
91 /* (min*60 + sec) * 75 + fps */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
92
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
93 unsigned long start_sector;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
94
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
95 /* = the sizes in bytes off all tracks bevor this one */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
96 /* its needed if there are mode1 tracks befor the mpeg tracks */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
97 unsigned long start_offset;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
98
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
99 /* unsigned char num[3]; */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
100 } tTrack;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
101
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
102 /* max 99 tracks on a cd */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
103 static tTrack tracks[100];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
104
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
105 static struct cue_track_pos {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
106 int track;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
107 unsigned short mode;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
108 unsigned short minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
109 unsigned short second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
110 unsigned short frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
111 } cue_current_pos;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
112
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
113 /* number of tracks on the cd */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
114 static int nTracks = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
115
25704
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
116 static int digits2int(char s[2], int errval) {
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
117 uint8_t a = s[0] - '0';
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
118 uint8_t b = s[1] - '0';
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
119 if (a > 9 || b > 9)
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
120 return errval;
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
121 return a * 10 + b;
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
122 }
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
123
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
124 /* presumes Line is preloaded with the "current" line of the file */
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
125 static int cue_getTrackinfo(char *Line, tTrack *track)
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
126 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
127 int already_set = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
128
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
129 /* Get the 'mode' */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
130 if (strncmp(&Line[2], "TRACK ", 6)==0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
131 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
132 /* strncpy(track->num, &Line[8], 2); track->num[2] = '\0'; */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
133
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
134 track->mode = UNKNOWN;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
135 if(strncmp(&Line[11], "AUDIO", 5)==0) track->mode = AUDIO;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
136 if(strncmp(&Line[11], "MODE1/2352", 10)==0) track->mode = MODE1_2352;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
137 if(strncmp(&Line[11], "MODE1/2048", 10)==0) track->mode = MODE1_2048;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
138 if(strncmp(&Line[11], "MODE2/2352", 10)==0) track->mode = MODE2_2352;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
139 if(strncmp(&Line[11], "MODE2/2336", 10)==0) track->mode = MODE2_2336;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
140 }
26756
c43ce7268677 cosmetics: Remove useless parentheses from return statements.
diego
parents: 25704
diff changeset
141 else return 1;
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
142
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
143 /* Get the track indexes */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
144 while(1) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
145 if(! fgets( Line, 256, fd_cue ) ) { break;}
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
146
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
147 if (strncmp(&Line[2], "TRACK ", 6)==0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
148 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
149 /* next track starting */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
150 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
151 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
152
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
153 /* Track 0 or 1, take the first an get fill the values*/
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
154 if (strncmp(&Line[4], "INDEX ", 6)==0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
155 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
156 /* check stuff here so if the answer is false the else stuff below won't be executed */
25704
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
157 if ((already_set == 0) && digits2int(Line + 10, 100) <= 1)
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
158 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
159 already_set = 1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
160
25704
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
161 track->minute = digits2int(Line + 13, 0);
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
162 track->second = digits2int(Line + 16, 0);
1977ed7f06d4 Simplify cue-parsing
reimar
parents: 25703
diff changeset
163 track->frame = digits2int(Line + 19, 0);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
164 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
165 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
166 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
167 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
168 else mp_msg (MSGT_OPEN,MSGL_INFO,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
169 MSGTR_MPDEMUX_CUEREAD_UnexpectedCuefileLine, Line);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
170 }
26756
c43ce7268677 cosmetics: Remove useless parentheses from return statements.
diego
parents: 25704
diff changeset
171 return 0;
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
172 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
173
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
174
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
175
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
176 /* FIXME: the string operations ( strcpy,strcat ) below depend
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
177 * on the arrays to have the same size, thus we need to make
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
178 * sure the sizes are in sync.
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
179 */
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
180 static int cue_find_bin (char *firstline) {
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
181 const char *cur_name;
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
182 int i,j;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
183 char s[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
184 char t[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
185
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
186 /* get the filename out of that */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
187 /* 12345 6 */
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
188 mp_msg (MSGT_OPEN,MSGL_INFO, "[bincue] cue_find_bin(%s)\n", firstline);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
189 if (strncmp(firstline, "FILE \"",6)==0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
190 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
191 i = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
192 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
193 while ( firstline[6 + i] != '"')
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
194 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
195 bin_filename[j] = firstline[6 + i];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
196
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
197 /* if I found a path info, than delete all bevor it */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
198 switch (bin_filename[j])
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
199 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
200 case '\\':
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
201 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
202 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
203
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
204 case '/':
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
205 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
206 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
207
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
208 default:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
209 j++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
210 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
211 i++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
212 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
213 bin_filename[j+1] = '\0';
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
214
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
215 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
216
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
217 fd_bin = -1;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
218 for (i = 0; fd_bin == -1 && i < 6; i++) {
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
219 switch (i) {
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
220 case 0:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
221 /* now try to open that file, without path */
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
222 cur_name = bin_filename;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
223 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
224 case 1:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
225 /* now try to find it with the path of the cue file */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
226 snprintf(s,sizeof( s ),"%s/%s",bincue_path,bin_filename);
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
227 cur_name = s;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
228 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
229 case 2:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
230 /* now I would say the whole filename is shit, build our own */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
231 strncpy(s, cue_filename, strlen(cue_filename) - 3 );
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
232 s[strlen(cue_filename) - 3] = '\0';
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
233 strcat(s, "bin");
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
234 cur_name = s;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
235 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
236 case 3:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
237 /* ok try it with path */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
238 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
239 fd_bin = open (t, O_RDONLY);
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
240 cur_name = t;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
241 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
242 case 4:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
243 /* now I would say the whole filename is shit, build our own */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
244 strncpy(s, cue_filename, strlen(cue_filename) - 3 );
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
245 s[strlen(cue_filename) - 3] = '\0';
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
246 strcat(s, "img");
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
247 cur_name = s;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
248 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
249 case 5:
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
250 /* ok try it with path */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
251 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s);
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
252 cur_name = t;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
253 break;
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
254 }
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
255 fd_bin = open(cur_name, O_RDONLY);
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
256 if (fd_bin == -1) {
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
257 mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
258 cur_name);
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
259 }
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
260 }
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
261
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
262 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
263 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
264 /* I'll give up */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
265 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
266 MSGTR_MPDEMUX_CUEREAD_CannotFindBinFile);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
267 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
268 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
269
30760
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
270 if (cur_name != bin_filename)
937621eaa290 Avoid code duplication and excessively deep nesting in cue_find_bin
reimar
parents: 30759
diff changeset
271 strcpy(bin_filename, cur_name);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
272
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
273 mp_msg(MSGT_OPEN,MSGL_INFO,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
274 MSGTR_MPDEMUX_CUEREAD_UsingBinFile, bin_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
275 return 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
276 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
277
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
278 static inline int cue_msf_2_sector(int minute, int second, int frame) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
279 return frame + (second + minute * 60 ) * 75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
280 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
281
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
282 static inline int cue_get_msf(void) {
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
283 return cue_msf_2_sector (cue_current_pos.minute,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
284 cue_current_pos.second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
285 cue_current_pos.frame);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
286 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
287
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
288 static inline void cue_set_msf(unsigned int sect){
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
289 cue_current_pos.frame=sect%75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
290 sect=sect/75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
291 cue_current_pos.second=sect%60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
292 sect=sect/60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
293 cue_current_pos.minute=sect;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
294 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
295
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
296 static inline int cue_mode_2_sector_size(int mode)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
297 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
298 switch (mode)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
299 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
300 case AUDIO: return AUDIO;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
301 case MODE1_2352: return SIZERAW;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
302 case MODE1_2048: return SIZEISO_MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
303 case MODE2_2352: return SIZEISO_MODE2_RAW;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
304 case MODE2_2336: return SIZEISO_MODE2_FORM2;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
305
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
306 default:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
307 mp_msg(MSGT_OPEN,MSGL_FATAL,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
308 MSGTR_MPDEMUX_CUEREAD_UnknownModeForBinfile);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
309 abort();
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
310 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
311
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
312 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
313
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
314
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
315 static int cue_read_cue (char *in_cue_filename)
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
316 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
317 struct stat filestat;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
318 char sLine[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
319 unsigned int sect;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
320 char *s,*t;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
321 int i;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
322
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
323 /* we have no tracks at the beginning */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
324 nTracks = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
325
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
326 fd_bin = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
327
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
328 /* split the filename into a path and filename part */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
329 s = strdup(in_cue_filename);
8815
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
330 t = strrchr(s, '/');
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
331 if (t == (char *)NULL)
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
332 t = ".";
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
333 else {
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
334 *t = '\0';
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
335 t = s;
8817
84522accebc0 10l, hopefully correct fix, before path was always overwritten to '/'
atmos4
parents: 8815
diff changeset
336 if (*t == '\0')
8815
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
337 strcpy(t, "/");
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
338 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
339
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 19298
diff changeset
340 av_strlcpy(bincue_path,t,sizeof( bincue_path ));
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
341 mp_msg(MSGT_OPEN,MSGL_V,"dirname: %s, cuepath: %s\n", t, bincue_path);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
342
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
343 /* no path at all? */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
344 if (strcmp(bincue_path, ".") == 0) {
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
345 mp_msg(MSGT_OPEN,MSGL_V,"bincue_path: %s\n", bincue_path);
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 19298
diff changeset
346 av_strlcpy(cue_filename,in_cue_filename,sizeof( cue_filename ));
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
347 } else {
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 19298
diff changeset
348 av_strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1,
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
349 sizeof( cue_filename ));
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
350 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
351
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
352
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
353
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
354 /* open the cue file */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
355 fd_cue = fopen (in_cue_filename, "r");
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
356 if (fd_cue == NULL)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
357 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
358 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
359 MSGTR_MPDEMUX_CUEREAD_CannotOpenCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
360 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
361 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
362
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
363 /* read the first line and hand it to find_bin, which will
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
364 test more than one possible name of the file */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
365
30759
76a6338e5e71 Use sizeof instead of hardcoded size.
reimar
parents: 30633
diff changeset
366 if(! fgets( sLine, sizeof(sLine), fd_cue ) )
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
367 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
368 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
369 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
370 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
371 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
372 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
373
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
374 if (cue_find_bin(sLine)) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
375 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
376 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
377 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
378
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
379
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
380 /* now build the track list */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
381 /* red the next line and call our track finder */
30759
76a6338e5e71 Use sizeof instead of hardcoded size.
reimar
parents: 30633
diff changeset
382 if(! fgets( sLine, sizeof(sLine), fd_cue ) )
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
383 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
384 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
385 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
386 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
387 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
388 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
389
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
390 while(!feof(fd_cue))
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
391 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
392 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
393 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
394 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
395 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
396 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
397 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
398 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
399 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
400
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
401 /* make a fake track with stands for the Lead out */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
402 if (fstat (fd_bin, &filestat) == -1) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
403 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
404 MSGTR_MPDEMUX_CUEREAD_ErrGettingBinFileSize);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
405 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
406 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
407 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
408
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
409 sect = filestat.st_size / 2352;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
410
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
411 tracks[nTracks].frame = sect%75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
412 sect=sect/75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
413 tracks[nTracks].second = sect%60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
414 sect=sect/60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
415 tracks[nTracks].minute = sect;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
416
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
417
11000
6e35326c742f many small typo and grammar fixes
gabucino
parents: 8817
diff changeset
418 /* let's calculate the start sectors and offsets */
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
419 for(i = 0; i <= nTracks; i++)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
420 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
421 tracks[i].start_sector = cue_msf_2_sector(tracks[i].minute,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
422 tracks[nTracks].second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
423 tracks[nTracks].frame);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
424
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
425 /* if we're the first track we don't need to offset of the one befor */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
426 if (i == 0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
427 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
428 /* was always 0 on my svcds, but who knows */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
429 tracks[0].start_offset = tracks[0].start_sector *
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
430 cue_mode_2_sector_size(tracks[0].mode);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
431 } else
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
432 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
433 tracks[i].start_offset = tracks[i-1].start_offset +
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
434 (tracks[i].start_sector - tracks[i-1].start_sector) *
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
435 cue_mode_2_sector_size(tracks[i-1].mode);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
436 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
437 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
438
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
439 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
440
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
441 return fd_bin;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
442 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
443
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
444
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
445
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
446
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
447 static int cue_read_toc_entry(void) {
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
448
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
449 int track = cue_current_pos.track - 1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
450
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
451 /* check if its a valid track, if not return -1 */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
452 if (track >= nTracks)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
453 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
454
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
455
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
456 switch (tracks[track].mode)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
457 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
458 case AUDIO:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
459 cue_current_pos.mode = AUDIO;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
460 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
461 case MODE1_2352:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
462 cue_current_pos.mode = MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
463 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
464 case MODE1_2048:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
465 cue_current_pos.mode = MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
466 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
467 default: /* MODE2_2352 and MODE2_2336 */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
468 cue_current_pos.mode = MODE2;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
469 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
470 cue_current_pos.minute = tracks[track].minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
471 cue_current_pos.second = tracks[track].second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
472 cue_current_pos.frame = tracks[track].frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
473
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
474 return 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
475 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
476
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
477 static int cue_vcd_seek_to_track (int track){
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
478 cue_current_pos.track = track;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
479
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
480 if (cue_read_toc_entry ())
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
481 return -1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
482
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
483 return VCD_SECTOR_DATA * cue_get_msf();
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
484 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
485
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
486 static int cue_vcd_get_track_end (int track){
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
487 cue_current_pos.frame = tracks[track].frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
488 cue_current_pos.second = tracks[track].second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
489 cue_current_pos.minute = tracks[track].minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
490
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
491 return VCD_SECTOR_DATA * cue_get_msf();
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
492 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
493
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
494 static void cue_vcd_read_toc(void){
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
495 int i;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
496 for (i = 0; i < nTracks; ++i) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
497
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
498 mp_msg(MSGT_OPEN,MSGL_INFO,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
499 MSGTR_MPDEMUX_CUEREAD_InfoTrackFormat,
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
500 i+1,
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
501 tracks[i].mode,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
502 tracks[i].minute,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
503 tracks[i].second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
504 tracks[i].frame
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
505 );
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
506 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
507 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
508
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
509 static int cue_vcd_read(stream_t *stream, char *mem, int size) {
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
510 unsigned long position;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
511 int track = cue_current_pos.track - 1;
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
512
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
513 position = tracks[track].start_offset +
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
514 (cue_msf_2_sector(cue_current_pos.minute,
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
515 cue_current_pos.second,
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
516 cue_current_pos.frame) -
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
517 tracks[track].start_sector)
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
518 * cue_mode_2_sector_size(tracks[track].mode);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
519
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
520
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
521 if(position >= tracks[track+1].start_offset)
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
522 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
523
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
524 if(lseek(fd_bin, position+VCD_SECTOR_OFFS, SEEK_SET) == -1) {
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
525 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_UnexpectedBinFileEOF);
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
526 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
527 }
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
528
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
529 if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) {
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
530 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_CannotReadNBytesOfPayload, VCD_SECTOR_DATA);
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
531 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
532 }
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
533
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
534 cue_current_pos.frame++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
535 if (cue_current_pos.frame==75){
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
536 cue_current_pos.frame=0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
537 cue_current_pos.second++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
538 if (cue_current_pos.second==60){
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
539 cue_current_pos.second=0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
540 cue_current_pos.minute++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
541 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
542 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
543
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
544 return VCD_SECTOR_DATA;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
545 }
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
546
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
547 static int seek(stream_t *s,off_t newpos) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
548 s->pos=newpos;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
549 cue_set_msf(s->pos/VCD_SECTOR_DATA);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
550 return 1;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
551 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
552
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
553
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
554 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
555 struct stream_priv_s* p = (struct stream_priv_s*)opts;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
556 int ret,ret2,f,track = 0;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
557 char *filename = NULL, *colon = NULL;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
558
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
559 if(mode != STREAM_READ || !p->filename) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
560 m_struct_free(&stream_opts,opts);
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23703
diff changeset
561 return STREAM_UNSUPPORTED;
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
562 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
563 filename = strdup(p->filename);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
564 if(!filename) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
565 m_struct_free(&stream_opts,opts);
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23703
diff changeset
566 return STREAM_UNSUPPORTED;
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
567 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
568 colon = strstr(filename, ":");
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
569 if(colon) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
570 if(strlen(colon)>1)
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
571 track = atoi(colon+1);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
572 *colon = 0;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
573 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
574 if(!track)
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
575 track = 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
576
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
577 f = cue_read_cue(filename);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
578 if(f < 0) {
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
579 m_struct_free(&stream_opts,opts);
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23703
diff changeset
580 return STREAM_UNSUPPORTED;
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
581 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
582 cue_vcd_read_toc();
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
583 ret2=cue_vcd_get_track_end(track);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
584 ret=cue_vcd_seek_to_track(track);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
585 if(ret<0){
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
586 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23703
diff changeset
587 return STREAM_UNSUPPORTED;
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
588 }
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
589 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CUEREAD_CueStreamInfo_FilenameTrackTracksavail, filename, track, ret, ret2);
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
590
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
591 stream->fd = f;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
592 stream->type = STREAMTYPE_VCDBINCUE;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
593 stream->sector_size = VCD_SECTOR_DATA;
29920
4f740437ed2b Finally rename the STREAM_SEEK define to MP_STREAM_SEEK, there are just too many
reimar
parents: 29263
diff changeset
594 stream->flags = STREAM_READ | MP_STREAM_SEEK_FW;
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
595 stream->start_pos = ret;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
596 stream->end_pos = ret2;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
597 stream->fill_buffer = cue_vcd_read;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
598 stream->seek = seek;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
599
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
600 free(filename);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
601 m_struct_free(&stream_opts,opts);
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
602 return STREAM_OK;
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
603 }
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
604
25211
c1d17bd6683c Mark all stream_info_t as const
reimar
parents: 24257
diff changeset
605 const stream_info_t stream_info_cue = {
15476
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
606 "CUE track",
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
607 "cue",
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
608 "Albeu",
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
609 "based on the code from ???",
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
610 open_s,
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
611 { "cue", NULL },
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
612 &stream_opts,
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
613 1 // Urls are an option string
5eb4994a691f ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents: 12646
diff changeset
614 };