I thought about this, and the MSVCRT mismatch also. What annoys me is that I even tried compiling the library myself (with exactly the same Visual Studio 2008 as my application) and the bug didn't change the least. Thank you for your ideas, but unless someone can confirm this, there still remains the possibility that I've made an error somewhere. Also someone with more experience with native debuggers (I'm a kind of .NET man) may be able to detect where the error comes from more precisely.<br>
About the Windows weirdness - we all want to program for Linux/Unix only, but even I don't want to use it for my desktop, so I guess we'll have to deal with Win32.<br><br>Ivailo Karamanolev<br><br><div class="gmail_quote">
On Wed, Jan 6, 2010 at 1:15 AM, Ben Allison <span dir="ltr"><<a href="mailto:benski@winamp.com">benski@winamp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ivailo -<br>
<br>
FILE objects are internal to the C runtime library, they are not system<br>
objects like HANDLEs (windows) or file descriptors (unix). This means<br>
that if libFLAC has linked against a different C runtime library than your<br>
application, then the two FILE objects are incompatible. This isn't just<br>
a Windows specific issue either - if libFLAC was compiled against libc and<br>
your application links to glibc (or even a different version of libc) you<br>
will experience the same issue. In my opinion, this function should have<br>
never been in the API in the first place. A function that accepts a<br>
HANDLE on Windows or an int (file descriptor) on Unix is more appropriate.<br>
<br>
-Ben Allison<br>
<div class="im"><br>
> I managed to get around it. I used the stream functions and provided my<br>
> own<br>
> callbacks for reading and writing. What's strange is that what I've done<br>
> is<br>
> just copied the contents of read/write/seek/tell/eof callbacks from the<br>
> sources to my application and it works just fine, no glitches. When I use<br>
> the build-in implementation, it just crashes without any reason. It's not<br>
> a<br>
> problem to stick with my own callbacks for reading, but fixing this issue<br>
> (if it's not just me) would be nice.<br>
><br>
> On Wed, Jan 6, 2010 at 12:38 AM, Erik de Castro Lopo<br>
</div>> <<a href="mailto:mle%2Bla@mega-nerd.com">mle+la@mega-nerd.com</a><<a href="mailto:mle%252Bla@mega-nerd.com">mle%2Bla@mega-nerd.com</a>><br>
<div><div></div><div class="h5">>> wrote:<br>
><br>
>> Ivailo Karamanolev wrote:<br>
>><br>
>> > I am currently learning the FLAC C API and had the code working with<br>
>> > FLAC__stream_decoder_init_file. However, since I'd need the Unicode<br>
>> filename<br>
>> > support, I tried _wfopen_s in combination with<br>
>> > FLAC__stream_decoder_init_FILE, however I get a runtime crash as sonn<br>
>> as<br>
>> I<br>
>> > call FLAC__stream_decoder_process_until_end_of_stream. The same code<br>
>> > (partially taken from the examples) is working perfectly with the<br>
>> function<br>
>> > accepting filename and crashing with the one accepting FILE*. I have<br>
>> tried<br>
>> > both compiling the library myself and using the precompiled<br>
>> > flac-1.2.1-devel-win. Can someone try if it is working for him (the<br>
>> FILE*)<br>
>> > version and if yes - send back the source code?<br>
>> > I work in Windows 7 64bit, but I tried that also on a virtual Windows<br>
>> XP<br>
>> and<br>
>> > it crashes there also.<br>
>><br>
>> There is a whole bunch of weird stuff in windows, this is just another<br>
>> instance.<br>
>><br>
>> If what you want to do is read/write FLAC files with windows UCS-16<br>
>> filenames,<br>
>> one option is to use libsndfile:<br>
>><br>
>> <a href="http://www.mega-nerd.com/libsndfile/" target="_blank">http://www.mega-nerd.com/libsndfile/</a><br>
>><br>
>> which with version 1.0.21 has added this function:<br>
>><br>
>> /* The function sf_wchar_open() is Windows Only!<br>
>> ** Open a file passing in a Windows Unicode filename. Otherwise, this<br>
>> is<br>
>> ** the same as sf_open().<br>
>> **<br>
>> ** In order for this to work, you need to do the following:<br>
>> **<br>
>> ** #include <windows.h><br>
>> ** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1<br>
>> ** #including <sndfile.h><br>
>> */<br>
>> #if ENABLE_SNDFILE_WINDOWS_PROTOTYPES<br>
>> SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;<br>
>> #endif<br>
>><br>
>> There is a windows binary installer in the main web page (one for each<br>
>> of<br>
>> 32 and 64 bit windows).<br>
>><br>
>> The only downside to this is that libsndfile does not expose the all of<br>
>> the features of the FLAC API to the user.<br>
>><br>
>> Erik<br>
>> --<br>
>> ----------------------------------------------------------------------<br>
>> Erik de Castro Lopo<br>
>> <a href="http://www.mega-nerd.com/" target="_blank">http://www.mega-nerd.com/</a><br>
>> _______________________________________________<br>
>> Flac-dev mailing list<br>
>> <a href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</a><br>
>> <a href="http://lists.xiph.org/mailman/listinfo/flac-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/flac-dev</a><br>
>><br>
> _______________________________________________<br>
> Flac-dev mailing list<br>
> <a href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</a><br>
> <a href="http://lists.xiph.org/mailman/listinfo/flac-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/flac-dev</a><br>
><br>
<br>
_______________________________________________<br>
Flac-dev mailing list<br>
<a href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/flac-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/flac-dev</a><br>
</div></div></blockquote></div><br>