1
0
Fork 0

Refactor CD-DA flow by removing intermediate buffers and loops

Thanks to @ripsaw8080 for insight into CD-DA channel mapping,
@hail-to-the-ryzen for testing and flagging a position-tracking bug,
and @dreamer_ for guidance and code review.

The CD-DA volume and channel mapping loops were moved to generic mixer
calls and no longer require a pre-processing loop:
 - Application-controlled CD-DA volume adjustment is now applied using
   an existing mixer volume scalar that was previously unused by the
   CD-DA code.
 - Mapping of CD-DA left and right channels is now applied at the tail
   end of the mixer's sample ingest sequence.

The following have been removed:
 - The CD-DA callback chunk-wise circular buffer
 - The decode buffers in the Opus and MP3 decoders
 - The decode buffer and conversion buffers in SDL_Sound
These removals and API changes allow the image player's buffer
to be passed-through ultimately to the audio codec, skipping multiple
intermediate buffers.
This commit is contained in:
krcroft 2019-11-11 13:36:31 -08:00 committed by Patryk Obara
parent 5a9dd2866b
commit d1a6f373cb
5 changed files with 310 additions and 336 deletions

View file

@ -46,8 +46,11 @@ extern Bit8u MixTemp[MIXER_BUFSIZE];
class MixerChannel {
public:
MixerChannel(MIXER_Handler _handler, Bitu _freq, const char * _name);
void SetVolume(float _left,float _right);
void SetScale( float f );
void SetScale(float f);
void SetScale(float _left, float _right);
void MapChannels(Bit8u _left, Bit8u _right);
void UpdateVolume(void);
void SetFreq(Bitu _freq);
void Mix(Bitu _needed);
@ -77,24 +80,25 @@ public:
void FillUp(void);
void Enable(bool _yesno);
MIXER_Handler handler;
float volmain[2];
float scale;
Bit32s volmul[2];
//This gets added the frequency counter each mixer step
Bitu freq_add;
//When this flows over a new sample needs to be read from the device
Bitu freq_counter;
//Timing on how many samples have been done and were needed by th emixer
Bitu done, needed;
//Previous and next samples
Bits prevSample[2];
Bits nextSample[2];
const char * name;
bool interpolate;
bool enabled;
MixerChannel * next;
float volmain[2];
MixerChannel* next;
const char* name;
Bitu done; //Timing on how many samples have been done by the mixer
bool enabled;
private:
MixerChannel();
MIXER_Handler handler;
Bitu freq_add; //This gets added the frequency counter each mixer step
Bitu freq_counter; //When this flows over a new sample needs to be read from the device
Bitu needed; //Timing on how many samples were needed by the mixer
Bits prev_sample[2]; //Previous and next samples
Bits next_sample[2];
Bit32s volmul[2];
float scale[2];
Bit8u channel_map[2]; //Output channel mapping
bool interpolate;
};
MixerChannel * MIXER_AddChannel(MIXER_Handler handler,Bitu freq,const char * name);