mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-21 21:17:19 +00:00
[client] audio: move the memory copy into the pull function
This commit is contained in:
parent
99536eaf9d
commit
15f76339c8
@ -106,8 +106,7 @@ static void pipewire_onPlaybackProcess(void * userdata)
|
||||
if (pw.playback.rateMatch && pw.playback.rateMatch->size > 0)
|
||||
frames = min(frames, pw.playback.rateMatch->size);
|
||||
|
||||
uint8_t * data;
|
||||
frames = pw.playback.pullFn(&data, frames);
|
||||
frames = pw.playback.pullFn(dst, frames);
|
||||
if (!frames)
|
||||
{
|
||||
if (pw.playback.state == STREAM_STATE_FLUSHING)
|
||||
@ -123,8 +122,6 @@ static void pipewire_onPlaybackProcess(void * userdata)
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst, data, frames * pw.playback.stride);
|
||||
|
||||
sbuf->datas[0].chunk->offset = 0;
|
||||
sbuf->datas[0].chunk->stride = pw.playback.stride;
|
||||
sbuf->datas[0].chunk->size = frames * pw.playback.stride;
|
||||
|
@ -220,14 +220,13 @@ static void pulseaudio_free(void)
|
||||
|
||||
static void pulseaudio_write_cb(pa_stream * p, size_t nbytes, void * userdata)
|
||||
{
|
||||
uint8_t * dst, * src;
|
||||
uint8_t * dst;
|
||||
|
||||
pa_stream_begin_write(p, (void **)&dst, &nbytes);
|
||||
|
||||
int frames = nbytes / pa.sinkStride;
|
||||
frames = pa.sinkPullFn(&src, frames);
|
||||
frames = pa.sinkPullFn(dst, frames);
|
||||
|
||||
memcpy(dst, src, frames * pa.sinkStride);
|
||||
pa_stream_write(p, dst, frames * pa.sinkStride, NULL, 0, PA_SEEK_RELATIVE);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef int (*LG_AudioPullFn)(uint8_t ** data, int frames);
|
||||
typedef void (*LG_AudioPushFn)(uint8_t * data, int frames);
|
||||
typedef int (*LG_AudioPullFn)(uint8_t * dst, int frames);
|
||||
typedef void (*LG_AudioPushFn)(uint8_t * src, int frames);
|
||||
|
||||
struct LG_AudioDevOps
|
||||
{
|
||||
|
@ -131,10 +131,21 @@ void playbackStopNL(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int playbackPullFrames(uint8_t ** data, int frames)
|
||||
static int playbackPullFrames(uint8_t * dst, int frames)
|
||||
{
|
||||
if (audio.playback.buffer)
|
||||
*data = ringbuffer_consume(audio.playback.buffer, &frames);
|
||||
{
|
||||
frames = min(frames, ringbuffer_getCount(audio.playback.buffer));
|
||||
for(int fetched = 0; fetched < frames; )
|
||||
{
|
||||
int copy = frames - fetched;
|
||||
uint8_t * src = ringbuffer_consume(audio.playback.buffer, ©);
|
||||
|
||||
memcpy(dst, src, copy * audio.playback.stride);
|
||||
dst += copy * audio.playback.stride;
|
||||
fetched += copy;
|
||||
}
|
||||
}
|
||||
else
|
||||
frames = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user