summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/wavplugin
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/wavplugin') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/wavplugin/Makefile.in4
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp45
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.h24
3 files changed, 46 insertions, 27 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
@@ -97,13 +97,15 @@ REQUIRES=
97 97
98 98
99 99
100####### Compile 100####### Compile
101 101
102wavplugin.o: wavplugin.cpp \ 102wavplugin.o: wavplugin.cpp \
103 wavplugin.h 103 wavplugin.h \
104 ../mediaplayerplugininterface.h
104 105
105wavpluginimpl.o: wavpluginimpl.cpp \ 106wavpluginimpl.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
@@ -14,12 +14,14 @@
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>
@@ -44,13 +46,13 @@ struct ChunkData {
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
50const int sound_buffer_size = 4096; 52const int sound_buffer_size = 512; // 4096; // you got to be kidding right?
51 53
52 54
53class WavPluginData { 55class WavPluginData {
54public: 56public:
55 QFile *input; 57 QFile *input;
56 58
@@ -70,35 +72,35 @@ public:
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;
@@ -140,13 +142,13 @@ public:
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)
@@ -202,13 +204,13 @@ WavPlugin::~WavPlugin() {
202 close(); 204 close();
203 delete d; 205 delete d;
204} 206}
205 207
206 208
207bool WavPlugin::isFileSupported( const QString& path ) { 209bool 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 )
@@ -221,13 +223,13 @@ bool WavPlugin::isFileSupported( const QString& path ) {
221 223
222 return FALSE; 224 return FALSE;
223} 225}
224 226
225 227
226bool WavPlugin::open( const QString& path ) { 228bool 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 );
@@ -242,60 +244,60 @@ bool WavPlugin::open( const QString& path ) {
242 244
243 return TRUE; 245 return TRUE;
244} 246}
245 247
246 248
247bool WavPlugin::close() { 249bool 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
257bool WavPlugin::isOpen() { 259bool 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
263int WavPlugin::audioStreams() { 265int WavPlugin::audioStreams() {
264 debugMsg( "WavPlugin::audioStreams" ); 266// qDebug( "WavPlugin::audioStreams" );
265 return 1; 267 return 1;
266} 268}
267 269
268 270
269int WavPlugin::audioChannels( int ) { 271int 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
275int WavPlugin::audioFrequency( int ) { 277int 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
281int WavPlugin::audioSamples( int ) { 283int 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
288bool WavPlugin::audioSetSample( long, int ) { 290bool WavPlugin::audioSetSample( long, int ) {
289 debugMsg( "WavPlugin::audioSetSample" ); 291// qDebug( "WavPlugin::audioSetSample" );
290 return FALSE; 292 return FALSE;
291} 293}
292 294
293 295
294long WavPlugin::audioGetSample( int ) { 296long WavPlugin::audioGetSample( int ) {
295 debugMsg( "WavPlugin::audioGetSample" ); 297// qDebug( "WavPlugin::audioGetSample" );
296 return 0; 298 return 0;
297} 299}
298 300
299/* 301/*
300bool WavPlugin::audioReadSamples( short *, int, long, int ) { 302bool WavPlugin::audioReadSamples( short *, int, long, int ) {
301 debugMsg( "WavPlugin::audioReadSamples" ); 303 debugMsg( "WavPlugin::audioReadSamples" );
@@ -319,16 +321,21 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl
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
324bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { 326bool 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
329double WavPlugin::getTime() { 331double WavPlugin::getTime() {
330 debugMsg( "WavPlugin::getTime" ); 332// qDebug( "WavPlugin::getTime" );
331 return 0.0; 333 return 0.0;
332} 334}
333 335
336int 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
@@ -14,19 +14,24 @@
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
29class WavPluginData; 34class WavPluginData;
30 35
31 36
32class WavPlugin : public MediaPlayerDecoder { 37class WavPlugin : public MediaPlayerDecoder {
@@ -40,27 +45,30 @@ public:
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; }
@@ -84,12 +92,14 @@ public:
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
90private: 100private:
91 WavPluginData *d; 101 WavPluginData *d;
92 QString strInfo; 102 QString strInfo;
93 103
94}; 104};
95 105