summaryrefslogtreecommitdiff
authorschurig <schurig>2004-09-10 12:34:40 (UTC)
committer schurig <schurig>2004-09-10 12:34:40 (UTC)
commit85928a3781d9a91b58ea414c0d7982459cc21920 (patch) (unidiff)
tree10aeedf3a79fe2372c55bda730b6913b5562231b
parent9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (diff)
downloadopie-85928a3781d9a91b58ea414c0d7982459cc21920.zip
opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.gz
opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.bz2
support for DEVFS
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp4
-rw-r--r--noncore/multimedia/opierec/device.cpp16
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp7
3 files changed, 27 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 7b4bfd9..e6afbd8 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,403 +1,407 @@
1#include "mediaplayer.h" 1#include "mediaplayer.h"
2#include "audiowidget.h" 2#include "audiowidget.h"
3#include "videowidget.h" 3#include "videowidget.h"
4#include "volumecontrol.h" 4#include "volumecontrol.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/config.h> 9#include <qpe/config.h>
10 10
11/* QT */ 11/* QT */
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13 13
14/* STD */ 14/* STD */
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <sys/file.h> 16#include <sys/file.h>
17#include <sys/ioctl.h> 17#include <sys/ioctl.h>
18 18
19#define FBIOBLANK 0x4611 19#define FBIOBLANK 0x4611
20 20
21MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 21MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
22 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 22 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
23 23
24 m_audioUI = 0; 24 m_audioUI = 0;
25 m_videoUI = 0; 25 m_videoUI = 0;
26 m_xineControl = 0; 26 m_xineControl = 0;
27 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 27 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
28 28
29 fd=-1;fl=-1; 29 fd=-1;fl=-1;
30 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 30 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
31 31
32 qApp->processEvents(); 32 qApp->processEvents();
33 // QPEApplication::grabKeyboard(); // EVIL 33 // QPEApplication::grabKeyboard(); // EVIL
34 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 34 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
35 35
36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
37 37
38// What is pauseCheck good for? (Simon) 38// What is pauseCheck good for? (Simon)
39// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); 39// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
40 40
41 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 41 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
42 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 42 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
43 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); 43 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
44 44
45 volControl = new VolumeControl; 45 volControl = new VolumeControl;
46 Config cfg( "OpiePlayer" ); 46 Config cfg( "OpiePlayer" );
47 cfg.setGroup("PlayList"); 47 cfg.setGroup("PlayList");
48 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 48 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
49 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 49 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
50 50
51 m_skinLoader = new SkinLoader; 51 m_skinLoader = new SkinLoader;
52 m_skinLoader->schedule( AudioWidget::guiInfo() ); 52 m_skinLoader->schedule( AudioWidget::guiInfo() );
53 m_skinLoader->schedule( VideoWidget::guiInfo() ); 53 m_skinLoader->schedule( VideoWidget::guiInfo() );
54 m_skinLoader->start(); 54 m_skinLoader->start();
55} 55}
56 56
57MediaPlayer::~MediaPlayer() { 57MediaPlayer::~MediaPlayer() {
58 // this shold never happen, but one never knows... 58 // this shold never happen, but one never knows...
59 if ( xine ) { 59 if ( xine ) {
60 xine->ensureInitialized(); 60 xine->ensureInitialized();
61 delete xine; 61 delete xine;
62 } 62 }
63 delete m_xineControl; 63 delete m_xineControl;
64 delete m_audioUI; 64 delete m_audioUI;
65 delete m_videoUI; 65 delete m_videoUI;
66 delete volControl; 66 delete volControl;
67} 67}
68 68
69void MediaPlayer::pauseCheck( bool b ) { 69void MediaPlayer::pauseCheck( bool b ) {
70 if ( b && !mediaPlayerState.isPlaying() ) { 70 if ( b && !mediaPlayerState.isPlaying() ) {
71 mediaPlayerState.setPaused( FALSE ); 71 mediaPlayerState.setPaused( FALSE );
72 } 72 }
73} 73}
74 74
75void MediaPlayer::play() { 75void MediaPlayer::play() {
76 mediaPlayerState.setPlaying( FALSE ); 76 mediaPlayerState.setPlaying( FALSE );
77 mediaPlayerState.setPlaying( TRUE ); 77 mediaPlayerState.setPlaying( TRUE );
78} 78}
79 79
80void MediaPlayer::setPlaying( bool play ) { 80void MediaPlayer::setPlaying( bool play ) {
81 if ( !play ) { 81 if ( !play ) {
82 return; 82 return;
83 } 83 }
84 84
85 if ( mediaPlayerState.isPaused() ) { 85 if ( mediaPlayerState.isPaused() ) {
86 mediaPlayerState.setPaused( FALSE ); 86 mediaPlayerState.setPaused( FALSE );
87 return; 87 return;
88 } 88 }
89 89
90 QString tickerText, time, fileName; 90 QString tickerText, time, fileName;
91 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 91 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
92 //if playing in file list.. play in a different way 92 //if playing in file list.. play in a different way
93 // random and looping settings enabled causes problems here, 93 // random and looping settings enabled causes problems here,
94 // since there is no selected file in the playlist, but a selected file in the file list, 94 // since there is no selected file in the playlist, but a selected file in the file list,
95 // so we remember and shutoff 95 // so we remember and shutoff
96 l = mediaPlayerState.isLooping(); 96 l = mediaPlayerState.isLooping();
97 if(l) { 97 if(l) {
98 mediaPlayerState.setLooping( false ); 98 mediaPlayerState.setLooping( false );
99 } 99 }
100 r = mediaPlayerState.isShuffled(); 100 r = mediaPlayerState.isShuffled();
101 mediaPlayerState.setShuffled( false ); 101 mediaPlayerState.setShuffled( false );
102 } 102 }
103 103
104 PlayListWidget::Entry playListEntry = playList.currentEntry(); 104 PlayListWidget::Entry playListEntry = playList.currentEntry();
105 fileName = playListEntry.name; 105 fileName = playListEntry.name;
106 xineControl()->play( playListEntry.file ); 106 xineControl()->play( playListEntry.file );
107 107
108 long seconds = mediaPlayerState.length(); 108 long seconds = mediaPlayerState.length();
109 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 109 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
110 110
111 if( fileName.left(4) == "http" ) { 111 if( fileName.left(4) == "http" ) {
112 fileName = QFileInfo( fileName ).baseName(); 112 fileName = QFileInfo( fileName ).baseName();
113 if ( xineControl()->getMetaInfo().isEmpty() ) { 113 if ( xineControl()->getMetaInfo().isEmpty() ) {
114 tickerText = tr( " File: " ) + fileName; 114 tickerText = tr( " File: " ) + fileName;
115 } else { 115 } else {
116 tickerText = xineControl()->getMetaInfo(); 116 tickerText = xineControl()->getMetaInfo();
117 } 117 }
118 } else { 118 } else {
119 if ( xineControl()->getMetaInfo().isEmpty() ) { 119 if ( xineControl()->getMetaInfo().isEmpty() ) {
120 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 120 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
121 } else { 121 } else {
122 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 122 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
123 } 123 }
124 } 124 }
125 audioUI()->setTickerText( tickerText ); 125 audioUI()->setTickerText( tickerText );
126} 126}
127 127
128 128
129void MediaPlayer::prev() { 129void MediaPlayer::prev() {
130 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 130 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
131 if ( playList.prev() ) { 131 if ( playList.prev() ) {
132 play(); 132 play();
133 } else if ( mediaPlayerState.isLooping() ) { 133 } else if ( mediaPlayerState.isLooping() ) {
134 if ( playList.last() ) { 134 if ( playList.last() ) {
135 play(); 135 play();
136 } 136 }
137 } else { 137 } else {
138 mediaPlayerState.setList(); 138 mediaPlayerState.setList();
139 } 139 }
140 } 140 }
141} 141}
142 142
143 143
144void MediaPlayer::next() { 144void MediaPlayer::next() {
145 145
146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
147 if ( playList.next() ) { 147 if ( playList.next() ) {
148 play(); 148 play();
149 } else if ( mediaPlayerState.isLooping() ) { 149 } else if ( mediaPlayerState.isLooping() ) {
150 if ( playList.first() ) { 150 if ( playList.first() ) {
151 play(); 151 play();
152 } 152 }
153 } else { 153 } else {
154 mediaPlayerState.setList(); 154 mediaPlayerState.setList();
155 } 155 }
156 } else { //if playing from file list, let's just stop 156 } else { //if playing from file list, let's just stop
157 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; 157 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl;
158 mediaPlayerState.setPlaying(false); 158 mediaPlayerState.setPlaying(false);
159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
160 if(l) mediaPlayerState.setLooping(l); 160 if(l) mediaPlayerState.setLooping(l);
161 if(r) mediaPlayerState.setShuffled(r); 161 if(r) mediaPlayerState.setShuffled(r);
162 } 162 }
163 qApp->processEvents(); 163 qApp->processEvents();
164} 164}
165 165
166 166
167void MediaPlayer::startDecreasingVolume() { 167void MediaPlayer::startDecreasingVolume() {
168 volumeDirection = -1; 168 volumeDirection = -1;
169 startTimer( 100 ); 169 startTimer( 100 );
170 volControl->decVol(2); 170 volControl->decVol(2);
171} 171}
172 172
173 173
174void MediaPlayer::startIncreasingVolume() { 174void MediaPlayer::startIncreasingVolume() {
175 volumeDirection = +1; 175 volumeDirection = +1;
176 startTimer( 100 ); 176 startTimer( 100 );
177 volControl->incVol(2); 177 volControl->incVol(2);
178} 178}
179 179
180 180
181bool drawnOnScreenDisplay = FALSE; 181bool drawnOnScreenDisplay = FALSE;
182unsigned int onScreenDisplayVolume = 0; 182unsigned int onScreenDisplayVolume = 0;
183const int yoff = 110; 183const int yoff = 110;
184 184
185void MediaPlayer::stopChangingVolume() { 185void MediaPlayer::stopChangingVolume() {
186 killTimers(); 186 killTimers();
187 // Get rid of the on-screen display stuff 187 // Get rid of the on-screen display stuff
188 drawnOnScreenDisplay = FALSE; 188 drawnOnScreenDisplay = FALSE;
189 onScreenDisplayVolume = 0; 189 onScreenDisplayVolume = 0;
190 int w=0; 190 int w=0;
191 int h=0; 191 int h=0;
192 if( !xineControl()->hasVideo() ) { 192 if( !xineControl()->hasVideo() ) {
193 w = audioUI()->width(); 193 w = audioUI()->width();
194 h = audioUI()->height(); 194 h = audioUI()->height();
195 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 195 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
196 } else { 196 } else {
197 w = videoUI()->width(); 197 w = videoUI()->width();
198 h = videoUI()->height(); 198 h = videoUI()->height();
199 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 199 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
200 } 200 }
201} 201}
202 202
203 203
204void MediaPlayer::timerEvent( QTimerEvent * ) { 204void MediaPlayer::timerEvent( QTimerEvent * ) {
205 if ( volumeDirection == +1 ) { 205 if ( volumeDirection == +1 ) {
206 volControl->incVol( 2 ); 206 volControl->incVol( 2 );
207 } else if ( volumeDirection == -1 ) { 207 } else if ( volumeDirection == -1 ) {
208 volControl->decVol( 2 ); 208 volControl->decVol( 2 );
209 } 209 }
210 210
211 211
212 // TODO FIXME 212 // TODO FIXME
213 // huh?? 213 // huh??
214 unsigned int v= 0; 214 unsigned int v= 0;
215 v = volControl->volume(); 215 v = volControl->volume();
216 v = v / 10; 216 v = v / 10;
217 217
218 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 218 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
219 return; 219 return;
220 } 220 }
221 221
222 int w=0; int h=0; 222 int w=0; int h=0;
223 if( !xineControl()->hasVideo() ) { 223 if( !xineControl()->hasVideo() ) {
224 w = audioUI()->width(); 224 w = audioUI()->width();
225 h = audioUI()->height(); 225 h = audioUI()->height();
226 226
227 if ( drawnOnScreenDisplay ) { 227 if ( drawnOnScreenDisplay ) {
228 if ( onScreenDisplayVolume > v ) { 228 if ( onScreenDisplayVolume > v ) {
229 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 229 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
230 } 230 }
231 } 231 }
232 drawnOnScreenDisplay = TRUE; 232 drawnOnScreenDisplay = TRUE;
233 onScreenDisplayVolume = v; 233 onScreenDisplayVolume = v;
234 QPainter p( audioUI() ); 234 QPainter p( audioUI() );
235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
237 237
238 QFont f; 238 QFont f;
239 f.setPixelSize( 20 ); 239 f.setPixelSize( 20 );
240 f.setBold( TRUE ); 240 f.setBold( TRUE );
241 p.setFont( f ); 241 p.setFont( f );
242 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 242 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
243 243
244 for ( unsigned int i = 0; i < 10; i++ ) { 244 for ( unsigned int i = 0; i < 10; i++ ) {
245 if ( v > i ) { 245 if ( v > i ) {
246 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 246 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
247 } else { 247 } else {
248 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 248 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
249 } 249 }
250 } 250 }
251 } else { 251 } else {
252 w = videoUI()->width(); 252 w = videoUI()->width();
253 h = videoUI()->height(); 253 h = videoUI()->height();
254 254
255 if ( drawnOnScreenDisplay ) { 255 if ( drawnOnScreenDisplay ) {
256 if ( onScreenDisplayVolume > v ) { 256 if ( onScreenDisplayVolume > v ) {
257 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 257 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
258 } 258 }
259 } 259 }
260 drawnOnScreenDisplay = TRUE; 260 drawnOnScreenDisplay = TRUE;
261 onScreenDisplayVolume = v; 261 onScreenDisplayVolume = v;
262 QPainter p( videoUI() ); 262 QPainter p( videoUI() );
263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
265 265
266 QFont f; 266 QFont f;
267 f.setPixelSize( 20 ); 267 f.setPixelSize( 20 );
268 f.setBold( TRUE ); 268 f.setBold( TRUE );
269 p.setFont( f ); 269 p.setFont( f );
270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
271 271
272 for ( unsigned int i = 0; i < 10; i++ ) { 272 for ( unsigned int i = 0; i < 10; i++ ) {
273 if ( v > i ) { 273 if ( v > i ) {
274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
275 } else { 275 } else {
276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
277 } 277 }
278 } 278 }
279 } 279 }
280} 280}
281 281
282 282
283void MediaPlayer::blank( bool b ) { 283void MediaPlayer::blank( bool b ) {
284#ifdef QT_QWS_DEVFS
285 fd=open("/dev/fb/0",O_RDWR);
286#else
284 fd=open("/dev/fb0",O_RDWR); 287 fd=open("/dev/fb0",O_RDWR);
288#endif
285#ifdef QT_QWS_SL5XXX 289#ifdef QT_QWS_SL5XXX
286 fl= open( "/dev/fl", O_RDWR ); 290 fl= open( "/dev/fl", O_RDWR );
287#endif 291#endif
288 if (fd != -1) { 292 if (fd != -1) {
289 if ( b ) { 293 if ( b ) {
290 odebug << "do blanking" << oendl; 294 odebug << "do blanking" << oendl;
291#ifdef QT_QWS_SL5XXX 295#ifdef QT_QWS_SL5XXX
292 ioctl( fd, FBIOBLANK, 1 ); 296 ioctl( fd, FBIOBLANK, 1 );
293 if(fl !=-1) { 297 if(fl !=-1) {
294 ioctl( fl, 2 ); 298 ioctl( fl, 2 );
295 ::close(fl); 299 ::close(fl);
296 } 300 }
297#else 301#else
298 ioctl( fd, FBIOBLANK, 3 ); 302 ioctl( fd, FBIOBLANK, 3 );
299#endif 303#endif
300 isBlanked = TRUE; 304 isBlanked = TRUE;
301 } else { 305 } else {
302 odebug << "do unblanking" << oendl; 306 odebug << "do unblanking" << oendl;
303 ioctl( fd, FBIOBLANK, 0); 307 ioctl( fd, FBIOBLANK, 0);
304#ifdef QT_QWS_SL5XXX 308#ifdef QT_QWS_SL5XXX
305 if(fl != -1) { 309 if(fl != -1) {
306 ioctl( fl, 1); 310 ioctl( fl, 1);
307 ::close(fl); 311 ::close(fl);
308 } 312 }
309#endif 313#endif
310 isBlanked = FALSE; 314 isBlanked = FALSE;
311 } 315 }
312 close( fd ); 316 close( fd );
313 } else { 317 } else {
314 odebug << "<< /dev/fb0 could not be opened >>" << oendl; 318 odebug << "<< /dev/fb0 could not be opened >>" << oendl;
315 } 319 }
316} 320}
317 321
318void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 322void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
319 switch ( e->key() ) { 323 switch ( e->key() ) {
320////////////////////////////// Zaurus keys 324////////////////////////////// Zaurus keys
321 case Key_Home: 325 case Key_Home:
322 break; 326 break;
323 case Key_F9: //activity 327 case Key_F9: //activity
324 break; 328 break;
325 case Key_F10: //contacts 329 case Key_F10: //contacts
326 break; 330 break;
327 case Key_F11: //menu 331 case Key_F11: //menu
328 break; 332 break;
329 case Key_F12: //home 333 case Key_F12: //home
330 odebug << "Blank here" << oendl; 334 odebug << "Blank here" << oendl;
331// mediaPlayerState->toggleBlank(); 335// mediaPlayerState->toggleBlank();
332 break; 336 break;
333 case Key_F13: //mail 337 case Key_F13: //mail
334 odebug << "Blank here" << oendl; 338 odebug << "Blank here" << oendl;
335 // mediaPlayerState->toggleBlank(); 339 // mediaPlayerState->toggleBlank();
336 break; 340 break;
337 } 341 }
338} 342}
339 343
340void MediaPlayer::cleanUp() {// this happens on closing 344void MediaPlayer::cleanUp() {// this happens on closing
341 Config cfg( "OpiePlayer" ); 345 Config cfg( "OpiePlayer" );
342 mediaPlayerState.writeConfig( cfg ); 346 mediaPlayerState.writeConfig( cfg );
343 playList.writeDefaultPlaylist( ); 347 playList.writeDefaultPlaylist( );
344 348
345// QPEApplication::grabKeyboard(); 349// QPEApplication::grabKeyboard();
346// QPEApplication::ungrabKeyboard(); 350// QPEApplication::ungrabKeyboard();
347} 351}
348 352
349void MediaPlayer::recreateAudioAndVideoWidgets() const 353void MediaPlayer::recreateAudioAndVideoWidgets() const
350{ 354{
351 delete m_skinLoader; 355 delete m_skinLoader;
352 356
353 delete m_xineControl; 357 delete m_xineControl;
354 delete m_audioUI; 358 delete m_audioUI;
355 delete m_videoUI; 359 delete m_videoUI;
356 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 360 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
357 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 361 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
358 362
359 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 363 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
360 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 364 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
361 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 365 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
362 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 366 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
363 367
364 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 368 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
365 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 369 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
366 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 370 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
367 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 371 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
368 372
369 if ( !xine ) 373 if ( !xine )
370 xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); 374 xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
371 375
372 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); 376 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
373 377
374 xine = 0; 378 xine = 0;
375} 379}
376 380
377AudioWidget *MediaPlayer::audioUI() const 381AudioWidget *MediaPlayer::audioUI() const
378{ 382{
379 if ( !m_audioUI ) 383 if ( !m_audioUI )
380 recreateAudioAndVideoWidgets(); 384 recreateAudioAndVideoWidgets();
381 return m_audioUI; 385 return m_audioUI;
382} 386}
383 387
384VideoWidget *MediaPlayer::videoUI() const 388VideoWidget *MediaPlayer::videoUI() const
385{ 389{
386 if ( !m_videoUI ) 390 if ( !m_videoUI )
387 recreateAudioAndVideoWidgets(); 391 recreateAudioAndVideoWidgets();
388 return m_videoUI; 392 return m_videoUI;
389} 393}
390 394
391XineControl *MediaPlayer::xineControl() const 395XineControl *MediaPlayer::xineControl() const
392{ 396{
393 if ( !m_xineControl ) 397 if ( !m_xineControl )
394 recreateAudioAndVideoWidgets(); 398 recreateAudioAndVideoWidgets();
395 return m_xineControl; 399 return m_xineControl;
396} 400}
397 401
398void MediaPlayer::reloadSkins() 402void MediaPlayer::reloadSkins()
399{ 403{
400 audioUI()->loadSkin(); 404 audioUI()->loadSkin();
401 videoUI()->loadSkin(); 405 videoUI()->loadSkin();
402} 406}
403 407
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index 683f0a5..cb47b77 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -1,358 +1,374 @@
1// device.cpp 1// device.cpp
2 2
3#include "device.h" 3#include "device.h"
4 4
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
7 7
8/* STD */ 8/* STD */
9#include <fcntl.h> 9#include <fcntl.h>
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
12#include <sys/ioctl.h> 12#include <sys/ioctl.h>
13#include <sys/soundcard.h> 13#include <sys/soundcard.h>
14#include <unistd.h> 14#include <unistd.h>
15#include <sys/wait.h> 15#include <sys/wait.h>
16#include <unistd.h> 16#include <unistd.h>
17#include <errno.h> 17#include <errno.h>
18 18
19//extern QtRec *qperec; 19//extern QtRec *qperec;
20 20
21Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) 21Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record )
22 : QObject( parent) 22 : QObject( parent)
23{ 23{
24 dspstr = (char *)dsp; 24 dspstr = (char *)dsp;
25 mixstr = (char *)mixr; 25 mixstr = (char *)mixr;
26 26
27 devForm=-1; 27 devForm=-1;
28 devCh=-1; 28 devCh=-1;
29 devRate=-1; 29 devRate=-1;
30 30
31 if( !record){ //playing 31 if( !record){ //playing
32 qDebug( "setting up DSP for playing" ); 32 qDebug( "setting up DSP for playing" );
33 flags = O_WRONLY; 33 flags = O_WRONLY;
34 } else { //recording 34 } else { //recording
35 qDebug( "setting up DSP for recording" ); 35 qDebug( "setting up DSP for recording" );
36 flags = O_RDWR; 36 flags = O_RDWR;
37// flags = O_RDONLY; 37// flags = O_RDONLY;
38 38
39// selectMicInput(); 39// selectMicInput();
40 40
41 } 41 }
42} 42}
43 43
44bool Device::openDsp() { 44bool Device::openDsp() {
45 if( openDevice( flags) == -1) { 45 if( openDevice( flags) == -1) {
46 perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); 46 perror("<<<<<<<<<<<<<<ioctl(\"Open device\")");
47 return false; 47 return false;
48 } 48 }
49 return true; 49 return true;
50} 50}
51 51
52int Device::openDevice( int flags) { 52int Device::openDevice( int flags) {
53/* pid_t pid; 53/* pid_t pid;
54 int status; 54 int status;
55 int pipefd[2]; 55 int pipefd[2];
56 char message[20]; 56 char message[20];
57 if (pipe(pipefd) == -1){ 57 if (pipe(pipefd) == -1){
58 perror ("Error creating pipe"); 58 perror ("Error creating pipe");
59exit(1); 59exit(1);
60 } 60 }
61 switch (pid = fork()) { 61 switch (pid = fork()) {
62 case -1: 62 case -1:
63 perror("The fork failed!"); 63 perror("The fork failed!");
64 break; 64 break;
65 case 0: { 65 case 0: {
66 */ 66 */
67qDebug( "Opening %s",dspstr); 67qDebug( "Opening %s",dspstr);
68 if (( sd = ::open( dspstr, flags)) == -1) { 68 if (( sd = ::open( dspstr, flags)) == -1) {
69 perror("open(\"/dev/dsp\")"); 69 perror("open(\"/dev/dsp\")");
70 QString errorMsg="Could not open audio device\n /dev/dsp\n" 70 QString errorMsg="Could not open audio device\n /dev/dsp\n"
71 +(QString)strerror(errno); 71 +(QString)strerror(errno);
72 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); 72 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
73 return -1; 73 return -1;
74 } 74 }
75 75
76qDebug( "Opening mixer" ); 76qDebug( "Opening mixer" );
77 int mixerHandle=0; 77 int mixerHandle=0;
78#ifdef QT_QWS_DEVFS
79 if (( mixerHandle = open("/dev/sound/mixer",O_RDWR))<0) {
80#else
78 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { 81 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) {
82#endif
79 perror("open(\"/dev/mixer\")"); 83 perror("open(\"/dev/mixer\")");
80 QString errorMsg="Could not open audio device\n /dev/dsp\n" 84 QString errorMsg="Could not open audio device\n /dev/dsp\n"
81 +(QString)strerror(errno); 85 +(QString)strerror(errno);
82 qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); 86 qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
83 } 87 }
84 88
85 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ 89 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
86 perror("ioctl RESET"); 90 perror("ioctl RESET");
87 } 91 }
88// sprintf(message, "%d", sd); 92// sprintf(message, "%d", sd);
89 93
90/* QFile f1("/pid"); 94/* QFile f1("/pid");
91 f1.open(IO_WriteOnly ); 95 f1.open(IO_WriteOnly );
92 f1.writeBlock(message, strlen(message)); 96 f1.writeBlock(message, strlen(message));
93 f1.close(); 97 f1.close();
94 */ 98 */
95 /* close(pipefd[0]); 99 /* close(pipefd[0]);
96 write(pipefd[1], message, sizeof(message)); 100 write(pipefd[1], message, sizeof(message));
97 close(pipefd[1]); 101 close(pipefd[1]);
98 // qDebug( "" + soundDevice->sd ); 102 // qDebug( "" + soundDevice->sd );
99 _exit(0); 103 _exit(0);
100 } 104 }
101 default: 105 default:
102 // pid greater than zero is parent getting the child's pid 106 // pid greater than zero is parent getting the child's pid
103 printf("Child's pid is %d\n",pid); 107 printf("Child's pid is %d\n",pid);
104 QString s; 108 QString s;
105 close(pipefd[1]); 109 close(pipefd[1]);
106 read(pipefd[0], message, sizeof(message)); 110 read(pipefd[0], message, sizeof(message));
107 s = message; 111 s = message;
108 close(pipefd[0]); 112 close(pipefd[0]);
109 113
110// while(wait(NULL)!=pid) 114// while(wait(NULL)!=pid)
111 // ; 115 // ;
112 printf("child %ld terminated normally, return status is zero\n", (long) pid); 116 printf("child %ld terminated normally, return status is zero\n", (long) pid);
113 */ 117 */
114 // filePara.sd=(long) pid; 118 // filePara.sd=(long) pid;
115 /* QFile f2("/pid"); 119 /* QFile f2("/pid");
116 f2.open(IO_ReadOnly); 120 f2.open(IO_ReadOnly);
117 QTextStream t(&f2); 121 QTextStream t(&f2);
118 // for(int f=0; f < t.atEnd() ;f++) { 122 // for(int f=0; f < t.atEnd() ;f++) {
119 s = t.readLine(); 123 s = t.readLine();
120 // } 124 // }
121 */ 125 */
122// bool ok; 126// bool ok;
123// sd = s.toInt(&ok, 10); 127// sd = s.toInt(&ok, 10);
124// qDebug( "<<<<<<<<<<<<<>>>>>>>>>>>>"+s ); 128// qDebug( "<<<<<<<<<<<<<>>>>>>>>>>>>"+s );
125 129
126// f2.close(); 130// f2.close();
127// } 131// }
128::close(mixerHandle ); 132::close(mixerHandle );
129// qDebug( "open device " + dspstr ); 133// qDebug( "open device " + dspstr );
130// qDebug( "success! " + sd ); 134// qDebug( "success! " + sd );
131 return sd; 135 return sd;
132} 136}
133 137
134 138
135int Device::getOutVolume( ) { 139int Device::getOutVolume( ) {
136 unsigned int volume; 140 unsigned int volume;
137 int mixerHandle = open( mixstr, O_RDWR ); 141 int mixerHandle = open( mixstr, O_RDWR );
138 if ( mixerHandle >= 0 ) { 142 if ( mixerHandle >= 0 ) {
139 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) 143 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1)
140 perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); 144 perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")");
141 ::close( mixerHandle ); 145 ::close( mixerHandle );
142 } else 146 } else
143 perror("open(\"/dev/mixer\")"); 147 perror("open(\"/dev/mixer\")");
144 printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); 148 printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume);
145 149
146 Config cfg("qpe"); 150 Config cfg("qpe");
147 cfg.setGroup("Volume"); 151 cfg.setGroup("Volume");
148 152
149 return cfg.readNumEntry("VolumePercent"); 153 return cfg.readNumEntry("VolumePercent");
150} 154}
151 155
152int Device::getInVolume() { 156int Device::getInVolume() {
153 unsigned int volume=0; 157 unsigned int volume=0;
154 int mixerHandle = ::open( mixstr, O_RDWR ); 158 int mixerHandle = ::open( mixstr, O_RDWR );
155 if ( mixerHandle >= 0 ) { 159 if ( mixerHandle >= 0 ) {
156 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) 160 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1)
157 perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); 161 perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")");
158 ::close( mixerHandle ); 162 ::close( mixerHandle );
159 } else 163 } else
160 perror("open(\"/dev/mixer\")"); 164 perror("open(\"/dev/mixer\")");
161 printf("<<<<<<<<<<<<<<input volume %d\n", volume ); 165 printf("<<<<<<<<<<<<<<input volume %d\n", volume );
162 Config cfg("qpe"); 166 Config cfg("qpe");
163 cfg.setGroup("Volume"); 167 cfg.setGroup("Volume");
164 168
165 return cfg.readNumEntry("Mic"); 169 return cfg.readNumEntry("Mic");
166} 170}
167 171
168void Device::changedOutVolume(int vol) { 172void Device::changedOutVolume(int vol) {
169 int level = (vol << 8) + vol; 173 int level = (vol << 8) + vol;
170 int fd = 0; 174 int fd = 0;
175#ifdef QT_QWS_DEVFS
176 if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) {
177#else
171 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 178 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
179#endif
172 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) 180 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1)
173 perror("ioctl(\"MIXER_IN_WRITE\")"); 181 perror("ioctl(\"MIXER_IN_WRITE\")");
174 182
175 Config cfg("qpe"); 183 Config cfg("qpe");
176 cfg.setGroup("Volume"); 184 cfg.setGroup("Volume");
177 cfg.writeEntry("VolumePercent", QString::number( vol )); 185 cfg.writeEntry("VolumePercent", QString::number( vol ));
178 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; 186 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
179 qDebug("changing output vol %d" ,vol ); 187 qDebug("changing output vol %d" ,vol );
180 } 188 }
181 ::close(fd); 189 ::close(fd);
182} 190}
183 191
184void Device::changedInVolume(int vol ) { 192void Device::changedInVolume(int vol ) {
185 int level = (vol << 8) + vol; 193 int level = (vol << 8) + vol;
186 int fd = 0; 194 int fd = 0;
195#ifdef QT_QWS_DEVFS
196 if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) {
197#else
187 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 198 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
199#endif
188 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) 200 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1)
189 perror("ioctl(\"MIXER_IN_WRITE\")"); 201 perror("ioctl(\"MIXER_IN_WRITE\")");
190 Config cfg("qpe"); 202 Config cfg("qpe");
191 cfg.setGroup("Volume"); 203 cfg.setGroup("Volume");
192 cfg.writeEntry("Mic", QString::number(vol )); 204 cfg.writeEntry("Mic", QString::number(vol ));
193 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; 205 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
194 qDebug("changing input volume %d",vol); 206 qDebug("changing input volume %d",vol);
195 } 207 }
196 ::close(fd); 208 ::close(fd);
197} 209}
198 210
199bool Device::selectMicInput() { 211bool Device::selectMicInput() {
200 212
201 int md=0; 213 int md=0;
202 int info=MIXER_WRITE(SOUND_MIXER_MIC); 214 int info=MIXER_WRITE(SOUND_MIXER_MIC);
215#ifdef QT_QWS_DEVFS
216 md = ::open( "/dev/sound/mixer", O_RDWR );
217#else
203 md = ::open( "/dev/mixer", O_RDWR ); 218 md = ::open( "/dev/mixer", O_RDWR );
219#endif
204 if ( md == -1) 220 if ( md == -1)
205 perror("open(\"/dev/mixer\")"); 221 perror("open(\"/dev/mixer\")");
206 else { 222 else {
207 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) 223 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1)
208 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); 224 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")");
209 ::close(md); 225 ::close(md);
210 return false; 226 return false;
211 } 227 }
212 ::close(md); 228 ::close(md);
213 229
214 return true; 230 return true;
215} 231}
216 232
217bool Device::closeDevice( bool) { 233bool Device::closeDevice( bool) {
218// if(b) {//close now 234// if(b) {//close now
219// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { 235// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
220// perror("ioctl(\"SNDCTL_DSP_RESET\")"); 236// perror("ioctl(\"SNDCTL_DSP_RESET\")");
221// } 237// }
222// } else { //let play 238// } else { //let play
223// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { 239// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) {
224// perror("ioctl(\"SNDCTL_DSP_SYNC\")"); 240// perror("ioctl(\"SNDCTL_DSP_SYNC\")");
225// } 241// }
226// } 242// }
227 243
228 ::close( sd); //close sound device 244 ::close( sd); //close sound device
229// sdfd=0; 245// sdfd=0;
230 // sd=0; 246 // sd=0;
231// qDebug( "closed dsp" ); 247// qDebug( "closed dsp" );
232 return true; 248 return true;
233} 249}
234 250
235bool Device::setDeviceFormat( int form) { 251bool Device::setDeviceFormat( int form) {
236 qDebug( "set device res %d: %d ",form, sd ); 252 qDebug( "set device res %d: %d ",form, sd );
237 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format 253 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
238 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 254 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
239 return false; 255 return false;
240 } 256 }
241 devRes=form; 257 devRes=form;
242 return true; 258 return true;
243} 259}
244 260
245bool Device::setDeviceChannels( int ch) { 261bool Device::setDeviceChannels( int ch) {
246 qDebug( "set channels %d: %d",ch ,sd); 262 qDebug( "set channels %d: %d",ch ,sd);
247 if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { 263 if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) {
248 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 264 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
249 return false; 265 return false;
250 } 266 }
251 devCh=ch; 267 devCh=ch;
252 return true; 268 return true;
253} 269}
254 270
255bool Device::setDeviceRate( int rate) { 271bool Device::setDeviceRate( int rate) {
256 qDebug( "set rate %d: %d",rate,sd); 272 qDebug( "set rate %d: %d",rate,sd);
257 if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { 273 if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) {
258 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 274 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
259 return false; 275 return false;
260 } 276 }
261 277
262 devRate=rate; 278 devRate=rate;
263 279
264 return true; 280 return true;
265} 281}
266 282
267int Device::getRes() { 283int Device::getRes() {
268 return devRes; 284 return devRes;
269} 285}
270 286
271int Device::getFormat() { 287int Device::getFormat() {
272 return devForm; 288 return devForm;
273} 289}
274 290
275int Device::getRate() { 291int Device::getRate() {
276 return devRate; 292 return devRate;
277} 293}
278 294
279int Device::getChannels() { 295int Device::getChannels() {
280 return devCh; 296 return devCh;
281} 297}
282 298
283int Device::getDeviceFormat() { 299int Device::getDeviceFormat() {
284 return 0; 300 return 0;
285} 301}
286 302
287 303
288int Device::getDeviceRate() { 304int Device::getDeviceRate() {
289 int dRate=0; 305 int dRate=0;
290 if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) { 306 if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) {
291 perror("ioctl(\"SNDCTL_PCM_READ_RATE\")"); 307 perror("ioctl(\"SNDCTL_PCM_READ_RATE\")");
292 } 308 }
293 return dRate; 309 return dRate;
294 310
295} 311}
296 312
297int Device::getDeviceBits() { 313int Device::getDeviceBits() {
298 int dBits=0; 314 int dBits=0;
299#ifndef QT_QWS_EBX // zaurus doesnt have this 315#ifndef QT_QWS_EBX // zaurus doesnt have this
300 if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) { 316 if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) {
301 perror("ioctl(\"SNDCTL_PCM_READ_BITS\")"); 317 perror("ioctl(\"SNDCTL_PCM_READ_BITS\")");
302 } 318 }
303#endif 319#endif
304 return dBits; 320 return dBits;
305} 321}
306 322
307int Device::getDeviceChannels() { 323int Device::getDeviceChannels() {
308 int dCh=0; 324 int dCh=0;
309 if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) { 325 if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) {
310 perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")"); 326 perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")");
311 } 327 }
312 return dCh; 328 return dCh;
313} 329}
314 330
315int Device::getDeviceFragSize() { 331int Device::getDeviceFragSize() {
316 int frag_size; 332 int frag_size;
317 333
318 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { 334 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
319 qDebug( "no fragsize" ); 335 qDebug( "no fragsize" );
320 } else { 336 } else {
321 qDebug( "driver says frag size is %d",frag_size); 337 qDebug( "driver says frag size is %d",frag_size);
322 } 338 }
323 return frag_size; 339 return frag_size;
324} 340}
325 341
326bool Device::setFragSize(int frag) { 342bool Device::setFragSize(int frag) {
327 if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) { 343 if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) {
328 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 344 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
329 return false; 345 return false;
330 } 346 }
331 return true; 347 return true;
332} 348}
333 349
334bool Device::reset() { 350bool Device::reset() {
335 closeDevice(true); 351 closeDevice(true);
336 openDsp(); 352 openDsp();
337 if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { 353 if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
338 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 354 perror("ioctl(\"SNDCTL_DSP_RESET\")");
339 return false; 355 return false;
340 } 356 }
341 return true; 357 return true;
342} 358}
343 359
344int Device::devRead(int soundDescriptor, short *buf, int size) { 360int Device::devRead(int soundDescriptor, short *buf, int size) {
345 Q_UNUSED(soundDescriptor); 361 Q_UNUSED(soundDescriptor);
346 int number = 0; 362 int number = 0;
347 number = ::read( sd /*soundDescriptor*/, (char *)buf, size); 363 number = ::read( sd /*soundDescriptor*/, (char *)buf, size);
348 return number; 364 return number;
349} 365}
350 366
351int Device::devWrite(int soundDescriptor, short * buf, int size) { 367int Device::devWrite(int soundDescriptor, short * buf, int size) {
352 Q_UNUSED(soundDescriptor); 368 Q_UNUSED(soundDescriptor);
353 int bytesWritten = 0; 369 int bytesWritten = 0;
354 bytesWritten = ::write( sd /*soundDescriptor*/, buf, size); 370 bytesWritten = ::write( sd /*soundDescriptor*/, buf, size);
355 return bytesWritten; 371 return bytesWritten;
356} 372}
357 373
358 374
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 1141faa..c237726 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,2144 +1,2151 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#define DEV_VERSION 6#define DEV_VERSION
7 7
8#include "pixmaps.h" 8#include "pixmaps.h"
9#include "qtrec.h" 9#include "qtrec.h"
10#include "waveform.h" 10#include "waveform.h"
11extern "C" { 11extern "C" {
12#include "adpcm.h" 12#include "adpcm.h"
13} 13}
14 14
15/* OPIE */ 15/* OPIE */
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39/* STD */ 39/* STD */
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <math.h> 42#include <math.h>
43#include <mntent.h> 43#include <mntent.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <sys/ioctl.h> 46#include <sys/ioctl.h>
47#include <sys/soundcard.h> 47#include <sys/soundcard.h>
48#include <sys/stat.h> 48#include <sys/stat.h>
49#include <sys/time.h> 49#include <sys/time.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/vfs.h> 51#include <sys/vfs.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/wait.h> 53#include <sys/wait.h>
54#include <sys/signal.h> 54#include <sys/signal.h>
55#include <pthread.h> 55#include <pthread.h>
56 56
57#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
58#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
60static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
61#else //OSS 61#else //OSS
62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
63static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
64#endif 64#endif
65 65
66#if defined(QT_QWS_SL5XXX) 66#if defined(QT_QWS_SL5XXX)
67///#if defined(QT_QWS_EBX) 67///#if defined(QT_QWS_EBX)
68 68
69#define DSPSTROUT "/dev/dsp" 69#define DSPSTROUT "/dev/dsp"
70#define DSPSTRMIXEROUT "/dev/mixer" 70#define DSPSTRMIXEROUT "/dev/mixer"
71 71
72#ifdef SHARP 72#ifdef SHARP
73#define DSPSTRIN "/dev/dsp1" 73#define DSPSTRIN "/dev/dsp1"
74#define DSPSTRMIXERIN "/dev/mixer1" 74#define DSPSTRMIXERIN "/dev/mixer1"
75#else 75#else
76#define DSPSTRIN "/dev/dsp" 76#define DSPSTRIN "/dev/dsp"
77#define DSPSTRMIXERIN "/dev/mixer" 77#define DSPSTRMIXERIN "/dev/mixer"
78#endif 78#endif
79 79
80#else 80#else
81 81
82#ifdef QT_QWS_DEVFS
83#define DSPSTROUT "/dev/sound/dsp"
84#define DSPSTRIN "/dev/sound/dsp"
85#define DSPSTRMIXERIN "/dev/sound/mixer"
86#define DSPSTRMIXEROUT "/dev/sound/mixer"
87#else
82#define DSPSTROUT "/dev/dsp" 88#define DSPSTROUT "/dev/dsp"
83#define DSPSTRIN "/dev/dsp" 89#define DSPSTRIN "/dev/dsp"
84#define DSPSTRMIXERIN "/dev/mixer" 90#define DSPSTRMIXERIN "/dev/mixer"
85#define DSPSTRMIXEROUT "/dev/mixer" 91#define DSPSTRMIXEROUT "/dev/mixer"
92#endif
86 93
87#endif 94#endif
88 95
89//#define ZAURUS 0 96//#define ZAURUS 0
90struct adpcm_state encoder_state; 97struct adpcm_state encoder_state;
91struct adpcm_state decoder_state; 98struct adpcm_state decoder_state;
92 99
93typedef struct { 100typedef struct {
94 int sampleRate; 101 int sampleRate;
95 /* int fragSize; */ 102 /* int fragSize; */
96 /* int blockSize; */ 103 /* int blockSize; */
97 int resolution; //bitrate 104 int resolution; //bitrate
98 int channels; //number of channels 105 int channels; //number of channels
99 int fd; //file descriptor 106 int fd; //file descriptor
100 int sd; //sound device descriptor 107 int sd; //sound device descriptor
101 int numberSamples; //total number of samples 108 int numberSamples; //total number of samples
102 int SecondsToRecord; // number of seconds that should be recorded 109 int SecondsToRecord; // number of seconds that should be recorded
103 float numberOfRecordedSeconds; //total number of samples recorded 110 float numberOfRecordedSeconds; //total number of samples recorded
104 int samplesToRecord; //number of samples to be recorded 111 int samplesToRecord; //number of samples to be recorded
105 int inVol; //input volume 112 int inVol; //input volume
106 int outVol; //output volume 113 int outVol; //output volume
107 int format; //wavfile format PCM.. ADPCM 114 int format; //wavfile format PCM.. ADPCM
108 const char *fileName; //name of fiel to be played/recorded 115 const char *fileName; //name of fiel to be played/recorded
109} fileParameters; 116} fileParameters;
110 117
111fileParameters filePara; 118fileParameters filePara;
112 119
113bool monitoring, recording, playing; 120bool monitoring, recording, playing;
114bool stopped; 121bool stopped;
115QLabel *timeLabel; 122QLabel *timeLabel;
116QSlider *timeSlider; 123QSlider *timeSlider;
117int sd; 124int sd;
118 125
119Waveform* waveform; 126Waveform* waveform;
120Device *soundDevice; 127Device *soundDevice;
121 128
122 129
123#ifdef THREADED 130#ifdef THREADED
124void quickRec() 131void quickRec()
125#else 132#else
126 void QtRec::quickRec() 133 void QtRec::quickRec()
127#endif 134#endif
128{ 135{
129 136
130 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; 137 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl;
131 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate 138 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate
132 << ", channels " << filePara.channels << oendl; 139 << ", channels " << filePara.channels << oendl;
133 140
134 int total = 0; // Total number of bytes read in so far. 141 int total = 0; // Total number of bytes read in so far.
135 int bytesWritten, number; 142 int bytesWritten, number;
136 143
137 bytesWritten = 0; 144 bytesWritten = 0;
138 number = 0; 145 number = 0;
139 QString num; 146 QString num;
140 int level = 0; 147 int level = 0;
141 int threshold = 0; 148 int threshold = 0;
142 int bits = filePara.resolution; 149 int bits = filePara.resolution;
143 odebug << "bits " << bits << "" << oendl; 150 odebug << "bits " << bits << "" << oendl;
144 151
145 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 152 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
146 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; 153 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
147 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; 154 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
148 odebug << "" << filePara.sd << "" << oendl; 155 odebug << "" << filePara.sd << "" << oendl;
149 level = 7; 156 level = 7;
150 threshold = 0; 157 threshold = 0;
151 158
152 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 159 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
153 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; 160 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
154// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 161// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
155 char abuf[ BUFSIZE/2 ]; 162 char abuf[ BUFSIZE/2 ];
156 short sbuf[ BUFSIZE ]; 163 short sbuf[ BUFSIZE ];
157 short sbuf2[ BUFSIZE ]; 164 short sbuf2[ BUFSIZE ];
158 memset( abuf, 0, BUFSIZE/2); 165 memset( abuf, 0, BUFSIZE/2);
159 memset( sbuf, 0, BUFSIZE); 166 memset( sbuf, 0, BUFSIZE);
160 memset( sbuf2, 0, BUFSIZE); 167 memset( sbuf2, 0, BUFSIZE);
161 168
162 for(;;) { 169 for(;;) {
163 if ( stopped) { 170 if ( stopped) {
164 odebug << "quickRec:: stopped" << oendl; 171 odebug << "quickRec:: stopped" << oendl;
165 break; 172 break;
166 } 173 }
167 174
168// number=::read( filePara.sd, sbuf, BUFSIZE); 175// number=::read( filePara.sd, sbuf, BUFSIZE);
169 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); 176 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE);
170 177
171 if(number <= 0) { 178 if(number <= 0) {
172 perror("recording error "); 179 perror("recording error ");
173 odebug << "" << filePara.fileName << " " << number << "" << oendl; 180 odebug << "" << filePara.fileName << " " << number << "" << oendl;
174 stopped = true; 181 stopped = true;
175 return; 182 return;
176 } 183 }
177 //if(stereo == 2) { 184 //if(stereo == 2) {
178// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 185// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
179 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 186 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
180 187
181 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); 188 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
182 189
183 waveform->newSamples( sbuf, number ); 190 waveform->newSamples( sbuf, number );
184 191
185 total += bytesWritten; 192 total += bytesWritten;
186 filePara.numberSamples = total; 193 filePara.numberSamples = total;
187 timeSlider->setValue( total); 194 timeSlider->setValue( total);
188 195
189 printf("%d, bytes %d,total %d\r",number, bytesWritten, total); 196 printf("%d, bytes %d,total %d\r",number, bytesWritten, total);
190 fflush(stdout); 197 fflush(stdout);
191 198
192 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; 199 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels;
193 200
194 qApp->processEvents(); 201 qApp->processEvents();
195 if( total >= filePara.samplesToRecord) { 202 if( total >= filePara.samplesToRecord) {
196 stopped = true; 203 stopped = true;
197 break; 204 break;
198 } 205 }
199 } 206 }
200 } else { 207 } else {
201 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 208 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
202 odebug << "start recording WAVE_FORMAT_PCM" << oendl; 209 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
203 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 210 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
204 memset( inbuffer, 0, BUFSIZE); 211 memset( inbuffer, 0, BUFSIZE);
205 memset( outbuffer, 0, BUFSIZE); 212 memset( outbuffer, 0, BUFSIZE);
206 213
207 for(;;) { 214 for(;;) {
208 if ( stopped) { 215 if ( stopped) {
209 odebug << "quickRec:: stopped" << oendl; 216 odebug << "quickRec:: stopped" << oendl;
210 stopped = true; 217 stopped = true;
211 break; // stop if playing was set to false 218 break; // stop if playing was set to false
212 return; 219 return;
213 } 220 }
214 221
215 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE); 222 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE);
216 223
217 if( number <= 0) { 224 if( number <= 0) {
218 perror( "recording error "); 225 perror( "recording error ");
219 odebug << filePara.fileName << oendl; 226 odebug << filePara.fileName << oendl;
220 stopped = true; 227 stopped = true;
221 return; 228 return;
222 } 229 }
223 230
224 bytesWritten = ::write( filePara.fd , inbuffer, number); 231 bytesWritten = ::write( filePara.fd , inbuffer, number);
225 waveform->newSamples( inbuffer, number ); 232 waveform->newSamples( inbuffer, number );
226 233
227 if( bytesWritten < 0) { 234 if( bytesWritten < 0) {
228 perror("File writing error "); 235 perror("File writing error ");
229 stopped = true; 236 stopped = true;
230 return; 237 return;
231 } 238 }
232 239
233 total += bytesWritten; 240 total += bytesWritten;
234 241
235 filePara.numberSamples = total; 242 filePara.numberSamples = total;
236 243
237 if( filePara.SecondsToRecord != 0) 244 if( filePara.SecondsToRecord != 0)
238 timeSlider->setValue( total); 245 timeSlider->setValue( total);
239 printf("%d, bytes %d,total %d\r",number, bytesWritten , total); 246 printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
240 fflush(stdout); 247 fflush(stdout);
241 248
242 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate 249 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
243 / (float)2/filePara.channels; 250 / (float)2/filePara.channels;
244 qApp->processEvents(); 251 qApp->processEvents();
245 252
246 if( total >= filePara.samplesToRecord) { 253 if( total >= filePara.samplesToRecord) {
247 stopped = true; 254 stopped = true;
248 break; 255 break;
249 } 256 }
250 } 257 }
251 } //end main loop 258 } //end main loop
252 259
253 } else { 260 } else {
254// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 261// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
255 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 262 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
256 memset( unsigned_inbuffer, 0, BUFSIZE); 263 memset( unsigned_inbuffer, 0, BUFSIZE);
257 memset( unsigned_outbuffer, 0, BUFSIZE); 264 memset( unsigned_outbuffer, 0, BUFSIZE);
258 265
259 for(;;) { 266 for(;;) {
260 if ( stopped) { 267 if ( stopped) {
261 odebug << "quickRec:: stopped" << oendl; 268 odebug << "quickRec:: stopped" << oendl;
262 break; // stop if playing was set to false 269 break; // stop if playing was set to false
263 } 270 }
264 271
265 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE); 272 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE);
266 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 273 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
267 waveform->newSamples( (const short *) unsigned_inbuffer, number ); 274 waveform->newSamples( (const short *) unsigned_inbuffer, number );
268 275
269 if(bytesWritten < 0) { 276 if(bytesWritten < 0) {
270 stopped = true; 277 stopped = true;
271 QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); 278 QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
272 perror("File writing error "); 279 perror("File writing error ");
273 return; 280 return;
274 } 281 }
275 282
276 total += bytesWritten; 283 total += bytesWritten;
277 filePara.numberSamples = total; 284 filePara.numberSamples = total;
278 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total); 285 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total);
279 // fflush(stdout); 286 // fflush(stdout);
280 if( filePara.SecondsToRecord !=0) 287 if( filePara.SecondsToRecord !=0)
281 timeSlider->setValue( total); 288 timeSlider->setValue( total);
282 289
283 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 290 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
284 291
285 qApp->processEvents(); 292 qApp->processEvents();
286 if( total >= filePara.samplesToRecord) { 293 if( total >= filePara.samplesToRecord) {
287 stopped = true; 294 stopped = true;
288 break; 295 break;
289 } 296 }
290 } //end main loop 297 } //end main loop
291 } 298 }
292} /// END quickRec() 299} /// END quickRec()
293 300
294 301
295#ifdef THREADED 302#ifdef THREADED
296void playIt() 303void playIt()
297#else 304#else
298 void QtRec::playIt() 305 void QtRec::playIt()
299#endif 306#endif
300{ 307{
301 int bytesWritten = 0; 308 int bytesWritten = 0;
302 int number = 0; 309 int number = 0;
303 int total = 0; // Total number of bytes read in so far. 310 int total = 0; // Total number of bytes read in so far.
304 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 311 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
305 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 312 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
306 char abuf[ BUFSIZE / 2 ]; 313 char abuf[ BUFSIZE / 2 ];
307 short sbuf[ BUFSIZE ]; 314 short sbuf[ BUFSIZE ];
308 short sbuf2[ BUFSIZE * 2 ]; 315 short sbuf2[ BUFSIZE * 2 ];
309 memset( abuf, 0, BUFSIZE / 2); 316 memset( abuf, 0, BUFSIZE / 2);
310 memset( sbuf, 0, BUFSIZE); 317 memset( sbuf, 0, BUFSIZE);
311 memset( sbuf2, 0, BUFSIZE * 2); 318 memset( sbuf2, 0, BUFSIZE * 2);
312// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 319// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
313 for(;;) { // play loop 320 for(;;) { // play loop
314 if ( stopped) { 321 if ( stopped) {
315 break; 322 break;
316 return; 323 return;
317 }// stop if playing was set to false 324 }// stop if playing was set to false
318 325
319 number = ::read( filePara.fd, abuf, BUFSIZE / 2); 326 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
320 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); 327 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
321 328
322// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 329// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
323// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 330// sbuf2[i+1]=sbuf2[i]=sbuf[i];
324// } 331// }
325 bytesWritten = write ( filePara.sd, sbuf, number * 4); 332 bytesWritten = write ( filePara.sd, sbuf, number * 4);
326 waveform->newSamples( (const short *)sbuf, number *4); 333 waveform->newSamples( (const short *)sbuf, number *4);
327 // if(filePara.channels==1) 334 // if(filePara.channels==1)
328 // total += bytesWritten/2; //mono 335 // total += bytesWritten/2; //mono
329 // else 336 // else
330 total += bytesWritten; 337 total += bytesWritten;
331 filePara.numberSamples = total/4; 338 filePara.numberSamples = total/4;
332 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 339 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
333 340
334 timeSlider->setValue( total/4); 341 timeSlider->setValue( total/4);
335// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 342// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
336// if(filePara.numberOfRecordedSeconds>1) 343// if(filePara.numberOfRecordedSeconds>1)
337// timeLabel->setText( timeString+ tr(" seconds")); 344// timeLabel->setText( timeString+ tr(" seconds"));
338// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 345// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
339// fflush(stdout); 346// fflush(stdout);
340 347
341 qApp->processEvents(); 348 qApp->processEvents();
342 349
343 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 350 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
344// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 351// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
345 stopped = true; 352 stopped = true;
346 break; 353 break;
347 } 354 }
348 } 355 }
349 } else { 356 } else {
350 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 357 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
351 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 358 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
352 memset( inbuffer, 0, BUFSIZE); 359 memset( inbuffer, 0, BUFSIZE);
353 memset( outbuffer, 0, BUFSIZE); 360 memset( outbuffer, 0, BUFSIZE);
354 361
355 for(;;) { // play loop 362 for(;;) { // play loop
356 if ( stopped) { 363 if ( stopped) {
357 break; 364 break;
358 return; 365 return;
359 } 366 }
360// stop if playing was set to false 367// stop if playing was set to false
361 number = ::read( filePara.fd, inbuffer, BUFSIZE); 368 number = ::read( filePara.fd, inbuffer, BUFSIZE);
362// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 369// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
363// // for (int i=0;i< number ; i++) { //2*i is left channel 370// // for (int i=0;i< number ; i++) { //2*i is left channel
364// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 371// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
365// } 372// }
366 bytesWritten = ::write( filePara.sd, inbuffer, number); 373 bytesWritten = ::write( filePara.sd, inbuffer, number);
367 waveform->newSamples( inbuffer, number); 374 waveform->newSamples( inbuffer, number);
368 //-------------->>>> out to device 375 //-------------->>>> out to device
369 // total+=bytesWritten; 376 // total+=bytesWritten;
370 // if(filePara.channels==1) 377 // if(filePara.channels==1)
371 // total += bytesWritten/2; //mono 378 // total += bytesWritten/2; //mono
372 // else 379 // else
373 total += bytesWritten; 380 total += bytesWritten;
374 timeSlider->setValue( total); 381 timeSlider->setValue( total);
375 382
376 filePara.numberSamples = total; 383 filePara.numberSamples = total;
377 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 384 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
378 385
379// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 386// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
380// timeLabel->setText( timeString + tr(" seconds")); 387// timeLabel->setText( timeString + tr(" seconds"));
381 388
382 qApp->processEvents(); 389 qApp->processEvents();
383 390
384 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 391 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
385 owarn << "Jane! Stop this crazy thing!" << oendl; 392 owarn << "Jane! Stop this crazy thing!" << oendl;
386 stopped = true; 393 stopped = true;
387// playing = false; 394// playing = false;
388 break; 395 break;
389 } 396 }
390 } 397 }
391// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 398// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
392// fflush(stdout); 399// fflush(stdout);
393 } //end loop 400 } //end loop
394 } else { 401 } else {
395/////////////////////////////// format = AFMT_U8; 402/////////////////////////////// format = AFMT_U8;
396 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 403 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
397 memset( unsigned_inbuffer, 0, BUFSIZE); 404 memset( unsigned_inbuffer, 0, BUFSIZE);
398 for(;;) { 405 for(;;) {
399// main loop 406// main loop
400 if (stopped) { 407 if (stopped) {
401 break; // stop if playing was set to false 408 break; // stop if playing was set to false
402 return; 409 return;
403 } 410 }
404 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 411 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
405//data = (val >> 8) ^ 0x80; 412//data = (val >> 8) ^ 0x80;
406 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 413 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
407 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 414 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
408 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 415 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
409 total += bytesWritten; 416 total += bytesWritten;
410 417
411 timeSlider->setValue( total); 418 timeSlider->setValue( total);
412 filePara.numberSamples = total; 419 filePara.numberSamples = total;
413 420
414 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 421 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
415// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 422// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
416// timeLabel->setText( timeString + tr(" seconds")); 423// timeLabel->setText( timeString + tr(" seconds"));
417 qApp->processEvents(); 424 qApp->processEvents();
418 425
419 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 426 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
420// if( total >= filePara.numberSamples ) { 427// if( total >= filePara.numberSamples ) {
421 stopped = true; 428 stopped = true;
422 break; 429 break;
423 } 430 }
424// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 431// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
425// fflush(stdout); 432// fflush(stdout);
426 } 433 }
427 } 434 }
428} 435}
429 436
430 437
431QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 438QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
432 : QWidget( parent, name, fl ) 439 : QWidget( parent, name, fl )
433{ 440{
434 if ( !name ) 441 if ( !name )
435 setName( "OpieRec" ); 442 setName( "OpieRec" );
436 init(); 443 init();
437 initConfig(); 444 initConfig();
438 initConnections(); 445 initConnections();
439 renameBox = 0; 446 renameBox = 0;
440 447
441// open sound device to get volumes 448// open sound device to get volumes
442 Config hwcfg("OpieRec"); 449 Config hwcfg("OpieRec");
443 hwcfg.setGroup("Hardware"); 450 hwcfg.setGroup("Hardware");
444 451
445 452
446 soundDevice = new Device( this, 453 soundDevice = new Device( this,
447 hwcfg.readEntry( "Audio",DSPSTROUT), 454 hwcfg.readEntry( "Audio",DSPSTROUT),
448 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); 455 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
449// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); 456// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
450 457
451// soundDevice->setDeviceFormat(AFMT_S16_LE); 458// soundDevice->setDeviceFormat(AFMT_S16_LE);
452// soundDevice->setDeviceChannels(1); 459// soundDevice->setDeviceChannels(1);
453// soundDevice->setDeviceRate( 22050); 460// soundDevice->setDeviceRate( 22050);
454 461
455 getInVol(); 462 getInVol();
456 getOutVol(); 463 getOutVol();
457 464
458 soundDevice->closeDevice( true); 465 soundDevice->closeDevice( true);
459 soundDevice->sd = -1; 466 soundDevice->sd = -1;
460 soundDevice = 0; 467 soundDevice = 0;
461 wavFile = 0; 468 wavFile = 0;
462 469
463// if( soundDevice) delete soundDevice; 470// if( soundDevice) delete soundDevice;
464 471
465 initIconView(); 472 initIconView();
466 473
467 if( autoMute) 474 if( autoMute)
468 doMute( true); 475 doMute( true);
469 ListView1->setFocus(); 476 ListView1->setFocus();
470 playing = false; 477 playing = false;
471} 478}
472 479
473QtRec::~QtRec() { 480QtRec::~QtRec() {
474// if( soundDevice) delete soundDevice; 481// if( soundDevice) delete soundDevice;
475 482
476} 483}
477 484
478void QtRec::cleanUp() { 485void QtRec::cleanUp() {
479 486
480 if( !stopped) { 487 if( !stopped) {
481 stopped = true; 488 stopped = true;
482 endRecording(); 489 endRecording();
483 } 490 }
484 491
485 ListView1->clear(); 492 ListView1->clear();
486 493
487 if( autoMute) 494 if( autoMute)
488 doMute(false); 495 doMute(false);
489 496
490// if( wavFile) delete wavFile; 497// if( wavFile) delete wavFile;
491// if(soundDevice) delete soundDevice; 498// if(soundDevice) delete soundDevice;
492} 499}
493 500
494void QtRec::init() { 501void QtRec::init() {
495 502
496 needsStereoOut = false; 503 needsStereoOut = false;
497 QPixmap image3( ( const char** ) image3_data ); 504 QPixmap image3( ( const char** ) image3_data );
498 QPixmap image4( ( const char** ) image4_data ); 505 QPixmap image4( ( const char** ) image4_data );
499 QPixmap image6( ( const char** ) image6_data ); 506 QPixmap image6( ( const char** ) image6_data );
500 507
501 stopped = true; 508 stopped = true;
502 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 509 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
503 QGridLayout *layout = new QGridLayout( this ); 510 QGridLayout *layout = new QGridLayout( this );
504 layout->setSpacing( 2); 511 layout->setSpacing( 2);
505 layout->setMargin( 2); 512 layout->setMargin( 2);
506 513
507 TabWidget = new QTabWidget( this, "TabWidget" ); 514 TabWidget = new QTabWidget( this, "TabWidget" );
508 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); 515 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8);
509// TabWidget->setTabShape(QTabWidget::Triangular); 516// TabWidget->setTabShape(QTabWidget::Triangular);
510 517
511 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 518 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
512 tab = new QWidget( TabWidget, "tab" ); 519 tab = new QWidget( TabWidget, "tab" );
513 520
514 QGridLayout *layout1 = new QGridLayout( tab); 521 QGridLayout *layout1 = new QGridLayout( tab);
515 layout1->setSpacing( 2); 522 layout1->setSpacing( 2);
516 layout1->setMargin( 2); 523 layout1->setMargin( 2);
517 524
518 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 525 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
519 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 526 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
520 527
521 // timeLabel = new QLabel( tab, "TimeLabel" ); 528 // timeLabel = new QLabel( tab, "TimeLabel" );
522 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 529 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
523 530
524 // playLabel2 = new QLabel(tab, "PlayLabel2" ); 531 // playLabel2 = new QLabel(tab, "PlayLabel2" );
525 // playLabel2->setText(tr("Play") ); 532 // playLabel2->setText(tr("Play") );
526 // playLabel2->setFixedHeight( 18); 533 // playLabel2->setFixedHeight( 18);
527 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 534 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
528 535
529 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 536 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
530 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 537 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
531 Stop_PushButton->setFixedSize( 22, 22); 538 Stop_PushButton->setFixedSize( 22, 22);
532 Stop_PushButton->setPixmap( image4 ); 539 Stop_PushButton->setPixmap( image4 );
533 540
534 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 541 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
535 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 542 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
536 toBeginningButton->setFixedSize( 22, 22); 543 toBeginningButton->setFixedSize( 22, 22);
537 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 544 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
538 545
539 toEndButton = new QPushButton( tab, "End_PushButton" ); 546 toEndButton = new QPushButton( tab, "End_PushButton" );
540 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 547 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
541 toEndButton->setFixedSize( 22, 22); 548 toEndButton->setFixedSize( 22, 22);
542 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 549 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
543 550
544 // QLabel *recLabel2; 551 // QLabel *recLabel2;
545 // recLabel2 = new QLabel( tab, "recLabel2" ); 552 // recLabel2 = new QLabel( tab, "recLabel2" );
546 // recLabel2->setText(tr("Rec")); 553 // recLabel2->setText(tr("Rec"));
547 // recLabel2->setFixedHeight( 18); 554 // recLabel2->setFixedHeight( 18);
548 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 555 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
549 556
550 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 557 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
551 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 558 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
552 Rec_PushButton->setFixedSize( 22, 22); 559 Rec_PushButton->setFixedSize( 22, 22);
553 Rec_PushButton->setPixmap( image6 ); 560 Rec_PushButton->setPixmap( image6 );
554 561
555 t = new QTimer( this ); 562 t = new QTimer( this );
556 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 563 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
557 564
558 rewindTimer = new QTimer( this ); 565 rewindTimer = new QTimer( this );
559 connect( rewindTimer, SIGNAL( timeout() ), 566 connect( rewindTimer, SIGNAL( timeout() ),
560 this, SLOT( rewindTimerTimeout() ) ); 567 this, SLOT( rewindTimerTimeout() ) );
561 568
562 forwardTimer = new QTimer( this ); 569 forwardTimer = new QTimer( this );
563 connect( forwardTimer, SIGNAL( timeout() ), 570 connect( forwardTimer, SIGNAL( timeout() ),
564 this, SLOT( forwardTimerTimeout() ) ); 571 this, SLOT( forwardTimerTimeout() ) );
565 572
566 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 573 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
567 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 574 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
568 deleteSoundButton->setText( tr( "Del" ) ); 575 deleteSoundButton->setText( tr( "Del" ) );
569 576
570 ListView1 = new QListView( tab, "IconView1" ); 577 ListView1 = new QListView( tab, "IconView1" );
571 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 578 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
572 579
573 ListView1->addColumn( tr( "Name" ) ); 580 ListView1->addColumn( tr( "Name" ) );
574 // ListView1->setColumnWidth( 0, 140); 581 // ListView1->setColumnWidth( 0, 140);
575 ListView1->setSorting( 1, false); 582 ListView1->setSorting( 1, false);
576 ListView1->addColumn( tr( "Time" ) ); //in seconds 583 ListView1->addColumn( tr( "Time" ) ); //in seconds
577 // ListView1->setColumnWidth( 1, -1); 584 // ListView1->setColumnWidth( 1, -1);
578 // ListView1->addColumn( tr("Location") ); 585 // ListView1->addColumn( tr("Location") );
579 // ListView1->setColumnWidth( 2, -1); 586 // ListView1->setColumnWidth( 2, -1);
580 // ListView1->addColumn( tr("Date") ); 587 // ListView1->addColumn( tr("Date") );
581 // ListView1->setColumnWidth( 3, -1); 588 // ListView1->setColumnWidth( 3, -1);
582 ListView1->setColumnWidthMode(0, QListView::Maximum); 589 ListView1->setColumnWidthMode(0, QListView::Maximum);
583 // ListView1->setColumnWidthMode(1, QListView::Maximum); 590 // ListView1->setColumnWidthMode(1, QListView::Maximum);
584 591
585 // ListView1->setColumnWidthMode( 0, QListView::Manual); 592 // ListView1->setColumnWidthMode( 0, QListView::Manual);
586 ListView1->setColumnAlignment( 1, QListView::AlignCenter); 593 ListView1->setColumnAlignment( 1, QListView::AlignCenter);
587 // ListView1->setColumnAlignment( 2, QListView::AlignRight); 594 // ListView1->setColumnAlignment( 2, QListView::AlignRight);
588 // ListView1->setColumnAlignment( 3, QListView::AlignLeft); 595 // ListView1->setColumnAlignment( 3, QListView::AlignLeft);
589 ListView1->setAllColumnsShowFocus( true ); 596 ListView1->setAllColumnsShowFocus( true );
590 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); 597 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
591 598
592 TabWidget->insertTab( tab, tr( "Files" ) ); 599 TabWidget->insertTab( tab, tr( "Files" ) );
593 600
594 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 601 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
595 tab_3 = new QWidget( TabWidget, "tab_3" ); 602 tab_3 = new QWidget( TabWidget, "tab_3" );
596 QGridLayout *glayout3 = new QGridLayout( tab_3 ); 603 QGridLayout *glayout3 = new QGridLayout( tab_3 );
597 glayout3->setSpacing( 2); 604 glayout3->setSpacing( 2);
598 glayout3->setMargin( 2); 605 glayout3->setMargin( 2);
599 //////////////////////////////////// 606 ////////////////////////////////////
600 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 607 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
601 sampleGroup->setTitle( tr( "Sample Rate" ) ); 608 sampleGroup->setTitle( tr( "Sample Rate" ) );
602 sampleGroup->setFixedSize( 95,50); 609 sampleGroup->setFixedSize( 95,50);
603 610
604 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 611 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
605 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 612 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
606//#ifndef QT_QWS_EBX 613//#ifndef QT_QWS_EBX
607 QString s; 614 QString s;
608 int z = 0; 615 int z = 0;
609 while( deviceSampleRates[z] != -1) { 616 while( deviceSampleRates[z] != -1) {
610 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); 617 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
611 z++; 618 z++;
612 } 619 }
613 620
614 621
615 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); 622 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
616 623
617 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 624 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
618 sizeGroup->setTitle( tr( "Limit Size" ) ); 625 sizeGroup->setTitle( tr( "Limit Size" ) );
619 sizeGroup->setFixedSize( 80, 50); 626 sizeGroup->setFixedSize( 80, 50);
620 627
621 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 628 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
622 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 629 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
623 sizeLimitCombo->insertItem(tr("Unlimited")); 630 sizeLimitCombo->insertItem(tr("Unlimited"));
624 631
625 for(int i=1;i<13; i++) { 632 for(int i=1;i<13; i++) {
626 sizeLimitCombo->insertItem( QString::number( i * 5)); 633 sizeLimitCombo->insertItem( QString::number( i * 5));
627 } 634 }
628 635
629 636
630 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); 637 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
631 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 638 dirGroup = new QGroupBox( tab_3, "dirGroup" );
632 dirGroup->setTitle( tr( "File Directory" ) ); 639 dirGroup->setTitle( tr( "File Directory" ) );
633 dirGroup->setFixedSize( 130, 50); 640 dirGroup->setFixedSize( 130, 50);
634 641
635 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 642 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
636 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 643 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
637 644
638 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); 645 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
639 646
640 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 647 bitGroup = new QGroupBox( tab_3, "bitGroup" );
641 bitGroup->setTitle( tr( "Bit Depth" ) ); 648 bitGroup->setTitle( tr( "Bit Depth" ) );
642 bitGroup->setFixedSize( 65, 50); 649 bitGroup->setFixedSize( 65, 50);
643 650
644 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 651 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
645 652
646 z = 0; 653 z = 0;
647 while( deviceBitRates[z] != -1) { 654 while( deviceBitRates[z] != -1) {
648 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); 655 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
649 z++; 656 z++;
650 } 657 }
651 658
652 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 659 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
653 660
654 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 661 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
655 662
656 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 663 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
657 664
658 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); 665 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
659 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); 666 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 );
660 667
661 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); 668 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
662 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); 669 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
663 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); 670 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
664 671
665 tab_5 = new QWidget( TabWidget, "tab_5" ); 672 tab_5 = new QWidget( TabWidget, "tab_5" );
666 673
667 QHBoxLayout *Layout19a; 674 QHBoxLayout *Layout19a;
668 Layout19a = new QHBoxLayout( tab_5); 675 Layout19a = new QHBoxLayout( tab_5);
669 Layout19a->setSpacing( 2 ); 676 Layout19a->setSpacing( 2 );
670 Layout19a->setMargin( 0 ); 677 Layout19a->setMargin( 0 );
671 678
672 Layout15 = new QVBoxLayout( this); 679 Layout15 = new QVBoxLayout( this);
673 Layout15->setSpacing( 2 ); 680 Layout15->setSpacing( 2 );
674 Layout15->setMargin( 0 ); 681 Layout15->setMargin( 0 );
675 682
676 Layout15b = new QVBoxLayout( this); 683 Layout15b = new QVBoxLayout( this);
677 Layout15b->setSpacing( 2 ); 684 Layout15b->setSpacing( 2 );
678 Layout15b->setMargin( 0 ); 685 Layout15b->setMargin( 0 );
679 686
680 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 687 TextLabel2 = new QLabel( tab_5, "InputLabel" );
681 TextLabel2->setText( tr( "In")); 688 TextLabel2->setText( tr( "In"));
682 TextLabel2->setFixedWidth( 35); 689 TextLabel2->setFixedWidth( 35);
683 Layout15->addWidget( TextLabel2 ); 690 Layout15->addWidget( TextLabel2 );
684 691
685 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 692 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
686 TextLabel3->setText( tr( "Out" ) ); 693 TextLabel3->setText( tr( "Out" ) );
687 Layout15b->addWidget( TextLabel3 ); 694 Layout15b->addWidget( TextLabel3 );
688 695
689 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 696 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
690 InputSlider->setTickmarks( QSlider::Both); 697 InputSlider->setTickmarks( QSlider::Both);
691 Layout15->addWidget( InputSlider); 698 Layout15->addWidget( InputSlider);
692 699
693 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 700 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
694 OutputSlider->setTickmarks( QSlider::Both); 701 OutputSlider->setTickmarks( QSlider::Both);
695 702
696 Layout15b->addWidget( OutputSlider ); 703 Layout15b->addWidget( OutputSlider );
697 704
698 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 705 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
699 Layout15->addWidget( outMuteCheckBox ); 706 Layout15->addWidget( outMuteCheckBox );
700 707
701 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 708 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
702 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 709 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
703 Layout15b->addWidget( inMuteCheckBox ); 710 Layout15b->addWidget( inMuteCheckBox );
704 711
705 712
706 Layout19a->addLayout( Layout15 ); 713 Layout19a->addLayout( Layout15 );
707 Layout19a->addLayout( Layout15b ); 714 Layout19a->addLayout( Layout15b );
708 715
709 fillDirectoryCombo(); 716 fillDirectoryCombo();
710 717
711 TabWidget->insertTab( tab_3, tr( "Options" ) ); 718 TabWidget->insertTab( tab_3, tr( "Options" ) );
712 719
713 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 720 TabWidget->insertTab( tab_5, tr( "Volume" ) );
714 721
715 722
716 waveform = new Waveform( this, "waveform" ); 723 waveform = new Waveform( this, "waveform" );
717// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); 724// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
718 waveform->setMinimumSize( QSize( 0, 50 ) ); 725 waveform->setMinimumSize( QSize( 0, 50 ) );
719 726
720 layout->addMultiCellWidget( waveform, 8, 8, 0, 8); 727 layout->addMultiCellWidget( waveform, 8, 8, 0, 8);
721 waveform->setBackgroundColor ( black ); 728 waveform->setBackgroundColor ( black );
722} 729}
723 730
724void QtRec::initIconView() { 731void QtRec::initIconView() {
725 732
726 ListView1->clear(); 733 ListView1->clear();
727 Config cfg("OpieRec"); 734 Config cfg("OpieRec");
728 cfg.setGroup("Sounds"); 735 cfg.setGroup("Sounds");
729 QString temp; 736 QString temp;
730 QPixmap image0( ( const char** ) image0_data ); 737 QPixmap image0( ( const char** ) image0_data );
731 738
732 int nFiles = cfg.readNumEntry("NumberofFiles",0); 739 int nFiles = cfg.readNumEntry("NumberofFiles",0);
733// odebug << "init number of files " << nFiles << "" << oendl; 740// odebug << "init number of files " << nFiles << "" << oendl;
734 741
735 for(int i=1;i<= nFiles;i++) { 742 for(int i=1;i<= nFiles;i++) {
736 743
737 QListViewItem * item; 744 QListViewItem * item;
738 QString fileS, mediaLocation, fileDate, filePath; 745 QString fileS, mediaLocation, fileDate, filePath;
739 746
740 temp.sprintf( "%d",i); 747 temp.sprintf( "%d",i);
741 temp = cfg.readEntry( temp,""); //reads currentFile 748 temp = cfg.readEntry( temp,""); //reads currentFile
742 filePath = cfg.readEntry( temp,""); //currentFileName 749 filePath = cfg.readEntry( temp,""); //currentFileName
743 750
744 QFileInfo info(filePath); 751 QFileInfo info(filePath);
745 fileDate = info.lastModified().toString(); 752 fileDate = info.lastModified().toString();
746 753
747 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 754 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
748 mediaLocation = getStorage( filePath); 755 mediaLocation = getStorage( filePath);
749 if( info.exists()) { 756 if( info.exists()) {
750 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); 757 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/);
751 item->setPixmap( 0, image0); 758 item->setPixmap( 0, image0);
752 if( currentFileName == filePath) 759 if( currentFileName == filePath)
753 ListView1->setSelected( item, true); 760 ListView1->setSelected( item, true);
754 } 761 }
755 } 762 }
756} 763}
757 764
758void QtRec::initConnections() { 765void QtRec::initConnections() {
759 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 766 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
760 767
761 connect( toBeginningButton, SIGNAL( pressed()), 768 connect( toBeginningButton, SIGNAL( pressed()),
762 this, SLOT( rewindPressed() )); 769 this, SLOT( rewindPressed() ));
763 connect( toBeginningButton, SIGNAL( released()), 770 connect( toBeginningButton, SIGNAL( released()),
764 this, SLOT( rewindReleased() )); 771 this, SLOT( rewindReleased() ));
765 connect( toEndButton, SIGNAL( pressed()), 772 connect( toEndButton, SIGNAL( pressed()),
766 this, SLOT( FastforwardPressed() )); 773 this, SLOT( FastforwardPressed() ));
767 connect( toEndButton, SIGNAL( released()), 774 connect( toEndButton, SIGNAL( released()),
768 this, SLOT( FastforwardReleased() )); 775 this, SLOT( FastforwardReleased() ));
769 connect( deleteSoundButton, SIGNAL(released()), 776 connect( deleteSoundButton, SIGNAL(released()),
770 this, SLOT( deleteSound() )); 777 this, SLOT( deleteSound() ));
771 connect( Stop_PushButton, SIGNAL(released()), 778 connect( Stop_PushButton, SIGNAL(released()),
772 this, SLOT( doPlayBtn() )); 779 this, SLOT( doPlayBtn() ));
773 connect( Rec_PushButton, SIGNAL(released()), 780 connect( Rec_PushButton, SIGNAL(released()),
774 this, SLOT( newSound() ) ); 781 this, SLOT( newSound() ) );
775 connect( TabWidget, SIGNAL( currentChanged(QWidget*)), 782 connect( TabWidget, SIGNAL( currentChanged(QWidget*)),
776 this, SLOT(thisTab(QWidget*) )); 783 this, SLOT(thisTab(QWidget*) ));
777 connect( OutputSlider, SIGNAL(sliderReleased()), 784 connect( OutputSlider, SIGNAL(sliderReleased()),
778 this, SLOT( changedOutVolume()) ); 785 this, SLOT( changedOutVolume()) );
779 connect( InputSlider, SIGNAL(sliderReleased()), 786 connect( InputSlider, SIGNAL(sliderReleased()),
780 this, SLOT( changedInVolume()) ); 787 this, SLOT( changedInVolume()) );
781 788
782 connect( sampleRateComboBox, SIGNAL(activated(int)), 789 connect( sampleRateComboBox, SIGNAL(activated(int)),
783 this, SLOT( changesamplerateCombo(int)) ); 790 this, SLOT( changesamplerateCombo(int)) );
784 connect( bitRateComboBox, SIGNAL(activated(int)), 791 connect( bitRateComboBox, SIGNAL(activated(int)),
785 this, SLOT( changebitrateCombo(int)) ); 792 this, SLOT( changebitrateCombo(int)) );
786 793
787 connect( directoryComboBox, SIGNAL(activated(int)), 794 connect( directoryComboBox, SIGNAL(activated(int)),
788 this, SLOT( changeDirCombo(int)) ); 795 this, SLOT( changeDirCombo(int)) );
789 connect( sizeLimitCombo, SIGNAL(activated(int)), 796 connect( sizeLimitCombo, SIGNAL(activated(int)),
790 this, SLOT( changeSizeLimitCombo(int)) ); 797 this, SLOT( changeSizeLimitCombo(int)) );
791 798
792 connect( stereoCheckBox, SIGNAL(toggled(bool)), 799 connect( stereoCheckBox, SIGNAL(toggled(bool)),
793 this, SLOT( changeStereoCheck(bool)) ); 800 this, SLOT( changeStereoCheck(bool)) );
794 801
795 connect( outMuteCheckBox, SIGNAL(toggled(bool)), 802 connect( outMuteCheckBox, SIGNAL(toggled(bool)),
796 this, SLOT( doVolMuting(bool)) ); 803 this, SLOT( doVolMuting(bool)) );
797 connect( inMuteCheckBox , SIGNAL(toggled(bool)), 804 connect( inMuteCheckBox , SIGNAL(toggled(bool)),
798 this, SLOT( doMicMuting(bool)) ); 805 this, SLOT( doMicMuting(bool)) );
799 806
800 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), 807 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)),
801 this,SLOT( itClick(QListViewItem*))); 808 this,SLOT( itClick(QListViewItem*)));
802 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 809 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
803 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); 810 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) );
804 connect( timeSlider, SIGNAL( sliderMoved(int)), 811 connect( timeSlider, SIGNAL( sliderMoved(int)),
805 this, SLOT( changeTimeSlider(int) )); 812 this, SLOT( changeTimeSlider(int) ));
806 connect( timeSlider, SIGNAL( sliderPressed()), 813 connect( timeSlider, SIGNAL( sliderPressed()),
807 this, SLOT( timeSliderPressed() )); 814 this, SLOT( timeSliderPressed() ));
808 connect( timeSlider, SIGNAL( sliderReleased()), 815 connect( timeSlider, SIGNAL( sliderReleased()),
809 this, SLOT( timeSliderReleased() )); 816 this, SLOT( timeSliderReleased() ));
810 connect( compressionCheckBox, SIGNAL( toggled(bool)), 817 connect( compressionCheckBox, SIGNAL( toggled(bool)),
811 this, SLOT( compressionSelected(bool))); 818 this, SLOT( compressionSelected(bool)));
812 connect( autoMuteCheckBox, SIGNAL( toggled(bool)), 819 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),
813 this, SLOT( slotAutoMute(bool))); 820 this, SLOT( slotAutoMute(bool)));
814} 821}
815 822
816void QtRec::initConfig() { 823void QtRec::initConfig() {
817 int index, fred, i; 824 int index, fred, i;
818 Config cfg("OpieRec"); 825 Config cfg("OpieRec");
819 cfg.setGroup("Settings"); 826 cfg.setGroup("Settings");
820 827
821 index = cfg.readNumEntry("samplerate",22050); 828 index = cfg.readNumEntry("samplerate",22050);
822 bool ok; 829 bool ok;
823 830
824 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 831 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
825 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 832 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
826 if( index == fred) { 833 if( index == fred) {
827 filePara.sampleRate = fred; 834 filePara.sampleRate = fred;
828 sampleRateComboBox->setCurrentItem(ws); 835 sampleRateComboBox->setCurrentItem(ws);
829 } 836 }
830 } 837 }
831 838
832 i = cfg.readNumEntry("bitrate",16); 839 i = cfg.readNumEntry("bitrate",16);
833 if(i == 16) 840 if(i == 16)
834 bitRateComboBox->setCurrentItem( 1); 841 bitRateComboBox->setCurrentItem( 1);
835 else if(i == 24) 842 else if(i == 24)
836 bitRateComboBox->setCurrentItem( 2); 843 bitRateComboBox->setCurrentItem( 2);
837 else if(i == 32) 844 else if(i == 32)
838 bitRateComboBox->setCurrentItem( 3); 845 bitRateComboBox->setCurrentItem( 3);
839 else 846 else
840 bitRateComboBox->setCurrentItem( 0); 847 bitRateComboBox->setCurrentItem( 0);
841 848
842 filePara.resolution = i; 849 filePara.resolution = i;
843 850
844 i = cfg.readNumEntry("sizeLimit", 5 ); 851 i = cfg.readNumEntry("sizeLimit", 5 );
845 QString temp; 852 QString temp;
846 sizeLimitCombo->setCurrentItem((i/5)); 853 sizeLimitCombo->setCurrentItem((i/5));
847 854
848 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); 855 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
849 if( stereoCheckBox->isChecked()) { 856 if( stereoCheckBox->isChecked()) {
850 filePara.channels = 2; 857 filePara.channels = 2;
851 } else { 858 } else {
852 filePara.channels = 1; 859 filePara.channels = 1;
853 } 860 }
854 861
855 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 862 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
856 if( compressionCheckBox->isChecked()) { 863 if( compressionCheckBox->isChecked()) {
857 bitRateComboBox->setEnabled(false); 864 bitRateComboBox->setEnabled(false);
858 bitRateComboBox->setCurrentItem(0); 865 bitRateComboBox->setCurrentItem(0);
859 filePara.resolution=16; 866 filePara.resolution=16;
860 } 867 }
861 868
862 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 869 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
863 if( autoMuteCheckBox->isChecked()) 870 if( autoMuteCheckBox->isChecked())
864 slotAutoMute(true); 871 slotAutoMute(true);
865 else 872 else
866 slotAutoMute(false); 873 slotAutoMute(false);
867 874
868 Config cofg( "qpe"); 875 Config cofg( "qpe");
869 cofg.setGroup( "Volume"); 876 cofg.setGroup( "Volume");
870 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 877 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
871 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 878 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
872} 879}
873 880
874void QtRec::stop() { 881void QtRec::stop() {
875 owarn << "STOP" << oendl; 882 owarn << "STOP" << oendl;
876 setRecordButton(false); 883 setRecordButton(false);
877 884
878 if( !recording) 885 if( !recording)
879 endPlaying(); 886 endPlaying();
880 else 887 else
881 endRecording(); 888 endRecording();
882 timeSlider->setValue(0); 889 timeSlider->setValue(0);
883} 890}
884 891
885void QtRec::doPlayBtn() { 892void QtRec::doPlayBtn() {
886 893
887 if(!stopped) { 894 if(!stopped) {
888 // playLabel2->setText(tr("Play")); 895 // playLabel2->setText(tr("Play"));
889 stop(); 896 stop();
890 } else { 897 } else {
891 if(ListView1->currentItem() == 0) return; 898 if(ListView1->currentItem() == 0) return;
892 // playLabel2->setText(tr("Stop")); 899 // playLabel2->setText(tr("Stop"));
893 currentFile = ListView1->currentItem()->text(0); 900 currentFile = ListView1->currentItem()->text(0);
894 start(); 901 start();
895 } 902 }
896} 903}
897 904
898void QtRec::start() { //play 905void QtRec::start() { //play
899 if( stopped) { 906 if( stopped) {
900 QPixmap image3( ( const char** ) image3_data ); 907 QPixmap image3( ( const char** ) image3_data );
901 Stop_PushButton->setPixmap( image3 ); 908 Stop_PushButton->setPixmap( image3 );
902 Stop_PushButton->setDown( true); 909 Stop_PushButton->setDown( true);
903 stopped = false; 910 stopped = false;
904 paused = false; 911 paused = false;
905 secCount = 1; 912 secCount = 1;
906 913
907 if( openPlayFile()) 914 if( openPlayFile())
908 if( setupAudio( false)) //recording is false 915 if( setupAudio( false)) //recording is false
909 doPlay(); 916 doPlay();
910 } 917 }
911} 918}
912 919
913bool QtRec::rec() { //record 920bool QtRec::rec() { //record
914 QString timeString; 921 QString timeString;
915 timeString.sprintf("%.0f", 0.0); 922 timeString.sprintf("%.0f", 0.0);
916 // timeLabel->setText( timeString+ " seconds"); 923 // timeLabel->setText( timeString+ " seconds");
917 if(!stopped) { 924 if(!stopped) {
918 monitoring = true; 925 monitoring = true;
919 return false; 926 return false;
920 } else { 927 } else {
921 secCount = 1; 928 secCount = 1;
922 // playLabel2->setText(tr("Stop")); 929 // playLabel2->setText(tr("Stop"));
923 monitoring = false; 930 monitoring = false;
924 setRecordButton( true); 931 setRecordButton( true);
925 932
926 if( setupAudio( true)) 933 if( setupAudio( true))
927 if(setUpFile()) { 934 if(setUpFile()) {
928 int fileSize = 0; 935 int fileSize = 0;
929 Config cfg("OpieRec"); 936 Config cfg("OpieRec");
930 cfg.setGroup("Settings"); 937 cfg.setGroup("Settings");
931// odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits() 938// odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits()
932// << ", device rate " << soundDevice->getDeviceRate() 939// << ", device rate " << soundDevice->getDeviceRate()
933// << ", device channels " << soundDevice->getDeviceChannels() << oendl; 940// << ", device channels " << soundDevice->getDeviceChannels() << oendl;
934 941
935 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 942 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
936// odebug << "sample rate is " << filePara.sampleRate << "" << oendl; 943// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
937 filePara.SecondsToRecord = getCurrentSizeLimit(); 944 filePara.SecondsToRecord = getCurrentSizeLimit();
938 945
939// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; 946// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
940 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 947 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
941 948
942 if( filePara.SecondsToRecord == 0) { 949 if( filePara.SecondsToRecord == 0) {
943 fileSize = diskSize; 950 fileSize = diskSize;
944 } else if( filePara.format == WAVE_FORMAT_PCM) { 951 } else if( filePara.format == WAVE_FORMAT_PCM) {
945// odebug << "WAVE_FORMAT_PCM" << oendl; 952// odebug << "WAVE_FORMAT_PCM" << oendl;
946 fileSize = (filePara.SecondsToRecord ) * filePara.channels 953 fileSize = (filePara.SecondsToRecord ) * filePara.channels
947 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 954 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
948 } else { 955 } else {
949// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 956// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
950 fileSize = ((filePara.SecondsToRecord) * filePara.channels 957 fileSize = ((filePara.SecondsToRecord) * filePara.channels
951 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 958 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
952 } 959 }
953 960
954 filePara.samplesToRecord = fileSize; 961 filePara.samplesToRecord = fileSize;
955 odebug << "filesize should be " << filePara.samplesToRecord 962 odebug << "filesize should be " << filePara.samplesToRecord
956 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; 963 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate;
957 if( paused) { 964 if( paused) {
958 paused = false; 965 paused = false;
959 } 966 }
960 // else { 967 // else {
961 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; 968 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
962 // if(fileSize != 0) 969 // if(fileSize != 0)
963 timeSlider->setRange(0, filePara.samplesToRecord); 970 timeSlider->setRange(0, filePara.samplesToRecord);
964 // } 971 // }
965 972
966 if( diskSize < fileSize/1024) { 973 if( diskSize < fileSize/1024) {
967 QMessageBox::warning(this, 974 QMessageBox::warning(this,
968 tr("Low Disk Space"), 975 tr("Low Disk Space"),
969 tr("You are running low of\nrecording space\n" 976 tr("You are running low of\nrecording space\n"
970 "or a card isn't being recognized")); 977 "or a card isn't being recognized"));
971 stopped = true; //we need to be stopped 978 stopped = true; //we need to be stopped
972 stop(); 979 stop();
973 } else { 980 } else {
974 QString msg; 981 QString msg;
975 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 982 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
976#ifdef DEV_VERSION 983#ifdef DEV_VERSION
977 setCaption( msg); 984 setCaption( msg);
978#endif 985#endif
979 filePara.fileName=currentFile.latin1(); 986 filePara.fileName=currentFile.latin1();
980 odebug << "Start recording" << oendl; 987 odebug << "Start recording" << oendl;
981 stopped = false; 988 stopped = false;
982 989
983#ifdef THREADED 990#ifdef THREADED
984 odebug << "Start recording thread" << oendl; 991 odebug << "Start recording thread" << oendl;
985 pthread_t thread1; 992 pthread_t thread1;
986 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 993 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
987#endif 994#endif
988 toBeginningButton->setEnabled( false); 995 toBeginningButton->setEnabled( false);
989 toEndButton->setEnabled( false); 996 toEndButton->setEnabled( false);
990 997
991 startTimer(1000); 998 startTimer(1000);
992#ifndef THREADED 999#ifndef THREADED
993 quickRec(); 1000 quickRec();
994#endif 1001#endif
995 } 1002 }
996 } //end setUpFile 1003 } //end setUpFile
997 } //end setupAudio 1004 } //end setupAudio
998 return true; 1005 return true;
999} 1006}
1000/* 1007/*
1001 This happens when a tab is selected*/ 1008 This happens when a tab is selected*/
1002void QtRec::thisTab(QWidget* widg) { 1009void QtRec::thisTab(QWidget* widg) {
1003 if(widg != NULL) { 1010 if(widg != NULL) {
1004 int index = TabWidget->currentPageIndex(); 1011 int index = TabWidget->currentPageIndex();
1005 1012
1006 if(index == 0) { //file page 1013 if(index == 0) { //file page
1007 } 1014 }
1008 1015
1009 if(index == 1) { //control page 1016 if(index == 1) { //control page
1010 fillDirectoryCombo(); 1017 fillDirectoryCombo();
1011// soundDevice->getOutVol(); 1018// soundDevice->getOutVol();
1012// soundDevice->getInVol(); 1019// soundDevice->getInVol();
1013 } 1020 }
1014 1021
1015 if( index==2) { //help page 1022 if( index==2) { //help page
1016 } 1023 }
1017 1024
1018 qApp->processEvents(); 1025 qApp->processEvents();
1019 update(); 1026 update();
1020 } 1027 }
1021} 1028}
1022 1029
1023void QtRec::getOutVol( ) { 1030void QtRec::getOutVol( ) {
1024 filePara.outVol = soundDevice->getOutVolume(); 1031 filePara.outVol = soundDevice->getOutVolume();
1025// odebug << "out vol " << filePara.outVol << "" << oendl; 1032// odebug << "out vol " << filePara.outVol << "" << oendl;
1026 OutputSlider->setValue( -filePara.outVol); 1033 OutputSlider->setValue( -filePara.outVol);
1027} 1034}
1028 1035
1029void QtRec::getInVol() { 1036void QtRec::getInVol() {
1030 filePara.inVol = soundDevice->getInVolume(); 1037 filePara.inVol = soundDevice->getInVolume();
1031// odebug << "in vol " << filePara.inVol << "" << oendl; 1038// odebug << "in vol " << filePara.inVol << "" << oendl;
1032 InputSlider->setValue( -filePara.inVol); 1039 InputSlider->setValue( -filePara.inVol);
1033} 1040}
1034 1041
1035void QtRec::changedOutVolume() { 1042void QtRec::changedOutVolume() {
1036 soundDevice->changedOutVolume( -OutputSlider->value()); 1043 soundDevice->changedOutVolume( -OutputSlider->value());
1037} 1044}
1038 1045
1039void QtRec::changedInVolume( ) { 1046void QtRec::changedInVolume( ) {
1040 soundDevice->changedInVolume( -InputSlider->value()); 1047 soundDevice->changedInVolume( -InputSlider->value());
1041} 1048}
1042 1049
1043 1050
1044bool QtRec::setupAudio( bool b) { 1051bool QtRec::setupAudio( bool b) {
1045 bool ok; 1052 bool ok;
1046 int sampleformat, stereo, flags; 1053 int sampleformat, stereo, flags;
1047 QString dspString, mixerString; 1054 QString dspString, mixerString;
1048 1055
1049 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1056 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1050 1057
1051 if( !b) { 1058 if( !b) {
1052// we want to play 1059// we want to play
1053#ifdef PDAUDIO //ALSA 1060#ifdef PDAUDIO //ALSA
1054 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1061 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1055 sampleformat = SND_PCM_FORMAT_S16; 1062 sampleformat = SND_PCM_FORMAT_S16;
1056 filePara.resolution = 16; 1063 filePara.resolution = 16;
1057 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { 1064 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
1058 sampleformat = SND_PCM_FORMAT_S24; 1065 sampleformat = SND_PCM_FORMAT_S24;
1059 filePara.resolution = 24; 1066 filePara.resolution = 24;
1060 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { 1067 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
1061 sampleformat = SND_PCM_FORMAT_S32; 1068 sampleformat = SND_PCM_FORMAT_S32;
1062 filePara.resolution = 32; 1069 filePara.resolution = 32;
1063 } else { 1070 } else {
1064 sampleformat = SND_PCM_FORMAT_U8; 1071 sampleformat = SND_PCM_FORMAT_U8;
1065 filePara.resolution = 8; 1072 filePara.resolution = 8;
1066 } 1073 }
1067#else 1074#else
1068// we want to play 1075// we want to play
1069 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1076 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1070 sampleformat = AFMT_S16_LE; 1077 sampleformat = AFMT_S16_LE;
1071 filePara.resolution = 16; 1078 filePara.resolution = 16;
1072 } else { 1079 } else {
1073 sampleformat = AFMT_U8; 1080 sampleformat = AFMT_U8;
1074 filePara.resolution = 8; 1081 filePara.resolution = 8;
1075 } 1082 }
1076#endif 1083#endif
1077 1084
1078 stereo = filePara.channels; 1085 stereo = filePara.channels;
1079 flags = O_WRONLY; 1086 flags = O_WRONLY;
1080 Config hwcfg("OpieRec"); 1087 Config hwcfg("OpieRec");
1081 hwcfg.setGroup("Hardware"); 1088 hwcfg.setGroup("Hardware");
1082 dspString = hwcfg.readEntry( "Audio", DSPSTROUT); 1089 dspString = hwcfg.readEntry( "Audio", DSPSTROUT);
1083 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); 1090 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT);
1084 recording = false; 1091 recording = false;
1085 } else { // we want to record 1092 } else { // we want to record
1086 1093
1087#ifdef PDAUDIO //ALSA 1094#ifdef PDAUDIO //ALSA
1088 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1095 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1089 sampleformat = SND_PCM_FORMAT_S16; 1096 sampleformat = SND_PCM_FORMAT_S16;
1090 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") 1097 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
1091 sampleformat = SND_PCM_FORMAT_S24; 1098 sampleformat = SND_PCM_FORMAT_S24;
1092 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") 1099 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
1093 sampleformat = SND_PCM_FORMAT_S32; 1100 sampleformat = SND_PCM_FORMAT_S32;
1094 else 1101 else
1095 sampleformat = SND_PCM_FORMAT_U8; 1102 sampleformat = SND_PCM_FORMAT_U8;
1096 1103
1097#else 1104#else
1098 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1105 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1099 sampleformat = AFMT_S16_LE; 1106 sampleformat = AFMT_S16_LE;
1100 else 1107 else
1101 sampleformat = AFMT_U8; 1108 sampleformat = AFMT_U8;
1102 1109
1103 if( !compressionCheckBox->isChecked()) { 1110 if( !compressionCheckBox->isChecked()) {
1104 filePara.format = WAVE_FORMAT_PCM; 1111 filePara.format = WAVE_FORMAT_PCM;
1105// odebug << "WAVE_FORMAT_PCM" << oendl; 1112// odebug << "WAVE_FORMAT_PCM" << oendl;
1106 } else { 1113 } else {
1107 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1114 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1108 sampleformat = AFMT_S16_LE; 1115 sampleformat = AFMT_S16_LE;
1109// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 1116// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
1110 } 1117 }
1111#endif 1118#endif
1112 1119
1113 stereo = filePara.channels; 1120 stereo = filePara.channels;
1114// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1121// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1115 flags= O_RDWR; 1122 flags= O_RDWR;
1116// flags= O_RDONLY; 1123// flags= O_RDONLY;
1117 Config hwcfg("OpieRec"); 1124 Config hwcfg("OpieRec");
1118 hwcfg.setGroup("Hardware"); 1125 hwcfg.setGroup("Hardware");
1119 dspString = hwcfg.readEntry( "Audio", DSPSTRIN); 1126 dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
1120 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); 1127 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
1121 recording = true; 1128 recording = true;
1122 } 1129 }
1123 1130
1124 // if(soundDevice) delete soundDevice; 1131 // if(soundDevice) delete soundDevice;
1125 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; 1132 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
1126 owarn << "change waveform settings" << oendl; 1133 owarn << "change waveform settings" << oendl;
1127 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1134 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1128 1135
1129 soundDevice = new Device( this, dspString, mixerString, b); 1136 soundDevice = new Device( this, dspString, mixerString, b);
1130// soundDevice->openDsp(); 1137// soundDevice->openDsp();
1131 soundDevice->reset(); 1138 soundDevice->reset();
1132 1139
1133 odebug << "device has been made " << soundDevice->sd << "" << oendl; 1140 odebug << "device has been made " << soundDevice->sd << "" << oendl;
1134 1141
1135 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1142 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1136 soundDevice->setDeviceFormat( sampleformat); 1143 soundDevice->setDeviceFormat( sampleformat);
1137 soundDevice->setDeviceChannels( filePara.channels); 1144 soundDevice->setDeviceChannels( filePara.channels);
1138 soundDevice->setDeviceRate( filePara.sampleRate); 1145 soundDevice->setDeviceRate( filePara.sampleRate);
1139 soundDevice->getDeviceFragSize(); 1146 soundDevice->getDeviceFragSize();
1140#ifdef QT_QWS_EBX 1147#ifdef QT_QWS_EBX
1141 int frag = FRAGSIZE; 1148 int frag = FRAGSIZE;
1142 soundDevice->setFragSize( frag); 1149 soundDevice->setFragSize( frag);
1143 soundDevice->getDeviceFragSize(); 1150 soundDevice->getDeviceFragSize();
1144#endif 1151#endif
1145 ///////////////// 1152 /////////////////
1146 filePara.sd = soundDevice->sd; 1153 filePara.sd = soundDevice->sd;
1147 1154
1148 if ( filePara.sd == -1) { 1155 if ( filePara.sd == -1) {
1149 1156
1150 monitoring = false; 1157 monitoring = false;
1151 stopped = true; 1158 stopped = true;
1152 update(); 1159 update();
1153 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); 1160 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1154 return false; 1161 return false;
1155 } 1162 }
1156 if(autoMute) 1163 if(autoMute)
1157 doMute(false); 1164 doMute(false);
1158 1165
1159 return true; 1166 return true;
1160} 1167}
1161 1168
1162 1169
1163bool QtRec::setUpFile() { //setup file for recording 1170bool QtRec::setUpFile() { //setup file for recording
1164// odebug << "Setting up wavfile" << oendl; 1171// odebug << "Setting up wavfile" << oendl;
1165// if(wavFile) delete wavFile; 1172// if(wavFile) delete wavFile;
1166 wavFile = new WavFile( this, (const QString &)"", 1173 wavFile = new WavFile( this, (const QString &)"",
1167 true, 1174 true,
1168 filePara.sampleRate, 1175 filePara.sampleRate,
1169 filePara.channels, 1176 filePara.channels,
1170 filePara.resolution, 1177 filePara.resolution,
1171 filePara.format); 1178 filePara.format);
1172 1179
1173 filePara.fd = wavFile->wavHandle(); 1180 filePara.fd = wavFile->wavHandle();
1174 if(filePara.fd == -1) { 1181 if(filePara.fd == -1) {
1175 return false; 1182 return false;
1176 } else { 1183 } else {
1177// filePara.channels=1; 1184// filePara.channels=1;
1178 } 1185 }
1179 return true; 1186 return true;
1180} 1187}
1181 1188
1182/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1189/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1183bool QtRec::doPlay() { 1190bool QtRec::doPlay() {
1184 1191
1185 if( !paused) { 1192 if( !paused) {
1186 total = 0; 1193 total = 0;
1187 filePara.numberOfRecordedSeconds = 0; 1194 filePara.numberOfRecordedSeconds = 0;
1188 } else { 1195 } else {
1189 paused = false; 1196 paused = false;
1190 secCount = (int)filePara.numberOfRecordedSeconds; 1197 secCount = (int)filePara.numberOfRecordedSeconds;
1191 } 1198 }
1192 playing = true; 1199 playing = true;
1193 stopped = false; 1200 stopped = false;
1194 recording = false; 1201 recording = false;
1195 1202
1196 QString num; 1203 QString num;
1197 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; 1204 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1198 1205
1199// timeSlider->setRange( 0, filePara.numberSamples); 1206// timeSlider->setRange( 0, filePara.numberSamples);
1200 1207
1201 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1208 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1202 // timeLabel->setText( timeString+ tr(" seconds")); 1209 // timeLabel->setText( timeString+ tr(" seconds"));
1203 1210
1204 QString msg; 1211 QString msg;
1205 msg.sprintf("%d, %d, %d", 1212 msg.sprintf("%d, %d, %d",
1206 filePara.sampleRate, 1213 filePara.sampleRate,
1207 filePara.channels, 1214 filePara.channels,
1208 filePara.resolution); 1215 filePara.resolution);
1209#ifdef DEV_VERSION 1216#ifdef DEV_VERSION
1210 setCaption( msg); 1217 setCaption( msg);
1211#endif 1218#endif
1212 1219
1213 startTimer( 1000); 1220 startTimer( 1000);
1214#ifdef THREADED 1221#ifdef THREADED
1215 pthread_t thread2; 1222 pthread_t thread2;
1216 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1223 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1217#endif 1224#endif
1218 1225
1219 toBeginningButton->setEnabled( false); 1226 toBeginningButton->setEnabled( false);
1220 toEndButton->setEnabled( false); 1227 toEndButton->setEnabled( false);
1221#ifndef THREADED 1228#ifndef THREADED
1222 playIt(); 1229 playIt();
1223#endif 1230#endif
1224 return true; 1231 return true;
1225} 1232}
1226 1233
1227 1234
1228void QtRec::changebitrateCombo(int i) { 1235void QtRec::changebitrateCombo(int i) {
1229 Config cfg("OpieRec"); 1236 Config cfg("OpieRec");
1230 cfg.setGroup("Settings"); 1237 cfg.setGroup("Settings");
1231 int bits = 0; 1238 int bits = 0;
1232 if( i == 1) { bits = 16; } 1239 if( i == 1) { bits = 16; }
1233 else if( i == 2) { bits = 24; } 1240 else if( i == 2) { bits = 24; }
1234 else if( i == 3) { bits = 32; } 1241 else if( i == 3) { bits = 32; }
1235 else { bits=8; } 1242 else { bits=8; }
1236 cfg.writeEntry("bitrate", bits); 1243 cfg.writeEntry("bitrate", bits);
1237 filePara.resolution = bits; 1244 filePara.resolution = bits;
1238 cfg.write(); 1245 cfg.write();
1239} 1246}
1240 1247
1241void QtRec::changesamplerateCombo(int i) { 1248void QtRec::changesamplerateCombo(int i) {
1242 Config cfg("OpieRec"); 1249 Config cfg("OpieRec");
1243 cfg.setGroup("Settings"); 1250 cfg.setGroup("Settings");
1244 int rate=0; 1251 int rate=0;
1245 bool ok; 1252 bool ok;
1246 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1253 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1247 cfg.writeEntry( "samplerate",rate); 1254 cfg.writeEntry( "samplerate",rate);
1248 filePara.sampleRate=rate; 1255 filePara.sampleRate=rate;
1249 odebug << "Change sample rate " << rate << "" << oendl; 1256 odebug << "Change sample rate " << rate << "" << oendl;
1250 cfg.write(); 1257 cfg.write();
1251} 1258}
1252 1259
1253 1260
1254void QtRec::changeDirCombo(int index) { 1261void QtRec::changeDirCombo(int index) {
1255 Config cfg("OpieRec"); 1262 Config cfg("OpieRec");
1256 cfg.setGroup("Settings"); 1263 cfg.setGroup("Settings");
1257 QString sName = directoryComboBox->text(index); 1264 QString sName = directoryComboBox->text(index);
1258 1265
1259 StorageInfo storageInfo; 1266 StorageInfo storageInfo;
1260 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1267 const QList<FileSystem> &fs = storageInfo.fileSystems();
1261 QListIterator<FileSystem> it ( fs ); 1268 QListIterator<FileSystem> it ( fs );
1262 QString storage; 1269 QString storage;
1263 for( ; it.current(); ++it ){ 1270 for( ; it.current(); ++it ){
1264 if( sName == (*it)->name()+" "+ (*it)->path() || 1271 if( sName == (*it)->name()+" "+ (*it)->path() ||
1265 (*it)->name() == sName ) { 1272 (*it)->name() == sName ) {
1266 const QString path = (*it)->path(); 1273 const QString path = (*it)->path();
1267 recDir = path; 1274 recDir = path;
1268 cfg.writeEntry("directory", recDir); 1275 cfg.writeEntry("directory", recDir);
1269 odebug << "new rec dir "+recDir << oendl; 1276 odebug << "new rec dir "+recDir << oendl;
1270 } 1277 }
1271 } 1278 }
1272 cfg.write(); 1279 cfg.write();
1273} 1280}
1274 1281
1275 1282
1276void QtRec::changeSizeLimitCombo(int) { 1283void QtRec::changeSizeLimitCombo(int) {
1277 Config cfg("OpieRec"); 1284 Config cfg("OpieRec");
1278 cfg.setGroup("Settings"); 1285 cfg.setGroup("Settings");
1279 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1286 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1280 cfg.write(); 1287 cfg.write();
1281} 1288}
1282 1289
1283void QtRec::newSound() { 1290void QtRec::newSound() {
1284 if( !rec()) { 1291 if( !rec()) {
1285 endRecording(); 1292 endRecording();
1286 deleteSound(); 1293 deleteSound();
1287 } 1294 }
1288} 1295}
1289 1296
1290void QtRec::itClick(QListViewItem *item) { 1297void QtRec::itClick(QListViewItem *item) {
1291 currentFile = item->text(0); 1298 currentFile = item->text(0);
1292 setCaption("OpieRecord "+currentFile); 1299 setCaption("OpieRecord "+currentFile);
1293} 1300}
1294 1301
1295void QtRec::deleteSound() { 1302void QtRec::deleteSound() {
1296 Config cfg("OpieRec"); 1303 Config cfg("OpieRec");
1297 cfg.setGroup("Sounds"); 1304 cfg.setGroup("Sounds");
1298 if( ListView1->currentItem() == NULL) 1305 if( ListView1->currentItem() == NULL)
1299 return; 1306 return;
1300#ifndef DEV_VERSION 1307#ifndef DEV_VERSION
1301 switch ( QMessageBox::warning(this,tr("Delete"), 1308 switch ( QMessageBox::warning(this,tr("Delete"),
1302 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), 1309 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"),
1303 tr("Yes"),tr("No"),0,1,1) ) { 1310 tr("Yes"),tr("No"),0,1,1) ) {
1304 case 0: 1311 case 0:
1305#endif 1312#endif
1306 { 1313 {
1307 QString file = ListView1->currentItem()->text(0); 1314 QString file = ListView1->currentItem()->text(0);
1308 QString fileName; 1315 QString fileName;
1309 fileName = cfg.readEntry( file, ""); 1316 fileName = cfg.readEntry( file, "");
1310 QFile f( fileName); 1317 QFile f( fileName);
1311 if( f.exists()) 1318 if( f.exists())
1312 if( !f.remove()) 1319 if( !f.remove())
1313 QMessageBox::message( tr("Error"), tr("Could not remove file.")); 1320 QMessageBox::message( tr("Error"), tr("Could not remove file."));
1314 1321
1315 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1322 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1316 bool found = false; 1323 bool found = false;
1317 for(int i=0;i<nFiles+1;i++) { 1324 for(int i=0;i<nFiles+1;i++) {
1318 1325
1319 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1326 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1320 found = true; 1327 found = true;
1321 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1328 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1322 } 1329 }
1323 if(found) 1330 if(found)
1324 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1331 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1325 } 1332 }
1326 1333
1327 cfg.removeEntry( cfg.readEntry( file)); 1334 cfg.removeEntry( cfg.readEntry( file));
1328 cfg.removeEntry( file); 1335 cfg.removeEntry( file);
1329 cfg.writeEntry( "NumberofFiles", nFiles-1); 1336 cfg.writeEntry( "NumberofFiles", nFiles-1);
1330 cfg.write(); 1337 cfg.write();
1331 1338
1332 ListView1->takeItem( ListView1->currentItem() ); 1339 ListView1->takeItem( ListView1->currentItem() );
1333 delete ListView1->currentItem(); 1340 delete ListView1->currentItem();
1334 1341
1335 ListView1->clear(); 1342 ListView1->clear();
1336 ListView1->setSelected( ListView1->firstChild(), true); 1343 ListView1->setSelected( ListView1->firstChild(), true);
1337 initIconView(); 1344 initIconView();
1338 update(); 1345 update();
1339 } 1346 }
1340#ifndef DEV_VERSION 1347#ifndef DEV_VERSION
1341 }; 1348 };
1342#endif 1349#endif
1343 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1350 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1344 1351
1345} 1352}
1346 1353
1347void QtRec::keyPressEvent( QKeyEvent *e) { 1354void QtRec::keyPressEvent( QKeyEvent *e) {
1348 1355
1349 switch ( e->key() ) { 1356 switch ( e->key() ) {
1350 // case Key_F1: 1357 // case Key_F1:
1351 // if(stopped && !recording) 1358 // if(stopped && !recording)
1352 // newSound(); 1359 // newSound();
1353 // else 1360 // else
1354 // stop(); 1361 // stop();
1355 // break; 1362 // break;
1356 // case Key_F2: { 1363 // case Key_F2: {
1357 // if( !e->isAutoRepeat()) 1364 // if( !e->isAutoRepeat())
1358 // rewindPressed(); 1365 // rewindPressed();
1359 // } 1366 // }
1360 // break; 1367 // break;
1361 // case Key_F3: { 1368 // case Key_F3: {
1362 // if( !e->isAutoRepeat()) 1369 // if( !e->isAutoRepeat())
1363 // FastforwardPressed(); 1370 // FastforwardPressed();
1364 // } 1371 // }
1365 // break; 1372 // break;
1366 1373
1367 ////////////////////////////// Zaurus keys 1374 ////////////////////////////// Zaurus keys
1368 case Key_F9: //activity 1375 case Key_F9: //activity
1369 break; 1376 break;
1370 case Key_F10: //contacts 1377 case Key_F10: //contacts
1371 break; 1378 break;
1372 case Key_F11: //menu 1379 case Key_F11: //menu
1373 break; 1380 break;
1374 case Key_F12: //home 1381 case Key_F12: //home
1375 break; 1382 break;
1376 case Key_F13: //mail 1383 case Key_F13: //mail
1377 break; 1384 break;
1378 case Key_Space: 1385 case Key_Space:
1379 break; 1386 break;
1380 case Key_Delete: 1387 case Key_Delete:
1381 break; 1388 break;
1382 case Key_Up: 1389 case Key_Up:
1383 // stop(); 1390 // stop();
1384 break; 1391 break;
1385 case Key_Down: 1392 case Key_Down:
1386 // newSound(); 1393 // newSound();
1387 break; 1394 break;
1388 case Key_Left: { 1395 case Key_Left: {
1389 odebug << "rewinding" << oendl; 1396 odebug << "rewinding" << oendl;
1390 if( !e->isAutoRepeat()) 1397 if( !e->isAutoRepeat())
1391 rewindPressed(); 1398 rewindPressed();
1392 } 1399 }
1393 break; 1400 break;
1394 case Key_Right: { 1401 case Key_Right: {
1395 if( !e->isAutoRepeat()) 1402 if( !e->isAutoRepeat())
1396 FastforwardPressed(); 1403 FastforwardPressed();
1397 } 1404 }
1398 break; 1405 break;
1399 } 1406 }
1400} 1407}
1401 1408
1402void QtRec::keyReleaseEvent( QKeyEvent *e) { 1409void QtRec::keyReleaseEvent( QKeyEvent *e) {
1403 switch ( e->key() ) { 1410 switch ( e->key() ) {
1404 // case Key_F1: 1411 // case Key_F1:
1405 // if(stopped && !recording) 1412 // if(stopped && !recording)
1406 // newSound(); 1413 // newSound();
1407 // else 1414 // else
1408 // stop(); 1415 // stop();
1409 // break; 1416 // break;
1410 // case Key_F2: 1417 // case Key_F2:
1411 // rewindReleased(); 1418 // rewindReleased();
1412 // break; 1419 // break;
1413 // case Key_F3: 1420 // case Key_F3:
1414 // FastforwardReleased(); 1421 // FastforwardReleased();
1415 // break; 1422 // break;
1416 1423
1417 ////////////////////////////// Zaurus keys 1424 ////////////////////////////// Zaurus keys
1418 case Key_F9: //activity 1425 case Key_F9: //activity
1419 break; 1426 break;
1420 case Key_F10: //contacts 1427 case Key_F10: //contacts
1421 break; 1428 break;
1422 case Key_F11: //menu 1429 case Key_F11: //menu
1423 break; 1430 break;
1424 case Key_F12: //home 1431 case Key_F12: //home
1425 if(stopped) 1432 if(stopped)
1426 doPlayBtn(); 1433 doPlayBtn();
1427 else 1434 else
1428 stop(); 1435 stop();
1429 break; 1436 break;
1430 case Key_F13: //mail 1437 case Key_F13: //mail
1431 break; 1438 break;
1432 case Key_Space: 1439 case Key_Space:
1433 if(stopped && !recording) 1440 if(stopped && !recording)
1434 newSound(); 1441 newSound();
1435 else 1442 else
1436 stop(); 1443 stop();
1437 break; 1444 break;
1438 case Key_Delete: 1445 case Key_Delete:
1439 deleteSound(); 1446 deleteSound();
1440 break; 1447 break;
1441 case Key_Up: 1448 case Key_Up:
1442 // stop(); 1449 // stop();
1443 odebug << "Up" << oendl; 1450 odebug << "Up" << oendl;
1444 break; 1451 break;
1445 case Key_Down: 1452 case Key_Down:
1446 // start(); 1453 // start();
1447 // odebug << "Down" << oendl; 1454 // odebug << "Down" << oendl;
1448 // newSound(); 1455 // newSound();
1449 break; 1456 break;
1450 case Key_Left: 1457 case Key_Left:
1451 odebug << "Left" << oendl; 1458 odebug << "Left" << oendl;
1452 rewindReleased(); 1459 rewindReleased();
1453 break; 1460 break;
1454 case Key_Right: 1461 case Key_Right:
1455 odebug << "Right" << oendl; 1462 odebug << "Right" << oendl;
1456 FastforwardReleased(); 1463 FastforwardReleased();
1457 break; 1464 break;
1458 } 1465 }
1459} 1466}
1460 1467
1461void QtRec::endRecording() { 1468void QtRec::endRecording() {
1462 monitoring = false; 1469 monitoring = false;
1463 recording = false; 1470 recording = false;
1464 stopped = true; 1471 stopped = true;
1465 waveform->reset(); 1472 waveform->reset();
1466 setRecordButton( false); 1473 setRecordButton( false);
1467 1474
1468 toBeginningButton->setEnabled( true); 1475 toBeginningButton->setEnabled( true);
1469 toEndButton->setEnabled( true); 1476 toEndButton->setEnabled( true);
1470 1477
1471 killTimers(); 1478 killTimers();
1472 1479
1473 if(autoMute) 1480 if(autoMute)
1474 doMute( true); 1481 doMute( true);
1475 1482
1476 soundDevice->closeDevice( true); 1483 soundDevice->closeDevice( true);
1477 1484
1478 if( wavFile->track.isOpen()) { 1485 if( wavFile->track.isOpen()) {
1479 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1486 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1480 // soundDevice->sd=-1; 1487 // soundDevice->sd=-1;
1481 filePara.numberSamples = 0; 1488 filePara.numberSamples = 0;
1482 // filePara.sd=-1; 1489 // filePara.sd=-1;
1483 wavFile->closeFile(); 1490 wavFile->closeFile();
1484 filePara.fd=0; 1491 filePara.fd=0;
1485 1492
1486 if( wavFile->isTempFile()) { 1493 if( wavFile->isTempFile()) {
1487// move tmp file to regular file 1494// move tmp file to regular file
1488 QString cmd; 1495 QString cmd;
1489 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1496 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1490 odebug << "moving tmp file to "+currentFileName << oendl; 1497 odebug << "moving tmp file to "+currentFileName << oendl;
1491 system( cmd.latin1()); 1498 system( cmd.latin1());
1492 } 1499 }
1493 1500
1494 odebug << "Just moved " + wavFile->currentFileName << oendl; 1501 odebug << "Just moved " + wavFile->currentFileName << oendl;
1495 Config cfg("OpieRec"); 1502 Config cfg("OpieRec");
1496 cfg.setGroup("Sounds"); 1503 cfg.setGroup("Sounds");
1497 1504
1498 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1505 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1499 1506
1500 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1507 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1501 currentFile = currentFile.left( currentFile.length() - 4); 1508 currentFile = currentFile.left( currentFile.length() - 4);
1502 1509
1503 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1510 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1504 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1511 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1505 cfg.writeEntry( currentFile, wavFile->currentFileName); 1512 cfg.writeEntry( currentFile, wavFile->currentFileName);
1506 1513
1507 QString time; 1514 QString time;
1508 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1515 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1509 cfg.writeEntry( wavFile->currentFileName, time ); 1516 cfg.writeEntry( wavFile->currentFileName, time );
1510 odebug << "writing config numberOfRecordedSeconds "+time << oendl; 1517 odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1511 1518
1512 cfg.write(); 1519 cfg.write();
1513 odebug << "finished recording" << oendl; 1520 odebug << "finished recording" << oendl;
1514 // timeLabel->setText(""); 1521 // timeLabel->setText("");
1515 } 1522 }
1516 1523
1517// if(soundDevice) delete soundDevice; 1524// if(soundDevice) delete soundDevice;
1518 1525
1519 timeSlider->setValue(0); 1526 timeSlider->setValue(0);
1520 initIconView(); 1527 initIconView();
1521 selectItemByName( currentFile); 1528 selectItemByName( currentFile);
1522} 1529}
1523 1530
1524void QtRec::endPlaying() { 1531void QtRec::endPlaying() {
1525 monitoring = false; 1532 monitoring = false;
1526 recording = false; 1533 recording = false;
1527 playing = false; 1534 playing = false;
1528 stopped = true; 1535 stopped = true;
1529 waveform->reset(); 1536 waveform->reset();
1530// errorStop(); 1537// errorStop();
1531 odebug << "end playing" << oendl; 1538 odebug << "end playing" << oendl;
1532 setRecordButton( false); 1539 setRecordButton( false);
1533 1540
1534 toBeginningButton->setEnabled( true); 1541 toBeginningButton->setEnabled( true);
1535 toEndButton->setEnabled( true); 1542 toEndButton->setEnabled( true);
1536 1543
1537 if(autoMute) 1544 if(autoMute)
1538 doMute( true); 1545 doMute( true);
1539 1546
1540 soundDevice->closeDevice( false); 1547 soundDevice->closeDevice( false);
1541 soundDevice->sd = -1; 1548 soundDevice->sd = -1;
1542 // if(soundDevice) delete soundDevice; 1549 // if(soundDevice) delete soundDevice;
1543 odebug << "file and sound device closed" << oendl; 1550 odebug << "file and sound device closed" << oendl;
1544 // timeLabel->setText(""); 1551 // timeLabel->setText("");
1545 total = 0; 1552 total = 0;
1546 filePara.numberSamples = 0; 1553 filePara.numberSamples = 0;
1547 filePara.sd = -1; 1554 filePara.sd = -1;
1548// wavFile->closeFile(); 1555// wavFile->closeFile();
1549 filePara.fd = 0; 1556 filePara.fd = 0;
1550// if(wavFile) delete wavFile; //this crashes 1557// if(wavFile) delete wavFile; //this crashes
1551 1558
1552 odebug << "track closed" << oendl; 1559 odebug << "track closed" << oendl;
1553 killTimers(); 1560 killTimers();
1554 owarn << "reset slider" << oendl; 1561 owarn << "reset slider" << oendl;
1555 timeSlider->setValue(0); 1562 timeSlider->setValue(0);
1556 1563
1557// if(soundDevice) delete soundDevice; 1564// if(soundDevice) delete soundDevice;
1558 1565
1559} 1566}
1560 1567
1561bool QtRec::openPlayFile() { 1568bool QtRec::openPlayFile() {
1562 1569
1563 qApp->processEvents(); 1570 qApp->processEvents();
1564 if( currentFile.isEmpty()) { 1571 if( currentFile.isEmpty()) {
1565 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1572 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1566 endPlaying(); 1573 endPlaying();
1567 return false; 1574 return false;
1568 } 1575 }
1569 QString currentFileName; 1576 QString currentFileName;
1570 Config cfg("OpieRec"); 1577 Config cfg("OpieRec");
1571 cfg.setGroup("Sounds"); 1578 cfg.setGroup("Sounds");
1572 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1579 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1573 for(int i=0;i<nFiles+1;i++) { //look for file 1580 for(int i=0;i<nFiles+1;i++) { //look for file
1574 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1581 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1575 currentFileName = cfg.readEntry( currentFile, "" ); 1582 currentFileName = cfg.readEntry( currentFile, "" );
1576 odebug << "opening for play: " + currentFileName << oendl; 1583 odebug << "opening for play: " + currentFileName << oendl;
1577 } 1584 }
1578 } 1585 }
1579 wavFile = new WavFile(this, 1586 wavFile = new WavFile(this,
1580 currentFileName, 1587 currentFileName,
1581 false); 1588 false);
1582 filePara.fd = wavFile->wavHandle(); 1589 filePara.fd = wavFile->wavHandle();
1583 if(filePara.fd == -1) { 1590 if(filePara.fd == -1) {
1584 // if(!track.open(IO_ReadOnly)) { 1591 // if(!track.open(IO_ReadOnly)) {
1585 QString errorMsg = (QString)strerror(errno); 1592 QString errorMsg = (QString)strerror(errno);
1586 monitoring = false; 1593 monitoring = false;
1587 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1594 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1588 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") 1595 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1589 + errorMsg + "\n" + currentFile); 1596 + errorMsg + "\n" + currentFile);
1590 return false; 1597 return false;
1591 } else { 1598 } else {
1592 1599
1593 filePara.numberSamples = wavFile->getNumberSamples(); 1600 filePara.numberSamples = wavFile->getNumberSamples();
1594 filePara.format = wavFile->getFormat(); 1601 filePara.format = wavFile->getFormat();
1595 filePara.sampleRate = wavFile->getSampleRate(); 1602 filePara.sampleRate = wavFile->getSampleRate();
1596 filePara.resolution = wavFile->getResolution(); 1603 filePara.resolution = wavFile->getResolution();
1597 filePara.channels = wavFile->getChannels(); 1604 filePara.channels = wavFile->getChannels();
1598 timeSlider->setPageStep(1); 1605 timeSlider->setPageStep(1);
1599 monitoring = true; 1606 monitoring = true;
1600 1607
1601 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; 1608 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1602 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1609 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1603 1610
1604 owarn << "seconds " << sec << "" << oendl; 1611 owarn << "seconds " << sec << "" << oendl;
1605 1612
1606 timeSlider->setRange(0, filePara.numberSamples ); 1613 timeSlider->setRange(0, filePara.numberSamples );
1607 } 1614 }
1608 1615
1609 return true; 1616 return true;
1610} 1617}
1611 1618
1612void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1619void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1613 if(item == NULL ) 1620 if(item == NULL )
1614 return; 1621 return;
1615 switch (mouse) { 1622 switch (mouse) {
1616 case 1: { 1623 case 1: {
1617 if( renameBox != 0 ) //tricky 1624 if( renameBox != 0 ) //tricky
1618 cancelRename(); 1625 cancelRename();
1619 1626
1620 currentFile = item->text(0); 1627 currentFile = item->text(0);
1621 setCaption( "OpieRecord " + currentFile); 1628 setCaption( "OpieRecord " + currentFile);
1622 } 1629 }
1623 break; 1630 break;
1624 case 2: 1631 case 2:
1625 showListMenu(item); 1632 showListMenu(item);
1626 ListView1->clearSelection(); 1633 ListView1->clearSelection();
1627 break; 1634 break;
1628 }; 1635 };
1629} 1636}
1630 1637
1631void QtRec::showListMenu(QListViewItem * item) { 1638void QtRec::showListMenu(QListViewItem * item) {
1632 if(item == NULL) 1639 if(item == NULL)
1633 return; 1640 return;
1634 QPopupMenu *m = new QPopupMenu(this); 1641 QPopupMenu *m = new QPopupMenu(this);
1635 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1642 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1636 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1643 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1637 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1644 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1638 // #if defined (QTOPIA_INTERNAL_FSLP) 1645 // #if defined (QTOPIA_INTERNAL_FSLP)
1639 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1646 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1640 // #endif 1647 // #endif
1641 m->insertSeparator(); 1648 m->insertSeparator();
1642 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1649 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1643 m->exec( QCursor::pos() ); 1650 m->exec( QCursor::pos() );
1644 qApp->processEvents(); 1651 qApp->processEvents();
1645} 1652}
1646 1653
1647void QtRec::fileBeamFinished( Ir *ir) { 1654void QtRec::fileBeamFinished( Ir *ir) {
1648 if(ir) 1655 if(ir)
1649 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1656 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1650 1657
1651} 1658}
1652 1659
1653void QtRec::doBeam() { 1660void QtRec::doBeam() {
1654 qApp->processEvents(); 1661 qApp->processEvents();
1655 if( ListView1->currentItem() == NULL) 1662 if( ListView1->currentItem() == NULL)
1656 return; 1663 return;
1657 Ir ir; 1664 Ir ir;
1658 if( ir.supported()) { 1665 if( ir.supported()) {
1659 QString file = ListView1->currentItem()->text(0); 1666 QString file = ListView1->currentItem()->text(0);
1660 Config cfg("OpieRec"); 1667 Config cfg("OpieRec");
1661 cfg.setGroup("Sounds"); 1668 cfg.setGroup("Sounds");
1662 1669
1663 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1670 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1664 1671
1665 for(int i=0;i<nFiles+1;i++) { 1672 for(int i=0;i<nFiles+1;i++) {
1666 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { 1673 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) {
1667 QString filePath = cfg.readEntry(file,""); 1674 QString filePath = cfg.readEntry(file,"");
1668 Ir *file = new Ir(this, "IR"); 1675 Ir *file = new Ir(this, "IR");
1669 connect( file, SIGNAL( done(Ir*)), 1676 connect( file, SIGNAL( done(Ir*)),
1670 this, SLOT( fileBeamFinished(Ir*))); 1677 this, SLOT( fileBeamFinished(Ir*)));
1671 file->send( filePath, "OPieRec audio file\n" + filePath ); 1678 file->send( filePath, "OPieRec audio file\n" + filePath );
1672 } 1679 }
1673 } 1680 }
1674 } 1681 }
1675} 1682}
1676 1683
1677void QtRec::doMenuPlay() { 1684void QtRec::doMenuPlay() {
1678 qApp->processEvents(); 1685 qApp->processEvents();
1679 currentFile = ListView1->currentItem()->text(0); 1686 currentFile = ListView1->currentItem()->text(0);
1680} 1687}
1681 1688
1682void QtRec::doRename() { 1689void QtRec::doRename() {
1683 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1690 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1684 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1691 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1685 r.setX( ListView1->contentsX() ); 1692 r.setX( ListView1->contentsX() );
1686 if ( r.width() > ListView1->visibleWidth() ) 1693 if ( r.width() > ListView1->visibleWidth() )
1687 r.setWidth( ListView1->visibleWidth() ); 1694 r.setWidth( ListView1->visibleWidth() );
1688 1695
1689 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1696 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1690 renameBox->setFrame(true); 1697 renameBox->setFrame(true);
1691 1698
1692 renameBox->setText( ListView1->currentItem()->text(0) ); 1699 renameBox->setText( ListView1->currentItem()->text(0) );
1693 1700
1694 renameBox->selectAll(); 1701 renameBox->selectAll();
1695 renameBox->installEventFilter( this ); 1702 renameBox->installEventFilter( this );
1696 ListView1->addChild( renameBox, r.x(), r.y() ); 1703 ListView1->addChild( renameBox, r.x(), r.y() );
1697 renameBox->resize( r.size() ); 1704 renameBox->resize( r.size() );
1698 ListView1->viewport()->setFocusProxy( renameBox ); 1705 ListView1->viewport()->setFocusProxy( renameBox );
1699 renameBox->setFocus(); 1706 renameBox->setFocus();
1700 renameBox->show(); 1707 renameBox->show();
1701 1708
1702} 1709}
1703 1710
1704void QtRec::okRename() { 1711void QtRec::okRename() {
1705 odebug << renameBox->text() << oendl; 1712 odebug << renameBox->text() << oendl;
1706 QString filename = renameBox->text(); 1713 QString filename = renameBox->text();
1707 cancelRename(); 1714 cancelRename();
1708 1715
1709 if( ListView1->currentItem() == NULL) 1716 if( ListView1->currentItem() == NULL)
1710 return; 1717 return;
1711 1718
1712 Config cfg("OpieRec"); 1719 Config cfg("OpieRec");
1713 cfg.setGroup("Sounds"); 1720 cfg.setGroup("Sounds");
1714 1721
1715 QString file = ListView1->currentItem()->text(0); 1722 QString file = ListView1->currentItem()->text(0);
1716 1723
1717 odebug << "filename is " + filename << oendl; 1724 odebug << "filename is " + filename << oendl;
1718 1725
1719 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1726 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1720 1727
1721 for(int i=0;i<nFiles+1;i++) { //look for file 1728 for(int i=0;i<nFiles+1;i++) { //look for file
1722 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1729 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1723 1730
1724 QString filePath = cfg.readEntry(file,""); 1731 QString filePath = cfg.readEntry(file,"");
1725 1732
1726 cfg.writeEntry( QString::number(i), filename ); 1733 cfg.writeEntry( QString::number(i), filename );
1727 cfg.writeEntry( filename, filePath ); 1734 cfg.writeEntry( filename, filePath );
1728 cfg.removeEntry( file); 1735 cfg.removeEntry( file);
1729 cfg.write(); 1736 cfg.write();
1730 } 1737 }
1731 } 1738 }
1732 1739
1733 ListView1->takeItem( ListView1->currentItem() ); 1740 ListView1->takeItem( ListView1->currentItem() );
1734 delete ListView1->currentItem(); 1741 delete ListView1->currentItem();
1735 ListView1->clear(); 1742 ListView1->clear();
1736 initIconView(); 1743 initIconView();
1737 update(); 1744 update();
1738} 1745}
1739 1746
1740void QtRec::cancelRename() { 1747void QtRec::cancelRename() {
1741 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1748 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1742 delete renameBox; 1749 delete renameBox;
1743 renameBox = 0; 1750 renameBox = 0;
1744 if ( resetFocus ) { 1751 if ( resetFocus ) {
1745 ListView1->viewport()->setFocusProxy( ListView1 ); 1752 ListView1->viewport()->setFocusProxy( ListView1 );
1746 ListView1->setFocus(); 1753 ListView1->setFocus();
1747 } 1754 }
1748} 1755}
1749 1756
1750bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1757bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1751 if ( o->inherits( "QLineEdit" ) ) { 1758 if ( o->inherits( "QLineEdit" ) ) {
1752 if ( e->type() == QEvent::KeyPress ) { 1759 if ( e->type() == QEvent::KeyPress ) {
1753 QKeyEvent *ke = (QKeyEvent*)e; 1760 QKeyEvent *ke = (QKeyEvent*)e;
1754 if ( ke->key() == Key_Return || 1761 if ( ke->key() == Key_Return ||
1755 ke->key() == Key_Enter ) { 1762 ke->key() == Key_Enter ) {
1756 okRename(); 1763 okRename();
1757 return true; 1764 return true;
1758 } else if ( ke->key() == Key_Escape ) { 1765 } else if ( ke->key() == Key_Escape ) {
1759 cancelRename(); 1766 cancelRename();
1760 return true; 1767 return true;
1761 } 1768 }
1762 } else if ( e->type() == QEvent::FocusOut ) { 1769 } else if ( e->type() == QEvent::FocusOut ) {
1763 cancelRename(); 1770 cancelRename();
1764 return true; 1771 return true;
1765 } 1772 }
1766 } 1773 }
1767 return QWidget::eventFilter( o, e ); 1774 return QWidget::eventFilter( o, e );
1768} 1775}
1769 1776
1770 1777
1771int QtRec::getCurrentSizeLimit() { 1778int QtRec::getCurrentSizeLimit() {
1772 return sizeLimitCombo->currentItem() * 5; 1779 return sizeLimitCombo->currentItem() * 5;
1773} 1780}
1774 1781
1775void QtRec::timerBreak() { 1782void QtRec::timerBreak() {
1776 endPlaying(); 1783 endPlaying();
1777} 1784}
1778 1785
1779void QtRec::doVolMuting(bool b) { 1786void QtRec::doVolMuting(bool b) {
1780 Config cfg( "qpe" ); 1787 Config cfg( "qpe" );
1781 cfg. setGroup( "Volume" ); 1788 cfg. setGroup( "Volume" );
1782 cfg.writeEntry( "Mute",b); 1789 cfg.writeEntry( "Mute",b);
1783 cfg.write(); 1790 cfg.write();
1784 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1791 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1785} 1792}
1786 1793
1787void QtRec::doMicMuting(bool b) { 1794void QtRec::doMicMuting(bool b) {
1788 // odebug << "mic mute" << oendl; 1795 // odebug << "mic mute" << oendl;
1789 Config cfg( "qpe" ); 1796 Config cfg( "qpe" );
1790 cfg. setGroup( "Volume" ); 1797 cfg. setGroup( "Volume" );
1791 cfg.writeEntry( "MicMute",b); 1798 cfg.writeEntry( "MicMute",b);
1792 cfg.write(); 1799 cfg.write();
1793 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1800 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1794} 1801}
1795 1802
1796void QtRec::compressionSelected(bool b) { 1803void QtRec::compressionSelected(bool b) {
1797 Config cfg("OpieRec"); 1804 Config cfg("OpieRec");
1798 cfg.setGroup("Settings"); 1805 cfg.setGroup("Settings");
1799 cfg.writeEntry("wavCompression", b); 1806 cfg.writeEntry("wavCompression", b);
1800 cfg.writeEntry("bitrate", 16); 1807 cfg.writeEntry("bitrate", 16);
1801 filePara.resolution = 16; 1808 filePara.resolution = 16;
1802 cfg.write(); 1809 cfg.write();
1803 1810
1804 if(b) { 1811 if(b) {
1805 bitRateComboBox->setEnabled( false); 1812 bitRateComboBox->setEnabled( false);
1806 bitRateComboBox->setCurrentItem( 1); 1813 bitRateComboBox->setCurrentItem( 1);
1807 filePara.resolution = 16; 1814 filePara.resolution = 16;
1808 } else{ 1815 } else{
1809 bitRateComboBox->setEnabled( true); 1816 bitRateComboBox->setEnabled( true);
1810 } 1817 }
1811} 1818}
1812 1819
1813long QtRec::checkDiskSpace(const QString &path) { 1820long QtRec::checkDiskSpace(const QString &path) {
1814 1821
1815 struct statfs fs; 1822 struct statfs fs;
1816 1823
1817 if ( !statfs( path.latin1(), &fs ) ) { 1824 if ( !statfs( path.latin1(), &fs ) ) {
1818 1825
1819 int blkSize = fs.f_bsize; 1826 int blkSize = fs.f_bsize;
1820 int availBlks = fs.f_bavail; 1827 int availBlks = fs.f_bavail;
1821 1828
1822 long mult = blkSize / 1024; 1829 long mult = blkSize / 1024;
1823 long div = 1024 / blkSize; 1830 long div = 1024 / blkSize;
1824 1831
1825 if ( !mult ) mult = 1; 1832 if ( !mult ) mult = 1;
1826 if ( !div ) div = 1; 1833 if ( !div ) div = 1;
1827 1834
1828 return availBlks * mult / div; 1835 return availBlks * mult / div;
1829 } 1836 }
1830 return -1; 1837 return -1;
1831} 1838}
1832 1839
1833// short f_fstyp; /* File system type */ 1840// short f_fstyp; /* File system type */
1834// long f_bsize; /* Block size */ 1841// long f_bsize; /* Block size */
1835// long f_frsize; /* Fragment size */ 1842// long f_frsize; /* Fragment size */
1836// long f_blocks; /* Total number of blocks*/ 1843// long f_blocks; /* Total number of blocks*/
1837// long f_bfree; /* Count of free blocks */ 1844// long f_bfree; /* Count of free blocks */
1838// long f_files; /* Total number of file nodes */ 1845// long f_files; /* Total number of file nodes */
1839// long f_ffree; /* Count of free file nodes */ 1846// long f_ffree; /* Count of free file nodes */
1840// char f_fname[6]; /* Volumename */ 1847// char f_fname[6]; /* Volumename */
1841// char f_fpack[6]; /* Pack name */ 1848// char f_fpack[6]; /* Pack name */
1842 1849
1843void QtRec::receive( const QCString &msg, const QByteArray & ) { 1850void QtRec::receive( const QCString &msg, const QByteArray & ) {
1844 odebug << "Voicerecord received message "+msg << oendl; 1851 odebug << "Voicerecord received message "+msg << oendl;
1845 1852
1846} 1853}
1847 1854
1848 1855
1849///////////////////////////// timerEvent 1856///////////////////////////// timerEvent
1850void QtRec::timerEvent( QTimerEvent * ) { 1857void QtRec::timerEvent( QTimerEvent * ) {
1851 1858
1852// if(!recording) 1859// if(!recording)
1853// timeSlider->setValue( secCount); 1860// timeSlider->setValue( secCount);
1854// else 1861// else
1855// timeSlider->setValue( filePara.numberOfRecordedSeconds); 1862// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1856 1863
1857 if( stopped && playing) { 1864 if( stopped && playing) {
1858 stop(); 1865 stop();
1859 } 1866 }
1860 1867
1861 if( stopped && recording ){ 1868 if( stopped && recording ){
1862 stop(); 1869 stop();
1863 } 1870 }
1864 1871
1865 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { 1872 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1866 stop(); 1873 stop();
1867 } 1874 }
1868 1875
1869 odebug << "" << secCount << "" << oendl; 1876 odebug << "" << secCount << "" << oendl;
1870 QString timeString; 1877 QString timeString;
1871#ifdef DEV_VERSION 1878#ifdef DEV_VERSION
1872 QString msg; 1879 QString msg;
1873 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1880 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1874 setCaption( msg +" :: "+QString::number(secCount)); 1881 setCaption( msg +" :: "+QString::number(secCount));
1875#endif 1882#endif
1876 1883
1877 timeString.sprintf("%d", secCount); 1884 timeString.sprintf("%d", secCount);
1878 // timeLabel->setText( timeString + " seconds"); 1885 // timeLabel->setText( timeString + " seconds");
1879 1886
1880 secCount++; 1887 secCount++;
1881} 1888}
1882 1889
1883void QtRec::changeTimeSlider(int index) { 1890void QtRec::changeTimeSlider(int index) {
1884 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1891 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1885 odebug << "Slider moved to " << index << "" << oendl; 1892 odebug << "Slider moved to " << index << "" << oendl;
1886 paused = true; 1893 paused = true;
1887 stopped = true; 1894 stopped = true;
1888 1895
1889 sliderPos=index; 1896 sliderPos=index;
1890 1897
1891 QString timeString; 1898 QString timeString;
1892 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1899 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1893 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1900 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1894 secCount = (int)filePara.numberOfRecordedSeconds; 1901 secCount = (int)filePara.numberOfRecordedSeconds;
1895 // timeLabel->setText( timeString + tr(" seconds")); 1902 // timeLabel->setText( timeString + tr(" seconds"));
1896} 1903}
1897 1904
1898void QtRec::timeSliderPressed() { 1905void QtRec::timeSliderPressed() {
1899 if( ListView1->currentItem() == 0) return; 1906 if( ListView1->currentItem() == 0) return;
1900 odebug << "slider pressed" << oendl; 1907 odebug << "slider pressed" << oendl;
1901 paused = true; 1908 paused = true;
1902 stopped = true; 1909 stopped = true;
1903} 1910}
1904 1911
1905void QtRec::timeSliderReleased() { 1912void QtRec::timeSliderReleased() {
1906 if( ListView1->currentItem() == 0) return; 1913 if( ListView1->currentItem() == 0) return;
1907 sliderPos = timeSlider->value(); 1914 sliderPos = timeSlider->value();
1908 1915
1909 odebug << "slider released " << sliderPos << "" << oendl; 1916 odebug << "slider released " << sliderPos << "" << oendl;
1910 stopped = false; 1917 stopped = false;
1911 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1918 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1912 total = newPos*4; 1919 total = newPos*4;
1913 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1920 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1914 1921
1915 doPlay(); 1922 doPlay();
1916} 1923}
1917 1924
1918void QtRec::rewindPressed() { 1925void QtRec::rewindPressed() {
1919 if( ListView1->currentItem() == 0) return; 1926 if( ListView1->currentItem() == 0) return;
1920 if( !wavFile->track.isOpen()) { 1927 if( !wavFile->track.isOpen()) {
1921 if( !openPlayFile() ) 1928 if( !openPlayFile() )
1922 return; 1929 return;
1923 else 1930 else
1924 if( !setupAudio( false)) 1931 if( !setupAudio( false))
1925 return; 1932 return;
1926 } else { 1933 } else {
1927 killTimers(); 1934 killTimers();
1928 paused = true; 1935 paused = true;
1929 stopped = true; 1936 stopped = true;
1930 rewindTimer->start( 50, false); 1937 rewindTimer->start( 50, false);
1931 } 1938 }
1932} 1939}
1933 1940
1934void QtRec::rewindTimerTimeout() { 1941void QtRec::rewindTimerTimeout() {
1935 int sliderValue = timeSlider->value(); 1942 int sliderValue = timeSlider->value();
1936 sliderValue = sliderValue - ( filePara.numberSamples / 100); 1943 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1937 // if(toBeginningButton->isDown()) 1944 // if(toBeginningButton->isDown())
1938 timeSlider->setValue( sliderValue ) ; 1945 timeSlider->setValue( sliderValue ) ;
1939 odebug << "" << sliderValue << "" << oendl; 1946 odebug << "" << sliderValue << "" << oendl;
1940 QString timeString; 1947 QString timeString;
1941 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1948 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1942 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1949 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1943 // timeLabel->setText( timeString+ tr(" seconds")); 1950 // timeLabel->setText( timeString+ tr(" seconds"));
1944} 1951}
1945 1952
1946void QtRec::rewindReleased() { 1953void QtRec::rewindReleased() {
1947 rewindTimer->stop(); 1954 rewindTimer->stop();
1948 if( wavFile->track.isOpen()) { 1955 if( wavFile->track.isOpen()) {
1949 sliderPos=timeSlider->value(); 1956 sliderPos=timeSlider->value();
1950 stopped = false; 1957 stopped = false;
1951 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1958 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1952 total = newPos * 4; 1959 total = newPos * 4;
1953 odebug << "rewind released " << total << "" << oendl; 1960 odebug << "rewind released " << total << "" << oendl;
1954 startTimer( 1000); 1961 startTimer( 1000);
1955 doPlay(); 1962 doPlay();
1956 } 1963 }
1957} 1964}
1958 1965
1959void QtRec::FastforwardPressed() { 1966void QtRec::FastforwardPressed() {
1960 if( ListView1->currentItem() == 0) return; 1967 if( ListView1->currentItem() == 0) return;
1961 if( !wavFile->track.isOpen()) 1968 if( !wavFile->track.isOpen())
1962 if( !openPlayFile() ) 1969 if( !openPlayFile() )
1963 return; 1970 return;
1964 else 1971 else
1965 if( !setupAudio( false)) 1972 if( !setupAudio( false))
1966 return; 1973 return;
1967 killTimers(); 1974 killTimers();
1968 1975
1969 paused = true; 1976 paused = true;
1970 stopped = true; 1977 stopped = true;
1971 forwardTimer->start(50, false); 1978 forwardTimer->start(50, false);
1972} 1979}
1973 1980
1974 1981
1975void QtRec::forwardTimerTimeout() { 1982void QtRec::forwardTimerTimeout() {
1976 int sliderValue = timeSlider->value(); 1983 int sliderValue = timeSlider->value();
1977 sliderValue = sliderValue + ( filePara.numberSamples / 100); 1984 sliderValue = sliderValue + ( filePara.numberSamples / 100);
1978 1985
1979 // if(toEndButton->isDown()) 1986 // if(toEndButton->isDown())
1980 timeSlider->setValue( sliderValue); 1987 timeSlider->setValue( sliderValue);
1981 1988
1982 QString timeString; 1989 QString timeString;
1983 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1990 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1984 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1991 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1985 // timeLabel->setText( timeString+ tr(" seconds")); 1992 // timeLabel->setText( timeString+ tr(" seconds"));
1986} 1993}
1987 1994
1988void QtRec::FastforwardReleased() { 1995void QtRec::FastforwardReleased() {
1989 forwardTimer->stop(); 1996 forwardTimer->stop();
1990 if( wavFile->track.isOpen()) { 1997 if( wavFile->track.isOpen()) {
1991 sliderPos=timeSlider->value(); 1998 sliderPos=timeSlider->value();
1992 stopped = false; 1999 stopped = false;
1993 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 2000 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1994 total = newPos * 4; 2001 total = newPos * 4;
1995 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 2002 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1996 startTimer( 1000); 2003 startTimer( 1000);
1997 doPlay(); 2004 doPlay();
1998 } 2005 }
1999} 2006}
2000 2007
2001 2008
2002QString QtRec::getStorage(const QString &fileName) { 2009QString QtRec::getStorage(const QString &fileName) {
2003 2010
2004 StorageInfo storageInfo; 2011 StorageInfo storageInfo;
2005 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2012 const QList<FileSystem> &fs = storageInfo.fileSystems();
2006 QListIterator<FileSystem> it ( fs ); 2013 QListIterator<FileSystem> it ( fs );
2007 QString storage; 2014 QString storage;
2008 for( ; it.current(); ++it ){ 2015 for( ; it.current(); ++it ){
2009 const QString name = ( *it)->name(); 2016 const QString name = ( *it)->name();
2010 const QString path = ( *it)->path(); 2017 const QString path = ( *it)->path();
2011 const QString disk = ( *it)->disk(); 2018 const QString disk = ( *it)->disk();
2012 if( fileName.find( path,0,true) != -1) 2019 if( fileName.find( path,0,true) != -1)
2013 storage = name; 2020 storage = name;
2014 // const QString options = (*it)->options(); 2021 // const QString options = (*it)->options();
2015 // if( name.find( tr("Internal"),0,true) == -1) { 2022 // if( name.find( tr("Internal"),0,true) == -1) {
2016 // storageComboBox->insertItem( name +" -> "+disk); 2023 // storageComboBox->insertItem( name +" -> "+disk);
2017 // odebug << name << oendl; 2024 // odebug << name << oendl;
2018 } 2025 }
2019 return storage; 2026 return storage;
2020 // struct mntent *me; 2027 // struct mntent *me;
2021 // // if(fileName == "/etc/mtab") { 2028 // // if(fileName == "/etc/mtab") {
2022 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2029 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2023 // if ( mntfp ) { 2030 // if ( mntfp ) {
2024 // while ( (me = getmntent( mntfp )) != 0 ) { 2031 // while ( (me = getmntent( mntfp )) != 0 ) {
2025 // QString filesystemType = me->mnt_type; 2032 // QString filesystemType = me->mnt_type;
2026 2033
2027 // } 2034 // }
2028 // } 2035 // }
2029 // endmntent( mntfp ); 2036 // endmntent( mntfp );
2030} 2037}
2031 2038
2032void QtRec::setRecordButton(bool b) { 2039void QtRec::setRecordButton(bool b) {
2033 2040
2034 if(b) { //about to record or play 2041 if(b) { //about to record or play
2035 2042
2036 Rec_PushButton->setDown( true); 2043 Rec_PushButton->setDown( true);
2037 QPixmap image3( ( const char** ) image3_data ); 2044 QPixmap image3( ( const char** ) image3_data );
2038 Stop_PushButton->setPixmap( image3 ); 2045 Stop_PushButton->setPixmap( image3 );
2039 if(Stop_PushButton->isDown()) 2046 if(Stop_PushButton->isDown())
2040 Stop_PushButton->setDown( true); 2047 Stop_PushButton->setDown( true);
2041 // playLabel2->setText( tr("Stop") ); 2048 // playLabel2->setText( tr("Stop") );
2042 2049
2043 } else { //about to stop 2050 } else { //about to stop
2044 2051
2045 QPixmap image4( ( const char** ) image4_data ); 2052 QPixmap image4( ( const char** ) image4_data );
2046 Stop_PushButton->setPixmap( image4); 2053 Stop_PushButton->setPixmap( image4);
2047 if(Stop_PushButton->isDown()) 2054 if(Stop_PushButton->isDown())
2048 Stop_PushButton->setDown( false); 2055 Stop_PushButton->setDown( false);
2049 // playLabel2->setText( tr("Play") ); 2056 // playLabel2->setText( tr("Play") );
2050 if(Rec_PushButton->isDown()) 2057 if(Rec_PushButton->isDown())
2051 Rec_PushButton->setDown( false); 2058 Rec_PushButton->setDown( false);
2052 } 2059 }
2053} 2060}
2054 2061
2055void QtRec::fillDirectoryCombo() { 2062void QtRec::fillDirectoryCombo() {
2056 if( directoryComboBox->count() > 0) 2063 if( directoryComboBox->count() > 0)
2057 directoryComboBox->clear(); 2064 directoryComboBox->clear();
2058 int index = 0; 2065 int index = 0;
2059 Config cfg("OpieRec"); 2066 Config cfg("OpieRec");
2060 cfg.setGroup("Settings"); 2067 cfg.setGroup("Settings");
2061 QString dir = cfg.readEntry("directory", "/"); 2068 QString dir = cfg.readEntry("directory", "/");
2062 StorageInfo storageInfo; 2069 StorageInfo storageInfo;
2063 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2070 const QList<FileSystem> &fs = storageInfo.fileSystems();
2064 QListIterator<FileSystem> it ( fs ); 2071 QListIterator<FileSystem> it ( fs );
2065 QString storage; 2072 QString storage;
2066 for( ; it.current(); ++it ){ 2073 for( ; it.current(); ++it ){
2067 const QString name = ( *it)->name(); 2074 const QString name = ( *it)->name();
2068 const QString path = ( *it)->path(); 2075 const QString path = ( *it)->path();
2069 // directoryComboBox->insertItem(name+" "+path); 2076 // directoryComboBox->insertItem(name+" "+path);
2070 directoryComboBox->insertItem(name); 2077 directoryComboBox->insertItem(name);
2071 if( path == dir) 2078 if( path == dir)
2072 directoryComboBox->setCurrentItem( index); 2079 directoryComboBox->setCurrentItem( index);
2073 index++; 2080 index++;
2074 } 2081 }
2075} 2082}
2076 2083
2077void QtRec::errorStop() { 2084void QtRec::errorStop() {
2078 stopped = true; 2085 stopped = true;
2079 wavFile->closeFile(); 2086 wavFile->closeFile();
2080 killTimers(); 2087 killTimers();
2081} 2088}
2082 2089
2083void QtRec::doMute(bool b) { 2090void QtRec::doMute(bool b) {
2084 doVolMuting( b); 2091 doVolMuting( b);
2085 doMicMuting( b); 2092 doMicMuting( b);
2086} 2093}
2087 2094
2088void QtRec::slotAutoMute(bool b) { 2095void QtRec::slotAutoMute(bool b) {
2089 autoMute = b; 2096 autoMute = b;
2090 Config cfg("OpieRec"); 2097 Config cfg("OpieRec");
2091 cfg.setGroup("Settings"); 2098 cfg.setGroup("Settings");
2092 cfg.writeEntry("useAutoMute",b); 2099 cfg.writeEntry("useAutoMute",b);
2093 doMute( b); 2100 doMute( b);
2094 outMuteCheckBox->setChecked( b); 2101 outMuteCheckBox->setChecked( b);
2095 inMuteCheckBox->setChecked( b); 2102 inMuteCheckBox->setChecked( b);
2096} 2103}
2097 2104
2098void QtRec::selectItemByName(const QString & name) { 2105void QtRec::selectItemByName(const QString & name) {
2099 QListViewItemIterator it( ListView1 ); 2106 QListViewItemIterator it( ListView1 );
2100 for ( ; it.current(); ++it ) 2107 for ( ; it.current(); ++it )
2101 if( name == it.current()->text(0)) 2108 if( name == it.current()->text(0))
2102 ListView1->setCurrentItem(it.current()); 2109 ListView1->setCurrentItem(it.current());
2103} 2110}
2104 2111
2105 2112
2106// long findPeak(long input ) { 2113// long findPeak(long input ) {
2107 2114
2108// // halfLife = time in seconds for output to decay to half value after an impulse 2115// // halfLife = time in seconds for output to decay to half value after an impulse
2109// static float output = 0.0; 2116// static float output = 0.0;
2110// float halfLife = .0025; 2117// float halfLife = .0025;
2111// float vsf = .0025; 2118// float vsf = .0025;
2112// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2119// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2113// if( input < 0.0 ) 2120// if( input < 0.0 )
2114// input = -input; // Absolute value. 2121// input = -input; // Absolute value.
2115// if ( input >= output ) { 2122// if ( input >= output ) {
2116// // When we hit a peak, ride the peak to the top. 2123// // When we hit a peak, ride the peak to the top.
2117// output = input; 2124// output = input;
2118// } else { 2125// } else {
2119// // Exponential decay of output when signal is low. 2126// // Exponential decay of output when signal is low.
2120// output = output * scalar; 2127// output = output * scalar;
2121// // 2128// //
2122// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2129// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2123// // which can cause a severe performance degradation due to a flood 2130// // which can cause a severe performance degradation due to a flood
2124// // of interrupts. 2131// // of interrupts.
2125// // 2132// //
2126// if( output < vsf ) output = 0.0; 2133// if( output < vsf ) output = 0.0;
2127// } 2134// }
2128 2135
2129// return (long) output; 2136// return (long) output;
2130// } 2137// }
2131 2138
2132void QtRec::changeStereoCheck(bool b) { 2139void QtRec::changeStereoCheck(bool b) {
2133 Config cfg("OpieRec"); 2140 Config cfg("OpieRec");
2134 cfg.setGroup("Settings"); 2141 cfg.setGroup("Settings");
2135 int ch = 0; 2142 int ch = 0;
2136 if ( !b) { ch = 1;} 2143 if ( !b) { ch = 1;}
2137 else { ch = 2;} 2144 else { ch = 2;}
2138 cfg.writeEntry("stereo", b); 2145 cfg.writeEntry("stereo", b);
2139 filePara.channels = ch; 2146 filePara.channels = ch;
2140 2147
2141 cfg.write(); 2148 cfg.write();
2142} 2149}
2143 2150
2144 2151