kwave  18.07.70
Kwave::CodecPlugin Class Referenceabstract

#include <CodecPlugin.h>

Inheritance diagram for Kwave::CodecPlugin:
Inheritance graph
Collaboration diagram for Kwave::CodecPlugin:
Collaboration graph

Classes

struct  Codec
 

Public Member Functions

 CodecPlugin (QObject *parent, const QVariantList &args, Codec &codec)
 
virtual ~CodecPlugin () Q_DECL_OVERRIDE
 
virtual void load (QStringList &) Q_DECL_OVERRIDE
 
virtual void unload () Q_DECL_OVERRIDE
 
virtual QList< Kwave::Decoder * > createDecoder ()=0
 
virtual QList< Kwave::Encoder * > createEncoder ()=0
 
- Public Member Functions inherited from Kwave::Plugin
 Plugin (QObject *parent, const QVariantList &args)
 
virtual ~Plugin () Q_DECL_OVERRIDE
 
virtual QString name () const
 
virtual QString description () const
 
virtual QString progressText ()
 
virtual bool canClose () const
 
bool isRunning () const
 
bool shouldStop () const
 
virtual QStringList * setup (QStringList &previous_params)
 
virtual int start (QStringList &params)
 
virtual int stop ()
 
virtual void run (QStringList params)
 
Kwave::PluginManagermanager () const
 
Kwave::SignalManagersignalManager ()
 
QWidget * parentWidget () const
 
QString signalName ()
 
virtual sample_index_t signalLength ()
 
virtual double signalRate ()
 
virtual const QList< unsigned int > selectedTracks ()
 
virtual sample_index_t selection (QList< unsigned int > *tracks=Q_NULLPTR, sample_index_t *left=Q_NULLPTR, sample_index_t *right=Q_NULLPTR, bool expand_if_empty=false)
 
virtual void selectRange (sample_index_t offset, sample_index_t length)
 
virtual void migrateToActiveContext ()
 
- Public Member Functions inherited from Kwave::Runnable
virtual ~Runnable ()
 

Protected Member Functions

template<class T >
QList< Kwave::Decoder * > singleDecoder ()
 
template<class T >
QList< Kwave::Encoder * > singleEncoder ()
 
- Protected Member Functions inherited from Kwave::Plugin
int execute (QStringList &params)
 
void emitCommand (const QString &command)
 
void use ()
 
void setPluginManager (Kwave::PluginManager *new_plugin_manager)
 
virtual void run_wrapper (const QVariant &params) Q_DECL_OVERRIDE
 

Private Attributes

Codecm_codec
 

Additional Inherited Members

- Public Slots inherited from Kwave::Plugin
virtual void setProgressDialogEnabled (bool enable)
 
virtual void updateProgress (qreal progress)
 
virtual void cancel ()
 
virtual void close ()
 
void release ()
 
- Signals inherited from Kwave::Plugin
void sigRunning (Kwave::Plugin *plugin)
 
void sigDone (Kwave::Plugin *plugin)
 
void sigClosed (Kwave::Plugin *p)
 
void sigCommand (const QString &command)
 
void setProgressText (const QString &text)
 

Detailed Description

Definition at line 33 of file CodecPlugin.h.

Constructor & Destructor Documentation

◆ CodecPlugin()

Kwave::CodecPlugin::CodecPlugin ( QObject *  parent,
const QVariantList &  args,
Codec codec 
)

Constructor

Parameters
parentpointer to the corresponding plugin manager
argsargument list, containts internal meta data
codecreference to a static container for the codec

Definition at line 26 of file CodecPlugin.cpp.

29  :Kwave::Plugin(parent, args), m_codec(codec)
30 {
31 }

◆ ~CodecPlugin()

Kwave::CodecPlugin::~CodecPlugin ( )
virtual

Destructor

Definition at line 34 of file CodecPlugin.cpp.

35 {
36 }

Member Function Documentation

◆ createDecoder()

virtual QList<Kwave::Decoder *> Kwave::CodecPlugin::createDecoder ( )
pure virtual

Create a new set of decoders

Returns
list of decoders, may be empty

Implemented in Kwave::MP3CodecPlugin, Kwave::FlacCodecPlugin, Kwave::AsciiCodecPlugin, Kwave::OggCodecPlugin, Kwave::WavCodecPlugin, and Kwave::AudiofileCodecPlugin.

Referenced by load().

Here is the caller graph for this function:

◆ createEncoder()

virtual QList<Kwave::Encoder *> Kwave::CodecPlugin::createEncoder ( )
pure virtual

Create a new set of encoders

Returns
list of encoders, may be empty

Implemented in Kwave::MP3CodecPlugin, Kwave::FlacCodecPlugin, Kwave::AsciiCodecPlugin, Kwave::OggCodecPlugin, Kwave::WavCodecPlugin, and Kwave::AudiofileCodecPlugin.

Referenced by load().

Here is the caller graph for this function:

◆ load()

void Kwave::CodecPlugin::load ( QStringList &  )
virtual

Gets called when the plugin is first loaded. Registers new encoder and decoder on first call, all subsequenct calls only increment the reference count of the existing encoder/decoder instances.

Reimplemented from Kwave::Plugin.

Reimplemented in Kwave::MP3CodecPlugin.

Definition at line 39 of file CodecPlugin.cpp.

References createDecoder(), createEncoder(), m_codec, Kwave::CodecPlugin::Codec::m_decoder, Kwave::CodecPlugin::Codec::m_encoder, Kwave::CodecPlugin::Codec::m_use_count, Kwave::CodecManager::registerDecoder(), Kwave::CodecManager::registerEncoder(), and Kwave::Plugin::use().

Referenced by Kwave::MP3CodecPlugin::load().

40 {
41  use();
42 
44  if (m_codec.m_use_count == 1)
45  {
47  if (!m_codec.m_encoder.isEmpty())
48  foreach (Kwave::Encoder *enc, m_codec.m_encoder)
50 
52  if (!m_codec.m_decoder.isEmpty())
53  foreach (Kwave::Decoder *dec, m_codec.m_decoder)
55  }
56 }
QList< Kwave::Encoder * > m_encoder
Definition: CodecPlugin.h:40
virtual QList< Kwave::Encoder * > createEncoder()=0
QList< Kwave::Decoder * > m_decoder
Definition: CodecPlugin.h:41
static void registerDecoder(Kwave::Decoder &decoder)
virtual QList< Kwave::Decoder * > createDecoder()=0
void use()
Definition: Plugin.cpp:412
static void registerEncoder(Kwave::Encoder &encoder)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ singleDecoder()

template<class T >
QList<Kwave::Decoder *> Kwave::CodecPlugin::singleDecoder ( )
inlineprotected

helper template to return a list with a single decoder, for use within createDecoder()

Definition at line 87 of file CodecPlugin.h.

88  {
89  QList<Kwave::Decoder *> list;
90  list.append(new(std::nothrow) T);
91  return list;
92  }

◆ singleEncoder()

template<class T >
QList<Kwave::Encoder *> Kwave::CodecPlugin::singleEncoder ( )
inlineprotected

helper template to return a list with a single encoder, for use within createEncoder()

Definition at line 98 of file CodecPlugin.h.

99  {
100  QList<Kwave::Encoder *> list;
101  list.append(new(std::nothrow) T);
102  return list;
103  }

◆ unload()

void Kwave::CodecPlugin::unload ( )
virtual

Gets called before the plugin is unloaded. Decrements the use count of existing encoder/decoder instances and removes them if zero gets reached.

Reimplemented from Kwave::Plugin.

Definition at line 59 of file CodecPlugin.cpp.

References m_codec, Kwave::CodecPlugin::Codec::m_decoder, Kwave::CodecPlugin::Codec::m_encoder, Kwave::CodecPlugin::Codec::m_use_count, Kwave::Plugin::release(), Kwave::CodecManager::unregisterDecoder(), and Kwave::CodecManager::unregisterEncoder().

60 {
62 
63  if (m_codec.m_use_count < 1)
64  {
65  while (!m_codec.m_decoder.isEmpty()) {
66  Kwave::Decoder *dec = m_codec.m_decoder.takeLast();
68  delete dec;
69  }
70 
71  while (!m_codec.m_encoder.isEmpty()) {
72  Kwave::Encoder *enc = m_codec.m_encoder.takeLast();
74  delete enc;
75  }
76  }
77 
78  release();
79 }
QList< Kwave::Encoder * > m_encoder
Definition: CodecPlugin.h:40
void release()
Definition: Plugin.cpp:420
QList< Kwave::Decoder * > m_decoder
Definition: CodecPlugin.h:41
static void unregisterEncoder(Kwave::Encoder *encoder)
static void unregisterDecoder(Kwave::Decoder *decoder)
Here is the call graph for this function:

Member Data Documentation

◆ m_codec

Codec& Kwave::CodecPlugin::m_codec
private

reference to the static container with encoder/decoder/usecount

Definition at line 108 of file CodecPlugin.h.

Referenced by load(), and unload().


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