Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns --- Bug Reports --- Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: [Linux] - Speed/sound issues since Groovymame 0.182  (Read 2153 times)

0 Members and 1 Guest are viewing this topic.

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
[Linux] - Speed/sound issues since Groovymame 0.182
« on: April 22, 2017, 06:42:59 am »
Hi,

I noticed a strange speed / sound issue with groovymame since version 0.182. I tried
all versions incrementally from 0.176 up to 0.183.

The speed of the game seems to be is instable and it is noticeable through sound pitch variations.

Using "-waitvsync" doesn't fix the issue (appart from removing tearing on
Nvidia card).

I use Ubuntu 16.10, Quad Core i5, and i have done many tests with both a
Nvidia G210 and a Radeon HD5450 graphic cards with the same results for
both (witch tearing for the nvidia one but that's another topic).
I use Openbox Window Manager.

I tried many games, it is more or less noticeable depending on the game, i
can list :
Code: [Select]
mame64 lresort
mame64 snes contra3  #very noticeable on this one
mame64 nes smb  # less noticeable but still

I take care to delete mame cfg and mame nvram path between each test launchs.

Logs files are attached to this post:

- Verbose logs of "lresort" launched with Groovymame 0.183
- Verbose logs of "snes contra3" launched with Groovymame 0.183
- Verbose logs of "snes contra3" launched with Groovymame 0.181, for comparison (this version has no speed/sound issues)
- My mame.ini
- Output of "mame64 -showconfig"

If you have an idea..
Thanks in advance

intealls

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 306
  • Last login:February 16, 2019, 02:24:58 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #1 on: April 22, 2017, 07:41:34 am »
Hi, this is due to a change for the PortAudio backend to avoid over/underruns with low latencies. Hopefully soon I'll have time to look at this in more detail and try to find a robust fix, I've seen a couple of people noticing issues.

Edit: You could also test setting -nosleep and upping the priority of GM with something like 'nice -n 0 ./mame64 -nosleep [game]'. On Windows this seems to work well.

If you want to revert this change, it's found here (src/emu/sound.cpp):

Code: [Select]
@@ -1051,7 +1048,7 @@
 //  and send it to the OSD layer
 //-------------------------------------------------
 
-void sound_manager::update(void *ptr, int param)
+void sound_manager::update()
 {
  VPRINTF(("sound_update\n"));
 
@@ -1063,13 +1060,13 @@
  speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM));
 
  // now downmix the final result
- u32 finalmix_step = machine().video().speed_factor();
+ u32 finalmix_step = machine().video().speed_percent() * 100000;
  u32 finalmix_offset = 0;
  s16 *finalmix = &m_finalmix[0];
  int sample;
- for (sample = m_finalmix_leftover; sample < samples_this_update * 1000; sample += finalmix_step)
+ for (sample = m_finalmix_leftover; sample < samples_this_update * 100000; sample += finalmix_step)
  {
- int sampindex = sample / 1000;
+ int sampindex = sample / 100000;
 
  // clamp the left side
  s32 samp = m_leftmix[sampindex];
@@ -1087,7 +1084,7 @@
  samp = 32767;
  finalmix[finalmix_offset++] = samp;
  }
- m_finalmix_leftover = sample - samples_this_update * 1000;
+ m_finalmix_leftover = sample - samples_this_update * 100000;
 
  // play the result
  if (finalmix_offset > 0)
« Last Edit: April 22, 2017, 08:24:22 am by intealls »

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #2 on: April 22, 2017, 09:05:37 am »
Hi intealls,

Thanks for your quick answer and your work on Groovymame.

I tried using "nice -n0 mame64 -nosleep": At first glance it seems to improve things. I need to do more checks to confirm. However It does not fix it when using -waitvsync

I tried to apply your patch but the compilation failed :

$ patch -p0 -E --binary -R < sound-patch.diff

(i needed to add -R because patch program detected it as "a reverse patch")

Code: [Select]
Compiling src/emu/sound.cpp...
../../../../../src/emu/sound.cpp:1051:6: error: prototype for ‘void sound_manager::update(void*, int)’ does not match any in class ‘sound_manager’
 void sound_manager::update(void *ptr, int param)
      ^~~~~~~~~~~~~
In file included from ../../../../../src/emu/emu.h:111:0:
../../../../../src/emu/sound.h:229:7: error: candidate is: void sound_manager::update()
  void update();
       ^~~~~~
emu.make:1178 : la recette pour la cible « ../../../../linux_gcc/obj/x64/Release/src/emu/sound.o » a échouée

Do i need to apply it before groovymame patch or after (i applied it after) ?

Again thanks.

intealls

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 306
  • Last login:February 16, 2019, 02:24:58 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #3 on: April 22, 2017, 09:54:42 am »
Hi, just replace the sound_manager::update (bottom of src/emu/sound.cpp) function with the one pasted below, it's from mainline. But please try upping the priority first and see if that removes the pitch variations.

Code: [Select]
void sound_manager::update(void *ptr, int param)
{
VPRINTF(("sound_update\n"));

g_profiler.start(PROFILER_SOUND);

// force all the speaker streams to generate the proper number of samples
int samples_this_update = 0;
for (speaker_device &speaker : speaker_device_iterator(machine().root_device()))
speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM));

// now downmix the final result
u32 finalmix_step = machine().video().speed_factor();
u32 finalmix_offset = 0;
s16 *finalmix = &m_finalmix[0];
int sample;
for (sample = m_finalmix_leftover; sample < samples_this_update * 1000; sample += finalmix_step)
{
int sampindex = sample / 1000;

// clamp the left side
s32 samp = m_leftmix[sampindex];
if (samp < -32768)
samp = -32768;
else if (samp > 32767)
samp = 32767;
finalmix[finalmix_offset++] = samp;

// clamp the right side
samp = m_rightmix[sampindex];
if (samp < -32768)
samp = -32768;
else if (samp > 32767)
samp = 32767;
finalmix[finalmix_offset++] = samp;
}
m_finalmix_leftover = sample - samples_this_update * 1000;

// play the result
if (finalmix_offset > 0)
{
if (!m_nosound_mode)
machine().osd().update_audio_stream(finalmix, finalmix_offset / 2);
machine().osd().add_audio_to_recording(finalmix, finalmix_offset / 2);
machine().video().add_sound_to_recording(finalmix, finalmix_offset / 2);
if (m_wavfile != nullptr)
wav_add_data_16(m_wavfile, finalmix, finalmix_offset);
}

// see if we ticked over to the next second
attotime curtime = machine().time();
bool second_tick = false;
if (curtime.seconds() != m_last_update.seconds())
{
assert(curtime.seconds() == m_last_update.seconds() + 1);
second_tick = true;
}

// iterate over all the streams and update them
for (auto &stream : m_stream_list)
stream->update_with_accounting(second_tick);

// remember the update time
m_last_update = curtime;

// update sample rates if they have changed
for (auto &stream : m_stream_list)
stream->apply_sample_rate_changes();

g_profiler.stop();
}

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #4 on: April 22, 2017, 11:25:22 am »
I've done some tests.

Here are the results. I tried with "snes contra3", the sound pitch issue is easily listenable during the Konami logo at the beginning of the game. I tried with lresort too.

Test 1: /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -v > /tmp/groovymame
Result: Original sound pitch issues

Test 2: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -v > /tmp/groovymame
Result: Real improvment. I can't truly confirm it solves it but i don't have noticed any sound pitch issue. If they are, they are very subtil. I should play a game longer to confirm this.

Test 3:  /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -waitvsync -v > /tmp/groovymame
Result: Sound pitch issue. A lot. Seems to be worst than without "waitsvync"

Test 4: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Same results as test 3. nice/nosleep seems to have no effect.

Test 5: sudo nice -n -18 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Same results as test 3 and 4. Augment nice level with root rights doesn't improve anything.

Observation: Despite the sound pitch occurs without -waitvsync, this options seems to be related in some way.

« Last Edit: April 22, 2017, 11:29:19 am by tiben »

intealls

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 306
  • Last login:February 16, 2019, 02:24:58 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #5 on: April 22, 2017, 12:18:14 pm »
I've done some tests.

Here are the results. I tried with "snes contra3", the sound pitch issue is easily listenable during the Konami logo at the beginning of the game. I tried with lresort too.

Test 1: /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -v > /tmp/groovymame
Result: Original sound pitch issues

Test 2: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -v > /tmp/groovymame
Result: Real improvment. I can't truly confirm it solves it but i don't have noticed any sound pitch issue. If they are, they are very subtil. I should play a game longer to confirm this.

Test 3:  /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -waitvsync -v > /tmp/groovymame
Result: Sound pitch issue. A lot. Seems to be worst than without "waitsvync"

Test 4: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Same results as test 3. nice/nosleep seems to have no effect.

Test 5: sudo nice -n -18 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Same results as test 3 and 4. Augment nice level with root rights doesn't improve anything.

Observation: Despite the sound pitch occurs without -waitvsync, this options seems to be related in some way.

Thanks for testing!

Hm. So waitvsync makes the pitch issues worse? On Windows using waitvsync seems to have the opposite effect, since syncing against vblank is nice and stable.

Calamity: any ideas?

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #6 on: April 22, 2017, 12:26:11 pm »
Theses tests are done with the Nvidia. I'm going to do the same with the radeon.

I've modified the "void sound_manager::update(" function as you said but the same compilation bug occurs:

Code: [Select]
../../../../../src/emu/sound.cpp:1051:6: error: prototype for ‘void sound_manager::update(void*, int)’ does not match any in class ‘sound_manager’
 void sound_manager::update(void *ptr, int param)
      ^~~~~~~~~~~~~
In file included from ../../../../../src/emu/emu.h:111:0:
../../../../../src/emu/sound.h:229:7: error: candidate is: void sound_manager::update()
  void update();
       ^~~~~~
emu.make:1178 : la recette pour la cible « ../../../../linux_gcc/obj/x64/Release/src/emu/sound.o » a échouée
make[2]: *** [../../../../linux_gcc/obj/x64/Release/src/emu/sound.o] Erreur 1
Makefile:79 : la recette pour la cible « emu » a échouée
make[1]: *** [emu] Erreur 2
makefile:1242 : la recette pour la cible « linux_x64 » a échouée
make: *** [linux_x64] Erreur 2


I tried first by only change the function on the previous code base (with groovymame patch and the patch of your first reply applied), then a restarted properly with a clean new copy, having only groovymame patch applied and the function changed manually. Same error on both.


intealls

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 306
  • Last login:February 16, 2019, 02:24:58 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #7 on: April 22, 2017, 12:52:44 pm »
Theses tests are done with the Nvidia. I'm going to do the same with the radeon.

I've modified the "void sound_manager::update(" function as you said but the same compilation bug occurs:

Code: [Select]
../../../../../src/emu/sound.cpp:1051:6: error: prototype for ‘void sound_manager::update(void*, int)’ does not match any in class ‘sound_manager’
 void sound_manager::update(void *ptr, int param)
      ^~~~~~~~~~~~~
In file included from ../../../../../src/emu/emu.h:111:0:
../../../../../src/emu/sound.h:229:7: error: candidate is: void sound_manager::update()
  void update();
       ^~~~~~
emu.make:1178 : la recette pour la cible « ../../../../linux_gcc/obj/x64/Release/src/emu/sound.o » a échouée
make[2]: *** [../../../../linux_gcc/obj/x64/Release/src/emu/sound.o] Erreur 1
Makefile:79 : la recette pour la cible « emu » a échouée
make[1]: *** [emu] Erreur 2
makefile:1242 : la recette pour la cible « linux_x64 » a échouée
make: *** [linux_x64] Erreur 2


I tried first by only change the function on the previous code base (with groovymame patch and the patch of your first reply applied), then a restarted properly with a clean new copy, having only groovymame patch applied and the function changed manually. Same error on both.

Sorry about that, forgot that the audio update routine has been changed slightly in GM. I also don't have the ability to easily create a patch for this at the moment.

Change the following lines on a freshly patched GM tree (between // now downmix... and // play the result) to:

Code: [Select]
// now downmix the final result
u32 finalmix_step = machine().video().speed_factor();
u32 finalmix_offset = 0;
s16 *finalmix = &m_finalmix[0];
int sample;
for (sample = m_finalmix_leftover; sample < samples_this_update * 1000; sample += finalmix_step)
{
int sampindex = sample / 1000;

// clamp the left side
s32 samp = m_leftmix[sampindex];
if (samp < -32768)
samp = -32768;
else if (samp > 32767)
samp = 32767;
finalmix[finalmix_offset++] = samp;

// clamp the right side
samp = m_rightmix[sampindex];
if (samp < -32768)
samp = -32768;
else if (samp > 32767)
samp = 32767;
finalmix[finalmix_offset++] = samp;
}
m_finalmix_leftover = sample - samples_this_update * 1000;

// play the result

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #8 on: April 22, 2017, 04:28:54 pm »
So here are the tests with the Radeon:

Test 1: /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -v > /tmp/groovymame
Result: Noticeable Sound pitch

Test 2: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -v > /tmp/groovymame
Result: Improve the results but does not seems to solve the issue completely
(but maybe this is simply auditive hallucination). However i noticed some
"syncronisation stall" from time to time. I don't know how to describe it
precisely: the scrolling stops to be smooth during short period and become
"blocky" (it move by step of very small blocks). There is no tearing at all
but the scroll is not smooth. During this test
it appeared on the level 2 of Last Resort. 2 or 3 seconds later
it become smooth again. I know this game has some natural slowdowns but i
saw this phenomen on other titles too. Originally, this issue made me use
"-waitvsync" because it seemed to fix it (despite potential input
lags i am aware of using this option). I
 believed it was because my radeon card was plugged on a PCI
Express 1x port (using a PCI express riser), i guessed this port provided simply not
enough bandwidth for Groovymame. But the test of today was opportunity to test my
radeon card on the main PCI Express 16x slot, and it proved this weird
issue remains.
To be clear, this is opportunity to speak about this issue. It is not specific to the use of nice and -nosleep option.
I noticed it  before, using no particular options.


Test 3: /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -waitvsync -v > /tmp/groovymame
Result: Noticeable Sound pitch

Test 4: nice -n 0 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Seems to reduce the sound pitch (unlike nvidia)

Test 5: sudo nice -n -18 /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 -nosleep snes contra3 -waitvsync -v > /tmp/groovymame
Result: Hardly noticeable (unlike nvidia too)

It is difficult to say theses tests are accurate because the behavior between systems (neogeo, snes etc..) differs depending on the graphic card, i noticed more sound pitch on snes using nvidia than radeon while neogeo seems pretty similar with both cards). I made the same tests with the radeon on 1x pci express port too and general behavior differed slightly too.

Code modification seems to be ok. Groovymame is now compiling...

What is the purpose of "nosleep" option ?

Thank you @intealls for the time you spend on that.



Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #9 on: April 22, 2017, 05:52:22 pm »
I'm seeing an issue here. DRM is not being opened by GM. Both 183 and 181 show the issue.

There are some blocks in drawogl.cpp between ifdefs that are not being activated for some reason (#ifdef SDLMAME_X11). Can anyone compile forcing these blocks to be activated (e.g. removing the ifdefs) and see if this fixes the issue?

EDIT: Forget it, your actual issue is GM is not using opengl but the sdl software renderer instead, not sure why.

There's a separate issue, drm wouldn't get activated on time anyway because the order of events has in the sdl build has changed recently it seems. I need to have a look at this issue.
« Last Edit: April 22, 2017, 06:11:40 pm by Calamity »
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #10 on: April 22, 2017, 06:30:50 pm »
Hi Calamity,

Logs of my first post have been made using my Nvidia card.
I attach here the same logs (gm0183, snes contra3) but with my Radeon. If it could help...

Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #11 on: April 22, 2017, 06:33:17 pm »
There's a possible workaround. In switchres_sdl, change:

 bool sync_refresh_effective = black_frame_insertion || !(fd == 0 || (best_mode->result.weight & R_V_FREQ_OFF) || best_mode->result.v_scale > 1);

by

 bool sync_refresh_effective = black_frame_insertion || !((best_mode->result.weight & R_V_FREQ_OFF) || best_mode->result.v_scale > 1);


If you get a compile error, remove this line too:

extern int fd;


(of course, you need to try this with -video opengl)
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #12 on: April 22, 2017, 06:56:15 pm »
Mame is now compiling with the modification you said on the file "src/osd/sdl/switchres_sdl.cpp".

This will take some time because i restarted from clean new source tree.

Quote
Forget it, your actual issue is GM is not using opengl but the sdl software renderer instead, not sure why.

@Calamity: Where on the logs do you see that ?

Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #13 on: April 22, 2017, 06:58:22 pm »
@Calamity: Where on the logs do you see that ?

Using SDL multi-window soft driver (SDL 2.0+)

It should be:

Using SDL multi-window OpenGL driver (SDL 2.0+)
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #14 on: April 22, 2017, 07:18:25 pm »
OK.

I just noticed i sent an empty file for logs with the radeon. Here a the good one.

Seems to be SDL software renderer too.

One strange thing, later on the log file there is this:

Code: [Select]
window: using renderer opengl

I checked it is present on logs with the nvidia too.

Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #15 on: April 22, 2017, 07:22:21 pm »
It won't activate drm unless it uses the native opengl renderer (not the one through sdl).
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #16 on: April 22, 2017, 09:04:20 pm »
Ok so this time i think it's solved :)

Test1: /usr/local/lib/15khz-arcade-pkg/groovymame/mame64 snes contra3 -video opengl -v > /tmp/groovymame
I tried here simply to add "-video opengl". The logs mentionned :

Code: [Select]
Using SDL multi-window OpenGL driver (SDL 2.0+)
/dev/dri/card0 successfully opened

I used my original groovymame-0183
Results: Despite the use of OpenGL i still noticed sound pitch issues

Test 2: Same as test 1 but with "mame64" freshly compiled with the modification mentionned by Calamity.
I played to Last Resort up to level 4 and it was perfect: no sound pitch and perfect scrolling, no "synchronisatoin stall".
I'll test more in depth tomorrow (with the nvidia card and with the radeon on pci 1x slot) but i'm pretty confident it is fixed now.

@Calamity: I did not have to remove "extern int fd;", it compiled the first time.

Thank you very much @Calamity and @intealls.

If you need testers feel free to ask

EDIT: i have attached verbose logs of Last Resort execution.




« Last Edit: April 22, 2017, 09:07:03 pm by tiben »

horihori

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:January 29, 2019, 02:54:03 am
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #17 on: April 23, 2017, 11:50:56 am »
Is this audio problem just Linux or does windows Groovymame suffer from this also?

intealls

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 306
  • Last login:February 16, 2019, 02:24:58 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #18 on: April 23, 2017, 12:00:51 pm »
In this instance, it appears to be Linux. If you happen to notice audio issues on Windows, use -nosleep and -priority 1.

horihori

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:January 29, 2019, 02:54:03 am
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #19 on: April 23, 2017, 12:19:02 pm »
Thanks intealls, yeah I usually have my .ini with nosleep and priority 1.  I'm currently testing build 0.183 and can't decide if I prefer it over the 0.171 version with ASIO support. 

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #20 on: April 23, 2017, 01:07:31 pm »
I noticed on the logs (the last where i say it works well) theses options when i add -video opengl:

Code: [Select]
SwitchRes: Setting option -syncrefresh
SwitchRes: Setting option -waitvsync

Is it normal ?

Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #21 on: April 23, 2017, 02:16:23 pm »
I noticed on the logs (the last where i say it works well) theses options when i add -video opengl:

Code: [Select]
SwitchRes: Setting option -syncrefresh
SwitchRes: Setting option -waitvsync

Is it normal ?

Yes, that's normal. You can't expect smooth anything without -syncrefresh. Actually it was the lack of activation of -syncrefresh in your previous logs what led me to the issue.


Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #22 on: April 26, 2017, 05:50:01 pm »
Being confident the issue was solved, i decided to setup my system as i would like to be definitively (ie Multiseat):

- seat0: Radeon on PCIEx16 port for desktop
- seat-1: Nvidia on PCIEx1 port for attract-mode/groovymame

Unfortunatelly the code modification suggested by @Calamity does not resolve the speed/sound issue on this setup.

I decided to take another look at the code modification about the sound fix suggested by @intealls.

The first tests were really confusing and i must admit i have hard time to understand what's going on.

After took a look at the code fix by @Calamity i realised it simply fixed the automatic set of "syncrefresh" and "waitvsync" options (maybe i'm wrong) which were not sat by default.
I confirm opengl is not chosen by default but software instead too.

The two renderers (soft and opengl) + the sound issue + waitvsync/syncrefresh options have impacts on the results. This leads to some combinatorial complexity that starts to be difficult to manage by only trying on the fly so i decided to conduct exhaustive tests and report results on the table below. Because @Calamity fix simply set options, it has been not taken in account,  options are explicitly set from the command line.
Same tests have been made using 3 differents mame drivers: neomrdo, snes contra3 and alexkidd.



*of course, resolution is wrong due to the use of original Mame.

Some observations:

- For now there is only two working combinations. Boths using groovymame  0181. Its better than nothing and seems to prove the system/setup is not the culprit and is capable.

- Using Groovymame, OpenGL performs really badder than software and there is no combination that solve tearing. No performance issue using OpenGL is observed with original Mame.

- There is an important performance decrease between groovymame 0181 and 0183 which makes new versions of groovymame unusable on my system.

- The intealls sound fix seems to reduce the sound issue but does not fix it completely.

- With the combination "-nowaitvsync, -syncrefresh", original mame warns that syncrefresh can't be activated without waitvsync. Groovymame does  not display this log message.

Please guys can you help me understand what's going on ?
« Last Edit: April 26, 2017, 06:04:15 pm by tiben »

Calamity

  • Moderator
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 6552
  • Last login:Today at 02:43:53 pm
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #23 on: April 30, 2017, 04:45:10 pm »
Hi tiben,

Thanks for your exhaustive testing. Here's my interpretation:

The only column that's relevant from your table is the rightmost one: -video opengl, -waitvsync, -syncrefresh. And that one shows a total fail.

The reasons why all other columns are irrelevant are, first, you only get the extended features from GM (drm support) when using -video opengl, second, it only makes sense to use GM with -syncrefresh enabled, and this involves -waitvsync already (so -syncrefresh -nowaitvsync is pointless). So don't waste your time with -syncrefresh/-nosyncrefresh/-waitvsync/-nowaitvsync combinations: if it doesn't work with -syncrefresh, it's not working at all.

Now, the reason why it's failing is with all probability that you're trying to target a secondary video card. GM is forced to target /dev/dri/card0 for drm. Hopefully we can do something about this at some point. I couldn't implement it at the time because for the life of me I wasn't able to get GM running on a secondary display using Linux.
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead or pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #24 on: May 18, 2017, 02:39:43 pm »
Thanks Calamity for you reply.

So, after experienced a lot of things including my multi-seat setup, i think the culprit was located between the mesa/dri layer. I upgraded theses packages by using the "Oibaf PPA" https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers which provides more up to date drivers and mesa libraries. This completelly resolved the issues mentionned in this thread (sound and slowdown).
Using groovymame 0.183, the behavior is like expected ie -opengl -syncrefresh -waitvsync. -syncrefresh is now imperative to get perfect vsync.

About `/dev/dri/card0`, two things:

- Chance were during tests explained in previous thread, the kernel defined the nvidia card that was used for 15khz/groovymame to card0. So no issue here.

- By now, i modified my multiseat configuration and the card is now at   `card2`. This does not seems to be an issue, for the tests,  /dev/dri/card2 can be symlinked to /dev/dri/card0 (simply using ln -s).  card0 is moved somewhere else temporarily. What is really crazy (at least for me!) is that if i dont do that, groovymame works well but is not vsynced, or, as i guess, is synced with the radeon GPU. In other words, i think the GPU used for opengl is simply the radeon one (card0), but the display is done through  the nvidia (card2). To be convinced: i simply changed the refresh rate of my radeon using xrandr  while groovymame was launched on the other seat and refresh on Groovymame changed (from 60hz to 50hz for a game at approx 60Hz, the scanning tearing suddenly speed up).

There is unfortunatelly a new issue with -opengl: i have a very small (one or two pixel thick) stable tearing line near the top of the screen. It is not the same as the previous one i had. It does not appear with normal mame build.

This tearing is not present with -soft, that has perfect rendering.

About -soft/-opengl there is something i don't understand. What are the real differences ? I noticed even if i use -video soft,  "libGL.so" seems to be required and groovymame does not start without this library (mame does not start iether). And now the only differences i notice between the two options is the small tearing line with -opengl.
« Last Edit: May 18, 2017, 02:52:43 pm by tiben »

Doozer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 400
  • Last login:Yesterday at 02:34:23 pm
  • Z80 ERROR
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #25 on: May 18, 2017, 03:11:34 pm »
Hi tiben,

It looks to me you have upgraded your xorg server. Not an issue, just add the following line to the ATI device section in xorg.conf.driver

Code: [Select]
        Option "ShadowPrimary" "on"

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #26 on: May 18, 2017, 03:55:40 pm »
Hi Doozer,

my current xorg version is: "xserver-xorg-core 2:1.18.4-1ubuntu6". I tried the parameter in the device section of both my radeon and my nvidia.

Regards to my last remaining tearing issue, it does not seems to change anything unfortunatelly.

What is the purpose of this parameter? i don't find it in "man xorg.conf".


Doozer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 400
  • Last login:Yesterday at 02:34:23 pm
  • Z80 ERROR
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #27 on: May 20, 2017, 03:50:45 am »
Hi Doozer,

my current xorg version is: "xserver-xorg-core 2:1.18.4-1ubuntu6". I tried the parameter in the device section of both my radeon and my nvidia.

Regards to my last remaining tearing issue, it does not seems to change anything unfortunatelly.

What is the purpose of this parameter? i don't find it in "man xorg.conf".

Hi,

The parameter is only useful starting from xorg 1.19. It eliminates the tearing effect due to page flip change that have been introduced with glamor. In your situation, I confirm it is useless.

Code: [Select]
The following driver Options are supported for glamor :

Option "ShadowPrimary" "boolean"

    This option enables a so-called "shadow primary" buffer for fast CPU access to pixel data, and separate scanout buffers for each display controller (CRTC). This may improve performance for some 2D workloads, potentially at the expense of other (e.g. 3D, video) workloads. Note in particular that enabling this option currently disables page flipping. The default is off.

 

tiben

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 40
  • Last login:February 23, 2019, 02:28:16 pm
  • I want to build my own arcade controls!
Re: [Linux] - Speed/sound issues since Groovymame 0.182
« Reply #28 on: May 20, 2017, 09:04:17 am »
I tried to play a little with the code. I don't pretend to understand it all as i am not an opengl guy nor a C developper.

I noticed if i revert back the line 589 in file `src/osd/modules/render/drawogl.cpp`:

Code: [Select]
m_gl_context->SetSwapInterval((video_config.waitvsync && fd == 0) ? 1 : 0);

to

m_gl_context->SetSwapInterval(video_config.waitvsync ? 1 : 0);

The small tearing line at the top of the screen disappears. But i guess it removes some GroovyMame specific optimisations, especially this below of the same file:

Code: [Select]
#ifdef SDLMAME_X11
// wait for vertical retrace
if (video_config.waitvsync && fd)
{
drmVBlank vbl;
memset(&vbl, 0, sizeof(vbl));
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 1;

        drmWaitVBlank(fd, &vbl)

if (drmWaitVBlank(fd, &vbl) != 0)
osd_printf_verbose("drmWaitVBlank failed\n");
}
#endif

This tearing line is noticeable with my radeon too which is my primary card (card0). But on the radeon it can be removed by using "Option TearFree true" in xorg.conf. Unfortunatelly this option doesn't not exist with nouveau drivers.