author | dwmw2 <dwmw2> | 2002-05-17 13:01:21 (UTC) |
---|---|---|
committer | dwmw2 <dwmw2> | 2002-05-17 13:01:21 (UTC) |
commit | e52cf1a1dc88cea3f2bac03a06d7c429e49a9f7e (patch) (side-by-side diff) | |
tree | 4a30a8a045049594c570e4e5c96a6018a044a4c5 | |
parent | d8d70e07a09a7c50021f6c85690b79b422d43df5 (diff) | |
download | opie-e52cf1a1dc88cea3f2bac03a06d7c429e49a9f7e.zip opie-e52cf1a1dc88cea3f2bac03a06d7c429e49a9f7e.tar.gz opie-e52cf1a1dc88cea3f2bac03a06d7c429e49a9f7e.tar.bz2 |
grrr. put qregexp.h back again
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 0adb503..3df23249 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -1,230 +1,231 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // largly modified by Maximilian Reiss <max.reiss@gmx.de> #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 <ctype.h> #include <errno.h> #include <time.h> #include <locale.h> #include <math.h> #include <assert.h> #include <qapplication.h> #include <qmessagebox.h> +#include <qregexp.h> #include <qpe/config.h> // for network handling #include <netinet/in.h> #include <netdb.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> //#define HAVE_MMAP #if defined(HAVE_MMAP) # include <sys/mman.h> #endif #include "libmadplugin.h" extern "C" { #include "mad.h" } #define MPEG_BUFFER_SIZE 65536 //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 //#define debugMsg(a) qDebug(a) #define debugMsg(a) class Input { public: char const *path; int fd; #if defined(HAVE_MMAP) void *fdm; #endif unsigned char *data; unsigned long length; int eof; }; class Output { public: mad_fixed_t attenuate; struct filter *filters; unsigned int channels_in; unsigned int channels_out; unsigned int speed_in; unsigned int speed_out; const char *path; }; # if defined(HAVE_MMAP) static void *map_file(int fd, unsigned long *length) { void *fdm; *length += MAD_BUFFER_GUARD; fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0); if (fdm == MAP_FAILED) return 0; # if defined(HAVE_MADVISE) madvise(fdm, *length, MADV_SEQUENTIAL); # endif return fdm; } static int unmap_file(void *fdm, unsigned long length) { if (munmap(fdm, length) == -1) return -1; return 0; } # endif static inline QString tr( const char *str ) { // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin return qApp->translate( "OpiePlayer", str, "libmad strings for mp3 file info" ); } class LibMadPluginData { public: Input input; Output output; int bad_last_frame; struct mad_stream stream; struct mad_frame frame; struct mad_synth synth; bool flush; }; LibMadPlugin::LibMadPlugin() { d = new LibMadPluginData; d->input.fd = 0; #if defined(HAVE_MMAP) d->input.fdm = 0; #endif d->input.data = 0; d->flush = TRUE; info = tr( "No Song Open" ); } LibMadPlugin::~LibMadPlugin() { close(); delete d; } bool LibMadPlugin::isFileSupported( const QString& path ) { debugMsg( "LibMadPlugin::isFileSupported" ); // Mpeg file extensions // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3" // Other media extensions // "wav","mid","mod","s3m","ogg","avi","mov","sid" char *ext = strrchr( path.latin1(), '.' ); // Test file extension if ( ext ) { if ( strncasecmp(ext, ".mp2", 4) == 0 ) return TRUE; if ( strncasecmp(ext, ".mp3", 4) == 0 ) return TRUE; } // UGLY - just for fast testing if ( path.left(4) == "http") { return TRUE; } return FALSE; } int LibMadPlugin::is_address_multicast(unsigned long address) { if ((address & 255) >= 224 && (address & 255) <= 239) return (1); return (0); } int LibMadPlugin::udp_open(char *address, int port) { int enable = 1L; struct sockaddr_in stAddr; struct sockaddr_in stLclAddr; struct ip_mreq stMreq; struct hostent *host; int sock; stAddr.sin_family = AF_INET; stAddr.sin_port = htons(port); if ((host = gethostbyname(address)) == NULL) { return (0); } stAddr.sin_addr = *((struct in_addr *)host->h_addr_list[0]); /* Create a UDP socket */ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { return (0); } /* Allow multiple instance of the client to share the same address and port */ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&enable, sizeof(unsigned long int)) < 0) { return (0); } /* If the address is multicast, register to the multicast group */ if (is_address_multicast(stAddr.sin_addr.s_addr)) { /* Bind the socket to port */ stLclAddr.sin_family = AF_INET; stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY); stLclAddr.sin_port = stAddr.sin_port; if (bind(sock, (struct sockaddr *)&stLclAddr, sizeof(stLclAddr)) < 0) { return (0); } |