# Bughunting bluetooth audio



## Crivens (Dec 22, 2021)

patovm04 said:


> service hcsecd onestart


`# service hcsecd onestart
hcsecd does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable`



patovm04 said:


> service bluetooth start ubt0


`# service bluetooth start ubt0
bluetooth does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable`


This is how far I get. What is missing here?


----------



## VladiBG (Dec 22, 2021)

31.5. Bluetooth


----------



## Crivens (Dec 22, 2021)

VladiBG said:


> 31.5. Bluetooth


Still gives me
`# service bluetooth start ubt0
bluetooth does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable`


----------



## VladiBG (Dec 22, 2021)

do you have /etc/rc.d/bluetooth script? Also it must be 555 root:wheel permissions


----------



## Crivens (Dec 22, 2021)

No, that is not there. I'm running 
_FreeBSD Wanderer 13.0-RELEASE-p5 FreeBSD 13.0-RELEASE-p5 #23 releng/13.0-n244765-2646dd66590: Fri Dec  3 03:11:32 CET 2021_


----------



## VladiBG (Dec 22, 2021)

If you build from source check your src.conf(5) if it has without_bluetooth.


----------



## grahamperrin@ (Dec 23, 2021)

`2646dd66590` built from source, I assume <https://cgit.freebsd.org/src/commit/?h=releng/13.0&id=2646dd665909e60a369015c17cb602515e6025dc> (and not `GENERIC`), so can you think of anything that might have excluded what's required from your build?

src.conf(5) and so on.


```
% uname -iKU
GENERIC-NODEBUG 1400043 1400043
% file /etc/rc.d/bluetooth
/etc/rc.d/bluetooth: POSIX shell script, ASCII text executable
%
```


----------



## Crivens (Dec 23, 2021)

I had touched src.conf last time when I was still running 8.x, and lo and behold, the only line in there was the one about bluetooth.
Since this is the howto section (I didn't realize that in time), may I collapse all the posts and simply point out that this might be a problem?


----------



## VladiBG (Dec 23, 2021)

Or make a separate topic and move the posts there. 
I'm also curious what specific needs you have to build a custom kernel.


----------



## grahamperrin@ (Dec 23, 2021)

Maybe here for the src.conf discussion: 









						Share your make.conf and src.conf
					

Hello :)   It would be nice that experienced users shared their make.conf and src.conf to help new users like me :)  I know that there are man pages and I read both of them, but real user's configurations are IMHO also helpful!




					forums.freebsd.org


----------



## Crivens (Dec 23, 2021)

VladiBG said:


> Or make a separate topic and move the posts there.
> I'm also curious what specific needs you have to build a custom kernel.


Well, I did development of kernel drivers once, and now was asked to get the kernel module up and running on 13+ as the development had stopped on 8.x several years ago. I have almost all the time compiling world+kernel from releng, but stopped to do that to ports.


----------



## Crivens (Dec 25, 2021)

Oh, and today I recompiled a kernel without any sound support. You need to do that when you want to use the oss port instead of the kernel provided one. And I assume we have a regression somewhere, since the kernel provided one does not work with a headphone jack, plugging in a headphone does nothing as does setting the default unit. But I want to connect my stereo, so I tried to use a BT->Analog box for that so I could connect the stereo by bluetooth. That works with my phone, but not the laptop since the laptop sees all the headphones I tried it on but does not get the BT_Audio bridge I used for the stereo. This is most unfortunate, but switching to the oss port should enable me to simply connect the docking station to the 3.5 cable and be done with it.


----------



## grahamperrin@ (Dec 27, 2021)

Crivens said:


> … I assume we have a regression somewhere, since the kernel provided one



Still `13.0-RELEASE-p5`, yes?



Crivens said:


> does not work with a headphone jack, plugging in a headphone does nothing as does setting the default unit. …



Hmm. Rewind to 23rd December:



grahamperrin said:


> … I'm left with *no audio* – nothing from integral loudspeakers or the headset on USB, which is frustrating. …



No response there  so I restarted the OS.

I typically use GTK-Mixer to set the default unit.

Today, without me altering the default – external loudspeakers working with their jack plug to the _headphone_ socket, integral loudspeakers working (but barely audible) when I unplug:


```
% cat /dev/sndstat
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play)
pcm1: <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec) default
pcm2: <IDT 92HD81B1X (Analog)> (play/rec)
pcm3: <USB audio> (rec)
No devices installed from userspace.
%
```

(I never understood the difference between `pcm1` and `pcm2`.)

I wondered whether I might reproduce _no audio_ through setting the default to something other than `IDT 92HD81B1X (Analog 2.0+HP/2.0)`, then back. 

Brief use of `ATI R6xx (HDMI)` as the default (with sound audible through loudspeakers on a Philips display on DisplayPort) was followed by no problem with default use of `IDT 92HD81B1X (Analog 2.0+HP/2.0)` (sound audible, again, through external loudspeakers with the headphone socket of the notebook), i.e. not reproducible.



```
% pkg info -x audio/oss
pkg: No package(s) matching audio/oss
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #118 main-n251923-4bae154fe8c: Sat Dec 25 08:03:37 GMT 2021     root@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBU
G  amd64 1400045 1400045
%
```

Crivens please, how might you summarise the difference between sound.ko and audio/oss?


----------



## Alexander88207 (Dec 27, 2021)

FreeBSD sound system is an different implementation of OSS.

pkg-descr of audio/oss


> Not to be confused with sound(4) which is a different implementation with the same API.


----------



## grahamperrin@ (Dec 27, 2021)

Thanks, how might you summarise the differences between the two implementations?


----------



## Crivens (Dec 27, 2021)

The difference is as follows, according to my experience:
- pkg OSS: the switch between back/front works as expected, without any manual interaction.
- pkg OSS: Audio crackles
- onboard OSS: Switching needs manual setting of the sysctl, BEFORE the app is started. Switching a running stream is not possible.


----------



## grahamperrin@ (Dec 27, 2021)

Thanks, 



Crivens said:


> back/front



The back and front of what? 

I'll be interested in the port if it can somehow automatically switch to a USB headset, when I connect it; and automatically switch away when I disconnect. 



> - onboard OSS: … Switching a running stream is not possible.



Yep, with Firefox (for example) a switch must be followed by a reload of the tab to be played.


----------



## Crivens (Dec 27, 2021)

grahamperrin said:


> The back and front of what?


Front=internal speakers
Back=headphones


----------



## grahamperrin@ (Dec 31, 2021)

Crivens said:


> … kernel without any sound support. You need to do that when you want to use the oss port …



Can I edit /etc/src.conf to get a kernel with that characteristic?

Or must I edit /usr/src/sys/amd64/conf as directed below?

OSS/FreeBSD


----------



## Crivens (Dec 31, 2021)

No. You create a file "/root/MyKernel", and in that you write
`include            GENERIC
ident                MyKernel
nodevice          sound                   # Generic sound driver (required)
nodevice          snd_cmi                 # CMedia CMI8338/CMI8738
nodevice          snd_csa                 # Crystal Semiconductor CS461x/428x
nodevice          snd_emu10kx             # Creative SoundBlaster Live! and Audigy
nodevice          snd_es137x              # Ensoniq AudioPCI ES137x
nodevice          snd_hda                 # Intel High Definition Audio
nodevice          snd_ich                 # Intel, NVidia and other ICH AC'97 Audio
nodevice          snd_via8233             # VIA VT8233x Audio`
Then you create the symbolic link in /usr/src/sys/amd64/conf/MyKernel to your kernel and proceed then with
`make buildkernel KERNCONF=MyKernel`


----------



## grahamperrin@ (Dec 31, 2021)

Thanks, so the developers' wiki page is outdated, partially invalid?

Or is it (written at the time of FreeBSD 10) an approach that's still valid, but no longer preferred?


----------



## Crivens (Dec 31, 2021)

I don't know what is written there, but the developers are always right 

The benefit of this method is, you keep your config when you remove all of /usr/src for any reason. Maybe switching from svn to git, and then this "now, where was my fine tuned config?".
Also, you are now based on the normal GENERIC, so when GENERIC changes, adds new drivers f.e., you get them too. This makes things more smooth when you suddenly find vt./.sc conflicts for example.


----------



## grahamperrin@ (Dec 31, 2021)

Thanks! 



Crivens said:


> … when you remove all of /usr/src for any reason. …



By coincidence, I had a reason to remove all of nearby /usr/doc around the time of your reply.

I do see the benefit. I'm less likely to inadvertently destroy my own stuff through being scatterbrained. 

For reference: 



grahamperrin said:


> OSS/FreeBSD



– that's the developers' method.


----------

