summaryrefslogtreecommitdiff
path: root/noncore/multimedia
authorerik <erik>2007-01-31 22:06:07 (UTC)
committer erik <erik>2007-01-31 22:06:07 (UTC)
commit9395cf2a65184e493714c699bb23b02ea31feef5 (patch) (unidiff)
treeea07c026298820559c13ad32e612d51048cee0a9 /noncore/multimedia
parent958e042c5a4d4e38fd1baae50b78a2febfd306ab (diff)
downloadopie-9395cf2a65184e493714c699bb23b02ea31feef5.zip
opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.gz
opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.bz2
I expanded my audit to include any app I could get to compile in i386.
In that expansion a whole new crop of unchecked returns has sprung up. This commit fixes those weeds or should I say potential bugs.
Diffstat (limited to 'noncore/multimedia') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp17
-rw-r--r--noncore/multimedia/opieplayer2/threadutil.cpp11
3 files changed, 16 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 84d28ce..5f281b7 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,189 +1,191 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9 .>+-= 9 .>+-=
10_;:, .> :=|. This program is free software; you can 10_;:, .> :=|. This program is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14- . .-<_> .<> Foundation; either version 2 of the License, 14- . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24: = ...= . :.=- 24: = ...= . :.=-
25-. .:....=;==+<; You should have received a copy of the GNU 25-. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include "lib.h" 35#include "lib.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40 40
41/* QT */ 41/* QT */
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45 45
46/* STD */ 46/* STD */
47#include <assert.h> 47#include <assert.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
51 int width, int height,int bytes ); 51 int width, int height,int bytes );
52typedef void (*vo_scale_cb) (void*, int, int, double, 52typedef void (*vo_scale_cb) (void*, int, int, double,
53 int*, int*, int*, int*, double*, int*, int* ); 53 int*, int*, int*, int*, double*, int*, int* );
54typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*); 54typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*);
55 55
56 56
57extern "C" { 57extern "C" {
58 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb ); 58 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void *, vo_scale_cb, dest_size_cb );
59 int null_is_showing_video( const xine_vo_driver_t* self ); 59 int null_is_showing_video( const xine_vo_driver_t* self );
60 void null_set_show_video( const xine_vo_driver_t* self, int show ); 60 void null_set_show_video( const xine_vo_driver_t* self, int show );
61 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 61 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
62 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 62 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
63} 63}
64 64
65using namespace XINE; 65using namespace XINE;
66 66
67Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 67Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
68{ 68{
69 m_initialized = false; 69 m_initialized = false;
70 m_duringInitialization = false; 70 m_duringInitialization = false;
71 m_video = false; 71 m_video = false;
72 m_wid = widget; 72 m_wid = widget;
73 printf("Lib"); 73 printf("Lib");
74 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 74 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
75 // get the configuration 75 // get the configuration
76 76
77 // not really OO, should be an extra class, later 77 // not really OO, should be an extra class, later
78 if ( !QFile::exists(configPath) ) { 78 if ( !QFile::exists(configPath) ) {
79 QFile f(configPath); 79 QFile f(configPath);
80 f.open(IO_WriteOnly); 80 if (f.open(IO_WriteOnly)) {
81 QTextStream ts( &f ); 81 QTextStream ts( &f );
82 ts << "misc.memcpy_method:glibc\n"; 82 ts << "misc.memcpy_method:glibc\n";
83 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; 83 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n";
84 ts << "codec.ffmpeg_pp_quality:3\n"; 84 ts << "codec.ffmpeg_pp_quality:3\n";
85 ts << "audio.num_buffers:50\n"; 85 ts << "audio.num_buffers:50\n";
86 ts << "audio.size_buffers:4096\n"; 86 ts << "audio.size_buffers:4096\n";
87 ts << "video.num_buffers:20\n"; 87 ts << "video.num_buffers:20\n";
88 ts << "video.size_buffers:4096\n"; 88 ts << "video.size_buffers:4096\n";
89 ts << "audio.out_num_audio_buf:16\n"; 89 ts << "audio.out_num_audio_buf:16\n";
90 ts << "audio.out_size_audio_buf:8096\n"; 90 ts << "audio.out_size_audio_buf:8096\n";
91 ts << "audio.out_size_zero_buf:1024\n"; 91 ts << "audio.out_size_zero_buf:1024\n";
92 ts << "audio.passthrough_offset:0\n"; 92 ts << "audio.passthrough_offset:0\n";
93 f.close(); 93 f.close();
94 } else
95 owarn << "Failed to open " f.name() << oendl;
94 } 96 }
95 97
96 if ( initMode == InitializeImmediately ) { 98 if ( initMode == InitializeImmediately ) {
97 initialize(); 99 initialize();
98 m_initialized = true; 100 m_initialized = true;
99 } 101 }
100 else 102 else
101 start(); 103 start();
102} 104}
103 105
104void Lib::run() 106void Lib::run()
105{ 107{
106 odebug << "Lib::run() started" << oendl; 108 odebug << "Lib::run() started" << oendl;
107 initialize(); 109 initialize();
108 m_initialized = true; 110 m_initialized = true;
109 odebug << "Lib::run() finished" << oendl; 111 odebug << "Lib::run() finished" << oendl;
110} 112}
111 113
112void Lib::initialize() 114void Lib::initialize()
113{ 115{
114 m_duringInitialization = true; 116 m_duringInitialization = true;
115 m_xine = xine_new( ); 117 m_xine = xine_new( );
116 118
117 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 119 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
118 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 120 xine_config_load( m_xine, QFile::encodeName( configPath ) );
119 121
120 xine_init( m_xine ); 122 xine_init( m_xine );
121 123
122 // allocate oss for sound 124 // allocate oss for sound
123 // and fb for framebuffer 125 // and fb for framebuffer
124 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 126 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
125 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, 127 m_videoOutput = ::init_video_out_plugin( m_xine, NULL,
126 xine_display_frame, this, 128 xine_display_frame, this,
127 xine_vo_scale_cb, 129 xine_vo_scale_cb,
128 xine_dest_cb ); 130 xine_dest_cb );
129 131
130 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 132 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
131 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); 133 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
132 134
133 if (m_wid != 0 ) 135 if (m_wid != 0 )
134 setWidget( m_wid ); 136 setWidget( m_wid );
135 137
136 138
137 m_queue = xine_event_new_queue (m_stream); 139 m_queue = xine_event_new_queue (m_stream);
138 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 140 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
139 141
140 m_duringInitialization = false; 142 m_duringInitialization = false;
141} 143}
142 144
143Lib::~Lib() { 145Lib::~Lib() {
144 assert( isRunning() == false ); 146 assert( isRunning() == false );
145 assert( m_initialized ); 147 assert( m_initialized );
146 148
147// free( m_config ); 149// free( m_config );
148 150
149 xine_close( m_stream ); 151 xine_close( m_stream );
150 xine_event_dispose_queue( m_queue ); 152 xine_event_dispose_queue( m_queue );
151 xine_dispose( m_stream ); 153 xine_dispose( m_stream );
152 xine_close_audio_driver(m_xine,m_audioOutput); 154 xine_close_audio_driver(m_xine,m_audioOutput);
153 xine_close_video_driver(m_xine,m_videoOutput); 155 xine_close_video_driver(m_xine,m_videoOutput);
154 xine_exit( m_xine ); 156 xine_exit( m_xine );
155 157
156 /* FIXME either free or delete but valgrind bitches against both */ 158 /* FIXME either free or delete but valgrind bitches against both */
157 //free( m_videoOutput ); 159 //free( m_videoOutput );
158 //delete m_audioOutput; 160 //delete m_audioOutput;
159} 161}
160 162
161void Lib::resize ( const QSize &s ) { 163void Lib::resize ( const QSize &s ) {
162 assert( m_initialized || m_duringInitialization ); 164 assert( m_initialized || m_duringInitialization );
163 165
164 if ( s. width ( ) && s. height ( ) ) 166 if ( s. width ( ) && s. height ( ) )
165 m_videoSize = s; 167 m_videoSize = s;
166} 168}
167 169
168int Lib::majorVersion() { 170int Lib::majorVersion() {
169 int major, minor, sub; 171 int major, minor, sub;
170 xine_get_version ( &major, &minor, &sub ); 172 xine_get_version ( &major, &minor, &sub );
171 return major; 173 return major;
172} 174}
173 175
174int Lib::minorVersion() { 176int Lib::minorVersion() {
175 int major, minor, sub; 177 int major, minor, sub;
176 xine_get_version ( &major, &minor, &sub ); 178 xine_get_version ( &major, &minor, &sub );
177 return minor; 179 return minor;
178} 180}
179 181
180int Lib::subVersion() { 182int Lib::subVersion() {
181 int major, minor, sub; 183 int major, minor, sub;
182 xine_get_version ( &major, &minor, &sub ); 184 xine_get_version ( &major, &minor, &sub );
183 return sub; 185 return sub;
184} 186}
185 187
186int Lib::setfile(const QString& fileName) 188int Lib::setfile(const QString& fileName)
187{ 189{
188 QString str = fileName.stripWhiteSpace(); 190 QString str = fileName.stripWhiteSpace();
189 191
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 790fa09..f2a01d3 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -1,152 +1,145 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "om3u.h" 32#include "om3u.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36using namespace Opie::Core; 36using namespace Opie::Core;
37 37
38//extern PlayListWidget *playList; 38//extern PlayListWidget *playList;
39 39
40Om3u::Om3u( const QString &filePath, int mode) 40Om3u::Om3u( const QString &filePath, int mode)
41 : QStringList (){ 41 : QStringList ()
42{
42odebug << "<<<<<<<new m3u "+filePath << oendl; 43odebug << "<<<<<<<new m3u "+filePath << oendl;
43 f.setName(filePath); 44 f.setName(filePath);
44 f.open(mode); 45 if (!f.open(mode)) {
46 owarn << "Unable to open file " << f.name() << oendl;
47 }
45} 48}
46 49
47Om3u::~Om3u(){} 50Om3u::~Om3u(){}
48 51
49void Om3u::readM3u() { 52void Om3u::readM3u() {
50// odebug << "<<<<<<reading m3u "+f.name() << oendl; 53// odebug << "<<<<<<reading m3u "+f.name() << oendl;
51 QTextStream t(&f); 54 QTextStream t(&f);
52 t.setEncoding(QTextStream::UnicodeUTF8); 55 t.setEncoding(QTextStream::UnicodeUTF8);
53 QString s; 56 QString s;
54 while ( !t.atEnd() ) { 57 while ( !t.atEnd() ) {
55 s=t.readLine(); 58 s=t.readLine();
56// odebug << s << oendl; 59// odebug << s << oendl;
57 if( s.find( "#", 0, TRUE) == -1 ) { 60 if( s.find( "#", 0, TRUE) == -1 ) {
58 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 61 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
59 s = s.right( s.length() -2 ); 62 s = s.right( s.length() -2 );
60 QFileInfo f( s ); 63 QFileInfo f( s );
61 QString name = f.baseName(); 64 QString name = f.baseName();
62 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 65 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
63 s=s.replace( QRegExp( "\\" ), "/" ); 66 s=s.replace( QRegExp( "\\" ), "/" );
64 append(s); 67 append(s);
65// odebug << s << oendl; 68// odebug << s << oendl;
66 } else { // is url 69 } else { // is url
67 QString name; 70 QString name;
68 name = s; 71 name = s;
69 append(name); 72 append(name);
70 } 73 }
71 } 74 }
72 } 75 }
73} 76}
74 77
75void Om3u::readPls() { //it's a pls file 78void Om3u::readPls() { //it's a pls file
76 QTextStream t( &f ); 79 QTextStream t( &f );
77 t.setEncoding(QTextStream::UnicodeUTF8); 80 t.setEncoding(QTextStream::UnicodeUTF8);
78 QString s; 81 QString s;
79 while ( !t.atEnd() ) { 82 while ( !t.atEnd() ) {
80 s = t.readLine(); 83 s = t.readLine();
81 if( s.left(4) == "File" ) { 84 if( s.left(4) == "File" ) {
82 s = s.right( s.length() - s.find("=",0,true)-1 ); 85 s = s.right( s.length() - s.find("=",0,true)-1 );
83 s = s.stripWhiteSpace(); 86 s = s.stripWhiteSpace();
84 s.replace( QRegExp( "%20" )," "); 87 s.replace( QRegExp( "%20" )," ");
85// odebug << "adding " + s + " to playlist" << oendl; 88// odebug << "adding " + s + " to playlist" << oendl;
86 // numberofentries=2
87 // File1=http
88 // Title
89 // Length
90 // Version
91 // File2=http
92 s = s.replace( QRegExp( "\\" ), "/" ); 89 s = s.replace( QRegExp( "\\" ), "/" );
93 QFileInfo f( s ); 90 QFileInfo f( s );
94 QString name = f.baseName(); 91 QString name = f.baseName();
95 if( name.left( 4 ) == "http" ) { 92 if( name.left( 4 ) == "http" ) {
96 name = s.right( s.length() - 7); 93 name = s.right( s.length() - 7);
97 } else { 94 } else {
98 name = s; 95 name = s;
99 } 96 }
100 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 97 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
101 if( s.at( s.length() - 4) == '.') // if this is probably a file 98 if( s.at( s.length() - 4) == '.') // if this is probably a file
102 append(s); 99 append(s);
103 else { //if its a url 100 else { //if its a url
104// if( name.right( 1 ).find( '/' ) == -1) {
105// s += "/";
106// }
107 append(s); 101 append(s);
108 } 102 }
109 } 103 }
110 } 104 }
111} 105}
112 106
113void Om3u::write() { //writes list to m3u file 107void Om3u::write() { //writes list to m3u file
114 QString list; 108 QString list;
115 QTextStream t(&f); 109 QTextStream t(&f);
116 t.setEncoding(QTextStream::UnicodeUTF8); 110 t.setEncoding(QTextStream::UnicodeUTF8);
117 if(count()>0) { 111 if(count()>0) {
118 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 112 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
119// odebug << *it << oendl; 113// odebug << *it << oendl;
120 t << *it << "\n"; 114 t << *it << "\n";
121 } 115 }
122 } 116 }
123// f.close();
124} 117}
125 118
126void Om3u::add(const QString &filePath) { //adds to m3u file 119void Om3u::add(const QString &filePath) { //adds to m3u file
127 append(filePath); 120 append(filePath);
128} 121}
129 122
130void Om3u::remove(const QString &filePath) { //removes from m3u list 123void Om3u::remove(const QString &filePath) { //removes from m3u list
131 QString list, currentFile; 124 QString list, currentFile;
132 if(count()>0) { 125 if(count()>0) {
133 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 126 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
134 currentFile=*it; 127 currentFile=*it;
135 // odebug << *it << oendl; 128 // odebug << *it << oendl;
136 129
137 if( filePath != currentFile) 130 if( filePath != currentFile)
138 list += currentFile+"\n"; 131 list += currentFile+"\n";
139 } 132 }
140 f.writeBlock( list, list.length() ); 133 f.writeBlock( list, list.length() );
141 } 134 }
142} 135}
143 136
144void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file 137void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
145 f.close(); 138 f.close();
146 f.remove(); 139 f.remove();
147 140
148} 141}
149 142
150void Om3u::close() { //closes m3u file 143void Om3u::close() { //closes m3u file
151 f.close(); 144 f.close();
152} 145}
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp
index b5cac61..5fc8a0b 100644
--- a/noncore/multimedia/opieplayer2/threadutil.cpp
+++ b/noncore/multimedia/opieplayer2/threadutil.cpp
@@ -140,198 +140,203 @@ struct Thread::Data
140 void run() { thr->run(); } 140 void run() { thr->run(); }
141}; 141};
142 142
143extern "C" 143extern "C"
144{ 144{
145 145
146static void terminate_thread( void *arg ) 146static void terminate_thread( void *arg )
147{ 147{
148 Thread::Data *data = ( Thread::Data* )arg; 148 Thread::Data *data = ( Thread::Data* )arg;
149 149
150 assert( data ); 150 assert( data );
151 151
152 AutoLock locker( data->guard ); 152 AutoLock locker( data->guard );
153 data->isRunning = false; 153 data->isRunning = false;
154 data->finishCondition.wakeAll(); 154 data->finishCondition.wakeAll();
155} 155}
156 156
157static void *start_thread( void *arg ) 157static void *start_thread( void *arg )
158{ 158{
159 Thread::Data *data = ( Thread::Data* )arg; 159 Thread::Data *data = ( Thread::Data* )arg;
160 160
161 pthread_cleanup_push( terminate_thread, data ); 161 pthread_cleanup_push( terminate_thread, data );
162 162
163 data->isRunning = true; 163 data->isRunning = true;
164 data->run(); 164 data->run();
165 165
166 pthread_cleanup_pop( true ); 166 pthread_cleanup_pop( true );
167 167
168 Thread::exit(); 168 Thread::exit();
169 return 0; // never reached 169 return 0; // never reached
170} 170}
171 171
172} 172}
173 173
174Thread::Thread() 174Thread::Thread()
175 : d( new Data ) 175 : d( new Data )
176{ 176{
177 d->thr = this; 177 d->thr = this;
178} 178}
179 179
180Thread::~Thread() 180Thread::~Thread()
181{ 181{
182 assert( d->isRunning == false ); 182 assert( d->isRunning == false );
183 delete d; 183 delete d;
184} 184}
185 185
186void Thread::start() 186void Thread::start()
187{ 187{
188 AutoLock lock( d->guard ); 188 AutoLock lock( d->guard );
189 189
190 if ( d->isRunning ) { 190 if ( d->isRunning ) {
191 odebug << "ThreadUtil::Thread::start() called for running thread." << oendl; 191 odebug << "ThreadUtil::Thread::start() called for running thread." << oendl;
192 return; 192 return;
193 } 193 }
194 194
195 pthread_attr_t attributes; 195 pthread_attr_t attributes;
196 pthread_attr_init( &attributes ); 196 pthread_attr_init( &attributes );
197 pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM ); 197 pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM );
198 int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d ); 198 int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d );
199 if ( err != 0 ) { 199 if ( err != 0 ) {
200 odebug << "ThreadUtil::Thread::start() : can't create thread: " << strerror( err ) << "" << oendl; 200 odebug << "ThreadUtil::Thread::start() : can't create thread: " << strerror( err ) << "" << oendl;
201 pthread_attr_destroy( &attributes ); 201 pthread_attr_destroy( &attributes );
202 return; 202 return;
203 } 203 }
204 pthread_attr_destroy( &attributes ); 204 pthread_attr_destroy( &attributes );
205} 205}
206 206
207void Thread::terminate() 207void Thread::terminate()
208{ 208{
209 AutoLock lock( d->guard ); 209 AutoLock lock( d->guard );
210 if ( !d->isRunning ) 210 if ( !d->isRunning )
211 return; 211 return;
212 212
213 pthread_cancel( d->self ); 213 pthread_cancel( d->self );
214} 214}
215 215
216bool Thread::wait() 216bool Thread::wait()
217{ 217{
218 AutoLock lock( d->guard ); 218 AutoLock lock( d->guard );
219 if ( !d->isRunning ) 219 if ( !d->isRunning )
220 return true; 220 return true;
221 221
222 return d->finishCondition.wait( d->guard ); 222 return d->finishCondition.wait( d->guard );
223} 223}
224 224
225bool Thread::isRunning() const 225bool Thread::isRunning() const
226{ 226{
227 AutoLock lock( d->guard ); 227 AutoLock lock( d->guard );
228 return d->isRunning; 228 return d->isRunning;
229} 229}
230 230
231void Thread::exit() 231void Thread::exit()
232{ 232{
233 pthread_exit( 0 ); 233 pthread_exit( 0 );
234} 234}
235 235
236OnewayNotifier::OnewayNotifier() 236OnewayNotifier::OnewayNotifier() :
237 m_readFd(-1),
238 m_writeFd(-1)
237{ 239{
238 int fds[ 2 ]; 240 int fds[ 2 ] = { -1, -1 };
239 pipe( fds ); 241 if (pipe( fds ) == 0) {
240 m_readFd = fds[ 0 ]; 242 m_readFd = fds[ 0 ];
241 m_writeFd = fds[ 1 ]; 243 m_writeFd = fds[ 1 ];
244 } else {
245 owarn << "Call to pipe() failed" << oendl;
246 }
242 247
243 m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); 248 m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read );
244 connect( m_notifier, SIGNAL( activated(int) ), 249 connect( m_notifier, SIGNAL( activated(int) ),
245 this, SLOT( wakeUp() ) ); 250 this, SLOT( wakeUp() ) );
246} 251}
247 252
248OnewayNotifier::~OnewayNotifier() 253OnewayNotifier::~OnewayNotifier()
249{ 254{
250 delete m_notifier; 255 delete m_notifier;
251 256
252 ::close( m_readFd ); 257 ::close( m_readFd );
253 ::close( m_writeFd ); 258 ::close( m_writeFd );
254} 259}
255 260
256void OnewayNotifier::notify() 261void OnewayNotifier::notify()
257{ 262{
258 const char c = 42; 263 const char c = 42;
259 ::write( m_writeFd, &c, 1 ); 264 ::write( m_writeFd, &c, 1 );
260} 265}
261 266
262void OnewayNotifier::wakeUp() 267void OnewayNotifier::wakeUp()
263{ 268{
264 char c = 0; 269 char c = 0;
265 270
266 if ( ::read( m_readFd, &c, 1 ) != 1 ) 271 if ( ::read( m_readFd, &c, 1 ) != 1 )
267 return; 272 return;
268 273
269 emit awake(); 274 emit awake();
270} 275}
271 276
272ChannelMessage::ChannelMessage( int type, int data, const char* msg ) 277ChannelMessage::ChannelMessage( int type, int data, const char* msg )
273 : m_type( type ), m_data( data ), m_msg( msg ), 278 : m_type( type ), m_data( data ), m_msg( msg ),
274 m_isCall( false ), m_replied( false ), m_inEventHandler( false ) 279 m_isCall( false ), m_replied( false ), m_inEventHandler( false )
275{} 280{}
276 281
277ChannelMessage::~ChannelMessage() 282ChannelMessage::~ChannelMessage()
278{ 283{
279 if ( m_guard.isLocked() ) 284 if ( m_guard.isLocked() )
280 m_guard.unlock(); 285 m_guard.unlock();
281} 286}
282 287
283void ChannelMessage::reply() 288void ChannelMessage::reply()
284{ 289{
285 if ( !m_isCall ) 290 if ( !m_isCall )
286 { 291 {
287 odebug << "ChannelMessage::reply() - can't reply oneway message!" << oendl; 292 odebug << "ChannelMessage::reply() - can't reply oneway message!" << oendl;
288 return; 293 return;
289 } 294 }
290 295
291 if ( m_inEventHandler ) 296 if ( m_inEventHandler )
292 { 297 {
293 m_replied = true; 298 m_replied = true;
294 return; 299 return;
295 } 300 }
296 301
297 m_condition.wakeOne(); 302 m_condition.wakeOne();
298 m_guard.unlock(); 303 m_guard.unlock();
299} 304}
300 305
301struct Channel::Private 306struct Channel::Private
302{ 307{
303 Private() 308 Private()
304 { 309 {
305 ownerThread = pthread_self(); 310 ownerThread = pthread_self();
306 } 311 }
307 312
308 pthread_t ownerThread; 313 pthread_t ownerThread;
309}; 314};
310 315
311Channel::Channel( QObject *parent, const char *name ) 316Channel::Channel( QObject *parent, const char *name )
312 : QObject( parent, name ), d( new Private ) 317 : QObject( parent, name ), d( new Private )
313{ 318{
314 connect( &m_notifier, SIGNAL( awake() ), 319 connect( &m_notifier, SIGNAL( awake() ),
315 this, SLOT( deliver() ) ); 320 this, SLOT( deliver() ) );
316} 321}
317 322
318Channel::~Channel() 323Channel::~Channel()
319{ 324{
320 delete d; 325 delete d;
321} 326}
322 327
323void Channel::send( ChannelMessage *message, SendType type ) 328void Channel::send( ChannelMessage *message, SendType type )
324{ 329{
325 if ( type == WaitForReply ) 330 if ( type == WaitForReply )
326 { 331 {
327 message->m_guard.lock(); 332 message->m_guard.lock();
328 message->m_isCall = true; 333 message->m_isCall = true;
329 } 334 }
330 335
331 m_pendingMessagesGuard.lock(); 336 m_pendingMessagesGuard.lock();
332 m_pendingMessages << MsgEnvelope( type, message ); 337 m_pendingMessages << MsgEnvelope( type, message );
333 m_pendingMessagesGuard.unlock(); 338 m_pendingMessagesGuard.unlock();
334 339
335 if ( d->ownerThread == pthread_self() ) { 340 if ( d->ownerThread == pthread_self() ) {
336 assert( type != WaitForReply ); 341 assert( type != WaitForReply );
337 342