Add single sample push.
This commit is contained in:
parent
36406a6627
commit
ac03facaa9
@ -33,7 +33,7 @@ namespace SNES
|
||||
{
|
||||
#include "bapu/dsp/blargg_endian.h"
|
||||
CPU cpu;
|
||||
}
|
||||
} // namespace SNES
|
||||
|
||||
namespace spc
|
||||
{
|
||||
@ -57,7 +57,7 @@ static uint32 ratio_numerator = APU_NUMERATOR_NTSC;
|
||||
static uint32 ratio_denominator = APU_DENOMINATOR_NTSC;
|
||||
|
||||
static double dynamic_rate_multiplier = 1.0;
|
||||
}
|
||||
} // namespace spc
|
||||
|
||||
namespace msu
|
||||
{
|
||||
@ -66,7 +66,7 @@ static const int buffer_size = MAX_SAMPLE_FRAMES * 6;
|
||||
static uint8 mixing_buffer[buffer_size];
|
||||
static Resampler *resampler = NULL;
|
||||
static std::vector<uint16> resample_buffer;
|
||||
}
|
||||
} // namespace msu
|
||||
|
||||
static void UpdatePlaybackRate(void);
|
||||
static void SPCSnapshotCallback(void);
|
||||
|
@ -95,12 +95,27 @@ struct Resampler
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void push(int16_t l, int16_t r)
|
||||
{
|
||||
if (space_empty() >= 2)
|
||||
{
|
||||
int end = start + size;
|
||||
if (end > buffer_size)
|
||||
end -= buffer_size;
|
||||
buffer[end] = l;
|
||||
buffer[end + 1] = r;
|
||||
size += 2;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool push(int16_t *src, int num_samples)
|
||||
{
|
||||
if (space_empty() < num_samples)
|
||||
return false;
|
||||
|
||||
int end = (start + size) % buffer_size;
|
||||
int end = start + size;
|
||||
if (end > buffer_size)
|
||||
end -= buffer_size;
|
||||
int first_write_size = min(num_samples, buffer_size - end);
|
||||
|
||||
memcpy(buffer + end, src, first_write_size * 2);
|
||||
|
Loading…
Reference in New Issue
Block a user