2 * Copyright 2002-2009, Haiku.
3 * Distributed under the terms of the MIT License.
9 #ifndef _SOUND_PLAY_NODE_H
10 #define _SOUND_PLAY_NODE_H
14 #include <BufferGroup.h>
15 #include <BufferProducer.h>
16 #include <MediaEventLooper.h>
17 #include <SoundPlayer.h>
23 class SoundPlayNode
: public BBufferProducer
, public BMediaEventLooper
{
25 SoundPlayNode(const char* name
,
26 BSoundPlayer
* player
);
27 virtual ~SoundPlayNode();
30 bigtime_t
CurrentTime();
34 virtual BMediaAddOn
* AddOn(int32
* _internalID
) const;
37 virtual void Preroll();
40 virtual status_t
HandleMessage(int32 message
, const void* data
,
44 virtual void NodeRegistered();
45 virtual status_t
RequestCompleted(
46 const media_request_info
& info
);
47 virtual void SetTimeSource(BTimeSource
* timeSource
);
48 virtual void SetRunMode(run_mode mode
);
50 // BBufferProducer methods
52 virtual status_t
FormatSuggestionRequested(media_type type
,
53 int32 quality
, media_format
* format
);
55 virtual status_t
FormatProposal(const media_source
& output
,
56 media_format
* format
);
58 virtual status_t
FormatChangeRequested(
59 const media_source
& source
,
60 const media_destination
& destination
,
61 media_format
* format
, int32
* _deprecated_
);
62 virtual status_t
GetNextOutput(int32
* cookie
,
63 media_output
* _output
);
64 virtual status_t
DisposeOutputCookie(int32 cookie
);
66 virtual status_t
SetBufferGroup(const media_source
& forSource
,
68 virtual status_t
GetLatency(bigtime_t
* _latency
);
70 virtual status_t
PrepareToConnect(const media_source
& what
,
71 const media_destination
& where
,
72 media_format
* format
, media_source
* _source
,
75 virtual void Connect(status_t error
,
76 const media_source
& source
,
77 const media_destination
& destination
,
78 const media_format
& format
,
81 virtual void Disconnect(const media_source
& what
,
82 const media_destination
& where
);
84 virtual void LateNoticeReceived(const media_source
& what
,
86 bigtime_t performanceTime
);
88 virtual void EnableOutput(const media_source
& what
,
89 bool enabled
, int32
* _deprecated_
);
90 virtual void AdditionalBufferRequested(
91 const media_source
& source
,
92 media_buffer_id previousBuffer
,
93 bigtime_t previousTime
,
94 const media_seek_tag
* previousTag
);
95 virtual void LatencyChanged(const media_source
& source
,
96 const media_destination
& destination
,
97 bigtime_t newLatency
, uint32 flags
);
99 // BMediaEventLooper methods
102 virtual void HandleEvent(const media_timed_event
* event
,
104 bool realTimeEvent
= false);
106 media_multi_audio_format
Format() const;
109 virtual status_t
HandleStart(const media_timed_event
* event
,
111 bool realTimeEvent
= false);
112 virtual status_t
HandleSeek(const media_timed_event
* event
,
114 bool realTimeEvent
= false);
115 virtual status_t
HandleWarp(const media_timed_event
* event
,
117 bool realTimeEvent
= false);
118 virtual status_t
HandleStop(const media_timed_event
* event
,
120 bool realTimeEvent
= false);
121 virtual status_t
SendNewBuffer(const media_timed_event
* event
,
123 bool realTimeEvent
= false);
124 virtual status_t
HandleDataStatus(const media_timed_event
* event
,
126 bool realTimeEvent
= false);
127 virtual status_t
HandleParameter(const media_timed_event
* event
,
129 bool realTimeEvent
= false);
131 status_t
AllocateBuffers();
132 BBuffer
* FillNextBuffer(bigtime_t eventTime
);
135 BSoundPlayer
* fPlayer
;
137 status_t fInitStatus
;
139 media_output fOutput
;
140 BBufferGroup
* fBufferGroup
;
142 bigtime_t fInternalLatency
;
143 bigtime_t fStartTime
;
145 int32 fTooEarlyCount
;
149 } // namespace BPrivate
152 #endif // _SOUND_PLAY_NODE_H