July 26, 2021, 14:00:02

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

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 91
BlitzmaxNG hanging on zipstream
« on: July 18, 2020, 22:38:09 »

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: 3613
Re: BlitzmaxNG hanging on zipstream
« Reply #1 on: July 19, 2020, 08:08:19 »
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
« Last Edit: July 19, 2020, 08:18:51 by Derron »

Offline Derron

  • Hero Member
  • *****
  • Posts: 3613
Re: BlitzmaxNG hanging on zipstream
« Reply #2 on: July 19, 2020, 08:43:37 »
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
« Last Edit: July 19, 2020, 12:02:13 by Derron »

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 91
Re: BlitzmaxNG hanging on zipstream
« Reply #3 on: July 19, 2020, 14:09:07 »
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: 3613
Re: BlitzmaxNG hanging on zipstream
« Reply #4 on: July 19, 2020, 19:47:46 »
"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: 91
Re: BlitzmaxNG hanging on zipstream
« Reply #5 on: July 21, 2020, 01:50:43 »
""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: 3613
Re: BlitzmaxNG hanging on zipstream
« Reply #6 on: July 21, 2020, 07:51:24 »
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: 91
Re: BlitzmaxNG hanging on zipstream
« Reply #7 on: July 22, 2020, 02:33:05 »
Ok, thanks.

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

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 329
    • Midimaster Music Education Software
Still problems with OGG-files read from INCBIN.
« Reply #8 on: June 29, 2021, 13:01:57 »
While translating my BlitzMax 1.50 app to BlitzMaxNG I have the same problem in reading OGG-file with Koriolis-ZipStream (source: https://github.com/maxmods/koriolis.mod ) from INBIN included DATEN.ZIP.
Code: BlitzMax
  1. Function ReloadAudioSounds(SoundName$)
  2. ' path is f.e.: ""ZIP::Incbin::DATEN.ZIP//Piano0.ogg""
  3.         For Local i%=0 To 36
  4.                 Print i + " " + target
  5.                 SoundTyp.Audio[i]=LoadSound(DatenPfad + SoundName + i + ".ogg")
  6.                 Print i + " fertig"
  7.         Next
  8. End Function
  9.  
The App hangs without any error message while reading the first OGG file. Other file types are processed as expected.

Does someboy know, whether there is already a solution?

does somebody know whether there is a replacement, where I can add a ZIP file via INCBIN and the read the datas?


Of course I have found a (not very elegant) workaround:
Code: BlitzMax
  1. Function ReloadAudioSounds(SoundName$)
  2.         If FileExists(AppPfad + "tempSounds\" + "Piano0.ogg")=False
  3.                 CreateDir AppPfad + "tempSounds"
  4.         EndIf
  5.        
  6.         For Local i%=0 To 36
  7.                 ' workaround for INCBIN OGG problem 2021-06-29
  8.        
  9.                 Local source$ = DatenPfad + SoundName + i + ".ogg"
  10.                 Local target$ = AppPfad + "tempSounds\" + SoundName + i + ".ogg"
  11.                 CopyFile source , target
  12.                        
  13.                 Print i + " " + target
  14.                 ' originalzeile:
  15.                 'SoundTyp.Audio[i]=LoadSound(DatenPfad + SoundName + i + ".ogg")
  16.                        
  17.                 SoundTyp.Audio[i]=LoadSound(target)
  18.                 Print i + " fertig"
  19.         Next
  20. End Function
  21.  
« Last Edit: June 30, 2021, 11:44:17 by Midimaster »
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 329
    • Midimaster Music Education Software
BlitzmaxNG MAC hanging on zipstream
« Reply #9 on: June 30, 2021, 10:41:43 »
Another strange behavoir in the context of koriolis ZipStream:

If you build your zip-file on the mac bigsur with the default finder option "Compress" the resulting ZIP-file can not be processed by koriolis zistream. As long as you build your ZIPs on Windows, f.e. with 7zip. it runs as exepected (except the ogg files, see post #8
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: BlitzmaxNG hanging on zipstream
« Reply #10 on: July 01, 2021, 10:59:54 »
Hi,

Brucey suggested using brl.io to mount a zip file (incbin is supported) and use it as a normal folder.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 329
    • Midimaster Music Education Software
Re: BlitzmaxNG hanging on zipstream
« Reply #11 on: July 01, 2021, 12:01:53 »
Yes I read this too, but I do not understand what it mean and how to do...

Is this a suggestion for a normal user or a possible way to remove the bug in BlitzMaxNG?
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: BlitzmaxNG hanging on zipstream
« Reply #12 on: July 01, 2021, 13:29:15 »
I'll see if I can check later today.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Offline Derron

  • Hero Member
  • *****
  • Posts: 3613
Re: BlitzmaxNG hanging on zipstream
« Reply #13 on: July 01, 2021, 14:03:06 »
I tried to explain it via the github issue already. If it works out, we could paste it to here too.


bye
Ron

Offline GW

  • Full Member
  • ***
  • Posts: 222
Re: BlitzmaxNG hanging on zipstream
« Reply #14 on: July 01, 2021, 20:26:15 »

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal