1
0
Fork 0
forked from len0rd/rockbox

SWCODEC Playback: Put a stop to the resume deadlock however crudely. Clean some unused lines out that no longer compatible.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13364 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-05-09 03:44:44 +00:00
parent a21871ceaa
commit e486ed0453

View file

@ -101,11 +101,11 @@
/* macros to enable logf for queues /* macros to enable logf for queues
logging on SYS_TIMEOUT can be disabled */ logging on SYS_TIMEOUT can be disabled */
#ifdef SIMULATOR #if 1//def SIMULATOR
/* Define this for logf output of all queuing except SYS_TIMEOUT */ /* Define this for logf output of all queuing except SYS_TIMEOUT */
#define PLAYBACK_LOGQUEUES #define PLAYBACK_LOGQUEUES
/* Define this to logf SYS_TIMEOUT messages */ /* Define this to logf SYS_TIMEOUT messages */
#define PLAYBACK_LOGQUEUES_SYS_TIMEOUT //#define PLAYBACK_LOGQUEUES_SYS_TIMEOUT
#endif #endif
#ifdef PLAYBACK_LOGQUEUES #ifdef PLAYBACK_LOGQUEUES
@ -138,14 +138,10 @@ enum {
Q_AUDIO_FLUSH, Q_AUDIO_FLUSH,
Q_AUDIO_TRACK_CHANGED, Q_AUDIO_TRACK_CHANGED,
Q_AUDIO_DIR_SKIP, Q_AUDIO_DIR_SKIP,
Q_AUDIO_UNUSED_0, /* Free. Previously Q_AUDIO_NEW_PLAYLIST */
Q_AUDIO_POSTINIT, Q_AUDIO_POSTINIT,
Q_AUDIO_FILL_BUFFER, Q_AUDIO_FILL_BUFFER,
#if MEM > 8 #if MEM > 8
Q_AUDIO_FILL_BUFFER_IF_ACTIVE_ATA, Q_AUDIO_FILL_BUFFER_IF_ACTIVE_ATA,
#endif
#if 0
Q_CODEC_REQUEST_PENDING,
#endif #endif
Q_CODEC_REQUEST_COMPLETE, Q_CODEC_REQUEST_COMPLETE,
Q_CODEC_REQUEST_FAILED, Q_CODEC_REQUEST_FAILED,
@ -668,7 +664,7 @@ void audio_play(long offset)
#endif #endif
/* Start playback */ /* Start playback */
LOGFQUEUE("audio >| audio Q_AUDIO_PLAY: %l", offset); LOGFQUEUE("audio >| audio Q_AUDIO_PLAY: %ld", offset);
/* Don't return until playback has actually started */ /* Don't return until playback has actually started */
queue_send(&audio_queue, Q_AUDIO_PLAY, offset); queue_send(&audio_queue, Q_AUDIO_PLAY, offset);
} }
@ -1579,11 +1575,14 @@ static void codec_advance_buffer_callback(size_t amount)
if (amount > CUR_TI->available) if (amount > CUR_TI->available)
{ {
intptr_t result; intptr_t result = Q_CODEC_REQUEST_FAILED;
LOGFQUEUE("codec >| audio Q_AUDIO_REBUFFER_SEEK");
if (!ci.stop_codec)
{
LOGFQUEUE("codec >| audio Q_AUDIO_REBUFFER_SEEK");
result = queue_send(&audio_queue, Q_AUDIO_REBUFFER_SEEK, result = queue_send(&audio_queue, Q_AUDIO_REBUFFER_SEEK,
ci.curpos + amount); ci.curpos + amount);
}
switch (result) switch (result)
{ {
@ -1722,10 +1721,14 @@ static bool codec_seek_buffer_callback(size_t newpos)
/* We need to reload the song. */ /* We need to reload the song. */
if (newpos < CUR_TI->start_pos) if (newpos < CUR_TI->start_pos)
{ {
intptr_t result; intptr_t result = Q_CODEC_REQUEST_FAILED;
if (!ci.stop_codec)
{
LOGFQUEUE("codec >| audio Q_AUDIO_REBUFFER_SEEK"); LOGFQUEUE("codec >| audio Q_AUDIO_REBUFFER_SEEK");
result = queue_send(&audio_queue, Q_AUDIO_REBUFFER_SEEK, newpos); result = queue_send(&audio_queue, Q_AUDIO_REBUFFER_SEEK,
newpos);
}
switch (result) switch (result)
{ {
@ -1862,7 +1865,7 @@ static void codec_track_skip_done(bool was_manual)
static bool codec_load_next_track(void) static bool codec_load_next_track(void)
{ {
intptr_t result; intptr_t result = Q_CODEC_REQUEST_FAILED;
prev_track_elapsed = CUR_TI->id3.elapsed; prev_track_elapsed = CUR_TI->id3.elapsed;
@ -1881,23 +1884,12 @@ static bool codec_load_next_track(void)
automatic_skip = true; automatic_skip = true;
} }
if (!ci.stop_codec)
{
trigger_cpu_boost(); trigger_cpu_boost();
LOGFQUEUE("codec >| audio Q_AUDIO_CHECK_NEW_TRACK"); LOGFQUEUE("codec >| audio Q_AUDIO_CHECK_NEW_TRACK");
result = queue_send(&audio_queue, Q_AUDIO_CHECK_NEW_TRACK, 0); result = queue_send(&audio_queue, Q_AUDIO_CHECK_NEW_TRACK, 0);
#if 0 /* Q_CODEC_REQUEST_PENDING never posted anyway */
while (1)
{
queue_wait(&codec_callback_queue, &ev);
if (ev.id == Q_CODEC_REQUEST_PENDING)
{
if (!automatic_skip)
pcmbuf_play_stop();
} }
else
break;
}
#endif
switch (result) switch (result)
{ {
@ -3003,27 +2995,6 @@ static void audio_rebuffer(void)
{ {
logf("Forcing rebuffer"); logf("Forcing rebuffer");
#if 0
/* Notify the codec that this will take a while */
/* Currently this can cause some problems (logf in reverse order):
* Codec load error:-1
* Codec load disk
* Codec: Unsupported
* Codec finished
* New codec:0/3
* Clearing tracks:7/7, 1
* Forcing rebuffer
* Check new track buffer
* Request new track
* Clearing tracks:5/5, 0
* Starting buffer fill
* Clearing tracks:5/5, 1
* Re-buffering song w/seek
*/
if (!filling)
queue_post(&codec_callback_queue, Q_CODEC_REQUEST_PENDING, 0);
#endif
/* Stop in progress fill, and clear open file descriptor */ /* Stop in progress fill, and clear open file descriptor */
if (current_fd >= 0) if (current_fd >= 0)
{ {
@ -3272,8 +3243,10 @@ static void audio_stop_codec_flush(void)
{ {
ci.stop_codec = true; ci.stop_codec = true;
pcmbuf_pause(true); pcmbuf_pause(true);
while (audio_codec_loaded) while (audio_codec_loaded)
yield(); yield();
/* If the audio codec is not loaded any more, and the audio is still /* If the audio codec is not loaded any more, and the audio is still
* playing, it is now and _only_ now safe to call this function from the * playing, it is now and _only_ now safe to call this function from the
* audio thread */ * audio thread */
@ -3287,9 +3260,18 @@ static void audio_stop_playback(void)
/* If we were playing, save resume information */ /* If we were playing, save resume information */
if (playing) if (playing)
{ {
struct mp3entry *id3 = NULL;
if (!playlist_end || !ci.stop_codec)
{
/* Set this early, the outside code yields and may allow the codec
to try to wait for a reply on a buffer wait */
ci.stop_codec = true;
id3 = audio_current_track();
}
/* Save the current playing spot, or NULL if the playlist has ended */ /* Save the current playing spot, or NULL if the playlist has ended */
playlist_update_resume_info( playlist_update_resume_info(id3);
(playlist_end && ci.stop_codec)?NULL:audio_current_track());
/* Increment index so runtime info is saved in audio_clear_track_entries(). /* Increment index so runtime info is saved in audio_clear_track_entries().
* Done here, as audio_stop_playback() may be called more than once. * Done here, as audio_stop_playback() may be called more than once.
@ -3703,6 +3685,7 @@ static void audio_thread(void)
#ifndef SIMULATOR #ifndef SIMULATOR
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
LOGFQUEUE("audio < SYS_USB_CONNECTED"); LOGFQUEUE("audio < SYS_USB_CONNECTED");
if (playing)
audio_stop_playback(); audio_stop_playback();
usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&audio_queue); usb_wait_for_disconnect(&audio_queue);