2012-03-25 36 views
0

極力打造Windows下Xuggler。 Xuggler是裹成Java進行聲音處理用途(包括FFMPEG)核心本地代碼的功能。爲什麼FREAD()不屬於MSYS/MinGW的工作(跳過字節)?

我的窗戶是64位Win 7的教授,但是所有使用的資料庫是32位。我下的MinGW /運行MSys的構建過程,從下MSYS殼與followinf腳本:

#!/bin/sh 
export JAVA_HOME=/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_25 
export XUGGLE_HOME=/C/Xuggler 

PATH=$XUGGLE_HOME/bin:/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_25/bin:/d/APPS/msysgit/msysgit/bin/git:/D/APPS/MinGW/bin:/bin:/D/APPS/apa che-ant-1.8.2/bin:/D/Users/Dims/Design/MinGW/Util:$PATH 
ant -Dbuild.m64=no run-tests 

Ant目標在結尾處包含一些測試,給出一個錯誤。錯誤如下

[exec] Running 6 tests.. 
[exec] In StdioURLProtocolHandlerTest::testRead: 
[exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:108: Error: Expected (4546420 == totalBytes), found (4546420 != 1042) 
[exec] In StdioURLProtocolHandlerTest::testReadWrite: 
[exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:185: Error: Expected (4546420 == totalBytes), found (4546420 != 1042) 
[exec] In StdioURLProtocolHandlerTest::testSeek: 
[exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:139: Error: Expected (4546420 == totalBytes), found (4546420 != 1042) 
[exec] . 
[exec] Failed 3 of 6 tests 
[exec] Success rate: 50% 
[exec] FAIL: xugglerioTestStdioURLProtocolHandler.exe 

更新1

的測試代碼如下:

int32_t totalBytes = 0; 
do { 
    unsigned char buf[2048]; 
    retval = handler->url_read(buf, (int)sizeof(buf)); 
    if (retval > 0) 
     totalBytes+= retval; 
} while (retval > 0); 
VS_TUT_ENSURE_EQUALS("", 4546420, totalBytes); 

雖然url_read代碼如下:

int 
StdioURLProtocolHandler :: url_read(unsigned char* buf, int size) 
{ 
    if (!mFile) 
     return -1; 
    return (int) fread(buf, 1, size, mFile); 
} 

我不明白在什麼情況下它可以返回1042? ?不知怎的,可能是64位播放?

更新2

我打印出來使用的文件名,這是

d:/......./../../../test/fixtures/testfile.flv 

路徑是正確的,但開始d://d/

這能起到MSYS下一個角色?

更新3

我比較與測試文件的真實內容讀進來字節和發現,FREAD()跳過某些原因,一些字節。不知道哪個字節還,可能這些都是CR/LF

UPDATE 4

與CR/LF我想沒有關係的。

原始字節

46 4C 56 01 05 00 00 00 09 00 00 00 00 12 00 00 F4 00 00 00 00 00 00 00 02 00 0A 6F 6E 4D 65 74 61 44 61 74 61 08 00 00 ... 

讀進來字節

46 4C 56 15 00 09 00 00 12 00 F4 00 00 00 02 0A 6F 6E 4D 65 74 61 44 61 74 61 80 00 B0 86 47 57 26 17 46 96 F6 E0 40 62 ... 

這是FLV文件開始。我不明白腐敗的原則。

如何01 05 00 00變換隻是15 ???

UPDATE 5

文件開口做過類似以下

void 
StdioURLProtocolHandlerTest :: testRead() 
{ 
    StdioURLProtocolManager::registerProtocol("test"); 
    URLProtocolHandler* handler = StdioURLProtocolManager::findHandler("test:foo", 0,0); 
    VS_TUT_ENSURE("", handler); 

    int retval = 0; 
    retval = handler->url_open(mSampleFile, URLProtocolHandler::URL_RDONLY_MODE); 
    VS_TUT_ENSURE("", retval >= 0); 

    int32_t totalBytes = 0; 
    printf("Bytes:\n"); 
    do { 
    //... 

url_open()函數如下:

int StdioURLProtocolHandler :: url_open(const char *url, int flags) 
{ 
    if (!url || !*url) 
    return -1; 
    reset(); 
    const char * mode; 

    switch(flags) { 
    case URLProtocolHandler::URL_RDONLY_MODE: 
     mode="r"; 
     break; 
    case URLProtocolHandler::URL_WRONLY_MODE: 
     mode="w"; 
     break; 
    case URLProtocolHandler::URL_RDWR_MODE: 
      mode="r+"; 
      break; 
     default: 
     return -1; 
    } 

    // The URL MAY contain a protocol string. Find it now. 
    char proto[256]; 
    const char* protocol = URLProtocolManager::parseProtocol(proto, sizeof(proto), url); 
    if (protocol) 
    { 
    size_t protoLen = strlen(protocol); 
    // skip past it 
    url = url + protoLen; 
    if (*url == ':' || *url == ',') 
     ++url; 
    } 
// fprintf(stderr, "protocol: %s; url: %s; mode: %s\n", protocol, url, mode); 
    mFile = fopen(url, mode); 
    if (!mFile) 
    return -1; 
    return 0; 
} 
+0

你是如何打開該文件的? – Mat 2012-03-26 07:16:59

+0

查看更新5.看起來不可疑。 – Dims 2012-03-26 12:45:04

+1

看起來很可疑。在打開模式下沒有「b」。 – Mat 2012-03-26 12:52:23

回答

1

應固定在GIT庫上CROSS_COMPILE分支爲今天。本週晚些時候/下週早些時候我會把它推到樹的尖端。

現在stdio處理程序以二進制打開所有文件。

+0

謝謝。建議用戶'cross_compile'爲Windows編譯?即我可以在Linux上運行編譯器,但會得到Windows的二進制文件,對吧? – Dims 2012-04-05 12:26:34

+0

現在主人包含此修復程序和分佈在我們常春藤回購的預構建的jar文件包含所有操作系統。如果您在Linux中構建,則不會默認生成Windows。你需要啓用交叉編譯(搜索博客)。 – 2012-04-05 16:50:54