diff options
author | Steve Bavin <pondlife@pondlife.me> | 2006-09-26 07:19:43 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2006-09-26 07:19:43 +0000 |
commit | 081281f6a1232fcd4a70946f444967b94b27a0e9 (patch) | |
tree | 1a6123312a51aace615db2a2eeb6ef78e21bbf3e /apps/playback.c | |
parent | 3ae1c103edd2d1a8758af072461c3b4056e1bff8 (diff) | |
download | rockbox-081281f6a1232fcd4a70946f444967b94b27a0e9.tar.gz rockbox-081281f6a1232fcd4a70946f444967b94b27a0e9.zip |
Fix a crash and CPU being left boosted when using voice - FS#6024
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11053 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/apps/playback.c b/apps/playback.c index e4806507ef..2b6081be42 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -446,16 +446,21 @@ void audio_play(long offset) | |||
446 | } | 446 | } |
447 | else | 447 | else |
448 | { | 448 | { |
449 | audio_stop(); | 449 | LOGFQUEUE("audio > audio Q_AUDIO_STOP"); |
450 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | ||
450 | LOGFQUEUE("audio > audio Q_AUDIO_PLAY"); | 451 | LOGFQUEUE("audio > audio Q_AUDIO_PLAY"); |
451 | queue_post(&audio_queue, Q_AUDIO_PLAY, (void *)offset); | 452 | queue_post(&audio_queue, Q_AUDIO_PLAY, (void *)offset); |
452 | } | 453 | } |
454 | while (!playing) | ||
455 | yield(); | ||
453 | } | 456 | } |
454 | 457 | ||
455 | void audio_stop(void) | 458 | void audio_stop(void) |
456 | { | 459 | { |
457 | LOGFQUEUE("audio > audio Q_AUDIO_STOP"); | 460 | LOGFQUEUE("audio > audio Q_AUDIO_STOP"); |
458 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); | 461 | queue_post(&audio_queue, Q_AUDIO_STOP, 0); |
462 | while(playing) | ||
463 | yield(); | ||
459 | } | 464 | } |
460 | 465 | ||
461 | void audio_pause(void) | 466 | void audio_pause(void) |
@@ -472,11 +477,11 @@ void audio_resume(void) | |||
472 | 477 | ||
473 | void audio_next(void) | 478 | void audio_next(void) |
474 | { | 479 | { |
475 | if (global_settings.beep) | ||
476 | pcmbuf_beep(5000, 100, 2500*global_settings.beep); | ||
477 | |||
478 | if (playlist_check(ci.new_track + wps_offset + 1)) | 480 | if (playlist_check(ci.new_track + wps_offset + 1)) |
479 | { | 481 | { |
482 | if (global_settings.beep) | ||
483 | pcmbuf_beep(5000, 100, 2500*global_settings.beep); | ||
484 | |||
480 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1"); | 485 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1"); |
481 | queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)1); | 486 | queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)1); |
482 | /* Keep wps fast while our message travels inside deep playback queues. */ | 487 | /* Keep wps fast while our message travels inside deep playback queues. */ |
@@ -487,18 +492,17 @@ void audio_next(void) | |||
487 | { | 492 | { |
488 | /* No more tracks. */ | 493 | /* No more tracks. */ |
489 | if (global_settings.beep) | 494 | if (global_settings.beep) |
490 | pcmbuf_beep(3000, 300, 2500*global_settings.beep); | 495 | pcmbuf_beep(1000, 100, 1000*global_settings.beep); |
491 | |||
492 | } | 496 | } |
493 | } | 497 | } |
494 | 498 | ||
495 | void audio_prev(void) | 499 | void audio_prev(void) |
496 | { | 500 | { |
497 | if (global_settings.beep) | ||
498 | pcmbuf_beep(5000, 100, 2500*global_settings.beep); | ||
499 | |||
500 | if (playlist_check(ci.new_track + wps_offset - 1)) | 501 | if (playlist_check(ci.new_track + wps_offset - 1)) |
501 | { | 502 | { |
503 | if (global_settings.beep) | ||
504 | pcmbuf_beep(5000, 100, 2500*global_settings.beep); | ||
505 | |||
502 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1"); | 506 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1"); |
503 | queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)-1); | 507 | queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)-1); |
504 | /* Keep wps fast while our message travels inside deep playback queues. */ | 508 | /* Keep wps fast while our message travels inside deep playback queues. */ |
@@ -509,8 +513,7 @@ void audio_prev(void) | |||
509 | { | 513 | { |
510 | /* No more tracks. */ | 514 | /* No more tracks. */ |
511 | if (global_settings.beep) | 515 | if (global_settings.beep) |
512 | pcmbuf_beep(3000, 300, 2500*global_settings.beep); | 516 | pcmbuf_beep(1000, 100, 1000*global_settings.beep); |
513 | |||
514 | } | 517 | } |
515 | } | 518 | } |
516 | 519 | ||
@@ -721,12 +724,17 @@ void voice_stop(void) | |||
721 | { | 724 | { |
722 | #ifdef PLAYBACK_VOICE | 725 | #ifdef PLAYBACK_VOICE |
723 | /* Messages should not be posted to voice codec queue unless it is the | 726 | /* Messages should not be posted to voice codec queue unless it is the |
724 | current codec or deadlocks happen. This will be addressed globally soon. | 727 | current codec or deadlocks happen. |
725 | -- jhMikeS */ | 728 | -- jhMikeS */ |
726 | if (current_codec != CODEC_IDX_VOICE) | 729 | if (current_codec != CODEC_IDX_VOICE) |
727 | return; | 730 | return; |
728 | 731 | ||
729 | mp3_play_stop(); | 732 | LOGFQUEUE("mp3 > voice Q_VOICE_STOP"); |
733 | queue_post(&voice_queue, Q_VOICE_STOP, 0); | ||
734 | while (voice_is_playing && !queue_empty(&voice_queue)) | ||
735 | yield(); | ||
736 | if (!playing) | ||
737 | pcmbuf_play_stop(); | ||
730 | #endif | 738 | #endif |
731 | } /* voice_stop */ | 739 | } /* voice_stop */ |
732 | 740 | ||
@@ -934,24 +942,25 @@ static void* voice_request_buffer_callback(size_t *realsize, size_t reqsize) | |||
934 | 942 | ||
935 | while (1) | 943 | while (1) |
936 | { | 944 | { |
937 | if (voice_is_playing) | 945 | if (voice_is_playing || playing) |
938 | { | ||
939 | queue_wait_w_tmo(&voice_queue, &ev, 0); | 946 | queue_wait_w_tmo(&voice_queue, &ev, 0); |
940 | } | 947 | else |
941 | else if (playing) | 948 | queue_wait(&voice_queue, &ev); |
949 | if (!voice_is_playing) | ||
942 | { | 950 | { |
943 | queue_wait_w_tmo(&voice_queue, &ev, 0); | ||
944 | if (ev.id == SYS_TIMEOUT) | 951 | if (ev.id == SYS_TIMEOUT) |
945 | ev.id = Q_AUDIO_PLAY; | 952 | ev.id = Q_AUDIO_PLAY; |
946 | } | 953 | } |
947 | else | ||
948 | queue_wait(&voice_queue, &ev); | ||
949 | 954 | ||
950 | switch (ev.id) { | 955 | switch (ev.id) { |
951 | case Q_AUDIO_PLAY: | 956 | case Q_AUDIO_PLAY: |
952 | LOGFQUEUE("voice < Q_AUDIO_PLAY"); | 957 | LOGFQUEUE("voice < Q_AUDIO_PLAY"); |
953 | if (playing) | 958 | if (playing) |
954 | swap_codec(); | 959 | { |
960 | if (audio_codec_loaded) | ||
961 | swap_codec(); | ||
962 | yield(); | ||
963 | } | ||
955 | break; | 964 | break; |
956 | 965 | ||
957 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) | 966 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) |
@@ -1810,10 +1819,6 @@ static void codec_thread(void) | |||
1810 | LOGFQUEUE("codec < SYS_USB_CONNECTED"); | 1819 | LOGFQUEUE("codec < SYS_USB_CONNECTED"); |
1811 | queue_clear(&codec_queue); | 1820 | queue_clear(&codec_queue); |
1812 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | 1821 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
1813 | #ifdef PLAYBACK_VOICE | ||
1814 | if(voice_codec_loaded) | ||
1815 | swap_codec(); | ||
1816 | #endif | ||
1817 | usb_wait_for_disconnect(&codec_queue); | 1822 | usb_wait_for_disconnect(&codec_queue); |
1818 | break; | 1823 | break; |
1819 | #endif | 1824 | #endif |
@@ -2170,6 +2175,7 @@ static void audio_read_file(bool quick) | |||
2170 | return ; | 2175 | return ; |
2171 | } | 2176 | } |
2172 | 2177 | ||
2178 | cpu_boost(true); | ||
2173 | while (tracks[track_widx].filerem > 0) | 2179 | while (tracks[track_widx].filerem > 0) |
2174 | { | 2180 | { |
2175 | int overlap; | 2181 | int overlap; |
@@ -2237,6 +2243,7 @@ static void audio_read_file(bool quick) | |||
2237 | logf("Partially buf:%dB", | 2243 | logf("Partially buf:%dB", |
2238 | tracks[track_widx].filesize - tracks[track_widx].filerem); | 2244 | tracks[track_widx].filesize - tracks[track_widx].filerem); |
2239 | } | 2245 | } |
2246 | cpu_boost(false); | ||
2240 | } | 2247 | } |
2241 | 2248 | ||
2242 | static bool audio_loadcodec(bool start_play) | 2249 | static bool audio_loadcodec(bool start_play) |