Squeezelite + bluetooth + Crackle


3 posts
by castalla » Mon Feb 04, 2013 12:43 pm
Has anyone got any suggestions for solving this issue?

1. Using mpa's script to start & stop squeezelite process:

Code: Select all
#!/bin/bash
pid=0
address="00:15:71:14:E6:22"
squeezelite_started=false
while (sleep 1)
do
  if [[ $squeezelite_started == false ]] ; then
    connected=$(hcitool con) > /dev/null
    if [[ $connected =~ .*${address}.* ]] ; then
      squeezelite -m ab:cd:ef:12:34:56 -n Test -o TEST -r 44100&
      echo $! > /tmp/TEST_squeezelite.pid
      squeezelite_started=true
      echo $address connected started Squeezelite
    fi
  fi

  if [[ $squeezelite_started == true ]] ; then
    connected=$(hcitool con) > /dev/null
    if [[ ! $connected =~ .*${address}.* ]] ; then
      pid=$(cat /tmp/TEST_squeezelite.pid)
      kill -9 $pid
      rm /tmp/TEST_squeezelite.pid
      squeezelite_started=false
      echo $address disconnected stopped Squeezelite
    fi
  fi
done


2. This always produces severe crackling on sound output

3. If I just run squeezelite -m ab:cd:ef:12:34:56 -n Test -o TEST -r 44100& from the command line then the sound output is perfect.

TEST output is declared in asound.conf
Posts: 472
Joined: Thu Jul 19, 2012 3:46 pm
by castalla » Mon Feb 04, 2013 4:42 pm
I've eliminated the crackle by delaying the squeezelite start for 10 secs. after the bt connection is detected.

The bt disconnect kills squeezelite (as expected) HOWEVER when bt connects again then the next squeezelite process gives a segmentation fault.

Code: Select all
.
.
.ALSA lib audio/pcm_bluetooth.c:835:(bluetooth_playback_poll_revents) read error: Resource temporarily unavailable (11): Resource temporarily unavailable
ALSA lib audio/pcm_bluetooth.c:835:(bluetooth_playback_poll_revents) ./BLUETOOTH: line 28:  2747 Killed                  /usr/bin/squeezelite -m ab:cd:ef:12:34:56 -n Test -o TEST -r 96000
00:15:71:14:E6:22 disconnected stopped Squeezelite
00:15:71:14:E6:22 connected started Squeezelite
./BLUETOOTH: line 28:  2961 Segmentation fault      /usr/bin/squeezelite -m ab:cd:ef:12:34:56 -n Test -o TEST -r 96000
Posts: 472
Joined: Thu Jul 19, 2012 3:46 pm
by castalla » Mon Feb 04, 2013 10:51 pm
I've now got this working .... with squeezelite rc2

Using the following code with sleep inserted at 2 points.

Use your approriate variables (do not just copy & paste)

Code: Select all
#!/bin/bash
pid=0
address="00:15:71:14:E6:22"
squeezelite_started=false
while (sleep 1)
do
  if [[ $squeezelite_started == false ]] ; then
    connected=$(hcitool con) > /dev/null
    if [[ $connected =~ .*${address}.* ]] ; then
   sleep 10
      /usr/bin/squeezelite -m ab:cd:ef:12:34:56 -n Test -o TEST -r 96000 &
      echo $! > /tmp/TEST_squeezelite.pid
      squeezelite_started=true
      echo $address connected started Squeezelite
    fi
  fi

  if [[ $squeezelite_started == true ]] ; then
    connected=$(hcitool con) > /dev/null
    if [[ ! $connected =~ .*${address}.* ]] ; then
      pid=$(cat /tmp/TEST_squeezelite.pid)
   sleep 5
      kill -9 $pid
      rm /tmp/TEST_squeezelite.pid
      squeezelite_started=false
      echo $address disconnected stopped Squeezelite
    fi
  fi
done
Posts: 472
Joined: Thu Jul 19, 2012 3:46 pm