diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-12-17 22:51:23 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-12-19 21:32:16 +0100 |
| commit | 30c9ecad729397574754163d13253c54a2285a6a (patch) | |
| tree | 4c45b456ac59870fba5c3e7eef42fe88b4f96821 | |
| parent | 0d786493ef12f2d9a6d8a27d2c47b67f2e00c333 (diff) | |
Move sound output driver selection into new preferences tab.
31 files changed, 384 insertions, 128 deletions
diff --git a/graphics/linux/128/dcpomatic2.png b/graphics/linux/128/dcpomatic2.png Binary files differindex ef8484970..6b12c5e60 100644 --- a/graphics/linux/128/dcpomatic2.png +++ b/graphics/linux/128/dcpomatic2.png diff --git a/graphics/linux/16/dcpomatic2.png b/graphics/linux/16/dcpomatic2.png Binary files differindex 2d177e7e3..d6ba7590a 100644 --- a/graphics/linux/16/dcpomatic2.png +++ b/graphics/linux/16/dcpomatic2.png diff --git a/graphics/linux/22/dcpomatic2.png b/graphics/linux/22/dcpomatic2.png Binary files differindex 0f29bbffb..116a7827d 100644 --- a/graphics/linux/22/dcpomatic2.png +++ b/graphics/linux/22/dcpomatic2.png diff --git a/graphics/linux/256/dcpomatic2.png b/graphics/linux/256/dcpomatic2.png Binary files differindex c39b1fe3b..cd0640f12 100644 --- a/graphics/linux/256/dcpomatic2.png +++ b/graphics/linux/256/dcpomatic2.png diff --git a/graphics/linux/32/dcpomatic2.png b/graphics/linux/32/dcpomatic2.png Binary files differindex 7fb1a4140..ee170e469 100644 --- a/graphics/linux/32/dcpomatic2.png +++ b/graphics/linux/32/dcpomatic2.png diff --git a/graphics/linux/48/dcpomatic2.png b/graphics/linux/48/dcpomatic2.png Binary files differindex 5e8aba8e7..8aec7be36 100644 --- a/graphics/linux/48/dcpomatic2.png +++ b/graphics/linux/48/dcpomatic2.png diff --git a/graphics/linux/512/dcpomatic2.png b/graphics/linux/512/dcpomatic2.png Binary files differindex cab55bbe5..f591f1c7e 100644 --- a/graphics/linux/512/dcpomatic2.png +++ b/graphics/linux/512/dcpomatic2.png diff --git a/graphics/linux/64/dcpomatic2.png b/graphics/linux/64/dcpomatic2.png Binary files differindex 40fe43090..685bd9bb9 100644 --- a/graphics/linux/64/dcpomatic2.png +++ b/graphics/linux/64/dcpomatic2.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_128x128.png b/graphics/osx/dcpomatic2.iconset/icon_128x128.png Binary files differindex ef8484970..6b12c5e60 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_128x128.png +++ b/graphics/osx/dcpomatic2.iconset/icon_128x128.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png b/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png Binary files differindex ef8484970..6b12c5e60 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png +++ b/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_16x16.png b/graphics/osx/dcpomatic2.iconset/icon_16x16.png Binary files differindex 2d177e7e3..d6ba7590a 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_16x16.png +++ b/graphics/osx/dcpomatic2.iconset/icon_16x16.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png b/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png Binary files differindex 2d177e7e3..d6ba7590a 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png +++ b/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_256x256.png b/graphics/osx/dcpomatic2.iconset/icon_256x256.png Binary files differindex c39b1fe3b..cd0640f12 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_256x256.png +++ b/graphics/osx/dcpomatic2.iconset/icon_256x256.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png b/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png Binary files differindex c39b1fe3b..cd0640f12 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png +++ b/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_32x32.png b/graphics/osx/dcpomatic2.iconset/icon_32x32.png Binary files differindex 7fb1a4140..ee170e469 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_32x32.png +++ b/graphics/osx/dcpomatic2.iconset/icon_32x32.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png b/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png Binary files differindex 7fb1a4140..ee170e469 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png +++ b/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_512x512.png b/graphics/osx/dcpomatic2.iconset/icon_512x512.png Binary files differindex cab55bbe5..f591f1c7e 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_512x512.png +++ b/graphics/osx/dcpomatic2.iconset/icon_512x512.png diff --git a/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png b/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png Binary files differindex cab55bbe5..f591f1c7e 100644 --- a/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png +++ b/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png diff --git a/graphics/osx/preferences/sound.png b/graphics/osx/preferences/sound.png Binary files differnew file mode 100644 index 000000000..b5a80d7a8 --- /dev/null +++ b/graphics/osx/preferences/sound.png diff --git a/graphics/src/sound.svg b/graphics/src/sound.svg new file mode 100644 index 000000000..0970fc0a8 --- /dev/null +++ b/graphics/src/sound.svg @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg4217" + viewBox="-553676.6 0 0 1052.3622" + version="1.0" + inkscape:version="0.92.3 (2405546, 2018-03-11)" + width="450" + height="450" + sodipodi:docname="sound.svg" + inkscape:export-filename="/home/carl/src/dcpomatic/icons/kdm_email.png" + inkscape:export-xdpi="6.5100002" + inkscape:export-ydpi="6.5100002"> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1025" + id="namedview6320" + showgrid="false" + inkscape:zoom="0.85295919" + inkscape:cx="29.780284" + inkscape:cy="94.540107" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:current-layer="svg4217" /> + <defs + id="defs4219"> + <linearGradient + id="linearGradient3594" + y2="742.5" + gradientUnits="userSpaceOnUse" + x2="-886.76001" + gradientTransform="matrix(-0.84033,-0.84033,-0.84033,0.84033,-405.66871,-1194.2782)" + y1="742.5" + x1="-772.01001"> + <stop + id="stop4687" + stop-color="#fff" + offset="0" /> + <stop + id="stop4689" + stop-color="#fff" + stop-opacity="0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3601" + y2="613.94" + gradientUnits="userSpaceOnUse" + x2="385.04001" + gradientTransform="matrix(0.70711,-0.70711,0.70711,0.70711,-745.96871,253.33182)" + y1="63.870998" + x1="386.39001"> + <stop + id="stop3797" + stop-color="#ffe800" + offset="0" /> + <stop + id="stop3799" + stop-color="#dfb300" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3609" + y2="161.84" + gradientUnits="userSpaceOnUse" + x2="212.92999" + y1="358.29999" + x1="409.38" + gradientTransform="translate(-619.78872,-118.87818)"> + <stop + id="stop4034" + stop-color="#dfb300" + offset="0" /> + <stop + id="stop3374" + stop-color="#dfb300" + offset=".5" /> + <stop + id="stop3376" + stop-color="#dfb300" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3632" + y2="448.35001" + gradientUnits="userSpaceOnUse" + x2="382.89999" + gradientTransform="matrix(0.70711,-0.70711,0.70711,0.70711,-745.96871,253.33182)" + y1="448.35001" + x1="403.63"> + <stop + id="stop3636" + stop-color="#ffe800" + stop-opacity=".39216" + offset="0" /> + <stop + id="stop3638" + stop-color="#dfb300" + stop-opacity=".39216" + offset="1" /> + </linearGradient> + </defs> + <metadata + id="metadata6318"> + <rdf:RDF> + <cc:Work> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <cc:license + rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" /> + <dc:publisher> + <cc:Agent + rdf:about="http://openclipart.org/"> + <dc:title>Openclipart</dc:title> + </cc:Agent> + </dc:publisher> + <dc:title></dc:title> + <dc:date>2007-02-27T15:15:43</dc:date> + <dc:description>A key icon.</dc:description> + <dc:source>http://openclipart.org/detail/3330/key-by-barretr</dc:source> + <dc:creator> + <cc:Agent> + <dc:title>barretr</dc:title> + </cc:Agent> + </dc:creator> + <dc:subject> + <rdf:Bag> + <rdf:li>clip art</rdf:li> + <rdf:li>clipart</rdf:li> + <rdf:li>icon</rdf:li> + <rdf:li>image</rdf:li> + <rdf:li>key</rdf:li> + <rdf:li>media</rdf:li> + <rdf:li>png</rdf:li> + <rdf:li>public domain</rdf:li> + <rdf:li>svg</rdf:li> + </rdf:Bag> + </dc:subject> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/publicdomain/zero/1.0/"> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Reproduction" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Distribution" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /> + </cc:License> + </rdf:RDF> + </metadata> + <rect + style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#ff0000;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;marker:none;enable-background:accumulate" + id="rect6322" + width="442.68826" + height="442.68826" + x="-457.43286" + y="2.3376961" /> + <rect + style="opacity:1;vector-effect:none;fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:25;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-end:none;paint-order:stroke fill markers" + id="rect831" + width="100.12302" + height="152.50291" + x="18.758173" + y="150.65996" /> + <path + style="opacity:1;vector-effect:none;fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:25;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-end:none;paint-order:stroke fill markers" + d="M 252.06369,383.67683 118.88119,303.16287 V 150.65996 L 252.0637,70.146007 Z" + id="path882" + inkscape:connector-curvature="0" /> + <path + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:14;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-end:none;paint-order:stroke fill markers" + id="path897" + sodipodi:type="arc" + sodipodi:cx="188.16844" + sodipodi:cy="226.6599" + sodipodi:rx="169.41022" + sodipodi:ry="169.41022" + sodipodi:start="5.4977871" + sodipodi:end="0.78539816" + d="m 307.95955,106.86878 a 169.41022,169.41022 0 0 1 49.61911,119.79111 169.41022,169.41022 0 0 1 -49.6191,119.79112" + sodipodi:open="true" /> + <path + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#999999;stroke-width:14;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-end:none;paint-order:stroke fill markers" + id="path897-6" + sodipodi:type="arc" + sodipodi:cx="203.15329" + sodipodi:cy="227.77385" + sodipodi:rx="227.83228" + sodipodi:ry="218.6208" + sodipodi:start="5.4977871" + sodipodi:end="0.78539816" + d="M 364.25503,73.18559 A 227.83228,218.6208 0 0 1 430.98557,227.77384 227.83228,218.6208 0 0 1 364.25504,382.3621" + sodipodi:open="true" /> +</svg> diff --git a/graphics/update b/graphics/update index 94cbbf88e..f0d91bf89 100755 --- a/graphics/update +++ b/graphics/update @@ -63,7 +63,7 @@ else # OS X preferences icons # servers.png does not have an SVG version mkdir -p osx/preferences - for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications accounts locations; do + for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications accounts locations sound; do $INKSCAPE osx/preferences/$i.png src/$i.svg -w 32 -h 32 done diff --git a/graphics/web/favicon-128x128.png b/graphics/web/favicon-128x128.png Binary files differindex d67c8921c..658bf796e 100644 --- a/graphics/web/favicon-128x128.png +++ b/graphics/web/favicon-128x128.png diff --git a/graphics/web/favicon-16x16.png b/graphics/web/favicon-16x16.png Binary files differindex 400d4b9b9..68e4f96c4 100644 --- a/graphics/web/favicon-16x16.png +++ b/graphics/web/favicon-16x16.png diff --git a/graphics/web/favicon-256x256.png b/graphics/web/favicon-256x256.png Binary files differindex 82467c213..f5b5e758d 100644 --- a/graphics/web/favicon-256x256.png +++ b/graphics/web/favicon-256x256.png diff --git a/graphics/web/favicon-32x32.png b/graphics/web/favicon-32x32.png Binary files differindex 446338669..75fd6ed71 100644 --- a/graphics/web/favicon-32x32.png +++ b/graphics/web/favicon-32x32.png diff --git a/graphics/web/favicon-64x64.png b/graphics/web/favicon-64x64.png Binary files differindex 3318ae280..f7e5ca6fc 100644 --- a/graphics/web/favicon-64x64.png +++ b/graphics/web/favicon-64x64.png diff --git a/graphics/web/logo.png b/graphics/web/logo.png Binary files differindex c9b04f07e..9a57085b2 100644 --- a/graphics/web/logo.png +++ b/graphics/web/logo.png diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 98a1a1a8e..14948afe8 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -155,36 +155,6 @@ GeneralPage::add_language_controls (wxGridBagSizer* table, int& r) } void -GeneralPage::add_play_sound_controls (wxGridBagSizer* table, int& r) -{ - _sound = new CheckBox (_panel, _("Play sound via")); - table->Add (_sound, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); - _sound_output = new wxChoice (_panel, wxID_ANY); - s->Add (_sound_output, 0); - _sound_output_details = new wxStaticText (_panel, wxID_ANY, wxT("")); - s->Add (_sound_output_details, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, DCPOMATIC_SIZER_X_GAP); - table->Add (s, wxGBPosition(r, 1)); - ++r; - - wxFont font = _sound_output_details->GetFont(); - font.SetStyle (wxFONTSTYLE_ITALIC); - font.SetPointSize (font.GetPointSize() - 1); - _sound_output_details->SetFont (font); - - RtAudio audio (DCPOMATIC_RTAUDIO_API); - for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { - RtAudio::DeviceInfo dev = audio.getDeviceInfo (i); - if (dev.probed && dev.outputChannels > 0) { - _sound_output->Append (std_to_wx (dev.name)); - } - } - - _sound->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::sound_changed, this)); - _sound_output->Bind (wxEVT_CHOICE, bind (&GeneralPage::sound_output_changed, this)); -} - -void GeneralPage::add_update_controls (wxGridBagSizer* table, int& r) { _check_for_updates = new CheckBox (_panel, _("Check for updates on startup")); @@ -233,62 +203,6 @@ GeneralPage::config_changed () checked_set (_check_for_updates, config->check_for_updates ()); checked_set (_check_for_test_updates, config->check_for_test_updates ()); - checked_set (_sound, config->sound ()); - - optional<string> const current_so = get_sound_output (); - optional<string> configured_so; - - if (config->sound_output()) { - configured_so = config->sound_output().get(); - } else { - /* No configured output means we should use the default */ - RtAudio audio (DCPOMATIC_RTAUDIO_API); - try { - configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; - } catch (RtAudioError& e) { - /* Probably no audio devices at all */ - } - } - - if (configured_so && current_so != configured_so) { - /* Update _sound_output with the configured value */ - unsigned int i = 0; - while (i < _sound_output->GetCount()) { - if (_sound_output->GetString(i) == std_to_wx(*configured_so)) { - _sound_output->SetSelection (i); - break; - } - ++i; - } - } - - RtAudio audio (DCPOMATIC_RTAUDIO_API); - - map<int, wxString> apis; - apis[RtAudio::MACOSX_CORE] = _("CoreAudio"); - apis[RtAudio::WINDOWS_ASIO] = _("ASIO"); - apis[RtAudio::WINDOWS_DS] = _("Direct Sound"); - apis[RtAudio::WINDOWS_WASAPI] = _("WASAPI"); - apis[RtAudio::UNIX_JACK] = _("JACK"); - apis[RtAudio::LINUX_ALSA] = _("ALSA"); - apis[RtAudio::LINUX_PULSE] = _("PulseAudio"); - apis[RtAudio::LINUX_OSS] = _("OSS"); - apis[RtAudio::RTAUDIO_DUMMY] = _("Dummy"); - - int channels = 0; - if (configured_so) { - for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { - RtAudio::DeviceInfo info = audio.getDeviceInfo(i); - if (info.name == *configured_so && info.outputChannels > 0) { - channels = info.outputChannels; - } - } - } - - _sound_output_details->SetLabel ( - wxString::Format(_("%d channels on %s"), channels, apis[audio.getCurrentApi()]) - ); - setup_sensitivity (); } @@ -297,19 +211,6 @@ GeneralPage::setup_sensitivity () { _language->Enable (_set_language->GetValue ()); _check_for_test_updates->Enable (_check_for_updates->GetValue ()); - _sound_output->Enable (_sound->GetValue ()); -} - -/** @return Currently-selected preview sound output in the dialogue */ -optional<string> -GeneralPage::get_sound_output () -{ - int const sel = _sound_output->GetSelection (); - if (sel == wxNOT_FOUND) { - return optional<string> (); - } - - return wx_to_std (_sound_output->GetString (sel)); } void @@ -346,24 +247,6 @@ GeneralPage::check_for_test_updates_changed () Config::instance()->set_check_for_test_updates (_check_for_test_updates->GetValue ()); } -void -GeneralPage::sound_changed () -{ - Config::instance()->set_sound (_sound->GetValue ()); -} - -void -GeneralPage::sound_output_changed () -{ - RtAudio audio (DCPOMATIC_RTAUDIO_API); - optional<string> const so = get_sound_output(); - if (!so || *so == audio.getDeviceInfo(audio.getDefaultOutputDevice()).name) { - Config::instance()->unset_sound_output (); - } else { - Config::instance()->set_sound_output (*so); - } -} - CertificateChainEditor::CertificateChainEditor ( wxWindow* parent, wxString title, @@ -965,3 +848,144 @@ KeysPage::export_decryption_certificate () d->Destroy (); } + +wxString +SoundPage::GetName () const +{ + return _("Sound"); +} + +void +SoundPage::setup () +{ + wxGridBagSizer* table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border); + + int r = 0; + + _sound = new CheckBox (_panel, _("Play sound via")); + table->Add (_sound, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _sound_output = new wxChoice (_panel, wxID_ANY); + s->Add (_sound_output, 0); + _sound_output_details = new wxStaticText (_panel, wxID_ANY, wxT("")); + s->Add (_sound_output_details, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, DCPOMATIC_SIZER_X_GAP); + table->Add (s, wxGBPosition(r, 1)); + ++r; + + wxFont font = _sound_output_details->GetFont(); + font.SetStyle (wxFONTSTYLE_ITALIC); + font.SetPointSize (font.GetPointSize() - 1); + _sound_output_details->SetFont (font); + + RtAudio audio (DCPOMATIC_RTAUDIO_API); + for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { + RtAudio::DeviceInfo dev = audio.getDeviceInfo (i); + if (dev.probed && dev.outputChannels > 0) { + _sound_output->Append (std_to_wx (dev.name)); + } + } + + _sound->Bind (wxEVT_CHECKBOX, bind (&SoundPage::sound_changed, this)); + _sound_output->Bind (wxEVT_CHOICE, bind (&SoundPage::sound_output_changed, this)); +} + +void +SoundPage::sound_changed () +{ + Config::instance()->set_sound (_sound->GetValue ()); +} + +void +SoundPage::sound_output_changed () +{ + RtAudio audio (DCPOMATIC_RTAUDIO_API); + optional<string> const so = get_sound_output(); + if (!so || *so == audio.getDeviceInfo(audio.getDefaultOutputDevice()).name) { + Config::instance()->unset_sound_output (); + } else { + Config::instance()->set_sound_output (*so); + } +} + +void +SoundPage::config_changed () +{ + Config* config = Config::instance (); + + checked_set (_sound, config->sound ()); + + optional<string> const current_so = get_sound_output (); + optional<string> configured_so; + + if (config->sound_output()) { + configured_so = config->sound_output().get(); + } else { + /* No configured output means we should use the default */ + RtAudio audio (DCPOMATIC_RTAUDIO_API); + try { + configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; + } catch (RtAudioError& e) { + /* Probably no audio devices at all */ + } + } + + if (configured_so && current_so != configured_so) { + /* Update _sound_output with the configured value */ + unsigned int i = 0; + while (i < _sound_output->GetCount()) { + if (_sound_output->GetString(i) == std_to_wx(*configured_so)) { + _sound_output->SetSelection (i); + break; + } + ++i; + } + } + + RtAudio audio (DCPOMATIC_RTAUDIO_API); + + map<int, wxString> apis; + apis[RtAudio::MACOSX_CORE] = _("CoreAudio"); + apis[RtAudio::WINDOWS_ASIO] = _("ASIO"); + apis[RtAudio::WINDOWS_DS] = _("Direct Sound"); + apis[RtAudio::WINDOWS_WASAPI] = _("WASAPI"); + apis[RtAudio::UNIX_JACK] = _("JACK"); + apis[RtAudio::LINUX_ALSA] = _("ALSA"); + apis[RtAudio::LINUX_PULSE] = _("PulseAudio"); + apis[RtAudio::LINUX_OSS] = _("OSS"); + apis[RtAudio::RTAUDIO_DUMMY] = _("Dummy"); + + int channels = 0; + if (configured_so) { + for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { + RtAudio::DeviceInfo info = audio.getDeviceInfo(i); + if (info.name == *configured_so && info.outputChannels > 0) { + channels = info.outputChannels; + } + } + } + + _sound_output_details->SetLabel ( + wxString::Format(_("%d channels on %s"), channels, apis[audio.getCurrentApi()]) + ); + + setup_sensitivity (); +} + +void +SoundPage::setup_sensitivity () +{ + _sound_output->Enable (_sound->GetValue()); +} + +/** @return Currently-selected preview sound output in the dialogue */ +optional<string> +SoundPage::get_sound_output () +{ + int const sel = _sound_output->GetSelection (); + if (sel == wxNOT_FOUND) { + return optional<string> (); + } + + return wx_to_std (_sound_output->GetString (sel)); +} diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index ac90cd42d..1a9d97a43 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -89,25 +89,18 @@ public: protected: void add_language_controls (wxGridBagSizer* table, int& r); - void add_play_sound_controls (wxGridBagSizer* table, int& r); void add_update_controls (wxGridBagSizer* table, int& r); virtual void config_changed (); private: void setup_sensitivity (); - boost::optional<std::string> get_sound_output (); void set_language_changed (); void language_changed (); void check_for_updates_changed (); void check_for_test_updates_changed (); - void sound_changed (); - void sound_output_changed (); wxCheckBox* _set_language; wxChoice* _language; - wxCheckBox* _sound; - wxChoice* _sound_output; - wxStaticText* _sound_output_details; wxCheckBox* _check_for_updates; wxCheckBox* _check_for_test_updates; }; @@ -185,4 +178,34 @@ private: }; +class SoundPage : public StandardPage +{ +public: + SoundPage (wxSize panel_size, int border) + : StandardPage (panel_size, border) + {} + + wxString GetName() const; + +#ifdef DCPOMATIC_OSX + wxBitmap GetLargeIcon () const + { + return wxBitmap ("sound", wxBITMAP_TYPE_PNG_RESOURCE); + } +#endif + +private: + + void setup (); + void config_changed (); + boost::optional<std::string> get_sound_output (); + void sound_changed (); + void sound_output_changed (); + void setup_sensitivity (); + + wxCheckBox* _sound; + wxChoice* _sound_output; + wxStaticText* _sound_output_details; +}; + #endif diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 1c5a9e3f6..f586672a8 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -116,8 +116,6 @@ private: table->Add (export_cinemas, wxGBPosition (r, 2)); ++r; - add_play_sound_controls (table, r); - #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG _analyse_ebur128 = new CheckBox (_panel, _("Find integrated loudness, true peak and loudness range when analysing audio")); table->Add (_analyse_ebur128, wxGBPosition (r, 0), wxGBSpan (1, 2)); @@ -1678,6 +1676,7 @@ create_full_config_dialog () #endif e->AddPage (new FullGeneralPage (ps, border)); + e->AddPage (new SoundPage (ps, border)); e->AddPage (new DefaultsPage (ps, border)); e->AddPage (new EncodingServersPage (ps, border)); e->AddPage (new KeysPage (ps, border)); diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc index 20ddde992..508b91746 100644 --- a/src/wx/player_config_dialog.cc +++ b/src/wx/player_config_dialog.cc @@ -85,7 +85,6 @@ private: int r = 0; add_language_controls (table, r); - add_play_sound_controls (table, r); add_update_controls (table, r); add_label_to_sizer (table, _panel, _("Start player as"), true, wxGBPosition(r, 0)); @@ -684,6 +683,7 @@ create_player_config_dialog () #endif e->AddPage (new PlayerGeneralPage(wxSize(-1, 500), border)); + e->AddPage (new SoundPage(ps, border)); e->AddPage (new LocationsPage(ps, border)); e->AddPage (new KeysPage(ps, border)); #ifdef DCPOMATIC_VARIANT_SWAROOP |
