Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Stuff
Tuesday, February 26th, 2008 at 4:36:20pm UTC 

  1. diff --git a/apps/playback.c b/apps/playback.c
  2. index cca5b73..bf02914 100644
  3. --- a/apps/playback.c
  4. +++ b/apps/playback.c
  5. @@ -222,6 +222,10 @@ static int track_widx = 0;           /* Track being buffered (A) */
  6.  static struct track_info *prev_ti = NULL;  /* Pointer to the previously played
  7.                                                track */
  8.  
  9. +/* Set by buffering_audio_callback when the low buffer event is received, to
  10. +   avoid flodding the audio queue with fill_file_buffer messages. */
  11. +static bool lowbuffer_event_sent = false;
  12. +
  13.  /* Set by the audio thread when the current track information has updated
  14.   * and the WPS may need to update its cached information */
  15.  static bool track_changed = false;
  16. @@ -553,7 +557,8 @@ struct mp3entry* audio_current_track(void)
  17.  
  18.  struct mp3entry* audio_next_track(void)
  19.  {
  20. -    int next_idx = track_ridx;
  21. +    int next_idx;
  22. +    int offset = ci.new_track + wps_offset;
  23.  
  24.      if (!audio_have_tracks())
  25.          return NULL;
  26. @@ -565,7 +570,7 @@ struct mp3entry* audio_next_track(void)
  27.          return &curtrack_id3;
  28.      }
  29.  
  30. -    next_idx = (next_idx + 1) & MAX_TRACK_MASK;
  31. +    next_idx = (track_ridx + offset + 1) & MAX_TRACK_MASK;
  32.  
  33.      if (next_idx == track_widx)
  34.      {
  35. @@ -629,17 +634,19 @@ void audio_resume(void)
  36.      queue_send(&audio_queue, Q_AUDIO_PAUSE, false);
  37.  }
  38.  
  39. -void audio_next(void)
  40. +static void audio_skip(int direction)
  41.  {
  42. -    if (playlist_check(ci.new_track + wps_offset + 1))
  43. +    if (playlist_check(ci.new_track + wps_offset + direction))
  44.      {
  45.          if (global_settings.beep)
  46.              pcmbuf_beep(5000, 100, 2500*global_settings.beep);
  47.  
  48. -        LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1");
  49. -        queue_post(&audio_queue, Q_AUDIO_SKIP, 1);
  50. +        LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", direction);
  51. +        queue_post(&audio_queue, Q_AUDIO_SKIP, direction);
  52.          /* Update wps while our message travels inside deep playback queues. */
  53. -        wps_offset++;
  54. +        playlist_next(direction);
  55. +        last_peek_offset -= direction;
  56. +        wps_offset += direction;
  57.          track_changed = true;
  58.      }
  59.      else
  60. @@ -650,25 +657,14 @@ void audio_next(void)
  61.      }
  62.  }
  63.  
  64. -void audio_prev(void)
  65. +void audio_next(void)
  66.  {
  67. -    if (playlist_check(ci.new_track + wps_offset - 1))
  68. -    {
  69. -        if (global_settings.beep)
  70. -            pcmbuf_beep(5000, 100, 2500*global_settings.beep);
  71. +    audio_skip(1);
  72. +}
  73.  
  74. -        LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1");
  75. -        queue_post(&audio_queue, Q_AUDIO_SKIP, -1);
  76. -        /* Update wps while our message travels inside deep playback queues. */
  77. -        wps_offset--;
  78. -        track_changed = true;
  79. -    }
  80. -    else
  81. -    {
  82. -        /* No more tracks. */
  83. -        if (global_settings.beep)
  84. -            pcmbuf_beep(1000, 100, 1000*global_settings.beep);
  85. -    }
  86. +void audio_prev(void)
  87. +{
  88. +    audio_skip(-1);
  89.  }
  90.  
  91.  void audio_next_dir(void)
  92. @@ -1466,8 +1462,11 @@ static void buffering_audio_callback(enum callback_event ev, int value)
  93.      switch (ev)
  94.      {
  95.          case EVENT_BUFFER_LOW:
  96. -            LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");
  97. -            queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);
  98. +            if (!lowbuffer_event_sent) {
  99. +                LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");
  100. +                queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);
  101. +                lowbuffer_event_sent = true;
  102. +            }
  103.              break;
  104.  
  105.          case EVENT_HANDLE_REBUFFER:
  106. @@ -1476,6 +1475,7 @@ static void buffering_audio_callback(enum callback_event ev, int value)
  107.              break;
  108.  
  109.          case EVENT_HANDLE_FINISHED:
  110. +            logf("handle %d finished buffering", value);
  111.              strip_tags(value);
  112.              break;
  113.  
  114. @@ -1895,6 +1895,9 @@ static void audio_fill_file_buffer(bool start_play, size_t offset)
  115.      bool had_next_track = audio_next_track() != NULL;
  116.      bool continue_buffering;
  117.  
  118. +    if (ci.new_track != 0)
  119. +        return;
  120. +
  121.      /* Must reset the buffer before use if trashed or voice only - voice
  122.         file size shouldn't have changed so we can go straight from
  123.         BUFFER_STATE_VOICED_ONLY to BUFFER_STATE_INITIALIZED */
  124. @@ -1930,6 +1933,7 @@ static void audio_fill_file_buffer(bool start_play, size_t offset)
  125.          track_changed = true;
  126.  
  127.      audio_generate_postbuffer_events();
  128. +    lowbuffer_event_sent = false;
  129.  }
  130.  
  131.  static void audio_rebuffer(void)
  132. @@ -2001,12 +2005,13 @@ static int audio_check_new_track(void)
  133.                  return Q_CODEC_REQUEST_FAILED;
  134.              }
  135.      }
  136. -    /* Update the playlist */
  137. -    last_peek_offset -= ci.new_track;
  138.  
  139. -    if (auto_dir_skip || !automatic_skip)
  140. +    if (auto_dir_skip)
  141.      {
  142. -        /* If the track change was manual or the result of an auto dir skip,
  143. +        /* Update the playlist */
  144. +        last_peek_offset -= ci.new_track;
  145. +
  146. +        /* If the track change was the result of an auto dir skip,
  147.             we need to update the playlist now */
  148.          next_playlist_index = playlist_next(ci.new_track);
  149.  
  150. @@ -2061,10 +2066,9 @@ static int audio_check_new_track(void)
  151.      {
  152.          playlist_end = false;
  153.          wps_offset = -ci.new_track;
  154. +        track_changed = true;
  155.      }
  156.  
  157. -    track_changed = true;
  158. -
  159.      /* If it is not safe to even skip this many track entries */
  160.      if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK)
  161.      {
  162. @@ -2296,8 +2300,11 @@ static void audio_new_playlist(void)
  163.      audio_fill_file_buffer(false, 0);
  164.  }
  165.  
  166. +/* Called on manual track skip */
  167.  static void audio_initiate_track_change(long direction)
  168.  {
  169. +    logf("audio_initiate_track_change(%ld)", direction);
  170. +
  171.      playlist_end = false;
  172.      ci.new_track += direction;
  173.      wps_offset -= direction;
  174. @@ -2305,6 +2312,7 @@ static void audio_initiate_track_change(long direction)
  175.          skipped_during_pause = true;
  176.  }
  177.  
  178. +/* Called on manual dir skip */
  179.  static void audio_initiate_dir_change(long direction)
  180.  {
  181.      playlist_end = false;

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right