summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/wavplugin/wavplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp50
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
@@ -19,13 +19,21 @@
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)
@@ -76,14 +84,14 @@ public:
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;
@@ -135,7 +143,7 @@ public:
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 {
@@ -145,7 +153,7 @@ public:
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
@@ -207,7 +215,7 @@ WavPlugin::~WavPlugin() {
207 215
208 216
209bool WavPlugin::isFileSupported( const QString& path ) { 217bool 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
@@ -226,7 +234,7 @@ bool WavPlugin::isFileSupported( const QString& path ) {
226 234
227 235
228bool WavPlugin::open( const QString& path ) { 236bool 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;
@@ -234,7 +242,7 @@ bool WavPlugin::open( const QString& path ) {
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;
@@ -248,7 +256,7 @@ bool WavPlugin::open( const QString& path ) {
248 256
249 257
250bool WavPlugin::close() { 258bool 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;
@@ -258,44 +266,44 @@ bool WavPlugin::close() {
258 266
259 267
260bool WavPlugin::isOpen() { 268bool 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
266int WavPlugin::audioStreams() { 274int WavPlugin::audioStreams() {
267// qDebug( "WavPlugin::audioStreams" ); 275// odebug << "WavPlugin::audioStreams" << oendl;
268 return 1; 276 return 1;
269} 277}
270 278
271 279
272int WavPlugin::audioChannels( int ) { 280int 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
278int WavPlugin::audioFrequency( int ) { 286int 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
284int WavPlugin::audioSamples( int ) { 292int 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
291bool WavPlugin::audioSetSample( long, int ) { 299bool 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
297long WavPlugin::audioGetSample( int ) { 305long WavPlugin::audioGetSample( int ) {
298// qDebug( "WavPlugin::audioGetSample" ); 306// odebug << "WavPlugin::audioGetSample" << oendl;
299 return 0; 307 return 0;
300} 308}
301 309
@@ -325,18 +333,18 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl
325*/ 333*/
326 334
327bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { 335bool 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
332double WavPlugin::getTime() { 340double 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