~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/tests/memblockq-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: memblockq-test.c 1971 2007-10-28 19:13:50Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
31
29
#include <pulsecore/memblockq.h>
32
30
#include <pulsecore/log.h>
33
31
 
 
32
static void dump(pa_memblockq *bq) {
 
33
    printf(">");
 
34
 
 
35
    for (;;) {
 
36
        pa_memchunk out;
 
37
        char *e;
 
38
        size_t n;
 
39
        void *q;
 
40
 
 
41
        if (pa_memblockq_peek(bq, &out) < 0)
 
42
            break;
 
43
 
 
44
        q = pa_memblock_acquire(out.memblock);
 
45
        for (e = (char*) q + out.index, n = 0; n < out.length; n++)
 
46
            printf("%c", *e);
 
47
        pa_memblock_release(out.memblock);
 
48
 
 
49
        pa_memblock_unref(out.memblock);
 
50
        pa_memblockq_drop(bq, out.length);
 
51
    }
 
52
 
 
53
    printf("<\n");
 
54
}
 
55
 
34
56
int main(int argc, char *argv[]) {
35
57
    int ret;
36
58
 
37
59
    pa_mempool *p;
38
60
    pa_memblockq *bq;
39
61
    pa_memchunk chunk1, chunk2, chunk3, chunk4;
40
 
    pa_memblock *silence;
 
62
    pa_memchunk silence;
41
63
 
42
64
    pa_log_set_maximal_level(PA_LOG_DEBUG);
43
65
 
44
 
    p = pa_mempool_new(0);
45
 
 
46
 
    silence = pa_memblock_new_fixed(p, (char*)  "__", 2, 1);
47
 
    assert(silence);
48
 
 
49
 
    bq = pa_memblockq_new(0, 40, 10, 2, 4, 4, silence);
 
66
    p = pa_mempool_new(FALSE, 0);
 
67
 
 
68
    silence.memblock = pa_memblock_new_fixed(p, (char*)  "__", 2, 1);
 
69
    assert(silence.memblock);
 
70
    silence.index = 0;
 
71
    silence.length = pa_memblock_get_length(silence.memblock);
 
72
 
 
73
    bq = pa_memblockq_new(0, 40, 10, 2, 4, 4, 40, &silence);
50
74
    assert(bq);
51
75
 
52
76
    chunk1.memblock = pa_memblock_new_fixed(p, (char*) "11", 2, 1);
72
96
    ret = pa_memblockq_push(bq, &chunk1);
73
97
    assert(ret == 0);
74
98
 
75
 
    ret = pa_memblockq_push(bq, &chunk1);
76
 
    assert(ret == 0);
77
 
 
78
 
    ret = pa_memblockq_push(bq, &chunk2);
79
 
    assert(ret == 0);
80
 
 
81
 
    ret = pa_memblockq_push(bq, &chunk2);
 
99
    ret = pa_memblockq_push(bq, &chunk2);
 
100
    assert(ret == 0);
 
101
 
 
102
    ret = pa_memblockq_push(bq, &chunk3);
 
103
    assert(ret == 0);
 
104
 
 
105
    ret = pa_memblockq_push(bq, &chunk4);
82
106
    assert(ret == 0);
83
107
 
84
108
    pa_memblockq_seek(bq, -6, 0);
86
110
    assert(ret == 0);
87
111
 
88
112
    pa_memblockq_seek(bq, -2, 0);
89
 
    ret = pa_memblockq_push(bq, &chunk3);
 
113
    ret = pa_memblockq_push(bq, &chunk1);
90
114
    assert(ret == 0);
91
115
 
92
116
    pa_memblockq_seek(bq, -10, 0);
119
143
    ret = pa_memblockq_push(bq, &chunk3);
120
144
    assert(ret == 0);
121
145
 
122
 
    pa_memblockq_shorten(bq, pa_memblockq_get_length(bq)-2);
123
 
 
124
 
    printf(">");
125
 
 
126
 
    for (;;) {
127
 
        pa_memchunk out;
128
 
        char *e;
129
 
        size_t n;
130
 
 
131
 
        if (pa_memblockq_peek(bq, &out) < 0)
132
 
            break;
133
 
 
134
 
        p = pa_memblock_acquire(out.memblock);
135
 
        for (e = (char*) p + out.index, n = 0; n < out.length; n++)
136
 
            printf("%c", *e);
137
 
        pa_memblock_release(out.memblock);
138
 
 
139
 
        pa_memblock_unref(out.memblock);
140
 
        pa_memblockq_drop(bq, out.length);
141
 
    }
142
 
 
143
 
    printf("<\n");
 
146
    pa_memblockq_seek(bq, 30, PA_SEEK_RELATIVE);
 
147
 
 
148
    dump(bq);
 
149
 
 
150
    pa_memblockq_rewind(bq, 52);
 
151
 
 
152
    dump(bq);
144
153
 
145
154
    pa_memblockq_free(bq);
146
 
    pa_memblock_unref(silence);
 
155
    pa_memblock_unref(silence.memblock);
147
156
    pa_memblock_unref(chunk1.memblock);
148
157
    pa_memblock_unref(chunk2.memblock);
149
158
    pa_memblock_unref(chunk3.memblock);
150
159
    pa_memblock_unref(chunk4.memblock);
151
160
 
 
161
    pa_mempool_free(p);
 
162
 
152
163
    return 0;
153
164
}