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)
1) Fix a statement in the middle of declarations in listen.c, causes error for
gcc 2.7
......
......@@ -1745,7 +1745,7 @@ fi
# Define the identity of the package.
PACKAGE=mpd
VERSION=0.9.1
VERSION=0.9.2
cat >>confdefs.h <<_ACEOF
......
AC_INIT(src/main.c)
AM_INIT_AUTOMAKE(mpd, 0.9.1)
AM_INIT_AUTOMAKE(mpd, 0.9.2)
AC_PROG_CC
AC_PROG_INSTALL
......
......@@ -88,6 +88,9 @@ playlistinfo
previous
plays previous song in playlist
random <int state>
set random state to _state_, _state_ should be 0 or 1
repeat <int state>
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
.B max_connections <int>
This specifies the maximum number of clients that can be connected to MPD. The default is 5 connections.
.TP
.B mixer_type <oss or alsa>
This specifies which mixer to use. The default is oss.
.TP
.B mixer_device <mixer dev>
This specifies which mixer to use. The default for oss is /dev/mixer;
the default for alsa is "hw:0".
.TP
.B mixer_type <oss or alsa>
This specifies which mixer to use. The default is oss.
.B mixer_control <string>
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
.B max_playlist_length <int>
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"
# optional
mixer_type "oss"
mixer_device "/dev/mixer"
#mixer_control "Pcm"
#mixer_type "alsa"
#mixer_device "default"
#mixer_control "PCM"
#ao_driver "oss"
#ao_driver_options "dsp=/dev/dsp"
max_playlist_length "4096"
......
......@@ -25,6 +25,8 @@
#include <assert.h>
#include <signal.h>
#define PLAY_SIZE 64
int audio_ao_driver_id;
ao_option * audio_ao_options;
......@@ -57,6 +59,7 @@ void initAudioDriver() {
if((ai = ao_driver_info(audio_ao_driver_id))==NULL) {
ERROR0("problems getting ao_driver_info\n");
ERROR0("you may not have permission to the audio device\n");
exit(-1);
}
......@@ -142,9 +145,18 @@ int initAudio(AudioFormat * audioFormat) {
void playAudio(char * playChunk, int size) {
int send;
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() {
......
......@@ -34,7 +34,7 @@
#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_REQUIRED 5
......@@ -85,7 +85,8 @@ char * conf_strings[CONF_NUMBER_OF_PARAMS] = {
"state_file",
"user",
"db_file",
"log_level"
"log_level",
"mixer_control"
};
int conf_absolutePaths[CONF_NUMBER_OF_PATHS] = {
......
......@@ -40,6 +40,7 @@
#define CONF_USER 18
#define CONF_DB_FILE 19
#define CONF_LOG_LEVEL 20
#define CONF_MIXER_CONTROL 21
/* do not free the return value, it is a static variable */
char ** readConf(char * file);
......
......@@ -465,12 +465,14 @@ int readDirectoryDB() {
int updateMp3Directory(FILE * fp) {
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;
}
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;
}
......
......@@ -59,13 +59,9 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
{
int current_section;
int eof = 0;
struct timeval tv;
long ret;
char chunk[CHUNK_SIZE];
tv.tv_sec = 0;
tv.tv_usec = 0;
while(!eof) {
if(dc->seek) {
cb->end = 0;
......
......@@ -64,7 +64,7 @@ void initPlayerData() {
playerData_pd->playerControl.stop = 0;
playerData_pd->playerControl.pause = 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.unlockQueue = 0;
playerData_pd->playerControl.state = PLAYER_STATE_STOP;
......@@ -77,6 +77,7 @@ void initPlayerData() {
playerData_pd->decoderControl.start = 0;
playerData_pd->decoderControl.state = DECODE_STATE_STOP;
playerData_pd->decoderControl.seek = 0;
playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR;
playerData_pd->decoderControl.file[0] = '\0';
}
......
......@@ -23,19 +23,14 @@
#include "player.h"
#include "decode.h"
/*
#define CHUNK_SIZE 256
#define BUFFERED_CHUNKS 8192
#define PLAY_SIZE 64
*/
#define CHUNK_SIZE 64
#define BUFFERED_CHUNKS 32768 /* 2 MB of buffer */
#define CHUNK_SIZE 1024
#define BUFFERED_CHUNKS 2048 /* 2 MB of buffer */
extern int buffered_before_play;
typedef struct _Buffer {
char chunks[BUFFERED_CHUNKS][CHUNK_SIZE];
unsigned char chunkSize[BUFFERED_CHUNKS];
uint_16 chunkSize[BUFFERED_CHUNKS];
float times[BUFFERED_CHUNKS];
int begin;
int end;
......
......@@ -75,7 +75,7 @@ Playlist playlist;
int playlist_state = PLAYLIST_STATE_STOP;
int playlist_max_length;
int playlist_stopOnError;
int playlist_errorCount;
int playlist_errorCount = 0;
int playlist_queueError;
int playlist_saveAbsolutePaths;
......@@ -681,12 +681,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
}
if(playlist.random) {
if(song>=0) for(i=0;song!=playlist.order[i];i++);
if(playlist_state==PLAYLIST_STATE_STOP) {
playlist.current = 0;
/*if(song == -1 && playlist_state==PLAYLIST_STATE_PLAY) {
randomizeOrder(0,playlist.length-1);
}
swapOrder(i,playlist.current);
i = playlist.current;
else {*/
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;
......@@ -702,10 +707,12 @@ void playPlaylistIfPlayerStopped() {
if(error==PLAYER_ERROR_NOERROR) playlist_errorCount = 0;
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_SYSTEM ||
playlist_errorCount>=playlist.length) {
playlist_errorCount>=playlist.length)) {
stopPlaylist(stderr);
}
else nextSongInPlaylist(stderr);
......@@ -733,7 +740,9 @@ int nextSongInPlaylist(FILE * fp) {
if(playlist.random) randomizeOrder(0,playlist.length-1);
return playPlaylistOrderNumber(fp,0);
}
else return stopPlaylist(fp);;
else {
return stopPlaylist(fp);;
}
return 0;
}
......@@ -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];
/* move songs to one more in to->from */
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;
/* now deal with order */
if(playlist.random) {
......@@ -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) {
playlist.current--;
}
else if(playlist.current>=to && playlist.current<from) {
playlist.current++;
}
unblockTermSignal();
......
......@@ -46,6 +46,7 @@ char * volume_mixerDevice;
#ifndef NO_OSSMIXER
int volume_ossFd;
int volume_ossControl = SOUND_MIXER_VOLUME;
#endif
#ifdef HAVE_ALSA
......@@ -57,11 +58,52 @@ long volume_alsaMax;
#ifndef NO_OSS_MIXER
int prepOssMixer(char * device) {
int devmask = 0;
if((volume_ossFd = open(device,O_RDONLY))<0) {
ERROR1("unable to open oss mixer \"%s\"\n",device);
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;
}
......@@ -72,7 +114,7 @@ void closeOssMixer() {
int getOssVolumeLevel() {
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);
ERROR0("unable to read volume\n");
return -1;
......@@ -106,7 +148,7 @@ int changeOssVolumeLevel(FILE * fp, int change) {
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);
return -1;
}
......@@ -118,6 +160,7 @@ int changeOssVolumeLevel(FILE * fp, int change) {
#ifdef HAVE_ALSA
int prepAlsaMixer(char * card) {
int err;
snd_mixer_elem_t * elem;
if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) {
ERROR1("problems opening alsa mixer: %s\n",snd_strerror(err));
......@@ -145,11 +188,40 @@ int prepAlsaMixer(char * card) {
return -1;
}
volume_alsaElem = snd_mixer_first_elem(volume_alsaMixerHandle);
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;
elem = snd_mixer_first_elem(volume_alsaMixerHandle);
if(getConf()[CONF_MIXER_CONTROL]) {
while(elem) {
if(snd_mixer_elem_get_type(elem)
==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);
......
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