mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
core: Make debugging a bit simpler
This takes out a bunch of commented debug prints and puts them in defines. Makes it easier to turn them all on/off at a single point.
This commit is contained in:
parent
80cfa050db
commit
efbfe5fecb
3 changed files with 76 additions and 32 deletions
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
#include "memblockq.h"
|
#include "memblockq.h"
|
||||||
|
|
||||||
|
/* #define MEMBLOCKQ_DEBUG */
|
||||||
|
|
||||||
struct list_item {
|
struct list_item {
|
||||||
struct list_item *next, *prev;
|
struct list_item *next, *prev;
|
||||||
int64_t index;
|
int64_t index;
|
||||||
|
|
@ -262,7 +264,9 @@ static void write_index_changed(pa_memblockq *bq, int64_t old_write_index, pa_bo
|
||||||
else
|
else
|
||||||
bq->missing -= delta;
|
bq->missing -= delta;
|
||||||
|
|
||||||
/* pa_log("pushed/seeked %lli: requested counter at %lli, account=%i", (long long) delta, (long long) bq->requested, account); */
|
#ifdef MEMBLOCKQ_DEBUG
|
||||||
|
pa_log("[%s] pushed/seeked %lli: requested counter at %lli, account=%i", bq->name, (long long) delta, (long long) bq->requested, account);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_index_changed(pa_memblockq *bq, int64_t old_read_index) {
|
static void read_index_changed(pa_memblockq *bq, int64_t old_read_index) {
|
||||||
|
|
@ -273,7 +277,9 @@ static void read_index_changed(pa_memblockq *bq, int64_t old_read_index) {
|
||||||
delta = bq->read_index - old_read_index;
|
delta = bq->read_index - old_read_index;
|
||||||
bq->missing += delta;
|
bq->missing += delta;
|
||||||
|
|
||||||
/* pa_log("popped %lli: missing counter at %lli", (long long) delta, (long long) bq->missing); */
|
#ifdef MEMBLOCKQ_DEBUG
|
||||||
|
pa_log("[%s] popped %lli: missing counter at %lli", bq->name, (long long) delta, (long long) bq->missing);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
|
int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
|
||||||
|
|
@ -832,7 +838,9 @@ size_t pa_memblockq_pop_missing(pa_memblockq *bq) {
|
||||||
|
|
||||||
pa_assert(bq);
|
pa_assert(bq);
|
||||||
|
|
||||||
/* pa_log("pop: %lli", bq->missing); */
|
#ifdef MEMBLOCKQ_DEBUG
|
||||||
|
pa_log("[%s] pop: %lli", bq->name, (long long) bq->missing);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bq->missing <= 0)
|
if (bq->missing <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -842,7 +850,9 @@ size_t pa_memblockq_pop_missing(pa_memblockq *bq) {
|
||||||
bq->requested += bq->missing;
|
bq->requested += bq->missing;
|
||||||
bq->missing = 0;
|
bq->missing = 0;
|
||||||
|
|
||||||
/* pa_log("sent %lli: request counter is at %lli", (long long) l, (long long) bq->requested); */
|
#ifdef MEMBLOCKQ_DEBUG
|
||||||
|
pa_log("[%s] sent %lli: request counter is at %lli", bq->name, (long long) l, (long long) bq->requested);
|
||||||
|
#endif
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@
|
||||||
|
|
||||||
#include "protocol-native.h"
|
#include "protocol-native.h"
|
||||||
|
|
||||||
|
/* #define PROTOCOL_NATIVE_DEBUG */
|
||||||
|
|
||||||
/* Kick a client if it doesn't authenticate within this time */
|
/* Kick a client if it doesn't authenticate within this time */
|
||||||
#define AUTH_TIMEOUT (60 * PA_USEC_PER_SEC)
|
#define AUTH_TIMEOUT (60 * PA_USEC_PER_SEC)
|
||||||
|
|
||||||
|
|
@ -812,14 +814,18 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
|
||||||
pa_tagstruct_putu32(t, (uint32_t) l);
|
pa_tagstruct_putu32(t, (uint32_t) l);
|
||||||
pa_pstream_send_tagstruct(s->connection->pstream, t);
|
pa_pstream_send_tagstruct(s->connection->pstream, t);
|
||||||
|
|
||||||
/* pa_log("Requesting %lu bytes", (unsigned long) l); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("Requesting %lu bytes", (unsigned long) l);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PLAYBACK_STREAM_MESSAGE_UNDERFLOW: {
|
case PLAYBACK_STREAM_MESSAGE_UNDERFLOW: {
|
||||||
pa_tagstruct *t;
|
pa_tagstruct *t;
|
||||||
|
|
||||||
/* pa_log("signalling underflow"); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("signalling underflow");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Report that we're empty */
|
/* Report that we're empty */
|
||||||
t = pa_tagstruct_new(NULL, 0);
|
t = pa_tagstruct_new(NULL, 0);
|
||||||
|
|
@ -895,17 +901,19 @@ static void fix_playback_buffer_attr(playback_stream *s) {
|
||||||
|
|
||||||
pa_assert(s);
|
pa_assert(s);
|
||||||
|
|
||||||
/* pa_log("Client requested: maxlength=%li bytes tlength=%li bytes minreq=%li bytes prebuf=%li bytes", */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
/* (long) s->buffer_attr.maxlength, */
|
pa_log("Client requested: maxlength=%li bytes tlength=%li bytes minreq=%li bytes prebuf=%li bytes",
|
||||||
/* (long) s->buffer_attr.tlength, */
|
(long) s->buffer_attr.maxlength,
|
||||||
/* (long) s->buffer_attr.minreq, */
|
(long) s->buffer_attr.tlength,
|
||||||
/* (long) s->buffer_attr.prebuf); */
|
(long) s->buffer_attr.minreq,
|
||||||
|
(long) s->buffer_attr.prebuf);
|
||||||
|
|
||||||
/* pa_log("Client requested: maxlength=%lu ms tlength=%lu ms minreq=%lu ms prebuf=%lu ms", */
|
pa_log("Client requested: maxlength=%lu ms tlength=%lu ms minreq=%lu ms prebuf=%lu ms",
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.maxlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.maxlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.tlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.tlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.minreq, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.minreq, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.prebuf, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC)); */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.prebuf, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This function will be called from the main thread, before as
|
/* This function will be called from the main thread, before as
|
||||||
* well as after the sink input has been activated using
|
* well as after the sink input has been activated using
|
||||||
|
|
@ -1039,11 +1047,13 @@ static void fix_playback_buffer_attr(playback_stream *s) {
|
||||||
s->buffer_attr.prebuf > max_prebuf)
|
s->buffer_attr.prebuf > max_prebuf)
|
||||||
s->buffer_attr.prebuf = max_prebuf;
|
s->buffer_attr.prebuf = max_prebuf;
|
||||||
|
|
||||||
/* pa_log("Client accepted: maxlength=%lu ms tlength=%lu ms minreq=%lu ms prebuf=%lu ms", */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.maxlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
pa_log("Client accepted: maxlength=%lu ms tlength=%lu ms minreq=%lu ms prebuf=%lu ms",
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.tlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.maxlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.minreq, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC), */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.tlength, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
/* (unsigned long) (pa_bytes_to_usec(s->buffer_attr.prebuf, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC)); */
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.minreq, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC),
|
||||||
|
(unsigned long) (pa_bytes_to_usec(s->buffer_attr.prebuf, &s->sink_input->sample_spec) / PA_USEC_PER_MSEC));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main context */
|
/* Called from main context */
|
||||||
|
|
@ -1190,7 +1200,9 @@ static playback_stream* playback_stream_new(
|
||||||
|
|
||||||
*missing = (uint32_t) pa_memblockq_pop_missing(s->memblockq);
|
*missing = (uint32_t) pa_memblockq_pop_missing(s->memblockq);
|
||||||
|
|
||||||
/* pa_log("missing original: %li", (long int) *missing); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("missing original: %li", (long int) *missing);
|
||||||
|
#endif
|
||||||
|
|
||||||
*ss = s->sink_input->sample_spec;
|
*ss = s->sink_input->sample_spec;
|
||||||
*map = s->sink_input->channel_map;
|
*map = s->sink_input->channel_map;
|
||||||
|
|
@ -1231,7 +1243,9 @@ static void playback_stream_request_bytes(playback_stream *s) {
|
||||||
if (m <= 0)
|
if (m <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* pa_log("request_bytes(%lu)", (unsigned long) m); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("request_bytes(%lu)", (unsigned long) m);
|
||||||
|
#endif
|
||||||
|
|
||||||
previous_missing = pa_atomic_add(&s->missing, (int) m);
|
previous_missing = pa_atomic_add(&s->missing, (int) m);
|
||||||
minreq = pa_memblockq_get_minreq(s->memblockq);
|
minreq = pa_memblockq_get_minreq(s->memblockq);
|
||||||
|
|
@ -1565,7 +1579,9 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
|
||||||
playback_stream_assert_ref(s);
|
playback_stream_assert_ref(s);
|
||||||
pa_assert(chunk);
|
pa_assert(chunk);
|
||||||
|
|
||||||
/* pa_log("%s, pop(): %lu", pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME), (unsigned long) pa_memblockq_get_length(s->memblockq)); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("%s, pop(): %lu", pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME), (unsigned long) pa_memblockq_get_length(s->memblockq));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pa_memblockq_is_readable(s->memblockq))
|
if (pa_memblockq_is_readable(s->memblockq))
|
||||||
s->is_underrun = FALSE;
|
s->is_underrun = FALSE;
|
||||||
|
|
@ -2127,7 +2143,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
|
||||||
pa_tagstruct_putu32(reply, s->sink_input->index);
|
pa_tagstruct_putu32(reply, s->sink_input->index);
|
||||||
pa_tagstruct_putu32(reply, missing);
|
pa_tagstruct_putu32(reply, missing);
|
||||||
|
|
||||||
/* pa_log("initial request is %u", missing); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("initial request is %u", missing);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (c->version >= 9) {
|
if (c->version >= 9) {
|
||||||
/* Since 0.9.0 we support sending the buffer metrics back to the client */
|
/* Since 0.9.0 we support sending the buffer metrics back to the client */
|
||||||
|
|
@ -4713,7 +4731,9 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pa_log("got %lu bytes", (unsigned long) chunk->length); */
|
#ifdef PROTOCOL_NATIVE_DEBUG
|
||||||
|
pa_log("got %lu bytes from client", (unsigned long) chunk->length);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (playback_stream_isinstance(stream)) {
|
if (playback_stream_isinstance(stream)) {
|
||||||
playback_stream *ps = PLAYBACK_STREAM(stream);
|
playback_stream *ps = PLAYBACK_STREAM(stream);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@
|
||||||
|
|
||||||
#include "sink-input.h"
|
#include "sink-input.h"
|
||||||
|
|
||||||
|
/* #define SINK_INPUT_DEBUG */
|
||||||
|
|
||||||
#define MEMBLOCKQ_MAXLENGTH (32*1024*1024)
|
#define MEMBLOCKQ_MAXLENGTH (32*1024*1024)
|
||||||
#define CONVERT_BUFFER_LENGTH (PA_PAGE_SIZE)
|
#define CONVERT_BUFFER_LENGTH (PA_PAGE_SIZE)
|
||||||
|
|
||||||
|
|
@ -791,7 +793,9 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p
|
||||||
pa_assert(chunk);
|
pa_assert(chunk);
|
||||||
pa_assert(volume);
|
pa_assert(volume);
|
||||||
|
|
||||||
/* pa_log_debug("peek"); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("peek");
|
||||||
|
#endif
|
||||||
|
|
||||||
block_size_max_sink_input = i->thread_info.resampler ?
|
block_size_max_sink_input = i->thread_info.resampler ?
|
||||||
pa_resampler_max_block_size(i->thread_info.resampler) :
|
pa_resampler_max_block_size(i->thread_info.resampler) :
|
||||||
|
|
@ -897,7 +901,9 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p
|
||||||
pa_memchunk rchunk;
|
pa_memchunk rchunk;
|
||||||
pa_resampler_run(i->thread_info.resampler, &wchunk, &rchunk);
|
pa_resampler_run(i->thread_info.resampler, &wchunk, &rchunk);
|
||||||
|
|
||||||
/* pa_log_debug("pushing %lu", (unsigned long) rchunk.length); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("pushing %lu", (unsigned long) rchunk.length);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (rchunk.memblock) {
|
if (rchunk.memblock) {
|
||||||
|
|
||||||
|
|
@ -925,7 +931,9 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p
|
||||||
pa_assert(chunk->length > 0);
|
pa_assert(chunk->length > 0);
|
||||||
pa_assert(chunk->memblock);
|
pa_assert(chunk->memblock);
|
||||||
|
|
||||||
/* pa_log_debug("peeking %lu", (unsigned long) chunk->length); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("peeking %lu", (unsigned long) chunk->length);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (chunk->length > block_size_max_sink)
|
if (chunk->length > block_size_max_sink)
|
||||||
chunk->length = block_size_max_sink;
|
chunk->length = block_size_max_sink;
|
||||||
|
|
@ -952,7 +960,9 @@ void pa_sink_input_drop(pa_sink_input *i, size_t nbytes /* in sink sample spec *
|
||||||
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
|
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
|
||||||
pa_assert(nbytes > 0);
|
pa_assert(nbytes > 0);
|
||||||
|
|
||||||
/* pa_log_debug("dropping %lu", (unsigned long) nbytes); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("dropping %lu", (unsigned long) nbytes);
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_memblockq_drop(i->thread_info.render_memblockq, nbytes);
|
pa_memblockq_drop(i->thread_info.render_memblockq, nbytes);
|
||||||
}
|
}
|
||||||
|
|
@ -967,7 +977,9 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam
|
||||||
pa_assert(PA_SINK_INPUT_IS_LINKED(i->thread_info.state));
|
pa_assert(PA_SINK_INPUT_IS_LINKED(i->thread_info.state));
|
||||||
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
|
pa_assert(pa_frame_aligned(nbytes, &i->sink->sample_spec));
|
||||||
|
|
||||||
/* pa_log_debug("rewind(%lu, %lu)", (unsigned long) nbytes, (unsigned long) i->thread_info.rewrite_nbytes); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("rewind(%lu, %lu)", (unsigned long) nbytes, (unsigned long) i->thread_info.rewrite_nbytes);
|
||||||
|
#endif
|
||||||
|
|
||||||
lbq = pa_memblockq_get_length(i->thread_info.render_memblockq);
|
lbq = pa_memblockq_get_length(i->thread_info.render_memblockq);
|
||||||
|
|
||||||
|
|
@ -1896,7 +1908,9 @@ void pa_sink_input_request_rewind(
|
||||||
|
|
||||||
nbytes = PA_MAX(i->thread_info.rewrite_nbytes, nbytes);
|
nbytes = PA_MAX(i->thread_info.rewrite_nbytes, nbytes);
|
||||||
|
|
||||||
/* pa_log_debug("request rewrite %zu", nbytes); */
|
#ifdef SINK_INPUT_DEBUG
|
||||||
|
pa_log_debug("request rewrite %zu", nbytes);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Calculate how much we can rewind locally without having to
|
/* Calculate how much we can rewind locally without having to
|
||||||
* touch the sink */
|
* touch the sink */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue