Failed To Allocate Audio Channel

Find quick help here to get you started with Hollywood
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Failed To Allocate Audio Channel

Post by oceanarts »

I don't think I've had this error before. (I've had to reinstall my Linux system because of some Nvidia issue, and this problem just manifested)
I have a single ambient music track playing continuously and a sample which triggers on MouseOver at various locations.
It's set up like this:

Code: Select all

@SAMPLE 1, "trm_select.wav"
@MUSIC 1, "trm_hum.wav"
PlayMusic(1, {Times = 0, Volume = Mst_Vol - Mus_Vol})
PlaySample(1, {Volume = Mst_Vol - Sfx_Vol})
Any ideas what could be wrong? I thought Hollywood handled this appropriately in the background.
Development System : Imac G5, MorphOs 3.19
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: Failed To Allocate Audio Channel

Post by Bugala »

Have you tried this on other platforms too, that does this only happen on Linux, or on others too?

I think error message should be different, but one possibility that comes to my mind is that if the sample is, are they called 32-bit samples or what? For Hollywood doesn't handle the most modern samples, but they need to be converted to lower version first. Lately getting sound libraries often require to convert the sounds first to lower versions for them to work in hollywood.
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Failed To Allocate Audio Channel

Post by oceanarts »

Seems I didn't include StopSample(x) later in the code.
But I honestly didn't think it would be needed as the sample in question was about half a second long (but I guess it's good practice in any case).
Does that mean that a channel isn't automatically freed when the sample has finished playing?
Development System : Imac G5, MorphOs 3.19
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Failed To Allocate Audio Channel

Post by oceanarts »

Well, actually StopSample doesn't solve anything.
The user might trigger that sample with their mouse multiple times, StopSample just abruptly stops it, as I guess it should.
I don't understand. I didn't have this problem before.
Development System : Imac G5, MorphOs 3.19
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: Failed To Allocate Audio Channel

Post by Bugala »

My guess, without seeing your code, is that you are triggering that PlaySample or PlayMusic so many times you run out of channels. Hollywood automatically chooses vacant channel for your newest "PlaySample", as long as one is available.

put "Debugprint("Playing Sample") right before that PlaySample and PlayMusic lines, and see how many times it prints that out.
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Failed To Allocate Audio Channel

Post by Flinx »

An "OpenResourceMonitor()" may help too.
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Failed To Allocate Audio Channel

Post by oceanarts »

Well, The ResourceMonitor didn't tell me much, but Hollywood crashes when the ninth instance of the sample is triggered which fits with the default eight channel limit. But that's still never happened before, and it's not counting the music sample playing continuously. Maybe there's something wrong with the sound system on this new Linux install? Is that possible?
Development System : Imac G5, MorphOs 3.19
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Failed To Allocate Audio Channel

Post by oceanarts »

So, I reinstalled Fedora which I used before I attempted Pop! OS (Ubuntu based) and the problem is no longer there.
Hollywood no longer crashes and the sample plays fine no matter how many times it is triggered.
I don't know what it was... A Pipewire issue, maybe?
Development System : Imac G5, MorphOs 3.19
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Failed To Allocate Audio Channel

Post by airsoftsoftwair »

oceanarts wrote: Sun Dec 15, 2024 6:42 pm So, I reinstalled Fedora which I used before I attempted Pop! OS (Ubuntu based) and the problem is no longer there.
Hollywood no longer crashes and the sample plays fine no matter how many times it is triggered.
I don't know what it was... A Pipewire issue, maybe?
Maybe, audio on Linux is a difficult thing and I've also seen buggy audio drivers. That being said, you must make sure there is a free channel before you start audio playback using PlaySample() or PlayMusic(). By default, Hollywood allocates 8 channels so if you call PlaySample() 9 times you'll get an error. If you don't want that, you could hard-code the channel for each audio playback by using the "Channel" tag of PlaySample() or PlayMusic(). From the manual:
"Channel": Channel to use for playback of this sample. By default, PlaySample() will automatically choose a vacant channel and will fail if there is no vacant channel. To override this behaviour, you can use this field. When specified, it will always enforce playback on the very channel specified here. If the channel is already playing, it will be stopped first.
If you hard-code the channel to use, there'll never be an error complaining about not enough free channels. But of course it means that if there's already something playing on the channel you specify, that previous playback will be stopped.
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Failed To Allocate Audio Channel

Post by oceanarts »

Thanks! I'll add that tag. :)
Development System : Imac G5, MorphOs 3.19
Post Reply