Advertisement
Guest User

Audacious input plugin changes

a guest
Aug 31st, 2013
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.50 KB | None | 0 0
  1. diff --git a/src/sndfile/plugin.c b/src/sndfile/plugin.c
  2. index 1742730..e7cf038 100644
  3. --- a/src/sndfile/plugin.c
  4. +++ b/src/sndfile/plugin.c
  5. @@ -39,7 +39,6 @@
  6.   */
  7.  
  8.  #include <math.h>
  9. -#include <pthread.h>
  10.  #include <stdlib.h>
  11.  
  12.  #include <sndfile.h>
  13. @@ -47,10 +46,6 @@
  14.  #include <audacious/plugin.h>
  15.  #include <audacious/i18n.h>
  16.  
  17. -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  18. -static int seek_value;
  19. -static bool_t stop_flag;
  20. -
  21.  /* Virtual file access wrappers for libsndfile
  22.   */
  23.  static sf_count_t
  24. @@ -289,7 +284,7 @@ static Tuple * get_song_tuple (const char * filename, VFSFile * file)
  25.  }
  26.  
  27.  static bool_t play_start (InputPlayback * playback, const char * filename,
  28. - VFSFile * file, int start_time, int stop_time, bool_t pause)
  29. + VFSFile * file)
  30.  {
  31.      if (file == NULL)
  32.          return FALSE;
  33. @@ -312,35 +307,16 @@ static bool_t play_start (InputPlayback * playback, const char * filename,
  34.       * files. */
  35.      playback->set_params (playback, 0, sfinfo.samplerate, sfinfo.channels);
  36.  
  37. -    seek_value = (start_time > 0) ? start_time : -1;
  38. -    stop_flag = FALSE;
  39. -    playback->set_pb_ready(playback);
  40. -
  41.      int size = sfinfo.channels * (sfinfo.samplerate / 50);
  42.      float * buffer = malloc (sizeof (float) * size);
  43.  
  44. -    while (stop_time < 0 || playback->output->written_time () < stop_time)
  45. +    while (! playback->check_stop ())
  46.      {
  47. -        pthread_mutex_lock (& mutex);
  48. -
  49. -        if (stop_flag)
  50. -        {
  51. -            pthread_mutex_unlock (& mutex);
  52. -            break;
  53. -        }
  54. -
  55. +        int seek_value = playback->check_seek ();
  56.          if (seek_value != -1)
  57. -        {
  58. -            sf_seek (sndfile, (int64_t) seek_value * sfinfo.samplerate / 1000,
  59. -             SEEK_SET);
  60. -            playback->output->flush (seek_value);
  61. -            seek_value = -1;
  62. -        }
  63. -
  64. -        pthread_mutex_unlock (& mutex);
  65. +            sf_seek (sndfile, (int64_t) seek_value * sfinfo.samplerate / 1000, SEEK_SET);
  66.  
  67.          int samples = sf_read_float (sndfile, buffer, size);
  68. -
  69.          if (! samples)
  70.              break;
  71.  
  72. @@ -350,49 +326,9 @@ static bool_t play_start (InputPlayback * playback, const char * filename,
  73.      sf_close (sndfile);
  74.      free (buffer);
  75.  
  76. -    pthread_mutex_lock (& mutex);
  77. -    stop_flag = TRUE;
  78. -    pthread_mutex_unlock (& mutex);
  79. -
  80.      return TRUE;
  81.  }
  82.  
  83. -static void play_pause (InputPlayback * p, bool_t pause)
  84. -{
  85. -    pthread_mutex_lock (& mutex);
  86. -
  87. -    if (! stop_flag)
  88. -        p->output->pause (pause);
  89. -
  90. -    pthread_mutex_unlock (& mutex);
  91. -}
  92. -
  93. -static void play_stop (InputPlayback * p)
  94. -{
  95. -    pthread_mutex_lock (& mutex);
  96. -
  97. -    if (! stop_flag)
  98. -    {
  99. -        stop_flag = TRUE;
  100. -        p->output->abort_write ();
  101. -    }
  102. -
  103. -    pthread_mutex_unlock (& mutex);
  104. -}
  105. -
  106. -static void file_mseek (InputPlayback * p, int time)
  107. -{
  108. -    pthread_mutex_lock (& mutex);
  109. -
  110. -    if (! stop_flag)
  111. -    {
  112. -        seek_value = time;
  113. -        p->output->abort_write();
  114. -    }
  115. -
  116. -    pthread_mutex_unlock (& mutex);
  117. -}
  118. -
  119.  static int
  120.  is_our_file_from_vfs(const char *filename, VFSFile *fin)
  121.  {
  122. @@ -436,12 +372,9 @@ AUD_INPUT_PLUGIN
  123.      .domain = PACKAGE,
  124.      .about_text = plugin_about,
  125.      .play = play_start,
  126. -    .stop = play_stop,
  127. -    .pause = play_pause,
  128.      .probe_for_tuple = get_song_tuple,
  129.      .is_our_file_from_vfs = is_our_file_from_vfs,
  130.      .extensions = sndfile_fmts,
  131. -    .mseek = file_mseek,
  132.  
  133.      /* low priority fallback (but before ffaudio) */
  134.      .priority = 9,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement