Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Tier 2]: PlayMusic function increases memory everytime it's played...

Author
Message
ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 3rd Aug 2014 21:12
...I'm looping music by calling the play music function, but everytime it hits it memory jumps up by 3mb. The music I'm playing is only 405kb.

I also tried not looping the music; and to play it when it senses the music has stopped with the same results.

Prove Your Worthiness
KG2Entertainment.com
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 3rd Aug 2014 23:41
Are you sure you're only loading it once?

-- Jim - When is there going to be a release?
ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 4th Aug 2014 00:33 Edited at: 4th Aug 2014 09:40
When I go from screen to screen I will load that screens music into the same variable. And right before I load I make sure I delete what was there before.

So screen 1 I call this:


...and then for the next screen I stop the previous music, delete it from the variable and then load the new.


Prove Your Worthiness
KG2Entertainment.com
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Aug 2014 01:03
Make sure that GetMusicExists() actually works correctly, otherwise you may be loading multiples. Music should stream anyway, so I'd be surpised if there was a big hit!

-- Jim - When is there going to be a release?
ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 4th Aug 2014 09:48 Edited at: 4th Aug 2014 17:03
OK. The problem is with the PlayMusic function in Tier 2. I have even commented out every place I have the function and the program doesn't have any memory issues.

It works as you would expect it to; when I load graphics the memory increases. When I release graphics from memory it decreases.

This is definitely something Paul should look at.

I have left my program running on the title screen for over an hour and the memory didn't increase but a few kilobytes here and there.

But with the PlayMusic function uncommented, with it looping, the memory would increase by about 3MB every time the music started over, and that would cause a crash because memory would reach over 300MB when just sitting on the title screen.

This happen with both lines of code:
Quote: "
agk:layMusic(titlemusic1,1,titlemusic1,titlemusic1);
"


and

Quote: "
agk:layMusic(titlemusic1,1);
"



@Edit
Just to confirm; I left the program to run overnight and it actually performed better.

Here are the numbers. It shows the memory usage and the time:

71, 428K at 11:36pm
70, 908K at 12:02am
49, 436 at 6:43am

Can someone else confirm my findings?

Prove Your Worthiness
KG2Entertainment.com
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 4th Aug 2014 17:34
I managed to replicate this with OGG files but not MP3s. I can reduce the effect by cleaning up the DirectShow filters before playing an OGG file but I can't seem to remove it completely so maybe there is a memory leak in the codec I'm using, or DirectShow has a memory leak internally with OGG?

Some people have found MP2 to be a good royalty free music format for PC which might be a viable work around here.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th Aug 2014 17:37
MP2 also requires no codecs to be installed. But you must use a higher bitrate to get the same audio quality as MP3. M4A works on mobile devices and Mac.

ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 4th Aug 2014 19:01
Thanks! I think I will switch to m4a files for the mobile platform.

But, I did have crashes when running on my galaxy S3, but I first need to confirm that it is not my code just to make sure before I blame on the .ogg format.

I will change all the music to .m4a and run the program on the phone to see what happens.

Prove Your Worthiness
KG2Entertainment.com
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th Aug 2014 22:08
m4a works well for windows pc as well, works great with android. Id go with m4a as it seams to work on everything i have tested.

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th Aug 2014 23:05
Quote: "m4a works well for windows pc as well"

Apparently not if you don't have the appropriate codec installed.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Aug 2014 23:19
M4A does NOT work natively on Windows.

-- Jim - When is there going to be a release?
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Aug 2014 05:24
Confirmed, M4A requires codec installation on Windows. Windows' best option is MP3 (lovely licensing fees) or MP2 (no licensing). Android, iOS, and Mac all support M4A natively, though.
With our last project I just switched out the files for Windows and put an M4A extension on my MP2 files so I didn't have to change any code. Easy peasy and works like a charm!

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 5th Aug 2014 12:20
Naphier:
Ever tried naming mp2 files m4a and run on your mobile?

SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 5th Aug 2014 15:50 Edited at: 5th Aug 2014 15:52
humm well i dont recall installing any codecs on any of my windows pc's to get m4a running... but if jim says it doesnt then it doesnt.

it however works on my vista machine....it also works on the 3 of my windows 7 machines... The laptop was a fresh install of windows 7

i guess im lucky to have 4 outa 4 machines running it without needing to look for codecs.

a good idea then is to use mp2 on pc,m4a on mobile ? thats what i will do.

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Aug 2014 16:09
@DA - nope never had the inkling to try. I was already using M4A in my development builds so I just remade them as MP2 when I found the game played no sound on my wife's Windows 7 laptop (32-bit home edition).
M4A would play fine in WMP, VLC, and Audacity on her machine, but not through AGK. Was the same with my desktop PC running Win 7 64-bit pro until I downloaded a codec pack.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th Aug 2014 19:08
WMP, VLC, Audacity and other programs or interfaces like FFMpeg include their own decoders. For programs that don't have these, it's necessary to install DirectShow (DShow) filters.

Not all filters work the same, or well, or at all - so this is a major pain in the rectum for companies like mine that require teachers to import their own (probably downloaded from YouTube) resources.

It's very important to understand the M4A is NOT a standard. It's a container format like MP4 which can itself use codecs - like .AVI.

So don't get too excited about M4A being the ultimate business here. Depending upon the encoding, it could still not play on device X.

-- Jim - When is there going to be a release?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Aug 2014 10:24
Thanks Jim, damned handy having you around
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Aug 2014 12:06
I'm sorry that I usually bring bad news!

Life is much easier than this using C++ or Pascal!

Users are reporting bad playback of even WAV files on iOS 7.1, and some reports of issues with M4A files on recent Android versions.

In general, the ONLY things that are guaranteed to play on all platforms are .WAV and .MP3. MP2 should also play, but it may be necessary to rename the file to .MP3 if the subsystem doesn't recognise the file extension. All MP3 subsystems will play MP2-encoded audio.

File extensions cannot be copyrighted or used as a trademark (legal precedent exists). So renaming anything to .MP3 cannot be challenged. The flag bits in the MPEG audio headers specifically contain a value for MPEG-1 Layer II (.mp2) and MPEG-1 Layer III (.mp3). Consequently, in the vanishingly-improbable eventuality of an Indie game developer being sued for using MP3, when they are actually using MP2, about 30 seconds in court will prove that they are not using MP3. In fact, anybody trying to bring an action would check this beforehand and forget it.

-- Jim - When is there going to be a release?

Login to post a reply

Server time is: 2024-05-12 13:31:42
Your offset time is: 2024-05-12 13:31:42