Difference between revisions of "ALSA, BTTV and MythTV 0.22"

From MythTV Official Wiki
Jump to: navigation, search
Line 1: Line 1:
 +
{{outdated}}
 
This page aims at documenting my backend setup and problems I had and solutions I found for setting it up with MythTV 0.22.
 
This page aims at documenting my backend setup and problems I had and solutions I found for setting it up with MythTV 0.22.
 
My setup includes an Intel E5300 CPU in an all-in-one board with Intel HDA audio and three bt878-based boards, one Prolink PixelView PV-BT878P+ (type 139) and two Jetway TV878-FB (type 78).
 
My setup includes an Intel E5300 CPU in an all-in-one board with Intel HDA audio and three bt878-based boards, one Prolink PixelView PV-BT878P+ (type 139) and two Jetway TV878-FB (type 78).

Revision as of 22:35, 16 November 2010

Time.png Outdated: The information on this page may no longer be relevant to the current release of MythTV, 34.0. Please consider helping to update it. This page was last modified on 2010-11-16.

This page aims at documenting my backend setup and problems I had and solutions I found for setting it up with MythTV 0.22. My setup includes an Intel E5300 CPU in an all-in-one board with Intel HDA audio and three bt878-based boards, one Prolink PixelView PV-BT878P+ (type 139) and two Jetway TV878-FB (type 78). The Jetway boards only output sound through the line-out jack, but the Prolink has a connection from the tuner to the bt878 chip, enabling sound capture with snd-bt87x. All boards output mono audio only.

Normally, I would have to connect cables from the line-out's of both Jetway cards to some soundcard for capture, but since I only had the motherboard's onboard soundcard, which could only record from a single source at a time, that wasn't possible. Also I didn't want cables on the outside of the case so I hacked a CD-ROM audio cable and soldered each of the audio wires (left/right) to one of the Jetway boards, right in the jack connector solder pads and connected the cable to the CD-ROM sound input on the motherboard.
Connecting BTTV card to motherboard CD audio in
With this operation I got audio from both Jetway boards coming in the CD input of the onboard soundboard, getting audio from one on the left channel and from the other on the right.

Then came the first problem: MythTV 0.22, as released, doesn't support sound capture from ALSA, only from OSS or MPEG2 streams. Thankfully, a patch for it exists and was applied after the 0.22 milestone, so future versions will support it, but for the time being the patch has to be manually applied and MythTV has to be built from source. Since that's explained elsewhere I won't do it here. After aplying the patch MythTV supports the ALSA:<device> notation as audio input for a capture card.

To be able to use the Jetway cards on MythTV I setup an /etc/asound.conf file with the following :

pcm.record_left {
       type dsnoop
       ipc_key 2049  # MUST MATCH RIGHT CHANNEL
       slave {
               pcm "hw:0,0"
               channels 2
       }
       bindings.0      0
       bindings.1      0
}
pcm.record_right {
       type dsnoop
       ipc_key 2049  # MUST MATCH LEFT CHANNEL
       slave {
               pcm "hw:0,0"
               channels 2
       }
       bindings.0      1
       bindings.1      1
}

All I had to do now was setup two capture cards on MythTV, one using /dev/video0 for video and ALSA:record_left for audio and the other using /dev/video1 and ALSA:record_right.

The third board can be used with the bttv ALSA audio driver, snd-bt87x, but I had to put 'load_all=1' in an option line for modprobing the driver, since the board isn't recognized. Then came another problem: although MythTV now supported ALSA capture, it just wouldn't do it from the snd-bt87x ALSA device. Everytime I tried to use the board for capture MythTV would error out about not being able to set the sample rate (wanted 48000, the driver reported 119466 sp/s), not being able to set the number of channels (wanted two, the driver only reported one) and some other errors. So finally I deciced to try the OSS layer and used the /dev/adsp3 device. That allowed audio capture from that card but with it came a high pitch background noise which made it very annoying to listen to the sound from the board.

So I had to try something else, so I added this to my asound.conf file :

pcm.record_bt878 {
       type plug
       slave {
               pcm "hw:3,1"
               channels 1
               rate 119466
       }
}

I then tried using arecord (an ALSA recording utility) to record audio from the card with the following command line :

arecord -d 10 -r 48000 -f S16_LE -c 2 -B 64000 -F 16000 -D record_bt878 input.wav

And it recorded ! So back to MythTV' source code, I compared the ALSA input code with arecord's code and found that some initializations were done differently. I changed MythTV's ALSA input code to match and finally got it to capture audio from record_bt878. So all that was left was creating the third card in MythTV setup, using /dev/video2 and ALSA:record_bt878.

The result of this setup is a machine able to record from all three cards simultaneously, with full PAL resolution, with 50 % usage on each CPU core. Not bad for 8-year old TV boards...

NOTE: Both patchs can be found in the myth-dev mailing list, posted in December 2009. NOTE 2: The patches got stuck in the moderator, so look for ticket #8361.