--- audioio-mp3.cpp Wed Feb 26 18:46:08 2003 +++ audioio-mp3.cpp Wed Sep 3 12:33:17 2003 @@ -261,8 +261,10 @@ if((file = std::fopen(filename, "rb")) == NULL) { return false; } - if (std::fread(tmp, 1, 4, file) != 4) + if (std::fread(tmp, 1, 4, file) != 4) { + ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Failed to read first 4 bytes of file!"); goto done; + } buf = new unsigned char [1024]; head = convert_to_header(tmp); while(!mpg123_head_check(head)) { @@ -285,30 +287,59 @@ if(mpg123_head_check(head)) { std::fseek(file, i+1-in_buf, SEEK_CUR); - break; + if (mpg123_decode_header(frp, head)) + { + /* + * We found something which looks like a MPEG-header. + * We check the next frame too, to be sure + */ + if (std::fseek(file, frp->framesize, SEEK_CUR) != 0) { + ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Seeking to next frame failed!"); + goto done; + } + if (std::fread(tmp, 1, 4, file) != 4) { + ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Failed to read the next 4 bytes!"); + goto done; + } + head = convert_to_header(tmp); + if (mpg123_head_check(head) && mpg123_decode_header(frp, head)) + { + std::fclose(file); + return true; + } + ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) head check and decode failed on second frame!"); + } + else + ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Failed to find second valid header!"); + // break; } } } delete[] buf; - if (mpg123_decode_header(frp, head)) - { - /* - * We found something which looks like a MPEG-header. - * We check the next frame too, to be sure - */ - if (std::fseek(file, frp->framesize, SEEK_CUR) != 0) { - goto done; - } - if (std::fread(tmp, 1, 4, file) != 4) { - goto done; - } - head = convert_to_header(tmp); - if (mpg123_head_check(head) && mpg123_decode_header(frp, head)) - { - std::fclose(file); - return true; - } - } +// if (mpg123_decode_header(frp, head)) +// { +// /* +// * We found something which looks like a MPEG-header. +// * We check the next frame too, to be sure +// */ +// if (std::fseek(file, frp->framesize, SEEK_CUR) != 0) { +// ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Seeking to next frame failed!"); +// goto done; +// } +// if (std::fread(tmp, 1, 4, file) != 4) { +// ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Failed to read the next 4 bytes!"); +// goto done; +// } +// head = convert_to_header(tmp); +// if (mpg123_head_check(head) && mpg123_decode_header(frp, head)) +// { +// std::fclose(file); +// return true; +// } +// ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) head check and decode failed on second frame!"); +// } +// else +// ECA_LOG_MSG(ECA_LOGGER::info, "(audioio-mp3) Failed to find second valid header!"); done: std::fclose(file);