~ubuntu-branches/ubuntu/trusty/opusfile/trusty

« back to all changes in this revision

Viewing changes to src/stream.c

  • Committer: Package Import Robot
  • Author(s): Ron Lee
  • Date: 2013-05-13 21:43:40 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130513214340-9p3jj0irk8afk7kd
Tags: 0.2+20130513-1
* Snapshot release for unstable.
* Fixes the pkg-config file to avoid overlinking.  Closes: #707969
* Split the URL handling into a separate library, so that linking with
  openssl is only an issue for people who do need that functionality.
  The main opusfile library can now be linked with anything again.
  Closes:  #708008

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
 ********************************************************************/
17
17
#include "internal.h"
 
18
#include <sys/types.h>
18
19
#include <stdio.h>
19
20
#include <stdlib.h>
20
21
#include <errno.h>
56
57
static int op_fseek(void *_stream,opus_int64 _offset,int _whence){
57
58
#if defined(_MSC_VER)
58
59
  return _fseeki64((FILE *)_stream,_offset,_whence);
 
60
#elif defined(__MINGW32__)
 
61
  /*i686-pc-mingw32 does not have fseeko() and requires
 
62
     __MSVCRT_VERSION__>=0x800 for _fseeki64(), which screws up linking with
 
63
     other libraries (that don't use MSVCRT80 from MSVC 2005 by default).
 
64
    i686-w64-mingw32 does have fseeko() and respects _FILE_OFFSET_BITS, but I
 
65
     don't know how to detect that at compile time.
 
66
    We don't need to use fopen64(), as this just dispatches to fopen() in
 
67
     mingw32.*/
 
68
  return fseeko64((FILE *)_stream,(off64_t)_offset,_whence);
59
69
#else
 
70
  /*This function actually conforms to the SUSv2 and POSIX.1-2001, so we prefer
 
71
     it except in the two special-cases above.*/
60
72
  return fseeko((FILE *)_stream,(off_t)_offset,_whence);
61
73
#endif
62
74
}
64
76
static opus_int64 op_ftell(void *_stream){
65
77
#if defined(_MSC_VER)
66
78
  return _ftelli64((FILE *)_stream);
 
79
#elif defined(__MINGW32__)
 
80
  /*i686-pc-mingw32 does not have ftello() and requires
 
81
     __MSVCRT_VERSION__>=0x800 for _ftelli64(), which screws up linking with
 
82
     other libraries (that don't use MSVCRT80 from MSVC 2005 by default).
 
83
    i686-w64-mingw32 does have ftello() and respects _FILE_OFFSET_BITS, but I
 
84
     don't know how to detect that at compile time.
 
85
    We don't need to use fopen64(), as this just dispatches to fopen() in
 
86
     mingw32.*/
 
87
  return ftello64((FILE *)_stream);
67
88
#else
 
89
  /*This function actually conforms to the SUSv2 and POSIX.1-2001, so we prefer
 
90
     it except in the two special-cases above.*/
68
91
  return ftello((FILE *)_stream);
69
92
#endif
70
93
}
110
133
  /*Check for EOF.*/
111
134
  if(pos>=size)return 0;
112
135
  /*Check for a short read.*/
113
 
  _buf_size=(int)OP_MAX(size-pos,_buf_size);
 
136
  _buf_size=(int)OP_MIN(size-pos,_buf_size);
114
137
  memcpy(_ptr,stream->data+pos,_buf_size);
115
138
  pos+=_buf_size;
116
139
  stream->pos=pos;