mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
parent
11f95fe11e
commit
486d797735
1 changed files with 15 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ struct sample_play {
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
struct sample *sample;
|
struct sample *sample;
|
||||||
struct pw_stream *stream;
|
struct pw_stream *stream;
|
||||||
|
struct spa_io_rate_match *rate_match;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
struct spa_hook listener;
|
struct spa_hook listener;
|
||||||
struct pw_context *context;
|
struct pw_context *context;
|
||||||
|
|
@ -81,6 +82,16 @@ static void sample_play_stream_state_changed(void *data, enum pw_stream_state ol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sample_play_stream_io_changed(void *data, uint32_t id, void *area, uint32_t size)
|
||||||
|
{
|
||||||
|
struct sample_play *p = data;
|
||||||
|
switch (id) {
|
||||||
|
case SPA_IO_RateMatch:
|
||||||
|
p->rate_match = area;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void sample_play_stream_destroy(void *data)
|
static void sample_play_stream_destroy(void *data)
|
||||||
{
|
{
|
||||||
struct sample_play *p = data;
|
struct sample_play *p = data;
|
||||||
|
|
@ -118,6 +129,8 @@ static void sample_play_stream_process(void *data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size = SPA_MIN(size, buf->datas[0].maxsize);
|
size = SPA_MIN(size, buf->datas[0].maxsize);
|
||||||
|
if (p->rate_match)
|
||||||
|
size = SPA_MIN(size, p->rate_match->size * p->stride);
|
||||||
|
|
||||||
memcpy(d, p->sample->buffer + p->offset, size);
|
memcpy(d, p->sample->buffer + p->offset, size);
|
||||||
|
|
||||||
|
|
@ -139,6 +152,7 @@ static void sample_play_stream_drained(void *data)
|
||||||
struct pw_stream_events sample_play_stream_events = {
|
struct pw_stream_events sample_play_stream_events = {
|
||||||
PW_VERSION_STREAM_EVENTS,
|
PW_VERSION_STREAM_EVENTS,
|
||||||
.state_changed = sample_play_stream_state_changed,
|
.state_changed = sample_play_stream_state_changed,
|
||||||
|
.io_changed = sample_play_stream_io_changed,
|
||||||
.destroy = sample_play_stream_destroy,
|
.destroy = sample_play_stream_destroy,
|
||||||
.process = sample_play_stream_process,
|
.process = sample_play_stream_process,
|
||||||
.drained = sample_play_stream_drained,
|
.drained = sample_play_stream_drained,
|
||||||
|
|
@ -176,6 +190,7 @@ static struct sample_play *sample_play_new(struct pw_core *core,
|
||||||
}
|
}
|
||||||
|
|
||||||
p->sample = sample;
|
p->sample = sample;
|
||||||
|
p->stride = sample_spec_frame_size(&sample->ss);
|
||||||
sample->ref++;
|
sample->ref++;
|
||||||
|
|
||||||
pw_stream_add_listener(p->stream,
|
pw_stream_add_listener(p->stream,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue