diff options
author | R. Belmont <rb6502@users.noreply.github.com> | 2019-07-14 17:29:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-14 17:29:50 -0400 |
commit | 5ed21f87acf372114ecaa75fed7900e71d3755eb (patch) | |
tree | 060f85aeceeaf1d8772528e11657a17802dc11bf | |
parent | 55285b2a42c38ff16b34f0c088175532e9bddc34 (diff) | |
parent | 3a19b4dcc32b5989ce045916097da78a4ba78105 (diff) |
Merge pull request #5343 from ericvids/k573latency
k573dio: timing fixes
-rw-r--r-- | src/devices/sound/mas3507d.cpp | 8 | ||||
-rw-r--r-- | src/devices/sound/mas3507d.h | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/devices/sound/mas3507d.cpp b/src/devices/sound/mas3507d.cpp index 762fa4f02f1..3581176ca53 100644 --- a/src/devices/sound/mas3507d.cpp +++ b/src/devices/sound/mas3507d.cpp @@ -48,6 +48,7 @@ void mas3507d_device::device_reset() mp3_count = 0; sample_count = 0; total_frame_count = 0; + buffered_frame_count = 0; } void mas3507d_device::i2c_scl_w(bool line) @@ -356,8 +357,6 @@ void mas3507d_device::fill_buffer() current_rate = mp3_info.hz; stream->set_sample_rate(current_rate); } - - total_frame_count += scount; } void mas3507d_device::append_buffer(stream_sample_t **outputs, int &pos, int scount) @@ -365,6 +364,8 @@ void mas3507d_device::append_buffer(stream_sample_t **outputs, int &pos, int sco if(!sample_count) return; + buffered_frame_count = scount; + int s1 = scount - pos; if(s1 > sample_count) s1 = sample_count; @@ -385,6 +386,7 @@ void mas3507d_device::append_buffer(stream_sample_t **outputs, int &pos, int sco if(s1 == sample_count) { pos += s1; sample_count = 0; + total_frame_count += s1; return; } @@ -395,6 +397,7 @@ void mas3507d_device::append_buffer(stream_sample_t **outputs, int &pos, int sco pos += s1; sample_count -= s1; + total_frame_count += s1; } void mas3507d_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int csamples) @@ -414,6 +417,7 @@ void mas3507d_device::sound_stream_update(sound_stream &stream, stream_sample_t mp3_count = 0; sample_count = 0; total_frame_count = 0; + buffered_frame_count = 0; for(int i=pos; i != csamples; i++) { outputs[0][i] = 0; diff --git a/src/devices/sound/mas3507d.h b/src/devices/sound/mas3507d.h index 2c894acddfb..64876cb321b 100644 --- a/src/devices/sound/mas3507d.h +++ b/src/devices/sound/mas3507d.h @@ -22,7 +22,7 @@ public: void i2c_scl_w(bool line); void i2c_sda_w(bool line); - u32 get_frame_count() const { return total_frame_count; } + u32 get_frame_count() const { return total_frame_count - buffered_frame_count; } protected: virtual void device_start() override; @@ -41,7 +41,7 @@ private: int i2c_bus_curbit; uint8_t i2c_bus_curval; int mp3_count, sample_count, current_rate; - u32 total_frame_count; + u32 total_frame_count, buffered_frame_count; mp3dec_t mp3_dec; mp3dec_frame_info_t mp3_info; |