summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-02-25 01:35:47 (UTC)
committer llornkcor <llornkcor>2002-02-25 01:35:47 (UTC)
commitf180c1a5e8fc889ff1fb390d5cc94cdbc5085046 (patch) (unidiff)
tree5e9ea6f1313f4c33d57fb266523c1cfbe0826756 /core
parentc0446b55fc32b7fdea9f58db06e40da703f5e8ff (diff)
downloadopie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.zip
opie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.tar.gz
opie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.tar.bz2
fucked up- no workie.. back out
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/Makefile.in30
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp82
-rw-r--r--core/multimedia/opieplayer/audiodevice.h11
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp7
-rw-r--r--core/multimedia/opieplayer/audiowidget.h5
-rw-r--r--core/multimedia/opieplayer/libflash/libflashplugin.h4
-rw-r--r--core/multimedia/opieplayer/libflash/libflashpluginimpl.h3
-rw-r--r--core/multimedia/opieplayer/libflash/swf.h2
-rw-r--r--core/multimedia/opieplayer/libmad/Makefile.in2
-rw-r--r--core/multimedia/opieplayer/libmad/libmad.pro2
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.h5
-rw-r--r--core/multimedia/opieplayer/libmad/libmadpluginimpl.h5
-rw-r--r--core/multimedia/opieplayer/libmad/version.c0
-rw-r--r--core/multimedia/opieplayer/libmpeg3/Makefile.in6
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h5
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h4
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp38
-rw-r--r--core/multimedia/opieplayer/loopcontrol.h7
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp7
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.h5
-rw-r--r--core/multimedia/opieplayer/main.cpp7
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp5
-rw-r--r--core/multimedia/opieplayer/mediaplayer.h7
-rw-r--r--core/multimedia/opieplayer/mediaplayerplugininterface.h9
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp16
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h6
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp5
-rw-r--r--core/multimedia/opieplayer/playlistselection.h5
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp357
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h38
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp9
-rw-r--r--core/multimedia/opieplayer/videowidget.h5
-rw-r--r--core/multimedia/opieplayer/wavplugin/Makefile.in4
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp217
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.h6
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp1
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavpluginimpl.h3
37 files changed, 381 insertions, 549 deletions
diff --git a/core/multimedia/opieplayer/Makefile.in b/core/multimedia/opieplayer/Makefile.in
index 8d33fb4..1d2ff5e 100644
--- a/core/multimedia/opieplayer/Makefile.in
+++ b/core/multimedia/opieplayer/Makefile.in
@@ -133,30 +133,26 @@ REQUIRES=
133 133
134 134
135####### Compile 135####### Compile
136 136
137main.o: main.cpp \ 137main.o: main.cpp \
138 $(OPIEDIR)/include/qpe/qpeapplication.h \ 138 $(OPIEDIR)/include/qpe/qpeapplication.h \
139 $(OPIEDIR)/include/qpedecoration_qws.h \
140 $(OPIEDIR)/include/timestring.h \
141 mediaplayerstate.h \ 139 mediaplayerstate.h \
142 playlistwidget.h \ 140 playlistwidget.h \
143 $(OPIEDIR)/include/qpe/applnk.h \ 141 $(OPIEDIR)/include/qpe/applnk.h \
144 audiowidget.h \ 142 audiowidget.h \
145 videowidget.h \ 143 videowidget.h \
146 loopcontrol.h \ 144 loopcontrol.h \
147 mediaplayer.h \ 145 mediaplayer.h \
148 $(OPIEDIR)/include/qpe/qlibrary.h \ 146 $(OPIEDIR)/include/qpe/qlibrary.h \
149 $(OPIEDIR)/include/qpe/qcom.h \ 147 $(OPIEDIR)/include/qpe/qcom.h \
150 $(OPIEDIR)/include/qpe/quuid.h \ 148 $(OPIEDIR)/include/qpe/quuid.h
151 mediaplayerplugininterface.h
152 149
153loopcontrol.o: loopcontrol.cpp \ 150loopcontrol.o: loopcontrol.cpp \
154 $(OPIEDIR)/include/qpe/qpeapplication.h \ 151 $(OPIEDIR)/include/qpe/qpeapplication.h \
155 $(OPIEDIR)/include/qpedecoration_qws.h \ 152 $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \
156 $(OPIEDIR)/include/timestring.h \
157 loopcontrol.h \ 153 loopcontrol.h \
158 videowidget.h \ 154 videowidget.h \
159 audiodevice.h \ 155 audiodevice.h \
160 mediaplayerplugininterface.h \ 156 mediaplayerplugininterface.h \
161 $(OPIEDIR)/include/qpe/qcom.h \ 157 $(OPIEDIR)/include/qpe/qcom.h \
162 $(OPIEDIR)/include/qpe/quuid.h \ 158 $(OPIEDIR)/include/qpe/quuid.h \
@@ -166,78 +162,63 @@ playlistselection.o: playlistselection.cpp \
166 $(OPIEDIR)/include/qpe/applnk.h \ 162 $(OPIEDIR)/include/qpe/applnk.h \
167 $(OPIEDIR)/include/qpe/resource.h \ 163 $(OPIEDIR)/include/qpe/resource.h \
168 playlistselection.h 164 playlistselection.h
169 165
170mediaplayerstate.o: mediaplayerstate.cpp \ 166mediaplayerstate.o: mediaplayerstate.cpp \
171 $(OPIEDIR)/include/qpe/qpeapplication.h \ 167 $(OPIEDIR)/include/qpe/qpeapplication.h \
172 $(OPIEDIR)/include/qpedecoration_qws.h \
173 $(OPIEDIR)/include/timestring.h \
174 $(OPIEDIR)/include/qpe/qlibrary.h \ 168 $(OPIEDIR)/include/qpe/qlibrary.h \
175 $(OPIEDIR)/include/qpe/qcom.h \ 169 $(OPIEDIR)/include/qpe/qcom.h \
176 $(OPIEDIR)/include/qpe/quuid.h \ 170 $(OPIEDIR)/include/qpe/quuid.h \
177 $(OPIEDIR)/include/qpe/config.h \ 171 $(OPIEDIR)/include/qpe/config.h \
178 mediaplayerplugininterface.h \
179 mediaplayerstate.h \ 172 mediaplayerstate.h \
180 libmad/libmadpluginimpl.h \ 173 libmad/libmadpluginimpl.h \
181 libmpeg3/libmpeg3pluginimpl.h \ 174 libmpeg3/libmpeg3pluginimpl.h \
182 wavplugin/wavpluginimpl.h 175 wavplugin/wavpluginimpl.h
183 176
184videowidget.o: videowidget.cpp \ 177videowidget.o: videowidget.cpp \
185 $(OPIEDIR)/include/qpe/resource.h \ 178 $(OPIEDIR)/include/qpe/resource.h \
186 mediaplayerplugininterface.h \
187 $(OPIEDIR)/include/qpe/qcom.h \
188 $(OPIEDIR)/include/qpe/quuid.h \
189 videowidget.h \ 179 videowidget.h \
190 mediaplayerstate.h 180 mediaplayerstate.h
191 181
192audiowidget.o: audiowidget.cpp \ 182audiowidget.o: audiowidget.cpp \
193 $(OPIEDIR)/include/qpe/resource.h \ 183 $(OPIEDIR)/include/qpe/resource.h \
194 audiowidget.h \ 184 audiowidget.h \
195 mediaplayerstate.h 185 mediaplayerstate.h
196 186
197playlistwidget.o: playlistwidget.cpp \ 187playlistwidget.o: playlistwidget.cpp \
198 $(OPIEDIR)/include/qpe/qpemenubar.h \ 188 $(OPIEDIR)/include/qpe/qpemenubar.h \
199 $(OPIEDIR)/include/qpe/qpetoolbar.h \ 189 $(OPIEDIR)/include/qpe/qpetoolbar.h \
200 $(OPIEDIR)/include/qpe/fileselector.h \ 190 $(OPIEDIR)/include/qpe/fileselector.h \
201 $(OPIEDIR)/include/filemanager.h \
202 $(OPIEDIR)/include/applnk.h \
203 $(OPIEDIR)/include/qpe/qpeapplication.h \
204 $(OPIEDIR)/include/qpedecoration_qws.h \
205 $(OPIEDIR)/include/timestring.h \
206 $(OPIEDIR)/include/qpe/applnk.h \ 191 $(OPIEDIR)/include/qpe/applnk.h \
207 $(OPIEDIR)/include/qpe/config.h \ 192 $(OPIEDIR)/include/qpe/config.h \
208 $(OPIEDIR)/include/qpe/global.h \ 193 $(OPIEDIR)/include/qpe/global.h \
209 $(OPIEDIR)/include/qpe/resource.h \ 194 $(OPIEDIR)/include/qpe/resource.h \
210 playlistselection.h \ 195 playlistselection.h \
211 playlistwidget.h \ 196 playlistwidget.h \
212 mediaplayerstate.h 197 mediaplayerstate.h
213 198
214mediaplayer.o: mediaplayer.cpp \ 199mediaplayer.o: mediaplayer.cpp \
215 $(OPIEDIR)/include/qpe/qpeapplication.h \ 200 $(OPIEDIR)/include/qpe/qpeapplication.h \
216 $(OPIEDIR)/include/qpedecoration_qws.h \
217 $(OPIEDIR)/include/timestring.h \
218 $(OPIEDIR)/include/qpe/qlibrary.h \ 201 $(OPIEDIR)/include/qpe/qlibrary.h \
219 $(OPIEDIR)/include/qpe/qcom.h \ 202 $(OPIEDIR)/include/qpe/qcom.h \
220 $(OPIEDIR)/include/qpe/quuid.h \ 203 $(OPIEDIR)/include/qpe/quuid.h \
221 $(OPIEDIR)/include/qpe/resource.h \ 204 $(OPIEDIR)/include/qpe/resource.h \
222 $(OPIEDIR)/include/qpe/config.h \ 205 $(OPIEDIR)/include/qpe/config.h \
223 mediaplayer.h \ 206 mediaplayer.h \
224 mediaplayerplugininterface.h \
225 playlistwidget.h \ 207 playlistwidget.h \
226 $(OPIEDIR)/include/qpe/applnk.h \ 208 $(OPIEDIR)/include/qpe/applnk.h \
227 audiowidget.h \ 209 audiowidget.h \
228 loopcontrol.h \ 210 loopcontrol.h \
229 audiodevice.h \ 211 audiodevice.h \
230 mediaplayerstate.h 212 mediaplayerstate.h
231 213
232audiodevice.o: audiodevice.cpp \ 214audiodevice.o: audiodevice.cpp \
233 $(OPIEDIR)/include/qpe/qpeapplication.h \ 215 $(OPIEDIR)/include/qpe/qpeapplication.h \
234 $(OPIEDIR)/include/qpedecoration_qws.h \
235 $(OPIEDIR)/include/timestring.h \
236 $(OPIEDIR)/include/qpe/config.h \ 216 $(OPIEDIR)/include/qpe/config.h \
237 audiodevice.h 217 audiodevice.h \
218 $(OPIEDIR)/include/qpe/qcopenvelope_qws.h
238 219
239moc_loopcontrol.o: moc_loopcontrol.cpp \ 220moc_loopcontrol.o: moc_loopcontrol.cpp \
240 loopcontrol.h 221 loopcontrol.h
241 222
242moc_playlistselection.o: moc_playlistselection.cpp \ 223moc_playlistselection.o: moc_playlistselection.cpp \
243 playlistselection.h \ 224 playlistselection.h \
@@ -257,14 +238,13 @@ moc_playlistwidget.o: moc_playlistwidget.cpp \
257 $(OPIEDIR)/include/qpe/applnk.h 238 $(OPIEDIR)/include/qpe/applnk.h
258 239
259moc_mediaplayer.o: moc_mediaplayer.cpp \ 240moc_mediaplayer.o: moc_mediaplayer.cpp \
260 mediaplayer.h \ 241 mediaplayer.h \
261 $(OPIEDIR)/include/qpe/qlibrary.h \ 242 $(OPIEDIR)/include/qpe/qlibrary.h \
262 $(OPIEDIR)/include/qpe/qcom.h \ 243 $(OPIEDIR)/include/qpe/qcom.h \
263 $(OPIEDIR)/include/qpe/quuid.h \ 244 $(OPIEDIR)/include/qpe/quuid.h
264 mediaplayerplugininterface.h
265 245
266moc_audiodevice.o: moc_audiodevice.cpp \ 246moc_audiodevice.o: moc_audiodevice.cpp \
267 audiodevice.h 247 audiodevice.h
268 248
269moc_loopcontrol.cpp: loopcontrol.h 249moc_loopcontrol.cpp: loopcontrol.h
270 $(MOC) loopcontrol.h -o moc_loopcontrol.cpp 250 $(MOC) loopcontrol.h -o moc_loopcontrol.cpp
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 11fd9e8..7b3700a 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,17 +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 better error code Fri 02-15-2002 14:37:47
21
22 20
23#include <stdlib.h> 21#include <stdlib.h>
24#include <stdio.h>
25#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 23#include <qpe/config.h>
27#include "audiodevice.h" 24#include "audiodevice.h"
28 25
29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 26#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
30#include "qpe/qcopenvelope_qws.h" 27#include "qpe/qcopenvelope_qws.h"
@@ -106,24 +103,23 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
106 formatData.nBlockAlign = 4; 103 formatData.nBlockAlign = 4;
107 formatData.nChannels = 2; 104 formatData.nChannels = 2;
108 formatData.nSamplesPerSec = 44000; 105 formatData.nSamplesPerSec = 44000;
109 formatData.wBitsPerSample = 16; 106 formatData.wBitsPerSample = 16;
110 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 107 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
111 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) 108 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
112// qDebug( "get volume of audio device failed" ); 109 qDebug( "get volume of audio device failed" );
113 waveOutClose( handle ); 110 waveOutClose( handle );
114 leftVolume = volume & 0xFFFF; 111 leftVolume = volume & 0xFFFF;
115 rightVolume = volume >> 16; 112 rightVolume = volume >> 16;
116#else 113#else
117 int mixerHandle = open( "/dev/mixer", O_RDWR ); 114 int mixerHandle = open( "/dev/mixer", O_RDWR );
118 if ( mixerHandle >= 0 ) { 115 if ( mixerHandle >= 0 ) {
119 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 116 ioctl( mixerHandle, MIXER_READ(0), &volume );
120 perror("ioctl(\"MIXER_READ\")");
121 close( mixerHandle ); 117 close( mixerHandle );
122 } else 118 } else
123 perror("open(\"/dev/mixer\")"); 119 qDebug( "get volume of audio device failed" );
124 leftVolume = ((volume & 0x00FF) << 16) / 101; 120 leftVolume = ((volume & 0x00FF) << 16) / 101;
125 rightVolume = ((volume & 0xFF00) << 8) / 101; 121 rightVolume = ((volume & 0xFF00) << 8) / 101;
126#endif 122#endif
127} 123}
128 124
129 125
@@ -148,29 +144,27 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
148 formatData.nChannels = 2; 144 formatData.nChannels = 2;
149 formatData.nSamplesPerSec = 44000; 145 formatData.nSamplesPerSec = 44000;
150 formatData.wBitsPerSample = 16; 146 formatData.wBitsPerSample = 16;
151 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 147 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
152 unsigned int volume = (rightVolume << 16) | leftVolume; 148 unsigned int volume = (rightVolume << 16) | leftVolume;
153 if ( waveOutSetVolume( handle, volume ) ) 149 if ( waveOutSetVolume( handle, volume ) )
154// qDebug( "set volume of audio device failed" ); 150 qDebug( "set volume of audio device failed" );
155 waveOutClose( handle ); 151 waveOutClose( handle );
156#else 152#else
157 // Volume can be from 0 to 100 which is 101 distinct values 153 // Volume can be from 0 to 100 which is 101 distinct values
158 unsigned int rV = (rightVolume * 101) >> 16; 154 unsigned int rV = (rightVolume * 101) >> 16;
159 155
160# if 0 156# if 0
161 unsigned int lV = (leftVolume * 101) >> 16; 157 unsigned int lV = (leftVolume * 101) >> 16;
162 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 158 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
163 int mixerHandle = 0; 159 int mixerHandle = 0;
164 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 160 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
165 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 161 ioctl( mixerHandle, MIXER_WRITE(0), &volume );
166 perror("ioctl(\"MIXER_WRITE\")");
167 close( mixerHandle ); 162 close( mixerHandle );
168 } else 163 } else
169 perror("open(\"/dev/mixer\")"); 164 qDebug( "set volume of audio device failed" );
170
171# else 165# else
172 // This is the way this has to be done now I guess, doesn't allow for 166 // This is the way this has to be done now I guess, doesn't allow for
173 // independant right and left channel setting, or setting for different outputs 167 // independant right and left channel setting, or setting for different outputs
174 Config cfg("Sound"); 168 Config cfg("Sound");
175 cfg.setGroup("System"); 169 cfg.setGroup("System");
176 cfg.writeEntry("Volume",(int)rV); 170 cfg.writeEntry("Volume",(int)rV);
@@ -189,53 +183,74 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
189 183
190AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 184AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
191 d = new AudioDevicePrivate; 185 d = new AudioDevicePrivate;
192 d->frequency = f; 186 d->frequency = f;
193 d->channels = chs; 187 d->channels = chs;
194 d->bytesPerSample = bps; 188 d->bytesPerSample = bps;
195// qDebug("%d",bps);
196 int format=0;
197 if( bps == 8) format = AFMT_U8;
198 else if( bps <= 0) format = AFMT_S16_LE;
199 else format = AFMT_S16_LE;
200 189
201// qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 190 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 191
192#ifdef Q_OS_WIN32
193 UINT result;
194 WAVEFORMATEX formatData;
195 formatData.cbSize = sizeof(WAVEFORMATEX);
196/*
197 // Other possible formats windows supports
198 formatData.wFormatTag = WAVE_FORMAT_MPEG;
199 formatData.wFormatTag = WAVE_FORMAT_MPEGLAYER3;
200 formatData.wFormatTag = WAVE_FORMAT_ADPCM;
201*/
202 formatData.wFormatTag = WAVE_FORMAT_PCM;
203 formatData.nAvgBytesPerSec = bps * chs * f;
204 formatData.nBlockAlign = bps * chs;
205 formatData.nChannels = chs;
206 formatData.nSamplesPerSec = f;
207 formatData.wBitsPerSample = bps * 8;
208 // Open a waveform device for output
209 if (result = waveOutOpen((LPHWAVEOUT)&d->handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL)) {
210 QString errorMsg = "error opening audio device.\nReason: %i - ";
211 switch (result) {
212 case MMSYSERR_ALLOCATED:errorMsg += "Specified resource is already allocated."; break;
213 case MMSYSERR_BADDEVICEID:errorMsg += "Specified device identifier is out of range."; break;
214 case MMSYSERR_NODRIVER:errorMsg += "No device driver is present."; break;
215 case MMSYSERR_NOMEM:errorMsg += "Unable to allocate or lock memory."; break;
216 case WAVERR_BADFORMAT:errorMsg += "Attempted to open with an unsupported waveform-audio format."; break;
217 case WAVERR_SYNC: errorMsg += "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag."; break;
218 default: errorMsg += "Undefined error"; break;
219 }
220 qDebug( errorMsg, result );
221 }
222
223 d->bufferSize = sound_fragment_bytes;
224#else
204 225
205 int fragments = 0x10000 * 8 + sound_fragment_shift; 226 int fragments = 0x10000 * 8 + sound_fragment_shift;
227 int format = AFMT_S16_LE;
206 int capabilities = 0; 228 int capabilities = 0;
207 229
208#ifdef KEEP_DEVICE_OPEN 230#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 231 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 232#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 233 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 234 qDebug( "error opening audio device /dev/dsp, sending data to /dev/null instead" );
213 d->handle = ::open( "/dev/null", O_WRONLY ); 235 d->handle = ::open( "/dev/null", O_WRONLY );
214 } 236 }
215#ifdef KEEP_DEVICE_OPEN 237#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 238 AudioDevicePrivate::dspFd = d->handle;
217 } else { 239 } else {
218 d->handle = AudioDevicePrivate::dspFd; 240 d->handle = AudioDevicePrivate::dspFd;
219 } 241 }
220#endif 242#endif
221 243
222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 244 ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities );
223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 245 ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments );
224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 246 ioctl( d->handle, SNDCTL_DSP_SETFMT, &format );
225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 247 ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency );
226 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
227 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
228 qDebug("freq %d", d->frequency);
229 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
230 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
231 qDebug("channels %d",d->channels);
232 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 248 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
233 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 249 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
234 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 250 ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels );
235 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
236 } 251 }
237 252
238 d->bufferSize = sound_fragment_bytes; 253 d->bufferSize = sound_fragment_bytes;
239 d->unwrittenBuffer = new char[d->bufferSize]; 254 d->unwrittenBuffer = new char[d->bufferSize];
240 d->unwritten = 0; 255 d->unwritten = 0;
241 d->can_GETOSPACE = TRUE; // until we find otherwise 256 d->can_GETOSPACE = TRUE; // until we find otherwise
@@ -243,12 +258,13 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
243 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 258 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
244 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 259 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
245 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 260 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
246 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 261 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
247 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 262 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
248 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 263 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
264#endif
249} 265}
250 266
251 267
252AudioDevice::~AudioDevice() { 268AudioDevice::~AudioDevice() {
253#ifdef Q_OS_WIN32 269#ifdef Q_OS_WIN32
254 waveOutClose( (HWAVEOUT)d->handle ); 270 waveOutClose( (HWAVEOUT)d->handle );
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h
index dcd79fe..ec70788 100644
--- a/core/multimedia/opieplayer/audiodevice.h
+++ b/core/multimedia/opieplayer/audiodevice.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,30 +14,25 @@
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
22
23#ifndef AUDIODEVICE_H 20#ifndef AUDIODEVICE_H
24#define AUDIODEVICE_H 21#define AUDIODEVICE_H
25 22
26
27#include <qobject.h> 23#include <qobject.h>
28#include <sys/soundcard.h>
29 24
30 25
31class AudioDevicePrivate; 26class AudioDevicePrivate;
32 27
33 28
34class AudioDevice : public QObject { 29class AudioDevice : public QObject {
35 Q_OBJECT 30 Q_OBJECT
36public: 31public:
37 AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE ); 32 AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 );
38 ~AudioDevice(); 33 ~AudioDevice();
39 34
40 unsigned int canWrite() const; 35 unsigned int canWrite() const;
41 void write( char *buffer, unsigned int length ); 36 void write( char *buffer, unsigned int length );
42 int bytesWritten(); 37 int bytesWritten();
43 38
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 0d88591..1e0757f 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -23,13 +23,12 @@
23#include <qpainter.h> 23#include <qpainter.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include "audiowidget.h" 26#include "audiowidget.h"
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29
30extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
31 30
32 31
33static const int xo = -2; // movable x offset 32static const int xo = -2; // movable x offset
34static const int yo = 22; // movable y offset 33static const int yo = 22; // movable y offset
35 34
@@ -58,13 +57,13 @@ MediaButton audioButtons[] = {
58static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 57static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
59 58
60 59
61AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 60AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
62 QWidget( parent, name, f ) 61 QWidget( parent, name, f )
63{ 62{
64 setCaption( tr("OpiePlayer") ); 63 setCaption( tr("MediaPlayer") );
65 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 64 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
66 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); 65 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
67 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); 66 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
68 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); 67 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) );
69 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); 68 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) );
70 69
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index 4b82a91..95f5322 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -17,13 +17,12 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef AUDIO_WIDGET_H 20#ifndef AUDIO_WIDGET_H
21#define AUDIO_WIDGET_H 21#define AUDIO_WIDGET_H
22 22
23
24#include <qwidget.h> 23#include <qwidget.h>
25#include <qpainter.h> 24#include <qpainter.h>
26#include <qdrawutil.h> 25#include <qdrawutil.h>
27#include <qpixmap.h> 26#include <qpixmap.h>
28#include <qstring.h> 27#include <qstring.h>
29#include <qslider.h> 28#include <qslider.h>
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.h b/core/multimedia/opieplayer/libflash/libflashplugin.h
index a2f1c42..48b512f 100644
--- a/core/multimedia/opieplayer/libflash/libflashplugin.h
+++ b/core/multimedia/opieplayer/libflash/libflashplugin.h
@@ -21,14 +21,13 @@
21#define LIBFLASH_PLUGIN_H 21#define LIBFLASH_PLUGIN_H
22 22
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qapplication.h> 25#include <qapplication.h>
26#include "flash.h" 26#include "flash.h"
27//#include <qpe/mediaplayerplugininterface.h> 27#include <qpe/mediaplayerplugininterface.h>
28#include "../mediaplayerplugininterface.h"
29 28
30 29
31class LibFlashPlugin : public MediaPlayerDecoder { 30class LibFlashPlugin : public MediaPlayerDecoder {
32 31
33public: 32public:
34 LibFlashPlugin(); 33 LibFlashPlugin();
@@ -46,13 +45,12 @@ public:
46 45
47 // If decoder doesn't support audio then return 0 here 46 // If decoder doesn't support audio then return 0 here
48 int audioStreams() { return 1; } 47 int audioStreams() { return 1; }
49 int audioChannels( int /*stream*/ ) { return 2; } 48 int audioChannels( int /*stream*/ ) { return 2; }
50 int audioFrequency( int /*stream*/ ) { return 44100; } 49 int audioFrequency( int /*stream*/ ) { return 44100; }
51 int audioSamples( int /*stream*/ ) { return 1000000; } 50 int audioSamples( int /*stream*/ ) { return 1000000; }
52int audioBitsPerSample(int) { return 0;}
53 bool audioSetSample( long sample, int stream ); 51 bool audioSetSample( long sample, int stream );
54 long audioGetSample( int stream ); 52 long audioGetSample( int stream );
55 //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 53 //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
56 //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 54 //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
57 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); 55 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
58 //bool audioReadSamples( short *output, int channel, long samples, int stream ); 56 //bool audioReadSamples( short *output, int channel, long samples, int stream );
diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
index cb8d959..33d8ad2 100644
--- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
+++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
@@ -18,14 +18,13 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIBFLASH_PLUGIN_IMPL_H 20#ifndef LIBFLASH_PLUGIN_IMPL_H
21#define LIBFLASH_PLUGIN_IMPL_H 21#define LIBFLASH_PLUGIN_IMPL_H
22 22
23 23
24//#include <qpe/mediaplayerplugininterface.h> 24#include <qpe/mediaplayerplugininterface.h>
25#include "../mediaplayerplugininterface.h"
26 25
27 26
28class LibFlashPlugin; 27class LibFlashPlugin;
29 28
30 29
31class LibFlashPluginImpl : public MediaPlayerPluginInterface 30class LibFlashPluginImpl : public MediaPlayerPluginInterface
diff --git a/core/multimedia/opieplayer/libflash/swf.h b/core/multimedia/opieplayer/libflash/swf.h
index 48986cc..5f5e4f7 100644
--- a/core/multimedia/opieplayer/libflash/swf.h
+++ b/core/multimedia/opieplayer/libflash/swf.h
@@ -205,13 +205,13 @@ struct FlashMovie;
205 205
206extern "C" { 206extern "C" {
207#include "jpeglib.h" 207#include "jpeglib.h"
208}; 208};
209extern "C" { 209extern "C" {
210//#include "zlib.h" 210//#include "zlib.h"
211#include "/opt/qt-2.3.2-embedded/src/3rdparty/zlib/zlib.h" 211#include "../src/3rdparty/zlib/zlib.h"
212}; 212};
213 213
214#include "graphic.h" 214#include "graphic.h"
215#include "character.h" 215#include "character.h"
216#include "bitmap.h" 216#include "bitmap.h"
217#include "shape.h" 217#include "shape.h"
diff --git a/core/multimedia/opieplayer/libmad/Makefile.in b/core/multimedia/opieplayer/libmad/Makefile.in
index 552043c..e9f74e7 100644
--- a/core/multimedia/opieplayer/libmad/Makefile.in
+++ b/core/multimedia/opieplayer/libmad/Makefile.in
@@ -211,15 +211,13 @@ layer3.o: layer3.c \
211huffman.o: huffman.c \ 211huffman.o: huffman.c \
212 libmad_global.h \ 212 libmad_global.h \
213 huffman.h 213 huffman.h
214 214
215libmadplugin.o: libmadplugin.cpp \ 215libmadplugin.o: libmadplugin.cpp \
216 libmadplugin.h \ 216 libmadplugin.h \
217 ../mediaplayerplugininterface.h \
218 mad.h 217 mad.h
219 218
220libmadpluginimpl.o: libmadpluginimpl.cpp \ 219libmadpluginimpl.o: libmadpluginimpl.cpp \
221 libmadplugin.h \ 220 libmadplugin.h \
222 ../mediaplayerplugininterface.h \
223 libmadpluginimpl.h 221 libmadpluginimpl.h
224 222
225 223
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro
index b54ca6b..6c40a15 100644
--- a/core/multimedia/opieplayer/libmad/libmad.pro
+++ b/core/multimedia/opieplayer/libmad/libmad.pro
@@ -5,10 +5,8 @@ HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h de
5SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ 5SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \
6 layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp 6 layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp
7TARGET = madplugin 7TARGET = madplugin
8DESTDIR = ../../plugins/codecs 8DESTDIR = ../../plugins/codecs
9INCLUDEPATH += $(OPIEDIR)/include .. 9INCLUDEPATH += $(OPIEDIR)/include ..
10DEPENDPATH += ../$(OPIEDIR)/include .. 10DEPENDPATH += ../$(OPIEDIR)/include ..
11TMAKE_CFLAGS += -DFPM_64BIT
12TMAKE_CXXFLAGS += -DFPM_64BIT
13LIBS += -lqpe -lm 11LIBS += -lqpe -lm
14VERSION = 1.0.0 12VERSION = 1.0.0
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h
index ff84c27..d85e0d4 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.h
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.h
@@ -17,16 +17,14 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIBMAD_PLUGIN_H 20#ifndef LIBMAD_PLUGIN_H
21#define LIBMAD_PLUGIN_H 21#define LIBMAD_PLUGIN_H
22 22
23
24#include <qstring.h> 23#include <qstring.h>
25//#include <qpe/mediaplayerplugininterface.h> 24#include <qpe/mediaplayerplugininterface.h>
26#include "../mediaplayerplugininterface.h"
27 25
28 26
29// #define OLD_MEDIAPLAYER_API 27// #define OLD_MEDIAPLAYER_API
30 28
31 29
32class LibMadPluginData; 30class LibMadPluginData;
@@ -51,13 +49,12 @@ public:
51 // If decoder doesn't support audio then return 0 here 49 // If decoder doesn't support audio then return 0 here
52 int audioStreams(); 50 int audioStreams();
53 int audioChannels( int stream ); 51 int audioChannels( int stream );
54 int audioFrequency( int stream ); 52 int audioFrequency( int stream );
55 int audioSamples( int stream ); 53 int audioSamples( int stream );
56 bool audioSetSample( long sample, int stream ); 54 bool audioSetSample( long sample, int stream );
57 int audioBitsPerSample(int) {return 0;}
58 long audioGetSample( int stream ); 55 long audioGetSample( int stream );
59#ifdef OLD_MEDIAPLAYER_API 56#ifdef OLD_MEDIAPLAYER_API
60 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 57 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
61 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 58 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
62 bool audioReadSamples( short *output, int channel, long samples, int stream ); 59 bool audioReadSamples( short *output, int channel, long samples, int stream );
63 bool audioReReadSamples( short *output, int channel, long samples, int stream ); 60 bool audioReReadSamples( short *output, int channel, long samples, int stream );
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
index 8ad4956..2c5ed3b 100644
--- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
+++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
@@ -17,15 +17,13 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIBMAD_PLUGIN_IMPL_H 20#ifndef LIBMAD_PLUGIN_IMPL_H
21#define LIBMAD_PLUGIN_IMPL_H 21#define LIBMAD_PLUGIN_IMPL_H
22 22
23 23#include <qpe/mediaplayerplugininterface.h>
24//#include <qpe/mediaplayerplugininterface.h>
25#include "../mediaplayerplugininterface.h"
26 24
27 25
28class LibMadPlugin; 26class LibMadPlugin;
29 27
30 28
31class LibMadPluginImpl : public MediaPlayerPluginInterface 29class LibMadPluginImpl : public MediaPlayerPluginInterface
@@ -40,12 +38,13 @@ public:
40 Q_REFCOUNT 38 Q_REFCOUNT
41 39
42#endif 40#endif
43 41
44 virtual MediaPlayerDecoder *decoder(); 42 virtual MediaPlayerDecoder *decoder();
45 virtual MediaPlayerEncoder *encoder(); 43 virtual MediaPlayerEncoder *encoder();
44
46private: 45private:
47 LibMadPlugin *libmadplugin; 46 LibMadPlugin *libmadplugin;
48 ulong ref; 47 ulong ref;
49}; 48};
50 49
51 50
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c
index 1baba26..413d54b 100644
--- a/core/multimedia/opieplayer/libmad/version.c
+++ b/core/multimedia/opieplayer/libmad/version.c
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in
index d255e4f..154f85d 100644
--- a/core/multimedia/opieplayer/libmpeg3/Makefile.in
+++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in
@@ -173,14 +173,13 @@ libmpeg3plugin.o: libmpeg3plugin.cpp \
173 mpeg3io.h \ 173 mpeg3io.h \
174 mpeg3css.h \ 174 mpeg3css.h \
175 mpeg3private.inc \ 175 mpeg3private.inc \
176 audio/mpeg3audio.h \ 176 audio/mpeg3audio.h \
177 mpeg3vtrack.h \ 177 mpeg3vtrack.h \
178 video/mpeg3video.h \ 178 video/mpeg3video.h \
179 mpeg3protos.h \ 179 mpeg3protos.h
180 ../mediaplayerplugininterface.h
181 180
182libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ 181libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \
183 libmpeg3plugin.h \ 182 libmpeg3plugin.h \
184 libmpeg3.h \ 183 libmpeg3.h \
185 mpeg3private.h \ 184 mpeg3private.h \
186 mpeg3atrack.h \ 185 mpeg3atrack.h \
@@ -190,13 +189,12 @@ libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \
190 mpeg3css.h \ 189 mpeg3css.h \
191 mpeg3private.inc \ 190 mpeg3private.inc \
192 audio/mpeg3audio.h \ 191 audio/mpeg3audio.h \
193 mpeg3vtrack.h \ 192 mpeg3vtrack.h \
194 video/mpeg3video.h \ 193 video/mpeg3video.h \
195 mpeg3protos.h \ 194 mpeg3protos.h \
196 ../mediaplayerplugininterface.h \
197 libmpeg3pluginimpl.h 195 libmpeg3pluginimpl.h
198 196
199bitstream.o: bitstream.c \ 197bitstream.o: bitstream.c \
200 mpeg3private.h \ 198 mpeg3private.h \
201 mpeg3atrack.h \ 199 mpeg3atrack.h \
202 mpeg3demux.h \ 200 mpeg3demux.h \
@@ -413,13 +411,13 @@ audio/layer2.o: audio/layer2.c \
413 mpeg3vtrack.h \ 411 mpeg3vtrack.h \
414 video/mpeg3video.h \ 412 video/mpeg3video.h \
415 audio/../mpeg3protos.h \ 413 audio/../mpeg3protos.h \
416 audio/tables.h 414 audio/tables.h
417 415
418audio/layer3.o: audio/layer3.c \ 416audio/layer3.o: audio/layer3.c \
419 huffman.h \ 417 audio/huffman.h \
420 audio/mpeg3audio.h \ 418 audio/mpeg3audio.h \
421 audio/ac3.h \ 419 audio/ac3.h \
422 audio/mpeg3real.h \ 420 audio/mpeg3real.h \
423 audio/../bitstream.h \ 421 audio/../bitstream.h \
424 mpeg3demux.h \ 422 mpeg3demux.h \
425 mpeg3title.h \ 423 mpeg3title.h \
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
index 54f259b..e0eb930 100644
--- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
@@ -17,19 +17,17 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIBMPEG3_PLUGIN_H 20#ifndef LIBMPEG3_PLUGIN_H
21#define LIBMPEG3_PLUGIN_H 21#define LIBMPEG3_PLUGIN_H
22 22
23
24#include <qstring.h> 23#include <qstring.h>
25#include <qapplication.h> 24#include <qapplication.h>
26#include "libmpeg3.h" 25#include "libmpeg3.h"
27#include "mpeg3protos.h" 26#include "mpeg3protos.h"
28//#include <qpe/mediaplayerplugininterface.h> 27#include <qpe/mediaplayerplugininterface.h>
29#include "../mediaplayerplugininterface.h"
30 28
31 29
32// #define OLD_MEDIAPLAYER_API 30// #define OLD_MEDIAPLAYER_API
33 31
34 32
35class LibMpeg3Plugin : public MediaPlayerDecoder { 33class LibMpeg3Plugin : public MediaPlayerDecoder {
@@ -49,13 +47,12 @@ public:
49 const QString &fileInfo() { return strInfo = ""; } 47 const QString &fileInfo() { return strInfo = ""; }
50 48
51 // If decoder doesn't support audio then return 0 here 49 // If decoder doesn't support audio then return 0 here
52 int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } 50 int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; }
53 int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } 51 int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; }
54 int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } 52 int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; }
55 int audioBitsPerSample(int) { return 0;}
56 int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } 53 int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; }
57 bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } 54 bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; }
58 long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } 55 long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; }
59#ifdef OLD_MEDIAPLAYER_API 56#ifdef OLD_MEDIAPLAYER_API
60 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 57 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
61 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 58 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
index 89abf97..e9926f4 100644
--- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
@@ -17,15 +17,13 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LIBMPEG3_PLUGIN_IMPL_H 20#ifndef LIBMPEG3_PLUGIN_IMPL_H
21#define LIBMPEG3_PLUGIN_IMPL_H 21#define LIBMPEG3_PLUGIN_IMPL_H
22 22
23 23#include <qpe/mediaplayerplugininterface.h>
24//#include <qpe/mediaplayerplugininterface.h>
25#include "../mediaplayerplugininterface.h"
26 24
27 25
28class LibMpeg3Plugin; 26class LibMpeg3Plugin;
29 27
30 28
31class LibMpeg3PluginImpl : public MediaPlayerPluginInterface 29class LibMpeg3PluginImpl : public MediaPlayerPluginInterface
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 1ae0059..dd466ed 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,29 +14,27 @@
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
22#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
23
24#ifdef Q_WS_QWS 21#ifdef Q_WS_QWS
22
25#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
26#endif 24#endif
25#include <qpe/mediaplayerplugininterface.h>
27#include <stdio.h> 26#include <stdio.h>
28#include <stdlib.h> 27#include <stdlib.h>
29#include <string.h> 28#include <string.h>
30#include <pthread.h> 29#include <pthread.h>
31#include <errno.h> 30#include <errno.h>
32#include <unistd.h> 31#include <unistd.h>
33#include "loopcontrol.h" 32#include "loopcontrol.h"
34#include "videowidget.h" 33#include "videowidget.h"
35#include "audiodevice.h" 34#include "audiodevice.h"
36#include "mediaplayerplugininterface.h"
37#include "mediaplayerstate.h" 35#include "mediaplayerstate.h"
38 36
39 37
40extern VideoWidget *videoUI; // now only needed to tell it to play a frame 38extern VideoWidget *videoUI; // now only needed to tell it to play a frame
41extern MediaPlayerState *mediaPlayerState; 39extern MediaPlayerState *mediaPlayerState;
42 40
@@ -101,25 +99,30 @@ LoopControl::LoopControl( QObject *parent, const char *name )
101 isMuted = FALSE; 99 isMuted = FALSE;
102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 100 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
103 101
104 audioMutex = new Mutex; 102 audioMutex = new Mutex;
105 103
106 pthread_attr_init(&audio_attr); 104 pthread_attr_init(&audio_attr);
107#define USE_REALTIME_AUDIO_THREAD 105
108#ifdef USE_REALTIME_AUDIO_THREAD 106 if ( getuid() == 0 ) {
107 printf("true, guid = %i\n", getuid());
108
109 // Attempt to set it to real-time round robin 109 // Attempt to set it to real-time round robin
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
111 sched_param params; 111 sched_param params;
112 params.sched_priority = 50; 112 params.sched_priority = 50;
113 pthread_attr_setschedparam(&audio_attr,&params); 113 pthread_attr_setschedparam(&audio_attr,&params);
114 } else { 114 } else {
115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
116 pthread_attr_destroy(&audio_attr); 116 pthread_attr_destroy(&audio_attr);
117 pthread_attr_init(&audio_attr); 117 pthread_attr_init(&audio_attr);
118 } 118 }
119#endif 119 }
120// printf("false, guid = %i\n", getuid());
121 usleep( 100 );
122
120 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 123 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
121} 124}
122 125
123 126
124LoopControl::~LoopControl() { 127LoopControl::~LoopControl() {
125 stop(); 128 stop();
@@ -228,29 +231,28 @@ void LoopControl::startAudio() {
228 currentSample = audioSampleCounter + 1; 231 currentSample = audioSampleCounter + 1;
229 232
230 if ( currentSample != audioSampleCounter + 1 ) 233 if ( currentSample != audioSampleCounter + 1 )
231 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 234 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
232 235
233 long samplesRead = 0; 236 long samplesRead = 0;
234 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 237 mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 238 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
236 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 239 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
237 240
238 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 241 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
239 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 242 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
240 } 243 } else if ( sampleWaitTime <= -5000 ) {
241 else if ( sampleWaitTime <= -5000 ) {
242 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 244 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
243 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 245 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
244 currentSample = sampleWeShouldBeAt; 246 currentSample = sampleWeShouldBeAt;
245 } 247 }
246 248
247 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 249 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
248 audioSampleCounter = currentSample + samplesRead - 1; 250 audioSampleCounter = currentSample + samplesRead - 1;
249 251
250 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 252 moreAudio = audioSampleCounter <= total_audio_samples;
251 253
252 } else { 254 } else {
253 255
254 moreAudio = FALSE; 256 moreAudio = FALSE;
255 257
256 } 258 }
@@ -374,29 +376,29 @@ bool LoopControl::init( const QString& filename ) {
374 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 376 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
375 377
376 if ( hasAudioChannel ) { 378 if ( hasAudioChannel ) {
377 int astream = 0; 379 int astream = 0;
378 380
379 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 381 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
380 qDebug( "LC- channels = %d", channels ); 382 DecodeLoopDebug(( "channels = %d\n", channels ));
381 383
382 if ( !total_audio_samples ) 384 if ( !total_audio_samples )
383 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 385 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
384 386
385// total_audio_samples += 1000; 387 total_audio_samples += 1000;
386 388
387 mediaPlayerState->setLength( total_audio_samples ); 389 mediaPlayerState->setLength( total_audio_samples );
388 390
389 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 391 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
390 qDebug( "LC- frequency = %d", freq ); 392 DecodeLoopDebug(( "frequency = %d\n", freq ));
391 393
392 audioSampleCounter = 0; 394 audioSampleCounter = 0;
393 395
394 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); 396 static const int bytes_per_sample = 2; //16 bit
395 397
396 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 398 audioDevice = new AudioDevice( freq, channels, bytes_per_sample );
397 audioBuffer = new char[ audioDevice->bufferSize() ]; 399 audioBuffer = new char[ audioDevice->bufferSize() ];
398 channels = audioDevice->channels(); 400 channels = audioDevice->channels();
399 401
400 //### must check which frequency is actually used. 402 //### must check which frequency is actually used.
401 static const int size = 1; 403 static const int size = 1;
402 short int buf[size]; 404 short int buf[size];
diff --git a/core/multimedia/opieplayer/loopcontrol.h b/core/multimedia/opieplayer/loopcontrol.h
index fc7d316..3191259 100644
--- a/core/multimedia/opieplayer/loopcontrol.h
+++ b/core/multimedia/opieplayer/loopcontrol.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,18 +14,15 @@
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
22#ifndef MPEGVIEW_H 20#ifndef MPEGVIEW_H
23#define MPEGVIEW_H 21#define MPEGVIEW_H
24 22
25
26#include <qwidget.h> 23#include <qwidget.h>
27#include <qdatetime.h> 24#include <qdatetime.h>
28 25
29 26
30class LoopControl : public QObject { 27class LoopControl : public QObject {
31 Q_OBJECT 28 Q_OBJECT
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index 2e49bb7..eb89b85 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -17,19 +17,20 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define _REENTRANT 21#define _REENTRANT
22 22
23
23#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
24#include <qimage.h> 25#include <qimage.h>
25#include <qpainter.h> 26#include <qpainter.h>
26#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
27#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
28#endif 29#endif
29#include "mediaplayerplugininterface.h" 30#include <qpe/mediaplayerplugininterface.h>
30#include <stdio.h> 31#include <stdio.h>
31#include <stdlib.h> 32#include <stdlib.h>
32#include <string.h> 33#include <string.h>
33#include <time.h> 34#include <time.h>
34#include <unistd.h> 35#include <unistd.h>
35#include <pthread.h> 36#include <pthread.h>
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.h b/core/multimedia/opieplayer/loopcontrol_threaded.h
index 9a009d1..ced6ac8 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.h
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -18,12 +18,13 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MPEGVIEW_H 20#ifndef MPEGVIEW_H
21#define MPEGVIEW_H 21#define MPEGVIEW_H
22 22
23 23
24
24#include <qwidget.h> 25#include <qwidget.h>
25#include <qdatetime.h> 26#include <qdatetime.h>
26 27
27 28
28class LoopControl : public QObject { 29class LoopControl : public QObject {
29 Q_OBJECT 30 Q_OBJECT
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp
index 9f7ef73..720a1ca 100644
--- a/core/multimedia/opieplayer/main.cpp
+++ b/core/multimedia/opieplayer/main.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -22,13 +22,12 @@
22#include "playlistwidget.h" 22#include "playlistwidget.h"
23#include "audiowidget.h" 23#include "audiowidget.h"
24#include "videowidget.h" 24#include "videowidget.h"
25#include "loopcontrol.h" 25#include "loopcontrol.h"
26#include "mediaplayer.h" 26#include "mediaplayer.h"
27 27
28
29MediaPlayerState *mediaPlayerState; 28MediaPlayerState *mediaPlayerState;
30PlayListWidget *playList; 29PlayListWidget *playList;
31AudioWidget *audioUI; 30AudioWidget *audioUI;
32VideoWidget *videoUI; 31VideoWidget *videoUI;
33LoopControl *loopControl; 32LoopControl *loopControl;
34 33
@@ -45,13 +44,13 @@ int main(int argc, char **argv) {
45 VideoWidget vw( 0, "videoUI" ); 44 VideoWidget vw( 0, "videoUI" );
46 videoUI = &vw; 45 videoUI = &vw;
47 LoopControl lc( 0, "loopControl" ); 46 LoopControl lc( 0, "loopControl" );
48 loopControl = &lc; 47 loopControl = &lc;
49 MediaPlayer mp( 0, "mediaPlayer" ); 48 MediaPlayer mp( 0, "mediaPlayer" );
50 49
51 pl.setCaption( MediaPlayer::tr("Opie Player") ); 50 pl.setCaption( MediaPlayer::tr("Media Player") );
52 a.showMainDocumentWidget(&pl); 51 a.showMainDocumentWidget(&pl);
53 52
54 return a.exec(); 53 return a.exec();
55} 54}
56 55
57 56
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 3d8f76c..ce42c2c 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,12 +14,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
20#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 22#include <qpe/qlibrary.h>
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23#include <qpe/config.h> 24#include <qpe/config.h>
24 25
25#include <qmainwindow.h> 26#include <qmainwindow.h>
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h
index 379d95c..73f8124 100644
--- a/core/multimedia/opieplayer/mediaplayer.h
+++ b/core/multimedia/opieplayer/mediaplayer.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -17,17 +17,16 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MEDIA_PLAYER_H 20#ifndef MEDIA_PLAYER_H
21#define MEDIA_PLAYER_H 21#define MEDIA_PLAYER_H
22 22
23
24#include <qmainwindow.h> 23#include <qmainwindow.h>
25#include <qframe.h> 24#include <qframe.h>
26#include <qpe/qlibrary.h> 25#include <qpe/qlibrary.h>
27#include "mediaplayerplugininterface.h" 26#include <qpe/mediaplayerplugininterface.h>
28 27
29 28
30class DocLnk; 29class DocLnk;
31 30
32 31
33class MediaPlayer : public QObject { 32class MediaPlayer : public QObject {
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h
index 339b2e4..aeeffde 100644
--- a/core/multimedia/opieplayer/mediaplayerplugininterface.h
+++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h
@@ -17,12 +17,13 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H 20#ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H
21#define MEDIA_PLAYER_PLUGIN_INTERFACE_H 21#define MEDIA_PLAYER_PLUGIN_INTERFACE_H
22 22
23
23#include <qpe/qcom.h> 24#include <qpe/qcom.h>
24 25
25#ifndef QT_NO_COMPONENT 26#ifndef QT_NO_COMPONENT
26// {c0093632-b44c-4cf7-a279-d82fe8a8890c} 27// {c0093632-b44c-4cf7-a279-d82fe8a8890c}
27# ifndef IID_MediaPlayerPlugin 28# ifndef IID_MediaPlayerPlugin
28# define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) 29# define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c )
@@ -58,13 +59,18 @@ public:
58 virtual int audioStreams() = 0; 59 virtual int audioStreams() = 0;
59 virtual int audioChannels( int stream ) = 0; 60 virtual int audioChannels( int stream ) = 0;
60 virtual int audioFrequency( int stream ) = 0; 61 virtual int audioFrequency( int stream ) = 0;
61 virtual int audioSamples( int stream ) = 0; 62 virtual int audioSamples( int stream ) = 0;
62 virtual bool audioSetSample( long sample, int stream ) = 0; 63 virtual bool audioSetSample( long sample, int stream ) = 0;
63 virtual long audioGetSample( int stream ) = 0; 64 virtual long audioGetSample( int stream ) = 0;
65// virtual bool audioReadMonoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0;
66// virtual bool audioReadStereoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0;
64 virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; 67 virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0;
68 // Libmpeg3 functions, perhaps good for reading an audio file with 5 channels or something!
69// virtual bool audioReadSamples( short *samples, int channel, long samples, int stream ) = 0;
70// virtual bool audioReReadSamples( short *samples, int channel, long samples, int stream ) = 0;
65 71
66 // If decoder doesn't support video then return 0 here 72 // If decoder doesn't support video then return 0 here
67 virtual int videoStreams() = 0; 73 virtual int videoStreams() = 0;
68 virtual int videoWidth( int stream ) = 0; 74 virtual int videoWidth( int stream ) = 0;
69 virtual int videoHeight( int stream ) = 0; 75 virtual int videoHeight( int stream ) = 0;
70 virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) 76 virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs)
@@ -88,15 +94,12 @@ public:
88 virtual bool supportsYUV() = 0; 94 virtual bool supportsYUV() = 0;
89 virtual bool supportsMMX() = 0; 95 virtual bool supportsMMX() = 0;
90 virtual bool supportsSMP() = 0; 96 virtual bool supportsSMP() = 0;
91 virtual bool supportsStereo() = 0; 97 virtual bool supportsStereo() = 0;
92 virtual bool supportsScaling() = 0; 98 virtual bool supportsScaling() = 0;
93 99
94 // File Properies
95 virtual long getPlayTime() { return -1; }
96 virtual int audioBitsPerSample( int stream ) = 0;
97}; 100};
98 101
99 102
100class MediaPlayerEncoder; 103class MediaPlayerEncoder;
101 104
102 105
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index 2a6bca3..7e82166 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -16,31 +16,29 @@
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#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h> 23#include <qpe/config.h>
23#include <qvaluelist.h> 24#include <qvaluelist.h>
24#include <qobject.h> 25#include <qobject.h>
25#include <qdir.h> 26#include <qdir.h>
26#include "mediaplayerplugininterface.h"
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29
30
31#ifdef QT_NO_COMPONENT 29#ifdef QT_NO_COMPONENT
32// Plugins which are compiled in when no plugin architecture available 30// Plugins which are compiled in when no plugin architecture available
33#include "libmad/libmadpluginimpl.h" 31#include "libmad/libmadpluginimpl.h"
34#include "libmpeg3/libmpeg3pluginimpl.h" 32#include "libmpeg3/libmpeg3pluginimpl.h"
35#include "wavplugin/wavpluginimpl.h" 33#include "wavplugin/wavpluginimpl.h"
36#endif 34#endif
37 35
38 36
39//#define MediaPlayerDebug(x) qDebug x 37 #define MediaPlayerDebug(x)qDebug x
40#define MediaPlayerDebug(x) 38//#define MediaPlayerDebug(x)
41 39
42 40
43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 41MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 42 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
45 Config cfg( "MediaPlayer" ); 43 Config cfg( "MediaPlayer" );
46 readConfig( cfg ); 44 readConfig( cfg );
@@ -113,16 +111,12 @@ MediaPlayerDecoder *MediaPlayerState::curDecoder() {
113 111
114// ### hack to get true sample count 112// ### hack to get true sample count
115MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 113MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
116 return libmpeg3decoder; 114 return libmpeg3decoder;
117} 115}
118 116
119// ### hack to get true sample count
120// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
121// return libwavdecoder;
122// }
123 117
124void MediaPlayerState::loadPlugins() { 118void MediaPlayerState::loadPlugins() {
125 119
126#ifndef QT_NO_COMPONENT 120#ifndef QT_NO_COMPONENT
127 QValueList<MediaPlayerPlugin>::Iterator mit; 121 QValueList<MediaPlayerPlugin>::Iterator mit;
128 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 122 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 1a23742..e82c263 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -17,13 +17,12 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MEDIA_PLAYER_STATE_H 20#ifndef MEDIA_PLAYER_STATE_H
21#define MEDIA_PLAYER_STATE_H 21#define MEDIA_PLAYER_STATE_H
22 22
23
24#include <qobject.h> 23#include <qobject.h>
25 24
26 25
27class MediaPlayerDecoder; 26class MediaPlayerDecoder;
28class Config; 27class Config;
29 28
@@ -103,13 +102,12 @@ private:
103 long curPosition; 102 long curPosition;
104 long curLength; 103 long curLength;
105 char curView; 104 char curView;
106 105
107 MediaPlayerDecoder *decoder; 106 MediaPlayerDecoder *decoder;
108 MediaPlayerDecoder *libmpeg3decoder; 107 MediaPlayerDecoder *libmpeg3decoder;
109// MediaPlayerDecoder *libwavdecoder;
110 108
111 void loadPlugins(); 109 void loadPlugins();
112 void readConfig( Config& cfg ); 110 void readConfig( Config& cfg );
113 void writeConfig( Config& cfg ) const; 111 void writeConfig( Config& cfg ) const;
114}; 112};
115 113
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index f17ab6f..a82b594 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -27,13 +27,12 @@
27#include <qpixmap.h> 27#include <qpixmap.h>
28 28
29#include "playlistselection.h" 29#include "playlistselection.h"
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33
34class PlayListSelectionItem : public QListViewItem { 33class PlayListSelectionItem : public QListViewItem {
35public: 34public:
36 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 35 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
37 setText( 0, f->name() ); 36 setText( 0, f->name() );
38 setPixmap( 0, f->pixmap() ); 37 setPixmap( 0, f->pixmap() );
39 } 38 }
diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h
index 6ce6bdc..22d3c74 100644
--- a/core/multimedia/opieplayer/playlistselection.h
+++ b/core/multimedia/opieplayer/playlistselection.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -18,12 +18,13 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_SELECTION_H 20#ifndef PLAY_LIST_SELECTION_H
21#define PLAY_LIST_SELECTION_H 21#define PLAY_LIST_SELECTION_H
22 22
23 23
24
24#include <qlist.h> 25#include <qlist.h>
25#include <qlistview.h> 26#include <qlistview.h>
26#include <qpe/applnk.h> 27#include <qpe/applnk.h>
27 28
28 29
29class PlayListSelection : public QListView { 30class PlayListSelection : public QListView {
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 269aed8..0423e7a 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,17 +14,16 @@
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
20#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
22#include <qpe/fileselector.h> 23#include <qpe/fileselector.h>
23#include <qpe/qpeapplication.h>
24
25#include <qpe/applnk.h> 24#include <qpe/applnk.h>
26#include <qpe/config.h> 25#include <qpe/config.h>
27#include <qpe/global.h> 26#include <qpe/global.h>
28#include <qpe/resource.h> 27#include <qpe/resource.h>
29#include <qaction.h> 28#include <qaction.h>
30#include <qimage.h> 29#include <qimage.h>
@@ -33,35 +32,31 @@
33#include <qlabel.h> 32#include <qlabel.h>
34#include <qlist.h> 33#include <qlist.h>
35#include <qlistbox.h> 34#include <qlistbox.h>
36#include <qmainwindow.h> 35#include <qmainwindow.h>
37#include <qmessagebox.h> 36#include <qmessagebox.h>
38#include <qtoolbutton.h> 37#include <qtoolbutton.h>
39#include <qtabwidget.h>
40#include <qlistview.h>
41#include <qpoint.h>
42//#include <qtimer.h>
43 38
44#include "playlistselection.h" 39#include "playlistselection.h"
45#include "playlistwidget.h" 40#include "playlistwidget.h"
46#include "mediaplayerstate.h" 41#include "mediaplayerstate.h"
47 42
48#include <stdlib.h> 43#include <stdlib.h>
49 44
50#define BUTTONS_ON_TOOLBAR
51#define SIDE_BUTTONS
52#define CAN_SAVE_LOAD_PLAYLISTS
53 45
54extern MediaPlayerState *mediaPlayerState; 46extern MediaPlayerState *mediaPlayerState;
55 47
56// class myFileSelector {
57 48
58// };
59class PlayListWidgetPrivate { 49class PlayListWidgetPrivate {
60public: 50public:
61 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 51 QToolButton *tbPlay;
52 QToolButton *tbFull;
53 QToolButton *tbLoop;
54 QToolButton *tbScale;
55 QToolButton *tbShuffle;
56
62 QFrame *playListFrame; 57 QFrame *playListFrame;
63 FileSelector *files; 58 FileSelector *files;
64 PlayListSelection *selectedFiles; 59 PlayListSelection *selectedFiles;
65 bool setDocumentUsed; 60 bool setDocumentUsed;
66 DocLnk *current; 61 DocLnk *current;
67}; 62};
@@ -95,18 +90,16 @@ public:
95PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 90PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
96 : QMainWindow( parent, name, fl ) { 91 : QMainWindow( parent, name, fl ) {
97 92
98 d = new PlayListWidgetPrivate; 93 d = new PlayListWidgetPrivate;
99 d->setDocumentUsed = FALSE; 94 d->setDocumentUsed = FALSE;
100 d->current = NULL; 95 d->current = NULL;
101// menuTimer = new QTimer( this ,"menu timer"),
102// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
103 96
104 setBackgroundMode( PaletteButton ); 97 setBackgroundMode( PaletteButton );
105 98
106 setCaption( tr("OpiePlayer") ); 99 setCaption( tr("MediaPlayer") );
107 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 100 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
108 101
109 setToolBarsMovable( FALSE ); 102 setToolBarsMovable( FALSE );
110 103
111 // Create Toolbar 104 // Create Toolbar
112 QPEToolBar *toolbar = new QPEToolBar( this ); 105 QPEToolBar *toolbar = new QPEToolBar( this );
@@ -115,172 +108,83 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
115 // Create Menubar 108 // Create Menubar
116 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 109 QPEMenuBar *menu = new QPEMenuBar( toolbar );
117 menu->setMargin( 0 ); 110 menu->setMargin( 0 );
118 111
119 QPEToolBar *bar = new QPEToolBar( this ); 112 QPEToolBar *bar = new QPEToolBar( this );
120 bar->setLabel( tr( "Play Operations" ) ); 113 bar->setLabel( tr( "Play Operations" ) );
121 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", 114#ifdef BUTTONS_ON_TOOLBAR
122 this , SLOT(addSelected()) ); 115 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", 116 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
124 this , SLOT(removeSelected()) ); 117#endif
125 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", 118 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE );
126 mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 119 d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
127 120 d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132
133// d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
134// d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
135 121
136 QPopupMenu *pmPlayList = new QPopupMenu( this ); 122 QPopupMenu *pmPlayList = new QPopupMenu( this );
137 menu->insertItem( tr( "File" ), pmPlayList ); 123 menu->insertItem( tr( "PlayList" ), pmPlayList );
124 new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) );
138 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 125 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
139 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 126 new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) );
140 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 127 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
141 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 128 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
129#ifdef CAN_SAVE_LOAD_PLAYLISTS
142 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 130 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
143 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 131 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
144 132#endif
145 QPopupMenu *pmView = new QPopupMenu( this );
146 menu->insertItem( tr( "View" ), pmView );
147
148 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
149 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
150 fullScreenButton->addTo(pmView);
151 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
152 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
153 scaleButton->addTo(pmView);
154 133
155 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 134 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
156 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
157// vbox4->setMargin(4);
158// libString = new QLabel( tr(" Media Library"), vbox4 );
159// libString->setBackgroundMode( QButton::PaletteButton );
160// libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
161
162 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
163
164 tabWidget = new QTabWidget( hbox6, "tabWidget" );
165 tabWidget->setTabShape(QTabWidget::Triangular);
166
167
168 QWidget *pTab;
169 pTab = new QWidget( tabWidget, "pTab" );
170 playlistView = new QListView( pTab, "Videoview" );
171 playlistView->setMinimumSize(236,260);
172 tabWidget->insertTab( pTab,"Playlist");
173 135
174 // Add the playlist area 136 // Add the playlist area
175 137 QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton );
176 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
177 d->playListFrame = vbox3; 138 d->playListFrame = vbox3;
178 d->playListFrame ->setMinimumSize(235,260); 139
140 QLabel *plString = new QLabel( tr(" PlayList"), vbox3 );
141 plString->setBackgroundMode( QButton::PaletteButton );
142 plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
179 143
180 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 144 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
181 d->selectedFiles = new PlayListSelection( hbox2); 145 d->selectedFiles = new PlayListSelection( hbox2);
182 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 146 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
183 147
148#ifndef BUTTONS_ON_TOOLBAR
149 d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
184 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 150 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
151#endif
185 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 152 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
186 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 153 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
187 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 154 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
188 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 155 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
189 156#ifndef BUTTONS_ON_TOOLBAR
190 QWidget *aTab; 157 d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
191 aTab = new QWidget( tabWidget, "aTab" ); 158#endif
192 audioView = new QListView( aTab, "Audioview" );
193 audioView->setMinimumSize(233,260);
194 audioView->addColumn( "Title",150);
195 audioView->addColumn("Size", 45);
196 audioView->addColumn("Media",35);
197 audioView->setColumnAlignment(1, Qt::AlignRight);
198 audioView->setColumnAlignment(2, Qt::AlignRight);
199 tabWidget->insertTab(aTab,"Audio");
200// audioView
201 Global::findDocuments(&files, "audio/*");
202 QListIterator<DocLnk> dit( files.children() );
203 QString storage;
204 for ( ; dit.current(); ++dit ) {
205 QListViewItem * newItem;
206 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
207 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
208 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
209 else storage="RAM";
210 if ( QFile( dit.current()->file()).exists() ) {
211 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
212 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
213 }
214 }
215// videowidget
216
217 QWidget *vTab;
218 vTab = new QWidget( tabWidget, "vTab" );
219 videoView = new QListView( vTab, "Videoview" );
220 videoView->setMinimumSize(233,260);
221
222 videoView->addColumn("Title",150);
223 videoView->addColumn("Size",45);
224 videoView->addColumn("Media",35);
225 videoView->setColumnAlignment(1, Qt::AlignRight);
226 videoView->setColumnAlignment(2, Qt::AlignRight);
227
228 tabWidget->insertTab( vTab,"Video");
229
230 Global::findDocuments(&vFiles, "video/*");
231 QListIterator<DocLnk> Vdit( vFiles.children() );
232 for ( ; Vdit.current(); ++Vdit ) {
233 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
234 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
235 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
236 else storage="RAM";
237 QListViewItem * newItem;
238 if ( QFile( Vdit.current()->file()).exists() ) {
239 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
240 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
241 }
242 }
243
244
245// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
246// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
247 159
248 // add the library area 160 // add the library area
161 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
249 162
250// d->files->setBackgroundMode( PaletteButton ); 163 QLabel *libString = new QLabel( tr(" Media Library"), vbox4 );
251// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); 164 libString->setBackgroundMode( QButton::PaletteButton );
252 165 libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
253// #ifdef SIDE_BUTTONS
254// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
255// #endif
256 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
257
258// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
259// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
260 166
261 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 167 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
262 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 168 d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE );
169 d->files->setBackgroundMode( PaletteButton );
170 QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
263 171
264 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), 172#ifdef SIDE_BUTTONS
265 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); 173 new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) );
266 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), 174 new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) );
267 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); 175 QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
176#endif
268 177
269 connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 178 connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
270 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
271 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
272 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
273 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 179 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
274 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 180 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
275 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 181 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
276 182 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) );
277// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); 183 connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) );
278// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); 184 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) );
279// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
280
281 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 185 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
282 186
283 setCentralWidget( vbox5 ); 187 setCentralWidget( vbox5 );
284 188
285 Config cfg( "MediaPlayer" ); 189 Config cfg( "MediaPlayer" );
286 readConfig( cfg ); 190 readConfig( cfg );
@@ -297,20 +201,19 @@ PlayListWidget::~PlayListWidget() {
297 delete d->current; 201 delete d->current;
298 delete d; 202 delete d;
299} 203}
300 204
301 205
302void PlayListWidget::initializeStates() { 206void PlayListWidget::initializeStates() {
303
304 d->tbPlay->setOn( mediaPlayerState->playing() ); 207 d->tbPlay->setOn( mediaPlayerState->playing() );
305 d->tbLoop->setOn( mediaPlayerState->looping() ); 208 d->tbLoop->setOn( mediaPlayerState->looping() );
306 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 209 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
307// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 210 d->tbFull->setOn( mediaPlayerState->fullscreen() );
308// d->tbScale->setOn( mediaPlayerState->scaled() ); 211 d->tbScale->setOn( mediaPlayerState->scaled() );
309// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 212 d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
310// setPlaylist( mediaPlayerState->playlist() ); 213 setPlaylist( mediaPlayerState->playlist() );
311} 214}
312 215
313 216
314void PlayListWidget::readConfig( Config& cfg ) { 217void PlayListWidget::readConfig( Config& cfg ) {
315 cfg.setGroup("PlayList"); 218 cfg.setGroup("PlayList");
316 219
@@ -369,22 +272,12 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
369 d->selectedFiles->addToSelection( lnk ); 272 d->selectedFiles->addToSelection( lnk );
370 else 273 else
371 mediaPlayerState->setPlaying( TRUE ); 274 mediaPlayerState->setPlaying( TRUE );
372} 275}
373 276
374 277
375void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
376 qDebug("add");
377// d->selectedFiles->addToSelection( lnk );
378 // }
379// else
380// mediaPlayerState->setPlaying( TRUE );
381//
382}
383
384
385void PlayListWidget::clearList() { 278void PlayListWidget::clearList() {
386 while ( first() ) 279 while ( first() )
387 d->selectedFiles->removeSelected(); 280 d->selectedFiles->removeSelected();
388} 281}
389 282
390 283
@@ -551,148 +444,6 @@ void PlayListWidget::setView( char view ) {
551 if ( view == 'l' ) 444 if ( view == 'l' )
552 showMaximized(); 445 showMaximized();
553 else 446 else
554 hide(); 447 hide();
555} 448}
556 449
557void PlayListWidget::addSelected() {
558// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here");
559 int tabPage=tabWidget->currentPageIndex();
560 switch (tabPage) {
561 case 0: //playlist
562 break;
563 case 1: { //audio
564 addToSelection( audioView->selectedItem() );
565 }
566 break;
567 case 2: { // video
568 addToSelection( videoView->selectedItem() );
569 }
570 break;
571 };
572}
573
574void PlayListWidget::removeSelected() {
575 d->selectedFiles->removeSelected( );
576}
577
578
579void PlayListWidget::playIt( QListViewItem *it) {
580 d->setDocumentUsed = FALSE;
581
582 if(it) {
583 qDebug("playit");
584 int tabPage=tabWidget->currentPageIndex();
585 switch (tabPage) {
586 case 1: {
587 DocLnkSet files;
588 QListIterator<DocLnk> dit( files.children() );
589 for ( ; dit.current(); ++dit ) {
590 if( dit.current()->name() == it->text(0)) {
591 setDocument( dit.current()->name());
592 }
593 }
594 }
595 break;
596 case 2: {
597 DocLnkSet vFiles;
598 QListIterator<DocLnk> dit( vFiles.children() );
599 for ( ; dit.current(); ++dit ) {
600 qDebug(dit.current()->name());
601 if( dit.current()->name() == it->text(0)) {
602 qDebug(it->text(0));
603 setDocument( dit.current()->name());
604 }
605 }
606 }
607 break;
608 };
609 }
610}
611
612void PlayListWidget::addToSelection( QListViewItem *it) {
613 d->setDocumentUsed = FALSE;
614
615 if(it) {
616 qDebug("add to selection");
617 int tabPage=tabWidget->currentPageIndex();
618 switch (tabPage) {
619 case 1: {
620 QListIterator<DocLnk> dit( files.children() );
621 for ( ; dit.current(); ++dit ) {
622 if( dit.current()->name() == it->text(0)) {
623 d->selectedFiles->addToSelection( **dit );
624 }
625 }
626 }
627 break;
628 case 2: {
629 QListIterator<DocLnk> dit( vFiles.children() );
630 for ( ; dit.current(); ++dit ) {
631 qDebug(dit.current()->name());
632 if( dit.current()->name() == it->text(0)) {
633 d->selectedFiles->addToSelection( **dit );
634 }
635 }
636 }
637 break;
638 case 0:
639 break;
640 };
641 tabWidget->setCurrentPage(0);
642// mediaPlayerState->setPlaying( TRUE );
643 }
644}
645
646void PlayListWidget::tabChanged(QWidget *widg) {
647
648 int tabPage=tabWidget->currentPageIndex();
649 switch (tabPage) {
650 case 0:
651 {
652 d->tbRemoveFromList->setEnabled(TRUE);
653 d->tbAddToList->setEnabled(FALSE);
654 }
655 break;
656 case 1:
657 {
658 d->tbRemoveFromList->setEnabled(FALSE);
659 d->tbAddToList->setEnabled(TRUE);
660 }
661 break;
662 case 2:
663 {
664 d->tbRemoveFromList->setEnabled(FALSE);
665 d->tbAddToList->setEnabled(TRUE);
666 }
667 break;
668 };
669}
670
671// void PlayListWidget::cancelMenuTimer() {
672// if( menuTimer->isActive() )
673// menuTimer->stop();
674// }
675
676// void PlayListWidget::showFileMenu() {
677
678// }
679
680// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
681// {
682// // QListView::contentsMousePressEvent( e );
683// menuTimer->start( 750, TRUE );
684// }
685
686
687// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e )
688// {
689// // QListView::contentsMouseReleaseEvent( e );
690// menuTimer->stop();
691// }
692// // void PlayListWidget::setFullScreen() {
693// mediaPlayerState->toggleFullscreen( );
694// }
695
696// void PlayListWidget::setScaled() {
697// mediaPlayerState->toggleScaled();
698// }
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 6fe2211..819adb1 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -17,81 +17,51 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23
24#include <qmainwindow.h> 23#include <qmainwindow.h>
25#include <qpe/applnk.h> 24#include <qpe/applnk.h>
26#include <qtabwidget.h>
27/* #include <qtimer.h> */
28 25
29 26
30class PlayListWidgetPrivate; 27class PlayListWidgetPrivate;
31class Config; 28class Config;
32class QListViewItem; 29
33class QListView;
34class QPoint;
35class QAction;
36class QLabel;
37 30
38class PlayListWidget : public QMainWindow { 31class PlayListWidget : public QMainWindow {
39 Q_OBJECT 32 Q_OBJECT
40public: 33public:
41 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 34 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
42 ~PlayListWidget(); 35 ~PlayListWidget();
43 QTabWidget * tabWidget; 36
44 QAction *fullScreenButton, *scaleButton;
45 DocLnkSet files;
46 DocLnkSet vFiles;
47 QListView *audioView, *videoView, *playlistView;
48 QLabel *libString;
49 // retrieve the current playlist entry (media file link) 37 // retrieve the current playlist entry (media file link)
50 const DocLnk *current(); 38 const DocLnk *current();
51 void useSelectedDocument(); 39 void useSelectedDocument();
52/* QTimer * menuTimer; */
53 40
54public slots: 41public slots:
55 void setDocument( const QString& fileref ); 42 void setDocument( const QString& fileref );
56 void addToSelection( const DocLnk& ); // Add a media file to the playlist 43 void addToSelection( const DocLnk& ); // Add a media file to the playlist
57 void addToSelection( QListViewItem* ); // Add a media file to the playlist
58 void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist
59 void setActiveWindow(); // need to handle this to show the right view 44 void setActiveWindow(); // need to handle this to show the right view
60 void setPlaylist( bool ); // Show/Hide the playlist 45 void setPlaylist( bool ); // Show/Hide the playlist
61 void setView( char ); 46 void setView( char );
62 void clearList(); 47 void clearList();
63 void addAllToList(); 48 void addAllToList();
64 void addAllMusicToList(); 49 void addAllMusicToList();
65 void addAllVideoToList(); 50 void addAllVideoToList();
66 void saveList(); // Save the playlist 51 void saveList(); // Save the playlist
67 void loadList(); // Load a playlist 52 void loadList(); // Load a playlist
68 void playIt( QListViewItem *);
69 bool first(); 53 bool first();
70 bool last(); 54 bool last();
71 bool next(); 55 bool next();
72 bool prev(); 56 bool prev();
73 void addSelected();
74 void removeSelected();
75 void tabChanged(QWidget*);
76/* void setFullScreen(); */
77/* void setScaled(); */
78protected:
79/* void contentsMousePressEvent( QMouseEvent * e ); */
80/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
81 57
82private: 58private:
83 void initializeStates(); 59 void initializeStates();
84 void readConfig( Config& cfg ); 60 void readConfig( Config& cfg );
85 void writeConfig( Config& cfg ) const; 61 void writeConfig( Config& cfg ) const;
86 PlayListWidgetPrivate *d; // Private implementation data 62 PlayListWidgetPrivate *d; // Private implementation data
87
88protected slots:
89/* void cancelMenuTimer(); */
90/* void showFileMenu(); */
91
92
93}; 63};
94 64
95 65
96#endif // PLAY_LIST_WIDGET_H 66#endif // PLAY_LIST_WIDGET_H
97 67
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 1f128a4..12ae4fd 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -14,14 +14,15 @@
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
20#include <qpe/resource.h> 21#include <qpe/resource.h>
21#include "mediaplayerplugininterface.h" 22#include <qpe/mediaplayerplugininterface.h>
22#include <qwidget.h> 23#include <qwidget.h>
23#include <qpainter.h> 24#include <qpainter.h>
24#include <qpixmap.h> 25#include <qpixmap.h>
25#include <qslider.h> 26#include <qslider.h>
26#include <qdrawutil.h> 27#include <qdrawutil.h>
27#include "videowidget.h" 28#include "videowidget.h"
@@ -63,13 +64,13 @@ MediaButton videoButtons[] = {
63 64
64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 65static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 66
66 67
67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 68VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 69 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
69 setCaption( tr("OpiePlayer") ); 70 setCaption( tr("MediaPlayer") );
70 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 71 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); 72 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) );
72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); 73 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) );
73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); 74 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) );
74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 75 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
75 76
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h
index 8b49091..cf13743 100644
--- a/core/multimedia/opieplayer/videowidget.h
+++ b/core/multimedia/opieplayer/videowidget.h
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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**
@@ -20,13 +20,12 @@
20#ifndef VIDEO_WIDGET_H 20#ifndef VIDEO_WIDGET_H
21#define VIDEO_WIDGET_H 21#define VIDEO_WIDGET_H
22 22
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25 25
26
27class QPixmap; 26class QPixmap;
28class QSlider; 27class QSlider;
29 28
30 29
31enum VideoButtons { 30enum VideoButtons {
32 VideoPrevious, 31 VideoPrevious,
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in
index a46b925..bcbe7f2 100644
--- a/core/multimedia/opieplayer/wavplugin/Makefile.in
+++ b/core/multimedia/opieplayer/wavplugin/Makefile.in
@@ -97,15 +97,13 @@ 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
105 104
106wavpluginimpl.o: wavpluginimpl.cpp \ 105wavpluginimpl.o: wavpluginimpl.cpp \
107 wavplugin.h \ 106 wavplugin.h \
108 ../mediaplayerplugininterface.h \
109 wavpluginimpl.h 107 wavpluginimpl.h
110 108
111 109
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
index 7f63b3b..0be667f 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
@@ -14,23 +14,20 @@
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
22#include <stdio.h> 20#include <stdio.h>
23#include <stdarg.h> 21#include <stdarg.h>
24#include <stdlib.h> 22#include <stdlib.h>
25#include <errno.h> 23#include <errno.h>
26#include <unistd.h> 24#include <unistd.h>
27#include <qfile.h> 25#include <qfile.h>
28#include "wavplugin.h" 26#include "wavplugin.h"
29 27
30
31//#define debugMsg(a) qDebug(a) 28//#define debugMsg(a) qDebug(a)
32#define debugMsg(a) 29#define debugMsg(a)
33 30
34 31
35struct RiffChunk { 32struct RiffChunk {
36 char id[4]; 33 char id[4];
@@ -46,13 +43,13 @@ struct ChunkData {
46 Q_INT32 avgBytesPerSec; 43 Q_INT32 avgBytesPerSec;
47 Q_INT16 blockAlign; 44 Q_INT16 blockAlign;
48 Q_INT16 wBitsPerSample; 45 Q_INT16 wBitsPerSample;
49}; 46};
50 47
51 48
52const int sound_buffer_size = 512; // 4096; // you got to be kidding right? 49const int sound_buffer_size = 4096;
53 50
54 51
55class WavPluginData { 52class WavPluginData {
56public: 53public:
57 QFile *input; 54 QFile *input;
58 55
@@ -60,51 +57,57 @@ public:
60 ChunkData chunkdata; 57 ChunkData chunkdata;
61 RiffChunk chunk; 58 RiffChunk chunk;
62 uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data 59 uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data
63 int out,max; 60 int out,max;
64 int samples_due; 61 int samples_due;
65 int samples; 62 int samples;
63 int freq;
64 int chan;
65 int sampleRate;
66 int resolution;
66 67
67 WavPluginData() { 68 WavPluginData() {
68 max = out = sound_buffer_size; 69 max = out = sound_buffer_size;
69 wavedata_remaining = 0; 70 wavedata_remaining = 0;
70 samples_due = 0; 71 samples_due = 0;
71 samples = -1; 72 samples = -1;
72 } 73 }
73 74
74 // expands out samples to the frequency of 44kHz 75 // expands out samples to the frequency of 44kHz
75 bool add( short *output, long count, long& done, bool stereo ) 76 bool add( short *output, long count, long& done, bool stereo )
76 { 77 {
78 qDebug("add");
77 done = 0; 79 done = 0;
78 qApp->processEvents();
79 80
80 if ( input == 0 ) { 81 if ( input == 0 ) {
81 qDebug("no input"); 82 qDebug("no input");
82 return FALSE; 83 return FALSE;
83 } 84 }
84 85
85 while ( count ) { 86 while ( count ) {
86 int l,r; 87 int l,r;
87 if ( getSample(l, r) == FALSE ) { 88 if ( getSample(l, r) == FALSE ) {
88 qDebug("didn't get sample"); 89 qDebug("didn't get sample");
89 return FALSE; 90 return FALSE;
90 } 91 }
91 samples_due += chunkdata.samplesPerSec; 92 samples_due += 44100;
92 while ( count && (samples_due > chunkdata.samplesPerSec) ) { 93 while ( count && (samples_due > chunkdata.samplesPerSec) ) {
93 *output++ = l; 94 *output++ = l;
94 if ( stereo ) 95 if ( stereo )
95 *output++ = r; 96 *output++ = r;
96 samples_due -= chunkdata.samplesPerSec; 97 samples_due -= chunkdata.samplesPerSec;
97 count--; 98 count--;
98 done++; 99 done++;
99 } 100 }
100 } 101 }
102
101 return TRUE; 103 return TRUE;
102 } 104 }
103 105
104 bool initialise() { 106 bool initialise() {
107 qDebug("initialize");
105 if ( input == 0 ) 108 if ( input == 0 )
106 return FALSE; 109 return FALSE;
107 110
108 wavedata_remaining = -1; 111 wavedata_remaining = -1;
109 112
110 while ( wavedata_remaining == -1 ) { 113 while ( wavedata_remaining == -1 ) {
@@ -135,20 +138,25 @@ public:
135 } 138 }
136#define WAVE_FORMAT_PCM 1 139#define WAVE_FORMAT_PCM 1
137 if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { 140 if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) {
138 qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); 141 qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag);
139 return FALSE; 142 return FALSE;
140 } 143 }
141 } else { 144 }
145
146
147
148
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
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)
@@ -169,31 +177,179 @@ public:
169 out = 0; 177 out = 0;
170 if ( max <= 0 ) { 178 if ( max <= 0 ) {
171 max = 0; 179 max = 0;
172 return TRUE; 180 return TRUE;
173 } 181 }
174 } 182 }
175 if ( chunkdata.wBitsPerSample == 8 ) { 183 if ( resolution == 8 ) {
176 l = (data[out++] - 128) * 128; 184 l = (data[out++] - 128) * 128;
177 } else { 185 } else {
178 l = ((short*)data)[out/2]; 186 l = ((short*)data)[out/2];
179 out += 2; 187 out += 2;
180 } 188 }
181 if ( chunkdata.channels == 1 ) { 189 if ( chan == 1 ) {
182 r = l; 190 r = l;
183 } else { 191 } else {
184 if ( chunkdata.wBitsPerSample == 8 ) { 192 if ( resolution == 8 ) {
185 r = (data[out++] - 128) * 128; 193 r = (data[out++] - 128) * 128;
186 } else { 194 } else {
187 r = ((short*)data)[out/2]; 195 r = ((short*)data)[out/2];
188 out += 2; 196 out += 2;
189 } 197 }
190 } 198 }
191 return TRUE; 199 return TRUE;
192 } // getSample 200 } // getSample
193 201
202//////////////////////////////////////////////////////
203int getWavSettings(int fd)
204{ //this came from wmrecord
205
206 char t1[4];
207 unsigned long l1;
208 int found;
209 short fmt;
210 unsigned short ch, brate;
211 unsigned long srate;
212
213
214 /* First read in the RIFF identifier. If this is missing then the
215 * file is not a valid WAVE file.
216 */
217 if (read(fd, t1, 4)<4) {
218 qDebug(" Could not read from sound file.\n");
219 return -1;
220 }
221 if (strncmp(t1, "RIFF", 4)) {
222 qDebug(" not a valid WAV file.\n");
223 return -1;
224 }
225 /* Advance the file pointer to the next relevant field. */
226 lseek(fd, 4, SEEK_CUR);
227 /* Read in the WAVE identifier. */
228 if (read(fd, t1, 4)<4) {
229 qDebug("Could not read from sound file.\n");
230 return -1;
231 }
232 if (strncmp(t1, "WAVE", 4)) {
233 qDebug("not a valid WAV file.\n");
234 return -1;
235 }
236
237 /* Search through the file for the format chunk. If the end of the
238 * file is reached without finding the chunk, then the file is not a
239 * valid WAVE file.
240 */
241 found = 0;
242 while (!found) {
243 if (read(fd, t1, 4)<4) {
244 qDebug("Could not read from sound file.\n");
245 return -1;
246 }
247 if (strncmp(t1, "fmt ", 4)) {
248 /* Determine the length of the chunk found and skip to the next
249 * chunk. The chunk length is always stored in the four bytes
250 * following the chunk id.
251 */
252 if (read(fd, &l1, 4)<4) {
253 qDebug("Could not read from sound file.\n");
254 return -1;
255 }
256 lseek(fd, l1, SEEK_CUR);
257 }
258 else {
259 /* This is the format chunk, which stores the playback settings
260 * for the recording.
261 */
262 /* Skip the length field, since we don't really need it. */
263 lseek(fd, 4, SEEK_CUR);
264 /* Read in the format tag. If it has a value of 1, then there is
265 * no compression and we can attempt to play the file
266 * back. Otherwise, return.
267 */
268 if (read(fd, &fmt, 2)<2) {
269 qDebug("Could not read from format chunk.\n");
270 return -1;
271 }
272 if (fmt != 1) {
273 qDebug("Wave file contains compressed data."
274 " Unable to continue.\n");
275 return -1;
276 }
277 /* Get the stereo mode. */
278 if (read(fd, &ch, 2)<2) {
279 qDebug("Could not read from format chunk.\n");
280 return -1;
281 }
282 else {
283 chan = ch;
284 qDebug("File has %d channels", chan);
285 }
286 /* Get the sample rate. */
287 if (read(fd, &srate, 4)<4) {
288 qDebug("Could not read from format chunk.\n");
289 return -1;
290 }
291 else {
292 sampleRate = srate;
293 qDebug("File has samplerate of %d", sampleRate);
294 }
295 /* Get the bit rate. This is at the end of the format chunk. */
296 lseek(fd, 6, SEEK_CUR);
297 if (read(fd, &brate, 2)<2) {
298 qDebug("Could not read from format chunk.\n");
299 return -1;
300 }
301 else {
302 resolution = brate;
303 qDebug("File has bitrate of %d", resolution);
304 }
305
306 found++;
307 }
308 }
309
310 /* Search through the file for the data chunk. If the end of the
311 * file is reached without finding the chunk, then the file is not a
312 * valid WAVE file.
313 */
314 found = 0;
315 while (!found) {
316 if (read(fd, t1, 4)<4) {
317 qDebug("Could not read from sound file.\n");
318 return -1;
319 }
320 if (strncmp(t1, "data", 4)) {
321 /* Determine the length of the chunk found and skip to the next
322 * chunk. The chunk length is always stored in the four bytes
323 * following the chunk id.
324 */
325 if (read(fd, &l1, 4)<4) {
326 qDebug("Could not read from sound file.\n");
327 return -1;
328 }
329 lseek(fd, l1, SEEK_CUR);
330 }
331 else {
332 /* This is the data chunk, which stores the recording. */
333 /* Get the length field. */
334 if (read(fd, &l1, 4)<4) {
335 qDebug("Could not read from sound file.\n");
336 return -1;
337 }
338 else {
339 samples =l1;
340 qDebug("file has length of %d\nlasting %d seconds",l1, (( l1 / sampleRate) / chan) / 2 ); // ????
341 return l1;
342 }
343 }
344 }
345
346 return 0;
347}
348
349//////////////////////////////////////////////////
194}; 350};
195 351
196 352
197WavPlugin::WavPlugin() { 353WavPlugin::WavPlugin() {
198 d = new WavPluginData; 354 d = new WavPluginData;
199 d->input = 0; 355 d->input = 0;
@@ -204,13 +360,13 @@ WavPlugin::~WavPlugin() {
204 close(); 360 close();
205 delete d; 361 delete d;
206} 362}
207 363
208 364
209bool WavPlugin::isFileSupported( const QString& path ) { 365bool WavPlugin::isFileSupported( const QString& path ) {
210// qDebug( "WavPlugin::isFileSupported" ); 366 debugMsg( "WavPlugin::isFileSupported" );
211 367
212 char *ext = strrchr( path.latin1(), '.' ); 368 char *ext = strrchr( path.latin1(), '.' );
213 369
214 // Test file extension 370 // Test file extension
215 if ( ext ) { 371 if ( ext ) {
216 if ( strncasecmp(ext, ".raw", 4) == 0 ) 372 if ( strncasecmp(ext, ".raw", 4) == 0 )
@@ -223,13 +379,13 @@ bool WavPlugin::isFileSupported( const QString& path ) {
223 379
224 return FALSE; 380 return FALSE;
225} 381}
226 382
227 383
228bool WavPlugin::open( const QString& path ) { 384bool WavPlugin::open( const QString& path ) {
229// qDebug( "WavPlugin::open" ); 385 qDebug( "WavPlugin::open" );
230 386
231 d->max = d->out = sound_buffer_size; 387 d->max = d->out = sound_buffer_size;
232 d->wavedata_remaining = 0; 388 d->wavedata_remaining = 0;
233 d->samples_due = 0; 389 d->samples_due = 0;
234 390
235 d->input = new QFile( path ); 391 d->input = new QFile( path );
@@ -237,67 +393,69 @@ bool WavPlugin::open( const QString& path ) {
237 qDebug("couldn't open file"); 393 qDebug("couldn't open file");
238 delete d->input; 394 delete d->input;
239 d->input = 0; 395 d->input = 0;
240 return FALSE; 396 return FALSE;
241 } 397 }
242 398
399// d->getWavSettings( d->input.handle());
243 d->initialise(); 400 d->initialise();
244 401
245 return TRUE; 402 return TRUE;
246} 403}
247 404
248 405
249bool WavPlugin::close() { 406bool WavPlugin::close() {
250// qDebug( "WavPlugin::close" ); 407 qDebug( "WavPlugin::close" );
251 408
252 d->input->close(); 409 d->input->close();
253 delete d->input; 410 delete d->input;
254 d->input = 0; 411 d->input = 0;
255 return TRUE; 412 return TRUE;
256} 413}
257 414
258 415
259bool WavPlugin::isOpen() { 416bool WavPlugin::isOpen() {
260// qDebug( "WavPlugin::isOpen" ); 417 qDebug( "WavPlugin::isOpen" );
261 return ( d->input != 0 ); 418 return ( d->input != 0 );
262} 419}
263 420
264 421
265int WavPlugin::audioStreams() { 422int WavPlugin::audioStreams() {
266// qDebug( "WavPlugin::audioStreams" ); 423 qDebug( "WavPlugin::audioStreams" );
267 return 1; 424 return 1;
268} 425}
269 426
270 427
271int WavPlugin::audioChannels( int ) { 428int WavPlugin::audioChannels( int ) {
272// qDebug( "WavPlugin::audioChannels" ); 429 debugMsg( "WavPlugin::audioChannels" );
273 return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples 430 return d->chan;
274} 431}
275 432
276 433
277int WavPlugin::audioFrequency( int ) { 434int WavPlugin::audioFrequency( int ) {
278// qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); 435 qDebug( "WavPlugin::audioFrequency" );
279 return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 436 return d->freq;
280} 437}
281 438
282 439
283int WavPlugin::audioSamples( int ) { 440int WavPlugin::audioSamples( int ) {
284// qDebug( "WavPlugin::audioSamples" ); 441 qDebug( "WavPlugin::audioSamples" );
285 return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, 442 return d->samples;
286 // Therefore if source is mono we will double the number of samples 443// return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo,
444// // Therefore if source is mono we will double the number of samples
287} 445}
288 446
289 447
290bool WavPlugin::audioSetSample( long, int ) { 448bool WavPlugin::audioSetSample( long, int ) {
291// qDebug( "WavPlugin::audioSetSample" ); 449 qDebug( "WavPlugin::audioSetSample" );
292 return FALSE; 450 return FALSE;
293} 451}
294 452
295 453
296long WavPlugin::audioGetSample( int ) { 454long WavPlugin::audioGetSample( int ) {
297// qDebug( "WavPlugin::audioGetSample" ); 455 qDebug( "WavPlugin::audioGetSample" );
298 return 0; 456 return 0;
299} 457}
300 458
301/* 459/*
302bool WavPlugin::audioReadSamples( short *, int, long, int ) { 460bool WavPlugin::audioReadSamples( short *, int, long, int ) {
303 debugMsg( "WavPlugin::audioReadSamples" ); 461 debugMsg( "WavPlugin::audioReadSamples" );
@@ -321,21 +479,16 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl
321 debugMsg( "WavPlugin::audioReadStereoSamples" ); 479 debugMsg( "WavPlugin::audioReadStereoSamples" );
322 return !d->add( output, samples, samplesMade, TRUE ); 480 return !d->add( output, samples, samplesMade, TRUE );
323} 481}
324*/ 482*/
325 483
326bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { 484bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) {
327// qDebug( "WavPlugin::audioReadSamples" ); 485 qDebug( "WavPlugin::audioReadSamples" );
328 return d->add( output, samples, samplesMade, channels != 1 ); 486 return d->add( output, samples, samplesMade, channels != 1 );
329} 487}
330 488
331double WavPlugin::getTime() { 489double WavPlugin::getTime() {
332// qDebug( "WavPlugin::getTime" ); 490 qDebug( "WavPlugin::getTime" );
333 return 0.0; 491 return 0.0;
334} 492}
335 493
336int WavPlugin::audioBitsPerSample( int ) {
337// qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample );
338 return d->chunkdata.wBitsPerSample; //
339}
340
341 494
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h
index 6afd67e..19d1a8e 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.h
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h
@@ -14,21 +14,18 @@
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
22#ifndef WAV_PLUGIN_H 20#ifndef WAV_PLUGIN_H
23#define WAV_PLUGIN_H 21#define WAV_PLUGIN_H
24 22
25
26#include <qstring.h> 23#include <qstring.h>
27#include <qapplication.h> 24#include <qapplication.h>
28#include "../mediaplayerplugininterface.h" 25#include <qpe/mediaplayerplugininterface.h>
29 26
30 27
31// #define OLD_MEDIAPLAYER_API 28// #define OLD_MEDIAPLAYER_API
32 29
33 30
34class WavPluginData; 31class WavPluginData;
@@ -51,13 +48,12 @@ public:
51 const QString &fileInfo() { return strInfo = ""; } 48 const QString &fileInfo() { return strInfo = ""; }
52 49
53 // If decoder doesn't support audio then return 0 here 50 // If decoder doesn't support audio then return 0 here
54 int audioStreams(); 51 int audioStreams();
55 int audioChannels( int stream ); 52 int audioChannels( int stream );
56 int audioFrequency( int stream ); 53 int audioFrequency( int stream );
57 int audioBitsPerSample( int stream );
58 int audioSamples( int stream ); 54 int audioSamples( int stream );
59 bool audioSetSample( long sample, int stream ); 55 bool audioSetSample( long sample, int stream );
60 long audioGetSample( int stream ); 56 long audioGetSample( int stream );
61#ifdef OLD_MEDIAPLAYER_API 57#ifdef OLD_MEDIAPLAYER_API
62 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 58 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
63 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 59 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp
index 1f7b85b..2923180 100644
--- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp
+++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp
@@ -17,13 +17,12 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "wavplugin.h" 20#include "wavplugin.h"
21#include "wavpluginimpl.h" 21#include "wavpluginimpl.h"
22 22
23
24WavPluginImpl::WavPluginImpl() 23WavPluginImpl::WavPluginImpl()
25 : libmadplugin(0), ref(0) 24 : libmadplugin(0), ref(0)
26{ 25{
27} 26}
28 27
29 28
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h
index ee32f54..71f5f20 100644
--- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h
+++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h
@@ -17,14 +17,13 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef WAV_PLUGIN_IMPL_H 20#ifndef WAV_PLUGIN_IMPL_H
21#define WAV_PLUGIN_IMPL_H 21#define WAV_PLUGIN_IMPL_H
22 22
23 23#include <qpe/mediaplayerplugininterface.h>
24#include "../mediaplayerplugininterface.h"
25 24
26 25
27class WavPlugin; 26class WavPlugin;
28 27
29 28
30class WavPluginImpl : public MediaPlayerPluginInterface 29class WavPluginImpl : public MediaPlayerPluginInterface