mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-18 08:56:40 -05:00
Implement PA_SOURCE_MESSAGE_GET_LATENCY
The pipe source needs to implement PA_SOURCE_MESSAGE_GET_LATENCY since we'll otherwise hit an assert. Closes #424.
This commit is contained in:
parent
10cc4ba1ca
commit
606c9caa0b
1 changed files with 30 additions and 0 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
@ -89,6 +90,34 @@ static const char* const valid_modargs[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int source_process_msg(
|
||||||
|
pa_msgobject *o,
|
||||||
|
int code,
|
||||||
|
void *data,
|
||||||
|
int64_t offset,
|
||||||
|
pa_memchunk *chunk) {
|
||||||
|
|
||||||
|
struct userdata *u = PA_SOURCE(o)->userdata;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
|
||||||
|
case PA_SOURCE_MESSAGE_GET_LATENCY: {
|
||||||
|
size_t n = 0;
|
||||||
|
int l;
|
||||||
|
|
||||||
|
#ifdef FIONREAD
|
||||||
|
if (ioctl(u->fd, FIONREAD, &l) >= 0 && l > 0)
|
||||||
|
n = (size_t) l;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
*((pa_usec_t*) data) = pa_bytes_to_usec(n, &u->source->sample_spec);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pa_source_process_msg(o, code, data, offset, chunk);
|
||||||
|
}
|
||||||
|
|
||||||
static void thread_func(void *userdata) {
|
static void thread_func(void *userdata) {
|
||||||
struct userdata *u = userdata;
|
struct userdata *u = userdata;
|
||||||
int read_type = 0;
|
int read_type = 0;
|
||||||
|
|
@ -243,6 +272,7 @@ int pa__init(pa_module*m) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u->source->parent.process_msg = source_process_msg;
|
||||||
u->source->userdata = u;
|
u->source->userdata = u;
|
||||||
|
|
||||||
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
|
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue