Use PlaySound api caused memory loading?
-
Dear all: I implement a application, when I get a touch data from WM_INPUT and touch count more than previous, it will play sound, My code show as below:
void CTouchSoundTrayDlg::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput)
{
UINT data_size = 0;
BOOL bGot = FALSE;
GetRawInputData(hRawInput, RID_INPUT, NULL, &data_size, sizeof(RAWINPUTHEADER));
vector data;
data.resize (data_size);if(GetRawInputData (hRawInput, RID\_INPUT, &data \[0\], &data\_size, sizeof(RAWINPUTHEADER))!=data\_size) { } RAWINPUT\* raw = (RAWINPUT\*)(&data \[0\]); if (raw->header.dwType == RIM\_TYPEHID) { RID\_DEVICE\_INFO device\_info; UINT info\_size = sizeof(RIDI\_DEVICEINFO); GetRawInputDeviceInfo ( raw->header.hDevice, RIDI\_DEVICEINFO, (LPVOID)&device\_info,&info\_size); if(device\_info.hid.dwVendorId = VENDER\_ID) { g\_CurFrameTime = GetTickCount64(); if(g\_CurFrameTime - g\_PreFrameTime > 30) { g\_PreUsedSize = 0; g\_CurUsedSize = 0; } g\_PreFrameTime = g\_CurFrameTime; DigitizerData\* result = (DigitizerData\*)(raw->data.hid.bRawData); g\_CurUsedSize = result->active\_touch\_count; if(g\_CurUsedSize <= 5) { if(g\_PreUsedSize < g\_CurUsedSize) { PlaySound(m\_WavPath, NULL, SND\_FILENAME|SND\_ASYNC ); } bGot = TRUE; } if(bGot) { g\_PreUsedSize = g\_CurUsedSize; } } } Default();
}
My question is when I touch, it will play sound, and the using memory in task manager will be add, When play music is finish, the using memory is still, will not free ,why? I try to disable the playSound api in my code, and the using memory is stable. Thank your help, Victor
-
Dear all: I implement a application, when I get a touch data from WM_INPUT and touch count more than previous, it will play sound, My code show as below:
void CTouchSoundTrayDlg::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput)
{
UINT data_size = 0;
BOOL bGot = FALSE;
GetRawInputData(hRawInput, RID_INPUT, NULL, &data_size, sizeof(RAWINPUTHEADER));
vector data;
data.resize (data_size);if(GetRawInputData (hRawInput, RID\_INPUT, &data \[0\], &data\_size, sizeof(RAWINPUTHEADER))!=data\_size) { } RAWINPUT\* raw = (RAWINPUT\*)(&data \[0\]); if (raw->header.dwType == RIM\_TYPEHID) { RID\_DEVICE\_INFO device\_info; UINT info\_size = sizeof(RIDI\_DEVICEINFO); GetRawInputDeviceInfo ( raw->header.hDevice, RIDI\_DEVICEINFO, (LPVOID)&device\_info,&info\_size); if(device\_info.hid.dwVendorId = VENDER\_ID) { g\_CurFrameTime = GetTickCount64(); if(g\_CurFrameTime - g\_PreFrameTime > 30) { g\_PreUsedSize = 0; g\_CurUsedSize = 0; } g\_PreFrameTime = g\_CurFrameTime; DigitizerData\* result = (DigitizerData\*)(raw->data.hid.bRawData); g\_CurUsedSize = result->active\_touch\_count; if(g\_CurUsedSize <= 5) { if(g\_PreUsedSize < g\_CurUsedSize) { PlaySound(m\_WavPath, NULL, SND\_FILENAME|SND\_ASYNC ); } bGot = TRUE; } if(bGot) { g\_PreUsedSize = g\_CurUsedSize; } } } Default();
}
My question is when I touch, it will play sound, and the using memory in task manager will be add, When play music is finish, the using memory is still, will not free ,why? I try to disable the playSound api in my code, and the using memory is stable. Thank your help, Victor
I would assume that data structures are initialized to play the sound, and then the data structures are kept for the next sound to play.
The difficult we do right away... ...the impossible takes slightly longer.