diff options
author | Eric Wong <normalperson@yhbt.net> | 2005-12-31 04:11:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2005-12-31 04:11:03 +0000 |
commit | ea5d367ecf00f9ac4a5e8f0d8cc8909538f42640 (patch) | |
tree | 306ea7e269c2f6d520dddd2b1d8c5c4366b8ef21 | |
parent | 18e5825cae10e3500ff75fdbbb7a768b8387a1c2 (diff) | |
download | mpd-ea5d367ecf00f9ac4a5e8f0d8cc8909538f42640.tar.gz mpd-ea5d367ecf00f9ac4a5e8f0d8cc8909538f42640.tar.xz mpd-ea5d367ecf00f9ac4a5e8f0d8cc8909538f42640.zip |
r1071@BL4ST: normalperson | 2005-12-30 20:05:16 -0800
merge with trunk:
* potential fix for bug #466 (shank, ALSA)
* Configure fix, so when no glib found it gives a error, and another race
condition fix in the master proces patch. (qball)
* call dropBufferedAudio() when pausing (shank)
* flac_plugin: revert the performance optimization we did a while ago
the performance optimization was broken for big-endian architectures.
mpd-uclinux is doing using a slightly different optimization to flacWrite()
that we may end up using here in the future. (me/qball)
----------------------------------------------------------------------
git-svn-id: https://svn.musicpd.org/mpd/branches/oggflac@3754 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 12 | ||||
-rw-r--r-- | src/decode.c | 5 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 42 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 45 | ||||
-rw-r--r-- | src/main.c | 2 |
6 files changed, 52 insertions, 56 deletions
diff --git a/configure.ac b/configure.ac index e9af7e634..3ed85057e 100644 --- a/configure.ac +++ b/configure.ac @@ -85,7 +85,7 @@ AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",) AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",) -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0, [MPD_LIBS="$MPD_LIBS $GLIB_LIBS" MPD_CFLAGS="$MPD_CFLAGS $GLIB_CFLAGS"],[echo "Unable to find glib-2.0 of version 2.0 or above"]) +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0, [MPD_LIBS="$MPD_LIBS $GLIB_LIBS" MPD_CFLAGS="$MPD_CFLAGS $GLIB_CFLAGS"],[echo "";echo "** ERROR:Unable to find glib-2.0 of version 2.0 or above **" ; exit 1]) diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index e3378143e..c895a9566 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -282,12 +282,6 @@ fail: return -1; } -static void alsa_dropBufferedAudio(AudioOutput * audioOutput) { - AlsaData * ad = audioOutput->data; - - snd_pcm_drop(ad->pcmHandle); -} - inline static int alsa_errorRecovery(AlsaData * ad, int err) { if(err == -EPIPE) { DEBUG("Underrun on alsa device \"%s\"\n", ad->device); @@ -317,6 +311,12 @@ inline static int alsa_errorRecovery(AlsaData * ad, int err) { return err; } +static void alsa_dropBufferedAudio(AudioOutput * audioOutput) { + AlsaData * ad = audioOutput->data; + + alsa_errorRecovery( ad, snd_pcm_drop(ad->pcmHandle) ); +} + static void alsa_closeDevice(AudioOutput * audioOutput) { AlsaData * ad = audioOutput->data; diff --git a/src/decode.c b/src/decode.c index 28a64e169..ccca3b204 100644 --- a/src/decode.c +++ b/src/decode.c @@ -243,7 +243,10 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, } \ pc->pause = 0; \ kill(getppid(),SIGUSR1); \ - if(pause) closeAudioDevice(); \ + if(pause) { \ + dropBufferedAudio(); \ + closeAudioDevice(); \ + } \ } \ if(pc->seek) { \ dropBufferedAudio(); \ diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 10a12f853..242dc6f22 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -284,11 +284,12 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec, { FlacData * data = (FlacData *)vdata; FLAC__uint32 samples = frame->header.blocksize; - int c_samp; - int c_chan; + FLAC__uint16 u16; + unsigned char * uc; + int c_samp, c_chan, d_samp; + int i; float timeChange; FLAC__uint64 newPosition = 0; - const int bytesPerSample = data->dc->audioFormat.bits/8; timeChange = ((float)samples)/frame->header.sample_rate; data->time+= timeChange; @@ -300,27 +301,22 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec, } data->position = newPosition; - for(c_samp = 0; c_samp < frame->header.blocksize; c_samp++) { - for(c_chan = 0; c_chan < frame->header.channels; c_chan++) { -#ifdef WORDS_BIGENDIAN - memcpy(data->chunk+data->chunk_length, - &buf[c_chan][c_samp]+4-bytesPerSample, - bytesPerSample); -#else - memcpy(data->chunk+data->chunk_length, - &buf[c_chan][c_samp], bytesPerSample); -#endif - data->chunk_length+=bytesPerSample; - - if(FLAC_CHUNK_SIZE-data->chunk_length < bytesPerSample) - { - if(flacSendChunk(data)<0) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - data->chunk_length = 0; - if(data->dc->seek) { - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + for(c_samp = d_samp = 0; c_samp < frame->header.blocksize; c_samp++) { + for(c_chan = 0; c_chan < frame->header.channels; + c_chan++, d_samp++) { + u16 = buf[c_chan][c_samp]; + uc = (unsigned char *)&u16; + for(i=0;i<(data->dc->audioFormat.bits/8);i++) { + if(data->chunk_length>=FLAC_CHUNK_SIZE) { + if(flacSendChunk(data)<0) { + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + data->chunk_length = 0; + if(data->dc->seek) { + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + } } + data->chunk[data->chunk_length++] = *(uc++); } } } diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index a5bce40c7..25f9a3cdb 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -161,8 +161,10 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite( { FlacData * data = (FlacData *)vdata; FLAC__uint32 samples = frame->header.blocksize; - int c_samp; - int c_chan; + FLAC__uint16 u16; + unsigned char * uc; + int c_samp, c_chan, d_samp; + int i; float timeChange; const int bytesPerSample = data->dc->audioFormat.bits/8; @@ -179,29 +181,24 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite( data->bitRate = ((8.0 * data->bytes_last_read * frame->header.sample_rate) /((float)samples * 1000)) + 0.5; - */ - for(c_samp = 0; c_samp < frame->header.blocksize; c_samp++) { - for(c_chan = 0; c_chan < frame->header.channels; c_chan++) { -#ifdef WORDS_BIGENDIAN - memcpy(data->chunk+data->chunk_length, - &buf[c_chan][c_samp]+4-bytesPerSample, - bytesPerSample); -#else - memcpy(data->chunk+data->chunk_length, - &buf[c_chan][c_samp], - bytesPerSample); -#endif - data->chunk_length+=bytesPerSample; - if ((FLAC_CHUNK_SIZE - data->chunk_length) - < bytesPerSample) - { - if(flacSendChunk(data)<0) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - data->chunk_length = 0; - if(data->dc->seek) { - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + */ + + for(c_samp = d_samp = 0; c_samp < frame->header.blocksize; c_samp++) { + for(c_chan = 0; c_chan < frame->header.channels; + c_chan++, d_samp++) { + u16 = buf[c_chan][c_samp]; + uc = (unsigned char *)&u16; + for(i=0;i<(data->dc->audioFormat.bits/8);i++) { + if(data->chunk_length>=FLAC_CHUNK_SIZE) { + if(flacSendChunk(data)<0) { + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + data->chunk_length = 0; + if(data->dc->seek) { + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + } } + data->chunk[data->chunk_length++] = *(uc++); } } } diff --git a/src/main.c b/src/main.c index 55847d8e8..7b05e7c14 100644 --- a/src/main.c +++ b/src/main.c @@ -521,11 +521,11 @@ int main(int argc, char * argv[]) { initAudioConfig(); initAudioDriver(); + initSigHandlers(); startMainProcess(); /* This is the main process which has * been forked from the master process. */ - initSigHandlers(); initPermissions(); |