mirror of
https://github.com/libretro/RetroArch
synced 2024-12-26 03:22:56 +00:00
(Audio/PipeWire) Fill rest buffer with silence. (#17272)
Formatting, fix typo
This commit is contained in:
parent
963ffc0e77
commit
0ae2b87c57
@ -481,7 +481,7 @@ vaguerant
|
||||
Val Packett (valpackett)
|
||||
Valerio Proietti (kamicane)
|
||||
vgmoose
|
||||
Viachaslau Khalikn (viachaslavic)
|
||||
Viachaslau Khalikin (viachaslavic)
|
||||
Vicki Pfau (endrift)
|
||||
Vicky C Lau (vickychenglau)
|
||||
vin (suseme)
|
||||
|
@ -66,6 +66,15 @@ typedef struct
|
||||
struct string_list *devicelist;
|
||||
} pw_t;
|
||||
|
||||
void clear_buf(void *buf, int len)
|
||||
{
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
memset(buf, 0x00, len);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels)
|
||||
{
|
||||
uint32_t sample_size = 1;
|
||||
@ -145,7 +154,7 @@ static void on_process(void *data)
|
||||
|
||||
if ((b = pw_stream_dequeue_buffer(pw->stream)) == NULL)
|
||||
{
|
||||
RARCH_WARN("[PipeWire]: Out of buffers: %s", strerror(errno));
|
||||
RARCH_WARN("[PipeWire]: Out of buffers: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,6 +174,10 @@ static void on_process(void *data)
|
||||
/* get no of available bytes to read data from buffer */
|
||||
avail = spa_ringbuffer_get_read_index(&pw->ring, &index);
|
||||
|
||||
if (avail <= 0)
|
||||
clear_buf(p, n_bytes);
|
||||
else
|
||||
{
|
||||
if (avail < (int32_t)n_bytes)
|
||||
n_bytes = avail;
|
||||
|
||||
@ -174,6 +187,7 @@ static void on_process(void *data)
|
||||
|
||||
index += n_bytes;
|
||||
spa_ringbuffer_read_update(&pw->ring, index);
|
||||
}
|
||||
|
||||
buf->datas[0].chunk->offset = 0;
|
||||
buf->datas[0].chunk->stride = pw->frame_size;
|
||||
@ -309,15 +323,17 @@ static void registry_event_global(void *data, uint32_t id,
|
||||
}
|
||||
else if (spa_streq(type, PW_TYPE_INTERFACE_Node))
|
||||
{
|
||||
const char* media = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
|
||||
media = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
|
||||
if (media && strcmp(media, "Audio/Sink") == 0)
|
||||
{
|
||||
sink = spa_dict_lookup(props, PW_KEY_NODE_NAME);
|
||||
if ((sink = spa_dict_lookup(props, PW_KEY_NODE_NAME)) != NULL)
|
||||
{
|
||||
attr.i = id;
|
||||
string_list_append(pw->devicelist, sink, attr);
|
||||
RARCH_LOG("[PipeWire]: Found Sink: %s\n", sink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const struct spa_dict_item *item;
|
||||
|
Loading…
Reference in New Issue
Block a user