summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/vorbis/libtremorplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/vorbis/libtremorplugin.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
index 53c4b2b..0002213 100644
--- a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
+++ b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp
@@ -10,42 +10,47 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
// fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org>
+#include "libtremorplugin.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+
+/* QT */
+#include <qmap.h>
+
+/* STD */
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <locale.h>
#include <math.h>
#include <assert.h>
-#include <qmap.h>
-
-#include "libtremorplugin.h"
-
extern "C" {
#include "tremor/ivorbisfile.h"
}
#define MPEG_BUFFER_SIZE 65536
//#define debugMsg(a) qDebug(a)
#define debugMsg(a)
class LibTremorPluginData {
@@ -53,25 +58,25 @@ public:
char* filename;
FILE* f;
OggVorbis_File vf;
vorbis_info* vi;
vorbis_comment* vc;
bool bos;
int csection;
QString finfo;
};
LibTremorPlugin::LibTremorPlugin() {
-qDebug("<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>");
+odebug << "<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>" << oendl;
d = new LibTremorPluginData;
d->f = 0;
d->vi = 0;
d->vc = 0;
d->bos = 0;
d->csection = 0;
d->finfo = "";
}
LibTremorPlugin::~LibTremorPlugin() {
close();
@@ -96,30 +101,30 @@ bool LibTremorPlugin::isFileSupported( const QString& path ) {
}
return FALSE;
}
bool LibTremorPlugin::open( const QString& path ) {
debugMsg( "LibTremorPlugin::open" );
d->filename = (char*) path.latin1();
d->f = fopen( d->filename, "r" );
if (d->f == 0) {
- qDebug("error opening %s", d->filename );
+ odebug << "error opening " << d->filename << "" << oendl;
return FALSE;
}
if (ov_open(d->f, &d->vf, NULL, 0) < 0) {
- qDebug("error opening %s", d->filename);
+ odebug << "error opening " << d->filename << "" << oendl;
return FALSE;
}
d->vc = ov_comment(&d->vf, -1);
d->vi = ov_info(&d->vf, -1);
d->bos = false;
QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" };
QString cdescr[] = { "Title", "Artist", "Album", "Year", "Track", "" };
QMap<QString, QString> cmap;
@@ -144,37 +149,37 @@ bool LibTremorPlugin::open( const QString& path ) {
for(int i = 0; !comments[i].isEmpty(); i++) {
QString v = cmap[comments[i].lower()];
if (!v.isEmpty()) {
if (!d->finfo.isEmpty()) {
d->finfo += ", ";
}
d->finfo += cdescr[i] + ": " + v;
}
}
- qDebug("finfo: " + d->finfo);
+ odebug << "finfo: " + d->finfo << oendl;
return TRUE;
}
bool LibTremorPlugin::close() {
debugMsg( "LibTremorPlugin::close" );
int result = TRUE;
if (fclose(d->f) == -1) {
- qDebug("error closing file %s", d->filename);
+ odebug << "error closing file " << d->filename << "" << oendl;
result = FALSE;
}
d->f = 0;
d->finfo = "";
return result;
}
bool LibTremorPlugin::isOpen() {
debugMsg( "LibTremorPlugin::isOpen" );
@@ -184,77 +189,77 @@ bool LibTremorPlugin::isOpen() {
const QString &LibTremorPlugin::fileInfo() {
return d->finfo;
}
int LibTremorPlugin::audioStreams() {
debugMsg( "LibTremorPlugin::audioStreams" );
return 1;
}
int LibTremorPlugin::audioChannels( int ) {
- qDebug( "LibTremorPlugin::audioChannels: %i", d->vi->channels );
+ odebug << "LibTremorPlugin::audioChannels: " << d->vi->channels << "" << oendl;
return d->vi->channels;
}
int LibTremorPlugin::audioFrequency( int ) {
- qDebug( "LibTremorPlugin::audioFrequency: %ld", d->vi->rate );
+ odebug << "LibTremorPlugin::audioFrequency: " << d->vi->rate << "" << oendl;
return d->vi->rate;
}
int LibTremorPlugin::audioSamples( int ) {
debugMsg( "LibTremorPlugin::audioSamples" );
return (int) ov_pcm_total(&d->vf,-1);
}
bool LibTremorPlugin::audioSetSample( long, int ) {
debugMsg( "LibTremorPlugin::audioSetSample" );
return FALSE;
}
long LibTremorPlugin::audioGetSample( int ) {
debugMsg( "LibTremorPlugin::audioGetSample" );
return 0;
}
bool LibTremorPlugin::audioReadSamples( short *output, int, long samples, long& samplesMade, int ) {
-// qDebug( "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples %d", samples );
+// odebug << "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples " << samples << "" << oendl;
int old_section = d->csection;
char* buf = (char*) output;
int length = samples * 4;
if ( samples == 0 )
return false;
while (length > 0) {
if (d->bos) {
d->vi = ov_info(&d->vf, -1);
d->vc = ov_comment(&d->vf, -1);
}
int n = 4096;
if (length < n) {
n = length;
}
long ret = ov_read(&d->vf, buf, n, &d->csection);
-// qDebug("%d", ret);
+// odebug << "" << ret << "" << oendl;
if (ret == 0) {
break;
} else if (ret < 0) {
return true;
}
if (old_section != d->csection) {
d->bos = true;
}
buf += ret;
length -= ret;