Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
63 user(s) are online (53 user(s) are browsing Forums)

Members: 1
Guests: 62

Georg, more...

Support us!

Headlines

 
  Register To Post  

audio.device questions
Home away from home
Home away from home


See User information
@All

Do have some code from classic Amiga times which, while written in C, do use "audio.device". I do not know much about it, but as far as I remember, there were users saying that anything which use audio.device don't work for them (maybe it platform dependent?)

Also, those who use it on os4, do you have any issues with, like, crashes on exit when you're about to close device, etc. ?

And as last question, is there some easy way to rewrite usage of audio.device to something which will works fine everywhere, but without total rewrite to AHI or so: the code ? Or maybe there are already some "modern" audio.device which is not part of the OS ?

Or, if taken into account that it all was system friendly enough just replaced the audio.device on ahi.device in hope not many changes need it?


Edited by kas1e on 2022/12/14 17:51:05
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Just can't stay away
Just can't stay away


See User information
Seems audio.device uses /somehow) ahi:
...
#rexx:DepsTrack.rexx DEVS:audio.device
depstrack V0.3C por megacz@usa.com - rastrear dependencias en binarios

/// analizando 'DEVS:audio.device' (19152 bytes)...
/// mostrando dependencias...
=== expansion.library
=== dos.library
=== intuition.library
=== iffparse.library
=== ahi.device
/// encontradas 5 dependencias en 0,08 segs.


audio.device 53.3 (11-09-2014)

Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@kas1e

Sadly, 68K software is often avoiding api’s even when the software should be system friendly.

I expect, properly nothing wrong with audio.device, but instead code using DFF006 or CIAA/CIAB for timing, you can try running NallePuh or Ciaagent, to see if helps.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@LiveForIT
At lest for me, on x5000, audio.device somehow works. And even if i have this kind of code in the source:

volatile struct Custom *custom = (struct Custom *)0xdff000;
.....
custom->intreq INTF_AUD0|INTF_AUD1|INTF_AUD2|INTF_AUD3;


It still didn't crash and works. But this line is set only one time in the code, in all other places this “custom” didn't used, and everywhere is usual:

if ((audio_mp CreatePort (NULL0)) == NULL ||
      (
audio_io = (struct IOAudio *)AllocMem(sizeof(struct IOAudio),
                                             
MEMF_PUBLIC MEMF_CLEAR)) == NULL)


Etc. So i think that maybe pure replacing audio.device on ahi.device and their MP and IO may make it works without changes (or with very little ones).

Interesting, when we run code over audio.device, this "INTF_AUD0" probably just skipped ?


EDIT: seems not that easy: audio.device is operated with BeginIO() while ahi.device is with SendIO()/DoIO(). But that alone not the problem, problem is the difference in the request, for example how to replace those:

.
      
c->audio_io->ioa_Request.io_Flags ADIOF_PERVOL;
      
c->audio_io->ioa_Period period;
      
c->audio_io->ioa_Cycles 1;
      
c->audio_io->ioa_Request.io_Unit 2;


Probably some rewrite still need it..


Edited by kas1e on 2022/12/14 20:41:51
Edited by kas1e on 2022/12/14 20:42:15
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Not too shy to talk
Not too shy to talk


See User information
@kas1e

It depends on the use of the audio.device. Most programs, especially module players and games, simply open audio.device to allocate the audio in a friendly manner but then bang the hardware. This was common practise.

This also caused confusion when an OS4 audio.device appeared in the early days. People used audio.device apps but didn't hear a sound. This is because the OS4 audio.device provided the API but didn't emulate Paula. People assumed the existence of the audio.device meant audio software would work. No, the audio.device and Amiga audio are two different things.

There are two variants of audio.device. The Classic version and the AmigaOne version. The Classic version be a straight up OS4 port of the original. The AmigaOne version is a shim that is a wrapper for ahi.device. It works fine for playing audio since it just redirects CMD_WRITE calls to AHI. So can't be fixed in that regard, since it already works, as it's the programs that aren't using it to play audio.

The AmigaOne version also has a bug I found out this year. The ADCMD_LOCK is faulty. It just replies back straight away. This could affect software as it is a bug that violates known API. Though it shouldn't affect playback. Given they ported audio.device to AHI I don't understand how they messed this up. The code was right there, what did they do with it?

So, aside from the hard patching method you employed in the past, the only way at present for this to work is to use NallePUH.

https://www.os4coding.net/forum/can-ad ... -command-work-audiodevice

Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@Hypex
In my case, audio.device used properly with CMD_WRITE, and while I do hear all the sounds, it crashes for me on exit. So i just tried to understand why so..

Have a clue how to rewrite this code from audios.device to ahi.device usage ?

.
      
c->audio_io->ioa_Request.io_Message.mn_ReplyPort audio_mp
      
c->audio_io->ioa_Request.io_Flags ADIOF_PERVOL;
      
c->audio_io->ioa_Period period;
      
c->audio_io->ioa_Cycles 1;
      
c->audio_io->ioa_Request.io_Unit 2;


I just didn't see in the AHIRequest structure analogs of this fields' usage, as in audio.device.

Just do not want to rewrite everything in this… Especially i have hard times to rewrite this part of code to AHI:

*c->audio_io = *audio_io;
    
c->audio_io->ioa_Request.io_Message.mn_ReplyPort c->audio_mp;
    if ( 
== NUMCHANNELS )
        
c->audio_io->ioa_Request.io_Unit = (struct Unit *)15;
    else
        
c->audio_io->ioa_Request.io_Unit = (struct Unit *)(<< i);

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Quote:
In my case, audio.device used properly with CMD_WRITE, and while I do hear all the sounds, it crashes for me on exit. So i just tried to understand why so..


I wonder if it's because of ADCMD_LOCK? Maybe not. Do you have any equivalent C code that can replicate the crash?

Quote:
Have a clue how to rewrite this code from audios.device to ahi.device usage ?


Sure. It's similar in a way as it uses a duplicated IORequest for each channel but can use Unit to specify channel. So unit 2 would map to channel 1 which should be right. Unless you had an Amiga which was opposite to the other side of the world.

To do it for channels an IORequest needs duplicating for each extra channel after opening AHI. Then the period needs converting to frequency. After that it's setting volume and matching pan.

Set the clock:
if (GfxBase->DisplayFlags PAL)     clock=3546895L;        /* PAL clock */
else     clock=3579545L;        /* NTSC clock */


AHIio->ahir_Std.io_Command CMD_WRITE;
AHIio->ahir_Std.io_Length  BUFFERSIZE;  
AHIio->ahir_Std.io_Data    buffer;   
AHIio->ahir_Type           AHIST_M8S;   
AHIio->ahir_Frequency      clock/period;
AHIio->ahir_Std.io_Offset  0;    
AHIio->ahir_Volume          0x10000;          // Full volume
AHIio->ahir_Position        0x0;           // Right
AHIio->ahir_Link            NULL;

IExec->SendIO((struct IORequest *) AHIio);


Quote:
Just do not want to rewrite everything in this… Especially i have hard times to rewrite this part of code to AHI:


It maps unit to channel. Except for when mapping all channels that I don't get. Seems total channels, such as 4, is code for playing on all channels.

Wiki has more info. Except doesn't say how to play a sound. Only has a CMD_READ recording example. Doesn't fully explain how to play sound. Leaves it to example to fill in gaps. Also the closing code is strange. It uses AbortIO() without checking then does a WaitPort() and GetMsg(). Looks kludgy. Then example code uses normal WaitIO().

https://wiki.amigaos.net/wiki/AHI_Device

Go to top
Re: audio.device questions
Amigans Defender
Amigans Defender


See User information
@kas1e

I have no practical experience with audio.device, but based on reading the documentation I can see that ioa_Length takes a value in WORDS, while ahir_Std.io_Length takes a value in BYTES. So when transferring the code to AHI, you need to multiply the original code's ioa_Length by 2 to get the length for ahir_Std.io_Length.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@Trixie
Yep, thanks for notice

@Hypex
Quote:

Set the clock:
if (GfxBase->DisplayFlags & PAL) clock=3546895L; /* PAL clock */
else clock=3579545L; /* NTSC clock */


Wait, we about amigaos4, right ? I mean, WTF PAL/NTSC ?:) We can just write 44100, or any other. Or you mean to just reproduce exactly freq as it was on audio.device's code ? But anyway, PAL or NTSC giving the same 44100, so probably no needs for this code.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Not too shy to talk
Not too shy to talk


See User information
@Trixie

Yes I had forgot about that. As well as period and volume it's the same as the direct hardware. I always thought it was too close and should have used sample length and frequency in the API.

@kas1e

Quote:
Wait, we about amigaos4, right ? I mean, WTF PAL/NTSC ?:) We can just write 44100, or any other. Or you mean to just reproduce exactly freq as it was on audio.device's code ? But anyway, PAL or NTSC giving the same 44100, so probably no needs for this code.


Yes, that should still work, it should be set in OS. It's needed for period conversion if you have a Paula period. But for direct frequency you don't need to convert it.

Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@All
So rewrote from the audio.device to ahi.device, and while sound works, i do crash always on exit when call first time WaitIO call after AbortIO. The same as it was with the original code.

Original was like this for stopsnd():

.
        
AbortIO ((struct IORequest *)channel_info[handle].audio_io);
        
WaitPort (channel_info[handle].audio_mp);
        
GetMsg (channel_info[handle].audio_mp);


And there is my ahi.device one (without getmsg):

.
        
AbortIO ((struct IORequest *)channel_info[handle].audio_io);
        
WaitIO ((struct IORequest *)channel_info[handle].audio_io);


And it crashes in both cases on "Wait" line.

Now, what is interesting : if i replace in the code CreateMsgPort() on AllocSysObject() and CreateIORequest() on AllocSysObjectTags() i have no more crashes!

Is it pointing us to something ? Like forgotten wait() for something with original CreateIORequest() and CreateMsgPort() or forgotten signal send maybe ? IT surely shouldn't crash even with original-deprecated functions, and replacing them on allocsysobject() ones somehow auto-fix something..

It just looks like the original os3 code has some bug there which were just forgiving on OS3, but on OS4 not, and when i replace functions it just “auto fixes” buggy code.


Edited by kas1e on 2022/12/16 11:00:57
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@kas1e

you must do a SendIO(), before doing WaitIo(), or else you get the crash.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@LiveForIT
Of course, it is done in the main function right after filling audio.devie structure, those part i show is from "stopsound()".

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Not too shy to talk
Not too shy to talk


See User information
@kas1e

That's why I thought it was kludgy. It doesn't fully use device functions which is only the case for special cases like some audio.device functions and timer.device interrupts.

The proper way is to check and then wait on the IO. Of course IO has to be sent. If an IORequest was opened on a device and then never used then an IO check can hang.

if (!CheckIO ((struct IORequest *)channel_info[handle].audio_io))
{
        AbortIO ((struct IORequest *)channel_info[handle].audio_io);
}
WaitIO ((struct IORequest *)channel_info[handle].audio_io);


Edited by Hypex on 2022/12/17 2:33:40
Go to top
Re: audio.device questions
Home away from home
Home away from home


See User information
@hypex
Wait, you quote ahi.device variant (my one), but i ask about why their audio.device variant crashes : they don't have waitio, but instead waitport() ÷ getmsg() and was ok for os3. Yeah, os3 was forgiving for bugs, but which one ? I mean checkio can be added before abortio in their audio.device way, but is waitport and getmsg can be used after ?


There is original code:

Init:

BOOL Initvoid )
{
    
int i;
    
struct channel_info *c;
    
UBYTE chans[1];

  if ((
audio_mp CreatePort (NULL0)) == NULL ||
      (
audio_io = (struct IOAudio *)AllocMem(sizeof(struct IOAudio),
                                             
MEMF_PUBLIC MEMF_CLEAR)) == NULL)
  {
    
printf_special("InitSound: CreatePort() or AllocMem() failed\n");
    return 
FALSE;
  }

  
chans[0] = (<< NUMCHANNELS) - 1/* numchannels Amiga audio channels */

  
audio_io->ioa_Request.io_Message.mn_ReplyPort audio_mp;
  
audio_io->ioa_Request.io_Message.mn_Node.ln_Pri 127;
  
audio_io->ioa_AllocKey 0;
  
audio_io->ioa_Data chans;
  
audio_io->ioa_Length sizeof(chans);

  if (
OpenDevice (AUDIONAME0, (struct IORequest *)audio_io0) != 0)
  {
    
printf_special("InitSound: Could not open audio.device!\n");
    return 
FALSE;
  }
  
audio_is_open TRUE;

  for (
0< (NUMCHANNELS+1); i++)
  {
    
= &channel_info[i];
    
c->sound_in_progress FALSE;
    if ((
c->audio_mp CreatePort (NULL0)) == NULL ||
        (
c->audio_io = (struct IOAudio *)AllocMem(sizeof(struct IOAudio),
                                             
MEMF_PUBLIC MEMF_CLEAR)) == NULL)
    {
      
printf_special("InitSound: CreatePort() or AllocMem() failed\n");
      return 
FALSE;
    }
    *
c->audio_io = *audio_io;

    
c->audio_io->ioa_Request.io_Message.mn_ReplyPort c->audio_mp;
    if ( 
== NUMCHANNELS )
        
c->audio_io->ioa_Request.io_Unit = (struct Unit *)15;
    else
        
c->audio_io->ioa_Request.io_Unit = (struct Unit *)(<< i);
  }

        return 
TRUE;

}


PlaySound:

void PlaySNDUBYTEsampleint cnum )
{
  
struct channel_info *c;

  
= &channel_info[cnum];
  
  
c->audio_io->ioa_Request.io_Command CMD_WRITE;
  
c->audio_io->ioa_Request.io_Flags ADIOF_PERVOL;
  
c->audio_io->ioa_Data sample;
  
c->audio_io->ioa_Length 1470;
  
c->audio_io->ioa_Period 163;
  
c->audio_io->ioa_Volume 63;
  
c->audio_io->ioa_Cycles 0;

  if (
c->sound_in_progress) {
    
AbortIO ((struct IORequest *)c->audio_io);
  }

  
BeginIO ((struct IORequest *)c->audio_io);

  
c->sound_in_progress TRUE;
}


StopSound (added checkio() as well, didn't help):

void StopSNDint handle )
{
    if (!
audio_is_open) {
        return;
    }

    if (
channel_info[handle].sound_in_progress) {
        if (!
CheckIO((struct IORequest *)channel_info[handle].audio_io)) AbortIO((struct IORequest *)channel_info[handle].audio_io);
        
WaitPort (channel_info[handle].audio_mp);
        
GetMsg (channel_info[handle].audio_mp);
        
channel_info[handle].sound_in_progress FALSE;
    }
}


So it crashes on WaitPort as far as i can tell.


I of course can replace it all on ahi.device already, but i just need to know what wrong with this code that it was ok for os3, but didn't for os4 ?


Edited by kas1e on 2022/12/16 16:31:38
Edited by kas1e on 2022/12/16 16:32:04
Edited by kas1e on 2022/12/16 16:32:48
Edited by kas1e on 2022/12/16 17:05:23
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: audio.device questions
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Quote:
Wait, you quote ahi.device variant (my one), but i ask about why their audio.device variant crashes : they don't have waitio, but instead waitport() ÷ getmsg() and was ok for os3.


Oh, I thought that was your audio.device code that matches your last code, in my last post about Abort()()?

Quote:
Yeah, os3 was forgiving for bugs, but which one ? I mean checkio can be added before abortio in their audio.device way, but is waitport and getmsg can be used after ?


It maybe because of the audio.device design using WaitPort and GetMsg and might need to be done in the unconventional way.

Quote:
There is original code:

Init:


That code is old, it looks original. It predates OS2.

Quote:
PlaySound:


I see an issue here:
  if (c->sound_in_progress) {
    AbortIO ((struct IORequest *)c->audio_io);
  }
  
BeginIO ((struct IORequest *)c->audio_io);


It aborts but doesn't clear the request. So if sound is playing it aborts but doesn't pull the old request then adds another request. Looks like it's asking for trouble.

In audio.device speak I think it should be this:
  if (c->sound_in_progress) 
    AbortIO ((struct IORequest *)c->audio_io);
    WaitPort (channel_info[handle].audio_mp);
    GetMsg (channel_info[handle].audio_mp); 
 
  }
  
 BeginIO ((struct IORequest *)c->audio_io);


Quote:
So it crashes on WaitPort as far as i can tell.


Strange.

Quote:
I of course can replace it all on ahi.device already, but i just need to know what wrong with this code that it was ok for os3, but didn't for os4 ?


I wonder if it's the OS4 audio.device which has proven to be faulty?

Do you have a classic OS4 setup to also test? That audio.device should be a port of the original.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project