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

Something
Tuesday, February 26th, 2008 at 3:27:15pm UTC 

  1. diff --git a/apps/buffering.c b/apps/buffering.c
  2. index 64f522c..f6c9f31 100644
  3. --- a/apps/buffering.c
  4. +++ b/apps/buffering.c
  5. @@ -61,7 +61,7 @@
  6.  #endif
  7.  
  8.  /* Define LOGF_ENABLE to enable logf output in this file */
  9. -/*#define LOGF_ENABLE*/
  10. +#define LOGF_ENABLE
  11.  #include "logf.h"
  12.  
  13.  /* macros to enable logf for queues
  14. @@ -639,6 +639,10 @@ static bool buffer_handle(int handle_id)
  15.          h->available += rc;
  16.          h->filerem -= rc;
  17.  
  18. +#ifdef SIMULATOR
  19. +        sleep(1);
  20. +#endif
  21. +
  22.          /* If this is a large file, see if we need to break or give the codec
  23.           * more time */
  24.          if (h->type == TYPE_PACKET_AUDIO &&
  25. diff --git a/apps/debug_menu.c b/apps/debug_menu.c
  26. index 8cd1fed..7091814 100644
  27. --- a/apps/debug_menu.c
  28. +++ b/apps/debug_menu.c
  29. @@ -279,6 +279,8 @@ static bool dbg_buffering_thread(void)
  30.      size_t bufsize = pcmbuf_get_bufsize();
  31.      int pcmbufdescs = pcmbuf_descs();
  32.      struct buffering_debug d;
  33. +    //extern struct codec_api ci;
  34. +    extern int wps_offset;
  35.  
  36.      ticks = boost_ticks = 0;
  37.  
  38. @@ -288,16 +290,16 @@ static bool dbg_buffering_thread(void)
  39.      lcd_setfont(FONT_SYSFIXED);
  40.      while(!done)
  41.      {
  42. -        button = get_action(CONTEXT_STD,HZ/5);
  43. +        button = get_action(CONTEXT_WPS,HZ/5);
  44.          switch(button)
  45.          {
  46. -            case ACTION_STD_NEXT:
  47. +            case ACTION_WPS_SKIPNEXT:
  48.                  audio_next();
  49.                  break;
  50. -            case ACTION_STD_PREV:
  51. +            case ACTION_WPS_SKIPPREV:
  52.                  audio_prev();
  53.                  break;
  54. -            case ACTION_STD_CANCEL:
  55. +            case ACTION_WPS_MENU:
  56.                  done = true;
  57.                  break;
  58.          }
  59. @@ -370,6 +372,12 @@ static bool dbg_buffering_thread(void)
  60.                  pcmbuf_used_descs(), pcmbufdescs);
  61.          lcd_puts(0, line++, buf);
  62.  
  63. +        //snprintf(buf, sizeof(buf), "ci.new_track: %d", ci.new_track);
  64. +        //lcd_puts(0, line++, buf);
  65. +
  66. +        snprintf(buf, sizeof(buf), "wps_offset: %d", wps_offset);
  67. +        lcd_puts(0, line++, buf);
  68. +
  69.          lcd_update();
  70.      }
  71.  
  72. diff --git a/apps/playback.c b/apps/playback.c
  73. index cca5b73..73558e2 100644
  74. --- a/apps/playback.c
  75. +++ b/apps/playback.c
  76. @@ -86,7 +86,7 @@
  77.  #define AUDIO_REBUFFER_GUESS_SIZE    (1024*32)
  78.  
  79.  /* Define LOGF_ENABLE to enable logf output in this file */
  80. -/*#define LOGF_ENABLE*/
  81. +#define LOGF_ENABLE
  82.  #include "logf.h"
  83.  
  84.  /* macros to enable logf for queues
  85. @@ -222,6 +222,10 @@ static int track_widx = 0;           /* Track being buffered (A) */
  86.  static struct track_info *prev_ti = NULL;  /* Pointer to the previously played
  87.                                                track */
  88.  
  89. +/* Set by buffering_audio_callback when the low buffer event is received, to
  90. +   avoid flodding the audio queue with fill_file_buffer messages. */
  91. +static bool lowbuffer_event_sent = false;
  92. +
  93.  /* Set by the audio thread when the current track information has updated
  94.   * and the WPS may need to update its cached information */
  95.  static bool track_changed = false;
  96. @@ -239,7 +243,7 @@ static bool playlist_end = false;   /* Has the current playlist ended? (A) */
  97.  static bool auto_dir_skip = false;  /* Have we changed dirs automatically? */
  98.  static bool dir_skip = false;       /* Is a directory skip pending? (A) */
  99.  static bool new_playlist = false;   /* Are we starting a new playlist? (A) */
  100. -static int wps_offset = 0;          /* Pending track change offset, to keep WPS responsive (A) */
  101. +int wps_offset = 0;          /* Pending track change offset, to keep WPS responsive (A) */
  102.  static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer when playback resumes (A) */
  103.  
  104.  /* Callbacks which applications or plugins may set */
  105. @@ -553,7 +557,8 @@ struct mp3entry* audio_current_track(void)
  106.  
  107.  struct mp3entry* audio_next_track(void)
  108.  {
  109. -    int next_idx = track_ridx;
  110. +    int next_idx;
  111. +    int offset = ci.new_track + wps_offset;
  112.  
  113.      if (!audio_have_tracks())
  114.          return NULL;
  115. @@ -565,7 +570,7 @@ struct mp3entry* audio_next_track(void)
  116.          return &curtrack_id3;
  117.      }
  118.  
  119. -    next_idx = (next_idx + 1) & MAX_TRACK_MASK;
  120. +    next_idx = (track_ridx + offset + 1) & MAX_TRACK_MASK;
  121.  
  122.      if (next_idx == track_widx)
  123.      {
  124. @@ -629,17 +634,19 @@ void audio_resume(void)
  125.      queue_send(&audio_queue, Q_AUDIO_PAUSE, false);
  126.  }
  127.  
  128. -void audio_next(void)
  129. +static void audio_skip(int direction)
  130.  {
  131. -    if (playlist_check(ci.new_track + wps_offset + 1))
  132. +    if (playlist_check(ci.new_track + wps_offset + direction))
  133.      {
  134.          if (global_settings.beep)
  135.              pcmbuf_beep(5000, 100, 2500*global_settings.beep);
  136.  
  137. -        LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1");
  138. -        queue_post(&audio_queue, Q_AUDIO_SKIP, 1);
  139. +        LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", direction);
  140. +        queue_post(&audio_queue, Q_AUDIO_SKIP, direction);
  141.          /* Update wps while our message travels inside deep playback queues. */
  142. -        wps_offset++;
  143. +        playlist_next(direction);
  144. +        last_peek_offset -= direction;
  145. +        wps_offset += direction;
  146.          track_changed = true;
  147.      }
  148.      else
  149. @@ -650,25 +657,14 @@ void audio_next(void)
  150.      }
  151.  }
  152.  
  153. -void audio_prev(void)
  154. +void audio_next(void)
  155.  {
  156. -    if (playlist_check(ci.new_track + wps_offset - 1))
  157. -    {
  158. -        if (global_settings.beep)
  159. -            pcmbuf_beep(5000, 100, 2500*global_settings.beep);
  160. +    audio_skip(1);
  161. +}
  162.  
  163. -        LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1");
  164. -        queue_post(&audio_queue, Q_AUDIO_SKIP, -1);
  165. -        /* Update wps while our message travels inside deep playback queues. */
  166. -        wps_offset--;
  167. -        track_changed = true;
  168. -    }
  169. -    else
  170. -    {
  171. -        /* No more tracks. */
  172. -        if (global_settings.beep)
  173. -            pcmbuf_beep(1000, 100, 1000*global_settings.beep);
  174. -    }
  175. +void audio_prev(void)
  176. +{
  177. +    audio_skip(-1);
  178.  }
  179.  
  180.  void audio_next_dir(void)
  181. @@ -1466,8 +1462,11 @@ static void buffering_audio_callback(enum callback_event ev, int value)
  182.      switch (ev)
  183.      {
  184.          case EVENT_BUFFER_LOW:
  185. -            LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");
  186. -            queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);
  187. +            if (!lowbuffer_event_sent) {
  188. +                LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");
  189. +                queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);
  190. +                lowbuffer_event_sent = true;
  191. +            }
  192.              break;
  193.  
  194.          case EVENT_HANDLE_REBUFFER:
  195. @@ -1476,6 +1475,7 @@ static void buffering_audio_callback(enum callback_event ev, int value)
  196.              break;
  197.  
  198.          case EVENT_HANDLE_FINISHED:
  199. +            logf("handle %d finished buffering", value);
  200.              strip_tags(value);
  201.              break;
  202.  
  203. @@ -1895,6 +1895,9 @@ static void audio_fill_file_buffer(bool start_play, size_t offset)
  204.      bool had_next_track = audio_next_track() != NULL;
  205.      bool continue_buffering;
  206.  
  207. +    if (ci.new_track != 0)
  208. +        return;
  209. +
  210.      /* Must reset the buffer before use if trashed or voice only - voice
  211.         file size shouldn't have changed so we can go straight from
  212.         BUFFER_STATE_VOICED_ONLY to BUFFER_STATE_INITIALIZED */
  213. @@ -1902,6 +1905,9 @@ static void audio_fill_file_buffer(bool start_play, size_t offset)
  214.          audio_reset_buffer();
  215.  
  216.      logf("Starting buffer fill");
  217. +#ifdef SIMULATOR
  218. +    sleep(200);
  219. +#endif
  220.  
  221.      if (!start_play)
  222.          audio_clear_track_entries(false);
  223. @@ -1930,6 +1936,7 @@ static void audio_fill_file_buffer(bool start_play, size_t offset)
  224.          track_changed = true;
  225.  
  226.      audio_generate_postbuffer_events();
  227. +    lowbuffer_event_sent = false;
  228.  }
  229.  
  230.  static void audio_rebuffer(void)
  231. @@ -1959,7 +1966,7 @@ static int audio_check_new_track(void)
  232.      int track_count = audio_track_count();
  233.      int old_track_ridx = track_ridx;
  234.      int i, idx;
  235. -    int next_playlist_index;
  236. +    //int next_playlist_index;
  237.      bool forward;
  238.      bool end_of_playlist;  /* Temporary flag, not the same as playlist_end */
  239.  
  240. @@ -2001,6 +2008,7 @@ static int audio_check_new_track(void)
  241.                  return Q_CODEC_REQUEST_FAILED;
  242.              }
  243.      }
  244. +#if 0
  245.      /* Update the playlist */
  246.      last_peek_offset -= ci.new_track;
  247.  
  248. @@ -2016,6 +2024,7 @@ static int audio_check_new_track(void)
  249.              return Q_CODEC_REQUEST_FAILED;
  250.          }
  251.      }
  252. +#endif
  253.  
  254.      if (new_playlist)
  255.      {
  256. @@ -2063,8 +2072,6 @@ static int audio_check_new_track(void)
  257.          wps_offset = -ci.new_track;
  258.      }
  259.  
  260. -    track_changed = true;
  261. -
  262.      /* If it is not safe to even skip this many track entries */
  263.      if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK)
  264.      {
  265. @@ -2296,8 +2303,11 @@ static void audio_new_playlist(void)
  266.      audio_fill_file_buffer(false, 0);
  267.  }
  268.  
  269. +/* Called on manual track skip */
  270.  static void audio_initiate_track_change(long direction)
  271.  {
  272. +    logf("audio_initiate_track_change(%ld)", direction);
  273. +
  274.      playlist_end = false;
  275.      ci.new_track += direction;
  276.      wps_offset -= direction;
  277. @@ -2305,6 +2315,7 @@ static void audio_initiate_track_change(long direction)
  278.          skipped_during_pause = true;
  279.  }
  280.  
  281. +/* Called on manual dir skip */
  282.  static void audio_initiate_dir_change(long direction)
  283.  {
  284.      playlist_end = false;
  285. diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
  286. index 822a43b..7489ff3 100644
  287. --- a/uisimulator/common/io.c
  288. +++ b/uisimulator/common/io.c
  289. @@ -342,7 +342,7 @@ int sim_open(const char *name, int o)
  290.      {
  291.          snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
  292.  
  293. -        debugf("We open the real file '%s'\n", buffer);
  294. +        //debugf("We open the real file '%s'\n", buffer);
  295.          if (num_openfiles < MAX_OPEN_FILES)
  296.          {
  297.              ret = OPEN(buffer, opts, 0666);

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
worth-right