now supports endian adjustment at the output
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -508,8 +508,6 @@ MixerCore::MixThread()
|
|||||||
}
|
}
|
||||||
PRINT(4, "send buffer, inframes %ld, outframes %ld\n", fMixBufferFrameCount, frames_per_buffer(fOutput->MediaOutput().format.u.raw_audio));
|
PRINT(4, "send buffer, inframes %ld, outframes %ld\n", fMixBufferFrameCount, frames_per_buffer(fOutput->MediaOutput().format.u.raw_audio));
|
||||||
|
|
||||||
// swap byte order if necessary
|
|
||||||
|
|
||||||
// fill in the buffer header
|
// fill in the buffer header
|
||||||
media_header* hdr = buf->Header();
|
media_header* hdr = buf->Header();
|
||||||
hdr->type = B_MEDIA_RAW_AUDIO;
|
hdr->type = B_MEDIA_RAW_AUDIO;
|
||||||
@@ -517,6 +515,9 @@ MixerCore::MixThread()
|
|||||||
hdr->time_source = fTimeSource->ID();
|
hdr->time_source = fTimeSource->ID();
|
||||||
hdr->start_time = event_time;
|
hdr->start_time = event_time;
|
||||||
|
|
||||||
|
// swap byte order if necessary
|
||||||
|
fOutput->AdjustByteOrder(buf);
|
||||||
|
|
||||||
// send the buffer
|
// send the buffer
|
||||||
if (B_OK != fNode->SendBuffer(buf, fOutput->MediaOutput().destination)) {
|
if (B_OK != fNode->SendBuffer(buf, fOutput->MediaOutput().destination)) {
|
||||||
printf("MixerCore: #### SendBuffer failed\n");
|
printf("MixerCore: #### SendBuffer failed\n");
|
||||||
|
|||||||
@@ -8,18 +8,21 @@ MixerOutput::MixerOutput(MixerCore *core, const media_output &output)
|
|||||||
: fCore(core),
|
: fCore(core),
|
||||||
fOutput(output),
|
fOutput(output),
|
||||||
fOutputChannelCount(0),
|
fOutputChannelCount(0),
|
||||||
fOutputChannelInfo(0)
|
fOutputChannelInfo(0),
|
||||||
|
fOutputByteSwap(0)
|
||||||
{
|
{
|
||||||
fix_multiaudio_format(&fOutput.format.u.raw_audio);
|
fix_multiaudio_format(&fOutput.format.u.raw_audio);
|
||||||
PRINT_OUTPUT("MixerOutput::MixerOutput", fOutput);
|
PRINT_OUTPUT("MixerOutput::MixerOutput", fOutput);
|
||||||
PRINT_CHANNEL_MASK(fOutput.format);
|
PRINT_CHANNEL_MASK(fOutput.format);
|
||||||
|
|
||||||
UpdateOutputChannels();
|
UpdateOutputChannels();
|
||||||
|
UpdateByteOrderSwap();
|
||||||
}
|
}
|
||||||
|
|
||||||
MixerOutput::~MixerOutput()
|
MixerOutput::~MixerOutput()
|
||||||
{
|
{
|
||||||
delete fOutputChannelInfo;
|
delete fOutputChannelInfo;
|
||||||
|
delete fOutputByteSwap;
|
||||||
}
|
}
|
||||||
|
|
||||||
media_output &
|
media_output &
|
||||||
@@ -38,6 +41,23 @@ MixerOutput::ChangeFormat(const media_multi_audio_format &format)
|
|||||||
PRINT_CHANNEL_MASK(fOutput.format);
|
PRINT_CHANNEL_MASK(fOutput.format);
|
||||||
|
|
||||||
UpdateOutputChannels();
|
UpdateOutputChannels();
|
||||||
|
UpdateByteOrderSwap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MixerOutput::UpdateByteOrderSwap()
|
||||||
|
{
|
||||||
|
delete fOutputByteSwap;
|
||||||
|
fOutputByteSwap = 0;
|
||||||
|
|
||||||
|
// perhaps we need byte swapping
|
||||||
|
if (fOutput.format.u.raw_audio.byte_order != B_MEDIA_HOST_ENDIAN) {
|
||||||
|
if ( fOutput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_FLOAT
|
||||||
|
|| fOutput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_INT
|
||||||
|
|| fOutput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_SHORT) {
|
||||||
|
fOutputByteSwap = new ByteSwap(fOutput.format.u.raw_audio.format);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#define _MIXER_OUTPUT_H
|
#define _MIXER_OUTPUT_H
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "ByteSwap.h"
|
||||||
|
#include <Buffer.h>
|
||||||
|
|
||||||
#define MAX_SOURCES 20
|
#define MAX_SOURCES 20
|
||||||
|
|
||||||
@@ -31,8 +33,10 @@ public:
|
|||||||
|
|
||||||
// only for use by MixerCore
|
// only for use by MixerCore
|
||||||
void GetMixerChannelInfo(int channel, int index, int *type, float *gain);
|
void GetMixerChannelInfo(int channel, int index, int *type, float *gain);
|
||||||
|
void AdjustByteOrder(BBuffer *buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void UpdateByteOrderSwap();
|
||||||
void UpdateOutputChannels();
|
void UpdateOutputChannels();
|
||||||
void AssignDefaultSources();
|
void AssignDefaultSources();
|
||||||
|
|
||||||
@@ -50,6 +54,7 @@ private:
|
|||||||
|
|
||||||
uint32 fOutputChannelCount;
|
uint32 fOutputChannelCount;
|
||||||
output_chan_info *fOutputChannelInfo; //array
|
output_chan_info *fOutputChannelInfo; //array
|
||||||
|
ByteSwap *fOutputByteSwap;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint32 MixerOutput::GetOutputChannelCount()
|
inline uint32 MixerOutput::GetOutputChannelCount()
|
||||||
@@ -79,4 +84,10 @@ inline void MixerOutput::GetMixerChannelInfo(int channel, int index, int *type,
|
|||||||
*gain = fOutputChannelInfo[channel].source_gain[index];
|
*gain = fOutputChannelInfo[channel].source_gain[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void MixerOutput::AdjustByteOrder(BBuffer *buffer)
|
||||||
|
{
|
||||||
|
if (fOutputByteSwap)
|
||||||
|
fOutputByteSwap->Swap(buffer->Data(), buffer->SizeUsed());
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user