author | ar <ar> | 2004-05-02 17:04:41 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:04:41 (UTC) |
commit | 4d3379027557e251201b531896974a69ae4c665a (patch) (unidiff) | |
tree | 6e813be1aa29131f8f8e91f532f38f8a381e38f4 /core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |
parent | f8add41b2e0b0371754521b44d95f87fa70a6ff2 (diff) | |
download | opie-4d3379027557e251201b531896974a69ae4c665a.zip opie-4d3379027557e251201b531896974a69ae4c665a.tar.gz opie-4d3379027557e251201b531896974a69ae4c665a.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'core/multimedia/opieplayer/wavplugin/wavplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 4e82900..7f3a0a8 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -16,19 +16,27 @@ | |||
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 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | |||
23 | #include "wavplugin.h" | ||
24 | |||
25 | /* OPIE */ | ||
26 | #include <opie2/odebug.h> | ||
27 | |||
28 | /* QT */ | ||
29 | #include <qfile.h> | ||
30 | |||
31 | /* STD */ | ||
22 | #include <stdio.h> | 32 | #include <stdio.h> |
23 | #include <stdarg.h> | 33 | #include <stdarg.h> |
24 | #include <stdlib.h> | 34 | #include <stdlib.h> |
25 | #include <errno.h> | 35 | #include <errno.h> |
26 | #include <unistd.h> | 36 | #include <unistd.h> |
27 | #include <qfile.h> | ||
28 | #include "wavplugin.h" | ||
29 | 37 | ||
30 | //#define debugMsg(a) qDebug(a) | 38 | //#define debugMsg(a) qDebug(a) |
31 | #define debugMsg(a) | 39 | #define debugMsg(a) |
32 | 40 | ||
33 | 41 | ||
34 | struct RiffChunk { | 42 | struct RiffChunk { |
@@ -73,20 +81,20 @@ public: | |||
73 | // expands out samples to the frequency of 44kHz //not any more | 81 | // expands out samples to the frequency of 44kHz //not any more |
74 | bool add( short *output, long count, long& done, bool stereo ) | 82 | bool add( short *output, long count, long& done, bool stereo ) |
75 | { | 83 | { |
76 | done = 0; | 84 | done = 0; |
77 | 85 | ||
78 | if ( input == 0 ) { | 86 | if ( input == 0 ) { |
79 | qDebug("no input"); | 87 | odebug << "no input" << oendl; |
80 | return FALSE; | 88 | return FALSE; |
81 | } | 89 | } |
82 | 90 | ||
83 | while ( count ) { | 91 | while ( count ) { |
84 | int l,r; | 92 | int l,r; |
85 | if ( getSample(l, r) == FALSE ) { | 93 | if ( getSample(l, r) == FALSE ) { |
86 | qDebug("didn't get sample"); | 94 | odebug << "didn't get sample" << oendl; |
87 | return FALSE; | 95 | return FALSE; |
88 | } | 96 | } |
89 | samples_due += chunkdata.samplesPerSec; | 97 | samples_due += chunkdata.samplesPerSec; |
90 | printf("samples due %d\r", samples_due); | 98 | printf("samples due %d\r", samples_due); |
91 | fflush(stdout); | 99 | fflush(stdout); |
92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 100 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
@@ -132,23 +140,23 @@ public: | |||
132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 140 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 141 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
134 | return FALSE; | 142 | return FALSE; |
135 | } | 143 | } |
136 | #define WAVE_FORMAT_PCM 1 | 144 | #define WAVE_FORMAT_PCM 1 |
137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 145 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 146 | odebug << "WAV file: UNSUPPORTED FORMAT " << chunkdata.formatTag << "" << oendl; |
139 | return FALSE; | 147 | return FALSE; |
140 | } | 148 | } |
141 | } else { | 149 | } else { |
142 | // ignored chunk | 150 | // ignored chunk |
143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 151 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
144 | return FALSE; | 152 | return FALSE; |
145 | } | 153 | } |
146 | } | 154 | } |
147 | } // while | 155 | } // while |
148 | qDebug("bits %d", chunkdata.wBitsPerSample); | 156 | odebug << "bits " << chunkdata.wBitsPerSample << "" << oendl; |
149 | return TRUE; | 157 | return TRUE; |
150 | } | 158 | } |
151 | 159 | ||
152 | 160 | ||
153 | // gets a sample from the file | 161 | // gets a sample from the file |
154 | bool getSample(int& l, int& r) | 162 | bool getSample(int& l, int& r) |
@@ -204,13 +212,13 @@ WavPlugin::~WavPlugin() { | |||
204 | close(); | 212 | close(); |
205 | delete d; | 213 | delete d; |
206 | } | 214 | } |
207 | 215 | ||
208 | 216 | ||
209 | bool WavPlugin::isFileSupported( const QString& path ) { | 217 | bool WavPlugin::isFileSupported( const QString& path ) { |
210 | // qDebug( "WavPlugin::isFileSupported" ); | 218 | // odebug << "WavPlugin::isFileSupported" << oendl; |
211 | 219 | ||
212 | char *ext = strrchr( path.latin1(), '.' ); | 220 | char *ext = strrchr( path.latin1(), '.' ); |
213 | 221 | ||
214 | // Test file extension | 222 | // Test file extension |
215 | if ( ext ) { | 223 | if ( ext ) { |
216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 224 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
@@ -223,21 +231,21 @@ bool WavPlugin::isFileSupported( const QString& path ) { | |||
223 | 231 | ||
224 | return FALSE; | 232 | return FALSE; |
225 | } | 233 | } |
226 | 234 | ||
227 | 235 | ||
228 | bool WavPlugin::open( const QString& path ) { | 236 | bool WavPlugin::open( const QString& path ) { |
229 | // qDebug( "WavPlugin::open" ); | 237 | // odebug << "WavPlugin::open" << oendl; |
230 | 238 | ||
231 | d->max = d->out = sound_buffer_size; | 239 | d->max = d->out = sound_buffer_size; |
232 | d->wavedata_remaining = 0; | 240 | d->wavedata_remaining = 0; |
233 | d->samples_due = 0; | 241 | d->samples_due = 0; |
234 | 242 | ||
235 | d->input = new QFile( path ); | 243 | d->input = new QFile( path ); |
236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 244 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
237 | qDebug("couldn't open file"); | 245 | odebug << "couldn't open file" << oendl; |
238 | delete d->input; | 246 | delete d->input; |
239 | d->input = 0; | 247 | d->input = 0; |
240 | return FALSE; | 248 | return FALSE; |
241 | } | 249 | } |
242 | 250 | ||
243 | d->initialise(); | 251 | d->initialise(); |
@@ -245,60 +253,60 @@ bool WavPlugin::open( const QString& path ) { | |||
245 | 253 | ||
246 | return TRUE; | 254 | return TRUE; |
247 | } | 255 | } |
248 | 256 | ||
249 | 257 | ||
250 | bool WavPlugin::close() { | 258 | bool WavPlugin::close() { |
251 | // qDebug( "WavPlugin::close" ); | 259 | // odebug << "WavPlugin::close" << oendl; |
252 | 260 | ||
253 | d->input->close(); | 261 | d->input->close(); |
254 | delete d->input; | 262 | delete d->input; |
255 | d->input = 0; | 263 | d->input = 0; |
256 | return TRUE; | 264 | return TRUE; |
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
260 | bool WavPlugin::isOpen() { | 268 | bool WavPlugin::isOpen() { |
261 | // qDebug( "WavPlugin::isOpen" ); | 269 | // odebug << "WavPlugin::isOpen" << oendl; |
262 | return ( d->input != 0 ); | 270 | return ( d->input != 0 ); |
263 | } | 271 | } |
264 | 272 | ||
265 | 273 | ||
266 | int WavPlugin::audioStreams() { | 274 | int WavPlugin::audioStreams() { |
267 | // qDebug( "WavPlugin::audioStreams" ); | 275 | // odebug << "WavPlugin::audioStreams" << oendl; |
268 | return 1; | 276 | return 1; |
269 | } | 277 | } |
270 | 278 | ||
271 | 279 | ||
272 | int WavPlugin::audioChannels( int ) { | 280 | int WavPlugin::audioChannels( int ) { |
273 | // qDebug( "WavPlugin::audioChannels" ); | 281 | // odebug << "WavPlugin::audioChannels" << oendl; |
274 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples | 282 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
275 | } | 283 | } |
276 | 284 | ||
277 | 285 | ||
278 | int WavPlugin::audioFrequency( int ) { | 286 | int WavPlugin::audioFrequency( int ) { |
279 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); | 287 | // odebug << "WavPlugin::audioFrequency " << d->chunkdata.samplesPerSec << "" << oendl; |
280 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 | 288 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
281 | } | 289 | } |
282 | 290 | ||
283 | 291 | ||
284 | int WavPlugin::audioSamples( int ) { | 292 | int WavPlugin::audioSamples( int ) { |
285 | // qDebug( "WavPlugin::audioSamples" ); | 293 | // odebug << "WavPlugin::audioSamples" << oendl; |
286 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, | 294 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
287 | // Therefore if source is mono we will double the number of samples | 295 | // Therefore if source is mono we will double the number of samples |
288 | } | 296 | } |
289 | 297 | ||
290 | 298 | ||
291 | bool WavPlugin::audioSetSample( long, int ) { | 299 | bool WavPlugin::audioSetSample( long, int ) { |
292 | // qDebug( "WavPlugin::audioSetSample" ); | 300 | // odebug << "WavPlugin::audioSetSample" << oendl; |
293 | return FALSE; | 301 | return FALSE; |
294 | } | 302 | } |
295 | 303 | ||
296 | 304 | ||
297 | long WavPlugin::audioGetSample( int ) { | 305 | long WavPlugin::audioGetSample( int ) { |
298 | // qDebug( "WavPlugin::audioGetSample" ); | 306 | // odebug << "WavPlugin::audioGetSample" << oendl; |
299 | return 0; | 307 | return 0; |
300 | } | 308 | } |
301 | 309 | ||
302 | /* | 310 | /* |
303 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 311 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
304 | debugMsg( "WavPlugin::audioReadSamples" ); | 312 | debugMsg( "WavPlugin::audioReadSamples" ); |
@@ -322,21 +330,21 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl | |||
322 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 330 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
323 | return !d->add( output, samples, samplesMade, TRUE ); | 331 | return !d->add( output, samples, samplesMade, TRUE ); |
324 | } | 332 | } |
325 | */ | 333 | */ |
326 | 334 | ||
327 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 335 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
328 | // qDebug( "WavPlugin::audioReadSamples" ); | 336 | // odebug << "WavPlugin::audioReadSamples" << oendl; |
329 | return d->add( output, samples, samplesMade, channels != 1 ); | 337 | return d->add( output, samples, samplesMade, channels != 1 ); |
330 | } | 338 | } |
331 | 339 | ||
332 | double WavPlugin::getTime() { | 340 | double WavPlugin::getTime() { |
333 | // qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! | 341 | // odebug << "WavPlugin::getTime" << oendl; //this is a stupid hack here!! |
334 | return d->chunkdata.wBitsPerSample; /*0.0*/; | 342 | return d->chunkdata.wBitsPerSample; /*0.0*/; |
335 | } | 343 | } |
336 | 344 | ||
337 | // int WavPlugin::audioBitsPerSample( int ) { | 345 | // int WavPlugin::audioBitsPerSample( int ) { |
338 | // // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | 346 | // // odebug << "WavPlugin::audioFormat " << d->chunkdata.wBitsPerSample << "" << oendl; |
339 | // return d->chunkdata.wBitsPerSample; // | 347 | // return d->chunkdata.wBitsPerSample; // |
340 | // } | 348 | // } |
341 | 349 | ||
342 | 350 | ||