|
1 /* This file is part of the KDE project. |
|
2 |
|
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
|
5 This library is free software: you can redistribute it and/or modify |
|
6 it under the terms of the GNU Lesser General Public License as published by |
|
7 the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU Lesser General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Lesser General Public License |
|
15 along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 */ |
|
17 |
|
18 #ifndef PHONON_QASYNCREADER_H |
|
19 #define PHONON_QASYNCREADER_H |
|
20 |
|
21 #include <QtCore/QWaitCondition> |
|
22 #include <QtCore/QQueue> |
|
23 #include <QtCore/QMutex> |
|
24 |
|
25 #include "qpin.h" |
|
26 |
|
27 QT_BEGIN_NAMESPACE |
|
28 |
|
29 namespace Phonon |
|
30 { |
|
31 namespace DS9 |
|
32 { |
|
33 //his class reads asynchronously from a QIODevice |
|
34 class QAsyncReader : public QPin, public IAsyncReader |
|
35 { |
|
36 public: |
|
37 QAsyncReader(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &mediaTypes); |
|
38 ~QAsyncReader(); |
|
39 |
|
40 //reimplementation from IUnknown |
|
41 STDMETHODIMP QueryInterface(REFIID iid, void** out); |
|
42 STDMETHODIMP_(ULONG) AddRef(); |
|
43 STDMETHODIMP_(ULONG) Release(); |
|
44 |
|
45 //reimplementation from IAsyncReader |
|
46 STDMETHODIMP RequestAllocator(IMemAllocator *,ALLOCATOR_PROPERTIES *,IMemAllocator **); |
|
47 STDMETHODIMP Request(IMediaSample *,DWORD_PTR); |
|
48 STDMETHODIMP WaitForNext(DWORD,IMediaSample **,DWORD_PTR *); |
|
49 STDMETHODIMP SyncReadAligned(IMediaSample *); |
|
50 STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *); |
|
51 STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; |
|
52 STDMETHODIMP BeginFlush(); |
|
53 STDMETHODIMP EndFlush(); |
|
54 |
|
55 protected: |
|
56 STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *); |
|
57 virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0; |
|
58 |
|
59 private: |
|
60 struct AsyncRequest |
|
61 { |
|
62 AsyncRequest(IMediaSample *s = 0, DWORD_PTR u = 0) : sample(s), user(u) {} |
|
63 IMediaSample *sample; |
|
64 DWORD_PTR user; |
|
65 }; |
|
66 |
|
67 QQueue<AsyncRequest> m_requestQueue; |
|
68 QWaitCondition m_requestWait; |
|
69 }; |
|
70 } |
|
71 } |
|
72 |
|
73 QT_END_NAMESPACE |
|
74 |
|
75 #endif |