summaryrefslogtreecommitdiff
path: root/core
authorschurig <schurig>2003-06-14 06:05:13 (UTC)
committer schurig <schurig>2003-06-14 06:05:13 (UTC)
commit6b57a9fbe9f56e6af3911ea9337872c468b614b5 (patch) (side-by-side diff)
tree69ef7f20babceda2ba3ee8138cbd29bdd8587f46 /core
parentbbb4e35556d1d1a759dbe99bc155ecfc45e49c1b (diff)
downloadopie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.zip
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.gz
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.bz2
Adaptions for QT_QWS_DEVFS
Diffstat (limited to 'core') (more/less context) (show 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:
static int dspFd;
static bool muted;
static unsigned int leftVolume;
static unsigned int rightVolume;
};
#ifdef Q_WS_QWS
// This is for keeping the device open in-between playing files when
// the device makes clicks and it starts to drive you insane! :)
// Best to have the device not open when not using it though
//#define KEEP_DEVICE_OPEN
#endif
int AudioDevicePrivate::dspFd = 0;
bool AudioDevicePrivate::muted = FALSE;
unsigned int AudioDevicePrivate::leftVolume = 0;
unsigned int AudioDevicePrivate::rightVolume = 0;
void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
muted = AudioDevicePrivate::muted;
unsigned int volume;
+#ifdef QT_QWS_DEVFS
+ int mixerHandle = open( "/dev/sound/mixer", O_RDWR );
+#else
int mixerHandle = open( "/dev/mixer", O_RDWR );
+#endif
if ( mixerHandle >= 0 ) {
if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
perror("ioctl(\"MIXER_READ\")");
close( mixerHandle );
} else
perror("open(\"/dev/mixer\")");
leftVolume = ((volume & 0x00FF) << 16) / 101;
rightVolume = ((volume & 0xFF00) << 8) / 101;
}
void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
AudioDevicePrivate::muted = muted;
if ( muted ) {
AudioDevicePrivate::leftVolume = leftVolume;
AudioDevicePrivate::rightVolume = rightVolume;
leftVolume = 0;
rightVolume = 0;
} else {
leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
}
// Volume can be from 0 to 100 which is 101 distinct values
unsigned int rV = (rightVolume * 101) >> 16;
# if 0
unsigned int lV = (leftVolume * 101) >> 16;
unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
int mixerHandle = 0;
+#ifdef QT_QWS_DEVFS
+ if ( ( mixerHandle = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
+#else
if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
+#endif
if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
perror("ioctl(\"MIXER_WRITE\")");
close( mixerHandle );
} else
perror("open(\"/dev/mixer\")");
# else
// This is the way this has to be done now I guess, doesn't allow for
// independant right and left channel setting, or setting for different outputs
Config cfg("qpe"); // qtopia is "Sound"
cfg.setGroup("Volume"); // qtopia is "Settings"
cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
# endif
//#endif
// qDebug( "setting volume to: 0x%x", volume );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
// Send notification that the volume has changed
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
#endif
}
AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
// qDebug("creating new audio device");
// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
d = new AudioDevicePrivate;
d->frequency = f;
d->channels = chs;
d->bytesPerSample = bps;
// qDebug("%d",bps);
int format=0;
if( bps == 8) format = AFMT_U8;
else if( bps <= 0) format = AFMT_S16_LE;
else format = AFMT_S16_LE;
// qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
int fragments = 0x10000 * 8 + sound_fragment_shift;
int capabilities = 0;
#ifdef KEEP_DEVICE_OPEN
if ( AudioDevicePrivate::dspFd == 0 ) {
#endif
+#ifdef QT_QWS_DEVFS
+ if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) {
+#else
if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
+#endif
-// perror("open(\"/dev/dsp\") sending to /dev/null instead");
perror("open(\"/dev/dsp\")");
QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
exit(-1); //harsh?
-// d->handle = ::open( "/dev/null", O_WRONLY );
- // WTF?!?!
}
#ifdef KEEP_DEVICE_OPEN
AudioDevicePrivate::dspFd = d->handle;
} else {
d->handle = AudioDevicePrivate::dspFd;
}
#endif
if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
// qDebug("freq %d", d->frequency);
if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
perror("ioctl(\"SNDCTL_DSP_SPEED\")");
// qDebug("channels %d",d->channels);
if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
d->channels = ( d->channels == 1 ) ? 2 : d->channels;
if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
}
// 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 ) {
fd->clip_x = 0;
fd->clip_y = 0;
fd->clip_width = 0;
fd->clip_height = 0;
char *buffer;
long size;
int status;
struct FlashInfo fi;
if (readFile(fileName.latin1(), &buffer, &size) < 0)
exit(2);
if (!(file = FlashNew()))
exit(1);
do
status = FlashParse(file, 0, buffer, size);
while (status & FLASH_PARSE_NEED_DATA);
free(buffer);
FlashGetInfo(file, &fi);
//FlashSettings(flashHandle, PLAYER_LOOP);
FlashGraphicInit(file, fd);
+#ifdef QT_QWS_DEVFS
+ FlashSoundInit(file, "/dev/sound/dsp");
+#else
FlashSoundInit(file, "/dev/dsp");
+#endif
FlashSetGetUrlMethod(file, showUrl, 0);
FlashSetGetSwfMethod(file, getSwf, (void*)file);
printf("opened file\n");
}
// If decoder doesn't support audio then return 0 here
bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; }
long LibFlashPlugin::audioGetSample( int stream ) { return 0; }
//bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; }
//bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; }
bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; }
//bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
//bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
// If decoder doesn't support video then return 0 here
int LibFlashPlugin::videoStreams() { return 1; }
int LibFlashPlugin::videoWidth( int stream ) { return 300; }
int LibFlashPlugin::videoHeight( int stream ) { return 200; }
double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; }
int LibFlashPlugin::videoFrames( int stream ) { return 1000000; }
bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; }
long LibFlashPlugin::videoGetFrame( int stream ) { return 0; }
bool 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)
void PlayListWidget::keyPressEvent( QKeyEvent *)
{
// qDebug("Key press");
// switch ( e->key() ) {
// ////////////////////////////// Zaurus keys
// case Key_A: //add to playlist
// qDebug("Add");
// addSelected();
// break;
// case Key_R: //remove from playlist
// removeSelected();
// break;
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
// case Key_Space:
// qDebug("Play");
// playSelected();
// break;
// }
}
void PlayListWidget::doBlank() {
- // qDebug("do blanking");
+ // TODO: why do we blank this way, why don't we use ODevice or ScreenSaver?
+#ifdef QT_QWS_DEVFS
+ fd=open("/dev/fb/0",O_RDWR);
+#else
fd=open("/dev/fb0",O_RDWR);
+#endif
if (fd != -1) {
ioctl(fd,FBIOBLANK,1);
// close(fd);
}
}
void PlayListWidget::doUnblank() {
// this crashes opieplayer with a segfault
// int fd;
// fd=open("/dev/fb0",O_RDWR);
// qDebug("do unblanking");
if (fd != -1) {
ioctl(fd,FBIOBLANK,0);
close(fd);
}
QCopEnvelope h("QPE/System", "setBacklight(int)");
h <<-3;// v[1]; // -3 Force on
}
void PlayListWidget::populateSkinsMenu() {
int item = 0;
defaultSkinIndex = 0;
QString skinName;
Config cfg( "OpiePlayer" );