Tremor on Mona のデバッグ
まずは Linux 上での動きを見る。
svn checkout
svn co -r13614 http://svn.xiph.org/trunk/Tremor tremor-test
Makefile
TARGET = tremor-test SOURCES = \ main.c \ bitwise.c \ block.c \ codebook.c \ floor0.c \ floor1.c \ framing.c \ info.c \ mapping0.c \ mdct.c \ registry.c \ res012.c \ sharedbook.c \ synthesis.c \ vorbisfile.c \ window.c CFLAGS = -g -idirafter . -Wall OBJECTS = $(SOURCES:.c=.o) all : $(TARGET) $(TARGET): $(OBJECTS) $(CC) $(OBJECTS) -o $(TARGET) .SUFFIXES: .c .o .c.o: $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ depend: $(CC) -MM $(INCLUDE) $(CFLAGS) $(SOURCES) > dependencies clean : rm -f $(OBJECTS) $(TARGET) -include dependencies
test code
#include <stdio.h> #include <ivorbisfile.h> int main(int ac,char **av) { OggVorbis_File vf; FILE* fp = fopen("./A.OGG", "rb"); if (NULL == fp) { fprintf(stderr, "file open error\n"); return -1; } if (ov_open(fp, &vf, NULL, 0) < 0) { fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); return -1; } char **ptr=ov_comment(&vf,-1)->user_comments; vorbis_info *vi=ov_info(&vf,-1); while(*ptr){ fprintf(stderr, "%s\n",*ptr); ++ptr; } fprintf(stderr, "\nBitstream is %d channel, %ldHz\n", vi->channels, vi->rate); fprintf(stderr, "\nDecoded length: %ld samples\n", (long)ov_pcm_total(&vf, -1)); fprintf(stderr, "Encoded by: %s\n\n", ov_comment(&vf, -1)->vendor); return 0; }
execute
sewashi% ./tremor-test TITLE=Lepidoptera ARTIST=Epoq ALBUM=Kahvi Collective DATE=2002 COMMENT=http://www.kahvi.org Bitstream is 2 channel, 44100Hz Decoded length: 13343346 samples Encoded by: Xiph.Org libVorbis I 20020717
ふむ。うまく動いています。
全く同じコードを Mona で動かすと。 ov_open が OV_EREAD が返ります。
fseek ?
.mjt さんに fseek かもねと言われていたので調べる。
Linux と Mona で発行された fseek を比べる。
static int _fseek64_wrap(FILE *f,ogg_int64_t off,int whence){ if(f==NULL)return(-1); int ret = fseek(f,off,whence); printf("fseek off=%d whence=%d ret=%d\n", off & 0xffffffff, whence, ret); return ret; }
Linux上の fseek
fseek off=0 whence=0 ret=1 fseek off=0 whence=0 ret=2 fseek off=4356968 whence=0 ret=0 fseek off=4355944 whence=0 ret=0 fseek off=4354920 whence=0 ret=0 fseek off=4355037 whence=0 ret=0 fseek off=4355037 whence=0 ret=0 fseek off=4355038 whence=0 ret=0 fseek off=4422 whence=0 ret=0 fseek off=4357992 whence=0 ret=0 fseek off=4356968 whence=0 ret=0 fseek off=4355944 whence=0 ret=0 fseek off=4354920 whence=0 ret=0 fseek off=4355037 whence=0 ret=0 fseek off=0 whence=0 ret=0
Mona上の fseek
fseek off=0 whence=0 ret=1 fseek off=0 whence=0 ret=2 fseek off=4356968 whence=0 ret=0 fseek off=4355944 whence=0 ret=0 fseek off=4354920 whence=0 ret=0 fseek off=4355037 whence=0 ret=0 fseek off=4355037 whence=0 ret=0 fseek off=4355038 whence=0 ret=0
どうも fseek ではなさそうだ。
ドキュメント
んー。しょうがないドキュメント読むか。(先に読めよ)。
OV_EREAD - A read from media returned an error.
メディアエラーではないのは明らかなので深追いするしかなさそう。
途中までは read 出来ている気配なので fread を trace してみるか。
fread
Linux
sewashi% ./tremor-test fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=907 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=907 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=906 fread 1 1024 ret=0 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=907 fread 1 1024 ret=1024
Mona
fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=907 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=907 fread 1 1024 ret=1024 fread 1 1024 ret=1024 fread 1 1024 ret=906 fread 1 1024 ret=-1
結論
ファイルが読めないときに、fread が返す値が違う。
次の日記に続く。