-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index e327098..7021fae 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -39,385 +39,385 @@ typedef struct _waveheader { | |||
39 | 39 | ||
40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
45 | 45 | ||
46 | u_long data_chunk; /* 'data' */ | 46 | u_long data_chunk; /* 'data' */ |
47 | 47 | ||
48 | u_long data_length;/* samplecount */ | 48 | u_long data_length;/* samplecount */ |
49 | } WaveHeader; | 49 | } WaveHeader; |
50 | 50 | ||
51 | #define RIFF 0x46464952 | 51 | #define RIFF 0x46464952 |
52 | #define WAVE 0x45564157 | 52 | #define WAVE 0x45564157 |
53 | #define FMT 0x20746D66 | 53 | #define FMT 0x20746D66 |
54 | #define DATA 0x61746164 | 54 | #define DATA 0x61746164 |
55 | #define PCM_CODE 1 | 55 | #define PCM_CODE 1 |
56 | #define WAVE_MONO 1 | 56 | #define WAVE_MONO 1 |
57 | #define WAVE_STEREO 2 | 57 | #define WAVE_STEREO 2 |
58 | 58 | ||
59 | #include "vmemo.h" | 59 | #include "vmemo.h" |
60 | 60 | ||
61 | #include <qpe/qpeapplication.h> | 61 | #include <qpe/qpeapplication.h> |
62 | #include <qpe/resource.h> | 62 | #include <qpe/resource.h> |
63 | #include <qpe/config.h> | 63 | #include <qpe/config.h> |
64 | 64 | ||
65 | #include <qpainter.h> | 65 | #include <qpainter.h> |
66 | #include <qdatetime.h> | 66 | #include <qdatetime.h> |
67 | #include <qregexp.h> | 67 | #include <qregexp.h> |
68 | #include <qsound.h> | 68 | #include <qsound.h> |
69 | #include <qfile.h> | 69 | #include <qfile.h> |
70 | #include <qmessagebox.h> | 70 | #include <qmessagebox.h> |
71 | 71 | ||
72 | int seq = 0; | 72 | int seq = 0; |
73 | 73 | ||
74 | /* XPM */ | 74 | /* XPM */ |
75 | static char * vmemo_xpm[] = { | 75 | static char * vmemo_xpm[] = { |
76 | "16 16 102 2", | 76 | "16 16 102 2", |
77 | " c None", | 77 | " c None", |
78 | ". c #60636A", | 78 | ". c #60636A", |
79 | "+ c #6E6E72", | 79 | "+ c #6E6E72", |
80 | "@ c #68696E", | 80 | "@ c #68696E", |
81 | "# c #4D525C", | 81 | "# c #4D525C", |
82 | "$ c #6B6C70", | 82 | "$ c #6B6C70", |
83 | "% c #E3E3E8", | 83 | "% c #E3E3E8", |
84 | "& c #EEEEF2", | 84 | "& c #EEEEF2", |
85 | "* c #EAEAEF", | 85 | "* c #EAEAEF", |
86 | "= c #CACAD0", | 86 | "= c #CACAD0", |
87 | "- c #474A51", | 87 | "- c #474A51", |
88 | "; c #171819", | 88 | "; c #171819", |
89 | "> c #9B9B9F", | 89 | "> c #9B9B9F", |
90 | ", c #EBEBF0", | 90 | ", c #EBEBF0", |
91 | "' c #F4F4F7", | 91 | "' c #F4F4F7", |
92 | ") c #F1F1F5", | 92 | ") c #F1F1F5", |
93 | "! c #DEDEE4", | 93 | "! c #DEDEE4", |
94 | "~ c #57575C", | 94 | "~ c #57575C", |
95 | "{ c #010101", | 95 | "{ c #010101", |
96 | "] c #A2A2A6", | 96 | "] c #A2A2A6", |
97 | "^ c #747477", | 97 | "^ c #747477", |
98 | "/ c #B5B5B8", | 98 | "/ c #B5B5B8", |
99 | "( c #AEAEB2", | 99 | "( c #AEAEB2", |
100 | "_ c #69696D", | 100 | "_ c #69696D", |
101 | ": c #525256", | 101 | ": c #525256", |
102 | "< c #181C24", | 102 | "< c #181C24", |
103 | "[ c #97979B", | 103 | "[ c #97979B", |
104 | "} c #A7A7AC", | 104 | "} c #A7A7AC", |
105 | "| c #B0B0B4", | 105 | "| c #B0B0B4", |
106 | "1 c #C8C8D1", | 106 | "1 c #C8C8D1", |
107 | "2 c #75757B", | 107 | "2 c #75757B", |
108 | "3 c #46464A", | 108 | "3 c #46464A", |
109 | "4 c #494A4F", | 109 | "4 c #494A4F", |
110 | "5 c #323234", | 110 | "5 c #323234", |
111 | "6 c #909095", | 111 | "6 c #909095", |
112 | "7 c #39393B", | 112 | "7 c #39393B", |
113 | "8 c #757578", | 113 | "8 c #757578", |
114 | "9 c #87878E", | 114 | "9 c #87878E", |
115 | "0 c #222224", | 115 | "0 c #222224", |
116 | "a c #414144", | 116 | "a c #414144", |
117 | "b c #6A6A6E", | 117 | "b c #6A6A6E", |
118 | "c c #020C16", | 118 | "c c #020C16", |
119 | "d c #6B6B6F", | 119 | "d c #6B6B6F", |
120 | "e c #68686D", | 120 | "e c #68686D", |
121 | "f c #5B5B60", | 121 | "f c #5B5B60", |
122 | "g c #8A8A8F", | 122 | "g c #8A8A8F", |
123 | "h c #6B6B6E", | 123 | "h c #6B6B6E", |
124 | "i c #ADADB2", | 124 | "i c #ADADB2", |
125 | "j c #828289", | 125 | "j c #828289", |
126 | "k c #3E3E41", | 126 | "k c #3E3E41", |
127 | "l c #CFCFD7", | 127 | "l c #CFCFD7", |
128 | "m c #4C4C50", | 128 | "m c #4C4C50", |
129 | "n c #000000", | 129 | "n c #000000", |
130 | "o c #66666A", | 130 | "o c #66666A", |
131 | "p c #505054", | 131 | "p c #505054", |
132 | "q c #838388", | 132 | "q c #838388", |
133 | "r c #A1A1A7", | 133 | "r c #A1A1A7", |
134 | "s c #A9A9AE", | 134 | "s c #A9A9AE", |
135 | "t c #A8A8B0", | 135 | "t c #A8A8B0", |
136 | "u c #5E5E63", | 136 | "u c #5E5E63", |
137 | "v c #3A3A3E", | 137 | "v c #3A3A3E", |
138 | "w c #BDBDC6", | 138 | "w c #BDBDC6", |
139 | "x c #59595E", | 139 | "x c #59595E", |
140 | "y c #76767C", | 140 | "y c #76767C", |
141 | "z c #373738", | 141 | "z c #373738", |
142 | "A c #717174", | 142 | "A c #717174", |
143 | "B c #727278", | 143 | "B c #727278", |
144 | "C c #1C1C1E", | 144 | "C c #1C1C1E", |
145 | "D c #3C3C3F", | 145 | "D c #3C3C3F", |
146 | "E c #ADADB6", | 146 | "E c #ADADB6", |
147 | "F c #54555A", | 147 | "F c #54555A", |
148 | "G c #8B8C94", | 148 | "G c #8B8C94", |
149 | "H c #5A5A5F", | 149 | "H c #5A5A5F", |
150 | "I c #BBBBC3", | 150 | "I c #BBBBC3", |
151 | "J c #C4C4CB", | 151 | "J c #C4C4CB", |
152 | "K c #909098", | 152 | "K c #909098", |
153 | "L c #737379", | 153 | "L c #737379", |
154 | "M c #343437", | 154 | "M c #343437", |
155 | "N c #8F8F98", | 155 | "N c #8F8F98", |
156 | "O c #000407", | 156 | "O c #000407", |
157 | "P c #2D3137", | 157 | "P c #2D3137", |
158 | "Q c #B0B1BC", | 158 | "Q c #B0B1BC", |
159 | "R c #3B3C40", | 159 | "R c #3B3C40", |
160 | "S c #6E6E74", | 160 | "S c #6E6E74", |
161 | "T c #95959C", | 161 | "T c #95959C", |
162 | "U c #74747A", | 162 | "U c #74747A", |
163 | "V c #1D1D1E", | 163 | "V c #1D1D1E", |
164 | "W c #91929A", | 164 | "W c #91929A", |
165 | "X c #42444A", | 165 | "X c #42444A", |
166 | "Y c #22282E", | 166 | "Y c #22282E", |
167 | "Z c #B0B2BC", | 167 | "Z c #B0B2BC", |
168 | "` c #898A90", | 168 | "` c #898A90", |
169 | " . c #65656A", | 169 | " . c #65656A", |
170 | ".. c #999AA2", | 170 | ".. c #999AA2", |
171 | "+. c #52535A", | 171 | "+. c #52535A", |
172 | "@. c #151B21", | 172 | "@. c #151B21", |
173 | "#. c #515257", | 173 | "#. c #515257", |
174 | "$. c #B5B5BE", | 174 | "$. c #B5B5BE", |
175 | "%. c #616167", | 175 | "%. c #616167", |
176 | "&. c #1A1D22", | 176 | "&. c #1A1D22", |
177 | "*. c #000713", | 177 | "*. c #000713", |
178 | "=. c #1F1F21", | 178 | "=. c #1F1F21", |
179 | " ", | 179 | " ", |
180 | " . + @ # ", | 180 | " . + @ # ", |
181 | " $ % & * = - ", | 181 | " $ % & * = - ", |
182 | " ; > , ' ) ! ~ ", | 182 | " ; > , ' ) ! ~ ", |
183 | " { ] ^ / ( _ : ", | 183 | " { ] ^ / ( _ : ", |
184 | " < [ } | 1 2 3 ", | 184 | " < [ } | 1 2 3 ", |
185 | " 4 5 6 7 8 9 0 a b c ", | 185 | " 4 5 6 7 8 9 0 a b c ", |
186 | " d e f g h i j 3 k l m n ", | 186 | " d e f g h i j 3 k l m n ", |
187 | " o p q r s t u v w n ", | 187 | " o p q r s t u v w n ", |
188 | " o x y z A B C D E n ", | 188 | " o x y z A B C D E n ", |
189 | " F G H I J K L M N O ", | 189 | " F G H I J K L M N O ", |
190 | " P Q R S T U V W X ", | 190 | " P Q R S T U V W X ", |
191 | " Y Z ` b ...+. ", | 191 | " Y Z ` b ...+. ", |
192 | " @.#.$.%.&. ", | 192 | " @.#.$.%.&. ", |
193 | " *.B =. ", | 193 | " *.B =. ", |
194 | " n n n n n n n n n "}; | 194 | " n n n n n n n n n "}; |
195 | 195 | ||
196 | 196 | ||
197 | VMemo::VMemo( QWidget *parent, const char *_name ) | 197 | VMemo::VMemo( QWidget *parent, const char *_name ) |
198 | : QWidget( parent, _name ) | 198 | : QWidget( parent, _name ) |
199 | { | 199 | { |
200 | setFixedHeight( 18 ); | 200 | setFixedHeight( 18 ); |
201 | setFixedWidth( 14 ); | 201 | setFixedWidth( 14 ); |
202 | 202 | ||
203 | recording = FALSE; | 203 | recording = FALSE; |
204 | 204 | ||
205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
206 | if (uname(&name) != -1) { | 206 | if (uname(&name) != -1) { |
207 | QString release=name.release; | 207 | QString release=name.release; |
208 | Config vmCfg("Vmemo"); | 208 | Config vmCfg("Vmemo"); |
209 | vmCfg.setGroup("Defaults"); | 209 | vmCfg.setGroup("Defaults"); |
210 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 210 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
211 | 211 | ||
212 | qDebug("toggleKey %d", toggleKey); | 212 | qDebug("toggleKey %d", toggleKey); |
213 | 213 | ||
214 | if(release.find("embedix",0,TRUE) !=-1) | 214 | if(release.find("embedix",0,TRUE) !=-1) |
215 | systemZaurus=TRUE; | 215 | systemZaurus=TRUE; |
216 | else | 216 | else |
217 | systemZaurus=FALSE; | 217 | systemZaurus=FALSE; |
218 | 218 | ||
219 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 219 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
221 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 221 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
222 | 222 | ||
223 | if( toggleKey != -1 ) { | 223 | if( toggleKey != -1 ) { |
224 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 224 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
225 | // e << 4096; // Key_Escape | 225 | // e << 4096; // Key_Escape |
226 | // e << Key_F5; //4148 | 226 | // e << Key_F5; //4148 |
227 | e << toggleKey; | 227 | e << toggleKey; |
228 | e << QString("QPE/VMemo"); | 228 | e << QString("QPE/VMemo"); |
229 | e << QString("toggleRecord()"); | 229 | e << QString("toggleRecord()"); |
230 | } | 230 | } |
231 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 231 | if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) |
232 | hide(); | 232 | hide(); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | VMemo::~VMemo() | 236 | VMemo::~VMemo() |
237 | { | 237 | { |
238 | } | 238 | } |
239 | 239 | ||
240 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 240 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
241 | { | 241 | { |
242 | QDataStream stream( data, IO_ReadOnly ); | 242 | QDataStream stream( data, IO_ReadOnly ); |
243 | if (msg == "toggleRecord()") { | 243 | if (msg == "toggleRecord()") { |
244 | if (recording) { | 244 | if (recording) { |
245 | fromToggle = TRUE; | 245 | fromToggle = TRUE; |
246 | stopRecording(); | 246 | stopRecording(); |
247 | } else { | 247 | } else { |
248 | fromToggle = TRUE; | 248 | fromToggle = TRUE; |
249 | startRecording(); | 249 | startRecording(); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | void VMemo::paintEvent( QPaintEvent* ) | 254 | void VMemo::paintEvent( QPaintEvent* ) |
255 | { | 255 | { |
256 | QPainter p(this); | 256 | QPainter p(this); |
257 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 257 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
258 | } | 258 | } |
259 | 259 | ||
260 | void VMemo::mousePressEvent( QMouseEvent * ) | 260 | void VMemo::mousePressEvent( QMouseEvent * ) |
261 | { | 261 | { |
262 | startRecording(); | 262 | startRecording(); |
263 | } | 263 | } |
264 | 264 | ||
265 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 265 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
266 | { | 266 | { |
267 | stopRecording(); | 267 | stopRecording(); |
268 | } | 268 | } |
269 | 269 | ||
270 | bool VMemo::startRecording() { | 270 | bool VMemo::startRecording() { |
271 | 271 | ||
272 | if ( recording) | 272 | if ( recording) |
273 | return FALSE;; | 273 | return FALSE;; |
274 | 274 | ||
275 | Config config( "Vmemo" ); | 275 | Config config( "Vmemo" ); |
276 | config.setGroup( "System" ); | 276 | config.setGroup( "System" ); |
277 | 277 | ||
278 | useAlerts = config.readBoolEntry("Alert"); | 278 | useAlerts = config.readBoolEntry("Alert"); |
279 | if(useAlerts) { | 279 | if(useAlerts) { |
280 | 280 | ||
281 | msgLabel = new QLabel( 0, "alertLabel" ); | 281 | msgLabel = new QLabel( 0, "alertLabel" ); |
282 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 282 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
283 | msgLabel->show(); | 283 | msgLabel->show(); |
284 | } | 284 | } |
285 | 285 | ||
286 | // if(useAlerts) | 286 | // if(useAlerts) |
287 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 287 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
288 | // return; | 288 | // return; |
289 | // } else { | 289 | // } else { |
290 | if (!systemZaurus ) | 290 | if (!systemZaurus ) |
291 | QSound::play(Resource::findSound("vmemob")); | 291 | QSound::play(Resource::findSound("vmemob")); |
292 | // } | 292 | // } |
293 | qDebug("Start recording"); | 293 | qDebug("Start recording"); |
294 | recording = TRUE; | 294 | recording = TRUE; |
295 | if (openDSP() == -1) { | 295 | if (openDSP() == -1) { |
296 | QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 296 | QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
297 | recording = FALSE; | 297 | recording = FALSE; |
298 | return FALSE; | 298 | return FALSE; |
299 | } | 299 | } |
300 | 300 | ||
301 | config.setGroup("Defaults"); | 301 | config.setGroup("Defaults"); |
302 | 302 | ||
303 | QDateTime dt = QDateTime::currentDateTime(); | 303 | QDateTime dt = QDateTime::currentDateTime(); |
304 | 304 | ||
305 | QString fName; | 305 | QString fName; |
306 | config.setGroup( "System" ); | 306 | config.setGroup( "System" ); |
307 | fName = QPEApplication::documentDir() ; | 307 | fName = QPEApplication::documentDir() ; |
308 | fileName = config.readEntry("RecLocation", fName); | 308 | fileName = config.readEntry("RecLocation", fName); |
309 | 309 | ||
310 | int s; | 310 | int s; |
311 | s=fileName.find(':'); | 311 | s=fileName.find(':'); |
312 | if(s) | 312 | if(s) |
313 | fileName=fileName.right(fileName.length()-s-2); | 313 | fileName=fileName.right(fileName.length()-s-2); |
314 | qDebug("filename will be "+fileName); | 314 | qDebug("filename will be "+fileName); |
315 | if( fileName.left(1).find('/') == -1) | 315 | if( fileName.left(1).find('/') == -1) |
316 | fileName="/"+fileName; | 316 | fileName="/"+fileName; |
317 | if( fileName.right(1).find('/') == -1) | 317 | if( fileName.right(1).find('/') == -1) |
318 | fileName+="/"; | 318 | fileName+="/"; |
319 | fName = "vm_"+ dt.toString()+ ".wav"; | 319 | fName = "vm_"+ dt.toString()+ ".wav"; |
320 | 320 | ||
321 | fileName+=fName; | 321 | fileName+=fName; |
322 | qDebug("filename is "+fileName); | 322 | qDebug("filename is "+fileName); |
323 | // No spaces in the filename | 323 | // No spaces in the filename |
324 | fileName.replace(QRegExp("'"),""); | 324 | fileName.replace(QRegExp("'"),""); |
325 | fileName.replace(QRegExp(" "),"_"); | 325 | fileName.replace(QRegExp(" "),"_"); |
326 | fileName.replace(QRegExp(":"),"."); | 326 | fileName.replace(QRegExp(":"),"."); |
327 | fileName.replace(QRegExp(","),""); | 327 | fileName.replace(QRegExp(","),""); |
328 | 328 | ||
329 | if(openWAV(fileName.latin1()) == -1) { | 329 | if(openWAV(fileName.latin1()) == -1) { |
330 | QString err("Could not open the output file\n"); | 330 | QString err("Could not open the output file\n"); |
331 | err += fileName; | 331 | err += fileName; |
332 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 332 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
333 | close(dsp); | 333 | close(dsp); |
334 | return FALSE; | 334 | return FALSE; |
335 | } | 335 | } |
336 | 336 | ||
337 | QArray<int> cats(1); | 337 | QArray<int> cats(1); |
338 | cats[0] = config.readNumEntry("Category", 0); | 338 | cats[0] = config.readNumEntry("Category", 0); |
339 | 339 | ||
340 | QString dlName("vm_"); | 340 | QString dlName("vm_"); |
341 | dlName += dt.toString(); | 341 | dlName += dt.toString(); |
342 | DocLnk l; | 342 | DocLnk l; |
343 | l.setFile(fileName); | 343 | l.setFile(fileName); |
344 | l.setName(dlName); | 344 | l.setName(dlName); |
345 | l.setType("audio/x-wav"); | 345 | l.setType("audio/x-wav"); |
346 | l.setCategories(cats); | 346 | l.setCategories(cats); |
347 | l.writeLink(); | 347 | l.writeLink(); |
348 | 348 | ||
349 | 349 | ||
350 | record(); | 350 | record(); |
351 | return TRUE; | 351 | return TRUE; |
352 | } | 352 | } |
353 | 353 | ||
354 | void VMemo::stopRecording() { | 354 | void VMemo::stopRecording() { |
355 | recording = FALSE; | 355 | recording = FALSE; |
356 | if(useAlerts) | 356 | if(useAlerts) |
357 | if( msgLabel) delete msgLabel; | 357 | if( msgLabel) delete msgLabel; |
358 | } | 358 | } |
359 | 359 | ||
360 | int VMemo::openDSP() | 360 | int VMemo::openDSP() |
361 | { | 361 | { |
362 | Config cfg("Vmemo"); | 362 | Config cfg("Vmemo"); |
363 | cfg.setGroup("Record"); | 363 | cfg.setGroup("Record"); |
364 | 364 | ||
365 | speed = cfg.readNumEntry("SampleRate", 22050); | 365 | speed = cfg.readNumEntry("SampleRate", 22050); |
366 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 366 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
367 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 367 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
368 | format = AFMT_S16_LE; | 368 | format = AFMT_S16_LE; |
369 | resolution = 16; | 369 | resolution = 16; |
370 | } else { | 370 | } else { |
371 | format = AFMT_U8; | 371 | format = AFMT_U8; |
372 | resolution = 8; | 372 | resolution = 8; |
373 | } | 373 | } |
374 | 374 | ||
375 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 375 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
376 | 376 | ||
377 | if(systemZaurus) { | 377 | if(systemZaurus) { |
378 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 378 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
379 | channels=1; //zaurus has one input channel | 379 | channels=1; //zaurus has one input channel |
380 | } else { | 380 | } else { |
381 | dsp = open("/dev/dsp", O_RDWR); | 381 | dsp = open("/dev/dsp", O_RDWR); |
382 | } | 382 | } |
383 | 383 | ||
384 | if(dsp == -1) { | 384 | if(dsp == -1) { |
385 | perror("open(\"/dev/dsp\")"); | 385 | perror("open(\"/dev/dsp\")"); |
386 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 386 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
387 | return -1; | 387 | return -1; |
388 | } | 388 | } |
389 | 389 | ||
390 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 390 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
391 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 391 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
392 | return -1; | 392 | return -1; |
393 | } | 393 | } |
394 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 394 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
395 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 395 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
396 | return -1; | 396 | return -1; |
397 | } | 397 | } |
398 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 398 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
399 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 399 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
400 | return -1; | 400 | return -1; |
401 | } | 401 | } |
402 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 402 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
403 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 403 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
404 | return -1; | 404 | return -1; |
405 | } | 405 | } |
406 | 406 | ||
407 | return 1; | 407 | return 1; |
408 | } | 408 | } |
409 | 409 | ||
410 | int VMemo::openWAV(const char *filename) | 410 | int VMemo::openWAV(const char *filename) |
411 | { | 411 | { |
412 | track.setName(filename); | 412 | track.setName(filename); |
413 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 413 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
414 | errorMsg=filename; | 414 | errorMsg=filename; |
415 | return -1; | 415 | return -1; |
416 | } | 416 | } |
417 | 417 | ||
418 | wav=track.handle(); | 418 | wav=track.handle(); |
419 | 419 | ||
420 | WaveHeader wh; | 420 | WaveHeader wh; |
421 | 421 | ||
422 | wh.main_chunk = RIFF; | 422 | wh.main_chunk = RIFF; |
423 | wh.length=0; | 423 | wh.length=0; |