Source:play() fails

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Source:play() fails

Post by _DaCoolOne_ »

Hello all!

Made a post a week or so ago, and have another question. A new bug has appeared in my game where some sources are not playing. After some debugging, I've traced the error back to the Source:play() itself. When called, source:play() returns false and does not start the audio. The weird thing is that it only does this for some sources and not for others (even though all sources are created and played the same way). My question is, what are some common reasons that this function can fail, and what can I do to combat the issue?

For reference, I'm on love 11.1 and my current system uses Source:clone() and Source:play() to run sources.

(Also sorry for lack of links to the wiki. I'm on mobile).

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Source:play() fails

Post by raidho36 »

There's a limit to how many sources can play at a time. See if you're hitting this limit.
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Re: Source:play() fails

Post by _DaCoolOne_ »

Hey, thanks for the reply!

Decided to go back and test, and I found that at the time of playing the source, using love.audio.getActiveSourceCount allowed a sound to be played with a source count as high as 61 active sources (for a "ui mouse over" sound). However, at the time of playing the source that was failing, this number was only at 1 - 2.

However, when I tested the source also played when I first opened the game after booting my computer, but hasn't played on any subsequent runs. So now I have no idea what's going on. :P
Last edited by _DaCoolOne_ on Wed Aug 14, 2019 11:12 am, edited 1 time in total.

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Re: Source:play() fails

Post by _DaCoolOne_ »

Also, for reference, I have attached the main script for the game with the audio manager.
Attachments
main.lua
(8.79 KiB) Downloaded 165 times

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Re: Source:play() fails

Post by _DaCoolOne_ »

Sorry about posting so much, but upon further testing I have noted something interesting with playing the source.

The first time I start my computer, the audio source will play just fine. However, it then won't play no matter how many times I restart the game. In other words, it looks like love2d has issues loading the source twice, even if I let it play the source all the way through. However, if I restart my computer then love2d will play the source exactly once, and then never again. Something weird is going on.

I also tried scanning and stopping any active sources in love.quit, but this doesn't appear to have fixed the issue. Not sure what's going on at this point.

Any thoughts are welcome! (Relevant code in above post)

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Re: Source:play() fails

Post by _DaCoolOne_ »

So I fixed my problem by just not cloning streamed sources. Most of the streamed stuff was voiced lines anyways, so I didn't need to have multiple of the same source playing, but I still find this bug weird. Any further thoughts appreciated. My issue is solved for now.

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Source:play() fails

Post by raidho36 »

Please file a bug report at the issue tracker.
User avatar
_DaCoolOne_
Prole
Posts: 16
Joined: Sat Mar 09, 2019 3:46 am

Re: Source:play() fails

Post by _DaCoolOne_ »

Done. Hope to see this fixed soon! :)

https://bitbucket.org/rude/love/issues/1508

Code: Select all

function not(val)
	if val == true then
		return false
	else
		return true
	end
end
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Source:play() fails

Post by Sasha264 »

Love 11.1 ? Hmm...
Here was some threads with audio problems, and slime recommended to try nightly build of Love 11.3, which contains some audio fixes.
I am not "authorized" to distribute nightly builds :o:, so here is the link to slime's post:
https://love2d.org/forums/viewtopic.php ... 02#p228502
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Source:play() fails

Post by raidho36 »

I don't think you need any authorization whatsoever to do whatever* you wish with LOVE.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 50 guests