diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-07-20 16:02:04 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-07-20 16:02:04 +0000 |
| commit | 136ed47dafbd60544add69a7f2d720b7929bd83e (patch) | |
| tree | 875c56e2850c7d887b677472e9e1332d1b8be120 /src/plugins/Input/sndfile | |
| parent | 699ae4cd4abb386706229e60de7beb93edf07867 (diff) | |
| download | qmmp-136ed47dafbd60544add69a7f2d720b7929bd83e.tar.gz qmmp-136ed47dafbd60544add69a7f2d720b7929bd83e.tar.bz2 qmmp-136ed47dafbd60544add69a7f2d720b7929bd83e.zip | |
enabled sndfile plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1052 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/sndfile')
9 files changed, 81 insertions, 240 deletions
diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp index 9152913fe..77e4438c2 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.cpp +++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ilya Kotov * + * Copyright (C) 2007-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,7 +22,6 @@ #include <QFile> #include <QFileInfo> -#include <qmmp/constants.h> #include <qmmp/buffer.h> #include <qmmp/output.h> #include <qmmp/recycler.h> @@ -35,92 +34,23 @@ DecoderSndFile::DecoderSndFile(QObject *parent, DecoderFactory *d, Output *o, c : Decoder(parent, d, o) { m_path = path; - m_inited = FALSE; - m_user_stop = FALSE; - m_output_buf = 0; - m_output_bytes = 0; - m_output_at = 0; - bks = 0; - m_done = FALSE; - m_finish = FALSE; - m_freq = 0; m_bitrate = 0; - m_seekTime = -1.0; - m_totalTime = 0.0; - m_chan = 0; - m_output_size = 0; - m_buf = 0; + m_totalTime = 0; m_sndfile = 0; + m_freq = 0; } - DecoderSndFile::~DecoderSndFile() { deinit(); } - -void DecoderSndFile::stop() -{ - m_user_stop = TRUE; -} - - -void DecoderSndFile::flush(bool final) -{ - ulong min = final ? 0 : 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_inited = FALSE; - m_done = TRUE; - } - else - { - m_output_bytes -= produceSound(m_output_buf, m_output_bytes, m_bitrate, m_chan); - m_output_size += bks; - m_output_at = m_output_bytes; - } - - if (output()->recycler()->full()) - { - output()->recycler()->cond()->wakeOne(); - } - - output()->recycler()->mutex()->unlock(); - } -} - - bool DecoderSndFile::initialize() { - bks = Buffer::size(); - m_inited = m_user_stop = m_done = m_finish = FALSE; - m_freq = m_bitrate = 0; - m_output_size = 0; - m_seekTime = -1.0; + m_bitrate = 0; m_totalTime = 0.0; SF_INFO snd_info; - if (!m_output_buf) - m_output_buf = new char[globalBufferSize]; - m_output_at = 0; - m_output_bytes = 0; - memset (&snd_info, 0, sizeof(snd_info)); snd_info.format=0; m_sndfile = sf_open(m_path.toLocal8Bit(), SFM_READ, &snd_info); @@ -131,123 +61,42 @@ bool DecoderSndFile::initialize() } m_freq = snd_info.samplerate; - m_chan = snd_info.channels; - + int chan = snd_info.channels; m_totalTime = snd_info.frames * 1000 / m_freq; - m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime + 0.5; - configure(m_freq, m_chan, 16); - m_buf = new short[bks / sizeof(short)]; - m_inited = TRUE; + configure(m_freq, chan, 16); qDebug("DecoderSndFile: detected format: %08X", snd_info.format); qDebug("DecoderSndFile: initialize succes"); return TRUE; } +void DecoderSndFile::deinit() +{ + m_totalTime = 0; + m_bitrate = 0; + m_freq = 0; + if (m_sndfile) + sf_close(m_sndfile); + m_sndfile = 0; +} qint64 DecoderSndFile::totalTime() { - if (! m_inited) - return 0; - return m_totalTime; } - -void DecoderSndFile::seek(qint64 pos) +int DecoderSndFile::bitrate() { - m_seekTime = pos; + return m_bitrate; } - -void DecoderSndFile::deinit() +qint64 DecoderSndFile::readAudio(char *audio, qint64 maxSize) { - m_inited = m_user_stop = m_done = m_finish = FALSE; - m_freq = m_bitrate = m_chan = 0; - m_output_size = 0; - if (m_inited) - { - delete m_buf; - m_buf = 0; - sf_close(m_sndfile); - m_sndfile = 0; - } + return sizeof(short)* sf_read_short (m_sndfile, (short *)audio, maxSize / sizeof(short)); } -void DecoderSndFile::run() +void DecoderSndFile::seekAudio(qint64 pos) { - - long len = 0; - - mutex()->lock (); - - if (!m_inited) - { - mutex()->unlock(); - return; - } - mutex()->unlock(); - - while (!m_done && !m_finish) - { - mutex()->lock (); - // decode - - if (m_seekTime >= 0) - { - m_output_size = sf_seek(m_sndfile, m_freq*m_seekTime/1000, SEEK_SET); - m_seekTime = -1.0; - } - - len = sizeof(short)* sf_read_short (m_sndfile, m_buf, bks / sizeof(short)); - - if (len > 0) - { - memmove((char *)(m_output_buf + m_output_at), (char *) m_buf, len); - 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; - if (! m_user_stop) - { - m_finish = TRUE; - } - } - else - { - // error in read - qWarning("DecoderSndFile: Error while decoding stream, File appears to be corrupted"); - m_finish = TRUE; - } - mutex()->unlock(); - } - - mutex()->lock (); - if (m_finish) - finish(); - mutex()->unlock(); - - deinit(); + sf_seek(m_sndfile, m_freq * pos/1000, SEEK_SET); } diff --git a/src/plugins/Input/sndfile/decoder_sndfile.h b/src/plugins/Input/sndfile/decoder_sndfile.h index c62544193..9b1bb6fb0 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.h +++ b/src/plugins/Input/sndfile/decoder_sndfile.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ilya Kotov * + * Copyright (C) 2007-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -36,30 +36,19 @@ public: // Standard Decoder API bool initialize(); qint64 totalTime(); - void seek(qint64); - void stop(); - + int bitrate(); private: - // thread run function - void run(); + qint64 readAudio(char *audio, qint64 maxSize); + void seekAudio(qint64 time); + // helper functions - void flush(bool = FALSE); void deinit(); - // output buffer - char *m_output_buf; - SNDFILE *m_sndfile; - ulong m_output_bytes, m_output_at; - //struct sndfile_data *m_data; - short *m_buf; - unsigned int bks; - bool m_done, m_finish, m_inited, m_user_stop; - long m_freq, m_bitrate; - int m_chan; - qint64 m_output_size; - qint64 m_totalTime, m_seekTime; + int m_bitrate; + quint32 m_freq; + qint64 m_totalTime; QString m_path; }; diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_cs.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_cs.ts index 391499027..ab078bd0d 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_cs.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_cs.ts @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="cs"> +<!DOCTYPE TS> +<TS version="2.0" language="cs"> <context> <name>DecoderSndFileFactory</name> <message> @@ -13,22 +14,22 @@ <translation>Soubory PCM</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="135"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>O modulu Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="136"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Vstupní modul Qmmp Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="137"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>Zkompilováno s</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="138"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilja Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_de.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_de.ts index 28e72feb4..8ebf2e136 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_de.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_de.ts @@ -4,32 +4,32 @@ <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Sndfile-Modul</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>PCM-Dateien</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>Über Sndfile-Audio-Modul</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Qmmp Sndfile-Audio-Modul</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>Kompiliert gegen</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_it.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_it.ts index aba6f4c79..e2c33fbd4 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_it.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_it.ts @@ -1,35 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="de"> -<defaultcodec></defaultcodec> +<!DOCTYPE TS> +<TS version="2.0" language="de"> <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Modulo Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>Brani PCM</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>Info sul modulo audio Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Modulo audio Sndfile per Qmmp</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>Compilato su</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autore: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_ru.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_ru.ts index 453193760..1f7262ec6 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_ru.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_ru.ts @@ -1,35 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="pl"> -<defaultcodec></defaultcodec> +<!DOCTYPE TS> +<TS version="2.0" language="pl"> <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Модуль Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>Файлы PCM</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>Об аудио-модуле Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Модуль SndFile для Qmmp</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>Собрано с</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Разработчик: Илья Котов <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_uk_UA.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_uk_UA.ts index 7250965d2..06d72eba5 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_uk_UA.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_uk_UA.ts @@ -1,35 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="pl"> -<defaultcodec></defaultcodec> +<!DOCTYPE TS> +<TS version="2.0" language="pl"> <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Модуль Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>Файли PCM</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>Про аудіо-модуль Sndfile</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Модуль SndFile для Qmmp</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>Зкомпільовано з</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Розробник: Ілля Котов <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_CN.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_CN.ts index be0f23d45..172f8ddfe 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_CN.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_CN.ts @@ -1,34 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="zh_CN"> +<!DOCTYPE TS> +<TS version="2.0" language="zh_CN"> <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Sndfile 插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>PCM 文件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>关于 Sndfile 音频插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Qmmp Sndfile 音频插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>编译依赖</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>作者:Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_TW.ts b/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_TW.ts index 74dd14453..cbc9f15f1 100644 --- a/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_TW.ts +++ b/src/plugins/Input/sndfile/translations/sndfile_plugin_zh_TW.ts @@ -1,34 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS><TS version="1.1" language="zh_TW"> +<!DOCTYPE TS> +<TS version="2.0" language="zh_TW"> <context> <name>DecoderSndFileFactory</name> <message> - <location filename="../decodersndfilefactory.cpp" line="65"/> + <location filename="../decodersndfilefactory.cpp" line="66"/> <source>Sndfile Plugin</source> <translation>Sndfile 插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="67"/> + <location filename="../decodersndfilefactory.cpp" line="68"/> <source>PCM Files</source> <translation>PCM 檔案</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="127"/> + <location filename="../decodersndfilefactory.cpp" line="136"/> <source>About Sndfile Audio Plugin</source> <translation>關於 Sndfile 聲訊插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="128"/> + <location filename="../decodersndfilefactory.cpp" line="137"/> <source>Qmmp Sndfile Audio Plugin</source> <translation>Qmmp Sndfile 聲訊插件</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="129"/> + <location filename="../decodersndfilefactory.cpp" line="138"/> <source>Compiled against</source> <translation>編譯依賴於</translation> </message> <message> - <location filename="../decodersndfilefactory.cpp" line="130"/> + <location filename="../decodersndfilefactory.cpp" line="139"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>作者:Ilya Kotov <forkotov02@hotmail.ru></translation> </message> |
