diff options
Diffstat (limited to '')
-rw-r--r-- | src/crossfade.c | 1 | ||||
-rw-r--r-- | src/decoder_api.c | 23 | ||||
-rw-r--r-- | src/decoder_control.h | 8 | ||||
-rw-r--r-- | src/pipe.c | 4 | ||||
-rw-r--r-- | src/pipe.h | 8 | ||||
-rw-r--r-- | src/player_thread.c | 12 |
6 files changed, 34 insertions, 22 deletions
diff --git a/src/crossfade.c b/src/crossfade.c index 95f7e8566..27a1c3642 100644 --- a/src/crossfade.c +++ b/src/crossfade.c @@ -21,6 +21,7 @@ #include "audio.h" #include "pcm_utils.h" #include "pipe.h" +#include "audio_format.h" #include <assert.h> #include <string.h> diff --git a/src/decoder_api.c b/src/decoder_api.c index 715a46c8d..73b5d23f6 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -39,8 +39,8 @@ void decoder_initialized(struct decoder * decoder, pcm_convert_init(&decoder->conv_state); - dc.audioFormat = *audio_format; - getOutputAudioFormat(audio_format, &ob.audioFormat); + dc.in_audio_format = *audio_format; + getOutputAudioFormat(audio_format, &dc.out_audio_format); dc.totalTime = total_time; @@ -157,12 +157,12 @@ decoder_data(struct decoder *decoder, static char *convBuffer; static size_t convBufferLen; - if (audio_format_equals(&ob.audioFormat, &dc.audioFormat)) { + if (audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) { data = dataIn; datalen = dataInLen; } else { - datalen = pcm_convert_size(&(dc.audioFormat), dataInLen, - &(ob.audioFormat)); + datalen = pcm_convert_size(&dc.in_audio_format, dataInLen, + &dc.out_audio_format); if (datalen > convBufferLen) { if (convBuffer != NULL) free(convBuffer); @@ -170,18 +170,21 @@ decoder_data(struct decoder *decoder, convBufferLen = datalen; } data = convBuffer; - datalen = pcm_convert(&(dc.audioFormat), dataIn, - dataInLen, &(ob.audioFormat), + datalen = pcm_convert(&dc.in_audio_format, dataIn, + dataInLen, &dc.out_audio_format, data, &decoder->conv_state); } if (replayGainInfo != NULL && (replayGainState != REPLAYGAIN_OFF)) - doReplayGain(replayGainInfo, data, datalen, &ob.audioFormat); + doReplayGain(replayGainInfo, data, datalen, + &dc.out_audio_format); else if (normalizationEnabled) - normalizeData(data, datalen, &ob.audioFormat); + normalizeData(data, datalen, &dc.out_audio_format); while (datalen > 0) { - nbytes = music_pipe_append(data, datalen, data_time, bitRate); + nbytes = music_pipe_append(data, datalen, + &dc.out_audio_format, + data_time, bitRate); datalen -= nbytes; data += nbytes; diff --git a/src/decoder_control.h b/src/decoder_control.h index bfee8a259..5f7bbf546 100644 --- a/src/decoder_control.h +++ b/src/decoder_control.h @@ -47,7 +47,13 @@ struct decoder_control { bool seekError; bool seekable; volatile double seekWhere; - struct audio_format audioFormat; + + /** the format of the song file */ + struct audio_format in_audio_format; + + /** the format being sent to the music pipe */ + struct audio_format out_audio_format; + struct song *current_song; struct song *volatile next_song; volatile float totalTime; diff --git a/src/pipe.c b/src/pipe.c index db463f7a5..9ad9a87d2 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -19,6 +19,7 @@ #include "pipe.h" #include "notify.h" #include "utils.h" +#include "audio_format.h" #include <assert.h> #include <string.h> @@ -185,10 +186,11 @@ tail_chunk(float data_time, uint16_t bitRate, size_t frame_size) } size_t music_pipe_append(const void *data0, size_t datalen, + const struct audio_format *audio_format, float data_time, uint16_t bitRate) { const unsigned char *data = data0; - const size_t frame_size = audio_format_frame_size(&ob.audioFormat); + const size_t frame_size = audio_format_frame_size(audio_format); size_t ret = 0, dataToSend; struct music_chunk *chunk = NULL; diff --git a/src/pipe.h b/src/pipe.h index a27629697..10a3501ec 100644 --- a/src/pipe.h +++ b/src/pipe.h @@ -19,14 +19,15 @@ #ifndef MPD_PIPE_H #define MPD_PIPE_H -#include "audio_format.h" - #include <stddef.h> +#include <stdint.h> #include <stdbool.h> /* pick 1020 since its devisible for 8,16,24, and 32-bit audio */ #define CHUNK_SIZE 1020 +struct audio_format; + struct music_chunk { uint16_t chunkSize; uint16_t bitRate; @@ -53,8 +54,6 @@ struct music_pipe { the buffer becomes non-empty */ bool lazy; - struct audio_format audioFormat; - struct notify *notify; }; @@ -109,6 +108,7 @@ music_pipe_get_chunk(const unsigned i); * @return the number of bytes actually written */ size_t music_pipe_append(const void *data, size_t datalen, + const struct audio_format *audio_format, float data_time, uint16_t bitRate); void music_pipe_skip(unsigned num); diff --git a/src/player_thread.c b/src/player_thread.c index 733d7ea41..e1f11652e 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -288,7 +288,7 @@ static void do_play(void) else if (!decoder_is_starting()) { /* the decoder is ready and ok */ player.decoder_starting = false; - if (!openAudioDevice(&ob.audioFormat)) { + if (!openAudioDevice(&dc.out_audio_format)) { char tmp[MPD_PATH_MAX]; assert(dc.next_song == NULL || dc.next_song->url != NULL); pc.errored_song = dc.next_song; @@ -303,9 +303,9 @@ static void do_play(void) closeAudioDevice(); pc.totalTime = dc.totalTime; - pc.audio_format = dc.audioFormat; - play_audio_format = ob.audioFormat; - sizeToTime = audioFormatSizeToTime(&ob.audioFormat); + pc.audio_format = dc.in_audio_format; + play_audio_format = dc.out_audio_format; + sizeToTime = audioFormatSizeToTime(&dc.out_audio_format); } else { /* the decoder is not yet ready; wait @@ -341,7 +341,7 @@ static void do_play(void) for it */ crossFadeChunks = cross_fade_calc(pc.crossFade, dc.totalTime, - &(ob.audioFormat), + &dc.out_audio_format, ob.size - pc.buffered_before_play); if (crossFadeChunks > 0) { @@ -378,7 +378,7 @@ static void do_play(void) music_pipe_set_lazy(true); cross_fade_apply(beginChunk, music_pipe_get_chunk(nextChunk), - &(ob.audioFormat), + &dc.out_audio_format, fadePosition, crossFadeChunks); } else { |