]> code.delx.au - pulseaudio/blobdiff - src/modules/bluetooth/module-bluez5-device.c
bluetooth: Change BlueZ 5 card profile name from a2dp to a2dp_sink
[pulseaudio] / src / modules / bluetooth / module-bluez5-device.c
index 287e763979ec2321b23e735c527c322ca78d57b5..19673257ce14bd30606cf25c9f1bdac5ecb3a32b 100644 (file)
@@ -402,6 +402,7 @@ static int a2dp_process_push(struct userdata *u) {
         void *d;
         ssize_t l;
         size_t to_write, to_decode;
+        size_t total_written = 0;
 
         a2dp_prepare_buffer(u);
 
@@ -428,17 +429,12 @@ static int a2dp_process_push(struct userdata *u) {
 
         pa_assert((size_t) l <= sbc_info->buffer_size);
 
-        u->read_index += (uint64_t) l;
-
         /* TODO: get timestamp from rtp */
         if (!found_tstamp) {
             /* pa_log_warn("Couldn't find SO_TIMESTAMP data in auxiliary recvmsg() data!"); */
             tstamp = pa_rtclock_now();
         }
 
-        pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
-        pa_smoother_resume(u->read_smoother, tstamp, true);
-
         p = (uint8_t*) sbc_info->buffer + sizeof(*header) + sizeof(*payload);
         to_decode = l - sizeof(*header) - sizeof(*payload);
 
@@ -458,9 +454,11 @@ static int a2dp_process_push(struct userdata *u) {
                 pa_log_error("SBC decoding error (%li)", (long) decoded);
                 pa_memblock_release(memchunk.memblock);
                 pa_memblock_unref(memchunk.memblock);
-                return -1;
+                return 0;
             }
 
+            total_written += written;
+
             /* Reset frame length, it can be changed due to bitpool change */
             sbc_info->frame_length = sbc_get_frame_length(&sbc_info->sbc);
 
@@ -476,6 +474,10 @@ static int a2dp_process_push(struct userdata *u) {
             to_write -= written;
         }
 
+        u->read_index += (uint64_t) total_written;
+        pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
+        pa_smoother_resume(u->read_smoother, tstamp, true);
+
         memchunk.length -= to_write;
 
         pa_memblock_release(memchunk.memblock);
@@ -1095,10 +1097,12 @@ static void thread_func(void *userdata) {
                 if (n_read < 0)
                     goto io_fail;
 
-                /* We just read something, so we are supposed to write something, too */
-                pending_read_bytes += n_read;
-                do_write += pending_read_bytes / u->write_block_size;
-                pending_read_bytes = pending_read_bytes % u->write_block_size;
+                if (n_read > 0) {
+                    /* We just read something, so we are supposed to write something, too */
+                    pending_read_bytes += n_read;
+                    do_write += pending_read_bytes / u->write_block_size;
+                    pending_read_bytes = pending_read_bytes % u->write_block_size;
+                }
             }
         }
 
@@ -1520,9 +1524,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
     pa_assert_se(output_port = pa_hashmap_get(ports, u->output_port_name));
 
     if (pa_streq(uuid, PA_BLUETOOTH_UUID_A2DP_SINK)) {
-       /* TODO: Change this profile's name to a2dp_sink, to reflect the remote
-         * device's role and be consistent with the a2dp source profile */
-        cp = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP Sink)"), sizeof(pa_bluetooth_profile_t));
+        cp = pa_card_profile_new("a2dp_sink", _("High Fidelity Playback (A2DP Sink)"), sizeof(pa_bluetooth_profile_t));
         cp->priority = 10;
         cp->n_sinks = 1;
         cp->n_sources = 0;