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

Zefk

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
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
  1. ---------------------------------------------------------------------------------------------------------
  2. --Tell the script it is a map and to use game functions
  3. local game = ...
  4.  
  5. --A table because I like tables and it prevents upvalue errors
  6. local jam = {
  7.      
  8.       y_pos = {},
  9.       x_pos = {},
  10.       y_font_pos = {},
  11.       x_font_pos,
  12.       y_pos_wheel = 0,
  13.       scroll_distance,
  14.       page_wheel_down_cal,
  15.  
  16.       bg = {},
  17.       bg_hover = {},
  18.  
  19.       m_r_bg_img = sol.surface.create("jam_station/bg/M_R_bg.png"),
  20.       text_bg_img = sol.surface.create("jam_station/bg/text_bg.png"),
  21.       text_bg_hover_img = sol.surface.create("jam_station/bg/text_bg_hover.png"),
  22.        
  23.       scroll = {},
  24.  
  25.       scrolling_wheel_img = sol.surface.create("jam_station/scrollbar/scrolling_bar.png"),
  26.       scroll_bar_arrows_img = sol.surface.create("jam_station/scrollbar/scroll_bg_bar_arrows.png"),
  27.  
  28.       volume ={},
  29.  
  30.       b_0_percent_img = sol.surface.create("jam_station/volume/0_percent.png"),
  31.       b_25_percent_img = sol.surface.create("jam_station/volume/25_percent.png"),
  32.       b_50_percent_img = sol.surface.create("jam_station/volume/50_percent.png"),
  33.       b_75_percent_img = sol.surface.create("jam_station/volume/75_percent.png"),
  34.       b_100_percent_img = sol.surface.create("jam_station/volume/100_percent.png"),
  35.       percent_bg_img = sol.surface.create("jam_station/volume/percent_bg.png"),
  36.  
  37.       audio_slot_1 = {},
  38.       audio_slot_2 = {},
  39.       audio_slot_3 = {},
  40.       audio_slot_4 = {},
  41.       audio_slot_5 = {},
  42.       audio_slot_6 = {},
  43.       audio_slot_7 = {},
  44.       audio_slot_8 = {},
  45.       page = {},
  46.       next = 0,
  47.       audio_name = {},
  48.       font,
  49.       font_size,
  50.       color_type,
  51.       audio_text = {},
  52. }
  53.  
  54. -----------------------
  55. --CHANGE SETTINGS AREA:
  56. -----------------------
  57.  
  58. --Number of text spots or slots
  59. local text_num = 7
  60.  
  61. --Audio amount starting at 0, so 1 is actully 2 sorta
  62. local audio_amount = 1
  63.  
  64. --Drawing basic images on stript start
  65. jam.volume[1] = true
  66. jam.volume[2] = true
  67. jam.scroll[1] = true
  68. jam.scroll[2] = true
  69.  
  70. --max distance the scroll wheel can go down
  71. jam.scroll_distance = 344
  72.  
  73. --Divide the distance with pages
  74. jam.page_wheel_down_cal = 1
  75.  
  76. --Change the font package
  77. --Leave it nil to use the Solarus team made bitmap font. (At least in this demo or if you have it in your project.)
  78. --name_list.font = nil
  79. jam.font = "minecraftia"
  80.  
  81. --Change font size
  82. jam.font_size = 12
  83.  
  84. --Change color. It was set to snow white (Not white 255,255,255, but snow white 255,250,250. Yeah, they are different.)
  85. --Check in of script for some RGB color values.
  86. jam.color_type = {188,143,143} --139,0,139
  87.  
  88. -----------------------------
  89. --END OF CHANGE SETTINGS AREA
  90. -----------------------------
  91.  
  92. function sol.main:on_draw(screen)
  93.  
  94. --Text properties and name string loading
  95. for rep = 0,text_num do
  96.      jam.audio_text[rep] = sol.text_surface.create({
  97.       font = jam.font,
  98.       text = jam.audio_name[rep],
  99.       font_size = jam.font_size,
  100.       color = jam.color_type,
  101.     })
  102. end
  103.  
  104. --Clear or reset 0-7
  105. jam.audio_name = {}
  106.  
  107. --show this text on pae 1
  108. if jam.page[0] == true then
  109. jam.page[1] = false
  110. jam.audio_name[0] = "Klgo Journey Path"
  111. jam.audio_name[1] = "Beautiful Sadness"
  112. jam.audio_name[2] = "Darkness"
  113. jam.audio_name[3] = "Dark Void"
  114. jam.audio_name[4] = "Dungeon Enemy of Blues"
  115. jam.audio_name[5] = "Dungeon of Crepelody"
  116. jam.audio_name[6] = "Klgo Journey Menu"
  117. jam.audio_name[7] = "Mystic Flute"
  118. end
  119.  
  120. --Show this text on page 2
  121. if jam.page[1] == true then
  122. jam.page[0] = false
  123. jam.audio_name[0] = "Open Chest"
  124. jam.audio_name[1] = "The Unknown Danger"
  125. jam.audio_name[2] = "You are Chosen"
  126. jam.audio_name[3] = "Bonus Piano"
  127. jam.audio_name[4] = "Random sound effect_1"
  128. jam.audio_name[5] = "Random sound effect_2"
  129. jam.audio_name[6] = "Random sound effect_3"
  130. jam.audio_name[7] = "Random sound effect_4"
  131. end
  132.  
  133. --Testing
  134. print("0 is",jam.audio_name[0])
  135. print("0 is",jam.audio_name[1])
  136. print("0 is",jam.audio_name[2])
  137. print("0 is",jam.audio_name[3])
  138. print("0 is",jam.audio_name[4])
  139. print("0 is",jam.audio_name[5])
  140. print("0 is",jam.audio_name[6])
  141. print("0 is",jam.audio_name[7])
  142.  
  143. --Background image
  144.   if jam.bg[1] == true then
  145.     jam.m_r_bg_img:draw(screen)
  146.   end
  147.  
  148. --Text, hover slot image, and background slot images
  149. for i = 0,text_num do
  150.   if jam.bg[2] == true then
  151.     jam.text_bg_img:draw(screen, jam.x_pos[i], jam.y_pos[i])
  152.     jam.audio_text[i]:draw(screen,jam.x_font_pos,jam.y_font_pos[i])
  153.   end
  154. end
  155.  
  156. for i = 0,text_num do
  157.   if jam.bg_hover[i] == true then
  158.     jam.text_bg_hover_img:draw(screen, jam.x_pos[i], jam.y_pos[i])
  159.     jam.audio_text[i]:draw(screen,jam.x_font_pos,jam.y_font_pos[i])
  160.   end
  161. end
  162.  
  163. --Scroll bar
  164.   if jam.scroll[1] == true then
  165.     jam.scroll_bar_arrows_img:draw(screen)
  166.   end
  167.  
  168.   if jam.scroll[2] == true then
  169.     jam.scrolling_wheel_img:draw(screen,0,jam.y_pos_wheel)
  170.   end
  171.  
  172. --Volume images
  173.   if jam.volume[1] == true then
  174.     jam.percent_bg_img:draw(screen)
  175.   end
  176.  
  177.   if jam.volume[2] == true then
  178.     jam.b_100_percent_img:draw(screen)
  179.   end
  180.  
  181.   if jam.volume[3] == true then
  182.     jam.b_75_percent_img:draw(screen)
  183.   end
  184.  
  185.   if jam.volume[4] == true then
  186.     jam.b_50_percent_img:draw(screen)
  187.   end
  188.  
  189.   if jam.volume[5] == true then
  190.     jam.b_25_percent_img:draw(screen)
  191.   end
  192.  
  193.   if jam.volume[6] == true then
  194.     jam.b_0_percent_img:draw(screen)
  195.   end
  196.  
  197. --Page is true or false depending on up or down arrows.
  198. for rep = 0, audio_amount do
  199.   if jam.next == rep then
  200.     jam.page[rep + 1] = false
  201.     jam.page[rep] = true
  202.     jam.page[rep - 1] = false
  203.   end
  204. end
  205.  
  206. end --end of draw function
  207.  
  208. --Image and text coordinate changes and drawing background or UI mostly
  209.  for i = 0,text_num do
  210.    jam.bg[i] = true
  211.    jam.x_pos[i] = 0
  212.    jam.y_pos[i] = i * 50
  213.  
  214.    jam.x_font_pos = 150
  215.    jam.y_font_pos[i] = i * 50 + 50
  216.  end
  217.  
  218. function sol.main:on_key_pressed(key)
  219. ---will be used to close everything
  220. end--end of key press function
  221.  
  222. function sol.main:on_mouse_pressed(button,x,y)
  223.  
  224. --Volume control
  225. --volume 100%
  226.   if button == "left" then
  227.     if (x > 466 and x < 492) and (y > 61 and y < 134) then
  228.       print("left pressed")
  229.       jam.volume[1] = true
  230.       jam.volume[2] = true
  231.       jam.volume[3] = false
  232.       jam.volume[4] = false
  233.       jam.volume[5] = false
  234.       jam.volume[6] = false
  235.       sol.audio.set_music_volume(100)
  236.     end
  237. --volume 75%
  238.     if (x > 466 and x < 492) and (y > 135 and y < 246) then
  239.       print("left pressed")
  240.       jam.volume[2] = false
  241.       jam.volume[3] = true
  242.       jam.volume[4] = false
  243.       jam.volume[5] = false
  244.       jam.volume[6] = false
  245.       sol.audio.set_music_volume(75)
  246.     end
  247. --volume 50%
  248.     if (x > 466 and x < 492) and (y > 247 and y < 360) then
  249.       print("left pressed")
  250.       jam.volume[2] = false
  251.       jam.volume[3] = false
  252.       jam.volume[4] = true
  253.       jam.volume[5] = false
  254.       jam.volume[6] = false
  255.       sol.audio.set_music_volume(50)
  256.     end
  257. --volume 25%
  258.     if (x > 466 and x < 492) and (y > 360 and y < 430) then
  259.       print("left pressed")
  260.       jam.volume[2] = false
  261.       jam.volume[3] = false
  262.       jam.volume[4] = false
  263.       jam.volume[5] = true
  264.       jam.volume[6] = false
  265.       sol.audio.set_music_volume(25)
  266.     end
  267. --volume 0%
  268.     if (x > 466 and x < 492) and (y > 431 and y < 451) then
  269.       print("left pressed")
  270.       jam.volume[2] = false
  271.       jam.volume[3] = false
  272.       jam.volume[4] = false
  273.       jam.volume[5] = false
  274.       jam.volume[6] = true
  275.       sol.audio.set_music_volume(0)
  276.     end
  277.  
  278. --Up arrow
  279.     if (x > 437 and x < 458) and (y > 18 and y < 40) then
  280.       print("up pressed")
  281. --Distance calculations for the scroll wheel
  282.       if jam.y_pos_wheel > 0 then
  283.         jam.y_pos_wheel = jam.y_pos_wheel - jam.scroll_distance/jam.page_wheel_down_cal
  284. --Calculations for the page
  285.         jam.next = jam.next - 1
  286.       end
  287.     end
  288. --down arrow
  289.     if (x > 437 and x < 458) and (y > 441 and y < 463) then
  290.       print("down pressed")
  291. --Distance calculations for the scroll wheel
  292.       if jam.y_pos_wheel <= jam.scroll_distance then
  293.         jam.y_pos_wheel = jam.y_pos_wheel + jam.scroll_distance/jam.page_wheel_down_cal
  294. --Calculations for the page
  295.         jam.next = jam.next + 1
  296. --Sets the image for the scroll wheel. Do not want it to go off the screen.
  297.         if jam.y_pos_wheel > 344 then
  298.           jam.y_pos_wheel = 344
  299.         end
  300.       end
  301.     end
  302.  
  303. for rep = 0, audio_amount do
  304. --Pages
  305.  if jam.page[rep] == true then
  306. --spot 1
  307.     if (x > 133 and x < 425) and (y > 41 and y < 69) then
  308. --Slots true or false depending on the page
  309.       jam.audio_slot_1[rep + 1] = false
  310.       jam.audio_slot_1[rep] = true
  311.       jam.audio_slot_1[rep - 1] = false
  312. --Play music in the first slot depending on which page
  313.       if jam.audio_slot_1[rep] == true then
  314.         sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
  315.       end
  316. --Hover image true
  317.       jam.bg_hover[0] = true
  318.     else
  319. --Hover image false
  320.       jam.bg_hover[0] = false
  321.     end
  322.  
  323. --spot 2
  324.     if (x > 133 and x < 425) and (y > 91 and y < 119) then
  325. --Slots true or false depending on the page
  326.       jam.audio_slot_2[rep + 1] = false
  327.       jam.audio_slot_2[rep] = true
  328.       jam.audio_slot_2[rep - 1] = false
  329. --Play music in the first slot depending on which page
  330.       if jam.audio_slot_2[rep] == true then
  331.         sol.audio.play_music("zane_kukta_music/slot_2/"..rep)
  332.       end
  333. --Hover image true
  334.       jam.bg_hover[1] = true
  335.     else
  336. --Hover image false
  337.       jam.bg_hover[1] = false
  338.     end
  339.  
  340. --spot 3
  341.     if (x > 133 and x < 425) and (y > 141 and y < 171) then
  342. --Slots true or false depending on the page
  343.       jam.audio_slot_3[rep + 1] = false
  344.       jam.audio_slot_3[rep] = true
  345.       jam.audio_slot_3[rep - 1] = false
  346. --Play music in the first slot depending on which page
  347.       if jam.audio_slot_3[rep] == true then
  348.         sol.audio.play_music("zane_kukta_music/slot_3/"..rep)
  349.       end
  350. --Hover image true
  351.       jam.bg_hover[2] = true
  352.     else
  353. --Hover image false
  354.       jam.bg_hover[2] = false
  355.     end
  356.  
  357. --spot 4
  358.     if (x > 133 and x < 425) and (y > 191 and y < 220) then
  359. --Slots true or false depending on the page
  360.       jam.audio_slot_4[rep + 1] = false
  361.       jam.audio_slot_4[rep] = true
  362.       jam.audio_slot_4[rep - 1] = false
  363. --Play music in the first slot depending on which page
  364.       if jam.audio_slot_4[rep] == true then
  365.         sol.audio.play_music("zane_kukta_music/slot_4/"..rep)
  366.       end
  367. --Hover image true
  368.       jam.bg_hover[3] = true
  369.     else
  370. --Hover image false
  371.       jam.bg_hover[3] = false
  372.     end
  373.  
  374. --spot 5
  375.     if (x > 133 and x < 425) and (y > 241 and y < 270) then
  376. --Slots true or false depending on the page
  377.       jam.audio_slot_5[rep + 1] = false
  378.       jam.audio_slot_5[rep] = true
  379.       jam.audio_slot_5[rep - 1] = false
  380. --Play music in the first slot depending on which page
  381.       if jam.audio_slot_5[rep] == true then
  382.         sol.audio.play_music("zane_kukta_music/slot_5/"..rep)
  383.       end
  384. --Hover image true
  385.       jam.bg_hover[4] = true
  386.     else
  387. --Hover image false
  388.       jam.bg_hover[4] = false
  389.     end
  390.  
  391. --spot 6
  392.     if (x > 133 and x < 425) and (y > 291 and y < 320) then
  393. --Slots true or false depending on the page
  394.       jam.audio_slot_6[rep + 1] = false
  395.       jam.audio_slot_6[rep] = true
  396.       jam.audio_slot_6[rep - 1] = false
  397. --Play music in the first slot depending on which page
  398.       if jam.audio_slot_6[rep] == true then
  399.         sol.audio.play_music("zane_kukta_music/slot_6/"..rep)
  400.       end
  401. --Hover image true
  402.       jam.bg_hover[5] = true
  403.     else
  404. --Hover image false
  405.       jam.bg_hover[5] = false
  406.     end
  407.  
  408. --spot 7
  409.     if (x > 133 and x < 425) and (y > 342 and y < 368) then
  410. --Slots true or false depending on the page
  411.       jam.audio_slot_7[rep + 1] = false
  412.       jam.audio_slot_7[rep] = true
  413.       jam.audio_slot_7[rep - 1] = false
  414. --Play music in the first slot depending on which page
  415.       if jam.audio_slot_7[rep] == true then
  416.         sol.audio.play_music("zane_kukta_music/slot_7/"..rep)
  417.       end
  418. --Hover image true
  419.       jam.bg_hover[6] = true
  420.     else
  421. --Hover image false
  422.       jam.bg_hover[6] = false
  423.     end
  424.  
  425. --spot 8
  426.     if (x > 133 and x < 425) and (y > 391 and y < 419) then
  427. --Slots true or false depending on the page
  428.       jam.audio_slot_8[rep + 1] = false
  429.       jam.audio_slot_8[rep] = true
  430.       jam.audio_slot_8[rep - 1] = false
  431. --Play music in the first slot depending on which page
  432.       if jam.audio_slot_8[rep] == true then
  433.         sol.audio.play_music("zane_kukta_music/slot_8/"..rep)
  434.       end
  435. --Hover image true
  436.       jam.bg_hover[7] = true
  437.     else
  438. --Hover image false
  439.       jam.bg_hover[7] = false
  440.     end
  441.   end -- end of if left button
  442.  end-- end of page
  443. end -- end of for loop
  444. end -- end of mouse press function
« Last Edit: November 30, 2016, 09:43:46 am by Zefk »

Diarandor

  • Hero Member
  • *****
  • Posts: 741
  • 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.

Zefk

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
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.
« Last Edit: November 29, 2016, 01:41:42 pm by Zefk »

Zefk

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
Re: Help test..Solarus crashes during audio playing
« Reply #3 on: November 29, 2016, 01:31:31 pm »

froggy77

  • Jr. Member
  • **
  • Posts: 82
    • 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: 1016
    • 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

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
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.


« Last Edit: November 30, 2016, 09:29:25 am by Zefk »

Zefk

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
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.
« Last Edit: November 30, 2016, 06:26:58 am by Zefk »

llamazing

  • Jr. Member
  • **
  • Posts: 70
    • 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

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
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
  1. for rep = 0, audio_amount do
  2. --Pages
  3. --Page is true or false depending on up or down arrows.
  4.   if jam.next == rep then
  5.     jam.page[rep + 1] = false
  6.     jam.page[rep] = true
  7.     jam.page[rep - 1] = false
  8.   end
  9.  if jam.page[rep] == true then
  10. --spot 1
  11.     if (x > 133 and x < 425) and (y > 41 and y < 69) then
  12. --Slots true or false depending on the page
  13.       jam.audio_slot_1[rep + 1] = false
  14.       jam.audio_slot_1[rep] = true
  15.       jam.audio_slot_1[rep - 1] = false
  16. --Play music in the first slot depending on which page
  17.       if jam.audio_slot_1[rep] == true then
  18.         sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
  19.       end
  20. --Hover image true
  21.       jam.bg_hover[0] = true
  22.     else
  23. --Hover image false
  24.       jam.bg_hover[0] = false
  25.     end

All of the mouse function:
Code: Lua
  1. function sol.main:on_mouse_pressed(button,x,y)
  2.  
  3. --Volume control
  4. --volume 100%
  5.   if button == "left" then
  6.     if (x > 466 and x < 492) and (y > 61 and y < 134) then
  7.       print("left pressed")
  8.       jam.volume[1] = true
  9.       jam.volume[2] = true
  10.       jam.volume[3] = false
  11.       jam.volume[4] = false
  12.       jam.volume[5] = false
  13.       jam.volume[6] = false
  14.       sol.audio.set_music_volume(100)
  15.     end
  16. --volume 75%
  17.     if (x > 466 and x < 492) and (y > 135 and y < 246) then
  18.       print("left pressed")
  19.       jam.volume[2] = false
  20.       jam.volume[3] = true
  21.       jam.volume[4] = false
  22.       jam.volume[5] = false
  23.       jam.volume[6] = false
  24.       sol.audio.set_music_volume(75)
  25.     end
  26. --volume 50%
  27.     if (x > 466 and x < 492) and (y > 247 and y < 360) then
  28.       print("left pressed")
  29.       jam.volume[2] = false
  30.       jam.volume[3] = false
  31.       jam.volume[4] = true
  32.       jam.volume[5] = false
  33.       jam.volume[6] = false
  34.       sol.audio.set_music_volume(50)
  35.     end
  36. --volume 25%
  37.     if (x > 466 and x < 492) and (y > 360 and y < 430) then
  38.       print("left pressed")
  39.       jam.volume[2] = false
  40.       jam.volume[3] = false
  41.       jam.volume[4] = false
  42.       jam.volume[5] = true
  43.       jam.volume[6] = false
  44.       sol.audio.set_music_volume(25)
  45.     end
  46. --volume 0%
  47.     if (x > 466 and x < 492) and (y > 431 and y < 451) then
  48.       print("left pressed")
  49.       jam.volume[2] = false
  50.       jam.volume[3] = false
  51.       jam.volume[4] = false
  52.       jam.volume[5] = false
  53.       jam.volume[6] = true
  54.       sol.audio.set_music_volume(0)
  55.     end
  56.  
  57. --Up arrow
  58.     if (x > 437 and x < 458) and (y > 18 and y < 40) then
  59.       print("up pressed")
  60. --Distance calculations for the scroll wheel
  61.       if jam.y_pos_wheel > 0 then
  62.         jam.y_pos_wheel = jam.y_pos_wheel - jam.scroll_distance/jam.page_wheel_down_cal
  63. --Calculations for the page
  64.         jam.next = jam.next - 1
  65.       end
  66.     end
  67. --down arrow
  68.     if (x > 437 and x < 458) and (y > 441 and y < 463) then
  69.       print("down pressed")
  70. --Distance calculations for the scroll wheel
  71.       if jam.y_pos_wheel <= jam.scroll_distance then
  72.         jam.y_pos_wheel = jam.y_pos_wheel + jam.scroll_distance/jam.page_wheel_down_cal
  73. --Calculations for the page
  74.         jam.next = jam.next + 1
  75. --Sets the image for the scroll wheel. Do not want it to go off the screen.
  76.         if jam.y_pos_wheel > 344 then
  77.           jam.y_pos_wheel = 344
  78.         end
  79.       end
  80.     end
  81.  
  82. for rep = 0, audio_amount do
  83. --Pages
  84. --Page is true or false depending on up or down arrows.
  85.   if jam.next == rep then
  86.     jam.page[rep + 1] = false
  87.     jam.page[rep] = true
  88.     jam.page[rep - 1] = false
  89.   end
  90.  if jam.page[rep] == true then
  91. --spot 1
  92.     if (x > 133 and x < 425) and (y > 41 and y < 69) then
  93. --Slots true or false depending on the page
  94.       jam.audio_slot_1[rep + 1] = false
  95.       jam.audio_slot_1[rep] = true
  96.       jam.audio_slot_1[rep - 1] = false
  97. --Play music in the first slot depending on which page
  98.       if jam.audio_slot_1[rep] == true then
  99.         sol.audio.play_music("zane_kukta_music/slot_1/"..rep)
  100.       end
  101. --Hover image true
  102.       jam.bg_hover[0] = true
  103.     else
  104. --Hover image false
  105.       jam.bg_hover[0] = false
  106.     end
  107.  
  108. --spot 2
  109.     if (x > 133 and x < 425) and (y > 91 and y < 119) then
  110. --Slots true or false depending on the page
  111.       jam.audio_slot_2[rep + 1] = false
  112.       jam.audio_slot_2[rep] = true
  113.       jam.audio_slot_2[rep - 1] = false
  114. --Play music in the first slot depending on which page
  115.       if jam.audio_slot_2[rep] == true then
  116.         sol.audio.play_music("zane_kukta_music/slot_2/"..rep)
  117.       end
  118. --Hover image true
  119.       jam.bg_hover[1] = true
  120.     else
  121. --Hover image false
  122.       jam.bg_hover[1] = false
  123.     end
  124.  
  125. --spot 3
  126.     if (x > 133 and x < 425) and (y > 141 and y < 171) then
  127. --Slots true or false depending on the page
  128.       jam.audio_slot_3[rep + 1] = false
  129.       jam.audio_slot_3[rep] = true
  130.       jam.audio_slot_3[rep - 1] = false
  131. --Play music in the first slot depending on which page
  132.       if jam.audio_slot_3[rep] == true then
  133.         sol.audio.play_music("zane_kukta_music/slot_3/"..rep)
  134.       end
  135. --Hover image true
  136.       jam.bg_hover[2] = true
  137.     else
  138. --Hover image false
  139.       jam.bg_hover[2] = false
  140.     end
  141.  
  142. --spot 4
  143.     if (x > 133 and x < 425) and (y > 191 and y < 220) then
  144. --Slots true or false depending on the page
  145.       jam.audio_slot_4[rep + 1] = false
  146.       jam.audio_slot_4[rep] = true
  147.       jam.audio_slot_4[rep - 1] = false
  148. --Play music in the first slot depending on which page
  149.       if jam.audio_slot_4[rep] == true then
  150.         sol.audio.play_music("zane_kukta_music/slot_4/"..rep)
  151.       end
  152. --Hover image true
  153.       jam.bg_hover[3] = true
  154.     else
  155. --Hover image false
  156.       jam.bg_hover[3] = false
  157.     end
  158.  
  159. --spot 5
  160.     if (x > 133 and x < 425) and (y > 241 and y < 270) then
  161. --Slots true or false depending on the page
  162.       jam.audio_slot_5[rep + 1] = false
  163.       jam.audio_slot_5[rep] = true
  164.       jam.audio_slot_5[rep - 1] = false
  165. --Play music in the first slot depending on which page
  166.       if jam.audio_slot_5[rep] == true then
  167.         sol.audio.play_music("zane_kukta_music/slot_5/"..rep)
  168.       end
  169. --Hover image true
  170.       jam.bg_hover[4] = true
  171.     else
  172. --Hover image false
  173.       jam.bg_hover[4] = false
  174.     end
  175.  
  176. --spot 6
  177.     if (x > 133 and x < 425) and (y > 291 and y < 320) then
  178. --Slots true or false depending on the page
  179.       jam.audio_slot_6[rep + 1] = false
  180.       jam.audio_slot_6[rep] = true
  181.       jam.audio_slot_6[rep - 1] = false
  182. --Play music in the first slot depending on which page
  183.       if jam.audio_slot_6[rep] == true then
  184.         sol.audio.play_music("zane_kukta_music/slot_6/"..rep)
  185.       end
  186. --Hover image true
  187.       jam.bg_hover[5] = true
  188.     else
  189. --Hover image false
  190.       jam.bg_hover[5] = false
  191.     end
  192.  
  193. --spot 7
  194.     if (x > 133 and x < 425) and (y > 342 and y < 368) then
  195. --Slots true or false depending on the page
  196.       jam.audio_slot_7[rep + 1] = false
  197.       jam.audio_slot_7[rep] = true
  198.       jam.audio_slot_7[rep - 1] = false
  199. --Play music in the first slot depending on which page
  200.       if jam.audio_slot_7[rep] == true then
  201.         sol.audio.play_music("zane_kukta_music/slot_7/"..rep)
  202.       end
  203. --Hover image true
  204.       jam.bg_hover[6] = true
  205.     else
  206. --Hover image false
  207.       jam.bg_hover[6] = false
  208.     end
  209.  
  210. --spot 8
  211.     if (x > 133 and x < 425) and (y > 391 and y < 419) then
  212. --Slots true or false depending on the page
  213.       jam.audio_slot_8[rep + 1] = false
  214.       jam.audio_slot_8[rep] = true
  215.       jam.audio_slot_8[rep - 1] = false
  216. --Play music in the first slot depending on which page
  217.       if jam.audio_slot_8[rep] == true then
  218.         sol.audio.play_music("zane_kukta_music/slot_8/"..rep)
  219.       end
  220. --Hover image true
  221.       jam.bg_hover[7] = true
  222.     else
  223. --Hover image false
  224.       jam.bg_hover[7] = false
  225.     end
  226.   end -- end of if left button
  227.  end-- end of page
  228. end -- end of for loop
  229. end -- end of mouse press function
  230.  

How do I fix it?
« Last Edit: November 30, 2016, 09:06:27 am by Zefk »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1016
    • 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.