Ticket #195 (assigned bug)

Opened 3 months ago

Last modified 3 weeks ago

USB audio device with TOSLINK connection does not work

Reported by: arion Owned by: tokyovigilante
Priority: major Milestone: Version 0.5
Component: Core Version: unknown
Keywords: imac optical usb audio toslink Cc:

Description

First, a little back story: I've got a semi-recent iMac 24" that I'm using with XBMC. My initial goal was to have an optical audio cable hooked up to my stereo system for use via XBMC and to still use the internal iMac speakers for stuff like iChat, etc. However, I found that when you plug in an optical audio cable to the back of the iMac, the internal speakers are disabled. The iMac treats the headphones/optical audio jack and internal speakers as one device. The only solution I came up with (because I'm too lazy to keep unplugging my optical audio cable) was to get a USB audio device with a TOSLINK connector. I found this device which seemed to be the one recommended from Mac audiophiles:

http://www.edirol.net/products/en/UA-1X/

It works with Leopard and has lots of audio input/outputs (including a miniplug TOSLINK connector). I've verified that it works properly with VLC in the setup I want (VLC audio to USB device, all other audio to speakers). So, back to the bug. This device shows up on my Mac as "DIROL UA-1EX 44.1kHz". Here is the section from my "guisettings.xml" file listing the device:

<audiooutput>

<ac3passthrough>true</ac3passthrough> <audiodevice>EDIROL UA-1EX 44.1kHz</audiodevice> <dtspassthrough>true</dtspassthrough> <mode>1</mode> <passthroughdevice>S/PDIF</passthroughdevice>

</audiooutput>

However, I don't hear any audio when its selected. I browsed through the code and it looks like a simple fix to "CPortAudio.cpp" could be applied -- the current code explicitly looks for "Digital" or "S/P-DIF" in the name of the device, and the device I'm using has neither in its name.

p.s. For those interested, the USB audio device is available at J&R Music World for ~$80.

Attachments

xbmc0.5b2-EDIROL.zip (104.0 kB) - added by arion 2 months ago.
Log files for various EDIROL configurations and source material

Change History

Changed 2 months ago by leafmuncher

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to Version 0.5

Should be fixed in 0.5.0b2...I've done away with the passthroughdevice setting. Just make sure you select your USB device and pick "digital" mode, and you *should* be all set. Let me know how it works.

Changed 2 months ago by arion

  • status changed from closed to reopened
  • resolution deleted

0.5.0b2: Unfortunately, XBMC still isn't sending audio to my USB device.

My iMac's default audio device is configured as "Internal Speakers" within the "Sound" control panel. I have "DIROL UA-1EX 44.1kHz" selected in XBMC as the audio device under "Settings -> System -> Audio Hardware". It is configured as "Digital". I have an optical cable hooked up to my Yamaha AV receiver. When I start up XBMC, all sound still comes through my iMac's internal speakers. For comparison, inside of VLC I can use "Audio -> Audio Device -> DIROL UA-1EX 44.1kHz" to explicitly send audio to the USB device and this works as intended.

As a side note, if I change my default audio device to the EDIROL device within the "Sound" control panel or the "Audio MIDI Setup" tool, I do get sound from XBMC out of the EDIROL device. This works great, but kind of defeats the purpose of having separate audio devices, which was my original goal. Weird, eh?

Let me know if there is anything else I can do to help debug. I looked through "/var/log/xbmc.log" but didn't see anything pertinent about audio devices...

Changed 2 months ago by leafmuncher

The sound XBMC makes when starting up always plays to the default speakers, I think. Try playing a movie and see what happens, in both digital and analog modes.

Changed 2 months ago by arion

Ah, didn't realize that XBMC sounds would come out of the default device rather than the selected output device. I have been able to get some sounds out of the EDIROL device, but I've run into a bunch of scenarios that cause errors.

More background about the EDIROL device: it can be configured in "normal" or "advanced driver" mode (toggle switch on it). When in advanced mode, you can change some dip switches on the back to control the output rate (44.1k, 48k, etc.). Here's a table of what I've tried and what seems to work:

xbmc0.5b2-ADVMODE44.1k-audio-flac.log       sound
xbmc0.5b2-ADVMODE44.1k-audio-mp3.log        sound
xbmc0.5b2-ADVMODE44.1k-video-mkv-ac3.log    no sound
xbmc0.5b2-ADVMODE44.1k-video-avi-mp3.log    sound
xbmc0.5b2-ADVMODE48k-audio-flac.log         no sound
xbmc0.5b2-ADVMODE48k-audio-mp3.log          no sound
xbmc0.5b2-ADVMODE48k-video-mkv-ac3.log      no sound
xbmc0.5b2-ADVMODE48k-video-avi-mp3.log      sound
xbmc0.5b2-NORMALMODE-audio-flac.log         no sound
xbmc0.5b2-NORMALMODE-audio-mp3.log          no sound
xbmc0.5b2-NORMALMODE-video-mkv-ac3.log      no sound
xbmc0.5b2-NORMALMODE-video-avi-mp3.log      no sound

Attached is a ZIP file with all of these log files.

More info: all of the files I tried work properly using an optical cable hooked to the normal iMac jack. Also, VLC wasn't able to play the audio for the MKV file through the EDIROL device, but I'm not sure if that is a limitation of VLC or the EDIROL device.

Changed 2 months ago by arion

Log files for various EDIROL configurations and source material

Changed 5 weeks ago by tokyovigilante

  • status changed from reopened to closed
  • resolution set to worksforme

My Generic USB SPDIF box (with the same internal chipset as the EDIROL) works fine. Make sure the system output is set to 48000Khz in Audio Midi Setup, as this is required for encoded bitstreams (eg AC3) over SPDIF.

Changed 4 weeks ago by arion

  • status changed from closed to reopened
  • resolution deleted

Sound is working now in all video file types (.mkv, .avi, .etc.) and encodings (AC3, MP3, etc.). However, when configured for 48Khz, I can't play any files (FLAC or MP3) via paplayer:

18:52:34 T:2684702624 M:1935069184  NOTICE: Asked to create device:   [EDIROL UA-1EX 48kHz]
18:52:34 T:2684702624 M:1935036416  NOTICE: Device should be digital: [1]
18:52:34 T:2684702624 M:1935036416  NOTICE: Channels:                 [2]
18:52:34 T:2684702624 M:1935036416  NOTICE: Sample Rate:              [44100]
18:52:34 T:2684702624 M:1935003648  NOTICE: BitsPerSample:            [16]
18:52:34 T:2684702624 M:1935003648  NOTICE: PacketSize:               [3840]
18:52:34 T:2684702624 M:1935003648  NOTICE: Picked device:            [EDIROL UA-1EX 48kHz]
18:52:34 T:2684702624 M:1934204928   ERROR: [PortAudio] Error opening stream: -9997.
18:52:34 T:2684702624 M:1934192640   ERROR: [PortAudio] ERROR[/.../paplayer_osx.cpp:190]: Invalid stream pointer.

Is this simply an encoding mismatch (44.1khz vs. 48khz) or am I missing something? How does the build-in optical device on the Mac handle this, since it seems to work fine? Thanks!

Changed 4 weeks ago by leafmuncher

  • owner set to tokyovigilante
  • status changed from reopened to new

I think I see the problem here. It's asking the device to be digital, which means it'll disable sample rate conversion, and the device probably ONLY supports 48KHz. Not sure why paplayer would ask the device to be digital. Handing over to Ryan for the moment since he's an audio guru and actually has a USB device.

Changed 4 weeks ago by tokyovigilante

  • status changed from new to assigned

I can definitely take a look, but I must confess to have used paplayer a grand total of once.

Presumably it's a faulty assumption regarding digital devices and sample conversion, although in theory even if we want digital out, we should do conversion first, as you don't need a DAC step before converting.

This may take a back seat to me fixing/upgrading my recently deceased desktop, and the other AC3 bug we've been working on. Hang tight!

Changed 4 weeks ago by leafmuncher

Totally understood :-)

Changed 3 weeks ago by arion

Ryan, you mentioned that you have a different generic USB SPDIF box -- could you post a link to it (product page or online store)? I want to invest in another USB audio box for another Mac thats going to run OSXBMC :-) Thx!

Changed 3 weeks ago by tokyovigilante

Just a cheap one off eBay:

http://cgi.ebay.com/NEW-USB-to-SPDIF-OPTICAL-Adapter-UDA1321-CS8405A_W0QQitemZ180258810751QQihZ008QQcategoryZ3272QQssPageNameZWDVWQQrdZ1QQcmdZViewItem

However, the chips are widely used designs by Phillips and TI, so I don't think it's too shabby, I've certainly had no problems with mine.

Note: See TracTickets for help on using tickets.