summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/pcmbuf.c28
-rw-r--r--apps/playback.c42
2 files changed, 35 insertions, 35 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index c7baad08e4..7201d3981a 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -206,7 +206,7 @@ static void commit_chunk(bool flush_next_time)
206{ 206{
207 if (!pcmbuffer_fillpos) 207 if (!pcmbuffer_fillpos)
208 return; 208 return;
209 209
210 /* Never use the last buffer descriptor */ 210 /* Never use the last buffer descriptor */
211 while (write_chunk == write_end_chunk) { 211 while (write_chunk == write_end_chunk) {
212 /* If this happens, something is being stupid */ 212 /* If this happens, something is being stupid */
@@ -217,9 +217,9 @@ static void commit_chunk(bool flush_next_time)
217 /* Let approximately one chunk of data playback */ 217 /* Let approximately one chunk of data playback */
218 sleep(HZ * PCMBUF_TARGET_CHUNK / BYTERATE); 218 sleep(HZ * PCMBUF_TARGET_CHUNK / BYTERATE);
219 } 219 }
220 220
221 /* commit the chunk */ 221 /* commit the chunk */
222 222
223 register size_t size = pcmbuffer_fillpos; 223 register size_t size = pcmbuffer_fillpos;
224 /* Grab the next description to write, and change the write pointer */ 224 /* Grab the next description to write, and change the write pointer */
225 register struct chunkdesc *pcmbuf_current = write_chunk; 225 register struct chunkdesc *pcmbuf_current = write_chunk;
@@ -229,7 +229,7 @@ static void commit_chunk(bool flush_next_time)
229 pcmbuf_current->size = size; 229 pcmbuf_current->size = size;
230 pcmbuf_current->end_of_track = false; 230 pcmbuf_current->end_of_track = false;
231 pcmbuf_current->link = NULL; 231 pcmbuf_current->link = NULL;
232 232
233 if (read_chunk != NULL) 233 if (read_chunk != NULL)
234 { 234 {
235 if (flush_pcmbuf) 235 if (flush_pcmbuf)
@@ -263,7 +263,7 @@ static void commit_chunk(bool flush_next_time)
263 * and the next chunk to be committed will be the next to be played. 263 * and the next chunk to be committed will be the next to be played.
264 * This is used to empty the PCM buffer for a track change. */ 264 * This is used to empty the PCM buffer for a track change. */
265 flush_pcmbuf = flush_next_time; 265 flush_pcmbuf = flush_next_time;
266 266
267 /* This is now the last buffer to read */ 267 /* This is now the last buffer to read */
268 read_end_chunk = pcmbuf_current; 268 read_end_chunk = pcmbuf_current;
269 269
@@ -423,7 +423,7 @@ void pcmbuf_write_complete(int count)
423 if (crossfade_active) 423 if (crossfade_active)
424 write_to_crossfade(length); 424 write_to_crossfade(length);
425 else 425 else
426#endif 426#endif
427 { 427 {
428 pcmbuffer_fillpos += length; 428 pcmbuffer_fillpos += length;
429 COMMIT_IF_NEEDED; 429 COMMIT_IF_NEEDED;
@@ -553,7 +553,7 @@ bool pcmbuf_start_track_change(bool auto_skip)
553 } 553 }
554 } 554 }
555#endif 555#endif
556 556
557 if (!auto_skip || crossfade) 557 if (!auto_skip || crossfade)
558 /* manual skip or crossfade */ 558 /* manual skip or crossfade */
559 { 559 {
@@ -640,7 +640,7 @@ static void pcmbuf_pcm_callback(unsigned char** start, size_t* size)
640 /* if during a track transition, update the elapsed time in ms */ 640 /* if during a track transition, update the elapsed time in ms */
641 if (track_transition) 641 if (track_transition)
642 audio_pcmbuf_position_callback(last_chunksize * 1000 / BYTERATE); 642 audio_pcmbuf_position_callback(last_chunksize * 1000 / BYTERATE);
643 643
644 /* if last chunk in the track, stop updates and notify audio thread */ 644 /* if last chunk in the track, stop updates and notify audio thread */
645 if (pcmbuf_current->end_of_track) 645 if (pcmbuf_current->end_of_track)
646 { 646 {
@@ -662,7 +662,7 @@ static void pcmbuf_pcm_callback(unsigned char** start, size_t* size)
662 crossfade_chunk = read_chunk; 662 crossfade_chunk = read_chunk;
663#endif 663#endif
664 } 664 }
665 665
666 { 666 {
667 /* Commit last samples at end of playlist */ 667 /* Commit last samples at end of playlist */
668 if (pcmbuffer_fillpos && !read_chunk) 668 if (pcmbuffer_fillpos && !read_chunk)
@@ -904,7 +904,7 @@ static void crossfade_start(void)
904 crossfade_mix_fade(factor, block_rem, NULL, 904 crossfade_mix_fade(factor, block_rem, NULL,
905 &fade_out_sample, &fade_out_chunk); 905 &fade_out_sample, &fade_out_chunk);
906 } 906 }
907 907
908 /* zero out the rest of the buffer */ 908 /* zero out the rest of the buffer */
909 crossfade_mix_fade(0, crossfade_rem, NULL, 909 crossfade_mix_fade(0, crossfade_rem, NULL,
910 &fade_out_sample, &fade_out_chunk); 910 &fade_out_sample, &fade_out_chunk);
@@ -997,7 +997,7 @@ static void pcmbuf_finish_crossfade_enable(void)
997{ 997{
998 /* Copy the pending setting over now */ 998 /* Copy the pending setting over now */
999 crossfade_enabled = crossfade_enable_request; 999 crossfade_enabled = crossfade_enable_request;
1000 1000
1001 pcmbuf_watermark = (crossfade_enabled && pcmbuf_size) ? 1001 pcmbuf_watermark = (crossfade_enabled && pcmbuf_size) ?
1002 /* If crossfading, try to keep the buffer full other than 1 second */ 1002 /* If crossfading, try to keep the buffer full other than 1 second */
1003 (pcmbuf_size - BYTERATE) : 1003 (pcmbuf_size - BYTERATE) :
@@ -1021,11 +1021,11 @@ bool pcmbuf_is_same_size(void)
1021 /* if pcmbuffer is NULL, then not set up yet even once so always */ 1021 /* if pcmbuffer is NULL, then not set up yet even once so always */
1022 bool same_size = pcmbuffer ? 1022 bool same_size = pcmbuffer ?
1023 (get_next_required_pcmbuf_size() == pcmbuf_size) : true; 1023 (get_next_required_pcmbuf_size() == pcmbuf_size) : true;
1024 1024
1025 /* no buffer change needed, so finish crossfade setup now */ 1025 /* no buffer change needed, so finish crossfade setup now */
1026 if (same_size) 1026 if (same_size)
1027 pcmbuf_finish_crossfade_enable(); 1027 pcmbuf_finish_crossfade_enable();
1028 1028
1029 return same_size; 1029 return same_size;
1030} 1030}
1031#endif /* HAVE_CROSSFADE */ 1031#endif /* HAVE_CROSSFADE */
@@ -1232,7 +1232,7 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
1232 if (!bufstart || !pcm_is_playing()) 1232 if (!bufstart || !pcm_is_playing())
1233 return; 1233 return;
1234 1234
1235 /* Give 5ms clearance. */ 1235 /* Give 5ms clearance. */
1236 bufstart += BYTERATE / 200; 1236 bufstart += BYTERATE / 200;
1237 1237
1238#ifdef HAVE_PCM_DMA_ADDRESS 1238#ifdef HAVE_PCM_DMA_ADDRESS
diff --git a/apps/playback.c b/apps/playback.c
index 3ff8d17214..a808a62a0e 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -132,7 +132,7 @@ static struct audio_scratch_memory
132} * audio_scratch_memory = NULL; 132} * audio_scratch_memory = NULL;
133 133
134/* These are used to store the current, next and optionally the peek-ahead 134/* These are used to store the current, next and optionally the peek-ahead
135 * mp3entry's - this guarentees that the pointer returned by audio_current/ 135 * mp3entry's - this guarantees that the pointer returned by audio_current/
136 * next_track will be valid for the full duration of the currently playing 136 * next_track will be valid for the full duration of the currently playing
137 * track */ 137 * track */
138enum audio_id3_types 138enum audio_id3_types
@@ -153,7 +153,7 @@ enum audio_id3_types
153static struct mp3entry static_id3_entries[ID3_TYPE_NUM_STATIC]; /* (A,O) */ 153static struct mp3entry static_id3_entries[ID3_TYPE_NUM_STATIC]; /* (A,O) */
154 154
155/* Peeking functions can yield and mess us up */ 155/* Peeking functions can yield and mess us up */
156static struct mutex id3_mutex SHAREDBSS_ATTR; /* (A,0)*/ 156static struct mutex id3_mutex SHAREDBSS_ATTR; /* (A,O)*/
157 157
158 158
159/** For Scrobbler support **/ 159/** For Scrobbler support **/
@@ -199,7 +199,7 @@ struct track_info
199{ 199{
200 /* In per-track allocated order: */ 200 /* In per-track allocated order: */
201 int id3_hid; /* Metadata handle ID */ 201 int id3_hid; /* Metadata handle ID */
202 int cuesheet_hid; /* Parsed cueesheet handle ID */ 202 int cuesheet_hid; /* Parsed cuesheet handle ID */
203#ifdef HAVE_ALBUMART 203#ifdef HAVE_ALBUMART
204 int aa_hid[MAX_MULTIPLE_AA];/* Album art handle IDs */ 204 int aa_hid[MAX_MULTIPLE_AA];/* Album art handle IDs */
205#endif 205#endif
@@ -315,7 +315,7 @@ static struct
315} track_change = { 0, 0 }; 315} track_change = { 0, 0 };
316 316
317/** Codec status **/ 317/** Codec status **/
318/* Did the codec notify us it finished while we were paused or while still 318/* Did the codec notify us it finished while we were paused or while still
319 in an automatic transition? 319 in an automatic transition?
320 320
321 If paused, it is necessary to defer a codec-initiated skip until resuming 321 If paused, it is necessary to defer a codec-initiated skip until resuming
@@ -780,7 +780,7 @@ static void audio_reset_buffer(void)
780 780
781#if defined(ROCKBOX_HAS_LOGF) && defined(LOGF_ENABLE) 781#if defined(ROCKBOX_HAS_LOGF) && defined(LOGF_ENABLE)
782 /* Make sure everything adds up - yes, some info is a bit redundant but 782 /* Make sure everything adds up - yes, some info is a bit redundant but
783 aids viewing and the sumation of certain variables should add up to 783 aids viewing and the summation of certain variables should add up to
784 the location of others. */ 784 the location of others. */
785 { 785 {
786 size_t pcmbufsize; 786 size_t pcmbufsize;
@@ -839,7 +839,7 @@ static void audio_update_filebuf_watermark(int seconds)
839#endif 839#endif
840 840
841 /* Watermark is a function of the bitrate of the last track in the buffer */ 841 /* Watermark is a function of the bitrate of the last track in the buffer */
842 struct mp3entry *id3 = NULL; 842 struct mp3entry *id3 = NULL;
843 struct track_info *info = track_list_last(0); 843 struct track_info *info = track_list_last(0);
844 844
845 if (info) 845 if (info)
@@ -854,7 +854,7 @@ static void audio_update_filebuf_watermark(int seconds)
854 else 854 else
855 { 855 {
856 /* Bitrate has no meaning to buffering margin for atomic audio - 856 /* Bitrate has no meaning to buffering margin for atomic audio -
857 rebuffer when it's the only track left unless it's the only 857 rebuffer when it's the only track left unless it's the only
858 track that fits, in which case we should avoid constant buffer 858 track that fits, in which case we should avoid constant buffer
859 low events */ 859 low events */
860 if (track_list_count() > 1) 860 if (track_list_count() > 1)
@@ -1475,7 +1475,7 @@ static bool audio_load_albumart(struct track_info *info,
1475#ifdef HAVE_CODEC_BUFFERING 1475#ifdef HAVE_CODEC_BUFFERING
1476/* Load a codec for the file onto the buffer - assumes we're working from the 1476/* Load a codec for the file onto the buffer - assumes we're working from the
1477 currently loading track - not called for the current track */ 1477 currently loading track - not called for the current track */
1478static bool audio_buffer_codec(struct track_info *track_info, 1478static bool audio_buffer_codec(struct track_info *track_info,
1479 struct mp3entry *track_id3) 1479 struct mp3entry *track_id3)
1480{ 1480{
1481 /* This will not be the current track -> it cannot be the first and the 1481 /* This will not be the current track -> it cannot be the first and the
@@ -1899,7 +1899,7 @@ static void audio_on_buffering(int event)
1899 1899
1900 if (track_list_empty()) 1900 if (track_list_empty())
1901 return; 1901 return;
1902 1902
1903 switch (event) 1903 switch (event)
1904 { 1904 {
1905 case BUFFER_EVENT_BUFFER_LOW: 1905 case BUFFER_EVENT_BUFFER_LOW:
@@ -2243,7 +2243,7 @@ static void audio_on_codec_complete(int status)
2243 2243
2244 if (trackstat == LOAD_TRACK_ERR_NO_MORE) 2244 if (trackstat == LOAD_TRACK_ERR_NO_MORE)
2245 { 2245 {
2246 /* Failed to find anything afterall - do playlist switchover 2246 /* Failed to find anything after all - do playlist switchover
2247 instead */ 2247 instead */
2248 skip_pending = TRACK_SKIP_AUTO_NEW_PLAYLIST; 2248 skip_pending = TRACK_SKIP_AUTO_NEW_PLAYLIST;
2249 end_of_playlist = playlist_next(1) < 0; 2249 end_of_playlist = playlist_next(1) < 0;
@@ -2683,7 +2683,7 @@ static void audio_on_ff_rewind(long time)
2683 !audio_init_codec(cur_info, ci_id3)) 2683 !audio_init_codec(cur_info, ci_id3))
2684 { 2684 {
2685 /* We should have still been able to get it - skip it and move 2685 /* We should have still been able to get it - skip it and move
2686 onto the next one - like it or not this track is borken */ 2686 onto the next one - like it or not this track is broken */
2687 break; 2687 break;
2688 } 2688 }
2689 2689
@@ -2753,7 +2753,7 @@ static void audio_on_audio_flush(void)
2753 id3_write_locked(UNBUFFERED_ID3, NULL); 2753 id3_write_locked(UNBUFFERED_ID3, NULL);
2754 audio_update_and_announce_next_track(NULL); 2754 audio_update_and_announce_next_track(NULL);
2755 2755
2756 /* Ignore return since it's about the next track, not this one */ 2756 /* Ignore return since it's about the next track, not this one */
2757 audio_fill_file_buffer(); 2757 audio_fill_file_buffer();
2758 2758
2759 if (skip_pending == TRACK_SKIP_NONE) 2759 if (skip_pending == TRACK_SKIP_NONE)
@@ -2961,7 +2961,7 @@ static void audio_thread(void)
2961 case Q_AUDIO_HANDLE_FINISHED: 2961 case Q_AUDIO_HANDLE_FINISHED:
2962 /* some other type is buffered */ 2962 /* some other type is buffered */
2963 LOGFQUEUE("audio < Q_AUDIO_HANDLE_FINISHED"); 2963 LOGFQUEUE("audio < Q_AUDIO_HANDLE_FINISHED");
2964 audio_on_handle_finished(ev.data); 2964 audio_on_handle_finished(ev.data);
2965 break; 2965 break;
2966 2966
2967 /** Miscellaneous messages **/ 2967 /** Miscellaneous messages **/
@@ -3429,10 +3429,10 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size)
3429 /* Ok to use everything from audiobuf to audiobufend - voice is loaded, 3429 /* Ok to use everything from audiobuf to audiobufend - voice is loaded,
3430 the talk buffer is not needed because voice isn't being used, or 3430 the talk buffer is not needed because voice isn't being used, or
3431 could be AUDIOBUF_STATE_TRASHED already. If state is 3431 could be AUDIOBUF_STATE_TRASHED already. If state is
3432 AUDIOBUF_STATE_VOICED_ONLY, no problem as long as memory isn't written 3432 AUDIOBUF_STATE_VOICED_ONLY, no problem as long as memory isn't
3433 without the caller knowing what's going on. Changing certain settings 3433 written without the caller knowing what's going on. Changing certain
3434 may move it to a worse condition but the memory in use by something 3434 settings may move it to a worse condition but the memory in use by
3435 else will remain undisturbed. 3435 something else will remain undisturbed.
3436 */ 3436 */
3437 if (buffer_state != AUDIOBUF_STATE_TRASHED) 3437 if (buffer_state != AUDIOBUF_STATE_TRASHED)
3438 { 3438 {
@@ -3597,7 +3597,7 @@ void audio_remove_encoder(void)
3597} 3597}
3598#endif /* HAVE_RECORDING */ 3598#endif /* HAVE_RECORDING */
3599 3599
3600/* Is an automatic skip in progress? If called outside transistion callbacks, 3600/* Is an automatic skip in progress? If called outside transition callbacks,
3601 indicates the last skip type at the time it was processed and isn't very 3601 indicates the last skip type at the time it was processed and isn't very
3602 meaningful. */ 3602 meaningful. */
3603bool audio_automatic_skip(void) 3603bool audio_automatic_skip(void)
@@ -3612,7 +3612,7 @@ int audio_get_file_pos(void)
3612 return 0; 3612 return 0;
3613} 3613}
3614 3614
3615/* Return the elasped time of the track previous to the current */ 3615/* Return the elapsed time of the track previous to the current */
3616unsigned long audio_prev_elapsed(void) 3616unsigned long audio_prev_elapsed(void)
3617{ 3617{
3618 return prev_track_elapsed; 3618 return prev_track_elapsed;
@@ -3715,7 +3715,7 @@ void audio_init(void)
3715 pcm_init(); 3715 pcm_init();
3716 3716
3717 codec_init_codec_api(); 3717 codec_init_codec_api();
3718 3718
3719 make_codec_thread(); 3719 make_codec_thread();
3720 3720
3721 /* This thread does buffer, so match its priority */ 3721 /* This thread does buffer, so match its priority */
@@ -3732,7 +3732,7 @@ void audio_init(void)
3732 voice_thread_init(); 3732 voice_thread_init();
3733#endif 3733#endif
3734 3734
3735 /* audio_reset_buffer must to know the size of voice buffer so init 3735 /* audio_reset_buffer must know the size of voice buffer so init
3736 talk first */ 3736 talk first */
3737 talk_init(); 3737 talk_init();
3738 3738