QtMobility Reference Documentation

Contents

QSampleCache Class Reference

 #include <QSampleCache>

Inherits QObject (private).

This class was introduced in Qt Mobility 1.1.

Public Functions

QSampleCache ()
~QSampleCache ()
QSample * requestSample ( const QUrl & url )
void setCapacity ( qint64 capacity )

Additional Inherited Members

Detailed Description

When you want to get a sound sample data, you need to request the QSample reference from QSampleCache.

   QSample *m_sample;     // class member.

 private Q_SLOTS:
   void decoderError();
   void sampleReady();
 Q_GLOBAL_STATIC(QSampleCache, sampleCache) //declare a singleton manager
   m_sample = sampleCache()->requestSample(url);
   switch(m_sample->state()) {
   case QSample::Ready:
       sampleReady();
       break;
   case QSample::Error:
       decoderError();
       break;
   default:
       connect(m_sample, SIGNAL(error()), this, SLOT(decoderError()));
       connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
       break;
   }

When you no longer need the sound sample data, you need to release it:

  if (m_sample) {
      m_sample->release();
      m_sample = 0;
  }

Member Function Documentation

QSampleCache::QSampleCache ()

QSampleCache::~QSampleCache ()

QSample * QSampleCache::requestSample ( const QUrl & url )

void QSampleCache::setCapacity ( qint64 capacity )