source: trunk/src/3rdparty/phonon/gstreamer/streamreader.cpp

Last change on this file was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 1.5 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "streamreader.h"
19#include <QtCore/QMutex>
20#include <phonon/streaminterface.h>
21
22QT_BEGIN_NAMESPACE
23#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
24namespace Phonon
25{
26namespace Gstreamer
27{
28
29bool StreamReader::read(quint64 pos, int length, char * buffer)
30{
31 if (currentPos() - currentBufferSize() != pos) {
32 if (!streamSeekable())
33 return false;
34 setCurrentPos(pos);
35 }
36
37 while (currentBufferSize() < length) {
38 int oldSize = currentBufferSize();
39 needData();
40 if (oldSize == currentBufferSize())
41 return false; // We didn't get any data
42 }
43
44 qMemCopy(buffer, m_buffer.data(), length);
45 //truncate the buffer
46 m_buffer = m_buffer.mid(pos);
47 return true;
48}
49
50}
51}
52#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
53
54QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.