Это русская секция форума wxWidjets. В этой секции вы можете обсуждать любые вопросы, связанные с wxWidgets на вашем родном языке.
cutecode
Super wx Problem Solver
Posts: 427 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Thu Sep 26, 2019 8:03 pm
на 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;
}
Attachments
А_12_1.wav.zip
(352.45 KiB) Downloaded 198 times
cutecode
Super wx Problem Solver
Posts: 427 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Sat Sep 28, 2019 10:10 am
вот так это звучит на Линуксе, хотя если просто открыть wav-файл двойным щелчком, он произносится правильно
На винде такой проблемы нет
Attachments
1.mp4.zip
(300.5 KiB) Downloaded 195 times
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Sep 28, 2019 12:01 pm
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
Use the source, Luke!
cutecode
Super wx Problem Solver
Posts: 427 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Sat Sep 28, 2019 12:16 pm
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?
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Sep 28, 2019 1:24 pm
I dont know how to know my sound backend, how to know it?
Add this line to your code:
It should be displayed in the console window.
Use the source, Luke!
cutecode
Super wx Problem Solver
Posts: 427 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Sat Sep 28, 2019 3:27 pm
I launched my App from consol, here is the log trace
Code: Select all
alexander@debian:~/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
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Sep 28, 2019 3:44 pm
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.
Use the source, Luke!
cutecode
Super wx Problem Solver
Posts: 427 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Sat Sep 28, 2019 4:16 pm
Hello,
Code: Select all
alexander@debian:~$ 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
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Sep 28, 2019 5:07 pm
wxSleep(5); did not help
That was not intended as a fix. I just wanted to narrow down the behavior.
Use the source, Luke!