remove buffered_chunks, use cb->size
Second patch to make OutputBuffer self-contained: since OutputBuffer now knows its own size, we do not need the global variable "buffered_chunks" anymore. git-svn-id: https://svn.musicpd.org/mpd/trunk@7311 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
e9e557c8d1
commit
e20b71ed63
@ -79,7 +79,7 @@ static void quitDecode(PlayerControl * pc, DecoderControl * dc)
|
|||||||
static unsigned calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
|
static unsigned calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
|
||||||
float totalTime)
|
float totalTime)
|
||||||
{
|
{
|
||||||
unsigned chunks;
|
unsigned int buffered_chunks, chunks;
|
||||||
|
|
||||||
if (pc->crossFade == 0 || pc->crossFade >= totalTime ||
|
if (pc->crossFade == 0 || pc->crossFade >= totalTime ||
|
||||||
!isCurrentAudioFormat(af))
|
!isCurrentAudioFormat(af))
|
||||||
@ -93,6 +93,7 @@ static unsigned calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
|
|||||||
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
|
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
|
||||||
chunks = (chunks * pc->crossFade + 0.5);
|
chunks = (chunks * pc->crossFade + 0.5);
|
||||||
|
|
||||||
|
buffered_chunks = getPlayerData()->buffer.size;
|
||||||
assert(buffered_chunks >= buffered_before_play);
|
assert(buffered_chunks >= buffered_before_play);
|
||||||
if (chunks > (buffered_chunks - buffered_before_play))
|
if (chunks > (buffered_chunks - buffered_before_play))
|
||||||
chunks = buffered_chunks - buffered_before_play;
|
chunks = buffered_chunks - buffered_before_play;
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
unsigned int buffered_before_play;
|
unsigned int buffered_before_play;
|
||||||
unsigned int buffered_chunks;
|
|
||||||
|
|
||||||
#define DEFAULT_BUFFER_SIZE 2048
|
#define DEFAULT_BUFFER_SIZE 2048
|
||||||
#define DEFAULT_BUFFER_BEFORE_PLAY 10
|
#define DEFAULT_BUFFER_BEFORE_PLAY 10
|
||||||
@ -36,6 +35,7 @@ void initPlayerData(void)
|
|||||||
char *test;
|
char *test;
|
||||||
int crossfade = 0;
|
int crossfade = 0;
|
||||||
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
||||||
|
unsigned int buffered_chunks;
|
||||||
ConfigParam *param;
|
ConfigParam *param;
|
||||||
size_t device_array_size = audio_device_count() * sizeof(mpd_sint8);
|
size_t device_array_size = audio_device_count() * sizeof(mpd_sint8);
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "outputBuffer.h"
|
#include "outputBuffer.h"
|
||||||
|
|
||||||
extern unsigned int buffered_before_play;
|
extern unsigned int buffered_before_play;
|
||||||
extern unsigned int buffered_chunks;
|
|
||||||
|
|
||||||
typedef struct _PlayerData {
|
typedef struct _PlayerData {
|
||||||
OutputBuffer buffer;
|
OutputBuffer buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user