implement list_OK/command_list_ok_begin

update COMMANDS

git-svn-id: https://svn.musicpd.org/mpd/trunk@1344 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-06-05 16:01:44 +00:00
parent 69d787b3e1
commit a8a8aacdb3
5 changed files with 49 additions and 38 deletions

View File

@ -110,6 +110,10 @@ playlistinfo <int song>
displays list of songs in the playlist displays list of songs in the playlist
_song_ is optional and species a single song to displa info for _song_ is optional and species a single song to displa info for
plchanges <playlist version>
displays changed songs currently in the playlist since
_playlist version_
previous previous
plays previous song in playlist plays previous song in playlist
@ -198,6 +202,10 @@ at once using a command list. The command list beings with:
command_list_begin command_list_begin
or:
command_list_ok_begin
And ends with: And ends with:
command_list_end command_list_end
@ -205,4 +213,5 @@ command_list_end
It does not execute any commands until the list has ended. The return It does not execute any commands until the list has ended. The return
value is whatever the return for a list of commands is. On success value is whatever the return for a list of commands is. On success
for all commands, OK is returned. If a command fails, no more commands for all commands, OK is returned. If a command fails, no more commands
are executed and the appropriate ACK error is returned. are executed and the appropriate ACK error is returned. If "command_list_ok_begin is used", "list_OK\n" is returned for each successful command executed
in the command list.

View File

@ -786,7 +786,7 @@ int processCommandInternal(FILE * fp, unsigned int * permission,
} }
int proccessListOfCommands(FILE * fp, int * permission, int * expired, int proccessListOfCommands(FILE * fp, int * permission, int * expired,
List * list) int listOK, List * list)
{ {
ListNode * node = list->firstNode; ListNode * node = list->firstNode;
ListNode * tempNode; ListNode * tempNode;
@ -804,6 +804,7 @@ int proccessListOfCommands(FILE * fp, int * permission, int * expired,
deleteNodeFromList(list,node); deleteNodeFromList(list,node);
node = tempNode; node = tempNode;
if(ret!=0 || (*expired)!=0) node = NULL; if(ret!=0 || (*expired)!=0) node = NULL;
else if(listOK) myfprintf(fp, "list_OK\n");
command_listNum++; command_listNum++;
} }

View File

@ -35,7 +35,7 @@ extern char * current_command;
extern int command_listNum; extern int command_listNum;
int proccessListOfCommands(FILE * fp, int * permission, int * expired, int proccessListOfCommands(FILE * fp, int * permission, int * expired,
List * list); int listOK, List * list);
int processCommand(FILE * fp, unsigned int * permission, char * commandString); int processCommand(FILE * fp, unsigned int * permission, char * commandString);

View File

@ -205,13 +205,16 @@ void putOggCommentsIntoDecoderControlMetadata(DecoderControl * dc,
{ {
MpdTag * tag; MpdTag * tag;
if(dc->metadataSet) return;
tag = oggCommentsParse(comments); tag = oggCommentsParse(comments);
if(!tag) return; if(!tag) return;
copyMpdTagToDecoderControlMetadata(dc, tag); copyMpdTagToDecoderControlMetadata(dc, tag);
/*if(tag->artist) printf("Artist: %s\n", tag->artist);
if(tag->album) printf("Album: %s\n", tag->album);
if(tag->track) printf("Track: %s\n", tag->track);
if(tag->title) printf("Title: %s\n", tag->title);*/
freeMpdTag(tag); freeMpdTag(tag);
} }
@ -229,7 +232,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
int chunkpos = 0; int chunkpos = 0;
long bitRate = 0; long bitRate = 0;
long test; long test;
float replayGainScale; float replayGainScale = 1.0;
char ** comments; char ** comments;
data.inStream = inStream; data.inStream = inStream;
@ -253,24 +256,10 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
return 0; return 0;
} }
{
vorbis_info *vi=ov_info(&vf,-1);
dc->audioFormat.bits = 16;
dc->audioFormat.channels = vi->channels;
dc->audioFormat.sampleRate = vi->rate;
getOutputAudioFormat(&(dc->audioFormat),&(cb->audioFormat));
}
dc->totalTime = ov_time_total(&vf,-1); dc->totalTime = ov_time_total(&vf,-1);
if(dc->totalTime < 0) dc->totalTime = 0; if(dc->totalTime < 0) dc->totalTime = 0;
comments = ov_comment(&vf, -1)->user_comments; dc->audioFormat.bits = 16;
putOggCommentsIntoDecoderControlMetadata(dc, comments);
dc->state = DECODE_STATE_DECODE;
replayGainScale = ogg_getReplayGainScale(comments);
while(!eof) { while(!eof) {
if(dc->seek) { if(dc->seek) {
@ -286,7 +275,17 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
OGG_DECODE_USE_BIGENDIAN, OGG_DECODE_USE_BIGENDIAN,
2, 1, &current_section); 2, 1, &current_section);
if(current_section!=prev_section) printf("song changed!\n"); if(current_section!=prev_section) {
/*printf("new song!\n");*/
vorbis_info *vi=ov_info(&vf,-1);
dc->audioFormat.channels = vi->channels;
dc->audioFormat.sampleRate = vi->rate;
getOutputAudioFormat(&(dc->audioFormat),&(cb->audioFormat));
comments = ov_comment(&vf, -1)->user_comments;
putOggCommentsIntoDecoderControlMetadata(dc, comments);
dc->state = DECODE_STATE_DECODE;
replayGainScale = ogg_getReplayGainScale(comments);
}
prev_section = current_section; prev_section = current_section;

View File

@ -45,6 +45,7 @@
#define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024 #define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin" #define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
#define INTERFACE_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define INTERFACE_LIST_MODE_END "command_list_end" #define INTERFACE_LIST_MODE_END "command_list_end"
#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096 #define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096
@ -62,6 +63,7 @@ typedef struct _Interface {
unsigned int permission; unsigned int permission;
time_t lastTime; time_t lastTime;
List * commandList; /* for when in list mode */ List * commandList; /* for when in list mode */
int commandListOK; /* print OK after each command execution */
unsigned long long commandListSize; /* mem commandList consumes */ unsigned long long commandListSize; /* mem commandList consumes */
List * bufferList; /* for output if client is slow */ List * bufferList; /* for output if client is slow */
unsigned long long outputBufferSize; /* mem bufferList consumes */ unsigned long long outputBufferSize; /* mem bufferList consumes */
@ -230,6 +232,7 @@ int interfaceReadInput(Interface * interface) {
interface->fp, interface->fp,
&(interface->permission), &(interface->permission),
&(interface->expired), &(interface->expired),
interface->commandListOK,
interface->commandList); interface->commandList);
DEBUG("interface %i: process command " DEBUG("interface %i: process command "
"list returned %i\n", "list returned %i\n",
@ -281,27 +284,27 @@ int interfaceReadInput(Interface * interface) {
interface->commandList = makeList(free); interface->commandList = makeList(free);
interface->commandListSize = interface->commandListSize =
sizeof(List); sizeof(List);
interface->commandListOK = 0;
ret = 1;
}
else if(strcmp(interface->buffer,
INTERFACE_LIST_OK_MODE_BEGIN)
==0)
{
interface->commandList = makeList(free);
interface->commandListSize =
sizeof(List);
interface->commandListOK = 1;
ret = 1; ret = 1;
} }
else { else {
if(strcmp(interface->buffer, DEBUG("interface %i: process command \"%s\"\n",interface->num,interface->buffer);
INTERFACE_LIST_MODE_END) ret = processCommand(
==0)
{
commandError(interface->fp,
ACK_ERROR_NOT_LIST,
"not in command list mode");
ret = -1;
}
else {
DEBUG("interface %i: process command \"%s\"\n",interface->num,interface->buffer);
ret = processCommand(
interface->fp, interface->fp,
&(interface-> &(interface->
permission), permission),
interface->buffer); interface->buffer);
DEBUG("interface %i: command returned %i\n",interface->num,ret); DEBUG("interface %i: command returned %i\n",interface->num,ret);
}
if(ret==0) { if(ret==0) {
commandSuccess(interface->fp); commandSuccess(interface->fp);
} }
@ -648,4 +651,3 @@ void printInterfaceOutBuffer(Interface * interface) {
interface->outBuflen = 0; interface->outBuflen = 0;
} }
/* vim:set shiftwidth=4 tabstop=8 expandtab: */