close audio device on pause
git-svn-id: https://svn.musicpd.org/mpd/trunk@329 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
115b0d06cd
commit
6436b0ac8a
17
src/audio.c
17
src/audio.c
|
@ -131,18 +131,21 @@ int isCurrentAudioFormat(AudioFormat * audioFormat) {
|
||||||
int initAudio(AudioFormat * audioFormat) {
|
int initAudio(AudioFormat * audioFormat) {
|
||||||
ao_sample_format format;
|
ao_sample_format format;
|
||||||
|
|
||||||
if(audio_device && !isCurrentAudioFormat(audioFormat)) {
|
if(audioFormat && audio_device && !isCurrentAudioFormat(audioFormat)) {
|
||||||
finishAudio();
|
finishAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!audio_device) {
|
if(!audio_device) {
|
||||||
format.bits = audioFormat->bits;
|
if(audioFormat) {
|
||||||
format.rate = audioFormat->sampleRate;
|
audio_format.bits = audioFormat->bits;
|
||||||
|
audio_format.sampleRate = audioFormat->sampleRate;
|
||||||
|
audio_format.channels = audioFormat->channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
format.bits = audio_format.bits;
|
||||||
|
format.rate = audio_format.sampleRate;
|
||||||
format.byte_format = AO_FMT_NATIVE;
|
format.byte_format = AO_FMT_NATIVE;
|
||||||
format.channels = audioFormat->channels;
|
format.channels = audio_format.channels;
|
||||||
audio_format.bits = format.bits;
|
|
||||||
audio_format.sampleRate = format.rate;
|
|
||||||
audio_format.channels = format.channels;
|
|
||||||
|
|
||||||
blockSignals();
|
blockSignals();
|
||||||
audio_device = ao_open_live(audio_ao_driver_id, &format,
|
audio_device = ao_open_live(audio_ao_driver_id, &format,
|
||||||
|
|
|
@ -104,10 +104,6 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
|
||||||
if(dc->stop) break;
|
if(dc->stop) break;
|
||||||
else if(dc->seek) continue;
|
else if(dc->seek) continue;
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
pcm_changeBufferEndianness(chunk,CHUNK_SIZE,
|
|
||||||
af->bits);
|
|
||||||
#endif
|
|
||||||
memcpy(cb->chunks+cb->end*CHUNK_SIZE,chunk,
|
memcpy(cb->chunks+cb->end*CHUNK_SIZE,chunk,
|
||||||
CHUNK_SIZE);
|
CHUNK_SIZE);
|
||||||
cb->chunkSize[cb->end] = CHUNK_SIZE;
|
cb->chunkSize[cb->end] = CHUNK_SIZE;
|
||||||
|
|
22
src/decode.c
22
src/decode.c
|
@ -180,8 +180,19 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
|
||||||
} \
|
} \
|
||||||
if(pc->pause) { \
|
if(pc->pause) { \
|
||||||
pause = !pause; \
|
pause = !pause; \
|
||||||
if(pause) pc->state = PLAYER_STATE_PAUSE; \
|
if(pause) { \
|
||||||
else pc->state = PLAYER_STATE_PLAY; \
|
finishAudio(); \
|
||||||
|
pc->state = PLAYER_STATE_PAUSE; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
if(initAudio(NULL)<0) { \
|
||||||
|
strncpy(pc->erroredFile,pc->file,MAXPATHLEN); \
|
||||||
|
pc->error = PLAYER_ERROR_AUDIO; \
|
||||||
|
quitDecode(pc,dc); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
pc->state = PLAYER_STATE_PLAY; \
|
||||||
|
} \
|
||||||
pc->pause = 0; \
|
pc->pause = 0; \
|
||||||
kill(getppid(),SIGUSR1); \
|
kill(getppid(),SIGUSR1); \
|
||||||
} \
|
} \
|
||||||
|
@ -296,7 +307,6 @@ void decode() {
|
||||||
|
|
||||||
{
|
{
|
||||||
/* PARENT */
|
/* PARENT */
|
||||||
char silence[CHUNK_SIZE];
|
|
||||||
int pause = 0;
|
int pause = 0;
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
int bbp = buffered_before_play;
|
int bbp = buffered_before_play;
|
||||||
|
@ -306,8 +316,6 @@ void decode() {
|
||||||
int nextChunk = -1;
|
int nextChunk = -1;
|
||||||
int test;
|
int test;
|
||||||
|
|
||||||
memset(silence,0,CHUNK_SIZE);
|
|
||||||
|
|
||||||
if(waitOnDecode(pc,af,dc,cb)<0) return;
|
if(waitOnDecode(pc,af,dc,cb)<0) return;
|
||||||
|
|
||||||
pc->state = PLAYER_STATE_PLAY;
|
pc->state = PLAYER_STATE_PLAY;
|
||||||
|
@ -348,9 +356,7 @@ void decode() {
|
||||||
}
|
}
|
||||||
else doCrossFade = -1;
|
else doCrossFade = -1;
|
||||||
}
|
}
|
||||||
if(pause) {
|
if(pause) usleep(10000);
|
||||||
if(playAudio(silence,CHUNK_SIZE)<0) quit = 1;
|
|
||||||
}
|
|
||||||
else if((cb->begin!=cb->end || cb->wrap) &&
|
else if((cb->begin!=cb->end || cb->wrap) &&
|
||||||
cb->begin!=cb->next)
|
cb->begin!=cb->next)
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,9 +251,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
size_t size = sampleBufferLen>CHUNK_SIZE-chunkLen ?
|
size_t size = sampleBufferLen>CHUNK_SIZE-chunkLen ?
|
||||||
CHUNK_SIZE-chunkLen:
|
CHUNK_SIZE-chunkLen:
|
||||||
sampleBufferLen;
|
sampleBufferLen;
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
pcm_changeBufferEndianness(sampleBuffer,size,af->bits);
|
|
||||||
#endif
|
|
||||||
while(cb->begin==cb->end && cb->wrap &&
|
while(cb->begin==cb->end && cb->wrap &&
|
||||||
!dc->stop && !dc->seek)
|
!dc->stop && !dc->seek)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue