Welcome, Guest. Please login or register.
Amiga Kit Amiga Store Iridium Banner AMIStore App Store A600 Memory

AuthorTopic: audio streaming with AHI problem  (Read 223 times)

0 Members and 1 Guest are viewing this topic.

Offline DamageX

audio streaming with AHI problem
« on: July 16, 2019, 11:50:58 AM »
I created a message port, created two io request (set ahi parameters), and opened ahi device. Then I use sendio/checkio/waitio. However I can ONLY play 8-bit mono.
Code: [Select]
;AHIST_M8S EQU 0 ; Mono, 8 bit signed (BYTE)
;AHIST_M16S EQU 1 ; Mono, 16 bit signed (WORD)
;AHIST_S8S EQU 2 ; Stereo, 8 bit signed (2ラBYTE)
;AHIST_S16S EQU 3 ; Stereo, 16 bit signed (2ラWORD)
;AHIST_M32S EQU 8 ; Mono, 32 bit signed (LONG)
;AHIST_S32S EQU 10 ; Stereo, 32 bit signed (2ラLONG)
Type 0 is the only one that works. The other ones don't return an error but playback appears to freeze after one block, sometimes with a loop of garbage data continuing.

I did find that setting the "channels" to 2 under AHI prefs allowed playing two separate 8-bit streams, using four buffers. It's hard to believe that this is the only option for Paula??
 

Offline Thomas

Re: audio streaming with AHI problem
« Reply #1 on: July 16, 2019, 02:58:54 PM »

Well, there is not much information in your post. I can assure you that it works like described in the manual. For all given types.

The only possible issue I see in your description is how you create the second IO request. You say that you create two requests and then call OpenDevice. In fact you should create one request, then call OpenDevice and then create a copy of the request to get the second one.



Offline DamageX

Re: audio streaming with AHI problem
« Reply #2 on: July 17, 2019, 09:08:21 AM »
After calling opendevice I duplicate the first ioreq to the second by copying all 80 bytes. The address at offset $2C is then changed to point to the second buffer. After playback begins the link field at offset $4C is filled in, first for ioreq2 then ioreq1.

Is there a different way that it should be done?

With audio type other than 0 it seems to play two blocks and then stop. Then checkio always returns nonzero, and waitio returns 0.

If I set the audio type to an invalid value then I get error 3 as expected (at ioreq offset $1F).
 

Offline Thomas

Re: audio streaming with AHI problem
« Reply #3 on: July 17, 2019, 04:54:30 PM »
Is there a different way that it should be done?

No, that sounds quite right. You still didn't give much information. Maybe you should post some code, otherwise I can only guess.

You mention CheckIO. This is not needed actually. If you call SendIO you know that the request is currently playing. You can call WaitIO to wait for it to finish. Or, if you don't want to block your program while the sample is playing, you can add the message port's signal to your Wait() loop.

You still need to call WaitIO if you received the signal. It is important that every call to SendIO is complemented by a call to WaitIO before you reuse the IORequest.

The call series should be

read buffer1
send req1
read buffer2
send req2
wait for req1
read buffer1
send req1
wait for req2
read buffer2
send req2
wait for req1
and so on...

If you are able to read C code, I attached a working streaming example. It reads raw CDDA data from a file (that is 16bit stereo 44100 Hz big-endian) and streams it using AHI unit 0.

Offline DamageX

Re: audio streaming with AHI problem
« Reply #4 on: July 18, 2019, 04:37:13 AM »
Thanks for posting that source. I'm not very good with C but I did notice a couple of differences compared to my original code: you only used createiorequest once and then copied that to two separate memory buffers, and you wrote parameters to those ioreq structures EVERY time you called sendio.

I implemented these changes in my program and now I can play 8-bit stereo. Cheers!