Re: audio/audacious unpausing by itself

2012-05-04 Thread Alexandre Ratchov
On Thu, Apr 05, 2012 at 08:29:18PM +0200, Stefan Sperling wrote:
 On Thu, Apr 05, 2012 at 09:53:40PM +0400, Alexander Polakov wrote:
  After updating audacious to 3.2 I have encountered
  a problem: I hit pause button and it stops playing,
  but some time passes and it starts playing without
  me doing a thing.
  
  Looks like the time before it starts is roughly 
  equal to the time from current time position to
  the end of the track. Like, if I hit pause on
  4:50 and the track's length is 5:00, the next track 
  starts playing in 10 seconds.
  
  Can anyone else confirm this?
  
  I'm running current on amd64.
  
  audacious 3.2p0
 
 Yes, I can reproduce this. It happens with the sndio backend.
 You can use the SDL audio backend as a workaround until this is fixed.

This is to update the plug-in to the newer 3.x plug-in semantics.
This fixes the unpausing bug which afaiu was an effect of using
the version 2.x plug-in with audacious version 3.x. This fixes
other similar bugs as well (eg. crashes during volume changes).

comments? ok?

-- Alexandre

Index: Makefile
===
RCS file: /cvs/ports/audio/audacious-plugins/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- Makefile6 Apr 2012 14:38:01 -   1.43
+++ Makefile4 May 2012 07:57:56 -
@@ -6,7 +6,7 @@ COMMENT =   input and output plugins for 
 
 V =3.2
 DISTNAME = audacious-plugins-$V
-REVISION = 2
+REVISION = 3
 
 CATEGORIES =   audio multimedia
 
Index: files/sndio.c
===
RCS file: /cvs/ports/audio/audacious-plugins/files/sndio.c,v
retrieving revision 1.3
diff -u -p -r1.3 sndio.c
--- files/sndio.c   20 Mar 2012 19:10:56 -  1.3
+++ files/sndio.c   4 May 2012 07:57:56 -
@@ -15,11 +15,13 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include errno.h
+#include poll.h
+#include pthread.h
 #include sndio.h
 #include stdio.h
 #include stdlib.h
 #include string.h
-#include pthread.h
 #include gtk/gtk.h
 #include audacious/plugin.h
 #include audacious/misc.h
@@ -39,6 +41,8 @@ void  sndio_get_volume(int *, int *);
 void   sndio_set_volume(int, int);
 bool_t sndio_open(int, int, int);
 void   sndio_close(void);
+intsndio_buffer_free(void);
+voidsndio_period_wait(void);
 void   sndio_write(void *, int);
 void   sndio_pause(bool_t);
 void   sndio_flush(int);
@@ -56,12 +60,10 @@ static struct sio_par par;
 static struct sio_hdl *hdl;
 static long long rdpos;
 static long long wrpos;
-static int paused, flushed, volume;
-static int flush_time, pause_flag, volume_target;
-static int writing, pause_pending, flush_pending, volume_pending;
+static int paused, restarted, volume;
+static int pause_pending, flush_pending, volume_pending;
 static int bytes_per_sec;
 static pthread_mutex_t mtx;
-static pthread_t sndio_thread;
 
 static GtkWidget *configure_win;
 static GtkWidget *adevice_entry;
@@ -80,6 +82,8 @@ AUD_OUTPUT_PLUGIN
.open_audio = sndio_open,
.write_audio = sndio_write,
.close_audio = sndio_close,
+   .buffer_free = sndio_buffer_free,
+   .period_wait = sndio_period_wait,
.flush = sndio_flush,
.pause = sndio_pause,
.output_time = sndio_output_time,
@@ -100,70 +104,62 @@ static struct fmt_to_par {
{FMT_U32_LE, 32, 0, 1}, {FMT_U32_BE, 32, 0, 0}
 };
 
+static const gchar * const sndio_defaults[] = {
+   volume, 100,
+   audiodev, ,
+   NULL,
+};
+
 static void
-volume_do(int v)
+reset(void)
 {
-   if (writing) {
-   volume_target = v;
-   volume_pending = 1;
-   } else {
-   if (hdl)
-   sio_setvol(hdl, v * SIO_MAXVOL / 100);
-   volume_pending = 0;
+   if (!restarted) {
+   restarted = 1;
+   sio_stop(hdl);
+   sio_start(hdl);
+   rdpos = wrpos;
}
 }
 
 static void
-pause_do(int flag)
+wait_ready(void)
 {
-   if (writing) {
-   pause_flag = flag;
-   pause_pending = 1;
-   } else {
-   if (flag  !paused  !flushed) {
-   sio_stop(hdl);
-   sio_start(hdl);
-   rdpos = wrpos;
-   }
-   paused = flag;
+   int n;
+   struct pollfd pfds[16];
+
+   if (volume_pending) {
+   sio_setvol(hdl, volume * SIO_MAXVOL / 100);
+   volume_pending = 0;
+   }
+   if (flush_pending) {
+   reset();
+   flush_pending = 0;
+   }
+   if (pause_pending) {
+   if (paused)
+   reset();
pause_pending = 0;
}
-}
-
-static void
-flush_do(int time)
-{
-   if (writing) {
-   flush_time = time;
-   flush_pending = 1;

Re: audio/audacious unpausing by itself

2012-05-04 Thread Stefan Sperling
On Fri, May 04, 2012 at 10:07:48AM +0200, Alexandre Ratchov wrote:
 This is to update the plug-in to the newer 3.x plug-in semantics.
 This fixes the unpausing bug which afaiu was an effect of using
 the version 2.x plug-in with audacious version 3.x. This fixes
 other similar bugs as well (eg. crashes during volume changes).
 
 comments? ok?

Works fine here. Thanks!



Re: audio/audacious unpausing by itself

2012-05-04 Thread Stefan Sperling
On Fri, May 04, 2012 at 11:38:02AM +0200, David Coppa wrote:
 On Fri, May 4, 2012 at 11:33 AM, Stefan Sperling s...@openbsd.org wrote:
  On Fri, May 04, 2012 at 10:07:48AM +0200, Alexandre Ratchov wrote:
  This is to update the plug-in to the newer 3.x plug-in semantics.
  This fixes the unpausing bug which afaiu was an effect of using
  the version 2.x plug-in with audacious version 3.x. This fixes
  other similar bugs as well (eg. crashes during volume changes).
 
  comments? ok?
 
  Works fine here. Thanks!
 
 ok for me too!

While here we might as well update to 3.2.2.
The diff below includes ratchov's sndio tweaks unchanged.

Index: audacious/Makefile
===
RCS file: /cvs/ports/audio/audacious/Makefile,v
retrieving revision 1.33
diff -u -p -r1.33 Makefile
--- audacious/Makefile  21 Mar 2012 16:13:25 -  1.33
+++ audacious/Makefile  4 May 2012 10:07:44 -
@@ -4,14 +4,12 @@ SHARED_ONLY = Yes
 
 COMMENT =  gtk+3 media player based on BMP and XMMS
 
-DISTNAME = audacious-3.2
+DISTNAME = audacious-3.2.2
 
-REVISION = 0
-
-SHARED_LIBS =  audclient   2.0 # 2.0
-SHARED_LIBS += audcore 1.0 # 1.0
-SHARED_LIBS += audgui  1.0 # 1.0
-SHARED_LIBS += audtag  1.0 # 1.0
+SHARED_LIBS =  audclient   2.1 # 2.1
+SHARED_LIBS += audcore 1.1 # 1.1
+SHARED_LIBS += audgui  1.1 # 1.1
+SHARED_LIBS += audtag  1.1 # 1.1
 
 CATEGORIES =   audio multimedia
 
Index: audacious/distinfo
===
RCS file: /cvs/ports/audio/audacious/distinfo,v
retrieving revision 1.10
diff -u -p -r1.10 distinfo
--- audacious/distinfo  20 Mar 2012 19:10:18 -  1.10
+++ audacious/distinfo  4 May 2012 09:54:18 -
@@ -1,5 +1,5 @@
-MD5 (audacious-3.2.tar.bz2) = 6Wj+txKiKeK+AxWoVdHJbQ==
-RMD160 (audacious-3.2.tar.bz2) = JfBU7g6xG7dNO4/ncDjqQ4+T5gQ=
-SHA1 (audacious-3.2.tar.bz2) = PrxNzc9dqWC6QAB4Aj4WfgIQXoQ=
-SHA256 (audacious-3.2.tar.bz2) = 8Y0qKOjl/wbRUozb174R/B5ceGhyWKfFeijTa48pvLY=
-SIZE (audacious-3.2.tar.bz2) = 728063
+MD5 (audacious-3.2.2.tar.bz2) = KPHixoPTWEV+2b/ovMKewg==
+RMD160 (audacious-3.2.2.tar.bz2) = H2omhhNFXwe9IJ8EiKoPLbr3tbQ=
+SHA1 (audacious-3.2.2.tar.bz2) = UNLvCNPdSMLvsZSp/fIW+k+K/SQ=
+SHA256 (audacious-3.2.2.tar.bz2) = xpwg5Iwu0zCg/7VfOmSLUDI0BuKhXKQH4ykfg+VwQu4=
+SIZE (audacious-3.2.2.tar.bz2) = 675192
Index: audacious/patches/patch-src_audtool_Makefile
===
RCS file: audacious/patches/patch-src_audtool_Makefile
diff -N audacious/patches/patch-src_audtool_Makefile
--- audacious/patches/patch-src_audtool_Makefile20 Mar 2012 19:10:18 
-  1.2
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,12 +0,0 @@
-$OpenBSD: patch-src_audtool_Makefile,v 1.2 2012/03/20 19:10:18 stsp Exp $
-prevents linker error if audacious2 is already installed
 src/audtool/Makefile.orig  Sun Feb  5 19:47:56 2012
-+++ src/audtool/Makefile   Sun Feb  5 19:48:41 2012
-@@ -16,6 +16,4 @@ CPPFLAGS += -I.. -I../.. \
- ${DBUS_CFLAGS} \
- ${GTK_CFLAGS}
- 
--LIBS += ${DBUS_LIBS}  \
--  -L../libaudclient -laudclient   \
--  ${GTK_LIBS}
-+LIBS += -L../libaudclient -laudclient ${DBUS_LIBS} ${GTK_LIBS}
Index: audacious-plugins/Makefile
===
RCS file: /cvs/ports/audio/audacious-plugins/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- audacious-plugins/Makefile  6 Apr 2012 14:38:01 -   1.43
+++ audacious-plugins/Makefile  4 May 2012 09:57:29 -
@@ -4,9 +4,8 @@ SHARED_ONLY =   Yes
 
 COMMENT =  input and output plugins for audacious
 
-V =3.2
+V =3.2.2
 DISTNAME = audacious-plugins-$V
-REVISION = 2
 
 CATEGORIES =   audio multimedia
 
Index: audacious-plugins/distinfo
===
RCS file: /cvs/ports/audio/audacious-plugins/distinfo,v
retrieving revision 1.11
diff -u -p -r1.11 distinfo
--- audacious-plugins/distinfo  20 Mar 2012 19:10:56 -  1.11
+++ audacious-plugins/distinfo  4 May 2012 09:57:34 -
@@ -1,5 +1,5 @@
-MD5 (audacious-plugins-3.2.tar.bz2) = LfCxBb8GYvEW3i7L4MChBw==
-RMD160 (audacious-plugins-3.2.tar.bz2) = ldCPNFm13nnrD/9RI/SS3W3I3Jg=
-SHA1 (audacious-plugins-3.2.tar.bz2) = ScwKBf3e+LFzDwjQoL+eR5fNOT0=
-SHA256 (audacious-plugins-3.2.tar.bz2) = 
X2AL+AaL39MGtSMMMz9F1cAS3XFyinslD+g5lW7gmQQ=
-SIZE (audacious-plugins-3.2.tar.bz2) = 1978199
+MD5 (audacious-plugins-3.2.2.tar.bz2) = eq+K04mimDut291XIH4HJA==
+RMD160 (audacious-plugins-3.2.2.tar.bz2) = dsAnF3ggEk4+/sbq74fcWq1pkeo=
+SHA1 (audacious-plugins-3.2.2.tar.bz2) = 

Re: audio/audacious unpausing by itself

2012-05-04 Thread Stuart Henderson
On 2012/05/04 12:12, Stefan Sperling wrote:
 On Fri, May 04, 2012 at 11:38:02AM +0200, David Coppa wrote:
  On Fri, May 4, 2012 at 11:33 AM, Stefan Sperling s...@openbsd.org wrote:
   On Fri, May 04, 2012 at 10:07:48AM +0200, Alexandre Ratchov wrote:
   This is to update the plug-in to the newer 3.x plug-in semantics.
   This fixes the unpausing bug which afaiu was an effect of using
   the version 2.x plug-in with audacious version 3.x. This fixes
   other similar bugs as well (eg. crashes during volume changes).
  
   comments? ok?
  
   Works fine here. Thanks!
  
  ok for me too!
 
 While here we might as well update to 3.2.2.
 The diff below includes ratchov's sndio tweaks unchanged.

not using audacious here, but I'd like to request that the update
should be a separate commit, please.



Re: audio/audacious unpausing by itself

2012-05-04 Thread Stefan Sperling
On Fri, May 04, 2012 at 12:42:18PM +0100, Stuart Henderson wrote:
 not using audacious here, but I'd like to request that the update
 should be a separate commit, please.

Sure. I'll wait for ratchov to get his change in and then rebase
my update on top of it.



Re: audio/audacious unpausing by itself

2012-04-05 Thread Stefan Sperling
On Thu, Apr 05, 2012 at 09:53:40PM +0400, Alexander Polakov wrote:
 After updating audacious to 3.2 I have encountered
 a problem: I hit pause button and it stops playing,
 but some time passes and it starts playing without
 me doing a thing.
 
 Looks like the time before it starts is roughly 
 equal to the time from current time position to
 the end of the track. Like, if I hit pause on
 4:50 and the track's length is 5:00, the next track 
 starts playing in 10 seconds.
 
 Can anyone else confirm this?
 
 I'm running current on amd64.
 
 audacious 3.2p0

Yes, I can reproduce this. It happens with the sndio backend.
You can use the SDL audio backend as a workaround until this is fixed.