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