xref: /haiku/src/apps/mediaplayer/supplier/ProxyAudioSupplier.h (revision 8dd3060da4f50b8de2830fd93216b186efec7c4f)
1 /*
2  * Copyright 2008 Stephan Aßmus <superstippi@gmx.de>
3  * All Rights Reserved. Distributed under the terms of the MIT license.
4  */
5 #ifndef PROXY_AUDIO_SUPPLIER_H
6 #define PROXY_AUDIO_SUPPLIER_H
7 
8 
9 #include <Locker.h>
10 
11 #include "AudioResampler.h"
12 #include "AudioSupplier.h"
13 
14 
15 class AudioTrackSupplier;
16 class AudioVolumeConverter;
17 class PlaybackManager;
18 
19 
20 class ProxyAudioSupplier : public AudioSupplier {
21 public:
22 								ProxyAudioSupplier(
23 									PlaybackManager* playbackManager);
24 	virtual						~ProxyAudioSupplier();
25 
26 	// AudioSupplier interface
27 	virtual	status_t			GetFrames(void* buffer, int64 frameCount,
28 									bigtime_t startTime, bigtime_t endTime);
29 
30 	virtual bigtime_t			InitialLatency() const;
31 	virtual	void				SetFormat(const media_format& format);
32 	virtual	const media_format&	Format() const;
33 
34 	virtual	status_t			InitCheck() const;
35 
36 	// ProxyAudioSupplier
37 			void				SetSupplier(AudioTrackSupplier* supplier,
38 									float videoFrameRate);
39 			void				SetVolume(float volume);
40 			float				Volume();
41 
42 private:
43 			int64				_AudioFrameForVideoFrame(int64 frame) const;
44 			int64				_VideoFrameForAudioFrame(int64 frame) const;
45 			int64				_AudioFrameForTime(bigtime_t time) const;
46 			int64				_VideoFrameForTime(bigtime_t time) const;
47 
48 			void				_ReadSilence(void* buffer, int64 frames) const;
49 			void				_ReverseFrames(void* buffer,
50 									int64 frames) const;
51 			void*				_SkipFrames(void* buffer, int64 frames) const;
52 
53 private:
54 	mutable BLocker				fSupplierLock;
55 
56 			PlaybackManager*	fPlaybackManager;
57 			float				fVideoFrameRate;
58 			float				fVolume;
59 
60 			AudioTrackSupplier*	fSupplier;
61 			AudioReader*		fAdapter;
62 			AudioVolumeConverter* fVolumeConverter;
63 			AudioResampler		fAudioResampler;
64 };
65 
66 
67 #endif	// PROXY_AUDIO_SUPPLIER_H
68