Diffstat (limited to 'core/multimedia/opieplayer/wavplugin') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/Makefile.in | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 261 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.h | 24 |
3 files changed, 154 insertions, 135 deletions
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in index bcbe7f2..a46b925 100644 --- a/core/multimedia/opieplayer/wavplugin/Makefile.in +++ b/core/multimedia/opieplayer/wavplugin/Makefile.in | |||
@@ -87,23 +87,25 @@ listaddonpromodules: | |||
87 | listaddonentmodules: | 87 | listaddonentmodules: |
88 | @echo | 88 | @echo |
89 | 89 | ||
90 | 90 | ||
91 | REQUIRES= | 91 | REQUIRES= |
92 | 92 | ||
93 | ####### Sub-libraries | 93 | ####### Sub-libraries |
94 | 94 | ||
95 | 95 | ||
96 | ###### Combined headers | 96 | ###### Combined headers |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | ####### Compile | 100 | ####### Compile |
101 | 101 | ||
102 | wavplugin.o: wavplugin.cpp \ | 102 | wavplugin.o: wavplugin.cpp \ |
103 | wavplugin.h | 103 | wavplugin.h \ |
104 | ../mediaplayerplugininterface.h | ||
104 | 105 | ||
105 | wavpluginimpl.o: wavpluginimpl.cpp \ | 106 | wavpluginimpl.o: wavpluginimpl.cpp \ |
106 | wavplugin.h \ | 107 | wavplugin.h \ |
108 | ../mediaplayerplugininterface.h \ | ||
107 | wavpluginimpl.h | 109 | wavpluginimpl.h |
108 | 110 | ||
109 | 111 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index a6bd974..7f63b3b 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -4,331 +4,338 @@ | |||
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 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #include <stdio.h> | 22 | #include <stdio.h> |
21 | #include <stdarg.h> | 23 | #include <stdarg.h> |
22 | #include <stdlib.h> | 24 | #include <stdlib.h> |
23 | #include <errno.h> | 25 | #include <errno.h> |
24 | #include <unistd.h> | 26 | #include <unistd.h> |
25 | #include <qfile.h> | 27 | #include <qfile.h> |
26 | #include "wavplugin.h" | 28 | #include "wavplugin.h" |
27 | 29 | ||
28 | 30 | ||
29 | //#define debugMsg(a) qDebug(a) | 31 | //#define debugMsg(a) qDebug(a) |
30 | #define debugMsg(a) | 32 | #define debugMsg(a) |
31 | 33 | ||
32 | 34 | ||
33 | struct RiffChunk { | 35 | struct RiffChunk { |
34 | char id[4]; | 36 | char id[4]; |
35 | Q_UINT32 size; | 37 | Q_UINT32 size; |
36 | char data[4]; | 38 | char data[4]; |
37 | }; | 39 | }; |
38 | 40 | ||
39 | 41 | ||
40 | struct ChunkData { | 42 | struct ChunkData { |
41 | Q_INT16 formatTag; | 43 | Q_INT16 formatTag; |
42 | Q_INT16 channels; | 44 | Q_INT16 channels; |
43 | Q_INT32 samplesPerSec; | 45 | Q_INT32 samplesPerSec; |
44 | Q_INT32 avgBytesPerSec; | 46 | Q_INT32 avgBytesPerSec; |
45 | Q_INT16 blockAlign; | 47 | Q_INT16 blockAlign; |
46 | Q_INT16 wBitsPerSample; | 48 | Q_INT16 wBitsPerSample; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | 51 | ||
50 | const int sound_buffer_size = 4096; | 52 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? |
51 | 53 | ||
52 | 54 | ||
53 | class WavPluginData { | 55 | class WavPluginData { |
54 | public: | 56 | public: |
55 | QFile *input; | 57 | QFile *input; |
56 | 58 | ||
57 | int wavedata_remaining; | 59 | int wavedata_remaining; |
58 | ChunkData chunkdata; | 60 | ChunkData chunkdata; |
59 | RiffChunk chunk; | 61 | RiffChunk chunk; |
60 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data | 62 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data |
61 | int out,max; | 63 | int out,max; |
62 | int samples_due; | 64 | int samples_due; |
63 | int samples; | 65 | int samples; |
64 | 66 | ||
65 | WavPluginData() { | 67 | WavPluginData() { |
66 | max = out = sound_buffer_size; | 68 | max = out = sound_buffer_size; |
67 | wavedata_remaining = 0; | 69 | wavedata_remaining = 0; |
68 | samples_due = 0; | 70 | samples_due = 0; |
69 | samples = -1; | 71 | samples = -1; |
70 | } | 72 | } |
71 | 73 | ||
72 | // expands out samples to the frequency of 44kHz | 74 | // expands out samples to the frequency of 44kHz |
73 | bool add( short *output, long count, long& done, bool stereo ) | 75 | bool add( short *output, long count, long& done, bool stereo ) |
74 | { | 76 | { |
75 | done = 0; | 77 | done = 0; |
78 | qApp->processEvents(); | ||
76 | 79 | ||
77 | if ( input == 0 ) { | 80 | if ( input == 0 ) { |
78 | qDebug("no input"); | 81 | qDebug("no input"); |
79 | return FALSE; | 82 | return FALSE; |
80 | } | 83 | } |
81 | 84 | ||
82 | while ( count ) { | 85 | while ( count ) { |
83 | int l,r; | 86 | int l,r; |
84 | if ( getSample(l, r) == FALSE ) { | 87 | if ( getSample(l, r) == FALSE ) { |
85 | qDebug("didn't get sample"); | 88 | qDebug("didn't get sample"); |
86 | return FALSE; | 89 | return FALSE; |
87 | } | 90 | } |
88 | samples_due += 44100; | 91 | samples_due += chunkdata.samplesPerSec; |
89 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
90 | *output++ = l; | 93 | *output++ = l; |
91 | if ( stereo ) | 94 | if ( stereo ) |
92 | *output++ = r; | 95 | *output++ = r; |
93 | samples_due -= chunkdata.samplesPerSec; | 96 | samples_due -= chunkdata.samplesPerSec; |
94 | count--; | 97 | count--; |
95 | done++; | 98 | done++; |
96 | } | 99 | } |
97 | } | 100 | } |
98 | |||
99 | return TRUE; | 101 | return TRUE; |
100 | } | 102 | } |
101 | 103 | ||
102 | bool initialise() { | 104 | bool initialise() { |
103 | if ( input == 0 ) | 105 | if ( input == 0 ) |
104 | return FALSE; | 106 | return FALSE; |
105 | 107 | ||
106 | wavedata_remaining = -1; | 108 | wavedata_remaining = -1; |
107 | 109 | ||
108 | while ( wavedata_remaining == -1 ) { | 110 | while ( wavedata_remaining == -1 ) { |
109 | // Keep reading chunks... | 111 | // Keep reading chunks... |
110 | const int n = sizeof(chunk) - sizeof(chunk.data); | 112 | const int n = sizeof(chunk) - sizeof(chunk.data); |
111 | int t = input->readBlock( (char*)&chunk, n ); | 113 | int t = input->readBlock( (char*)&chunk, n ); |
112 | if ( t != n ) { | 114 | if ( t != n ) { |
113 | if ( t == -1 ) | 115 | if ( t == -1 ) |
114 | return FALSE; | 116 | return FALSE; |
115 | return TRUE; | 117 | return TRUE; |
116 | } | 118 | } |
117 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 119 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
118 | samples = wavedata_remaining = chunk.size; | 120 | samples = wavedata_remaining = chunk.size; |
119 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 121 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
120 | char d[4]; | 122 | char d[4]; |
121 | if ( input->readBlock(d,4) != 4 ) { | 123 | if ( input->readBlock(d,4) != 4 ) { |
122 | return FALSE; | 124 | return FALSE; |
123 | } | 125 | } |
124 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
125 | // skip | 127 | // skip |
126 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
127 | return FALSE; | 129 | return FALSE; |
128 | } | 130 | } |
129 | } | 131 | } |
130 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
131 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
132 | return FALSE; | 134 | return FALSE; |
133 | } | 135 | } |
134 | #define WAVE_FORMAT_PCM 1 | 136 | #define WAVE_FORMAT_PCM 1 |
135 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
136 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); |
137 | return FALSE; | 139 | return FALSE; |
138 | } | 140 | } |
139 | } else { | 141 | } else { |
140 | // ignored chunk | 142 | // ignored chunk |
141 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
142 | return FALSE; | 144 | return FALSE; |
143 | } | 145 | } |
144 | } | 146 | } |
145 | } // while | 147 | } // while |
146 | 148 | qDebug("bits %d", chunkdata.wBitsPerSample); | |
147 | return TRUE; | 149 | return TRUE; |
148 | } | 150 | } |
149 | 151 | ||
150 | 152 | ||
151 | // gets a sample from the file | 153 | // gets a sample from the file |
152 | bool getSample(int& l, int& r) | 154 | bool getSample(int& l, int& r) |
153 | { | 155 | { |
154 | l = r = 0; | 156 | l = r = 0; |
155 | 157 | ||
156 | if ( input == 0 ) | 158 | if ( input == 0 ) |
157 | return FALSE; | 159 | return FALSE; |
158 | 160 | ||
159 | if ( (wavedata_remaining < 0) || !max ) | 161 | if ( (wavedata_remaining < 0) || !max ) |
160 | return FALSE; | 162 | return FALSE; |
161 | 163 | ||
162 | if ( out >= max ) { | 164 | if ( out >= max ) { |
163 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); | 165 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); |
164 | 166 | ||
165 | wavedata_remaining -= max; | 167 | wavedata_remaining -= max; |
166 | 168 | ||
167 | out = 0; | 169 | out = 0; |
168 | if ( max <= 0 ) { | 170 | if ( max <= 0 ) { |
169 | max = 0; | 171 | max = 0; |
170 | return TRUE; | 172 | return TRUE; |
171 | } | 173 | } |
172 | } | 174 | } |
173 | if ( chunkdata.wBitsPerSample == 8 ) { | 175 | if ( chunkdata.wBitsPerSample == 8 ) { |
174 | l = (data[out++] - 128) * 128; | 176 | l = (data[out++] - 128) * 128; |
175 | } else { | 177 | } else { |
176 | l = ((short*)data)[out/2]; | 178 | l = ((short*)data)[out/2]; |
177 | out += 2; | 179 | out += 2; |
178 | } | 180 | } |
179 | if ( chunkdata.channels == 1 ) { | 181 | if ( chunkdata.channels == 1 ) { |
180 | r = l; | 182 | r = l; |
181 | } else { | 183 | } else { |
182 | if ( chunkdata.wBitsPerSample == 8 ) { | 184 | if ( chunkdata.wBitsPerSample == 8 ) { |
183 | r = (data[out++] - 128) * 128; | 185 | r = (data[out++] - 128) * 128; |
184 | } else { | 186 | } else { |
185 | r = ((short*)data)[out/2]; | 187 | r = ((short*)data)[out/2]; |
186 | out += 2; | 188 | out += 2; |
187 | } | 189 | } |
188 | } | 190 | } |
189 | return TRUE; | 191 | return TRUE; |
190 | } // getSample | 192 | } // getSample |
191 | 193 | ||
192 | }; | 194 | }; |
193 | 195 | ||
194 | 196 | ||
195 | WavPlugin::WavPlugin() { | 197 | WavPlugin::WavPlugin() { |
196 | d = new WavPluginData; | 198 | d = new WavPluginData; |
197 | d->input = 0; | 199 | d->input = 0; |
198 | } | 200 | } |
199 | 201 | ||
200 | 202 | ||
201 | WavPlugin::~WavPlugin() { | 203 | WavPlugin::~WavPlugin() { |
202 | close(); | 204 | close(); |
203 | delete d; | 205 | delete d; |
204 | } | 206 | } |
205 | 207 | ||
206 | 208 | ||
207 | bool WavPlugin::isFileSupported( const QString& path ) { | 209 | bool WavPlugin::isFileSupported( const QString& path ) { |
208 | debugMsg( "WavPlugin::isFileSupported" ); | 210 | // qDebug( "WavPlugin::isFileSupported" ); |
209 | 211 | ||
210 | char *ext = strrchr( path.latin1(), '.' ); | 212 | char *ext = strrchr( path.latin1(), '.' ); |
211 | 213 | ||
212 | // Test file extension | 214 | // Test file extension |
213 | if ( ext ) { | 215 | if ( ext ) { |
214 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
215 | return TRUE; | 217 | return TRUE; |
216 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
217 | return TRUE; | 219 | return TRUE; |
218 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
219 | return TRUE; | 221 | return TRUE; |
220 | } | 222 | } |
221 | 223 | ||
222 | return FALSE; | 224 | return FALSE; |
223 | } | 225 | } |
224 | 226 | ||
225 | 227 | ||
226 | bool WavPlugin::open( const QString& path ) { | 228 | bool WavPlugin::open( const QString& path ) { |
227 | debugMsg( "WavPlugin::open" ); | 229 | // qDebug( "WavPlugin::open" ); |
228 | 230 | ||
229 | d->max = d->out = sound_buffer_size; | 231 | d->max = d->out = sound_buffer_size; |
230 | d->wavedata_remaining = 0; | 232 | d->wavedata_remaining = 0; |
231 | d->samples_due = 0; | 233 | d->samples_due = 0; |
232 | 234 | ||
233 | d->input = new QFile( path ); | 235 | d->input = new QFile( path ); |
234 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
235 | qDebug("couldn't open file"); | 237 | qDebug("couldn't open file"); |
236 | delete d->input; | 238 | delete d->input; |
237 | d->input = 0; | 239 | d->input = 0; |
238 | return FALSE; | 240 | return FALSE; |
239 | } | 241 | } |
240 | 242 | ||
241 | d->initialise(); | 243 | d->initialise(); |
242 | 244 | ||
243 | return TRUE; | 245 | return TRUE; |
244 | } | 246 | } |
245 | 247 | ||
246 | 248 | ||
247 | bool WavPlugin::close() { | 249 | bool WavPlugin::close() { |
248 | debugMsg( "WavPlugin::close" ); | 250 | // qDebug( "WavPlugin::close" ); |
249 | 251 | ||
250 | d->input->close(); | 252 | d->input->close(); |
251 | delete d->input; | 253 | delete d->input; |
252 | d->input = 0; | 254 | d->input = 0; |
253 | return TRUE; | 255 | return TRUE; |
254 | } | 256 | } |
255 | 257 | ||
256 | 258 | ||
257 | bool WavPlugin::isOpen() { | 259 | bool WavPlugin::isOpen() { |
258 | debugMsg( "WavPlugin::isOpen" ); | 260 | // qDebug( "WavPlugin::isOpen" ); |
259 | return ( d->input != 0 ); | 261 | return ( d->input != 0 ); |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | int WavPlugin::audioStreams() { | 265 | int WavPlugin::audioStreams() { |
264 | debugMsg( "WavPlugin::audioStreams" ); | 266 | // qDebug( "WavPlugin::audioStreams" ); |
265 | return 1; | 267 | return 1; |
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | int WavPlugin::audioChannels( int ) { | 271 | int WavPlugin::audioChannels( int ) { |
270 | debugMsg( "WavPlugin::audioChannels" ); | 272 | // qDebug( "WavPlugin::audioChannels" ); |
271 | return 2; // ### Always scale audio to stereo samples | 273 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
272 | } | 274 | } |
273 | 275 | ||
274 | 276 | ||
275 | int WavPlugin::audioFrequency( int ) { | 277 | int WavPlugin::audioFrequency( int ) { |
276 | debugMsg( "WavPlugin::audioFrequency" ); | 278 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); |
277 | return 44100; // ### Always scale to frequency of 44100 | 279 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | int WavPlugin::audioSamples( int ) { | 283 | int WavPlugin::audioSamples( int ) { |
282 | debugMsg( "WavPlugin::audioSamples" ); | 284 | // qDebug( "WavPlugin::audioSamples" ); |
283 | return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, | 285 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
284 | // Therefore if source is mono we will double the number of samples | 286 | // Therefore if source is mono we will double the number of samples |
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | bool WavPlugin::audioSetSample( long, int ) { | 290 | bool WavPlugin::audioSetSample( long, int ) { |
289 | debugMsg( "WavPlugin::audioSetSample" ); | 291 | // qDebug( "WavPlugin::audioSetSample" ); |
290 | return FALSE; | 292 | return FALSE; |
291 | } | 293 | } |
292 | 294 | ||
293 | 295 | ||
294 | long WavPlugin::audioGetSample( int ) { | 296 | long WavPlugin::audioGetSample( int ) { |
295 | debugMsg( "WavPlugin::audioGetSample" ); | 297 | // qDebug( "WavPlugin::audioGetSample" ); |
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
298 | 300 | ||
299 | /* | 301 | /* |
300 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 302 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
301 | debugMsg( "WavPlugin::audioReadSamples" ); | 303 | debugMsg( "WavPlugin::audioReadSamples" ); |
302 | return FALSE; | 304 | return FALSE; |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 308 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
307 | debugMsg( "WavPlugin::audioReReadSamples" ); | 309 | debugMsg( "WavPlugin::audioReReadSamples" ); |
308 | return FALSE; | 310 | return FALSE; |
309 | } | 311 | } |
310 | 312 | ||
311 | 313 | ||
312 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 314 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
313 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 315 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
314 | return !d->add( output, samples, samplesMade, FALSE ); | 316 | return !d->add( output, samples, samplesMade, FALSE ); |
315 | } | 317 | } |
316 | 318 | ||
317 | 319 | ||
318 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 320 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
319 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 321 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
320 | return !d->add( output, samples, samplesMade, TRUE ); | 322 | return !d->add( output, samples, samplesMade, TRUE ); |
321 | } | 323 | } |
322 | */ | 324 | */ |
323 | 325 | ||
324 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 326 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
325 | debugMsg( "WavPlugin::audioReadSamples" ); | 327 | // qDebug( "WavPlugin::audioReadSamples" ); |
326 | return d->add( output, samples, samplesMade, channels != 1 ); | 328 | return d->add( output, samples, samplesMade, channels != 1 ); |
327 | } | 329 | } |
328 | 330 | ||
329 | double WavPlugin::getTime() { | 331 | double WavPlugin::getTime() { |
330 | debugMsg( "WavPlugin::getTime" ); | 332 | // qDebug( "WavPlugin::getTime" ); |
331 | return 0.0; | 333 | return 0.0; |
332 | } | 334 | } |
333 | 335 | ||
336 | int WavPlugin::audioBitsPerSample( int ) { | ||
337 | // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | ||
338 | return d->chunkdata.wBitsPerSample; // | ||
339 | } | ||
340 | |||
334 | 341 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 64635ca..6afd67e 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h | |||
@@ -4,94 +4,104 @@ | |||
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 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #ifndef WAV_PLUGIN_H | 22 | #ifndef WAV_PLUGIN_H |
21 | #define WAV_PLUGIN_H | 23 | #define WAV_PLUGIN_H |
22 | 24 | ||
23 | 25 | ||
24 | #include <qstring.h> | 26 | #include <qstring.h> |
25 | #include <qapplication.h> | 27 | #include <qapplication.h> |
26 | #include "mediaplayerplugininterface.h" | 28 | #include "../mediaplayerplugininterface.h" |
29 | |||
30 | |||
31 | // #define OLD_MEDIAPLAYER_API | ||
27 | 32 | ||
28 | 33 | ||
29 | class WavPluginData; | 34 | class WavPluginData; |
30 | 35 | ||
31 | 36 | ||
32 | class WavPlugin : public MediaPlayerDecoder { | 37 | class WavPlugin : public MediaPlayerDecoder { |
33 | 38 | ||
34 | public: | 39 | public: |
35 | WavPlugin(); | 40 | WavPlugin(); |
36 | ~WavPlugin(); | 41 | ~WavPlugin(); |
37 | 42 | ||
38 | const char *pluginName() { return "WavPlugin"; } | 43 | const char *pluginName() { return "WavPlugin"; } |
39 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } | 44 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } |
40 | double pluginVersion() { return 1.0; } | 45 | double pluginVersion() { return 1.0; } |
41 | 46 | ||
42 | bool isFileSupported( const QString& ); | 47 | bool isFileSupported( const QString& ); |
43 | bool open( const QString& ); | 48 | bool open( const QString& ); |
44 | bool close(); | 49 | bool close(); |
45 | bool isOpen(); | 50 | bool isOpen(); |
46 | //const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } | 51 | const QString &fileInfo() { return strInfo = ""; } |
47 | const QString &fileInfo() { return strInfo = QString(""); } | ||
48 | 52 | ||
49 | // If decoder doesn't support audio then return 0 here | 53 | // If decoder doesn't support audio then return 0 here |
50 | int audioStreams(); | 54 | int audioStreams(); |
51 | int audioChannels( int stream ); | 55 | int audioChannels( int stream ); |
52 | int audioFrequency( int stream ); | 56 | int audioFrequency( int stream ); |
57 | int audioBitsPerSample( int stream ); | ||
53 | int audioSamples( int stream ); | 58 | int audioSamples( int stream ); |
54 | bool audioSetSample( long sample, int stream ); | 59 | bool audioSetSample( long sample, int stream ); |
55 | long audioGetSample( int stream ); | 60 | long audioGetSample( int stream ); |
56 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 61 | #ifdef OLD_MEDIAPLAYER_API |
57 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 62 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
63 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
64 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
65 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
66 | #else | ||
58 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 67 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
59 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); | 68 | #endif |
60 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
61 | 69 | ||
62 | // If decoder doesn't support video then return 0 here | 70 | // If decoder doesn't support video then return 0 here |
63 | int videoStreams() { return 0; } | 71 | int videoStreams() { return 0; } |
64 | int videoWidth( int ) { return 0; } | 72 | int videoWidth( int ) { return 0; } |
65 | int videoHeight( int ) { return 0; } | 73 | int videoHeight( int ) { return 0; } |
66 | double videoFrameRate( int ) { return 0.0; } | 74 | double videoFrameRate( int ) { return 0.0; } |
67 | int videoFrames( int ) { return 0; } | 75 | int videoFrames( int ) { return 0; } |
68 | bool videoSetFrame( long, int ) { return FALSE; } | 76 | bool videoSetFrame( long, int ) { return FALSE; } |
69 | long videoGetFrame( int ) { return 0; } | 77 | long videoGetFrame( int ) { return 0; } |
70 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 78 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
71 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 79 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
72 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 80 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
73 | 81 | ||
74 | // Profiling | 82 | // Profiling |
75 | double getTime(); | 83 | double getTime(); |
76 | 84 | ||
77 | // Ignore if these aren't supported | 85 | // Ignore if these aren't supported |
78 | bool setSMP( int ) { return FALSE; } | 86 | bool setSMP( int ) { return FALSE; } |
79 | bool setMMX( bool ) { return FALSE; } | 87 | bool setMMX( bool ) { return FALSE; } |
80 | 88 | ||
81 | // Capabilities | 89 | // Capabilities |
82 | bool supportsAudio() { return TRUE; } | 90 | bool supportsAudio() { return TRUE; } |
83 | bool supportsVideo() { return FALSE; } | 91 | bool supportsVideo() { return FALSE; } |
84 | bool supportsYUV() { return FALSE; } | 92 | bool supportsYUV() { return FALSE; } |
85 | bool supportsMMX() { return TRUE; } | 93 | bool supportsMMX() { return TRUE; } |
86 | bool supportsSMP() { return FALSE; } | 94 | bool supportsSMP() { return FALSE; } |
87 | bool supportsStereo() { return TRUE; } | 95 | bool supportsStereo() { return TRUE; } |
88 | bool supportsScaling() { return FALSE; } | 96 | bool supportsScaling() { return FALSE; } |
89 | 97 | ||
98 | long getPlayTime() { return -1; } | ||
99 | |||
90 | private: | 100 | private: |
91 | WavPluginData *d; | 101 | WavPluginData *d; |
92 | QString strInfo; | 102 | QString strInfo; |
93 | 103 | ||
94 | }; | 104 | }; |
95 | 105 | ||
96 | 106 | ||
97 | #endif | 107 | #endif |