mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Make audio ring buffer size a multiple of 3,5,7,8.
This commit is contained in:
parent
ebe0beb400
commit
207871fd9b
@ -1,6 +1,8 @@
|
||||
User johns
|
||||
Date:
|
||||
|
||||
Make audio ring buffer size a multiple of 3,5,7,8.
|
||||
Add reset ring buffer support.
|
||||
Fix bug: alloca wrong size for audio buffer.
|
||||
Handle jump in stream like stream start.
|
||||
Always compile audio drift correction.
|
||||
|
13
audio.c
13
audio.c
@ -178,8 +178,8 @@ static int AudioVolume; ///< current volume (0 .. 1000)
|
||||
|
||||
extern int VideoAudioDelay; ///< import audio/video delay
|
||||
|
||||
/// default ring buffer size ~2s 8ch 16bit
|
||||
static const unsigned AudioRingBufferSize = 2 * 48000 * 8 * 2;
|
||||
/// default ring buffer size ~2s 8ch 16bit (3 * 5 * 7 * 8)
|
||||
static const unsigned AudioRingBufferSize = 3 * 5 * 7 * 8 * 2 * 1000;
|
||||
|
||||
static int AudioChannelsInHw[9]; ///< table which channels are supported
|
||||
enum _audio_rates
|
||||
@ -684,9 +684,7 @@ static int AudioRingAdd(unsigned sample_rate, int channels, int use_ac3)
|
||||
AudioRing[AudioRingWrite].HwSampleRate = sample_rate;
|
||||
AudioRing[AudioRingWrite].HwChannels = AudioChannelMatrix[u][channels];
|
||||
AudioRing[AudioRingWrite].PTS = INT64_C(0x8000000000000000);
|
||||
// reset ring-buffer
|
||||
RingBufferReadAdvance(AudioRing[AudioRingWrite].RingBuffer,
|
||||
RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
|
||||
RingBufferReset(AudioRing[AudioRingWrite].RingBuffer);
|
||||
|
||||
atomic_inc(&AudioRingFilled);
|
||||
|
||||
@ -856,6 +854,11 @@ static int AlsaPlayRingbuffer(void)
|
||||
// FIXME: if not all are written, we double amplify them
|
||||
}
|
||||
frames = snd_pcm_bytes_to_frames(AlsaPCMHandle, avail);
|
||||
if (avail != snd_pcm_frames_to_bytes(AlsaPCMHandle, frames)) {
|
||||
Error(_("audio/alsa: bytes lost -> out of sync\n"));
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
if (AlsaUseMmap) {
|
||||
|
20
ringbuffer.c
20
ringbuffer.c
@ -48,6 +48,18 @@ struct _ring_buffer_
|
||||
atomic_t Filled; ///< how many of the buffer is used
|
||||
};
|
||||
|
||||
/**
|
||||
** Reset ring buffer pointers.
|
||||
**
|
||||
** @param rb Ring buffer to reset read/write pointers.
|
||||
*/
|
||||
void RingBufferReset(RingBuffer * rb)
|
||||
{
|
||||
rb->ReadPointer = rb->Buffer;
|
||||
rb->WritePointer = rb->Buffer;
|
||||
atomic_set(&rb->Filled, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
** Allocate a new ring buffer.
|
||||
**
|
||||
@ -69,10 +81,8 @@ RingBuffer *RingBufferNew(size_t size)
|
||||
}
|
||||
|
||||
rb->Size = size;
|
||||
rb->ReadPointer = rb->Buffer;
|
||||
rb->WritePointer = rb->Buffer;
|
||||
rb->BufferEnd = rb->Buffer + size;
|
||||
atomic_set(&rb->Filled, 0);
|
||||
RingBufferReset(rb);
|
||||
|
||||
return rb;
|
||||
}
|
||||
@ -89,7 +99,7 @@ void RingBufferDel(RingBuffer * rb)
|
||||
/**
|
||||
** Advance write pointer in ring buffer.
|
||||
**
|
||||
** @param rb Ring buffer to adance write pointer.
|
||||
** @param rb Ring buffer to advance write pointer.
|
||||
** @param cnt Number of bytes to be adavanced.
|
||||
**
|
||||
** @returns Number of bytes that could be advanced in ring buffer.
|
||||
@ -198,7 +208,7 @@ size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp)
|
||||
/**
|
||||
** Advance read pointer in ring buffer.
|
||||
**
|
||||
** @param rb Ring buffer to adance read pointer.
|
||||
** @param rb Ring buffer to advance read pointer.
|
||||
** @param cnt Number of bytes to be advanced.
|
||||
**
|
||||
** @returns Number of bytes that could be advanced in ring buffer.
|
||||
|
@ -23,13 +23,16 @@
|
||||
/// @addtogroup Ringbuffer
|
||||
/// @{
|
||||
|
||||
///< ring buffer typedef
|
||||
/// ring buffer typedef
|
||||
typedef struct _ring_buffer_ RingBuffer;
|
||||
|
||||
///< create new ring buffer
|
||||
/// reset ring buffer pointers
|
||||
extern void RingBufferReset(RingBuffer *);
|
||||
|
||||
/// create new ring buffer
|
||||
extern RingBuffer *RingBufferNew(size_t);
|
||||
|
||||
///< free ring buffer
|
||||
/// free ring buffer
|
||||
extern void RingBufferDel(RingBuffer *);
|
||||
|
||||
/// write into ring buffer
|
||||
|
Loading…
Reference in New Issue
Block a user