[PATCH 52/56] bluetooth: Create I/O thread function for BlueZ 5 cards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2013-07-12 at 15:07 -0300, jprvita at gmail.com wrote:
> +/* Run from IO thread */
> +static int a2dp_process_push(struct userdata *u) {
> +    int ret = 0;
> +    pa_memchunk memchunk;
> +
> +    pa_assert(u);
> +    pa_assert(u->profile == PROFILE_A2DP_SOURCE);
> +    pa_assert(u->source);
> +    pa_assert(u->read_smoother);
> +
> +    memchunk.memblock = pa_memblock_new(u->core->mempool, u->read_block_size);
> +    memchunk.index = memchunk.length = 0;
> +
> +    for (;;) {
> +        bool found_tstamp = false;
> +        pa_usec_t tstamp;
> +        struct sbc_info *sbc_info;
> +        struct rtp_header *header;
> +        struct rtp_payload *payload;
> +        const void *p;
> +        void *d;
> +        ssize_t l;
> +        size_t to_write, to_decode;
> +
> +        a2dp_prepare_buffer(u);
> +
> +        sbc_info = &u->sbc_info;
> +        header = sbc_info->buffer;
> +        payload = (struct rtp_payload*) ((uint8_t*) sbc_info->buffer + sizeof(*header));
> +
> +        l = pa_read(u->stream_fd, sbc_info->buffer, sbc_info->buffer_size, &u->stream_write_type);
> +
> +        if (l <= 0) {
> +
> +            if (l < 0 && errno == EINTR)
> +                /* Retry right away if we got interrupted */
> +                continue;
> +
> +            else if (l < 0 && errno == EAGAIN)
> +                /* Hmm, apparently the socket was not readable, give up for now. */
> +                break;
> +
> +            pa_log_error("Failed to read data from socket: %s", l < 0 ? pa_cstrerror(errno) : "EOF");
> +            ret = -1;
> +            break;
> +        }
> +
> +        pa_assert((size_t) l <= sbc_info->buffer_size);
> +
> +        u->read_index += (uint64_t) l;

This is wrong. read_index is occasionally converted to time, which means
that read_index should count the PCM bytes. However, l is the number of
bytes read from the socket, and that data contains the rtp headers, and
the audio data isn't in PCM format either.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux