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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Visor

Pages: [1]
1
Audio / Re: sf::SoundRecorder derived class
« on: December 11, 2017, 09:35:02 pm »
Hi eXpl0it3r, thanks for reply.

If I delete the cMicRecord class, there is no crash. I guess it would crash even whitout my derived class if I had mixed 64 and 32 bits libraries. Also, I remember I only downloaded the x86 version. So, I don't think the problem comes from here.
I thought it wasn't usefull (there is nothing in it), there is the complete implementation:

Code: [Select]

cMicRecord::cMicRecord()
{ // <- Error here
m_bRecording = false;

std::vector<std::string> availableDevices = sf::SoundRecorder::getAvailableDevices();

if (availableDevices.size() > 0
&& this->setDevice(availableDevices[0]))
m_bOperational = true;
else
m_bOperational = false;
}

cMicRecord::~cMicRecord()
{
m_bRecording = false;
m_bOperational = false;

stop();
}

bool cMicRecord::onStart()
{
this->setProcessingInterval(sf::milliseconds(100));

if (m_bOperational
&& this->isAvailable())
{
m_bRecording = true;

return true;
}
else
return false;
}

bool cMicRecord::onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
{
//const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(static_cast<const char*>(packet.getData()) + 1);
//std::size_t      sampleCount = (packet.getDataSize() - 1) / sizeof(sf::Int16);

//sf::Lock lock(SINGLETON.m_micStreamer.m_mutex);
//std::copy(samples, samples + sampleCount, std::back_inserter(SINGLETON.m_micStreamer.m_samples));

return true;
}

void cMicRecord::onStop()
{
m_bRecording = false;
}

bool cMicRecord::isRecording()
{
return m_bRecording;
}

In another class I derived the sf::SoundStream class and it produces the same problem. Here too, if I delete the constructor, it doesn't crash anymore... And even if the constructor has nothing in it, it crashes.

EDIT 1:
I downloaded the last SFML version on Git, built it, etc.
Now I can see better where it crashes:
Code: [Select]
> *****.exe!sf::priv::MutexImpl::lock() [EnterCriticalSection(&m_mutex);]
  *****.exe!sf::Mutex::lock() [m_mutexImpl->lock();]
  *****.exe!sf::Lock::Lock(sf::Mutex & mutex) [m_mutex.lock();]
  *****.exe!sf::AlResource::AlResource() [Lock lock(mutex);]
  *****.exe!sf::SoundRecorder::SoundRecorder() [CONSTRUCTOR]
  *****.exe!cMicRecord::cMicRecord() [CONSTRUCTOR]


It crashes here, it appears that m_mutex is NULL.
In my implementation I have a m_mutex too and if I remove it, it crashes anyway at this line, because of m_mutex implemented in sf::AlResource (for "Very first global device initialization").
Code: [Select]
"SFML/System/Win32/MutexImpl.hpp"

void MutexImpl::lock()
{
    EnterCriticalSection(&m_mutex); // <-- err
}


EDIT 2:
I removed everything in my class, except the (empty) constructor and the two pure virtual member functions (empty too).
It crashes anyway when locking the mutex of sf::AlResource.

EDIT 3:
Okay, it's not about a constructor. It seems that the mutex implemented in sf::AlResource isn't properly initialized. I tried to insert my derived class a way its constructor is called the later I could but even if its mutex isn't NULL, it crashes anyway. So instead of a composition model like, I tried an external agregation with a pointer of my derived class (and allocate at Singleton runtime). And it works...
So I think the derived class constructor calls the sf::AlResource constructor too soon, therefore its mutex isn't totally initialized.

I'll try to find why.

EDIT 4:
I still don't know why the mutex pre-implemented in sf::AlResource isn't properly initialized when its constructor is called, but because I need my derived class to be agregated to a class used a long time after the game's starts, the problem isn't anymore.

Anyway, if somebody know what's the problem and could explain me, I would be glad to understand.

2
Audio / sf::SoundRecorder derived class
« on: December 11, 2017, 08:58:26 pm »
Hello everyone,

I'm trying to make a derived class of sf::SoundRecorder, but I get an error at the start in the constructor:

Code: [Select]
class cMicRecord : public sf::SoundRecorder
{
public:
cMicRecord();
~cMicRecord();

bool isRecording();

protected:
virtual bool onStart();
virtual bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount);
virtual void onStop();

private:
bool m_bRecording;
bool m_bOperational;
};

Quote
Exception is thrown at 0x77D0A225 (ntdll.dll) in ******.exe : 0xC0000005 : Access violation when writing at 0x00000004.
(Screenshot)

I really don't understand how is it possible. I guess I did a mistake in the implementation ?
Is it impossible to make a constructor of a derived class wich has its constructor in protected ?


3
Audio / Re: OpenAL error (AL_OUT_OF_MEMORY)
« on: April 21, 2017, 03:12:12 pm »
Ok I think I found what was the real problem, it seems a sf::sound's pointer could have had an unexpected behavior depending on some cases.
Thank you again for trying to help !

4
Graphics / Re: Multi pass drawing
« on: April 15, 2017, 11:07:44 pm »
Yes, it works !
In my case there are too much render to texture, and draw them to another one is really too expensive in resources (it's starting lagging).

Thank you !

5
Audio / Re: OpenAL error (AL_OUT_OF_MEMORY)
« on: April 15, 2017, 12:32:21 am »
Thank you for helping.

It's really depending on what's happening ingame, I can't really know.
I use a vector of sf::SoundBuffer with 24mb of flac loaded in at startup,
and I get the pointer I need to use it in the processing vector (the one with max 100 elements).

Most of the sounds are just alternatives (e.g multiples step sound), so I guess only the half are used at the same time in the <100 elem vector. One of them is pretty huge tho, ~10mb. All the others are less than 1mb.

6
Graphics / Multi pass drawing
« on: April 14, 2017, 05:01:50 pm »
Hello,

I'm trying to do a multi pass drawing (e.g environment, character, particles), but I can't figure out how to draw sf::RenderTexture to another sf::RenderTexture with a sf::Blend style.

I guess my logic is wrong... How should I draw my drawables to multiples buffers with transparent background, and then draw all this buffers to a sf::RenderTexture with blend style ?

I actually draw all my drawables to the related sf::RenderTexture, and then try to combine all thoses render texture with blend style in one to apply a shader on it.

7
Audio / Re: OpenAL error (AL_OUT_OF_MEMORY)
« on: April 13, 2017, 11:49:27 pm »
Windows 8.1 (64bits), I build in 32bits.

Edit: I put the OpenAL.dll from SFML_2.4.2 zip in the app's executable folder.

8
Audio / Re: OpenAL error (AL_OUT_OF_MEMORY)
« on: April 13, 2017, 09:39:23 pm »
Sorry, I forfot to show the struct:

Quote

struct sSoundManager
{
public:
   sf::Sound m_sound;
   sf::Vector2f m_position;
   bool m_bPlayed;
   int m_iDistanceMin;
   int m_iDistanceMax;
   int m_iTimeToLive;
   int m_iTimeDelay;
   bool m_bTimeToLive_enabled;
   
   sSoundManager()
   {
      m_bPlayed = false;
      m_iTimeToLive = 0;
      m_iTimeDelay = 0;
      m_bTimeToLive_enabled = false;
   }
};

The sf::Sound is deleted with the *sSoundManager when calling m_soundManager.erase(iteratorSounds). Nothing strange according to me.

9
Audio / [SOLVED] OpenAL error (AL_OUT_OF_MEMORY)
« on: April 13, 2017, 03:56:08 pm »
Hello,

I get an AL error, but I have no idea what I did wrong in my code. I really don't think it's a memory problem, I have RAM 16 GB and create new sounds only if there are less than 100 sounds in the vector (I read that it can works until 256).

The first error I get is:
Quote
An internal OpenAL call failed in SoundSource.cpp(37).
Expression:
   alGenSources(1, &m_source)
Error description:
   AL_OUT_OF_MEMORY
   There is not enough memory left to execute the command.

And then, every new sound created implies this error:
Quote
An internal OpenAL call failed in SoundSource.cpp(37).
Expression:
   alSourcei(m_source, AL_BUFFER, 0)
Error description:
   AL_INVALID_NAME
   A bad name (ID) has been specified.

It's probably because of my sound manager, so here is it:
Quote

for (std::vector<sSoundManager*>::iterator iteratorSounds = m_soundManager.begin(); iteratorSounds != m_soundManager.end() ; )
   {   
      if ((*iteratorSounds)->m_bPlayed == false // Play the sound if not played yet
         && (*iteratorSounds)->m_iTimeDelay <= 0)
      {
         (*iteratorSounds)->m_bPlayed = true;
         (*iteratorSounds)->m_sound.play();
         iteratorSounds++;
      }
      else if ((*iteratorSounds)->m_bPlayed == true // Purge played sounds
         && ((*iteratorSounds)->m_sound.getStatus() == sf::Sound::Status::Stopped
         || ((*iteratorSounds)->m_bTimeToLive_enabled && (*iteratorSounds)->m_iTimeToLive <= 0)))
      {
         if ((*iteratorSounds)->m_sound.getStatus() != sf::Sound::Status::Stopped)
            (*iteratorSounds)->m_sound.stop();

         delete(*iteratorSounds);
         iteratorSounds = m_soundManager.erase(iteratorSounds);
      }
      else // Processing sounds
      {
         (*iteratorSounds)->m_iTimeDelay -= m_DeltaTime;

         if ((*iteratorSounds)->m_bTimeToLive_enabled
            && (*iteratorSounds)->m_iTimeDelay <= 0)
            (*iteratorSounds)->m_iTimeToLive -= m_DeltaTime;

         iteratorSounds++;
      }
}

I saw that "erase.()" deletes the element when it want (not instantly)... But I don't think it can be the problem.

Do anybody have an idea where the problem can be ?

10
Network / Re: ttl
« on: March 13, 2017, 12:02:09 am »
Yes, that's the case ! That's why I personally need TTL exposition.

But that's just my example, and I don't think I'm alone.

11
Network / Re: ttl
« on: March 12, 2017, 11:19:29 am »
Okay.

I'm working on a multiplayer game with a VPS as Master Server.
I'll keep a lot of connections opened between the server and each clients in UDP, but I don't want to *really* have a connection between them. The server can take a while before sending the data (so the number of clients waiting can be huge), I just need to keep the router of each client opened to receive it. In my opinion TCP isn't a good alternative.

I usually change the TTL to 3 or 4 maximum so the client's router keep the VPS's ip in its cache but the packet will be deleted quickly before received by the VPS, and any data sent from the Master Server to this router will be rerouted to the local client IP successfully.

It seems to me that TTL modification is pretty used for game network programming. Whether big or small studios.

12
Network / ttl
« on: March 11, 2017, 11:03:53 pm »
Hello,

I'm working on network with SFML and I just would like to know if a next version of the SFML will allow to define the ttl's packet ?

Pages: [1]
anything