mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
add new pa_pstream_get_shm() API, rename pa_pstream_use_shm() to pa_pstream_enable_shm(); pa_bool_t-ization
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2274 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
bee409acbe
commit
687aa295a7
2 changed files with 37 additions and 27 deletions
|
|
@ -98,7 +98,7 @@ struct item_info {
|
||||||
/* packet info */
|
/* packet info */
|
||||||
pa_packet *packet;
|
pa_packet *packet;
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
int with_creds;
|
pa_bool_t with_creds;
|
||||||
pa_creds creds;
|
pa_creds creds;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ struct pa_pstream {
|
||||||
|
|
||||||
pa_queue *send_queue;
|
pa_queue *send_queue;
|
||||||
|
|
||||||
int dead;
|
pa_bool_t dead;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
pa_pstream_descriptor descriptor;
|
pa_pstream_descriptor descriptor;
|
||||||
|
|
@ -141,7 +141,7 @@ struct pa_pstream {
|
||||||
size_t index;
|
size_t index;
|
||||||
} read;
|
} read;
|
||||||
|
|
||||||
int use_shm;
|
pa_bool_t use_shm;
|
||||||
pa_memimport *import;
|
pa_memimport *import;
|
||||||
pa_memexport *export;
|
pa_memexport *export;
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ struct pa_pstream {
|
||||||
|
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
pa_creds read_creds, write_creds;
|
pa_creds read_creds, write_creds;
|
||||||
int read_creds_valid, send_creds_now;
|
pa_bool_t read_creds_valid, send_creds_now;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ pa_pstream *pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *poo
|
||||||
PA_REFCNT_INIT(p);
|
PA_REFCNT_INIT(p);
|
||||||
p->io = io;
|
p->io = io;
|
||||||
pa_iochannel_set_callback(io, io_callback, p);
|
pa_iochannel_set_callback(io, io_callback, p);
|
||||||
p->dead = 0;
|
p->dead = FALSE;
|
||||||
|
|
||||||
p->mainloop = m;
|
p->mainloop = m;
|
||||||
p->defer_event = m->defer_new(m, defer_callback, p);
|
p->defer_event = m->defer_new(m, defer_callback, p);
|
||||||
|
|
@ -269,18 +269,18 @@ pa_pstream *pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *poo
|
||||||
|
|
||||||
p->mempool = pool;
|
p->mempool = pool;
|
||||||
|
|
||||||
p->use_shm = 0;
|
p->use_shm = FALSE;
|
||||||
p->export = NULL;
|
p->export = NULL;
|
||||||
|
|
||||||
/* We do importing unconditionally */
|
/* We do importing unconditionally */
|
||||||
p->import = pa_memimport_new(p->mempool, memimport_release_cb, p);
|
p->import = pa_memimport_new(p->mempool, memimport_release_cb, p);
|
||||||
|
|
||||||
pa_iochannel_socket_set_rcvbuf(io, 1024*8);
|
pa_iochannel_socket_set_rcvbuf(io, pa_mempool_block_size_max(p->mempool));
|
||||||
pa_iochannel_socket_set_sndbuf(io, 1024*8);
|
pa_iochannel_socket_set_sndbuf(io, pa_mempool_block_size_max(p->mempool));
|
||||||
|
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
p->send_creds_now = 0;
|
p->send_creds_now = FALSE;
|
||||||
p->read_creds_valid = 0;
|
p->read_creds_valid = FALSE;
|
||||||
#endif
|
#endif
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +383,7 @@ void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa
|
||||||
i->offset = offset;
|
i->offset = offset;
|
||||||
i->seek_mode = seek_mode;
|
i->seek_mode = seek_mode;
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
i->with_creds = 0;
|
i->with_creds = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_queue_push(p->send_queue, i);
|
pa_queue_push(p->send_queue, i);
|
||||||
|
|
@ -410,7 +410,7 @@ void pa_pstream_send_release(pa_pstream *p, uint32_t block_id) {
|
||||||
item->type = PA_PSTREAM_ITEM_SHMRELEASE;
|
item->type = PA_PSTREAM_ITEM_SHMRELEASE;
|
||||||
item->block_id = block_id;
|
item->block_id = block_id;
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
item->with_creds = 0;
|
item->with_creds = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_queue_push(p->send_queue, item);
|
pa_queue_push(p->send_queue, item);
|
||||||
|
|
@ -447,7 +447,7 @@ void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id) {
|
||||||
item->type = PA_PSTREAM_ITEM_SHMREVOKE;
|
item->type = PA_PSTREAM_ITEM_SHMREVOKE;
|
||||||
item->block_id = block_id;
|
item->block_id = block_id;
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
item->with_creds = 0;
|
item->with_creds = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_queue_push(p->send_queue, item);
|
pa_queue_push(p->send_queue, item);
|
||||||
|
|
@ -504,7 +504,7 @@ static void prepare_next_write_item(pa_pstream *p) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
int send_payload = 1;
|
pa_bool_t send_payload = TRUE;
|
||||||
|
|
||||||
pa_assert(p->write.current->type == PA_PSTREAM_ITEM_MEMBLOCK);
|
pa_assert(p->write.current->type == PA_PSTREAM_ITEM_MEMBLOCK);
|
||||||
pa_assert(p->write.current->chunk.memblock);
|
pa_assert(p->write.current->chunk.memblock);
|
||||||
|
|
@ -529,7 +529,7 @@ static void prepare_next_write_item(pa_pstream *p) {
|
||||||
&length) >= 0) {
|
&length) >= 0) {
|
||||||
|
|
||||||
flags |= PA_FLAG_SHMDATA;
|
flags |= PA_FLAG_SHMDATA;
|
||||||
send_payload = 0;
|
send_payload = FALSE;
|
||||||
|
|
||||||
p->write.shm_info[PA_PSTREAM_SHM_BLOCKID] = htonl(block_id);
|
p->write.shm_info[PA_PSTREAM_SHM_BLOCKID] = htonl(block_id);
|
||||||
p->write.shm_info[PA_PSTREAM_SHM_SHMID] = htonl(shm_id);
|
p->write.shm_info[PA_PSTREAM_SHM_SHMID] = htonl(shm_id);
|
||||||
|
|
@ -599,7 +599,7 @@ static int do_write(pa_pstream *p) {
|
||||||
if ((r = pa_iochannel_write_with_creds(p->io, d, l, &p->write_creds)) < 0)
|
if ((r = pa_iochannel_write_with_creds(p->io, d, l, &p->write_creds)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
p->send_creds_now = 0;
|
p->send_creds_now = FALSE;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -875,7 +875,7 @@ frame_done:
|
||||||
p->read.data = NULL;
|
p->read.data = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_CREDS
|
#ifdef HAVE_CREDS
|
||||||
p->read_creds_valid = 0;
|
p->read_creds_valid = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -935,14 +935,14 @@ void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb,
|
||||||
p->release_callback_userdata = userdata;
|
p->release_callback_userdata = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_pstream_is_pending(pa_pstream *p) {
|
pa_bool_t pa_pstream_is_pending(pa_pstream *p) {
|
||||||
int b;
|
pa_bool_t b;
|
||||||
|
|
||||||
pa_assert(p);
|
pa_assert(p);
|
||||||
pa_assert(PA_REFCNT_VALUE(p) > 0);
|
pa_assert(PA_REFCNT_VALUE(p) > 0);
|
||||||
|
|
||||||
if (p->dead)
|
if (p->dead)
|
||||||
b = 0;
|
b = FALSE;
|
||||||
else
|
else
|
||||||
b = p->write.current || !pa_queue_is_empty(p->send_queue);
|
b = p->write.current || !pa_queue_is_empty(p->send_queue);
|
||||||
|
|
||||||
|
|
@ -971,7 +971,7 @@ void pa_pstream_unlink(pa_pstream *p) {
|
||||||
if (p->dead)
|
if (p->dead)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p->dead = 1;
|
p->dead = TRUE;
|
||||||
|
|
||||||
if (p->import) {
|
if (p->import) {
|
||||||
pa_memimport_free(p->import);
|
pa_memimport_free(p->import);
|
||||||
|
|
@ -999,7 +999,7 @@ void pa_pstream_unlink(pa_pstream *p) {
|
||||||
p->recieve_memblock_callback = NULL;
|
p->recieve_memblock_callback = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_pstream_use_shm(pa_pstream *p, int enable) {
|
void pa_pstream_enable_shm(pa_pstream *p, pa_bool_t enable) {
|
||||||
pa_assert(p);
|
pa_assert(p);
|
||||||
pa_assert(PA_REFCNT_VALUE(p) > 0);
|
pa_assert(PA_REFCNT_VALUE(p) > 0);
|
||||||
|
|
||||||
|
|
@ -1018,3 +1018,10 @@ void pa_pstream_use_shm(pa_pstream *p, int enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_bool_t pa_pstream_get_shm(pa_pstream *p) {
|
||||||
|
pa_assert(p);
|
||||||
|
pa_assert(PA_REFCNT_VALUE(p) > 0);
|
||||||
|
|
||||||
|
return p->use_shm;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include <pulsecore/iochannel.h>
|
#include <pulsecore/iochannel.h>
|
||||||
#include <pulsecore/memchunk.h>
|
#include <pulsecore/memchunk.h>
|
||||||
#include <pulsecore/creds.h>
|
#include <pulsecore/creds.h>
|
||||||
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
typedef struct pa_pstream pa_pstream;
|
typedef struct pa_pstream pa_pstream;
|
||||||
|
|
||||||
|
|
@ -44,8 +45,11 @@ typedef void (*pa_pstream_notify_cb_t)(pa_pstream *p, void *userdata);
|
||||||
typedef void (*pa_pstream_block_id_cb_t)(pa_pstream *p, uint32_t block_id, void *userdata);
|
typedef void (*pa_pstream_block_id_cb_t)(pa_pstream *p, uint32_t block_id, void *userdata);
|
||||||
|
|
||||||
pa_pstream* pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *p);
|
pa_pstream* pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *p);
|
||||||
void pa_pstream_unref(pa_pstream*p);
|
|
||||||
pa_pstream* pa_pstream_ref(pa_pstream*p);
|
pa_pstream* pa_pstream_ref(pa_pstream*p);
|
||||||
|
void pa_pstream_unref(pa_pstream*p);
|
||||||
|
|
||||||
|
void pa_pstream_unlink(pa_pstream *p);
|
||||||
|
|
||||||
void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, const pa_creds *creds);
|
void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, const pa_creds *creds);
|
||||||
void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk);
|
void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk);
|
||||||
|
|
@ -59,10 +63,9 @@ void pa_pstream_set_die_callback(pa_pstream *p, pa_pstream_notify_cb_t cb, void
|
||||||
void pa_pstream_set_release_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata);
|
void pa_pstream_set_release_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata);
|
||||||
void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata);
|
void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata);
|
||||||
|
|
||||||
int pa_pstream_is_pending(pa_pstream *p);
|
pa_bool_t pa_pstream_is_pending(pa_pstream *p);
|
||||||
|
|
||||||
void pa_pstream_use_shm(pa_pstream *p, int enable);
|
void pa_pstream_enable_shm(pa_pstream *p, pa_bool_t enable);
|
||||||
|
pa_bool_t pa_pstream_get_shm(pa_pstream *p);
|
||||||
void pa_pstream_unlink(pa_pstream *p);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue