~schumski-deactivatedaccount-deactivatedaccount/k3b/master

« back to all changes in this revision

Viewing changes to libk3b/projects/k3bpipebuffer.cpp

  • Committer: Sebastian Trueg
  • Date: 2009-02-22 22:39:42 UTC
  • Revision ID: git-v1:6dd604da258355f5620f2f59e0ddb7c52e625553
I finally did it: I moved all K3b classes into the K3b namespace. Now this might sound like completely useless (and it actually is, too)
but I like it better this way and it also forced me to look at nearly each source file to fix the things that my crude scripting skills
did not catch properly.
And on the way I also cleaned up the code, used QFlags a few more times and introduced some d-pointers.

svn path=/trunk/extragear/multimedia/k3b/; revision=930262

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
//
34
34
 
35
35
 
36
 
class K3bPipeBuffer::Private
 
36
class K3b::PipeBuffer::Private
37
37
{
38
38
public:
39
39
    Private()
51
51
        if( inFd == -1 ) {
52
52
            if( ::socketpair(AF_UNIX, SOCK_STREAM, 0, inFdPair) ) {
53
53
                //      if( ::pipe( inFdPair ) ) {
54
 
                kDebug() << "(K3bPipeBuffer::WorkThread) unable to create socketpair";
 
54
                kDebug() << "(K3b::PipeBuffer::WorkThread) unable to create socketpair";
55
55
                inFdPair[0] = inFdPair[1] = -1;
56
56
                return false;
57
57
            }
78
78
};
79
79
 
80
80
 
81
 
K3bPipeBuffer::K3bPipeBuffer( K3bJobHandler* jh, QObject* parent )
82
 
    : K3bThreadJob( jh, parent ),
 
81
K3b::PipeBuffer::PipeBuffer( K3b::JobHandler* jh, QObject* parent )
 
82
    : K3b::ThreadJob( jh, parent ),
83
83
      d( new Private() )
84
84
{
85
85
}
86
86
 
87
87
 
88
 
K3bPipeBuffer::~K3bPipeBuffer()
 
88
K3b::PipeBuffer::~PipeBuffer()
89
89
{
90
90
    delete d;
91
91
}
92
92
 
93
93
 
94
 
void K3bPipeBuffer::start()
 
94
void K3b::PipeBuffer::start()
95
95
{
96
96
    //
97
97
    // Create the socketpair in the gui thread to be sure it's available after
100
100
    if( !d->initFds() )
101
101
        jobFinished(false);
102
102
    else
103
 
        K3bThreadJob::start();
 
103
        K3b::ThreadJob::start();
104
104
}
105
105
 
106
106
 
107
 
void K3bPipeBuffer::setBufferSize( int mb )
 
107
void K3b::PipeBuffer::setBufferSize( int mb )
108
108
{
109
109
    d->bufSize = mb * 1024 * 1024;
110
110
}
111
111
 
112
112
 
113
 
void K3bPipeBuffer::readFromFd( int fd )
 
113
void K3b::PipeBuffer::readFromFd( int fd )
114
114
{
115
115
    d->inFd = fd;
116
116
}
117
117
 
118
118
 
119
 
void K3bPipeBuffer::writeToFd( int fd )
 
119
void K3b::PipeBuffer::writeToFd( int fd )
120
120
{
121
121
    d->outFd = fd;
122
122
}
123
123
 
124
124
 
125
 
int K3bPipeBuffer::inFd() const
 
125
int K3b::PipeBuffer::inFd() const
126
126
{
127
127
    if( d->inFd == -1 )
128
128
        return d->inFdPair[1];
130
130
        return d->inFd;
131
131
}
132
132
 
133
 
bool K3bPipeBuffer::run()
 
133
bool K3b::PipeBuffer::run()
134
134
{
135
135
    int usedInFd = -1;
136
136
    if( d->inFd > 0 )
138
138
    else
139
139
        usedInFd = d->inFdPair[0];
140
140
 
141
 
    kDebug() << "(K3bPipeBuffer::WorkThread) reading from " << usedInFd
 
141
    kDebug() << "(K3b::PipeBuffer::WorkThread) reading from " << usedInFd
142
142
             << " and writing to " << d->outFd << endl;
143
 
    kDebug() << "(K3bPipeBuffer::WorkThread) using buffer size of " << d->bufSize;
 
143
    kDebug() << "(K3b::PipeBuffer::WorkThread) using buffer size of " << d->bufSize;
144
144
 
145
145
    // start the buffering
146
146
    unsigned int bufPos = 0;
189
189
 
190
190
                if( ret < 0 ) {
191
191
                    if( (errno != EINTR) && (errno != EAGAIN) ) {
192
 
                        kDebug() << "(K3bPipeBuffer::WorkThread) error while writing to " << d->outFd;
 
192
                        kDebug() << "(K3b::PipeBuffer::WorkThread) error while writing to " << d->outFd;
193
193
                        error = true;
194
194
                    }
195
195
                }
220
220
                ret = ::read( usedInFd, &d->buffer[readPos], maxLen );
221
221
                if( ret < 0 ) {
222
222
                    if( (errno != EINTR) && (errno != EAGAIN) ) {
223
 
                        kDebug() << "(K3bPipeBuffer::WorkThread) error while reading from " << usedInFd;
 
223
                        kDebug() << "(K3b::PipeBuffer::WorkThread) error while reading from " << usedInFd;
224
224
                        error = true;
225
225
                    }
226
226
                }
227
227
                else if( ret == 0 ) {
228
 
                    kDebug() << "(K3bPipeBuffer::WorkThread) end of input.";
 
228
                    kDebug() << "(K3b::PipeBuffer::WorkThread) end of input.";
229
229
                    eof = true;
230
230
                }
231
231
                else {
246
246
        }
247
247
        else if( !canceled() ) {
248
248
            error = true;
249
 
            kDebug() << "(K3bPipeBuffer::WorkThread) select: " << ::strerror(errno);
 
249
            kDebug() << "(K3b::PipeBuffer::WorkThread) select: " << ::strerror(errno);
250
250
        }
251
251
    }
252
252