Author Topic: Help test..Solarus crashes during audio playing  (Read 3589 times)

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Help test..Solarus crashes during audio playing
« on: November 28, 2016, 08:40:51 pm »
About:
My script crashes Solarus when playing music. Everything is fine on the first page, but on the second page it crashes, but not always. Sometimes some of the music slots work and other times it just crashes. The script is almost done, but this is a problem...

I tried a variety of tests. It could be a Solarus bug, wine issue, or my script.

Crash in gif:


Demo Project Link:
Download

Jam Station Script:
Code: ( lua) [Select]
---------------------------------------------------------------------------------------------------------
--Tell the script it is a map and to use game functions
local game = ...

--A table because I like tables and it prevents upvalue errors
local jam = {
     
      y_pos = {},
      x_pos = {},
      y_font_pos = {},
      x_font_pos,
      y_pos_wheel = 0,
      scroll_distance,
      page_wheel_down_cal,
 
      bg = {},
      bg_hover = {},

      m_r_bg_img = sol.surface.create("jam_station/bg/M_R_bg.png"),
      text_bg_img = sol.surface.create("jam_station/bg/text_bg.png"),
      text_bg_hover_img = sol.surface.create("jam_station/bg/text_bg_hover.png"),
       
      scroll = {},

      scrolling_wheel_img = sol.surface.create("jam_station/scrollbar/scrolling_bar.png"),
      scroll_bar_arrows_img = sol.surface.create("jam_station/scrollbar/scroll_bg_bar_arrows.png"),

      volume ={},

      b_0_percent_img = sol.surface.create("jam_station/volume/0_percent.png"),
      b_25_percent_img = sol.surface.create("jam_station/volume/25_percent.png"),
      b_50_percent_img = sol.surface.create("jam_station/volume/50_percent.png"),
      b_75_percent_img = sol.surface.create("jam_station/volume/75_percent.png"),
      b_100_percent_img = sol.surface.create("jam_station/volume/100_percent.png"),
      percent_bg_img = sol.surface.create("jam_station/volume/percent_bg.png"),

      audio_slot_1 = {},
      audio_slot_2 = {},
      audio_slot_3 = {},
      audio_slot_4 = {},
      audio_slot_5 = {},
      audio_slot_6 = {},
      audio_slot_7 = {},
      audio_slot_8 = {},
      page = {},
      next = 0,
      audio_name = {},
      font,
      font_size,
      color_type,
      audio_text = {},
}

-----------------------
--CHANGE SETTINGS AREA:
-----------------------

--Number of text spots or slots
local text_num = 7

--Audio amount starting at 0, so 1 is actully 2 sorta
local audio_amount = 1

--Drawing basic images on stript start
jam.volume[1] = true
jam.volume[2] = true
jam.scroll[1] = true
jam.scroll[2] = true

--max distance the scroll wheel can go down
jam.scroll_distance = 344

--Divide the distance with pages
jam.page_wheel_down_cal = 1

--Change the font package
--Leave it nil to use the Solarus team made bitmap font. (At least in this demo or if you have it in your project.)
--name_list.font = nil
jam.font = "minecraftia"

--Change font size
jam.font_size = 12

--Change color. It was set to snow white (Not white 255,255,255, but snow white 255,250,250. Yeah, they are different.)
--Check in of script for some RGB color values.
jam.color_type = {188,143,143} --139,0,139

-----------------------------
--END OF CHANGE SETTINGS AREA
-----------------------------

function sol.main:on_draw(screen)

--Text properties and name string loading
for rep = 0,text_num do
     jam.audio_text[rep] = sol.text_surface.create({
      font = jam.font,
      text = jam.audio_name[rep],
      font_size = jam.font_size,
      color = jam.color_type,
    })
end

--Clear or reset 0-7
jam.audio_name = {}

--show this text on pae 1
if jam.page[0] == true then
jam.page[1] = false
jam.audio_name[0] = "Klgo Journey Path"
jam.audio_name[1] = "Beautiful Sadness"
jam.audio_name[2] = "Darkness"
jam.audio_name[3] = "Dark Void"
jam.audio_name[4] = "Dungeon Enemy of Blues"
jam.audio_name[5] = "Dungeon of Crepelody"
jam.audio_name[6] = "Klgo Journey Menu"
jam.audio_name[7] = "Mystic Flute"
end

--Show this text on page 2
if jam.page[1] == true then
jam.page[0] = false
jam.audio_name[0] = "Open Chest"
jam.audio_name[1] = "The Unknown Danger"
jam.audio_name[2] = "You are Chosen"
jam.audio_name[3] = "Bonus Piano"
jam.audio_name[4] = "Random sound effect_1"
jam.audio_name[5] = "Random sound effect_2"
jam.audio_name[6] = "Random sound effect_3"
jam.audio_name[7] = "Random sound effect_4"
end

--Testing
print("0 is",jam.audio_name[0])
print("0 is",jam.audio_name[1])
print("0 is",jam.audio_name[2])
print("0 is",jam.audio_name[3])
print("0 is",jam.audio_name[4])
print("0 is",jam.audio_name[5])
print("0 is",jam.audio_name[6])
print("0 is",jam.audio_name[7])

--Background image
  if jam.bg[1] == true then
    jam.m_r_bg_img:draw(screen)
  end

--Text, hover slot image, and background slot images
for i = 0,text_num do
  if jam.bg[2] == true then
    jam.text_bg_img:draw(screen, jam.x_pos[i], jam.y_pos[i])
    jam.audio_text[i]:draw(screen,jam.x_font_pos,jam.y_font_pos[i])
  end
end

for i = 0,text_num do
  if jam.bg_hover[i] == true then
    jam.text_bg_hover_img:draw(screen, jam.x_pos[i], jam.y_pos[i])
    jam.audio_text[i]:draw(screen,jam.x_font_pos,jam.y_font_pos[i])
  end
end

--Scroll bar
  if jam.scroll[1] == true then
    jam.scroll_bar_arrows_img:draw(screen)
  end

  if jam.scroll[2] == true then
    jam.scrolling_wheel_img:draw(screen,0,jam.y_pos_wheel)
  end

--Volume images
  if jam.volume[1] == true then
    jam.percent_bg_img:draw(screen)
  end

  if jam.volume[2] == true then
    jam.b_100_percent_img:draw(screen)
  end

  if jam.volume[3] == true then
    jam.b_75_percent_img:draw(screen)
  end

  if jam.volume[4] == true then
    jam.b_50_percent_img:draw(screen)
  end

  if jam.volume[5] == true then
    jam.b_25_percent_img:draw(screen)
  end

  if jam.volume[6] == true then
    jam.b_0_percent_img:draw(screen)
  end

--Page is true or false depending on up or down arrows.
for rep = 0, audio_amount do
  if jam.next == rep then
    jam.page[rep + 1] = false
    jam.page[rep] = true
    jam.page[rep - 1] = false
  end
end

end --end of draw function

--Image and text coordinate changes and drawing background or UI mostly
 for i = 0,text_num do
   jam.bg[i] = true
   jam.x_pos[i] = 0
   jam.y_pos[i] = i * 50

   jam.x_font_pos = 150
   jam.y_font_pos[i] = i * 50 + 50
 end

function sol.main:on_key_pressed(key)
---will be used to close everything
end--end of key press function

function sol.main:on_mouse_pressed(button,x,y)

--Volume control
--volume 100%
  if button == "left" then
    if (x > 466 and x < 492) and (y > 61 and y < 134) then
      print("left pressed")
      jam.volume[1] = true
      jam.volume[2] = true
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(100)
    end
--volume 75%
    if (x > 466 and x < 492) and (y > 135 and y < 246) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = true
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(75)
    end
--volume 50%
    if (x > 466 and x < 492) and (y > 247 and y < 360) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = true
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(50)
    end
--volume 25%
    if (x > 466 and x < 492) and (y > 360 and y < 430) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = true
      jam.volume[6] = false
      sol.audio.set_music_volume(25)
    end
--volume 0%
    if (x > 466 and x < 492) and (y > 431 and y < 451) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = true
      sol.audio.set_music_volume(0)
    end

--Up arrow
    if (x > 437 and x < 458) and (y > 18 and y < 40) then
      print("up pressed")
--Distance calculations for the scroll wheel
      if jam.y_pos_wheel > 0 then
        jam.y_pos_wheel = jam.y_pos_wheel - jam.scroll_distance/jam.page_wheel_down_cal
--Calculations for the page
        jam.next = jam.next - 1
      end
    end
--down arrow
    if (x > 437 and x < 458) and (y > 441 and y < 463) then
      print("down pressed")
--Distance calculations for the scroll wheel
      if jam.y_pos_wheel <= jam.scroll_distance then
        jam.y_pos_wheel = jam.y_pos_wheel + jam.scroll_distance/jam.page_wheel_down_cal
--Calculations for the page
        jam.next = jam.next + 1
--Sets the image for the scroll wheel. Do not want it to go off the screen.
        if jam.y_pos_wheel > 344 then
          jam.y_pos_wheel = 344
        end
      end
    end

for rep = 0, audio_amount do
--Pages
 if jam.page[rep] == true then
--spot 1
    if (x > 133 and x < 425) and (y > 41 and y < 69) then
--Slots true or false depending on the page
      jam.audio_slot_1[rep + 1] = false
      jam.audio_slot_1[rep] = true
      jam.audio_slot_1[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_1[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
      end
--Hover image true
      jam.bg_hover[0] = true
    else
--Hover image false
      jam.bg_hover[0] = false
    end

--spot 2
    if (x > 133 and x < 425) and (y > 91 and y < 119) then
--Slots true or false depending on the page
      jam.audio_slot_2[rep + 1] = false
      jam.audio_slot_2[rep] = true
      jam.audio_slot_2[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_2[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_2/"..rep)
      end
--Hover image true
      jam.bg_hover[1] = true
    else
--Hover image false
      jam.bg_hover[1] = false
    end

--spot 3
    if (x > 133 and x < 425) and (y > 141 and y < 171) then
--Slots true or false depending on the page
      jam.audio_slot_3[rep + 1] = false
      jam.audio_slot_3[rep] = true
      jam.audio_slot_3[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_3[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_3/"..rep)
      end
--Hover image true
      jam.bg_hover[2] = true
    else
--Hover image false
      jam.bg_hover[2] = false
    end

--spot 4
    if (x > 133 and x < 425) and (y > 191 and y < 220) then
--Slots true or false depending on the page
      jam.audio_slot_4[rep + 1] = false
      jam.audio_slot_4[rep] = true
      jam.audio_slot_4[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_4[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_4/"..rep)
      end
--Hover image true
      jam.bg_hover[3] = true
    else
--Hover image false
      jam.bg_hover[3] = false
    end

--spot 5
    if (x > 133 and x < 425) and (y > 241 and y < 270) then
--Slots true or false depending on the page
      jam.audio_slot_5[rep + 1] = false
      jam.audio_slot_5[rep] = true
      jam.audio_slot_5[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_5[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_5/"..rep)
      end
--Hover image true
      jam.bg_hover[4] = true
    else
--Hover image false
      jam.bg_hover[4] = false
    end

--spot 6
    if (x > 133 and x < 425) and (y > 291 and y < 320) then
--Slots true or false depending on the page
      jam.audio_slot_6[rep + 1] = false
      jam.audio_slot_6[rep] = true
      jam.audio_slot_6[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_6[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_6/"..rep)
      end
--Hover image true
      jam.bg_hover[5] = true
    else
--Hover image false
      jam.bg_hover[5] = false
    end

--spot 7
    if (x > 133 and x < 425) and (y > 342 and y < 368) then
--Slots true or false depending on the page
      jam.audio_slot_7[rep + 1] = false
      jam.audio_slot_7[rep] = true
      jam.audio_slot_7[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_7[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_7/"..rep)
      end
--Hover image true
      jam.bg_hover[6] = true
    else
--Hover image false
      jam.bg_hover[6] = false
    end

--spot 8
    if (x > 133 and x < 425) and (y > 391 and y < 419) then
--Slots true or false depending on the page
      jam.audio_slot_8[rep + 1] = false
      jam.audio_slot_8[rep] = true
      jam.audio_slot_8[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_8[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_8/"..rep)
      end
--Hover image true
      jam.bg_hover[7] = true
    else
--Hover image false
      jam.bg_hover[7] = false
    end
  end -- end of if left button
 end-- end of page
end -- end of for loop
end -- end of mouse press function

Diarandor

  • Hero Member
  • *****
  • Posts: 1053
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Help test..Solarus crashes during audio playing
« Reply #1 on: November 29, 2016, 02:02:28 am »
You should not create those surfaces in the on_draw event. On the one hand, you are creating them each time the event is called, which is probably unnecessary and may slow down the game. On the other hand, on_draw is not always called, so it might happen that your surface is not created and get an error or crash when you try to access it from other function.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: Help test..Solarus crashes during audio playing
« Reply #2 on: November 29, 2016, 02:32:43 am »
You should not create those surfaces in the on_draw event. On the one hand, you are creating them each time the event is called, which is probably unnecessary and may slow down the game. On the other hand, on_draw is not always called, so it might happen that your surface is not created and get an error or crash when you try to access it from other function.

1. This is not the case. The same error occurs.

2. The error does not involve Wine. I tried it in my Windows 7 OS and the same error occurred.

3. I also tried tests with sol.audio.play_music("none"), but this made no difference.

4. I played the music with sol.audio.play_sound() and no crashed occurred. Sadly, I cannot stop sound with sol.audio.play_sound(), so I have a bunch of music playing at the same time.

I think it is a bug in the engine. I would think sol.audio.play_sound() would make the same crash. Kinda difficult to pinpoint the problem, but there are only few differences between sol.audio.play_sound() and sol.audio.play_music(). sol.audio.play_music() stops audio after another audio file is played and maybe that becomes overloaded somehow.


froggy77

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Help test..Solarus crashes during audio playing
« Reply #4 on: November 29, 2016, 10:31:35 pm »
Zefk, I tested your project and when I started it, it did not look like your gif image.
Quote
You should not create those surfaces in the on_draw event.
Diarandor +1
- Message at the beginning: "Warning: Cannot use quest size 320x240: this quest only supports 640x480 to 640x480. Using 640x480 instead."
- The entire menu, text, and buttons are offset.
- Clicking everywhere changes the music.
- And sometimes, "Fatal: Failed to create software surface" crashes Solarus.
- See attachment file.


« Last Edit: November 29, 2016, 10:37:45 pm by froggy77 »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Help test..Solarus crashes during audio playing
« Reply #5 on: November 29, 2016, 11:38:59 pm »
Creating surfaces at each frame is a very bad idea yes.
Solarus 1.5.1 (released just a few minutes ago!) fixes a memory leak with them, and it should be much harder to get such a crash now. (But it is still a very bad idea :))

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: Help test..Solarus crashes during audio playing
« Reply #6 on: November 30, 2016, 05:50:27 am »
Zefk, I tested your project and when I started it, it did not look like your gif image.

@froggy
None of the surfaces vanish during playtest in the Solarus editor and I get no such warning.

Quote
1. Message at the beginning: "Warning: Cannot use quest size 320x240: this quest only supports 640x480 to 640x480. Using 640x480 instead."
That is normal. I wanted this.



Quote
-The entire menu, text, and buttons are offset.
That does not happen to me in the editor during playtest.

Quote
-Clicking everywhere changes the music.
- And sometimes, "Fatal: Failed to create software surface" crashes Solarus.
Those do not happen to me either in the editor during playtest.

Edit:
Quote
-Clicking everywhere changes the music.
Not everywhere, but only on the slot locations. I am not sure which you meant. I have to add a true/false, so the audio does not play before the jam station is activated.



Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: Help test..Solarus crashes during audio playing
« Reply #7 on: November 30, 2016, 06:22:35 am »
Quote
Solarus 1.5.1 (released just a few minutes ago!) fixes a memory leak with them,
@Christopho
The crash does not happen much with the new version, but I still do not understand why others are getting different error outputs and results..... Does it have to do with Windows operating system versions? I get a total crash and froggy got a surface error? Also, I get no crash with sol.audio.play_sound(), but I do with sol.audio.play_music(). I am totally confused.

llamazing

  • Full Member
  • ***
  • Posts: 201
    • View Profile
Re: Help test..Solarus crashes during audio playing
« Reply #8 on: November 30, 2016, 07:47:04 am »
You should not create those surfaces in the on_draw event. On the one hand, you are creating them each time the event is called, which is probably unnecessary and may slow down the game. On the other hand, on_draw is not always called, so it might happen that your surface is not created and get an error or crash when you try to access it from other function.

Listen to what Diarandor is telling you. Just because version 1.5.1 mitigates the issue is no excuse to not fix the script. Re-creating all of your surfaces over and over again a hundred times per second is going to have unpredictable results.

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: Help test..Solarus crashes during audio playing
« Reply #9 on: November 30, 2016, 08:27:29 am »
You should not create those surfaces in the on_draw event. On the one hand, you are creating them each time the event is called, which is probably unnecessary and may slow down the game. On the other hand, on_draw is not always called, so it might happen that your surface is not created and get an error or crash when you try to access it from other function.

Listen to what Diarandor is telling you. Just because version 1.5.1 mitigates the issue is no excuse to not fix the script. Re-creating all of your surfaces over and over again a hundred times per second is going to have unpredictable results.

Okay, so I just completely deleted the draw function and when clicking for the audio. it still crashes on the second page. This means the issue has nothing to do with the draw function.

The problem is the mouse press function. I believe the array in there for the sounds is causing the problem.  Also, I get no crash with sol.audio.play_sound(), but I do with sol.audio.play_music() as I mentioned before. That is obviously weird! This is why I reported it as a music bug.

Array start area:
Code: ( lua) [Select]
for rep = 0, audio_amount do
--Pages
--Page is true or false depending on up or down arrows.
  if jam.next == rep then
    jam.page[rep + 1] = false
    jam.page[rep] = true
    jam.page[rep - 1] = false
  end
 if jam.page[rep] == true then
--spot 1
    if (x > 133 and x < 425) and (y > 41 and y < 69) then
--Slots true or false depending on the page
      jam.audio_slot_1[rep + 1] = false
      jam.audio_slot_1[rep] = true
      jam.audio_slot_1[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_1[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
      end
--Hover image true
      jam.bg_hover[0] = true
    else
--Hover image false
      jam.bg_hover[0] = false
    end

All of the mouse function:
Code: ( lua) [Select]
function sol.main:on_mouse_pressed(button,x,y)

--Volume control
--volume 100%
  if button == "left" then
    if (x > 466 and x < 492) and (y > 61 and y < 134) then
      print("left pressed")
      jam.volume[1] = true
      jam.volume[2] = true
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(100)
    end
--volume 75%
    if (x > 466 and x < 492) and (y > 135 and y < 246) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = true
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(75)
    end
--volume 50%
    if (x > 466 and x < 492) and (y > 247 and y < 360) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = true
      jam.volume[5] = false
      jam.volume[6] = false
      sol.audio.set_music_volume(50)
    end
--volume 25%
    if (x > 466 and x < 492) and (y > 360 and y < 430) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = true
      jam.volume[6] = false
      sol.audio.set_music_volume(25)
    end
--volume 0%
    if (x > 466 and x < 492) and (y > 431 and y < 451) then
      print("left pressed")
      jam.volume[2] = false
      jam.volume[3] = false
      jam.volume[4] = false
      jam.volume[5] = false
      jam.volume[6] = true
      sol.audio.set_music_volume(0)
    end

--Up arrow
    if (x > 437 and x < 458) and (y > 18 and y < 40) then
      print("up pressed")
--Distance calculations for the scroll wheel
      if jam.y_pos_wheel > 0 then
        jam.y_pos_wheel = jam.y_pos_wheel - jam.scroll_distance/jam.page_wheel_down_cal
--Calculations for the page
        jam.next = jam.next - 1
      end
    end
--down arrow
    if (x > 437 and x < 458) and (y > 441 and y < 463) then
      print("down pressed")
--Distance calculations for the scroll wheel
      if jam.y_pos_wheel <= jam.scroll_distance then
        jam.y_pos_wheel = jam.y_pos_wheel + jam.scroll_distance/jam.page_wheel_down_cal
--Calculations for the page
        jam.next = jam.next + 1
--Sets the image for the scroll wheel. Do not want it to go off the screen.
        if jam.y_pos_wheel > 344 then
          jam.y_pos_wheel = 344
        end
      end
    end

for rep = 0, audio_amount do
--Pages
--Page is true or false depending on up or down arrows.
  if jam.next == rep then
    jam.page[rep + 1] = false
    jam.page[rep] = true
    jam.page[rep - 1] = false
  end
 if jam.page[rep] == true then
--spot 1
    if (x > 133 and x < 425) and (y > 41 and y < 69) then
--Slots true or false depending on the page
      jam.audio_slot_1[rep + 1] = false
      jam.audio_slot_1[rep] = true
      jam.audio_slot_1[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_1[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
      end
--Hover image true
      jam.bg_hover[0] = true
    else
--Hover image false
      jam.bg_hover[0] = false
    end

--spot 2
    if (x > 133 and x < 425) and (y > 91 and y < 119) then
--Slots true or false depending on the page
      jam.audio_slot_2[rep + 1] = false
      jam.audio_slot_2[rep] = true
      jam.audio_slot_2[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_2[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_2/"..rep)
      end
--Hover image true
      jam.bg_hover[1] = true
    else
--Hover image false
      jam.bg_hover[1] = false
    end

--spot 3
    if (x > 133 and x < 425) and (y > 141 and y < 171) then
--Slots true or false depending on the page
      jam.audio_slot_3[rep + 1] = false
      jam.audio_slot_3[rep] = true
      jam.audio_slot_3[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_3[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_3/"..rep)
      end
--Hover image true
      jam.bg_hover[2] = true
    else
--Hover image false
      jam.bg_hover[2] = false
    end

--spot 4
    if (x > 133 and x < 425) and (y > 191 and y < 220) then
--Slots true or false depending on the page
      jam.audio_slot_4[rep + 1] = false
      jam.audio_slot_4[rep] = true
      jam.audio_slot_4[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_4[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_4/"..rep)
      end
--Hover image true
      jam.bg_hover[3] = true
    else
--Hover image false
      jam.bg_hover[3] = false
    end

--spot 5
    if (x > 133 and x < 425) and (y > 241 and y < 270) then
--Slots true or false depending on the page
      jam.audio_slot_5[rep + 1] = false
      jam.audio_slot_5[rep] = true
      jam.audio_slot_5[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_5[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_5/"..rep)
      end
--Hover image true
      jam.bg_hover[4] = true
    else
--Hover image false
      jam.bg_hover[4] = false
    end

--spot 6
    if (x > 133 and x < 425) and (y > 291 and y < 320) then
--Slots true or false depending on the page
      jam.audio_slot_6[rep + 1] = false
      jam.audio_slot_6[rep] = true
      jam.audio_slot_6[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_6[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_6/"..rep)
      end
--Hover image true
      jam.bg_hover[5] = true
    else
--Hover image false
      jam.bg_hover[5] = false
    end

--spot 7
    if (x > 133 and x < 425) and (y > 342 and y < 368) then
--Slots true or false depending on the page
      jam.audio_slot_7[rep + 1] = false
      jam.audio_slot_7[rep] = true
      jam.audio_slot_7[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_7[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_7/"..rep)
      end
--Hover image true
      jam.bg_hover[6] = true
    else
--Hover image false
      jam.bg_hover[6] = false
    end

--spot 8
    if (x > 133 and x < 425) and (y > 391 and y < 419) then
--Slots true or false depending on the page
      jam.audio_slot_8[rep + 1] = false
      jam.audio_slot_8[rep] = true
      jam.audio_slot_8[rep - 1] = false
--Play music in the first slot depending on which page
      if jam.audio_slot_8[rep] == true then
        sol.audio.play_music("zane_kukta_music/slot_8/"..rep)
      end
--Hover image true
      jam.bg_hover[7] = true
    else
--Hover image false
      jam.bg_hover[7] = false
    end
  end -- end of if left button
 end-- end of page
end -- end of for loop
end -- end of mouse press function

How do I fix it?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Help test..Solarus crashes during audio playing
« Reply #10 on: November 30, 2016, 08:55:13 am »
Thanks for the bug report, I will try to reproduce it and to fix it.

The remark about creating surfaces in on_draw() is unrelated with the crash you have in sol.audio.play_music(), it was the cause of other crashes in 1.5.0.