remove "wrap" from buffering control, its not needed, and could potentially

create a race condition (but hasn't happened in the last 10 months since
this code was written)

git-svn-id: https://svn.musicpd.org/mpd/trunk@1397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-06-08 18:55:16 +00:00
parent c274d7d62f
commit 6f4a55ea7c
4 changed files with 18 additions and 28 deletions

19
TODO
View File

@ -1,21 +1,16 @@
1) remove wrap from ring buffer code, its not 100% safe 1) put some sort of error reporting for streaming/inputStream!
a) player, just ensure that begin != end
b) decoder: compute what the next chunk needs to be
and wait till begin is no longer that
2) put some sort of error reporting for streaming/inputStream! 2) Fix charset errors so they don't goto stderr/out
3) Fix charset errors so they don't goto stderr/out 3) Add a timeout for streams (how long? 1 minutes?)
4) Add a timeout for streams (how long? 1 minutes?) 4) compute time of vorbis from actual number of samples played
5) compute time of vorbis from actual number of samples played 5) remove previous hack for streams
6) remove previous hack for streams 6) add "plversion" and "currentsong" commands
7) add "plversion" and "currentsong" commands 7) in libmpdclient, buffer all stuff going out for playlist command,
8) in libmpdclient, buffer all stuff going out for playlist command,
should make it much faster should make it much faster

View File

@ -173,7 +173,6 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
stopDecode(dc); stopDecode(dc);
cb->begin = 0; cb->begin = 0;
cb->end = 0; cb->end = 0;
cb->wrap = 0;
dc->error = 0; dc->error = 0;
dc->start = 1; dc->start = 1;
waitOnDecode(pc,dc,cb,decodeWaitedOn); waitOnDecode(pc,dc,cb,decodeWaitedOn);
@ -391,7 +390,7 @@ int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous, void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous,
int * currentChunkSent, MetadataChunk * currentChunk) int * currentChunkSent, MetadataChunk * currentChunk)
{ {
if(cb->begin!=cb->end || cb->wrap) { if(cb->begin!=cb->end) {
int meta = cb->metaChunk[cb->begin]; int meta = cb->metaChunk[cb->begin];
if( meta != *previous ) { if( meta != *previous ) {
if( meta >= 0 && cb->metaChunkSet[meta]) { if( meta >= 0 && cb->metaChunkSet[meta]) {
@ -425,7 +424,6 @@ void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc,
cb->begin++; cb->begin++;
if(cb->begin>=buffered_chunks) { if(cb->begin>=buffered_chunks) {
cb->begin = 0; cb->begin = 0;
cb->wrap = 0;
} }
} }
} }
@ -454,7 +452,8 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
pc->play = 0; pc->play = 0;
kill(getppid(),SIGUSR1); kill(getppid(),SIGUSR1);
while(*decode_pid>0 && !cb->wrap && cb->end-cb->begin<bbp && while(*decode_pid>0 && cb->end-cb->begin<bbp &&
cb->end!=buffered_chunks-1 &&
dc->state!=DECODE_STATE_STOP) dc->state!=DECODE_STATE_STOP)
{ {
processDecodeInput(); processDecodeInput();
@ -492,9 +491,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
else doCrossFade = -1; else doCrossFade = -1;
} }
if(pause) my_usleep(10000); if(pause) my_usleep(10000);
else if((cb->begin!=cb->end || cb->wrap) && else if(cb->begin!=cb->end && cb->begin!=cb->next) {
cb->begin!=cb->next)
{
if(doCrossFade==1 && cb->next>=0 && if(doCrossFade==1 && cb->next>=0 &&
((cb->next>cb->begin && ((cb->next>cb->begin &&
(fadePosition=cb->next-cb->begin) (fadePosition=cb->next-cb->begin)
@ -507,7 +504,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
crossFadeChunks = fadePosition; crossFadeChunks = fadePosition;
} }
test = cb->end; test = cb->end;
if(cb->wrap) test+=buffered_chunks; if(cb->end < cb->begin) test+=buffered_chunks;
nextChunk = cb->begin+crossFadeChunks; nextChunk = cb->begin+crossFadeChunks;
if(nextChunk<test) { if(nextChunk<test) {
if(nextChunk>=buffered_chunks) if(nextChunk>=buffered_chunks)
@ -557,14 +554,13 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
cb->begin++; cb->begin++;
if(cb->begin>=buffered_chunks) { if(cb->begin>=buffered_chunks) {
cb->begin = 0; cb->begin = 0;
cb->wrap = 0;
} }
} }
else if(cb->next==cb->begin) { else if(cb->next==cb->begin) {
if(doCrossFade==1 && nextChunk>=0) { if(doCrossFade==1 && nextChunk>=0) {
nextChunk = cb->begin+crossFadeChunks; nextChunk = cb->begin+crossFadeChunks;
test = cb->end; test = cb->end;
if(cb->wrap) test+=buffered_chunks; if(cb->end < cb->begin) test+=buffered_chunks;
if(nextChunk<test) { if(nextChunk<test) {
if(nextChunk>=buffered_chunks) if(nextChunk>=buffered_chunks)
{ {
@ -631,7 +627,6 @@ void decode() {
cb->begin = 0; cb->begin = 0;
cb->end = 0; cb->end = 0;
cb->wrap = 0;
pc = &(getPlayerData()->playerControl); pc = &(getPlayerData()->playerControl);
dc = &(getPlayerData()->decoderControl); dc = &(getPlayerData()->decoderControl);
dc->error = 0; dc->error = 0;

View File

@ -42,7 +42,6 @@ void clearOutputBuffer(OutputBuffer * cb) {
currentChunk = -1; currentChunk = -1;
cb->end = cb->begin; cb->end = cb->begin;
cb->wrap = 0;
/* be sure to reset metaChunkSets cause we are skipping over audio /* be sure to reset metaChunkSets cause we are skipping over audio
* audio chunks, and thus skipping over metadata */ * audio chunks, and thus skipping over metadata */
@ -60,7 +59,6 @@ void flushOutputBuffer(OutputBuffer * cb) {
cb->end++; cb->end++;
if(cb->end>=buffered_chunks) { if(cb->end>=buffered_chunks) {
cb->end = 0; cb->end = 0;
cb->wrap = 1;
} }
currentChunk = -1; currentChunk = -1;
} }
@ -97,8 +95,11 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
while(datalen) { while(datalen) {
if(currentChunk != cb->end) { if(currentChunk != cb->end) {
while(cb->begin==cb->end && cb->wrap && !dc->stop) int next = cb->end+1;
{ if(next>=buffered_chunks) {
next = 0;
}
while(cb->begin==next && !dc->stop) {
if(dc->seek) { if(dc->seek) {
if(seekable) { if(seekable) {
return OUTPUT_BUFFER_DC_SEEK; return OUTPUT_BUFFER_DC_SEEK;

View File

@ -38,7 +38,6 @@ typedef struct _OutputBuffer {
mpd_sint16 volatile begin; mpd_sint16 volatile begin;
mpd_sint16 volatile end; mpd_sint16 volatile end;
mpd_sint16 volatile next; mpd_sint16 volatile next;
mpd_sint8 volatile wrap;
AudioFormat audioFormat; AudioFormat audioFormat;
MetadataChunk metadataChunks[BUFFERED_METACHUNKS]; MetadataChunk metadataChunks[BUFFERED_METACHUNKS];
mpd_sint8 metaChunkSet[BUFFERED_METACHUNKS]; mpd_sint8 metaChunkSet[BUFFERED_METACHUNKS];