Page 1 of 1

на Линуксе wxSound ну очень быстро

Posted: Thu Sep 26, 2019 8:03 pm
by cutecode
на windows wav-файл проигрывается так, как и надо.
А на Линуксе таже функция пригрывает очень быстро
Можно ли как то исправить?

Code: Select all

bool PlaySound(wxString &sz)
{
	if (!wxFileExists(sz))
	{
		write_message(L"PlaySound() - Файл не существует " + sz);
		return false;
	}

	bool bresult = false;
	wxSound snd(sz);
	if (snd.IsOk())
		bresult = snd.Play();

	return bresult;
}

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 10:10 am
by cutecode
вот так это звучит на Линуксе, хотя если просто открыть wav-файл двойным щелчком, он произносится правильно
На винде такой проблемы нет

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 12:01 pm
by doublemax
This sounds like a bug. The documentation says that if you play the sound asynchronously, it keeps playing even if you destroy the sound object.

What happens if you delay the destruction of the sound object?
What sound backend do you use?

Please run the "sound" sample that comes with wxWidgets and try the "play sound asynchronously (object on stack)". If the same happens there, please open a bug report at http://trac.wxwidgets.org

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 12:16 pm
by cutecode
Hello
I tried wxSOUND_SYNC and wxSOUND_ASYNC - with the same result

I dont know how to know my sound backend, how to know it?

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 1:24 pm
by doublemax
I dont know how to know my sound backend, how to know it?
Add this line to your code:

Code: Select all

wxLog::AddTraceMask("sound");
It should be displayed in the console window.

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 3:27 pm
by cutecode
I launched my App from consol, here is the log trace

Code: Select all

[email protected]:~/Documents/_builds/debug_dll$ ./soft_itUD64
18:25:10: Trace: (sound) using backend 'Open Sound System'
18:25:10: Trace: (sound) asking audio to stop
18:25:10: Trace: (sound) audio was stopped
18:25:10: Trace: (sound) launched async playback thread

(soft_itUD64:21319): Gdk-WARNING **: gdk_window_set_icon_list: icons too large

(soft_itUD64:21319): Gdk-WARNING **: gdk_window_set_icon_list: icons too large
18:25:10: Trace: (sound) Unable to set DSP to mono.
18:25:10: Trace: (sound) terminated async playback thread

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 3:44 pm
by doublemax
Still looks like a bug to me. What wxWidgets version are you using?

Try a sleep after Play() in order to see if destruction of the sound object stops the sound playing. If that's the case please open a bug report.

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 4:16 pm
by cutecode
Hello,

Code: Select all

[email protected]:~$ wx-config --version
3.1.3
wxSleep(5); did not help

as a temporary solution I added this part of code

Code: Select all

#ifdef __WXGTK__
	wxString szShell;
	szShell.Printf(L"aplay %s", sz);
	wxExecute(szShell, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE);
	bresult = true;
#else

Re: на Линуксе wxSound ну очень быстро

Posted: Sat Sep 28, 2019 5:07 pm
by doublemax
wxSleep(5); did not help
That was not intended as a fix. I just wanted to narrow down the behavior.