ReactOS 0.4.15-dev-7958-gcd0bb1a
msgsm32.c File Reference
#include "config.h"
#include <wine/port.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "mmsystem.h"
#include "mmreg.h"
#include "msacm.h"
#include "msacmdrv.h"
#include "wine/library.h"
#include "wine/debug.h"
Include dependency graph for msgsm32.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gsm)
 
static LRESULT GSM_drvFree (void)
 
static LRESULT GSM_DriverDetails (PACMDRIVERDETAILSW add)
 
static BOOL GSM_FormatValidate (const WAVEFORMATEX *wfx)
 
static LRESULT GSM_FormatTagDetails (PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
 
static LRESULT GSM_FormatDetails (PACMFORMATDETAILSW afd, DWORD dwQuery)
 
static LRESULT GSM_FormatSuggest (PACMDRVFORMATSUGGEST adfs)
 
LRESULT CALLBACK GSM_DriverProc (DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, LPARAM dwParam1, LPARAM dwParam2)
 

Variables

static const DWORD gsm_rates [] = { 8000, 11025, 22050, 44100, 48000, 96000 }
 

Function Documentation

◆ GSM_DriverDetails()

static LRESULT GSM_DriverDetails ( PACMDRIVERDETAILSW  add)
static

Definition at line 114 of file msgsm32.c.

115{
118 /* Details found from probing native msgsm32.acm */
119 add->wMid = MM_MICROSOFT;
121 add->vdwACM = 0x3320000;
122 add->vdwDriver = 0x4000000;
124 add->cFormatTags = 2;
125 add->cFilterTags = 0;
126 add->hicon = NULL;
127 MultiByteToWideChar( CP_ACP, 0, "Microsoft GSM 6.10", -1,
128 add->szShortName, ARRAY_SIZE( add->szShortName ));
129 MultiByteToWideChar( CP_ACP, 0, "Wine GSM 6.10 libgsm codec", -1,
130 add->szLongName, ARRAY_SIZE( add->szLongName ));
131 MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1,
132 add->szCopyright, ARRAY_SIZE( add->szCopyright ));
133 MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1,
134 add->szLicensing, ARRAY_SIZE( add->szLicensing ));
135 add->szFeatures[0] = 0;
136 return MMSYSERR_NOERROR;
137}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
#define MM_MSFT_ACM_GSM610
Definition: mmreg.h:148
#define MM_MICROSOFT
Definition: mmreg.h:144
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define ACMDRIVERDETAILS_FCCCOMP_UNDEFINED
Definition: msacm.h:59
#define ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC
Definition: msacm.h:58
#define ACMDRIVERDETAILS_SUPPORTF_CODEC
Definition: msacm.h:61
DWORD cFilterTags
Definition: msacm.h:311
WCHAR szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS]
Definition: msacm.h:317
WCHAR szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS]
Definition: msacm.h:316
WCHAR szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS]
Definition: msacm.h:315
FOURCC fccComp
Definition: msacm.h:301
WCHAR szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS]
Definition: msacm.h:318
FOURCC fccType
Definition: msacm.h:300
WCHAR szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS]
Definition: msacm.h:319
DWORD cFormatTags
Definition: msacm.h:310
DWORD fdwSupport
Definition: msacm.h:309
DWORD vdwDriver
Definition: msacm.h:307

Referenced by GSM_DriverProc().

◆ GSM_DriverProc()

LRESULT CALLBACK GSM_DriverProc ( DWORD_PTR  dwDevID,
HDRVR  hDriv,
UINT  wMsg,
LPARAM  dwParam1,
LPARAM  dwParam2 
)

Definition at line 572 of file msgsm32.c.

574{
575 TRACE("(%08lx %p %04x %08lx %08lx);\n",
576 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
577
578 switch (wMsg)
579 {
580 case DRV_LOAD: return 1;
581 case DRV_FREE: return GSM_drvFree();
582 case DRV_OPEN: return 1;
583 case DRV_CLOSE: return 1;
584 case DRV_ENABLE: return 1;
585 case DRV_DISABLE: return 1;
586 case DRV_QUERYCONFIGURE: return 1;
587 case DRV_CONFIGURE: MessageBoxA(0, "GSM 06.10 codec", "Wine Driver", MB_OK); return 1;
588 case DRV_INSTALL: return DRVCNF_RESTART;
589 case DRV_REMOVE: return DRVCNF_RESTART;
590
592 /* no caching from other ACM drivers is done so far */
593 return MMSYSERR_NOERROR;
594
596 return GSM_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
597
599 return GSM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
600
602 return GSM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
603
605 return GSM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
606
607#ifdef SONAME_LIBGSM
609 return GSM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
610
612 return GSM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
613
615 return GSM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
616
618 return GSM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
619#else
620 case ACMDM_STREAM_OPEN: WARN("libgsm support not compiled in!\n");
625#endif
626
629 /* this converter is not a hardware driver */
632 /* this converter is not a filter */
634 /* only needed for asynchronous driver... we aren't, so just say it */
638 /* nothing special to do here... so don't do anything */
639 return MMSYSERR_NOERROR;
640
641 default:
642 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
643 }
644}
#define WARN(fmt,...)
Definition: debug.h:112
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:554
#define DRV_LOAD(x)
#define DRV_CLOSE
Definition: mmsystem.h:122
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define DRVCNF_RESTART
Definition: mmsystem.h:135
#define DRV_REMOVE
Definition: mmsystem.h:128
#define DRV_ENABLE
Definition: mmsystem.h:120
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define DRV_OPEN
Definition: mmsystem.h:121
#define DRV_INSTALL
Definition: mmsystem.h:127
#define DRV_FREE
Definition: mmsystem.h:124
#define DRV_DISABLE
Definition: mmsystem.h:123
#define ACMDM_STREAM_PREPARE
Definition: msacmdrv.h:63
#define ACMDM_STREAM_CLOSE
Definition: msacmdrv.h:59
#define ACMDM_STREAM_CONVERT
Definition: msacmdrv.h:61
#define ACMDM_FORMAT_SUGGEST
Definition: msacmdrv.h:53
#define ACMDM_FILTER_DETAILS
Definition: msacmdrv.h:56
#define ACMDM_HARDWARE_WAVE_CAPS_INPUT
Definition: msacmdrv.h:48
#define ACMDM_DRIVER_NOTIFY
Definition: msacmdrv.h:45
#define ACMDM_FORMAT_DETAILS
Definition: msacmdrv.h:52
#define ACMDM_STREAM_SIZE
Definition: msacmdrv.h:60
#define ACMDM_FILTERTAG_DETAILS
Definition: msacmdrv.h:55
#define ACMDM_HARDWARE_WAVE_CAPS_OUTPUT
Definition: msacmdrv.h:49
#define ACMDM_FORMATTAG_DETAILS
Definition: msacmdrv.h:51
#define ACMDM_STREAM_UNPREPARE
Definition: msacmdrv.h:64
#define ACMDM_STREAM_OPEN
Definition: msacmdrv.h:58
#define ACMDM_DRIVER_DETAILS
Definition: msacmdrv.h:46
#define ACMDM_STREAM_RESET
Definition: msacmdrv.h:62
static LRESULT GSM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
Definition: msgsm32.c:260
static LRESULT GSM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
Definition: msgsm32.c:207
static LRESULT GSM_DriverDetails(PACMDRIVERDETAILSW add)
Definition: msgsm32.c:114
static LRESULT GSM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
Definition: msgsm32.c:308
static LRESULT GSM_drvFree(void)
Definition: msgsm32.c:103
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790

◆ GSM_drvFree()

static LRESULT GSM_drvFree ( void  )
static

Definition at line 103 of file msgsm32.c.

104{
105 return 1;
106}

Referenced by GSM_DriverProc().

◆ GSM_FormatDetails()

static LRESULT GSM_FormatDetails ( PACMFORMATDETAILSW  afd,
DWORD  dwQuery 
)
static

Definition at line 260 of file msgsm32.c.

261{
262 switch (dwQuery)
263 {
265 if (!GSM_FormatValidate(afd->pwfx)) return ACMERR_NOTPOSSIBLE;
266 break;
268 afd->pwfx->wFormatTag = afd->dwFormatTag;
269 switch (afd->dwFormatTag)
270 {
271 case WAVE_FORMAT_PCM:
273 afd->pwfx->nChannels = 1;
275 afd->pwfx->wBitsPerSample = 16;
276 afd->pwfx->nBlockAlign = 2;
278 break;
281 afd->pwfx->nChannels = 1;
283 afd->pwfx->wBitsPerSample = 0;
284 afd->pwfx->nBlockAlign = 65;
285 afd->pwfx->nAvgBytesPerSec = afd->pwfx->nSamplesPerSec * 65 / 320;
286 afd->pwfx->cbSize = sizeof(WORD);
287 ((GSM610WAVEFORMAT*)afd->pwfx)->wSamplesPerBlock = 320;
288 break;
289 default:
290 WARN("Unsupported tag %08x\n", afd->dwFormatTag);
291 return MMSYSERR_INVALPARAM;
292 }
293 break;
294 default:
295 WARN("Unsupported query %08x\n", dwQuery);
297 }
299 afd->szFormat[0] = 0; /* let MSACM format this for us... */
300
301 return MMSYSERR_NOERROR;
302}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
unsigned short WORD
Definition: ntddk_ex.h:93
#define WAVE_FORMAT_GSM610
Definition: mmreg.h:118
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define ACMERR_NOTPOSSIBLE
Definition: msacm.h:36
#define ACM_FORMATDETAILSF_FORMAT
Definition: msacm.h:161
#define ACM_FORMATDETAILSF_INDEX
Definition: msacm.h:160
static BOOL GSM_FormatValidate(const WAVEFORMATEX *wfx)
Definition: msgsm32.c:140
static const DWORD gsm_rates[]
Definition: msgsm32.c:201
WCHAR szFormat[ACMFORMATDETAILS_FORMAT_CHARS]
Definition: msacm.h:509
DWORD dwFormatTag
Definition: msacm.h:505
DWORD dwFormatIndex
Definition: msacm.h:504
DWORD fdwSupport
Definition: msacm.h:506
PWAVEFORMATEX pwfx
Definition: msacm.h:507
WORD nBlockAlign
Definition: mmreg.h:82
WORD cbSize
Definition: mmreg.h:84
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nChannels
Definition: mmreg.h:79
WORD wFormatTag
Definition: mmreg.h:78
WORD wBitsPerSample
Definition: mmreg.h:83

Referenced by GSM_DriverProc().

◆ GSM_FormatSuggest()

static LRESULT GSM_FormatSuggest ( PACMDRVFORMATSUGGEST  adfs)
static

Definition at line 308 of file msgsm32.c.

309{
310 /* some tests ... */
311 if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
312 adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
314 /* FIXME: should do those tests against the real size (according to format tag */
315
316 /* If no suggestion for destination, then copy source value */
318 adfs->pwfxDst->nChannels = adfs->pwfxSrc->nChannels;
321
323 {
324 if (adfs->pwfxSrc->wFormatTag == WAVE_FORMAT_PCM)
325 adfs->pwfxDst->wBitsPerSample = 0;
326 else
327 adfs->pwfxDst->wBitsPerSample = 16;
328 }
330 {
331 switch (adfs->pwfxSrc->wFormatTag)
332 {
335 }
336 }
337
338 /* recompute other values */
339 switch (adfs->pwfxDst->wFormatTag)
340 {
341 case WAVE_FORMAT_PCM:
342 adfs->pwfxDst->nBlockAlign = 2;
343 adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * 2;
344 break;
346 if (adfs->pwfxDst->cbSize < sizeof(WORD))
347 return ACMERR_NOTPOSSIBLE;
348 adfs->pwfxDst->nBlockAlign = 65;
349 adfs->pwfxDst->nAvgBytesPerSec = adfs->pwfxDst->nSamplesPerSec * 65 / 320;
350 ((GSM610WAVEFORMAT*)adfs->pwfxDst)->wSamplesPerBlock = 320;
351 break;
352 default:
353 return ACMERR_NOTPOSSIBLE;
354 }
355
356 /* check if result is ok */
358 return MMSYSERR_NOERROR;
359}
#define ACM_FORMATSUGGESTF_WFORMATTAG
Definition: msacm.h:174
#define ACM_FORMATSUGGESTF_NCHANNELS
Definition: msacm.h:175
#define ACM_FORMATSUGGESTF_WBITSPERSAMPLE
Definition: msacm.h:177
#define ACM_FORMATSUGGESTF_NSAMPLESPERSEC
Definition: msacm.h:176
PWAVEFORMATEX pwfxSrc
Definition: msacmdrv.h:151
PWAVEFORMATEX pwfxDst
Definition: msacmdrv.h:153

Referenced by GSM_DriverProc().

◆ GSM_FormatTagDetails()

static LRESULT GSM_FormatTagDetails ( PACMFORMATTAGDETAILSW  aftd,
DWORD  dwQuery 
)
static

Definition at line 207 of file msgsm32.c.

208{
209 static const WCHAR szPcm[]={'P','C','M',0};
210 static const WCHAR szGsm[]={'G','S','M',' ','6','.','1','0',0};
211
212 switch (dwQuery)
213 {
215 if (aftd->dwFormatTagIndex > 1) return ACMERR_NOTPOSSIBLE;
216 break;
218 if (aftd->dwFormatTag == WAVE_FORMAT_UNKNOWN)
219 {
220 aftd->dwFormatTagIndex = 1;
221 break;
222 }
223 /* fall through */
225 switch (aftd->dwFormatTag)
226 {
227 case WAVE_FORMAT_PCM: aftd->dwFormatTagIndex = 0; break;
228 case WAVE_FORMAT_GSM610: aftd->dwFormatTagIndex = 1; break;
229 default: return ACMERR_NOTPOSSIBLE;
230 }
231 break;
232 default:
233 WARN("Unsupported query %08x\n", dwQuery);
235 }
236
238 switch (aftd->dwFormatTagIndex)
239 {
240 case 0:
242 aftd->cbFormatSize = sizeof(PCMWAVEFORMAT);
244 lstrcpyW(aftd->szFormatTag, szPcm);
245 break;
246 case 1:
248 aftd->cbFormatSize = sizeof(GSM610WAVEFORMAT);
250 lstrcpyW(aftd->szFormatTag, szGsm);
251 break;
252 }
253 return MMSYSERR_NOERROR;
254}
#define lstrcpyW
Definition: compat.h:749
#define WAVE_FORMAT_UNKNOWN
Definition: mmreg.h:95
struct gsm610waveformat_tag GSM610WAVEFORMAT
struct pcmwaveformat_tag PCMWAVEFORMAT
#define ACM_FORMATTAGDETAILSF_FORMATTAG
Definition: msacm.h:183
#define ACM_FORMATTAGDETAILSF_LARGESTSIZE
Definition: msacm.h:184
#define ACM_FORMATTAGDETAILSF_INDEX
Definition: msacm.h:182
WCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS]
Definition: msacm.h:535
DWORD dwFormatTagIndex
Definition: msacm.h:530
DWORD cStandardFormats
Definition: msacm.h:534
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GSM_DriverProc().

◆ GSM_FormatValidate()

static BOOL GSM_FormatValidate ( const WAVEFORMATEX wfx)
static

Definition at line 140 of file msgsm32.c.

141{
142 if (wfx->nChannels != 1)
143 return FALSE;
144
145 switch (wfx->wFormatTag)
146 {
147 case WAVE_FORMAT_PCM:
148 if (wfx->wBitsPerSample != 16)
149 {
150 WARN("PCM wBitsPerSample %u\n", wfx->wBitsPerSample);
151 return FALSE;
152 }
153 if (wfx->nBlockAlign != 2)
154 {
155 WARN("PCM nBlockAlign %u\n", wfx->nBlockAlign);
156 return FALSE;
157 }
158 if (wfx->nAvgBytesPerSec != wfx->nBlockAlign * wfx->nSamplesPerSec)
159 {
160 WARN("PCM nAvgBytesPerSec %u/%u\n",
161 wfx->nAvgBytesPerSec,
162 wfx->nBlockAlign * wfx->nSamplesPerSec);
163 return FALSE;
164 }
165 return TRUE;
167 if (wfx->cbSize < sizeof(WORD))
168 {
169 WARN("GSM cbSize %u\n", wfx->cbSize);
170 return FALSE;
171 }
172 if (wfx->wBitsPerSample != 0)
173 {
174 WARN("GSM wBitsPerSample %u\n", wfx->wBitsPerSample);
175 return FALSE;
176 }
177 if (wfx->nBlockAlign != 65)
178 {
179 WARN("GSM nBlockAlign %u\n", wfx->nBlockAlign);
180 return FALSE;
181 }
182 if (((const GSM610WAVEFORMAT*)wfx)->wSamplesPerBlock != 320)
183 {
184 WARN("GSM wSamplesPerBlock %u\n",
185 ((const GSM610WAVEFORMAT*)wfx)->wSamplesPerBlock);
186 return FALSE;
187 }
188 if (wfx->nAvgBytesPerSec != wfx->nSamplesPerSec * 65 / 320)
189 {
190 WARN("GSM nAvgBytesPerSec %d / %d\n",
191 wfx->nAvgBytesPerSec, wfx->nSamplesPerSec * 65 / 320);
192 return FALSE;
193 }
194 return TRUE;
195 default:
196 return FALSE;
197 }
198 return FALSE;
199}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42

Referenced by GSM_FormatDetails(), and GSM_FormatSuggest().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( gsm  )

Variable Documentation

◆ gsm_rates

const DWORD gsm_rates[] = { 8000, 11025, 22050, 44100, 48000, 96000 }
static

Definition at line 201 of file msgsm32.c.

Referenced by GSM_FormatDetails(), and GSM_FormatTagDetails().