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 - Gigotdarnaud

Pages: [1]
1
Problem solved!
As it turns out, the project had been using the wrong DLLs all along.

When building a new project in Visual Studio (I usually don't use it), the runtime couldn't find the DLLs, and when copied near the executable the code didn't crash anymore.
I returned to my usual development environment, did the same thing and voilĂ .
Out of curiosity, how come the call to the DLLs didn't crash closer to the app entry point? Aren't dynamic libraries version-ed or something?

2
Hello,

I am experimenting an odd issue with this code:
#include <SFML/Graphics.hpp>

int main()
{

    sf::RenderTexture test;
    test.create(150, 150);

    sf::RectangleShape bg(sf::Vector2f(50, 50));
    bg.setFillColor(sf::Color(255, 0, 0));

    test.draw(bg);

    return 0;
}

The call to sf::RenderTexture::draw crashes the program.

I did not have this issue back when I used MSVC10 and the SFML 2.1 binaries downloaded from the site. Since I needed advanced C++11 features, I upgraded to MSVC12, built SFML from source using SFML Installer. Everything compiled as usual (it links just fine, the binaries were indeed made by and for MSVC12), until I started to call sf::RenderTexture to, well, render on a texture.

Note that sf::RenderWindow works just fine.

I am rebuilding SFML one more time right now, just in case something went wrong the first time, but it seems unlikely.

Any idea?


EDIT:
Even with the rebuild it crashes. I believe we can rule that one out.

3
Audio / sf::SoundStream throws std::bad_alloc
« on: July 27, 2012, 08:38:49 pm »
Hello again,
I got a new issue with my little VOIP system. Now the sf::SoundStream seems to work fine, until it throws a std::bad_alloc exception after some time (it goes from ten seconds to a few minutes).
Trouble is, the memory consumption is stable (+/- 4,7Mo, Qt is quite heavy even without a GUI), so it's not just a memory leak waiting to be fixed. Since sf::SoundStream delete its OpenAL buffers, but only when the recording is stopped, I have to call stop()/play() every once in a while to clear the memory though.

The code:

Player.h
#ifndef PLAYER_H
#define PLAYER_H

#include <QObject>
#include <QQueue>
#include <SFML2/Audio.hpp>

#include <QMetaType>
#include <QVector>

typedef QVector<sf::Int16> IntVector;
Q_DECLARE_METATYPE(IntVector);

#include <QDebug>
#define D() qDebug() << __FILE__ << ";" << __LINE__

class Player : public QObject, public sf::SoundStream
{
    Q_OBJECT
    public:
        Player(size_t sampleRate);

    public slots:
        void queue(const IntVector& frame);

    protected:
        virtual bool onGetData(Chunk& Data);
        virtual void onSeek(sf::Time) {}

    private:

        size_t m_pending;

        QQueue<Chunk> m_buffers;

        sf::Mutex m_mutex;

};

#endif // PLAYER_H
 

Player.cpp
#include "Player.h"

#define MAX_BUFFER 10
#define CLEAR_BUFFER 15 //Has to be > to sf::SoundStream internal buffer count to prevent shuttering. Aims to prevent a huge memory leak.

Player::Player(size_t sampleRate)
{
    m_pending=0;

    initialize(1, sampleRate);
}

bool Player::onGetData(Chunk& Data)
{
    Chunk chu;
    m_mutex.lock();
    if(m_buffers.size() == 0)
    {
        sf::Int16* s =new sf::Int16[1000];
        for(size_t i=0;i<1000;++i)
            s[i]=0;

        chu.sampleCount=1000;
        chu.samples=s;
    }
    else
    {
        chu=m_buffers.dequeue();
    }

    D() << m_pending << m_buffers.size();

    Data=chu;
    ++m_pending;
    m_mutex.unlock();
    return true;
}

void Player::queue(const IntVector& frame)
{
    m_mutex.lock();
    if(m_buffers.size()>=MAX_BUFFER)
    {
        D() << "No buffers available!";
        return;
    }

    if(frame.size() == 0)
        return;

    Chunk chu;
    chu.sampleCount=frame.size();
    sf::Int16* s=new sf::Int16[chu.sampleCount];

    for(size_t i=0;i<chu.sampleCount;++i)
        s[i]=frame[i];

    chu.samples=s;

    m_buffers.enqueue(chu);

    if(m_pending>=CLEAR_BUFFER)
    {
       stop(); // Will clear all the OpenAL buffers as a side effect
       m_pending=0;

       play();
    }
    m_mutex.unlock();
}
 

Debugging with GDB just give my a Segfault and no useful information whatsoever, just that it happens in "rtlsidhashlookup" in ntdll.dll. No exception caught it seems.

I am probably doing something wrong. I uploaded the whole test project (with the SoundRecorder subclass, the main file...) here in case you want to see if it's coming from somewhere else, but I doubt it. I didn't have this problem when the sf::SoundStream subclass wasn't working at all.

Using: SFML 2.0 RC, Qt (core only, unrelated to the issue), Mingw, Windows 7 64bits.

Thanks.

[attachment deleted by admin]

4
Audio / Re: sf::SoundStream::OnGetData called only a few times
« on: July 25, 2012, 11:24:45 pm »
Hum, so if I don't receive anything from the network, I have to create a few zero-ed frames? Why not, it should be an easy fix. I'll try it ASAP and get back with what I've found.
However, what I don't get is that I couldn't restart the SoundStream once it went down because of an empty frame with "Play".
Anyway, this behavior should be explained in the documentation or the tutorial (something like "Warning: the Chunk must NOT be empty, or else!").

Thank you again Laurent.

EDIT: It seems to be working just fine now:

bool Player::onGetData(Chunk& Data)
{
    sf::Int16* buff=new sf::Int16[800];
    Data.samples=buff;
    Data.sampleCount=800;

     D() << "B";
    return true;
}
 

Now I got a segfault on exit though (Ctrl-C from the terminal is quite violent thought, I hope a 'softer' exit will fix it)

5
Audio / Re: sf::SoundStream::OnGetData called only a few times
« on: July 25, 2012, 12:00:52 pm »
Okay, so I got a few updates.
I made a new code from scratch in a new project, still with SFML 1.6, and I still got this strange behavior.
I migrated to SFML 2.0, changed a few things in the code because of the new name conventions, and this is the code I got in the end:

Main.cpp
#include <QCoreApplication>

#include "Player.h"

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);

    Player play(44100);
    play.play();

    return app.exec();
}
 

Player.h
#ifndef PLAYER_H
#define PLAYER_H

#include <QObject>
#include <SFML2/Audio.hpp>

#include <QDebug>
#define D() qDebug() << __FILE__ << ";" << __LINE__

class Player : public QObject, public sf::SoundStream
{
    public:
        Player(size_t sampleRate);

    protected:
        virtual bool onGetData(Chunk& Data);
        virtual void onSeek(sf::Time) {}

};

#endif // PLAYER_H
 

Player.cpp
#include "Player.h"

Player::Player(size_t sampleRate)
{
    initialize(1, sampleRate);
}

bool Player::onGetData(Chunk& Data)
{
     D() << "B";
    return true;
}
 

Aaaand it still don't work. I got three "B", and then nothing, onGetData() isn't called anymore. Is it because I don't give any data the first three times? It just doesn't make any sense.

6
Audio / sf::SoundStream::OnGetData called only a few times
« on: July 24, 2012, 11:58:08 am »
Hello,

I'm using sf::SoundRecorder / sf::SoundStream to make a VOIP client. The recording and the networking (using Qt for the later) are working just fine (except that the SoundRecorder crash on exit, go figure), but I'm running into a weird behavior when I'm subclassing sf::SoundStream.

Beforehand, my code:
Sound.h
#ifndef DEF_SOUND
#define DEF_SOUND
/* Some includes */

class Sound : public QObject, public sf::SoundStream
{
    Q_OBJECT
    public:
        Sound(size_t sampleRate);

    protected:

        virtual bool OnGetData(Chunk& Data);

    public slots:

        void queue(const IntVector & samples);

    private:

        sf::Mutex m_bmux;
        QQueue<IntVector > m_buff;

        size_t m_sampleRate;

};

#endif
 

Sound.cpp
#include "Sound.h"

#include <QDebug>
#define D() qDebug() << __FILE__ << ";" << __LINE__


Sound::Sound(size_t sampleRate):sf::SoundStream()
{
    m_sampleRate=sampleRate;
    Initialize(1, m_sampleRate);
    Play();
}


bool Sound::OnGetData(Chunk& Data)
{
    m_bmux.Lock();
    if(m_buff.size()<1)
    {
        m_bmux.Unlock();
        return true;
    }

    IntVector bu = m_buff.dequeue();

    m_bmux.Unlock();


    size_t bfs=bu.size();
    sf::Int16* bf=new sf::Int16[bfs]; //Possible memory leak? SFML documentation is unclear about that...

    for(size_t i=0;i<bfs;++i)
        bf[i]=bu[i];


    Data.Samples   = bf;
    Data.NbSamples = bfs;

    D() << "B";

    return true;
}

void Sound::queue(const IntVector & samples)
{
    m_bmux.Lock();
    if(m_buff.size() < 150)
        m_buff.enqueue(samples);
    else
        D() << "Buffer full!";
    m_bmux.Unlock();

    Play();
    D() << "A";

}
 

IntVector is a QVector<sf::Int16> typedef.
All the Qt containers behave like STL's here. A queue's a queue, and a "vector" is a wrapper over a C-array.
I call queue() every once in a while (each time I receive a frame). For debug purpose it's at the moment directly connected to a sf::SoundRecorder.

The minor part of the problem:
in OnGetData(), do I loose the ownership of the data array I put into the chunk? Both the documentation and the tutorial are very vague about it.

The MAJOR part of the problem:
I expected the console output to be ABABAB..., give or take.
What I get, however, is "ABBBAAAAAAAAAA...". OnGetData() just stop being called, yet the GetState() function still return Playing.
I tried delaying the Play() call, calling it only when there are at least 3 frames in the buffer. This time I got "AAABBBAABBAABBAABBAAAAAAAAAAAAAAAAAA...", so it's kind of better, but it's still broken.
I tried calling Initialize(), Stop(), etc. pretty much everywhere in the code, obviously it just doesn't work this way.

I'm compiling with Mingw32, on a 64bits Windows 7. I used to work with OpenAL directly, but it was a pain to debug and to maintain, this is why I switched to SFML 1.6 for the VOIP.

Anyone got a suggestion on what's wrong with what I've done here?

Thanks,

Gig


PS: I apologize for my English, it is not my mothertongue.

Pages: [1]