ReactOS  0.4.15-dev-1018-g0695ecb
wavfile.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "winerror.h"
#include "mmsystem.h"
#include "vfw.h"
#include "msacm.h"
#include "avifile_private.h"
#include "extrachunk.h"
#include "wine/debug.h"
Include dependency graph for wavfile.c:

Go to the source code of this file.

Classes

struct  SUNAUDIOHEADER
 
struct  _IAVIFileImpl
 

Macros

#define COBJMACROS
 
#define formtypeWAVE   mmioFOURCC('W','A','V','E')
 
#define ckidWAVEFORMAT   mmioFOURCC('f','m','t',' ')
 
#define ckidWAVEFACT   mmioFOURCC('f','a','c','t')
 
#define ckidWAVEDATA   mmioFOURCC('d','a','t','a')
 
#define ENDIAN_SWAPWORD(x)   ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))
 
#define ENDIAN_SWAPDWORD(x)
 
#define BE2H_WORD(x)   ENDIAN_SWAPWORD(x)
 
#define BE2H_DWORD(x)   ENDIAN_SWAPDWORD(x)
 
#define LE2H_WORD(x)   (x)
 
#define LE2H_DWORD(x)   (x)
 
#define AU_ENCODING_ULAW_8   1
 
#define AU_ENCODING_PCM_8   2
 
#define AU_ENCODING_PCM_16   3
 
#define AU_ENCODING_PCM_24   4
 
#define AU_ENCODING_PCM_32   5
 
#define AU_ENCODING_FLOAT   6
 
#define AU_ENCODING_DOUBLE   7
 
#define AU_ENCODING_ADPCM_G721_32   23
 
#define AU_ENCODING_ADPCM_G722   24
 
#define AU_ENCODING_ADPCM_G723_24   25
 
#define AU_ENCODING_ADPCM_G723_5   26
 
#define AU_ENCODING_ALAW_8   27
 

Typedefs

typedef struct _IAVIFileImpl IAVIFileImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (avifile)
 
static HRESULT AVIFILE_LoadFile (IAVIFileImpl *This)
 
static HRESULT AVIFILE_LoadSunFile (IAVIFileImpl *This)
 
static HRESULT AVIFILE_SaveFile (const IAVIFileImpl *This)
 
static IAVIFileImplimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IUnknown_fnAddRef (IUnknown *iface)
 
static ULONG WINAPI IUnknown_fnRelease (IUnknown *iface)
 
static IAVIFileImplimpl_from_IAVIFile (IAVIFile *iface)
 
static HRESULT WINAPI IAVIFile_fnQueryInterface (IAVIFile *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IAVIFile_fnAddRef (IAVIFile *iface)
 
static ULONG WINAPI IAVIFile_fnRelease (IAVIFile *iface)
 
static HRESULT WINAPI IAVIFile_fnInfo (IAVIFile *iface, AVIFILEINFOW *afi, LONG size)
 
static HRESULT WINAPI IAVIFile_fnGetStream (IAVIFile *iface, IAVIStream **avis, DWORD fccType, LONG lParam)
 
static HRESULT WINAPI IAVIFile_fnCreateStream (IAVIFile *iface, IAVIStream **avis, AVISTREAMINFOW *asi)
 
static HRESULT WINAPI IAVIFile_fnWriteData (IAVIFile *iface, DWORD ckid, void *lpData, LONG size)
 
static HRESULT WINAPI IAVIFile_fnReadData (IAVIFile *iface, DWORD ckid, void *lpData, LONG *size)
 
static HRESULT WINAPI IAVIFile_fnEndRecord (IAVIFile *iface)
 
static HRESULT WINAPI IAVIFile_fnDeleteStream (IAVIFile *iface, DWORD fccType, LONG lParam)
 
static IAVIFileImplimpl_from_IPersistFile (IPersistFile *iface)
 
static HRESULT WINAPI IPersistFile_fnQueryInterface (IPersistFile *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IPersistFile_fnAddRef (IPersistFile *iface)
 
static ULONG WINAPI IPersistFile_fnRelease (IPersistFile *iface)
 
static HRESULT WINAPI IPersistFile_fnGetClassID (IPersistFile *iface, LPCLSID pClassID)
 
static HRESULT WINAPI IPersistFile_fnIsDirty (IPersistFile *iface)
 
static HRESULT WINAPI IPersistFile_fnLoad (IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
 
static HRESULT WINAPI IPersistFile_fnSave (IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
 
static HRESULT WINAPI IPersistFile_fnSaveCompleted (IPersistFile *iface, LPCOLESTR pszFileName)
 
static HRESULT WINAPI IPersistFile_fnGetCurFile (IPersistFile *iface, LPOLESTR *ppszFileName)
 
static IAVIFileImplimpl_from_IAVIStream (IAVIStream *iface)
 
static HRESULT WINAPI IAVIStream_fnQueryInterface (IAVIStream *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IAVIStream_fnAddRef (IAVIStream *iface)
 
static ULONG WINAPI IAVIStream_fnRelease (IAVIStream *iface)
 
static HRESULT WINAPI IAVIStream_fnCreate (IAVIStream *iface, LPARAM lParam1, LPARAM lParam2)
 
static HRESULT WINAPI IAVIStream_fnInfo (IAVIStream *iface, AVISTREAMINFOW *psi, LONG size)
 
static LONG WINAPI IAVIStream_fnFindSample (IAVIStream *iface, LONG pos, LONG flags)
 
static HRESULT WINAPI IAVIStream_fnReadFormat (IAVIStream *iface, LONG pos, void *format, LONG *formatsize)
 
static HRESULT WINAPI IAVIStream_fnSetFormat (IAVIStream *iface, LONG pos, void *format, LONG formatsize)
 
static HRESULT WINAPI IAVIStream_fnRead (IAVIStream *iface, LONG start, LONG samples, void *buffer, LONG buffersize, LONG *bytesread, LONG *samplesread)
 
static HRESULT WINAPI IAVIStream_fnWrite (IAVIStream *iface, LONG start, LONG samples, void *buffer, LONG buffersize, DWORD flags, LONG *sampwritten, LONG *byteswritten)
 
static HRESULT WINAPI IAVIStream_fnDelete (IAVIStream *iface, LONG start, LONG samples)
 
static HRESULT WINAPI IAVIStream_fnReadData (IAVIStream *iface, DWORD fcc, void *lp, LONG *lpread)
 
static HRESULT WINAPI IAVIStream_fnWriteData (IAVIStream *iface, DWORD fcc, void *lp, LONG size)
 
static HRESULT WINAPI IAVIStream_fnSetInfo (IAVIStream *iface, LPAVISTREAMINFOW info, LONG infolen)
 
HRESULT AVIFILE_CreateWAVFile (IUnknown *outer_unk, REFIID riid, void **ret_iface)
 

Variables

static const IUnknownVtbl unk_vtbl
 
static const struct IAVIFileVtbl iwavft
 
static const struct IPersistFileVtbl iwavpft
 
static const struct IAVIStreamVtbl iwavst
 

Macro Definition Documentation

◆ AU_ENCODING_ADPCM_G721_32

#define AU_ENCODING_ADPCM_G721_32   23

Definition at line 81 of file wavfile.c.

◆ AU_ENCODING_ADPCM_G722

#define AU_ENCODING_ADPCM_G722   24

Definition at line 82 of file wavfile.c.

◆ AU_ENCODING_ADPCM_G723_24

#define AU_ENCODING_ADPCM_G723_24   25

Definition at line 83 of file wavfile.c.

◆ AU_ENCODING_ADPCM_G723_5

#define AU_ENCODING_ADPCM_G723_5   26

Definition at line 84 of file wavfile.c.

◆ AU_ENCODING_ALAW_8

#define AU_ENCODING_ALAW_8   27

Definition at line 85 of file wavfile.c.

◆ AU_ENCODING_DOUBLE

#define AU_ENCODING_DOUBLE   7

Definition at line 80 of file wavfile.c.

◆ AU_ENCODING_FLOAT

#define AU_ENCODING_FLOAT   6

Definition at line 79 of file wavfile.c.

◆ AU_ENCODING_PCM_16

#define AU_ENCODING_PCM_16   3

Definition at line 76 of file wavfile.c.

◆ AU_ENCODING_PCM_24

#define AU_ENCODING_PCM_24   4

Definition at line 77 of file wavfile.c.

◆ AU_ENCODING_PCM_32

#define AU_ENCODING_PCM_32   5

Definition at line 78 of file wavfile.c.

◆ AU_ENCODING_PCM_8

#define AU_ENCODING_PCM_8   2

Definition at line 75 of file wavfile.c.

◆ AU_ENCODING_ULAW_8

#define AU_ENCODING_ULAW_8   1

Definition at line 74 of file wavfile.c.

◆ BE2H_DWORD

#define BE2H_DWORD (   x)    ENDIAN_SWAPDWORD(x)

Definition at line 60 of file wavfile.c.

◆ BE2H_WORD

#define BE2H_WORD (   x)    ENDIAN_SWAPWORD(x)

Definition at line 59 of file wavfile.c.

◆ ckidWAVEDATA

#define ckidWAVEDATA   mmioFOURCC('d','a','t','a')

Definition at line 45 of file wavfile.c.

◆ ckidWAVEFACT

#define ckidWAVEFACT   mmioFOURCC('f','a','c','t')

Definition at line 44 of file wavfile.c.

◆ ckidWAVEFORMAT

#define ckidWAVEFORMAT   mmioFOURCC('f','m','t',' ')

Definition at line 43 of file wavfile.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file wavfile.c.

◆ ENDIAN_SWAPDWORD

#define ENDIAN_SWAPDWORD (   x)
Value:
(ENDIAN_SWAPWORD((x >> 16) & 0xFFFF) | \
ENDIAN_SWAPWORD(x & 0xFFFF) << 16)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define ENDIAN_SWAPWORD(x)
Definition: wavfile.c:49

Definition at line 50 of file wavfile.c.

◆ ENDIAN_SWAPWORD

#define ENDIAN_SWAPWORD (   x)    ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))

Definition at line 49 of file wavfile.c.

◆ formtypeWAVE

#define formtypeWAVE   mmioFOURCC('W','A','V','E')

Definition at line 42 of file wavfile.c.

◆ LE2H_DWORD

#define LE2H_DWORD (   x)    (x)

Definition at line 62 of file wavfile.c.

◆ LE2H_WORD

#define LE2H_WORD (   x)    (x)

Definition at line 61 of file wavfile.c.

Typedef Documentation

◆ IAVIFileImpl

Function Documentation

◆ AVIFILE_CreateWAVFile()

HRESULT AVIFILE_CreateWAVFile ( IUnknown outer_unk,
REFIID  riid,
void **  ret_iface 
)

Definition at line 978 of file wavfile.c.

979 {
980  IAVIFileImpl *pfile;
981  HRESULT hr;
982 
983  *ret_iface = NULL;
984 
985  pfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pfile));
986  if (!pfile)
987  return AVIERR_MEMORY;
988 
989  pfile->IUnknown_inner.lpVtbl = &unk_vtbl;
990  pfile->IAVIFile_iface.lpVtbl = &iwavft;
991  pfile->IPersistFile_iface.lpVtbl = &iwavpft;
992  pfile->IAVIStream_iface.lpVtbl = &iwavst;
993  pfile->ref = 1;
994  if (outer_unk)
995  pfile->outer_unk = outer_unk;
996  else
997  pfile->outer_unk = &pfile->IUnknown_inner;
998 
999  hr = IUnknown_QueryInterface(&pfile->IUnknown_inner, riid, ret_iface);
1000  IUnknown_Release(&pfile->IUnknown_inner);
1001 
1002  return hr;
1003 }
static const struct IAVIFileVtbl iwavft
Definition: wavfile.c:412
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
static const struct IAVIStreamVtbl iwavst
Definition: wavfile.c:961
IAVIStream IAVIStream_iface
Definition: wavfile.c:93
IUnknown IUnknown_inner
Definition: avifile.c:92
#define AVIERR_MEMORY
Definition: vfw.h:1745
smooth NULL
Definition: ftsmooth.c:416
IAVIFile IAVIFile_iface
Definition: avifile.c:93
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
IPersistFile IPersistFile_iface
Definition: avifile.c:94
IUnknown * outer_unk
Definition: avifile.c:95
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const struct IPersistFileVtbl iwavpft
Definition: wavfile.c:583
static const IUnknownVtbl unk_vtbl
Definition: wavfile.c:190
LONG ref
Definition: avifile.c:96

Referenced by IClassFactory_fnCreateInstance().

◆ AVIFILE_LoadFile()

static HRESULT AVIFILE_LoadFile ( IAVIFileImpl This)
static

Definition at line 1007 of file wavfile.c.

1008 {
1009  MMCKINFO ckRIFF;
1010  MMCKINFO ck;
1011 
1012  This->sInfo.dwLength = 0; /* just to be sure */
1013  This->fDirty = FALSE;
1014 
1015  /* search for RIFF chunk */
1016  ckRIFF.fccType = 0; /* find any */
1017  if (mmioDescend(This->hmmio, &ckRIFF, NULL, MMIO_FINDRIFF) != S_OK) {
1018  return AVIFILE_LoadSunFile(This);
1019  }
1020 
1021  if (ckRIFF.fccType != formtypeWAVE)
1022  return AVIERR_BADFORMAT;
1023 
1024  /* search WAVE format chunk */
1025  ck.ckid = ckidWAVEFORMAT;
1026  if (FindChunkAndKeepExtras(&This->extra, This->hmmio, &ck,
1027  &ckRIFF, MMIO_FINDCHUNK) != S_OK)
1028  return AVIERR_FILEREAD;
1029 
1030  /* get memory for format and read it */
1031  This->lpFormat = HeapAlloc(GetProcessHeap(), 0, ck.cksize);
1032  if (This->lpFormat == NULL)
1033  return AVIERR_FILEREAD;
1034  This->cbFormat = ck.cksize;
1035 
1036  if (mmioRead(This->hmmio, (HPSTR)This->lpFormat, ck.cksize) != ck.cksize)
1037  return AVIERR_FILEREAD;
1038  if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
1039  return AVIERR_FILEREAD;
1040 
1041  /* Non-pcm formats have a fact chunk.
1042  * We don't need it, so simply add it to the extra chunks.
1043  */
1044 
1045  /* find the big data chunk */
1046  This->ckData.ckid = ckidWAVEDATA;
1047  if (FindChunkAndKeepExtras(&This->extra, This->hmmio, &This->ckData,
1048  &ckRIFF, MMIO_FINDCHUNK) != S_OK)
1049  return AVIERR_FILEREAD;
1050 
1051  memset(&This->sInfo, 0, sizeof(This->sInfo));
1052  This->sInfo.fccType = streamtypeAUDIO;
1053  This->sInfo.dwRate = This->lpFormat->nAvgBytesPerSec;
1054  This->sInfo.dwSampleSize =
1055  This->sInfo.dwScale = This->lpFormat->nBlockAlign;
1056  This->sInfo.dwLength = This->ckData.cksize / This->lpFormat->nBlockAlign;
1057  This->sInfo.dwSuggestedBufferSize = This->ckData.cksize;
1058 
1059  This->fInfo.dwStreams = 1;
1060 
1061  if (mmioAscend(This->hmmio, &This->ckData, 0) != S_OK) {
1062  /* seems to be truncated */
1063  WARN(": file seems to be truncated!\n");
1064  This->ckData.cksize = mmioSeek(This->hmmio, 0, SEEK_END) -
1065  This->ckData.dwDataOffset;
1066  This->sInfo.dwLength = This->ckData.cksize / This->lpFormat->nBlockAlign;
1067  This->sInfo.dwSuggestedBufferSize = This->ckData.cksize;
1068  }
1069 
1070  /* ignore errors */
1071  FindChunkAndKeepExtras(&This->extra, This->hmmio, &ck, &ckRIFF, 0);
1072 
1073  return AVIERR_OK;
1074 }
MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags)
Definition: mmio.c:1204
#define WARN(fmt,...)
Definition: debug.h:112
static HRESULT AVIFILE_LoadSunFile(IAVIFileImpl *This)
Definition: wavfile.c:1076
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:835
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define MMIO_FINDCHUNK
Definition: mmsystem.h:551
FOURCC fccType
Definition: mmsystem.h:1509
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD cksize
Definition: mmsystem.h:1508
char * HPSTR
Definition: mmsystem.h:1477
#define streamtypeAUDIO
Definition: aviriff.h:93
#define formtypeWAVE
Definition: wavfile.c:42
#define ckidWAVEDATA
Definition: wavfile.c:45
#define AVIERR_OK
Definition: vfw.h:1740
#define ckidWAVEFORMAT
Definition: wavfile.c:43
#define S_OK
Definition: intsafe.h:59
FOURCC ckid
Definition: mmsystem.h:1507
MMRESULT WINAPI mmioDescend(HMMIO hmmio, LPMMCKINFO lpck, const MMCKINFO *lpckParent, UINT uFlags)
Definition: mmio.c:1106
#define MMIO_FINDRIFF
Definition: mmsystem.h:552
#define SEEK_END
Definition: cabinet.c:27
#define AVIERR_FILEREAD
Definition: vfw.h:1751
#define AVIERR_BADFORMAT
Definition: vfw.h:1744
#define memset(x, y, z)
Definition: compat.h:39
LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
Definition: mmio.c:732
HRESULT FindChunkAndKeepExtras(LPEXTRACHUNKS extra, HMMIO hmmio, MMCKINFO *lpck, MMCKINFO *lpckParent, UINT flags)
Definition: extrachunk.c:143

Referenced by IPersistFile_fnLoad().

◆ AVIFILE_LoadSunFile()

static HRESULT AVIFILE_LoadSunFile ( IAVIFileImpl This)
static

Definition at line 1076 of file wavfile.c.

1077 {
1078  SUNAUDIOHEADER auhdr;
1079 
1080  mmioSeek(This->hmmio, 0, SEEK_SET);
1081  if (mmioRead(This->hmmio, (HPSTR)&auhdr, sizeof(auhdr)) != sizeof(auhdr))
1082  return AVIERR_FILEREAD;
1083 
1084  if (auhdr.fccType == 0x0064732E) {
1085  /* header in little endian */
1086  This->ckData.dwDataOffset = LE2H_DWORD(auhdr.offset);
1087  This->ckData.cksize = LE2H_DWORD(auhdr.size);
1088 
1089  auhdr.encoding = LE2H_DWORD(auhdr.encoding);
1090  auhdr.sampleRate = LE2H_DWORD(auhdr.sampleRate);
1091  auhdr.channels = LE2H_DWORD(auhdr.channels);
1092  } else if (auhdr.fccType == mmioFOURCC('.','s','n','d')) {
1093  /* header in big endian */
1094  This->ckData.dwDataOffset = BE2H_DWORD(auhdr.offset);
1095  This->ckData.cksize = BE2H_DWORD(auhdr.size);
1096 
1097  auhdr.encoding = BE2H_DWORD(auhdr.encoding);
1098  auhdr.sampleRate = BE2H_DWORD(auhdr.sampleRate);
1099  auhdr.channels = BE2H_DWORD(auhdr.channels);
1100  } else
1101  return AVIERR_FILEREAD;
1102 
1103  if (auhdr.channels < 1)
1104  return AVIERR_BADFORMAT;
1105 
1106  /* get size of header */
1107  switch(auhdr.encoding) {
1109  This->cbFormat = sizeof(G721_ADPCMWAVEFORMAT); break;
1111  This->cbFormat = sizeof(G723_ADPCMWAVEFORMAT); break;
1114  WARN("unsupported Sun audio format %d\n", auhdr.encoding);
1115  return AVIERR_UNSUPPORTED; /* FIXME */
1116  default:
1117  This->cbFormat = sizeof(WAVEFORMATEX); break;
1118  };
1119 
1120  This->lpFormat = HeapAlloc(GetProcessHeap(), 0, This->cbFormat);
1121  if (This->lpFormat == NULL)
1122  return AVIERR_MEMORY;
1123 
1124  This->lpFormat->nChannels = auhdr.channels;
1125  This->lpFormat->nSamplesPerSec = auhdr.sampleRate;
1126  switch(auhdr.encoding) {
1127  case AU_ENCODING_ULAW_8:
1128  This->lpFormat->wFormatTag = WAVE_FORMAT_MULAW;
1129  This->lpFormat->wBitsPerSample = 8;
1130  break;
1131  case AU_ENCODING_PCM_8:
1132  This->lpFormat->wFormatTag = WAVE_FORMAT_PCM;
1133  This->lpFormat->wBitsPerSample = 8;
1134  break;
1135  case AU_ENCODING_PCM_16:
1136  This->lpFormat->wFormatTag = WAVE_FORMAT_PCM;
1137  This->lpFormat->wBitsPerSample = 16;
1138  break;
1139  case AU_ENCODING_PCM_24:
1140  This->lpFormat->wFormatTag = WAVE_FORMAT_PCM;
1141  This->lpFormat->wBitsPerSample = 24;
1142  break;
1143  case AU_ENCODING_PCM_32:
1144  This->lpFormat->wFormatTag = WAVE_FORMAT_PCM;
1145  This->lpFormat->wBitsPerSample = 32;
1146  break;
1147  case AU_ENCODING_ALAW_8:
1148  This->lpFormat->wFormatTag = WAVE_FORMAT_ALAW;
1149  This->lpFormat->wBitsPerSample = 8;
1150  break;
1152  This->lpFormat->wFormatTag = WAVE_FORMAT_G721_ADPCM;
1153  This->lpFormat->wBitsPerSample = (3*5*8);
1154  This->lpFormat->nBlockAlign = 15*15*8;
1155  This->lpFormat->cbSize = sizeof(WORD);
1156  ((LPG721_ADPCMWAVEFORMAT)This->lpFormat)->nAuxBlockSize = 0;
1157  break;
1159  This->lpFormat->wFormatTag = WAVE_FORMAT_G723_ADPCM;
1160  This->lpFormat->wBitsPerSample = (3*5*8);
1161  This->lpFormat->nBlockAlign = 15*15*8;
1162  This->lpFormat->cbSize = 2*sizeof(WORD);
1163  ((LPG723_ADPCMWAVEFORMAT)This->lpFormat)->cbExtraSize = 0;
1164  ((LPG723_ADPCMWAVEFORMAT)This->lpFormat)->nAuxBlockSize = 0;
1165  break;
1166  default:
1167  WARN("unsupported Sun audio format %d\n", auhdr.encoding);
1168  return AVIERR_UNSUPPORTED;
1169  };
1170 
1171  This->lpFormat->nBlockAlign =
1172  (This->lpFormat->nChannels * This->lpFormat->wBitsPerSample) / 8;
1173  if (This->lpFormat->nBlockAlign == 0 && This->lpFormat->wBitsPerSample < 8)
1174  This->lpFormat->nBlockAlign++;
1175  This->lpFormat->nAvgBytesPerSec =
1176  This->lpFormat->nBlockAlign * This->lpFormat->nSamplesPerSec;
1177 
1178  This->fDirty = FALSE;
1179 
1180  This->sInfo.fccType = streamtypeAUDIO;
1181  This->sInfo.fccHandler = 0;
1182  This->sInfo.dwFlags = 0;
1183  This->sInfo.wPriority = 0;
1184  This->sInfo.wLanguage = 0;
1185  This->sInfo.dwInitialFrames = 0;
1186  This->sInfo.dwScale = This->lpFormat->nBlockAlign;
1187  This->sInfo.dwRate = This->lpFormat->nAvgBytesPerSec;
1188  This->sInfo.dwStart = 0;
1189  This->sInfo.dwLength =
1190  This->ckData.cksize / This->lpFormat->nBlockAlign;
1191  This->sInfo.dwSuggestedBufferSize = This->sInfo.dwLength;
1192  This->sInfo.dwSampleSize = This->lpFormat->nBlockAlign;
1193 
1194  This->fInfo.dwStreams = 1;
1195  This->fInfo.dwScale = 1;
1196  This->fInfo.dwRate = This->lpFormat->nSamplesPerSec;
1197  This->fInfo.dwLength =
1198  MulDiv(This->ckData.cksize, This->lpFormat->nSamplesPerSec,
1199  This->lpFormat->nAvgBytesPerSec);
1200 
1201  return AVIERR_OK;
1202 }
#define AU_ENCODING_ADPCM_G722
Definition: wavfile.c:82
#define AU_ENCODING_ALAW_8
Definition: wavfile.c:85
#define WARN(fmt,...)
Definition: debug.h:112
#define AU_ENCODING_ADPCM_G723_5
Definition: wavfile.c:84
#define AU_ENCODING_PCM_8
Definition: wavfile.c:75
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:835
#define AU_ENCODING_PCM_16
Definition: wavfile.c:76
#define AU_ENCODING_ULAW_8
Definition: wavfile.c:74
#define AVIERR_MEMORY
Definition: vfw.h:1745
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define FALSE
Definition: types.h:117
G723_ADPCMWAVEFORMAT * LPG723_ADPCMWAVEFORMAT
Definition: mmreg.h:212
#define WAVE_FORMAT_MULAW
Definition: constants.h:428
#define WAVE_FORMAT_G723_ADPCM
Definition: mmreg.h:106
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743
#define SEEK_SET
Definition: jmemansi.c:26
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct g721_adpcmwaveformat_tag G721_ADPCMWAVEFORMAT
struct g723_adpcmwaveformat_tag G723_ADPCMWAVEFORMAT
unsigned short WORD
Definition: ntddk_ex.h:93
#define AU_ENCODING_PCM_24
Definition: wavfile.c:77
char * HPSTR
Definition: mmsystem.h:1477
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
#define streamtypeAUDIO
Definition: aviriff.h:93
#define AVIERR_OK
Definition: vfw.h:1740
#define AU_ENCODING_PCM_32
Definition: wavfile.c:78
#define AU_ENCODING_ADPCM_G721_32
Definition: wavfile.c:81
#define AU_ENCODING_ADPCM_G723_24
Definition: wavfile.c:83
G721_ADPCMWAVEFORMAT * LPG721_ADPCMWAVEFORMAT
Definition: mmreg.h:337
#define WAVE_FORMAT_ALAW
Definition: constants.h:427
#define LE2H_DWORD(x)
Definition: wavfile.c:62
#define AVIERR_FILEREAD
Definition: vfw.h:1751
#define AVIERR_BADFORMAT
Definition: vfw.h:1744
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define WAVE_FORMAT_G721_ADPCM
Definition: mmreg.h:125
LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
Definition: mmio.c:732
#define BE2H_DWORD(x)
Definition: wavfile.c:60

Referenced by AVIFILE_LoadFile().

◆ AVIFILE_SaveFile()

static HRESULT AVIFILE_SaveFile ( const IAVIFileImpl This)
static

Definition at line 1204 of file wavfile.c.

1205 {
1206  MMCKINFO ckRIFF;
1207  MMCKINFO ck;
1208 
1209  mmioSeek(This->hmmio, 0, SEEK_SET);
1210 
1211  /* create the RIFF chunk with formtype WAVE */
1212  ckRIFF.fccType = formtypeWAVE;
1213  ckRIFF.cksize = 0;
1214  if (mmioCreateChunk(This->hmmio, &ckRIFF, MMIO_CREATERIFF) != S_OK)
1215  return AVIERR_FILEWRITE;
1216 
1217  /* the next chunk is the format */
1218  ck.ckid = ckidWAVEFORMAT;
1219  ck.cksize = This->cbFormat;
1220  if (mmioCreateChunk(This->hmmio, &ck, 0) != S_OK)
1221  return AVIERR_FILEWRITE;
1222  if (This->lpFormat != NULL && This->cbFormat > 0) {
1223  if (mmioWrite(This->hmmio, (HPSTR)This->lpFormat, ck.cksize) != ck.cksize)
1224  return AVIERR_FILEWRITE;
1225  }
1226  if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
1227  return AVIERR_FILEWRITE;
1228 
1229  /* fact chunk is needed for non-pcm waveforms */
1230  if (This->lpFormat != NULL && This->cbFormat > sizeof(PCMWAVEFORMAT) &&
1231  This->lpFormat->wFormatTag != WAVE_FORMAT_PCM) {
1232  WAVEFORMATEX wfx;
1233  DWORD dwFactLength;
1234  HACMSTREAM has;
1235 
1236  /* try to open an appropriate audio codec to figure out
1237  * data for fact-chunk */
1239  if (acmFormatSuggest(NULL, This->lpFormat, &wfx,
1240  sizeof(wfx), ACM_FORMATSUGGESTF_WFORMATTAG)) {
1241  acmStreamOpen(&has, NULL, This->lpFormat, &wfx, NULL,
1243  acmStreamSize(has, This->ckData.cksize, &dwFactLength,
1245  dwFactLength /= wfx.nBlockAlign;
1246  acmStreamClose(has, 0);
1247 
1248  /* create the fact chunk */
1249  ck.ckid = ckidWAVEFACT;
1250  ck.cksize = sizeof(dwFactLength);
1251 
1252  /* test for enough space before data chunk */
1253  if (mmioSeek(This->hmmio, 0, SEEK_CUR) > This->ckData.dwDataOffset
1254  - ck.cksize - 4 * sizeof(DWORD))
1255  return AVIERR_FILEWRITE;
1256  if (mmioCreateChunk(This->hmmio, &ck, 0) != S_OK)
1257  return AVIERR_FILEWRITE;
1258  if (mmioWrite(This->hmmio, (HPSTR)&dwFactLength, ck.cksize) != ck.cksize)
1259  return AVIERR_FILEWRITE;
1260  if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
1261  return AVIERR_FILEWRITE;
1262  } else
1263  ERR(": fact chunk is needed for non-pcm files -- currently no codec found, so skipped!\n");
1264  }
1265 
1266  /* if there was extra stuff, we need to fill it with JUNK */
1267  if (mmioSeek(This->hmmio, 0, SEEK_CUR) + 2 * sizeof(DWORD) < This->ckData.dwDataOffset) {
1268  ck.ckid = ckidAVIPADDING;
1269  ck.cksize = 0;
1270  if (mmioCreateChunk(This->hmmio, &ck, 0) != S_OK)
1271  return AVIERR_FILEWRITE;
1272 
1273  if (mmioSeek(This->hmmio, This->ckData.dwDataOffset
1274  - 2 * sizeof(DWORD), SEEK_SET) == -1)
1275  return AVIERR_FILEWRITE;
1276  if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
1277  return AVIERR_FILEWRITE;
1278  }
1279 
1280  /* create the data chunk */
1281  ck.ckid = ckidWAVEDATA;
1282  ck.cksize = This->ckData.cksize;
1283  if (mmioCreateChunk(This->hmmio, &ck, 0) != S_OK)
1284  return AVIERR_FILEWRITE;
1285  if (mmioSeek(This->hmmio, This->ckData.cksize, SEEK_CUR) == -1)
1286  return AVIERR_FILEWRITE;
1287  if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
1288  return AVIERR_FILEWRITE;
1289 
1290  /* some optional extra chunks? */
1291  if (This->extra.lp != NULL && This->extra.cb > 0) {
1292  /* chunk headers are already in structure */
1293  if (mmioWrite(This->hmmio, This->extra.lp, This->extra.cb) != This->extra.cb)
1294  return AVIERR_FILEWRITE;
1295  }
1296 
1297  /* close RIFF chunk */
1298  if (mmioAscend(This->hmmio, &ckRIFF, 0) != S_OK)
1299  return AVIERR_FILEWRITE;
1300  if (mmioFlush(This->hmmio, 0) != S_OK)
1301  return AVIERR_FILEWRITE;
1302 
1303  return AVIERR_OK;
1304 }
MMRESULT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags)
Definition: mmio.c:960
#define SEEK_CUR
Definition: util.h:63
#define ckidAVIPADDING
Definition: vfw.h:916
MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags)
Definition: mmio.c:1204
#define ACM_FORMATSUGGESTF_WFORMATTAG
Definition: msacm.h:174
#define DWORD
Definition: nt_native.h:44
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:835
#define WAVE_FORMAT_PCM
Definition: constants.h:425
LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
Definition: mmio.c:781
smooth NULL
Definition: ftsmooth.c:416
FOURCC fccType
Definition: mmsystem.h:1509
#define SEEK_SET
Definition: jmemansi.c:26
#define ACM_STREAMSIZEF_SOURCE
Definition: msacm.h:217
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cksize
Definition: mmsystem.h:1508
#define AVIERR_FILEWRITE
Definition: vfw.h:1752
char * HPSTR
Definition: mmsystem.h:1477
MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO *lpck, UINT uFlags)
Definition: mmio.c:1238
#define formtypeWAVE
Definition: wavfile.c:42
#define ckidWAVEDATA
Definition: wavfile.c:45
#define AVIERR_OK
Definition: vfw.h:1740
#define MMIO_CREATERIFF
Definition: mmsystem.h:554
#define ERR(fmt,...)
Definition: debug.h:110
#define ckidWAVEFORMAT
Definition: wavfile.c:43
#define S_OK
Definition: intsafe.h:59
FOURCC ckid
Definition: mmsystem.h:1507
MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest)
Definition: format.c:746
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: stream.c:149
MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, LPDWORD pdwOutputBytes, DWORD fdwSize)
Definition: stream.c:394
#define ACM_STREAMOPENF_NONREALTIME
Definition: msacm.h:215
#define ckidWAVEFACT
Definition: wavfile.c:44
MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
Definition: stream.c:65

Referenced by IUnknown_fnRelease().

◆ IAVIFile_fnAddRef()

static ULONG WINAPI IAVIFile_fnAddRef ( IAVIFile iface)
static

Definition at line 209 of file wavfile.c.

210 {
212 
213  return IUnknown_AddRef(This->outer_unk);
214 }
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197

◆ IAVIFile_fnCreateStream()

static HRESULT WINAPI IAVIFile_fnCreateStream ( IAVIFile iface,
IAVIStream **  avis,
AVISTREAMINFOW asi 
)
static

Definition at line 281 of file wavfile.c.

283 {
285 
286  TRACE("(%p,%p,%p)\n", iface, avis, asi);
287 
288  /* check parameters */
289  if (avis == NULL || asi == NULL)
290  return AVIERR_BADPARAM;
291 
292  *avis = NULL;
293 
294  /* We only support one audio stream */
295  if (This->fInfo.dwStreams != 0 || This->lpFormat != NULL)
296  return AVIERR_UNSUPPORTED;
297  if (asi->fccType != streamtypeAUDIO)
298  return AVIERR_UNSUPPORTED;
299 
300  /* Does the user have write permission? */
301  if ((This->uMode & MMIO_RWMODE) == 0)
302  return AVIERR_READONLY;
303 
304  This->cbFormat = 0;
305  This->lpFormat = NULL;
306 
307  memcpy(&This->sInfo, asi, sizeof(This->sInfo));
308 
309  /* make sure streaminfo if okay for us */
310  This->sInfo.fccHandler = 0;
311  This->sInfo.dwFlags = 0;
313  This->sInfo.dwStart = 0;
314  This->sInfo.dwInitialFrames = 0;
315  This->sInfo.dwFormatChangeCount = 0;
316  SetRectEmpty(&This->sInfo.rcFrame);
317 
318  This->fInfo.dwStreams = 1;
319  This->fInfo.dwScale = This->sInfo.dwScale;
320  This->fInfo.dwRate = This->sInfo.dwRate;
321  This->fInfo.dwLength = This->sInfo.dwLength;
322 
323  This->ckData.dwDataOffset = 0;
324  This->ckData.cksize = 0;
325 
326  *avis = &This->IAVIStream_iface;
327  IAVIStream_AddRef(*avis);
328 
329  return AVIERR_OK;
330 }
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define AVIFILECAPS_CANREAD
Definition: vfw.h:1060
#define IAVIStream_AddRef(p)
Definition: vfw.h:1176
smooth NULL
Definition: ftsmooth.c:416
#define AVIFILECAPS_CANWRITE
Definition: vfw.h:1061
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743
#define TRACE(s)
Definition: solgame.cpp:4
#define streamtypeAUDIO
Definition: aviriff.h:93
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define AVIERR_OK
Definition: vfw.h:1740
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ IAVIFile_fnDeleteStream()

static HRESULT WINAPI IAVIFile_fnDeleteStream ( IAVIFile iface,
DWORD  fccType,
LONG  lParam 
)
static

Definition at line 372 of file wavfile.c.

373 {
375 
376  TRACE("(%p,0x%08X,%d)\n", iface, fccType, lParam);
377 
378  /* check parameter */
379  if (lParam < 0)
380  return AVIERR_BADPARAM;
381 
382  /* Do we have our audio stream? */
383  if (lParam != 0 || This->fInfo.dwStreams == 0 ||
384  (fccType != 0 && fccType != streamtypeAUDIO))
385  return AVIERR_NODATA;
386 
387  /* Have user write permissions? */
388  if ((This->uMode & MMIO_RWMODE) == 0)
389  return AVIERR_READONLY;
390 
391  HeapFree(GetProcessHeap(), 0, This->lpFormat);
392  This->lpFormat = NULL;
393  This->cbFormat = 0;
394 
395  /* update infos */
396  This->ckData.dwDataOffset = 0;
397  This->ckData.cksize = 0;
398 
399  This->sInfo.dwScale = 0;
400  This->sInfo.dwRate = 0;
401  This->sInfo.dwLength = 0;
402  This->sInfo.dwSuggestedBufferSize = 0;
403 
404  This->fInfo.dwStreams = 0;
405  This->fInfo.dwEditCount++;
406 
407  This->fDirty = TRUE;
408 
409  return AVIERR_OK;
410 }
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define AVIERR_NODATA
Definition: vfw.h:1757
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define streamtypeAUDIO
Definition: aviriff.h:93
#define AVIERR_OK
Definition: vfw.h:1740
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197
#define AVIERR_READONLY
Definition: vfw.h:1756
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ IAVIFile_fnEndRecord()

static HRESULT WINAPI IAVIFile_fnEndRecord ( IAVIFile iface)
static

Definition at line 362 of file wavfile.c.

363 {
364  TRACE("(%p)\n",iface);
365 
366  /* This is only needed for interleaved files.
367  * We have only one stream, which can't be interleaved.
368  */
369  return AVIERR_OK;
370 }
#define TRACE(s)
Definition: solgame.cpp:4
#define AVIERR_OK
Definition: vfw.h:1740

◆ IAVIFile_fnGetStream()

static HRESULT WINAPI IAVIFile_fnGetStream ( IAVIFile iface,
IAVIStream **  avis,
DWORD  fccType,
LONG  lParam 
)
static

Definition at line 256 of file wavfile.c.

258 {
260 
261  TRACE("(%p,%p,0x%08X,%d)\n", iface, avis, fccType, lParam);
262 
263  /* check parameter */
264  if (avis == NULL)
265  return AVIERR_BADPARAM;
266 
267  *avis = NULL;
268 
269  /* Does our stream exists? */
270  if (lParam != 0 || This->fInfo.dwStreams == 0)
271  return AVIERR_NODATA;
272  if (fccType != 0 && fccType != streamtypeAUDIO)
273  return AVIERR_NODATA;
274 
275  *avis = &This->IAVIStream_iface;
276  IAVIStream_AddRef(*avis);
277 
278  return AVIERR_OK;
279 }
#define AVIERR_NODATA
Definition: vfw.h:1757
#define IAVIStream_AddRef(p)
Definition: vfw.h:1176
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
#define streamtypeAUDIO
Definition: aviriff.h:93
#define AVIERR_OK
Definition: vfw.h:1740
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197
LPARAM lParam
Definition: combotst.c:139

◆ IAVIFile_fnInfo()

static HRESULT WINAPI IAVIFile_fnInfo ( IAVIFile iface,
AVIFILEINFOW afi,
LONG  size 
)
static

Definition at line 223 of file wavfile.c.

224 {
226 
227  TRACE("(%p,%p,%d)\n",iface,afi,size);
228 
229  if (afi == NULL)
230  return AVIERR_BADPARAM;
231  if (size < 0)
232  return AVIERR_BADSIZE;
233 
234  /* update file info */
235  This->fInfo.dwFlags = 0;
237  if (This->lpFormat != NULL) {
238  assert(This->sInfo.dwScale != 0);
239 
240  This->fInfo.dwStreams = 1;
241  This->fInfo.dwScale = This->sInfo.dwScale;
242  This->fInfo.dwRate = This->sInfo.dwRate;
243  This->fInfo.dwLength = This->sInfo.dwLength;
244  This->fInfo.dwSuggestedBufferSize = This->ckData.cksize;
245  This->fInfo.dwMaxBytesPerSec =
246  MulDiv(This->sInfo.dwSampleSize,This->sInfo.dwRate,This->sInfo.dwScale);
247  }
248 
249  memcpy(afi, &This->fInfo, min((DWORD)size, sizeof(This->fInfo)));
250 
251  if ((DWORD)size < sizeof(This->fInfo))
252  return AVIERR_BUFFERTOOSMALL;
253  return AVIERR_OK;
254 }
#define AVIFILECAPS_CANREAD
Definition: vfw.h:1060
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
#define AVIFILECAPS_CANWRITE
Definition: vfw.h:1061
#define AVIERR_BUFFERTOOSMALL
Definition: vfw.h:1758
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define AVIERR_BADSIZE
Definition: vfw.h:1749
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AVIERR_OK
Definition: vfw.h:1740
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197
#define min(a, b)
Definition: monoChain.cc:55
#define MulDiv(x, y, z)
Definition: gdifloat.h:86

◆ IAVIFile_fnQueryInterface()

static HRESULT WINAPI IAVIFile_fnQueryInterface ( IAVIFile iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 202 of file wavfile.c.

203 {
205 
206  return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
207 }
REFIID riid
Definition: precomp.h:44
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197

◆ IAVIFile_fnReadData()

static HRESULT WINAPI IAVIFile_fnReadData ( IAVIFile iface,
DWORD  ckid,
void lpData,
LONG size 
)
static

Definition at line 353 of file wavfile.c.

354 {
356 
357  TRACE("(%p,0x%08X,%p,%p)\n", iface, ckid, lpData, size);
358 
359  return ReadExtraChunk(&This->extra, ckid, lpData, size);
360 }
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HRESULT ReadExtraChunk(const EXTRACHUNKS *extra, FOURCC ckid, LPVOID lpData, LPLONG size)
Definition: extrachunk.c:32
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197

◆ IAVIFile_fnRelease()

static ULONG WINAPI IAVIFile_fnRelease ( IAVIFile iface)
static

Definition at line 216 of file wavfile.c.

217 {
219 
220  return IUnknown_Release(This->outer_unk);
221 }
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197

◆ IAVIFile_fnWriteData()

static HRESULT WINAPI IAVIFile_fnWriteData ( IAVIFile iface,
DWORD  ckid,
void lpData,
LONG  size 
)
static

Definition at line 332 of file wavfile.c.

333 {
335 
336  TRACE("(%p,0x%08X,%p,%d)\n", iface, ckid, lpData, size);
337 
338  /* check parameters */
339  if (lpData == NULL)
340  return AVIERR_BADPARAM;
341  if (size < 0)
342  return AVIERR_BADSIZE;
343 
344  /* Do we have write permission? */
345  if ((This->uMode & MMIO_RWMODE) == 0)
346  return AVIERR_READONLY;
347 
348  This->fDirty = TRUE;
349 
350  return WriteExtraChunk(&This->extra, ckid, lpData, size);
351 }
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define TRUE
Definition: types.h:120
HRESULT WriteExtraChunk(LPEXTRACHUNKS extra, FOURCC ckid, LPCVOID lpData, LONG size)
Definition: extrachunk.c:70
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define AVIERR_BADSIZE
Definition: vfw.h:1749
static IAVIFileImpl * impl_from_IAVIFile(IAVIFile *iface)
Definition: wavfile.c:197
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ IAVIStream_fnAddRef()

static ULONG WINAPI IAVIStream_fnAddRef ( IAVIStream iface)
static

Definition at line 609 of file wavfile.c.

610 {
612 
613  return IUnknown_AddRef(This->outer_unk);
614 }
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597

◆ IAVIStream_fnCreate()

static HRESULT WINAPI IAVIStream_fnCreate ( IAVIStream iface,
LPARAM  lParam1,
LPARAM  lParam2 
)
static

Definition at line 623 of file wavfile.c.

625 {
626  TRACE("(%p,0x%08lX,0x%08lX)\n", iface, lParam1, lParam2);
627 
628  /* This IAVIStream interface needs an WAVFile */
629  return AVIERR_UNSUPPORTED;
630 }
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743
#define TRACE(s)
Definition: solgame.cpp:4

◆ IAVIStream_fnDelete()

static HRESULT WINAPI IAVIStream_fnDelete ( IAVIStream iface,
LONG  start,
LONG  samples 
)
static

Definition at line 894 of file wavfile.c.

895 {
897 
898  TRACE("(%p,%d,%d)\n", iface, start, samples);
899 
900  /* check parameters */
901  if (start < 0 || samples < 0)
902  return AVIERR_BADPARAM;
903 
904  /* Delete before start of stream? */
905  if ((DWORD)(start + samples) < This->sInfo.dwStart)
906  return AVIERR_OK;
907 
908  /* Delete after end of stream? */
909  if ((DWORD)start > This->sInfo.dwLength)
910  return AVIERR_OK;
911 
912  /* For the rest we need write permissions */
913  if ((This->uMode & MMIO_RWMODE) == 0)
914  return AVIERR_READONLY;
915 
916  if ((DWORD)(start + samples) >= This->sInfo.dwLength) {
917  /* deletion at end */
918  samples = This->sInfo.dwLength - start;
919  This->sInfo.dwLength -= samples;
920  This->ckData.cksize -= samples * This->sInfo.dwSampleSize;
921  } else if ((DWORD)start <= This->sInfo.dwStart) {
922  /* deletion at start */
923  samples = This->sInfo.dwStart - start;
924  start = This->sInfo.dwStart;
925  This->ckData.dwDataOffset += samples * This->sInfo.dwSampleSize;
926  This->ckData.cksize -= samples * This->sInfo.dwSampleSize;
927  } else {
928  /* deletion inside stream -- needs playlist and cue's */
929  FIXME(": deletion inside of stream not supported!\n");
930 
931  return AVIERR_UNSUPPORTED;
932  }
933 
934  This->fDirty = TRUE;
935 
936  return AVIERR_OK;
937 }
GLsizei samples
Definition: glext.h:7006
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define AVIERR_OK
Definition: vfw.h:1740
GLuint start
Definition: gl.h:1545
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ IAVIStream_fnFindSample()

static LONG WINAPI IAVIStream_fnFindSample ( IAVIStream iface,
LONG  pos,
LONG  flags 
)
static

Definition at line 650 of file wavfile.c.

651 {
653 
654  TRACE("(%p,%d,0x%08X)\n",iface,pos,flags);
655 
656  /* Do we have data? */
657  if (This->lpFormat == NULL)
658  return -1;
659 
660  /* We don't have an index */
661  if (flags & FIND_INDEX)
662  return -1;
663 
664  if (flags & FIND_FROM_START) {
665  pos = This->sInfo.dwStart;
667  flags |= FIND_NEXT;
668  }
669 
670  if (flags & FIND_FORMAT) {
671  if ((flags & FIND_NEXT) && pos > 0)
672  pos = -1;
673  else
674  pos = 0;
675  }
676 
677  if ((flags & FIND_RET) == FIND_LENGTH ||
678  (flags & FIND_RET) == FIND_SIZE)
679  return This->sInfo.dwSampleSize;
680  if ((flags & FIND_RET) == FIND_OFFSET)
681  return This->ckData.dwDataOffset + pos * This->sInfo.dwSampleSize;
682 
683  return pos;
684 }
#define FIND_RET
Definition: vfw.h:1127
#define FIND_OFFSET
Definition: vfw.h:1130
#define FIND_INDEX
Definition: vfw.h:1132
#define FIND_NEXT
Definition: vfw.h:1118
#define FIND_PREV
Definition: vfw.h:1119
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define FIND_LENGTH
Definition: vfw.h:1129
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
#define FIND_FROM_START
Definition: vfw.h:1120
#define FIND_SIZE
Definition: vfw.h:1131
#define FIND_FORMAT
Definition: vfw.h:1125

◆ IAVIStream_fnInfo()

static HRESULT WINAPI IAVIStream_fnInfo ( IAVIStream iface,
AVISTREAMINFOW psi,
LONG  size 
)
static

Definition at line 632 of file wavfile.c.

633 {
635 
636  TRACE("(%p,%p,%d)\n", iface, psi, size);
637 
638  if (psi == NULL)
639  return AVIERR_BADPARAM;
640  if (size < 0)
641  return AVIERR_BADSIZE;
642 
643  memcpy(psi, &This->sInfo, min((DWORD)size, sizeof(This->sInfo)));
644 
645  if ((DWORD)size < sizeof(This->sInfo))
646  return AVIERR_BUFFERTOOSMALL;
647  return AVIERR_OK;
648 }
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BUFFERTOOSMALL
Definition: vfw.h:1758
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define AVIERR_BADSIZE
Definition: vfw.h:1749
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AVIERR_OK
Definition: vfw.h:1740
#define min(a, b)
Definition: monoChain.cc:55

◆ IAVIStream_fnQueryInterface()

static HRESULT WINAPI IAVIStream_fnQueryInterface ( IAVIStream iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 602 of file wavfile.c.

603 {
605 
606  return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
607 }
REFIID riid
Definition: precomp.h:44
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597

◆ IAVIStream_fnRead()

static HRESULT WINAPI IAVIStream_fnRead ( IAVIStream iface,
LONG  start,
LONG  samples,
void buffer,
LONG  buffersize,
LONG bytesread,
LONG samplesread 
)
static

Definition at line 769 of file wavfile.c.

771 {
773 
774  TRACE("(%p,%d,%d,%p,%d,%p,%p)\n", iface, start, samples, buffer,
775  buffersize, bytesread, samplesread);
776 
777  /* clear return parameters if given */
778  if (bytesread != NULL)
779  *bytesread = 0;
780  if (samplesread != NULL)
781  *samplesread = 0;
782 
783  /* positions without data */
784  if (start < 0 || (DWORD)start > This->sInfo.dwLength)
785  return AVIERR_OK;
786 
787  /* check samples */
788  if (samples < 0)
789  samples = 0;
790  if (buffersize > 0) {
791  if (samples > 0)
792  samples = min((DWORD)samples, buffersize / This->sInfo.dwSampleSize);
793  else
794  samples = buffersize / This->sInfo.dwSampleSize;
795  }
796 
797  /* limit to end of stream */
798  if ((DWORD)(start + samples) > This->sInfo.dwLength)
799  samples = This->sInfo.dwLength - start;
800 
801  /* request only the sizes? */
802  if (buffer == NULL || buffersize <= 0) {
803  /* then I need at least one parameter for it */
804  if (bytesread == NULL && samplesread == NULL)
805  return AVIERR_BADPARAM;
806 
807  if (bytesread != NULL)
808  *bytesread = samples * This->sInfo.dwSampleSize;
809  if (samplesread != NULL)
810  *samplesread = samples;
811 
812  return AVIERR_OK;
813  }
814 
815  /* nothing to read? */
816  if (samples == 0)
817  return AVIERR_OK;
818 
819  /* Can I read at least one sample? */
820  if ((DWORD)buffersize < This->sInfo.dwSampleSize)
821  return AVIERR_BUFFERTOOSMALL;
822 
823  buffersize = samples * This->sInfo.dwSampleSize;
824 
825  if (mmioSeek(This->hmmio, This->ckData.dwDataOffset
826  + start * This->sInfo.dwSampleSize, SEEK_SET) == -1)
827  return AVIERR_FILEREAD;
828  if (mmioRead(This->hmmio, buffer, buffersize) != buffersize)
829  return AVIERR_FILEREAD;
830 
831  /* fill out return parameters if given */
832  if (bytesread != NULL)
833  *bytesread = buffersize;
834  if (samplesread != NULL)
835  *samplesread = samples;
836 
837  return AVIERR_OK;
838 }
GLsizei samples
Definition: glext.h:7006
GLuint buffer
Definition: glext.h:5915
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:835
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BUFFERTOOSMALL
Definition: vfw.h:1758
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define SEEK_SET
Definition: jmemansi.c:26
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define AVIERR_OK
Definition: vfw.h:1740
GLuint start
Definition: gl.h:1545
#define min(a, b)
Definition: monoChain.cc:55
#define AVIERR_FILEREAD
Definition: vfw.h:1751
LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
Definition: mmio.c:732

◆ IAVIStream_fnReadData()

static HRESULT WINAPI IAVIStream_fnReadData ( IAVIStream iface,
DWORD  fcc,
void lp,
LONG lpread 
)
static

Definition at line 939 of file wavfile.c.

940 {
942 
943  return IAVIFile_ReadData(&This->IAVIFile_iface, fcc, lp, lpread);
944 }
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define IAVIFile_ReadData(p, a, b, c)
Definition: vfw.h:1610

◆ IAVIStream_fnReadFormat()

static HRESULT WINAPI IAVIStream_fnReadFormat ( IAVIStream iface,
LONG  pos,
void format,
LONG formatsize 
)
static

Definition at line 686 of file wavfile.c.

688 {
690 
691  TRACE("(%p,%d,%p,%p)\n", iface, pos, format, formatsize);
692 
693  if (formatsize == NULL)
694  return AVIERR_BADPARAM;
695 
696  /* only interested in needed buffersize? */
697  if (format == NULL || *formatsize <= 0) {
698  *formatsize = This->cbFormat;
699 
700  return AVIERR_OK;
701  }
702 
703  /* copy initial format (only as much as will fit) */
704  memcpy(format, This->lpFormat, min(*formatsize, This->cbFormat));
705  if (*formatsize < This->cbFormat) {
706  *formatsize = This->cbFormat;
707  return AVIERR_BUFFERTOOSMALL;
708  }
709 
710  *formatsize = This->cbFormat;
711  return AVIERR_OK;
712 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BUFFERTOOSMALL
Definition: vfw.h:1758
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AVIERR_OK
Definition: vfw.h:1740
#define min(a, b)
Definition: monoChain.cc:55

◆ IAVIStream_fnRelease()

static ULONG WINAPI IAVIStream_fnRelease ( IAVIStream iface)
static

Definition at line 616 of file wavfile.c.

617 {
619 
620  return IUnknown_Release(This->outer_unk);
621 }
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597

◆ IAVIStream_fnSetFormat()

static HRESULT WINAPI IAVIStream_fnSetFormat ( IAVIStream iface,
LONG  pos,
void format,
LONG  formatsize 
)
static

Definition at line 714 of file wavfile.c.

716 {
718 
719  TRACE("(%p,%d,%p,%d)\n", iface, pos, format, formatsize);
720 
721  /* check parameters */
722  if (format == NULL || formatsize <= sizeof(PCMWAVEFORMAT))
723  return AVIERR_BADPARAM;
724 
725  /* We can only do this to an empty wave file, but ignore call
726  * if still same format */
727  if (This->lpFormat != NULL) {
728  if (formatsize != This->cbFormat ||
729  memcmp(format, This->lpFormat, formatsize) != 0)
730  return AVIERR_UNSUPPORTED;
731 
732  return AVIERR_OK;
733  }
734 
735  /* only support start at position 0 */
736  if (pos != 0)
737  return AVIERR_UNSUPPORTED;
738 
739  /* Do we have write permission? */
740  if ((This->uMode & MMIO_RWMODE) == 0)
741  return AVIERR_READONLY;
742 
743  /* get memory for format and copy it */
744  This->lpFormat = HeapAlloc(GetProcessHeap(), 0, formatsize);
745  if (This->lpFormat == NULL)
746  return AVIERR_MEMORY;
747 
748  This->cbFormat = formatsize;
749  memcpy(This->lpFormat, format, formatsize);
750 
751  /* update info's about 'data' chunk */
752  This->ckData.dwDataOffset = formatsize + 7 * sizeof(DWORD);
753  This->ckData.cksize = 0;
754 
755  /* for non-pcm format we need also a 'fact' chunk */
756  if (This->lpFormat->wFormatTag != WAVE_FORMAT_PCM)
757  This->ckData.dwDataOffset += 3 * sizeof(DWORD);
758 
759  /* update stream and file info */
760  This->sInfo.dwSampleSize = This->lpFormat->nBlockAlign;
761  This->sInfo.dwScale = This->lpFormat->nBlockAlign;
762  This->sInfo.dwRate = This->lpFormat->nAvgBytesPerSec;
763  This->sInfo.dwLength = 0;
764  This->sInfo.dwSuggestedBufferSize = 0;
765 
766  return AVIERR_OK;
767 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define DWORD
Definition: nt_native.h:44
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define AVIERR_MEMORY
Definition: vfw.h:1745
#define WAVE_FORMAT_PCM
Definition: constants.h:425
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AVIERR_OK
Definition: vfw.h:1740
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ IAVIStream_fnSetInfo()

static HRESULT WINAPI IAVIStream_fnSetInfo ( IAVIStream iface,
LPAVISTREAMINFOW  info,
LONG  infolen 
)
static

Definition at line 953 of file wavfile.c.

955 {
956  FIXME("(%p,%p,%d): stub\n", iface, info, infolen);
957 
958  return E_FAIL;
959 }
#define E_FAIL
Definition: ddrawi.h:102
#define FIXME(fmt,...)
Definition: debug.h:111

◆ IAVIStream_fnWrite()

static HRESULT WINAPI IAVIStream_fnWrite ( IAVIStream iface,
LONG  start,
LONG  samples,
void buffer,
LONG  buffersize,
DWORD  flags,
LONG sampwritten,
LONG byteswritten 
)
static

Definition at line 840 of file wavfile.c.

842 {
844 
845  TRACE("(%p,%d,%d,%p,%d,0x%08X,%p,%p)\n", iface, start, samples,
846  buffer, buffersize, flags, sampwritten, byteswritten);
847 
848  /* clear return parameters if given */
849  if (sampwritten != NULL)
850  *sampwritten = 0;
851  if (byteswritten != NULL)
852  *byteswritten = 0;
853 
854  /* check parameters */
855  if (buffer == NULL && (buffersize > 0 || samples > 0))
856  return AVIERR_BADPARAM;
857 
858  /* Do we have write permission? */
859  if ((This->uMode & MMIO_RWMODE) == 0)
860  return AVIERR_READONLY;
861 
862  /* < 0 means "append" */
863  if (start < 0)
864  start = This->sInfo.dwStart + This->sInfo.dwLength;
865 
866  /* check buffersize -- must multiple of samplesize */
867  if (buffersize & ~(This->sInfo.dwSampleSize - 1))
868  return AVIERR_BADSIZE;
869 
870  /* do we have anything to write? */
871  if (buffer != NULL && buffersize > 0) {
872  This->fDirty = TRUE;
873 
874  if (mmioSeek(This->hmmio, This->ckData.dwDataOffset +
875  start * This->sInfo.dwSampleSize, SEEK_SET) == -1)
876  return AVIERR_FILEWRITE;
877  if (mmioWrite(This->hmmio, buffer, buffersize) != buffersize)
878  return AVIERR_FILEWRITE;
879 
880  This->sInfo.dwLength = max(This->sInfo.dwLength, (DWORD)start + samples);
881  This->ckData.cksize = max(This->ckData.cksize,
882  start * This->sInfo.dwSampleSize + buffersize);
883 
884  /* fill out return parameters if given */
885  if (sampwritten != NULL)
886  *sampwritten = samples;
887  if (byteswritten != NULL)
888  *byteswritten = buffersize;
889  }
890 
891  return AVIERR_OK;
892 }
GLsizei samples
Definition: glext.h:7006
#define max(a, b)
Definition: svc.c:63
#define MMIO_RWMODE
Definition: mmsystem.h:526
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:835
LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
Definition: mmio.c:781
smooth NULL
Definition: ftsmooth.c:416
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define SEEK_SET
Definition: jmemansi.c:26
#define TRACE(s)
Definition: solgame.cpp:4
#define AVIERR_BADSIZE
Definition: vfw.h:1749
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define AVIERR_FILEWRITE
Definition: vfw.h:1752
#define AVIERR_OK
Definition: vfw.h:1740
GLuint start
Definition: gl.h:1545
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ IAVIStream_fnWriteData()

static HRESULT WINAPI IAVIStream_fnWriteData ( IAVIStream iface,
DWORD  fcc,
void lp,
LONG  size 
)
static

Definition at line 946 of file wavfile.c.

947 {
949 
950  return IAVIFile_WriteData(&This->IAVIFile_iface, fcc, lp, size);
951 }
#define IAVIFile_WriteData(p, a, b, c)
Definition: vfw.h:1609
static IAVIFileImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: wavfile.c:597
GLsizeiptr size
Definition: glext.h:5919

◆ impl_from_IAVIFile()

static IAVIFileImpl* impl_from_IAVIFile ( IAVIFile iface)
inlinestatic

Definition at line 197 of file wavfile.c.

198 {
199  return CONTAINING_RECORD(iface, IAVIFileImpl, IAVIFile_iface);
200 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IAVIFile_fnAddRef(), IAVIFile_fnCreateStream(), IAVIFile_fnDeleteStream(), IAVIFile_fnGetStream(), IAVIFile_fnInfo(), IAVIFile_fnQueryInterface(), IAVIFile_fnReadData(), IAVIFile_fnRelease(), and IAVIFile_fnWriteData().

◆ impl_from_IAVIStream()

static IAVIFileImpl* impl_from_IAVIStream ( IAVIStream iface)
inlinestatic

Definition at line 597 of file wavfile.c.

598 {
599  return CONTAINING_RECORD(iface, IAVIFileImpl, IAVIStream_iface);
600 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IAVIStream_fnAddRef(), IAVIStream_fnDelete(), IAVIStream_fnFindSample(), IAVIStream_fnInfo(), IAVIStream_fnQueryInterface(), IAVIStream_fnRead(), IAVIStream_fnReadData(), IAVIStream_fnReadFormat(), IAVIStream_fnRelease(), IAVIStream_fnSetFormat(), IAVIStream_fnWrite(), and IAVIStream_fnWriteData().

◆ impl_from_IPersistFile()

static IAVIFileImpl* impl_from_IPersistFile ( IPersistFile iface)
inlinestatic

Definition at line 427 of file wavfile.c.

428 {
429  return CONTAINING_RECORD(iface, IAVIFileImpl, IPersistFile_iface);
430 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IPersistFile_fnAddRef(), IPersistFile_fnGetCurFile(), IPersistFile_fnIsDirty(), IPersistFile_fnLoad(), IPersistFile_fnQueryInterface(), and IPersistFile_fnRelease().

◆ impl_from_IUnknown()

static IAVIFileImpl* impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 120 of file wavfile.c.

121 {
122  return CONTAINING_RECORD(iface, IAVIFileImpl, IUnknown_inner);
123 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IUnknown_fnAddRef(), IUnknown_fnQueryInterface(), and IUnknown_fnRelease().

◆ IPersistFile_fnAddRef()

static ULONG WINAPI IPersistFile_fnAddRef ( IPersistFile iface)
static

Definition at line 440 of file wavfile.c.

441 {
443 
444  return IUnknown_AddRef(This->outer_unk);
445 }
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427

◆ IPersistFile_fnGetClassID()

static HRESULT WINAPI IPersistFile_fnGetClassID ( IPersistFile iface,
LPCLSID  pClassID 
)
static

Definition at line 454 of file wavfile.c.

456 {
457  TRACE("(%p,%p)\n", iface, pClassID);
458 
459  if (pClassID == NULL)
460  return AVIERR_BADPARAM;
461 
462  *pClassID = CLSID_WAVFile;
463 
464  return AVIERR_OK;
465 }
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
#define AVIERR_OK
Definition: vfw.h:1740

◆ IPersistFile_fnGetCurFile()

static HRESULT WINAPI IPersistFile_fnGetCurFile ( IPersistFile iface,
LPOLESTR ppszFileName 
)
static

Definition at line 559 of file wavfile.c.

560 {
562 
563  TRACE("(%p,%p)\n", iface, ppszFileName);
564 
565  if (ppszFileName == NULL)
566  return AVIERR_BADPARAM;
567 
568  *ppszFileName = NULL;
569 
570  if (This->szFileName) {
571  int len = lstrlenW(This->szFileName) + 1;
572 
573  *ppszFileName = CoTaskMemAlloc(len * sizeof(WCHAR));
574  if (*ppszFileName == NULL)
575  return AVIERR_MEMORY;
576 
577  lstrcpyW(*ppszFileName, This->szFileName);
578  }
579 
580  return AVIERR_OK;
581 }
#define lstrlenW
Definition: compat.h:498
#define AVIERR_MEMORY
Definition: vfw.h:1745
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
#define AVIERR_OK
Definition: vfw.h:1740
#define lstrcpyW
Definition: compat.h:497
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

◆ IPersistFile_fnIsDirty()

static HRESULT WINAPI IPersistFile_fnIsDirty ( IPersistFile iface)
static

Definition at line 467 of file wavfile.c.

468 {
470 
471  TRACE("(%p)\n", iface);
472 
473  return (This->fDirty ? S_OK : S_FALSE);
474 }
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427

◆ IPersistFile_fnLoad()

static HRESULT WINAPI IPersistFile_fnLoad ( IPersistFile iface,
LPCOLESTR  pszFileName,
DWORD  dwMode 
)
static

Definition at line 476 of file wavfile.c.

477 {
479  WCHAR wszStreamFmt[50];
480  INT len;
481 
482  TRACE("(%p,%s,0x%08X)\n", iface, debugstr_w(pszFileName), dwMode);
483 
484  /* check parameter */
485  if (pszFileName == NULL)
486  return AVIERR_BADPARAM;
487 
488  if (This->hmmio != NULL)
489  return AVIERR_ERROR; /* No reuse of this object for another file! */
490 
491  /* remember mode and name */
492  This->uMode = dwMode;
493 
494  len = lstrlenW(pszFileName) + 1;
495  This->szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
496  if (This->szFileName == NULL)
497  return AVIERR_MEMORY;
498  lstrcpyW(This->szFileName, pszFileName);
499 
500  /* try to open the file */
501  This->hmmio = mmioOpenW(This->szFileName, NULL, MMIO_ALLOCBUF | dwMode);
502  if (This->hmmio == NULL) {
503  /* mmioOpenW not in native DLLs of Win9x -- try mmioOpenA */
504  LPSTR szFileName;
505  len = WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1,
506  NULL, 0, NULL, NULL);
507  szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
508  if (szFileName == NULL)
509  return AVIERR_MEMORY;
510 
511  WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, szFileName,
512  len, NULL, NULL);
513 
514  This->hmmio = mmioOpenA(szFileName, NULL, MMIO_ALLOCBUF | dwMode);
515  HeapFree(GetProcessHeap(), 0, szFileName);
516  if (This->hmmio == NULL)
517  return AVIERR_FILEOPEN;
518  }
519 
520  memset(& This->fInfo, 0, sizeof(This->fInfo));
521  memset(& This->sInfo, 0, sizeof(This->sInfo));
522 
523  LoadStringW(AVIFILE_hModule, IDS_WAVEFILETYPE, This->fInfo.szFileType,
524  ARRAY_SIZE(This->fInfo.szFileType));
526  wszStreamFmt, ARRAY_SIZE(wszStreamFmt)) > 0) {
527  wsprintfW(This->sInfo.szName, wszStreamFmt,
528  AVIFILE_BasenameW(This->szFileName));
529  }
530 
531  /* should we create a new file? */
532  if (dwMode & OF_CREATE) {
533  /* nothing more to do */
534  return AVIERR_OK;
535  } else
536  return AVIFILE_LoadFile(This);
537 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MMIO_ALLOCBUF
Definition: mmsystem.h:532
#define IDS_WAVESTREAMFORMAT
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO *lpmmioinfo, DWORD dwOpenFlags)
Definition: mmio.c:669
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:498
HMMIO WINAPI mmioOpenA(LPSTR szFileName, MMIOINFO *lpmmioinfo, DWORD dwOpenFlags)
Definition: mmio.c:692
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define AVIERR_MEMORY
Definition: vfw.h:1745
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
smooth NULL
Definition: ftsmooth.c:416
#define AVIERR_BADPARAM
Definition: vfw.h:1748
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDS_WAVEFILETYPE
HMODULE AVIFILE_hModule
Definition: factory.c:39
GLenum GLsizei len
Definition: glext.h:6722
#define AVIERR_OK
Definition: vfw.h:1740
#define lstrcpyW
Definition: compat.h:497
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427
#define ARRAY_SIZE(a)
Definition: main.h:24
#define AVIERR_FILEOPEN
Definition: vfw.h:1753
#define OF_CREATE
Definition: winbase.h:125
LPCWSTR AVIFILE_BasenameW(LPCWSTR szFileName) DECLSPEC_HIDDEN
Definition: factory.c:162
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:483
static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
Definition: wavfile.c:1007
#define AVIERR_ERROR
Definition: vfw.h:1761

◆ IPersistFile_fnQueryInterface()

static HRESULT WINAPI IPersistFile_fnQueryInterface ( IPersistFile iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 432 of file wavfile.c.

434 {
436 
437  return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
438 }
REFIID riid
Definition: precomp.h:44
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427

◆ IPersistFile_fnRelease()

static ULONG WINAPI IPersistFile_fnRelease ( IPersistFile iface)
static

Definition at line 447 of file wavfile.c.

448 {
450 
451  return IUnknown_Release(This->outer_unk);
452 }
static IAVIFileImpl * impl_from_IPersistFile(IPersistFile *iface)
Definition: wavfile.c:427

◆ IPersistFile_fnSave()

static HRESULT WINAPI IPersistFile_fnSave ( IPersistFile iface,
LPCOLESTR  pszFileName,
BOOL  fRemember 
)
static

Definition at line 539 of file wavfile.c.

541 {
542  TRACE("(%p,%s,%d)\n", iface, debugstr_w(pszFileName), fRemember);
543 
544  /* We write directly to disk, so nothing to do. */
545 
546  return AVIERR_OK;
547 }
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
#define TRACE(s)
Definition: solgame.cpp:4
#define AVIERR_OK
Definition: vfw.h:1740

◆ IPersistFile_fnSaveCompleted()

static HRESULT WINAPI IPersistFile_fnSaveCompleted ( IPersistFile iface,
LPCOLESTR  pszFileName 
)
static

Definition at line 549 of file wavfile.c.

551 {
552  TRACE("(%p,%s)\n", iface, debugstr_w(pszFileName));
553 
554  /* We write directly to disk, so nothing to do. */
555 
556  return AVIERR_OK;
557 }
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
#define TRACE(s)
Definition: solgame.cpp:4
#define AVIERR_OK
Definition: vfw.h:1740

◆ IUnknown_fnAddRef()

static ULONG WINAPI IUnknown_fnAddRef ( IUnknown iface)
static

Definition at line 150 of file wavfile.c.

151 {
154 
155  TRACE("(%p) ref=%d\n", This, ref);
156 
157  return ref;
158 }
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static IAVIFileImpl * impl_from_IUnknown(IUnknown *iface)
Definition: wavfile.c:120
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ IUnknown_fnQueryInterface()

static HRESULT WINAPI IUnknown_fnQueryInterface ( IUnknown iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 125 of file wavfile.c.

126 {
128 
129  TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ret_iface);
130 
132  *ret_iface = &This->IUnknown_inner;
133  else if (IsEqualGUID(&IID_IAVIFile, riid))
134  *ret_iface = &This->IAVIFile_iface;
135  else if (IsEqualGUID(&IID_IAVIStream, riid))
136  *ret_iface = &This->IAVIStream_iface;
137  else if (IsEqualGUID(&IID_IPersistFile, riid))
138  *ret_iface = &This->IPersistFile_iface;
139  else {
140  WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ret_iface);
141  *ret_iface = NULL;
142  return E_NOINTERFACE;
143  }
144 
145  /* Violation of the COM aggregation ref counting rule */
146  IUnknown_AddRef(&This->IUnknown_inner);
147  return S_OK;
148 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static IAVIFileImpl * impl_from_IUnknown(IUnknown *iface)
Definition: wavfile.c:120
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
const GUID IID_IPersistFile

◆ IUnknown_fnRelease()

static ULONG WINAPI IUnknown_fnRelease ( IUnknown iface)
static

Definition at line 160 of file wavfile.c.

161 {
164 
165  TRACE("(%p) ref=%d\n", This, ref);
166 
167  if (!ref) {
168  /* need to write headers to file */
169  if (This->fDirty)
171 
172  HeapFree(GetProcessHeap(), 0, This->lpFormat);
173  This->lpFormat = NULL;
174  This->cbFormat = 0;
175  HeapFree(GetProcessHeap(), 0, This->extra.lp);
176  This->extra.lp = NULL;
177  This->extra.cb = 0;
178  HeapFree(GetProcessHeap(), 0, This->szFileName);
179  This->szFileName = NULL;
180  if (This->hmmio) {
181  mmioClose(This->hmmio, 0);
182  This->hmmio = NULL;
183  }
185  }
186 
187  return ref;
188 }
MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
Definition: mmio.c:701
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
static IAVIFileImpl * impl_from_IUnknown(IUnknown *iface)
Definition: wavfile.c:120
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
static HRESULT AVIFILE_SaveFile(const IAVIFileImpl *This)
Definition: wavfile.c:1204
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( avifile  )

Variable Documentation

◆ iwavft

const struct IAVIFileVtbl iwavft
static
Initial value:
= {
}
static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface, IAVIStream **avis, AVISTREAMINFOW *asi)
Definition: wavfile.c:281
static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, void *lpData, LONG *size)
Definition: wavfile.c:353
static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, void *lpData, LONG size)
Definition: wavfile.c:332
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
Definition: wavfile.c:216
static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, IAVIStream **avis, DWORD fccType, LONG lParam)
Definition: wavfile.c:256
static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface)
Definition: wavfile.c:209
static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, LONG lParam)
Definition: wavfile.c:372
static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile *iface)
Definition: wavfile.c:362
static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, AVIFILEINFOW *afi, LONG size)
Definition: wavfile.c:223
static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile *iface, REFIID riid, void **ret_iface)
Definition: wavfile.c:202

Definition at line 412 of file wavfile.c.

Referenced by AVIFILE_CreateWAVFile().

◆ iwavpft

const struct IPersistFileVtbl iwavpft
static
Initial value:
= {
}
static ULONG WINAPI IPersistFile_fnRelease(IPersistFile *iface)
Definition: wavfile.c:447
static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
Definition: wavfile.c:549
static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile *iface)
Definition: wavfile.c:467
static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, LPOLESTR *ppszFileName)
Definition: wavfile.c:559
static HRESULT WINAPI IPersistFile_fnSave(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
Definition: wavfile.c:539
static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
Definition: wavfile.c:476
static HRESULT WINAPI IPersistFile_fnQueryInterface(IPersistFile *iface, REFIID riid, void **ret_iface)
Definition: wavfile.c:432
static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile *iface, LPCLSID pClassID)
Definition: wavfile.c:454
static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile *iface)
Definition: wavfile.c:440

Definition at line 583 of file wavfile.c.

Referenced by AVIFILE_CreateWAVFile().

◆ iwavst

const struct IAVIStreamVtbl iwavst
static
Initial value:
= {
}
static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, REFIID riid, void **ret_iface)
Definition: wavfile.c:602
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1, LPARAM lParam2)
Definition: wavfile.c:623
static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface, AVISTREAMINFOW *psi, LONG size)
Definition: wavfile.c:632
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream *iface)
Definition: wavfile.c:616
static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void *format, LONG formatsize)
Definition: wavfile.c:714
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, void *format, LONG *formatsize)
Definition: wavfile.c:686
static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, void *lp, LONG *lpread)
Definition: wavfile.c:939
static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, LONG flags)
Definition: wavfile.c:650
static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream *iface, LPAVISTREAMINFOW info, LONG infolen)
Definition: wavfile.c:953
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface)
Definition: wavfile.c:609
static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, void *lp, LONG size)
Definition: wavfile.c:946
static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, LONG samples)
Definition: wavfile.c:894
static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, LONG samples, void *buffer, LONG buffersize, LONG *bytesread, LONG *samplesread)
Definition: wavfile.c:769
static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, LONG samples, void *buffer, LONG buffersize, DWORD flags, LONG *sampwritten, LONG *byteswritten)
Definition: wavfile.c:840

Definition at line 961 of file wavfile.c.

Referenced by AVIFILE_CreateWAVFile().

◆ unk_vtbl

const IUnknownVtbl unk_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface)
Definition: wavfile.c:160
static HRESULT WINAPI IUnknown_fnQueryInterface(IUnknown *iface, REFIID riid, void **ret_iface)
Definition: wavfile.c:125
static ULONG WINAPI IUnknown_fnAddRef(IUnknown *iface)
Definition: wavfile.c:150

Definition at line 190 of file wavfile.c.

Referenced by AVIFILE_CreateWAVFile().