Changeset 831

Show
Ignore:
Timestamp:
2003-03-17 02:24:46 (6 years ago)
Author:
robert
Message:

Fixed a series of ogg/vorbis write tags bugs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mb_tagger/trunk/main.dfm

    r827 r831  
    55  AutoScroll = False 
    66  Caption = 'MusicBrainz Tagger' 
    7   ClientHeight = 750 
     7  ClientHeight = 739 
    88  ClientWidth = 792 
    99  Color = clBtnFace 
     
    151151  object statusBar: TStatusBar 
    152152    Left = 0 
    153     Top = 731 
     153    Top = 720 
    154154    Width = 792 
    155155    Height = 19 
     
    997997    Top = 215 
    998998    Width = 792 
    999     Height = 516 
     999    Height = 505 
    10001000    Align = alClient 
    10011001    Caption = 'rightPanel' 
     
    10061006      Top = 1 
    10071007      Width = 790 
    1008       Height = 514 
     1008      Height = 503 
    10091009      TabStop = True 
    10101010      Align = alClient 
     
    10141014      OnDocumentComplete = webBrowserDocumentComplete 
    10151015      ControlData = { 
    1016         4C000000A6510000203500000000000000000000000000000000000000000000 
     1016        4C000000A6510000FD3300000000000000000000000000000000000000000000 
    10171017        000000004C000000000000000000000001000000E0D057007335CF11AE690800 
    10181018        2B2E126200000000000000004C0000000114020000000000C000000000000046 
  • mb_tagger/trunk/preferences.cpp

    r829 r831  
    164164   } 
    165165 
     166   prefs.proxyServer = AnsiString(""); 
    166167   INTERNET_PROXY_INFO *info = (INTERNET_PROXY_INFO *)new char[size]; 
    167168   if (InternetQueryOption(NULL, INTERNET_OPTION_PROXY, info, &size)) 
     
    174175       } 
    175176   } 
     177#if 0 
     178   if (prefs.proxyServer.IsEmpty()) 
     179   { 
     180       AnsiString autoProxy; 
     181 
     182       if (getAutoProxy(autoProxy)) 
     183       { 
     184           char temp[128]; 
     185           sscanf(info->lpszProxy, "%[^:]:%d", temp, &prefs.proxyPort); 
     186           prefs.proxyServer = AnsiString(temp); 
     187       } 
     188   } 
     189#endif 
     190 
    176191   delete [] info; 
    177192 
     
    223238} 
    224239 
     240#if 0 
     241typedef bool (WINAPI *pfnGetProxyInfo)(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD); 
     242typedef bool (WINAPI *pfnInitializeAutoProxyDll)(DWORD); 
     243typedef bool (WINAPI *pfnDeInitializeAutoProxyDll)(LPSTR, DWORD); 
     244 
     245bool __fastcall Preferences::getAutoProxy(AnsiString &proxyString) 
     246{ 
     247   HMODULE hModJS;                               // Handle for loading the DLL 
     248   pfnGetProxyInfo pIGPI;                // Function-pointer instance 
     249   pfnDeInitializeAutoProxyDll pIIDAPD;  // Function-pointer instance 
     250   pfnInitializeAutoProxyDll   pIIIAPD; 
     251   unsigned long  proxyLen = 0; 
     252   char          *proxy = NULL; 
     253   const char    *url = "http://musicbrainz.org/index.html"; 
     254   const char    *hostName = "musicbrainz.org"; 
     255   bool           ret = false; 
     256 
     257   proxyString = ""; 
     258 
     259   hModJS = LoadLibrary( "jsproxy.dll" ); 
     260   if (!hModJS) 
     261       return false; 
     262 
     263   pIGPI = (pfnGetProxyInfo)GetProcAddress( hModJS, "InternetGetProxyInfo"); 
     264   if (!pIGPI) 
     265       return false; 
     266 
     267   pIIIAPD= (pfnInitializeAutoProxyDll) 
     268                GetProcAddress( hModJS, "InternetInitializeAutoProxyDll" ); 
     269   if (!pIIIAPD) 
     270       return false; 
     271 
     272   pIIDAPD = (pfnDeInitializeAutoProxyDll) 
     273                GetProcAddress(hModJS, "InternetDeInitializeAutoProxyDll"); 
     274   if (!pIIDAPD) 
     275       return false; 
     276 
     277   // Initialize the M$ crap 
     278   pIIIAPD(0); 
     279 
     280   if (pIGPI(url, strlen(url), (char *)hostName, strlen(hostName), &proxy, &proxyLen)) 
     281   { 
     282       proxyString = AnsiString(proxy); 
     283       ret = true; 
     284   } 
     285 
     286   // Shut it down; good riddance 
     287   pIIDAPD( NULL, 0 ); 
     288 
     289   return ret; 
     290} 
     291#endif 
  • mb_tagger/trunk/preferences.h

    r829 r831  
    6666        PreferenceValues prefs; 
    6767 
     68        //bool __fastcall getAutoProxy(AnsiString &proxyString); 
    6869}; 
    6970 
  • mb_tagger/trunk/utf8.c

    r828 r831  
    138138 
    139139    if(wchars == 0) 
    140     { 
    141         fprintf(stderr, "Unicode translation error %d\n", GetLastError()); 
    142140        return -1; 
    143     } 
    144141 
    145142    unicode = calloc(wchars + 1, sizeof(unsigned short)); 
    146     if(unicode == NULL)  
    147     { 
    148         fprintf(stderr, "Out of memory processing string to UTF8\n"); 
     143    if(unicode == NULL) 
    149144        return -1; 
    150     } 
    151  
    152     err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from,  
     145 
     146    err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, 
    153147            strlen(from), unicode, wchars); 
    154148    if(err != wchars) 
    155149    { 
    156150        free(unicode); 
    157         fprintf(stderr, "Unicode translation error %d\n", GetLastError()); 
    158151        return -1; 
    159152    } 
     
    178171    unicode = make_unicode_string(from); 
    179172    if(unicode == NULL)  
    180     { 
    181         fprintf(stderr, "Out of memory processing string from UTF8 to UNICODE16\n"); 
    182173        return -1; 
    183     } 
    184174 
    185175    chars = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode, 
     
    194184 
    195185    *to = calloc(chars + 1, sizeof(unsigned char)); 
    196     if(*to == NULL)  
     186    if(*to == NULL) 
    197187    { 
    198188        fprintf(stderr, "Out of memory processing string to local charset\n"); 
     
    201191    } 
    202192 
    203     err = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode,  
     193    err = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode, 
    204194            -1, *to, chars, NULL, NULL); 
    205195    if(err != chars) 
  • mb_tagger/trunk/vcedit.c

    r819 r831  
    4343static void vcedit_clear_internals(vcedit_state *state) 
    4444{ 
     45    char *tmp; 
    4546    if(state->vc) 
    4647    { 
     
    6970    } 
    7071 
     72    tmp = state->lasterror; 
    7173    memset(state, 0, sizeof(*state)); 
     74    state->lasterror = tmp; 
    7275} 
    7376 
     
    98101    oggpack_writeinit(&opb); 
    99102 
    100     /* preamble */   
     103    /* preamble */ 
    101104    oggpack_write(&opb,0x03,8); 
    102105    _v_writestring(&opb,"vorbis", 6); 
     
    113116            if(vc->user_comments[i]){ 
    114117                oggpack_write(&opb,vc->comment_lengths[i],32); 
    115                 _v_writestring(&opb,vc->user_comments[i],  
     118                _v_writestring(&opb,vc->user_comments[i], 
    116119                        vc->comment_lengths[i]); 
    117120            }else{ 
     
    197200    char *buffer; 
    198201    int bytes,i; 
     202    int chunks = 0; 
    199203    ogg_packet *header; 
    200204    ogg_packet  header_main; 
     
    210214    ogg_sync_init(state->oy); 
    211215 
    212     buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); 
    213     bytes = state->read(buffer, 1, CHUNKSIZE, state->in); 
    214  
    215     ogg_sync_wrote(state->oy, bytes); 
    216  
    217     if(ogg_sync_pageout(state->oy, &og) != 1) 
    218     { 
    219         if(bytes<CHUNKSIZE) 
    220             state->lasterror = _("Input truncated or empty."); 
    221         else 
    222             state->lasterror = _("Input is not an Ogg bitstream."); 
    223         goto err; 
    224     } 
     216    while(1) 
     217    { 
     218        buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); 
     219        bytes = state->read(buffer, 1, CHUNKSIZE, state->in); 
     220 
     221        ogg_sync_wrote(state->oy, bytes); 
     222 
     223        if(ogg_sync_pageout(state->oy, &og) == 1) 
     224            break; 
     225 
     226        if(chunks++ >= 10) /* Bail if we don't find data in the first 40 kB */ 
     227        { 
     228            if(bytes<CHUNKSIZE) 
     229                state->lasterror = _("Input truncated or empty."); 
     230            else 
     231                state->lasterror = _("Input is not an Ogg bitstream."); 
     232            goto err; 
     233        } 
     234    } 
    225235 
    226236    state->serial = ogg_page_serialno(&og); 
     
    343353    ogg_stream_init(&streamout, state->serial); 
    344354 
     355    memset(&header_comments, 0, sizeof(header_comments)); 
    345356    _commentheader_out(state->vc, state->vendor, &header_comments); 
    346357 
     
    354365                (size_t) ogout.header_len) 
    355366            goto cleanup; 
    356         if(state->write(ogout.body,1,ogout.body_len, out) !=  
     367        if(state->write(ogout.body,1,ogout.body_len, out) != 
    357368                (size_t) ogout.body_len) 
    358369            goto cleanup; 
     
    369380            if(ogg_stream_flush(&streamout, &ogout)) 
    370381            { 
    371                 if(state->write(ogout.header,1,ogout.header_len,  
     382                if(state->write(ogout.header,1,ogout.header_len, 
    372383                            out) != (size_t) ogout.header_len) 
    373384                    goto cleanup; 
     
    384395                            out) != (size_t) ogout.header_len) 
    385396                    goto cleanup; 
    386                 if(state->write(ogout.body,1,ogout.body_len,  
     397                if(state->write(ogout.body,1,ogout.body_len, 
    387398                            out) != (size_t) ogout.body_len) 
    388399                    goto cleanup; 
     
    411422                needout=1; 
    412423            } 
    413         }       
     424        } 
    414425    } 
    415426 
     
    453464                if(state->write(ogout.header,1,ogout.header_len,  
    454465                        out) != (size_t) ogout.header_len) { 
    455                     fprintf(stderr, "Bumming out\n"); 
    456466                    goto cleanup; 
    457467                } 
    458468                if(state->write(ogout.body,1,ogout.body_len, out) != 
    459469                        (size_t) ogout.body_len) { 
    460                     fprintf(stderr, "Bumming out 2\n"); 
    461470                    goto cleanup; 
    462471                } 
     
    472481        } 
    473482    } 
    474                              
     483 
    475484 
    476485cleanup: 
     486 
    477487    ogg_stream_clear(&streamout); 
     488    if (header_comments.packet) 
     489    { 
     490        _ogg_free(header_comments.packet); 
     491        header_comments.packet = NULL; 
     492    } 
    478493    ogg_packet_clear(&header_comments); 
    479494 
  • mb_tagger/trunk/vorbis.cpp

    r830 r831  
    9292        key = entry.substr(0, sep); 
    9393 
    94         utf8_decode (entry.substr(sep+1, string::npos).c_str(), &decoded)
    95         val = decoded; 
    96         if (decoded) 
    97         { 
    98             free (decoded); 
    99             decoded = NULL
     94        decoded = NULL
     95        if (utf8_decode (entry.substr(sep+1, string::npos).c_str(), &decoded) == 0) 
     96        { 
     97            val = decoded; 
     98            if (decoded) 
     99                free (decoded)
    100100        } 
    101101 
    102102        transform(key.begin(),key.end(),key.begin(),(int(*)(int))&tolower); 
    103103        map.insert (pair<string,string>(key, val)); 
    104 //        cerr << "found " << key << " with " << val << endl; 
    105104    } 
    106105} 
     
    123122        transform(key.begin(),key.end(),key.begin(),(int(*)(int))&toupper); 
    124123 
    125         utf8_encode ((*it).second.c_str(), &encoded); 
    126         comment = key + '=' + encoded; 
    127         free (encoded); 
     124        encoded = NULL; 
     125        if (utf8_encode ((*it).second.c_str(), &encoded) == 0) 
     126        { 
     127            comment = key + '=' + encoded; 
     128            if (encoded) 
     129               free (encoded); 
     130        } 
    128131         
    129132        vorbis_comment_add (vc, (char*)comment.c_str());