<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18854">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>I haven't done any FLAC development for some time 
now, but I've around 25 years experience of working with libc and I don't really 
agree with Ben's view.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>You're talking about&nbsp;a binary compatibility 
issue and&nbsp;I'd be surprised if Microsoft had changed something in the 
library to break it. OS companies usually only break binary compatibility if 
they absolutely have to. </FONT><FONT size=2 face=Arial>Having said that, one of 
the things that is putting me off upgrading to Windows 7 is the fact they 
have&nbsp;felt the need to include&nbsp;some sort of&nbsp;"Windows XP emulator". 
Yes I'm still on Windows XP!!</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>From what you've said I think you're right that the 
error is somewhere else.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>Stuart</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> 
  <A title=ivailo91@gmail.com href="mailto:ivailo91@gmail.com">Ivailo 
  Karamanolev</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=flac-dev@xiph.org 
  href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, January 06, 2010 7:49 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Flac-dev] FLAC C API / 
  Visual Studio 2008 FILE* Issue</DIV>
  <DIV><FONT size=2 face=Arial></FONT><FONT size=2 face=Arial></FONT><FONT 
  size=2 face=Arial></FONT><FONT size=2 face=Arial></FONT><BR></DIV>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>&lt;<A 
  href="mailto:benski@winamp.com">benski@winamp.com</A>&gt;</SPAN> wrote:<BR>
  <BLOCKQUOTE 
  style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" 
  class=gmail_quote>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). &nbsp;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. &nbsp;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. &nbsp;In my opinion, this function should have<BR>never been in 
    the API in the first place. &nbsp;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><FONT size=2 face=Arial></FONT><BR>&gt; I managed to get 
    around it. I used the stream functions and provided my<BR>&gt; own<BR>&gt; 
    callbacks for reading and writing. What's strange is that what I've 
    done<BR>&gt; is<BR>&gt; just copied the contents of read/write/seek/tell/eof 
    callbacks from the<BR>&gt; sources to my application and it works just fine, 
    no glitches. When I use<BR>&gt; the build-in implementation, it just crashes 
    without any reason. It's not<BR>&gt; a<BR>&gt; problem to stick with my own 
    callbacks for reading, but fixing this issue<BR>&gt; (if it's not just me) 
    would be nice.<BR>&gt;<BR>&gt; On Wed, Jan 6, 2010 at 12:38 AM, Erik de 
    Castro Lopo<BR></DIV>&gt; &lt;<A 
    href="mailto:mle%2Bla@mega-nerd.com">mle+la@mega-nerd.com</A>&lt;<A 
    href="mailto:mle%252Bla@mega-nerd.com">mle%2Bla@mega-nerd.com</A>&gt;<BR>
    <DIV>
    <DIV></DIV>
    <DIV class=h5>&gt;&gt; wrote:<BR>&gt;<BR>&gt;&gt; Ivailo Karamanolev 
    wrote:<BR>&gt;&gt;<BR>&gt;&gt; &gt; I am currently learning the FLAC C API 
    and had the code working with<BR>&gt;&gt; &gt; 
    FLAC__stream_decoder_init_file. However, since I'd need the 
    Unicode<BR>&gt;&gt; filename<BR>&gt;&gt; &gt; support, I tried _wfopen_s in 
    combination with<BR>&gt;&gt; &gt; FLAC__stream_decoder_init_FILE, however I 
    get a runtime crash as sonn<BR>&gt;&gt; as<BR>&gt;&gt; I<BR>&gt;&gt; &gt; 
    call FLAC__stream_decoder_process_until_end_of_stream. The same 
    code<BR>&gt;&gt; &gt; (partially taken from the examples) is working 
    perfectly with the<BR>&gt;&gt; function<BR>&gt;&gt; &gt; accepting filename 
    and crashing with the one accepting FILE*. I have<BR>&gt;&gt; 
    tried<BR>&gt;&gt; &gt; both compiling the library myself and using the 
    precompiled<BR>&gt;&gt; &gt; flac-1.2.1-devel-win. Can someone try if it is 
    working for him (the<BR>&gt;&gt; FILE*)<BR>&gt;&gt; &gt; version and if yes 
    - send back the source code?<BR>&gt;&gt; &gt; I work in Windows 7 64bit, but 
    I tried that also on a virtual Windows<BR>&gt;&gt; XP<BR>&gt;&gt; 
    and<BR>&gt;&gt; &gt; it crashes there also.<BR>&gt;&gt;<BR>&gt;&gt; There is 
    a whole bunch of weird stuff in windows, this is just another<BR>&gt;&gt; 
    instance.<BR>&gt;&gt;<BR>&gt;&gt; If what you want to do is read/write FLAC 
    files with windows UCS-16<BR>&gt;&gt; filenames,<BR>&gt;&gt; one option is 
    to use libsndfile:<BR>&gt;&gt;<BR>&gt;&gt; &nbsp; &nbsp;<A 
    href="http://www.mega-nerd.com/libsndfile/" 
    target=_blank>http://www.mega-nerd.com/libsndfile/</A><BR>&gt;&gt;<BR>&gt;&gt; 
    which with version 1.0.21 has added this function:<BR>&gt;&gt;<BR>&gt;&gt; 
    &nbsp; &nbsp;/* The function sf_wchar_open() is Windows Only!<BR>&gt;&gt; 
    &nbsp; &nbsp;** Open a file passing in a Windows Unicode filename. 
    Otherwise, this<BR>&gt;&gt; is<BR>&gt;&gt; &nbsp; &nbsp;** the same as 
    sf_open().<BR>&gt;&gt; &nbsp; &nbsp;**<BR>&gt;&gt; &nbsp; &nbsp;** In order 
    for this to work, you need to do the following:<BR>&gt;&gt; &nbsp; 
    &nbsp;**<BR>&gt;&gt; &nbsp; &nbsp;** &nbsp; &nbsp; &nbsp; &nbsp; 
    &nbsp;#include &lt;windows.h&gt;<BR>&gt;&gt; &nbsp; &nbsp;** &nbsp; &nbsp; 
    &nbsp; &nbsp; &nbsp;#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1<BR>&gt;&gt; 
    &nbsp; &nbsp;** &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#including 
    &lt;sndfile.h&gt;<BR>&gt;&gt; &nbsp; &nbsp;*/<BR>&gt;&gt; &nbsp; &nbsp;#if 
    ENABLE_SNDFILE_WINDOWS_PROTOTYPES<BR>&gt;&gt; &nbsp; &nbsp;SNDFILE* 
    sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;<BR>&gt;&gt; 
    &nbsp; &nbsp;#endif<BR>&gt;&gt;<BR>&gt;&gt; There is a windows binary 
    installer in the main web page (one for each<BR>&gt;&gt; of<BR>&gt;&gt; 32 
    and 64 bit windows).<BR>&gt;&gt;<BR>&gt;&gt; The only downside to this is 
    that libsndfile does not expose the all of<BR>&gt;&gt; the features of the 
    FLAC API to the user.<BR>&gt;&gt;<BR>&gt;&gt; Erik<BR>&gt;&gt; 
    --<BR>&gt;&gt; 
    ----------------------------------------------------------------------<BR>&gt;&gt; 
    Erik de Castro Lopo<BR>&gt;&gt; <A href="http://www.mega-nerd.com/" 
    target=_blank>http://www.mega-nerd.com/</A><BR>&gt;&gt; 
    _______________________________________________<BR>&gt;&gt; Flac-dev mailing 
    list<BR>&gt;&gt; <A 
    href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</A><BR>&gt;&gt; <A 
    href="http://lists.xiph.org/mailman/listinfo/flac-dev" 
    target=_blank>http://lists.xiph.org/mailman/listinfo/flac-dev</A><BR>&gt;&gt;<BR>&gt; 
    _______________________________________________<BR>&gt; Flac-dev mailing 
    list<BR>&gt; <A 
    href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</A><BR>&gt; <A 
    href="http://lists.xiph.org/mailman/listinfo/flac-dev" 
    target=_blank>http://lists.xiph.org/mailman/listinfo/flac-dev</A><BR>&gt;<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>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>Flac-dev mailing 
  list<BR>Flac-dev@xiph.org<BR>http://lists.xiph.org/mailman/listinfo/flac-dev<BR></BLOCKQUOTE></BODY></HTML>