xref: /haiku/src/kits/media/SoundPlayNode.h (revision 7120e97489acbf17d86d3f33e3b2e68974fd4b23)
1 #ifndef _SOUND_PLAY_NODE_
2 #define _SOUND_PLAY_NODE_
3 
4 /***********************************************************************
5  * AUTHOR: Marcus Overhagen
6  *   FILE: SoundPlayNode.h
7  *  DESCR: This is the BBufferProducer, used internally by BSoundPlayer
8  *         This belongs into a private namespace, but isn't for
9  *         compatibility reasons.
10  ***********************************************************************/
11 
12 class _SoundPlayNode : public BBufferProducer
13 {
14 public:
15 	_SoundPlayNode(const char *name, const media_multi_audio_format *format, BSoundPlayer *player);
16 	~_SoundPlayNode();
17 
18 	media_multi_audio_format Format() const;
19 
20 private:
21 
22 	virtual	status_t FormatSuggestionRequested(
23 				media_type type,
24 				int32 quality,
25 				media_format * format);
26 	virtual	status_t FormatProposal(
27 				const media_source & output,
28 				media_format * format);
29 	virtual	status_t FormatChangeRequested(
30 				const media_source & source,
31 				const media_destination & destination,
32 				media_format * io_format,
33 				int32 * _deprecated_);
34 	virtual	status_t GetNextOutput(	/* cookie starts as 0 */
35 				int32 * cookie,
36 				media_output * out_output);
37 	virtual	status_t DisposeOutputCookie(
38 				int32 cookie);
39 	virtual	status_t SetBufferGroup(
40 				const media_source & for_source,
41 				BBufferGroup * group);
42 	virtual	status_t VideoClippingChanged(
43 				const media_source & for_source,
44 				int16 num_shorts,
45 				int16 * clip_data,
46 				const media_video_display_info & display,
47 				int32 * _deprecated_);
48 	virtual	status_t GetLatency(
49 				bigtime_t * out_lantency);
50 	virtual	status_t PrepareToConnect(
51 				const media_source & what,
52 				const media_destination & where,
53 				media_format * format,
54 				media_source * out_source,
55 				char * out_name);
56 	virtual	void Connect(
57 				status_t error,
58 				const media_source & source,
59 				const media_destination & destination,
60 				const media_format & format,
61 				char * io_name);
62 	virtual	void Disconnect(
63 				const media_source & what,
64 				const media_destination & where);
65 	virtual	void LateNoticeReceived(
66 				const media_source & what,
67 				bigtime_t how_much,
68 				bigtime_t performance_time);
69 	virtual	void EnableOutput(
70 				const media_source & what,
71 				bool enabled,
72 				int32 * _deprecated_);
73 
74 	virtual	BMediaAddOn* AddOn(
75 				int32 * internal_id) const;
76 
77 public:
78 	void Start();
79 	void Stop();
80 
81 private:
82 	int fFramesPerBuffer;
83 	thread_id fThreadId;
84 	volatile bool fStopThread;
85 	static int32 threadstart(void *arg);
86 	void PlayThread();
87 	media_multi_audio_format fFormat;
88 	BSoundPlayer *fPlayer;
89 };
90 
91 #endif
92