identify mixer channels by a type number (0 to 31)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3587 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-06-20 21:39:01 +00:00
parent c6f7aae127
commit a4b8db8530
5 changed files with 31 additions and 8 deletions
@@ -10,6 +10,11 @@
#define ASSERT_LOCKED() if (fLocker->IsLocked()) {} else debugger("core not locked, meltdown occurred")
/* Mixer channels are identified by a type number, each type number corresponds
* to the one of the channel masks of enum media_multi_channels.
*/
MixerCore::MixerCore()
: fLocker(new BLocker),
fOutputBufferLength(MAX_OUTPUT_BUFFER_LENGTH),
@@ -233,7 +233,7 @@ MixerInput::UpdateMixerChannels()
for (int i = 0, mask = 1; i < fMixerChannelCount; i++) {
while (mask != 0 && (all_bits & mask) == 0)
mask <<= 1;
fMixerChannelInfo[i].designation = mask;
fMixerChannelInfo[i].type = ChannelMaskToChannelType(mask);
mask <<= 1;
}
@@ -241,7 +241,7 @@ MixerInput::UpdateMixerChannels()
for (int i = 0; i < fMixerChannelCount; i++) {
int j;
for (j = 0; j < fInputChannelCount; j++) {
if (fInputChannelInfo[j].designations & fMixerChannelInfo[i].designation) {
if (fInputChannelInfo[j].designations & ChannelTypeToChannelMask(fMixerChannelInfo[i].type)) {
fMixerChannelInfo[i].buffer_base = &fMixBuffer[j];
break;
}
@@ -256,7 +256,7 @@ MixerInput::UpdateMixerChannels()
if (old_mixer_channel_info != 0) {
for (int i = 0; i < fMixerChannelCount; i++) {
for (int j = 0; j < old_mixer_channel_count; j++) {
if (fMixerChannelInfo[i].designation == old_mixer_channel_info[j].designation) {
if (fMixerChannelInfo[i].type == old_mixer_channel_info[j].type) {
fMixerChannelInfo[i].gain = old_mixer_channel_info[j].gain;
break;
}
@@ -267,7 +267,7 @@ MixerInput::UpdateMixerChannels()
}
for (int i = 0; i < fMixerChannelCount; i++)
printf("UpdateMixerChannels: mixer channel %d, designation 0x%08X, base %p, gain %.3f\n", i, fMixerChannelInfo[i].designation, fMixerChannelInfo[i].buffer_base, fMixerChannelInfo[i].gain);
printf("UpdateMixerChannels: mixer channel %d, type %2d, des 0x%08X, base %p, gain %.3f\n", i, fMixerChannelInfo[i].type, ChannelTypeToChannelMask(fMixerChannelInfo[i].type), fMixerChannelInfo[i].buffer_base, fMixerChannelInfo[i].gain);
printf("UpdateMixerChannels: leave\n");
}
@@ -279,13 +279,13 @@ MixerInput::GetMixerChannelCount()
}
void
MixerInput::GetMixerChannelInfo(int channel, const float **buffer, uint32 *sample_offset, uint32 *type, float *gain)
MixerInput::GetMixerChannelInfo(int channel, const float **buffer, uint32 *sample_offset, int *type, float *gain)
{
ASSERT(fMixBuffer);
ASSERT(channel >= 0 && channel < fMixerChannelCount);
*buffer = fMixerChannelInfo[channel].buffer_base;
*sample_offset = sizeof(float) * fInputChannelCount;
*type = fMixerChannelInfo[channel].designation;
*type = fMixerChannelInfo[channel].type;
*gain = fMixerChannelInfo[channel].gain;
}
@@ -16,7 +16,7 @@ public:
media_input & MediaInput();
uint32 GetMixerChannelCount();
void GetMixerChannelInfo(int channel, const float **buffer, uint32 *sample_offset, uint32 *type, float *gain);
void GetMixerChannelInfo(int channel, const float **buffer, uint32 *sample_offset, int *type, float *gain);
void SetMixerChannelGain(int channel, float gain);
float GetMixerChannelGain(int channel);
@@ -43,7 +43,7 @@ private:
};
struct mixer_chan_info {
float *buffer_base;
uint32 designation; // only one bit is set
int type;
float gain;
};
@@ -127,6 +127,21 @@ GetChannelMask(int channel, uint32 all_channel_masks)
}
}
int ChannelMaskToChannelType(uint32 mask)
{
for (int i = 0; i < 32; i++)
if (mask & (1 << i))
return i;
return -1;
}
uint32 ChannelTypeToChannelMask(int type)
{
if (type < 0 || type > 31)
return 0;
return 1 << type;
}
void
CopySamples(float *_dst, int32 _dst_sample_offset,
const float *_src, int32 _src_sample_offset,
@@ -20,3 +20,6 @@ inline int64 frames_for_duration(double framerate, bigtime_t duration)
{
return (int64) ceil(framerate * double(duration) / 1000000.0);
}
int ChannelMaskToChannelType(uint32 mask);
uint32 ChannelTypeToChannelMask(int type);