Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Streaming from DAT file  (Read 2382 times)

0 Members and 1 Guest are viewing this topic.

Michard

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Streaming from DAT file
« on: November 29, 2012, 06:22:14 pm »
Hi everyone,
I'm currently working on a SFML project. In this project, I'm using a DAT file to store all my files (at the moment only images) to prevent users from modifying them. Now I'd like to store audio data (BGMs and sound effects) in the same file. With Sound effects there shouldn't be any problem, I can just load the data in a char* ecc.. Now I'm facing the problem of BGM streaming. How could I solve my problem? I could just load one whole track at a time, but then I would have a really big size allocated and I wanted to avoid doing so. Any suggestions?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Streaming from DAT file
« Reply #1 on: November 29, 2012, 07:05:51 pm »
You should not have music and other resources in the same file. sf::Music has an own thread that continously loads stream chunks, and this may create race conditions with other accesses to that file.

Use a separate file for music, and implement your sf::InputStream derivate to read from the .dat file. Make sure you don't play multiple music themes simultaneously, otherwise you have again the problem described above.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Michard

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Streaming from DAT file
« Reply #2 on: November 29, 2012, 07:27:34 pm »
Hello Nexus,
first of all , thank you for the help. For the first tip, that's ok, as I don't have any problems with a second dat file. As for the second suggestion, I'm currently using SFML 1.6, while sf::InputStream seems to be included only in SFML 2.0. Any suggestions for version 1.6?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Streaming from DAT file
« Reply #3 on: November 29, 2012, 07:52:06 pm »
Switch to version 2.0 ;)

I don't know to do it with SFML 1.6. But this version has not been maintained for years, contains much more bugs and less features than SFML 2. If it's somehow possible, I really advise you to work with SFML 2.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Michard

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Streaming from DAT file
« Reply #4 on: December 02, 2012, 05:17:00 pm »
Thank you anyway, I'll think about switching to 2.0

 

anything