Coding style consistency.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30224 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007 Haiku Inc. All rights reserved.
|
* Copyright 2007-2009 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _MIXER_CORE_H
|
#ifndef _MIXER_CORE_H
|
||||||
@@ -24,88 +24,91 @@ class Resampler;
|
|||||||
// but for now we redefine type 12
|
// but for now we redefine type 12
|
||||||
#define B_CHANNEL_MONO B_CHANNEL_TOP_CENTER
|
#define B_CHANNEL_MONO B_CHANNEL_TOP_CENTER
|
||||||
|
|
||||||
class MixerCore
|
class MixerCore {
|
||||||
{
|
public:
|
||||||
public:
|
MixerCore(AudioMixer *node);
|
||||||
MixerCore(AudioMixer *node);
|
virtual ~MixerCore();
|
||||||
~MixerCore();
|
|
||||||
|
|
||||||
MixerSettings *Settings();
|
MixerSettings* Settings();
|
||||||
|
|
||||||
// To avoid calling Settings()->AttenuateOutput() for every outgoing
|
// To avoid calling Settings()->AttenuateOutput() for every outgoing
|
||||||
// buffer, this setting is cached in fOutputGain and must be set by
|
// buffer, this setting is cached in fOutputGain and must be set by
|
||||||
// the audio mixer node using SetOutputAttenuation()
|
// the audio mixer node using SetOutputAttenuation()
|
||||||
void SetOutputAttenuation(float gain);
|
void SetOutputAttenuation(float gain);
|
||||||
MixerInput * AddInput(const media_input &input);
|
MixerInput* AddInput(const media_input& input);
|
||||||
MixerOutput * AddOutput(const media_output &output);
|
MixerOutput* AddOutput(const media_output& output);
|
||||||
|
|
||||||
bool RemoveInput(int32 inputID);
|
bool RemoveInput(int32 inputID);
|
||||||
bool RemoveOutput();
|
bool RemoveOutput();
|
||||||
int32 CreateInputID();
|
int32 CreateInputID();
|
||||||
|
|
||||||
// index = 0 to count-1, NOT inputID
|
// index = 0 to count-1, NOT inputID
|
||||||
MixerInput * Input(int index);
|
MixerInput* Input(int index);
|
||||||
MixerOutput * Output();
|
MixerOutput* Output();
|
||||||
|
|
||||||
void Lock();
|
void Lock();
|
||||||
bool LockWithTimeout(bigtime_t timeout);
|
bool LockWithTimeout(bigtime_t timeout);
|
||||||
bool LockFromMixThread();
|
bool LockFromMixThread();
|
||||||
void Unlock();
|
void Unlock();
|
||||||
|
|
||||||
void BufferReceived(BBuffer *buffer,
|
void BufferReceived(BBuffer* buffer,
|
||||||
bigtime_t lateness);
|
bigtime_t lateness);
|
||||||
|
|
||||||
void InputFormatChanged(int32 inputID,
|
void InputFormatChanged(int32 inputID,
|
||||||
const media_multi_audio_format &format);
|
const media_multi_audio_format& format);
|
||||||
void OutputFormatChanged(
|
void OutputFormatChanged(
|
||||||
const media_multi_audio_format &format);
|
const media_multi_audio_format& format);
|
||||||
|
|
||||||
void SetOutputBufferGroup(BBufferGroup *group);
|
void SetOutputBufferGroup(BBufferGroup* group);
|
||||||
void SetTimingInfo(BTimeSource *ts,
|
void SetTimingInfo(BTimeSource* timeSource,
|
||||||
bigtime_t downstream_latency);
|
bigtime_t downstream_latency);
|
||||||
void EnableOutput(bool enabled);
|
void EnableOutput(bool enabled);
|
||||||
bool Start();
|
bool Start();
|
||||||
bool Stop();
|
bool Stop();
|
||||||
|
|
||||||
void StartMixThread();
|
void StartMixThread();
|
||||||
void StopMixThread();
|
void StopMixThread();
|
||||||
uint32 OutputChannelCount();
|
uint32 OutputChannelCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ApplyOutputFormat();
|
void ApplyOutputFormat();
|
||||||
static int32 _mix_thread_(void *arg);
|
static int32 _mix_thread_(void* arg);
|
||||||
void MixThread();
|
void MixThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLocker *fLocker;
|
BLocker* fLocker;
|
||||||
BList *fInputs;
|
BList* fInputs;
|
||||||
MixerOutput *fOutput;
|
MixerOutput* fOutput;
|
||||||
int32 fNextInputID;
|
int32 fNextInputID;
|
||||||
// true = the mix thread is running
|
bool fRunning;
|
||||||
bool fRunning;
|
// true = the mix thread is running
|
||||||
// true = mix thread should be
|
|
||||||
// started of it is not running
|
|
||||||
bool fStarted;
|
|
||||||
// true = mix thread should be
|
|
||||||
// started of it is not running
|
|
||||||
bool fOutputEnabled;
|
|
||||||
Resampler **fResampler; // array
|
|
||||||
float *fMixBuffer;
|
|
||||||
int32 fMixBufferFrameRate;
|
|
||||||
int32 fMixBufferFrameCount;
|
|
||||||
int32 fMixBufferChannelCount;
|
|
||||||
int32 *fMixBufferChannelTypes; //array
|
|
||||||
bool fDoubleRateMixing;
|
|
||||||
bigtime_t fDownstreamLatency;
|
|
||||||
MixerSettings *fSettings;
|
|
||||||
AudioMixer *fNode;
|
|
||||||
BBufferGroup *fBufferGroup;
|
|
||||||
BTimeSource *fTimeSource;
|
|
||||||
thread_id fMixThread;
|
|
||||||
sem_id fMixThreadWaitSem;
|
|
||||||
float fOutputGain;
|
|
||||||
|
|
||||||
friend class MixerInput; // XXX debug only
|
bool fStarted;
|
||||||
|
// true = mix thread should be
|
||||||
|
// started of it is not running
|
||||||
|
|
||||||
|
bool fOutputEnabled;
|
||||||
|
// true = mix thread should be
|
||||||
|
// started of it is not running
|
||||||
|
|
||||||
|
Resampler** fResampler; // array
|
||||||
|
float* fMixBuffer;
|
||||||
|
int32 fMixBufferFrameRate;
|
||||||
|
int32 fMixBufferFrameCount;
|
||||||
|
int32 fMixBufferChannelCount;
|
||||||
|
int32* fMixBufferChannelTypes; //array
|
||||||
|
bool fDoubleRateMixing;
|
||||||
|
bigtime_t fDownstreamLatency;
|
||||||
|
MixerSettings* fSettings;
|
||||||
|
AudioMixer* fNode;
|
||||||
|
BBufferGroup* fBufferGroup;
|
||||||
|
BTimeSource* fTimeSource;
|
||||||
|
thread_id fMixThread;
|
||||||
|
sem_id fMixThreadWaitSem;
|
||||||
|
float fOutputGain;
|
||||||
|
|
||||||
|
friend class MixerInput;
|
||||||
|
// NOTE: debug only
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -115,18 +118,21 @@ MixerCore::Lock()
|
|||||||
fLocker->Lock();
|
fLocker->Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
MixerCore::LockWithTimeout(bigtime_t timeout)
|
MixerCore::LockWithTimeout(bigtime_t timeout)
|
||||||
{
|
{
|
||||||
return B_OK == fLocker->LockWithTimeout(timeout);
|
return fLocker->LockWithTimeout(timeout) == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
MixerCore::Unlock()
|
MixerCore::Unlock()
|
||||||
{
|
{
|
||||||
fLocker->Unlock();
|
fLocker->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
MixerCore::LockFromMixThread()
|
MixerCore::LockFromMixThread()
|
||||||
{
|
{
|
||||||
@@ -134,8 +140,12 @@ MixerCore::LockFromMixThread()
|
|||||||
if (LockWithTimeout(10000))
|
if (LockWithTimeout(10000))
|
||||||
return true;
|
return true;
|
||||||
// XXX accessing fMixThreadWaitSem is still a race condition :(
|
// XXX accessing fMixThreadWaitSem is still a race condition :(
|
||||||
if (B_WOULD_BLOCK != acquire_sem_etc(fMixThreadWaitSem, 1, B_RELATIVE_TIMEOUT, 0))
|
if (acquire_sem_etc(fMixThreadWaitSem, 1, B_RELATIVE_TIMEOUT, 0)
|
||||||
|
!= B_WOULD_BLOCK) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif // _MIXER_CORE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user