kwave  18.07.70
CodecPlugin.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  CodecPlugin.cpp - base class for codec plugins
3  -------------------
4  begin : Fri Dec 28 2012
5  copyright : (C) 2012 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include "libkwave/CodecManager.h"
21 #include "libkwave/CodecPlugin.h"
22 #include "libkwave/Decoder.h"
23 #include "libkwave/Encoder.h"
24 
25 /***************************************************************************/
27  const QVariantList &args,
28  Codec &codec)
29  :Kwave::Plugin(parent, args), m_codec(codec)
30 {
31 }
32 
33 /***************************************************************************/
35 {
36 }
37 
38 /***************************************************************************/
39 void Kwave::CodecPlugin::load(QStringList &/* params */)
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 }
57 
58 /***************************************************************************/
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 }
80 
81 /***************************************************************************/
82 /***************************************************************************/
QList< Kwave::Encoder * > m_encoder
Definition: CodecPlugin.h:40
Definition: App.h:33
virtual void load(QStringList &) Q_DECL_OVERRIDE
Definition: CodecPlugin.cpp:39
virtual void unload() Q_DECL_OVERRIDE
Definition: CodecPlugin.cpp:59
virtual QList< Kwave::Encoder * > createEncoder()=0
void release()
Definition: Plugin.cpp:420
virtual ~CodecPlugin() Q_DECL_OVERRIDE
Definition: CodecPlugin.cpp:34
QList< Kwave::Decoder * > m_decoder
Definition: CodecPlugin.h:41
static void registerDecoder(Kwave::Decoder &decoder)
CodecPlugin(QObject *parent, const QVariantList &args, Codec &codec)
Definition: CodecPlugin.cpp:26
static void unregisterEncoder(Kwave::Encoder *encoder)
virtual QList< Kwave::Decoder * > createDecoder()=0
void use()
Definition: Plugin.cpp:412
static void unregisterDecoder(Kwave::Decoder *decoder)
static void registerEncoder(Kwave::Encoder &encoder)