Raspi+MIPS wrote: 
> Hi Paul,
> how do you figure out if a stream is playing? I'm also on a RasPi and
> very satisfied with SqueezeLite on the internal as well as with external
> DACs, so I spent some time to hook up a 433mhz transmitter to control rc
> power sockets to switch my speakers with the RasPi.
> Now I just need to know when to switch them on & off ... How do you
> figure out when squeezelite starts playing?
> TIA

I'm going to post my notes, as it is more informative than a diff.   You
will find references to a file gpio.c.   Which c source code to control
a cpio header is found on the Raspi site, I just modified that code to
be a function called relay(), rather than being a main source code.  
These hooks will do the following
*turn the relay off and on, based on the power button for the player in
LMS.  (Working for ASLA only)
*At the end of a playlist, there is a 300 second delay before turning
off the amp
*Starting a new playlist will turn the amp back on.
*Pausing a stream currently does nothing, although that would be easy to
add.  You will see how it hooks, and then you can just add to the
pause/unpause status.


Code:
--------------------
    
  Status Meanings
  STMu - End of Playlists
  STMd - End of Current Track Stream
  STMf - Fetch new Stream Connection
  STMo - Start Track Stream
  STMn - Open New Track Stream
  STMc - Stream Crossfade
  STMs - Start Stream
  STMt - WOrking
  STMp - Pause Stream
  STMr - Resume Stream
  
  
  Amplifier Idle - Auto Shutoff and Startup
  
  -------Makefile----------------
  add gpio.c to the sources line
  
  
  ------squeezelite.h---------------
  ---Add to end of file
  
  //gpio.c
  
  void relay( int state);
  
  //  my amp state
  int ampstate;
  
  
  
  -------output.c----------------
  
  ----in *output_thread
  ----below the if !!alsa_open-----just before start= true
  
  // Wake up amp
  ampstate = 1;
  relay(1);
  //                        sleep(500);  //   Give amp time to power up before 
allowing play
  
  
  ----just after the line if (output.state == OUTPUT_OFF
  
  //  Put Amp to Sleep
  ampstate = 0;
  relay(0);
  //                        sleep(50); // let amp power down before turning off 
analog out
  
  
  --------slimproto.c--------------
  ----Add in the global varialbes
  
  static u32_t ampidletime = 0;
  static int ampidle = 0;
  static int ampidle_set = 0;
  extern int ampstate;
  #define SLEEP_DELAY 300000
  
  ----In Function process_strm
  In Case u:   ampidle = 0;
  In Case s:   ampidle = 0;
  ---In Function slimproto_run
  ---at the beginning of the wake 100ms loop
  
  if ((ampstate == 1) && (ampidle_set == 0) && (ampidle == 1) && (now - 
ampidletime > SLEEP_DELAY) ){
  ampidle_set = 1;
  relay( 0);
  }
  if ( ampstate == 1 && ampidle_set == 1 && ampidle == 0){
  ampidletime = 0;
  ampidle_set = 0;
  relay( 1);
  }
  
  ----in the sentSTMu = true section
  
  ampidle = 1;
  ampidletime = now;
  
  -----in the sentSTMo = true section
  
  ampidle = 0;
  
  
--------------------


------------------------------------------------------------------------
paul-'s Profile: http://forums.slimdevices.com/member.php?userid=58858
View this thread: http://forums.slimdevices.com/showthread.php?t=97046

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to