-rw-r--r-- | library/sound.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/library/sound.cpp b/library/sound.cpp index 5b67995..ee2aabc 100644 --- a/library/sound.cpp +++ b/library/sound.cpp | |||
@@ -1,85 +1,83 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
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 | 20 | ||
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/sound.h> | 22 | #include <qpe/sound.h> |
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | 24 | ||
25 | #include <qsound.h> | 25 | #include <qsound.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <fcntl.h> | 29 | #include <fcntl.h> |
30 | #include <sys/ioctl.h> | 30 | #include <sys/ioctl.h> |
31 | 31 | ||
32 | #ifndef QT_NO_SOUND | 32 | #ifndef QT_NO_SOUND |
33 | #include <sys/soundcard.h> | 33 | #include <sys/soundcard.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include "config.h" | ||
37 | #include <qmessagebox.h> | ||
38 | #ifndef QT_NO_SOUND | 36 | #ifndef QT_NO_SOUND |
39 | static int WAVsoundDuration(const QString& filename) | 37 | static int WAVsoundDuration(const QString& filename) |
40 | { | 38 | { |
41 | // bad solution | 39 | // bad solution |
42 | 40 | ||
43 | // most of this is copied from qsoundqss.cpp | 41 | // most of this is copied from qsoundqss.cpp |
44 | 42 | ||
45 | QFile input(filename); | 43 | QFile input(filename); |
46 | if ( !input.open(IO_ReadOnly) ) | 44 | if ( !input.open(IO_ReadOnly) ) |
47 | return 0; | 45 | return 0; |
48 | 46 | ||
49 | struct QRiffChunk { | 47 | struct QRiffChunk { |
50 | char id[4]; | 48 | char id[4]; |
51 | Q_UINT32 size; | 49 | Q_UINT32 size; |
52 | char data[4/*size*/]; | 50 | char data[4/*size*/]; |
53 | } chunk; | 51 | } chunk; |
54 | 52 | ||
55 | struct { | 53 | struct { |
56 | Q_INT16 formatTag; | 54 | Q_INT16 formatTag; |
57 | Q_INT16 channels; | 55 | Q_INT16 channels; |
58 | Q_INT32 samplesPerSec; | 56 | Q_INT32 samplesPerSec; |
59 | Q_INT32 avgBytesPerSec; | 57 | Q_INT32 avgBytesPerSec; |
60 | Q_INT16 blockAlign; | 58 | Q_INT16 blockAlign; |
61 | Q_INT16 wBitsPerSample; | 59 | Q_INT16 wBitsPerSample; |
62 | } chunkdata; | 60 | } chunkdata; |
63 | 61 | ||
64 | int total = 0; | 62 | int total = 0; |
65 | 63 | ||
66 | while(1) { | 64 | while(1) { |
67 | // Keep reading chunks... | 65 | // Keep reading chunks... |
68 | const int n = sizeof(chunk)-sizeof(chunk.data); | 66 | const int n = sizeof(chunk)-sizeof(chunk.data); |
69 | if ( input.readBlock((char*)&chunk,n) != n ) | 67 | if ( input.readBlock((char*)&chunk,n) != n ) |
70 | break; | 68 | break; |
71 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 69 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
72 | total += chunkdata.avgBytesPerSec ? | 70 | total += chunkdata.avgBytesPerSec ? |
73 | chunk.size * 1000 / chunkdata.avgBytesPerSec : 0; | 71 | chunk.size * 1000 / chunkdata.avgBytesPerSec : 0; |
74 | //qDebug("%d bytes of PCM (%dms)", chunk.size,chunkdata.avgBytesPerSec ? chunk.size * 1000 / chunkdata.avgBytesPerSec : 0); | 72 | //qDebug("%d bytes of PCM (%dms)", chunk.size,chunkdata.avgBytesPerSec ? chunk.size * 1000 / chunkdata.avgBytesPerSec : 0); |
75 | input.at(input.at()+chunk.size-4); | 73 | input.at(input.at()+chunk.size-4); |
76 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 74 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
77 | char d[4]; | 75 | char d[4]; |
78 | if ( input.readBlock(d,4) != 4 ) | 76 | if ( input.readBlock(d,4) != 4 ) |
79 | return 0; | 77 | return 0; |
80 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 78 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
81 | // skip | 79 | // skip |
82 | //qDebug("skip %.4s RIFF chunk",d); | 80 | //qDebug("skip %.4s RIFF chunk",d); |
83 | if ( chunk.size < 10000000 ) | 81 | if ( chunk.size < 10000000 ) |
84 | (void)input.at(input.at()+chunk.size-4); | 82 | (void)input.at(input.at()+chunk.size-4); |
85 | } | 83 | } |