[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-87-ga714861

Lennart Poettering gitmailer-noreply at 0pointer.de
Fri May 8 13:50:08 PDT 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  7f767e5fe660ced7e1cb0207ef0477818152d833 (commit)

- Log -----------------------------------------------------------------
a714861 channelmap: add pa_channel_map_has_position()
44e566a bluetooth-device: Add safe guard against BT streaming irregularities.
-----------------------------------------------------------------------

Summary of changes:
 src/modules/bluetooth/module-bluetooth-device.c |   30 ++++++++++++++++++++--
 src/pulse/channelmap.c                          |   13 ++++++++++
 src/pulse/channelmap.h                          |    4 +++
 3 files changed, 44 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------

commit 44e566ade8a62163007780f7f81b514705e3233b
Author: Jyri Sarha <jyri.sarha at nokia.com>
Date:   Fri May 8 13:25:21 2009 +0300

    bluetooth-device: Add safe guard against BT streaming irregularities.
    
    Some bad quality BT-headsets block bluez socket sometimes for hundreds
    of milliseconds, especially when changing mode. When the module tries
    catch up the lost time it may SBC encode up to half a second of audio
    without yielding. On slow machine this may cause maximum RT time slice
    to be exceeded. Cleaned out the minor fix that slipped into first version
    of the patch.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index c5c55a1..812b0ba 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -174,6 +174,8 @@ struct userdata {
 #define FIXED_LATENCY_PLAYBACK_HSP (125*PA_USEC_PER_MSEC)
 #define FIXED_LATENCY_RECORD_HSP (25*PA_USEC_PER_MSEC)
 
+#define MAX_PLAYBACK_CATCH_UP_USEC (100*PA_USEC_PER_MSEC)
+
 #ifdef NOKIA
 #define USE_SCO_OVER_PCM(u) (u->profile == PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source))
 #endif
@@ -1296,15 +1298,37 @@ static void thread_func(void *userdata) {
 
                 if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0 && writable) {
                     pa_usec_t time_passed;
-                    uint64_t should_have_written;
+                    pa_usec_t audio_sent;
 
                     /* Hmm, there is no input stream we could synchronize
                      * to. So let's do things by time */
 
                     time_passed = pa_rtclock_usec() - u->started_at;
-                    should_have_written = pa_usec_to_bytes(time_passed, &u->sample_spec);
+                    audio_sent = pa_bytes_to_usec(u->write_index, &u->sample_spec);
+
+                    if (audio_sent <= time_passed) {
+                        pa_usec_t audio_to_send = time_passed - audio_sent;
+
+                        /* Never try to catch up for more than 100ms */
+                        if (u->write_index > 0 && audio_to_send > MAX_PLAYBACK_CATCH_UP_USEC) {
+                            pa_usec_t skip_usec;
+                            uint64_t skip_bytes;
+                            pa_memchunk tmp;
+
+                            skip_usec = audio_to_send - MAX_PLAYBACK_CATCH_UP_USEC;
+                            skip_bytes = pa_usec_to_bytes(skip_usec, &u->sample_spec);
 
-                    do_write = u->write_index <= should_have_written;
+                            pa_log_warn("Skipping %llu us (= %llu bytes) in audio stream",
+                                        (unsigned long long) skip_usec,
+                                        (unsigned long long) skip_bytes);
+
+                            pa_sink_render_full(u->sink, skip_bytes, &tmp);
+                            pa_memblock_unref(tmp.memblock);
+                            u->write_index += skip_bytes;
+                        }
+
+                        do_write = 1;
+                    }
                 }
 
                 if (writable && do_write > 0) {

commit a714861cc1fa2e06c5f5509880fcbfbc334c2812
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 8 22:45:24 2009 +0200

    channelmap: add pa_channel_map_has_position()

diff --git a/src/pulse/channelmap.c b/src/pulse/channelmap.c
index ce7dadc..fe14df2 100644
--- a/src/pulse/channelmap.c
+++ b/src/pulse/channelmap.c
@@ -839,3 +839,16 @@ const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) {
 
     return NULL;
 }
+
+int pa_channel_map_has_position(const pa_channel_map *map, pa_channel_position_t p) {
+    unsigned c;
+
+    pa_return_val_if_fail(pa_channel_map_valid(map), 0);
+    pa_return_val_if_fail(p < PA_CHANNEL_POSITION_MAX, 0);
+
+    for (c = 0; c < map->channels; c++)
+        if (map->map[c] == p)
+            return 1;
+
+    return 0;
+}
diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h
index d4db45b..a2925c1 100644
--- a/src/pulse/channelmap.h
+++ b/src/pulse/channelmap.h
@@ -325,6 +325,10 @@ mapping. I.e. "Stereo", "Surround 7.1" and so on. If the channel
 mapping is unknown NULL will be returned. \since 0.9.15 */
 const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) PA_GCC_PURE;
 
+/** Returns TRUE if the specified channel position is available at
+ * least once in the channel map. \since 0.9.16 */
+int pa_channel_map_has_position(const pa_channel_map *map, pa_channel_position_t p) PA_GCC_PURE;
+
 PA_C_DECL_END
 
 #endif

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list