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

Author Topic: sf::Musics' threads  (Read 3411 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
sf::Musics' threads
« on: February 01, 2013, 06:05:00 pm »
Can few sf::Music instances play using single sf::InputStream?
If yes, does that require sf::InputStream implementation to be thread safe?
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Musics' threads
« Reply #1 on: February 01, 2013, 10:43:29 pm »
Quote
Can few sf::Music instances play using single sf::InputStream?
If you look at what sf::InputStream does, it is obvious that it cannot work with several "clients": it has the current reading position. And multiple musics would require multiple reading positions.
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Musics' threads
« Reply #2 on: February 02, 2013, 07:57:28 pm »
Right, and what is read supposed to return on error? Returning 0 caused me access violation, returning -1 like in all others works and just errors with sane message about file being corrupt. Also maybe it's a good idea to make more apparent that read assumes that read pointer is advanced by the amount of bytes read, maybe I'm stupid but that wasn't that obvious to me. And assumption(or maybe I debugged my stream wrong but I didn't see a single seek() call in my test for sf::Image from png) that streams start with read pointer at 0 can be somewhat harmful if I'd want to load few things from same stream in succession, I'd have to call seek(0) myself in between or it'd error out with corrupt file message.
« Last Edit: February 02, 2013, 08:29:43 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Musics' threads
« Reply #3 on: February 02, 2013, 08:35:08 pm »
Quote
Right, and what is read supposed to return on error?
It's documented.

Quote
Also maybe it's a good idea to make more apparent that read assumes that read pointer is advanced by the amount of bytes read
Yep, probably.

Quote
And assumption(or maybe I debugged my stream wrong but I didn't see a single seek() call in my test for sf::Image from png) that streams start with read pointer at 0 can be somewhat harmful if I'd want to load few things from same stream in succession, I'd have to call seek(0) myself in between or it'd error out with corrupt file message.
Hmm yes, you're right. I think you should create an issue on the tracker to summarize your feedback, so that I can work on it later.
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Musics' threads
« Reply #4 on: February 02, 2013, 08:39:08 pm »
Quote
It's documented.
Not here... but that's old docs..
http://www.sfml-dev.org/documentation/2.0/classsf_1_1InputStream.php#a8dd89c74c1acb693203f50e750c6ae53
Not even here in the holy c++ source code itself.
https://github.com/SFML/SFML/blob/master/include/SFML/System/InputStream.hpp
The other 3 all say to return -1 on error in both of these though. Or does that mean that I should return 0 on error since I read 0 bytes?
« Last Edit: February 02, 2013, 08:41:25 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Musics' threads
« Reply #5 on: February 02, 2013, 08:43:05 pm »
It's in the tutorial... ... ok, shame on me :-[

I just added it.
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Musics' threads
« Reply #6 on: February 02, 2013, 08:53:27 pm »
Awesome. Here's the issue, I hope I wrote it alright:
https://github.com/SFML/SFML/issues/349

Quote
It's in the tutorial... ... ok, shame on me :-[
I should have remember it was tutorial, I had in mind I've seen sf::InputStream using std::FILE somewhere but couldn't remember where.
« Last Edit: February 02, 2013, 08:58:23 pm by FRex »
Back to C++ gamedev with SFML in May 2023

 

anything