Commit 4b5e4c06 authored by Led's avatar Led

0.9.2-rc1

parent a8b9bc70
ver 0.9.2 (2003/10/6)
1) Fix FreeBSD Compilation Problems
2) Fix bug in move command
3) Add mixer_control options to configure which mixer control/device mpd controls
4) Randomize on play -1
ver 0.9.1 (2003/9/30) ver 0.9.1 (2003/9/30)
1) Fix a statement in the middle of declarations in listen.c, causes error for 1) Fix a statement in the middle of declarations in listen.c, causes error for
gcc 2.7 gcc 2.7
......
...@@ -1745,7 +1745,7 @@ fi ...@@ -1745,7 +1745,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE=mpd PACKAGE=mpd
VERSION=0.9.1 VERSION=0.9.2
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
......
AC_INIT(src/main.c) AC_INIT(src/main.c)
AM_INIT_AUTOMAKE(mpd, 0.9.1) AM_INIT_AUTOMAKE(mpd, 0.9.2)
AC_PROG_CC AC_PROG_CC
AC_PROG_INSTALL AC_PROG_INSTALL
......
...@@ -88,6 +88,9 @@ playlistinfo ...@@ -88,6 +88,9 @@ playlistinfo
previous previous
plays previous song in playlist plays previous song in playlist
random <int state>
set random state to _state_, _state_ should be 0 or 1
repeat <int state> repeat <int state>
set repeat state to _state_, _state_ should be 0 or 1 set repeat state to _state_, _state_ should be 0 or 1
......
...@@ -78,12 +78,15 @@ If a client does not send any new data in this time period, the connection is cl ...@@ -78,12 +78,15 @@ If a client does not send any new data in this time period, the connection is cl
.B max_connections <int> .B max_connections <int>
This specifies the maximum number of clients that can be connected to MPD. The default is 5 connections. This specifies the maximum number of clients that can be connected to MPD. The default is 5 connections.
.TP .TP
.B mixer_type <oss or alsa>
This specifies which mixer to use. The default is oss.
.TP
.B mixer_device <mixer dev> .B mixer_device <mixer dev>
This specifies which mixer to use. The default for oss is /dev/mixer; This specifies which mixer to use. The default for oss is /dev/mixer;
the default for alsa is "hw:0". the default for alsa is "hw:0".
.TP .TP
.B mixer_type <oss or alsa> .B mixer_control <string>
This specifies which mixer to use. The default is oss. This specifies which mixer control to use (sometimes referred to as the "device"). Examples of mixer controls are PCM, Line1, Master, etc. An example for OSS is "Pcm", and an example for alsa is "PCM".
.TP .TP
.B max_playlist_length <int> .B max_playlist_length <int>
This specifies the maximum number of songs that can be in the playlist. The default is 4096 songs. This specifies the maximum number of songs that can be in the playlist. The default is 4096 songs.
......
...@@ -8,8 +8,10 @@ error_file "/home/shank/mpd.error" ...@@ -8,8 +8,10 @@ error_file "/home/shank/mpd.error"
# optional # optional
mixer_type "oss" mixer_type "oss"
mixer_device "/dev/mixer" mixer_device "/dev/mixer"
#mixer_control "Pcm"
#mixer_type "alsa" #mixer_type "alsa"
#mixer_device "default" #mixer_device "default"
#mixer_control "PCM"
#ao_driver "oss" #ao_driver "oss"
#ao_driver_options "dsp=/dev/dsp" #ao_driver_options "dsp=/dev/dsp"
max_playlist_length "4096" max_playlist_length "4096"
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
#define PLAY_SIZE 64
int audio_ao_driver_id; int audio_ao_driver_id;
ao_option * audio_ao_options; ao_option * audio_ao_options;
...@@ -57,6 +59,7 @@ void initAudioDriver() { ...@@ -57,6 +59,7 @@ void initAudioDriver() {
if((ai = ao_driver_info(audio_ao_driver_id))==NULL) { if((ai = ao_driver_info(audio_ao_driver_id))==NULL) {
ERROR0("problems getting ao_driver_info\n"); ERROR0("problems getting ao_driver_info\n");
ERROR0("you may not have permission to the audio device\n");
exit(-1); exit(-1);
} }
...@@ -142,9 +145,18 @@ int initAudio(AudioFormat * audioFormat) { ...@@ -142,9 +145,18 @@ int initAudio(AudioFormat * audioFormat) {
void playAudio(char * playChunk, int size) { void playAudio(char * playChunk, int size) {
int send;
assert(audio_device!=NULL); assert(audio_device!=NULL);
ao_play(audio_device,playChunk,size); while(size>0) {
send = PLAY_SIZE>size?size:PLAY_SIZE;
ao_play(audio_device,playChunk,send);
playChunk+=send;
size-=send;
}
} }
void finishAudio() { void finishAudio() {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#define CONF_COMMENT '#' #define CONF_COMMENT '#'
#define CONF_NUMBER_OF_PARAMS 21 #define CONF_NUMBER_OF_PARAMS 22
#define CONF_NUMBER_OF_PATHS 6 #define CONF_NUMBER_OF_PATHS 6
#define CONF_NUMBER_OF_REQUIRED 5 #define CONF_NUMBER_OF_REQUIRED 5
...@@ -85,7 +85,8 @@ char * conf_strings[CONF_NUMBER_OF_PARAMS] = { ...@@ -85,7 +85,8 @@ char * conf_strings[CONF_NUMBER_OF_PARAMS] = {
"state_file", "state_file",
"user", "user",
"db_file", "db_file",
"log_level" "log_level",
"mixer_control"
}; };
int conf_absolutePaths[CONF_NUMBER_OF_PATHS] = { int conf_absolutePaths[CONF_NUMBER_OF_PATHS] = {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#define CONF_USER 18 #define CONF_USER 18
#define CONF_DB_FILE 19 #define CONF_DB_FILE 19
#define CONF_LOG_LEVEL 20 #define CONF_LOG_LEVEL 20
#define CONF_MIXER_CONTROL 21
/* do not free the return value, it is a static variable */ /* do not free the return value, it is a static variable */
char ** readConf(char * file); char ** readConf(char * file);
......
...@@ -465,12 +465,14 @@ int readDirectoryDB() { ...@@ -465,12 +465,14 @@ int readDirectoryDB() {
int updateMp3Directory(FILE * fp) { int updateMp3Directory(FILE * fp) {
if(updateDirectory(mp3rootDirectory)<0) { if(updateDirectory(mp3rootDirectory)<0) {
myfprintf(fp,"%s problems updating directory info\n",COMMAND_RESPOND_ERROR); ERROR0("problems updating music db\n");
myfprintf(fp,"%s problems updating music db\n",COMMAND_RESPOND_ERROR);
return -1; return -1;
} }
if(writeDirectoryDB()<0) { if(writeDirectoryDB()<0) {
myfprintf(fp,"%s problems writing directory info\n",COMMAND_RESPOND_ERROR); ERROR1("problems writing music db file, \"%s\"\n",directorydb);
myfprintf(fp,"%s problems writing music db\n",COMMAND_RESPOND_ERROR);
return -1; return -1;
} }
......
...@@ -59,13 +59,9 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) ...@@ -59,13 +59,9 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
{ {
int current_section; int current_section;
int eof = 0; int eof = 0;
struct timeval tv;
long ret; long ret;
char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
tv.tv_sec = 0;
tv.tv_usec = 0;
while(!eof) { while(!eof) {
if(dc->seek) { if(dc->seek) {
cb->end = 0; cb->end = 0;
......
...@@ -64,7 +64,7 @@ void initPlayerData() { ...@@ -64,7 +64,7 @@ void initPlayerData() {
playerData_pd->playerControl.stop = 0; playerData_pd->playerControl.stop = 0;
playerData_pd->playerControl.pause = 0; playerData_pd->playerControl.pause = 0;
playerData_pd->playerControl.play = 0; playerData_pd->playerControl.play = 0;
playerData_pd->playerControl.error = 0; playerData_pd->playerControl.error = PLAYER_ERROR_NOERROR;
playerData_pd->playerControl.lockQueue = 0; playerData_pd->playerControl.lockQueue = 0;
playerData_pd->playerControl.unlockQueue = 0; playerData_pd->playerControl.unlockQueue = 0;
playerData_pd->playerControl.state = PLAYER_STATE_STOP; playerData_pd->playerControl.state = PLAYER_STATE_STOP;
...@@ -77,6 +77,7 @@ void initPlayerData() { ...@@ -77,6 +77,7 @@ void initPlayerData() {
playerData_pd->decoderControl.start = 0; playerData_pd->decoderControl.start = 0;
playerData_pd->decoderControl.state = DECODE_STATE_STOP; playerData_pd->decoderControl.state = DECODE_STATE_STOP;
playerData_pd->decoderControl.seek = 0; playerData_pd->decoderControl.seek = 0;
playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR;
playerData_pd->decoderControl.file[0] = '\0'; playerData_pd->decoderControl.file[0] = '\0';
} }
......
...@@ -23,19 +23,14 @@ ...@@ -23,19 +23,14 @@
#include "player.h" #include "player.h"
#include "decode.h" #include "decode.h"
/* #define CHUNK_SIZE 1024
#define CHUNK_SIZE 256 #define BUFFERED_CHUNKS 2048 /* 2 MB of buffer */
#define BUFFERED_CHUNKS 8192
#define PLAY_SIZE 64
*/
#define CHUNK_SIZE 64
#define BUFFERED_CHUNKS 32768 /* 2 MB of buffer */
extern int buffered_before_play; extern int buffered_before_play;
typedef struct _Buffer { typedef struct _Buffer {
char chunks[BUFFERED_CHUNKS][CHUNK_SIZE]; char chunks[BUFFERED_CHUNKS][CHUNK_SIZE];
unsigned char chunkSize[BUFFERED_CHUNKS]; uint_16 chunkSize[BUFFERED_CHUNKS];
float times[BUFFERED_CHUNKS]; float times[BUFFERED_CHUNKS];
int begin; int begin;
int end; int end;
......
...@@ -75,7 +75,7 @@ Playlist playlist; ...@@ -75,7 +75,7 @@ Playlist playlist;
int playlist_state = PLAYLIST_STATE_STOP; int playlist_state = PLAYLIST_STATE_STOP;
int playlist_max_length; int playlist_max_length;
int playlist_stopOnError; int playlist_stopOnError;
int playlist_errorCount; int playlist_errorCount = 0;
int playlist_queueError; int playlist_queueError;
int playlist_saveAbsolutePaths; int playlist_saveAbsolutePaths;
...@@ -681,12 +681,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) { ...@@ -681,12 +681,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
} }
if(playlist.random) { if(playlist.random) {
if(song>=0) for(i=0;song!=playlist.order[i];i++); /*if(song == -1 && playlist_state==PLAYLIST_STATE_PLAY) {
if(playlist_state==PLAYLIST_STATE_STOP) { randomizeOrder(0,playlist.length-1);
playlist.current = 0;
} }
swapOrder(i,playlist.current); else {*/
i = playlist.current; if(song>=0) for(i=0;song!=playlist.order[i];i++);
if(playlist_state==PLAYLIST_STATE_STOP) {
playlist.current = 0;
}
swapOrder(i,playlist.current);
i = playlist.current;
//}
} }
playlist_stopOnError = stopOnError; playlist_stopOnError = stopOnError;
...@@ -702,10 +707,12 @@ void playPlaylistIfPlayerStopped() { ...@@ -702,10 +707,12 @@ void playPlaylistIfPlayerStopped() {
if(error==PLAYER_ERROR_NOERROR) playlist_errorCount = 0; if(error==PLAYER_ERROR_NOERROR) playlist_errorCount = 0;
else playlist_errorCount++; else playlist_errorCount++;
if((playlist_stopOnError && error!=PLAYER_ERROR_NOERROR) || if(playlist_state==PLAYLIST_STATE_PLAY && (
(playlist_stopOnError &&
error!=PLAYER_ERROR_NOERROR) ||
error==PLAYER_ERROR_AUDIO || error==PLAYER_ERROR_AUDIO ||
error==PLAYER_ERROR_SYSTEM || error==PLAYER_ERROR_SYSTEM ||
playlist_errorCount>=playlist.length) { playlist_errorCount>=playlist.length)) {
stopPlaylist(stderr); stopPlaylist(stderr);
} }
else nextSongInPlaylist(stderr); else nextSongInPlaylist(stderr);
...@@ -733,7 +740,9 @@ int nextSongInPlaylist(FILE * fp) { ...@@ -733,7 +740,9 @@ int nextSongInPlaylist(FILE * fp) {
if(playlist.random) randomizeOrder(0,playlist.length-1); if(playlist.random) randomizeOrder(0,playlist.length-1);
return playPlaylistOrderNumber(fp,0); return playPlaylistOrderNumber(fp,0);
} }
else return stopPlaylist(fp);; else {
return stopPlaylist(fp);;
}
return 0; return 0;
} }
...@@ -796,7 +805,7 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { ...@@ -796,7 +805,7 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
for(i=from;i<to;i++) playlist.songs[i] = playlist.songs[i+1]; for(i=from;i<to;i++) playlist.songs[i] = playlist.songs[i+1];
/* move songs to one more in to->from */ /* move songs to one more in to->from */
for(i=from;i>to;i--) playlist.songs[i] = playlist.songs[i-1]; for(i=from;i>to;i--) playlist.songs[i] = playlist.songs[i-1];
/* but song at _to_ */ /* put song at _to_ */
playlist.songs[to] = tmpSong; playlist.songs[to] = tmpSong;
/* now deal with order */ /* now deal with order */
if(playlist.random) { if(playlist.random) {
...@@ -814,6 +823,12 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { ...@@ -814,6 +823,12 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
} }
} }
else if(playlist.current==from) playlist.current = to; else if(playlist.current==from) playlist.current = to;
else if(playlist.current>from && playlist.current<=to) {
playlist.current--;
}
else if(playlist.current>=to && playlist.current<from) {
playlist.current++;
}
unblockTermSignal(); unblockTermSignal();
......
...@@ -46,6 +46,7 @@ char * volume_mixerDevice; ...@@ -46,6 +46,7 @@ char * volume_mixerDevice;
#ifndef NO_OSSMIXER #ifndef NO_OSSMIXER
int volume_ossFd; int volume_ossFd;
int volume_ossControl = SOUND_MIXER_VOLUME;
#endif #endif
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
...@@ -57,11 +58,52 @@ long volume_alsaMax; ...@@ -57,11 +58,52 @@ long volume_alsaMax;
#ifndef NO_OSS_MIXER #ifndef NO_OSS_MIXER
int prepOssMixer(char * device) { int prepOssMixer(char * device) {
int devmask = 0;
if((volume_ossFd = open(device,O_RDONLY))<0) { if((volume_ossFd = open(device,O_RDONLY))<0) {
ERROR1("unable to open oss mixer \"%s\"\n",device); ERROR1("unable to open oss mixer \"%s\"\n",device);
return -1; return -1;
} }
if(getConf()[CONF_MIXER_CONTROL]) {
char * labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
char * dup;
int i,j;
if(ioctl(volume_ossFd,SOUND_MIXER_READ_DEVMASK,&devmask)<0) {
ERROR0("errors getting read_devmask for oss mixer\n");
close(volume_ossFd);
return -1;
}
for(i=0;i<SOUND_MIXER_NRDEVICES;i++) {
dup = strdup(labels[i]);
/* eliminate spaces at the end */
j = strlen(dup)-1;
while(j>=0 && dup[j]==' ') dup[j--] = '\0';
if(strcmp(dup,getConf()[CONF_MIXER_CONTROL])==0) {
free(dup);
break;
}
free(dup);
}
if(i>=SOUND_MIXER_NRDEVICES) {
ERROR1("mixer control \"%s\" not found\n",
getConf()[CONF_MIXER_CONTROL]);
close(volume_ossFd);
return -1;
}
else if(!( ( 1 << i ) & devmask )) {
ERROR1("mixer control \"%s\" not usable\n",
getConf()[CONF_MIXER_CONTROL]);
close(volume_ossFd);
return -1;
}
volume_ossControl = i;
}
return 0; return 0;
} }
...@@ -72,7 +114,7 @@ void closeOssMixer() { ...@@ -72,7 +114,7 @@ void closeOssMixer() {
int getOssVolumeLevel() { int getOssVolumeLevel() {
int left, right, level; int left, right, level;
if(ioctl(volume_ossFd,MIXER_READ(SOUND_MIXER_VOLUME),&level) < 0) { if(ioctl(volume_ossFd,MIXER_READ(volume_ossControl),&level) < 0) {
while(close(volume_ossFd)<0 && errno==EINTR); while(close(volume_ossFd)<0 && errno==EINTR);
ERROR0("unable to read volume\n"); ERROR0("unable to read volume\n");
return -1; return -1;
...@@ -106,7 +148,7 @@ int changeOssVolumeLevel(FILE * fp, int change) { ...@@ -106,7 +148,7 @@ int changeOssVolumeLevel(FILE * fp, int change) {
level = (new << 8) + new; level = (new << 8) + new;
if(ioctl(volume_ossFd,MIXER_WRITE(SOUND_MIXER_VOLUME),&level) < 0) { if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) {
myfprintf(fp,"%s problems setting volume\n",COMMAND_RESPOND_ERROR); myfprintf(fp,"%s problems setting volume\n",COMMAND_RESPOND_ERROR);
return -1; return -1;
} }
...@@ -118,6 +160,7 @@ int changeOssVolumeLevel(FILE * fp, int change) { ...@@ -118,6 +160,7 @@ int changeOssVolumeLevel(FILE * fp, int change) {
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
int prepAlsaMixer(char * card) { int prepAlsaMixer(char * card) {
int err; int err;
snd_mixer_elem_t * elem;
if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) { if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) {
ERROR1("problems opening alsa mixer: %s\n",snd_strerror(err)); ERROR1("problems opening alsa mixer: %s\n",snd_strerror(err));
...@@ -145,11 +188,40 @@ int prepAlsaMixer(char * card) { ...@@ -145,11 +188,40 @@ int prepAlsaMixer(char * card) {
return -1; return -1;
} }
volume_alsaElem = snd_mixer_first_elem(volume_alsaMixerHandle); elem = snd_mixer_first_elem(volume_alsaMixerHandle);
if(snd_mixer_elem_get_type(volume_alsaElem)==SND_MIXER_ELEM_SIMPLE) { if(getConf()[CONF_MIXER_CONTROL]) {
snd_mixer_selem_get_playback_volume_range(volume_alsaElem, while(elem) {
&volume_alsaMin,&volume_alsaMax); if(snd_mixer_elem_get_type(elem)
return 0; ==SND_MIXER_ELEM_SIMPLE)
{
if(strcmp(getConf()[CONF_MIXER_CONTROL],
snd_mixer_selem_get_name(elem))
==0)
{
break;
}
}
elem = snd_mixer_elem_next(elem);
}
if(elem) {
volume_alsaElem = elem;
snd_mixer_selem_get_playback_volume_range(
volume_alsaElem,
&volume_alsaMin,&volume_alsaMax);
return 0;
}
}
else {
volume_alsaElem = elem;
if(snd_mixer_elem_get_type(volume_alsaElem)
==SND_MIXER_ELEM_SIMPLE)
{
snd_mixer_selem_get_playback_volume_range(
volume_alsaElem,
&volume_alsaMin,&volume_alsaMax);
return 0;
}
} }
snd_mixer_close(volume_alsaMixerHandle); snd_mixer_close(volume_alsaMixerHandle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment