本文整理汇总了C++中pa_memblock_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ pa_memblock_unref函数的具体用法?C++ pa_memblock_unref怎么用?C++ pa_memblock_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pa_memblock_unref函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_render
static void process_render(struct userdata *u, pa_usec_t now) {
pa_memchunk chunk;
int request_bytes;
//int index;
pa_assert(u);
if (u->got_max_latency) {
return;
}
//index = 0;
while (u->timestamp < now + u->block_usec) {
//index++;
//if (index > 3) {
/* used when u->block_usec and
u->sink->thread_info.max_request get big
using got_max_latency now */
// return;
//}
request_bytes = u->sink->thread_info.max_request;
request_bytes = MIN(request_bytes, 16 * 1024);
pa_sink_render(u->sink, request_bytes, &chunk);
//pa_log("bytes %d index %d", chunk.length, index);
data_send(u, &chunk);
pa_memblock_unref(chunk.memblock);
u->timestamp += pa_bytes_to_usec(chunk.length, &u->sink->sample_spec);
}
}
示例2: pa__done
void pa__done(pa_module*m) {
struct userdata *u;
pa_assert(m);
if (!(u = m->userdata))
return;
if (u->sink)
pa_sink_unlink(u->sink);
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
pa_thread_free(u->thread);
}
pa_thread_mq_done(&u->thread_mq);
if (u->sink)
pa_sink_unref(u->sink);
if (u->rtpoll_item)
pa_rtpoll_item_free(u->rtpoll_item);
if (u->rtpoll)
pa_rtpoll_free(u->rtpoll);
if (u->raw_memchunk.memblock)
pa_memblock_unref(u->raw_memchunk.memblock);
if (u->encoded_memchunk.memblock)
pa_memblock_unref(u->encoded_memchunk.memblock);
if (u->raop)
pa_raop_client_free(u->raop);
pa_xfree(u->read_data);
pa_xfree(u->write_data);
if (u->smoother)
pa_smoother_free(u->smoother);
if (u->fd >= 0)
pa_close(u->fd);
pa_xfree(u);
}
示例3: while
static void *mi6k_render_thread(void *userdata)
{
while (1) {
pa_memchunk chunk;
int i;
int is_empty = 1;
static int sleeptimer = 0;
i = pa_memblockq_peek(mi6k.queue, &chunk);
/*
* Before writing this chunk, let's see if there's anything
* printable in it. For our purposes, these include
* special characters but not control characters: thus, anything
* above the space.
*/
for (i=0; i<chunk.length; i++) {
int c = ((unsigned char*)chunk.memblock->data)[chunk.index + i];
if (c > ' ') {
is_empty = 0;
}
}
if (is_empty) {
if (mi6k.power) {
/*
* We're rendering blank frames. Our sleep timer counts down...
* If we stay blank for quite a while, power down the VFD.
*/
if (++sleeptimer > AUTO_OFF_FRAMES) {
mi6k_set_power(0);
}
}
} else {
sleeptimer = 0;
if (!mi6k.power) {
/*
* We're rendering non-blank frames, but the display is off.
* Turn on the juice, wait for it to start up, then do our initialization.
*/
mi6k_set_power(1);
usleep(200000);
mi6k_init_hardware();
}
}
fwrite(chunk.memblock->data + chunk.index, 1, chunk.length, mi6k.device);
fflush(mi6k.device);
pa_memblock_unref(chunk.memblock);
pa_memblockq_drop(mi6k.queue, &chunk, chunk.length);
}
return NULL;
}
示例4: do_read
static int do_read(connection *c) {
pa_memchunk chunk;
ssize_t r;
size_t l;
void *p;
size_t space = 0;
connection_assert_ref(c);
if (!c->sink_input || (l = (size_t) pa_atomic_load(&c->playback.missing)) <= 0)
return 0;
if (c->playback.current_memblock) {
space = pa_memblock_get_length(c->playback.current_memblock) - c->playback.memblock_index;
if (space <= 0) {
pa_memblock_unref(c->playback.current_memblock);
c->playback.current_memblock = NULL;
}
}
if (!c->playback.current_memblock) {
pa_assert_se(c->playback.current_memblock = pa_memblock_new(c->protocol->core->mempool, (size_t) -1));
c->playback.memblock_index = 0;
space = pa_memblock_get_length(c->playback.current_memblock);
}
if (l > space)
l = space;
p = pa_memblock_acquire(c->playback.current_memblock);
r = pa_iochannel_read(c->io, (uint8_t*) p + c->playback.memblock_index, l);
pa_memblock_release(c->playback.current_memblock);
if (r <= 0) {
if (r < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
pa_log_debug("read(): %s", r == 0 ? "EOF" : pa_cstrerror(errno));
return -1;
}
chunk.memblock = c->playback.current_memblock;
chunk.index = c->playback.memblock_index;
chunk.length = (size_t) r;
c->playback.memblock_index += (size_t) r;
pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, &chunk, NULL);
pa_atomic_sub(&c->playback.missing, (int) r);
return 0;
}
示例5: pa_memblock_unref_fixed
/* No lock necessary. This function is not multiple caller safe*/
void pa_memblock_unref_fixed(pa_memblock *b) {
pa_assert(b);
pa_assert(PA_REFCNT_VALUE(b) > 0);
pa_assert(b->type == PA_MEMBLOCK_FIXED);
if (PA_REFCNT_VALUE(b) > 1)
memblock_make_local(b);
pa_memblock_unref(b);
}
示例6: pa_silence_cache_done
void pa_silence_cache_done(pa_silence_cache *cache) {
pa_sample_format_t f;
pa_assert(cache);
for (f = 0; f < PA_SAMPLE_MAX; f++)
if (cache->blocks[f])
pa_memblock_unref(cache->blocks[f]);
memset(cache, 0, sizeof(pa_silence_cache));
}
示例7: do_read
static void do_read(struct userdata *u) {
uint32_t free_frags;
pa_memchunk memchunk;
WAVEHDR *hdr;
MMRESULT res;
void *p;
if (!u->source)
return;
if (!PA_SOURCE_IS_LINKED(u->source->state))
return;
EnterCriticalSection(&u->crit);
free_frags = u->free_ifrags;
u->free_ifrags = 0;
LeaveCriticalSection(&u->crit);
if (free_frags == u->fragments)
pa_log_debug("WaveIn overflow!");
while (free_frags) {
hdr = &u->ihdrs[u->cur_ihdr];
if (hdr->dwFlags & WHDR_PREPARED)
waveInUnprepareHeader(u->hwi, hdr, sizeof(WAVEHDR));
if (hdr->dwBytesRecorded) {
memchunk.memblock = pa_memblock_new(u->core->mempool, hdr->dwBytesRecorded);
pa_assert(memchunk.memblock);
p = pa_memblock_acquire(memchunk.memblock);
memcpy((char*) p, hdr->lpData, hdr->dwBytesRecorded);
pa_memblock_release(memchunk.memblock);
memchunk.length = hdr->dwBytesRecorded;
memchunk.index = 0;
pa_source_post(u->source, &memchunk);
pa_memblock_unref(memchunk.memblock);
}
res = waveInPrepareHeader(u->hwi, hdr, sizeof(WAVEHDR));
if (res != MMSYSERR_NOERROR)
pa_log_error("Unable to prepare waveIn block: %d", res);
res = waveInAddBuffer(u->hwi, hdr, sizeof(WAVEHDR));
if (res != MMSYSERR_NOERROR)
pa_log_error("Unable to add waveIn block: %d", res);
free_frags--;
u->cur_ihdr++;
u->cur_ihdr %= u->fragments;
}
}
示例8: thread_func
static void thread_func(void *userdata) {
struct userdata *u = userdata;
pa_assert(u);
pa_log_debug("Thread starting up");
pa_thread_mq_install(&u->thread_mq);
u->timestamp = pa_rtclock_now();
for (;;) {
int ret;
/* Generate some null data */
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
pa_usec_t now;
pa_memchunk chunk;
now = pa_rtclock_now();
if ((chunk.length = pa_usec_to_bytes(now - u->timestamp, &u->source->sample_spec)) > 0) {
chunk.memblock = pa_memblock_new(u->core->mempool, (size_t) -1); /* or chunk.length? */
chunk.index = 0;
pa_source_post(u->source, &chunk);
pa_memblock_unref(chunk.memblock);
u->timestamp = now;
}
pa_rtpoll_set_timer_absolute(u->rtpoll, u->timestamp + u->latency_time * PA_USEC_PER_MSEC);
} else
pa_rtpoll_set_timer_disabled(u->rtpoll);
/* Hmm, nothing to do. Let's sleep */
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
goto fail;
if (ret == 0)
goto finish;
}
fail:
/* If this was no regular exit from the loop we have to continue
* processing messages until we received PA_MESSAGE_SHUTDOWN */
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
finish:
pa_log_debug("Thread shutting down");
}
示例9: free_entry
static void free_entry(pa_scache_entry *e) {
pa_assert(e);
pa_namereg_unregister(e->core, e->name);
pa_subscription_post(e->core, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_REMOVE, e->index);
pa_xfree(e->name);
pa_xfree(e->filename);
if (e->memchunk.memblock)
pa_memblock_unref(e->memchunk.memblock);
if (e->proplist)
pa_proplist_free(e->proplist);
pa_xfree(e);
}
示例10: cmtspeech_sink_input_reset_dl_stream
/* Called from I/O thread context */
static void cmtspeech_sink_input_reset_dl_stream(struct userdata *u) {
cmtspeech_dl_buf_t *buf;
pa_assert(u);
/* Flush all DL buffers */
pa_memblockq_flush_read(u->dl_memblockq);
cmtspeech_dl_sideinfo_flush(u);
while ((buf = pa_asyncq_pop(u->cmt_connection.dl_frame_queue, FALSE))) {
pa_memchunk cmtchunk;
if (0 == cmtspeech_buffer_to_memchunk(u, buf, &cmtchunk))
pa_memblock_unref(cmtchunk.memblock);
}
}
示例11: pa__done
void pa__done(pa_module *m) {
struct userdata *u;
pa_assert(m);
if (!(u = m->userdata))
return;
if (u->sig) {
ioctl(u->fd, I_SETSIG, 0);
pa_signal_free(u->sig);
}
if (u->sink)
pa_sink_unlink(u->sink);
if (u->source)
pa_source_unlink(u->source);
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
pa_thread_free(u->thread);
}
pa_thread_mq_done(&u->thread_mq);
if (u->sink)
pa_sink_unref(u->sink);
if (u->source)
pa_source_unref(u->source);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
if (u->rtpoll_item)
pa_rtpoll_item_free(u->rtpoll_item);
if (u->rtpoll)
pa_rtpoll_free(u->rtpoll);
if (u->fd >= 0)
close(u->fd);
if (u->smoother)
pa_smoother_free(u->smoother);
pa_xfree(u->device_name);
pa_xfree(u);
}
示例12: pa_memblockq_free
void pa_memblockq_free(pa_memblockq* bq) {
pa_assert(bq);
pa_memblockq_silence(bq);
if (bq->silence.memblock)
pa_memblock_unref(bq->silence.memblock);
if (bq->mcalign)
pa_mcalign_free(bq->mcalign);
pa_xfree(bq->name);
pa_xfree(bq);
}
示例13: connection_free
static void connection_free(pa_object *o) {
connection *c = CONNECTION(o);
pa_assert(c);
if (c->playback.current_memblock)
pa_memblock_unref(c->playback.current_memblock);
if (c->input_memblockq)
pa_memblockq_free(c->input_memblockq);
if (c->output_memblockq)
pa_memblockq_free(c->output_memblockq);
pa_xfree(c);
}
示例14: pa_raop_packet_buffer_free
void pa_raop_packet_buffer_free(pa_raop_packet_buffer *pb) {
size_t i;
pa_assert(pb);
for (i = 0; pb->packets && i < pb->size; i++) {
if (pb->packets[i].memblock)
pa_memblock_unref(pb->packets[i].memblock);
pa_memchunk_reset(&pb->packets[i]);
}
pa_xfree(pb->packets);
pb->packets = NULL;
pa_xfree(pb);
}
示例15: pa_raop_packet_buffer_reset
void pa_raop_packet_buffer_reset(pa_raop_packet_buffer *pb, uint16_t seq) {
size_t i;
pa_assert(pb);
pa_assert(pb->packets);
pb->pos = 0;
pb->count = 0;
pb->seq = (!seq) ? UINT16_MAX : seq - 1;
for (i = 0; i < pb->size; i++) {
if (pb->packets[i].memblock)
pa_memblock_unref(pb->packets[i].memblock);
pa_memchunk_reset(&pb->packets[i]);
}
}