2006-04-14 23:47:33 +00:00
|
|
|
#ifndef foortphfoo
|
|
|
|
|
#define foortphfoo
|
|
|
|
|
|
|
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-02-13 15:35:19 +00:00
|
|
|
|
|
|
|
|
Copyright 2006 Lennart Poettering
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2006-04-14 23:47:33 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2006-04-14 23:47:33 +00:00
|
|
|
or (at your option) any later version.
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2006-04-14 23:47:33 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-04-14 23:47:33 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2014-11-26 14:14:51 +01:00
|
|
|
along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
2006-04-14 23:47:33 +00:00
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/types.h>
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/memblockq.h>
|
|
|
|
|
#include <pulsecore/memchunk.h>
|
2006-04-14 23:47:33 +00:00
|
|
|
|
|
|
|
|
typedef struct pa_rtp_context {
|
|
|
|
|
int fd;
|
|
|
|
|
uint16_t sequence;
|
|
|
|
|
uint32_t timestamp;
|
|
|
|
|
uint32_t ssrc;
|
|
|
|
|
uint8_t payload;
|
2006-04-15 15:26:42 +00:00
|
|
|
size_t frame_size;
|
2008-05-15 23:34:41 +00:00
|
|
|
|
rtp: don't use memblocks for non-audio data
pa_memblockq_push() expects all memchunks to be aligned to PCM frame
boundaries, and that means both the index and length fields of
pa_memchunk. pa_rtp_recv(), however, used a memblock for storing both
the RTP packet metadata and the actual audio data. The metadata was
"removed" from the audio data by setting the memchunk index
appropriately, so the metadata stayed in the memblock, but it was not
played back. The metadata length is not necessarily divisible by the PCM
frame size, which caused pa_memblock_push() to crash in an assertion
with some sample specs, because the memchunk index was not properly
aligned. In my tests the metadata length was 12, so it was compatible
with many configurations, but eight-channel audio didn't work.
This patch adds a separate buffer for receiving the RTP packets. As a
result, an extra memcpy is needed for moving the audio data from the
receive buffer to the memblock buffer.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96612
2016-09-20 12:59:04 +03:00
|
|
|
uint8_t *recv_buf;
|
|
|
|
|
size_t recv_buf_size;
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_memchunk memchunk;
|
2006-04-14 23:47:33 +00:00
|
|
|
} pa_rtp_context;
|
|
|
|
|
|
2016-05-12 17:56:51 +05:30
|
|
|
int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint8_t payload, size_t frame_size);
|
virtual-sink: Fix a crash when moving the sink to a new master right after setup.
If the virtual sink is moved to a new master right after it has been created,
then the virtual sink input's memblockq can be rewound to a negative read
index. The data written prior to the move starts from index zero, so after the
rewind there's a bit of silence. If the memblockq doesn't have a silence
memchunk set, then pa_memblockq_peek() will return zero in such case, and the
returned memchunk's memblock pointer will be NULL.
That scenario wasn't taken into account in the implementation of
sink_input_pop_cb. Setting a silence memchunk for the memblockq solves this
problem, because pa_memblock_peek() will now return a valid memblock if the
read index happens to point to a hole in the memblockq.
I believe this isn't the best possible solution, though. It doesn't really make
sense to rewind the sink input's memblockq beyond index 0 in the first place,
because now when the stream starts to play to the new master sink, there's some
unnecessary silence before the actual data starts. This is a small problem,
though, and I don't grok the rewinding system well enough to know how to fix
this issue properly.
I went through all files that call pa_memblockq_peek() to see if there are more
similar bugs. play-memblockq.c was the only one that looked to me like it might
be broken in the same way. I didn't try reproducing the bug with
play-memblockq.c, though, so I just added a FIXME comment there.
2011-02-24 16:16:43 +02:00
|
|
|
|
|
|
|
|
/* If the memblockq doesn't have a silence memchunk set, then the caller must
|
|
|
|
|
* guarantee that the current read index doesn't point to a hole. */
|
2006-04-14 23:47:33 +00:00
|
|
|
int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q);
|
|
|
|
|
|
2006-04-16 00:16:53 +00:00
|
|
|
pa_rtp_context* pa_rtp_context_init_recv(pa_rtp_context *c, int fd, size_t frame_size);
|
2009-04-07 00:50:47 +02:00
|
|
|
int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, struct timeval *tstamp);
|
2006-04-16 00:16:53 +00:00
|
|
|
|
|
|
|
|
void pa_rtp_context_destroy(pa_rtp_context *c);
|
2006-04-14 23:47:33 +00:00
|
|
|
|
|
|
|
|
pa_sample_spec* pa_rtp_sample_spec_fixup(pa_sample_spec *ss);
|
|
|
|
|
int pa_rtp_sample_spec_valid(const pa_sample_spec *ss);
|
|
|
|
|
|
2006-04-16 00:16:53 +00:00
|
|
|
uint8_t pa_rtp_payload_from_sample_spec(const pa_sample_spec *ss);
|
|
|
|
|
pa_sample_spec *pa_rtp_sample_spec_from_payload(uint8_t payload, pa_sample_spec *ss);
|
|
|
|
|
|
|
|
|
|
const char* pa_rtp_format_to_string(pa_sample_format_t f);
|
|
|
|
|
pa_sample_format_t pa_rtp_string_to_format(const char *s);
|
2006-04-14 23:47:33 +00:00
|
|
|
|
|
|
|
|
#endif
|