mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
work around C99/GCC incompatibility
native protocol: add "local" field to pa_context add volume paramter to pa_stream_connect_playback add support for renaming streams/clients support lazy samples add functions to kill clients/source inputs/sink outputs add functions for loading/unloading modules add autoload management API git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@204 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
9ca72dce0b
commit
f5d47a293a
23 changed files with 680 additions and 40 deletions
|
|
@ -84,6 +84,7 @@ struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *
|
|||
c->subscribe_userdata = NULL;
|
||||
|
||||
c->memblock_stat = pa_memblock_stat_new();
|
||||
c->local = -1;
|
||||
|
||||
pa_check_signal_is_blocked(SIGPIPE);
|
||||
return c;
|
||||
|
|
@ -252,7 +253,7 @@ static void setup_complete_callback(struct pa_pdispatch *pd, uint32_t command, u
|
|||
struct pa_tagstruct *t;
|
||||
t = pa_tagstruct_new(NULL, 0);
|
||||
assert(t);
|
||||
pa_tagstruct_putu32(t, PA_COMMAND_SET_NAME);
|
||||
pa_tagstruct_putu32(t, PA_COMMAND_SET_CLIENT_NAME);
|
||||
pa_tagstruct_putu32(t, tag = c->ctag++);
|
||||
pa_tagstruct_puts(t, c->name);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
|
|
@ -383,6 +384,8 @@ static int context_connect_spawn(struct pa_context *c, const struct pa_spawn_api
|
|||
int fds[2] = { -1, -1} ;
|
||||
struct pa_iochannel *io;
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
|
||||
pa_log(__FILE__": socketpair() failed: %s\n", strerror(errno));
|
||||
pa_context_fail(c, PA_ERROR_INTERNAL);
|
||||
|
|
@ -417,7 +420,7 @@ static int context_connect_spawn(struct pa_context *c, const struct pa_spawn_api
|
|||
putenv(t);
|
||||
|
||||
snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
|
||||
execl(p, p, t, NULL);
|
||||
execl(p, p, "--daemonize=yes", "--log-target=syslog", t, NULL);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -439,9 +442,14 @@ static int context_connect_spawn(struct pa_context *c, const struct pa_spawn_api
|
|||
}
|
||||
|
||||
close(fds[1]);
|
||||
|
||||
c->local = 1;
|
||||
|
||||
io = pa_iochannel_new(c->mainloop, fds[0], fds[0]);
|
||||
setup_context(c, io);
|
||||
|
||||
pa_context_unref(c);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
|
@ -450,11 +458,11 @@ fail:
|
|||
if (fds[1] != -1)
|
||||
close(fds[1]);
|
||||
|
||||
pa_context_unref(c);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int pa_context_connect(struct pa_context *c, const char *server, int spawn, const struct pa_spawn_api *api) {
|
||||
int r = -1;
|
||||
assert(c && c->ref >= 1 && c->state == PA_CONTEXT_UNCONNECTED);
|
||||
|
|
@ -483,6 +491,8 @@ int pa_context_connect(struct pa_context *c, const char *server, int spawn, cons
|
|||
pa_context_fail(c, PA_ERROR_CONNECTIONREFUSED);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
c->local = 1;
|
||||
} else {
|
||||
struct sockaddr* sa;
|
||||
size_t sa_len;
|
||||
|
|
@ -499,6 +509,8 @@ int pa_context_connect(struct pa_context *c, const char *server, int spawn, cons
|
|||
pa_context_fail(c, PA_ERROR_CONNECTIONREFUSED);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
c->local = 0;
|
||||
}
|
||||
|
||||
pa_socket_client_set_callback(c->client, on_connection, c);
|
||||
|
|
@ -702,3 +714,28 @@ struct pa_operation* pa_context_set_default_source(struct pa_context *c, const c
|
|||
|
||||
return pa_operation_ref(o);
|
||||
}
|
||||
|
||||
int pa_context_is_local(struct pa_context *c) {
|
||||
assert(c);
|
||||
return c->local;
|
||||
}
|
||||
|
||||
struct pa_operation* pa_context_set_name(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata) {
|
||||
struct pa_tagstruct *t;
|
||||
struct pa_operation *o;
|
||||
uint32_t tag;
|
||||
assert(c && name && cb);
|
||||
|
||||
o = pa_operation_new(c, NULL);
|
||||
o->callback = cb;
|
||||
o->userdata = userdata;
|
||||
|
||||
t = pa_tagstruct_new(NULL, 0);
|
||||
pa_tagstruct_putu32(t, PA_COMMAND_SET_CLIENT_NAME);
|
||||
pa_tagstruct_putu32(t, tag = c->ctag++);
|
||||
pa_tagstruct_puts(t, name);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, o);
|
||||
|
||||
return pa_operation_ref(o);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue