Changeset 487 for libmpc/trunk/mpcchap/mpcchap.c
- Timestamp:
- 01/10/16 22:36:06 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcchap/mpcchap.c
r429 r487 23 23 #include "iniparser.h" 24 24 25 #include <inttypes.h> 25 26 #include <sys/stat.h> 26 27 … … 83 84 char * tmp_buff; 84 85 dictionary * dict; 86 mpc_status ret = MPC_STATUS_OK; 85 87 86 88 chap_pos = (demux->chap_pos >> 3) + si->header_position; … … 90 92 stat(mpc_file, &stbuf); 91 93 tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size); 94 92 95 in_file = fopen( mpc_file, "r+b" ); 93 96 fseek(in_file, chap_pos + chap_size, SEEK_SET); 94 fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file); 97 if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) { 98 ret = MPC_STATUS_FAIL; 99 goto error_read_in_file; 100 } 95 101 fseek(in_file, chap_pos, SEEK_SET); 96 102 … … 105 111 106 112 if (chap_pos > si->samples - si->beg_silence) 107 fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",108 113 fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n", 114 i + 1, chap_pos, si->samples - si->beg_silence); 109 115 110 116 Init_Tags(); … … 142 148 143 149 fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file); 144 ftruncate(fileno(in_file), ftell(in_file)); 145 146 fclose(in_file); 147 free(tmp_buff); 148 iniparser_freedict(dict); 149 150 return MPC_STATUS_OK; 150 if (0 != ftruncate(fileno(in_file), ftell(in_file))) 151 ret = MPC_STATUS_FAIL; 152 153 iniparser_freedict(dict); 154 error_read_in_file: 155 fclose(in_file); 156 free(tmp_buff); 157 158 return ret; 151 159 } 152 160 … … 159 167 int chap_pos, end_pos, chap_size, i; 160 168 char * tmp_buff; 169 mpc_status ret = MPC_STATUS_OK; 161 170 162 171 if (0 == (cd = cf_parse(chap_file, &format))) { … … 173 182 in_file = fopen( mpc_file, "r+b" ); 174 183 fseek(in_file, chap_pos + chap_size, SEEK_SET); 175 fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file); 184 if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) { 185 ret = MPC_STATUS_FAIL; 186 goto error_read_in_file; 187 } 176 188 fseek(in_file, chap_pos, SEEK_SET); 177 189 … … 191 203 192 204 if (chap_pos > si->samples - si->beg_silence) 193 fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",205 fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n", 194 206 i, chap_pos, si->samples - si->beg_silence); 195 207 … … 225 237 226 238 fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file); 227 ftruncate(fileno(in_file), ftell(in_file)); 228 239 if (0 != ftruncate(fileno(in_file), ftell(in_file))) 240 ret = MPC_STATUS_FAIL; 241 242 error_read_in_file: 229 243 fclose(in_file); 230 244 free(tmp_buff); 231 245 232 return MPC_STATUS_OK;246 return ret; 233 247 } 234 248 … … 248 262 for (i = 0; i < chap_nb; i++) { 249 263 chap = mpc_demux_chap(demux, i); 250 fprintf(out_file, "[%lli]\ngain=%i\npeak=%i\n", chap->sample, chap->gain, chap->peak);264 fprintf(out_file, "[%" PRId64 "]\ngain=%i\npeak=%i\n", chap->sample, chap->gain, chap->peak); 251 265 if (chap->tag_size > 0) { 252 266 int item_count, j;
Note: See TracChangeset
for help on using the changeset viewer.