Hi all
This is the code I'm using for a long time to play sound
After some time the memory would start to incrse and the system would crash, what am i doing wrong or is there a better way to play sound from a file or resource
Any help, please..
Hi all
This is the code I'm using for a long time to play sound
After some time the memory would start to incrse and the
system would crash, what am i doing wrong or is there a
better way to play sound from a file or resource
Any help, please..
TIS_YON
HB_FUNC( PLAYSOUND2 )
{
LPCSTR pszSound = ( hb_pcount()>0 && ISCHAR(1) )? hb_parc(1):NULL;
HMODULE hmod = GetModuleHandle(NULL);
DWORD fdwSound = SND_NODEFAULT;
if( hb_pcount()>3 && ISLOG(4) && hb_parl(4) )
fdwSound |= SND_RESOURCE;
else
fdwSound |= SND_FILENAME;
if( hb_pcount()>1 && ISLOG(2) && hb_parl(2) )
fdwSound |= SND_SYNC;
else
fdwSound |= SND_ASYNC;
if( hb_pcount()>2 && ISLOG(3) && hb_parl(3) )
fdwSound |= SND_LOOP;
//if( !pszSound )
// fdwSound |= SND_PURGE;
PlaySound( pszSound, hmod, fdwSound )
RELEASE pszSound, hmod, fdwSound
hb_retl( .T. );
}
So you are allocating memory, but not releasing it. Or could use STATIC / LOCAL variables, that are defined once.
LPCSTR pszSound = ( hb_pcount()>0 && ISCHAR(1) )? hb_parc(1):NULL;
You have just allocated memory, pszSound
Il 06/12/2022 15:32, dlzc ha scritto:... the Newsgroup they are asking on. How are these variables defined, made 'LOCAL' in C? In the function definition, right?
So you are allocating memory, but not releasing it. Or could
use STATIC / LOCAL variables, that are defined once.
LPCSTR pszSound = ( hb_pcount()>0 && ISCHAR(1) )? hb_parc(1):NULL;
You have just allocated memory, pszSound
You are confusing xHarbour code and C code.
For me the problem is in the
PlaySound() function that I don't know what it does.
You are confusing xHarbour code and C code.
... the Newsgroup they are asking on. How are these variables defined, made 'LOCAL' in C? In the function definition, right?
Il 06/12/2022 17:51, dlzc ha scritto:
You are confusing xHarbour code and C code.
... the Newsgroup they are asking on. How are these variables defined,
made 'LOCAL' in C? In the function definition, right?
They are already defined as the C equivalent of LOCAL. There is no
memory leak in that code. The only place where it could be is, as I
alredy wrote, the unknown function PlaySound().
On Tuesday, December 6, 2022 at 10:50:01 AM UTC-7, Enrico Maria Giordano wrote:
Il 06/12/2022 17:51, dlzc ha scritto:
You are confusing xHarbour code and C code.
... the Newsgroup they are asking on. How are these variables defined, made 'LOCAL' in C? In the function definition, right?
They are already defined as the C equivalent of LOCAL. There is noAgreed on PlaySound. I find a thread on MSN that cite it (presumably built-in language function) as 1 Meg with every call, but might be out-of-date.
memory leak in that code. The only place where it could be is, as I
alredy wrote, the unknown function PlaySound().
Thanks for your persistence / tolerance.
David A. Smith (I don't do C, it makes me C-sick.)
Hi All and thanks so much for the help
I did not have a chance yet to test
I believe playSound took over the Microsoft legacy sndPlaySound http://www.jasinskionline.com/windowsapi/ref/s/sndplaysound.html
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 251 |
Nodes: | 16 (2 / 14) |
Uptime: | 140:01:50 |
Calls: | 5,526 |
Calls today: | 3 |
Files: | 11,671 |
Messages: | 5,096,316 |