aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/audio/symbian/streamplayer.h
blob: 8c6e74f9200b920a71da58598596feda1eeb5be7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef STREAMPLAYER_H
#define STREAMPLAYER_H

#include<MdaAudioOutputStream.h>

const TInt KSilenceBuffer = 256;

class MStreamObs
    {
    public:
    	enum 
    	{
    	EInit, 
    	EPlay,
    	EWrite,
    	EClose,	
    	};
        virtual void Complete(TInt aState, TInt aError) = 0;
    };

class MStreamProvider
	{
	public:
		virtual TPtrC8 Data() = 0;	
	};

NONSHARABLE_CLASS(CStreamPlayer) : public CBase, public MMdaAudioOutputStreamCallback
	{
	public:
		CStreamPlayer(MStreamProvider& aProvider, MStreamObs& aObs);
		~CStreamPlayer();
		void ConstructL();
		
		static TInt ClosestSupportedRate(TInt aRate);
		
		TInt OpenStream(TInt aRate, TInt aChannels, TUint32 aType = KMMFFourCCCodePCM16);
		
		void SetVolume(TInt aNew);
		TInt Volume() const;
		TInt MaxVolume() const;
		
		void Stop();
		void Start();
		void Open();
		void Close();
		
		TBool Playing() const;
		TBool Closed() const;
		
	private:

		void MaoscOpenComplete(TInt aError) ;
		void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);
		void MaoscPlayComplete(TInt aError);
	
	private:
		void Request();
		void SetCapsL();

	private:
		MStreamProvider& iProvider;
		MStreamObs& iObs;	
		TInt iVolume;
	
		CMdaAudioOutputStream* iStream;
	
		TInt iRate;
		TInt iChannels;
		TUint32 iType;
		
		enum 
			{
				ENone = 0,
				EInited = 0x1,
				EStarted = 0x2,
				EStopped = 0x4,
				EVolumeChange = 0x8,
				EDied		  = 0x10
			};
		
		TInt iState;
		TBuf8<KSilenceBuffer> iSilence;
		TPtrC8 iPtr;
	
	};


#endif