More simplifications.
[SDL.s60v3.git] / src / audio / symbian / streamplayer.h
bloba0ac92d1257b76f33b9f944c5cf407cd5a9723da
1 #ifndef STREAMPLAYER_H
2 #define STREAMPLAYER_H
4 #include <mdaaudiooutputstream.h>
6 const int KSilenceBuffer = 1024;
7 const int KMaxVolume = 256;
9 class MStreamObs
11 public:
12 enum
14 EInit,
15 EPlay,
16 EWrite,
17 EClose,
19 virtual void Complete(int aState, int aError) = 0;
22 class MStreamProvider
24 public:
25 virtual TPtrC8 Data() = 0;
28 class CStreamPlayer : public CBase, public MMdaAudioOutputStreamCallback
30 public:
31 CStreamPlayer(MStreamProvider& aProvider, MStreamObs& aObs);
32 ~CStreamPlayer();
34 static int ClosestSupportedRate(int aRate);
36 int OpenStream(int aRate, int aChannels, TUint32 aType = KMMFFourCCCodePCM16);
38 void SetVolume(int aNew);
39 int Volume() const { return iVolume; }
41 void Stop();
42 void Start();
43 void Open();
44 void Close();
46 bool Playing() const { return (iState & EInited) && (iState & EStarted); }
47 bool Closed() const { return !(iState & EInited) && !(iState & EDied); }
49 private:
50 void MaoscOpenComplete(int aError);
51 void MaoscBufferCopied(int aError, const TDesC8& aBuffer);
52 void MaoscPlayComplete(int aError);
54 void Request();
56 MStreamProvider& iProvider;
57 MStreamObs& iObs;
58 int iVolume;
60 CMdaAudioOutputStream* iStream;
62 int iRate;
63 int iChannels;
64 TUint32 iType;
66 enum
68 ENone = 0,
69 EInited = 0x1,
70 EStarted = 0x2,
71 EStopped = 0x4,
72 EVolumeChange = 0x8,
73 EDied = 0x10
76 int iState;
77 TBuf8<KSilenceBuffer> iSilence;
78 TPtrC8 iPtr;
81 #endif