]>
Commit | Line | Data |
---|---|---|
55951cc9 BZ |
1 | --- player.cpp 2008/09/16 19:41:09 274 |
2 | +++ player.cpp 2009/04/21 20:44:39 275 | |
3 | @@ -1,5 +1,5 @@ | |
4 | /* | |
5 | - Copyright (c) 2006-2008 by amdfanatyk <amdfanatyk@o2.pl> | |
6 | + Copyright (c) 2006-2009 by amdfanatyk <amdfanatyk@o2.pl> | |
7 | ||
8 | ************************************************************************* | |
9 | * * | |
10 | @@ -26,6 +26,8 @@ | |
11 | ao_port = xine_open_audio_driver(xine, NULL, NULL); | |
12 | ||
13 | term = true; | |
14 | + restoring = false; | |
15 | + | |
16 | pos = 0; | |
17 | stream = 0; | |
18 | ||
19 | @@ -98,6 +100,9 @@ | |
20 | void Player::setVolume(const int & vol) | |
21 | { | |
22 | volume = vol; | |
23 | + | |
24 | + if (stream) | |
25 | + xine_set_param(stream, XINE_PARAM_AUDIO_VOLUME, volume); | |
26 | } | |
27 | ||
28 | int Player::getLength() const | |
29 | @@ -115,6 +120,11 @@ | |
30 | return pos; | |
31 | } | |
32 | ||
33 | +bool Player::getRestoring() const | |
34 | +{ | |
35 | + return restoring; | |
36 | +} | |
37 | + | |
38 | void Player::setPos(const int & p) | |
39 | { | |
40 | pos = p; | |
41 | @@ -155,6 +165,11 @@ | |
42 | term = false; | |
43 | } | |
44 | ||
45 | +void Player::setRestoring(const bool value) | |
46 | +{ | |
47 | + restoring = value; | |
48 | +} | |
49 | + | |
50 | void Player::run() | |
51 | { | |
52 | if (!xine) | |
53 | @@ -168,16 +183,21 @@ | |
54 | if (!xine_open(stream, (const char *)track.local8Bit()) || !xine_play(stream, 0, pos)) | |
55 | goto cleanup; | |
56 | ||
57 | + setVolume(volume); | |
58 | + | |
59 | while ((xine_get_status(stream) == XINE_STATUS_PLAY) && (!term)) | |
60 | { | |
61 | - xine_set_param(stream, XINE_PARAM_AUDIO_VOLUME, volume); | |
62 | + if (restoring) | |
63 | + setVolume(volume); | |
64 | + else | |
65 | + volume = xine_get_param(stream, XINE_PARAM_AUDIO_VOLUME); | |
66 | + | |
67 | xine_get_pos_length(stream, NULL, &pos, &length); | |
68 | ||
69 | QThread::msleep(250); | |
70 | } | |
71 | ||
72 | cleanup: | |
73 | - | |
74 | xine_close(stream); | |
75 | xine_dispose(stream); | |
76 | ||
77 | --- frmmain.ui.h 2008/09/16 19:41:09 274 | |
78 | +++ frmmain.ui.h 2009/04/21 20:44:39 275 | |
55951cc9 BZ |
79 | @@ -571,6 +571,8 @@ |
80 | player.setPos(frame); | |
81 | sldPos->setValue(frame); | |
82 | ||
83 | + player.setRestoring(true); | |
84 | + | |
85 | QTimer::singleShot(0, this, SLOT(onAction())); | |
86 | } | |
87 | } | |
88 | @@ -1154,6 +1156,9 @@ | |
89 | sldPos->setMaxValue(player.getLength()); // doesn't work without it ;[ | |
90 | sldPos->setValue(player.getPos()); | |
91 | ||
92 | + if (!player.getRestoring()) | |
93 | + sldVol->setValue(player.getVolume()); | |
94 | + | |
95 | if (!player.running()) | |
96 | { | |
97 | eqAdj = false; | |
98 | @@ -3231,17 +3236,18 @@ | |
99 | ||
100 | void frmMain::restoreVolume() | |
101 | { | |
102 | - const int & vol = player.getVolume(); | |
103 | + const int vol = (player.getVolume() + 5); | |
104 | ||
105 | - if (vol < desiredVolume) | |
106 | + if (vol >= desiredVolume) | |
107 | { | |
108 | - if ((vol + 5) > desiredVolume) | |
109 | - sldVol->setValue(desiredVolume); | |
110 | - else | |
111 | - player.setVolume(vol + 5); | |
112 | + volumeTimer.stop(); | |
113 | + | |
114 | + sldVol->setValue(desiredVolume); | |
115 | + | |
116 | + player.setRestoring(false); | |
117 | } | |
118 | else | |
119 | - volumeTimer.stop(); | |
120 | + player.setVolume(vol); | |
121 | } | |
122 | ||
123 | void frmMain::makeUpPlaylist(int id) | |
124 | --- player.h 2008/09/16 19:41:09 274 | |
125 | +++ player.h 2009/04/21 20:44:39 275 | |
126 | @@ -38,6 +38,7 @@ | |
127 | int getLength() const; | |
128 | int getVolume() const; | |
129 | int getPos() const; | |
130 | + bool getRestoring() const; | |
131 | QString getTrack() const; | |
132 | QStringList getAudioCDContents(const QString & device) const; | |
133 | const xine_t * getXineHandle() const; | |
134 | @@ -49,18 +50,22 @@ | |
135 | void termThread(); | |
136 | void wakeThread(); | |
137 | ||
138 | + void setRestoring(bool); | |
139 | + | |
140 | private: | |
141 | QString xineVer; | |
142 | QString track; | |
143 | bool term; | |
144 | + bool restoring; | |
145 | ||
146 | int volume; | |
147 | int length; | |
148 | int pos; | |
149 | ||
150 | - xine_t * xine; | |
151 | - xine_stream_t * stream; | |
152 | - xine_audio_port_t * ao_port; | |
153 | + xine_t * xine; | |
154 | + xine_stream_t * stream; | |
155 | + xine_audio_port_t * ao_port; | |
156 | + xine_event_queue_t * event_queue; | |
157 | }; | |
158 | ||
159 | #endif | |
160 | --- frmmain.ui.h 2010/12/30 19:27:09 291 | |
161 | +++ frmmain.ui.h 2011/01/01 00:39:30 292 | |
55951cc9 BZ |
162 | @@ -341,6 +341,9 @@ |
163 | ||
164 | alreadyRunning = false; | |
165 | ||
166 | + if (!dir.exists()) | |
167 | + QDir().mkdir(dir.path()); | |
168 | + | |
169 | if (lockFile.exists()) | |
170 | { | |
171 | if (files.isEmpty()) | |
172 | @@ -378,9 +381,6 @@ | |
173 | lockFile.close(); | |
174 | } | |
175 | ||
176 | - if (!dir.exists()) | |
177 | - QDir().mkdir(dir.path()); | |
178 | - | |
179 | http = 0; | |
180 | lyricsErrStr = i18n("No lyrics found"); | |
181 | sldVol->setValue(50); |