2 * Copyright 2002 David Shipman,
3 * Copyright 2003-2007 Marcus Overhagen
4 * Copyright 2007-2010 Haiku Inc. All rights reserved.
5 * Distributed under the terms of the MIT License.
11 #include <BufferConsumer.h>
12 #include <BufferGroup.h>
13 #include <BufferProducer.h>
14 #include <Controllable.h>
15 #include <MediaEventLooper.h>
16 #include <MediaNode.h>
23 class AudioMixer
: public BBufferConsumer
, public BBufferProducer
,
24 public BControllable
, public BMediaEventLooper
{
26 AudioMixer(BMediaAddOn
* addOn
,
28 virtual ~AudioMixer();
30 void DisableNodeStop();
35 void PublishEventLatencyChange();
36 void UpdateParameterWeb();
38 void HandleInputBuffer(BBuffer
* buffer
,
41 status_t
CreateBufferGroup(BBufferGroup
** buffer
) const;
43 status_t
SendBuffer(BBuffer
* buffer
,
46 float dB_to_Gain(float db
);
47 float Gain_to_dB(float gain
);
50 virtual BMediaAddOn
* AddOn(int32
* _internalID
) const;
51 virtual void NodeRegistered();
52 virtual void Stop(bigtime_t performanceTime
, bool immediate
);
53 virtual void SetTimeSource(BTimeSource
* timeSource
);
56 // BControllable methods
57 virtual status_t
GetParameterValue(int32 id
,
58 bigtime_t
* _lastChange
, void* _value
,
60 virtual void SetParameterValue(int32 id
, bigtime_t when
,
61 const void* value
, size_t size
);
63 // BBufferConsumer methods
64 virtual status_t
HandleMessage(int32 message
, const void* data
,
66 virtual status_t
AcceptFormat(const media_destination
& dest
,
67 media_format
* format
);
68 virtual status_t
GetNextInput(int32
* cookie
,
70 virtual void DisposeInputCookie(int32 cookie
);
71 virtual void BufferReceived(BBuffer
*buffer
);
72 virtual void ProducerDataStatus(
73 const media_destination
& forWhom
,
74 int32 status
, bigtime_t atPerformanceTime
);
75 virtual status_t
GetLatencyFor(const media_destination
& forWhom
,
77 media_node_id
* _timesource
);
78 virtual status_t
Connected(const media_source
& producer
,
79 const media_destination
& where
,
80 const media_format
& withFormat
,
82 virtual void Disconnected(const media_source
& producer
,
83 const media_destination
& where
);
84 virtual status_t
FormatChanged(const media_source
& producer
,
85 const media_destination
& consumer
,
87 const media_format
& format
);
89 // BBufferProducer methods
90 virtual status_t
FormatSuggestionRequested(media_type type
,
91 int32 quality
, media_format
* format
);
92 virtual status_t
FormatProposal(const media_source
& output
,
93 media_format
* format
);
94 virtual status_t
FormatChangeRequested(
95 const media_source
& source
,
96 const media_destination
&destination
,
98 int32
* /*deprecated*/);
99 virtual status_t
GetNextOutput(int32
* cookie
,
100 media_output
* _output
);
101 virtual status_t
DisposeOutputCookie(int32 cookie
);
102 virtual status_t
SetBufferGroup(const media_source
& source
,
103 BBufferGroup
* group
);
104 virtual status_t
GetLatency(bigtime_t
* _latency
);
105 virtual status_t
PrepareToConnect(const media_source
& what
,
106 const media_destination
& where
,
107 media_format
* format
, media_source
* _source
,
109 virtual void Connect(status_t error
,
110 const media_source
& source
,
111 const media_destination
& destination
,
112 const media_format
& format
, char *_name
);
113 virtual void Disconnect(const media_source
& what
,
114 const media_destination
& where
);
115 virtual void LateNoticeReceived(const media_source
& what
,
117 bigtime_t performanceTime
);
118 virtual void EnableOutput(const media_source
& what
,
119 bool enabled
, int32
* /*_deprecated_*/);
120 virtual void LatencyChanged(const media_source
& source
,
121 const media_destination
& destination
,
122 bigtime_t newLatency
, uint32 flags
);
124 // BMediaEventLooper methods
125 virtual void HandleEvent(const media_timed_event
* event
,
127 bool realTimeEvent
= false);
133 BBufferGroup
* fBufferGroup
;
134 bigtime_t fDownstreamLatency
;
135 bigtime_t fInternalLatency
;
137 media_format fDefaultFormat
;
138 bigtime_t fLastLateNotification
;
139 bigtime_t fLastLateness
;
143 #endif // AUDIO_MIXER_H