X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mp3_afh.c;h=4eaad087f1405d3b7ee85d8ec4121c0cac15bf21;hp=691f1f093c302320b8877cf6588fdec246bb6c51;hb=02d14b8dab5d70d73402fb12a6bd642f70287b52;hpb=4cfbdce5e460934d4724cac63aa718ea6c7af199 diff --git a/mp3_afh.c b/mp3_afh.c index 691f1f09..4eaad087 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -252,7 +252,7 @@ static int get_header(FILE *file, struct mp3header *header) */ static int mp3_seek_next_header(void) { - int k, l = 0, c, first_len; + int k, l = 0, c, first_len, ret; struct mp3header h, h2; long valid_start = 0; @@ -266,17 +266,22 @@ static int mp3_seek_next_header(void) first_len = get_header(infile, &h); if (first_len <= 0) continue; - if (fseek(infile, first_len - FRAME_HEADER_SIZE, SEEK_CUR) < 0) - return -E_FSEEK; + ret = para_fseek(infile, first_len - FRAME_HEADER_SIZE, SEEK_CUR); + if (ret < 0) + return ret; for (k = 1; k < MIN_CONSEC_GOOD_FRAMES; k++) { if ((l = get_header(infile, &h2)) <= 0) break; if (!compare_headers(&h, &h2)) break; - fseek(infile, l - FRAME_HEADER_SIZE, SEEK_CUR); + ret = para_fseek(infile, l - FRAME_HEADER_SIZE, SEEK_CUR); + if (ret < 0) + return ret; } if (k == MIN_CONSEC_GOOD_FRAMES) { - fseek(infile, valid_start, SEEK_SET); + ret = para_fseek(infile, valid_start, SEEK_SET); + if (ret < 0) + return ret; memcpy(&(mp3.header), &h2, sizeof(struct mp3header)); return first_len; } @@ -286,6 +291,7 @@ static int mp3_seek_next_header(void) static int mp3_get_id3(void) { char fbuf[4]; + int ret; mp3.id3_isvalid = 0; mp3.id3.title[0] = '\0'; @@ -293,8 +299,9 @@ static int mp3_get_id3(void) mp3.id3.album[0] = '\0'; mp3.id3.comment[0] = '\0'; mp3.id3.year[0] = '\0'; - if (fseek(infile, -128, SEEK_END)) - return -E_FSEEK; + ret = para_fseek(infile, -128, SEEK_END); + if (ret < 0 ) + return ret; if (para_fread(fbuf, 1, 3, infile) < 0) return -E_FREAD; fbuf[3] = '\0'; @@ -302,8 +309,9 @@ static int mp3_get_id3(void) PARA_INFO_LOG("%s", "no id3 tag\n"); return 0; } - if (fseek(infile, -125, SEEK_END) < 0) - return -E_FSEEK; + ret = para_fseek(infile, -125, SEEK_END); + if (ret < 0) + return ret; if (para_fread(mp3.id3.title, 1, 30, infile) != 30) return -E_FREAD; mp3.id3.title[30] = '\0'; @@ -330,7 +338,7 @@ static int mp3_get_id3(void) static int find_valid_start(void) { - int frame_len; + int ret, frame_len; if (!infile) return -E_MP3_NO_FILE; @@ -341,9 +349,11 @@ static int find_valid_start(void) frame_len = mp3_seek_next_header(); if (frame_len <= 0) return frame_len; - } else - if (fseek(infile, -FRAME_HEADER_SIZE, SEEK_CUR) < 0) - return -E_FSEEK; + } else { + ret = para_fseek(infile, -FRAME_HEADER_SIZE, SEEK_CUR); + if (ret < 0) + return ret; + } if (frame_len <= 1) return -E_FRAME_LENGTH; return frame_len; @@ -370,8 +380,8 @@ static int mp3_read_info(void) int freq, br, fl; struct timeval tmp, cct; /* current chunk time */ if (len > 0) { - ret = -E_FSEEK; - if (fseek(infile, len, SEEK_CUR) < 0) + ret = para_fseek(infile, len, SEEK_CUR); + if (ret < 0) goto err_out; } len = find_valid_start(); @@ -417,8 +427,8 @@ static int mp3_read_info(void) ret = -E_MP3_INFO; if (!num_chunks || !freq_avg || !br_avg) goto err_out; - ret = -E_FSEEK; - if (fseek(infile, 0, SEEK_END) < 0) + ret= para_fseek(infile, 0, SEEK_END); + if (ret < 0) goto err_out; chunk_table[num_chunks] = ftell(infile); mp3.br_average = br_avg;