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

Author Topic: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)  (Read 4243 times)

0 Members and 1 Guest are viewing this topic.

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« on: March 13, 2012, 11:38:23 pm »
Just a quick question: is the fact, that Music's loading functions begin with "open" and all the other classes (Image, Font, SoundBuffer) have their corresponding functions beginning with "load" deliberate? Why the inconsistency? Is there a reason behind it I failed to grasp?

By the way: if all the Image, Font, Music... classes inherited the same abstract interface class like "Loadable" it could sometimes save people from writing the repetitive cod for each of them individually - but it might be another thing Laurent thought through and decided against :)

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #1 on: March 13, 2012, 11:51:48 pm »
I'm pretty sure it's due to the fact that musics are opened and loaded chunk by chunk, not fully loaded when the function is used like for other resources :)

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #2 on: March 13, 2012, 11:59:12 pm »
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #3 on: March 14, 2012, 12:18:29 am »
Quote from: "nietaki"
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?


Hmm, sorry I don't know about that, I never load from memory.

Either wait for Laurent (he's so fast that he'll probably answer before you read this line so you won't wait for long :P), or try it out yourself by loading from memory and then overwriting the data?

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #4 on: March 14, 2012, 12:38:39 am »
Quote from: "Mjonir"
Either wait for Laurent (he's so fast that he'll probably answer before you read this line so you won't wait for long :P), or try it out yourself by loading from memory and then overwriting the data?


If he doesn't respond by tommorow I'll try it out myself, I've just finished a big chunk of code and gave myself the rest of the day off ;)

Damn, the project I'm writing with SFML is the first one that ever gave me so much insight and fulfillment and we haven't even reached the fun part yet ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #5 on: March 14, 2012, 08:07:42 am »
Quote
I'm pretty sure it's due to the fact that musics are opened and loaded chunk by chunk, not fully loaded when the function is used like for other resources

Correct.

Quote
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?

No. Isn't it written in the doc?
Laurent Gomila - SFML developer

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #6 on: March 14, 2012, 06:20:08 pm »
Quote from: "Laurent"
Quote
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?

No. Isn't it written in the doc?


It isn't, at least not explicitly - I read it once again and I still wouldn't be sure if not for your answer.

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #7 on: March 14, 2012, 06:25:02 pm »
Quote from: "nietaki"
It isn't, at least not explicitly - I read it once again and I still wouldn't be sure if not for your answer.


I agree, I had checked the doc before answering and wasn't 100% sure about the behavior of music opening.

I also think the special status of sf::Music::openFrom* deserves a small mention in the doc of these methods.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
« Reply #8 on: March 14, 2012, 07:05:52 pm »
Sorry, shame on me :(
Laurent Gomila - SFML developer

 

anything