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 / LoadMusicOGG() an ASync Process?

Author
Message
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 18th Aug 2016 19:54
Hello guys,

This question also extends to other functions that load media, are they all handled asynchronously?

Take this piece of code for example:


I assumed that the music file would be fully loaded before the DeleteFile command is executed but instead I get strange results. For example, in this instance the file won't be deleted, I'm assuming it's because the music file is still being loaded in the background.

Now rather than Delete the file, if you overwrite it instead, for example like so:


In this instance, the music referenced by musicID exists (GetMusicExistsOGG returns 1) but refuses to play. I'm assuming that's because the loading was cut short by the overwriting of the source file.

So is the LoadMusicOGG() an ASync process? I just need confirmation so I can handle my code a bit differently keeping that in mind. Thanks!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Aug 2016 08:28
I think you have answered your own question with some good tests

It makes sense because as soon as you have the file headers and a few bytes of data, you can start playing the sound. It's not like an image where you need the full file before you can use it. Sound performance is also much better than previous releases, so again maybe this is due to "streaming" the audio as soon as enough data is available.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 19th Aug 2016 09:46
@BatVink:
That makes a lot of sense, thanks! I'm packing my media using memblocks so that they're not individually visible in the distributed version of the game. During runtime, my extraction process (e.g. for music) involves extracting a music track from the memblock to a file, loading the music file, then extracting the next music track to overwrite the same file, and so on. I then noticed that the music file refused to play even though AppGameKit indicated that it exists. I guess I'll start extracting to separate files instead.

I also noticed that the .OGG file is locked and can't be deleted as long as you've loaded music from it in AGK. As long as the loaded music exists, its source file can't be deleted, as soon as you delete the loaded music then you can delete the source file.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Aug 2016 15:38
very useful info, thanks for sharing
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-09-29 17:21:22
Your offset time is: 2024-09-29 17:21:22