summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index f1b9773..6ed4cea 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -110,48 +110,49 @@ Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
110void Lib::run() 110void Lib::run()
111{ 111{
112 odebug << "Lib::run() started" << oendl; 112 odebug << "Lib::run() started" << oendl;
113 initialize(); 113 initialize();
114 m_initialized = true; 114 m_initialized = true;
115 odebug << "Lib::run() finished" << oendl; 115 odebug << "Lib::run() finished" << oendl;
116} 116}
117 117
118void Lib::initialize() 118void Lib::initialize()
119{ 119{
120 m_duringInitialization = true; 120 m_duringInitialization = true;
121 m_xine = xine_new( ); 121 m_xine = xine_new( );
122 122
123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
124 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 124 xine_config_load( m_xine, QFile::encodeName( configPath ) );
125 125
126 xine_init( m_xine ); 126 xine_init( m_xine );
127 127
128 // allocate oss for sound 128 // allocate oss for sound
129 // and fb for framebuffer 129 // and fb for framebuffer
130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
132 132
133 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 133 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
134 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
134 135
135 if (m_wid != 0 ) 136 if (m_wid != 0 )
136 setWidget( m_wid ); 137 setWidget( m_wid );
137 138
138 139
139 m_queue = xine_event_new_queue (m_stream); 140 m_queue = xine_event_new_queue (m_stream);
140 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 141 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
141 142
142 ::null_preload_decoders( m_stream ); 143 ::null_preload_decoders( m_stream );
143 144
144 m_duringInitialization = false; 145 m_duringInitialization = false;
145} 146}
146 147
147Lib::~Lib() { 148Lib::~Lib() {
148 assert( isRunning() == false ); 149 assert( isRunning() == false );
149 assert( m_initialized ); 150 assert( m_initialized );
150 151
151// free( m_config ); 152// free( m_config );
152 153
153 xine_close( m_stream ); 154 xine_close( m_stream );
154 xine_event_dispose_queue( m_queue ); 155 xine_event_dispose_queue( m_queue );
155 xine_dispose( m_stream ); 156 xine_dispose( m_stream );
156 xine_exit( m_xine ); 157 xine_exit( m_xine );
157 158
@@ -181,54 +182,62 @@ int Lib::minorVersion() {
181 return minor; 182 return minor;
182} 183}
183 184
184int Lib::subVersion() { 185int Lib::subVersion() {
185 int major, minor, sub; 186 int major, minor, sub;
186 xine_get_version ( &major, &minor, &sub ); 187 xine_get_version ( &major, &minor, &sub );
187 return sub; 188 return sub;
188} 189}
189 190
190int Lib::play( const QString& fileName, int startPos, int start_time ) { 191int Lib::play( const QString& fileName, int startPos, int start_time ) {
191 assert( m_initialized ); 192 assert( m_initialized );
192 193
193 QString str = fileName.stripWhiteSpace(); 194 QString str = fileName.stripWhiteSpace();
194 195
195 196
196 if ( !xine_open( m_stream, str.utf8().data() ) ) { 197 if ( !xine_open( m_stream, str.utf8().data() ) ) {
197 return 0; 198 return 0;
198 } 199 }
199 return xine_play( m_stream, startPos, start_time); 200 return xine_play( m_stream, startPos, start_time);
200} 201}
201 202
202void Lib::stop() { 203void Lib::stop() {
203 assert( m_initialized ); 204 assert( m_initialized );
204 xine_stop( m_stream ); 205 xine_stop( m_stream );
206 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
205} 207}
206 208
207void Lib::pause( bool toggle ) { 209void Lib::pause( bool toggle ) {
208 assert( m_initialized ); 210 assert( m_initialized );
209 211
210 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 212 if ( toggle ) {
213 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
214 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
215 }
216
217 else {
218 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL );
219 }
211} 220}
212 221
213int Lib::speed() const { 222int Lib::speed() const {
214 assert( m_initialized ); 223 assert( m_initialized );
215 224
216 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 225 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
217} 226}
218 227
219void Lib::setSpeed( int speed ) { 228void Lib::setSpeed( int speed ) {
220 assert( m_initialized ); 229 assert( m_initialized );
221 230
222 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 231 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
223} 232}
224 233
225int Lib::status() const { 234int Lib::status() const {
226 assert( m_initialized ); 235 assert( m_initialized );
227 236
228 return xine_get_status( m_stream ); 237 return xine_get_status( m_stream );
229} 238}
230 239
231int Lib::currentPosition() const { 240int Lib::currentPosition() const {
232 assert( m_initialized ); 241 assert( m_initialized );
233 242
234 int pos, time, length; 243 int pos, time, length;
@@ -261,49 +270,59 @@ int Lib::length() const {
261 if (iRetVal) 270 if (iRetVal)
262 {/* if the function didn't return 0, then pos, time and length are valid.*/ 271 {/* if the function didn't return 0, then pos, time and length are valid.*/
263 return length/1000; 272 return length/1000;
264 } 273 }
265 /*don't poll too much*/ 274 /*don't poll too much*/
266 usleep(100000); 275 usleep(100000);
267 iTestLoop++; 276 iTestLoop++;
268 } 277 }
269 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any 278 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
270valid stream, then return -1 (this value could be used to make the stream 279valid stream, then return -1 (this value could be used to make the stream
271unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 280unseekable, but it should never occur!! Mr. Murphy ? :) ) */
272 281
273 return -1; 282 return -1;
274} 283}
275 284
276bool Lib::isSeekable() const { 285bool Lib::isSeekable() const {
277 assert( m_initialized ); 286 assert( m_initialized );
278 287
279 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 288 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
280} 289}
281 290
282void Lib::seekTo( int time ) { 291void Lib::seekTo( int time ) {
283 assert( m_initialized ); 292 assert( m_initialized );
284 293
285 xine_play( m_stream, 0, time*1000 ); 294 odebug << "Seeking to second " << time << oendl;
295 //Keep it paused if it was in that state
296 if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) {
297 xine_play( m_stream, 0, time*1000 );
298 }
299
300 else {
301 xine_play( m_stream, 0, time*1000 );
302 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
303 }
304
286} 305}
287 306
288 307
289Frame Lib::currentFrame() const { 308Frame Lib::currentFrame() const {
290 assert( m_initialized ); 309 assert( m_initialized );
291 310
292 Frame frame; 311 Frame frame;
293 return frame; 312 return frame;
294}; 313};
295 314
296QString Lib::metaInfo( int number) const { 315QString Lib::metaInfo( int number) const {
297 assert( m_initialized ); 316 assert( m_initialized );
298 317
299 return xine_get_meta_info( m_stream, number ); 318 return xine_get_meta_info( m_stream, number );
300} 319}
301 320
302int Lib::error() const { 321int Lib::error() const {
303 assert( m_initialized ); 322 assert( m_initialized );
304 323
305 return xine_get_error( m_stream ); 324 return xine_get_error( m_stream );
306}; 325};
307 326
308void Lib::ensureInitialized() 327void Lib::ensureInitialized()
309{ 328{