summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer
authorschurig <schurig>2003-06-14 06:05:13 (UTC)
committer schurig <schurig>2003-06-14 06:05:13 (UTC)
commit6b57a9fbe9f56e6af3911ea9337872c468b614b5 (patch) (unidiff)
tree69ef7f20babceda2ba3ee8138cbd29bdd8587f46 /core/multimedia/opieplayer
parentbbb4e35556d1d1a759dbe99bc155ecfc45e49c1b (diff)
downloadopie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.zip
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.gz
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.bz2
Adaptions for QT_QWS_DEVFS
Diffstat (limited to 'core/multimedia/opieplayer') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp15
-rw-r--r--core/multimedia/opieplayer/libflash/libflashplugin.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp6
3 files changed, 21 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index d01d2ba..6a38fc9 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -70,134 +70,143 @@ public:
70 static int dspFd; 70 static int dspFd;
71 static bool muted; 71 static bool muted;
72 static unsigned int leftVolume; 72 static unsigned int leftVolume;
73 static unsigned int rightVolume; 73 static unsigned int rightVolume;
74}; 74};
75 75
76 76
77#ifdef Q_WS_QWS 77#ifdef Q_WS_QWS
78// This is for keeping the device open in-between playing files when 78// This is for keeping the device open in-between playing files when
79// the device makes clicks and it starts to drive you insane! :) 79// the device makes clicks and it starts to drive you insane! :)
80// Best to have the device not open when not using it though 80// Best to have the device not open when not using it though
81//#define KEEP_DEVICE_OPEN 81//#define KEEP_DEVICE_OPEN
82#endif 82#endif
83 83
84 84
85int AudioDevicePrivate::dspFd = 0; 85int AudioDevicePrivate::dspFd = 0;
86bool AudioDevicePrivate::muted = FALSE; 86bool AudioDevicePrivate::muted = FALSE;
87unsigned int AudioDevicePrivate::leftVolume = 0; 87unsigned int AudioDevicePrivate::leftVolume = 0;
88unsigned int AudioDevicePrivate::rightVolume = 0; 88unsigned int AudioDevicePrivate::rightVolume = 0;
89 89
90 90
91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
92 muted = AudioDevicePrivate::muted; 92 muted = AudioDevicePrivate::muted;
93 unsigned int volume; 93 unsigned int volume;
94#ifdef QT_QWS_DEVFS
95 int mixerHandle = open( "/dev/sound/mixer", O_RDWR );
96#else
94 int mixerHandle = open( "/dev/mixer", O_RDWR ); 97 int mixerHandle = open( "/dev/mixer", O_RDWR );
98#endif
95 if ( mixerHandle >= 0 ) { 99 if ( mixerHandle >= 0 ) {
96 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 100 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
97 perror("ioctl(\"MIXER_READ\")"); 101 perror("ioctl(\"MIXER_READ\")");
98 close( mixerHandle ); 102 close( mixerHandle );
99 } else 103 } else
100 perror("open(\"/dev/mixer\")"); 104 perror("open(\"/dev/mixer\")");
101 leftVolume = ((volume & 0x00FF) << 16) / 101; 105 leftVolume = ((volume & 0x00FF) << 16) / 101;
102 rightVolume = ((volume & 0xFF00) << 8) / 101; 106 rightVolume = ((volume & 0xFF00) << 8) / 101;
103} 107}
104 108
105 109
106void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 110void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
107 AudioDevicePrivate::muted = muted; 111 AudioDevicePrivate::muted = muted;
108 if ( muted ) { 112 if ( muted ) {
109 AudioDevicePrivate::leftVolume = leftVolume; 113 AudioDevicePrivate::leftVolume = leftVolume;
110 AudioDevicePrivate::rightVolume = rightVolume; 114 AudioDevicePrivate::rightVolume = rightVolume;
111 leftVolume = 0; 115 leftVolume = 0;
112 rightVolume = 0; 116 rightVolume = 0;
113 } else { 117 } else {
114 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 118 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
115 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 119 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
116 } 120 }
117 // Volume can be from 0 to 100 which is 101 distinct values 121 // Volume can be from 0 to 100 which is 101 distinct values
118 unsigned int rV = (rightVolume * 101) >> 16; 122 unsigned int rV = (rightVolume * 101) >> 16;
119 123
120# if 0 124# if 0
121 unsigned int lV = (leftVolume * 101) >> 16; 125 unsigned int lV = (leftVolume * 101) >> 16;
122 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 126 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
123 int mixerHandle = 0; 127 int mixerHandle = 0;
128#ifdef QT_QWS_DEVFS
129 if ( ( mixerHandle = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
130#else
124 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 131 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
132#endif
125 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 133 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
126 perror("ioctl(\"MIXER_WRITE\")"); 134 perror("ioctl(\"MIXER_WRITE\")");
127 close( mixerHandle ); 135 close( mixerHandle );
128 } else 136 } else
129 perror("open(\"/dev/mixer\")"); 137 perror("open(\"/dev/mixer\")");
130 138
131# else 139# else
132 // This is the way this has to be done now I guess, doesn't allow for 140 // This is the way this has to be done now I guess, doesn't allow for
133 // independant right and left channel setting, or setting for different outputs 141 // independant right and left channel setting, or setting for different outputs
134 Config cfg("qpe"); // qtopia is "Sound" 142 Config cfg("qpe"); // qtopia is "Sound"
135 cfg.setGroup("Volume"); // qtopia is "Settings" 143 cfg.setGroup("Volume"); // qtopia is "Settings"
136 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume 144 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
137# endif 145# endif
138 146
139//#endif 147//#endif
140// qDebug( "setting volume to: 0x%x", volume ); 148// qDebug( "setting volume to: 0x%x", volume );
141#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 149#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
142 // Send notification that the volume has changed 150 // Send notification that the volume has changed
143 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 151 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
144#endif 152#endif
145} 153}
146 154
147 155
148 156
149AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 157AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
150 // qDebug("creating new audio device"); 158 // qDebug("creating new audio device");
151// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 159// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
152 d = new AudioDevicePrivate; 160 d = new AudioDevicePrivate;
153 d->frequency = f; 161 d->frequency = f;
154 d->channels = chs; 162 d->channels = chs;
155 d->bytesPerSample = bps; 163 d->bytesPerSample = bps;
156 // qDebug("%d",bps); 164 // qDebug("%d",bps);
157 int format=0; 165 int format=0;
158 if( bps == 8) format = AFMT_U8; 166 if( bps == 8) format = AFMT_U8;
159 else if( bps <= 0) format = AFMT_S16_LE; 167 else if( bps <= 0) format = AFMT_S16_LE;
160 else format = AFMT_S16_LE; 168 else format = AFMT_S16_LE;
161 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 169 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
162 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 170 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
163 171
164 int fragments = 0x10000 * 8 + sound_fragment_shift; 172 int fragments = 0x10000 * 8 + sound_fragment_shift;
165 int capabilities = 0; 173 int capabilities = 0;
166 174
167 175
168#ifdef KEEP_DEVICE_OPEN 176#ifdef KEEP_DEVICE_OPEN
169 if ( AudioDevicePrivate::dspFd == 0 ) { 177 if ( AudioDevicePrivate::dspFd == 0 ) {
170#endif 178#endif
179#ifdef QT_QWS_DEVFS
180 if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) {
181#else
171 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 182 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
183#endif
172 184
173// perror("open(\"/dev/dsp\") sending to /dev/null instead");
174 perror("open(\"/dev/dsp\")"); 185 perror("open(\"/dev/dsp\")");
175 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); 186 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
176 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); 187 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
177 exit(-1); //harsh? 188 exit(-1); //harsh?
178// d->handle = ::open( "/dev/null", O_WRONLY );
179 // WTF?!?!
180 } 189 }
181#ifdef KEEP_DEVICE_OPEN 190#ifdef KEEP_DEVICE_OPEN
182 AudioDevicePrivate::dspFd = d->handle; 191 AudioDevicePrivate::dspFd = d->handle;
183 } else { 192 } else {
184 d->handle = AudioDevicePrivate::dspFd; 193 d->handle = AudioDevicePrivate::dspFd;
185 } 194 }
186#endif 195#endif
187 196
188 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 197 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
189 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 198 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
190 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 199 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
191 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 200 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
192 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 201 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
193 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 202 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
194 // qDebug("freq %d", d->frequency); 203 // qDebug("freq %d", d->frequency);
195 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 204 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
196 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 205 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
197 // qDebug("channels %d",d->channels); 206 // qDebug("channels %d",d->channels);
198 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 207 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
199 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 208 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
200 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 209 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
201 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 210 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
202 } 211 }
203// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 212// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.cpp b/core/multimedia/opieplayer/libflash/libflashplugin.cpp
index 538c695..78cf555 100644
--- a/core/multimedia/opieplayer/libflash/libflashplugin.cpp
+++ b/core/multimedia/opieplayer/libflash/libflashplugin.cpp
@@ -130,49 +130,53 @@ bool LibFlashPlugin::open( const QString& fileName ) {
130 fd->clip_x = 0; 130 fd->clip_x = 0;
131 fd->clip_y = 0; 131 fd->clip_y = 0;
132 fd->clip_width = 0; 132 fd->clip_width = 0;
133 fd->clip_height = 0; 133 fd->clip_height = 0;
134 134
135 char *buffer; 135 char *buffer;
136 long size; 136 long size;
137 int status; 137 int status;
138 struct FlashInfo fi; 138 struct FlashInfo fi;
139 139
140 if (readFile(fileName.latin1(), &buffer, &size) < 0) 140 if (readFile(fileName.latin1(), &buffer, &size) < 0)
141 exit(2); 141 exit(2);
142 142
143 if (!(file = FlashNew())) 143 if (!(file = FlashNew()))
144 exit(1); 144 exit(1);
145 145
146 do 146 do
147 status = FlashParse(file, 0, buffer, size); 147 status = FlashParse(file, 0, buffer, size);
148 while (status & FLASH_PARSE_NEED_DATA); 148 while (status & FLASH_PARSE_NEED_DATA);
149 149
150 free(buffer); 150 free(buffer);
151 FlashGetInfo(file, &fi); 151 FlashGetInfo(file, &fi);
152 //FlashSettings(flashHandle, PLAYER_LOOP); 152 //FlashSettings(flashHandle, PLAYER_LOOP);
153 FlashGraphicInit(file, fd); 153 FlashGraphicInit(file, fd);
154#ifdef QT_QWS_DEVFS
155 FlashSoundInit(file, "/dev/sound/dsp");
156#else
154 FlashSoundInit(file, "/dev/dsp"); 157 FlashSoundInit(file, "/dev/dsp");
158#endif
155 FlashSetGetUrlMethod(file, showUrl, 0); 159 FlashSetGetUrlMethod(file, showUrl, 0);
156 FlashSetGetSwfMethod(file, getSwf, (void*)file); 160 FlashSetGetSwfMethod(file, getSwf, (void*)file);
157 161
158 printf("opened file\n"); 162 printf("opened file\n");
159} 163}
160 164
161// If decoder doesn't support audio then return 0 here 165// If decoder doesn't support audio then return 0 here
162bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; } 166bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; }
163long LibFlashPlugin::audioGetSample( int stream ) { return 0; } 167long LibFlashPlugin::audioGetSample( int stream ) { return 0; }
164//bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; } 168//bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; }
165//bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; } 169//bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; }
166bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; } 170bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; }
167//bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } 171//bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
168//bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } 172//bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
169 173
170// If decoder doesn't support video then return 0 here 174// If decoder doesn't support video then return 0 here
171int LibFlashPlugin::videoStreams() { return 1; } 175int LibFlashPlugin::videoStreams() { return 1; }
172int LibFlashPlugin::videoWidth( int stream ) { return 300; } 176int LibFlashPlugin::videoWidth( int stream ) { return 300; }
173int LibFlashPlugin::videoHeight( int stream ) { return 200; } 177int LibFlashPlugin::videoHeight( int stream ) { return 200; }
174double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; } 178double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; }
175int LibFlashPlugin::videoFrames( int stream ) { return 1000000; } 179int LibFlashPlugin::videoFrames( int stream ) { return 1000000; }
176bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; } 180bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; }
177long LibFlashPlugin::videoGetFrame( int stream ) { return 0; } 181long LibFlashPlugin::videoGetFrame( int stream ) { return 0; }
178bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { return TRUE; } 182bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { return TRUE; }
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index efea385..b393230 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1351,50 +1351,54 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1351void PlayListWidget::keyPressEvent( QKeyEvent *) 1351void PlayListWidget::keyPressEvent( QKeyEvent *)
1352{ 1352{
1353// qDebug("Key press"); 1353// qDebug("Key press");
1354// switch ( e->key() ) { 1354// switch ( e->key() ) {
1355// ////////////////////////////// Zaurus keys 1355// ////////////////////////////// Zaurus keys
1356// case Key_A: //add to playlist 1356// case Key_A: //add to playlist
1357// qDebug("Add"); 1357// qDebug("Add");
1358// addSelected(); 1358// addSelected();
1359// break; 1359// break;
1360// case Key_R: //remove from playlist 1360// case Key_R: //remove from playlist
1361// removeSelected(); 1361// removeSelected();
1362// break; 1362// break;
1363// case Key_P: //play 1363// case Key_P: //play
1364// qDebug("Play"); 1364// qDebug("Play");
1365// playSelected(); 1365// playSelected();
1366// break; 1366// break;
1367// case Key_Space: 1367// case Key_Space:
1368// qDebug("Play"); 1368// qDebug("Play");
1369// playSelected(); 1369// playSelected();
1370// break; 1370// break;
1371// } 1371// }
1372} 1372}
1373 1373
1374void PlayListWidget::doBlank() { 1374void PlayListWidget::doBlank() {
1375 // qDebug("do blanking"); 1375 // TODO: why do we blank this way, why don't we use ODevice or ScreenSaver?
1376#ifdef QT_QWS_DEVFS
1377 fd=open("/dev/fb/0",O_RDWR);
1378#else
1376 fd=open("/dev/fb0",O_RDWR); 1379 fd=open("/dev/fb0",O_RDWR);
1380#endif
1377 if (fd != -1) { 1381 if (fd != -1) {
1378 ioctl(fd,FBIOBLANK,1); 1382 ioctl(fd,FBIOBLANK,1);
1379 // close(fd); 1383 // close(fd);
1380 } 1384 }
1381} 1385}
1382 1386
1383void PlayListWidget::doUnblank() { 1387void PlayListWidget::doUnblank() {
1384 // this crashes opieplayer with a segfault 1388 // this crashes opieplayer with a segfault
1385 // int fd; 1389 // int fd;
1386 // fd=open("/dev/fb0",O_RDWR); 1390 // fd=open("/dev/fb0",O_RDWR);
1387 // qDebug("do unblanking"); 1391 // qDebug("do unblanking");
1388 if (fd != -1) { 1392 if (fd != -1) {
1389 ioctl(fd,FBIOBLANK,0); 1393 ioctl(fd,FBIOBLANK,0);
1390 close(fd); 1394 close(fd);
1391 } 1395 }
1392 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1396 QCopEnvelope h("QPE/System", "setBacklight(int)");
1393 h <<-3;// v[1]; // -3 Force on 1397 h <<-3;// v[1]; // -3 Force on
1394} 1398}
1395 1399
1396void PlayListWidget::populateSkinsMenu() { 1400void PlayListWidget::populateSkinsMenu() {
1397 int item = 0; 1401 int item = 0;
1398 defaultSkinIndex = 0; 1402 defaultSkinIndex = 0;
1399 QString skinName; 1403 QString skinName;
1400 Config cfg( "OpiePlayer" ); 1404 Config cfg( "OpiePlayer" );