summaryrefslogtreecommitdiff
authordwmw2 <dwmw2>2002-05-09 10:55:29 (UTC)
committer dwmw2 <dwmw2>2002-05-09 10:55:29 (UTC)
commitd23dbae0bafac32e9f91bf7bf9d0f7721a893ddf (patch) (unidiff)
tree4a885128bb79823dab6e857e09460dd1de7210f8
parent87b3b4dc4e32a7ffbe1ffd2d54b2eb8c23674c66 (diff)
downloadopie-d23dbae0bafac32e9f91bf7bf9d0f7721a893ddf.zip
opie-d23dbae0bafac32e9f91bf7bf9d0f7721a893ddf.tar.gz
opie-d23dbae0bafac32e9f91bf7bf9d0f7721a893ddf.tar.bz2
include qregexp.h
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index eda5859..b06cdaa 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -1,166 +1,167 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// largly modified by Maximilian Reiss <max.reiss@gmx.de> 20// largly modified by Maximilian Reiss <max.reiss@gmx.de>
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <stdarg.h> 23#include <stdarg.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <sys/types.h> 25#include <sys/types.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27#include <fcntl.h> 27#include <fcntl.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <string.h> 29#include <string.h>
30#include <ctype.h> 30#include <ctype.h>
31#include <errno.h> 31#include <errno.h>
32#include <time.h> 32#include <time.h>
33#include <locale.h> 33#include <locale.h>
34#include <math.h> 34#include <math.h>
35#include <assert.h> 35#include <assert.h>
36 36
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qregexp.h>
39 40
40#include <qpe/config.h> 41#include <qpe/config.h>
41 42
42// for network handling 43// for network handling
43#include <netinet/in.h> 44#include <netinet/in.h>
44#include <netdb.h> 45#include <netdb.h>
45#include <sys/socket.h> 46#include <sys/socket.h>
46#include <arpa/inet.h> 47#include <arpa/inet.h>
47#include <unistd.h> 48#include <unistd.h>
48 49
49 50
50//#define HAVE_MMAP 51//#define HAVE_MMAP
51 52
52#if defined(HAVE_MMAP) 53#if defined(HAVE_MMAP)
53# include <sys/mman.h> 54# include <sys/mman.h>
54#endif 55#endif
55#include "libmadplugin.h" 56#include "libmadplugin.h"
56 57
57 58
58extern "C" { 59extern "C" {
59#include "mad.h" 60#include "mad.h"
60} 61}
61 62
62 63
63#define MPEG_BUFFER_SIZE 65536 64#define MPEG_BUFFER_SIZE 65536
64//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 65//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192
65//#define debugMsg(a) qDebug(a) 66//#define debugMsg(a) qDebug(a)
66#define debugMsg(a) 67#define debugMsg(a)
67 68
68 69
69class Input { 70class Input {
70public: 71public:
71 char const *path; 72 char const *path;
72 int fd; 73 int fd;
73#if defined(HAVE_MMAP) 74#if defined(HAVE_MMAP)
74 void *fdm; 75 void *fdm;
75#endif 76#endif
76 unsigned char *data; 77 unsigned char *data;
77 unsigned long length; 78 unsigned long length;
78 int eof; 79 int eof;
79}; 80};
80 81
81 82
82class Output { 83class Output {
83public: 84public:
84 mad_fixed_t attenuate; 85 mad_fixed_t attenuate;
85 struct filter *filters; 86 struct filter *filters;
86 unsigned int channels_in; 87 unsigned int channels_in;
87 unsigned int channels_out; 88 unsigned int channels_out;
88 unsigned int speed_in; 89 unsigned int speed_in;
89 unsigned int speed_out; 90 unsigned int speed_out;
90 const char *path; 91 const char *path;
91}; 92};
92 93
93 94
94# if defined(HAVE_MMAP) 95# if defined(HAVE_MMAP)
95static void *map_file(int fd, unsigned long *length) 96static void *map_file(int fd, unsigned long *length)
96{ 97{
97 void *fdm; 98 void *fdm;
98 99
99 *length += MAD_BUFFER_GUARD; 100 *length += MAD_BUFFER_GUARD;
100 101
101 fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0); 102 fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0);
102 if (fdm == MAP_FAILED) 103 if (fdm == MAP_FAILED)
103 return 0; 104 return 0;
104 105
105# if defined(HAVE_MADVISE) 106# if defined(HAVE_MADVISE)
106 madvise(fdm, *length, MADV_SEQUENTIAL); 107 madvise(fdm, *length, MADV_SEQUENTIAL);
107# endif 108# endif
108 109
109 return fdm; 110 return fdm;
110} 111}
111 112
112 113
113static int unmap_file(void *fdm, unsigned long length) 114static int unmap_file(void *fdm, unsigned long length)
114{ 115{
115 if (munmap(fdm, length) == -1) 116 if (munmap(fdm, length) == -1)
116 return -1; 117 return -1;
117 118
118 return 0; 119 return 0;
119} 120}
120# endif 121# endif
121 122
122 123
123static inline QString tr( const char *str ) { 124static inline QString tr( const char *str ) {
124 // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin 125 // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin
125 return qApp->translate( "OpiePlayer", str, "libmad strings for mp3 file info" ); 126 return qApp->translate( "OpiePlayer", str, "libmad strings for mp3 file info" );
126} 127}
127 128
128 129
129class LibMadPluginData { 130class LibMadPluginData {
130public: 131public:
131 Input input; 132 Input input;
132 Output output; 133 Output output;
133 int bad_last_frame; 134 int bad_last_frame;
134 struct mad_stream stream; 135 struct mad_stream stream;
135 struct mad_frame frame; 136 struct mad_frame frame;
136 struct mad_synth synth; 137 struct mad_synth synth;
137 bool flush; 138 bool flush;
138}; 139};
139 140
140 141
141LibMadPlugin::LibMadPlugin() { 142LibMadPlugin::LibMadPlugin() {
142 d = new LibMadPluginData; 143 d = new LibMadPluginData;
143 d->input.fd = 0; 144 d->input.fd = 0;
144#if defined(HAVE_MMAP) 145#if defined(HAVE_MMAP)
145 d->input.fdm = 0; 146 d->input.fdm = 0;
146#endif 147#endif
147 d->input.data = 0; 148 d->input.data = 0;
148 d->flush = TRUE; 149 d->flush = TRUE;
149 info = tr( "No Song Open" ); 150 info = tr( "No Song Open" );
150} 151}
151 152
152 153
153LibMadPlugin::~LibMadPlugin() { 154LibMadPlugin::~LibMadPlugin() {
154 close(); 155 close();
155 delete d; 156 delete d;
156} 157}
157 158
158 159
159bool LibMadPlugin::isFileSupported( const QString& path ) { 160bool LibMadPlugin::isFileSupported( const QString& path ) {
160 debugMsg( "LibMadPlugin::isFileSupported" ); 161 debugMsg( "LibMadPlugin::isFileSupported" );
161 162
162 // Mpeg file extensions 163 // Mpeg file extensions
163 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3" 164 // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3"
164 // Other media extensions 165 // Other media extensions
165 // "wav","mid","mod","s3m","ogg","avi","mov","sid" 166 // "wav","mid","mod","s3m","ogg","avi","mov","sid"
166 167