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,14 +508,15 @@ MixerCore::MixThread()
|
||||
}
|
||||
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
|
||||
media_header* hdr = buf->Header();
|
||||
hdr->type = B_MEDIA_RAW_AUDIO;
|
||||
hdr->size_used = fOutput->MediaOutput().format.u.raw_audio.buffer_size;
|
||||
hdr->time_source = fTimeSource->ID();
|
||||
hdr->start_time = event_time;
|
||||
|
||||
// swap byte order if necessary
|
||||
fOutput->AdjustByteOrder(buf);
|
||||
|
||||
// send the buffer
|
||||
if (B_OK != fNode->SendBuffer(buf, fOutput->MediaOutput().destination)) {
|
||||
|
||||
@@ -8,18 +8,21 @@ MixerOutput::MixerOutput(MixerCore *core, const media_output &output)
|
||||
: fCore(core),
|
||||
fOutput(output),
|
||||
fOutputChannelCount(0),
|
||||
fOutputChannelInfo(0)
|
||||
fOutputChannelInfo(0),
|
||||
fOutputByteSwap(0)
|
||||
{
|
||||
fix_multiaudio_format(&fOutput.format.u.raw_audio);
|
||||
PRINT_OUTPUT("MixerOutput::MixerOutput", fOutput);
|
||||
PRINT_CHANNEL_MASK(fOutput.format);
|
||||
|
||||
UpdateOutputChannels();
|
||||
UpdateByteOrderSwap();
|
||||
}
|
||||
|
||||
MixerOutput::~MixerOutput()
|
||||
{
|
||||
delete fOutputChannelInfo;
|
||||
delete fOutputByteSwap;
|
||||
}
|
||||
|
||||
media_output &
|
||||
@@ -38,6 +41,23 @@ MixerOutput::ChangeFormat(const media_multi_audio_format &format)
|
||||
PRINT_CHANNEL_MASK(fOutput.format);
|
||||
|
||||
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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define _MIXER_OUTPUT_H
|
||||
|
||||
#include "debug.h"
|
||||
#include "ByteSwap.h"
|
||||
#include <Buffer.h>
|
||||
|
||||
#define MAX_SOURCES 20
|
||||
|
||||
@@ -31,8 +33,10 @@ public:
|
||||
|
||||
// only for use by MixerCore
|
||||
void GetMixerChannelInfo(int channel, int index, int *type, float *gain);
|
||||
void AdjustByteOrder(BBuffer *buffer);
|
||||
|
||||
private:
|
||||
void UpdateByteOrderSwap();
|
||||
void UpdateOutputChannels();
|
||||
void AssignDefaultSources();
|
||||
|
||||
@@ -50,6 +54,7 @@ private:
|
||||
|
||||
uint32 fOutputChannelCount;
|
||||
output_chan_info *fOutputChannelInfo; //array
|
||||
ByteSwap *fOutputByteSwap;
|
||||
};
|
||||
|
||||
inline uint32 MixerOutput::GetOutputChannelCount()
|
||||
@@ -79,4 +84,10 @@ inline void MixerOutput::GetMixerChannelInfo(int channel, int index, int *type,
|
||||
*gain = fOutputChannelInfo[channel].source_gain[index];
|
||||
}
|
||||
|
||||
inline void MixerOutput::AdjustByteOrder(BBuffer *buffer)
|
||||
{
|
||||
if (fOutputByteSwap)
|
||||
fOutputByteSwap->Swap(buffer->Data(), buffer->SizeUsed());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user