1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Steve Bavin 2006-09-26 07:19:43 +00:00
parent 3ae1c103ed
commit 081281f6a1
2 changed files with 33 additions and 25 deletions

View file

@ -203,6 +203,7 @@ process_new_buffer:
*realsize = 0; *realsize = 0;
*realstart = NULL; *realstart = NULL;
CALL_IF_EXISTS(pcmbuf_event_handler); CALL_IF_EXISTS(pcmbuf_event_handler);
pcmbuf_boost(false);
} }
} }
} }

View file

@ -446,16 +446,21 @@ void audio_play(long offset)
} }
else else
{ {
audio_stop(); LOGFQUEUE("audio > audio Q_AUDIO_STOP");
queue_post(&audio_queue, Q_AUDIO_STOP, 0);
LOGFQUEUE("audio > audio Q_AUDIO_PLAY"); LOGFQUEUE("audio > audio Q_AUDIO_PLAY");
queue_post(&audio_queue, Q_AUDIO_PLAY, (void *)offset); queue_post(&audio_queue, Q_AUDIO_PLAY, (void *)offset);
} }
while (!playing)
yield();
} }
void audio_stop(void) void audio_stop(void)
{ {
LOGFQUEUE("audio > audio Q_AUDIO_STOP"); LOGFQUEUE("audio > audio Q_AUDIO_STOP");
queue_post(&audio_queue, Q_AUDIO_STOP, 0); queue_post(&audio_queue, Q_AUDIO_STOP, 0);
while(playing)
yield();
} }
void audio_pause(void) void audio_pause(void)
@ -472,11 +477,11 @@ void audio_resume(void)
void audio_next(void) void audio_next(void)
{ {
if (global_settings.beep)
pcmbuf_beep(5000, 100, 2500*global_settings.beep);
if (playlist_check(ci.new_track + wps_offset + 1)) if (playlist_check(ci.new_track + wps_offset + 1))
{ {
if (global_settings.beep)
pcmbuf_beep(5000, 100, 2500*global_settings.beep);
LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1"); LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1");
queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)1); queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)1);
/* Keep wps fast while our message travels inside deep playback queues. */ /* Keep wps fast while our message travels inside deep playback queues. */
@ -487,18 +492,17 @@ void audio_next(void)
{ {
/* No more tracks. */ /* No more tracks. */
if (global_settings.beep) if (global_settings.beep)
pcmbuf_beep(3000, 300, 2500*global_settings.beep); pcmbuf_beep(1000, 100, 1000*global_settings.beep);
} }
} }
void audio_prev(void) void audio_prev(void)
{ {
if (global_settings.beep)
pcmbuf_beep(5000, 100, 2500*global_settings.beep);
if (playlist_check(ci.new_track + wps_offset - 1)) if (playlist_check(ci.new_track + wps_offset - 1))
{ {
if (global_settings.beep)
pcmbuf_beep(5000, 100, 2500*global_settings.beep);
LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1"); LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1");
queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)-1); queue_post(&audio_queue, Q_AUDIO_SKIP, (void *)-1);
/* Keep wps fast while our message travels inside deep playback queues. */ /* Keep wps fast while our message travels inside deep playback queues. */
@ -509,8 +513,7 @@ void audio_prev(void)
{ {
/* No more tracks. */ /* No more tracks. */
if (global_settings.beep) if (global_settings.beep)
pcmbuf_beep(3000, 300, 2500*global_settings.beep); pcmbuf_beep(1000, 100, 1000*global_settings.beep);
} }
} }
@ -721,12 +724,17 @@ void voice_stop(void)
{ {
#ifdef PLAYBACK_VOICE #ifdef PLAYBACK_VOICE
/* Messages should not be posted to voice codec queue unless it is the /* Messages should not be posted to voice codec queue unless it is the
current codec or deadlocks happen. This will be addressed globally soon. current codec or deadlocks happen.
-- jhMikeS */ -- jhMikeS */
if (current_codec != CODEC_IDX_VOICE) if (current_codec != CODEC_IDX_VOICE)
return; return;
mp3_play_stop(); LOGFQUEUE("mp3 > voice Q_VOICE_STOP");
queue_post(&voice_queue, Q_VOICE_STOP, 0);
while (voice_is_playing && !queue_empty(&voice_queue))
yield();
if (!playing)
pcmbuf_play_stop();
#endif #endif
} /* voice_stop */ } /* voice_stop */
@ -934,24 +942,25 @@ static void* voice_request_buffer_callback(size_t *realsize, size_t reqsize)
while (1) while (1)
{ {
if (voice_is_playing) if (voice_is_playing || playing)
{
queue_wait_w_tmo(&voice_queue, &ev, 0); queue_wait_w_tmo(&voice_queue, &ev, 0);
} else
else if (playing) queue_wait(&voice_queue, &ev);
if (!voice_is_playing)
{ {
queue_wait_w_tmo(&voice_queue, &ev, 0);
if (ev.id == SYS_TIMEOUT) if (ev.id == SYS_TIMEOUT)
ev.id = Q_AUDIO_PLAY; ev.id = Q_AUDIO_PLAY;
} }
else
queue_wait(&voice_queue, &ev);
switch (ev.id) { switch (ev.id) {
case Q_AUDIO_PLAY: case Q_AUDIO_PLAY:
LOGFQUEUE("voice < Q_AUDIO_PLAY"); LOGFQUEUE("voice < Q_AUDIO_PLAY");
if (playing) if (playing)
swap_codec(); {
if (audio_codec_loaded)
swap_codec();
yield();
}
break; break;
#if defined(HAVE_RECORDING) && !defined(SIMULATOR) #if defined(HAVE_RECORDING) && !defined(SIMULATOR)
@ -1810,10 +1819,6 @@ static void codec_thread(void)
LOGFQUEUE("codec < SYS_USB_CONNECTED"); LOGFQUEUE("codec < SYS_USB_CONNECTED");
queue_clear(&codec_queue); queue_clear(&codec_queue);
usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_acknowledge(SYS_USB_CONNECTED_ACK);
#ifdef PLAYBACK_VOICE
if(voice_codec_loaded)
swap_codec();
#endif
usb_wait_for_disconnect(&codec_queue); usb_wait_for_disconnect(&codec_queue);
break; break;
#endif #endif
@ -2170,6 +2175,7 @@ static void audio_read_file(bool quick)
return ; return ;
} }
cpu_boost(true);
while (tracks[track_widx].filerem > 0) while (tracks[track_widx].filerem > 0)
{ {
int overlap; int overlap;
@ -2237,6 +2243,7 @@ static void audio_read_file(bool quick)
logf("Partially buf:%dB", logf("Partially buf:%dB",
tracks[track_widx].filesize - tracks[track_widx].filerem); tracks[track_widx].filesize - tracks[track_widx].filerem);
} }
cpu_boost(false);
} }
static bool audio_loadcodec(bool start_play) static bool audio_loadcodec(bool start_play)