msacm32: Convert acmFormatChoose internals to Unicode, implement acmFormatChoose[AW] on top of it.

This commit is contained in:
Eric Pouech 2012-08-12 10:03:41 +02:00 committed by Alexandre Julliard
parent 03ab4bea9c
commit 22789aa30e
1 changed files with 125 additions and 56 deletions

View File

@ -1,5 +1,3 @@
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/*
* MSACM32 library
*
@ -45,13 +43,13 @@ struct MSACM_FillFormatData {
#define WINE_ACMFF_FORMAT 1
#define WINE_ACMFF_WFX 2
int mode;
char szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
PACMFORMATCHOOSEA afc;
WCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
PACMFORMATCHOOSEW afc;
DWORD ret;
};
static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
PACMFORMATTAGDETAILSA paftd,
PACMFORMATTAGDETAILSW paftd,
DWORD_PTR dwInstance,
DWORD fdwSupport)
{
@ -59,21 +57,21 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
switch (affd->mode) {
case WINE_ACMFF_TAG:
if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
if (SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_FINDSTRINGEXACT, -1,
(LPARAM)paftd->szFormatTag) == CB_ERR)
SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_ADDSTRING, 0, (LPARAM)paftd->szFormatTag);
break;
case WINE_ACMFF_FORMAT:
if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) {
HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
ACMFORMATDETAILSA afd;
ACMFORMATDETAILSW afd;
unsigned int i, len;
MMRESULT mmr;
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
WCHAR buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
afd.cbStruct = sizeof(afd);
afd.dwFormatTag = paftd->dwFormatTag;
@ -84,42 +82,45 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
afd.cbwfx = paftd->cbFormatSize;
for (i = 0; i < paftd->cStandardFormats; i++) {
static const WCHAR fmtW[] = {'%','d',' ','K','o','/','s','\0'};
int j;
afd.dwFormatIndex = i;
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
mmr = acmFormatDetailsW(had, &afd, ACM_FORMATDETAILSF_INDEX);
if (mmr == MMSYSERR_NOERROR) {
lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
len = strlen(buffer);
memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len);
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
"%d Ko/s",
(afd.pwfx->nAvgBytesPerSec + 512) / 1024);
SendDlgItemMessageA(affd->hWnd,
lstrcpynW(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
len = strlenW(buffer);
for (j = len; j < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; j++)
buffer[j] = ' ';
wsprintfW(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
fmtW, (afd.pwfx->nAvgBytesPerSec + 512) / 1024);
SendDlgItemMessageW(affd->hWnd,
IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_ADDSTRING, 0, (LPARAM)buffer);
}
}
acmDriverClose(had, 0);
SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_SETCURSEL, 0, 0);
HeapFree(MSACM_hHeap, 0, afd.pwfx);
}
}
break;
case WINE_ACMFF_WFX:
if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) {
HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
ACMFORMATDETAILSA afd;
ACMFORMATDETAILSW afd;
afd.cbStruct = sizeof(afd);
afd.dwFormatTag = paftd->dwFormatTag;
afd.pwfx = affd->afc->pwfx;
afd.cbwfx = affd->afc->cbwfx;
afd.dwFormatIndex = SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
afd.dwFormatIndex = SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_GETCURSEL, 0, 0);
affd->ret = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
affd->ret = acmFormatDetailsW(had, &afd, ACM_FORMATDETAILSF_INDEX);
acmDriverClose(had, 0);
return TRUE;
}
@ -134,7 +135,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
static BOOL MSACM_FillFormatTags(HWND hWnd)
{
ACMFORMATTAGDETAILSA aftd;
ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd;
memset(&aftd, 0, sizeof(aftd));
@ -143,37 +144,37 @@ static BOOL MSACM_FillFormatTags(HWND hWnd)
affd.hWnd = hWnd;
affd.mode = WINE_ACMFF_TAG;
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, CB_SETCURSEL, 0, 0);
acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, CB_SETCURSEL, 0, 0);
return TRUE;
}
static BOOL MSACM_FillFormat(HWND hWnd)
{
ACMFORMATTAGDETAILSA aftd;
ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0);
memset(&aftd, 0, sizeof(aftd));
aftd.cbStruct = sizeof(aftd);
affd.hWnd = hWnd;
affd.mode = WINE_ACMFF_FORMAT;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETLBTEXT,
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETCURSEL, 0, 0),
(LPARAM)affd.szFormatTag);
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0);
acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0);
return TRUE;
}
static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc)
static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEW afc)
{
ACMFORMATTAGDETAILSA aftd;
ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd;
memset(&aftd, 0, sizeof(aftd));
@ -183,29 +184,29 @@ static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc)
affd.mode = WINE_ACMFF_WFX;
affd.afc = afc;
affd.ret = MMSYSERR_NOERROR;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETLBTEXT,
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETCURSEL, 0, 0),
(LPARAM)affd.szFormatTag);
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
return affd.ret;
}
static const char* fmt_prop = "acmprop";
static const WCHAR fmt_prop[] = {'a','c','m','p','r','o','p','\0'};
static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
PACMFORMATCHOOSEA afc = (PACMFORMATCHOOSEA)GetPropA(hWnd, fmt_prop);
PACMFORMATCHOOSEW afc = (PACMFORMATCHOOSEW)GetPropW(hWnd, fmt_prop);
TRACE("hwnd=%p msg=%i 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam);
switch (msg) {
case WM_INITDIALOG:
afc = (PACMFORMATCHOOSEA)lParam;
SetPropA(hWnd, fmt_prop, (HANDLE)afc);
afc = (PACMFORMATCHOOSEW)lParam;
SetPropW(hWnd, fmt_prop, (HANDLE)afc);
MSACM_FillFormatTags(hWnd);
MSACM_FillFormat(hWnd);
if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP|
@ -236,8 +237,8 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
break;
case IDD_ACMFORMATCHOOSE_BTN_HELP:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP)
SendMessageA(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGSTRINGA), 0L, 0L);
SendMessageW(afc->hwndOwner,
RegisterWindowMessageW(ACMHELPMSGSTRINGW), 0L, 0L);
break;
default:
@ -248,15 +249,15 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
break;
case WM_CONTEXTMENU:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
SendMessageA(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA),
SendMessageW(afc->hwndOwner,
RegisterWindowMessageW(ACMHELPMSGCONTEXTMENUW),
wParam, lParam);
break;
#if defined(WM_CONTEXTHELP)
case WM_CONTEXTHELP:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
SendMessageA(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA),
SendMessageW(afc->hwndOwner,
RegisterWindowMessageW(ACMHELPMSGCONTEXTHELPW),
wParam, lParam);
break;
#endif
@ -273,8 +274,77 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
*/
MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc)
{
return DialogBoxParamA(MSACM_hInstance32, MAKEINTRESOURCEA(DLG_ACMFORMATCHOOSE_ID),
pafmtc->hwndOwner, FormatChooseDlgProc, (LPARAM)pafmtc);
ACMFORMATCHOOSEW afcw;
MMRESULT ret;
LPWSTR title = NULL;
LPWSTR name = NULL;
LPWSTR templ = NULL;
DWORD sz;
afcw.cbStruct = sizeof(afcw);
afcw.fdwStyle = pafmtc->fdwStyle;
afcw.hwndOwner = pafmtc->hwndOwner;
afcw.pwfx = pafmtc->pwfx;
afcw.cbwfx = pafmtc->cbwfx;
if (pafmtc->pszTitle)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTitle, -1, NULL, 0);
if (!(title = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTitle, -1, title, sz);
}
afcw.pszTitle = title;
if (pafmtc->pszName)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszName, -1, NULL, 0);
if (!(name = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszName, -1, name, sz);
}
afcw.pszName = name;
afcw.cchName = pafmtc->cchName;
afcw.fdwEnum = pafmtc->fdwEnum;
afcw.pwfxEnum = pafmtc->pwfxEnum;
afcw.hInstance = pafmtc->hInstance;
if (pafmtc->pszTemplateName)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTemplateName, -1, NULL, 0);
if (!(templ = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTemplateName, -1, templ, sz);
}
afcw.pszTemplateName = templ;
/* FIXME: hook procs not supported yet */
if (pafmtc->pfnHook)
{
FIXME("Unsupported hook procs\n");
ret = MMSYSERR_NOTSUPPORTED;
goto done;
}
ret = acmFormatChooseW(&afcw);
if (ret == MMSYSERR_NOERROR)
{
WideCharToMultiByte(CP_ACP, 0, afcw.szFormatTag, -1, pafmtc->szFormatTag, sizeof(pafmtc->szFormatTag),
NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, afcw.szFormat, -1, pafmtc->szFormat, sizeof(pafmtc->szFormat),
NULL, NULL);
if (pafmtc->pszName)
WideCharToMultiByte(CP_ACP, 0, afcw.pszName, -1, pafmtc->pszName, pafmtc->cchName, NULL, NULL);
}
done:
HeapFree(GetProcessHeap(), 0, title);
HeapFree(GetProcessHeap(), 0, name);
HeapFree(GetProcessHeap(), 0, templ);
return ret;
}
/***********************************************************************
@ -282,9 +352,8 @@ MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc)
*/
MMRESULT WINAPI acmFormatChooseW(PACMFORMATCHOOSEW pafmtc)
{
FIXME("(%p): stub\n", pafmtc);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return MMSYSERR_ERROR;
return DialogBoxParamW(MSACM_hInstance32, MAKEINTRESOURCEW(DLG_ACMFORMATCHOOSE_ID),
pafmtc->hwndOwner, FormatChooseDlgProc, (LPARAM)pafmtc);
}
/***********************************************************************