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

Author Topic: Buffers not deleted  (Read 29157 times)

0 Members and 1 Guest are viewing this topic.

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Buffers not deleted
« on: September 04, 2008, 11:55:11 pm »
If my application exits, I get the following error message (replace 1 with the number of sounds loaded at runtime):

Code: [Select]
AL lib: alBuffer.c:1097: exit() 1 Buffer(s) NOT deleted

I keep a sf::Sound and a sf::SoundBuffer inside a class to make it easier to keep track of the resources (for my resource-manager and script bindings).

The destructor is called as expected, so I'm not sure what causes it.

Code: [Select]
class SoundBuffer
{
public:
SoundBuffer()
{
std::cerr << "sound created" << std::endl;
}

virtual ~SoundBuffer()
{
std::cerr << "sound destroyed" << std::endl;
}

bool Init(File& Data)
{
bool Success = Buffer.LoadFromMemory(Data.GetContent(), Data.Size());

Sound.SetBuffer(Buffer);

return Success;
}

sf::Sound Sound;

private:
sf::SoundBuffer Buffer;
};


Can anyone help?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #1 on: September 05, 2008, 09:29:11 am »
Which OS ? Have you tried using openal-soft ?
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Buffers not deleted
« Reply #2 on: September 05, 2008, 09:45:21 am »
Linux, and yes, I'm using openal-soft.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #3 on: September 05, 2008, 10:38:29 am »
Can you give a minimal / complete example which reproduces this bug ?
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Buffers not deleted
« Reply #4 on: September 05, 2008, 03:01:53 pm »
I solved it: the buffer has to be destroyed after the sound.

This will give you the error:

Code: [Select]
#include <SFML/Audio.hpp>

class SoundBuffer
{
public:
   SoundBuffer()
   {
   }

   virtual ~SoundBuffer()
   {
   }

   bool Init(const std::string& Filename)
   {
      bool Success = Buffer.LoadFromFile(Filename);

      Sound.SetBuffer(Buffer);

      return Success;
   }

   sf::Sound Sound;

private:
   sf::SoundBuffer Buffer;
};

int main()
{
   SoundBuffer Buffer;

   if (!Buffer.Init("test.wav"))
   {
      return EXIT_FAILURE;
   }

   Buffer.Sound.Play();

   while (Buffer.Sound.GetStatus() == sf::Sound::Playing)
   {
      sf::Sleep(0.1f);
   }

   sf::Sleep(1.f);

   return EXIT_SUCCESS;
}


This however will work:

Code: [Select]
#include <SFML/Audio.hpp>

class SoundBuffer
{
public:
SoundBuffer()
{
Buffer = new sf::SoundBuffer;
Sound  = new sf::Sound;
}

virtual ~SoundBuffer()
{
delete Sound;
delete Buffer;
}

bool Init(const std::string& Filename)
{
bool Success = Buffer->LoadFromFile(Filename);

Sound->SetBuffer(*Buffer);

return Success;
}

sf::Sound* Sound;

private:
sf::SoundBuffer* Buffer;
};

int main()
{
SoundBuffer Buffer;

if (!Buffer.Init("test.wav"))
{
return EXIT_FAILURE;
}

Buffer.Sound->Play();

while (Buffer.Sound->GetStatus() == sf::Sound::Playing)

{
sf::Sleep(0.1f);
}

sf::Sleep(1.f);

return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #5 on: September 05, 2008, 04:40:19 pm »
This is not supposed to happen, there's explicit code to get rid of this kind of dependency. Which version of SFML are you using ?
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Buffers not deleted
« Reply #6 on: September 05, 2008, 04:58:28 pm »
Quote
Which version of SFML are you using ?

Revision 858 (latest).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #7 on: September 05, 2008, 05:48:18 pm »
Hmm ok, I'll check that. Thanks for your help, I'll keep you informed :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #8 on: September 09, 2008, 06:21:22 pm »
I've tried your code in both static and dynamic debug versions, everything works fine.

Which error do you get exactly ? Did you make a full rebuild of SFML ?
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Buffers not deleted
« Reply #9 on: September 09, 2008, 07:23:26 pm »
I always do a full rebuild (especially before posting something like this).
However, I can't reproduce it with the latest svn, so maybe it was all my systems fault
(as you know, I recently encountered some other problems in combination with sfml).

However, this was the message I got:
Code: [Select]
AL lib: alBuffer.c:1097: exit() 1 Buffer(s) NOT deleted
Google gives a few results, but nothing useful.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffers not deleted
« Reply #10 on: September 09, 2008, 07:44:07 pm »
Ok, so I guess we can consider the problem solved.

Let me know if it comes back ;)
Laurent Gomila - SFML developer

 

anything