svcore  1.9
MP3FileReader Class Reference

#include <MP3FileReader.h>

Inheritance diagram for MP3FileReader:
Collaboration diagram for MP3FileReader:

Classes

struct  DecoderData
 
class  DecodeThread
 

Public Types

enum  DecodeMode { DecodeAtOnce, DecodeThreaded }
 
enum  CacheMode { CacheInTemporaryFile, CacheInMemory }
 
typedef std::map< QString, QString > TagMap
 

Public Slots

void cancelled ()
 

Signals

void progress (int)
 
void frameCountChanged ()
 

Public Member Functions

 MP3FileReader (FileSource source, DecodeMode decodeMode, CacheMode cacheMode, int targetRate=0, bool normalised=false, ProgressReporter *reporter=0)
 
virtual ~MP3FileReader ()
 
virtual QString getError () const
 
virtual QString getLocation () const
 Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example). More...
 
virtual QString getTitle () const
 Return the title of the work in the audio file, if known. More...
 
virtual QString getMaker () const
 Return the "maker" of the work in the audio file, if known. More...
 
virtual TagMap getTags () const
 
virtual int getDecodeCompletion () const
 
virtual bool isUpdating () const
 
virtual void getInterleavedFrames (int start, int count, SampleBlock &frames) const
 Return interleaved samples for count frames from index start. More...
 
virtual int getNativeRate () const
 
virtual bool isQuicklySeekable () const
 Intermediate cache means all CodedAudioFileReaders are quickly seekable. More...
 
bool isOK () const
 
int getFrameCount () const
 
int getChannelCount () const
 
int getSampleRate () const
 
virtual void getDeInterleavedFrames (int start, int count, std::vector< SampleBlock > &frames) const
 Return de-interleaved samples for count frames from index start. More...
 

Static Public Member Functions

static void getSupportedExtensions (std::set< QString > &extensions)
 
static bool supportsExtension (QString ext)
 
static bool supportsContentType (QString type)
 
static bool supports (FileSource &source)
 

Protected Member Functions

bool decode (void *mm, int sz)
 
enum mad_flow accept (struct mad_header const *, struct mad_pcm *)
 
void loadTags ()
 
QString loadTag (void *vtag, const char *name)
 
void initialiseDecodeCache ()
 
void addSamplesToDecodeCache (float **samples, int nframes)
 
void addSamplesToDecodeCache (float *samplesInterleaved, int nframes)
 
void addSamplesToDecodeCache (const SampleBlock &interleaved)
 
void finishDecodeCache ()
 
bool isDecodeCacheInitialised () const
 
void startSerialised (QString id)
 
void endSerialised ()
 

Static Protected Member Functions

static enum mad_flow input (void *, struct mad_stream *)
 
static enum mad_flow output (void *, struct mad_header const *, struct mad_pcm *)
 
static enum mad_flow error (void *, struct mad_stream *, struct mad_frame *)
 

Protected Attributes

FileSource m_source
 
QString m_path
 
QString m_error
 
QString m_title
 
QString m_maker
 
TagMap m_tags
 
int m_fileSize
 
double m_bitrateNum
 
int m_bitrateDenom
 
int m_completion
 
bool m_done
 
unsigned char * m_filebuffer
 
float ** m_samplebuffer
 
int m_samplebuffersize
 
ProgressReporterm_reporter
 
bool m_cancelled
 
DecodeThreadm_decodeThread
 
QMutex m_cacheMutex
 
CacheMode m_cacheMode
 
SampleBlock m_data
 
QReadWriteLock m_dataLock
 
bool m_initialised
 
Serialiserm_serialiser
 
int m_fileRate
 
QString m_cacheFileName
 
SNDFILE * m_cacheFileWritePtr
 
WavFileReaderm_cacheFileReader
 
float * m_cacheWriteBuffer
 
int m_cacheWriteBufferIndex
 
int m_cacheWriteBufferSize
 
Resamplerm_resampler
 
float * m_resampleBuffer
 
int m_fileFrameCount
 
bool m_normalised
 
float m_max
 
float m_gain
 
int m_frameCount
 
int m_channelCount
 
int m_sampleRate
 

Detailed Description

Definition at line 30 of file MP3FileReader.h.

Member Typedef Documentation

◆ TagMap

typedef std::map<QString, QString> AudioFileReader::TagMap
inherited

Definition at line 65 of file AudioFileReader.h.

Member Enumeration Documentation

◆ DecodeMode

Enumerator
DecodeAtOnce 
DecodeThreaded 

Definition at line 35 of file MP3FileReader.h.

◆ CacheMode

Enumerator
CacheInTemporaryFile 
CacheInMemory 

Definition at line 36 of file CodedAudioFileReader.h.

Constructor & Destructor Documentation

◆ MP3FileReader()

◆ ~MP3FileReader()

MP3FileReader::~MP3FileReader ( )
virtual

Definition at line 149 of file MP3FileReader.cpp.

References m_cancelled, and m_decodeThread.

Member Function Documentation

◆ getError()

virtual QString MP3FileReader::getError ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 48 of file MP3FileReader.h.

References m_error.

◆ getLocation()

virtual QString MP3FileReader::getLocation ( ) const
inlinevirtual

Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example).

Reimplemented from AudioFileReader.

Definition at line 50 of file MP3FileReader.h.

References FileSource::getLocation(), and m_source.

◆ getTitle()

virtual QString MP3FileReader::getTitle ( ) const
inlinevirtual

Return the title of the work in the audio file, if known.

This may be implemented by subclasses that support file tagging. This is not the same thing as the file name.

Reimplemented from AudioFileReader.

Definition at line 51 of file MP3FileReader.h.

References m_title.

◆ getMaker()

virtual QString MP3FileReader::getMaker ( ) const
inlinevirtual

Return the "maker" of the work in the audio file, if known.

This could represent almost anything (band, composer, conductor, artist etc).

Reimplemented from AudioFileReader.

Definition at line 52 of file MP3FileReader.h.

References m_maker.

◆ getTags()

virtual TagMap MP3FileReader::getTags ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 53 of file MP3FileReader.h.

References m_tags.

◆ getSupportedExtensions()

void MP3FileReader::getSupportedExtensions ( std::set< QString > &  extensions)
static

◆ supportsExtension()

bool MP3FileReader::supportsExtension ( QString  ext)
static

Definition at line 451 of file MP3FileReader.cpp.

References getSupportedExtensions().

Referenced by supports().

◆ supportsContentType()

bool MP3FileReader::supportsContentType ( QString  type)
static

Definition at line 459 of file MP3FileReader.cpp.

Referenced by supports().

◆ supports()

bool MP3FileReader::supports ( FileSource source)
static

◆ getDecodeCompletion()

virtual int MP3FileReader::getDecodeCompletion ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 60 of file MP3FileReader.h.

References m_completion.

◆ isUpdating()

virtual bool MP3FileReader::isUpdating ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 62 of file MP3FileReader.h.

References m_decodeThread.

◆ cancelled

void MP3FileReader::cancelled ( )
slot

Definition at line 159 of file MP3FileReader.cpp.

References m_cancelled.

Referenced by MP3FileReader().

◆ decode()

bool MP3FileReader::decode ( void *  mm,
int  sz 
)
protected

◆ accept()

◆ input()

enum mad_flow MP3FileReader::input ( void *  dp,
struct mad_stream *  stream 
)
staticprotected

Definition at line 312 of file MP3FileReader.cpp.

References MP3FileReader::DecoderData::length, and MP3FileReader::DecoderData::start.

Referenced by decode().

◆ output()

enum mad_flow MP3FileReader::output ( void *  dp,
struct mad_header const *  header,
struct mad_pcm *  pcm 
)
staticprotected

Definition at line 339 of file MP3FileReader.cpp.

References accept(), and MP3FileReader::DecoderData::reader.

Referenced by decode().

◆ error()

enum mad_flow MP3FileReader::error ( void *  ,
struct mad_stream *  ,
struct mad_frame *   
)
staticprotected

Definition at line 431 of file MP3FileReader.cpp.

Referenced by decode().

◆ loadTags()

void MP3FileReader::loadTags ( )
protected

Definition at line 165 of file MP3FileReader.cpp.

References loadTag(), m_maker, m_path, m_tags, m_title, and SVDEBUG.

Referenced by MP3FileReader().

◆ loadTag()

QString MP3FileReader::loadTag ( void *  vtag,
const char *  name 
)
protected

Definition at line 211 of file MP3FileReader.cpp.

References SVDEBUG.

Referenced by loadTags().

◆ getInterleavedFrames()

void CodedAudioFileReader::getInterleavedFrames ( int  start,
int  count,
SampleBlock frames 
) const
virtualinherited

Return interleaved samples for count frames from index start.

The resulting sample block will contain count * getChannelCount() samples (or fewer if end of file is reached).

The subclass implementations of this function must be thread-safe – that is, safe to call from multiple threads with different arguments on the same object at the same time.

Implements AudioFileReader.

Definition at line 409 of file CodedAudioFileReader.cpp.

References CodedAudioFileReader::CacheInMemory, CodedAudioFileReader::CacheInTemporaryFile, WavFileReader::getInterleavedFrames(), AudioFileReader::isOK(), CodedAudioFileReader::m_cacheFileReader, CodedAudioFileReader::m_cacheMode, AudioFileReader::m_channelCount, CodedAudioFileReader::m_data, CodedAudioFileReader::m_dataLock, CodedAudioFileReader::m_gain, CodedAudioFileReader::m_initialised, CodedAudioFileReader::m_normalised, and SVDEBUG.

◆ getNativeRate()

virtual int CodedAudioFileReader::getNativeRate ( ) const
inlinevirtualinherited

Reimplemented from AudioFileReader.

Definition at line 44 of file CodedAudioFileReader.h.

References CodedAudioFileReader::m_fileRate.

◆ isQuicklySeekable()

virtual bool CodedAudioFileReader::isQuicklySeekable ( ) const
inlinevirtualinherited

Intermediate cache means all CodedAudioFileReaders are quickly seekable.

Implements AudioFileReader.

Definition at line 47 of file CodedAudioFileReader.h.

◆ progress

void CodedAudioFileReader::progress ( int  )
signalinherited

◆ initialiseDecodeCache()

◆ addSamplesToDecodeCache() [1/3]

◆ addSamplesToDecodeCache() [2/3]

◆ addSamplesToDecodeCache() [3/3]

◆ finishDecodeCache()

◆ isDecodeCacheInitialised()

◆ startSerialised()

void CodedAudioFileReader::startSerialised ( QString  id)
protectedinherited

◆ endSerialised()

◆ isOK()

◆ getFrameCount()

◆ getChannelCount()

◆ getSampleRate()

int AudioFileReader::getSampleRate ( ) const
inlineinherited

◆ getDeInterleavedFrames()

void AudioFileReader::getDeInterleavedFrames ( int  start,
int  count,
std::vector< SampleBlock > &  frames 
) const
virtualinherited

Return de-interleaved samples for count frames from index start.

Implemented in this class (it calls getInterleavedFrames and de-interleaves). The resulting vector will contain getChannelCount() sample blocks of count samples each (or fewer if end of file is reached).

Definition at line 19 of file AudioFileReader.cpp.

References AudioFileReader::getChannelCount(), and AudioFileReader::getInterleavedFrames().

◆ frameCountChanged

void AudioFileReader::frameCountChanged ( )
signalinherited

Member Data Documentation

◆ m_source

FileSource MP3FileReader::m_source
protected

Definition at line 70 of file MP3FileReader.h.

Referenced by getLocation().

◆ m_path

QString MP3FileReader::m_path
protected

Definition at line 71 of file MP3FileReader.h.

Referenced by loadTags(), MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_error

QString MP3FileReader::m_error
protected

Definition at line 72 of file MP3FileReader.h.

Referenced by getError(), MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_title

QString MP3FileReader::m_title
protected

Definition at line 73 of file MP3FileReader.h.

Referenced by getTitle(), and loadTags().

◆ m_maker

QString MP3FileReader::m_maker
protected

Definition at line 74 of file MP3FileReader.h.

Referenced by getMaker(), and loadTags().

◆ m_tags

TagMap MP3FileReader::m_tags
protected

Definition at line 75 of file MP3FileReader.h.

Referenced by getTags(), and loadTags().

◆ m_fileSize

int MP3FileReader::m_fileSize
protected

Definition at line 76 of file MP3FileReader.h.

Referenced by accept(), MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_bitrateNum

double MP3FileReader::m_bitrateNum
protected

Definition at line 77 of file MP3FileReader.h.

Referenced by accept(), and MP3FileReader().

◆ m_bitrateDenom

int MP3FileReader::m_bitrateDenom
protected

Definition at line 78 of file MP3FileReader.h.

Referenced by accept(), and MP3FileReader().

◆ m_completion

int MP3FileReader::m_completion
protected

◆ m_done

bool MP3FileReader::m_done
protected

Definition at line 80 of file MP3FileReader.h.

Referenced by decode(), MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_filebuffer

unsigned char* MP3FileReader::m_filebuffer
protected

Definition at line 82 of file MP3FileReader.h.

Referenced by MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_samplebuffer

float** MP3FileReader::m_samplebuffer
protected

Definition at line 83 of file MP3FileReader.h.

Referenced by accept(), MP3FileReader(), and MP3FileReader::DecodeThread::run().

◆ m_samplebuffersize

int MP3FileReader::m_samplebuffersize
protected

Definition at line 84 of file MP3FileReader.h.

Referenced by accept(), and MP3FileReader().

◆ m_reporter

ProgressReporter* MP3FileReader::m_reporter
protected

Definition at line 86 of file MP3FileReader.h.

Referenced by accept(), and MP3FileReader().

◆ m_cancelled

bool MP3FileReader::m_cancelled
protected

Definition at line 87 of file MP3FileReader.h.

Referenced by accept(), cancelled(), MP3FileReader(), and ~MP3FileReader().

◆ m_decodeThread

DecodeThread* MP3FileReader::m_decodeThread
protected

Definition at line 113 of file MP3FileReader.h.

Referenced by isUpdating(), MP3FileReader(), and ~MP3FileReader().

◆ m_cacheMutex

◆ m_cacheMode

◆ m_data

◆ m_dataLock

QReadWriteLock CodedAudioFileReader::m_dataLock
mutableprotectedinherited

◆ m_initialised

◆ m_serialiser

Serialiser* CodedAudioFileReader::m_serialiser
protectedinherited

◆ m_fileRate

◆ m_cacheFileName

QString CodedAudioFileReader::m_cacheFileName
protectedinherited

◆ m_cacheFileWritePtr

◆ m_cacheFileReader

◆ m_cacheWriteBuffer

◆ m_cacheWriteBufferIndex

int CodedAudioFileReader::m_cacheWriteBufferIndex
protectedinherited

◆ m_cacheWriteBufferSize

int CodedAudioFileReader::m_cacheWriteBufferSize
protectedinherited

◆ m_resampler

◆ m_resampleBuffer

◆ m_fileFrameCount

int CodedAudioFileReader::m_fileFrameCount
protectedinherited

◆ m_normalised

bool CodedAudioFileReader::m_normalised
protectedinherited

◆ m_max

float CodedAudioFileReader::m_max
protectedinherited

◆ m_gain

float CodedAudioFileReader::m_gain
protectedinherited

◆ m_frameCount

◆ m_channelCount

◆ m_sampleRate


The documentation for this class was generated from the following files: