aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-07-10 17:33:17 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-07-10 17:33:17 +0000
commitd875270150b521ff84f9371248b0afaa88abe0e8 (patch)
tree5e2f76186763b5915c49d453139a020e45ce3c76 /src
parent193585f35414ef95a09f6dbd0e3e040c090950ca (diff)
downloadqmmp-d875270150b521ff84f9371248b0afaa88abe0e8.tar.gz
qmmp-d875270150b521ff84f9371248b0afaa88abe0e8.tar.bz2
qmmp-d875270150b521ff84f9371248b0afaa88abe0e8.zip
new decoder api, disabled broken plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1016 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Input/CMakeLists.txt20
-rw-r--r--src/plugins/Input/Input.pro18
-rw-r--r--src/plugins/Input/mad/decoder_mad.cpp432
-rw-r--r--src/plugins/Input/mad/decoder_mad.h34
-rw-r--r--src/plugins/Input/vorbis/decoder_vorbis.cpp207
-rw-r--r--src/plugins/Input/vorbis/decoder_vorbis.h35
-rw-r--r--src/plugins/Output/alsa/outputalsa.cpp1
-rw-r--r--src/plugins/Output/jack/outputjack.cpp1
-rw-r--r--src/plugins/Output/oss/outputoss.cpp1
-rw-r--r--src/plugins/Output/pulseaudio/outputpulseaudio.cpp1
-rw-r--r--src/plugins/Visual/analyzer/analyzer.cpp1
-rw-r--r--src/plugins/Visual/analyzer/analyzer.h1
-rw-r--r--src/plugins/Visual/projectm/projectmplugin.cpp1
-rw-r--r--src/plugins/Visual/projectm/projectmplugin.h1
-rw-r--r--src/qmmp/CMakeLists.txt1
-rw-r--r--src/qmmp/buffer.h8
-rw-r--r--src/qmmp/constants.h7
-rw-r--r--src/qmmp/decoder.cpp204
-rw-r--r--src/qmmp/decoder.h39
-rw-r--r--src/qmmp/downloader.cpp1
-rw-r--r--src/qmmp/effect.cpp1
-rw-r--r--src/qmmp/output.cpp1
-rw-r--r--src/qmmp/qmmp.cpp7
-rw-r--r--src/qmmp/qmmp.h4
-rw-r--r--src/qmmp/qmmp.pro142
-rw-r--r--src/qmmp/recycler.cpp2
-rw-r--r--src/qmmp/soundcore.cpp1
-rw-r--r--src/qmmp/statehandler.cpp1
-rw-r--r--src/qmmp/visual.cpp1
-rw-r--r--src/ui/mainvisual.cpp1
-rw-r--r--src/ui/mainvisual.h1
31 files changed, 479 insertions, 697 deletions
diff --git a/src/plugins/Input/CMakeLists.txt b/src/plugins/Input/CMakeLists.txt
index a62066aea..98c733694 100644
--- a/src/plugins/Input/CMakeLists.txt
+++ b/src/plugins/Input/CMakeLists.txt
@@ -21,7 +21,7 @@ add_subdirectory(mad)
ENDIF(USE_MAD AND TAGLIB_FOUND)
IF(USE_FLAC AND TAGLIB_FOUND)
-add_subdirectory(flac)
+#add_subdirectory(flac)
ENDIF(USE_FLAC AND TAGLIB_FOUND)
IF(USE_VORBIS AND TAGLIB_FOUND)
@@ -29,37 +29,37 @@ add_subdirectory(vorbis)
ENDIF(USE_VORBIS AND TAGLIB_FOUND)
IF(USE_FFMPEG)
-add_subdirectory(ffmpeg)
+#add_subdirectory(ffmpeg)
ENDIF(USE_FFMPEG)
IF(USE_MPC AND TAGLIB_FOUND)
-add_subdirectory(mpc)
+#add_subdirectory(mpc)
ENDIF(USE_MPC AND TAGLIB_FOUND)
IF(USE_SNDFILE)
-add_subdirectory(sndfile)
+#add_subdirectory(sndfile)
ENDIF(USE_SNDFILE)
IF(USE_WAVPACK)
-add_subdirectory(wavpack)
+#add_subdirectory(wavpack)
ENDIF(USE_WAVPACK)
IF(USE_MODPLUG)
-add_subdirectory(modplug)
+#add_subdirectory(modplug)
ENDIF(USE_MODPLUG)
IF(USE_AAC)
-add_subdirectory(aac)
+#add_subdirectory(aac)
ENDIF(USE_AAC)
IF(USE_CUE)
-add_subdirectory(cue)
+#add_subdirectory(cue)
ENDIF(USE_CUE)
IF(USE_MPLAYER)
-add_subdirectory(mplayer)
+#add_subdirectory(mplayer)
ENDIF(USE_MPLAYER)
IF(USE_CDA)
-add_subdirectory(cdaudio)
+#add_subdirectory(cdaudio)
ENDIF(USE_CDA)
diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro
index 520d9060b..7b07b7571 100644
--- a/src/plugins/Input/Input.pro
+++ b/src/plugins/Input/Input.pro
@@ -1,54 +1,54 @@
include(../../../qmmp.pri)
-SUBDIRS += mad cue
+SUBDIRS += mad #cue
TEMPLATE = subdirs
unix{
-SUBDIRS += vorbis sndfile wavpack
+SUBDIRS += vorbis #sndfile wavpack
contains(CONFIG, MODPLUG_PLUGIN){
- SUBDIRS += modplug
+ #SUBDIRS += modplug
message(***************************)
message(* Modplug plugin enabled *)
message(***************************)
}
contains(CONFIG, MUSEPACK_PLUGIN){
- SUBDIRS += mpc
+ #SUBDIRS += mpc
message(***************************)
message(* Musepack plugin enabled *)
message(***************************)
}
contains(CONFIG, FLAC_PLUGIN){
- SUBDIRS += flac
+ #SUBDIRS += flac
message(***********************)
message(* FLAC plugin enabled *)
message(***********************)
}
contains(CONFIG, FFMPEG_PLUGIN){
- SUBDIRS += ffmpeg
+ #SUBDIRS += ffmpeg
message(*************************)
message(* FFMPEG plugin enabled *)
message(*************************)
}
contains(CONFIG, AAC_PLUGIN){
- SUBDIRS += aac
+ #SUBDIRS += aac
message(**********************)
message(* AAC plugin enabled *)
message(**********************)
}
contains(CONFIG, MPLAYER_PLUGIN){
- SUBDIRS += mplayer
+ #SUBDIRS += mplayer
message(**************************)
message(* Mplayer plugin enabled *)
message(**************************)
}
contains(CONFIG, CDAUDIO_PLUGIN){
- SUBDIRS += cdaudio
+ #SUBDIRS += cdaudio
message(***************************)
message(* CD Audio plugin enabled *)
message(***************************)
diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp
index 645c2369d..d2a5f7d3c 100644
--- a/src/plugins/Input/mad/decoder_mad.cpp
+++ b/src/plugins/Input/mad/decoder_mad.cpp
@@ -11,7 +11,6 @@
#include "decoder_mad.h"
#include "tagextractor.h"
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/output.h>
@@ -25,85 +24,55 @@
DecoderMAD::DecoderMAD(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
: Decoder(parent, d, i, o)
{
- inited = false;
- user_stop = false;
- done = false;
- m_finish = false;
- derror = false;
- eof = false;
- useeq = false;
+ m_inited = false;
m_totalTime = 0.;
- seekTime = -1.;
- channels = 0;
- bks = 0;
- bitrate = 0;
- freq = 0;
- len = 0;
- input_buf = 0;
- input_bytes = 0;
- output_buf = 0;
- output_bytes = 0;
- output_at = 0;
- output_size = 0;
+ m_channels = 0;
+ m_bitrate = 0;
+ m_freq = 0;
+ m_len = 0;
+ m_input_buf = 0;
+ m_input_bytes = 0;
+ m_output_bytes = 0;
+ m_output_at = 0;
+ m_skip_frames = 0;
}
DecoderMAD::~DecoderMAD()
{
wait();
deinit();
- mutex()->lock();
- if (input_buf)
+ if (m_input_buf)
{
qDebug("DecoderMAD: deleting input_buf");
- delete [] input_buf;
- }
- input_buf = 0;
-
- if (output_buf)
- {
- qDebug("DecoderMAD: deleting output_buf");
- delete [] output_buf;
- }
- output_buf = 0;
- mutex()->unlock();
+ delete [] m_input_buf;
+ m_input_buf = 0;
+ }
}
bool DecoderMAD::initialize()
{
- bks = Buffer::size();
-
- inited = false;
- user_stop = false;
- done = false;
- m_finish = false;
- derror = false;
- eof = false;
+ m_inited = false;
m_totalTime = 0.;
- seekTime = -1.;
- channels = 0;
- bitrate = 0;
- freq = 0;
- len = 0;
- input_bytes = 0;
- output_bytes = 0;
- output_at = 0;
- output_size = 0;
-
- if (! input())
+ m_channels = 0;
+ m_bitrate = 0;
+ m_freq = 0;
+ m_len = 0;
+ m_input_bytes = 0;
+ m_output_bytes = 0;
+ m_output_at = 0;
+
+ if (!input())
{
qWarning("DecoderMAD: cannot initialize. No input.");
return FALSE;
}
- if (! input_buf)
- input_buf = new char[INPUT_BUFFER_SIZE];
+ if (!m_input_buf)
+ m_input_buf = new char[INPUT_BUFFER_SIZE];
- if (! output_buf)
- output_buf = new char[globalBufferSize];
-
- if (! input()->isOpen())
+ if (!input()->isOpen())
{
- if (! input()->open(QIODevice::ReadOnly))
+ if (!input()->open(QIODevice::ReadOnly))
{
qWarning("DecoderMAD: %s", qPrintable(input()->errorString ()));
return FALSE;
@@ -121,51 +90,43 @@ bool DecoderMAD::initialize()
mad_frame_init(&frame);
mad_synth_init(&synth);
- if (! findHeader())
+ if (!findHeader())
{
qDebug("DecoderMAD: Can't find a valid MPEG header.");
return FALSE;
}
- mad_stream_buffer(&stream, (unsigned char *) input_buf, input_bytes);
+ mad_stream_buffer(&stream, (unsigned char *) m_input_buf, m_input_bytes);
stream.error = MAD_ERROR_NONE;
stream.error = MAD_ERROR_BUFLEN;
mad_frame_mute (&frame);
stream.next_frame = NULL;
stream.sync = 0;
- configure(freq, channels, 16);
+ configure(m_freq, m_channels, 16);
- inited = TRUE;
+ m_inited = TRUE;
return TRUE;
}
void DecoderMAD::deinit()
{
- if (!inited)
+ if (!m_inited)
return;
mad_synth_finish(&synth);
mad_frame_finish(&frame);
mad_stream_finish(&stream);
- inited = false;
- user_stop = false;
- done = false;
- m_finish = false;
- derror = false;
- eof = false;
- useeq = false;
+ m_inited = FALSE;
m_totalTime = 0.;
- seekTime = -1.;
- channels = 0;
- bks = 0;
- bitrate = 0;
- freq = 0;
- len = 0;
- input_bytes = 0;
- output_bytes = 0;
- output_at = 0;
- output_size = 0;
+ m_channels = 0;
+ m_bitrate = 0;
+ m_freq = 0;
+ m_len = 0;
+ m_input_bytes = 0;
+ m_output_bytes = 0;
+ m_output_at = 0;
+ m_skip_frames = 0;
}
bool DecoderMAD::findXingHeader(struct mad_bitptr ptr, unsigned int bitlen)
@@ -236,9 +197,9 @@ bool DecoderMAD::findHeader()
struct mad_header header;
mad_header_init (&header);
- while (TRUE)
+ forever
{
- input_bytes = 0;
+ m_input_bytes = 0;
if (stream.error == MAD_ERROR_BUFLEN || !stream.buffer)
{
size_t remaining = 0;
@@ -246,15 +207,15 @@ bool DecoderMAD::findHeader()
if (!stream.next_frame)
{
remaining = stream.bufend - stream.next_frame;
- memmove (input_buf, stream.next_frame, remaining);
+ memmove (m_input_buf, stream.next_frame, remaining);
}
- input_bytes = input()->read(input_buf + remaining, INPUT_BUFFER_SIZE - remaining);
+ m_input_bytes = input()->read(m_input_buf + remaining, INPUT_BUFFER_SIZE - remaining);
- if (input_bytes <= 0)
+ if (m_input_bytes <= 0)
break;
- mad_stream_buffer(&stream, (unsigned char *) input_buf + remaining, input_bytes);
+ mad_stream_buffer(&stream, (unsigned char *) m_input_buf + remaining, m_input_bytes);
stream.error = MAD_ERROR_NONE;
}
@@ -298,13 +259,13 @@ bool DecoderMAD::findHeader()
//try to detect VBR
if (!is_vbr && !(count > 15))
{
- if (bitrate && header.bitrate != bitrate)
+ if (m_bitrate && header.bitrate != m_bitrate)
{
qDebug ("DecoderMAD: VBR detected");
is_vbr = TRUE;
}
else
- bitrate = header.bitrate;
+ m_bitrate = header.bitrate;
}
else if (!is_vbr)
{
@@ -331,144 +292,41 @@ bool DecoderMAD::findHeader()
m_totalTime = mad_timer_count(duration, MAD_UNITS_MILLISECONDS);
qDebug ("DecoderMAD: Total time: %ld", long(m_totalTime));
- freq = header.samplerate;
- channels = MAD_NCHANNELS(&header);
- bitrate = header.bitrate / 1000;
+ m_freq = header.samplerate;
+ m_channels = MAD_NCHANNELS(&header);
+ m_bitrate = header.bitrate / 1000;
mad_header_finish(&header);
input()->seek(0);
- input_bytes = 0;
+ m_input_bytes = 0;
return TRUE;
}
qint64 DecoderMAD::totalTime()
{
- if (! inited)
- return 0.;
+ if (!m_inited)
+ return 0;
return m_totalTime;
}
-void DecoderMAD::seek(qint64 pos)
-{
- seekTime = pos;
-}
-
-void DecoderMAD::stop()
+int DecoderMAD::bitrate()
{
- user_stop = TRUE;
-}
-
-void DecoderMAD::flush(bool final)
-{
- ulong min = final ? 0 : bks;
- while (!done && (output_bytes > min) && seekTime == -1.)
- {
- output()->recycler()->mutex()->lock();
-
- while (!done && output()->recycler()->full())
- {
- mutex()->unlock();
- output()->recycler()->cond()->wait(output()->recycler()->mutex());
-
- mutex()->lock();
- done = user_stop;
- }
-
- if (user_stop)
- {
- inited = FALSE;
- done = TRUE;
- }
- else
- {
- output_bytes -= produceSound(output_buf, output_bytes, bitrate, channels);
- output_size += bks;
- output_at = output_bytes;
- }
-
- if (output()->recycler()->full())
- {
- output()->recycler()->cond()->wakeOne();
- }
-
- output()->recycler()->mutex()->unlock();
- }
+ return int(m_bitrate);
}
-void DecoderMAD::run()
+qint64 DecoderMAD::readAudio(char *data, qint64 size)
{
- int skip_frames = 0;
- mutex()->lock();
-
- if (! inited)
+ forever
{
- mutex()->unlock();
- return;
- }
-
- mutex()->unlock();
-
- while (! done && ! m_finish && ! derror)
- {
- mutex()->lock();
-
- if (seekTime >= 0.0 && m_totalTime > 0)
+ if(stream.error == MAD_ERROR_BUFLEN || !stream.buffer)
{
- long seek_pos = long(seekTime * input()->size() / m_totalTime);
- input()->seek(seek_pos);
- output_size = long(seekTime) * long(freq * channels * 16 / 2);
- mad_frame_mute(&frame);
- mad_synth_mute(&synth);
- stream.error = MAD_ERROR_BUFLEN;
- stream.sync = 0;
- input_bytes = 0;
- output_at = 0;
- output_bytes = 0;
- stream.next_frame = 0;
- skip_frames = 2;
- eof = false;
- seekTime = -1;
+ if(!fillBuffer())
+ return 0;
}
- m_finish = eof;
-
- if (! eof)
+ if(mad_frame_decode(&frame, &stream) < 0)
{
- if (stream.next_frame)
+ switch((int) stream.error)
{
- input_bytes = &input_buf[input_bytes] - (char *) stream.next_frame;
- memmove(input_buf, stream.next_frame, input_bytes);
- }
-
- if (stream.error == MAD_ERROR_BUFLEN)
- {
- int len = input()->read((char *) input_buf + input_bytes,
- INPUT_BUFFER_SIZE - input_bytes);
-
- if (len == 0)
- {
- qDebug("DecoderMAD: end of file");
- eof = true;
- }
- else if (len < 0)
- {
- qWarning("DecoderMAD: %s", qPrintable(input()->errorString ()));
- derror = true;
- break;
- }
-
- input_bytes += len;
- }
-
- mad_stream_buffer(&stream, (unsigned char *) input_buf, input_bytes);
- }
-
- mutex()->unlock();
-
- // decode
- while (!done && !m_finish && !derror && seekTime == -1.)
- {
- if (mad_frame_decode(&frame, &stream) == -1)
- {
- if (stream.error == MAD_ERROR_LOSTSYNC)
+ case MAD_ERROR_LOSTSYNC:
{
//skip ID3v2 tag
uint tagSize = findID3v2((uchar *)stream.this_frame,
@@ -480,76 +338,61 @@ void DecoderMAD::run()
}
continue;
}
-
- if (stream.error == MAD_ERROR_BUFLEN)
- break;
-
- if (stream.error == MAD_ERROR_BUFLEN)
+ case MAD_ERROR_BUFLEN:
continue;
-
- // error in decoding
- if (!MAD_RECOVERABLE(stream.error))
- {
- derror = true;
- break;
- }
- continue;
+ default:
+ if (!MAD_RECOVERABLE(stream.error))
+ return 0;
+ else
+ continue;
}
-
- mutex()->lock();
-
- if (seekTime >= 0.)
- {
- mutex()->unlock();
- break;
- }
-
- if (skip_frames)
- {
- skip_frames-- ;
- mutex()->unlock();
- continue;
- }
- mad_synth_frame(&synth, &frame);
- madOutput();
- mutex()->unlock();
}
- }
-
- mutex()->lock();
-
- if (!user_stop && eof)
- {
- flush(TRUE);
-
- if (output())
+ if(m_skip_frames)
{
- output()->recycler()->mutex()->lock();
- // end of stream
- while (! output()->recycler()->empty() && ! user_stop)
- {
- output()->recycler()->cond()->wakeOne();
- mutex()->unlock();
- output()->recycler()->cond()->wait(output()->recycler()->mutex());
- mutex()->lock();
- }
- output()->recycler()->mutex()->unlock();
+ m_skip_frames--;
+ continue;
}
-
- done = TRUE;
- if (!user_stop)
- m_finish = TRUE;
+ mad_synth_frame(&synth, &frame);
+ return madOutput(data, size);
}
+}
+void DecoderMAD::seekAudio(qint64 pos)
+{
+ if(m_totalTime > 0)
+ {
+ qint64 seek_pos = qint64(pos * input()->size() / m_totalTime);
+ input()->seek(seek_pos);
+ mad_frame_mute(&frame);
+ mad_synth_mute(&synth);
+ stream.error = MAD_ERROR_BUFLEN;
+ stream.sync = 0;
+ m_input_bytes = 0;
+ stream.next_frame = 0;
+ m_skip_frames = 2;
+ }
+}
- if (m_finish)
- finish();
-
- mutex()->unlock();
-
- if (input())
- input()->close();
- deinit();
-
+bool DecoderMAD::fillBuffer()
+{
+ if (stream.next_frame)
+ {
+ m_input_bytes = &m_input_buf[m_input_bytes] - (char *) stream.next_frame;
+ memmove(m_input_buf, stream.next_frame, m_input_bytes);
+ }
+ int len = input()->read((char *) m_input_buf + m_input_bytes, INPUT_BUFFER_SIZE - m_input_bytes);
+ if (!len)
+ {
+ qDebug("DecoderMAD: end of file");
+ return FALSE;
+ }
+ else if(len < 0)
+ {
+ qWarning("error");
+ return FALSE;
+ }
+ m_input_bytes += len;
+ mad_stream_buffer(&stream, (unsigned char *) m_input_buf, m_input_bytes);
+ return TRUE;
}
uint DecoderMAD::findID3v2(uchar *data, ulong size) //retuns ID3v2 tag size
@@ -603,7 +446,7 @@ static inline signed long fix_sample(unsigned int bits, mad_fixed_t sample)
return quantized >> (MAD_F_FRACBITS + 1 - bits);
}
-enum mad_flow DecoderMAD::madOutput()
+qint64 DecoderMAD::madOutput(char *data, qint64 size)
{
unsigned int samples, channels;
mad_fixed_t const *left, *right;
@@ -612,45 +455,32 @@ enum mad_flow DecoderMAD::madOutput()
channels = synth.pcm.channels;
left = synth.pcm.samples[0];
right = synth.pcm.samples[1];
+ m_bitrate = frame.header.bitrate / 1000;
+ m_output_at = 0;
+ m_output_bytes = 0;
+ if(samples * channels * 2 > size)
+ {
+ qWarning("DecoderMad: input buffer is too small");
+ samples = size / channels / 2;
+ }
- bitrate = frame.header.bitrate / 1000;
- done = user_stop;
-
- while (samples-- && !user_stop)
+ while (samples--)
{
signed int sample;
- if (output_bytes + 4096 > globalBufferSize)
- flush();
-
sample = fix_sample(16, *left++);
- *(output_buf + output_at++) = ((sample >> 0) & 0xff);
- *(output_buf + output_at++) = ((sample >> 8) & 0xff);
- output_bytes += 2;
+ *(data + m_output_at++) = ((sample >> 0) & 0xff);
+ *(data + m_output_at++) = ((sample >> 8) & 0xff);
+ m_output_bytes += 2;
if (channels == 2)
{
sample = fix_sample(16, *right++);
- *(output_buf + output_at++) = ((sample >> 0) & 0xff);
- *(output_buf + output_at++) = ((sample >> 8) & 0xff);
- output_bytes += 2;
+ *(data + m_output_at++) = ((sample >> 0) & 0xff);
+ *(data + m_output_at++) = ((sample >> 8) & 0xff);
+ m_output_bytes += 2;
}
}
-
- if (done || m_finish)
- {
- return MAD_FLOW_STOP;
- }
-
- return MAD_FLOW_CONTINUE;
-}
-
-enum mad_flow DecoderMAD::madError(struct mad_stream *stream,
- struct mad_frame *)
-{
- if (MAD_RECOVERABLE(stream->error))
- return MAD_FLOW_CONTINUE;
- qFatal("MADERROR!\n");
- return MAD_FLOW_STOP;
+ return m_output_bytes;
}
diff --git a/src/plugins/Input/mad/decoder_mad.h b/src/plugins/Input/mad/decoder_mad.h
index 6fb6f2a40..f25ad2b80 100644
--- a/src/plugins/Input/mad/decoder_mad.h
+++ b/src/plugins/Input/mad/decoder_mad.h
@@ -28,37 +28,29 @@ public:
// standard decoder API
bool initialize();
qint64 totalTime();
- void seek(qint64);
- void stop();
+ int bitrate();
private:
- // thread run function
- void run();
-
- enum mad_flow madOutput();
- enum mad_flow madError(struct mad_stream *, struct mad_frame *);
+ qint64 readAudio(char *data, qint64 size);
+ void seekAudio(qint64);
// helper functions
- void flush(bool = FALSE);
+ qint64 madOutput(char *data, qint64 size);
+ bool fillBuffer();
void deinit();
bool findHeader();
bool findXingHeader(struct mad_bitptr, unsigned int);
uint findID3v2(uchar *data, ulong size);
- bool inited, user_stop, done, m_finish, derror, eof, useeq;
- qint64 m_totalTime, seekTime;
- int channels;
- unsigned long bitrate;
- long freq, len;
- unsigned int bks;
- mad_fixed_t eqbands[32];
+ bool m_inited;
+ qint64 m_totalTime;
+ int m_channels, m_skip_frames;
+ uint m_bitrate;
+ long m_freq, m_len;
+ qint64 m_output_bytes, m_output_at;
// file input buffer
- char *input_buf;
- unsigned long input_bytes;
-
- // output buffer
- char *output_buf;
- unsigned long output_bytes, output_at, output_size;
+ char *m_input_buf;
+ qint64 m_input_bytes;
// MAD decoder
struct
diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp
index 492d256df..fdbfd1432 100644
--- a/src/plugins/Input/vorbis/decoder_vorbis.cpp
+++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp
@@ -5,7 +5,6 @@
//
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/output.h>
#include <qmmp/recycler.h>
@@ -78,103 +77,32 @@ DecoderVorbis::DecoderVorbis(QObject *parent, DecoderFactory *d, QIODevice *i, O
: Decoder(parent, d, i, o)
{
inited = FALSE;
- user_stop = FALSE;
- stat = 0;
- output_buf = 0;
- output_bytes = 0;
- output_at = 0;
- bks = 0;
- done = FALSE;
- m_finish = FALSE;
- len = 0;
- freq = 0;
- bitrate = 0;
- seekTime = -1.0;
- m_totalTime = 0.0;
- chan = 0;
- output_size = 0;
+ m_totalTime = 0;
+ m_section = 0;
+ m_last_section = -1;
+ m_bitrate = 0;
}
DecoderVorbis::~DecoderVorbis()
{
deinit();
-
- if (output_buf)
- delete [] output_buf;
- output_buf = 0;
-}
-
-
-void DecoderVorbis::stop()
-{
- user_stop = TRUE;
-}
-
-
-void DecoderVorbis::flush(bool final)
-{
- ulong min = final ? 0 : bks;
-
- while ((!done && !m_finish) && output_bytes > min)
- {
- output()->recycler()->mutex()->lock ();
- while ((! done && ! m_finish) && output()->recycler()->full())
- {
- mutex()->unlock();
- output()->recycler()->cond()->wait(output()->recycler()->mutex());
- mutex()->lock ();
- done = user_stop;
- }
-
- if (user_stop || m_finish)
- {
- inited = FALSE;
- done = TRUE;
- }
- else
- {
- output_bytes -= produceSound(output_buf, output_bytes, bitrate, chan);
- output_size += bks;
- output_at = output_bytes;
- }
-
- if (output()->recycler()->full())
- {
- output()->recycler()->cond()->wakeOne();
- }
-
- output()->recycler()->mutex()->unlock();
- }
}
-
bool DecoderVorbis::initialize()
{
qDebug("DecoderVorbis: initialize");
- bks = Buffer::size();
-
- inited = user_stop = done = m_finish = FALSE;
- len = freq = bitrate = 0;
- stat = chan = 0;
- output_size = 0;
- seekTime = -1.0;
- m_totalTime = 0.0;
- if (! input())
+ inited = FALSE;
+ m_totalTime = 0;
+ if (!input())
{
qDebug("DecoderVorbis: cannot initialize. No input");
-
return FALSE;
}
- if (! output_buf)
- output_buf = new char[globalBufferSize];
- output_at = 0;
- output_bytes = 0;
-
- if (! input()->isOpen())
+ if (!input()->isOpen())
{
- if (! input()->open(QIODevice::ReadOnly))
+ if (!input()->open(QIODevice::ReadOnly))
{
qWarning("%s",qPrintable("DecoderVorbis: failed to open input. " +
input()->errorString () + "."));
@@ -196,9 +124,9 @@ bool DecoderVorbis::initialize()
return FALSE;
}
- freq = 0;
- bitrate = ov_bitrate(&oggfile, -1) / 1000;
- chan = 0;
+ quint32 freq = 0;
+ m_bitrate = ov_bitrate(&oggfile, -1) / 1000;
+ int chan = 0;
m_totalTime = ov_time_total(&oggfile, -1) * 1000;
m_totalTime = qMax(qint64(0), m_totalTime);
@@ -219,16 +147,14 @@ bool DecoderVorbis::initialize()
qint64 DecoderVorbis::totalTime()
{
- if (! inited)
+ if (!inited)
return 0;
-
return m_totalTime;
}
-
-void DecoderVorbis::seek(qint64 pos)
+int DecoderVorbis::bitrate()
{
- seekTime = pos;
+ return m_bitrate;
}
@@ -236,10 +162,7 @@ void DecoderVorbis::deinit()
{
if (inited)
ov_clear(&oggfile);
- inited = user_stop = done = m_finish = FALSE;
- len = freq = bitrate = 0;
- stat = chan = 0;
- output_size = 0;
+ len = 0;
}
void DecoderVorbis::updateTags()
@@ -292,92 +215,22 @@ void DecoderVorbis::updateTags()
stateHandler()->dispatch(metaData);
}
-void DecoderVorbis::run()
+void DecoderVorbis::seekAudio(qint64 time)
{
- mutex()->lock ();
+ ov_time_seek(&oggfile, (double) time/1000);
+}
- if (!inited)
+qint64 DecoderVorbis::readAudio(char *data, qint64 maxSize)
+{
+ len = -1;
+ while (len < 0)
{
- mutex()->unlock();
- return;
+ len = ov_read(&oggfile, data, maxSize, 0, 2, 1, &m_section);
}
-
- mutex()->unlock();
-
- int section = 0;
- int last_section = -1;
-
- while (! done && ! m_finish)
- {
- mutex()->lock ();
- // decode
-
- if (seekTime >= 0.0)
- {
- ov_time_seek(&oggfile, (double) seekTime/1000);
- seekTime = -1.0;
-
- output_size = ov_time_tell(&oggfile) * freq * chan * 2;
- }
- len = -1;
- while (len < 0)
- {
- len = ov_read(&oggfile, (char *) (output_buf + output_at), bks, 0, 2, 1,
- &section);
- }
- if (section != last_section)
- updateTags();
- last_section = section;
-
- if (len > 0)
- {
- bitrate = ov_bitrate_instant(&oggfile) / 1000;
-
- output_at += len;
- output_bytes += len;
- if (output())
- flush();
- }
- else if (len == 0)
- {
- flush(TRUE);
-
- if (output())
- {
- output()->recycler()->mutex()->lock ();
- // end of stream
- while (! output()->recycler()->empty() && ! user_stop)
- {
- output()->recycler()->cond()->wakeOne();
- mutex()->unlock();
- output()->recycler()->cond()->wait(output()->recycler()->mutex());
- mutex()->lock ();
- }
- output()->recycler()->mutex()->unlock();
- }
-
- done = TRUE;
- if (! user_stop)
- {
- m_finish = TRUE;
- }
- }
- else
- {
- // error in read
- //error("DecoderVorbis: Error while decoding stream, File appears to be "
- // "corrupted");
-
- m_finish = TRUE;
- }
- mutex()->unlock();
- }
-
- mutex()->lock ();
-
- if (m_finish)
- finish();
-
- mutex()->unlock();
- deinit();
+ if (m_section != m_last_section)
+ updateTags();
+ m_last_section = m_section;
+ if(len > 0)
+ m_bitrate = ov_bitrate_instant(&oggfile) / 1000;
+ return len;
}
diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h
index ec1158f31..b20b26ab7 100644
--- a/src/plugins/Input/vorbis/decoder_vorbis.h
+++ b/src/plugins/Input/vorbis/decoder_vorbis.h
@@ -21,42 +21,23 @@ public:
// Standard Decoder API
bool initialize();
qint64 totalTime();
- void seek(qint64);
- void stop();
-
- // Equalizer
- bool isEQSupported() const { return FALSE; }
- void setEQEnabled(bool) { ; }
- void setEQGain(int) { ; }
- void setEQBands(int[10]) { ; }
-
+ int bitrate();
private:
- // thread run function
- void run();
+ virtual qint64 readAudio(char *data, qint64 maxSize);
+ void seekAudio(qint64 time);
// helper functions
- void flush(bool = FALSE);
void deinit();
-
void updateTags();
- bool inited, user_stop;
- int stat;
-
- // output buffer
- char *output_buf;
- ulong output_bytes, output_at;
-
// OggVorbis Decoder
OggVorbis_File oggfile;
-
- unsigned int bks;
- bool done, m_finish;
- long len, freq, bitrate;
- int chan;
- qint64 output_size;
- qint64 m_totalTime, seekTime;
+ qint64 m_totalTime;
+ long len;
+ int m_section, m_last_section;
+ int m_bitrate;
+ bool inited;
};
diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp
index 53874a1e7..d668bde52 100644
--- a/src/plugins/Output/alsa/outputalsa.cpp
+++ b/src/plugins/Output/alsa/outputalsa.cpp
@@ -31,7 +31,6 @@
#include <string.h>
#include <iostream>
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/visual.h>
#include <qmmp/statehandler.h>
diff --git a/src/plugins/Output/jack/outputjack.cpp b/src/plugins/Output/jack/outputjack.cpp
index 2819941d4..8ff7d016b 100644
--- a/src/plugins/Output/jack/outputjack.cpp
+++ b/src/plugins/Output/jack/outputjack.cpp
@@ -25,7 +25,6 @@
#include <QSettings>
#include "outputjack.h"
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/visual.h>
diff --git a/src/plugins/Output/oss/outputoss.cpp b/src/plugins/Output/oss/outputoss.cpp
index ecb39cb72..9402d99bd 100644
--- a/src/plugins/Output/oss/outputoss.cpp
+++ b/src/plugins/Output/oss/outputoss.cpp
@@ -31,7 +31,6 @@ extern "C"
}
#include "outputoss.h"
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/visual.h>
diff --git a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp
index 7a2949922..e122e0c64 100644
--- a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp
+++ b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp
@@ -31,7 +31,6 @@ extern "C"
#include <string.h>
#include <iostream>
-#include <qmmp/constants.h>
#include <qmmp/buffer.h>
#include <qmmp/visual.h>
#include "outputpulseaudio.h"
diff --git a/src/plugins/Visual/analyzer/analyzer.cpp b/src/plugins/Visual/analyzer/analyzer.cpp
index 28746d1d9..d0f5cbba0 100644
--- a/src/plugins/Visual/analyzer/analyzer.cpp
+++ b/src/plugins/Visual/analyzer/analyzer.cpp
@@ -24,7 +24,6 @@
#include <QActionGroup>
#include <qmmp/buffer.h>
-#include <qmmp/constants.h>
#include <qmmp/output.h>
#include <math.h>
#include <stdlib.h>
diff --git a/src/plugins/Visual/analyzer/analyzer.h b/src/plugins/Visual/analyzer/analyzer.h
index 6cc301b8d..9b0352dae 100644
--- a/src/plugins/Visual/analyzer/analyzer.h
+++ b/src/plugins/Visual/analyzer/analyzer.h
@@ -23,7 +23,6 @@
#include <QWidget>
#include <QResizeEvent>
#include <qmmp/visual.h>
-#include <qmmp/constants.h>
#include <QDir>
class QSettings;
diff --git a/src/plugins/Visual/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp
index 67dddd86e..b29dfab1e 100644
--- a/src/plugins/Visual/projectm/projectmplugin.cpp
+++ b/src/plugins/Visual/projectm/projectmplugin.cpp
@@ -29,7 +29,6 @@
#include <libprojectM/projectM.hpp>
#include <qmmp/buffer.h>
-#include <qmmp/constants.h>
#include <qmmp/output.h>
#include "projectmwidget.h"
#include "projectmplugin.h"
diff --git a/src/plugins/Visual/projectm/projectmplugin.h b/src/plugins/Visual/projectm/projectmplugin.h
index a3a5a7bfb..db16ab110 100644
--- a/src/plugins/Visual/projectm/projectmplugin.h
+++ b/src/plugins/Visual/projectm/projectmplugin.h
@@ -22,7 +22,6 @@
#include <QWidget>
#include <qmmp/visual.h>
-#include <qmmp/constants.h>
class QTimer;
class Buffer;
diff --git a/src/qmmp/CMakeLists.txt b/src/qmmp/CMakeLists.txt
index 6df4a1926..304044117 100644
--- a/src/qmmp/CMakeLists.txt
+++ b/src/qmmp/CMakeLists.txt
@@ -58,7 +58,6 @@ SET(libqmmp_MOC_HDRS
visual.h
recycler.h
buffer.h
- constants.h
decoder.h
output.h
fileinfo.h
diff --git a/src/qmmp/buffer.h b/src/qmmp/buffer.h
index 13fd42e0e..e0ab18a16 100644
--- a/src/qmmp/buffer.h
+++ b/src/qmmp/buffer.h
@@ -7,7 +7,7 @@
#ifndef __buffer_h
#define __buffer_h
-#include "constants.h"
+#define QMMP_BLOCK_SIZE 2048
/*! @brief Audio buffer class.
* @author Brad Hughes <bhughes@trolltech.com>
@@ -20,7 +20,7 @@ public:
*/
Buffer()
{
- data = new unsigned char[Buffer::size()];
+ data = new unsigned char[QMMP_BLOCK_SIZE];
nbytes = 0;
rate = 0;
exceeding = 0;
@@ -44,9 +44,9 @@ public:
/*!
* Returns block size.
*/
- static unsigned long size()
+ static unsigned int size()
{
- return globalBlockSize;
+ return QMMP_BLOCK_SIZE;
}
};
diff --git a/src/qmmp/constants.h b/src/qmmp/constants.h
deleted file mode 100644
index e9d346343..000000000
--- a/src/qmmp/constants.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CONSTANTS_H
-#define CONSTANTS_H
-
-const unsigned int globalBlockSize = 2 * 1024; //2*1024
-const unsigned int globalBufferSize = globalBlockSize * 128;
-
-#endif // CONSTANTS_H
diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp
index d555348cb..1c4bdf087 100644
--- a/src/qmmp/decoder.cpp
+++ b/src/qmmp/decoder.cpp
@@ -13,7 +13,6 @@
#include "effect.h"
#include "effectfactory.h"
-#include "constants.h"
#include "buffer.h"
#include "output.h"
#include "visual.h"
@@ -29,52 +28,78 @@ extern "C"
Decoder::Decoder(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : QThread(parent), m_factory(d), m_input(i), m_output(o),m_eqInited(FALSE),
- m_useEQ(FALSE)
+ : QThread(parent), _m_factory(d), _m_input(i), _m_output(o), _m_eqInited(FALSE),
+ _m_useEQ(FALSE)
{
init();
}
Decoder::Decoder(QObject *parent, DecoderFactory *d, Output *o)
- : QThread(parent), m_factory(d), m_input(0), m_output(o),m_eqInited(FALSE),
- m_useEQ(FALSE)
+ : QThread(parent), _m_factory(d), _m_input(0), _m_output(o), _m_eqInited(FALSE),
+ _m_useEQ(FALSE)
{
init();
}
Decoder::~Decoder()
{
- m_factory = 0;
- m_input = 0;
- m_output = 0;
- blksize = 0;
+ _m_factory = 0;
+ _m_input = 0;
+ _m_output = 0;
+ _blksize = 0;
+ _m_handler = 0;
+ _m_done = FALSE;
+ _m_finish = FALSE;
+ _m_totalTime = 0;
+ _m_seekTime = -1;
+ _m_output_bytes = 0;
+ _m_output_at = 0;
+ _m_user_stop = FALSE;
+ _m_bks = Buffer::size();
+ _m_output_buf = 0;
+ _m_bitrate = 0;
+ _m_chan = 0;
+ if(_m_output_buf)
+ delete [] _m_output_buf;
+ _m_output_buf = 0;
}
void Decoder::init()
{
- if (m_output)
- m_output->recycler()->clear();
+ if (_m_output)
+ _m_output->recycler()->clear();
double b[] = {0,0,0,0,0,0,0,0,0,0};
setEQ(b, 0);
qRegisterMetaType<Qmmp::State>("Qmmp::State");
- blksize = Buffer::size();
- m_effects = Effect::create(this);
- m_handler = 0;
+ _blksize = Buffer::size();
+ _m_effects = Effect::create(this);
+ _m_handler = 0;
+ _m_done = FALSE;
+ _m_finish = FALSE;
+ _m_totalTime = 0;
+ _m_seekTime = -1;
+ _m_output_bytes = 0;
+ _m_output_at = 0;
+ _m_user_stop = FALSE;
+ _m_bks = Buffer::size();
+ _m_output_buf = 0;
+ _m_bitrate = 0;
+ _m_chan = 0;
}
DecoderFactory *Decoder::factory() const
{
- return m_factory;
+ return _m_factory;
}
QIODevice *Decoder::input()
{
- return m_input;
+ return _m_input;
}
Output *Decoder::output()
{
- return m_output;
+ return _m_output;
}
QMutex *Decoder::mutex()
@@ -89,12 +114,12 @@ QWaitCondition *Decoder::cond()
StateHandler *Decoder::stateHandler()
{
- return m_handler;
+ return _m_handler;
}
void Decoder::setStateHandler(StateHandler *handler)
{
- m_handler = handler;
+ _m_handler = handler;
}
void Decoder::setEQ(double bands[10], double preamp)
@@ -111,33 +136,48 @@ void Decoder::setEQ(double bands[10], double preamp)
void Decoder::setEQEnabled(bool on)
{
- m_useEQ = on;
+ _m_useEQ = on;
}
void Decoder::configure(quint32 srate, int chan, int bps)
{
Effect* effect = 0;
- foreach(effect, m_effects)
+ foreach(effect, _m_effects)
{
effect->configure(srate, chan, bps);
srate = effect->sampleRate();
chan = effect->channels();
bps = effect->bitsPerSample();
}
- if (m_output)
- m_output->configure(srate, chan, bps);
+ _m_chan = chan;
+ if (_m_output)
+ {
+ _m_output->configure(srate, chan, bps);
+ if (!_m_output_buf)
+ _m_output_buf = new unsigned char[Qmmp::globalBufferSize()];
+ }
+}
+
+void Decoder::seek(qint64 time)
+{
+ _m_seekTime = time;
+}
+
+void Decoder::stop()
+{
+ _m_user_stop = TRUE;
}
qint64 Decoder::produceSound(char *data, qint64 size, quint32 brate, int chan)
{
- ulong sz = size < blksize ? size : blksize;
+ ulong sz = size < _blksize ? size : _blksize;
- if (m_useEQ)
+ if (_m_useEQ)
{
- if (!m_eqInited)
+ if (!_m_eqInited)
{
init_iir();
- m_eqInited = TRUE;
+ _m_eqInited = TRUE;
}
iir((void*) data, sz, chan);
}
@@ -145,7 +185,7 @@ qint64 Decoder::produceSound(char *data, qint64 size, quint32 brate, int chan)
char *prev_data = data;
qint64 w = sz;
Effect* effect = 0;
- foreach(effect, m_effects)
+ foreach(effect, _m_effects)
{
w = effect->process(prev_data, sz, &out_data);
@@ -168,8 +208,8 @@ qint64 Decoder::produceSound(char *data, qint64 size, quint32 brate, int chan)
if (data != out_data)
delete out_data;
- if (w < blksize + b->exceeding)
- memset(b->data + w, 0, blksize + b->exceeding - w);
+ if (w < _blksize + b->exceeding)
+ memset(b->data + w, 0, _blksize + b->exceeding - w);
b->nbytes = w;
b->rate = brate;
@@ -188,14 +228,110 @@ void Decoder::finish()
output()->mutex()->lock ();
output()->finish();
output()->mutex()->unlock();
- /*output()->recycler()->mutex()->lock ();
- output()->recycler()->cond()->wakeAll();
- output()->recycler()->mutex()->unlock();
- output()->wait();*/
}
emit playbackFinished();
}
+void Decoder::run()
+{
+ Q_ASSERT(_m_chan == 0);
+ mutex()->lock ();
+
+ qint64 len = 0;
+
+ /*if (!inited)
+ {
+ mutex()->unlock();
+ return;
+ }*/
+
+ mutex()->unlock();
+
+ while (! _m_done && ! _m_finish)
+ {
+ mutex()->lock ();
+ // decode
+
+ if (_m_seekTime >= 0)
+ {
+ seekAudio(_m_seekTime);
+ _m_seekTime = -1;
+ }
+ len = readAudio((char *)(_m_output_buf + _m_output_at), Qmmp::globalBufferSize() - _m_output_at);
+ if (len > 0)
+ {
+ _m_bitrate = bitrate();
+ _m_output_at += len;
+ _m_output_bytes += len;
+ if (output())
+ flush();
+ }
+ else if (len == 0)
+ {
+ flush(TRUE);
+
+ if (output())
+ {
+ output()->recycler()->mutex()->lock ();
+ // end of stream
+ while (!output()->recycler()->empty() && !_m_user_stop)
+ {
+ output()->recycler()->cond()->wakeOne();
+ mutex()->unlock();
+ output()->recycler()->cond()->wait(output()->recycler()->mutex());
+ mutex()->lock ();
+ }
+ output()->recycler()->mutex()->unlock();
+ }
+
+ _m_done = TRUE;
+ _m_finish = !_m_user_stop;
+ }
+ else
+ _m_finish = TRUE;
+ mutex()->unlock();
+ }
+
+ mutex()->lock ();
+
+ if (_m_finish)
+ finish();
+
+ mutex()->unlock();
+}
+
+void Decoder::flush(bool final)
+{
+ ulong min = final ? 0 : _m_bks;
+
+ while ((!_m_done && !_m_finish) && _m_output_bytes > min)
+ {
+ output()->recycler()->mutex()->lock ();
+ while ((!_m_done && !_m_finish) && output()->recycler()->full())
+ {
+ mutex()->unlock();
+ output()->recycler()->cond()->wait(output()->recycler()->mutex());
+ mutex()->lock ();
+ _m_done = _m_user_stop;
+ }
+
+ if (_m_user_stop || _m_finish)
+ _m_done = TRUE;
+ else
+ {
+ _m_output_bytes -= produceSound((char*)_m_output_buf, _m_output_bytes, _m_bitrate, _m_chan);
+ _m_output_at = _m_output_bytes;
+ }
+
+ if (output()->recycler()->full())
+ {
+ output()->recycler()->cond()->wakeOne();
+ }
+
+ output()->recycler()->mutex()->unlock();
+ }
+}
+
// static methods
QList<DecoderFactory*> *Decoder::m_factories = 0;
DecoderFactory *Decoder::m_lastFactory = 0;
diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h
index 8093ad58e..a6fe04550 100644
--- a/src/qmmp/decoder.h
+++ b/src/qmmp/decoder.h
@@ -69,17 +69,18 @@ public:
* Requests a seek to the time \b time indicated, specified in milliseconds.
* Subclass should reimplement this function.
*/
- virtual void seek(qint64 time) = 0;
+ virtual void seek(qint64 time);
/*!
* Requests playback to stop
* Subclass should reimplement this function.
*/
- virtual void stop() = 0;
+ virtual void stop();
/*!
* Requests playback to pause. If it was paused already, playback should resume.
* Subclass with own output should reimplement this function.
*/
- virtual void pause(){};
+ virtual int bitrate() = 0;
+ virtual void pause(){}
/*!
* Returns decoder's factory object.
*/
@@ -182,6 +183,8 @@ signals:
void playbackFinished();
protected:
+
+ virtual void run();
/*!
* Use this function inside initialize() reimplementation to tell other plugins about audio parameters.
* @param srate Sample rate.
@@ -198,6 +201,10 @@ protected:
*/
qint64 produceSound(char *data, qint64 size, quint32 brate, int chan);
+ virtual qint64 readAudio(char *data, qint64 maxSize) = 0;
+
+ virtual void seekAudio(qint64 time) = 0;
+
protected slots:
/*!
* Subclass should call this slot when decoding is finished.
@@ -206,24 +213,32 @@ protected slots:
private:
void init();
+ void flush(bool = FALSE);
static void checkFactories();
- DecoderFactory *m_factory;
- QList <Effect*> m_effects;
- QIODevice *m_input;
- Output *m_output;
+ DecoderFactory *_m_factory;
+ QList <Effect*> _m_effects;
+ QIODevice *_m_input;
+ Output *_m_output;
QMutex m_mutex;
QWaitCondition m_waitCondition;
- uint blksize;
- bool m_eqInited;
- bool m_useEQ;
- StateHandler *m_handler;
+ uint _blksize;
+ bool _m_eqInited;
+ bool _m_useEQ;
+ bool _m_done, _m_finish, _m_user_stop;
+
+ ulong _m_bks;
+ qint64 _m_totalTime, _m_seekTime;
+ ulong _m_output_bytes, _m_output_at;
+ int _m_bitrate, _m_chan;
+ StateHandler *_m_handler;
+ unsigned char *_m_output_buf;
+
static QList<DecoderFactory*> *m_factories;
static DecoderFactory *m_lastFactory;
static QStringList m_files;
-
};
#endif // DECODER_H
diff --git a/src/qmmp/downloader.cpp b/src/qmmp/downloader.cpp
index ecd7b2414..b9170972c 100644
--- a/src/qmmp/downloader.cpp
+++ b/src/qmmp/downloader.cpp
@@ -26,7 +26,6 @@
#include <stdint.h>
#include <stdlib.h>
-#include "constants.h"
#include "qmmp.h"
#include "statehandler.h"
#include "downloader.h"
diff --git a/src/qmmp/effect.cpp b/src/qmmp/effect.cpp
index 0cb45a268..e0a26239e 100644
--- a/src/qmmp/effect.cpp
+++ b/src/qmmp/effect.cpp
@@ -24,7 +24,6 @@
#include "qmmp.h"
#include "effectfactory.h"
-#include "constants.h"
#include "effect.h"
Effect::Effect(QObject *parent)
diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp
index 15c75999f..0d26cf03d 100644
--- a/src/qmmp/output.cpp
+++ b/src/qmmp/output.cpp
@@ -10,7 +10,6 @@
#include <QApplication>
#include <QTimer>
-#include "constants.h"
#include "buffer.h"
#include "output.h"
#include "volumecontrol.h"
diff --git a/src/qmmp/qmmp.cpp b/src/qmmp/qmmp.cpp
index 567ddc9ba..ab682e286 100644
--- a/src/qmmp/qmmp.cpp
+++ b/src/qmmp/qmmp.cpp
@@ -32,6 +32,7 @@
#define LIB_DIR "/lib"
#endif
+#include "buffer.h"
#include "qmmp.h"
QString Qmmp::m_configFile;
@@ -119,3 +120,9 @@ QString Qmmp::systemLanguageID()
#endif
return QLocale::system().name();
}
+
+unsigned int Qmmp::globalBufferSize()
+{
+ return Buffer::size() * 128;
+}
+
diff --git a/src/qmmp/qmmp.h b/src/qmmp/qmmp.h
index e04904ee5..2b846919e 100644
--- a/src/qmmp/qmmp.h
+++ b/src/qmmp/qmmp.h
@@ -100,6 +100,10 @@ public:
* Returns system language
*/
static QString systemLanguageID();
+ /*!
+ * Returns global buffer size in bytes
+ */
+ static unsigned int globalBufferSize();
private:
diff --git a/src/qmmp/qmmp.pro b/src/qmmp/qmmp.pro
index f88868c3f..e803844f0 100644
--- a/src/qmmp/qmmp.pro
+++ b/src/qmmp/qmmp.pro
@@ -1,92 +1,80 @@
unix:include(../../qmmp.pri)
win32:include(../../qmmp.pri)
-
HEADERS += recycler.h \
- buffer.h \
- constants.h \
- decoder.h \
- output.h \
- outputfactory.h \
- equ\iir_cfs.h \
- equ\iir_fpu.h \
- equ\iir.h \
- decoderfactory.h \
- soundcore.h \
- streamreader.h \
- downloader.h \
- visual.h \
- visualfactory.h \
- effect.h \
- effectfactory.h \
- statehandler.h \
- qmmp.h \
- fileinfo.h \
- volumecontrol.h
+ buffer.h \
+ decoder.h \
+ output.h \
+ outputfactory.h \
+ equ\iir_cfs.h \
+ equ\iir_fpu.h \
+ equ\iir.h \
+ decoderfactory.h \
+ soundcore.h \
+ streamreader.h \
+ downloader.h \
+ visual.h \
+ visualfactory.h \
+ effect.h \
+ effectfactory.h \
+ statehandler.h \
+ qmmp.h \
+ fileinfo.h \
+ volumecontrol.h
SOURCES += recycler.cpp \
- decoder.cpp \
- output.cpp \
- equ\iir.c \
- equ\iir_cfs.c \
- equ\iir_fpu.c \
- soundcore.cpp \
- streamreader.cpp \
- downloader.cpp \
- visual.cpp \
- effect.cpp \
- statehandler.cpp \
- qmmp.cpp \
- fileinfo.cpp \
- volumecontrol.cpp
-
+ decoder.cpp \
+ output.cpp \
+ equ\iir.c \
+ equ\iir_cfs.c \
+ equ\iir_fpu.c \
+ soundcore.cpp \
+ streamreader.cpp \
+ downloader.cpp \
+ visual.cpp \
+ effect.cpp \
+ statehandler.cpp \
+ qmmp.cpp \
+ fileinfo.cpp \
+ volumecontrol.cpp
unix:TARGET = ../../lib/qmmp
-win32:TARGET = ../../../bin/qmmp
+win32:TARGET = ../../../bin/qmmp
CONFIG += release \
-shared \
-warn_on \
-qt \
-thread \
-link_pkgconfig
-
+ shared \
+ warn_on \
+ qt \
+ thread \
+ link_pkgconfig
TEMPLATE = lib
VERSION = $$QMMP_VERSION
unix:PKGCONFIG += libcurl
-win32:LIBS += -lcurldll
-
-unix : isEmpty(LIB_DIR){
- LIB_DIR = /lib
- }
-
-unix : DEFINES += LIB_DIR=\\\"$$LIB_DIR\\\"
+win32:LIBS += -lcurldll
+unix:isEmpty(LIB_DIR):LIB_DIR = /lib
+unix:DEFINES += LIB_DIR=\\\"$$LIB_DIR\\\"
DEFINES += QMMP_VERSION=$$QMMP_VERSION
DEFINES += QMMP_STR_VERSION=\\\"$$QMMP_VERSION\\\"
-
-contains(CONFIG, SVN_VERSION){
+contains(CONFIG, SVN_VERSION) {
unix:DEFINES += SVN_REVISION=\\\"$$system(./svn_revision.sh)\\\"
win32:DEFINES += SVN_REVISION=\\\"svn\\\"
}
-
-unix {
-target.path = $$LIB_DIR
-
-devel.files += buffer.h \
- constants.h \
- decoderfactory.h \
- decoder.h \
- effectfactory.h \
- effect.h \
- fileinfo.h \
- outputfactory.h \
- output.h \
- qmmp.h \
- recycler.h \
- soundcore.h \
- statehandler.h \
- visualfactory.h \
- visual.h \
- volumecontrol.h
-
-devel.path = /include/qmmp
-
-INSTALLS += target devel
-DESTDIR = .
+unix {
+ target.path = $$LIB_DIR
+ devel.files += buffer.h \
+ constants.h \
+ decoderfactory.h \
+ decoder.h \
+ effectfactory.h \
+ effect.h \
+ fileinfo.h \
+ outputfactory.h \
+ output.h \
+ qmmp.h \
+ recycler.h \
+ soundcore.h \
+ statehandler.h \
+ visualfactory.h \
+ visual.h \
+ volumecontrol.h
+ devel.path = /include/qmmp
+ INSTALLS += target \
+ devel
+ DESTDIR = .
}
diff --git a/src/qmmp/recycler.cpp b/src/qmmp/recycler.cpp
index e718d9c46..fd8b03cff 100644
--- a/src/qmmp/recycler.cpp
+++ b/src/qmmp/recycler.cpp
@@ -5,10 +5,8 @@
//
#include "recycler.h"
-#include "constants.h"
#include "buffer.h"
-
Recycler::Recycler ( unsigned int sz )
: add_index ( 0 ), done_index ( 0 ), current_count ( 0 )
{
diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp
index 7c8061d7b..c0e9e3582 100644
--- a/src/qmmp/soundcore.cpp
+++ b/src/qmmp/soundcore.cpp
@@ -25,7 +25,6 @@
#include <QDir>
#include "decoderfactory.h"
-#include "constants.h"
#include "streamreader.h"
#include "effect.h"
#include "statehandler.h"
diff --git a/src/qmmp/statehandler.cpp b/src/qmmp/statehandler.cpp
index 7636dcfde..8188159f1 100644
--- a/src/qmmp/statehandler.cpp
+++ b/src/qmmp/statehandler.cpp
@@ -57,6 +57,7 @@ void StateHandler::dispatch(qint64 elapsed,
int precision,
int channels)
{
+ Q_UNUSED(totalTime);
m_mutex.lock();
if (qAbs(m_elapsed - elapsed) > TICK_INTERVAL)
{
diff --git a/src/qmmp/visual.cpp b/src/qmmp/visual.cpp
index 366492986..ac820d497 100644
--- a/src/qmmp/visual.cpp
+++ b/src/qmmp/visual.cpp
@@ -25,7 +25,6 @@
#include <QApplication>
#include "visualfactory.h"
-#include "constants.h"
#include "output.h"
#include "visual.h"
diff --git a/src/ui/mainvisual.cpp b/src/ui/mainvisual.cpp
index b56a9d017..fe5707ecc 100644
--- a/src/ui/mainvisual.cpp
+++ b/src/ui/mainvisual.cpp
@@ -24,7 +24,6 @@
#include <QActionGroup>
#include <qmmp/buffer.h>
-#include <qmmp/constants.h>
#include <qmmp/output.h>
#include <math.h>
#include <stdlib.h>
diff --git a/src/ui/mainvisual.h b/src/ui/mainvisual.h
index 7e5d23c8e..d5b0f5068 100644
--- a/src/ui/mainvisual.h
+++ b/src/ui/mainvisual.h
@@ -23,7 +23,6 @@
#include <QWidget>
#include <QResizeEvent>
#include <qmmp/visual.h>
-#include <qmmp/constants.h>
#include "logscale.h"