August 04, 2020, 12:59:07 PM

Author Topic: BlitzmaxNG hanging on zipstream  (Read 187 times)

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
BlitzmaxNG hanging on zipstream
« on: July 18, 2020, 10:38:09 PM »

The following code makes BlitzmaxNG hand indefinitely:

Code: BlitzMax
  1. Import koriolis.zipstream
  2.  
  3. Local mmTune:TSound = LoadSound("ZIP::music/music.zip//"+"example.ogg")
  4.  
  5. If mmTune=Null Then RuntimeError "can't load music"
  6.  

Am I doing something wrong or is there something wrong with loading a 1mb ogg? I noticed that incbin does not work with NG always leading to out of memory errors when building.

The code above builds and output says "executing: zip test.exe" and just hangs. Is this an NG issue?

Can you guys give me an example of loading an ogg from a zip file?



Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: BlitzmaxNG hanging on zipstream
« Reply #1 on: July 19, 2020, 08:08:19 AM »
It is not hanging on the zipstream but on loading the OGG from the stream.

I created a file "ogg_incbin.bmx" with the following code:
Code: BlitzMax
  1. SuperStrict
  2.  
  3. Framework Brl.StandardIO
  4. Import Brl.Audio 'TSound
  5. Import Brl.OggLoader 'to decode OGG
  6. Import koriolis.zipstream 'to load/stream zips
  7. Import Brl.TextStream
  8.  
  9. Incbin "music.zip"
  10.  
  11. Local source:String = LoadText("zip::music.zip//ogg_incbin.bmx")
  12. print "source: " + source
  13.  
  14. Local mmTune:TSound = LoadSound("zip::music.zip//"+"example.ogg")
  15.  
  16. If mmTune=Null Then Throw "can't load music"
  17.  
  18. print "loaded sound"
  19.  

Within "music.zip" I placed the source code itself and an example.ogg file - the text is printed properly but it stucks on the LoadSound() command.


Edit - loading an incbinned ogg fails too (might need another import to work or so):
Code: [Select]
Incbin "example.ogg"

Local incbinTune:TSound = LoadSound("incbin::example.ogg")
if incbinTune then print "loaded incbinned tune"
if not incbinTune then print "failed loading incbinned tune"
This is because I use the "framework" - and to make the direct incbin load work here, I need to add "Import Brl.RamStream" too. Then it loads the incbinned ogg directly.


bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: BlitzmaxNG hanging on zipstream
« Reply #2 on: July 19, 2020, 08:43:37 AM »
Code: BlitzMax
  1. SuperStrict
  2.  
  3. Framework Brl.StandardIO
  4. Import Brl.Audio 'TSound
  5. Import Brl.OggLoader 'to decode OGG
  6. Import koriolis.zipstream 'to load/stream zips
  7. 'Import Brl.TextStream 'if you load a sample text file
  8. Import Brl.RamStream
  9.  
  10. Incbin "music.zip"
  11. Incbin "example.ogg"
  12.  
  13. 'Local source:String = LoadText("zip::music.zip//ogg_incbin.bmx")
  14. 'print "source: " + source
  15.  
  16.  
  17. 'FILESYSTEM FILE
  18. 'works
  19. Local oggStream:TStream = ReadStream("example.ogg")
  20. If oggStream Then Print "loaded ogg stream"
  21. If Not oggStream Then Print "failed loading ogg stream"
  22.  
  23. 'works
  24. Local streamTune:TSound = LoadSound( oggStream )
  25. If streamTune Then Print "loaded sound from ogg stream"
  26. If Not streamTune Then Print "failed loading sound from ogg stream"
  27.  
  28.  
  29. 'INCBIN FILE
  30. 'fails
  31. Local incbinOggStream:TStream = ReadStream("incbin::example.ogg")
  32. If incbinOggStream Then Print "loaded ogg stream from incbinned ogg file"
  33. If Not incbinOggStream Then Print "failed loading ogg stream from incbinned ogg file"
  34.  
  35. 'works
  36. Local incbinTune:TSound = LoadSound("incbin::example.ogg")
  37. If incbinTune Then Print "loaded sound from incbinned ogg file"
  38. If Not incbinTune Then Print "failed loading sound from incbinned ogg file"
  39.  
  40. 'this fails
  41. Local incbinStreamTune:TSound = LoadSound( incbinOggStream )
  42. If incbinStreamTune Then Print "loaded sound by stream from incbinned ogg file"
  43. If Not incbinStreamTune Then Print "failed loading sound by stream from incbinned ogg file"
  44.  
  45.  
  46. 'INCBIN ZIP CONTENT
  47. 'works
  48. Local incbinZipOggStream:TStream = ReadStream("zip?::music.zip//"+"example.ogg")
  49. If incbinZipOggStream Then Print "loaded ogg stream from incbinned zip file"
  50. If Not incbinZipOggStream Then Print "failed loading ogg stream from incbinned zip file"
  51.  
  52. 'fails and STUCKS
  53. Local incbinZipOggSound:TSound = LoadSound(incbinZipOggStream)
  54. If incbinZipOggSound Then Print "loaded sound by stream from incbinned zip file"
  55. If Not incbinZipOggSound Then Print "failed loading sound by stream from incbinned zip file"
  56.  
  57. 'fails and STUCKS
  58. Local incbinZipTune:TSound = LoadSound("zip?::music.zip//"+"example.ogg")
  59. If incbinZipTune Then Print "loaded sound from incbinned zip file"
  60. If Not incbinZipTune Then Print "failed loading sound from incbinned zip file"
  61.  
  62. Print "DONE."
  63.  

Some test case - will raise an issue for it.


Edit: https://github.com/bmx-ng/brl.mod/issues/186

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
Re: BlitzmaxNG hanging on zipstream
« Reply #3 on: July 19, 2020, 02:09:07 PM »
Thanks Derron.

Incbin works if you include a few small files but I have 40mb worth of game music and the compiler throws an error. Here is the code:

Code: BlitzMax
  1. SuperStrict
  2.  
  3. Framework Brl.StandardIO
  4. Import Brl.Audio 'TSound
  5. Import Brl.OggLoader 'to decode OGG
  6. Import koriolis.zipstream 'to load/stream zips
  7. 'Import Brl.TextStream 'if you load a sample text file
  8. Import Brl.RamStream
  9.  
  10. Incbin "music2/dream_on.ogg"
  11. Incbin "music2/forest_of_f.ogg"
  12. Incbin "music2/med1.ogg"
  13. Incbin "music2/rom_mem.ogg"
  14. Incbin "music2/rom_mem drums.ogg"
  15. Incbin "music2/track1.ogg"
  16. Incbin "music2/track2.ogg"
  17. Incbin "music2/track3.ogg"
  18. Incbin "music2/track4.ogg"
  19. Incbin "music2/track5.ogg"
  20. Incbin "music2/track6.ogg"
  21. Incbin "music2/win_loop.ogg"
  22.  
  23.  
  24. Print "all incbined"
  25.  

Error:
Code: [Select]
Building incbin NG
[ 86%] Processing:incbin NG.bmx
[ 90%] Compiling:incbin NG.bmx.release.win32.x86.incbin.c
[ 95%] Compiling:incbin NG.bmx.gui.release.win32.x86.c
cc1.exe: out of memory allocating 536875007 bytes
Build Error: failed to compile (1) M:/Dropbox/Programming tests/.bmx/incbin NG.bmx.release.win32.x86.incbin.c
Process complete

I have 32Gb Ram and 64 free Gb on my system ssd.

What does the question mark do in "zip?::", does it replace "incbin::"?


Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: BlitzmaxNG hanging on zipstream
« Reply #4 on: July 19, 2020, 07:47:46 PM »
"zip::" - it is of course a zip
"zip?::" - it might be a zip (at least koriolis.zipstream had both in it and I just tried it out)

The question mark is not a standard thing - at least I am not aware of it.

bye
Ron

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
Re: BlitzmaxNG hanging on zipstream
« Reply #5 on: July 21, 2020, 01:50:43 AM »
""zip?::" - it might be a zip (at least koriolis.zipstream had both in it and I just tried it out)"

Ok, nice.

So for incbined zip shouldn't it be
Code: BlitzMax
  1. Local incbinZipOggStream:TStream = ReadStream("incbin::zip?::music.zip//"+"example.ogg")

Tried it, still gets stuck.



Offline Derron

  • Hero Member
  • *****
  • Posts: 3074
Re: BlitzmaxNG hanging on zipstream
« Reply #6 on: July 21, 2020, 07:51:24 AM »
It "should" not ... but "could". So if you know it is a zip, just use "zip::" without the question mark.


But as written in the issue I raised... it fails as soon as "ogg_dec" (ogg vorbis decoder) tries to read from the provided memory stream of that zip extracted file (maybe some memory thingy).


bye
Ron

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 60
Re: BlitzmaxNG hanging on zipstream
« Reply #7 on: July 22, 2020, 02:33:05 AM »
Ok, thanks.

I wish I knew how to fix these things myself. Blitzmax is such a nice language.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal