summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/libmadplugin.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/libmadplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 1989b4a..428fc28 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -20,4 +20,16 @@
20// largly modified by Maximilian Reiss <max.reiss@gmx.de> 20// largly modified by Maximilian Reiss <max.reiss@gmx.de>
21 21
22#include "libmadplugin.h"
23
24/* OPIE */
25#include <qpe/config.h>
26#include <opie2/odebug.h>
27
28/* QT */
29#include <qapplication.h>
30#include <qmessagebox.h>
31#include <qregexp.h>
32
33/* STD */
22#include <stdio.h> 34#include <stdio.h>
23#include <stdarg.h> 35#include <stdarg.h>
@@ -35,10 +47,4 @@
35#include <assert.h> 47#include <assert.h>
36 48
37#include <qapplication.h>
38#include <qmessagebox.h>
39#include <qregexp.h>
40
41#include <qpe/config.h>
42
43// for network handling 49// for network handling
44#include <netinet/in.h> 50#include <netinet/in.h>
@@ -55,5 +61,4 @@
55# include <sys/mman.h> 61# include <sys/mman.h>
56#endif 62#endif
57#include "libmadplugin.h"
58 63
59 64
@@ -383,5 +388,5 @@ int LibMadPlugin::http_open(const QString& path ) {
383 388
384 if (len == -1) { 389 if (len == -1) {
385 // qDebug( "http_open: "+ QString(strerror(errno)) +"\n"); 390 // odebug << "http_open: "+ QString(strerror(errno)) +"\n" << oendl;
386 return 0; 391 return 0;
387 } 392 }
@@ -397,5 +402,5 @@ int LibMadPlugin::http_open(const QString& path ) {
397 /* This is shoutcast/icecast streaming */ 402 /* This is shoutcast/icecast streaming */
398 if (strncmp(http_request + 4, "200 ", 4)) { 403 if (strncmp(http_request + 4, "200 ", 4)) {
399 // qDebug("http_open: " + QString(http_request) + "\n"); 404 // odebug << "http_open: " + QString(http_request) + "\n" << oendl;
400 return 0; 405 return 0;
401 } 406 }
@@ -418,5 +423,5 @@ int LibMadPlugin::http_open(const QString& path ) {
418 info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); 423 info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " );
419 424
420 // qDebug("Stream info: " + info); 425 // odebug << "Stream info: " + info << oendl;
421 426
422 return (tcp_sock); 427 return (tcp_sock);
@@ -430,10 +435,10 @@ bool LibMadPlugin::open( const QString& path ) {
430 cfg.setGroup("Options"); 435 cfg.setGroup("Options");
431 bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); 436 bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE);
432 // qDebug("buffer size is %d", bufferSize); 437 // odebug << "buffer size is " << bufferSize << "" << oendl;
433 d->bad_last_frame = 0; 438 d->bad_last_frame = 0;
434 d->flush = TRUE; 439 d->flush = TRUE;
435 info = QString( "" ); 440 info = QString( "" );
436 441
437 //qDebug( "Opening %s", path.latin1() ); 442 //odebug << "Opening " << path << "" << oendl;
438 443
439 if (path.left( 4 ) == "http" ) { 444 if (path.left( 4 ) == "http" ) {
@@ -451,5 +456,5 @@ bool LibMadPlugin::open( const QString& path ) {
451 } 456 }
452 if (d->input.fd == -1) { 457 if (d->input.fd == -1) {
453 // qDebug("error opening %s", d->input.path ); 458 // odebug << "error opening " << d->input.path << "" << oendl;
454 return FALSE; 459 return FALSE;
455 } 460 }
@@ -457,5 +462,5 @@ bool LibMadPlugin::open( const QString& path ) {
457 struct stat stat; 462 struct stat stat;
458 if (fstat(d->input.fd, &stat) == -1) { 463 if (fstat(d->input.fd, &stat) == -1) {
459 // qDebug("error calling fstat"); return FALSE; 464 // odebug << "error calling fstat" << oendl; return FALSE;
460 } 465 }
461 if (S_ISREG(stat.st_mode) && stat.st_size > 0) 466 if (S_ISREG(stat.st_mode) && stat.st_size > 0)
@@ -463,5 +468,5 @@ bool LibMadPlugin::open( const QString& path ) {
463 else 468 else
464 d->input.fileLength = 0; 469 d->input.fileLength = 0;
465 470
466#if defined(HAVE_MMAP) 471#if defined(HAVE_MMAP)
467 if (S_ISREG(stat.st_mode) && stat.st_size > 0) { 472 if (S_ISREG(stat.st_mode) && stat.st_size > 0) {
@@ -469,5 +474,5 @@ bool LibMadPlugin::open( const QString& path ) {
469 d->input.fdm = map_file(d->input.fd, &d->input.length); 474 d->input.fdm = map_file(d->input.fd, &d->input.length);
470 if (d->input.fdm == 0) { 475 if (d->input.fdm == 0) {
471 // qDebug("error mmapping file"); return FALSE; 476 // odebug << "error mmapping file" << oendl; return FALSE;
472 } 477 }
473 d->input.data = (unsigned char *)d->input.fdm; 478 d->input.data = (unsigned char *)d->input.fdm;
@@ -478,5 +483,5 @@ bool LibMadPlugin::open( const QString& path ) {
478 d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); 483 d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/);
479 if (d->input.data == 0) { 484 if (d->input.data == 0) {
480 // qDebug("error allocating input buffer"); 485 // odebug << "error allocating input buffer" << oendl;
481 return FALSE; 486 return FALSE;
482 } 487 }
@@ -506,5 +511,5 @@ bool LibMadPlugin::close() {
506 if (d->input.fdm) { 511 if (d->input.fdm) {
507 if (unmap_file(d->input.fdm, d->input.length) == -1) { 512 if (unmap_file(d->input.fdm, d->input.length) == -1) {
508 // qDebug("error munmapping file"); 513 // odebug << "error munmapping file" << oendl;
509 result = FALSE; 514 result = FALSE;
510 } 515 }
@@ -520,5 +525,5 @@ bool LibMadPlugin::close() {
520 525
521 if (::close(d->input.fd) == -1) { 526 if (::close(d->input.fd) == -1) {
522 // qDebug("error closing file %s", d->input.path); 527 // odebug << "error closing file " << d->input.path << "" << oendl;
523 result = FALSE; 528 result = FALSE;
524 } 529 }
@@ -546,5 +551,5 @@ int LibMadPlugin::audioChannels( int ) {
546/* 551/*
547 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); 552 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
548 qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); 553 odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl;
549 return d->frame.header.mode > 0 ? 2 : 1; 554 return d->frame.header.mode > 0 ? 2 : 1;
550*/ 555*/
@@ -556,5 +561,5 @@ int LibMadPlugin::audioFrequency( int ) {
556 debugMsg( "LibMadPlugin::audioFrequency" ); 561 debugMsg( "LibMadPlugin::audioFrequency" );
557 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); 562 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
558 // qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); 563 // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl;
559 return d->frame.header.samplerate; 564 return d->frame.header.samplerate;
560} 565}
@@ -567,6 +572,5 @@ int LibMadPlugin::audioSamples( int ) {
567 mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); 572 mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream );
568/* 573/*
569 qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, 574 odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl;
570 d->frame.header.samplerate );
571 return d->frame.header.duration.seconds * d->frame.header.samplerate; 575 return d->frame.header.duration.seconds * d->frame.header.samplerate;
572*/ 576*/
@@ -576,6 +580,6 @@ int LibMadPlugin::audioSamples( int ) {
576 580
577 // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, 581 // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength,
578 // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); 582 // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate );
579 // qDebug( "LibMadPlugin::audioSamples: %i", samples ); 583 // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl;
580 584
581 return samples; 585 return samples;
@@ -593,5 +597,5 @@ bool LibMadPlugin::audioSetSample( long, int ) {
593 597
594// // Seek to requested position 598// // Seek to requested position
595// qDebug( "seek pos: %i", (int)((double)pos * d->input.fileLength / totalSamples) ); 599// odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl;
596// ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); 600// ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET );
597// mad_stream_sync(&d->stream); 601// mad_stream_sync(&d->stream);
@@ -681,5 +685,5 @@ bool LibMadPlugin::read() {
681 685
682 if (len == -1) { 686 if (len == -1) {
683 // qDebug("error reading audio"); 687 // odebug << "error reading audio" << oendl;
684 return FALSE; 688 return FALSE;
685 } 689 }
@@ -759,5 +763,5 @@ bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) {
759 if ( d->stream.error == MAD_ERROR_BADCRC ) { 763 if ( d->stream.error == MAD_ERROR_BADCRC ) {
760 mad_frame_mute(&d->frame); 764 mad_frame_mute(&d->frame);
761 // qDebug( "error decoding, bad crc" ); 765 // odebug << "error decoding, bad crc" << oendl;
762 } 766 }
763 } 767 }
@@ -822,15 +826,15 @@ double LibMadPlugin::getTime() {
822 826
823void LibMadPlugin::printID3Tags() { 827void LibMadPlugin::printID3Tags() {
824 // qDebug( "LibMadPlugin::printID3Tags" ); 828 // odebug << "LibMadPlugin::printID3Tags" << oendl;
825 829
826 char id3v1[128 + 1]; 830 char id3v1[128 + 1];
827 831
828 if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { 832 if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) {
829 // qDebug( "error seeking to id3 tags" ); 833 // odebug << "error seeking to id3 tags" << oendl;
830 return; 834 return;
831 } 835 }
832 836
833 if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { 837 if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) {
834 // qDebug( "error reading in id3 tags" ); 838 // odebug << "error reading in id3 tags" << oendl;
835 return; 839 return;
836 } 840 }
@@ -842,5 +846,5 @@ void LibMadPlugin::printID3Tags() {
842 QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; 846 QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) };
843 char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; 847 char *ptr = id3v1 + 3, *ptr2 = ptr + len[0];
844 // qDebug( "ID3 tags in file:" ); 848 // odebug << "ID3 tags in file:" << oendl;
845 info = ""; 849 info = "";
846 for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { 850 for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) {
@@ -854,5 +858,5 @@ void LibMadPlugin::printID3Tags() {
854 info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; 858 info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr;
855 } 859 }
856// qDebug( info.latin1() ); 860// odebug << info.latin1() << oendl;
857 *ptr3 = push2; 861 *ptr3 = push2;
858 *ptr2 = push; 862 *ptr2 = push;
@@ -863,5 +867,5 @@ void LibMadPlugin::printID3Tags() {
863 867
864 if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { 868 if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) {
865 // qDebug( "error seeking back to beginning" ); 869 // odebug << "error seeking back to beginning" << oendl;
866 return; 870 return;
867 } 871 }