ReactOS  0.4.14-dev-358-gbef841c
stream.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/debug.h"
#include "mmsystem.h"
#include "mmreg.h"
#include "msacm.h"
#include "msacmdrv.h"
#include "wineacm.h"
Include dependency graph for stream.c:

Go to the source code of this file.

Macros

#define NOBITMAP
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msacm)
 
static PWINE_ACMSTREAM ACM_GetStream (HACMSTREAM has)
 
static BOOL ACM_ValidatePointers (PACMDRVSTREAMHEADER padsh)
 
MMRESULT WINAPI acmStreamClose (HACMSTREAM has, DWORD fdwClose)
 
MMRESULT WINAPI acmStreamConvert (HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwConvert)
 
MMRESULT WINAPI acmStreamMessage (HACMSTREAM has, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
 
MMRESULT WINAPI acmStreamOpen (PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
 
MMRESULT WINAPI acmStreamPrepareHeader (HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwPrepare)
 
MMRESULT WINAPI acmStreamReset (HACMSTREAM has, DWORD fdwReset)
 
MMRESULT WINAPI acmStreamSize (HACMSTREAM has, DWORD cbInput, LPDWORD pdwOutputBytes, DWORD fdwSize)
 
MMRESULT WINAPI acmStreamUnprepareHeader (HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare)
 

Macro Definition Documentation

◆ NOBITMAP

#define NOBITMAP

Definition at line 38 of file stream.c.

Function Documentation

◆ ACM_GetStream()

static PWINE_ACMSTREAM ACM_GetStream ( HACMSTREAM  has)
static

Definition at line 46 of file stream.c.

47 {
48  TRACE("(%p)\n", has);
49 
50  return (PWINE_ACMSTREAM)has;
51 }
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by acmStreamClose(), acmStreamConvert(), acmStreamPrepareHeader(), acmStreamReset(), acmStreamSize(), and acmStreamUnprepareHeader().

◆ ACM_ValidatePointers()

static BOOL ACM_ValidatePointers ( PACMDRVSTREAMHEADER  padsh)
static

Definition at line 53 of file stream.c.

54 {
55  /* check that pointers have not been modified */
56  return !(padsh->pbPreparedSrc != padsh->pbSrc ||
57  padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
58  padsh->pbPreparedDst != padsh->pbDst ||
59  padsh->cbPreparedDstLength < padsh->cbDstLength);
60 }
LPBYTE pbPreparedSrc
Definition: msacmdrv.h:133
DWORD cbPreparedSrcLength
Definition: msacmdrv.h:134
DWORD cbPreparedDstLength
Definition: msacmdrv.h:136
LPBYTE pbPreparedDst
Definition: msacmdrv.h:135

Referenced by acmStreamConvert(), and acmStreamUnprepareHeader().

◆ acmStreamClose()

MMRESULT WINAPI acmStreamClose ( HACMSTREAM  has,
DWORD  fdwClose 
)

Definition at line 65 of file stream.c.

66 {
67  PWINE_ACMSTREAM was;
68  MMRESULT ret;
69 
70  TRACE("(%p, %d)\n", has, fdwClose);
71 
72  if ((was = ACM_GetStream(has)) == NULL) {
73  WARN("invalid handle\n");
74  return MMSYSERR_INVALHANDLE;
75  }
76  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_CLOSE, (LPARAM)&was->drvInst, 0);
77  if (ret == MMSYSERR_NOERROR) {
78  if (was->hAcmDriver)
79  acmDriverClose(was->hAcmDriver, 0L);
80  HeapFree(MSACM_hHeap, 0, was);
81  }
82  TRACE("=> (%d)\n", ret);
83  return ret;
84 }
#define WARN(fmt,...)
Definition: debug.h:111
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define ACMDM_STREAM_CLOSE
Definition: msacmdrv.h:59
MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
Definition: driver.c:179
HACMDRIVER hAcmDriver
Definition: wineacm.h:83
HANDLE MSACM_hHeap
Definition: internal.c:47
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
int ret
static const WCHAR L[]
Definition: oid.c:1250
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by ACMStream_fnRelease(), ACMWrapper_BreakConnect(), AVIFILE_SaveFile(), audio_resampler_acm::close(), test_convert(), test_mp3(), test_prepareheader(), widClose(), widOpenHelper(), wodClose(), and wodOpenHelper().

◆ acmStreamConvert()

MMRESULT WINAPI acmStreamConvert ( HACMSTREAM  has,
PACMSTREAMHEADER  pash,
DWORD  fdwConvert 
)

Definition at line 89 of file stream.c.

91 {
92  PWINE_ACMSTREAM was;
94  PACMDRVSTREAMHEADER padsh;
95 
96  TRACE("(%p, %p, %d)\n", has, pash, fdwConvert);
97 
98  if ((was = ACM_GetStream(has)) == NULL) {
99  WARN("invalid handle\n");
100  return MMSYSERR_INVALHANDLE;
101  }
102  if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
103  WARN("invalid parameter\n");
104  return MMSYSERR_INVALPARAM;
105  }
107  WARN("unprepared header\n");
108  return ACMERR_UNPREPARED;
109  }
110 
111  pash->cbSrcLengthUsed = 0;
112  pash->cbDstLengthUsed = 0;
113 
114  /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
115  * size. some fields are private to msacm internals, and are exposed
116  * in ACMSTREAMHEADER in the dwReservedDriver array
117  */
118  padsh = (PACMDRVSTREAMHEADER)pash;
119 
120  if (!ACM_ValidatePointers(padsh)) {
121  WARN("invalid parameter\n");
122  return MMSYSERR_INVALPARAM;
123  }
124 
125  padsh->fdwConvert = fdwConvert;
126 
127  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_CONVERT, (LPARAM)&was->drvInst, (LPARAM)padsh);
128  if (ret == MMSYSERR_NOERROR) {
130  }
131  TRACE("=> (%d)\n", ret);
132  return ret;
133 }
static BOOL ACM_ValidatePointers(PACMDRVSTREAMHEADER padsh)
Definition: stream.c:53
#define ACMERR_UNPREPARED
Definition: msacm.h:38
#define WARN(fmt,...)
Definition: debug.h:111
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
DWORD cbSrcLengthUsed
Definition: msacm.h:555
#define ACMSTREAMHEADER_STATUSF_DONE
Definition: msacm.h:209
DWORD cbDstLengthUsed
Definition: msacm.h:559
#define ACMDM_STREAM_CONVERT
Definition: msacmdrv.h:61
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD cbStruct
Definition: msacm.h:550
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
int ret
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
DWORD fdwStatus
Definition: msacm.h:551
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define ACMSTREAMHEADER_STATUSF_PREPARED
Definition: msacm.h:210
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
struct _ACMDRVSTREAMHEADER * PACMDRVSTREAMHEADER
Definition: msacmdrv.h:111

Referenced by ACMStream_fnRead(), ACMStream_fnWrite(), ACMWrapper_Receive(), audio_resampler_acm::audio_receive(), test_convert(), test_prepareheader(), widCallback(), and wodWrite().

◆ acmStreamMessage()

MMRESULT WINAPI acmStreamMessage ( HACMSTREAM  has,
UINT  uMsg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 138 of file stream.c.

140 {
141  FIXME("(%p, %u, %ld, %ld): stub\n", has, uMsg, lParam1, lParam2);
143  return MMSYSERR_ERROR;
144 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define SetLastError(x)
Definition: compat.h:417
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ acmStreamOpen()

MMRESULT WINAPI acmStreamOpen ( PHACMSTREAM  phas,
HACMDRIVER  had,
PWAVEFORMATEX  pwfxSrc,
PWAVEFORMATEX  pwfxDst,
PWAVEFILTER  pwfltr,
DWORD_PTR  dwCallback,
DWORD_PTR  dwInstance,
DWORD  fdwOpen 
)

Definition at line 149 of file stream.c.

153 {
154  PWINE_ACMSTREAM was;
155  PWINE_ACMDRIVER wad;
156  MMRESULT ret;
157  int wfxSrcSize;
158  int wfxDstSize;
159  WAVEFORMATEX wfxSrc, wfxDst;
160 
161  TRACE("(%p, %p, %p, %p, %p, %ld, %ld, %d)\n",
162  phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
163 
164  /* NOTE: pwfxSrc and/or pwfxDst can point to a structure smaller than
165  * WAVEFORMATEX so don't use them directly when not sure */
166  if (pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) {
167  memcpy(&wfxSrc, pwfxSrc, sizeof(PCMWAVEFORMAT));
168  wfxSrc.wBitsPerSample = pwfxSrc->wBitsPerSample;
169  wfxSrc.cbSize = 0;
170  pwfxSrc = &wfxSrc;
171  }
172 
173  if (pwfxDst->wFormatTag == WAVE_FORMAT_PCM) {
174  memcpy(&wfxDst, pwfxDst, sizeof(PCMWAVEFORMAT));
175  wfxDst.wBitsPerSample = pwfxDst->wBitsPerSample;
176  wfxDst.cbSize = 0;
177  pwfxDst = &wfxDst;
178  }
179 
180  TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
181  pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
182  pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
183 
184  TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
185  pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
186  pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
187 
188  /* (WS) In query mode, phas should be NULL. If it is not, then instead
189  * of returning an error we are making sure it is NULL, preventing some
190  * applications that pass garbage for phas from crashing.
191  */
192  if (fdwOpen & ACM_STREAMOPENF_QUERY) phas = NULL;
193 
194  if (pwfltr && (pwfxSrc->wFormatTag != pwfxDst->wFormatTag)) {
195  WARN("invalid parameter\n");
196  return MMSYSERR_INVALPARAM;
197  }
198 
199  wfxSrcSize = wfxDstSize = sizeof(WAVEFORMATEX);
200  if (pwfxSrc->wFormatTag != WAVE_FORMAT_PCM) wfxSrcSize += pwfxSrc->cbSize;
201  if (pwfxDst->wFormatTag != WAVE_FORMAT_PCM) wfxDstSize += pwfxDst->cbSize;
202 
203  was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize +
204  ((pwfltr) ? sizeof(WAVEFILTER) : 0));
205  if (was == NULL) {
206  WARN("no memory\n");
207  return MMSYSERR_NOMEM;
208  }
209 
210  was->drvInst.cbStruct = sizeof(was->drvInst);
211  was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
212  memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
213  was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
214  memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
215  if (pwfltr) {
216  was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
217  memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
218  } else {
219  was->drvInst.pwfltr = NULL;
220  }
221  was->drvInst.dwCallback = dwCallback;
222  was->drvInst.dwInstance = dwInstance;
223  was->drvInst.fdwOpen = fdwOpen;
224  was->drvInst.fdwDriver = 0L;
225  was->drvInst.dwDriver = 0L;
226  /* real value will be stored once ACMDM_STREAM_OPEN succeeds */
227  was->drvInst.has = 0L;
228 
229  if (had) {
230  if (!(wad = MSACM_GetDriver(had))) {
232  goto errCleanUp;
233  }
234 
236  was->obj.pACMDriverID = wad->obj.pACMDriverID;
237  was->pDrv = wad;
238  was->hAcmDriver = 0; /* not to close it in acmStreamClose */
239 
240  ret = MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_OPEN, (LPARAM)&was->drvInst, 0L);
241  if (ret != MMSYSERR_NOERROR)
242  goto errCleanUp;
243  } else {
244  PWINE_ACMDRIVERID wadi;
245 
247  for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
249  !MSACM_FindFormatTagInCache(wadi, pwfxSrc->wFormatTag, NULL) ||
250  !MSACM_FindFormatTagInCache(wadi, pwfxDst->wFormatTag, NULL))
251  continue;
252  ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
253  if (ret != MMSYSERR_NOERROR)
254  continue;
255  if ((wad = MSACM_GetDriver(had)) != 0) {
257  was->obj.pACMDriverID = wad->obj.pACMDriverID;
258  was->pDrv = wad;
259  was->hAcmDriver = had;
260 
261  ret = MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_OPEN, (LPARAM)&was->drvInst, 0L);
262  TRACE("%s => %08x\n", debugstr_w(wadi->pszDriverAlias), ret);
263  if (ret == MMSYSERR_NOERROR) {
264  if (fdwOpen & ACM_STREAMOPENF_QUERY) {
265  MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_CLOSE, (LPARAM)&was->drvInst, 0);
266  acmDriverClose(had, 0L);
267  }
268  break;
269  }
270  }
271  /* no match, close this acm driver and try next one */
272  acmDriverClose(had, 0L);
273  }
274  if (ret != MMSYSERR_NOERROR) {
276  goto errCleanUp;
277  }
278  }
280  was->drvInst.has = (HACMSTREAM)was;
281  if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
282  if (phas)
283  *phas = (HACMSTREAM)was;
284  TRACE("=> (%d)\n", ret);
285  return ret;
286  }
287 errCleanUp:
288  if (phas)
289  *phas = NULL;
290  HeapFree(MSACM_hHeap, 0, was);
291  TRACE("=> (%d)\n", ret);
292  return ret;
293 }
PWAVEFILTER pwfltr
Definition: msacmdrv.h:102
DWORD fdwSupport
Definition: wineacm.h:98
DWORD_PTR dwInstance
Definition: msacmdrv.h:104
WINE_ACMOBJ obj
Definition: wineacm.h:88
struct _WAVEFORMATEX * PWAVEFORMATEX
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
WORD nChannels
Definition: mmreg.h:79
#define WARN(fmt,...)
Definition: debug.h:111
PWINE_ACMDRIVERID pACMDriverID
Definition: wineacm.h:45
DWORD dwType
Definition: wineacm.h:44
UINT MMRESULT
Definition: mmsystem.h:962
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
#define ACMDM_STREAM_OPEN
Definition: msacmdrv.h:58
char * LPSTR
Definition: xmlstorage.h:182
#define ACMDM_STREAM_CLOSE
Definition: msacmdrv.h:59
BOOL MSACM_FindFormatTagInCache(const WINE_ACMDRIVERID *padid, DWORD fmtTag, LPDWORD idx)
Definition: internal.c:118
MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
Definition: driver.c:179
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define WAVE_FORMAT_PCM
Definition: constants.h:425
HACMDRIVER hAcmDriver
Definition: wineacm.h:83
#define debugstr_w
Definition: kernel32.h:32
WORD wBitsPerSample
Definition: audioclient.idl:45
HANDLE MSACM_hHeap
Definition: internal.c:47
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
WINE_ACMOBJ obj
Definition: wineacm.h:80
PWINE_ACMDRIVERID pNextACMDriverID
Definition: wineacm.h:93
PWAVEFORMATEX pwfxDst
Definition: msacmdrv.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LPWSTR pszDriverAlias
Definition: wineacm.h:89
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
Definition: driver.c:491
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
Definition: internal.c:844
WORD wFormatTag
Definition: mmreg.h:78
int ret
static const WCHAR L[]
Definition: oid.c:1250
WINE_ACMOBJ obj
Definition: wineacm.h:71
PWINE_ACMDRIVERID MSACM_pFirstACMDriverID
Definition: internal.c:48
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ACMERR_NOTPOSSIBLE
Definition: msacm.h:36
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
WORD cbSize
Definition: mmreg.h:84
#define WINE_ACMOBJ_STREAM
Definition: wineacm.h:38
DWORD_PTR dwDriver
Definition: msacmdrv.h:107
struct _WAVEFILTER * PWAVEFILTER
#define ACMDRIVERDETAILS_SUPPORTF_DISABLED
Definition: msacm.h:67
DWORD nSamplesPerSec
Definition: mmreg.h:80
DWORD_PTR dwCallback
Definition: msacmdrv.h:103
WORD nBlockAlign
Definition: mmreg.h:82
WORD wBitsPerSample
Definition: mmreg.h:83
PWAVEFORMATEX pwfxSrc
Definition: msacmdrv.h:100
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
#define ACM_STREAMOPENF_QUERY
Definition: msacm.h:213
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by ACMWrapper_CompleteConnect(), ACMWrapper_SetMediaType(), AVIFILE_OpenCompressor(), AVIFILE_SaveFile(), audio_resampler_acm::open(), test_convert(), test_mp3(), test_prepareheader(), widOpenHelper(), and wodOpenHelper().

◆ acmStreamPrepareHeader()

MMRESULT WINAPI acmStreamPrepareHeader ( HACMSTREAM  has,
PACMSTREAMHEADER  pash,
DWORD  fdwPrepare 
)

Definition at line 299 of file stream.c.

301 {
302  PWINE_ACMSTREAM was;
304  PACMDRVSTREAMHEADER padsh;
305 
306  TRACE("(%p, %p, %d)\n", has, pash, fdwPrepare);
307 
308  if ((was = ACM_GetStream(has)) == NULL) {
309  WARN("invalid handle\n");
310  return MMSYSERR_INVALHANDLE;
311  }
312  if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
313  WARN("invalid parameter\n");
314  return MMSYSERR_INVALPARAM;
315  }
316  if (fdwPrepare) {
317  WARN("invalid use of reserved parameter\n");
318  return MMSYSERR_INVALFLAG;
319  }
322  pash->cbSrcLength < was->drvInst.pwfxSrc->nBlockAlign) {
323  WARN("source smaller than block align (%d < %d)\n",
324  pash->cbSrcLength, was->drvInst.pwfxSrc->nBlockAlign);
326  }
327 
328  /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
329  * size. some fields are private to msacm internals, and are exposed
330  * in ACMSTREAMHEADER in the dwReservedDriver array
331  */
332  padsh = (PACMDRVSTREAMHEADER)pash;
333 
334  padsh->fdwConvert = fdwPrepare;
335  padsh->padshNext = NULL;
336  padsh->fdwDriver = padsh->dwDriver = 0L;
337 
338  padsh->fdwPrepared = 0;
339  padsh->dwPrepared = 0;
340  padsh->pbPreparedSrc = 0;
341  padsh->cbPreparedSrcLength = 0;
342  padsh->pbPreparedDst = 0;
343  padsh->cbPreparedDstLength = 0;
344 
345  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_PREPARE, (LPARAM)&was->drvInst, (LPARAM)padsh);
350  padsh->fdwPrepared = padsh->fdwStatus;
351  padsh->dwPrepared = 0;
352  padsh->pbPreparedSrc = padsh->pbSrc;
353  padsh->cbPreparedSrcLength = padsh->cbSrcLength;
354  padsh->pbPreparedDst = padsh->pbDst;
355  padsh->cbPreparedDstLength = padsh->cbDstLength;
356  } else {
357  padsh->fdwPrepared = 0;
358  padsh->dwPrepared = 0;
359  padsh->pbPreparedSrc = 0;
360  padsh->cbPreparedSrcLength = 0;
361  padsh->pbPreparedDst = 0;
362  padsh->cbPreparedDstLength = 0;
363  }
364  TRACE("=> (%d)\n", ret);
365  return ret;
366 }
#define WARN(fmt,...)
Definition: debug.h:111
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define ACMDM_STREAM_PREPARE
Definition: msacmdrv.h:63
DWORD cbSrcLength
Definition: msacm.h:554
#define ACMSTREAMHEADER_STATUSF_INQUEUE
Definition: msacm.h:211
#define WAVE_FORMAT_PCM
Definition: constants.h:425
DWORD_PTR dwPrepared
Definition: msacmdrv.h:132
PACMDRVSTREAMHEADER * padshNext
Definition: msacmdrv.h:126
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD cbStruct
Definition: msacm.h:550
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
WORD wFormatTag
Definition: mmreg.h:78
int ret
static const WCHAR L[]
Definition: oid.c:1250
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
#define ACMERR_NOTPOSSIBLE
Definition: msacm.h:36
#define WAVE_FORMAT_ADPCM
Definition: constants.h:426
LPBYTE pbPreparedSrc
Definition: msacmdrv.h:133
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
DWORD cbPreparedSrcLength
Definition: msacmdrv.h:134
WORD nBlockAlign
Definition: mmreg.h:82
DWORD cbPreparedDstLength
Definition: msacmdrv.h:136
#define ACMSTREAMHEADER_STATUSF_PREPARED
Definition: msacm.h:210
LPBYTE pbPreparedDst
Definition: msacmdrv.h:135
PWAVEFORMATEX pwfxSrc
Definition: msacmdrv.h:100
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
struct _ACMDRVSTREAMHEADER * PACMDRVSTREAMHEADER
Definition: msacmdrv.h:111
DWORD_PTR dwDriver
Definition: msacmdrv.h:128

Referenced by ACMStream_fnRead(), ACMStream_fnWrite(), ACMWrapper_Receive(), audio_resampler_acm::open(), test_convert(), test_prepareheader(), widPrepare(), and wodPrepare().

◆ acmStreamReset()

MMRESULT WINAPI acmStreamReset ( HACMSTREAM  has,
DWORD  fdwReset 
)

Definition at line 371 of file stream.c.

372 {
373  PWINE_ACMSTREAM was;
375 
376  TRACE("(%p, %d)\n", has, fdwReset);
377 
378  if (fdwReset) {
379  WARN("invalid flag\n");
381  } else if ((was = ACM_GetStream(has)) == NULL) {
382  WARN("invalid handle\n");
383  return MMSYSERR_INVALHANDLE;
384  } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
385  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_RESET, (LPARAM)&was->drvInst, 0);
386  }
387  TRACE("=> (%d)\n", ret);
388  return ret;
389 }
#define WARN(fmt,...)
Definition: debug.h:111
#define ACMDM_STREAM_RESET
Definition: msacmdrv.h:62
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
#define ACM_STREAMOPENF_ASYNC
Definition: msacm.h:214
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
int ret
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81

◆ acmStreamSize()

MMRESULT WINAPI acmStreamSize ( HACMSTREAM  has,
DWORD  cbInput,
LPDWORD  pdwOutputBytes,
DWORD  fdwSize 
)

Definition at line 394 of file stream.c.

396 {
397  PWINE_ACMSTREAM was;
398  ACMDRVSTREAMSIZE adss;
399  MMRESULT ret;
400 
401  TRACE("(%p, %d, %p, %d)\n", has, cbInput, pdwOutputBytes, fdwSize);
402 
403  if ((was = ACM_GetStream(has)) == NULL) {
404  WARN("invalid handle\n");
405  return MMSYSERR_INVALHANDLE;
406  }
407  if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
408  WARN("invalid flag\n");
409  return MMSYSERR_INVALFLAG;
410  }
411 
412  *pdwOutputBytes = 0L;
413 
414  switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
416  adss.cbDstLength = cbInput;
417  adss.cbSrcLength = 0;
418  break;
420  adss.cbSrcLength = cbInput;
421  adss.cbDstLength = 0;
422  break;
423  default:
424  WARN("invalid flag\n");
425  return MMSYSERR_INVALFLAG;
426  }
427 
428  adss.cbStruct = sizeof(adss);
429  adss.fdwSize = fdwSize;
430  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_SIZE,
431  (LPARAM)&was->drvInst, (LPARAM)&adss);
432  if (ret == MMSYSERR_NOERROR) {
433  switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
435  *pdwOutputBytes = adss.cbSrcLength;
436  break;
438  *pdwOutputBytes = adss.cbDstLength;
439  break;
440  }
441  }
442  TRACE("=> (%d) [%u]\n", ret, *pdwOutputBytes);
443  return ret;
444 }
#define ACM_STREAMSIZEF_DESTINATION
Definition: msacm.h:218
#define ACM_STREAMSIZEF_QUERYMASK
Definition: msacm.h:219
#define WARN(fmt,...)
Definition: debug.h:111
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define ACM_STREAMSIZEF_SOURCE
Definition: msacm.h:217
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
int ret
static const WCHAR L[]
Definition: oid.c:1250
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
#define ACMDM_STREAM_SIZE
Definition: msacmdrv.h:60

Referenced by AVIFILE_SaveFile(), audio_resampler_acm::open(), test_mp3(), widPrepare(), and wodPrepare().

◆ acmStreamUnprepareHeader()

MMRESULT WINAPI acmStreamUnprepareHeader ( HACMSTREAM  has,
PACMSTREAMHEADER  pash,
DWORD  fdwUnprepare 
)

Definition at line 449 of file stream.c.

451 {
452  PWINE_ACMSTREAM was;
454  PACMDRVSTREAMHEADER padsh;
455 
456  TRACE("(%p, %p, %d)\n", has, pash, fdwUnprepare);
457 
458  if ((was = ACM_GetStream(has)) == NULL) {
459  WARN("invalid handle\n");
460  return MMSYSERR_INVALHANDLE;
461  }
462  if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
463  WARN("invalid parameter\n");
464  return MMSYSERR_INVALPARAM;
465  }
467  WARN("unprepared header\n");
468  return ACMERR_UNPREPARED;
469  }
470 
471  /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
472  * size. some fields are private to msacm internals, and are exposed
473  * in ACMSTREAMHEADER in the dwReservedDriver array
474  */
475  padsh = (PACMDRVSTREAMHEADER)pash;
476 
477  if (!ACM_ValidatePointers(padsh)) {
478  WARN("invalid parameter\n");
479  return MMSYSERR_INVALPARAM;
480  }
481 
482  padsh->fdwConvert = fdwUnprepare;
483 
484  ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_UNPREPARE, (LPARAM)&was->drvInst, (LPARAM)padsh);
488  }
489  TRACE("=> (%d)\n", ret);
490  return ret;
491 }
static BOOL ACM_ValidatePointers(PACMDRVSTREAMHEADER padsh)
Definition: stream.c:53
#define ACMERR_UNPREPARED
Definition: msacm.h:38
#define WARN(fmt,...)
Definition: debug.h:111
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define ACMSTREAMHEADER_STATUSF_INQUEUE
Definition: msacm.h:211
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD cbStruct
Definition: msacm.h:550
#define TRACE(s)
Definition: solgame.cpp:4
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
ACMDRVSTREAMINSTANCE drvInst
Definition: wineacm.h:82
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: internal.c:872
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
int ret
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
Definition: stream.c:46
#define ACMDM_STREAM_UNPREPARE
Definition: msacmdrv.h:64
DWORD fdwStatus
Definition: msacm.h:551
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define ACMSTREAMHEADER_STATUSF_PREPARED
Definition: msacm.h:210
PWINE_ACMDRIVER pDrv
Definition: wineacm.h:81
struct _ACMDRVSTREAMHEADER * PACMDRVSTREAMHEADER
Definition: msacmdrv.h:111

Referenced by ACMStream_fnRelease(), ACMWrapper_Receive(), audio_resampler_acm::close(), test_convert(), test_prepareheader(), widUnprepare(), and wodUnprepare().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msacm  )