Hi all,
please anyone tell me what is wrong with the code... I did everything said
in the memory management section to allocate memory and tried to play the
wave file. but the playfunction always return that not enough memory to
complete the operation (errorcode 14 ).
here is the code... first is with file mapping and the other reading the
file to memory allocated with virtualalloc function.
The code works perfectly in emulator but not in the device. I am using an
iPAQ hx2700
with 256Mb, up to 144Mb of it is for user.
I have written a program using IO device but I have no idea how to fill the
details of the WAVEFORMATEX struct (samplebitrate, etc), because I dont know
anything about the wav file in hand.
anyhelp please .....
Thanks
{HANDLE hFile;
hFile = CreateFileForMapping(TEXT("\\My
Documents\\Music01.wav"),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
HANDLE hMapFile = CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,0);
DWORD dw = GetLastError();
DWORD nWords,dwSize;
dwSize = GetFileSize(hFile,&nWords);
LPVOID pMap = MapViewOfFile(hMapFile,FILE_MAP_READ,0,0,0);
dw = GetLastError();
BOOL b;
pMap = MapC
int ret = PlaySound((LPCWSTR)pMap,NULL,SND_MEMORY);
DWORD res = GetLastError();
UnmapViewOfFile(pMap);
CloseHandle(hMapFile);
b = CloseHandle(hFile);}
//
{HANDLE hFile;
hFile = CreateFile(TEXT("\\My
Documents\\Music01.wav"),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
LPVOID pBase = NULL;
LPVOID pBuff = NULL;
pBase = VirtualAlloc(0,5*1024*1024,MEM_RESERVE,PAGE_NOACCESS);
pBuff = VirtualAlloc(pBase,5*1024*1024,MEM_COMMIT,PAGE_READWRITE);
DWORD nWords,dwSize;
dwSize = GetFileSize(hFile,&nWords);
BOOL b;
b = ReadFile(hFile,pBuff,dwSize,&nWords,0);
b = PlaySound((LPCWSTR)pBuff,NULL,SND_SYNC|SND_MEMORY);
DWORD res = GetLastError();
b = VirtualFree(pBase,0,MEM_RELEASE);
b = CloseHandle(hFile);}