summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiodevice.cpp
authorllornkcor <llornkcor>2002-06-17 12:54:54 (UTC)
committer llornkcor <llornkcor>2002-06-17 12:54:54 (UTC)
commit282007e58a8a038a0db042341528510e73ac80fc (patch) (side-by-side diff)
treef1a16c9a6a380bdc4217e9f92ac6ef6128d10717 /core/multimedia/opieplayer/audiodevice.cpp
parent2917d7481dc8c1b053e3212a699e64948a90ec4c (diff)
downloadopie-282007e58a8a038a0db042341528510e73ac80fc.zip
opie-282007e58a8a038a0db042341528510e73ac80fc.tar.gz
opie-282007e58a8a038a0db042341528510e73ac80fc.tar.bz2
fixes for goofy crap going on
Diffstat (limited to 'core/multimedia/opieplayer/audiodevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 3262e38..4c5f12d 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -31,10 +31,9 @@
#endif
-#ifdef Q_WS_WIN
-#include <windows.h>
-#include <mmsystem.h>
-#include <mmreg.h>
-#endif
-
+// #ifdef Q_WS_WIN
+// #include <windows.h>
+// #include <mmsystem.h>
+// #include <mmreg.h>
+// #endif
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
#include <fcntl.h>
@@ -47,9 +46,9 @@
#endif
-#if defined(Q_OS_WIN32)
-static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
-static const int timerResolutionMilliSeconds = 30;
-static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
-#else
+// #if defined(Q_OS_WIN32)
+// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
+// static const int timerResolutionMilliSeconds = 30;
+// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
+// #else
# if defined(QT_QWS_IPAQ)
static const int sound_fragment_shift = 14;
@@ -58,5 +57,5 @@ static const int sound_fragment_shift = 16;
# endif
static const int sound_fragment_bytes = (1<<sound_fragment_shift);
-#endif
+//#endif
@@ -68,9 +67,9 @@ public:
unsigned int bytesPerSample;
unsigned int bufferSize;
-#ifndef Q_OS_WIN32
+//#ifndef Q_OS_WIN32
bool can_GETOSPACE;
char* unwrittenBuffer;
unsigned int unwritten;
-#endif
+//#endif
static int dspFd;
@@ -98,21 +97,21 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
muted = AudioDevicePrivate::muted;
unsigned int volume;
-#ifdef Q_OS_WIN32
- HWAVEOUT handle;
- WAVEFORMATEX formatData;
- formatData.cbSize = sizeof(WAVEFORMATEX);
- formatData.wFormatTag = WAVE_FORMAT_PCM;
- formatData.nAvgBytesPerSec = 4 * 44000;
- formatData.nBlockAlign = 4;
- formatData.nChannels = 2;
- formatData.nSamplesPerSec = 44000;
- formatData.wBitsPerSample = 16;
- waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
- if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
-// qDebug( "get volume of audio device failed" );
- waveOutClose( handle );
- leftVolume = volume & 0xFFFF;
- rightVolume = volume >> 16;
-#else
+// #ifdef Q_OS_WIN32
+// HWAVEOUT handle;
+// WAVEFORMATEX formatData;
+// formatData.cbSize = sizeof(WAVEFORMATEX);
+// formatData.wFormatTag = WAVE_FORMAT_PCM;
+// formatData.nAvgBytesPerSec = 4 * 44000;
+// formatData.nBlockAlign = 4;
+// formatData.nChannels = 2;
+// formatData.nSamplesPerSec = 44000;
+// formatData.wBitsPerSample = 16;
+// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
+// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
+// // qDebug( "get volume of audio device failed" );
+// waveOutClose( handle );
+// leftVolume = volume & 0xFFFF;
+// rightVolume = volume >> 16;
+// #else
int mixerHandle = open( "/dev/mixer", O_RDWR );
if ( mixerHandle >= 0 ) {
@@ -124,5 +123,5 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
leftVolume = ((volume & 0x00FF) << 16) / 101;
rightVolume = ((volume & 0xFF00) << 8) / 101;
-#endif
+//#endif
}
@@ -139,20 +138,20 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
}
-#ifdef Q_OS_WIN32
- HWAVEOUT handle;
- WAVEFORMATEX formatData;
- formatData.cbSize = sizeof(WAVEFORMATEX);
- formatData.wFormatTag = WAVE_FORMAT_PCM;
- formatData.nAvgBytesPerSec = 4 * 44000;
- formatData.nBlockAlign = 4;
- formatData.nChannels = 2;
- formatData.nSamplesPerSec = 44000;
- formatData.wBitsPerSample = 16;
- waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
- unsigned int volume = (rightVolume << 16) | leftVolume;
- if ( waveOutSetVolume( handle, volume ) )
-// qDebug( "set volume of audio device failed" );
- waveOutClose( handle );
-#else
+// #ifdef Q_OS_WIN32
+// HWAVEOUT handle;
+// WAVEFORMATEX formatData;
+// formatData.cbSize = sizeof(WAVEFORMATEX);
+// formatData.wFormatTag = WAVE_FORMAT_PCM;
+// formatData.nAvgBytesPerSec = 4 * 44000;
+// formatData.nBlockAlign = 4;
+// formatData.nChannels = 2;
+// formatData.nSamplesPerSec = 44000;
+// formatData.wBitsPerSample = 16;
+// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
+// unsigned int volume = (rightVolume << 16) | leftVolume;
+// if ( waveOutSetVolume( handle, volume ) )
+// // qDebug( "set volume of audio device failed" );
+// waveOutClose( handle );
+// #else
// Volume can be from 0 to 100 which is 101 distinct values
unsigned int rV = (rightVolume * 101) >> 16;
@@ -177,5 +176,5 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
# endif
-#endif
+//#endif
// qDebug( "setting volume to: 0x%x", volume );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
@@ -257,7 +256,7 @@ AudioDevice::~AudioDevice() {
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
-#ifdef Q_OS_WIN32
- waveOutClose( (HWAVEOUT)d->handle );
-#else
+// #ifdef Q_OS_WIN32
+// waveOutClose( (HWAVEOUT)d->handle );
+// #else
# ifndef KEEP_DEVICE_OPEN
close( d->handle ); // Now it should be safe to shut the handle
@@ -265,5 +264,6 @@ AudioDevice::~AudioDevice() {
delete d->unwrittenBuffer;
delete d;
-#endif
+//#endif
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
}
@@ -278,18 +278,18 @@ void AudioDevice::volumeChanged( bool muted )
void AudioDevice::write( char *buffer, unsigned int length )
{
-#ifdef Q_OS_WIN32
- // returns immediately and (to be implemented) emits completedIO() when finished writing
- WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
- // maybe the buffer should be copied so that this fool proof, but its a performance hit
- lpWaveHdr->lpData = buffer;
- lpWaveHdr->dwBufferLength = length;
- lpWaveHdr->dwFlags = 0L;
- lpWaveHdr->dwLoops = 0L;
- waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
- // waveOutWrite returns immediately. the data is sent in the background.
- if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
- qDebug( "failed to write block to audio device" );
- // emit completedIO();
-#else
+// #ifdef Q_OS_WIN32
+// // returns immediately and (to be implemented) emits completedIO() when finished writing
+// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
+// // maybe the buffer should be copied so that this fool proof, but its a performance hit
+// lpWaveHdr->lpData = buffer;
+// lpWaveHdr->dwBufferLength = length;
+// lpWaveHdr->dwFlags = 0L;
+// lpWaveHdr->dwLoops = 0L;
+// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
+// // waveOutWrite returns immediately. the data is sent in the background.
+// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
+// qDebug( "failed to write block to audio device" );
+// // emit completedIO();
+// #else
int t = ::write( d->handle, buffer, length );
if ( t<0 ) t = 0;
@@ -299,5 +299,5 @@ void AudioDevice::write( char *buffer, unsigned int length )
d->unwritten = length-t;
}
-#endif
+//#endif
}
@@ -328,7 +328,7 @@ unsigned int AudioDevice::bufferSize() const
unsigned int AudioDevice::canWrite() const
{
-#ifdef Q_OS_WIN32
- return bufferSize(); // Any better?
-#else
+// #ifdef Q_OS_WIN32
+// return bufferSize(); // Any better?
+// #else
audio_buf_info info;
if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
@@ -355,17 +355,17 @@ unsigned int AudioDevice::canWrite() const
return d->bufferSize;
}
-#endif
+//#endif
}
int AudioDevice::bytesWritten() {
-#ifdef Q_OS_WIN32
- MMTIME pmmt = { TIME_BYTES, 0 };
- if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
- qDebug( "failed to get audio device position" );
- return -1;
- }
- return pmmt.u.cb;
-#else
+// #ifdef Q_OS_WIN32
+// MMTIME pmmt = { TIME_BYTES, 0 };
+// if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
+// qDebug( "failed to get audio device position" );
+// return -1;
+// }
+// return pmmt.u.cb;
+// #else
int buffered = 0;
if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
@@ -374,5 +374,5 @@ int AudioDevice::bytesWritten() {
}
return buffered;
-#endif
+//#endif
}