Hi,
This is error message I'm getting: AL lib: pulseaudio.c:386: Context did not get ready: Connection refused
What does it mean? What's causing it and how to do I fix it?
// main.cpp
//
#include <QFile>
#include "Snd.h"
int main(int argc, char *argv[])
{
QFile file("test.wav");
if (file.open(QIODevice::ReadOnly)) {
qDebug("file opened\n");
int size = file.size();
char * buf = new char[size];;
file.read(buf, size);
char t[5];
t[4] = 0;
memcpy(t, buf, 4);
qDebug("header: %s\n", t);
CSnd snd;
snd.Create(buf, size, QString("test"));
snd.Play();
delete [] buf;
}
return 0;
}
// Snd.h : header file
//
#ifndef _SND_H
#define _SND_H
#include <QtGui/QApplication>
#include <SFML/Audio.hpp>
/////////////////////////////////////////////////////////////////////////////
// CSnd
class CSnd
{
// Construction
public:
CSnd();
// Attributes
public:
bool IsValid () {
return m_buffer && m_sound;
}
QString GetName() const;
// Operations
public:
void SetName (const QString);
bool Create(const char *, int, const QString );
bool Play ();
bool Stop ();
void RemoveAt (int n);
// Implementation
public:
~CSnd();
protected:
sf::SoundBuffer *m_buffer;
sf::Sound *m_sound;
QString m_name;
};
/////////////////////////////////////////////////////////////////////////////
#endif
// Snd.cpp : implementation file
//
#include "Snd.h"
#define q2c(__qstring__) (char*) __qstring__.toAscii().constData()
/////////////////////////////////////////////////////////////////////////////
// CSnd
CSnd::CSnd()
{
m_buffer = NULL;
m_sound = NULL;
}
CSnd::~CSnd()
{
if (m_buffer) {
delete m_buffer;
}
if (m_sound) {
delete m_sound;
}
}
/////////////////////////////////////////////////////////////////////////////
// CSnd message handlers
bool CSnd::Play ()
{
if (IsValid() == FALSE) {
// qDebug ("Warning - Cannot play from an invalid CSnd object '%s'\n", q2c(m_name));
return false;
}
sf::Sound::Status status = m_sound->GetStatus();
if (status != sf::Sound::Playing ) {
m_sound->Play();
return true;
}
return true;
}
bool CSnd::Stop ()
{
return false;
}
bool CSnd::Create(const char *buffer, int size, const QString name)
{
if (!size) return true;
if (!buffer ){
qDebug("buffer is null\n");
}
m_sound = new sf::Sound;
m_buffer = new sf::SoundBuffer;
if (!m_buffer->LoadFromMemory(buffer, size))
{
qDebug("couldn't create: %s\n", q2c(name));
return false;
}
m_sound->SetBuffer(*m_buffer);
m_name = name;
return true;
}
QString CSnd::GetName() const
{
return m_name;
}
void CSnd::SetName(const QString name)
{
m_name = name;
}
Running OpenSuse 11.2. Latest stable release.
Regards.
Frank B.[/code]