~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/memblockq.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-05-05 14:18:20 UTC
  • mfrom: (1.2.4 upstream) (1.1.8 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090505141820-rrr2mtdd1jkllvr8
Tags: 1:0.9.15-1ubuntu1
* Merge from unreleased Debian pulseaudio git, remaining changes:
  - epoch (my stupid fault :S)
  - Don't build against, and create jack package. Jack is not in main
  - use linear resampler to work better with lack of PREEMPT in jaunty's
    -generic kernel config, also change buffer size
  - Add alsa configuration files to route alsa applications via pulseaudio
  - Move libasound2-plugins from Recommends to Depends
  - Add pm-utils sleep hook to suspend (and resume) users' pulseaudio
    daemons
  - patch to fix source/sink and suspend-on-idle race
  - Make initscript more informative in the default case of per-user
    sessions
  - create /var/run/pulse, and make restart more robust
  - add status check for system wide pulseaudio instance
  - LSB {Required-*,Should-*} should specify hal instead of dbus,
    since hal is required (and already requires dbus)
  - indicate that the system pulseaudio instance is being started from the init
    script
  - Install more upstream man pages
  - Link to pacat for parec man page
  - check whether pulseaudio is running before preloading the padsp library
  - Add DEB_OPT_FLAG = -O3 as per recommendation from
    pulseaudio-discuss/2007-December/001017.html
  - cache /usr/share/sounds/ubuntu/stereo/ wav files on pulseaudio load
  - disable glitch free (use tsched=0)
  - Generate a PO template on build
  - add special case to disable pulseaudio loading if accessibility/speech
    is being used
  - the sd wrapper script should not load pulseaudio if pulseaudio is being
    used as a system service
  - add a pulseaudio apport hook
  - fix some typos in README.Debian
  - demote paprefs to suggests
  - drop padevchooser(Recommends) and pavucontrol (Suggests)
  - drop libasyncns-dev build dependency, its in universe
* add libudev-dev as a build-dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
  PulseAudio is free software; you can redistribute it and/or modify
7
7
  it under the terms of the GNU Lesser General Public License as published
8
 
  by the Free Software Foundation; either version 2 of the License,
 
8
  by the Free Software Foundation; either version 2.1 of the License,
9
9
  or (at your option) any later version.
10
10
 
11
11
  PulseAudio is distributed in the hope that it will be useful, but
90
90
 
91
91
    pa_memblockq_set_maxlength(bq, maxlength);
92
92
    pa_memblockq_set_tlength(bq, tlength);
 
93
    pa_memblockq_set_minreq(bq, minreq);
93
94
    pa_memblockq_set_prebuf(bq, prebuf);
94
 
    pa_memblockq_set_minreq(bq, minreq);
95
95
    pa_memblockq_set_maxrewind(bq, maxrewind);
96
96
 
97
97
    pa_log_debug("memblockq sanitized: maxlength=%lu, tlength=%lu, base=%lu, prebuf=%lu, minreq=%lu maxrewind=%lu",
601
601
    return l >= bq->minreq ? l : 0;
602
602
}
603
603
 
604
 
void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek) {
 
604
void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek, pa_bool_t account) {
605
605
    int64_t old, delta;
606
606
    pa_assert(bq);
607
607
 
628
628
 
629
629
    delta = bq->write_index - old;
630
630
 
631
 
    if (delta >= (int64_t) bq->requested) {
632
 
        delta -= (int64_t) bq->requested;
633
 
        bq->requested = 0;
634
 
    } else if (delta >= 0) {
635
 
        bq->requested -= (size_t) delta;
636
 
        delta = 0;
 
631
    if (account) {
 
632
        if (delta >= (int64_t) bq->requested) {
 
633
            delta -= (int64_t) bq->requested;
 
634
            bq->requested = 0;
 
635
        } else if (delta >= 0) {
 
636
            bq->requested -= (size_t) delta;
 
637
            delta = 0;
 
638
        }
637
639
    }
638
640
 
639
641
    bq->missing -= delta;
782
784
 
783
785
    if (bq->tlength > bq->maxlength)
784
786
        pa_memblockq_set_tlength(bq, bq->maxlength);
785
 
 
786
 
    if (bq->prebuf > bq->maxlength)
787
 
        pa_memblockq_set_prebuf(bq, bq->maxlength);
788
787
}
789
788
 
790
789
void pa_memblockq_set_tlength(pa_memblockq *bq, size_t tlength) {
791
790
    size_t old_tlength;
792
791
    pa_assert(bq);
793
792
 
794
 
    if (tlength <= 0)
 
793
    if (tlength <= 0 || tlength == (size_t) -1)
795
794
        tlength = bq->maxlength;
796
795
 
797
796
    old_tlength = bq->tlength;
800
799
    if (bq->tlength > bq->maxlength)
801
800
        bq->tlength = bq->maxlength;
802
801
 
803
 
    if (bq->prebuf > bq->tlength)
804
 
        pa_memblockq_set_prebuf(bq, bq->tlength);
805
 
 
806
802
    if (bq->minreq > bq->tlength)
807
803
        pa_memblockq_set_minreq(bq, bq->tlength);
808
804
 
 
805
    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
 
806
        pa_memblockq_set_prebuf(bq, bq->tlength+bq->base-bq->minreq);
 
807
 
809
808
    bq->missing += (int64_t) bq->tlength - (int64_t) old_tlength;
810
809
}
811
810
 
 
811
void pa_memblockq_set_minreq(pa_memblockq *bq, size_t minreq) {
 
812
    pa_assert(bq);
 
813
 
 
814
    bq->minreq = (minreq/bq->base)*bq->base;
 
815
 
 
816
    if (bq->minreq > bq->tlength)
 
817
        bq->minreq = bq->tlength;
 
818
 
 
819
    if (bq->minreq < bq->base)
 
820
        bq->minreq = bq->base;
 
821
 
 
822
    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
 
823
        pa_memblockq_set_prebuf(bq, bq->tlength+bq->base-bq->minreq);
 
824
}
 
825
 
812
826
void pa_memblockq_set_prebuf(pa_memblockq *bq, size_t prebuf) {
813
827
    pa_assert(bq);
814
828
 
815
829
    if (prebuf == (size_t) -1)
816
 
        prebuf = bq->tlength;
 
830
        prebuf = bq->tlength+bq->base-bq->minreq;
817
831
 
818
832
    bq->prebuf = ((prebuf+bq->base-1)/bq->base)*bq->base;
819
833
 
820
834
    if (prebuf > 0 && bq->prebuf < bq->base)
821
835
        bq->prebuf = bq->base;
822
836
 
823
 
    if (bq->prebuf > bq->tlength)
824
 
        bq->prebuf = bq->tlength;
 
837
    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
 
838
        bq->prebuf = bq->tlength+bq->base-bq->minreq;
825
839
 
826
840
    if (bq->prebuf <= 0 || pa_memblockq_get_length(bq) >= bq->prebuf)
827
841
        bq->in_prebuf = FALSE;
828
 
 
829
 
    if (bq->minreq > bq->prebuf)
830
 
        pa_memblockq_set_minreq(bq, bq->prebuf);
831
 
}
832
 
 
833
 
void pa_memblockq_set_minreq(pa_memblockq *bq, size_t minreq) {
834
 
    pa_assert(bq);
835
 
 
836
 
    bq->minreq = (minreq/bq->base)*bq->base;
837
 
 
838
 
    if (bq->minreq > bq->tlength)
839
 
        bq->minreq = bq->tlength;
840
 
 
841
 
    if (bq->minreq > bq->prebuf)
842
 
        bq->minreq = bq->prebuf;
843
 
 
844
 
    if (bq->minreq < bq->base)
845
 
        bq->minreq = bq->base;
846
842
}
847
843
 
848
844
void pa_memblockq_set_maxrewind(pa_memblockq *bq, size_t maxrewind) {
851
847
    bq->maxrewind = (maxrewind/bq->base)*bq->base;
852
848
}
853
849
 
 
850
void pa_memblockq_apply_attr(pa_memblockq *bq, const pa_buffer_attr *a) {
 
851
    pa_assert(bq);
 
852
    pa_assert(a);
 
853
 
 
854
    pa_memblockq_set_maxlength(bq, a->maxlength);
 
855
    pa_memblockq_set_tlength(bq, a->tlength);
 
856
    pa_memblockq_set_prebuf(bq, a->prebuf);
 
857
    pa_memblockq_set_minreq(bq, a->minreq);
 
858
}
 
859
 
 
860
void pa_memblockq_get_attr(pa_memblockq *bq, pa_buffer_attr *a) {
 
861
    pa_assert(bq);
 
862
    pa_assert(a);
 
863
 
 
864
    a->maxlength = (uint32_t) pa_memblockq_get_maxlength(bq);
 
865
    a->tlength = (uint32_t) pa_memblockq_get_tlength(bq);
 
866
    a->prebuf = (uint32_t) pa_memblockq_get_prebuf(bq);
 
867
    a->minreq = (uint32_t) pa_memblockq_get_minreq(bq);
 
868
}
 
869
 
854
870
int pa_memblockq_splice(pa_memblockq *bq, pa_memblockq *source) {
855
871
 
856
872
    pa_assert(bq);
875
891
 
876
892
            pa_memblock_unref(chunk.memblock);
877
893
        } else
878
 
            pa_memblockq_seek(bq, (int64_t) chunk.length, PA_SEEK_RELATIVE);
 
894
            pa_memblockq_seek(bq, (int64_t) chunk.length, PA_SEEK_RELATIVE, TRUE);
879
895
 
880
896
        pa_memblockq_drop(bq, chunk.length);
881
897
    }