Koriolis ZipStream failt!

Started by Midimaster, April 12, 2023, 10:47:24

Previous topic - Next topic

Midimaster

With the new version of BlitzMax NG the module...

KORIOLIS.ZIPSTREAM.MOD

..is not longer working with OGG-files.  With other files it is perfect, also when the zip is IncBined

BlitzMax NG hangs without any message, when try to load/extract a OGG file from a zip.

Here is a working example that shows the problem. When the OGG is in the project folder it works. When the OGG is in the ZIP it does not work (the same with cobination of INCBIN)

SuperStrict
Import koriolis.zipstream
Incbin "test.zip"
Incbin "klarinette.ogg"


Global Path:String = ""
Print "test 1: audio name " +  Path + "klarinette.ogg"
Local Temp1:TAudioSample = LoadAudioSample(Path + "klarinette.ogg")
Print "audio lang " +  Temp1.length
Print "audio hertz " + Temp1.hertz
Print "audio format" + Temp1.format
print

Path ="Incbin::"
Print "test 2: audio name " +  Path + "klarinette.ogg"
Local Temp2:TAudioSample = LoadAudioSample(Path + "klarinette.ogg")
Print "audio lang " +  Temp2.length
Print "audio hertz " + Temp2.hertz
Print "audio format" + Temp2.format
print

Path ="ZIP::test.zip//"
Print "test 3: audio name " +  Path + "klarinette.ogg"
Local Temp3:TAudioSample = LoadAudioSample(Path + "klarinette.ogg")
Print "audio lang " +  Temp3.length
Print "audio hertz " + Temp3.hertz
Print "audio format" + Temp3.format
print

Path ="ZIP::Incbin::test.zip//"
Print "test 3: audio name " +  Path + "klarinette.ogg"
Local Temp4:TAudioSample = LoadAudioSample(Path + "klarinette.ogg")
Print "audio lang " +  Temp4.length
Print "audio hertz " + Temp4.hertz
Print "audio format" + Temp4.format

files are add as attachment:
...back from Egypt

Derron

#1
There is an open issue for brl.mod which is about this very issue you experience.

The issue is from 2020 ... and you replied in there.
https://github.com/bmx-ng/brl.mod/issues/186

Maybe use the solution I provided there (brl.io -> mounting the incbinned zip as virtual folder, stream from there)


If you really need koriolis.zipstream you might load the ogg stream data into a TBank ... and load the sound from the bank then. So something like "unzipping into a tbank".

bye
Ron

Derron

Path ="ZIP::Incbin::test.zip//"
Print "test 3: audio name " +  Path + "klarinette.ogg"

Local Temp4:TAudioSample = LoadAudioSample(Path + "klarinette.ogg")
'becomes
Local bank:TBank = LoadBank(Path + "klarinette.ogg")
Local Temp4:TAudioSample = LoadAudioSample(bank)
'or
Local Temp4:TAudioSample = LoadAudioSample(LoadBank(Path + "klarinette.ogg"))


works here at least.


bye
Ron

Midimaster

With help of Derron and the new MaxIo.mod I found a solution, that fulfills all my needs:

1. During development the resources are in a "data" folder. So I can manipulate them and use the new versions immediately.
2. When I publish the app, the resources are inside a ZIP file which is mounted to the EXE.
3. The new approach must work for image, data and audio resources at the same time.

So I found this solution:

SuperStrict
Import koriolis.zipstream
Graphics 800,400

Incbin "test.zip"

Global Path:String ="daten/"
'Path ="ZIP::Incbin::test.zip//"

Global AudioPath:String = CheckPath(Path)


Print "test AudioPath...  audio name=" +  AudioPath + "klarinette.ogg"
Local Audio:TAudioSample = LoadAudioSample(AudioPath + "klarinette.ogg")
Print "audio lang " +  Audio.length
Print "audio hertz " + Audio.hertz
Print "audio format" + Audio.format


Local Image:TImage = LoadImage(Path + "HinterLeer.png")
Repeat
DrawImage Image,0,0
Flip
Until AppTerminate()


Function CheckPath:String (oldPath:String )
' keep folder approachm when there is no INCBINed zip file:
If oldPath.contains("::") = False Then Return oldPath

' make a special approach for audios when ZIP is activ:
MaxIO.Init
Print "MountIncBin result: " + MaxIO.Mount("incbin::test.zip", "music")
Return "music/"
End Function

This way has two branches: In the case of using a ZIP-file, the new IO-mod is used for audios, by calling audios via a virtual folder "music". In the ZIP file the audios are (as the images) in the root directory.
...back from Egypt

Midimaster

The combination of STREAMS and ZIPs and INCBIN keeps problematic in BlitzMax NG.

The approach with MaxIO.mod and it's MountIncbin() has also treacheries and causes new problems.

With the current version of BlitzMax also now a simple ReadLine() leads to crashes, when it is used in combination with INCBIN and/or ZIP:

This will crash:
SuperStrict
Import koriolis.zipstream
Incbin "DATA.ZIP"

Global DataPath:String = "ZIP::Incbin::DATA.ZIP//"
Local File:String = "Anyfile.txt"

Local InStream:TStream = ReadFile(DataPath + File)

While Eof(InStream)=0
    Print ReadLine(InStream)
Wend
CloseFile InStream

Now I found out, that a simple workaround could heal the problem. Add a UT8-Tag "utf8::" to the URL and the ReadLine() works without problems:

This will work:
SuperStrict
Import koriolis.zipstream
Incbin "DATA.ZIP"

Global DataPath:String = "ZIP::Incbin::DATA.ZIP//"
Local File:String = "Anyfile.txt"

Local InStream:TStream = ReadFile("utf8::" + DataPath + File)

While Eof(InStream)=0
    Print ReadLine(InStream)
Wend
CloseFile InStream
...back from Egypt

SToS

Quote from: Midimaster on October 22, 2023, 17:53:20The combination of STREAMS and ZIPs and INCBIN keeps problematic in BlitzMax NG.

The approach with MaxIO.mod and it's MountIncbin() has also treacheries and causes new problems.

With the current version of BlitzMax also now a simple ReadLine() leads to crashes, when it is used in combination with INCBIN and/or ZIP:

This will crash:
SuperStrict
Import koriolis.zipstream
Incbin "DATA.ZIP"

Global DataPath:String = "ZIP::Incbin::DATA.ZIP//"
Local File:String = "Anyfile.txt"

Local InStream:TStream = ReadFile(DataPath + File)

While Eof(InStream)=0
    Print ReadLine(InStream)
Wend
CloseFile InStream
FYI, this does not crash on linux version!

Midimaster

@SToS  Interesting! May I ask you to test the problematic file?

In the attachment you find the file that made problems.

Exchange the file name in my example code from anyfile.txt to BuchHtml.vorl
...back from Egypt

SToS

Quote from: Midimaster on October 23, 2023, 01:22:05@SToS  Interesting! May I ask you to test the problematic file?

In the attachment you find the file that made problems.

Exchange the file name in my example code from anyfile.txt to BuchHtml.vorl
Yes, it works fine.