diff options
author | malc <av1474@comtv.ru> | 2009-09-18 10:59:38 +0400 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-09-18 14:04:36 +0400 |
commit | cab648c46260e1c04c68c304fc11cd77c30bef19 (patch) | |
tree | ece37c4a5141ea9c8f36d3c5003175c5742fd7df /audio | |
parent | 960e932d74a935ba1115a117f9d3d33cb8f18094 (diff) | |
download | qemu-cab648c46260e1c04c68c304fc11cd77c30bef19.tar.gz qemu-cab648c46260e1c04c68c304fc11cd77c30bef19.tar.bz2 qemu-cab648c46260e1c04c68c304fc11cd77c30bef19.zip |
audio: introduce audio_pcm_hw_clip_out helper function
Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audio.c | 22 | ||||
-rw-r--r-- | audio/audio_int.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/audio/audio.c b/audio/audio.c index a3e23b212b..d8e1e1519a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -851,6 +851,28 @@ int audio_pcm_hw_get_live_in (HWVoiceIn *hw) return live; } +int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, + int live, int pending) +{ + int left = hw->samples - pending; + int len = audio_MIN (left, live); + int clipped = 0; + + while (len) { + struct st_sample *src = hw->mix_buf + hw->rpos; + uint8_t *dst = advance (pcm_buf, hw->rpos << hw->info.shift); + int samples_till_end_of_buf = hw->samples - hw->rpos; + int samples_to_clip = audio_MIN (len, samples_till_end_of_buf); + + hw->clip (dst, src, samples_to_clip); + + hw->rpos = (hw->rpos + samples_to_clip) % hw->samples; + len -= samples_to_clip; + clipped += samples_to_clip; + } + return clipped; +} + /* * Soft voice (capture) */ diff --git a/audio/audio_int.h b/audio/audio_int.h index ce791ee46c..7ea872926e 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -221,6 +221,9 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len); int audio_pcm_hw_get_live_out (HWVoiceOut *hw); int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live); +int audio_pcm_hw_clip_out (HWVoiceOut *hw, void *pcm_buf, + int live, int pending); + int audio_bug (const char *funcname, int cond); void *audio_calloc (const char *funcname, int nmemb, size_t size); |