Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Play all audio file types through bluez-alsa: possible? YES!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Fri Apr 13, 2018 11:34 am    Post subject: Play all audio file types through bluez-alsa: possible? YES! Reply with quote

Hi all.

I sometimes use and enjoy my Bluetooth speaker; it seems to accept only certain audio file types — it wouldn't play FLAC nor MP3, for instance and mplayer -ao alsa:device=bluealsa stalls playing these. But is it possible to play other or any type as well? Btw is ALSA not capable of transcoding an audio stream before sending it out? Transcoding with mplayer would also be an option though I'd rather play music with my usual tools (such as audacious).

Thanks in advance for any hint/suggestion.

EDIT: Yes, it's possible — at least I haven't yet come across a file type that I couldn't play that way. And thanks to Jocker16's hint!
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!


Last edited by VinzC on Tue Aug 21, 2018 5:53 pm; edited 2 times in total
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5934

PostPosted: Fri Apr 13, 2018 12:11 pm    Post subject: Reply with quote

i don't have the exact setup on hand, but it goes something like this:

~/.asoundrc

Code:
pcm.!default {
  playback.pcm "jblflip"
}

pcm.jblflip {
  type plug
  slave.pcm {
          type bluealsa
          device "00:11:DD:AA:66:FF"
          profile "a2dp"
  }
  hint {
          show on
          description "JBL Flip 2"
  }
}

_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Fri Apr 13, 2018 12:14 pm    Post subject: Reply with quote

Player decodes the audio and sends it to the playback device raw. Thus, it should have nothing to do with input file encoding, be it MP3, FLAC or something else. I suspect the problem is sampling rate. 41 kHz vs 48 kHz.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Fri Apr 13, 2018 12:25 pm    Post subject: Reply with quote

Jaglover wrote:
Player decodes the audio and sends it to the playback device raw. Thus, it should have nothing to do with input file encoding, be it MP3, FLAC or something else. I suspect the problem is sampling rate. 41 kHz vs 48 kHz.

Aha! Now that you're mentioning that, indeed all the files that I successfully played were @ 48kHz... Good tip, I'll try resampling and report!

EDIT: I just can't figure out how to have mplayer resample @48000 Hz *and* play through blue-alsa. Resampling alone seems to work
mplayer -srate 48000 'Musique/...':
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 57.89.100 (external)
AUDIO: 44100 Hz, 2 ch, s16le, 881.0 kbit/62.43% (ratio: 110119->176400)
Selected audio codec: [ffflac] afm: ffmpeg (FFmpeg FLAC audio)
==========================================================================
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
but not when I use blue-alsa as an output:
mplayer -srate 48000 -ao alsa:device=btheadset 'Musique/...':
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 57.89.100 (external)
AUDIO: 44100 Hz, 2 ch, s16le, 881.0 kbit/62.43% (ratio: 110119->176400)
Selected audio codec: [ffflac] afm: ffmpeg (FFmpeg FLAC audio)
==========================================================================


MPlayer interrupted by signal 2 in module: ao2_init

I had to press Ctrl+C. And putting -srate *after* -ao doesn't change anything. FTR here's my global asound.conf:
/etc/asound.conf:
# Bluetooth headset
defaults.bluealsa {
    interface "hci0"                    # host Bluetooth adapter
    device "XX:YY:ZZ:52:1E:AA"          # Radius Speaker MAC address
    profile "a2dp"
    # Doesn't seem to force resampling:
    rate 48000
}

pcm.btheadset {
    type plug
    slave.pcm {
        type bluealsa
        device "XX:YY:ZZ:52:1E:AA"
        profile "a2dp"
    }
    hint {
        show on
        description "Radius BT Speaker"
    }
}

_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sat Apr 14, 2018 9:06 am    Post subject: Reply with quote

Any idea?
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6639
Location: The soundosphere

PostPosted: Mon Apr 16, 2018 2:22 pm    Post subject: Reply with quote

If you can get audacious connected to blue-alsa, audacious has a resampling plugin.
_________________
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Tue Apr 17, 2018 8:29 pm    Post subject: Reply with quote

audiodef wrote:
If you can get audacious connected to blue-alsa, audacious has a resampling plugin.

I hadn't compiled audacious with that plugin. I did but it doesn't seem to work either: I set [which I assume is] the new sample rate to 48000 and I get an error message saying
Quote:
ALSA error: snd_pcm_open failed: No such file or directory.
Still no change, hence. Even worse, none of the tracks that used to work with audacious do play anymore, I get that very error message or the connection gets lost almost everytime :-( . Bummer...

EDIT: After a couple of unsuccessful attempts (stop/start Blueman, stop/start bluetooth, stop/start audacious, disconnect/reconnect with Radius Speaker, remove/add Radius Speaker...) it now... works!

Thanks for the hint anyway. At least I know it *can* do it!
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6639
Location: The soundosphere

PostPosted: Tue Apr 17, 2018 8:46 pm    Post subject: Reply with quote

Good. I will want to do this myself at some point on my new laptop. I can connect bluetooth devices, but I have yet to try to run audio through them.
_________________
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sun Apr 22, 2018 2:27 pm    Post subject: Reply with quote

audiodef wrote:
Good. I will want to do this myself at some point on my new laptop. I can connect bluetooth devices, but I have yet to try to run audio through them.

8)
Just note however that I still haven't found how to make mplayer (my player of choice) resample any audio file that I want to play through bluealsa. I'll report as soon as I find out.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Jocker16
n00b
n00b


Joined: 18 Sep 2010
Posts: 6

PostPosted: Thu Jul 26, 2018 6:23 am    Post subject: Reply with quote

I was suffering the same problem, here's the answer:
Code:
LIBASOUND_THREAD_SAFE=0 mplayer my_song.mp3


or export the environment variable, i.e.
Code:
export LIBASOUND_THREAD_SAFE=0
mplayer my_song.mp3


Found the solution here:
https://forum.armbian.com/topic/6480-bluealsa-bluetooth-audio-using-alsa-not-pulseaudio/
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Thu Aug 16, 2018 6:16 am    Post subject: Reply with quote

@Jocker16

Awesome 8) ! Thanks!

EDIT: And I'll add it works a treat! Yay! I've even added an alias to my .bashrc
Code:
alias btplay="LIBASOUND_THREAD_SAFE=0 mplayer -ao alsa:device=btheadset"

_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum