summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 20:27:19 (UTC)
committer simon <simon>2002-12-08 20:27:19 (UTC)
commitec91b042d8312f83027beb357448fe02a13e8923 (patch) (unidiff)
treec61b89e7fc7f22bb1dfaa19f2597c5bdae903572
parentce313e53a56591fd883348f5e265606865fdcb50 (diff)
downloadopie-ec91b042d8312f83027beb357448fe02a13e8923.zip
opie-ec91b042d8312f83027beb357448fe02a13e8923.tar.gz
opie-ec91b042d8312f83027beb357448fe02a13e8923.tar.bz2
- properly shut down xine in the destructor. fixes crashes when switching
skins
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 4a96408..1b5fd51 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -75,96 +75,103 @@ Lib::Lib( XineVideoWidget* widget ) {
75 printf("Lib"); 75 printf("Lib");
76 QCString str( getenv("HOME") ); 76 QCString str( getenv("HOME") );
77 str += "/Settings/opiexine.cf"; 77 str += "/Settings/opiexine.cf";
78 // get the configuration 78 // get the configuration
79 79
80 // not really OO, should be an extra class, later 80 // not really OO, should be an extra class, later
81 if ( !QFile(str).exists() ) { 81 if ( !QFile(str).exists() ) {
82 QFile f(str); 82 QFile f(str);
83 f.open(IO_WriteOnly); 83 f.open(IO_WriteOnly);
84 QTextStream ts( &f ); 84 QTextStream ts( &f );
85 ts << "misc.memcpy_method:glibc\n"; 85 ts << "misc.memcpy_method:glibc\n";
86 f.close(); 86 f.close();
87 } 87 }
88 88
89 m_xine = xine_new( ); 89 m_xine = xine_new( );
90 90
91 xine_config_load( m_xine, str.data() ); 91 xine_config_load( m_xine, str.data() );
92 92
93 xine_init( m_xine ); 93 xine_init( m_xine );
94 94
95 // allocate oss for sound 95 // allocate oss for sound
96 // and fb for framebuffer 96 // and fb for framebuffer
97 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 97 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
98 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 98 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
99 99
100 100
101//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 101//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
102 102
103 103
104// null_display_handler( m_videoOutput, xine_display_frame, this ); 104// null_display_handler( m_videoOutput, xine_display_frame, this );
105 105
106 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 106 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
107 107
108 if (m_wid != 0 ) { 108 if (m_wid != 0 ) {
109 printf( "!0\n" ); 109 printf( "!0\n" );
110 resize ( m_wid-> size ( ) ); 110 resize ( m_wid-> size ( ) );
111 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 111 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
112 112
113 m_wid->repaint(); 113 m_wid->repaint();
114 } 114 }
115 115
116 m_queue = xine_event_new_queue (m_stream); 116 m_queue = xine_event_new_queue (m_stream);
117 117
118 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 118 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
119} 119}
120 120
121Lib::~Lib() { 121Lib::~Lib() {
122// free( m_config ); 122// free( m_config );
123
124 xine_close( m_stream );
125
126 xine_event_dispose_queue( m_queue );
127
128 xine_dispose( m_stream );
129
123 xine_exit( m_xine ); 130 xine_exit( m_xine );
124 /* FIXME either free or delete but valgrind bitches against both */ 131 /* FIXME either free or delete but valgrind bitches against both */
125 //free( m_videoOutput ); 132 //free( m_videoOutput );
126 //delete m_audioOutput; 133 //delete m_audioOutput;
127} 134}
128 135
129void Lib::resize ( const QSize &s ) { 136void Lib::resize ( const QSize &s ) {
130 if ( s. width ( ) && s. height ( ) ) { 137 if ( s. width ( ) && s. height ( ) ) {
131 ::null_set_gui_width( m_videoOutput, s. width() ); 138 ::null_set_gui_width( m_videoOutput, s. width() );
132 ::null_set_gui_height( m_videoOutput, s. height() ); 139 ::null_set_gui_height( m_videoOutput, s. height() );
133 } 140 }
134} 141}
135 142
136int Lib::majorVersion() { 143int Lib::majorVersion() {
137 int major, minor, sub; 144 int major, minor, sub;
138 xine_get_version ( &major, &minor, &sub ); 145 xine_get_version ( &major, &minor, &sub );
139 return major; 146 return major;
140} 147}
141 148
142int Lib::minorVersion() { 149int Lib::minorVersion() {
143 int major, minor, sub; 150 int major, minor, sub;
144 xine_get_version ( &major, &minor, &sub ); 151 xine_get_version ( &major, &minor, &sub );
145 return minor; 152 return minor;
146} 153}
147 154
148int Lib::subVersion() { 155int Lib::subVersion() {
149 int major, minor, sub; 156 int major, minor, sub;
150 xine_get_version ( &major, &minor, &sub ); 157 xine_get_version ( &major, &minor, &sub );
151 return sub; 158 return sub;
152} 159}
153 160
154int Lib::play( const QString& fileName, int startPos, int start_time ) { 161int Lib::play( const QString& fileName, int startPos, int start_time ) {
155 QString str = fileName.stripWhiteSpace(); 162 QString str = fileName.stripWhiteSpace();
156 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 163 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
157 return 0; 164 return 0;
158 } 165 }
159 return xine_play( m_stream, startPos, start_time); 166 return xine_play( m_stream, startPos, start_time);
160} 167}
161 168
162void Lib::stop() { 169void Lib::stop() {
163 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 170 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
164 xine_stop( m_stream ); 171 xine_stop( m_stream );
165} 172}
166 173
167void Lib::pause() { 174void Lib::pause() {
168 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 175 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
169} 176}
170 177