~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/pstream.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: pstream.c 1971 2007-10-28 19:13:50Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
98
96
    /* packet info */
99
97
    pa_packet *packet;
100
98
#ifdef HAVE_CREDS
101
 
    int with_creds;
 
99
    pa_bool_t with_creds;
102
100
    pa_creds creds;
103
101
#endif
104
102
 
121
119
 
122
120
    pa_queue *send_queue;
123
121
 
124
 
    int dead;
 
122
    pa_bool_t dead;
125
123
 
126
124
    struct {
127
125
        pa_pstream_descriptor descriptor;
141
139
        size_t index;
142
140
    } read;
143
141
 
144
 
    int use_shm;
 
142
    pa_bool_t use_shm;
145
143
    pa_memimport *import;
146
144
    pa_memexport *export;
147
145
 
167
165
 
168
166
#ifdef HAVE_CREDS
169
167
    pa_creds read_creds, write_creds;
170
 
    int read_creds_valid, send_creds_now;
 
168
    pa_bool_t read_creds_valid, send_creds_now;
171
169
#endif
172
170
};
173
171
 
239
237
    PA_REFCNT_INIT(p);
240
238
    p->io = io;
241
239
    pa_iochannel_set_callback(io, io_callback, p);
242
 
    p->dead = 0;
 
240
    p->dead = FALSE;
243
241
 
244
242
    p->mainloop = m;
245
243
    p->defer_event = m->defer_new(m, defer_callback, p);
269
267
 
270
268
    p->mempool = pool;
271
269
 
272
 
    p->use_shm = 0;
 
270
    p->use_shm = FALSE;
273
271
    p->export = NULL;
274
272
 
275
273
    /* We do importing unconditionally */
276
274
    p->import = pa_memimport_new(p->mempool, memimport_release_cb, p);
277
275
 
278
 
    pa_iochannel_socket_set_rcvbuf(io, 1024*8);
279
 
    pa_iochannel_socket_set_sndbuf(io, 1024*8);
 
276
    pa_iochannel_socket_set_rcvbuf(io, pa_mempool_block_size_max(p->mempool));
 
277
    pa_iochannel_socket_set_sndbuf(io, pa_mempool_block_size_max(p->mempool));
280
278
 
281
279
#ifdef HAVE_CREDS
282
 
    p->send_creds_now = 0;
283
 
    p->read_creds_valid = 0;
 
280
    p->send_creds_now = FALSE;
 
281
    p->read_creds_valid = FALSE;
284
282
#endif
285
283
    return p;
286
284
}
287
285
 
288
 
static void item_free(void *item, PA_GCC_UNUSED void *q) {
 
286
static void item_free(void *item, void *q) {
289
287
    struct item_info *i = item;
290
288
    pa_assert(i);
291
289
 
374
372
            i = pa_xnew(struct item_info, 1);
375
373
        i->type = PA_PSTREAM_ITEM_MEMBLOCK;
376
374
 
377
 
        n = MIN(length, bsm);
 
375
        n = PA_MIN(length, bsm);
378
376
        i->chunk.index = chunk->index + idx;
379
377
        i->chunk.length = n;
380
378
        i->chunk.memblock = pa_memblock_ref(chunk->memblock);
383
381
        i->offset = offset;
384
382
        i->seek_mode = seek_mode;
385
383
#ifdef HAVE_CREDS
386
 
        i->with_creds = 0;
 
384
        i->with_creds = FALSE;
387
385
#endif
388
386
 
389
387
        pa_queue_push(p->send_queue, i);
410
408
    item->type = PA_PSTREAM_ITEM_SHMRELEASE;
411
409
    item->block_id = block_id;
412
410
#ifdef HAVE_CREDS
413
 
    item->with_creds = 0;
 
411
    item->with_creds = FALSE;
414
412
#endif
415
413
 
416
414
    pa_queue_push(p->send_queue, item);
447
445
    item->type = PA_PSTREAM_ITEM_SHMREVOKE;
448
446
    item->block_id = block_id;
449
447
#ifdef HAVE_CREDS
450
 
    item->with_creds = 0;
 
448
    item->with_creds = FALSE;
451
449
#endif
452
450
 
453
451
    pa_queue_push(p->send_queue, item);
490
488
 
491
489
        pa_assert(p->write.current->packet);
492
490
        p->write.data = p->write.current->packet->data;
493
 
        p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl(p->write.current->packet->length);
 
491
        p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl((uint32_t) p->write.current->packet->length);
494
492
 
495
493
    } else if (p->write.current->type == PA_PSTREAM_ITEM_SHMRELEASE) {
496
494
 
504
502
 
505
503
    } else {
506
504
        uint32_t flags;
507
 
        int send_payload = 1;
 
505
        pa_bool_t send_payload = TRUE;
508
506
 
509
507
        pa_assert(p->write.current->type == PA_PSTREAM_ITEM_MEMBLOCK);
510
508
        pa_assert(p->write.current->chunk.memblock);
513
511
        p->write.descriptor[PA_PSTREAM_DESCRIPTOR_OFFSET_HI] = htonl((uint32_t) (((uint64_t) p->write.current->offset) >> 32));
514
512
        p->write.descriptor[PA_PSTREAM_DESCRIPTOR_OFFSET_LO] = htonl((uint32_t) ((uint64_t) p->write.current->offset));
515
513
 
516
 
        flags = p->write.current->seek_mode & PA_FLAG_SEEKMASK;
 
514
        flags = (uint32_t) (p->write.current->seek_mode & PA_FLAG_SEEKMASK);
517
515
 
518
516
        if (p->use_shm) {
519
517
            uint32_t block_id, shm_id;
529
527
                                 &length) >= 0) {
530
528
 
531
529
                flags |= PA_FLAG_SHMDATA;
532
 
                send_payload = 0;
 
530
                send_payload = FALSE;
533
531
 
534
532
                p->write.shm_info[PA_PSTREAM_SHM_BLOCKID] = htonl(block_id);
535
533
                p->write.shm_info[PA_PSTREAM_SHM_SHMID] = htonl(shm_id);
544
542
        }
545
543
 
546
544
        if (send_payload) {
547
 
            p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl(p->write.current->chunk.length);
 
545
            p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl((uint32_t) p->write.current->chunk.length);
548
546
            p->write.memchunk = p->write.current->chunk;
549
547
            pa_memblock_ref(p->write.memchunk.memblock);
550
548
            p->write.data = NULL;
599
597
        if ((r = pa_iochannel_write_with_creds(p->io, d, l, &p->write_creds)) < 0)
600
598
            goto fail;
601
599
 
602
 
        p->send_creds_now = 0;
 
600
        p->send_creds_now = FALSE;
603
601
    } else
604
602
#endif
605
603
 
609
607
    if (release_memblock)
610
608
        pa_memblock_release(release_memblock);
611
609
 
612
 
    p->write.index += r;
 
610
    p->write.index += (size_t) r;
613
611
 
614
612
    if (p->write.index >= PA_PSTREAM_DESCRIPTOR_SIZE + ntohl(p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH])) {
615
613
        pa_assert(p->write.current);
677
675
    if (release_memblock)
678
676
        pa_memblock_release(release_memblock);
679
677
 
680
 
    p->read.index += r;
 
678
    p->read.index += (size_t) r;
681
679
 
682
680
    if (p->read.index == PA_PSTREAM_DESCRIPTOR_SIZE) {
683
681
        uint32_t flags, length, channel;
771
769
        if (p->read.memblock && p->recieve_memblock_callback) {
772
770
 
773
771
            /* Is this memblock data? Than pass it to the user */
774
 
            l = (p->read.index - r) < PA_PSTREAM_DESCRIPTOR_SIZE ? p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE : (size_t) r;
 
772
            l = (p->read.index - (size_t) r) < PA_PSTREAM_DESCRIPTOR_SIZE ? (size_t) (p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE) : (size_t) r;
775
773
 
776
774
            if (l > 0) {
777
775
                pa_memchunk chunk;
875
873
    p->read.data = NULL;
876
874
 
877
875
#ifdef HAVE_CREDS
878
 
    p->read_creds_valid = 0;
 
876
    p->read_creds_valid = FALSE;
879
877
#endif
880
878
 
881
879
    return 0;
935
933
    p->release_callback_userdata = userdata;
936
934
}
937
935
 
938
 
int pa_pstream_is_pending(pa_pstream *p) {
939
 
    int b;
 
936
pa_bool_t pa_pstream_is_pending(pa_pstream *p) {
 
937
    pa_bool_t b;
940
938
 
941
939
    pa_assert(p);
942
940
    pa_assert(PA_REFCNT_VALUE(p) > 0);
943
941
 
944
942
    if (p->dead)
945
 
        b = 0;
 
943
        b = FALSE;
946
944
    else
947
 
        b = p->write.current || !pa_queue_is_empty(p->send_queue);
 
945
        b = p->write.current || !pa_queue_isempty(p->send_queue);
948
946
 
949
947
    return b;
950
948
}
971
969
    if (p->dead)
972
970
        return;
973
971
 
974
 
    p->dead = 1;
 
972
    p->dead = TRUE;
975
973
 
976
974
    if (p->import) {
977
975
        pa_memimport_free(p->import);
999
997
    p->recieve_memblock_callback = NULL;
1000
998
}
1001
999
 
1002
 
void pa_pstream_use_shm(pa_pstream *p, int enable) {
 
1000
void pa_pstream_enable_shm(pa_pstream *p, pa_bool_t enable) {
1003
1001
    pa_assert(p);
1004
1002
    pa_assert(PA_REFCNT_VALUE(p) > 0);
1005
1003
 
1018
1016
        }
1019
1017
    }
1020
1018
}
 
1019
 
 
1020
pa_bool_t pa_pstream_get_shm(pa_pstream *p) {
 
1021
    pa_assert(p);
 
1022
    pa_assert(PA_REFCNT_VALUE(p) > 0);
 
1023
 
 
1024
    return p->use_shm;
 
1025
}