OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Hardware => Topic started by: Wim Brul on January 15, 2021, 12:21:38 pm

Title: USB Audio - Issues with some Devices
Post by: Wim Brul on January 15, 2021, 12:21:38 pm
Hi

Today I tried some USB audio input devices I have arround:
- Music Fairy USB 2.0‎‎ (https://www.os2world.com/wiki/index.php/Music_Fairy_USB_2.0): worked great with Lar's USBAUDIO.SYS. The chipset is the same as "Conceptronic CSOUNDU C08-041 USB Audio Stick"
- C-Media Electronics USB Mic (https://www.os2world.com/wiki/index.php/C-Media_Electronics_USB_Mic) (0D8C:013C). Did not work.
-  Karaoke USB Adapter (https://www.os2world.com/wiki/index.php/Karaoke_USB_Adapter) - Only audio Inputs -  This thing has a switch with two modes. Did not work.
-- 1) 046D:0A03  - Logitech USB Microphone  according to some sites)
-- 2) 1415:0000 - Sony SingStar USBMIC by Nam Tai E&E Products Ltd. or OmniVision Technologies, Inc.

I tested these devices with Wim's Audio Recorder.

REgards

Alas, for some reason, the cause of which is yet unknown to me, recording with microphone only USB audio devices does not work.
For me this is a known problem. I think it has to do with some flaw in the USB audio drivers, not with my Wim's Audio Recorder.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 03:00:42 pm
I think the flaw goes like this:
1) whatever the intention of the sound app, the audio device driver will always be requested with some "dummy" sound format (sample rate, num channels, bit depth) and to perform audio playback (and not record). The audio device driver is supposed to acknowledge the choice or give the next best alternative. Idiotic enough, the sound apps requirement will ultimatively be communicated to the sound driver once a stream is opened (for playback or recording), no matter what the device driver reported to this initial check request.

2) if the audio device driver cannot acknowledge the requested sound format, this will be ignored for the most part. But if it does not acknowledge the "playback" but instead reports that it can only do "record", then this is not ignored and the audio driver will never be opened with a stream.

Wim, I think not the audio device drivers need a fix but we rather need to add a hack to USBAUDIF.DLL to fake the caller of USBAUDIF.DLL that "playback" or at least "playback or record" was acknowledged instead of "record only". In the end, the caller will overrule this reporting anyway and will subsequently open the stream it needs (playback or record, whatever is intended by the sound app). The drawback of this solution is obvious: if a sound app requests playback but the device really is "record only", this will of course fail if the stream is finally created. However, the audio device drivers properly handle this error, and therefore, at least nothing will crash or break. You will just get an error in the sound app (which might be confusing if everything seemed to work initially).

This is all due to the lousy implementation of the multimedia subsystem as a whole. It's a mess.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 03:20:03 pm
Martin, I'll have quite some spare time in the next weeks. I'll try to fix it. But you will need to serve as the guinea pig for testing.
I currently have no usb audio device at all to test with.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 15, 2021, 03:41:33 pm
Martin, I'll have quite some spare time in the next weeks. I'll try to fix it. But you will need to serve as the guinea pig for testing.
I currently have no usb audio device at all to test with.

Hi Lars. I have no problem with that, just let me know and I will test what you told me.
By the way, I'm using AN USB 12.07 and I copied USBAUDIO.SYS and USBAUD2.SYS from your usbdrv237. Just in case.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 03:54:31 pm
My modifications will likely go against USBAUDIF.DLL. I have no clue if AN also delivers that. It's a customized version of AUDIOIF.DLL that was necessary to support the extended sampling rates and sound formats that the USB audio drivers support. The reason I did not modify AUDIOIF.DLL was that I did not want to modify stuff being in existance for decades, possibly breaking it for other audio drivers (like UNIAUD, which uses AUDIOIF.DLL).
Title: Re: USB Audio - Issues with some Devices
Post by: Wim Brul on January 15, 2021, 04:09:50 pm
Wim, I think not the audio device drivers need a fix but we rather need to add a hack to USBAUDIF.DLL to fake the caller of USBAUDIF.DLL that "playback" or at least "playback or record" was acknowledged instead of "record only". In the end, the caller will overrule this reporting anyway and will subsequently open the stream it needs (playback or record, whatever is intended by the sound app). The drawback of this solution is obvious: if a sound app requests playback but the device really is "record only", this will of course fail if the stream is finally created. However, the audio device drivers properly handle this error, and therefore, at least nothing will crash or break. You will just get an error in the sound app (which might be confusing if everything seemed to work initially).
Yes Lars, that thought crossed my mind too. I think you are right.

By the way, I'm using AN USB 12.07 and I copied USBAUDIO.SYS and USBAUD2.SYS from your usbdrv237. Just in case.
Hi Martin, I hope that you did not just copy those drivers. Proper deinstall/install using minstall /* must have been done.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 15, 2021, 06:58:13 pm
Hi

I slip these topic to only focus on what may I be doing wrong.

By the way, I'm using AN USB 12.07 and I copied USBAUDIO.SYS and USBAUD2.SYS from your usbdrv237. Just in case.
Hi Martin, I hope that you did not just copy those drivers. Proper deinstall/install using minstall /* must have been done.
....uhm... Yes. I did it the wrong way. I will reinstall USBAudio with dinstall and minstall and test again those devices.

Do you think that changing the USB Base drivers to Lar's USB will make a difference for these two Audio USB Devices to work? (0D8C:013C and 046D:0A03 / 1415:000 )

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 07:08:53 pm
No, it will not help. The problem is already identified. It needs to be fixed preferably in USBAUDIF.DLL. Or in the audio drivers which is less preferred because they are doing the right thing.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 15, 2021, 07:37:47 pm
Ok. Thanks !!
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 09:19:51 pm
It turned out that I had to change both: the audio drivers as well as USBAUDIF.DLL.
But the changes are limited to usbaudio.zip package. I now updated it. Sent to you.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 09:22:40 pm
Sorry, this was too premature. Need to do additional fixes.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 15, 2021, 09:43:49 pm
Martin, I cannot send this zip file to your email account. It refuses these attachments.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 16, 2021, 01:33:55 am
Hi Lars.

To send it to gmail try rename it from .zip to .piz and gmail will not scan it. Otherwise you can try uploading to the forum or using dropbox or something similar.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 16, 2021, 12:31:55 pm
just renaming the zip is NOT enough. I would have to rename EVERY file with a .DLL,.EXE,.SCR,.SYS extension inside the zip. I don't feel like doing so. Where do I upload in the forum ?
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 16, 2021, 12:33:18 pm
Ah, sorry, forgot. Here it is.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 16, 2021, 05:07:55 pm
Thanks Lars.

I had de-installed USBAudio with "minstall" first. Rebooted and installed your drivers with "minstall" again, all the 4 packaged included and rebooted. I'm using ArcaOS 5.0.6.

To test, first I tried the "HP Gaming Headset H320GS (https://www.os2world.com/wiki/index.php/HP_Gaming_Headset_H320GS)" which was working before and I confirmed it still records audio with its USB mic with DTAPE. With this I guess the USBAUDIO driver is installed correctly since it worked.

Now I tried the USB Mic first: C-Media Electronics USB Mic (0D8C:013C). It did not work.

First I tried a lsusb just to be sure it is recognized.
Code: [Select]
[X:\]lsusb
Bus 001 Device 001: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 002: ID 05c8:0317 Cheng Uei Precision Industry Co., Ltd (Foxlink)
Bus 001 Device 003: ID 147e:1002 Upek Biometric Touchchip/Touchstrip Fingerprint Sensor
Bus 001 Device 004: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller

Later I used DTAPE to test with the same settings that I used "HP Gaming Headset H320GS (https://www.os2world.com/wiki/index.php/HP_Gaming_Headset_H320GS)". The program gives me a "Hardware Error".

I also tried "Audio Recorder" and I got a similar hardware error.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 16, 2021, 07:18:57 pm
Try this.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 16, 2021, 07:44:19 pm
If it still does not work, I'd need you to activate tracing for major code 238.
How this is done is described in the readusb.txt. I would need a formatted trace. That will hopefully tell me enough about what is going wrong so that I can fix it.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 17, 2021, 02:26:40 am
Hi Lars

I followed the instructions.

- Added these on the config.sys.
Code: [Select]
TRACEBUF=2048 /M=W,Q,NODTI /D=ALL
TRACE=ON 238
- Rebooted, Attached the USB mic C-Media Electronics USB Mic (0D8C:013C).
- Executed DTAPE, produced the Hardware error twice
- Executed record.exe and produced the Hardware error twice
- Saved the .ftf file as formatted.

I hope it can give some hints.
Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 17, 2021, 12:47:33 pm
What sampling rate,num channels, bit depth did you select ? Did you indeed select record ?
Did you do the same as the screen shot you posted ?
I need to know this so that I know if the app request matches to what is requested from the driver or not.
As I said, the multimedia subsystem is a mess.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 17, 2021, 01:02:41 pm
ok, had a look at the trace.
I assume that you asked for recording in both cases (which I am pretty certain is true).
What I can see already is that the system insists on calling the driver for "playback" which of course is wrong and also, as we know, the device cannot do "playback". No wonder it returns with an error (even though it correctly reports back that it can do "record").

Can you do me a favor and repeat this, including tracing, with the original 10.237 driver set ? I just want to know where we started initially.

If I have this picture I hopefully can find a hackaround.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 17, 2021, 02:10:57 pm
Hi Lars

- On DTape I used. "Record Type -> PCM, 44100, 16bits, mono, microphone."
- For Audio Recorder I'm using "record /a2 /b16 /c1 /f44100".

I had tried back again with 10.237, I attach the trace.

What I did was:
- Boot, attach the mic, run lsusb to confirm it is attached.
- run Dtape - New  ->Record, get the error. I repeated the record again on to get the error a second time.
later
- Command line, and do "record /a2 /b16 /c1 /f44100", get the error. Repeat the command to get the error a second time.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 17, 2021, 06:29:04 pm
ok, that's why the very same error appears twice (you run it twice).
So for RECORD, I assume that /b16 /c1 /f44100 mean 44100 Hz, 16 bits, mono just like you use for DTAPE, correct ?

What does /a2 mean ?
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 17, 2021, 11:06:12 pm
ok, try attached. Also try with "playback + record" devices.
Take trace as you did before.
I ONLY updated USBAUDIO.SYS but not yet USBAUD2.SYS. Means, you need to test a audio class 1 device but I think you did. Make sure you do a full minstall as I had to update USBAUDIF.DLL along with the driver.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 17, 2021, 11:27:04 pm
Sorry, needed to update.
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 18, 2021, 01:59:13 am
and again.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 18, 2021, 03:48:11 am
Hi Lars

I tried your newer driver. The error on DTAPE and Record has changed.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 18, 2021, 09:32:38 am
That's actually a good sign as it gives me a better clue of where it goes wrong.
But please also send me trace. Screenshots help but don't give enough detail of why it goes wrong. But also send screenshots.

Can you please do me a favor and take a trace on recording with DTAPE and RECORD with the 10.237 drivers and a device that at least supports "playback" (in short: one that already worked in the past) ? I'll need to compare and see when and how it succeeds.

In order to not drive you nuts: for the time being it is sufficient to replace USBAUDIF.DLL, USBAUDIO.SYS, USBAUD2.SYS and reboot. Restore these files once you took the trace mentioned above.

You can also send to my private email address. I think you have that.
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 18, 2021, 03:20:33 pm
Hi Lars

I uploaded on my last message the "USBAudio-10-238-2021-01-17.ftf" file which has the new error with 10.238.

Here it is the 10.237 using the HP USB headphones that works with playback and recording the mic. Same test by recording a file with DTAPE and record.exe, and later reproduce it to test the playback.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Martin Iturbide on January 18, 2021, 03:24:08 pm
Hi again.

I thought that the best way will be to create a ticket on the USB Netlabs Trac.
I just created it: http://trac.netlabs.org/usb/ticket/92

But I just noticed that the upload size of files are limited to 256.0 KB. I'm not sure where to fix that on Trac and if is possible with my level access.

Regards
Title: Re: USB Audio - Issues with some Devices
Post by: Lars on January 18, 2021, 09:41:55 pm
ok, I moved over to the ticket. Please check. I'll continue updating the zip, you can then attach resulting trace.
As to file size: I cannot change it.
As to permissions: you are set as admin. This has been like this for a long time.