author | llornkcor <llornkcor> | 2002-06-22 01:38:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-22 01:38:20 (UTC) |
commit | 9adc4e5ab0a07eda196fffc8921da2d2d4f273e7 (patch) (unidiff) | |
tree | 91500597f01f145b5ec5a6ff80e812c59f95317f /core | |
parent | 28f2e6b92c40125172c9716790dc98cc30abc7fc (diff) | |
download | opie-9adc4e5ab0a07eda196fffc8921da2d2d4f273e7.zip opie-9adc4e5ab0a07eda196fffc8921da2d2d4f273e7.tar.gz opie-9adc4e5ab0a07eda196fffc8921da2d2d4f273e7.tar.bz2 |
new action if /dev/dsp can't open, instead of sending to bytes to /dev/null.. lets immediately exit
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 15 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 10 |
2 files changed, 18 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index faadd72..8f04d0d 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -3,50 +3,55 @@ | |||
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 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 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 | 20 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 |
21 | 21 | ||
22 | 22 | ||
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qmessagebox.h> | ||
28 | |||
27 | #include "audiodevice.h" | 29 | #include "audiodevice.h" |
28 | 30 | ||
31 | |||
32 | #include <errno.h> | ||
33 | |||
29 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 34 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
30 | #include "qpe/qcopenvelope_qws.h" | 35 | #include "qpe/qcopenvelope_qws.h" |
31 | #endif | 36 | #endif |
32 | 37 | ||
33 | // #ifdef Q_WS_WIN | 38 | // #ifdef Q_WS_WIN |
34 | // #include <windows.h> | 39 | // #include <windows.h> |
35 | // #include <mmsystem.h> | 40 | // #include <mmsystem.h> |
36 | // #include <mmreg.h> | 41 | // #include <mmreg.h> |
37 | // #endif | 42 | // #endif |
38 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 43 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
39 | #include <fcntl.h> | 44 | #include <fcntl.h> |
40 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
41 | #include <sys/soundcard.h> | 46 | #include <sys/soundcard.h> |
42 | #include <sys/stat.h> | 47 | #include <sys/stat.h> |
43 | #include <sys/time.h> | 48 | #include <sys/time.h> |
44 | #include <sys/types.h> | 49 | #include <sys/types.h> |
45 | #include <unistd.h> | 50 | #include <unistd.h> |
46 | #endif | 51 | #endif |
47 | 52 | ||
48 | // #if defined(Q_OS_WIN32) | 53 | // #if defined(Q_OS_WIN32) |
49 | // static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; | 54 | // static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; |
50 | // static const int timerResolutionMilliSeconds = 30; | 55 | // static const int timerResolutionMilliSeconds = 30; |
51 | // static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; | 56 | // static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; |
52 | // #else | 57 | // #else |
@@ -188,50 +193,56 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
188 | 193 | ||
189 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
190 | qDebug("creating new audio device"); | 195 | qDebug("creating new audio device"); |
191 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 196 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
192 | d = new AudioDevicePrivate; | 197 | d = new AudioDevicePrivate; |
193 | d->frequency = f; | 198 | d->frequency = f; |
194 | d->channels = chs; | 199 | d->channels = chs; |
195 | d->bytesPerSample = bps; | 200 | d->bytesPerSample = bps; |
196 | qDebug("%d",bps); | 201 | qDebug("%d",bps); |
197 | int format=0; | 202 | int format=0; |
198 | if( bps == 8) format = AFMT_U8; | 203 | if( bps == 8) format = AFMT_U8; |
199 | else if( bps <= 0) format = AFMT_S16_LE; | 204 | else if( bps <= 0) format = AFMT_S16_LE; |
200 | else format = AFMT_S16_LE; | 205 | else format = AFMT_S16_LE; |
201 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | 206 | 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) ) ); | 207 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
203 | 208 | ||
204 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 209 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
205 | int capabilities = 0; | 210 | int capabilities = 0; |
206 | 211 | ||
207 | 212 | ||
208 | #ifdef KEEP_DEVICE_OPEN | 213 | #ifdef KEEP_DEVICE_OPEN |
209 | if ( AudioDevicePrivate::dspFd == 0 ) { | 214 | if ( AudioDevicePrivate::dspFd == 0 ) { |
210 | #endif | 215 | #endif |
211 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 216 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
212 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); | 217 | |
213 | d->handle = ::open( "/dev/null", O_WRONLY ); | 218 | // perror("open(\"/dev/dsp\") sending to /dev/null instead"); |
219 | perror("open(\"/dev/dsp\")"); | ||
220 | QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); | ||
221 | QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); | ||
222 | exit(-1); //harsh? | ||
223 | // d->handle = ::open( "/dev/null", O_WRONLY ); | ||
224 | // WTF?!?! | ||
214 | } | 225 | } |
215 | #ifdef KEEP_DEVICE_OPEN | 226 | #ifdef KEEP_DEVICE_OPEN |
216 | AudioDevicePrivate::dspFd = d->handle; | 227 | AudioDevicePrivate::dspFd = d->handle; |
217 | } else { | 228 | } else { |
218 | d->handle = AudioDevicePrivate::dspFd; | 229 | d->handle = AudioDevicePrivate::dspFd; |
219 | } | 230 | } |
220 | #endif | 231 | #endif |
221 | 232 | ||
222 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 233 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
223 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 234 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
224 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 235 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
225 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 236 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
226 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | 237 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) |
227 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
228 | qDebug("freq %d", d->frequency); | 239 | qDebug("freq %d", d->frequency); |
229 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | 240 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) |
230 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 241 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
231 | qDebug("channels %d",d->channels); | 242 | qDebug("channels %d",d->channels); |
232 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 243 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
233 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 244 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
234 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 245 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
235 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 246 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
236 | } | 247 | } |
237 | 248 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index ae25fe3..0332237 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -396,61 +396,61 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
396 | // next time... | 396 | // next time... |
397 | if ( !QFile::exists( lnk->linkFile() ) ) { | 397 | if ( !QFile::exists( lnk->linkFile() ) ) { |
398 | // the way writing lnks doesn't really check for out | 398 | // the way writing lnks doesn't really check for out |
399 | // of disk space, but check it anyway. | 399 | // of disk space, but check it anyway. |
400 | if ( !lnk->writeLink() ) { | 400 | if ( !lnk->writeLink() ) { |
401 | QMessageBox::critical( 0, tr("Out of space"), | 401 | QMessageBox::critical( 0, tr("Out of space"), |
402 | tr( "There was a problem saving " | 402 | tr( "There was a problem saving " |
403 | "the playlist.\n" | 403 | "the playlist.\n" |
404 | "Your playlist " | 404 | "Your playlist " |
405 | "may be missing some entries\n" | 405 | "may be missing some entries\n" |
406 | "the next time you start it." ) | 406 | "the next time you start it." ) |
407 | ); | 407 | ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | noOfFiles++; | 410 | noOfFiles++; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | while ( d->selectedFiles->next() ); | 413 | while ( d->selectedFiles->next() ); |
414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
419 | // qDebug("add"); | 419 | // qDebug("add"); |
420 | if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { | 420 | // if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { |
421 | QMessageBox::message("Note","You are trying to play\na malformed url."); | 421 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
422 | 422 | ||
423 | } else { | 423 | // } else { |
424 | 424 | ||
425 | d->setDocumentUsed = FALSE; | 425 | d->setDocumentUsed = FALSE; |
426 | if ( mediaPlayerState->playlist() ) { | 426 | if ( mediaPlayerState->playlist() ) { |
427 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 427 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
428 | d->selectedFiles->addToSelection( lnk ); | 428 | d->selectedFiles->addToSelection( lnk ); |
429 | } | 429 | } |
430 | else | 430 | else |
431 | mediaPlayerState->setPlaying( TRUE ); | 431 | mediaPlayerState->setPlaying( TRUE ); |
432 | } | 432 | // } |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void PlayListWidget::clearList() { | 436 | void PlayListWidget::clearList() { |
437 | while ( first() ) | 437 | while ( first() ) |
438 | d->selectedFiles->removeSelected(); | 438 | d->selectedFiles->removeSelected(); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void PlayListWidget::addAllToList() { | 442 | void PlayListWidget::addAllToList() { |
443 | DocLnkSet filesAll; | 443 | DocLnkSet filesAll; |
444 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 444 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
445 | QListIterator<DocLnk> Adit( filesAll.children() ); | 445 | QListIterator<DocLnk> Adit( filesAll.children() ); |
446 | for ( ; Adit.current(); ++Adit ) | 446 | for ( ; Adit.current(); ++Adit ) |
447 | if(QFileInfo(Adit.current()->file()).exists()) | 447 | if(QFileInfo(Adit.current()->file()).exists()) |
448 | d->selectedFiles->addToSelection( **Adit ); | 448 | d->selectedFiles->addToSelection( **Adit ); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void PlayListWidget::addAllMusicToList() { | 452 | void PlayListWidget::addAllMusicToList() { |
453 | QListIterator<DocLnk> dit( files.children() ); | 453 | QListIterator<DocLnk> dit( files.children() ); |
454 | for ( ; dit.current(); ++dit ) | 454 | for ( ; dit.current(); ++dit ) |
455 | if(QFileInfo(dit.current()->file()).exists()) | 455 | if(QFileInfo(dit.current()->file()).exists()) |
456 | d->selectedFiles->addToSelection( **dit ); | 456 | d->selectedFiles->addToSelection( **dit ); |
@@ -834,49 +834,49 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
834 | if( !tbDeletePlaylist->isHidden()) | 834 | if( !tbDeletePlaylist->isHidden()) |
835 | tbDeletePlaylist->hide(); | 835 | tbDeletePlaylist->hide(); |
836 | d->tbRemoveFromList->setEnabled(FALSE); | 836 | d->tbRemoveFromList->setEnabled(FALSE); |
837 | d->tbAddToList->setEnabled(TRUE); | 837 | d->tbAddToList->setEnabled(TRUE); |
838 | } | 838 | } |
839 | break; | 839 | break; |
840 | case 3: | 840 | case 3: |
841 | { | 841 | { |
842 | if( tbDeletePlaylist->isHidden()) | 842 | if( tbDeletePlaylist->isHidden()) |
843 | tbDeletePlaylist->show(); | 843 | tbDeletePlaylist->show(); |
844 | playLists->reread(); | 844 | playLists->reread(); |
845 | } | 845 | } |
846 | break; | 846 | break; |
847 | }; | 847 | }; |
848 | } | 848 | } |
849 | 849 | ||
850 | void PlayListWidget::btnPlay(bool b) { | 850 | void PlayListWidget::btnPlay(bool b) { |
851 | 851 | ||
852 | // mediaPlayerState->setPlaying(b); | 852 | // mediaPlayerState->setPlaying(b); |
853 | switch ( tabWidget->currentPageIndex()) { | 853 | switch ( tabWidget->currentPageIndex()) { |
854 | case 0: | 854 | case 0: |
855 | { | 855 | { |
856 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 856 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
857 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 857 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
858 | QMessageBox::message("Note","You are trying to play\na malformed url."); | 858 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
859 | // } else { | 859 | // } else { |
860 | mediaPlayerState->setPlaying(b); | 860 | mediaPlayerState->setPlaying(b); |
861 | // } | 861 | // } |
862 | } | 862 | } |
863 | break; | 863 | break; |
864 | case 1: | 864 | case 1: |
865 | { | 865 | { |
866 | addToSelection( audioView->currentItem() ); | 866 | addToSelection( audioView->currentItem() ); |
867 | mediaPlayerState->setPlaying(b); | 867 | mediaPlayerState->setPlaying(b); |
868 | d->selectedFiles->removeSelected( ); | 868 | d->selectedFiles->removeSelected( ); |
869 | tabWidget->setCurrentPage(1); | 869 | tabWidget->setCurrentPage(1); |
870 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
871 | insanityBool=FALSE; | 871 | insanityBool=FALSE; |
872 | }// audioView->clearSelection(); | 872 | }// audioView->clearSelection(); |
873 | break; | 873 | break; |
874 | case 2: | 874 | case 2: |
875 | { | 875 | { |
876 | addToSelection( videoView->currentItem() ); | 876 | addToSelection( videoView->currentItem() ); |
877 | mediaPlayerState->setPlaying(b); | 877 | mediaPlayerState->setPlaying(b); |
878 | qApp->processEvents(); | 878 | qApp->processEvents(); |
879 | d->selectedFiles->removeSelected( ); | 879 | d->selectedFiles->removeSelected( ); |
880 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
881 | d->selectedFiles->unSelect(); | 881 | d->selectedFiles->unSelect(); |
882 | insanityBool=FALSE; | 882 | insanityBool=FALSE; |