diff --git a/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp b/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp index 368413c808..93757245f4 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp +++ b/src/add-ons/media/media-add-ons/mixer/MixerInput.cpp @@ -4,11 +4,13 @@ #include "MixerInput.h" #include "MixerCore.h" #include "MixerUtils.h" +#include "ByteSwap.h" #include "debug.h" MixerInput::MixerInput(MixerCore *core, const media_input &input, float mixSampleRate, int32 mixFramesCount, bigtime_t mixStartTime) : fCore(core), fInput(input), + fInputByteSwap(0), fInputChannelInfo(0), fInputChannelCount(0), fInputChannelMask(0), @@ -30,6 +32,15 @@ MixerInput::MixerInput(MixerCore *core, const media_input &input, float mixSampl fInputChannelMask = fInput.format.u.raw_audio.channel_mask; fInputChannelInfo = new input_chan_info[fInputChannelCount]; + // perhaps we need byte swapping + if (fInput.format.u.raw_audio.byte_order != B_MEDIA_HOST_ENDIAN) { + if ( fInput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_FLOAT + || fInput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_INT + || fInput.format.u.raw_audio.format == media_raw_audio_format::B_AUDIO_SHORT) { + fInputByteSwap = new ByteSwap(fInput.format.u.raw_audio.format); + } + } + // initialize fInputChannelInfo for (int i = 0; i < fInputChannelCount; i++) { fInputChannelInfo[i].buffer_base = 0; // will be set by SetMixBufferFormat() @@ -63,9 +74,22 @@ MixerInput::~MixerInput() void MixerInput::BufferReceived(BBuffer *buffer) { + void *data; + size_t size; + bigtime_t start; + ASSERT(fMixBuffer); - printf("mix buffer start %14Ld, buffer start %14Ld\n", fMixBufferStartTime, buffer->Header()->start_time); + data = buffer->Data(); + size = buffer->SizeUsed(); + start = buffer->Header()->start_time; + + // swap the byte order of this buffer, if necessary + if (fInputByteSwap) + fInputByteSwap->Swap(data, size); + + + printf("mix buffer start %14Ld, buffer start %14Ld\n", fMixBufferStartTime, start); } media_input & diff --git a/src/add-ons/media/media-add-ons/mixer/MixerInput.h b/src/add-ons/media/media-add-ons/mixer/MixerInput.h index deced19804..4c85e17867 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerInput.h +++ b/src/add-ons/media/media-add-ons/mixer/MixerInput.h @@ -2,6 +2,7 @@ #define _MIXER_INPUT_H class MixerCore; +class ByteSwap; class MixerInput { @@ -50,6 +51,7 @@ private: private: MixerCore *fCore; media_input fInput; + ByteSwap *fInputByteSwap; input_chan_info *fInputChannelInfo; // array uint32 fInputChannelCount;