[beast/devel: 27/27] ALL: remove trailing white spaces
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 27/27] ALL: remove trailing white spaces
- Date: Sun, 23 Dec 2012 17:35:29 +0000 (UTC)
commit 4e9c9795133299ba04c0969f3d43c7c9a8f7bd54
Author: Tim Janik <timj gnu org>
Date: Sun Dec 23 18:23:15 2012 +0100
ALL: remove trailing white spaces
beast-gtk/bstapp.cc | 83 -------
beast-gtk/bstapp.hh | 20 --
beast-gtk/bstasciipixbuf.cc | 23 --
beast-gtk/bstasciipixbuf.hh | 8 -
beast-gtk/bstauxdialogs.cc | 23 --
beast-gtk/bstauxdialogs.hh | 6 -
beast-gtk/bstbseutils.cc | 5 -
beast-gtk/bstbseutils.hh | 7 -
beast-gtk/bstbuseditor.cc | 19 --
beast-gtk/bstbuseditor.hh | 9 -
beast-gtk/bstbusmixer.cc | 20 --
beast-gtk/bstbusmixer.hh | 9 -
beast-gtk/bstbusview.cc | 15 --
beast-gtk/bstbusview.hh | 9 -
beast-gtk/bstcanvaslink.cc | 62 -----
beast-gtk/bstcanvaslink.hh | 18 --
beast-gtk/bstcanvassource.cc | 123 ---------
beast-gtk/bstcanvassource.hh | 14 -
beast-gtk/bstcluehunter.cc | 117 ---------
beast-gtk/bstcluehunter.hh | 21 --
beast-gtk/bstcxxutils.cc | 4 -
beast-gtk/bstcxxutils.hh | 5 -
beast-gtk/bstdbmeter.cc | 102 --------
beast-gtk/bstdbmeter.hh | 9 -
beast-gtk/bstdefs.hh | 20 --
beast-gtk/bstdial.cc | 110 ---------
beast-gtk/bstdial.hh | 20 --
beast-gtk/bsteffectview.cc | 56 -----
beast-gtk/bsteffectview.hh | 16 --
beast-gtk/bsteventroll.cc | 101 --------
beast-gtk/bsteventroll.hh | 18 --
beast-gtk/bsteventrollctrl.cc | 72 ------
beast-gtk/bsteventrollctrl.hh | 8 -
beast-gtk/bstfiledialog.cc | 108 --------
beast-gtk/bstfiledialog.hh | 13 -
beast-gtk/bstgconfig.cc | 41 ---
beast-gtk/bstgconfig.hh | 9 -
beast-gtk/bstgrowbar.cc | 21 --
beast-gtk/bstgrowbar.hh | 11 -
beast-gtk/bstitemseqdialog.cc | 46 ----
beast-gtk/bstitemseqdialog.hh | 11 -
beast-gtk/bstitemview.cc | 56 -----
beast-gtk/bstitemview.hh | 16 --
beast-gtk/bstkeybindings.cc | 45 ----
beast-gtk/bstkeybindings.hh | 8 -
beast-gtk/bstknob.cc | 118 ---------
beast-gtk/bstknob.hh | 14 -
beast-gtk/bstlogadjustment.cc | 36 ---
beast-gtk/bstlogadjustment.hh | 11 -
beast-gtk/bstmain.cc | 55 ----
beast-gtk/bstmenus.cc | 65 -----
beast-gtk/bstmenus.hh | 11 -
beast-gtk/bstmsgabsorb.cc | 34 ---
beast-gtk/bstmsgabsorb.hh | 7 -
beast-gtk/bstparam-automation.cc | 10 -
beast-gtk/bstparam-choice.cc | 10 -
beast-gtk/bstparam-color-spinner.cc | 8 -
beast-gtk/bstparam-item-seq.cc | 6 -
beast-gtk/bstparam-note-sequence.cc | 4 -
beast-gtk/bstparam-note-spinner.cc | 6 -
beast-gtk/bstparam-proxy.cc | 12 -
beast-gtk/bstparam-scale.cc | 5 -
beast-gtk/bstparam-searchpath.cc | 10 -
beast-gtk/bstparam-time.cc | 4 -
beast-gtk/bstparam.cc | 44 ----
beast-gtk/bstparam.hh | 15 --
beast-gtk/bstparamview.cc | 50 ----
beast-gtk/bstparamview.hh | 14 -
beast-gtk/bstpartdialog.cc | 46 ----
beast-gtk/bstpartdialog.hh | 10 -
beast-gtk/bstpartview.cc | 20 --
beast-gtk/bstpartview.hh | 9 -
beast-gtk/bstpatterncolumns.cc | 48 ----
beast-gtk/bstpatterncolumns.hh | 9 -
beast-gtk/bstpatternctrl.cc | 22 --
beast-gtk/bstpatternctrl.hh | 7 -
beast-gtk/bstpatternview.cc | 104 --------
beast-gtk/bstpatternview.hh | 19 --
beast-gtk/bstpianoroll.cc | 131 ----------
beast-gtk/bstpianoroll.hh | 19 --
beast-gtk/bstpianorollctrl.cc | 78 ------
beast-gtk/bstpianorollctrl.hh | 8 -
beast-gtk/bstplayback.cc | 29 ---
beast-gtk/bstplayback.hh | 11 -
beast-gtk/bstplaylist.cc | 82 ------
beast-gtk/bstplaylist.hh | 14 -
beast-gtk/bstpreferences.cc | 67 -----
beast-gtk/bstpreferences.hh | 15 --
beast-gtk/bstprocbrowser.cc | 42 ----
beast-gtk/bstprocbrowser.hh | 16 --
beast-gtk/bstprocedure.cc | 90 -------
beast-gtk/bstprocedure.hh | 14 -
beast-gtk/bstprofiler.cc | 12 -
beast-gtk/bstprofiler.hh | 6 -
beast-gtk/bstprojectctrl.cc | 24 --
beast-gtk/bstprojectctrl.hh | 10 -
beast-gtk/bstqsampler.cc | 167 -------------
beast-gtk/bstqsampler.hh | 21 --
beast-gtk/bstrackeditor-covers.cc | 20 --
beast-gtk/bstrackeditor.cc | 41 ---
beast-gtk/bstrackeditor.hh | 13 -
beast-gtk/bstrackitem.cc | 26 --
beast-gtk/bstrackitem.hh | 11 -
beast-gtk/bstracktable.cc | 125 ----------
beast-gtk/bstracktable.hh | 15 --
beast-gtk/bstrackview.cc | 32 ---
beast-gtk/bstrackview.hh | 10 -
beast-gtk/bstrecords.idl | 11 -
beast-gtk/bstrtest.cc | 33 ---
beast-gtk/bstsampleeditor.cc | 72 ------
beast-gtk/bstsampleeditor.hh | 15 --
beast-gtk/bstscrollgraph.cc | 54 ----
beast-gtk/bstscrollgraph.hh | 7 -
beast-gtk/bstsegment.cc | 15 --
beast-gtk/bstsegment.hh | 8 -
beast-gtk/bstsequence.cc | 43 ----
beast-gtk/bstsequence.hh | 14 -
beast-gtk/bstservermonitor.cc | 19 --
beast-gtk/bstservermonitor.hh | 14 -
beast-gtk/bstskinconfig.cc | 38 ---
beast-gtk/bstskinconfig.hh | 9 -
beast-gtk/bstsnetrouter.cc | 123 ---------
beast-gtk/bstsnetrouter.hh | 16 --
beast-gtk/bstsnifferscope.cc | 31 ---
beast-gtk/bstsnifferscope.hh | 8 -
beast-gtk/bstsplash.cc | 61 -----
beast-gtk/bstsplash.hh | 15 --
beast-gtk/bststest.cc | 96 -------
beast-gtk/bstsupershell.cc | 33 ---
beast-gtk/bstsupershell.hh | 9 -
beast-gtk/bsttrackroll.cc | 127 ----------
beast-gtk/bsttrackroll.hh | 20 --
beast-gtk/bsttrackrollctrl.cc | 51 ----
beast-gtk/bsttrackrollctrl.hh | 9 -
beast-gtk/bsttracksynthdialog.cc | 43 ----
beast-gtk/bsttracksynthdialog.hh | 12 -
beast-gtk/bsttrackview.cc | 68 -----
beast-gtk/bsttrackview.hh | 11 -
beast-gtk/bsttreestores.cc | 48 ----
beast-gtk/bsttreestores.hh | 11 -
beast-gtk/bstusermessage.cc | 47 ----
beast-gtk/bstusermessage.hh | 9 -
beast-gtk/bstutils.cc | 143 -----------
beast-gtk/bstutils.hh | 24 --
beast-gtk/bstwaveeditor.cc | 77 ------
beast-gtk/bstwaveeditor.hh | 15 --
beast-gtk/bstwaveview.cc | 25 --
beast-gtk/bstwaveview.hh | 10 -
beast-gtk/bstxframe.cc | 57 -----
beast-gtk/bstxframe.hh | 12 -
beast-gtk/bstxkb.cc | 24 --
beast-gtk/bstxkb.hh | 11 -
beast-gtk/bstzoomedwindow.cc | 46 ----
beast-gtk/bstzoomedwindow.hh | 14 -
beast-gtk/gxk/glewidgets.c | 285 ---------------------
beast-gtk/gxk/glewidgets.h | 56 -----
beast-gtk/gxk/gxk.hh | 3 -
beast-gtk/gxk/gxkaction.cc | 76 ------
beast-gtk/gxk/gxkaction.hh | 14 -
beast-gtk/gxk/gxkassortment.cc | 50 ----
beast-gtk/gxk/gxkassortment.hh | 9 -
beast-gtk/gxk/gxkauxwidgets.cc | 37 ---
beast-gtk/gxk/gxkauxwidgets.hh | 12 -
beast-gtk/gxk/gxkcanvas.cc | 32 ---
beast-gtk/gxk/gxkcanvas.hh | 6 -
beast-gtk/gxk/gxkcellrendererpopup.cc | 45 ----
beast-gtk/gxk/gxkcellrendererpopup.hh | 16 --
beast-gtk/gxk/gxkdialog.cc | 88 -------
beast-gtk/gxk/gxkdialog.hh | 16 --
beast-gtk/gxk/gxkglobals.cc | 9 -
beast-gtk/gxk/gxkglobals.hh | 24 --
beast-gtk/gxk/gxkimagecache.cc | 12 -
beast-gtk/gxk/gxkimagecache.hh | 8 -
beast-gtk/gxk/gxkled.cc | 36 ---
beast-gtk/gxk/gxkled.hh | 11 -
beast-gtk/gxk/gxklistwrapper.cc | 94 -------
beast-gtk/gxk/gxklistwrapper.hh | 12 -
beast-gtk/gxk/gxklogadjustment.cc | 56 -----
beast-gtk/gxk/gxklogadjustment.hh | 13 -
beast-gtk/gxk/gxkmenubutton.cc | 32 ---
beast-gtk/gxk/gxkmenubutton.hh | 6 -
beast-gtk/gxk/gxknotebook.cc | 25 --
beast-gtk/gxk/gxknotebook.hh | 9 -
beast-gtk/gxk/gxkparam-entry.cc | 4 -
beast-gtk/gxk/gxkparam-label.cc | 4 -
beast-gtk/gxk/gxkparam-scale.cc | 5 -
beast-gtk/gxk/gxkparam-spinner.cc | 4 -
beast-gtk/gxk/gxkparam-toggle.cc | 6 -
beast-gtk/gxk/gxkparam.cc | 88 -------
beast-gtk/gxk/gxkparam.hh | 16 --
beast-gtk/gxk/gxkpolygon.cc | 32 ---
beast-gtk/gxk/gxkpolygon.hh | 9 -
beast-gtk/gxk/gxkrackcovers.cc | 17 --
beast-gtk/gxk/gxkrackeditor.cc | 38 ---
beast-gtk/gxk/gxkrackeditor.hh | 10 -
beast-gtk/gxk/gxkrackitem.cc | 40 ---
beast-gtk/gxk/gxkrackitem.hh | 10 -
beast-gtk/gxk/gxkracktable.cc | 73 ------
beast-gtk/gxk/gxkracktable.hh | 11 -
beast-gtk/gxk/gxkradget.cc | 125 ----------
beast-gtk/gxk/gxkradget.hh | 11 -
beast-gtk/gxk/gxkradgetfactory.cc | 45 ----
beast-gtk/gxk/gxkradgetfactory.hh | 15 --
beast-gtk/gxk/gxkscrollcanvas.cc | 154 ------------
beast-gtk/gxk/gxkscrollcanvas.hh | 9 -
beast-gtk/gxk/gxksimplelabel.cc | 53 ----
beast-gtk/gxk/gxksimplelabel.hh | 8 -
beast-gtk/gxk/gxkspline.cc | 13 -
beast-gtk/gxk/gxkspline.hh | 7 -
beast-gtk/gxk/gxkstatusbar.cc | 44 ----
beast-gtk/gxk/gxkstatusbar.hh | 10 -
beast-gtk/gxk/gxkstock.cc | 49 ----
beast-gtk/gxk/gxkstock.hh | 12 -
beast-gtk/gxk/gxktest.cc | 38 ---
beast-gtk/gxk/gxktexttools.cc | 185 --------------
beast-gtk/gxk/gxktexttools.hh | 11 -
beast-gtk/gxk/gxkutils.cc | 300 -----------------------
beast-gtk/gxk/gxkutils.hh | 28 --
beast-gtk/gxk/splinetest.cc | 8 -
beast-gtk/testgui.cc | 20 --
beast-gtk/tsmview.cc | 13 -
birnet/birnet-zintern.cc | 21 --
birnet/birnet.hh | 5 -
birnet/birnetcdefs.h | 19 --
birnet/birnetcpu.cc | 16 --
birnet/birnetcpu.hh | 7 -
birnet/birnetdebugtools.cc | 7 -
birnet/birnetdebugtools.hh | 6 -
birnet/birnetmath.cc | 2 -
birnet/birnetmath.hh | 6 -
birnet/birnetmsg.cc | 34 ---
birnet/birnetmsg.hh | 8 -
birnet/birnettests.h | 19 --
birnet/birnetthread.cc | 43 ----
birnet/birnetthread.hh | 21 --
birnet/birnetthreadimpl.cc | 139 -----------
birnet/birnetutf8.cc | 33 ---
birnet/birnetutf8.hh | 20 --
birnet/birnetutils.cc | 109 --------
birnet/birnetutils.hh | 33 ---
birnet/tests/datalist.cc | 11 -
birnet/tests/infotest.cc | 11 -
birnet/tests/math.cc | 7 -
birnet/tests/sorting.cc | 6 -
birnet/tests/strings.cc | 14 -
birnet/tests/systest.cc | 7 -
birnet/tests/threads.cc | 72 ------
birnet/tests/utils.cc | 8 -
bse/bse.hh | 6 -
bse/bse.idl | 3 -
bse/bseautodoc.cc | 54 ----
bse/bsebiquadfilter.cc | 48 ----
bse/bsebiquadfilter.hh | 14 -
bse/bseblockutils.cc | 23 --
bse/bseblockutils.hh | 22 --
bse/bsebus.cc | 62 -----
bse/bsebus.hh | 12 -
bse/bsebus.proc | 28 --
bse/bsebusmodule.cc | 4 -
bse/bsebusmodule.idl | 5 -
bse/bsecategories.cc | 55 ----
bse/bsecategories.hh | 10 -
bse/bsecategories.proc | 23 --
bse/bsecompat.cc | 4 -
bse/bsecompat.hh | 8 -
bse/bseconstant.cc | 37 ---
bse/bseconstant.hh | 13 -
bse/bseconstvalues.cc | 2 -
bse/bseconstvalues.hh | 23 --
bse/bsecontainer.cc | 224 -----------------
bse/bsecontainer.hh | 14 -
bse/bsecontainer.proc | 15 --
bse/bsecontextmerger.cc | 30 ---
bse/bsecontextmerger.hh | 9 -
bse/bsecore.cc | 6 -
bse/bsecore.idl | 36 ---
bse/bsecsynth.cc | 18 --
bse/bsecsynth.hh | 10 -
bse/bsecsynth.proc | 4 -
bse/bsecxxarg.cc | 6 -
bse/bsecxxarg.hh | 9 -
bse/bsecxxbase.cc | 47 ----
bse/bsecxxbase.hh | 18 --
bse/bsecxxbase.idl | 4 -
bse/bsecxxclosure.cc | 9 -
bse/bsecxxclosure.hh | 6 -
bse/bsecxxmodule.cc | 49 ----
bse/bsecxxmodule.hh | 11 -
bse/bsecxxmodule.idl | 4 -
bse/bsecxxplugin.cc | 4 -
bse/bsecxxplugin.hh | 23 --
bse/bsecxxutils.cc | 13 -
bse/bsecxxutils.hh | 18 --
bse/bsecxxvalue.cc | 16 --
bse/bsecxxvalue.hh | 8 -
bse/bsedatahandle-fir.cc | 51 ----
bse/bsedatahandle-resample.cc | 57 -----
bse/bsedatapocket.cc | 109 --------
bse/bsedatapocket.hh | 15 --
bse/bsedatapocket.proc | 57 -----
bse/bsedefs.hh | 17 --
bse/bsedevice.cc | 36 ---
bse/bsedevice.hh | 12 -
bse/bseeditablesample.cc | 35 ---
bse/bseeditablesample.hh | 15 --
bse/bseeditablesample.proc | 39 ---
bse/bseengine.cc | 175 -------------
bse/bseengine.hh | 16 --
bse/bseenginemaster.cc | 90 -------
bse/bseenginemaster.hh | 5 -
bse/bseenginenode.hh | 17 --
bse/bseengineschedule.cc | 72 ------
bse/bseengineschedule.hh | 7 -
bse/bseengineutils.cc | 85 -------
bse/bseengineutils.hh | 11 -
bse/bseenums.cc | 15 --
bse/bseenums.hh | 11 -
bse/bseenums.proc | 13 -
bse/bseexports.hh | 20 --
bse/bsefilter-ellf.cc | 74 ------
bse/bsefilter.cc | 8 -
bse/bsefilter.hh | 15 --
bse/bsegconfig.cc | 15 --
bse/bsegconfig.hh | 5 -
bse/bsegenclosures.hh | 18 --
bse/bseglobals.cc | 18 --
bse/bseglobals.hh | 12 -
bse/bseglue.cc | 112 ---------
bse/bseglue.hh | 10 -
bse/bseieee754.hh | 25 --
bse/bseincluder.hh | 5 -
bse/bseinfo.cc | 13 -
bse/bseinstrument.hh | 16 --
bse/bseinstrumentinput.cc | 22 --
bse/bseinstrumentinput.hh | 10 -
bse/bseinstrumentoutput.cc | 22 --
bse/bseinstrumentoutput.hh | 9 -
bse/bseitem.cc | 162 ------------
bse/bseitem.hh | 17 --
bse/bseitem.proc | 126 ----------
bse/bsejanitor.cc | 73 ------
bse/bsejanitor.hh | 10 -
bse/bsejanitor.proc | 69 ------
bse/bseladspa.cc | 64 -----
bse/bseladspa.hh | 9 -
bse/bseladspamodule.cc | 39 ---
bse/bseladspamodule.hh | 8 -
bse/bseloader-aiff.cc | 37 ---
bse/bseloader-bsewave.cc | 44 ----
bse/bseloader-guspatch.cc | 86 -------
bse/bseloader-mad.cc | 22 --
bse/bseloader-oggvorbis.cc | 22 --
bse/bseloader-wav.cc | 57 -----
bse/bseloader.cc | 61 -----
bse/bseloader.hh | 15 --
bse/bsemain.cc | 68 -----
bse/bsemain.hh | 13 -
bse/bsemath.cc | 30 ---
bse/bsemath.hh | 24 --
bse/bsemathsignal.cc | 60 -----
bse/bsemathsignal.hh | 78 ------
bse/bsemidicontroller.cc | 42 ----
bse/bsemidicontroller.hh | 12 -
bse/bsemididecoder.cc | 24 --
bse/bsemididecoder.hh | 10 -
bse/bsemididevice-null.cc | 19 --
bse/bsemididevice-null.hh | 6 -
bse/bsemididevice-oss.cc | 37 ---
bse/bsemididevice-oss.hh | 9 -
bse/bsemididevice.cc | 19 --
bse/bsemididevice.hh | 12 -
bse/bsemidievent.cc | 33 ---
bse/bsemidievent.hh | 14 -
bse/bsemidifile.cc | 13 -
bse/bsemidifile.hh | 6 -
bse/bsemidiinput.cc | 42 ----
bse/bsemidiinput.hh | 12 -
bse/bsemidinotifier.cc | 25 --
bse/bsemidinotifier.hh | 11 -
bse/bsemidinotifier.proc | 7 -
bse/bsemidireceiver.cc | 193 ---------------
bse/bsemidireceiver.hh | 9 -
bse/bsemidisynth.cc | 48 ----
bse/bsemidisynth.hh | 11 -
bse/bsemidivoice.cc | 58 -----
bse/bsemidivoice.hh | 12 -
bse/bsenote.cc | 31 ---
bse/bsenote.hh | 11 -
bse/bseobject.cc | 112 ---------
bse/bseobject.hh | 15 --
bse/bseparam.cc | 17 --
bse/bseparam.hh | 13 -
bse/bseparasite.cc | 59 -----
bse/bseparasite.hh | 7 -
bse/bseparasite.proc | 5 -
bse/bsepart.cc | 178 --------------
bse/bsepart.hh | 23 --
bse/bsepart.proc | 129 ----------
bse/bsepattern.hh | 28 --
bse/bsepatterngroup.hh | 15 --
bse/bsepcmdevice-null.cc | 18 --
bse/bsepcmdevice-null.hh | 7 -
bse/bsepcmdevice-oss.cc | 71 ------
bse/bsepcmdevice-oss.hh | 12 -
bse/bsepcmdevice.cc | 35 ---
bse/bsepcmdevice.hh | 16 --
bse/bsepcminput.cc | 40 ---
bse/bsepcminput.hh | 12 -
bse/bsepcmmodule.cc | 33 ---
bse/bsepcmoutput.cc | 40 ---
bse/bsepcmoutput.hh | 16 --
bse/bsepcmwriter.cc | 28 --
bse/bsepcmwriter.hh | 10 -
bse/bseplugin.cc | 68 -----
bse/bseplugin.hh | 13 -
bse/bseprobe.cc | 26 --
bse/bseprobe.idl | 5 -
bse/bseprocedure.cc | 74 ------
bse/bseprocedure.hh | 18 --
bse/bseprocedure.proc | 44 ----
bse/bseprocidl.cc | 61 -----
bse/bseproject.cc | 138 -----------
bse/bseproject.hh | 15 --
bse/bseproject.proc | 154 ------------
bse/bsequery.cc | 40 ---
bse/bseresampler.cc | 22 --
bse/bseresampler.hh | 17 --
bse/bseresamplerimpl.hh | 41 ---
bse/bsescripthelper.cc | 33 ---
bse/bsescripthelper.hh | 8 -
bse/bsescripthelper.proc | 8 -
bse/bsesequencer.cc | 37 ---
bse/bsesequencer.hh | 7 -
bse/bseserver.cc | 150 -----------
bse/bseserver.hh | 15 --
bse/bseserver.proc | 76 ------
bse/bsesnet.cc | 147 -----------
bse/bsesnet.hh | 17 --
bse/bsesnet.proc | 22 --
bse/bsesnooper.cc | 33 ---
bse/bsesnooper.hh | 11 -
bse/bsesong.cc | 94 -------
bse/bsesong.hh | 19 --
bse/bsesong.proc | 63 -----
bse/bsesource.cc | 248 -------------------
bse/bsesource.hh | 20 --
bse/bsesource.proc | 111 ---------
bse/bsestandardosc.cc | 51 ----
bse/bsestandardosc.hh | 12 -
bse/bsestandardsynths.cc | 15 --
bse/bsestandardsynths.hh | 8 -
bse/bsestorage.cc | 237 ------------------
bse/bsestorage.hh | 22 --
bse/bsesubiport.cc | 45 ----
bse/bsesubiport.hh | 7 -
bse/bsesuboport.cc | 45 ----
bse/bsesuboport.hh | 7 -
bse/bsesubsynth.cc | 66 -----
bse/bsesubsynth.hh | 10 -
bse/bsesuper.cc | 27 --
bse/bsesuper.hh | 15 --
bse/bsetrack.cc | 113 ---------
bse/bsetrack.hh | 14 -
bse/bsetrack.proc | 47 ----
bse/bsetype.cc | 51 ----
bse/bsetype.hh | 21 --
bse/bseundostack.cc | 49 ----
bse/bseundostack.hh | 11 -
bse/bseutils.cc | 70 ------
bse/bseutils.hh | 21 --
bse/bsewave.cc | 79 ------
bse/bsewave.hh | 14 -
bse/bsewave.proc | 25 --
bse/bsewaveosc.cc | 66 -----
bse/bsewaveosc.hh | 12 -
bse/bsewaveosc.proc | 12 -
bse/bsewaverepo.cc | 33 ---
bse/bsewaverepo.hh | 13 -
bse/bsewaverepo.proc | 21 --
bse/gslcommon.cc | 39 ---
bse/gslcommon.hh | 14 -
bse/gsldatacache.cc | 74 ------
bse/gsldatacache.hh | 9 -
bse/gsldatahandle-mad.cc | 111 ---------
bse/gsldatahandle-mad.hh | 5 -
bse/gsldatahandle-vorbis.cc | 62 -----
bse/gsldatahandle-vorbis.hh | 7 -
bse/gsldatahandle.cc | 218 ----------------
bse/gsldatahandle.hh | 24 --
bse/gsldatautils.cc | 112 ---------
bse/gsldatautils.hh | 38 ---
bse/gsldefs.hh | 12 -
bse/gslfft.hh | 14 -
bse/gslfilehash.cc | 58 -----
bse/gslfilehash.hh | 12 -
bse/gslfilter.cc | 188 --------------
bse/gslfilter.hh | 34 ---
bse/gslincluder.hh | 8 -
bse/gslmagic.cc | 82 ------
bse/gslmagic.hh | 13 -
bse/gsloscillator-aux.cc | 14 -
bse/gsloscillator.cc | 26 --
bse/gsloscillator.hh | 11 -
bse/gslosctable.cc | 72 ------
bse/gslosctable.hh | 13 -
bse/gslvorbis-cutter.cc | 28 --
bse/gslvorbis-cutter.hh | 6 -
bse/gslvorbis-enc.cc | 62 -----
bse/gslvorbis-enc.hh | 8 -
bse/gslwavechunk.cc | 60 -----
bse/gslwavechunk.hh | 13 -
bse/gslwaveosc-aux.cc | 13 -
bse/gslwaveosc.cc | 48 ----
bse/gslwaveosc.hh | 16 --
bse/ladspa.hh | 120 ---------
bse/tests/blocktests.cc | 90 -------
bse/tests/filtertest.cc | 49 ----
bse/tests/firhandle.cc | 65 -----
bse/tests/loophandle.cc | 31 ---
bse/tests/misctests.cc | 11 -
bse/tests/resamplehandle.cc | 65 -----
bse/tests/subnormals-aux.cc | 5 -
bse/tests/subnormals.cc | 30 ---
bse/tests/testcxx.cc | 10 -
bse/tests/testfft.cc | 63 -----
drivers/bse-portaudio/bsepcmdevice-portaudio.cc | 45 ----
drivers/bse-portaudio/bsepcmdevice-portaudio.hh | 6 -
drivers/bsemididevice-alsa.cc | 28 --
drivers/bsemididevice-alsa.hh | 6 -
drivers/bsepcmdevice-alsa.cc | 45 ----
drivers/bsepcmdevice-alsa.hh | 6 -
launchers/beaststart.c | 2 -
launchers/bseshstart.c | 2 -
launchers/suidmain.c | 14 -
launchers/suidmain.h | 4 -
library/scripts/mixer-splitup-by-track.scm | 7 -
library/scripts/modules2grid.scm | 2 -
library/scripts/part-harmonic-transposer.scm | 22 --
library/scripts/progressor-example.scm | 3 -
library/scripts/record-midi.scm | 2 -
library/scripts/song-parts-operations.scm | 7 -
plugins/artscompressor.cc | 17 --
plugins/artscompressor.idl | 5 -
plugins/bseadder.cc | 36 ---
plugins/bseadder.hh | 14 -
plugins/bseamplifier.cc | 9 -
plugins/bseamplifier.idl | 4 -
plugins/bseatandistort.cc | 31 ---
plugins/bseatandistort.hh | 13 -
plugins/bsebalance.cc | 4 -
plugins/bsebalance.idl | 3 -
plugins/bseblockutils.cc | 10 -
plugins/bsecontribsampleandhold.cc | 9 -
plugins/bsecontribsampleandhold.idl | 1 -
plugins/bsefirfilter.c | 56 -----
plugins/bsefirfilter.hh | 20 --
plugins/bseiirfilter.cc | 41 ---
plugins/bseiirfilter.hh | 14 -
plugins/bsemixer.cc | 37 ---
plugins/bsemixer.hh | 16 --
plugins/bsemult.cc | 18 --
plugins/bsemult.hh | 14 -
plugins/bsenoise.cc | 14 -
plugins/bsenoise.idl | 3 -
plugins/bsequantizer.cc | 4 -
plugins/bsequantizer.idl | 3 -
plugins/bsesequencer.cc | 49 ----
plugins/bsesequencer.hh | 13 -
plugins/bsesimpleadsr-aux.cc | 6 -
plugins/bsesimpleadsr.cc | 40 ---
plugins/bsesimpleadsr.hh | 10 -
plugins/bsesummation.cc | 4 -
plugins/bsesummation.idl | 3 -
plugins/davbassfilter.cc | 6 -
plugins/davbassfilter.idl | 4 -
plugins/davcanyondelay.cc | 44 ----
plugins/davcanyondelay.hh | 11 -
plugins/davchorus.cc | 11 -
plugins/davchorus.idl | 3 -
plugins/davguitar.c | 89 -------
plugins/davguitar.hh | 16 --
plugins/davorgan.cc | 16 --
plugins/davorgan.idl | 3 -
plugins/davsyndrum.cc | 39 ---
plugins/davsyndrum.hh | 8 -
plugins/davxtalstrings.cc | 52 ----
plugins/davxtalstrings.hh | 13 -
plugins/evaluator/bseevaluator.cc | 17 --
plugins/evaluator/bseevaluator.idl | 4 -
plugins/evaluator/compiler.cc | 20 --
plugins/evaluator/compiler.hh | 8 -
plugins/evaluator/cpu.cc | 18 --
plugins/evaluator/cpu.hh | 10 -
plugins/evaluator/evaluateexpr.cc | 10 -
plugins/evaluator/instruction.cc | 7 -
plugins/evaluator/instruction.hh | 14 -
plugins/evaluator/symbols.hh | 12 -
plugins/evaluator/token.hh | 11 -
plugins/freeverb/bsefreeverb.cc | 34 ---
plugins/freeverb/bsefreeverb.hh | 13 -
plugins/freeverb/bsefreeverbcpp.hh | 8 -
plugins/freeverb/denormals.hh | 4 -
plugins/freeverb/tuning.hh | 6 -
plugins/icons/adsr.c | 3 -
plugins/icons/any.c | 2 -
plugins/icons/atan.c | 3 -
plugins/icons/canyon.c | 3 -
plugins/icons/drum.c | 3 -
plugins/icons/filter.c | 3 -
plugins/icons/genosc.c | 2 -
plugins/icons/mixer.c | 3 -
plugins/icons/multiply.c | 3 -
plugins/icons/noise.c | 3 -
plugins/icons/organ.c | 3 -
plugins/icons/osc.c | 2 -
plugins/icons/pipe.c | 2 -
plugins/icons/reverb.c | 3 -
plugins/icons/sequencer.c | 3 -
plugins/icons/sine.c | 2 -
plugins/icons/speaker.c | 2 -
plugins/icons/strings.c | 3 -
plugins/icons/sub.c | 3 -
plugins/icons/sum.c | 3 -
plugins/standardguspatchenvelope.cc | 41 ---
plugins/standardguspatchenvelope.idl | 6 -
plugins/standardsaturator.cc | 5 -
plugins/standardsaturator.idl | 4 -
r+d-files/bse-ellf.c | 241 ------------------
r+d-files/transpose_freq.scm | 3 -
sfi/gbsearcharray.hh | 35 ---
sfi/glib-extra.cc | 119 ---------
sfi/glib-extra.hh | 44 ----
sfi/sfi.hh | 3 -
sfi/sficomport.cc | 62 -----
sfi/sficomport.hh | 14 -
sfi/sficomwire.cc | 131 ----------
sfi/sficomwire.hh | 25 --
sfi/sficxx.cc | 6 -
sfi/sficxx.hh | 24 --
sfi/sfidl-cbase.cc | 89 -------
sfi/sfidl-cbase.hh | 28 --
sfi/sfidl-clientc.cc | 43 ----
sfi/sfidl-clientc.hh | 9 -
sfi/sfidl-clientcxx.cc | 78 ------
sfi/sfidl-clientcxx.hh | 13 -
sfi/sfidl-corec.cc | 72 ------
sfi/sfidl-corecxx.cc | 69 ------
sfi/sfidl-cxxbase.cc | 10 -
sfi/sfidl-cxxbase.hh | 7 -
sfi/sfidl-factory.cc | 6 -
sfi/sfidl-factory.hh | 11 -
sfi/sfidl-generator.cc | 37 ---
sfi/sfidl-generator.hh | 18 --
sfi/sfidl-hostc.cc | 46 ----
sfi/sfidl-hostc.hh | 9 -
sfi/sfidl-namespace.cc | 22 --
sfi/sfidl-namespace.hh | 12 -
sfi/sfidl-options.cc | 32 ---
sfi/sfidl-options.hh | 9 -
sfi/sfidl-parser.cc | 263 --------------------
sfi/sfidl-parser.hh | 59 -----
sfi/sfidl-typelist.cc | 10 -
sfi/sfidl-utils.hh | 8 -
sfi/sfidl.cc | 11 -
sfi/sfifilecrawler.cc | 49 ----
sfi/sfifilecrawler.hh | 12 -
sfi/sfiglue.cc | 133 ----------
sfi/sfiglue.hh | 23 --
sfi/sfigluecodec.cc | 125 ----------
sfi/sfigluecodec.hh | 15 --
sfi/sfiglueproxy.cc | 117 ---------
sfi/sfiglueproxy.hh | 12 -
sfi/sfimemory.cc | 27 --
sfi/sfimemory.hh | 11 -
sfi/sfinote.cc | 23 --
sfi/sfinote.hh | 17 --
sfi/sfiparams.cc | 192 ---------------
sfi/sfiparams.hh | 29 ---
sfi/sfiprimitives.cc | 171 -------------
sfi/sfiprimitives.hh | 13 -
sfi/sfiring.cc | 99 --------
sfi/sfiring.hh | 12 -
sfi/sfiserial.cc | 34 ---
sfi/sfiserial.hh | 12 -
sfi/sfistore.cc | 119 ---------
sfi/sfistore.hh | 14 -
sfi/sfitests.hh | 4 -
sfi/sfitime.cc | 55 ----
sfi/sfitime.hh | 11 -
sfi/sfitypes.cc | 26 --
sfi/sfitypes.hh | 11 -
sfi/sfiustore.cc | 45 ----
sfi/sfiustore.hh | 15 --
sfi/sfivalues.cc | 116 ---------
sfi/sfivalues.hh | 23 --
sfi/sfivmarshal.cc | 10 -
sfi/sfivmarshal.hh | 10 -
sfi/sfiwrapper.cc | 34 ---
sfi/sfiwrapper.hh | 19 --
sfi/tests/misctests.cc | 63 -----
sfi/tests/ring.cc | 23 --
sfi/tests/testcxx.cc | 8 -
sfi/tests/testidl.idl | 10 -
sfi/tests/testsfidl.cc | 26 --
sfi/toyprof-mem.c | 29 ---
sfi/toyprof-mem.hh | 7 -
sfi/toyprof.c | 82 ------
sfi/toyprof.hh | 12 -
shell/bsescm.cc | 31 ---
shell/bsescminterp.cc | 141 -----------
shell/bsescminterp.hh | 10 -
tests/audio/bse2wav.scm | 6 -
tests/bse/cxxbinding.cc | 18 --
tests/bse/filtertest.cc | 47 ----
tests/bse/testplugin.cc | 8 -
tests/bse/testplugin.idl | 9 -
tests/filecheck/checkproject.scm | 3 -
tests/latency/bselatencytest.cc | 19 --
tests/latency/bselatencytest.idl | 6 -
tests/latency/bseplay.scm | 1 -
tests/perftest.cc | 13 -
tests/testresampler.cc | 55 ----
tests/testresamplerq.cc | 27 --
tests/testwavechunk.c | 46 ----
tools/bsefcompare.cc | 111 ---------
tools/bsefextract.cc | 225 -----------------
tools/bseloopfuncs.cc | 84 -------
tools/bseloopfuncs.hh | 9 -
tools/bsewavetool.cc | 152 ------------
tools/bsewavetool.hh | 3 -
tools/bwtwave.cc | 32 ---
tools/bwtwave.hh | 6 -
tools/cutvorbis.cc | 10 -
tools/magictest.cc | 8 -
tools/mathtool.cc | 59 -----
tools/scripts/noteplaytest.scm | 5 -
tools/scripts/waveloadtest.scm | 5 -
tools/sfiutils.cc | 48 ----
tools/sfiutils.hh | 11 -
topconfig.h | 2 -
740 files changed, 0 insertions(+), 25089 deletions(-)
---
diff --git a/beast-gtk/bstapp.cc b/beast-gtk/bstapp.cc
index 80cfdd0..164be1e 100644
--- a/beast-gtk/bstapp.cc
+++ b/beast-gtk/bstapp.cc
@@ -16,8 +16,6 @@
#include "bstprofiler.hh"
#include "bstusermessage.hh"
#include <string.h>
-
-
/* --- prototypes --- */
static void bst_app_run_script_proc (gpointer data,
gulong category_id);
@@ -29,8 +27,6 @@ static gboolean app_action_check (gpointer data,
gulong action,
guint64 action_stamp);
static void bst_app_reload_pages (BstApp *self);
-
-
/* --- menus --- */
enum {
ACTION_INTERNALS = BST_ACTION_APP_LAST,
@@ -187,14 +183,10 @@ static const GxkStockAction demo_dialogs[] = {
{ "Demo Debug Dialog", NULL, "Fire up a debug dialog for demonstration purposes",
ACTION_DEMO_DIALOG_DEBUG, BST_STOCK_DIAG },
};
-
/* --- variables --- */
static BstAppClass *bst_app_class = NULL;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstApp, bst_app, GXK_TYPE_DIALOG);
-
static void
bst_app_register (BstApp *app)
{
@@ -213,9 +205,7 @@ bst_app_init (BstApp *self)
GtkWidget *widget = GTK_WIDGET (self);
BseCategorySeq *cseq;
GxkActionList *al1, *al2;
-
self->cookie = g_strdup ("");
-
g_object_set (self,
"name", "BEAST-Application",
"allow_shrink", TRUE,
@@ -225,7 +215,6 @@ bst_app_init (BstApp *self)
bst_app_register (self);
self->box = gxk_radget_create ("beast", "application-box", NULL);
gtk_container_add (GTK_CONTAINER (GXK_DIALOG (self)->vbox), (GtkWidget*) self->box);
-
/* publish widget specific actions */
gxk_widget_publish_actions (self, "file-open", G_N_ELEMENTS (file_open_actions), file_open_actions,
NULL, app_action_check, app_action_exec);
@@ -292,15 +281,12 @@ bst_app_init (BstApp *self)
al1 = skin_entries_create (self);
gxk_action_list_sort (al1);
gxk_widget_publish_action_list (widget, "skin-options", al1);
-
/* setup playback controls */
self->pcontrols = (GtkWidget*) g_object_new (BST_TYPE_PROJECT_CTRL, NULL);
gxk_radget_add (self->box, "control-area", self->pcontrols);
-
/* setup project pages */
self->ppages = gxk_assortment_new ();
gxk_widget_publish_assortment (widget, "project-pages", self->ppages);
-
/* setup WAVE file entry */
// gxk_radget_add (self->box, "control-area", gxk_vseparator_space_new (TRUE));
self->wave_file = bst_param_new_proxy (bse_proxy_get_pspec (BSE_SERVER, "wave_file"), BSE_SERVER);
@@ -313,7 +299,6 @@ bst_app_init (BstApp *self)
NULL));
gxk_radget_add (self->box, "export-area-file-entry", gxk_param_create_editor (self->wave_file, NULL));
gxk_param_update (self->wave_file);
-
/* setup the main notebook */
self->notebook = (GtkNotebook*) gxk_radget_find (self->box, "main-notebook");
gxk_nullify_in_object (self, &self->notebook);
@@ -321,21 +306,17 @@ bst_app_init (BstApp *self)
"swapped_signal_after::switch-page", gxk_widget_update_actions, self,
NULL);
}
-
static void
bst_app_destroy (GtkObject *object)
{
BstApp *self = BST_APP (object);
-
if (self->wave_file)
{
gxk_param_destroy (self->wave_file);
self->wave_file = NULL;
}
-
if (self->rack_dialog)
gtk_widget_destroy (self->rack_dialog);
-
if (self->project)
{
if (self->pcontrols)
@@ -348,26 +329,20 @@ bst_app_destroy (GtkObject *object)
bse_item_unuse (self->project);
self->project = 0;
}
-
if (self->ppages)
gxk_assortment_dispose (self->ppages);
-
bst_app_unregister (self);
-
GTK_OBJECT_CLASS (bst_app_parent_class)->destroy (object);
-
if (!bst_app_class->apps && bst_app_class->seen_apps)
{
bst_app_class->seen_apps = FALSE;
BST_MAIN_LOOP_QUIT ();
}
}
-
static void
bst_app_finalize (GObject *object)
{
BstApp *self = BST_APP (object);
-
if (self->project)
{
bse_proxy_disconnect (self->project,
@@ -384,18 +359,14 @@ bst_app_finalize (GObject *object)
self->ppages = NULL;
}
g_free (self->cookie);
-
G_OBJECT_CLASS (bst_app_parent_class)->finalize (object);
}
-
BstApp*
bst_app_new (SfiProxy project)
{
g_return_val_if_fail (BSE_IS_PROJECT (project), NULL);
-
BstApp *self = (BstApp*) g_object_new (BST_TYPE_APP, NULL);
gxk_dialog_set_sizes (GXK_DIALOG (self), 500, 400, 950, 800);
-
self->project = project;
bse_item_use (self->project);
bse_proxy_connect (self->project,
@@ -407,33 +378,25 @@ bst_app_new (SfiProxy project)
bst_window_sync_title_to_proxy (GXK_DIALOG (self), self->project, "%s");
if (self->pcontrols)
bst_project_ctrl_set_project (BST_PROJECT_CTRL (self->pcontrols), self->project);
-
bst_app_reload_pages (self);
-
/* update menu entries
*/
gxk_widget_update_actions (self);
-
return self;
}
-
BstApp*
bst_app_find (SfiProxy project)
{
GSList *slist;
-
g_return_val_if_fail (BSE_IS_PROJECT (project), NULL);
-
for (slist = bst_app_class->apps; slist; slist = slist->next)
{
BstApp *app = (BstApp*) slist->data;
-
if (app->project == project)
return app;
}
return NULL;
}
-
static SfiProxy
bst_app_get_current_super (BstApp *app)
{
@@ -449,7 +412,6 @@ bst_app_get_current_super (BstApp *app)
}
return 0;
}
-
static gint
proxy_rate_item (SfiProxy p)
{
@@ -463,7 +425,6 @@ proxy_rate_item (SfiProxy p)
return 3;
return 5;
}
-
static void
app_update_page_item (SfiProxy item,
const gchar *property_name,
@@ -477,7 +438,6 @@ app_update_page_item (SfiProxy item,
gxk_assortment_changed (self->ppages, entry);
}
}
-
static void
ppage_item_free (gpointer user_data,
GObject *object,
@@ -490,7 +450,6 @@ ppage_item_free (gpointer user_data,
gtk_widget_destroy (GTK_WIDGET (object));
bse_item_unuse (item);
}
-
static void
bst_app_add_page_item (BstApp *self,
guint position,
@@ -533,7 +492,6 @@ bst_app_add_page_item (BstApp *self,
g_object_unref (page);
g_free (tip);
}
-
static gint
proxyp_cmp_items (gconstpointer v1,
gconstpointer v2,
@@ -545,17 +503,14 @@ proxyp_cmp_items (gconstpointer v1,
return 0;
return proxy_rate_item (*p1) - proxy_rate_item (*p2);
}
-
static void
bst_app_reload_pages (BstApp *self)
{
g_return_if_fail (BST_IS_APP (self));
-
GtkWidget *old_focus = GTK_WINDOW (self)->focus_widget;
if (old_focus)
gtk_widget_ref (old_focus);
SfiProxy old_item = self->ppages->selected ? (SfiProxy) self->ppages->selected->user_data : 0;
-
/* collect page objects */
BseItemSeq *iseq = bse_project_get_supers (self->project);
SfiRing *ring, *proxies = NULL;
@@ -565,7 +520,6 @@ bst_app_reload_pages (BstApp *self)
proxies = sfi_ring_append (proxies, iseq->items + i);
/* sort proxies */
proxies = sfi_ring_sort (proxies, proxyp_cmp_items, NULL);
-
/* remove outdated project pages */
SfiRing *outdated = NULL;
GSList *slist;
@@ -586,7 +540,6 @@ bst_app_reload_pages (BstApp *self)
GxkAssortmentEntry *entry = (GxkAssortmentEntry*) sfi_ring_pop_head (&outdated);
gxk_assortment_remove (self->ppages, entry);
}
-
/* add missing project pages */
SfiProxy first_unseen = 0, first_synth = 0;
i = 0;
@@ -602,7 +555,6 @@ bst_app_reload_pages (BstApp *self)
if (!first_synth && BSE_IS_SNET (item))
first_synth = item;
}
-
/* select/restore current page */
if (first_unseen && self->select_unseen_super)
gxk_assortment_select_data (self->ppages, (void*) first_unseen);
@@ -620,7 +572,6 @@ bst_app_reload_pages (BstApp *self)
gtk_widget_unref (old_focus);
}
}
-
static gboolean
bst_app_handle_delete_event (GtkWidget *widget,
GdkEventAny *event)
@@ -650,29 +601,23 @@ bst_app_handle_delete_event (GtkWidget *widget,
gtk_widget_destroy (widget);
return TRUE;
}
-
static void
rebuild_super_shell (BstSuperShell *super_shell)
{
SfiProxy proxy;
-
g_return_if_fail (BST_IS_SUPER_SHELL (super_shell));
-
proxy = super_shell->super;
bse_item_use (proxy);
bst_super_shell_set_super (super_shell, 0);
bst_super_shell_set_super (super_shell, proxy);
bse_item_unuse (proxy);
}
-
typedef struct {
gchar *file;
gchar *name;
} DemoEntry;
-
static DemoEntry *demo_entries = NULL;
static guint n_demo_entries = 0;
-
static int
demo_entries_compare (const void *v1,
const void *v2)
@@ -681,7 +626,6 @@ demo_entries_compare (const void *v1,
const DemoEntry *d2 = (const DemoEntry*) v2;
return strcmp (d1->file, d2->file);
}
-
static void
demo_entries_setup (void)
{
@@ -712,7 +656,6 @@ demo_entries_setup (void)
qsort (demo_entries, n_demo_entries, sizeof (demo_entries[0]), demo_entries_compare);
}
}
-
static void
demo_play_song (gpointer data,
gulong callback_action)
@@ -734,7 +677,6 @@ demo_play_song (gpointer data,
}
bse_item_unuse (project);
}
-
static GxkActionList*
demo_entries_create (BstApp *app)
{
@@ -747,10 +689,8 @@ demo_entries_create (BstApp *app)
NULL, demo_play_song, app);
return alist;
}
-
static DemoEntry *skin_entries = NULL;
static guint n_skin_entries = 0;
-
static void
skin_entries_setup (void)
{
@@ -781,7 +721,6 @@ skin_entries_setup (void)
}
}
}
-
static void
load_skin (gpointer data,
gulong callback_action)
@@ -790,7 +729,6 @@ load_skin (gpointer data,
BseErrorType error = bst_skin_parse (file_name);
bst_status_eprintf (error, _("Loading skin `%s'"), file_name);
}
-
static GxkActionList*
skin_entries_create (BstApp *app)
{
@@ -803,7 +741,6 @@ skin_entries_create (BstApp *app)
NULL, load_skin, app);
return alist;
}
-
static void
bst_app_run_script_proc (gpointer data,
gulong category_id)
@@ -812,7 +749,6 @@ bst_app_run_script_proc (gpointer data,
BseCategory *cat = bse_category_from_id (category_id);
SfiProxy super = bst_app_get_current_super (self);
const gchar *song = "", *wave_repo = "", *snet = "", *csynth = "";
-
if (BSE_IS_SONG (super))
song = "song";
else if (BSE_IS_WAVE_REPO (super))
@@ -823,7 +759,6 @@ bst_app_run_script_proc (gpointer data,
if (BSE_IS_CSYNTH (super))
csynth = "custom-synth";
}
-
bst_procedure_exec_auto (cat->type,
"project", SFI_TYPE_PROXY, self->project,
song, SFI_TYPE_PROXY, super,
@@ -832,14 +767,12 @@ bst_app_run_script_proc (gpointer data,
csynth, SFI_TYPE_PROXY, super,
NULL);
}
-
void
bst_app_show_release_notes (BstApp *app)
{
if (app_action_check (app, ACTION_HELP_RELEASE_NOTES, gxk_action_inc_cache_stamp()))
app_action_exec (app, ACTION_HELP_RELEASE_NOTES);
}
-
static void
app_action_exec (gpointer data,
gulong action)
@@ -848,9 +781,7 @@ app_action_exec (gpointer data,
BstApp *self = BST_APP (data);
const gchar *docs_url = NULL, *docs_title = "";
GtkWidget *widget = GTK_WIDGET (self);
-
gxk_status_window_push (widget);
-
switch (action)
{
SfiProxy proxy;
@@ -860,7 +791,6 @@ app_action_exec (gpointer data,
if (bst_app_class)
{
GSList *slist, *free_slist = g_slist_copy (bst_app_class->apps);
-
for (slist = free_slist; slist; slist = slist->next)
gxk_toplevel_delete ((GtkWidget*) slist->data);
g_slist_free (free_slist);
@@ -874,11 +804,9 @@ app_action_exec (gpointer data,
{
SfiProxy project = bse_server_use_new_project (BSE_SERVER, "Untitled.bse");
BstApp *new_app;
-
bse_project_get_wave_repo (project);
new_app = bst_app_new (project);
bse_item_unuse (project);
-
gxk_idle_show_widget (GTK_WIDGET (new_app));
}
break;
@@ -953,7 +881,6 @@ app_action_exec (gpointer data,
BstRackEditor *ed = (BstRackEditor*) g_object_new (BST_TYPE_RACK_EDITOR,
"visible", TRUE,
NULL);
-
self->rack_editor = (GtkWidget*) g_object_connect (ed, "swapped_signal::destroy", g_nullify_pointer, &self->rack_editor, NULL);
bst_rack_editor_set_rack_view (ed, bse_project_get_data_pocket (self->project, "BEAST-Rack-View"));
self->rack_dialog = (GtkWidget*) gxk_dialog_new (&self->rack_dialog,
@@ -994,7 +921,6 @@ app_action_exec (gpointer data,
if (!bst_proc_browser)
{
GtkWidget *widget;
-
widget = bst_proc_browser_new ();
gtk_widget_show (widget);
bst_proc_browser = gxk_dialog_new (&bst_proc_browser,
@@ -1126,12 +1052,9 @@ app_action_exec (gpointer data,
g_assert_not_reached ();
break;
}
-
gxk_status_window_pop ();
-
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
app_action_check (gpointer data,
gulong action,
@@ -1227,21 +1150,15 @@ app_action_check (gpointer data,
return FALSE;
}
}
-
static void
bst_app_class_init (BstAppClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
bst_app_class = klass;
-
gobject_class->finalize = bst_app_finalize;
-
object_class->destroy = bst_app_destroy;
-
widget_class->delete_event = bst_app_handle_delete_event;
-
klass->apps = NULL;
}
diff --git a/beast-gtk/bstapp.hh b/beast-gtk/bstapp.hh
index 6570c4e..cb1814b 100644
--- a/beast-gtk/bstapp.hh
+++ b/beast-gtk/bstapp.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_APP_H__
#define __BST_APP_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_APP (bst_app_get_type ())
#define BST_APP(object) (GTK_CHECK_CAST ((object), BST_TYPE_APP, BstApp))
@@ -13,33 +10,22 @@ G_BEGIN_DECLS
#define BST_IS_APP(object) (GTK_CHECK_TYPE ((object), BST_TYPE_APP))
#define BST_IS_APP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_APP))
#define BST_APP_GET_CLASS(app) (G_TYPE_INSTANCE_GET_CLASS ((app), BST_TYPE_APP, BstAppClass))
-
-
/* --- typedefs --- */
typedef struct _BstApp BstApp;
typedef struct _BstAppClass BstAppClass;
-
-
/* --- structures --- */
struct _BstApp
{
GxkDialog window;
-
SfiProxy project;
-
guint select_unseen_super : 1;
-
gchar *cookie;
-
GxkParam *wave_file;
-
GxkRadget *box;
GtkNotebook *notebook;
-
GtkWidget *rack_dialog;
GtkWidget *rack_editor;
GtkWidget *pcontrols;
-
GxkAssortment *ppages;
};
struct _BstAppClass
@@ -48,8 +34,6 @@ struct _BstAppClass
gboolean seen_apps;
GSList *apps;
};
-
-
/* --- actions --- */
enum {
BST_ACTION_APP_NONE,
@@ -89,15 +73,11 @@ enum {
/* last value */
BST_ACTION_APP_LAST
};
-
-
/* --- prototypes --- */
GType bst_app_get_type (void);
BstApp* bst_app_new (SfiProxy project);
void bst_app_create_default (BstApp *app);
BstApp* bst_app_find (SfiProxy project);
void bst_app_show_release_notes (BstApp *app);
-
G_END_DECLS
-
#endif /* __BST_APP_H__ */
diff --git a/beast-gtk/bstasciipixbuf.cc b/beast-gtk/bstasciipixbuf.cc
index 1046ae0..1f90856 100644
--- a/beast-gtk/bstasciipixbuf.cc
+++ b/beast-gtk/bstasciipixbuf.cc
@@ -1,15 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstasciipixbuf.hh"
-
-
/* --- prototypes --- */
static GdkPixbuf* ascii_pixbuf_create (void);
-
-
/* --- variables --- */
static GdkPixbuf *ascii_pixbuf = NULL;
-
-
/* --- functions --- */
void
bst_ascii_pixbuf_ref (void)
@@ -22,17 +16,14 @@ bst_ascii_pixbuf_ref (void)
else
g_object_ref (ascii_pixbuf);
}
-
static void
bst_ascii_pixbuf_child_destroy (guint8 *pixels,
gpointer data)
{
GdkPixbuf *pixbuf = (GdkPixbuf*) data;
-
g_return_if_fail (pixbuf == ascii_pixbuf);
g_object_unref (pixbuf);
}
-
GdkPixbuf*
bst_ascii_pixbuf_new (gchar character,
guint char_width,
@@ -41,9 +32,7 @@ bst_ascii_pixbuf_new (gchar character,
GdkPixbuf *pixbuf;
guint width, i;
guint8 *pixels;
-
g_return_val_if_fail (character >= 32 && character <= 126, NULL);
-
bst_ascii_pixbuf_ref ();
width = gdk_pixbuf_get_width (ascii_pixbuf);
width /= 126 - 32 + 1;
@@ -63,26 +52,19 @@ bst_ascii_pixbuf_new (gchar character,
if (char_width != width || char_height != gdk_pixbuf_get_height (pixbuf))
{
GdkPixbuf *tmp_pixbuf = pixbuf;
-
pixbuf = gdk_pixbuf_scale_simple (pixbuf, char_width, char_height, GDK_INTERP_HYPER);
g_object_unref (tmp_pixbuf);
}
bst_ascii_pixbuf_unref ();
-
return pixbuf;
}
-
void
bst_ascii_pixbuf_unref (void)
{
g_return_if_fail (ascii_pixbuf != NULL);
-
g_object_unref (ascii_pixbuf);
}
-
-
/* --- image data --- */
-
/* inlined pixbuf image containing character bitmaps for ascii 32 up to ascii 126.
* created with the gimp, by drawing a text string:
* for i in `seq 32 126` ; do OCT=`printf '\%o' $i` ; echo -ne "$OCT" ; done ; echo
@@ -91,10 +73,7 @@ bst_ascii_pixbuf_unref (void)
* into an apropriate size.
* image size is width=95*12 by height=24, characters are 12 pixels wide
*/
-
-
/* GdkPixbuf RGB C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 ascii_font_pixdata[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -740,8 +719,6 @@ static const guint8 ascii_font_pixdata[] =
"\336\0\0\0\0\202\0\0\0\377\236\0\0\0\0\202\0\0\0\377\377\0\0\0\0\377"
"\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0"
"\377\0\0\0\0\377\0\0\0\0\232\0\0\0\0"};
-
-
static GdkPixbuf*
ascii_pixbuf_create (void)
{
diff --git a/beast-gtk/bstasciipixbuf.hh b/beast-gtk/bstasciipixbuf.hh
index 07c1c8f..94bb8d1 100644
--- a/beast-gtk/bstasciipixbuf.hh
+++ b/beast-gtk/bstasciipixbuf.hh
@@ -1,24 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_ASCII_PIXBUF_H__
#define __BST_ASCII_PIXBUF_H__
-
#include <gtk/gtk.h>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
void bst_ascii_pixbuf_ref (void);
GdkPixbuf* bst_ascii_pixbuf_new (gchar character,
guint char_width,
guint char_height);
void bst_ascii_pixbuf_unref (void);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_ASCII_PIXBUF_H__ */
diff --git a/beast-gtk/bstauxdialogs.cc b/beast-gtk/bstauxdialogs.cc
index 382be45..eaf7fdb 100644
--- a/beast-gtk/bstauxdialogs.cc
+++ b/beast-gtk/bstauxdialogs.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstauxdialogs.hh"
#include <gdk/gdkkeysyms.h>
-
-
/* --- list popup dialog --- */
static GSList *list_popups = NULL;
static void
@@ -16,13 +14,11 @@ tree_view_remove_selection (GtkTreeView *tview)
else
bst_gui_error_bell (tview);
}
-
static void
widget_flag_data_valid (GtkWidget *dialog)
{
g_object_set_long (dialog, "data-valid", 1);
}
-
static void
ensure_list_popups (void)
{
@@ -69,13 +65,11 @@ ensure_list_popups (void)
list_popups = g_slist_prepend (list_popups, dialog);
}
}
-
typedef struct {
GCallback handler;
gpointer data;
GDestroyNotify destroy;
} CustomPopupData;
-
static void
bst_list_popup_hidden (GtkWidget *dialog,
CustomPopupData *data)
@@ -106,7 +100,6 @@ bst_list_popup_hidden (GtkWidget *dialog,
g_free (data);
list_popups = g_slist_prepend (list_popups, dialog);
}
-
GtkWidget*
bst_list_popup_new (const gchar *title,
GtkWidget *transient_parent,
@@ -137,7 +130,6 @@ bst_list_popup_new (const gchar *title,
}
return dialog;
}
-
void
bst_list_popup_add (GtkWidget *dialog,
const gchar *string)
@@ -151,11 +143,8 @@ bst_list_popup_add (GtkWidget *dialog,
0, string,
-1);
}
-
-
/* --- enable activates-default --- */
static void colorsel_enable_activates_default (GtkWidget *widget);
-
static gboolean
idle_activate_toplevel (gpointer data)
{
@@ -166,7 +155,6 @@ idle_activate_toplevel (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static gboolean
colorsel_drawing_area_key_event (GtkWidget *widget,
GdkEvent *event)
@@ -177,14 +165,12 @@ colorsel_drawing_area_key_event (GtkWidget *widget,
g_idle_add (idle_activate_toplevel, g_object_ref (widget));
return FALSE;
}
-
static void
recurse_set_activates_default (GtkWidget *child,
gpointer user_data)
{
colorsel_enable_activates_default (child);
}
-
static void
colorsel_enable_activates_default (GtkWidget *widget)
{
@@ -198,8 +184,6 @@ colorsel_enable_activates_default (GtkWidget *widget)
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), recurse_set_activates_default, NULL);
}
-
-
/* --- color popup dialog --- */
static GSList *color_popups = NULL;
static void
@@ -231,7 +215,6 @@ ensure_color_popups (void)
color_popups = g_slist_prepend (color_popups, dialog);
}
}
-
static void
color_popup_hidden (GtkWidget *dialog,
CustomPopupData *data)
@@ -250,7 +233,6 @@ color_popup_hidden (GtkWidget *dialog,
g_free (data);
color_popups = g_slist_prepend (color_popups, dialog);
}
-
GtkWidget*
bst_color_popup_new (const gchar *title,
GtkWidget *transient_parent,
@@ -280,8 +262,6 @@ bst_color_popup_new (const gchar *title,
}
return dialog;
}
-
-
/* --- key grabber dialog --- */
gboolean
bst_key_combo_valid (guint keyval,
@@ -301,11 +281,9 @@ bst_key_combo_valid (guint keyval,
return TRUE;
return FALSE;
}
-
static guint grab_key_keyval;
static GdkModifierType grab_key_modifier;
static gboolean grab_key_valid;
-
static gboolean
grab_key_event (GtkWidget *window,
GdkEvent *event)
@@ -333,7 +311,6 @@ grab_key_event (GtkWidget *window,
}
return !GTK_WIDGET_VISIBLE (window);
}
-
gboolean
bst_key_combo_popup (const gchar *function,
guint *keyval,
diff --git a/beast-gtk/bstauxdialogs.hh b/beast-gtk/bstauxdialogs.hh
index 9f39550..bea265d 100644
--- a/beast-gtk/bstauxdialogs.hh
+++ b/beast-gtk/bstauxdialogs.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_AUX_DIALOGS_H__
#define __BST_AUX_DIALOGS_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- list popup dialog --- */
typedef void (*BstListPopupHandler) (GtkWidget *dialog,
gchar **strings,
@@ -31,8 +28,5 @@ gboolean bst_key_combo_valid (guint keyval,
gboolean bst_key_combo_popup (const gchar *function,
guint *keyval,
GdkModifierType *modifier);
-
-
G_END_DECLS
-
#endif /* __BST_AUX_DIALOGS_H__ */
diff --git a/beast-gtk/bstbseutils.cc b/beast-gtk/bstbseutils.cc
index 7bbdc7a..0cfff5c 100644
--- a/beast-gtk/bstbseutils.cc
+++ b/beast-gtk/bstbseutils.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstbseutils.hh"
-
/* --- BEAST utilities --- */
BseErrorType
bst_project_restore_from_file (SfiProxy project,
@@ -34,7 +33,6 @@ bst_project_restore_from_file (SfiProxy project,
bse_project_clean_dirty (project);
return error;
}
-
BseErrorType
bst_project_import_midi_file (SfiProxy project,
const gchar *file_name)
@@ -55,7 +53,6 @@ bst_project_import_midi_file (SfiProxy project,
}
return error;
}
-
const gchar*
bst_procedure_get_title (const gchar *procedure)
{
@@ -67,7 +64,5 @@ bst_procedure_get_title (const gchar *procedure)
}
return NULL;
}
-
-
/* --- generated code --- */
#include "bstgenbseapi.cc"
diff --git a/beast-gtk/bstbseutils.hh b/beast-gtk/bstbseutils.hh
index 948e287..b2986f7 100644
--- a/beast-gtk/bstbseutils.hh
+++ b/beast-gtk/bstbseutils.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_BSE_UTILS_H__
#define __BST_BSE_UTILS_H__
-
#include <sfi/sfi.hh> /* needed by bstgenbseapi.h */
-
G_BEGIN_DECLS
-
#include "bstgenbseapi.h" /* include this within extern "C" */
-
/* --- BSE utilities --- */
#define BSE_SERVER (1 /* HACK */ )
#define bse_proxy_set_property sfi_glue_proxy_set_property
@@ -28,7 +24,6 @@ G_BEGIN_DECLS
#define bse_proxy_get_data(p,n) bse_proxy_get_qdata ((p), g_quark_try_string (n))
#define bse_proxy_steal_data(p,n) bse_proxy_steal_qdata ((p), g_quark_try_string (n))
#define bse_proxy_set_data_full(p,n,d,f) bse_proxy_set_qdata_full ((p), g_quark_from_string (n), (d), (f))
-
/* --- BEAST utilities --- */
BseErrorType bst_project_restore_from_file (SfiProxy project,
const gchar *file_name,
@@ -37,7 +32,5 @@ BseErrorType bst_project_restore_from_file (SfiProxy project,
BseErrorType bst_project_import_midi_file (SfiProxy project,
const gchar *file_name);
const gchar* bst_procedure_get_title (const gchar *procedure);
-
G_END_DECLS
-
#endif /* __BST_BSE_UTILS_H__ */
diff --git a/beast-gtk/bstbuseditor.cc b/beast-gtk/bstbuseditor.cc
index 6d9d2e1..e47a340 100644
--- a/beast-gtk/bstbuseditor.cc
+++ b/beast-gtk/bstbuseditor.cc
@@ -3,16 +3,12 @@
#include "bstparam.hh"
#include "bstitemseqdialog.hh" // FIXME
#include "bstsnifferscope.hh" // FIXME
-
-
/* --- prototypes --- */
static void bus_editor_action_exec (gpointer data,
gulong action);
static gboolean bus_editor_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
/* --- bus actions --- */
enum {
ACTION_ADD_BUS,
@@ -24,11 +20,8 @@ static const GxkStockAction bus_editor_actions[] = {
{ N_("Delete"), NULL, NULL, ACTION_DELETE_BUS, BST_STOCK_TRASHCAN },
{ N_("Editor"), NULL, NULL, ACTION_EDIT_BUS, BST_STOCK_PART_EDITOR },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstBusEditor, bst_bus_editor, GTK_TYPE_ALIGNMENT);
-
static void
bst_bus_editor_init (BstBusEditor *self)
{
@@ -39,7 +32,6 @@ bst_bus_editor_init (BstBusEditor *self)
G_N_ELEMENTS (bus_editor_actions), bus_editor_actions,
NULL, bus_editor_action_check, bus_editor_action_exec);
}
-
static void
bst_bus_editor_destroy (GtkObject *object)
{
@@ -47,7 +39,6 @@ bst_bus_editor_destroy (GtkObject *object)
bst_bus_editor_set_bus (self, 0);
GTK_OBJECT_CLASS (bst_bus_editor_parent_class)->destroy (object);
}
-
static void
bst_bus_editor_finalize (GObject *object)
{
@@ -55,7 +46,6 @@ bst_bus_editor_finalize (GObject *object)
bst_bus_editor_set_bus (self, 0);
G_OBJECT_CLASS (bst_bus_editor_parent_class)->finalize (object);
}
-
GtkWidget*
bst_bus_editor_new (SfiProxy bus)
{
@@ -65,7 +55,6 @@ bst_bus_editor_new (SfiProxy bus)
bst_bus_editor_set_bus (self, bus);
return widget;
}
-
static void
bus_editor_release_item (SfiProxy item,
BstBusEditor *self)
@@ -73,7 +62,6 @@ bus_editor_release_item (SfiProxy item,
g_assert (self->item == item);
bst_bus_editor_set_bus (self, 0);
}
-
static void
bus_probes_notify (SfiProxy bus,
SfiSeq *sseq,
@@ -96,7 +84,6 @@ bus_probes_notify (SfiProxy bus,
bst_source_queue_probe_request (self->item, 1, BST_SOURCE_PROBE_ENERGIE, 20.0);
bse_probe_seq_free (pseq);
}
-
static GtkWidget*
bus_build_param (BstBusEditor *self,
const gchar *property,
@@ -112,14 +99,12 @@ bus_build_param (BstBusEditor *self,
g_object_set (gxk_parent_find_descendant (ewidget, GTK_TYPE_LABEL), "label", label, NULL);
return ewidget;
}
-
static gboolean
grab_focus_and_false (GtkWidget *widget)
{
gtk_widget_grab_focus (widget);
return FALSE;
}
-
void
bst_bus_editor_set_bus (BstBusEditor *self,
SfiProxy item)
@@ -190,7 +175,6 @@ bst_bus_editor_set_bus (BstBusEditor *self,
bst_source_queue_probe_request (self->item, 1, BST_SOURCE_PROBE_ENERGIE, 20.0);
}
}
-
static void
bus_editor_action_exec (gpointer data,
gulong action)
@@ -207,7 +191,6 @@ bus_editor_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
bus_editor_action_check (gpointer data,
gulong action,
@@ -224,13 +207,11 @@ bus_editor_action_check (gpointer data,
return FALSE;
}
}
-
static void
bst_bus_editor_class_init (BstBusEditorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_bus_editor_finalize;
object_class->destroy = bst_bus_editor_destroy;
}
diff --git a/beast-gtk/bstbuseditor.hh b/beast-gtk/bstbuseditor.hh
index e24ae89..c4d5b64 100644
--- a/beast-gtk/bstbuseditor.hh
+++ b/beast-gtk/bstbuseditor.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_BUS_EDITOR_H__
#define __BST_BUS_EDITOR_H__
-
#include "bstitemview.hh"
#include "bstdbmeter.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_BUS_EDITOR (bst_bus_editor_get_type ())
#define BST_BUS_EDITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_BUS_EDITOR, BstBusEditor))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BST_IS_BUS_EDITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_BUS_EDITOR))
#define BST_IS_BUS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_BUS_EDITOR))
#define BST_BUS_EDITOR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_BUS_EDITOR, BstBusEditorClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstBusEditor BstBusEditor;
typedef struct _BstBusEditorClass BstBusEditorClass;
@@ -30,14 +25,10 @@ struct _BstBusEditorClass
{
GtkAlignmentClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_bus_editor_get_type (void);
GtkWidget* bst_bus_editor_new (SfiProxy song);
void bst_bus_editor_set_bus (BstBusEditor *self,
SfiProxy item);
-
G_END_DECLS
-
#endif /* __BST_BUS_EDITOR_H__ */
diff --git a/beast-gtk/bstbusmixer.cc b/beast-gtk/bstbusmixer.cc
index 7dd8d30..386c440 100644
--- a/beast-gtk/bstbusmixer.cc
+++ b/beast-gtk/bstbusmixer.cc
@@ -1,16 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstbusmixer.hh"
#include "bstbuseditor.hh"
-
-
/* --- prototypes --- */
static void bus_mixer_action_exec (gpointer data,
gulong action);
static gboolean bus_mixer_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
/* --- bus actions --- */
enum {
ACTION_ADD_BUS,
@@ -20,14 +16,11 @@ static const GxkStockAction bus_mixer_actions[] = {
{ N_("Add"), NULL, N_("Add a new bus to the mixer"), ACTION_ADD_BUS, BST_STOCK_BUS_ADD },
{ N_("Delete"), NULL, N_("Delete the currently selected bus"), ACTION_DELETE_BUS, BST_STOCK_TRASHCAN },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstBusMixer, bst_bus_mixer, BST_TYPE_ITEM_VIEW);
#define HPAD (3)
#define HSPACING (1)
#define YPAD (2 * HPAD)
-
static gboolean
canvas_box_expose_event (GtkWidget *widget,
GdkEventExpose *event,
@@ -49,7 +42,6 @@ canvas_box_expose_event (GtkWidget *widget,
}
return FALSE;
}
-
static void
bus_mixer_add (BstBusMixer *self,
GtkWidget *widget)
@@ -59,7 +51,6 @@ bus_mixer_add (BstBusMixer *self,
gtk_box_pack_start (self->hbox, widget, FALSE, TRUE, 0);
gxk_widget_update_actions (self);
}
-
static void
bst_bus_mixer_init (BstBusMixer *self)
{
@@ -78,20 +69,15 @@ bst_bus_mixer_init (BstBusMixer *self)
GxkRadget *bdesc = gxk_radget_create ("beast", "bus-description", NULL);
bus_mixer_add (self, (GtkWidget*) bdesc);
}
-
GtkWidget*
bst_bus_mixer_new (SfiProxy song)
{
GtkWidget *bus_mixer;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
bus_mixer = gtk_widget_new (BST_TYPE_BUS_MIXER, NULL);
bst_item_view_set_container (BST_ITEM_VIEW (bus_mixer), song);
-
return bus_mixer;
}
-
static void
bus_mixer_item_added (SfiProxy container,
SfiProxy item,
@@ -106,7 +92,6 @@ bus_mixer_item_added (SfiProxy container,
bus_mixer_add (self, be);
}
}
-
static void
bus_mixer_item_removed (SfiProxy unused1,
SfiProxy item,
@@ -133,7 +118,6 @@ bus_mixer_item_removed (SfiProxy unused1,
gxk_widget_update_actions (self);
}
}
-
static void
bus_mixer_set_container (BstItemView *iview,
SfiProxy container)
@@ -164,7 +148,6 @@ bus_mixer_set_container (BstItemView *iview,
bus_mixer_item_added (iview->container, iseq->items[i], self);
}
}
-
static void
bus_mixer_action_exec (gpointer data,
gulong action)
@@ -194,7 +177,6 @@ bus_mixer_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
bus_mixer_action_check (gpointer data,
gulong action,
@@ -219,12 +201,10 @@ bus_mixer_action_check (gpointer data,
return FALSE;
}
}
-
static void
bst_bus_mixer_class_init (BstBusMixerClass *klass)
{
BstItemViewClass *iview_class = BST_ITEM_VIEW_CLASS (klass);
-
iview_class->item_type = "BseBus";
iview_class->set_container = bus_mixer_set_container;
}
diff --git a/beast-gtk/bstbusmixer.hh b/beast-gtk/bstbusmixer.hh
index 1b1f7f0..eedadde 100644
--- a/beast-gtk/bstbusmixer.hh
+++ b/beast-gtk/bstbusmixer.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_BUS_MIXER_H__
#define __BST_BUS_MIXER_H__
-
#include "bstitemview.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_BUS_MIXER (bst_bus_mixer_get_type ())
#define BST_BUS_MIXER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_BUS_MIXER, BstBusMixer))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_BUS_MIXER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_BUS_MIXER))
#define BST_IS_BUS_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_BUS_MIXER))
#define BST_BUS_MIXER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_BUS_MIXER, BstBusMixerClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstBusMixer BstBusMixer;
typedef struct _BstBusMixerClass BstBusMixerClass;
@@ -28,12 +23,8 @@ struct _BstBusMixerClass
{
BstItemViewClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_bus_mixer_get_type (void);
GtkWidget* bst_bus_mixer_new (SfiProxy song);
-
G_END_DECLS
-
#endif /* __BST_BUS_MIXER_H__ */
diff --git a/beast-gtk/bstbusview.cc b/beast-gtk/bstbusview.cc
index 0d3139d..dbc05ea 100644
--- a/beast-gtk/bstbusview.cc
+++ b/beast-gtk/bstbusview.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstbusview.hh"
-
-
/* --- prototypes --- */
static void bus_view_action_exec (gpointer data,
gulong action);
static gboolean bus_view_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
/* --- bus actions --- */
enum {
ACTION_ADD_BUS,
@@ -19,19 +15,14 @@ static const GxkStockAction bus_view_actions[] = {
{ N_("Add"), NULL, NULL, ACTION_ADD_BUS, BST_STOCK_NO_ICON },
{ N_("Delete"), NULL, NULL, ACTION_DELETE_BUS, BST_STOCK_TRASHCAN },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstBusView, bst_bus_view, BST_TYPE_ITEM_VIEW);
-
static void
bst_bus_view_class_init (BstBusViewClass *klass)
{
BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (klass);
-
item_view_class->item_type = "BseBus";
}
-
static void
bst_bus_view_init (BstBusView *self)
{
@@ -48,20 +39,15 @@ bst_bus_view_init (BstBusView *self)
/* create property editor */
bst_item_view_build_param_view (iview, (GtkContainer*) gxk_radget_find (radget, "property-area"));
}
-
GtkWidget*
bst_bus_view_new (SfiProxy song)
{
GtkWidget *bus_view;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
bus_view = gtk_widget_new (BST_TYPE_BUS_VIEW, NULL);
bst_item_view_set_container (BST_ITEM_VIEW (bus_view), song);
-
return bus_view;
}
-
static void
bus_view_action_exec (gpointer data,
gulong action)
@@ -83,7 +69,6 @@ bus_view_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
bus_view_action_check (gpointer data,
gulong action,
diff --git a/beast-gtk/bstbusview.hh b/beast-gtk/bstbusview.hh
index 1500d86..4b37f88 100644
--- a/beast-gtk/bstbusview.hh
+++ b/beast-gtk/bstbusview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_BUS_VIEW_H__
#define __BST_BUS_VIEW_H__
-
#include "bstitemview.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_BUS_VIEW (bst_bus_view_get_type ())
#define BST_BUS_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_BUS_VIEW, BstBusView))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_BUS_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_BUS_VIEW))
#define BST_IS_BUS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_BUS_VIEW))
#define BST_BUS_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_BUS_VIEW, BstBusViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstBusView BstBusView;
typedef struct _BstBusViewClass BstBusViewClass;
@@ -26,12 +21,8 @@ struct _BstBusViewClass
{
BstItemViewClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_bus_view_get_type (void);
GtkWidget* bst_bus_view_new (SfiProxy song);
-
G_END_DECLS
-
#endif /* __BST_BUS_VIEW_H__ */
diff --git a/beast-gtk/bstcanvaslink.cc b/beast-gtk/bstcanvaslink.cc
index 0c63ded..46e0a21 100644
--- a/beast-gtk/bstcanvaslink.cc
+++ b/beast-gtk/bstcanvaslink.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstcanvaslink.hh"
-
#include <math.h>
-
#define ARROW_LENGTH (12.0)
#define ARROW_WIDTH (6.0)
#define TAG_DIAMETER (2.0)
-
-
/* --- prototypes --- */
static void bst_canvas_link_adjust_arrow (BstCanvasLink *clink);
static void bst_canvas_link_adjust_tags (BstCanvasLink *clink);
@@ -15,11 +11,8 @@ static gboolean bst_canvas_link_child_event (GnomeCanvasItem *item,
GdkEvent *event);
static void bst_canvas_link_update (BstCanvasLink *clink);
static gboolean bst_canvas_link_build_async (gpointer data);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstCanvasLink, bst_canvas_link, GNOME_TYPE_CANVAS_GROUP);
-
static void
bst_canvas_link_init (BstCanvasLink *clink)
{
@@ -35,39 +28,30 @@ bst_canvas_link_init (BstCanvasLink *clink)
clink->ic_handler = 0;
clink->link_view = NULL;
}
-
static void
bst_canvas_link_destroy (GtkObject *object)
{
BstCanvasLink *clink = BST_CANVAS_LINK (object);
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (object);
-
while (group->item_list)
gtk_object_destroy ((GtkObject*) group->item_list->data);
-
bst_canvas_link_set_ocsource (clink, NULL, 0);
bst_canvas_link_set_icsource (clink, NULL, 0);
-
GTK_OBJECT_CLASS (bst_canvas_link_parent_class)->destroy (object);
}
-
GnomeCanvasItem*
bst_canvas_link_new (GnomeCanvasGroup *group)
{
GnomeCanvasItem *item;
-
g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (group), NULL);
-
item = gnome_canvas_item_new (group,
BST_TYPE_CANVAS_LINK,
NULL);
-
/* work around stale canvas pointers, see #340437 */
g_object_set_data_full ((GObject*) item, "bst-workaround-canvas-ref", g_object_ref (item->canvas), g_object_unref);
bst_background_handler1_add (bst_canvas_link_build_async, g_object_ref (item), NULL);
return item;
}
-
BstCanvasLink*
bst_canvas_link_at (GnomeCanvas *canvas,
gdouble world_x,
@@ -75,16 +59,13 @@ bst_canvas_link_at (GnomeCanvas *canvas,
{
return (BstCanvasLink*) gnome_canvas_typed_item_at (canvas, BST_TYPE_CANVAS_LINK, world_x, world_y);
}
-
BstCanvasSource*
bst_canvas_link_csource_at (BstCanvasLink *clink,
gdouble world_x,
gdouble world_y)
{
GnomeCanvasItem *tag;
-
g_return_val_if_fail (BST_IS_CANVAS_LINK (clink), NULL);
-
tag = gnome_canvas_typed_item_at (GNOME_CANVAS_ITEM (clink)->canvas, GNOME_TYPE_CANVAS_ELLIPSE, world_x, world_y);
if (tag && tag == clink->tag_start)
return clink->ocsource;
@@ -93,7 +74,6 @@ bst_canvas_link_csource_at (BstCanvasLink *clink,
else
return NULL;
}
-
static void
clink_view_update (BstCanvasLink *clink,
gboolean force_update)
@@ -106,7 +86,6 @@ clink_view_update (BstCanvasLink *clink,
GtkWidget *text = GTK_BIN (frame)->child;
const gchar *ic_label, *oc_label, *ic_blurb, *oc_blurb, *iname, *oname;
gchar *string;
-
/* figure appropriate window title
*/
iname = clink->icsource ? bse_item_get_name_or_type (clink->icsource->source) : "<""???"">";
@@ -114,7 +93,6 @@ clink_view_update (BstCanvasLink *clink,
string = g_strconcat (_("Module Link: "), iname, " <=> ", oname, NULL);
gxk_dialog_set_title (GXK_DIALOG (clink->link_view), string);
g_free (string);
-
/* construct actuall information
*/
oc_label = clink->ocsource ? bse_source_ochannel_label (clink->ocsource->source, clink->ochannel) : NULL;
@@ -125,7 +103,6 @@ clink_view_update (BstCanvasLink *clink,
oc_label = "?";
if (!ic_label)
ic_label = "?";
-
/* compose new info */
gxk_scroll_text_clear (text);
gxk_scroll_text_aprintf (text, "Source Module:\n");
@@ -153,12 +130,10 @@ clink_view_update (BstCanvasLink *clink,
gxk_scroll_text_aprintf (text, "%s: %s\n", iname, ic_label);
}
}
-
void
bst_canvas_link_popup_view (BstCanvasLink *clink)
{
g_return_if_fail (BST_IS_CANVAS_LINK (clink));
-
if (!clink->link_view)
clink->link_view = (GtkWidget*) gxk_dialog_new (&clink->link_view,
GTK_OBJECT (clink),
@@ -173,26 +148,21 @@ bst_canvas_link_popup_view (BstCanvasLink *clink)
clink_view_update (clink, TRUE);
gxk_widget_showraise (clink->link_view);
}
-
void
bst_canvas_link_toggle_view (BstCanvasLink *clink)
{
g_return_if_fail (BST_IS_CANVAS_LINK (clink));
-
if (!clink->link_view || !GTK_WIDGET_VISIBLE (clink->link_view))
bst_canvas_link_popup_view (clink);
else
gtk_widget_hide (clink->link_view);
}
-
static void
clink_view_check_update (BstCanvasLink *clink)
{
g_return_if_fail (BST_IS_CANVAS_LINK (clink));
-
clink_view_update (clink, FALSE);
}
-
void
bst_canvas_link_set_ocsource (BstCanvasLink *clink,
BstCanvasSource *ocsource,
@@ -201,7 +171,6 @@ bst_canvas_link_set_ocsource (BstCanvasLink *clink,
g_return_if_fail (BST_IS_CANVAS_LINK (clink));
if (ocsource)
g_return_if_fail (BST_CANVAS_SOURCE (ocsource));
-
if (clink->ocsource)
{
if (clink->ocsource->source) /* source may be destroyed already */
@@ -227,7 +196,6 @@ bst_canvas_link_set_ocsource (BstCanvasLink *clink,
bst_canvas_link_update (clink);
}
}
-
void
bst_canvas_link_set_icsource (BstCanvasLink *clink,
BstCanvasSource *icsource,
@@ -236,7 +204,6 @@ bst_canvas_link_set_icsource (BstCanvasLink *clink,
g_return_if_fail (BST_IS_CANVAS_LINK (clink));
if (icsource)
g_return_if_fail (BST_CANVAS_SOURCE (icsource));
-
if (clink->icsource)
{
if (clink->icsource->source) /* source may be destroyed already */
@@ -262,7 +229,6 @@ bst_canvas_link_set_icsource (BstCanvasLink *clink,
bst_canvas_link_update (clink);
}
}
-
static gboolean
bst_canvas_link_build_async (gpointer data)
{
@@ -329,7 +295,6 @@ bst_canvas_link_build_async (gpointer data)
g_object_unref (canvas); /* canvases don't properly protect their items */
return FALSE;
}
-
static void
bst_canvas_link_update (BstCanvasLink *clink)
{
@@ -368,20 +333,17 @@ bst_canvas_link_update (BstCanvasLink *clink)
bst_canvas_link_adjust_tags (clink);
bst_canvas_link_adjust_arrow (clink);
}
-
static void
bst_canvas_link_adjust_tags (BstCanvasLink *clink)
{
GnomeCanvasPoints *gpoints;
gdouble x1, y1, x2, y2, *points;
-
if (!clink->line)
return;
gtk_object_get (GTK_OBJECT (clink->line), "points", &gpoints, NULL);
if (!gpoints)
gpoints = gnome_canvas_points_new0 (2);
points = gpoints->coords;
-
x1 = points[0] - TAG_DIAMETER;
y1 = points[1] - TAG_DIAMETER;
x2 = points[0] + TAG_DIAMETER;
@@ -404,41 +366,33 @@ bst_canvas_link_adjust_tags (BstCanvasLink *clink)
"x2", x2,
"y2", y2,
NULL);
-
gnome_canvas_points_free (gpoints);
}
-
static void
bst_canvas_link_adjust_arrow (BstCanvasLink *clink)
{
GnomeCanvasPoints *gpoints;
gdouble dx, dy, l, x, y, px, py, cos_theta, sin_theta, *points;
-
if (!clink->line)
return;
gtk_object_get (GTK_OBJECT (clink->line), "points", &gpoints, NULL);
if (!gpoints)
gpoints = gnome_canvas_points_new0 (2);
points = gpoints->coords;
-
dx = points[0] - points[2];
dy = points[1] - points[3];
l = sqrt (dx * dx + dy * dy);
x = (points[2] + points[0]) / 2;
y = (points[3] + points[1]) / 2;
-
gnome_canvas_points_free (gpoints);
-
sin_theta = l ? dy / l : 0;
cos_theta = l ? dx / l : 0;
px = x - ARROW_LENGTH / 2.0 * cos_theta;
py = y - ARROW_LENGTH / 2.0 * sin_theta;
x += ARROW_LENGTH / 2.0 * cos_theta;
y += ARROW_LENGTH / 2.0 * sin_theta;
-
gpoints = gnome_canvas_points_new (4);
points = gpoints->coords;
-
*(points++) = px;
*(points++) = py;
*(points++) = x - ARROW_WIDTH * sin_theta;
@@ -447,26 +401,22 @@ bst_canvas_link_adjust_arrow (BstCanvasLink *clink)
*(points++) = y - ARROW_WIDTH * cos_theta;
*(points++) = px;
*(points++) = py;
-
if (clink->arrow)
g_object_set (clink->arrow, "points", gpoints, NULL);
gnome_canvas_points_free (gpoints);
}
-
static gboolean
bst_canvas_link_event (GnomeCanvasItem *item,
GdkEvent *event)
{
BstCanvasLink *clink = BST_CANVAS_LINK (item);
gboolean handled = FALSE;
-
switch (event->type)
{
case GDK_BUTTON_PRESS:
if (event->button.button == 2)
{
GdkCursor *fleur;
-
if (clink->ocsource)
{
clink->start_move_dx = event->button.x;
@@ -484,7 +434,6 @@ bst_canvas_link_event (GnomeCanvasItem *item,
&clink->end_move_dy);
}
clink->in_move = TRUE;
-
fleur = gdk_cursor_new (GDK_FLEUR);
gnome_canvas_item_grab (item,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
@@ -498,7 +447,6 @@ bst_canvas_link_event (GnomeCanvasItem *item,
if (clink->in_move && clink->ocsource)
{
gdouble x = event->motion.x, y = event->motion.y;
-
gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->ocsource), &x, &y);
gnome_canvas_item_move (GNOME_CANVAS_ITEM (clink->ocsource),
x - clink->start_move_dx,
@@ -509,7 +457,6 @@ bst_canvas_link_event (GnomeCanvasItem *item,
if (clink->in_move && clink->icsource)
{
gdouble x = event->motion.x, y = event->motion.y;
-
gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->icsource), &x, &y);
gnome_canvas_item_move (GNOME_CANVAS_ITEM (clink->icsource),
x - clink->end_move_dx,
@@ -529,13 +476,10 @@ bst_canvas_link_event (GnomeCanvasItem *item,
default:
break;
}
-
if (!handled && GNOME_CANVAS_ITEM_CLASS (bst_canvas_link_parent_class)->event)
handled |= GNOME_CANVAS_ITEM_CLASS (bst_canvas_link_parent_class)->event (item, event);
-
return handled;
}
-
static gboolean
bst_canvas_link_child_event (GnomeCanvasItem *item,
GdkEvent *event)
@@ -543,9 +487,7 @@ bst_canvas_link_child_event (GnomeCanvasItem *item,
BstCanvasLink *clink;
GtkWidget *widget = GTK_WIDGET (item->canvas);
gboolean handled = FALSE;
-
clink = BST_CANVAS_LINK (item);
-
switch (event->type)
{
case GDK_ENTER_NOTIFY:
@@ -584,21 +526,17 @@ bst_canvas_link_child_event (GnomeCanvasItem *item,
default:
break;
}
-
return handled;
}
-
static void
bst_canvas_link_class_init (BstCanvasLinkClass *klass)
{
GtkObjectClass *object_class;
GnomeCanvasItemClass *canvas_item_class;
GnomeCanvasGroupClass *canvas_group_class;
-
object_class = GTK_OBJECT_CLASS (klass);
canvas_item_class = GNOME_CANVAS_ITEM_CLASS (klass);
canvas_group_class = GNOME_CANVAS_GROUP_CLASS (klass);
-
object_class->destroy = bst_canvas_link_destroy;
canvas_item_class->event = bst_canvas_link_event;
}
diff --git a/beast-gtk/bstcanvaslink.hh b/beast-gtk/bstcanvaslink.hh
index bbed95b..28a1dc1 100644
--- a/beast-gtk/bstcanvaslink.hh
+++ b/beast-gtk/bstcanvaslink.hh
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_CANVAS_LINK_H__
#define __BST_CANVAS_LINK_H__
-
#include "bstutils.hh"
#include "bstcanvassource.hh"
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_CANVAS_LINK (bst_canvas_link_get_type ())
#define BST_CANVAS_LINK(object) (GTK_CHECK_CAST ((object), BST_TYPE_CANVAS_LINK, BstCanvasLink))
@@ -18,38 +13,30 @@ extern "C" {
#define BST_IS_CANVAS_LINK(object) (GTK_CHECK_TYPE ((object), BST_TYPE_CANVAS_LINK))
#define BST_IS_CANVAS_LINK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_CANVAS_LINK))
#define BST_CANVAS_LINK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_CANVAS_LINK, BstCanvasLinkClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstCanvasLink BstCanvasLink;
typedef struct _BstCanvasLinkClass BstCanvasLinkClass;
struct _BstCanvasLink
{
GnomeCanvasGroup parent_object;
-
GnomeCanvasItem *line;
GnomeCanvasItem *arrow;
GnomeCanvasItem *tag_start, *tag_end;
-
BstCanvasSource *ocsource;
guint ochannel;
gulong oc_handler;
BstCanvasSource *icsource;
guint ichannel;
gulong ic_handler;
-
guint in_move : 1;
gdouble start_move_dx, start_move_dy;
gdouble end_move_dx, end_move_dy;
-
GtkWidget *link_view;
};
struct _BstCanvasLinkClass
{
GnomeCanvasGroupClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_canvas_link_get_type (void);
GnomeCanvasItem* bst_canvas_link_new (GnomeCanvasGroup *group);
@@ -67,12 +54,7 @@ BstCanvasLink* bst_canvas_link_at (GnomeCanvas *canvas,
BstCanvasSource* bst_canvas_link_csource_at (BstCanvasLink *clink,
gdouble world_x,
gdouble world_y);
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_CANVAS_LINK_H__ */
diff --git a/beast-gtk/bstcanvassource.cc b/beast-gtk/bstcanvassource.cc
index 97bd39d..98c825a 100644
--- a/beast-gtk/bstcanvassource.cc
+++ b/beast-gtk/bstcanvassource.cc
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstcanvassource.hh"
-
#include "topconfig.h"
#include "bstparamview.hh"
#include "bstgconfig.hh"
#include <string.h>
-
-
/* --- defines --- */
#define ICON_WIDTH(cs) ((gdouble) 64)
#define ICON_HEIGHT(cs) ((gdouble) 64)
@@ -32,7 +29,6 @@
#define FONT_HEIGHT ((gdouble) BST_GCONFIG (snet_font_size))
#define RGBA_BLACK (0x000000ff)
#define RGBA_INTERNAL (0x0000ffff)
-
/* --- signals --- */
enum
{
@@ -41,8 +37,6 @@ enum
};
typedef void (*SignalUpdateLinks) (BstCanvasSource *source,
gpointer func_data);
-
-
/* --- prototypes --- */
static gboolean bst_canvas_source_child_event (BstCanvasSource *csource,
GdkEvent *event,
@@ -53,20 +47,14 @@ static void bst_canvas_icon_set (GnomeCanvasItem *item,
const gchar *module_type);
static void csource_info_update (BstCanvasSource *csource);
static void bst_canvas_source_build (BstCanvasSource *csource);
-
-
/* --- static variables --- */
static guint csource_signals[SIGNAL_LAST] = { 0 };
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstCanvasSource, bst_canvas_source, GNOME_TYPE_CANVAS_GROUP);
-
static void
bst_canvas_source_init (BstCanvasSource *csource)
{
GtkObject *object = GTK_OBJECT (csource);
-
csource->source = 0;
csource->params_dialog = NULL;
csource->source_info = NULL;
@@ -83,22 +71,18 @@ bst_canvas_source_init (BstCanvasSource *csource)
"signal::notify", bst_canvas_source_changed, NULL,
NULL);
}
-
static void
source_channels_changed (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
GNOME_CANVAS_NOTIFY (csource);
bst_canvas_source_update_links (csource);
}
-
static gboolean
idle_move_item (gpointer data)
{
BstCanvasSource *self = (BstCanvasSource*) data;
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (self);
-
GDK_THREADS_ENTER ();
if (self->source && item->canvas)
{
@@ -122,7 +106,6 @@ idle_move_item (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
source_pos_changed (BstCanvasSource *self)
{
@@ -132,7 +115,6 @@ source_pos_changed (BstCanvasSource *self)
g_idle_add (idle_move_item, g_object_ref (self));
}
}
-
static void
canvas_source_set_position (BstCanvasSource *self)
{
@@ -142,59 +124,47 @@ canvas_source_set_position (BstCanvasSource *self)
GDK_THREADS_ENTER ();
self->idle_reposition = idle_reposition;
}
-
static void
source_name_changed (BstCanvasSource *csource)
{
const gchar *name;
-
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
name = bse_item_get_name_or_type (csource->source);
-
if (csource->text)
g_object_set (csource->text, "text", name, NULL);
-
if (csource->params_dialog)
{
gxk_dialog_set_title (GXK_DIALOG (csource->params_dialog), name);
csource_info_update (csource);
}
-
name = g_strconcat ("Info: ", name, NULL);
if (csource->source_info)
gxk_dialog_set_title (GXK_DIALOG (csource->source_info), name);
}
-
static void
source_icon_changed (BstCanvasSource *csource)
{
BseIcon *icon;
-
/* update icon in group, revert to a stock icon if none is available
*/
icon = bse_item_get_icon (csource->source);
if (csource->icon_item)
bst_canvas_icon_set (csource->icon_item, icon, bse_item_get_type (csource->source));
}
-
static void
bst_canvas_source_destroy (GtkObject *object)
{
BstCanvasSource *csource = BST_CANVAS_SOURCE (object);
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (object);
-
if (csource->in_move)
{
csource->in_move = FALSE;
bse_item_ungroup_undo (csource->source);
}
-
while (csource->channel_hints)
gtk_object_destroy ((GtkObject*) csource->channel_hints->data);
while (group->item_list)
gtk_object_destroy ((GtkObject*) group->item_list->data);
-
if (csource->source)
{
bse_proxy_disconnect (csource->source,
@@ -207,12 +177,9 @@ bst_canvas_source_destroy (GtkObject *object)
bse_item_unuse (csource->source);
csource->source = 0;
}
-
GTK_OBJECT_CLASS (bst_canvas_source_parent_class)->destroy (object);
}
-
#define EPSILON 1e-6
-
static void
bse_object_set_parasite_coords (SfiProxy proxy,
SfiReal x,
@@ -222,17 +189,14 @@ bse_object_set_parasite_coords (SfiProxy proxy,
x / BST_CANVAS_SOURCE_PIXEL_SCALE,
y / -BST_CANVAS_SOURCE_PIXEL_SCALE);
}
-
GnomeCanvasItem*
bst_canvas_source_new (GnomeCanvasGroup *group,
SfiProxy source)
{
BstCanvasSource *csource;
GnomeCanvasItem *item;
-
g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (group), NULL);
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
-
item = gnome_canvas_item_new (group,
BST_TYPE_CANVAS_SOURCE,
NULL);
@@ -246,31 +210,24 @@ bst_canvas_source_new (GnomeCanvasGroup *group,
"swapped_signal::property-notify::pos-y", source_pos_changed, csource,
"swapped_signal::icon-changed", source_icon_changed, csource,
NULL);
-
canvas_source_set_position (csource);
bst_canvas_source_build (csource);
-
GNOME_CANVAS_NOTIFY (item);
-
return item;
}
-
void
bst_canvas_source_update_links (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
if (csource->source)
gtk_signal_emit (GTK_OBJECT (csource), csource_signals[SIGNAL_UPDATE_LINKS]);
}
-
static inline void
canvas_source_create_params (BstCanvasSource *csource)
{
if (!csource->params_dialog)
{
GtkWidget *param_view;
-
param_view = bst_param_view_new (csource->source);
csource->params_dialog = (GtkWidget*) gxk_dialog_new (&csource->params_dialog,
GTK_OBJECT (csource),
@@ -280,47 +237,37 @@ canvas_source_create_params (BstCanvasSource *csource)
source_name_changed (csource);
}
}
-
void
bst_canvas_source_reset_params (BstCanvasSource *csource)
{
GtkWidget *param_view;
-
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
canvas_source_create_params (csource);
param_view = gxk_dialog_get_child (GXK_DIALOG (csource->params_dialog));
bst_param_view_apply_defaults (BST_PARAM_VIEW (param_view));
}
-
void
bst_canvas_source_popup_params (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
canvas_source_create_params (csource);
gxk_widget_showraise (csource->params_dialog);
}
-
void
bst_canvas_source_toggle_params (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
if (!csource->params_dialog || !GTK_WIDGET_VISIBLE (csource->params_dialog))
bst_canvas_source_popup_params (csource);
else
gtk_widget_hide (csource->params_dialog);
}
-
void
bst_canvas_source_set_channel_hints (BstCanvasSource *csource,
gboolean on_off)
{
GSList *slist;
-
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
csource->show_hints = !!on_off;
if (csource->show_hints)
for (slist = csource->channel_hints; slist; slist = slist->next)
@@ -329,7 +276,6 @@ bst_canvas_source_set_channel_hints (BstCanvasSource *csource,
for (slist = csource->channel_hints; slist; slist = slist->next)
g_object_set (slist->data, "text", "", NULL);
}
-
static void
csource_info_update (BstCanvasSource *csource)
{
@@ -339,11 +285,9 @@ csource_info_update (BstCanvasSource *csource)
if (text)
{
const gchar *string;
-
/* construct information */
gxk_scroll_text_clear (text);
gxk_scroll_text_aprintf (text, "%s:\n", bse_item_get_name_or_type (csource->source));
-
/* type & category */
gxk_scroll_text_push_indent (text);
gxk_scroll_text_aprintf (text, "Type: %s\n", bse_item_get_type_name (csource->source));
@@ -351,7 +295,6 @@ csource_info_update (BstCanvasSource *csource)
if (cseq->n_cats)
gxk_scroll_text_aprintf (text, "Category: %s\n", cseq->cats[0]->category);
gxk_scroll_text_pop_indent (text);
-
/* input channels */
if (bse_source_n_ichannels (csource->source))
{
@@ -374,7 +317,6 @@ csource_info_update (BstCanvasSource *csource)
}
if (bse_source_n_ichannels (csource->source))
gxk_scroll_text_pop_indent (text);
-
/* output channels */
if (bse_source_n_ochannels (csource->source))
{
@@ -397,7 +339,6 @@ csource_info_update (BstCanvasSource *csource)
}
if (bse_source_n_ochannels (csource->source))
gxk_scroll_text_pop_indent (text);
-
/* description */
string = bse_item_get_type_blurb (csource->source);
if (string && string[0])
@@ -407,24 +348,20 @@ csource_info_update (BstCanvasSource *csource)
gxk_scroll_text_aprintf (text, "%s\n", string);
gxk_scroll_text_pop_indent (text);
}
-
/* authors */
string = bse_item_get_type_authors (csource->source);
if (string && string[0])
gxk_scroll_text_aprintf (text, "\nAuthors: %s\n", string);
-
/* license */
string = bse_item_get_type_license (csource->source);
if (string && string[0])
gxk_scroll_text_aprintf (text, "\nLicense: %s\n", string);
}
}
-
void
bst_canvas_source_popup_info (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
if (!csource->source_info)
{
GtkWidget *sctext = gxk_scroll_text_create (GXK_SCROLL_TEXT_WIDGET_LOOK, NULL);
@@ -449,18 +386,15 @@ bst_canvas_source_popup_info (BstCanvasSource *csource)
source_name_changed (csource);
gxk_widget_showraise (csource->source_info);
}
-
void
bst_canvas_source_toggle_info (BstCanvasSource *csource)
{
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
if (!csource->source_info || !GTK_WIDGET_VISIBLE (csource->source_info))
bst_canvas_source_popup_info (csource);
else
gtk_widget_hide (csource->source_info);
}
-
BstCanvasSource*
bst_canvas_source_at (GnomeCanvas *canvas,
gdouble world_x,
@@ -468,34 +402,27 @@ bst_canvas_source_at (GnomeCanvas *canvas,
{
return (BstCanvasSource*) gnome_canvas_typed_item_at (canvas, BST_TYPE_CANVAS_SOURCE, world_x, world_y);
}
-
gboolean
bst_canvas_source_is_jchannel (BstCanvasSource *csource,
guint ichannel)
{
g_return_val_if_fail (BST_IS_CANVAS_SOURCE (csource), FALSE);
-
if (!csource->source)
return FALSE;
-
return bse_source_is_joint_ichannel_by_id (csource->source, ichannel);
}
-
gboolean
bst_canvas_source_ichannel_free (BstCanvasSource *csource,
guint ichannel)
{
g_return_val_if_fail (BST_IS_CANVAS_SOURCE (csource), FALSE);
-
if (!csource->source)
return FALSE;
-
if (bse_source_is_joint_ichannel_by_id (csource->source, ichannel))
return TRUE;
else
return bse_source_ichannel_get_osource (csource->source, ichannel, 0) == 0;
}
-
void
bst_canvas_source_ichannel_pos (BstCanvasSource *csource,
guint ochannel,
@@ -503,9 +430,7 @@ bst_canvas_source_ichannel_pos (BstCanvasSource *csource,
gdouble *y_p)
{
gdouble x = 0, y = 0;
-
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
x = ICHANNEL_X (csource) + CHANNEL_WIDTH (csource) / 2;
if (csource->source)
y = CHANNEL_HEIGHT (csource) / bse_source_n_ichannels (csource->source);
@@ -517,7 +442,6 @@ bst_canvas_source_ichannel_pos (BstCanvasSource *csource,
if (y_p)
*y_p = y;
}
-
void
bst_canvas_source_ochannel_pos (BstCanvasSource *csource,
guint ichannel,
@@ -525,9 +449,7 @@ bst_canvas_source_ochannel_pos (BstCanvasSource *csource,
gdouble *y_p)
{
gdouble x, y;
-
g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
-
x = OCHANNEL_X (csource) + CHANNEL_WIDTH (csource) / 2;
if (csource->source)
y = CHANNEL_HEIGHT (csource) / bse_source_n_ochannels (csource->source);
@@ -539,18 +461,14 @@ bst_canvas_source_ochannel_pos (BstCanvasSource *csource,
if (y_p)
*y_p = y;
}
-
guint
bst_canvas_source_ichannel_at (BstCanvasSource *csource,
gdouble x,
gdouble y)
{
guint channel = ~0;
-
g_return_val_if_fail (BST_IS_CANVAS_SOURCE (csource), 0);
-
gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (csource), &x, &y);
-
x -= ICHANNEL_X (csource);
y -= ICHANNEL_Y (csource);
if (x > 0 && x < CHANNEL_WIDTH (csource) &&
@@ -560,21 +478,16 @@ bst_canvas_source_ichannel_at (BstCanvasSource *csource,
y /= CHANNEL_HEIGHT (csource) / bse_source_n_ichannels (csource->source);
channel = y;
}
-
return channel;
}
-
guint
bst_canvas_source_ochannel_at (BstCanvasSource *csource,
gdouble x,
gdouble y)
{
guint channel = ~0;
-
g_return_val_if_fail (BST_IS_CANVAS_SOURCE (csource), 0);
-
gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (csource), &x, &y);
-
x -= OCHANNEL_X (csource);
y -= OCHANNEL_Y (csource);
if (x > 0 && x < CHANNEL_WIDTH (csource) &&
@@ -584,10 +497,8 @@ bst_canvas_source_ochannel_at (BstCanvasSource *csource,
y /= CHANNEL_HEIGHT (csource) / bse_source_n_ochannels (csource->source);
channel = y;
}
-
return channel;
}
-
static void
bst_canvas_icon_set (GnomeCanvasItem *item,
BseIcon *icon,
@@ -595,7 +506,6 @@ bst_canvas_icon_set (GnomeCanvasItem *item,
{
GdkPixbuf *pixbuf;
gboolean need_unref = FALSE;
-
if (icon && icon->pixels->bytes)
{
icon = bse_icon_copy_shallow (icon);
@@ -613,7 +523,6 @@ bst_canvas_icon_set (GnomeCanvasItem *item,
pixbuf = bst_pixbuf_ladspa ();
else
pixbuf = bst_pixbuf_no_icon ();
-
g_object_set (GTK_OBJECT (item),
"pixbuf", pixbuf,
"x_in_pixels", FALSE,
@@ -623,21 +532,18 @@ bst_canvas_icon_set (GnomeCanvasItem *item,
if (need_unref)
g_object_unref (pixbuf);
}
-
static void
channel_item_remove (BstCanvasSource *csource,
GnomeCanvasItem *item)
{
csource->channel_items = g_slist_remove (csource->channel_items, item);
}
-
static void
channel_name_remove (BstCanvasSource *csource,
GnomeCanvasItem *item)
{
csource->channel_hints = g_slist_remove (csource->channel_hints, item);
}
-
static void
bst_canvas_source_build_channels (BstCanvasSource *csource,
gboolean is_input,
@@ -654,7 +560,6 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
gdouble x1, x2, y1, y2;
gdouble d_y;
gboolean east_channel = CHANNEL_EAST (csource, is_input);
-
if (is_input)
{
n_channels = bse_source_n_ichannels (csource->source);
@@ -672,16 +577,13 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
d_y = y2 - y1;
if (n_channels)
d_y /= n_channels;
-
if (n_channels > 1)
{
gint cd_red, cd_blue, cd_green;
-
cd_red = ((color1_fade & 0xff0000) - (color1 & 0xff0000)) / (n_channels - 1);
cd_green = ((color1_fade & 0x00ff00) - (color1 & 0x00ff00)) / (n_channels - 1);
cd_blue = ((color1_fade & 0x0000ff) - (color1 & 0x0000ff)) / (n_channels - 1);
color1_delta = (cd_red & ~0xffff) + (cd_green & ~0xff) + cd_blue;
-
cd_red = ((color2_fade & 0xff0000) - (color2 & 0xff0000)) / (n_channels - 1);
cd_green = ((color2_fade & 0x00ff00) - (color2 & 0x00ff00)) / (n_channels - 1);
cd_blue = ((color2_fade & 0x0000ff) - (color2 & 0x0000ff)) / (n_channels - 1);
@@ -708,14 +610,12 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
csource->channel_items = g_slist_prepend (csource->channel_items, item);
}
}
-
for (int i = 0; i < n_channels; i++)
{
GnomeCanvasItem *item;
gboolean is_jchannel = is_input && bse_source_is_joint_ichannel_by_id (csource->source, i);
const gchar *label = (is_input ? bse_source_ichannel_label : bse_source_ochannel_label) (csource->source, i);
guint tmp_color = is_jchannel ? color2 : color1;
-
y2 = y1 + d_y;
if (build_channel_items)
{
@@ -734,7 +634,6 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
NULL);
csource->channel_items = g_slist_prepend (csource->channel_items, item);
}
-
if (build_channel_hints)
{
item = gnome_canvas_item_new (group,
@@ -754,13 +653,11 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
g_object_set_data_full (G_OBJECT (item), "hint_text", g_strdup (label), g_free);
csource->channel_hints = g_slist_prepend (csource->channel_hints, item);
}
-
color1 += color1_delta;
color2 += color2_delta;
y1 = y2;
}
}
-
static gboolean
bst_canvas_source_build_async (gpointer data)
{
@@ -769,9 +666,7 @@ bst_canvas_source_build_async (gpointer data)
{
BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
-
/* keep in mind, that creation order affects stacking */
-
/* add input and output channel items */
if (!csource->built_ichannels)
{
@@ -793,7 +688,6 @@ bst_canvas_source_build_async (gpointer data)
TRUE, FALSE);
return TRUE;
}
-
/* add icon to group */
if (!csource->icon_item)
{
@@ -811,7 +705,6 @@ bst_canvas_source_build_async (gpointer data)
source_icon_changed (csource);
return TRUE;
}
-
if (!csource->text)
{
/* add text item, invoke name_changed callback to setup the text value */
@@ -833,7 +726,6 @@ bst_canvas_source_build_async (gpointer data)
source_name_changed (csource);
return TRUE;
}
-
/* add input and output channel hints */
if (!csource->built_ihints)
{
@@ -862,7 +754,6 @@ bst_canvas_source_build_async (gpointer data)
g_object_unref (canvas); /* canvases don't properly protect their items */
return FALSE;
}
-
static void
bst_canvas_source_build (BstCanvasSource *csource)
{
@@ -899,7 +790,6 @@ bst_canvas_source_build (BstCanvasSource *csource)
g_object_set_data_full ((GObject*) csource_item, "bst-workaround-canvas-ref", g_object_ref (csource_item->canvas), g_object_unref);
bst_background_handler2_add (bst_canvas_source_build_async, g_object_ref (csource), NULL);
}
-
static void
bst_canvas_source_changed (BstCanvasSource *csource)
{
@@ -911,14 +801,12 @@ bst_canvas_source_changed (BstCanvasSource *csource)
bse_object_set_parasite_coords (csource->source, x, y);
}
}
-
static gboolean
bst_canvas_source_event (GnomeCanvasItem *item,
GdkEvent *event)
{
BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
gboolean handled = FALSE;
-
switch (event->type)
{
case GDK_BUTTON_PRESS:
@@ -945,7 +833,6 @@ bst_canvas_source_event (GnomeCanvasItem *item,
if (csource->in_move)
{
gdouble x = event->motion.x, y = event->motion.y;
-
gnome_canvas_item_w2i (item, &x, &y);
gnome_canvas_item_move (item, x - csource->move_dx, y - csource->move_dy);
GNOME_CANVAS_NOTIFY (item);
@@ -955,7 +842,6 @@ bst_canvas_source_event (GnomeCanvasItem *item,
{
guint channel;
const gchar *label = NULL, *prefix = NULL, *ident = NULL;
-
/* set i/o channel hints */
channel = bst_canvas_source_ichannel_at (csource, event->motion.x, event->motion.y);
if (channel != ~uint (0))
@@ -992,13 +878,10 @@ bst_canvas_source_event (GnomeCanvasItem *item,
default:
break;
}
-
if (!handled && GNOME_CANVAS_ITEM_CLASS (bst_canvas_source_parent_class)->event)
handled = GNOME_CANVAS_ITEM_CLASS (bst_canvas_source_parent_class)->event (item, event);
-
return handled;
}
-
static gboolean
bst_canvas_source_child_event (BstCanvasSource *csource,
GdkEvent *event,
@@ -1007,9 +890,7 @@ bst_canvas_source_child_event (BstCanvasSource *csource,
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (csource);
GtkWidget *widget = GTK_WIDGET (item->canvas);
gboolean handled = FALSE;
-
csource = BST_CANVAS_SOURCE (item);
-
switch (event->type)
{
case GDK_ENTER_NOTIFY:
@@ -1042,21 +923,17 @@ bst_canvas_source_child_event (BstCanvasSource *csource,
default:
break;
}
-
return handled;
}
-
static void
bst_canvas_source_class_init (BstCanvasSourceClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GnomeCanvasItemClass *canvas_item_class = GNOME_CANVAS_ITEM_CLASS (klass);
/* GnomeCanvasGroupClass *canvas_group_class = GNOME_CANVAS_GROUP_CLASS (klass); */
-
object_class->destroy = bst_canvas_source_destroy;
canvas_item_class->event = bst_canvas_source_event;
klass->update_links = NULL;
-
csource_signals[SIGNAL_UPDATE_LINKS] =
gtk_signal_new ("update-links",
GTK_RUN_LAST,
diff --git a/beast-gtk/bstcanvassource.hh b/beast-gtk/bstcanvassource.hh
index 17635eb..405c189 100644
--- a/beast-gtk/bstcanvassource.hh
+++ b/beast-gtk/bstcanvassource.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_CANVAS_SOURCE_H__
#define __BST_CANVAS_SOURCE_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_CANVAS_SOURCE (bst_canvas_source_get_type ())
#define BST_CANVAS_SOURCE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_CANVAS_SOURCE, BstCanvasSource))
@@ -14,25 +11,19 @@ G_BEGIN_DECLS
#define BST_IS_CANVAS_SOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BST_TYPE_CANVAS_SOURCE))
#define BST_CANVAS_SOURCE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_CANVAS_SOURCE, BstCanvasSourceClass))
#define BST_CANVAS_SOURCE_PIXEL_SCALE ((SfiReal) 100) /* > total width/height */
-
-
/* --- structures & typedefs --- */
typedef struct _BstCanvasSource BstCanvasSource;
typedef struct _BstCanvasSourceClass BstCanvasSourceClass;
struct _BstCanvasSource
{
GnomeCanvasGroup parent_object;
-
SfiProxy source;
-
GtkWidget *params_dialog;
GtkWidget *source_info;
-
GnomeCanvasItem *icon_item;
GnomeCanvasItem *text;
GSList *channel_items;
GSList *channel_hints;
-
guint swap_channels : 1;
guint in_move : 1;
guint show_hints : 1;
@@ -46,11 +37,8 @@ struct _BstCanvasSource
struct _BstCanvasSourceClass
{
GnomeCanvasGroupClass parent_class;
-
void (*update_links) (BstCanvasSource *source);
};
-
-
/* --- prototypes --- */
GType bst_canvas_source_get_type (void);
GnomeCanvasItem* bst_canvas_source_new (GnomeCanvasGroup *group,
@@ -84,7 +72,5 @@ void bst_canvas_source_popup_info (BstCanvasSource *csource)
void bst_canvas_source_toggle_info (BstCanvasSource *csource);
void bst_canvas_source_set_channel_hints (BstCanvasSource *csource,
gboolean on_off);
-
G_END_DECLS
-
#endif /* __BST_CANVAS_SOURCE_H__ */
diff --git a/beast-gtk/bstcluehunter.cc b/beast-gtk/bstcluehunter.cc
index 017d45c..ab45547 100644
--- a/beast-gtk/bstcluehunter.cc
+++ b/beast-gtk/bstcluehunter.cc
@@ -3,8 +3,6 @@
#include "bstmarshal.h"
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
-
/* --- signals --- */
enum {
SIGNAL_ACTIVATE,
@@ -14,8 +12,6 @@ enum {
SIGNAL_POLL_REFRESH,
SIGNAL_LAST
};
-
-
/* --- arguments --- */
enum {
PROP_0,
@@ -24,8 +20,6 @@ enum {
PROP_KEEP_HISTORY,
PROP_ENTRY
};
-
-
/* --- prototypes --- */
static void bst_clue_hunter_class_init (BstClueHunterClass *klass);
static void bst_clue_hunter_init (BstClueHunter *clue_hunter);
@@ -56,20 +50,15 @@ static void bst_clue_hunter_add_history (BstClueHunter *clue_hunter,
static void bst_clue_hunter_do_select_on (BstClueHunter *clue_hunter,
const gchar *string);
static void bst_clue_hunter_popdown (BstClueHunter *clue_hunter);
-
-
/* --- variables --- */
static GtkWindowClass *parent_class = NULL;
static BstClueHunterClass *bst_clue_hunter_class = NULL;
static guint clue_hunter_signals[SIGNAL_LAST] = { 0, };
-
-
/* --- functions --- */
GtkType
bst_clue_hunter_get_type (void)
{
static GtkType clue_hunter_type = 0;
-
if (!clue_hunter_type)
{
GtkTypeInfo clue_hunter_info =
@@ -87,30 +76,23 @@ bst_clue_hunter_get_type (void)
}
return clue_hunter_type;
}
-
static void
bst_clue_hunter_class_init (BstClueHunterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
bst_clue_hunter_class = klass;
parent_class = (GtkWindowClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bst_clue_hunter_set_property;
gobject_class->get_property = bst_clue_hunter_get_property;
gobject_class->finalize = bst_clue_hunter_finalize;
-
object_class->destroy = bst_clue_hunter_destroy;
-
widget_class->event = bst_clue_hunter_event;
-
klass->activate = bst_clue_hunter_do_activate;
klass->popup = bst_clue_hunter_do_popup;
klass->popdown = bst_clue_hunter_do_popdown;
klass->select_on = bst_clue_hunter_do_select_on;
-
/* override GtkWindow::type property */
g_object_class_install_property (gobject_class,
1024,
@@ -134,7 +116,6 @@ bst_clue_hunter_class_init (BstClueHunterClass *klass)
PROP_ENTRY,
g_param_spec_object ("entry", NULL, NULL,
GTK_TYPE_ENTRY, G_PARAM_READWRITE));
-
clue_hunter_signals[SIGNAL_ACTIVATE] = g_signal_new ("activate", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (BstClueHunterClass, activate),
@@ -167,22 +148,18 @@ bst_clue_hunter_class_init (BstClueHunterClass *klass)
gtk_signal_default_marshaller,
G_TYPE_NONE, 0);
}
-
static void
bst_clue_hunter_init (BstClueHunter *self)
{
GtkWidget *parent;
GtkCList *clist;
-
self->popped_up = FALSE;
self->completion_tag = FALSE;
self->pattern_matching = TRUE;
self->align_widget = NULL;
self->keep_history = FALSE;
self->cstring = NULL;
-
GTK_WINDOW (self)->type = GTK_WINDOW_POPUP;
-
g_object_set (self,
"allow_shrink", FALSE,
"allow_grow", FALSE,
@@ -210,7 +187,6 @@ bst_clue_hunter_init (BstClueHunter *self)
gtk_clist_column_titles_hide (GTK_CLIST (clist));
bst_clue_hunter_set_clist (self, clist, 0);
}
-
static void
bst_clue_hunter_set_property (GObject *object,
guint prop_id,
@@ -218,7 +194,6 @@ bst_clue_hunter_set_property (GObject *object,
GParamSpec *pspec)
{
BstClueHunter *self = BST_CLUE_HUNTER (object);
-
switch (prop_id)
{
case PROP_PATTERN_MATCHING:
@@ -242,7 +217,6 @@ bst_clue_hunter_set_property (GObject *object,
break;
}
}
-
static void
bst_clue_hunter_get_property (GObject *object,
guint prop_id,
@@ -250,7 +224,6 @@ bst_clue_hunter_get_property (GObject *object,
GParamSpec *pspec)
{
BstClueHunter *self = BST_CLUE_HUNTER (object);
-
switch (prop_id)
{
case PROP_PATTERN_MATCHING:
@@ -270,12 +243,10 @@ bst_clue_hunter_get_property (GObject *object,
break;
}
}
-
static void
bst_clue_hunter_destroy (GtkObject *object)
{
BstClueHunter *self = BST_CLUE_HUNTER (object);
-
if (self->align_widget)
{
g_object_unref (self->align_widget);
@@ -283,54 +254,42 @@ bst_clue_hunter_destroy (GtkObject *object)
}
if (self->popped_up)
bst_clue_hunter_popdown (self);
-
self->scw = NULL;
if (self->clist)
g_object_unref (self->clist);
self->clist = NULL;
-
if (self->entry)
bst_clue_hunter_set_entry (self, NULL);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_clue_hunter_finalize (GObject *object)
{
BstClueHunter *self = BST_CLUE_HUNTER (object);
-
if (self->align_widget)
g_object_unref (self->align_widget);
g_free (self->cstring);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gint
bst_clue_hunter_clist_click (BstClueHunter *self,
GdkEvent *event,
GtkCList *clist)
{
gboolean handled = FALSE;
-
if (event->type == GDK_2BUTTON_PRESS &&
event->button.button == 1 && clist->selection)
{
gchar *string;
-
handled = TRUE;
string = bst_clue_hunter_try_complete (self);
gtk_entry_set_text (GTK_ENTRY (self->entry), string ? string : "");
g_free (string);
-
bst_clue_hunter_popdown (self);
gtk_widget_activate (GTK_WIDGET (self->entry));
}
-
return handled;
}
-
static gboolean
intercept_innermost_signal (GObject *object)
{
@@ -338,20 +297,17 @@ intercept_innermost_signal (GObject *object)
g_signal_stop_emission (object, ihint->signal_id, ihint->detail);
return FALSE;
}
-
void
bst_clue_hunter_set_clist (BstClueHunter *self,
GtkCList *clist,
guint16 column)
{
GtkWidget *clist_parent;
-
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
g_return_if_fail (GTK_IS_CLIST (clist));
clist_parent = GTK_WIDGET (clist)->parent;
g_return_if_fail (clist_parent == NULL);
g_return_if_fail (column < GTK_CLIST (clist)->columns);
-
if (self->clist)
{
if (clist_parent)
@@ -377,51 +333,41 @@ bst_clue_hunter_set_clist (BstClueHunter *self,
NULL);
self->clist_column = column;
}
-
static void
bst_clue_hunter_popdown (BstClueHunter *self)
{
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
-
if (self->popped_up)
g_signal_emit (self, clue_hunter_signals[SIGNAL_POPDOWN], 0);
}
-
void
bst_clue_hunter_popup (BstClueHunter *self)
{
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
-
if (self->popped_up == FALSE &&
self->entry && GTK_WIDGET_DRAWABLE (self->entry))
g_signal_emit (self, clue_hunter_signals[SIGNAL_POPUP], 0);
}
-
void
bst_clue_hunter_select_on (BstClueHunter *self,
const gchar *string)
{
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
g_return_if_fail (string != NULL);
-
g_signal_emit (self, clue_hunter_signals[SIGNAL_SELECT_ON], 0, string);
}
-
void
bst_clue_hunter_popup_if_editable (BstClueHunter *self)
{
if (self->entry && gtk_editable_get_editable (GTK_EDITABLE (self->entry)))
bst_clue_hunter_popup (self);
}
-
GtkWidget*
bst_clue_hunter_create_arrow (BstClueHunter *self,
gboolean require_editable)
{
GtkWidget *button, *arrow;
-
g_return_val_if_fail (BST_IS_CLUE_HUNTER (self), NULL);
-
button = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"can_focus", FALSE,
@@ -440,7 +386,6 @@ bst_clue_hunter_create_arrow (BstClueHunter *self,
NULL);
return button;
}
-
static void
bst_clue_hunter_entry_changed (BstClueHunter *self)
{
@@ -449,14 +394,12 @@ bst_clue_hunter_entry_changed (BstClueHunter *self)
self->cstring = g_strdup (gtk_entry_get_text (self->entry));
bst_clue_hunter_select_on (self, self->cstring);
}
-
static gint
bst_clue_hunter_entry_key_press (BstClueHunter *self,
GdkEventKey *event,
GtkEntry *entry)
{
gboolean handled = FALSE;
-
if ((event->keyval == GDK_Tab || event->keyval == GDK_ISO_Left_Tab) &&
!(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)))
{
@@ -486,13 +429,11 @@ bst_clue_hunter_entry_key_press (BstClueHunter *self,
}
return handled;
}
-
static void
bst_clue_hunter_entry_destroyed (GtkObject *clue_hunter)
{
gtk_object_destroy (clue_hunter);
}
-
void
bst_clue_hunter_set_entry (BstClueHunter *self,
GtkEntry *entry)
@@ -503,7 +444,6 @@ bst_clue_hunter_set_entry (BstClueHunter *self,
g_return_if_fail (GTK_IS_ENTRY (entry));
g_return_if_fail (bst_clue_hunter_from_entry (entry) == NULL);
}
-
bst_clue_hunter_popdown (self);
if (self->entry)
{
@@ -533,45 +473,36 @@ bst_clue_hunter_set_entry (BstClueHunter *self,
}
self->completion_tag = FALSE;
}
-
gpointer
bst_clue_hunter_from_entry (gpointer entry)
{
g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
-
return g_object_get_data (G_OBJECT (entry), "BstClueHunter");
}
-
void
bst_clue_hunter_add_string (BstClueHunter *self,
const gchar *string)
{
gchar **text;
-
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
g_return_if_fail (string != NULL);
-
text = g_new0 (gchar*, self->clist->columns);
text[self->clist_column] = (gchar*) string;
gtk_clist_insert (self->clist, 0, text);
g_free (text);
}
-
void
bst_clue_hunter_remove_string (BstClueHunter *self,
const gchar *string)
{
GList *list;
guint n = 0;
-
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
g_return_if_fail (string != NULL);
-
for (list = self->clist->row_list; list; list = list->next)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
gchar *ctext = clist_row->cell[self->clist_column].u.text;
-
if (ctext && strcmp (string, ctext) == 0)
{
gtk_clist_remove (self->clist, n);
@@ -580,7 +511,6 @@ bst_clue_hunter_remove_string (BstClueHunter *self,
n++;
}
}
-
void
bst_clue_hunter_remove_matches (BstClueHunter *self,
const gchar *pattern)
@@ -588,20 +518,16 @@ bst_clue_hunter_remove_matches (BstClueHunter *self,
GPatternSpec *pspec;
GList *list;
guint n = 0;
-
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
if (!pattern)
pattern = "*";
-
pspec = g_pattern_spec_new (pattern);
-
gtk_clist_freeze (self->clist);
list = self->clist->row_list;
while (list)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
gchar *ctext = clist_row->cell[self->clist_column].u.text;
-
list = list->next;
if (!ctext || g_pattern_match_string (pspec, ctext))
gtk_clist_remove (self->clist, n);
@@ -611,27 +537,21 @@ bst_clue_hunter_remove_matches (BstClueHunter *self,
g_pattern_spec_free (pspec);
gtk_clist_thaw (self->clist);
}
-
static gchar*
string_list_intersect (guint max_len,
GSList *strings)
{
gchar *completion;
guint l = 0;
-
if (!strings || !max_len)
return NULL;
-
completion = g_new (gchar, max_len + 1);
-
while (l < max_len)
{
gchar *s = (gchar*) strings->data;
GSList *slist;
-
s += l;
completion[l] = *s;
-
for (slist = strings->next; slist; slist = slist->next)
{
s = (char*) slist->data;
@@ -644,10 +564,8 @@ string_list_intersect (guint max_len,
l++;
}
completion[l] = 0;
-
return g_renew (gchar, completion, completion[0] ? l + 1 : 0);
}
-
gchar*
bst_clue_hunter_try_complete (BstClueHunter *self)
{
@@ -655,40 +573,31 @@ bst_clue_hunter_try_complete (BstClueHunter *self)
gchar *completion;
GSList *strings = NULL;
guint max_len = 0, n = 0;
-
g_return_val_if_fail (BST_IS_CLUE_HUNTER (self), NULL);
-
for (list = self->clist->row_list; list; list = list->next)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
-
if (g_list_find (self->clist->selection, GINT_TO_POINTER (n)))
{
gchar *ctext = clist_row->cell[self->clist_column].u.text;
guint l = ctext ? strlen (ctext) : 0;
-
max_len = MAX (max_len, l);
if (ctext)
strings = g_slist_prepend (strings, ctext);
}
n++;
}
-
completion = string_list_intersect (max_len, strings);
g_slist_free (strings);
-
return completion;
}
-
void
bst_clue_hunter_poll_refresh (BstClueHunter *self)
{
g_return_if_fail (BST_IS_CLUE_HUNTER (self));
-
if (self->entry && GTK_WIDGET_HAS_FOCUS (self->entry))
g_signal_emit (self, clue_hunter_signals[SIGNAL_POLL_REFRESH], 0);
}
-
static void
bst_clue_hunter_do_activate (BstClueHunter *self)
{
@@ -697,7 +606,6 @@ bst_clue_hunter_do_activate (BstClueHunter *self)
else if (self->entry)
bst_clue_hunter_popup_if_editable (self);
}
-
static void
bst_clue_hunter_do_popup (BstClueHunter *self)
{
@@ -708,13 +616,10 @@ bst_clue_hunter_do_popup (BstClueHunter *self)
gint sheight = gdk_screen_height ();
gint swidth = gdk_screen_width ();
gint x = 0, y = 0, width = 0, height = 0;
-
g_return_if_fail (!self->popped_up);
-
gtk_widget_grab_focus (GTK_WIDGET (self->entry));
if (!self->cstring)
self->cstring = g_strdup ("");
-
/* work around clist and scrolled window resizing misbehaviour */
gtk_clist_columns_autosize (self->clist);
gtk_widget_queue_resize (wlist); /* work around gtk+ optimizations */
@@ -728,7 +633,6 @@ bst_clue_hunter_do_popup (BstClueHunter *self)
+ 3 /* gtkscrolledwindow.c hardcoded spacing */
+ scw->hscrollbar->requisition.height);
gtk_widget_size_request (widget, NULL);
-
if (self->align_widget && GTK_WIDGET_DRAWABLE (self->align_widget))
{
gdk_window_get_origin (self->align_widget->window, &x, &y);
@@ -781,13 +685,10 @@ bst_clue_hunter_do_popup (BstClueHunter *self)
}
width = MIN (swidth - x, width);
gtk_widget_set_size_request (widget, width, height);
-
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move (widget->window, x, y);
gtk_window_move (GTK_WINDOW (widget), x, y);
-
gtk_widget_grab_focus (wlist);
-
gtk_widget_show (widget);
if (gxk_grab_pointer_and_keyboard (widget->window, TRUE,
GDK_POINTER_MOTION_HINT_MASK |
@@ -806,63 +707,51 @@ bst_clue_hunter_do_popup (BstClueHunter *self)
else
gtk_widget_hide (widget);
}
-
static void
bst_clue_hunter_do_popdown (BstClueHunter *self)
{
GtkWidget *widget = GTK_WIDGET (self);
-
g_return_if_fail (self->popped_up);
-
gtk_widget_hide (widget);
gdk_flush (); /* remove pointer instantly */
gtk_grab_remove (widget);
-
self->popped_up = FALSE;
self->completion_tag = FALSE;
}
-
static void
bst_clue_hunter_add_history (BstClueHunter *self,
const gchar *string)
{
GList *list;
-
for (list = self->clist->row_list; list; list = list->next)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
gchar *ctext = clist_row->cell[self->clist_column].u.text;
-
if (ctext && strcmp (string, ctext) == 0)
return;
}
bst_clue_hunter_add_string (self, string);
}
-
static void
bst_clue_hunter_do_select_on (BstClueHunter *self,
const gchar *cstring)
{
GList *list;
guint len = strlen (cstring);
-
gtk_clist_freeze (self->clist);
gtk_clist_undo_selection (self->clist);
gtk_clist_unselect_all (self->clist);
-
if (len && self->pattern_matching)
{
guint n = 0;
gboolean check_visibility = TRUE;
gchar *pattern = g_strconcat (cstring, "*", NULL);
GPatternSpec *pspec = g_pattern_spec_new (pattern);
-
g_free (pattern);
for (list = self->clist->row_list; list; list = list->next)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
gchar *ctext = clist_row->cell[self->clist_column].u.text;
-
if (ctext && g_pattern_match_string (pspec, ctext))
{
gtk_clist_select_row (self->clist, n, 0);
@@ -879,7 +768,6 @@ bst_clue_hunter_do_select_on (BstClueHunter *self,
{
guint n = 0;
gboolean check_visibility = TRUE;
-
for (list = self->clist->row_list; list; list = list->next)
{
GtkCListRow *clist_row = (GtkCListRow*) list->data;
@@ -897,14 +785,12 @@ bst_clue_hunter_do_select_on (BstClueHunter *self,
}
gtk_clist_thaw (self->clist);
}
-
static gint
bst_clue_hunter_event (GtkWidget *widget,
GdkEvent *event)
{
BstClueHunter *self = BST_CLUE_HUNTER (widget);
gboolean handled = FALSE;
-
switch (event->type)
{
GtkWidget *ev_widget;
@@ -947,7 +833,6 @@ bst_clue_hunter_event (GtkWidget *widget,
else
handled = gtk_widget_event (GTK_WIDGET (self->entry), event);
break;
-
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.window == self->clist->clist_window)
@@ -980,7 +865,6 @@ bst_clue_hunter_event (GtkWidget *widget,
if (ev_widget == widget && event->type == GDK_BUTTON_PRESS)
{
gint w, h;
-
gdk_window_get_size (widget->window, &w, &h);
if (event->button.x > w || event->button.y > h ||
event->button.x < 0 || event->button.y < 0)
@@ -1002,6 +886,5 @@ bst_clue_hunter_event (GtkWidget *widget,
default:
break;
}
-
return handled;
}
diff --git a/beast-gtk/bstcluehunter.hh b/beast-gtk/bstcluehunter.hh
index 67dceae..b425a45 100644
--- a/beast-gtk/bstcluehunter.hh
+++ b/beast-gtk/bstcluehunter.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_CLUE_HUNTER_H__
#define __BST_CLUE_HUNTER_H__
-
#include <gxk/gxk.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BST_TYPE_CLUE_HUNTER (bst_clue_hunter_get_type ())
#define BST_CLUE_HUNTER(object) (GTK_CHECK_CAST ((object), BST_TYPE_CLUE_HUNTER, BstClueHunter))
@@ -16,26 +12,19 @@ extern "C" {
#define BST_IS_CLUE_HUNTER(object) (GTK_CHECK_TYPE ((object), BST_TYPE_CLUE_HUNTER))
#define BST_IS_CLUE_HUNTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_CLUE_HUNTER))
#define BST_CLUE_HUNTER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_CLUE_HUNTER, BstClueHunterClass))
-
-
/* --- typedefs --- */
typedef struct _BstClueHunterClass BstClueHunterClass;
typedef struct _BstClueHunter BstClueHunter;
-
-
/* --- structures --- */
struct _BstClueHunter
{
GtkWindow window;
-
guint popped_up : 1;
guint completion_tag : 1;
guint pattern_matching : 1;
guint keep_history : 1;
guint clist_column : 16;
-
gchar *cstring;
-
GtkWidget *align_widget;
GtkWidget *scw;
GtkCList *clist;
@@ -44,7 +33,6 @@ struct _BstClueHunter
struct _BstClueHunterClass
{
GtkWindowClass parent_class;
-
void (*activate) (BstClueHunter *clue_hunter);
void (*popup) (BstClueHunter *clue_hunter);
void (*popdown) (BstClueHunter *clue_hunter);
@@ -52,8 +40,6 @@ struct _BstClueHunterClass
const gchar *string);
void (*poll_refresh) (BstClueHunter *clue_hunter);
};
-
-
/* --- prototypes --- */
GtkType bst_clue_hunter_get_type (void);
void bst_clue_hunter_popup (BstClueHunter *clue_hunter);
@@ -76,14 +62,7 @@ gchar* bst_clue_hunter_try_complete (BstClueHunter *clue_hunter);
GtkWidget* bst_clue_hunter_create_arrow (BstClueHunter *clue_hunter,
gboolean require_editable);
gpointer bst_clue_hunter_from_entry (gpointer entry);
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-
#endif /* __BST_CLUE_HUNTER_H__ */
diff --git a/beast-gtk/bstcxxutils.cc b/beast-gtk/bstcxxutils.cc
index 76bd1d8..cfbb4ca 100644
--- a/beast-gtk/bstcxxutils.cc
+++ b/beast-gtk/bstcxxutils.cc
@@ -2,9 +2,7 @@
#include "bstcxxutils.hh"
#include "bstusermessage.hh"
#include <birnet/birnet.hh>
-
using namespace Birnet;
-
static void
bstcxx_message_handler (const char *domain,
Msg::Type mtype,
@@ -45,13 +43,11 @@ bstcxx_message_handler (const char *domain,
msg.msg_bits = NULL;
bst_message_handler (&msg);
}
-
extern "C" void
bst_message_handler_install (void)
{
Msg::set_thread_handler (bstcxx_message_handler);
}
-
extern "C" void
bst_message_handler_uninstall (void)
{
diff --git a/beast-gtk/bstcxxutils.hh b/beast-gtk/bstcxxutils.hh
index 9e693fd..07bcc6f 100644
--- a/beast-gtk/bstcxxutils.hh
+++ b/beast-gtk/bstcxxutils.hh
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_XXUTILS_H__
#define __BST_XXUTILS_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
void bst_message_handler_install (void);
void bst_message_handler_uninstall (void);
-
G_END_DECLS
-
#endif /* __BST_XXUTILS_H__ */
diff --git a/beast-gtk/bstdbmeter.cc b/beast-gtk/bstdbmeter.cc
index 9486ea5..6fcf3fc 100644
--- a/beast-gtk/bstdbmeter.cc
+++ b/beast-gtk/bstdbmeter.cc
@@ -2,8 +2,6 @@
#include "bstdbmeter.hh"
#include <string.h>
#include <math.h>
-
-
#define WIDGET(self) (GTK_WIDGET (self))
/* accessors */
#define STATE(self) (GtkStateType (WIDGET (self)->state))
@@ -11,11 +9,8 @@
#define XTHICKNESS(self) (STYLE (self)->xthickness)
#define YTHICKNESS(self) (STYLE (self)->ythickness)
#define ALLOCATION(self) (&WIDGET (self)->allocation)
-
#define DEFAULT_BORDER (20)
#define NUMBER_HPADDING (8) /* extra spacing to seperate numbers horizontally */
-
-
/* --- DB Setup --- */
static BstDBSetup*
bst_db_setup_get_default (void)
@@ -45,7 +40,6 @@ bst_db_setup_get_default (void)
}
return dbsetup;
}
-
static int
db_color_pixel_cmp (const void *v1,
const void *v2)
@@ -54,7 +48,6 @@ db_color_pixel_cmp (const void *v1,
const BstDBColor *c2 = (const BstDBColor*) v2;
return c1->pixel < c2->pixel ? -1 : c1->pixel > c2->pixel;
}
-
BstDBSetup*
bst_db_setup_new (GxkSpline *db2pixel_spline,
double maxdb,
@@ -92,7 +85,6 @@ bst_db_setup_new (GxkSpline *db2pixel_spline,
bst_db_setup_relocate (dbsetup, 0, 99, FALSE);
return dbsetup;
}
-
void
bst_db_setup_relocate (BstDBSetup *dbsetup,
gint offset,
@@ -115,7 +107,6 @@ bst_db_setup_relocate (BstDBSetup *dbsetup,
dbsetup->colors[i].pixel = bst_db_setup_get_pixel (dbsetup, dbsetup->colors[i].db);
qsort (dbsetup->colors, dbsetup->n_colors, sizeof (dbsetup->colors[0]), db_color_pixel_cmp);
}
-
guint
bst_db_setup_get_color (BstDBSetup *dbsetup,
double pixel,
@@ -154,7 +145,6 @@ bst_db_setup_get_color (BstDBSetup *dbsetup,
return (red << 16) | (green << 8) | blue;
}
}
-
BstDBSetup*
bst_db_setup_copy (BstDBSetup *srcdb)
{
@@ -166,7 +156,6 @@ bst_db_setup_copy (BstDBSetup *srcdb)
dbsetup->ref_count = 1;
return dbsetup;
}
-
BstDBSetup*
bst_db_setup_ref (BstDBSetup *dbsetup)
{
@@ -175,7 +164,6 @@ bst_db_setup_ref (BstDBSetup *dbsetup)
dbsetup->ref_count += 1;
return dbsetup;
}
-
void
bst_db_setup_unref (BstDBSetup *dbsetup)
{
@@ -190,7 +178,6 @@ bst_db_setup_unref (BstDBSetup *dbsetup)
g_free (dbsetup);
}
}
-
double
bst_db_setup_get_pixel (BstDBSetup *dbsetup,
double dbvalue)
@@ -200,7 +187,6 @@ bst_db_setup_get_pixel (BstDBSetup *dbsetup,
pixel = (dbsetup->length - 1) - pixel;
return pixel + dbsetup->offset;
}
-
double
bst_db_setup_get_dbvalue (BstDBSetup *dbsetup,
double pixel)
@@ -210,8 +196,6 @@ bst_db_setup_get_dbvalue (BstDBSetup *dbsetup,
pixel = (dbsetup->length - 1) - pixel;
return gxk_spline_findx (dbsetup->spline, pixel / dbsetup->spzoom);
}
-
-
/* --- comon helpers --- */
static void
db_setup_size_allocate (BstDBSetup *dbsetup,
@@ -226,15 +210,12 @@ db_setup_size_allocate (BstDBSetup *dbsetup,
size -= 1; /* account for length = range + 1 pixels */
bst_db_setup_relocate (dbsetup, border, MAX (size, 0), !vertical);
}
-
enum {
PROP_ORIENTATION = 1,
PROP_DRAW_VALUES,
PROP_JUSTIFY,
PROP_N_CHANNELS,
};
-
-
/* --- DB Labeling --- */
G_DEFINE_TYPE (BstDBLabeling, bst_db_labeling, GTK_TYPE_WIDGET);
static void
@@ -248,14 +229,12 @@ bst_db_labeling_init (BstDBLabeling *self)
self->orientation = GTK_ORIENTATION_VERTICAL;
self->justify = GTK_JUSTIFY_CENTER;
}
-
static void
bst_db_labeling_destroy (GtkObject *object)
{
// BstDBLabeling *self = BST_DB_LABELING (object);
GTK_OBJECT_CLASS (bst_db_labeling_parent_class)->destroy (object);
}
-
static void
bst_db_labeling_finalize (GObject *object)
{
@@ -263,7 +242,6 @@ bst_db_labeling_finalize (GObject *object)
bst_db_setup_unref (self->dbsetup);
G_OBJECT_CLASS (bst_db_labeling_parent_class)->finalize (object);
}
-
static PangoLayout*
bst_db_labeling_create_layout (BstDBLabeling *self,
double dB)
@@ -273,7 +251,6 @@ bst_db_labeling_create_layout (BstDBLabeling *self,
g_free (buffer);
return layout;
}
-
static void
bst_db_labeling_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -286,7 +263,6 @@ bst_db_labeling_size_request (GtkWidget *widget,
PangoRectangle irect = { 0, }, lrect = { 0 };
int breadth = 0, length = 0;
PangoLayout *layout;
-
for (uint i = 0; i < self->dbsetup->spline->n_segs; i++)
{
double v = self->dbsetup->spline->segs[i].x;
@@ -312,7 +288,6 @@ bst_db_labeling_size_request (GtkWidget *widget,
pango_layout_get_pixel_extents (layout, &irect, &lrect);
g_object_unref (layout);
guint dash_length = lrect.width;
-
if (self->justify == GTK_JUSTIFY_CENTER)
breadth = 2 * dash_length | 1; /* always request odd size */
else
@@ -329,7 +304,6 @@ bst_db_labeling_size_request (GtkWidget *widget,
requisition->height = breadth;
}
}
-
static void
bst_db_labeling_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -340,7 +314,6 @@ bst_db_labeling_size_allocate (GtkWidget *widget,
guint thickness = vertical ? YTHICKNESS (self) : XTHICKNESS (self);
db_setup_size_allocate (self->dbsetup, thickness, self->border, vertical ? allocation->height : allocation->width, vertical);
}
-
typedef enum {
DRAW_SKIP,
DRAW_ETCHED,
@@ -350,7 +323,6 @@ typedef enum {
DRAW_SUBRO,
DRAW_NUM
} DrawType;
-
static void
db_labeling_draw_lateral_line (BstDBLabeling *self,
GdkGC *gc,
@@ -389,7 +361,6 @@ db_labeling_draw_lateral_line (BstDBLabeling *self,
else /* horizontal */
gdk_draw_vline (drawable, gc, x + pos, y + pixindent, breadth - breadth_reduz);
}
-
static void
db_labeling_draw_vline (BstDBLabeling *self,
GdkGC *gc,
@@ -406,7 +377,6 @@ db_labeling_draw_vline (BstDBLabeling *self,
else /* horizontal */
gdk_draw_hline (drawable, gc, x + pos, y + indent, breadth);
}
-
static void
bst_db_labeling_draw_value (BstDBLabeling *self,
GdkRectangle *expose_area,
@@ -504,7 +474,6 @@ bst_db_labeling_draw_value (BstDBLabeling *self,
db_labeling_draw_lateral_line (self, light_gc, canvas->x, canvas->y, pos + 1, cbreadth, 0);
}
}
-
static gboolean
bst_db_labeling_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -524,7 +493,6 @@ bst_db_labeling_expose (GtkWidget *widget,
gdk_draw_line (widget->window, widget->style->black_gc, widget->allocation.x + widget->allocation.width-1, widget->allocation.y,
widget->allocation.x, widget->allocation.y + widget->allocation.height-1);
}
-
GdkGC *dark_gc = widget->style->light_gc[widget->state];
GdkGC *line_gc = widget->style->fg_gc[widget->state];
GdkGC *light_gc = widget->style->dark_gc[widget->state];
@@ -650,10 +618,8 @@ bst_db_labeling_expose (GtkWidget *widget,
/* vline bar */
if (draw_longitudinal)
db_labeling_draw_vline (self, line_gc, allocation->x, allocation->y, dbsetup->offset, dbsetup->length, longitudinal_pos);
-
return FALSE;
}
-
void
bst_db_labeling_setup (BstDBLabeling *self,
BstDBSetup *db_setup)
@@ -662,7 +628,6 @@ bst_db_labeling_setup (BstDBLabeling *self,
self->dbsetup = bst_db_setup_copy (db_setup);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
void
bst_db_labeling_set_border (BstDBLabeling *self,
guint border)
@@ -673,7 +638,6 @@ bst_db_labeling_set_border (BstDBLabeling *self,
gtk_widget_queue_resize (GTK_WIDGET (self));
}
}
-
static void
bst_db_labeling_set_property (GObject *object,
guint prop_id,
@@ -701,7 +665,6 @@ bst_db_labeling_set_property (GObject *object,
break;
}
}
-
static void
bst_db_labeling_get_property (GObject *object,
guint prop_id,
@@ -725,24 +688,19 @@ bst_db_labeling_get_property (GObject *object,
break;
}
}
-
static void
bst_db_labeling_class_init (BstDBLabelingClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->set_property = bst_db_labeling_set_property;
gobject_class->get_property = bst_db_labeling_get_property;
gobject_class->finalize = bst_db_labeling_finalize;
-
object_class->destroy = bst_db_labeling_destroy;
-
widget_class->size_request = bst_db_labeling_size_request;
widget_class->size_allocate = bst_db_labeling_size_allocate;
widget_class->expose_event = bst_db_labeling_expose;
-
g_object_class_install_property (gobject_class, PROP_DRAW_VALUES,
g_param_spec_boolean ("draw-values", _("Draw Values"), _("Adjust whether to draw dB values instead of lines"),
FALSE, G_PARAM_READWRITE));
@@ -753,11 +711,8 @@ bst_db_labeling_class_init (BstDBLabelingClass *klass)
g_param_spec_enum ("justify", _("Justify"), _("Adjust relative alignment of the values or bars to be drawn"),
GTK_TYPE_JUSTIFICATION, GTK_JUSTIFY_CENTER, G_PARAM_READWRITE));
}
-
-
/* --- DB Beam --- */
G_DEFINE_TYPE (BstDBBeam, bst_db_beam, GTK_TYPE_WIDGET);
-
static void
bst_db_beam_init (BstDBBeam *self)
{
@@ -769,14 +724,12 @@ bst_db_beam_init (BstDBBeam *self)
self->orientation = GTK_ORIENTATION_VERTICAL;
self->currentdb = 0;
}
-
static void
bst_db_beam_destroy (GtkObject *object)
{
// BstDBBeam *self = BST_DB_BEAM (object);
GTK_OBJECT_CLASS (bst_db_beam_parent_class)->destroy (object);
}
-
static void
bst_db_beam_finalize (GObject *object)
{
@@ -784,7 +737,6 @@ bst_db_beam_finalize (GObject *object)
bst_db_setup_unref (self->dbsetup);
G_OBJECT_CLASS (bst_db_beam_parent_class)->finalize (object);
}
-
static void
bst_db_beam_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -792,14 +744,12 @@ bst_db_beam_size_request (GtkWidget *widget,
BstDBBeam *self = BST_DB_BEAM (widget);
const gboolean vertical = self->orientation == GTK_ORIENTATION_VERTICAL;
guint thickness = vertical ? XTHICKNESS (self) : YTHICKNESS (self);
-
/* font width */
PangoRectangle irect = { 0, }, lrect = { 0 };
PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "z");
pango_layout_get_pixel_extents (layout, &irect, &lrect);
g_object_unref (layout);
guint thick_beam = lrect.width;
-
if (vertical)
{
requisition->width = thickness + thick_beam + thickness;
@@ -811,7 +761,6 @@ bst_db_beam_size_request (GtkWidget *widget,
requisition->height = thickness + thick_beam + thickness;
}
}
-
static void
db_beam_redraw_pixmap (BstDBBeam *self)
{
@@ -847,7 +796,6 @@ db_beam_redraw_pixmap (BstDBBeam *self)
}
}
}
-
static void
bst_db_beam_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -860,7 +808,6 @@ bst_db_beam_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_REALIZED (self))
db_beam_redraw_pixmap (self);
}
-
static void
bst_db_beam_realize (GtkWidget *widget)
{
@@ -868,7 +815,6 @@ bst_db_beam_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (bst_db_beam_parent_class)->realize (widget);
db_beam_redraw_pixmap (self);
}
-
static void
bst_db_beam_unrealize (GtkWidget *widget)
{
@@ -877,7 +823,6 @@ bst_db_beam_unrealize (GtkWidget *widget)
self->pixmap = NULL;
GTK_WIDGET_CLASS (bst_db_beam_parent_class)->unrealize (widget);
}
-
static gboolean
bst_db_beam_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -896,7 +841,6 @@ bst_db_beam_expose (GtkWidget *widget,
gdk_draw_line (widget->window, widget->style->black_gc, widget->allocation.x + widget->allocation.width-1, widget->allocation.y,
widget->allocation.x, widget->allocation.y + widget->allocation.height-1);
}
-
/* subtract one pixel in length, since it doesn't make sense to always paint mindb (=silence) highlighted */
if (vertical)
gtk_paint_shadow (STYLE (self), drawable, STATE (self), GTK_SHADOW_IN, NULL, NULL, NULL,
@@ -906,17 +850,14 @@ bst_db_beam_expose (GtkWidget *widget,
gtk_paint_shadow (STYLE (self), drawable, STATE (self), GTK_SHADOW_IN, NULL, NULL, NULL,
allocation->x + dbsetup->offset - XTHICKNESS (self) + dbsetup->flipdir, allocation->y,
dbsetup->length + 2 * XTHICKNESS (self) - 1, allocation->height);
-
/* force complete beam redraw */
double currentdb = self->currentdb;
self->currentdb = G_MAXDOUBLE;
bst_db_beam_set_value (self, currentdb);
self->currentdb = -G_MAXDOUBLE;
bst_db_beam_set_value (self, currentdb);
-
return FALSE;
}
-
void
bst_db_beam_set_value (BstDBBeam *self,
double db)
@@ -963,7 +904,6 @@ bst_db_beam_set_value (BstDBBeam *self,
vertical ? length : allocation->height - 2 * thickness);
}
}
-
void
bst_db_beam_set_border (BstDBBeam *self,
guint border)
@@ -974,7 +914,6 @@ bst_db_beam_set_border (BstDBBeam *self,
gtk_widget_queue_resize (GTK_WIDGET (self));
}
}
-
void
bst_db_beam_setup (BstDBBeam *self,
BstDBSetup *db_setup)
@@ -983,7 +922,6 @@ bst_db_beam_setup (BstDBBeam *self,
self->dbsetup = bst_db_setup_copy (db_setup);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
bst_db_beam_set_property (GObject *object,
guint prop_id,
@@ -1003,7 +941,6 @@ bst_db_beam_set_property (GObject *object,
break;
}
}
-
static void
bst_db_beam_get_property (GObject *object,
guint prop_id,
@@ -1021,35 +958,27 @@ bst_db_beam_get_property (GObject *object,
break;
}
}
-
static void
bst_db_beam_class_init (BstDBBeamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->set_property = bst_db_beam_set_property;
gobject_class->get_property = bst_db_beam_get_property;
gobject_class->finalize = bst_db_beam_finalize;
-
object_class->destroy = bst_db_beam_destroy;
-
widget_class->size_request = bst_db_beam_size_request;
widget_class->size_allocate = bst_db_beam_size_allocate;
widget_class->realize = bst_db_beam_realize;
widget_class->unrealize = bst_db_beam_unrealize;
widget_class->expose_event = bst_db_beam_expose;
-
g_object_class_install_property (gobject_class, PROP_ORIENTATION,
g_param_spec_enum ("orientation", _("Orientation"), _("Choose horizontal or vertical orientation"),
GTK_TYPE_ORIENTATION, GTK_ORIENTATION_VERTICAL, G_PARAM_READWRITE));
}
-
-
/* --- DB Meter --- */
G_DEFINE_TYPE (BstDBMeter, bst_db_meter, GTK_TYPE_ALIGNMENT);
-
static void
bst_db_meter_init (BstDBMeter *self)
{
@@ -1062,7 +991,6 @@ bst_db_meter_init (BstDBMeter *self)
"yalign", 0.5,
NULL);
}
-
static void
bst_db_meter_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -1074,10 +1002,8 @@ bst_db_meter_size_allocate (GtkWidget *widget,
db_setup_size_allocate (self->dbsetup, thickness, self->border,
vertical ? widget->allocation.height : widget->allocation.width, vertical);
}
-
static void db_meter_build_channels (BstDBMeter *self,
guint n_channels);
-
static void
bst_db_meter_set_property (GObject *object,
guint prop_id,
@@ -1110,7 +1036,6 @@ bst_db_meter_set_property (GObject *object,
break;
}
}
-
static void
bst_db_meter_get_property (GObject *object,
guint prop_id,
@@ -1128,7 +1053,6 @@ bst_db_meter_get_property (GObject *object,
break;
}
}
-
GtkWidget*
bst_db_meter_new (GtkOrientation orientation,
guint n_channels)
@@ -1136,14 +1060,12 @@ bst_db_meter_new (GtkOrientation orientation,
BstDBMeter *self = (BstDBMeter*) g_object_new (BST_TYPE_DB_METER, "orientation", orientation, "n-channels", n_channels, NULL);
return GTK_WIDGET (self);
}
-
static void
bst_db_meter_destroy (GtkObject *object)
{
// BstDBMeter *self = BST_DB_METER (object);
GTK_OBJECT_CLASS (bst_db_meter_parent_class)->destroy (object);
}
-
static void
bst_db_meter_finalize (GObject *object)
{
@@ -1152,7 +1074,6 @@ bst_db_meter_finalize (GObject *object)
self->dbsetup = NULL;
G_OBJECT_CLASS (bst_db_meter_parent_class)->finalize (object);
}
-
static void
db_meter_setup_recursive (GtkWidget *widget,
gpointer data)
@@ -1165,7 +1086,6 @@ db_meter_setup_recursive (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget), db_meter_setup_recursive, data);
}
-
void
bst_db_meter_propagate_setup (BstDBMeter *self,
BstDBSetup *db_setup)
@@ -1176,7 +1096,6 @@ bst_db_meter_propagate_setup (BstDBMeter *self,
self->dbsetup = bst_db_setup_copy (db_setup);
db_meter_setup_recursive (GTK_WIDGET (self), self->dbsetup);
}
-
static void
db_meter_set_border_recursive (GtkWidget *widget,
gpointer data)
@@ -1189,7 +1108,6 @@ db_meter_set_border_recursive (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget), db_meter_set_border_recursive, data);
}
-
void
bst_db_meter_propagate_border (BstDBMeter *self,
guint border)
@@ -1201,7 +1119,6 @@ bst_db_meter_propagate_border (BstDBMeter *self,
db_meter_set_border_recursive (GTK_WIDGET (self), GUINT_TO_POINTER (self->border));
}
}
-
BstDBBeam*
bst_db_meter_create_beam (BstDBMeter *self,
guint padding)
@@ -1219,7 +1136,6 @@ bst_db_meter_create_beam (BstDBMeter *self,
}
return aux;
}
-
BstDBLabeling*
bst_db_meter_create_numbers (BstDBMeter *self,
guint padding)
@@ -1238,7 +1154,6 @@ bst_db_meter_create_numbers (BstDBMeter *self,
}
return aux;
}
-
BstDBLabeling*
bst_db_meter_create_dashes (BstDBMeter *self,
GtkJustification justify,
@@ -1259,7 +1174,6 @@ bst_db_meter_create_dashes (BstDBMeter *self,
}
return aux;
}
-
static void
db_scale_pixel_adjustment_value_changed_unconverted (GtkAdjustment *adjustment,
GxkParam *param)
@@ -1275,7 +1189,6 @@ db_scale_pixel_adjustment_value_changed_unconverted (GtkAdjustment *adjustment,
g_value_unset (&dvalue);
gxk_param_apply_value (param);
}
-
static void
db_scale_pixel_adjustment_update_unconverted (GxkParam *param,
GtkObject *object)
@@ -1287,7 +1200,6 @@ db_scale_pixel_adjustment_update_unconverted (GxkParam *param,
gtk_adjustment_set_value (GTK_ADJUSTMENT (object), bst_db_setup_get_pixel (dbsetup, g_value_get_double (&dvalue)));
g_value_unset (&dvalue);
}
-
static void
db_scale_pixel_adjustment_value_changed (GtkAdjustment *adjustment,
GxkParam *param)
@@ -1304,7 +1216,6 @@ db_scale_pixel_adjustment_value_changed (GtkAdjustment *adjustment,
g_value_unset (&dvalue);
gxk_param_apply_value (param);
}
-
static void
db_scale_pixel_adjustment_update (GxkParam *param,
GtkObject *object)
@@ -1321,7 +1232,6 @@ db_scale_pixel_adjustment_update (GxkParam *param,
gtk_adjustment_set_value (GTK_ADJUSTMENT (object), bst_db_setup_get_pixel (dbsetup, dbvalue));
g_value_unset (&dvalue);
}
-
void
bst_db_scale_hook_up_param (GtkRange *range,
GxkParam *param)
@@ -1346,7 +1256,6 @@ bst_db_scale_hook_up_param (GtkRange *range,
/* save param for GtkRange */
g_object_set_data ((GObject*) range, "GxkParam", param);
}
-
static void
db_scale_size_allocate (GtkRange *range,
GtkAllocation *dummy,
@@ -1419,7 +1328,6 @@ db_scale_size_allocate (GtkRange *range,
if (param)
gxk_param_update (param);
}
-
GtkRange*
bst_db_meter_create_scale (BstDBMeter *self,
guint padding)
@@ -1447,7 +1355,6 @@ bst_db_meter_create_scale (BstDBMeter *self,
}
return range;
}
-
static gpointer
db_meter_get_child (BstDBMeter *self,
guint nth,
@@ -1473,28 +1380,24 @@ db_meter_get_child (BstDBMeter *self,
}
return child;
}
-
GtkRange*
bst_db_meter_get_scale (BstDBMeter *self,
guint nth)
{
return (GtkRange*) db_meter_get_child (self, nth, GTK_TYPE_RANGE);
}
-
BstDBBeam*
bst_db_meter_get_beam (BstDBMeter *self,
guint nth)
{
return (BstDBBeam*) db_meter_get_child (self, nth, BST_TYPE_DB_BEAM);
}
-
BstDBLabeling*
bst_db_meter_get_labeling (BstDBMeter *self,
guint nth)
{
return (BstDBLabeling*) db_meter_get_child (self, nth, BST_TYPE_DB_LABELING);
}
-
static void
db_meter_build_channels (BstDBMeter *self,
guint n_channels)
@@ -1525,22 +1428,17 @@ db_meter_build_channels (BstDBMeter *self,
bst_db_meter_create_scale (self, padding);
}
}
-
static void
bst_db_meter_class_init (BstDBMeterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->set_property = bst_db_meter_set_property;
gobject_class->get_property = bst_db_meter_get_property;
gobject_class->finalize = bst_db_meter_finalize;
-
object_class->destroy = bst_db_meter_destroy;
-
widget_class->size_allocate = bst_db_meter_size_allocate;
-
g_object_class_install_property (gobject_class, PROP_ORIENTATION,
g_param_spec_enum ("orientation", _("Orientation"), _("Choose horizontal or vertical orientation"),
GTK_TYPE_ORIENTATION, GTK_ORIENTATION_VERTICAL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
diff --git a/beast-gtk/bstdbmeter.hh b/beast-gtk/bstdbmeter.hh
index 5e9cb1a..130f36b 100644
--- a/beast-gtk/bstdbmeter.hh
+++ b/beast-gtk/bstdbmeter.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_DB_METER_H__
#define __BST_DB_METER_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- DB Setup --- */
typedef struct {
double db;
@@ -40,7 +37,6 @@ double bst_db_setup_get_pixel (BstDBSetup *dbsetup,
double dbvalue);
double bst_db_setup_get_dbvalue (BstDBSetup *dbsetup,
double pixel);
-
/* --- type macros --- */
#define BST_TYPE_DB_LABELING (bst_db_labeling_get_type ())
#define BST_DB_LABELING(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_DB_LABELING, BstDBLabeling))
@@ -62,7 +58,6 @@ void bst_db_labeling_setup (BstDBLabeling *self,
BstDBSetup *db_setup);
void bst_db_labeling_set_border (BstDBLabeling *self,
guint border);
-
/* --- type macros --- */
#define BST_TYPE_DB_BEAM (bst_db_beam_get_type ())
#define BST_DB_BEAM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_DB_BEAM, BstDBBeam))
@@ -86,7 +81,6 @@ void bst_db_beam_set_border (BstDBBeam *self,
guint border);
void bst_db_beam_set_value (BstDBBeam *self,
double db);
-
/* --- type macros --- */
#define BST_TYPE_DB_METER (bst_db_meter_get_type ())
#define BST_DB_METER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_DB_METER, BstDBMeter))
@@ -94,7 +88,6 @@ void bst_db_beam_set_value (BstDBBeam *self,
#define BST_IS_DB_METER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_DB_METER))
#define BST_IS_DB_METER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_DB_METER))
#define BST_DB_METER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_DB_METER, BstDBMeterClass))
-
/* --- API --- */
typedef struct {
GtkAlignment parent_instance;
@@ -127,7 +120,5 @@ BstDBLabeling* bst_db_meter_get_labeling (BstDBMeter *self,
guint nth);
void bst_db_scale_hook_up_param (GtkRange *range,
GxkParam *param);
-
G_END_DECLS
-
#endif /* __BST_DB_METER_H__ */
diff --git a/beast-gtk/bstdefs.hh b/beast-gtk/bstdefs.hh
index 6ad5057..cdbeb71 100644
--- a/beast-gtk/bstdefs.hh
+++ b/beast-gtk/bstdefs.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_DEFS_H__
#define __BST_DEFS_H__
-
#include <gxk/gxk.hh>
#include <libintl.h>
#include "bstzoomedwindow.hh"
-
G_BEGIN_DECLS
-
-
/* --- generic constants --- */
typedef enum {
BST_QUANTIZE_NONE = 0,
@@ -22,10 +18,7 @@ typedef enum {
BST_QUANTIZE_NOTE_128 = 128,
BST_QUANTIZE_TACT = 65535
} BstQuantizationType;
-
-
typedef struct _BstKeyBinding BstKeyBinding;
-
/* choose IDs that are unlikely to clash with category IDs */
#define BST_COMMON_ROLL_TOOL_FIRST (G_MAXINT - 100000)
typedef enum /*< skip >*/
@@ -46,14 +39,10 @@ typedef enum /*< skip >*/
BST_COMMON_ROLL_TOOL_MOVE_TICK_RIGHT,
BST_COMMON_ROLL_TOOL_LAST
} BstCommonRollTool;
-
-
/* --- constants & defines --- */
#define BST_TAG_DIAMETER (20)
#define BST_STRDUP_RC_FILE() (g_strconcat (g_get_home_dir (), "/.beast/beastrc", NULL))
#define BST_STRDUP_SKIN_PATH() (g_strconcat (BST_PATH_SKINS, ":~/.beast/skins/:~/.beast/skins/*/", NULL))
-
-
/* --- configuration candidates --- */
/* mouse button numbers and masks for drag operations */
#define BST_DRAG_BUTTON_COPY (1)
@@ -61,8 +50,6 @@ typedef enum /*< skip >*/
#define BST_DRAG_BUTTON_MOVE (2)
#define BST_DRAG_BUTTON_MOVE_MASK (GDK_BUTTON2_MASK)
#define BST_DRAG_BUTTON_CONTEXT (3) /* delete, clone, linkdup */
-
-
/* --- miscellaneous --- */
#define BST_DVL_HINTS (bst_developer_hints != FALSE)
#define BST_DBG_EXT (bst_debug_extensions != FALSE)
@@ -71,21 +58,14 @@ typedef enum /*< skip >*/
if (GTK_IS_OBJECT (object)) \
g_signal_emit_by_name (object, "notify::generic-change", NULL); \
} G_STMT_END
-
-
/* --- i18n and gettext helpers --- */
#define BEAST_GETTEXT_DOMAIN (NULL)
#define _(str) dgettext (BEAST_GETTEXT_DOMAIN, str)
#define N_(str) (str)
-
-
/* --- internal stuff --- */
void beast_show_about_box (void);
extern gboolean bst_developer_hints;
extern gboolean bst_debug_extensions;
extern gboolean bst_main_loop_running;
-
-
G_END_DECLS
-
#endif /* __BST_DEFS_H__ */
diff --git a/beast-gtk/bstdial.cc b/beast-gtk/bstdial.cc
index 91b4828..d016ac4 100644
--- a/beast-gtk/bstdial.cc
+++ b/beast-gtk/bstdial.cc
@@ -1,16 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstdial.hh"
-
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <math.h>
#include <stdio.h>
-
#define SCROLL_DELAY_LENGTH 300
#define DIAL_DEFAULT_SIZE 30
#define RATIO 0.75752
#define HCENTER (1.0 / (2 * RATIO))
-
static void bst_dial_class_init (BstDialClass *klass);
static void bst_dial_init (BstDial *dial);
static void bst_dial_destroy (GtkObject *object);
@@ -37,14 +34,11 @@ static void bst_dial_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static void bst_dial_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
-
static GtkWidgetClass *parent_class = NULL;
-
GtkType
bst_dial_get_type (void)
{
static GtkType dial_type = 0;
-
if (!dial_type)
{
GtkTypeInfo dial_info =
@@ -58,23 +52,17 @@ bst_dial_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
dial_type = gtk_type_unique (GTK_TYPE_WIDGET, &dial_info);
}
-
return dial_type;
}
-
static void
bst_dial_class_init (BstDialClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = (GtkWidgetClass*) g_type_class_peek_parent (klass);
-
object_class->destroy = bst_dial_destroy;
-
widget_class->size_request = bst_dial_size_request;
widget_class->size_allocate = bst_dial_size_allocate;
widget_class->realize = bst_dial_realize;
@@ -83,7 +71,6 @@ bst_dial_class_init (BstDialClass *klass)
widget_class->button_release_event = bst_dial_button_release;
widget_class->motion_notify_event = bst_dial_motion_notify;
}
-
static void
bst_dial_init (BstDial *dial)
{
@@ -98,41 +85,32 @@ bst_dial_init (BstDial *dial)
dial->old_upper = 0.0;
dial->adjustment = NULL;
}
-
static void
bst_dial_destroy (GtkObject *object)
{
BstDial *dial;
-
g_return_if_fail (BST_IS_DIAL (object));
-
dial = BST_DIAL (object);
-
bst_dial_set_align_widget (dial, 0, 0, 0);
-
if (dial->timer)
{
gtk_timeout_remove (dial->timer);
dial->timer = 0;
}
-
if (dial->adjustment)
{
gtk_signal_disconnect_by_data (dial->adjustment, dial);
gtk_object_unref (dial->adjustment);
dial->adjustment = NULL;
}
-
/* chain parent class' handler */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_dial_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
BstDial *dial = BST_DIAL (widget);
-
if (dial->align_widget)
{
gtk_widget_size_request (dial->align_widget, requisition);
@@ -153,25 +131,21 @@ bst_dial_size_request (GtkWidget *widget,
requisition->height = DIAL_DEFAULT_SIZE * RATIO + 0.5;
}
}
-
static void
bst_dial_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstDial *dial = BST_DIAL (widget);
-
/* center widget within given allocation
*/
widget->allocation.width = MIN (allocation->width, allocation->height / RATIO);
widget->allocation.height = widget->allocation.width * RATIO;
widget->allocation.x = allocation->x + (allocation->width - widget->allocation.width) / 2;
widget->allocation.y = allocation->y + (allocation->height - widget->allocation.height) / 2;
-
/* determine dial radius and pointer width from allocation
*/
dial->radius = MAX (widget->allocation.width, 2) / 2;
dial->pointer_width = dial->radius * 0.25;
-
/* position widget's window accordingly
*/
if (GTK_WIDGET_REALIZED (widget))
@@ -179,16 +153,13 @@ bst_dial_size_allocate (GtkWidget *widget,
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
}
-
static void
bst_dial_realize (GtkWidget *widget)
{
// BstDial *dial = BST_DIAL (widget);
GdkWindowAttr attributes;
gint attributes_mask;
-
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = widget->allocation.width;
@@ -201,32 +172,25 @@ bst_dial_realize (GtkWidget *widget)
GDK_POINTER_MOTION_HINT_MASK);
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
-
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, widget);
-
widget->style = gtk_style_attach (widget->style, widget->window);
-
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
}
-
static gint
bst_dial_expose (GtkWidget *widget,
GdkEventExpose *event)
{
g_return_val_if_fail (BST_IS_DIAL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
/* since we redraw the whole widget from scratch, we ignore
* intermediate expose events
*/
if (event->count == 0)
bst_dial_paint (BST_DIAL (widget));
-
return TRUE;
}
-
static void
bst_dial_paint (BstDial *dial)
{
@@ -237,12 +201,10 @@ bst_dial_paint (BstDial *dial)
gint xc, yc;
gint tick_length, n_steps, thick_step;
guint i, pointer_width, radius;
-
xc = widget->allocation.width / 2;
yc = (widget->allocation.height - dial->radius) / 2 + dial->radius;
pointer_width = dial->pointer_width;
radius = dial->radius;
-
/* clear paintable area
*/
/* fill upper part */
@@ -275,7 +237,6 @@ bst_dial_paint (BstDial *dial)
xc - radius, yc,
xc + radius, yc);
radius -= 1;
-
/* draw the ticks
*/
if (widget->allocation.width >= DIAL_DEFAULT_SIZE * 2)
@@ -293,10 +254,8 @@ bst_dial_paint (BstDial *dial)
theta = M_PI - (i * M_PI / ((double) n_steps));
s = sin (theta);
c = cos (theta);
-
/* draw every nth tick with doubled length */
tick_length = (i % thick_step == 0) ? pointer_width : pointer_width / 2;
-
/* draw the ticks as a polygon to get proper shading */
points[0].x = xc + c * (radius - tick_length);
points[0].y = yc - s * (radius - tick_length);
@@ -312,7 +271,6 @@ bst_dial_paint (BstDial *dial)
else
gdk_draw_polygon (widget->window, widget->style->black_gc, FALSE, points, 2);
}
-
/* draw the pointer
*/
s = sin (dial->angle);
@@ -342,67 +300,51 @@ bst_dial_paint (BstDial *dial)
/*gdk_draw_line (widget->window, widget->style->black_gc,
xc, yc, xc + c * radius, yc - s * radius);*/
}
-
static gint
bst_dial_button_press (GtkWidget *widget,
GdkEventButton *event)
{
BstDial *dial = BST_DIAL (widget);
-
if (!dial->button)
{
dial->button = event->button;
-
bst_dial_mouse_update (dial, event->x, event->y);
}
-
return TRUE;
}
-
static gint
bst_dial_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
BstDial *dial = BST_DIAL (widget);
-
if (dial->button != 0 && event->window == widget->window)
{
if (event->is_hint)
gdk_window_get_pointer (widget->window, NULL, NULL, NULL);
-
bst_dial_mouse_update (dial, event->x, event->y);
}
-
return TRUE;
}
-
static gint
bst_dial_button_release (GtkWidget *widget,
GdkEventButton *event)
{
BstDial *dial = BST_DIAL (widget);
-
if (dial->button == event->button)
{
GtkAdjustment *adjustment = GTK_ADJUSTMENT (dial->adjustment);
-
bst_dial_mouse_update (dial, event->x, event->y);
-
dial->button = 0;
-
if (dial->timer)
{
gtk_timeout_remove (dial->timer);
dial->timer = 0;
}
-
if (dial->old_value != adjustment->value)
gtk_adjustment_value_changed (GTK_ADJUSTMENT (dial->adjustment));
}
-
return TRUE;
}
-
static void
bst_dial_mouse_update (BstDial *dial,
gint x,
@@ -412,16 +354,12 @@ bst_dial_mouse_update (BstDial *dial,
GtkWidget *widget;
gint xc, yc;
gdouble angle;
-
g_return_if_fail (BST_IS_DIAL (dial));
-
widget = GTK_WIDGET (dial);
adjustment = GTK_ADJUSTMENT (dial->adjustment);
-
/* figure the arc's center */
xc = widget->allocation.width / 2;
yc = (widget->allocation.height - dial->radius) / 2 + dial->radius;
-
/* calculate the angle of the button click, constrained to the
* viewable area of the arc
*/
@@ -433,11 +371,9 @@ bst_dial_mouse_update (BstDial *dial,
if (angle > M_PI)
angle = M_PI;
dial->angle = angle;
-
/* compute new adjustment value, translated to its lower...upper range */
adjustment->value = (adjustment->lower +
(1.0 - angle / M_PI) * (adjustment->upper - adjustment->lower - adjustment->page_size));
-
/* if the adjustment value changed:
* - for continuous updates: emit the GtkAdjustment::value_changed signal
* - for delayed updates: install a timer to emit the changed signal, if
@@ -455,12 +391,10 @@ bst_dial_mouse_update (BstDial *dial,
/* restart timer, so the delay interval starts from scratch */
if (dial->timer)
gtk_timeout_remove (dial->timer);
-
dial->timer = gtk_timeout_add (SCROLL_DELAY_LENGTH,
bst_dial_timer,
dial);
}
-
/* immediately update the widget, so the GUI is responsive and
* not delayed like the ::value_changed signal
*/
@@ -468,66 +402,48 @@ bst_dial_mouse_update (BstDial *dial,
}
}
}
-
static gboolean
bst_dial_timer (gpointer data)
{
BstDial *dial;
-
GDK_THREADS_ENTER ();
-
dial = BST_DIAL (data);
-
gtk_adjustment_value_changed (GTK_ADJUSTMENT (dial->adjustment));
-
dial->timer = 0;
-
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
GtkWidget*
bst_dial_new (GtkAdjustment *adjustment)
{
GtkWidget *dial;
-
if (adjustment)
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
else
adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 250.0, 0.0, 0.0, 0.0);
-
dial = gtk_widget_new (BST_TYPE_DIAL, NULL);
-
bst_dial_set_adjustment (BST_DIAL (dial), adjustment);
-
return dial;
}
-
GtkAdjustment*
bst_dial_get_adjustment (BstDial *dial)
{
g_return_val_if_fail (BST_IS_DIAL (dial), NULL);
-
return GTK_ADJUSTMENT (dial->adjustment);
}
-
void
bst_dial_set_update_policy (BstDial *dial,
GtkUpdateType policy)
{
g_return_if_fail (BST_IS_DIAL (dial));
-
if (dial->update_policy != policy)
{
dial->update_policy = policy;
-
/* remove a pending timer if necessary */
if (dial->timer)
{
gtk_timeout_remove (dial->timer);
dial->timer = 0;
-
/* perform pending notification */
if (policy == GTK_UPDATE_CONTINUOUS &&
dial->old_value != GTK_ADJUSTMENT (dial->adjustment)->value)
@@ -535,25 +451,20 @@ bst_dial_set_update_policy (BstDial *dial,
}
}
}
-
void
bst_dial_set_adjustment (BstDial *dial,
GtkAdjustment *adjustment)
{
g_return_if_fail (BST_IS_DIAL (dial));
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
if (dial->adjustment)
{
gtk_signal_disconnect_by_data (dial->adjustment, dial);
gtk_object_unref (dial->adjustment);
}
-
dial->adjustment = GTK_OBJECT (adjustment);
-
gtk_object_ref (dial->adjustment);
gtk_object_sink (dial->adjustment);
-
gtk_signal_connect (dial->adjustment,
"changed",
GTK_SIGNAL_FUNC (bst_dial_adjustment_changed),
@@ -562,26 +473,20 @@ bst_dial_set_adjustment (BstDial *dial,
"value_changed",
GTK_SIGNAL_FUNC (bst_dial_adjustment_value_changed),
dial);
-
dial->old_value = adjustment->value;
dial->old_lower = adjustment->lower;
dial->old_upper = adjustment->upper;
dial->old_page_size = adjustment->page_size;
-
bst_dial_update (dial);
}
-
static void
bst_dial_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
BstDial *dial;
-
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
g_return_if_fail (data != NULL);
-
dial = BST_DIAL (data);
-
if (dial->old_value != adjustment->value ||
dial->old_lower != adjustment->lower ||
dial->old_upper != adjustment->upper ||
@@ -591,44 +496,33 @@ bst_dial_adjustment_changed (GtkAdjustment *adjustment,
dial->old_lower = adjustment->lower;
dial->old_upper = adjustment->upper;
dial->old_page_size = adjustment->page_size;
-
bst_dial_update (dial);
}
}
-
static void
bst_dial_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
BstDial *dial;
-
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
g_return_if_fail (data != NULL);
-
dial = BST_DIAL (data);
-
if (dial->old_value != adjustment->value)
{
dial->old_value = adjustment->value;
-
bst_dial_update (dial);
}
}
-
static void
bst_dial_update (BstDial *dial)
{
GtkAdjustment *adjustment;
GtkWidget *widget;
gdouble new_value;
-
g_return_if_fail (BST_IS_DIAL (dial));
-
widget = GTK_WIDGET (dial);
adjustment = GTK_ADJUSTMENT (dial->adjustment);
-
new_value = CLAMP (adjustment->value, adjustment->lower, adjustment->upper - adjustment->page_size);
-
if (new_value != adjustment->value)
{
if (0)
@@ -637,13 +531,10 @@ bst_dial_update (BstDial *dial)
adjustment->value = new_value;
gtk_adjustment_value_changed (GTK_ADJUSTMENT (dial->adjustment));
}
-
dial->angle = (M_PI - M_PI * (adjustment->value - adjustment->lower) /
(adjustment->upper - adjustment->page_size - adjustment->lower));
-
gtk_widget_queue_draw (widget);
}
-
void
bst_dial_set_align_widget (BstDial *dial,
GtkWidget *widget,
@@ -659,7 +550,6 @@ bst_dial_set_align_widget (BstDial *dial,
height_align = height_align != FALSE;
g_return_if_fail (width_align ^ height_align);
}
-
if (dial->align_widget)
g_object_unref (dial->align_widget);
dial->align_widget = widget;
diff --git a/beast-gtk/bstdial.hh b/beast-gtk/bstdial.hh
index 8e1a4a0..96072cb 100644
--- a/beast-gtk/bstdial.hh
+++ b/beast-gtk/bstdial.hh
@@ -1,57 +1,42 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_DIAL_H__
#define __BST_DIAL_H__
-
#include <gtk/gtkadjustment.h>
#include <gtk/gtkwidget.h>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
#define BST_TYPE_DIAL (bst_dial_get_type ())
#define BST_DIAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_DIAL, BstDial))
#define BST_DIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BST_TYPE_DIAL, BstDialClass))
#define BST_IS_DIAL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_DIAL))
#define BST_IS_DIAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_DIAL))
#define BST_DIAL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_DIAL, BstDialClass))
-
-
typedef struct _BstDial BstDial;
typedef struct _BstDialClass BstDialClass;
struct _BstDial
{
GtkWidget parent_object;
-
/* The update policy: GTK_UPDATE_CONTINUOUS,
* GTK_UPDATE_DISCONTINUOUS or GTK_UPDATE_DELAYED
*/
GtkUpdateType update_policy;
-
GtkWidget *align_widget;
guint align_width : 1;
-
/* The button currently pressed or 0 if none */
guint8 button;
-
/* Dimensions of dial components */
gint radius;
gint pointer_width;
-
/* ID of update timer for delayed updates, or 0 if none */
guint timer;
-
/* Current angle of the pointer */
gdouble angle;
-
/* Old values from GtkAdjustment, stored so we know when something changed */
gdouble old_value;
gdouble old_lower;
gdouble old_upper;
gdouble old_page_size;
-
/* The adjustment object that stores the data for this dial */
GtkObject *adjustment;
};
@@ -59,8 +44,6 @@ struct _BstDialClass
{
GtkWidgetClass parent_class;
};
-
-
GtkType bst_dial_get_type (void);
GtkWidget* bst_dial_new (GtkAdjustment *adjustment);
void bst_dial_set_adjustment (BstDial *dial,
@@ -72,10 +55,7 @@ void bst_dial_set_align_widget (BstDial *dial,
GtkWidget *widget,
gboolean width_align,
gboolean height_align);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_DIAL_H__ */
-
diff --git a/beast-gtk/bsteffectview.cc b/beast-gtk/bsteffectview.cc
index fb039bf..81f8cf8 100644
--- a/beast-gtk/bsteffectview.cc
+++ b/beast-gtk/bsteffectview.cc
@@ -1,10 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsteffectview.hh"
-
#include "bstparamview.hh"
-
-
-
/* --- prototypes --- */
static void bst_effect_view_class_init (BstEffectViewClass *klass);
static void bst_effect_view_init (BstEffectView *effect_view);
@@ -19,19 +15,14 @@ static void add_effect (BstEffectView *effect_view);
static void remove_effect (BstEffectView *effect_view);
static void alist_selection_changed (BstEffectView *effect_view);
static void plist_selection_changed (BstEffectView *effect_view);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static BstEffectViewClass *bst_effect_view_class = NULL;
-
-
/* --- functions --- */
GtkType
bst_effect_view_get_type (void)
{
static GtkType effect_view_type = 0;
-
if (!effect_view_type)
{
GtkTypeInfo effect_view_info =
@@ -45,34 +36,25 @@ bst_effect_view_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
effect_view_type = gtk_type_unique (GTK_TYPE_ALIGNMENT, &effect_view_info);
}
-
return effect_view_type;
}
-
static void
bst_effect_view_class_init (BstEffectViewClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
bst_effect_view_class = klass;
parent_class = gtk_type_class (GTK_TYPE_ALIGNMENT);
-
G_OBJECT_CLASS (klass)->finalize = bst_effect_view_finalize;
-
object_class->destroy = bst_effect_view_destroy;
-
klass->default_param_view_height = 60;
}
-
static void
bst_effect_view_init (BstEffectView *effect_view)
{
GtkWidget *alist_box, *pbox, *bbox, *sc_win;
GtkCList *clist;
-
/* setup containers */
effect_view->paned = gtk_widget_new (GTK_TYPE_HPANED,
"visible", TRUE,
@@ -109,7 +91,6 @@ bst_effect_view_init (BstEffectView *effect_view)
"yalign", 0.5,
NULL),
FALSE, TRUE, 0);
-
/* setup lists */
sc_win = gtk_widget_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
@@ -163,7 +144,6 @@ bst_effect_view_init (BstEffectView *effect_view)
gtk_clist_set_column_auto_resize (clist, 0, TRUE);
gtk_clist_column_titles_show (clist);
gtk_clist_column_titles_passive (clist);
-
/* setup param view */
effect_view->param_view = bst_param_view_new (0);
gtk_widget_set (effect_view->param_view,
@@ -173,7 +153,6 @@ bst_effect_view_init (BstEffectView *effect_view)
NULL);
gtk_widget_ref (effect_view->param_view);
bst_param_view_set_mask (BST_PARAM_VIEW (effect_view->param_view), BSE_TYPE_EFFECT, 0, NULL, NULL);
-
/* setup buttons */
effect_view->add_button = g_object_connect (gtk_widget_new (GTK_TYPE_BUTTON,
"visible", TRUE,
@@ -193,51 +172,38 @@ bst_effect_view_init (BstEffectView *effect_view)
"swapped_signal::clicked", remove_effect, effect_view,
NULL);
gtk_widget_ref (effect_view->remove_button);
-
effect_view->pattern = NULL;
effect_view->channel = 0;
effect_view->row = 0;
}
-
static void
bst_effect_view_destroy (GtkObject *object)
{
BstEffectView *effect_view = BST_EFFECT_VIEW (object);
-
bst_effect_view_set_note (effect_view, NULL, 0, 0);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_effect_view_finalize (GObject *object)
{
BstEffectView *effect_view = BST_EFFECT_VIEW (object);
-
bst_effect_view_set_note (effect_view, NULL, 0, 0);
-
gtk_widget_unref (effect_view->paned);
gtk_widget_unref (effect_view->clist_aeffects);
gtk_widget_unref (effect_view->clist_peffects);
gtk_widget_unref (effect_view->param_view);
gtk_widget_unref (effect_view->add_button);
gtk_widget_unref (effect_view->remove_button);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
GtkWidget*
bst_effect_view_new (BseSong *song)
{
GtkWidget *effect_view;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
effect_view = gtk_widget_new (BST_TYPE_EFFECT_VIEW, NULL);
-
return effect_view;
}
-
void
bst_effect_view_set_note (BstEffectView *effect_view,
BsePattern *pattern,
@@ -256,7 +222,6 @@ bst_effect_view_set_note (BstEffectView *effect_view,
channel = 0;
row = 0;
}
-
if (effect_view->pattern)
{
g_object_disconnect (effect_view->pattern,
@@ -276,7 +241,6 @@ bst_effect_view_set_note (BstEffectView *effect_view,
}
update_effect_lists (effect_view);
}
-
static void
bst_effect_view_note_changed (BstEffectView *effect_view,
guint channel,
@@ -284,26 +248,21 @@ bst_effect_view_note_changed (BstEffectView *effect_view,
BsePattern *pattern)
{
g_return_if_fail (effect_view->pattern == pattern);
-
if (channel == effect_view->channel && row == effect_view->row)
update_effect_lists (effect_view);
}
-
static void
update_effect_lists (BstEffectView *effect_view)
{
GtkCList *aclist = GTK_CLIST (effect_view->clist_aeffects);
GtkCList *pclist = GTK_CLIST (effect_view->clist_peffects);
-
if (aclist && pclist)
{
guint i, n_effects = 0, ptype = ~0;
-
if (!aclist->selection)
{
BseCategory *cats;
guint n_cats;
-
gtk_clist_freeze (aclist);
gtk_clist_clear (aclist);
cats = bse_categories_match_typed ("/Effect/""*", BSE_TYPE_EFFECT, &n_cats);
@@ -311,14 +270,12 @@ update_effect_lists (BstEffectView *effect_view)
{
gchar *name = cats[i].category + cats[i].mindex + 1;
gint clist_row = gtk_clist_insert (aclist, 0, &name);
-
gtk_clist_set_row_data (aclist, clist_row, (gpointer) cats[i].type);
}
g_free (cats);
gtk_clist_select_row (aclist, 0, -1);
gtk_clist_thaw (aclist);
}
-
ptype = (GType) gtk_clist_get_selection_data (pclist, 0);
gtk_clist_freeze (pclist);
gtk_clist_clear (pclist);
@@ -336,11 +293,9 @@ update_effect_lists (BstEffectView *effect_view)
effect_view->channel,
effect_view->row,
i);
-
cats = bse_categories_from_type (BSE_OBJECT_TYPE (effect), &n_cats);
name = cats ? cats[0].category + cats[0].mindex + 1 : g_type_name (BSE_OBJECT_TYPE (effect));
g_free (cats);
-
clist_row = gtk_clist_insert (pclist, 0, &name);
gtk_clist_set_row_data (pclist, clist_row, GUINT_TO_POINTER (BSE_OBJECT_TYPE (effect)));
if (BSE_OBJECT_TYPE (effect) == ptype)
@@ -353,36 +308,29 @@ update_effect_lists (BstEffectView *effect_view)
gtk_clist_select_row (pclist, 0, -1);
gtk_clist_thaw (pclist);
}
-
alist_selection_changed (effect_view);
plist_selection_changed (effect_view);
}
-
static void
add_effect (BstEffectView *effect_view)
{
GtkCList *aclist = GTK_CLIST (effect_view->clist_aeffects);
-
if (aclist && aclist->selection && effect_view->pattern)
bse_pattern_note_actuate_effect (effect_view->pattern, effect_view->channel, effect_view->row,
GPOINTER_TO_UINT (gtk_clist_get_selection_data (aclist, 0)));
}
-
static void
remove_effect (BstEffectView *effect_view)
{
GtkCList *pclist = GTK_CLIST (effect_view->clist_peffects);
-
if (pclist && pclist->selection && effect_view->pattern)
bse_pattern_note_drop_effect (effect_view->pattern, effect_view->channel, effect_view->row,
GPOINTER_TO_UINT (gtk_clist_get_selection_data (pclist, 0)));
}
-
static void
alist_selection_changed (BstEffectView *effect_view)
{
GtkCList *aclist = GTK_CLIST (effect_view->clist_aeffects);
-
if (effect_view->param_view && effect_view->pattern)
{
gpointer data = gtk_clist_get_selection_data (aclist, 0);
@@ -390,17 +338,14 @@ alist_selection_changed (BstEffectView *effect_view)
effect_view->channel,
effect_view->row,
GPOINTER_TO_UINT (data)) : NULL;
-
gtk_widget_set_sensitive (effect_view->add_button, effect == NULL);
}
gtk_clist_moveto_selection (aclist);
}
-
static void
plist_selection_changed (BstEffectView *effect_view)
{
GtkCList *pclist = GTK_CLIST (effect_view->clist_peffects);
-
if (effect_view->param_view && effect_view->pattern)
{
gpointer data = gtk_clist_get_selection_data (pclist, 0);
@@ -408,7 +353,6 @@ plist_selection_changed (BstEffectView *effect_view)
effect_view->channel,
effect_view->row,
GPOINTER_TO_UINT (data)) : NULL;
-
bst_param_view_set_object (BST_PARAM_VIEW (effect_view->param_view),
effect ? BSE_OBJECT_ID (effect) : 0);
}
diff --git a/beast-gtk/bsteffectview.hh b/beast-gtk/bsteffectview.hh
index e272324..1d945e5 100644
--- a/beast-gtk/bsteffectview.hh
+++ b/beast-gtk/bsteffectview.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_EFFECT_VIEW_H__
#define __BST_EFFECT_VIEW_H__
-
#include "bstitemview.hh"
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_EFFECT_VIEW (bst_effect_view_get_type ())
#define BST_EFFECT_VIEW(object) (GTK_CHECK_CAST ((object), BST_TYPE_EFFECT_VIEW, BstEffectView))
@@ -17,22 +12,18 @@ extern "C" {
#define BST_IS_EFFECT_VIEW(object) (GTK_CHECK_TYPE ((object), BST_TYPE_EFFECT_VIEW))
#define BST_IS_EFFECT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_EFFECT_VIEW))
#define BST_EFFECT_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_EFFECT_VIEW, BstEffectViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstEffectView BstEffectView;
typedef struct _BstEffectViewClass BstEffectViewClass;
struct _BstEffectView
{
GtkAlignment parent_object;
-
GtkWidget *paned;
GtkWidget *clist_aeffects; /* available effects */
GtkWidget *clist_peffects; /* present effects */
GtkWidget *param_view;
GtkWidget *add_button;
GtkWidget *remove_button;
-
BsePattern *pattern;
guint channel;
guint row;
@@ -40,11 +31,8 @@ struct _BstEffectView
struct _BstEffectViewClass
{
GtkAlignmentClass parent_class;
-
guint default_param_view_height;
};
-
-
/* --- prototypes --- */
GtkType bst_effect_view_get_type (void);
GtkWidget* bst_effect_view_new (BseSong *song);
@@ -52,11 +40,7 @@ void bst_effect_view_set_note (BstEffectView *effect_view,
BsePattern *pattern,
guint channel,
guint row);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_EFFECT_VIEW_H__ */
diff --git a/beast-gtk/bsteventroll.cc b/beast-gtk/bsteventroll.cc
index c83ffd8..1fc7d2c 100644
--- a/beast-gtk/bsteventroll.cc
+++ b/beast-gtk/bsteventroll.cc
@@ -3,8 +3,6 @@
#include "bstasciipixbuf.hh"
#include "bstskinconfig.hh"
#include <string.h>
-
-
/* --- defines --- */
/* accessors */
#define STYLE(self) (GTK_WIDGET (self)->style)
@@ -22,30 +20,23 @@
#define COLOR_GC_NEGATIVE(self) (COLOR_GC (self, INDEX_NEGATIVE))
#define CANVAS(self) (GXK_SCROLL_CANVAS (self)->canvas)
#define VPANEL(self) (GXK_SCROLL_CANVAS (self)->left_panel)
-
/* appearance */
#define VPANEL_BG_COLOR(self) (&STYLE (self)->bg[GTK_WIDGET_IS_SENSITIVE (self) ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE])
#define CANVAS_BG_COLOR(self) (&STYLE (self)->base[GTK_WIDGET_STATE (self)])
#define QNOTE_HPIXELS (30) /* guideline */
-
-
/* --- prototypes --- */
static void bst_event_roll_hsetup (BstEventRoll *self,
guint ppqn,
guint qnpt,
guint max_ticks,
gfloat hzoom);
-
/* --- static variables --- */
static guint signal_canvas_drag = 0;
static guint signal_canvas_clicked = 0;
static guint signal_vpanel_drag = 0;
static guint signal_vpanel_clicked = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstEventRoll, bst_event_roll, GXK_TYPE_SCROLL_CANVAS);
-
enum {
INDEX_HBAR,
INDEX_MBAR,
@@ -54,7 +45,6 @@ enum {
INDEX_NEGATIVE,
INDEX_LAST
};
-
static void
event_roll_class_setup_skin (BstEventRollClass *klass)
{
@@ -73,16 +63,13 @@ event_roll_class_setup_skin (BstEventRollClass *klass)
scroll_canvas_class->image_saturation = BST_SKIN_CONFIG (controls_shade) * 0.01;
gxk_scroll_canvas_class_skin_changed (scroll_canvas_class);
}
-
static void
bst_event_roll_init (BstEventRoll *self)
{
GtkWidget *widget = GTK_WIDGET (self);
-
GTK_WIDGET_UNSET_FLAGS (self, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (self, GTK_CAN_FOCUS);
gtk_widget_set_double_buffered (widget, FALSE);
-
self->proxy = 0;
self->control_type = BSE_MIDI_SIGNAL_CONTINUOUS_7; /* valoume */
self->ppqn = 384; /* default Parts (clock ticks) Per Quarter Note */
@@ -94,50 +81,37 @@ bst_event_roll_init (BstEventRoll *self)
self->selection_tick = 0;
self->selection_duration = 0;
bst_event_roll_hsetup (self, 384, 4, 800 * 384, 1);
-
bst_ascii_pixbuf_ref ();
gxk_scroll_canvas_set_canvas_cursor (GXK_SCROLL_CANVAS (self), GDK_LEFT_PTR);
gxk_scroll_canvas_set_left_panel_cursor (GXK_SCROLL_CANVAS (self), GDK_HAND2);
}
-
static void
bst_event_roll_destroy (GtkObject *object)
{
BstEventRoll *self = BST_EVENT_ROLL (object);
-
bst_event_roll_set_proxy (self, 0);
-
GTK_OBJECT_CLASS (bst_event_roll_parent_class)->destroy (object);
}
-
static void
bst_event_roll_dispose (GObject *object)
{
BstEventRoll *self = BST_EVENT_ROLL (object);
-
bst_event_roll_set_proxy (self, 0);
-
G_OBJECT_CLASS (bst_event_roll_parent_class)->dispose (object);
}
-
static void
bst_event_roll_finalize (GObject *object)
{
BstEventRoll *self = BST_EVENT_ROLL (object);
-
bst_event_roll_set_proxy (self, 0);
-
bst_ascii_pixbuf_unref ();
-
G_OBJECT_CLASS (bst_event_roll_parent_class)->finalize (object);
}
-
static void
event_roll_get_layout (GxkScrollCanvas *scc,
GxkScrollCanvasLayout *layout)
{
BstEventRoll *self = BST_EVENT_ROLL (scc);
-
layout->top_panel_height = 0;
if (self->fetch_vpanel_width)
layout->left_panel_width = self->fetch_vpanel_width (self->fetch_vpanel_width_data);
@@ -146,14 +120,12 @@ event_roll_get_layout (GxkScrollCanvas *scc,
layout->canvas_width = 500 + XTHICKNESS (self);
layout->canvas_height = 64 + YTHICKNESS (self);
}
-
static void
event_roll_reallocate_contents (GxkScrollCanvas *scc,
gint xdiff,
gint ydiff)
{
BstEventRoll *self = BST_EVENT_ROLL (scc);
-
if (!xdiff && !ydiff && self->child) /* real size-allocate */
{
GtkAllocation child_allocation;
@@ -168,34 +140,27 @@ event_roll_reallocate_contents (GxkScrollCanvas *scc,
if (bst_segment_initialized (&self->segment))
bst_segment_translate (&self->segment, xdiff, 0);
}
-
static void
bst_event_roll_add (GtkContainer *container,
GtkWidget *child)
{
BstEventRoll *self = BST_EVENT_ROLL (container);
-
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (self->child == NULL);
-
gtk_widget_set_parent_window (child, VPANEL (self));
self->child = child;
gtk_widget_set_parent (child, GTK_WIDGET (self));
}
-
static void
bst_event_roll_remove (GtkContainer *container,
GtkWidget *child)
{
BstEventRoll *self = BST_EVENT_ROLL (container);
-
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (self->child == child);
-
gtk_widget_unparent (child);
self->child = NULL;
}
-
static void
bst_event_roll_forall (GtkContainer *container,
gboolean include_internals,
@@ -203,48 +168,37 @@ bst_event_roll_forall (GtkContainer *container,
gpointer callback_data)
{
BstEventRoll *self = BST_EVENT_ROLL (container);
-
g_return_if_fail (callback != NULL);
-
if (self->child)
callback (self->child, callback_data);
}
-
static void
bst_event_roll_realize (GtkWidget *widget)
{
BstEventRoll *self = BST_EVENT_ROLL (widget);
-
GTK_WIDGET_CLASS (bst_event_roll_parent_class)->realize (widget);
-
if (self->child)
gtk_widget_set_parent_window (self->child, VPANEL (self));
}
-
static gint
ticks_to_pixels (BstEventRoll *self,
gint ticks)
{
gdouble ppqn = self->ppqn;
gdouble tpixels = QNOTE_HPIXELS;
-
/* compute pixel span of a tick range */
-
tpixels *= self->hzoom / ppqn * (gdouble) ticks;
if (ticks)
tpixels = MAX (tpixels, 1);
return MIN (G_MAXINT, tpixels);
}
-
static gint
pixels_to_ticks (BstEventRoll *self,
gint pixels)
{
gdouble ppqn = self->ppqn;
gdouble ticks = 1.0 / (gdouble) QNOTE_HPIXELS;
-
/* compute tick span of a pixel range */
-
ticks = ticks * ppqn / self->hzoom * (gdouble) pixels;
if (pixels > 0)
ticks = MAX (ticks, 1);
@@ -252,33 +206,28 @@ pixels_to_ticks (BstEventRoll *self,
ticks = 0;
return MIN (G_MAXINT, ticks);
}
-
static gint
tick_to_coord (BstEventRoll *self,
gint tick)
{
return ticks_to_pixels (self, tick) - X_OFFSET (self);
}
-
static gint
coord_to_tick (BstEventRoll *self,
gint x,
gboolean right_bound)
{
guint tick;
-
x += X_OFFSET (self);
tick = pixels_to_ticks (self, x);
if (right_bound)
{
guint tick2 = pixels_to_ticks (self, x + 1);
-
if (tick2 > tick)
tick = tick2 - 1;
}
return tick;
}
-
static void
event_roll_draw_vpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -287,7 +236,6 @@ event_roll_draw_vpanel (GxkScrollCanvas *scc,
BstEventRoll *self = BST_EVENT_ROLL (scc);
gint width, height;
gdk_window_get_size (drawable, &width, &height);
-
if (0)
{
/* outer vpanel shadow */
@@ -298,7 +246,6 @@ event_roll_draw_vpanel (GxkScrollCanvas *scc,
width, height + 2 * YTHICKNESS (self));
}
}
-
static gint
event_roll_scale_range (BstEventRoll *self,
gint *rangep)
@@ -312,23 +259,18 @@ event_roll_scale_range (BstEventRoll *self,
*rangep = range;
return mid;
}
-
#define TICK_WIDTH(self) (pixels_to_ticks (self, XTHICKNESS (self) * 2 + 1))
-
static void
bst_event_roll_overlap_grow_canvas_area (BstEventRoll *self,
GdkRectangle *area)
{
gint x = area->x, xbound = x + area->width;
-
/* grow canvas paint area by value bar width, so we don't clear out parts of neighbouring bars */
x -= TICK_WIDTH (self);
xbound += TICK_WIDTH (self);
-
area->x = MAX (x, 0);
area->width = xbound - area->x;
}
-
static void
event_roll_draw_canvas (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -343,11 +285,9 @@ event_roll_draw_canvas (GxkScrollCanvas *scc,
gint x, xbound, width, height;
GXK_SCROLL_CANVAS_CLASS (bst_event_roll_parent_class)->draw_canvas (scc, drawable, area);
gdk_window_get_size (drawable, &width, &height);
-
bst_event_roll_overlap_grow_canvas_area (self, area);
x = area->x;
xbound = x + area->width;
-
/* draw selection */
if (self->selection_duration)
{
@@ -360,7 +300,6 @@ event_roll_draw_canvas (GxkScrollCanvas *scc,
gdk_draw_rectangle (drawable, GTK_WIDGET (self)->style->bg_gc[GTK_STATE_SELECTED], TRUE,
x1, 0, MAX (x2 - x1, 0), height);
}
-
/* draw horizontal grid lines */
draw_gc = COLOR_GC_MBAR (self);
gdk_gc_set_line_attributes (draw_gc, line_width, GDK_LINE_ON_OFF_DASH, GDK_CAP_BUTT, GDK_JOIN_MITER);
@@ -372,7 +311,6 @@ event_roll_draw_canvas (GxkScrollCanvas *scc,
gdk_gc_set_line_attributes (draw_gc, line_width, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
draw_gc = COLOR_GC_HBAR (self);
gdk_draw_line (drawable, draw_gc, x, mid, xbound - 1, mid);
-
/* draw controls */
dark_gc = STYLE (self)->dark_gc[GTK_STATE_NORMAL];
cseq = self->proxy ? bse_part_list_controls (self->proxy,
@@ -386,7 +324,6 @@ event_roll_draw_canvas (GxkScrollCanvas *scc,
GdkGC *xdark_gc, *xlight_gc, *xval_gc;
gint x1, x2, y1, y2;
gboolean selected = pctrl->selected;
-
selected |= (uint (pctrl->tick) >= self->selection_tick &&
uint (pctrl->tick) < self->selection_tick + self->selection_duration);
if (selected)
@@ -424,18 +361,15 @@ event_roll_draw_canvas (GxkScrollCanvas *scc,
y1 = mid - YTHICKNESS (self);
y2 = mid + YTHICKNESS (self);
}
-
gdk_draw_rectangle (drawable, xval_gc, TRUE, x1, y1, MAX (x2 - x1, 1), MAX (y2 - y1, 1));
gdk_draw_line (drawable, xdark_gc, x1, y2, x2, y2);
gdk_draw_line (drawable, xdark_gc, x2, y1, x2, y2);
gdk_draw_line (drawable, xlight_gc, x1, y1, x2, y1);
gdk_draw_line (drawable, xlight_gc, x1, y1, x1, y2);
}
-
if (bst_segment_initialized (&self->segment))
bst_segment_draw (&self->segment, STYLE (self));
}
-
static void
event_roll_update_adjustments (GxkScrollCanvas *scc,
gboolean hadj,
@@ -454,7 +388,6 @@ event_roll_update_adjustments (GxkScrollCanvas *scc,
}
GXK_SCROLL_CANVAS_CLASS (bst_event_roll_parent_class)->update_adjustments (scc, hadj, vadj);
}
-
static void
bst_event_roll_hsetup (BstEventRoll *self,
guint ppqn,
@@ -466,7 +399,6 @@ bst_event_roll_hsetup (BstEventRoll *self,
guint old_qnpt = self->qnpt;
guint old_max_ticks = self->max_ticks;
gfloat old_hzoom = self->hzoom;
-
/* here, we setup all things necessary to determine our
* horizontal layout. we have to avoid resizes at
* least if just max_ticks changes, since the tick range
@@ -476,7 +408,6 @@ bst_event_roll_hsetup (BstEventRoll *self,
self->qnpt = CLAMP (qnpt, 3, 4);
self->max_ticks = MAX (max_ticks, 1);
self->hzoom = CLAMP (hzoom, 0.01, 100);
-
if (old_ppqn != self->ppqn ||
old_qnpt != self->qnpt ||
old_hzoom != self->hzoom)
@@ -493,18 +424,14 @@ bst_event_roll_hsetup (BstEventRoll *self,
gxk_scroll_canvas_update_adjustments (GXK_SCROLL_CANVAS (self), TRUE, FALSE);
}
}
-
gfloat
bst_event_roll_set_hzoom (BstEventRoll *self,
gfloat hzoom)
{
g_return_val_if_fail (BST_IS_EVENT_ROLL (self), 0);
-
bst_event_roll_hsetup (self, self->ppqn, self->qnpt, self->max_ticks, hzoom);
-
return self->hzoom;
}
-
static void
event_roll_handle_drag (GxkScrollCanvas *scc,
GxkScrollCanvasDrag *scc_drag,
@@ -563,7 +490,6 @@ event_roll_handle_drag (GxkScrollCanvas *scc,
g_signal_emit (self, signal_vpanel_clicked, 0, drag->button, drag->start_tick, drag->start_value, event);
}
}
-
static void
event_roll_range_changed (BstEventRoll *self)
{
@@ -571,7 +497,6 @@ event_roll_range_changed (BstEventRoll *self)
bse_proxy_get (self->proxy, "last-tick", &max_ticks, NULL);
bst_event_roll_hsetup (self, self->ppqn, self->qnpt, self->max_ticks, self->hzoom);
}
-
static void
event_roll_update (BstEventRoll *self,
guint tick_start,
@@ -593,13 +518,11 @@ event_roll_update (BstEventRoll *self,
}
gxk_widget_update_actions (self); /* update controllers */
}
-
static void
event_roll_unset_proxy (BstEventRoll *self)
{
bst_event_roll_set_proxy (self, 0);
}
-
void
bst_event_roll_set_proxy (BstEventRoll *self,
SfiProxy proxy)
@@ -610,7 +533,6 @@ bst_event_roll_set_proxy (BstEventRoll *self,
g_return_if_fail (BSE_IS_ITEM (proxy));
g_return_if_fail (bse_item_get_project (proxy) != 0);
}
-
if (self->proxy)
{
bse_proxy_disconnect (self->proxy,
@@ -633,18 +555,15 @@ bst_event_roll_set_proxy (BstEventRoll *self,
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
void
bst_event_roll_set_vpanel_width_hook (BstEventRoll *self,
gint (*fetch_vpanel_width) (gpointer data),
gpointer data)
{
g_return_if_fail (BST_IS_EVENT_ROLL (self));
-
self->fetch_vpanel_width = fetch_vpanel_width;
self->fetch_vpanel_width_data = data;
}
-
static void
event_roll_queue_region (BstEventRoll *self,
guint tick,
@@ -654,20 +573,17 @@ event_roll_queue_region (BstEventRoll *self,
bse_part_queue_controls (self->proxy, tick, duration);
event_roll_update (self, tick, duration);
}
-
void
bst_event_roll_set_view_selection (BstEventRoll *self,
guint tick,
guint duration)
{
g_return_if_fail (BST_IS_EVENT_ROLL (self));
-
if (!duration) /* invalid selection */
{
tick = 0;
duration = 0;
}
-
if (self->selection_duration && duration)
{
/* if at least one corner of the old an the new selection
@@ -704,16 +620,13 @@ bst_event_roll_set_view_selection (BstEventRoll *self,
self->selection_tick = tick;
self->selection_duration = duration;
}
-
void
bst_event_roll_set_control_type (BstEventRoll *self, BseMidiSignalType control_type)
{
g_return_if_fail (BST_IS_EVENT_ROLL (self));
-
self->control_type = control_type;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
void
bst_event_roll_init_segment (BstEventRoll *self,
BstSegmentType type)
@@ -721,7 +634,6 @@ bst_event_roll_init_segment (BstEventRoll *self,
bst_event_roll_clear_segment (self);
bst_segment_init (&self->segment, type, CANVAS (self));
}
-
void
bst_event_roll_segment_start (BstEventRoll *self,
guint tick,
@@ -733,7 +645,6 @@ bst_event_roll_segment_start (BstEventRoll *self,
tick_to_coord (self, tick),
mid - value * range);
}
-
void
bst_event_roll_segment_move_to (BstEventRoll *self,
guint tick,
@@ -745,7 +656,6 @@ bst_event_roll_segment_move_to (BstEventRoll *self,
tick_to_coord (self, tick),
mid - value * range);
}
-
void
bst_event_roll_segment_tick_range (BstEventRoll *self,
guint *tick_p,
@@ -761,7 +671,6 @@ bst_event_roll_segment_tick_range (BstEventRoll *self,
if (duration_p)
*duration_p = coord_to_tick (self, x + w, TRUE) - t;
}
-
gdouble
bst_event_roll_segment_value (BstEventRoll *self,
guint tick)
@@ -775,7 +684,6 @@ bst_event_roll_segment_value (BstEventRoll *self,
v = CLAMP (v, -1, +1);
return v;
}
-
void
bst_event_roll_clear_segment (BstEventRoll *self)
{
@@ -785,7 +693,6 @@ bst_event_roll_clear_segment (BstEventRoll *self)
bst_segment_clear (&self->segment);
}
}
-
static void
bst_event_roll_class_init (BstEventRollClass *klass)
{
@@ -794,18 +701,13 @@ bst_event_roll_class_init (BstEventRollClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GxkScrollCanvasClass *scroll_canvas_class = GXK_SCROLL_CANVAS_CLASS (klass);
-
gobject_class->dispose = bst_event_roll_dispose;
gobject_class->finalize = bst_event_roll_finalize;
-
object_class->destroy = bst_event_roll_destroy;
-
widget_class->realize = bst_event_roll_realize;
-
container_class->add = bst_event_roll_add;
container_class->remove = bst_event_roll_remove;
container_class->forall = bst_event_roll_forall;
-
scroll_canvas_class->hscrollable = TRUE;
scroll_canvas_class->get_layout = event_roll_get_layout;
scroll_canvas_class->update_adjustments = event_roll_update_adjustments;
@@ -813,12 +715,9 @@ bst_event_roll_class_init (BstEventRollClass *klass)
scroll_canvas_class->draw_left_panel = event_roll_draw_vpanel;
scroll_canvas_class->draw_canvas = event_roll_draw_canvas;
scroll_canvas_class->handle_drag = event_roll_handle_drag;
-
bst_skin_config_add_notify ((BstSkinConfigNotify) event_roll_class_setup_skin, klass);
event_roll_class_setup_skin (klass);
-
klass->canvas_clicked = NULL;
-
signal_canvas_drag = g_signal_new ("canvas-drag", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BstEventRollClass, canvas_drag),
NULL, NULL,
diff --git a/beast-gtk/bsteventroll.hh b/beast-gtk/bsteventroll.hh
index 90f7546..c5ced14 100644
--- a/beast-gtk/bsteventroll.hh
+++ b/beast-gtk/bsteventroll.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_EVENT_ROLL_H__
#define __BST_EVENT_ROLL_H__
-
#include "bstsegment.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_EVENT_ROLL (bst_event_roll_get_type ())
#define BST_EVENT_ROLL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_EVENT_ROLL, BstEventRoll))
@@ -13,13 +10,9 @@ G_BEGIN_DECLS
#define BST_IS_EVENT_ROLL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_EVENT_ROLL))
#define BST_IS_EVENT_ROLL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_EVENT_ROLL))
#define BST_EVENT_ROLL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_EVENT_ROLL, BstEventRollClass))
-
-
/* --- typedefs & enums --- */
typedef struct _BstEventRoll BstEventRoll;
typedef struct _BstEventRollClass BstEventRollClass;
-
-
/* --- structures & typedefs --- */
typedef struct {
GXK_SCROLL_CANVAS_DRAG_FIELDS;
@@ -37,11 +30,9 @@ typedef struct {
struct _BstEventRoll
{
GxkScrollCanvas parent_instance;
-
SfiProxy proxy;
BseMidiSignalType control_type;
GtkWidget *child;
-
/* horizontal layout */
guint ppqn; /* parts per quarter note */
guint qnpt; /* quarter notes per tact */
@@ -49,19 +40,15 @@ struct _BstEventRoll
gfloat hzoom;
guint draw_qn_grid : 1;
guint draw_qqn_grid : 1;
-
/* drag data */
guint start_valid : 1;
guint start_tick;
gfloat start_value;
-
/* vpanel width sync */
gint (*fetch_vpanel_width) (gpointer data);
gpointer fetch_vpanel_width_data;
-
/* line drawing */
BstSegment segment;
-
/* selection rectangle */
guint selection_tick;
guint selection_duration;
@@ -71,7 +58,6 @@ struct _BstEventRoll
struct _BstEventRollClass
{
GxkScrollCanvasClass parent_class;
-
void (*canvas_drag) (BstEventRoll *self,
BstEventRollDrag *drag);
void (*canvas_clicked) (BstEventRoll *eroll,
@@ -86,8 +72,6 @@ struct _BstEventRollClass
gfloat value,
GdkEvent *event);
};
-
-
/* --- prototypes --- */
GType bst_event_roll_get_type (void);
void bst_event_roll_set_proxy (BstEventRoll *self,
@@ -115,7 +99,5 @@ void bst_event_roll_segment_tick_range (BstEventRoll *self,
gdouble bst_event_roll_segment_value (BstEventRoll *self,
guint tick);
void bst_event_roll_clear_segment (BstEventRoll *self);
-
G_END_DECLS
-
#endif /* __BST_EVENT_ROLL_H__ */
diff --git a/beast-gtk/bsteventrollctrl.cc b/beast-gtk/bsteventrollctrl.cc
index f4b7cbf..1a45b07 100644
--- a/beast-gtk/bsteventrollctrl.cc
+++ b/beast-gtk/bsteventrollctrl.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsteventrollctrl.hh"
#include "bstpianorollctrl.hh"
-
-
#define CONTROL_TYPE(erctrl) ((erctrl)->eroll->control_type)
#define QUANTIZATION(self) ((self)->quant_rtools->action_id)
#define HAVE_OBJECT (1 << 31)
-
-
/* --- prototypes --- */
static gboolean bst_event_roll_controller_check_action (BstEventRollController *self,
gulong action_id,
@@ -20,11 +16,8 @@ static void controller_vpanel_drag (BstEventRollController *self,
BstEventRollDrag *drag);
static void controller_update_canvas_cursor (BstEventRollController *self,
BstCommonRollTool tool);
-
-
/* --- variables --- */
static BsePartControlSeq *clipboard_cseq = NULL;
-
/* --- actions --- */
enum {
ACTION_NONE = BST_COMMON_ROLL_TOOL_LAST,
@@ -32,7 +25,6 @@ enum {
ACTION_SELECT_NONE,
ACTION_SELECT_INVERT,
};
-
/* --- functions --- */
GxkActionList*
bst_event_roll_controller_select_actions (BstEventRollController *self)
@@ -53,7 +45,6 @@ bst_event_roll_controller_select_actions (BstEventRollController *self)
self);
return alist;
}
-
void
bst_event_roll_controller_set_clipboard (BsePartControlSeq *cseq)
{
@@ -63,33 +54,27 @@ bst_event_roll_controller_set_clipboard (BsePartControlSeq *cseq)
if (clipboard_cseq)
bst_piano_roll_controller_set_clipboard (NULL);
}
-
BsePartControlSeq*
bst_event_roll_controller_get_clipboard (void)
{
return clipboard_cseq;
}
-
static void
controller_reset_canvas_cursor (BstEventRollController *self)
{
controller_update_canvas_cursor (self, BstCommonRollTool (self->canvas_rtools->action_id));
}
-
BstEventRollController*
bst_event_roll_controller_new (BstEventRoll *eroll,
GxkActionGroup *quant_rtools,
GxkActionGroup *canvas_rtools)
{
BstEventRollController *self;
-
g_return_val_if_fail (BST_IS_EVENT_ROLL (eroll), NULL);
g_return_val_if_fail (quant_rtools && canvas_rtools, NULL);
-
self = g_new0 (BstEventRollController, 1);
self->eroll = eroll;
self->ref_count = 1;
-
self->ref_count++;
g_signal_connect_data (eroll, "canvas-drag",
G_CALLBACK (controller_canvas_drag),
@@ -106,27 +91,21 @@ bst_event_roll_controller_new (BstEventRoll *eroll,
"swapped_signal::changed", controller_reset_canvas_cursor, self,
NULL);
controller_reset_canvas_cursor (self);
-
return self;
}
-
BstEventRollController*
bst_event_roll_controller_ref (BstEventRollController *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count >= 1, NULL);
-
self->ref_count++;
-
return self;
}
-
void
bst_event_roll_controller_unref (BstEventRollController *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count >= 1);
-
self->ref_count--;
if (!self->ref_count)
{
@@ -137,7 +116,6 @@ bst_event_roll_controller_unref (BstEventRollController *self)
g_free (self);
}
}
-
static gboolean
bst_event_roll_controller_check_action (BstEventRollController *self,
gulong action_id,
@@ -153,7 +131,6 @@ bst_event_roll_controller_check_action (BstEventRollController *self,
}
return FALSE;
}
-
static void
bst_event_roll_controller_exec_action (BstEventRollController *self,
gulong action_id)
@@ -181,7 +158,6 @@ bst_event_roll_controller_exec_action (BstEventRollController *self,
}
gxk_widget_update_actions_downwards (self->eroll);
}
-
static BstCommonRollTool
event_canvas_button_tool (BstEventRollController *self,
guint button,
@@ -253,16 +229,13 @@ event_canvas_button_tool (BstEventRollController *self,
}
return BST_COMMON_ROLL_TOOL_NONE;
}
-
void
bst_event_roll_controller_clear (BstEventRollController *self)
{
BsePartControlSeq *cseq;
SfiProxy proxy;
guint i;
-
g_return_if_fail (self != NULL);
-
proxy = self->eroll->proxy;
cseq = bse_part_list_selected_controls (proxy, CONTROL_TYPE (self));
bse_item_group_undo (proxy, "Clear Selection");
@@ -273,16 +246,13 @@ bst_event_roll_controller_clear (BstEventRollController *self)
}
bse_item_ungroup_undo (proxy);
}
-
void
bst_event_roll_controller_cut (BstEventRollController *self)
{
BsePartControlSeq *cseq;
SfiProxy proxy;
guint i;
-
g_return_if_fail (self != NULL);
-
proxy = self->eroll->proxy;
cseq = bse_part_list_selected_controls (proxy, CONTROL_TYPE (self));
bse_item_group_undo (proxy, "Cut Selection");
@@ -294,29 +264,23 @@ bst_event_roll_controller_cut (BstEventRollController *self)
bst_event_roll_controller_set_clipboard (cseq);
bse_item_ungroup_undo (proxy);
}
-
gboolean
bst_event_roll_controller_copy (BstEventRollController *self)
{
BsePartControlSeq *cseq;
SfiProxy proxy;
-
g_return_val_if_fail (self != NULL, FALSE);
-
proxy = self->eroll->proxy;
cseq = bse_part_list_selected_controls (proxy, CONTROL_TYPE (self));
bst_event_roll_controller_set_clipboard (cseq);
return cseq && cseq->n_pcontrols;
}
-
void
bst_event_roll_controller_paste (BstEventRollController *self)
{
BsePartControlSeq *cseq;
SfiProxy proxy;
-
g_return_if_fail (self != NULL);
-
proxy = self->eroll->proxy;
cseq = bst_event_roll_controller_get_clipboard ();
if (cseq)
@@ -343,14 +307,12 @@ bst_event_roll_controller_paste (BstEventRollController *self)
bse_item_ungroup_undo (proxy);
}
}
-
gboolean
bst_event_roll_controller_clipboard_full (BstEventRollController *self)
{
BsePartControlSeq *cseq = bst_event_roll_controller_get_clipboard ();
return cseq && cseq->n_pcontrols;
}
-
gboolean
bst_event_roll_controller_has_selection (BstEventRollController *self,
guint64 action_stamp)
@@ -369,13 +331,11 @@ bst_event_roll_controller_has_selection (BstEventRollController *self,
}
return self->cached_n_controls > 0;
}
-
guint
bst_event_roll_controller_quantize (BstEventRollController *self,
guint fine_tick)
{
g_return_val_if_fail (self != NULL, fine_tick);
-
/* quantize tick */
if (QUANTIZATION (self) && self->eroll)
{
@@ -390,7 +350,6 @@ bst_event_roll_controller_quantize (BstEventRollController *self,
}
return fine_tick;
}
-
static void
controller_update_canvas_cursor (BstEventRollController *self,
BstCommonRollTool tool)
@@ -418,7 +377,6 @@ controller_update_canvas_cursor (BstEventRollController *self,
break;
}
}
-
static void
move_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -438,14 +396,12 @@ move_start (BstEventRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
move_group_motion (BstEventRollController *self,
BstEventRollDrag *drag)
{
SfiProxy part = self->eroll->proxy;
gint i, new_tick, delta_tick;
-
new_tick = bst_event_roll_controller_quantize (self, drag->current_tick);
delta_tick = self->obj_tick;
delta_tick -= new_tick;
@@ -466,20 +422,17 @@ move_group_motion (BstEventRollController *self,
}
bse_item_ungroup_undo (part);
}
-
static void
move_motion (BstEventRollController *self,
BstEventRollDrag *drag)
{
SfiProxy part = self->eroll->proxy;
gint new_tick;
-
if (self->sel_cseq)
{
move_group_motion (self, drag);
return;
}
-
new_tick = bst_event_roll_controller_quantize (self, drag->current_tick);
if (new_tick != self->obj_tick)
{
@@ -493,7 +446,6 @@ move_motion (BstEventRollController *self,
}
}
}
-
static void
move_abort (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -505,7 +457,6 @@ move_abort (BstEventRollController *self,
}
gxk_status_set (GXK_STATUS_ERROR, _("Move Control Event"), _("Lost Event"));
}
-
static void
align_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -515,7 +466,6 @@ align_start (BstEventRollController *self,
drag->state = GXK_DRAG_CONTINUE;
gxk_status_set (GXK_STATUS_WAIT, _("Align Control Events"), NULL);
}
-
static void
align_motion (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -526,7 +476,6 @@ align_motion (BstEventRollController *self,
SfiProxy part = self->eroll->proxy;
guint tick, duration, i;
BsePartControlSeq *cseq;
-
bse_item_group_undo (part, "Align Control Events");
bst_event_roll_segment_tick_range (self->eroll, &tick, &duration);
cseq = bse_part_list_controls (part, tick, duration, CONTROL_TYPE (self));
@@ -540,7 +489,6 @@ align_motion (BstEventRollController *self,
bse_item_ungroup_undo (part);
}
}
-
static void
align_abort (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -548,7 +496,6 @@ align_abort (BstEventRollController *self,
bst_event_roll_clear_segment (self->eroll);
gxk_status_set (GXK_STATUS_ERROR, _("Align Control Events"), _("Aborted"));
}
-
static void
insert_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -575,7 +522,6 @@ insert_start (BstEventRollController *self,
bst_status_eprintf (error, _("Insert Control Event"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
resize_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -592,7 +538,6 @@ resize_start (BstEventRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
insert_resize_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -601,13 +546,11 @@ insert_resize_start (BstEventRollController *self,
if (self->obj_id)
resize_start (self, drag);
}
-
static void
resize_motion (BstEventRollController *self,
BstEventRollDrag *drag)
{
SfiProxy part = self->eroll->proxy;
-
/* apply new control event size */
if (drag->current_value != self->obj_value)
{
@@ -619,14 +562,12 @@ resize_motion (BstEventRollController *self,
bse_item_ungroup_undo (part);
}
}
-
static void
resize_abort (BstEventRollController *self,
BstEventRollDrag *drag)
{
gxk_status_set (GXK_STATUS_ERROR, _("Resize Control Event"), _("Lost Event"));
}
-
static void
delete_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -641,7 +582,6 @@ delete_start (BstEventRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Delete Control Event"), _("No target"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
select_start (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -651,7 +591,6 @@ select_start (BstEventRollController *self,
gxk_status_set (GXK_STATUS_WAIT, _("Select Region"), NULL);
drag->state = GXK_DRAG_CONTINUE;
}
-
static void
select_motion (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -659,7 +598,6 @@ select_motion (BstEventRollController *self,
SfiProxy part = self->eroll->proxy;
guint start_tick = MIN (drag->start_tick, drag->current_tick);
guint end_tick = MAX (drag->start_tick, drag->current_tick);
-
bst_event_roll_set_view_selection (drag->eroll, start_tick, end_tick - start_tick);
if (drag->type == GXK_DRAG_DONE)
{
@@ -667,7 +605,6 @@ select_motion (BstEventRollController *self,
bst_event_roll_set_view_selection (drag->eroll, 0, 0);
}
}
-
static void
select_abort (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -675,7 +612,6 @@ select_abort (BstEventRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Select Region"), _("Aborted"));
bst_event_roll_set_view_selection (drag->eroll, 0, 0);
}
-
#if 0
static void
generic_abort (BstEventRollController *self,
@@ -684,10 +620,8 @@ generic_abort (BstEventRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Abortion"), NULL);
}
#endif
-
typedef void (*DragFunc) (BstEventRollController *,
BstEventRollDrag *);
-
void
controller_canvas_drag (BstEventRollController *self,
BstEventRollDrag *drag)
@@ -704,9 +638,7 @@ controller_canvas_drag (BstEventRollController *self,
{ BST_COMMON_ROLL_TOOL_SELECT, select_start, select_motion, select_abort, },
};
guint i;
-
// g_printerr ("canvas drag event, tick=%d (valid=%d) value=%f", drag->current_tick, drag->current_valid, drag->current_value);
-
if (drag->type == GXK_DRAG_START)
{
BstCommonRollTool tool = BST_COMMON_ROLL_TOOL_NONE;
@@ -714,7 +646,6 @@ controller_canvas_drag (BstEventRollController *self,
gint j, i = drag->start_tick;
BsePartControl *nearest = NULL;
gboolean retry_quantized = TRUE;
-
/* setup drag data */
retry_quantized:
j = i;
@@ -753,7 +684,6 @@ controller_canvas_drag (BstEventRollController *self,
if (self->sel_cseq)
g_warning ("leaking old drag selection (%p)", self->sel_cseq);
self->sel_cseq = NULL;
-
/* find drag tool */
tool = event_canvas_button_tool (self, drag->button, self->obj_id > 0);
for (i = 0; i < G_N_ELEMENTS (tool_table); i++)
@@ -785,13 +715,11 @@ controller_canvas_drag (BstEventRollController *self,
drag->type == GXK_DRAG_ABORT)
controller_reset_canvas_cursor (self);
}
-
void
controller_vpanel_drag (BstEventRollController *self,
BstEventRollDrag *drag)
{
// g_printerr ("vpanel drag event, tick=%d (valid=%d) value=%f", drag->current_tick, drag->current_valid, drag->current_value);
-
if (drag->type == GXK_DRAG_START ||
drag->type == GXK_DRAG_MOTION)
drag->state = GXK_DRAG_CONTINUE;
diff --git a/beast-gtk/bsteventrollctrl.hh b/beast-gtk/bsteventrollctrl.hh
index 0a84084..f2c3ba3 100644
--- a/beast-gtk/bsteventrollctrl.hh
+++ b/beast-gtk/bsteventrollctrl.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_EVENT_ROLL_CONTROLLER_H__
#define __BST_EVENT_ROLL_CONTROLLER_H__
-
#include "bsteventroll.hh"
-
G_BEGIN_DECLS
-
typedef struct {
/* misc data */
guint ref_count;
@@ -24,8 +21,6 @@ typedef struct {
guint64 cached_stamp;
guint cached_n_controls;
} BstEventRollController;
-
-
/* --- API --- */
BstEventRollController* bst_event_roll_controller_new (BstEventRoll *eroll,
GxkActionGroup *quant_rtools,
@@ -44,8 +39,5 @@ void bst_event_roll_controller_paste (BstEventRollController *self);
gboolean bst_event_roll_controller_clipboard_full (BstEventRollController *self);
gboolean bst_event_roll_controller_has_selection (BstEventRollController *self,
guint64 action_stamp);
-
-
G_END_DECLS
-
#endif /* __BST_EVENT_ROLL_CONTROLLER_H__ */
diff --git a/beast-gtk/bstfiledialog.cc b/beast-gtk/bstfiledialog.cc
index 7913b3c..cb2b1a4 100644
--- a/beast-gtk/bstfiledialog.cc
+++ b/beast-gtk/bstfiledialog.cc
@@ -6,30 +6,22 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-
-
/* --- prototypes --- */
static void bst_file_dialog_finalize (GObject *object);
static void bst_file_dialog_activate (BstFileDialog *self);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstFileDialog, bst_file_dialog, GXK_TYPE_DIALOG);
-
static void
bst_file_dialog_class_init (BstFileDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_file_dialog_finalize;
}
-
static void
tree_viewable_changed (BstFileDialog *self)
{
gboolean viewable = gxk_widget_viewable (GTK_WIDGET (self->tview));
gboolean tvisible = GTK_WIDGET_VISIBLE (gtk_widget_get_toplevel (GTK_WIDGET (self->tview)));
-
if (viewable && !self->using_file_store)
{
self->using_file_store = TRUE;
@@ -41,7 +33,6 @@ tree_viewable_changed (BstFileDialog *self)
bst_file_store_forget_list (self->file_store);
}
}
-
static void
bst_file_dialog_init (BstFileDialog *self)
{
@@ -49,9 +40,7 @@ bst_file_dialog_init (BstFileDialog *self)
GtkTreeModel *smodel;
GtkWidget *bbox, *vbox;
GtkWidget *main_box = GXK_DIALOG (self)->vbox;
-
self->ignore_activate = TRUE;
-
/* configure self */
g_object_set (self,
"flags", (GXK_DIALOG_HIDE_ON_DELETE |
@@ -65,7 +54,6 @@ bst_file_dialog_init (BstFileDialog *self)
"spacing", 0,
"border_width", 0,
NULL);
-
/* notebook */
self->notebook = (GtkWidget*) g_object_new (GXK_TYPE_NOTEBOOK,
"visible", TRUE,
@@ -79,7 +67,6 @@ bst_file_dialog_init (BstFileDialog *self)
"parent", main_box,
"enable_popup", FALSE,
NULL);
-
/* setup file selection widgets and add to notebook */
self->fs = (GtkFileSelection*) gtk_file_selection_new ("");
self->fpage = gxk_file_selection_split (self->fs, &bbox);
@@ -87,7 +74,6 @@ bst_file_dialog_init (BstFileDialog *self)
gtk_container_remove (GTK_CONTAINER (self->fpage->parent), self->fpage);
gxk_notebook_append (GTK_NOTEBOOK (self->notebook), self->fpage, "File Selection", TRUE);
g_object_unref (self->fpage);
-
/* sample selection tree */
self->spage = (GtkWidget*) g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
@@ -115,7 +101,6 @@ bst_file_dialog_init (BstFileDialog *self)
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_BROWSE);
gxk_tree_selection_force_browse (tsel, smodel);
g_object_connect (self->tview, "swapped_object_signal::row_activated", gtk_button_clicked, self->fs->ok_button, NULL);
-
/* sample selection tree columns */
gxk_tree_view_add_text_column (self->tview, BST_FILE_STORE_COL_WAVE_NAME, "S",
0.0, _("Name"), _("Sample or instrument name"),
@@ -148,7 +133,6 @@ bst_file_dialog_init (BstFileDialog *self)
gxk_tree_view_add_text_column (self->tview, BST_FILE_STORE_COL_FILE, "S",
0.0, _("Filename"), NULL,
NULL, self, G_CONNECT_SWAPPED);
-
/* pack separator and buttons */
gtk_box_pack_end (GTK_BOX (main_box), bbox, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (main_box),
@@ -156,7 +140,6 @@ bst_file_dialog_init (BstFileDialog *self)
"visible", TRUE,
NULL),
FALSE, TRUE, 0);
-
/* setup save options */
self->osave = (GtkWidget*) g_object_new (GTK_TYPE_FRAME,
"label", _("Contents"),
@@ -181,34 +164,27 @@ bst_file_dialog_init (BstFileDialog *self)
"can_focus", FALSE,
NULL);
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (self->radio2)->child), 0, .5);
-
/* setup actions */
g_object_connect (self->fs->ok_button, "swapped_signal::clicked", bst_file_dialog_activate, self, NULL);
g_object_connect (self->fs->cancel_button, "swapped_signal::clicked", gxk_toplevel_delete, self, NULL);
-
/* fixup focus and default widgets */
gxk_dialog_set_default (GXK_DIALOG (self), self->fs->ok_button);
gxk_dialog_set_focus (GXK_DIALOG (self), self->fs->selection_entry);
-
/* setup remaining bits */
bst_file_dialog_set_mode (self, NULL, BstFileDialogMode (0), _("File Selection"), 0);
gtk_window_set_type_hint (GTK_WINDOW (self), GDK_WINDOW_TYPE_HINT_DIALOG);
}
-
static void
bst_file_dialog_finalize (GObject *object)
{
BstFileDialog *self = BST_FILE_DIALOG (object);
-
bst_file_dialog_set_mode (self, NULL, BstFileDialogMode (0), NULL, 0);
g_free (self->search_path);
self->search_filter = NULL;
bst_file_store_destroy (self->file_store);
-
/* chain parent class' handler */
G_OBJECT_CLASS (bst_file_dialog_parent_class)->finalize (object);
}
-
static BstFileDialog*
bst_file_dialog_global_project (void)
{
@@ -217,7 +193,6 @@ bst_file_dialog_global_project (void)
singleton = (BstFileDialog*) g_object_new (BST_TYPE_FILE_DIALOG, NULL);
return singleton;
}
-
static BstFileDialog*
bst_file_dialog_global_wave (void)
{
@@ -226,7 +201,6 @@ bst_file_dialog_global_wave (void)
singleton = (BstFileDialog*) g_object_new (BST_TYPE_FILE_DIALOG, NULL);
return singleton;
}
-
static BstFileDialog*
bst_file_dialog_global_effect (void)
{
@@ -243,7 +217,6 @@ bst_file_dialog_global_effect (void)
}
return singleton;
}
-
static BstFileDialog*
bst_file_dialog_global_instrument (void)
{
@@ -260,7 +233,6 @@ bst_file_dialog_global_instrument (void)
}
return singleton;
}
-
static void
parent_window_destroyed (BstFileDialog *self)
{
@@ -268,7 +240,6 @@ parent_window_destroyed (BstFileDialog *self)
bst_file_dialog_set_mode (self, NULL, BstFileDialogMode (0), NULL, 0);
gxk_toplevel_delete (GTK_WIDGET (self));
}
-
void
bst_file_dialog_set_mode (BstFileDialog *self,
gpointer parent_widget,
@@ -277,29 +248,23 @@ bst_file_dialog_set_mode (BstFileDialog *self,
SfiProxy proxy)
{
GtkWindow *window = GTK_WINDOW (self);
-
g_return_if_fail (BST_IS_FILE_DIALOG (self));
-
gtk_widget_hide (GTK_WIDGET (self));
gtk_widget_hide (self->osave);
self->mode = mode;
g_free (self->selected);
self->selected = NULL;
-
/* reset proxy handling */
bst_window_sync_title_to_proxy (self, proxy, fs_title);
self->proxy = proxy;
self->super = 0;
-
/* cleanup connections to old parent_window */
if (self->parent_window)
g_signal_handlers_disconnect_by_func (self->parent_window, (void*) parent_window_destroyed, self);
if (window->group)
gtk_window_group_remove_window (window->group, window);
gtk_window_set_transient_for (window, NULL);
-
self->parent_window = parent_widget ? (GtkWindow*) gtk_widget_get_ancestor ((GtkWidget*) parent_widget, GTK_TYPE_WINDOW) : NULL;
-
/* setup connections to new parent_window */
if (self->parent_window)
{
@@ -310,10 +275,8 @@ bst_file_dialog_set_mode (BstFileDialog *self,
G_CALLBACK (parent_window_destroyed),
self, G_CONNECT_SWAPPED);
}
-
/* allow activation */
self->ignore_activate = FALSE;
-
/* handle tree visibility */
switch (mode & BST_FILE_DIALOG_MODE_MASK)
{
@@ -363,56 +326,45 @@ bst_file_dialog_set_mode (BstFileDialog *self,
break;
}
}
-
GtkWidget*
bst_file_dialog_popup_open_project (gpointer parent_widget)
{
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_OPEN_PROJECT,
_("Open Project"), 0);
gxk_widget_showraise (widget);
-
return widget;
}
-
GtkWidget*
bst_file_dialog_popup_select_file (gpointer parent_widget)
{
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_SELECT_FILE,
_("Select File"), 0);
gxk_widget_showraise (widget);
-
return widget;
}
-
GtkWidget*
bst_file_dialog_popup_select_dir (gpointer parent_widget)
{
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_SELECT_DIR | BST_FILE_DIALOG_ALLOW_DIRS,
_("Select Directory"), 0);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_open_project (BstFileDialog *self,
const gchar *file_name)
{
SfiProxy project = bse_server_use_new_project (BSE_SERVER, file_name);
BseErrorType error = bst_project_restore_from_file (project, file_name, TRUE, TRUE);
-
if (error)
bst_status_eprintf (error, _("Opening project `%s'"), file_name);
else
@@ -425,54 +377,42 @@ bst_file_dialog_open_project (BstFileDialog *self,
gxk_idle_show_widget (GTK_WIDGET (app));
}
bse_item_unuse (project);
-
return TRUE;
}
-
GtkWidget*
bst_file_dialog_popup_merge_project (gpointer parent_widget,
SfiProxy project)
{
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_MERGE_PROJECT,
_("Merge: %s"), project);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_merge_project (BstFileDialog *self,
const gchar *file_name)
{
SfiProxy project = bse_item_use (self->proxy);
BseErrorType error = bst_project_restore_from_file (project, file_name, FALSE, FALSE);
-
bst_status_eprintf (error, _("Merging project `%s'"), file_name);
-
bse_item_unuse (project);
-
return TRUE;
}
-
GtkWidget*
bst_file_dialog_popup_import_midi (gpointer parent_widget,
SfiProxy project)
{
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_IMPORT_MIDI,
_("Import MIDI: %s"), project);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_import_midi (BstFileDialog *self,
const gchar *file_name)
@@ -481,7 +421,6 @@ bst_file_dialog_import_midi (BstFileDialog *self,
bst_status_eprintf (error, _("Importing MIDI file `%s'"), file_name);
return TRUE;
}
-
static gboolean
store_bse_file (SfiProxy project,
SfiProxy super,
@@ -557,7 +496,6 @@ store_bse_file (SfiProxy project,
g_free (title);
return handled;
}
-
static gboolean
bst_file_dialog_save_project (SfiProxy proxy,
gboolean self_contained,
@@ -578,10 +516,8 @@ bst_file_dialog_save_project (SfiProxy proxy,
if (handled)
bse_project_clean_dirty (project);
bse_item_unuse (project);
-
return handled;
}
-
GtkWidget*
bst_file_dialog_popup_save_project (gpointer parent_widget,
SfiProxy project,
@@ -600,7 +536,6 @@ bst_file_dialog_popup_save_project (gpointer parent_widget,
/* the usual Save As scenario */
BstFileDialog *self = bst_file_dialog_global_project ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_SAVE_PROJECT,
_("Save: %s"), project);
@@ -614,39 +549,30 @@ bst_file_dialog_popup_save_project (gpointer parent_widget,
gtk_widget_show (self->osave);
/* show dialog */
gxk_widget_showraise (widget);
-
return widget;
}
-
GtkWidget*
bst_file_dialog_popup_merge_effect (gpointer parent_widget,
SfiProxy project)
{
BstFileDialog *self = bst_file_dialog_global_effect ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_MERGE_EFFECT,
_("Load Effect"), project);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_merge_effect (BstFileDialog *self,
const gchar *file_name)
{
SfiProxy project = bse_item_use (self->proxy);
BseErrorType error = bst_project_restore_from_file (project, file_name, FALSE, FALSE);
-
bst_status_eprintf (error, _("Merging effect `%s'"), file_name);
-
bse_item_unuse (project);
-
return TRUE;
}
-
GtkWidget*
bst_file_dialog_popup_save_effect (gpointer parent_widget,
SfiProxy project,
@@ -654,17 +580,14 @@ bst_file_dialog_popup_save_effect (gpointer parent_widget,
{
BstFileDialog *self = bst_file_dialog_global_effect ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_SAVE_EFFECT,
_("Save Effect"), project);
self->super = super;
/* show dialog */
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_save_effect (BstFileDialog *self,
const gchar *file_name)
@@ -673,39 +596,30 @@ bst_file_dialog_save_effect (BstFileDialog *self,
gboolean self_contained = TRUE;
gboolean handled = store_bse_file (project, self->super, file_name, _("Saving effect `%s'"), self_contained, FALSE);
bse_item_unuse (project);
-
return handled;
}
-
GtkWidget*
bst_file_dialog_popup_merge_instrument (gpointer parent_widget,
SfiProxy project)
{
BstFileDialog *self = bst_file_dialog_global_instrument ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_MERGE_INSTRUMENT,
_("Load Instrument"), project);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_merge_instrument (BstFileDialog *self,
const gchar *file_name)
{
SfiProxy project = bse_item_use (self->proxy);
BseErrorType error = bst_project_restore_from_file (project, file_name, FALSE, FALSE);
-
bst_status_eprintf (error, _("Merging instrument `%s'"), file_name);
-
bse_item_unuse (project);
-
return TRUE;
}
-
GtkWidget*
bst_file_dialog_popup_save_instrument (gpointer parent_widget,
SfiProxy project,
@@ -713,17 +627,14 @@ bst_file_dialog_popup_save_instrument (gpointer parent_widget,
{
BstFileDialog *self = bst_file_dialog_global_instrument ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
BST_FILE_DIALOG_SAVE_INSTRUMENT,
_("Save Instrument"), project);
self->super = super;
/* show dialog */
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_save_instrument (BstFileDialog *self,
const gchar *file_name)
@@ -732,10 +643,8 @@ bst_file_dialog_save_instrument (BstFileDialog *self,
gboolean self_contained = TRUE;
gboolean handled = store_bse_file (project, self->super, file_name, _("Saving instrument `%s'"), self_contained, FALSE);
bse_item_unuse (project);
-
return handled;
}
-
GtkWidget*
bst_file_dialog_popup_load_wave (gpointer parent_widget,
SfiProxy wave_repo,
@@ -743,30 +652,24 @@ bst_file_dialog_popup_load_wave (gpointer parent_widget,
{
BstFileDialog *self = bst_file_dialog_global_wave ();
GtkWidget *widget = GTK_WIDGET (self);
-
bst_file_dialog_set_mode (self, parent_widget,
show_lib ? BST_FILE_DIALOG_LOAD_WAVE_LIB : BST_FILE_DIALOG_LOAD_WAVE,
_("Load Wave"), wave_repo);
gxk_widget_showraise (widget);
-
return widget;
}
-
static gboolean
bst_file_dialog_load_wave (BstFileDialog *self,
const gchar *file_name)
{
BseErrorType error;
-
gxk_status_printf (0, NULL, _("Loading wave `%s'"), file_name);
error = bse_wave_repo_load_file (self->proxy, file_name);
bst_status_eprintf (error, _("Loading wave `%s'"), file_name);
if (error)
sfi_error (_("Failed to load wave file \"%s\": %s"), file_name, bse_error_blurb (error));
-
return TRUE;
}
-
GtkWidget*
bst_file_dialog_create (void)
{
@@ -776,7 +679,6 @@ bst_file_dialog_create (void)
"File Selector", 0);
return GTK_WIDGET (self);
}
-
void
bst_file_dialog_setup (GtkWidget *widget,
gpointer parent_widget,
@@ -796,13 +698,11 @@ bst_file_dialog_setup (GtkWidget *widget,
g_free (path);
tree_viewable_changed (self);
}
-
typedef struct {
BstFileDialogHandler handler;
gpointer data;
GDestroyNotify destroy;
} BstFileDialogData;
-
static void
bst_file_dialog_handler (BstFileDialog *self,
BstFileDialogData *data)
@@ -814,7 +714,6 @@ bst_file_dialog_handler (BstFileDialog *self,
g_object_disconnect (self, "any_signal", bst_file_dialog_handler, data, NULL);
g_free (data);
}
-
void
bst_file_dialog_set_handler (BstFileDialog *self,
BstFileDialogHandler handler,
@@ -822,25 +721,20 @@ bst_file_dialog_set_handler (BstFileDialog *self,
GDestroyNotify destroy)
{
BstFileDialogData *data = g_new0 (BstFileDialogData, 1);
-
g_return_if_fail (GTK_WIDGET_VISIBLE (self));
-
data->handler = handler;
data->data = handler_data;
data->destroy = destroy;
g_object_connect (self, "signal_after::hide", bst_file_dialog_handler, data, NULL);
}
-
static void
bst_file_dialog_activate (BstFileDialog *self)
{
GtkWindow *swin = self->parent_window;
gboolean popdown = TRUE;
gchar *file_name;
-
if (self->ignore_activate)
return;
-
if (self->tview && gxk_widget_viewable (GTK_WIDGET (self->tview)))
{
GtkTreeIter iter;
@@ -857,7 +751,6 @@ bst_file_dialog_activate (BstFileDialog *self)
}
else
file_name = g_strdup (gtk_file_selection_get_filename (self->fs));
-
if (!(self->mode & BST_FILE_DIALOG_ALLOW_DIRS) &&
g_file_test (file_name, G_FILE_TEST_IS_DIR))
{
@@ -868,7 +761,6 @@ bst_file_dialog_activate (BstFileDialog *self)
g_free (file_name);
return;
}
-
if (swin)
gxk_status_window_push (swin);
switch (self->mode & BST_FILE_DIALOG_MODE_MASK)
diff --git a/beast-gtk/bstfiledialog.hh b/beast-gtk/bstfiledialog.hh
index 4ccf7cd..2cf3394 100644
--- a/beast-gtk/bstfiledialog.hh
+++ b/beast-gtk/bstfiledialog.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_FILE_DIALOG_H__
#define __BST_FILE_DIALOG_H__
-
#include "bstutils.hh"
#include "bstapp.hh"
-
G_BEGIN_DECLS
-
-
/* --- type macros --- */
#define BST_TYPE_FILE_DIALOG (bst_file_dialog_get_type ())
#define BST_FILE_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_FILE_DIALOG, BstFileDialog))
@@ -15,13 +11,9 @@ G_BEGIN_DECLS
#define BST_IS_FILE_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_FILE_DIALOG))
#define BST_IS_FILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_FILE_DIALOG))
#define BST_FILE_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_FILE_DIALOG, BstFileDialogClass))
-
-
/* --- typedefs --- */
typedef struct _BstFileDialog BstFileDialog;
typedef struct _BstFileDialogClass BstFileDialogClass;
-
-
/* --- structures --- */
typedef enum {
BST_FILE_DIALOG_OPEN_PROJECT = 0x0001,
@@ -66,8 +58,6 @@ struct _BstFileDialogClass
{
GxkDialogClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_file_dialog_get_type (void);
GtkWidget* bst_file_dialog_popup_open_project (gpointer parent_widget);
@@ -111,9 +101,7 @@ void bst_file_dialog_set_handler (BstFileDialog *self,
BstFileDialogHandler handler,
gpointer handler_data,
GDestroyNotify destroy);
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline BstFileDialogMode operator& (BstFileDialogMode s1, BstFileDialogMode s2) { return BstFileDialogMode (s1 & (long long unsigned) s2); }
@@ -122,5 +110,4 @@ inline BstFileDialogMode operator| (BstFileDialogMode s1, BstFileDialogMode s
inline BstFileDialogMode& operator|= (BstFileDialogMode &s1, BstFileDialogMode s2) { s1 = s1 | s2; return s1; }
inline BstFileDialogMode operator~ (BstFileDialogMode s1) { return BstFileDialogMode (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __BST_FILE_DIALOG_H__ */
diff --git a/beast-gtk/bstgconfig.cc b/beast-gtk/bstgconfig.cc
index ba189bb..2fc464b 100644
--- a/beast-gtk/bstgconfig.cc
+++ b/beast-gtk/bstgconfig.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstgconfig.hh"
-
#include <string.h>
-
/* --- variables --- */
static BstGConfig *bst_global_config = NULL;
static GParamSpec *pspec_global_config = NULL;
-
-
/* --- functions --- */
void
_bst_gconfig_init (void)
@@ -15,9 +11,7 @@ _bst_gconfig_init (void)
BstGConfig *gconfig;
GValue *value;
SfiRec *rec;
-
g_return_if_fail (bst_global_config == NULL);
-
/* global config record description */
pspec_global_config = sfi_pspec_rec ("beast-preferences-v1", NULL, NULL,
bst_gconfig_fields, SFI_PARAM_STANDARD);
@@ -35,19 +29,16 @@ _bst_gconfig_init (void)
sfi_value_free (value);
sfi_rec_unref (rec);
}
-
GParamSpec*
bst_gconfig_pspec (void)
{
return pspec_global_config;
}
-
BstGConfig*
bst_gconfig_get_global (void)
{
return bst_global_config;
}
-
static BstGConfig*
copy_gconfig (BstGConfig *src_config)
{
@@ -56,7 +47,6 @@ copy_gconfig (BstGConfig *src_config)
sfi_rec_unref (rec);
return gconfig;
}
-
static void
set_gconfig (BstGConfig *gconfig)
{
@@ -64,15 +54,12 @@ set_gconfig (BstGConfig *gconfig)
bst_global_config = gconfig;
bst_gconfig_free (oldconfig);
}
-
void
bst_gconfig_apply (SfiRec *rec)
{
SfiRec *vrec;
BstGConfig *gconfig;
-
g_return_if_fail (rec != NULL);
-
vrec = sfi_rec_copy_deep (rec);
sfi_rec_validate (vrec, sfi_pspec_get_rec_fields (pspec_global_config));
gconfig = bst_gconfig_from_rec (vrec);
@@ -80,34 +67,28 @@ bst_gconfig_apply (SfiRec *rec)
set_gconfig (gconfig);
bst_gconfig_push_updates();
}
-
void
bst_gconfig_set_rc_version (const gchar *rc_version)
{
BstGConfig *gconfig;
-
gconfig = copy_gconfig (bst_global_config);
g_free (gconfig->rc_version);
gconfig->rc_version = g_strdup (rc_version);
set_gconfig (gconfig);
bst_gconfig_push_updates();
}
-
void
bst_gconfig_set_rec_rc_version (SfiRec *rec,
const gchar *rc_version)
{
sfi_rec_set_string (rec, "rc_version", rc_version);
}
-
void
bst_gconfig_push_updates (void)
{
/* update all code portions that cannot poll config options */
gxk_status_enable_error_bell (BST_GUI_ENABLE_ERROR_BELL);
}
-
-
/* --- loading and saving rc file --- */
#include <unistd.h>
#include <fcntl.h>
@@ -124,29 +105,21 @@ accel_map_print (gpointer data,
GString *gstring = g_string_new (changed ? NULL : "; ");
SfiWStore *wstore = (SfiWStore*) data;
gchar *tmp, *name;
-
g_string_append (gstring, "(gtk_accel_path \"");
-
tmp = g_strescape (accel_path, NULL);
g_string_append (gstring, tmp);
g_free (tmp);
-
g_string_append (gstring, "\" \"");
-
name = gtk_accelerator_name (accel_key, GdkModifierType (accel_mods));
tmp = g_strescape (name, NULL);
g_free (name);
g_string_append (gstring, tmp);
g_free (tmp);
-
g_string_append (gstring, "\")");
-
sfi_wstore_break (wstore);
sfi_wstore_puts (wstore, gstring->str);
-
g_string_free (gstring, TRUE);
}
-
BseErrorType
bst_rc_dump (const gchar *file_name)
{
@@ -154,21 +127,15 @@ bst_rc_dump (const gchar *file_name)
GValue *value;
SfiRec *rec;
gint fd;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
sfi_make_dirname_path (file_name);
fd = open (file_name,
O_WRONLY | O_CREAT | O_TRUNC, /* O_EXCL, */
0666);
-
if (fd < 0)
return errno == EEXIST ? BSE_ERROR_FILE_EXISTS : BSE_ERROR_IO;
-
wstore = sfi_wstore_new ();
-
sfi_wstore_printf (wstore, "; rc-file for BEAST v%s\n", BST_VERSION);
-
/* store BstGConfig */
sfi_wstore_puts (wstore, "\n; BstGConfig Dump\n");
rec = bst_gconfig_to_rec (bst_gconfig_get_global ());
@@ -177,7 +144,6 @@ bst_rc_dump (const gchar *file_name)
sfi_value_free (value);
sfi_rec_unref (rec);
sfi_wstore_puts (wstore, "\n");
-
/* store accelerator paths */
sfi_wstore_puts (wstore, "\n; Gtk+ Accel Map Path Dump\n");
sfi_wstore_puts (wstore, "(menu-accelerators ");
@@ -186,14 +152,11 @@ bst_rc_dump (const gchar *file_name)
sfi_wstore_break (wstore); /* make sure this is no comment line */
sfi_wstore_puts (wstore, ")\n");
sfi_wstore_pop_level (wstore);
-
/* flush buffers to file */
sfi_wstore_flush_fd (wstore, fd);
sfi_wstore_destroy (wstore);
-
return close (fd) < 0 ? BSE_ERROR_IO : BSE_ERROR_NONE;
}
-
static GTokenType
rc_file_try_statement (gpointer context_data,
SfiRStore *rstore,
@@ -226,21 +189,17 @@ rc_file_try_statement (gpointer context_data,
else
return SFI_TOKEN_UNMATCHED;
}
-
BseErrorType
bst_rc_parse (const gchar *file_name)
{
SfiRStore *rstore;
BseErrorType error = BSE_ERROR_NONE;
gint fd;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
fd = open (file_name, O_RDONLY, 0);
if (fd < 0)
return (errno == ENOENT || errno == ENOTDIR || errno == ELOOP ?
BSE_ERROR_FILE_NOT_FOUND : BSE_ERROR_IO);
-
rstore = sfi_rstore_new ();
sfi_rstore_input_fd (rstore, fd, file_name);
if (sfi_rstore_parse_all (rstore, NULL, rc_file_try_statement, NULL) > 0)
diff --git a/beast-gtk/bstgconfig.hh b/beast-gtk/bstgconfig.hh
index c20c0a1..ee838fe 100644
--- a/beast-gtk/bstgconfig.hh
+++ b/beast-gtk/bstgconfig.hh
@@ -1,19 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_GCONFIG_H__
#define __BST_GCONFIG_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- BstGConfig - configurable defaults --- */
#define BST_RC_VERSION BST_GCONFIG (rc_version)
#define BST_GUI_ENABLE_ERROR_BELL BST_GCONFIG (gui_enable_error_bell)
#define BST_SNET_ANTI_ALIASED BST_GCONFIG (snet_anti_aliased)
#define BST_SNET_EDIT_FALLBACK BST_GCONFIG (snet_edit_fallback)
#define BST_SNET_SWAP_IO_CHANNELS BST_GCONFIG (snet_swap_io_channels)
-
-
/* --- prototypes --- */
void _bst_gconfig_init (void);
void bst_gconfig_set_rc_version (const gchar *rc_version);
@@ -23,12 +18,8 @@ void bst_gconfig_apply (SfiRec *rec);
GParamSpec* bst_gconfig_pspec (void);
void bst_gconfig_push_updates (void);
/* bstutils.hh: BstGConfig* bst_gconfig_get_global (void); */
-
-
/* --- rc file --- */
BseErrorType bst_rc_dump (const gchar *file_name);
BseErrorType bst_rc_parse (const gchar *file_name);
-
G_END_DECLS
-
#endif /* __BST_GCONFIG_H__ */
diff --git a/beast-gtk/bstgrowbar.cc b/beast-gtk/bstgrowbar.cc
index 4fe3540..341bb8a 100644
--- a/beast-gtk/bstgrowbar.cc
+++ b/beast-gtk/bstgrowbar.cc
@@ -8,17 +8,13 @@
#include <gtk/gtkhscrollbar.h>
#include <gtk/gtkvscrollbar.h>
#include <gxk/gxkutils.hh>
-
-
/* --- prototypes --- */
static gboolean draw_grow_sign (GtkWidget *widget, GdkEventExpose *event, BstGrowBar *self);
static gboolean draw_shrink_sign (GtkWidget *widget, GdkEventExpose *event, BstGrowBar *self);
static void grow_range (GtkWidget *widget, BstGrowBar *self);
static void shrink_range (GtkWidget *widget, BstGrowBar *self);
-
/* --- BstGrowBar --- */
G_DEFINE_DATA_TYPE (BstGrowBar, bst_grow_bar, GTK_TYPE_ALIGNMENT);
-
static void
bst_grow_bar_init (BstGrowBar *self,
BstGrowBarClass *klass)
@@ -77,7 +73,6 @@ bst_grow_bar_init (BstGrowBar *self,
NULL,
_("Grow the scrollable area"));
}
-
static void
bst_grow_bar_finalize (GObject *object)
{
@@ -88,17 +83,14 @@ bst_grow_bar_finalize (GObject *object)
/* chain parent class handler */
G_OBJECT_CLASS (bst_grow_bar_parent_class)->finalize (object);
}
-
static void
bst_grow_bar_class_init (BstGrowBarClass *klass,
gpointer class_data)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
// GtkBarClass *bar_class = GTK_BAR_CLASS (klass);
-
gobject_class->finalize = bst_grow_bar_finalize;
}
-
static gboolean
draw_grow_sign (GtkWidget *widget,
GdkEventExpose *event,
@@ -114,7 +106,6 @@ draw_grow_sign (GtkWidget *widget,
widget->allocation.x, widget->allocation.y + p, widget->allocation.width, l);
return FALSE;
}
-
static gboolean
draw_shrink_sign (GtkWidget *widget,
GdkEventExpose *event,
@@ -126,7 +117,6 @@ draw_shrink_sign (GtkWidget *widget,
widget->allocation.x, widget->allocation.y + p, widget->allocation.width, l);
return FALSE;
}
-
static void
grow_range (GtkWidget *widget,
BstGrowBar *self)
@@ -140,7 +130,6 @@ grow_range (GtkWidget *widget,
gtk_adjustment_changed (adj);
}
}
-
static void
shrink_range (GtkWidget *widget,
BstGrowBar *self)
@@ -159,20 +148,17 @@ shrink_range (GtkWidget *widget,
gtk_adjustment_value_changed (adj);
}
}
-
void
bst_grow_bar_set_adjustment (BstGrowBar *self,
GtkAdjustment *adj)
{
gtk_range_set_adjustment (self->range, adj);
}
-
GtkAdjustment*
bst_grow_bar_get_adjustment (BstGrowBar *self)
{
return gtk_range_get_adjustment (self->range);
}
-
void
bst_grow_bar_set_tooltips (BstGrowBar *self,
const gchar *shrink_tip,
@@ -183,31 +169,24 @@ bst_grow_bar_set_tooltips (BstGrowBar *self,
gxk_widget_set_tooltip (GTK_WIDGET (self->range), scroll_tip);
gxk_widget_set_tooltip (self->growb, grow_tip);
}
-
/* --- BstHGrowBar --- */
G_DEFINE_TYPE (BstHGrowBar, bst_hgrow_bar, BST_TYPE_GROW_BAR);
-
static void
bst_hgrow_bar_init (BstHGrowBar *self)
{
}
-
static void
bst_hgrow_bar_class_init (BstHGrowBarClass *klass)
{
BstGrowBarClass *grow_bar_class = BST_GROW_BAR_CLASS (klass);
grow_bar_class->is_horizontal = TRUE;
}
-
-
/* --- BstVGrowBar --- */
G_DEFINE_TYPE (BstVGrowBar, bst_vgrow_bar, BST_TYPE_GROW_BAR);
-
static void
bst_vgrow_bar_init (BstVGrowBar *self)
{
}
-
static void
bst_vgrow_bar_class_init (BstVGrowBarClass *klass)
{
diff --git a/beast-gtk/bstgrowbar.hh b/beast-gtk/bstgrowbar.hh
index 74b53ae..216a0e8 100644
--- a/beast-gtk/bstgrowbar.hh
+++ b/beast-gtk/bstgrowbar.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_GROW_BAR_H__
#define __BST_GROW_BAR_H__
-
#include <gtk/gtkalignment.h>
#include <gtk/gtkrange.h>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_GROW_BAR (bst_grow_bar_get_type ())
#define BST_GROW_BAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_GROW_BAR, BstGrowBar))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define BST_IS_GROW_BAR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_GROW_BAR))
#define BST_IS_GROW_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_GROW_BAR))
#define BST_GROW_BAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_GROW_BAR, BstGrowBarClass))
-
/* --- type macros --- */
#define BST_TYPE_HGROW_BAR (bst_hgrow_bar_get_type ())
#define BST_HGROW_BAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_HGROW_BAR, BstHGrowBar))
@@ -22,7 +18,6 @@ G_BEGIN_DECLS
#define BST_IS_HGROW_BAR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_HGROW_BAR))
#define BST_IS_HGROW_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_HGROW_BAR))
#define BST_HGROW_BAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_HGROW_BAR, BstHGrowBarClass))
-
/* --- type macros --- */
#define BST_TYPE_VGROW_BAR (bst_vgrow_bar_get_type ())
#define BST_VGROW_BAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_VGROW_BAR, BstVGrowBar))
@@ -30,8 +25,6 @@ G_BEGIN_DECLS
#define BST_IS_VGROW_BAR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_VGROW_BAR))
#define BST_IS_VGROW_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_VGROW_BAR))
#define BST_VGROW_BAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_VGROW_BAR, BstVGrowBarClass))
-
-
/* --- structures & typedefs --- */
typedef struct {
GtkAlignment parent_instance;
@@ -47,8 +40,6 @@ typedef BstGrowBar BstHGrowBar;
typedef BstGrowBar BstVGrowBar;
typedef BstGrowBarClass BstHGrowBarClass;
typedef BstGrowBarClass BstVGrowBarClass;
-
-
/* --- prototypes --- */
GType bst_hgrow_bar_get_type (void);
GType bst_vgrow_bar_get_type (void);
@@ -62,7 +53,5 @@ void bst_grow_bar_set_tooltips (BstGrowBar *self,
const gchar *shrink_tip,
const gchar *scroll_tip,
const gchar *grow_tip);
-
G_END_DECLS
-
#endif /* __BST_GROW_BAR_H__ */
diff --git a/beast-gtk/bstitemseqdialog.cc b/beast-gtk/bstitemseqdialog.cc
index ab90f53..244a2bf 100644
--- a/beast-gtk/bstitemseqdialog.cc
+++ b/beast-gtk/bstitemseqdialog.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstitemseqdialog.hh"
#include "bsttreestores.hh"
-
-
/* --- prototypes --- */
static void bst_item_seq_dialog_activate (BstItemSeqDialog *self);
static gboolean bst_item_seq_dialog_delete_event (GtkWidget *widget,
@@ -11,22 +9,16 @@ static void bst_item_seq_dialog_setup (BstItemSeqDialog *self,
gpointer parent_widget,
const gchar *title,
SfiProxy proxy);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstItemSeqDialog, bst_item_seq_dialog, GXK_TYPE_DIALOG);
-
static void
bst_item_seq_dialog_finalize (GObject *object)
{
BstItemSeqDialog *self = BST_ITEM_SEQ_DIALOG (object);
-
bst_item_seq_dialog_setup (self, NULL, NULL, 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (bst_item_seq_dialog_parent_class)->finalize (object);
}
-
static gboolean
bst_item_seq_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event)
@@ -44,7 +36,6 @@ bst_item_seq_dialog_delete_event (GtkWidget *widget,
/* chain parent class' handler */
return GTK_WIDGET_CLASS (bst_item_seq_dialog_parent_class)->delete_event (widget, event);
}
-
static void
parent_window_destroyed (BstItemSeqDialog *self)
{
@@ -58,7 +49,6 @@ parent_window_destroyed (BstItemSeqDialog *self)
gtk_widget_hide (GTK_WIDGET (self));
bst_item_seq_dialog_setup (self, NULL, NULL, 0);
}
-
static void
bst_item_seq_dialog_setup (BstItemSeqDialog *self,
gpointer parent_widget,
@@ -66,29 +56,22 @@ bst_item_seq_dialog_setup (BstItemSeqDialog *self,
SfiProxy proxy)
{
GtkWindow *window = GTK_WINDOW (self);
-
g_return_if_fail (BST_IS_ITEM_SEQ_DIALOG (self));
-
GxkFreeFunc selected_cleanup = self->selected_cleanup;
self->selected_callback = NULL;
self->selected_cleanup = NULL;
if (selected_cleanup)
selected_cleanup (self->selected_data);
-
gtk_widget_hide (GTK_WIDGET (self));
-
/* reset proxy handling */
bst_window_sync_title_to_proxy (self, proxy, title);
-
/* cleanup connections to old parent_window */
if (self->parent_window)
g_signal_handlers_disconnect_by_func (self->parent_window, (void*) parent_window_destroyed, self);
if (window->group)
gtk_window_group_remove_window (window->group, window);
gtk_window_set_transient_for (window, NULL);
-
self->parent_window = parent_widget ? (GtkWindow*) gtk_widget_get_ancestor ((GtkWidget*) parent_widget, GTK_TYPE_WINDOW) : NULL;
-
/* setup connections to new parent_window */
if (self->parent_window)
{
@@ -99,11 +82,9 @@ bst_item_seq_dialog_setup (BstItemSeqDialog *self,
G_CALLBACK (parent_window_destroyed),
self, G_CONNECT_SWAPPED);
}
-
/* allow activation */
self->ignore_activate = FALSE;
}
-
static BstItemSeqDialog*
bst_item_seq_dialog_singleton (void)
{
@@ -112,7 +93,6 @@ bst_item_seq_dialog_singleton (void)
ts_singleton = (BstItemSeqDialog*) g_object_new (BST_TYPE_ITEM_SEQ_DIALOG, NULL);
return ts_singleton;
}
-
GtkWidget*
bst_item_seq_dialog_popup (gpointer parent_widget,
SfiProxy item,
@@ -130,14 +110,11 @@ bst_item_seq_dialog_popup (gpointer parent_widget,
GtkWidget *widget = GTK_WIDGET (self);
GxkDialog *dialog = GXK_DIALOG (self);
GtkWidget *radget = gxk_dialog_get_child (dialog);
-
bst_item_seq_dialog_setup (self, NULL, NULL, 0);
-
g_object_set (gxk_radget_find (radget, "candidate-label"), "label", candidate_label, NULL);
g_object_set (gxk_radget_find (radget, "item-label"), "label", item_label, NULL);
gxk_widget_set_tooltip (gxk_radget_find (radget, "candidate-view"), candidate_tooltip);
gxk_widget_set_tooltip (gxk_radget_find (radget, "item-view"), item_tooltip);
-
/* construct add/remove button tooltips */
gchar *string;
string = g_strdup_printf (_("Adds the selection from the \"%s\" list to the \"%s\" list"), candidate_label, item_label);
@@ -146,7 +123,6 @@ bst_item_seq_dialog_popup (gpointer parent_widget,
string = g_strdup_printf (_("Removes the selection from the \"%s\" list"), item_label);
gxk_widget_set_tooltip (gxk_radget_find (radget, "button-remove"), string);
g_free (string);
-
bst_item_seq_dialog_set (self, candidates, items);
bst_item_seq_dialog_setup (self, parent_widget,
/* TRANSLATORS: this is a dialog title and %s is replaced by an object name */
@@ -156,21 +132,17 @@ bst_item_seq_dialog_popup (gpointer parent_widget,
self->selected_data = selected_data;
self->selected_cleanup = selected_cleanup;
gxk_widget_showraise (widget);
-
return widget;
}
-
void
bst_item_seq_dialog_set (BstItemSeqDialog *self,
BseItemSeq *candidates,
BseItemSeq *iseq)
{
g_return_if_fail (BST_IS_ITEM_SEQ_DIALOG (self));
-
bst_item_seq_store_set (self->candidate_store, candidates);
bst_item_seq_store_set (self->item_store, iseq);
}
-
static gboolean
bst_item_seq_dialog_sensitize_idle (gpointer data)
{
@@ -205,13 +177,11 @@ bst_item_seq_dialog_sensitize_idle (gpointer data)
GDK_THREADS_LEAVE();
return FALSE;
}
-
static void
bst_item_seq_dialog_queue_sensitize (BstItemSeqDialog *self)
{
g_idle_add (bst_item_seq_dialog_sensitize_idle, g_object_ref (self));
}
-
static void
bst_item_seq_dialog_up (BstItemSeqDialog *self)
{
@@ -226,7 +196,6 @@ bst_item_seq_dialog_up (BstItemSeqDialog *self)
gxk_tree_view_select_index (gtk_tree_selection_get_tree_view (self->item_sel), row);
}
}
-
static void
bst_item_seq_dialog_down (BstItemSeqDialog *self)
{
@@ -241,7 +210,6 @@ bst_item_seq_dialog_down (BstItemSeqDialog *self)
gxk_tree_view_select_index (gtk_tree_selection_get_tree_view (self->item_sel), row);
}
}
-
static void
bst_item_seq_dialog_add (BstItemSeqDialog *self)
{
@@ -257,7 +225,6 @@ bst_item_seq_dialog_add (BstItemSeqDialog *self)
gxk_tree_view_select_index (gtk_tree_selection_get_tree_view (self->item_sel), row);
}
}
-
static void
bst_item_seq_dialog_remove (BstItemSeqDialog *self)
{
@@ -273,13 +240,11 @@ bst_item_seq_dialog_remove (BstItemSeqDialog *self)
gxk_tree_view_select_index (gtk_tree_selection_get_tree_view (self->candidate_sel), row);
}
}
-
static void
bst_item_seq_dialog_activate (BstItemSeqDialog *self)
{
if (self->ignore_activate)
return;
-
/* ignore_activate guards against multiple clicks */
self->ignore_activate = TRUE;
BstItemSeqDialogSelected selected_callback = self->selected_callback;
@@ -295,15 +260,12 @@ bst_item_seq_dialog_activate (BstItemSeqDialog *self)
}
if (selected_cleanup)
selected_cleanup (selected_data);
-
gxk_toplevel_delete (GTK_WIDGET (self));
}
-
static void
bst_item_seq_dialog_init (BstItemSeqDialog *self)
{
GtkTreeView *tview;
-
/* configure self */
g_object_set (self,
"flags", (GXK_DIALOG_HIDE_ON_DELETE |
@@ -312,11 +274,9 @@ bst_item_seq_dialog_init (BstItemSeqDialog *self)
GXK_DIALOG_MODAL),
NULL);
gxk_dialog_set_sizes (GXK_DIALOG (self), 550, 300, 600, 320);
-
/* dialog contents */
GxkRadget *radget = gxk_radget_create ("beast", "item-seq-box", NULL);
gxk_dialog_set_child (GXK_DIALOG (self), (GtkWidget*) radget);
-
/* candidate store and selection setup */
self->candidate_store = bst_item_seq_store_new (TRUE);
tview = (GtkTreeView*) gxk_radget_find (radget, "candidate-view");
@@ -338,7 +298,6 @@ bst_item_seq_dialog_init (BstItemSeqDialog *self)
NULL, NULL, G_CONNECT_SWAPPED);
/* make row connections */
g_signal_connect_object (tview, "row_activated", G_CALLBACK (gtk_button_clicked), gxk_radget_find (radget, "button-add"), G_CONNECT_SWAPPED);
-
/* item store and selection setup */
self->item_store = bst_item_seq_store_new (FALSE);
tview = (GtkTreeView*) gxk_radget_find (radget, "item-view");
@@ -360,11 +319,9 @@ bst_item_seq_dialog_init (BstItemSeqDialog *self)
NULL, NULL, G_CONNECT_SWAPPED);
/* make row connections */
g_signal_connect_object (tview, "row_activated", G_CALLBACK (gtk_button_clicked), gxk_radget_find (radget, "button-remove"), G_CONNECT_SWAPPED);
-
/* provide buttons */
self->ok = gxk_dialog_default_action_swapped (GXK_DIALOG (self), BST_STOCK_OK, (void*) bst_item_seq_dialog_activate, self);
gxk_dialog_action (GXK_DIALOG (self), BST_STOCK_CANCEL, (void*) gxk_toplevel_delete, self);
-
/* connect buttons */
g_signal_connect_object (gxk_radget_find (radget, "button-add"), "clicked", G_CALLBACK (bst_item_seq_dialog_add), self, G_CONNECT_SWAPPED);
g_signal_connect_object (gxk_radget_find (radget, "button-remove"), "clicked", G_CALLBACK (bst_item_seq_dialog_remove), self, G_CONNECT_SWAPPED);
@@ -372,14 +329,11 @@ bst_item_seq_dialog_init (BstItemSeqDialog *self)
g_signal_connect_object (gxk_radget_find (radget, "button-down"), "clicked", G_CALLBACK (bst_item_seq_dialog_down), self, G_CONNECT_SWAPPED);
bst_item_seq_dialog_queue_sensitize (self);
}
-
static void
bst_item_seq_dialog_class_init (BstItemSeqDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->finalize = bst_item_seq_dialog_finalize;
-
widget_class->delete_event = bst_item_seq_dialog_delete_event;
}
diff --git a/beast-gtk/bstitemseqdialog.hh b/beast-gtk/bstitemseqdialog.hh
index abb2706..94c88b8 100644
--- a/beast-gtk/bstitemseqdialog.hh
+++ b/beast-gtk/bstitemseqdialog.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_ITEM_SEQ_DIALOG_H__
#define __BST_ITEM_SEQ_DIALOG_H__
-
#include "bstutils.hh"
#include "bstwaveview.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_ITEM_SEQ_DIALOG (bst_item_seq_dialog_get_type ())
#define BST_ITEM_SEQ_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_ITEM_SEQ_DIALOG, BstItemSeqDialog))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define BST_IS_ITEM_SEQ_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_ITEM_SEQ_DIALOG))
#define BST_IS_ITEM_SEQ_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_ITEM_SEQ_DIALOG))
#define BST_ITEM_SEQ_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_ITEM_SEQ_DIALOG, BstItemSeqDialogClass))
-
/* --- structures & typedefs --- */
typedef struct _BstItemSeqDialog BstItemSeqDialog;
typedef struct _BstItemSeqDialogClass BstItemSeqDialogClass;
@@ -28,7 +24,6 @@ struct _BstItemSeqDialog
GtkTreeSelection *candidate_sel;
GtkTreeModel *item_store; /* proxy store */
GtkTreeSelection *item_sel;
-
GtkWidget *ok; /* ok button */
GtkWindow *parent_window;
guint ignore_activate : 1;
@@ -40,8 +35,6 @@ struct _BstItemSeqDialogClass
{
GxkDialogClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_item_seq_dialog_get_type (void);
GtkWidget* bst_item_seq_dialog_popup (gpointer parent_widget,
@@ -58,9 +51,5 @@ GtkWidget* bst_item_seq_dialog_popup (gpointer parent_widget
void bst_item_seq_dialog_set (BstItemSeqDialog *self,
BseItemSeq *candidates,
BseItemSeq *iseq);
-
-
-
G_END_DECLS
-
#endif /* __BST_ITEM_SEQ_DIALOG_H__ */
diff --git a/beast-gtk/bstitemview.cc b/beast-gtk/bstitemview.cc
index 3263d5a..a530350 100644
--- a/beast-gtk/bstitemview.cc
+++ b/beast-gtk/bstitemview.cc
@@ -2,8 +2,6 @@
#include "bstitemview.hh"
#include "bstparamview.hh"
#include "bsttreestores.hh"
-
-
/* --- prototypes --- */
static void bst_item_view_destroy (GtkObject *object);
static void bst_item_view_finalize (GObject *object);
@@ -13,59 +11,42 @@ static void item_view_unlisten_on (BstItemView *self,
SfiProxy item);
static void item_view_set_container (BstItemView *self,
SfiProxy new_container);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstItemView, bst_item_view, GTK_TYPE_ALIGNMENT);
-
static void
bst_item_view_class_init (BstItemViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_item_view_finalize;
-
object_class->destroy = bst_item_view_destroy;
-
klass->item_type = NULL;
-
klass->listen_on = item_view_listen_on;
klass->unlisten_on = item_view_unlisten_on;
-
klass->set_container = item_view_set_container;
}
-
static void
bst_item_view_init (BstItemView *self)
{
self->container = 0;
}
-
static void
bst_item_view_destroy (GtkObject *object)
{
BstItemView *self = BST_ITEM_VIEW (object);
-
bst_item_view_set_container (self, 0);
-
GTK_OBJECT_CLASS (bst_item_view_parent_class)->destroy (object);
}
-
static void
bst_item_view_finalize (GObject *object)
{
BstItemView *self = BST_ITEM_VIEW (object);
-
bst_item_view_set_container (self, 0);
-
g_free (self->op_widgets);
if (self->wlist)
g_object_unref (self->wlist);
-
G_OBJECT_CLASS (bst_item_view_parent_class)->finalize (object);
}
-
void
bst_item_view_refresh (BstItemView *self,
SfiProxy item)
@@ -73,14 +54,12 @@ bst_item_view_refresh (BstItemView *self,
if (self->wlist)
bst_child_list_wrapper_proxy_changed (self->wlist, item);
}
-
void
bst_item_view_name_edited (BstItemView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_ITEM_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -89,14 +68,12 @@ bst_item_view_name_edited (BstItemView *self,
bse_item_set_name (item, text);
}
}
-
void
bst_item_view_blurb_edited (BstItemView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_ITEM_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -105,7 +82,6 @@ bst_item_view_blurb_edited (BstItemView *self,
bse_proxy_set (item, "blurb", text, NULL);
}
}
-
static void
item_view_listener (GtkTreeModel *model,
SfiProxy item,
@@ -118,7 +94,6 @@ item_view_listener (GtkTreeModel *model,
BST_ITEM_VIEW_GET_CLASS (self)->unlisten_on (self, item);
gxk_widget_update_actions (self);
}
-
GtkTreeModel*
bst_item_view_adapt_list_wrapper (BstItemView *self,
GxkListWrapper *lwrapper)
@@ -126,13 +101,11 @@ bst_item_view_adapt_list_wrapper (BstItemView *self,
g_return_val_if_fail (BST_IS_ITEM_VIEW (self), NULL);
g_return_val_if_fail (GXK_IS_LIST_WRAPPER (lwrapper), NULL);
g_return_val_if_fail (self->wlist == NULL, NULL);
-
g_object_set_data ((GObject*) lwrapper, "item-view", self);
bst_child_list_wrapper_set_listener (lwrapper, item_view_listener);
self->wlist = (GxkListWrapper*) g_object_ref (lwrapper);
return gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (self->wlist));
}
-
static void
pview_selection_changed (BstItemView *self)
{
@@ -141,25 +114,20 @@ pview_selection_changed (BstItemView *self)
bst_item_view_get_current (self));
gxk_widget_update_actions (self);
}
-
void
bst_item_view_set_tree (BstItemView *self,
GtkTreeView *tree)
{
g_return_if_fail (self->tree == NULL);
-
self->tree = tree;
gxk_nullify_in_object (self, &self->tree);
-
/* keep property editor updated */
g_object_connect (gtk_tree_view_get_selection (self->tree),
"swapped_object_signal::changed", pview_selection_changed, self,
NULL);
-
/* adapt param view */
pview_selection_changed (self);
}
-
void
bst_item_view_complete_tree (BstItemView *self,
GtkTreeView *tree)
@@ -167,23 +135,18 @@ bst_item_view_complete_tree (BstItemView *self,
GtkTreeSelection *tsel;
GtkTreeModel *smodel;
GxkListWrapper *lwrapper;
-
g_return_if_fail (self->tree == NULL);
-
/* item list model */
lwrapper = bst_child_list_wrapper_store_new ();
smodel = bst_item_view_adapt_list_wrapper (self, lwrapper);
gtk_tree_view_set_model (tree, smodel);
g_object_unref (lwrapper);
-
bst_item_view_set_tree (self, tree);
-
/* selection setup */
tsel = gtk_tree_view_get_selection (self->tree);
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_BROWSE);
gxk_tree_selection_force_browse (tsel, smodel);
g_object_unref (smodel);
-
/* add list view columns */
gxk_tree_view_add_text_column (self->tree, BST_PROXY_STORE_SEQID, "S",
0.0, _("ID"), NULL,
@@ -201,7 +164,6 @@ bst_item_view_complete_tree (BstItemView *self,
/* sync to selection */
gxk_widget_update_actions (self);
}
-
static void
item_view_listen_on (BstItemView *self,
SfiProxy item)
@@ -211,20 +173,17 @@ item_view_listen_on (BstItemView *self,
bst_item_view_select (self, item);
self->auto_select = 0;
}
-
static void
item_view_unlisten_on (BstItemView *self,
SfiProxy item)
{
bse_proxy_disconnect (item, "any_signal", gxk_widget_update_actions, self, NULL);
}
-
static void
bst_item_view_release_container (BstItemView *item_view)
{
bst_item_view_set_container (item_view, 0);
}
-
static void
item_view_set_container (BstItemView *self,
SfiProxy new_container)
@@ -249,7 +208,6 @@ item_view_set_container (BstItemView *self,
bst_child_list_wrapper_setup (self->wlist, self->container, BST_ITEM_VIEW_GET_CLASS (self)->item_type);
}
}
-
void
bst_item_view_set_container (BstItemView *self,
SfiProxy new_container)
@@ -257,19 +215,15 @@ bst_item_view_set_container (BstItemView *self,
g_return_if_fail (BST_IS_ITEM_VIEW (self));
if (new_container)
g_return_if_fail (BSE_IS_CONTAINER (new_container));
-
BST_ITEM_VIEW_GET_CLASS (self)->set_container (self, new_container);
-
gxk_widget_update_actions (self);
}
-
void
bst_item_view_select (BstItemView *self,
SfiProxy item)
{
g_return_if_fail (BST_IS_ITEM_VIEW (self));
g_return_if_fail (BSE_IS_ITEM (item));
-
if (self->tree && bse_item_get_parent (item) == self->container)
{
GtkTreeIter witer;
@@ -287,14 +241,12 @@ bst_item_view_select (BstItemView *self,
self->auto_select = item;
}
}
-
gint
bst_item_view_get_proxy_row (BstItemView *self,
SfiProxy item)
{
g_return_val_if_fail (BST_IS_ITEM_VIEW (self), -1);
g_return_val_if_fail (BSE_IS_ITEM (item), -1);
-
if (self->tree && bse_item_get_parent (item) == self->container)
{
GtkTreeIter witer;
@@ -317,15 +269,12 @@ bst_item_view_get_proxy_row (BstItemView *self,
}
return -1;
}
-
SfiProxy
bst_item_view_get_proxy (BstItemView *self,
gint row)
{
SfiProxy item = 0;
-
g_return_val_if_fail (BST_IS_ITEM_VIEW (self), 0);
-
if (self->tree && row >= 0)
{
GtkTreeIter siter, witer;
@@ -345,16 +294,13 @@ bst_item_view_get_proxy (BstItemView *self,
g_return_val_if_fail (BSE_IS_ITEM (item), 0);
return item;
}
-
SfiProxy
bst_item_view_get_current (BstItemView *self)
{
SfiProxy item = 0;
GtkTreeIter siter;
GtkTreeModel *smodel;
-
g_return_val_if_fail (BST_IS_ITEM_VIEW (self), 0);
-
if (self->tree &&
gtk_tree_selection_get_selected (gtk_tree_view_get_selection (self->tree), &smodel, &siter))
{
@@ -369,14 +315,12 @@ bst_item_view_get_current (BstItemView *self)
g_return_val_if_fail (BSE_IS_ITEM (item), 0);
return item;
}
-
void
bst_item_view_build_param_view (BstItemView *self,
GtkContainer *container)
{
g_return_if_fail (BST_IS_ITEM_VIEW (self));
g_return_if_fail (self->pview == NULL);
-
/* property view */
self->pview = bst_param_view_new (0);
gxk_nullify_in_object (self, &self->pview);
diff --git a/beast-gtk/bstitemview.hh b/beast-gtk/bstitemview.hh
index 1f956d4..69e7753 100644
--- a/beast-gtk/bstitemview.hh
+++ b/beast-gtk/bstitemview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_ITEM_VIEW_H__
#define __BST_ITEM_VIEW_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_ITEM_VIEW (bst_item_view_get_type ())
#define BST_ITEM_VIEW(object) (GTK_CHECK_CAST ((object), BST_TYPE_ITEM_VIEW, BstItemView))
@@ -13,22 +10,16 @@ G_BEGIN_DECLS
#define BST_IS_ITEM_VIEW(object) (GTK_CHECK_TYPE ((object), BST_TYPE_ITEM_VIEW))
#define BST_IS_ITEM_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_ITEM_VIEW))
#define BST_ITEM_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_ITEM_VIEW, BstItemViewClass))
-
#define BST_ITEM_VIEW_TREE_HEIGHT (120)
-
-
/* --- structures & typedefs --- */
typedef struct _BstItemView BstItemView;
typedef struct _BstItemViewClass BstItemViewClass;
struct _BstItemView
{
GtkAlignment parent_object;
-
GtkTreeView *tree;
GxkListWrapper *wlist;
-
GtkWidget *pview;
-
SfiProxy container;
SfiProxy auto_select;
GtkWidget **op_widgets;
@@ -36,9 +27,7 @@ struct _BstItemView
struct _BstItemViewClass
{
GtkAlignmentClass parent_class;
-
const gchar *item_type;
-
void (*set_container) (BstItemView *self,
SfiProxy new_container);
void (*listen_on) (BstItemView *self,
@@ -46,8 +35,6 @@ struct _BstItemViewClass
void (*unlisten_on) (BstItemView *self,
SfiProxy item);
};
-
-
/* --- prototypes --- */
GType bst_item_view_get_type (void);
void bst_item_view_select (BstItemView *item_view,
@@ -77,8 +64,5 @@ void bst_item_view_enable_param_view (BstItemView *self,
gboolean enabled);
GtkTreeModel* bst_item_view_adapt_list_wrapper (BstItemView *self,
GxkListWrapper *lwrapper);
-
-
G_END_DECLS
-
#endif /* __BST_ITEM_VIEW_H__ */
diff --git a/beast-gtk/bstkeybindings.cc b/beast-gtk/bstkeybindings.cc
index 1f39c8b..a7e9828 100644
--- a/beast-gtk/bstkeybindings.cc
+++ b/beast-gtk/bstkeybindings.cc
@@ -5,7 +5,6 @@
#include "bstpatternctrl.hh"
#include "bstfiledialog.hh"
#include <string.h>
-
enum {
ACTION_ADD,
ACTION_EDIT,
@@ -14,21 +13,17 @@ enum {
ACTION_RAISE,
ACTION_LOAD
};
-
enum {
BCOL_KEY,
BCOL_FUNCTION,
BCOL_PARAM,
N_BCOLS
};
-
enum {
FCOL_NAME,
FCOL_BLURB,
N_FCOLS
};
-
-
/* --- variables --- */
static const GxkStockAction key_bindings_actions[] = {
{ N_("Add..."), "", N_("Bind a new key combination to a program function"),
@@ -44,8 +39,6 @@ static const GxkStockAction key_bindings_actions[] = {
{ N_("Load"), "", N_("Load a key binding set"),
ACTION_LOAD, BST_STOCK_LOAD, },
};
-
-
/* --- functions --- */
static inline guint
key_binding_find_key (BstKeyBinding *kbinding,
@@ -61,7 +54,6 @@ key_binding_find_key (BstKeyBinding *kbinding,
return i;
return G_MAXINT;
}
-
static void
key_bindings_load_file (GtkWidget *dialog,
const gchar *file,
@@ -78,7 +70,6 @@ key_bindings_load_file (GtkWidget *dialog,
if (error)
g_message ("failed to load \"%s\": %s", file, bse_error_blurb (error));
}
-
static void
key_bindings_exec_action (gpointer data,
gulong action)
@@ -229,7 +220,6 @@ key_bindings_exec_action (gpointer data,
gxk_status_window_pop ();
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
key_bindings_check_action (gpointer data,
gulong action,
@@ -260,7 +250,6 @@ key_bindings_check_action (gpointer data,
return FALSE;
}
}
-
static gdouble
key_binding_clamp_param (BstKeyBindingParam ptype,
gdouble param)
@@ -277,7 +266,6 @@ key_binding_clamp_param (BstKeyBindingParam ptype,
default: return 0;
}
}
-
static void
key_binding_binding_param_edited (GtkWidget *self,
const gchar *strpath,
@@ -304,7 +292,6 @@ key_binding_binding_param_edited (GtkWidget *self,
value = g_strtod (text, NULL);
kbinding->keys[nb].param = key_binding_clamp_param (ptype, value);
}
-
static void
key_binding_fill_binding_value (GtkWidget *self,
guint column,
@@ -346,7 +333,6 @@ key_binding_fill_binding_value (GtkWidget *self,
break;
}
}
-
static void
key_binding_fill_function_value (GtkWidget *self,
guint column,
@@ -365,7 +351,6 @@ key_binding_fill_function_value (GtkWidget *self,
break;
}
}
-
static void
key_binding_free (gpointer data)
{
@@ -374,7 +359,6 @@ key_binding_free (gpointer data)
g_free (kbinding->keys);
g_free (kbinding);
}
-
GtkWidget*
bst_key_binding_box (const gchar *binding_name,
guint n_funcs,
@@ -389,12 +373,10 @@ bst_key_binding_box (const gchar *binding_name,
kbinding->binding_name = g_strdup (binding_name);
kbinding->n_funcs = n_funcs;
kbinding->funcs = funcs;
-
g_object_set_data_full ((GObject*) self, "BstKeyBinding", kbinding, key_binding_free);
g_object_set_long (self, "editable", editable != FALSE);
gxk_widget_publish_actions (self, "key-bindings-actions", G_N_ELEMENTS (key_bindings_actions), key_bindings_actions,
NULL, key_bindings_check_action, key_bindings_exec_action);
-
/* binding list */
lwrapper = gxk_list_wrapper_new (N_BCOLS,
G_TYPE_STRING, /* BCOL_KEY */
@@ -405,7 +387,6 @@ bst_key_binding_box (const gchar *binding_name,
G_CALLBACK (key_binding_fill_binding_value),
self, G_CONNECT_SWAPPED);
gxk_list_wrapper_notify_append (lwrapper, kbinding->n_keys);
-
/* binding view setup */
tview = (GtkTreeView*) gxk_radget_find (self, "binding-tree-view");
gtk_tree_view_set_model (tview, GTK_TREE_MODEL (lwrapper));
@@ -422,7 +403,6 @@ bst_key_binding_box (const gchar *binding_name,
gxk_tree_view_add_text_column (tview, BCOL_PARAM, "S", 0.0, _("Parameter"),
_("Parameter to pass to functions upon activation"),
editable ? (void*) key_binding_binding_param_edited : NULL, self, G_CONNECT_SWAPPED);
-
/* function list */
lwrapper = gxk_list_wrapper_new (N_FCOLS,
G_TYPE_STRING, /* FCOL_NAME */
@@ -432,7 +412,6 @@ bst_key_binding_box (const gchar *binding_name,
G_CALLBACK (key_binding_fill_function_value),
self, G_CONNECT_SWAPPED);
gxk_list_wrapper_notify_append (lwrapper, kbinding->n_funcs);
-
/* function view setup */
tview = (GtkTreeView*) gxk_radget_find (self, "function-tree-view");
gtk_tree_view_set_model (tview, GTK_TREE_MODEL (lwrapper));
@@ -444,10 +423,8 @@ bst_key_binding_box (const gchar *binding_name,
_("Function used to create new key bindings"),
NULL, NULL, GConnectFlags (0));
gxk_tree_view_add_text_column (tview, FCOL_BLURB, "S", 0.0, _("Description"), NULL, NULL, NULL, GConnectFlags (0));
-
return (GtkWidget*) self;
}
-
void
bst_key_binding_box_set (GtkWidget *self,
BstKeyBindingItemSeq *kbseq)
@@ -459,14 +436,12 @@ bst_key_binding_box_set (GtkWidget *self,
gxk_list_wrapper_notify_clear (GXK_LIST_WRAPPER (model));
gxk_list_wrapper_notify_append (GXK_LIST_WRAPPER (model), kbinding->n_keys);
}
-
BstKeyBindingItemSeq*
bst_key_binding_box_get (GtkWidget *self)
{
BstKeyBinding *kbinding = (BstKeyBinding*) g_object_get_data ((GObject*) self, "BstKeyBinding");
return bst_key_binding_get_item_seq (kbinding);
}
-
BstKeyBindingKey*
bst_key_binding_lookup_key (BstKeyBinding *kbinding,
guint keyval,
@@ -483,7 +458,6 @@ bst_key_binding_lookup_key (BstKeyBinding *kbinding,
return &kbinding->keys[i];
return NULL;
}
-
const BstKeyBindingFunction*
bst_key_binding_lookup (BstKeyBinding *kbinding,
guint keyval,
@@ -496,7 +470,6 @@ bst_key_binding_lookup (BstKeyBinding *kbinding,
*param = key ? key->param : 0;
return key ? &kbinding->funcs[key->func_index] : NULL;
}
-
guint
bst_key_binding_lookup_id (BstKeyBinding *kbinding,
guint keyval,
@@ -507,7 +480,6 @@ bst_key_binding_lookup_id (BstKeyBinding *kbinding,
const BstKeyBindingFunction *func = bst_key_binding_lookup (kbinding, keyval, modifier, collision_group, param);
return func ? func->id : 0;
}
-
static inline guint
key_binding_find_function (BstKeyBinding *kbinding,
const gchar *func_name)
@@ -518,7 +490,6 @@ key_binding_find_function (BstKeyBinding *kbinding,
return i;
return G_MAXINT;
}
-
void
bst_key_binding_set_item_seq (BstKeyBinding *kbinding,
BstKeyBindingItemSeq *seq)
@@ -548,7 +519,6 @@ bst_key_binding_set_item_seq (BstKeyBinding *kbinding,
/* shrink capacity */
kbinding->keys = (BstKeyBindingKey*) g_realloc (kbinding->keys, sizeof (kbinding->keys[0]) * kbinding->n_keys);
}
-
BstKeyBindingItemSeq*
bst_key_binding_get_item_seq (BstKeyBinding *kbinding)
{
@@ -566,7 +536,6 @@ bst_key_binding_get_item_seq (BstKeyBinding *kbinding)
}
return iseq;
}
-
GParamSpec*
bst_key_binding_item_pspec (void)
{
@@ -579,8 +548,6 @@ bst_key_binding_item_pspec (void)
}
return pspec;
}
-
-
/* --- keyrc file --- */
#include <unistd.h>
#include <fcntl.h>
@@ -595,7 +562,6 @@ bst_key_binding_rcfile (void)
key_binding_rc = sfi_path_get_filename (".beast/keyrc", "~");
return key_binding_rc;
}
-
BseErrorType
bst_key_binding_dump (const gchar *file_name,
GSList *kbindings)
@@ -603,20 +569,15 @@ bst_key_binding_dump (const gchar *file_name,
SfiWStore *wstore;
GSList *slist;
gint fd;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
sfi_make_dirname_path (file_name);
fd = open (file_name,
O_WRONLY | O_CREAT | O_TRUNC, /* O_EXCL, */
0666);
if (fd < 0)
return errno == EEXIST ? BSE_ERROR_FILE_EXISTS : BSE_ERROR_IO;
-
wstore = sfi_wstore_new ();
-
sfi_wstore_printf (wstore, "; key-binding-file for BEAST v%s\n", BST_VERSION);
-
/* store BstSkinConfig */
sfi_wstore_puts (wstore, "\n");
for (slist = kbindings; slist; slist = slist->next)
@@ -633,14 +594,11 @@ bst_key_binding_dump (const gchar *file_name,
sfi_seq_unref (seq);
sfi_wstore_puts (wstore, "\n");
}
-
/* flush buffers to file */
sfi_wstore_flush_fd (wstore, fd);
sfi_wstore_destroy (wstore);
-
return close (fd) < 0 ? BSE_ERROR_IO : BSE_ERROR_NONE;
}
-
static GTokenType
key_binding_try_statement (gpointer context_data,
SfiRStore *rstore,
@@ -674,7 +632,6 @@ key_binding_try_statement (gpointer context_data,
}
return SFI_TOKEN_UNMATCHED;
}
-
BseErrorType
bst_key_binding_parse (const gchar *file_name,
GSList *kbindings)
@@ -684,7 +641,6 @@ bst_key_binding_parse (const gchar *file_name,
gchar *absname;
gint fd;
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
absname = sfi_path_get_filename (file_name, NULL);
fd = open (absname, O_RDONLY, 0);
if (fd < 0)
@@ -693,7 +649,6 @@ bst_key_binding_parse (const gchar *file_name,
return (errno == ENOENT || errno == ENOTDIR || errno == ELOOP ?
BSE_ERROR_FILE_NOT_FOUND : BSE_ERROR_IO);
}
-
rstore = sfi_rstore_new ();
sfi_rstore_input_fd (rstore, fd, absname);
if (sfi_rstore_parse_all (rstore, kbindings, key_binding_try_statement, absname) > 0)
diff --git a/beast-gtk/bstkeybindings.hh b/beast-gtk/bstkeybindings.hh
index a6220f7..a4892c3 100644
--- a/beast-gtk/bstkeybindings.hh
+++ b/beast-gtk/bstkeybindings.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_KEY_BINDINGS_H__
#define __BST_KEY_BINDINGS_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
-
/* --- typedefs & structures --- */
typedef enum /*< skip >*/
{
@@ -40,8 +36,6 @@ struct _BstKeyBinding
guint n_keys;
BstKeyBindingKey *keys;
};
-
-
/* --- prototypes --- */
GtkWidget* bst_key_binding_box (const gchar *binding_name,
guint n_funcs,
@@ -73,7 +67,5 @@ BseErrorType bst_key_binding_dump (const gchar
BseErrorType bst_key_binding_parse (const gchar *file_name,
GSList *kbindings);
GParamSpec* bst_key_binding_item_pspec (void);
-
G_END_DECLS
-
#endif /* __BST_KEY_BINDINGS_H__ */
diff --git a/beast-gtk/bstknob.cc b/beast-gtk/bstknob.cc
index b228671..e76d145 100644
--- a/beast-gtk/bstknob.cc
+++ b/beast-gtk/bstknob.cc
@@ -1,23 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh" /* for the knob pixbuf */
#include "bstknob.hh"
-
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <math.h>
#include <stdio.h>
-
-
#define SCROLL_DELAY_LENGTH 300
#define SQR(x) ((x) * (x))
-
enum {
MOUSE_SETUP,
MOUSE_MOVE,
MOUSE_JUMP
};
-
-
/* --- prototypes --- */
static void bst_knob_paint (BstKnob *knob);
static gboolean bst_knob_timer (gpointer data);
@@ -30,56 +24,45 @@ static void bst_knob_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static void bst_knob_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
-
/* --- functions --- */
G_DEFINE_TYPE (BstKnob, bst_knob, GTK_TYPE_IMAGE);
-
static void
bst_knob_destroy (GtkObject *object)
{
BstKnob *knob = BST_KNOB (object);
-
if (knob->timer)
{
gtk_timeout_remove (knob->timer);
knob->timer = 0;
}
-
if (knob->adjustment)
{
gtk_object_unref (knob->adjustment);
knob->adjustment = NULL;
}
-
if (knob->pixbuf)
{
g_object_unref (knob->pixbuf);
knob->pixbuf = NULL;
}
-
/* chain parent class' handler */
GTK_OBJECT_CLASS (bst_knob_parent_class)->destroy (object);
}
-
static void
bst_knob_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
// BstKnob *knob = BST_KNOB (widget);
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_knob_parent_class)->size_request (widget, requisition);
}
-
static void
bst_knob_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstKnob *knob = BST_KNOB (widget);
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_knob_parent_class)->size_allocate (widget, allocation);
-
/* position widget's window accordingly
*/
if (GTK_WIDGET_REALIZED (widget))
@@ -87,17 +70,14 @@ bst_knob_size_allocate (GtkWidget *widget,
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
}
-
static void
bst_knob_realize (GtkWidget *widget)
{
BstKnob *knob = BST_KNOB (widget);
GdkWindowAttr attributes;
gint attributes_mask;
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_knob_parent_class)->realize (widget);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -110,62 +90,47 @@ bst_knob_realize (GtkWidget *widget)
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
-
knob->iwindow = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (knob->iwindow, knob);
}
-
static void
bst_knob_unrealize (GtkWidget *widget)
{
BstKnob *knob = BST_KNOB (widget);
-
gdk_window_set_user_data (knob->iwindow, NULL);
gdk_window_destroy (knob->iwindow);
knob->iwindow = NULL;
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_knob_parent_class)->unrealize (widget);
}
-
static void
bst_knob_map (GtkWidget *widget)
{
BstKnob *knob = BST_KNOB (widget);
-
GTK_WIDGET_CLASS (bst_knob_parent_class)->map (widget);
-
gdk_window_show (knob->iwindow);
}
-
static void
bst_knob_unmap (GtkWidget *widget)
{
BstKnob *knob = BST_KNOB (widget);
-
gdk_window_hide (knob->iwindow);
-
GTK_WIDGET_CLASS (bst_knob_parent_class)->unmap (widget);
}
-
static gint
bst_knob_expose (GtkWidget *widget,
GdkEventExpose *event)
{
BstKnob *knob = BST_KNOB (widget);
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_knob_parent_class)->expose_event (widget, event);
-
/* we ignore intermediate expose events
*/
if (event->count == 0)
bst_knob_paint (knob);
-
return TRUE;
}
-
static void
bst_knob_paint (BstKnob *knob)
{
@@ -175,16 +140,13 @@ bst_knob_paint (BstKnob *knob)
gint pointer_width = 3;
gint line_width = 1;
GdkPoint points[5];
-
/* compute center */
xc = widget->allocation.width / 2 + widget->allocation.x + knob->xofs;
yc = widget->allocation.height / 2 + widget->allocation.y + knob->yofs;
-
/* compute pointer coords */
angle = knob->arc_start - knob->arc_dist * knob->angle_range;
s = sin (angle);
c = cos (angle);
-
/* draw the pointer */
radius = knob->furrow_radius;
gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
@@ -198,7 +160,6 @@ bst_knob_paint (BstKnob *knob)
xc + c * radius, yc - s * radius,
xc, yc);
gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
-
radius = knob->dot_radius;
dw = (knob->dot_radius - knob->furrow_radius) * 0.75;
gdk_draw_arc (widget->window, gc,
@@ -206,8 +167,6 @@ bst_knob_paint (BstKnob *knob)
xc + c * radius - dw, yc - s * radius - dw,
2 * dw, 2 * dw,
0.0 * 64, 360. * 64);
-
-
if (0)
{
points[0].x = xc + s * pointer_width + 0.5;
@@ -220,19 +179,16 @@ bst_knob_paint (BstKnob *knob)
points[3].y = points[0].y - s * radius + 0.5;
points[4].x = points[0].x;
points[4].y = points[0].y;
-
gdk_gc_set_line_attributes (gc, line_width, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
gdk_draw_polygon (widget->window, gc, TRUE, points, 5);
gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
}
}
-
static gint
bst_knob_button_press (GtkWidget *widget,
GdkEventButton *event)
{
BstKnob *knob = BST_KNOB (widget);
-
if (!knob->button)
{
if (event->button == 1)
@@ -246,63 +202,48 @@ bst_knob_button_press (GtkWidget *widget,
bst_knob_mouse_update (knob, event->x, event->y, MOUSE_JUMP);
}
}
-
return TRUE;
}
-
static gint
bst_knob_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
BstKnob *knob = BST_KNOB (widget);
-
if (knob->button != 0 && event->window == knob->iwindow)
{
if (event->is_hint)
gdk_window_get_pointer (widget->window, NULL, NULL, NULL);
-
bst_knob_mouse_update (knob, event->x, event->y, knob->button == 1 ? MOUSE_MOVE : MOUSE_JUMP);
}
-
return TRUE;
}
-
static gint
bst_knob_button_release (GtkWidget *widget,
GdkEventButton *event)
{
BstKnob *knob = BST_KNOB (widget);
-
if (knob->button == event->button)
{
GtkAdjustment *adjustment = GTK_ADJUSTMENT (knob->adjustment);
-
bst_knob_mouse_update (knob, event->x, event->y, knob->button == 1 ? MOUSE_MOVE : MOUSE_JUMP);
-
knob->button = 0;
-
if (knob->timer)
{
gtk_timeout_remove (knob->timer);
knob->timer = 0;
}
-
if (knob->old_value != adjustment->value)
gtk_adjustment_value_changed (GTK_ADJUSTMENT (knob->adjustment));
}
-
return TRUE;
}
-
static double /* expresses arc2 relative to arc1 */
arc_diff (double arc1,
double arc2)
{
const double _2pi = M_PI * 2.0;
double diff;
-
diff = arc2 - arc1;
-
if (diff > _2pi)
{
double f = floor (diff / _2pi);
@@ -317,10 +258,8 @@ arc_diff (double arc1,
diff -= _2pi;
else if (diff < -M_PI)
diff += _2pi;
-
return diff;
}
-
static void
bst_knob_mouse_update (BstKnob *knob,
gint x,
@@ -331,14 +270,11 @@ bst_knob_mouse_update (BstKnob *knob,
GtkWidget *widget = GTK_WIDGET (knob);
gdouble angle, diff, dist, sensitivity = 0.001;
gint xc, yc;
-
/* figure the arc's center */
xc = widget->allocation.width / 2;
yc = widget->allocation.height / 2;
-
/* calculate the angle of the pointer */
angle = atan2 (yc - y, x - xc);
-
switch (mode)
{
gdouble sdiff, ediff;
@@ -368,13 +304,10 @@ bst_knob_mouse_update (BstKnob *knob,
knob->angle_range = angle / knob->arc_dist;
break;
}
-
/* constrained to the valid area of the arc */
knob->angle_range = CLAMP (knob->angle_range, 0, 1.0);
-
/* compute new adjustment value, translated to its lower...upper range */
adjustment->value = adjustment->lower + knob->angle_range * (adjustment->upper - adjustment->page_size - adjustment->lower);
-
/* if the adjustment value changed:
* - for continuous updates: emit the GtkAdjustment::value_changed signal
* - for delayed updates: install a timer to emit the changed signal, if
@@ -392,12 +325,10 @@ bst_knob_mouse_update (BstKnob *knob,
/* restart timer, so the delay interval starts from scratch */
if (knob->timer)
gtk_timeout_remove (knob->timer);
-
knob->timer = gtk_timeout_add (SCROLL_DELAY_LENGTH,
bst_knob_timer,
knob);
}
-
/* immediately update the widget, so the GUI is responsive and
* not delayed like the ::value_changed signal
*/
@@ -405,66 +336,48 @@ bst_knob_mouse_update (BstKnob *knob,
}
}
}
-
static gboolean
bst_knob_timer (gpointer data)
{
BstKnob *knob;
-
GDK_THREADS_ENTER ();
-
knob = BST_KNOB (data);
-
gtk_adjustment_value_changed (GTK_ADJUSTMENT (knob->adjustment));
-
knob->timer = 0;
-
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
GtkWidget*
bst_knob_new (GtkAdjustment *adjustment)
{
GtkWidget *knob;
-
if (adjustment)
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
else
adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 250.0, 0.0, 0.0, 0.0);
-
knob = gtk_widget_new (BST_TYPE_KNOB, NULL);
-
bst_knob_set_adjustment (BST_KNOB (knob), adjustment);
-
return knob;
}
-
GtkAdjustment*
bst_knob_get_adjustment (BstKnob *knob)
{
g_return_val_if_fail (BST_IS_KNOB (knob), NULL);
-
return GTK_ADJUSTMENT (knob->adjustment);
}
-
void
bst_knob_set_update_policy (BstKnob *knob,
GtkUpdateType policy)
{
g_return_if_fail (BST_IS_KNOB (knob));
-
if (knob->update_policy != policy)
{
knob->update_policy = policy;
-
/* remove a pending timer if necessary */
if (knob->timer)
{
gtk_timeout_remove (knob->timer);
knob->timer = 0;
-
/* perform pending notification */
if (policy == GTK_UPDATE_CONTINUOUS &&
knob->old_value != GTK_ADJUSTMENT (knob->adjustment)->value)
@@ -472,25 +385,20 @@ bst_knob_set_update_policy (BstKnob *knob,
}
}
}
-
void
bst_knob_set_adjustment (BstKnob *knob,
GtkAdjustment *adjustment)
{
g_return_if_fail (BST_IS_KNOB (knob));
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
if (knob->adjustment)
{
gtk_signal_disconnect_by_data (knob->adjustment, knob);
gtk_object_unref (knob->adjustment);
}
-
knob->adjustment = GTK_OBJECT (adjustment);
-
gtk_object_ref (knob->adjustment);
gtk_object_sink (knob->adjustment);
-
gtk_signal_connect (knob->adjustment,
"changed",
GTK_SIGNAL_FUNC (bst_knob_adjustment_changed),
@@ -499,26 +407,20 @@ bst_knob_set_adjustment (BstKnob *knob,
"value_changed",
GTK_SIGNAL_FUNC (bst_knob_adjustment_value_changed),
knob);
-
knob->old_value = adjustment->value;
knob->old_lower = adjustment->lower;
knob->old_upper = adjustment->upper;
knob->old_page_size = adjustment->page_size;
-
bst_knob_update (knob);
}
-
static void
bst_knob_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
BstKnob *knob;
-
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
g_return_if_fail (data != NULL);
-
knob = BST_KNOB (data);
-
if (knob->old_value != adjustment->value ||
knob->old_lower != adjustment->lower ||
knob->old_upper != adjustment->upper ||
@@ -528,44 +430,33 @@ bst_knob_adjustment_changed (GtkAdjustment *adjustment,
knob->old_lower = adjustment->lower;
knob->old_upper = adjustment->upper;
knob->old_page_size = adjustment->page_size;
-
bst_knob_update (knob);
}
}
-
static void
bst_knob_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
BstKnob *knob;
-
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
g_return_if_fail (data != NULL);
-
knob = BST_KNOB (data);
-
if (knob->old_value != adjustment->value)
{
knob->old_value = adjustment->value;
-
bst_knob_update (knob);
}
}
-
static void
bst_knob_update (BstKnob *knob)
{
GtkAdjustment *adjustment;
GtkWidget *widget;
gdouble new_value;
-
g_return_if_fail (BST_IS_KNOB (knob));
-
widget = GTK_WIDGET (knob);
adjustment = GTK_ADJUSTMENT (knob->adjustment);
-
new_value = CLAMP (adjustment->value, adjustment->lower, adjustment->upper - adjustment->page_size);
-
if (new_value != adjustment->value)
{
if (0)
@@ -574,18 +465,14 @@ bst_knob_update (BstKnob *knob)
adjustment->value = new_value;
gtk_adjustment_value_changed (GTK_ADJUSTMENT (knob->adjustment));
}
-
knob->angle_range = ((adjustment->value - adjustment->lower) /
(adjustment->upper - adjustment->page_size - adjustment->lower));
-
gtk_widget_queue_draw (widget);
}
-
static void
bst_knob_init (BstKnob *knob)
{
gfloat w, h, radius;
-
knob->update_policy = GTK_UPDATE_CONTINUOUS;
knob->button = 0;
knob->arc_start = 1.25 * M_PI; /* 0 .. 2*M_PI */
@@ -599,7 +486,6 @@ bst_knob_init (BstKnob *knob)
knob->adjustment = NULL;
knob->pixbuf = (GdkPixbuf*) g_object_ref (bst_pixbuf_knob ());
g_assert (knob->pixbuf);
-
gtk_image_set_from_pixbuf (GTK_IMAGE (knob), knob->pixbuf);
w = gdk_pixbuf_get_width (knob->pixbuf);
h = gdk_pixbuf_get_height (knob->pixbuf);
@@ -609,15 +495,12 @@ bst_knob_init (BstKnob *knob)
knob->xofs = 1;
knob->yofs = 0;
}
-
static void
bst_knob_class_init (BstKnobClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
object_class->destroy = bst_knob_destroy;
-
widget_class->size_request = bst_knob_size_request;
widget_class->size_allocate = bst_knob_size_allocate;
widget_class->realize = bst_knob_realize;
@@ -628,7 +511,6 @@ bst_knob_class_init (BstKnobClass *klass)
widget_class->button_press_event = bst_knob_button_press;
widget_class->button_release_event = bst_knob_button_release;
widget_class->motion_notify_event = bst_knob_motion_notify;
-
/* sets text[PRELIGHT] to red */
gtk_rc_parse_string ("style'BstKnobClass-style'{text[PRELIGHT]={1.,0.,0.}}"
"widget_class'*BstKnob'style'BstKnobClass-style'");
diff --git a/beast-gtk/bstknob.hh b/beast-gtk/bstknob.hh
index 966ccae..99db1b2 100644
--- a/beast-gtk/bstknob.hh
+++ b/beast-gtk/bstknob.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_KNOB_H__
#define __BST_KNOB_H__
-
#include <gtk/gtkadjustment.h>
#include <gtk/gtkimage.h>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_KNOB (bst_knob_get_type ())
#define BST_KNOB(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_KNOB, BstKnob))
@@ -14,42 +11,33 @@ G_BEGIN_DECLS
#define BST_IS_KNOB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_KNOB))
#define BST_IS_KNOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_KNOB))
#define BST_KNOB_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_KNOB, BstKnobClass))
-
/* --- structures & typedefs --- */
typedef struct _BstKnob BstKnob;
typedef struct _BstKnobClass BstKnobClass;
struct _BstKnob
{
GtkImage parent_object;
-
/* The update policy: GTK_UPDATE_CONTINUOUS,
* GTK_UPDATE_DISCONTINUOUS or GTK_UPDATE_DELAYED
*/
GtkUpdateType update_policy;
-
/* The button currently pressed or 0 if none */
guint8 button;
-
/* Dimensions of knob components */
gfloat furrow_radius, dot_radius, xofs, yofs;
gfloat arc_start, arc_dist;
-
/* ID of update timer for delayed updates, or 0 if none */
guint timer;
-
/* Current angle of the pointer */
gdouble angle_range;
-
/* user input */
gfloat pangle;
gfloat px, py;
-
/* Old values from GtkAdjustment, stored so we know when something changed */
gdouble old_value;
gdouble old_lower;
gdouble old_upper;
gdouble old_page_size;
-
/* The adjustment object that stores the data for this knob */
GtkObject *adjustment;
GdkWindow *iwindow;
@@ -59,7 +47,6 @@ struct _BstKnobClass
{
GtkImageClass parent_class;
};
-
/* --- public methods --- */
GType bst_knob_get_type (void);
GtkWidget* bst_knob_new (GtkAdjustment *adjustment);
@@ -69,5 +56,4 @@ GtkAdjustment* bst_knob_get_adjustment (BstKnob *knob);
void bst_knob_set_update_policy (BstKnob *knob,
GtkUpdateType policy);
G_END_DECLS
-
#endif /* __BST_KNOB_H__ */
diff --git a/beast-gtk/bstlogadjustment.cc b/beast-gtk/bstlogadjustment.cc
index 719a84b..16671af 100644
--- a/beast-gtk/bstlogadjustment.cc
+++ b/beast-gtk/bstlogadjustment.cc
@@ -1,47 +1,36 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <sfi/glib-extra.hh>
#include "bstlogadjustment.hh"
-
#include <math.h>
-
-
/* --- prototypes --- */
static void bst_log_adjustment_destroy (GtkObject *object);
static void bst_log_adjustment_changed (GtkAdjustment *adj);
static void bst_log_adjustment_value_changed (GtkAdjustment *adj);
static void ladj_adjust_ranges (BstLogAdjustment *ladj);
static void ladj_client_value_changed (BstLogAdjustment *ladj);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstLogAdjustment, bst_log_adjustment, GTK_TYPE_ADJUSTMENT);
-
static void
bst_log_adjustment_class_init (BstLogAdjustmentClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkAdjustmentClass *adjustment_class = GTK_ADJUSTMENT_CLASS (klass);
-
object_class->destroy = bst_log_adjustment_destroy;
-
adjustment_class->changed = bst_log_adjustment_changed;
adjustment_class->value_changed = bst_log_adjustment_value_changed;
}
-
static gdouble
call_exp (BstLogAdjustment *ladj,
gdouble x)
{
return pow (ladj->base, x);
}
-
static gdouble
call_log (BstLogAdjustment *ladj,
gdouble x)
{
return log (CLAMP (x, ladj->llimit, ladj->ulimit)) / ladj->base_ln;
}
-
static void
bst_log_adjustment_init (BstLogAdjustment *ladj)
{
@@ -49,31 +38,23 @@ bst_log_adjustment_init (BstLogAdjustment *ladj)
ladj->client = NULL;
bst_log_adjustment_setup (ladj, 10000, 10, 4);
}
-
static void
bst_log_adjustment_destroy (GtkObject *object)
{
BstLogAdjustment *ladj = BST_LOG_ADJUSTMENT (object);
-
bst_log_adjustment_set_client (ladj, NULL);
-
/* chain parent class handler */
GTK_OBJECT_CLASS (bst_log_adjustment_parent_class)->destroy (object);
}
-
GtkAdjustment*
bst_log_adjustment_from_adj (GtkAdjustment *client)
{
BstLogAdjustment *ladj;
-
g_return_val_if_fail (GTK_IS_ADJUSTMENT (client), NULL);
-
ladj = (BstLogAdjustment*) g_object_new (BST_TYPE_LOG_ADJUSTMENT, NULL);
bst_log_adjustment_set_client (ladj, client);
-
return GTK_ADJUSTMENT (ladj);
}
-
void
bst_log_adjustment_set_client (BstLogAdjustment *ladj,
GtkAdjustment *client)
@@ -81,7 +62,6 @@ bst_log_adjustment_set_client (BstLogAdjustment *ladj,
g_return_if_fail (BST_IS_LOG_ADJUSTMENT (ladj));
if (client)
g_return_if_fail (GTK_IS_ADJUSTMENT (client));
-
g_object_ref (ladj);
if (ladj->client)
{
@@ -101,7 +81,6 @@ bst_log_adjustment_set_client (BstLogAdjustment *ladj,
}
g_object_unref (ladj);
}
-
void
bst_log_adjustment_setup (BstLogAdjustment *ladj,
gdouble center,
@@ -109,11 +88,9 @@ bst_log_adjustment_setup (BstLogAdjustment *ladj,
gdouble n_steps)
{
GtkAdjustment *adj;
-
g_return_if_fail (BST_IS_LOG_ADJUSTMENT (ladj));
g_return_if_fail (n_steps > 0);
g_return_if_fail (base > 0);
-
adj = GTK_ADJUSTMENT (ladj);
ladj->center = center;
ladj->n_steps = n_steps;
@@ -121,18 +98,15 @@ bst_log_adjustment_setup (BstLogAdjustment *ladj,
ladj->base_ln = log (ladj->base);
ladj->ulimit = pow (ladj->base, ladj->n_steps);
ladj->llimit = 1.0 / ladj->ulimit;
-
adj->value = ladj->center;
ladj_adjust_ranges (ladj);
gtk_adjustment_value_changed (adj);
}
-
static void
bst_log_adjustment_changed (GtkAdjustment *adj)
{
BstLogAdjustment *ladj = BST_LOG_ADJUSTMENT (adj);
GtkAdjustment *client = ladj->client;
-
if (client && !ladj->block_client)
{
ladj->block_client++;
@@ -140,13 +114,11 @@ bst_log_adjustment_changed (GtkAdjustment *adj)
ladj->block_client--;
}
}
-
static void
bst_log_adjustment_value_changed (GtkAdjustment *adj)
{
BstLogAdjustment *ladj = BST_LOG_ADJUSTMENT (adj);
GtkAdjustment *client = ladj->client;
-
adj->value = CLAMP (adj->value, adj->lower, adj->upper);
if (client && !ladj->block_client)
{
@@ -156,18 +128,15 @@ bst_log_adjustment_value_changed (GtkAdjustment *adj)
ladj->block_client--;
}
}
-
static void
ladj_adjust_ranges (BstLogAdjustment *ladj)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (ladj);
-
adj->upper = ladj->n_steps;
adj->lower = -ladj->n_steps;
adj->page_increment = (adj->upper - adj->lower) / (2.0 * ladj->n_steps);
adj->step_increment = adj->page_increment / 100.0;
adj->page_size = 0;
-
if (0)
{
GtkAdjustment *client = ladj->client;
@@ -177,7 +146,6 @@ ladj_adjust_ranges (BstLogAdjustment *ladj)
ladj->center,
client ? client->lower : -99.777, client ? client->upper : -99.777);
}
-
if (!ladj->block_client)
{
ladj->block_client++;
@@ -185,22 +153,18 @@ ladj_adjust_ranges (BstLogAdjustment *ladj)
ladj->block_client--;
}
}
-
static void
ladj_client_value_changed (BstLogAdjustment *ladj)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (ladj);
GtkAdjustment *client = ladj->client;
-
if (client)
adj->value = call_log (ladj, client->value / ladj->center);
adj->value = CLAMP (adj->value, adj->lower, adj->upper);
-
if (0)
g_printerr ("ladj: client-value-changed: [%f %f] %g CLIENT: [%f %f] %g\n",
adj->lower, adj->upper, adj->value,
client->lower, client->upper, client->value);
-
if (!ladj->block_client)
{
ladj->block_client++;
diff --git a/beast-gtk/bstlogadjustment.hh b/beast-gtk/bstlogadjustment.hh
index e4f99fe..f8ef331 100644
--- a/beast-gtk/bstlogadjustment.hh
+++ b/beast-gtk/bstlogadjustment.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_LOG_ADJUSTMENT_H__
#define __BST_LOG_ADJUSTMENT_H__
-
#include <gtk/gtkadjustment.h>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_LOG_ADJUSTMENT (bst_log_adjustment_get_type ())
#define BST_LOG_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_LOG_ADJUSTMENT, BstLogAdjustment))
@@ -13,21 +10,17 @@ G_BEGIN_DECLS
#define BST_IS_LOG_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_LOG_ADJUSTMENT))
#define BST_IS_LOG_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_LOG_ADJUSTMENT))
#define BST_LOG_ADJUSTMENT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_LOG_ADJUSTMENT, BstLogAdjustmentClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstLogAdjustment BstLogAdjustment;
typedef struct _BstLogAdjustmentClass BstLogAdjustmentClass;
struct _BstLogAdjustment
{
GtkAdjustment parent_instance;
-
/* settings */
gdouble center;
gdouble n_steps;
gdouble base;
GtkAdjustment *client;
-
guint block_client;
gdouble base_ln;
gdouble llimit;
@@ -37,8 +30,6 @@ struct _BstLogAdjustmentClass
{
GtkAdjustmentClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_log_adjustment_get_type (void);
void bst_log_adjustment_set_client (BstLogAdjustment *ladj,
@@ -48,7 +39,5 @@ void bst_log_adjustment_setup (BstLogAdjustment *ladj,
gdouble center,
gdouble base,
gdouble n_steps);
-
G_END_DECLS
-
#endif /* __BST_LOG_ADJUSTMENT_H__ */
diff --git a/beast-gtk/bstmain.cc b/beast-gtk/bstmain.cc
index e9f82b4..3a143ea 100644
--- a/beast-gtk/bstmain.cc
+++ b/beast-gtk/bstmain.cc
@@ -19,17 +19,12 @@
#include <sys/time.h>
#include <sys/resource.h>
// #include "sfi/toyprof-mem.h"
-
extern "C" void bse_object_debug_leaks (void); // FIXME
-
-
/* --- prototypes --- */
static void bst_early_parse_args (gint *argc_p,
gchar ***argv_p);
static void bst_print_blurb (void);
static void bst_exit_print_version (void);
-
-
/* --- variables --- */
gboolean bst_developer_hints = FALSE;
gboolean bst_debug_extensions = FALSE;
@@ -41,8 +36,6 @@ static gboolean register_core_plugins = TRUE;
static gboolean register_ladspa_plugins = TRUE;
static gboolean register_scripts = TRUE;
static gboolean may_auto_update_bse_rc_file = TRUE;
-
-
/* --- functions --- */
static void
server_registration (SfiProxy server,
@@ -52,7 +45,6 @@ server_registration (SfiProxy server,
gpointer data)
{
BseRegistrationType rtype = bse_registration_type_from_choice (rchoice);
-
if (rtype == BSE_REGISTER_DONE)
registration_done = TRUE;
else
@@ -63,7 +55,6 @@ server_registration (SfiProxy server,
g_message ("failed to register \"%s\": %s", what, error);
}
}
-
int
main (int argc,
char *argv[])
@@ -77,24 +68,20 @@ main (int argc,
{ NULL },
};
guint i;
-
/* initialize i18n */
bindtextdomain (BST_GETTEXT_DOMAIN, BST_PATH_LOCALE);
bind_textdomain_codeset (BST_GETTEXT_DOMAIN, "UTF-8");
textdomain (BST_GETTEXT_DOMAIN);
setlocale (LC_ALL, "");
-
/* initialize random numbers */
struct timeval tv;
gettimeofday (&tv, NULL);
srand48 (tv.tv_usec + (tv.tv_sec << 16));
srand (tv.tv_usec + (tv.tv_sec << 16));
-
/* initialize GLib guts */
// toyprof_init_glib_memtable ("/tmp/beast-leak.debug", 10 /* SIGUSR1 */);
g_thread_init (NULL);
g_type_init ();
-
/* initialize Birnet/Sfi */
sfi_init (&argc, &argv, _("BEAST"), NULL); /* application name is user visible */
sfi_msg_allow ("misc");
@@ -102,21 +89,18 @@ main (int argc,
sfi_thread_set_name ("Beast GUI");
sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup,
g_main_context_default (), NULL);
-
/* initialize Gtk+ and go into threading mode */
bst_early_parse_args (&argc, &argv);
if (bst_debug_extensions)
debugbool[0] = '1';
gtk_init (&argc, &argv);
GDK_THREADS_ENTER ();
-
/* initialize Gtk+ Extension Kit */
gxk_init ();
/* documentation search paths */
gxk_text_add_tsm_path (BST_PATH_DOCS);
gxk_text_add_tsm_path (BST_PATH_IMAGES);
gxk_text_add_tsm_path (".");
-
/* now, we can popup the splash screen */
beast_splash = bst_splash_new ("BEAST-Splash", BST_SPLASH_WIDTH, BST_SPLASH_HEIGHT, 15);
bst_splash_set_title (beast_splash, _("BEAST Startup"));
@@ -128,7 +112,6 @@ main (int argc,
BST_VERSION, BST_VERSION_HINT);
bst_splash_update_entity (beast_splash, _("Startup"));
bst_splash_show_grab (beast_splash);
-
/* BEAST initialization */
bst_splash_update_item (beast_splash, _("Initializers"));
_bst_init_utils ();
@@ -136,11 +119,9 @@ main (int argc,
_bst_gconfig_init ();
_bst_skin_config_init ();
_bst_msg_absorb_config_init ();
-
/* parse rc file */
bst_splash_update_item (beast_splash, _("RC Files"));
bst_preferences_load_rc_files();
-
/* show splash images */
bst_splash_update_item (beast_splash, _("Splash Image"));
string = g_strconcat (BST_PATH_IMAGES, G_DIR_SEPARATOR_S, BST_SPLASH_IMAGE, NULL);
@@ -152,7 +133,6 @@ main (int argc,
bst_splash_set_animation (beast_splash, anim);
g_object_unref (anim);
}
-
/* start BSE core and connect */
bst_splash_update_item (beast_splash, _("BSE Core"));
bse_init_async (&argc, &argv, "BEAST", config);
@@ -163,20 +143,16 @@ main (int argc,
NULL, NULL, NULL);
g_source_attach (source, NULL);
g_source_unref (source);
-
/* now that the BSE thread runs, drop scheduling priorities if we have any */
setpriority (PRIO_PROCESS, getpid(), 0);
-
/* watch registration notifications on server */
bse_proxy_connect (BSE_SERVER,
"signal::registration", server_registration, beast_splash,
NULL);
-
/* register core plugins */
if (register_core_plugins)
{
bst_splash_update_entity (beast_splash, _("Plugins"));
-
/* plugin registration, this is done asyncronously,
* so we wait until all are done
*/
@@ -190,12 +166,10 @@ main (int argc,
sfi_glue_gc_run ();
}
}
-
/* register LADSPA plugins */
if (register_ladspa_plugins)
{
bst_splash_update_entity (beast_splash, _("LADSPA Plugins"));
-
/* plugin registration, this is done asyncronously,
* so we wait until all are done
*/
@@ -209,7 +183,6 @@ main (int argc,
sfi_glue_gc_run ();
}
}
-
/* debugging hook */
const char *estring = g_getenv ("BEAST_SLEEP4GDB");
if (estring && atoi (estring) > 0)
@@ -218,12 +191,10 @@ main (int argc,
g_message ("going into sleep mode due to debugging request (pid=%u)", getpid ());
g_usleep (2147483647);
}
-
/* register BSE scripts */
if (register_scripts)
{
bst_splash_update_entity (beast_splash, _("Scripts"));
-
/* script registration, this is done asyncronously,
* so we wait until all are done
*/
@@ -237,15 +208,12 @@ main (int argc,
sfi_glue_gc_run ();
}
}
-
/* listen to BseServer notification */
bst_splash_update_entity (beast_splash, _("Dialogs"));
bst_message_connect_to_server ();
_bst_init_radgets ();
-
/* install message dialog handler */
bst_message_handler_install();
-
/* open files given on command line */
if (argc > 1)
bst_splash_update_entity (beast_splash, _("Loading..."));
@@ -254,14 +222,12 @@ main (int argc,
for (i = 1; i < argc; i++)
{
bst_splash_update ();
-
/* parse non-file args */
if (strcmp (argv[i], "--merge") == 0)
{
merge_with_last = TRUE;
continue;
}
-
/* load waves into the last project */
if (bse_server_can_load (BSE_SERVER, argv[i]))
{
@@ -294,7 +260,6 @@ main (int argc,
}
continue;
}
-
/* load/merge projects */
if (!app || !merge_with_last)
{
@@ -318,13 +283,11 @@ main (int argc,
sfi_error (_("Failed to merge project \"%s\": %s"), argv[i], bse_error_blurb (error));
}
}
-
/* open default app window
*/
if (!app)
{
SfiProxy project = bse_server_use_new_project (BSE_SERVER, "Untitled.bse");
-
bse_project_get_wave_repo (project);
app = bst_app_new (project);
bse_item_unuse (project);
@@ -332,7 +295,6 @@ main (int argc,
gtk_widget_hide (beast_splash);
}
/* splash screen is definitely hidden here (still grabbing) */
-
/* fire up release notes dialog
*/
gboolean update_rc_files = FALSE;
@@ -374,7 +336,6 @@ main (int argc,
update_rc_files = TRUE;
bst_gconfig_set_rc_version (BST_VERSION);
}
-
/* release splash grab */
gtk_widget_hide (beast_splash);
bst_splash_release_grab (beast_splash);
@@ -386,11 +347,9 @@ main (int argc,
g_main_iteration (TRUE);
GDK_THREADS_ENTER ();
}
-
/* take down GUI */
bst_message_handler_uninstall();
bst_message_dialogs_popdown ();
-
/* perform necessary cleanup cycles */
GDK_THREADS_LEAVE ();
while (g_main_iteration (FALSE))
@@ -400,7 +359,6 @@ main (int argc,
GDK_THREADS_LEAVE ();
}
GDK_THREADS_ENTER ();
-
/* save BSE configuration */
if (update_rc_files && !bst_preferences_saved())
{
@@ -413,7 +371,6 @@ main (int argc,
g_warning ("failed to save rc-file \"%s\": %s", file_name, bse_error_blurb (error));
g_free (file_name);
}
-
/* perform necessary cleanup cycles
*/
GDK_THREADS_LEAVE ();
@@ -424,12 +381,9 @@ main (int argc,
GDK_THREADS_LEAVE ();
}
birnet_cleanup_force_handlers();
-
bse_object_debug_leaks ();
-
return 0;
}
-
static void
bst_early_parse_args (int *argc_p,
char ***argv_p)
@@ -438,7 +392,6 @@ bst_early_parse_args (int *argc_p,
gchar **argv = *argv_p;
gchar *envar;
guint i, e;
-
envar = getenv ("BST_DEBUG");
if (envar)
sfi_msg_allow (envar);
@@ -451,7 +404,6 @@ bst_early_parse_args (int *argc_p,
envar = getenv ("BEAST_NO_DEBUG");
if (envar)
sfi_msg_deny (envar);
-
gboolean initialize_bse_and_exit = FALSE;
for (i = 1; i < argc; i++)
{
@@ -519,7 +471,6 @@ bst_early_parse_args (int *argc_p,
strncmp ("--debug=", argv[i], 8) == 0)
{
gchar *equal = argv[i] + 7;
-
if (*equal == '=')
sfi_msg_allow (equal + 1);
else if (i + 1 < argc)
@@ -533,7 +484,6 @@ bst_early_parse_args (int *argc_p,
strncmp ("--no-debug=", argv[i], 11) == 0)
{
gchar *equal = argv[i] + 10;
-
if (*equal == '=')
sfi_msg_deny (equal + 1);
else if (i + 1 < argc)
@@ -663,7 +613,6 @@ bst_early_parse_args (int *argc_p,
}
}
gxk_param_set_devel_tips (bst_developer_hints);
-
e = 1;
for (i = 1; i < argc; i++)
if (argv[i])
@@ -673,14 +622,12 @@ bst_early_parse_args (int *argc_p,
argv[i] = NULL;
}
*argc_p = e;
-
if (initialize_bse_and_exit)
{
bse_init_async (argc_p, argv_p, "BEAST", NULL);
exit (0);
}
}
-
static void G_GNUC_NORETURN
bst_exit_print_version (void)
{
@@ -735,7 +682,6 @@ bst_exit_print_version (void)
g_free (freeme);
exit (0);
}
-
static void
bst_print_blurb (void)
{
@@ -794,7 +740,6 @@ bst_print_blurb (void)
g_print (" --g-fatal-warnings Make warnings fatal (abort)\n");
g_print (" --sync Do all X calls synchronously\n");
}
-
void
beast_show_about_box (void)
{
diff --git a/beast-gtk/bstmenus.cc b/beast-gtk/bstmenus.cc
index afeb4b0..127a296 100644
--- a/beast-gtk/bstmenus.cc
+++ b/beast-gtk/bstmenus.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstmenus.hh"
#include <string.h>
-
-
/* --- structures --- */
struct _BstChoice
{
@@ -12,14 +10,10 @@ struct _BstChoice
const gchar *name;
gpointer p_id;
};
-
-
/* --- variables --- */
static gboolean modal_loop_running = FALSE;
static gboolean modal_loop_quit_on_menu_item_activate = FALSE;
static GtkWidget *current_popup_menu = NULL;
-
-
/* --- functions --- */
BstChoice*
bst_choice_alloc (BstChoiceFlags type,
@@ -29,26 +23,21 @@ bst_choice_alloc (BstChoiceFlags type,
BseIcon *icon)
{
BstChoice *choice = g_new (BstChoice, 1);
-
choice->type_and_flags = type;
choice->icon_stock_id = icon_stock_id;
choice->bse_icon = icon ? bse_icon_copy_shallow (icon) : NULL;
choice->name = choice_name;
choice->p_id = choice_id;
-
return choice;
}
-
static void
menu_choice_activate (GtkWidget *item,
gpointer data)
{
gpointer udata = gtk_object_get_user_data (GTK_OBJECT (item));
-
if (GTK_IS_MENU (current_popup_menu))
{
gtk_object_set_data (GTK_OBJECT (current_popup_menu), "BstChoice", udata);
-
if (modal_loop_quit_on_menu_item_activate)
modal_loop_running = FALSE;
}
@@ -57,42 +46,34 @@ menu_choice_activate (GtkWidget *item,
while (GTK_IS_MENU (item->parent))
{
GtkWidget *tmp;
-
item = item->parent;
tmp = gtk_menu_get_attach_widget (GTK_MENU (item));
if (GTK_IS_MENU_ITEM (tmp))
item = tmp;
}
g_assert (GTK_IS_MENU (item));
-
gtk_object_set_data (GTK_OBJECT (item), "BstChoice", udata);
}
}
-
static void
button_choice_activate (GtkWidget *item,
gpointer data)
{
GtkWidget *window = gtk_widget_get_ancestor (item, GTK_TYPE_WINDOW);
-
gtk_object_set_data (GTK_OBJECT (window), "BstChoice", data);
-
gtk_widget_hide (window);
}
-
static void
check_modal_quit (GtkWidget *item)
{
if (modal_loop_quit_on_menu_item_activate)
modal_loop_running = FALSE;
}
-
static void
menu_item_add_activator (GtkWidget *widget,
gpointer function)
{
GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
-
if (GTK_IS_CONTAINER (menu))
gtk_container_forall (GTK_CONTAINER (menu), menu_item_add_activator, NULL);
else
@@ -100,7 +81,6 @@ menu_item_add_activator (GtkWidget *widget,
"signal::activate", function, NULL,
NULL);
}
-
static void
free_choice (BstChoice *choice)
{
@@ -108,20 +88,16 @@ free_choice (BstChoice *choice)
bse_icon_free (choice->bse_icon);
g_free (choice);
}
-
void
bst_choice_menu_add_choice_and_free (GtkWidget *menu,
BstChoice *choice)
{
guint choice_type, choice_flags;
GtkWidget *item;
-
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (choice != NULL);
-
choice_type = choice->type_and_flags & BST_CHOICE_TYPE_MASK;
choice_flags = choice->type_and_flags & BST_CHOICE_FLAG_MASK;
-
item = gtk_widget_new (GTK_TYPE_IMAGE_MENU_ITEM,
"visible", TRUE,
"sensitive", !((choice_flags & BST_CHOICE_FLAG_INSENSITIVE) ||
@@ -137,7 +113,6 @@ bst_choice_menu_add_choice_and_free (GtkWidget *menu,
if (choice->name)
{
GtkWidget *any;
-
if (choice->icon_stock_id)
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
gxk_stock_image (choice->icon_stock_id, GXK_ICON_SIZE_MENU));
@@ -153,7 +128,6 @@ bst_choice_menu_add_choice_and_free (GtkWidget *menu,
}
free_choice (choice);
}
-
void
bst_choice_menu_set_item_sensitive (GtkWidget *menu,
gulong id,
@@ -161,9 +135,7 @@ bst_choice_menu_set_item_sensitive (GtkWidget *menu,
{
GtkMenuShell *shell;
GList *list;
-
g_return_if_fail (GTK_IS_MENU (menu));
-
shell = GTK_MENU_SHELL (menu);
for (list = shell->children; list; list = list->next)
{
@@ -175,7 +147,6 @@ bst_choice_menu_set_item_sensitive (GtkWidget *menu,
}
g_warning ("unable to find item with id %lu in menu %p", id, menu);
}
-
GtkWidget*
bst_choice_menu_createv (const gchar *menu_path,
BstChoice *first_choice,
@@ -185,7 +156,6 @@ bst_choice_menu_createv (const gchar *menu_path,
GtkWidget *menu;
va_list args;
va_start (args, first_choice);
-
menu = gtk_widget_new (GTK_TYPE_MENU, NULL);
g_object_connect (menu,
"signal::selection-done", check_modal_quit, NULL,
@@ -193,19 +163,15 @@ bst_choice_menu_createv (const gchar *menu_path,
gtk_menu_set_accel_path (GTK_MENU (menu), menu_path);
gtk_widget_ref (menu);
gtk_object_sink (GTK_OBJECT (menu));
-
choice = first_choice;
while (choice)
{
bst_choice_menu_add_choice_and_free (menu, choice);
choice = va_arg (args, BstChoice*);
}
-
va_end (args);
-
return menu;
}
-
GtkWidget*
bst_choice_dialog_createv (BstChoice *first_choice,
...)
@@ -213,9 +179,7 @@ bst_choice_dialog_createv (BstChoice *first_choice,
BstChoice *choice;
GtkWidget *vbox, *dialog;
va_list args;
-
g_return_val_if_fail (first_choice != NULL, NULL);
-
/* text portions
*/
vbox = gtk_widget_new (GTK_TYPE_VBOX,
@@ -228,7 +192,6 @@ bst_choice_dialog_createv (BstChoice *first_choice,
{
guint choice_type = choice->type_and_flags & BST_CHOICE_TYPE_MASK;
guint choice_flags = choice->type_and_flags & BST_CHOICE_FLAG_MASK;
-
switch (choice_type)
{
GtkWidget *any;
@@ -256,13 +219,11 @@ bst_choice_dialog_createv (BstChoice *first_choice,
}
while (choice);
va_end (args);
-
/* create dialog
*/
dialog = (GtkWidget*) gxk_dialog_new (NULL, NULL, GXK_DIALOG_POPUP_POS | GXK_DIALOG_MODAL, NULL, vbox);
gtk_widget_ref (dialog);
gtk_object_sink (GTK_OBJECT (dialog));
-
/* add items
*/
va_start (args, first_choice);
@@ -271,7 +232,6 @@ bst_choice_dialog_createv (BstChoice *first_choice,
{
guint choice_type = choice->type_and_flags & BST_CHOICE_TYPE_MASK;
guint choice_flags = choice->type_and_flags & BST_CHOICE_FLAG_MASK;
-
switch (choice_type)
{
GtkWidget *any;
@@ -287,41 +247,31 @@ bst_choice_dialog_createv (BstChoice *first_choice,
gtk_widget_set_sensitive (any, FALSE);
break;
}
-
free_choice (choice);
-
choice = va_arg (args, BstChoice*);
}
while (choice);
va_end (args);
-
return dialog;
}
-
void
bst_choice_destroy (GtkWidget *choice)
{
g_return_if_fail (GTK_IS_CONTAINER (choice));
-
gtk_widget_destroy (choice);
gtk_widget_unref (choice);
}
-
gboolean
bst_choice_selectable (GtkWidget *widget)
{
gboolean selectable = FALSE;
-
g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE);
-
if (GTK_IS_MENU (widget))
{
GList *list, *children = gtk_container_children (GTK_CONTAINER (widget));
-
for (list = children; list; list = list->next)
{
GtkBin *bin = (GtkBin*) list->data;
-
if (GTK_WIDGET_IS_SENSITIVE (bin) && GTK_WIDGET_VISIBLE (bin) && bin->child)
{
selectable = TRUE;
@@ -333,11 +283,9 @@ bst_choice_selectable (GtkWidget *widget)
else if (GXK_IS_DIALOG (widget))
{
GList *list, *children = gtk_container_children (GTK_CONTAINER (GXK_DIALOG (widget)->hbox));
-
for (list = children; list; list = list->next)
{
GtkBin *bin = (GtkBin*) list->data;
-
if (GTK_IS_BUTTON (bin) && GTK_WIDGET_IS_SENSITIVE (bin) && GTK_WIDGET_VISIBLE (bin))
{
selectable = TRUE;
@@ -346,23 +294,18 @@ bst_choice_selectable (GtkWidget *widget)
}
g_list_free (children);
}
-
return selectable;
}
-
guint
bst_choice_modal (GtkWidget *choice,
guint mouse_button,
guint32 time)
{
gpointer data = GUINT_TO_POINTER (0);
-
if (GTK_IS_MENU (choice))
{
GtkMenu *menu = GTK_MENU (choice);
-
gtk_object_set_data (GTK_OBJECT (menu), "BstChoice", data);
-
if (bst_choice_selectable (choice))
{
modal_loop_quit_on_menu_item_activate = TRUE;
@@ -378,17 +321,14 @@ bst_choice_modal (GtkWidget *choice,
current_popup_menu = NULL;
modal_loop_quit_on_menu_item_activate = FALSE;
}
-
data = gtk_object_get_data (GTK_OBJECT (menu), "BstChoice");
}
else if (GXK_IS_DIALOG (choice))
{
gtk_object_set_data (GTK_OBJECT (choice), "BstChoice", data);
-
if (bst_choice_selectable (choice))
{
gtk_widget_show (choice);
-
while (GTK_WIDGET_VISIBLE (choice))
{
GDK_THREADS_LEAVE ();
@@ -396,21 +336,16 @@ bst_choice_modal (GtkWidget *choice,
GDK_THREADS_ENTER ();
}
}
-
data = gtk_object_get_data (GTK_OBJECT (choice), "BstChoice");
}
-
return GPOINTER_TO_UINT (data);
}
-
guint
bst_choice_get_last (GtkWidget *widget)
{
gpointer data = gtk_object_get_data (GTK_OBJECT (widget), "BstChoice");
-
return GPOINTER_TO_UINT (data);
}
-
/* Accelerator recommendations:
*
{ "/File/New", "<Control>N", },
diff --git a/beast-gtk/bstmenus.hh b/beast-gtk/bstmenus.hh
index ee7984b..fc09518 100644
--- a/beast-gtk/bstmenus.hh
+++ b/beast-gtk/bstmenus.hh
@@ -1,16 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_MENUS_H__
#define __BST_MENUS_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- BstChoice --- */
/* BstChoice are simple inlined popup menus for modal selections.
*/
typedef struct _BstChoice BstChoice;
-
GtkWidget* bst_choice_menu_createv (const gchar *menu_path,
BstChoice *first_choice,
...);
@@ -27,8 +23,6 @@ guint bst_choice_modal (GtkWidget *widget,
guint32 time);
guint bst_choice_get_last (GtkWidget *widget);
void bst_choice_destroy (GtkWidget *choice);
-
-
/* --- BstChoice shortcuts --- */
#define BST_CHOICE_TITLE(name) (bst_choice_alloc (BST_CHOICE_TYPE_TITLE, \
(name), NULL, BST_STOCK_NONE, 0))
@@ -50,8 +44,6 @@ void bst_choice_destroy (GtkWidget *choice);
#define BST_CHOICE_SEPERATOR (bst_choice_alloc (BST_CHOICE_TYPE_SEPARATOR, \
NULL, NULL, BST_STOCK_NONE, 0))
#define BST_CHOICE_END (NULL)
-
-
/* --- private implementation stubs --- */
typedef enum
{
@@ -70,9 +62,7 @@ BstChoice* bst_choice_alloc (BstChoiceFlags type,
gpointer choice_id,
const gchar *icon_stock_id,
BseIcon *bse_icon);
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline BstChoiceFlags operator& (BstChoiceFlags s1, BstChoiceFlags s2) { return BstChoiceFlags (s1 & (long long unsigned) s2); }
@@ -81,5 +71,4 @@ inline BstChoiceFlags operator| (BstChoiceFlags s1, BstChoiceFlags s2) { retu
inline BstChoiceFlags& operator|= (BstChoiceFlags &s1, BstChoiceFlags s2) { s1 = s1 | s2; return s1; }
inline BstChoiceFlags operator~ (BstChoiceFlags s1) { return BstChoiceFlags (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __BST_MENUS_H__ */
diff --git a/beast-gtk/bstmsgabsorb.cc b/beast-gtk/bstmsgabsorb.cc
index ef34154..2dfa6aa 100644
--- a/beast-gtk/bstmsgabsorb.cc
+++ b/beast-gtk/bstmsgabsorb.cc
@@ -1,25 +1,21 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstmsgabsorb.hh"
#include <string.h>
-
enum {
MCOL_CHECK,
MCOL_BLURB,
MCOL_VERSION,
N_MCOLS
};
-
/* --- variables --- */
static BstMsgAbsorbStringSeq *global_msg_absorb_config = NULL;
static GParamSpec *pspec_msg_absorb_config = NULL;
static gboolean msg_absorb_config_loaded = FALSE;
-
/* --- functions --- */
void
_bst_msg_absorb_config_init (void)
{
g_return_if_fail (global_msg_absorb_config == NULL);
-
/* global config record description */
pspec_msg_absorb_config = sfi_pspec_seq ("beast-msg-absorb-config-v1", NULL, NULL,
sfi_pspec_rec ("mstring", NULL, NULL, bst_msg_absorb_string_fields, SFI_PARAM_STANDARD),
@@ -38,13 +34,11 @@ _bst_msg_absorb_config_init (void)
sfi_value_free (value);
sfi_seq_unref (seq);
}
-
GParamSpec*
bst_msg_absorb_config_pspec (void)
{
return pspec_msg_absorb_config;
}
-
BstMsgAbsorbStringSeq*
bst_msg_absorb_config_get_global (void)
{
@@ -52,7 +46,6 @@ bst_msg_absorb_config_get_global (void)
bst_msg_absorb_config_load();
return global_msg_absorb_config;
}
-
static void
set_msg_absorb_config (BstMsgAbsorbStringSeq *msg_absorb_config)
{
@@ -60,21 +53,17 @@ set_msg_absorb_config (BstMsgAbsorbStringSeq *msg_absorb_config)
global_msg_absorb_config = msg_absorb_config;
bst_msg_absorb_string_seq_free (oldconfig);
}
-
void
bst_msg_absorb_config_apply (SfiSeq *src_seq)
{
g_return_if_fail (src_seq != NULL);
-
SfiSeq *seq = sfi_seq_copy_deep (src_seq);
sfi_seq_validate (seq, bst_msg_absorb_config_pspec());
BstMsgAbsorbStringSeq *mconfig = bst_msg_absorb_string_seq_from_seq (seq);
sfi_seq_unref (seq);
set_msg_absorb_config (mconfig);
}
-
# include "topconfig.h" /* BST_VERSION */
-
gboolean
bst_msg_absorb_config_match (const gchar *config_blurb)
{
@@ -85,7 +74,6 @@ bst_msg_absorb_config_match (const gchar *config_blurb)
return !mstrings->strings[i]->enabled;
return FALSE;
}
-
void
bst_msg_absorb_config_update (const gchar *config_blurb)
{
@@ -107,7 +95,6 @@ bst_msg_absorb_config_update (const gchar *config_blurb)
if (changed)
bst_msg_absorb_config_save();
}
-
gboolean
bst_msg_absorb_config_adjust (const gchar *config_blurb,
gboolean enabled,
@@ -141,7 +128,6 @@ bst_msg_absorb_config_adjust (const gchar *config_blurb,
}
return FALSE;
}
-
static void
msg_absorb_string_seq_fill_value (GtkWidget *self,
guint column,
@@ -169,7 +155,6 @@ msg_absorb_string_seq_fill_value (GtkWidget *self,
break;
}
}
-
static void
msg_absorb_string_toggled (GtkCellRendererToggle *cell,
const gchar *strpath,
@@ -184,7 +169,6 @@ msg_absorb_string_toggled (GtkCellRendererToggle *cell,
gtk_cell_renderer_toggle_set_active (cell, mass->strings[i]->enabled);
}
}
-
GtkWidget*
bst_msg_absorb_config_box (void)
{
@@ -217,7 +201,6 @@ bst_msg_absorb_config_box (void)
gtk_tree_view_set_expander_column (tview, col); /* where to put unused expander space */
return (GtkWidget*) self;
}
-
void
bst_msg_absorb_config_box_set (GtkWidget *self,
BstMsgAbsorbStringSeq *mass)
@@ -232,37 +215,30 @@ bst_msg_absorb_config_box_set (GtkWidget *self,
gxk_list_wrapper_notify_clear (GXK_LIST_WRAPPER (model));
gxk_list_wrapper_notify_append (GXK_LIST_WRAPPER (model), mass->n_strings);
}
-
BstMsgAbsorbStringSeq*
bst_msg_absorb_config_box_get (GtkWidget *self)
{
BstMsgAbsorbStringSeq *mass = (BstMsgAbsorbStringSeq*) g_object_get_data ((GObject*) self, "BstMsgAbsorbStringSeq");
return mass;
}
-
/* --- config file --- */
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "topconfig.h" /* BST_VERSION */
#include <sfi/sfistore.hh> /* we rely on internal API here */
-
static BseErrorType
bst_msg_absorb_config_dump (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
sfi_make_dirname_path (file_name);
gint fd = open (file_name,
O_WRONLY | O_CREAT | O_TRUNC, /* O_EXCL, */
0666);
if (fd < 0)
return errno == EEXIST ? BSE_ERROR_FILE_EXISTS : BSE_ERROR_IO;
-
SfiWStore *wstore = sfi_wstore_new ();
-
sfi_wstore_printf (wstore, "; message-absorb-config-file for BEAST v%s\n", BST_VERSION);
-
/* store config */
sfi_wstore_puts (wstore, "\n");
SfiSeq *seq = bst_msg_absorb_string_seq_to_seq (bst_msg_absorb_config_get_global());
@@ -271,14 +247,11 @@ bst_msg_absorb_config_dump (const gchar *file_name)
sfi_value_free (value);
sfi_seq_unref (seq);
sfi_wstore_puts (wstore, "\n");
-
/* flush buffers to file */
sfi_wstore_flush_fd (wstore, fd);
sfi_wstore_destroy (wstore);
-
return close (fd) < 0 ? BSE_ERROR_IO : BSE_ERROR_NONE;
}
-
void
bst_msg_absorb_config_save (void)
{
@@ -288,7 +261,6 @@ bst_msg_absorb_config_save (void)
sfi_diag ("Failed to save config-file \"%s\": %s", file_name, bse_error_blurb (error));
g_free (file_name);
}
-
static GTokenType
msg_absorb_config_try_statement (gpointer context_data,
SfiRStore *rstore,
@@ -310,12 +282,10 @@ msg_absorb_config_try_statement (gpointer context_data,
else
return SFI_TOKEN_UNMATCHED;
}
-
static BseErrorType
bst_msg_absorb_config_parse (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
gchar *absname = sfi_path_get_filename (file_name, NULL);
gint fd = open (absname, O_RDONLY, 0);
if (fd < 0)
@@ -324,7 +294,6 @@ bst_msg_absorb_config_parse (const gchar *file_name)
return (errno == ENOENT || errno == ENOTDIR || errno == ELOOP ?
BSE_ERROR_FILE_NOT_FOUND : BSE_ERROR_IO);
}
-
SfiRStore *rstore = sfi_rstore_new ();
sfi_rstore_input_fd (rstore, fd, absname);
BseErrorType error = BSE_ERROR_NONE;
@@ -335,7 +304,6 @@ bst_msg_absorb_config_parse (const gchar *file_name)
g_free (absname);
return error;
}
-
static gboolean
parse_version (const gchar *version,
glong *vmajorp,
@@ -368,7 +336,6 @@ parse_version (const gchar *version,
g_free (vstring);
return FALSE;
}
-
static gint
string_versions_compare (const gchar *version1,
const gchar *version2)
@@ -380,7 +347,6 @@ string_versions_compare (const gchar *version1,
(vminor1 != vminor2) ? (vminor1 > vminor2 ? +1 : -1) :
(vmicro1 < vmicro2 ? -1 : vmicro1 > vmicro2));
}
-
void
bst_msg_absorb_config_load (void)
{
diff --git a/beast-gtk/bstmsgabsorb.hh b/beast-gtk/bstmsgabsorb.hh
index ae39b62..7241bc2 100644
--- a/beast-gtk/bstmsgabsorb.hh
+++ b/beast-gtk/bstmsgabsorb.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_MSG_ABSORB_H__
#define __BST_MSG_ABSORB_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- access config file --- */
#define BST_STRDUP_ABSORBRC_FILE() (g_strconcat (g_get_home_dir (), "/.beast/absorbrc", NULL))
-
/* --- prototypes --- */
void _bst_msg_absorb_config_init (void);
void bst_msg_absorb_config_apply (SfiSeq *seq);
@@ -23,11 +19,8 @@ GtkWidget* bst_msg_absorb_config_box (void);
void bst_msg_absorb_config_box_set (GtkWidget *box,
BstMsgAbsorbStringSeq *mass);
BstMsgAbsorbStringSeq* bst_msg_absorb_config_box_get (GtkWidget *box);
-
/* --- config file --- */
void bst_msg_absorb_config_save (void);
void bst_msg_absorb_config_load (void);
-
G_END_DECLS
-
#endif /* __BST_MSG_ABSORB_H__ */
diff --git a/beast-gtk/bstparam-automation.cc b/beast-gtk/bstparam-automation.cc
index 08183ee..bac4aba 100644
--- a/beast-gtk/bstparam-automation.cc
+++ b/beast-gtk/bstparam-automation.cc
@@ -1,16 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- automation setup editor --- */
#include "bstprocedure.hh"
-
static void
param_automation_dialog_cancel (GxkDialog *dialog)
{
g_object_set_data ((GObject*) dialog, "beast-GxkParam", NULL);
gxk_toplevel_delete (GTK_WIDGET (dialog));
}
-
static void
param_automation_dialog_ok (GxkDialog *dialog)
{
@@ -27,7 +23,6 @@ param_automation_dialog_ok (GxkDialog *dialog)
}
gxk_toplevel_delete (GTK_WIDGET (dialog));
}
-
static void
param_automation_popup_editor (GtkWidget *widget,
GxkParam *param)
@@ -94,7 +89,6 @@ param_automation_popup_editor (GtkWidget *widget,
gxk_widget_showraise (GTK_WIDGET (automation_dialog));
}
}
-
static void
param_automation_unrequest_focus_space (GtkWidget *button, // GTKFIX: GtkButton requests focus space for !CAN_FOCUS
GtkRequisition *requisition)
@@ -108,7 +102,6 @@ param_automation_unrequest_focus_space (GtkWidget *button, // GTKFIX: GtkB
requisition->height -= 2 * (focus_width + focus_pad);
}
}
-
static GtkWidget*
param_automation_create (GxkParam *param,
const gchar *tooltip,
@@ -136,7 +129,6 @@ param_automation_create (GxkParam *param,
g_object_connect (button, "signal::clicked", param_automation_popup_editor, param, NULL);
return widget;
}
-
static const SfiChoiceValue*
param_automation_find_choice_value (const gchar *choice,
GParamSpec *pspec)
@@ -148,7 +140,6 @@ param_automation_find_choice_value (const gchar *choice,
return &cvalues.values[i];
return NULL;
}
-
static void
param_automation_update (GxkParam *param,
GtkWidget *widget)
@@ -214,7 +205,6 @@ param_automation_update (GxkParam *param,
g_free (tip);
gtk_widget_set_sensitive (GTK_BIN (widget)->child, proxy && !bse_source_is_prepared (proxy));
}
-
static GxkParamEditor param_automation = {
{ "automation", N_("Control Automation"), },
{ 0, },
diff --git a/beast-gtk/bstparam-choice.cc b/beast-gtk/bstparam-choice.cc
index 17ae4f9..743a8fb 100644
--- a/beast-gtk/bstparam-choice.cc
+++ b/beast-gtk/bstparam-choice.cc
@@ -1,9 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- choice parameters --- */
#define CHOICE_PARAM_OPTION_MENU GXK_MENU_BUTTON_POPUP_MODE
-
static void
param_choice_change_value (GtkWidget *widget,
GxkParam *param)
@@ -23,7 +20,6 @@ param_choice_change_value (GtkWidget *widget,
gxk_param_apply_value (param);
}
}
-
static void
param_choice_item_activated (GtkWidget *menu_item,
GtkWidget *widget)
@@ -32,7 +28,6 @@ param_choice_item_activated (GtkWidget *menu_item,
if (mshell)
gxk_menu_set_active (GTK_MENU (mshell), menu_item);
}
-
static GtkWidget*
param_choice_create (GxkParam *param,
const gchar *tooltip,
@@ -43,7 +38,6 @@ param_choice_create (GxkParam *param,
GtkContainer *menu;
gchar *str;
guint i;
-
if (variant == CHOICE_PARAM_OPTION_MENU)
widget = (GtkWidget*) g_object_new (GTK_TYPE_OPTION_MENU,
"visible", TRUE,
@@ -55,7 +49,6 @@ param_choice_create (GxkParam *param,
"can-focus", variant == GXK_MENU_BUTTON_COMBO_MODE,
NULL);
gxk_widget_set_tooltip (widget, tooltip);
-
menu = (GtkContainer*) g_object_new (GTK_TYPE_MENU, NULL);
for (i = 0; i < cvalues.n_values; i++)
{
@@ -67,7 +60,6 @@ param_choice_create (GxkParam *param,
g_object_set_qdata (G_OBJECT (item), quark_param_choice_values, (gpointer) &cvalues.values[i]);
gtk_container_add (menu, item);
}
-
if (GXK_IS_MENU_BUTTON (widget))
{
SfiProxy proxy = bst_param_get_proxy (param);
@@ -90,7 +82,6 @@ param_choice_create (GxkParam *param,
NULL);
return widget;
}
-
static void
param_choice_update (GxkParam *param,
GtkWidget *widget)
@@ -123,7 +114,6 @@ param_choice_update (GxkParam *param,
gxk_menu_button_update (GXK_MENU_BUTTON (widget));
}
}
-
static GxkParamEditor param_choice1 = {
{ "combo-button", N_("Drop Down Combo"), },
{ G_TYPE_STRING, "SfiChoice", },
diff --git a/beast-gtk/bstparam-color-spinner.cc b/beast-gtk/bstparam-color-spinner.cc
index 424a91a..642a69a 100644
--- a/beast-gtk/bstparam-color-spinner.cc
+++ b/beast-gtk/bstparam-color-spinner.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- color parameter editors --- */
#include "bstauxdialogs.hh"
static gint
@@ -19,7 +17,6 @@ param_color_spinner_input (GtkSpinButton *spin_button,
else
return GTK_INPUT_ERROR;
}
-
static gint
param_color_spinner_output (GtkSpinButton *spin_button,
GxkParam *param)
@@ -30,7 +27,6 @@ param_color_spinner_output (GtkSpinButton *spin_button,
g_free (string);
return TRUE;
}
-
static void
param_color_assign (GtkWidget *dialog,
GdkColor *color,
@@ -41,7 +37,6 @@ param_color_assign (GtkWidget *dialog,
guint n = ((c.red >> 8) << 16) + ((c.green >> 8) << 8) + (c.blue >> 8);
gtk_adjustment_set_value (spin_button->adjustment, n);
}
-
static void
param_color_popup_selector (GtkSpinButton *spin_button)
{
@@ -55,7 +50,6 @@ param_color_popup_selector (GtkSpinButton *spin_button)
gxk_widget_showraise (dialog);
}
}
-
static GtkWidget*
param_color_spinner_create (GxkParam *param,
const gchar *tooltip,
@@ -87,7 +81,6 @@ param_color_spinner_create (GxkParam *param,
gxk_widget_add_option (box, "hexpand", "+");
return widget;
}
-
static void
param_color_spinner_update (GxkParam *param,
GtkWidget *widget)
@@ -95,7 +88,6 @@ param_color_spinner_update (GxkParam *param,
/* contents are updated through the adjustment */
gtk_editable_set_editable (GTK_EDITABLE (widget), param->editable);
}
-
static GxkParamEditor param_color_spinner = {
{ "color-spinner", N_("Color Entry"), },
{ G_TYPE_INT, },
diff --git a/beast-gtk/bstparam-item-seq.cc b/beast-gtk/bstparam-item-seq.cc
index 5d8e3f6..4dac83e 100644
--- a/beast-gtk/bstparam-item-seq.cc
+++ b/beast-gtk/bstparam-item-seq.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- item sequence editors --- */
#include "bstitemseqdialog.hh"
static void
@@ -17,7 +15,6 @@ param_item_seq_changed (gpointer data,
gxk_param_apply_value (param);
}
}
-
static void
param_item_seq_popup_editor (GtkWidget *widget,
GxkParam *param)
@@ -36,7 +33,6 @@ param_item_seq_popup_editor (GtkWidget *widget,
bse_item_seq_free (iseq);
}
}
-
static GtkWidget*
param_item_seq_create (GxkParam *param,
const gchar *tooltip,
@@ -76,7 +72,6 @@ param_item_seq_create (GxkParam *param,
/* gxk_widget_add_option (box, "hexpand", "+"); */
return widget;
}
-
static void
param_item_seq_update (GxkParam *param,
GtkWidget *widget)
@@ -125,7 +120,6 @@ param_item_seq_update (GxkParam *param,
NULL);
g_free (content);
}
-
static GxkParamEditor param_item_seq = {
{ "item-list", N_("Item List"), },
{ G_TYPE_BOXED, "SfiSeq", },
diff --git a/beast-gtk/bstparam-note-sequence.cc b/beast-gtk/bstparam-note-sequence.cc
index 006e066..88d128a 100644
--- a/beast-gtk/bstparam-note-sequence.cc
+++ b/beast-gtk/bstparam-note-sequence.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstsequence.hh"
-
/* --- string parameters --- */
static void
param_note_sequence_changed (GtkWidget *swidget,
@@ -12,7 +11,6 @@ param_note_sequence_changed (GtkWidget *swidget,
gxk_param_apply_value (param);
}
}
-
static GtkWidget*
param_note_sequence_create (GxkParam *param,
const gchar *tooltip,
@@ -27,7 +25,6 @@ param_note_sequence_create (GxkParam *param,
gxk_widget_add_option (widget, "vexpand", "+");
return widget;
}
-
static void
param_note_sequence_update (GxkParam *param,
GtkWidget *widget)
@@ -40,7 +37,6 @@ param_note_sequence_update (GxkParam *param,
bse_note_sequence_free (nseq);
}
}
-
static GxkParamEditor param_note_sequence = {
{ "note-sequence", N_("Note Sequence Grid Editor"), },
{ G_TYPE_BOXED, "SfiRec", },
diff --git a/beast-gtk/bstparam-note-spinner.cc b/beast-gtk/bstparam-note-spinner.cc
index 1b6f1a7..0e9e3fa 100644
--- a/beast-gtk/bstparam-note-spinner.cc
+++ b/beast-gtk/bstparam-note-spinner.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- note parameter editors --- */
static gint
param_note_spinner_input (GtkSpinButton *spin_button,
@@ -13,7 +11,6 @@ param_note_spinner_input (GtkSpinButton *spin_button,
g_free (error);
return error ? GTK_INPUT_ERROR : TRUE;
}
-
static gint
param_note_spinner_output (GtkSpinButton *spin_button,
GxkParam *param)
@@ -23,7 +20,6 @@ param_note_spinner_output (GtkSpinButton *spin_button,
g_free (string);
return TRUE;
}
-
static GtkWidget*
param_note_spinner_create (GxkParam *param,
const gchar *tooltip,
@@ -46,7 +42,6 @@ param_note_spinner_create (GxkParam *param,
gxk_widget_set_tooltip (widget, tooltip);
return widget;
}
-
static void
param_note_spinner_update (GxkParam *param,
GtkWidget *widget)
@@ -54,7 +49,6 @@ param_note_spinner_update (GxkParam *param,
/* contents are updated through the adjustment */
gtk_editable_set_editable (GTK_EDITABLE (widget), param->editable);
}
-
static GxkParamEditor param_note_spinner = {
{ "note-spinner", N_("Note Entry"), },
{ G_TYPE_INT, },
diff --git a/beast-gtk/bstparam-proxy.cc b/beast-gtk/bstparam-proxy.cc
index f1fd47e..81416a0 100644
--- a/beast-gtk/bstparam-proxy.cc
+++ b/beast-gtk/bstparam-proxy.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstcluehunter.hh"
#include <string.h>
-
/* --- SfiProxy parameter editors --- */
typedef struct {
BseItemSeq *iseq;
@@ -17,7 +16,6 @@ param_proxy_free_population (gpointer p)
bse_item_seq_free (pop->iseq);
g_free (pop);
}
-
static void
param_proxy_populate (GtkWidget *chunter,
GxkParam *param)
@@ -28,10 +26,8 @@ param_proxy_populate (GtkWidget *chunter,
SfiProxy proxy;
gchar *p;
guint i, l;
-
/* clear current list */
bst_clue_hunter_remove_matches (ch, "*");
-
/* list candidates */
proxy = bst_param_get_proxy (param);
if (proxy)
@@ -54,7 +50,6 @@ param_proxy_populate (GtkWidget *chunter,
g_object_set_data_full (G_OBJECT (ch), "pop", pop, param_proxy_free_population);
if (!pop)
return;
-
/* figure common prefix, aligned to path segment boundaries (':') */
pop->prefix = g_strdup (pop->paths[0]);
/* intersect */
@@ -82,12 +77,10 @@ param_proxy_populate (GtkWidget *chunter,
g_free (pop->prefix);
pop->prefix = p;
l = pop->prefix ? strlen (pop->prefix) : 0;
-
/* add unprefixed names to clue hunter */
for (i = 0; pop->paths[i]; i++)
bst_clue_hunter_add_string (ch, pop->paths[i] + l);
}
-
static void
param_proxy_changed (GtkWidget *entry,
GxkParam *param)
@@ -153,7 +146,6 @@ param_proxy_changed (GtkWidget *entry,
g_free (string);
}
}
-
SfiProxy
bst_item_seq_list_match (GSList *item_seq_slist,
const gchar *text)
@@ -184,7 +176,6 @@ bst_item_seq_list_match (GSList *item_seq_slist,
/* fallback to tail match, then case insensitive matches */
return tmatch ? tmatch : cmatch ? cmatch : tcmatch;
}
-
static GtkWidget*
param_proxy_create (GxkParam *param,
const gchar *tooltip,
@@ -221,7 +212,6 @@ param_proxy_create (GxkParam *param,
gxk_widget_add_option (box, "hexpand", "+");
return box;
}
-
static void
param_proxy_update (GxkParam *param,
GtkWidget *box)
@@ -230,7 +220,6 @@ param_proxy_update (GxkParam *param,
const gchar *cstring = item ? bse_item_get_uname_path (item) : NULL;
GtkWidget *entry = ((GtkBoxChild*) GTK_BOX (box)->children->data)->widget;
GtkWidget *chunter = (GtkWidget*) bst_clue_hunter_from_entry (entry);
-
if (cstring && chunter)
{
ParamProxyPopulation *pop = (ParamProxyPopulation*) g_object_get_data (G_OBJECT (chunter), "pop");
@@ -274,7 +263,6 @@ param_proxy_update (GxkParam *param,
gtk_entry_set_text (GTK_ENTRY (entry), "");
gtk_editable_set_editable (GTK_EDITABLE (entry), param->editable);
}
-
static GxkParamEditor param_proxy = {
{ "proxy", N_("Object Drop Down Box"), },
{ G_TYPE_POINTER, "SfiProxy", },
diff --git a/beast-gtk/bstparam-scale.cc b/beast-gtk/bstparam-scale.cc
index 699eb37..baf09d5 100644
--- a/beast-gtk/bstparam-scale.cc
+++ b/beast-gtk/bstparam-scale.cc
@@ -1,14 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstdial.hh"
#include "bstknob.hh"
-
/* --- scale-alike parameter editor --- */
enum {
PARAM_SCALE_DIAL,
PARAM_SCALE_KNOB,
PARAM_SCALE_LOGARITHMIC = 0x10000
};
-
static GtkWidget*
param_scale_create (GxkParam *param,
const gchar *tooltip,
@@ -25,7 +23,6 @@ param_scale_create (GxkParam *param,
adjustment = gxk_param_get_decibel_adjustment (param);
if (!adjustment)
adjustment = gxk_param_get_adjustment (param);
-
switch (svariant)
{
case PARAM_SCALE_DIAL:
@@ -45,7 +42,6 @@ param_scale_create (GxkParam *param,
gxk_widget_set_tooltip (widget, tooltip);
return widget;
}
-
static GxkParamEditor param_scale1 = {
{ "knob-lin", N_("Knob"), },
{ G_TYPE_NONE, NULL, TRUE, TRUE, }, /* all int types and all float types */
@@ -63,7 +59,6 @@ static const gchar *param_scale_aliases1[] = {
"knob-lin", "knob-log",
NULL,
};
-
static GxkParamEditor param_scale3 = {
{ "dial-lin", N_("Dial"), },
{ G_TYPE_NONE, NULL, TRUE, TRUE, }, /* all int types and all float types */
diff --git a/beast-gtk/bstparam-searchpath.cc b/beast-gtk/bstparam-searchpath.cc
index 27ec2d2..7277ade 100644
--- a/beast-gtk/bstparam-searchpath.cc
+++ b/beast-gtk/bstparam-searchpath.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
/* --- searchpath editor --- */
#include "bstauxdialogs.hh"
#include "bstfiledialog.hh"
@@ -15,7 +13,6 @@ param_searchpath_change_value (GtkWidget *entry)
gxk_param_apply_value (param);
}
}
-
static void
param_searchpath_assign (GtkWidget *dialog,
gchar **strings,
@@ -27,7 +24,6 @@ param_searchpath_assign (GtkWidget *dialog,
g_free (paths);
param_searchpath_change_value (widget);
}
-
static void
param_searchpath_popup_remove (GtkWidget *widget)
{
@@ -46,7 +42,6 @@ param_searchpath_popup_remove (GtkWidget *widget)
gxk_widget_showraise (dialog);
}
}
-
static void
param_searchpath_add (GtkWidget *dialog,
const gchar *file,
@@ -59,7 +54,6 @@ param_searchpath_add (GtkWidget *dialog,
g_free (str);
param_searchpath_change_value (widget);
}
-
static void
param_searchpath_popup_add (GtkWidget *widget)
{
@@ -70,7 +64,6 @@ param_searchpath_popup_add (GtkWidget *widget)
bst_file_dialog_set_handler (BST_FILE_DIALOG (dialog), param_searchpath_add, widget, NULL);
}
}
-
static void
param_searchpath_replace (GtkWidget *dialog,
const gchar *file,
@@ -80,7 +73,6 @@ param_searchpath_replace (GtkWidget *dialog,
gtk_entry_set_text (GTK_ENTRY (widget), file);
param_searchpath_change_value (widget);
}
-
static void
param_searchpath_popup_replace (GtkWidget *widget)
{
@@ -91,7 +83,6 @@ param_searchpath_popup_replace (GtkWidget *widget)
bst_file_dialog_set_handler (BST_FILE_DIALOG (dialog), param_searchpath_replace, widget, NULL);
}
}
-
static GtkWidget*
param_searchpath_create (GxkParam *param,
const gchar *tooltip,
@@ -127,7 +118,6 @@ param_searchpath_create (GxkParam *param,
gxk_widget_add_option (box, "hexpand", "+");
return box;
}
-
static GxkParamEditor param_searchpath = {
{ "searchpath", N_("Searchpath Text Entry"), },
{ G_TYPE_STRING, },
diff --git a/beast-gtk/bstparam-time.cc b/beast-gtk/bstparam-time.cc
index 81f6b60..bf87bca 100644
--- a/beast-gtk/bstparam-time.cc
+++ b/beast-gtk/bstparam-time.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- time parameter editor --- */
static void
param_time_changed (GtkWidget *entry,
@@ -9,7 +8,6 @@ param_time_changed (GtkWidget *entry,
sfi_value_set_time (¶m->value, sfi_time_from_string (string));
gxk_param_apply_value (param);
}
-
static GtkWidget*
param_time_create (GxkParam *param,
const gchar *tooltip,
@@ -25,7 +23,6 @@ param_time_create (GxkParam *param,
gxk_widget_set_tooltip (widget, tooltip);
return widget;
}
-
static void
param_time_update (GxkParam *param,
GtkWidget *widget)
@@ -34,7 +31,6 @@ param_time_update (GxkParam *param,
gxk_param_entry_set_text (param, widget, string);
g_free (string);
}
-
static GxkParamEditor param_time = {
{ "time", N_("Time Entry"), },
{ G_TYPE_INT64, },
diff --git a/beast-gtk/bstparam.cc b/beast-gtk/bstparam.cc
index c536ebf..2b3c069 100644
--- a/beast-gtk/bstparam.cc
+++ b/beast-gtk/bstparam.cc
@@ -1,19 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstparam.hh"
#include "bstxframe.hh"
-
-
/* --- prototypes --- */
static gboolean bst_param_xframe_check_button (GxkParam *param,
guint button);
-
-
/* --- variable --- */
static GQuark quark_null_group = 0;
static GQuark quark_param_choice_values = 0;
static guint param_size_group = 0;
-
-
/* --- gmask parameters --- */
static GtkWidget*
param_get_gmask_container (GtkWidget *parent,
@@ -47,7 +41,6 @@ param_get_gmask_container (GtkWidget *parent,
}
return container;
}
-
static const GxkParamEditorSizes param_editor_homogeneous_sizes = {
FALSE, /* may_resize */
FALSE, /* request_fractions */
@@ -63,7 +56,6 @@ static const GxkParamEditorSizes param_editor_homogeneous_sizes = {
2, 8, /* double */
9, 3, /* string */
};
-
static BstGMask*
bst_param_create_gmask_intern (GxkParam *param,
const gchar *editor_name,
@@ -77,21 +69,16 @@ bst_param_create_gmask_intern (GxkParam *param,
BstGMask *gmask;
gboolean expand_action;
gchar *tooltip;
-
g_return_val_if_fail (GXK_IS_PARAM (param), NULL);
g_return_val_if_fail (GTK_IS_CONTAINER (parent), NULL);
-
gxk_param_set_sizes (param_size_group, BST_GCONFIG (size_group_input_fields) ? ¶m_editor_homogeneous_sizes : NULL);
group = sfi_pspec_get_group (param->pspec);
parent = param_get_gmask_container (parent, group ? g_quark_from_string (group) : 0);
-
action = gxk_param_create_editor (param, editor_name);
-
xframe = (GtkWidget*) g_object_new (BST_TYPE_XFRAME, "cover", action, NULL);
g_object_connect (xframe,
"swapped_signal::button_check", bst_param_xframe_check_button, param,
NULL);
-
if (GTK_IS_TOGGLE_BUTTON (action))
{
/* if there's a prompt widget inside the button already, sneak in xframe */
@@ -111,7 +98,6 @@ bst_param_create_gmask_intern (GxkParam *param,
NULL);
gxk_param_add_object (param, GTK_OBJECT (prompt));
}
-
expand_action = !prompt || gxk_widget_check_option (action, "hexpand");
gmask = bst_gmask_form (parent, action, multi_span ? BST_GMASK_MULTI_SPAN : expand_action ? BST_GMASK_BIG : BST_GMASK_INTERLEAVE);
bst_gmask_set_column (gmask, column);
@@ -145,7 +131,6 @@ bst_param_create_gmask_intern (GxkParam *param,
g_message ("failed to create scale/dial widget for parameter \"%s\" of type `%s'",
param->pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (param->pspec)));
}
-
tooltip = gxk_param_dup_tooltip (param);
bst_gmask_set_tip (gmask, tooltip);
g_free (tooltip);
@@ -153,7 +138,6 @@ bst_param_create_gmask_intern (GxkParam *param,
gxk_param_update (param);
return gmask;
}
-
BstGMask*
bst_param_create_gmask (GxkParam *param,
const gchar *editor_name,
@@ -161,7 +145,6 @@ bst_param_create_gmask (GxkParam *param,
{
return bst_param_create_gmask_intern (param, editor_name, parent, 0, FALSE);
}
-
BstGMask*
bst_param_create_col_gmask (GxkParam *param,
const gchar *editor_name,
@@ -170,7 +153,6 @@ bst_param_create_col_gmask (GxkParam *param,
{
return bst_param_create_gmask_intern (param, editor_name, parent, column, FALSE);
}
-
BstGMask*
bst_param_create_span_gmask (GxkParam *param,
const gchar *editor_name,
@@ -179,7 +161,6 @@ bst_param_create_span_gmask (GxkParam *param,
{
return bst_param_create_gmask_intern (param, editor_name, parent, column, TRUE);
}
-
/* --- value binding --- */
GxkParam*
bst_param_new_value (GParamSpec *pspec,
@@ -191,7 +172,6 @@ bst_param_new_value (GParamSpec *pspec,
gxk_param_set_size_group (param, param_size_group);
return param;
}
-
/* --- GObject binding --- */
GxkParam*
bst_param_new_object (GParamSpec *pspec,
@@ -202,7 +182,6 @@ bst_param_new_object (GParamSpec *pspec,
gxk_param_set_size_group (param, param_size_group);
return param;
}
-
/* --- proxy binding --- */
static void
proxy_binding_set_value (GxkParam *param,
@@ -212,7 +191,6 @@ proxy_binding_set_value (GxkParam *param,
if (proxy)
sfi_glue_proxy_set_property (proxy, param->pspec->name, value);
}
-
static void
proxy_binding_get_value (GxkParam *param,
GValue *value)
@@ -229,7 +207,6 @@ proxy_binding_get_value (GxkParam *param,
else
g_value_reset (value);
}
-
static void
proxy_binding_weakref (gpointer data,
SfiProxy junk)
@@ -238,7 +215,6 @@ proxy_binding_weakref (gpointer data,
param->bdata[0].v_long = 0;
param->bdata[1].v_long = 0; /* already disconnected */
}
-
static void
proxy_binding_destroy (GxkParam *param)
{
@@ -251,7 +227,6 @@ proxy_binding_destroy (GxkParam *param)
param->bdata[1].v_long = 0;
}
}
-
static void
proxy_binding_start_grouping (GxkParam *param)
{
@@ -261,7 +236,6 @@ proxy_binding_start_grouping (GxkParam *param)
bse_item_group_undo (proxy, ustr);
g_free (ustr);
}
-
static void
proxy_binding_stop_grouping (GxkParam *param)
{
@@ -269,7 +243,6 @@ proxy_binding_stop_grouping (GxkParam *param)
if (proxy)
bse_item_ungroup_undo (proxy);
}
-
static gboolean
proxy_binding_check_writable (GxkParam *param)
{
@@ -279,7 +252,6 @@ proxy_binding_check_writable (GxkParam *param)
else
return FALSE;
}
-
static GxkParamBinding proxy_binding = {
2, // n_data_fields
NULL, // setup
@@ -290,7 +262,6 @@ static GxkParamBinding proxy_binding = {
proxy_binding_start_grouping,
proxy_binding_stop_grouping,
};
-
GxkParam*
bst_param_new_proxy (GParamSpec *pspec,
SfiProxy proxy)
@@ -300,14 +271,12 @@ bst_param_new_proxy (GParamSpec *pspec,
gxk_param_set_size_group (param, param_size_group);
return param;
}
-
void
bst_param_set_proxy (GxkParam *param,
SfiProxy proxy)
{
g_return_if_fail (GXK_IS_PARAM (param));
g_return_if_fail (param->binding == &proxy_binding);
-
proxy_binding_destroy (param);
param->bdata[0].v_long = proxy;
if (proxy)
@@ -318,18 +287,14 @@ bst_param_set_proxy (GxkParam *param,
sfi_glue_proxy_weak_ref (proxy, proxy_binding_weakref, param);
}
}
-
SfiProxy
bst_param_get_proxy (GxkParam *param)
{
g_return_val_if_fail (GXK_IS_PARAM (param), 0);
-
if (param->binding == &proxy_binding)
return param->bdata[0].v_long;
return 0;
}
-
-
/* --- record binding --- */
static void
record_binding_set_value (GxkParam *param,
@@ -337,7 +302,6 @@ record_binding_set_value (GxkParam *param,
{
sfi_rec_set ((SfiRec*) param->bdata[0].v_pointer, param->pspec->name, value);
}
-
static void
record_binding_get_value (GxkParam *param,
GValue *value)
@@ -348,14 +312,12 @@ record_binding_get_value (GxkParam *param,
else
g_value_reset (value);
}
-
static void
record_binding_destroy (GxkParam *param)
{
sfi_rec_unref ((SfiRec*) param->bdata[0].v_pointer);
param->bdata[0].v_pointer = NULL;
}
-
static GxkParamBinding record_binding = {
1, NULL,
record_binding_set_value,
@@ -363,7 +325,6 @@ static GxkParamBinding record_binding = {
record_binding_destroy,
NULL, /* check_writable */
};
-
GxkParam*
bst_param_new_rec (GParamSpec *pspec,
SfiRec *rec)
@@ -374,8 +335,6 @@ bst_param_new_rec (GParamSpec *pspec,
gxk_param_set_size_group (param, param_size_group);
return param;
}
-
-
/* --- param implementation utils --- */
static gboolean
bst_param_xframe_check_button (GxkParam *param,
@@ -404,8 +363,6 @@ bst_param_xframe_check_button (GxkParam *param,
#endif
return FALSE;
}
-
-
/* --- param editor registration --- */
#include "bstparam-choice.cc"
#include "bstparam-color-spinner.cc"
@@ -421,7 +378,6 @@ void
_bst_init_params (void)
{
g_assert (quark_null_group == 0);
-
quark_null_group = g_quark_from_static_string ("bst-param-null-group");
quark_param_choice_values = g_quark_from_static_string ("bst-param-choice-values");
param_size_group = gxk_param_create_size_group ();
diff --git a/beast-gtk/bstparam.hh b/beast-gtk/bstparam.hh
index e2ecd6b..dd6532d 100644
--- a/beast-gtk/bstparam.hh
+++ b/beast-gtk/bstparam.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PARAM_H__
#define __BST_PARAM_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- parameters gmasks --- */
BstGMask* bst_param_create_gmask (GxkParam *param,
const gchar *editor_name,
@@ -18,18 +15,13 @@ BstGMask* bst_param_create_span_gmask (GxkParam *param,
const gchar *editor_name,
GtkWidget *parent,
guint column);
-
-
/* --- SfiValue parameters --- */
GxkParam* bst_param_new_value (GParamSpec *pspec, /* gxk_param_new_value() */
GxkParamValueNotify notify,
gpointer notify_data);
-
/* --- SfiRec parameters --- */
GxkParam* bst_param_new_rec (GParamSpec *pspec,
SfiRec *rec);
-
-
/* --- GObject parameters --- */
GxkParam* bst_param_new_object (GParamSpec *pspec, /* gxk_param_new_object() */
GObject *object);
@@ -41,15 +33,8 @@ void bst_param_set_proxy (GxkParam *param,
SfiProxy bst_param_get_proxy (GxkParam *param);
SfiProxy bst_item_seq_list_match (GSList *proxy_seq_slist, /* bstparam-proxy.cc */
const gchar *text);
-
-
/* --- param implementation utils --- */
void _bst_init_params (void);
-
-
-
G_END_DECLS
-
#endif /* __BST_PARAM_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/beast-gtk/bstparamview.cc b/beast-gtk/bstparamview.cc
index 88d541b..207de3e 100644
--- a/beast-gtk/bstparamview.cc
+++ b/beast-gtk/bstparamview.cc
@@ -1,47 +1,33 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstparamview.hh"
-
#include "bstparam.hh"
-
-
/* --- prototypes --- */
static void bst_param_view_destroy (GtkObject *object);
static void bst_param_view_finalize (GObject *object);
-
-
/* --- static variables --- */
static BstParamViewClass *bst_param_view_class = NULL;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstParamView, bst_param_view, GTK_TYPE_VBOX);
-
static void
bst_param_view_class_init (BstParamViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
bst_param_view_class = klass;
-
gobject_class->finalize = bst_param_view_finalize;
-
object_class->destroy = bst_param_view_destroy;
}
-
static void
bst_param_view_init (BstParamView *self)
{
self->item = 0;
self->params = NULL;
-
self->first_base_type = g_strdup ("BseObject");
self->last_base_type = NULL;
self->reject_pattern = NULL;
self->match_pattern = NULL;
gtk_widget_show (GTK_WIDGET (self));
}
-
static void
bst_param_view_destroy_contents (BstParamView *self)
{
@@ -49,29 +35,21 @@ bst_param_view_destroy_contents (BstParamView *self)
while (self->params)
gxk_param_destroy ((GxkParam*) g_slist_pop_head (&self->params));
}
-
static void
bst_param_view_destroy (GtkObject *object)
{
BstParamView *self = BST_PARAM_VIEW (object);
-
bst_param_view_destroy_contents (self);
-
bst_param_view_set_item (self, 0);
-
GTK_OBJECT_CLASS (bst_param_view_parent_class)->destroy (object);
}
-
static void
bst_param_view_finalize (GObject *object)
{
BstParamView *self = BST_PARAM_VIEW (object);
-
bst_param_view_set_item (self, 0);
-
g_free (self->first_base_type);
g_free (self->last_base_type);
-
if (self->reject_pattern)
{
g_pattern_spec_free (self->reject_pattern);
@@ -82,64 +60,49 @@ bst_param_view_finalize (GObject *object)
g_pattern_spec_free (self->match_pattern);
self->match_pattern = NULL;
}
-
G_OBJECT_CLASS (bst_param_view_parent_class)->finalize (object);
}
-
GtkWidget*
bst_param_view_new (SfiProxy item)
{
GtkWidget *self = gtk_widget_new (BST_TYPE_PARAM_VIEW, NULL);
-
if (item)
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
-
if (item)
bst_param_view_set_item (BST_PARAM_VIEW (self), item);
-
return self;
}
-
static void
param_view_reset_item (BstParamView *self)
{
bst_param_view_set_item (self, 0);
}
-
void
bst_param_view_set_item (BstParamView *self,
SfiProxy item)
{
GSList *slist;
-
g_return_if_fail (BST_IS_PARAM_VIEW (self));
if (item)
g_return_if_fail (BSE_IS_ITEM (item));
-
if (item == self->item)
return;
-
if (self->item)
{
bse_proxy_disconnect (self->item,
"any_signal", param_view_reset_item, self,
NULL);
self->item = 0;
-
for (slist = self->params; slist; slist = slist->next)
bst_param_set_proxy ((GxkParam*) slist->data, 0);
}
-
self->item = item;
-
if (self->item)
bse_proxy_connect (self->item,
"swapped_signal::release", param_view_reset_item, self,
NULL);
-
bst_param_view_rebuild (self);
}
-
void
bst_param_view_set_mask (BstParamView *param_view,
const gchar *first_base_type,
@@ -148,26 +111,21 @@ bst_param_view_set_mask (BstParamView *param_view,
const gchar *match_pattern)
{
g_return_if_fail (BST_IS_PARAM_VIEW (param_view));
-
if (param_view->reject_pattern)
g_pattern_spec_free (param_view->reject_pattern);
param_view->reject_pattern = reject_pattern ? g_pattern_spec_new (reject_pattern) : NULL;
-
if (param_view->match_pattern)
g_pattern_spec_free (param_view->match_pattern);
param_view->match_pattern = match_pattern ? g_pattern_spec_new (match_pattern) : NULL;
-
g_free (param_view->first_base_type);
param_view->first_base_type = g_strdup (first_base_type);
g_free (param_view->last_base_type);
param_view->last_base_type = g_strdup (last_base_type);
}
-
void
bst_param_view_apply_defaults (BstParamView *self)
{
g_return_if_fail (BST_IS_PARAM_VIEW (self));
-
if (self->item)
{
GSList *slist;
@@ -177,7 +135,6 @@ bst_param_view_apply_defaults (BstParamView *self)
bse_item_ungroup_undo (self->item);
}
}
-
void
bst_param_view_rebuild (BstParamView *self)
{
@@ -187,15 +144,11 @@ bst_param_view_rebuild (BstParamView *self)
GSList *slist;
gint border_width = 5;
guint i, n;
-
g_return_if_fail (BST_IS_PARAM_VIEW (self));
-
bst_param_view_destroy_contents (self);
-
pbox = GTK_BOX (self);
if (!self->item)
return;
-
/* create parameter fields */
pstrings = bse_proxy_list_properties (self->item, self->first_base_type, self->last_base_type, &n);
for (i = 0; i < n; i++)
@@ -223,7 +176,6 @@ bst_param_view_rebuild (BstParamView *self)
self->params = g_slist_prepend (self->params, param);
}
}
-
/* pack groupless parameters */
if (ncontainer)
{
@@ -234,7 +186,6 @@ bst_param_view_rebuild (BstParamView *self)
NULL);
gtk_box_pack_start (pbox, ncontainer, FALSE, TRUE, 0);
}
-
/* pack grouped parameters */
if (gcontainer)
{
@@ -251,7 +202,6 @@ bst_param_view_rebuild (BstParamView *self)
GtkWidget *scwin = gxk_scrolled_window_create (gcontainer, GTK_SHADOW_NONE, 1, 0.8);
gtk_container_add (GTK_CONTAINER (self), scwin);
}
-
/* refresh parameter fields */
for (slist = self->params; slist; slist = slist->next)
gxk_param_update ((GxkParam*) slist->data);
diff --git a/beast-gtk/bstparamview.hh b/beast-gtk/bstparamview.hh
index 5edb184..472c9f4 100644
--- a/beast-gtk/bstparamview.hh
+++ b/beast-gtk/bstparamview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PARAM_VIEW_H__
#define __BST_PARAM_VIEW_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_PARAM_VIEW (bst_param_view_get_type ())
#define BST_PARAM_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PARAM_VIEW, BstParamView))
@@ -13,19 +10,14 @@ G_BEGIN_DECLS
#define BST_IS_PARAM_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PARAM_VIEW))
#define BST_IS_PARAM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PARAM_VIEW))
#define BST_PARAM_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PARAM_VIEW, BstParamViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstParamView BstParamView;
typedef struct _BstParamViewClass BstParamViewClass;
struct _BstParamView
{
GtkVBox parent_object;
-
SfiProxy item;
-
GSList *params; /* GxkParam* */
-
gchar *first_base_type;
gchar *last_base_type;
GPatternSpec *reject_pattern;
@@ -35,8 +27,6 @@ struct _BstParamViewClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_param_view_get_type (void);
GtkWidget* bst_param_view_new (SfiProxy item);
@@ -49,9 +39,5 @@ void bst_param_view_set_mask (BstParamView *param_view,
const gchar *last_base_type,
const gchar *reject_pattern,
const gchar *match_pattern);
-
-
-
G_END_DECLS
-
#endif /* __BST_PARAM_VIEW_H__ */
diff --git a/beast-gtk/bstpartdialog.cc b/beast-gtk/bstpartdialog.cc
index f221896..e1a2e86 100644
--- a/beast-gtk/bstpartdialog.cc
+++ b/beast-gtk/bstpartdialog.cc
@@ -4,10 +4,7 @@
#include "bstmenus.hh"
#include "bstparam.hh"
#include "bstgrowbar.hh"
-
#define SCROLLBAR_SPACING (3) /* from gtkscrolledwindow.c:DEFAULT_SCROLLBAR_SPACING */
-
-
/* --- prototypes --- */
static void bst_part_dialog_finalize (GObject *object);
static void piano_canvas_clicked (BstPianoRoll *proll,
@@ -29,8 +26,6 @@ static void part_dialog_action_exec (gpointer data,
gulong action);
static void part_dialog_run_script_proc (gpointer data,
gulong category_id);
-
-
/* --- track actions --- */
enum {
ACTION_NONE = BST_COMMON_ROLL_TOOL_LAST,
@@ -56,19 +51,14 @@ static const GxkStockAction piano_clear_undo[] = {
{ N_("_Clear Undo"), NULL, NULL,
ACTION_CLEAR_UNDO, BST_STOCK_CLEAR_UNDO, },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstPartDialog, bst_part_dialog, GXK_TYPE_DIALOG);
-
static void
bst_part_dialog_class_init (BstPartDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_part_dialog_finalize;
}
-
static void
hzoom_changed (BstPartDialog *self,
GtkAdjustment *adjustment)
@@ -78,7 +68,6 @@ hzoom_changed (BstPartDialog *self,
if (self->eroll)
bst_event_roll_set_hzoom (self->eroll, adjustment->value * 0.08);
}
-
static void
vzoom_changed (BstPartDialog *self,
GtkAdjustment *adjustment)
@@ -86,7 +75,6 @@ vzoom_changed (BstPartDialog *self,
if (self->proll)
bst_piano_roll_set_vzoom (self->proll, adjustment->value);
}
-
static void
eparam_changed (gpointer data,
GxkParam *param)
@@ -99,7 +87,6 @@ eparam_changed (gpointer data,
gxk_widget_update_actions (self); /* update controllers */
}
}
-
static void
bst_part_dialog_init (BstPartDialog *self)
{
@@ -110,18 +97,15 @@ bst_part_dialog_init (BstPartDialog *self)
GtkAdjustment *adj;
GParamSpec *pspec;
GxkRadget *radget;
-
/* configure self */
g_object_set (self,
"name", "BEAST-PartDialog",
"flags", GXK_DIALOG_STATUS_BAR,
NULL);
gxk_dialog_set_sizes (GXK_DIALOG (self), 640, 400, 1005, 650);
-
/* radget-complete GUI */
radget = gxk_radget_create ("beast", "piano-roll-box", NULL);
gtk_container_add (GTK_CONTAINER (GXK_DIALOG (self)->vbox), (GtkWidget*) radget);
-
/* publish actions */
gxk_widget_publish_actions (self, "piano-edit-actions",
G_N_ELEMENTS (piano_edit_actions), piano_edit_actions,
@@ -132,15 +116,12 @@ bst_part_dialog_init (BstPartDialog *self)
if (BST_DVL_HINTS)
gxk_widget_publish_actions (self, "piano-clear-undo", G_N_ELEMENTS (piano_clear_undo), piano_clear_undo,
NULL, part_dialog_action_check, part_dialog_action_exec);
-
/* publish /Part/ scripts */
cseq = bse_categories_match ("/Part/*");
al1 = bst_action_list_from_cats (cseq, 1, BST_STOCK_EXECUTE, NULL, part_dialog_run_script_proc, self);
gxk_action_list_sort (al1);
gxk_widget_publish_action_list (self, "part-scripts", al1);
-
BstGrowBar *grow_bar = (BstGrowBar*) gxk_radget_find (radget, "piano-roll-hgrow-bar");
-
/* piano roll */
self->proll = (BstPianoRoll*) gxk_radget_find (radget, "piano-roll");
gxk_nullify_in_object (self, &self->proll);
@@ -154,7 +135,6 @@ bst_part_dialog_init (BstPartDialog *self)
gxk_widget_publish_action_list (self, "pctrl-canvas-tools", bst_piano_roll_controller_canvas_actions (self->pctrl));
gxk_widget_publish_action_list (self, "pctrl-note-tools", bst_piano_roll_controller_note_actions (self->pctrl));
gxk_widget_publish_action_list (self, "pctrl-quant-tools", bst_piano_roll_controller_quant_actions (self->pctrl));
-
/* event roll */
self->eroll = (BstEventRoll*) gxk_radget_find (radget, "event-roll");
gxk_nullify_in_object (self, &self->eroll);
@@ -164,9 +144,7 @@ bst_part_dialog_init (BstPartDialog *self)
gxk_scroll_canvas_set_hadjustment (GXK_SCROLL_CANVAS (self->eroll), adj);
bst_event_roll_set_vpanel_width_hook (self->eroll, (int (*) (void*)) bst_piano_roll_get_vpanel_width, self->proll);
gxk_widget_publish_action_list (self, "ectrl-select-actions", bst_event_roll_controller_select_actions (self->ectrl));
-
grow_bar = (BstGrowBar*) gxk_radget_find (radget, "pattern-view-vgrow-bar");
-
/* pattern view */
self->pview = (BstPatternView*) gxk_radget_find (radget, "pattern-view");
gxk_nullify_in_object (self, &self->pview);
@@ -175,7 +153,6 @@ bst_part_dialog_init (BstPartDialog *self)
adj = bst_grow_bar_get_adjustment (grow_bar);
gxk_scroll_canvas_set_vadjustment (GXK_SCROLL_CANVAS (self->pview), adj);
self->pvctrl = bst_pattern_controller_new (self->pview, self->pctrl->quant_rtools);
-
/* pattern view controls */
g_signal_connect_swapped (gxk_radget_find (radget, "configure-button"), "clicked",
G_CALLBACK (bst_pattern_column_layouter_popup), self->pview);
@@ -196,10 +173,8 @@ bst_part_dialog_init (BstPartDialog *self)
gxk_radget_add (radget, "pattern-control-box", gxk_vseparator_space_new (TRUE));
gxk_radget_add (radget, "pattern-control-box", gxk_param_create_editor (self->pvctrl->row_shading, "name"));
gxk_radget_add (radget, "pattern-control-box", gxk_param_create_editor (self->pvctrl->row_shading, "combo-button"));
-
/* event roll children */
g_object_new (GTK_TYPE_LABEL, "visible", TRUE, "label", "C", "parent", self->eroll, NULL);
-
/* event roll control type */
pspec = bst_procedure_ref_pspec ("BsePart+change-control", "control-type");
if (pspec)
@@ -212,7 +187,6 @@ bst_part_dialog_init (BstPartDialog *self)
sfi_value_set_choice (¶m->value, bse_midi_signal_type_to_choice (BSE_MIDI_SIGNAL_VELOCITY));
gxk_param_apply_value (param); /* update model, auto updates GUI */
}
-
/* hzoom */
adjustment = gtk_adjustment_new (13, 0, 100, 1, 5, 0);
g_object_connect (adjustment,
@@ -242,30 +216,23 @@ bst_part_dialog_init (BstPartDialog *self)
"width_request", 2 * gxk_size_width (GXK_ICON_SIZE_TOOLBAR),
NULL));
}
-
static void
bst_part_dialog_finalize (GObject *object)
{
BstPartDialog *self = BST_PART_DIALOG (object);
-
bst_part_dialog_set_proxy (self, 0);
-
bst_piano_roll_controller_unref (self->pctrl);
bst_event_roll_controller_unref (self->ectrl);
-
G_OBJECT_CLASS (bst_part_dialog_parent_class)->finalize (object);
}
-
void
bst_part_dialog_set_proxy (BstPartDialog *self,
SfiProxy part)
{
SfiProxy project;
-
g_return_if_fail (BST_IS_PART_DIALOG (self));
if (part)
g_return_if_fail (BSE_IS_PART (part));
-
if (self->project)
{
bse_proxy_disconnect (self->project,
@@ -273,9 +240,7 @@ bst_part_dialog_set_proxy (BstPartDialog *self,
NULL);
self->project = 0;
}
-
project = part ? bse_item_get_project (part) : 0;
-
if (project)
{
bst_window_sync_title_to_proxy (GXK_DIALOG (self), part, "%s");
@@ -290,10 +255,8 @@ bst_part_dialog_set_proxy (BstPartDialog *self,
"swapped_signal::property-notify::dirty", gxk_widget_update_actions_downwards, self,
NULL);
}
-
gxk_widget_update_actions_downwards (self);
}
-
static void
piano_canvas_clicked (BstPianoRoll *proll,
guint button,
@@ -307,7 +270,6 @@ piano_canvas_clicked (BstPianoRoll *proll,
event->button.x_root, event->button.y_root,
event->button.button, event->button.time);
}
-
static void
event_canvas_clicked (BstEventRoll *eroll,
guint button,
@@ -321,7 +283,6 @@ event_canvas_clicked (BstEventRoll *eroll,
event->button.x_root, event->button.y_root,
event->button.button, event->button.time);
}
-
static void
part_dialog_run_script_proc (gpointer data,
gulong category_id)
@@ -329,13 +290,11 @@ part_dialog_run_script_proc (gpointer data,
BstPartDialog *self = BST_PART_DIALOG (data);
BseCategory *cat = bse_category_from_id (category_id);
SfiProxy part = self->proll->proxy;
-
bst_procedure_exec_auto (cat->type,
"project", SFI_TYPE_PROXY, bse_item_get_project (part),
"part", SFI_TYPE_PROXY, part,
NULL);
}
-
static gboolean
part_dialog_action_check (gpointer data,
gulong action,
@@ -375,15 +334,12 @@ part_dialog_action_check (gpointer data,
return FALSE;
}
}
-
static void
part_dialog_action_exec (gpointer data,
gulong action)
{
BstPartDialog *self = BST_PART_DIALOG (data);
-
gxk_status_window_push (self);
-
switch (action)
{
case ACTION_CLEAR:
@@ -414,8 +370,6 @@ part_dialog_action_exec (gpointer data,
default:
break;
}
-
gxk_status_window_pop ();
-
gxk_widget_update_actions_downwards (self);
}
diff --git a/beast-gtk/bstpartdialog.hh b/beast-gtk/bstpartdialog.hh
index e3c62fd..d2685bf 100644
--- a/beast-gtk/bstpartdialog.hh
+++ b/beast-gtk/bstpartdialog.hh
@@ -1,16 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PART_DIALOG_H__
#define __BST_PART_DIALOG_H__
-
#include "bstpianoroll.hh"
#include "bsteventroll.hh"
#include "bstpatternview.hh"
#include "bstpatternctrl.hh"
#include "bstpianorollctrl.hh"
#include "bsteventrollctrl.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_PART_DIALOG (bst_part_dialog_get_type ())
#define BST_PART_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PART_DIALOG, BstPartDialog))
@@ -18,15 +15,12 @@ G_BEGIN_DECLS
#define BST_IS_PART_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PART_DIALOG))
#define BST_IS_PART_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PART_DIALOG))
#define BST_PART_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PART_DIALOG, BstPartDialogClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstPartDialog BstPartDialog;
typedef struct _BstPartDialogClass BstPartDialogClass;
struct _BstPartDialog
{
GxkDialog parent_object;
-
BstPianoRoll *proll;
BstPianoRollController *pctrl;
BstEventRoll *eroll;
@@ -39,13 +33,9 @@ struct _BstPartDialogClass
{
GxkDialogClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_part_dialog_get_type (void);
void bst_part_dialog_set_proxy (BstPartDialog *self,
SfiProxy part);
-
G_END_DECLS
-
#endif /* __BST_PART_DIALOG_H__ */
diff --git a/beast-gtk/bstpartview.cc b/beast-gtk/bstpartview.cc
index c47bfb0..f2bf83c 100644
--- a/beast-gtk/bstpartview.cc
+++ b/beast-gtk/bstpartview.cc
@@ -1,19 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstpartview.hh"
-
#include "bstpartdialog.hh"
#include "bstpianoroll.hh"
-
-
-
/* --- prototypes --- */
static void part_view_action_exec (gpointer data,
gulong action);
static gboolean part_view_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
/* --- part actions --- */
enum {
ACTION_ADD_PART,
@@ -25,19 +19,14 @@ static const GxkStockAction part_view_actions[] = {
{ N_("Delete"), NULL, NULL, ACTION_DELETE_PART, BST_STOCK_TRASHCAN },
{ N_("Editor"), NULL, NULL, ACTION_EDIT_PART, BST_STOCK_PART_EDITOR },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstPartView, bst_part_view, BST_TYPE_ITEM_VIEW);
-
static void
bst_part_view_class_init (BstPartViewClass *klass)
{
BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (klass);
-
item_view_class->item_type = "BsePart";
}
-
static void
bst_part_view_init (BstPartView *self)
{
@@ -54,34 +43,26 @@ bst_part_view_init (BstPartView *self)
/* create property editor */
bst_item_view_build_param_view (iview, (GtkContainer*) gxk_radget_find (radget, "property-area"));
}
-
static void
popup_part_dialog (BstPartView *part_view)
{
SfiProxy part;
GtkWidget *pdialog;
-
part = bst_item_view_get_current (BST_ITEM_VIEW (part_view));
pdialog = (GtkWidget*) g_object_new (BST_TYPE_PART_DIALOG, NULL);
-
bst_part_dialog_set_proxy (BST_PART_DIALOG (pdialog), part);
g_signal_connect_object (part_view, "destroy", G_CALLBACK (gtk_widget_destroy), pdialog, G_CONNECT_SWAPPED);
gtk_widget_show (pdialog);
}
-
GtkWidget*
bst_part_view_new (SfiProxy song)
{
GtkWidget *part_view;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
part_view = gtk_widget_new (BST_TYPE_PART_VIEW, NULL);
bst_item_view_set_container (BST_ITEM_VIEW (part_view), song);
-
return part_view;
}
-
static void
part_view_action_exec (gpointer data,
gulong action)
@@ -106,7 +87,6 @@ part_view_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
part_view_action_check (gpointer data,
gulong action,
diff --git a/beast-gtk/bstpartview.hh b/beast-gtk/bstpartview.hh
index f198af0..2eb1f00 100644
--- a/beast-gtk/bstpartview.hh
+++ b/beast-gtk/bstpartview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PART_VIEW_H__
#define __BST_PART_VIEW_H__
-
#include "bstitemview.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_PART_VIEW (bst_part_view_get_type ())
#define BST_PART_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PART_VIEW, BstPartView))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_PART_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PART_VIEW))
#define BST_IS_PART_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PART_VIEW))
#define BST_PART_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PART_VIEW, BstPartViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstPartView BstPartView;
typedef struct _BstPartViewClass BstPartViewClass;
@@ -26,12 +21,8 @@ struct _BstPartViewClass
{
BstItemViewClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_part_view_get_type (void);
GtkWidget* bst_part_view_new (SfiProxy song);
-
G_END_DECLS
-
#endif /* __BST_PART_VIEW_H__ */
diff --git a/beast-gtk/bstpatterncolumns.cc b/beast-gtk/bstpatterncolumns.cc
index 4df54be..7a45da7 100644
--- a/beast-gtk/bstpatterncolumns.cc
+++ b/beast-gtk/bstpatterncolumns.cc
@@ -3,8 +3,6 @@
#include "bstpatternview.hh"
#include <string.h>
#include <math.h>
-
-
/* --- defines --- */
/* checks */
#define ISSPACE(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
@@ -20,8 +18,6 @@
#define FOCUS_WIDTH(self) (bst_pattern_view_get_focus_width (self))
#define X_OFFSET(self) (GXK_SCROLL_CANVAS (self)->x_offset)
#define Y_OFFSET(self) (GXK_SCROLL_CANVAS (self)->y_offset)
-
-
/* --- functions --- */
static void
playout_calc_char_extents (PangoLayout *pango_layout,
@@ -54,15 +50,12 @@ playout_calc_char_extents (PangoLayout *pango_layout,
*char_offset = 0;
}
}
-
-
/* --- note cell --- */
typedef struct {
BstPatternColumn column;
gint co0, co1, co2, co3; /* char offsets */
gint cw0, cw1, cw2, cw3; /* char widths */
} BstPatternColumnNote;
-
static PangoFontDescription*
pattern_column_note_create_font_desc (BstPatternColumn *self)
{
@@ -71,7 +64,6 @@ pattern_column_note_create_font_desc (BstPatternColumn *self)
pango_font_description_set_weight (fdesc, PANGO_WEIGHT_BOLD);
return fdesc;
}
-
static guint
pattern_column_note_width_request (BstPatternColumn *column,
BstPatternView *pview,
@@ -92,7 +84,6 @@ pattern_column_note_width_request (BstPatternColumn *column,
width = self->cw0 + self->cw1 + self->cw2 + self->cw3;
return FOCUS_WIDTH (pview) + width + XTHICKNESS (pview) + FOCUS_WIDTH (pview);
}
-
static char
pattern_column_note_char (BstPatternColumnNote *self,
BsePartNoteSeq *pseq,
@@ -115,7 +106,6 @@ pattern_column_note_char (BstPatternColumnNote *self,
default: return '-'; /* not reached */
}
}
-
static void
pattern_column_note_draw_cell (BstPatternColumn *column,
BstPatternView *pview,
@@ -136,7 +126,6 @@ pattern_column_note_draw_cell (BstPatternColumn *column,
BsePartNoteSeq *pseq = proxy ? bse_part_list_notes_within (proxy, column->num, tick, duration) : NULL;
gchar ch;
gint accu, yline;
-
accu = crect->x + FOCUS_WIDTH (pview);
ch = pattern_column_note_char (self, pseq, 0);
draw_gc = ch == '-' ? inactive_gc : text_gc; /* choose gc dependant on note letter */
@@ -144,26 +133,22 @@ pattern_column_note_draw_cell (BstPatternColumn *column,
pango_layout_get_pixel_extents (pango_layout, NULL, &prect);
yline = crect->y + (crect->height - prect.height) / 2;
gdk_draw_layout (drawable, draw_gc, accu + self->co0 + (self->cw0 - prect.width) / 2, yline, pango_layout);
-
accu += self->cw0;
ch = pattern_column_note_char (self, pseq, 1);
pango_layout_set_text (pango_layout, &ch, 1);
pango_layout_get_pixel_extents (pango_layout, NULL, &prect);
gdk_draw_layout (drawable, draw_gc, accu + self->co1 + (self->cw1 - prect.width) / 2, yline, pango_layout);
-
accu += self->cw1;
ch = pattern_column_note_char (self, pseq, 2);
pango_layout_set_text (pango_layout, &ch, 1);
pango_layout_get_pixel_extents (pango_layout, NULL, &prect);
gdk_draw_layout (drawable, draw_gc, accu + self->co2 + (self->cw2 - prect.width) / 2, yline, pango_layout);
-
accu += self->cw2;
ch = pattern_column_note_char (self, pseq, 3);
pango_layout_set_text (pango_layout, &ch, 1);
pango_layout_get_pixel_extents (pango_layout, NULL, &prect);
gdk_draw_layout (drawable, draw_gc, accu + self->co3 + (self->cw3 - prect.width) / 2, yline, pango_layout);
}
-
static gboolean
pattern_column_note_key_event (BstPatternColumn *column,
BstPatternView *pview,
@@ -209,14 +194,12 @@ pattern_column_note_key_event (BstPatternColumn *column,
}
return FALSE;
}
-
static void
pattern_column_note_finalize (BstPatternColumn *column)
{
BstPatternColumnNote *self = (BstPatternColumnNote*) column;
g_free (self);
}
-
static BstPatternColumnClass pattern_column_note_class = {
1, /* n_focus_positions */
sizeof (BstPatternColumnNote),
@@ -229,15 +212,12 @@ static BstPatternColumnClass pattern_column_note_class = {
pattern_column_note_key_event,
pattern_column_note_finalize,
};
-
-
/* --- event cell --- */
typedef struct {
BstPatternColumn column;
gint co; /* character offset to translate ink-rect to logical-rect */
gint cw; /* character width */
} BstPatternColumnEvent;
-
static void
pattern_column_event_init (BstPatternColumn *column)
{
@@ -245,7 +225,6 @@ pattern_column_event_init (BstPatternColumn *column)
gint n_digits = 1 + (column->lflags & BST_PATTERN_LFLAG_DIGIT_MASK);
column->n_focus_positions = is_signed + n_digits;
}
-
static PangoFontDescription*
pattern_column_event_create_font_desc (BstPatternColumn *self)
{
@@ -254,7 +233,6 @@ pattern_column_event_create_font_desc (BstPatternColumn *self)
pango_font_description_set_weight (fdesc, PANGO_WEIGHT_BOLD);
return fdesc;
}
-
static guint
pattern_column_event_width_request (BstPatternColumn *column,
BstPatternView *pview,
@@ -269,7 +247,6 @@ pattern_column_event_width_request (BstPatternColumn *column,
width = 1 + (is_signed + n_digits) * (self->cw + 1);
return FOCUS_WIDTH (pview) + width + FOCUS_WIDTH (pview);
}
-
static guint
control_get_max (guint num_type,
guint n_digits)
@@ -279,7 +256,6 @@ control_get_max (guint num_type,
else /* if (num_type == BST_PATTERN_LFLAG_HEX) */
return pow (16, n_digits) - 1;
}
-
static guint
control_get_digit_increment (guint num_type,
guint nth_digits)
@@ -290,7 +266,6 @@ control_get_digit_increment (guint num_type,
else /* if (num_type == BST_PATTERN_LFLAG_HEX) */
return pow (16, nth_digits - 1);
}
-
static guint
pattern_column_event_to_string (BstPatternColumn *column,
gchar buffer[64],
@@ -331,7 +306,6 @@ pattern_column_event_to_string (BstPatternColumn *column,
}
return is_signed + n_digits;
}
-
static gfloat
pattern_column_event_value_from_int (BstPatternColumn *column,
gint ivalue)
@@ -347,7 +321,6 @@ pattern_column_event_value_from_int (BstPatternColumn *column,
value += value < 0 ? -0.000001 : +0.000001;
return CLAMP (value, -1, +1);
}
-
static gint
pattern_column_event_ivalue_from_string (BstPatternColumn *column,
const gchar *string)
@@ -365,7 +338,6 @@ pattern_column_event_ivalue_from_string (BstPatternColumn *column,
g_free (stripped);
return CLAMP (ival, -vmax, vmax);
}
-
static gfloat
pattern_column_event_value_from_string (BstPatternColumn *column,
const gchar *string)
@@ -373,7 +345,6 @@ pattern_column_event_value_from_string (BstPatternColumn *column,
gint ival = pattern_column_event_ivalue_from_string (column, string);
return pattern_column_event_value_from_int (column, ival);
}
-
static BseMidiSignalType
pattern_column_control_type (BstPatternColumn *column, bool *isnote_p)
{
@@ -392,7 +363,6 @@ pattern_column_control_type (BstPatternColumn *column, bool *isnote_p)
*isnote_p = isnote;
return control_type;
}
-
static BsePartControl*
pattern_column_event_lookup (BstPatternColumn *column,
BstPatternView *pview,
@@ -419,7 +389,6 @@ pattern_column_event_lookup (BstPatternColumn *column,
*cseq_p = cseq;
return pctrl;
}
-
static void
pattern_column_event_draw_cell (BstPatternColumn *column,
BstPatternView *pview,
@@ -440,7 +409,6 @@ pattern_column_event_draw_cell (BstPatternColumn *column,
int n = pattern_column_event_to_string (column, buffer, pctrl, placeholder, NULL);
GdkGC *draw_gc = placeholder == '-' ? inactive_gc : text_gc;
int yline, accu = crect->x + FOCUS_WIDTH (pview) + 1;
-
for (int i = 0; i < n; i++)
{
PangoRectangle irect, prect;
@@ -451,7 +419,6 @@ pattern_column_event_draw_cell (BstPatternColumn *column,
accu += self->cw + 1;
}
}
-
static void
pattern_column_event_get_focus_pos (BstPatternColumn *column,
BstPatternView *pview,
@@ -472,7 +439,6 @@ pattern_column_event_get_focus_pos (BstPatternColumn *column,
*pos_x = accu;
*pos_width = width;
}
-
static gboolean
pattern_column_event_key_event (BstPatternColumn *column,
BstPatternView *pview,
@@ -568,14 +534,12 @@ pattern_column_event_key_event (BstPatternColumn *column,
}
return handled;
}
-
static void
pattern_column_event_finalize (BstPatternColumn *column)
{
BstPatternColumnEvent *self = (BstPatternColumnEvent*) column;
g_free (self);
}
-
static BstPatternColumnClass pattern_column_event_class = {
1, /* n_focus_positions */
sizeof (BstPatternColumnEvent),
@@ -588,8 +552,6 @@ static BstPatternColumnClass pattern_column_event_class = {
pattern_column_event_key_event,
pattern_column_event_finalize,
};
-
-
/* --- vbar cell --- */
static guint
pattern_column_vbar_width_request (BstPatternColumn *self,
@@ -603,7 +565,6 @@ pattern_column_vbar_width_request (BstPatternColumn *self,
/* space */
return 1 + 1; // 2 * XTHICKNESS (pview) + 1;
}
-
static void
pattern_column_vbar_draw_cell (BstPatternColumn *self,
BstPatternView *pview,
@@ -631,13 +592,11 @@ pattern_column_vbar_draw_cell (BstPatternColumn *self,
if (self->num < 0)
gdk_gc_set_line_attributes (draw_gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
}
-
static void
pattern_column_vbar_finalize (BstPatternColumn *self)
{
g_free (self);
}
-
static BstPatternColumnClass pattern_column_vbar_class = {
0, /* n_focus_positions */
sizeof (BstPatternColumn),
@@ -650,8 +609,6 @@ static BstPatternColumnClass pattern_column_vbar_class = {
NULL, /* key_event */
pattern_column_vbar_finalize,
};
-
-
/* --- layout configuration --- */
static void
pattern_column_layouter_apply (GtkWidget *dialog)
@@ -666,9 +623,7 @@ pattern_column_layouter_apply (GtkWidget *dialog)
bst_gui_error_bell (dialog);
}
}
-
#define __(str) str /* leave string unstranslated */
-
void
bst_pattern_column_layouter_popup (BstPatternView *pview)
{
@@ -744,7 +699,6 @@ bst_pattern_column_layouter_popup (BstPatternView *pview)
gtk_entry_set_text (entry, bst_pattern_view_get_layout (pview));
gxk_widget_showraise (dialog);
}
-
const gchar*
bst_pattern_layout_parse_column (const gchar *string,
BstPatternLType *ltype,
@@ -838,7 +792,6 @@ bst_pattern_layout_parse_column (const gchar *string,
*flags |= BST_PATTERN_LFLAG_SIGNED | BST_PATTERN_LFLAG_HEX | BST_PATTERN_LFLAG_DIGIT_2;
return string;
}
-
BstPatternColumn*
bst_pattern_column_create (BstPatternLType ltype,
gint num,
@@ -882,7 +835,6 @@ bst_pattern_column_create (BstPatternLType ltype,
klass->init (column);
return column;
}
-
gboolean
bst_pattern_column_has_notes (BstPatternColumn *column)
{
diff --git a/beast-gtk/bstpatterncolumns.hh b/beast-gtk/bstpatterncolumns.hh
index 97a5c7d..54eb59b 100644
--- a/beast-gtk/bstpatterncolumns.hh
+++ b/beast-gtk/bstpatterncolumns.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PATTERN_COLUMNS_H__
#define __BST_PATTERN_COLUMNS_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- enums --- */
typedef enum /*< skip >*/
{
@@ -74,7 +71,6 @@ typedef enum {
BST_PATTERN_LFLAG_COL4 = 3 << 8,
BST_PATTERN_LFLAG_COL_MASK = (3 << 8),
} BstPatternLFlags;
-
/* --- typedefs & structures --- */
typedef struct _BstPatternView BstPatternView;
typedef struct _BstPatternColumn BstPatternColumn;
@@ -137,7 +133,6 @@ struct _BstPatternColumnClass
BstPatternFunction *movement);
void (*finalize) (BstPatternColumn *self);
};
-
void bst_pattern_column_layouter_popup (BstPatternView *pview);
const gchar* bst_pattern_layout_parse_column (const gchar *string,
BstPatternLType *ltype,
@@ -147,9 +142,7 @@ BstPatternColumn* bst_pattern_column_create (BstPatternLType ltype,
gint num,
BstPatternLFlags lflags);
gboolean bst_pattern_column_has_notes (BstPatternColumn *column);
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline BstPatternLFlags operator& (BstPatternLFlags s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 & (long long unsigned) s2); }
@@ -157,12 +150,10 @@ inline BstPatternLFlags& operator&= (BstPatternLFlags &s1, BstPatternLFlags s2)
inline BstPatternLFlags operator| (BstPatternLFlags s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 | (long long unsigned) s2); }
inline BstPatternLFlags& operator|= (BstPatternLFlags &s1, BstPatternLFlags s2) { s1 = s1 | s2; return s1; }
inline BstPatternLFlags operator~ (BstPatternLFlags s1) { return BstPatternLFlags (~(long long unsigned) s1); }
-
inline BstPatternFunction operator& (BstPatternFunction s1, BstPatternFunction s2) { return BstPatternFunction (s1 & (long long unsigned) s2); }
inline BstPatternFunction& operator&= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 & s2; return s1; }
inline BstPatternFunction operator| (BstPatternFunction s1, BstPatternFunction s2) { return BstPatternFunction (s1 | (long long unsigned) s2); }
inline BstPatternFunction& operator|= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 | s2; return s1; }
inline BstPatternFunction operator~ (BstPatternFunction s1) { return BstPatternFunction (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __BST_PATTERN_COLUMNS_H__ */
diff --git a/beast-gtk/bstpatternctrl.cc b/beast-gtk/bstpatternctrl.cc
index 510f86f..a098ccf 100644
--- a/beast-gtk/bstpatternctrl.cc
+++ b/beast-gtk/bstpatternctrl.cc
@@ -3,13 +3,9 @@
#include "bstkeybindings.hh"
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
-
/* --- prototypes --- */
static gboolean pattern_controller_key_press (BstPatternController *self,
GdkEventKey *event);
-
-
/* --- functions --- */
static void
pattern_controller_vraster_notify (gpointer notify_data,
@@ -53,7 +49,6 @@ pattern_controller_vraster_notify (gpointer notify_data,
bst_pattern_view_vsetup (pview, pview->tpqn, pview->tpt / pview->tpqn,
pview->max_ticks, vraster);
}
-
static void
pattern_controller_row_shading_notify (gpointer notify_data,
GxkParam *param)
@@ -90,15 +85,12 @@ pattern_controller_row_shading_notify (gpointer notify_data,
}
bst_pattern_view_set_shading (pview, r1, r2, r3, r4);
}
-
BstPatternController*
bst_pattern_controller_new (BstPatternView *pview,
GxkActionGroup *quant_rtools)
{
BstPatternController *self;
-
g_return_val_if_fail (BST_IS_PATTERN_VIEW (pview), NULL);
-
self = g_new0 (BstPatternController, 1);
self->vraster = gxk_param_new_value (sfi_pspec_choice ("vertical-raster", _("VZoom"),
_("The tick/note length per line"),
@@ -128,7 +120,6 @@ bst_pattern_controller_new (BstPatternView *pview,
pattern_controller_row_shading_notify, self);
self->pview = pview;
self->ref_count = 1;
-
self->ref_count++;
g_signal_connect_data (pview, "key-press-event",
G_CALLBACK (pattern_controller_key_press),
@@ -137,28 +128,22 @@ bst_pattern_controller_new (BstPatternView *pview,
self->quant_rtools = quant_rtools ? (GxkActionGroup*) g_object_ref (quant_rtools) : NULL;
pattern_controller_vraster_notify (self, NULL);
pattern_controller_row_shading_notify (self, NULL);
-
gxk_scroll_canvas_set_canvas_cursor (GXK_SCROLL_CANVAS (pview), GDK_XTERM);
return self;
}
-
BstPatternController*
bst_pattern_controller_ref (BstPatternController *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count >= 1, NULL);
-
self->ref_count++;
-
return self;
}
-
void
bst_pattern_controller_unref (BstPatternController *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count >= 1);
-
self->ref_count--;
if (!self->ref_count)
{
@@ -175,7 +160,6 @@ bst_pattern_controller_unref (BstPatternController *self)
g_free (self);
}
}
-
static gboolean
pattern_controller_key_press (BstPatternController *self,
GdkEventKey *event)
@@ -290,7 +274,6 @@ pattern_controller_key_press (BstPatternController *self,
}
return handled;
}
-
static const BstKeyBindingFunction*
pattern_controller_get_functions (gboolean want_piano,
guint *n_p)
@@ -376,7 +359,6 @@ pattern_controller_get_functions (gboolean want_piano,
return generic_funcs;
}
}
-
struct ConstKeyBindingItem {
const char* key_name;
const char* func_name;
@@ -391,7 +373,6 @@ BstKeyBindingItem_from_ConstKeyBindingItem (const ConstKeyBindingItem *ckb)
BIRNET_STATIC_ASSERT (offsetof (ConstKeyBindingItem, func_param) == offsetof (BstKeyBindingItem, func_param));
return (BstKeyBindingItem*) ckb;
}
-
BstKeyBinding*
bst_pattern_controller_default_generic_keys (void)
{
@@ -505,7 +486,6 @@ bst_pattern_controller_default_generic_keys (void)
}
return &kbinding;
}
-
BstKeyBinding*
bst_pattern_controller_default_piano_keys (void)
{
@@ -528,7 +508,6 @@ bst_pattern_controller_default_piano_keys (void)
}
return &kbinding;
}
-
BstKeyBinding*
bst_pattern_controller_generic_keys (void)
{
@@ -545,7 +524,6 @@ bst_pattern_controller_generic_keys (void)
}
return &kbinding;
}
-
BstKeyBinding*
bst_pattern_controller_piano_keys (void)
{
diff --git a/beast-gtk/bstpatternctrl.hh b/beast-gtk/bstpatternctrl.hh
index 5adc62a..c813572 100644
--- a/beast-gtk/bstpatternctrl.hh
+++ b/beast-gtk/bstpatternctrl.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PATTERN_CONTROLLER_H__
#define __BST_PATTERN_CONTROLLER_H__
-
#include "bstpatternview.hh"
-
G_BEGIN_DECLS
-
typedef struct {
GxkParam *vraster;
GxkParam *steps;
@@ -19,8 +16,6 @@ typedef struct {
/* tool selections */
GxkActionGroup *quant_rtools;
} BstPatternController;
-
-
BstPatternController* bst_pattern_controller_new (BstPatternView *pview,
GxkActionGroup *quant_rtools);
BstPatternController* bst_pattern_controller_ref (BstPatternController *self);
@@ -29,7 +24,5 @@ BstKeyBinding* bst_pattern_controller_default_generic_keys (void);
BstKeyBinding* bst_pattern_controller_generic_keys (void);
BstKeyBinding* bst_pattern_controller_default_piano_keys (void);
BstKeyBinding* bst_pattern_controller_piano_keys (void);
-
G_END_DECLS
-
#endif /* __BST_PATTERN_CONTROLLER_H__ */
diff --git a/beast-gtk/bstpatternview.cc b/beast-gtk/bstpatternview.cc
index d85452a..a682acf 100644
--- a/beast-gtk/bstpatternview.cc
+++ b/beast-gtk/bstpatternview.cc
@@ -2,8 +2,6 @@
#include "bstpatternview.hh"
#include "bstskinconfig.hh"
#include <string.h>
-
-
/* --- defines --- */
/* accessors */
#define STYLE(self) (GTK_WIDGET (self)->style)
@@ -33,24 +31,16 @@
/* layout (allocation) */
#define CMARK_HEIGHT(self) (YTHICKNESS (self) * 3 + 1)
#define PMARK_HEIGHT(self) (CMARK_HEIGHT (self) + 3 * YTHICKNESS (self))
-
#define CUSTOM_MARKER_OFFSET (128)
-
-
/* --- prototypes --- */
static void pattern_view_queue_expose (BstPatternView *self,
guint tick_start,
guint tick_end);
-
-
/* --- static variables --- */
static guint signal_drag = 0;
static guint signal_clicked = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstPatternView, bst_pattern_view, GXK_TYPE_SCROLL_CANVAS);
-
enum {
CINDEX_SHADE1,
CINDEX_SHADE2,
@@ -59,7 +49,6 @@ enum {
CINDEX_VBAR,
CINDEX_LAST
};
-
static void
pattern_view_class_setup_skin (BstPatternViewClass *klass)
{
@@ -78,12 +67,10 @@ pattern_view_class_setup_skin (BstPatternViewClass *klass)
scroll_canvas_class->image_saturation = BST_SKIN_CONFIG (pattern_shade) * 0.01;
gxk_scroll_canvas_class_skin_changed (scroll_canvas_class);
}
-
static void
bst_pattern_view_init (BstPatternView *self)
{
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
-
self->row_height = 1;
self->tpt = 384 * 4;
self->max_ticks = 1;
@@ -99,17 +86,13 @@ bst_pattern_view_init (BstPatternView *self)
"offset-3 : note-3 : velocity-3 : fine-tune-3 : length-3 | "
"control-4 | control-7 | control-8"));
}
-
static void
bst_pattern_view_dispose (GObject *object)
{
BstPatternView *self = BST_PATTERN_VIEW (object);
-
bst_pattern_view_set_proxy (self, 0);
-
G_OBJECT_CLASS (bst_pattern_view_parent_class)->dispose (object);
}
-
static void
bst_pattern_view_destroy_columns (BstPatternView *self)
{
@@ -134,18 +117,14 @@ bst_pattern_view_destroy_columns (BstPatternView *self)
self->layout_string = NULL;
gxk_scroll_canvas_reset_pango_layouts (GXK_SCROLL_CANVAS (self));
}
-
static void
bst_pattern_view_finalize (GObject *object)
{
BstPatternView *self = BST_PATTERN_VIEW (object);
-
bst_pattern_view_set_proxy (self, 0);
bst_pattern_view_destroy_columns (self);
-
G_OBJECT_CLASS (bst_pattern_view_parent_class)->finalize (object);
}
-
static void
pattern_view_update (BstPatternView *self,
guint tick,
@@ -157,14 +136,12 @@ pattern_view_update (BstPatternView *self,
if (GTK_WIDGET_DRAWABLE (self))
pattern_view_queue_expose (self, tick, tick + duration - 1);
}
-
static void
pattern_view_release_proxy (BstPatternView *self)
{
gxk_toplevel_delete (GTK_WIDGET (self));
bst_pattern_view_set_proxy (self, 0);
}
-
static void
pattern_view_range_changed (BstPatternView *self)
{
@@ -172,7 +149,6 @@ pattern_view_range_changed (BstPatternView *self)
bse_proxy_get (self->proxy, "last-tick", &max_ticks, NULL);
bst_pattern_view_vsetup (self, 384, 4, MAX (max_ticks, 1), self->vticks);
}
-
void
bst_pattern_view_set_proxy (BstPatternView *self,
SfiProxy proxy)
@@ -183,7 +159,6 @@ bst_pattern_view_set_proxy (BstPatternView *self,
g_return_if_fail (BSE_IS_PART (proxy));
g_return_if_fail (bse_item_get_project (proxy) != 0);
}
-
if (self->proxy)
{
bse_proxy_disconnect (self->proxy,
@@ -206,7 +181,6 @@ bst_pattern_view_set_proxy (BstPatternView *self,
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static PangoLayout*
pattern_view_column_pango_layout (BstPatternView *self,
BstPatternColumn *col)
@@ -218,7 +192,6 @@ pattern_view_column_pango_layout (BstPatternView *self,
break;
return gxk_scroll_canvas_peek_pango_layout (scc, COLUMN_PLAYOUT_INDEX (i));
}
-
static void
pattern_view_get_layout (GxkScrollCanvas *scc,
GxkScrollCanvasLayout *layout)
@@ -228,11 +201,9 @@ pattern_view_get_layout (GxkScrollCanvas *scc,
PangoRectangle rect = { 0 };
gchar buffer[64];
guint i, accu = 0;
-
/* hpanel writings */
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
layout->top_panel_height = rect.height;
-
/* vpanel numbers */
fdesc = pango_font_description_new ();
pango_font_description_set_family_static (fdesc, "monospace");
@@ -244,10 +215,8 @@ pattern_view_get_layout (GxkScrollCanvas *scc,
pango_layout_set_text (PLAYOUT_VPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_VPANEL (self), NULL, &rect);
layout->left_panel_width = rect.width + 2 * XTHICKNESS (self);
-
layout->right_panel_width = 0;
layout->bottom_panel_height = 0;
-
/* canvas size */
pango_layout_get_pixel_extents (PLAYOUT_CANVAS (self), NULL, &rect);
self->row_height = rect.height + FOCUS_WIDTH (self);
@@ -268,7 +237,6 @@ pattern_view_get_layout (GxkScrollCanvas *scc,
}
layout->canvas_width = accu;
}
-
static gint
tick_to_row (BstPatternView *self,
gint tick)
@@ -276,7 +244,6 @@ tick_to_row (BstPatternView *self,
double row = tick / (double) self->vticks;
return MIN (row, G_MAXINT);
}
-
static gint
last_visible_row (BstPatternView *self)
{
@@ -285,7 +252,6 @@ last_visible_row (BstPatternView *self)
gint view_row = (-1 + (gint) scc->vadjustment->upper) / self->row_height;
return MAX (model_row, view_row);
}
-
static void
row_to_ticks (BstPatternView *self,
gint row,
@@ -298,7 +264,6 @@ row_to_ticks (BstPatternView *self,
if (duration_p)
*duration_p = self->vticks;
}
-
static gint
pixels_to_row_unscrolled (BstPatternView *self,
gint y)
@@ -306,7 +271,6 @@ pixels_to_row_unscrolled (BstPatternView *self,
double row = y / (double) self->row_height;
return MIN (G_MAXINT, row);
}
-
static gint
coord_to_row (BstPatternView *self,
gint y,
@@ -317,7 +281,6 @@ coord_to_row (BstPatternView *self,
*is_valid = row >= 0 && row <= last_visible_row (self);
return row;
}
-
static void
row_to_pixels_unscrolled (BstPatternView *self,
gint row,
@@ -329,7 +292,6 @@ row_to_pixels_unscrolled (BstPatternView *self,
if (height_p)
*height_p = self->row_height;
}
-
static gboolean
row_to_coords (BstPatternView *self,
gint row,
@@ -343,7 +305,6 @@ row_to_coords (BstPatternView *self,
*height_p = self->row_height;
return row >= 0 && row <= last_visible_row (self);
}
-
static gint
coord_to_focus_col (BstPatternView *self,
gint x,
@@ -394,7 +355,6 @@ coord_to_focus_col (BstPatternView *self,
*is_valid = valid;
return focus_col;
}
-
#if 0
static gint
ticks_to_pixels (BstPatternView *self,
@@ -406,7 +366,6 @@ ticks_to_pixels (BstPatternView *self,
pixels = MAX (pixels, 1);
return pixels;
}
-
static gint
pixels_to_ticks (BstPatternView *self,
gint pixels)
@@ -419,14 +378,12 @@ pixels_to_ticks (BstPatternView *self,
ticks = 0;
return ticks;
}
-
static gint
coord_to_tick (BstPatternView *self,
gint y,
gboolean extended_bound)
{
guint tick;
-
y += Y_OFFSET (self);
tick = pixels_to_ticks (self, y);
if (extended_bound)
@@ -437,10 +394,8 @@ coord_to_tick (BstPatternView *self,
}
return tick;
}
-
#define CROSSING_TACT4 (1)
#define CROSSING_TACT (2)
-
static guint
coord_check_crossing (BstPatternView *self,
gint y,
@@ -449,10 +404,8 @@ coord_check_crossing (BstPatternView *self,
guint ntick = coord_to_tick (self, y, FALSE);
guint xtick = coord_to_tick (self, y, TRUE);
guint nq = 0, xq = 0;
-
/* catch _at_ tick boundary as well */
xtick += 1;
-
switch (crossing)
{
case CROSSING_TACT4:
@@ -464,11 +417,9 @@ coord_check_crossing (BstPatternView *self,
xq = xtick / self->tpt;
break;
}
-
return nq != xq;
}
#endif
-
static void
pattern_view_allocate_2markers (BstPatternView *self,
GxkScrollMarker *marker)
@@ -487,7 +438,6 @@ pattern_view_allocate_2markers (BstPatternView *self,
0, ry + rh / 2 - PMARK_HEIGHT (self) / 2,
pw, PMARK_HEIGHT (self));
}
-
static void
pattern_view_move_2markers (BstPatternView *self,
GxkScrollMarker *marker)
@@ -498,7 +448,6 @@ pattern_view_move_2markers (BstPatternView *self,
gxk_scroll_canvas_move_marker (scc, &marker[0], 0, ry + rh / 2 - CMARK_HEIGHT (self) / 2);
gxk_scroll_canvas_move_marker (scc, &marker[1], 0, ry + rh / 2 - PMARK_HEIGHT (self) / 2);
}
-
static void
pattern_view_reallocate_contents (GxkScrollCanvas *scc,
gint xdiff,
@@ -532,7 +481,6 @@ pattern_view_reallocate_contents (GxkScrollCanvas *scc,
}
}
}
-
static void
pattern_view_realize (GtkWidget *widget)
{
@@ -540,7 +488,6 @@ pattern_view_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (bst_pattern_view_parent_class)->realize (widget);
bst_pattern_view_set_focus (self, 0, 0);
}
-
static void
draw_row_shading (BstPatternView *self,
GdkWindow *drawable,
@@ -556,7 +503,6 @@ draw_row_shading (BstPatternView *self,
gdk_draw_rectangle (drawable, COLOR_GC_SHADE2 (self), TRUE,
0, y, drawable_width, height);
}
-
static void
bst_pattern_view_draw_canvas (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -569,12 +515,10 @@ bst_pattern_view_draw_canvas (GxkScrollCanvas *scc,
// gint line_width = 0; /* line widths != 0 interfere with dash-settings on some X servers */
GXK_SCROLL_CANVAS_CLASS (bst_pattern_view_parent_class)->draw_canvas (scc, drawable, area);
gdk_window_get_size (CANVAS (self), &width, &height);
-
GdkGC *gcs[BST_PATTERN_COLUMN_GC_LAST] = { NULL, };
gcs[BST_PATTERN_COLUMN_GC_TEXT0] = COLOR_GC_TEXT0 (self);
gcs[BST_PATTERN_COLUMN_GC_TEXT1] = COLOR_GC_TEXT1 (self);
gcs[BST_PATTERN_COLUMN_GC_VBAR] = COLOR_GC_VBAR (self);
-
validrow = row_to_coords (self, row, &rect.y, &rect.height);
while (validrow && rect.y < area->y + area->height)
{
@@ -593,14 +537,12 @@ bst_pattern_view_draw_canvas (GxkScrollCanvas *scc,
validrow = row_to_coords (self, ++row, &rect.y, &rect.height);
}
}
-
#if 0 // FIXME
static void
bst_pattern_view_overlap_grow_hpanel_area (BstPatternView *self,
GdkRectangle *area)
{
gint i, x = area->x, xbound = x + area->width;
-
/* grow hpanel exposes by surrounding tacts */
i = coord_to_tick (self, x, FALSE);
i /= self->tpt;
@@ -613,12 +555,10 @@ bst_pattern_view_overlap_grow_hpanel_area (BstPatternView *self,
i += 2; /* fudge 1 tact to the right (+1 for round-off) */
i *= self->tpt;
xbound = tick_to_coord (self, i);
-
area->x = x;
area->width = xbound - area->x;
}
#endif
-
static void
bst_pattern_view_draw_hpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -632,7 +572,6 @@ bst_pattern_view_draw_hpanel (GxkScrollCanvas *scc,
gint i, width, height;
gdk_window_get_size (drawable, &width, &height);
bst_pattern_view_overlap_grow_hpanel_area (self, area);
-
/* tact numbers */
for (i = area->x; i < area->x + area->width; i++)
{
@@ -642,14 +581,11 @@ bst_pattern_view_draw_hpanel (GxkScrollCanvas *scc,
if (coord_check_crossing (self, i, CROSSING_TACT4))
{
guint next_pixel, tact4 = coord_to_tick (self, i, TRUE) + 1;
-
tact4 /= (self->tpt * 4);
next_pixel = tick_to_coord (self, (tact4 + 1) * (self->tpt * 4));
-
g_snprintf (buffer, 64, "%u", tact4 + 1);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width / 2 < (i + next_pixel) / 2)
gdk_draw_layout (drawable, draw_gc,
@@ -659,17 +595,14 @@ bst_pattern_view_draw_hpanel (GxkScrollCanvas *scc,
else if (self->draw_tact_grid && coord_check_crossing (self, i, CROSSING_TACT))
{
guint next_pixel, tact = coord_to_tick (self, i, TRUE) + 1;
-
tact /= self->tpt;
next_pixel = tick_to_coord (self, (tact + 1) * self->tpt);
tact = tact % 4 + 1;
if (tact == 1444)
continue; /* would draw on top of tact4 number */
-
g_snprintf (buffer, 64, ":%u", tact % 4 + 1);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width < (i + next_pixel) / 2) /* don't half width, leave some more space */
gdk_draw_layout (drawable, draw_gc,
@@ -679,7 +612,6 @@ bst_pattern_view_draw_hpanel (GxkScrollCanvas *scc,
}
#endif
}
-
static void
bst_pattern_view_draw_vpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -692,7 +624,6 @@ bst_pattern_view_draw_vpanel (GxkScrollCanvas *scc,
gchar buffer[64];
GdkRectangle rect;
gdk_window_get_size (VPANEL (self), &width, &height);
-
validrow = row_to_coords (self, row, &rect.y, &rect.height);
while (validrow && rect.y < area->y + area->height)
{
@@ -709,7 +640,6 @@ bst_pattern_view_draw_vpanel (GxkScrollCanvas *scc,
validrow = row_to_coords (self, ++row, &rect.y, &rect.height);
}
}
-
static void
bst_pattern_view_draw_marker (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -750,7 +680,6 @@ bst_pattern_view_draw_marker (GxkScrollCanvas *scc,
x, y, width, height);
#endif
}
-
static void
pattern_view_queue_expose (BstPatternView *self,
guint tick_start,
@@ -773,7 +702,6 @@ pattern_view_queue_expose (BstPatternView *self,
gdk_window_get_size (CANVAS (self), &area.width, NULL);
gdk_window_invalidate_rect (CANVAS (self), &area, TRUE);
}
-
static void
pattern_view_adjustment_changed (GxkScrollCanvas *scc,
GtkAdjustment *adj)
@@ -807,14 +735,12 @@ pattern_view_adjustment_changed (GxkScrollCanvas *scc,
bst_pattern_view_set_focus (self, self->focus_col, self->focus_row);
}
}
-
static void
pattern_view_update_adjustments (GxkScrollCanvas *scc,
gboolean hadj,
gboolean vadj)
{
BstPatternView *self = BST_PATTERN_VIEW (scc);
-
if (hadj)
{
scc->hadjustment->upper = scc->layout.canvas_width;
@@ -842,10 +768,8 @@ pattern_view_update_adjustments (GxkScrollCanvas *scc,
scc->hadjustment->step_increment = 4 * rh; // FIXME rows-per-tact
}
GXK_SCROLL_CANVAS_CLASS (bst_pattern_view_parent_class)->update_adjustments (scc, hadj, vadj);
-
bst_pattern_view_set_focus (self, self->focus_col, self->focus_row);
}
-
void
bst_pattern_view_vsetup (BstPatternView *self,
guint tpqn,
@@ -857,12 +781,10 @@ bst_pattern_view_vsetup (BstPatternView *self,
self->tpt = MAX (qnpt, 1) * self->tpqn;
self->vticks = CLAMP (vticks, 1, self->tpt);
self->max_ticks = MAX (max_ticks, self->tpt);
-
gtk_widget_queue_draw (GTK_WIDGET (self));
Y_OFFSET (self) = GXK_SCROLL_CANVAS (self)->vadjustment->value;
gxk_scroll_canvas_update_adjustments (GXK_SCROLL_CANVAS (self), FALSE, TRUE);
}
-
static void
pattern_view_handle_drag (GxkScrollCanvas *scc,
GxkScrollCanvasDrag *scc_drag,
@@ -914,7 +836,6 @@ pattern_view_handle_drag (GxkScrollCanvas *scc,
g_signal_emit (self, signal_clicked, 0, drag->button, drag->start_row, drag->start_tick, event);
}
}
-
void
bst_pattern_view_add_column (BstPatternView *self,
BstPatternLType ltype,
@@ -923,7 +844,6 @@ bst_pattern_view_add_column (BstPatternView *self,
{
BstPatternColumn *col;
g_return_if_fail (BST_PATTERN_VIEW (self));
-
self->cols = g_renew (BstPatternColumn*, self->cols, self->n_cols + 1);
col = bst_pattern_column_create (ltype, num, lflags);
self->cols[self->n_cols++] = col;
@@ -935,21 +855,18 @@ bst_pattern_view_add_column (BstPatternView *self,
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
gint
bst_pattern_view_get_focus_width (BstPatternView *self)
{
g_return_val_if_fail (BST_PATTERN_VIEW (self), 0);
return (XTHICKNESS (self) + YTHICKNESS (self)) / 2;
}
-
gint
bst_pattern_view_get_last_row (BstPatternView *self)
{
g_return_val_if_fail (BST_PATTERN_VIEW (self), 0);
return last_visible_row (self);
}
-
BstPatternColumn*
bst_pattern_view_get_focus_cell (BstPatternView *self, int *tick_p, int *duration_p)
{
@@ -962,7 +879,6 @@ bst_pattern_view_get_focus_cell (BstPatternView *self, int *tick_p, int *duratio
}
return NULL;
}
-
gboolean
bst_pattern_view_dispatch_key (BstPatternView *self,
guint keyval,
@@ -990,14 +906,12 @@ bst_pattern_view_dispatch_key (BstPatternView *self,
}
return FALSE;
}
-
void
bst_pattern_view_set_focus (BstPatternView *self, int focus_col, int focus_row)
{
GdkRectangle rect;
gint last_row;
g_return_if_fail (BST_PATTERN_VIEW (self));
-
focus_col = MIN (focus_col + 1, self->n_focus_cols) - 1;
last_row = bst_pattern_view_get_last_row (self);
focus_row = MIN (focus_row, last_row);
@@ -1039,7 +953,6 @@ bst_pattern_view_set_focus (BstPatternView *self, int focus_col, int focus_row)
rect.width, rect.height);
}
}
-
void
bst_pattern_view_set_marker (BstPatternView *self,
guint mark_index,
@@ -1051,7 +964,6 @@ bst_pattern_view_set_marker (BstPatternView *self,
guint count;
g_return_if_fail (mark_index > 0);
mark_index += CUSTOM_MARKER_OFFSET;
-
marker = gxk_scroll_canvas_lookup_marker (scc, mark_index, &count);
if (!marker && !mtype)
return;
@@ -1070,9 +982,7 @@ bst_pattern_view_set_marker (BstPatternView *self,
}
return;
}
-
g_return_if_fail (count == 2);
-
marker[0].coords.y = position;
marker[1].coords.y = position;
if (marker[0].mtype != mtype || !marker[0].pixmap)
@@ -1084,7 +994,6 @@ bst_pattern_view_set_marker (BstPatternView *self,
else
pattern_view_move_2markers (self, marker);
}
-
void
bst_pattern_view_set_pixmarker (BstPatternView *self,
guint mark_index,
@@ -1098,7 +1007,6 @@ bst_pattern_view_set_pixmarker (BstPatternView *self,
GxkScrollMarker *marker;
guint count;
g_return_if_fail (mark_index > 0 && mark_index < CUSTOM_MARKER_OFFSET);
-
marker = gxk_scroll_canvas_lookup_marker (scc, mark_index, &count);
if (!marker && !mtype)
return;
@@ -1116,9 +1024,7 @@ bst_pattern_view_set_pixmarker (BstPatternView *self,
}
return;
}
-
g_return_if_fail (count == 1);
-
if (marker->mtype == mtype && marker->windowp == &CANVAS (self) &&
marker->extends.width == width && marker->extends.height == height)
gxk_scroll_canvas_move_marker (scc, marker, x, y);
@@ -1128,13 +1034,11 @@ bst_pattern_view_set_pixmarker (BstPatternView *self,
gxk_scroll_canvas_setup_marker (scc, marker, &CANVAS (self), x, y, width, height);
}
}
-
const gchar*
bst_pattern_view_get_layout (BstPatternView *self)
{
return self->layout_string;
}
-
guint
bst_pattern_view_set_layout (BstPatternView *self,
const gchar *layout)
@@ -1172,7 +1076,6 @@ bst_pattern_view_set_layout (BstPatternView *self,
g_free (column);
return p2 - layout;
}
-
void
bst_pattern_view_set_shading (BstPatternView *self,
guint row1,
@@ -1184,19 +1087,15 @@ bst_pattern_view_set_shading (BstPatternView *self,
self->srow2 = row2;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
static void
bst_pattern_view_class_init (BstPatternViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GxkScrollCanvasClass *scroll_canvas_class = GXK_SCROLL_CANVAS_CLASS (klass);
-
gobject_class->finalize = bst_pattern_view_finalize;
gobject_class->dispose = bst_pattern_view_dispose;
-
widget_class->realize = pattern_view_realize;
-
scroll_canvas_class->hscrollable = TRUE;
scroll_canvas_class->vscrollable = TRUE;
scroll_canvas_class->get_layout = pattern_view_get_layout;
@@ -1210,10 +1109,8 @@ bst_pattern_view_class_init (BstPatternViewClass *klass)
scroll_canvas_class->handle_drag = pattern_view_handle_drag;
scroll_canvas_class->image_tint = gdk_color_from_rgb (0x00ffffff);
scroll_canvas_class->image_saturation = 0;
-
klass->drag = NULL;
klass->clicked = NULL;
-
signal_drag = g_signal_new ("drag", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BstPatternViewClass, drag),
NULL, NULL,
@@ -1225,7 +1122,6 @@ bst_pattern_view_class_init (BstPatternViewClass *klass)
bst_marshal_NONE__UINT_UINT_INT_BOXED,
G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
bst_skin_config_add_notify ((BstSkinConfigNotify) pattern_view_class_setup_skin, klass);
pattern_view_class_setup_skin (klass);
}
diff --git a/beast-gtk/bstpatternview.hh b/beast-gtk/bstpatternview.hh
index bc37e9d..f1edf0c 100644
--- a/beast-gtk/bstpatternview.hh
+++ b/beast-gtk/bstpatternview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PATTERN_VIEW_H__
#define __BST_PATTERN_VIEW_H__
-
#include "bstpatterncolumns.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_PATTERN_VIEW (bst_pattern_view_get_type ())
#define BST_PATTERN_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PATTERN_VIEW, BstPatternView))
@@ -13,13 +10,9 @@ G_BEGIN_DECLS
#define BST_IS_PATTERN_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PATTERN_VIEW))
#define BST_IS_PATTERN_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PATTERN_VIEW))
#define BST_PATTERN_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PATTERN_VIEW, BstPatternViewClass))
-
-
/* --- typedefs & enums --- */
/* bstpatterncolumns.hh: typedef struct _BstPatternView BstPatternView; */
typedef struct _BstPatternViewClass BstPatternViewClass;
-
-
/* --- structures & typedefs --- */
typedef enum /*< skip >*/
{
@@ -44,30 +37,24 @@ typedef struct {
struct _BstPatternView
{
GxkScrollCanvas parent_instance;
-
SfiProxy proxy;
-
/* vertical layout */
guint row_height;
guint tpqn; /* ticks per quarter note */
guint tpt; /* ticks per tact */
gint vticks; /* ticks per row */
guint max_ticks;
-
/* horizontal layout */
guint n_cols;
BstPatternColumn **cols;
gchar *layout_string;
-
/* focus cell */
guint focus_col;
guint focus_row;
int n_focus_cols;
BstPatternColumn **focus_cols;
-
/* shading */
guint16 srow1, srow2;
-
/* last drag state */
guint start_col;
guint start_row;
@@ -78,7 +65,6 @@ struct _BstPatternView
struct _BstPatternViewClass
{
GxkScrollCanvasClass parent_class;
-
void (*drag) (BstPatternView *self,
BstPatternViewDrag *drag);
void (*clicked) (BstPatternView *tview,
@@ -87,8 +73,6 @@ struct _BstPatternViewClass
guint tick_position,
GdkEvent *event);
};
-
-
/* --- prototypes --- */
GType bst_pattern_view_get_type (void);
void bst_pattern_view_set_proxy (BstPatternView *self,
@@ -131,8 +115,5 @@ gint bst_pattern_view_get_last_row (BstPatternView *s
const gchar* bst_pattern_view_get_layout (BstPatternView *self);
guint bst_pattern_view_set_layout (BstPatternView *self,
const gchar *layout);
-
-
G_END_DECLS
-
#endif /* __BST_PATTERN_VIEW_H__ */
diff --git a/beast-gtk/bstpianoroll.cc b/beast-gtk/bstpianoroll.cc
index 59e4556..1ea10fa 100644
--- a/beast-gtk/bstpianoroll.cc
+++ b/beast-gtk/bstpianoroll.cc
@@ -4,8 +4,6 @@
#include "bstskinconfig.hh"
#include <string.h>
#include <math.h>
-
-
/* --- defines --- */
/* accessors */
#define STYLE(self) (GTK_WIDGET (self)->style)
@@ -41,7 +39,6 @@
/* appearance */
#define KEY_DEFAULT_VPIXELS (4)
#define QNOTE_HPIXELS (30) /* guideline */
-
enum {
CINDEX_C,
CINDEX_Cis,
@@ -64,24 +61,19 @@ enum {
CINDEX_SELECT,
CINDEX_COUNT
};
-
/* --- prototypes --- */
static void bst_piano_roll_hsetup (BstPianoRoll *self,
guint ppqn,
guint qnpt,
guint max_ticks,
gfloat hzoom);
-
/* --- static variables --- */
static guint signal_canvas_drag = 0;
static guint signal_canvas_clicked = 0;
static guint signal_piano_drag = 0;
static guint signal_piano_clicked = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstPianoRoll, bst_piano_roll, GXK_TYPE_SCROLL_CANVAS);
-
static void
piano_roll_class_setup_skin (BstPianoRollClass *klass)
{
@@ -129,14 +121,11 @@ piano_roll_class_setup_skin (BstPianoRollClass *klass)
scroll_canvas_class->image_saturation = BST_SKIN_CONFIG (piano_shade) * 0.01;
gxk_scroll_canvas_class_skin_changed (scroll_canvas_class);
}
-
static void
bst_piano_roll_init (BstPianoRoll *self)
{
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
-
GTK_WIDGET_SET_FLAGS (self, GTK_CAN_FOCUS);
-
self->proxy = 0;
self->vzoom = KEY_DEFAULT_VPIXELS;
self->ppqn = 384; /* default Parts (clock ticks) Per Quarter Note */
@@ -156,72 +145,53 @@ bst_piano_roll_init (BstPianoRoll *self)
self->selection_min_note = 0;
self->selection_max_note = 0;
bst_piano_roll_hsetup (self, 384, 4, 800 * 384, 1);
-
bst_ascii_pixbuf_ref ();
}
-
static void
bst_piano_roll_destroy (GtkObject *object)
{
BstPianoRoll *self = BST_PIANO_ROLL (object);
-
bst_piano_roll_set_proxy (self, 0);
-
GTK_OBJECT_CLASS (bst_piano_roll_parent_class)->destroy (object);
}
-
static void
bst_piano_roll_dispose (GObject *object)
{
BstPianoRoll *self = BST_PIANO_ROLL (object);
-
bst_piano_roll_set_proxy (self, 0);
-
G_OBJECT_CLASS (bst_piano_roll_parent_class)->dispose (object);
}
-
static void
bst_piano_roll_finalize (GObject *object)
{
BstPianoRoll *self = BST_PIANO_ROLL (object);
-
bst_piano_roll_set_proxy (self, 0);
-
bst_ascii_pixbuf_unref ();
-
G_OBJECT_CLASS (bst_piano_roll_parent_class)->finalize (object);
}
-
static void
bst_piano_roll_map (GtkWidget *widget)
{
BstPianoRoll *self = BST_PIANO_ROLL (widget);
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
-
/* initially center the vscrollbar */
if (self->proxy)
gtk_adjustment_set_value (scc->vadjustment,
(scc->vadjustment->upper -
scc->vadjustment->lower -
scc->vadjustment->page_size) / 2);
-
GTK_WIDGET_CLASS (bst_piano_roll_parent_class)->map (widget);
}
-
gfloat
bst_piano_roll_set_vzoom (BstPianoRoll *self,
gfloat vzoom)
{
g_return_val_if_fail (BST_IS_PIANO_ROLL (self), 0);
-
self->vzoom = vzoom; // * KEY_DEFAULT_VPIXELS;
self->vzoom = CLAMP (self->vzoom, 1, 16);
-
gtk_widget_queue_resize (GTK_WIDGET (self));
-
return self->vzoom;
}
-
static void
piano_roll_get_layout (GxkScrollCanvas *scc,
GxkScrollCanvasLayout *layout)
@@ -236,31 +206,25 @@ piano_roll_get_layout (GxkScrollCanvas *scc,
layout->max_canvas_height = N_OCTAVES (self) * OCTAVE_HEIGHT (self);
layout->canvas_height = N_OCTAVES (self) * OCTAVE_HEIGHT (self);
}
-
static gdouble
ticks_to_pixels (BstPianoRoll *self,
gdouble ticks)
{
gdouble ppqn = self->ppqn;
gdouble tpixels = QNOTE_HPIXELS;
-
/* compute pixel span of a tick range */
-
tpixels *= self->hzoom / ppqn * ticks;
if (ticks)
tpixels = MAX (tpixels, 1);
return MIN (G_MAXINT, tpixels);
}
-
static gdouble
pixels_to_ticks (BstPianoRoll *self,
gdouble pixels)
{
gdouble ppqn = self->ppqn;
gdouble ticks = 1.0 / (gdouble) QNOTE_HPIXELS;
-
/* compute tick span of a pixel range */
-
ticks = ticks * ppqn / self->hzoom * pixels;
if (pixels > 0)
ticks = MAX (ticks, 1);
@@ -268,37 +232,31 @@ pixels_to_ticks (BstPianoRoll *self,
ticks = 0;
return MIN (G_MAXINT, ticks);
}
-
static gint
tick_to_coord (BstPianoRoll *self,
gint tick)
{
return ticks_to_pixels (self, tick) - X_OFFSET (self);
}
-
static gint
coord_to_tick (BstPianoRoll *self,
gint x,
gboolean right_bound)
{
guint tick;
-
x += X_OFFSET (self);
tick = pixels_to_ticks (self, x);
if (right_bound)
{
guint tick2 = pixels_to_ticks (self, x + 1);
-
if (tick2 > tick)
tick = tick2 - 1;
}
return tick;
}
-
#define CROSSING_TACT (1)
#define CROSSING_QNOTE (2)
#define CROSSING_QNOTE_Q (3)
-
static guint
coord_check_crossing (BstPianoRoll *self,
gint x,
@@ -307,10 +265,8 @@ coord_check_crossing (BstPianoRoll *self,
guint ltick = coord_to_tick (self, x, FALSE);
guint rtick = coord_to_tick (self, x, TRUE);
guint lq = 0, rq = 0;
-
/* catch _at_ tick boundary as well */
rtick += 1;
-
switch (crossing)
{
case CROSSING_TACT:
@@ -326,15 +282,12 @@ coord_check_crossing (BstPianoRoll *self,
rq = rtick * 4 / self->ppqn;
break;
}
-
return lq != rq;
}
-
#define DRAW_NONE (0)
#define DRAW_START (1)
#define DRAW_MIDDLE (2)
#define DRAW_END (3)
-
typedef struct {
gint octave;
guint semitone; /* 0 .. 11 within octave */
@@ -348,7 +301,6 @@ typedef struct {
gint valid_octave;
guint valid_semitone;
} NoteInfo;
-
static gint
note_to_pixels (BstPianoRoll *self,
gint note,
@@ -357,7 +309,6 @@ note_to_pixels (BstPianoRoll *self,
{
gint octave, ythickness = 1, z = self->vzoom, h = NOTE_HEIGHT (self), semitone = SFI_NOTE_SEMITONE (note);
gint oheight = OCTAVE_HEIGHT (self), y, zz = z + z, offs = 0, height = h;
-
switch (semitone)
{
case 10: offs += zz + h;
@@ -378,21 +329,17 @@ note_to_pixels (BstPianoRoll *self,
octave = N_OCTAVES (self) - 1 - SFI_NOTE_OCTAVE (note) + MIN_OCTAVE (self);
y = octave * oheight;
y += oheight - offs - h;
-
/* spacing out by a bit looks nicer */
if (z >= 4)
{
height += ythickness;
}
-
if (height_p)
*height_p = height;
if (ces_fes_height_p)
*ces_fes_height_p = (semitone == 0 || semitone == 4 || semitone == 5 || semitone == 11) ? z : 0;
-
return y;
}
-
static gint
note_to_coord (BstPianoRoll *self,
gint note,
@@ -401,7 +348,6 @@ note_to_coord (BstPianoRoll *self,
{
return note_to_pixels (self, note, height_p, ces_fes_height_p) - Y_OFFSET (self);
}
-
static gboolean
coord_to_note (BstPianoRoll *self,
gint y,
@@ -410,7 +356,6 @@ coord_to_note (BstPianoRoll *self,
gint ythickness = 1, i, z = self->vzoom, h = NOTE_HEIGHT (self);
gint end_shift, start_shift, black_shift = 0;
gint oheight = OCTAVE_HEIGHT (self), kheight = 2 * z + h;
-
y += Y_OFFSET (self);
info->octave = y / oheight;
i = y - info->octave * oheight;
@@ -419,7 +364,6 @@ coord_to_note (BstPianoRoll *self,
info->key_frac = i - info->key * kheight;
i = info->key_frac;
info->octave = N_OCTAVES (self) - 1 - info->octave + MIN_OCTAVE (self);
-
/* figure black notes */
end_shift = i >= z + h;
start_shift = i < z; /* + ythickness; */
@@ -447,7 +391,6 @@ coord_to_note (BstPianoRoll *self,
black_shift = start_shift;
break;
}
-
/* pixel layout and note numbers:
* Iz|h|zIz|h|zIz|h|zIz|h|zIz|h|zIz|h|zIz|h|zI
* I 0 |#1#|2|#3#|4 I 5|#6#|7|#8#|9|#10|11 I
@@ -457,7 +400,6 @@ coord_to_note (BstPianoRoll *self,
* +--0--+--1--+--2--+--3--+--4--+--5--+--6--+
* i=key_fraction, increases to right --->
*/
-
/* figure draw states */
if (i < ythickness)
info->wstate = DRAW_START;
@@ -475,7 +417,6 @@ coord_to_note (BstPianoRoll *self,
info->bstate = DRAW_END;
else
info->bstate = DRAW_MIDDLE;
-
/* behaviour fixup, ignore black note borders */
if (black_shift && info->bstate == DRAW_START)
{
@@ -489,7 +430,6 @@ coord_to_note (BstPianoRoll *self,
}
else
info->bmatch = TRUE;
-
/* validate note */
if (y < 0 || /* we calc junk in this case, flag invalidity */
info->octave > MAX_OCTAVE (self) ||
@@ -512,10 +452,8 @@ coord_to_note (BstPianoRoll *self,
info->valid_semitone = info->semitone;
info->valid = TRUE;
}
-
return info->bmatch != 0;
}
-
static void
piano_roll_allocate_marker (BstPianoRoll *self,
GxkScrollMarker *marker)
@@ -528,7 +466,6 @@ piano_roll_allocate_marker (BstPianoRoll *self,
x - CMARK_WIDTH (self) / 2, 0,
CMARK_WIDTH (self), ch);
}
-
static void
piano_roll_move_marker (BstPianoRoll *self,
GxkScrollMarker *marker)
@@ -537,7 +474,6 @@ piano_roll_move_marker (BstPianoRoll *self,
gint x = tick_to_coord (self, marker[0].coords.x);
gxk_scroll_canvas_move_marker (scc, &marker[0], x - CMARK_WIDTH (self) / 2, 0);
}
-
static void
bst_piano_roll_draw_marker (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -571,7 +507,6 @@ bst_piano_roll_draw_marker (GxkScrollCanvas *scc,
break;
}
}
-
static void
piano_roll_reallocate_contents (GxkScrollCanvas *scc,
gint xdiff,
@@ -585,7 +520,6 @@ piano_roll_reallocate_contents (GxkScrollCanvas *scc,
else
piano_roll_allocate_marker (self, scc->markers + i);
}
-
static void
bst_piano_roll_overlap_grow_vpanel_area (BstPianoRoll *self,
GdkRectangle *area)
@@ -595,7 +529,6 @@ bst_piano_roll_overlap_grow_vpanel_area (BstPianoRoll *self,
area->height += OCTAVE_HEIGHT (self) / 7; /* compensate for y-=key */
area->height += OCTAVE_HEIGHT (self) / 7; /* fudge 1 key downwards */
}
-
static void
bst_piano_roll_draw_vpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -609,17 +542,14 @@ bst_piano_roll_draw_vpanel (GxkScrollCanvas *scc,
gint width, height;
gdk_window_get_size (drawable, &width, &height);
bst_piano_roll_overlap_grow_vpanel_area (self, area);
-
/* draw vertical frame lines */
gdk_draw_line (drawable, dark_gc, start_x + white_x - 1, area->y, start_x + white_x - 1, area->y + area->height - 1);
gdk_draw_line (drawable, light_gc, start_x, area->y, start_x, area->y + area->height - 1);
-
/* draw horizontal lines */
for (y = MAX (area->y, 0); y < area->y + area->height; y++)
{
gint x = black_x + 1;
NoteInfo info;
-
coord_to_note (self, y, &info);
switch (info.bstate)
{
@@ -646,7 +576,6 @@ bst_piano_roll_draw_vpanel (GxkScrollCanvas *scc,
gint pbheight, ypos, ythickness = 1, overlap = 1;
gint pbwidth = white_x - black_x + overlap;
GdkPixbuf *pixbuf;
-
pbheight = OCTAVE_HEIGHT (self) / 7;
pbwidth /= 2;
ypos = y - pbheight + ythickness;
@@ -681,7 +610,6 @@ bst_piano_roll_draw_vpanel (GxkScrollCanvas *scc,
}
}
}
-
static void
bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -693,12 +621,10 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
BsePartNoteSeq *pseq;
GXK_SCROLL_CANVAS_CLASS (bst_piano_roll_parent_class)->draw_canvas (scc, drawable, area);
gdk_window_get_size (drawable, &width, &height);
-
/* draw selection */
if (self->selection_duration)
{
gint x1, x2, y1, y2, h;
-
x1 = tick_to_coord (self, self->selection_tick);
x2 = tick_to_coord (self, self->selection_tick + self->selection_duration);
y1 = note_to_coord (self, self->selection_max_note, &h, NULL);
@@ -712,7 +638,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
gdk_draw_rectangle (drawable, GTK_WIDGET (self)->style->bg_gc[GTK_STATE_SELECTED], TRUE,
x1, y1, MAX (x2 - x1, 0), MAX (y2 - y1, 0));
}
-
/* we do multiple passes to draw h/v grid lines for them to properly ovrlay */
for (pass = 1; pass <= 3; pass++)
{
@@ -763,7 +688,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
{
GdkGC *draw_gc = COLOR_GC_MBAR (self);
guint8 dash[3] = { 2, 2, 0 };
-
gdk_gc_set_line_attributes (draw_gc, line_width, GDK_LINE_ON_OFF_DASH, GDK_CAP_BUTT, GDK_JOIN_MITER);
dlen = dash[0] + dash[1];
gdk_gc_set_dashes (draw_gc, (X_OFFSET (self) + area->x + 1) % dlen, (gint8*) dash, 2);
@@ -774,7 +698,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
{
GdkGC *draw_gc = COLOR_GC_HGRID (self);
guint8 dash[3] = { 1, 1, 0 };
-
gdk_gc_set_line_attributes (draw_gc, line_width, GDK_LINE_ON_OFF_DASH, GDK_CAP_BUTT, GDK_JOIN_MITER);
dlen = dash[0] + dash[1];
gdk_gc_set_dashes (draw_gc, (X_OFFSET (self) + area->x + 1) % dlen, (gint8*) dash, 2);
@@ -783,7 +706,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
}
}
}
-
/* draw notes */
dark_gc = STYLE (self)->dark_gc[GTK_STATE_NORMAL];
pseq = self->proxy ? bse_part_list_notes_crossing (self->proxy,
@@ -797,7 +719,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
GdkGC *xdark_gc, *xlight_gc, *xnote_gc;
gint x1, x2, y1, y2, height;
gboolean selected = pnote->selected;
-
selected |= (pnote->tick >= self->selection_tick &&
pnote->tick < self->selection_tick + self->selection_duration &&
pnote->note >= self->selection_min_note &&
@@ -816,7 +737,6 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
}
x1 = tick_to_coord (self, start);
x2 = tick_to_coord (self, end);
-
y1 = note_to_coord (self, pnote->note, &height, NULL);
y2 = y1 + height - 1;
gdk_draw_line (drawable, xdark_gc, x1, y2, x2, y2);
@@ -832,13 +752,11 @@ bst_piano_roll_draw_canvas (GxkScrollCanvas *scc,
}
}
}
-
static void
bst_piano_roll_overlap_grow_hpanel_area (BstPianoRoll *self,
GdkRectangle *area)
{
gint i, x = area->x, xbound = x + area->width;
-
/* grow hpanel exposes by surrounding tacts */
i = coord_to_tick (self, x, FALSE);
i /= self->ppqn * self->qnpt;
@@ -851,11 +769,9 @@ bst_piano_roll_overlap_grow_hpanel_area (BstPianoRoll *self,
i += 2; /* fudge 1 tact to the right (+1 for round-off) */
i *= self->ppqn * self->qnpt;
xbound = tick_to_coord (self, i);
-
area->x = x;
area->width = xbound - area->x;
}
-
static void
bst_piano_roll_draw_hpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -868,7 +784,6 @@ bst_piano_roll_draw_hpanel (GxkScrollCanvas *scc,
int width, height;
gdk_window_get_size (drawable, &width, &height);
bst_piano_roll_overlap_grow_hpanel_area (self, area);
-
/* draw tact/note numbers */
gdk_gc_set_clip_rectangle (draw_gc, area);
for (int i = area->x; i < area->x + area->width; i++)
@@ -879,14 +794,11 @@ bst_piano_roll_draw_hpanel (GxkScrollCanvas *scc,
if (coord_check_crossing (self, i, CROSSING_TACT))
{
int next_pixel, tact = coord_to_tick (self, i, TRUE) + 1;
-
tact /= (self->ppqn * self->qnpt);
next_pixel = tick_to_coord (self, (tact + 1) * (self->ppqn * self->qnpt));
-
g_snprintf (buffer, 64, "%u", tact + 1);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width / 2 < (i + next_pixel) / 2)
gdk_draw_layout (drawable, draw_gc,
@@ -896,18 +808,15 @@ bst_piano_roll_draw_hpanel (GxkScrollCanvas *scc,
else if (self->draw_qqn_grid && coord_check_crossing (self, i, CROSSING_QNOTE))
{
int next_pixel, tact = coord_to_tick (self, i, TRUE) + 1, qn = tact;
-
tact /= (self->ppqn * self->qnpt);
qn /= self->ppqn;
next_pixel = tick_to_coord (self, (qn + 1) * self->ppqn);
qn = qn % self->qnpt + 1;
if (qn == 1)
continue; /* would draw on top of tact number */
-
g_snprintf (buffer, 64, ":%u", qn);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width < (i + next_pixel) / 2) /* don't half width, leave some more space */
gdk_draw_layout (drawable, draw_gc,
@@ -917,7 +826,6 @@ bst_piano_roll_draw_hpanel (GxkScrollCanvas *scc,
}
gdk_gc_set_clip_rectangle (draw_gc, NULL);
}
-
static void
piano_roll_queue_expose (BstPianoRoll *self,
GdkWindow *window,
@@ -929,7 +837,6 @@ piano_roll_queue_expose (BstPianoRoll *self,
gint x2 = tick_to_coord (self, tick_end);
gint height, cfheight, y1 = note_to_coord (self, note, &height, &cfheight);
GdkRectangle area;
-
area.x = x1;
area.width = x2 - x1;
area.x -= 3; /* add fudge */
@@ -950,7 +857,6 @@ piano_roll_queue_expose (BstPianoRoll *self,
}
gdk_window_invalidate_rect (window, &area, TRUE);
}
-
static void
piano_roll_adjustment_changed (GxkScrollCanvas *scc,
GtkAdjustment *adj)
@@ -975,14 +881,12 @@ piano_roll_adjustment_changed (GxkScrollCanvas *scc,
{
}
}
-
static void
piano_roll_update_adjustments (GxkScrollCanvas *scc,
gboolean hadj,
gboolean vadj)
{
BstPianoRoll *self = BST_PIANO_ROLL (scc);
-
if (hadj)
{
/* allow free boundary adjustments by the user between last_tick and 1e+9 ticks and pixels.
@@ -1007,7 +911,6 @@ piano_roll_update_adjustments (GxkScrollCanvas *scc,
}
GXK_SCROLL_CANVAS_CLASS (bst_piano_roll_parent_class)->update_adjustments (scc, hadj, vadj);
}
-
static void
bst_piano_roll_hsetup (BstPianoRoll *self,
guint ppqn,
@@ -1021,18 +924,15 @@ bst_piano_roll_hsetup (BstPianoRoll *self,
guint old_max_ticks = self->max_ticks;
gfloat old_hzoom = self->hzoom;
gdouble old_hpos = pixels_to_ticks (self, scc->hadjustment->value);
-
/* here, we setup all things necessary to determine our
* horizontal layout. we avoid resizes if only max_ticks
* changes, since the tick range might grow/shrink fairly
* frequently.
*/
-
self->ppqn = MAX (ppqn, 1);
self->qnpt = CLAMP (qnpt, 3, 4);
self->max_ticks = MAX (max_ticks, 1);
self->hzoom = CLAMP (hzoom, 0.01, 100);
-
if (old_ppqn != self->ppqn ||
old_qnpt != self->qnpt ||
old_hzoom != self->hzoom)
@@ -1050,23 +950,19 @@ bst_piano_roll_hsetup (BstPianoRoll *self,
gxk_scroll_canvas_update_adjustments (GXK_SCROLL_CANVAS (self), TRUE, FALSE);
}
}
-
gfloat
bst_piano_roll_set_hzoom (BstPianoRoll *self,
gfloat hzoom)
{
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
g_return_val_if_fail (BST_IS_PIANO_ROLL (self), 0);
-
bst_piano_roll_hsetup (self, self->ppqn, self->qnpt, self->max_ticks, hzoom);
guint i;
/* readjust markers */
for (i = 0; i < scc->n_markers; i++)
piano_roll_allocate_marker (self, scc->markers + i);
-
return self->hzoom;
}
-
static void
piano_roll_handle_drag (GxkScrollCanvas *scc,
GxkScrollCanvasDrag *scc_drag,
@@ -1120,7 +1016,6 @@ piano_roll_handle_drag (GxkScrollCanvas *scc,
g_signal_emit (self, signal_piano_clicked, 0, drag->button, drag->start_tick, drag->start_note, event);
}
}
-
static void
piano_roll_song_pointer_changed (BstPianoRoll *self,
SfiInt position)
@@ -1153,7 +1048,6 @@ piano_roll_song_pointer_changed (BstPianoRoll *self,
else
bst_piano_roll_set_marker (self, 1, position, BstPianoRollMarkerType (0));
}
-
static void
piano_roll_links_changed (BstPianoRoll *self)
{
@@ -1167,7 +1061,6 @@ piano_roll_links_changed (BstPianoRoll *self)
self->plinks = bse_part_link_seq_copy_shallow (self->plinks);
}
}
-
static void
piano_roll_range_changed (BstPianoRoll *self)
{
@@ -1175,7 +1068,6 @@ piano_roll_range_changed (BstPianoRoll *self)
bse_proxy_get (self->proxy, "last-tick", &max_ticks, NULL);
bst_piano_roll_hsetup (self, self->ppqn, self->qnpt, MAX (max_ticks, 1), self->hzoom);
}
-
static void
piano_roll_update (BstPianoRoll *self,
guint tick,
@@ -1190,14 +1082,12 @@ piano_roll_update (BstPianoRoll *self,
piano_roll_queue_expose (self, CANVAS (self), note, tick, tick + duration - 1);
gxk_widget_update_actions (self); /* update controllers */
}
-
static void
piano_roll_release_proxy (BstPianoRoll *self)
{
gxk_toplevel_delete (GTK_WIDGET (self));
bst_piano_roll_set_proxy (self, 0);
}
-
void
bst_piano_roll_set_proxy (BstPianoRoll *self,
SfiProxy proxy)
@@ -1208,7 +1098,6 @@ bst_piano_roll_set_proxy (BstPianoRoll *self,
g_return_if_fail (BSE_IS_ITEM (proxy));
g_return_if_fail (bse_item_get_project (proxy) != 0);
}
-
if (self->proxy)
{
if (self->song)
@@ -1260,7 +1149,6 @@ bst_piano_roll_set_proxy (BstPianoRoll *self,
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
piano_roll_queue_region (BstPianoRoll *self,
guint tick,
@@ -1272,7 +1160,6 @@ piano_roll_queue_region (BstPianoRoll *self,
bse_part_queue_notes (self->proxy, tick, duration, min_note, max_note);
piano_roll_update (self, tick, duration, min_note, max_note);
}
-
void
bst_piano_roll_set_view_selection (BstPianoRoll *self,
guint tick,
@@ -1281,7 +1168,6 @@ bst_piano_roll_set_view_selection (BstPianoRoll *self,
gint max_note)
{
g_return_if_fail (BST_IS_PIANO_ROLL (self));
-
if (min_note > max_note || !duration) /* invalid selection */
{
tick = 0;
@@ -1289,7 +1175,6 @@ bst_piano_roll_set_view_selection (BstPianoRoll *self,
min_note = 0;
max_note = 0;
}
-
if (self->selection_duration && duration)
{
/* if at least one corner of the old an the new selection
@@ -1347,7 +1232,6 @@ bst_piano_roll_set_view_selection (BstPianoRoll *self,
self->selection_min_note = min_note;
self->selection_max_note = max_note;
}
-
gint
bst_piano_roll_get_vpanel_width (BstPianoRoll *self)
{
@@ -1359,7 +1243,6 @@ bst_piano_roll_get_vpanel_width (BstPianoRoll *self)
width = GXK_SCROLL_CANVAS (self)->layout.left_panel_width;
return width;
}
-
void
bst_piano_roll_get_paste_pos (BstPianoRoll *self,
guint *tick_p,
@@ -1367,9 +1250,7 @@ bst_piano_roll_get_paste_pos (BstPianoRoll *self,
{
guint tick, semitone;
gint octave;
-
g_return_if_fail (BST_IS_PIANO_ROLL (self));
-
if (GTK_WIDGET_DRAWABLE (self))
{
NoteInfo info;
@@ -1398,7 +1279,6 @@ bst_piano_roll_get_paste_pos (BstPianoRoll *self,
if (tick_p)
*tick_p = tick;
}
-
void
bst_piano_roll_set_marker (BstPianoRoll *self,
guint mark_index,
@@ -1409,7 +1289,6 @@ bst_piano_roll_set_marker (BstPianoRoll *self,
GxkScrollMarker *marker;
guint count;
g_return_if_fail (mark_index > 0);
-
marker = gxk_scroll_canvas_lookup_marker (scc, mark_index, &count);
if (!marker && !mtype)
return;
@@ -1427,9 +1306,7 @@ bst_piano_roll_set_marker (BstPianoRoll *self,
}
return;
}
-
g_return_if_fail (count == 1);
-
marker[0].coords.x = position;
if (marker[0].mtype != mtype || !marker[0].pixmap)
{
@@ -1439,7 +1316,6 @@ bst_piano_roll_set_marker (BstPianoRoll *self,
else
piano_roll_move_marker (self, marker);
}
-
static void
bst_piano_roll_class_init (BstPianoRollClass *klass)
{
@@ -1447,14 +1323,10 @@ bst_piano_roll_class_init (BstPianoRollClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GxkScrollCanvasClass *scroll_canvas_class = GXK_SCROLL_CANVAS_CLASS (klass);
-
gobject_class->dispose = bst_piano_roll_dispose;
gobject_class->finalize = bst_piano_roll_finalize;
-
object_class->destroy = bst_piano_roll_destroy;
-
widget_class->map = bst_piano_roll_map;
-
scroll_canvas_class->hscrollable = TRUE;
scroll_canvas_class->vscrollable = TRUE;
scroll_canvas_class->get_layout = piano_roll_get_layout;
@@ -1466,12 +1338,9 @@ bst_piano_roll_class_init (BstPianoRollClass *klass)
scroll_canvas_class->update_adjustments = piano_roll_update_adjustments;
scroll_canvas_class->adjustment_changed = piano_roll_adjustment_changed;
scroll_canvas_class->handle_drag = piano_roll_handle_drag;
-
bst_skin_config_add_notify ((BstSkinConfigNotify) piano_roll_class_setup_skin, klass);
piano_roll_class_setup_skin (klass);
-
klass->canvas_clicked = NULL;
-
signal_canvas_drag = g_signal_new ("canvas-drag", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BstPianoRollClass, canvas_drag),
NULL, NULL,
diff --git a/beast-gtk/bstpianoroll.hh b/beast-gtk/bstpianoroll.hh
index 9e6c9e7..625b087 100644
--- a/beast-gtk/bstpianoroll.hh
+++ b/beast-gtk/bstpianoroll.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PIANO_ROLL_H__
#define __BST_PIANO_ROLL_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_PIANO_ROLL (bst_piano_roll_get_type ())
#define BST_PIANO_ROLL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PIANO_ROLL, BstPianoRoll))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_PIANO_ROLL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PIANO_ROLL))
#define BST_IS_PIANO_ROLL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PIANO_ROLL))
#define BST_PIANO_ROLL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PIANO_ROLL, BstPianoRollClass))
-
-
/* --- typedefs & enums --- */
typedef struct _BstPianoRoll BstPianoRoll;
typedef struct _BstPianoRollClass BstPianoRollClass;
@@ -24,8 +19,6 @@ typedef enum /*< skip >*/
BST_PIANO_ROLL_MARKER_POINTER,
BST_PIANO_ROLL_MARKER_SELECT
} BstPianoRollMarkerType;
-
-
/* --- structures & typedefs --- */
typedef struct {
GXK_SCROLL_CANVAS_DRAG_FIELDS;
@@ -41,31 +34,25 @@ typedef struct {
struct _BstPianoRoll
{
GxkScrollCanvas parent_instance;
-
SfiProxy proxy;
SfiProxy song;
BsePartLinkSeq*plinks;
gint min_note;
gint max_note;
guint vzoom;
-
/* horizontal layout */
guint ppqn; /* parts per quarter note */
guint qnpt; /* quarter notes per tact */
guint max_ticks; /* in ticks */
gfloat hzoom;
-
/* last drag state */
guint start_tick;
gint start_note;
guint start_valid : 1;
-
guint draw_qn_grid : 1;
guint draw_qqn_grid : 1;
-
/* slight hack */
guint release_closes_toplevel : 1;
-
/* selection rectangle */
int selection_tick;
int selection_duration;
@@ -75,7 +62,6 @@ struct _BstPianoRoll
struct _BstPianoRollClass
{
GxkScrollCanvasClass parent_class;
-
void (*canvas_drag) (BstPianoRoll *self,
BstPianoRollDrag *drag);
void (*canvas_clicked) (BstPianoRoll *proll,
@@ -90,8 +76,6 @@ struct _BstPianoRollClass
gint note,
GdkEvent *event);
};
-
-
/* --- prototypes --- */
GType bst_piano_roll_get_type (void);
void bst_piano_roll_set_proxy (BstPianoRoll *self,
@@ -113,8 +97,5 @@ void bst_piano_roll_set_marker (BstPianoRoll *self,
guint mark_index,
guint position,
BstPianoRollMarkerType mtype);
-
-
G_END_DECLS
-
#endif /* __BST_PIANO_ROLL_H__ */
diff --git a/beast-gtk/bstpianorollctrl.cc b/beast-gtk/bstpianorollctrl.cc
index 95ee93e..65b2af3 100644
--- a/beast-gtk/bstpianorollctrl.cc
+++ b/beast-gtk/bstpianorollctrl.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstpianorollctrl.hh"
#include "bsteventrollctrl.hh"
-
-
#define NOTE_LENGTH(self) ((self)->note_rtools->action_id)
#define QUANTIZATION(self) ((self)->quant_rtools->action_id)
#define HAVE_OBJECT (1 << 31)
-
-
/* --- prototypes --- */
static gboolean bst_piano_roll_controller_check_action (BstPianoRollController *self,
gulong action_id,
@@ -20,11 +16,8 @@ static void controller_piano_drag (BstPianoRollController *self,
BstPianoRollDrag *drag);
static void controller_update_canvas_cursor (BstPianoRollController *self,
BstCommonRollTool tool);
-
-
/* --- variables --- */
static BsePartNoteSeq *clipboard_pseq = NULL;
-
/* --- actions --- */
enum {
ACTION_NONE = BST_COMMON_ROLL_TOOL_LAST,
@@ -32,7 +25,6 @@ enum {
ACTION_SELECT_NONE,
ACTION_SELECT_INVERT,
};
-
/* --- functions --- */
GxkActionList*
bst_piano_roll_controller_select_actions (BstPianoRollController *self)
@@ -53,7 +45,6 @@ bst_piano_roll_controller_select_actions (BstPianoRollController *self)
self);
return alist;
}
-
GxkActionList*
bst_piano_roll_controller_canvas_actions (BstPianoRollController *self)
{
@@ -74,7 +65,6 @@ bst_piano_roll_controller_canvas_actions (BstPianoRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
GxkActionList*
bst_piano_roll_controller_note_actions (BstPianoRollController *self)
{
@@ -101,7 +91,6 @@ bst_piano_roll_controller_note_actions (BstPianoRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
GxkActionList*
bst_piano_roll_controller_quant_actions (BstPianoRollController *self)
{
@@ -132,7 +121,6 @@ bst_piano_roll_controller_quant_actions (BstPianoRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
void
bst_piano_roll_controller_set_clipboard (BsePartNoteSeq *pseq)
{
@@ -142,30 +130,24 @@ bst_piano_roll_controller_set_clipboard (BsePartNoteSeq *pseq)
if (clipboard_pseq)
bst_event_roll_controller_set_clipboard (NULL);
}
-
BsePartNoteSeq*
bst_piano_roll_controller_get_clipboard (void)
{
return clipboard_pseq;
}
-
static void
controller_reset_canvas_cursor (BstPianoRollController *self)
{
controller_update_canvas_cursor (self, BstCommonRollTool (self->canvas_rtools->action_id));
}
-
BstPianoRollController*
bst_piano_roll_controller_new (BstPianoRoll *proll)
{
BstPianoRollController *self;
-
g_return_val_if_fail (BST_IS_PIANO_ROLL (proll), NULL);
-
self = g_new0 (BstPianoRollController, 1);
self->proll = proll;
self->ref_count = 1;
-
self->ref_count++;
g_signal_connect_data (proll, "canvas-drag",
G_CALLBACK (controller_canvas_drag),
@@ -190,24 +172,19 @@ bst_piano_roll_controller_new (BstPianoRoll *proll)
controller_reset_canvas_cursor (self);
return self;
}
-
BstPianoRollController*
bst_piano_roll_controller_ref (BstPianoRollController *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count >= 1, NULL);
-
self->ref_count++;
-
return self;
}
-
void
bst_piano_roll_controller_unref (BstPianoRollController *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count >= 1);
-
self->ref_count--;
if (!self->ref_count)
{
@@ -220,7 +197,6 @@ bst_piano_roll_controller_unref (BstPianoRollController *self)
g_free (self);
}
}
-
static gboolean
bst_piano_roll_controller_check_action (BstPianoRollController *self,
gulong action_id,
@@ -236,7 +212,6 @@ bst_piano_roll_controller_check_action (BstPianoRollController *self,
}
return FALSE;
}
-
static void
bst_piano_roll_controller_exec_action (BstPianoRollController *self,
gulong action_id)
@@ -264,7 +239,6 @@ bst_piano_roll_controller_exec_action (BstPianoRollController *self,
}
gxk_widget_update_actions_downwards (self->proll);
}
-
static BstCommonRollTool
piano_canvas_button_tool (BstPianoRollController *self,
guint button,
@@ -336,16 +310,13 @@ piano_canvas_button_tool (BstPianoRollController *self,
}
return BST_COMMON_ROLL_TOOL_NONE;
}
-
void
bst_piano_roll_controller_clear (BstPianoRollController *self)
{
BsePartNoteSeq *pseq;
SfiProxy proxy;
guint i;
-
g_return_if_fail (self != NULL);
-
proxy = self->proll->proxy;
pseq = bse_part_list_selected_notes (proxy);
bse_item_group_undo (proxy, "Clear Selection");
@@ -356,16 +327,13 @@ bst_piano_roll_controller_clear (BstPianoRollController *self)
}
bse_item_ungroup_undo (proxy);
}
-
void
bst_piano_roll_controller_cut (BstPianoRollController *self)
{
BsePartNoteSeq *pseq;
SfiProxy proxy;
guint i;
-
g_return_if_fail (self != NULL);
-
proxy = self->proll->proxy;
pseq = bse_part_list_selected_notes (proxy);
bse_item_group_undo (proxy, "Cut Selection");
@@ -377,29 +345,23 @@ bst_piano_roll_controller_cut (BstPianoRollController *self)
bst_piano_roll_controller_set_clipboard (pseq);
bse_item_ungroup_undo (proxy);
}
-
gboolean
bst_piano_roll_controller_copy (BstPianoRollController *self)
{
BsePartNoteSeq *pseq;
SfiProxy proxy;
-
g_return_val_if_fail (self != NULL, FALSE);
-
proxy = self->proll->proxy;
pseq = bse_part_list_selected_notes (proxy);
bst_piano_roll_controller_set_clipboard (pseq);
return pseq && pseq->n_pnotes;
}
-
void
bst_piano_roll_controller_paste (BstPianoRollController *self)
{
BsePartNoteSeq *pseq;
SfiProxy proxy;
-
g_return_if_fail (self != NULL);
-
proxy = self->proll->proxy;
pseq = bst_piano_roll_controller_get_clipboard ();
if (pseq)
@@ -438,14 +400,12 @@ bst_piano_roll_controller_paste (BstPianoRollController *self)
bse_item_ungroup_undo (proxy);
}
}
-
gboolean
bst_piano_roll_controller_clipboard_full (BstPianoRollController *self)
{
BsePartNoteSeq *pseq = bst_piano_roll_controller_get_clipboard ();
return pseq && pseq->n_pnotes;
}
-
gboolean
bst_piano_roll_controller_has_selection (BstPianoRollController *self,
guint64 action_stamp)
@@ -464,7 +424,6 @@ bst_piano_roll_controller_has_selection (BstPianoRollController *self,
}
return self->cached_n_notes > 0;
}
-
guint
bst_piano_roll_controller_quantize (BstPianoRollController *self,
guint fine_tick)
@@ -472,7 +431,6 @@ bst_piano_roll_controller_quantize (BstPianoRollController *self,
BseSongTiming *timing;
guint quant, tick, qtick;
g_return_val_if_fail (self != NULL, fine_tick);
-
timing = bse_part_get_timing (self->proll->proxy, fine_tick);
if (QUANTIZATION (self) == BST_QUANTIZE_NONE)
quant = 1;
@@ -488,7 +446,6 @@ bst_piano_roll_controller_quantize (BstPianoRollController *self,
tick = timing->tick + qtick;
return tick;
}
-
static void
controller_update_canvas_cursor (BstPianoRollController *self,
BstCommonRollTool tool)
@@ -519,7 +476,6 @@ controller_update_canvas_cursor (BstPianoRollController *self,
break;
}
}
-
static gboolean
check_hoverlap (SfiProxy part,
guint tick,
@@ -532,7 +488,6 @@ check_hoverlap (SfiProxy part,
{
BsePartNoteSeq *pseq = bse_part_check_overlap (part, tick, duration, note);
BsePartNote *pnote;
-
if (pseq->n_pnotes == 0)
return FALSE; /* no overlap */
if (pseq->n_pnotes > 1)
@@ -544,7 +499,6 @@ check_hoverlap (SfiProxy part,
}
return TRUE;
}
-
static void
move_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -565,14 +519,12 @@ move_start (BstPianoRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
move_group_motion (BstPianoRollController *self,
BstPianoRollDrag *drag)
{
SfiProxy part = self->proll->proxy;
int new_tick, old_note, new_note, delta_tick, delta_note;
-
new_tick = MAX (drag->current_tick, self->xoffset) - self->xoffset;
new_tick = bst_piano_roll_controller_quantize (self, new_tick);
old_note = self->obj_note;
@@ -602,20 +554,17 @@ move_group_motion (BstPianoRollController *self,
}
bse_item_ungroup_undo (part);
}
-
static void
move_motion (BstPianoRollController *self,
BstPianoRollDrag *drag)
{
SfiProxy part = self->proll->proxy;
bool note_changed;
-
if (self->sel_pseq)
{
move_group_motion (self, drag);
return;
}
-
int new_tick = MAX (drag->current_tick, self->xoffset) - self->xoffset;
new_tick = bst_piano_roll_controller_quantize (self, new_tick);
note_changed = self->obj_note != drag->current_note;
@@ -638,7 +587,6 @@ move_motion (BstPianoRollController *self,
bse_item_ungroup_undo (part);
}
}
-
static void
move_abort (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -650,7 +598,6 @@ move_abort (BstPianoRollController *self,
}
gxk_status_set (GXK_STATUS_ERROR, _("Move Note"), _("Lost Note"));
}
-
static void
resize_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -658,7 +605,6 @@ resize_start (BstPianoRollController *self,
if (self->obj_id) /* got note for resize */
{
guint bound = self->obj_tick + self->obj_duration + 1;
-
/* set the fix-point (either note start or note end) */
if (drag->start_tick - self->obj_tick <= bound - drag->start_tick)
self->tick_bound = bound;
@@ -674,21 +620,18 @@ resize_start (BstPianoRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
resize_motion (BstPianoRollController *self,
BstPianoRollDrag *drag)
{
SfiProxy part = self->proll->proxy;
guint new_bound, new_tick, new_duration;
-
/* calc new note around fix-point */
new_tick = bst_piano_roll_controller_quantize (self, drag->current_tick);
new_bound = MAX (new_tick, self->tick_bound);
new_tick = MIN (new_tick, self->tick_bound);
new_duration = new_bound - new_tick;
new_duration = MAX (new_duration, 1) - 1;
-
/* apply new note size */
if ((self->obj_tick != new_tick || new_duration != self->obj_duration) &&
!check_hoverlap (part, new_tick, new_duration, self->obj_note,
@@ -714,14 +657,12 @@ resize_motion (BstPianoRollController *self,
bse_item_ungroup_undo (part);
}
}
-
static void
resize_abort (BstPianoRollController *self,
BstPianoRollDrag *drag)
{
gxk_status_set (GXK_STATUS_ERROR, _("Resize Note"), _("Lost Note"));
}
-
static void
delete_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -736,7 +677,6 @@ delete_start (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Delete Note"), _("No target"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
insert_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -758,7 +698,6 @@ insert_start (BstPianoRollController *self,
bst_status_eprintf (error, _("Insert Note"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
select_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -768,7 +707,6 @@ select_start (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_WAIT, _("Select Region"), NULL);
drag->state = GXK_DRAG_CONTINUE;
}
-
static void
select_motion (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -778,7 +716,6 @@ select_motion (BstPianoRollController *self,
guint end_tick = MAX (drag->start_tick, drag->current_tick);
gint min_note = MIN (drag->start_note, drag->current_note);
gint max_note = MAX (drag->start_note, drag->current_note);
-
bst_piano_roll_set_view_selection (drag->proll, start_tick, end_tick - start_tick, min_note, max_note);
if (drag->type == GXK_DRAG_DONE)
{
@@ -786,7 +723,6 @@ select_motion (BstPianoRollController *self,
bst_piano_roll_set_view_selection (drag->proll, 0, 0, 0, 0);
}
}
-
static void
select_abort (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -794,7 +730,6 @@ select_abort (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Select Region"), _("Aborted"));
bst_piano_roll_set_view_selection (drag->proll, 0, 0, 0, 0);
}
-
static void
vselect_start (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -804,7 +739,6 @@ vselect_start (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_WAIT, _("Vertical Select"), NULL);
drag->state = GXK_DRAG_CONTINUE;
}
-
static void
vselect_motion (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -812,7 +746,6 @@ vselect_motion (BstPianoRollController *self,
SfiProxy part = self->proll->proxy;
guint start_tick = MIN (drag->start_tick, drag->current_tick);
guint end_tick = MAX (drag->start_tick, drag->current_tick);
-
bst_piano_roll_set_view_selection (drag->proll, start_tick, end_tick - start_tick,
drag->proll->min_note, drag->proll->max_note);
if (drag->type == GXK_DRAG_DONE)
@@ -822,7 +755,6 @@ vselect_motion (BstPianoRollController *self,
bst_piano_roll_set_view_selection (drag->proll, 0, 0, 0, 0);
}
}
-
static void
vselect_abort (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -830,7 +762,6 @@ vselect_abort (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Vertical Region"), _("Aborted"));
bst_piano_roll_set_view_selection (drag->proll, 0, 0, 0, 0);
}
-
#if 0
static void
generic_abort (BstPianoRollController *self,
@@ -839,10 +770,8 @@ generic_abort (BstPianoRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Abortion"), NULL);
}
#endif
-
typedef void (*DragFunc) (BstPianoRollController *,
BstPianoRollDrag *);
-
void
controller_canvas_drag (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -860,12 +789,10 @@ controller_canvas_drag (BstPianoRollController *self,
{ BST_COMMON_ROLL_TOOL_VSELECT, vselect_start, vselect_motion, vselect_abort, },
};
guint i;
-
if (drag->type == GXK_DRAG_START)
{
BstCommonRollTool tool = BST_COMMON_ROLL_TOOL_NONE;
BsePartNoteSeq *pseq;
-
/* setup drag data */
pseq = bse_part_get_notes (drag->proll->proxy, drag->start_tick, drag->start_note);
if (pseq->n_pnotes)
@@ -892,7 +819,6 @@ controller_canvas_drag (BstPianoRollController *self,
self->sel_pseq = NULL;
self->xoffset = 0;
self->tick_bound = 0;
-
/* find drag tool */
tool = piano_canvas_button_tool (self, drag->button, self->obj_id > 0);
for (i = 0; i < G_N_ELEMENTS (tool_table); i++)
@@ -924,7 +850,6 @@ controller_canvas_drag (BstPianoRollController *self,
drag->type == GXK_DRAG_ABORT)
controller_reset_canvas_cursor (self);
}
-
void
controller_piano_drag (BstPianoRollController *self,
BstPianoRollDrag *drag)
@@ -933,9 +858,7 @@ controller_piano_drag (BstPianoRollController *self,
SfiProxy song = bse_item_get_parent (part);
SfiProxy project = song ? bse_item_get_parent (song) : 0;
SfiProxy track = song ? bse_song_find_track_for_part (song, part) : 0;
-
// g_printerr ("piano drag event, note=%d (valid=%d)", drag->current_note, drag->current_valid);
-
if (project && track)
{
if (drag->type == GXK_DRAG_START ||
@@ -952,7 +875,6 @@ controller_piano_drag (BstPianoRollController *self,
drag->state = GXK_DRAG_CONTINUE;
}
}
-
if (drag->type == GXK_DRAG_START ||
drag->type == GXK_DRAG_MOTION)
drag->state = GXK_DRAG_CONTINUE;
diff --git a/beast-gtk/bstpianorollctrl.hh b/beast-gtk/bstpianorollctrl.hh
index 6391e9f..54e650f 100644
--- a/beast-gtk/bstpianorollctrl.hh
+++ b/beast-gtk/bstpianorollctrl.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PIANO_ROLL_CONTROLLER_H__
#define __BST_PIANO_ROLL_CONTROLLER_H__
-
#include "bstpianoroll.hh"
-
G_BEGIN_DECLS
-
typedef struct {
/* misc data */
guint ref_count;
@@ -27,8 +24,6 @@ typedef struct {
guint64 cached_stamp;
guint cached_n_notes;
} BstPianoRollController;
-
-
/* --- API --- */
BstPianoRollController* bst_piano_roll_controller_new (BstPianoRoll *proll);
BstPianoRollController* bst_piano_roll_controller_ref (BstPianoRollController *self);
@@ -48,8 +43,5 @@ void bst_piano_roll_controller_paste (BstPianoRollController *self);
gboolean bst_piano_roll_controller_clipboard_full (BstPianoRollController *self);
gboolean bst_piano_roll_controller_has_selection (BstPianoRollController *self,
guint64 action_stamp);
-
-
G_END_DECLS
-
#endif /* __BST_PIANO_ROLL_CONTROLLER_H__ */
diff --git a/beast-gtk/bstplayback.cc b/beast-gtk/bstplayback.cc
index d3819a3..930ca09 100644
--- a/beast-gtk/bstplayback.cc
+++ b/beast-gtk/bstplayback.cc
@@ -1,28 +1,20 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstplayback.hh"
#include "bstapp.hh"
-
-
-
-
/* --- prototypes --- */
static void wave_oscillator_pcm_notify (BstPlayBackHandle *handle,
SfiNum tick_stamp,
guint pcm_position,
SfiProxy wosc);
-
-
/* --- functions --- */
BstPlayBackHandle*
bst_play_back_handle_new (void)
{
BstPlayBackHandle *handle;
-
handle = g_new0 (BstPlayBackHandle, 1);
handle->project = bse_server_use_new_project (BSE_SERVER, "# BEAST Play Back");
if (BST_DBG_EXT)
gxk_idle_show_widget (GTK_WIDGET (bst_app_new (handle->project)));
-
handle->snet = bse_project_create_csynth (handle->project, NULL);
bse_proxy_set (handle->snet, "auto_activate", TRUE, NULL);
handle->speaker = bse_snet_create_source (handle->snet, "BsePcmOutput");
@@ -39,7 +31,6 @@ bst_play_back_handle_new (void)
NULL);
return handle;
}
-
void
bst_play_back_handle_set (BstPlayBackHandle *handle,
SfiProxy esample,
@@ -48,22 +39,18 @@ bst_play_back_handle_set (BstPlayBackHandle *handle,
g_return_if_fail (handle != NULL);
if (esample)
g_return_if_fail (BSE_IS_EDITABLE_SAMPLE (esample));
-
bse_proxy_set (handle->constant, "frequency_1", osc_freq, NULL);
bse_wave_osc_set_from_editable_sample (handle->wosc1, esample);
bse_wave_osc_set_from_editable_sample (handle->wosc2, esample);
}
-
void
bst_play_back_handle_start (BstPlayBackHandle *handle)
{
BseErrorType error;
-
error = bse_project_play (handle->project);
if (error)
bst_status_eprintf (error, _("Playback"));
}
-
void
bst_play_back_handle_seek_perc (BstPlayBackHandle *handle,
gfloat perc)
@@ -77,14 +64,12 @@ bst_play_back_handle_seek_perc (BstPlayBackHandle *handle,
handle->discard_next_notify = TRUE;
bse_item_seq_free (iseq);
}
-
void
bst_play_back_handle_stop (BstPlayBackHandle *handle)
{
bse_project_stop (handle->project);
bst_play_back_handle_pcm_notify (handle, 0, NULL, NULL);
}
-
void
bst_play_back_handle_toggle (BstPlayBackHandle *handle)
{
@@ -93,13 +78,11 @@ bst_play_back_handle_toggle (BstPlayBackHandle *handle)
else
bst_play_back_handle_start (handle);
}
-
gboolean
bst_play_back_handle_is_playing (BstPlayBackHandle *handle)
{
return bse_project_is_playing (handle->project);
}
-
static void
wave_oscillator_pcm_notify (BstPlayBackHandle *handle,
SfiNum tick_stamp,
@@ -107,20 +90,16 @@ wave_oscillator_pcm_notify (BstPlayBackHandle *handle,
SfiProxy wosc)
{
gboolean discard_next_notify = handle->discard_next_notify;
-
g_assert (handle->wosc1 == wosc);
-
handle->waiting_for_notify = FALSE;
handle->discard_next_notify = FALSE;
if (handle->pcm_notify && !discard_next_notify)
handle->pcm_notify (handle->pcm_data, tick_stamp, pcm_position);
}
-
static gboolean
pcm_timer (gpointer data)
{
BstPlayBackHandle *handle = (BstPlayBackHandle*) data;
-
GDK_THREADS_ENTER ();
if (!handle->waiting_for_notify)
{
@@ -128,10 +107,8 @@ pcm_timer (gpointer data)
handle->waiting_for_notify = TRUE;
}
GDK_THREADS_LEAVE ();
-
return TRUE;
}
-
void
bst_play_back_handle_pcm_notify (BstPlayBackHandle *handle,
guint timeout,
@@ -159,7 +136,6 @@ bst_play_back_handle_pcm_notify (BstPlayBackHandle *handle,
pcm_timer, handle, NULL);
}
}
-
void
bst_play_back_handle_time_pcm_notify (BstPlayBackHandle *handle,
guint timeout)
@@ -172,19 +148,14 @@ bst_play_back_handle_time_pcm_notify (BstPlayBackHandle *handle,
pcm_timer, handle, NULL);
}
}
-
void
bst_play_back_handle_destroy (BstPlayBackHandle *handle)
{
g_return_if_fail (handle != NULL);
-
bst_play_back_handle_stop (handle);
-
bse_proxy_disconnect (handle->wosc1, "any_signal", wave_oscillator_pcm_notify, handle, NULL);
-
if (handle->pcm_timeout)
g_source_remove (handle->pcm_timeout);
-
bse_item_unuse (handle->project);
g_free (handle);
}
diff --git a/beast-gtk/bstplayback.hh b/beast-gtk/bstplayback.hh
index 902358d..d1cdac4 100644
--- a/beast-gtk/bstplayback.hh
+++ b/beast-gtk/bstplayback.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PLAY_BACK_H__
#define __BST_PLAY_BACK_H__
-
#include "bstutils.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- typedefs & structures --- */
typedef void (*BstPlayBackNotify) (gpointer data,
SfiNum tick_stamp,
@@ -27,8 +23,6 @@ typedef struct
guint waiting_for_notify : 1;
guint discard_next_notify : 1;
} BstPlayBackHandle;
-
-
/* --- functions --- */
BstPlayBackHandle* bst_play_back_handle_new (void);
void bst_play_back_handle_set (BstPlayBackHandle *handle,
@@ -48,12 +42,7 @@ void bst_play_back_handle_time_pcm_notify (BstPlayBackHandle *handle,
gboolean bst_play_back_handle_is_playing (BstPlayBackHandle *handle);
gboolean bst_play_back_handle_done (BstPlayBackHandle *handle);
void bst_play_back_handle_destroy (BstPlayBackHandle *handle);
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_PLAY_BACK_H__ */
diff --git a/beast-gtk/bstplaylist.cc b/beast-gtk/bstplaylist.cc
index 3e5bd90..1ebdb84 100644
--- a/beast-gtk/bstplaylist.cc
+++ b/beast-gtk/bstplaylist.cc
@@ -1,9 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstplaylist.hh"
-
#include "bstmenus.hh"
-
-
/* --- drop target --- */
static const gchar *target_xpm[] = {
"16 16 6 1", " c None", "# c #DF4444", ": c #E78484", "- c ##F85E5E", "X c #373684", "| c #7E7CF8",
@@ -24,8 +21,6 @@ static const gchar *target_xpm[] = {
" :###:###: ",
" :###: ",
};
-
-
/* --- global play_list variables --- */
static GtkWidget *bst_play_list_drag_window_pattern_icon = NULL;
static GtkWidget *bst_play_list_drag_window_pattern_group_icon = NULL;
@@ -33,21 +28,16 @@ static GtkWidget *bst_play_list_drop_spot_pattern = NULL;
static GtkWidget *bst_play_list_drop_spot_pattern_group = NULL;
static GdkAtom atom_beast_pattern_group_pointer = 0;
static GdkAtom atom_beast_pattern_pointer = 0;
-
-
/* --- bug workarounds --- */
static void
container_remove (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
}
-
#include "bstdragpattern.cc" /* draggable pattern widgets */
#include "bstdraggroup.cc" /* draggable pattern group widgets */
-
/* --- prototypes --- */
static void bst_play_list_class_init (BstPlayListClass *klass);
static void bst_play_list_init (BstPlayList *play_list);
@@ -76,20 +66,15 @@ static void group_list_drag_data_received (GtkWidget *group_list,
guint info,
guint time,
BstPlayList *plist);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static BstPlayListClass *bst_play_list_class = NULL;
static guint drag_windows_ref_count = 0;
-
-
/* --- functions --- */
GtkType
bst_play_list_get_type (void)
{
static GtkType play_list_type = 0;
-
if (!play_list_type)
{
GtkTypeInfo play_list_info =
@@ -103,38 +88,29 @@ bst_play_list_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
play_list_type = gtk_type_unique (GTK_TYPE_VPANED, &play_list_info);
}
-
return play_list_type;
}
-
static void
bst_play_list_class_init (BstPlayListClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
-
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
bst_play_list_class = klass;
parent_class = gtk_type_class (GTK_TYPE_VPANED);
-
object_class->destroy = bst_play_list_destroy;
-
atom_beast_pattern_pointer = gdk_atom_intern ("_BEAST_PATTERN_POINTER", FALSE);
atom_beast_pattern_group_pointer = gdk_atom_intern ("_BEAST_PATTERN_GROUP_POINTER", FALSE);
}
-
static void
bst_play_list_init (BstPlayList *plist)
{
static const GtkTargetEntry target = { "_BEAST_PATTERN_GROUP_POINTER", GTK_TARGET_SAME_APP, 0 };
GtkWidget *sw, *vbox, *any;
-
plist->song = NULL;
-
/* setup pattern list
*/
vbox = gtk_widget_new (GTK_TYPE_VBOX,
@@ -163,7 +139,6 @@ bst_play_list_init (BstPlayList *plist)
NULL);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), plist->pattern_list);
gxk_widget_modify_bg_as_base (plist->pattern_list->parent);
-
/* setup group list
*/
vbox = gtk_widget_new (GTK_TYPE_VBOX,
@@ -191,7 +166,6 @@ bst_play_list_init (BstPlayList *plist)
NULL);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), plist->group_list);
gxk_widget_modify_bg_as_base (plist->group_list->parent);
-
/* setup group list as drag destination
*/
gtk_drag_dest_set (plist->group_list,
@@ -204,14 +178,11 @@ bst_play_list_init (BstPlayList *plist)
"signal::drag_data_received", group_list_drag_data_received, plist,
"signal::drag_drop", group_list_drag_drop, plist,
NULL);
-
-
/* build insertion spots and drag_windows
*/
if (!drag_windows_ref_count)
{
GtkWidget *drag_widget, *hbox, *frame;
-
drag_widget = gtk_widget_new (GTK_TYPE_FRAME,
"visible", TRUE,
"shadow", GTK_SHADOW_IN,
@@ -220,7 +191,6 @@ bst_play_list_init (BstPlayList *plist)
gtk_widget_ref (drag_widget);
gtk_object_sink (GTK_OBJECT (drag_widget));
bst_play_list_drop_spot_pattern = drag_widget;
-
hbox = gtk_widget_new (GTK_TYPE_HBOX,
"visible", TRUE,
NULL);
@@ -251,12 +221,10 @@ bst_play_list_init (BstPlayList *plist)
gtk_object_sink (GTK_OBJECT (drag_widget));
gxk_widget_force_bg_clear (drag_widget);
bst_play_list_drop_spot_pattern_group = drag_widget;
-
drag_widget = bst_drag_window_from_stock (BST_STOCK_PATTERN);
gtk_widget_ref (drag_widget);
gtk_object_sink (GTK_OBJECT (drag_widget));
bst_play_list_drag_window_pattern_icon = drag_widget;
-
drag_widget = bst_drag_window_from_stock (BST_STOCK_PATTERN_GROUP);
gtk_widget_ref (drag_widget);
gtk_object_sink (GTK_OBJECT (drag_widget));
@@ -265,51 +233,41 @@ bst_play_list_init (BstPlayList *plist)
drag_windows_ref_count += 1;
plist->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
}
-
static void
bst_play_list_destroy (GtkObject *object)
{
BstPlayList *plist = BST_PLAY_LIST (object);
-
bst_play_list_set_song (plist, NULL);
-
if (plist->size_group) /* catch first destroy only */
{
g_object_unref (plist->size_group);
plist->size_group = NULL;
-
/* destroy drag_windows
*/
drag_windows_ref_count -= 1;
if (!drag_windows_ref_count)
{
GtkWidget *drag_widget;
-
drag_widget = bst_play_list_drop_spot_pattern_group;
bst_play_list_drop_spot_pattern_group = NULL;
gtk_widget_destroy (drag_widget);
gtk_widget_unref (drag_widget);
-
drag_widget = bst_play_list_drop_spot_pattern;
bst_play_list_drop_spot_pattern = NULL;
gtk_widget_destroy (drag_widget);
gtk_widget_unref (drag_widget);
-
drag_widget = bst_play_list_drag_window_pattern_icon;
bst_play_list_drag_window_pattern_icon = NULL;
gtk_widget_destroy (drag_widget);
gtk_widget_unref (drag_widget);
-
drag_widget = bst_play_list_drag_window_pattern_group_icon;
bst_play_list_drag_window_pattern_group_icon = NULL;
gtk_widget_destroy (drag_widget);
gtk_widget_unref (drag_widget);
}
}
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static gboolean
group_list_drag_motion (GtkWidget *group_list,
GdkDragContext *context,
@@ -319,7 +277,6 @@ group_list_drag_motion (GtkWidget *group_list,
BstPlayList *plist)
{
GtkWidget *drag_source = gtk_drag_get_source_widget (context);
-
if (drag_source && /* check SAME_APP */
gtk_widget_is_ancestor (drag_source, GTK_WIDGET (plist)) && /* check widget branch */
context->targets && /* check target type */
@@ -327,37 +284,29 @@ group_list_drag_motion (GtkWidget *group_list,
{
guint action = context->actions & context->suggested_action;
gint old_pos, new_pos;
-
if (action & GDK_ACTION_LINK)
gdk_drag_status (context, action & GDK_ACTION_LINK, time);
else if (action & GDK_ACTION_COPY)
gdk_drag_status (context, action & GDK_ACTION_COPY, time);
else
gdk_drag_status (context, action & GDK_ACTION_MOVE, time);
-
if (action & (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK))
gtk_widget_show (bst_play_list_drop_spot_pattern_group);
else
gtk_widget_hide (bst_play_list_drop_spot_pattern_group);
-
if (!bst_play_list_drop_spot_pattern_group->parent)
gtk_box_pack_start (GTK_BOX (group_list), bst_play_list_drop_spot_pattern_group, FALSE, TRUE, 1);
-
new_pos = bst_container_get_insertion_position (GTK_CONTAINER (group_list),
FALSE, y,
bst_play_list_drop_spot_pattern_group,
&old_pos);
if (new_pos != old_pos)
gtk_box_reorder_child (GTK_BOX (group_list), bst_play_list_drop_spot_pattern_group, new_pos);
-
return TRUE;
}
-
container_remove (bst_play_list_drop_spot_pattern_group); /* FIXME: GTKFIX, DND breaks on tree alterations */
-
return FALSE;
}
-
static void
group_list_drag_leave (GtkWidget *group_list,
GdkDragContext *context,
@@ -366,7 +315,6 @@ group_list_drag_leave (GtkWidget *group_list,
{
container_remove (bst_play_list_drop_spot_pattern_group);
}
-
static gboolean
group_list_drag_drop (GtkWidget *group_list,
GdkDragContext *context,
@@ -376,20 +324,16 @@ group_list_drag_drop (GtkWidget *group_list,
BstPlayList *plist)
{
GtkWidget *drag_source = gtk_drag_get_source_widget (context);
-
if (drag_source && /* check SAME_APP */
gtk_widget_is_ancestor (drag_source, GTK_WIDGET (plist)) && /* check widget branch */
context->targets && /* check target type */
context->targets->data == atom_beast_pattern_group_pointer)
{
gtk_drag_get_data (group_list, context, context->targets->data, time);
-
return TRUE;
}
-
return FALSE;
}
-
static void
group_list_drag_data_received (GtkWidget *group_list,
GdkDragContext *context,
@@ -403,21 +347,16 @@ group_list_drag_data_received (GtkWidget *group_list,
gpointer drag_contents;
gint position;
guint action;
-
g_return_if_fail (selection_data->type == atom_beast_pattern_group_pointer);
g_return_if_fail (selection_data->format == 8);
g_return_if_fail (selection_data->length == sizeof (gpointer));
-
action = context->actions & context->suggested_action;
g_return_if_fail ((action & (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)) != 0);
-
drag_contents = *((gpointer*) selection_data->data);
g_return_if_fail (BSE_IS_PATTERN_GROUP (drag_contents));
-
position = bst_container_get_insertion_position (GTK_CONTAINER (group_list),
FALSE, y,
bst_play_list_drop_spot_pattern_group, NULL);
-
if (bst_play_list_drop_spot_pattern_group->parent) // FIXME GTKFIX (1.2.7 bug)
{
container_remove (bst_play_list_drop_spot_pattern_group);
@@ -425,7 +364,6 @@ group_list_drag_data_received (GtkWidget *group_list,
gtk_box_reorder_child (GTK_BOX (bst_play_list_drop_spot_pattern_group->parent),
bst_play_list_drop_spot_pattern_group, -1);
}
-
if (context->actions & GDK_ACTION_COPY)
bse_song_insert_pattern_group_copy (plist->song, drag_contents, position);
else if (context->actions & GDK_ACTION_MOVE)
@@ -433,7 +371,6 @@ group_list_drag_data_received (GtkWidget *group_list,
else if (context->actions & GDK_ACTION_LINK)
bse_song_insert_pattern_group_link (plist->song, drag_contents, position);
}
-
static void
song_item_added (BseSong *song,
BseItem *item,
@@ -442,14 +379,12 @@ song_item_added (BseSong *song,
if (BSE_IS_PATTERN (item))
{
BstDragPattern *drag_pattern = bst_drag_pattern_new (BSE_PATTERN (item), NULL, 0, FALSE);
-
gtk_container_add_with_properties (GTK_CONTAINER (plist->pattern_list), drag_pattern->widget,
"expand", FALSE,
NULL);
gtk_widget_queue_resize (plist->pattern_list);
}
}
-
static void
song_pattern_group_insert (BseSong *song,
BsePatternGroup *pgroup,
@@ -458,14 +393,12 @@ song_pattern_group_insert (BseSong *song,
gboolean ignore_first_insert)
{
BstDragGroup *drag_group = bst_drag_group_new (pgroup, position, ignore_first_insert);
-
gtk_size_group_add_widget (plist->size_group, drag_group->name);
gtk_container_add_with_properties (GTK_CONTAINER (plist->group_list), drag_group->widget,
"expand", FALSE,
"position", position,
NULL);
}
-
static void
song_pattern_group_inserted (BseSong *song,
BsePatternGroup *pgroup,
@@ -474,7 +407,6 @@ song_pattern_group_inserted (BseSong *song,
{
song_pattern_group_insert (song, pgroup, position, plist, FALSE); /* ignore_first_insert: TRUE */
}
-
void
bst_play_list_set_song (BstPlayList *plist,
BseSong *song)
@@ -482,7 +414,6 @@ bst_play_list_set_song (BstPlayList *plist,
g_return_if_fail (BST_IS_PLAY_LIST (plist));
if (song)
g_return_if_fail (BSE_IS_SONG (song));
-
if (plist->song)
{
g_object_disconnect (BSE_OBJECT (plist->song),
@@ -497,21 +428,17 @@ bst_play_list_set_song (BstPlayList *plist,
{
BswIterProxy *iter;
guint i;
-
/* setup pattern list
*/
g_object_connect (BSE_OBJECT (plist->song),
"signal::item_added", song_item_added, plist,
NULL);
-
for (iter = bsw_container_list_items (BSE_OBJECT_ID (plist->song)); bsw_iter_n_left (iter); bsw_iter_next (iter))
{
SfiProxy item = bsw_iter_get_proxy (iter);
-
song_item_added (plist->song, bse_object_from_id (item), plist);
}
bsw_iter_free (iter);
-
/* setup pattern groups
*/
g_object_connect (BSE_OBJECT (plist->song),
@@ -521,34 +448,25 @@ bst_play_list_set_song (BstPlayList *plist,
song_pattern_group_insert (plist->song, plist->song->pgroups[i], i, plist, FALSE);
}
}
-
void
bst_play_list_rebuild (BstPlayList *plist)
{
g_return_if_fail (BST_IS_PLAY_LIST (plist));
-
if (plist->song)
{
BseSong *song = plist->song;
-
bse_object_ref (BSE_OBJECT (song));
-
bst_play_list_set_song (plist, NULL);
bst_play_list_set_song (plist, song);
-
bse_object_unref (BSE_OBJECT (song));
}
}
-
GtkWidget*
bst_play_list_new (BseSong *song)
{
GtkWidget *play_list;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
play_list = gtk_widget_new (BST_TYPE_PLAY_LIST, NULL);
bst_play_list_set_song (BST_PLAY_LIST (play_list), song);
-
return play_list;
}
diff --git a/beast-gtk/bstplaylist.hh b/beast-gtk/bstplaylist.hh
index 671c98f..8c5c784 100644
--- a/beast-gtk/bstplaylist.hh
+++ b/beast-gtk/bstplaylist.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PLAY_LIST_H__
#define __BST_PLAY_LIST_H__
-
#include "bstutils.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_PLAY_LIST (bst_play_list_get_type ())
#define BST_PLAY_LIST(object) (GTK_CHECK_CAST ((object), BST_TYPE_PLAY_LIST, BstPlayList))
@@ -16,17 +12,13 @@ extern "C" {
#define BST_IS_PLAY_LIST(object) (GTK_CHECK_TYPE ((object), BST_TYPE_PLAY_LIST))
#define BST_IS_PLAY_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_PLAY_LIST))
#define BST_PLAY_LIST_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_PLAY_LIST, BstPlayListClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstPlayList BstPlayList;
typedef struct _BstPlayListClass BstPlayListClass;
struct _BstPlayList
{
GtkVPaned parent_object;
-
BseSong *song;
-
GtkWidget *pattern_list;
GtkWidget *group_list;
GtkSizeGroup *size_group;
@@ -35,19 +27,13 @@ struct _BstPlayListClass
{
GtkVPanedClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_play_list_get_type (void);
GtkWidget* bst_play_list_new (BseSong *song);
void bst_play_list_set_song (BstPlayList *plist,
BseSong *song);
void bst_play_list_rebuild (BstPlayList *plist);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_PLAY_LIST_H__ */
diff --git a/beast-gtk/bstpreferences.cc b/beast-gtk/bstpreferences.cc
index c83c69a..71922c2 100644
--- a/beast-gtk/bstpreferences.cc
+++ b/beast-gtk/bstpreferences.cc
@@ -7,24 +7,19 @@
#include "bstpatternctrl.hh"
#include "topconfig.h" /* BST_VERSION */
#include "bstparam.hh"
-
-
/* --- prototypes --- */
static void bst_preferences_destroy (GtkObject *object);
static GtkWidget* bst_preferences_build_rec_editor (SfiRec *rec,
SfiRecFields fields,
SfiRing **bparam_list);
-
/* --- functions --- */
G_DEFINE_TYPE (BstPreferences, bst_preferences, GTK_TYPE_VBOX);
-
static void
bst_preferences_class_init (BstPreferencesClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = bst_preferences_destroy;
}
-
static void
bst_preferences_init (BstPreferences *self)
{
@@ -33,7 +28,6 @@ bst_preferences_init (BstPreferences *self)
GParamSpec *pspec;
GtkWidget *pchild;
SfiRec *rec;
-
self->notebook = (GtkNotebook*) g_object_new (GXK_TYPE_NOTEBOOK,
"visible", TRUE,
"parent", self,
@@ -43,35 +37,29 @@ bst_preferences_init (BstPreferences *self)
"border_width", 5,
NULL);
gxk_nullify_in_object (self, &self->notebook);
-
pspec = bst_gconfig_pspec ();
self->rec_gconfig = bst_gconfig_to_rec (bst_gconfig_get_global ());
pchild = bst_preferences_build_rec_editor (self->rec_gconfig, sfi_pspec_get_rec_fields (pspec), &self->params_gconfig);
gxk_notebook_append (self->notebook, pchild, "BEAST", FALSE);
-
kbinding = bst_pattern_controller_piano_keys();
iseq = bst_key_binding_get_item_seq (kbinding);
self->box_piano_keys = bst_key_binding_box (kbinding->binding_name, kbinding->n_funcs, kbinding->funcs, TRUE);
bst_key_binding_box_set (self->box_piano_keys, iseq);
bst_key_binding_item_seq_free (iseq);
gxk_notebook_append (self->notebook, self->box_piano_keys, _("Piano Keys"), FALSE);
-
kbinding = bst_pattern_controller_generic_keys();
iseq = bst_key_binding_get_item_seq (kbinding);
self->box_generic_keys = bst_key_binding_box (kbinding->binding_name, kbinding->n_funcs, kbinding->funcs, FALSE);
bst_key_binding_box_set (self->box_generic_keys, iseq);
bst_key_binding_item_seq_free (iseq);
gxk_notebook_append (self->notebook, self->box_generic_keys, _("Generic Keys"), FALSE);
-
self->box_msg_absorb_config = bst_msg_absorb_config_box();
bst_msg_absorb_config_box_set (self->box_msg_absorb_config, bst_msg_absorb_config_get_global());
gxk_notebook_append (self->notebook, self->box_msg_absorb_config, _("Messages"), FALSE);
-
pspec = bst_skin_config_pspec ();
self->rec_skin = bst_skin_config_to_rec (bst_skin_config_get_global ());
pchild = bst_preferences_build_rec_editor (self->rec_skin, sfi_pspec_get_rec_fields (pspec), &self->params_skin);
gxk_notebook_append (self->notebook, pchild, _("Skin"), FALSE);
-
pspec = bse_proxy_get_pspec (BSE_SERVER, "bse-preferences");
self->bsepspec = g_param_spec_ref (pspec);
bse_proxy_get (BSE_SERVER, "bse-preferences", &rec, NULL);
@@ -79,12 +67,10 @@ bst_preferences_init (BstPreferences *self)
pchild = bst_preferences_build_rec_editor (self->bserec, sfi_pspec_get_rec_fields (pspec), &self->bseparams);
gxk_notebook_append (self->notebook, pchild, "BSE", FALSE);
}
-
static void
bst_preferences_destroy (GtkObject *object)
{
BstPreferences *self = BST_PREFERENCES (object);
-
if (self->rec_gconfig)
{
sfi_rec_unref (self->rec_gconfig);
@@ -92,7 +78,6 @@ bst_preferences_destroy (GtkObject *object)
}
sfi_ring_free (self->params_gconfig);
self->params_gconfig = NULL;
-
if (self->rec_skin)
{
sfi_rec_unref (self->rec_skin);
@@ -100,7 +85,6 @@ bst_preferences_destroy (GtkObject *object)
}
sfi_ring_free (self->params_skin);
self->params_skin = NULL;
-
if (self->bsepspec)
{
g_param_spec_unref (self->bsepspec);
@@ -113,10 +97,8 @@ bst_preferences_destroy (GtkObject *object)
}
sfi_ring_free (self->bseparams);
self->bseparams = NULL;
-
GTK_OBJECT_CLASS (bst_preferences_parent_class)->destroy (object);
}
-
static GtkWidget*
bst_preferences_build_rec_editor (SfiRec *rec,
SfiRecFields fields,
@@ -124,9 +106,7 @@ bst_preferences_build_rec_editor (SfiRec *rec,
{
SfiRing *ring, *params = NULL;
guint i;
-
g_return_val_if_fail (rec != NULL, NULL);
-
GtkWidget *vbox = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
"homogeneous", FALSE,
@@ -148,10 +128,8 @@ bst_preferences_build_rec_editor (SfiRec *rec,
*param_list = params;
else
sfi_ring_free (params);
-
return gxk_scrolled_window_create (vbox, GTK_SHADOW_NONE, 1, 0.8);
}
-
static void
bst_preferences_update_params (BstPreferences *self)
{
@@ -163,133 +141,103 @@ bst_preferences_update_params (BstPreferences *self)
for (ring = self->bseparams; ring; ring = sfi_ring_walk (ring, self->bseparams))
gxk_param_update ((GxkParam*) ring->data);
}
-
void
bst_preferences_revert (BstPreferences *self)
{
BstKeyBindingItemSeq *iseq;
BstKeyBinding *kbinding;
SfiRec *rec, *crec;
-
g_return_if_fail (BST_IS_PREFERENCES (self));
-
rec = bst_gconfig_to_rec (bst_gconfig_get_global ());
crec = sfi_rec_copy_deep (rec);
sfi_rec_unref (rec);
sfi_rec_swap_fields (self->rec_gconfig, crec);
sfi_rec_unref (crec);
-
kbinding = bst_pattern_controller_piano_keys();
iseq = bst_key_binding_get_item_seq (kbinding);
bst_key_binding_box_set (self->box_piano_keys, iseq);
bst_key_binding_item_seq_free (iseq);
-
kbinding = bst_pattern_controller_generic_keys();
iseq = bst_key_binding_get_item_seq (kbinding);
bst_key_binding_box_set (self->box_generic_keys, iseq);
bst_key_binding_item_seq_free (iseq);
-
bst_msg_absorb_config_box_set (self->box_msg_absorb_config, bst_msg_absorb_config_get_global());
-
rec = bst_skin_config_to_rec (bst_skin_config_get_global ());
crec = sfi_rec_copy_deep (rec);
sfi_rec_unref (rec);
sfi_rec_swap_fields (self->rec_skin, crec);
sfi_rec_unref (crec);
-
bse_proxy_get (BSE_SERVER, "bse-preferences", &rec, NULL);
crec = sfi_rec_copy_deep (rec);
sfi_rec_swap_fields (self->bserec, crec);
sfi_rec_unref (crec);
-
bst_preferences_update_params (self);
}
-
void
bst_preferences_default_revert (BstPreferences *self)
{
BstKeyBindingItemSeq *iseq;
BstKeyBinding *kbinding;
SfiRec *rec;
-
g_return_if_fail (BST_IS_PREFERENCES (self));
-
rec = sfi_rec_new ();
sfi_rec_validate (rec, sfi_pspec_get_rec_fields (bst_gconfig_pspec ()));
bst_gconfig_set_rec_rc_version (rec, BST_VERSION);
sfi_rec_swap_fields (self->rec_gconfig, rec);
sfi_rec_unref (rec);
-
kbinding = bst_pattern_controller_piano_keys();
(void) kbinding;
iseq = bst_key_binding_get_item_seq (bst_pattern_controller_default_piano_keys());
bst_key_binding_box_set (self->box_piano_keys, iseq);
bst_key_binding_item_seq_free (iseq);
-
kbinding = bst_pattern_controller_generic_keys();
iseq = bst_key_binding_get_item_seq (bst_pattern_controller_default_generic_keys());
bst_key_binding_box_set (self->box_generic_keys, iseq);
bst_key_binding_item_seq_free (iseq);
-
BstMsgAbsorbStringSeq empty_mas_seq = { 0, };
bst_msg_absorb_config_box_set (self->box_msg_absorb_config, &empty_mas_seq);
-
rec = sfi_rec_new ();
sfi_rec_validate (rec, sfi_pspec_get_rec_fields (bst_skin_config_pspec ()));
sfi_rec_swap_fields (self->rec_skin, rec);
sfi_rec_unref (rec);
-
rec = sfi_rec_new ();
sfi_rec_validate (rec, sfi_pspec_get_rec_fields (self->bsepspec));
sfi_rec_swap_fields (self->bserec, rec);
sfi_rec_unref (rec);
-
bst_preferences_update_params (self);
}
-
void
bst_preferences_apply (BstPreferences *self)
{
BstKeyBindingItemSeq *iseq;
BstKeyBinding *kbinding;
g_return_if_fail (BST_IS_PREFERENCES (self));
-
bst_gconfig_apply (self->rec_gconfig);
-
kbinding = bst_pattern_controller_piano_keys();
iseq = bst_key_binding_box_get (self->box_piano_keys);
bst_key_binding_set_item_seq (kbinding, iseq);
bst_key_binding_item_seq_free (iseq);
-
kbinding = bst_pattern_controller_generic_keys();
iseq = bst_key_binding_box_get (self->box_generic_keys);
bst_key_binding_set_item_seq (kbinding, iseq);
bst_key_binding_item_seq_free (iseq);
-
BstMsgAbsorbStringSeq *mass = bst_msg_absorb_config_box_get (self->box_msg_absorb_config);
SfiSeq *seq = bst_msg_absorb_string_seq_to_seq (mass);
bst_msg_absorb_config_apply (seq);
sfi_seq_unref (seq);
-
bst_skin_config_apply (self->rec_skin, NULL);
-
bse_proxy_set (BSE_SERVER, "bse-preferences", self->bserec, NULL);
-
bst_preferences_revert (self);
}
-
void
bst_preferences_load_rc_files (void)
{
gchar *file_name = BST_STRDUP_RC_FILE ();
BseErrorType error;
GSList *slist = NULL;
-
bst_rc_parse (file_name);
g_free (file_name);
-
bst_skin_parse (bst_skin_config_rcfile ());
-
slist = g_slist_append (slist, bst_pattern_controller_piano_keys());
// slist = g_slist_append (slist, bst_pattern_controller_generic_keys());
error = bst_key_binding_parse (bst_key_binding_rcfile (), slist);
@@ -302,26 +250,20 @@ bst_preferences_load_rc_files (void)
}
g_slist_free (slist);
}
-
static gboolean successfull_rc_dump = FALSE;
-
gboolean
bst_preferences_saved (void)
{
return successfull_rc_dump;
}
-
void
bst_preferences_save (BstPreferences *self)
{
BseErrorType error = BseErrorType (0);
gchar *file_name;
GSList *slist = NULL;
-
g_return_if_fail (BST_IS_PREFERENCES (self));
-
bse_server_save_preferences (BSE_SERVER);
-
file_name = BST_STRDUP_RC_FILE ();
error = bst_rc_dump (file_name);
if (error)
@@ -329,7 +271,6 @@ bst_preferences_save (BstPreferences *self)
else
successfull_rc_dump = TRUE;
g_free (file_name);
-
file_name = g_strdup (bst_key_binding_rcfile ());
slist = g_slist_append (slist, bst_pattern_controller_piano_keys());
// slist = g_slist_append (slist, bst_pattern_controller_generic_keys());
@@ -337,26 +278,21 @@ bst_preferences_save (BstPreferences *self)
if (error)
g_warning ("failed to save keyrc \"%s\": %s", file_name, bse_error_blurb (error));
g_slist_free (slist);
-
bst_msg_absorb_config_save();
-
file_name = g_strdup (bst_skin_config_rcfile ());
error = bst_skin_dump (file_name);
if (error)
g_warning ("failed to save skinrc \"%s\": %s", file_name, bse_error_blurb (error));
g_free (file_name);
}
-
void
bst_preferences_create_buttons (BstPreferences *self,
GxkDialog *dialog)
{
GtkWidget *widget;
-
g_return_if_fail (BST_IS_PREFERENCES (self));
g_return_if_fail (GXK_IS_DIALOG (dialog));
g_return_if_fail (self->apply == NULL);
-
/* Apply
*/
self->apply = gxk_dialog_default_action (dialog, BST_STOCK_APPLY, NULL, NULL);
@@ -369,17 +305,14 @@ bst_preferences_create_buttons (BstPreferences *self,
"Apply and save the preference values. Some values may only take effect after "
"restart while others can be locked against modifcation during "
"playback.");
-
/* Revert
*/
widget = gxk_dialog_action_swapped (dialog, BST_STOCK_REVERT, (void*) bst_preferences_revert, self);
gxk_widget_set_tooltip (widget, "Revert dialog changes to the currently active values.");
-
/* Default Revert
*/
widget = gxk_dialog_action_swapped (dialog, BST_STOCK_DEFAULT_REVERT, (void*) bst_preferences_default_revert, self);
gxk_widget_set_tooltip (widget, "Revert to hardcoded default values (factory settings).");
-
/* Close
*/
widget = (GtkWidget*) gxk_dialog_action (dialog, BST_STOCK_DISMISS, (void*) gxk_toplevel_delete, NULL);
diff --git a/beast-gtk/bstpreferences.hh b/beast-gtk/bstpreferences.hh
index 6c932b3..12045f5 100644
--- a/beast-gtk/bstpreferences.hh
+++ b/beast-gtk/bstpreferences.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PREFERENCES_H__
#define __BST_PREFERENCES_H__
-
#include "bstparamview.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_PREFERENCES (bst_preferences_get_type ())
#define BST_PREFERENCES(object) (GTK_CHECK_CAST ((object), BST_TYPE_PREFERENCES, BstPreferences))
@@ -13,29 +10,21 @@ G_BEGIN_DECLS
#define BST_IS_PREFERENCES(object) (GTK_CHECK_TYPE ((object), BST_TYPE_PREFERENCES))
#define BST_IS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_PREFERENCES))
#define BST_PREFERENCES_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_PREFERENCES, BstPreferencesClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstPreferences BstPreferences;
typedef struct _BstPreferencesClass BstPreferencesClass;
struct _BstPreferences
{
GtkVBox parent_object;
-
GtkNotebook *notebook;
GtkWidget *apply;
-
SfiRec *rec_gconfig;
SfiRing *params_gconfig;
-
GtkWidget *box_piano_keys;
GtkWidget *box_generic_keys;
-
GtkWidget *box_msg_absorb_config;
-
SfiRec *rec_skin;
SfiRing *params_skin;
-
GParamSpec *bsepspec;
SfiRec *bserec;
SfiRing *bseparams;
@@ -44,8 +33,6 @@ struct _BstPreferencesClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_preferences_get_type (void);
void bst_preferences_apply (BstPreferences *prefs);
@@ -56,7 +43,5 @@ void bst_preferences_revert (BstPreferences *prefs);
void bst_preferences_default_revert (BstPreferences *prefs);
void bst_preferences_create_buttons (BstPreferences *prefs,
GxkDialog *dialog);
-
G_END_DECLS
-
#endif /* __BST_PREFERENCES_H__ */
diff --git a/beast-gtk/bstprocbrowser.cc b/beast-gtk/bstprocbrowser.cc
index 33a8c6e..bc2861e 100644
--- a/beast-gtk/bstprocbrowser.cc
+++ b/beast-gtk/bstprocbrowser.cc
@@ -1,17 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstprocbrowser.hh"
-
#include "bstprocedure.hh"
-
#if 0
-
enum {
COL_SNAME, /* scheme name */
COL_TNAME, /* type name */
COL_CAT, /* category */
N_COLS
};
-
/* --- prototypes --- */
static void bst_proc_browser_class_init (BstProcBrowserClass *klass);
static void bst_proc_browser_init (BstProcBrowser *self);
@@ -24,18 +20,13 @@ static void tree_row_activated (BstProcBrowser *self,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkTreeView *tree_view);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
bst_proc_browser_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
@@ -49,31 +40,24 @@ bst_proc_browser_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) bst_proc_browser_init,
};
-
type = g_type_register_static (GTK_TYPE_VBOX,
"BstProcBrowser",
&type_info, 0);
}
-
return type;
}
-
static void
bst_proc_browser_class_init (BstProcBrowserClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->destroy = bst_proc_browser_destroy;
}
-
static void
bst_proc_browser_init (BstProcBrowser *self)
{
GtkWidget *scwin, *tree;
GtkTreeSelection *tsel;
-
/* main HBox
*/
self->hbox = g_object_new (GTK_TYPE_HBOX,
@@ -81,11 +65,9 @@ bst_proc_browser_init (BstProcBrowser *self)
"border_width", 3,
"parent", self,
NULL);
-
/* fetch categories
*/
self->cats = bse_categories_match_typed ("*", BSE_TYPE_PROCEDURE, &self->n_cats);
-
/* setup procedure list model
*/
self->proc_list = gtk_list_wrapper_new (N_COLS,
@@ -97,8 +79,6 @@ bst_proc_browser_init (BstProcBrowser *self)
G_CALLBACK (proc_list_fill_value),
self, G_CONNECT_SWAPPED);
gtk_list_wrapper_notify_prepend (self->proc_list, self->n_cats);
-
-
/* setup tree view and it's scrolled window
*/
scwin = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
@@ -126,13 +106,11 @@ bst_proc_browser_init (BstProcBrowser *self)
g_object_connect (tree,
"swapped_object_signal::row_activated", tree_row_activated, self,
NULL);
-
/* ensure selection
*/
tsel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_SINGLE);
gxk_tree_selection_select_spath (tsel, "0");
-
/* text entry
*/
self->entry = g_object_new (GTK_TYPE_ENTRY,
@@ -141,18 +119,14 @@ bst_proc_browser_init (BstProcBrowser *self)
NULL);
gtk_box_pack_start (GTK_BOX (self), GTK_WIDGET (self->entry), FALSE, TRUE, 0);
}
-
static void
bst_proc_browser_destroy (GtkObject *object)
{
BstProcBrowser *self = BST_PROC_BROWSER (object);
-
g_free (self->cats);
self->n_cats = 0;
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
proc_list_fill_value (BstProcBrowser *self,
guint column,
@@ -160,11 +134,8 @@ proc_list_fill_value (BstProcBrowser *self,
GValue *value)
{
BseCategory *cat;
-
g_return_if_fail (row < self->n_cats);
-
cat = self->cats + row;
-
switch (column)
{
case COL_TNAME:
@@ -178,7 +149,6 @@ proc_list_fill_value (BstProcBrowser *self,
break;
}
}
-
static void
tree_row_activated (BstProcBrowser *self,
GtkTreePath *path,
@@ -187,35 +157,28 @@ tree_row_activated (BstProcBrowser *self,
{
// GtkTreeSelection *tsel = gtk_tree_view_get_selection (tree_view);
BseCategory *cat;
-
cat = self->cats + gtk_tree_path_get_indices (path)[0];
bst_procedure_exec (cat->type, NULL, NULL);
}
-
GtkWidget*
bst_proc_browser_new (void)
{
GtkWidget *sbrowser = (GtkWidget*) g_object_new (BST_TYPE_PROC_BROWSER, NULL);
-
return sbrowser;
}
-
static void
bst_proc_browser_execute (BstProcBrowser *self)
{
gchar *text;
guint argc;
char **argv;
-
g_return_if_fail (BST_IS_PROC_BROWSER (self));
-
text = gtk_entry_get_text (self->entry);
if (!g_shell_parse_argv (text, &argc, &argv, NULL))
g_printerr ("failed to parse: %s\n", text);
else
{
GType ptype = g_type_from_name (argv[0]);
-
if (BSE_TYPE_IS_PROCEDURE (ptype))
{
g_printerr ("proc-call: %s %s\n", argv[0], g_type_name (ptype));
@@ -223,22 +186,18 @@ bst_proc_browser_execute (BstProcBrowser *self)
}
else
g_printerr ("no-such-procedure: %s \n", argv[0]);
-
// g_printerr ("return: %d\n", bsw_server_exec_proc (BSE_SERVER, argv[0], argv[1]));
g_strfreev (argv);
}
}
-
void
bst_proc_browser_create_buttons (BstProcBrowser *self,
GxkDialog *dialog)
{
GtkWidget *widget;
-
g_return_if_fail (BST_IS_PROC_BROWSER (self));
g_return_if_fail (GXK_IS_DIALOG (dialog));
g_return_if_fail (self->execute == NULL);
-
/* Execute
*/
if (0)
@@ -249,7 +208,6 @@ bst_proc_browser_create_buttons (BstProcBrowser *self,
NULL);
gxk_widget_set_tooltip (self->execute, "Execute the current line.");
}
-
/* Close
*/
widget = gxk_dialog_action (dialog, BST_STOCK_CLOSE, gxk_toplevel_delete, NULL);
diff --git a/beast-gtk/bstprocbrowser.hh b/beast-gtk/bstprocbrowser.hh
index 3df6e9e..585c3a7 100644
--- a/beast-gtk/bstprocbrowser.hh
+++ b/beast-gtk/bstprocbrowser.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PROC_BROWSER_H__
#define __BST_PROC_BROWSER_H__
-
#include "bstparamview.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BST_TYPE_PROC_BROWSER (bst_proc_browser_get_type ())
#define BST_PROC_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PROC_BROWSER, BstProcBrowser))
@@ -16,23 +12,17 @@ extern "C" {
#define BST_IS_PROC_BROWSER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PROC_BROWSER))
#define BST_IS_PROC_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PROC_BROWSER))
#define BST_PROC_BROWSER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PROC_BROWSER, BstProcBrowserClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstProcBrowser BstProcBrowser;
typedef struct _BstProcBrowserClass BstProcBrowserClass;
struct _BstProcBrowser
{
GtkVBox parent_object;
-
GtkWidget *hbox;
-
guint n_cats;
BseCategory *cats;
-
GxkListWrapper *proc_list;
GtkEntry *entry;
-
/* buttons */
GtkWidget *execute;
};
@@ -40,18 +30,12 @@ struct _BstProcBrowserClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_proc_browser_get_type (void);
GtkWidget* bst_proc_browser_new (void);
void bst_proc_browser_create_buttons (BstProcBrowser *self,
GxkDialog *dialog);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_PROC_BROWSER_H__ */
diff --git a/beast-gtk/bstprocedure.cc b/beast-gtk/bstprocedure.cc
index b00888c..2ef48f4 100644
--- a/beast-gtk/bstprocedure.cc
+++ b/beast-gtk/bstprocedure.cc
@@ -3,28 +3,21 @@
#include "bstparam.hh"
#include <gobject/gvaluecollector.h>
#include <string.h>
-
-
/* --- prototypes --- */
static void bst_procedure_shell_class_init (BstProcedureShellClass *klass);
static void bst_procedure_shell_init (BstProcedureShell *pe);
static void bst_procedure_shell_destroy (GtkObject *object);
static void bst_procedure_shell_finalize (GObject *object);
-
-
/* --- static variables --- */
static BstProcedureShell *global_proc_shell = NULL;
static gpointer parent_class = NULL;
static GQuark quark_input_params = 0;
static GQuark quark_output_params = 0;
-
-
/* --- functions --- */
GtkType
bst_procedure_shell_get_type (void)
{
static GtkType procedure_shell_type = 0;
-
if (!procedure_shell_type)
{
GtkTypeInfo procedure_shell_info =
@@ -38,29 +31,21 @@ bst_procedure_shell_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
procedure_shell_type = gtk_type_unique (GTK_TYPE_VBOX, &procedure_shell_info);
}
-
return procedure_shell_type;
}
-
static void
bst_procedure_shell_class_init (BstProcedureShellClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
quark_output_params = g_quark_from_static_string ("Output Parameters");
quark_input_params = g_quark_from_static_string ("Input Parameters");
-
gobject_class->finalize = bst_procedure_shell_finalize;
-
object_class->destroy = bst_procedure_shell_destroy;
}
-
static void
bst_procedure_shell_init (BstProcedureShell *self)
{
@@ -72,7 +57,6 @@ bst_procedure_shell_init (BstProcedureShell *self)
self->in_execution = FALSE;
self->hide_dialog_on_exec = FALSE;
}
-
static void
bst_procedure_shell_destroy_contents (BstProcedureShell *self)
{
@@ -82,49 +66,37 @@ bst_procedure_shell_destroy_contents (BstProcedureShell *self)
self->params = NULL;
self->in_modal_selection = FALSE;
}
-
static void
bst_procedure_shell_destroy (GtkObject *object)
{
BstProcedureShell *self = BST_PROCEDURE_SHELL (object);
-
if (self->in_execution)
g_warning (G_STRLOC ": destroying procedure shell during execution");
-
bst_procedure_shell_set_proc (self, NULL);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_procedure_shell_finalize (GObject *object)
{
BstProcedureShell *self = BST_PROCEDURE_SHELL (object);
-
bst_procedure_shell_set_proc (self, NULL);
sfi_rec_unref (self->prec);
self->prec = NULL;
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
GtkWidget*
bst_procedure_shell_new (SfiGlueProc *proc)
{
GtkWidget *widget;
-
widget = gtk_widget_new (BST_TYPE_PROCEDURE_SHELL, NULL);
bst_procedure_shell_set_proc (BST_PROCEDURE_SHELL (widget), proc);
-
return widget;
}
-
void
bst_procedure_shell_set_proc (BstProcedureShell *self,
SfiGlueProc *proc)
{
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
-
if (proc != self->proc)
{
bst_procedure_shell_destroy_contents (self);
@@ -136,7 +108,6 @@ bst_procedure_shell_set_proc (BstProcedureShell *self,
bst_procedure_shell_rebuild (self);
}
}
-
void
bst_procedure_shell_rebuild (BstProcedureShell *self)
{
@@ -144,17 +115,12 @@ bst_procedure_shell_rebuild (BstProcedureShell *self)
GtkWidget *param_box;
SfiRing *ring, *pspecs = NULL;
guint i;
-
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
-
sfi_rec_clear (self->prec);
bst_procedure_shell_destroy_contents (self);
-
if (!self->proc)
return;
-
proc = self->proc;
-
/* main container
*/
param_box = GTK_WIDGET (self);
@@ -163,7 +129,6 @@ bst_procedure_shell_rebuild (BstProcedureShell *self)
"spacing", 0,
"border_width", 5,
NULL);
-
/* put procedure title */
const gchar *string = bst_procedure_get_title (proc->name);
if (!string)
@@ -177,7 +142,6 @@ bst_procedure_shell_rebuild (BstProcedureShell *self)
FALSE,
TRUE,
0);
-
/* put description
*/
if (proc->help)
@@ -197,7 +161,6 @@ bst_procedure_shell_rebuild (BstProcedureShell *self)
"child", gxk_scroll_text_create (GXK_SCROLL_TEXT_WIDGET_LOOK, proc->help),
NULL);
}
-
/* parameter fields
*/
for (i = 0; i < proc->n_params; i++)
@@ -213,23 +176,18 @@ bst_procedure_shell_rebuild (BstProcedureShell *self)
self->params = sfi_ring_append (self->params, param);
}
sfi_ring_free (pspecs);
-
/* initialize parameter values
*/
bst_procedure_shell_reset (self);
}
-
void
bst_procedure_shell_update (BstProcedureShell *self)
{
SfiRing *ring;
-
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
-
for (ring = self->params; ring; ring = sfi_ring_walk (ring, self->params))
gxk_param_update ((GxkParam*) ring->data);
}
-
static GxkParam*
shell_find_param (BstProcedureShell *self,
const gchar *name)
@@ -240,24 +198,19 @@ shell_find_param (BstProcedureShell *self,
return (GxkParam*) ring->data;
return NULL;
}
-
void
bst_procedure_shell_execute (BstProcedureShell *self)
{
GtkWidget *widget;
SfiRing *ring;
-
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
g_return_if_fail (self->proc != NULL);
g_return_if_fail (self->in_execution == FALSE);
-
widget = GTK_WIDGET (self);
gtk_widget_ref (widget);
-
/* update parameter record */
for (ring = self->params; ring; ring = sfi_ring_walk (ring, self->params))
gxk_param_apply_value ((GxkParam*) ring->data);
-
if (widget)
{
SfiGlueProc *proc = self->proc;
@@ -265,16 +218,12 @@ bst_procedure_shell_execute (BstProcedureShell *self)
SfiSeq *pseq = sfi_seq_new ();
GValue *rvalue;
guint i;
-
for (i = 0; i < proc->n_params; i++)
sfi_seq_append (pseq, sfi_rec_get (self->prec, proc->params[i]->name));
-
self->in_execution = TRUE;
rvalue = sfi_glue_call_seq (self->proc->name, pseq);
self->in_execution = FALSE;
-
bst_status_eprintf (error, _("Executing '%s'"), self->proc->name);
-
sfi_seq_unref (pseq);
if (rvalue && proc->ret_param)
{
@@ -284,18 +233,14 @@ bst_procedure_shell_execute (BstProcedureShell *self)
gxk_param_update (param);
}
}
-
gtk_widget_unref (widget);
}
-
void
bst_procedure_shell_reset (BstProcedureShell *self)
{
SfiGlueProc *proc;
SfiRing *ring;
-
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
-
proc = self->proc;
sfi_rec_clear (self->prec);
if (!self->params)
@@ -317,18 +262,14 @@ bst_procedure_shell_reset (BstProcedureShell *self)
gxk_param_update (param);
}
self->n_preset_params = 0;
-
/* update parameters from record */
bst_procedure_shell_update (self);
}
-
void
bst_procedure_shell_unpreset (BstProcedureShell *self)
{
SfiRing *ring;
-
g_return_if_fail (BST_IS_PROCEDURE_SHELL (self));
-
for (ring = self->params; ring; ring = sfi_ring_walk (ring, self->params))
{
GxkParam *param = (GxkParam*) ring->data;
@@ -350,7 +291,6 @@ bst_procedure_shell_unpreset (BstProcedureShell *self)
}
self->n_preset_params = 0;
}
-
gboolean
bst_procedure_shell_preset (BstProcedureShell *self,
const gchar *name,
@@ -359,27 +299,22 @@ bst_procedure_shell_preset (BstProcedureShell *self,
{
SfiGlueProc *proc;
SfiRing *ring;
-
g_return_val_if_fail (BST_IS_PROCEDURE_SHELL (self), 0);
g_return_val_if_fail (self->proc != NULL, 0);
g_return_val_if_fail (name != NULL, 0);
g_return_val_if_fail (G_IS_VALUE (value), 0);
-
proc = self->proc;
-
/* ok, this is the really interesting part!
* we try to unificate the preset parameter with the procedure's
* input parameters. if we find a name match and type conversion
* is sucessfull, the procedure gets invoked with a predefined
* parameter value.
*/
-
for (ring = self->params; ring; ring = sfi_ring_walk (ring, self->params))
{
GxkParam *param = (GxkParam*) ring->data;
GParamSpec *pspec = param->pspec;
gboolean is_out_param = pspec == proc->ret_param;
-
if (!is_out_param && strcmp (pspec->name, name) == 0)
{
if (g_value_type_transformable (G_VALUE_TYPE (value),
@@ -408,17 +343,14 @@ bst_procedure_shell_preset (BstProcedureShell *self,
}
/* update parameters from record */
bst_procedure_shell_update (self);
-
return FALSE;
}
-
BstProcedureShell*
bst_procedure_shell_global (void)
{
if (!global_proc_shell)
{
GtkWidget *dialog;
-
global_proc_shell = (BstProcedureShell*) bst_procedure_shell_new (NULL);
g_object_ref (global_proc_shell);
gtk_object_sink (GTK_OBJECT (global_proc_shell));
@@ -426,10 +358,8 @@ bst_procedure_shell_global (void)
GXK_DIALOG_STATUS_BAR | GXK_DIALOG_HIDE_ON_DELETE | GXK_DIALOG_MODAL, // | GXK_DIALOG_WINDOW_GROUP,
_("Start Procedure"), NULL);
gxk_dialog_set_sizes (GXK_DIALOG (dialog), -1, -1, 320, -1);
-
gtk_container_add (GTK_CONTAINER (GXK_DIALOG (dialog)->vbox), GTK_WIDGET (global_proc_shell));
gtk_widget_show (GTK_WIDGET (global_proc_shell));
-
/* actions */
gxk_dialog_default_action_swapped (GXK_DIALOG (dialog),
BST_STOCK_EXECUTE, (void*) bst_procedure_shell_execute, global_proc_shell);
@@ -437,7 +367,6 @@ bst_procedure_shell_global (void)
}
return global_proc_shell;
}
-
static void
bst_procedure_exec_internal (const gchar *procedure_name,
const gchar *preset_param,
@@ -449,7 +378,6 @@ bst_procedure_exec_internal (const gchar *procedure_name,
BstProcedureShell *shell;
SfiGlueProc *proc;
GtkWidget *dialog;
-
/* structure setup */
proc = sfi_glue_describe_proc (procedure_name);
if (!proc)
@@ -461,7 +389,6 @@ bst_procedure_exec_internal (const gchar *procedure_name,
shell = bst_procedure_shell_global ();
dialog = gtk_widget_get_toplevel (GTK_WIDGET (shell));
bst_procedure_shell_set_proc (shell, proc);
-
/* set preset parameters */
bst_procedure_shell_unpreset (shell);
while (preset_param)
@@ -469,7 +396,6 @@ bst_procedure_exec_internal (const gchar *procedure_name,
GType vtype = va_arg (var_args, GType);
gchar *error = NULL;
GValue value = { 0, };
-
g_value_init (&value, vtype);
G_VALUE_COLLECT (&value, var_args, 0, &error);
if (error)
@@ -483,12 +409,10 @@ bst_procedure_exec_internal (const gchar *procedure_name,
g_value_unset (&value);
preset_param = va_arg (var_args, const gchar*);
}
-
if (modal)
gxk_dialog_add_flags (GXK_DIALOG (dialog), GXK_DIALOG_MODAL);
else
gxk_dialog_clear_flags (GXK_DIALOG (dialog), GXK_DIALOG_MODAL);
-
/* execution */
gxk_status_window_push (dialog);
g_object_ref (dialog);
@@ -513,67 +437,53 @@ bst_procedure_exec_internal (const gchar *procedure_name,
}
gxk_status_window_pop ();
g_object_unref (dialog);
-
sfi_glue_proc_unref (proc);
}
-
void
bst_procedure_exec_modal (const gchar *procedure_name,
const gchar *preset_param,
...)
{
va_list var_args;
-
g_return_if_fail (procedure_name != NULL);
-
va_start (var_args, preset_param);
bst_procedure_exec_internal (procedure_name, preset_param, TRUE, TRUE, TRUE, var_args);
va_end (var_args);
}
-
void
bst_procedure_exec (const gchar *procedure_name,
const gchar *preset_param,
...)
{
va_list var_args;
-
g_return_if_fail (procedure_name != NULL);
-
va_start (var_args, preset_param);
bst_procedure_exec_internal (procedure_name, preset_param, FALSE, FALSE, FALSE, var_args);
va_end (var_args);
}
-
void
bst_procedure_exec_auto (const gchar *procedure_name,
const gchar *preset_param,
...)
{
va_list var_args;
-
g_return_if_fail (procedure_name != NULL);
-
va_start (var_args, preset_param);
bst_procedure_exec_internal (procedure_name, preset_param, FALSE, TRUE, FALSE, var_args);
va_end (var_args);
}
-
GParamSpec*
bst_procedure_ref_pspec (const gchar *procedure_name,
const gchar *parameter)
{
SfiGlueProc *proc;
guint i;
-
/* structure setup */
proc = sfi_glue_describe_proc (procedure_name);
if (!proc)
return NULL;
-
for (i = 0; i < proc->n_params; i++)
if (strcmp (parameter, proc->params[i]->name) == 0)
return g_param_spec_ref (proc->params[i]);
-
return NULL;
}
diff --git a/beast-gtk/bstprocedure.hh b/beast-gtk/bstprocedure.hh
index a6dac7b..f2d4360 100644
--- a/beast-gtk/bstprocedure.hh
+++ b/beast-gtk/bstprocedure.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PROCEDURE_H__
#define __BST_PROCEDURE_H__
-
#include "bstparamview.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_PROCEDURE_SHELL (bst_procedure_shell_get_type ())
#define BST_PROCEDURE_SHELL(object) (GTK_CHECK_CAST ((object), BST_TYPE_PROCEDURE_SHELL, BstProcedureShell))
@@ -13,21 +10,16 @@ G_BEGIN_DECLS
#define BST_IS_PROCEDURE_SHELL(object) (GTK_CHECK_TYPE ((object), BST_TYPE_PROCEDURE_SHELL))
#define BST_IS_PROCEDURE_SHELL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_PROCEDURE_SHELL))
#define BST_PROCEDURE_SHELL_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_PROCEDURE_SHELL, BstProcedureShellClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstProcedureShell BstProcedureShell;
typedef struct _BstProcedureShellClass BstProcedureShellClass;
struct _BstProcedureShell
{
GtkVBox parent_object;
-
SfiGlueProc *proc;
SfiRec *prec;
-
guint n_preset_params;
SfiRing *params; /* n_in_params + n_out_params params */
-
guint in_modal_selection : 1;
guint in_execution : 1;
guint hide_dialog_on_exec : 1;
@@ -36,8 +28,6 @@ struct _BstProcedureShellClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_procedure_shell_get_type (void);
GtkWidget* bst_procedure_shell_new (SfiGlueProc *proc);
@@ -52,8 +42,6 @@ gboolean bst_procedure_shell_preset (BstProcedureShell *procedure_shell,
const gchar *name,
const GValue *value,
gboolean lock_preset);
-
-
/* --- convenience --- */
BstProcedureShell* bst_procedure_shell_global (void);
void bst_procedure_exec (const gchar *procedure_name,
@@ -67,7 +55,5 @@ void bst_procedure_exec_modal (const gchar *procedure_name,
...) G_GNUC_NULL_TERMINATED;
GParamSpec* bst_procedure_ref_pspec (const gchar *procedure_name,
const gchar *parameter);
-
G_END_DECLS
-
#endif /* __BST_PROCEDURE_H__ */
diff --git a/beast-gtk/bstprofiler.cc b/beast-gtk/bstprofiler.cc
index 5227fb3..28d0416 100644
--- a/beast-gtk/bstprofiler.cc
+++ b/beast-gtk/bstprofiler.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstprofiler.hh"
#include <string.h>
-
-
/* --- thread view --- */
enum {
TCOL_NAME,
@@ -14,16 +12,12 @@ enum {
TCOL_STIME,
N_TCOLS
};
-
-
/* --- variables --- */
static GtkWidget *profiler_dialog = NULL;
static GxkRadget *profiler = NULL;
static guint timer_id = 0;
static guint n_thread_infos = 0;
static BseThreadInfo *thread_infos = NULL;
-
-
/* --- funtions --- */
#if 0
static gchar
@@ -43,7 +37,6 @@ char_state_from_thread_state (BseThreadState thread_state)
}
}
#endif
-
static BseThreadState
thread_state_from_char_state (gchar thread_state)
{
@@ -60,7 +53,6 @@ thread_state_from_char_state (gchar thread_state)
case SFI_THREAD_DEAD: return BSE_THREAD_STATE_DEAD;
}
}
-
static void
thread_info_cell_fill_value (GtkWidget *profiler,
guint column,
@@ -93,7 +85,6 @@ thread_info_cell_fill_value (GtkWidget *profiler,
break;
}
}
-
static void
update_infos (GSList *slist,
GxkListWrapper *lw)
@@ -155,7 +146,6 @@ update_infos (GSList *slist,
gxk_list_wrapper_notify_change (lw, n - 1);
}
}
-
static void
profiler_update (void)
{
@@ -185,7 +175,6 @@ profiler_update (void)
g_slist_free (slist);
sfi_thread_info_free (si);
}
-
static gboolean
profiler_timer (gpointer data)
{
@@ -199,7 +188,6 @@ profiler_timer (gpointer data)
GDK_THREADS_LEAVE ();
return visible;
}
-
GtkWidget*
bst_profiler_window_get (void)
{
diff --git a/beast-gtk/bstprofiler.hh b/beast-gtk/bstprofiler.hh
index ec811fd..fc8cac1 100644
--- a/beast-gtk/bstprofiler.hh
+++ b/beast-gtk/bstprofiler.hh
@@ -1,14 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PROFILER_H__
#define __BST_PROFILER_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
GtkWidget* bst_profiler_window_get (void);
-
-
G_END_DECLS
-
#endif /* __BST_PROFILER_H__ */
diff --git a/beast-gtk/bstprojectctrl.cc b/beast-gtk/bstprojectctrl.cc
index dd27a39..3ea8aa7 100644
--- a/beast-gtk/bstprojectctrl.cc
+++ b/beast-gtk/bstprojectctrl.cc
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstprojectctrl.hh"
-
#include <math.h>
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstProjectCtrl, bst_project_ctrl, GTK_TYPE_HBOX);
-
void
bst_project_ctrl_play (BstProjectCtrl *self)
{
@@ -14,7 +10,6 @@ bst_project_ctrl_play (BstProjectCtrl *self)
{
gchar *starting;
BseErrorType error;
-
if (bse_project_is_playing (self->project))
starting = _("Restarting Playback");
else
@@ -24,7 +19,6 @@ bst_project_ctrl_play (BstProjectCtrl *self)
bst_status_eprintf (error, "%s", starting);
}
}
-
void
bst_project_ctrl_stop (BstProjectCtrl *self)
{
@@ -34,7 +28,6 @@ bst_project_ctrl_stop (BstProjectCtrl *self)
gxk_status_set (GXK_STATUS_DONE, _("Stopping Playback"), NULL);
}
}
-
static void
bst_project_ctrl_finalize (GObject *object)
{
@@ -42,13 +35,11 @@ bst_project_ctrl_finalize (GObject *object)
bst_project_ctrl_set_project (self, 0);
G_OBJECT_CLASS (bst_project_ctrl_parent_class)->finalize (object);
}
-
static void
project_state_changed (BstProjectCtrl *self,
SfiChoice choice)
{
BseProjectState state = bse_project_state_from_choice (choice);
-
if (self->led)
switch (state)
{
@@ -63,13 +54,11 @@ project_state_changed (BstProjectCtrl *self,
break;
}
}
-
static void
project_release (BstProjectCtrl *self)
{
bst_project_ctrl_set_project (self, 0);
}
-
void
bst_project_ctrl_set_project (BstProjectCtrl *self,
SfiProxy project)
@@ -77,7 +66,6 @@ bst_project_ctrl_set_project (BstProjectCtrl *self,
g_return_if_fail (BST_IS_PROJECT_CTRL (self));
if (project)
g_return_if_fail (BSE_IS_PROJECT (project));
-
if (self->project)
bse_proxy_disconnect (self->project,
"any_signal", project_state_changed, self,
@@ -95,14 +83,12 @@ bst_project_ctrl_set_project (BstProjectCtrl *self,
else if (self->led)
gxk_led_set_color (self->led, GXK_LED_OFF);
}
-
static void
bst_project_ctrl_init (BstProjectCtrl *self)
{
GtkWidget *box = GTK_WIDGET (self);
GtkWidget *frame;
guint spaceing = 0;
-
/* Led */
self->led = (GxkLed*) gxk_led_new (GXK_LED_OFF);
frame = (GtkWidget*) g_object_new (GTK_TYPE_FRAME,
@@ -112,7 +98,6 @@ bst_project_ctrl_init (BstProjectCtrl *self)
gxk_led_set_border_width (self->led, 1);
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->led);
-
/* Stop */
self->stop = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"child", gxk_polygon_new (&gxk_polygon_stop),
@@ -121,10 +106,8 @@ bst_project_ctrl_init (BstProjectCtrl *self)
g_object_connect (self->stop, "swapped_signal::clicked", bst_project_ctrl_stop, self, NULL);
gtk_box_pack_start (GTK_BOX (box), self->stop, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->stop);
-
/* size-group Led's frame and Stop */
gxk_size_group (GTK_SIZE_GROUP_BOTH, frame, self->stop, NULL);
-
/* Rewind */
self->rew = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"child", gxk_polygon_new (&gxk_polygon_rewind),
@@ -133,7 +116,6 @@ bst_project_ctrl_init (BstProjectCtrl *self)
NULL);
gtk_box_pack_start (GTK_BOX (box), self->rew, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->rew);
-
/* Play */
self->play = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"child", gxk_polygon_new (&gxk_polygon_play),
@@ -142,7 +124,6 @@ bst_project_ctrl_init (BstProjectCtrl *self)
g_object_connect (self->play, "swapped_signal::clicked", bst_project_ctrl_play, self, NULL);
gtk_box_pack_start (GTK_BOX (box), self->play, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->play);
-
/* Pause */
self->pause = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"child", gxk_polygon_new (&gxk_polygon_pause),
@@ -151,7 +132,6 @@ bst_project_ctrl_init (BstProjectCtrl *self)
NULL);
gtk_box_pack_start (GTK_BOX (box), self->pause, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->pause);
-
/* Forward */
self->fwd = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"child", gxk_polygon_new (&gxk_polygon_forward),
@@ -160,15 +140,11 @@ bst_project_ctrl_init (BstProjectCtrl *self)
NULL);
gtk_box_pack_start (GTK_BOX (box), self->fwd, FALSE, FALSE, spaceing);
gxk_nullify_in_object (self, &self->fwd);
-
gtk_widget_show_all (box);
}
-
-
static void
bst_project_ctrl_class_init (BstProjectCtrlClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_project_ctrl_finalize;
}
diff --git a/beast-gtk/bstprojectctrl.hh b/beast-gtk/bstprojectctrl.hh
index 405b143..ce4180c 100644
--- a/beast-gtk/bstprojectctrl.hh
+++ b/beast-gtk/bstprojectctrl.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_PROJECT_CTRL_H__
#define __BST_PROJECT_CTRL_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_PROJECT_CTRL (bst_project_ctrl_get_type ())
#define BST_PROJECT_CTRL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PROJECT_CTRL, BstProjectCtrl))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_PROJECT_CTRL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PROJECT_CTRL))
#define BST_IS_PROJECT_CTRL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PROJECT_CTRL))
#define BST_PROJECT_CTRL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PROJECT_CTRL, BstProjectCtrlClass))
-
-
/* --- typedefs & structures --- */
typedef struct {
GtkHBox parent_instance;
@@ -27,16 +22,11 @@ typedef struct {
GtkWidget *fwd;
} BstProjectCtrl;
typedef GtkHBoxClass BstProjectCtrlClass;
-
-
/* --- prototypes --- */
GType bst_project_ctrl_get_type (void);
void bst_project_ctrl_set_project (BstProjectCtrl *self,
SfiProxy project);
void bst_project_ctrl_play (BstProjectCtrl *self);
void bst_project_ctrl_stop (BstProjectCtrl *self);
-
-
G_END_DECLS
-
#endif /* __BST_PROJECT_CTRL_H__ */
diff --git a/beast-gtk/bstqsampler.cc b/beast-gtk/bstqsampler.cc
index 91f1560..e92a193 100644
--- a/beast-gtk/bstqsampler.cc
+++ b/beast-gtk/bstqsampler.cc
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstqsampler.hh"
-
#include "bstutils.hh"
#include <string.h>
-
-
/* --- properties --- */
enum {
PROP_0,
@@ -12,8 +9,6 @@ enum {
PROP_VSCALE,
PROP_DRAW_MODE
};
-
-
/* --- prototypes --- */
static void bst_qsampler_destroy (GtkObject *object);
static void bst_qsampler_finalize (GObject *object);
@@ -49,37 +44,28 @@ static void bst_qsampler_invalidate (BstQSampler *qsampler,
static void bst_qsampler_redraw (BstQSampler *qsampler,
gboolean draw_dirty);
static void bst_qsampler_queue_refresh (BstQSampler *qsampler);
-
-
/* --- static variables --- */
static GSList *refresh_widgets = NULL;
static GSList *tmp_refresh_widgets = NULL;
static gint refresh_handler = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstQSampler, bst_qsampler, GTK_TYPE_WIDGET);
-
static void
bst_qsampler_class_init (BstQSamplerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->finalize = bst_qsampler_finalize;
gobject_class->set_property = bst_qsampler_set_property;
gobject_class->get_property = bst_qsampler_get_property;
-
object_class->destroy = bst_qsampler_destroy;
-
widget_class->realize = bst_qsampler_realize;
widget_class->size_request = bst_qsampler_size_request;
widget_class->size_allocate = bst_qsampler_size_allocate;
widget_class->style_set = bst_qsampler_style_set;
widget_class->unrealize = bst_qsampler_unrealize;
widget_class->expose_event = bst_qsampler_expose;
-
g_object_class_install_property (G_OBJECT_CLASS (object_class),
PROP_ZOOM,
g_param_spec_double ("zoom", "Zoom [%]", NULL,
@@ -97,19 +83,16 @@ bst_qsampler_class_init (BstQSamplerClass *klass)
BST_QSAMPLER_DRAW_CRANGE,
G_PARAM_READWRITE));
}
-
static void
bst_qsampler_init (BstQSampler *qsampler)
{
GdkColor default_red = { 0, 0xe130, 0, 0 };
GdkColor default_green = { 0, 0, 0xe130, 0 };
-
qsampler->peak_length = 0;
qsampler->peak_offset = 0;
qsampler->n_peaks = 0;
qsampler->peaks = NULL;
qsampler->n_pixels = 0;
-
qsampler->zoom_factor = 1.0;
qsampler->vscale_factor = 1.0;
qsampler->marks = NULL;
@@ -127,37 +110,30 @@ bst_qsampler_init (BstQSampler *qsampler)
bst_qsampler_resize (qsampler);
gtk_widget_set_double_buffered (GTK_WIDGET (qsampler), FALSE);
}
-
static void
bst_qsampler_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
/* BstQSampler *qsampler = BST_QSAMPLER (widget); */
-
/* can just guess constantly */
requisition->width = 32;
requisition->height = widget->style->ythickness * 2;
}
-
static void
bst_qsampler_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstQSampler *qsampler = BST_QSAMPLER (widget);
-
GTK_WIDGET_CLASS (bst_qsampler_parent_class)->size_allocate (widget, allocation);
-
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (qsampler->canvas,
widget->style->xthickness,
widget->style->ythickness,
widget->allocation.width - 2 * widget->style->xthickness,
widget->allocation.height - 2 * widget->style->ythickness);
-
qsampler->n_pixels = widget->allocation.width - 2 * widget->style->xthickness;
bst_qsampler_resize (qsampler);
}
-
static void
bst_qsampler_realize (GtkWidget *widget)
{
@@ -166,9 +142,7 @@ bst_qsampler_realize (GtkWidget *widget)
GdkGCValues gc_values;
GdkWindowAttr attributes;
gint attributes_mask;
-
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -196,7 +170,6 @@ bst_qsampler_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, qsampler->canvas);
gtk_style_set_background (widget->style, qsampler->canvas, GTK_STATE_NORMAL);
gdk_window_show (qsampler->canvas);
-
if (!gdk_color_alloc (widget->style->colormap, &qsampler->red))
g_warning ("unable to allocate color: { %d, %d, %d }",
qsampler->red.red, qsampler->red.green, qsampler->red.blue);
@@ -209,20 +182,16 @@ bst_qsampler_realize (GtkWidget *widget)
gc_values.foreground = qsampler->green;
qsampler->green_gc = gtk_gc_get (widget->style->depth, widget->style->colormap, &gc_values, gc_values_mask);
}
-
static void
bst_qsampler_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
BstQSampler *qsampler = BST_QSAMPLER (widget);
-
GTK_WIDGET_CLASS (bst_qsampler_parent_class)->style_set (widget, previous_style);
-
if (GTK_WIDGET_REALIZED (qsampler))
{
GdkGCValuesMask gc_values_mask;
GdkGCValues gc_values;
-
gdk_window_move_resize (qsampler->canvas,
widget->style->xthickness,
widget->style->ythickness,
@@ -248,12 +217,10 @@ bst_qsampler_style_set (GtkWidget *widget,
}
qsampler->n_pixels = widget->allocation.width - 2 * widget->style->xthickness;
}
-
static void
bst_qsampler_unrealize (GtkWidget *widget)
{
BstQSampler *qsampler = BST_QSAMPLER (widget);
-
gdk_colormap_free_colors (widget->style->colormap, &qsampler->red, 1);
gdk_colormap_free_colors (widget->style->colormap, &qsampler->green, 1);
gtk_gc_release (qsampler->red_gc);
@@ -265,13 +232,11 @@ bst_qsampler_unrealize (GtkWidget *widget)
qsampler->canvas = NULL;
GTK_WIDGET_CLASS (bst_qsampler_parent_class)->unrealize (widget);
}
-
static gint
bst_qsampler_expose (GtkWidget *widget,
GdkEventExpose *event)
{
BstQSampler *qsampler = BST_QSAMPLER (widget);
-
if (GTK_WIDGET_DRAWABLE (qsampler))
{
qsampler->expose_frame |= event->window == widget->window;
@@ -281,71 +246,54 @@ bst_qsampler_expose (GtkWidget *widget,
}
return TRUE;
}
-
void
bst_qsampler_get_bounds (BstQSampler *qsampler,
gint *first_offset,
gint *last_offset)
{
guint ostart, oend;
-
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
// GtkWidget *widget = GTK_WIDGET (qsampler);
-
ostart = qsampler->peak_offset;
oend = ostart + qsampler->n_pixels - 1;
-
/* return visible pcm area */
-
if (first_offset)
*first_offset = ostart * qsampler->zoom_factor;
if (last_offset)
*last_offset = oend * qsampler->zoom_factor;
}
-
gboolean
bst_qsampler_get_offset_at (BstQSampler *qsampler,
gint *x_coord_p)
{
gboolean fits_visible = FALSE;
gint x_coord = 0;
-
g_return_val_if_fail (BST_IS_QSAMPLER (qsampler), FALSE);
g_return_val_if_fail (x_coord_p != NULL, FALSE);
-
if (GTK_WIDGET_DRAWABLE (qsampler))
{
x_coord = *x_coord_p;
-
/* translate to peaks */
fits_visible = x_coord >= 0 && uint (x_coord) < qsampler->n_pixels;
-
/* translate to pcm offset */
x_coord += qsampler->peak_offset;
x_coord *= qsampler->zoom_factor;
}
*x_coord_p = x_coord;
-
return fits_visible;
}
-
static void
bst_qsampler_destroy (GtkObject *object)
{
BstQSampler *qsampler = BST_QSAMPLER (object);
-
bst_qsampler_set_source (qsampler, 0, NULL, NULL, NULL);
bst_qsampler_set_adjustment (qsampler, NULL);
-
GTK_OBJECT_CLASS (bst_qsampler_parent_class)->destroy (object);
}
-
static void
bst_qsampler_finalize (GObject *object)
{
BstQSampler *qsampler = BST_QSAMPLER (object);
-
g_free (qsampler->peaks);
g_free (qsampler->marks);
g_free (qsampler->regions);
@@ -356,10 +304,8 @@ bst_qsampler_finalize (GObject *object)
}
else
qsampler->refresh_queued = TRUE;
-
G_OBJECT_CLASS (bst_qsampler_parent_class)->finalize (object);
}
-
static void
bst_qsampler_set_property (GObject *object,
guint prop_id,
@@ -367,7 +313,6 @@ bst_qsampler_set_property (GObject *object,
GParamSpec *pspec)
{
BstQSampler *qsampler = BST_QSAMPLER (object);
-
switch (prop_id)
{
case PROP_ZOOM:
@@ -384,7 +329,6 @@ bst_qsampler_set_property (GObject *object,
break;
}
}
-
static void
bst_qsampler_get_property (GObject *object,
guint prop_id,
@@ -392,7 +336,6 @@ bst_qsampler_get_property (GObject *object,
GParamSpec *pspec)
{
BstQSampler *qsampler = BST_QSAMPLER (object);
-
switch (prop_id)
{
case PROP_ZOOM:
@@ -409,7 +352,6 @@ bst_qsampler_get_property (GObject *object,
break;
}
}
-
static guint
last_peek_from_pcm_region (BstQSampler *qsampler,
guint pcm_offset,
@@ -417,12 +359,9 @@ last_peek_from_pcm_region (BstQSampler *qsampler,
{
guint last = (pcm_offset + pcm_length - 1) / qsampler->zoom_factor;
guint bound = (pcm_offset + pcm_length) / qsampler->zoom_factor;
-
/* depending on zoom factor, a pcm_length of 1 spawns multiple peaks */
-
return MAX (last, MAX (bound, 1) - 1);
}
-
static void
bst_qsampler_update_types (BstQSampler *qsampler,
guint pcm_offset,
@@ -432,54 +371,41 @@ bst_qsampler_update_types (BstQSampler *qsampler,
guint start = pcm_offset / qsampler->zoom_factor; /* first peek from pcm region */
guint end = last_peek_from_pcm_region (qsampler, pcm_offset, MAX (pcm_length, 1));
guint i, n, s, e, changed;
-
pcm_length = MAX (pcm_length, 1);
-
/* intersect with cached area */
start = MAX (start, qsampler->peak_offset);
end = MIN (end, qsampler->peak_offset + qsampler->n_peaks - 1);
-
if (end < start)
return;
-
types = g_new0 (guint8, end - start + 1);
-
/* merge regions */
for (n = 0; n < qsampler->n_regions; n++)
{
BstQSamplerRegion *r = qsampler->regions + n;
guint rstart = r->offset / qsampler->zoom_factor;
guint rend = last_peek_from_pcm_region (qsampler, r->offset, r->length);
-
g_assert (rstart <= rend);
-
/* intersect */
s = MAX (start, rstart);
e = MIN (end, rend);
-
/* merge region flags */
for (i = s; i <= e; i++)
types[i - start] |= r->type;
}
-
/* merge marks */
for (n = 0; n < qsampler->n_marks; n++)
{
BstQSamplerMark *m = qsampler->marks + n;
guint mstart = m->offset / qsampler->zoom_factor;
guint mend = last_peek_from_pcm_region (qsampler, m->offset, 1);
-
g_assert (mstart <= mend);
-
/* intersect */
s = MAX (start, mstart);
e = MIN (end, mend);
-
/* merge mark flags */
for (i = s; i <= e; i++)
types[i - start] |= m->type;
}
-
/* apply changes */
start -= qsampler->peak_offset;
end -= qsampler->peak_offset;
@@ -492,17 +418,14 @@ bst_qsampler_update_types (BstQSampler *qsampler,
changed = i;
}
g_free (types);
-
/* make sure we have an expose handler */
if (changed <= end)
bst_qsampler_invalidate (qsampler, changed, 1, FALSE);
}
-
static gboolean
bst_qsampler_reload (BstQSampler *qsampler)
{
guint span, i;
-
for (i = 0; i < qsampler->n_peaks; i++)
if (qsampler->peaks[i].type & BST_QSAMPLER_DIRTY)
break;
@@ -516,7 +439,6 @@ bst_qsampler_reload (BstQSampler *qsampler)
guint block_length = CLAMP (1 * qsampler->zoom_factor, 1, 1024);
BstQSamplerPeak values[256];
guint start = i;
-
span = MIN (span, 256);
if (qsampler->src_filler)
span = qsampler->src_filler (qsampler->src_data,
@@ -525,7 +447,6 @@ bst_qsampler_reload (BstQSampler *qsampler)
qsampler);
else
memset (values, 0, span * sizeof (values[0]));
-
for (i = 0; i < span; i++)
{
qsampler->peaks[start + i].max = values[i].max;
@@ -542,17 +463,14 @@ bst_qsampler_reload (BstQSampler *qsampler)
else
return FALSE;
}
-
static gboolean
bst_qsampler_refresh_idler (gpointer data)
{
GSList *slist;
-
GDK_THREADS_ENTER ();
for (slist = refresh_widgets; slist; slist = refresh_widgets)
{
BstQSampler *qsampler = (BstQSampler*) slist->data;
-
refresh_widgets = slist->next;
slist->next = tmp_refresh_widgets;
tmp_refresh_widgets = slist;
@@ -564,7 +482,6 @@ bst_qsampler_refresh_idler (gpointer data)
for (slist = refresh_widgets; slist; slist = refresh_widgets)
{
BstQSampler *qsampler = (BstQSampler*) slist->data;
-
refresh_widgets = slist->next;
slist->next = tmp_refresh_widgets;
tmp_refresh_widgets = slist;
@@ -575,7 +492,6 @@ bst_qsampler_refresh_idler (gpointer data)
for (slist = refresh_widgets; slist; slist = refresh_widgets)
{
BstQSampler *qsampler = (BstQSampler*) slist->data;
-
refresh_widgets = slist->next;
if (qsampler->invalid_remains)
{
@@ -595,10 +511,8 @@ bst_qsampler_refresh_idler (gpointer data)
if (!refresh_widgets)
refresh_handler = 0;
GDK_THREADS_LEAVE ();
-
return refresh_handler != 0;
}
-
static void
bst_qsampler_queue_refresh (BstQSampler *qsampler)
{
@@ -614,7 +528,6 @@ bst_qsampler_queue_refresh (BstQSampler *qsampler)
qsampler->invalid_remains = TRUE;
}
}
-
static void
bst_qsampler_invalidate (BstQSampler *qsampler,
guint offset,
@@ -622,7 +535,6 @@ bst_qsampler_invalidate (BstQSampler *qsampler,
gboolean reset)
{
guint i, bound;
-
if (reset)
{
bound = qsampler->peak_length - MIN (qsampler->peak_offset, qsampler->peak_length);
@@ -651,38 +563,32 @@ bst_qsampler_invalidate (BstQSampler *qsampler,
if (offset < qsampler->n_peaks && length)
bst_qsampler_queue_refresh (qsampler);
}
-
static void
bst_qsampler_resize (BstQSampler *qsampler)
{
GtkWidget *widget = GTK_WIDGET (qsampler);
-
qsampler->peak_length = qsampler->pcm_length / qsampler->zoom_factor;
qsampler->n_peaks = widget->allocation.width + widget->allocation.width;
qsampler->peaks = g_renew (BstQSamplerTPeak, qsampler->peaks, qsampler->n_peaks);
bst_qsampler_invalidate (qsampler, 0, qsampler->n_peaks, TRUE);
bst_qsampler_update_types (qsampler, 0, qsampler->pcm_length);
-
/* adjust page size */
qsampler->ignore_adjustment = TRUE;
bst_qsampler_update_adjustment (qsampler);
qsampler->ignore_adjustment = FALSE;
bst_qsampler_queue_refresh (qsampler);
}
-
static void
bst_qsampler_copy_area (BstQSampler *qsampler,
guint from,
guint to)
{
guint length = MAX (from, to);
-
if (GTK_WIDGET_DRAWABLE (qsampler) && length < qsampler->n_pixels)
gdk_window_scroll (qsampler->canvas, from - to, 0);
else
bst_qsampler_invalidate (qsampler, from, qsampler->n_peaks - length, FALSE);
}
-
static void
bst_qsampler_move_to (BstQSampler *qsampler,
guint peak_offset)
@@ -698,7 +604,6 @@ bst_qsampler_move_to (BstQSampler *qsampler,
else if (peak_offset > qsampler->peak_offset)
{
guint diff = peak_offset - qsampler->peak_offset;
-
g_memmove (qsampler->peaks, qsampler->peaks + diff, (qsampler->n_peaks - diff) * sizeof (qsampler->peaks[0]));
qsampler->peak_offset = peak_offset;
bst_qsampler_invalidate (qsampler, (qsampler->n_peaks - diff), qsampler->n_peaks, TRUE);
@@ -710,7 +615,6 @@ bst_qsampler_move_to (BstQSampler *qsampler,
else if (peak_offset < qsampler->peak_offset)
{
guint diff = qsampler->peak_offset - peak_offset;
-
g_memmove (qsampler->peaks + diff, qsampler->peaks, (qsampler->n_peaks - diff) * sizeof (qsampler->peaks[0]));
qsampler->peak_offset = peak_offset;
bst_qsampler_invalidate (qsampler, 0, diff, TRUE);
@@ -719,7 +623,6 @@ bst_qsampler_move_to (BstQSampler *qsampler,
}
bst_qsampler_queue_refresh (qsampler);
}
-
static void
bst_qsampler_avalue_changed (BstQSampler *qsampler)
{
@@ -727,21 +630,17 @@ bst_qsampler_avalue_changed (BstQSampler *qsampler)
{
GtkAdjustment *adjustment = qsampler->adjustment;
gdouble rel_offset;
-
rel_offset = (adjustment->value - adjustment->lower) / (adjustment->upper - adjustment->lower);
bst_qsampler_move_to (qsampler, rel_offset * qsampler->peak_length);
}
}
-
static void
bst_qsampler_update_adjustment (BstQSampler *qsampler)
{
GtkAdjustment *adjustment = qsampler->adjustment;
-
if (adjustment)
{
gdouble value = adjustment->value;
-
adjustment->lower = 0;
adjustment->upper = qsampler->pcm_length;
adjustment->page_size = MIN (qsampler->n_pixels * qsampler->zoom_factor, adjustment->upper - adjustment->lower);
@@ -753,7 +652,6 @@ bst_qsampler_update_adjustment (BstQSampler *qsampler)
gtk_adjustment_value_changed (adjustment);
}
}
-
static inline void
bst_qsampler_draw_peak (BstQSampler *qsampler,
guint offset,
@@ -775,8 +673,6 @@ bst_qsampler_draw_peak (BstQSampler *qsampler,
gfloat middle_value = (value + mvalue) / 2;
gfloat next_middle_value = (next_value + next_mvalue) / 2;
gint x = offset, y;
-
-
switch (qsampler->draw_mode)
{
gint yb, yn;
@@ -816,7 +712,6 @@ bst_qsampler_draw_peak (BstQSampler *qsampler,
gint cur_min = mpeak, cur_max = peak;
gint y1, y2;
gfloat min_value, max_value;
-
y1 = cur_max;
y2 = cur_max;
if (last_min > cur_max)
@@ -831,7 +726,6 @@ bst_qsampler_draw_peak (BstQSampler *qsampler,
if (cur_min > next_max)
y2 = (next_max + cur_min) / 2;
cur_min = MIN (cur_min, MIN (y1, y2));
-
min_value = ((gfloat) cur_min) / 32768.;
max_value = ((gfloat) cur_max) / 32768.;
y1 = low - (max_value + 1) * range;
@@ -855,7 +749,6 @@ bst_qsampler_draw_peak (BstQSampler *qsampler,
break;
}
}
-
static inline gboolean
bst_qsampler_fetch_gcs (BstQSampler *qsampler,
guint peak_type,
@@ -864,7 +757,6 @@ bst_qsampler_fetch_gcs (BstQSampler *qsampler,
{
GtkWidget *widget = (GtkWidget*) qsampler;
GdkGC *back_gc, *fore_gc = NULL;
-
if (GTK_WIDGET_IS_SENSITIVE (widget) && !(peak_type & BST_QSAMPLER_SKIP))
{
back_gc = widget->style->base_gc[GTK_STATE_NORMAL];
@@ -918,10 +810,8 @@ bst_qsampler_fetch_gcs (BstQSampler *qsampler,
}
*fore_gc_p = fore_gc;
*back_gc_p = back_gc;
-
return peak_type & BST_QSAMPLER_DIRTY;
}
-
static void
bst_qsampler_redraw (BstQSampler *qsampler,
gboolean draw_dirty)
@@ -931,20 +821,17 @@ bst_qsampler_redraw (BstQSampler *qsampler,
gint ythickness = widget->style->ythickness;
gint hi = 0, low = MAX (widget->allocation.height - 2 * ythickness, hi);
guint peak_type = 0, i, bound;
-
if (qsampler->expose_frame)
gtk_draw_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
0, 0,
widget->allocation.width, widget->allocation.height);
qsampler->expose_frame = FALSE;
-
i = 0;
do
{
GdkGC *fore_gc, *back_gc;
gboolean zero_line;
-
/* find first needs_draw peak */
for (; i < qsampler->n_pixels; i++)
{
@@ -957,13 +844,11 @@ bst_qsampler_redraw (BstQSampler *qsampler,
if (i >= qsampler->n_pixels)
return;
zero_line = bst_qsampler_fetch_gcs (qsampler, peak_type, &fore_gc, &back_gc);
-
/* coalesce common gc setups and clear flags */
qsampler->peaks[i].type &= ~BST_QSAMPLER_NEEDS_DRAW;
for (bound = i + 1; bound < qsampler->n_pixels; bound++)
{
GdkGC *tmp_fore_gc, *tmp_back_gc;
-
peak_type = qsampler->peaks[bound].type;
if (!(peak_type & BST_QSAMPLER_NEEDS_DRAW) ||
(!draw_dirty && (peak_type & BST_QSAMPLER_DIRTY)))
@@ -973,10 +858,8 @@ bst_qsampler_redraw (BstQSampler *qsampler,
break;
qsampler->peaks[bound].type &= ~BST_QSAMPLER_NEEDS_DRAW;
}
-
/* clear background */
gdk_draw_rectangle (canvas, back_gc, TRUE, i, hi, bound - i, low - hi);
-
/* draw peaks */
if (zero_line)
gdk_draw_line (canvas, fore_gc, i, (hi + low) >> 1, bound - 1, (hi + low) >> 1);
@@ -987,7 +870,6 @@ bst_qsampler_redraw (BstQSampler *qsampler,
}
while (i < qsampler->n_pixels);
}
-
void
bst_qsampler_set_source (BstQSampler *qsampler,
guint n_total_samples,
@@ -1000,11 +882,9 @@ bst_qsampler_set_source (BstQSampler *qsampler,
g_return_if_fail (fill_func != NULL);
else
g_return_if_fail (fill_func == NULL && destroy == NULL);
-
if (qsampler->src_destroy)
{
GDestroyNotify d = qsampler->src_destroy;
-
qsampler->src_destroy = NULL;
d (qsampler->src_data);
}
@@ -1025,16 +905,13 @@ bst_qsampler_set_source (BstQSampler *qsampler,
if (qsampler->adjustment)
bst_qsampler_avalue_changed (qsampler); /* force update */
}
-
gint
bst_qsampler_get_mark_offset (BstQSampler *qsampler,
guint mark_index)
{
guint n;
-
g_return_val_if_fail (BST_IS_QSAMPLER (qsampler), -1);
g_return_val_if_fail (mark_index > 0, -1);
-
for (n = 0; n < qsampler->n_marks; n++)
if (qsampler->marks[n].index == mark_index)
break;
@@ -1043,7 +920,6 @@ bst_qsampler_get_mark_offset (BstQSampler *qsampler,
else
return qsampler->marks[n].offset;
}
-
void
bst_qsampler_set_mark (BstQSampler *qsampler,
guint mark_index,
@@ -1051,12 +927,10 @@ bst_qsampler_set_mark (BstQSampler *qsampler,
BstQSamplerType type)
{
guint n;
-
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (mark_index > 0);
g_return_if_fail ((type & ~BST_QSAMPLER_MARK_MASK) == 0);
g_return_if_fail (offset < offset + 1); /* catch guint wraps */
-
if (type)
type |= BST_QSAMPLER_MARK;
for (n = 0; n < qsampler->n_marks; n++)
@@ -1075,7 +949,6 @@ bst_qsampler_set_mark (BstQSampler *qsampler,
else
{
guint old_offset = qsampler->marks[n].offset;
-
if (type)
{
qsampler->marks[n].type = type;
@@ -1093,7 +966,6 @@ bst_qsampler_set_mark (BstQSampler *qsampler,
}
bst_qsampler_update_types (qsampler, offset, 1);
}
-
void
bst_qsampler_set_region (BstQSampler *qsampler,
guint region_index,
@@ -1102,12 +974,10 @@ bst_qsampler_set_region (BstQSampler *qsampler,
BstQSamplerType type)
{
guint n;
-
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (region_index > 0);
g_return_if_fail ((type & ~BST_QSAMPLER_REGION_MASK) == 0);
g_return_if_fail (offset < offset + length); /* catch guint wraps */
-
for (n = 0; n < qsampler->n_regions; n++)
if (qsampler->regions[n].index == region_index)
break;
@@ -1126,7 +996,6 @@ bst_qsampler_set_region (BstQSampler *qsampler,
{
guint old_offset = qsampler->regions[n].offset;
guint old_length = qsampler->regions[n].length;
-
if (type && length)
{
qsampler->regions[n].type = type;
@@ -1145,47 +1014,38 @@ bst_qsampler_set_region (BstQSampler *qsampler,
}
bst_qsampler_update_types (qsampler, offset, length);
}
-
void
bst_qsampler_set_zoom (BstQSampler *qsampler,
gdouble zoom)
{
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
zoom = CLAMP (zoom, 1e-16, 1e+16);
qsampler->zoom_factor = 100. / zoom;
qsampler->peak_offset = qsampler->adjustment->value / qsampler->zoom_factor;
bst_qsampler_resize (qsampler);
-
g_object_notify (G_OBJECT (qsampler), "zoom");
}
-
void
bst_qsampler_set_vscale (BstQSampler *qsampler,
gdouble vscale)
{
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
vscale = CLAMP (vscale, 1e-16, 1e+16);
qsampler->vscale_factor = vscale / 100.;
bst_qsampler_invalidate (qsampler, 0, qsampler->n_pixels, FALSE);
bst_qsampler_queue_refresh (qsampler);
-
g_object_notify (G_OBJECT (qsampler), "vscale");
}
-
void
bst_qsampler_set_draw_mode (BstQSampler *qsampler,
BstQSamplerDrawMode dmode)
{
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (dmode < BST_QSAMPLER_DRAW_MODE_LAST);
-
qsampler->draw_mode = dmode;
gtk_widget_queue_draw (GTK_WIDGET (qsampler));
g_object_notify (G_OBJECT (qsampler), "draw_mode");
}
-
static void
bst_qsampler_scroll_internal (BstQSampler *qsampler,
guint pcm_offset,
@@ -1196,7 +1056,6 @@ bst_qsampler_scroll_internal (BstQSampler *qsampler,
GtkAdjustment *adjustment = qsampler->adjustment;
gfloat upper = qsampler->n_pixels * pscale;
gfloat lower = qsampler->n_pixels * pscale;
-
if ((lrflag & 1) && pcm_offset >= (qsampler->peak_offset + upper) * qsampler->zoom_factor)
{
adjustment->value = adjustment->lower + pcm_offset - (upper - pscale) * qsampler->zoom_factor;
@@ -1210,7 +1069,6 @@ bst_qsampler_scroll_internal (BstQSampler *qsampler,
adjustment->value = CLAMP (adjustment->value, adjustment->lower, adjustment->upper - adjustment->page_size);
}
}
-
void
bst_qsampler_scroll_rbounded (BstQSampler *qsampler,
guint pcm_offset,
@@ -1220,11 +1078,9 @@ bst_qsampler_scroll_rbounded (BstQSampler *qsampler,
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (boundary_padding >= 0.1 && boundary_padding <= 1.0);
g_return_if_fail (padding >= 0 && padding <= 1.0);
-
bst_qsampler_scroll_internal (qsampler, pcm_offset, boundary_padding, padding, 1);
gtk_adjustment_value_changed (qsampler->adjustment);
}
-
void
bst_qsampler_scroll_lbounded (BstQSampler *qsampler,
guint pcm_offset,
@@ -1234,11 +1090,9 @@ bst_qsampler_scroll_lbounded (BstQSampler *qsampler,
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (boundary_padding >= 0.1 && boundary_padding <= 1.0);
g_return_if_fail (padding >= 0 && padding <= 1.0);
-
bst_qsampler_scroll_internal (qsampler, pcm_offset, 1.0 - boundary_padding, padding, 2);
gtk_adjustment_value_changed (qsampler->adjustment);
}
-
void
bst_qsampler_scroll_bounded (BstQSampler *qsampler,
guint pcm_offset,
@@ -1248,46 +1102,37 @@ bst_qsampler_scroll_bounded (BstQSampler *qsampler,
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (boundary_padding >= 0.1 && boundary_padding <= 1.0);
g_return_if_fail (padding >= 0 && padding <= 1.0);
-
bst_qsampler_scroll_internal (qsampler, pcm_offset, boundary_padding, padding, 1);
bst_qsampler_scroll_internal (qsampler, pcm_offset, 1.0 - boundary_padding, padding, 2);
gtk_adjustment_value_changed (qsampler->adjustment);
}
-
void
bst_qsampler_scroll_show (BstQSampler *qsampler,
guint pcm_offset)
{
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
bst_qsampler_scroll_internal (qsampler, pcm_offset, 1.0, 0, 1);
bst_qsampler_scroll_internal (qsampler, pcm_offset, 0, 0, 2);
gtk_adjustment_value_changed (qsampler->adjustment);
}
-
void
bst_qsampler_scroll_to (BstQSampler *qsampler,
guint pcm_offset)
{
GtkAdjustment *adjustment;
-
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
adjustment = qsampler->adjustment;
adjustment->value = pcm_offset;
adjustment->value = CLAMP (adjustment->value, adjustment->lower, adjustment->upper - adjustment->page_size);
gtk_adjustment_value_changed (adjustment);
}
-
void
bst_qsampler_force_refresh (BstQSampler *qsampler)
{
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
-
if (GTK_WIDGET_DRAWABLE (qsampler))
bst_qsampler_redraw (qsampler, FALSE);
}
-
void
bst_qsampler_set_adjustment (BstQSampler *qsampler,
GtkAdjustment *adjustment)
@@ -1295,7 +1140,6 @@ bst_qsampler_set_adjustment (BstQSampler *qsampler,
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
if (qsampler->adjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (qsampler->adjustment), qsampler);
@@ -1312,14 +1156,11 @@ bst_qsampler_set_adjustment (BstQSampler *qsampler,
}
bst_qsampler_update_adjustment (qsampler);
}
-
-
typedef struct {
SfiProxy esample;
guint nth_channel;
guint n_channels;
} ESampleFiller;
-
static guint
qsampler_esample_filler (gpointer data,
guint voffset,
@@ -1331,7 +1172,6 @@ qsampler_esample_filler (gpointer data,
{
ESampleFiller *fill = (ESampleFiller*) data;
SfiFBlock *fblock;
-
voffset = voffset * fill->n_channels + fill->nth_channel;
fblock = bse_editable_sample_collect_stats (fill->esample,
voffset,
@@ -1345,35 +1185,28 @@ qsampler_esample_filler (gpointer data,
values[i].min = fblock->values[i * 2] * 32767.9;
values[i].max = fblock->values[i * 2 + 1] * 32767.9;
}
-
return i;
}
-
static void
free_esample_filler (gpointer data)
{
ESampleFiller *fill = (ESampleFiller*) data;
-
bse_item_unuse (fill->esample);
g_free (data);
}
-
void
bst_qsampler_set_source_from_esample (BstQSampler *qsampler,
SfiProxy esample,
guint nth_channel)
{
ESampleFiller *fill;
-
g_return_if_fail (BST_IS_QSAMPLER (qsampler));
g_return_if_fail (BSE_IS_EDITABLE_SAMPLE (esample));
-
fill = g_new (ESampleFiller, 1);
fill->esample = esample;
bse_item_use (fill->esample);
fill->n_channels = bse_editable_sample_get_n_channels (fill->esample);
fill->nth_channel = nth_channel;
-
bst_qsampler_set_source (qsampler,
bse_editable_sample_get_length (fill->esample) / fill->n_channels,
qsampler_esample_filler,
diff --git a/beast-gtk/bstqsampler.hh b/beast-gtk/bstqsampler.hh
index 24b56b1..0946c64 100644
--- a/beast-gtk/bstqsampler.hh
+++ b/beast-gtk/bstqsampler.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_QSAMPLER_H__
#define __BST_QSAMPLER_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_QSAMPLER (bst_qsampler_get_type ())
#define BST_QSAMPLER(object) (GTK_CHECK_CAST ((object), BST_TYPE_QSAMPLER, BstQSampler))
@@ -13,9 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_QSAMPLER(object) (GTK_CHECK_TYPE ((object), BST_TYPE_QSAMPLER))
#define BST_IS_QSAMPLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_QSAMPLER))
#define BST_QSAMPLER_GET_CLASS(obj) ((BstQSamplerClass*) ((GtkObject*) (obj))->klass)
-
-
-
/* --- typedefs --- */
typedef struct _BstQSampler BstQSampler;
typedef struct _BstQSamplerClass BstQSamplerClass;
@@ -39,7 +33,6 @@ typedef enum
BST_QSAMPLER_SELECTED = 1 << 2,
/* marks only */
BST_QSAMPLER_PRELIGHT = 1 << 3,
-
/*< private >*/
BST_QSAMPLER_MARK_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE | BST_QSAMPLER_PRELIGHT),
BST_QSAMPLER_REGION_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE),
@@ -56,7 +49,6 @@ inline BstQSamplerType operator| (BstQSamplerType s1, BstQSamplerType s2) { r
inline BstQSamplerType& operator|= (BstQSamplerType &s1, BstQSamplerType s2) { s1 = s1 | s2; return s1; }
inline BstQSamplerType operator~ (BstQSamplerType s1) { return BstQSamplerType (~(long long unsigned) s1); }
#endif // __cplusplus
-
typedef enum
{
BST_QSAMPLER_DRAW_CRANGE,
@@ -70,20 +62,15 @@ typedef enum
BST_QSAMPLER_DRAW_MODE_LAST /*< skip >*/
} BstQSamplerDrawMode;
#define BST_QSAMPLER_RELOAD_PRIORITY (GTK_PRIORITY_REDRAW + 5)
-
-
/* --- structures --- */
struct _BstQSampler
{
GtkWidget parent_instance;
-
guint peak_length; /* pcm length in peaks */
guint n_peaks; /* number of cached peaks */
BstQSamplerTPeak *peaks;
guint peak_offset; /* display offset */
guint n_pixels; /* <= n_peaks */
-
-
/* user settings */
guint n_marks;
BstQSamplerMark *marks;
@@ -94,10 +81,8 @@ struct _BstQSampler
gpointer src_data;
GDestroyNotify src_destroy;
gdouble zoom_factor;
-
GtkAdjustment *adjustment;
gdouble vscale_factor;
-
GdkColor red, green;
GdkGC *red_gc, *green_gc;
GdkWindow *canvas;
@@ -106,7 +91,6 @@ struct _BstQSampler
guint ignore_adjustment : 1;
guint refresh_queued : 1;
guint invalid_remains : 1; /* temporary refresh flag */
-
/* user data */
gpointer owner;
guint owner_index;
@@ -137,8 +121,6 @@ struct _BstQSamplerRegion
guint offset;
guint length;
};
-
-
/* --- prototypes --- */
GType bst_qsampler_get_type (void);
void bst_qsampler_set_source (BstQSampler *qsampler,
@@ -187,11 +169,8 @@ void bst_qsampler_set_draw_mode (BstQSampler *qsampler,
BstQSamplerDrawMode dmode);
void bst_qsampler_set_adjustment (BstQSampler *qsampler,
GtkAdjustment *adjustment);
-
void bst_qsampler_set_source_from_esample (BstQSampler *qsampler,
SfiProxy esample,
guint nth_channel);
-
G_END_DECLS
-
#endif /* __BST_QSAMPLER_H__ */
diff --git a/beast-gtk/bstrackeditor-covers.cc b/beast-gtk/bstrackeditor-covers.cc
index c7c3c93..15443a1 100644
--- a/beast-gtk/bstrackeditor-covers.cc
+++ b/beast-gtk/bstrackeditor-covers.cc
@@ -1,7 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
-
/* --- functions --- */
static GtkWidget*
rack_cover_create (GtkWidget *rtable)
@@ -29,36 +26,28 @@ rack_cover_create (GtkWidget *rtable)
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *pix;
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
gdk_pixmap_unref (pixmap);
gdk_pixmap_unref (mask);
-
pix = (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT, "visible", TRUE, NULL);
gtk_table_attach (table, pix, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0);
-
return cover;
}
-
#if 0
static void
rack_cover_grow_area_horizontal (BstRackTable *rtable,
@@ -69,7 +58,6 @@ rack_cover_grow_area_horizontal (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (i = 1; col + i < table->ncols; i++)
if (bst_rack_table_check_cell (rtable, col + i, row))
break;
@@ -79,7 +67,6 @@ rack_cover_grow_area_horizontal (BstRackTable *rtable,
*hspan = i;
*vspan = j;
}
-
static void
rack_cover_grow_area_vertical (BstRackTable *rtable,
guint col,
@@ -89,7 +76,6 @@ rack_cover_grow_area_vertical (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (j = 1; row + j < table->nrows; j++)
if (bst_rack_table_check_cell (rtable, col, row + j))
break;
@@ -100,7 +86,6 @@ rack_cover_grow_area_vertical (BstRackTable *rtable,
*vspan = j;
}
#endif
-
static GSList*
rack_cover_add_plates (BstRackTable *rtable)
{
@@ -109,7 +94,6 @@ rack_cover_add_plates (BstRackTable *rtable)
guint i, j, max;
guint k, l, m, n;
GSList *plate_list = NULL;
-
#if 0
for (i = 0; i < table->ncols; i++)
for (j = 0; j < table->nrows; j++)
@@ -117,13 +101,11 @@ rack_cover_add_plates (BstRackTable *rtable)
{
rtable_grow_area_vertical (rtable, i, j, &k, &l);
rtable_grow_area_horizontal (rtable, i, j, &m, &n);
-
if (m * n > k * l)
{
k = m;
l = n;
}
-
cover = make_cover (GTK_WIDGET (rtable));
plate_list = g_slist_prepend (plate_list, cover);
bst_rack_child_set_info (cover, i, j, k, l);
@@ -143,7 +125,6 @@ rack_cover_add_plates (BstRackTable *rtable)
if (!bst_rack_table_check_cell (rtable, i, j))
{
guint t, u;
-
max_free--;
bst_rack_table_expand_rect (rtable, i, j, &t, &u);
if (t * u > max)
@@ -172,6 +153,5 @@ rack_cover_add_plates (BstRackTable *rtable)
}
while (max > 0);
#endif
-
return plate_list;
}
diff --git a/beast-gtk/bstrackeditor.cc b/beast-gtk/bstrackeditor.cc
index 4adaf2c..27933a6 100644
--- a/beast-gtk/bstrackeditor.cc
+++ b/beast-gtk/bstrackeditor.cc
@@ -3,12 +3,8 @@
#if 0
#include "bstrackitem.hh"
#endif
-
-
/* --- include sources --- */
#include "bstrackeditor-covers.cc"
-
-
/* --- prototypes --- */
static void bst_rack_editor_class_init (BstRackEditorClass *klass);
static void bst_rack_editor_init (BstRackEditor *rack_editor);
@@ -17,18 +13,13 @@ static void update_covers (BstRackEditor *ed);
static void update_items (BstRackEditor *ed);
static void create_rack_item (BstRackEditor *ed,
guint entry_id);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
bst_rack_editor_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
@@ -42,33 +33,25 @@ bst_rack_editor_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) bst_rack_editor_init,
};
-
type = g_type_register_static (GTK_TYPE_VBOX,
"BstRackEditor",
&type_info, GTypeFlags (0));
}
-
return type;
}
-
static void
bst_rack_editor_class_init (BstRackEditorClass *klass)
{
GtkObjectClass *object_class;
-
object_class = GTK_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->destroy = bst_rack_editor_destroy;
}
-
static void
toggle_edit_mode (BstRackEditor *ed)
{
bst_rack_table_set_edit_mode (ed->rtable, !ed->rtable->edit_mode);
}
-
static void
bst_rack_editor_init (BstRackEditor *ed)
{
@@ -98,7 +81,6 @@ bst_rack_editor_init (BstRackEditor *ed)
"swapped_signal::destroy", g_nullify_pointer, &ed->button_edit,
"swapped_signal::clicked", toggle_edit_mode, ed,
NULL);
-
ed->rtable = (BstRackTable*) g_object_new (BST_TYPE_RACK_TABLE,
"visible", TRUE,
"parent", ed,
@@ -110,18 +92,14 @@ bst_rack_editor_init (BstRackEditor *ed)
gtk_table_resize (GTK_TABLE (ed->rtable), 20, 30);
update_covers (ed);
}
-
static void
bst_rack_editor_destroy (GtkObject *object)
{
BstRackEditor *ed = BST_RACK_EDITOR (object);
-
bst_rack_editor_set_rack_view (ed, 0);
-
while (ed->plate_list)
{
GSList *slist = ed->plate_list;
-
ed->plate_list = slist->next;
gtk_widget_destroy ((GtkWidget*) slist->data);
g_slist_free_1 (slist);
@@ -129,16 +107,13 @@ bst_rack_editor_destroy (GtkObject *object)
while (ed->item_list)
{
GSList *slist = ed->item_list;
-
ed->item_list = slist->next;
gtk_widget_destroy ((GtkWidget*) slist->data);
g_slist_free_1 (slist);
}
-
/* chain parent class' handler */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
pocket_entry_changed (BstRackEditor *ed,
guint entry_id)
@@ -147,7 +122,6 @@ pocket_entry_changed (BstRackEditor *ed,
GSList *slist;
BstRackItem *item = NULL;
const gchar *controller;
-
for (slist = ed->item_list; slist; slist = slist->next)
{
item = slist->data;
@@ -166,13 +140,11 @@ pocket_entry_changed (BstRackEditor *ed,
create_rack_item (ed, entry_id);
#endif
}
-
static void
pocket_remove (BstRackEditor *ed)
{
bst_rack_editor_set_rack_view (ed, 0);
}
-
void
bst_rack_editor_set_rack_view (BstRackEditor *ed,
SfiProxy pocket)
@@ -180,7 +152,6 @@ bst_rack_editor_set_rack_view (BstRackEditor *ed,
g_return_if_fail (BST_IS_RACK_EDITOR (ed));
if (pocket)
g_return_if_fail (BSE_IS_DATA_POCKET (pocket));
-
if (ed->pocket)
{
bse_proxy_disconnect (ed->pocket,
@@ -199,7 +170,6 @@ bst_rack_editor_set_rack_view (BstRackEditor *ed,
update_items (ed);
}
}
-
void
bst_rack_editor_add_property (BstRackEditor *ed,
SfiProxy item,
@@ -208,11 +178,9 @@ bst_rack_editor_add_property (BstRackEditor *ed,
g_return_if_fail (BST_IS_RACK_EDITOR (ed));
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (property_name != NULL);
-
if (ed->pocket)
{
GParamSpec *pspec = bse_proxy_get_pspec (item, property_name);
-
if (pspec)
{
guint id = bse_data_pocket_create_entry (ed->pocket);
@@ -222,7 +190,6 @@ bst_rack_editor_add_property (BstRackEditor *ed,
}
}
}
-
static void
update_covers (BstRackEditor *ed)
{
@@ -231,7 +198,6 @@ update_covers (BstRackEditor *ed)
while (ed->plate_list)
{
GSList *slist = ed->plate_list;
-
ed->plate_list = slist->next;
gtk_widget_destroy ((GtkWidget*) slist->data);
g_slist_free_1 (slist);
@@ -240,22 +206,18 @@ update_covers (BstRackEditor *ed)
else if (!ed->plate_list)
ed->plate_list = rack_cover_add_plates (ed->rtable);
}
-
static void
update_items (BstRackEditor *ed)
{
GSList *slist = NULL;
guint i;
-
while (ed->item_list)
{
GSList *slist = ed->item_list;
-
ed->item_list = slist->next;
gtk_widget_destroy ((GtkWidget*) slist->data);
g_slist_free_1 (slist);
}
-
bst_rack_table_set_edit_mode (ed->rtable, TRUE);
i = bse_data_pocket_get_n_entries (ed->pocket);
while (i--)
@@ -265,7 +227,6 @@ update_items (BstRackEditor *ed)
GSList *tmp = slist;
guint entry_id = GPOINTER_TO_UINT (tmp->data);
const gchar *controller;
-
slist = tmp->next;
controller = bse_data_pocket_get_string (ed->pocket, entry_id, "property-controller");
if (controller)
@@ -274,7 +235,6 @@ update_items (BstRackEditor *ed)
}
bst_rack_table_set_edit_mode (ed->rtable, FALSE);
}
-
static void
create_rack_item (BstRackEditor *ed,
guint entry_id)
@@ -284,7 +244,6 @@ create_rack_item (BstRackEditor *ed,
GtkWidget *item = (GtkWidget*) g_object_new (BST_TYPE_RACK_ITEM,
"visible", TRUE,
NULL);
-
if (!edit_mode)
bst_rack_table_set_edit_mode (ed->rtable, TRUE);
bst_rack_child_set_info (item, -1, -2, 4, 4);
diff --git a/beast-gtk/bstrackeditor.hh b/beast-gtk/bstrackeditor.hh
index 3b934a1..69abb18 100644
--- a/beast-gtk/bstrackeditor.hh
+++ b/beast-gtk/bstrackeditor.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_RACK_EDITOR_H__
#define __BST_RACK_EDITOR_H__
-
#include "bstracktable.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BST_TYPE_RACK_EDITOR (bst_rack_editor_get_type ())
#define BST_RACK_EDITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_RACK_EDITOR, BstRackEditor))
@@ -16,17 +12,13 @@ extern "C" {
#define BST_IS_RACK_EDITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_RACK_EDITOR))
#define BST_IS_RACK_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_RACK_EDITOR))
#define BST_RACK_EDITOR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_RACK_EDITOR, BstRackEditorClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstRackEditor BstRackEditor;
typedef struct _BstRackEditorClass BstRackEditorClass;
struct _BstRackEditor
{
GtkVBox parent_instance;
-
SfiProxy pocket;
-
BstRackTable *rtable;
GSList *plate_list;
GtkWidget *button_edit;
@@ -36,8 +28,6 @@ struct _BstRackEditorClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_rack_editor_get_type (void);
GtkWidget* bst_rack_editor_new (SfiProxy rack_view);
@@ -46,10 +36,7 @@ void bst_rack_editor_set_rack_view (BstRackEditor *editor,
void bst_rack_editor_add_property (BstRackEditor *editor,
SfiProxy item,
const gchar *property_name);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_RACK_EDITOR_H__ */
diff --git a/beast-gtk/bstrackitem.cc b/beast-gtk/bstrackitem.cc
index 901108f..d1c0be1 100644
--- a/beast-gtk/bstrackitem.cc
+++ b/beast-gtk/bstrackitem.cc
@@ -2,20 +2,14 @@
#include "bstrackitem.hh"
#include "bstmenus.hh"
#include <string.h>
-
-
/* --- prototypes --- */
static void rack_item_class_init (BstRackItemClass *klass);
static void rack_item_init (BstRackItem *item);
static void rack_item_destroy (GtkObject *object);
static void rack_item_button_press (GxkRackItem *xitem,
GdkEventButton *event);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
bst_rack_item_get_type (void)
@@ -38,20 +32,15 @@ bst_rack_item_get_type (void)
}
return type;
}
-
static void
rack_item_class_init (BstRackItemClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GxkRackItemClass *xitem_class = GXK_RACK_ITEM_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->destroy = rack_item_destroy;
-
xitem_class->button_press = rack_item_button_press;
}
-
static void
rack_item_init (BstRackItem *self)
{
@@ -60,31 +49,25 @@ rack_item_init (BstRackItem *self)
self->block_updates = 0;
self->param = NULL;
}
-
static void
rack_item_destroy (GtkObject *object)
{
BstRackItem *self = BST_RACK_ITEM (object);
-
if (self->param)
{
gxk_param_destroy (self->param);
self->param = NULL;
}
-
bst_rack_item_set_parasite (self, 0, NULL);
-
if (self->choice)
{
bst_choice_destroy (self->choice);
self->controller_choice = NULL;
self->choice = NULL;
}
-
/* chain parent class' handler */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
GtkWidget*
bst_rack_item_new (SfiProxy proxy,
const gchar *path)
@@ -98,7 +81,6 @@ bst_rack_item_new (SfiProxy proxy,
bst_rack_item_set_parasite (self, proxy, path);
return GTK_WIDGET (self);
}
-
static void
rack_item_parasite_changed (BstRackItem *self)
{
@@ -108,18 +90,15 @@ rack_item_parasite_changed (BstRackItem *self)
GParamSpec *pspec = NULL;
SfiProxy proxy = 0;
const gchar *controller, *name;
-
controller = bse_data_pocket_get_string (self->pocket, self->entry, "property-controller");
name = bse_data_pocket_get_string (self->pocket, self->entry, "property-name");
proxy = bse_data_pocket_get_object (self->pocket, self->entry, "property-object");
if (proxy && name)
pspec = bse_proxy_get_pspec (proxy, name);
bst_rack_item_set_proxy (self, pspec ? proxy : 0, pspec, controller);
-
if (self->bparam)
{
BstRackChildInfo info;
-
info.col = bse_data_pocket_get_int (self->pocket, self->entry, "property-x");
info.row = bse_data_pocket_get_int (self->pocket, self->entry, "property-y");
info.hspan = bse_data_pocket_get_int (self->pocket, self->entry, "property-hspan");
@@ -134,20 +113,17 @@ rack_item_parasite_changed (BstRackItem *self)
#endif
}
}
-
static void
rack_item_remove_proxy (BstRackItem *self)
{
bst_rack_item_set_parasite (self, 0, NULL);
}
-
void
bst_rack_item_set_parasite (BstRackItem *self,
SfiProxy proxy,
const gchar *path)
{
g_return_if_fail (BST_IS_RACK_ITEM (self));
-
if (self->proxy)
{
bse_proxy_disconnect (self->proxy,
@@ -167,7 +143,6 @@ bst_rack_item_set_parasite (BstRackItem *self,
rack_item_parasite_changed (self);
}
}
-
static void
rack_item_button_press (GxkRackItem *xitem,
GdkEventButton *event)
@@ -178,7 +153,6 @@ rack_item_button_press (GxkRackItem *xitem,
{
gboolean can_clone = self->pocket && self->bparam && self->proxy && self->pspec;
guint id;
-
if (!self->choice)
{
self->controller_choice = create_controller_menu ();
diff --git a/beast-gtk/bstrackitem.hh b/beast-gtk/bstrackitem.hh
index deab9dc..2f0c683 100644
--- a/beast-gtk/bstrackitem.hh
+++ b/beast-gtk/bstrackitem.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_RACK_ITEM_H__
#define __BST_RACK_ITEM_H__
-
#include "bstracktable.hh"
#include "bstparam.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_RACK_ITEM (bst_rack_item_get_type ())
#define BST_RACK_ITEM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_RACK_ITEM, BstRackItem))
@@ -14,26 +11,21 @@ G_BEGIN_DECLS
#define BST_IS_RACK_ITEM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_RACK_ITEM))
#define BST_IS_RACK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_RACK_ITEM))
#define BST_RACK_ITEM_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_RACK_ITEM, BstRackItemClass))
-
/* --- structures & typedefs --- */
typedef struct {
GxkRackItem parent_instance;
SfiProxy proxy;
const gchar *path;
SfiRec *rec;
-
guint block_updates;
GtkWidget *controller_choice;
GtkWidget *choice;
-
/* pocket data */
GParamSpec *pspec;
gchar *ctype;
-
GxkParam *param;
} BstRackItem;
typedef struct _GxkRackItemClass BstRackItemClass;
-
/* --- prototypes --- */
GType bst_rack_item_get_type (void);
GtkWidget* bst_rack_item_new (SfiProxy proxy,
@@ -41,8 +33,5 @@ GtkWidget* bst_rack_item_new (SfiProxy proxy,
void bst_rack_item_set_parasite (BstRackItem *self,
SfiProxy proxy,
const gchar *path);
-
-
G_END_DECLS
-
#endif /* __BST_RACK_ITEM_H__ */
diff --git a/beast-gtk/bstracktable.cc b/beast-gtk/bstracktable.cc
index 70b4169..5bcf0d3 100644
--- a/beast-gtk/bstracktable.cc
+++ b/beast-gtk/bstracktable.cc
@@ -6,7 +6,6 @@
#include "bstutils.hh"
#include <gtk/gtkalignment.h>
#include <gtk/gtklabel.h>
-
typedef enum
{
EXPOSE_AREA,
@@ -14,8 +13,6 @@ typedef enum
DRAW_ACTIVE,
DRAW_INACTIVE,
} AreaAction;
-
-
/* --- prototypes --- */
static void bst_rack_table_class_init (BstRackTableClass *klass);
static void bst_rack_table_init (BstRackTable *rtable);
@@ -62,20 +59,15 @@ static void widget_reparent (GtkWidget *child,
GtkWidget *parent);
static void rtable_abort_drag (BstRackTable *rtable,
guint32 etime);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static GQuark quark_rack_info = 0;
static guint signal_edit_mode_changed = 0;
-
-
/* --- functions --- */
GtkType
bst_rack_table_get_type (void)
{
static GType object_type = 0;
-
if (!object_type)
{
static const GTypeInfo object_info = {
@@ -89,15 +81,12 @@ bst_rack_table_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) bst_rack_table_init,
};
-
object_type = g_type_register_static (GTK_TYPE_TABLE,
"BstRackTable",
&object_info, GTypeFlags (0));
}
-
return object_type;
}
-
static void
bst_rack_table_class_init (BstRackTableClass *klass)
{
@@ -105,15 +94,10 @@ bst_rack_table_class_init (BstRackTableClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
quark_rack_info = g_quark_from_static_string ("BstRackChildInfo");
-
gobject_class->finalize = bst_rack_table_finalize;
-
object_class->destroy = bst_rack_table_destroy;
-
widget_class->style_set = bst_rack_table_style_set;
widget_class->size_request = bst_rack_table_size_request;
widget_class->size_allocate = bst_rack_table_size_allocate;
@@ -125,10 +109,8 @@ bst_rack_table_class_init (BstRackTableClass *klass)
widget_class->button_release_event = bst_rack_table_button_release;
widget_class->motion_notify_event = bst_rack_table_motion_notify;
widget_class->expose_event = bst_rack_table_expose;
-
container_class->add = bst_rack_table_add;
container_class->remove = bst_rack_table_remove;
-
signal_edit_mode_changed = g_signal_new ("edit-mode-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
@@ -137,7 +119,6 @@ bst_rack_table_class_init (BstRackTableClass *klass)
bst_marshal_NONE__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}
-
static void
bst_rack_table_init (BstRackTable *rtable)
{
@@ -151,7 +132,6 @@ bst_rack_table_init (BstRackTable *rtable)
NULL);
rtable->cell_request_width = 0;
rtable->cell_request_height = 0;
-
rtable->drag_window = (GtkWidget*) g_object_new (GTK_TYPE_WINDOW,
"type", GTK_WINDOW_POPUP,
"width_request", rtable->cell_request_width,
@@ -164,42 +144,32 @@ bst_rack_table_init (BstRackTable *rtable)
"visible", TRUE,
NULL);
}
-
static void
bst_rack_table_destroy (GtkObject *object)
{
BstRackTable *rtable = BST_RACK_TABLE (object);
-
rtable_abort_drag (rtable, GDK_CURRENT_TIME);
-
if (rtable->drag_window)
{
gtk_widget_destroy (rtable->drag_window);
rtable->drag_window = NULL;
}
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_rack_table_finalize (GObject *object)
{
BstRackTable *rtable = BST_RACK_TABLE (object);
-
g_free (rtable->child_map);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bst_rack_table_realize (GtkWidget *widget)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
GdkWindowAttr attributes;
gint attributes_mask;
-
GTK_WIDGET_CLASS (parent_class)->realize (widget);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -215,12 +185,10 @@ bst_rack_table_realize (GtkWidget *widget)
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
-
rtable->iwindow = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (rtable->iwindow, rtable);
}
-
static void
bst_rack_table_style_set (GtkWidget *widget,
GtkStyle *previous_style)
@@ -228,17 +196,14 @@ bst_rack_table_style_set (GtkWidget *widget,
BstRackTable *rtable = BST_RACK_TABLE (widget);
GdkFont *font = gtk_style_get_font (widget->style);
guint i, x = 0;
-
for (i = 0; i < 256; i++)
{
guint width = gdk_char_width (font, i);
-
x = MAX (x, width);
}
rtable->cell_request_width = x;
rtable->cell_request_height = font->ascent + font->descent;
}
-
static void
bst_rack_table_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -247,15 +212,12 @@ bst_rack_table_size_request (GtkWidget *widget,
GtkTable *table = GTK_TABLE (rtable);
GList *list;
guint i, j;
-
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
-
if (GTK_WIDGET_VISIBLE (child->widget))
gtk_widget_size_request (child->widget, NULL);
}
-
requisition->width = GTK_CONTAINER (rtable)->border_width * 2;
requisition->height = GTK_CONTAINER (rtable)->border_width * 2;
for (i = 0; i < table->ncols; i++)
@@ -269,21 +231,16 @@ bst_rack_table_size_request (GtkWidget *widget,
requisition->height += table->rows[j].requisition;
}
}
-
static void
bst_rack_table_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (rtable);
-
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
bst_rtable_update_child_map (rtable);
-
rtable->cell_width = table->cols[0].allocation;
rtable->cell_height = table->rows[0].allocation;
-
if (GTK_WIDGET_REALIZED (rtable))
{
gdk_window_move_resize (rtable->iwindow,
@@ -292,42 +249,31 @@ bst_rack_table_size_allocate (GtkWidget *widget,
gdk_window_raise (rtable->iwindow);
}
}
-
static void
bst_rack_table_unrealize (GtkWidget *widget)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
-
gdk_window_set_user_data (rtable->iwindow, NULL);
gdk_window_destroy (rtable->iwindow);
rtable->iwindow = NULL;
-
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
-
static void
bst_rack_table_map (GtkWidget *widget)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
-
GTK_WIDGET_CLASS (parent_class)->map (widget);
-
if (rtable->edit_mode)
gdk_window_show (rtable->iwindow);
}
-
static void
bst_rack_table_unmap (GtkWidget *widget)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
-
rtable_abort_drag (rtable, GDK_CURRENT_TIME);
-
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
gdk_window_hide (rtable->iwindow);
}
-
static void
widget_reparent (GtkWidget *child,
GtkWidget *parent)
@@ -337,22 +283,18 @@ widget_reparent (GtkWidget *child,
gtk_container_add (GTK_CONTAINER (parent), child);
g_object_unref (child);
}
-
static gint
bst_rack_table_button_press (GtkWidget *widget,
GdkEventButton *event)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (rtable);
-
if (!rtable->edit_mode)
return FALSE;
-
if (event->type == GDK_BUTTON_PRESS && event->button == 2)
{
bool was_dragging = rtable->in_drag;
uint h, v;
-
if (bst_rack_table_iwindow_translate (rtable, event->x, event->y, &h, &v))
rtable->child = bst_rack_table_find_child (rtable, h, v);
rtable->in_drag = rtable->child != NULL;
@@ -361,7 +303,6 @@ bst_rack_table_button_press (GtkWidget *widget,
if (!was_dragging)
{
GdkCursor *cursor = gdk_cursor_new (GDK_FLEUR);
-
rtable->in_drag_and_grabbing = gdk_pointer_grab (rtable->iwindow, FALSE,
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
@@ -415,33 +356,26 @@ bst_rack_table_button_press (GtkWidget *widget,
#endif
(void) child;
}
-
return TRUE;
}
-
static gint
bst_rack_table_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (rtable);
-
if (rtable->in_drag)
{
guint h, v;
gint x, y;
-
gtk_window_move (GTK_WINDOW (rtable->drag_window), event->x_root - rtable->xofs, event->y_root - rtable->yofs);
-
if (event->is_hint) /* trigger new events */
gdk_window_get_pointer (widget->window, NULL, NULL, NULL);
-
/* translate x/y to first cell mid-point */
x = event->x - rtable->xofs;
y = event->y - rtable->yofs;
x += rtable->cell_width / 2;
y += rtable->cell_height / 2;
-
if (!bst_rack_table_iwindow_translate (rtable, x, y, &h, &v) ||
h >= table->ncols || v >= table->nrows ||
h + rtable->drag_info.hspan > table->ncols ||
@@ -467,10 +401,8 @@ bst_rack_table_motion_notify (GtkWidget *widget,
rtable->drag_info.vspan);
}
}
-
return TRUE;
}
-
static void
rtable_abort_drag (BstRackTable *rtable,
guint32 etime)
@@ -491,19 +423,15 @@ rtable_abort_drag (BstRackTable *rtable,
rtable->child = NULL;
}
}
-
static gint
bst_rack_table_button_release (GtkWidget *widget,
GdkEventButton *event)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
-
if (rtable->in_drag && event->button == 2)
rtable_abort_drag (rtable, event->time);
-
return TRUE;
}
-
static void
bst_rack_table_on_area (BstRackTable *rtable,
AreaAction action,
@@ -515,16 +443,13 @@ bst_rack_table_on_area (BstRackTable *rtable,
GtkWidget *widget = GTK_WIDGET (rtable);
GtkTable *table = GTK_TABLE (rtable);
guint i, x, y, width, height, hcell2 = hcell1 + hspan, vcell2 = vcell1 + vspan;
-
g_return_if_fail (hspan > 0 && hcell2 <= table->ncols);
g_return_if_fail (vspan > 0 && vcell2 <= table->nrows);
-
x = GTK_CONTAINER (widget)->border_width + widget->allocation.x;
width = 0;
for (i = 0; i < hcell2; i++)
{
guint bound = table->cols[i].allocation + table->cols[i].spacing;
-
if (i < hcell1)
x += bound;
else
@@ -535,13 +460,11 @@ bst_rack_table_on_area (BstRackTable *rtable,
for (i = 0; i < vcell2; i++)
{
guint bound = table->rows[i].allocation + table->rows[i].spacing;
-
if (i < vcell1)
y += bound;
else
height += bound;
}
-
switch (action)
{
GdkGC *bg_gc, *dark_gc, *light_gc;
@@ -592,25 +515,21 @@ bst_rack_table_on_area (BstRackTable *rtable,
break;
}
}
-
static gint
bst_rack_table_expose (GtkWidget *widget,
GdkEventExpose *event)
{
BstRackTable *rtable = BST_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (rtable);
-
if (rtable->edit_mode)
{
uint h1 = rtable->drag_info.col, h2 = h1 + rtable->drag_info.hspan;
uint v1 = rtable->drag_info.row, v2 = v1 + rtable->drag_info.vspan;
int x = GTK_CONTAINER (rtable)->border_width + GTK_WIDGET (rtable)->allocation.x, bx = 0;
uint i, j;
-
for (i = 0; i < table->ncols; i++)
{
int y = GTK_CONTAINER (rtable)->border_width + GTK_WIDGET (rtable)->allocation.y, by = 0;
-
bx = table->cols[i].allocation + table->cols[i].spacing;
if (x > event->area.x + event->area.width || x + bx < event->area.x)
{
@@ -640,12 +559,9 @@ bst_rack_table_expose (GtkWidget *widget,
x += bx;
}
}
-
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-
return FALSE;
}
-
static void
bst_rack_table_add (GtkContainer *container,
GtkWidget *child)
@@ -653,7 +569,6 @@ bst_rack_table_add (GtkContainer *container,
BstRackTable *rtable = BST_RACK_TABLE (container);
GtkTable *table = GTK_TABLE (rtable);
BstRackChildInfo rinfo = { 0, };
-
bst_rack_child_get_info (child, &rinfo);
if (rinfo.hspan < 1)
rinfo.hspan = 4;
@@ -665,7 +580,6 @@ bst_rack_table_add (GtkContainer *container,
bst_rack_table_check_area (rtable, rinfo.col, rinfo.row, rinfo.hspan, rinfo.vspan))
{
guint row, col = 0; /* silence compiler */
-
for (row = 0; row < table->nrows; row++)
for (col = 0; col + rinfo.hspan <= table->ncols; col++)
if (!bst_rack_table_check_area (rtable, col, row, rinfo.hspan, rinfo.vspan))
@@ -689,21 +603,17 @@ bst_rack_table_add (GtkContainer *container,
bst_rack_item_gui_changed (BST_RACK_ITEM (child));
#endif
}
-
static void
bst_rack_table_remove (GtkContainer *container,
GtkWidget *child)
{
BstRackTable *rtable = BST_RACK_TABLE (container);
-
/* cause a map-update */
rtable->map_cols = 0;
rtable->map_rows = 0;
-
/* chain parent class' handler */
GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
}
-
static gboolean
bst_rack_table_iwindow_translate (BstRackTable *rtable,
gint x,
@@ -713,13 +623,11 @@ bst_rack_table_iwindow_translate (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i;
-
x -= GTK_CONTAINER (rtable)->border_width;
*hcell = 0;
for (i = 0; i < table->ncols; i++)
{
int bound = table->cols[i].allocation + table->cols[i].spacing;
-
if (x < bound)
{
*hcell = i;
@@ -729,13 +637,11 @@ bst_rack_table_iwindow_translate (BstRackTable *rtable,
}
if (i >= table->ncols)
*hcell = table->ncols;
-
y -= GTK_CONTAINER (rtable)->border_width;
*vcell = 0;
for (i = 0; i < table->nrows; i++)
{
int bound = table->rows[i].allocation + table->rows[i].spacing;
-
if (y < bound)
{
*vcell = i;
@@ -745,10 +651,8 @@ bst_rack_table_iwindow_translate (BstRackTable *rtable,
}
if (i >= table->nrows)
*vcell = table->nrows;
-
return x >= 0 && *hcell < table->ncols && y >= 0 && *vcell < table->nrows;
}
-
static GtkWidget*
bst_rack_table_find_child (BstRackTable *rtable,
guint hcell,
@@ -756,11 +660,9 @@ bst_rack_table_find_child (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
GList *list;
-
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
-
if (hcell >= child->left_attach && hcell < child->right_attach &&
vcell >= child->top_attach && vcell < child->bottom_attach)
{
@@ -775,17 +677,14 @@ bst_rack_table_find_child (BstRackTable *rtable,
#endif
}
}
-
return NULL;
}
-
static void
bst_rtable_update_child_map (BstRackTable *rtable)
{
GtkTable *table = GTK_TABLE (rtable);
guint32 *bits;
guint i, j, n = 0;
-
rtable->map_cols = table->ncols;
rtable->map_rows = table->nrows;
g_free (rtable->child_map);
@@ -803,40 +702,32 @@ bst_rtable_update_child_map (BstRackTable *rtable)
}
}
}
-
static inline guint
test_cell (guint32 *bits,
guint col,
guint row_offset)
{
guint i, n;
-
i = row_offset + col;
n = i >> 5;
bits += n;
i &= 0x1f;
return *bits & (1 << i);
}
-
gboolean
bst_rack_table_check_cell (BstRackTable *rtable,
guint col,
guint row)
{
GtkTable *table;
-
g_return_val_if_fail (BST_IS_RACK_TABLE (rtable), FALSE);
-
table = GTK_TABLE (rtable);
if (col >= table->ncols || row >= table->nrows)
return FALSE;
-
if (table->ncols != rtable->map_cols || table->nrows != rtable->map_rows)
bst_rtable_update_child_map (rtable);
-
return test_cell (rtable->child_map, col, row * table->ncols) > 0;
}
-
gboolean
bst_rack_table_expand_rect (BstRackTable *rtable,
guint col,
@@ -846,14 +737,11 @@ bst_rack_table_expand_rect (BstRackTable *rtable,
{
GtkTable *table;
guint i, j, f;
-
g_return_val_if_fail (BST_IS_RACK_TABLE (rtable), FALSE);
-
table = GTK_TABLE (rtable);
if (col + 1 >= table->ncols || row + 1 >= table->nrows ||
bst_rack_table_check_cell (rtable, col, row))
return FALSE;
-
/* h/v expand */
for (i = 1; col + i < table->ncols; i++)
if (test_cell (rtable->child_map, col + i, row * table->ncols))
@@ -865,7 +753,6 @@ bst_rack_table_expand_rect (BstRackTable *rtable,
last_row_break:
*hspan = i;
*vspan = j;
-
/* v/h expand */
for (j = j; row + j < table->nrows; j++)
if (test_cell (rtable->child_map, col, (row + j) * table->ncols))
@@ -884,7 +771,6 @@ bst_rack_table_expand_rect (BstRackTable *rtable,
}
return TRUE;
}
-
gboolean
bst_rack_table_check_area (BstRackTable *rtable,
guint col,
@@ -894,26 +780,21 @@ bst_rack_table_check_area (BstRackTable *rtable,
{
GtkTable *table;
guint i, j;
-
g_return_val_if_fail (BST_IS_RACK_TABLE (rtable), FALSE);
-
table = GTK_TABLE (rtable);
if (col >= table->ncols || row >= table->nrows)
return FALSE;
-
for (i = 0; i < hspan; i++)
for (j = 0; j < vspan; j++)
if (bst_rack_table_check_cell (rtable, col + i, row + j))
return TRUE;
return FALSE;
}
-
void
bst_rack_table_set_edit_mode (BstRackTable *rtable,
gboolean enable_editing)
{
g_return_if_fail (BST_IS_RACK_TABLE (rtable));
-
rtable->edit_mode = enable_editing != FALSE;
if (GTK_WIDGET_REALIZED (rtable))
{
@@ -928,14 +809,12 @@ bst_rack_table_set_edit_mode (BstRackTable *rtable,
}
g_signal_emit (rtable, signal_edit_mode_changed, 0, rtable->edit_mode);
}
-
void
bst_rack_child_get_info (GtkWidget *widget,
BstRackChildInfo *info)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (info != NULL);
-
#if 0
if (BST_IS_RACK_ITEM (widget))
*info = BST_RACK_ITEM (widget)->rack_child_info;
@@ -954,7 +833,6 @@ bst_rack_child_get_info (GtkWidget *widget,
}
#endif
}
-
void
bst_rack_child_set_info (GtkWidget *widget,
gint col,
@@ -963,16 +841,13 @@ bst_rack_child_set_info (GtkWidget *widget,
gint vspan)
{
GtkWidget *parent = NULL;
-
g_return_if_fail (GTK_IS_WIDGET (widget));
-
g_object_ref (widget);
if (BST_IS_RACK_TABLE (widget->parent))
{
parent = widget->parent;
gtk_container_remove (GTK_CONTAINER (parent), widget);
}
-
#if 0
BstRackChildInfo *rinfo;
if (BST_IS_RACK_ITEM (widget))
diff --git a/beast-gtk/bstracktable.hh b/beast-gtk/bstracktable.hh
index 9d14702..82d42a9 100644
--- a/beast-gtk/bstracktable.hh
+++ b/beast-gtk/bstracktable.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_RACK_TABLE_H__
#define __BST_RACK_TABLE_H__
-
#include "bstutils.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BST_TYPE_RACK_TABLE (bst_rack_table_get_type ())
#define BST_RACK_TABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_RACK_TABLE, BstRackTable))
@@ -16,8 +12,6 @@ extern "C" {
#define BST_IS_RACK_TABLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_RACK_TABLE))
#define BST_IS_RACK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_RACK_TABLE))
#define BST_RACK_TABLE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_RACK_TABLE, BstRackTableClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstRackTable BstRackTable;
typedef struct _BstRackTableClass BstRackTableClass;
@@ -30,18 +24,14 @@ struct _BstRackChildInfo
struct _BstRackTable
{
GtkTable parent_object;
-
GtkWidget *drag_window;
-
guint map_cols;
guint map_rows;
guint32 *child_map;
-
guint cell_request_width;
guint cell_request_height;
guint cell_width;
guint cell_height;
-
GdkWindow *iwindow;
guint edit_mode : 1;
guint in_drag : 2;
@@ -56,14 +46,11 @@ struct _BstRackTable
struct _BstRackTableClass
{
GtkTableClass parent_class;
-
void (*edit_mode_changed) (BstRackTable *rtable,
gboolean edit_mode);
void (*child_changed) (BstRackTable *rtable,
GtkWidget *child);
};
-
-
/* --- prototypes --- */
GtkType bst_rack_table_get_type (void);
void bst_rack_table_set_edit_mode (BstRackTable *rtable,
@@ -88,9 +75,7 @@ void bst_rack_child_set_info (GtkWidget *widget,
gint row,
gint hspan,
gint vspan);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_RACK_TABLE_H__ */
diff --git a/beast-gtk/bstrackview.cc b/beast-gtk/bstrackview.cc
index e3adeb8..d1cc3c2 100644
--- a/beast-gtk/bstrackview.cc
+++ b/beast-gtk/bstrackview.cc
@@ -2,7 +2,6 @@
#include "bstrackview.hh"
#include "bstrackitem.hh"
#include "gxk/gxkrackeditor.hh"
-
/* --- prototypes --- */
static void rack_view_class_init (BstRackViewClass *klass);
static void rack_view_init (BstRackView *self);
@@ -15,9 +14,6 @@ static void rack_view_popup_action (gpointer user_data,
static gboolean rack_view_popup_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
-
/* --- rack view actions --- */
enum {
ACTION_ADD_LABEL,
@@ -31,12 +27,8 @@ static const GxkStockAction rack_view_popup_actions[] = {
ACTION_ADD_LABEL, BST_STOCK_NO_ICON,
},
};
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
bst_rack_view_get_type (void)
@@ -59,20 +51,15 @@ bst_rack_view_get_type (void)
}
return type;
}
-
static void
rack_view_class_init (BstRackViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = rack_view_finalize;
-
object_class->destroy = rack_view_destroy;
}
-
static void
toggle_edit_mode (GtkToggleButton *tb,
BstRackView *self)
@@ -83,7 +70,6 @@ toggle_edit_mode (GtkToggleButton *tb,
gxk_widget_update_actions_upwards (self->rack_table);
}
}
-
static void
rack_view_init (BstRackView *self)
{
@@ -104,27 +90,20 @@ rack_view_init (BstRackView *self)
G_N_ELEMENTS (rack_view_popup_actions), rack_view_popup_actions,
NULL, rack_view_popup_action_check, rack_view_popup_action);
}
-
static void
rack_view_destroy (GtkObject *object)
{
BstRackView *self = BST_RACK_VIEW (object);
-
bst_rack_view_set_item (self, 0);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
rack_view_finalize (GObject *object)
{
BstRackView *self = BST_RACK_VIEW (object);
-
bst_rack_view_set_item (self, 0);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
GtkWidget*
bst_rack_view_new (SfiProxy item)
{
@@ -136,13 +115,11 @@ bst_rack_view_new (SfiProxy item)
}
return self;
}
-
static void
rack_view_reset_item (BstRackView *self)
{
bst_rack_view_set_item (self, 0);
}
-
static void
rack_view_parasites_added (BstRackView *self)
{
@@ -156,7 +133,6 @@ rack_view_parasites_added (BstRackView *self)
gtk_container_add (GTK_CONTAINER (self->rack_table), item);
}
}
-
void
bst_rack_view_set_item (BstRackView *self,
SfiProxy item)
@@ -164,10 +140,8 @@ bst_rack_view_set_item (BstRackView *self,
g_return_if_fail (BST_IS_RACK_VIEW (self));
if (item)
g_return_if_fail (BSE_IS_ITEM (item));
-
if (item == self->item)
return;
-
if (self->item)
{
bse_proxy_disconnect (self->item,
@@ -182,16 +156,13 @@ bst_rack_view_set_item (BstRackView *self,
"swapped_signal::release", rack_view_reset_item, self,
"swapped_signal::parasites-added::/beast-rack-view/", rack_view_parasites_added, self,
NULL);
-
bst_rack_view_rebuild (self);
}
-
void
bst_rack_view_rebuild (BstRackView *self)
{
GtkWidget *toggle;
g_return_if_fail (BST_IS_RACK_VIEW (self));
-
gtk_container_foreach (GTK_CONTAINER (self->rack_table), (GtkCallback) gtk_widget_destroy, NULL);
toggle = (GtkWidget*) gxk_radget_find (self, "edit-toggle");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), FALSE);
@@ -199,7 +170,6 @@ bst_rack_view_rebuild (BstRackView *self)
return;
rack_view_parasites_added (self);
}
-
static gboolean
rack_view_button_press_event (BstRackView *self,
GdkEventButton *event)
@@ -213,7 +183,6 @@ rack_view_button_press_event (BstRackView *self,
}
return FALSE;
}
-
static void
rack_view_popup_action (gpointer user_data,
gulong action_id)
@@ -234,7 +203,6 @@ rack_view_popup_action (gpointer user_data,
break;
}
}
-
static gboolean
rack_view_popup_action_check (gpointer data,
gulong action,
diff --git a/beast-gtk/bstrackview.hh b/beast-gtk/bstrackview.hh
index 4910c0b..9c75f65 100644
--- a/beast-gtk/bstrackview.hh
+++ b/beast-gtk/bstrackview.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_RACK_VIEW_H__
#define __BST_RACK_VIEW_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_RACK_VIEW (bst_rack_view_get_type ())
#define BST_RACK_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_RACK_VIEW, BstRackView))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_RACK_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_RACK_VIEW))
#define BST_IS_RACK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_RACK_VIEW))
#define BST_RACK_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_RACK_VIEW, BstRackViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstRackView BstRackView;
typedef struct _BstRackViewClass BstRackViewClass;
@@ -28,16 +23,11 @@ struct _BstRackViewClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_rack_view_get_type (void);
GtkWidget* bst_rack_view_new (SfiProxy item);
void bst_rack_view_set_item (BstRackView *self,
SfiProxy item);
void bst_rack_view_rebuild (BstRackView *self);
-
-
G_END_DECLS
-
#endif /* __BST_RACK_VIEW_H__ */
diff --git a/beast-gtk/bstrecords.idl b/beast-gtk/bstrecords.idl
index 18d23a8..7b09725 100644
--- a/beast-gtk/bstrecords.idl
+++ b/beast-gtk/bstrecords.idl
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
namespace Bst {
/*
choice Test1 {
@@ -11,17 +10,14 @@ record Test2 {
};
*/
using namespace Sfi;
-
Const STORAGE = ":r:w:S:";
Const STANDARD = STORAGE "G:";
-
choice Direction {
UP = (_("Up"), _("Move upwards")),
LEFT = (_("Left"), _("Move to the left")),
RIGHT = (_("Right"), _("Move to the right")),
DOWN = (_("Down"), _("Move downwards"))
};
-
choice FFTSize {
FFT_SIZE_2 = (_("2 Value FFT Window"), _("A 2 value FFT window corresponds to a spectrum with 2 frequency peaks")),
FFT_SIZE_4 = (_("4 Value FFT Window"), _("A 4 value FFT window corresponds to a spectrum with 3 frequency peaks")),
@@ -40,7 +36,6 @@ choice FFTSize {
FFT_SIZE_32768 = (_("32768 Value FFT Window"), _("A 32768 value FFT window corresponds to a spectrum with 16385 frequency peaks")),
FFT_SIZE_65536 = (_("65536 Value FFT Window"), _("A 65536 value FFT window corresponds to a spectrum with 32769 frequency peaks")),
};
-
choice NoteLength {
NOTE_LENGTH_NONE = (Neutral, _("None"), _("Unspecified length")),
NOTE_LENGTH_1 = (_("1/1"), _("Whole note")),
@@ -68,7 +63,6 @@ choice NoteLength {
NOTE_LENGTH_64T = (_("1/64T"), _("Triplet sixty-fourth note")),
NOTE_LENGTH_128T = (_("1/128T"),_("Triplet hundred twenty-eighth note")),
};
-
choice RowShading {
ROW_SHADING_NONE = (Neutral, _("None")),
ROW_SHADING_2 = (_("2"), _("Every second row")),
@@ -87,7 +81,6 @@ choice RowShading {
ROW_SHADING_3_12 = (_("3 & 12"), _("Every third and twelfth row")),
ROW_SHADING_6_12 = (_("6 & 12"), _("Every sixth and twelfth row")),
};
-
/* BEAST Global Config */
record GConfig {
String rc_version = (NULL, _("Release counter"), NULL, STORAGE);
@@ -114,7 +107,6 @@ record GConfig {
FALSE, STANDARD);
};
};
-
/* skin config */
record SkinConfig {
String skin_name = (_("Skin Name"), _("Name for the current skin configuration (used for skin selections)."), NULL, STANDARD);
@@ -149,7 +141,6 @@ record SkinConfig {
Int controls_negative = (_("Negative Value Color"), NULL, 0x0000ff, 0, 0xffffff, 0x010101, STANDARD ":rgb:hex");
};
};
-
/* message filter */
record MsgAbsorbString {
String version;
@@ -159,7 +150,6 @@ record MsgAbsorbString {
sequence MsgAbsorbStringSeq {
MsgAbsorbString strings;
};
-
/* pattern editor key bindings */
record KeyBindingItem {
String key_name = (NULL, NULL, NULL, STANDARD);
@@ -169,5 +159,4 @@ record KeyBindingItem {
sequence KeyBindingItemSeq {
KeyBindingItem items;
};
-
};
diff --git a/beast-gtk/bstrtest.cc b/beast-gtk/bstrtest.cc
index f4965a8..ddbd313 100644
--- a/beast-gtk/bstrtest.cc
+++ b/beast-gtk/bstrtest.cc
@@ -2,9 +2,7 @@
#include <gtk/gtk.h>
#include "bstracktable.hh"
#include "bstdial.hh"
-
static GSList *plate_list = NULL;
-
static GtkWidget*
make_cover (GtkWidget *rtable)
{
@@ -31,36 +29,28 @@ make_cover (GtkWidget *rtable)
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *pix;
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
gdk_pixmap_unref (pixmap);
gdk_pixmap_unref (mask);
-
pix = g_object_new (GTK_TYPE_ALIGNMENT, "visible", TRUE, NULL);
gtk_table_attach (table, pix, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0);
-
return cover;
}
-
static void
rtable_grow_area_horizontal (BstRackTable *rtable,
guint col,
@@ -70,7 +60,6 @@ rtable_grow_area_horizontal (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (i = 1; col + i < table->ncols; i++)
if (bst_rack_table_check_cell (rtable, col + i, row))
break;
@@ -80,7 +69,6 @@ rtable_grow_area_horizontal (BstRackTable *rtable,
*hspan = i;
*vspan = j;
}
-
static void
rtable_grow_area_vertical (BstRackTable *rtable,
guint col,
@@ -90,7 +78,6 @@ rtable_grow_area_vertical (BstRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (j = 1; row + j < table->nrows; j++)
if (bst_rack_table_check_cell (rtable, col, row + j))
break;
@@ -100,7 +87,6 @@ rtable_grow_area_vertical (BstRackTable *rtable,
*hspan = i;
*vspan = j;
}
-
static void
add_plates (BstRackTable *rtable)
{
@@ -108,9 +94,7 @@ add_plates (BstRackTable *rtable)
GtkWidget *cover;
guint i, j, max;
guint k, l, m, n;
-
table = GTK_TABLE (rtable);
-
#if 0
for (i = 0; i < table->ncols; i++)
for (j = 0; j < table->nrows; j++)
@@ -118,13 +102,11 @@ add_plates (BstRackTable *rtable)
{
rtable_grow_area_vertical (rtable, i, j, &k, &l);
rtable_grow_area_horizontal (rtable, i, j, &m, &n);
-
if (m * n > k * l)
{
k = m;
l = n;
}
-
cover = make_cover (GTK_WIDGET (rtable));
plate_list = g_slist_prepend (plate_list, cover);
bst_rack_widget_set_info (cover, i, j, k, l);
@@ -144,7 +126,6 @@ add_plates (BstRackTable *rtable)
if (!bst_rack_table_check_cell (rtable, i, j))
{
guint t, u, v, w;
-
max_free--;
bst_rack_table_expand_rect (rtable, i, j, &t, &u);
if (t * u > max)
@@ -174,7 +155,6 @@ add_plates (BstRackTable *rtable)
while (max > 0);
#endif
}
-
static void
rtable_toggle_edit (BstRackTable *rtable)
{
@@ -184,23 +164,19 @@ rtable_toggle_edit (BstRackTable *rtable)
else
{
GSList *slist;
-
for (slist = plate_list; slist; slist = slist->next)
gtk_widget_destroy (slist->data);
g_slist_free (plate_list);
plate_list = NULL;
}
}
-
int
main (int argc,
char *argv[])
{
GtkWidget *window, *vbox, *hbox, *rtable, *dial, *button, *scale, *frame;
gpointer adjustment;
-
gtk_init (&argc, &argv);
-
window = g_object_new (GTK_TYPE_WINDOW, NULL);
g_object_connect (window,
"signal::destroy", gtk_main_quit, NULL,
@@ -219,7 +195,6 @@ main (int argc,
"border_width", 10,
NULL);
gtk_table_resize (GTK_TABLE (rtable), 40, 60);
-
frame = g_object_new (GTK_TYPE_FRAME,
"visible", TRUE,
"child", g_object_new (GTK_TYPE_LABEL,
@@ -229,7 +204,6 @@ main (int argc,
NULL);
bst_rack_widget_set_info (frame, -1, -1, 16, 16);
gtk_container_add (GTK_CONTAINER (rtable), frame);
-
bst_rack_widget_set_info (g_object_new (GTK_TYPE_LABEL,
"visible", TRUE,
"label", "HAHA21",
@@ -246,7 +220,6 @@ main (int argc,
"label", "v37____u",
"parent", rtable,
NULL);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"label", "Edit",
"parent", hbox,
@@ -254,9 +227,7 @@ main (int argc,
NULL),
"swapped_signal::clicked", rtable_toggle_edit, rtable,
NULL);
-
adjustment = gtk_adjustment_new (0, 0, 1, 0.05, 0.25, 0.5);
-
dial = g_object_new (BST_TYPE_DIAL,
"visible", TRUE,
"parent", g_object_new (GTK_TYPE_FRAME,
@@ -267,7 +238,6 @@ main (int argc,
NULL),
NULL);
bst_dial_set_adjustment (BST_DIAL (dial), adjustment);
-
frame = g_object_new (GTK_TYPE_FRAME,
"visible", TRUE,
"shadow_type", GTK_SHADOW_ETCHED_OUT,
@@ -281,7 +251,6 @@ main (int argc,
NULL);
bst_rack_widget_set_info (frame, -1, -1, 8, 4);
gtk_container_add (GTK_CONTAINER (rtable), frame);
-
scale = g_object_new (GTK_TYPE_VSCALE,
"visible", TRUE,
"draw_value", FALSE,
@@ -289,10 +258,8 @@ main (int argc,
NULL);
bst_rack_widget_set_info (scale, -1, -1, 4, 16);
gtk_container_add (GTK_CONTAINER (rtable), scale);
-
add_plates (rtable);
gtk_widget_show (window);
gtk_main ();
-
return 0;
}
diff --git a/beast-gtk/bstsampleeditor.cc b/beast-gtk/bstsampleeditor.cc
index 7f5230f..31dd185 100644
--- a/beast-gtk/bstsampleeditor.cc
+++ b/beast-gtk/bstsampleeditor.cc
@@ -1,19 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstsampleeditor.hh"
-
#include "bstprocedure.hh"
#include "bstmenus.hh"
#include <gdk/gdkkeysyms.h>
-
-
/* --- parameters --- */
enum
{
PARAM_0,
PARAM_SAMPLE
};
-
-
/* --- prototypes --- */
static void bst_sample_editor_class_init (BstSampleEditorClass *klass);
static void bst_sample_editor_init (BstSampleEditor *sample_editor);
@@ -27,18 +22,13 @@ static void bst_sample_editor_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GtkType
bst_sample_editor_get_type (void)
{
static GtkType sample_editor_type = 0;
-
if (!sample_editor_type)
{
GtkTypeInfo sample_editor_info =
@@ -52,40 +42,31 @@ bst_sample_editor_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
sample_editor_type = gtk_type_unique (GTK_TYPE_VBOX, &sample_editor_info);
}
-
return sample_editor_type;
}
-
static void
bst_sample_editor_class_init (BstSampleEditorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
// GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bst_sample_editor_set_property;
gobject_class->get_property = bst_sample_editor_get_property;
gobject_class->finalize = bst_sample_editor_finalize;
-
object_class->destroy = bst_sample_editor_destroy;
-
g_object_class_install_property (gobject_class, PARAM_SAMPLE,
sfi_pspec_proxy ("sample", NULL, NULL,
SFI_PARAM_READWRITE));
}
-
static void
bst_sample_editor_init (BstSampleEditor *editor)
{
/* setup main container */
editor->main_vbox = GTK_WIDGET (editor);
}
-
static void
bst_sample_editor_set_property (GObject *object,
guint prop_id,
@@ -93,7 +74,6 @@ bst_sample_editor_set_property (GObject *object,
GParamSpec *pspec)
{
BstSampleEditor *editor = BST_SAMPLE_EDITOR (object);
-
switch (prop_id)
{
case PARAM_SAMPLE:
@@ -104,7 +84,6 @@ bst_sample_editor_set_property (GObject *object,
break;
}
}
-
static void
bst_sample_editor_get_property (GObject *object,
guint prop_id,
@@ -112,7 +91,6 @@ bst_sample_editor_get_property (GObject *object,
GParamSpec *pspec)
{
BstSampleEditor *editor = BST_SAMPLE_EDITOR (object);
-
switch (prop_id)
{
case PARAM_SAMPLE:
@@ -123,7 +101,6 @@ bst_sample_editor_get_property (GObject *object,
break;
}
}
-
void
bst_sample_editor_set_sample (BstSampleEditor *editor,
SfiProxy sample)
@@ -131,7 +108,6 @@ bst_sample_editor_set_sample (BstSampleEditor *editor,
g_return_if_fail (BST_IS_SAMPLE_EDITOR (editor));
if (sample)
g_return_if_fail (BSE_IS_EDITABLE_SAMPLE (sample));
-
if (sample != editor->esample)
{
if (editor->esample)
@@ -147,42 +123,31 @@ bst_sample_editor_set_sample (BstSampleEditor *editor,
g_object_notify (G_OBJECT (editor), "sample");
}
}
-
static void
bst_sample_editor_destroy (GtkObject *object)
{
BstSampleEditor *editor = BST_SAMPLE_EDITOR (object);
-
bst_sample_editor_set_sample (editor, 0);
-
if (editor->play_back)
bst_play_back_handle_destroy (editor->play_back);
editor->play_back = NULL;
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_sample_editor_finalize (GObject *object)
{
// BstSampleEditor *editor = BST_SAMPLE_EDITOR (object);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
GtkWidget*
bst_sample_editor_new (SfiProxy sample)
{
GtkWidget *widget;
-
widget = gtk_widget_new (BST_TYPE_SAMPLE_EDITOR, "sample", sample, NULL);
-
return widget;
}
-
#define QSAMPLER_SELECTION_TIMEOUT (33)
static gulong qsampler_selection_timeout_id = 0;
-
static void
qsampler_set_selection (BstQSampler *qsampler,
gint m1,
@@ -191,14 +156,12 @@ qsampler_set_selection (BstQSampler *qsampler,
{
BstSampleEditor *editor = BST_SAMPLE_EDITOR (qsampler->owner);
guint i, length = bse_editable_sample_get_length (editor->esample);
-
m1 = CLAMP (m1, 0, (gint) (length / editor->n_channels));
m2 = CLAMP (m2, 0, (gint) (length / editor->n_channels));
for (i = 0; i < editor->n_channels; i++)
{
BstQSampler *qs = editor->qsampler[i];
gchar *s;
-
bst_qsampler_set_mark (qs, 1, m1, BST_QSAMPLER_SELECTED);
bst_qsampler_set_mark (qs, 2, m2, BST_QSAMPLER_SELECTED);
bst_qsampler_set_region (qs, 1, MIN (m1, m2), 1 + MAX (m1, m2) - MIN (m1, m2), BST_QSAMPLER_SELECTED);
@@ -214,22 +177,18 @@ qsampler_set_selection (BstQSampler *qsampler,
g_free (s);
}
}
-
static gboolean
qsampler_selection_timeout (gpointer data)
{
BstQSampler *qsampler;
gboolean retain = FALSE;
-
GDK_THREADS_ENTER ();
-
qsampler = BST_QSAMPLER (data);
if (GTK_WIDGET_DRAWABLE (qsampler))
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x;
-
gdk_window_get_pointer (GTK_WIDGET (qsampler)->window, &x, NULL, NULL);
bst_qsampler_get_offset_at (qsampler, &x);
retain = x < qsampler->pcm_length && x >= 0;
@@ -238,7 +197,6 @@ qsampler_selection_timeout (gpointer data)
else
qsampler_set_selection (qsampler, m1, x, 2);
}
-
if (retain && qsampler_selection_timeout_id)
{
GDK_THREADS_LEAVE ();
@@ -252,22 +210,18 @@ qsampler_selection_timeout (gpointer data)
return FALSE;
}
}
-
static gboolean
qsampler_button_event (BstQSampler *qsampler,
GdkEventButton *event)
{
gboolean handled = FALSE;
-
if (event->button == 1)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x = event->x;
-
handled = TRUE;
bst_qsampler_get_offset_at (qsampler, &x);
-
if (event->type == GDK_BUTTON_PRESS && (event->state & GDK_SHIFT_MASK) &&
m1 >= 0 && m2 >= 0)
{
@@ -287,22 +241,18 @@ qsampler_button_event (BstQSampler *qsampler,
}
}
}
-
return handled;
}
-
static gboolean
qsampler_motion_event (BstQSampler *qsampler,
GdkEventMotion *event)
{
gboolean handled = FALSE;
-
if (event->type == GDK_MOTION_NOTIFY)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
// gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x = event->x;
-
handled = TRUE;
if (bst_qsampler_get_offset_at (qsampler, &x))
qsampler_set_selection (qsampler, m1, x, 2);
@@ -312,25 +262,20 @@ qsampler_motion_event (BstQSampler *qsampler,
qsampler_selection_timeout,
g_object_ref (qsampler), NULL);
}
-
return handled;
}
-
static void
change_draw_mode (BstSampleEditor *editor,
GtkOptionMenu *omenu)
{
guint i;
BstQSamplerDrawMode mode = (BstQSamplerDrawMode) bst_choice_get_last (omenu->menu);
-
for (i = 0; i < editor->n_channels; i++)
{
BstQSampler *qsampler = editor->qsampler[i];
-
bst_qsampler_set_draw_mode (qsampler, mode);
}
}
-
static void
update_play_back_marks (gpointer data,
SfiNum tick_stamp,
@@ -338,19 +283,16 @@ update_play_back_marks (gpointer data,
{
BstSampleEditor *editor = (BstSampleEditor*) data;
guint i;
-
pcm_pos /= editor->n_channels;
for (i = 0; i < editor->n_channels; i++)
{
BstQSampler *qsampler = editor->qsampler[i];
-
bst_qsampler_set_mark (qsampler, 3, pcm_pos, BstQSamplerType (0));
bst_qsampler_force_refresh (qsampler);
bst_qsampler_scroll_rbounded (qsampler, pcm_pos, 0.98, 0.05);
bst_qsampler_set_mark (qsampler, 3, pcm_pos, BST_QSAMPLER_PRELIGHT);
}
}
-
static void
play_back_wchunk (BstSampleEditor *editor)
{
@@ -365,39 +307,32 @@ play_back_wchunk (BstSampleEditor *editor)
if (bst_play_back_handle_is_playing (editor->play_back))
bst_play_back_handle_pcm_notify (editor->play_back, 50, update_play_back_marks, editor);
}
-
static void
adjustments_changed (BstSampleEditor *editor,
GtkAdjustment *adjustment)
{
guint i;
-
for (i = 0; i < editor->n_channels; i++)
{
BstQSampler *qsampler = editor->qsampler[i];
-
if (adjustment == editor->zoom_adjustment)
bst_qsampler_set_zoom (qsampler, adjustment->value);
else if (adjustment == editor->vscale_adjustment)
bst_qsampler_set_vscale (qsampler, adjustment->value);
}
}
-
void
bst_sample_editor_rebuild (BstSampleEditor *editor)
{
GtkWidget *qsampler_parent, *sbar, *entry, *mask_parent, *any;
gpointer gmask;
guint i;
-
g_return_if_fail (BST_IS_SAMPLE_EDITOR (editor));
-
gtk_container_foreach (GTK_CONTAINER (editor), (GtkCallback) gtk_widget_destroy, NULL);
g_free (editor->qsampler);
editor->qsampler = NULL;
if (!editor->esample)
return;
-
qsampler_parent = gtk_widget_new (GTK_TYPE_VBOX,
"visible", TRUE,
"spacing", 1,
@@ -405,8 +340,6 @@ bst_sample_editor_rebuild (BstSampleEditor *editor)
"border_width", 0,
NULL);
editor->qsampler = g_renew (BstQSampler*, editor->qsampler, editor->n_channels);
-
-
/* setup qsampler widgets
*/
sbar = gtk_widget_new (GTK_TYPE_HSCROLLBAR,
@@ -442,8 +375,6 @@ bst_sample_editor_rebuild (BstSampleEditor *editor)
bst_qsampler_set_source_from_esample (qsampler, editor->esample, i);
}
gtk_box_pack_start (GTK_BOX (qsampler_parent), sbar, FALSE, TRUE, 0);
-
-
/* setup qsampler zoom and vscale
*/
mask_parent = bst_gmask_container_create (5, TRUE);
@@ -470,7 +401,6 @@ bst_sample_editor_rebuild (BstSampleEditor *editor)
"visible", TRUE,
NULL);
gmask = bst_gmask_quick (mask_parent, 1, _("VScale:"), entry, NULL);
-
/* setup qsampler selection start and end
*/
editor->sstart = (GtkEntry*) g_object_new (GTK_TYPE_ENTRY,
@@ -487,7 +417,6 @@ bst_sample_editor_rebuild (BstSampleEditor *editor)
"swapped_signal::destroy", g_nullify_pointer, &editor->sstart,
NULL);
gmask = bst_gmask_quick (mask_parent, 1, _("End:"), editor->send, NULL);
-
/* setup sample display type
*/
any = (GtkWidget*) g_object_new (GTK_TYPE_OPTION_MENU,
@@ -509,7 +438,6 @@ bst_sample_editor_rebuild (BstSampleEditor *editor)
NULL);
gtk_option_menu_set_history (GTK_OPTION_MENU (any), 0);
gmask = bst_gmask_quick (mask_parent, 2, NULL, any, NULL);
-
/* setup preview button
*/
any = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
diff --git a/beast-gtk/bstsampleeditor.hh b/beast-gtk/bstsampleeditor.hh
index d37a446..d65e338 100644
--- a/beast-gtk/bstsampleeditor.hh
+++ b/beast-gtk/bstsampleeditor.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SAMPLE_EDITOR_H__
#define __BST_SAMPLE_EDITOR_H__
-
#include "bstqsampler.hh"
#include "bstplayback.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_SAMPLE_EDITOR (bst_sample_editor_get_type ())
#define BST_SAMPLE_EDITOR(object) (GTK_CHECK_CAST ((object), BST_TYPE_SAMPLE_EDITOR, BstSampleEditor))
@@ -17,45 +13,34 @@ extern "C" {
#define BST_IS_SAMPLE_EDITOR(object) (GTK_CHECK_TYPE ((object), BST_TYPE_SAMPLE_EDITOR))
#define BST_IS_SAMPLE_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_SAMPLE_EDITOR))
#define BST_SAMPLE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_SAMPLE_EDITOR, BstSampleEditorClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstSampleEditor BstSampleEditor;
typedef struct _BstSampleEditorClass BstSampleEditorClass;
struct _BstSampleEditor
{
GtkVBox parent_object;
-
SfiProxy esample;
guint n_channels;
-
GtkWidget *main_vbox;
GtkAdjustment *zoom_adjustment;
GtkAdjustment *vscale_adjustment;
GtkEntry *sstart;
GtkEntry *send;
-
BstQSampler **qsampler;
GtkWidget *popup;
-
BstPlayBackHandle *play_back;
};
struct _BstSampleEditorClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_sample_editor_get_type (void);
GtkWidget* bst_sample_editor_new (SfiProxy sample);
void bst_sample_editor_set_sample (BstSampleEditor *sample_editor,
SfiProxy editable_sample);
void bst_sample_editor_rebuild (BstSampleEditor *sample_editor);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_SAMPLE_EDITOR_H__ */
diff --git a/beast-gtk/bstscrollgraph.cc b/beast-gtk/bstscrollgraph.cc
index b00f7f8..735eb63 100644
--- a/beast-gtk/bstscrollgraph.cc
+++ b/beast-gtk/bstscrollgraph.cc
@@ -3,7 +3,6 @@
#include "bstsnifferscope.hh" // FIXME: remove include
#include "bstparam.hh"
#include <math.h>
-
#define N_VALUES(scg) ((scg)->n_points * (scg)->n_bars)
#define VALUE(scg,b,p) (BAR (scg, b)[(p)])
#define BAR(scg,nth) ((scg)->values + (scg)->n_points * (((scg)->bar_offset + (nth)) % (scg)->n_bars))
@@ -11,7 +10,6 @@
#define VERTICAL(scg) ((scg)->direction == BST_UP || (scg)->direction == BST_DOWN)
#define FLIP(scg) ((scg)->flip ^ HORIZONTAL (scg))
#define FFTSZ2POINTS(k) ((k) / 2 + 1)
-
enum {
PROP_0,
PROP_FLIP,
@@ -19,16 +17,13 @@ enum {
PROP_BOOST,
PROP_WINDOW_SIZE,
};
-
/* --- prototypes --- */
static void bst_scrollgraph_resize_values (BstScrollgraph *self,
BstDirection direction);
static void bst_scrollgraph_io_changed (BstScrollgraph *self);
static guint signal_resize_values = 0;
-
/* --- functions --- */
G_DEFINE_TYPE (BstScrollgraph, bst_scrollgraph, GTK_TYPE_BIN);
-
static void
bst_scrollgraph_destroy (GtkObject *object)
{
@@ -37,7 +32,6 @@ bst_scrollgraph_destroy (GtkObject *object)
/* chain parent class' handler */
GTK_OBJECT_CLASS (bst_scrollgraph_parent_class)->destroy (object);
}
-
static void
bst_scrollgraph_finalize (GObject *object)
{
@@ -47,14 +41,12 @@ bst_scrollgraph_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (bst_scrollgraph_parent_class)->finalize (object);
}
-
static void
bst_scrollgraph_resize_values (BstScrollgraph *self,
BstDirection direction)
{
g_signal_emit (self, signal_resize_values, 0, CLAMP (direction, BST_UP, BST_DOWN));
}
-
static void
bst_scrollgraph_set_property (GObject *object,
guint prop_id,
@@ -88,7 +80,6 @@ bst_scrollgraph_set_property (GObject *object,
break;
}
}
-
static void
bst_scrollgraph_get_property (GObject *object,
guint prop_id,
@@ -115,16 +106,13 @@ bst_scrollgraph_get_property (GObject *object,
break;
}
}
-
static void
bst_scrollgraph_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
BstScrollgraph *self = BST_SCROLLGRAPH (widget);
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_scrollgraph_parent_class)->size_request (widget, requisition);
-
guint length = MIN (FFTSZ2POINTS (self->window_size), 480);
if (HORIZONTAL (self))
{
@@ -136,7 +124,6 @@ bst_scrollgraph_size_request (GtkWidget *widget,
requisition->height = length;
requisition->width = FFTSZ2POINTS (self->window_size);
}
-
GtkBin *bin = GTK_BIN (self);
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
@@ -144,7 +131,6 @@ bst_scrollgraph_size_request (GtkWidget *widget,
gtk_widget_size_request (bin->child, &child_requisition);
}
}
-
static void
scrollgraph_resize_values (BstScrollgraph *self,
BstDirection direction)
@@ -183,21 +169,16 @@ scrollgraph_resize_values (BstScrollgraph *self,
}
gtk_widget_queue_draw (widget);
}
-
static void
bst_scrollgraph_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstScrollgraph *self = BST_SCROLLGRAPH (widget);
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_scrollgraph_parent_class)->size_allocate (widget, allocation);
-
if (self->canvas)
gdk_window_move_resize (self->canvas, 0, 0, allocation->width, allocation->height);
-
bst_scrollgraph_resize_values (self, self->direction);
-
GtkBin *bin = GTK_BIN (self);
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
@@ -209,16 +190,13 @@ bst_scrollgraph_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (bin->child, &child_allocation);
}
}
-
static void
bst_scrollgraph_realize (GtkWidget *widget)
{
BstScrollgraph *self = BST_SCROLLGRAPH (widget);
GdkWindowAttr attributes;
gint attributes_mask;
-
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -236,38 +214,30 @@ bst_scrollgraph_realize (GtkWidget *widget)
gdk_window_set_user_data (widget->window, self);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-
attributes.x = 0;
attributes.y = 0;
self->canvas = gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (self->canvas, self);
gdk_window_set_background (self->canvas, &widget->style->black);
-
self->pixbuf = gdk_pixbuf_new_from_data (g_new (guint8, self->n_points * 3),
GDK_COLORSPACE_RGB, FALSE, 8,
VERTICAL (self) ? self->n_points : 1,
HORIZONTAL (self) ? self->n_points : 1,
3, (GdkPixbufDestroyNotify) g_free, NULL);
-
bst_scrollgraph_io_changed (self); /* show self->canvas if appropriate */
}
-
static void
bst_scrollgraph_unrealize (GtkWidget *widget)
{
BstScrollgraph *self = BST_SCROLLGRAPH (widget);
-
g_object_unref (self->pixbuf);
self->pixbuf = NULL;
-
gdk_window_set_user_data (self->canvas, NULL);
gdk_window_destroy (self->canvas);
self->canvas = NULL;
-
/* chain parent class' handler */
GTK_WIDGET_CLASS (bst_scrollgraph_parent_class)->unrealize (widget);
}
-
static void
bst_scrollgraph_scroll_bars (BstScrollgraph *self)
{
@@ -282,7 +252,6 @@ bst_scrollgraph_scroll_bars (BstScrollgraph *self)
gdk_window_scroll (drawable, 0, self->direction == BST_UP ? -1 : 1);
}
}
-
static GxkColorDots*
create_color_dots (void)
{
@@ -294,7 +263,6 @@ create_color_dots (void)
};
return gxk_color_dots_new (G_N_ELEMENTS (dots), dots);
}
-
static void
bst_scrollgraph_draw_bar (BstScrollgraph *self,
guint nth)
@@ -325,7 +293,6 @@ bst_scrollgraph_draw_bar (BstScrollgraph *self,
gdk_pixbuf_get_height (self->pixbuf),
GDK_RGB_DITHER_MAX, 0, 0);
}
-
static gint
bst_scrollgraph_bar_from_coord (BstScrollgraph *self,
gint x,
@@ -342,7 +309,6 @@ bst_scrollgraph_bar_from_coord (BstScrollgraph *self,
n = ((gint) self->n_bars) - 1 - n;
return n;
}
-
static gint
bst_scrollgraph_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -371,7 +337,6 @@ bst_scrollgraph_expose (GtkWidget *widget,
}
return GTK_WIDGET_CLASS (bst_scrollgraph_parent_class)->expose_event (widget, event);
}
-
void
bst_scrollgraph_clear (BstScrollgraph *self)
{
@@ -383,7 +348,6 @@ bst_scrollgraph_clear (BstScrollgraph *self)
VALUE (self, i, j) = 0;
gtk_widget_queue_draw (widget);
}
-
static void
bst_scrollgraph_probes_notify (SfiProxy source,
SfiSeq *sseq,
@@ -429,7 +393,6 @@ bst_scrollgraph_probes_notify (SfiProxy source,
float mix_freq = bse_source_get_mix_freq (self->source);
bst_source_queue_probe_request (self->source, self->ochannel, BST_SOURCE_PROBE_FFT, mix_freq / self->window_size);
}
-
static void
bst_scrollgraph_io_changed (BstScrollgraph *self)
{
@@ -441,7 +404,6 @@ bst_scrollgraph_io_changed (BstScrollgraph *self)
gdk_window_hide (self->canvas);
}
}
-
static void
bst_scrollgraph_release_item (SfiProxy item,
BstScrollgraph *self)
@@ -451,7 +413,6 @@ bst_scrollgraph_release_item (SfiProxy item,
if (self->delete_toplevel)
gxk_toplevel_delete (GTK_WIDGET (self));
}
-
void
bst_scrollgraph_set_source (BstScrollgraph *self,
SfiProxy source,
@@ -483,7 +444,6 @@ bst_scrollgraph_set_source (BstScrollgraph *self,
bst_scrollgraph_io_changed (self);
}
}
-
static gboolean
bst_scrollgraph_button_press (GtkWidget *widget,
GdkEventButton *event)
@@ -491,7 +451,6 @@ bst_scrollgraph_button_press (GtkWidget *widget,
// BstScrollgraph *self = BST_SCROLLGRAPH (widget);
return TRUE;
}
-
static gboolean
bst_scrollgraph_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
@@ -499,7 +458,6 @@ bst_scrollgraph_motion_notify (GtkWidget *widget,
// BstScrollgraph *self = BST_SCROLLGRAPH (widget);
return TRUE;
}
-
static gboolean
bst_scrollgraph_button_release (GtkWidget *widget,
GdkEventButton *event)
@@ -507,7 +465,6 @@ bst_scrollgraph_button_release (GtkWidget *widget,
// BstScrollgraph *self = BST_SCROLLGRAPH (widget);
return TRUE;
}
-
static void
bst_scrollgraph_init (BstScrollgraph *self)
{
@@ -527,20 +484,16 @@ bst_scrollgraph_init (BstScrollgraph *self)
widget->allocation.width = 10; widget->allocation.height = 10; // FIXME: initial values for _resize()
bst_scrollgraph_resize_values (self, BST_LEFT);
}
-
static void
bst_scrollgraph_class_init (BstScrollgraphClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->set_property = bst_scrollgraph_set_property;
gobject_class->get_property = bst_scrollgraph_get_property;
gobject_class->finalize = bst_scrollgraph_finalize;
-
object_class->destroy = bst_scrollgraph_destroy;
-
widget_class->size_request = bst_scrollgraph_size_request;
widget_class->size_allocate = bst_scrollgraph_size_allocate;
widget_class->realize = bst_scrollgraph_realize;
@@ -549,9 +502,7 @@ bst_scrollgraph_class_init (BstScrollgraphClass *klass)
widget_class->button_press_event = bst_scrollgraph_button_press;
widget_class->button_release_event = bst_scrollgraph_button_release;
widget_class->motion_notify_event = bst_scrollgraph_motion_notify;
-
klass->resize_values = scrollgraph_resize_values;
-
bst_object_class_install_property (gobject_class, _("Spectrograph"), PROP_FLIP,
sfi_pspec_bool ("flip", _("Flip Spectrum"), _("Flip Spectrum display, interchaging low and high frequencies"),
FALSE, SFI_PARAM_STANDARD));
@@ -570,7 +521,6 @@ bst_scrollgraph_class_init (BstScrollgraphClass *klass)
bst_marshal_NONE__INT, // HACK: should use BstDirection enum type
G_TYPE_NONE, 1, G_TYPE_INT);
}
-
static GxkParam*
scrollgraph_build_param (BstScrollgraph *self,
const gchar *property)
@@ -579,7 +529,6 @@ scrollgraph_build_param (BstScrollgraph *self,
GxkParam *param = bst_param_new_object (pspec, G_OBJECT (self));
return param;
}
-
static void
scrollgraph_resize_rulers (BstScrollgraph *self,
BstDirection direction,
@@ -627,7 +576,6 @@ scrollgraph_resize_rulers (BstScrollgraph *self,
pango_font_description_free (pfd);
}
}
-
static void
scrollgraph_resize_alignment (BstScrollgraph *self,
BstDirection direction,
@@ -639,14 +587,12 @@ scrollgraph_resize_alignment (BstScrollgraph *self,
"yscale", VERTICAL (self) ? 1.0 : 0.0,
NULL);
}
-
GtkWidget*
bst_scrollgraph_build_dialog (GtkWidget *alive_object,
SfiProxy source,
guint ochannel)
{
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
-
GxkRadget *radget = gxk_radget_create ("beast", "scrollgraph-dialog", NULL);
BstScrollgraph *scg = (BstScrollgraph*) gxk_radget_find (radget, "scrollgraph");
if (BST_IS_SCROLLGRAPH (scg))
diff --git a/beast-gtk/bstscrollgraph.hh b/beast-gtk/bstscrollgraph.hh
index 87a2760..389181e 100644
--- a/beast-gtk/bstscrollgraph.hh
+++ b/beast-gtk/bstscrollgraph.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SCROLLGRAPH_H__
#define __BST_SCROLLGRAPH_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_SCROLLGRAPH (bst_scrollgraph_get_type ())
#define BST_SCROLLGRAPH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_SCROLLGRAPH, BstScrollgraph))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_SCROLLGRAPH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_SCROLLGRAPH))
#define BST_IS_SCROLLGRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_SCROLLGRAPH))
#define BST_SCROLLGRAPH_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_SCROLLGRAPH, BstScrollgraphClass))
-
/* --- structures & typedefs --- */
typedef struct _BstScrollgraph BstScrollgraph;
typedef struct _BstScrollgraphClass BstScrollgraphClass;
@@ -41,7 +37,6 @@ struct _BstScrollgraphClass
void (*resize_values) (BstScrollgraph *self,
BstDirection direction);
};
-
/* --- public methods --- */
GType bst_scrollgraph_get_type (void);
void bst_scrollgraph_clear (BstScrollgraph *self);
@@ -51,7 +46,5 @@ void bst_scrollgraph_set_source (BstScrollgraph *self,
GtkWidget* bst_scrollgraph_build_dialog (GtkWidget *alive_object,
SfiProxy source,
guint ochannel);
-
G_END_DECLS
-
#endif /* __BST_SCROLLGRAPH_H__ */
diff --git a/beast-gtk/bstsegment.cc b/beast-gtk/bstsegment.cc
index a05ca63..7fec68f 100644
--- a/beast-gtk/bstsegment.cc
+++ b/beast-gtk/bstsegment.cc
@@ -1,9 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstsegment.hh"
-
#include <string.h>
-
-
/* --- functions --- */
void
bst_segment_expose (BstSegment *self)
@@ -12,7 +9,6 @@ bst_segment_expose (BstSegment *self)
bst_segment_bbox (self, &area);
gdk_window_invalidate_rect (self->any.drawable, &area, TRUE);
}
-
void
bst_segment_bbox (BstSegment *self,
GdkRectangle *area)
@@ -25,13 +21,11 @@ bst_segment_bbox (BstSegment *self,
area->width = w + 2.5;
area->height = h + 2.5;
}
-
gint
bst_segment_initialized (BstSegment *self)
{
return self->type && self->any.drawable;
}
-
void
bst_segment_init (BstSegment *self,
BstSegmentType type,
@@ -40,7 +34,6 @@ bst_segment_init (BstSegment *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->type == 0);
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
self->type = type;
self->any.drawable = (GdkDrawable*) g_object_ref (drawable);
switch (self->type)
@@ -53,7 +46,6 @@ bst_segment_init (BstSegment *self,
break;
}
}
-
void
bst_segment_clear (BstSegment *self)
{
@@ -66,7 +58,6 @@ bst_segment_clear (BstSegment *self)
g_object_unref (self->any.drawable);
memset (self, 0, sizeof (*self));
}
-
void
bst_segment_xrange (BstSegment *self,
gdouble *x_p,
@@ -85,7 +76,6 @@ bst_segment_xrange (BstSegment *self,
if (width_p)
*width_p = MAX (x1, x2) - MIN (x1, x2) + 1;
}
-
void
bst_segment_yrange (BstSegment *self,
gdouble *y_p,
@@ -104,7 +94,6 @@ bst_segment_yrange (BstSegment *self,
if (height_p)
*height_p = MAX (y1, y2) - MIN (y1, y2) + 1;
}
-
gdouble
bst_segment_calcy (BstSegment *self,
gdouble x)
@@ -121,7 +110,6 @@ bst_segment_calcy (BstSegment *self,
}
return v;
}
-
void
bst_segment_start (BstSegment *self,
gdouble x,
@@ -139,7 +127,6 @@ bst_segment_start (BstSegment *self,
}
bst_segment_expose (self);
}
-
void
bst_segment_move_to (BstSegment *self,
gdouble x,
@@ -155,7 +142,6 @@ bst_segment_move_to (BstSegment *self,
}
bst_segment_expose (self);
}
-
void
bst_segment_translate (BstSegment *self,
gdouble xdiff,
@@ -171,7 +157,6 @@ bst_segment_translate (BstSegment *self,
break;
}
}
-
void
bst_segment_draw (BstSegment *self,
GtkStyle *style)
diff --git a/beast-gtk/bstsegment.hh b/beast-gtk/bstsegment.hh
index 6882f51..bd6041e 100644
--- a/beast-gtk/bstsegment.hh
+++ b/beast-gtk/bstsegment.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SEGMENT_H__
#define __BST_SEGMENT_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
-
/* --- structures & typedefs --- */
typedef enum {
BST_SEGMENT_LINE = 1,
@@ -28,8 +24,6 @@ typedef union
BstSegmentAny any;
BstSegmentLine line;
} BstSegment;
-
-
/* --- API --- */
void bst_segment_init (BstSegment *self,
BstSegmentType type,
@@ -58,7 +52,5 @@ void bst_segment_expose (BstSegment *self);
void bst_segment_draw (BstSegment *self,
GtkStyle *style);
void bst_segment_clear (BstSegment *self);
-
G_END_DECLS
-
#endif /* __BST_SEGMENT_H__ */
diff --git a/beast-gtk/bstsequence.cc b/beast-gtk/bstsequence.cc
index 6a5b8b1..e3f4739 100644
--- a/beast-gtk/bstsequence.cc
+++ b/beast-gtk/bstsequence.cc
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh" /* for GScanner */
#include "bstsequence.hh"
-
#include <gtk/gtkdrawingarea.h>
-
-
/* --- prototypes --- */
static void bst_sequence_finalize (GObject *object);
static gint darea_configure_event (BstSequence *seq,
@@ -17,23 +14,16 @@ static gint darea_button_event (BstSequence *seq,
GdkEventButton *event);
static gint darea_motion_event (BstSequence *seq,
GdkEventMotion *event);
-
-
/* --- varibales --- */
static guint seq_changed_signal = 0;
-
-
/* --- fucntions --- */
G_DEFINE_TYPE (BstSequence, bst_sequence, GTK_TYPE_HBOX);
-
static void
bst_sequence_class_init (BstSequenceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
gobject_class->finalize = bst_sequence_finalize;
-
seq_changed_signal = gtk_signal_new ("seq-changed",
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
@@ -41,13 +31,11 @@ bst_sequence_class_init (BstSequenceClass *klass)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
}
-
static void
bst_sequence_init (BstSequence *seq)
{
GtkWidget *frame;
gtk_widget_show (GTK_WIDGET (seq));
-
frame = gtk_widget_new (GTK_TYPE_FRAME,
"visible", TRUE,
"label", NULL,
@@ -55,7 +43,6 @@ bst_sequence_init (BstSequence *seq)
"border_width", 0,
"parent", seq,
NULL);
-
seq->darea = (GtkWidget*) g_object_new (GTK_TYPE_DRAWING_AREA,
"visible", TRUE,
"height_request", 50,
@@ -77,30 +64,24 @@ bst_sequence_init (BstSequence *seq)
"swapped_object_signal::button_release_event", darea_button_event, seq,
"swapped_object_signal::motion_notify_event", darea_motion_event, seq,
NULL);
-
seq->n_rows = 13;
seq->sdata = bse_note_sequence_new ();
bse_note_seq_resize (seq->sdata->notes, 1);
seq->sdata->offset = SFI_NOTE_C (SFI_KAMMER_OCTAVE);
}
-
static void
bst_sequence_finalize (GObject *object)
{
BstSequence *seq = BST_SEQUENCE (object);
-
bse_note_sequence_free (seq->sdata);
-
/* chain parent class' handler */
G_OBJECT_CLASS (bst_sequence_parent_class)->finalize (object);
}
-
void
bst_sequence_set_seq (BstSequence *seq,
BseNoteSequence *sdata)
{
g_return_if_fail (BST_IS_SEQUENCE (seq));
-
bse_note_sequence_free (seq->sdata);
if (sdata)
seq->sdata = bse_note_sequence_copy_shallow (sdata);
@@ -112,24 +93,19 @@ bst_sequence_set_seq (BstSequence *seq,
}
gtk_widget_queue_draw (seq->darea);
}
-
static gint
darea_configure_event (BstSequence *seq,
GdkEventConfigure *event)
{
GtkWidget *widget = seq->darea;
-
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
-
return TRUE;
}
-
static gint
darea_cross_event (BstSequence *seq,
GdkEventCrossing *event)
{
GtkWidget *widget = seq->darea;
-
if (event->type == GDK_ENTER_NOTIFY)
seq->entered = TRUE;
else if (event->type == GDK_LEAVE_NOTIFY)
@@ -137,12 +113,9 @@ darea_cross_event (BstSequence *seq,
if (seq->entered)
seq->entered = FALSE;
}
-
gtk_widget_queue_draw (widget);
-
return TRUE;
}
-
static gint
darea_expose_event (BstSequence *seq,
GdkEventExpose *event)
@@ -156,11 +129,9 @@ darea_expose_event (BstSequence *seq,
gint width, height, maxx, maxy;
gfloat nwidth, row_height;
gint i, j;
-
gdk_window_get_size (widget->window, &width, &height);
maxx = width - 1;
maxy = height - 1;
-
/* clear background
*/
gdk_draw_rectangle (drawable, bg_gc,
@@ -169,7 +140,6 @@ darea_expose_event (BstSequence *seq,
0,
width,
height);
-
/* draw rectangles */
row_height = maxy / (gfloat) seq->n_rows;
nwidth = maxx / (gfloat) sdata->notes->n_notes;
@@ -177,7 +147,6 @@ darea_expose_event (BstSequence *seq,
for (j = 0; j < seq->n_rows; j++)
{
gboolean ncheck = sdata->notes->notes[i] == (seq->n_rows - 1 - j) + sdata->offset;
-
if (ncheck)
gdk_draw_rectangle (drawable, hl_gc, TRUE,
i * nwidth + 0.5, j * row_height + 0.5,
@@ -186,10 +155,8 @@ darea_expose_event (BstSequence *seq,
i * nwidth + 0.5, j * row_height + 0.5,
nwidth, row_height);
}
-
return TRUE;
}
-
static gint
darea_button_event (BstSequence *seq,
GdkEventButton *event)
@@ -197,7 +164,6 @@ darea_button_event (BstSequence *seq,
GtkWidget *widget = seq->darea;
BseNoteSequence *sdata = seq->sdata;
gboolean changed = FALSE;
-
if (event->type == GDK_BUTTON_PRESS)
{
if (event->button == 1)
@@ -205,13 +171,11 @@ darea_button_event (BstSequence *seq,
gint width, height, maxx, maxy;
gfloat nwidth, row_height;
gint dx, dy;
-
gdk_window_get_size (widget->window, &width, &height);
maxx = width - 1;
maxy = height - 1;
row_height = maxy / (gfloat) seq->n_rows;
nwidth = maxx / (gfloat) sdata->notes->n_notes;
-
dx = event->x / nwidth;
dy = event->y / row_height;
dy = seq->n_rows - 1 - CLAMP (dy, 0, seq->n_rows - 1);
@@ -225,7 +189,6 @@ darea_button_event (BstSequence *seq,
else if (event->button == 2)
{
guint i;
-
for (i = 0; i < sdata->notes->n_notes; i++)
sdata->notes->notes[i] = sdata->offset;
changed = TRUE;
@@ -236,10 +199,8 @@ darea_button_event (BstSequence *seq,
g_signal_emit (seq, seq_changed_signal, 0);
gtk_widget_queue_draw (widget);
}
-
return TRUE;
}
-
static gint
darea_motion_event (BstSequence *seq,
GdkEventMotion *event)
@@ -247,19 +208,16 @@ darea_motion_event (BstSequence *seq,
GtkWidget *widget = seq->darea;
BseNoteSequence *sdata = seq->sdata;
gboolean changed = FALSE;
-
if (event->type == GDK_MOTION_NOTIFY && !event->is_hint)
{
gint width, height, maxx, maxy;
gfloat nwidth, row_height;
gint dx, dy;
-
gdk_window_get_size (widget->window, &width, &height);
maxx = width - 1;
maxy = height - 1;
row_height = maxy / (gfloat) seq->n_rows;
nwidth = maxx / (gfloat) sdata->notes->n_notes;
-
dx = event->x / nwidth;
dy = event->y / row_height;
dy = seq->n_rows - 1 - CLAMP (dy, 0, seq->n_rows - 1);
@@ -275,6 +233,5 @@ darea_motion_event (BstSequence *seq,
g_signal_emit (seq, seq_changed_signal, 0);
gtk_widget_queue_draw (widget);
}
-
return TRUE;
}
diff --git a/beast-gtk/bstsequence.hh b/beast-gtk/bstsequence.hh
index 229123e..bf54f99 100644
--- a/beast-gtk/bstsequence.hh
+++ b/beast-gtk/bstsequence.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SEQUENCE_H__
#define __BST_SEQUENCE_H__
-
#include <gtk/gtk.h>
#include "bstbseutils.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BST_TYPE_SEQUENCE (bst_sequence_get_type ())
#define BST_SEQUENCE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_SEQUENCE, BstSequence))
@@ -17,15 +13,12 @@ extern "C" {
#define BST_IS_SEQUENCE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_SEQUENCE))
#define BST_IS_SEQUENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_SEQUENCE))
#define BST_SEQUENCE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_SEQUENCE, BstSequenceClass))
-
-
/* --- structures --- */
typedef struct _BstSequence BstSequence;
typedef struct _BstSequenceClass BstSequenceClass;
struct _BstSequence
{
GtkHBox parent_object;
-
guint entered : 1;
GtkWidget *darea;
gint n_rows;
@@ -34,20 +27,13 @@ struct _BstSequence
struct _BstSequenceClass
{
GtkHBoxClass parent_class;
-
void (*seq_changed) (BstSequence *sequence);
};
-
-
/* --- prototypes --- */
GType bst_sequence_get_type (void);
void bst_sequence_set_seq (BstSequence *seq,
BseNoteSequence *sdata);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_SEQUENCE_H__ */
-
diff --git a/beast-gtk/bstservermonitor.cc b/beast-gtk/bstservermonitor.cc
index c66cd4e..d6b8699 100644
--- a/beast-gtk/bstservermonitor.cc
+++ b/beast-gtk/bstservermonitor.cc
@@ -1,23 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstservermonitor.hh"
-
-
/* --- prototypes --- */
static void bst_server_monitor_class_init (BstServerMonitorClass *klass);
static void bst_server_monitor_init (BstServerMonitor *smon);
static void bst_server_monitor_finalize (GObject *object);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GtkType
bst_server_monitor_get_type (void)
{
static GtkType server_monitor_type = 0;
-
if (!server_monitor_type)
{
GtkTypeInfo server_monitor_info =
@@ -31,23 +24,17 @@ bst_server_monitor_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
server_monitor_type = gtk_type_unique (GTK_TYPE_VBOX, &server_monitor_info);
}
-
return server_monitor_type;
}
-
static void
bst_server_monitor_class_init (BstServerMonitorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bst_server_monitor_finalize;
}
-
static void
bst_server_monitor_init (BstServerMonitor *smon)
{
@@ -58,26 +45,20 @@ bst_server_monitor_init (BstServerMonitor *smon)
gtk_container_add (GTK_CONTAINER (smon), smon->param_view);
bst_param_view_set_item (BST_PARAM_VIEW (smon->param_view), smon->server);
}
-
static void
bst_server_monitor_finalize (GObject *object)
{
/* BstServerMonitor *smon = BST_SERVER_MONITOR (object); */
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
void
bst_server_monitor_rebuild (BstServerMonitor *smon)
{
g_return_if_fail (BST_IS_SERVER_MONITOR (smon));
-
bst_server_monitor_update (smon);
}
-
void
bst_server_monitor_update (BstServerMonitor *smon)
{
g_return_if_fail (BST_IS_SERVER_MONITOR (smon));
-
}
diff --git a/beast-gtk/bstservermonitor.hh b/beast-gtk/bstservermonitor.hh
index d54c54d..538cf10 100644
--- a/beast-gtk/bstservermonitor.hh
+++ b/beast-gtk/bstservermonitor.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SERVER_MONITOR_H__
#define __BST_SERVER_MONITOR_H__
-
#include "bstparamview.hh"
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_SERVER_MONITOR (bst_server_monitor_get_type ())
#define BST_SERVER_MONITOR(object) (GTK_CHECK_CAST ((object), BST_TYPE_SERVER_MONITOR, BstServerMonitor))
@@ -17,33 +12,24 @@ extern "C" {
#define BST_IS_SERVER_MONITOR(object) (GTK_CHECK_TYPE ((object), BST_TYPE_SERVER_MONITOR))
#define BST_IS_SERVER_MONITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_SERVER_MONITOR))
#define BST_SERVER_MONITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_SERVER_MONITOR, BstServerMonitorClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstServerMonitor BstServerMonitor;
typedef struct _BstServerMonitorClass BstServerMonitorClass;
struct _BstServerMonitor
{
GtkVBox parent_object;
-
SfiProxy server;
-
GtkWidget *param_view;
};
struct _BstServerMonitorClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_server_monitor_get_type (void);
void bst_server_monitor_update (BstServerMonitor *smon);
void bst_server_monitor_rebuild (BstServerMonitor *smon);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_SERVER_MONITOR_H__ */
diff --git a/beast-gtk/bstskinconfig.cc b/beast-gtk/bstskinconfig.cc
index 7305a19..1766929 100644
--- a/beast-gtk/bstskinconfig.cc
+++ b/beast-gtk/bstskinconfig.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstskinconfig.hh"
#include <string.h>
-
-
/* --- variables --- */
static BstSkinConfig *global_skin_config = NULL;
static GParamSpec *pspec_skin_config = NULL;
-
-
/* --- functions --- */
void
_bst_skin_config_init (void)
@@ -15,9 +11,7 @@ _bst_skin_config_init (void)
BstSkinConfig *skin_config;
GValue *value;
SfiRec *rec;
-
g_return_if_fail (global_skin_config == NULL);
-
/* global config record description */
pspec_skin_config = sfi_pspec_rec ("beast-skin-config-v1", NULL, NULL,
bst_skin_config_fields, SFI_PARAM_STANDARD);
@@ -35,19 +29,16 @@ _bst_skin_config_init (void)
sfi_value_free (value);
sfi_rec_unref (rec);
}
-
GParamSpec*
bst_skin_config_pspec (void)
{
return pspec_skin_config;
}
-
BstSkinConfig*
bst_skin_config_get_global (void)
{
return global_skin_config;
}
-
static void
set_skin_config (BstSkinConfig *skin_config)
{
@@ -55,7 +46,6 @@ set_skin_config (BstSkinConfig *skin_config)
global_skin_config = skin_config;
bst_skin_config_free (oldconfig);
}
-
static void
rec_make_absolute_pathnames (SfiRec *rec,
const gchar *path_prefix,
@@ -85,7 +75,6 @@ rec_make_absolute_pathnames (SfiRec *rec,
}
}
}
-
static void
rec_make_relative_pathnames (SfiRec *rec,
const gchar *path_prefix,
@@ -117,18 +106,14 @@ rec_make_relative_pathnames (SfiRec *rec,
}
}
}
-
static gchar *skin_path_prefix = NULL;
-
void
bst_skin_config_apply (SfiRec *rec,
const gchar *skin_file)
{
SfiRec *vrec;
BstSkinConfig *skin_config;
-
g_return_if_fail (rec != NULL);
-
vrec = sfi_rec_copy_deep (rec);
sfi_rec_validate (vrec, sfi_pspec_get_rec_fields (pspec_skin_config));
if (skin_file)
@@ -147,21 +132,17 @@ bst_skin_config_apply (SfiRec *rec,
skin_path_prefix = g_path_get_dirname (skin_file);
}
}
-
const gchar*
bst_skin_config_dirname (void)
{
return skin_path_prefix;
}
-
struct SkinNotify {
BstSkinConfigNotify func;
gpointer data;
};
-
static SkinNotify *notifies = NULL;
static uint n_notifies = 0;
-
void
bst_skin_config_add_notify (BstSkinConfigNotify func,
gpointer data)
@@ -171,7 +152,6 @@ bst_skin_config_add_notify (BstSkinConfigNotify func,
notifies[i].func = func;
notifies[i].data = data;
}
-
void
bst_skin_config_notify (void)
{
@@ -179,8 +159,6 @@ bst_skin_config_notify (void)
for (i = 0; i < n_notifies; i++)
notifies[i].func (notifies[i].data);
}
-
-
/* --- skin file --- */
#include <unistd.h>
#include <fcntl.h>
@@ -194,21 +172,15 @@ bst_skin_dump (const gchar *file_name)
GValue *value;
SfiRec *rec;
gint fd;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
sfi_make_dirname_path (file_name);
fd = open (file_name,
O_WRONLY | O_CREAT | O_TRUNC, /* O_EXCL, */
0666);
-
if (fd < 0)
return errno == EEXIST ? BSE_ERROR_FILE_EXISTS : BSE_ERROR_IO;
-
wstore = sfi_wstore_new ();
-
sfi_wstore_printf (wstore, "; skin-file for BEAST v%s\n", BST_VERSION);
-
/* store BstSkinConfig */
sfi_wstore_puts (wstore, "\n");
rec = bst_skin_config_to_rec (bst_skin_config_get_global ());
@@ -224,14 +196,11 @@ bst_skin_dump (const gchar *file_name)
sfi_value_free (value);
sfi_rec_unref (rec);
sfi_wstore_puts (wstore, "\n");
-
/* flush buffers to file */
sfi_wstore_flush_fd (wstore, fd);
sfi_wstore_destroy (wstore);
-
return close (fd) < 0 ? BSE_ERROR_IO : BSE_ERROR_NONE;
}
-
static GTokenType
skin_file_try_statement (gpointer context_data,
SfiRStore *rstore,
@@ -256,7 +225,6 @@ skin_file_try_statement (gpointer context_data,
else
return SFI_TOKEN_UNMATCHED;
}
-
BseErrorType
bst_skin_parse (const gchar *file_name)
{
@@ -264,9 +232,7 @@ bst_skin_parse (const gchar *file_name)
BseErrorType error = BSE_ERROR_NONE;
gchar *absname;
gint fd;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
absname = sfi_path_get_filename (file_name, NULL);
fd = open (absname, O_RDONLY, 0);
if (fd < 0)
@@ -275,7 +241,6 @@ bst_skin_parse (const gchar *file_name)
return (errno == ENOENT || errno == ENOTDIR || errno == ELOOP ?
BSE_ERROR_FILE_NOT_FOUND : BSE_ERROR_IO);
}
-
rstore = sfi_rstore_new ();
sfi_rstore_input_fd (rstore, fd, absname);
if (sfi_rstore_parse_all (rstore, NULL, skin_file_try_statement, absname) > 0)
@@ -285,9 +250,7 @@ bst_skin_parse (const gchar *file_name)
g_free (absname);
return error;
}
-
static gchar *skinrc_name = NULL;
-
void
bst_skin_config_set_rcfile (const gchar *file_name)
{
@@ -298,7 +261,6 @@ bst_skin_config_set_rcfile (const gchar *file_name)
skinrc_name = sfi_path_get_filename (file_name, NULL);
}
}
-
const gchar*
bst_skin_config_rcfile (void)
{
diff --git a/beast-gtk/bstskinconfig.hh b/beast-gtk/bstskinconfig.hh
index 37c424f..a1cb649 100644
--- a/beast-gtk/bstskinconfig.hh
+++ b/beast-gtk/bstskinconfig.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SKIN_CONFIG_H__
#define __BST_SKIN_CONFIG_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- access skin config --- */
#define BST_SKIN_CONFIG(field) (* bst_skin_config_get_global ()) . field
#define BST_SKIN_CONFIG_STRDUP_PATH(field) sfi_path_get_filename (BST_SKIN_CONFIG (field), bst_skin_config_dirname())
-
/* --- prototypes --- */
void _bst_skin_config_init (void);
void bst_skin_config_apply (SfiRec *rec,
@@ -20,16 +16,11 @@ typedef void (*BstSkinConfigNotify) (gpointer data);
void bst_skin_config_notify (void);
void bst_skin_config_add_notify (BstSkinConfigNotify func,
gpointer data);
-
-
/* --- skin file --- */
void bst_skin_config_set_rcfile (const gchar *file_name);
const gchar* bst_skin_config_rcfile (void);
const gchar* bst_skin_config_dirname (void);
BseErrorType bst_skin_dump (const gchar *file_name);
BseErrorType bst_skin_parse (const gchar *file_name);
-
-
G_END_DECLS
-
#endif /* __BST_SKIN_CONFIG_H__ */
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index 6d2e2db..6d8e9d5 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstsnetrouter.hh"
-
#include <math.h>
#include <string.h>
#include "bstcanvaslink.hh"
@@ -9,19 +8,15 @@
#include "bstprocedure.hh"
#include "bstscrollgraph.hh"
#include <gdk/gdkkeysyms.h>
-
-
#define EPSILON 1e-6
#define ROUTER_TOOL(router) (router->canvas_tool->action_id)
#define CHANNEL_HINTS(router) (router->channel_toggle->action_id != FALSE)
-
enum {
ROUTER_TOOL_EDIT = 0,
ROUTER_TOOL_CREATE_LINK = G_MAXINT - 1024, /* don't clash with category IDs */
ROUTER_TOOL_TOGGLE_PALETTE,
ROUTER_TOOL_CHANNEL_HINTS
};
-
/* --- tools & actions --- */
struct ToolBlurb { size_t action_id; const char *blurb; } tool_blurbs[] = {
{ ROUTER_TOOL_EDIT, N_("Edit tool (mouse buttons 1-3)\n"
@@ -36,15 +31,10 @@ static const GxkStockAction router_toolbar_actions[] = {
{ N_("Palette"), "", N_("Toggle visibility of the tool palette"),
ROUTER_TOOL_TOGGLE_PALETTE, BST_STOCK_PALETTE },
};
-
-
/* --- static variables --- */
static BstSNetRouterClass *bst_snet_router_class = NULL;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstSNetRouter, bst_snet_router, GNOME_TYPE_CANVAS);
-
static gboolean
filter_popup_modules (gpointer predicate_data,
BseCategory *cat)
@@ -56,16 +46,13 @@ filter_popup_modules (gpointer predicate_data,
return FALSE;
return TRUE;
}
-
static void
bst_snet_router_viewable_changed (GtkWidget *widget)
{
BstSNetRouter *router = BST_SNET_ROUTER (widget);
-
if (router->palette)
{
gboolean show_palette = widget->window && gxk_widget_viewable (widget);
-
if (show_palette && router->reshow_palette)
{
gtk_widget_show (router->palette);
@@ -78,14 +65,12 @@ bst_snet_router_viewable_changed (GtkWidget *widget)
}
}
}
-
static void
bst_snet_router_reset_tool (BstSNetRouter *self)
{
if (ROUTER_TOOL (self) == ROUTER_TOOL_CREATE_LINK)
gxk_action_group_select (self->canvas_tool, ROUTER_TOOL_EDIT);
}
-
static void
bst_snet_router_destroy_contents (BstSNetRouter *self)
{
@@ -93,7 +78,6 @@ bst_snet_router_destroy_contents (BstSNetRouter *self)
if (canvas->root)
{
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (canvas->root);
-
while (group->item_list)
gtk_object_destroy ((GtkObject*) group->item_list->data);
}
@@ -104,42 +88,32 @@ bst_snet_router_destroy_contents (BstSNetRouter *self)
g_object_unref (link);
}
}
-
static void
bst_snet_router_destroy (GtkObject *object)
{
BstSNetRouter *self = BST_SNET_ROUTER (object);
-
bst_snet_router_reset_tool (self);
bst_snet_router_destroy_contents (self);
bst_snet_router_set_snet (self, 0);
-
gxk_action_group_dispose (self->canvas_tool);
gxk_action_group_dispose (self->channel_toggle);
-
if (self->palette)
gtk_widget_destroy (self->palette);
-
GTK_OBJECT_CLASS (bst_snet_router_parent_class)->destroy (object);
}
-
static void
bst_snet_router_finalize (GObject *object)
{
BstSNetRouter *self = BST_SNET_ROUTER (object);
-
g_object_unref (self->canvas_tool);
g_object_unref (self->channel_toggle);
-
G_OBJECT_CLASS (bst_snet_router_parent_class)->finalize (object);
}
-
static void
bst_snet_router_update_links (BstSNetRouter *self,
BstCanvasSource *csource)
{
GnomeCanvas *canvas = GNOME_CANVAS (self);
-
/* sort out input links of this csource */
SfiRing *node, *iring = NULL, *tmp_ring = self->canvas_links;
self->canvas_links = NULL;
@@ -151,7 +125,6 @@ bst_snet_router_update_links (BstSNetRouter *self,
else
self->canvas_links = sfi_ring_append (self->canvas_links, link);
}
-
/* now we walk the (c)source's input channels, keep
* existing links and create new ones on the fly
*/
@@ -194,7 +167,6 @@ bst_snet_router_update_links (BstSNetRouter *self,
self->canvas_links = sfi_ring_append (self->canvas_links, link);
}
}
-
/* cleanup iring and left-over link objects */
while (iring)
{
@@ -206,9 +178,7 @@ bst_snet_router_update_links (BstSNetRouter *self,
}
}
}
-
static SfiRing *queued_canvas_sources = NULL;
-
static gboolean
bst_snet_router_handle_link_update (gpointer data)
{
@@ -225,7 +195,6 @@ bst_snet_router_handle_link_update (gpointer data)
GDK_THREADS_LEAVE();
return FALSE;
}
-
static void
bst_snet_router_queue_link_update (BstSNetRouter *self,
BstCanvasSource *csource)
@@ -243,22 +212,17 @@ bst_snet_router_queue_link_update (BstSNetRouter *self,
queued_canvas_sources = sfi_ring_append (queued_canvas_sources, csource);
}
}
-
GtkWidget*
bst_snet_router_new (SfiProxy snet)
{
GtkWidget *router;
-
g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
-
router = gtk_widget_new (BST_TYPE_SNET_ROUTER,
"aa", BST_SNET_ANTI_ALIASED,
NULL);
bst_snet_router_set_snet (BST_SNET_ROUTER (router), snet);
-
return router;
}
-
static void
bst_snet_router_item_added (BstSNetRouter *self,
SfiProxy item,
@@ -266,10 +230,8 @@ bst_snet_router_item_added (BstSNetRouter *self,
{
GnomeCanvas *canvas = GNOME_CANVAS (self);
GnomeCanvasItem *csource;
-
if (!BSE_IS_SOURCE (item))
return;
-
csource = bst_canvas_source_new (GNOME_CANVAS_GROUP (canvas->root), item);
bst_canvas_source_set_channel_hints (BST_CANVAS_SOURCE (csource), CHANNEL_HINTS (self));
g_object_connect (csource,
@@ -279,7 +241,6 @@ bst_snet_router_item_added (BstSNetRouter *self,
/* queue update cause ellipse-rect is broken */
gnome_canvas_FIXME_hard_update (canvas);
}
-
void
bst_snet_router_set_snet (BstSNetRouter *self,
SfiProxy snet)
@@ -287,7 +248,6 @@ bst_snet_router_set_snet (BstSNetRouter *self,
g_return_if_fail (BST_IS_SNET_ROUTER (self));
if (snet)
g_return_if_fail (BSE_IS_SNET (snet));
-
if (self->snet)
{
bst_snet_router_destroy_contents (self);
@@ -304,7 +264,6 @@ bst_snet_router_set_snet (BstSNetRouter *self,
bse_proxy_connect (self->snet,
"swapped_signal::item_added", bst_snet_router_item_added, self,
NULL);
-
bst_snet_router_update (self);
bst_snet_router_adjust_region (self);
#if 0
@@ -314,14 +273,12 @@ bst_snet_router_set_snet (BstSNetRouter *self,
#endif
}
}
-
static void
bst_router_popup_select (gpointer user_data, size_t action_id)
{
BstSNetRouter *self = BST_SNET_ROUTER (user_data);
gxk_action_group_select (self->canvas_tool, action_id);
}
-
static void
bst_router_run_method (gpointer user_data, size_t action_id)
{
@@ -332,7 +289,6 @@ bst_router_run_method (gpointer user_data, size_t action_id)
BSE_IS_CSYNTH (self->snet) ? "custom-synth" : "", SFI_TYPE_PROXY, self->snet,
NULL);
}
-
void
bst_snet_router_update (BstSNetRouter *self)
{
@@ -341,14 +297,10 @@ bst_snet_router_update (BstSNetRouter *self)
BseItemSeq *iseq;
GSList *slist, *csources = NULL;
guint i;
-
g_return_if_fail (BST_IS_SNET_ROUTER (self));
-
canvas = GNOME_CANVAS (self);
-
/* destroy all canvas sources */
bst_snet_router_destroy_contents (self);
-
if (0)
{
/* add canvas source for the snet itself */
@@ -359,13 +311,11 @@ bst_snet_router_update (BstSNetRouter *self)
NULL);
csources = g_slist_prepend (csources, csource);
}
-
/* walk all child sources */
iseq = bse_container_list_children (self->snet);
for (i = 0; i < iseq->n_items; i++)
{
SfiProxy item = iseq->items[i];
-
if (BSE_IS_SOURCE (item))
{
GnomeCanvasItem *csource = bst_canvas_source_new (GNOME_CANVAS_GROUP (canvas->root), item);
@@ -376,40 +326,30 @@ bst_snet_router_update (BstSNetRouter *self)
csources = g_slist_prepend (csources, csource);
}
}
-
/* update all links */
for (slist = csources; slist; slist = slist->next)
bst_canvas_source_update_links (BST_CANVAS_SOURCE (slist->data));
g_slist_free (csources);
-
/* queue update cause ellipse-rect is broken */
gnome_canvas_FIXME_hard_update (canvas);
}
-
static gboolean
idle_zoom (gpointer data)
{
GDK_THREADS_ENTER ();
-
GnomeCanvas *canvas = GNOME_CANVAS (data);
double *d = (double*) gtk_object_get_data (GTK_OBJECT (canvas), "zoom_d");
-
if (EPSILON < fabs (canvas->pixels_per_unit - *d))
gnome_canvas_set_zoom (canvas, *d);
-
gtk_object_remove_data (GTK_OBJECT (canvas), "zoom_d");
-
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
static void
bst_snet_router_adjust_zoom (BstSNetRouter *router)
{
GtkObject *object = GTK_OBJECT (router);
double *d = (double*) gtk_object_get_data (object, "zoom_d");
-
if (router->snet)
{
#if 0
@@ -417,7 +357,6 @@ bst_snet_router_adjust_zoom (BstSNetRouter *router)
bse_parasite_set_floats (router->snet, "BstRouterZoom", 1, &zoom);
#endif
}
-
if (!d)
{
d = g_new (gdouble, 1);
@@ -430,7 +369,6 @@ bst_snet_router_adjust_zoom (BstSNetRouter *router)
}
*d = router->adjustment->value;
}
-
void
bst_snet_router_adjust_region (BstSNetRouter *router)
{
@@ -438,20 +376,15 @@ bst_snet_router_adjust_region (BstSNetRouter *router)
GtkLayout *layout;
GnomeCanvas *canvas;
gdouble x1, y1, x2, y2;
-
g_return_if_fail (BST_IS_SNET_ROUTER (router));
-
canvas = GNOME_CANVAS (router);
layout = GTK_LAYOUT (router);
-
/* sigh, queue a hard update to get pending bounds recalculated */
gnome_canvas_FIXME_hard_update (canvas);
-
/* recompute everything, now. then we can use the new root bounds
* to adjust the scrolling region
*/
gnome_canvas_update_now (canvas);
-
/* set new scroll region with fudge */
gnome_canvas_item_get_bounds (canvas->root, &x1, &y1, &x2, &y2);
x1 -= 1; y1 -= 1; x2 += 1; y2 += 1;
@@ -464,11 +397,9 @@ bst_snet_router_adjust_region (BstSNetRouter *router)
gtk_adjustment_set_value (adjustment,
(adjustment->upper - adjustment->lower) / 2 -
adjustment->page_size / 2);
-
/* the canvas forgets to re-translate and update its items */
gnome_canvas_FIXME_hard_update (canvas);
}
-
BstCanvasSource*
bst_snet_router_csource_from_source (BstSNetRouter *router,
SfiProxy source)
@@ -476,23 +407,18 @@ bst_snet_router_csource_from_source (BstSNetRouter *router,
GnomeCanvas *canvas;
GnomeCanvasGroup *root;
GList *list;
-
g_return_val_if_fail (BST_IS_SNET_ROUTER (router), NULL);
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
-
canvas = GNOME_CANVAS (router);
root = GNOME_CANVAS_GROUP (canvas->root);
for (list = root->item_list; list; list = list->next)
{
BstCanvasSource *csource = (BstCanvasSource*) list->data;
-
if (BST_IS_CANVAS_SOURCE (csource) && csource->source == source)
return csource;
}
-
return NULL;
}
-
static void
update_tmp_line (BstSNetRouter *self)
{
@@ -508,7 +434,6 @@ update_tmp_line (BstSNetRouter *self)
else
{
GnomeCanvasPoints *gpoints = NULL;
-
gtk_object_get (GTK_OBJECT (self->tmp_line), "points", &gpoints, NULL);
if (gpoints)
{
@@ -528,48 +453,38 @@ update_tmp_line (BstSNetRouter *self)
}
}
}
-
static void
bst_router_tool_changed (BstSNetRouter *self)
{
GnomeCanvas *canvas = GNOME_CANVAS (self);
-
update_tmp_line (self);
-
if (GTK_WIDGET_REALIZED (canvas))
{
GdkCursor *cursor;
-
if (ROUTER_TOOL (self) == ROUTER_TOOL_CREATE_LINK)
cursor = gdk_cursor_new (GDK_TCROSS);
else if (ROUTER_TOOL (self))
cursor = gdk_cursor_new (GDK_UL_ANGLE);
else
cursor = NULL;
-
gdk_window_set_cursor (GTK_WIDGET (canvas)->window, cursor);
-
if (cursor)
gdk_cursor_destroy (cursor);
-
gxk_status_clear ();
}
}
-
static gboolean
bst_snet_router_root_event (BstSNetRouter *self,
GdkEvent *event)
{
GnomeCanvas *canvas = GNOME_CANVAS (self);
gboolean handled = FALSE;
-
if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE)
{
BstCanvasSource *csource = bst_canvas_source_at (canvas, event->button.x, event->button.y);
BstCanvasLink *clink = bst_canvas_link_at (canvas, event->button.x, event->button.y);
guint ochannel = ~0, ichannel = ~0;
gboolean at_channel;
-
if (!csource && clink)
csource = bst_canvas_link_csource_at (clink, event->button.x, event->button.y);
if (csource)
@@ -578,13 +493,11 @@ bst_snet_router_root_event (BstSNetRouter *self,
ichannel = bst_canvas_source_ichannel_at (csource, event->button.x, event->button.y);
}
at_channel = ochannel != ~uint (0) || ichannel != ~uint (0);
-
if (event->type == GDK_BUTTON_PRESS &&
event->button.button == 1 &&
ROUTER_TOOL (self) == 0) /* start link (or popup property dialog) */
{
g_return_val_if_fail (self->tmp_line == NULL, FALSE);
-
self->drag_is_input = ichannel != ~uint (0);
if (csource && at_channel && self->drag_is_input && /* ichannel in use */
!bst_canvas_source_ichannel_free (csource, ichannel))
@@ -592,7 +505,6 @@ bst_snet_router_root_event (BstSNetRouter *self,
else if (csource && at_channel) /* i/o link */
{
GnomeCanvasPoints *gpoints = gnome_canvas_points_new (2);
-
self->drag_channel = self->drag_is_input ? ichannel : ochannel;
self->drag_csource = csource;
(self->drag_is_input ?
@@ -640,7 +552,6 @@ bst_snet_router_root_event (BstSNetRouter *self,
else
{
BseErrorType error;
-
if (!csource || (self->drag_is_input ? ochannel : ichannel) == ~0)
error = self->drag_is_input ? BSE_ERROR_SOURCE_NO_SUCH_OCHANNEL : BSE_ERROR_SOURCE_NO_SUCH_ICHANNEL;
else if (self->drag_is_input)
@@ -730,7 +641,6 @@ bst_snet_router_root_event (BstSNetRouter *self,
{
GtkWidget *choice;
guint i;
-
choice = bst_choice_menu_createv ("<BEAST-SNetRouter>/LinkPopup",
BST_CHOICE_TITLE (_("Module link")),
BST_CHOICE_SEPERATOR,
@@ -760,7 +670,6 @@ bst_snet_router_root_event (BstSNetRouter *self,
}
return handled;
}
-
static gboolean
bst_snet_router_event (GtkWidget *widget,
GdkEvent *event)
@@ -768,7 +677,6 @@ bst_snet_router_event (GtkWidget *widget,
BstSNetRouter *self = BST_SNET_ROUTER (widget);
GnomeCanvas *canvas = GNOME_CANVAS (self);
gboolean handled = FALSE;
-
switch (event->type)
{
case GDK_BUTTON_PRESS:
@@ -778,12 +686,10 @@ bst_snet_router_event (GtkWidget *widget,
{
BseErrorType error;
BseCategory *cat = bse_category_from_id (ROUTER_TOOL (self));
-
handled = TRUE;
gnome_canvas_window_to_world (canvas,
event->button.x, event->button.y,
&self->world_x, &self->world_y);
-
error = bse_snet_can_create_source (self->snet, cat->type);
if (!error)
{
@@ -825,30 +731,24 @@ bst_snet_router_event (GtkWidget *widget,
default:
break;
}
-
if (!handled && GTK_WIDGET_CLASS (bst_snet_router_parent_class)->event)
handled = GTK_WIDGET_CLASS (bst_snet_router_parent_class)->event (widget, event);
-
return handled;
}
-
static gboolean
bst_snet_router_button_press (GtkWidget *widget,
GdkEventButton *event)
{
BstSNetRouter *self = BST_SNET_ROUTER (widget);
gboolean handled;
-
/* chain parent class' handler */
handled = GTK_WIDGET_CLASS (bst_snet_router_parent_class)->button_press_event (widget, event);
-
if (!handled && event->button == 3 && self->canvas_popup)
gxk_menu_popup (self->canvas_popup,
event->x_root, event->y_root,
event->button, event->time);
return handled;
}
-
static void
snet_router_tool2text (BstSNetRouter *self)
{
@@ -890,7 +790,6 @@ snet_router_tool2text (BstSNetRouter *self)
}
g_object_set (label, "label", name, NULL);
}
-
static void
snet_router_action_exec (gpointer user_data,
gulong action_id)
@@ -898,7 +797,6 @@ snet_router_action_exec (gpointer user_data,
BstSNetRouter *self = BST_SNET_ROUTER (user_data);
GnomeCanvas *canvas = GNOME_CANVAS (self);
GnomeCanvasGroup *root = GNOME_CANVAS_GROUP (canvas->root);
-
switch (action_id)
{
GList *list;
@@ -937,7 +835,6 @@ snet_router_action_exec (gpointer user_data,
}
gxk_widget_update_actions_downwards (self);
}
-
BstSNetRouter*
bst_snet_router_build_page (SfiProxy snet)
{
@@ -961,12 +858,9 @@ bst_snet_router_build_page (SfiProxy snet)
GdkPixmap *pixmap;
GdkBitmap *mask;
GxkRadget *radget;
-
g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
-
/* main radget */
radget = gxk_radget_create ("beast", "snet-view", NULL);
-
/* router */
self = (BstSNetRouter*) g_object_new (BST_TYPE_SNET_ROUTER,
"aa", BST_SNET_ANTI_ALIASED,
@@ -975,7 +869,6 @@ bst_snet_router_build_page (SfiProxy snet)
bst_snet_router_set_snet (self, snet);
gxk_radget_add (radget, "zoomed-window", self);
self->canvas_popup = (GtkMenu*) gxk_radget_find (radget, "snet-popup");
-
/* setup zoomed window and its toggle pixmap */
zoomed_window = (GtkWidget*) gxk_radget_find (radget, "zoomed-window");
g_object_connect (zoomed_window,
@@ -990,7 +883,6 @@ bst_snet_router_build_page (SfiProxy snet)
"visible", TRUE,
"parent", BST_ZOOMED_WINDOW (zoomed_window)->toggle_button,
NULL);
-
/* add Zoom spinner */
gxk_radget_add (radget, "zoom-area",
g_object_new (GTK_TYPE_SPIN_BUTTON,
@@ -999,10 +891,8 @@ bst_snet_router_build_page (SfiProxy snet)
"digits", 2,
"width_request", 2 * gxk_size_width (GXK_ICON_SIZE_TOOLBAR),
NULL));
-
return self;
}
-
static void
bst_snet_router_init (BstSNetRouter *self)
{
@@ -1010,7 +900,6 @@ bst_snet_router_init (BstSNetRouter *self)
GxkActionList *al1, *al2, *canvas_modules, *toolbar_modules, *palette_modules;
BseCategorySeq *cseq;
guint i, n;
-
self->palette = NULL;
self->adjustment = NULL;
self->snet = 0;
@@ -1021,7 +910,6 @@ bst_snet_router_init (BstSNetRouter *self)
self->drag_csource = NULL;
self->tmp_line = NULL;
self->canvas_links = NULL;
-
/* module selection group */
self->canvas_tool = gxk_action_group_new ();
g_object_connect (self->canvas_tool, "swapped_signal::changed", bst_router_tool_changed, self, NULL);
@@ -1032,13 +920,11 @@ bst_snet_router_init (BstSNetRouter *self)
g_object_connect (canvas->root,
"swapped_signal::event", bst_snet_router_root_event, self,
NULL);
-
self->adjustment = (GtkAdjustment*) gtk_adjustment_new (1.0, 0.20, 5.00, 0.05, 0.50, 0 /* 0.50 - spin buttons needs 0 */);
g_object_connect (self->adjustment,
"swapped_signal::value_changed", bst_snet_router_adjust_zoom, self,
"swapped_signal::destroy", g_nullify_pointer, &self->adjustment,
NULL);
-
/* CSynth & SNet utilities */
cseq = bse_categories_match ("/CSynth/*");
al1 = bst_action_list_from_cats (cseq, 1, BST_STOCK_EXECUTE, NULL, bst_router_run_method, self);
@@ -1048,7 +934,6 @@ bst_snet_router_init (BstSNetRouter *self)
gxk_action_list_sort (al2);
al1 = gxk_action_list_merge (al1, al2);
gxk_widget_publish_action_list (GTK_WIDGET (self), "router-util-actions", al1);
-
/* publish canvas toolbar tools & actions */
gxk_widget_publish_actions_grouped (self, self->canvas_tool, "router-canvas-tools",
G_N_ELEMENTS (router_canvas_tools), router_canvas_tools,
@@ -1056,7 +941,6 @@ bst_snet_router_init (BstSNetRouter *self)
gxk_widget_publish_actions (self, "router-toolbar-actions",
G_N_ELEMENTS (router_toolbar_actions), router_toolbar_actions,
NULL, NULL, snet_router_action_exec);
-
/* construct module type action lists */
canvas_modules = gxk_action_list_create_grouped (self->canvas_tool);
palette_modules = gxk_action_list_create_grouped (self->canvas_tool);
@@ -1099,7 +983,6 @@ bst_snet_router_init (BstSNetRouter *self)
if (strncmp (cat->type, "BseLadspaModule_", 16) == 0)
stock_fallback = BST_STOCK_LADSPA;
const gchar *stock_id;
-
if (cat->icon)
{
bst_stock_register_icon (cat->category, cat->icon->bytes_per_pixel,
@@ -1123,7 +1006,6 @@ bst_snet_router_init (BstSNetRouter *self)
gxk_action_list_sort (palette_modules);
gxk_widget_publish_action_list (self, "router-palette-modules", palette_modules);
gxk_widget_publish_action_list (self, "router-toolbar-modules", toolbar_modules);
-
/* channel hints toggle */
self->channel_toggle = gxk_action_toggle_new ();
gxk_action_group_select (self->channel_toggle, ROUTER_TOOL_CHANNEL_HINTS);
@@ -1134,22 +1016,17 @@ bst_snet_router_init (BstSNetRouter *self)
/* set default tool */
gxk_action_group_select (self->canvas_tool, ROUTER_TOOL_EDIT);
}
-
static void
bst_snet_router_class_init (BstSNetRouterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
bst_snet_router_class = klass;
-
gobject_class->finalize = bst_snet_router_finalize;
object_class->destroy = bst_snet_router_destroy;
-
widget_class->event = bst_snet_router_event;
widget_class->button_press_event = bst_snet_router_button_press;
-
klass->popup_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<BstSnetRouter>", NULL);
gtk_accel_group_lock (klass->popup_factory->accel_group);
}
diff --git a/beast-gtk/bstsnetrouter.hh b/beast-gtk/bstsnetrouter.hh
index f0da768..6a14410 100644
--- a/beast-gtk/bstsnetrouter.hh
+++ b/beast-gtk/bstsnetrouter.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SNET_ROUTER_H__
#define __BST_SNET_ROUTER_H__
-
#include "bstcanvassource.hh"
-
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_SNET_ROUTER (bst_snet_router_get_type ())
#define BST_SNET_ROUTER(object) (GTK_CHECK_CAST ((object), BST_TYPE_SNET_ROUTER, BstSNetRouter))
@@ -14,25 +10,19 @@ G_BEGIN_DECLS
#define BST_IS_SNET_ROUTER(object) (GTK_CHECK_TYPE ((object), BST_TYPE_SNET_ROUTER))
#define BST_IS_SNET_ROUTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_SNET_ROUTER))
#define BST_SNET_ROUTER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_SNET_ROUTER, BstSNetRouterClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstSNetRouter BstSNetRouter;
typedef struct _BstSNetRouterClass BstSNetRouterClass;
struct _BstSNetRouter
{
GnomeCanvas parent_object;
-
GtkMenu *canvas_popup;
GtkWidget *palette;
GtkWidget *palette_text;
GtkAdjustment *adjustment;
-
SfiProxy snet;
-
GxkActionGroup *canvas_tool;
GxkActionGroup *channel_toggle;
-
gdouble world_x, world_y;
guint reshow_palette : 1;
guint drag_is_input : 1;
@@ -44,11 +34,8 @@ struct _BstSNetRouter
struct _BstSNetRouterClass
{
GnomeCanvasClass parent_class;
-
GtkItemFactory *popup_factory;
};
-
-
/* --- prototypes --- */
GType bst_snet_router_get_type (void);
GtkWidget* bst_snet_router_new (SfiProxy snet);
@@ -59,8 +46,5 @@ void bst_snet_router_adjust_region (BstSNetRouter *snet_router);
BstCanvasSource* bst_snet_router_csource_from_source (BstSNetRouter *snet_router,
SfiProxy source);
BstSNetRouter* bst_snet_router_build_page (SfiProxy snet);
-
-
G_END_DECLS
-
#endif /* __BST_SNET_ROUTER_H__ */
diff --git a/beast-gtk/bstsnifferscope.cc b/beast-gtk/bstsnifferscope.cc
index 7f008d9..87b90ae 100644
--- a/beast-gtk/bstsnifferscope.cc
+++ b/beast-gtk/bstsnifferscope.cc
@@ -1,63 +1,49 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstsnifferscope.hh"
#include <string.h>
-
-
#define WIDGET(self) (GTK_WIDGET (self))
#define STATE(self) (WIDGET (self)->state)
#define STYLE(self) (WIDGET (self)->style)
#define BASE_GC(self) (STYLE (self)->base_gc[STATE (self)])
-
G_DEFINE_TYPE (BstSnifferScope, bst_sniffer_scope, GTK_TYPE_WIDGET);
-
/* --- functions --- */
static void
bst_sniffer_scope_init (BstSnifferScope *self)
{
GtkWidget *widget = GTK_WIDGET (self);
-
GTK_WIDGET_SET_FLAGS (self, GTK_NO_WINDOW);
gtk_widget_show (widget);
}
-
GtkWidget*
bst_sniffer_scope_new (void)
{
BstSnifferScope *self = (BstSnifferScope*) g_object_new (BST_TYPE_SNIFFER_SCOPE, NULL);
return GTK_WIDGET (self);
}
-
static void
bst_sniffer_scope_destroy (GtkObject *object)
{
BstSnifferScope *self = BST_SNIFFER_SCOPE (object);
-
bst_sniffer_scope_set_sniffer (self, 0);
-
GTK_OBJECT_CLASS (bst_sniffer_scope_parent_class)->destroy (object);
}
-
static void
bst_sniffer_scope_finalize (GObject *object)
{
BstSnifferScope *self = BST_SNIFFER_SCOPE (object);
-
bst_sniffer_scope_set_sniffer (self, 0);
g_free (self->lvalues);
g_free (self->rvalues);
G_OBJECT_CLASS (bst_sniffer_scope_parent_class)->finalize (object);
}
-
static void
bst_sniffer_scope_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
// BstSnifferScope *self = BST_SNIFFER_SCOPE (widget);
-
requisition->width = 30 + 4;
requisition->height = 20;
}
-
static void
bst_sniffer_scope_realize (GtkWidget *widget)
{
@@ -67,7 +53,6 @@ bst_sniffer_scope_realize (GtkWidget *widget)
GdkColor color = gdk_color_from_rgb (0xff0000);
gdk_gc_set_rgb_fg_color (self->oshoot_gc, &color);
}
-
static void
bst_sniffer_scope_unrealize (GtkWidget *widget)
{
@@ -76,7 +61,6 @@ bst_sniffer_scope_unrealize (GtkWidget *widget)
self->oshoot_gc = NULL;
GTK_WIDGET_CLASS (bst_sniffer_scope_parent_class)->unrealize (widget);
}
-
static void
bst_sniffer_scope_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -89,7 +73,6 @@ bst_sniffer_scope_size_allocate (GtkWidget *widget,
self->rvalues = g_renew (float, self->rvalues, self->n_values);
memset (self->rvalues, 0, self->n_values * sizeof (self->rvalues[0]));
}
-
static void
sniffer_scope_lregion (BstSnifferScope *self,
gint *x,
@@ -99,7 +82,6 @@ sniffer_scope_lregion (BstSnifferScope *self,
*width = self->n_values;
*x = widget->allocation.x + 1;
}
-
static void
sniffer_scope_rregion (BstSnifferScope *self,
gint *x,
@@ -109,7 +91,6 @@ sniffer_scope_rregion (BstSnifferScope *self,
*width = self->n_values;
*x = widget->allocation.x + 1 + *width + 1 + (widget->allocation.width & 1) + 1;
}
-
static void
sniffer_scope_draw_bar (BstSnifferScope *self,
guint x,
@@ -128,7 +109,6 @@ sniffer_scope_draw_bar (BstSnifferScope *self,
gdk_draw_vline (window, value > 1.0 ? xg_gc : fg_gc,
x, y + height - top, top);
}
-
static gboolean
bst_sniffer_scope_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -138,7 +118,6 @@ bst_sniffer_scope_expose (GtkWidget *widget,
GtkAllocation *allocation = &widget->allocation;
if (window != widget->window)
return FALSE;
-
/* draw left and right channel */
gint i, xl, xr, width;
sniffer_scope_lregion (self, &xl, &width);
@@ -173,10 +152,8 @@ bst_sniffer_scope_expose (GtkWidget *widget,
gdk_draw_hline (window, light_gc, allocation->x, allocation->y, allocation->width);
if (bgcol >= 0) /* paint above hline outline */
gdk_draw_vline (window, widget->style->bg_gc[GTK_STATE_NORMAL], bgcol, allocation->y, allocation->height);
-
return FALSE;
}
-
static void
sniffer_scope_shift (BstSnifferScope *self)
{
@@ -207,7 +184,6 @@ sniffer_scope_shift (BstSnifferScope *self)
}
}
}
-
static void
scope_probes_notify (SfiProxy proxy,
SfiSeq *sseq,
@@ -240,25 +216,20 @@ scope_probes_notify (SfiProxy proxy,
bst_source_queue_probe_request (self->proxy, 0, BST_SOURCE_PROBE_RANGE, 20.0);
bst_source_queue_probe_request (self->proxy, 1, BST_SOURCE_PROBE_RANGE, 20.0);
}
-
static void
bst_sniffer_scope_class_init (BstSnifferScopeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->finalize = bst_sniffer_scope_finalize;
-
object_class->destroy = bst_sniffer_scope_destroy;
-
widget_class->size_request = bst_sniffer_scope_size_request;
widget_class->size_allocate = bst_sniffer_scope_size_allocate;
widget_class->realize = bst_sniffer_scope_realize;
widget_class->expose_event = bst_sniffer_scope_expose;
widget_class->unrealize = bst_sniffer_scope_unrealize;
}
-
void
bst_sniffer_scope_set_sniffer (BstSnifferScope *self,
SfiProxy proxy)
@@ -285,7 +256,6 @@ bst_sniffer_scope_set_sniffer (BstSnifferScope *self,
bst_source_queue_probe_request (self->proxy, 1, BST_SOURCE_PROBE_RANGE, 20.0);
}
}
-
static BseProbeRequestSeq *probe_request_seq = NULL;
static gboolean
source_probe_idle_request (gpointer data)
@@ -301,7 +271,6 @@ source_probe_idle_request (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
void
bst_source_queue_probe_request (SfiProxy source,
guint ochannel_id,
diff --git a/beast-gtk/bstsnifferscope.hh b/beast-gtk/bstsnifferscope.hh
index 75d6d3f..4ab8f49 100644
--- a/beast-gtk/bstsnifferscope.hh
+++ b/beast-gtk/bstsnifferscope.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SNIFFER_SCOPE_H__
#define __BST_SNIFFER_SCOPE_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_SNIFFER_SCOPE (bst_sniffer_scope_get_type ())
#define BST_SNIFFER_SCOPE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_SNIFFER_SCOPE, BstSnifferScope))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_SNIFFER_SCOPE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_SNIFFER_SCOPE))
#define BST_IS_SNIFFER_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_SNIFFER_SCOPE))
#define BST_SNIFFER_SCOPE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_SNIFFER_SCOPE, BstSnifferScopeClass))
-
/* --- API --- */
typedef struct {
GtkWidget parent_instance;
@@ -28,19 +24,15 @@ GType bst_sniffer_scope_get_type (void);
GtkWidget* bst_sniffer_scope_new (void);
void bst_sniffer_scope_set_sniffer (BstSnifferScope *scope,
SfiProxy proxy);
-
typedef enum {
BST_SOURCE_PROBE_RANGE = 0x01,
BST_SOURCE_PROBE_ENERGIE = 0x02,
BST_SOURCE_PROBE_SAMPLES = 0x04,
BST_SOURCE_PROBE_FFT = 0x08,
} BstSourceProbeFeature;
-
void bst_source_queue_probe_request (SfiProxy source,
guint ochannel_id,
BstSourceProbeFeature pfeature,
gfloat frequency);
-
G_END_DECLS
-
#endif /* __BST_SNIFFER_SCOPE_H__ */
diff --git a/beast-gtk/bstsplash.cc b/beast-gtk/bstsplash.cc
index 426e987..1223f98 100644
--- a/beast-gtk/bstsplash.cc
+++ b/beast-gtk/bstsplash.cc
@@ -3,8 +3,6 @@
#include <gdk/gdkkeysyms.h>
#include "topconfig.h"
#include <string.h>
-
-
/* --- prototypes --- */
static void bst_splash_class_init (BstSplashClass *klass);
static void bst_splash_init (BstSplash *splash);
@@ -18,18 +16,13 @@ static void bst_splash_show (GtkWidget *widget);
static void bst_splash_unrealize (GtkWidget *widget);
static gboolean bst_splash_delete_event (GtkWidget *widget,
GdkEventAny *event);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GtkType
bst_splash_get_type (void)
{
static GtkType splash_type = 0;
-
if (!splash_type)
{
GtkTypeInfo splash_info =
@@ -43,23 +36,17 @@ bst_splash_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
splash_type = gtk_type_unique (GTK_TYPE_WINDOW, &splash_info);
}
-
return splash_type;
}
-
static void
bst_splash_class_init (BstSplashClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bst_splash_finalize;
-
widget_class->delete_event = bst_splash_delete_event;
widget_class->key_press_event = bst_splash_key_press_event;
widget_class->button_press_event = bst_splash_button_press;
@@ -67,19 +54,16 @@ bst_splash_class_init (BstSplashClass *klass)
widget_class->show = bst_splash_show;
widget_class->unrealize = bst_splash_unrealize;
}
-
static void
bst_splash_init (BstSplash *self)
{
GtkWindow *window = GTK_WINDOW (self);
GtkWidget *any;
-
/* window setup */
g_object_set (window,
"window_position", GTK_WIN_POS_CENTER,
"events", GDK_BUTTON_PRESS_MASK,
NULL);
-
/* main vbox */
self->vbox = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -87,7 +71,6 @@ bst_splash_init (BstSplash *self)
"parent", window,
NULL);
gxk_nullify_in_object (self, &self->vbox);
-
/* splash vbox */
self->splash_box = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -95,7 +78,6 @@ bst_splash_init (BstSplash *self)
NULL);
gxk_nullify_in_object (self, &self->splash_box);
gtk_box_pack_start (GTK_BOX (self->vbox), self->splash_box, TRUE, TRUE, 0);
-
/* progress bar */
self->pbar = (GtkProgressBar*) g_object_new (GTK_TYPE_PROGRESS_BAR,
"visible", TRUE,
@@ -103,7 +85,6 @@ bst_splash_init (BstSplash *self)
gxk_nullify_in_object (self, &self->pbar);
gtk_box_pack_end (GTK_BOX (self->vbox), GTK_WIDGET (self->pbar), FALSE, TRUE, 0);
gtk_progress_set_show_text (GTK_PROGRESS (self->pbar), FALSE);
-
/* item label */
any = (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT,
"visible", TRUE,
@@ -117,7 +98,6 @@ bst_splash_init (BstSplash *self)
"parent", any,
NULL);
gxk_nullify_in_object (self, &self->item);
-
/* entity label */
any = (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT,
"visible", TRUE,
@@ -132,24 +112,19 @@ bst_splash_init (BstSplash *self)
NULL);
gxk_nullify_in_object (self, &self->entity);
}
-
static void
bst_splash_finalize (GObject *object)
{
// BstSplash *splash = BST_SPLASH (object);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gboolean
bst_splash_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
gtk_widget_hide (widget);
-
return TRUE;
}
-
static gboolean
bst_splash_key_press_event (GtkWidget *widget,
GdkEventKey *event)
@@ -162,16 +137,13 @@ bst_splash_key_press_event (GtkWidget *widget,
}
return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
}
-
static gint
bst_splash_button_press (GtkWidget *widget,
GdkEventButton *event)
{
gtk_widget_hide (widget);
-
return TRUE;
}
-
static void
bst_splash_hide (GtkWidget *widget)
{
@@ -186,36 +158,29 @@ bst_splash_hide (GtkWidget *widget)
}
GTK_WIDGET_CLASS (parent_class)->hide (widget);
}
-
static void
bst_splash_show (GtkWidget *widget)
{
BstSplash *self = BST_SPLASH (widget);
-
self->item_count = 0;
GTK_WIDGET_CLASS (parent_class)->show (widget);
}
-
static void
bst_splash_unrealize (GtkWidget *widget)
{
BstSplash *self = BST_SPLASH (widget);
-
if (BST_DBG_EXT) /* && self->item_count > self->max_items */
g_message ("BstSplash: seen %u/%u items (%+d)",
self->item_count, self->max_items,
self->item_count - self->max_items);
-
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
-
void
bst_splash_set_title (GtkWidget *widget,
const gchar *title)
{
gtk_window_set_title (GTK_WINDOW (widget), title);
}
-
GtkWidget*
bst_splash_new (const gchar *role,
guint splash_width,
@@ -223,7 +188,6 @@ bst_splash_new (const gchar *role,
guint max_items)
{
GtkWidget *splash = (GtkWidget*) g_object_new (BST_TYPE_SPLASH, NULL);
-
/* set title and role */
gtk_window_set_role (GTK_WINDOW (splash), role);
gtk_window_set_title (GTK_WINDOW (splash), role);
@@ -232,15 +196,12 @@ bst_splash_new (const gchar *role,
"width_request", splash_width,
"height_request", splash_height,
NULL);
-
return splash;
}
-
void
bst_splash_show_grab (GtkWidget *widget)
{
BstSplash *self = BST_SPLASH (widget);
-
if (!GTK_WIDGET_VISIBLE (widget))
{
gtk_widget_show (widget);
@@ -249,7 +210,6 @@ bst_splash_show_grab (GtkWidget *widget)
self->has_grab = TRUE;
gtk_grab_add (widget);
}
-
GDK_THREADS_LEAVE ();
while (!GTK_WIDGET_MAPPED (widget))
g_main_iteration (TRUE);
@@ -258,7 +218,6 @@ bst_splash_show_grab (GtkWidget *widget)
GDK_THREADS_ENTER ();
}
}
-
void
bst_splash_release_grab (GtkWidget *widget)
{
@@ -269,7 +228,6 @@ bst_splash_release_grab (GtkWidget *widget)
gtk_grab_remove (widget);
}
}
-
void
bst_splash_update_entity (GtkWidget *widget,
const gchar *format,
@@ -278,19 +236,15 @@ bst_splash_update_entity (GtkWidget *widget,
BstSplash *self;
va_list args;
gchar *text;
-
g_return_if_fail (BST_IS_SPLASH (widget));
-
self = BST_SPLASH (widget);
va_start (args, format);
text = g_strdup_vprintf (format, args);
va_end (args);
-
gtk_label_set_text (GTK_LABEL (self->entity), text);
gtk_label_set_text (GTK_LABEL (self->item), NULL);
g_free (text);
}
-
void
bst_splash_update_item (GtkWidget *widget,
const gchar *format,
@@ -299,17 +253,13 @@ bst_splash_update_item (GtkWidget *widget,
BstSplash *self;
va_list args;
gchar *text;
-
g_return_if_fail (BST_IS_SPLASH (widget));
-
self = BST_SPLASH (widget);
va_start (args, format);
text = g_strdup_vprintf (format, args);
va_end (args);
-
gtk_label_set_text (GTK_LABEL (self->item), text);
g_free (text);
-
if (GTK_WIDGET_VISIBLE (self))
{
gfloat frac = self->item_count++;
@@ -320,7 +270,6 @@ bst_splash_update_item (GtkWidget *widget,
g_usleep (1000 * 250);
}
}
-
void
bst_splash_update (void)
{
@@ -329,7 +278,6 @@ bst_splash_update (void)
g_main_iteration (FALSE);
GDK_THREADS_ENTER ();
}
-
void
bst_splash_set_text (GtkWidget *widget,
const gchar *format,
@@ -338,13 +286,10 @@ bst_splash_set_text (GtkWidget *widget,
BstSplash *self;
va_list args;
gchar *text;
-
g_return_if_fail (BST_IS_SPLASH (widget));
-
va_start (args, format);
text = g_strdup_vprintf (format, args);
va_end (args);
-
self = BST_SPLASH (widget);
gtk_container_foreach (GTK_CONTAINER (self->splash_box), (GtkCallback) gtk_widget_destroy, NULL);
if (text)
@@ -369,15 +314,12 @@ bst_splash_set_text (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (self))
bst_splash_update ();
}
-
void
bst_splash_set_animation (GtkWidget *widget,
GdkPixbufAnimation *anim)
{
BstSplash *self;
-
g_return_if_fail (BST_IS_SPLASH (widget));
-
self = BST_SPLASH (widget);
gtk_container_foreach (GTK_CONTAINER (self->splash_box), (GtkCallback) gtk_widget_destroy, NULL);
if (anim)
@@ -405,7 +347,6 @@ bst_splash_set_animation (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (self))
bst_splash_update ();
}
-
static const gchar*
splash_select_string (BstSplash *self)
{
@@ -421,7 +362,6 @@ splash_select_string (BstSplash *self)
}
return string;
}
-
static gboolean
about_timer (gpointer data)
{
@@ -439,7 +379,6 @@ about_timer (gpointer data)
GDK_THREADS_LEAVE ();
return TRUE;
}
-
void
bst_splash_animate_strings (GtkWidget *splash,
const gchar **strings)
diff --git a/beast-gtk/bstsplash.hh b/beast-gtk/bstsplash.hh
index d670956..c2d9e03 100644
--- a/beast-gtk/bstsplash.hh
+++ b/beast-gtk/bstsplash.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SPLASH_H__
#define __BST_SPLASH_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_SPLASH (bst_splash_get_type ())
#define BST_SPLASH(object) (GTK_CHECK_CAST ((object), BST_TYPE_SPLASH, BstSplash))
@@ -13,22 +10,15 @@ G_BEGIN_DECLS
#define BST_IS_SPLASH(object) (GTK_CHECK_TYPE ((object), BST_TYPE_SPLASH))
#define BST_IS_SPLASH_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_SPLASH))
#define BST_SPLASH_GET_CLASS(splash) (G_TYPE_INSTANCE_GET_CLASS ((splash), BST_TYPE_SPLASH, BstSplashClass))
-
-
/* --- typedefs & enums --- */
typedef struct _BstSplash BstSplash;
typedef struct _BstSplashClass BstSplashClass;
-
-
/* --- structures --- */
struct _BstSplash
{
GtkWindow window;
-
GtkWidget *vbox;
-
GtkWidget *splash_box;
-
GtkWidget *entity;
GtkWidget *item;
GtkProgressBar *pbar;
@@ -45,8 +35,6 @@ struct _BstSplashClass
{
GtkWindowClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_splash_get_type (void);
GtkWidget* bst_splash_new (const gchar *role,
@@ -71,8 +59,5 @@ void bst_splash_update_item (GtkWidget *widget,
...) G_GNUC_PRINTF (2, 3);
void bst_splash_animate_strings (GtkWidget *splash,
const gchar **strings);
-
-
G_END_DECLS
-
#endif /* __BST_SPLASH_H__ */
diff --git a/beast-gtk/bststest.cc b/beast-gtk/bststest.cc
index 3fd86f1..46de364 100644
--- a/beast-gtk/bststest.cc
+++ b/beast-gtk/bststest.cc
@@ -5,21 +5,15 @@
// #include <bse/gsldatacache.hh>
// #include <bse/gsldatahandle.hh>
#include <string.h>
-
#include <math.h>
-
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-
int main() { return 0; }
-
#if 0
-
#define QSAMPLER_SELECTION_TIMEOUT (33)
-
typedef struct _WaveView WaveView;
struct _WaveView
{
@@ -28,10 +22,7 @@ struct _WaveView
WaveView *next;
};
static WaveView *wave_views = NULL;
-
-
static gulong qsampler_selection_timeout_id = 0;
-
static void
qsampler_set_selection (BstQSampler *qsampler,
gint m1,
@@ -46,24 +37,20 @@ qsampler_set_selection (BstQSampler *qsampler,
else if (visible_mark == 2)
bst_qsampler_scroll_show (qsampler, m2);
}
-
static gboolean
qsampler_selection_timeout (gpointer data)
{
BstQSampler *qsampler = BST_QSAMPLER (data);
gboolean retain = FALSE;
-
if (GTK_WIDGET_DRAWABLE (qsampler))
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x;
-
gdk_window_get_pointer (GTK_WIDGET (qsampler)->window, &x, NULL, NULL);
if (!bst_qsampler_get_offset_at (qsampler, &x))
{
gint b;
-
if (x < 0)
{
bst_qsampler_get_bounds (qsampler, &b, NULL);
@@ -81,7 +68,6 @@ qsampler_selection_timeout (gpointer data)
else
qsampler_set_selection (qsampler, m1, x, 2);
}
-
if (retain && qsampler_selection_timeout_id)
return TRUE;
else
@@ -91,19 +77,16 @@ qsampler_selection_timeout (gpointer data)
return FALSE;
}
}
-
static gboolean
qsampler_button_event (BstQSampler *qsampler,
GdkEventButton *event)
{
gboolean handled = FALSE;
-
if (event->button == 1)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x = event->x;
-
handled = TRUE;
if (!bst_qsampler_get_offset_at (qsampler, &x))
{
@@ -112,7 +95,6 @@ qsampler_button_event (BstQSampler *qsampler,
else
bst_qsampler_get_bounds (qsampler, NULL, &x);
}
-
if (event->type == GDK_BUTTON_PRESS && (event->state & GDK_SHIFT_MASK) &&
m1 >= 0 && m2 >= 0)
{
@@ -132,22 +114,18 @@ qsampler_button_event (BstQSampler *qsampler,
}
}
}
-
return handled;
}
-
static gboolean
qsampler_motion_event (BstQSampler *qsampler,
GdkEventMotion *event)
{
gboolean handled = FALSE;
-
if (event->type == GDK_MOTION_NOTIFY)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
// gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
gint x = event->x;
-
handled = TRUE;
if (bst_qsampler_get_offset_at (qsampler, &x))
qsampler_set_selection (qsampler, m1, x, 2);
@@ -157,20 +135,15 @@ qsampler_motion_event (BstQSampler *qsampler,
qsampler_selection_timeout,
g_object_ref (qsampler), NULL);
}
-
return handled;
}
-
-
static void
selection_to_loop (BstQSampler *qsampler)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 1);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 2);
-
if (m2 < 0 || m1 < 0)
return;
-
if (m2 < m1)
{
gint t = m2;
@@ -184,25 +157,20 @@ selection_to_loop (BstQSampler *qsampler)
bst_qsampler_set_mark (qsampler, 1, 0, 0);
bst_qsampler_set_mark (qsampler, 2, 0, 0);
}
-
static void
loop_to_selection (BstQSampler *qsampler)
{
gint m1, m2;
-
m1 = bst_qsampler_get_mark_offset (qsampler, 3);
m2 = bst_qsampler_get_mark_offset (qsampler, 4);
if (m2 < 0 || m1 < 0)
return;
-
qsampler_set_selection (qsampler, MIN (m1, m2), MAX (m1, m2), 0);
}
-
static void
zoom_selection (BstQSampler *qsampler)
{
gint m1, m2;
-
m1 = bst_qsampler_get_mark_offset (qsampler, 1);
m2 = bst_qsampler_get_mark_offset (qsampler, 2);
if (m2 < 0 || m1 < 0)
@@ -214,11 +182,9 @@ zoom_selection (BstQSampler *qsampler)
m1 = t;
}
m2 = MAX (m2, m1 + 1);
-
bst_qsampler_scroll_to (qsampler, m1);
bst_qsampler_set_zoom (qsampler, qsampler->n_pixels / (gdouble) (m2 - m1) * 100.);
}
-
static void
adjust_zoom (GtkAdjustment *adjustment,
BstQSampler *qsampler)
@@ -231,7 +197,6 @@ adjust_vscale (GtkAdjustment *adjustment,
{
bst_qsampler_set_vscale (qsampler, adjustment->value);
}
-
static void
qsampler_dcache_filler (gpointer data,
guint voffset,
@@ -243,14 +208,12 @@ qsampler_dcache_filler (gpointer data,
GslDataCacheNode *dnode;
glong dcache_length, dnode_length;
gint i;
-
dnode = gsl_data_cache_ref_node (dcache, voffset, TRUE);
dcache_length = gsl_data_handle_length (dcache->dhandle);
dnode_length = dcache->node_size;
for (i = 0; i < n_values; i++)
{
glong offset = voffset + i;
-
if (offset < 0 || offset >= dcache_length)
values[i] = 0;
else
@@ -265,53 +228,43 @@ qsampler_dcache_filler (gpointer data,
}
gsl_data_cache_unref_node (dcache, dnode);
}
-
static void
qsampler_set_handle (BstQSampler *qsampler,
GslDataHandle *handle)
{
GslDataCache *dcache = gsl_data_cache_new (handle, 1);
-
gsl_data_cache_open (dcache);
bst_qsampler_set_source (qsampler, gsl_data_handle_length (dcache->dhandle),
qsampler_dcache_filler, dcache, (GDestroyNotify) gsl_data_cache_close);
gsl_data_cache_unref (dcache);
}
-
GslDataHandle *global_handle = NULL;
-
static void
unset_loop (BstQSampler *qsampler)
{
qsampler_set_handle (qsampler, global_handle);
}
-
static void
set_loop (BstQSampler *qsampler)
{
gint m1 = bst_qsampler_get_mark_offset (qsampler, 3);
gint m2 = bst_qsampler_get_mark_offset (qsampler, 4);
-
if (m2 < 0 || m1 < 0)
return;
-
if (m2 < m1)
{
gint t = m2;
m2 = m1;
m1 = t;
}
-
if (m1 >= 0 && m2 > m1)
{
GslDataHandle *handle = gsl_data_handle_new_looped (global_handle, m1, m2);
-
qsampler_set_handle (qsampler, handle);
gsl_data_handle_unref (handle);
qsampler_set_selection (qsampler, m1, m2, 0);
}
}
-
static void
score (BstQSampler *qsampler)
{
@@ -320,89 +273,74 @@ score (BstQSampler *qsampler)
GslDataHandle *dhandle = dcache->dhandle;
GslLong l, length = MIN (gsl_data_handle_length (shandle), gsl_data_handle_length (dhandle));
gdouble score = 0;
-
for (l = 0; l < length; )
{
GslLong b = 8192;
gfloat v1[b], v2[b];
-
b = MIN (b, length - l);
b = gsl_data_handle_read (shandle, l, b, v1);
b = gsl_data_handle_read (dhandle, l, b, v2);
g_assert (b >= 0);
g_assert (b >= 1);
l += b;
-
while (b--)
score += (v1[b] - v2[b]) * (v1[b] - v2[b]);
// g_print ("0x%08lx) %10.3f\n", l, score);
}
g_print ("total score: %10.3f\n", score);
}
-
static gdouble
score_loop (GslDataHandle *shandle,
GslDataHandle *dhandle)
{
GslLong l, length = MIN (gsl_data_handle_length (shandle), gsl_data_handle_length (dhandle));
gdouble score = 0;
-
for (l = 0; l < length; )
{
GslLong b = 8192;
gfloat v1[b], v2[b];
-
b = MIN (b, length - l);
b = gsl_data_handle_read (shandle, l, b, v1);
b = gsl_data_handle_read (dhandle, l, b, v2);
g_assert (b >= 0);
g_assert (b >= 1);
l += b;
-
while (b--)
score += (v1[b] - v2[b]) * (v1[b] - v2[b]);
}
return score;
}
-
#include <bse/gsldatautils.hh>
-
static void
find (WaveView *view)
{
GslLong start, end;
GslLong length = gsl_data_handle_length (view->handle);
GslLoopSpec loop_spec = { 0, length / 3, 44100.0/15., length / 3.5 };
-
gsl_data_find_tailmatch (view->handle, &loop_spec, &start, &end);
qsampler_set_selection (view->qsampler, start, end, 2);
selection_to_loop (view->qsampler);
}
-
static void
mark_signalh (WaveView *view)
{
GslLong mark;
-
mark = gsl_data_find_sample (view->handle,
1. / 32768. * +16.,
1. / 32768. * -16.,
0, +1);
bst_qsampler_set_mark (view->qsampler, 5, MAX (mark, 0), mark < 0 ? 0 : BST_QSAMPLER_PRELIGHT);
}
-
static void
mark_signalt (WaveView *view)
{
GslLong mark;
-
mark = gsl_data_find_sample (view->handle,
1. / 32768. * +16.,
1. / 32768. * -16.,
-1, -1);
bst_qsampler_set_mark (view->qsampler, 5, MAX (mark, 0), mark < 0 ? 0 : BST_QSAMPLER_PRELIGHT);
}
-
static void
findx ()
{
@@ -411,16 +349,13 @@ findx ()
GslLong length = gsl_data_handle_length (shandle);
GslLong l, start = 0, end = 0, lsize = gsl_data_handle_length (shandle) / 2;
gdouble score = 0, least = GSL_MAXLONG;
-
gsl_data_cache_unref (dcache);
gsl_data_handle_open (shandle);
-
while (lsize)
{
for (l = 0; l < length - lsize; l++)
{
GslDataHandle *dhandle = gsl_data_handle_new_looped (shandle, l, l + lsize);
-
gsl_data_handle_open (dhandle);
score = score_loop (shandle, dhandle);
gsl_data_handle_close (dhandle);
@@ -439,9 +374,7 @@ findx ()
gsl_data_handle_close (shandle);
gsl_data_handle_unref (shandle);
}
-
static GtkWidget* pack_test_widget (void);
-
int
main (int argc,
char *argv[])
@@ -455,7 +388,6 @@ main (int argc,
};
WaveView *view, *first_view = NULL;
guint i;
-
g_thread_init (NULL);
g_type_init ();
birnet_init (&argc, &argv, NULL);
@@ -464,21 +396,17 @@ main (int argc,
gtk_init (&argc, &argv);
gxk_init ();
_bst_init_utils ();
-
if (argc < 2)
g_error ("need filenames");
-
vbox = gtk_widget_new (GTK_TYPE_VBOX,
"visible", TRUE,
"border_width", 10,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), pack_test_widget (), TRUE, TRUE, 0);
-
sbar = gtk_widget_new (GTK_TYPE_HSCROLLBAR,
"visible", TRUE,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), sbar, FALSE, TRUE, 0);
-
for (i = 1; i < argc; i++)
{
view = g_new (WaveView, 1);
@@ -504,7 +432,6 @@ main (int argc,
if (i == 1)
first_view = view;
}
-
spin = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 1e-16, 1e+16, 0.1, 10, 0)), 0, 5);
gtk_widget_set (spin,
"visible", TRUE,
@@ -515,7 +442,6 @@ main (int argc,
"signal::value_changed", adjust_zoom, view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), spin, FALSE, TRUE, 0);
-
spin = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 1e-16, 1e+16, 1, 10, 0)), 0, 5);
gtk_widget_set (spin,
"visible", TRUE,
@@ -526,13 +452,11 @@ main (int argc,
"signal::value_changed", adjust_vscale, view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), spin, FALSE, TRUE, 0);
-
hbox = gtk_widget_new (GTK_TYPE_HBOX,
"visible", TRUE,
"border_width", 10,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Selection to Loop"),
@@ -540,7 +464,6 @@ main (int argc,
"swapped_signal::clicked", selection_to_loop, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Loop to Selection"),
@@ -548,7 +471,6 @@ main (int argc,
"swapped_signal::clicked", loop_to_selection, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Zoom Selection"),
@@ -556,7 +478,6 @@ main (int argc,
"swapped_signal::clicked", zoom_selection, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Apply Loop"),
@@ -564,7 +485,6 @@ main (int argc,
"swapped_signal::clicked", set_loop, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Reset Loop"),
@@ -572,7 +492,6 @@ main (int argc,
"swapped_signal::clicked", unset_loop, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Score"),
@@ -580,7 +499,6 @@ main (int argc,
"swapped_signal::clicked", score, first_view->qsampler,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
button = g_object_connect (g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Find"),
@@ -588,7 +506,6 @@ main (int argc,
"swapped_signal::clicked", find, first_view,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
-
window = g_object_connect (gtk_widget_new (GTK_TYPE_WINDOW,
"child", vbox,
"visible", TRUE,
@@ -598,7 +515,6 @@ main (int argc,
NULL),
"signal::destroy", gtk_main_quit, NULL,
NULL);
-
button = g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Mark Signal (Head)"),
@@ -608,7 +524,6 @@ main (int argc,
g_object_connect (GTK_OBJECT (button),
"swapped_signal::clicked", mark_signalh, view,
NULL);
-
button = g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
"label", _("Mark Signal (Tail)"),
@@ -618,13 +533,9 @@ main (int argc,
g_object_connect (GTK_OBJECT (button),
"swapped_signal::clicked", mark_signalt, view,
NULL);
-
-
gtk_main ();
-
return 0;
}
-
#if 0 /* test code */
static void
plist_fill_value (gpointer da_NULL,
@@ -645,7 +556,6 @@ plist_fill_value (gpointer da_NULL,
break;
}
}
-
static gboolean
tree_event (GtkTreeView *tree,
GdkEvent *event)
@@ -678,7 +588,6 @@ tree_event (GtkTreeView *tree,
}
return FALSE;
}
-
static GtkWidget*
pack_test_widget (void)
{
@@ -693,7 +602,6 @@ pack_test_widget (void)
G_CALLBACK (plist_fill_value),
NULL, G_CONNECT_SWAPPED);
gxk_list_wrapper_notify_prepend (plist, 200);
-
scwin = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
"hscrollbar_policy", GTK_POLICY_AUTOMATIC,
@@ -734,13 +642,11 @@ pack_test_widget (void)
"swapped_object_signal::row_activated", tree_row_activated, self,
NULL);
#endif
-
/* ensure selection
*/
tsel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_SINGLE);
gxk_tree_selection_select_spath (tsel, "0");
-
return scwin;
}
#else
@@ -750,6 +656,4 @@ pack_test_widget (void)
return g_object_new (GTK_TYPE_ALIGNMENT, NULL);
}
#endif
-
-
#endif
diff --git a/beast-gtk/bstsupershell.cc b/beast-gtk/bstsupershell.cc
index 7e717c1..75e6f0d 100644
--- a/beast-gtk/bstsupershell.cc
+++ b/beast-gtk/bstsupershell.cc
@@ -10,13 +10,10 @@
#include "bstsnetrouter.hh"
#include "bstgconfig.hh"
#include <string.h>
-
enum {
PROP_0,
PROP_SUPER
};
-
-
/* --- prototypes --- */
static void bst_super_shell_destroy (GtkObject *object);
static void bst_super_shell_finalize (GObject *object);
@@ -29,34 +26,24 @@ static void bst_super_shell_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void super_shell_add_views (BstSuperShell *self);
-
-
/* --- static variables --- */
static BstSuperShellClass *bst_super_shell_class = NULL;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstSuperShell, bst_super_shell, GTK_TYPE_VBOX);
-
static void
bst_super_shell_class_init (BstSuperShellClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
bst_super_shell_class = klass;
-
gobject_class->set_property = bst_super_shell_set_property;
gobject_class->get_property = bst_super_shell_get_property;
gobject_class->finalize = bst_super_shell_finalize;
-
object_class->destroy = bst_super_shell_destroy;
-
g_object_class_install_property (gobject_class,
PROP_SUPER,
sfi_pspec_proxy ("super", NULL, NULL, SFI_PARAM_STANDARD));
}
-
static void
bst_super_shell_init (BstSuperShell *self)
{
@@ -68,7 +55,6 @@ bst_super_shell_init (BstSuperShell *self)
"border_width", 0,
NULL);
}
-
static void
bst_super_shell_set_property (GObject *object,
guint prop_id,
@@ -76,7 +62,6 @@ bst_super_shell_set_property (GObject *object,
GParamSpec *pspec)
{
BstSuperShell *self = BST_SUPER_SHELL (object);
-
switch (prop_id)
{
case PROP_SUPER:
@@ -87,7 +72,6 @@ bst_super_shell_set_property (GObject *object,
break;
}
}
-
static void
bst_super_shell_get_property (GObject *object,
guint prop_id,
@@ -95,7 +79,6 @@ bst_super_shell_get_property (GObject *object,
GParamSpec *pspec)
{
BstSuperShell *self = BST_SUPER_SHELL (object);
-
switch (prop_id)
{
case PROP_SUPER:
@@ -106,26 +89,20 @@ bst_super_shell_get_property (GObject *object,
break;
}
}
-
static void
bst_super_shell_destroy (GtkObject *object)
{
BstSuperShell *self = BST_SUPER_SHELL (object);
-
if (self->super)
bst_super_shell_set_super (self, 0);
-
GTK_OBJECT_CLASS (bst_super_shell_parent_class)->destroy (object);
}
-
static void
bst_super_shell_finalize (GObject *object)
{
// BstSuperShell *self = BST_SUPER_SHELL (object);
-
G_OBJECT_CLASS (bst_super_shell_parent_class)->finalize (object);
}
-
void
bst_super_shell_set_super (BstSuperShell *self,
SfiProxy super)
@@ -133,7 +110,6 @@ bst_super_shell_set_super (BstSuperShell *self,
g_return_if_fail (BST_IS_SUPER_SHELL (self));
if (super)
g_return_if_fail (BSE_IS_SUPER (super));
-
if (super != self->super)
{
if (self->super)
@@ -149,19 +125,16 @@ bst_super_shell_set_super (BstSuperShell *self,
}
}
}
-
GtkWidget*
bst_super_shell_create_label (BstSuperShell *super_shell)
{
return gxk_notebook_create_tabulator ("SuperShell", NULL, NULL);
}
-
static void
super_shell_build_song (BstSuperShell *self,
GtkNotebook *notebook)
{
SfiProxy song = self->super;
-
gtk_notebook_append_page (notebook,
bst_track_view_new (song),
gxk_notebook_create_tabulator (_("Tracks"), BST_STOCK_TRACKS, _("Tracks contain instrument definitions and parts with notes")));
@@ -184,14 +157,12 @@ super_shell_build_song (BstSuperShell *self,
gtk_widget_get_toplevel (GTK_WIDGET (bst_snet_router_build_page (song))),
gxk_notebook_create_tabulator (_("Routing"), BST_STOCK_MESH, NULL));
}
-
static void
super_shell_build_snet (BstSuperShell *self,
GtkNotebook *notebook)
{
SfiProxy snet = self->super;
GtkWidget *param_view;
-
if (BST_DBG_EXT && bse_snet_supports_user_synths (snet))
gtk_notebook_append_page (notebook,
gtk_widget_get_toplevel (bst_rack_view_new (snet)),
@@ -205,13 +176,11 @@ super_shell_build_snet (BstSuperShell *self,
bst_param_view_new (snet),
gxk_notebook_create_tabulator (_("Properties"), BST_STOCK_PROPERTIES, _("Adjust overall synthesizer behaviour")));
}
-
static void
super_shell_build_wave_repo (BstSuperShell *self,
GtkNotebook *notebook)
{
SfiProxy wrepo = self->super;
-
gtk_notebook_append_page (notebook,
bst_wave_view_new (wrepo),
gxk_notebook_create_tabulator (_("Waves"), BST_STOCK_MINI_WAVE_REPO, NULL));
@@ -219,7 +188,6 @@ super_shell_build_wave_repo (BstSuperShell *self,
bst_param_view_new (wrepo),
gxk_notebook_create_tabulator (_("Properties"), BST_STOCK_PROPERTIES, NULL));
}
-
static GtkNotebook*
create_notebook (BstSuperShell *self)
{
@@ -236,7 +204,6 @@ create_notebook (BstSuperShell *self)
NULL);
return notebook;
}
-
static void
super_shell_add_views (BstSuperShell *self)
{
diff --git a/beast-gtk/bstsupershell.hh b/beast-gtk/bstsupershell.hh
index 741f57c..2c41d97 100644
--- a/beast-gtk/bstsupershell.hh
+++ b/beast-gtk/bstsupershell.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_SUPER_SHELL_H__
#define __BST_SUPER_SHELL_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_SUPER_SHELL (bst_super_shell_get_type ())
#define BST_SUPER_SHELL(object) (GTK_CHECK_CAST ((object), BST_TYPE_SUPER_SHELL, BstSuperShell))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_SUPER_SHELL(object) (GTK_CHECK_TYPE ((object), BST_TYPE_SUPER_SHELL))
#define BST_IS_SUPER_SHELL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_SUPER_SHELL))
#define BST_SUPER_SHELL_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_SUPER_SHELL, BstSuperShellClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstSuperShell BstSuperShell;
typedef struct _BstSuperShellClass BstSuperShellClass;
@@ -28,14 +23,10 @@ struct _BstSuperShellClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_super_shell_get_type (void);
void bst_super_shell_set_super (BstSuperShell *super_shell,
SfiProxy super);
GtkWidget* bst_super_shell_create_label (BstSuperShell *super_shell);
-
G_END_DECLS
-
#endif /* __BST_SUPER_SHELL_H__ */
diff --git a/beast-gtk/bsttrackroll.cc b/beast-gtk/bsttrackroll.cc
index cc22b01..be3280c 100644
--- a/beast-gtk/bsttrackroll.cc
+++ b/beast-gtk/bsttrackroll.cc
@@ -2,8 +2,6 @@
#include "bsttrackroll.hh"
#include "bstsnifferscope.hh"
#include <string.h>
-
-
/* --- defines --- */
/* accessors */
#define STYLE(self) (GTK_WIDGET (self)->style)
@@ -29,8 +27,6 @@
#define PMARK_WIDTH(self) (CMARK_WIDTH (self) + 3 * XTHICKNESS (self))
/* appearance */
#define TACT_HPIXELS (50) /* guideline */
-
-
/* --- prototypes --- */
static void bst_track_roll_hsetup (BstTrackRoll *self,
guint tpt,
@@ -40,30 +36,23 @@ static void bst_track_roll_allocate_ecell (BstTrackRoll *self);
static void bst_track_roll_allocate_scope (BstTrackRoll *self,
GtkWidget *child,
guint row);
-
-
/* --- static variables --- */
static guint signal_select_row = 0;
static guint signal_drag = 0;
static guint signal_clicked = 0;
static guint signal_stop_edit = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstTrackRoll, bst_track_roll, GXK_TYPE_SCROLL_CANVAS);
-
enum {
CINDEX_POS,
CINDEX_LOOP,
CINDEX_SELECT,
CINDEX_COUNT
};
-
static void
bst_track_roll_init (BstTrackRoll *self)
{
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
-
self->tpt = 384 * 4;
self->max_ticks = 1;
self->hzoom = 1;
@@ -76,13 +65,11 @@ bst_track_roll_init (BstTrackRoll *self)
self->area_offset = 20;
bst_track_roll_hsetup (self, 384 * 4, 800 * 384, 100);
}
-
static void
bst_track_roll_destroy (GtkObject *object)
{
BstTrackRoll *self = BST_TRACK_ROLL (object);
guint i;
-
if (self->scope_update)
{
g_source_remove (self->scope_update);
@@ -93,31 +80,24 @@ bst_track_roll_destroy (GtkObject *object)
g_free (self->scopes);
self->scopes = NULL;
self->n_scopes = 0;
-
GTK_OBJECT_CLASS (bst_track_roll_parent_class)->destroy (object);
}
-
static void
bst_track_roll_finalize (GObject *object)
{
BstTrackRoll *self = BST_TRACK_ROLL (object);
guint i;
-
bst_track_roll_setup (self, NULL, 0);
-
if (self->scope_update)
{
g_source_remove (self->scope_update);
self->scope_update = 0;
}
-
for (i = 0; i < self->n_scopes; i++)
gtk_widget_unparent (self->scopes[i]);
g_free (self->scopes);
-
G_OBJECT_CLASS (bst_track_roll_parent_class)->finalize (object);
}
-
static void
track_roll_forall (GtkContainer *container,
gboolean include_internals,
@@ -132,24 +112,19 @@ track_roll_forall (GtkContainer *container,
if (self->ecell && include_internals)
callback ((GtkWidget*) self->ecell, callback_data);
}
-
static void
track_roll_update_layout (BstTrackRoll *self,
gboolean queue_resize)
{
gint old_area_offset, dummy;
-
old_area_offset = self->area_offset;
-
if (self->tree)
gxk_tree_view_get_bin_window_pos (self->tree, &dummy, &self->area_offset);
else
self->area_offset = 20;
-
if (old_area_offset != self->area_offset && queue_resize)
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
track_roll_get_layout (GxkScrollCanvas *scc,
GxkScrollCanvasLayout *layout)
@@ -163,7 +138,6 @@ track_roll_get_layout (GxkScrollCanvas *scc,
layout->canvas_width = 1 + 2 * XTHICKNESS (self) + 1;
layout->canvas_height = 1;
}
-
static void
track_roll_release_proxy (BstTrackRoll *self)
{
@@ -173,7 +147,6 @@ track_roll_release_proxy (BstTrackRoll *self)
bse_item_unuse (self->proxy);
self->proxy = 0;
}
-
void
bst_track_roll_setup (BstTrackRoll *self,
GtkTreeView *tree,
@@ -184,7 +157,6 @@ bst_track_roll_setup (BstTrackRoll *self,
g_return_if_fail (GTK_IS_TREE_VIEW (tree));
if (song)
g_return_if_fail (BSE_IS_SONG (song));
-
if (self->tree)
{
g_object_disconnect_any (self->tree, (void*) gxk_scroll_canvas_reallocate, self);
@@ -198,7 +170,6 @@ bst_track_roll_setup (BstTrackRoll *self,
"swapped_object_signal_after::size_allocate", gxk_scroll_canvas_reallocate, self,
NULL);
}
-
if (self->proxy)
track_roll_release_proxy (self);
self->proxy = song;
@@ -213,12 +184,10 @@ bst_track_roll_setup (BstTrackRoll *self,
bst_track_roll_queue_row_change (self, 0);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
void
bst_track_roll_reselect (BstTrackRoll *self)
{
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
if (self->tree)
{
bst_track_roll_set_prelight_row (self, gxk_tree_view_get_selected_row (self->tree));
@@ -228,31 +197,25 @@ bst_track_roll_reselect (BstTrackRoll *self)
else
bst_track_roll_set_prelight_row (self, 0xffffffff);
}
-
static gint
ticks_to_pixels (BstTrackRoll *self,
gint ticks)
{
gdouble tpt = self->tpt;
gdouble tpixels = TACT_HPIXELS;
-
/* compute pixel span of a tick range */
-
tpixels *= self->hzoom / tpt * (gdouble) ticks;
if (ticks)
tpixels = MAX (tpixels, 1);
return MIN (G_MAXINT, tpixels);
}
-
static gint
pixels_to_ticks_unscrolled (BstTrackRoll *self,
gint pixels)
{
gdouble tpt = self->tpt;
gdouble ticks = 1.0 / (gdouble) TACT_HPIXELS;
-
/* compute tick span of a pixel range */
-
ticks = ticks * tpt / self->hzoom * (gdouble) pixels;
if (pixels > 0)
ticks = MAX (ticks, 1);
@@ -260,36 +223,30 @@ pixels_to_ticks_unscrolled (BstTrackRoll *self,
ticks = 0;
return MIN (G_MAXINT, ticks);
}
-
static gint
tick_to_coord (BstTrackRoll *self,
gint tick)
{
return ticks_to_pixels (self, tick) - X_OFFSET (self);
}
-
static gint
coord_to_tick (BstTrackRoll *self,
gint x,
gboolean right_bound)
{
guint tick;
-
x += X_OFFSET (self);
tick = pixels_to_ticks_unscrolled (self, x);
if (right_bound)
{
guint tick2 = pixels_to_ticks_unscrolled (self, x + 1);
-
if (tick2 > tick)
tick = tick2 - 1;
}
return tick;
}
-
#define CROSSING_TACT4 (1)
#define CROSSING_TACT (2)
-
static guint
coord_check_crossing (BstTrackRoll *self,
gint x,
@@ -298,10 +255,8 @@ coord_check_crossing (BstTrackRoll *self,
guint ltick = coord_to_tick (self, x, FALSE);
guint rtick = coord_to_tick (self, x, TRUE);
guint lq = 0, rq = 0;
-
/* catch _at_ tick boundary as well */
rtick += 1;
-
switch (crossing)
{
case CROSSING_TACT4:
@@ -313,10 +268,8 @@ coord_check_crossing (BstTrackRoll *self,
rq = rtick / self->tpt;
break;
}
-
return lq != rq;
}
-
static gint
coord_to_row (BstTrackRoll *self,
gint y,
@@ -331,7 +284,6 @@ coord_to_row (BstTrackRoll *self,
row = y / 15; /* uneducated guess */
return row;
}
-
static gboolean
row_to_coords (BstTrackRoll *self,
gint row,
@@ -349,7 +301,6 @@ row_to_coords (BstTrackRoll *self,
return TRUE;
}
}
-
static SfiProxy
row_to_track (BstTrackRoll *self,
gint row)
@@ -359,7 +310,6 @@ row_to_track (BstTrackRoll *self,
else
return 0;
}
-
static void
track_roll_allocate_2markers (BstTrackRoll *self,
GxkScrollMarker *marker)
@@ -377,7 +327,6 @@ track_roll_allocate_2markers (BstTrackRoll *self,
x - PMARK_WIDTH (self) / 2, 0,
PMARK_WIDTH (self), ph);
}
-
static void
track_roll_move_2markers (BstTrackRoll *self,
GxkScrollMarker *marker)
@@ -387,7 +336,6 @@ track_roll_move_2markers (BstTrackRoll *self,
gxk_scroll_canvas_move_marker (scc, &marker[0], x - CMARK_WIDTH (self) / 2, 0);
gxk_scroll_canvas_move_marker (scc, &marker[1], x - PMARK_WIDTH (self) / 2, 0);
}
-
static void
track_roll_reallocate_contents (GxkScrollCanvas *scc,
gint xdiff,
@@ -416,13 +364,11 @@ track_roll_reallocate_contents (GxkScrollCanvas *scc,
gtk_widget_size_allocate (widget, &allocation);
}
}
-
for (i = 0; i < scc->n_markers; i += 2)
if (xdiff || ydiff)
track_roll_move_2markers (self, scc->markers + i);
else
track_roll_allocate_2markers (self, scc->markers + i);
-
if (!xdiff && !ydiff) /* real size-allocate */
{
guint i;
@@ -433,7 +379,6 @@ track_roll_reallocate_contents (GxkScrollCanvas *scc,
bst_track_roll_reselect (self);
}
}
-
static void
scope_set_track (GtkWidget *scope,
SfiProxy track)
@@ -443,30 +388,24 @@ scope_set_track (GtkWidget *scope,
bst_sniffer_scope_set_sniffer (BST_SNIFFER_SCOPE (scope),
bse_track_get_output_source (track));
}
-
static SfiProxy
scope_get_track (GtkWidget *scope)
{
return g_object_get_long (scope, "BstTrackRoll-Track");
}
-
static gboolean
track_roll_idle_update_scopes (gpointer data)
{
BstTrackRoll *self = BST_TRACK_ROLL (data);
GSList *scope_list = NULL;
guint i;
-
GDK_THREADS_ENTER ();
self->scope_update = 0;
-
/* save existing scopes */
for (i = 0; i < self->n_scopes; i++)
scope_list = g_slist_prepend (scope_list, self->scopes[i]);
-
/* reset scope list */
self->n_scopes = 0;
-
/* match or create needed scopes */
if (self->get_track && GTK_WIDGET_REALIZED (self))
for (i = 0; ; i++)
@@ -498,36 +437,30 @@ track_roll_idle_update_scopes (gpointer data)
self->scopes = g_renew (GtkWidget*, self->scopes, self->n_scopes);
self->scopes[i] = scope;
}
-
/* get rid of unneeded scopes */
while (scope_list)
{
GtkWidget *child = (GtkWidget*) g_slist_pop_head (&scope_list);
gtk_widget_unparent (child);
}
-
/* allocate scopes 'n stuff */
gxk_scroll_canvas_reallocate (GXK_SCROLL_CANVAS (self));
/* work around spurious redraw problems */
gtk_widget_queue_draw (GTK_WIDGET (self));
-
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
queue_scope_update (BstTrackRoll *self)
{
if (!self->scope_update)
self->scope_update = g_idle_add_full (GTK_PRIORITY_RESIZE - 1, track_roll_idle_update_scopes, self, NULL);
}
-
void
bst_track_roll_check_update_scopes (BstTrackRoll *self)
{
guint i;
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
/* check whether scope update is necessary and schedule one */
if (!GTK_WIDGET_REALIZED (self) || !self->get_track)
{
@@ -550,32 +483,25 @@ bst_track_roll_check_update_scopes (BstTrackRoll *self)
return;
}
}
-
static void
bst_track_roll_realize (GtkWidget *widget)
{
BstTrackRoll *self = BST_TRACK_ROLL (widget);
guint i;
-
GTK_WIDGET_CLASS (bst_track_roll_parent_class)->realize (widget);
-
/* update children */
for (i = 0; i < self->n_scopes; i++)
gtk_widget_set_parent_window (self->scopes[i], VPANEL (self));
if (self->ecell)
gtk_widget_set_parent_window (GTK_WIDGET (self->ecell), CANVAS (self));
}
-
static void
bst_track_roll_unrealize (GtkWidget *widget)
{
BstTrackRoll *self = BST_TRACK_ROLL (widget);
-
bst_track_roll_abort_edit (self);
-
GTK_WIDGET_CLASS (bst_track_roll_parent_class)->unrealize (widget);
}
-
static void
bst_track_roll_draw_canvas (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -594,7 +520,6 @@ bst_track_roll_draw_canvas (GxkScrollCanvas *scc,
// gint line_width = 0; /* line widths != 0 interfere with dash-settings on some X servers */
GXK_SCROLL_CANVAS_CLASS (bst_track_roll_parent_class)->draw_canvas (scc, drawable, area);
gdk_window_get_size (CANVAS (self), &width, &height);
-
validrow = row_to_coords (self, row, &ry, &rheight);
while (validrow && ry < area->y + area->height)
{
@@ -649,13 +574,11 @@ bst_track_roll_draw_canvas (GxkScrollCanvas *scc,
validrow = row_to_coords (self, ++row, &ry, &rheight);
}
}
-
static void
bst_track_roll_overlap_grow_hpanel_area (BstTrackRoll *self,
GdkRectangle *area)
{
gint i, x = area->x, xbound = x + area->width;
-
/* grow hpanel exposes by surrounding tacts */
i = coord_to_tick (self, x, FALSE);
i /= self->tpt;
@@ -668,11 +591,9 @@ bst_track_roll_overlap_grow_hpanel_area (BstTrackRoll *self,
i += 2; /* fudge 1 tact to the right (+1 for round-off) */
i *= self->tpt;
xbound = tick_to_coord (self, i);
-
area->x = x;
area->width = xbound - area->x;
}
-
static void
bst_track_roll_draw_hpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -685,7 +606,6 @@ bst_track_roll_draw_hpanel (GxkScrollCanvas *scc,
gint i, width, height;
gdk_window_get_size (drawable, &width, &height);
bst_track_roll_overlap_grow_hpanel_area (self, area);
-
/* tact numbers */
for (i = area->x; i < area->x + area->width; i++)
{
@@ -695,14 +615,11 @@ bst_track_roll_draw_hpanel (GxkScrollCanvas *scc,
if (coord_check_crossing (self, i, CROSSING_TACT4))
{
int next_pixel, tact4 = coord_to_tick (self, i, TRUE) + 1;
-
tact4 /= (self->tpt * 4);
next_pixel = tick_to_coord (self, (tact4 + 1) * (self->tpt * 4));
-
g_snprintf (buffer, 64, "%u", tact4 * 4 + 1);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width / 2 < (i + next_pixel) / 2)
gdk_draw_layout (drawable, draw_gc,
@@ -712,14 +629,11 @@ bst_track_roll_draw_hpanel (GxkScrollCanvas *scc,
else if (self->draw_tact_grid && coord_check_crossing (self, i, CROSSING_TACT))
{
int next_pixel, tact = coord_to_tick (self, i, TRUE) + 1;
-
tact /= self->tpt;
next_pixel = tick_to_coord (self, (tact + 1) * self->tpt);
-
g_snprintf (buffer, 64, "%u", tact + 1);
pango_layout_set_text (PLAYOUT_HPANEL (self), buffer, -1);
pango_layout_get_pixel_extents (PLAYOUT_HPANEL (self), NULL, &rect);
-
/* draw this tact if there's enough space */
if (i + rect.width < (i + next_pixel) / 2) /* don't half width, leave some more space */
gdk_draw_layout (drawable, draw_gc,
@@ -728,7 +642,6 @@ bst_track_roll_draw_hpanel (GxkScrollCanvas *scc,
}
}
}
-
static void
bst_track_roll_allocate_scope (BstTrackRoll *self,
GtkWidget *child,
@@ -754,7 +667,6 @@ bst_track_roll_allocate_scope (BstTrackRoll *self,
}
gtk_widget_size_allocate (child, &allocation);
}
-
static void
bst_track_roll_draw_vpanel (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -766,7 +678,6 @@ bst_track_roll_draw_vpanel (GxkScrollCanvas *scc,
gint ry, rheight, validrow, width, height;
gdk_window_get_size (VPANEL (self), &width, &height);
validrow = row_to_coords (self, row, &ry, &rheight);
-
while (validrow && ry < area->y + area->height)
{
gdk_draw_rectangle (drawable,
@@ -786,7 +697,6 @@ bst_track_roll_draw_vpanel (GxkScrollCanvas *scc,
validrow = row_to_coords (self, ++row, &ry, &rheight);
}
}
-
static void
bst_track_roll_draw_marker (GxkScrollCanvas *scc,
GdkWindow *drawable,
@@ -816,7 +726,6 @@ bst_track_roll_draw_marker (GxkScrollCanvas *scc,
width == PMARK_WIDTH (self) ? GTK_SHADOW_IN : GTK_SHADOW_OUT, NULL, NULL, NULL,
x, y, width, height);
}
-
static void
track_roll_adjustment_changed (GxkScrollCanvas *scc,
GtkAdjustment *adj)
@@ -838,14 +747,12 @@ track_roll_adjustment_changed (GxkScrollCanvas *scc,
}
}
}
-
static void
track_roll_update_adjustments (GxkScrollCanvas *scc,
gboolean hadj,
gboolean vadj)
{
BstTrackRoll *self = BST_TRACK_ROLL (scc);
-
if (hadj)
{
double umin = ticks_to_pixels (self, self->max_ticks); /* lower bound for adj->upper based on max_ticks */
@@ -860,7 +767,6 @@ track_roll_update_adjustments (GxkScrollCanvas *scc,
}
GXK_SCROLL_CANVAS_CLASS (bst_track_roll_parent_class)->update_adjustments (scc, hadj, vadj);
}
-
static void
bst_track_roll_hsetup (BstTrackRoll *self,
guint tpt,
@@ -870,7 +776,6 @@ bst_track_roll_hsetup (BstTrackRoll *self,
guint old_tpt = self->tpt;
guint old_max_ticks = self->max_ticks;
gdouble old_hzoom = self->hzoom;
-
/* here, we setup all things necessary to determine our
* horizontal layout. we have to avoid resizes at
* least if just max_ticks changes, since the tick range
@@ -889,14 +794,12 @@ bst_track_roll_hsetup (BstTrackRoll *self,
gxk_scroll_canvas_update_adjustments (GXK_SCROLL_CANVAS (self), TRUE, FALSE);
}
}
-
gdouble
bst_track_roll_set_hzoom (BstTrackRoll *self,
gdouble hzoom)
{
GxkScrollCanvas *scc = GXK_SCROLL_CANVAS (self);
guint i;
-
hzoom = CLAMP (hzoom, 0.1, 100);
bst_track_roll_hsetup (self, self->tpt, self->max_ticks, hzoom / 50);
/* readjust markers */
@@ -904,7 +807,6 @@ bst_track_roll_set_hzoom (BstTrackRoll *self,
track_roll_allocate_2markers (self, scc->markers + i);
return self->hzoom * 50;
}
-
static void
track_roll_handle_drag (GxkScrollCanvas *scc,
GxkScrollCanvasDrag *scc_drag,
@@ -954,7 +856,6 @@ track_roll_handle_drag (GxkScrollCanvas *scc,
g_signal_emit (self, signal_clicked, 0, drag->button, drag->start_row, drag->start_tick, event);
}
}
-
static gboolean
bst_track_roll_button_press (GtkWidget *widget,
GdkEventButton *event)
@@ -964,29 +865,24 @@ bst_track_roll_button_press (GtkWidget *widget,
bst_track_roll_stop_edit (self);
return GTK_WIDGET_CLASS (bst_track_roll_parent_class)->button_press_event (widget, event);
}
-
void
bst_track_roll_set_track_callback (BstTrackRoll *self,
gpointer data,
BstTrackRollTrackFunc get_track)
{
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
self->proxy_data = data;
self->get_track = get_track;
gtk_widget_queue_draw (GTK_WIDGET (self));
bst_track_roll_queue_row_change (self, 0);
}
-
void
bst_track_roll_queue_row_change (BstTrackRoll *self,
guint row)
{
GxkScrollCanvas *scc;
GdkRectangle rect;
-
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
scc = GXK_SCROLL_CANVAS (self);
gxk_scroll_canvas_get_canvas_size (scc, &rect.width, &rect.height);
rect.x = 0;
@@ -1009,13 +905,11 @@ bst_track_roll_queue_row_change (BstTrackRoll *self,
}
bst_track_roll_hsetup (self, self->tpt, last_tick + 1, self->hzoom);
}
-
void
bst_track_roll_set_prelight_row (BstTrackRoll *self,
guint row)
{
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
if (self->prelight_row != row)
{
gint clear_row = self->prelight_row;
@@ -1024,7 +918,6 @@ bst_track_roll_set_prelight_row (BstTrackRoll *self,
bst_track_roll_queue_row_change (self, self->prelight_row);
}
}
-
static void
bst_track_roll_allocate_ecell (BstTrackRoll *self)
{
@@ -1051,7 +944,6 @@ bst_track_roll_allocate_ecell (BstTrackRoll *self)
gtk_widget_size_allocate (GTK_WIDGET (self->ecell), &allocation);
}
}
-
void
bst_track_roll_start_edit (BstTrackRoll *self,
guint row,
@@ -1060,14 +952,12 @@ bst_track_roll_start_edit (BstTrackRoll *self,
GtkCellEditable *ecell)
{
gint ry, rheight, validrow;
-
g_return_if_fail (BST_IS_TRACK_ROLL (self));
g_return_if_fail (GTK_WIDGET_REALIZED (self));
g_return_if_fail (GTK_IS_CELL_EDITABLE (ecell));
g_return_if_fail (GTK_WIDGET_CAN_FOCUS (ecell));
g_return_if_fail (GTK_WIDGET (ecell)->parent == NULL);
g_return_if_fail (self->ecell == NULL);
-
validrow = row_to_coords (self, row, &ry, &rheight);
if (!validrow)
{
@@ -1087,7 +977,6 @@ bst_track_roll_start_edit (BstTrackRoll *self,
gtk_cell_editable_start_editing (self->ecell, NULL);
gtk_widget_grab_focus (GTK_WIDGET (self->ecell));
}
-
static void
track_roll_stop_edit (BstTrackRoll *self,
gboolean canceled)
@@ -1106,23 +995,18 @@ track_roll_stop_edit (BstTrackRoll *self,
self->ecell = NULL;
}
}
-
void
bst_track_roll_abort_edit (BstTrackRoll *self)
{
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
track_roll_stop_edit (self, TRUE);
}
-
void
bst_track_roll_stop_edit (BstTrackRoll *self)
{
g_return_if_fail (BST_IS_TRACK_ROLL (self));
-
track_roll_stop_edit (self, FALSE);
}
-
void
bst_track_roll_set_marker (BstTrackRoll *self,
guint mark_index,
@@ -1133,7 +1017,6 @@ bst_track_roll_set_marker (BstTrackRoll *self,
GxkScrollMarker *marker;
guint count;
g_return_if_fail (mark_index > 0);
-
marker = gxk_scroll_canvas_lookup_marker (scc, mark_index, &count);
if (!marker && !mtype)
return;
@@ -1152,9 +1035,7 @@ bst_track_roll_set_marker (BstTrackRoll *self,
}
return;
}
-
g_return_if_fail (count == 2);
-
marker[0].coords.x = position;
marker[1].coords.x = position;
if (marker[0].mtype != mtype || !marker[0].pixmap)
@@ -1166,7 +1047,6 @@ bst_track_roll_set_marker (BstTrackRoll *self,
else
track_roll_move_2markers (self, marker);
}
-
static void
bst_track_roll_class_init (BstTrackRollClass *klass)
{
@@ -1180,17 +1060,12 @@ bst_track_roll_class_init (BstTrackRollClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GxkScrollCanvasClass *scroll_canvas_class = GXK_SCROLL_CANVAS_CLASS (klass);
-
gobject_class->finalize = bst_track_roll_finalize;
-
object_class->destroy = bst_track_roll_destroy;
-
widget_class->realize = bst_track_roll_realize;
widget_class->unrealize = bst_track_roll_unrealize;
widget_class->button_press_event = bst_track_roll_button_press;
-
container_class->forall = track_roll_forall;
-
scroll_canvas_class->hscrollable = TRUE;
scroll_canvas_class->vscrollable = TRUE;
scroll_canvas_class->n_colors = CINDEX_COUNT;
@@ -1206,10 +1081,8 @@ bst_track_roll_class_init (BstTrackRollClass *klass)
scroll_canvas_class->handle_drag = track_roll_handle_drag;
scroll_canvas_class->image_tint = gdk_color_from_rgb (0x00ffffff);
scroll_canvas_class->image_saturation = 0;
-
klass->drag = NULL;
klass->clicked = NULL;
-
signal_select_row = g_signal_new ("select-row", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BstTrackRollClass, select_row),
NULL, NULL,
diff --git a/beast-gtk/bsttrackroll.hh b/beast-gtk/bsttrackroll.hh
index b42cf31..9ee0f2c 100644
--- a/beast-gtk/bsttrackroll.hh
+++ b/beast-gtk/bsttrackroll.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_TRACK_ROLL_H__
#define __BST_TRACK_ROLL_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BST_TYPE_TRACK_ROLL (bst_track_roll_get_type ())
#define BST_TRACK_ROLL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_TRACK_ROLL, BstTrackRoll))
@@ -13,15 +10,11 @@ G_BEGIN_DECLS
#define BST_IS_TRACK_ROLL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_TRACK_ROLL))
#define BST_IS_TRACK_ROLL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_TRACK_ROLL))
#define BST_TRACK_ROLL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_TRACK_ROLL, BstTrackRollClass))
-
-
/* --- typedefs & enums --- */
typedef struct _BstTrackRoll BstTrackRoll;
typedef struct _BstTrackRollClass BstTrackRollClass;
typedef SfiProxy (*BstTrackRollTrackFunc) (gpointer proxy_data,
gint row);
-
-
/* --- structures & typedefs --- */
typedef enum /*< skip >*/
{
@@ -46,35 +39,28 @@ typedef struct {
struct _BstTrackRoll
{
GxkScrollCanvas parent_instance;
-
SfiProxy proxy;
GtkTreeView *tree;
guint n_scopes; /* does not always reflect number of rows */
GtkWidget **scopes;
guint scope_update;
-
/* horizontal layout */
guint tpt; /* ticks (parts) per tact */
guint max_ticks;
gdouble hzoom;
guint draw_tact_grid : 1;
-
guint prelight_row;
guint hpanel_height;
-
/* editable popup */
GtkCellEditable *ecell;
guint ecell_row;
guint ecell_tick;
guint ecell_duration;
-
/* size queries */
gint area_offset;
-
/* BseTrack retrieval */
gpointer proxy_data;
BstTrackRollTrackFunc get_track;
-
/* last drag state */
guint start_row;
SfiProxy start_track;
@@ -84,7 +70,6 @@ struct _BstTrackRoll
struct _BstTrackRollClass
{
GxkScrollCanvasClass parent_class;
-
void (*select_row) (BstTrackRoll *troll,
gint row);
void (*drag) (BstTrackRoll *self,
@@ -98,8 +83,6 @@ struct _BstTrackRollClass
gboolean canceled,
GtkCellEditable *ecell);
};
-
-
/* --- prototypes --- */
GType bst_track_roll_get_type (void);
void bst_track_roll_setup (BstTrackRoll *troll,
@@ -127,8 +110,5 @@ void bst_track_roll_set_marker (BstTrackRoll *self,
guint mark_index,
guint position,
BstTrackRollMarkerType mtype);
-
-
G_END_DECLS
-
#endif /* __BST_TRACK_ROLL_H__ */
diff --git a/beast-gtk/bsttrackrollctrl.cc b/beast-gtk/bsttrackrollctrl.cc
index 8d8f147..a521bc7 100644
--- a/beast-gtk/bsttrackrollctrl.cc
+++ b/beast-gtk/bsttrackrollctrl.cc
@@ -1,13 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsttrackrollctrl.hh"
-
#include "bstpartdialog.hh"
-
-
#define QUANTIZATION(self) ((self)->quant_rtools->action_id)
#define HAVE_OBJECT (1 << 31)
-
-
/* --- prototypes --- */
static void controller_drag (BstTrackRollController *self,
BstTrackRollDrag *drag);
@@ -18,8 +13,6 @@ static void controller_update_hpanel_cursor (BstTrackRollController *self,
static void controller_stop_edit (BstTrackRollController *self,
gboolean canceled,
GtkCellEditable *ecell);
-
-
/* --- functions --- */
GxkActionList*
bst_track_roll_controller_canvas_actions (BstTrackRollController *self)
@@ -39,7 +32,6 @@ bst_track_roll_controller_canvas_actions (BstTrackRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
GxkActionList*
bst_track_roll_controller_hpanel_actions (BstTrackRollController *self)
{
@@ -56,7 +48,6 @@ bst_track_roll_controller_hpanel_actions (BstTrackRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
GxkActionList*
bst_track_roll_controller_quant_actions (BstTrackRollController *self)
{
@@ -87,26 +78,21 @@ bst_track_roll_controller_quant_actions (BstTrackRollController *self)
NULL /*i18n_domain*/, NULL /*acheck*/, NULL /*aexec*/, NULL);
return alist;
}
-
static void
controller_reset_canvas_cursor (BstTrackRollController *self)
{
controller_update_canvas_cursor (self, self->canvas_rtools->action_id);
}
-
static void
controller_reset_hpanel_cursor (BstTrackRollController *self)
{
controller_update_hpanel_cursor (self, self->hpanel_rtools->action_id);
}
-
BstTrackRollController*
bst_track_roll_controller_new (BstTrackRoll *troll)
{
BstTrackRollController *self;
-
g_return_val_if_fail (BST_IS_TRACK_ROLL (troll), NULL);
-
self = g_new0 (BstTrackRollController, 1);
self->troll = troll;
self->ref_count = 1;
@@ -137,10 +123,8 @@ bst_track_roll_controller_new (BstTrackRoll *troll)
/* register quantization tools */
self->quant_rtools = gxk_action_group_new ();
gxk_action_group_select (self->quant_rtools, BST_QUANTIZE_TACT);
-
return self;
}
-
static BstCommonRollTool
hpanel_button_tool (BstTrackRollController *self,
guint button)
@@ -171,7 +155,6 @@ hpanel_button_tool (BstTrackRollController *self,
}
return BST_COMMON_ROLL_TOOL_NONE;
}
-
static BstCommonRollTool
canvas_button_tool (BstTrackRollController *self,
guint button,
@@ -254,24 +237,19 @@ canvas_button_tool (BstTrackRollController *self,
}
return BST_COMMON_ROLL_TOOL_NONE;
}
-
BstTrackRollController*
bst_track_roll_controller_ref (BstTrackRollController *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count >= 1, NULL);
-
self->ref_count++;
-
return self;
}
-
void
bst_track_roll_controller_unref (BstTrackRollController *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count >= 1);
-
self->ref_count--;
if (!self->ref_count)
{
@@ -284,29 +262,24 @@ bst_track_roll_controller_unref (BstTrackRollController *self)
g_free (self);
}
}
-
void
bst_track_roll_controller_set_song (BstTrackRollController *self,
SfiProxy song)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count >= 1);
-
if (BSE_IS_SONG (song))
self->song = song;
else
self->song = 0;
}
-
guint
bst_track_roll_controller_quantize (BstTrackRollController *self,
guint fine_tick)
{
BseSongTiming *timing;
guint quant, tick, qtick;
-
g_return_val_if_fail (self != NULL, fine_tick);
-
timing = bse_song_get_timing (self->song, fine_tick);
if (QUANTIZATION (self) == BST_QUANTIZE_NONE)
quant = 1;
@@ -322,7 +295,6 @@ bst_track_roll_controller_quantize (BstTrackRollController *self,
tick = timing->tick + qtick;
return tick;
}
-
static void
controller_update_hpanel_cursor (BstTrackRollController *self,
guint tool_id)
@@ -344,7 +316,6 @@ controller_update_hpanel_cursor (BstTrackRollController *self,
break;
}
}
-
static void
controller_update_canvas_cursor (BstTrackRollController *self,
guint tool_id)
@@ -375,7 +346,6 @@ controller_update_canvas_cursor (BstTrackRollController *self,
break;
}
}
-
static void
edit_name_start (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -400,7 +370,6 @@ edit_name_start (BstTrackRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Edit Part"), _("No Part"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
controller_stop_edit (BstTrackRollController *self,
gboolean canceled,
@@ -413,7 +382,6 @@ controller_stop_edit (BstTrackRollController *self,
}
controller_reset_canvas_cursor (self);
}
-
static void
insert_start (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -446,7 +414,6 @@ insert_start (BstTrackRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
delete_start (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -464,7 +431,6 @@ delete_start (BstTrackRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Delete Part"), _("No target"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
move_link_start (BstTrackRollController *self,
BstTrackRollDrag *drag,
@@ -485,28 +451,24 @@ move_link_start (BstTrackRollController *self,
drag->state = GXK_DRAG_HANDLED;
}
}
-
static void
move_start (BstTrackRollController *self,
BstTrackRollDrag *drag)
{
move_link_start (self, drag, FALSE);
}
-
static void
link_start (BstTrackRollController *self,
BstTrackRollDrag *drag)
{
move_link_start (self, drag, TRUE);
}
-
static void
move_motion (BstTrackRollController *self,
BstTrackRollDrag *drag)
{
const gchar *action = self->skip_deletion ? _("Link Part") : _("Move Part");
gint new_tick;
-
new_tick = MAX (drag->current_tick, self->xoffset) - self->xoffset;
new_tick = bst_track_roll_controller_quantize (self, new_tick);
// track_changed = self->obj_track != drag->current_track;
@@ -530,14 +492,12 @@ move_motion (BstTrackRollController *self,
bse_item_ungroup_undo (drag->current_track);
}
}
-
static void
move_abort (BstTrackRollController *self,
BstTrackRollDrag *drag)
{
gxk_status_set (GXK_STATUS_ERROR, _("Move Part"), _("Lost Part"));
}
-
static void
editor_create (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -555,7 +515,6 @@ editor_create (BstTrackRollController *self,
gxk_status_set (GXK_STATUS_ERROR, _("Start Editor"), _("No target"));
drag->state = GXK_DRAG_HANDLED;
}
-
static void
pointer_move (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -568,7 +527,6 @@ pointer_move (BstTrackRollController *self,
drag->state = GXK_DRAG_CONTINUE;
}
}
-
static void
tick_left_move (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -580,7 +538,6 @@ tick_left_move (BstTrackRollController *self,
drag->state = GXK_DRAG_CONTINUE;
}
}
-
static void
tick_right_move (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -592,7 +549,6 @@ tick_right_move (BstTrackRollController *self,
drag->state = GXK_DRAG_CONTINUE;
}
}
-
typedef void (*DragFunc) (BstTrackRollController *,
BstTrackRollDrag *);
struct _BstTrackRollUtil
@@ -600,7 +556,6 @@ struct _BstTrackRollUtil
BstCommonRollTool tool;
DragFunc start, motion, abort;
};
-
void
controller_drag (BstTrackRollController *self,
BstTrackRollDrag *drag)
@@ -618,7 +573,6 @@ controller_drag (BstTrackRollController *self,
{ BST_COMMON_ROLL_TOOL_MOVE_TICK_LEFT, tick_left_move, tick_left_move, NULL, },
{ BST_COMMON_ROLL_TOOL_MOVE_TICK_RIGHT, tick_right_move, tick_right_move, NULL, },
};
-
/* initial drag handling */
if (drag->type == GXK_DRAG_START)
{
@@ -627,9 +581,7 @@ controller_drag (BstTrackRollController *self,
const BstTrackRollUtil *tool_table;
guint i, n_tools;
BseTrackPartSeq *tps;
-
self->current_tool = NULL; /* paranoid */
-
/* figure area specific tool */
if (drag->canvas_drag)
{
@@ -647,7 +599,6 @@ controller_drag (BstTrackRollController *self,
}
else /* unsupported area */
return;
-
/* setup drag data */
if (!drag->start_valid)
drag->start_track = 0;
@@ -669,7 +620,6 @@ controller_drag (BstTrackRollController *self,
self->obj_duration = tpart ? tpart->duration : 0;
self->xoffset = 0;
self->tick_bound = 0;
-
/* find drag tool */
if (self->obj_part) /* have object */
tool = obj_tool;
@@ -682,7 +632,6 @@ controller_drag (BstTrackRollController *self,
}
if (!self->current_tool)
return;
-
/* generic drag handling */
switch (drag->type)
{
diff --git a/beast-gtk/bsttrackrollctrl.hh b/beast-gtk/bsttrackrollctrl.hh
index dd28aa7..989eeb8 100644
--- a/beast-gtk/bsttrackrollctrl.hh
+++ b/beast-gtk/bsttrackrollctrl.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_TRACK_ROLL_CONTROLLER_H__
#define __BST_TRACK_ROLL_CONTROLLER_H__
-
-
#include "bsttrackroll.hh"
-
G_BEGIN_DECLS
-
typedef struct _BstTrackRollUtil BstTrackRollUtil;
typedef struct {
/* misc data */
@@ -27,8 +23,6 @@ typedef struct {
GxkActionGroup *hpanel_rtools;
GxkActionGroup *quant_rtools;
} BstTrackRollController;
-
-
/* --- API --- */
BstTrackRollController* bst_track_roll_controller_new (BstTrackRoll *troll);
BstTrackRollController* bst_track_roll_controller_ref (BstTrackRollController *self);
@@ -42,8 +36,5 @@ guint bst_track_roll_controller_quantize (BstTrackRollController *self,
GxkActionList* bst_track_roll_controller_canvas_actions (BstTrackRollController *self);
GxkActionList* bst_track_roll_controller_hpanel_actions (BstTrackRollController *self);
GxkActionList* bst_track_roll_controller_quant_actions (BstTrackRollController *self);
-
-
G_END_DECLS
-
#endif /* __BST_TRACK_ROLL_CONTROLLER_H__ */
diff --git a/beast-gtk/bsttracksynthdialog.cc b/beast-gtk/bsttracksynthdialog.cc
index 29a3be3..0279227 100644
--- a/beast-gtk/bsttracksynthdialog.cc
+++ b/beast-gtk/bsttracksynthdialog.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsttracksynthdialog.hh"
#include "bsttreestores.hh"
-
-
/* --- prototypes --- */
static void bst_track_synth_dialog_finalize (GObject *object);
static void bst_track_synth_dialog_activate (BstTrackSynthDialog *self);
@@ -12,29 +10,22 @@ static void bst_track_synth_dialog_setup (BstTrackSynthDialog *self,
gpointer parent_widget,
const gchar *title,
SfiProxy proxy);
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstTrackSynthDialog, bst_track_synth_dialog, GXK_TYPE_DIALOG);
-
static void
bst_track_synth_dialog_class_init (BstTrackSynthDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->finalize = bst_track_synth_dialog_finalize;
-
widget_class->delete_event = bst_track_synth_dialog_delete_event;
}
-
static void
bst_track_synth_dialog_init (BstTrackSynthDialog *self)
{
GtkTreeSelection *tsel;
GtkTreeModel *smodel;
GtkWidget *main_box = GXK_DIALOG (self)->vbox;
-
/* configure self */
g_object_set (self,
"flags", (GXK_DIALOG_HIDE_ON_DELETE |
@@ -43,7 +34,6 @@ bst_track_synth_dialog_init (BstTrackSynthDialog *self)
GXK_DIALOG_MODAL),
NULL);
gxk_dialog_set_sizes (GXK_DIALOG (self), 550, 300, 600, 320);
-
/* notebook */
self->notebook = (GtkNotebook*) g_object_new (GXK_TYPE_NOTEBOOK,
"visible", TRUE,
@@ -58,7 +48,6 @@ bst_track_synth_dialog_init (BstTrackSynthDialog *self)
"parent", main_box,
"enable_popup", FALSE,
NULL);
-
/* synth list */
self->spage = (GtkWidget*) g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
@@ -68,7 +57,6 @@ bst_track_synth_dialog_init (BstTrackSynthDialog *self)
"shadow_type", GTK_SHADOW_IN,
NULL);
gxk_notebook_append (self->notebook, self->spage, "synth", TRUE);
-
/* synth selection store and tree */
self->pstore = bst_item_seq_store_new (TRUE);
smodel = gtk_tree_model_sort_new_with_model (self->pstore);
@@ -84,7 +72,6 @@ bst_track_synth_dialog_init (BstTrackSynthDialog *self)
tsel = gtk_tree_view_get_selection (self->tview);
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_BROWSE);
gxk_tree_selection_force_browse (tsel, smodel);
-
/* synth selection tree columns */
if (BST_DVL_HINTS)
gxk_tree_view_add_text_column (self->tview, BST_PROXY_STORE_SEQID, "S",
@@ -100,33 +87,26 @@ bst_track_synth_dialog_init (BstTrackSynthDialog *self)
gxk_tree_view_add_text_column (self->tview, BST_PROXY_STORE_TYPE, "",
0.0, "Type", NULL,
NULL, NULL, G_CONNECT_SWAPPED);
-
/* wave repo view */
self->wpage = (GtkWidget*) g_object_new (BST_TYPE_WAVE_VIEW, "visible", TRUE, NULL);
gxk_notebook_append (self->notebook, self->wpage, "wave", TRUE);
bst_wave_view_set_editable (BST_WAVE_VIEW (self->wpage), FALSE);
-
/* provide buttons */
self->ok = gxk_dialog_default_action_swapped (GXK_DIALOG (self), BST_STOCK_OK, (void*) bst_track_synth_dialog_activate, self);
gxk_dialog_action (GXK_DIALOG (self), BST_STOCK_CANCEL, (void*) gxk_toplevel_delete, (GtkWidget*) self);
-
/* make row connections */
g_signal_connect_object (self->tview, "row_activated", G_CALLBACK (gtk_button_clicked), self->ok, G_CONNECT_SWAPPED);
g_signal_connect_object (BST_ITEM_VIEW (self->wpage)->tree, "row_activated",
G_CALLBACK (gtk_button_clicked), self->ok, G_CONNECT_SWAPPED);
}
-
static void
bst_track_synth_dialog_finalize (GObject *object)
{
BstTrackSynthDialog *self = BST_TRACK_SYNTH_DIALOG (object);
-
bst_track_synth_dialog_setup (self, NULL, NULL, 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (bst_track_synth_dialog_parent_class)->finalize (object);
}
-
static gboolean
bst_track_synth_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event)
@@ -142,7 +122,6 @@ bst_track_synth_dialog_delete_event (GtkWidget *widget,
/* chain parent class' handler */
return GTK_WIDGET_CLASS (bst_track_synth_dialog_parent_class)->delete_event (widget, event);
}
-
static void
parent_window_destroyed (BstTrackSynthDialog *self)
{
@@ -155,7 +134,6 @@ parent_window_destroyed (BstTrackSynthDialog *self)
bst_track_synth_dialog_setup (self, NULL, NULL, 0);
gxk_toplevel_delete (GTK_WIDGET (self));
}
-
static void
bst_track_synth_dialog_setup (BstTrackSynthDialog *self,
gpointer parent_widget,
@@ -163,30 +141,23 @@ bst_track_synth_dialog_setup (BstTrackSynthDialog *self,
SfiProxy proxy)
{
GtkWindow *window = GTK_WINDOW (self);
-
g_return_if_fail (BST_IS_TRACK_SYNTH_DIALOG (self));
-
self->selected_callback = NULL;
GxkFreeFunc selected_cleanup = self->selected_cleanup;
self->selected_callback = NULL;
self->selected_cleanup = NULL;
if (selected_cleanup)
selected_cleanup (self->selected_data);
-
gtk_widget_hide (GTK_WIDGET (self));
-
/* reset proxy handling */
bst_window_sync_title_to_proxy (self, proxy, title);
-
/* cleanup connections to old parent_window */
if (self->parent_window)
g_signal_handlers_disconnect_by_func (self->parent_window, (void*) parent_window_destroyed, self);
if (window->group)
gtk_window_group_remove_window (window->group, window);
gtk_window_set_transient_for (window, NULL);
-
self->parent_window = parent_widget ? (GtkWindow*) gtk_widget_get_ancestor ((GtkWidget*) parent_widget, GTK_TYPE_WINDOW) : NULL;
-
/* setup connections to new parent_window */
if (self->parent_window)
{
@@ -197,12 +168,10 @@ bst_track_synth_dialog_setup (BstTrackSynthDialog *self,
G_CALLBACK (parent_window_destroyed),
self, G_CONNECT_SWAPPED);
}
-
/* allow activation */
self->ignore_activate = FALSE;
gxk_notebook_set_current_page_widget (self->notebook, self->spage);
}
-
static BstTrackSynthDialog*
bst_track_synth_dialog_singleton (void)
{
@@ -211,7 +180,6 @@ bst_track_synth_dialog_singleton (void)
ts_singleton = (BstTrackSynthDialog*) g_object_new (BST_TYPE_TRACK_SYNTH_DIALOG, NULL);
return ts_singleton;
}
-
GtkWidget*
bst_track_synth_dialog_popup (gpointer parent_widget,
SfiProxy track,
@@ -231,49 +199,39 @@ bst_track_synth_dialog_popup (gpointer parent_widget,
candidate_label = "";
if (!wrepo_label)
wrepo_label = "";
-
bst_track_synth_dialog_setup (self, NULL, NULL, 0);
-
g_object_set (gtk_notebook_get_tab_label (self->notebook, self->spage), "label", candidate_label, NULL);
gxk_widget_set_tooltip (self->tview, candidate_tooltip);
g_object_set (gtk_notebook_get_tab_label (self->notebook, self->wpage), "label", wrepo_label, NULL);
gxk_widget_set_tooltip (BST_ITEM_VIEW (self->wpage)->tree, wrepo_tooltip);
-
bst_track_synth_dialog_set (self, candidates, wrepo);
bst_track_synth_dialog_setup (self, parent_widget,
/* TRANSLATORS: this is a dialog title and %s is replaced by an object name */
_("Synthesizer Selection: %s"),
track);
-
self->selected_callback = selected_callback;
self->selected_data = selected_data;
self->selected_cleanup = selected_cleanup;
gxk_widget_showraise (widget);
-
return widget;
}
-
void
bst_track_synth_dialog_set (BstTrackSynthDialog *self,
BseItemSeq *iseq,
SfiProxy wrepo)
{
g_return_if_fail (BST_IS_TRACK_SYNTH_DIALOG (self));
-
bst_item_view_set_container (BST_ITEM_VIEW (self->wpage), wrepo);
bst_item_seq_store_set (self->pstore, iseq);
g_object_set (self->wpage, "visible", wrepo != 0, NULL);
g_object_set (self->spage, "visible", iseq != NULL, NULL);
}
-
static void
bst_track_synth_dialog_activate (BstTrackSynthDialog *self)
{
SfiProxy proxy = 0;
-
if (self->ignore_activate)
return;
-
if (self->tview && gxk_widget_viewable (GTK_WIDGET (self->tview)))
{
GtkTreeIter siter;
@@ -290,7 +248,6 @@ bst_track_synth_dialog_activate (BstTrackSynthDialog *self)
}
else if (self->wpage)
proxy = bst_item_view_get_current (BST_ITEM_VIEW (self->wpage));
-
/* ignore_activate guards against multiple clicks */
self->ignore_activate = TRUE;
/* notify and done */
diff --git a/beast-gtk/bsttracksynthdialog.hh b/beast-gtk/bsttracksynthdialog.hh
index df50a4f..031ec02 100644
--- a/beast-gtk/bsttracksynthdialog.hh
+++ b/beast-gtk/bsttracksynthdialog.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_TRACK_SYNTH_DIALOG_H__
#define __BST_TRACK_SYNTH_DIALOG_H__
-
#include "bstutils.hh"
#include "bstwaveview.hh"
-
G_BEGIN_DECLS
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_TRACK_SYNTH_DIALOG (bst_track_synth_dialog_get_type ())
#define BST_TRACK_SYNTH_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_TRACK_SYNTH_DIALOG, BstTrackSynthDialog))
@@ -15,8 +11,6 @@ G_BEGIN_DECLS
#define BST_IS_TRACK_SYNTH_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_TRACK_SYNTH_DIALOG))
#define BST_IS_TRACK_SYNTH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_TRACK_SYNTH_DIALOG))
#define BST_TRACK_SYNTH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_TRACK_SYNTH_DIALOG, BstTrackSynthDialogClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstTrackSynthDialog BstTrackSynthDialog;
typedef struct _BstTrackSynthDialogClass BstTrackSynthDialogClass;
@@ -42,8 +36,6 @@ struct _BstTrackSynthDialogClass
{
GxkDialogClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_track_synth_dialog_get_type (void);
GtkWidget* bst_track_synth_dialog_popup (gpointer parent_widget,
@@ -60,9 +52,5 @@ GtkWidget* bst_track_synth_dialog_popup (gpointer parent_
void bst_track_synth_dialog_set (BstTrackSynthDialog *self,
BseItemSeq *iseq,
SfiProxy wrepo);
-
-
-
G_END_DECLS
-
#endif /* __BST_TRACK_SYNTH_DIALOG_H__ */
diff --git a/beast-gtk/bsttrackview.cc b/beast-gtk/bsttrackview.cc
index b699fc8..40ac496 100644
--- a/beast-gtk/bsttrackview.cc
+++ b/beast-gtk/bsttrackview.cc
@@ -6,9 +6,7 @@
#include "bstitemseqdialog.hh"
#include <stdlib.h> /* strtol */
#include <string.h>
-
#define SCROLLBAR_SPACING (3) /* from gtkscrolledwindow.c:DEFAULT_SCROLLBAR_SPACING */
-
/* --- prototypes --- */
static void bst_track_view_finalize (GObject *object);
static gboolean track_view_action_check (gpointer data,
@@ -22,8 +20,6 @@ static void track_view_listen_on (BstItemView *iview,
SfiProxy item);
static void track_view_unlisten_on (BstItemView *iview,
SfiProxy item);
-
-
/* --- columns --- */
enum {
COL_SEQID,
@@ -37,8 +33,6 @@ enum {
COL_BLURB,
N_COLS
};
-
-
/* --- track actions --- */
enum {
ACTION_ADD_TRACK,
@@ -52,50 +46,36 @@ static const GxkStockAction track_view_actions[] = {
ACTION_DELETE_TRACK, BST_STOCK_TRASHCAN,
},
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstTrackView, bst_track_view, BST_TYPE_ITEM_VIEW);
-
static void
bst_track_view_class_init (BstTrackViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (klass);
-
gobject_class->finalize = bst_track_view_finalize;
-
item_view_class->set_container = track_view_set_container;
item_view_class->listen_on = track_view_listen_on;
item_view_class->unlisten_on = track_view_unlisten_on;
-
item_view_class->item_type = "BseTrack";
}
-
static void
bst_track_view_finalize (GObject *object)
{
BstTrackView *self = BST_TRACK_VIEW (object);
-
if (self->tctrl)
bst_track_roll_controller_unref (self->tctrl);
-
G_OBJECT_CLASS (bst_track_view_parent_class)->finalize (object);
}
-
GtkWidget*
bst_track_view_new (SfiProxy song)
{
GtkWidget *track_view;
-
g_return_val_if_fail (BSE_IS_SONG (song), NULL);
-
track_view = gtk_widget_new (BST_TYPE_TRACK_VIEW, NULL);
bst_item_view_set_container (BST_ITEM_VIEW (track_view), song);
-
return track_view;
}
-
static void
track_view_hzoom_changed (BstTrackView *self,
GtkAdjustment *adjustment)
@@ -103,7 +83,6 @@ track_view_hzoom_changed (BstTrackView *self,
if (self->troll)
bst_track_roll_set_hzoom (self->troll, adjustment->value);
}
-
static void
track_view_fill_value (BstItemView *iview,
guint column,
@@ -168,14 +147,12 @@ track_view_fill_value (BstItemView *iview,
break;
}
}
-
static void
track_view_synth_edited (BstTrackView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -203,14 +180,12 @@ track_view_synth_edited (BstTrackView *self,
bse_proxy_set (item, "snet", 0, "wave", 0, NULL);
}
}
-
static void
track_view_post_synth_edited (BstTrackView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -234,12 +209,10 @@ track_view_post_synth_edited (BstTrackView *self,
bse_proxy_set (item, "pnet", 0, NULL);
}
}
-
typedef struct {
BstTrackView *self;
GxkCellRendererPopup *pcell;
} SynthPopup;
-
static void
track_view_synth_popup_cleanup (gpointer data)
{
@@ -247,7 +220,6 @@ track_view_synth_popup_cleanup (gpointer data)
gxk_cell_renderer_popup_change (sdata->pcell, NULL, FALSE, TRUE);
g_free (sdata);
}
-
static void
track_view_synth_popup_cb (gpointer data,
SfiProxy proxy,
@@ -259,7 +231,6 @@ track_view_synth_popup_cb (gpointer data,
FALSE,
proxy == 0);
}
-
static void
track_view_synth_popup (BstTrackView *self,
const gchar *strpath,
@@ -267,7 +238,6 @@ track_view_synth_popup (BstTrackView *self,
GxkCellRendererPopup *pcell)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -288,7 +258,6 @@ track_view_synth_popup (BstTrackView *self,
bst_gui_error_bell (self);
}
}
-
static void
track_view_post_synth_popup (BstTrackView *self,
const gchar *strpath,
@@ -296,7 +265,6 @@ track_view_post_synth_popup (BstTrackView *self,
GxkCellRendererPopup *pcell)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -315,13 +283,11 @@ track_view_post_synth_popup (BstTrackView *self,
bst_gui_error_bell (self);
}
}
-
typedef struct {
BstTrackView *self;
GxkCellRendererPopup *pcell;
SfiProxy item;
} OutputsPopup;
-
static void
track_view_outputs_cleanup (gpointer data)
{
@@ -329,7 +295,6 @@ track_view_outputs_cleanup (gpointer data)
gxk_cell_renderer_popup_change (odata->pcell, NULL, FALSE, FALSE);
g_free (odata);
}
-
static void
track_view_outputs_changed (gpointer data,
BseItemSeq *iseq,
@@ -343,7 +308,6 @@ track_view_outputs_changed (gpointer data,
bse_proxy_set_property (odata->item, "outputs", value);
sfi_value_free (value);
}
-
static void
track_view_outputs_popup (BstTrackView *self,
const gchar *strpath,
@@ -351,7 +315,6 @@ track_view_outputs_popup (BstTrackView *self,
GxkCellRendererPopup *pcell)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -370,14 +333,12 @@ track_view_outputs_popup (BstTrackView *self,
gxk_cell_renderer_popup_dialog (pcell, dialog);
}
}
-
static void
track_view_mute_toggled (BstTrackView *self,
const gchar *strpath,
GtkCellRendererToggle *tcell)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -392,14 +353,12 @@ track_view_mute_toggled (BstTrackView *self,
}
}
}
-
static void
track_view_voice_edited (BstTrackView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -412,14 +371,12 @@ track_view_voice_edited (BstTrackView *self,
}
}
}
-
static void
track_view_midi_channel_edited (BstTrackView *self,
const gchar *strpath,
const gchar *text)
{
g_return_if_fail (BST_IS_TRACK_VIEW (self));
-
if (strpath)
{
gint row = gxk_tree_spath_index0 (strpath);
@@ -432,14 +389,12 @@ track_view_midi_channel_edited (BstTrackView *self,
}
}
}
-
static SfiProxy
get_track (gpointer data,
gint row)
{
return bst_item_view_get_proxy (BST_ITEM_VIEW (data), row);
}
-
static void
track_view_marks_changed (BstTrackView *self)
{
@@ -453,7 +408,6 @@ track_view_marks_changed (BstTrackView *self)
bst_track_roll_set_marker (self->troll, 3, pointer, pointer >= 0 ? BST_TRACK_ROLL_MARKER_POS : BST_TRACK_ROLL_MARKER_NONE);
}
}
-
static void
track_view_repeat_toggled (BstTrackView *self)
{
@@ -461,7 +415,6 @@ track_view_repeat_toggled (BstTrackView *self)
if (song && self->repeat_toggle)
bse_proxy_set (song, "loop_enabled", GTK_TOGGLE_BUTTON (self->repeat_toggle)->active, NULL);
}
-
static void
track_view_repeat_changed (BstTrackView *self)
{
@@ -475,7 +428,6 @@ track_view_repeat_changed (BstTrackView *self)
gtk_toggle_button_set_active (toggle, enabled);
}
}
-
static void
bst_track_view_init (BstTrackView *self)
{
@@ -487,13 +439,11 @@ bst_track_view_init (BstTrackView *self)
GtkTreeModel *smodel;
GxkListWrapper *lwrapper;
GxkRadget *radget;
-
/* create GUI */
gxk_widget_publish_actions (self, "track-view-actions",
G_N_ELEMENTS (track_view_actions), track_view_actions,
NULL, track_view_action_check, track_view_action_exec);
radget = gxk_radget_complete (GTK_WIDGET (self), "beast", "track-view", NULL);
-
/* item list model */
lwrapper = gxk_list_wrapper_new (N_COLS,
G_TYPE_STRING, /* COL_SEQID */
@@ -511,12 +461,10 @@ bst_track_view_init (BstTrackView *self)
G_CALLBACK (track_view_fill_value),
iview, G_CONNECT_SWAPPED);
g_object_unref (lwrapper);
-
/* scrollbars */
treehs = (GtkWidget*) gxk_radget_find (radget, "tree-hscrollbar");
trackgb = (GtkWidget*) gxk_radget_find (radget, "track-hgrow-bar");
vscroll = (GtkWidget*) gxk_radget_find (radget, "tree-vscrollbar");
-
/* tree view (track list) */
tview = (GtkTreeView*) gxk_radget_find (radget, "tree-view");
gtk_tree_view_set_model (tview, smodel);
@@ -527,7 +475,6 @@ bst_track_view_init (BstTrackView *self)
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_BROWSE);
gxk_tree_selection_force_browse (tsel, smodel);
g_object_unref (smodel);
-
/* track roll */
self->troll = (BstTrackRoll*) g_object_new (BST_TYPE_TRACK_ROLL,
"visible", TRUE,
@@ -538,7 +485,6 @@ bst_track_view_init (BstTrackView *self)
gxk_scroll_canvas_set_vadjustment (GXK_SCROLL_CANVAS (self->troll), gtk_range_get_adjustment (GTK_RANGE (vscroll)));
bst_track_roll_set_track_callback (self->troll, self, get_track);
track_view_marks_changed (self);
-
/* link track roll to tree view and list model */
g_signal_connect_object (tsel, "changed",
G_CALLBACK (bst_track_roll_reselect),
@@ -552,20 +498,17 @@ bst_track_view_init (BstTrackView *self)
g_signal_connect_object (iview->wlist, "row-change",
G_CALLBACK (bst_track_roll_abort_edit),
self->troll, G_CONNECT_SWAPPED);
-
/* track roll controller */
self->tctrl = bst_track_roll_controller_new (self->troll);
bst_track_roll_controller_set_song (self->tctrl, iview->container);
gxk_widget_publish_action_list (self, "tctrl-canvas-tools", bst_track_roll_controller_canvas_actions (self->tctrl));
gxk_widget_publish_action_list (self, "tctrl-hpanel-tools", bst_track_roll_controller_hpanel_actions (self->tctrl));
gxk_widget_publish_action_list (self, "tctrl-quant-tools", bst_track_roll_controller_quant_actions (self->tctrl));
-
/* add repeat toggle */
self->repeat_toggle = (GtkWidget*) gxk_radget_find (radget, "repeat-toggle");
gxk_nullify_in_object (self, &self->repeat_toggle);
g_object_connect (self->repeat_toggle, "swapped_signal::toggled", track_view_repeat_toggled, self, NULL);
track_view_repeat_changed (self);
-
/* add zoom spinner */
adjustment = gtk_adjustment_new (50, 1, 100, 1, 5, 0);
g_object_connect (adjustment,
@@ -578,7 +521,6 @@ bst_track_view_init (BstTrackView *self)
"digits", 0,
"width_request", 2 * gxk_size_width (GXK_ICON_SIZE_TOOLBAR),
NULL));
-
/* add list view columns */
if (BST_DVL_HINTS)
gxk_tree_view_add_text_column (iview->tree, COL_SEQID, "S",
@@ -609,7 +551,6 @@ bst_track_view_init (BstTrackView *self)
0.0, _("Comment"), NULL,
(void*) bst_item_view_blurb_edited, self, G_CONNECT_SWAPPED);
}
-
static void
track_changed (SfiProxy track,
BstTrackView *self)
@@ -620,7 +561,6 @@ track_changed (SfiProxy track,
bst_track_roll_queue_row_change (self->troll, row);
}
}
-
static void
track_view_pointer_changed (BstTrackView *self,
SfiInt position)
@@ -628,7 +568,6 @@ track_view_pointer_changed (BstTrackView *self,
if (self->troll)
bst_track_roll_set_marker (self->troll, 3, position, position >= 0 ? BST_TRACK_ROLL_MARKER_POS : BST_TRACK_ROLL_MARKER_NONE);
}
-
static void
track_view_set_container (BstItemView *iview,
SfiProxy new_container)
@@ -657,7 +596,6 @@ track_view_set_container (BstItemView *iview,
track_view_repeat_changed (self);
}
}
-
static void
track_property_changed (SfiProxy item,
const gchar *property_name,
@@ -665,7 +603,6 @@ track_property_changed (SfiProxy item,
{
bst_item_view_refresh (iview, item);
}
-
static void
track_view_listen_on (BstItemView *iview,
SfiProxy item)
@@ -686,7 +623,6 @@ track_view_listen_on (BstItemView *iview,
/* COL_BLURB handled by GxkListWrapper */
NULL);
}
-
static void
track_view_unlisten_on (BstItemView *iview,
SfiProxy item)
@@ -697,7 +633,6 @@ track_view_unlisten_on (BstItemView *iview,
NULL);
BST_ITEM_VIEW_CLASS (bst_track_view_parent_class)->unlisten_on (iview, item);
}
-
static void
track_view_action_exec (gpointer data,
gulong action)
@@ -705,7 +640,6 @@ track_view_action_exec (gpointer data,
BstTrackView *self = BST_TRACK_VIEW (data);
BstItemView *item_view = BST_ITEM_VIEW (self);
SfiProxy song = item_view->container;
-
switch (action)
{
SfiProxy item;
@@ -736,7 +670,6 @@ track_view_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
track_view_action_check (gpointer data,
gulong action,
@@ -744,7 +677,6 @@ track_view_action_check (gpointer data,
{
BstTrackView *self = BST_TRACK_VIEW (data);
BstItemView *item_view = BST_ITEM_VIEW (self);
-
switch (action)
{
SfiProxy item;
diff --git a/beast-gtk/bsttrackview.hh b/beast-gtk/bsttrackview.hh
index 8bcf952..f8c629d 100644
--- a/beast-gtk/bsttrackview.hh
+++ b/beast-gtk/bsttrackview.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_TRACK_VIEW_H__
#define __BST_TRACK_VIEW_H__
-
#include "bstitemview.hh"
#include "bsttrackroll.hh"
#include "bsttrackrollctrl.hh"
-
G_BEGIN_DECLS
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_TRACK_VIEW (bst_track_view_get_type ())
#define BST_TRACK_VIEW(object) (GTK_CHECK_CAST ((object), BST_TYPE_TRACK_VIEW, BstTrackView))
@@ -15,8 +12,6 @@ G_BEGIN_DECLS
#define BST_IS_TRACK_VIEW(object) (GTK_CHECK_TYPE ((object), BST_TYPE_TRACK_VIEW))
#define BST_IS_TRACK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_TRACK_VIEW))
#define BST_TRACK_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_TRACK_VIEW, BstTrackViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstTrackView BstTrackView;
typedef struct _BstTrackViewClass BstTrackViewClass;
@@ -31,14 +26,8 @@ struct _BstTrackViewClass
{
BstItemViewClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_track_view_get_type (void);
GtkWidget* bst_track_view_new (SfiProxy song);
-
-
-
G_END_DECLS
-
#endif /* __BST_TRACK_VIEW_H__ */
diff --git a/beast-gtk/bsttreestores.cc b/beast-gtk/bsttreestores.cc
index 23b29a7..224a3b7 100644
--- a/beast-gtk/bsttreestores.cc
+++ b/beast-gtk/bsttreestores.cc
@@ -2,9 +2,7 @@
#include "bsttreestores.hh"
#include "topconfig.h"
#include <string.h>
-
typedef void (*ListenerFunc) (GtkTreeModel *model, SfiProxy item, gboolean added);
-
/* --- functions --- */
static gboolean
file_store_idle_handler (gpointer data)
@@ -119,7 +117,6 @@ file_store_idle_handler (gpointer data)
GDK_THREADS_LEAVE ();
return busy;
}
-
GtkTreeModel*
bst_file_store_create (void)
{
@@ -136,7 +133,6 @@ bst_file_store_create (void)
-1);
return (GtkTreeModel*) sample_store;
}
-
void
bst_file_store_update_list (GtkTreeModel *model,
const gchar *search_path,
@@ -145,9 +141,7 @@ bst_file_store_update_list (GtkTreeModel *model,
GtkTreeStore *store = GTK_TREE_STORE (model);
SfiFileCrawler *crawler = sfi_file_crawler_new ();
glong l;
-
g_return_if_fail (search_path != NULL);
-
sfi_file_crawler_add_search_path (crawler, search_path, filter);
g_object_set_data_full ((GObject*) store, "file-crawler", crawler, (GDestroyNotify) sfi_file_crawler_destroy);
l = g_timeout_add_full (G_PRIORITY_LOW + 100, 0,
@@ -155,7 +149,6 @@ bst_file_store_update_list (GtkTreeModel *model,
store, NULL);
g_object_set_long (store, "timer", l);
}
-
void
bst_file_store_forget_list (GtkTreeModel *model)
{
@@ -173,15 +166,12 @@ bst_file_store_forget_list (GtkTreeModel *model)
}
gtk_tree_store_clear (store);
}
-
void
bst_file_store_destroy (GtkTreeModel *model)
{
bst_file_store_forget_list (model);
g_object_unref (model);
}
-
-
/* --- child list wrapper --- */
typedef struct _ProxyStore ProxyStore;
struct _ProxyStore
@@ -199,7 +189,6 @@ struct _ProxyStore
} pq; /* proxy sequence specific */
} u;
};
-
static void
proxy_store_item_property_notify (SfiProxy item,
const gchar *property_name,
@@ -209,7 +198,6 @@ proxy_store_item_property_notify (SfiProxy item,
if (row >= 0) /* the item can be removed already */
gxk_list_wrapper_notify_change (ps->self, row);
}
-
static gint
proxy_store_item_listen_on (ProxyStore *ps,
SfiProxy item)
@@ -223,7 +211,6 @@ proxy_store_item_listen_on (ProxyStore *ps,
gxk_list_wrapper_notify_insert (ps->self, row);
return row;
}
-
static void
proxy_store_item_unlisten_on (ProxyStore *ps,
SfiProxy item,
@@ -235,7 +222,6 @@ proxy_store_item_unlisten_on (ProxyStore *ps,
if (row >= 0) /* special case ipool foreach destroy */
gxk_list_wrapper_notify_delete (ps->self, row);
}
-
static gboolean
proxy_store_get_iter (ProxyStore *ps,
GtkTreeIter *iter,
@@ -248,14 +234,12 @@ proxy_store_get_iter (ProxyStore *ps,
gtk_tree_path_free (path);
return isset;
}
-
static void
child_list_wrapper_release_container (SfiProxy container,
ProxyStore *ps)
{
g_object_set_data ((GObject*) ps->self, "ProxyStore", NULL);
}
-
static void
child_list_wrapper_item_added (SfiProxy container,
SfiProxy item,
@@ -270,7 +254,6 @@ child_list_wrapper_item_added (SfiProxy container,
listener (GTK_TREE_MODEL (ps->self), item, TRUE);
}
}
-
static void
child_list_wrapper_item_removed (SfiProxy container,
SfiProxy item,
@@ -288,14 +271,12 @@ child_list_wrapper_item_removed (SfiProxy container,
listener (GTK_TREE_MODEL (ps->self), item, FALSE);
}
}
-
static gint
child_list_wrapper_row_from_proxy (ProxyStore *ps,
SfiProxy proxy)
{
return bse_item_get_seqid (proxy) - 1;
}
-
static gboolean
child_list_wrapper_foreach (gpointer data,
gulong unique_id)
@@ -304,7 +285,6 @@ child_list_wrapper_foreach (gpointer data,
child_list_wrapper_item_removed (0, unique_id, 0, ps);
return TRUE;
}
-
static void
child_list_wrapper_destroy_data (gpointer data)
{
@@ -320,7 +300,6 @@ child_list_wrapper_destroy_data (gpointer data)
g_free (ps->u.cl.child_type);
g_free (ps);
}
-
void
bst_child_list_wrapper_setup (GxkListWrapper *self,
SfiProxy parent,
@@ -348,7 +327,6 @@ bst_child_list_wrapper_setup (GxkListWrapper *self,
g_object_set_data_full ((GObject*) self, "ProxyStore", ps, child_list_wrapper_destroy_data);
}
}
-
static void
child_list_wrapper_rebuild_with_listener (GxkListWrapper *self,
gpointer listener,
@@ -365,20 +343,17 @@ child_list_wrapper_rebuild_with_listener (GxkListWrapper *self,
bst_child_list_wrapper_setup (self, parent, child_type);
g_free (child_type);
}
-
void
bst_child_list_wrapper_set_listener (GxkListWrapper *self,
ListenerFunc listener)
{
child_list_wrapper_rebuild_with_listener (self, (void*) listener, TRUE);
}
-
void
bst_child_list_wrapper_rebuild (GxkListWrapper *self)
{
child_list_wrapper_rebuild_with_listener (self, NULL, FALSE);
}
-
SfiProxy
bst_child_list_wrapper_get_from_iter (GxkListWrapper *self,
GtkTreeIter *iter)
@@ -386,7 +361,6 @@ bst_child_list_wrapper_get_from_iter (GxkListWrapper *self,
gint row = gxk_list_wrapper_get_index (self, iter);
return bst_child_list_wrapper_get_proxy (self, row);
}
-
SfiProxy
bst_child_list_wrapper_get_proxy (GxkListWrapper *self,
gint row)
@@ -399,7 +373,6 @@ bst_child_list_wrapper_get_proxy (GxkListWrapper *self,
}
return 0;
}
-
gboolean
bst_child_list_wrapper_get_iter (GxkListWrapper *self,
GtkTreeIter *iter,
@@ -408,7 +381,6 @@ bst_child_list_wrapper_get_iter (GxkListWrapper *self,
ProxyStore *ps = (ProxyStore*) g_object_get_data ((GObject*) self, "ProxyStore");
return ps ? proxy_store_get_iter (ps, iter, proxy) : FALSE;
}
-
void
bst_child_list_wrapper_proxy_changed (GxkListWrapper *self,
SfiProxy item)
@@ -418,8 +390,6 @@ bst_child_list_wrapper_proxy_changed (GxkListWrapper *self,
if (row >= 0)
gxk_list_wrapper_notify_change (ps->self, row);
}
-
-
/* --- proxy stores --- */
static void
child_list_wrapper_fill_value (GxkListWrapper *self,
@@ -450,7 +420,6 @@ child_list_wrapper_fill_value (GxkListWrapper *self,
break;
}
}
-
GxkListWrapper*
bst_child_list_wrapper_store_new (void)
{
@@ -466,7 +435,6 @@ bst_child_list_wrapper_store_new (void)
self, G_CONNECT_SWAPPED);
return self;
}
-
static void
item_seq_store_fill_value (GxkListWrapper *self,
guint column,
@@ -497,7 +465,6 @@ item_seq_store_fill_value (GxkListWrapper *self,
break;
}
}
-
GtkTreeModel*
bst_item_seq_store_new (gboolean sorted)
{
@@ -514,20 +481,17 @@ bst_item_seq_store_new (gboolean sorted)
g_object_set_long (self, "sorted-proxies", sorted != FALSE);
return GTK_TREE_MODEL (self);
}
-
static inline SfiProxy
get_proxy (const SfiRing *ring)
{
return (SfiProxy) (ring ? ring->data : NULL);
}
-
static gint
item_seq_store_row_from_proxy (ProxyStore *ps,
SfiProxy proxy)
{
return sfi_ring_index (ps->u.pq.items, (gpointer) proxy);
}
-
static void
item_seq_store_destroy_data (gpointer data)
{
@@ -539,7 +503,6 @@ item_seq_store_destroy_data (gpointer data)
sfi_ring_free (ps->u.pq.items);
g_free (ps);
}
-
static gint
proxy_cmp_sorted (gconstpointer value1,
gconstpointer value2,
@@ -562,7 +525,6 @@ proxy_cmp_sorted (gconstpointer value1,
return s2 ? -1 : s1 != 0;
return strcmp (s1, s2);
}
-
void
bst_item_seq_store_set (GtkTreeModel *model,
BseItemSeq *iseq)
@@ -584,7 +546,6 @@ bst_item_seq_store_set (GtkTreeModel *model,
g_object_set_data_full ((GObject*) model, "ProxyStore", ps, item_seq_store_destroy_data);
}
}
-
gint
bst_item_seq_store_add (GtkTreeModel *model,
SfiProxy proxy)
@@ -597,7 +558,6 @@ bst_item_seq_store_add (GtkTreeModel *model,
gint row = proxy_store_item_listen_on (ps, proxy);
return row;
}
-
gint
bst_item_seq_store_remove (GtkTreeModel *model,
SfiProxy proxy)
@@ -611,7 +571,6 @@ bst_item_seq_store_remove (GtkTreeModel *model,
}
return row;
}
-
gboolean
bst_item_seq_store_can_raise (GtkTreeModel *model,
SfiProxy proxy)
@@ -620,7 +579,6 @@ bst_item_seq_store_can_raise (GtkTreeModel *model,
gint row = item_seq_store_row_from_proxy (ps, proxy);
return row > 0;
}
-
gint
bst_item_seq_store_raise (GtkTreeModel *model,
SfiProxy proxy)
@@ -637,7 +595,6 @@ bst_item_seq_store_raise (GtkTreeModel *model,
}
return row;
}
-
gboolean
bst_item_seq_store_can_lower (GtkTreeModel *model,
SfiProxy proxy)
@@ -646,7 +603,6 @@ bst_item_seq_store_can_lower (GtkTreeModel *model,
gint row = item_seq_store_row_from_proxy (ps, proxy);
return row >= 0 && sfi_ring_tail (ps->u.pq.items)->data != (gpointer) proxy;
}
-
gint
bst_item_seq_store_lower (GtkTreeModel *model,
SfiProxy proxy)
@@ -663,7 +619,6 @@ bst_item_seq_store_lower (GtkTreeModel *model,
}
return row;
}
-
BseItemSeq*
bst_item_seq_store_dup (GtkTreeModel *model)
{
@@ -674,7 +629,6 @@ bst_item_seq_store_dup (GtkTreeModel *model)
bse_item_seq_append (iseq, (SfiProxy) ring->data);
return iseq;
}
-
SfiProxy
bst_item_seq_store_get_from_iter (GtkTreeModel *model,
GtkTreeIter *iter)
@@ -683,7 +637,6 @@ bst_item_seq_store_get_from_iter (GtkTreeModel *model,
gint row = gxk_list_wrapper_get_index (self, iter);
return bst_item_seq_store_get_proxy (model, row);
}
-
SfiProxy
bst_item_seq_store_get_proxy (GtkTreeModel *model,
gint row)
@@ -693,7 +646,6 @@ bst_item_seq_store_get_proxy (GtkTreeModel *model,
return get_proxy (sfi_ring_nth (ps->u.pq.items, row));
return 0;
}
-
gboolean
bst_item_seq_store_get_iter (GtkTreeModel *model,
GtkTreeIter *iter,
diff --git a/beast-gtk/bsttreestores.hh b/beast-gtk/bsttreestores.hh
index 2e61b2e..158e709 100644
--- a/beast-gtk/bsttreestores.hh
+++ b/beast-gtk/bsttreestores.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_TREE_STORES_H__
#define __BST_TREE_STORES_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
-
/* --- file store --- */
enum {
BST_FILE_STORE_COL_ID,
@@ -26,8 +22,6 @@ void bst_file_store_update_list (GtkTreeModel *model,
const gchar *filter);
void bst_file_store_forget_list (GtkTreeModel *model);
void bst_file_store_destroy (GtkTreeModel *model);
-
-
/* --- proxy stores --- */
enum {
BST_PROXY_STORE_SEQID,
@@ -62,8 +56,6 @@ gboolean bst_item_seq_store_get_iter (GtkTreeModel *self,
SfiProxy proxy);
/* store based on the child list of a container */
GxkListWrapper* bst_child_list_wrapper_store_new (void);
-
-
/* --- generic child list wrapper --- */
void bst_child_list_wrapper_setup (GxkListWrapper *self,
SfiProxy parent,
@@ -82,8 +74,5 @@ gboolean bst_child_list_wrapper_get_iter (GxkListWrapper *self,
SfiProxy proxy);
void bst_child_list_wrapper_proxy_changed (GxkListWrapper *self,
SfiProxy item);
-
-
G_END_DECLS
-
#endif /* __BST_TREE_STORES_H__ */
diff --git a/beast-gtk/bstusermessage.cc b/beast-gtk/bstusermessage.cc
index 0b15c59..aac38e0 100644
--- a/beast-gtk/bstusermessage.cc
+++ b/beast-gtk/bstusermessage.cc
@@ -4,22 +4,16 @@
#include "bstmsgabsorb.hh"
#include <string.h>
#include <errno.h>
-
-
/* --- prototypes --- */
static GtkWidget* create_janitor_dialog (SfiProxy janitor);
-
/* --- variables --- */
static GSList *msg_windows = NULL;
-
-
/* --- functions --- */
static void
dialog_destroyed (GtkWidget *dialog)
{
msg_windows = g_slist_remove (msg_windows, dialog);
}
-
static inline gboolean
hastext (const gchar *string)
{
@@ -29,7 +23,6 @@ hastext (const gchar *string)
string++;
return string[0] != 0;
}
-
static gchar*
message_title (const BstMessage *msg,
const gchar **stock,
@@ -72,16 +65,13 @@ message_title (const BstMessage *msg,
return g_strdup (message);
}
}
-
static void
janitor_action (gpointer data,
GtkWidget *widget)
{
SfiProxy proxy = (SfiProxy) data;
-
bse_janitor_trigger_action (proxy, (const char*) g_object_get_data (G_OBJECT (widget), "user_data"));
}
-
static void
toggle_update_filter (GtkWidget *toggle,
gpointer data)
@@ -90,7 +80,6 @@ toggle_update_filter (GtkWidget *toggle,
if (config_check && bst_msg_absorb_config_adjust (config_check, GTK_TOGGLE_BUTTON (toggle)->active, TRUE))
bst_msg_absorb_config_save();
}
-
static gchar*
adapt_message_spacing (const gchar *head,
const gchar *message,
@@ -109,7 +98,6 @@ adapt_message_spacing (const gchar *head,
g_string_append (gstring, tail);
return g_string_free (gstring, FALSE);
}
-
static gchar*
strdup_msg_hashkey (const BstMessage *msg)
{
@@ -122,7 +110,6 @@ strdup_msg_hashkey (const BstMessage *msg)
else
return g_strdup_printf ("## %x ## %s ## %s ## N%x", msg->type, msg->primary, msg->secondary, msg->pid);
}
-
static void
bst_msg_dialog_update (GxkDialog *dialog,
const BstMessage *msg,
@@ -257,20 +244,17 @@ bst_msg_dialog_update (GxkDialog *dialog,
gxk_dialog_set_title (dialog, title);
g_free (title);
}
-
static void
bst_msg_dialog_janitor_update (GxkDialog *dialog,
SfiProxy janitor)
{
g_return_if_fail (BSE_IS_JANITOR (janitor));
-
guint i, n = bse_janitor_n_actions (janitor);
for (i = 0; i < n; i++)
{
const gchar *action = bse_janitor_get_action (janitor, i);
const gchar *name = bse_janitor_get_action_name (janitor, i);
const gchar *blurb = bse_janitor_get_action_blurb (janitor, i);
-
if (action)
{
GtkWidget *button = gxk_dialog_action_multi (dialog, name,
@@ -283,8 +267,6 @@ bst_msg_dialog_janitor_update (GxkDialog *dialog,
GtkWidget *bwidget = gxk_dialog_action (dialog, BST_STOCK_CANCEL, (void*) gxk_toplevel_delete, NULL);
gxk_dialog_set_focus (dialog, bwidget);
}
-
-
void
bst_msg_bit_free (BstMsgBit *mbit)
{
@@ -293,7 +275,6 @@ bst_msg_bit_free (BstMsgBit *mbit)
g_free (mbit->options);
g_free (mbit);
}
-
BstMsgBit*
bst_msg_bit_printf (guint8 msg_part_id,
const char *format,
@@ -314,7 +295,6 @@ bst_msg_bit_printf (guint8 msg_part_id,
errno = saved_errno;
return mbit;
}
-
BstMsgBit*
bst_msg_bit_create_choice (guint id,
const gchar *name,
@@ -331,7 +311,6 @@ bst_msg_bit_create_choice (guint id,
errno = saved_errno;
return mbit;
}
-
static void
message_dialog_choice_triggered (GtkWidget *choice,
gpointer data)
@@ -341,7 +320,6 @@ message_dialog_choice_triggered (GtkWidget *choice,
g_object_set_data ((GObject*) toplevel, "bst-modal-choice-result", data);
gxk_toplevel_delete (choice);
}
-
static void
repeat_dialog (GxkDialog *dialog)
{
@@ -356,7 +334,6 @@ repeat_dialog (GxkDialog *dialog)
gtk_widget_show (GTK_WIDGET (label));
}
}
-
static GtkWidget*
find_dialog (GSList *dialog_list,
const BstMessage *msg)
@@ -376,7 +353,6 @@ find_dialog (GSList *dialog_list,
g_free (mid);
return widget;
}
-
static void
dialog_show_above_modals (GxkDialog *dialog,
gboolean must_return_visible)
@@ -389,7 +365,6 @@ dialog_show_above_modals (GxkDialog *dialog,
}
gtk_widget_show (GTK_WIDGET (dialog));
}
-
guint
bst_message_handler (const BstMessage *const_msg)
{
@@ -467,7 +442,6 @@ bst_message_handler (const BstMessage *const_msg)
}
return result;
}
-
static BstMsgType
bst_msg_type_from_user_msg_type (BseMsgType utype)
{
@@ -481,7 +455,6 @@ bst_msg_type_from_user_msg_type (BseMsgType utype)
BIRNET_STATIC_ASSERT (BST_MSG_DEBUG == (uint) BSE_MSG_DEBUG);
return BstMsgType (utype);
}
-
static void
message_fill_from_script (BstMessage *msg,
BstMsgType mtype,
@@ -523,7 +496,6 @@ message_fill_from_script (BstMessage *msg,
msg->n_msg_bits = 0;
msg->msg_bits = NULL;
}
-
static void
message_free_from_script (BstMessage *msg)
{
@@ -533,7 +505,6 @@ message_free_from_script (BstMessage *msg)
g_free ((char*) msg->details);
g_free ((char*) msg->config_check);
}
-
static void
janitor_actions_changed (GxkDialog *dialog)
{
@@ -548,7 +519,6 @@ janitor_actions_changed (GxkDialog *dialog)
bst_msg_dialog_janitor_update (dialog, janitor);
message_free_from_script (&msg);
}
-
static void
janitor_progress (GxkDialog *dialog,
SfiReal progress)
@@ -566,7 +536,6 @@ janitor_progress (GxkDialog *dialog,
gxk_status_window_pop ();
g_free (exec_name);
}
-
static void
janitor_unconnected (GxkDialog *dialog)
{
@@ -593,12 +562,10 @@ janitor_unconnected (GxkDialog *dialog)
}
}
}
-
static void
janitor_window_deleted (GxkDialog *dialog)
{
SfiProxy janitor = (SfiProxy) g_object_get_data (G_OBJECT (dialog), "user-data");
-
bse_proxy_disconnect (janitor,
"any_signal", janitor_actions_changed, dialog,
"any_signal", janitor_progress, dialog,
@@ -607,7 +574,6 @@ janitor_window_deleted (GxkDialog *dialog)
bse_janitor_kill (janitor);
bse_item_unuse (janitor);
}
-
static GtkWidget*
create_janitor_dialog (SfiProxy janitor)
{
@@ -615,7 +581,6 @@ create_janitor_dialog (SfiProxy janitor)
GXK_DIALOG_STATUS_BAR, // | GXK_DIALOG_WINDOW_GROUP,
NULL, NULL);
gxk_dialog_set_sizes (dialog, -1, -1, 512, -1);
-
g_object_set_data (G_OBJECT (dialog), "user-data", (gpointer) janitor);
bse_proxy_connect (janitor,
"swapped-object-signal::action-changed", janitor_actions_changed, dialog,
@@ -627,10 +592,8 @@ create_janitor_dialog (SfiProxy janitor)
bse_item_use (janitor);
g_object_connect (dialog, "swapped_signal::destroy", janitor_window_deleted, dialog, NULL);
dialog_show_above_modals (dialog, FALSE);
-
return GTK_WIDGET (dialog);
}
-
void
bst_message_synth_msg_handler (const BseMessage *umsg)
{
@@ -649,7 +612,6 @@ bst_message_synth_msg_handler (const BseMessage *umsg)
msg.pid = umsg->pid;
bst_message_handler (&msg);
}
-
static char*
text_concat (char *prefix,
char *text)
@@ -658,8 +620,6 @@ text_concat (char *prefix,
g_free (prefix);
return result;
}
-
-
/**
* bst_message_dialog_display
* @param log_domain log domain
@@ -746,14 +706,12 @@ bst_message_dialog_display (const char *log_domain,
errno = saved_errno;
return result;
}
-
void
bst_message_dialogs_popdown (void)
{
while (msg_windows)
gtk_widget_destroy ((GtkWidget*) msg_windows->data);
}
-
static void
server_bse_message (SfiProxy server,
SfiRec *bse_msg_rec)
@@ -762,14 +720,12 @@ server_bse_message (SfiProxy server,
bst_message_synth_msg_handler (umsg);
bse_message_free (umsg);
}
-
static void
server_script_start (SfiProxy server,
SfiProxy janitor)
{
create_janitor_dialog (janitor);
}
-
static void
server_script_error (SfiProxy server,
const gchar *script_name,
@@ -784,7 +740,6 @@ server_script_error (SfiProxy server,
bst_message_handler (&msg);
message_free_from_script (&msg);
}
-
void
bst_message_connect_to_server (void)
{
@@ -795,7 +750,6 @@ bst_message_connect_to_server (void)
NULL);
bse_proxy_set (BSE_SERVER, "log-messages", FALSE, NULL);
}
-
static int
msg_id_compare (const void *v1, const void *v2)
{
@@ -803,7 +757,6 @@ msg_id_compare (const void *v1, const void *v2)
const BstMsgID *mid2 = (const BstMsgID*) v2;
return strcmp (mid1->ident, mid2->ident);
}
-
const BstMsgID*
bst_message_list_types (guint *n_types)
{
diff --git a/beast-gtk/bstusermessage.hh b/beast-gtk/bstusermessage.hh
index 0fb57f1..195afbb 100644
--- a/beast-gtk/bstusermessage.hh
+++ b/beast-gtk/bstusermessage.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_USER_MESSAGE_H__
#define __BST_USER_MESSAGE_H__
-
#include "bstutils.hh"
-
G_BEGIN_DECLS
-
/* --- structures --- */
typedef enum {
BST_MSG_NONE = SFI_MSG_NONE,
@@ -17,14 +14,12 @@ typedef enum {
BST_MSG_DIAG = SFI_MSG_DIAG,
BST_MSG_DEBUG = SFI_MSG_DEBUG,
} BstMsgType;
-
typedef struct {
guint id;
gchar *text;
gchar *stock_icon;
gchar *options;
} BstMsgBit;
-
typedef struct {
const char *log_domain;
BstMsgType type;
@@ -41,13 +36,11 @@ typedef struct {
guint n_msg_bits;
BstMsgBit **msg_bits;
} BstMessage;
-
typedef struct {
guint type;
const gchar *ident;
const gchar *label; /* maybe NULL */
} BstMsgID;
-
/* --- prototypes --- */
void bst_message_connect_to_server (void);
void bst_message_dialogs_popdown (void);
@@ -87,7 +80,5 @@ BstMsgBit* bst_msg_bit_create_choice (guint id,
__result = bst_message_dialog_display (BIRNET_LOG_DOMAIN, \
__mt, BIRNET_ARRAY_SIZE (__ba), __ba); } \
__result; })
-
G_END_DECLS
-
#endif /* __BST_USER_MESSAGE_H__ */
diff --git a/beast-gtk/bstutils.cc b/beast-gtk/bstutils.cc
index 2383fbf..064403c 100644
--- a/beast-gtk/bstutils.cc
+++ b/beast-gtk/bstutils.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh"
-
#include "bstgconfig.hh"
#include "bstmenus.hh"
#include "bsttrackview.hh"
@@ -19,29 +18,19 @@
#include <errno.h>
#include <unistd.h>
#include <string.h>
-
-
/* --- generated enums --- */
#include "bstenum_arrays.cc" /* enum string value arrays plus include directives */
-
-
/* --- prototypes --- */
static void _bst_init_idl (void);
-
-
/* --- variables --- */
static GtkIconFactory *stock_icon_factory = NULL;
-
-
/* --- functions --- */
void
_bst_init_utils (void)
{
g_assert (stock_icon_factory == NULL);
-
stock_icon_factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (stock_icon_factory);
-
/* initialize generated type ids */
{
static struct {
@@ -56,7 +45,6 @@ _bst_init_utils (void)
for (i = 0; i < sizeof (builtin_info) / sizeof (builtin_info[0]); i++)
{
GType type_id = 0;
-
if (builtin_info[i].parent == G_TYPE_ENUM)
type_id = g_enum_register_static (builtin_info[i].type_name, (const GEnumValue*) builtin_info[i].pointer1);
else if (builtin_info[i].parent == G_TYPE_FLAGS)
@@ -67,18 +55,14 @@ _bst_init_utils (void)
*builtin_info[i].type_id = type_id;
}
}
-
/* initialize IDL types */
_bst_init_idl ();
-
/* initialize stock icons (included above) */
{
/* generated stock icons */
#include "beast-gtk/icons/bst-stock-gen.cc"
-
gxk_stock_register_icons (G_N_ELEMENTS (stock_icons), stock_icons);
}
-
/* initialize stock actions */
{
static const GxkStockItem stock_items[] = {
@@ -92,7 +76,6 @@ _bst_init_utils (void)
gxk_stock_register_items (G_N_ELEMENTS (stock_items), stock_items);
}
}
-
#include "beast-gtk/dialogs/beast-xml-zfiles.cc"
void
_bst_init_radgets (void)
@@ -121,7 +104,6 @@ _bst_init_radgets (void)
gxk_radget_parse_text ("beast", text, -1, NULL, NULL);
g_free (text);
}
-
GtkWidget*
bst_stock_button (const gchar *stock_id)
{
@@ -129,7 +111,6 @@ bst_stock_button (const gchar *stock_id)
gtk_widget_show_all (w);
return w;
}
-
GtkWidget*
bst_stock_dbutton (const gchar *stock_id)
{
@@ -137,7 +118,6 @@ bst_stock_dbutton (const gchar *stock_id)
g_object_set (w, "can-default", TRUE, NULL);
return w;
}
-
GtkWidget*
bst_stock_icon_button (const gchar *stock_id)
{
@@ -149,7 +129,6 @@ bst_stock_icon_button (const gchar *stock_id)
gtk_widget_show_all (w);
return w;
}
-
void
bst_stock_register_icon (const gchar *stock_id,
guint bytes_per_pixel,
@@ -160,7 +139,6 @@ bst_stock_register_icon (const gchar *stock_id,
{
g_return_if_fail (bytes_per_pixel == 3 || bytes_per_pixel == 4);
g_return_if_fail (width > 0 && height > 0 && rowstride >= width * bytes_per_pixel);
-
if (!gtk_icon_factory_lookup (stock_icon_factory, stock_id))
{
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data ((guchar*) g_memdup (pixels, rowstride * height),
@@ -174,8 +152,6 @@ bst_stock_register_icon (const gchar *stock_id,
gtk_icon_set_unref (iset);
}
}
-
-
/* --- beast/bse specific extensions --- */
void
bst_status_eprintf (BseErrorType error,
@@ -184,23 +160,19 @@ bst_status_eprintf (BseErrorType error,
{
gchar *buffer;
va_list args;
-
va_start (args, message_fmt);
buffer = g_strdup_vprintf (message_fmt, args);
va_end (args);
-
if (error)
gxk_status_set (GXK_STATUS_ERROR, buffer, bse_error_blurb (error));
else
gxk_status_set (GXK_STATUS_DONE, buffer, NULL);
g_free (buffer);
}
-
void
bst_gui_error_bell (gpointer widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (GTK_WIDGET_DRAWABLE (widget) && BST_GUI_ENABLE_ERROR_BELL)
{
#if GTK_CHECK_VERSION (2, 12, 0)
@@ -210,30 +182,25 @@ bst_gui_error_bell (gpointer widget)
#endif
}
}
-
typedef struct {
GtkWindow *window;
SfiProxy proxy;
gchar *title1;
gchar *title2;
} TitleSync;
-
static void
sync_title (TitleSync *tsync)
{
const gchar *name = bse_item_get_name (tsync->proxy);
gchar *s;
-
s = g_strconcat (tsync->title1, name ? name : "<NULL>", tsync->title2, NULL);
g_object_set (tsync->window, "title", s, NULL);
g_free (s);
}
-
static void
free_title_sync (gpointer data)
{
TitleSync *tsync = (TitleSync*) data;
-
bse_proxy_disconnect (tsync->proxy,
"any_signal", sync_title, tsync,
NULL);
@@ -241,14 +208,12 @@ free_title_sync (gpointer data)
g_free (tsync->title2);
g_free (tsync);
}
-
void
bst_window_sync_title_to_proxy (gpointer window,
SfiProxy proxy,
const gchar *title_format)
{
const char *p;
-
g_return_if_fail (GTK_IS_WINDOW (window));
if (proxy)
{
@@ -276,16 +241,13 @@ bst_window_sync_title_to_proxy (gpointer window,
g_object_set (window, "title", title_format, NULL);
}
}
-
typedef struct {
gboolean (*handler) (gpointer data);
gpointer data;
void (*free_func) (gpointer data);
} BackgroundHandler;
-
static SfiRing *background_handlers1 = NULL;
static SfiRing *background_handlers2 = NULL;
-
static gboolean
bst_background_handlers_timeout (gpointer timeout_data)
{
@@ -326,7 +288,6 @@ bst_background_handlers_timeout (gpointer timeout_data)
bst_background_handlers_timeout, NULL, NULL);
return FALSE;
}
-
static void
bst_background_handler_add (gboolean (*handler) (gpointer data),
gpointer data,
@@ -347,7 +308,6 @@ bst_background_handler_add (gboolean (*handler) (gpointer data),
else
background_handlers2 = sfi_ring_append (background_handlers2, bgh);
}
-
void
bst_background_handler1_add (gboolean (*handler) (gpointer data),
gpointer data,
@@ -355,7 +315,6 @@ bst_background_handler1_add (gboolean (*handler) (gpointer data),
{
bst_background_handler_add (handler, data, free_func, 1);
}
-
void
bst_background_handler2_add (gboolean (*handler) (gpointer data),
gpointer data,
@@ -363,7 +322,6 @@ bst_background_handler2_add (gboolean (*handler) (gpointer data),
{
bst_background_handler_add (handler, data, free_func, 2);
}
-
/* --- packing utilities --- */
#define SPACING 3
static void
@@ -433,7 +391,6 @@ bst_util_pack (GtkWidget *widget,
location = va_arg (args, gchar*);
}
}
-
GtkWidget*
bst_vpack (const gchar *first_location,
...)
@@ -448,7 +405,6 @@ bst_vpack (const gchar *first_location,
gtk_widget_show_all (box);
return box;
}
-
GtkWidget*
bst_hpack (const gchar *first_location,
...)
@@ -463,7 +419,6 @@ bst_hpack (const gchar *first_location,
gtk_widget_show_all (box);
return box;
}
-
GtkWidget*
bst_vpack0 (const gchar *first_location,
...)
@@ -478,7 +433,6 @@ bst_vpack0 (const gchar *first_location,
gtk_widget_show_all (box);
return box;
}
-
GtkWidget*
bst_hpack0 (const gchar *first_location,
...)
@@ -493,7 +447,6 @@ bst_hpack0 (const gchar *first_location,
gtk_widget_show_all (box);
return box;
}
-
void
bst_action_list_add_cat (GxkActionList *alist,
BseCategory *cat,
@@ -504,7 +457,6 @@ bst_action_list_add_cat (GxkActionList *alist,
gpointer user_data)
{
const gchar *p, *stock_id;
-
if (cat->icon)
{
bst_stock_register_icon (cat->category, cat->icon->bytes_per_pixel,
@@ -515,20 +467,17 @@ bst_action_list_add_cat (GxkActionList *alist,
}
else
stock_id = stock_fallback;
-
p = cat->category[0] == '/' ? cat->category + 1 : cat->category;
while (skip_levels--)
{
const gchar *d = strchr (p, '/');
p = d ? d + 1 : p;
}
-
gxk_action_list_add_translated (alist, NULL, p, NULL,
gxk_factory_path_get_leaf (cat->category),
cat->category_id, stock_id,
acheck, aexec, user_data);
}
-
GxkActionList*
bst_action_list_from_cats_pred (BseCategorySeq *cseq,
guint skip_levels,
@@ -541,15 +490,12 @@ bst_action_list_from_cats_pred (BseCategorySeq *cseq,
{
GxkActionList *alist = gxk_action_list_create ();
guint i;
-
g_return_val_if_fail (cseq != NULL, alist);
-
for (i = 0; i < cseq->n_cats; i++)
if (!predicate || predicate (predicate_data, cseq->cats[i]))
bst_action_list_add_cat (alist, cseq->cats[i], skip_levels, stock_fallback, acheck, aexec, user_data);
return alist;
}
-
GxkActionList*
bst_action_list_from_cats (BseCategorySeq *cseq,
guint skip_levels,
@@ -560,8 +506,6 @@ bst_action_list_from_cats (BseCategorySeq *cseq,
{
return bst_action_list_from_cats_pred (cseq, skip_levels, stock_fallback, acheck, aexec, user_data, NULL, NULL);
}
-
-
/* --- field mask --- */
static GQuark gmask_quark = 0;
typedef struct {
@@ -576,12 +520,10 @@ typedef struct {
guint gpack : 8;
} GMask;
#define GMASK_GET(o) ((GMask*) g_object_get_qdata (G_OBJECT (o), gmask_quark))
-
static void
gmask_destroy (gpointer data)
{
GMask *gmask = (GMask*) data;
-
if (gmask->parent)
g_object_unref (gmask->parent);
if (gmask->prompt)
@@ -595,33 +537,26 @@ gmask_destroy (gpointer data)
g_free (gmask->tip);
g_free (gmask);
}
-
static gpointer
gmask_form (GtkWidget *parent,
GtkWidget *action,
BstGMaskPack gpack)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_TABLE (parent), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (action), NULL);
-
if (!gmask_quark)
gmask_quark = g_quark_from_static_string ("GMask");
-
gmask = GMASK_GET (action);
g_return_val_if_fail (gmask == NULL, NULL);
-
gmask = g_new0 (GMask, 1);
g_object_set_qdata_full (G_OBJECT (action), gmask_quark, gmask, gmask_destroy);
gmask->parent = (GtkWidget*) g_object_ref (parent);
gtk_object_sink (GTK_OBJECT (parent));
gmask->action = action;
gmask->gpack = gpack;
-
return action;
}
-
/**
* @param border_width Border width of this GUI mask
* @param dislodge_columns Provide expandable space between columns
@@ -646,10 +581,8 @@ bst_gmask_container_create (guint border_width,
NULL);
if (dislodge_columns)
g_object_set_data (G_OBJECT (container), "GMask-dislodge", GUINT_TO_POINTER (TRUE));
-
return container;
}
-
/**
* @param gmask_container container created with bst_gmask_container_create()
* @param action valid GtkWidget
@@ -684,7 +617,6 @@ bst_gmask_form (GtkWidget *gmask_container,
{
return (BstGMask*) gmask_form (gmask_container, action, gpack);
}
-
/**
* @param mask valid BstGMask
* @param tip_text tooltip text
@@ -696,15 +628,12 @@ bst_gmask_set_tip (BstGMask *mask,
const gchar *tip_text)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
-
g_free (gmask->tip);
gmask->tip = g_strdup (tip_text);
}
-
/**
* @param mask valid BstGMask
* @param widget valid GtkWidget
@@ -716,18 +645,15 @@ bst_gmask_set_prompt (BstGMask *mask,
gpointer widget)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (gmask->prompt)
g_object_unref (gmask->prompt);
gmask->prompt = (GtkWidget*) g_object_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
}
-
/**
* @param mask valid BstGMask
* @param widget valid GtkWidget
@@ -739,18 +665,15 @@ bst_gmask_set_aux1 (BstGMask *mask,
gpointer widget)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (gmask->aux1)
g_object_unref (gmask->aux1);
gmask->aux1 = (GtkWidget*) g_object_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
}
-
/**
* @param mask valid BstGMask
* @param widget valid GtkWidget
@@ -764,18 +687,15 @@ bst_gmask_set_aux2 (BstGMask *mask,
gpointer widget)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (gmask->aux2)
g_object_unref (gmask->aux2);
gmask->aux2 = (GtkWidget*) g_object_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
}
-
/**
* @param mask valid BstGMask
* @param widget valid GtkWidget
@@ -787,18 +707,15 @@ bst_gmask_set_aux3 (BstGMask *mask,
gpointer widget)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (gmask->aux3)
g_object_unref (gmask->aux3);
gmask->aux3 = (GtkWidget*) g_object_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
}
-
/**
* @param mask valid BstGMask
* @param column column number
@@ -811,14 +728,11 @@ bst_gmask_set_column (BstGMask *mask,
guint column)
{
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
-
gmask->column = column;
}
-
/**
* @param mask valid BstGMask
* @return the requested GtkWidget or NULL
@@ -829,14 +743,11 @@ GtkWidget*
bst_gmask_get_prompt (BstGMask *mask)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_WIDGET (mask), NULL);
gmask = GMASK_GET (mask);
g_return_val_if_fail (gmask != NULL, NULL);
-
return gmask->prompt;
}
-
/**
* @param mask valid BstGMask
* @return the requested GtkWidget or NULL
@@ -847,14 +758,11 @@ GtkWidget*
bst_gmask_get_aux1 (BstGMask *mask)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_WIDGET (mask), NULL);
gmask = GMASK_GET (mask);
g_return_val_if_fail (gmask != NULL, NULL);
-
return gmask->aux1;
}
-
/**
* @param mask valid BstGMask
* @return the requested GtkWidget or NULL
@@ -865,14 +773,11 @@ GtkWidget*
bst_gmask_get_aux2 (BstGMask *mask)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_WIDGET (mask), NULL);
gmask = GMASK_GET (mask);
g_return_val_if_fail (gmask != NULL, NULL);
-
return gmask->aux2;
}
-
/**
* @param mask valid BstGMask
* @return the requested GtkWidget or NULL
@@ -883,14 +788,11 @@ GtkWidget*
bst_gmask_get_aux3 (BstGMask *mask)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_WIDGET (mask), NULL);
gmask = GMASK_GET (mask);
g_return_val_if_fail (gmask != NULL, NULL);
-
return gmask->aux3;
}
-
/**
* @param mask valid BstGMask
* @return the requested GtkWidget or NULL
@@ -901,14 +803,11 @@ GtkWidget*
bst_gmask_get_action (BstGMask *mask)
{
GMask *gmask;
-
g_return_val_if_fail (GTK_IS_WIDGET (mask), NULL);
gmask = GMASK_GET (mask);
g_return_val_if_fail (gmask != NULL, NULL);
-
return gmask->action;
}
-
/**
* @param mask valid BstGMask
* @param func foreach function as: void func(GtkWidget*, gpointer data);
@@ -924,12 +823,10 @@ bst_gmask_foreach (BstGMask *mask,
{
GMask *gmask;
GtkCallback callback = GtkCallback (func);
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
g_return_if_fail (func != NULL);
-
if (gmask->prompt)
callback (gmask->prompt, data);
if (gmask->aux1)
@@ -941,13 +838,11 @@ bst_gmask_foreach (BstGMask *mask,
if (gmask->action)
callback (gmask->action, data);
}
-
static GtkWidget*
get_toplevel_and_set_tip (GtkWidget *widget,
const gchar *tip)
{
GtkWidget *last;
-
if (!widget)
return NULL;
else if (!tip)
@@ -971,7 +866,6 @@ get_toplevel_and_set_tip (GtkWidget *widget,
gxk_widget_set_tooltip (widget, tip);
return widget;
}
-
static guint
table_max_bottom_row (GtkTable *table,
guint left_col,
@@ -979,17 +873,14 @@ table_max_bottom_row (GtkTable *table,
{
guint max_bottom = 0;
GList *list;
-
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
-
if (child->left_attach < right_col && child->right_attach > left_col)
max_bottom = MAX (max_bottom, child->bottom_attach);
}
return max_bottom;
}
-
/**
* @param mask valid BstGMask
*
@@ -1006,11 +897,9 @@ bst_gmask_pack (BstGMask *mask)
gboolean dummy_aux2 = FALSE;
guint row, n, c, dislodge_columns;
GMask *gmask;
-
g_return_if_fail (GTK_IS_WIDGET (mask));
gmask = GMASK_GET (mask);
g_return_if_fail (gmask != NULL);
-
/* GUI mask layout:
* row: |Prompt|Aux1| Aux2 |Aux3| PreAction#Action#PostAction|
* FILL: allocate all possible (Pre/Post)Action space to the action widget
@@ -1018,7 +907,6 @@ bst_gmask_pack (BstGMask *mask)
* BIG: allocate maximum (left extendeded) possible space to Action
* Aux2 expands automatically
*/
-
/* retrieve children and set tips */
prompt = get_toplevel_and_set_tip (gmask->prompt, gmask->tip);
aux1 = get_toplevel_and_set_tip (gmask->aux1, gmask->tip);
@@ -1027,13 +915,11 @@ bst_gmask_pack (BstGMask *mask)
action = get_toplevel_and_set_tip (gmask->action, gmask->tip);
dislodge_columns = g_object_get_data (G_OBJECT (gmask->parent), "GMask-dislodge") != NULL;
table = GTK_TABLE (gmask->parent);
-
/* ensure expansion happens outside of columns */
if (dislodge_columns)
{
gchar *dummy_name = g_strdup_printf ("GMask-dummy-dislodge-%u", MAX (gmask->column, 1) - 1);
GtkWidget *dislodge = (GtkWidget*) g_object_get_data (G_OBJECT (table), dummy_name);
-
if (!dislodge)
{
dislodge = (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT, "visible", TRUE, NULL);
@@ -1043,7 +929,6 @@ bst_gmask_pack (BstGMask *mask)
}
g_free (dummy_name);
}
-
/* pack gmask children, options: GTK_EXPAND, GTK_SHRINK, GTK_FILL */
gboolean span_multi_columns = aux2 && gmask->gpack == BST_GMASK_MULTI_SPAN;
c = span_multi_columns ? 0 : 6 * gmask->column;
@@ -1064,7 +949,6 @@ bst_gmask_pack (BstGMask *mask)
{
char *dummy_name = g_strdup_printf ("GMask-dummy-aux2-%u", gmask->column);
aux2 = (GtkWidget*) g_object_get_data (G_OBJECT (table), dummy_name);
-
/* need to have at least 1 (dummy) aux2-child per table column to eat up
* expanding space in this column if !dislodge_columns
*/
@@ -1146,7 +1030,6 @@ bst_gmask_pack (BstGMask *mask)
if (c)
gtk_table_set_col_spacing (table, c - 1, 5); /* spacing between gmask columns */
}
-
/**
* @param gmask_container container created with bst_gmask_container_create()
* @param column column number for bst_gmask_set_column()
@@ -1168,7 +1051,6 @@ bst_gmask_quick (GtkWidget *gmask_container,
const gchar *tip_text)
{
BstGMask *mask = bst_gmask_form (gmask_container, (GtkWidget*) action, BST_GMASK_INTERLEAVE);
-
if (prompt)
bst_gmask_set_prompt (mask, g_object_new (GTK_TYPE_LABEL,
"visible", TRUE,
@@ -1178,11 +1060,8 @@ bst_gmask_quick (GtkWidget *gmask_container,
bst_gmask_set_tip (mask, tip_text);
bst_gmask_set_column (mask, column);
bst_gmask_pack (mask);
-
return mask;
}
-
-
/* --- named children --- */
static GQuark quark_container_named_children = 0;
typedef struct {
@@ -1192,7 +1071,6 @@ static void
nchildren_free (gpointer data)
{
NChildren *children = (NChildren*) data;
-
g_datalist_clear (&children->qdata);
g_free (children);
}
@@ -1207,16 +1085,13 @@ bst_container_set_named_child (GtkWidget *container,
GtkWidget *child)
{
NChildren *children;
-
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (qname > 0);
g_return_if_fail (GTK_IS_WIDGET (child));
if (child)
g_return_if_fail (gtk_widget_is_ancestor (child, container));
-
if (!quark_container_named_children)
quark_container_named_children = g_quark_from_static_string ("BstContainer-named_children");
-
children = (NChildren*) g_object_get_qdata (G_OBJECT (container), quark_container_named_children);
if (!children)
{
@@ -1230,21 +1105,17 @@ bst_container_set_named_child (GtkWidget *container,
g_object_ref (child);
g_datalist_id_set_data_full (&children->qdata, qname, child, g_object_unref);
}
-
GtkWidget*
bst_container_get_named_child (GtkWidget *container,
GQuark qname)
{
NChildren *children;
-
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
g_return_val_if_fail (qname > 0, NULL);
-
children = quark_container_named_children ? (NChildren*) g_object_get_qdata (G_OBJECT (container), quark_container_named_children) : NULL;
if (children)
{
GtkWidget *child = (GtkWidget*) g_datalist_id_get_data (&children->qdata, qname);
-
if (child && !gtk_widget_is_ancestor (child, container))
{
/* got removed meanwhile */
@@ -1255,7 +1126,6 @@ bst_container_get_named_child (GtkWidget *container,
}
return NULL;
}
-
GtkWidget*
bst_xpm_view_create (const gchar **xpm,
GtkWidget *colormap_widget)
@@ -1263,10 +1133,8 @@ bst_xpm_view_create (const gchar **xpm,
GtkWidget *pix;
GdkPixmap *pixmap;
GdkBitmap *mask;
-
g_return_val_if_fail (xpm != NULL, NULL);
g_return_val_if_fail (GTK_IS_WIDGET (colormap_widget), NULL);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (colormap_widget),
&mask, NULL, (gchar**) xpm);
pix = gtk_pixmap_new (pixmap, mask);
@@ -1277,8 +1145,6 @@ bst_xpm_view_create (const gchar **xpm,
NULL);
return pix;
}
-
-
/* --- misc utils --- */
gint
bst_fft_size_to_int (BstFFTSize fft_size)
@@ -1325,7 +1191,6 @@ bst_fft_size_to_int (BstFFTSize fft_size)
default: return 0;
}
}
-
BstFFTSize
bst_fft_size_from_int (guint sz)
{
@@ -1380,18 +1245,14 @@ bst_fft_size_from_int (guint sz)
}
return sizes[offset].fft_size;
}
-
#include <sfi/sfistore.hh>
-
gchar*
bst_file_scan_find_key (const gchar *file,
const gchar *key,
const gchar *value_prefix)
{
SfiRStore *rstore;
-
g_return_val_if_fail (file != NULL, NULL);
-
rstore = sfi_rstore_new_open (file);
if (rstore)
{
@@ -1421,12 +1282,8 @@ bst_file_scan_find_key (const gchar *file,
else
return NULL;
}
-
-
/* --- generated marshallers --- */
#include "bstmarshal.cc"
-
-
/* --- IDL pspecs --- */
#define sfidl_pspec_Bool(group, name, nick, blurb, dflt, hints) \
sfi_pspec_set_group (sfi_pspec_bool (name, nick, blurb, dflt, hints), group)
diff --git a/beast-gtk/bstutils.hh b/beast-gtk/bstutils.hh
index 581f743..fef3683 100644
--- a/beast-gtk/bstutils.hh
+++ b/beast-gtk/bstutils.hh
@@ -1,16 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_UTILS_H__
#define __BST_UTILS_H__
-
#include "bstbseutils.hh"
#include <gtk/gtk.h>
#include "bstdefs.hh"
#include "bstcluehunter.hh"
/* generated type IDs, idl types */
#include "bstgentypes.h"
-
G_BEGIN_DECLS
-
/* --- GUI utilities --- */
void bst_status_eprintf (BseErrorType error,
const gchar *message_fmt,
@@ -63,8 +60,6 @@ void bst_background_handler1_add (gboolean (*handler) (gpoint
void bst_background_handler2_add (gboolean (*handler) (gpointer data),
gpointer data,
void (*free_func) (gpointer data));
-
-
/* --- stock utilities --- */
GtkWidget* bst_stock_button (const gchar *stock_id);
GtkWidget* bst_stock_dbutton (const gchar *stock_id);
@@ -79,16 +74,12 @@ void bst_stock_register_icon (const gchar *stock_id,
#define bst_pixbuf_no_icon() gxk_stock_fallback_pixbuf (BST_STOCK_NO_ICON)
#define bst_pixbuf_ladspa() gxk_stock_fallback_pixbuf (BST_STOCK_LADSPA)
#define bst_pixbuf_knob() gxk_stock_fallback_pixbuf (BST_STOCK_KNOB)
-
-
/* --- misc utils --- */
gint bst_fft_size_to_int (BstFFTSize fft_size);
BstFFTSize bst_fft_size_from_int (guint sz);
gchar* bst_file_scan_find_key (const gchar *file,
const gchar *key,
const gchar *value_prefix);
-
-
/* --- GUI field mask --- */
typedef struct _BstGMask BstGMask;
GtkWidget* bst_gmask_container_create (guint border_width,
@@ -140,17 +131,13 @@ BstGMask* bst_gmask_quick (GtkWidget *gmask_container,
bst_gmask_foreach ((mask), gtk_widget_destroy, NULL)
#define bst_gmask_ref g_object_ref
#define bst_gmask_unref g_object_unref
-
-
/* --- object utils --- */
#define bst_object_class_install_property(oclass, group, property_id, pspec) \
g_object_class_install_property (oclass, property_id, sfi_pspec_set_group (pspec, group))
-
/* --- stock icon aliases --- */
#define BST_STOCK_QUESTION GTK_STOCK_DIALOG_QUESTION
#define BST_STOCK_WARNING GTK_STOCK_DIALOG_WARNING
#define BST_STOCK_ERROR GTK_STOCK_DIALOG_ERROR
-
#define BST_STOCK_NEW GTK_STOCK_NEW
#define BST_STOCK_OPEN GTK_STOCK_OPEN
#define BST_STOCK_MERGE GTK_STOCK_OPEN // FIXME
@@ -175,12 +162,9 @@ BstGMask* bst_gmask_quick (GtkWidget *gmask_container,
#define BST_STOCK_ONLINE_SOUND_ARCHIVE BST_STOCK_LOAD_LIB // FIXME
#define BST_STOCK_ADD GTK_STOCK_ADD
#define BST_STOCK_REMOVE GTK_STOCK_REMOVE
-
#define BST_STOCK_SELECT_ALL BST_STOCK_NONE // FIXME
#define BST_STOCK_SELECT_NONE BST_STOCK_NONE // FIXME
#define BST_STOCK_SELECT_INVERT BST_STOCK_NONE // FIXME
-
-
/* --- stock actions and aliases --- */
#define BST_STOCK_NONE (NULL)
#define BST_STOCK_APPLY GTK_STOCK_APPLY
@@ -201,24 +185,16 @@ BstGMask* bst_gmask_quick (GtkWidget *gmask_container,
#define BST_STOCK_ZOOM_FIT GTK_STOCK_ZOOM_FIT
#define BST_STOCK_ZOOM_IN GTK_STOCK_ZOOM_IN
#define BST_STOCK_ZOOM_OUT GTK_STOCK_ZOOM_OUT
-
-
/* --- generated includes --- */
/* marshallers */
#include "bstmarshal.h"
/* icon stock IDs */
#include "beast-gtk/icons/bst-stock-gen.h"
-
-
/* --- config values --- */
BstGConfig* bst_gconfig_get_global (void);
#define BST_GCONFIG(field) (* bst_gconfig_get_global ()) . field
-
-
/* --- internal --- */
void _bst_init_utils (void);
void _bst_init_radgets (void);
-
G_END_DECLS
-
#endif /* __BST_UTILS_H__ */
diff --git a/beast-gtk/bstwaveeditor.cc b/beast-gtk/bstwaveeditor.cc
index 5ec464d..4906f41 100644
--- a/beast-gtk/bstwaveeditor.cc
+++ b/beast-gtk/bstwaveeditor.cc
@@ -1,20 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstwaveeditor.hh"
-
#include "bstplayback.hh"
#include "bstprocedure.hh"
#include "bstmenus.hh"
#include <gdk/gdkkeysyms.h>
-
extern "C" guint64 bse_engine_tick_stamp_from_systime (guint64 systime); // FIXME
-
enum {
SCROLL_NONE = 0,
SCROLL_BOTH = 3,
SCROLL_LEFT = 1,
SCROLL_RIGHT = 2,
};
-
/* --- wave chunk list model --- */
enum {
COL_OSC_FREQ,
@@ -24,8 +20,6 @@ enum {
COL_FILE_NAME,
N_COLS
};
-
-
/* --- prototypes --- */
static void bst_wave_editor_class_init (BstWaveEditorClass *klass);
static void bst_wave_editor_init (BstWaveEditor *wave_editor);
@@ -52,18 +46,13 @@ static void wave_chunk_fill_value (BstWaveEditor *self,
GValue *value);
static void wave_editor_set_n_qsamplers (BstWaveEditor *self,
guint n_qsamplers);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GtkType
bst_wave_editor_get_type (void)
{
static GtkType wave_editor_type = 0;
-
if (!wave_editor_type)
{
GtkTypeInfo wave_editor_info =
@@ -77,37 +66,28 @@ bst_wave_editor_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
wave_editor_type = gtk_type_unique (GTK_TYPE_VBOX, &wave_editor_info);
}
-
return wave_editor_type;
}
-
static void
bst_wave_editor_class_init (BstWaveEditorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
// GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bst_wave_editor_finalize;
-
object_class->destroy = bst_wave_editor_destroy;
}
-
static void
bst_wave_editor_init (BstWaveEditor *self)
{
GtkTreeSelection *tsel;
GtkWidget *any, *paned;
gpointer gmask;
-
/* setup main container */
self->main_vbox = GTK_WIDGET (self);
-
/* wave chunk list model */
self->chunk_wrapper = gxk_list_wrapper_new (N_COLS,
G_TYPE_STRING, /* COL_OSC_FREQ */
@@ -119,13 +99,11 @@ bst_wave_editor_init (BstWaveEditor *self)
g_signal_connect_object (self->chunk_wrapper, "fill-value",
G_CALLBACK (wave_chunk_fill_value),
self, G_CONNECT_SWAPPED);
-
/* chunk list / qsampler paned container */
paned = (GtkWidget*) g_object_new (GTK_TYPE_VPANED,
"visible", TRUE,
"parent", self->main_vbox,
NULL);
-
/* chunk list widgets */
any = (GtkWidget*) g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
@@ -148,7 +126,6 @@ bst_wave_editor_init (BstWaveEditor *self)
tsel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->tree));
gtk_tree_selection_set_mode (tsel, GTK_SELECTION_SINGLE);
g_object_connect (tsel, "swapped_object_signal::changed", tree_selection_changed, self, NULL);
-
/* add columns to chunk list */
gxk_tree_view_append_text_columns (GTK_TREE_VIEW (self->tree), N_COLS,
COL_OSC_FREQ, "", 0.0, "OscFreq",
@@ -156,7 +133,6 @@ bst_wave_editor_init (BstWaveEditor *self)
COL_LOOP, "", 0.0, "Loop",
COL_WAVE_NAME, "", 0.0, "WaveName",
COL_FILE_NAME, "", 0.0, "FileName");
-
/* qsampler container */
self->qsampler_parent = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -165,12 +141,10 @@ bst_wave_editor_init (BstWaveEditor *self)
NULL);
gxk_nullify_in_object (self, &self->qsampler_parent);
gtk_paned_pack2 (GTK_PANED (paned), self->qsampler_parent, TRUE, TRUE);
-
/* GUI mask container */
self->gmask_parent = bst_gmask_container_create (5, TRUE);
gxk_nullify_in_object (self, &self->gmask_parent);
gtk_box_pack_start (GTK_BOX (self->main_vbox), self->gmask_parent, FALSE, TRUE, 0);
-
/* qsampler (horizontal) zoom */
self->zoom_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.5, 1e-16, 1e+16, 0.1, 10, 0));
g_object_connect (self->zoom_adjustment, "swapped_signal_after::value_changed", adjustments_changed, self, NULL);
@@ -181,7 +155,6 @@ bst_wave_editor_init (BstWaveEditor *self)
"visible", TRUE,
NULL);
gmask = bst_gmask_quick (self->gmask_parent, 0, _("Zoom:"), any, NULL);
-
/* qsampler vscale */
self->vscale_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (100, 1e-16, 1e+16, 1, 10, 0));
g_object_connect (self->vscale_adjustment, "swapped_signal_after::value_changed", adjustments_changed, self, NULL);
@@ -192,7 +165,6 @@ bst_wave_editor_init (BstWaveEditor *self)
"visible", TRUE,
NULL);
gmask = bst_gmask_quick (self->gmask_parent, 1, _("VScale:"), any, NULL);
-
/* qsampler draw type choice */
any = (GtkWidget*) g_object_new (GTK_TYPE_OPTION_MENU, "visible", TRUE, NULL);
gtk_option_menu_set_menu (GTK_OPTION_MENU (any),
@@ -210,11 +182,9 @@ bst_wave_editor_init (BstWaveEditor *self)
gtk_option_menu_set_history (GTK_OPTION_MENU (any), 0);
self->draw_mode = BST_QSAMPLER_DRAW_CRANGE;
gmask = bst_gmask_quick (self->gmask_parent, 2, NULL, any, NULL);
-
/* playback handle */
self->phandle = bst_play_back_handle_new ();
self->playback_length = 0;
-
/* preview auto scroll choice */
any = (GtkWidget*) g_object_new (GTK_TYPE_OPTION_MENU, "visible", TRUE, NULL);
gtk_option_menu_set_menu (GTK_OPTION_MENU (any),
@@ -228,7 +198,6 @@ bst_wave_editor_init (BstWaveEditor *self)
gtk_option_menu_set_history (GTK_OPTION_MENU (any), 1);
self->auto_scroll_mode = SCROLL_BOTH;
gmask = bst_gmask_quick (self->gmask_parent, 1, NULL, any, NULL);
-
/* preview buttons */
any = (GtkWidget*) g_object_new (GTK_TYPE_HBOX,
"visible", TRUE,
@@ -248,12 +217,10 @@ bst_wave_editor_init (BstWaveEditor *self)
gtk_widget_hide (self->preview_off);
gmask = bst_gmask_quick (self->gmask_parent, 2, NULL, any, NULL);
}
-
static void
bst_wave_editor_destroy (GtkObject *object)
{
BstWaveEditor *self = BST_WAVE_EDITOR (object);
-
bst_wave_editor_set_esample (self, 0);
if (self->phandle)
{
@@ -261,28 +228,21 @@ bst_wave_editor_destroy (GtkObject *object)
self->phandle = NULL;
}
bst_wave_editor_set_wave (self, 0);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_wave_editor_finalize (GObject *object)
{
BstWaveEditor *self = BST_WAVE_EDITOR (object);
-
g_return_if_fail (self->qsamplers == NULL);
-
g_object_unref (self->chunk_wrapper);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
void
bst_wave_editor_set_wave (BstWaveEditor *self,
SfiProxy wave)
{
g_return_if_fail (BST_IS_WAVE_EDITOR (self));
-
if (wave != self->wave)
{
if (self->wave)
@@ -305,7 +265,6 @@ bst_wave_editor_set_wave (BstWaveEditor *self,
}
}
}
-
static void
play_back_wchunk_off (BstWaveEditor *self)
{
@@ -322,14 +281,12 @@ play_back_wchunk_off (BstWaveEditor *self)
for (i = 0; i < self->n_qsamplers; i++)
bst_qsampler_set_mark (self->qsamplers[i], 3, 0, BstQSamplerType (0));
}
-
static void
update_play_back_marks (gpointer data,
SfiNum tick_stamp,
guint pcm_pos)
{
BstWaveEditor *self = (BstWaveEditor*) data;
-
/* initial notify */
if (!self->tick_stamp || tick_stamp <= self->tick_stamp || pcm_pos <= self->pcm_pos)
{
@@ -353,16 +310,13 @@ update_play_back_marks (gpointer data,
/* updates may slow down now */
bst_play_back_handle_time_pcm_notify (self->phandle, 500);
}
-
if (pcm_pos > self->playback_length)
play_back_wchunk_off (self); /* stop looping */
}
-
static gboolean
playback_marker (gpointer data)
{
BstWaveEditor *self;
-
GDK_THREADS_ENTER ();
self = BST_WAVE_EDITOR (data);
if (self->tick_stamp)
@@ -373,7 +327,6 @@ playback_marker (gpointer data)
gtk_adjustment_set_value (GTK_RANGE (self->qsampler_playpos)->adjustment,
pcm_pos * 100.0 / ((gfloat) self->playback_length));
self->ignore_playpos = FALSE;
-
if (1)
{
guint i, qpos = pcm_pos / self->n_qsamplers; /* n esample channels */
@@ -395,7 +348,6 @@ playback_marker (gpointer data)
GDK_THREADS_LEAVE ();
return TRUE;
}
-
static void
play_back_wchunk_on (BstWaveEditor *self)
{
@@ -429,7 +381,6 @@ play_back_wchunk_on (BstWaveEditor *self)
gtk_widget_show (self->preview_on);
}
}
-
static void
play_back_button_clicked (BstWaveEditor *self)
{
@@ -438,20 +389,16 @@ play_back_button_clicked (BstWaveEditor *self)
else
play_back_wchunk_on (self);
}
-
static void
wave_editor_set_n_qsamplers (BstWaveEditor *self,
guint n_qsamplers)
{
GtkWidget *qsampler_parent = self->qsampler_parent;
-
if (!qsampler_parent)
n_qsamplers = 0;
-
if (self->n_qsamplers != n_qsamplers)
{
guint i;
-
/* playback position scale */
if (!self->qsampler_playpos && n_qsamplers)
{
@@ -503,7 +450,6 @@ wave_editor_set_n_qsamplers (BstWaveEditor *self,
adjustments_changed (self, self->zoom_adjustment);
adjustments_changed (self, self->vscale_adjustment);
}
-
void
bst_wave_editor_set_esample (BstWaveEditor *self,
SfiProxy esample)
@@ -511,14 +457,11 @@ bst_wave_editor_set_esample (BstWaveEditor *self,
g_return_if_fail (BST_IS_WAVE_EDITOR (self));
if (esample)
g_return_if_fail (BSE_IS_EDITABLE_SAMPLE (esample));
-
if (esample != self->esample)
{
guint i;
-
if (self->phandle)
play_back_wchunk_off (self);
-
if (self->esample)
{
if (self->esample_open)
@@ -536,7 +479,6 @@ bst_wave_editor_set_esample (BstWaveEditor *self,
g_message ("failed to open sample: %s", bse_error_blurb (error));
}
wave_editor_set_n_qsamplers (self, self->esample ? bse_editable_sample_get_n_channels (self->esample) : 0);
-
for (i = 0; i < self->n_qsamplers; i++)
if (self->esample)
{
@@ -547,35 +489,28 @@ bst_wave_editor_set_esample (BstWaveEditor *self,
bst_qsampler_set_source (self->qsamplers[i], 0, NULL, NULL, NULL);
}
}
-
GtkWidget*
bst_wave_editor_new (SfiProxy wave)
{
GtkWidget *widget;
-
widget = gtk_widget_new (BST_TYPE_WAVE_EDITOR,
"visible", TRUE,
NULL);
bst_wave_editor_set_wave (BST_WAVE_EDITOR (widget), wave);
-
return widget;
}
-
static void
tree_selection_changed (BstWaveEditor *self,
GtkTreeSelection *tsel)
{
GtkTreeModel *model;
GtkTreeIter iter;
-
if (gtk_tree_selection_get_selected (tsel, &model, &iter))
{
gchar *osc_str, *mix_str;
gfloat osc_freq, mix_freq;
SfiProxy esample;
-
g_assert (self->chunk_wrapper == (GxkListWrapper*) model);
-
gtk_tree_model_get (model, &iter,
COL_OSC_FREQ, &osc_str,
COL_MIX_FREQ, &mix_str,
@@ -584,13 +519,11 @@ tree_selection_changed (BstWaveEditor *self,
mix_freq = g_strtod (mix_str, NULL);
g_free (osc_str);
g_free (mix_str);
-
esample = bse_wave_use_editable (self->wave, gxk_list_wrapper_get_index (self->chunk_wrapper, &iter));
bst_wave_editor_set_esample (self, esample);
bse_item_unuse (esample);
}
}
-
static void
tree_row_activated (BstWaveEditor *self,
GtkTreePath *path,
@@ -598,23 +531,19 @@ tree_row_activated (BstWaveEditor *self,
GtkTreeView *tree_view)
{
// GtkTreeSelection *tsel = gtk_tree_view_get_selection (tree_view);
-
play_back_wchunk_on (self);
}
-
static void
change_scroll_mode (BstWaveEditor *self,
GtkOptionMenu *omenu)
{
self->auto_scroll_mode = bst_choice_get_last (omenu->menu);
}
-
static void
change_draw_mode (BstWaveEditor *self,
GtkOptionMenu *omenu)
{
guint i;
-
self->draw_mode = bst_choice_get_last (omenu->menu);
for (i = 0; i < self->n_qsamplers; i++)
{
@@ -622,24 +551,20 @@ change_draw_mode (BstWaveEditor *self,
bst_qsampler_set_draw_mode (qsampler, BstQSamplerDrawMode (self->draw_mode));
}
}
-
static void
adjustments_changed (BstWaveEditor *self,
GtkAdjustment *adjustment)
{
guint i;
-
for (i = 0; i < self->n_qsamplers; i++)
{
BstQSampler *qsampler = self->qsamplers[i];
-
if (adjustment == self->zoom_adjustment)
bst_qsampler_set_zoom (qsampler, adjustment->value);
else if (adjustment == self->vscale_adjustment)
bst_qsampler_set_vscale (qsampler, adjustment->value);
}
}
-
static void
playpos_changed (BstWaveEditor *self,
GtkAdjustment *adjustment)
@@ -654,7 +579,6 @@ playpos_changed (BstWaveEditor *self,
bst_play_back_handle_time_pcm_notify (self->phandle, 40); /* request quick update */
}
}
-
static void
wave_chunk_fill_value (BstWaveEditor *self,
guint column,
@@ -663,7 +587,6 @@ wave_chunk_fill_value (BstWaveEditor *self,
{
SfiProxy wave = self->wave;
guint cidx = row; /* wave chunk index */
-
switch (column)
{
const gchar *string;
diff --git a/beast-gtk/bstwaveeditor.hh b/beast-gtk/bstwaveeditor.hh
index 6ac1b36..3627035 100644
--- a/beast-gtk/bstwaveeditor.hh
+++ b/beast-gtk/bstwaveeditor.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_WAVE_EDITOR_H__
#define __BST_WAVE_EDITOR_H__
-
#include "bstqsampler.hh"
#include "bstplayback.hh"
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_WAVE_EDITOR (bst_wave_editor_get_type ())
#define BST_WAVE_EDITOR(object) (GTK_CHECK_CAST ((object), BST_TYPE_WAVE_EDITOR, BstWaveEditor))
@@ -17,8 +13,6 @@ extern "C" {
#define BST_IS_WAVE_EDITOR(object) (GTK_CHECK_TYPE ((object), BST_TYPE_WAVE_EDITOR))
#define BST_IS_WAVE_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_WAVE_EDITOR))
#define BST_WAVE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_WAVE_EDITOR, BstWaveEditorClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstWaveEditor BstWaveEditor;
typedef struct _BstWaveEditorClass BstWaveEditorClass;
@@ -26,7 +20,6 @@ struct _BstWaveEditor
{
GtkVBox parent_object;
GtkWidget *main_vbox;
-
GxkListWrapper *chunk_wrapper;
GtkWidget *tree;
GtkWidget *qsampler_parent;
@@ -34,7 +27,6 @@ struct _BstWaveEditor
GtkAdjustment *zoom_adjustment;
GtkAdjustment *vscale_adjustment;
guint draw_mode;
-
/* preview (playback) */
BstPlayBackHandle *phandle;
guint playback_length;
@@ -45,9 +37,7 @@ struct _BstWaveEditor
SfiNum tick_stamp;
guint pcm_pos;
gdouble pcm_per_tick;
-
SfiProxy wave;
-
/* editable sample view */
SfiProxy esample;
guint esample_open : 1;
@@ -61,8 +51,6 @@ struct _BstWaveEditorClass
{
GtkVBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType bst_wave_editor_get_type (void);
GtkWidget* bst_wave_editor_new (SfiProxy wave);
@@ -71,10 +59,7 @@ void bst_wave_editor_set_wave (BstWaveEditor *self,
void bst_wave_editor_rebuild (BstWaveEditor *wave_editor);
void bst_wave_editor_set_esample (BstWaveEditor *self,
SfiProxy editable_sample);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_WAVE_EDITOR_H__ */
diff --git a/beast-gtk/bstwaveview.cc b/beast-gtk/bstwaveview.cc
index 0cfc07a..67cfb97 100644
--- a/beast-gtk/bstwaveview.cc
+++ b/beast-gtk/bstwaveview.cc
@@ -4,16 +4,12 @@
#include "bstwaveeditor.hh"
#include "bstfiledialog.hh"
#include "bstsampleeditor.hh"
-
-
/* --- prototypes --- */
static void wave_view_action_exec (gpointer data,
gulong action);
static gboolean wave_view_action_check (gpointer data,
gulong action,
guint64 action_stamp);
-
-
/* --- wave actions --- */
enum {
ACTION_LOAD_WAVE,
@@ -32,19 +28,14 @@ static const GxkStockAction wave_view_actions[] = {
{ N_("Editor"), NULL, N_("Edit the currently selected wave"),
ACTION_EDIT_WAVE, BST_STOCK_EDIT_TOOL, },
};
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstWaveView, bst_wave_view, BST_TYPE_ITEM_VIEW);
-
static void
bst_wave_view_class_init (BstWaveViewClass *klass)
{
BstItemViewClass *item_view_class = BST_ITEM_VIEW_CLASS (klass);
-
item_view_class->item_type = "BseWave";
}
-
static void
bst_wave_view_init (BstWaveView *self)
{
@@ -60,43 +51,34 @@ bst_wave_view_init (BstWaveView *self)
/* prime locals */
self->editable = TRUE;
}
-
GtkWidget*
bst_wave_view_new (SfiProxy wrepo)
{
GtkWidget *wave_view;
-
g_return_val_if_fail (BSE_IS_WAVE_REPO (wrepo), NULL);
-
wave_view = gtk_widget_new (BST_TYPE_WAVE_VIEW, NULL);
bst_item_view_set_container (BST_ITEM_VIEW (wave_view), wrepo);
-
return wave_view;
}
-
static void
popup_wave_dialog (BstWaveView *wave_view)
{
SfiProxy wave = bst_item_view_get_current (BST_ITEM_VIEW (wave_view));
GtkWidget *weditor, *wdialog;
-
weditor = bst_wave_editor_new (wave);
wdialog = (GtkWidget*) gxk_dialog_new (NULL, GTK_OBJECT (wave_view), GXK_DIALOG_DELETE_BUTTON, NULL, weditor);
bst_window_sync_title_to_proxy (GXK_DIALOG (wdialog), wave, "%s");
gtk_widget_show (wdialog);
}
-
#if 0
static void
popup_wave_dialog (BstWaveView *wave_view)
{
SfiProxy wave = bst_item_view_get_current (BST_ITEM_VIEW (wave_view));
SfiProxy esample = bse_wave_use_editable (wave, 0);
-
if (esample)
{
GtkWidget *wdialog, *editor = bst_sample_editor_new (esample);
-
wdialog = gxk_dialog_new (NULL, GTK_OBJECT (wave_view), GXK_DIALOG_DELETE_BUTTON,
NULL,
editor);
@@ -107,22 +89,17 @@ popup_wave_dialog (BstWaveView *wave_view)
}
}
#endif
-
void
bst_wave_view_set_editable (BstWaveView *self,
gboolean enabled)
{
BstItemView *iview = BST_ITEM_VIEW (self);
-
g_return_if_fail (BST_IS_WAVE_VIEW (self));
-
self->editable = enabled != FALSE;
if (iview->tree)
gxk_tree_view_set_editable (iview->tree, self->editable);
-
gxk_widget_update_actions_downwards (self);
}
-
static void
wave_view_action_exec (gpointer data,
gulong action)
@@ -130,7 +107,6 @@ wave_view_action_exec (gpointer data,
BstWaveView *self = BST_WAVE_VIEW (data);
BstItemView *item_view = BST_ITEM_VIEW (self);
SfiProxy wrepo = item_view->container;
-
switch (action)
{
SfiProxy item;
@@ -152,7 +128,6 @@ wave_view_action_exec (gpointer data,
}
gxk_widget_update_actions_downwards (self);
}
-
static gboolean
wave_view_action_check (gpointer data,
gulong action,
diff --git a/beast-gtk/bstwaveview.hh b/beast-gtk/bstwaveview.hh
index c7c475c..c4db322 100644
--- a/beast-gtk/bstwaveview.hh
+++ b/beast-gtk/bstwaveview.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_WAVE_VIEW_H__
#define __BST_WAVE_VIEW_H__
-
#include "bstitemview.hh"
-
G_BEGIN_DECLS
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_WAVE_VIEW (bst_wave_view_get_type ())
#define BST_WAVE_VIEW(object) (GTK_CHECK_CAST ((object), BST_TYPE_WAVE_VIEW, BstWaveView))
@@ -14,8 +10,6 @@ G_BEGIN_DECLS
#define BST_IS_WAVE_VIEW(object) (GTK_CHECK_TYPE ((object), BST_TYPE_WAVE_VIEW))
#define BST_IS_WAVE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_WAVE_VIEW))
#define BST_WAVE_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_WAVE_VIEW, BstWaveViewClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstWaveView BstWaveView;
typedef struct _BstWaveViewClass BstWaveViewClass;
@@ -28,14 +22,10 @@ struct _BstWaveViewClass
{
BstItemViewClass parent_class;
};
-
-
/* --- prototypes --- */
GType bst_wave_view_get_type (void);
GtkWidget* bst_wave_view_new (SfiProxy wrepo);
void bst_wave_view_set_editable (BstWaveView *self,
gboolean enabled);
-
G_END_DECLS
-
#endif /* __BST_WAVE_VIEW_H__ */
diff --git a/beast-gtk/bstxframe.cc b/beast-gtk/bstxframe.cc
index 648a01d..6f428c1 100644
--- a/beast-gtk/bstxframe.cc
+++ b/beast-gtk/bstxframe.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh" /* for GScanner */
#include "bstxframe.hh"
-
-
enum {
PARAM_0,
PARAM_COVER,
PARAM_STEAL_BUTTON
};
-
-
/* --- prototypes --- */
static void bst_xframe_destroy (GtkObject *object);
static void bst_xframe_set_property (GObject *object,
@@ -37,26 +33,19 @@ static gint bst_xframe_leave_notify (GtkWidget *widget,
GdkEventCrossing *event);
static void bst_xframe_size_allocate_cover (GtkWidget *widget,
GtkAllocation *allocation);
-
-
/* --- variables --- */
static guint signal_button_check = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (BstXFrame, bst_xframe, GTK_TYPE_FRAME);
-
static void
bst_xframe_class_init (BstXFrameClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->set_property = bst_xframe_set_property;
gobject_class->get_property = bst_xframe_get_property;
object_class->destroy = bst_xframe_destroy;
-
widget_class->size_allocate = bst_xframe_size_allocate;
widget_class->realize = bst_xframe_realize;
widget_class->unrealize = bst_xframe_unrealize;
@@ -66,7 +55,6 @@ bst_xframe_class_init (BstXFrameClass *klass)
widget_class->button_release_event = bst_xframe_button_release;
widget_class->enter_notify_event = bst_xframe_enter_notify;
widget_class->leave_notify_event = bst_xframe_leave_notify;
-
g_object_class_install_property (gobject_class, PARAM_COVER,
g_param_spec_object ("cover", "Cover", NULL,
GTK_TYPE_WIDGET,
@@ -83,7 +71,6 @@ bst_xframe_class_init (BstXFrameClass *klass)
bst_marshal_BOOLEAN__UINT,
G_TYPE_BOOLEAN, 1, G_TYPE_UINT);
}
-
static void
bst_xframe_init (BstXFrame *xframe)
{
@@ -94,18 +81,14 @@ bst_xframe_init (BstXFrame *xframe)
xframe->entered = FALSE;
g_object_set (xframe, "visible", TRUE, "shadow_type", GTK_SHADOW_NONE, NULL);
}
-
static void
bst_xframe_destroy (GtkObject *object)
{
BstXFrame *xframe = BST_XFRAME (object);
-
if (xframe->cover)
bst_xframe_set_cover_widget (xframe, NULL, FALSE);
-
GTK_OBJECT_CLASS (bst_xframe_parent_class)->destroy (object);
}
-
static void
bst_xframe_set_property (GObject *object,
guint prop_id,
@@ -113,7 +96,6 @@ bst_xframe_set_property (GObject *object,
GParamSpec *pspec)
{
BstXFrame *xframe = BST_XFRAME (object);
-
switch (prop_id)
{
case PARAM_COVER:
@@ -127,7 +109,6 @@ bst_xframe_set_property (GObject *object,
break;
}
}
-
static void
bst_xframe_get_property (GObject *object,
guint prop_id,
@@ -135,7 +116,6 @@ bst_xframe_get_property (GObject *object,
GParamSpec *pspec)
{
BstXFrame *xframe = BST_XFRAME (object);
-
switch (prop_id)
{
case PARAM_COVER:
@@ -149,14 +129,12 @@ bst_xframe_get_property (GObject *object,
break;
}
}
-
static void
bst_xframe_resize (BstXFrame *xframe)
{
if (GTK_WIDGET_REALIZED (xframe))
{
GtkAllocation a = GTK_WIDGET (xframe)->allocation;
-
if (FALSE && xframe->allocation_valid)
{
a.width = MAX (a.x + a.width, xframe->cover->allocation.x + xframe->cover->allocation.width);
@@ -170,27 +148,21 @@ bst_xframe_resize (BstXFrame *xframe)
gdk_window_lower (xframe->iwindow);
}
}
-
static void
bst_xframe_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
GTK_WIDGET_CLASS (bst_xframe_parent_class)->size_allocate (widget, allocation);
-
bst_xframe_resize (xframe);
}
-
static void
bst_xframe_realize (GtkWidget *widget)
{
BstXFrame *xframe = BST_XFRAME (widget);
GdkWindowAttr attributes;
gint attributes_mask;
-
GTK_WIDGET_CLASS (bst_xframe_parent_class)->realize (widget);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -204,127 +176,99 @@ bst_xframe_realize (GtkWidget *widget)
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
-
xframe->iwindow = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (xframe->iwindow, xframe);
}
-
static void
bst_xframe_unrealize (GtkWidget *widget)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
gdk_window_set_user_data (xframe->iwindow, NULL);
gdk_window_destroy (xframe->iwindow);
xframe->iwindow = NULL;
-
GTK_WIDGET_CLASS (bst_xframe_parent_class)->unrealize (widget);
}
-
static void
bst_xframe_map (GtkWidget *widget)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
GTK_WIDGET_CLASS (bst_xframe_parent_class)->map (widget);
-
gdk_window_show (xframe->iwindow);
gdk_window_lower (xframe->iwindow);
}
-
static void
bst_xframe_unmap (GtkWidget *widget)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
gdk_window_hide (xframe->iwindow);
-
GTK_WIDGET_CLASS (bst_xframe_parent_class)->unmap (widget);
}
-
static gint
bst_xframe_button_press (GtkWidget *widget,
GdkEventButton *event)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
if (!xframe->button_down && xframe->entered)
{
xframe->button_down = event->button;
return TRUE;
}
-
return FALSE;
}
-
static gint
bst_xframe_button_release (GtkWidget *widget,
GdkEventButton *event)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
if (event->button == xframe->button_down)
{
gboolean valid = FALSE;
-
if (xframe->entered)
g_signal_emit (widget, signal_button_check, 0, xframe->button_down, &valid);
xframe->button_down = 0;
return TRUE;
}
-
return FALSE;
}
-
static gint
bst_xframe_enter_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
if (GTK_WIDGET_IS_SENSITIVE (widget) &&
(!GTK_BIN (widget)->child || GTK_WIDGET_IS_SENSITIVE (GTK_BIN (widget)->child)))
{
gboolean valid = FALSE;
-
g_signal_emit (widget, signal_button_check, 0, 0, &valid);
-
if (valid)
{
g_object_set (xframe, "shadow_type", GTK_SHADOW_ETCHED_OUT, NULL);
xframe->entered = TRUE;
}
}
-
return FALSE;
}
-
static gint
bst_xframe_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
g_object_set (xframe, "shadow_type", GTK_SHADOW_NONE, NULL);
xframe->entered = FALSE;
-
return FALSE;
}
-
static void
bst_xframe_size_allocate_cover (GtkWidget *widget,
GtkAllocation *allocation)
{
BstXFrame *xframe = BST_XFRAME (widget);
-
xframe->allocation_valid = (GTK_WIDGET_VISIBLE (xframe->cover) &&
xframe->cover->window &&
gdk_window_is_viewable (xframe->cover->window));
xframe->allocation = xframe->cover->allocation;
bst_xframe_resize (xframe);
}
-
void
bst_xframe_set_cover_widget (BstXFrame *xframe,
GtkWidget *widget,
@@ -333,7 +277,6 @@ bst_xframe_set_cover_widget (BstXFrame *xframe,
g_return_if_fail (BST_IS_XFRAME (xframe));
if (widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (xframe->cover)
{
g_signal_handlers_disconnect_by_func (xframe->cover, (void*) bst_xframe_size_allocate_cover, xframe);
diff --git a/beast-gtk/bstxframe.hh b/beast-gtk/bstxframe.hh
index 6859428..a0bac01 100644
--- a/beast-gtk/bstxframe.hh
+++ b/beast-gtk/bstxframe.hh
@@ -1,22 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_XFRAME_H__
#define __BST_XFRAME_H__
-
#include <gtk/gtkframe.h>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
#define BST_TYPE_XFRAME (bst_xframe_get_type ())
#define BST_XFRAME(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_XFRAME, BstXFrame))
#define BST_XFRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BST_TYPE_XFRAME, BstXFrameClass))
#define BST_IS_XFRAME(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_XFRAME))
#define BST_IS_XFRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_XFRAME))
#define BST_XFRAME_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((obj), BST_TYPE_XFRAME, BstXFrameClass))
-
-
typedef struct _BstXFrame BstXFrame;
typedef struct _BstXFrameClass BstXFrameClass;
struct _BstXFrame
@@ -33,20 +27,14 @@ struct _BstXFrame
struct _BstXFrameClass
{
GtkFrameClass parent_class;
-
gboolean (*button_check) (BstXFrame *xframe,
guint button);
};
-
-
GType bst_xframe_get_type (void);
void bst_xframe_set_cover_widget (BstXFrame *xframe,
GtkWidget *widget,
gboolean steal_button);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_XFRAME_H__ */
-
diff --git a/beast-gtk/bstxkb.cc b/beast-gtk/bstxkb.cc
index 82fddb5..fb4af7d 100644
--- a/beast-gtk/bstxkb.cc
+++ b/beast-gtk/bstxkb.cc
@@ -1,21 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstxkb.hh"
-
#include "topconfig.h"
#include <string.h>
-
#ifdef BST_WITH_XKB
-
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
-
-
/* --- variables --- */
static Display *bst_xkb_display = NULL;
static XkbDescPtr bst_xkb_desc = NULL;
-
-
/* --- functions --- */
gboolean
bst_xkb_open (const gchar *const_display,
@@ -25,10 +18,8 @@ bst_xkb_open (const gchar *const_display,
int ext_base_event, ext_base_error, ext_status;
int ext_major = XkbMajorVersion;
int ext_minor = XkbMinorVersion;
-
g_return_val_if_fail (display != NULL, FALSE);
g_return_val_if_fail (bst_xkb_display == NULL, FALSE);
-
bst_xkb_display = XkbOpenDisplay (display,
&ext_base_event,
&ext_base_error,
@@ -62,41 +53,32 @@ bst_xkb_open (const gchar *const_display,
XCloseDisplay (bst_xkb_display);
bst_xkb_display = NULL;
}
-
return bst_xkb_desc != NULL;
}
-
void
bst_xkb_close (void)
{
g_return_if_fail (bst_xkb_display != NULL);
-
XkbFreeKeyboard (bst_xkb_desc, XkbAllComponentsMask, True);
bst_xkb_desc = NULL;
XCloseDisplay (bst_xkb_display);
bst_xkb_display = NULL;
}
-
const gchar*
bst_xkb_get_symbol (gboolean physical)
{
gchar *name;
-
g_return_val_if_fail (bst_xkb_desc != NULL, NULL);
-
if (physical)
name = bst_xkb_desc->names->phys_symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->phys_symbols) : "";
else
name = bst_xkb_desc->names->symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->symbols) : "";
-
return name;
}
-
void
bst_xkb_dump (void)
{
g_return_if_fail (bst_xkb_desc != NULL);
-
g_message ("XKB: keycodes: %s types: %s "
"symbols: %s phys_symbols: %s "
"geo-name: %s",
@@ -105,7 +87,6 @@ bst_xkb_dump (void)
bst_xkb_desc->names->symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->symbols) : "<>",
bst_xkb_desc->names->phys_symbols ? XGetAtomName (bst_xkb_display, bst_xkb_desc->names->phys_symbols) : "<>",
bst_xkb_desc->geom->name ? XGetAtomName (bst_xkb_display, bst_xkb_desc->geom->name) : "<>");
-
/* Tim Janik <timj gtk org>:
* keycodes: xfree86 types: complete
* symbols: en_US(pc102)_de(nodeadkeys) phys_symbols: en_US(pc102)_de(nodeadkeys)
@@ -128,7 +109,6 @@ bst_xkb_dump (void)
* geo-name: pc(pc101)
*/
}
-
#else /* !BST_WITH_XKB */
gboolean
bst_xkb_open (const gchar *display,
@@ -149,9 +129,7 @@ bst_xkb_get_symbol (gboolean physical)
{
return NULL;
}
-
#endif /* !BST_WITH_XKB */
-
void
bst_xkb_parse_symbol (const gchar *const_symbol,
gchar **encoding_p,
@@ -160,9 +138,7 @@ bst_xkb_parse_symbol (const gchar *const_symbol,
gchar **variant_p)
{
const char *s, *e, *symbol = const_symbol ? (gchar*) const_symbol : "";
-
e = symbol + strlen (symbol);
-
s = strchr (symbol, '(');
if (encoding_p)
*encoding_p = s ? g_strndup (symbol, s - symbol) : *symbol ? g_strdup (symbol) : NULL;
diff --git a/beast-gtk/bstxkb.hh b/beast-gtk/bstxkb.hh
index a98f1f4..33af82c 100644
--- a/beast-gtk/bstxkb.hh
+++ b/beast-gtk/bstxkb.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_XKB_H__
#define __BST_XKB_H__
-
#include <glib.h>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- prototypes --- */
gboolean bst_xkb_open (const gchar *display,
gboolean sync);
@@ -20,14 +16,7 @@ void bst_xkb_parse_symbol (const gchar *symbol,
gchar **model_p,
gchar **layout_p,
gchar **variant_p);
-
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_XKB_H__ */
diff --git a/beast-gtk/bstzoomedwindow.cc b/beast-gtk/bstzoomedwindow.cc
index 74d2a0a..dbe33c9 100644
--- a/beast-gtk/bstzoomedwindow.cc
+++ b/beast-gtk/bstzoomedwindow.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh" /* for marshallers */
#include "bstzoomedwindow.hh"
-
#include <gtk/gtktogglebutton.h>
#include <gtk/gtksignal.h>
-
-
/* --- signals --- */
enum {
SIGNAL_ZOOM,
@@ -14,8 +11,6 @@ enum {
typedef gboolean (*SignalZoom) (GtkObject *object,
gboolean zoom_in,
gpointer func_data);
-
-
/* --- prototypes --- */
static void bst_zoomed_window_class_init (BstZoomedWindowClass *klass);
static void bst_zoomed_window_init (BstZoomedWindow *zoomed_window);
@@ -32,20 +27,15 @@ static void bst_zoomed_window_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
static void bst_zoomed_window_clicked (BstZoomedWindow *zoomed_window);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static BstZoomedWindowClass *bst_zoomed_window_class = NULL;
static guint zoomed_window_signals[SIGNAL_LAST] = { 0 };
-
-
/* --- functions --- */
GtkType
bst_zoomed_window_get_type (void)
{
static GtkType zoomed_window_type = 0;
-
if (!zoomed_window_type)
{
GtkTypeInfo zoomed_window_info =
@@ -59,36 +49,26 @@ bst_zoomed_window_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
zoomed_window_type = gtk_type_unique (GTK_TYPE_SCROLLED_WINDOW, &zoomed_window_info);
}
-
return zoomed_window_type;
}
-
static void
bst_zoomed_window_class_init (BstZoomedWindowClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
bst_zoomed_window_class = klass;
parent_class = g_type_class_peek_parent (klass);
-
G_OBJECT_CLASS (object_class)->finalize = bst_zoomed_window_finalize;
-
object_class->destroy = bst_zoomed_window_destroy;
-
widget_class->map = bst_zoomed_window_map;
widget_class->unmap = bst_zoomed_window_unmap;
widget_class->size_request = bst_zoomed_window_size_request;
widget_class->size_allocate = bst_zoomed_window_size_allocate;
-
container_class->forall = bst_zoomed_window_forall;
-
klass->zoom = NULL;
-
zoomed_window_signals[SIGNAL_ZOOM] =
gtk_signal_new ("zoom",
GTK_RUN_LAST,
@@ -98,16 +78,13 @@ bst_zoomed_window_class_init (BstZoomedWindowClass *klass)
GTK_TYPE_BOOL,
1, GTK_TYPE_BOOL);
}
-
static void
bst_zoomed_window_init (BstZoomedWindow *zoomed_window)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (zoomed_window);
-
/* default construct */
gtk_scrolled_window_set_hadjustment (scrolled_window, NULL);
gtk_scrolled_window_set_vadjustment (scrolled_window, NULL);
-
gtk_widget_push_composite_child ();
zoomed_window->toggle_button = gtk_widget_new (GTK_TYPE_TOGGLE_BUTTON,
"visible", TRUE,
@@ -119,91 +96,72 @@ bst_zoomed_window_init (BstZoomedWindow *zoomed_window)
gtk_widget_set_parent (zoomed_window->toggle_button, GTK_WIDGET (zoomed_window));
gtk_widget_pop_composite_child ();
}
-
static void
bst_zoomed_window_destroy (GtkObject *object)
{
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (object);
-
if (zoomed_window->toggle_button)
{
gtk_widget_unparent (zoomed_window->toggle_button);
zoomed_window->toggle_button = NULL;
}
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
bst_zoomed_window_finalize (GObject *object)
{
/* BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (object); */
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bst_zoomed_window_map (GtkWidget *widget)
{
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (widget);
-
/* chain parent class handler to map self and children */
GTK_WIDGET_CLASS (parent_class)->map (widget);
-
if (zoomed_window->toggle_button &&
GTK_WIDGET_VISIBLE (zoomed_window->toggle_button) &&
!GTK_WIDGET_MAPPED (zoomed_window->toggle_button))
gtk_widget_map (zoomed_window->toggle_button);
}
-
static void
bst_zoomed_window_unmap (GtkWidget *widget)
{
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (widget);
-
/* chain parent class handler to unmap self and children */
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
if (zoomed_window->toggle_button &&
GTK_WIDGET_MAPPED (zoomed_window->toggle_button))
gtk_widget_unmap (zoomed_window->toggle_button);
}
-
static void
bst_zoomed_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (widget);
-
if (zoomed_window->toggle_button)
gtk_widget_size_request (zoomed_window->toggle_button, NULL);
-
/* chain parent class handler for requisition */
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
}
-
static void
bst_zoomed_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (widget);
-
/* chain parent class handler to layout children */
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
if (zoomed_window->toggle_button)
{
if (scrolled_window->hscrollbar && GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar) &&
scrolled_window->vscrollbar && GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
{
GtkAllocation child_allocation;
-
child_allocation.x = scrolled_window->vscrollbar->allocation.x;
child_allocation.y = scrolled_window->hscrollbar->allocation.y;
child_allocation.width = scrolled_window->vscrollbar->allocation.width;
child_allocation.height = scrolled_window->hscrollbar->allocation.height;
-
gtk_widget_size_allocate (zoomed_window->toggle_button, &child_allocation);
gtk_widget_show (zoomed_window->toggle_button);
}
@@ -211,7 +169,6 @@ bst_zoomed_window_size_allocate (GtkWidget *widget,
gtk_widget_hide (zoomed_window->toggle_button);
}
}
-
static void
bst_zoomed_window_forall (GtkContainer *container,
gboolean include_internals,
@@ -219,7 +176,6 @@ bst_zoomed_window_forall (GtkContainer *container,
gpointer callback_data)
{
BstZoomedWindow *zoomed_window = BST_ZOOMED_WINDOW (container);
-
GTK_CONTAINER_CLASS (parent_class)->forall (container,
include_internals,
callback,
@@ -227,12 +183,10 @@ bst_zoomed_window_forall (GtkContainer *container,
if (include_internals && zoomed_window->toggle_button)
callback (zoomed_window->toggle_button, callback_data);
}
-
static void
bst_zoomed_window_clicked (BstZoomedWindow *zoomed_window)
{
gboolean stay_active = GTK_TOGGLE_BUTTON (zoomed_window->toggle_button)->active;
-
gtk_widget_ref (GTK_WIDGET (zoomed_window));
gtk_signal_emit (GTK_OBJECT (zoomed_window),
zoomed_window_signals[SIGNAL_ZOOM],
diff --git a/beast-gtk/bstzoomedwindow.hh b/beast-gtk/bstzoomedwindow.hh
index fcf9dbf..20888b1 100644
--- a/beast-gtk/bstzoomedwindow.hh
+++ b/beast-gtk/bstzoomedwindow.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BST_ZOOMED_WINDOW_H__
#define __BST_ZOOMED_WINDOW_H__
-
#include <gtk/gtkscrolledwindow.h>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- Gtk+ type macros --- */
#define BST_TYPE_ZOOMED_WINDOW (bst_zoomed_window_get_type ())
#define BST_ZOOMED_WINDOW(object) (GTK_CHECK_CAST ((object), BST_TYPE_ZOOMED_WINDOW, BstZoomedWindow))
@@ -17,32 +12,23 @@ extern "C" {
#define BST_IS_ZOOMED_WINDOW(object) (GTK_CHECK_TYPE ((object), BST_TYPE_ZOOMED_WINDOW))
#define BST_IS_ZOOMED_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_ZOOMED_WINDOW))
#define BST_ZOOMED_WINDOW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BST_TYPE_ZOOMED_WINDOW, BstZoomedWindowClass))
-
-
/* --- structures & typedefs --- */
typedef struct _BstZoomedWindow BstZoomedWindow;
typedef struct _BstZoomedWindowClass BstZoomedWindowClass;
struct _BstZoomedWindow
{
GtkScrolledWindow parent_object;
-
GtkWidget *toggle_button;
};
struct _BstZoomedWindowClass
{
GtkScrolledWindowClass parent_class;
-
gboolean (*zoom) (BstZoomedWindow *zoomed_window,
gboolean zoom_in);
};
-
-
/* --- prototypes --- */
GtkType bst_zoomed_window_get_type (void);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BST_ZOOMED_WINDOW_H__ */
diff --git a/beast-gtk/gxk/glewidgets.c b/beast-gtk/gxk/glewidgets.c
index 8bb6262..2734f5a 100644
--- a/beast-gtk/gxk/glewidgets.c
+++ b/beast-gtk/gxk/glewidgets.c
@@ -2,7 +2,6 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
@@ -25,10 +24,7 @@
* Boston, MA 02111-1307, USA.
*/
/* #include <math.h> */
-
/* #include "gtkwrapbox.h" */
-
-
/* --- arguments --- */
enum {
ARG__gtkwrapbox_0,
@@ -50,8 +46,6 @@ enum {
CHILD_PROP_VFILL,
CHILD_PROP_WRAPPED
};
-
-
/* --- prototypes --- */
static void gtk_wrap_box_class_init (GtkWrapBoxClass *klass);
static void gtk_wrap_box_init (GtkWrapBox *wbox);
@@ -84,18 +78,13 @@ static void gtk_wrap_box_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
static GtkType gtk_wrap_box_child_type (GtkContainer *container);
-
-
/* --- variables --- */
static gpointer parent_gtkwrapbox_class = NULL;
-
-
/* --- functions --- */
GtkType
gtk_wrap_box_get_type (void)
{
static GtkType wrap_box_type = 0;
-
if (!wrap_box_type)
{
static const GtkTypeInfo wrap_box_info =
@@ -109,42 +98,32 @@ gtk_wrap_box_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
wrap_box_type = gtk_type_unique (GTK_TYPE_CONTAINER, &wrap_box_info);
}
-
return wrap_box_type;
}
-
static void
gtk_wrap_box_class_init (GtkWrapBoxClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
-
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
container_class = GTK_CONTAINER_CLASS (klass);
-
parent_gtkwrapbox_class = g_type_class_peek_parent (klass);
-
object_class->set_arg = gtk_wrap_box_set_arg;
object_class->get_arg = gtk_wrap_box_get_arg;
-
widget_class->map = gtk_wrap_box_map;
widget_class->unmap = gtk_wrap_box_unmap;
widget_class->expose_event = gtk_wrap_box_expose;
-
container_class->add = gtk_wrap_box_add;
container_class->remove = gtk_wrap_box_remove;
container_class->forall = gtk_wrap_box_forall;
container_class->child_type = gtk_wrap_box_child_type;
container_class->set_child_property = gtk_wrap_box_set_child_property;
container_class->get_child_property = gtk_wrap_box_get_child_property;
-
klass->rlist_line_children = NULL;
-
gtk_object_add_arg_type ("GtkWrapBox::homogeneous",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG__gtkwrapbox_HOMOGENEOUS);
gtk_object_add_arg_type ("GtkWrapBox::justify",
@@ -161,7 +140,6 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *klass)
GTK_TYPE_FLOAT, GTK_ARG_READABLE, ARG__gtkwrapbox_CURRENT_RATIO);
gtk_object_add_arg_type ("GtkWrapBox::max_children_per_line",
GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG__gtkwrapbox_CHILD_LIMIT);
-
gtk_container_class_install_child_property (container_class, CHILD_PROP_POSITION,
g_param_spec_int ("position", NULL, NULL,
-1, G_MAXINT, 0,
@@ -187,12 +165,10 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *klass)
FALSE,
G_PARAM_READWRITE));
}
-
static void
gtk_wrap_box_init (GtkWrapBox *wbox)
{
GTK_WIDGET_SET_FLAGS (wbox, GTK_NO_WINDOW);
-
wbox->homogeneous = FALSE;
wbox->hspacing = 0;
wbox->vspacing = 0;
@@ -203,14 +179,12 @@ gtk_wrap_box_init (GtkWrapBox *wbox)
wbox->aspect_ratio = 1;
wbox->child_limit = 32767;
}
-
static void
gtk_wrap_box_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (object);
-
switch (arg_id)
{
case ARG__gtkwrapbox_HOMOGENEOUS:
@@ -240,7 +214,6 @@ gtk_wrap_box_set_arg (GtkObject *object,
break;
}
}
-
static void
gtk_wrap_box_get_arg (GtkObject *object,
GtkArg *arg,
@@ -248,7 +221,6 @@ gtk_wrap_box_get_arg (GtkObject *object,
{
GtkWrapBox *wbox = GTK_WRAP_BOX (object);
GtkWidget *widget = GTK_WIDGET (object);
-
switch (arg_id)
{
case ARG__gtkwrapbox_HOMOGENEOUS:
@@ -281,7 +253,6 @@ gtk_wrap_box_get_arg (GtkObject *object,
break;
}
}
-
static void
gtk_wrap_box_set_child_property (GtkContainer *container,
GtkWidget *child,
@@ -291,10 +262,8 @@ gtk_wrap_box_set_child_property (GtkContainer *container,
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
-
if (property_id != CHILD_PROP_POSITION)
gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
-
switch (property_id)
{
case CHILD_PROP_POSITION:
@@ -335,7 +304,6 @@ gtk_wrap_box_set_child_property (GtkContainer *container,
break;
}
}
-
static void
gtk_wrap_box_get_child_property (GtkContainer *container,
GtkWidget *child,
@@ -345,10 +313,8 @@ gtk_wrap_box_get_child_property (GtkContainer *container,
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE, wrapped = FALSE;
-
if (property_id != CHILD_PROP_POSITION)
gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill, &wrapped);
-
switch (property_id)
{
GtkWrapBoxChild *child_info;
@@ -383,19 +349,16 @@ gtk_wrap_box_get_child_property (GtkContainer *container,
break;
}
}
-
static GtkType
gtk_wrap_box_child_type (GtkContainer *container)
{
return GTK_TYPE_WIDGET;
}
-
void
gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
gboolean homogeneous)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
homogeneous = homogeneous != FALSE;
if (wbox->homogeneous != homogeneous)
{
@@ -403,76 +366,64 @@ gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_set_hspacing (GtkWrapBox *wbox,
guint hspacing)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
if (wbox->hspacing != hspacing)
{
wbox->hspacing = hspacing;
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_set_vspacing (GtkWrapBox *wbox,
guint vspacing)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
if (wbox->vspacing != vspacing)
{
wbox->vspacing = vspacing;
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_set_justify (GtkWrapBox *wbox,
GtkJustification justify)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (justify <= GTK_JUSTIFY_FILL);
-
if (wbox->justify != justify)
{
wbox->justify = justify;
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_set_line_justify (GtkWrapBox *wbox,
GtkJustification line_justify)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (line_justify <= GTK_JUSTIFY_FILL);
-
if (wbox->line_justify != line_justify)
{
wbox->line_justify = line_justify;
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox,
gfloat aspect_ratio)
{
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
-
aspect_ratio = CLAMP (aspect_ratio, 1.0 / 256.0, 256.0);
-
if (wbox->aspect_ratio != aspect_ratio)
{
wbox->aspect_ratio = aspect_ratio;
gtk_widget_queue_resize (GTK_WIDGET (wbox));
}
}
-
void
gtk_wrap_box_pack (GtkWrapBox *wbox,
GtkWidget *child,
@@ -484,10 +435,8 @@ gtk_wrap_box_pack (GtkWrapBox *wbox,
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == NULL);
-
gtk_wrap_box_pack_wrapped (wbox, child, hexpand, hfill, vexpand, vfill, FALSE);
}
-
void
gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
GtkWidget *child,
@@ -498,11 +447,9 @@ gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
gboolean wrapped)
{
GtkWrapBoxChild *child_info;
-
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == NULL);
-
child_info = g_new (GtkWrapBoxChild, 1);
child_info->widget = child;
child_info->hexpand = hexpand ? TRUE : FALSE;
@@ -514,7 +461,6 @@ gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
if (wbox->children)
{
GtkWrapBoxChild *last = wbox->children;
-
while (last->next)
last = last->next;
last->next = child_info;
@@ -522,44 +468,34 @@ gtk_wrap_box_pack_wrapped (GtkWrapBox *wbox,
else
wbox->children = child_info;
wbox->n_children++;
-
gtk_widget_set_parent (child, GTK_WIDGET (wbox));
-
if (GTK_WIDGET_REALIZED (wbox))
gtk_widget_realize (child);
-
if (GTK_WIDGET_VISIBLE (wbox) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (wbox))
gtk_widget_map (child);
-
gtk_widget_queue_resize (child);
}
}
-
void
gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
GtkWidget *child,
gint position)
{
GtkWrapBoxChild *child_info, *last = NULL;
-
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
for (child_info = wbox->children; child_info; last = child_info, child_info = last->next)
if (child_info->widget == child)
break;
-
if (child_info && wbox->children->next)
{
GtkWrapBoxChild *tmp;
-
if (last)
last->next = child_info->next;
else
wbox->children = child_info->next;
-
last = NULL;
tmp = wbox->children;
while (position && tmp->next)
@@ -568,7 +504,6 @@ gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
last = tmp;
tmp = last->next;
}
-
if (position)
{
tmp->next = child_info;
@@ -582,12 +517,10 @@ gtk_wrap_box_reorder_child (GtkWrapBox *wbox,
else
wbox->children = child_info;
}
-
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
gtk_widget_queue_resize (child);
}
}
-
void
gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
@@ -598,14 +531,11 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
gboolean *wrapped)
{
GtkWrapBoxChild *child_info;
-
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
-
if (child_info)
{
if (hexpand)
@@ -620,7 +550,6 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
*wrapped = child_info->wrapped;
}
}
-
void
gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
@@ -631,20 +560,16 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
gboolean wrapped)
{
GtkWrapBoxChild *child_info;
-
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
-
hexpand = hexpand != FALSE;
hfill = hfill != FALSE;
vexpand = vexpand != FALSE;
vfill = vfill != FALSE;
wrapped = wrapped != FALSE;
-
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
-
if (child_info &&
(child_info->hexpand != hexpand || child_info->vexpand != vexpand ||
child_info->hfill != hfill || child_info->vfill != vfill ||
@@ -655,12 +580,10 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
child_info->vexpand = vexpand;
child_info->vfill = vfill;
child_info->wrapped = wrapped;
-
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
gtk_widget_queue_resize (child);
}
}
-
guint*
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *_n_lines)
@@ -670,18 +593,15 @@ gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
gboolean expand_line;
GSList *slist;
guint max_child_size, border, n_lines = 0, *lines = NULL;
-
if (_n_lines)
*_n_lines = 0;
g_return_val_if_fail (GTK_IS_WRAP_BOX (wbox), NULL);
-
allocation = >K_WIDGET (wbox)->allocation;
border = GTK_CONTAINER (wbox)->border_width;
area.x = allocation->x + border;
area.y = allocation->y + border;
area.width = MAX (1, (gint) allocation->width - border * 2);
area.height = MAX (1, (gint) allocation->height - border * 2);
-
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
@@ -691,101 +611,81 @@ gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
while (slist)
{
guint l = n_lines++;
-
lines = g_renew (guint, lines, n_lines);
lines[l] = g_slist_length (slist);
g_slist_free (slist);
-
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
&area,
&max_child_size,
&expand_line);
}
-
if (_n_lines)
*_n_lines = n_lines;
-
return lines;
}
-
static void
gtk_wrap_box_map (GtkWidget *widget)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
-
GTK_WIDGET_SET_FLAGS (wbox, GTK_MAPPED);
-
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
-
static void
gtk_wrap_box_unmap (GtkWidget *widget)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
-
GTK_WIDGET_UNSET_FLAGS (wbox, GTK_MAPPED);
-
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget) &&
GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
-
static gint
gtk_wrap_box_expose (GtkWidget *widget,
GdkEventExpose *event)
{
return GTK_WIDGET_CLASS (parent_gtkwrapbox_class)->expose_event (widget, event);
}
-
static void
gtk_wrap_box_add (GtkContainer *container,
GtkWidget *widget)
{
gtk_wrap_box_pack (GTK_WRAP_BOX (container), widget, FALSE, TRUE, FALSE, TRUE);
}
-
static void
gtk_wrap_box_remove (GtkContainer *container,
GtkWidget *widget)
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
GtkWrapBoxChild *child, *last = NULL;
-
child = wbox->children;
while (child)
{
if (child->widget == widget)
{
gboolean was_visible;
-
was_visible = GTK_WIDGET_VISIBLE (widget);
gtk_widget_unparent (widget);
-
if (last)
last->next = child->next;
else
wbox->children = child->next;
g_free (child);
wbox->n_children--;
-
if (was_visible)
gtk_widget_queue_resize (GTK_WIDGET (container));
-
break;
}
-
last = child;
child = last->next;
}
}
-
static void
gtk_wrap_box_forall (GtkContainer *container,
gboolean include_internals,
@@ -794,14 +694,11 @@ gtk_wrap_box_forall (GtkContainer *container,
{
GtkWrapBox *wbox = GTK_WRAP_BOX (container);
GtkWrapBoxChild *child;
-
child = wbox->children;
while (child)
{
GtkWidget *widget = child->widget;
-
child = child->next;
-
callback (widget, callback_data);
}
}
@@ -828,8 +725,6 @@ gtk_wrap_box_forall (GtkContainer *container,
*/
/* #include "gtkhwrapbox.h" */
/* #include <math.h> */
-
-
/* --- prototypes --- */
static void gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass);
static void gtk_hwrap_box_init (GtkHWrapBox *hwbox);
@@ -842,18 +737,13 @@ static GSList* reverse_list_row_children (GtkWrapBox *wbox,
GtkAllocation *area,
guint *max_height,
gboolean *can_vexpand);
-
-
/* --- variables --- */
static gpointer parent_gtkhwrapbox_class = NULL;
-
-
/* --- functions --- */
GtkType
gtk_hwrap_box_get_type (void)
{
static GtkType hwrap_box_type = 0;
-
if (!hwrap_box_type)
{
static const GtkTypeInfo hwrap_box_info =
@@ -867,13 +757,10 @@ gtk_hwrap_box_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
hwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &hwrap_box_info);
}
-
return hwrap_box_type;
}
-
static void
gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass)
{
@@ -881,39 +768,29 @@ gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass)
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWrapBoxClass *wrap_box_class;
-
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
container_class = GTK_CONTAINER_CLASS (klass);
wrap_box_class = GTK_WRAP_BOX_CLASS (klass);
-
parent_gtkhwrapbox_class = gtk_type_class (GTK_TYPE_WRAP_BOX);
-
widget_class->size_request = gtk_hwrap_box_size_request;
widget_class->size_allocate = gtk_hwrap_box_size_allocate;
-
wrap_box_class->rlist_line_children = reverse_list_row_children;
}
-
static void
gtk_hwrap_box_init (GtkHWrapBox *hwbox)
{
hwbox->max_child_width = 0;
hwbox->max_child_height = 0;
}
-
GtkWidget*
gtk_hwrap_box_new (gboolean homogeneous)
{
GtkHWrapBox *hwbox;
-
hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL));
-
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
-
return GTK_WIDGET (hwbox);
}
-
static inline void
get_gtkhwrapbox_child_requisition (GtkWrapBox *wbox,
GtkWidget *child,
@@ -922,14 +799,12 @@ get_gtkhwrapbox_child_requisition (GtkWrapBox *wbox,
if (wbox->homogeneous)
{
GtkHWrapBox *hwbox = GTK_HWRAP_BOX (wbox);
-
child_requisition->width = hwbox->max_child_width;
child_requisition->height = hwbox->max_child_height;
}
else
gtk_widget_get_child_requisition (child, child_requisition);
}
-
static void
_gtk_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -938,29 +813,23 @@ _gtk_hwrap_box_size_request (GtkWidget *widget,
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
guint area = 0;
-
g_return_if_fail (requisition != NULL);
-
/*<h2v-off>*/
requisition->width = 0;
requisition->height = 0;
this->max_child_width = 0;
this->max_child_height = 0;
-
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
-
gtk_widget_size_request (child->widget, &child_requisition);
-
area += child_requisition.width * child_requisition.height;
this->max_child_width = MAX (this->max_child_width, child_requisition.width);
this->max_child_height = MAX (this->max_child_height, child_requisition.height);
}
if (wbox->homogeneous)
area = this->max_child_width * this->max_child_height * wbox->n_children;
-
if (area)
{
requisition->width = sqrt (area * wbox->aspect_ratio);
@@ -971,12 +840,10 @@ _gtk_hwrap_box_size_request (GtkWidget *widget,
requisition->width = 0;
requisition->height = 0;
}
-
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
/*<h2v-on>*/
}
-
static gfloat
get_gtkhwrapbox_layout_size (GtkHWrapBox *this,
guint max_width,
@@ -986,19 +853,15 @@ get_gtkhwrapbox_layout_size (GtkHWrapBox *this,
GtkWrapBoxChild *child;
guint n_rows, left_over = 0, total_height = 0;
gboolean last_row_filled = TRUE;
-
*width_inc = this->max_child_width + 1;
-
n_rows = 0;
for (child = wbox->children; child; child = child->next)
{
GtkWrapBoxChild *row_child;
GtkRequisition child_requisition;
guint row_width, row_height, n = 1;
-
if (!GTK_WIDGET_VISIBLE (child->widget))
continue;
-
get_gtkhwrapbox_child_requisition (wbox, child->widget, &child_requisition);
if (!last_row_filled)
*width_inc = MIN (*width_inc, child_requisition.width - left_over);
@@ -1022,13 +885,10 @@ get_gtkhwrapbox_layout_size (GtkHWrapBox *this,
total_height += (n_rows ? wbox->vspacing : 0) + row_height;
n_rows++;
}
-
if (*width_inc > this->max_child_width)
*width_inc = 0;
-
return MAX (total_height, 1);
}
-
static void
gtk_hwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -1038,26 +898,20 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_width = 0;
guint row_inc = 0;
-
g_return_if_fail (requisition != NULL);
-
requisition->width = 0;
requisition->height = 0;
this->max_child_width = 0;
this->max_child_height = 0;
-
/* size_request all children */
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
-
gtk_widget_size_request (child->widget, &child_requisition);
-
this->max_child_width = MAX (this->max_child_width, child_requisition.width);
this->max_child_height = MAX (this->max_child_height, child_requisition.height);
}
-
/* figure all possible layouts */
ratio_dist = 32768;
layout_width = this->max_child_width;
@@ -1065,7 +919,6 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
{
gfloat layout_height;
gfloat ratio, dist;
-
layout_width += row_inc;
layout_height = get_gtkhwrapbox_layout_size (this, layout_width, &row_inc);
ratio = layout_width / layout_height; /*<h2v-skip>*/
@@ -1076,7 +929,6 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
requisition->width = layout_width;
requisition->height = layout_height;
}
-
/* g_print ("ratio for width %d height %d = %f\n",
(gint) layout_width,
(gint) layout_height,
@@ -1084,7 +936,6 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
*/
}
while (row_inc);
-
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
/* g_print ("choosen: width %d, height %d\n",
@@ -1092,7 +943,6 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
requisition->height);
*/
}
-
static GSList*
reverse_list_row_children (GtkWrapBox *wbox,
GtkWrapBoxChild **child_p,
@@ -1103,21 +953,17 @@ reverse_list_row_children (GtkWrapBox *wbox,
GSList *slist = NULL;
guint width = 0, row_width = area->width;
GtkWrapBoxChild *child = *child_p;
-
*max_child_size = 0;
*expand_line = FALSE;
-
while (child && !GTK_WIDGET_VISIBLE (child->widget))
{
*child_p = child->next;
child = *child_p;
}
-
if (child)
{
GtkRequisition child_requisition;
guint n = 1;
-
get_gtkhwrapbox_child_requisition (wbox, child->widget, &child_requisition);
width += child_requisition.width;
*max_child_size = MAX (*max_child_size, child_requisition.height);
@@ -1125,7 +971,6 @@ reverse_list_row_children (GtkWrapBox *wbox,
slist = g_slist_prepend (slist, child);
*child_p = child->next;
child = *child_p;
-
while (child && n < wbox->child_limit)
{
if (GTK_WIDGET_VISIBLE (child->widget))
@@ -1144,10 +989,8 @@ reverse_list_row_children (GtkWrapBox *wbox,
child = *child_p;
}
}
-
return slist;
}
-
static void
layout_row (GtkWrapBox *wbox,
GtkAllocation *area,
@@ -1160,27 +1003,22 @@ layout_row (GtkWrapBox *wbox,
gint total_width = 0;
gfloat x, width, extra;
GtkAllocation child_allocation;
-
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
GtkRequisition child_requisition;
-
n_children++;
if (child->hexpand)
n_expand_children++;
-
get_gtkhwrapbox_child_requisition (wbox, child->widget, &child_requisition);
total_width += child_requisition.width;
}
-
width = MAX (1, area->width - (n_children - 1) * wbox->hspacing);
if (width > total_width)
extra = width - total_width;
else
extra = 0;
have_expand_children = n_expand_children && extra;
-
x = area->x;
if (wbox->homogeneous)
{
@@ -1220,12 +1058,10 @@ layout_row (GtkWrapBox *wbox,
extra = 0;
}
}
-
n_children = 0;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
-
child_allocation.x = x;
child_allocation.y = area->y;
if (wbox->homogeneous)
@@ -1237,9 +1073,7 @@ layout_row (GtkWrapBox *wbox,
else
{
GtkRequisition child_requisition;
-
get_gtkhwrapbox_child_requisition (wbox, child->widget, &child_requisition);
-
if (child_requisition.height >= area->height)
child_allocation.height = area->height;
else
@@ -1252,14 +1086,12 @@ layout_row (GtkWrapBox *wbox,
else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
child_allocation.y += area->height - child_requisition.height;
}
-
if (have_expand_children)
{
child_allocation.width = child_requisition.width;
if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
{
guint space;
-
n_expand_children--;
space = extra * n_expand_children;
space = width - space;
@@ -1284,13 +1116,11 @@ layout_row (GtkWrapBox *wbox,
area->width - child_allocation.x + area->x);
}
}
-
x += child_allocation.width + wbox->hspacing;
gtk_widget_size_allocate (child->widget, &child_allocation);
n_children++;
}
}
-
typedef struct _Line_gtkhwrapbox_ Line_gtkhwrapbox_;
struct _Line_gtkhwrapbox_
{
@@ -1299,7 +1129,6 @@ struct _Line_gtkhwrapbox_
guint expand : 1;
Line_gtkhwrapbox_ *next;
};
-
static void
layout_rows (GtkWrapBox *wbox,
GtkAllocation *area)
@@ -1312,7 +1141,6 @@ layout_rows (GtkWrapBox *wbox,
guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height;
guint children_per_line;
-
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
@@ -1320,12 +1148,10 @@ layout_rows (GtkWrapBox *wbox,
&min_height,
&vexpand);
slist = g_slist_reverse (slist);
-
children_per_line = g_slist_length (slist);
while (slist)
{
Line_gtkhwrapbox_ *line = g_new (Line_gtkhwrapbox_, 1);
-
line->children = slist;
line->min_size = min_height;
total_height += min_height;
@@ -1335,7 +1161,6 @@ layout_rows (GtkWrapBox *wbox,
line->next = line_list;
line_list = line;
n_lines++;
-
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
area,
@@ -1343,26 +1168,21 @@ layout_rows (GtkWrapBox *wbox,
&vexpand);
slist = g_slist_reverse (slist);
}
-
if (total_height > area->height)
shrink_height = total_height - area->height;
else
shrink_height = 0;
-
if (1) /* reverse lines and shrink */
{
Line_gtkhwrapbox_ *prev = NULL, *last = NULL;
gfloat n_shrink_lines = n_lines;
-
while (line_list)
{
Line_gtkhwrapbox_ *tmp = line_list->next;
-
if (shrink_height)
{
Line_gtkhwrapbox_ *line = line_list;
guint shrink_fract = shrink_height / n_shrink_lines + 0.5;
-
if (line->min_size > shrink_fract)
{
shrink_height -= shrink_fract;
@@ -1375,7 +1195,6 @@ layout_rows (GtkWrapBox *wbox,
}
}
n_shrink_lines--;
-
last = line_list;
line_list->next = prev;
prev = line_list;
@@ -1383,15 +1202,12 @@ layout_rows (GtkWrapBox *wbox,
}
line_list = last;
}
-
if (n_lines)
{
Line_gtkhwrapbox_ *line;
gfloat y, height, extra = 0;
-
height = area->height;
height = MAX (n_lines, height - (n_lines - 1) * wbox->vspacing);
-
if (wbox->homogeneous)
height /= ((gdouble) n_lines);
else if (n_expand_lines)
@@ -1401,14 +1217,12 @@ layout_rows (GtkWrapBox *wbox,
}
else
height = 0;
-
y = area->y;
line = line_list;
while (line)
{
GtkAllocation row_allocation;
Line_gtkhwrapbox_ *next_line = line->next;
-
row_allocation.x = area->x;
row_allocation.width = area->width;
if (wbox->homogeneous)
@@ -1416,27 +1230,22 @@ layout_rows (GtkWrapBox *wbox,
else
{
row_allocation.height = line->min_size;
-
if (line->expand)
row_allocation.height += extra;
}
-
row_allocation.y = y;
-
y += row_allocation.height + wbox->vspacing;
layout_row (wbox,
&row_allocation,
line->children,
children_per_line,
line->expand);
-
g_slist_free (line->children);
g_free (line);
line = next_line;
}
}
}
-
static void
gtk_hwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -1444,20 +1253,17 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
-
widget->allocation = *allocation;
area.x = allocation->x + border;
area.y = allocation->y + border;
area.width = MAX (1, (gint) allocation->width - border * 2);
area.height = MAX (1, (gint) allocation->height - border * 2);
-
/*<h2v-off>*/
/* g_print ("got: width %d, height %d\n",
allocation->width,
allocation->height);
*/
/*<h2v-on>*/
-
layout_rows (wbox, &area);
}
/* GTK - The GIMP Toolkit
@@ -1483,8 +1289,6 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
*/
/* #include "gtkvwrapbox.h" */
/* #include <math.h> */
-
-
/* --- prototypes --- */
static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass);
static void gtk_vwrap_box_init (GtkVWrapBox *vwbox);
@@ -1497,18 +1301,13 @@ static GSList* reverse_list_col_children (GtkWrapBox *wbox,
GtkAllocation *area,
guint *max_width,
gboolean *can_hexpand);
-
-
/* --- variables --- */
static gpointer parent_gtkvwrapbox_class = NULL;
-
-
/* --- functions --- */
GtkType
gtk_vwrap_box_get_type (void)
{
static GtkType vwrap_box_type = 0;
-
if (!vwrap_box_type)
{
static const GtkTypeInfo vwrap_box_info =
@@ -1522,13 +1321,10 @@ gtk_vwrap_box_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
vwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &vwrap_box_info);
}
-
return vwrap_box_type;
}
-
static void
gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass)
{
@@ -1536,39 +1332,29 @@ gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass)
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWrapBoxClass *wrap_box_class;
-
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
container_class = GTK_CONTAINER_CLASS (klass);
wrap_box_class = GTK_WRAP_BOX_CLASS (klass);
-
parent_gtkvwrapbox_class = gtk_type_class (GTK_TYPE_WRAP_BOX);
-
widget_class->size_request = gtk_vwrap_box_size_request;
widget_class->size_allocate = gtk_vwrap_box_size_allocate;
-
wrap_box_class->rlist_line_children = reverse_list_col_children;
}
-
static void
gtk_vwrap_box_init (GtkVWrapBox *vwbox)
{
vwbox->max_child_height = 0;
vwbox->max_child_width = 0;
}
-
GtkWidget*
gtk_vwrap_box_new (gboolean homogeneous)
{
GtkVWrapBox *vwbox;
-
vwbox = GTK_VWRAP_BOX (gtk_widget_new (GTK_TYPE_VWRAP_BOX, NULL));
-
GTK_WRAP_BOX (vwbox)->homogeneous = homogeneous ? TRUE : FALSE;
-
return GTK_WIDGET (vwbox);
}
-
static inline void
get_gtkvwrapbox_child_requisition (GtkWrapBox *wbox,
GtkWidget *child,
@@ -1577,14 +1363,12 @@ get_gtkvwrapbox_child_requisition (GtkWrapBox *wbox,
if (wbox->homogeneous)
{
GtkVWrapBox *vwbox = GTK_VWRAP_BOX (wbox);
-
child_requisition->height = vwbox->max_child_height;
child_requisition->width = vwbox->max_child_width;
}
else
gtk_widget_get_child_requisition (child, child_requisition);
}
-
static void
_gtk_vwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -1593,29 +1377,23 @@ _gtk_vwrap_box_size_request (GtkWidget *widget,
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkWrapBoxChild *child;
guint area = 0;
-
g_return_if_fail (requisition != NULL);
-
/*<h2v-off>*/
requisition->width = 0;
requisition->height = 0;
this->max_child_width = 0;
this->max_child_height = 0;
-
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
-
gtk_widget_size_request (child->widget, &child_requisition);
-
area += child_requisition.width * child_requisition.height;
this->max_child_width = MAX (this->max_child_width, child_requisition.width);
this->max_child_height = MAX (this->max_child_height, child_requisition.height);
}
if (wbox->homogeneous)
area = this->max_child_width * this->max_child_height * wbox->n_children;
-
if (area)
{
requisition->width = sqrt (area * wbox->aspect_ratio);
@@ -1626,12 +1404,10 @@ _gtk_vwrap_box_size_request (GtkWidget *widget,
requisition->width = 0;
requisition->height = 0;
}
-
requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
/*<h2v-on>*/
}
-
static gfloat
get_gtkvwrapbox_layout_size (GtkVWrapBox *this,
guint max_height,
@@ -1641,19 +1417,15 @@ get_gtkvwrapbox_layout_size (GtkVWrapBox *this,
GtkWrapBoxChild *child;
guint n_cols, left_over = 0, total_width = 0;
gboolean last_col_filled = TRUE;
-
*height_inc = this->max_child_height + 1;
-
n_cols = 0;
for (child = wbox->children; child; child = child->next)
{
GtkWrapBoxChild *col_child;
GtkRequisition child_requisition;
guint col_height, col_width, n = 1;
-
if (!GTK_WIDGET_VISIBLE (child->widget))
continue;
-
get_gtkvwrapbox_child_requisition (wbox, child->widget, &child_requisition);
if (!last_col_filled)
*height_inc = MIN (*height_inc, child_requisition.height - left_over);
@@ -1677,13 +1449,10 @@ get_gtkvwrapbox_layout_size (GtkVWrapBox *this,
total_width += (n_cols ? wbox->hspacing : 0) + col_width;
n_cols++;
}
-
if (*height_inc > this->max_child_height)
*height_inc = 0;
-
return MAX (total_width, 1);
}
-
static void
gtk_vwrap_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -1693,26 +1462,20 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
GtkWrapBoxChild *child;
gfloat ratio_dist, layout_height = 0;
guint col_inc = 0;
-
g_return_if_fail (requisition != NULL);
-
requisition->height = 0;
requisition->width = 0;
this->max_child_height = 0;
this->max_child_width = 0;
-
/* size_request all children */
for (child = wbox->children; child; child = child->next)
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
-
gtk_widget_size_request (child->widget, &child_requisition);
-
this->max_child_height = MAX (this->max_child_height, child_requisition.height);
this->max_child_width = MAX (this->max_child_width, child_requisition.width);
}
-
/* figure all possible layouts */
ratio_dist = 32768;
layout_height = this->max_child_height;
@@ -1720,7 +1483,6 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
{
gfloat layout_width;
gfloat ratio, dist;
-
layout_height += col_inc;
layout_width = get_gtkvwrapbox_layout_size (this, layout_height, &col_inc);
ratio = layout_width / layout_height; /*<h2v-skip>*/
@@ -1731,7 +1493,6 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
requisition->height = layout_height;
requisition->width = layout_width;
}
-
/* g_print ("ratio for height %d width %d = %f\n",
(gint) layout_height,
(gint) layout_width,
@@ -1739,7 +1500,6 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
*/
}
while (col_inc);
-
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /*<h2v-skip>*/
/* g_print ("choosen: height %d, width %d\n",
@@ -1747,7 +1507,6 @@ gtk_vwrap_box_size_request (GtkWidget *widget,
requisition->width);
*/
}
-
static GSList*
reverse_list_col_children (GtkWrapBox *wbox,
GtkWrapBoxChild **child_p,
@@ -1758,21 +1517,17 @@ reverse_list_col_children (GtkWrapBox *wbox,
GSList *slist = NULL;
guint height = 0, col_height = area->height;
GtkWrapBoxChild *child = *child_p;
-
*max_child_size = 0;
*expand_line = FALSE;
-
while (child && !GTK_WIDGET_VISIBLE (child->widget))
{
*child_p = child->next;
child = *child_p;
}
-
if (child)
{
GtkRequisition child_requisition;
guint n = 1;
-
get_gtkvwrapbox_child_requisition (wbox, child->widget, &child_requisition);
height += child_requisition.height;
*max_child_size = MAX (*max_child_size, child_requisition.width);
@@ -1780,7 +1535,6 @@ reverse_list_col_children (GtkWrapBox *wbox,
slist = g_slist_prepend (slist, child);
*child_p = child->next;
child = *child_p;
-
while (child && n < wbox->child_limit)
{
if (GTK_WIDGET_VISIBLE (child->widget))
@@ -1799,10 +1553,8 @@ reverse_list_col_children (GtkWrapBox *wbox,
child = *child_p;
}
}
-
return slist;
}
-
static void
layout_col (GtkWrapBox *wbox,
GtkAllocation *area,
@@ -1815,27 +1567,22 @@ layout_col (GtkWrapBox *wbox,
gint total_height = 0;
gfloat y, height, extra;
GtkAllocation child_allocation;
-
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
GtkRequisition child_requisition;
-
n_children++;
if (child->vexpand)
n_expand_children++;
-
get_gtkvwrapbox_child_requisition (wbox, child->widget, &child_requisition);
total_height += child_requisition.height;
}
-
height = MAX (1, area->height - (n_children - 1) * wbox->vspacing);
if (height > total_height)
extra = height - total_height;
else
extra = 0;
have_expand_children = n_expand_children && extra;
-
y = area->y;
if (wbox->homogeneous)
{
@@ -1875,12 +1622,10 @@ layout_col (GtkWrapBox *wbox,
extra = 0;
}
}
-
n_children = 0;
for (slist = children; slist; slist = slist->next)
{
GtkWrapBoxChild *child = slist->data;
-
child_allocation.y = y;
child_allocation.x = area->x;
if (wbox->homogeneous)
@@ -1892,9 +1637,7 @@ layout_col (GtkWrapBox *wbox,
else
{
GtkRequisition child_requisition;
-
get_gtkvwrapbox_child_requisition (wbox, child->widget, &child_requisition);
-
if (child_requisition.width >= area->width)
child_allocation.width = area->width;
else
@@ -1907,14 +1650,12 @@ layout_col (GtkWrapBox *wbox,
else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM)
child_allocation.x += area->width - child_requisition.width;
}
-
if (have_expand_children)
{
child_allocation.height = child_requisition.height;
if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
{
guint space;
-
n_expand_children--;
space = extra * n_expand_children;
space = height - space;
@@ -1939,13 +1680,11 @@ layout_col (GtkWrapBox *wbox,
area->height - child_allocation.y + area->y);
}
}
-
y += child_allocation.height + wbox->vspacing;
gtk_widget_size_allocate (child->widget, &child_allocation);
n_children++;
}
}
-
typedef struct _Line_gtkvwrapbox_ Line_gtkvwrapbox_;
struct _Line_gtkvwrapbox_
{
@@ -1954,7 +1693,6 @@ struct _Line_gtkvwrapbox_
guint expand : 1;
Line_gtkvwrapbox_ *next;
};
-
static void
layout_cols (GtkWrapBox *wbox,
GtkAllocation *area)
@@ -1967,7 +1705,6 @@ layout_cols (GtkWrapBox *wbox,
guint total_width = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_width;
guint children_per_line;
-
next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
@@ -1975,12 +1712,10 @@ layout_cols (GtkWrapBox *wbox,
&min_width,
&hexpand);
slist = g_slist_reverse (slist);
-
children_per_line = g_slist_length (slist);
while (slist)
{
Line_gtkvwrapbox_ *line = g_new (Line_gtkvwrapbox_, 1);
-
line->children = slist;
line->min_size = min_width;
total_width += min_width;
@@ -1990,7 +1725,6 @@ layout_cols (GtkWrapBox *wbox,
line->next = line_list;
line_list = line;
n_lines++;
-
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
&next_child,
area,
@@ -1998,26 +1732,21 @@ layout_cols (GtkWrapBox *wbox,
&hexpand);
slist = g_slist_reverse (slist);
}
-
if (total_width > area->width)
shrink_width = total_width - area->width;
else
shrink_width = 0;
-
if (1) /* reverse lines and shrink */
{
Line_gtkvwrapbox_ *prev = NULL, *last = NULL;
gfloat n_shrink_lines = n_lines;
-
while (line_list)
{
Line_gtkvwrapbox_ *tmp = line_list->next;
-
if (shrink_width)
{
Line_gtkvwrapbox_ *line = line_list;
guint shrink_fract = shrink_width / n_shrink_lines + 0.5;
-
if (line->min_size > shrink_fract)
{
shrink_width -= shrink_fract;
@@ -2030,7 +1759,6 @@ layout_cols (GtkWrapBox *wbox,
}
}
n_shrink_lines--;
-
last = line_list;
line_list->next = prev;
prev = line_list;
@@ -2038,15 +1766,12 @@ layout_cols (GtkWrapBox *wbox,
}
line_list = last;
}
-
if (n_lines)
{
Line_gtkvwrapbox_ *line;
gfloat x, width, extra = 0;
-
width = area->width;
width = MAX (n_lines, width - (n_lines - 1) * wbox->hspacing);
-
if (wbox->homogeneous)
width /= ((gdouble) n_lines);
else if (n_expand_lines)
@@ -2056,14 +1781,12 @@ layout_cols (GtkWrapBox *wbox,
}
else
width = 0;
-
x = area->x;
line = line_list;
while (line)
{
GtkAllocation col_allocation;
Line_gtkvwrapbox_ *next_line = line->next;
-
col_allocation.y = area->y;
col_allocation.height = area->height;
if (wbox->homogeneous)
@@ -2071,27 +1794,22 @@ layout_cols (GtkWrapBox *wbox,
else
{
col_allocation.width = line->min_size;
-
if (line->expand)
col_allocation.width += extra;
}
-
col_allocation.x = x;
-
x += col_allocation.width + wbox->hspacing;
layout_col (wbox,
&col_allocation,
line->children,
children_per_line,
line->expand);
-
g_slist_free (line->children);
g_free (line);
line = next_line;
}
}
}
-
static void
gtk_vwrap_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -2099,19 +1817,16 @@ gtk_vwrap_box_size_allocate (GtkWidget *widget,
GtkWrapBox *wbox = GTK_WRAP_BOX (widget);
GtkAllocation area;
gint border = GTK_CONTAINER (wbox)->border_width; /*<h2v-skip>*/
-
widget->allocation = *allocation;
area.y = allocation->y + border;
area.x = allocation->x + border;
area.height = MAX (1, (gint) allocation->height - border * 2);
area.width = MAX (1, (gint) allocation->width - border * 2);
-
/*<h2v-off>*/
/* g_print ("got: width %d, height %d\n",
allocation->width,
allocation->height);
*/
/*<h2v-on>*/
-
layout_cols (wbox, &area);
}
diff --git a/beast-gtk/gxk/glewidgets.h b/beast-gtk/gxk/glewidgets.h
index 663b5f7..49fb940 100644
--- a/beast-gtk/gxk/glewidgets.h
+++ b/beast-gtk/gxk/glewidgets.h
@@ -4,7 +4,6 @@
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
@@ -28,17 +27,11 @@ extern "C" {
*/
#ifndef __GTK_WRAP_BOX_H__
#define __GTK_WRAP_BOX_H__
-
-
/* #include <gdk/gdk.h> */
/* #include <gtk/gtkcontainer.h> */
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define GTK_TYPE_WRAP_BOX (gtk_wrap_box_get_type ())
#define GTK_WRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBox))
@@ -46,18 +39,14 @@ extern "C" {
#define GTK_IS_WRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_WRAP_BOX))
#define GTK_IS_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX))
#define GTK_WRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass))
-
-
/* --- typedefs --- */
typedef struct _GtkWrapBox GtkWrapBox;
typedef struct _GtkWrapBoxClass GtkWrapBoxClass;
typedef struct _GtkWrapBoxChild GtkWrapBoxChild;
-
/* --- GtkWrapBox --- */
struct _GtkWrapBox
{
GtkContainer container;
-
guint homogeneous : 1;
guint justify : 4;
guint line_justify : 4;
@@ -71,7 +60,6 @@ struct _GtkWrapBox
struct _GtkWrapBoxClass
{
GtkContainerClass parent_class;
-
GSList* (*rlist_line_children) (GtkWrapBox *wbox,
GtkWrapBoxChild **child_p,
GtkAllocation *area,
@@ -86,13 +74,10 @@ struct _GtkWrapBoxChild
guint vexpand : 1;
guint vfill : 1;
guint wrapped : 1;
-
GtkWrapBoxChild *next;
};
#define GTK_JUSTIFY_TOP GTK_JUSTIFY_LEFT
#define GTK_JUSTIFY_BOTTOM GTK_JUSTIFY_RIGHT
-
-
/* --- prototypes --- */
GtkType gtk_wrap_box_get_type (void);
void gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox,
@@ -139,14 +124,9 @@ void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
gboolean wrapped);
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *n_lines);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-
#endif /* __GTK_WRAP_BOX_H__ */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
@@ -171,16 +151,10 @@ guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
*/
#ifndef __GTK_HWRAP_BOX_H__
#define __GTK_HWRAP_BOX_H__
-
-
/* #include <gle/gtkwrapbox.h> */
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define GTK_TYPE_HWRAP_BOX (gtk_hwrap_box_get_type ())
#define GTK_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBox))
@@ -188,40 +162,28 @@ extern "C" {
#define GTK_IS_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HWRAP_BOX))
#define GTK_IS_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HWRAP_BOX))
#define GTK_HWRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass))
-
-
/* --- typedefs --- */
typedef struct _GtkHWrapBox GtkHWrapBox;
typedef struct _GtkHWrapBoxClass GtkHWrapBoxClass;
-
-
/* --- GtkHWrapBox --- */
struct _GtkHWrapBox
{
GtkWrapBox parent_widget;
-
/*<h2v-off>*/
guint max_child_width;
guint max_child_height;
/*<h2v-on>*/
};
-
struct _GtkHWrapBoxClass
{
GtkWrapBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType gtk_hwrap_box_get_type (void);
GtkWidget* gtk_hwrap_box_new (gboolean homogeneous);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-
#endif /* __GTK_HWRAP_BOX_H__ */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
@@ -246,16 +208,10 @@ GtkWidget* gtk_hwrap_box_new (gboolean homogeneous);
*/
#ifndef __GTK_VWRAP_BOX_H__
#define __GTK_VWRAP_BOX_H__
-
-
/* #include <gle/gtkwrapbox.h> */
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define GTK_TYPE_VWRAP_BOX (gtk_vwrap_box_get_type ())
#define GTK_VWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBox))
@@ -263,40 +219,28 @@ extern "C" {
#define GTK_IS_VWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_VWRAP_BOX))
#define GTK_IS_VWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_VWRAP_BOX))
#define GTK_VWRAP_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass))
-
-
/* --- typedefs --- */
typedef struct _GtkVWrapBox GtkVWrapBox;
typedef struct _GtkVWrapBoxClass GtkVWrapBoxClass;
-
-
/* --- GtkVWrapBox --- */
struct _GtkVWrapBox
{
GtkWrapBox parent_widget;
-
/*<h2v-off>*/
guint max_child_width;
guint max_child_height;
/*<h2v-on>*/
};
-
struct _GtkVWrapBoxClass
{
GtkWrapBoxClass parent_class;
};
-
-
/* --- prototypes --- */
GtkType gtk_vwrap_box_get_type (void);
GtkWidget* gtk_vwrap_box_new (gboolean homogeneous);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-
#endif /* __GTK_VWRAP_BOX_H__ */
#ifdef __cplusplus
}
diff --git a/beast-gtk/gxk/gxk.hh b/beast-gtk/gxk/gxk.hh
index 461c1e7..7c16165 100644
--- a/beast-gtk/gxk/gxk.hh
+++ b/beast-gtk/gxk/gxk.hh
@@ -1,10 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_H__
#define __GXK_H__
-
#include <sfi/glib-extra.hh>
#include <gtk/gtk.h>
-
#include <gxk/glewidgets.h>
#include <gxk/gxkaction.hh>
#include <gxk/gxkassortment.hh>
@@ -31,5 +29,4 @@
#include <gxk/gxkstock.hh>
#include <gxk/gxktexttools.hh>
#include <gxk/gxkutils.hh>
-
#endif /* __GXK_H__ */
diff --git a/beast-gtk/gxk/gxkaction.cc b/beast-gtk/gxk/gxkaction.cc
index f739ef0..ca2b473 100644
--- a/beast-gtk/gxk/gxkaction.cc
+++ b/beast-gtk/gxk/gxkaction.cc
@@ -2,17 +2,12 @@
#include "gxkaction.hh"
#include <string.h>
#include <libintl.h>
-
-
#define intern_null_string(s,sconst) (s ? (sconst ? g_intern_static_string : g_intern_string) (s) : NULL)
#define intern_i18n_string(idom,s,sconst) (intern_null_string (idom && s ? dgettext (idom, s) : s, sconst))
-
/* --- caching GxkActionCheck() --- */
#define ACTION_CHECK( func, user_data, action_id) (!func || action_check_stamped (func, user_data, action_id, TRUE))
#define ACTION_CHECK_CACHED( func, user_data, action_id) (!func || action_check_stamped (func, user_data, action_id, FALSE))
-
static guint64 global_action_cache_stamp = 0x100000000LL;
-
guint64
gxk_action_inc_cache_stamp (void)
{
@@ -21,7 +16,6 @@ gxk_action_inc_cache_stamp (void)
while ((global_action_cache_stamp & 0xffffffff) == 0);
return global_action_cache_stamp;
}
-
static inline gboolean
action_check_stamped (GxkActionCheck acheck_func,
gpointer user_data,
@@ -32,7 +26,6 @@ action_check_stamped (GxkActionCheck acheck_func,
gxk_action_inc_cache_stamp();
return acheck_func (user_data, action_id, global_action_cache_stamp) != FALSE;
}
-
/* --- action class ---- */
typedef struct {
GxkActionCheck acheck;
@@ -44,7 +37,6 @@ typedef struct {
guint ref_count;
} ActionClass;
static GHashTable *action_class_ht = NULL;
-
static gboolean
action_class_equals (gconstpointer v1,
gconstpointer v2)
@@ -57,7 +49,6 @@ action_class_equals (gconstpointer v1,
c1->agroup == c2->agroup &&
c1->class_flags == c2->class_flags);
}
-
static guint
action_class_hash (gconstpointer v)
{
@@ -68,7 +59,6 @@ action_class_hash (gconstpointer v)
G_HASH_POINTER (c->agroup) ^
c->class_flags);
}
-
static ActionClass*
action_class_ref_new (GxkActionCheck acheck,
GxkActionExec aexec,
@@ -94,7 +84,6 @@ action_class_ref_new (GxkActionCheck acheck,
c->ref_count++;
return c;
}
-
static ActionClass*
action_class_ref (ActionClass *aclass)
{
@@ -102,7 +91,6 @@ action_class_ref (ActionClass *aclass)
aclass->ref_count++;
return aclass;
}
-
static void
action_class_unref (ActionClass *aclass)
{
@@ -116,8 +104,6 @@ action_class_unref (ActionClass *aclass)
g_free (aclass);
}
}
-
-
/* --- action list --- */
typedef struct {
ActionClass *klass;
@@ -126,13 +112,11 @@ typedef struct {
GSList *widgets;
} ActionEntry;
static GQuark quark_action_entry = 0;
-
struct GxkActionList {
guint n_entries;
ActionEntry **entries;
GxkActionGroup *agroup;
};
-
static void
action_list_add (GxkActionList *alist,
ActionClass *klass,
@@ -154,7 +138,6 @@ action_list_add (GxkActionList *alist,
alist->entries = g_renew (ActionEntry*, alist->entries, alist->n_entries);
alist->entries[j] = entry;
}
-
static void
action_entry_free (ActionEntry *entry)
{
@@ -167,7 +150,6 @@ action_entry_free (ActionEntry *entry)
action_class_unref (entry->klass);
g_free (entry);
}
-
static ActionEntry*
action_entry_copy (const ActionEntry *source)
{
@@ -176,13 +158,11 @@ action_entry_copy (const ActionEntry *source)
entry->widgets = NULL;
return entry;
}
-
GxkActionList*
gxk_action_list_create (void)
{
return gxk_action_list_create_grouped (NULL);
}
-
GxkActionList*
gxk_action_list_create_grouped (GxkActionGroup *agroup)
{
@@ -190,7 +170,6 @@ gxk_action_list_create_grouped (GxkActionGroup *agroup)
alist->agroup = agroup ? (GxkActionGroup*) g_object_ref (agroup) : NULL;
return alist;
}
-
void
gxk_action_list_add_actions (GxkActionList *alist,
guint n_actions,
@@ -210,7 +189,6 @@ gxk_action_list_add_actions (GxkActionList *alist,
}
action_class_unref (klass);
}
-
void
gxk_action_list_add_translated (GxkActionList *alist,
const gchar *key,
@@ -236,7 +214,6 @@ gxk_action_list_add_translated (GxkActionList *alist,
action_list_add (alist, klass, FALSE, key, &a, NULL);
action_class_unref (klass);
}
-
static gint
action_entries_compare (gconstpointer v1,
gconstpointer v2,
@@ -246,14 +223,12 @@ action_entries_compare (gconstpointer v1,
const ActionEntry *const*p2 = (const ActionEntry*const*) v2, *e2 = *p2;
return strcmp (e1->action.name, e2->action.name);
}
-
GxkActionList*
gxk_action_list_sort (GxkActionList *alist)
{
g_qsort_with_data (alist->entries, alist->n_entries, sizeof (alist->entries[0]), action_entries_compare, NULL);
return alist;
}
-
GxkActionList*
gxk_action_list_merge (GxkActionList *alist1,
GxkActionList *alist2)
@@ -273,7 +248,6 @@ gxk_action_list_merge (GxkActionList *alist1,
g_free (alist2);
return alist1;
}
-
GxkActionList*
gxk_action_list_copy (GxkActionList *alist)
{
@@ -285,13 +259,11 @@ gxk_action_list_copy (GxkActionList *alist)
al->entries[i] = action_entry_copy (alist->entries[i]);
return al;
}
-
guint
gxk_action_list_get_n_actions (GxkActionList *alist)
{
return alist->n_entries;
}
-
void
gxk_action_list_get_action (GxkActionList *alist,
guint nth,
@@ -308,7 +280,6 @@ gxk_action_list_get_action (GxkActionList *alist,
action->action_id = e->action.action_id;
action->stock_icon = e->action.stock_icon;
}
-
static void
widget_set_active (GxkActionGroup *agroup,
GtkWidget *widget)
@@ -323,7 +294,6 @@ widget_set_active (GxkActionGroup *agroup,
gxk_action_group_unlock (agroup);
}
}
-
void
gxk_action_list_regulate_widget (GxkActionList *alist,
guint nth,
@@ -337,7 +307,6 @@ gxk_action_list_regulate_widget (GxkActionList *alist,
if (e->klass->agroup && gxk_widget_regulate_uses_active (widget))
g_signal_connect_object (e->klass->agroup, "changed", G_CALLBACK (widget_set_active), widget, GConnectFlags (0));
}
-
void
gxk_action_list_force_regulate (GtkWidget *widget)
{
@@ -353,7 +322,6 @@ gxk_action_list_force_regulate (GtkWidget *widget)
gxk_action_group_unlock (e->klass->agroup);
}
}
-
void
gxk_action_list_free (GxkActionList *alist)
{
@@ -365,7 +333,6 @@ gxk_action_list_free (GxkActionList *alist)
g_object_unref (alist->agroup);
g_free (alist);
}
-
void
gxk_action_activate_callback (gconstpointer action_data)
{
@@ -394,15 +361,12 @@ gxk_action_activate_callback (gconstpointer action_data)
}
}
}
-
-
/* --- GtkWindow actions --- */
typedef struct {
gpointer client_data;
GxkActionClient added_func;
} ActionClient;
static GQuark quark_action_clients = 0;
-
typedef struct ActionLink ActionLink;
struct ActionLink {
guint ref_count;
@@ -414,7 +378,6 @@ struct ActionLink {
};
static GQuark quark_action_links = 0;
static GQuark quark_action_factories = 0;
-
static void
action_link_unref (ActionLink *alink)
{
@@ -427,7 +390,6 @@ action_link_unref (ActionLink *alink)
g_free (alink);
}
}
-
static void
window_destroy_action_links (gpointer data)
{
@@ -441,7 +403,6 @@ window_destroy_action_links (gpointer data)
action_link_unref (alink);
}
}
-
static void
window_add_action_link (GtkWidget *window,
ActionLink *alink)
@@ -461,13 +422,11 @@ window_add_action_link (GtkWidget *window,
aclient->added_func (aclient->client_data, (GtkWindow*) window, alink->prefix, alink->alist, alink->widget);
}
}
-
static void
window_remove_action_link (ActionLink *alink)
{
GtkWidget *window = alink->toplevel;
g_return_if_fail (GTK_IS_WIDGET (alink->toplevel));
-
ActionLink *last = NULL, *anode = (ActionLink*) g_object_get_qdata ((GObject*) window, quark_action_links);
for (; anode; last = anode, anode = last->next)
if (anode == alink)
@@ -485,11 +444,9 @@ window_remove_action_link (ActionLink *alink)
return;
}
}
-
static GSList *window_queue = NULL;
static GQuark quark_widgets_upwards = 0;
static GQuark quark_widgets_downwards = 0;
-
static void
free_widget_slist (gpointer data)
{
@@ -500,7 +457,6 @@ free_widget_slist (gpointer data)
g_object_unref (widget);
}
}
-
static inline gboolean
check_ancestor (GtkWidget *widget,
GtkWidget *ancestor)
@@ -513,7 +469,6 @@ check_ancestor (GtkWidget *widget,
}
return FALSE;
}
-
static gboolean
gxk_action_timer_update_window (gpointer data)
{
@@ -576,7 +531,6 @@ gxk_action_timer_update_window (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
window_queue_action_updates (GtkWidget *window,
GtkWidget *upwards,
@@ -618,9 +572,6 @@ window_queue_action_updates (GtkWidget *window,
window_queue = g_slist_prepend (window_queue, g_object_ref (window));
}
}
-
-
-
void
gxk_widget_update_actions_upwards (gpointer widget)
{
@@ -629,7 +580,6 @@ gxk_widget_update_actions_upwards (gpointer widget)
if (GTK_IS_WINDOW (toplevel))
window_queue_action_updates (toplevel, (GtkWidget*) widget, NULL);
}
-
void
gxk_widget_update_actions_downwards (gpointer widget)
{
@@ -638,7 +588,6 @@ gxk_widget_update_actions_downwards (gpointer widget)
if (GTK_IS_WINDOW (toplevel))
window_queue_action_updates (toplevel, NULL, (GtkWidget*) widget);
}
-
void
gxk_widget_update_actions (gpointer widget)
{
@@ -647,12 +596,9 @@ gxk_widget_update_actions (gpointer widget)
if (GTK_IS_WINDOW (toplevel))
window_queue_action_updates (toplevel, (GtkWidget*) widget, (GtkWidget*) widget);
}
-
-
/* --- publishing --- */
static GQuark quark_widget_actions = 0;
static GSList *publisher_list = NULL;
-
static gboolean
action_idle_publisher (gpointer data)
{
@@ -679,7 +625,6 @@ action_idle_publisher (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
publisher_update_actions (GtkWidget *widget)
{
@@ -690,7 +635,6 @@ publisher_update_actions (GtkWidget *widget)
publisher_list = g_slist_prepend (publisher_list, g_object_ref (widget));
}
}
-
static void
publisher_destroy_action_links (gpointer data)
{
@@ -703,7 +647,6 @@ publisher_destroy_action_links (gpointer data)
action_link_unref (alink);
}
}
-
void
gxk_widget_publish_action_list (gpointer widget,
const gchar *prefix,
@@ -725,7 +668,6 @@ gxk_widget_publish_action_list (gpointer widget,
g_object_connect (widget, "signal_after::realize", gxk_widget_update_actions, NULL, NULL);
gxk_widget_update_actions (widget);
}
-
GSList*
gxk_widget_peek_action_widgets (gpointer widget,
const gchar *prefix,
@@ -746,7 +688,6 @@ gxk_widget_peek_action_widgets (gpointer widget,
}
return NULL;
}
-
void
gxk_widget_republish_actions (gpointer widget,
const gchar *prefix,
@@ -763,7 +704,6 @@ gxk_widget_republish_actions (gpointer widget,
}
}
}
-
void
gxk_widget_publish_actions_grouped (gpointer widget,
GxkActionGroup *group,
@@ -779,7 +719,6 @@ gxk_widget_publish_actions_grouped (gpointer widget,
gxk_action_list_add_actions (alist, n_actions, actions, i18n_domain, acheck, aexec, widget);
gxk_widget_publish_action_list (widget, prefix, alist);
}
-
void
gxk_widget_publish_actions (gpointer widget,
const gchar *prefix,
@@ -791,7 +730,6 @@ gxk_widget_publish_actions (gpointer widget,
{
gxk_widget_publish_actions_grouped (widget, NULL, prefix, n_actions, actions, i18n_domain, acheck, aexec);
}
-
void
gxk_widget_publish_grouped_translated (gpointer widget,
GxkActionGroup *group,
@@ -812,7 +750,6 @@ gxk_widget_publish_grouped_translated (gpointer widget,
acheck, aexec, widget);
gxk_widget_publish_action_list (widget, prefix, alist);
}
-
void
gxk_widget_publish_translated (gpointer widget,
const gchar *prefix,
@@ -829,7 +766,6 @@ gxk_widget_publish_translated (gpointer widget,
gxk_widget_publish_grouped_translated (widget, NULL, prefix, key ? key : name, name, accelerator,
tooltip, action_id, stock_icon, acheck, aexec);
}
-
void
gxk_window_add_action_client (GtkWindow *window,
GxkActionClient added_func,
@@ -846,7 +782,6 @@ gxk_window_add_action_client (GtkWindow *window,
for (alink = (ActionLink*) g_object_get_qdata ((GObject*) window, quark_action_links); alink; alink = alink->next)
aclient->added_func (aclient->client_data, window, alink->prefix, alink->alist, alink->widget);
}
-
void
gxk_window_remove_action_client (GtkWindow *window,
gpointer client_data)
@@ -871,10 +806,8 @@ gxk_window_remove_action_client (GtkWindow *window,
}
g_warning ("failed to remove action client (%p) from GtkWindow (%p)", client_data, window);
}
-
/* --- action group --- */
static gulong action_group_signal_changed = 0;
-
static void
gxk_action_group_class_init (GxkActionGroupClass *klass)
{
@@ -884,7 +817,6 @@ gxk_action_group_class_init (GxkActionGroupClass *klass)
NULL, NULL, gtk_signal_default_marshaller,
G_TYPE_NONE, 0);
}
-
GType
gxk_action_group_get_type (void)
{
@@ -906,7 +838,6 @@ gxk_action_group_get_type (void)
}
return type;
}
-
GxkActionGroup*
gxk_action_toggle_new (void)
{
@@ -914,13 +845,11 @@ gxk_action_toggle_new (void)
group->invert_dups = TRUE;
return group;
}
-
GxkActionGroup*
gxk_action_group_new (void)
{
return (GxkActionGroup*) g_object_new (GXK_TYPE_ACTION_GROUP, NULL);
}
-
void
gxk_action_group_select (GxkActionGroup *self,
gulong action_id)
@@ -937,14 +866,12 @@ gxk_action_group_select (GxkActionGroup *self,
self->lock_count--;
}
}
-
void
gxk_action_group_lock (GxkActionGroup *self)
{
g_return_if_fail (GXK_IS_ACTION_GROUP (self));
self->lock_count++;
}
-
void
gxk_action_group_unlock (GxkActionGroup *self)
{
@@ -952,15 +879,12 @@ gxk_action_group_unlock (GxkActionGroup *self)
g_return_if_fail (self->lock_count > 0);
self->lock_count--;
}
-
void
gxk_action_group_dispose (GxkActionGroup *self)
{
g_return_if_fail (GXK_IS_ACTION_GROUP (self));
g_object_run_dispose ((GObject*) self);
}
-
-
/* --- initialization --- */
void
gxk_init_actions (void)
diff --git a/beast-gtk/gxk/gxkaction.hh b/beast-gtk/gxk/gxkaction.hh
index 06ab917..3b38d10 100644
--- a/beast-gtk/gxk/gxkaction.hh
+++ b/beast-gtk/gxk/gxkaction.hh
@@ -1,15 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_ACTION_H__
#define __GXK_ACTION_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
-
#define GXK_ACTION_PRIORITY (G_PRIORITY_HIGH - 10)
-
-
/* --- structures --- */
typedef gboolean (*GxkActionCheck) (gpointer user_data,
gulong action_id,
@@ -27,7 +21,6 @@ typedef struct {
gulong action_id;
const gchar *stock_icon; /* stock_id for the icon or NULL */
} GxkAction;
-
typedef struct {
const gchar *name; /* subject to i18n (key) */
const gchar *accelerator;
@@ -35,7 +28,6 @@ typedef struct {
gulong action_id;
const gchar *stock_icon; /* stock_id for the icon */
} GxkStockAction;
-
/* --- public API --- */
guint64 gxk_action_inc_cache_stamp (void);
GxkActionList* gxk_action_list_create (void);
@@ -74,7 +66,6 @@ void gxk_action_activate_callback (gconstpointer action_d
void gxk_widget_update_actions_upwards (gpointer widget);
void gxk_widget_update_actions_downwards (gpointer widget);
void gxk_widget_update_actions (gpointer widget);
-
/* --- publishing --- */
void gxk_widget_publish_action_list (gpointer widget,
const gchar *prefix,
@@ -131,8 +122,6 @@ void gxk_window_add_action_client (GtkWindow *window,
gpointer client_data);
void gxk_window_remove_action_client (GtkWindow *window,
gpointer client_data);
-
-
/* --- action groups --- */
#define GXK_TYPE_ACTION_GROUP (gxk_action_group_get_type ())
#define GXK_ACTION_GROUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_ACTION_GROUP, GxkActionGroup))
@@ -158,8 +147,5 @@ void gxk_action_group_lock (GxkActionGroup *agroup);
void gxk_action_group_unlock (GxkActionGroup *agroup);
void gxk_action_group_dispose (GxkActionGroup *agroup);
GxkActionGroup* gxk_action_toggle_new (void);
-
-
G_END_DECLS
-
#endif /* __GXK_ACTION_H__ */
diff --git a/beast-gtk/gxk/gxkassortment.cc b/beast-gtk/gxk/gxkassortment.cc
index c71ef46..d0fca79 100644
--- a/beast-gtk/gxk/gxkassortment.cc
+++ b/beast-gtk/gxk/gxkassortment.cc
@@ -3,8 +3,6 @@
#include "gxkstock.hh"
#include <string.h>
#include <libintl.h>
-
-
/* --- assortment --- */
static gpointer
assortment_entry_copy (gpointer boxed)
@@ -13,7 +11,6 @@ assortment_entry_copy (gpointer boxed)
entry->ref_count += 1;
return entry;
}
-
static void
assortment_entry_free (GxkAssortmentEntry *aentry)
{
@@ -31,14 +28,12 @@ assortment_entry_free (GxkAssortmentEntry *aentry)
g_free (aentry);
}
}
-
static void
assortment_entry_free_boxed (gpointer boxed)
{
GxkAssortmentEntry *aentry = (GxkAssortmentEntry*) boxed;
assortment_entry_free (aentry);
}
-
GType
gxk_assortment_entry_get_type (void)
{
@@ -47,38 +42,32 @@ gxk_assortment_entry_get_type (void)
type_id = g_boxed_type_register_static ("GxkAssortmentEntry", assortment_entry_copy, assortment_entry_free_boxed);
return type_id;
}
-
G_DEFINE_TYPE (GxkAssortment, gxk_assortment, G_TYPE_OBJECT);
static guint signal_entry_added = 0;
static guint signal_entry_changed = 0;
static guint signal_entry_remove = 0;
static guint signal_selection_changed = 0;
-
void
gxk_assortment_init (GxkAssortment *self)
{
}
-
GxkAssortment*
gxk_assortment_new (void)
{
return (GxkAssortment*) g_object_new (GXK_TYPE_ASSORTMENT, NULL);
}
-
void
gxk_assortment_dispose (GxkAssortment *self)
{
g_return_if_fail (GXK_IS_ASSORTMENT (self));
g_object_run_dispose ((GObject*) self);
}
-
void
gxk_assortment_block_selection (GxkAssortment *self)
{
g_return_if_fail (GXK_IS_ASSORTMENT (self));
self->block_count++;
}
-
void
gxk_assortment_unblock_selection (GxkAssortment *self)
{
@@ -86,7 +75,6 @@ gxk_assortment_unblock_selection (GxkAssortment *self)
g_return_if_fail (self->block_count > 0);
self->block_count--;
}
-
void
gxk_assortment_select (GxkAssortment *self,
GxkAssortmentEntry *entry)
@@ -98,7 +86,6 @@ gxk_assortment_select (GxkAssortment *self,
g_signal_emit (self, signal_selection_changed, 0);
}
}
-
void
gxk_assortment_select_data (GxkAssortment *self,
gpointer entry_user_data)
@@ -106,7 +93,6 @@ gxk_assortment_select_data (GxkAssortment *self,
g_return_if_fail (GXK_IS_ASSORTMENT (self));
gxk_assortment_select (self, gxk_assortment_find_data (self, entry_user_data));
}
-
GxkAssortmentEntry*
gxk_assortment_find_data (GxkAssortment *self,
gpointer entry_user_data)
@@ -121,7 +107,6 @@ gxk_assortment_find_data (GxkAssortment *self,
}
return NULL;
}
-
GxkAssortmentEntry*
gxk_assortment_insert (GxkAssortment *self,
guint position,
@@ -134,7 +119,6 @@ gxk_assortment_insert (GxkAssortment *self,
GxkAssortmentDelete free_func)
{
g_return_val_if_fail (GXK_IS_ASSORTMENT (self), NULL);
-
GxkAssortmentEntry *aentry = g_new0 (GxkAssortmentEntry, 1);
aentry->label = g_strdup (label);
aentry->stock_icon = g_strdup (stock_icon);
@@ -148,29 +132,24 @@ gxk_assortment_insert (GxkAssortment *self,
g_signal_emit (self, signal_entry_added, 0, aentry);
return aentry;
}
-
void
gxk_assortment_changed (GxkAssortment *self,
GxkAssortmentEntry *entry)
{
g_return_if_fail (GXK_IS_ASSORTMENT (self));
g_return_if_fail (g_slist_find (self->entries, entry) != NULL);
-
g_signal_emit (self, signal_entry_changed, 0, entry);
}
-
void
gxk_assortment_remove (GxkAssortment *self,
GxkAssortmentEntry *entry)
{
g_return_if_fail (GXK_IS_ASSORTMENT (self));
-
GSList *last = NULL, *slist;
for (slist = self->entries; slist; last = slist, slist = last->next)
if (slist->data == entry)
break;
g_return_if_fail (slist != NULL);
-
gboolean selection_changed = FALSE;
if (self->selected == entry)
{
@@ -197,7 +176,6 @@ gxk_assortment_remove (GxkAssortment *self,
if (selection_changed)
g_signal_emit (self, signal_selection_changed, 0);
}
-
static void
assortment_dispose (GObject *object)
{
@@ -215,7 +193,6 @@ assortment_dispose (GObject *object)
g_signal_emit (self, signal_selection_changed, 0);
G_OBJECT_CLASS (gxk_assortment_parent_class)->dispose (object);
}
-
static void
assortment_finalize (GObject *object)
{
@@ -231,15 +208,12 @@ assortment_finalize (GObject *object)
self->publishing_name = NULL;
G_OBJECT_CLASS (gxk_assortment_parent_class)->finalize (object);
}
-
void
gxk_assortment_class_init (GxkAssortmentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->dispose = assortment_dispose;
gobject_class->finalize = assortment_finalize;
-
signal_entry_added = g_signal_new ("entry-added", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GxkAssortmentClass, entry_added),
@@ -260,12 +234,10 @@ gxk_assortment_class_init (GxkAssortmentClass *klass)
G_STRUCT_OFFSET (GxkAssortmentClass, selection_changed),
NULL, NULL, gtk_signal_default_marshaller, G_TYPE_NONE, 0);
}
-
/* --- publishing --- */
static GQuark quark_assortment_clients = 0;
static GQuark quark_window_assortments = 0;
static GQuark quark_widget_assortments = 0;
-
void
gxk_init_assortments (void)
{
@@ -273,7 +245,6 @@ gxk_init_assortments (void)
quark_window_assortments = g_quark_from_static_string ("gxk-window-assortments");
quark_widget_assortments = g_quark_from_static_string ("gxk-widget-assortments");
}
-
typedef struct AssortmentLink AssortmentLink;
struct AssortmentLink {
GxkAssortment *assortment;
@@ -282,7 +253,6 @@ struct AssortmentLink {
GtkWidget *toplevel;
AssortmentLink *next; /* linked list on toplevel */
};
-
static void
assortment_link_unref (AssortmentLink *alink)
{
@@ -294,7 +264,6 @@ assortment_link_unref (AssortmentLink *alink)
g_free (alink);
}
}
-
static void
window_destroy_assortments (gpointer data)
{
@@ -308,13 +277,11 @@ window_destroy_assortments (gpointer data)
assortment_link_unref (alink);
}
}
-
typedef struct {
gpointer client_data;
GxkAssortmentClient added_func;
GxkAssortmentClient removed_func;
} AssortmentClient;
-
static void
window_add_assortment_link (GtkWidget *window,
AssortmentLink *alink)
@@ -336,13 +303,11 @@ window_add_assortment_link (GtkWidget *window,
aclient->added_func (aclient->client_data, (GtkWindow*) window, alink->assortment, alink->widget);
}
}
-
static void
window_remove_assortment_link (AssortmentLink *alink)
{
GtkWidget *window = alink->toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
-
AssortmentLink *last = NULL, *anode = (AssortmentLink*) g_object_get_qdata ((GObject*) window, quark_window_assortments);
for (; anode; last = anode, anode = last->next)
if (anode == alink)
@@ -368,7 +333,6 @@ window_remove_assortment_link (AssortmentLink *alink)
return;
}
}
-
static GSList *publisher_list = NULL;
static gboolean
assortment_idle_publisher (gpointer data)
@@ -396,7 +360,6 @@ assortment_idle_publisher (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
publisher_update_assortments (GtkWidget *widget)
{
@@ -407,7 +370,6 @@ publisher_update_assortments (GtkWidget *widget)
publisher_list = g_slist_prepend (publisher_list, g_object_ref (widget));
}
}
-
static void
delete_assortment_link_list (gpointer data)
{
@@ -420,7 +382,6 @@ delete_assortment_link_list (gpointer data)
assortment_link_unref (alink);
}
}
-
void
gxk_widget_publish_assortment (gpointer widget,
const gchar *publishing_name,
@@ -441,7 +402,6 @@ gxk_widget_publish_assortment (gpointer widget,
g_object_connect (widget, "signal_after::hierarchy-changed", publisher_update_assortments, NULL, NULL);
publisher_update_assortments ((GtkWidget*) widget);
}
-
void
gxk_window_add_assortment_client (GtkWindow *window,
GxkAssortmentClient added_func,
@@ -461,7 +421,6 @@ gxk_window_add_assortment_client (GtkWindow *window,
if (aclient->added_func)
aclient->added_func (aclient->client_data, window, alink->assortment, alink->widget);
}
-
void
gxk_window_remove_assortment_client (GtkWindow *window,
gpointer client_data)
@@ -486,12 +445,10 @@ gxk_window_remove_assortment_client (GtkWindow *window,
}
g_warning ("failed to remove assortment client (%p) from GtkWindow (%p)", client_data, window);
}
-
/* --- menus --- */
static void assortment_menu_entry_changed (GxkAssortment *self,
GxkAssortmentEntry *entry,
GtkMenu *menu);
-
static void
assortment_menu_entry_added (GxkAssortment *self,
GxkAssortmentEntry *entry,
@@ -516,7 +473,6 @@ assortment_menu_entry_added (GxkAssortment *self,
gxk_assortment_unblock_selection (self);
assortment_menu_entry_changed (self, entry, menu);
}
-
static void
assortment_menu_entry_changed (GxkAssortment *self,
GxkAssortmentEntry *entry,
@@ -562,7 +518,6 @@ assortment_menu_entry_changed (GxkAssortment *self,
gxk_widget_set_tooltip (menu_item, entry->tooltip);
}
}
-
static void
assortment_menu_entry_remove (GxkAssortment *self,
GxkAssortmentEntry *entry,
@@ -579,7 +534,6 @@ assortment_menu_entry_remove (GxkAssortment *self,
if (list)
gtk_widget_destroy ((GtkWidget*) list->data);
}
-
static void
assortment_menu_selection_changed (GxkAssortment *self,
GtkMenu *menu)
@@ -598,7 +552,6 @@ assortment_menu_selection_changed (GxkAssortment *self,
gxk_menu_set_active (menu, (GtkWidget*) list->data);
}
}
-
static void
assortment_menu_selection_done (GtkMenu *menu,
GxkAssortment *self)
@@ -610,20 +563,17 @@ assortment_menu_selection_done (GtkMenu *menu,
gxk_assortment_select_data (self, user_data);
}
}
-
void
gxk_assortment_manage_menu (GxkAssortment *self,
GtkMenu *menu)
{
g_return_if_fail (GXK_IS_ASSORTMENT (self));
g_return_if_fail (GTK_IS_MENU (menu));
-
g_signal_connect_object (self, "entry-added", G_CALLBACK (assortment_menu_entry_added), menu, GConnectFlags (0));
g_signal_connect_object (self, "entry-changed", G_CALLBACK (assortment_menu_entry_changed), menu, GConnectFlags (0));
g_signal_connect_object (self, "entry-remove", G_CALLBACK (assortment_menu_entry_remove), menu, GConnectFlags (0));
g_signal_connect_object (self, "selection-changed", G_CALLBACK (assortment_menu_selection_changed), menu, GConnectFlags (0));
g_signal_connect_object (menu, "selection-done", G_CALLBACK (assortment_menu_selection_done), self, GConnectFlags (0));
-
GSList *slist;
for (slist = self->entries; slist; slist = slist->next)
assortment_menu_entry_added (self, (GxkAssortmentEntry*) slist->data, menu);
diff --git a/beast-gtk/gxk/gxkassortment.hh b/beast-gtk/gxk/gxkassortment.hh
index dab577a..691916d 100644
--- a/beast-gtk/gxk/gxkassortment.hh
+++ b/beast-gtk/gxk/gxkassortment.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_ASSORTMENT_H__
#define __GXK_ASSORTMENT_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
#define GXK_ASSORTMENT_PRIORITY (G_PRIORITY_HIGH - 10)
-
/* --- assortment --- */
#define GXK_TYPE_ASSORTMENT_ENTRY (gxk_assortment_entry_get_type ())
#define GXK_TYPE_ASSORTMENT (gxk_assortment_get_type ())
@@ -48,7 +44,6 @@ typedef struct {
GxkAssortmentEntry *entry);
void (*selection_changed) (GxkAssortment *self);
} GxkAssortmentClass;
-
/* --- assortment --- */
GType gxk_assortment_entry_get_type (void);
GType gxk_assortment_get_type (void);
@@ -77,7 +72,6 @@ void gxk_assortment_select_data (GxkAssortment *self,
void gxk_assortment_unblock_selection (GxkAssortment *self);
void gxk_assortment_manage_menu (GxkAssortment *self,
GtkMenu *menu);
-
/* --- publishing --- */
void gxk_widget_publish_assortment (gpointer widget,
const gchar *publishing_name,
@@ -92,8 +86,5 @@ void gxk_window_add_assortment_client (GtkWindow *window,
gpointer client_data);
void gxk_window_remove_assortment_client (GtkWindow *window,
gpointer client_data);
-
-
G_END_DECLS
-
#endif /* __GXK_ASSORTMENT_H__ */
diff --git a/beast-gtk/gxk/gxkauxwidgets.cc b/beast-gtk/gxk/gxkauxwidgets.cc
index 4948a5d..8b5b3dc 100644
--- a/beast-gtk/gxk/gxkauxwidgets.cc
+++ b/beast-gtk/gxk/gxkauxwidgets.cc
@@ -2,7 +2,6 @@
#include "gxkauxwidgets.hh"
#include "gxkstock.hh"
#include <gdk/gdkkeysyms.h>
-
/* --- GxkMenuItem --- */
enum {
MENU_ITEM_PROP_0,
@@ -14,7 +13,6 @@ enum {
MENU_ITEM_PROP_TITLE_STYLE,
MENU_ITEM_PROP_RIGHT_JUSTIFY
};
-
static void gxk_menu_item_class_init (GxkMenuItemClass *klass);
static void gxk_menu_item_set_property (GObject *object,
guint param_id,
@@ -31,7 +29,6 @@ menu_item_keep_menubar_image (GtkImageMenuItem *imitem)
!g_object_get_long (imitem, "gxk-keep-menubar-image"))
gtk_image_menu_item_set_image (imitem, NULL);
}
-
static void
gxk_menu_item_set_property (GObject *object,
guint param_id,
@@ -118,7 +115,6 @@ gxk_menu_item_set_property (GObject *object,
break;
}
}
-
static void
gxk_menu_item_get_property (GObject *object,
guint param_id,
@@ -133,14 +129,12 @@ gxk_menu_item_get_property (GObject *object,
break;
}
}
-
static void
gxk_menu_item_init (GxkMenuItem *self)
{
g_signal_connect (self, "parent-set", G_CALLBACK (menu_item_keep_menubar_image), NULL);
g_signal_connect (self, "check-resize", G_CALLBACK (menu_item_keep_menubar_image), NULL);
}
-
static void
gxk_menu_item_class_init (GxkMenuItemClass *klass)
{
@@ -162,7 +156,6 @@ gxk_menu_item_class_init (GxkMenuItemClass *klass)
g_object_class_install_property (gobject_class, MENU_ITEM_PROP_TITLE_STYLE,
g_param_spec_boolean ("title-style", NULL, NULL, FALSE, G_PARAM_WRITABLE));
}
-
GType
gxk_menu_item_get_type (void)
{
@@ -184,15 +177,12 @@ gxk_menu_item_get_type (void)
}
return type;
}
-
/* --- scrolled window --- */
G_DEFINE_TYPE (GxkScrolledWindow, gxk_scrolled_window, GTK_TYPE_SCROLLED_WINDOW);
-
static void
gxk_scrolled_window_init (GxkScrolledWindow *self)
{
}
-
enum {
SCROLLED_WINDOW_PROP_0,
SCROLLED_WINDOW_PROP_SPARE_SPACE,
@@ -217,7 +207,6 @@ gxk_scrolled_window_set_property (GObject *object,
break;
}
}
-
static void
gxk_scrolled_window_class_init (GxkScrolledWindowClass *klass)
{
@@ -227,7 +216,6 @@ gxk_scrolled_window_class_init (GxkScrolledWindowClass *klass)
g_param_spec_boolean ("spare-space", NULL, NULL, FALSE, G_PARAM_WRITABLE));
GTK_SCROLLED_WINDOW_CLASS (klass)->scrollbar_spacing = 1;
}
-
/* --- GxkFreeRadioButton --- */
static void
gxk_free_radio_button_class_init (GxkFreeRadioButtonClass *klass)
@@ -237,7 +225,6 @@ gxk_free_radio_button_class_init (GxkFreeRadioButtonClass *klass)
button_class->clicked = GTK_BUTTON_CLASS (gtk_check_button_class)->clicked;
g_type_class_unref (gtk_check_button_class);
}
-
GType
gxk_free_radio_button_get_type (void)
{
@@ -259,8 +246,6 @@ gxk_free_radio_button_get_type (void)
}
return type;
}
-
-
/* --- GxkImage --- */
enum {
IMAGE_PROP_0,
@@ -271,7 +256,6 @@ static void gxk_image_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
-
static void
gxk_image_set_property (GObject *object,
guint param_id,
@@ -292,7 +276,6 @@ gxk_image_set_property (GObject *object,
break;
}
}
-
static void
gxk_image_class_init (GxkImageClass *klass)
{
@@ -301,7 +284,6 @@ gxk_image_class_init (GxkImageClass *klass)
g_object_class_install_property (gobject_class, IMAGE_PROP_STOCK_SIZE,
g_param_spec_string ("stock-size", NULL, NULL, NULL, G_PARAM_WRITABLE));
}
-
GType
gxk_image_get_type (void)
{
@@ -323,8 +305,6 @@ gxk_image_get_type (void)
}
return type;
}
-
-
/* --- GxkWidgetPatcher --- */
static void gxk_widget_patcher_class_init (GxkWidgetPatcherClass *klass);
static void gxk_widget_patcher_set_property (GObject *object,
@@ -340,7 +320,6 @@ widget_patcher_unref (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
enum {
PATCHER_PROP_0,
PATCHER_PROP_TOOLTIP,
@@ -589,7 +568,6 @@ widget_patcher_adopt (GxkRadget *radget,
g_idle_add (widget_patcher_unref, self); /* takes over initial ref count */
return FALSE; /* no support for packing options */
}
-
GType
gxk_widget_patcher_get_type (void)
{
@@ -611,14 +589,12 @@ gxk_widget_patcher_get_type (void)
}
return type;
}
-
static GParamSpec*
widget_patcher_find_prop (GTypeClass *klass,
const gchar *prop_name)
{
return g_object_class_find_property (G_OBJECT_CLASS (klass), prop_name);
}
-
static GxkRadget*
widget_patcher_create (GType type,
const gchar *name,
@@ -628,7 +604,6 @@ widget_patcher_create (GType type,
{
return g_object_newv (type, n_construct_params, construct_params);
}
-
static const GxkRadgetType widget_patcher_def = {
widget_patcher_find_prop,
widget_patcher_create,
@@ -638,11 +613,8 @@ static const GxkRadgetType widget_patcher_def = {
NULL, /* set_pack */
};
const GxkRadgetType *gxk_widget_patcher_def = &widget_patcher_def;
-
-
/* --- back shade --- */
G_DEFINE_TYPE (GxkBackShade, gxk_back_shade, GTK_TYPE_ALIGNMENT);
-
/* color converion code stolen from gtkstyle.c */
static void
rgb_to_hls (gdouble red,
@@ -676,7 +648,6 @@ rgb_to_hls (gdouble red,
*l_p = l;
*s_p = s;
}
-
static void
hls_to_rgb (gdouble hue, /* 0..360 */
gdouble lightness, /* 0..1 */
@@ -699,7 +670,6 @@ hls_to_rgb (gdouble hue, /* 0..360 */
else
m2 = lightness + saturation - lightness * saturation;
gdouble m1 = 2 * lightness - m2;
-
chue = hue + 120;
while (chue > 360)
chue -= 360;
@@ -713,7 +683,6 @@ hls_to_rgb (gdouble hue, /* 0..360 */
*r_p = m1 + (m2 - m1) * (240 - chue) / 60;
else
*r_p = m1;
-
chue = hue;
while (chue > 360)
chue -= 360;
@@ -727,7 +696,6 @@ hls_to_rgb (gdouble hue, /* 0..360 */
*g_p = m1 + (m2 - m1) * (240 - chue) / 60;
else
*g_p = m1;
-
chue = hue - 120;
while (chue > 360)
chue -= 360;
@@ -743,7 +711,6 @@ hls_to_rgb (gdouble hue, /* 0..360 */
*b_p = m1;
}
}
-
static void
color_shade (GdkColor *color,
gdouble k)
@@ -760,7 +727,6 @@ color_shade (GdkColor *color,
color->green = g * 65535.;
color->blue = b * 65535.;
}
-
static GdkGC*
get_darkened_gc (GdkWindow *window,
GdkColor *srccolor,
@@ -773,7 +739,6 @@ get_darkened_gc (GdkWindow *window,
gdk_gc_set_rgb_fg_color (gc, &color);
return gc;
}
-
static gboolean
back_shade_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -789,13 +754,11 @@ back_shade_expose_event (GtkWidget *widget,
/* chain to parent */
return GTK_WIDGET_CLASS (gxk_back_shade_parent_class)->expose_event (widget, event);
}
-
static void
gxk_back_shade_init (GxkBackShade *self)
{
GTK_WIDGET_SET_FLAGS (self, GTK_VISIBLE);
}
-
static void
gxk_back_shade_class_init (GxkBackShadeClass *klass)
{
diff --git a/beast-gtk/gxk/gxkauxwidgets.hh b/beast-gtk/gxk/gxkauxwidgets.hh
index a54219d..ac1fb79 100644
--- a/beast-gtk/gxk/gxkauxwidgets.hh
+++ b/beast-gtk/gxk/gxkauxwidgets.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_AUX_WIDGETS_H__
#define __GXK_AUX_WIDGETS_H__
-
#include "gxkutils.hh"
#include "gxkradget.hh"
-
G_BEGIN_DECLS
-
/* --- menu item --- */
#define GXK_TYPE_MENU_ITEM (gxk_menu_item_get_type ())
#define GXK_MENU_ITEM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_MENU_ITEM, GxkMenuItem))
@@ -17,7 +14,6 @@ G_BEGIN_DECLS
typedef GtkImageMenuItem GxkMenuItem;
typedef GtkImageMenuItemClass GxkMenuItemClass;
GType gxk_menu_item_get_type (void);
-
/* --- scrolled window --- */
#define GXK_TYPE_SCROLLED_WINDOW (gxk_scrolled_window_get_type ())
#define GXK_SCROLLED_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_SCROLLED_WINDOW, GxkScrolledWindow))
@@ -28,7 +24,6 @@ GType gxk_menu_item_get_type (void);
typedef GtkScrolledWindow GxkScrolledWindow;
typedef GtkScrolledWindowClass GxkScrolledWindowClass;
GType gxk_scrolled_window_get_type (void);
-
/* --- free radio button --- */
#define GXK_TYPE_FREE_RADIO_BUTTON (gxk_free_radio_button_get_type ())
#define GXK_FREE_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXK_TYPE_FREE_RADIO_BUTTON, GxkFreeRadioButton))
@@ -40,7 +35,6 @@ typedef GtkRadioButton GxkFreeRadioButton;
typedef GtkRadioButtonClass GxkFreeRadioButtonClass;
GType gxk_free_radio_button_get_type (void);
GtkWidget* gxk_free_radio_button_new (void);
-
/* --- image --- */
#define GXK_TYPE_IMAGE (gxk_image_get_type ())
#define GXK_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_IMAGE, GxkImage))
@@ -51,7 +45,6 @@ GtkWidget* gxk_free_radio_button_new (void);
typedef GtkImage GxkImage;
typedef GtkImageClass GxkImageClass;
GType gxk_image_get_type (void);
-
/* --- widget-patcher --- */
#define GXK_TYPE_WIDGET_PATCHER (gxk_widget_patcher_get_type ())
#define GXK_WIDGET_PATCHER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_WIDGET_PATCHER, GxkWidgetPatcher))
@@ -78,7 +71,6 @@ typedef struct {
} GxkWidgetPatcher;
GType gxk_widget_patcher_get_type (void);
extern const GxkRadgetType *gxk_widget_patcher_def;
-
/* --- back shade --- */
#define GXK_TYPE_BACK_SHADE (gxk_back_shade_get_type ())
#define GXK_BACK_SHADE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_BACK_SHADE, GxkBackShade))
@@ -89,9 +81,5 @@ extern const GxkRadgetType *gxk_widget_patcher_def;
typedef GtkAlignment GxkBackShade;
typedef GtkAlignmentClass GxkBackShadeClass;
GType gxk_back_shade_get_type (void);
-
-
-
G_END_DECLS
-
#endif /* __GXK_AUX_WIDGETS_H__ */
diff --git a/beast-gtk/gxk/gxkcanvas.cc b/beast-gtk/gxk/gxkcanvas.cc
index 0df98cb..03ac179 100644
--- a/beast-gtk/gxk/gxkcanvas.cc
+++ b/beast-gtk/gxk/gxkcanvas.cc
@@ -1,27 +1,21 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkcanvas.hh"
#include "gxkutils.hh"
-
-
/* --- functions --- */
GnomeCanvasPoints*
gnome_canvas_points_new0 (guint num_points)
{
GnomeCanvasPoints *points;
guint i;
-
g_return_val_if_fail (num_points > 1, NULL);
-
points = gnome_canvas_points_new (num_points);
for (i = 0; i < num_points; i++)
{
points->coords[i] = 0;
points->coords[i + num_points] = 0;
}
-
return points;
}
-
GnomeCanvasPoints*
gnome_canvas_points_newv (guint num_points,
...)
@@ -29,18 +23,14 @@ gnome_canvas_points_newv (guint num_points,
GnomeCanvasPoints *points;
guint i;
va_list args;
-
g_return_val_if_fail (num_points > 1, NULL);
-
va_start (args, num_points);
points = gnome_canvas_points_new (num_points);
for (i = 0; i < num_points * 2; i++)
points->coords[i] = va_arg (args, gdouble);
va_end (args);
-
return points;
}
-
GnomeCanvasItem*
gnome_canvas_typed_item_at (GnomeCanvas *canvas,
GtkType item_type,
@@ -48,16 +38,12 @@ gnome_canvas_typed_item_at (GnomeCanvas *canvas,
gdouble world_y)
{
GnomeCanvasItem *item;
-
g_return_val_if_fail (GNOME_IS_CANVAS (canvas), NULL);
-
item = gnome_canvas_get_item_at (canvas, world_x, world_y);
while (item && !g_type_is_a (GTK_OBJECT_TYPE (item), item_type))
item = item->parent;
-
return item && g_type_is_a (GTK_OBJECT_TYPE (item), item_type) ? item : NULL;
}
-
gboolean
gnome_canvas_item_check_undisposed (GnomeCanvasItem *item)
{
@@ -76,18 +62,15 @@ gnome_canvas_item_check_undisposed (GnomeCanvasItem *item)
}
return FALSE;
}
-
guint
gnome_canvas_item_get_stacking (GnomeCanvasItem *item)
{
g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), 0);
-
if (item->parent)
{
GnomeCanvasGroup *parent = GNOME_CANVAS_GROUP (item->parent);
GList *list;
guint pos = 0;
-
for (list = parent->item_list; list; list = list->next)
{
if (list->data == item)
@@ -95,10 +78,8 @@ gnome_canvas_item_get_stacking (GnomeCanvasItem *item)
pos++;
}
}
-
return 0;
}
-
void
gnome_canvas_item_keep_between (GnomeCanvasItem *between,
GnomeCanvasItem *item1,
@@ -107,13 +88,11 @@ gnome_canvas_item_keep_between (GnomeCanvasItem *between,
g_return_if_fail (GNOME_IS_CANVAS_ITEM (between));
g_return_if_fail (GNOME_IS_CANVAS_ITEM (item1));
g_return_if_fail (GNOME_IS_CANVAS_ITEM (item2));
-
if (between->parent && item1->parent && item2->parent)
{
if (item1->parent == between->parent && item2->parent == between->parent)
{
guint n, i, z;
-
n = gnome_canvas_item_get_stacking (item1);
i = gnome_canvas_item_get_stacking (item2);
z = gnome_canvas_item_get_stacking (between);
@@ -127,7 +106,6 @@ gnome_canvas_item_keep_between (GnomeCanvasItem *between,
g_warning ("gnome_canvas_item_keep_between() called for non-siblings");
}
}
-
void
gnome_canvas_item_keep_above (GnomeCanvasItem *above,
GnomeCanvasItem *item1,
@@ -136,13 +114,11 @@ gnome_canvas_item_keep_above (GnomeCanvasItem *above,
g_return_if_fail (GNOME_IS_CANVAS_ITEM (above));
g_return_if_fail (GNOME_IS_CANVAS_ITEM (item1));
g_return_if_fail (GNOME_IS_CANVAS_ITEM (item2));
-
if (above->parent && item1->parent && item2->parent)
{
if (item1->parent == above->parent && item2->parent == above->parent)
{
guint n, i, z;
-
n = gnome_canvas_item_get_stacking (item1);
i = gnome_canvas_item_get_stacking (item2);
z = gnome_canvas_item_get_stacking (above);
@@ -156,7 +132,6 @@ gnome_canvas_item_keep_above (GnomeCanvasItem *above,
g_warning ("gnome_canvas_item_keep_above() called for non-siblings");
}
}
-
/**
* @param item canvas text item
* @param pixels default font size
@@ -170,11 +145,9 @@ gnome_canvas_text_set_zoom_size (GnomeCanvasText *item,
gdouble pixels)
{
g_return_if_fail (GNOME_IS_CANVAS_TEXT (item));
-
g_object_set (item, "size_points", pixels * GNOME_CANVAS_ITEM(item)->canvas->pixels_per_unit, NULL);
g_object_set_double (item, "zoom_size", pixels);
}
-
static void
canvas_adjust_text_zoom (GnomeCanvasGroup *group,
gdouble pixels_per_unit)
@@ -193,7 +166,6 @@ canvas_adjust_text_zoom (GnomeCanvasGroup *group,
canvas_adjust_text_zoom (GNOME_CANVAS_GROUP (item), pixels_per_unit);
}
}
-
/**
* @param canvas valid GnomeCanvas
* @param pixels_per_unit zoom factor (defaults to 1.0)
@@ -208,22 +180,18 @@ gnome_canvas_set_zoom (GnomeCanvas *canvas,
gdouble pixels_per_unit)
{
g_return_if_fail (GNOME_IS_CANVAS (canvas));
-
/* adjust all text items */
canvas_adjust_text_zoom (GNOME_CANVAS_GROUP (canvas->root), pixels_per_unit);
/* perform the actual zoom */
gnome_canvas_set_pixels_per_unit (canvas, pixels_per_unit);
}
-
void
gnome_canvas_FIXME_hard_update (GnomeCanvas *canvas)
{
return;
g_return_if_fail (GNOME_IS_CANVAS (canvas));
-
/* _first_ recalc bounds of already queued items */
gnome_canvas_update_now (canvas);
-
/* just requeueing an update doesn't suffice for rect-ellipses,
* re-translating the root-item is good enough though.
*/
diff --git a/beast-gtk/gxk/gxkcanvas.hh b/beast-gtk/gxk/gxkcanvas.hh
index 2b98c31..ba91193 100644
--- a/beast-gtk/gxk/gxkcanvas.hh
+++ b/beast-gtk/gxk/gxkcanvas.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_CANVAS_H__
#define __GXK_CANVAS_H__
-
#include <gxk/gxkglobals.hh>
#include <libgnomecanvas/libgnomecanvas.h>
-
G_BEGIN_DECLS
-
/* --- functions --- */
GnomeCanvasPoints* gnome_canvas_points_new0 (guint num_points);
GnomeCanvasPoints* gnome_canvas_points_newv (guint num_points,
@@ -28,8 +25,5 @@ void gnome_canvas_text_set_zoom_size (GnomeCanvasText *item,
void gnome_canvas_set_zoom (GnomeCanvas *canvas,
gdouble pixels_per_unit);
void gnome_canvas_FIXME_hard_update (GnomeCanvas *canvas);
-
-
G_END_DECLS
-
#endif /* __GXK_CANVAS_H__ */
diff --git a/beast-gtk/gxk/gxkcellrendererpopup.cc b/beast-gtk/gxk/gxkcellrendererpopup.cc
index 0083c67..5719628 100644
--- a/beast-gtk/gxk/gxkcellrendererpopup.cc
+++ b/beast-gtk/gxk/gxkcellrendererpopup.cc
@@ -6,18 +6,13 @@
#include <gtk/gtkarrow.h>
#include <gtk/gtkframe.h>
#include <gtk/gtklabel.h>
-
-
#define ARROW_WIDTH 20
-
enum {
PROP_NONE,
PROP_TEXT_EDITING,
PROP_POPUP_EDITING,
PROP_AUTO_POPUP,
};
-
-
/* --- prototypes --- */
static void gxk_cell_renderer_popup_init (GxkCellRendererPopup *self);
static void gxk_cell_renderer_popup_class_init (GxkCellRendererPopupClass *klass);
@@ -50,13 +45,9 @@ static GtkCellEditable* gxk_cell_renderer_popup_start_editing (GtkCellRenderer
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static guint signal_popup = 0;
-
-
/* --- functions --- */
/**
* @return GXK_TYPE_CELL_RENDERER_POPUP
@@ -68,7 +59,6 @@ GType
gxk_cell_renderer_popup_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
@@ -82,29 +72,23 @@ gxk_cell_renderer_popup_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gxk_cell_renderer_popup_init,
};
-
type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT,
"GxkCellRendererPopup",
&type_info, GTypeFlags (0));
}
return type;
}
-
static void
gxk_cell_renderer_popup_class_init (GxkCellRendererPopupClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->get_property = gxk_cell_renderer_popup_get_property;
object_class->set_property = gxk_cell_renderer_popup_set_property;
-
cell_class->get_size = gxk_cell_renderer_popup_get_size;
cell_class->render = gxk_cell_renderer_popup_render;
cell_class->start_editing = gxk_cell_renderer_popup_start_editing;
-
g_object_class_install_property (object_class,
PROP_TEXT_EDITING,
g_param_spec_boolean ("text-editing", "Text Editing", "Whether the text is directly editable",
@@ -127,7 +111,6 @@ gxk_cell_renderer_popup_class_init (GxkCellRendererPopupClass *klass)
G_TYPE_STRING,
G_TYPE_STRING);
}
-
static void
gxk_cell_renderer_popup_init (GxkCellRendererPopup *self)
{
@@ -137,7 +120,6 @@ gxk_cell_renderer_popup_init (GxkCellRendererPopup *self)
// GTK_CELL_RENDERER (self)->xpad = 2;
// GTK_CELL_RENDERER (self)->ypad = 2;
}
-
static void
gxk_cell_renderer_popup_set_property (GObject *object,
guint param_id,
@@ -145,7 +127,6 @@ gxk_cell_renderer_popup_set_property (GObject *object,
GParamSpec *pspec)
{
GxkCellRendererPopup *self = GXK_CELL_RENDERER_POPUP (object);
-
switch (param_id)
{
case PROP_TEXT_EDITING:
@@ -162,7 +143,6 @@ gxk_cell_renderer_popup_set_property (GObject *object,
break;
}
}
-
static void
gxk_cell_renderer_popup_get_property (GObject *object,
guint param_id,
@@ -170,7 +150,6 @@ gxk_cell_renderer_popup_get_property (GObject *object,
GParamSpec *pspec)
{
GxkCellRendererPopup *self = GXK_CELL_RENDERER_POPUP (object);
-
switch (param_id)
{
case PROP_TEXT_EDITING:
@@ -187,7 +166,6 @@ gxk_cell_renderer_popup_get_property (GObject *object,
break;
}
}
-
static void
gxk_cell_renderer_popup_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
@@ -198,9 +176,7 @@ gxk_cell_renderer_popup_get_size (GtkCellRenderer *cell,
gint *height_p)
{
GxkCellRendererPopup *self = GXK_CELL_RENDERER_POPUP (cell);
-
GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell, widget, cell_area, xoffs_p, yoffs_p, width_p, height_p);
-
if (self->popup_editing)
{
if (width_p)
@@ -209,7 +185,6 @@ gxk_cell_renderer_popup_get_size (GtkCellRenderer *cell,
*xoffs_p = MAX (*xoffs_p - ARROW_WIDTH / 2, 0);
}
}
-
static void
gxk_cell_renderer_popup_render (GtkCellRenderer *cell,
GdkWindow *window,
@@ -247,7 +222,6 @@ gxk_cell_renderer_popup_render (GtkCellRenderer *cell,
area->x, area->y, area->width, area->height);
#endif
}
-
void
gxk_cell_renderer_popup_dialog (GxkCellRendererPopup *self,
GtkWidget *dialog)
@@ -255,7 +229,6 @@ gxk_cell_renderer_popup_dialog (GxkCellRendererPopup *self,
g_return_if_fail (GXK_IS_CELL_RENDERER_POPUP (self));
if (dialog)
g_return_if_fail (GTK_IS_WINDOW (dialog));
-
if (self->dialog)
{
gxk_toplevel_delete (self->dialog);
@@ -268,14 +241,12 @@ gxk_cell_renderer_popup_dialog (GxkCellRendererPopup *self,
gxk_widget_showraise (self->dialog);
}
}
-
static void
gxk_cell_renderer_remove_widget (GxkCellRendererPopup *self)
{
gxk_cell_renderer_popup_dialog (self, NULL);
self->entry = NULL;
}
-
static void
gxk_cell_renderer_popup_editing_done (GxkCellRendererPopup *self,
GtkEntry *entry)
@@ -285,7 +256,6 @@ gxk_cell_renderer_popup_editing_done (GxkCellRendererPopup *self,
return;
g_signal_emit_by_name (self, "edited", path, gtk_entry_get_text (entry));
}
-
void
gxk_cell_renderer_popup_change (GxkCellRendererPopup *self,
const gchar *text,
@@ -293,7 +263,6 @@ gxk_cell_renderer_popup_change (GxkCellRendererPopup *self,
gboolean keep_editing)
{
g_return_if_fail (GXK_IS_CELL_RENDERER_POPUP (self));
-
if (self->entry && text)
gtk_entry_set_text (GTK_ENTRY (self->entry), text);
if (!preserve_popup)
@@ -306,7 +275,6 @@ gxk_cell_renderer_popup_change (GxkCellRendererPopup *self,
gtk_cell_editable_remove_widget (ecell);
}
}
-
static gboolean
gxk_cell_renderer_popup_clicked (GxkCellRendererPopup *self)
{
@@ -320,19 +288,16 @@ gxk_cell_renderer_popup_clicked (GxkCellRendererPopup *self)
}
return TRUE; /* we handled the event */
}
-
static gboolean
gxk_cell_renderer_idle_popup (gpointer data)
{
GxkCellRendererPopup *self = GXK_CELL_RENDERER_POPUP (data);
-
GDK_THREADS_ENTER ();
if (self->auto_popup && !self->dialog && self->entry)
gxk_cell_renderer_popup_clicked (self);
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static GtkCellEditable*
gxk_cell_renderer_popup_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
@@ -389,7 +354,6 @@ gxk_cell_renderer_popup_start_editing (GtkCellRenderer *cell,
g_object_unref);
return GTK_CELL_EDITABLE (eproxy);
}
-
/* --- GxkProxyEditable --- */
static void
gxk_proxy_editable_start_editing (GtkCellEditable *cell_editable,
@@ -405,7 +369,6 @@ gxk_proxy_editable_start_editing (GtkCellEditable *cell_editable,
self->block_start_editing--;
}
}
-
static void
gxk_proxy_editable_remove_widget (GtkCellEditable *cell_editable)
{
@@ -417,7 +380,6 @@ gxk_proxy_editable_remove_widget (GtkCellEditable *cell_editable)
self->block_remove_widget--;
}
}
-
static void
gxk_proxy_editable_proxy_remove_widget (GtkCellEditable *cell_editable)
{
@@ -429,7 +391,6 @@ gxk_proxy_editable_proxy_remove_widget (GtkCellEditable *cell_editable)
self->block_remove_widget--;
}
}
-
static void
gxk_proxy_editable_editing_done (GtkCellEditable *cell_editable)
{
@@ -441,7 +402,6 @@ gxk_proxy_editable_editing_done (GtkCellEditable *cell_editable)
self->block_editing_done--;
}
}
-
static void
gxk_proxy_editable_proxy_editing_done (GtkCellEditable *cell_editable)
{
@@ -453,7 +413,6 @@ gxk_proxy_editable_proxy_editing_done (GtkCellEditable *cell_editable)
self->block_editing_done--;
}
}
-
/**
* @param self valid GxkProxyEditable
* @param ecell valid GtkCellEditable
@@ -469,7 +428,6 @@ gxk_proxy_editable_set_cell_editable (GxkProxyEditable *self,
g_return_if_fail (GXK_IS_PROXY_EDITABLE (self));
g_return_if_fail (GTK_IS_CELL_EDITABLE (ecell));
g_return_if_fail (self->ecell == NULL);
-
self->ecell = ecell;
g_signal_connect_object (ecell, "remove_widget",
G_CALLBACK (gxk_proxy_editable_proxy_remove_widget), self,
@@ -478,7 +436,6 @@ gxk_proxy_editable_set_cell_editable (GxkProxyEditable *self,
G_CALLBACK (gxk_proxy_editable_proxy_editing_done), self,
G_CONNECT_SWAPPED);
}
-
static void
gxk_proxy_editable_init_cell_editable (GtkCellEditableIface *iface)
{
@@ -486,7 +443,6 @@ gxk_proxy_editable_init_cell_editable (GtkCellEditableIface *iface)
iface->remove_widget = gxk_proxy_editable_remove_widget;
iface->editing_done = gxk_proxy_editable_editing_done;
}
-
/**
* @return GXK_TYPE_PROXY_EDITABLE
*
@@ -499,7 +455,6 @@ GType
gxk_proxy_editable_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
diff --git a/beast-gtk/gxk/gxkcellrendererpopup.hh b/beast-gtk/gxk/gxkcellrendererpopup.hh
index 1edb57d..34910de 100644
--- a/beast-gtk/gxk/gxkcellrendererpopup.hh
+++ b/beast-gtk/gxk/gxkcellrendererpopup.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_CELL_RENDERER_POPUP_H__
#define __GXK_CELL_RENDERER_POPUP_H__
-
#include <gxk/gxkutils.hh>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkeventbox.h>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_CELL_RENDERER_POPUP (gxk_cell_renderer_popup_get_type ())
#define GXK_CELL_RENDERER_POPUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_CELL_RENDERER_POPUP, GxkCellRendererPopup))
@@ -15,8 +12,6 @@ G_BEGIN_DECLS
#define GXK_IS_CELL_RENDERER_POPUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_CELL_RENDERER_POPUP))
#define GXK_IS_CELL_RENDERER_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_CELL_RENDERER_POPUP))
#define GXK_CELL_RENDERER_POPUP_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_CELL_RENDERER_POPUP, GxkCellRendererPopupClass))
-
-
/* --- structures & typedefs --- */
typedef struct {
GtkCellRendererText parent_instace;
@@ -31,8 +26,6 @@ typedef struct {
const gchar *path,
const gchar *text);
} GxkCellRendererPopupClass;
-
-
/* --- functions --- */
GType gxk_cell_renderer_popup_get_type (void);
void gxk_cell_renderer_popup_dialog (GxkCellRendererPopup *popup,
@@ -41,8 +34,6 @@ void gxk_cell_renderer_popup_change (GxkCellRendererPopup *popup,
const gchar *text,
gboolean preserve_popup,
gboolean keep_editing);
-
-
/* --- type macros --- */
#define GXK_TYPE_PROXY_EDITABLE (gxk_proxy_editable_get_type ())
#define GXK_PROXY_EDITABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_PROXY_EDITABLE, GxkProxyEditable))
@@ -50,8 +41,6 @@ void gxk_cell_renderer_popup_change (GxkCellRendererPopup *popup,
#define GXK_IS_PROXY_EDITABLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_PROXY_EDITABLE))
#define GXK_IS_PROXY_EDITABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_PROXY_EDITABLE))
#define GXK_PROXY_EDITABLE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_PROXY_EDITABLE, GxkProxyEditableClass))
-
-
/* --- structures & typedefs --- */
typedef struct {
GtkEventBox parent_instace;
@@ -63,14 +52,9 @@ typedef struct {
typedef struct {
GtkEventBoxClass parent_class;
} GxkProxyEditableClass;
-
-
/* --- functions --- */
GType gxk_proxy_editable_get_type (void);
void gxk_proxy_editable_set_cell_editable (GxkProxyEditable *self,
GtkCellEditable *ecell);
-
-
G_END_DECLS
-
#endif /* __GXK_CELL_RENDERER_POPUP_H__ */
diff --git a/beast-gtk/gxk/gxkdialog.cc b/beast-gtk/gxk/gxkdialog.cc
index 05edc92..d4e7a78 100644
--- a/beast-gtk/gxk/gxkdialog.cc
+++ b/beast-gtk/gxk/gxkdialog.cc
@@ -5,10 +5,7 @@
#include "gxkstatusbar.hh"
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
#define DEFAULT_TITLE "Auxillary Dialog"
-
-
/* --- properties --- */
enum {
PROP_0,
@@ -17,29 +14,20 @@ enum {
PROP_FLAGS,
PROP_TITLE
};
-
-
/* --- prototypes --- */
-
-
/* --- variables --- */
static GSList *enter_stack = NULL;
-
-
/* --- functions --- */
G_DEFINE_TYPE (GxkDialog, gxk_dialog, GTK_TYPE_WINDOW);
-
static void
gxk_dialog_init (GxkDialog *self)
{
GtkWindow *window = GTK_WINDOW (self);
-
self->flags = GxkDialogFlags (0);
self->pointer_loc = NULL;
self->alive_object = NULL;
gtk_window_set_role (window, G_OBJECT_TYPE_NAME (self));
gxk_dialog_set_title (self, DEFAULT_TITLE);
-
/* main box */
self->mbox = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -48,7 +36,6 @@ gxk_dialog_init (GxkDialog *self)
"parent", window,
NULL);
gxk_nullify_in_object (self, &self->mbox);
-
/* user vbox */
self->vbox = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -57,12 +44,10 @@ gxk_dialog_init (GxkDialog *self)
"parent", self->mbox,
NULL);
gxk_nullify_in_object (self, &self->vbox);
-
/* status bar */
self->status_bar = gxk_status_bar_create ();
gxk_nullify_in_object (self, &self->status_bar);
gtk_box_pack_end (GTK_BOX (self->mbox), self->status_bar, FALSE, FALSE, 0);
-
/* button box */
self->hbox = (GtkWidget*) g_object_new (GTK_TYPE_HBOX,
"visible", FALSE,
@@ -72,7 +57,6 @@ gxk_dialog_init (GxkDialog *self)
NULL);
gxk_nullify_in_object (self, &self->hbox);
gtk_box_pack_end (GTK_BOX (self->mbox), self->hbox, FALSE, TRUE, 0);
-
/* separator */
self->sep = (GtkWidget*) g_object_new (GTK_TYPE_HSEPARATOR,
"visible", FALSE,
@@ -80,7 +64,6 @@ gxk_dialog_init (GxkDialog *self)
gxk_nullify_in_object (self, &self->sep);
gtk_box_pack_end (GTK_BOX (self->mbox), self->sep, FALSE, FALSE, 0);
}
-
static void
gxk_dialog_set_property (GObject *object,
guint prop_id,
@@ -88,7 +71,6 @@ gxk_dialog_set_property (GObject *object,
GParamSpec *pspec)
{
GxkDialog *self = GXK_DIALOG (object);
-
switch (prop_id)
{
GtkWindow *window;
@@ -161,7 +143,6 @@ gxk_dialog_set_property (GObject *object,
break;
}
}
-
static void
gxk_dialog_get_property (GObject *object,
guint prop_id,
@@ -169,7 +150,6 @@ gxk_dialog_get_property (GObject *object,
GParamSpec *pspec)
{
GxkDialog *dialog = GXK_DIALOG (object);
-
switch (prop_id)
{
case PROP_FLAGS:
@@ -189,37 +169,28 @@ gxk_dialog_get_property (GObject *object,
break;
}
}
-
static void
gxk_dialog_destroy (GtkObject *object)
{
GxkDialog *dialog = GXK_DIALOG (object);
-
enter_stack = g_slist_remove (enter_stack, dialog);
-
if (dialog->pointer_loc)
*dialog->pointer_loc = NULL;
-
g_object_set (dialog,
"alive_object", NULL,
"pointer", NULL,
NULL);
-
GTK_OBJECT_CLASS (gxk_dialog_parent_class)->destroy (object);
}
-
static void
gxk_dialog_finalize (GObject *object)
{
GxkDialog *dialog = GXK_DIALOG (object);
-
if (dialog->child)
g_object_unref (dialog->child);
dialog->child = NULL;
-
G_OBJECT_CLASS (gxk_dialog_parent_class)->finalize (object);
}
-
/**
* @param pointer_loc pointer to nullify upon dialog destruction
* @param alive_object object which upon destruction, takes the dialog with it
@@ -248,7 +219,6 @@ gxk_dialog_new (gpointer pointer_loc,
GtkWidget *child)
{
GxkDialog *dialog;
-
dialog = (GxkDialog*) g_object_new (GXK_TYPE_DIALOG,
"pointer", pointer_loc,
"alive_object", alive_object,
@@ -257,10 +227,8 @@ gxk_dialog_new (gpointer pointer_loc,
NULL);
gxk_dialog_set_title (dialog, title);
gxk_dialog_set_child (dialog, child);
-
return dialog;
}
-
gpointer
gxk_dialog_new_radget (gpointer pointer_loc,
GtkObject *alive_object,
@@ -275,7 +243,6 @@ gxk_dialog_new_radget (gpointer pointer_loc,
else
return NULL;
}
-
static void
gxk_dialog_set_min_size (GxkDialog *self,
gint min_width,
@@ -292,7 +259,6 @@ gxk_dialog_set_min_size (GxkDialog *self,
gtk_window_set_geometry_hints (GTK_WINDOW (self), NULL, &geometry, GDK_HINT_MIN_SIZE);
}
}
-
/**
* @param dialog valid GxkDialog
* @param min_width minimum dialog width or -1
@@ -325,7 +291,6 @@ gxk_dialog_set_sizes (GxkDialog *dialog,
gxk_dialog_set_min_size (dialog, min_width, min_height);
gtk_window_set_default_size (GTK_WINDOW (dialog), default_width, default_height);
}
-
/**
* @param dialog valid GxkDialog
* @param title dialog window manager title
@@ -337,10 +302,8 @@ gxk_dialog_set_title (GxkDialog *dialog,
const gchar *title)
{
g_return_if_fail (GXK_IS_DIALOG (dialog));
-
g_object_set (dialog, "title", title, NULL);
}
-
/**
* @param dialog valid GxkDialog
* @param flags additional flags to set on the dialog.
@@ -352,14 +315,11 @@ gxk_dialog_add_flags (GxkDialog *dialog,
GxkDialogFlags flags)
{
gint f;
-
g_return_if_fail (GXK_IS_DIALOG (dialog));
-
f = dialog->flags;
f |= flags;
g_object_set (dialog, "flags", f, NULL);
}
-
/**
* @param dialog valid GxkDialog
* @param flags flags to unset on the dialog.
@@ -371,14 +331,11 @@ gxk_dialog_clear_flags (GxkDialog *dialog,
GxkDialogFlags flags)
{
gint f;
-
g_return_if_fail (GXK_IS_DIALOG (dialog));
-
f = dialog->flags;
f &= ~flags;
g_object_set (dialog, "flags", f, NULL);
}
-
/**
* @param dialog valid GxkDialog
*
@@ -391,7 +348,6 @@ gxk_dialog_get_child (GxkDialog *dialog)
/* return the single child that was passed to gxk_dialog_new() if any */
return dialog->child;
}
-
/**
* @param dialog valid GxkDialog
* @param child new child
@@ -404,7 +360,6 @@ gxk_dialog_set_child (GxkDialog *dialog,
GtkWidget *child)
{
g_return_if_fail (GXK_IS_DIALOG (dialog));
-
gtk_container_foreach (GTK_CONTAINER (dialog->vbox), (GtkCallback) gtk_widget_destroy, NULL);
if (dialog->child)
g_object_unref (dialog->child);
@@ -415,7 +370,6 @@ gxk_dialog_set_child (GxkDialog *dialog,
gtk_container_add (GTK_CONTAINER (dialog->vbox), gtk_widget_get_toplevel (child));
}
}
-
/**
* @param dialog valid GxkDialog
* @param focus_widget valid GtkWidget
@@ -429,13 +383,11 @@ gxk_dialog_set_focus (GxkDialog *self,
GtkWidget *focus_widget)
{
g_return_if_fail (GXK_IS_DIALOG (self));
-
if (self->focus_widget)
g_signal_handlers_disconnect_by_func (self->focus_widget, (void*) g_nullify_pointer, &self->focus_widget);
self->focus_widget = focus_widget;
g_signal_connect_swapped (self->focus_widget, "destroy", G_CALLBACK (g_nullify_pointer), &self->focus_widget);
}
-
/**
* @param dialog valid GxkDialog
* @param default_widget valid GtkWidget
@@ -449,7 +401,6 @@ gxk_dialog_set_default (GxkDialog *self,
GtkWidget *default_widget)
{
g_return_if_fail (GXK_IS_DIALOG (self));
-
if (self->default_widget)
g_signal_handlers_disconnect_by_func (self->default_widget, (void*) g_nullify_pointer, &self->default_widget);
self->default_widget = default_widget;
@@ -457,17 +408,14 @@ gxk_dialog_set_default (GxkDialog *self,
if (!self->focus_widget && default_widget)
gxk_dialog_set_focus (self, default_widget);
}
-
static void
gxk_dialog_show (GtkWidget *widget)
{
GxkDialog *self = GXK_DIALOG (widget);
-
if (self->flags & GXK_DIALOG_POPUP_POS)
g_object_set (self, "window_position", GTK_WIN_POS_MOUSE, NULL);
else
g_object_set (self, "window_position", GTK_WIN_POS_NONE, NULL);
-
if (self->focus_widget && GTK_WIDGET_CAN_FOCUS (self->focus_widget) &&
gtk_widget_get_toplevel (self->focus_widget) == widget)
gtk_window_set_focus (GTK_WINDOW (self), self->focus_widget);
@@ -475,34 +423,25 @@ gxk_dialog_show (GtkWidget *widget)
gtk_window_set_focus (GTK_WINDOW (self), NULL);
if (self->default_widget)
gtk_widget_grab_default (self->default_widget);
-
if (self->status_bar &&
gxk_dialog_get_status_window () == NULL &&
!g_slist_find (enter_stack, self))
enter_stack = g_slist_prepend (enter_stack, self);
-
GTK_WIDGET_CLASS (gxk_dialog_parent_class)->show (widget);
-
gxk_widget_viewable_changed (widget);
-
/* GTKFIX: gtk doesn't take away focus from a widget on a hidden notebook page when realizing the window */
if (self->focus_widget && !gxk_widget_viewable (self->focus_widget))
gtk_window_set_focus (GTK_WINDOW (self), NULL);
}
-
static void
gxk_dialog_hide (GtkWidget *widget)
{
GxkDialog *self = GXK_DIALOG (widget);
-
GTK_WIDGET_CLASS (gxk_dialog_parent_class)->hide (widget);
-
gxk_widget_viewable_changed (widget);
-
if (!(self->flags & GXK_DIALOG_PRESERVE_STATE))
gxk_idle_unrealize_widget (widget);
}
-
static gboolean
gxk_dialog_key_press_event (GtkWidget *widget,
GdkEventKey *event)
@@ -510,7 +449,6 @@ gxk_dialog_key_press_event (GtkWidget *widget,
GxkDialog *dialog = GXK_DIALOG (widget);
GtkWindow *window = GTK_WINDOW (widget);
gboolean handled = FALSE;
-
/* decide whether we close the window upon Escape:
* - we provide Escape as a short cut for the GXK_DIALOG_DELETE_BUTTON
* - we offer Escape for normal dialogs, i.e. non status-shell ones.
@@ -523,12 +461,10 @@ gxk_dialog_key_press_event (GtkWidget *widget,
gxk_toplevel_delete (widget);
return TRUE;
}
-
/* we're overriding the GtkWindow implementation here to give
* the focus widget precedence over unmodified accelerators
* before the accelerator activation scheme.
*/
-
/* invoke control/alt accelerators */
if (!handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
handled = gtk_window_activate_key (window, event);
@@ -541,16 +477,13 @@ gxk_dialog_key_press_event (GtkWidget *widget,
/* chain up, bypassing gtk_window_key_press(), to invoke binding set */
if (!handled)
handled = GTK_WIDGET_CLASS (g_type_class_peek (g_type_parent (GTK_TYPE_WINDOW)))->key_press_event (widget, event);
-
return handled;
}
-
static gboolean
gxk_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
GxkDialog *dialog = GXK_DIALOG (widget);
-
if (dialog->flags & GXK_DIALOG_HIDE_ON_DELETE)
{
gtk_widget_hide (GTK_WIDGET (dialog));
@@ -559,14 +492,12 @@ gxk_dialog_delete_event (GtkWidget *widget,
else
return FALSE;
}
-
static gboolean
gxk_dialog_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
GxkDialog *dialog = GXK_DIALOG (widget);
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent*) event);
-
if (event_widget == widget && event->detail != GDK_NOTIFY_INFERIOR)
{
enter_stack = g_slist_remove (enter_stack, dialog);
@@ -574,7 +505,6 @@ gxk_dialog_enter_notify_event (GtkWidget *widget,
}
return FALSE;
}
-
/**
* @return a valid GxkDialog or NULL
*
@@ -584,17 +514,14 @@ GxkDialog*
gxk_dialog_get_status_window (void)
{
GSList *slist;
-
for (slist = enter_stack; slist; slist = slist->next)
{
GxkDialog *dialog = GXK_DIALOG (slist->data);
-
if (dialog->status_bar && GTK_WIDGET_DRAWABLE (dialog->status_bar))
return dialog;
}
return NULL;
}
-
/**
* @param dialog valid GxkDialog
*
@@ -604,12 +531,10 @@ void
gxk_dialog_remove_actions (GxkDialog *dialog)
{
g_return_if_fail (GXK_IS_DIALOG (dialog));
-
if (dialog->hbox)
gtk_container_foreach (GTK_CONTAINER (dialog->hbox), (GtkCallback) gtk_widget_destroy, NULL);
dialog->flags &= ~GXK_DIALOG_DELETE_BUTTON;
}
-
/**
* @param dialog valid GxkDialog
* @param action button label or stock ID
@@ -627,23 +552,18 @@ gxk_dialog_action_multi (GxkDialog *self,
GxkDialogMultiFlags multi_mode)
{
GtkWidget *button = NULL;
-
g_return_val_if_fail (GXK_IS_DIALOG (self), NULL);
g_return_val_if_fail (action != NULL, NULL);
-
if (self->sep)
gtk_widget_show (self->sep);
if (self->hbox)
{
GtkWidget *alignment, *hbox, *image = icon_stock_id ? gxk_stock_image (icon_stock_id, GXK_ICON_SIZE_BUTTON) : NULL;
-
if (!image)
image = gxk_stock_image (action, GXK_ICON_SIZE_BUTTON);
-
/* catch installation of a Close button */
if (strcmp (action, GTK_STOCK_CLOSE) == 0)
self->flags |= GXK_DIALOG_DELETE_BUTTON;
-
/* setup button */
button = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"can_default", TRUE,
@@ -653,7 +573,6 @@ gxk_dialog_action_multi (GxkDialog *self,
g_signal_connect_data (button, "clicked",
GCallback (callback), data, NULL,
GConnectFlags ((multi_mode & GXK_DIALOG_MULTI_SWAPPED) ? G_CONNECT_SWAPPED : 0));
-
/* setup button contents */
alignment = gtk_alignment_new (0.5, 0.5, 0.1, 0.1);
gtk_container_add (GTK_CONTAINER (button), alignment);
@@ -668,34 +587,27 @@ gxk_dialog_action_multi (GxkDialog *self,
NULL),
FALSE, TRUE, 0);
gtk_widget_show_all (button);
-
gtk_widget_show (self->hbox);
-
if (multi_mode & GXK_DIALOG_MULTI_DEFAULT)
gxk_dialog_set_default (self, button);
}
return button;
}
-
static void
gxk_dialog_class_init (GxkDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
gobject_class->finalize = gxk_dialog_finalize;
gobject_class->set_property = gxk_dialog_set_property;
gobject_class->get_property = gxk_dialog_get_property;
-
object_class->destroy = gxk_dialog_destroy;
-
widget_class->show = gxk_dialog_show;
widget_class->hide = gxk_dialog_hide;
widget_class->key_press_event = gxk_dialog_key_press_event;
widget_class->delete_event = gxk_dialog_delete_event;
widget_class->enter_notify_event = gxk_dialog_enter_notify_event;
-
g_object_class_install_property (G_OBJECT_CLASS (object_class),
PROP_POINTER,
g_param_spec_pointer ("pointer", NULL, NULL,
diff --git a/beast-gtk/gxk/gxkdialog.hh b/beast-gtk/gxk/gxkdialog.hh
index 6114f80..a5c2672 100644
--- a/beast-gtk/gxk/gxkdialog.hh
+++ b/beast-gtk/gxk/gxkdialog.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_DIALOG_H__
#define __GXK_DIALOG_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_DIALOG (gxk_dialog_get_type ())
#define GXK_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_DIALOG, GxkDialog))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_DIALOG))
#define GXK_IS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_DIALOG))
#define GXK_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_DIALOG, GxkDialogClass))
-
-
/* --- typedefs & enums --- */
typedef struct _GxkDialog GxkDialog;
typedef struct _GxkDialogClass GxkDialogClass;
@@ -29,15 +24,11 @@ typedef enum
GXK_DIALOG_POPUP_POS = 1 << 6, /* popup at mouse pointer */
GXK_DIALOG_PRESERVE_STATE = 1 << 7 /* don't always reset size etc. upon hiding */
} GxkDialogFlags;
-
-
/* --- structures --- */
struct _GxkDialog
{
GtkWindow window;
-
GtkWidget *vbox;
-
/*< private >*/
GtkObject *alive_object; /* dialog is destroyed with this object */
GxkDialogFlags flags;
@@ -54,8 +45,6 @@ struct _GxkDialogClass
{
GtkWindowClass parent_class;
};
-
-
/* --- prototypes --- */
GType gxk_dialog_get_type (void);
gpointer gxk_dialog_new (gpointer pointer_loc,
@@ -97,8 +86,6 @@ void gxk_dialog_remove_actions (GxkDialog *dialog);
gxk_dialog_action_multi ((dialog), (action), (callback), (data), 0, GXK_DIALOG_MULTI_SWAPPED)
#define gxk_dialog_default_action_swapped( dialog, action, callback, data) \
gxk_dialog_action_multi ((dialog), (action), (callback), (data), 0, GXK_DIALOG_MULTI_DEFAULT | GXK_DIALOG_MULTI_SWAPPED)
-
-
/* --- internal --- */
typedef enum /*< skip >*/
{
@@ -111,9 +98,7 @@ GtkWidget* gxk_dialog_action_multi (GxkDialog *dialog,
gpointer data,
const gchar *icon_stock_id,
GxkDialogMultiFlags multi_mode);
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline GxkDialogFlags operator& (GxkDialogFlags s1, GxkDialogFlags s2) { return GxkDialogFlags (s1 & (long long unsigned) s2); }
@@ -127,5 +112,4 @@ inline GxkDialogMultiFlags operator| (GxkDialogMultiFlags s1, GxkDialogMultiF
inline GxkDialogMultiFlags& operator|= (GxkDialogMultiFlags &s1, GxkDialogMultiFlags s2) { s1 = s1 | s2; return s1; }
inline GxkDialogMultiFlags operator~ (GxkDialogMultiFlags s1) { return GxkDialogMultiFlags (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __GXK_DIALOG_H__ */
diff --git a/beast-gtk/gxk/gxkglobals.cc b/beast-gtk/gxk/gxkglobals.cc
index 62d9dff..b0d19ae 100644
--- a/beast-gtk/gxk/gxkglobals.cc
+++ b/beast-gtk/gxk/gxkglobals.cc
@@ -1,25 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkglobals.hh"
-
-
/* --- variables --- */
const GxkGlobals* gxk_globals = NULL;
-
-
/* --- functions --- */
void
gxk_init (void)
{
static GxkGlobals globals = { NULL, };
-
g_return_if_fail (gxk_globals == NULL);
-
gxk_globals = &globals;
-
globals.tooltips = gtk_tooltips_new ();
g_object_ref (globals.tooltips);
gtk_object_sink (GTK_OBJECT (globals.tooltips));
-
gxk_init_utils ();
gxk_init_params ();
gxk_init_stock ();
@@ -27,7 +19,6 @@ gxk_init (void)
gxk_init_assortments ();
gxk_init_radget_types ();
}
-
gulong
gxk_nullify_in_object (gpointer object,
gpointer _location)
diff --git a/beast-gtk/gxk/gxkglobals.hh b/beast-gtk/gxk/gxkglobals.hh
index 02dd49d..a891f00 100644
--- a/beast-gtk/gxk/gxkglobals.hh
+++ b/beast-gtk/gxk/gxkglobals.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_GLOBALS_H__
#define __GXK_GLOBALS_H__
-
#include <sfi/glib-extra.hh>
#include <gtk/gtk.h>
-
G_BEGIN_DECLS
-
/* --- i18n and gettext helpers --- */
#ifdef GXK_COMPILATION
# define GXK_I18N_DOMAIN NULL
@@ -14,39 +11,25 @@ G_BEGIN_DECLS
# define T_(str) dgettext (GXK_I18N_DOMAIN, str)
# define N_(str) (str)
#endif
-
-
/* --- macros --- */
#define GXK_TOOLTIPS (gxk_globals->tooltips)
-
-
/* --- typedefs & structures --- */
typedef void (*GxkFreeFunc) (gpointer data);
typedef struct
{
GtkTooltips *tooltips;
} GxkGlobals;
-
-
/* --- spacing/padding --- */
#define GXK_OUTER_BORDER (5) /* outer dialog border-width */
#define GXK_INNER_SPACING (3) /* spacing/padding between h/v boxes */
#define GXK_BUTTON_PADDING (3) /* padding between adjacent buttons */
-
-
/* --- convenience --- */
gulong gxk_nullify_in_object (gpointer object,
gpointer location);
-
-
/* --- variables --- */
extern const GxkGlobals* gxk_globals;
-
-
/* --- functions --- */
void gxk_init (void);
-
-
/* --- internal --- */
void gxk_init_utils (void);
void gxk_init_params (void);
@@ -54,10 +37,7 @@ void gxk_init_stock (void);
void gxk_init_actions (void);
void gxk_init_assortments (void);
void gxk_init_radget_types (void);
-
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline GdkEventMask operator& (GdkEventMask s1, GdkEventMask s2) { return GdkEventMask (s1 & (long long unsigned) s2); }
@@ -65,24 +45,20 @@ inline GdkEventMask& operator&= (GdkEventMask &s1, GdkEventMask s2) { s1 = s1 &
inline GdkEventMask operator| (GdkEventMask s1, GdkEventMask s2) { return GdkEventMask (s1 | (long long unsigned) s2); }
inline GdkEventMask& operator|= (GdkEventMask &s1, GdkEventMask s2) { s1 = s1 | s2; return s1; }
inline GdkEventMask operator~ (GdkEventMask s1) { return GdkEventMask (~(long long unsigned) s1); }
-
inline GdkModifierType operator& (GdkModifierType s1, GdkModifierType s2) { return GdkModifierType (s1 & (long long unsigned) s2); }
inline GdkModifierType& operator&= (GdkModifierType &s1, GdkModifierType s2) { s1 = s1 & s2; return s1; }
inline GdkModifierType operator| (GdkModifierType s1, GdkModifierType s2) { return GdkModifierType (s1 | (long long unsigned) s2); }
inline GdkModifierType& operator|= (GdkModifierType &s1, GdkModifierType s2) { s1 = s1 | s2; return s1; }
inline GdkModifierType operator~ (GdkModifierType s1) { return GdkModifierType (~(long long unsigned) s1); }
-
inline GdkWindowHints operator& (GdkWindowHints s1, GdkWindowHints s2) { return GdkWindowHints (s1 & (long long unsigned) s2); }
inline GdkWindowHints& operator&= (GdkWindowHints &s1, GdkWindowHints s2) { s1 = s1 & s2; return s1; }
inline GdkWindowHints operator| (GdkWindowHints s1, GdkWindowHints s2) { return GdkWindowHints (s1 | (long long unsigned) s2); }
inline GdkWindowHints& operator|= (GdkWindowHints &s1, GdkWindowHints s2) { s1 = s1 | s2; return s1; }
inline GdkWindowHints operator~ (GdkWindowHints s1) { return GdkWindowHints (~(long long unsigned) s1); }
-
inline GtkAttachOptions operator& (GtkAttachOptions s1, GtkAttachOptions s2) { return GtkAttachOptions (s1 & (long long unsigned) s2); }
inline GtkAttachOptions& operator&= (GtkAttachOptions &s1, GtkAttachOptions s2) { s1 = s1 & s2; return s1; }
inline GtkAttachOptions operator| (GtkAttachOptions s1, GtkAttachOptions s2) { return GtkAttachOptions (s1 | (long long unsigned) s2); }
inline GtkAttachOptions& operator|= (GtkAttachOptions &s1, GtkAttachOptions s2) { s1 = s1 | s2; return s1; }
inline GtkAttachOptions operator~ (GtkAttachOptions s1) { return GtkAttachOptions (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __GXK_GLOBALS_H__ */
diff --git a/beast-gtk/gxk/gxkimagecache.cc b/beast-gtk/gxk/gxkimagecache.cc
index 5165f70..49e50ee 100644
--- a/beast-gtk/gxk/gxkimagecache.cc
+++ b/beast-gtk/gxk/gxkimagecache.cc
@@ -1,15 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkimagecache.hh"
#include <string.h>
-
-
#define MAX_CACHE_FILL 0
-
-
/* --- variables --- */
static GSList *image_cache = NULL;
-
-
/* --- functions --- */
static inline void
desaturate (GdkColor tint,
@@ -25,7 +19,6 @@ desaturate (GdkColor tint,
*green = saturation * *green + (1.0 - saturation) * g;
*blue = saturation * *blue + (1.0 - saturation) * b;
}
-
static GdkPixbuf*
load_pixbuf (const char *file_name,
GError **errorp)
@@ -43,7 +36,6 @@ load_pixbuf (const char *file_name,
/* try to load from disk */
return gdk_pixbuf_new_from_file (file_name, errorp);
}
-
static GxkImageCacheItem*
image_cache_create_item (const gchar *file_name,
GdkColor tint,
@@ -90,7 +82,6 @@ image_cache_create_item (const gchar *file_name,
image_cache = g_slist_append (image_cache, citem);
return citem;
}
-
static void
image_cache_item_unuse (GxkImageCacheItem *citem)
{
@@ -123,7 +114,6 @@ image_cache_item_unuse (GxkImageCacheItem *citem)
/* nothing to free */
}
}
-
static GxkImageCacheItem*
image_cache_find_item (const gchar *file_name,
GdkColor tint,
@@ -144,7 +134,6 @@ image_cache_find_item (const gchar *file_name,
}
return NULL;
}
-
GdkPixmap*
gxk_image_cache_use_pixmap (const gchar *file_name,
GdkColor tint,
@@ -164,7 +153,6 @@ gxk_image_cache_use_pixmap (const gchar *file_name,
}
return NULL;
}
-
void
gxk_image_cache_unuse_pixmap (GdkPixmap *pixmap)
{
diff --git a/beast-gtk/gxk/gxkimagecache.hh b/beast-gtk/gxk/gxkimagecache.hh
index f5d4df1..b5733b1 100644
--- a/beast-gtk/gxk/gxkimagecache.hh
+++ b/beast-gtk/gxk/gxkimagecache.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_IMAGE_CACHE_H__
#define __GXK_IMAGE_CACHE_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
typedef struct {
gchar *file_name;
GdkColor tint;
@@ -14,16 +11,11 @@ typedef struct {
GdkPixmap *pixmap;
guint use_count;
} GxkImageCacheItem;
-
#define GXK_IMAGE_BLACK32 (":/: black32")
-
GdkPixmap* gxk_image_cache_use_pixmap (const gchar *file_name,
GdkColor tint,
gdouble saturation,
GdkColormap *colormap);
void gxk_image_cache_unuse_pixmap (GdkPixmap *pixmap);
-
-
G_END_DECLS
-
#endif /* __GXK_IMAGE_CACHE_H__ */
diff --git a/beast-gtk/gxk/gxkled.cc b/beast-gtk/gxk/gxkled.cc
index f2be9da..5c9c50b 100644
--- a/beast-gtk/gxk/gxkled.cc
+++ b/beast-gtk/gxk/gxkled.cc
@@ -1,11 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkled.hh"
-
#include <math.h>
-
#define FUDGE 3
-
-
/* --- prototypes --- */
static void gxk_led_class_init (GxkLedClass *klass);
static void gxk_led_init (GxkLed *self);
@@ -22,12 +18,8 @@ static void gxk_led_resize (GxkLed *self);
static void gxk_led_rerender (GxkLed *self);
static gboolean gxk_led_expose (GtkWidget *widget,
GdkEventExpose *event);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
gxk_led_get_type (void)
@@ -46,31 +38,25 @@ gxk_led_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gxk_led_init,
};
-
type = g_type_register_static (GTK_TYPE_WIDGET,
"GxkLed",
&type_info, GTypeFlags (0));
}
return type;
}
-
static void
gxk_led_class_init (GxkLedClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = gxk_led_finalize;
-
widget_class->size_request = gxk_led_size_request;
widget_class->size_allocate = gxk_led_size_allocate;
widget_class->state_changed = gxk_led_state_changed;
widget_class->style_set = gxk_led_style_set;
widget_class->expose_event = gxk_led_expose;
}
-
static void
gxk_led_init (GxkLed *self)
{
@@ -80,18 +66,14 @@ gxk_led_init (GxkLed *self)
gtk_widget_show (GTK_WIDGET (self));
gxk_led_resize (self);
}
-
static void
gxk_led_finalize (GObject *object)
{
GxkLed *self = GXK_LED (object);
-
if (self->pixbuf)
g_object_unref (self->pixbuf);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
/**
* @param color rgb color
*
@@ -105,7 +87,6 @@ gxk_led_new (guint color)
gxk_led_set_color (self, color);
return self;
}
-
/**
* @param self valid GxkLed
* @param color color as RGB byte triple
@@ -117,24 +98,20 @@ gxk_led_set_color (GxkLed *self,
guint color)
{
g_return_if_fail (GXK_IS_LED (self));
-
if (!color) /* lazy bum! */
color = GXK_LED_OFF;
self->color = color;
if (self->pixbuf)
gxk_led_rerender (self);
}
-
void
gxk_led_set_border_width (GxkLed *self,
guint border_width)
{
g_return_if_fail (GXK_IS_LED (self));
-
self->border_width = border_width;
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
gxk_led_state_changed (GtkWidget *widget,
GtkStateType previous_state)
@@ -144,7 +121,6 @@ gxk_led_state_changed (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state);
gxk_led_rerender (self);
}
-
static void
gxk_led_style_set (GtkWidget *widget,
GtkStyle *previous_style)
@@ -154,14 +130,12 @@ gxk_led_style_set (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
gxk_led_rerender (self);
}
-
static void
gxk_led_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GxkLed *self = GXK_LED (widget);
GdkPixbuf *pixbuf = self->pixbuf;
-
requisition->width = 0;
requisition->height = 0;
if (pixbuf)
@@ -170,12 +144,10 @@ gxk_led_size_request (GtkWidget *widget,
requisition->height += gdk_pixbuf_get_height (pixbuf);
}
}
-
static void
gxk_led_resize (GxkLed *self)
{
/* GtkWidget *widget = GTK_WIDGET (self); */
-
if (self->pixbuf)
g_object_unref (self->pixbuf);
self->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
@@ -183,7 +155,6 @@ gxk_led_resize (GxkLed *self)
2 * self->radius);
gxk_led_rerender (self);
}
-
static void
gxk_led_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -194,7 +165,6 @@ gxk_led_size_allocate (GtkWidget *widget,
self->radius = MAX (self->radius, 3 + self->border_width) - 2 - self->border_width;
gxk_led_resize (self);
}
-
static void
gxk_led_rerender (GxkLed *self)
{
@@ -209,7 +179,6 @@ gxk_led_rerender (GxkLed *self)
gint x, y;
gdouble xc, yc, radius = self->radius;
gdouble lx, ly, lr;
-
/* center */
xc = width / 2;
yc = height / 2;
@@ -229,13 +198,10 @@ gxk_led_rerender (GxkLed *self)
pixels[y * rowstride + x * 4 + 2] = la * b;
pixels[y * rowstride + x * 4 + 3] = a * 0xff;
}
-
if (!GTK_WIDGET_IS_SENSITIVE (self))
gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0.8, TRUE);
-
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
static gboolean
gxk_led_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -243,7 +209,6 @@ gxk_led_expose (GtkWidget *widget,
GxkLed *self = GXK_LED (widget);
GdkRectangle rect, area = event->area;
GdkPixbuf *pixbuf = self->pixbuf;
-
if (0)
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
@@ -252,7 +217,6 @@ gxk_led_expose (GtkWidget *widget,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height);
-
if (pixbuf && gdk_rectangle_intersect (&area, &widget->allocation, &area))
{
gdouble radius = self->radius;
diff --git a/beast-gtk/gxk/gxkled.hh b/beast-gtk/gxk/gxkled.hh
index 713e32f..ca61311 100644
--- a/beast-gtk/gxk/gxkled.hh
+++ b/beast-gtk/gxk/gxkled.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_LED_H__
#define __GXK_LED_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_LED (gxk_led_get_type ())
#define GXK_LED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_LED, GxkLed))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_LED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_LED))
#define GXK_IS_LED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_LED))
#define GXK_LED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_LED, GxkLedClass))
-
#define GXK_LED_OFF (0x505050)
#define GXK_LED_MAGENTA (0xff50ff)
#define GXK_LED_RED (0xff5050)
@@ -21,8 +17,6 @@ G_BEGIN_DECLS
#define GXK_LED_GREEN (0x50ff50)
#define GXK_LED_CYAN (0x50ffff)
#define GXK_LED_BLUE (0x5050ff)
-
-
/* --- structures --- */
typedef struct {
GtkWidget parent_instance;
@@ -35,8 +29,6 @@ typedef struct {
typedef struct {
GtkWidgetClass parent_class;
} GxkLedClass;
-
-
/* --- prototypes --- */
GType gxk_led_get_type (void);
gpointer gxk_led_new (guint color);
@@ -44,8 +36,5 @@ void gxk_led_set_color (GxkLed *self,
guint rgb_colors);
void gxk_led_set_border_width (GxkLed *self,
guint border_width);
-
-
G_END_DECLS
-
#endif /* __GXK_LED_H__ */
diff --git a/beast-gtk/gxk/gxklistwrapper.cc b/beast-gtk/gxk/gxklistwrapper.cc
index a3e188f..b593d8b 100644
--- a/beast-gtk/gxk/gxklistwrapper.cc
+++ b/beast-gtk/gxk/gxklistwrapper.cc
@@ -2,20 +2,15 @@
#include "gxklistwrapper.hh"
#include "gxkmarshal.h"
#include <gtk/gtkmain.h>
-
-
#define I2P(x) GINT_TO_POINTER (x)
#define P2I(x) GPOINTER_TO_INT (x)
#define _(x) (x)
-
enum {
PROP_0,
PROP_N_COLS,
PROP_COLUMN_TYPES,
PROP_N_ROWS
};
-
-
/* --- prototypes --- */
static void gxk_list_wrapper_class_init (GxkListWrapperClass *klass);
static void gxk_list_wrapper_init (GxkListWrapper *self);
@@ -29,20 +24,15 @@ static void gxk_list_wrapper_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gxk_list_wrapper_init_tree_model_iface (GtkTreeModelIface *iface);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static guint signal_fill_value = 0;
static guint signal_row_change = 0;
-
-
/* --- functions --- */
GType
gxk_list_wrapper_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
@@ -61,24 +51,19 @@ gxk_list_wrapper_get_type (void)
(GInterfaceFinalizeFunc) NULL,
NULL, /* interface_data */
};
-
type = g_type_register_static (G_TYPE_OBJECT, "GxkListWrapper", &type_info, GTypeFlags (0));
g_type_add_interface_static (type, GTK_TYPE_TREE_MODEL, &iface_info);
}
return type;
}
-
static void
gxk_list_wrapper_class_init (GxkListWrapperClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->set_property = gxk_list_wrapper_set_property;
object_class->get_property = gxk_list_wrapper_get_property;
object_class->finalize = gxk_list_wrapper_finalize;
-
g_object_class_install_property (object_class,
PROP_N_COLS,
g_param_spec_uint ("n_cols", _("Number of Columns"), NULL,
@@ -91,7 +76,6 @@ gxk_list_wrapper_class_init (GxkListWrapperClass *klass)
PROP_N_ROWS,
g_param_spec_uint ("n_rows", _("Number of Rows"), NULL,
0, G_MAXINT, 0, GParamFlags (G_PARAM_READWRITE)));
-
signal_fill_value = g_signal_new ("fill-value",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
@@ -108,7 +92,6 @@ gxk_list_wrapper_class_init (GxkListWrapperClass *klass)
gxk_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
}
-
static void
gxk_list_wrapper_init (GxkListWrapper *self)
{
@@ -117,7 +100,6 @@ gxk_list_wrapper_init (GxkListWrapper *self)
self->column_types = NULL;
self->stamp = 1;
}
-
static void
gxk_list_wrapper_set_property (GObject *object,
guint param_id,
@@ -126,7 +108,6 @@ gxk_list_wrapper_set_property (GObject *object,
{
GxkListWrapper *self = GXK_LIST_WRAPPER (object);
guint i;
-
switch (param_id)
{
GType *ctypes;
@@ -151,7 +132,6 @@ gxk_list_wrapper_set_property (GObject *object,
break;
}
}
-
static void
gxk_list_wrapper_get_property (GObject *object,
guint param_id,
@@ -159,7 +139,6 @@ gxk_list_wrapper_get_property (GObject *object,
GParamSpec *pspec)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (object);
-
switch (param_id)
{
case PROP_N_COLS:
@@ -176,35 +155,27 @@ gxk_list_wrapper_get_property (GObject *object,
break;
}
}
-
static void
gxk_list_wrapper_finalize (GObject *object)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (object);
-
g_free (self->column_types);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
GxkListWrapper*
gxk_list_wrapper_newv (guint n_cols,
GType *column_types)
{
GxkListWrapper *self;
-
g_return_val_if_fail (n_cols > 0, NULL);
g_return_val_if_fail (column_types != NULL, NULL);
-
self = (GxkListWrapper*) g_object_new (GXK_TYPE_LIST_WRAPPER,
"n_cols", n_cols,
"column_types", column_types,
NULL);
-
return self;
}
-
GxkListWrapper*
gxk_list_wrapper_new (guint n_cols,
GType first_column_type,
@@ -214,51 +185,39 @@ gxk_list_wrapper_new (guint n_cols,
GType *ctypes;
va_list var_args;
guint i;
-
g_return_val_if_fail (n_cols > 0, NULL);
-
ctypes = g_new (GType, n_cols);
-
ctypes[0] = first_column_type;
va_start (var_args, first_column_type);
for (i = 1; i < n_cols; i++)
ctypes[i] = va_arg (var_args, GType);
va_end (var_args);
-
self = (GxkListWrapper*) g_object_new (GXK_TYPE_LIST_WRAPPER,
"n_cols", n_cols,
"column_types", ctypes,
NULL);
g_free (ctypes);
-
return self;
}
-
static GtkTreeModelFlags
gxk_list_wrapper_get_flags (GtkTreeModel *tree_model)
{
return GtkTreeModelFlags (0);
}
-
static gint
gxk_list_wrapper_get_n_columns (GtkTreeModel *tree_model)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
return self->n_cols;
}
-
static GType
gxk_list_wrapper_get_column_type (GtkTreeModel *tree_model,
gint index)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
g_return_val_if_fail (index >= 0 && index < int (self->n_cols), G_TYPE_INVALID);
-
return self->column_types[index];
}
-
static gboolean
gxk_list_wrapper_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
@@ -266,38 +225,28 @@ gxk_list_wrapper_get_iter (GtkTreeModel *tree_model,
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
gint *ind;
-
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
-
ind = gtk_tree_path_get_indices (path);
if (ind[0] < 0 || ind[0] >= int (self->n_rows))
return FALSE; /* only happens on stamp aliasing and empty lists */
-
iter->stamp = self->stamp;
iter->user_data = I2P (ind[0]);
-
return TRUE;
}
-
static GtkTreePath*
gxk_list_wrapper_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
GtkTreePath *path;
-
g_return_val_if_fail (iter->stamp == int (self->stamp), NULL);
-
uint i = P2I (iter->user_data);
if (i < 0 || i >= self->n_rows)
return FALSE; /* only happens on stamp aliasing */
-
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, i);
-
return path;
}
-
static void
gxk_list_wrapper_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
@@ -305,56 +254,43 @@ gxk_list_wrapper_get_value (GtkTreeModel *tree_model,
GValue *value)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
g_return_if_fail (iter->stamp == int (self->stamp));
g_return_if_fail (column >= 0 && uint (column) < self->n_cols);
-
g_value_init (value, self->column_types[column]);
-
uint i = P2I (iter->user_data);
if (i < 0 || i >= self->n_rows)
return; /* only happens on stamp aliasing */
-
g_signal_emit (tree_model, signal_fill_value, 0, column, i, value);
}
-
static gboolean
gxk_list_wrapper_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
g_return_val_if_fail (iter->stamp == int (self->stamp), FALSE);
-
uint i = P2I (iter->user_data);
if (i < 0 || i >= self->n_rows)
return FALSE; /* only happens on stamp aliasing */
-
i++;
iter->user_data = I2P(i);
-
return i < self->n_rows;
}
-
static gboolean
gxk_list_wrapper_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
return FALSE;
}
-
static gint
gxk_list_wrapper_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
if (!iter) /* root node */
return self->n_rows;
else
return 0;
}
-
static gboolean
gxk_list_wrapper_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
@@ -362,17 +298,13 @@ gxk_list_wrapper_iter_nth_child (GtkTreeModel *tree_model,
gint n)
{
GxkListWrapper *self = GXK_LIST_WRAPPER (tree_model);
-
if (parent) /* nodes of a list don't have a parent */
return FALSE;
-
g_return_val_if_fail (n >= 0 && uint (n) < self->n_rows, FALSE);
-
iter->stamp = self->stamp;
iter->user_data = I2P (n);
return TRUE;
}
-
static void
gxk_list_wrapper_init_tree_model_iface (GtkTreeModelIface *iface)
{
@@ -388,9 +320,7 @@ gxk_list_wrapper_init_tree_model_iface (GtkTreeModelIface *iface)
iface->iter_has_child = gxk_list_wrapper_iter_has_child;
iface->iter_n_children = gxk_list_wrapper_iter_n_children;
iface->iter_nth_child = gxk_list_wrapper_iter_nth_child;
-
}
-
void
gxk_list_wrapper_notify_insert (GxkListWrapper *self,
guint nth_row)
@@ -398,25 +328,19 @@ gxk_list_wrapper_notify_insert (GxkListWrapper *self,
GtkTreeModel *tree_model;
GtkTreeIter iter;
GtkTreePath *path;
-
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
g_return_if_fail (nth_row <= self->n_rows);
-
g_signal_emit (self, signal_row_change, 0, -1);
tree_model = GTK_TREE_MODEL (self);
-
self->n_rows++;
self->stamp++;
iter.stamp = self->stamp;
iter.user_data = I2P (nth_row);
-
path = gtk_tree_model_get_path (tree_model, &iter);
gtk_tree_model_row_inserted (tree_model, path, &iter);
gtk_tree_path_free (path);
-
g_object_notify (G_OBJECT (self), "n_rows");
}
-
void
gxk_list_wrapper_notify_change (GxkListWrapper *self,
guint nth_row)
@@ -424,21 +348,16 @@ gxk_list_wrapper_notify_change (GxkListWrapper *self,
GtkTreeModel *tree_model;
GtkTreeIter iter;
GtkTreePath *path;
-
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
g_return_if_fail (nth_row < self->n_rows);
-
g_signal_emit (self, signal_row_change, 0, nth_row);
tree_model = GTK_TREE_MODEL (self);
-
iter.stamp = self->stamp;
iter.user_data = I2P (nth_row);
-
path = gtk_tree_model_get_path (tree_model, &iter);
gtk_tree_model_row_changed (tree_model, path, &iter);
gtk_tree_path_free (path);
}
-
void
gxk_list_wrapper_notify_delete (GxkListWrapper *self,
guint nth_row)
@@ -446,13 +365,10 @@ gxk_list_wrapper_notify_delete (GxkListWrapper *self,
GtkTreeModel *tree_model;
GtkTreeIter iter;
GtkTreePath *path;
-
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
g_return_if_fail (nth_row < self->n_rows);
-
g_signal_emit (self, signal_row_change, 0, -1);
tree_model = GTK_TREE_MODEL (self);
-
iter.stamp = self->stamp;
iter.user_data = I2P (nth_row);
path = gtk_tree_model_get_path (tree_model, &iter);
@@ -462,45 +378,38 @@ gxk_list_wrapper_notify_delete (GxkListWrapper *self,
gtk_tree_path_free (path);
g_object_notify (G_OBJECT (self), "n_rows");
}
-
void
gxk_list_wrapper_notify_prepend (GxkListWrapper *self,
guint n_rows)
{
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
-
g_object_freeze_notify (G_OBJECT (self));
g_signal_emit (self, signal_row_change, 0, -1);
while (n_rows--)
gxk_list_wrapper_notify_insert (self, 0);
g_object_thaw_notify (G_OBJECT (self));
}
-
void
gxk_list_wrapper_notify_append (GxkListWrapper *self,
guint n_rows)
{
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
-
g_object_freeze_notify (G_OBJECT (self));
g_signal_emit (self, signal_row_change, 0, -1);
while (n_rows--)
gxk_list_wrapper_notify_insert (self, self->n_rows);
g_object_thaw_notify (G_OBJECT (self));
}
-
void
gxk_list_wrapper_notify_clear (GxkListWrapper *self)
{
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
-
g_object_freeze_notify (G_OBJECT (self));
g_signal_emit (self, signal_row_change, 0, -1);
while (self->n_rows)
gxk_list_wrapper_notify_delete (self, self->n_rows - 1);
g_object_thaw_notify (G_OBJECT (self));
}
-
void
gxk_list_wrapper_get_iter_at (GxkListWrapper *self,
GtkTreeIter *iter,
@@ -509,11 +418,9 @@ gxk_list_wrapper_get_iter_at (GxkListWrapper *self,
g_return_if_fail (GXK_IS_LIST_WRAPPER (self));
g_return_if_fail (iter != NULL);
g_return_if_fail (index < self->n_rows);
-
iter->stamp = self->stamp;
iter->user_data = I2P (index);
}
-
guint
gxk_list_wrapper_get_index (GxkListWrapper *self,
GtkTreeIter *iter)
@@ -521,6 +428,5 @@ gxk_list_wrapper_get_index (GxkListWrapper *self,
g_return_val_if_fail (GXK_IS_LIST_WRAPPER (self), G_MAXUINT);
g_return_val_if_fail (iter != NULL, G_MAXUINT);
g_return_val_if_fail (iter->stamp == int (self->stamp), G_MAXUINT);
-
return P2I (iter->user_data);
}
diff --git a/beast-gtk/gxk/gxklistwrapper.hh b/beast-gtk/gxk/gxklistwrapper.hh
index b5b628f..c836f9c 100644
--- a/beast-gtk/gxk/gxklistwrapper.hh
+++ b/beast-gtk/gxk/gxklistwrapper.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_LIST_WRAPPER_H__
#define __GXK_LIST_WRAPPER_H__
-
#include <gtk/gtktreemodel.h>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_LIST_WRAPPER (gxk_list_wrapper_get_type ())
#define GXK_LIST_WRAPPER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_LIST_WRAPPER, GxkListWrapper))
@@ -13,26 +10,21 @@ G_BEGIN_DECLS
#define GXK_IS_LIST_WRAPPER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_LIST_WRAPPER))
#define GXK_IS_LIST_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_LIST_WRAPPER))
#define GXK_LIST_WRAPPER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_LIST_WRAPPER, GxkListWrapperClass))
-
-
/* --- structures & typedefs --- */
typedef struct _GxkListWrapper GxkListWrapper;
typedef struct _GxkListWrapperClass GxkListWrapperClass;
struct _GxkListWrapper
{
GObject parent_instance;
-
guint n_rows;
guint n_cols;
GType *column_types;
-
/*< private >*/
guint stamp;
};
struct _GxkListWrapperClass
{
GObjectClass parent_class;
-
void (*fill_value) (GxkListWrapper *self,
guint column,
guint row,
@@ -40,8 +32,6 @@ struct _GxkListWrapperClass
void (*row_change) (GxkListWrapper *self,
gint row);
};
-
-
/* --- prototypes --- */
GType gxk_list_wrapper_get_type (void);
GxkListWrapper* gxk_list_wrapper_new (guint n_cols,
@@ -65,7 +55,5 @@ guint gxk_list_wrapper_get_index (GxkListWrapper *self,
void gxk_list_wrapper_get_iter_at (GxkListWrapper *self,
GtkTreeIter *iter,
guint index);
-
G_END_DECLS
-
#endif /* __GXK_LIST_WRAPPER_H__ */
diff --git a/beast-gtk/gxk/gxklogadjustment.cc b/beast-gtk/gxk/gxklogadjustment.cc
index 4c8f8a7..cb927f1 100644
--- a/beast-gtk/gxk/gxklogadjustment.cc
+++ b/beast-gtk/gxk/gxklogadjustment.cc
@@ -1,15 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxklogadjustment.hh"
#include <math.h>
-
/* --- functions --- */
G_DEFINE_TYPE (GxkAdapterAdjustment, gxk_adapter_adjustment, GTK_TYPE_ADJUSTMENT);
-
static void
gxk_adapter_adjustment_init (GxkAdapterAdjustment *self)
{
}
-
static void
adapter_adjustment_destroy (GtkObject *object)
{
@@ -19,7 +16,6 @@ adapter_adjustment_destroy (GtkObject *object)
/* chain parent class handler */
GTK_OBJECT_CLASS (gxk_adapter_adjustment_parent_class)->destroy (object);
}
-
static void
adapter_adjustment_finalize (GObject *object)
{
@@ -29,7 +25,6 @@ adapter_adjustment_finalize (GObject *object)
/* chain parent class handler */
G_OBJECT_CLASS (gxk_adapter_adjustment_parent_class)->finalize (object);
}
-
GtkAdjustment*
gxk_adapter_adjustment_from_adj (GtkAdjustment *client,
GxkAdapterAdjustmentFunc conv_func,
@@ -43,7 +38,6 @@ gxk_adapter_adjustment_from_adj (GtkAdjustment *client,
gxk_adapter_adjustment_setup (self, conv_func, data, destroy);
return GTK_ADJUSTMENT (self);
}
-
static inline gdouble
adapter_adjustment_convert (GxkAdapterAdjustment *self,
GxkAdapterAdjustmentConvertType convert_type,
@@ -54,13 +48,11 @@ adapter_adjustment_convert (GxkAdapterAdjustment *self,
else
return value;
}
-
static void
adapter_adjustment_changed (GtkAdjustment *adj)
{
GxkAdapterAdjustment *self = GXK_ADAPTER_ADJUSTMENT (adj);
GtkAdjustment *client = self->client;
-
if (client && !self->block_client)
{
self->block_client++;
@@ -68,13 +60,11 @@ adapter_adjustment_changed (GtkAdjustment *adj)
self->block_client--;
}
}
-
static void
adapter_adjustment_value_changed (GtkAdjustment *adj)
{
GxkAdapterAdjustment *self = GXK_ADAPTER_ADJUSTMENT (adj);
GtkAdjustment *client = self->client;
-
adj->value = CLAMP (adj->value, adj->lower, adj->upper);
if (client && !self->block_client)
{
@@ -85,7 +75,6 @@ adapter_adjustment_value_changed (GtkAdjustment *adj)
self->block_client--;
}
}
-
static void
adapter_adjustment_adjust_ranges (GxkAdapterAdjustment *self)
{
@@ -124,13 +113,11 @@ adapter_adjustment_adjust_ranges (GxkAdapterAdjustment *self)
}
}
}
-
static void
adapter_adjustment_client_value_changed (GxkAdapterAdjustment *self)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (self);
GtkAdjustment *client = self->client;
-
if (client)
{
adj->value = adapter_adjustment_convert (self, GXK_ADAPTER_ADJUSTMENT_CONVERT_FROM_CLIENT, client->value);
@@ -147,7 +134,6 @@ adapter_adjustment_client_value_changed (GxkAdapterAdjustment *self)
}
}
}
-
void
gxk_adapter_adjustment_set_client (GxkAdapterAdjustment *self,
GtkAdjustment *client)
@@ -157,7 +143,6 @@ gxk_adapter_adjustment_set_client (GxkAdapterAdjustment *self,
g_return_if_fail (GTK_IS_ADJUSTMENT (client));
if (client)
g_object_ref (client);
-
if (self->client)
{
g_signal_handlers_disconnect_by_func (self->client, (void*) adapter_adjustment_adjust_ranges, self);
@@ -174,11 +159,9 @@ gxk_adapter_adjustment_set_client (GxkAdapterAdjustment *self,
NULL);
adapter_adjustment_adjust_ranges (self);
}
-
if (client)
g_object_unref (client);
}
-
void
gxk_adapter_adjustment_setup (GxkAdapterAdjustment *self,
GxkAdapterAdjustmentFunc conv_func,
@@ -198,22 +181,17 @@ gxk_adapter_adjustment_setup (GxkAdapterAdjustment *self,
if (G_OBJECT (self)->ref_count) /* catch finalization */
gtk_adjustment_value_changed (adj);
}
-
static void
gxk_adapter_adjustment_class_init (GxkAdapterAdjustmentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkAdjustmentClass *adjustment_class = GTK_ADJUSTMENT_CLASS (klass);
-
gobject_class->finalize = adapter_adjustment_finalize;
-
object_class->destroy = adapter_adjustment_destroy;
-
adjustment_class->changed = adapter_adjustment_changed;
adjustment_class->value_changed = adapter_adjustment_value_changed;
}
-
/* --- prototypes --- */
static void log_adjustment_class_init (GxkLogAdjustmentClass *klass);
static void log_adjustment_init (GxkLogAdjustment *self);
@@ -222,10 +200,8 @@ static void log_adjustment_changed (GtkAdjustment *adj);
static void log_adjustment_value_changed (GtkAdjustment *adj);
static void log_adjustment_adjust_ranges (GxkLogAdjustment *self);
static void log_adjustment_client_value_changed (GxkLogAdjustment *self);
-
/* --- static variables --- */
static gpointer ladj_parent_class = NULL;
-
/* --- functions --- */
GType
gxk_log_adjustment_get_type (void)
@@ -248,35 +224,28 @@ gxk_log_adjustment_get_type (void)
}
return type;
}
-
static void
log_adjustment_class_init (GxkLogAdjustmentClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkAdjustmentClass *adjustment_class = GTK_ADJUSTMENT_CLASS (klass);
-
ladj_parent_class = g_type_class_peek_parent (klass);
-
object_class->destroy = log_adjustment_destroy;
-
adjustment_class->changed = log_adjustment_changed;
adjustment_class->value_changed = log_adjustment_value_changed;
}
-
static gdouble
call_exp (GxkLogAdjustment *self,
gdouble x)
{
return pow (self->base, x);
}
-
static gdouble
call_log (GxkLogAdjustment *self,
gdouble x)
{
return log (CLAMP (x, self->llimit, self->ulimit)) / self->base_ln;
}
-
static void
log_adjustment_init (GxkLogAdjustment *self)
{
@@ -284,31 +253,23 @@ log_adjustment_init (GxkLogAdjustment *self)
self->client = NULL;
gxk_log_adjustment_setup (self, 10000, 10, 4);
}
-
static void
log_adjustment_destroy (GtkObject *object)
{
GxkLogAdjustment *self = GXK_LOG_ADJUSTMENT (object);
-
gxk_log_adjustment_set_client (self, NULL);
-
/* chain parent class handler */
GTK_OBJECT_CLASS (ladj_parent_class)->destroy (object);
}
-
GtkAdjustment*
gxk_log_adjustment_from_adj (GtkAdjustment *client)
{
GxkLogAdjustment *self;
-
g_return_val_if_fail (GTK_IS_ADJUSTMENT (client), NULL);
-
self = (GxkLogAdjustment*) g_object_new (GXK_TYPE_LOG_ADJUSTMENT, NULL);
gxk_log_adjustment_set_client (self, client);
-
return GTK_ADJUSTMENT (self);
}
-
void
gxk_log_adjustment_set_client (GxkLogAdjustment *self,
GtkAdjustment *client)
@@ -316,7 +277,6 @@ gxk_log_adjustment_set_client (GxkLogAdjustment *self,
g_return_if_fail (GXK_IS_LOG_ADJUSTMENT (self));
if (client)
g_return_if_fail (GTK_IS_ADJUSTMENT (client));
-
g_object_ref (self);
if (self->client)
{
@@ -336,7 +296,6 @@ gxk_log_adjustment_set_client (GxkLogAdjustment *self,
}
g_object_unref (self);
}
-
void
gxk_log_adjustment_setup (GxkLogAdjustment *self,
gdouble center,
@@ -344,11 +303,9 @@ gxk_log_adjustment_setup (GxkLogAdjustment *self,
gdouble n_steps)
{
GtkAdjustment *adj;
-
g_return_if_fail (GXK_IS_LOG_ADJUSTMENT (self));
g_return_if_fail (n_steps > 0);
g_return_if_fail (base > 0);
-
adj = GTK_ADJUSTMENT (self);
self->center = center;
self->n_steps = n_steps;
@@ -356,18 +313,15 @@ gxk_log_adjustment_setup (GxkLogAdjustment *self,
self->base_ln = log (self->base);
self->ulimit = pow (self->base, self->n_steps);
self->llimit = 1.0 / self->ulimit;
-
adj->value = self->center;
log_adjustment_adjust_ranges (self);
gtk_adjustment_value_changed (adj);
}
-
static void
log_adjustment_changed (GtkAdjustment *adj)
{
GxkLogAdjustment *self = GXK_LOG_ADJUSTMENT (adj);
GtkAdjustment *client = self->client;
-
if (client && !self->block_client)
{
self->block_client++;
@@ -375,13 +329,11 @@ log_adjustment_changed (GtkAdjustment *adj)
self->block_client--;
}
}
-
static void
log_adjustment_value_changed (GtkAdjustment *adj)
{
GxkLogAdjustment *self = GXK_LOG_ADJUSTMENT (adj);
GtkAdjustment *client = self->client;
-
adj->value = CLAMP (adj->value, adj->lower, adj->upper);
if (client && !self->block_client)
{
@@ -391,18 +343,15 @@ log_adjustment_value_changed (GtkAdjustment *adj)
self->block_client--;
}
}
-
static void
log_adjustment_adjust_ranges (GxkLogAdjustment *self)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (self);
-
adj->upper = self->n_steps;
adj->lower = -self->n_steps;
adj->page_increment = (adj->upper - adj->lower) / (2.0 * self->n_steps);
adj->step_increment = adj->page_increment / 100.0;
adj->page_size = 0;
-
if (0)
{
GtkAdjustment *client = self->client;
@@ -412,7 +361,6 @@ log_adjustment_adjust_ranges (GxkLogAdjustment *self)
self->center,
client ? client->lower : -99.777, client ? client->upper : -99.777);
}
-
if (!self->block_client)
{
self->block_client++;
@@ -420,22 +368,18 @@ log_adjustment_adjust_ranges (GxkLogAdjustment *self)
self->block_client--;
}
}
-
static void
log_adjustment_client_value_changed (GxkLogAdjustment *self)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (self);
GtkAdjustment *client = self->client;
-
if (client)
adj->value = call_log (self, client->value / self->center);
adj->value = CLAMP (adj->value, adj->lower, adj->upper);
-
if (0)
g_printerr ("ladj: client-value-changed: [%f %f] %g CLIENT: [%f %f] %g\n",
adj->lower, adj->upper, adj->value,
client->lower, client->upper, client->value);
-
if (!self->block_client)
{
self->block_client++;
diff --git a/beast-gtk/gxk/gxklogadjustment.hh b/beast-gtk/gxk/gxklogadjustment.hh
index d61ae26..ef0ddd1 100644
--- a/beast-gtk/gxk/gxklogadjustment.hh
+++ b/beast-gtk/gxk/gxklogadjustment.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_LOG_ADJUSTMENT_H__
#define __GXK_LOG_ADJUSTMENT_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_ADAPTER_ADJUSTMENT (gxk_adapter_adjustment_get_type ())
#define GXK_ADAPTER_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_ADAPTER_ADJUSTMENT, GxkAdapterAdjustment))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_ADAPTER_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_ADAPTER_ADJUSTMENT))
#define GXK_IS_ADAPTER_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_ADAPTER_ADJUSTMENT))
#define GXK_ADAPTER_ADJUSTMENT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_ADAPTER_ADJUSTMENT, GxkAdapterAdjustmentClass))
-
/* --- structures & typedefs --- */
typedef struct _GxkAdapterAdjustment GxkAdapterAdjustment;
typedef struct _GxkAdapterAdjustmentClass GxkAdapterAdjustmentClass;
@@ -31,10 +27,8 @@ typedef gdouble (*GxkAdapterAdjustmentFunc) (GxkAdapterAdjustment *sel
struct _GxkAdapterAdjustment
{
GtkAdjustment parent_instance;
-
guint block_client;
GtkAdjustment *client;
-
GxkAdapterAdjustmentFunc conv_func;
gpointer data;
GDestroyNotify destroy;
@@ -43,7 +37,6 @@ struct _GxkAdapterAdjustmentClass
{
GtkAdjustmentClass parent_class;
};
-
/* --- prototypes --- */
GType gxk_adapter_adjustment_get_type (void);
void gxk_adapter_adjustment_set_client (GxkAdapterAdjustment *self,
@@ -56,7 +49,6 @@ GtkAdjustment* gxk_adapter_adjustment_from_adj (GtkAdjustment
GxkAdapterAdjustmentFunc conv_func,
gpointer data,
GDestroyNotify destroy);
-
/* --- type macros --- */
#define GXK_TYPE_LOG_ADJUSTMENT (gxk_log_adjustment_get_type ())
#define GXK_LOG_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_LOG_ADJUSTMENT, GxkLogAdjustment))
@@ -64,20 +56,17 @@ GtkAdjustment* gxk_adapter_adjustment_from_adj (GtkAdjustment
#define GXK_IS_LOG_ADJUSTMENT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_LOG_ADJUSTMENT))
#define GXK_IS_LOG_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_LOG_ADJUSTMENT))
#define GXK_LOG_ADJUSTMENT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_LOG_ADJUSTMENT, GxkLogAdjustmentClass))
-
/* --- structures & typedefs --- */
typedef struct _GxkLogAdjustment GxkLogAdjustment;
typedef struct _GxkLogAdjustmentClass GxkLogAdjustmentClass;
struct _GxkLogAdjustment
{
GtkAdjustment parent_instance;
-
/* settings */
gdouble center;
gdouble n_steps;
gdouble base;
GtkAdjustment *client;
-
guint block_client;
gdouble base_ln;
gdouble llimit;
@@ -87,7 +76,6 @@ struct _GxkLogAdjustmentClass
{
GtkAdjustmentClass parent_class;
};
-
/* --- prototypes --- */
GType gxk_log_adjustment_get_type (void);
void gxk_log_adjustment_set_client (GxkLogAdjustment *self,
@@ -98,5 +86,4 @@ void gxk_log_adjustment_setup (GxkLogAdjustment *self,
gdouble base,
gdouble n_steps);
G_END_DECLS
-
#endif /* __GXK_LOG_ADJUSTMENT_H__ */
diff --git a/beast-gtk/gxk/gxkmenubutton.cc b/beast-gtk/gxk/gxkmenubutton.cc
index 662e9b6..2fc9921 100644
--- a/beast-gtk/gxk/gxkmenubutton.cc
+++ b/beast-gtk/gxk/gxkmenubutton.cc
@@ -4,7 +4,6 @@
#include "gxkauxwidgets.hh"
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
enum {
MENU_BUTTON_PROP_0,
MENU_BUTTON_PROP_CAN_FOCUS,
@@ -14,19 +13,13 @@ enum {
MENU_BUTTON_PROP_RELIEF,
MENU_BUTTON_PROP_MODE
};
-
/* --- prototypes --- */
static void menu_button_remove_contents (GxkMenuButton *self);
static void menu_button_layout (GxkMenuButton *self);
-
-
/* --- variables --- */
static guint menu_button_signal_changed = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (GxkMenuButton, gxk_menu_button, GTK_TYPE_EVENT_BOX);
-
static void
menu_button_save_snapshot (GxkMenuButton *self)
{
@@ -73,7 +66,6 @@ menu_button_save_snapshot (GxkMenuButton *self)
gdk_window_show (self->bwindow);
gdk_window_clear (self->bwindow);
}
-
static void
menu_button_restore_backing (GxkMenuButton *self)
{
@@ -86,7 +78,6 @@ menu_button_restore_backing (GxkMenuButton *self)
if (self->button)
gtk_button_set_relief (GTK_BUTTON (self->button), self->relief);
}
-
static void
menu_button_grab_focus (GxkMenuButton *self)
{
@@ -95,7 +86,6 @@ menu_button_grab_focus (GxkMenuButton *self)
else if (self->button)
gtk_widget_grab_focus (self->button);
}
-
static void
menu_button_popup (GxkMenuButton *self,
guint button,
@@ -147,7 +137,6 @@ menu_button_popup (GxkMenuButton *self,
if (menu_item)
gtk_menu_shell_select_item (GTK_MENU_SHELL (self->menu), menu_item);
}
-
static gboolean
menu_button_button_press (GtkWidget *widget,
GdkEventButton *event)
@@ -158,7 +147,6 @@ menu_button_button_press (GtkWidget *widget,
menu_button_popup (self, event->button, event->time);
return TRUE;
}
-
static GtkWidget*
menu_find_sibling (GtkMenu *menu,
gpointer old_child,
@@ -178,7 +166,6 @@ menu_find_sibling (GtkMenu *menu,
}
return NULL;
}
-
static gboolean
menu_button_key_press (GtkWidget *widget,
GdkEventKey *event)
@@ -208,7 +195,6 @@ menu_button_key_press (GtkWidget *widget,
}
return FALSE;
}
-
static gboolean
menu_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
@@ -217,7 +203,6 @@ menu_button_mnemonic_activate (GtkWidget *widget,
menu_button_grab_focus (self);
return TRUE;
}
-
static void
menu_button_proxy_state (GxkMenuButton *self)
{
@@ -226,7 +211,6 @@ menu_button_proxy_state (GxkMenuButton *self)
if (self->image)
gtk_widget_set_sensitive (self->image, GTK_WIDGET_IS_SENSITIVE (self->menu_item));
}
-
static void
menu_button_max_size (GxkMenuButton *self)
{
@@ -261,7 +245,6 @@ menu_button_max_size (GxkMenuButton *self)
NULL);
}
}
-
static void
menu_button_remove_contents (GxkMenuButton *self)
{
@@ -289,7 +272,6 @@ menu_button_remove_contents (GxkMenuButton *self)
gxk_widget_set_tooltip (GTK_WIDGET (self), NULL);
}
}
-
void
gxk_menu_button_update (GxkMenuButton *self)
{
@@ -346,7 +328,6 @@ gxk_menu_button_update (GxkMenuButton *self)
if (old_menu_item != self->menu_item)
g_signal_emit (self, menu_button_signal_changed, 0);
}
-
static void
menu_button_detacher (GtkWidget *widget,
GtkMenu *menu)
@@ -359,7 +340,6 @@ menu_button_detacher (GtkWidget *widget,
self->menu = NULL;
g_object_notify ((GObject*) self, "menu");
}
-
static void
menu_button_assortment_added (gpointer client_data,
GtkWindow *window,
@@ -375,7 +355,6 @@ menu_button_assortment_added (gpointer client_data,
g_object_set (self, "menu", menu, NULL);
}
}
-
static void
menu_button_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
@@ -392,7 +371,6 @@ menu_button_hierarchy_changed (GtkWidget *widget,
gxk_window_add_assortment_client (GTK_WINDOW (toplevel), menu_button_assortment_added, NULL, self);
}
}
-
static void
gxk_menu_button_set_property (GObject *object,
guint param_id,
@@ -475,7 +453,6 @@ gxk_menu_button_set_property (GObject *object,
break;
}
}
-
static void
gxk_menu_button_get_property (GObject *object,
guint param_id,
@@ -508,7 +485,6 @@ gxk_menu_button_get_property (GObject *object,
break;
}
}
-
static void
menu_button_dispose (GObject *object)
{
@@ -519,7 +495,6 @@ menu_button_dispose (GObject *object)
self->assortment_name = NULL;
G_OBJECT_CLASS (gxk_menu_button_parent_class)->dispose (object);
}
-
static void
menu_button_finalize (GObject *object)
{
@@ -530,9 +505,7 @@ menu_button_finalize (GObject *object)
self->assortment_name = NULL;
G_OBJECT_CLASS (gxk_menu_button_parent_class)->finalize (object);
}
-
#define FOCUS_SHADOW (GTK_SHADOW_IN /* anything != NONE */)
-
static void
menu_button_focus_changed (GxkMenuButton *self)
{
@@ -540,7 +513,6 @@ menu_button_focus_changed (GxkMenuButton *self)
gtk_frame_set_shadow_type (GTK_FRAME (self->fframe),
GTK_WIDGET_HAS_FOCUS (self) ? FOCUS_SHADOW : GTK_SHADOW_NONE);
}
-
static GtkWidget*
menu_button_create_button (GxkMenuButton *self,
gpointer child)
@@ -557,7 +529,6 @@ menu_button_create_button (GxkMenuButton *self,
g_signal_connect_swapped (self->button, "key-press-event", G_CALLBACK (menu_button_key_press), self);
return self->button;
}
-
static gboolean
focus_frame_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -576,7 +547,6 @@ focus_frame_expose_event (GtkWidget *widget,
gtk_container_propagate_expose (GTK_CONTAINER (frame), child, event);
return TRUE; /* skip normal frame drawing code */
}
-
static void
menu_button_layout (GxkMenuButton *self)
{
@@ -732,7 +702,6 @@ menu_button_layout (GxkMenuButton *self)
gtk_widget_show_all (GTK_WIDGET (GTK_BIN (self)->child));
menu_button_focus_changed (self);
}
-
static void
gxk_menu_button_init (GxkMenuButton *self)
{
@@ -740,7 +709,6 @@ gxk_menu_button_init (GxkMenuButton *self)
g_signal_connect (self, "focus-in-event", G_CALLBACK (menu_button_focus_changed), NULL);
g_signal_connect (self, "focus-out-event", G_CALLBACK (menu_button_focus_changed), NULL);
}
-
static void
gxk_menu_button_class_init (GxkMenuButtonClass *klass)
{
diff --git a/beast-gtk/gxk/gxkmenubutton.hh b/beast-gtk/gxk/gxkmenubutton.hh
index a733dad..fee03e6 100644
--- a/beast-gtk/gxk/gxkmenubutton.hh
+++ b/beast-gtk/gxk/gxkmenubutton.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_MENU_BUTTON_H__
#define __GXK_MENU_BUTTON_H__
-
#include "gxkutils.hh"
#include "gxkassortment.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_MENU_BUTTON (gxk_menu_button_get_type ())
#define GXK_MENU_BUTTON(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_MENU_BUTTON, GxkMenuButton))
@@ -37,8 +34,5 @@ typedef struct {
typedef GtkEventBoxClass GxkMenuButtonClass;
GType gxk_menu_button_get_type (void);
void gxk_menu_button_update (GxkMenuButton *self);
-
-
G_END_DECLS
-
#endif /* __GXK_MENU_BUTTON_H__ */
diff --git a/beast-gtk/gxk/gxknotebook.cc b/beast-gtk/gxk/gxknotebook.cc
index a055584..d856514 100644
--- a/beast-gtk/gxk/gxknotebook.cc
+++ b/beast-gtk/gxk/gxknotebook.cc
@@ -1,25 +1,19 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxknotebook.hh"
#include <string.h>
-
-
/* --- properties --- */
enum {
PROP_0,
PROP_ASSORTMENT
};
-
/* --- variables --- */
static GQuark quark_page_data = 0;
-
/* --- functions --- */
G_DEFINE_TYPE (GxkNotebook, gxk_notebook, GTK_TYPE_NOTEBOOK);
-
static void
gxk_notebook_init (GxkNotebook *self)
{
}
-
static void
gxk_notebook_assortment_added (gpointer client_data,
GtkWindow *window,
@@ -31,7 +25,6 @@ gxk_notebook_assortment_added (gpointer client_data,
strcmp (self->assortment_name, assortment->publishing_name) == 0)
gxk_notebook_set_assortment (self, assortment);
}
-
static void
gxk_notebook_assortment_removed (gpointer client_data,
GtkWindow *window,
@@ -42,7 +35,6 @@ gxk_notebook_assortment_removed (gpointer client_data,
if (self->assortment == assortment)
gxk_notebook_set_assortment (self, NULL);
}
-
static void
gxk_notebook_set_property (GObject *object,
guint prop_id,
@@ -74,7 +66,6 @@ gxk_notebook_set_property (GObject *object,
break;
}
}
-
static void
gxk_notebook_get_property (GObject *object,
guint prop_id,
@@ -92,7 +83,6 @@ gxk_notebook_get_property (GObject *object,
break;
}
}
-
static void
gxk_notebook_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
@@ -109,7 +99,6 @@ gxk_notebook_hierarchy_changed (GtkWidget *widget,
gxk_window_add_assortment_client (GTK_WINDOW (toplevel), gxk_notebook_assortment_added, gxk_notebook_assortment_removed, self);
}
}
-
static void
notebook_assortment_entry_added (GxkAssortment *assortment,
GxkAssortmentEntry *entry,
@@ -129,7 +118,6 @@ notebook_assortment_entry_added (GxkAssortment *assortment,
}
gxk_assortment_unblock_selection (assortment);
}
-
static void
notebook_assortment_entry_changed (GxkAssortment *assortment,
GxkAssortmentEntry *entry,
@@ -146,7 +134,6 @@ notebook_assortment_entry_changed (GxkAssortment *assortment,
}
g_list_free (children);
}
-
static void
notebook_assortment_entry_remove (GxkAssortment *assortment,
GxkAssortmentEntry *entry,
@@ -162,7 +149,6 @@ notebook_assortment_entry_remove (GxkAssortment *assortment,
}
g_list_free (children);
}
-
static void
notebook_assortment_selection_changed (GxkAssortment *assortment,
GxkNotebook *self)
@@ -180,7 +166,6 @@ notebook_assortment_selection_changed (GxkAssortment *assortment,
g_list_free (children);
}
}
-
void
gxk_notebook_set_assortment (GxkNotebook *self,
GxkAssortment *assortment)
@@ -220,7 +205,6 @@ gxk_notebook_set_assortment (GxkNotebook *self,
notebook_assortment_selection_changed (self->assortment, self);
}
}
-
static void
gxk_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page,
@@ -236,7 +220,6 @@ gxk_notebook_switch_page (GtkNotebook *notebook,
gxk_assortment_select_data (self->assortment, g_object_get_qdata ((GObject*) child, quark_page_data));
}
}
-
static void
gxk_notebook_destroy (GtkObject *object)
{
@@ -246,7 +229,6 @@ gxk_notebook_destroy (GtkObject *object)
gxk_notebook_set_assortment (self, NULL);
GTK_OBJECT_CLASS (gxk_notebook_parent_class)->destroy (object);
}
-
static void
gxk_notebook_finalize (GObject *object)
{
@@ -256,7 +238,6 @@ gxk_notebook_finalize (GObject *object)
gxk_notebook_set_assortment (self, NULL);
G_OBJECT_CLASS (gxk_notebook_parent_class)->finalize (object);
}
-
static void
gxk_notebook_class_init (GxkNotebookClass *klass)
{
@@ -264,19 +245,13 @@ gxk_notebook_class_init (GxkNotebookClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
-
quark_page_data = g_quark_from_static_string ("gxk-notebook-page-data");
-
gobject_class->finalize = gxk_notebook_finalize;
gobject_class->set_property = gxk_notebook_set_property;
gobject_class->get_property = gxk_notebook_get_property;
-
object_class->destroy = gxk_notebook_destroy;
-
widget_class->hierarchy_changed = gxk_notebook_hierarchy_changed;
-
notebook_class->switch_page = gxk_notebook_switch_page;
-
g_object_class_install_property (G_OBJECT_CLASS (object_class),
PROP_ASSORTMENT,
g_param_spec_string ("assortment", NULL, NULL,
diff --git a/beast-gtk/gxk/gxknotebook.hh b/beast-gtk/gxk/gxknotebook.hh
index a414355..9c32950 100644
--- a/beast-gtk/gxk/gxknotebook.hh
+++ b/beast-gtk/gxk/gxknotebook.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_NOTEBOOK_H__
#define __GXK_NOTEBOOK_H__
-
#include "gxkassortment.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_NOTEBOOK (gxk_notebook_get_type ())
#define GXK_NOTEBOOK(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_NOTEBOOK, GxkNotebook))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_NOTEBOOK(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_NOTEBOOK))
#define GXK_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_NOTEBOOK))
#define GXK_NOTEBOOK_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_NOTEBOOK, GxkNotebookClass))
-
-
/* --- structures --- */
typedef struct {
GtkNotebook parent_instance;
@@ -24,13 +19,9 @@ typedef struct {
typedef struct {
GtkNotebookClass parent_class;
} GxkNotebookClass;
-
-
/* --- prototypes --- */
GType gxk_notebook_get_type (void);
void gxk_notebook_set_assortment (GxkNotebook *self,
GxkAssortment *assortment);
-
G_END_DECLS
-
#endif /* __GXK_NOTEBOOK_H__ */
diff --git a/beast-gtk/gxk/gxkparam-entry.cc b/beast-gtk/gxk/gxkparam-entry.cc
index 91e2b57..29f4037 100644
--- a/beast-gtk/gxk/gxkparam-entry.cc
+++ b/beast-gtk/gxk/gxkparam-entry.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- string parameters --- */
static void
param_entry_changed (GtkWidget *entry,
@@ -17,7 +16,6 @@ param_entry_changed (GtkWidget *entry,
gxk_param_apply_value (param);
}
}
-
static GtkWidget*
param_entry_create (GxkParam *param,
const gchar *tooltip,
@@ -35,14 +33,12 @@ param_entry_create (GxkParam *param,
gxk_widget_add_option (widget, "hexpand", "+");
return widget;
}
-
static void
param_entry_update (GxkParam *param,
GtkWidget *widget)
{
gxk_param_entry_set_text (param, widget, g_value_get_string (¶m->value));
}
-
static GxkParamEditor param_entry = {
{ "entry", N_("Text Entry"), },
{ G_TYPE_STRING, },
diff --git a/beast-gtk/gxk/gxkparam-label.cc b/beast-gtk/gxk/gxkparam-label.cc
index b6bb464..bfb1346 100644
--- a/beast-gtk/gxk/gxkparam-label.cc
+++ b/beast-gtk/gxk/gxkparam-label.cc
@@ -1,12 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- label display --- */
enum {
PARAM_LABEL,
PARAM_LABEL_IDENT,
PARAM_LABEL_NAME,
};
-
static GtkWidget*
param_label_create (GxkParam *param,
const gchar *tooltip,
@@ -37,14 +35,12 @@ param_label_create (GxkParam *param,
gtk_label_set_text (GTK_LABEL (widget), g_param_spec_get_nick (param->pspec));
return widget;
}
-
static void
param_label_update (GxkParam *param,
GtkWidget *widget)
{
gtk_label_set_text (GTK_LABEL (widget), g_value_get_string (¶m->value));
}
-
static GxkParamEditor param_label1 = {
{ "ident", N_("Property Identifier"), },
{ 0, },
diff --git a/beast-gtk/gxk/gxkparam-scale.cc b/beast-gtk/gxk/gxkparam-scale.cc
index 3d8fc83..f61942f 100644
--- a/beast-gtk/gxk/gxkparam-scale.cc
+++ b/beast-gtk/gxk/gxkparam-scale.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- h/v scale editors --- */
enum {
PARAM_SCALE_HORIZONTAL,
@@ -7,7 +6,6 @@ enum {
PARAM_SCALE_VERTICAL,
PARAM_LSCALE_VERTICAL,
};
-
static void
param_scale_hscale_size_request (GtkWidget *scale,
GtkRequisition *requisition)
@@ -19,7 +17,6 @@ param_scale_hscale_size_request (GtkWidget *scale,
requisition->width = slider_length * 1.5;
requisition->width += 2 * trough_border;
}
-
static void
param_scale_vscale_size_request (GtkWidget *scale,
GtkRequisition *requisition)
@@ -31,7 +28,6 @@ param_scale_vscale_size_request (GtkWidget *scale,
requisition->height = slider_length * 1.5;
requisition->height += 2 * trough_border;
}
-
static GtkWidget*
param_scale_create (GxkParam *param,
const gchar *tooltip,
@@ -66,7 +62,6 @@ param_scale_create (GxkParam *param,
gxk_param_add_grab_widget (param, widget);
return widget;
}
-
static GxkParamEditor param_scale1 = {
{ "hscale-lin", N_("Horizontal Scale"), },
{ G_TYPE_NONE, NULL, TRUE, TRUE, }, /* all int types and all float types */
diff --git a/beast-gtk/gxk/gxkparam-spinner.cc b/beast-gtk/gxk/gxkparam-spinner.cc
index 473e32c..80e6093 100644
--- a/beast-gtk/gxk/gxkparam-spinner.cc
+++ b/beast-gtk/gxk/gxkparam-spinner.cc
@@ -1,11 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- spinnbutton editors --- */
enum {
PARAM_SPINNER_LINEAR,
PARAM_SPINNER_LOGARITHMIC,
};
-
static GtkWidget*
param_spinner_create (GxkParam *param,
const gchar *tooltip,
@@ -69,7 +67,6 @@ param_spinner_create (GxkParam *param,
gxk_widget_set_tooltip (widget, tooltip);
return widget;
}
-
static void
param_spinner_update (GxkParam *param,
GtkWidget *widget)
@@ -77,7 +74,6 @@ param_spinner_update (GxkParam *param,
/* contents are updated through the adjustment */
gtk_editable_set_editable (GTK_EDITABLE (widget), param->editable);
}
-
static GxkParamEditor param_spinner1 = {
{ "spinner", N_("Spin Button"), },
{ G_TYPE_NONE, NULL, TRUE, TRUE, }, /* all int types and all float types */
diff --git a/beast-gtk/gxk/gxkparam-toggle.cc b/beast-gtk/gxk/gxkparam-toggle.cc
index fc089bf..43fed64 100644
--- a/beast-gtk/gxk/gxkparam-toggle.cc
+++ b/beast-gtk/gxk/gxkparam-toggle.cc
@@ -1,13 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxksimplelabel.hh"
#include "gxkauxwidgets.hh"
-
/* --- toggle/check button editors --- */
enum {
PARAM_TOGGLE_CHECKER,
PARAM_TOGGLE_WITH_LABEL,
};
-
static void
param_toggle_change_value (GtkWidget *toggle,
GxkParam *param)
@@ -18,7 +16,6 @@ param_toggle_change_value (GtkWidget *toggle,
gxk_param_apply_value (param);
}
}
-
static GtkWidget*
param_toggle_create (GxkParam *param,
const gchar *tooltip,
@@ -53,21 +50,18 @@ param_toggle_create (GxkParam *param,
NULL);
return widget;
}
-
static void
param_toggle_update (GxkParam *param,
GtkWidget *widget)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), g_value_get_boolean (¶m->value));
}
-
static GxkParamEditor param_toggle = {
{ "toggle", N_("Check/ToggleRadio Button"), },
{ G_TYPE_BOOLEAN, },
{ NULL, +5, TRUE, }, /* options, rating, editing */
param_toggle_create, param_toggle_update, PARAM_TOGGLE_CHECKER,
};
-
static GxkParamEditor param_toggle_empty = {
{ "toggle+label", N_("Toggle Button"), },
{ G_TYPE_BOOLEAN, },
diff --git a/beast-gtk/gxk/gxkparam.cc b/beast-gtk/gxk/gxkparam.cc
index 7a93b41..3f65168 100644
--- a/beast-gtk/gxk/gxkparam.cc
+++ b/beast-gtk/gxk/gxkparam.cc
@@ -4,7 +4,6 @@
#include <string.h>
#include <math.h>
#include <libintl.h>
-
/* --- GxkParam functions --- */
static void
param_update_flags (GxkParam *param)
@@ -23,7 +22,6 @@ param_update_flags (GxkParam *param)
if (GTK_IS_WIDGET (slist->data))
gtk_widget_set_sensitive ((GtkWidget*) slist->data, param->sensitive);
}
-
static GxkParam*
param_new (GParamSpec *pspec,
gboolean is_constant,
@@ -51,7 +49,6 @@ param_new (GParamSpec *pspec,
}
return param;
}
-
GxkParam*
gxk_param_new (GParamSpec *pspec,
GxkParamBinding *binding,
@@ -61,7 +58,6 @@ gxk_param_new (GParamSpec *pspec,
g_return_val_if_fail (binding != NULL, NULL);
return param_new (pspec, FALSE, binding, user_data);
}
-
GxkParam*
gxk_param_new_constant (GParamSpec *pspec,
GxkParamBinding *binding,
@@ -71,7 +67,6 @@ gxk_param_new_constant (GParamSpec *pspec,
g_return_val_if_fail (binding != NULL, NULL);
return param_new (pspec, TRUE, binding, user_data);
}
-
static void
param_call_update (GxkParam *param,
gpointer object)
@@ -88,7 +83,6 @@ param_call_update (GxkParam *param,
param->updating = updating;
}
}
-
void
gxk_object_set_param_callback (GtkObject *object,
GxkParamUpdateFunc ufunc)
@@ -97,15 +91,12 @@ gxk_object_set_param_callback (GtkObject *object,
g_return_if_fail (GTK_IS_OBJECT (object));
g_object_set_data ((GObject*) object, "GxkParamUpdateFunc", (void*) ufunc);
}
-
void
gxk_param_update (GxkParam *param)
{
GSList *slist;
gboolean updating;
-
g_return_if_fail (GXK_IS_PARAM (param));
-
updating = param->updating;
param->updating = TRUE;
if (param->binding->get_value)
@@ -120,7 +111,6 @@ gxk_param_update (GxkParam *param)
}
param->updating = updating;
}
-
static gboolean
gxk_param_grouping_event (GtkWidget *widget,
GdkEvent *event,
@@ -141,7 +131,6 @@ gxk_param_grouping_event (GtkWidget *widget,
}
return FALSE;
}
-
static void
gxk_param_grouping_unrealized (GtkWidget *widget,
GxkParam *param)
@@ -149,7 +138,6 @@ gxk_param_grouping_unrealized (GtkWidget *widget,
while (param->grouping)
gxk_param_stop_grouping (param);
}
-
void
gxk_param_add_grab_widget (GxkParam *param,
GtkWidget *widget)
@@ -160,7 +148,6 @@ gxk_param_add_grab_widget (GxkParam *param,
"signal::unrealize", gxk_param_grouping_unrealized, param,
NULL);
}
-
static void
gxk_param_remove_object (GxkParam *param,
GtkObject *object)
@@ -179,7 +166,6 @@ gxk_param_remove_object (GxkParam *param,
NULL);
g_object_unref (object);
}
-
void
gxk_param_add_object (GxkParam *param,
GtkObject *object)
@@ -194,7 +180,6 @@ gxk_param_add_object (GxkParam *param,
param_call_update (param, object);
}
}
-
void
gxk_param_apply_value (GxkParam *param)
{
@@ -212,7 +197,6 @@ gxk_param_apply_value (GxkParam *param)
else
gxk_param_update (param);
}
-
void
gxk_param_apply_default (GxkParam *param)
{
@@ -223,7 +207,6 @@ gxk_param_apply_default (GxkParam *param)
gxk_param_apply_value (param);
}
}
-
void
gxk_param_set_editable (GxkParam *param,
gboolean editable)
@@ -244,21 +227,18 @@ gxk_param_set_editable (GxkParam *param,
}
}
}
-
const gchar*
gxk_param_get_name (GxkParam *param)
{
g_return_val_if_fail (GXK_IS_PARAM (param), NULL);
return param->pspec->name;
}
-
static gboolean _param_devel_tips = FALSE;
void
gxk_param_set_devel_tips (gboolean enabled)
{
_param_devel_tips = enabled != FALSE;
}
-
gchar*
gxk_param_dup_tooltip (GxkParam *param)
{
@@ -274,7 +254,6 @@ gxk_param_dup_tooltip (GxkParam *param)
tooltip = g_strdup_printf ("(%s)", g_param_spec_get_name (param->pspec));
return tooltip;
}
-
void
gxk_param_start_grouping (GxkParam *param)
{
@@ -285,7 +264,6 @@ gxk_param_start_grouping (GxkParam *param)
param->binding->start_grouping)
param->binding->start_grouping (param);
}
-
void
gxk_param_stop_grouping (GxkParam *param)
{
@@ -298,16 +276,13 @@ gxk_param_stop_grouping (GxkParam *param)
param->binding->stop_grouping (param);
}
}
-
void
gxk_param_destroy (GxkParam *param)
{
g_return_if_fail (GXK_IS_PARAM (param));
g_return_if_fail (param->binding != NULL);
-
while (param->grouping)
gxk_param_stop_grouping (param);
-
while (param->objects)
{
GObject *object = (GObject*) param->objects->data;
@@ -323,8 +298,6 @@ gxk_param_destroy (GxkParam *param)
g_param_spec_unref (param->pspec);
g_free (param);
}
-
-
/* --- value binding --- */
static void
param_value_binding_setup (GxkParam *param,
@@ -333,7 +306,6 @@ param_value_binding_setup (GxkParam *param,
if (user_data)
param->constant = TRUE;
}
-
static void
param_value_binding_set_value (GxkParam *param,
const GValue *value)
@@ -344,7 +316,6 @@ param_value_binding_set_value (GxkParam *param,
notify (param->bdata[1].v_pointer, param);
gxk_param_update (param);
}
-
static void
param_value_binding_get_value (GxkParam *param,
GValue *value)
@@ -352,14 +323,12 @@ param_value_binding_get_value (GxkParam *param,
g_value_copy (¶m->value, value);
g_param_value_validate (param->pspec, value);
}
-
static void
param_value_binding_destroy (GxkParam *param)
{
param->bdata[0].v_pointer = NULL;
param->bdata[1].v_pointer = NULL;
}
-
static GxkParamBinding _param_value_binding = {
2, /* fields: notify, notify_data */
param_value_binding_setup,
@@ -368,7 +337,6 @@ static GxkParamBinding _param_value_binding = {
param_value_binding_destroy,
/* check_writable */
};
-
GxkParam*
gxk_param_new_value (GParamSpec *pspec,
GxkParamValueNotify notify,
@@ -379,7 +347,6 @@ gxk_param_new_value (GParamSpec *pspec,
param->bdata[1].v_pointer = notify_data;
return param;
}
-
GxkParam*
gxk_param_new_constant_value (GParamSpec *pspec,
GxkParamValueNotify notify,
@@ -390,8 +357,6 @@ gxk_param_new_constant_value (GParamSpec *pspec,
param->bdata[1].v_pointer = notify_data;
return param;
}
-
-
/* --- param object binding --- */
static void
object_binding_set_value (GxkParam *param,
@@ -401,7 +366,6 @@ object_binding_set_value (GxkParam *param,
if (object)
g_object_set_property (object, param->pspec->name, value);
}
-
static void
object_binding_get_value (GxkParam *param,
GValue *value)
@@ -418,7 +382,6 @@ object_binding_get_value (GxkParam *param,
else
g_value_reset (value);
}
-
static void
object_binding_weakref (gpointer data,
GObject *junk)
@@ -427,7 +390,6 @@ object_binding_weakref (gpointer data,
param->bdata[0].v_pointer = NULL;
param->bdata[1].v_long = 0; /* already disconnected */
}
-
static void
object_binding_destroy (GxkParam *param)
{
@@ -440,7 +402,6 @@ object_binding_destroy (GxkParam *param)
param->bdata[1].v_long = 0;
}
}
-
static gboolean
object_binding_check_writable (GxkParam *param)
{
@@ -450,7 +411,6 @@ object_binding_check_writable (GxkParam *param)
else
return FALSE;
}
-
static GxkParamBinding g_object_binding = {
2, // n_data_fields
NULL, // setup
@@ -461,7 +421,6 @@ static GxkParamBinding g_object_binding = {
NULL, // start_grouping
NULL, // stop_grouping
};
-
GxkParam*
gxk_param_new_object (GParamSpec *pspec,
GObject *object)
@@ -470,7 +429,6 @@ gxk_param_new_object (GParamSpec *pspec,
gxk_param_set_object (param, object);
return param;
}
-
void
gxk_param_set_object (GxkParam *param,
GObject *object)
@@ -479,7 +437,6 @@ gxk_param_set_object (GxkParam *param,
g_return_if_fail (param->binding == &g_object_binding);
if (object)
g_return_if_fail (G_IS_OBJECT (object));
-
object_binding_destroy (param);
param->bdata[0].v_pointer = object;
if (object)
@@ -490,18 +447,14 @@ gxk_param_set_object (GxkParam *param,
g_object_weak_ref (object, object_binding_weakref, param);
}
}
-
GObject*
gxk_param_get_object (GxkParam *param)
{
g_return_val_if_fail (GXK_IS_PARAM (param), NULL);
-
if (param->binding == &g_object_binding)
return (GObject*) param->bdata[0].v_pointer;
return 0;
}
-
-
/* --- param view/editor --- */
static GSList *_param_editor_list = NULL;
static void
@@ -511,7 +464,6 @@ param_register_editor (GxkParamEditor *editor,
editor->ident.nick = dgettext (i18n_domain, editor->ident.nick);
_param_editor_list = g_slist_prepend (_param_editor_list, (GxkParamEditor*) editor);
}
-
static void
params_register_editor_dup_typed (GxkParamEditor *editor,
const gchar *i18n_domain,
@@ -521,7 +473,6 @@ params_register_editor_dup_typed (GxkParamEditor *editor,
ed->type_match.type = new_type;
param_register_editor (ed, GXK_I18N_DOMAIN);
}
-
void
gxk_param_register_editor (GxkParamEditor *editor,
const gchar *i18n_domain)
@@ -550,7 +501,6 @@ gxk_param_register_editor (GxkParamEditor *editor,
param_register_editor (editor, i18n_domain);
}
}
-
gchar**
gxk_param_list_editors (void)
{
@@ -570,10 +520,8 @@ gxk_param_list_editors (void)
names[i] = NULL;
return names;
}
-
static guint _param_editor_name_n_aliases = 0;
static const gchar ***_param_editor_name_aliases = NULL;
-
void
gxk_param_register_aliases (const gchar **aliases)
{
@@ -584,7 +532,6 @@ gxk_param_register_aliases (const gchar **aliases)
_param_editor_name_aliases[i] = aliases;
}
}
-
static gboolean
param_editor_name_match (const gchar *editor_name,
const GxkParamEditor *editor)
@@ -607,7 +554,6 @@ param_editor_name_match (const gchar *editor_name,
}
return FALSE;
}
-
static guint
param_score_editor (const GxkParamEditor *editor,
GParamSpec *pspec,
@@ -640,7 +586,6 @@ param_score_editor (const GxkParamEditor *editor,
option_mismatch |= !g_param_spec_provides_options (pspec, editor->features.options);
bonus++;
}
-
if (annotate)
g_printerr (" %s(%s): fundamental=%s derived=%s%s%s editing=%s bonus=%+d%s%s: ",
editor->ident.name, editor->ident.nick,
@@ -652,14 +597,12 @@ param_score_editor (const GxkParamEditor *editor,
editor->features.rating,
editor->features.options ? " options=" : "",
editor->features.options ? editor->features.options : "");
-
if (type_mismatch || option_mismatch) /* bail out on mismatches */
{
if (annotate)
g_printerr ("%s mismatch\n", type_mismatch ? "type" : "option");
return 0;
}
-
guint rating = 0;
rating |= 256 - type_distance;
rating <<= 1;
@@ -672,12 +615,10 @@ param_score_editor (const GxkParamEditor *editor,
rating += 128 + editor->features.rating; /* rating is signed, 8bit */
rating <<= 8;
rating += bonus; /* bonus is provided for overcomming additional mismatch possibilities */
-
if (annotate)
g_printerr ("%d\n", rating);
return rating;
}
-
static GxkParamEditor*
param_lookup_editor (const gchar *editor_name,
GParamSpec *pspec)
@@ -704,7 +645,6 @@ param_lookup_editor (const gchar *editor_name,
#endif
return best;
}
-
guint
gxk_param_editor_score (const gchar *editor_name,
GParamSpec *pspec)
@@ -724,7 +664,6 @@ gxk_param_editor_score (const gchar *editor_name,
}
return rating;
}
-
void
gxk_param_editor_debug_score (GParamSpec *pspec)
{
@@ -745,7 +684,6 @@ gxk_param_editor_debug_score (GParamSpec *pspec)
rating = MAX (r, rating);
}
}
-
const gchar*
gxk_param_lookup_editor (const gchar *editor_name,
GParamSpec *pspec)
@@ -754,7 +692,6 @@ gxk_param_lookup_editor (const gchar *editor_name,
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), 0);
return param_lookup_editor (editor_name, pspec)->ident.name;
}
-
GtkWidget*
gxk_param_create_editor (GxkParam *param,
const gchar *editor_name)
@@ -776,7 +713,6 @@ gxk_param_create_editor (GxkParam *param,
gxk_param_add_object (param, GTK_OBJECT (toplevel));
return toplevel;
}
-
/* --- param editor sizes --- */
static const GxkParamEditorSizes param_editor_default_sizes = {
TRUE, /* may_resize */
@@ -800,7 +736,6 @@ static const GxkParamEditorSizes param_editor_default_sizes = {
};
static GxkParamEditorSizes *size_groups = NULL;
static guint n_size_groups = 0;
-
guint
gxk_param_create_size_group (void)
{
@@ -813,7 +748,6 @@ gxk_param_create_size_group (void)
size_groups[i].request_fractions = FALSE;
return n_size_groups;
}
-
const GxkParamEditorSizes*
gxk_param_get_editor_sizes (GxkParam *param)
{
@@ -821,7 +755,6 @@ gxk_param_get_editor_sizes (GxkParam *param)
return &size_groups[param->size_group - 1];
return ¶m_editor_default_sizes;
}
-
void
gxk_param_set_size_group (GxkParam *param,
guint size_group)
@@ -830,7 +763,6 @@ gxk_param_set_size_group (GxkParam *param,
g_return_if_fail (size_group <= n_size_groups);
param->size_group = size_group;
}
-
void
gxk_param_set_sizes (guint size_group,
const GxkParamEditorSizes *esizes)
@@ -838,7 +770,6 @@ gxk_param_set_sizes (guint size_group,
g_return_if_fail (size_group > 0 && size_group <= n_size_groups);
size_groups[size_group - 1] = esizes ? *esizes : param_editor_default_sizes;
}
-
guint
gxk_param_get_digits (gdouble value,
guint base)
@@ -847,15 +778,12 @@ gxk_param_get_digits (gdouble value,
return 1;
return 1 + log (value) / log (base);
}
-
-
/* --- param editor widgets --- */
#include "gxkparam-entry.cc"
#include "gxkparam-label.cc"
#include "gxkparam-scale.cc"
#include "gxkparam-spinner.cc"
#include "gxkparam-toggle.cc"
-
void
gxk_init_params (void)
{
@@ -874,7 +802,6 @@ gxk_init_params (void)
gxk_param_register_editor (¶m_toggle, GXK_I18N_DOMAIN);
gxk_param_register_editor (¶m_toggle_empty, GXK_I18N_DOMAIN);
}
-
/* --- param implementation utils --- */
gboolean
gxk_param_entry_key_press (GtkEntry *entry,
@@ -882,7 +809,6 @@ gxk_param_entry_key_press (GtkEntry *entry,
{
GtkEditable *editable = GTK_EDITABLE (entry);
gboolean intercept = FALSE;
-
if (event->state & GDK_MOD1_MASK)
switch (event->keyval)
{
@@ -900,7 +826,6 @@ gxk_param_entry_key_press (GtkEntry *entry,
}
return intercept;
}
-
void
gxk_param_entry_set_text (GxkParam *param,
GtkWidget *_entry,
@@ -917,7 +842,6 @@ gxk_param_entry_set_text (GxkParam *param,
}
gtk_editable_set_editable (GTK_EDITABLE (entry), param->editable);
}
-
static void
gxk_entry_changed_marshaller (GClosure *closure,
GValue *return_value,
@@ -932,7 +856,6 @@ gxk_entry_changed_marshaller (GClosure *closure,
if (!param->updating)
changed ((GtkWidget*) g_value_get_object (param_values + 0), param);
}
-
void
gxk_param_entry_connect_handlers (GxkParam *param,
GtkWidget *entry,
@@ -948,14 +871,12 @@ gxk_param_entry_connect_handlers (GxkParam *param,
g_signal_connect_closure (entry, "focus-out-event", closure, FALSE);
}
}
-
gboolean
gxk_param_ensure_focus (GtkWidget *widget)
{
gtk_widget_grab_focus (widget);
return FALSE;
}
-
static void
param_adjustment_update (GxkParam *param,
GtkObject *object)
@@ -966,7 +887,6 @@ param_adjustment_update (GxkParam *param,
gtk_adjustment_set_value (GTK_ADJUSTMENT (object), g_value_get_double (&dvalue));
g_value_unset (&dvalue);
}
-
static void
param_adjustment_value_changed (GtkAdjustment *adjustment,
GxkParam *param)
@@ -981,7 +901,6 @@ param_adjustment_value_changed (GtkAdjustment *adjustment,
gxk_param_apply_value (param);
}
}
-
GtkAdjustment*
gxk_param_get_adjustment_with_stepping (GxkParam *param,
gdouble pstepping)
@@ -995,7 +914,6 @@ gxk_param_get_adjustment_with_stepping (GxkParam *param,
if (GTK_IS_ADJUSTMENT (slist->data) &&
g_object_get_data ((GObject*) slist->data, "gxk-param-func") == gxk_param_get_adjustment_with_stepping)
return (GtkAdjustment*) slist->data;
-
#define EXTRACT_FIELDS(p,T,mi,ma,df) { T *t = (T*) p; mi = t->minimum; ma = t->maximum; df = t->default_value; }
if (G_IS_PARAM_SPEC_CHAR (pspec))
{
@@ -1052,7 +970,6 @@ gxk_param_get_adjustment_with_stepping (GxkParam *param,
else
return NULL;
#undef EXTRACT_FIELDS
-
if (pstepping <= 0)
pstepping = isint ? 1.0 : 0.1;
if (pstepping == stepping)
@@ -1076,13 +993,11 @@ gxk_param_get_adjustment_with_stepping (GxkParam *param,
g_object_set_data ((GObject*) adjustment, "gxk-param-func", (void*) gxk_param_get_adjustment_with_stepping);
return GTK_ADJUSTMENT (adjustment);
}
-
GtkAdjustment*
gxk_param_get_adjustment (GxkParam *param)
{
return gxk_param_get_adjustment_with_stepping (param, 0);
}
-
GtkAdjustment*
gxk_param_get_log_adjustment (GxkParam *param)
{
@@ -1110,11 +1025,9 @@ gxk_param_get_log_adjustment (GxkParam *param)
}
return NULL;
}
-
typedef struct {
gdouble mindb, maxdb;
} GxkParamDBData;
-
static gdouble
gxk_param_db_adjustment_convert (GxkAdapterAdjustment *self,
GxkAdapterAdjustmentConvertType convert_type,
@@ -1139,7 +1052,6 @@ gxk_param_db_adjustment_convert (GxkAdapterAdjustment *self,
return 0;
}
}
-
GtkAdjustment*
gxk_param_get_decibel_adjustment (GxkParam *param)
{
diff --git a/beast-gtk/gxk/gxkparam.hh b/beast-gtk/gxk/gxkparam.hh
index a808447..495e6bc 100644
--- a/beast-gtk/gxk/gxkparam.hh
+++ b/beast-gtk/gxk/gxkparam.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_PARAM_H__
#define __GXK_PARAM_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- macros --- */
#define GXK_IS_PARAM(p) (p && G_IS_PARAM_SPEC (p->pspec))
-
/* --- typedefs, structures & enums --- */
typedef struct _GxkParamBinding GxkParamBinding;
typedef struct {
@@ -48,7 +44,6 @@ struct _GxkParamBinding
};
typedef void (*GxkParamUpdateFunc) (GxkParam *param,
GtkObject *object);
-
/* --- functions --- */
GxkParam* gxk_param_new (GParamSpec *pspec,
GxkParamBinding *binding,
@@ -73,8 +68,6 @@ void gxk_param_set_devel_tips (gboolean enabled);
void gxk_param_destroy (GxkParam *param);
void gxk_object_set_param_callback (GtkObject *object,
GxkParamUpdateFunc ufunc);
-
-
/* --- param value binding --- */
typedef void (*GxkParamValueNotify) (gpointer notify_data,
GxkParam *param);
@@ -84,15 +77,12 @@ GxkParam* gxk_param_new_value (GParamSpec *pspec,
GxkParam* gxk_param_new_constant_value (GParamSpec *pspec,
GxkParamValueNotify notify,
gpointer notify_data);
-
/* --- param object binding --- */
GxkParam* gxk_param_new_object (GParamSpec *pspec,
GObject *object);
void gxk_param_set_object (GxkParam *param,
GObject *object);
GObject* gxk_param_get_object (GxkParam *param);
-
-
/* --- param view/editor --- */
typedef struct {
const char *name, *nick;
@@ -128,7 +118,6 @@ const gchar* gxk_param_lookup_editor (const gchar *editor_name,
GtkWidget* gxk_param_create_editor (GxkParam *param,
const gchar *editor_name);
void gxk_param_editor_debug_score (GParamSpec *pspec);
-
/* --- param editor size groups --- */
typedef struct {
guint may_resize : 1; /* whether the specified chars/digits may be adjusted */
@@ -153,8 +142,6 @@ void gxk_param_set_size_group (GxkParam
const GxkParamEditorSizes* gxk_param_get_editor_sizes (GxkParam *param);
guint gxk_param_get_digits (gdouble value,
guint base);
-
-
/* --- param implementation utils --- */
gboolean gxk_param_entry_key_press (GtkEntry *entry,
GdkEventKey *event);
@@ -171,9 +158,6 @@ GtkAdjustment* gxk_param_get_adjustment_with_stepping (GxkParam *param,
gdouble pstepping);
GtkAdjustment* gxk_param_get_log_adjustment (GxkParam *param);
GtkAdjustment* gxk_param_get_decibel_adjustment (GxkParam *param);
-
G_END_DECLS
-
#endif /* __GXK_PARAM_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/beast-gtk/gxk/gxkpolygon.cc b/beast-gtk/gxk/gxkpolygon.cc
index 3d970f6..73c20cf 100644
--- a/beast-gtk/gxk/gxkpolygon.cc
+++ b/beast-gtk/gxk/gxkpolygon.cc
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkpolygon.hh"
-
#include <math.h>
-
#define SQR(x) ((x) * (x))
#define PI 3.1415926535897932384626433832795029
-
-
/* --- prototypes --- */
static void gxk_polygon_class_init (GxkPolygonClass *klass);
static void gxk_polygon_init (GxkPolygon *self);
@@ -15,12 +11,8 @@ static void gxk_polygon_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gboolean gxk_polygon_expose (GtkWidget *widget,
GdkEventExpose *event);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
gxk_polygon_get_type (void)
@@ -39,28 +31,22 @@ gxk_polygon_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gxk_polygon_init,
};
-
type = g_type_register_static (GTK_TYPE_WIDGET,
"GxkPolygon",
&type_info, GTypeFlags (0));
}
return type;
}
-
static void
gxk_polygon_class_init (GxkPolygonClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = gxk_polygon_finalize;
-
widget_class->size_request = gxk_polygon_size_request;
widget_class->expose_event = gxk_polygon_expose;
}
-
static void
gxk_polygon_init (GxkPolygon *self)
{
@@ -71,18 +57,14 @@ gxk_polygon_init (GxkPolygon *self)
self->arcs = NULL;
gtk_widget_show (GTK_WIDGET (self));
}
-
static void
gxk_polygon_finalize (GObject *object)
{
GxkPolygon *self = GXK_POLYGON (object);
-
g_free (self->lines);
g_free (self->arcs);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
/**
* @param polygon_graph set of lines and arcs
*
@@ -95,7 +77,6 @@ gxk_polygon_new (GxkPolygonGraph *polygon_graph)
gxk_polygon_set_graph (self, polygon_graph);
return self;
}
-
/**
* @param self valid GxkPolygon
* @param n_lines number of lines
@@ -112,13 +93,11 @@ gxk_polygon_set_lines (GxkPolygon *self,
g_return_if_fail (GXK_IS_POLYGON (self));
if (n_lines)
g_return_if_fail (lines != NULL);
-
g_free (self->lines);
self->n_lines = n_lines;
self->lines = (GxkPolygonLine*) g_memdup (lines, sizeof (lines[0]) * n_lines);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
/**
* @param self valid GxkPolygon
* @param n_arcs number of arcs
@@ -135,13 +114,11 @@ gxk_polygon_set_arcs (GxkPolygon *self,
g_return_if_fail (GXK_IS_POLYGON (self));
if (n_arcs)
g_return_if_fail (arcs != NULL);
-
g_free (self->arcs);
self->n_arcs = n_arcs;
self->arcs = (GxkPolygonArc*) g_memdup (arcs, sizeof (arcs[0]) * n_arcs);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
/**
* @param self valid GxkPolygon
* @param polygon_graph set of lines and arcs
@@ -167,7 +144,6 @@ gxk_polygon_set_graph (GxkPolygon *self,
/* gxk_polygon_set_length (self, 0); */
}
}
-
/**
* @param self valid GxkPolygon
* @param length set of lines and arcs
@@ -180,11 +156,9 @@ gxk_polygon_set_length (GxkPolygon *self,
guint length)
{
g_return_if_fail (GXK_IS_POLYGON (self));
-
self->request_length = length;
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
gxk_polygon_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -193,7 +167,6 @@ gxk_polygon_size_request (GtkWidget *widget,
requisition->width = self->request_length;
requisition->height = self->request_length;
}
-
/* draw line styles:
* _ETCHED_IN: _ETCHED_OUT:
* #######. 3) # = Dark +++++++X 3) + = Light
@@ -258,7 +231,6 @@ init_gcs (GxkPolygon *self,
break;
}
}
-
static gboolean
gxk_polygon_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -273,7 +245,6 @@ gxk_polygon_expose (GtkWidget *widget,
guint n, pass, draw_lines, draw_arcs;
width -= 2;
height -= 2;
-
if (0)
gdk_draw_rectangle (widget->window,
widget->style->white_gc,
@@ -429,7 +400,6 @@ gxk_polygon_expose (GtkWidget *widget,
}
return FALSE;
}
-
#if 0 /* test polygons */
/* right turn */
lines[i++] = (GxkPolygonLine) { 0.5, 0.5, 0.0, 0.9 }; /* \ */
@@ -458,9 +428,7 @@ lines[i++] = (GxkPolygonLine) { 0.1, 0.0, 0.5, 0.5 }; /* / */
lines[i++] = (GxkPolygonLine) { 0.0, 0.0, 0.5, 0.5 }; /* / */
lines[i++] = (GxkPolygonLine) { 0.0, 0.1, 0.5, 0.5 }; /* / */
#endif
-
#define STOCK_SIZE 16
-
/* power */
static GxkPolygonLine power_lines[] = {
{ 0.44, 1.0, 0.44, 0.5 }, /* | */
diff --git a/beast-gtk/gxk/gxkpolygon.hh b/beast-gtk/gxk/gxkpolygon.hh
index c619f38..c94832a 100644
--- a/beast-gtk/gxk/gxkpolygon.hh
+++ b/beast-gtk/gxk/gxkpolygon.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_POLYGON_H__
#define __GXK_POLYGON_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_POLYGON (gxk_polygon_get_type ())
#define GXK_POLYGON(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_POLYGON, GxkPolygon))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_POLYGON(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_POLYGON))
#define GXK_IS_POLYGON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_POLYGON))
#define GXK_POLYGON_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_POLYGON, GxkPolygonClass))
-
-
/* --- structures --- */
typedef struct {
gfloat x1, y1, x2, y2;
@@ -42,8 +37,6 @@ typedef struct {
GxkPolygonArc *arcs;
guint length;
} GxkPolygonGraph;
-
-
/* --- prototypes --- */
GType gxk_polygon_get_type (void);
gpointer gxk_polygon_new (GxkPolygonGraph *polygon_graph);
@@ -67,7 +60,5 @@ extern GxkPolygonGraph gxk_polygon_play;
extern GxkPolygonGraph gxk_polygon_forward;
extern GxkPolygonGraph gxk_polygon_next;
extern GxkPolygonGraph gxk_polygon_last;
-
G_END_DECLS
-
#endif /* __GXK_POLYGON_H__ */
diff --git a/beast-gtk/gxk/gxkrackcovers.cc b/beast-gtk/gxk/gxkrackcovers.cc
index ff3e47b..acd7916 100644
--- a/beast-gtk/gxk/gxkrackcovers.cc
+++ b/beast-gtk/gxk/gxkrackcovers.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* --- functions --- */
static GtkWidget*
rack_cover_create (GtkWidget *rtable)
@@ -27,39 +26,30 @@ rack_cover_create (GtkWidget *rtable)
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *pix;
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (rtable), &mask, NULL, (gchar**) rivet_xpm);
pix = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (pix);
gtk_table_attach (table, pix, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
-
gdk_pixmap_unref (pixmap);
gdk_pixmap_unref (mask);
-
pix = (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT, "visible", TRUE, NULL);
gtk_table_attach (table, pix, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0);
-
g_object_ref (cover);
gtk_object_sink (GTK_OBJECT (cover));
-
return cover;
}
-
static void
rack_cover_grow_area_horizontal (GxkRackTable *rtable,
guint col,
@@ -69,7 +59,6 @@ rack_cover_grow_area_horizontal (GxkRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (i = 1; col + i < table->ncols; i++)
if (gxk_rack_table_check_cell (rtable, col + i, row))
break;
@@ -79,7 +68,6 @@ rack_cover_grow_area_horizontal (GxkRackTable *rtable,
*hspan = i;
*vspan = j;
}
-
static void
rack_cover_grow_area_vertical (GxkRackTable *rtable,
guint col,
@@ -89,7 +77,6 @@ rack_cover_grow_area_vertical (GxkRackTable *rtable,
{
GtkTable *table = GTK_TABLE (rtable);
guint i, j;
-
for (j = 1; row + j < table->nrows; j++)
if (gxk_rack_table_check_cell (rtable, col, row + j))
break;
@@ -99,7 +86,6 @@ rack_cover_grow_area_vertical (GxkRackTable *rtable,
*hspan = i;
*vspan = j;
}
-
static GSList*
rack_cover_add_plates (GxkRackTable *rtable)
{
@@ -108,7 +94,6 @@ rack_cover_add_plates (GxkRackTable *rtable)
guint i, j;
guint k, l, m, n;
GSList *plate_list = NULL;
-
if (0)
{
/* grab the first free cell and start growing a cover from it.
@@ -121,13 +106,11 @@ rack_cover_add_plates (GxkRackTable *rtable)
{
rack_cover_grow_area_vertical (rtable, i, j, &k, &l);
rack_cover_grow_area_horizontal (rtable, i, j, &m, &n);
-
if (m * n > k * l)
{
k = m;
l = n;
}
-
cover = rack_cover_create (GTK_WIDGET (rtable));
plate_list = g_slist_prepend (plate_list, cover);
gxk_rack_table_attach (rtable, cover, i, j, k, l);
diff --git a/beast-gtk/gxk/gxkrackeditor.cc b/beast-gtk/gxk/gxkrackeditor.cc
index 60ec08d..b1fd617 100644
--- a/beast-gtk/gxk/gxkrackeditor.cc
+++ b/beast-gtk/gxk/gxkrackeditor.cc
@@ -1,17 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkrackeditor.hh"
#include "gxkrackitem.hh"
-
-
#define CR_WINDOW_THICKNESS(self) (2)
#define CR_WINDOW_SPAN(self) (MAX (self->cell_request_width, self->cell_request_height) * 3/4)
-
-
/* --- prototypes --- */
static void rack_table_abort_drag (GxkRackTable *self,
guint32 etime);
-
-
/* --- functions --- */
static void
rack_table_realize_rframe (GxkRackTable *self)
@@ -21,7 +15,6 @@ rack_table_realize_rframe (GxkRackTable *self)
GdkColor *color = >K_WIDGET (self)->style->black;
GdkWindowAttr attributes = { 0, };
gint attributes_mask;
-
attributes_mask = GDK_WA_X | GDK_WA_Y;
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -34,7 +27,6 @@ rack_table_realize_rframe (GxkRackTable *self)
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
self->editor->iwindow = gdk_window_new (pwindow, &attributes, attributes_mask);
gdk_window_set_user_data (self->editor->iwindow, self);
-
attributes_mask = 0;
attributes.width = CR_WINDOW_THICKNESS (self);
attributes.height = CR_WINDOW_THICKNESS (self);
@@ -68,7 +60,6 @@ rack_table_realize_rframe (GxkRackTable *self)
gdk_window_set_user_data (self->editor->crq4, self);
gdk_window_set_background (self->editor->crq4, color);
}
-
static void
rack_table_hide_rframe (GxkRackTable *self)
{
@@ -86,7 +77,6 @@ rack_table_hide_rframe (GxkRackTable *self)
self->editor->rfw = self->editor->rfh = 0;
}
}
-
static GtkWidget*
rack_table_update_rframe (GxkRackTable *self,
gint cx,
@@ -131,7 +121,6 @@ rack_table_update_rframe (GxkRackTable *self,
gdk_window_show_unraised (self->editor->crb4);
return child;
}
-
static void
rack_table_editor_unrealize (GxkRackTable *self)
{
@@ -145,7 +134,6 @@ rack_table_editor_unrealize (GxkRackTable *self)
gdk_window_destroy (self->editor->crb3);
gdk_window_destroy (self->editor->crb4);
}
-
void
gxk_rack_table_adjust_editor (GxkRackTable *self)
{
@@ -167,7 +155,6 @@ gxk_rack_table_adjust_editor (GxkRackTable *self)
gdk_window_get_pointer (self->editor->iwindow, &x, &y, NULL);
rack_table_update_rframe (self, x, y);
}
-
void
gxk_rack_table_unmap_editor (GxkRackTable *self)
{
@@ -175,16 +162,13 @@ gxk_rack_table_unmap_editor (GxkRackTable *self)
gdk_window_hide (self->editor->iwindow);
rack_table_hide_rframe (self);
}
-
gboolean
gxk_rack_table_handle_button_press (GxkRackTable *self,
GdkEventButton *event)
{
GtkWidget *widget = GTK_WIDGET (self);
-
if (!self->editor || event->window != self->editor->iwindow)
return FALSE;
-
if (!self->editor->drag_child && (event->button == 1 || event->button == 2))
{
gint x = widget->allocation.x + event->x;
@@ -260,7 +244,6 @@ gxk_rack_table_handle_button_press (GxkRackTable *self,
}
return FALSE;
}
-
gboolean
gxk_rack_table_handle_enter_notify (GxkRackTable *self,
GdkEventCrossing *event)
@@ -269,7 +252,6 @@ gxk_rack_table_handle_enter_notify (GxkRackTable *self,
rack_table_update_rframe (self, event->x, event->y);
return TRUE;
}
-
static void
rack_table_editor_drag_corner (GxkRackTable *self,
gint h,
@@ -439,13 +421,11 @@ rack_table_editor_drag_corner (GxkRackTable *self,
self->editor->drag_hspan,
self->editor->drag_vspan);
}
-
gboolean
gxk_rack_table_handle_motion_notify (GxkRackTable *self,
GdkEventMotion *event)
{
GtkWidget *widget = GTK_WIDGET (self);
-
if (self->editor->drag_child)
{
guint h, v;
@@ -466,10 +446,8 @@ gxk_rack_table_handle_motion_notify (GxkRackTable *self,
if (event->is_hint) /* trigger new events */
gdk_window_get_pointer (widget->window, NULL, NULL, NULL);
}
-
return TRUE;
}
-
gboolean
gxk_rack_table_handle_leave_notify (GxkRackTable *self,
GdkEventCrossing *event)
@@ -478,7 +456,6 @@ gxk_rack_table_handle_leave_notify (GxkRackTable *self,
rack_table_hide_rframe (self);
return TRUE;
}
-
static void
rack_table_abort_drag (GxkRackTable *self,
guint32 etime)
@@ -499,7 +476,6 @@ rack_table_abort_drag (GxkRackTable *self,
self->editor->drag_vspan);
}
}
-
gboolean
gxk_rack_table_handle_button_release (GxkRackTable *self,
GdkEventButton *event)
@@ -519,7 +495,6 @@ gxk_rack_table_handle_button_release (GxkRackTable *self,
}
return TRUE;
}
-
void
gxk_rack_table_destroy_editor (GxkRackTable *self)
{
@@ -530,13 +505,11 @@ gxk_rack_table_destroy_editor (GxkRackTable *self)
g_free (self->editor);
self->editor = NULL;
}
-
void
gxk_rack_table_set_edit_mode (GxkRackTable *self,
gboolean enable_editing)
{
g_return_if_fail (GXK_IS_RACK_TABLE (self));
-
enable_editing = enable_editing && GTK_WIDGET_DRAWABLE (self);
if (!self->editor && enable_editing)
{
@@ -554,18 +527,15 @@ gxk_rack_table_set_edit_mode (GxkRackTable *self,
gtk_widget_queue_draw (GTK_WIDGET (self));
g_signal_emit_by_name (self, "edit-mode-changed", self->editor != NULL);
}
-
gboolean
gxk_rack_table_check_cell (GxkRackTable *self,
guint col,
guint row)
{
g_return_val_if_fail (GXK_IS_RACK_TABLE (self), FALSE);
-
gxk_rack_table_update_child_map (self);
return g_bit_matrix_test (self->child_map, col, row);
}
-
gboolean
gxk_rack_table_check_area (GxkRackTable *self,
gboolean framed,
@@ -577,9 +547,7 @@ gxk_rack_table_check_area (GxkRackTable *self,
{
guint ecol, erow, ehspan, evspan, i, j;
gboolean empty_frame;
-
g_return_val_if_fail (GXK_IS_RACK_TABLE (self), FALSE);
-
gxk_rack_table_update_child_map (self);
if (col + hspan > self->child_map->width ||
row + vspan > self->child_map->height)
@@ -611,7 +579,6 @@ gxk_rack_table_check_area (GxkRackTable *self,
}
return FALSE;
}
-
gboolean
gxk_rack_table_expand_rect (GxkRackTable *self,
guint col,
@@ -621,19 +588,15 @@ gxk_rack_table_expand_rect (GxkRackTable *self,
{
GtkTable *table;
guint i, j, f;
-
g_return_val_if_fail (GXK_IS_RACK_TABLE (self), FALSE);
-
gxk_rack_table_update_child_map (self);
table = GTK_TABLE (self);
if (col >= table->ncols || row >= table->nrows ||
g_bit_matrix_peek (self->child_map, col, row))
return FALSE;
-
/* we start two expansion passes, first horizontal, then
* vertical. the greater resulting area is returned.
*/
-
/* expand horizontally */
for (i = 1; col + i < table->ncols; i++)
if (g_bit_matrix_peek (self->child_map, col + i, row))
@@ -645,7 +608,6 @@ gxk_rack_table_expand_rect (GxkRackTable *self,
last_row_break:
*hspan = i;
*vspan = j;
-
/* expand vertically */
for (j = j; row + j < table->nrows; j++)
if (g_bit_matrix_peek (self->child_map, col, row + j))
diff --git a/beast-gtk/gxk/gxkrackeditor.hh b/beast-gtk/gxk/gxkrackeditor.hh
index d04066a..c630d69 100644
--- a/beast-gtk/gxk/gxkrackeditor.hh
+++ b/beast-gtk/gxk/gxkrackeditor.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_RACK_EDITOR_H__
#define __GXK_RACK_EDITOR_H__
-
#include <gxk/gxkracktable.hh>
-
G_BEGIN_DECLS
-
struct _GxkRackEditor {
GdkWindow *iwindow;
gint rfx, rfy, rfw, rfh;
@@ -19,8 +16,6 @@ struct _GxkRackEditor {
gint drag_corner, drag_x, drag_y;
gint drag_col, drag_row, drag_hspan, drag_vspan;
};
-
-
/* --- prototypes --- */
void gxk_rack_table_set_edit_mode (GxkRackTable *self,
gboolean enable_editing);
@@ -39,8 +34,6 @@ gboolean gxk_rack_table_expand_rect (GxkRackTable *self,
guint row,
guint *hspan,
guint *vspan);
-
-
/* --- implementation details --- */
void gxk_rack_table_destroy_editor (GxkRackTable *self);
gboolean gxk_rack_table_handle_enter_notify (GxkRackTable *self,
@@ -55,8 +48,5 @@ gboolean gxk_rack_table_handle_leave_notify (GxkRackTable *self,
GdkEventCrossing *event);
void gxk_rack_table_adjust_editor (GxkRackTable *self);
void gxk_rack_table_unmap_editor (GxkRackTable *self);
-
-
G_END_DECLS
-
#endif /* __GXK_RACK_EDITOR_H__ */
diff --git a/beast-gtk/gxk/gxkrackitem.cc b/beast-gtk/gxk/gxkrackitem.cc
index d04f600..90de7f8 100644
--- a/beast-gtk/gxk/gxkrackitem.cc
+++ b/beast-gtk/gxk/gxkrackitem.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkrackitem.hh"
#include <string.h>
-
/* --- prototypes --- */
static void gxk_rack_item_class_init (GxkRackItemClass *klass);
static void gxk_rack_item_init (GxkRackItem *self);
@@ -16,18 +15,13 @@ static void gxk_rack_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gxk_rack_item_button_press (GxkRackItem *self,
GdkEventButton *event);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
gxk_rack_item_get_type (void)
{
static GType type = 0;
-
if (!type)
{
static const GTypeInfo type_info = {
@@ -41,34 +35,25 @@ gxk_rack_item_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gxk_rack_item_init,
};
-
type = g_type_register_static (GTK_TYPE_FRAME,
"GxkRackItem",
&type_info, GTypeFlags (0));
}
-
return type;
}
-
static void
gxk_rack_item_class_init (GxkRackItemClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
object_class->destroy = gxk_rack_item_destroy;
-
widget_class->parent_set = gxk_rack_item_parent_set;
widget_class->size_allocate = gxk_rack_item_size_allocate;
-
container_class->add = gxk_rack_item_add;
container_class->remove = gxk_rack_item_remove;
-
klass->button_press = gxk_rack_item_button_press;
-
g_signal_new ("button-press",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
@@ -77,7 +62,6 @@ gxk_rack_item_class_init (GxkRackItemClass *klass)
gxk_marshal_NONE__BOXED,
G_TYPE_NONE, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
}
-
static void
gxk_rack_item_init (GxkRackItem *self)
{
@@ -89,16 +73,13 @@ gxk_rack_item_init (GxkRackItem *self)
self->empty_frame = TRUE;
GTK_FRAME (self)->label_xalign = 0.5;
}
-
static void
gxk_rack_item_destroy (GtkObject *object)
{
// GxkRackItem *self = GXK_RACK_ITEM (object);
-
/* chain parent class' handler */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
gxk_rack_item_add (GtkContainer *container,
GtkWidget *child)
@@ -110,7 +91,6 @@ gxk_rack_item_add (GtkContainer *container,
gxk_rack_table_invalidate_child_map (GXK_RACK_TABLE (widget->parent));
GTK_CONTAINER_CLASS (parent_class)->add (container, child);
}
-
static void
gxk_rack_item_remove (GtkContainer *container,
GtkWidget *child)
@@ -122,19 +102,16 @@ gxk_rack_item_remove (GtkContainer *container,
gxk_rack_table_invalidate_child_map (GXK_RACK_TABLE (widget->parent));
GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
}
-
static void
update_frame (GxkRackItem *self)
{
GtkWidget *widget = GTK_WIDGET (self);
GxkRackTable *rtable = GXK_RACK_TABLE (widget->parent);
-
if (!self->empty_frame)
g_object_set (self,
"shadow_type", rtable->editor ? GTK_SHADOW_ETCHED_OUT : GTK_SHADOW_NONE,
NULL);
}
-
static void
gxk_rack_item_parent_set (GtkWidget *widget,
GtkWidget *previous_parent)
@@ -147,12 +124,10 @@ gxk_rack_item_parent_set (GtkWidget *widget,
}
else if (GXK_IS_RACK_TABLE (previous_parent))
g_object_disconnect (previous_parent, "any_signal", update_frame, self, NULL);
-
/* chain parent class' handler */
if (GTK_WIDGET_CLASS (parent_class)->parent_set)
GTK_WIDGET_CLASS (parent_class)->parent_set (widget, previous_parent);
}
-
static void
gxk_rack_item_size_allocate (GtkWidget *widget,
GtkAllocation *assigned_allocation)
@@ -167,9 +142,7 @@ gxk_rack_item_size_allocate (GtkWidget *widget,
GtkAllocation new_allocation;
gint cell_width = GXK_IS_RACK_TABLE (widget->parent) ? GXK_RACK_TABLE (widget->parent)->cell_width : 0;
gint cell_height = GXK_IS_RACK_TABLE (widget->parent) ? GXK_RACK_TABLE (widget->parent)->cell_height : 0;
-
widget->allocation = *assigned_allocation;
-
/* center within cell thickness */
cell_width -= widget->style->xthickness / 2;
cell_height -= widget->style->ythickness / 2;
@@ -183,9 +156,7 @@ gxk_rack_item_size_allocate (GtkWidget *widget,
widget->allocation.y += frame->label_widget ? 0 : cell_height / 2;
widget->allocation.height -= frame->label_widget ? cell_height / 2 : cell_height;
}
-
GTK_FRAME_GET_CLASS (frame)->compute_child_allocation (frame, &new_allocation);
-
/* If the child allocation changed, that means that the frame is drawn
* in a new place, so we must redraw the entire widget.
*/
@@ -195,26 +166,20 @@ gxk_rack_item_size_allocate (GtkWidget *widget,
new_allocation.width != frame->child_allocation.width ||
new_allocation.height != frame->child_allocation.height))
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
gtk_widget_size_allocate (bin->child, &new_allocation);
-
frame->child_allocation = new_allocation;
-
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
{
GtkRequisition child_requisition;
GtkAllocation child_allocation;
const int LABEL_PAD = 1, LABEL_SIDE_PAD = 2;
gfloat xalign;
-
gtk_widget_get_child_requisition (frame->label_widget, &child_requisition);
-
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
xalign = frame->label_xalign;
else
xalign = 1.0 - frame->label_xalign;
-
child_allocation.x = frame->child_allocation.x + LABEL_SIDE_PAD +
xalign * MAX (0, (frame->child_allocation.width -
child_requisition.width -
@@ -225,14 +190,11 @@ gxk_rack_item_size_allocate (GtkWidget *widget,
frame->child_allocation.width -
// 2 * LABEL_PAD -
2 * LABEL_SIDE_PAD);
-
child_allocation.y = frame->child_allocation.y - child_requisition.height;
child_allocation.height = child_requisition.height;
-
gtk_widget_size_allocate (frame->label_widget, &child_allocation);
}
}
-
static void
gxk_rack_item_button_press (GxkRackItem *self,
GdkEventButton *event)
@@ -242,13 +204,11 @@ gxk_rack_item_button_press (GxkRackItem *self,
}
g_print ("rack-item, button-%u pressed\n", event->button);
}
-
void
gxk_rack_item_gui_changed (GxkRackItem *self)
{
g_return_if_fail (GXK_IS_RACK_ITEM (self));
}
-
gboolean
gxk_rack_item_set_area (GxkRackItem *self,
gint col,
diff --git a/beast-gtk/gxk/gxkrackitem.hh b/beast-gtk/gxk/gxkrackitem.hh
index c2c3439..d8ef5a8 100644
--- a/beast-gtk/gxk/gxkrackitem.hh
+++ b/beast-gtk/gxk/gxkrackitem.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_RACK_ITEM_H__
#define __GXK_RACK_ITEM_H__
-
#include <gxk/gxkracktable.hh>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_RACK_ITEM (gxk_rack_item_get_type ())
#define GXK_RACK_ITEM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_RACK_ITEM, GxkRackItem))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_RACK_ITEM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_RACK_ITEM))
#define GXK_IS_RACK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_RACK_ITEM))
#define GXK_RACK_ITEM_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_RACK_ITEM, GxkRackItemClass))
-
-
/* --- structures & typedefs --- */
typedef struct _GxkRackItem GxkRackItem;
typedef struct _GxkRackItemClass GxkRackItemClass;
@@ -28,12 +23,9 @@ struct _GxkRackItem
struct _GxkRackItemClass
{
GtkFrameClass parent_class;
-
void (*button_press) (GxkRackItem *item,
GdkEventButton *event);
};
-
-
/* --- prototypes --- */
GtkType gxk_rack_item_get_type (void);
void gxk_rack_item_gui_changed (GxkRackItem *self);
@@ -42,7 +34,5 @@ gboolean gxk_rack_item_set_area (GxkRackItem *self,
gint row,
gint hspan,
gint vspan);
-
G_END_DECLS
-
#endif /* __GXK_RACK_ITEM_H__ */
diff --git a/beast-gtk/gxk/gxkracktable.cc b/beast-gtk/gxk/gxkracktable.cc
index 219fc4e..bde9395 100644
--- a/beast-gtk/gxk/gxkracktable.cc
+++ b/beast-gtk/gxk/gxkracktable.cc
@@ -2,7 +2,6 @@
#include "gxkracktable.hh"
#include "gxkrackeditor.hh"
#include "gxkrackitem.hh"
-
typedef enum
{
EXPOSE_AREA,
@@ -10,12 +9,8 @@ typedef enum
DRAW_ACTIVE,
DRAW_INACTIVE,
} AreaAction;
-
-
#define CR_WINDOW_THICKNESS (2)
#define CR_WINDOW_SPAN (8)
-
-
/* --- prototypes --- */
static void gxk_rack_table_class_init (GxkRackTableClass *klass);
static void gxk_rack_table_init (GxkRackTable *self);
@@ -45,13 +40,9 @@ static void gxk_rack_table_draw_area (GxkRackTable
guint vcell1,
guint hspan,
guint vspan);
-
-
/* --- static variables --- */
static gpointer parent_class = NULL;
static guint signal_edit_mode_changed = 0;
-
-
/* --- functions --- */
GType
gxk_rack_table_get_type (void)
@@ -76,7 +67,6 @@ gxk_rack_table_get_type (void)
}
return object_type;
}
-
static void
gxk_rack_table_class_init (GxkRackTableClass *klass)
{
@@ -84,13 +74,9 @@ gxk_rack_table_class_init (GxkRackTableClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = gxk_rack_table_finalize;
-
object_class->destroy = gxk_rack_table_destroy;
-
widget_class->style_set = gxk_rack_table_style_set;
widget_class->size_request = gxk_rack_table_size_request;
widget_class->size_allocate = gxk_rack_table_size_allocate;
@@ -103,10 +89,8 @@ gxk_rack_table_class_init (GxkRackTableClass *klass)
widget_class->leave_notify_event = (gboolean (*) (GtkWidget*, GdkEventCrossing*)) gxk_rack_table_handle_leave_notify;
widget_class->button_release_event = (gboolean (*) (GtkWidget*, GdkEventButton*)) gxk_rack_table_handle_button_release;
widget_class->expose_event = gxk_rack_table_expose;
-
container_class->add = gxk_rack_table_add;
container_class->remove = gxk_rack_table_remove;
-
signal_edit_mode_changed = g_signal_new ("edit-mode-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
@@ -115,7 +99,6 @@ gxk_rack_table_class_init (GxkRackTableClass *klass)
gxk_marshal_NONE__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}
-
static void
gxk_rack_table_init (GxkRackTable *self)
{
@@ -134,32 +117,24 @@ gxk_rack_table_init (GxkRackTable *self)
self->cell_height = 0;
self->editor = NULL;
}
-
static void
gxk_rack_table_destroy (GtkObject *object)
{
GxkRackTable *self = GXK_RACK_TABLE (object);
-
if (self->editor)
gxk_rack_table_destroy_editor (self);
gxk_rack_table_uncover (self);
-
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
gxk_rack_table_finalize (GObject *object)
{
GxkRackTable *self = GXK_RACK_TABLE (object);
-
while (self->covers)
g_object_unref (g_slist_pop_head (&self->covers));
-
g_bit_matrix_free (self->child_map);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
gxk_rack_table_style_set (GtkWidget *widget,
GtkStyle *previous_style)
@@ -167,11 +142,9 @@ gxk_rack_table_style_set (GtkWidget *widget,
GxkRackTable *self = GXK_RACK_TABLE (widget);
GdkFont *font = gtk_style_get_font (widget->style);
guint i, x = 0;
-
for (i = 0; i < 256; i++)
{
guint width = gdk_char_width (font, i);
-
x = MAX (x, width);
}
self->cell_request_width = x;
@@ -183,7 +156,6 @@ gxk_rack_table_style_set (GtkWidget *widget,
self->cell_request_width = self->cell_request_height = MAX (self->cell_request_width, self->cell_request_height);
}
}
-
static void
gxk_rack_table_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -192,16 +164,13 @@ gxk_rack_table_size_request (GtkWidget *widget,
GtkTable *table = GTK_TABLE (self);
GList *list;
guint i, j;
-
gxk_rack_table_invalidate_child_map (self); /* we get here when re-attaching children */
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
-
if (GTK_WIDGET_VISIBLE (child->widget))
gtk_widget_size_request (child->widget, NULL);
}
-
requisition->width = GTK_CONTAINER (self)->border_width * 2;
requisition->height = GTK_CONTAINER (self)->border_width * 2;
for (i = 0; i < table->ncols; i++)
@@ -215,25 +184,19 @@ gxk_rack_table_size_request (GtkWidget *widget,
requisition->height += table->rows[j].requisition;
}
}
-
static void
gxk_rack_table_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GxkRackTable *self = GXK_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (self);
-
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
gxk_rack_table_invalidate_child_map (self);
-
self->cell_width = table->cols[0].allocation;
self->cell_height = table->rows[0].allocation;
-
if (self->editor)
gxk_rack_table_adjust_editor (self);
}
-
static void
gxk_rack_table_unrealize (GtkWidget *widget)
{
@@ -242,7 +205,6 @@ gxk_rack_table_unrealize (GtkWidget *widget)
gxk_rack_table_destroy_editor (self);
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
-
static void
gxk_rack_table_map (GtkWidget *widget)
{
@@ -251,7 +213,6 @@ gxk_rack_table_map (GtkWidget *widget)
if (self->editor)
gxk_rack_table_adjust_editor (self);
}
-
static void
gxk_rack_table_unmap (GtkWidget *widget)
{
@@ -260,7 +221,6 @@ gxk_rack_table_unmap (GtkWidget *widget)
gxk_rack_table_unmap_editor (self);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
-
static void
gxk_rack_table_draw_area (GxkRackTable *self,
AreaAction action,
@@ -272,16 +232,13 @@ gxk_rack_table_draw_area (GxkRackTable *self,
GtkWidget *widget = GTK_WIDGET (self);
GtkTable *table = GTK_TABLE (self);
guint i, x, y, width, height, hcell2 = hcell1 + hspan, vcell2 = vcell1 + vspan;
-
g_return_if_fail (hspan > 0 && hcell2 <= table->ncols);
g_return_if_fail (vspan > 0 && vcell2 <= table->nrows);
-
x = GTK_CONTAINER (widget)->border_width + widget->allocation.x;
width = 0;
for (i = 0; i < hcell2; i++)
{
guint bound = table->cols[i].allocation + table->cols[i].spacing;
-
if (i < hcell1)
x += bound;
else
@@ -292,13 +249,11 @@ gxk_rack_table_draw_area (GxkRackTable *self,
for (i = 0; i < vcell2; i++)
{
guint bound = table->rows[i].allocation + table->rows[i].spacing;
-
if (i < vcell1)
y += bound;
else
height += bound;
}
-
switch (action)
{
GdkGC *bg_gc, *dark_gc, *light_gc;
@@ -349,7 +304,6 @@ gxk_rack_table_draw_area (GxkRackTable *self,
break;
}
}
-
void
gxk_rack_table_redraw_cells (GxkRackTable *self,
guint hcell1,
@@ -359,23 +313,19 @@ gxk_rack_table_redraw_cells (GxkRackTable *self,
{
gxk_rack_table_draw_area (self, EXPOSE_AREA, hcell1, vcell1, hspan, vspan);
}
-
static gint
gxk_rack_table_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GxkRackTable *self = GXK_RACK_TABLE (widget);
GtkTable *table = GTK_TABLE (self);
-
if (self->editor && event->window == widget->window)
{
int i, j, x = GTK_CONTAINER (self)->border_width + GTK_WIDGET (self)->allocation.x, bx = 0;
-
gxk_rack_table_update_child_map (self);
for (i = 0; i < table->ncols; i++)
{
int y = GTK_CONTAINER (self)->border_width + GTK_WIDGET (self)->allocation.y, by = 0;
-
bx = table->cols[i].allocation + table->cols[i].spacing;
if (x > event->area.x + event->area.width || x + bx < event->area.x)
{
@@ -407,12 +357,9 @@ gxk_rack_table_expose (GtkWidget *widget,
x += bx;
}
}
-
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-
return FALSE;
}
-
void
gxk_rack_table_attach (GxkRackTable *self,
GtkWidget *child,
@@ -435,7 +382,6 @@ gxk_rack_table_attach (GxkRackTable *self,
0, 0);
gxk_rack_table_invalidate_child_map (self);
}
-
static void
gxk_rack_table_add (GtkContainer *container,
GtkWidget *child)
@@ -502,19 +448,15 @@ gxk_rack_table_add (GtkContainer *container,
if (GXK_IS_RACK_ITEM (child))
gxk_rack_item_gui_changed (GXK_RACK_ITEM (child));
}
-
static void
gxk_rack_table_remove (GtkContainer *container,
GtkWidget *child)
{
GxkRackTable *self = GXK_RACK_TABLE (container);
-
gxk_rack_table_invalidate_child_map (self);
-
/* chain parent class' handler */
GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
}
-
gboolean
gxk_rack_table_translate (GxkRackTable *self,
gint x,
@@ -524,7 +466,6 @@ gxk_rack_table_translate (GxkRackTable *self,
{
GtkTable *table = GTK_TABLE (self);
guint i;
-
/* translate widget relative coordinates */
x -= GTK_CONTAINER (self)->border_width;
*hcell = 0;
@@ -540,7 +481,6 @@ gxk_rack_table_translate (GxkRackTable *self,
}
if (i >= table->ncols)
*hcell = table->ncols;
-
y -= GTK_CONTAINER (self)->border_width;
*vcell = 0;
for (i = 0; i < table->nrows; i++)
@@ -555,10 +495,8 @@ gxk_rack_table_translate (GxkRackTable *self,
}
if (i >= table->nrows)
*vcell = table->nrows;
-
return x >= 0 && *hcell < table->ncols && y >= 0 && *vcell < table->nrows;
}
-
GtkWidget*
gxk_rack_table_find_child (GxkRackTable *self,
gint x,
@@ -588,7 +526,6 @@ gxk_rack_table_find_child (GxkRackTable *self,
}
return NULL;
}
-
gboolean
gxk_rack_table_get_child_area (GxkRackTable *self,
GtkWidget *child_widget,
@@ -599,7 +536,6 @@ gxk_rack_table_get_child_area (GxkRackTable *self,
{
GtkTable *table = GTK_TABLE (self);
GList *list;
-
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
@@ -618,7 +554,6 @@ gxk_rack_table_get_child_area (GxkRackTable *self,
}
return FALSE;
}
-
static GtkWidget*
gxk_rack_table_find_cell_child (GxkRackTable *self,
guint hcell,
@@ -626,11 +561,9 @@ gxk_rack_table_find_cell_child (GxkRackTable *self,
{
GtkTable *table = GTK_TABLE (self);
GList *list;
-
for (list = table->children; list; list = list->next)
{
GtkTableChild *child = (GtkTableChild*) list->data;
-
if (hcell >= child->left_attach && hcell < child->right_attach &&
vcell >= child->top_attach && vcell < child->bottom_attach)
{
@@ -642,17 +575,14 @@ gxk_rack_table_find_cell_child (GxkRackTable *self,
return child->widget;
}
}
-
return NULL;
}
-
void
gxk_rack_table_invalidate_child_map (GxkRackTable *self)
{
g_bit_matrix_free (self->child_map);
self->child_map = NULL;
}
-
void
gxk_rack_table_update_child_map (GxkRackTable *self)
{
@@ -667,9 +597,7 @@ gxk_rack_table_update_child_map (GxkRackTable *self)
gxk_rack_table_find_cell_child (self, i, j) != NULL);
}
}
-
#include "gxkrackcovers.cc"
-
void
gxk_rack_table_cover_up (GxkRackTable *self)
{
@@ -677,7 +605,6 @@ gxk_rack_table_cover_up (GxkRackTable *self)
if (!self->covers)
self->covers = rack_cover_add_plates (self);
}
-
void
gxk_rack_table_uncover (GxkRackTable *self)
{
diff --git a/beast-gtk/gxk/gxkracktable.hh b/beast-gtk/gxk/gxkracktable.hh
index 9abc717..fde29dd 100644
--- a/beast-gtk/gxk/gxkracktable.hh
+++ b/beast-gtk/gxk/gxkracktable.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_RACK_TABLE_H__
#define __GXK_RACK_TABLE_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_RACK_TABLE (gxk_rack_table_get_type ())
#define GXK_RACK_TABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_RACK_TABLE, GxkRackTable))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_RACK_TABLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_RACK_TABLE))
#define GXK_IS_RACK_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_RACK_TABLE))
#define GXK_RACK_TABLE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_RACK_TABLE, GxkRackTableClass))
-
-
/* --- structures & typedefs --- */
typedef struct _GxkRackTable GxkRackTable;
typedef struct _GxkRackTableClass GxkRackTableClass;
@@ -33,14 +28,11 @@ struct _GxkRackTable
struct _GxkRackTableClass
{
GtkTableClass parent_class;
-
void (*edit_mode_changed) (GxkRackTable *self,
gboolean edit_mode);
void (*child_changed) (GxkRackTable *self,
GtkWidget *child);
};
-
-
/* --- prototypes --- */
GType gxk_rack_table_get_type (void);
gboolean gxk_rack_table_get_child_area (GxkRackTable *self,
@@ -72,8 +64,5 @@ void gxk_rack_table_attach (GxkRackTable *self,
guint vspan);
void gxk_rack_table_cover_up (GxkRackTable *self);
void gxk_rack_table_uncover (GxkRackTable *self);
-
-
G_END_DECLS
-
#endif /* __GXK_RACK_TABLE_H__ */
diff --git a/beast-gtk/gxk/gxkradget.cc b/beast-gtk/gxk/gxkradget.cc
index 7d1fcef..6229c5b 100644
--- a/beast-gtk/gxk/gxkradget.cc
+++ b/beast-gtk/gxk/gxkradget.cc
@@ -16,9 +16,7 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
-
#define NODE(n) ((Node*) n)
-
struct _GxkRadgetArgs {
guint n_variables;
gboolean intern_quarks;
@@ -28,11 +26,9 @@ struct _GxkRadgetArgs {
#define ARGS_N_ENTRIES(o) ((o) ? (o)->n_variables : 0)
#define ARGS_NTH_NAME(o,n) (g_quark_to_string ((o)->quarks[(n)]))
#define ARGS_NTH_VALUE(o,n) ((o)->values[(n)])
-
typedef struct {
guint null_collapse : 1;
} EnvSpecials;
-
typedef struct {
GSList *args_list; /* GxkRadgetArgs* */
const gchar *name;
@@ -41,7 +37,6 @@ typedef struct {
GData *hgroups, *vgroups, *hvgroups;
GxkRadget *xdef_radget;
} Env;
-
typedef struct {
const gchar *name;
const gchar *value;
@@ -79,8 +74,6 @@ typedef struct {
} PData; /* parser state */
typedef gchar* (*MacroFunc) (GSList *args,
Env *env);
-
-
/* --- prototypes --- */
static gchar* expand_expr (const gchar *expr,
Env *env);
@@ -99,16 +92,12 @@ static void gxk_adopt_hint_hook (GxkRadget *radget,
guint property_id,
const GValue *value,
GParamSpec *pspec);
-
-
/* --- variables --- */
static Domain *standard_domain = NULL;
static GQuark quark_id = 0;
static GQuark quark_name = 0;
static GQuark quark_radget_type = 0;
static GQuark quark_radget_node = 0;
-
-
/* --- functions --- */
static void
set_error (GError **error,
@@ -127,9 +116,7 @@ set_error (GError **error,
g_free (buffer);
}
}
-
#define g_slist_new(d) g_slist_prepend (0, d)
-
typedef struct {
Node *source;
Node *clone;
@@ -138,7 +125,6 @@ typedef struct {
guint n_clones;
NodeClone *clones;
} CloneList;
-
static void
clone_list_add (CloneList *clist,
Node *source,
@@ -149,7 +135,6 @@ clone_list_add (CloneList *clist,
clist->clones[i].source = source;
clist->clones[i].clone = clone;
}
-
static Node*
clone_list_find (CloneList *clist,
Node *source)
@@ -161,7 +146,6 @@ clone_list_find (CloneList *clist,
g_warning ("failed to find clone for %p", source);
return NULL;
}
-
static GxkRadgetArgs*
clone_args (const GxkRadgetArgs *source)
{
@@ -169,7 +153,6 @@ clone_args (const GxkRadgetArgs *source)
return gxk_radget_args_merge (gxk_radget_const_args (), source);
return NULL;
}
-
static Node*
clone_node_intern (Node *source,
const gchar *domain,
@@ -231,7 +214,6 @@ clone_node_intern (Node *source,
g_assert (source->call_stack == NULL);
return node;
}
-
static Node*
clone_node (Node *source,
const gchar *domain,
@@ -243,7 +225,6 @@ clone_node (Node *source,
g_free (clist.clones);
return node;
}
-
static inline gboolean
boolean_from_string (const gchar *value)
{
@@ -251,14 +232,12 @@ boolean_from_string (const gchar *value)
value[0] == 'f' || value[0] == 'F' ||
value[0] == 'n' || value[0] == 'N');
}
-
static inline gdouble
float_from_string (const gchar *value)
{
gdouble v_float = value ? g_strtod (value, NULL) : 0;
return v_float;
}
-
static inline guint64
num_from_string (const gchar *value)
{
@@ -266,7 +245,6 @@ num_from_string (const gchar *value)
v_float = v_float > 0 ? v_float + 0.5 : v_float - 0.5;
return v_float;
}
-
static inline gchar
char2eval (const gchar c)
{
@@ -279,7 +257,6 @@ char2eval (const gchar c)
else
return '-';
}
-
static inline gboolean
enum_match (const gchar *str1,
const gchar *str2)
@@ -293,7 +270,6 @@ enum_match (const gchar *str1,
}
return *str1 == 0 && *str2 == 0;
}
-
static gint
enums_match_value (guint n_values,
GEnumValue *values,
@@ -323,7 +299,6 @@ enums_match_value (guint n_values,
}
return fallback;
}
-
static void
env_clear (Env *env)
{
@@ -331,7 +306,6 @@ env_clear (Env *env)
g_datalist_clear (&env->vgroups);
g_datalist_clear (&env->hvgroups);
}
-
static GtkSizeGroup*
env_get_size_group (Env *env,
const gchar *name,
@@ -348,7 +322,6 @@ env_get_size_group (Env *env,
}
return sg;
}
-
typedef struct _RecursiveOption RecursiveOption;
struct _RecursiveOption {
RecursiveOption *next;
@@ -356,7 +329,6 @@ struct _RecursiveOption {
GQuark quark;
};
static RecursiveOption *stack_options = NULL;
-
static const GxkRadgetArgs*
env_find_quark (Env *env,
GQuark quark,
@@ -378,7 +350,6 @@ env_find_quark (Env *env,
}
return NULL;
}
-
static const gchar*
env_lookup (Env *env,
const gchar *var)
@@ -391,7 +362,6 @@ env_lookup (Env *env,
args = quark ? env_find_quark (env, quark, &nth) : NULL;
return args ? ARGS_NTH_VALUE (args, nth) : NULL;
}
-
static gchar*
env_expand_args_value (Env *env,
const GxkRadgetArgs *args,
@@ -408,7 +378,6 @@ env_expand_args_value (Env *env,
stack_options = ropt.next;
return exval;
}
-
static inline const gchar*
advance_level (const gchar *c)
{
@@ -430,7 +399,6 @@ advance_level (const gchar *c)
while (level);
return c;
}
-
static inline const gchar*
advance_arg (const gchar *c)
{
@@ -441,7 +409,6 @@ advance_arg (const gchar *c)
c++;
return c;
}
-
static const gchar*
parse_formula (const gchar *c,
GString *result,
@@ -478,7 +445,6 @@ parse_formula (const gchar *c,
}
return c;
}
-
static const gchar*
parse_dollar (const gchar *c,
GString *result,
@@ -524,7 +490,6 @@ parse_dollar (const gchar *c,
c++;
return c;
}
-
static gchar*
expand_expr (const gchar *expr,
Env *env)
@@ -550,7 +515,6 @@ expand_expr (const gchar *expr,
else
return g_string_free (result, FALSE);
}
-
#if 0 // FIXME: unused
static guint64
num_from_expr (const gchar *expr,
@@ -561,7 +525,6 @@ num_from_expr (const gchar *expr,
g_free (result);
return num;
}
-
static gboolean
boolean_from_expr (const gchar *expr,
Env *env)
@@ -572,7 +535,6 @@ boolean_from_expr (const gchar *expr,
return boolv;
}
#endif
-
static Node*
node_children_find_area (Node *node,
const gchar *area)
@@ -595,7 +557,6 @@ node_children_find_area (Node *node,
}
return NULL;
}
-
static Node*
node_find_area (Node *node,
const gchar *area)
@@ -631,7 +592,6 @@ node_find_area (Node *node,
else
return node;
}
-
static Node*
node_lookup (Domain *domain,
const gchar *node_name)
@@ -641,7 +601,6 @@ node_lookup (Domain *domain,
node = (Node*) g_datalist_get_data (&standard_domain->nodes, node_name);
return node;
}
-
static GxkRadgetArgs*
radget_args_intern_set (GxkRadgetArgs *args,
const gchar *name,
@@ -651,7 +610,6 @@ radget_args_intern_set (GxkRadgetArgs *args,
args = gxk_radget_const_args ();
return gxk_radget_args_set (args, name, value);
}
-
static Node*
node_define (Domain *domain,
const gchar *node_name,
@@ -764,7 +722,6 @@ node_define (Domain *domain,
set_error (error, "no radget type specified in definition of: %s", node_name);
return node;
}
-
static void /* callback for open tags <foo bar="baz"> */
radget_start_element (GMarkupParseContext *context,
const gchar *element_name,
@@ -820,7 +777,6 @@ radget_start_element (GMarkupParseContext *context,
else
set_error (error, "unknown element: %s", element_name);
}
-
static void /* callback for close tags </foo> */
radget_end_element (GMarkupParseContext *context,
const gchar *element_name,
@@ -842,7 +798,6 @@ radget_end_element (GMarkupParseContext *context,
g_slist_pop_head (&pdata->node_stack);
}
}
-
static void /* callback for character data */
radget_text (GMarkupParseContext *context,
const gchar *text, /* text is not 0-terminated */
@@ -852,7 +807,6 @@ radget_text (GMarkupParseContext *context,
{
// PData *pdata = user_data;
}
-
static void /* callback for comments and processing instructions */
radget_passthrough (GMarkupParseContext *context,
const gchar *passthrough_text, /* text is not 0-terminated. */
@@ -862,7 +816,6 @@ radget_passthrough (GMarkupParseContext *context,
{
// PData *pdata = user_data;
}
-
static void /* callback for errors, including ones set by other methods in the vtable */
radget_error (GMarkupParseContext *context,
GError *error, /* the GError should not be freed */
@@ -870,7 +823,6 @@ radget_error (GMarkupParseContext *context,
{
// PData *pdata = user_data;
}
-
static void
radget_parser (Domain *domain,
const gchar *i18n_domain,
@@ -909,9 +861,7 @@ radget_parser (Domain *domain,
g_markup_parse_context_end_parse (context, error);
g_markup_parse_context_free (context);
}
-
static GData *domains = NULL;
-
/**
* @param domain_name radget domain name
* @param file_name file containing ragdet definitions
@@ -945,7 +895,6 @@ gxk_radget_parse (const gchar *domain_name,
g_error_free (myerror);
}
}
-
/**
* @param domain_name radget domain name
* @param text radget definition string
@@ -980,7 +929,6 @@ gxk_radget_parse_text (const gchar *domain_name,
g_error_free (myerror);
}
}
-
static GtkSizeGroup*
toplevel_get_size_group (GtkWidget *toplevel,
const gchar *name,
@@ -998,7 +946,6 @@ toplevel_get_size_group (GtkWidget *toplevel,
g_free (key);
return sg;
}
-
static void
radget_widget_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
@@ -1031,7 +978,6 @@ radget_widget_hierarchy_changed (GtkWidget *widget,
g_object_set_data ((GObject*) widget, "gxk-window-hvgroup", NULL); /* gtk_size_group_add_widget() <= 2.4.4 may not be called twice */
}
}
-
static void
property_value_from_string (GtkType widget_type,
GParamSpec *pspec,
@@ -1123,7 +1069,6 @@ property_value_from_string (GtkType widget_type,
g_print ("property[%s]: expr=%s result=%s GValue=%s\n", pspec->name, pvalue, exvalue, g_strdup_value_contents (value));
g_free (exvalue);
}
-
static GxkRadgetArgs*
merge_args_list (GxkRadgetArgs *args,
GSList *call_args)
@@ -1136,7 +1081,6 @@ merge_args_list (GxkRadgetArgs *args,
}
return args;
}
-
static GxkRadgetArgs*
node_expand_call_args (Node *node,
GSList *call_args,
@@ -1189,14 +1133,12 @@ node_expand_call_args (Node *node,
g_slist_pop_head (&env->args_list);
return args;
}
-
struct GxkRadgetData {
Node *node;
GxkRadgetArgs *call_stack_top;
GxkRadget *xdef_radget;
Env *env;
};
-
static GxkRadget*
radget_create_from_node (Node *node,
GxkRadget *radget,
@@ -1298,7 +1240,6 @@ radget_create_from_node (Node *node,
g_slist_pop_head (&env->args_list);
return radget;
}
-
static void
radget_add_to_parent (GxkRadget *parent,
GxkRadget *radget,
@@ -1362,7 +1303,6 @@ radget_add_to_parent (GxkRadget *parent,
while (n_pops--)
g_slist_pop_head (&env->args_list);
}
-
static void
radget_apply_hooks (GxkRadget *radget,
Env *env,
@@ -1411,7 +1351,6 @@ radget_apply_hooks (GxkRadget *radget,
while (n_pops--)
g_slist_pop_head (&env->args_list);
}
-
static void
radget_create_children (GxkRadget *parent,
Env *env,
@@ -1437,7 +1376,6 @@ radget_create_children (GxkRadget *parent,
gxk_radget_free_args (call_args);
}
}
-
static GxkRadget*
radget_creator (GxkRadget *radget,
const gchar *domain_name,
@@ -1491,7 +1429,6 @@ radget_creator (GxkRadget *radget,
g_warning ("GxkRadget: no such radget domain: %s", domain_name);
return radget;
}
-
/* --- radget args --- */
GxkRadgetArgs*
gxk_radget_data_copy_call_args (GxkRadgetData *gdgdata)
@@ -1504,7 +1441,6 @@ gxk_radget_data_copy_call_args (GxkRadgetData *gdgdata)
g_slist_free (olist);
return args;
}
-
GxkRadgetArgs*
gxk_radget_const_args (void)
{
@@ -1512,7 +1448,6 @@ gxk_radget_const_args (void)
args->intern_quarks = TRUE;
return args;
}
-
GxkRadgetArgs*
gxk_radget_args_valist (const gchar *name1,
va_list var_args)
@@ -1527,7 +1462,6 @@ gxk_radget_args_valist (const gchar *name1,
}
return args;
}
-
GxkRadgetArgs*
gxk_radget_args (const gchar *name1,
...)
@@ -1539,7 +1473,6 @@ gxk_radget_args (const gchar *name1,
va_end (vargs);
return args;
}
-
GxkRadgetArgs*
gxk_radget_args_set (GxkRadgetArgs *args,
const gchar *name,
@@ -1568,7 +1501,6 @@ gxk_radget_args_set (GxkRadgetArgs *args,
args->values[i] = g_strdup (value);
return args;
}
-
static const gchar*
radget_args_lookup_quark (const GxkRadgetArgs *args,
GQuark quark,
@@ -1584,7 +1516,6 @@ radget_args_lookup_quark (const GxkRadgetArgs *args,
}
return NULL;
}
-
const gchar*
gxk_radget_args_get (const GxkRadgetArgs *args,
const gchar *name)
@@ -1594,7 +1525,6 @@ gxk_radget_args_get (const GxkRadgetArgs *args,
return radget_args_lookup_quark (args, quark, NULL);
return NULL;
}
-
GxkRadgetArgs*
gxk_radget_args_merge (GxkRadgetArgs *args,
const GxkRadgetArgs *source)
@@ -1609,7 +1539,6 @@ gxk_radget_args_merge (GxkRadgetArgs *args,
}
return args;
}
-
void
gxk_radget_free_args (GxkRadgetArgs *args)
{
@@ -1624,14 +1553,12 @@ gxk_radget_free_args (GxkRadgetArgs *args)
g_free (args);
}
}
-
/* --- radget functions --- */
GxkRadget*
gxk_radget_data_get_scope_radget (GxkRadgetData *gdgdata)
{
return gdgdata->xdef_radget;
}
-
gchar*
gxk_radget_data_dup_expand (GxkRadgetData *gdgdata,
const gchar *expression)
@@ -1641,7 +1568,6 @@ gxk_radget_data_dup_expand (GxkRadgetData *gdgdata,
gdgdata->env->skip_property = skip_property;
return string;
}
-
GxkRadget*
gxk_radget_creator (GxkRadget *radget,
const gchar *domain_name,
@@ -1659,7 +1585,6 @@ gxk_radget_creator (GxkRadget *radget,
}
return radget_creator (radget, domain_name, name, parent, call_args, env_args);
}
-
/**
* @param domain_name radget domain
* @param name radget definition name
@@ -1686,7 +1611,6 @@ gxk_radget_create (const gchar *domain_name,
va_end (vargs);
return radget;
}
-
/**
* @param radget toplevel ragdet container
* @param domain_name radget domain
@@ -1715,7 +1639,6 @@ gxk_radget_complete (GxkRadget *radget,
va_end (vargs);
return radget;
}
-
/**
* @param radget a valid radget
* @return radget domain
@@ -1730,7 +1653,6 @@ gxk_radget_get_domain (GxkRadget *radget)
g_return_val_if_fail (radget_node != NULL, NULL);
return radget_node->domain;
}
-
void
gxk_radget_sensitize (GxkRadget *radget,
const gchar *name,
@@ -1749,7 +1671,6 @@ gxk_radget_sensitize (GxkRadget *radget,
gtk_widget_set_sensitive (widget, sensitive);
}
}
-
/**
* @param radget a valid radget
* @param name radget name
@@ -1763,13 +1684,10 @@ gxk_radget_find (GxkRadget *radget,
const gchar *name)
{
const gchar *next, *c = name;
-
g_return_val_if_fail (radget != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
-
if (!GTK_IS_WIDGET (radget))
return NULL;
-
next = strchr (c, '.');
while (radget && next)
{
@@ -1782,7 +1700,6 @@ gxk_radget_find (GxkRadget *radget,
radget = gxk_widget_find_level_ordered ((GtkWidget*) radget, c);
return radget;
}
-
/**
* @param radget a valid radget
* @param area radget name
@@ -1806,7 +1723,6 @@ gxk_radget_find_area (GxkRadget *radget,
}
return radget;
}
-
/**
* @param radget a valid radget
* @param area radget name
@@ -1826,8 +1742,6 @@ gxk_radget_add (GxkRadget *radget,
else
g_error ("GxkRadget: failed to find area \"%s\"", area);
}
-
-
/* --- radget types --- */
static void
radget_define_type (GType type,
@@ -1845,7 +1759,6 @@ radget_define_type (GType type,
if (error)
g_error ("while registering standard radgets: %s", error->message);
}
-
void
gxk_init_radget_types (void)
{
@@ -1881,7 +1794,6 @@ gxk_init_radget_types (void)
gxk_radget_define_type (GXK_TYPE_WIDGET_PATCHER, gxk_widget_patcher_def);
gxk_radget_register_hook (g_param_spec_string ("gxk-adopt-hint", NULL, NULL, NULL, G_PARAM_READWRITE), 1, gxk_adopt_hint_hook);
}
-
gboolean
gxk_radget_type_lookup (GType type,
GxkRadgetType *ggtype)
@@ -1894,23 +1806,18 @@ gxk_radget_type_lookup (GType type,
}
return FALSE;
}
-
void
gxk_radget_define_type (GType type,
const GxkRadgetType *ggtype)
{
const gchar *attribute_names[1] = { NULL };
const gchar *attribute_values[1] = { NULL };
-
g_return_if_fail (!G_TYPE_IS_ABSTRACT (type));
g_return_if_fail (G_TYPE_IS_OBJECT (type));
g_return_if_fail (g_type_get_qdata (type, quark_radget_type) == NULL);
-
g_type_set_qdata (type, quark_radget_type, (gpointer) ggtype);
radget_define_type (type, g_type_name (type), attribute_names, attribute_values, NULL);
}
-
-
/* --- widget types --- */
static GParamSpec*
widget_find_prop (GTypeClass *klass,
@@ -1918,7 +1825,6 @@ widget_find_prop (GTypeClass *klass,
{
return g_object_class_find_property (G_OBJECT_CLASS (klass), construct_param_name);
}
-
static GxkRadget*
widget_create (GType type,
const gchar *name,
@@ -1930,7 +1836,6 @@ widget_create (GType type,
g_object_set (widget, "name", name, NULL);
return widget;
}
-
static void
gxk_adopt_hint_hook (GxkRadget *radget,
guint property_id,
@@ -1939,7 +1844,6 @@ gxk_adopt_hint_hook (GxkRadget *radget,
{
g_object_set_data_full ((GObject*) radget, "gxk-adopt-hint", g_value_dup_string (value), g_free);
}
-
static gboolean
widget_adopt (GxkRadget *radget,
GxkRadget *parent,
@@ -1969,7 +1873,6 @@ widget_adopt (GxkRadget *radget,
gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (radget));
return TRUE;
}
-
static GParamSpec*
widget_find_pack (GxkRadget *radget,
const gchar *pack_name)
@@ -1977,7 +1880,6 @@ widget_find_pack (GxkRadget *radget,
GtkWidget *parent = GTK_WIDGET (radget)->parent;
return gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (parent), pack_name);
}
-
static void
widget_set_pack (GxkRadget *radget,
const gchar *pack_name,
@@ -1986,7 +1888,6 @@ widget_set_pack (GxkRadget *radget,
GtkWidget *parent = GTK_WIDGET (radget)->parent;
gtk_container_child_set_property (GTK_CONTAINER (parent), (GtkWidget*) radget, pack_name, value);
}
-
void
gxk_radget_define_widget_type (GType type)
{
@@ -2018,11 +1919,9 @@ gxk_radget_define_widget_type (GType type)
const gchar *attribute_names[G_N_ELEMENTS (widget_def) + G_N_ELEMENTS (container_def) + 1];
const gchar *attribute_values[G_N_ELEMENTS (widget_def) + G_N_ELEMENTS (container_def) + 1];
guint i, j = 0;
-
g_return_if_fail (!G_TYPE_IS_ABSTRACT (type));
g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET));
g_return_if_fail (g_type_get_qdata (type, quark_radget_type) == NULL);
-
g_type_set_qdata (type, quark_radget_type, (gpointer) &widget_info);
for (i = 0; i < G_N_ELEMENTS (widget_def); i++)
{
@@ -2041,7 +1940,6 @@ gxk_radget_define_widget_type (GType type)
attribute_values[j] = NULL;
radget_define_type (type, g_type_name (type), attribute_names, attribute_values, NULL);
}
-
static gboolean
menu_adopt (GxkRadget *radget,
GxkRadget *parent,
@@ -2057,9 +1955,7 @@ menu_adopt (GxkRadget *radget,
gxk_menu_attach_as_popup ((GtkMenu*) radget, (GtkWidget*) parent);
return TRUE;
}
-
static void* return_NULL (void) { return NULL; }
-
static void
radget_define_gtk_menu (void)
{
@@ -2079,7 +1975,6 @@ radget_define_gtk_menu (void)
attribute_values[0] = "$(ifdef,visible,$visible,1)";
radget_define_type (type, g_type_name (type), attribute_names, attribute_values, NULL);
}
-
/* --- radget hooks --- */
typedef struct RadgetHook RadgetHook;
struct RadgetHook {
@@ -2088,7 +1983,6 @@ struct RadgetHook {
RadgetHook *next;
};
static RadgetHook *radget_hooks = NULL;
-
void
gxk_radget_register_hook (GParamSpec *pspec,
guint property_id,
@@ -2115,7 +2009,6 @@ gxk_radget_register_hook (GParamSpec *pspec,
hook->next = radget_hooks;
radget_hooks = hook;
}
-
static GParamSpec*
find_hook (const gchar *name,
GxkRadgetHook *hook_func_p)
@@ -2127,7 +2020,6 @@ find_hook (const gchar *name,
*hook_func_p = hook->hook_func;
return hook ? hook->pspec : NULL;
}
-
/* --- macro functions --- */
static inline const gchar*
argiter_pop (GSList **slist_p)
@@ -2140,7 +2032,6 @@ argiter_pop (GSList **slist_p)
}
return (const char*) d;
}
-
static inline gchar*
argiter_exp (GSList **slist_p,
Env *env)
@@ -2148,7 +2039,6 @@ argiter_exp (GSList **slist_p,
const gchar *s = argiter_pop (slist_p);
return s ? expand_expr (s, env) : NULL;
}
-
static gchar*
mf_if (GSList *args,
Env *env)
@@ -2164,7 +2054,6 @@ mf_if (GSList *args,
else
return elze ? expand_expr (elze, env) : g_strdup ("0");
}
-
static gchar*
mf_not (GSList *args,
Env *env)
@@ -2175,7 +2064,6 @@ mf_not (GSList *args,
g_free (cond);
return g_strdup (b ? "0" : "1");
}
-
static gchar*
mf_blogic (GSList *args,
Env *env)
@@ -2199,7 +2087,6 @@ mf_blogic (GSList *args,
result = !result;
return g_strdup (result ? "1" : "0");
}
-
static inline int
null_strcmp (const gchar *s1,
const gchar *s2)
@@ -2209,7 +2096,6 @@ null_strcmp (const gchar *s1,
else
return strcmp (s1, s2);
}
-
static gchar*
mf_str_cmp (GSList *args,
Env *env)
@@ -2247,9 +2133,7 @@ mf_str_cmp (GSList *args,
g_free (last);
return g_strdup (result ? "1" : "0");
}
-
#define EQ_FLAG 0x80
-
static gchar*
mf_floatcmp (GSList *args,
Env *env)
@@ -2288,7 +2172,6 @@ mf_floatcmp (GSList *args,
}
return g_strdup (result ? "1" : "0");
}
-
static gchar*
mf_floatcollect (GSList *args,
Env *env)
@@ -2321,7 +2204,6 @@ mf_floatcollect (GSList *args,
accu /= n;
return g_strdup_printf ("%.17g", accu);
}
-
static gchar*
mf_first_occupied (GSList *args,
Env *env)
@@ -2335,7 +2217,6 @@ mf_first_occupied (GSList *args,
}
return name ? name : g_strdup ("");
}
-
static gchar*
mf_ifdef (GSList *args,
Env *env)
@@ -2351,7 +2232,6 @@ mf_ifdef (GSList *args,
else
return elze ? expand_expr (elze, env) : g_strdup ("0");
}
-
static gchar*
mf_nth (GSList *args,
Env *env)
@@ -2363,7 +2243,6 @@ mf_nth (GSList *args,
g_free (num);
return d ? expand_expr (d, env) : NULL;
}
-
static gchar*
mf_null_collapse (GSList *args,
Env *env)
@@ -2374,7 +2253,6 @@ mf_null_collapse (GSList *args,
env->specials->null_collapse = TRUE;
return value;
}
-
static gchar*
mf_skip_property (GSList *args,
Env *env)
@@ -2382,14 +2260,12 @@ mf_skip_property (GSList *args,
env->skip_property = TRUE;
return g_strdup ("");
}
-
static gchar*
mf_empty (GSList *args,
Env *env)
{
return g_strdup ("");
}
-
static gchar*
mf_println (GSList *args,
Env *env)
@@ -2404,7 +2280,6 @@ mf_println (GSList *args,
g_print ("\n");
return NULL;
}
-
static MacroFunc
macro_func_lookup (const gchar *name)
{
diff --git a/beast-gtk/gxk/gxkradget.hh b/beast-gtk/gxk/gxkradget.hh
index 43687ae..d117939 100644
--- a/beast-gtk/gxk/gxkradget.hh
+++ b/beast-gtk/gxk/gxkradget.hh
@@ -1,18 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_RADGET_H__
#define __GXK_RADGET_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- structures --- */
#define GXK_RADGET G_OBJECT
#define GXK_IS_RADGET G_IS_OBJECT
typedef void GxkRadget;
typedef struct _GxkRadgetArgs GxkRadgetArgs;
-
-
/* --- radget args (aggregation of (name, value) pairs) --- */
GxkRadgetArgs* gxk_radget_args (const gchar *name1,
...);
@@ -27,8 +22,6 @@ const gchar* gxk_radget_args_get (const GxkRadgetArgs *args,
GxkRadgetArgs* gxk_radget_args_merge (GxkRadgetArgs *dest,
const GxkRadgetArgs *source);
void gxk_radget_free_args (GxkRadgetArgs *args);
-
-
/* --- radget functions --- */
GxkRadget* gxk_radget_create (const gchar *domain_name,
const gchar *name,
@@ -65,8 +58,6 @@ void gxk_radget_add (GxkRadget *radget,
void gxk_radget_sensitize (GxkRadget *radget,
const gchar *name,
gboolean sensitive);
-
-
/* --- radget types --- */
typedef struct GxkRadgetData GxkRadgetData;
typedef struct {
@@ -105,7 +96,5 @@ GxkRadgetArgs* gxk_radget_data_copy_call_args (GxkRadgetData *gdgdata);
GxkRadget* gxk_radget_data_get_scope_radget (GxkRadgetData *gdgdata);
gchar* gxk_radget_data_dup_expand (GxkRadgetData *gdgdata,
const gchar *expression);
-
G_END_DECLS
-
#endif /* __GXK_RADGET_H__ */
diff --git a/beast-gtk/gxk/gxkradgetfactory.cc b/beast-gtk/gxk/gxkradgetfactory.cc
index c61a438..c35be95 100644
--- a/beast-gtk/gxk/gxkradgetfactory.cc
+++ b/beast-gtk/gxk/gxkradgetfactory.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkradgetfactory.hh"
#include <string.h>
-
enum {
PROP_0,
PROP_NAME,
@@ -13,14 +12,10 @@ enum {
PROP_ACTIVATABLE,
PROP_REGULATE
};
-
/* --- static variables --- */
static GQuark quark_radget_factory_hook = 0;
-
-
/* --- functions --- */
G_DEFINE_TYPE (GxkRadgetFactory, gxk_radget_factory, G_TYPE_OBJECT);
-
static void
gxk_radget_factory_init (GxkRadgetFactory *self)
{
@@ -30,14 +25,12 @@ gxk_radget_factory_init (GxkRadgetFactory *self)
self->name = NULL;
self->action_root = g_strdup (":xdef");
}
-
static gchar*
value_dup_string_non_empty (const GValue *value)
{
const gchar *str = g_value_get_string (value);
return str && str[0] ? g_strdup (str) : NULL;
}
-
static void
gxk_radget_factory_set_property (GObject *object,
guint param_id,
@@ -84,7 +77,6 @@ gxk_radget_factory_set_property (GObject *object,
break;
}
}
-
static void
gxk_radget_factory_get_property (GObject *object,
guint param_id,
@@ -123,12 +115,10 @@ gxk_radget_factory_get_property (GObject *object,
break;
}
}
-
static void
gxk_radget_factory_finalize (GObject *object)
{
GxkRadgetFactory *self = GXK_RADGET_FACTORY (object);
-
g_assert (self->window == NULL);
g_datalist_clear (&self->branch_widgets);
g_free (self->action_root);
@@ -144,13 +134,10 @@ gxk_radget_factory_finalize (GObject *object)
GxkFactoryBranch *b = (GxkFactoryBranch*) g_slist_pop_head (&self->branches);
g_object_unref (b);
}
-
g_return_if_fail (self->timer == 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (gxk_radget_factory_parent_class)->finalize (object);
}
-
static GxkRadget*
radget_factory_retrieve_branch (GxkRadgetFactory *self,
const gchar *key_path, /* uline_unescaped */
@@ -196,7 +183,6 @@ radget_factory_retrieve_branch (GxkRadgetFactory *self,
}
return radget;
}
-
static gboolean
match_action_root (GxkRadgetFactory *self,
GtkWidget *publisher)
@@ -223,7 +209,6 @@ match_action_root (GxkRadgetFactory *self,
ancestor = gxk_widget_find_level_ordered ((GtkWidget*) self->window, self->action_root);
return ancestor && gxk_widget_has_ancestor (publisher, ancestor);
}
-
static inline const gchar*
strip_slashes (const gchar *string)
{
@@ -231,8 +216,6 @@ strip_slashes (const gchar *string)
string++;
return string;
}
-
-
static void
radget_factory_action_list_added (gpointer client_data,
GtkWindow *window,
@@ -341,7 +324,6 @@ radget_factory_action_list_added (gpointer client_data,
g_free (path_prefix);
}
}
-
static gboolean
radget_factory_check_anchored (gpointer data)
{
@@ -366,7 +348,6 @@ radget_factory_check_anchored (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
void
gxk_radget_factory_check_anchored (GxkRadgetFactory *self)
{
@@ -375,7 +356,6 @@ gxk_radget_factory_check_anchored (GxkRadgetFactory *self)
radget_factory_check_anchored,
self, NULL);
}
-
static void
destroy_factory_slist (gpointer data)
{
@@ -388,16 +368,13 @@ destroy_factory_slist (gpointer data)
g_object_unref (fact);
}
}
-
void
gxk_radget_factory_attach (GxkRadgetFactory *self,
GxkRadget *radget)
{
GSList *slist;
-
g_return_if_fail (self->radget == NULL);
g_return_if_fail (GTK_IS_WIDGET (radget));
-
g_object_ref (self);
slist = (GSList*) g_object_steal_qdata ((GObject*) radget, quark_radget_factory_hook);
slist = g_slist_prepend (slist, self);
@@ -409,18 +386,14 @@ gxk_radget_factory_attach (GxkRadgetFactory *self,
G_CALLBACK (gxk_radget_factory_check_anchored), self, G_CONNECT_SWAPPED);
gxk_radget_factory_check_anchored (self);
}
-
static void
gxk_radget_factory_class_init (GxkRadgetFactoryClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
quark_radget_factory_hook = g_quark_from_static_string ("GxkRadgetFactory-hook");
-
gobject_class->set_property = gxk_radget_factory_set_property;
gobject_class->get_property = gxk_radget_factory_get_property;
gobject_class->finalize = gxk_radget_factory_finalize;
-
g_object_class_install_property (gobject_class, PROP_NAME,
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_ACTION_ROOT,
@@ -438,8 +411,6 @@ gxk_radget_factory_class_init (GxkRadgetFactoryClass *klass)
g_object_class_install_property (gobject_class, PROP_REGULATE,
g_param_spec_string ("regulate", NULL, NULL, NULL, G_PARAM_READWRITE));
}
-
-
/* --- radget type hooks --- */
static GParamSpec*
radget_factory_find_prop (GTypeClass *klass,
@@ -447,7 +418,6 @@ radget_factory_find_prop (GTypeClass *klass,
{
return g_object_class_find_property (G_OBJECT_CLASS (klass), prop_name);
}
-
static GxkRadget*
radget_factory_create (GType type,
const gchar *name,
@@ -459,7 +429,6 @@ radget_factory_create (GType type,
g_object_set (widget, "name", name, NULL);
return widget;
}
-
static gboolean
radget_factory_adopt (GxkRadget *radget,
GxkRadget *parent,
@@ -472,7 +441,6 @@ radget_factory_adopt (GxkRadget *radget,
self->cslot = gxk_container_get_insertion_slot (GTK_CONTAINER (parent));
return FALSE; /* no support for packing options */
}
-
static const GxkRadgetType radget_factory_def = {
radget_factory_find_prop,
radget_factory_create,
@@ -482,22 +450,17 @@ static const GxkRadgetType radget_factory_def = {
NULL, /* set_pack */
};
const GxkRadgetType *gxk_radget_factory_def = &radget_factory_def;
-
-
/* --- GxkFactoryBranch --- */
G_DEFINE_TYPE (GxkFactoryBranch, gxk_factory_branch, G_TYPE_OBJECT);
-
enum {
FACTORY_BRANCH_PROP_0,
FACTORY_BRANCH_PROP_ULINE_LABEL,
FACTORY_BRANCH_PROP_KEY_LABEL
};
-
static void
gxk_factory_branch_init (GxkFactoryBranch *self)
{
}
-
static void
gxk_factory_branch_set_property (GObject *object,
guint param_id,
@@ -522,7 +485,6 @@ gxk_factory_branch_set_property (GObject *object,
if (!self->key_label && self->uline_label)
self->key_label = g_strdup (self->uline_label);
}
-
static void
gxk_factory_branch_finalize (GObject *object)
{
@@ -533,21 +495,17 @@ gxk_factory_branch_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (gxk_factory_branch_parent_class)->finalize (object);
}
-
static void
gxk_factory_branch_class_init (GxkFactoryBranchClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->set_property = gxk_factory_branch_set_property;
gobject_class->finalize = gxk_factory_branch_finalize;
-
g_object_class_install_property (gobject_class, FACTORY_BRANCH_PROP_ULINE_LABEL,
g_param_spec_string ("uline-label", NULL, NULL, NULL, G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class, FACTORY_BRANCH_PROP_KEY_LABEL,
g_param_spec_string ("key-label", NULL, NULL, NULL, G_PARAM_WRITABLE));
}
-
/* --- GxkFactoryBranch radget type hooks --- */
static GParamSpec*
factory_branch_find_prop (GTypeClass *klass,
@@ -555,7 +513,6 @@ factory_branch_find_prop (GTypeClass *klass,
{
return g_object_class_find_property (G_OBJECT_CLASS (klass), prop_name);
}
-
static GxkRadget*
factory_branch_create (GType type,
const gchar *name,
@@ -565,7 +522,6 @@ factory_branch_create (GType type,
{
return g_object_newv (type, n_construct_params, construct_params);
}
-
static gboolean
factory_branch_adopt (GxkRadget *radget,
GxkRadget *parent,
@@ -579,7 +535,6 @@ factory_branch_adopt (GxkRadget *radget,
factory->branches = g_slist_append (factory->branches, radget);
return FALSE; /* no support for packing args */
}
-
static const GxkRadgetType factory_branch_def = {
factory_branch_find_prop,
factory_branch_create,
diff --git a/beast-gtk/gxk/gxkradgetfactory.hh b/beast-gtk/gxk/gxkradgetfactory.hh
index 968f3ca..00181aa 100644
--- a/beast-gtk/gxk/gxkradgetfactory.hh
+++ b/beast-gtk/gxk/gxkradgetfactory.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_RADGET_FACTORY_H__
#define __GXK_RADGET_FACTORY_H__
-
#include "gxkradget.hh"
#include "gxkaction.hh"
-
G_BEGIN_DECLS
-
-
/* --- type macros --- */
#define GXK_TYPE_RADGET_FACTORY (gxk_radget_factory_get_type ())
#define GXK_RADGET_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_RADGET_FACTORY, GxkRadgetFactory))
@@ -15,8 +11,6 @@ G_BEGIN_DECLS
#define GXK_IS_RADGET_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_RADGET_FACTORY))
#define GXK_IS_RADGET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_RADGET_FACTORY))
#define GXK_RADGET_FACTORY_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_RADGET_FACTORY, GxkRadgetFactoryClass))
-
-
/* --- structures --- */
typedef struct {
GObject parent_instance;
@@ -38,8 +32,6 @@ typedef struct {
GSList *branches;
} GxkRadgetFactory;
typedef GObjectClass GxkRadgetFactoryClass;
-
-
/* --- public API --- */
GType gxk_radget_factory_get_type (void);
void gxk_radget_factory_check_anchored (GxkRadgetFactory *self);
@@ -48,8 +40,6 @@ void gxk_radget_factory_attach (GxkRadgetFactory *self,
void gxk_radget_factory_match (GxkRadgetFactory *self,
const gchar *prefix,
GxkActionList *alist);
-
-
/* --- GxkFactoryBranch --- */
#define GXK_TYPE_FACTORY_BRANCH (gxk_factory_branch_get_type ())
#define GXK_FACTORY_BRANCH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_FACTORY_BRANCH, GxkFactoryBranch))
@@ -65,13 +55,8 @@ typedef struct {
} GxkFactoryBranch;
typedef GObjectClass GxkFactoryBranchClass;
GType gxk_factory_branch_get_type (void);
-
-
/* --- implementation details --- */
extern const GxkRadgetType *gxk_radget_factory_def;
extern const GxkRadgetType *gxk_factory_branch_def;
-
-
G_END_DECLS
-
#endif /* __GXK_RADGET_FACTORY_H__ */
diff --git a/beast-gtk/gxk/gxkscrollcanvas.cc b/beast-gtk/gxk/gxkscrollcanvas.cc
index 16e8cf7..d6d3067 100644
--- a/beast-gtk/gxk/gxkscrollcanvas.cc
+++ b/beast-gtk/gxk/gxkscrollcanvas.cc
@@ -3,8 +3,6 @@
#include "gxkimagecache.hh"
#include <gdk/gdkkeysyms.h>
#include <string.h>
-
-
/* --- defines --- */
/* accessors */
#define STYLE(self) (GTK_WIDGET (self)->style)
@@ -68,13 +66,9 @@
/* behaviour */
#define AUTO_SCROLL_TIMEOUT (33)
#define AUTO_SCROLL_SCALE (0.2)
-
-
/* --- prototypes --- */
static void scroll_canvas_adjustment_value_changed (GxkScrollCanvas *self,
GtkAdjustment *adjustment);
-
-
/* --- functions --- */
#if 0
typedef enum /*< skip >*/
@@ -98,35 +92,28 @@ typedef enum /*< skip >*/
GXK_DRAG_AREA_XOR, /* Shift or Ctrl */
} GxkDragModifier;
#endif
-
GxkDragMode
gxk_drag_modifier_start (GdkModifierType key_mods)
{
return GxkDragMode (0);
}
-
GxkDragMode
gxk_drag_modifier_next (GdkModifierType key_mods,
GxkDragMode last_drag_mods)
{
return GxkDragMode (0);
}
-
G_DEFINE_TYPE (GxkScrollCanvas, gxk_scroll_canvas, GTK_TYPE_CONTAINER);
-
static void
gxk_scroll_canvas_init (GxkScrollCanvas *self)
{
GtkWidget *widget = GTK_WIDGET (self);
-
GTK_WIDGET_UNSET_FLAGS (self, GTK_NO_WINDOW);
gtk_widget_set_double_buffered (widget, FALSE);
gtk_widget_set_redraw_on_allocate (widget, TRUE);
gtk_widget_show (widget);
-
gxk_scroll_canvas_set_hadjustment (self, NULL);
gxk_scroll_canvas_set_vadjustment (self, NULL);
-
gxk_scroll_canvas_get_layout (self, &self->layout);
gxk_scroll_canvas_set_window_cursor (self, GXK_DEFAULT_CURSOR);
gxk_scroll_canvas_set_canvas_cursor (self, GXK_DEFAULT_CURSOR);
@@ -135,51 +122,40 @@ gxk_scroll_canvas_init (GxkScrollCanvas *self)
gxk_scroll_canvas_set_right_panel_cursor (self, GXK_DEFAULT_CURSOR);
gxk_scroll_canvas_set_bottom_panel_cursor (self, GXK_DEFAULT_CURSOR);
}
-
static void
scroll_canvas_destroy (GtkObject *object)
{
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (object);
-
if (self->scroll_timer)
g_source_remove (self->scroll_timer);
self->scroll_timer = 0;
-
gxk_scroll_canvas_set_hadjustment (self, NULL);
gxk_scroll_canvas_set_vadjustment (self, NULL);
-
GTK_OBJECT_CLASS (gxk_scroll_canvas_parent_class)->destroy (object);
}
-
static void
scroll_canvas_finalize (GObject *object)
{
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (object);
guint i;
-
g_object_unref (self->hadjustment);
self->hadjustment = NULL;
g_object_unref (self->vadjustment);
self->vadjustment = NULL;
-
for (i = 0; i < self->n_pango_layouts; i++)
if (self->pango_layouts[i])
g_object_unref (self->pango_layouts[i]);
g_free (self->pango_layouts);
self->pango_layouts = NULL;
self->n_pango_layouts = 0;
-
if (self->scroll_timer)
g_source_remove (self->scroll_timer);
self->scroll_timer = 0;
-
g_free (self->markers);
self->markers = NULL;
self->n_markers = 0;
-
G_OBJECT_CLASS (gxk_scroll_canvas_parent_class)->finalize (object);
}
-
static void
scroll_canvas_adjustment_changed_handler (GxkScrollCanvas *self,
GtkAdjustment *adjustment)
@@ -187,7 +163,6 @@ scroll_canvas_adjustment_changed_handler (GxkScrollCanvas *self,
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
klass->adjustment_changed (self, adjustment);
}
-
void
gxk_scroll_canvas_set_hadjustment (GxkScrollCanvas *self,
GtkAdjustment *adjustment)
@@ -195,7 +170,6 @@ gxk_scroll_canvas_set_hadjustment (GxkScrollCanvas *self,
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
if (self->hadjustment)
{
g_object_disconnect (self->hadjustment,
@@ -205,10 +179,8 @@ gxk_scroll_canvas_set_hadjustment (GxkScrollCanvas *self,
g_object_unref (self->hadjustment);
self->hadjustment = NULL;
}
-
if (!adjustment)
adjustment = (GtkAdjustment*) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);
-
self->hadjustment = (GtkAdjustment*) g_object_ref (adjustment);
gtk_object_sink (GTK_OBJECT (adjustment));
g_object_connect (self->hadjustment,
@@ -216,7 +188,6 @@ gxk_scroll_canvas_set_hadjustment (GxkScrollCanvas *self,
"swapped_signal::value-changed", scroll_canvas_adjustment_value_changed, self,
NULL);
}
-
void
gxk_scroll_canvas_set_vadjustment (GxkScrollCanvas *self,
GtkAdjustment *adjustment)
@@ -224,7 +195,6 @@ gxk_scroll_canvas_set_vadjustment (GxkScrollCanvas *self,
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
if (self->vadjustment)
{
g_object_disconnect (self->vadjustment,
@@ -234,10 +204,8 @@ gxk_scroll_canvas_set_vadjustment (GxkScrollCanvas *self,
g_object_unref (self->vadjustment);
self->vadjustment = NULL;
}
-
if (!adjustment)
adjustment = (GtkAdjustment*) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);
-
self->vadjustment = (GtkAdjustment*) g_object_ref (adjustment);
gtk_object_sink (GTK_OBJECT (adjustment));
g_object_connect (self->vadjustment,
@@ -245,7 +213,6 @@ gxk_scroll_canvas_set_vadjustment (GxkScrollCanvas *self,
"swapped_signal::value-changed", scroll_canvas_adjustment_value_changed, self,
NULL);
}
-
static void
scroll_canvas_set_scroll_adjustments (GxkScrollCanvas *self,
GtkAdjustment *hadjustment,
@@ -256,7 +223,6 @@ scroll_canvas_set_scroll_adjustments (GxkScrollCanvas *self,
if (self->vadjustment != vadjustment)
gxk_scroll_canvas_set_vadjustment (self, vadjustment);
}
-
void
gxk_scroll_canvas_reset_pango_layouts (GxkScrollCanvas *self)
{
@@ -274,7 +240,6 @@ gxk_scroll_canvas_reset_pango_layouts (GxkScrollCanvas *self)
/* force get_layout() size request to recreate required pango_layouts */
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
scroll_canvas_reset_skin_and_style (GxkScrollCanvas *self,
gboolean relayout)
@@ -324,7 +289,6 @@ scroll_canvas_reset_skin_and_style (GxkScrollCanvas *self,
}
}
}
-
static void
scroll_canvas_style_set (GtkWidget *widget,
GtkStyle *previous_style)
@@ -333,7 +297,6 @@ scroll_canvas_style_set (GtkWidget *widget,
scroll_canvas_reset_skin_and_style (self, TRUE);
GTK_WIDGET_CLASS (gxk_scroll_canvas_parent_class)->style_set (widget, previous_style);
}
-
static void
scroll_canvas_state_changed (GtkWidget *widget,
GtkStateType previous_state)
@@ -342,7 +305,6 @@ scroll_canvas_state_changed (GtkWidget *widget,
scroll_canvas_reset_skin_and_style (self, TRUE);
GTK_WIDGET_CLASS (gxk_scroll_canvas_parent_class)->state_changed (widget, previous_state);
}
-
static void
scroll_canvas_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction)
@@ -351,7 +313,6 @@ scroll_canvas_direction_changed (GtkWidget *widget,
scroll_canvas_reset_skin_and_style (self, TRUE);
GTK_WIDGET_CLASS (gxk_scroll_canvas_parent_class)->direction_changed (widget, previous_direction);
}
-
void
gxk_scroll_canvas_get_layout (GxkScrollCanvas *self,
GxkScrollCanvasLayout *layout)
@@ -382,14 +343,12 @@ gxk_scroll_canvas_get_layout (GxkScrollCanvas *self,
}
*layout = tlayout;
}
-
static void
child_request_size (GtkWidget *child,
gpointer data)
{
gtk_widget_size_request (child, NULL);
}
-
static void
scroll_canvas_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -400,7 +359,6 @@ scroll_canvas_size_request (GtkWidget *widget,
requisition->width = 2 * BORDER_WIDTH (self) + WINDOW_WIDTH (self, LAYOUT (self)->canvas_width);
requisition->height = 2 * BORDER_WIDTH (self) + WINDOW_HEIGHT (self, LAYOUT (self)->canvas_height);
}
-
static void
scroll_canvas_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -418,7 +376,6 @@ scroll_canvas_size_allocate (GtkWidget *widget,
WINDOW_HEIGHT (self, LAYOUT (self)->max_canvas_height));
gxk_scroll_canvas_reallocate (self);
}
-
void
gxk_scroll_canvas_get_canvas_size (GxkScrollCanvas *self,
gint *width,
@@ -442,14 +399,12 @@ gxk_scroll_canvas_get_canvas_size (GxkScrollCanvas *self,
*height = self->layout.canvas_height;
}
}
-
void
gxk_scroll_canvas_reallocate (GxkScrollCanvas *self)
{
GxkScrollCanvasClass *klass;
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
-
/* one reason we could be called is simply that self->layout has changed */
gxk_scroll_canvas_get_layout (self, &self->layout);
if (GTK_WIDGET_REALIZED (self))
@@ -484,7 +439,6 @@ gxk_scroll_canvas_reallocate (GxkScrollCanvas *self)
klass->reallocate_contents (self, 0, 0);
gxk_scroll_canvas_update_adjustments (self, TRUE, TRUE);
}
-
static void
scroll_canvas_realize_marker (GxkScrollCanvas *self,
GxkScrollMarker *marker)
@@ -498,7 +452,6 @@ scroll_canvas_realize_marker (GxkScrollCanvas *self,
gdk_window_invalidate_rect (*marker->windowp, &marker->extends, TRUE);
}
}
-
static void
scroll_canvas_realize (GtkWidget *widget)
{
@@ -512,15 +465,12 @@ scroll_canvas_realize (GtkWidget *widget)
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
panel_events &= ~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
-
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
/* widget->window */
attributes.x = widget->allocation.x + BORDER_WIDTH (self);
attributes.y = widget->allocation.y + BORDER_WIDTH (self);
@@ -530,7 +480,6 @@ scroll_canvas_realize (GtkWidget *widget)
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, self);
gxk_window_set_cursor_type (widget->window, (GdkCursorType) g_object_get_long (self, "window_cursor"));
-
/* self->top_panel */
if (LAYOUT (self)->top_panel_height)
{
@@ -544,7 +493,6 @@ scroll_canvas_realize (GtkWidget *widget)
gxk_window_set_cursor_type (self->top_panel, (GdkCursorType) g_object_get_long (self, "top_panel_cursor"));
gdk_window_show (self->top_panel);
}
-
/* self->left_panel */
if (LAYOUT (self)->left_panel_width)
{
@@ -558,7 +506,6 @@ scroll_canvas_realize (GtkWidget *widget)
gxk_window_set_cursor_type (self->left_panel, (GdkCursorType) g_object_get_long (self, "left_panel_cursor"));
gdk_window_show (self->left_panel);
}
-
/* self->right_panel */
if (LAYOUT (self)->right_panel_width)
{
@@ -572,7 +519,6 @@ scroll_canvas_realize (GtkWidget *widget)
gxk_window_set_cursor_type (self->right_panel, (GdkCursorType) g_object_get_long (self, "right_panel_cursor"));
gdk_window_show (self->right_panel);
}
-
/* self->bottom_panel */
if (LAYOUT (self)->bottom_panel_height)
{
@@ -586,7 +532,6 @@ scroll_canvas_realize (GtkWidget *widget)
gxk_window_set_cursor_type (self->bottom_panel, (GdkCursorType) g_object_get_long (self, "bottom_panel_cursor"));
gdk_window_show (self->bottom_panel);
}
-
/* self->canvas */
attributes.x = CANVAS_X (self);
attributes.y = CANVAS_Y (self);
@@ -597,27 +542,21 @@ scroll_canvas_realize (GtkWidget *widget)
gdk_window_set_user_data (self->canvas, self);
gxk_window_set_cursor_type (self->canvas, (GdkCursorType) g_object_get_long (self, "canvas_cursor"));
gdk_window_show (self->canvas);
-
/* setup style, allocate colors */
widget->style = gtk_style_attach (widget->style, widget->window);
self->color_gc = g_new0 (GdkGC*, klass->n_colors);
for (i = 0; i < klass->n_colors; i++)
self->color_gc[i] = gdk_gc_new (widget->window);
-
/* catch skin changes */
klass->realized_widgets = g_slist_prepend (klass->realized_widgets, self);
-
/* setup backgrounds, colors and pango layouts */
scroll_canvas_reset_skin_and_style (self, FALSE);
-
/* realize markers */
for (i = 0; i < self->n_markers; i++)
scroll_canvas_realize_marker (self, self->markers + i);
-
/* update sizes */
gxk_scroll_canvas_reallocate (self);
}
-
static void
scroll_canvas_unrealize_marker (GxkScrollCanvas *self,
GxkScrollMarker *marker,
@@ -633,23 +572,19 @@ scroll_canvas_unrealize_marker (GxkScrollCanvas *self,
marker->pixmap = NULL;
}
}
-
static void
scroll_canvas_unrealize (GtkWidget *widget)
{
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (widget);
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
guint i;
-
/* ignore skin changes */
klass->realized_widgets = g_slist_remove (klass->realized_widgets, self);
-
/* release color GCs */
for (i = 0; i < klass->n_colors; i++)
g_object_unref (self->color_gc[i]);
g_free (self->color_gc);
self->color_gc = NULL;
-
/* release pango layouts */
for (i = 0; i < self->n_pango_layouts; i++)
if (self->pango_layouts[i])
@@ -657,11 +592,9 @@ scroll_canvas_unrealize (GtkWidget *widget)
g_object_unref (self->pango_layouts[i]);
self->pango_layouts[i] = NULL;
}
-
/* unrealize markers */
for (i = 0; i < self->n_markers; i++)
scroll_canvas_unrealize_marker (self, self->markers + i, FALSE);
-
/* destroy windows */
gdk_window_set_user_data (self->canvas, NULL);
gdk_window_destroy (self->canvas);
@@ -695,13 +628,10 @@ scroll_canvas_unrealize (GtkWidget *widget)
gxk_image_cache_unuse_pixmap (self->canvas_pixmap);
self->canvas_pixmap = NULL;
}
-
/* unset parent windows of children */
gtk_container_forall (GTK_CONTAINER (self), (GtkCallback) gtk_widget_set_parent_window, NULL);
-
GTK_WIDGET_CLASS (gxk_scroll_canvas_parent_class)->unrealize (widget);
}
-
static void
scroll_canvas_draw_window (GxkScrollCanvas *self,
GdkWindow *drawable,
@@ -710,7 +640,6 @@ scroll_canvas_draw_window (GxkScrollCanvas *self,
GtkWidget *widget = GTK_WIDGET (self);
// GdkGC *fg_gc = STYLE (self)->fg_gc[STATE (self)];
gint x, y, width, height, xb, yb;
-
/* frame: upper-left */
x = 0, y = 0, xb = CANVAS_X (self), yb = CANVAS_Y (self);
gtk_paint_shadow (widget->style, drawable, GtkStateType (widget->state), GTK_SHADOW_ETCHED_IN,
@@ -759,14 +688,12 @@ scroll_canvas_draw_window (GxkScrollCanvas *self,
GTK_SHADOW_OUT, NULL, NULL, NULL,
x, y, xb - x, yb - y);
}
-
static void
scroll_canvas_draw_canvas (GxkScrollCanvas *self,
GdkWindow *drawable,
GdkRectangle *area)
{
GdkGC *bg_gc = STYLE (self)->bg_gc[STATE (self)];
-
if (self->canvas_pixmap)
{
gint x, y, pwidth, pheight;
@@ -789,7 +716,6 @@ scroll_canvas_draw_canvas (GxkScrollCanvas *self,
gdk_gc_set_clip_rectangle (bg_gc, NULL);
}
}
-
static void
scroll_canvas_draw_panel (GxkScrollCanvas *self,
GdkWindow *drawable,
@@ -800,10 +726,8 @@ scroll_canvas_draw_panel (GxkScrollCanvas *self,
GdkGC *bg_gc = STYLE (self)->bg_gc[STATE (self)];
gint width, height;
gdk_drawable_get_size (drawable, &width, &height);
-
/* clear background */
gdk_draw_rectangle (drawable, bg_gc, TRUE, 0, 0, width, height);
-
/* debugging stuff */
if (1)
{
@@ -811,7 +735,6 @@ scroll_canvas_draw_panel (GxkScrollCanvas *self,
gdk_draw_line (drawable, fg_gc, width-1, 0, 0, height-1);
}
}
-
static void
scroll_canvas_redraw_markers (GxkScrollCanvas *self,
GdkWindow *drawable,
@@ -834,7 +757,6 @@ scroll_canvas_redraw_markers (GxkScrollCanvas *self,
}
}
}
-
static void
scroll_canvas_update_markers (GxkScrollCanvas *self,
GdkWindow *drawable,
@@ -861,7 +783,6 @@ scroll_canvas_update_markers (GxkScrollCanvas *self,
}
scroll_canvas_redraw_markers (self, drawable, area);
}
-
static gboolean
scroll_canvas_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -870,10 +791,8 @@ scroll_canvas_expose (GtkWidget *widget,
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
GdkRectangle *areas;
gint j, n_areas;
-
if (!GTK_WIDGET_DRAWABLE (widget))
return FALSE;
-
if (event->region)
gdk_region_get_rectangles (event->region, &areas, &n_areas);
else
@@ -881,7 +800,6 @@ scroll_canvas_expose (GtkWidget *widget,
n_areas = 1;
areas = (GdkRectangle*) g_memdup (&event->area, sizeof (event->area));
}
-
/* with gtk_widget_set_double_buffered (self, FALSE) in init and
* with gdk_window_begin_paint_region()/gdk_window_end_paint()
* around our redraw functions, we can decide on our own what
@@ -974,7 +892,6 @@ scroll_canvas_expose (GtkWidget *widget,
g_free (areas);
return FALSE;
}
-
static void
scroll_canvas_draw_focus (GxkScrollCanvas *self)
{
@@ -1008,7 +925,6 @@ scroll_canvas_draw_focus (GxkScrollCanvas *self)
}
}
}
-
static gboolean
scroll_canvas_focus_in (GtkWidget *widget,
GdkEventFocus *event)
@@ -1018,7 +934,6 @@ scroll_canvas_focus_in (GtkWidget *widget,
scroll_canvas_draw_focus (self);
return TRUE;
}
-
static gboolean
scroll_canvas_focus_out (GtkWidget *widget,
GdkEventFocus *event)
@@ -1028,7 +943,6 @@ scroll_canvas_focus_out (GtkWidget *widget,
scroll_canvas_draw_focus (self);
return TRUE;
}
-
void
gxk_scroll_canvas_set_window_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1044,7 +958,6 @@ gxk_scroll_canvas_set_window_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (widget->window, cursor);
}
}
-
void
gxk_scroll_canvas_set_canvas_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1059,7 +972,6 @@ gxk_scroll_canvas_set_canvas_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (self->canvas, cursor);
}
}
-
void
gxk_scroll_canvas_set_top_panel_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1074,7 +986,6 @@ gxk_scroll_canvas_set_top_panel_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (self->top_panel, cursor);
}
}
-
void
gxk_scroll_canvas_set_left_panel_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1089,7 +1000,6 @@ gxk_scroll_canvas_set_left_panel_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (self->left_panel, cursor);
}
}
-
void
gxk_scroll_canvas_set_right_panel_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1104,7 +1014,6 @@ gxk_scroll_canvas_set_right_panel_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (self->right_panel, cursor);
}
}
-
void
gxk_scroll_canvas_set_bottom_panel_cursor (GxkScrollCanvas *self,
GdkCursorType cursor)
@@ -1119,14 +1028,12 @@ gxk_scroll_canvas_set_bottom_panel_cursor (GxkScrollCanvas *self,
gxk_window_set_cursor_type (self->bottom_panel, cursor);
}
}
-
PangoLayout*
gxk_scroll_canvas_get_pango_layout (GxkScrollCanvas *self,
guint nth)
{
guint i;
g_return_val_if_fail (GXK_IS_SCROLL_CANVAS (self), NULL);
-
if (nth >= self->n_pango_layouts)
{
i = self->n_pango_layouts;
@@ -1142,7 +1049,6 @@ gxk_scroll_canvas_get_pango_layout (GxkScrollCanvas *self,
}
return self->pango_layouts[nth];
}
-
PangoLayout*
gxk_scroll_canvas_peek_pango_layout (GxkScrollCanvas *self,
guint nth)
@@ -1150,14 +1056,12 @@ gxk_scroll_canvas_peek_pango_layout (GxkScrollCanvas *self,
g_return_val_if_fail (GXK_IS_SCROLL_CANVAS (self), NULL);
return nth < self->n_pango_layouts ? self->pango_layouts[nth] : NULL;
}
-
static void
scroll_canvas_adjustment_changed (GxkScrollCanvas *self,
GtkAdjustment *adjustment)
{
gtk_widget_queue_draw (GTK_WIDGET (self));
}
-
static void
scroll_canvas_adjustment_value_changed (GxkScrollCanvas *self,
GtkAdjustment *adjustment)
@@ -1207,7 +1111,6 @@ scroll_canvas_adjustment_value_changed (GxkScrollCanvas *self,
klass->reallocate_contents (self, xdiff, ydiff);
}
}
-
void
gxk_scroll_canvas_update_adjustments (GxkScrollCanvas *self,
gboolean hadj,
@@ -1236,7 +1139,6 @@ gxk_scroll_canvas_update_adjustments (GxkScrollCanvas *self,
}
GXK_SCROLL_CANVAS_GET_CLASS (self)->update_adjustments (self, hadj, vadj);
}
-
static void
scroll_canvas_update_adjustments (GxkScrollCanvas *self,
gboolean hadj,
@@ -1245,7 +1147,6 @@ scroll_canvas_update_adjustments (GxkScrollCanvas *self,
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
gdouble hv = self->hadjustment->value;
gdouble vv = self->vadjustment->value;
-
if (hadj && klass->hscrollable)
{
self->hadjustment->lower = MAX (self->hadjustment->lower, 0);
@@ -1289,7 +1190,6 @@ scroll_canvas_update_adjustments (GxkScrollCanvas *self,
if (vv != self->vadjustment->value && klass->vscrollable)
gtk_adjustment_value_changed (self->vadjustment);
}
-
static void
scroll_canvas_change_adjustments (GxkScrollCanvas *self,
gint xval,
@@ -1298,7 +1198,6 @@ scroll_canvas_change_adjustments (GxkScrollCanvas *self,
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
gdouble hv = self->hadjustment->value;
gdouble vv = self->vadjustment->value;
-
if (klass->hscrollable)
{
self->hadjustment->value = xval;
@@ -1320,29 +1219,24 @@ scroll_canvas_change_adjustments (GxkScrollCanvas *self,
if (klass->vscrollable && vv != self->vadjustment->value)
gtk_adjustment_value_changed (self->vadjustment);
}
-
static void
scroll_canvas_scroll_adjustments (GxkScrollCanvas *self,
gint x_pixel,
gint y_pixel)
{
gint xdiff, ydiff;
-
xdiff = x_pixel * AUTO_SCROLL_SCALE;
if (x_pixel > 0)
xdiff = MAX (xdiff, 1);
else if (x_pixel < 0)
xdiff = MIN (-1, xdiff);
-
ydiff = y_pixel * AUTO_SCROLL_SCALE;
if (y_pixel > 0)
ydiff = MAX (ydiff, 1);
else if (y_pixel < 0)
ydiff = MIN (-1, ydiff);
-
scroll_canvas_change_adjustments (self, self->hadjustment->value + xdiff, self->vadjustment->value + ydiff);
}
-
gboolean
gxk_scroll_canvas_dragging (GxkScrollCanvas *self)
{
@@ -1350,7 +1244,6 @@ gxk_scroll_canvas_dragging (GxkScrollCanvas *self)
GxkScrollCanvasDrag *drag = DRAG (self);
return drag != NULL;
}
-
void
gxk_scroll_canvas_drag_abort (GxkScrollCanvas *self)
{
@@ -1364,7 +1257,6 @@ gxk_scroll_canvas_drag_abort (GxkScrollCanvas *self)
GXK_SCROLL_CANVAS_GET_CLASS (self)->handle_drag (self, &dcopy, NULL);
}
}
-
static gboolean
scroll_canvas_drag (GxkScrollCanvas *self,
gint coord_x,
@@ -1400,7 +1292,6 @@ scroll_canvas_drag (GxkScrollCanvas *self,
}
return FALSE;
}
-
static gboolean
scroll_canvas_button_press (GtkWidget *widget,
GdkEventButton *event)
@@ -1408,14 +1299,11 @@ scroll_canvas_button_press (GtkWidget *widget,
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (widget);
GxkScrollCanvasDrag *drag = DRAG (self);
gboolean handled = FALSE;
-
if (drag)
return TRUE;
-
if (GTK_WIDGET_CAN_FOCUS (self) && !GTK_WIDGET_HAS_FOCUS (self) &&
GXK_SCROLL_CANVAS_GET_CLASS (self)->grab_focus)
gtk_widget_grab_focus (widget);
-
/* start new drag */
drag = g_new0 (GxkScrollCanvasDrag, 1);
drag->widget = widget;
@@ -1430,7 +1318,6 @@ scroll_canvas_button_press (GtkWidget *widget,
drag->left_panel_drag = drag->drawable == self->left_panel;
drag->right_panel_drag = drag->drawable == self->right_panel;
drag->bottom_panel_drag = drag->drawable == self->bottom_panel;
-
/* check drag validity */
if (drag->window_drag || drag->canvas_drag ||
drag->top_panel_drag || drag->left_panel_drag ||
@@ -1442,17 +1329,14 @@ scroll_canvas_button_press (GtkWidget *widget,
}
else /* very unlikely */
g_free (drag);
-
return handled;
}
-
static gboolean
scroll_canvas_auto_scroller (gpointer data)
{
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (data);
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
guint remain = 1;
-
GDK_THREADS_ENTER ();
GxkScrollCanvasDrag *drag = DRAG (self);
if (drag && GTK_WIDGET_DRAWABLE (self))
@@ -1463,7 +1347,6 @@ scroll_canvas_auto_scroller (gpointer data)
GdkModifierType modifiers;
gdk_window_get_size (drag->drawable, &width, &height);
gdk_window_get_pointer (drag->drawable, &x, &y, &modifiers);
-
if (hdrag && x < 0)
xdiff = x;
else if (hdrag && x >= width)
@@ -1472,7 +1355,6 @@ scroll_canvas_auto_scroller (gpointer data)
ydiff = y;
else if (vdrag && y >= height)
ydiff = y - height + 1;
-
if (xdiff || ydiff)
{
scroll_canvas_scroll_adjustments (self, xdiff, ydiff);
@@ -1486,10 +1368,8 @@ scroll_canvas_auto_scroller (gpointer data)
else
self->scroll_timer = remain = 0;
GDK_THREADS_LEAVE ();
-
return remain;
}
-
static gboolean
scroll_canvas_motion (GtkWidget *widget,
GdkEventMotion *event)
@@ -1497,7 +1377,6 @@ scroll_canvas_motion (GtkWidget *widget,
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (widget);
GxkScrollCanvasDrag *drag = DRAG (self);
gboolean handled = FALSE;
-
/* process drag event */
if (drag)
{
@@ -1507,7 +1386,6 @@ scroll_canvas_motion (GtkWidget *widget,
scroll_canvas_drag (self, event->x, event->y, (GdkEvent*) event);
drag = DRAG (self);
}
-
/* start up auto-scroll timer */
if (drag && !drag->current_confined && !self->scroll_timer)
{
@@ -1518,10 +1396,8 @@ scroll_canvas_motion (GtkWidget *widget,
/* trigger motion events (since we use motion-hint) */
gdk_window_get_pointer (drag->drawable, NULL, NULL, NULL);
}
-
return handled;
}
-
static gboolean
scroll_canvas_button_release (GtkWidget *widget,
GdkEventButton *event)
@@ -1529,7 +1405,6 @@ scroll_canvas_button_release (GtkWidget *widget,
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (widget);
GxkScrollCanvasDrag *drag = DRAG (self);
gboolean handled = FALSE;
-
if (drag && event->button == drag->button)
{
handled = TRUE;
@@ -1541,10 +1416,8 @@ scroll_canvas_button_release (GtkWidget *widget,
}
else if (drag)
handled = TRUE;
-
return handled;
}
-
static gboolean
scroll_canvas_key_press (GtkWidget *widget,
GdkEventKey *event)
@@ -1552,7 +1425,6 @@ scroll_canvas_key_press (GtkWidget *widget,
GxkScrollCanvas *self = GXK_SCROLL_CANVAS (widget);
GxkScrollCanvasDrag *drag = DRAG (self);
gboolean handled = FALSE;
-
if (drag && event->keyval == GDK_Escape)
{
gxk_scroll_canvas_drag_abort (self);
@@ -1560,14 +1432,12 @@ scroll_canvas_key_press (GtkWidget *widget,
}
return handled;
}
-
void
gxk_scroll_canvas_scroll_to (GxkScrollCanvas *self,
gint scroll_area_x,
gint scroll_area_y)
{
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
-
if (GTK_WIDGET_REALIZED (self))
{
GxkScrollCanvasClass *klass = GXK_SCROLL_CANVAS_GET_CLASS (self);
@@ -1590,7 +1460,6 @@ gxk_scroll_canvas_scroll_to (GxkScrollCanvas *self,
}
}
}
-
void
gxk_scroll_canvas_make_visible (GxkScrollCanvas *self,
gint scroll_area_x,
@@ -1619,7 +1488,6 @@ gxk_scroll_canvas_make_visible (GxkScrollCanvas *self,
gxk_scroll_canvas_scroll_to (self, ihv, ivv);
}
}
-
GxkScrollMarker*
gxk_scroll_canvas_lookup_marker (GxkScrollCanvas *self,
guint index,
@@ -1627,7 +1495,6 @@ gxk_scroll_canvas_lookup_marker (GxkScrollCanvas *self,
{
guint i;
g_return_val_if_fail (GXK_IS_SCROLL_CANVAS (self), NULL);
-
if (countp)
*countp = 0;
for (i = 0; i < self->n_markers; i++)
@@ -1644,7 +1511,6 @@ gxk_scroll_canvas_lookup_marker (GxkScrollCanvas *self,
}
return NULL;
}
-
GxkScrollMarker*
gxk_scroll_canvas_add_marker (GxkScrollCanvas *self,
guint index)
@@ -1653,7 +1519,6 @@ gxk_scroll_canvas_add_marker (GxkScrollCanvas *self,
guint i;
g_return_val_if_fail (GXK_IS_SCROLL_CANVAS (self), NULL);
g_return_val_if_fail (index > 0, NULL);
-
for (i = 0; i < self->n_markers; i++)
if (index < self->markers[i].index)
break;
@@ -1665,7 +1530,6 @@ gxk_scroll_canvas_add_marker (GxkScrollCanvas *self,
marker->index = index;
return marker;
}
-
void
gxk_scroll_canvas_remove_marker (GxkScrollCanvas *self,
GxkScrollMarker *marker)
@@ -1673,13 +1537,11 @@ gxk_scroll_canvas_remove_marker (GxkScrollCanvas *self,
guint i;
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
g_return_if_fail (marker != NULL);
-
i = marker - self->markers;
gxk_scroll_canvas_setup_marker (self, marker, NULL, 0, 0, 0, 0);
self->n_markers -= 1;
g_memmove (self->markers + i, self->markers + i + 1, sizeof (marker[0]) * (self->n_markers - i));
}
-
void
gxk_scroll_canvas_setup_marker (GxkScrollCanvas *self,
GxkScrollMarker *marker,
@@ -1697,7 +1559,6 @@ gxk_scroll_canvas_setup_marker (GxkScrollCanvas *self,
g_return_if_fail (windowp == &widget->window || windowp == &self->canvas ||
windowp == &self->top_panel || windowp == &self->left_panel ||
windowp == &self->right_panel || windowp == &self->bottom_panel);
-
scroll_canvas_unrealize_marker (self, marker, TRUE);
marker->windowp = windowp;
marker->extends.x = -width;
@@ -1707,7 +1568,6 @@ gxk_scroll_canvas_setup_marker (GxkScrollCanvas *self,
scroll_canvas_realize_marker (self, marker);
gxk_scroll_canvas_move_marker (self, marker, x, y);
}
-
void
gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
GxkScrollMarker *marker,
@@ -1716,7 +1576,6 @@ gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
{
g_return_if_fail (GXK_IS_SCROLL_CANVAS (self));
g_return_if_fail (marker != NULL);
-
uint ox = marker->extends.x;
uint oy = marker->extends.y;
if (x == ox && y == oy)
@@ -1727,7 +1586,6 @@ gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
marker->extends.y = y;
return;
}
-
/* restore backing under marker */
GdkGC *draw_gc = STYLE (self)->bg_gc[STATE (self)];
gdk_window_begin_paint_rect (*marker->windowp, &marker->extends);
@@ -1749,11 +1607,9 @@ gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
klass->draw_marker (self, *marker2->windowp, &isec, marker2);
}
}
-
/* move */
marker->extends.x = x;
marker->extends.y = y;
-
/* save new backing */
gdk_draw_drawable (marker->pixmap, draw_gc, *marker->windowp,
marker->extends.x, marker->extends.y, 0, 0,
@@ -1772,7 +1628,6 @@ gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
isec.width, isec.height);
}
}
-
/* redraw old and new marker area */
gdk_window_begin_paint_rect (*marker->windowp, &marker->extends);
gdk_draw_drawable (*marker->windowp, draw_gc, marker->pixmap,
@@ -1791,17 +1646,14 @@ gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
klass->draw_marker (self, *marker2->windowp, &isec, marker2);
}
}
-
/* update onscreen */
gdk_window_end_paint (*marker->windowp);
gdk_window_end_paint (*marker->windowp);
}
-
static void
dummy_handler (void)
{
}
-
static void
gxk_scroll_canvas_class_init (GxkScrollCanvasClass *klass)
{
@@ -1809,11 +1661,8 @@ gxk_scroll_canvas_class_init (GxkScrollCanvasClass *klass)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
// GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
gobject_class->finalize = scroll_canvas_finalize;
-
object_class->destroy = scroll_canvas_destroy;
-
widget_class->size_request = scroll_canvas_size_request;
widget_class->size_allocate = scroll_canvas_size_allocate;
widget_class->realize = scroll_canvas_realize;
@@ -1828,7 +1677,6 @@ gxk_scroll_canvas_class_init (GxkScrollCanvasClass *klass)
widget_class->key_press_event = scroll_canvas_key_press;
widget_class->focus_in_event = scroll_canvas_focus_in;
widget_class->focus_out_event = scroll_canvas_focus_out;
-
/* widget config */
klass->double_buffer_top_panel = TRUE;
klass->double_buffer_left_panel = TRUE;
@@ -1858,7 +1706,6 @@ gxk_scroll_canvas_class_init (GxkScrollCanvasClass *klass)
klass->draw_right_panel = scroll_canvas_draw_panel;
klass->draw_bottom_panel = scroll_canvas_draw_panel;
klass->handle_drag = (void (*) (GxkScrollCanvas*, GxkScrollCanvasDrag*, GdkEvent*)) dummy_handler;
-
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
@@ -1867,7 +1714,6 @@ gxk_scroll_canvas_class_init (GxkScrollCanvasClass *klass)
gxk_marshal_NONE__OBJECT_OBJECT,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
}
-
void
gxk_scroll_canvas_class_skin_changed (GxkScrollCanvasClass *klass)
{
diff --git a/beast-gtk/gxk/gxkscrollcanvas.hh b/beast-gtk/gxk/gxkscrollcanvas.hh
index 551bf28..7585d71 100644
--- a/beast-gtk/gxk/gxkscrollcanvas.hh
+++ b/beast-gtk/gxk/gxkscrollcanvas.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_SCROLL_CANVAS_H__
#define __GXK_SCROLL_CANVAS_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define GXK_TYPE_SCROLL_CANVAS (gxk_scroll_canvas_get_type ())
#define GXK_SCROLL_CANVAS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_SCROLL_CANVAS, GxkScrollCanvas))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define GXK_IS_SCROLL_CANVAS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_SCROLL_CANVAS))
#define GXK_IS_SCROLL_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_SCROLL_CANVAS))
#define GXK_SCROLL_CANVAS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_SCROLL_CANVAS, GxkScrollCanvasClass))
-
-
/* --- typedefs, enums & structures --- */
typedef enum /*< skip >*/
{
@@ -166,8 +161,6 @@ typedef struct
GxkScrollCanvasDrag *drag,
GdkEvent *event);
} GxkScrollCanvasClass;
-
-
/* --- prototypes --- */
GType gxk_scroll_canvas_get_type (void);
void gxk_scroll_canvas_get_layout (GxkScrollCanvas *self,
@@ -229,7 +222,5 @@ void gxk_scroll_canvas_move_marker (GxkScrollCanvas
guint x,
guint y);
void gxk_scroll_canvas_class_skin_changed (GxkScrollCanvasClass*);
-
G_END_DECLS
-
#endif /* __GXK_SCROLL_CANVAS_H__ */
diff --git a/beast-gtk/gxk/gxksimplelabel.cc b/beast-gtk/gxk/gxksimplelabel.cc
index 37a6437..8611649 100644
--- a/beast-gtk/gxk/gxksimplelabel.cc
+++ b/beast-gtk/gxk/gxksimplelabel.cc
@@ -4,7 +4,6 @@
#include <gdk/gdkkeysyms.h>
#include <pango/pango.h>
#include <libintl.h>
-
enum {
PROP_0,
PROP_LABEL,
@@ -15,7 +14,6 @@ enum {
PROP_MNEMONIC_KEYVAL,
PROP_MNEMONIC_WIDGET
};
-
/* --- prototypes --- */
static void simple_label_class_init (GxkSimpleLabelClass *klass);
static void simple_label_init (GxkSimpleLabel *label);
@@ -49,11 +47,8 @@ static gboolean simple_label_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void simple_label_setup_mnemonic (GxkSimpleLabel *label,
guint last_key);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
GType
gxk_simple_label_get_type (void)
@@ -77,22 +72,17 @@ gxk_simple_label_get_type (void)
}
return label_type;
}
-
static void
simple_label_class_init (GxkSimpleLabelClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = simple_label_set_property;
gobject_class->get_property = simple_label_get_property;
gobject_class->finalize = simple_label_finalize;
-
object_class->destroy = simple_label_destroy;
-
widget_class->size_request = simple_label_size_request;
widget_class->style_set = simple_label_style_set;
widget_class->direction_changed = simple_label_direction_changed;
@@ -100,7 +90,6 @@ simple_label_class_init (GxkSimpleLabelClass *klass)
widget_class->hierarchy_changed = simple_label_hierarchy_changed;
widget_class->screen_changed = simple_label_screen_changed;
widget_class->mnemonic_activate = simple_label_mnemonic_activate;
-
g_object_class_install_property (gobject_class,
PROP_LABEL,
g_param_spec_string ("label", _("Label"), _("The text of the label"),
@@ -137,13 +126,11 @@ simple_label_class_init (GxkSimpleLabelClass *klass)
"key is pressed"),
GTK_TYPE_WIDGET, G_PARAM_READWRITE));
}
-
static void
simple_label_init (GxkSimpleLabel *self)
{
GTK_WIDGET_SET_FLAGS (self, GTK_NO_WINDOW);
gtk_widget_show (GTK_WIDGET (self));
-
self->jtype = GTK_JUSTIFY_LEFT;
self->layout = NULL;
self->text = g_strdup ("");
@@ -155,7 +142,6 @@ simple_label_init (GxkSimpleLabel *self)
self->label = g_strdup ("");
gxk_simple_label_recalculate (self);
}
-
static void
simple_label_set_property (GObject *object,
guint prop_id,
@@ -212,7 +198,6 @@ simple_label_set_property (GObject *object,
break;
}
}
-
static void
simple_label_get_property (GObject *object,
guint prop_id,
@@ -220,9 +205,7 @@ simple_label_get_property (GObject *object,
GParamSpec *pspec)
{
GxkSimpleLabel *label;
-
label = GXK_SIMPLE_LABEL (object);
-
switch (prop_id)
{
case PROP_LABEL:
@@ -248,7 +231,6 @@ simple_label_get_property (GObject *object,
break;
}
}
-
static void
simple_label_destroy (GtkObject *object)
{
@@ -256,7 +238,6 @@ simple_label_destroy (GtkObject *object)
gxk_simple_label_set_mnemonic_widget (self, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
simple_label_finalize (GObject *object)
{
@@ -269,7 +250,6 @@ simple_label_finalize (GObject *object)
g_free (self->text);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gboolean
simple_label_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
@@ -277,7 +257,6 @@ simple_label_mnemonic_activate (GtkWidget *widget,
GtkWidget *parent = widget->parent;
if (GXK_SIMPLE_LABEL (widget)->mnemonic_widget)
return gtk_widget_mnemonic_activate (GXK_SIMPLE_LABEL (widget)->mnemonic_widget, group_cycling);
-
/* Try to find the widget to activate by traversing the
* widget's ancestry.
*/
@@ -299,13 +278,11 @@ simple_label_mnemonic_activate (GtkWidget *widget,
}
parent = parent->parent;
}
-
/* barf if there was nothing to activate */
g_warning ("Couldn't find a target for a mnemonic activation.");
gdk_display_beep (gtk_widget_get_display (widget));
return FALSE;
}
-
static void
simple_label_setup_mnemonic (GxkSimpleLabel *self,
guint last_key)
@@ -329,7 +306,6 @@ simple_label_setup_mnemonic (GxkSimpleLabel *self,
self->mnemonic_window = GTK_WINDOW (toplevel);
}
}
-
static void
simple_label_hierarchy_changed (GtkWidget *widget,
GtkWidget *old_toplevel)
@@ -337,24 +313,20 @@ simple_label_hierarchy_changed (GtkWidget *widget,
GxkSimpleLabel *self = GXK_SIMPLE_LABEL (widget);
simple_label_setup_mnemonic (self, self->mnemonic_keyval);
}
-
static void
simple_label_screen_changed (GtkWidget *widget,
GdkScreen *old_screen)
{
gxk_simple_label_recalculate (GXK_SIMPLE_LABEL (widget));
}
-
static void
label_mnemonic_widget_weak_notify (gpointer data,
GObject *where_the_object_was)
{
GxkSimpleLabel *label = (GxkSimpleLabel*) data;
-
label->mnemonic_widget = NULL;
g_object_notify (G_OBJECT (label), "mnemonic_widget");
}
-
void
gxk_simple_label_set_mnemonic_widget (GxkSimpleLabel *self,
GtkWidget *widget)
@@ -362,7 +334,6 @@ gxk_simple_label_set_mnemonic_widget (GxkSimpleLabel *self,
g_return_if_fail (GXK_IS_SIMPLE_LABEL (self));
if (widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (self->mnemonic_widget)
g_object_weak_unref (G_OBJECT (self->mnemonic_widget),
label_mnemonic_widget_weak_notify,
@@ -374,7 +345,6 @@ gxk_simple_label_set_mnemonic_widget (GxkSimpleLabel *self,
self);
g_object_notify ((GObject*) self, "mnemonic_widget");
}
-
static PangoAttrList*
simple_label_pattern_to_attrs (GxkSimpleLabel *self,
const gchar *pattern)
@@ -383,9 +353,7 @@ simple_label_pattern_to_attrs (GxkSimpleLabel *self,
const char *p = self->text;
const char *q = pattern;
PangoAttrList *attrs;
-
attrs = pango_attr_list_new ();
-
while (1)
{
while (*p && *q && *q != '_')
@@ -399,22 +367,18 @@ simple_label_pattern_to_attrs (GxkSimpleLabel *self,
p = g_utf8_next_char (p);
q++;
}
-
if (p > start)
{
PangoAttribute *attr = pango_attr_underline_new (PANGO_UNDERLINE_LOW);
attr->start_index = start - self->text;
attr->end_index = p - self->text;
-
pango_attr_list_insert (attrs, attr);
}
else
break;
}
-
return attrs;
}
-
static void
simple_label_set_pattern_internal (GxkSimpleLabel *self,
const gchar *pattern)
@@ -424,7 +388,6 @@ simple_label_set_pattern_internal (GxkSimpleLabel *self,
pango_attr_list_unref (self->effective_attrs);
self->effective_attrs = attrs;
}
-
static void
simple_label_set_uline_text_internal (GxkSimpleLabel *self,
const gchar *str)
@@ -436,7 +399,6 @@ simple_label_set_uline_text_internal (GxkSimpleLabel *self,
gchar *pattern_dest = pattern;
const gchar *src = str;
gboolean underscore = FALSE;
-
/* Split text into the base text and a separate pattern
* of underscores.
*/
@@ -482,15 +444,12 @@ simple_label_set_uline_text_internal (GxkSimpleLabel *self,
}
*dest = 0;
*pattern_dest = 0;
-
g_free (self->text);
self->text = new_str;
simple_label_set_pattern_internal (self, pattern);
g_free (pattern);
-
self->mnemonic_keyval = accel_key;
}
-
static void
gxk_simple_label_recalculate (GxkSimpleLabel *self)
{
@@ -517,7 +476,6 @@ gxk_simple_label_recalculate (GxkSimpleLabel *self)
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-
static void
label_ensure_layout (GxkSimpleLabel *self)
{
@@ -545,7 +503,6 @@ label_ensure_layout (GxkSimpleLabel *self)
pango_layout_set_text (self->layout, self->text, -1);
self->needs_cutting = self->auto_cut;
}
-
static inline gint
label_allocation_width (GxkSimpleLabel *self)
{
@@ -553,7 +510,6 @@ label_allocation_width (GxkSimpleLabel *self)
GtkMisc *misc = GTK_MISC (self);
return MAX (widget->allocation.width - 2 * misc->xpad, 1);
}
-
static inline gint
label_allocation_height (GxkSimpleLabel *self)
{
@@ -561,7 +517,6 @@ label_allocation_height (GxkSimpleLabel *self)
GtkMisc *misc = GTK_MISC (self);
return MAX (widget->allocation.height - 2 * misc->ypad, 1);
}
-
static void
label_cut_layout (GxkSimpleLabel *self)
{
@@ -589,14 +544,12 @@ label_cut_layout (GxkSimpleLabel *self)
pango_layout_get_extents (self->layout, NULL, &logical_rect);
}
}
-
static void
simple_label_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GxkSimpleLabel *self = GXK_SIMPLE_LABEL (widget);
PangoRectangle logical_rect;
-
if (self->layout)
{
g_object_unref (self->layout);
@@ -607,7 +560,6 @@ simple_label_size_request (GtkWidget *widget,
requisition->width = PANGO_PIXELS (logical_rect.width) + 2 * GTK_MISC (self)->xpad;
requisition->height = PANGO_PIXELS (logical_rect.height) + 2 * GTK_MISC (self)->ypad;
}
-
static void
simple_label_style_set (GtkWidget *widget,
GtkStyle *previous_style)
@@ -615,7 +567,6 @@ simple_label_style_set (GtkWidget *widget,
GxkSimpleLabel *self = GXK_SIMPLE_LABEL (widget);
gxk_simple_label_recalculate (self);
}
-
static void
simple_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
@@ -625,7 +576,6 @@ simple_label_direction_changed (GtkWidget *widget,
pango_layout_context_changed (self->layout);
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
-
static void
get_layout_location (GxkSimpleLabel *self,
gint *xp,
@@ -640,19 +590,16 @@ get_layout_location (GxkSimpleLabel *self,
pango_layout_get_extents (self->layout, NULL, &logical_rect);
gint rwidth = MIN (widget->requisition.width, PANGO_PIXELS (logical_rect.width));
gint rheight = MIN (widget->requisition.height, PANGO_PIXELS (logical_rect.height));
-
x = widget->allocation.x + xpad + GTK_MISC (self)->xalign * MAX (label_allocation_width (self) - rwidth, 0);
y = widget->allocation.y + ypad + GTK_MISC (self)->yalign * MAX (label_allocation_height (self) - rheight, 0);
*xp = x;
*yp = y;
}
-
static gint
simple_label_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GxkSimpleLabel *self = GXK_SIMPLE_LABEL (widget);
-
label_ensure_layout (self);
if (self->needs_cutting)
{
diff --git a/beast-gtk/gxk/gxksimplelabel.hh b/beast-gtk/gxk/gxksimplelabel.hh
index 7c5db78..b74e305 100644
--- a/beast-gtk/gxk/gxksimplelabel.hh
+++ b/beast-gtk/gxk/gxksimplelabel.hh
@@ -1,21 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_SIMPLE_LABEL_H__
#define __GXK_SIMPLE_LABEL_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
#define GXK_TYPE_SIMPLE_LABEL (gxk_simple_label_get_type ())
#define GXK_SIMPLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXK_TYPE_SIMPLE_LABEL, GxkSimpleLabel))
#define GXK_SIMPLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXK_TYPE_SIMPLE_LABEL, GxkSimpleLabelClass))
#define GXK_IS_SIMPLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXK_TYPE_SIMPLE_LABEL))
#define GXK_IS_SIMPLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_SIMPLE_LABEL))
#define GXK_SIMPLE_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXK_TYPE_SIMPLE_LABEL, GxkSimpleLabelClass))
-
typedef struct {
GtkMisc parent_instance;
-
gchar *label;
guint8 jtype;
guint use_underline : 1;
@@ -29,11 +24,8 @@ typedef struct {
PangoLayout *layout;
} GxkSimpleLabel;
typedef GtkMiscClass GxkSimpleLabelClass;
-
GType gxk_simple_label_get_type (void) G_GNUC_CONST;
void gxk_simple_label_set_mnemonic_widget (GxkSimpleLabel *self,
GtkWidget *widget);
-
G_END_DECLS
-
#endif /* __GXK_SIMPLE_LABEL_H__ */
diff --git a/beast-gtk/gxk/gxkspline.cc b/beast-gtk/gxk/gxkspline.cc
index 794300d..22bc5be 100644
--- a/beast-gtk/gxk/gxkspline.cc
+++ b/beast-gtk/gxk/gxkspline.cc
@@ -4,11 +4,8 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-
#define SQRT_3 (1.7320508075688772935274463415059)
static const double INF = DBL_MAX;
-
-
/* --- functions --- */
static inline double
segment_eval (const GxkSplineSegment *xseg, /* must not be last segment */
@@ -38,7 +35,6 @@ segment_eval (const GxkSplineSegment *xseg, /* must not be last segment */
next->yd2 * (w * w + 2 * v * (3 * x - v - w) - 3 * x * x) / (6. * (w - v));
return y;
}
-
/**
* @param n_points number of fix points
* @param points fix points
@@ -51,7 +47,6 @@ gxk_spline_new_natural (guint n_points,
{
return gxk_spline_new (n_points, points, NAN, NAN);
}
-
/**
* @param spline correctly setup GxkSpline
* @return newly allocated spline
@@ -62,7 +57,6 @@ gxk_spline_copy (GxkSpline *spline)
{
return (GxkSpline*) g_memdup (spline, sizeof (spline[0]) + spline->n_segs * sizeof (spline->segs[0]));
}
-
static int
spline_segment_cmp (const void *v1,
const void *v2)
@@ -71,7 +65,6 @@ spline_segment_cmp (const void *v1,
const GxkSplineSegment *s2 = (GxkSplineSegment*) v2;
return s1->x < s2->x ? -1 : s1->x > s2->x;
}
-
/**
* @param n_points number of fix points
* @param points fix points
@@ -172,7 +165,6 @@ gxk_spline_new (guint n_points,
spline->segs[i].ymin = spline->segs[i].ymax = spline->segs[i].y;
return spline;
}
-
/**
* @param spline correctly setup GxkSpline
* @param x x position for evaluation
@@ -202,7 +194,6 @@ gxk_spline_eval (const GxkSpline *spline,
double y = segment_eval (spline->segs + first, x, yd1);
return y;
}
-
/**
* @param spline correctly setup GxkSpline
* @param x x position for evaluation
@@ -217,14 +208,12 @@ gxk_spline_y (const GxkSpline *spline,
{
return gxk_spline_eval (spline, x, NULL);
}
-
static double
round_to_double (double vin)
{
volatile double rounded = vin;
return rounded;
}
-
/**
* @param spline correctly setup GxkSpline
* @param y interpolated y value
@@ -371,7 +360,6 @@ gxk_spline_findx (const GxkSpline *spline,
}
return x;
}
-
/**
* @param spline correctly setup GxkSpline
*
@@ -383,7 +371,6 @@ gxk_spline_free (GxkSpline *spline)
g_return_if_fail (spline != NULL);
g_free (spline);
}
-
/**
* @param spline correctly setup GxkSpline
*
diff --git a/beast-gtk/gxk/gxkspline.hh b/beast-gtk/gxk/gxkspline.hh
index 3212838..df63142 100644
--- a/beast-gtk/gxk/gxkspline.hh
+++ b/beast-gtk/gxk/gxkspline.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_SPLINE_H__
#define __GXK_SPLINE_H__
-
#include <gxk/gxkglobals.hh>
-
G_BEGIN_DECLS
-
typedef struct _GxkSpline GxkSpline;
typedef struct {
double x, y;
@@ -35,9 +32,5 @@ double gxk_spline_findx (const GxkSpline *spline,
void gxk_spline_dump (GxkSpline *spline);
GxkSpline* gxk_spline_copy (GxkSpline *spline);
void gxk_spline_free (GxkSpline *spline);
-
-
-
G_END_DECLS
-
#endif /* __GXK_SPLINE_H__ */
diff --git a/beast-gtk/gxk/gxkstatusbar.cc b/beast-gtk/gxk/gxkstatusbar.cc
index 9f27ad1..18a0816 100644
--- a/beast-gtk/gxk/gxkstatusbar.cc
+++ b/beast-gtk/gxk/gxkstatusbar.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkstatusbar.hh"
-
#include <gdk/gdkkeysyms.h>
#include <math.h>
#include <string.h>
#include "gxkdialog.hh"
-
-
#define LONGEST_TIMEOUT (2147483647 /* 2^31-1 */)
#define PERC_CMP(f1, f2) (fabs ((f1) - (f2)) < 1e-7)
-
/* --- prototypes --- */
static GxkStatusBar* status_bar_get_current (void);
static void status_bar_queue_clear (GxkStatusBar *sbar,
@@ -18,20 +14,16 @@ static void status_bar_set (GxkStatusBar *sbar,
gfloat percentage,
const gchar *message,
const gchar *status_msg);
-
-
/* --- variables --- */
static GQuark quark_status_bar = 0;
static GSList *status_window_stack = NULL;
static gboolean error_bell_enabled = TRUE;
-
/* --- functions --- */
void
gxk_status_enable_error_bell (gboolean enable_error_bell)
{
error_bell_enabled = enable_error_bell != FALSE;
}
-
static void
status_bar_remove_timer (GxkStatusBar *sbar)
{
@@ -41,19 +33,16 @@ status_bar_remove_timer (GxkStatusBar *sbar)
sbar->timer_id = 0;
}
}
-
static void
sbar_free (gpointer data)
{
GxkStatusBar *sbar = (GxkStatusBar*) data;
-
status_bar_remove_timer (sbar);
g_object_unref (sbar->pbar);
g_object_unref (sbar->message);
g_object_unref (sbar->status);
g_free (sbar);
}
-
/**
* @return status bar container
*
@@ -65,10 +54,8 @@ gxk_status_bar_create (void)
{
GtkWidget *obox, *hbox;
GxkStatusBar *sbar = g_new0 (GxkStatusBar, 1);
-
if (!quark_status_bar)
quark_status_bar = g_quark_from_static_string ("GxkStatusBar");
-
sbar->sbar = (GtkWidget*) g_object_new (GTK_TYPE_FRAME,
"visible", FALSE,
"shadow", GTK_SHADOW_OUT,
@@ -92,7 +79,6 @@ gxk_status_bar_create (void)
gtk_progress_set_format_string (sbar->prog, "%p %%");
gtk_progress_set_show_text (sbar->prog, TRUE);
gtk_box_pack_start (GTK_BOX (obox), GTK_WIDGET (sbar->pbar), FALSE, TRUE, 0);
-
hbox = (GtkWidget*) g_object_new (GTK_TYPE_HBOX,
"visible", TRUE,
"homogeneous", FALSE,
@@ -111,7 +97,6 @@ gxk_status_bar_create (void)
"xalign", 1.0,
NULL);
gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (sbar->status), FALSE, TRUE, GTK_STYLE_THICKNESS (hbox->style, y));
-
g_object_ref (sbar->pbar);
g_object_ref (sbar->message);
g_object_ref (sbar->status);
@@ -119,35 +104,28 @@ gxk_status_bar_create (void)
sbar->timer_id = 0;
status_bar_queue_clear (sbar, 0);
g_object_set_qdata_full (G_OBJECT (sbar->sbar), quark_status_bar, sbar, sbar_free);
-
return sbar->sbar;
}
-
static gboolean
status_bar_clear_handler (gpointer data)
{
GxkStatusBar *sbar = (GxkStatusBar*) data;
-
GDK_THREADS_ENTER ();
sbar->timer_id = 0;
status_bar_set (sbar, GXK_STATUS_IDLE, NULL, NULL);
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
static void
status_bar_queue_clear (GxkStatusBar *sbar,
guint msecs)
{
status_bar_remove_timer (sbar);
-
if (!msecs)
status_bar_set (sbar, GXK_STATUS_IDLE, NULL, NULL);
else
sbar->timer_id = g_timeout_add (msecs, status_bar_clear_handler, sbar);
}
-
/**
* Clear the current status bar.
*/
@@ -155,11 +133,9 @@ void
gxk_status_clear (void)
{
GxkStatusBar *sbar = status_bar_get_current ();
-
if (sbar)
status_bar_queue_clear (sbar, 0);
}
-
static void
status_bar_set (GxkStatusBar *sbar,
gfloat percentage,
@@ -171,12 +147,10 @@ status_bar_set (GxkStatusBar *sbar,
gfloat fraction = 0;
gboolean activity_pulse = FALSE;
gboolean beep = FALSE; /* flag beeps for errors */
-
if (PERC_CMP (percentage, GXK_STATUS_IDLE_HINT) && !sbar->is_idle)
return; /* don't override existing status */
if (!message) /* clear */
percentage = GXK_STATUS_IDLE;
-
sbar->is_idle = FALSE;
if (PERC_CMP (percentage, GXK_STATUS_IDLE))
{
@@ -243,7 +217,6 @@ status_bar_set (GxkStatusBar *sbar,
#endif
}
}
-
/**
* @param percentage progress percentage
* @param message message to be displayed
@@ -261,11 +234,9 @@ gxk_status_set (gfloat percentage,
const gchar *status_msg)
{
GxkStatusBar *sbar = status_bar_get_current ();
-
if (sbar)
status_bar_set (sbar, percentage, message, status_msg);
}
-
/**
* @param percentage progress percentage
* @param status_msg error status
@@ -281,21 +252,17 @@ gxk_status_printf (gfloat percentage,
...)
{
GxkStatusBar *sbar = status_bar_get_current ();
-
if (sbar)
{
gchar *buffer;
va_list args;
-
va_start (args, message_fmt);
buffer = g_strdup_vprintf (message_fmt, args);
va_end (args);
-
status_bar_set (sbar, percentage, buffer, status_msg);
g_free (buffer);
}
}
-
/**
* @param libc_errno errno value
* @param message_fmt printf style message to be displayed
@@ -309,16 +276,13 @@ gxk_status_errnoprintf (gint libc_errno,
...)
{
GxkStatusBar *sbar = status_bar_get_current ();
-
if (sbar)
{
gchar *buffer;
va_list args;
-
va_start (args, message_fmt);
buffer = g_strdup_vprintf (message_fmt, args);
va_end (args);
-
if (libc_errno)
status_bar_set (sbar, GXK_STATUS_ERROR, buffer, g_strerror (libc_errno));
else
@@ -326,7 +290,6 @@ gxk_status_errnoprintf (gint libc_errno,
g_free (buffer);
}
}
-
/**
* @param widget status bar window
*
@@ -339,11 +302,9 @@ gxk_status_window_push (gpointer widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
widget = gtk_widget_get_toplevel ((GtkWidget*) widget);
g_return_if_fail (GTK_IS_WINDOW (widget) == TRUE);
-
gtk_widget_ref ((GtkWidget*) widget);
status_window_stack = g_slist_prepend (status_window_stack, widget);
}
-
/**
* Pop the most recently pushed window from the status bar
* window stack.
@@ -352,25 +313,20 @@ void
gxk_status_window_pop (void)
{
g_return_if_fail (status_window_stack != NULL);
-
gtk_widget_unref ((GtkWidget*) status_window_stack->data);
status_window_stack = g_slist_remove (status_window_stack, status_window_stack->data);
}
-
static GxkStatusBar*
status_bar_get_current (void)
{
GxkDialog *dialog;
GSList *slist;
-
for (slist = status_window_stack; slist; slist = slist->next)
{
dialog = GXK_DIALOG (slist->data);
-
if (dialog->status_bar && GTK_WIDGET_DRAWABLE (dialog->status_bar))
return (GxkStatusBar*) g_object_get_qdata (G_OBJECT (dialog->status_bar), quark_status_bar);
}
dialog = gxk_dialog_get_status_window ();
-
return dialog ? (GxkStatusBar*) g_object_get_qdata (G_OBJECT (dialog->status_bar), quark_status_bar) : NULL;
}
diff --git a/beast-gtk/gxk/gxkstatusbar.hh b/beast-gtk/gxk/gxkstatusbar.hh
index 2011225..09ef173 100644
--- a/beast-gtk/gxk/gxkstatusbar.hh
+++ b/beast-gtk/gxk/gxkstatusbar.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_STATUS_BAR_H__
#define __GXK_STATUS_BAR_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
/* --- status percentages --- */
#define GXK_STATUS_PROGRESS (+200.0)
#define GXK_STATUS_DONE (+100.0)
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define GXK_STATUS_WAIT (-1.0)
#define GXK_STATUS_ERROR (-2.0)
/* 0..+100 is normal progression percentage */
-
-
/* --- auxillary structure --- */
typedef struct
{
@@ -27,8 +22,6 @@ typedef struct
guint is_idle : 1;
guint timer_id;
} GxkStatusBar;
-
-
/* --- prototypes --- */
GtkWidget* gxk_status_bar_create (void);
void gxk_status_enable_error_bell (gboolean enable_error_bell);
@@ -47,8 +40,5 @@ void gxk_status_window_push (gpointer widget);
void gxk_status_window_pop (void);
void gxk_status_push_progress_window (gpointer widget);
void gxk_status_pop_progress_window (void);
-
-
G_END_DECLS
-
#endif /* __GXK_STATUS_BAR_H__ */
diff --git a/beast-gtk/gxk/gxkstock.cc b/beast-gtk/gxk/gxkstock.cc
index 3daa4c7..31c1a4e 100644
--- a/beast-gtk/gxk/gxkstock.cc
+++ b/beast-gtk/gxk/gxkstock.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gxkstock.hh"
-
#include <string.h>
-
/* --- variables --- */
GtkIconSize gxk_size_button = GtkIconSize (0);
GtkIconSize gxk_size_big_button = GtkIconSize (0);
@@ -13,15 +11,12 @@ GtkIconSize gxk_size_tabulator = GtkIconSize (0);
GtkIconSize gxk_size_info_sign = GtkIconSize (0);
GtkIconSize gxk_size_palette = GtkIconSize (0);
static GtkIconFactory *stock_icon_factory = NULL;
-
-
/* --- functions --- */
void
gxk_init_stock (void)
{
stock_icon_factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (stock_icon_factory);
-
/* setup icon sizes */
gxk_size_button = GTK_ICON_SIZE_BUTTON; /* 20x20 */
gxk_size_big_button = GTK_ICON_SIZE_DND; /* 32x32 */
@@ -40,7 +35,6 @@ gxk_init_stock (void)
gtk_icon_size_register_alias ("info-sign", GXK_ICON_SIZE_INFO_SIGN);
gtk_icon_size_register_alias ("palette", GXK_ICON_SIZE_PALETTE);
}
-
/**
* @param icon_size image size id
* @return image size width
@@ -54,7 +48,6 @@ gxk_size_width (GtkIconSize icon_size)
gtk_icon_size_lookup (icon_size, &width, NULL);
return width;
}
-
/**
* @param icon_size image size id
* @return image size height
@@ -68,7 +61,6 @@ gxk_size_height (GtkIconSize icon_size)
gtk_icon_size_lookup (icon_size, NULL, &height);
return height;
}
-
/**
* @param stock_icon_id stock name
* @param icon_size image size
@@ -86,13 +78,11 @@ gxk_stock_image (const gchar *stock_icon_id,
if (stock_icon_id && gtk_icon_factory_lookup_default (stock_icon_id))
{
GtkWidget *image = gtk_image_new_from_stock (stock_icon_id, icon_size);
-
gtk_widget_show (image);
return image;
}
return NULL;
}
-
/**
* @param stock_id stock name
* @param label button text
@@ -105,18 +95,14 @@ gxk_stock_button (const gchar *stock_id,
const gchar *label)
{
GtkWidget *button, *alignment;
-
g_return_val_if_fail (stock_id != NULL, NULL);
-
button = (GtkWidget*) g_object_new (GTK_TYPE_BUTTON,
"visible", TRUE,
NULL);
alignment = gxk_stock_button_child (stock_id, label);
gtk_container_add (GTK_CONTAINER (button), alignment);
-
return button;
}
-
/**
* @param stock_id stock name
* @param label button text
@@ -133,9 +119,7 @@ gxk_stock_button_child (const gchar *stock_id,
const gchar *label)
{
GtkWidget *alignment, *hbox, *image;
-
g_return_val_if_fail (stock_id != NULL, NULL);
-
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
@@ -149,10 +133,8 @@ gxk_stock_button_child (const gchar *stock_id,
NULL),
FALSE, TRUE, 0);
gtk_widget_show_all (alignment);
-
return alignment;
}
-
/**
* @param icon a validly filled out GxkStockIcon
*
@@ -165,16 +147,13 @@ gxk_stock_register_icon (const GxkStockIcon *icon)
{
GdkPixbuf *pixbuf;
GtkIconSet *iset;
-
g_return_if_fail (icon != NULL);
-
pixbuf = gdk_pixbuf_new_from_inline (-1, icon->inlined_pixbuf, FALSE, NULL);
iset = gtk_icon_set_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
gtk_icon_factory_add (stock_icon_factory, icon->stock_id, iset);
gtk_icon_set_unref (iset);
}
-
/**
* @param n_icons number of icons to register
* @param icons a validly filled out array of GxkStockIcon
@@ -188,14 +167,11 @@ gxk_stock_register_icons (guint n_icons,
if (n_icons)
{
guint i;
-
g_return_if_fail (icons != NULL);
-
for (i = 0; i < n_icons; i++)
gxk_stock_register_icon (icons + i);
}
}
-
/**
* @param item a validly filled out GxkStockItem
*
@@ -210,11 +186,9 @@ void
gxk_stock_register_item (const GxkStockItem *item)
{
GtkStockItem tkitem = { NULL, };
-
g_return_if_fail (item != NULL);
g_return_if_fail (item->stock_id != NULL);
g_return_if_fail (item->label != NULL || item->stock_fallback != NULL);
-
tkitem.stock_id = (gchar*) item->stock_id;
if (item->label)
tkitem.label = (gchar*) item->label;
@@ -224,7 +198,6 @@ gxk_stock_register_item (const GxkStockItem *item)
tkitem.keyval = 0;
tkitem.translation_domain = NULL;
gtk_stock_add (&tkitem, 1);
-
if (item->stock_fallback)
{
GtkIconSet *iset = gtk_icon_factory_lookup_default (item->stock_fallback);
@@ -232,7 +205,6 @@ gxk_stock_register_item (const GxkStockItem *item)
gtk_icon_factory_add (stock_icon_factory, item->stock_id, iset);
}
}
-
/**
* @param n_items number of items to register
* @param items a validly filled out array of GxkStockItem
@@ -246,30 +218,23 @@ gxk_stock_register_items (guint n_items,
if (n_items)
{
guint i;
-
g_return_if_fail (items != NULL);
-
for (i = 0; i < n_items; i++)
gxk_stock_register_item (items + i);
}
}
-
const gchar*
gxk_stock_item (const gchar *stock_id)
{
const gchar *item = NULL;
GtkStockItem tkitem;
-
g_return_val_if_fail (stock_id != NULL, NULL);
-
if (gtk_stock_lookup (stock_id, &tkitem))
item = tkitem.label;
else
item = stock_id;
-
return item;
}
-
/**
* @param stock_id stock name
* @return this @a stock_id's pixbuf (or NULL for invalid stock ids)
@@ -284,14 +249,11 @@ gxk_stock_fallback_pixbuf (const gchar *stock_id)
{
static GData *stock_pixbuf_repo = NULL;
GdkPixbuf *pixbuf;
-
g_return_val_if_fail (stock_id != NULL, NULL);
-
pixbuf = (GdkPixbuf*) g_datalist_get_data (&stock_pixbuf_repo, stock_id);
if (!pixbuf)
{
GtkIconSet *iset = gtk_icon_factory_lookup_default (stock_id);
-
if (iset)
{
static GtkStyle *style = NULL; /* FIXME: GTKFIX: gtk_icon_set_render_icon() shouldn't demand a style */
@@ -304,7 +266,6 @@ gxk_stock_fallback_pixbuf (const gchar *stock_id)
}
return pixbuf;
}
-
static guint8*
gdk_pixbuf_create_bitmap_data (GdkPixbuf *pixbuf,
gint *width_p,
@@ -313,14 +274,11 @@ gdk_pixbuf_create_bitmap_data (GdkPixbuf *pixbuf,
{
guint width, height, rowstride, x, y;
guint8 *data, *buffer;
-
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
-
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
buffer = gdk_pixbuf_get_pixels (pixbuf);
-
data = g_new0 (guint8, (width + 7) / 8 * height);
if (!gdk_pixbuf_get_has_alpha (pixbuf))
memset (data, 0xff, (width + 7) / 8 * height);
@@ -330,7 +288,6 @@ gdk_pixbuf_create_bitmap_data (GdkPixbuf *pixbuf,
{
guint8 *d = data + (width + 7) / 8 * y + x / 8;
guint8 *buf = buffer + y * rowstride + x * 4;
-
if (buf[3] >= alpha_threshold)
*d |= 1 << (x % 8);
}
@@ -340,7 +297,6 @@ gdk_pixbuf_create_bitmap_data (GdkPixbuf *pixbuf,
*height_p = height;
return data;
}
-
/**
* @param stock_id a valid stock icon name
* @return a window showing the stock icon
@@ -357,19 +313,15 @@ gxk_stock_icon_window (const gchar *stock_id)
GdkBitmap *mask;
guint8 *bitmap_data;
gint width = 0, height = 0;
-
g_return_val_if_fail (stock_id != NULL, NULL);
-
pixbuf = gxk_stock_fallback_pixbuf (stock_id);
if (!pixbuf)
{
g_warning ("%s: unregistered stock id: \"%s\"", G_STRLOC, stock_id);
return NULL;
}
-
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (image);
-
drag_window = gtk_widget_new (GTK_TYPE_WINDOW,
"type", GTK_WINDOW_POPUP,
"child", image,
@@ -382,6 +334,5 @@ gxk_stock_icon_window (const gchar *stock_id)
g_free (bitmap_data);
gtk_widget_shape_combine_mask (drag_window, mask, 0, 0);
gdk_pixmap_unref (mask);
-
return drag_window;
}
diff --git a/beast-gtk/gxk/gxkstock.hh b/beast-gtk/gxk/gxkstock.hh
index 1d3083f..8704136 100644
--- a/beast-gtk/gxk/gxkstock.hh
+++ b/beast-gtk/gxk/gxkstock.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_STOCK_H__
#define __GXK_STOCK_H__
-
#include <gxk/gxkutils.hh>
-
G_BEGIN_DECLS
-
/* --- icon sizes --- */
#define GXK_ICON_SIZE_BUTTON (gxk_size_button)
#define GXK_ICON_SIZE_BIG_BUTTON (gxk_size_big_button)
@@ -17,8 +14,6 @@ G_BEGIN_DECLS
#define GXK_ICON_SIZE_PALETTE (gxk_size_palette)
guint gxk_size_width (GtkIconSize icon_size);
guint gxk_size_height (GtkIconSize icon_size);
-
-
/* --- functions --- */
GtkWidget* gxk_stock_image (const gchar *stock_icon_id,
GtkIconSize icon_size);
@@ -29,8 +24,6 @@ GtkWidget* gxk_stock_button_child (const gchar *stock_id,
const gchar* gxk_stock_item (const gchar *stock_id);
GdkPixbuf* gxk_stock_fallback_pixbuf (const gchar *stock_id);
GtkWidget* gxk_stock_icon_window (const gchar *stock_id);
-
-
/* --- registration --- */
typedef struct {
const gchar *stock_id;
@@ -47,8 +40,6 @@ void gxk_stock_register_icons (guint n_icons,
void gxk_stock_register_item (const GxkStockItem *item);
void gxk_stock_register_items (guint n_items,
const GxkStockItem *items);
-
-
/* --- internal --- */
extern GtkIconSize gxk_size_button;
extern GtkIconSize gxk_size_big_button;
@@ -58,8 +49,5 @@ extern GtkIconSize gxk_size_menu;
extern GtkIconSize gxk_size_tabulator;
extern GtkIconSize gxk_size_info_sign;
extern GtkIconSize gxk_size_palette;
-
-
G_END_DECLS
-
#endif /* __GXK_STOCK_H__ */
diff --git a/beast-gtk/gxk/gxktest.cc b/beast-gtk/gxk/gxktest.cc
index d1a558a..55e8e4e 100644
--- a/beast-gtk/gxk/gxktest.cc
+++ b/beast-gtk/gxk/gxktest.cc
@@ -4,12 +4,8 @@
#include "gxkrackeditor.hh"
#include "gxkrackitem.hh"
#include "gxkscrollcanvas.hh"
-
-
/* --- prototype --- */
static void rack_test (void);
-
-
/* --- variables --- */
static guint led_colors[] = {
GXK_LED_OFF,
@@ -25,19 +21,14 @@ static guint led_colors[] = {
GXK_LED_OFF,
GXK_LED_BLUE,
};
-
-
/* --- prototypes --- */
static void scroll_canvas_test (void);
-
-
/* --- functions --- */
static gint
led_timer (gpointer data)
{
GxkLed *led = (GxkLed*) data;
static guint led_cindex = 0;
-
GDK_THREADS_ENTER ();
led_cindex++;
led_cindex %= G_N_ELEMENTS (led_colors);
@@ -45,7 +36,6 @@ led_timer (gpointer data)
GDK_THREADS_LEAVE ();
return TRUE;
}
-
int
main (int argc,
char *argv[])
@@ -53,22 +43,17 @@ main (int argc,
GtkWidget *led, *polygon1, *polygon2, *polygon, *box, *box2;
GxkPolygonArc arcs[64];
guint i;
-
/* GLib's thread and object systems */
g_thread_init (NULL);
g_type_init ();
-
/* initialize Gtk+ and go into threading mode */
gtk_init (&argc, &argv);
g_set_prgname ("GxkTest"); /* overriding Gdk's program name */
GDK_THREADS_ENTER ();
-
/* initialize Gtk+ Extension Kit */
gxk_init ();
-
scroll_canvas_test ();
rack_test ();
-
/* test polygons */
{
GxkPolygonLine lines[] = {
@@ -88,7 +73,6 @@ main (int argc,
GxkPolygonGraph graph = { G_N_ELEMENTS (lines), lines, 0, NULL };
polygon1 = (GtkWidget*) gxk_polygon_new (&graph);
}
-
{
GxkPolygonLine lines[] = {
{ 0.0, 0.9, 0.5, 0.5 }, /* \ */
@@ -111,7 +95,6 @@ main (int argc,
arcs[i++] = (GxkPolygonArc) { 0.5, 0.5, 0.3, 0.3, 0, +360 }; /* O */
arcs[i++] = (GxkPolygonArc) { 0.5, 0.5, 0.1, 0.1, 0, -360 }; /* o */
gxk_polygon_set_arcs (GXK_POLYGON (polygon2), i, arcs);
-
box = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
NULL);
@@ -121,37 +104,26 @@ main (int argc,
"visible", TRUE,
NULL);
gtk_box_pack_start (GTK_BOX (box), box2, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_power);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_stop);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_first);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_previous);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_rewind);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_play);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_pause);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_forward);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_next);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
polygon = (GtkWidget*) gxk_polygon_new (&gxk_polygon_last);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
{
GxkPolygonLine lines[] = {
{ 0.25, 0.25, 0.75, 0.25 }, /* right */
@@ -164,7 +136,6 @@ main (int argc,
}
// gxk_polygon_set_length (GXK_POLYGON (polygon), 21);
gtk_box_pack_start (GTK_BOX (box2), polygon, FALSE, FALSE, 5);
-
led = (GtkWidget*) gxk_led_new (0x13f4e5);
gtk_box_pack_start (GTK_BOX (box), led, TRUE, TRUE, 5);
g_object_new (GTK_TYPE_WINDOW,
@@ -176,13 +147,10 @@ main (int argc,
"sensitive", FALSE,
NULL);
g_timeout_add (400, led_timer, led);
-
/* start main loop */
gtk_main ();
-
return 0;
}
-
static void
toggle_edit_mode (GtkToggleButton *tb,
GxkRackTable *rtable)
@@ -193,13 +161,11 @@ toggle_edit_mode (GtkToggleButton *tb,
else
gxk_rack_table_cover_up (rtable);
}
-
static void G_GNUC_NORETURN
exit_program ()
{
exit (0);
}
-
static void
rack_test (void)
{
@@ -245,9 +211,7 @@ rack_test (void)
/* start main loop */
gtk_main ();
}
-
static GxkScrollCanvasLayout faked_layout = { 10, 10, 10, 10, 32, 320, 20, 200 };
-
static void
toggle_panel_sizes (GtkToggleButton *tb,
GxkScrollCanvas *scc)
@@ -267,14 +231,12 @@ toggle_panel_sizes (GtkToggleButton *tb,
}
gtk_widget_queue_resize ((GtkWidget*) scc);
}
-
static void
faked_scroll_canvas_get_layout (GxkScrollCanvas *self,
GxkScrollCanvasLayout *layout)
{
*layout = faked_layout;
}
-
static void
scroll_canvas_test (void)
{
diff --git a/beast-gtk/gxk/gxktexttools.cc b/beast-gtk/gxk/gxktexttools.cc
index 6c2244a..74049ab 100644
--- a/beast-gtk/gxk/gxktexttools.cc
+++ b/beast-gtk/gxk/gxktexttools.cc
@@ -10,15 +10,11 @@
#include <string.h>
#include <errno.h>
#include <dirent.h>
-
-
#define GXK_IS_SCROLL_TEXT GTK_IS_VBOX
-
typedef struct {
gchar *url;
gdouble vpos;
} HEntry; /* History entry */
-
typedef struct {
GtkWidget *sctext;
GtkWidget *backb;
@@ -35,8 +31,6 @@ typedef struct {
GSList *back_stack; /* HEntry* */
GSList *fore_stack; /* HEntry* */
} TextNavigation;
-
-
/* --- prototypes --- */
static TextNavigation* navigation_from_sctext (GtkWidget *sctext);
static void navigate_back (GtkWidget *sctext);
@@ -52,8 +46,6 @@ static bool navigate_urls (GtkWidget *sctext,
static void text_buffer_add_error (GtkTextBuffer *tbuffer,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
-
-
/* --- functions --- */
static void
text_buffer_add_error (GtkTextBuffer *tbuffer,
@@ -86,7 +78,6 @@ text_buffer_add_error (GtkTextBuffer *tbuffer,
gtk_text_buffer_insert_with_tags (tbuffer, &iter, string, strlen (string), tag, NULL);
g_free (string);
}
-
static GSList *tsm_paths = NULL;
void
gxk_text_add_tsm_path (const gchar *path)
@@ -127,7 +118,6 @@ gxk_text_add_tsm_path (const gchar *path)
g_free (str);
}
}
-
static GdkPixbuf*
pixbuf_new_from_path (const gchar *file_name,
GError **error)
@@ -147,14 +137,11 @@ pixbuf_new_from_path (const gchar *file_name,
}
return pixbuf;
}
-
-
/* --- Textget handling --- */
typedef struct {
GtkTextChildAnchor *anchor;
GSList *widgets;
} Textget;
-
static void
free_textgets (gpointer data)
{
@@ -170,14 +157,12 @@ free_textgets (gpointer data)
g_free (textget);
}
}
-
static Textget*
gxk_text_buffer_create_textget (GtkTextBuffer *tbuffer)
{
Textget *textget = g_new (Textget, 1);
GtkTextIter iter;
GSList *slist;
-
gtk_text_buffer_get_iter_at_mark (tbuffer, &iter, gtk_text_buffer_get_insert (tbuffer));
textget->anchor = gtk_text_buffer_create_child_anchor (tbuffer, &iter);
textget->widgets = NULL;
@@ -186,33 +171,26 @@ gxk_text_buffer_create_textget (GtkTextBuffer *tbuffer)
g_object_set_data_full ((GObject*) tbuffer, "textgets", slist, free_textgets);
return textget;
}
-
typedef struct {
const gchar *element_name;
GxkTextTextgetHandler handler;
gpointer user_data;
} TextgetHandler;
static GSList *textget_handlers = NULL;
-
-
void
gxk_text_register_textget_handler (const gchar *element_name,
GxkTextTextgetHandler handler,
gpointer user_data)
{
TextgetHandler *th;
-
g_return_if_fail (element_name != NULL);
g_return_if_fail (handler != NULL);
-
th = g_new (TextgetHandler, 1);
th->element_name = g_strdup (element_name);
th->handler = handler;
th->user_data = user_data;
-
textget_handlers = g_slist_append (textget_handlers, th);
}
-
static void
gxk_text_buffer_handle_textget (GtkTextBuffer *tbuffer,
const gchar *element_name,
@@ -237,14 +215,12 @@ gxk_text_buffer_handle_textget (GtkTextBuffer *tbuffer,
}
}
}
-
void
gxk_text_buffer_add_textgets_to_view (GtkTextBuffer *tbuffer,
GtkTextView *tview)
{
g_return_if_fail (GTK_IS_TEXT_BUFFER (tbuffer));
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
GSList *slist = (GSList*) g_object_steal_data ((GObject*) tbuffer, "textgets");
while (slist)
{
@@ -257,8 +233,6 @@ gxk_text_buffer_add_textgets_to_view (GtkTextBuffer *tbuffer,
}
}
}
-
-
/* --- TextTag property setup --- */
static inline gchar
char2eval (gchar c)
@@ -272,7 +246,6 @@ char2eval (gchar c)
else
return '-';
}
-
static inline gboolean
enum_match (const gchar *str1,
const gchar *str2)
@@ -286,14 +259,12 @@ enum_match (const gchar *str1,
}
return *str1 == 0 && *str2 == 0;
}
-
static gint
enum_match_value (GEnumClass *eclass,
const gchar *name,
gint fallback)
{
guint i, length = strlen (name);
-
for (i = 0; i < eclass->n_values; i++)
{
const char *vname = eclass->values[i].value_name;
@@ -314,7 +285,6 @@ enum_match_value (GEnumClass *eclass,
}
return fallback;
}
-
static inline gboolean
check_boolean (const gchar *value)
{
@@ -322,7 +292,6 @@ check_boolean (const gchar *value)
value[0] == 'f' || value[0] == 'F' ||
value[0] == 'n' || value[0] == 'N');
}
-
static gboolean
text_buffer_tagdef (GtkTextBuffer *tbuffer,
const gchar *tag_name,
@@ -396,11 +365,8 @@ text_buffer_tagdef (GtkTextBuffer *tbuffer,
}
return TRUE;
}
-
-
/* --- TagSpanMarkup parser --- */
static guint signal_custom_activate = 0;
-
void
gxk_text_buffer_init_custom (void)
{
@@ -412,7 +378,6 @@ gxk_text_buffer_init_custom (void)
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
}
-
typedef struct _TsmLevel TsmLevel;
typedef struct {
GtkTextBuffer *tbuffer;
@@ -424,7 +389,6 @@ typedef struct {
guint after_newline : 1;
GtkStyle *style;
} TsmData;
-
static GtkStyle*
tsm_data_ensure_style (TsmData *md)
{
@@ -432,7 +396,6 @@ tsm_data_ensure_style (TsmData *md)
md->style = (GtkStyle*) g_object_new (GTK_TYPE_STYLE, NULL);
return md->style;
}
-
static gboolean
data_tag_event (GtkTextTag *tag,
GObject *event_object, /* widget, canvas item, whatever */
@@ -455,7 +418,6 @@ data_tag_event (GtkTextTag *tag,
}
return FALSE;
}
-
struct _TsmLevel
{
guint strip_space : 1;
@@ -464,7 +426,6 @@ struct _TsmLevel
GtkTextMark *mark;
TsmLevel *next;
};
-
static const TsmLevel*
tsm_peek_level (TsmData *md)
{
@@ -476,7 +437,6 @@ tsm_peek_level (TsmData *md)
};
return md->lstack ? md->lstack : &ttemplate;
}
-
static TsmLevel*
tsm_push_level (TsmData *md)
{
@@ -491,7 +451,6 @@ tsm_push_level (TsmData *md)
md->lstack = ml;
return ml;
}
-
static void
tsm_pop_level (TsmData *md)
{
@@ -503,7 +462,6 @@ tsm_pop_level (TsmData *md)
g_free (ml->tag_name);
g_free (ml);
}
-
/* Called for open tags <foo bar="baz"> */
static void
tsm_start_element (GMarkupParseContext *context,
@@ -514,7 +472,6 @@ tsm_start_element (GMarkupParseContext *context,
GError **error)
{
TsmData *md = (TsmData*) user_data;
-
if (strcmp (element_name, "tagdef") == 0)
{
guint i;
@@ -683,7 +640,6 @@ tsm_start_element (GMarkupParseContext *context,
else
text_buffer_add_error (md->tbuffer, "<%s>", element_name);
}
-
/* Called for close tags </foo> */
static void
tsm_end_element (GMarkupParseContext *context,
@@ -692,7 +648,6 @@ tsm_end_element (GMarkupParseContext *context,
GError **error)
{
TsmData *md = (TsmData*) user_data;
-
if (strcmp (element_name, "tagdef") == 0)
{
}
@@ -758,7 +713,6 @@ tsm_end_element (GMarkupParseContext *context,
else
text_buffer_add_error (md->tbuffer, "</%s>", element_name);
}
-
/* Called for character data */
static void
tsm_text (GMarkupParseContext *context,
@@ -771,10 +725,8 @@ tsm_text (GMarkupParseContext *context,
gchar *string = g_new (gchar, text_len + 1), *dest = string;
const TsmLevel *ml = tsm_peek_level (md);
guint i;
-
if (0)
gtk_text_buffer_insert_at_cursor (md->tbuffer, text, text_len);
-
for (i = 0; i < text_len; i++)
switch (text[i])
{
@@ -806,7 +758,6 @@ tsm_text (GMarkupParseContext *context,
gtk_text_buffer_insert_at_cursor (md->tbuffer, string, i);
g_free (string);
}
-
/* this includes comments and processing instructions */
static void
tsm_passthrough (GMarkupParseContext *context,
@@ -817,7 +768,6 @@ tsm_passthrough (GMarkupParseContext *context,
{
// TsmData *md = user_data;
}
-
/* Called on error, including one set by other methods in the vtable */
static void
tsm_error (GMarkupParseContext *context,
@@ -826,7 +776,6 @@ tsm_error (GMarkupParseContext *context,
{
// TsmData *md = user_data;
}
-
static void
gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
gboolean parse_tsm,
@@ -843,10 +792,8 @@ gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
GtkTextMark *start_mark;
GtkTextTag *tag;
gchar *name;
-
gtk_text_buffer_get_iter_at_mark (tbuffer, &start_iter, gtk_text_buffer_get_insert (tbuffer));
start_mark = gtk_text_buffer_create_mark (tbuffer, NULL, &start_iter, TRUE);
-
if (!parse_tsm)
{
GError *error = NULL;
@@ -883,18 +830,15 @@ gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
guint icon_square_sizes[] = { 8, 10, 12, 14, 16, 18, 20, 24, 32, 48, 56, 64, 96 };
static guint n_icon_sizes = G_N_ELEMENTS (icon_square_sizes);
guint n;
-
/* ensure certain icon sizes */
for (n = 0; n < n_icon_sizes; n++)
{
name = g_strdup_printf ("%ux%u", icon_square_sizes[n], icon_square_sizes[n]);
-
if (gtk_icon_size_from_name (name) == GTK_ICON_SIZE_INVALID)
gtk_icon_size_register (name, icon_square_sizes[n], icon_square_sizes[n]);
g_free (name);
}
n_icon_sizes = 0;
-
md.tbuffer = tbuffer;
md.tagns = gtk_text_tag_table_get_size (ttable); /* unique tag namespace */
md.lc = ' ';
@@ -904,7 +848,6 @@ gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
md.after_newline = TRUE;
md.style = NULL;
context = g_markup_parse_context_new (&tsm_parser, GMarkupParseFlags (0), &md, NULL);
-
n = read_callback (callback_data, data_buffer, &error);
while (n)
{
@@ -927,7 +870,6 @@ gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
if (md.style)
g_object_unref (md.style);
}
-
name = g_strdup_printf ("gxk-text-tools-indent-%u", indent);
tag = gtk_text_tag_table_lookup (ttable, name);
if (!tag)
@@ -945,25 +887,21 @@ gxk_text_buffer_insert (GtkTextBuffer *tbuffer,
g_object_unref (tag);
}
g_free (name);
-
gtk_text_buffer_get_iter_at_mark (tbuffer, &start_iter, start_mark);
gtk_text_buffer_delete_mark (tbuffer, start_mark);
gtk_text_buffer_get_iter_at_mark (tbuffer, &end_iter, gtk_text_buffer_get_insert (tbuffer));
gtk_text_buffer_apply_tag (tbuffer, tag, &start_iter, &end_iter);
}
-
static guint
static_read_callback (gpointer data,
guint8 *buffer,
GError **error)
{
guint i, *ip = (guint*) data;
-
i = *ip;
*ip = 0;
return i;
}
-
void
gxk_text_buffer_append_from_string (GtkTextBuffer *tbuffer,
gboolean parse_tsm,
@@ -974,22 +912,18 @@ gxk_text_buffer_append_from_string (GtkTextBuffer *tbuffer,
g_return_if_fail (GTK_IS_TEXT_BUFFER (tbuffer));
if (text_length)
g_return_if_fail (text != NULL);
-
gxk_text_buffer_cursor_to_end (tbuffer);
if (!text_length)
return;
gxk_text_buffer_insert (tbuffer, parse_tsm, indent_margin, "<Inlined String>", static_read_callback, &text_length, (guint8*) text);
}
-
#define FILE_READ_BUFFER_SIZE (8192)
-
static guint
fd_read_callback (gpointer data,
guint8 *buffer,
GError **error)
{
gint l, *fdp = (gint*) data;
-
do
l = read (*fdp, buffer, FILE_READ_BUFFER_SIZE);
while (l < 0 && errno == EINTR);
@@ -997,7 +931,6 @@ fd_read_callback (gpointer data,
g_set_error (error, 0, errno, "file read failed: %s", g_strerror (errno));
return MAX (0, l);
}
-
void
gxk_text_buffer_append_from_file (GtkTextBuffer *tbuffer,
gboolean parse_tsm,
@@ -1005,12 +938,9 @@ gxk_text_buffer_append_from_file (GtkTextBuffer *tbuffer,
const gchar *file_name)
{
gint fd;
-
g_return_if_fail (GTK_IS_TEXT_BUFFER (tbuffer));
g_return_if_fail (file_name != NULL);
-
gxk_text_buffer_cursor_to_end (tbuffer);
-
fd = open (file_name, O_RDONLY);
if (fd >= 0)
{
@@ -1021,30 +951,22 @@ gxk_text_buffer_append_from_file (GtkTextBuffer *tbuffer,
else
text_buffer_add_error (tbuffer, "Failed to open \"%s\": %s", file_name, g_strerror (errno));
}
-
void
gxk_text_buffer_cursor_to_start (GtkTextBuffer *tbuffer)
{
GtkTextIter iter;
-
g_return_if_fail (GTK_IS_TEXT_BUFFER (tbuffer));
-
gtk_text_buffer_get_start_iter (tbuffer, &iter);
gtk_text_buffer_place_cursor (tbuffer, &iter);
}
-
void
gxk_text_buffer_cursor_to_end (GtkTextBuffer *tbuffer)
{
GtkTextIter iter;
-
g_return_if_fail (GTK_IS_TEXT_BUFFER (tbuffer));
-
gtk_text_buffer_get_end_iter (tbuffer, &iter);
gtk_text_buffer_place_cursor (tbuffer, &iter);
}
-
-
/* --- TextView browse mode --- */
static inline void
adjustment_set_clamped_value (GtkAdjustment *adjustment,
@@ -1052,7 +974,6 @@ adjustment_set_clamped_value (GtkAdjustment *adjustment,
{
gtk_adjustment_set_value (adjustment, MIN (value, adjustment->upper - adjustment->page_size));
}
-
static gboolean
text_view_key_event (GtkTextView *tview,
GdkEventKey *event)
@@ -1113,7 +1034,6 @@ text_view_key_event (GtkTextView *tview,
}
return handled;
}
-
/**
* @param tview a GtkTextView object
*
@@ -1124,14 +1044,12 @@ void
gxk_text_view_enter_browse_mode (GtkTextView *tview)
{
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
if (!g_signal_handler_find (tview, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, (void*) text_view_key_event, tview))
{
g_signal_connect (tview, "key_press_event", G_CALLBACK (text_view_key_event), tview);
g_signal_connect (tview, "key_release_event", G_CALLBACK (text_view_key_event), tview);
}
}
-
/**
* @param tview a GtkTextView object
*
@@ -1142,11 +1060,9 @@ void
gxk_text_view_leave_browse_mode (GtkTextView *tview)
{
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
if (g_signal_handler_find (tview, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, (void*) text_view_key_event, tview))
g_signal_handlers_disconnect_by_func (tview, (void*) text_view_key_event, tview);
}
-
/**
* @param tview a GtkTextView object
*
@@ -1158,14 +1074,11 @@ void
gxk_text_view_cursor_to_start (GtkTextView *tview)
{
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_buffer_cursor_to_start (tbuffer);
gtk_text_view_scroll_to_mark (tview, gtk_text_buffer_get_insert (tbuffer), 0.0, TRUE, 0.0, 0.0);
}
-
/**
* @param tview a GtkTextView object
*
@@ -1177,19 +1090,15 @@ void
gxk_text_view_cursor_to_end (GtkTextView *tview)
{
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_buffer_cursor_to_end (tbuffer);
gtk_text_view_scroll_to_mark (tview, gtk_text_buffer_get_insert (tbuffer), 0.0, TRUE, 0.0, 0.0);
}
-
void
gxk_text_view_cursor_busy (GtkTextView *tview)
{
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
if (GTK_WIDGET_DRAWABLE (tview))
{
GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
@@ -1198,12 +1107,10 @@ gxk_text_view_cursor_busy (GtkTextView *tview)
gdk_flush ();
}
}
-
void
gxk_text_view_cursor_normal (GtkTextView *tview)
{
g_return_if_fail (GTK_IS_TEXT_VIEW (tview));
-
if (GTK_WIDGET_DRAWABLE (tview))
{
GdkCursor *cursor = gdk_cursor_new (GDK_XTERM);
@@ -1212,7 +1119,6 @@ gxk_text_view_cursor_normal (GtkTextView *tview)
gdk_flush ();
}
}
-
static gboolean
scroll_text_key_event (GtkWidget *sctext,
GdkEventKey *event)
@@ -1244,7 +1150,6 @@ scroll_text_key_event (GtkWidget *sctext,
}
return FALSE;
}
-
static void
scroll_text_patchup_size_request (GtkWidget *scwin,
GtkRequisition *requisition,
@@ -1260,7 +1165,6 @@ scroll_text_patchup_size_request (GtkWidget *scwin,
requisition->height += 100;
}
}
-
static void
tnav_update_vpos (GtkAdjustment *a,
TextNavigation *tnav)
@@ -1268,7 +1172,6 @@ tnav_update_vpos (GtkAdjustment *a,
if (tnav->current)
tnav->current->vpos = a->value > a->lower ? (a->value - a->lower) / (a->upper - a->lower) : 0;
}
-
/**
* @param flags scroll text flags
* @param string default contents
@@ -1299,9 +1202,7 @@ gxk_scroll_text_create (GxkScrollTextFlags flags,
GtkWidget *widget, *sctext, *scwin;
GtkTextBuffer *tbuffer;
GxkRadget *toolbar = NULL;
-
gxk_text_buffer_init_custom ();
-
/* sctext outer container */
sctext = (GtkWidget*) g_object_new (GTK_TYPE_VBOX,
"visible", TRUE,
@@ -1315,7 +1216,6 @@ gxk_scroll_text_create (GxkScrollTextFlags flags,
}
else /* there's code depending on the "presence" of a widget in the toolbar slot */
gtk_box_pack_start (GTK_BOX (sctext), (GtkWidget*) g_object_new (GTK_TYPE_ALIGNMENT, NULL), FALSE, TRUE, 0);
-
/* scrollable text area */
scwin = (GtkWidget*) g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
@@ -1330,7 +1230,6 @@ gxk_scroll_text_create (GxkScrollTextFlags flags,
NULL);
gtk_widget_grab_focus (widget);
tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
-
/* navigation bits */
if (toolbar)
{
@@ -1364,7 +1263,6 @@ gxk_scroll_text_create (GxkScrollTextFlags flags,
}
else
g_signal_connect_swapped (tbuffer, "custom-activate", G_CALLBACK (navigate_urls), sctext);
-
if (flags & GXK_SCROLL_TEXT_EDITABLE)
g_object_set (widget,
"editable", TRUE,
@@ -1398,12 +1296,9 @@ gxk_scroll_text_create (GxkScrollTextFlags flags,
}
if (flags & GXK_SCROLL_TEXT_WIDGET_BG)
gxk_widget_modify_base_as_bg (widget);
-
gxk_scroll_text_append (sctext, string);
-
return sctext;
}
-
GtkWidget*
gxk_scroll_text_create_for (GxkScrollTextFlags flags,
GtkWidget *parent)
@@ -1414,7 +1309,6 @@ gxk_scroll_text_create_for (GxkScrollTextFlags flags,
gtk_container_add (GTK_CONTAINER (parent), sctext);
return sctext;
}
-
static void
text_tag_remove (GtkTextTag *tag,
gpointer data)
@@ -1423,7 +1317,6 @@ text_tag_remove (GtkTextTag *tag,
if (g_object_get_int (tag, "gxk-text-tools-owned"))
*slist_p = g_slist_prepend (*slist_p, tag);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
*
@@ -1437,13 +1330,10 @@ gxk_scroll_text_clear (GtkWidget *sctext)
GtkTextTagTable *ttable;
GtkTextIter iter1, iter2;
GSList *node, *slist = NULL;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tview = gxk_scroll_text_get_text_view (sctext);
tbuffer = gtk_text_view_get_buffer (tview);
ttable = gtk_text_buffer_get_tag_table (tbuffer);
-
gtk_text_buffer_get_start_iter (tbuffer, &iter1);
gtk_text_buffer_get_end_iter (tbuffer, &iter2);
gtk_text_buffer_delete (tbuffer, &iter1, &iter2);
@@ -1453,7 +1343,6 @@ gxk_scroll_text_clear (GtkWidget *sctext)
g_slist_free (slist);
g_object_set_int (tview, "indent", 0);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param string the new text to be displayed
@@ -1465,11 +1354,9 @@ gxk_scroll_text_set (GtkWidget *sctext,
const gchar *string)
{
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
gxk_scroll_text_clear (sctext);
gxk_scroll_text_append (sctext, string);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param string the new text to be displayed in tag-span-markup
@@ -1482,11 +1369,9 @@ gxk_scroll_text_set_tsm (GtkWidget *sctext,
const gchar *string)
{
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
gxk_scroll_text_clear (sctext);
gxk_scroll_text_append_tsm (sctext, string);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param string the text to be displayed
@@ -1499,9 +1384,7 @@ gxk_scroll_text_append (GtkWidget *sctext,
{
GtkTextView *tview;
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tview = gxk_scroll_text_get_text_view (sctext);
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_view_cursor_busy (tview);
@@ -1511,7 +1394,6 @@ gxk_scroll_text_append (GtkWidget *sctext,
gxk_text_view_cursor_normal (tview);
gxk_text_view_cursor_to_start (tview);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param string the text to be displayed in tag-span-markup
@@ -1525,9 +1407,7 @@ gxk_scroll_text_append_tsm (GtkWidget *sctext,
{
GtkTextView *tview;
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tview = gxk_scroll_text_get_text_view (sctext);
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_view_cursor_busy (tview);
@@ -1537,7 +1417,6 @@ gxk_scroll_text_append_tsm (GtkWidget *sctext,
gxk_text_view_cursor_normal (tview);
gxk_text_view_cursor_to_start (tview);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param file_name file holding the text to be displayed
@@ -1551,10 +1430,8 @@ gxk_scroll_text_append_file (GtkWidget *sctext,
{
GtkTextView *tview;
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
g_return_if_fail (file_name != NULL);
-
tview = gxk_scroll_text_get_text_view (sctext);
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_view_cursor_busy (tview);
@@ -1563,7 +1440,6 @@ gxk_scroll_text_append_file (GtkWidget *sctext,
gxk_text_view_cursor_normal (tview);
gxk_text_view_cursor_to_start (tview);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param file_name file holding the text to be displayed in tag-span-markup
@@ -1577,10 +1453,8 @@ gxk_scroll_text_append_file_tsm (GtkWidget *sctext,
{
GtkTextView *tview;
GtkTextBuffer *tbuffer;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
g_return_if_fail (file_name != NULL);
-
tview = gxk_scroll_text_get_text_view (sctext);
tbuffer = gtk_text_view_get_buffer (tview);
gxk_text_view_cursor_busy (tview);
@@ -1589,7 +1463,6 @@ gxk_scroll_text_append_file_tsm (GtkWidget *sctext,
gxk_text_view_cursor_normal (tview);
gxk_text_view_cursor_to_start (tview);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param text_fmt printf(3) style format string
@@ -1602,21 +1475,17 @@ gxk_scroll_text_aprintf (GtkWidget *sctext,
...)
{
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
if (text_fmt)
{
va_list args;
gchar *buffer;
-
va_start (args, text_fmt);
buffer = g_strdup_vprintf (text_fmt, args);
va_end (args);
-
gxk_scroll_text_append (sctext, buffer);
g_free (buffer);
}
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @return a GtkTextView widget
@@ -1628,16 +1497,11 @@ gxk_scroll_text_get_text_view (GtkWidget *sctext)
{
GtkTextView *tview;
GtkWidget *scwin;
-
g_return_val_if_fail (GXK_IS_SCROLL_TEXT (sctext), NULL);
-
scwin = ((GtkBoxChild*) GTK_BOX (sctext)->children->next->data)->widget;
-
tview = GTK_TEXT_VIEW (GTK_BIN (scwin)->child);
-
return tview;
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
*
@@ -1649,14 +1513,11 @@ gxk_scroll_text_push_indent (GtkWidget *sctext)
{
GtkTextView *tview;
guint indent;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tview = gxk_scroll_text_get_text_view (sctext);
indent = g_object_get_int (tview, "indent");
g_object_set_int (tview, "indent", indent + 2);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
*
@@ -1668,15 +1529,12 @@ gxk_scroll_text_pop_indent (GtkWidget *sctext)
{
GtkTextView *tview;
guint indent;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tview = gxk_scroll_text_get_text_view (sctext);
indent = g_object_get_int (tview, "indent");
if (indent)
g_object_set_int (tview, "indent", indent - 2);
}
-
static void
navigation_reset_url (TextNavigation *tnav)
{
@@ -1689,7 +1547,6 @@ navigation_reset_url (TextNavigation *tnav)
g_free (tnav->anchor);
tnav->anchor = NULL;
}
-
static gboolean
navigation_test_file (const gchar *dir,
const gchar *path,
@@ -1705,14 +1562,12 @@ navigation_test_file (const gchar *dir,
g_free (fname);
return check;
}
-
static void
navigation_set_url (TextNavigation *tnav,
const gchar *src_url,
gdouble vert_frac)
{
gchar *p, *url = g_strdup (src_url), *buffer = url;
-
p = strchr (url, ':');
if (p)
{
@@ -1720,7 +1575,6 @@ navigation_set_url (TextNavigation *tnav,
tnav->proto = g_strndup (url, p - url);
url = p + 1;
}
-
g_free (tnav->anchor);
p = strrchr (url, '#');
if (p)
@@ -1730,7 +1584,6 @@ navigation_set_url (TextNavigation *tnav,
}
else
tnav->anchor = NULL;
-
p = strrchr (url, '/');
if (p)
{
@@ -1745,7 +1598,6 @@ navigation_set_url (TextNavigation *tnav,
tnav->file = g_strdup (url);
*url = 0;
}
-
if (url[0] == '/')
{
g_free (tnav->path);
@@ -1763,7 +1615,6 @@ navigation_set_url (TextNavigation *tnav,
tnav->path = p;
}
/* here, url contains just path segment */
-
/* patch up relative file names */
if (url[0] != '/'
&& strcmp (tnav->proto, "file") == 0
@@ -1782,11 +1633,9 @@ navigation_set_url (TextNavigation *tnav,
break;
}
}
-
g_free (buffer);
tnav->vert_frac = vert_frac;
}
-
static gchar*
navigation_strdup_url (TextNavigation *tnav)
{
@@ -1795,7 +1644,6 @@ navigation_strdup_url (TextNavigation *tnav)
else
return g_strconcat (tnav->proto, ":", tnav->path, tnav->file, NULL);
}
-
static void
navigation_clear_fore_stack (TextNavigation *tnav)
{
@@ -1809,7 +1657,6 @@ navigation_clear_fore_stack (TextNavigation *tnav)
g_slist_free (tnav->fore_stack);
tnav->fore_stack = NULL;
}
-
static void
navigation_update_widgets (TextNavigation *tnav)
{
@@ -1822,7 +1669,6 @@ navigation_update_widgets (TextNavigation *tnav)
if (tnav->refe)
gtk_entry_set_text (GTK_ENTRY (tnav->refe), tnav->current ? tnav->current->url : "");
}
-
static void
free_navigation (gpointer data)
{
@@ -1854,7 +1700,6 @@ free_navigation (gpointer data)
g_slist_free (tnav->back_stack);
g_free (tnav);
}
-
static TextNavigation*
navigation_from_sctext (GtkWidget *sctext)
{
@@ -1869,13 +1714,11 @@ navigation_from_sctext (GtkWidget *sctext)
}
return tnav;
}
-
enum {
FILE_TYPE_UNKNOWN,
FILE_TYPE_TSM,
FILE_TYPE_DIR,
};
-
static guint
guess_file_type (const gchar *file_name)
{
@@ -1909,7 +1752,6 @@ guess_file_type (const gchar *file_name)
return FILE_TYPE_DIR;
return FILE_TYPE_UNKNOWN;
}
-
static void
g_string_add_xmlstr (GString *gstring,
const gchar *str)
@@ -1926,7 +1768,6 @@ g_string_add_xmlstr (GString *gstring,
default: g_string_append_c (gstring, *p);
}
}
-
static gboolean
adjust_vscroll_offset (gpointer data)
{
@@ -1943,12 +1784,10 @@ adjust_vscroll_offset (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
scroll_text_reload (GtkWidget *sctext)
{
TextNavigation *tnav = navigation_from_sctext (sctext);
-
gxk_scroll_text_clear (sctext);
if (strcmp (tnav->proto, "about") == 0)
gxk_scroll_text_set_tsm (sctext,
@@ -2033,7 +1872,6 @@ scroll_text_reload (GtkWidget *sctext)
if (tnav->vert_frac >= 0)
g_idle_add_full (G_PRIORITY_LOW + 100, adjust_vscroll_offset, g_object_ref (sctext), g_object_unref);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param uri resource locator
@@ -2046,16 +1884,12 @@ gxk_scroll_text_display (GtkWidget *sctext,
const gchar *uri)
{
TextNavigation *tnav;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
g_return_if_fail (uri != NULL);
-
tnav = navigation_from_sctext (sctext);
navigation_set_url (tnav, uri, -1);
-
scroll_text_reload (sctext);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param uri resource locator
@@ -2070,10 +1904,8 @@ gxk_scroll_text_advance (GtkWidget *sctext,
{
TextNavigation *tnav;
HEntry *last;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
g_return_if_fail (uri != NULL);
-
tnav = navigation_from_sctext (sctext);
/* handle history */
last = tnav->back_stack ? (HEntry*) tnav->back_stack->data : NULL;
@@ -2109,7 +1941,6 @@ gxk_scroll_text_advance (GtkWidget *sctext,
scroll_text_reload (sctext);
navigation_update_widgets (tnav);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param uri resource locator
@@ -2122,15 +1953,12 @@ gxk_scroll_text_enter (GtkWidget *sctext,
const gchar *uri)
{
TextNavigation *tnav;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
g_return_if_fail (uri != NULL);
-
tnav = navigation_from_sctext (sctext);
navigation_reset_url (tnav);
gxk_scroll_text_advance (sctext, uri);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
* @param uri resource locator
@@ -2143,16 +1971,13 @@ gxk_scroll_text_set_index (GtkWidget *sctext,
const gchar *uri)
{
TextNavigation *tnav;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
if (!uri || !uri[0])
uri = "about:";
-
tnav = navigation_from_sctext (sctext);
g_free (tnav->index);
tnav->index = g_strdup (uri);
}
-
/**
* @param sctext a scroll text widget as returned from gxk_scroll_text_create()
*
@@ -2162,9 +1987,7 @@ void
gxk_scroll_text_rewind (GtkWidget *sctext)
{
TextNavigation *tnav;
-
g_return_if_fail (GXK_IS_SCROLL_TEXT (sctext));
-
tnav = navigation_from_sctext (sctext);
while (tnav->back_stack)
{
@@ -2190,7 +2013,6 @@ gxk_scroll_text_rewind (GtkWidget *sctext)
navigation_update_widgets (tnav);
gxk_text_view_cursor_to_start (gxk_scroll_text_get_text_view (sctext));
}
-
static void
navigate_back (GtkWidget *sctext)
{
@@ -2215,7 +2037,6 @@ navigate_back (GtkWidget *sctext)
navigation_update_widgets (tnav);
}
}
-
static void
navigate_forward (GtkWidget *sctext)
{
@@ -2240,20 +2061,17 @@ navigate_forward (GtkWidget *sctext)
navigation_update_widgets (tnav);
}
}
-
static void
navigate_index (GtkWidget *sctext)
{
TextNavigation *tnav = navigation_from_sctext (sctext);
gxk_scroll_text_enter (sctext, tnav->index);
}
-
static void
navigate_find (GtkWidget *sctext)
{
gxk_scroll_text_enter (sctext, "about:");
}
-
static void
navigate_reload (GtkWidget *sctext)
{
@@ -2261,7 +2079,6 @@ navigate_reload (GtkWidget *sctext)
tnav->vert_frac = -1;
scroll_text_reload (sctext);
}
-
static void
navigate_goto (GtkWidget *sctext)
{
@@ -2270,7 +2087,6 @@ navigate_goto (GtkWidget *sctext)
if (text && text[0])
gxk_scroll_text_enter (sctext, text);
}
-
static bool
navigate_urls (GtkWidget *sctext,
const gchar *uri)
@@ -2286,7 +2102,6 @@ navigate_urls (GtkWidget *sctext,
else
return FALSE;
}
-
static void
navigate_link (GtkWidget *sctext,
const gchar *uri)
diff --git a/beast-gtk/gxk/gxktexttools.hh b/beast-gtk/gxk/gxktexttools.hh
index bbf3a6b..4c7aa20 100644
--- a/beast-gtk/gxk/gxktexttools.hh
+++ b/beast-gtk/gxk/gxktexttools.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_TEXT_TOOLS_H__
#define __GXK_TEXT_TOOLS_H__
-
#include "gxkutils.hh"
-
G_BEGIN_DECLS
-
/* --- text tools flags --- */
typedef enum /*< skip >*/
{
@@ -21,8 +18,6 @@ typedef enum /*< skip >*/
GXK_SCROLL_TEXT_VFIXED = 1 << 8
#define GXK_SCROLL_TEXT_WIDGET_LOOK (GXK_SCROLL_TEXT_WRAP | GXK_SCROLL_TEXT_WIDGET_BG | GXK_SCROLL_TEXT_SANS)
} GxkScrollTextFlags;
-
-
/* --- text tools functions --- */
void gxk_text_view_enter_browse_mode (GtkTextView *tview);
void gxk_text_view_leave_browse_mode (GtkTextView *tview);
@@ -75,8 +70,6 @@ void gxk_text_buffer_append_from_file (GtkTextBuffer *tbuffer,
gboolean parse_tsm,
guint indent_margin,
const gchar *file_name);
-
-
/* --- special tag handlers --- */
typedef GtkWidget* (*GxkTextTextgetHandler) (gpointer user_data,
const gchar *element_name,
@@ -87,10 +80,7 @@ void gxk_text_register_textget_handler (const gchar *element_name
gpointer user_data);
void gxk_text_buffer_add_textgets_to_view (GtkTextBuffer *tbuffer,
GtkTextView *tview);
-
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline GxkScrollTextFlags operator& (GxkScrollTextFlags s1, GxkScrollTextFlags s2) { return GxkScrollTextFlags (s1 & (long long unsigned) s2); }
@@ -99,5 +89,4 @@ inline GxkScrollTextFlags operator| (GxkScrollTextFlags s1, GxkScrollTextFlag
inline GxkScrollTextFlags& operator|= (GxkScrollTextFlags &s1, GxkScrollTextFlags s2) { s1 = s1 | s2; return s1; }
inline GxkScrollTextFlags operator~ (GxkScrollTextFlags s1) { return GxkScrollTextFlags (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __GXK_TEXT_TOOLS_H__ */
diff --git a/beast-gtk/gxk/gxkutils.cc b/beast-gtk/gxk/gxkutils.cc
index f854681..5bd8cf0 100644
--- a/beast-gtk/gxk/gxkutils.cc
+++ b/beast-gtk/gxk/gxkutils.cc
@@ -7,29 +7,19 @@
#include "gxkauxwidgets.hh"
#include <string.h>
#include <stdlib.h>
-
-
/* --- generated marshallers --- */
#include "gxkmarshal.cc"
-
-
/* --- generated type IDs and enums --- */
#include "gxkgentypes.cc"
-
-
/* --- prototypes --- */
static void gxk_traverse_viewable_changed (GtkWidget *widget,
gpointer data);
static void gxk_traverse_attached_hierarchy_changed (GtkWidget *widget,
gpointer data);
static void gxk_menu_refetch_accel_group (GtkMenu *menu);
-
-
/* --- variables --- */
static guint signal_viewable_changed = 0;
static guint signal_attached_hierarchy_changed = 0;
-
-
/* --- functions --- */
static gboolean
gxk_widget_real_can_activate_accel (GtkWidget *widget, // GTKFIX: #145270, remove this when depending on gtk+ > 2.4.10
@@ -38,7 +28,6 @@ gxk_widget_real_can_activate_accel (GtkWidget *widget, // GTKFIX: #145270, remov
/* widgets must be onscreen for accels to take effect */
return GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_DRAWABLE (widget) && gxk_widget_ancestry_viewable (widget);
}
-
static gboolean
ehook_container_focus_child_set (GSignalInvocationHint *ihint,
guint n_param_values,
@@ -74,13 +63,11 @@ ehook_container_focus_child_set (GSignalInvocationHint *ihint,
}
return TRUE;
}
-
void
gxk_init_utils (void)
{
/* type registrations */
gxk_type_register_generated (G_N_ELEMENTS (generated_type_entries), generated_type_entries);
-
/* Gtk+ patchups */
signal_viewable_changed = g_signal_newv ("viewable-changed",
G_TYPE_FROM_CLASS (gtk_type_class (GTK_TYPE_WIDGET)),
@@ -98,13 +85,11 @@ gxk_init_utils (void)
G_TYPE_NONE, 0, NULL);
GtkWidgetClass *widget_class = (GtkWidgetClass*) gtk_type_class (GTK_TYPE_WIDGET);
widget_class->can_activate_accel = gxk_widget_real_can_activate_accel;
-
/* patch up scrolling+focus behaviour */
g_type_class_unref (g_type_class_ref (GTK_TYPE_CONTAINER)); /* create static class */
g_signal_add_emission_hook (g_signal_lookup ("set-focus-child", GTK_TYPE_CONTAINER), 0,
ehook_container_focus_child_set, NULL, NULL);
}
-
/**
* @param widget a valid GtkWidget
* @return whether @a widget is visible on screen
@@ -128,7 +113,6 @@ gxk_widget_ancestry_viewable (GtkWidget *widget)
}
return TRUE;
}
-
/**
* @param n_entries number of generated types to register
* @param entries GxkTypeGenerated type descriptions
@@ -146,7 +130,6 @@ gxk_type_register_generated (guint n_entries,
const GxkTypeGenerated *entries)
{
guint i;
-
for (i = 0; i < n_entries; i++)
{
GType type_id;
@@ -166,7 +149,6 @@ gxk_type_register_generated (guint n_entries,
*entries[i].type_id = type_id;
}
}
-
/**
* @param object a valid GObject
* @param name name of the double value to set
@@ -181,9 +163,7 @@ g_object_set_double (gpointer object,
gdouble v_double)
{
gdouble zero = 0;
-
g_return_if_fail (G_IS_OBJECT (object));
-
if (memcmp (&v_double, &zero, sizeof (zero)) == 0)
g_object_set_data ((GObject*) object, name, NULL);
else
@@ -193,7 +173,6 @@ g_object_set_double (gpointer object,
g_object_set_data_full ((GObject*) object, name, dp, g_free);
}
}
-
/**
* @param object a valid GObject
* @param name name of the double value to retrieve
@@ -207,11 +186,9 @@ g_object_get_double (gpointer object,
const gchar *name)
{
g_return_val_if_fail (G_IS_OBJECT (object), 0);
-
double *dp = (double*) g_object_get_data ((GObject*) object, name);
return dp ? *dp : 0;
}
-
/**
* @param object a valid GObject
* @param name name of the long value to set
@@ -226,10 +203,8 @@ g_object_set_long (gpointer object,
glong v_long)
{
g_return_if_fail (G_IS_OBJECT (object));
-
g_object_set_data ((GObject*) object, name, (gpointer) v_long);
}
-
/**
* @param object a valid GObject
* @param name name of the long value to retrieve
@@ -243,10 +218,8 @@ g_object_get_long (gpointer object,
const gchar *name)
{
g_return_val_if_fail (G_IS_OBJECT (object), 0);
-
return (glong) g_object_get_data ((GObject*) object, name);
}
-
gchar*
gxk_convert_latin1_to_utf8 (const gchar *string)
{
@@ -267,7 +240,6 @@ gxk_convert_latin1_to_utf8 (const gchar *string)
}
return NULL;
}
-
gchar*
gxk_filename_to_utf8 (const gchar *filename)
{
@@ -280,7 +252,6 @@ gxk_filename_to_utf8 (const gchar *filename)
}
return NULL;
}
-
const gchar*
gxk_factory_path_get_leaf (const gchar *path)
{
@@ -297,7 +268,6 @@ gxk_factory_path_get_leaf (const gchar *path)
}
return last ? last : path;
}
-
gchar*
gxk_factory_path_unescape_uline (const gchar *path)
{
@@ -315,8 +285,6 @@ gxk_factory_path_unescape_uline (const gchar *path)
*d = 0;
return str;
}
-
-
/* --- Gtk+ Utilities --- */
/**
* @param widget valid GtkWidget
@@ -329,7 +297,6 @@ gboolean
gxk_widget_viewable (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-
while (widget)
{
if (!GTK_WIDGET_MAPPED (widget))
@@ -338,7 +305,6 @@ gxk_widget_viewable (GtkWidget *widget)
}
return TRUE;
}
-
/**
* @param widget valid GtkWidget
*
@@ -356,10 +322,8 @@ void
gxk_widget_viewable_changed (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
g_signal_emit (widget, signal_viewable_changed, 0);
}
-
static void
gxk_traverse_viewable_changed (GtkWidget *widget,
gpointer data)
@@ -367,7 +331,6 @@ gxk_traverse_viewable_changed (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) gxk_widget_viewable_changed, NULL);
}
-
/**
* @param widget valid GtkWidget
*
@@ -385,10 +348,8 @@ void
gxk_widget_attached_hierarchy_changed (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
g_signal_emit (widget, signal_attached_hierarchy_changed, 0);
}
-
static void
widget_propagate_hierarchy_changed_to_attached (GtkWidget *widget)
{
@@ -408,7 +369,6 @@ widget_propagate_hierarchy_changed_to_attached (GtkWidget *widget)
for (; menu_list; menu_list = menu_list->next)
gxk_widget_attached_hierarchy_changed ((GtkWidget*) menu_list->data);
}
-
static void
gxk_traverse_attached_hierarchy_changed (GtkWidget *widget,
gpointer data)
@@ -416,12 +376,10 @@ gxk_traverse_attached_hierarchy_changed (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) gxk_widget_attached_hierarchy_changed, NULL);
widget_propagate_hierarchy_changed_to_attached (widget);
-
/* special attached_hierarchy_changed hooks */
if (GTK_IS_MENU (widget))
gxk_menu_refetch_accel_group (GTK_MENU (widget));
}
-
static void
gxk_widget_proxy_hierarchy_changed_to_attached (GtkWidget *widget)
{
@@ -429,7 +387,6 @@ gxk_widget_proxy_hierarchy_changed_to_attached (GtkWidget *widget)
g_signal_connect_after (widget, "hierarchy-changed", G_CALLBACK (widget_propagate_hierarchy_changed_to_attached), NULL);
widget_propagate_hierarchy_changed_to_attached (widget);
}
-
/**
* @param window valid GdkWindow*
* @param cursor GdkCursorType cursor type
@@ -442,7 +399,6 @@ gxk_window_set_cursor_type (GdkWindow *window,
GdkCursorType cursor)
{
g_return_if_fail (GDK_IS_WINDOW (window));
-
if (cursor >= GDK_LAST_CURSOR || cursor < 0)
gdk_window_set_cursor (window, NULL);
else
@@ -452,11 +408,9 @@ gxk_window_set_cursor_type (GdkWindow *window,
gdk_cursor_unref (wc);
}
}
-
static guint expose_handler_id = 0;
static GSList *expose_windows = NULL;
static GSList *cexpose_windows = NULL;
-
static gboolean
expose_handler (gpointer data)
{
@@ -477,7 +431,6 @@ expose_handler (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
/**
* @param window valid GdkWindow
* @param update_children whether to also process updates for child windows
@@ -490,7 +443,6 @@ gxk_window_process_next (GdkWindow *window,
gboolean update_children)
{
g_return_if_fail (GDK_IS_WINDOW (window));
-
if (update_children)
cexpose_windows = g_slist_append_uniq (cexpose_windows, window);
else
@@ -498,7 +450,6 @@ gxk_window_process_next (GdkWindow *window,
if (!expose_handler_id)
expose_handler_id = g_idle_add_full (G_PRIORITY_DEFAULT, expose_handler, NULL, NULL);
}
-
/**
* Convenience variant of gdk_draw_line() to draw a horizontal line.
*/
@@ -512,7 +463,6 @@ gdk_draw_hline (GdkDrawable *drawable,
if (width > 0)
gdk_draw_line (drawable, gc, x, y, x + width - 1, y);
}
-
/**
* Convenience variant of gdk_draw_line() to draw a vertical line.
*/
@@ -526,7 +476,6 @@ gdk_draw_vline (GdkDrawable *drawable,
if (height > 0)
gdk_draw_line (drawable, gc, x, y, x, y + height - 1);
}
-
/**
* @param colormap valid GdkColormap
* @param color valid GdkColor
@@ -541,7 +490,6 @@ gxk_color_alloc (GdkColormap *colormap,
if (!gdk_color_alloc (colormap, color))
g_message ("failed to allocate color: { %d, %d, %d }", color->red, color->green, color->blue);
}
-
/**
* @param rgb_value 0xRrGgBb color value
*
@@ -561,7 +509,6 @@ gdk_color_from_rgb (guint rgb_value)
c.blue *= 0x0101;
return c;
}
-
/**
* @param rgb_value 0xAaRrGgBb color value
*
@@ -581,7 +528,6 @@ gdk_color_from_argb (guint rgb_value)
c.blue *= 0x0101;
return c;
}
-
/**
* @param rgb_value 0xRrGgBbAa color value
*
@@ -601,7 +547,6 @@ gdk_color_from_rgba (guint rgb_value)
c.blue *= 0x0101;
return c;
}
-
/* --- Colors --- */
static int
gxk_color_dot_cmp (const void *v1,
@@ -611,7 +556,6 @@ gxk_color_dot_cmp (const void *v1,
const GxkColorDot *c2 = (const GxkColorDot*) v2;
return c1->value < c2->value ? -1 : c1->value > c2->value;
}
-
GxkColorDots*
gxk_color_dots_new (guint n_dots,
const GxkColorDot *dots)
@@ -624,7 +568,6 @@ gxk_color_dots_new (guint n_dots,
qsort (cdots->colors, cdots->n_colors, sizeof_color_dot, gxk_color_dot_cmp);
return cdots;
}
-
guint
gxk_color_dots_interpolate (GxkColorDots *cdots,
double value,
@@ -664,7 +607,6 @@ gxk_color_dots_interpolate (GxkColorDots *cdots,
return (red << 16) | (green << 8) | blue;
}
}
-
void
gxk_color_dots_destroy (GxkColorDots *cdots)
{
@@ -672,9 +614,7 @@ gxk_color_dots_destroy (GxkColorDots *cdots)
g_free (cdots->colors);
g_free (cdots);
}
-
/* --- Gtk convenience --- */
-
/**
* @param widget a valid GtkWidget
*
@@ -685,11 +625,9 @@ void
gxk_widget_make_insensitive (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (GTK_WIDGET_IS_SENSITIVE (widget))
gtk_widget_set_sensitive (widget, FALSE);
}
-
/**
* @param widget a valid GtkWidget
*
@@ -700,11 +638,9 @@ void
gxk_widget_make_sensitive (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!GTK_WIDGET_IS_SENSITIVE (widget))
gtk_widget_set_sensitive (widget, TRUE);
}
-
static gboolean
idle_showraiser (gpointer data)
{
@@ -724,7 +660,6 @@ idle_showraiser (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
/**
* @param widget a valid GtkWidget
*
@@ -737,21 +672,16 @@ void
gxk_idle_showraise (GtkWidget *widget)
{
GtkWidget **widget_p;
-
g_return_if_fail (GTK_IS_WIDGET (widget));
-
widget_p = g_new (GtkWidget*, 1);
-
*widget_p = widget;
g_object_connect (widget, "signal::destroy", gtk_widget_destroyed, widget_p, NULL);
gtk_idle_add_priority (GTK_PRIORITY_RESIZE - 1, idle_showraiser, widget_p);
}
-
static gint
idle_shower (GtkWidget **widget_p)
{
GDK_THREADS_ENTER ();
-
if (GTK_IS_WIDGET (*widget_p))
{
gtk_signal_disconnect_by_func (GTK_OBJECT (*widget_p),
@@ -762,12 +692,9 @@ idle_shower (GtkWidget **widget_p)
gtk_widget_show (*widget_p);
}
g_free (widget_p);
-
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
/**
* @param widget a valid GtkWidget
*
@@ -780,11 +707,8 @@ void
gxk_idle_show_widget (GtkWidget *widget)
{
GtkWidget **widget_p;
-
g_return_if_fail (GTK_IS_WIDGET (widget));
-
widget_p = g_new (GtkWidget*, 1);
-
*widget_p = widget;
gtk_signal_connect (GTK_OBJECT (widget),
"destroy",
@@ -792,12 +716,10 @@ gxk_idle_show_widget (GtkWidget *widget)
widget_p);
gtk_idle_add_priority (GTK_PRIORITY_RESIZE - 1, (GtkFunction) idle_shower, widget_p);
}
-
static gint
idle_unrealizer (GtkWidget **widget_p)
{
GDK_THREADS_ENTER ();
-
if (GTK_IS_WINDOW (*widget_p))
{
gtk_signal_disconnect_by_func (GTK_OBJECT (*widget_p),
@@ -808,12 +730,9 @@ idle_unrealizer (GtkWidget **widget_p)
gtk_widget_unrealize (*widget_p);
}
g_free (widget_p);
-
GDK_THREADS_LEAVE ();
-
return FALSE;
}
-
/**
* @param widget a valid GtkWindow
*
@@ -826,11 +745,8 @@ void
gxk_idle_unrealize_widget (GtkWidget *widget)
{
GtkWidget **widget_p;
-
g_return_if_fail (GTK_IS_WINDOW (widget));
-
widget_p = g_new (GtkWidget*, 1);
-
*widget_p = widget;
gtk_signal_connect (GTK_OBJECT (widget),
"destroy",
@@ -838,7 +754,6 @@ gxk_idle_unrealize_widget (GtkWidget *widget)
widget_p);
gtk_idle_add_priority (GTK_PRIORITY_RESIZE - 1, (GtkFunction) idle_unrealizer, widget_p);
}
-
GtkWidget*
gxk_notebook_create_tabulator (const gchar *label_text,
const gchar *stock_image,
@@ -854,7 +769,6 @@ gxk_notebook_create_tabulator (const gchar *label_text,
gxk_notebook_change_tabulator (ev, label_text, stock_image, tooltip);
return ev;
}
-
void
gxk_notebook_change_tabulator (GtkWidget *tabulator,
const gchar *label_text,
@@ -886,8 +800,6 @@ gxk_notebook_change_tabulator (GtkWidget *tabulator,
}
}
}
-
-
/**
* @param notebook a valid notebook
* @param child a valid parent-less widget
@@ -908,7 +820,6 @@ gxk_notebook_append (GtkNotebook *notebook,
gtk_notebook_set_menu_label_text (notebook, child, tab_text);
gtk_notebook_set_tab_label_packing (notebook, child, fillexpand, fillexpand, GTK_PACK_START);
}
-
/**
* @param notebook valid GtkNotebook
* @param page @a notebook page widget
@@ -924,7 +835,6 @@ gxk_notebook_set_current_page_widget (GtkNotebook *notebook,
if (num >= 0)
gtk_notebook_set_current_page (notebook, num);
}
-
static void
vseparator_space_request (GtkWidget *widget,
GtkRequisition *requisition,
@@ -933,7 +843,6 @@ vseparator_space_request (GtkWidget *widget,
guint i = GPOINTER_TO_INT (data);
requisition->width = i * widget->style->xthickness;
}
-
/**
* @param draw_seperator enable visible vertical seperator
* @return visible vertical space/seperator widget
@@ -951,7 +860,6 @@ gxk_vseparator_space_new (gboolean draw_seperator)
GUINT_TO_POINTER (draw_seperator ? 2 + 1 + 2 : 3));
return widget;
}
-
/**
* @param notebook valid GtkNotebook
* @return the widget corresponding to the current page
@@ -964,7 +872,6 @@ gtk_notebook_current_widget (GtkNotebook *notebook)
{
return gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
}
-
/**
* @param widget valid GtkWidget
* @return notebook page widget or NULL
@@ -978,7 +885,6 @@ gxk_notebook_descendant_get_page (GtkWidget *widget)
widget = widget->parent;
return widget->parent ? widget : NULL;
}
-
/**
* @param widget valid GtkWidget
* @return notebook page tab widget or NULL
@@ -992,7 +898,6 @@ gxk_notebook_descendant_get_tab (GtkWidget *widget)
widget = gxk_notebook_descendant_get_page (widget);
return widget ? gtk_notebook_get_tab_label (GTK_NOTEBOOK (widget->parent), widget) : NULL;
}
-
/**
* @param box a valid GtkBox
* @param pos position of the requested child
@@ -1007,17 +912,13 @@ gtk_box_get_nth_child (GtkBox *box,
gint pos)
{
g_return_val_if_fail (GTK_IS_BOX (box), NULL);
-
GList *child = box->children;
-
if (child)
while (child->next && pos--)
child = child->next;
-
GtkBoxChild *child_info = child && pos <= 0 ? (GtkBoxChild*) child->data : NULL;
return child_info ? child_info->widget : NULL;
}
-
/**
* @param widget a valid widget
*
@@ -1028,12 +929,10 @@ void
gxk_widget_showraise (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
gtk_widget_show (widget);
if (GTK_WIDGET_REALIZED (widget) && !widget->parent)
gdk_window_raise (widget->window);
}
-
static gboolean
async_delete_event_handler (gpointer data)
{
@@ -1052,7 +951,6 @@ async_delete_event_handler (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
/**
* @param widget a widget having a toplevel
*
@@ -1066,12 +964,10 @@ void
gxk_toplevel_delete (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
widget = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (widget) && GTK_WIDGET_DRAWABLE (widget))
g_idle_add_full (G_PRIORITY_DEFAULT, async_delete_event_handler, g_object_ref (widget), NULL);
}
-
/**
* @param widget a widget having a toplevel
*
@@ -1081,12 +977,10 @@ void
gxk_toplevel_activate_default (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
widget = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (widget))
gtk_window_activate_default (GTK_WINDOW (widget));
}
-
/**
* @param widget a widget having a toplevel
*
@@ -1096,16 +990,13 @@ void
gxk_toplevel_hide (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
widget = gtk_widget_get_toplevel (widget);
gtk_widget_hide (widget);
}
-
typedef struct {
GtkWidget *child;
GType type;
} DescendantSearch;
-
static void
find_descendant_callback (GtkWidget *child,
gpointer data)
@@ -1119,7 +1010,6 @@ find_descendant_callback (GtkWidget *child,
gtk_container_foreach (GTK_CONTAINER (child), find_descendant_callback, dsearch);
}
}
-
GtkWidget*
gxk_parent_find_descendant (GtkWidget *parent,
GType descendant_type)
@@ -1130,7 +1020,6 @@ gxk_parent_find_descendant (GtkWidget *parent,
gtk_container_foreach (GTK_CONTAINER (parent), find_descendant_callback, &dsearch);
return dsearch.child;
}
-
enum {
STYLE_MODIFY_FG_AS_SENSITIVE,
STYLE_MODIFY_BASE_AS_BG,
@@ -1138,7 +1027,6 @@ enum {
STYLE_MODIFY_NORMAL_BG_AS_BASE,
STYLE_MODIFY_BG_AS_ACTIVE,
};
-
static void
widget_modify_style (GtkWidget *widget)
{
@@ -1201,7 +1089,6 @@ widget_modify_style (GtkWidget *widget)
break;
}
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1213,7 +1100,6 @@ void
gxk_widget_modify_as_title (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!gxk_signal_handler_exists (widget, "realize", G_CALLBACK (widget_modify_style), NULL))
{
g_object_set_int (widget, "gxk-style-modify-type", STYLE_MODIFY_FG_AS_SENSITIVE);
@@ -1225,7 +1111,6 @@ gxk_widget_modify_as_title (GtkWidget *widget)
g_signal_connect_after (widget, "realize", G_CALLBACK (gxk_widget_make_insensitive), NULL);
}
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1238,7 +1123,6 @@ void
gxk_widget_modify_bg_as_base (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!gxk_signal_handler_exists (widget, "realize", G_CALLBACK (widget_modify_style), NULL))
{
g_object_set_int (widget, "gxk-style-modify-type", STYLE_MODIFY_BG_AS_BASE);
@@ -1247,7 +1131,6 @@ gxk_widget_modify_bg_as_base (GtkWidget *widget)
widget_modify_style (widget);
}
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1258,7 +1141,6 @@ void
gxk_widget_modify_normal_bg_as_base (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!gxk_signal_handler_exists (widget, "realize", G_CALLBACK (widget_modify_style), NULL))
{
g_object_set_int (widget, "gxk-style-modify-type", STYLE_MODIFY_NORMAL_BG_AS_BASE);
@@ -1267,7 +1149,6 @@ gxk_widget_modify_normal_bg_as_base (GtkWidget *widget)
widget_modify_style (widget);
}
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1281,7 +1162,6 @@ void
gxk_widget_modify_base_as_bg (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!gxk_signal_handler_exists (widget, "realize", G_CALLBACK (widget_modify_style), NULL))
{
g_object_set_int (widget, "gxk-style-modify-type", STYLE_MODIFY_BASE_AS_BG);
@@ -1290,7 +1170,6 @@ gxk_widget_modify_base_as_bg (GtkWidget *widget)
widget_modify_style (widget);
}
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1301,7 +1180,6 @@ void
gxk_widget_modify_bg_as_active (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!gxk_signal_handler_exists (widget, "realize", G_CALLBACK (widget_modify_style), NULL))
{
g_object_set_int (widget, "gxk-style-modify-type", STYLE_MODIFY_BG_AS_ACTIVE);
@@ -1310,17 +1188,14 @@ gxk_widget_modify_bg_as_active (GtkWidget *widget)
widget_modify_style (widget);
}
}
-
static gboolean
expose_bg_clear (GtkWidget *widget,
GdkEventExpose *event)
{
gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_NORMAL,
GTK_SHADOW_NONE, &event->area, widget, "base", 0, 0, -1, -1);
-
return FALSE;
}
-
/**
* @param widget a valid GtkWidget
*
@@ -1334,12 +1209,10 @@ void
gxk_widget_force_bg_clear (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
gtk_widget_set_redraw_on_allocate (widget, TRUE);
if (!gxk_signal_handler_exists (widget, "expose_event", G_CALLBACK (expose_bg_clear), NULL))
g_signal_connect (widget, "expose_event", G_CALLBACK (expose_bg_clear), NULL);
}
-
/**
* @param widget a valid GtkWidget
* @param tooltip descriptive tooltip
@@ -1356,7 +1229,6 @@ gxk_widget_set_tooltip (gpointer widget,
gxk_widget_set_latent_tooltip ((GtkWidget*) widget, tooltip);
gtk_tooltips_set_tip (GXK_TOOLTIPS, (GtkWidget*) widget, tooltip, NULL);
}
-
/**
* @param widget a valid GtkWidget
* @param tooltip descriptive tooltip
@@ -1376,7 +1248,6 @@ gxk_widget_set_latent_tooltip (GtkWidget *widget,
tooltip = NULL;
g_object_set_data_full ((GObject*) widget, "gxk-widget-latent-tooltip", g_strdup (tooltip), g_free);
}
-
/**
* @param widget a valid GtkWidget
* @return descriptive tooltip
@@ -1390,7 +1261,6 @@ gxk_widget_get_latent_tooltip (GtkWidget *widget)
{
return (const char*) g_object_get_data ((GObject*) widget, "gxk-widget-latent-tooltip");
}
-
static gboolean
gxk_activate_accel_group (GtkWidget *widget,
GdkEventKey *event,
@@ -1410,7 +1280,6 @@ gxk_activate_accel_group (GtkWidget *widget,
}
return was_handled;
}
-
/**
* @param widget a valid GtkWidget
* @param accel_group a valid GtkAccelGroup
@@ -1427,11 +1296,9 @@ gxk_widget_activate_accel_group (GtkWidget *widget,
GtkAccelGroup *accel_group)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (accel_group)
{
g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
-
gtk_accel_group_lock (accel_group);
g_signal_connect_data (widget, "key_press_event",
G_CALLBACK (gxk_activate_accel_group),
@@ -1439,7 +1306,6 @@ gxk_widget_activate_accel_group (GtkWidget *widget,
(GClosureNotify) g_object_unref, GConnectFlags (0));
}
}
-
/**
* @param sgmode size group mode, one of @c GTK_SIZE_GROUP_NONE,
* @c GTK_SIZE_GROUP_HORIZONTAL, @c GTK_SIZE_GROUP_VERTICAL or
@@ -1460,7 +1326,6 @@ gxk_size_group (GtkSizeGroupMode sgmode,
GtkWidget *widget = (GtkWidget*) first_widget;
GtkSizeGroup *sgroup = gtk_size_group_new (sgmode);
va_list args;
-
va_start (args, first_widget);
while (widget)
{
@@ -1471,7 +1336,6 @@ gxk_size_group (GtkSizeGroupMode sgmode,
g_object_unref (sgroup);
}
}
-
/**
* @param strpath stringified GtkTreePath
*
@@ -1491,7 +1355,6 @@ gxk_tree_spath_index0 (const gchar *strpath)
}
return row;
}
-
/**
*
* This function is a replacement for gtk_tree_model_get_iter()
@@ -1515,8 +1378,6 @@ gxk_tree_model_get_iter (GtkTreeModel *tree_model,
}
return TRUE;
}
-
-
/**
* @param path valid GtkTreePath
*
@@ -1530,7 +1391,6 @@ gxk_tree_path_prev (GtkTreePath *path)
return FALSE;
return gtk_tree_path_prev (path);
}
-
/**
* @param tree_view valid GtkTreeView
* @param position column position (or -1 to append)
@@ -1556,36 +1416,28 @@ gxk_tree_view_add_column (GtkTreeView *tree_view,
{
guint n_cols;
va_list var_args;
-
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), 0);
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (column), 0);
g_return_val_if_fail (column->tree_view == NULL, 0);
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), 0);
-
g_object_ref (column);
g_object_ref (cell);
gtk_object_sink (GTK_OBJECT (column));
gtk_object_sink (GTK_OBJECT (cell));
gtk_tree_view_column_pack_start (column, cell, TRUE);
-
va_start (var_args, attrib_name);
while (attrib_name)
{
guint col = va_arg (var_args, guint);
-
gtk_tree_view_column_add_attribute (column, cell, attrib_name, col);
attrib_name = va_arg (var_args, const gchar*);
}
va_end (var_args);
-
n_cols = gtk_tree_view_insert_column (tree_view, column, position);
-
g_object_unref (column);
g_object_unref (cell);
-
return n_cols;
}
-
/**
* @param tree_view valid GtkTreeView
* @param n_cols number of columns to append
@@ -1623,9 +1475,7 @@ gxk_tree_view_append_text_columns (GtkTreeView *tree_view,
...)
{
va_list var_args;
-
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
-
va_start (var_args, n_cols);
while (n_cols--)
{
@@ -1633,14 +1483,12 @@ gxk_tree_view_append_text_columns (GtkTreeView *tree_view,
gchar *column_flags = va_arg (var_args, gchar*);
gfloat xalign = va_arg (var_args, gdouble);
gchar *title = va_arg (var_args, gchar*);
-
gxk_tree_view_add_text_column (tree_view, col, column_flags,
xalign, title, NULL,
NULL, NULL, GConnectFlags (0));
}
va_end (var_args);
}
-
static GtkTreeViewColumn*
tree_view_add_column (GtkTreeView *tree_view,
guint model_column,
@@ -1662,7 +1510,6 @@ tree_view_add_column (GtkTreeView *tree_view,
gboolean reorderable = FALSE, resizable = TRUE, sortable = FALSE, auto_popup = FALSE;
gchar *p, *column_flags = g_strconcat (" ", dcolumn_flags, ucolumn_flags, NULL);
guint fixed_width = 0, padding = 0;
-
for (p = column_flags; *p; p++)
switch (*p)
{
@@ -1704,7 +1551,6 @@ tree_view_add_column (GtkTreeView *tree_view,
auto_popup = TRUE;
break;
}
-
switch (column_type)
{
case 1: /* text */
@@ -1762,7 +1608,6 @@ tree_view_add_column (GtkTreeView *tree_view,
g_free (column_flags);
return tcol;
}
-
/**
* @param tree_view valid GtkTreeView
* @param model_column model column
@@ -1800,12 +1645,10 @@ gxk_tree_view_add_text_column (GtkTreeView *tree_view,
GConnectFlags cflags)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
return tree_view_add_column (tree_view, model_column, xalign, title, tooltip,
edited_callback, NULL, data, cflags,
1, "", column_flags);
}
-
/**
* @param tree_view valid GtkTreeView
* @param model_column model column
@@ -1837,12 +1680,10 @@ gxk_tree_view_add_popup_column (GtkTreeView *tree_view,
GConnectFlags cflags)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
return tree_view_add_column (tree_view, model_column, xalign, title, tooltip,
edited_callback, popup_callback, data, cflags,
2, "", column_flags);
}
-
/**
* @param tree_view valid GtkTreeView
* @param model_column model column
@@ -1875,12 +1716,10 @@ gxk_tree_view_add_toggle_column (GtkTreeView *tree_view,
GConnectFlags cflags)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
return tree_view_add_column (tree_view, model_column, xalign, title, tooltip,
toggled_callback, NULL, data, cflags,
3, "A", column_flags);
}
-
void
gxk_tree_view_set_editable (GtkTreeView *tview,
gboolean maybe_editable)
@@ -1913,7 +1752,6 @@ gxk_tree_view_set_editable (GtkTreeView *tview,
tcol = (GtkTreeViewColumn*) g_list_pop_head (&clist);
}
}
-
static void
fixup_tcolumn_title (GtkWidget *widget,
const gchar *tooltip)
@@ -1923,7 +1761,6 @@ fixup_tcolumn_title (GtkWidget *widget,
if (GTK_IS_BUTTON (widget))
gxk_widget_set_tooltip (widget, tooltip);
}
-
/**
* @param tree_column valid GtkTreeViewColumn
* @param title column title
@@ -1941,9 +1778,7 @@ gxk_tree_view_column_set_tip_title (GtkTreeViewColumn *tree_column,
const gchar *tooltip)
{
GtkWidget *label;
-
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
-
gtk_tree_view_column_set_title (tree_column, title);
label = (GtkWidget*) g_object_new (GTK_TYPE_LABEL,
"visible", TRUE,
@@ -1955,7 +1790,6 @@ gxk_tree_view_column_set_tip_title (GtkTreeViewColumn *tree_column,
GConnectFlags (0));
gtk_tree_view_column_set_widget (tree_column, label);
}
-
/**
* @param selection GtkTreeSelection to modify
* @param str_path a stringified GtkTreePath
@@ -1967,15 +1801,12 @@ gxk_tree_selection_select_spath (GtkTreeSelection *selection,
const gchar *str_path)
{
GtkTreePath *path;
-
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (str_path != NULL);
-
path = gtk_tree_path_new_from_string (str_path);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
}
-
/**
* @param selection GtkTreeSelection to modify
* @param str_path a stringified GtkTreePath
@@ -1987,15 +1818,12 @@ gxk_tree_selection_unselect_spath (GtkTreeSelection *selection,
const gchar *str_path)
{
GtkTreePath *path;
-
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (str_path != NULL);
-
path = gtk_tree_path_new_from_string (str_path);
gtk_tree_selection_unselect_path (selection, path);
gtk_tree_path_free (path);
}
-
/**
* @param selection GtkTreeSelection to modify
* @param ...: GtkTreePath indices
@@ -2011,9 +1839,7 @@ gxk_tree_selection_select_ipath (GtkTreeSelection *selection,
GtkTreePath *path;
va_list args;
gint i;
-
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
-
path = gtk_tree_path_new ();
i = first_index;
va_start (args, first_index);
@@ -2026,7 +1852,6 @@ gxk_tree_selection_select_ipath (GtkTreeSelection *selection,
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
}
-
/**
* @param selection GtkTreeSelection to modify
* @param ...: GtkTreePath indices
@@ -2042,9 +1867,7 @@ gxk_tree_selection_unselect_ipath (GtkTreeSelection *selection,
GtkTreePath *path;
va_list args;
gint i;
-
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
-
path = gtk_tree_path_new ();
i = first_index;
va_start (args, first_index);
@@ -2057,7 +1880,6 @@ gxk_tree_selection_unselect_ipath (GtkTreeSelection *selection,
gtk_tree_selection_unselect_path (selection, path);
gtk_tree_path_free (path);
}
-
void
gxk_tree_view_select_index (GtkTreeView *tview,
guint index)
@@ -2076,18 +1898,15 @@ gxk_tree_view_select_index (GtkTreeView *tview,
}
gtk_tree_path_free (path);
}
-
static GSList *browse_selection_queue = NULL;
static guint browse_selection_handler_id = 0;
static GtkTreeSelection *browse_selection_ignore = NULL;
-
static void
browse_selection_weak_notify (gpointer data,
GObject *object)
{
browse_selection_queue = g_slist_remove (browse_selection_queue, object);
}
-
static gboolean
browse_selection_handler (gpointer data)
{
@@ -2166,7 +1985,6 @@ browse_selection_handler (gpointer data)
GDK_THREADS_LEAVE ();
return FALSE;
}
-
static void
browse_selection_changed (GtkTreeSelection *selection)
{
@@ -2186,7 +2004,6 @@ browse_selection_changed (GtkTreeSelection *selection)
browse_selection_handler_id = g_idle_add_full (G_PRIORITY_DEFAULT, browse_selection_handler, NULL, NULL);
}
}
-
/**
* @param selection GtkTreeSelection to watch
* @param model tree model used with @a selection
@@ -2207,7 +2024,6 @@ gxk_tree_selection_force_browse (GtkTreeSelection *selection,
g_signal_connect_object (model, "row-inserted", G_CALLBACK (browse_selection_changed), selection, G_CONNECT_SWAPPED);
browse_selection_changed (selection);
}
-
/**
* @param tree valid GtkTreeView
* @param x_p x position
@@ -2223,9 +2039,7 @@ gxk_tree_view_get_bin_window_pos (GtkTreeView *tree,
{
GdkWindow *window;
gint ax = 0, ay = 0;
-
g_return_if_fail (GTK_IS_TREE_VIEW (tree));
-
window = gtk_tree_view_get_bin_window (tree);
if (window)
{
@@ -2245,7 +2059,6 @@ gxk_tree_view_get_bin_window_pos (GtkTreeView *tree,
if (y_p)
*y_p = ay;
}
-
/**
* @param tree valid GtkTreeView
* @param row row to retrieve area coordinates for
@@ -2264,9 +2077,7 @@ gxk_tree_view_get_row_area (GtkTreeView *tree,
gboolean content_area)
{
GdkRectangle rect = { 0, 0, 0, 0 };
-
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree), FALSE);
-
if (row >= 0)
{
GtkTreePath *path = gtk_tree_path_new ();
@@ -2291,7 +2102,6 @@ gxk_tree_view_get_row_area (GtkTreeView *tree,
}
return FALSE; /* no row */
}
-
/**
* @param tree valid GtkTreeView
* @param row row to focus
@@ -2304,15 +2114,12 @@ gxk_tree_view_focus_row (GtkTreeView *tree,
gint row)
{
GtkTreePath *path;
-
g_return_if_fail (GTK_IS_TREE_VIEW (tree));
-
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, row);
gtk_tree_view_set_cursor (tree, path, NULL, FALSE);
gtk_tree_path_free (path);
}
-
/**
* @param tree valid GtkTreeView
* @param row row to test
@@ -2325,7 +2132,6 @@ gxk_tree_view_is_row_selected (GtkTreeView *tree,
gint row)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree), FALSE);
-
if (row >= 0)
{
GtkTreePath *path = gtk_tree_path_new ();
@@ -2338,7 +2144,6 @@ gxk_tree_view_is_row_selected (GtkTreeView *tree,
}
return FALSE;
}
-
/**
* @param tree valid GtkTreeView
* @return first selected row or -1
@@ -2352,9 +2157,7 @@ gxk_tree_view_get_selected_row (GtkTreeView *tree)
GtkTreeModel *model;
GtkTreeIter iter;
gint row = -1;
-
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree), -1);
-
if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (tree),
&model, &iter))
{
@@ -2365,7 +2168,6 @@ gxk_tree_view_get_selected_row (GtkTreeView *tree)
}
return row;
}
-
/**
* @param tree valid GtkTreeView
* @param y bin window y coordinate
@@ -2383,9 +2185,7 @@ gxk_tree_view_get_row_from_coord (GtkTreeView *tree,
{
GtkTreePath *path = NULL;
gint row = -1, outside = FALSE;
-
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree), FALSE);
-
if (!gtk_tree_view_get_path_at_pos (tree, GTK_WIDGET (tree)->allocation.width / 2,
y, &path, NULL, NULL, NULL))
{
@@ -2431,7 +2231,6 @@ gxk_tree_view_get_row_from_coord (GtkTreeView *tree,
*row_p = row;
return row >= 0 && !outside;
}
-
/**
* @param instance object instance with signals
* @param detailed_signal signal name
@@ -2453,11 +2252,9 @@ gxk_signal_handler_exists (gpointer instance,
{
guint signal_id;
GQuark detail = 0;
-
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), FALSE);
g_return_val_if_fail (detailed_signal != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
-
if (detailed_signal && g_signal_parse_name (detailed_signal, G_TYPE_FROM_INSTANCE (instance),
&signal_id, &detail, FALSE))
{
@@ -2476,7 +2273,6 @@ gxk_signal_handler_exists (gpointer instance,
g_warning ("%s: signal name \"%s\" is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
return FALSE;
}
-
/**
* @param instance object instance with signals
* @param detailed_signal signal name
@@ -2498,11 +2294,9 @@ gxk_signal_handler_pending (gpointer instance,
{
guint signal_id;
GQuark detail = 0;
-
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), FALSE);
g_return_val_if_fail (detailed_signal != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
-
if (detailed_signal && g_signal_parse_name (detailed_signal, G_TYPE_FROM_INSTANCE (instance),
&signal_id, &detail, FALSE))
{
@@ -2521,7 +2315,6 @@ gxk_signal_handler_pending (gpointer instance,
g_warning ("%s: signal name \"%s\" is invalid for instance `%p'", G_STRLOC, detailed_signal, instance);
return FALSE;
}
-
/* --- Gtk bug fixes --- */
/**
* @param ecell valid GtkCellEditable
@@ -2534,12 +2327,10 @@ gboolean
gxk_cell_editable_canceled (GtkCellEditable *ecell)
{
g_return_val_if_fail (GTK_IS_CELL_EDITABLE (ecell), FALSE);
-
if (GTK_IS_ENTRY (ecell))
return GTK_ENTRY (ecell)->editing_canceled;
return FALSE;
}
-
/**
* @param ecell valid GtkCellEditable
* @return returns FALSE
@@ -2552,14 +2343,12 @@ void
gxk_cell_editable_is_focus_handler (GtkCellEditable *ecell)
{
g_return_if_fail (GTK_IS_CELL_EDITABLE (ecell));
-
if (!gtk_widget_is_focus (GTK_WIDGET (ecell)))
{
gtk_cell_editable_editing_done (ecell);
gtk_cell_editable_remove_widget (ecell);
}
}
-
static gchar*
path_fix_uline (const gchar *str)
{
@@ -2584,7 +2373,6 @@ path_fix_uline (const gchar *str)
*q = 0;
return path;
}
-
/**
* @param ifactory valid GtkItemFactory
* @param path item factory path
@@ -2621,7 +2409,6 @@ gxk_item_factory_sensitize (GtkItemFactory *ifactory,
}
return item;
}
-
/**
* @param ifactory valid GtkItemFactory
* @param path item factory path
@@ -2639,7 +2426,6 @@ gxk_item_factory_get_item (GtkItemFactory *ifactory,
g_free (p);
return widget;
}
-
/**
* @param ifactory valid GtkItemFactory
* @param path item factory path
@@ -2657,7 +2443,6 @@ gxk_item_factory_get_widget (GtkItemFactory *ifactory,
g_free (p);
return widget;
}
-
static void
requisition_to_aux_info (GtkWidget *widget,
GtkRequisition *requisition,
@@ -2666,7 +2451,6 @@ requisition_to_aux_info (GtkWidget *widget,
double *xyscale = (double*) data;
guint width = requisition->width;
guint height = requisition->height;
-
/* patch up requisition since gtk tends to allocate the viewport with the
* requested size minus vscrollbar->width or minus hscrollbar->height.
*/
@@ -2685,16 +2469,13 @@ requisition_to_aux_info (GtkWidget *widget,
height += requisition.height;
}
}
-
/* we constrain the requisition to a fraction of the screen size */
width = MIN (width, gdk_screen_width () * xyscale[0]);
height = MIN (height, gdk_screen_height () * xyscale[1]);
-
gtk_widget_set_size_request (widget,
xyscale[0] < 0 ? -1 : width,
xyscale[1] < 0 ? -1 : height);
}
-
/**
* @param widget valid GtkWidget
* @param xscale fractional factor for screen width
@@ -2716,14 +2497,12 @@ gxk_widget_proxy_requisition (GtkWidget *widget,
gdouble yscale)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
-
g_signal_handlers_disconnect_by_func (widget, (void*) requisition_to_aux_info, NULL);
double xyscale[2] = { xscale, yscale };
if (xscale >= 0 || yscale >= 0)
g_signal_connect_data (widget, "size-request", G_CALLBACK (requisition_to_aux_info),
g_memdup (xyscale, sizeof (xyscale)), (GClosureNotify) g_free, G_CONNECT_AFTER);
}
-
static void
scrolled_window_size_request_spare_space (GtkScrolledWindow *scwin,
GtkRequisition *requisition)
@@ -2743,7 +2522,6 @@ scrolled_window_size_request_spare_space (GtkScrolledWindow *scwin,
requisition->height = child_requisition.height;
}
}
-
/**
* @param scwin valid GtkScrolledWindow
*
@@ -2760,7 +2538,6 @@ gxk_scrolled_window_spare_space (GtkScrolledWindow*scwin)
if (!gxk_signal_handler_exists (scwin, "size-request", G_CALLBACK (scrolled_window_size_request_spare_space), NULL))
g_signal_connect (scwin, "size-request", G_CALLBACK (scrolled_window_size_request_spare_space), NULL);
}
-
/**
*
* @param scwin valid GtkScrolledWindow
@@ -2773,7 +2550,6 @@ gxk_scrolled_window_unspare_space (GtkScrolledWindow*scwin)
if (gxk_signal_handler_exists (scwin, "size-request", G_CALLBACK (scrolled_window_size_request_spare_space), NULL))
g_signal_handlers_disconnect_by_func (scwin, (void*) scrolled_window_size_request_spare_space, NULL);
}
-
/**
* @param child valid GtkWidget
* @param shadow_type shadow around the GtkViewport
@@ -2809,7 +2585,6 @@ gxk_scrolled_window_create (GtkWidget *child,
gxk_widget_proxy_requisition (viewport, xrequest, yrequest);
return scwin;
}
-
static void
request_hclient_height (GtkWidget *widget,
GtkRequisition *requisition,
@@ -2819,7 +2594,6 @@ request_hclient_height (GtkWidget *widget,
gtk_widget_size_request (client, &client_requisition);
requisition->height = client_requisition.width;
}
-
/**
* @param widget valid GtkWidget
* @param client valid GtkWidget
@@ -2834,7 +2608,6 @@ gxk_widget_request_hclient_height (GtkWidget *widget,
g_signal_handlers_disconnect_by_func (widget, (void*) request_hclient_height, client);
g_signal_connect_after (widget, "size_request", G_CALLBACK (request_hclient_height), client);
}
-
static void
request_vclient_width (GtkWidget *widget,
GtkRequisition *requisition,
@@ -2844,7 +2617,6 @@ request_vclient_width (GtkWidget *widget,
gtk_widget_size_request (client, &client_requisition);
requisition->width = client_requisition.height;
}
-
/**
* @param widget valid GtkWidget
* @param client valid GtkWidget
@@ -2859,7 +2631,6 @@ gxk_widget_request_vclient_width (GtkWidget *widget,
g_signal_handlers_disconnect_by_func (widget, (void*) request_vclient_width, client);
g_signal_connect_after (widget, "size_request", G_CALLBACK (request_vclient_width), client);
}
-
/**
* @param widget valid GtkWidget
* @param ancestor valid GtkWidget
@@ -2876,7 +2647,6 @@ gxk_widget_has_ancestor (gpointer widget,
GtkWidget *w = (GtkWidget*) widget, *a = (GtkWidget*) ancestor;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (ancestor), FALSE);
-
while (w)
{
if (w == a)
@@ -2885,7 +2655,6 @@ gxk_widget_has_ancestor (gpointer widget,
}
return FALSE;
}
-
/**
* @param menu valid GtkMenu
* @param child an immediate child of @a menu
@@ -2902,7 +2671,6 @@ gxk_menu_set_active (GtkMenu *menu,
{
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_WIDGET (child));
-
gint nth = g_list_index (GTK_MENU_SHELL (menu)->children, child);
if (nth >= 0 && child != menu->old_active_menu_item)
{
@@ -2918,7 +2686,6 @@ gxk_menu_set_active (GtkMenu *menu,
#endif
}
}
-
/**
* @param widget valid GtkWidget
* @param sensitive whether @a widget should be sensitive
@@ -2957,7 +2724,6 @@ gxk_widget_regulate (GtkWidget *widget,
g_object_thaw_notify (G_OBJECT (widget));
}
}
-
/**
* @param widget valid GtkWidget
* @return TRUE if gxk_widget_regulate() uses @a active for @a widget
@@ -2973,7 +2739,6 @@ gxk_widget_regulate_uses_active (GtkWidget *widget)
GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (widget), "active");
return GTK_IS_MENU_ITEM (widget) || (pspec && pspec->value_type == G_TYPE_BOOLEAN);
}
-
/**
* @param window valid GtkWindow
* @return valid GtkAccelGroup
@@ -2994,7 +2759,6 @@ gxk_window_get_menu_accel_group (GtkWindow *window)
}
return agroup;
}
-
static GdkGeometry*
window_get_geometry (GtkWindow *window)
{
@@ -3008,7 +2772,6 @@ window_get_geometry (GtkWindow *window)
}
return geometry;
}
-
void
gxk_window_set_geometry_min_width (GtkWindow *window,
guint min_width)
@@ -3020,7 +2783,6 @@ gxk_window_set_geometry_min_width (GtkWindow *window,
gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, geometry, GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
}
}
-
void
gxk_window_set_geometry_min_height (GtkWindow *window,
guint min_height)
@@ -3032,7 +2794,6 @@ gxk_window_set_geometry_min_height (GtkWindow *window,
gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, geometry, GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
}
}
-
void
gxk_window_set_geometry_width_inc (GtkWindow *window,
guint width_increment)
@@ -3044,7 +2805,6 @@ gxk_window_set_geometry_width_inc (GtkWindow *window,
gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, geometry, GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
}
}
-
void
gxk_window_set_geometry_height_inc (GtkWindow *window,
guint height_increment)
@@ -3056,7 +2816,6 @@ gxk_window_set_geometry_height_inc (GtkWindow *window,
gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, geometry, GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
}
}
-
static void
adjust_visibility (GtkWidget *expander,
GParamSpec *pspec,
@@ -3070,7 +2829,6 @@ adjust_visibility (GtkWidget *expander,
else
gtk_widget_hide (widget);
}
-
/**
* @param expander valid GtkWidget with boolean ::expanded property
* @param widget valid GtkWidget
@@ -3086,7 +2844,6 @@ gxk_expander_connect_to_widget (GtkWidget *expander,
g_signal_connect_object (expander, "notify::expanded", G_CALLBACK (adjust_visibility), widget, GConnectFlags (0));
g_object_notify ((GObject*) expander, "expanded");
}
-
/**
* @param label a GtkLabel
* @param ... a list of PangoAttrType and value pairs terminated by -1.
@@ -3112,7 +2869,6 @@ gxk_label_set_attributes (GtkLabel *label,
* Copyright (C) 2000 Michael Natterer <mitch gimp org>
*/
g_return_if_fail (GTK_IS_LABEL (label));
-
va_list args;
va_start (args, label);
PangoAttrList *attrs = pango_attr_list_new ();
@@ -3120,7 +2876,6 @@ gxk_label_set_attributes (GtkLabel *label,
do
{
PangoAttrType attr_type = (PangoAttrType) va_arg (args, int); // PangoAttrType
-
switch (attr_type)
{
case PANGO_ATTR_LANGUAGE:
@@ -3150,7 +2905,6 @@ gxk_label_set_attributes (GtkLabel *label,
case PANGO_ATTR_FOREGROUND:
{
const PangoColor *color = va_arg (args, const PangoColor *);
-
attr = pango_attr_foreground_new (color->red,
color->green,
color->blue);
@@ -3159,7 +2913,6 @@ gxk_label_set_attributes (GtkLabel *label,
case PANGO_ATTR_BACKGROUND:
{
const PangoColor *color = va_arg (args, const PangoColor *);
-
attr = pango_attr_background_new (color->red,
color->green,
color->blue);
@@ -3197,8 +2950,6 @@ gxk_label_set_attributes (GtkLabel *label,
gtk_label_set_attributes (label, attrs);
pango_attr_list_unref (attrs);
}
-
-
guint
gxk_container_get_insertion_slot (GtkContainer *container)
{
@@ -3218,7 +2969,6 @@ gxk_container_get_insertion_slot (GtkContainer *container)
g_object_set_data_full ((GObject*) container, "gxk-container-slots", slots, g_free);
return n_slots;
}
-
void
gxk_container_slot_reorder_child (GtkContainer *container,
GtkWidget *widget,
@@ -3241,7 +2991,6 @@ gxk_container_slot_reorder_child (GtkContainer *container,
slots[i]++;
}
}
-
/**
* @param window the window receiving the grab
* @param owner_events if TRUE, events will be reported relative to @a window
@@ -3274,7 +3023,6 @@ gxk_grab_pointer_and_keyboard (GdkWindow *window,
}
return FALSE;
}
-
/**
* @param window window pointer was previously grabed on
*
@@ -3292,7 +3040,6 @@ gxk_ungrab_pointer_and_keyboard (GdkWindow *window,
gdk_display_pointer_ungrab (display, time);
gdk_display_keyboard_ungrab (display, time);
}
-
/**
* @param menu valid GtkMenu
* @return TRUE if @a menu contains selectable items
@@ -3316,7 +3063,6 @@ gxk_menu_check_sensitive (GtkMenu *menu)
}
return FALSE;
}
-
static void
submenu_adjust_sensitivity (GtkMenu *menu)
{
@@ -3334,7 +3080,6 @@ submenu_adjust_sensitivity (GtkMenu *menu)
}
}
}
-
static void
gxk_menu_refetch_accel_group (GtkMenu *menu)
{
@@ -3342,7 +3087,6 @@ gxk_menu_refetch_accel_group (GtkMenu *menu)
if (GTK_IS_WINDOW (toplevel))
gtk_menu_set_accel_group (menu, gxk_window_get_menu_accel_group ((GtkWindow*) toplevel));
}
-
/**
* @param menu valid GtkMenu
* @param menu_item valid GtkMenuItem
@@ -3365,11 +3109,8 @@ gxk_menu_attach_as_submenu (GtkMenu *menu,
{
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
-
gtk_menu_item_set_submenu (menu_item, GTK_WIDGET (menu));
-
gxk_widget_proxy_hierarchy_changed_to_attached (GTK_WIDGET (menu_item));
-
if (!gxk_signal_handler_exists (menu, "parent-set", G_CALLBACK (submenu_adjust_sensitivity), NULL))
g_object_connect (menu,
"signal_after::parent-set", submenu_adjust_sensitivity, NULL,
@@ -3378,7 +3119,6 @@ gxk_menu_attach_as_submenu (GtkMenu *menu,
NULL);
submenu_adjust_sensitivity (menu);
}
-
/**
* @param option_menu valid GtkOptionMenu
* @param menu valid GtkMenu
@@ -3397,12 +3137,9 @@ gxk_option_menu_set_menu (GtkOptionMenu *option_menu,
{
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
g_return_if_fail (GTK_IS_MENU (menu));
-
gtk_option_menu_set_menu (option_menu, GTK_WIDGET (menu));
-
gxk_widget_proxy_hierarchy_changed_to_attached (GTK_WIDGET (option_menu));
}
-
static void
popup_menus_detach (gpointer data)
{
@@ -3414,7 +3151,6 @@ popup_menus_detach (gpointer data)
gtk_menu_detach (menu);
}
}
-
static void
popup_menu_detacher (GtkWidget *widget,
GtkMenu *menu)
@@ -3430,7 +3166,6 @@ popup_menu_detacher (GtkWidget *widget,
if (mdfunc)
mdfunc (widget, menu);
}
-
/**
* @param menu valid GtkMenu
* @param menu_item valid GtkMenuItem
@@ -3445,16 +3180,13 @@ gxk_menu_attach_as_popup_with_func (GtkMenu *menu,
{
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_WIDGET (widget));
-
GList *menu_list = (GList*) g_object_steal_data ((GObject*) widget, "GxkWidget-popup-menus");
menu_list = g_list_prepend (menu_list, menu);
g_object_set_data_full ((GObject*) widget, "GxkWidget-popup-menus", menu_list, popup_menus_detach);
g_object_set_data ((GObject*) menu, "gxk-GtkMenuDetachFunc", (void*) mdfunc);
gtk_menu_attach_to_widget (menu, widget, popup_menu_detacher);
-
gxk_widget_proxy_hierarchy_changed_to_attached (widget);
}
-
/**
* @param menu valid GtkMenu
* @param menu_item valid GtkMenuItem
@@ -3473,13 +3205,11 @@ gxk_menu_attach_as_popup (GtkMenu *menu,
{
gxk_menu_attach_as_popup_with_func (menu, widget, NULL);
}
-
typedef struct {
gint x, y, pushed_x, pushed_y;
guint pushed_in : 1;
guint pushable : 1;
} PopupData;
-
static gboolean
menu_position_unpushed (GtkMenu *menu,
gint *x,
@@ -3496,7 +3226,6 @@ menu_position_unpushed (GtkMenu *menu,
else
return TRUE;
}
-
static void
menu_position_pushed_in (GtkMenu *menu,
gint *x,
@@ -3517,7 +3246,6 @@ menu_position_pushed_in (GtkMenu *menu,
}
}
}
-
static void
menu_position_func (GtkMenu *menu,
gint *x,
@@ -3564,7 +3292,6 @@ menu_position_func (GtkMenu *menu,
}
}
}
-
void
gxk_menu_popup (GtkMenu *menu,
gint x,
@@ -3578,7 +3305,6 @@ gxk_menu_popup (GtkMenu *menu,
pdata->y = y;
gtk_menu_popup (menu, NULL, NULL, menu_position_func, pdata, mouse_button, time);
}
-
void
gxk_menu_popup_pushable (GtkMenu *menu,
gint x,
@@ -3597,7 +3323,6 @@ gxk_menu_popup_pushable (GtkMenu *menu,
pdata->pushable = TRUE;
gtk_menu_popup (menu, NULL, NULL, menu_position_func, pdata, mouse_button, time);
}
-
void
gxk_menu_popup_pushed_in (GtkMenu *menu,
gint pushed_x,
@@ -3612,7 +3337,6 @@ gxk_menu_popup_pushed_in (GtkMenu *menu,
pdata->pushed_in = TRUE;
gtk_menu_popup (menu, NULL, NULL, menu_position_func, pdata, mouse_button, time);
}
-
static GtkWidget*
widget_find_level_ordered (GtkWidget *widget,
const gchar *name)
@@ -3651,7 +3375,6 @@ widget_find_level_ordered (GtkWidget *widget,
}
return NULL;
}
-
/**
* @param toplevel valid GtkWidget
* @param name name of the widget being looked for
@@ -3672,10 +3395,8 @@ gxk_widget_find_level_ordered (GtkWidget *toplevel,
{
g_return_val_if_fail (GTK_IS_WIDGET (toplevel), NULL);
g_return_val_if_fail (name != NULL, NULL);
-
return widget_find_level_ordered (toplevel, name);
}
-
/**
* @param widget valid GtkWidget
*
@@ -3704,7 +3425,6 @@ gxk_widget_get_attach_toplevel (GtkWidget *widget)
} while (parent);
return widget;
}
-
static void
widget_add_font_requisition (GtkWidget *widget,
GtkRequisition *requisition)
@@ -3719,7 +3439,6 @@ widget_add_font_requisition (GtkWidget *widget,
requisition->width += PANGO_PIXELS (points);
pango_font_metrics_unref (metrics);
}
-
/**
* @param widget valid GtkWidget
* @param n_chars number of characters to request space for
@@ -3742,7 +3461,6 @@ gxk_widget_add_font_requisition (GtkWidget *widget,
g_signal_connect_after (widget, "size-request", G_CALLBACK (widget_add_font_requisition), NULL);
gtk_widget_queue_resize (widget);
}
-
/**
* @param widget valid GtkWidget
* @return custom options set on the widget
@@ -3756,7 +3474,6 @@ gxk_widget_get_options (gpointer widget)
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return (const char*) g_object_get_data ((GObject*) widget, "GxkWidget-options");
}
-
/**
* @param widget valid GtkWidget
* @param option option to add to widget
@@ -3798,7 +3515,6 @@ gxk_widget_add_option (gpointer widget,
g_object_set_data_full ((GObject*) widget, "GxkWidget-options", s, g_free);
}
}
-
/**
* @param widget valid GtkWidget
* @param option option to check for
@@ -3815,19 +3531,15 @@ gxk_widget_check_option (gpointer widget,
options = (const char*) g_object_get_data ((GObject*) widget, "GxkWidget-options");
return g_option_check (options, option);
}
-
GtkWidget*
gxk_file_selection_split (GtkFileSelection *fs,
GtkWidget **bbox_p)
{
GtkWidget *main_vbox;
GtkWidget *hbox;
-
g_return_val_if_fail (GTK_IS_FILE_SELECTION (fs), NULL);
-
/* nuke GUI junk */
gtk_file_selection_hide_fileop_buttons (fs);
-
/* fix spacing and borders */
gtk_container_set_border_width (GTK_CONTAINER (fs), 0);
gtk_widget_ref (fs->main_vbox);
@@ -3846,11 +3558,9 @@ gxk_file_selection_split (GtkFileSelection *fs,
NULL);
gtk_box_pack_start (GTK_BOX (main_vbox), fs->main_vbox, TRUE, TRUE, 0);
gtk_widget_unref (fs->main_vbox);
-
/* fixup focus and default widgets */
gtk_widget_grab_default (fs->ok_button);
gtk_widget_grab_focus (fs->selection_entry);
-
/* use an ordinary HBox as button container */
gtk_widget_hide (fs->ok_button->parent);
hbox = gtk_widget_new (GTK_TYPE_HBOX,
@@ -3865,19 +3575,15 @@ gxk_file_selection_split (GtkFileSelection *fs,
gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
gtk_widget_reparent (fs->ok_button, hbox);
gtk_widget_reparent (fs->cancel_button, hbox);
-
/* fix the action_area packing so we can customize children */
gtk_box_set_child_packing (GTK_BOX (fs->action_area->parent),
fs->action_area,
FALSE, TRUE,
5, GTK_PACK_START);
-
/* fs life cycle */
g_signal_connect_object (main_vbox, "destroy", G_CALLBACK (gtk_widget_destroy), fs, G_CONNECT_SWAPPED);
-
return main_vbox;
}
-
/**
* @param fs valid GtkFileSelection
* @return new toplevel VBox of the file selection
@@ -3895,18 +3601,14 @@ GtkWidget*
gxk_file_selection_heal (GtkFileSelection *fs)
{
GtkWidget *any, *main_box;
-
main_box = gxk_file_selection_split (fs, NULL);
-
/* add obligatory button seperator */
any = (GtkWidget*) g_object_new (GTK_TYPE_HSEPARATOR,
"visible", TRUE,
NULL);
gtk_box_pack_end (GTK_BOX (main_box), any, FALSE, TRUE, 0);
-
return main_box;
}
-
/* --- zlib support --- */
#include <zlib.h>
gchar*
@@ -3919,7 +3621,6 @@ gxk_zfile_uncompress (guint uncompressed_size,
guint8 *text = (guint8*) g_malloc (len);
gint result;
const gchar *err;
-
result = uncompress (text, &dlen, cdata, cdata_size);
switch (result)
{
@@ -3945,7 +3646,6 @@ gxk_zfile_uncompress (guint uncompressed_size,
}
if (err)
g_error ("while decompressing (%p, %u): %s", cdata, cdata_size, err);
-
text[dlen] = 0;
return (char*) text;
}
diff --git a/beast-gtk/gxk/gxkutils.hh b/beast-gtk/gxk/gxkutils.hh
index e8ce742..053653e 100644
--- a/beast-gtk/gxk/gxkutils.hh
+++ b/beast-gtk/gxk/gxkutils.hh
@@ -1,18 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GXK_UTILS_H__
#define __GXK_UTILS_H__
-
#include <gxk/gxkglobals.hh>
-
G_BEGIN_DECLS
-
/* --- generated includes --- */
/* type IDs */
#include <gxk/gxkgentypes.h>
/* marshallers */
#include <gxk/gxkmarshal.h>
-
-
/* --- Gtk+ workarounds and amendments --- */
gboolean gxk_widget_ancestry_viewable (GtkWidget *widget);
void gxk_cell_editable_is_focus_handler (GtkCellEditable *ecell);
@@ -93,7 +88,6 @@ void gxk_expander_connect_to_widget (GtkWidget *expander,
GtkWidget *widget);
void gxk_label_set_attributes (GtkLabel *label,
...);
-
guint gxk_container_get_insertion_slot (GtkContainer *container);
void gxk_container_slot_reorder_child (GtkContainer *container,
GtkWidget *widget,
@@ -106,14 +100,10 @@ gboolean gxk_grab_pointer_and_keyboard (GdkWindow *window,
guint32 time);
void gxk_ungrab_pointer_and_keyboard (GdkWindow *window,
guint32 time);
-
-
/* --- GtkFileSelection workarounds --- */
GtkWidget* gxk_file_selection_heal (GtkFileSelection *fs);
GtkWidget* gxk_file_selection_split (GtkFileSelection *fs,
GtkWidget **bbox);
-
-
/* --- GObject convenience --- */
typedef struct {
const char *type_name;
@@ -135,21 +125,15 @@ glong g_object_get_long (gpointer object,
const gchar *name);
#define g_object_set_int g_object_set_long // FIXME
#define g_object_get_int g_object_get_long // FIXME
-
-
/* --- UTF8 helpers --- */
gchar* gxk_convert_latin1_to_utf8 (const gchar *string);
gchar* gxk_filename_to_utf8 (const gchar *string);
const gchar* gxk_factory_path_get_leaf (const gchar *path);
gchar* gxk_factory_path_unescape_uline (const gchar *path);
-
-
/* --- Gtk+ Utilities --- */
void gxk_widget_viewable_changed (GtkWidget *widget);
gboolean gxk_widget_viewable (GtkWidget *widget);
void gxk_widget_attached_hierarchy_changed (GtkWidget *widget);
-
-
/* --- Gdk convenience --- */
#define GXK_DEFAULT_CURSOR GDK_LAST_CURSOR ///< Indicates default (inherited) cursor
void gxk_window_set_cursor_type (GdkWindow *window,
@@ -171,7 +155,6 @@ void gxk_color_alloc (GdkColormap *colormap,
GdkColor gdk_color_from_rgb (guint rgb_value);
GdkColor gdk_color_from_argb (guint rgb_value);
GdkColor gdk_color_from_rgba (guint rgb_value);
-
/* --- Colors --- */
typedef struct {
double value;
@@ -187,7 +170,6 @@ guint gxk_color_dots_interpolate (GxkColorDots *cdots,
double value,
double saturation);
void gxk_color_dots_destroy (GxkColorDots *cdots);
-
/* --- Gtk convenience --- */
#define GTK_STYLE_THICKNESS(s,xy) ((s)-> xy##thickness)
void gxk_widget_make_insensitive (GtkWidget *widget);
@@ -221,12 +203,10 @@ GtkWidget* gxk_scrolled_window_create (GtkWidget *child,
GtkShadowType shadow_type,
gdouble xrequest,
gdouble yrequest);
-
/* functions to affect a widget tree's toplevel */
void gxk_toplevel_delete (GtkWidget *widget);
void gxk_toplevel_hide (GtkWidget *widget);
void gxk_toplevel_activate_default (GtkWidget *widget);
-
/* widget utilities */
GtkWidget* gxk_parent_find_descendant (GtkWidget *parent,
GType descendant_type);
@@ -246,7 +226,6 @@ void gxk_widget_activate_accel_group (GtkWidget *widget,
void gxk_size_group (GtkSizeGroupMode sgmode,
gpointer first_widget,
...) G_GNUC_NULL_TERMINATED;
-
/* tree view convenience */
gint gxk_tree_spath_index0 (const gchar *strpath);
gboolean gxk_tree_model_get_iter (GtkTreeModel *tree_model,
@@ -295,7 +274,6 @@ void gxk_tree_view_column_set_tip_title (GtkTreeViewColumn *tree
const gchar *tooltip);
void gxk_tree_view_set_editable (GtkTreeView *tview,
gboolean maybe_editable);
-
/* tree selection convenience */
void gxk_tree_selection_select_spath (GtkTreeSelection *selection,
const gchar *str_path);
@@ -327,7 +305,6 @@ void gxk_tree_view_focus_row (GtkTreeView *tree,
gboolean gxk_tree_view_is_row_selected (GtkTreeView *tree,
gint row);
gint gxk_tree_view_get_selected_row (GtkTreeView *tree);
-
/* --- signal convenience --- */
gboolean gxk_signal_handler_exists (gpointer instance,
const gchar *detailed_signal,
@@ -337,14 +314,9 @@ gboolean gxk_signal_handler_pending (gpointer instance,
const gchar *detailed_signal,
GCallback callback,
gpointer data);
-
-
/* --- zlib support --- */
gchar* gxk_zfile_uncompress (guint uncompressed_size,
const unsigned char *cdata,
guint cdata_size);
-
-
G_END_DECLS
-
#endif /* __GXK_UTILS_H__ */
diff --git a/beast-gtk/gxk/splinetest.cc b/beast-gtk/gxk/splinetest.cc
index e621714..29e5a6f 100644
--- a/beast-gtk/gxk/splinetest.cc
+++ b/beast-gtk/gxk/splinetest.cc
@@ -3,7 +3,6 @@
#include <math.h>
#include "gxk/gxkspline.hh"
#include <stdlib.h>
-
static void
spline_test (GxkSpline *spline,
guint interval_steps,
@@ -27,7 +26,6 @@ spline_test (GxkSpline *spline,
}
}
}
-
static void
print_spline (guint n_points,
const GxkSplinePoint *points,
@@ -42,7 +40,6 @@ print_spline (guint n_points,
spline_test (spline, steps, swap);
gxk_spline_free (spline);
}
-
int
main (int argc,
char *argv[])
@@ -50,23 +47,18 @@ main (int argc,
/* GLib's thread and object systems */
g_thread_init (NULL);
g_type_init ();
-
/* initialize Gtk+ and go into threading mode */
gtk_init (&argc, &argv);
g_set_prgname ("splinetest"); /* overriding Gdk's program name */
GDK_THREADS_ENTER ();
-
/* initialize Gtk+ Extension Kit */
gxk_init ();
-
/* usage: splinetest <variant123> <nsteps> */
-
gint variant = 0, steps = 10;
if (argc > 1)
variant = atoi (argv[1]);
if (argc > 2)
steps = atoi (argv[2]);
-
if (ABS (variant) == 1)
{
GxkSplinePoint points[] = {
diff --git a/beast-gtk/testgui.cc b/beast-gtk/testgui.cc
index 7d1b8b1..cb9eb95 100644
--- a/beast-gtk/testgui.cc
+++ b/beast-gtk/testgui.cc
@@ -6,14 +6,11 @@
#include "bstparam.hh"
#include "bstgconfig.hh"
#include "bstskinconfig.hh"
-
/* --- FIXME: --- */
gboolean bst_developer_hints = FALSE;
gboolean bst_debug_extensions = FALSE;
gboolean bst_main_loop_running = TRUE;
void beast_show_about_box (void) {}
-
-
/* --- functions --- */
static gboolean
change_beam_value (gpointer data)
@@ -32,28 +29,22 @@ change_beam_value (gpointer data)
GDK_THREADS_LEAVE ();
return TRUE;
}
-
static GtkWidget*
create_db_meter (GtkOrientation orientation)
{
GtkWidget *widget = bst_db_meter_new (orientation, 0);
BstDBMeter *self = BST_DB_METER (widget);
BstDBBeam *dbbeam;
-
bst_db_meter_create_dashes (self, GTK_JUSTIFY_RIGHT, 2);
bst_db_meter_create_scale (self, 2);
bst_db_meter_create_dashes (self, GTK_JUSTIFY_FILL, 2);
-
dbbeam = bst_db_meter_create_beam (self, 2);
bst_db_meter_create_dashes (self, GTK_JUSTIFY_LEFT, 2);
g_timeout_add (50, change_beam_value, g_object_ref (dbbeam));
-
bst_db_meter_create_numbers (self, 2);
bst_db_meter_create_dashes (self, GTK_JUSTIFY_CENTER, 2);
-
return widget;
}
-
static void
build_db_meter_test (GtkBox *box)
{
@@ -69,7 +60,6 @@ build_db_meter_test (GtkBox *box)
bst_db_beam_set_value (bst_db_meter_get_beam ((BstDBMeter*) meter, 1), G_MAXDOUBLE);
gtk_box_pack_start (box, meter, TRUE, TRUE, 5);
}
-
int
main (int argc,
char *argv[])
@@ -79,37 +69,31 @@ main (int argc,
bind_textdomain_codeset (BST_GETTEXT_DOMAIN, "UTF-8");
textdomain (BST_GETTEXT_DOMAIN);
setlocale (LC_ALL, "");
-
/* initialize GLib */
g_thread_init (NULL);
g_type_init ();
-
/* initialize Sfi */
sfi_init (&argc, &argv, "TestGUI", NULL);
sfi_msg_allow ("misc");
/* ensure SFI can wake us up */
sfi_thread_set_name ("TestGUI");
sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup, g_main_context_default (), NULL);
-
/* initialize Gtk+ and enter threading mode */
gtk_init (&argc, &argv);
g_set_prgname ("testgui"); /* override Gdk's program name */
g_set_application_name ("TestGUI"); /* User visible name */
GDK_THREADS_ENTER ();
-
/* initialize Gtk+ Extension Kit */
gxk_init ();
/* add documentation search paths */
gxk_text_add_tsm_path (BST_PATH_DOCS);
gxk_text_add_tsm_path (BST_PATH_IMAGES);
gxk_text_add_tsm_path (".");
-
/* initialize BEAST GUI components */
_bst_init_utils ();
_bst_init_params ();
_bst_gconfig_init ();
_bst_skin_config_init ();
-
/* start BSE core and connect */
bse_init_async (&argc, &argv, "TestGUI", NULL);
sfi_glue_context_push (bse_init_glue_context ("TestGUI"));
@@ -119,7 +103,6 @@ main (int argc,
NULL, NULL, NULL);
g_source_attach (source, NULL);
g_source_unref (source);
-
GtkWidget *dialog = (GtkWidget*) gxk_dialog_new (NULL, NULL, GXK_DIALOG_DELETE_BUTTON, "Test Window", NULL);
g_object_connect (dialog, "signal::destroy", gtk_main_quit, NULL, NULL);
g_object_set (dialog,
@@ -133,15 +116,12 @@ main (int argc,
"border_width", 10,
"child", box,
NULL));
-
build_db_meter_test (GTK_BOX (box));
-
gtk_widget_show_now (dialog);
g_object_set (dialog,
"height-request", 25,
"width-request", 25,
NULL);
gtk_main ();
-
return 0;
}
diff --git a/beast-gtk/tsmview.cc b/beast-gtk/tsmview.cc
index 616c87a..829b679 100644
--- a/beast-gtk/tsmview.cc
+++ b/beast-gtk/tsmview.cc
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <gxk/gxk.hh>
-
#include "topconfig.h"
-
#include <string.h>
-
#define PRGNAME "tsmview"
-
/* --- functions --- */
static GtkWidget*
textget_handler (gpointer user_data,
@@ -19,7 +15,6 @@ textget_handler (gpointer user_data,
"label", element_name,
NULL);
}
-
int
main (int argc,
char *argv[])
@@ -33,9 +28,7 @@ main (int argc,
g_type_init ();
gtk_init (&argc, &argv);
gxk_init ();
-
gxk_text_register_textget_handler ("textget-label", textget_handler, NULL);
-
for (i = 1; i < argc; i++)
if (!flags && strcmp (argv[i], "--edit") == 0)
{
@@ -66,24 +59,18 @@ main (int argc,
title = g_strconcat (title, " ", argv[i], NULL);
g_free (str);
}
-
str = title;
title = g_strdup ("tsmview"); // g_strconcat (title, " - tsmview", NULL);
g_free (str);
-
dialog = (GtkWidget*) gxk_dialog_new (NULL, NULL, GXK_DIALOG_DELETE_BUTTON, title, NULL);
g_free (title);
-
g_object_connect (dialog, "signal::destroy", gtk_main_quit, NULL, NULL);
-
gxk_dialog_set_child (GXK_DIALOG (dialog), sctext);
-
g_object_set (dialog,
"default_width", 560,
"default_height", 640,
"visible", TRUE,
NULL);
gtk_main ();
-
return 0;
}
diff --git a/birnet/birnet-zintern.cc b/birnet/birnet-zintern.cc
index d5bcf72..8e3c1c1 100644
--- a/birnet/birnet-zintern.cc
+++ b/birnet/birnet-zintern.cc
@@ -5,18 +5,14 @@
#include <string.h>
#include <errno.h>
#include <zlib.h>
-
namespace Birnet {
-
static bool use_compression = FALSE;
static bool use_base_name = FALSE;
-
typedef struct {
uint pos;
bool pad;
} Config;
static Config config_init = { 0, 0 };
-
static inline void
print_uchar (Config *config,
uint8 d)
@@ -58,7 +54,6 @@ print_uchar (Config *config,
config->pad = FALSE;
return;
}
-
#define to_upper(c) ((c) >='a' && (c) <='z' ? (c) - 'a' + 'A' : (c))
#define is_alnum(c) (((c) >='A' && (c) <='Z') || ((c) >='a' && (c) <='z') || ((c) >='0' && (c) <='9'))
static String
@@ -72,7 +67,6 @@ to_cupper (const String &str)
s[i] = '_';
return s;
}
-
static void
gen_zfile (const char *name,
const char *file)
@@ -96,10 +90,8 @@ gen_zfile (const char *name,
dlen += fread (data + dlen, 1, mlen - dlen, f);
}
while (!feof (f));
-
if (ferror (f))
BIRNET_ERROR ("failed to read from \"%s\": %s", file, string_from_errno (errno).c_str());
-
if (use_compression)
{
int result;
@@ -130,30 +122,24 @@ gen_zfile (const char *name,
clen = dlen;
cdata = data;
}
-
g_print ("/* birnet-zintern file dump of %s */\n", file);
-
config = config_init;
printf ("#define %s_NAME \"", to_cupper (name).c_str());
for (i = 0; i < fname.size(); i++)
print_uchar (&config, fname[i]);
printf ("\"\n");
-
printf ("#define %s_SIZE (%u)\n", to_cupper (name).c_str(), dlen);
-
config = config_init;
printf ("static const unsigned char %s_DATA[%lu + 1] =\n", to_cupper (name).c_str(), clen);
printf ("( \"");
for (i = 0; i < clen; i++)
print_uchar (&config, cdata[i]);
printf ("\");\n");
-
fclose (f);
g_free (data);
if (cdata != data)
g_free (cdata);
}
-
static int
help (char *arg)
{
@@ -165,19 +151,16 @@ help (char *arg)
g_printerr ("containing inlined data blocks of the files given.\n");
return arg != NULL;
}
-
extern "C" int
main (int argc,
char *argv[])
{
GSList *plist = NULL;
-
InitValue ivalues[] = {
{ "stand-alone", "true" },
{ NULL }
};
birnet_init (&argc, &argv, NULL, ivalues);
-
for (int i = 1; i < argc; i++)
{
if (strcmp ("-z", argv[i]) == 0)
@@ -195,10 +178,8 @@ main (int argc,
else
plist = g_slist_append (plist, argv[i]);
}
-
if (argc <= 1)
return help (NULL);
-
while (plist && plist->next)
{
const char *name = (char*) plist->data;
@@ -211,8 +192,6 @@ main (int argc,
g_slist_free_1 (tmp);
gen_zfile (name, file);
}
-
return 0;
}
-
} // Birnet
diff --git a/birnet/birnet.hh b/birnet/birnet.hh
index 4a518a8..779e6ff 100644
--- a/birnet/birnet.hh
+++ b/birnet/birnet.hh
@@ -1,23 +1,18 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_H__
#define __BIRNET_H__
-
#include <birnet/birnetconfig.h>
#include <birnet/birnetcpu.hh>
#include <birnet/birnetdebugtools.hh>
-
#include <birnet/birnetmsg.hh>
-
#include <birnet/birnetmath.hh>
#include <birnet/birnetutf8.hh>
#include <birnet/birnetutils.hh>
#include <birnet/birnetthread.hh>
-
/**
* @namespace Birnet
* Library with utility functions, carried forward in Rapicorn: http://dev.testbit.eu/rapicorn/latest/
*/
namespace Birnet {}
-
#endif /* __BIRNET_H__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetcdefs.h b/birnet/birnetcdefs.h
index caecc48..110ffdc 100644
--- a/birnet/birnetcdefs.h
+++ b/birnet/birnetcdefs.h
@@ -1,16 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_CDEFS_H__
#define __BIRNET_CDEFS_H__
-
#include <stdbool.h>
#include <stddef.h> /* NULL */
#include <sys/types.h> /* uint, ssize */
#include <limits.h> /* {INT|CHAR|...}_{MIN|MAX} */
#include <float.h> /* {FLT|DBL}_{MIN|MAX|EPSILON} */
#include <birnet/birnetconfig.h>
-
BIRNET_EXTERN_C_BEGIN();
-
/* --- standard macros --- */
#ifndef FALSE
# define FALSE false
@@ -58,13 +55,11 @@ BIRNET_EXTERN_C_BEGIN();
# define UINT64_MAX (INT64_MAX * 2ULL + 1ULL)
#endif
#endif
-
/* --- likelyness hinting --- */
#define BIRNET__BOOL(expr) __extension__ ({ bool _birnet__bool; if (expr) _birnet__bool = 1; else _birnet__bool = 0; _birnet__bool; })
#define BIRNET_ISLIKELY(expr) __builtin_expect (BIRNET__BOOL (expr), 1)
#define BIRNET_UNLIKELY(expr) __builtin_expect (BIRNET__BOOL (expr), 0)
#define BIRNET_LIKELY BIRNET_ISLIKELY
-
/* --- assertions and runtime errors --- */
#define BIRNET_RETURN_IF_FAIL(e) do { if (BIRNET_ISLIKELY (e)) break; BIRNET__RUNTIME_PROBLEM ('R', BIRNET_LOG_DOMAIN, __FILE__, __LINE__, BIRNET_SIMPLE_FUNCTION, "%s", #e); return; } while (0)
#define BIRNET_RETURN_VAL_IF_FAIL(e,v) do { if (BIRNET_ISLIKELY (e)) break; BIRNET__RUNTIME_PROBLEM ('R', BIRNET_LOG_DOMAIN, __FILE__, __LINE__, BIRNET_SIMPLE_FUNCTION, "%s", #e); return v; } while (0)
@@ -73,7 +68,6 @@ BIRNET_EXTERN_C_BEGIN();
#define BIRNET_WARNING(...) do { BIRNET__RUNTIME_PROBLEM ('W', BIRNET_LOG_DOMAIN, __FILE__, __LINE__, BIRNET_SIMPLE_FUNCTION, __VA_ARGS__); } while (0)
#define BIRNET_ERROR(...) do { BIRNET__RUNTIME_PROBLEM ('E', BIRNET_LOG_DOMAIN, __FILE__, __LINE__, BIRNET_SIMPLE_FUNCTION, __VA_ARGS__); BIRNET_ABORT_NORETURN(); } while (0)
#define BIRNET_ABORT_NORETURN() birnet_abort_noreturn()
-
/* --- convenient aliases --- */
#ifdef _BIRNET_SOURCE_EXTENSIONS
#define ISLIKELY BIRNET_ISLIKELY
@@ -86,7 +80,6 @@ BIRNET_EXTERN_C_BEGIN();
#define WARNING BIRNET_WARNING
#define ERROR BIRNET_ERROR
#endif /* _BIRNET_SOURCE_EXTENSIONS */
-
/* --- preprocessor pasting --- */
#define BIRNET_CPP_PASTE4i(a,b,c,d) a ## b ## c ## d /* twofold indirection is required to expand macros like __LINE__ */
#define BIRNET_CPP_PASTE4(a,b,c,d) BIRNET_CPP_PASTE4i (a,b,c,d)
@@ -98,7 +91,6 @@ BIRNET_EXTERN_C_BEGIN();
#define BIRNET_STATIC_ASSERT(expr) BIRNET_STATIC_ASSERT_NAMED (expr, compile_time_assertion_failed)
#define BIRNET_STARTUP_ASSERTi(e, _N) namespace { static struct _N { inline _N() { BIRNET_ASSERT (e); } } _N; }
#define BIRNET_STARTUP_ASSERT(expr) BIRNET_STARTUP_ASSERTi (expr, BIRNET_CPP_PASTE2 (StartupAssertion, __LINE__))
-
/* --- attributes --- */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
#define BIRNET_PRETTY_FUNCTION (__PRETTY_FUNCTION__)
@@ -139,7 +131,6 @@ BIRNET_EXTERN_C_BEGIN();
#else
#define BIRNET_SIMPLE_FUNCTION BIRNET_PRETTY_FUNCTION
#endif
-
/* --- provide canonical integer types --- */
#if BIRNET_SIZEOF_SYS_TYPESH_UINT == 0
typedef unsigned int uint; /* for systems that don't define uint in types.h */
@@ -169,8 +160,6 @@ BIRNET_STATIC_ASSERT (sizeof (BirnetInt32) == 4);
BIRNET_STATIC_ASSERT (sizeof (BirnetInt64) == 8);
typedef BirnetUInt32 BirnetUnichar;
BIRNET_STATIC_ASSERT (sizeof (BirnetUnichar) == 4);
-
-
/* --- path handling --- */
#ifdef BIRNET_OS_WIN32
#define BIRNET_DIR_SEPARATOR '\\'
@@ -185,7 +174,6 @@ BIRNET_STATIC_ASSERT (sizeof (BirnetUnichar) == 4);
#endif /* !BIRNET_OS_WIN32 */
#define BIRNET_IS_DIR_SEPARATOR(c) ((c) == BIRNET_DIR_SEPARATOR)
#define BIRNET_IS_SEARCHPATH_SEPARATOR(c) ((c) == BIRNET_SEARCHPATH_SEPARATOR)
-
/* --- initialization --- */
typedef struct {
bool stand_alone; /* "stand-alone": no rcfiles, boot scripts, etc. */
@@ -193,13 +181,11 @@ typedef struct {
bool test_slow; /* run slow tests */
bool test_perf; /* run benchmarks, test performance */
} BirnetInitSettings;
-
typedef struct {
const char *value_name; /* value list ends with value_name == NULL */
const char *value_string;
long double value_num; /* valid if value_string == NULL */
} BirnetInitValue;
-
/* --- CPU info --- */
typedef struct {
/* architecture name */
@@ -211,7 +197,6 @@ typedef struct {
uint x86_mmx : 1, x86_mmxext : 1, x86_3dnow : 1, x86_3dnowext : 1;
uint x86_sse : 1, x86_sse2 : 1, x86_sse3 : 1, x86_sse4 : 1;
} BirnetCPUInfo;
-
/* --- Thread info --- */
typedef enum {
BIRNET_THREAD_UNKNOWN = '?',
@@ -235,7 +220,6 @@ typedef struct {
BirnetUInt64 cutime; /* user time of dead children */
BirnetUInt64 cstime; /* system time of dead children */
} BirnetThreadInfo;
-
/* --- threading ABI --- */
typedef struct _BirnetThread BirnetThread;
typedef void (*BirnetThreadFunc) (void *user_data);
@@ -347,7 +331,6 @@ typedef struct {
BirnetInt64 max_useconds);
void (*cond_destroy) (BirnetCond *cond);
} BirnetThreadTable;
-
/* --- implementation bits --- */
/* the above macros rely on a problem handler macro: */
// BIRNET__RUNTIME_PROBLEM(ErrorWarningReturnAssertNotreach,domain,file,line,funcname,exprformat,...); // noreturn cases: 'E', 'A', 'N'
@@ -363,7 +346,5 @@ extern inline void birnet_abort_noreturn (void) { while (1) *(void*volatile*)0;
#define BIRNET_MEMORY_BARRIER_RW(tht) do { } while (0)
#endif
BIRNET_EXTERN_C_END();
-
#endif /* __BIRNET_CDEFS_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetcpu.cc b/birnet/birnetcpu.cc
index 0bbb50d..002b105 100644
--- a/birnet/birnetcpu.cc
+++ b/birnet/birnetcpu.cc
@@ -4,9 +4,7 @@
#include <setjmp.h>
#include <signal.h>
#include <string.h>
-
namespace Birnet {
-
/* figure architecture name from compiler */
static const char*
get_arch_name (void)
@@ -49,7 +47,6 @@ get_arch_name (void)
return "unknown-arch";
#endif
}
-
/* --- X86 detection via CPUID --- */
#if defined __i386__
# define x86_has_cpuid() ({ \
@@ -106,16 +103,12 @@ get_arch_name (void)
# define x86_has_cpuid() (false)
# define x86_cpuid(input, eax, ebx, ecx, edx) do {} while (0)
#endif
-
-
static jmp_buf cpu_info_jmp_buf;
-
static void BIRNET_NORETURN
cpu_info_sigill_handler (int dummy)
{
longjmp (cpu_info_jmp_buf, 1);
}
-
static bool
get_x86_cpu_features (CPUInfo *ci,
char vendor[13])
@@ -124,7 +117,6 @@ get_x86_cpu_features (CPUInfo *ci,
/* check if the CPUID instruction is supported */
if (!x86_has_cpuid ())
return false;
-
/* query intel CPUID range */
unsigned int eax, ebx, ecx, edx;
x86_cpuid (0, eax, ebx, ecx, edx);
@@ -159,7 +151,6 @@ get_x86_cpu_features (CPUInfo *ci,
* "Intel Processor Identificaiton and the CPUID Instruction"
*/
}
-
/* query extended CPUID range */
x86_cpuid (0x80000000, eax, ebx, ecx, edx);
if (eax >= 0x80000001 && /* may query extended feature information */
@@ -177,7 +168,6 @@ get_x86_cpu_features (CPUInfo *ci,
* "AMD CPUID Specification"
*/
}
-
/* check system support for SSE */
if (ci->x86_sse)
{
@@ -200,18 +190,14 @@ get_x86_cpu_features (CPUInfo *ci,
}
sigaction (SIGILL, &old_action, NULL);
}
-
return true;
}
-
static CPUInfo cached_cpu_info; /* = 0; */
-
CPUInfo
cpu_info (void)
{
return cached_cpu_info;
}
-
void
_birnet_init_cpuinfo (void)
{
@@ -231,7 +217,6 @@ _birnet_init_cpuinfo (void)
}
cached_cpu_info = lci;
}
-
String
cpu_info_string (const CPUInfo &cpu_info)
{
@@ -290,5 +275,4 @@ cpu_info_string (const CPUInfo &cpu_info)
g_string_free (gstring, TRUE);
return retval;
}
-
} // Birnet
diff --git a/birnet/birnetcpu.hh b/birnet/birnetcpu.hh
index 0ddcb31..6fc37bc 100644
--- a/birnet/birnetcpu.hh
+++ b/birnet/birnetcpu.hh
@@ -1,21 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_CPU_HH__
#define __BIRNET_CPU_HH__
-
#include <birnet/birnetutils.hh>
-
namespace Birnet {
-
typedef BirnetCPUInfo CPUInfo;
-
/* --- functions --- */
CPUInfo cpu_info (void);
String cpu_info_string (const CPUInfo &cpu_info);
-
/* --- implementation --- */
void _birnet_init_cpuinfo (void);
-
} // Birnet
-
#endif /* __BIRNET_CPU_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetdebugtools.cc b/birnet/birnetdebugtools.cc
index af181b8..3685ee6 100644
--- a/birnet/birnetdebugtools.cc
+++ b/birnet/birnetdebugtools.cc
@@ -4,19 +4,14 @@
#include <syslog.h>
#include <errno.h>
#include <stdio.h>
-
#ifndef _ // FIXME
#define _(x) (x)
#endif
-
namespace Birnet {
-
DebugChannel::DebugChannel()
{}
-
DebugChannel::~DebugChannel ()
{}
-
struct DebugChannelFileAsync : public virtual DebugChannel, public virtual Thread {
FILE *fout;
uint skip_count;
@@ -86,12 +81,10 @@ struct DebugChannelFileAsync : public virtual DebugChannel, public virtual Threa
while (Thread::Self::sleep (15 * 1000));
}
};
-
DebugChannel*
DebugChannel::new_from_file_async (const String &filename)
{
DebugChannelFileAsync *dcfa = new DebugChannelFileAsync (filename);
return dcfa;
}
-
} // Birnet
diff --git a/birnet/birnetdebugtools.hh b/birnet/birnetdebugtools.hh
index 5eb2ef9..0b272b8 100644
--- a/birnet/birnetdebugtools.hh
+++ b/birnet/birnetdebugtools.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_DEBUG_TOOLS_HH__
#define __BIRNET_DEBUG_TOOLS_HH__
-
#include <birnet/birnetutils.hh>
#include <stdarg.h>
-
namespace Birnet {
-
class DebugChannel : public virtual ReferenceCountImpl {
BIRNET_PRIVATE_CLASS_COPY (DebugChannel);
protected:
@@ -18,7 +15,6 @@ public:
inline void printf (const char *format, ...) BIRNET_PRINTF (2, 3);
static DebugChannel* new_from_file_async (const String &filename);
};
-
inline void
DebugChannel::printf (const char *format,
...)
@@ -28,8 +24,6 @@ DebugChannel::printf (const char *format,
printf_valist (format, a);
va_end (a);
}
-
} // Birnet
-
#endif /* __BIRNET_DEBUG_TOOLS_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetmath.cc b/birnet/birnetmath.cc
index 99a1be2..0d49c4b 100644
--- a/birnet/birnetmath.cc
+++ b/birnet/birnetmath.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "birnetmath.hh"
-
namespace Birnet {
-
} // Birnet
diff --git a/birnet/birnetmath.hh b/birnet/birnetmath.hh
index 4336dd6..cda0588 100644
--- a/birnet/birnetmath.hh
+++ b/birnet/birnetmath.hh
@@ -1,19 +1,15 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_MATH_HH__
#define __BIRNET_MATH_HH__
-
#include <birnet/birnetutils.hh>
#include <math.h>
-
namespace Birnet {
-
/* --- double to integer --- */
inline int dtoi32 (double d) BIRNET_CONST;
inline int64 dtoi64 (double d) BIRNET_CONST;
inline int64 iround (double d) BIRNET_CONST;
inline int64 ifloor (double d) BIRNET_CONST;
inline int64 iceil (double d) BIRNET_CONST;
-
/* --- implementation bits --- */
inline int BIRNET_CONST
_dtoi32_generic (double d)
@@ -57,8 +53,6 @@ dtoi64 (double d)
inline int64 BIRNET_CONST iround (double d) { return dtoi64 (round (d)); }
inline int64 BIRNET_CONST ifloor (double d) { return dtoi64 (floor (d)); }
inline int64 BIRNET_CONST iceil (double d) { return dtoi64 (ceil (d)); }
-
} // Birnet
-
#endif /* __BIRNET_MATH_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetmsg.cc b/birnet/birnetmsg.cc
index b7cbd44..6a098b9 100644
--- a/birnet/birnetmsg.cc
+++ b/birnet/birnetmsg.cc
@@ -6,17 +6,13 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
-
#ifndef _ // FIXME
#define _(x) (x)
#endif
-
namespace Birnet {
-
Msg::Part::Part() :
ptype (0)
{}
-
void
Msg::Part::setup (uint8 _ptype,
String smsg)
@@ -24,7 +20,6 @@ Msg::Part::setup (uint8 _ptype,
ptype = _ptype;
string = smsg;
}
-
void
Msg::Part::setup (uint8 _ptype,
const char *format,
@@ -34,12 +29,9 @@ Msg::Part::setup (uint8 _ptype,
setup (_ptype, String (s));
g_free (s);
}
-
const Msg::Part &Msg::empty_part = Part();
-
volatile int Msg::n_msg_types = 0;
uint8 *volatile Msg::msg_type_bits = NULL;
-
struct MsgType {
/* this structure cannot use C++ types because it's not properly constructed */
const char *ident;
@@ -53,7 +45,6 @@ static MsgType* msg_types = NULL; /* cannot use a vector<> here, because of cons
static bool msg_log_to_stderr = true;
static uint msg_syslog_priority = 0; // LOG_USER | LOG_INFO;
static FILE *msg_log_file = NULL;
-
void
Msg::set_msg_type_L (uint mtype,
uint32 flags,
@@ -83,7 +74,6 @@ Msg::set_msg_type_L (uint mtype,
msg_type_bits[i / 8] &= ~(1 << i % 8);
}
}
-
void
Msg::init_standard_types()
{
@@ -124,7 +114,6 @@ Msg::init_standard_types()
mtype = register_type ("debug", NONE, "Debug");
set_msg_type_L (mtype, LOG_TO_STDERR, false);
}
-
/**
* @param ident message identifier
* @param default_ouput an existing SfiMsgType
@@ -197,14 +186,12 @@ Msg::register_type (const char *ident,
msg_mutex.unlock();
return mtype;
}
-
static struct AutoConstruct {
AutoConstruct()
{
Msg::register_type ("none", Msg::NONE, "");
}
} auto_construct;
-
/**
* @param ident message identifier, e.g. "error", "warning", "info", etc...
* @return corresponding Type or 0
@@ -222,7 +209,6 @@ Msg::lookup_type (const String &ident)
return Type (i);
return Msg::NONE;
}
-
void
Msg::enable (Type mtype)
{
@@ -230,7 +216,6 @@ Msg::enable (Type mtype)
if (mtype > 1 && mtype < (int) n_msg_types)
set_msg_type_L (mtype, msg_types[mtype].flags, true);
}
-
void
Msg::disable (Type mtype)
{
@@ -238,8 +223,6 @@ Msg::disable (Type mtype)
if (mtype > 1 && mtype < (int) n_msg_types)
set_msg_type_L (mtype, msg_types[mtype].flags, false);
}
-
-
/**
* @param type message type, e.g. Msg::ERROR, Msg::WARNING, Msg::INFO, etc...
* @return translated message identifier or NULL
@@ -256,7 +239,6 @@ Msg::type_ident (Type mtype)
return msg_types[mtype].ident;
return NULL;
}
-
/**
* @param type message type, e.g. Msg::ERROR, Msg::WARNING, Msg::INFO, etc...
* @return translated message identifier or NULL
@@ -274,7 +256,6 @@ Msg::type_label (Type mtype)
return msg_types[mtype].label;
return NULL;
}
-
uint32
Msg::type_flags (Type mtype)
{
@@ -284,7 +265,6 @@ Msg::type_flags (Type mtype)
flags = msg_types[mtype].flags;
return flags;
}
-
void
Msg::configure (Type mtype,
LogFlags log_mask,
@@ -294,7 +274,6 @@ Msg::configure (Type mtype,
if (mtype > 1 && mtype < n_msg_types)
set_msg_type_L (mtype, log_mask, msg_types[mtype].enabled);
}
-
void
Msg::key_list_change_L (const String &keylist,
bool isenabled)
@@ -316,7 +295,6 @@ Msg::key_list_change_L (const String &keylist,
set_msg_type_L (i, msg_types[i].flags, isenabled);
return;
}
-
/* walk all kyes */
String::size_type k = 1;
String::size_type c = s.find (':', k);
@@ -336,7 +314,6 @@ Msg::key_list_change_L (const String &keylist,
c = s.find (':', k);
}
}
-
void
Msg::allow_msgs (const String &key)
{
@@ -351,7 +328,6 @@ Msg::allow_msgs (const String &key)
check (i));
#endif
}
-
void
Msg::deny_msgs (const String &key)
{
@@ -359,7 +335,6 @@ Msg::deny_msgs (const String &key)
if (key.size())
key_list_change_L (key, false);
}
-
void
Msg::configure_stdlog (bool redirect_stdlog_to_stderr,
const String &stdlog_filename,
@@ -376,7 +351,6 @@ Msg::configure_stdlog (bool redirect_stdlog_to_stderr,
msg_log_file = fopen (stdlog_filename.c_str(), "a");
msg_syslog_priority = syslog_priority;
}
-
static String
prgname (bool maystrip)
{
@@ -388,7 +362,6 @@ prgname (bool maystrip)
}
return pname;
}
-
static String
log_prefix (const String &prg_name,
uint pid,
@@ -416,9 +389,7 @@ log_prefix (const String &prg_name,
/* ... */
return str;
}
-
static DataKey<Msg::Handler> msg_thread_handler_key;
-
/**
* @param handler a valid Msg::Handler or NULL
*
@@ -434,7 +405,6 @@ Msg::set_thread_handler (Handler handler)
Thread &self = Thread::self();
self.set_data (&msg_thread_handler_key, handler);
}
-
void
Msg::display_parts (const char *domain,
Type message_type,
@@ -516,7 +486,6 @@ Msg::display_parts (const char *domain,
}
errno = saved_errno;
}
-
void
Msg::display_aparts (const char *log_domain,
Type message_type,
@@ -541,7 +510,6 @@ Msg::display_aparts (const char *log_domain,
display_parts (log_domain, message_type, parts);
errno = saved_errno;
}
-
void
Msg::display_vmsg (const char *log_domain,
Type message_type,
@@ -556,7 +524,6 @@ Msg::display_vmsg (const char *log_domain,
display_parts (log_domain, message_type, parts);
errno = saved_errno;
}
-
/**
* @param domain message domain
* @param parts message parts
@@ -608,5 +575,4 @@ Msg::default_handler (const char *domain,
g_printerr ("** [X] %s\n", checkmsg.c_str());
g_printerr ("********************************************************************************\n");
}
-
} // Birnet
diff --git a/birnet/birnetmsg.hh b/birnet/birnetmsg.hh
index 6a68f92..6ff5c9a 100644
--- a/birnet/birnetmsg.hh
+++ b/birnet/birnetmsg.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_MSG_HH__
#define __BIRNET_MSG_HH__
-
#include <birnet/birnetutils.hh>
#include <stdarg.h>
-
namespace Birnet {
-
/* --- messaging --- */
struct Msg {
/* message parts */
@@ -140,7 +137,6 @@ public:
BIRNET_PRIVATE_CLASS_COPY (CustomType);
};
};
-
/* --- inline implementations --- */
inline bool
Msg::check (Type mtype)
@@ -150,7 +146,6 @@ Msg::check (Type mtype)
mtype < n_msg_types &&
(msg_type_bits[mtype / 8] & (1 << mtype % 8)));
}
-
inline void
Msg::display (Type message_type,
const Part &p0, const Part &p1,
@@ -163,7 +158,6 @@ Msg::display (Type message_type,
if (check (message_type))
display_aparts (BIRNET_LOG_DOMAIN, message_type, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
-
inline void
Msg::display (const CustomType &message_type,
const char *format,
@@ -177,8 +171,6 @@ Msg::display (const CustomType &message_type,
va_end (args);
}
}
-
} // Birnet
-
#endif /* __BIRNET_MSG_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnettests.h b/birnet/birnettests.h
index 47dcd06..34718bd 100644
--- a/birnet/birnettests.h
+++ b/birnet/birnettests.h
@@ -4,17 +4,12 @@
#else
#include <birnet/birnetconfig.h>
#endif
-
/* this file may be included by C programs */
-
#include <glib.h>
#include <string.h>
#include <signal.h> /* G_BREAKPOINT() */
-
BIRNET_EXTERN_C_BEGIN();
-
/* === auxillary macros for test programs === */
-
/* provide dummy i18n function for test programs */
#ifndef _
# define _(x) (x)
@@ -22,7 +17,6 @@ BIRNET_EXTERN_C_BEGIN();
# define N_(x) (x)
# define U_(x) (x)
#endif
-
/* --- macros --- */
/* macros used for testing.
* note that g_print() does fflush(stdout) automatically.
@@ -59,7 +53,6 @@ typedef void (*BirnetTAbort) (void*);
#define TDONE() do { g_printerr ("]\n"); /* test outro */ \
TABORT_set (NULL, NULL); } while(0)
#endif
-
/* --- performance --- */
typedef enum {
TUNIT_NONE = 0,
@@ -87,7 +80,6 @@ typedef enum {
TUNIT_FILE = 0x0008, /* FILE */
} TUnitType;
#define TUNIT(unit1,per_unit2) ((TUnitType) (0x00010000 * (uint) TUNIT_ ## per_unit2 | (uint) TUNIT_ ## unit1))
-
static const char*
treport_unit (uint tunit)
{
@@ -107,7 +99,6 @@ treport_unit (uint tunit)
};
}
static void treport_generic (const char *perf_name, double amount, TUnitType amount_unit, int bias);
-
static void BIRNET_UNUSED
treport_title (const char *perf_name)
{
@@ -158,7 +149,6 @@ treport_generic (const char *perf_name,
amount_unit > 0xffff ? '/' : ' ',
treport_unit (amount_unit >> 16));
}
-
/* --- macro details --- */
static void
tabort_handler (bool set_values,
@@ -177,13 +167,11 @@ tabort_handler (bool set_values,
*data_loc = g_dataset_get_data ((void*) g_dataset_destroy, "birnet-tabort-data");
}
}
-
#define TABORT_set(func,data) do { \
void *__tabort_func = (void*) func; \
void *__tabort_data = (void*) data; \
tabort_handler (1, &__tabort_func, &__tabort_data); \
} while (0)
-
#define TABORT_call() do { \
void *__tabort_func = NULL, *__tabort_data = NULL; \
tabort_handler (0, &__tabort_func, &__tabort_data); \
@@ -191,13 +179,11 @@ tabort_handler (bool set_values,
((BirnetTAbort) __tabort_func) (__tabort_data); \
G_BREAKPOINT(); \
} while (0)
-
#define TSTART_impl(postfix, ...) do { \
char *_test_name_ = g_strdup_printf (__VA_ARGS__); \
g_printerr ("%s%s", _test_name_, postfix); \
g_free (_test_name_); \
} while (0)
-
#define TASSERT_impl(mark, code, show) do { \
if (code) { \
if (show >= 2) \
@@ -211,7 +197,6 @@ tabort_handler (bool set_values,
#code); \
TABORT_call(); } \
} while (0)
-
#define TASSERT_CMP_impl(mark, a, cmp, b, show) do { \
double __tassert_va = a; double __tassert_vb = b; \
if (a cmp b) { \
@@ -231,7 +216,6 @@ tabort_handler (bool set_values,
__tassert_va, #cmp, __tassert_vb); \
TABORT_call(); } \
} while (0)
-
#define TERROR_impl(mark, ...) do { \
g_printerr ("%s", mark); \
char *_error_msg_ = g_strdup_printf (__VA_ARGS__); \
@@ -242,7 +226,6 @@ tabort_handler (bool set_values,
g_free (_error_msg_); \
TABORT_call(); \
} while (0)
-
/**
* TEST_CALIBRATION() - This macro is used to calculate the number of
* repetitions needed for execution of a test routine, so that the total
@@ -302,7 +285,6 @@ tabort_handler (bool set_values,
dups = MAX ((guint) (dups * factor), 1); \
dups; \
})
-
/* --- C++ test initialization --- */
#ifdef __cplusplus
namespace Birnet {
@@ -330,5 +312,4 @@ birnet_init_test (int *argc,
}
} // Birnet
#endif
-
BIRNET_EXTERN_C_END();
diff --git a/birnet/birnetthread.cc b/birnet/birnetthread.cc
index f39c377..7ac4ede 100644
--- a/birnet/birnetthread.cc
+++ b/birnet/birnetthread.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "birnetthread.hh"
#include <list>
-
#define birnet_threads_initialized() ISLIKELY ((void*) ThreadTable.mutex_lock != (void*) ThreadTable.mutex_unlock)
-
namespace Birnet {
-
/* --- Thread::ThreadWrapperInternal --- */
struct Thread::ThreadWrapperInternal : public Thread {
ThreadWrapperInternal (BirnetThread *bthread) :
@@ -46,28 +43,24 @@ struct Thread::ThreadWrapperInternal : public Thread {
unref (self);
}
};
-
/* --- ThreadWrapperInternal (public version of Thread::ThreadWrapperInternal --- */
struct ThreadDescendant : public Thread {
typedef ThreadWrapperInternal PublicThreadWrapperInternal;
ThreadDescendant (const String &name) : Thread (name) {}
};
typedef ThreadDescendant::PublicThreadWrapperInternal ThreadWrapperInternal;
-
/* --- Thread methods --- */
void
Thread::threadxx_wrap (BirnetThread *cthread)
{
ThreadWrapperInternal::thread_from_c (cthread);
}
-
void
Thread::threadxx_delete (void *cxxthread)
{
Thread *thread = reinterpret_cast<Thread*> (cxxthread);
ThreadWrapperInternal::thread_reset_c (thread);
}
-
Thread::Thread (BirnetThread* thread) :
bthread (NULL)
{
@@ -82,7 +75,6 @@ Thread::Thread (BirnetThread* thread) :
; /* invalid object state; this should be reaped by thread_from_c() */
ThreadTable.thread_unref (thread);
}
-
static BirnetThread*
bthread_create_for_thread (const String &name,
void *threadxx)
@@ -93,11 +85,9 @@ bthread_create_for_thread (const String &name,
ThreadTable.thread_ref_sink (bthread);
return bthread;
}
-
Thread::Thread (const String &_name) :
bthread (bthread_create_for_thread (_name, this))
{}
-
Thread::~Thread ()
{
if (bthread) /* can be NULL in thread_from_c() */
@@ -106,7 +96,6 @@ Thread::~Thread ()
ThreadTable.thread_unref (bthread);
}
}
-
void
Thread::start ()
{
@@ -118,80 +107,67 @@ Thread::start ()
ThreadTable.thread_yield();
}
}
-
void
Thread::emit_wakeups (uint64 stamp)
{
ThreadTable.thread_emit_wakeups (stamp);
}
-
int
Thread::pid () const
{
return ThreadTable.thread_pid (bthread);
}
-
String
Thread::name () const
{
return ThreadTable.thread_name (bthread);
}
-
void
Thread::queue_abort ()
{
ThreadTable.thread_queue_abort (bthread);
}
-
void
Thread::abort ()
{
ThreadTable.thread_abort (bthread);
}
-
bool
Thread::aborted ()
{
return ThreadTable.thread_get_aborted (bthread);
}
-
void
Thread::wakeup ()
{
ThreadTable.thread_wakeup (bthread);
}
-
bool
Thread::running ()
{
return ThreadTable.thread_get_running (bthread);
}
-
void
Thread::wait_for_exit ()
{
ThreadTable.thread_wait_for_exit (bthread);
}
-
Thread&
Thread::self ()
{
Thread *thread = (Thread*) ThreadTable.thread_selfxx();
return *thread;
}
-
String
Thread::Self::name ()
{
return ThreadTable.thread_name (ThreadTable.thread_self());
}
-
void
Thread::Self::name (const String &name)
{
ThreadTable.thread_set_name (name.c_str());
}
-
/**
* @param max_useconds maximum amount of micro seconds to sleep (-1 for infinite time)
* @param returns TRUE while the thread should continue execution
@@ -203,25 +179,21 @@ Thread::Self::sleep (long max_useconds)
{
return ThreadTable.thread_sleep (max_useconds);
}
-
bool
Thread::Self::aborted ()
{
return ThreadTable.thread_aborted();
}
-
int
Thread::Self::pid ()
{
return ThreadTable.thread_pid (ThreadTable.thread_self());
}
-
void
Thread::Self::awake_after (uint64 stamp)
{
ThreadTable.thread_awake_after (stamp);
}
-
void
Thread::Self::set_wakeup (BirnetThreadWakeup wakeup_func,
void *wakeup_data,
@@ -229,27 +201,22 @@ Thread::Self::set_wakeup (BirnetThreadWakeup wakeup_func,
{
ThreadTable.thread_set_wakeup (wakeup_func, wakeup_data, destroy_data);
}
-
OwnedMutex&
Thread::Self::owned_mutex ()
{
return self().m_omutex;
}
-
void
Thread::Self::yield ()
{
ThreadTable.thread_yield ();
}
-
void
Thread::Self::exit (void *retval)
{
ThreadTable.thread_exit (retval);
}
-
static const BirnetMutex zero_mutex = { 0, };
-
Mutex::Mutex () :
mutex (zero_mutex)
{
@@ -258,7 +225,6 @@ Mutex::Mutex () :
else
ThreadTable.mutex_chain4init (&mutex);
}
-
Mutex::~Mutex ()
{
if (birnet_threads_initialized())
@@ -266,9 +232,7 @@ Mutex::~Mutex ()
else
ThreadTable.mutex_unchain (&mutex);
}
-
static const BirnetRecMutex zero_rec_mutex = { { 0, }, };
-
RecMutex::RecMutex () :
rmutex (zero_rec_mutex)
{
@@ -277,7 +241,6 @@ RecMutex::RecMutex () :
else
ThreadTable.rec_mutex_chain4init (&rmutex);
}
-
RecMutex::~RecMutex ()
{
if (birnet_threads_initialized())
@@ -285,9 +248,7 @@ RecMutex::~RecMutex ()
else
ThreadTable.rec_mutex_unchain (&rmutex);
}
-
static const BirnetCond zero_cond = { 0, };
-
Cond::Cond () :
cond (zero_cond)
{
@@ -296,7 +257,6 @@ Cond::Cond () :
else
ThreadTable.cond_chain4init (&cond);
}
-
Cond::~Cond ()
{
if (birnet_threads_initialized())
@@ -304,7 +264,6 @@ Cond::~Cond ()
else
ThreadTable.cond_unchain (&cond);
}
-
OwnedMutex::OwnedMutex () :
m_rec_mutex (zero_rec_mutex),
m_owner (NULL)
@@ -314,7 +273,6 @@ OwnedMutex::OwnedMutex () :
else
ThreadTable.rec_mutex_chain4init (&m_rec_mutex);
}
-
OwnedMutex::~OwnedMutex()
{
BIRNET_ASSERT (m_owner == NULL);
@@ -323,5 +281,4 @@ OwnedMutex::~OwnedMutex()
else
ThreadTable.rec_mutex_unchain (&m_rec_mutex);
}
-
} // Birnet
diff --git a/birnet/birnetthread.hh b/birnet/birnetthread.hh
index 663cb0a..2a43876 100644
--- a/birnet/birnetthread.hh
+++ b/birnet/birnetthread.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_THREAD_XX_HH__
#define __BIRNET_THREAD_XX_HH__
-
#include <birnet/birnetutils.hh>
-
namespace Birnet {
-
class Thread;
-
class Mutex {
BirnetMutex mutex;
friend class Cond;
@@ -19,7 +15,6 @@ public:
bool trylock () { return 0 == ThreadTable.mutex_trylock (&mutex); /* TRUE indicates success */ }
/*Des*/ ~Mutex ();
};
-
class RecMutex {
BirnetRecMutex rmutex;
BIRNET_PRIVATE_CLASS_COPY (RecMutex);
@@ -30,7 +25,6 @@ public:
bool trylock () { return 0 == ThreadTable.rec_mutex_trylock (&rmutex); /* TRUE indicates success */ }
/*Des*/ ~RecMutex ();
};
-
class Cond {
BirnetCond cond;
BIRNET_PRIVATE_CLASS_COPY (Cond);
@@ -43,7 +37,6 @@ public:
int64 max_usecs) { ThreadTable.cond_wait_timed (&cond, &m.mutex, max_usecs); }
/*Des*/ ~Cond ();
};
-
namespace Atomic {
inline void read_barrier (void) { BIRNET_MEMORY_BARRIER_RO (ThreadTable); }
inline void write_barrier (void) { BIRNET_MEMORY_BARRIER_WO (ThreadTable); }
@@ -70,7 +63,6 @@ inline V* ptr_get (V* volatile const *ptr_addr) { return (V*) Th
template<class V>
inline bool ptr_cas (V* volatile *ptr_adr, V *o, V *n) { return ThreadTable.atomic_pointer_cas ((void**) ptr_adr, (void*) o, (void*) n); }
} // Atomic
-
class OwnedMutex {
BirnetRecMutex m_rec_mutex;
Thread * volatile m_owner;
@@ -84,7 +76,6 @@ public:
inline bool mine ();
/*Des*/ ~OwnedMutex ();
};
-
class Thread : public virtual ReferenceCountImpl {
protected:
explicit Thread (const String &name);
@@ -144,7 +135,6 @@ protected:
static void threadxx_wrap (BirnetThread *cthread);
static void threadxx_delete (void *cxxthread);
};
-
/**
* The AutoLocker class locks mutex like objects on construction, and automatically
* unlocks on destruction. So putting an AutoLocker object on the stack conveniently
@@ -194,9 +184,7 @@ public:
inline void relock () { locker()->lock(); lcount++; }
inline void unlock () { BIRNET_ASSERT (lcount > 0); lcount--; locker()->unlock(); }
};
-
namespace Atomic {
-
template<typename T>
class RingBuffer {
const uint m_size;
@@ -295,9 +283,7 @@ public:
return orig_length - length;
}
};
-
} // Atomic
-
/* --- implementation --- */
inline void
OwnedMutex::lock ()
@@ -305,7 +291,6 @@ OwnedMutex::lock ()
ThreadTable.rec_mutex_lock (&m_rec_mutex);
Atomic::ptr_set (&m_owner, &Thread::self());
}
-
inline bool
OwnedMutex::trylock ()
{
@@ -317,28 +302,22 @@ OwnedMutex::trylock ()
else
return false;
}
-
inline void
OwnedMutex::unlock ()
{
Atomic::ptr_set (&m_owner, (Thread*) 0);
ThreadTable.rec_mutex_unlock (&m_rec_mutex);
}
-
inline Thread*
OwnedMutex::owner ()
{
return Atomic::ptr_get (&m_owner);
}
-
inline bool
OwnedMutex::mine ()
{
return Atomic::ptr_get (&m_owner) == &Thread::self();
}
-
} // Birnet
-
#endif /* __BIRNET_THREAD_XX_HH__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetthreadimpl.cc b/birnet/birnetthreadimpl.cc
index 14a7e9e..0d575fc 100644
--- a/birnet/birnetthreadimpl.cc
+++ b/birnet/birnetthreadimpl.cc
@@ -20,11 +20,9 @@
#include <sys/times.h>
#include "birnetutils.hh"
#include "birnetthread.hh"
-
#define FLOATING_FLAG (1 << 31)
#define THREAD_REF_COUNT(thread) (thread->ref_field & ~FLOATING_FLAG)
#define THREAD_CAS(thread, oldval, newval) Atomic::uint_cas (&thread->ref_field, oldval, newval)
-
/* --- some GLib compat --- */
#define HAVE_GSLICE GLIB_CHECK_VERSION (2, 9, 1)
#if !GLIB_CHECK_VERSION (2, 10, 0)
@@ -41,7 +39,6 @@ g_atomic_pointer_set (volatile gpointer *atomic,
while (!g_atomic_pointer_compare_and_exchange ((gpointer*) atomic, *atomic, value));
}
#endif
-
/* --- structures --- */
struct _BirnetThread
{
@@ -73,9 +70,7 @@ struct _BirnetThread
gint cutime, cstime;
} info;
};
-
namespace Birnet {
-
/* --- prototypes --- */
static void birnet_guard_deregister_all (BirnetThread *thread);
static void birnet_thread_handle_exit (BirnetThread *thread);
@@ -83,8 +78,6 @@ static void birnet_thread_accounting_L (BirnetThread *self,
bool force_update);
static void thread_get_tid (BirnetThread *thread);
static inline guint cached_getpid (void);
-
-
/* --- variables --- */
static Mutex global_thread_mutex;
static Cond global_thread_cond;
@@ -94,8 +87,6 @@ static GSList *thread_awaken_list = NULL;
static BirnetMutex *mutex_init_chain = NULL;
static BirnetMutex *rec_mutex_init_chain = NULL;
static BirnetCond *cond_init_chain = NULL;
-
-
/* --- functions --- */
static BirnetThread*
common_thread_new (const gchar *name)
@@ -107,7 +98,6 @@ common_thread_new (const gchar *name)
#else
thread = g_new0 (BirnetThread, 1);
#endif
-
ThreadTable.atomic_pointer_set (&thread->threadxx, NULL);
thread->ref_field = FLOATING_FLAG + 1;
thread->name = g_strdup (name);
@@ -123,7 +113,6 @@ common_thread_new (const gchar *name)
g_datalist_init (&thread->qdata);
return thread;
}
-
static BirnetThread*
common_thread_ref (BirnetThread *thread)
{
@@ -137,7 +126,6 @@ common_thread_ref (BirnetThread *thread)
} while (!THREAD_CAS (thread, old_ref, new_ref));
return thread;
}
-
static BirnetThread*
common_thread_ref_sink (BirnetThread *thread)
{
@@ -153,7 +141,6 @@ common_thread_ref_sink (BirnetThread *thread)
ThreadTable.thread_unref (thread);
return thread;
}
-
static void
common_thread_unref (BirnetThread *thread)
{
@@ -180,7 +167,6 @@ common_thread_unref (BirnetThread *thread)
#endif
}
}
-
static void
birnet_thread_handle_exit (BirnetThread *thread)
{
@@ -212,11 +198,9 @@ birnet_thread_handle_exit (BirnetThread *thread)
thread->awake_stamp = 1;
global_thread_cond.broadcast();
global_thread_mutex.unlock();
-
/* free thread structure */
ThreadTable.thread_unref (thread);
}
-
static void
filter_priority_warning (const gchar *log_domain,
GLogLevelFlags log_level,
@@ -229,7 +213,6 @@ filter_priority_warning (const gchar *log_domain,
else
g_log_default_handler (log_domain, log_level, message, unused_data);
}
-
static gpointer
birnet_thread_exec (gpointer data)
{
@@ -238,14 +221,10 @@ birnet_thread_exec (gpointer data)
BirnetThreadFunc func = (BirnetThreadFunc) tfdx[1];
gpointer user_data = tfdx[2];
ThreadTable.thread_set_handle (thread);
-
BirnetThread *self = ThreadTable.thread_self ();
g_assert (self == thread);
-
thread_get_tid (thread);
-
ThreadTable.thread_ref (thread);
-
global_thread_mutex.lock();
global_thread_list = g_slist_append (global_thread_list, self);
self->accounting = 1;
@@ -253,20 +232,16 @@ birnet_thread_exec (gpointer data)
global_thread_cond.broadcast();
global_thread_mutex.unlock();
/* here, tfdx contents have become invalid */
-
global_startup_mutex.lock();
/* acquiring this mutex waits for birnet_thread_run() to figure inlist (global_thread_list, self) */
global_startup_mutex.unlock();
-
func (user_data);
g_datalist_clear (&thread->qdata);
-
/* because func() can be prematurely exited via pthread_exit(),
* birnet_thread_handle_exit() does unref and final destruction
*/
return NULL;
}
-
/**
* @param thread a valid, unstarted BirnetThread
* @param func function to execute in new thread
@@ -282,16 +257,12 @@ common_thread_start (BirnetThread *thread,
{
GThread *gthread = NULL;
GError *gerror = NULL;
-
g_return_val_if_fail (thread != NULL, FALSE);
g_return_val_if_fail (thread->tid == -1, FALSE);
g_return_val_if_fail (func != NULL, FALSE);
-
ThreadTable.thread_ref (thread);
-
/* silence those stupid priority warnings triggered by glib */
guint hid = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING, filter_priority_warning, NULL);
-
/* thread creation context, protection by global_startup_mutex */
global_startup_mutex.lock();
void **tfdx = g_new0 (void*, 4);
@@ -299,9 +270,7 @@ common_thread_start (BirnetThread *thread,
tfdx[1] = (void*) func;
tfdx[2] = user_data;
tfdx[3] = NULL;
-
thread->tid = cached_getpid();
-
/* don't dare setting joinable to TRUE, that prevents the thread's
* resources from being freed, since we don't offer pthread_join().
* so we'd just run out of stack at some point.
@@ -322,19 +291,14 @@ common_thread_start (BirnetThread *thread,
g_message ("failed to create thread \"%s\": %s", thread->name, gerror->message);
g_error_free (gerror);
}
-
/* let the new thread actually start out */
global_startup_mutex.unlock();
-
/* withdraw warning filter */
g_free (tfdx);
g_log_remove_handler ("GLib", hid);
-
ThreadTable.thread_unref (thread);
-
return gthread != NULL;
}
-
/**
* Volountarily give up the curren scheduler time slice and let
* another process or thread run, if any is in the queue.
@@ -350,7 +314,6 @@ common_thread_yield (void)
g_thread_yield();
#endif
}
-
/**
* @return thread handle
*
@@ -379,7 +342,6 @@ common_thread_self (void)
}
return thread;
}
-
static inline void*
common_thread_getxx (BirnetThread *thread)
{
@@ -395,7 +357,6 @@ common_thread_getxx (BirnetThread *thread)
}
return ptr;
}
-
static void*
common_thread_selfxx (void)
{
@@ -404,7 +365,6 @@ common_thread_selfxx (void)
thread = ThreadTable.thread_self();
return common_thread_getxx (thread);
}
-
static bool
common_thread_setxx (BirnetThread *thread,
void *xxdata)
@@ -421,7 +381,6 @@ common_thread_setxx (BirnetThread *thread,
global_thread_mutex.unlock();
return success;
}
-
/**
* @param thread a valid BirnetThread handle
* @return thread id
@@ -437,7 +396,6 @@ common_thread_pid (BirnetThread *thread)
thread = thread ? thread : ThreadTable.thread_self();
return thread->tid;
}
-
/**
* @param thread a valid BirnetThread handle
* @return thread name
@@ -451,7 +409,6 @@ common_thread_name (BirnetThread *thread)
thread = thread ? thread : ThreadTable.thread_self();
return thread->name;
}
-
static void
common_thread_set_name (const gchar *name)
{
@@ -464,7 +421,6 @@ common_thread_set_name (const gchar *name)
global_thread_mutex.unlock();
}
}
-
static void
birnet_thread_wakeup_L (BirnetThread *thread)
{
@@ -473,7 +429,6 @@ birnet_thread_wakeup_L (BirnetThread *thread)
thread->wakeup_func (thread->wakeup_data);
thread->got_wakeup = TRUE;
}
-
/**
* @param max_useconds maximum amount of micro seconds to sleep (-1 for infinite time)
* @param returns TRUE while the thread should continue execution
@@ -492,11 +447,8 @@ common_thread_sleep (BirnetInt64 max_useconds)
{
BirnetThread *self = ThreadTable.thread_self ();
bool aborted;
-
global_thread_mutex.lock();
-
birnet_thread_accounting_L (self, FALSE);
-
if (!self->got_wakeup && max_useconds != 0)
{
if (max_useconds >= 0) /* wait once without time adjustments */
@@ -505,14 +457,11 @@ common_thread_sleep (BirnetInt64 max_useconds)
while (!self->got_wakeup)
self->wakeup_cond.wait (global_thread_mutex);
}
-
self->got_wakeup = FALSE;
aborted = self->aborted != FALSE;
global_thread_mutex.unlock();
-
return !aborted;
}
-
/**
* @param wakeup_func wakeup function to be called by birnet_thread_wakeup()
* @param wakeup_data data passed into wakeup_func()
@@ -532,17 +481,14 @@ common_thread_set_wakeup (BirnetThreadWakeup wakeup_func,
GDestroyNotify destroy)
{
BirnetThread *self = ThreadTable.thread_self ();
-
g_return_if_fail (wakeup_func != NULL);
g_return_if_fail (self->wakeup_func == NULL);
-
global_thread_mutex.lock();
self->wakeup_func = wakeup_func;
self->wakeup_data = wakeup_data;
self->wakeup_destroy = destroy;
global_thread_mutex.unlock();
}
-
/**
* @param thread thread to wake up
*
@@ -554,13 +500,11 @@ static void
common_thread_wakeup (BirnetThread *thread)
{
g_return_if_fail (thread != NULL);
-
global_thread_mutex.lock();
g_assert (g_slist_find (global_thread_list, thread));
birnet_thread_wakeup_L (thread);
global_thread_mutex.unlock();
}
-
/**
* @param stamp stamp to trigger wakeup
*
@@ -572,9 +516,7 @@ static void
common_thread_awake_after (BirnetUInt64 stamp)
{
BirnetThread *self = ThreadTable.thread_self ();
-
g_return_if_fail (stamp > 0);
-
global_thread_mutex.lock();
if (!self->awake_stamp)
{
@@ -585,7 +527,6 @@ common_thread_awake_after (BirnetUInt64 stamp)
self->awake_stamp = MIN (self->awake_stamp, stamp);
global_thread_mutex.unlock();
}
-
/**
* @param wakeup_stamp wakeup stamp to trigger wakeups
*
@@ -597,7 +538,6 @@ static void
common_thread_emit_wakeups (BirnetUInt64 wakeup_stamp)
{
g_return_if_fail (wakeup_stamp > 0);
-
global_thread_mutex.lock();
GSList *next, *node;
for (node = thread_awaken_list; node; node = next)
@@ -613,7 +553,6 @@ common_thread_emit_wakeups (BirnetUInt64 wakeup_stamp)
}
global_thread_mutex.unlock();
}
-
/**
* @param thread thread to abort
*
@@ -627,7 +566,6 @@ common_thread_abort (BirnetThread *thread)
{
g_return_if_fail (thread != NULL);
g_return_if_fail (thread != ThreadTable.thread_self ());
-
global_thread_mutex.lock();
g_assert (g_slist_find (global_thread_list, thread));
thread->aborted = TRUE;
@@ -636,7 +574,6 @@ common_thread_abort (BirnetThread *thread)
global_thread_cond.wait (global_thread_mutex);
global_thread_mutex.unlock();
}
-
/**
* @param thread thread to abort
*
@@ -649,14 +586,12 @@ static void
common_thread_queue_abort (BirnetThread *thread)
{
g_return_if_fail (thread != NULL);
-
global_thread_mutex.lock();
g_assert (g_slist_find (global_thread_list, thread));
thread->aborted = TRUE;
birnet_thread_wakeup_L (thread);
global_thread_mutex.unlock();
}
-
/**
* @param returns TRUE if the thread should abort execution
*
@@ -676,7 +611,6 @@ common_thread_aborted (void)
global_thread_mutex.unlock();
return aborted;
}
-
/**
* @param thread thread to abort
* @param returns TRUE if the thread should abort execution
@@ -695,7 +629,6 @@ common_thread_get_aborted (BirnetThread *thread)
global_thread_mutex.unlock();
return aborted;
}
-
static bool
common_thread_get_running (BirnetThread *thread)
{
@@ -704,7 +637,6 @@ common_thread_get_running (BirnetThread *thread)
global_thread_mutex.unlock();
return running;
}
-
static void
common_thread_wait_for_exit (BirnetThread *thread)
{
@@ -713,14 +645,12 @@ common_thread_wait_for_exit (BirnetThread *thread)
global_thread_cond.wait (global_thread_mutex);
global_thread_mutex.unlock();
}
-
static gpointer
common_thread_get_qdata (GQuark quark)
{
BirnetThread *self = ThreadTable.thread_self ();
return quark ? g_datalist_id_get_data (&self->qdata, quark) : NULL;
}
-
static void
common_thread_set_qdata_full (GQuark quark,
gpointer data,
@@ -731,14 +661,12 @@ common_thread_set_qdata_full (GQuark quark,
g_datalist_id_set_data_full (&self->qdata, quark, data,
data ? destroy : (GDestroyNotify) NULL);
}
-
static gpointer
common_thread_steal_qdata (GQuark quark)
{
BirnetThread *self = ThreadTable.thread_self ();
return quark ? g_datalist_id_remove_no_notify (&self->qdata, quark) : NULL;
}
-
static bool
common_split_useconds (BirnetInt64 max_useconds,
BirnetUInt64 *abs_secs,
@@ -761,7 +689,6 @@ common_split_useconds (BirnetInt64 max_useconds,
*abs_usecs = limit_usec;
return true;
}
-
static inline guint
cached_getpid (void)
{
@@ -770,7 +697,6 @@ cached_getpid (void)
cached_pid = getpid();
return cached_pid;
}
-
#ifdef __linux__
#include <sys/types.h>
#include <sys/syscall.h>
@@ -781,7 +707,6 @@ thread_get_tid (BirnetThread *thread)
{
gint ppid = thread->tid; /* creator process id */
gint tid = -1;
-
#if defined (__linux__) && defined (__NR_gettid) /* present on linux >= 2.4.20 */
tid = syscall (__NR_gettid);
#endif
@@ -793,15 +718,12 @@ thread_get_tid (BirnetThread *thread)
else
thread->tid = 0; /* failed to figure id */
}
-
-
/* --- thread info --- */
static inline unsigned long long int
timeval_usecs (const struct timeval *tv)
{
return tv->tv_usec + tv->tv_sec * (guint64) 1000000;
}
-
static void
thread_info_from_stat_L (BirnetThread *self,
double usec_norm)
@@ -851,7 +773,6 @@ thread_info_from_stat_L (BirnetThread *self,
);
if (file)
fclose (file);
-
if (n >= 15)
{
self->ac.utime = utime * 10000;
@@ -867,9 +788,7 @@ thread_info_from_stat_L (BirnetThread *self,
if (n >= 39)
self->info.processor = 1 + processor;
}
-
#define ACCOUNTING_MSECS (500)
-
static void
birnet_thread_accounting_L (BirnetThread *self,
bool force_update)
@@ -909,7 +828,6 @@ birnet_thread_accounting_L (BirnetThread *self,
self->accounting--;
}
}
-
static BirnetThreadInfo*
common_thread_info_collect (BirnetThread *thread)
{
@@ -939,7 +857,6 @@ common_thread_info_collect (BirnetThread *thread)
global_thread_mutex.unlock();
return info;
}
-
static void
common_thread_info_free (BirnetThreadInfo *info)
{
@@ -947,7 +864,6 @@ common_thread_info_free (BirnetThreadInfo *info)
g_free (info->name);
g_free (info);
}
-
/* --- structure chaining for initialization --- */
static void
common_mutex_chain4init (BirnetMutex *mutex)
@@ -956,7 +872,6 @@ common_mutex_chain4init (BirnetMutex *mutex)
mutex->mutex_pointer = mutex_init_chain;
mutex_init_chain = mutex;
}
-
static void
common_mutex_unchain (BirnetMutex *mutex)
{
@@ -971,7 +886,6 @@ common_mutex_unchain (BirnetMutex *mutex)
else
mutex_init_chain = (BirnetMutex*) mutex->mutex_pointer;
}
-
static void
common_rec_mutex_chain4init (BirnetRecMutex *rec_mutex)
{
@@ -980,7 +894,6 @@ common_rec_mutex_chain4init (BirnetRecMutex *rec_mutex)
rec_mutex->mutex.mutex_pointer = rec_mutex_init_chain;
rec_mutex_init_chain = &rec_mutex->mutex;
}
-
static void
common_rec_mutex_unchain (BirnetRecMutex *rec_mutex)
{
@@ -996,7 +909,6 @@ common_rec_mutex_unchain (BirnetRecMutex *rec_mutex)
else
rec_mutex_init_chain = (BirnetMutex*) mutex->mutex_pointer;
}
-
static void
common_cond_chain4init (BirnetCond *cond)
{
@@ -1004,7 +916,6 @@ common_cond_chain4init (BirnetCond *cond)
cond->cond_pointer = cond_init_chain;
cond_init_chain = cond;
}
-
static void
common_cond_unchain (BirnetCond *cond)
{
@@ -1019,7 +930,6 @@ common_cond_unchain (BirnetCond *cond)
else
cond_init_chain = (BirnetCond*) cond->cond_pointer;
}
-
/* --- hazard pointer guards --- */
struct BirnetGuard
{
@@ -1034,7 +944,6 @@ static gint volatile guard_list_length = 0;
#define BIRNET_GUARD_ALIGN (4)
#define guard2values(ptr) G_STRUCT_MEMBER_P (ptr, +G_STRUCT_OFFSET (BirnetGuard, values[0]))
#define values2guard(ptr) G_STRUCT_MEMBER_P (ptr, -G_STRUCT_OFFSET (BirnetGuard, values[0]))
-
/**
* @param n_hazards number of required hazard pointers
* @return a valid BirnetGuard
@@ -1081,7 +990,6 @@ birnet_guard_register (guint n_hazards)
}
return (volatile BirnetGuard*) guard2values (guard);
}
-
/**
* @param guard a valid BirnetGuard as returned from birnet_guard_register()
*
@@ -1099,7 +1007,6 @@ birnet_guard_deregister (volatile BirnetGuard *guard)
guard->cache_next = (volatile BirnetGuard*) thread->guard_cache;
thread->guard_cache = guard;
}
-
static void
birnet_guard_deregister_all (BirnetThread *thread)
{
@@ -1113,7 +1020,6 @@ birnet_guard_deregister_all (BirnetThread *thread)
ThreadTable.atomic_pointer_cas (&guard->thread, thread, NULL); /* reset ->thread with memory barrier */
}
}
-
/**
* @param guard a valid BirnetGuard as returned from birnet_guard_register()
* @param nth_hazard index of the hazard pointer to use for protection
@@ -1150,7 +1056,6 @@ void birnet_guard_protect (volatile BirnetGuard *guard, /* defined in birnetthr
guint nth_hazard,
gpointer value);
#endif
-
/**
* @return an upper bound on the number of registered hazard pointers
*
@@ -1166,7 +1071,6 @@ birnet_guard_n_snap_values (void)
{
return Atomic::int_get (&guard_list_length);
}
-
/**
* @param n_values location of n_values variable
* @param values value array to fill in
@@ -1217,7 +1121,6 @@ birnet_guard_snap_values (guint *n_values,
*n_values = n; /* number of values used */
return TRUE;
}
-
/**
* @param value hazard pointer value
* @return TRUE if a hazard pointer protecting @a value has been found
@@ -1248,46 +1151,38 @@ birnet_guard_is_protected (gpointer value)
}
return FALSE;
}
-
/* --- fallback (GLib) BirnetThreadTable --- */
static GPrivate *fallback_thread_table_key = NULL;
-
static void
fallback_thread_set_handle (BirnetThread *handle)
{
g_private_set (fallback_thread_table_key, handle);
}
-
static BirnetThread*
fallback_thread_get_handle (void)
{
return (BirnetThread*) g_private_get (fallback_thread_table_key);
}
-
static void
fallback_mutex_init (BirnetMutex *mutex)
{
g_return_if_fail (mutex != NULL);
mutex->mutex_pointer = g_mutex_new ();
}
-
static int
fallback_mutex_trylock (BirnetMutex *mutex)
{
return g_mutex_trylock ((GMutex*) mutex->mutex_pointer) ? 0 : -1;
}
-
static void
fallback_mutex_lock (BirnetMutex *mutex)
{
static gboolean is_smp_system = FALSE; // FIXME
-
/* spin locks should be held only very short times,
* so usually, we should succeed here.
*/
if (g_mutex_trylock ((GMutex*) mutex->mutex_pointer))
return;
-
if (!is_smp_system)
{
/* on uni processor systems, there's no point in busy spinning */
@@ -1309,20 +1204,17 @@ fallback_mutex_lock (BirnetMutex *mutex)
g_mutex_lock ((GMutex*) mutex->mutex_pointer);
}
}
-
static void
fallback_mutex_unlock (BirnetMutex *mutex)
{
g_mutex_unlock ((GMutex*) mutex->mutex_pointer);
}
-
static void
fallback_mutex_destroy (BirnetMutex *mutex)
{
g_mutex_free ((GMutex*) mutex->mutex_pointer);
memset (mutex, 0, sizeof (*mutex));
}
-
static void
fallback_rec_mutex_init (BirnetRecMutex *rec_mutex)
{
@@ -1330,12 +1222,10 @@ fallback_rec_mutex_init (BirnetRecMutex *rec_mutex)
rec_mutex->depth = 0;
ThreadTable.mutex_init (&rec_mutex->mutex);
}
-
static int
fallback_rec_mutex_trylock (BirnetRecMutex *rec_mutex)
{
BirnetThread *self = ThreadTable.thread_self ();
-
if (rec_mutex->owner == self)
{
g_assert (rec_mutex->depth > 0); /* paranoid */
@@ -1354,12 +1244,10 @@ fallback_rec_mutex_trylock (BirnetRecMutex *rec_mutex)
}
return -1;
}
-
static void
fallback_rec_mutex_lock (BirnetRecMutex *rec_mutex)
{
BirnetThread *self = ThreadTable.thread_self ();
-
if (rec_mutex->owner == self)
{
g_assert (rec_mutex->depth > 0); /* paranoid */
@@ -1373,12 +1261,10 @@ fallback_rec_mutex_lock (BirnetRecMutex *rec_mutex)
rec_mutex->depth = 1;
}
}
-
static void
fallback_rec_mutex_unlock (BirnetRecMutex *rec_mutex)
{
BirnetThread *self = ThreadTable.thread_self ();
-
if (rec_mutex->owner == self && rec_mutex->depth > 0)
{
rec_mutex->depth -= 1;
@@ -1392,7 +1278,6 @@ fallback_rec_mutex_unlock (BirnetRecMutex *rec_mutex)
g_warning ("unable to unlock recursive mutex with self %p != %p or depth %u < 1",
rec_mutex->owner, self, rec_mutex->depth);
}
-
static void
fallback_rec_mutex_destroy (BirnetRecMutex *rec_mutex)
{
@@ -1404,25 +1289,21 @@ fallback_rec_mutex_destroy (BirnetRecMutex *rec_mutex)
g_assert (rec_mutex->owner == NULL && rec_mutex->depth == 0);
}
}
-
static void
fallback_cond_init (BirnetCond *cond)
{
cond->cond_pointer = g_cond_new ();
}
-
static void
fallback_cond_signal (BirnetCond *cond)
{
g_cond_signal ((GCond*) cond->cond_pointer);
}
-
static void
fallback_cond_broadcast (BirnetCond *cond)
{
g_cond_broadcast ((GCond*) cond->cond_pointer);
}
-
static void
fallback_cond_wait (BirnetCond *cond,
BirnetMutex *mutex)
@@ -1430,7 +1311,6 @@ fallback_cond_wait (BirnetCond *cond,
/* infinite wait */
g_cond_wait ((GCond*) cond->cond_pointer, (GMutex*) mutex->mutex_pointer);
}
-
static void
fallback_cond_wait_timed (BirnetCond *cond,
BirnetMutex *mutex,
@@ -1447,20 +1327,17 @@ fallback_cond_wait_timed (BirnetCond *cond,
else
g_cond_wait ((GCond*) cond->cond_pointer, (GMutex*) mutex->mutex_pointer);
}
-
static void
fallback_cond_destroy (BirnetCond *cond)
{
g_cond_free ((GCond*) cond->cond_pointer);
}
-
static void G_GNUC_NORETURN
fallback_thread_exit (gpointer retval)
{
g_thread_exit (retval);
abort(); /* silence compiler */
}
-
#ifdef g_atomic_int_get
static int
birnet_g_atomic_int_get (volatile int *atomic)
@@ -1470,7 +1347,6 @@ birnet_g_atomic_int_get (volatile int *atomic)
#undef g_atomic_int_get
#define g_atomic_int_get birnet_g_atomic_int_get
#endif
-
#ifdef g_atomic_pointer_get
static void*
birnet_g_atomic_pointer_get (volatile void **atomic)
@@ -1480,8 +1356,6 @@ birnet_g_atomic_pointer_get (volatile void **atomic)
#undef g_atomic_pointer_get
#define g_atomic_pointer_get birnet_g_atomic_pointer_get
#endif
-
-
static BirnetThreadTable fallback_thread_table = {
NULL, /* mutex_chain4init */
NULL, /* mutex_unchain */
@@ -1551,15 +1425,12 @@ static BirnetThreadTable fallback_thread_table = {
fallback_cond_wait_timed,
fallback_cond_destroy,
};
-
static BirnetThreadTable*
get_fallback_thread_table (void)
{
fallback_thread_table_key = g_private_new ((GDestroyNotify) birnet_thread_handle_exit);
return &fallback_thread_table;
}
-
-
/* --- POSIX threads table --- */
#if (BIRNET_HAVE_MUTEXATTR_SETTYPE > 0)
#include <pthread.h>
@@ -1577,7 +1448,6 @@ pth_thread_get_handle (void)
{
return (BirnetThread*) pthread_getspecific (pth_thread_table_key);
}
-
static void
pth_mutex_init (BirnetMutex *mutex)
{
@@ -1586,7 +1456,6 @@ pth_mutex_init (BirnetMutex *mutex)
*/
pthread_mutex_init ((pthread_mutex_t*) mutex, NULL);
}
-
static void
pth_rec_mutex_init (BirnetRecMutex *mutex)
{
@@ -1597,13 +1466,11 @@ pth_rec_mutex_init (BirnetRecMutex *mutex)
pthread_mutex_init ((pthread_mutex_t*) mutex, &attr);
pthread_mutexattr_destroy (&attr);
}
-
static void
pth_cond_init (BirnetCond *cond)
{
pthread_cond_init ((pthread_cond_t*) cond, NULL);
}
-
static void
pth_cond_wait_timed (BirnetCond *cond,
BirnetMutex *mutex,
@@ -1620,7 +1487,6 @@ pth_cond_wait_timed (BirnetCond *cond,
else
pthread_cond_wait ((pthread_cond_t*) cond, (pthread_mutex_t *) mutex);
}
-
static BirnetThreadTable pth_thread_table = {
NULL, /* mutex_chain4init */
NULL, /* mutex_unchain */
@@ -1705,7 +1571,6 @@ get_pth_thread_table (void)
#else /* !BIRNET_HAVE_MUTEXATTR_SETTYPE */
#define get_pth_thread_table() NULL
#endif /* !BIRNET_HAVE_MUTEXATTR_SETTYPE */
-
/* ::Birnet::ThreadTable must be a BirnetThreadTable, not a reference for the C API wrapper to work */
BirnetThreadTable ThreadTable = {
common_mutex_chain4init,
@@ -1729,7 +1594,6 @@ BirnetThreadTable ThreadTable = {
(uint (*) (volatile uint*, uint)) g_atomic_int_exchange_and_add,
NULL,
};
-
void
_birnet_init_threads (void)
{
@@ -1737,7 +1601,6 @@ _birnet_init_threads (void)
if (!table)
table = get_fallback_thread_table ();
ThreadTable = *table;
-
while (mutex_init_chain)
{
BirnetMutex *mutex = mutex_init_chain;
@@ -1757,8 +1620,6 @@ _birnet_init_threads (void)
cond_init_chain = (BirnetCond*) cond->cond_pointer;
ThreadTable.cond_init (cond);
}
-
ThreadTable.thread_self ();
}
-
} // Birnet
diff --git a/birnet/birnetutf8.cc b/birnet/birnetutf8.cc
index 6318c18..746835a 100644
--- a/birnet/birnetutf8.cc
+++ b/birnet/birnetutf8.cc
@@ -1,125 +1,104 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "birnetutf8.hh"
#include <glib.h>
-
namespace Birnet {
namespace Unichar {
-
/* --- unichar ctype.h equivalents --- */
bool
isalnum (unichar uc)
{
return g_unichar_isalnum (uc);
}
-
bool
isalpha (unichar uc)
{
return g_unichar_isalpha (uc);
}
-
bool
iscntrl (unichar uc)
{
return g_unichar_iscntrl (uc);
}
-
bool
isdigit (unichar uc)
{
return g_unichar_isdigit (uc);
}
-
int
digit_value (unichar uc)
{
return g_unichar_digit_value (uc);
}
-
bool
isgraph (unichar uc)
{
return g_unichar_isgraph (uc);
}
-
bool
islower (unichar uc)
{
return g_unichar_islower (uc);
}
-
unichar
tolower (unichar uc)
{
return g_unichar_tolower (uc);
}
-
bool
isprint (unichar uc)
{
return g_unichar_isprint (uc);
}
-
bool
ispunct (unichar uc)
{
return g_unichar_ispunct (uc);
}
-
bool
isspace (unichar uc)
{
return g_unichar_isspace (uc);
}
-
bool
isupper (unichar uc)
{
return g_unichar_isupper (uc);
}
-
unichar
toupper (unichar uc)
{
return g_unichar_toupper (uc);
}
-
bool
isxdigit (unichar uc)
{
return g_unichar_isxdigit (uc);
}
-
int
xdigit_value (unichar uc)
{
return g_unichar_xdigit_value (uc);
}
-
bool
istitle (unichar uc)
{
return g_unichar_istitle (uc);
}
-
unichar
totitle (unichar uc)
{
return g_unichar_totitle (uc);
}
-
bool
isdefined (unichar uc)
{
return g_unichar_isdefined (uc);
}
-
bool
iswide (unichar uc)
{
return g_unichar_iswide (uc);
}
-
bool
iswide_cjk (unichar uc)
{
@@ -129,19 +108,16 @@ iswide_cjk (unichar uc)
return false;
#endif
}
-
Type
get_type (unichar uc)
{
return Type (g_unichar_type (uc));
}
-
BreakType
get_break (unichar uc)
{
return BreakType (g_unichar_break_type (uc));
}
-
/* --- ensure castable Birnet::Unichar::Type --- */
BIRNET_STATIC_ASSERT (Unichar::CONTROL == (int) G_UNICODE_CONTROL);
BIRNET_STATIC_ASSERT (Unichar::FORMAT == (int) G_UNICODE_FORMAT);
@@ -173,7 +149,6 @@ BIRNET_STATIC_ASSERT (Unichar::OTHER_SYMBOL == (int) G_UNICODE_OTHER_SYMBOL);
BIRNET_STATIC_ASSERT (Unichar::LINE_SEPARATOR == (int) G_UNICODE_LINE_SEPARATOR);
BIRNET_STATIC_ASSERT (Unichar::PARAGRAPH_SEPARATOR == (int) G_UNICODE_PARAGRAPH_SEPARATOR);
BIRNET_STATIC_ASSERT (Unichar::SPACE_SEPARATOR == (int) G_UNICODE_SPACE_SEPARATOR);
-
/* --- ensure castable Birnet::Unichar::BreakType --- */
BIRNET_STATIC_ASSERT (Unichar::BREAK_MANDATORY == (int) G_UNICODE_BREAK_MANDATORY);
BIRNET_STATIC_ASSERT (Unichar::BREAK_CARRIAGE_RETURN == (int) G_UNICODE_BREAK_CARRIAGE_RETURN);
@@ -214,7 +189,6 @@ BIRNET_STATIC_ASSERT (Unichar::BREAK_HANGUL_LV_SYLLABLE == (int) G_UNICODE_BREAK
BIRNET_STATIC_ASSERT (Unichar::BREAK_HANGUL_LVT_SYLLABLE == (int) G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE);
#endif
} // Unichar
-
/* --- UTF-8 movement --- */
const int8 utf8_skip_table[256] = {
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@@ -226,7 +200,6 @@ const int8 utf8_skip_table[256] = {
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
};
-
static inline const int8
utf8_char_length (const uint8 c)
{
@@ -238,14 +211,12 @@ utf8_length_bits (const uint8 l)
const uint length_bits[] = { 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, };
return l <= 6 ? length_bits[l] : 0;
}
-
static inline const uint8
utf8_char_mask (const uint8 c)
{
const uint8 char_masks[8] = { 0x00, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00 };
return char_masks[utf8_skip_table[c]];
}
-
static inline uint8
utf8_length_from_unichar (unichar uc)
{
@@ -257,7 +228,6 @@ utf8_length_from_unichar (unichar uc)
l += uc >= 0x04000000; /* 6 */
return l;
}
-
unichar
utf8_to_unichar (const char *str)
{
@@ -275,7 +245,6 @@ utf8_to_unichar (const char *str)
}
return uc;
}
-
int
utf8_from_unichar (unichar uc,
char str[8])
@@ -293,7 +262,6 @@ utf8_from_unichar (unichar uc,
str[i] = uc | utf8_length_bits (l); /* i == 0 */
return l;
}
-
bool
utf8_validate (const String &strng,
int *bound)
@@ -306,5 +274,4 @@ utf8_validate (const String &strng,
*bound = !gb ? end - c : -1;
return gb != false;
}
-
} // Birnet
diff --git a/birnet/birnetutf8.hh b/birnet/birnetutf8.hh
index 22afa00..56576a7 100644
--- a/birnet/birnetutf8.hh
+++ b/birnet/birnetutf8.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_UTF8_HH__
#define __BIRNET_UTF8_HH__
-
#include <birnet/birnetutils.hh>
-
namespace Birnet {
-
namespace Unichar {
inline bool isvalid (unichar uc) BIRNET_CONST;
bool isalnum (unichar uc) BIRNET_CONST;
@@ -56,9 +53,7 @@ typedef enum {
BREAK_HANGUL_T_JAMO, BREAK_HANGUL_LV_SYLLABLE, BREAK_HANGUL_LVT_SYLLABLE
} BreakType;
BreakType get_break (unichar uc) BIRNET_CONST;
-
} // Unichar
-
/* --- UTF-8 movement --- */
inline const char* utf8_next (const char *c);
inline char* utf8_next (char *c);
@@ -82,7 +77,6 @@ int utf8_from_unichar (unichar uc,
char str[8]);
bool utf8_validate (const String &string,
int *bound = NULL);
-
/* --- implementation bits --- */
namespace Unichar {
inline bool
@@ -99,21 +93,17 @@ isvalid (unichar uc)
return true;
}
} // Unichar
-
extern const int8 utf8_skip_table[256];
-
inline const char*
utf8_next (const char *c)
{
return c + utf8_skip_table[(uint8) *c];
}
-
inline char*
utf8_next (char *c)
{
return c + utf8_skip_table[(uint8) *c];
}
-
inline const char*
utf8_prev (const char *c)
{
@@ -122,7 +112,6 @@ utf8_prev (const char *c)
while ((*c & 0xc0) == 0x80);
return c;
}
-
inline char*
utf8_prev (char *c)
{
@@ -131,7 +120,6 @@ utf8_prev (char *c)
while ((*c & 0xc0) == 0x80);
return c;
}
-
inline const char*
utf8_find_next (const char *c,
const char *bound)
@@ -142,14 +130,12 @@ utf8_find_next (const char *c,
while ((!bound || c < bound) && (*c & 0xc0) == 0x80);
return !bound || c < bound ? c : NULL;
}
-
inline char*
utf8_find_next (char *c,
const char *bound)
{
return const_cast<char*> (utf8_find_next (const_cast<const char*> (c), bound));
}
-
inline const char*
utf8_find_prev (const char *start,
const char *current)
@@ -159,14 +145,12 @@ utf8_find_prev (const char *start,
while (current >= start && (*current & 0xc0) == 0x80);
return current >= start ? current : NULL;
}
-
inline char*
utf8_find_prev (const char *start,
char *current)
{
return const_cast<char*> (utf8_find_prev (start, const_cast<const char*> (current)));
}
-
inline const char*
utf8_align (const char *start,
const char *current)
@@ -175,21 +159,17 @@ utf8_align (const char *start,
current--;
return current;
}
-
inline char*
utf8_align (const char *start,
char *current)
{
return const_cast<char*> (utf8_align (start, const_cast<const char*> (current)));
}
-
inline bool
utf8_aligned (const char *c)
{
return (*c & 0xc0) == 0x80;
}
-
} // Birnet
-
#endif /* __BIRNET_UTF8_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetutils.cc b/birnet/birnetutils.cc
index 45c35de..eea6dc0 100644
--- a/birnet/birnetutils.cc
+++ b/birnet/birnetutils.cc
@@ -17,27 +17,20 @@
#include <signal.h>
#include <string.h>
#include <stdio.h>
-
#ifndef _
#define _(s) s
#endif
-
namespace Birnet {
-
static Msg::CustomType debug_browser ("browser", Msg::DEBUG);
-
static const InitSettings *birnet_init_settings = NULL;
-
InitSettings
init_settings ()
{
return *birnet_init_settings;
}
-
/* --- InitHooks --- */
static void (*run_init_hooks) () = NULL;
static InitHook *init_hooks = NULL;
-
InitHook::InitHook (InitHookFunc _func,
int _priority) :
next (NULL), priority (_priority), hook (_func)
@@ -48,7 +41,6 @@ InitHook::InitHook (InitHookFunc _func,
init_hooks = this;
run_init_hooks = invoke_hooks;
}
-
void
InitHook::invoke_hooks (void)
{
@@ -67,13 +59,11 @@ InitHook::invoke_hooks (void)
for (std::vector<InitHook*>::iterator it = hv.begin(); it != hv.end(); it++)
(*it)->hook();
}
-
/* --- initialization --- */
static InitSettings global_init_settings = {
false, /* stand_alone */
false, /* perf_test */
};
-
static void
birnet_parse_settings_and_args (InitValue *value,
int *argc_p,
@@ -138,7 +128,6 @@ birnet_parse_settings_and_args (InitValue *value,
}
*argc_p = e;
}
-
void
birnet_init (int *argcp,
char ***argvp,
@@ -148,7 +137,6 @@ birnet_init (int *argcp,
/* mandatory initial initialization */
if (!g_threads_got_initialized)
g_thread_init (NULL);
-
/* update program/application name upon repeated initilization */
char *prg_name = argcp && *argcp ? g_path_get_basename ((*argvp)[0]) : NULL;
if (birnet_init_settings != NULL)
@@ -160,7 +148,6 @@ birnet_init (int *argcp,
g_set_application_name (app_name);
return; /* simply ignore repeated initializations */
}
-
/* normal initialization */
birnet_init_settings = &global_init_settings;
birnet_parse_settings_and_args (ivalues, argcp, argvp);
@@ -169,7 +156,6 @@ birnet_init (int *argcp,
g_free (prg_name);
if (app_name && (!g_get_application_name() || g_get_application_name() == g_get_prgname()))
g_set_application_name (app_name);
-
/* initialize random numbers */
{
struct timeval tv;
@@ -177,14 +163,12 @@ birnet_init (int *argcp,
srand48 (tv.tv_usec + (tv.tv_sec << 16));
srand (lrand48());
}
-
/* initialize sub systems */
_birnet_init_cpuinfo();
_birnet_init_threads();
if (run_init_hooks)
run_init_hooks();
}
-
bool
init_value_bool (InitValue *value)
{
@@ -201,7 +185,6 @@ init_value_bool (InitValue *value)
else
return ABS (value->value_num) >= 0.5;
}
-
double
init_value_double (InitValue *value)
{
@@ -209,7 +192,6 @@ init_value_double (InitValue *value)
return g_strtod (value->value_string, NULL);
return value->value_num;
}
-
int64
init_value_int (InitValue *value)
{
@@ -217,7 +199,6 @@ init_value_int (InitValue *value)
return strtoll (value->value_string, NULL, 0);
return int64 (value->value_num + 0.5);
}
-
/* --- limits.h & float.h checks --- */
/* assert several assumptions the code makes */
BIRNET_STATIC_ASSERT (CHAR_BIT == +8);
@@ -242,14 +223,12 @@ BIRNET_STARTUP_ASSERT (DBL_EPSILON <= 1E-9);
BIRNET_STATIC_ASSERT (LDBL_MIN <= 1E-37);
BIRNET_STATIC_ASSERT (LDBL_MAX >= 1E+37);
BIRNET_STATIC_ASSERT (LDBL_EPSILON <= 1E-9);
-
/* --- assertions/warnings/errors --- */
void
raise_sigtrap ()
{
raise (SIGTRAP);
}
-
static void
stderr_print (bool bail_out,
const char *prefix,
@@ -284,7 +263,6 @@ stderr_print (bool bail_out,
fputs (msg.c_str(), stderr);
fflush (stderr);
}
-
void
birnet_runtime_problem (char ewran_tag,
const char *domain,
@@ -299,7 +277,6 @@ birnet_runtime_problem (char ewran_tag,
birnet_runtime_problemv (ewran_tag, domain, file, line, funcname, msgformat, args);
va_end (args);
}
-
void
birnet_runtime_problemv (char ewran_tag,
const char *domain,
@@ -344,23 +321,19 @@ birnet_runtime_problemv (char ewran_tag,
abort();
}
}
-
/* --- VirtualTypeid --- */
VirtualTypeid::~VirtualTypeid ()
{ /* virtual destructor ensures vtable */ }
-
String
VirtualTypeid::typeid_name ()
{
return typeid (*this).name();
}
-
String
VirtualTypeid::typeid_pretty_name ()
{
return cxx_demangle (typeid (*this).name());
}
-
String
VirtualTypeid::cxx_demangle (const char *mangled_identifier)
{
@@ -371,7 +344,6 @@ VirtualTypeid::cxx_demangle (const char *mangled_identifier)
free (malloced_result);
return result;
}
-
/* --- string utils --- */
String
string_tolower (const String &str)
@@ -381,7 +353,6 @@ string_tolower (const String &str)
s[i] = Unichar::tolower (s[i]);
return s;
}
-
String
string_toupper (const String &str)
{
@@ -390,7 +361,6 @@ string_toupper (const String &str)
s[i] = Unichar::toupper (s[i]);
return s;
}
-
String
string_totitle (const String &str)
{
@@ -399,7 +369,6 @@ string_totitle (const String &str)
s[i] = Unichar::totitle (s[i]);
return s;
}
-
String
string_printf (const char *format,
...)
@@ -411,7 +380,6 @@ string_printf (const char *format,
va_end (args);
return str;
}
-
String
string_vprintf (const char *format,
va_list vargs)
@@ -426,7 +394,6 @@ string_vprintf (const char *format,
else
return format;
}
-
String
string_strip (const String &str)
{
@@ -438,7 +405,6 @@ string_strip (const String &str)
start++;
return String (cstr + start, end - start);
}
-
bool
string_to_bool (const String &string)
{
@@ -468,13 +434,11 @@ string_to_bool (const String &string)
p[0] == 'f' || p[0] == 'F' ||
p[0] == 'n' || p[0] == 'N');
}
-
String
string_from_bool (bool value)
{
return String (value ? "1" : "0");
}
-
uint64
string_to_uint (const String &string,
uint base)
@@ -485,13 +449,11 @@ string_to_uint (const String &string,
bool hex = p[0] == '0' && (p[1] == 'X' || p[1] == 'x');
return strtoull (hex ? p + 2 : p, NULL, hex ? 16 : base);
}
-
String
string_from_uint (uint64 value)
{
return string_printf ("%llu", value);
}
-
bool
string_has_int (const String &string)
{
@@ -500,7 +462,6 @@ string_has_int (const String &string)
p++;
return p[0] >= '0' && p[0] <= '9';
}
-
int64
string_to_int (const String &string,
uint base)
@@ -511,19 +472,16 @@ string_to_int (const String &string,
bool hex = p[0] == '0' && (p[1] == 'X' || p[1] == 'x');
return strtoll (hex ? p + 2 : p, NULL, hex ? 16 : base);
}
-
String
string_from_int (int64 value)
{
return string_printf ("%lld", value);
}
-
double
string_to_double (const String &string)
{
return g_ascii_strtod (string.c_str(), NULL);
}
-
String
string_from_float (float value)
{
@@ -531,7 +489,6 @@ string_from_float (float value)
g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%.7g", value);
return String (numbuf);
}
-
String
string_from_double (double value)
{
@@ -539,7 +496,6 @@ string_from_double (double value)
g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%.17g", value);
return String (numbuf);
}
-
vector<double>
string_to_vector (const String &string)
{
@@ -576,7 +532,6 @@ string_to_vector (const String &string)
// printf ("vector: %d: %s\n", dvec.size(), string_from_vector (dvec).c_str());
return dvec;
}
-
String
string_from_vector (const vector<double> &dvec,
const String &delim)
@@ -590,7 +545,6 @@ string_from_vector (const vector<double> &dvec,
}
return s;
}
-
String
string_from_errno (int errno_val)
{
@@ -600,7 +554,6 @@ string_from_errno (int errno_val)
return strerror (errno_val);
return buffer;
}
-
bool
string_is_uuid (const String &uuid_string) /* check uuid formatting */
{
@@ -623,21 +576,18 @@ string_is_uuid (const String &uuid_string) /* check uuid formatting */
return false;
return true;
}
-
int
string_cmp_uuid (const String &uuid_string1,
const String &uuid_string2) /* -1=smaller, 0=equal, +1=greater (assuming valid uuid strings) */
{
return strcasecmp (uuid_string1.c_str(), uuid_string2.c_str()); /* good enough for numeric equality and defines stable order */
}
-
/* --- file utils --- */
/**
* @namespace Birnet::Path
* The Birnet::Path namespace covers function for file path manipulation and evaluation.
*/
namespace Path {
-
const String
dirname (const String &path)
{
@@ -649,7 +599,6 @@ dirname (const String &path)
base--;
return String (filename, base - filename + 1);
}
-
const String
basename (const String &path)
{
@@ -659,20 +608,17 @@ basename (const String &path)
return filename;
return String (base + 1);
}
-
bool
isabs (const String &path)
{
return g_path_is_absolute (path.c_str());
}
-
const String
skip_root (const String &path)
{
const char *frag = g_path_skip_root (path.c_str());
return frag;
}
-
const String
join (const String &frag0, const String &frag1,
const String &frag2, const String &frag3,
@@ -692,13 +638,11 @@ join (const String &frag0, const String &frag1,
g_free (cpath);
return path;
}
-
static int
errno_check_file (const char *file_name,
const char *mode)
{
uint access_mask = 0, nac = 0;
-
if (strchr (mode, 'e')) /* exists */
nac++, access_mask |= F_OK;
if (strchr (mode, 'r')) /* readable */
@@ -708,13 +652,11 @@ errno_check_file (const char *file_name,
bool check_exec = strchr (mode, 'x') != NULL;
if (check_exec) /* executable */
nac++, access_mask |= X_OK;
-
/* on some POSIX systems, X_OK may succeed for root without any
* executable bits set, so we also check via stat() below.
*/
if (nac && access (file_name, access_mask) < 0)
return -errno;
-
bool check_file = strchr (mode, 'f') != NULL; /* open as file */
bool check_dir = strchr (mode, 'd') != NULL; /* open as directory */
bool check_link = strchr (mode, 'l') != NULL; /* open as link */
@@ -722,11 +664,9 @@ errno_check_file (const char *file_name,
bool check_block = strchr (mode, 'b') != NULL; /* open as block device */
bool check_pipe = strchr (mode, 'p') != NULL; /* open as pipe */
bool check_socket = strchr (mode, 's') != NULL; /* open as socket */
-
if (check_exec || check_file || check_dir || check_link || check_char || check_block || check_pipe || check_socket)
{
struct stat st;
-
if (check_link)
{
if (lstat (file_name, &st) < 0)
@@ -734,7 +674,6 @@ errno_check_file (const char *file_name,
}
else if (stat (file_name, &st) < 0)
return -errno;
-
if (0)
g_printerr ("file-check(\"%s\",\"%s\"): %s%s%s%s%s%s%s\n",
file_name, mode,
@@ -745,7 +684,6 @@ errno_check_file (const char *file_name,
S_ISBLK (st.st_mode) ? "b" : "",
S_ISFIFO (st.st_mode) ? "p" : "",
S_ISSOCK (st.st_mode) ? "s" : "");
-
if (S_ISDIR (st.st_mode) && (check_file || check_link || check_char || check_block || check_pipe))
return -EISDIR;
if (check_file && !S_ISREG (st.st_mode))
@@ -765,10 +703,8 @@ errno_check_file (const char *file_name,
if (check_exec && !(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return -EACCES; /* for root executable, any +x bit is good enough */
}
-
return 0;
}
-
/**
* @param file possibly relative filename
* @param mode feature string
@@ -797,7 +733,6 @@ check (const String &file,
errno = err < 0 ? -err : 0;
return errno == 0;
}
-
/**
* @param file1 possibly relative filename
* @param file2 possibly relative filename
@@ -826,15 +761,12 @@ equals (const String &file1,
st1.st_ino == st2.st_ino &&
st1.st_rdev == st2.st_rdev);
}
-
} // Path
-
/* --- Deletable --- */
Deletable::~Deletable ()
{
invoke_deletion_hooks();
}
-
/**
* @param deletable possible Deletable* handle
* @return TRUE if the hook was added
@@ -853,7 +785,6 @@ Deletable::DeletionHook::deletable_add_hook (Deletable *deletable)
}
return false;
}
-
/**
* @param deletable possible Deletable* handle
* @return TRUE if the hook was removed
@@ -872,27 +803,23 @@ Deletable::DeletionHook::deletable_remove_hook (Deletable *deletable)
}
return false;
}
-
Deletable::DeletionHook::~DeletionHook ()
{
if (this->next || this->prev)
g_error ("%s: hook is being destroyed but not unlinked: %p", G_STRFUNC, this);
}
-
#if 0
static struct {
Mutex mutex;
std::map<Deletable*,Deletable::DeletionHook*> dmap;
} deletable_maps[19]; /* use prime size for hashing, sum up to roughly 1k (use 83 for 4k) */
#endif
-
#define DELETABLE_MAP_HASH (19) /* use prime size for hashing, sum up to roughly 1k (use 83 for 4k) */
struct DeletableMap {
Mutex mutex;
std::map<Deletable*,Deletable::DeletionHook*> dmap;
};
static DeletableMap * volatile deletable_maps = NULL;
-
static inline void
auto_init_deletable_maps (void)
{
@@ -903,7 +830,6 @@ auto_init_deletable_maps (void)
delete dmaps;
}
}
-
/**
* @param hook valid deletion hook
*
@@ -937,7 +863,6 @@ Deletable::add_deletion_hook (DeletionHook *hook)
hook->monitoring_deletable (*this);
//g_printerr ("DELETABLE-ADD(%p,%p)\n", this, hook);
}
-
/**
* @param hook valid deletion hook
*
@@ -964,7 +889,6 @@ Deletable::remove_deletion_hook (DeletionHook *hook)
deletable_maps[hashv].mutex.unlock();
//g_printerr ("DELETABLE-REM(%p,%p)\n", this, hook);
}
-
/**
* Invoke all deletion hooks installed on this deletable.
*/
@@ -1004,33 +928,27 @@ Deletable::invoke_deletion_hooks()
}
}
}
-
/* --- ReferenceCountImpl --- */
void
ReferenceCountImpl::ref_diag (const char *msg) const
{
fprintf (stderr, "%s: this=%p ref_count=%d floating=%d", msg ? msg : "ReferenceCountImpl", this, ref_count(), floating());
}
-
void
ReferenceCountImpl::finalize ()
{}
-
void
ReferenceCountImpl::delete_this ()
{
delete this;
}
-
ReferenceCountImpl::~ReferenceCountImpl ()
{
BIRNET_ASSERT (ref_count() == 0);
}
-
/* --- DataList --- */
DataList::NodeBase::~NodeBase ()
{}
-
void
DataList::set_data (NodeBase *node)
{
@@ -1042,7 +960,6 @@ DataList::set_data (NodeBase *node)
node->next = nodes;
nodes = node;
}
-
DataList::NodeBase*
DataList::get_data (DataKey<void> *key) const
{
@@ -1052,7 +969,6 @@ DataList::get_data (DataKey<void> *key) const
return it;
return NULL;
}
-
DataList::NodeBase*
DataList::rip_data (DataKey<void> *key)
{
@@ -1070,7 +986,6 @@ DataList::rip_data (DataKey<void> *key)
}
return NULL;
}
-
void
DataList::clear_like_destructor()
{
@@ -1082,12 +997,10 @@ DataList::clear_like_destructor()
delete it;
}
}
-
DataList::~DataList()
{
clear_like_destructor();
}
-
/* --- url handling --- */
bool
url_test_show (const char *url)
@@ -1175,7 +1088,6 @@ url_test_show (const char *url)
www_browsers[i].disabled = false;
return false;
}
-
static void
browser_launch_warning (const char *url)
{
@@ -1185,7 +1097,6 @@ browser_launch_warning (const char *url)
Msg::Text2 (_("No suitable web browser executable could be found to be executed and to display the URL: %s"), url),
Msg::Check (_("Show messages about web browser launch problems")));
}
-
void
url_show (const char *url)
{
@@ -1193,7 +1104,6 @@ url_show (const char *url)
if (!success)
browser_launch_warning (url);
}
-
static void
unlink_file_name (gpointer data)
{
@@ -1201,7 +1111,6 @@ unlink_file_name (gpointer data)
while (unlink (file_name) < 0 && errno == EINTR);
g_free (file_name);
}
-
static const gchar*
url_create_redirect (const char *url,
const char *url_title,
@@ -1254,7 +1163,6 @@ url_create_redirect (const char *url,
cleanup_add (60 * 1000, unlink_file_name, tname); /* free tname */
return tname;
}
-
bool
url_test_show_with_cookie (const char *url,
const char *url_title,
@@ -1266,7 +1174,6 @@ url_test_show_with_cookie (const char *url,
else
return url_test_show (url);
}
-
void
url_show_with_cookie (const char *url,
const char *url_title,
@@ -1276,17 +1183,14 @@ url_show_with_cookie (const char *url,
if (!success)
browser_launch_warning (url);
}
-
/* --- cleanups --- */
typedef struct {
uint id;
GDestroyNotify handler;
void *data;
} Cleanup;
-
static Mutex cleanup_mutex;
static GSList *cleanup_list = NULL;
-
static void
cleanup_exec_Lm (Cleanup *cleanup)
{
@@ -1299,7 +1203,6 @@ cleanup_exec_Lm (Cleanup *cleanup)
handler (data);
cleanup_mutex.lock();
}
-
/**
* Force all cleanup handlers (see birnet_cleanup_add()) to be immediately
* executed. This function should be called at program exit to execute
@@ -1313,7 +1216,6 @@ cleanup_force_handlers (void)
cleanup_exec_Lm ((Cleanup*) cleanup_list->data);
cleanup_mutex.unlock();
}
-
static gboolean
cleanup_exec (gpointer data)
{
@@ -1322,7 +1224,6 @@ cleanup_exec (gpointer data)
cleanup_mutex.unlock();
return FALSE;
}
-
/**
* @param timeout_ms timeout in milliseconds
* @param handler cleanup handler to run
@@ -1347,7 +1248,6 @@ cleanup_add (guint timeout_ms,
cleanup_mutex.unlock();
return cleanup->id;
}
-
/* --- string utils --- */
void
memset4 (guint32 *mem,
@@ -1359,7 +1259,6 @@ memset4 (guint32 *mem,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) mem, filler, length);
}
-
/* --- memory utils --- */
void*
malloc_aligned (gsize total_size,
@@ -1368,12 +1267,10 @@ malloc_aligned (gsize total_size,
{
const bool alignment_power_of_2 = (alignment & (alignment - 1)) == 0;
const gsize cache_line_size = 64; // ensure that no false sharing will occur (at begin and end of data)
-
if (alignment_power_of_2)
{
// for power of 2 alignment, we guarantee also cache line alignment
alignment = std::max (alignment, cache_line_size);
-
uint8 *aligned_mem = (uint8 *) g_malloc (total_size + (alignment - 1) + (cache_line_size - 1));
*free_pointer = aligned_mem;
if ((ptrdiff_t) aligned_mem % alignment)
@@ -1391,10 +1288,8 @@ malloc_aligned (gsize total_size,
return aligned_mem;
}
}
-
/* --- zintern support --- */
#include <zlib.h>
-
/**
* @param decompressed_size exact size of the decompressed data to be returned
* @param cdata compressed data block
@@ -1422,7 +1317,6 @@ zintern_decompress (unsigned int decompressed_size,
uint8 *text = (uint8*) g_try_malloc (len);
if (!text)
return NULL; /* handle ENOMEM gracefully */
-
int64 result = uncompress (text, &dlen, cdata, cdata_size);
const char *err;
switch (result)
@@ -1451,15 +1345,12 @@ zintern_decompress (unsigned int decompressed_size,
}
if (err)
g_error ("failed to decompress (%p, %u): %s", cdata, cdata_size, err);
-
text[dlen] = 0;
return text; /* success */
}
-
void
zintern_free (uint8 *dc_data)
{
g_free (dc_data);
}
-
} // Birnet
diff --git a/birnet/birnetutils.hh b/birnet/birnetutils.hh
index ca350b2..cc18075 100644
--- a/birnet/birnetutils.hh
+++ b/birnet/birnetutils.hh
@@ -1,16 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BIRNET_UTILS_XX_HH__
#define __BIRNET_UTILS_XX_HH__
-
#include <birnet/birnetcdefs.h>
#include <glib.h> /* g_free */
#include <string>
#include <vector>
#include <map>
#include <stdarg.h>
-
namespace Birnet {
-
/* --- short integer types --- */
typedef BirnetUInt8 uint8;
typedef BirnetUInt16 uint16;
@@ -21,7 +18,6 @@ typedef BirnetInt16 int16;
typedef BirnetInt32 int32;
typedef BirnetInt64 int64;
typedef BirnetUnichar unichar;
-
/* --- convenient stdc++ types --- */
typedef std::string String;
using std::vector;
@@ -36,7 +32,6 @@ public:
String typeid_pretty_name ();
static String cxx_demangle (const char *mangled_identifier);
};
-
/* --- implement assertion macros --- */
#ifndef BIRNET__RUNTIME_PROBLEM
#define BIRNET__RUNTIME_PROBLEM(ErrorWarningReturnAssertNotreach,domain,file,line,funcname,...) \
@@ -56,7 +51,6 @@ void birnet_runtime_problemv (char ewran_tag,
const char *funcname,
const char *msgformat,
va_list msgargs);
-
/* --- private copy constructor and assignment operator --- */
#define BIRNET_PRIVATE_CLASS_COPY(Class) private: Class (const Class&); Class& operator= (const Class&);
#ifdef _BIRNET_SOURCE_EXTENSIONS
@@ -64,7 +58,6 @@ void birnet_runtime_problemv (char ewran_tag,
#define return_if_fail g_return_if_fail
#define return_val_if_fail g_return_val_if_fail
#endif /* _BIRNET_SOURCE_EXTENSIONS */
-
/* --- initialization --- */
typedef BirnetInitValue InitValue;
typedef BirnetInitSettings InitSettings;
@@ -76,7 +69,6 @@ void birnet_init (int *argcp,
bool init_value_bool (InitValue *value);
double init_value_double (InitValue *value);
int64 init_value_int (InitValue *value);
-
/* --- initialization hooks --- */
class InitHook {
typedef void (*InitHookFunc) (void);
@@ -89,7 +81,6 @@ public:
explicit InitHook (InitHookFunc _func,
int _priority = 0);
};
-
/* --- assertions/warnings/errors --- */
void raise_sigtrap ();
#if (defined __i386__ || defined __x86_64__) && defined __GNUC__ && __GNUC__ >= 2
@@ -99,10 +90,8 @@ extern inline void BREAKPOINT() { __asm__ __volatile__ ("bpt"); }
#else /* !__i386__ && !__alpha__ */
extern inline void BREAKPOINT() { raise_sigtrap(); }
#endif /* __i386__ */
-
/* --- threading implementaiton bit --- */
extern BirnetThreadTable ThreadTable; /* private, provided by birnetthreadimpl.cc */
-
/* --- string functionality --- */
String string_tolower (const String &str);
String string_toupper (const String &str);
@@ -149,7 +138,6 @@ String string_from_errno (int errno_val);
bool string_is_uuid (const String &uuid_string); /* check uuid formatting */
int string_cmp_uuid (const String &uuid_string1,
const String &uuid_string2); /* -1=smaller, 0=equal, +1=greater (assuming valid uuid strings) */
-
/* --- file/path functionality --- */
namespace Path {
const String dirname (const String &path);
@@ -169,7 +157,6 @@ bool check (const String &file,
bool equals (const String &file1,
const String &file2);
} // Path
-
/* --- url handling --- */
void url_show (const char *url);
void url_show_with_cookie (const char *url,
@@ -179,13 +166,11 @@ bool url_test_show (const char *url);
bool url_test_show_with_cookie (const char *url,
const char *url_title,
const char *cookie);
-
/* --- cleanup registration --- */
uint cleanup_add (uint timeout_ms,
void (*destroy_data) (void*),
void *data);
void cleanup_force_handlers (void);
-
/* --- string utils --- */
void memset4 (uint32 *mem,
uint32 filler,
@@ -194,16 +179,13 @@ void memset4 (uint32 *mem,
void* malloc_aligned (size_t total_size,
size_t alignment,
uint8 **free_pointer);
-
/* --- C++ demangling --- */
char* cxx_demangle (const char *mangled_identifier); /* in birnetutilsxx.cc */
-
/* --- zintern support --- */
uint8* zintern_decompress (unsigned int decompressed_size,
const unsigned char *cdata,
unsigned int cdata_size);
void zintern_free (uint8 *dc_data);
-
/* --- template errors --- */
namespace TEMPLATE_ERROR {
// to error out, call invalid_type<YourInvalidType>();
@@ -211,7 +193,6 @@ template<typename Type> void invalid_type () { bool force_compiler_error = void
// to error out, derive from InvalidType<YourInvalidType>
template<typename Type> class InvalidType;
}
-
/* --- Deletable --- */
/**
* Deletable is a virtual base class that can be derived from (usually with
@@ -249,7 +230,6 @@ protected:
void invoke_deletion_hooks ();
virtual ~Deletable ();
};
-
/* --- ReferenceCountImpl --- */
class ReferenceCountImpl : public virtual Deletable
{
@@ -349,7 +329,6 @@ template<class Obj> static void unref (Obj &obj) { obj.unref(); }
template<class Obj> static void unref (Obj *obj) { obj->unref(); }
template<class Obj> static void sink (Obj &obj) { obj.ref_sink(); obj.unref(); }
template<class Obj> static void sink (Obj *obj) { obj->ref_sink(); obj->unref(); }
-
/* --- Binary Lookups --- */
template<typename RandIter, class Cmp, typename Arg, int case_lookup_or_sibling_or_insertion>
static inline std::pair<RandIter,bool>
@@ -419,7 +398,6 @@ binary_lookup (RandIter begin,
/* return end or exact match */
return binary_lookup_fuzzy<RandIter,Cmp,Arg,0> (begin, end, cmp_elements, arg).first;
}
-
/* --- generic named data --- */
template<typename Type>
class DataKey {
@@ -432,7 +410,6 @@ public:
virtual void destroy (Type data) { /* destruction hook */ }
virtual ~DataKey () {}
};
-
class DataList {
class NodeBase {
protected:
@@ -531,7 +508,6 @@ private:
NodeBase* get_data (DataKey<void> *key) const;
NodeBase* rip_data (DataKey<void> *key);
};
-
/* --- DataListContainer --- */
class DataListContainer {
DataList data_list;
@@ -542,14 +518,12 @@ public: /* generic data API */
template<typename Type> inline Type swap_data (DataKey<Type> *key) { return data_list.swap (key); }
template<typename Type> inline void delete_data (DataKey<Type> *key) { data_list.del (key); }
};
-
/* --- class to allocate aligned memory --- */
template<class T, int ALIGN>
class AlignedArray {
unsigned char *unaligned_mem;
T *data;
size_t n_elements;
-
void
allocate_aligned_data()
{
@@ -563,7 +537,6 @@ public:
n_elements (elements.size())
{
allocate_aligned_data();
-
for (size_t i = 0; i < n_elements; i++)
new (data + i) T (elements[i]);
}
@@ -571,7 +544,6 @@ public:
n_elements (n_elements)
{
allocate_aligned_data();
-
for (size_t i = 0; i < n_elements; i++)
new (data + i) T();
}
@@ -580,7 +552,6 @@ public:
/* C++ destruction order: last allocated element is deleted first */
while (n_elements)
data[--n_elements].~T();
-
g_free (unaligned_mem);
}
T&
@@ -599,12 +570,8 @@ public:
return n_elements;
}
};
-
-
/* --- implementation --- */
void _birnet_init_threads (void);
-
} // Birnet
-
#endif /* __BIRNET_UTILS_XX_HH__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/datalist.cc b/birnet/tests/datalist.cc
index a1dcd35..4b7f8ec 100644
--- a/birnet/tests/datalist.cc
+++ b/birnet/tests/datalist.cc
@@ -1,10 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
//#define TEST_VERBOSE
#include <birnet/birnettests.h>
-
namespace {
using namespace Birnet;
-
class MyKey : public DataKey<int> {
void destroy (int i)
{
@@ -15,14 +13,12 @@ class MyKey : public DataKey<int> {
return -1;
}
};
-
class StringKey : public DataKey<String> {
void destroy (String s)
{
TPRINT ("%s: delete \"%s\";\n", STRFUNC, s.c_str());
}
};
-
template<class DataListContainer> static void
data_list_test_strings (DataListContainer &r)
{
@@ -35,7 +31,6 @@ data_list_test_strings (DataListContainer &r)
r.delete_data (&strkey);
TASSERT (String ("") == r.get_data (&strkey).c_str()); // fallback()
}
-
template<class DataListContainer> static void
data_list_test_ints (DataListContainer &r)
{
@@ -62,7 +57,6 @@ data_list_test_ints (DataListContainer &r)
r.set_data (&intkey, 9);
TASSERT (9 == r.get_data (&intkey));
}
-
static void
data_list_test ()
{
@@ -72,14 +66,12 @@ data_list_test ()
data_list_test_strings (r);
}
TDONE();
-
TSTART ("DataList<int>");
{
DataListContainer r;
data_list_test_ints (r);
}
TDONE();
-
TSTART ("DataList-mixed");
{
DataListContainer r;
@@ -88,7 +80,6 @@ data_list_test ()
data_list_test_strings (r);
}
TDONE();
-
TSTART ("DataList-threaded");
{
Thread &thread = Thread::self();
@@ -98,9 +89,7 @@ data_list_test ()
}
TDONE();
}
-
} // anon
-
int
main (int argc,
char *argv[])
diff --git a/birnet/tests/infotest.cc b/birnet/tests/infotest.cc
index f5e545c..c6bed98 100644
--- a/birnet/tests/infotest.cc
+++ b/birnet/tests/infotest.cc
@@ -2,11 +2,9 @@
//#define TEST_VERBOSE
#include <birnet/birnettests.h>
using namespace Birnet;
-
#if BIRNET_CHECK_VERSION (2147483647, 2147483647, 2147483647) || !BIRNET_CHECK_VERSION (0, 0, 1)
#error BIRNET_CHECK_VERSION() apparently broken
#endif
-
static void
test_cpu_info (void)
{
@@ -20,7 +18,6 @@ test_cpu_info (void)
TOK();
TDONE();
}
-
static void
test_paths()
{
@@ -53,7 +50,6 @@ test_paths()
TASSERT (Path::dirname ("dir" BIRNET_DIR_SEPARATOR_S "file") == "dir");
TDONE();
}
-
static void
test_zintern()
{
@@ -65,7 +61,6 @@ test_zintern()
TOK();
TDONE();
}
-
static void
test_files (const char *argv0)
{
@@ -84,7 +79,6 @@ test_files (const char *argv0)
TASSERT (Path::check (argv0, "s") == FALSE);
TDONE();
}
-
static void
test_messaging ()
{
@@ -118,7 +112,6 @@ test_messaging ()
Msg::Text3 ("And more message details: a, b, c."),
Msg::Check ("Show this message again."));
}
-
static void
test_virtual_typeid()
{
@@ -133,21 +126,17 @@ test_virtual_typeid()
TASSERT (strstr (b.typeid_pretty_name().c_str(), "TypeB") != NULL);
TDONE();
}
-
int
main (int argc,
char *argv[])
{
birnet_init_test (&argc, &argv);
-
test_cpu_info();
test_paths();
test_zintern();
test_files (argv[0]);
test_messaging();
test_virtual_typeid();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/math.cc b/birnet/tests/math.cc
index c0489d6..437e523 100644
--- a/birnet/tests/math.cc
+++ b/birnet/tests/math.cc
@@ -2,10 +2,8 @@
//#define TEST_VERBOSE
#include <birnet/birnettests.h>
#include <birnet/birnet.hh>
-
namespace {
using namespace Birnet;
-
static void
test_dtoi()
{
@@ -146,19 +144,14 @@ test_dtoi()
TASSERT (ifloor (-1125899906842624.7) == -1125899906842625LL);
TDONE();
}
-
} // Anon
-
int
main (int argc,
char *argv[])
{
birnet_init_test (&argc, &argv);
-
if (init_settings().test_quick)
test_dtoi();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/sorting.cc b/birnet/tests/sorting.cc
index dfcf2e0..620a4f0 100644
--- a/birnet/tests/sorting.cc
+++ b/birnet/tests/sorting.cc
@@ -4,24 +4,20 @@
#include <math.h>
#include <stdlib.h>
#include <algorithm>
-
namespace {
using namespace Birnet;
-
static int
compare_floats (float f1,
float f2)
{
return f1 < f2 ? -1 : f1 > f2;
}
-
static int
smaller_float (float f1,
float f2)
{
return f1 < f2;
}
-
static void
test_binary_lookup()
{
@@ -111,9 +107,7 @@ test_binary_lookup()
TASSERT (seen_inexact == true);
TDONE();
}
-
} // Anon
-
int
main (int argc,
char *argv[])
diff --git a/birnet/tests/strings.cc b/birnet/tests/strings.cc
index 42a94aa..737d733 100644
--- a/birnet/tests/strings.cc
+++ b/birnet/tests/strings.cc
@@ -3,12 +3,9 @@
#include <birnet/birnettests.h>
#include <stdlib.h>
#include <stdio.h>
-
using namespace Birnet;
-
namespace {
using namespace Birnet;
-
static void
random_tf8_and_unichar_test (void)
{
@@ -23,7 +20,6 @@ random_tf8_and_unichar_test (void)
continue;
char buffer[8], gstr[10] = { 0, };
int l;
-
l = utf8_from_unichar (uc, buffer);
TCHECK (l > 0);
TCHECK (l <= 7);
@@ -38,7 +34,6 @@ random_tf8_and_unichar_test (void)
TCHECK (p1 == buffer + l);
char *p2 = utf8_prev (p1);
TCHECK (p2 == buffer);
-
char cbuffer[1024];
snprintf (cbuffer, 1024, "x%sy7", buffer);
char *cur = cbuffer, *pn, *gn, *pp;
@@ -81,7 +76,6 @@ random_tf8_and_unichar_test (void)
/* first with bounds */
pp = utf8_find_prev (cbuffer, cbuffer);
TCHECK (pp == NULL);
-
/* validate valid UTF-8 */
bool bb = utf8_validate (cbuffer);
bool gb = g_utf8_validate (cbuffer, -1, NULL);
@@ -98,7 +92,6 @@ random_tf8_and_unichar_test (void)
}
TDONE();
}
-
static void
random_unichar_test (void)
{
@@ -113,7 +106,6 @@ random_unichar_test (void)
int bv, gv;
if (i % 20000 == 0)
TOK();
-
bb = Unichar::isvalid (uc);
gb = g_unichar_validate (uc);
TCHECK (bb == gb);
@@ -196,7 +188,6 @@ random_unichar_test (void)
}
TDONE();
}
-
static void
uuid_tests (void)
{
@@ -238,20 +229,15 @@ uuid_tests (void)
TASSERT (string_cmp_uuid ("a425fd92-4f06-11db-aea9-000102e7e309", "6ba7b812-9dad-11d1-80b4-00c04fd430c8") > 0);
TDONE();
}
-
} // Anon
-
int
main (int argc,
char *argv[])
{
birnet_init_test (&argc, &argv);
-
uuid_tests();
random_unichar_test();
random_tf8_and_unichar_test();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/systest.cc b/birnet/tests/systest.cc
index 4c33ddf..53f9819 100644
--- a/birnet/tests/systest.cc
+++ b/birnet/tests/systest.cc
@@ -2,10 +2,8 @@
//#define TEST_VERBOSE
#include <birnet/birnettests.h>
#include <poll.h>
-
namespace {
using namespace Birnet;
-
static void
test_poll()
{
@@ -22,18 +20,13 @@ test_poll()
TASSERT (BIRNET_SYSVAL_POLLNVAL == POLLNVAL);
TDONE();
}
-
} // Anon
-
int
main (int argc,
char *argv[])
{
birnet_init_test (&argc, &argv);
-
test_poll();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/threads.cc b/birnet/tests/threads.cc
index 4dd7964..5d306ae 100644
--- a/birnet/tests/threads.cc
+++ b/birnet/tests/threads.cc
@@ -3,10 +3,8 @@
#include <birnet/birnettests.h>
#include <unistd.h>
#include <stdlib.h>
-
namespace {
using namespace Birnet;
-
/* --- utilities --- */
BirnetThread*
birnet_thread_run (const gchar *name,
@@ -14,7 +12,6 @@ birnet_thread_run (const gchar *name,
gpointer user_data)
{
g_return_val_if_fail (name && name[0], NULL);
-
BirnetThread *thread = ThreadTable.thread_new (name);
ThreadTable.thread_ref_sink (thread);
if (ThreadTable.thread_start (thread, func, user_data))
@@ -25,7 +22,6 @@ birnet_thread_run (const gchar *name,
return NULL;
}
}
-
#define birnet_mutex_init(mtx) (ThreadTable.mutex_init (mtx))
#define birnet_mutex_lock(mtx) (ThreadTable.mutex_lock (mtx))
#define birnet_mutex_trylock(mtx) (0 == ThreadTable.mutex_trylock (mtx))
@@ -36,30 +32,25 @@ birnet_thread_run (const gchar *name,
#define birnet_rec_mutex_trylock(mtx) (0 == ThreadTable.rec_mutex_trylock (mtx))
#define birnet_rec_mutex_unlock(mtx) (ThreadTable.rec_mutex_unlock (mtx))
#define birnet_rec_mutex_destroy(mtx) (ThreadTable.rec_mutex_destroy (mtx))
-
#define BIRNET_MUTEX_DECLARE_INITIALIZED(mutexname) \
BirnetMutex mutexname = { 0 }; \
static void BIRNET_CONSTRUCTOR \
BIRNET_CPP_PASTE4 (__birnet_mutex__autoinit, __LINE__, __, mutexname) (void) \
{ ThreadTable.mutex_chain4init (&mutexname); }
-
#define BIRNET_REC_MUTEX_DECLARE_INITIALIZED(recmtx) \
BirnetRecMutex recmtx = { { 0 } }; \
static void BIRNET_CONSTRUCTOR \
BIRNET_CPP_PASTE4 (__birnet_rec_mutex__autoinit, __LINE__, __, recmtx) (void) \
{ ThreadTable.rec_mutex_chain4init (&recmtx); }
-
#define BIRNET_COND_DECLARE_INITIALIZED(condname) \
BirnetCond condname = { 0 }; \
static void BIRNET_CONSTRUCTOR \
BIRNET_CPP_PASTE4 (__birnet_cond__autoinit, __LINE__, __, condname) (void) \
{ ThreadTable.cond_chain4init (&condname); }
-
/* --- atomicity tests --- */
static volatile guint atomic_count = 0;
static BirnetMutex atomic_mutex;
static BirnetCond atomic_cond;
-
static void
atomic_up_thread (gpointer data)
{
@@ -72,7 +63,6 @@ atomic_up_thread (gpointer data)
birnet_mutex_unlock (&atomic_mutex);
TASSERT (strcmp (ThreadTable.thread_name (ThreadTable.thread_self()), "AtomicTest") == 0);
}
-
static void
atomic_down_thread (gpointer data)
{
@@ -85,7 +75,6 @@ atomic_down_thread (gpointer data)
birnet_mutex_unlock (&atomic_mutex);
TASSERT (strcmp (ThreadTable.thread_name (ThreadTable.thread_self()), "AtomicTest") == 0);
}
-
static void
test_atomic (void)
{
@@ -115,7 +104,6 @@ test_atomic (void)
TASSERT (atomic_counter == result);
TDONE ();
}
-
/* --- basic threading tests --- */
static void
plus1_thread (gpointer data)
@@ -126,11 +114,9 @@ plus1_thread (gpointer data)
while (!ThreadTable.thread_aborted ())
ThreadTable.thread_sleep (-1);
}
-
static BIRNET_MUTEX_DECLARE_INITIALIZED (static_mutex);
static BIRNET_REC_MUTEX_DECLARE_INITIALIZED (static_rec_mutex);
static BIRNET_COND_DECLARE_INITIALIZED (static_cond);
-
static void
test_threads (void)
{
@@ -205,7 +191,6 @@ test_threads (void)
ThreadTable.thread_unref (thread3);
TDONE ();
}
-
/* --- C++ threading tests --- */
struct ThreadA : public virtual Birnet::Thread {
int value;
@@ -224,7 +209,6 @@ struct ThreadA : public virtual Birnet::Thread {
ThreadTable.atomic_int_add (counter, value);
}
};
-
template<class M> static bool
lockable (M &mutex)
{
@@ -233,7 +217,6 @@ lockable (M &mutex)
mutex.unlock();
return lockable;
}
-
static void
test_thread_cxx (void)
{
@@ -262,7 +245,6 @@ test_thread_cxx (void)
}
TASSERT (atomic_counter == result);
TDONE ();
-
TSTART ("C++OwnedMutex");
static OwnedMutex static_omutex;
static_omutex.lock();
@@ -291,7 +273,6 @@ test_thread_cxx (void)
TASSERT (omutex.owner() == NULL);
TDONE();
}
-
/* --- auto locker tests --- */
static void
test_simple_auto_lock (Mutex &mutex1,
@@ -299,18 +280,13 @@ test_simple_auto_lock (Mutex &mutex1,
{
TASSERT (lockable (mutex1) == true);
TASSERT (lockable (mutex2) == true);
-
AutoLocker locker1 (mutex1);
-
TASSERT (lockable (mutex1) == false);
TASSERT (lockable (mutex2) == true);
-
AutoLocker locker2 (&mutex2);
-
TASSERT (lockable (mutex1) == false);
TASSERT (lockable (mutex2) == false);
}
-
static void
test_recursive_auto_lock (RecMutex &rec_mutex,
guint depth)
@@ -333,7 +309,6 @@ test_recursive_auto_lock (RecMutex &rec_mutex,
locker.unlock();
}
}
-
// helper class for testing auto locking, which counts the lock() and unlock() calls
class LockCounter {
guint m_lock_count;
@@ -359,7 +334,6 @@ public:
return m_lock_count;
}
};
-
class LockCountAssert {
const LockCounter &m_lock_counter;
const guint m_required_lock_count;
@@ -376,7 +350,6 @@ public:
TASSERT (m_lock_counter.lock_count() == m_required_lock_count);
}
};
-
/* Check that C++ constructors and destructors and the AutoLocker constructor
* and destructor will be executed in the order we need, that is: an AutoLocker
* that is created before an object should protect its constructor and
@@ -388,29 +361,21 @@ test_auto_locker_order()
{
LockCounter lock_counter1;
LockCounter lock_counter2;
-
for (guint i = 0; i < 3; i++)
{
LockCountAssert lc_assert1 (lock_counter1, 0);
LockCountAssert lc_assert2 (lock_counter2, 0);
-
AutoLocker auto_locker1 (lock_counter1);
-
LockCountAssert lc_assert3 (lock_counter1, 1);
LockCountAssert lc_assert4 (lock_counter2, 0);
-
AutoLocker auto_locker2 (lock_counter2);
-
LockCountAssert lc_assert5 (lock_counter1, 1);
LockCountAssert lc_assert6 (lock_counter2, 1);
-
AutoLocker auto_locker3 (lock_counter1);
-
LockCountAssert lc_assert7 (lock_counter1, 2);
LockCountAssert lc_assert8 (lock_counter2, 1);
}
}
-
static void
test_auto_locker_counting()
{
@@ -433,7 +398,6 @@ test_auto_locker_counting()
}
TASSERT (lock_counter.lock_count() == 0);
}
-
static void
test_auto_locker_cxx()
{
@@ -457,28 +421,21 @@ test_auto_locker_cxx()
}
Mutex mutex1, mutex2;
RecMutex rec_mutex;
-
TASSERT (lockable (mutex1) == true);
TASSERT (lockable (mutex2) == true);
test_simple_auto_lock (mutex1, mutex2);
test_simple_auto_lock (mutex1, mutex2);
TASSERT (lockable (mutex1) == true);
TASSERT (lockable (mutex2) == true);
-
test_recursive_auto_lock (rec_mutex, 30);
AutoLocker locker (&rec_mutex);
test_recursive_auto_lock (rec_mutex, 17);
-
test_auto_locker_order();
-
test_auto_locker_counting();
-
TDONE();
}
-
/* --- auto locker benchmarks --- */
#define RUNS (500000)
-
class HeapLocker {
// like PtrAutoLocker but allocates on the heap
struct Lockable {
@@ -509,7 +466,6 @@ public:
void lock () { l.lock(); }
void unlock () { l.unlock(); }
};
-
static void
bench_heap_auto_locker()
{
@@ -521,7 +477,6 @@ bench_heap_auto_locker()
HeapLocker locker2 (rmutex);
}
}
-
static void
bench_direct_auto_locker()
{
@@ -564,7 +519,6 @@ bench_direct_auto_locker()
AutoLocker2 locker2 (rmutex);
}
}
-
class GenericAutoLocker {
// supports automated scope-bound lock/unlock for all kinds of objects
struct Locker {
@@ -598,7 +552,6 @@ public:
void unlock () const { locker()->unlock(); }
/*Des*/ ~GenericAutoLocker () { unlock(); }
};
-
static void
bench_generic_auto_locker()
{
@@ -610,7 +563,6 @@ bench_generic_auto_locker()
GenericAutoLocker locker2 (rmutex);
}
}
-
class PtrAutoLocker {
// like GenericAutoLocker but uses an extra pointer
struct Locker {
@@ -635,7 +587,6 @@ public:
void unlock () { locker->unlock(); }
/*Des*/ ~PtrAutoLocker () { unlock(); }
};
-
static void
bench_ptr_auto_locker()
{
@@ -647,7 +598,6 @@ bench_ptr_auto_locker()
PtrAutoLocker locker2 (rmutex);
}
}
-
static void
bench_birnet_auto_locker()
{
@@ -659,7 +609,6 @@ bench_birnet_auto_locker()
AutoLocker locker2 (rmutex);
}
}
-
static void
bench_manual_locker()
{
@@ -673,7 +622,6 @@ bench_manual_locker()
rmutex.unlock();
}
}
-
static void
bench_auto_locker_cxx()
{
@@ -780,7 +728,6 @@ bench_auto_locker_cxx()
treport_minimized ("Pointer-AutoLocker", pmin / pdups / RUNS * 1000. * 1000. * 1000., TUNIT_NSEC);
treport_minimized ("Heap-AutoLocker", tmin / tdups / RUNS * 1000. * 1000. * 1000., TUNIT_NSEC);
}
-
/* --- C++ atomicity tests --- */
static void
test_thread_atomic_cxx (void)
@@ -837,7 +784,6 @@ test_thread_atomic_cxx (void)
TASSERT (p == (void*) 4294967279U);
TDONE ();
}
-
/* --- thread_yield --- */
static inline void
handle_contention ()
@@ -859,7 +805,6 @@ handle_contention ()
*/
usleep (500); // 1usec is the minimum value to cause an effect
}
-
/* --- ring buffer --- */
typedef Atomic::RingBuffer<int> IntRingBuffer;
class IntSequence {
@@ -946,7 +891,6 @@ struct RingBufferReader : public virtual Birnet::Thread, IntSequence {
TPRINT ("%s done.", Thread::Self::name().c_str());
}
};
-
static void
test_ring_buffer ()
{
@@ -966,7 +910,6 @@ test_ring_buffer ()
TASSERT (rb1.n_writable() == ttl);
TASSERT (strncmp (buffer, testtext, n) == 0);
TDONE();
-
/* check lower end ring buffer sizes (high contention test) */
for (uint step = 1; step < 8; step++)
{
@@ -987,7 +930,6 @@ test_ring_buffer ()
unref (rbw);
TDONE();
}
-
/* check big ring buffer sizes */
if (true)
{
@@ -1009,7 +951,6 @@ test_ring_buffer ()
TDONE();
}
}
-
/* --- --- */
static void
test_debug_channel ()
@@ -1042,7 +983,6 @@ test_debug_channel ()
TICK();
TDONE();
}
-
/* --- late deletable destruction --- */
static bool deletable_destructor = false;
struct MyDeletable : public virtual Deletable {
@@ -1083,10 +1023,8 @@ struct MyDeletableHook : public Deletable::DeletionHook {
deletable = NULL;
}
};
-
static MyDeletable early_deletable __attribute__ ((init_priority (101)));
static MyDeletable late_deletable __attribute__ ((init_priority (65535)));
-
static void
test_deletable_destruction ()
{
@@ -1121,7 +1059,6 @@ test_deletable_destruction ()
TDONE();
/* early_deletable and late_deletable are only tested at program end */
}
-
/* --- Mutextes before g_thread_init() --- */
static void
test_before_thread_init()
@@ -1134,28 +1071,21 @@ test_before_thread_init()
delete rmutex;
delete cond;
}
-
} // Anon
-
static guint constructur_attribute_test = 0;
-
static void BIRNET_CONSTRUCTOR
constructur_attribute_test_initializer (void)
{
constructur_attribute_test = 0x1237ABBA;
}
-
int
main (int argc,
char *argv[])
{
if (constructur_attribute_test != 305638330)
g_error ("%s: static constructors have not been called before main", G_STRFUNC);
-
test_before_thread_init();
-
birnet_init_test (&argc, &argv);
-
test_threads();
test_atomic();
test_thread_cxx();
@@ -1166,8 +1096,6 @@ main (int argc,
test_debug_channel();
if (init_settings().test_perf)
bench_auto_locker_cxx();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/tests/utils.cc b/birnet/tests/utils.cc
index 15c816b..821e645 100644
--- a/birnet/tests/utils.cc
+++ b/birnet/tests/utils.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <birnet/birnettests.h>
-
using namespace Birnet;
-
struct Foo
{
static int destructor_calls;
@@ -18,12 +16,10 @@ struct Foo
destructor_calls++;
}
};
-
template<class T, int N>
void aligned_array_test()
{
const size_t cache_line_size = 64; // sync with Birnet::malloc_aligned
-
size_t len = g_random_int_range (1, 1000);
AlignedArray<T, N> array (len);
TCHECK (array.size() == len);
@@ -34,9 +30,7 @@ void aligned_array_test()
TCHECK (size_t (&array[0]) % cache_line_size == 0);
TOK();
};
-
int Foo::destructor_calls = 0;
-
static void
test_aligned_array (void)
{
@@ -76,12 +70,10 @@ test_aligned_array (void)
TOK();
TDONE();
}
-
int
main (int argc,
char *argv[])
{
birnet_init_test (&argc, &argv);
-
test_aligned_array();
}
diff --git a/bse/bse.hh b/bse/bse.hh
index 73f4aed..9ea06d2 100644
--- a/bse/bse.hh
+++ b/bse/bse.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_H__
#define __BSE_H__
-
#include <sfi/sfi.hh>
#include <bse/bseconfig.h>
-
G_BEGIN_DECLS
-
/* initialize BSE and start the core thread */
void bse_init_async (gint *argc,
gchar ***argv,
@@ -14,7 +11,6 @@ void bse_init_async (gint *argc,
SfiInitValue values[]);
/* provide SFI glue layer context for BSE */
SfiGlueContext* bse_init_glue_context (const gchar *client);
-
/* library versioning */
extern const guint bse_major_version;
extern const guint bse_minor_version;
@@ -25,7 +21,5 @@ extern const gchar *bse_version;
const char* bse_check_version (guint required_major,
guint required_minor,
guint required_micro);
-
G_END_DECLS
-
#endif /* __BSE_H__ */
diff --git a/bse/bse.idl b/bse/bse.idl
index a335f65..39bab74 100644
--- a/bse/bse.idl
+++ b/bse/bse.idl
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include-impl <bse/bsecore.idl>
#include-impl <bse/bsecxxbase.idl>
#include-impl <bse/bsecxxmodule.idl>
#include-impl <bse/bseprobe.idl>
-
// include non-C++ types
#include-impl <bse/bsehack.idl> // generated by bseprocidl
-
/* vim:set ts=8 sts=2 sw=2 syntax=cpp: */
diff --git a/bse/bseautodoc.cc b/bse/bseautodoc.cc
index 51876a2..cdd150d 100644
--- a/bse/bseautodoc.cc
+++ b/bse/bseautodoc.cc
@@ -10,8 +10,6 @@
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
-
-
static const gchar*
beauty_float (gdouble f)
{
@@ -33,21 +31,17 @@ beauty_float (gdouble f)
g_free (s);
return c;
}
-
static GQuark boxed_type_tag = 0;
-
static void
tag_all_boxed_pspecs (void)
{
GType *children;
guint i;
-
children = g_type_children (G_TYPE_BOXED, NULL);
for (i = 0; children[i]; i++)
{
SfiRecFields rfields = sfi_boxed_type_get_rec_fields (children[i]);
GParamSpec *element = sfi_boxed_type_get_seq_element (children[i]);
-
if (element)
{
g_param_spec_ref (element);
@@ -65,7 +59,6 @@ tag_all_boxed_pspecs (void)
}
g_free (children);
}
-
static const gchar*
lookup_boxed_tag (GParamSpec *pspec)
{
@@ -73,7 +66,6 @@ lookup_boxed_tag (GParamSpec *pspec)
return (const gchar*) g_param_spec_get_qdata (pspec, boxed_type_tag);
return NULL;
}
-
static gchar*
type_name (GParamSpec *pspec)
{
@@ -123,9 +115,7 @@ type_name (GParamSpec *pspec)
}
return NULL;
}
-
static GSList *all_strings = NULL;
-
static const gchar*
qescape (const gchar *name)
{
@@ -135,7 +125,6 @@ qescape (const gchar *name)
all_strings = g_slist_prepend (all_strings, s);
return s;
}
-
static gchar*
pspec_construct_description (GParamSpec *pspec,
const gchar *cname,
@@ -143,14 +132,11 @@ pspec_construct_description (GParamSpec *pspec,
{
const gchar *blurb = g_param_spec_get_blurb (pspec);
const gchar *nick = g_param_spec_get_nick (pspec);
-
if (blurb && (strcmp (blurb, cname) == 0 || strcmp (blurb, sname) == 0))
blurb = NULL;
if (nick && (strcmp (nick, cname) == 0 || strcmp (nick, sname) == 0))
nick = NULL;
-
GString *gstring = g_string_new ("");
-
if (blurb || nick)
{
if (gstring->str[0])
@@ -162,7 +148,6 @@ pspec_construct_description (GParamSpec *pspec,
}
while (gstring->len && gstring->str[gstring->len - 1] == '\n')
gstring->str[--gstring->len] = 0;
-
if (SFI_IS_PSPEC_INT (pspec))
{
SfiInt imin, imax;
@@ -177,13 +162,11 @@ pspec_construct_description (GParamSpec *pspec,
}
while (gstring->len && gstring->str[gstring->len - 1] == '\n')
gstring->str[--gstring->len] = 0;
-
if (gstring->len)
return g_string_free (gstring, FALSE);
g_string_free (gstring, TRUE);
return NULL;
}
-
static void
print_pspec (GParamSpec *pspec,
const gchar *indent,
@@ -208,15 +191,12 @@ print_pspec (GParamSpec *pspec,
g_free (tname);
g_free (blurb);
}
-
static void
show_procdoc (void)
{
BseCategorySeq *cseq;
guint i;
-
g_print ("functions = (\n");
-
cseq = bse_categories_match_typed ("*", BSE_TYPE_PROCEDURE);
for (i = 0; i < cseq->n_cats; i++)
{
@@ -226,7 +206,6 @@ show_procdoc (void)
gchar *cname = g_type_name_to_cname (cseq->cats[i]->type);
gchar *sname = g_type_name_to_sname (cseq->cats[i]->type);
guint j;
-
g_print ("{\n");
g_print (" 'name': '%s',\n", cname);
g_print (" 'aliases': [ ('%s', 'scheme'), ], # aliases\n", sname);
@@ -237,7 +216,6 @@ show_procdoc (void)
print_pspec (pspec, " ", "");
}
g_print (" ],\n");
-
if (pclass->n_out_pspecs == 1)
{
g_print (" 'return': \n");
@@ -246,10 +224,8 @@ show_procdoc (void)
}
else if (pclass->n_out_pspecs > 1)
g_print (" 'return': ('RETURNS', 'MultiReturn', '', '', ('%s', '', 0), ),\n", _("This procedure has multiple return values."));
-
if (blurb)
g_print (" 'description': (%s, '', 0),\n", qescape (blurb));
-
/* procedures/%s:0 is a lame substitute for the real file/line location */
if (bse_type_get_file (type))
{
@@ -266,7 +242,6 @@ show_procdoc (void)
}
else
g_print (" 'location': ('procedures/%s', 0),\n", cseq->cats[i]->type);
-
g_print ("},\n");
g_type_class_unref (pclass);
g_free (cname);
@@ -275,22 +250,18 @@ show_procdoc (void)
g_print ("); # end of functions\n");
bse_category_seq_free (cseq);
}
-
static void
show_structdoc (void)
{
GType *children;
guint i;
-
g_print ("structures = (\n");
-
children = g_type_children (G_TYPE_BOXED, NULL);
for (i = 0; children[i]; i++)
{
GType type = children[i];
SfiRecFields rfields = sfi_boxed_type_get_rec_fields (type);
GParamSpec *element = sfi_boxed_type_get_seq_element (type);
-
if (element || rfields.n_fields)
{
const gchar *name = g_type_name (type);
@@ -300,19 +271,16 @@ show_structdoc (void)
const gchar *cstring;
SfiRing *ring, *pspecs = NULL;
guint j;
-
g_print ("{\n");
g_print (" 'name': '%s',\n", name);
g_print (" 'hint': '%s',\n", dname);
g_print (" 'aliases': [ ('%s', 'scheme'), ], # aliases\n", sname);
g_print (" 'fields': [\n");
g_print ("\n");
-
for (j = 0; j < rfields.n_fields; j++)
pspecs = sfi_ring_append (pspecs, rfields.fields[j]);
if (element)
pspecs = sfi_ring_append (pspecs, element);
-
if (element)
{
GParamSpec *pspec = (GParamSpec*) pspecs->data;
@@ -326,7 +294,6 @@ show_structdoc (void)
print_pspec (pspec, " ", element ? "*" : "");
}
g_print (" ],\n");
-
GString *full_description = g_string_new ("");
cstring = bse_type_get_blurb (type);
if (cstring)
@@ -349,10 +316,8 @@ show_structdoc (void)
g_string_append (full_description, " ");
g_string_append (full_description, cstring);
}
-
if (full_description->str[0])
g_print (" 'description': (%s, '', 0),\n", qescape (full_description->str));
-
/* structures/%s:0 is a lame substitute for the real file/line location */
if (bse_type_get_file (type))
{
@@ -369,10 +334,8 @@ show_structdoc (void)
}
else
g_print (" 'location': ('structures/%s', 0),\n", g_type_name (type));
-
g_print ("},\n");
g_string_free (full_description, TRUE);
-
g_free (cname);
g_free (sname);
sfi_ring_free (pspecs);
@@ -381,7 +344,6 @@ show_structdoc (void)
g_print ("); # end of structures\n");
g_free (children);
}
-
static gboolean
strequals (const gchar *s1,
const gchar *s2)
@@ -390,7 +352,6 @@ strequals (const gchar *s1,
return s1 == s2;
return strcmp (s1, s2) == 0;
}
-
static void
showdoc_print_type (GObjectClass *oclass,
gboolean show_channels)
@@ -400,7 +361,6 @@ showdoc_print_type (GObjectClass *oclass,
const gchar *string;
g_print ("{\n");
g_print (" 'name': '%s',\n", g_type_name (type));
-
GString *full_description = g_string_new ("");
const gchar *cstring = bse_type_get_blurb (type);
if (cstring)
@@ -426,7 +386,6 @@ showdoc_print_type (GObjectClass *oclass,
if (full_description->str[0])
g_print (" 'description': (%s, '', 0),\n", qescape (full_description->str));
g_string_free (full_description, TRUE);
-
g_print (" 'properties': [\n");
btype = G_TYPE_OBJECT;
do
@@ -447,7 +406,6 @@ showdoc_print_type (GObjectClass *oclass,
}
while (btype != type);
g_print (" ],\n");
-
/* show signals */
guint n = 0, ns, *sigs = g_signal_list_ids (type, &n);
g_print (" 'signals': [\n");
@@ -466,7 +424,6 @@ showdoc_print_type (GObjectClass *oclass,
}
g_free (sigs);
g_print (" ],\n");
-
/* show input and output channels */
g_print (" 'channels': [\n");
if (show_channels &&
@@ -502,10 +459,8 @@ showdoc_print_type (GObjectClass *oclass,
g_object_unref (source);
}
g_print (" ],\n");
-
g_print ("},\n");
}
-
static void
showdoc_descendants (GType type)
{
@@ -517,7 +472,6 @@ showdoc_descendants (GType type)
g_free (children);
g_type_class_unref (oclass);
}
-
static gint
help (const gchar *name,
const gchar *arg)
@@ -529,10 +483,8 @@ help (const gchar *name,
fprintf (stderr, " -s include scripts\n");
fprintf (stderr, " -h show help\n");
fprintf (stderr, " --seealso <link> add a SEE ALSO section link\n");
-
return arg != NULL;
}
-
int
main (gint argc,
gchar *argv[])
@@ -548,11 +500,9 @@ main (gint argc,
{ "load-core-scripts", scriptbool },
{ NULL },
};
-
g_thread_init (NULL);
sfi_init (&argc, &argv, "BseAutoDoc", NULL);
boxed_type_tag = g_quark_from_static_string ("bse-auto-doc-boxed-type-tag");
-
guint i;
for (i = 1; i < argc; i++)
{
@@ -595,11 +545,8 @@ main (gint argc,
else
return help (argv[0], argv[i]);
}
-
bse_init_inprocess (&argc, &argv, "BseAutoDoc", config);
-
tag_all_boxed_pspecs ();
-
if (gen_procs)
show_procdoc ();
else if (gen_structs)
@@ -612,6 +559,5 @@ main (gint argc,
}
else
return help (argv[0], NULL);
-
return 0;
}
diff --git a/bse/bsebiquadfilter.cc b/bse/bsebiquadfilter.cc
index 4436d19..e71f027 100644
--- a/bse/bsebiquadfilter.cc
+++ b/bse/bsebiquadfilter.cc
@@ -1,14 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsebiquadfilter.hh"
-
#include <bse/bsecategories.hh>
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
-
static SFI_MSG_TYPE_DEFINE (debug_biquadfilter, "biquadfilter", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_biquadfilter, __VA_ARGS__)
#define FREQ_DELTA 0.1
-
/* --- parameters --- */
enum
{
@@ -23,8 +20,6 @@ enum
PROP_FM_OCTAVES,
PROP_GAIN_PERC
};
-
-
/* --- prototypes --- */
static void bse_biquad_filter_init (BseBiquadFilter *self);
static void bse_biquad_filter_class_init (BseBiquadFilterClass *klass);
@@ -40,44 +35,35 @@ static void bse_biquad_filter_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
static void bse_biquad_filter_update_modules (BseBiquadFilter *self);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static const GTypeInfo type_info_biquad_filter = {
sizeof (BseBiquadFilterClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_biquad_filter_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseBiquadFilter),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_biquad_filter_init,
};
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseBiquadFilter)
{
static const GTypeInfo type_info = {
sizeof (BseBiquadFilterClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_biquad_filter_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseBiquadFilter),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_biquad_filter_init,
};
#include "./icons/biquad.c"
GType type;
-
type = bse_type_register_static (BSE_TYPE_SOURCE,
"BseBiquadFilter",
"BseBiquadFilter - an infinite impulse "
@@ -91,7 +77,6 @@ BSE_BUILTIN_TYPE (BseBiquadFilter)
bse_categories_register_stock_module (N_("/Filters/Biquad Types"), type, biquad_pixstream);
return type;
}
-
static void
bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
{
@@ -99,14 +84,10 @@ bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_biquad_filter_set_property;
gobject_class->get_property = bse_biquad_filter_get_property;
-
source_class->context_create = bse_biquad_filter_context_create;
-
bse_object_class_add_param (object_class, _("Filter"),
PROP_FILTER_TYPE,
bse_param_spec_genum ("filter_type", _("Filter Type"), _("The filter design type"),
@@ -169,7 +150,6 @@ bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
_("Strength of gain modulation"),
0.0, 0.0, 100.0, 5.0,
SFI_PARAM_STANDARD ":scale"));
-
channel_id = bse_source_class_add_ichannel (source_class, "audio-in", _("Audio In"), _("Unfiltered Audio Signal"));
g_assert (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_AUDIO);
channel_id = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Center Frequency Input"));
@@ -181,7 +161,6 @@ bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
channel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Filtered Audio Signal"));
g_assert (channel_id == BSE_BIQUAD_FILTER_OCHANNEL_AUDIO);
}
-
static void
bse_biquad_filter_init (BseBiquadFilter *self)
{
@@ -195,7 +174,6 @@ bse_biquad_filter_init (BseBiquadFilter *self)
self->gain = 3;
self->gain_strength = 0.25;
}
-
static void
bse_biquad_filter_set_property (GObject *object,
guint param_id,
@@ -203,7 +181,6 @@ bse_biquad_filter_set_property (GObject *object,
GParamSpec *pspec)
{
BseBiquadFilter *self = BSE_BIQUAD_FILTER (object);
-
switch (param_id)
{
case PROP_FILTER_TYPE:
@@ -251,7 +228,6 @@ bse_biquad_filter_set_property (GObject *object,
break;
}
}
-
static void
bse_biquad_filter_get_property (GObject *object,
guint param_id,
@@ -259,7 +235,6 @@ bse_biquad_filter_get_property (GObject *object,
GParamSpec *pspec)
{
BseBiquadFilter *self = BSE_BIQUAD_FILTER (object);
-
switch (param_id)
{
case PROP_FILTER_TYPE:
@@ -294,7 +269,6 @@ bse_biquad_filter_get_property (GObject *object,
break;
}
}
-
typedef struct {
GslBiquadFilter biquad;
BseFrequencyModulator fm;
@@ -304,14 +278,12 @@ typedef struct {
gfloat gain_strength;
guint clear_state : 1;
} FilterModule;
-
static void
biquad_filter_access (BseModule *module,
gpointer data)
{
FilterModule *fmod = (FilterModule*) module->user_data;
const FilterModule *cfg = (const FilterModule*) data;
-
fmod->fm = cfg->fm;
fmod->config = cfg->config;
fmod->base_freq = cfg->base_freq;
@@ -319,7 +291,6 @@ biquad_filter_access (BseModule *module,
fmod->gain_strength = cfg->gain_strength;
gsl_biquad_filter_config (&fmod->biquad, &fmod->config, cfg->clear_state);
}
-
static void
bse_biquad_filter_update_modules (BseBiquadFilter *self)
{
@@ -327,7 +298,6 @@ bse_biquad_filter_update_modules (BseBiquadFilter *self)
{
FilterModule *cfg = g_new0 (FilterModule, 1);
gfloat nyquist_freq = 0.5 * bse_engine_sample_freq ();
-
cfg->base_freq = MIN (self->freq, nyquist_freq);
cfg->gain = self->gain;
cfg->gain_strength = self->gain_strength;
@@ -342,19 +312,15 @@ bse_biquad_filter_update_modules (BseBiquadFilter *self)
bse_source_access_modules (BSE_SOURCE (self),
biquad_filter_access, cfg, g_free,
NULL);
-
-
if (1)
{
GslBiquadFilter biquad, approx;
GslBiquadConfig c;
-
gsl_biquad_config_init (&c, GslBiquadType (self->filter_type), GslBiquadNormalize (self->norm_type));
gsl_biquad_config_setup (&c, self->freq / nyquist_freq, self->gain, 0);
gsl_biquad_filter_config (&biquad, &c, TRUE);
DEBUG ("Bxx(z) = (%.14g + (%.14g + %.14g * z) * z) / (1 + (%.14g + %.14g * z) * z)\n",
biquad.xc0, biquad.xc1, biquad.xc2, biquad.yc1, biquad.yc2);
-
gsl_biquad_config_approx_gain (&c, self->gain);
gsl_biquad_filter_config (&approx, &c, TRUE);
DEBUG ("Byy(z) = (%.14g + (%.14g + %.14g * z) * z) / (1 + (%.14g + %.14g * z) * z)\n",
@@ -368,17 +334,14 @@ bse_biquad_filter_update_modules (BseBiquadFilter *self)
}
}
}
-
static void
biquad_filter_reset (BseModule *module)
{
FilterModule *fmod = (FilterModule*) module->user_data;
gfloat nyquist_freq = 0.5 * bse_engine_sample_freq ();
-
gsl_biquad_config_setup (&fmod->config, fmod->base_freq / nyquist_freq, fmod->gain, 0);
gsl_biquad_filter_config (&fmod->biquad, &fmod->config, TRUE);
}
-
static void
biquad_filter_process (BseModule *module,
guint n_values)
@@ -388,7 +351,6 @@ biquad_filter_process (BseModule *module,
gfloat *sig_out = BSE_MODULE_OBUFFER (module, BSE_BIQUAD_FILTER_OCHANNEL_AUDIO);
gfloat *bound = sig_out + n_values;
gboolean sig_out_as_freq = TRUE;
-
if (BSE_MODULE_ISTREAM (module, BSE_BIQUAD_FILTER_ICHANNEL_FREQ).connected &&
BSE_MODULE_ISTREAM (module, BSE_BIQUAD_FILTER_ICHANNEL_FREQ_MOD).connected)
bse_frequency_modulator (&fmod->fm,
@@ -410,7 +372,6 @@ biquad_filter_process (BseModule *module,
sig_out);
else
sig_out_as_freq = FALSE;
-
if (BSE_MODULE_ISTREAM (module, BSE_BIQUAD_FILTER_ICHANNEL_GAIN_MOD).connected && sig_out_as_freq)
{
const gfloat *gain_in = BSE_MODULE_IBUFFER (module, BSE_BIQUAD_FILTER_ICHANNEL_GAIN_MOD);
@@ -421,7 +382,6 @@ biquad_filter_process (BseModule *module,
do
{
guint n = MIN (bound - sig_out, bse_engine_control_raster ());
-
if (UNLIKELY (BSE_SIGNAL_FREQ_CHANGED (*sig_out, last_freq)))
{
last_freq = *sig_out;
@@ -455,7 +415,6 @@ biquad_filter_process (BseModule *module,
do
{
guint n = MIN (bound - sig_out, bse_engine_control_raster ());
-
if (UNLIKELY (BSE_SIGNAL_FREQ_CHANGED (*sig_out, last_freq)))
{
last_freq = *sig_out;
@@ -476,7 +435,6 @@ biquad_filter_process (BseModule *module,
do
{
guint n = MIN (bound - sig_out, bse_engine_control_raster ());
-
if (UNLIKELY (BSE_SIGNAL_GAIN_CHANGED (*gain_in, last_gain)))
{
last_gain = *gain_in;
@@ -493,7 +451,6 @@ biquad_filter_process (BseModule *module,
else
gsl_biquad_filter_eval (&fmod->biquad, n_values, audio_in, sig_out);
}
-
static void
bse_biquad_filter_context_create (BseSource *source,
guint context_handle,
@@ -513,7 +470,6 @@ bse_biquad_filter_context_create (BseSource *source,
FilterModule *fmod = g_new0 (FilterModule, 1);
gfloat nyquist_freq = 0.5 * bse_engine_sample_freq ();
BseModule *module;
-
fmod->base_freq = MIN (self->freq, nyquist_freq);
fmod->gain = self->gain;
fmod->gain_strength = self->gain_strength;
@@ -524,15 +480,11 @@ bse_biquad_filter_context_create (BseSource *source,
fmod->fm.fine_tune = 0;
gsl_biquad_config_init (&fmod->config, GslBiquadType (self->filter_type), GslBiquadNormalize (self->norm_type));
gsl_biquad_config_setup (&fmod->config, fmod->base_freq / nyquist_freq, fmod->gain, 0);
-
module = bse_module_new (&biquad_filter_class, fmod);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/bse/bsebiquadfilter.hh b/bse/bsebiquadfilter.hh
index fdac329..d5dd135 100644
--- a/bse/bsebiquadfilter.hh
+++ b/bse/bsebiquadfilter.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_BIQUAD_FILTER_H__
#define __BSE_BIQUAD_FILTER_H__
-
#include <bse/bsesource.hh>
#include <bse/gslfilter.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BSE_TYPE_BIQUAD_FILTER (BSE_TYPE_ID (BseBiquadFilter))
#define BSE_BIQUAD_FILTER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_BIQUAD_FILTER, BseBiquadFilter))
@@ -17,8 +13,6 @@ extern "C" {
#define BSE_IS_BIQUAD_FILTER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_BIQUAD_FILTER))
#define BSE_IS_BIQUAD_FILTER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_BIQUAD_FILTER))
#define BSE_BIQUAD_FILTER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_BIQUAD_FILTER, BseBiquadFilterClass))
-
-
/* --- enums --- */
typedef enum
{
@@ -31,15 +25,12 @@ typedef enum /* skip */
BSE_BIQUAD_FILTER_NORM_RESONANCE_GAIN = GSL_BIQUAD_NORMALIZE_RESONANCE_GAIN,
BSE_BIQUAD_FILTER_NORM_PEAK_GAIN = GSL_BIQUAD_NORMALIZE_PEAK_GAIN
} BseBiquadFilterNorm;
-
-
/* --- BseBiquadFilter source --- */
typedef struct _BseBiquadFilter BseBiquadFilter;
typedef struct _BseBiquadFilterClass BseBiquadFilterClass;
struct _BseBiquadFilter
{
BseSource parent_object;
-
BseBiquadFilterType filter_type;
guint type_change : 1;
guint exponential_fm : 1;
@@ -54,8 +45,6 @@ struct _BseBiquadFilterClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -70,10 +59,7 @@ enum
BSE_BIQUAD_FILTER_OCHANNEL_AUDIO,
BSE_BIQUAD_FILTER_N_OCHANNELS
};
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_BIQUAD_FILTER_H__ */
diff --git a/bse/bseblockutils.cc b/bse/bseblockutils.cc
index 3a0d872..3a3e12f 100644
--- a/bse/bseblockutils.cc
+++ b/bse/bseblockutils.cc
@@ -2,7 +2,6 @@
#include "bseblockutils.hh"
#include "bseresampler.hh"
#include "bseresamplerimpl.hh"
-
namespace {
class BlockImpl : virtual public Bse::Block::Impl {
virtual const char*
@@ -75,7 +74,6 @@ class BlockImpl : virtual public Bse::Block::Impl {
if (n_values)
{
minv = maxv = ivalues[0];
-
for (guint i = 1; i < n_values; i++)
{
if (UNLIKELY (ivalues[i] < minv))
@@ -96,10 +94,8 @@ class BlockImpl : virtual public Bse::Block::Impl {
const float *ivalues)
{
float square_sum = 0.0;
-
for (guint i = 0; i < n_values; i++)
square_sum += ivalues[i] * ivalues[i];
-
return square_sum;
}
virtual float
@@ -114,11 +110,9 @@ class BlockImpl : virtual public Bse::Block::Impl {
{
minv = maxv = ivalues[0];
square_sum = ivalues[0] * ivalues[0];
-
for (guint i = 1; i < n_values; i++)
{
square_sum += ivalues[i] * ivalues[i];
-
if (UNLIKELY (ivalues[i] < minv))
minv = ivalues[i];
if (UNLIKELY (ivalues[i] > maxv))
@@ -159,26 +153,20 @@ class BlockImpl : virtual public Bse::Block::Impl {
};
static BlockImpl default_block_impl;
} // Anon
-
namespace Bse {
-
Block::Impl*
Block::default_singleton ()
{
return &default_block_impl;
}
-
Block::Impl *Block::singleton = &default_block_impl;
-
Block::Impl*
Block::current_singleton ()
{
return Block::singleton;
}
-
Block::Impl::~Impl()
{}
-
void
Block::Impl::substitute (Impl *substitute_impl)
{
@@ -186,15 +174,12 @@ Block::Impl::substitute (Impl *substitute_impl)
substitute_impl = &default_block_impl;
Block::singleton = substitute_impl;
}
-
} // Bse
-
extern "C" const char*
bse_block_impl_name (void)
{
return Bse::Block::impl_name();
}
-
extern "C" void
bse_block_add_floats (guint n_values,
float *ovalues,
@@ -202,7 +187,6 @@ bse_block_add_floats (guint n_values,
{
Bse::Block::add (n_values, ovalues, ivalues);
}
-
extern "C" void
bse_block_sub_floats (guint n_values,
float *ovalues,
@@ -210,7 +194,6 @@ bse_block_sub_floats (guint n_values,
{
Bse::Block::sub (n_values, ovalues, ivalues);
}
-
extern "C" void
bse_block_mul_floats (guint n_values,
float *ovalues,
@@ -218,7 +201,6 @@ bse_block_mul_floats (guint n_values,
{
Bse::Block::mul (n_values, ovalues, ivalues);
}
-
void
bse_block_scale_floats (guint n_values,
float *ovalues,
@@ -227,7 +209,6 @@ bse_block_scale_floats (guint n_values,
{
Bse::Block::scale (n_values, ovalues, ivalues, level);
}
-
extern "C" void
bse_block_interleave2_floats (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
@@ -236,7 +217,6 @@ bse_block_interleave2_floats (guint n_ivalues,
{
Bse::Block::interleave2 (n_ivalues, ovalues, ivalues, offset);
}
-
extern "C" void
bse_block_interleave2_add_floats (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
@@ -245,7 +225,6 @@ bse_block_interleave2_add_floats (guint n_ivalues,
{
Bse::Block::interleave2_add (n_ivalues, ovalues, ivalues, offset);
}
-
extern "C" void
bse_block_calc_float_range (guint n_values,
const float *ivalues,
@@ -254,14 +233,12 @@ bse_block_calc_float_range (guint n_values,
{
Bse::Block::range (n_values, ivalues, *min_value, *max_value);
}
-
extern "C" float
bse_block_calc_float_square_sum (guint n_values,
const float *ivalues)
{
return Bse::Block::square_sum (n_values, ivalues);
}
-
extern "C" float
bse_block_calc_float_range_and_square_sum (guint n_values,
const float *ivalues,
diff --git a/bse/bseblockutils.hh b/bse/bseblockutils.hh
index 4ee67bc..dedf8c7 100644
--- a/bse/bseblockutils.hh
+++ b/bse/bseblockutils.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_BLOCK_UTILS_H__
#define __BSE_BLOCK_UTILS_H__
-
#include <wchar.h> /* wmemset */
#include <bse/bseieee754.hh>
-
G_BEGIN_DECLS
-
/* --- C API --- */
const
char* bse_block_impl_name (void);
@@ -57,13 +54,10 @@ float bse_block_calc_float_range_and_square_sum (guint n_values,
const float *ivalues,
float *min_value,
float *max_value);
-
G_END_DECLS
-
#ifdef __cplusplus
#include <bse/bseresampler.hh>
namespace Bse {
-
/* --- C++ API --- */
class Block {
public:
@@ -111,16 +105,12 @@ public:
const float *ivalues,
float& min_value,
float& max_value) { return singleton->range_and_square_sum (n_values, ivalues, min_value, max_value); }
-
typedef Resampler::Resampler2 Resampler2;
static inline
Resampler2* create_resampler2 (BseResampler2Mode mode,
BseResampler2Precision precision) { return singleton->create_resampler2 (mode, precision); }
static inline
bool test_resampler2 (bool verbose) { return singleton->test_resampler2 (verbose); }
-
-
-
class Impl {
protected:
virtual ~Impl ();
@@ -168,7 +158,6 @@ public:
private:
static Impl *singleton;
};
-
/* --- C++ implementation bits --- */
inline void
Block::fill (guint n_values,
@@ -180,7 +169,6 @@ Block::fill (guint n_values,
const union { float f; guint32 vuint32; } u = { value };
wmemset ((wchar_t*) values, u.vuint32, n_values);
}
-
inline void
Block::fill (guint n_values,
guint32 *values,
@@ -189,7 +177,6 @@ Block::fill (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, value, n_values);
}
-
inline void
Block::copy (guint n_values,
guint32 *values,
@@ -198,7 +185,6 @@ Block::copy (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
-
inline void
Block::copy (guint n_values,
gfloat *values,
@@ -208,13 +194,10 @@ Block::copy (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
-
} // Bse
#endif /* __cplusplus */
-
/* --- C implementation bits --- */
G_BEGIN_DECLS
-
static inline void
bse_block_fill_uint32 (guint n_values,
guint32 *values,
@@ -223,7 +206,6 @@ bse_block_fill_uint32 (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, vuint32, n_values);
}
-
static inline void
bse_block_fill_float (guint n_values,
float *values,
@@ -234,7 +216,6 @@ bse_block_fill_float (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, u.vuint32, n_values);
}
-
static inline void
bse_block_copy_uint32 (guint n_values,
guint32 *values,
@@ -243,7 +224,6 @@ bse_block_copy_uint32 (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
-
static inline void
bse_block_copy_float (guint n_values,
gfloat *values,
@@ -253,7 +233,5 @@ bse_block_copy_float (guint n_values,
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
-
G_END_DECLS
-
#endif /* __BSE_BLOCK_UTILS_H__ */
diff --git a/bse/bsebus.cc b/bse/bsebus.cc
index ac4a611..f95e9e5 100644
--- a/bse/bsebus.cc
+++ b/bse/bsebus.cc
@@ -10,12 +10,8 @@
#include "bseproject.hh"
#include "bsestorage.hh"
#include "bsecxxplugin.hh"
-
-
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
/* --- parameters --- */
enum
{
@@ -30,15 +26,10 @@ enum
PROP_RIGHT_VOLUME,
PROP_MASTER_OUTPUT,
};
-
-
/* --- prototypes --- */
static gboolean bse_bus_ensure_summation (BseBus *self);
-
/* --- variables --- */
static gpointer bus_parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_bus_init (BseBus *self)
@@ -50,7 +41,6 @@ bse_bus_init (BseBus *self)
self->saved_sync = self->synced;
bse_sub_synth_set_null_shortcut (BSE_SUB_SYNTH (self), TRUE);
}
-
static void
bse_bus_dispose (GObject *object)
{
@@ -59,10 +49,8 @@ bse_bus_dispose (GObject *object)
bse_bus_disconnect (self, BSE_ITEM (self->inputs->data));
/* chain parent class' handler */
G_OBJECT_CLASS (bus_parent_class)->dispose (object);
-
g_assert (self->bus_outputs == NULL);
}
-
static void
bse_bus_finalize (GObject *object)
{
@@ -73,7 +61,6 @@ bse_bus_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (bus_parent_class)->finalize (object);
}
-
static BseBus*
get_master (BseBus *self)
{
@@ -85,7 +72,6 @@ get_master (BseBus *self)
}
return NULL;
}
-
static void
bus_list_input_candidates (BseBus *self,
BseItemSeq *iseq)
@@ -97,7 +83,6 @@ bus_list_input_candidates (BseBus *self,
if (master)
bse_item_seq_remove (iseq, BSE_ITEM (master));
}
-
void
bse_bus_or_track_list_output_candidates (BseItem *trackbus,
BseItemSeq *iseq)
@@ -105,7 +90,6 @@ bse_bus_or_track_list_output_candidates (BseItem *trackbus,
if (BSE_IS_BUS (trackbus) || BSE_IS_TRACK (trackbus))
bse_item_gather_items_typed (trackbus, iseq, BSE_TYPE_BUS, BSE_TYPE_SONG, FALSE);
}
-
static void
bse_bus_get_candidates (BseItem *item,
guint param_id,
@@ -142,7 +126,6 @@ bse_bus_get_candidates (BseItem *item,
break;
}
}
-
static gboolean
bse_bus_editable_property (BseObject *object,
guint param_id,
@@ -165,7 +148,6 @@ bse_bus_editable_property (BseObject *object,
}
return TRUE;
}
-
static void
bus_disconnect_outputs (BseBus *self)
{
@@ -179,7 +161,6 @@ bus_disconnect_outputs (BseBus *self)
g_object_notify (G_OBJECT (self), "master-output"); /* master may have changed */
g_object_notify (G_OBJECT (self), "solo"); /* master may have changed */
}
-
static void
song_connect_master (BseSong *song,
BseBus *bus)
@@ -194,7 +175,6 @@ song_connect_master (BseSong *song,
g_object_notify (G_OBJECT (bus), "solo");
}
}
-
static gdouble
center_volume (gdouble volume1,
gdouble volume2)
@@ -209,7 +189,6 @@ center_volume (gdouble volume1,
else
return (volume1 + volume2) * 0.5;
}
-
static void
bus_volume_changed (BseBus *self)
{
@@ -233,7 +212,6 @@ bus_volume_changed (BseBus *self)
g_object_set (self->bmodule, "volume1", v1, "volume2", v2, NULL);
}
}
-
void
bse_bus_or_track_set_outputs (BseItem *trackbus,
BseItemSeq *outputs_iseq)
@@ -274,7 +252,6 @@ bse_bus_or_track_set_outputs (BseItem *trackbus,
*pbus_outputs = sfi_ring_reorder (*pbus_outputs, saved_outputs);
sfi_ring_free (saved_outputs);
}
-
static void
bse_bus_set_property (GObject *object,
guint param_id,
@@ -398,7 +375,6 @@ bse_bus_set_property (GObject *object,
break;
}
}
-
static void
bse_bus_get_property (GObject *object,
guint param_id,
@@ -468,7 +444,6 @@ bse_bus_get_property (GObject *object,
break;
}
}
-
void
bse_bus_change_solo (BseBus *self,
gboolean solo_muted)
@@ -478,26 +453,20 @@ bse_bus_change_solo (BseBus *self,
g_object_notify (G_OBJECT (self), "solo");
g_object_notify (G_OBJECT (self), "mute");
}
-
static void
bse_bus_set_parent (BseItem *item,
BseItem *parent)
{
BseBus *self = BSE_BUS (item);
self->solo_muted = FALSE;
-
if (item->parent)
bse_object_unproxy_notifies (item->parent, self, "notify::outputs");
-
/* chain parent class' handler */
BSE_ITEM_CLASS (bus_parent_class)->set_parent (item, parent);
-
if (item->parent)
bse_object_proxy_notifies (item->parent, self, "notify::outputs");
-
while (self->inputs)
bse_bus_disconnect (self, BSE_ITEM (self->inputs->data));
-
if (self->summation)
{
BseItem *sitem = BSE_ITEM (self->summation);
@@ -513,7 +482,6 @@ bse_bus_set_parent (BseItem *item,
g_warning ("Bus[%p] has snet[%p] in set-parent", self, BSE_SUB_SYNTH (self)->snet);
}
}
-
static void
bse_bus_prepare (BseSource *source)
{
@@ -521,7 +489,6 @@ bse_bus_prepare (BseSource *source)
/* chain parent class' handler */
BSE_SOURCE_CLASS (bus_parent_class)->prepare (source);
}
-
static void
bse_bus_context_create (BseSource *source,
guint context_handle,
@@ -531,7 +498,6 @@ bse_bus_context_create (BseSource *source,
/* chain parent class' handler */
BSE_SOURCE_CLASS (bus_parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_bus_context_connect (BseSource *source,
guint context_handle,
@@ -541,7 +507,6 @@ bse_bus_context_connect (BseSource *source,
/* chain parent class' handler */
BSE_SOURCE_CLASS (bus_parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_bus_reset (BseSource *source)
{
@@ -549,7 +514,6 @@ bse_bus_reset (BseSource *source)
/* chain parent class' handler */
BSE_SOURCE_CLASS (bus_parent_class)->reset (source);
}
-
gboolean
bse_bus_get_stack (BseBus *self,
BseContainer **snetp,
@@ -592,7 +556,6 @@ bse_bus_get_stack (BseBus *self,
}
return FALSE;
}
-
static gboolean
bse_bus_ensure_summation (BseBus *self)
{
@@ -611,7 +574,6 @@ bse_bus_ensure_summation (BseBus *self)
}
return self->summation != NULL;
}
-
static void
trackbus_update_outputs (BseItem *trackbus,
BseBus *added,
@@ -627,7 +589,6 @@ trackbus_update_outputs (BseItem *trackbus,
else
BSE_BUS (trackbus)->bus_outputs = outputs;
}
-
static void
bus_uncross_input (BseItem *owner,
BseItem *item)
@@ -638,7 +599,6 @@ bus_uncross_input (BseItem *owner,
else /* IS_BUS */
bse_item_exec_void (owner, "disconnect-bus", item);
}
-
BseErrorType
bse_bus_connect (BseBus *self,
BseItem *trackbus)
@@ -662,7 +622,6 @@ bse_bus_connect (BseBus *self,
else
return BSE_ERROR_SOURCE_CONNECTION_INVALID;
}
-
BseErrorType
bse_bus_connect_unchecked (BseBus *self,
BseItem *trackbus)
@@ -691,7 +650,6 @@ bse_bus_connect_unchecked (BseBus *self,
}
return error;
}
-
BseErrorType
bse_bus_disconnect (BseBus *self,
BseItem *trackbus)
@@ -716,19 +674,16 @@ bse_bus_disconnect (BseBus *self,
g_object_notify (G_OBJECT (trackbus), "outputs");
return error1 ? error1 : error2;
}
-
SfiRing*
bse_bus_list_inputs (BseBus *self)
{
return sfi_ring_copy (self->inputs);
}
-
SfiRing*
bse_bus_list_outputs (BseBus *self)
{
return sfi_ring_copy (self->bus_outputs);
}
-
static void
bus_restore_add_input (gpointer data,
BseStorage *storage,
@@ -738,7 +693,6 @@ bus_restore_add_input (gpointer data,
{
BseBus *self = BSE_BUS (from_item);
BseSource *osource = to_item ? BSE_SOURCE (to_item) : NULL;
-
if (error)
bse_storage_warn (storage, "failed to add input to mixer bus \"%s\": %s", BSE_OBJECT_UNAME (self), error);
else
@@ -756,7 +710,6 @@ bus_restore_add_input (gpointer data,
bse_error_blurb (cerror));
}
}
-
static void
bus_restore_start (BseObject *object,
BseStorage *storage)
@@ -767,14 +720,12 @@ bus_restore_start (BseObject *object,
self->synced = FALSE;
BSE_OBJECT_CLASS (bus_parent_class)->restore_start (object, storage);
}
-
static GTokenType
bus_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner)
{
BseBus *self = BSE_BUS (object);
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER &&
bse_string_equals ("bus-input", scanner->next_value.v_identifier))
{
@@ -790,7 +741,6 @@ bus_restore_private (BseObject *object,
else /* chain parent class' handler */
return BSE_OBJECT_CLASS (bus_parent_class)->restore_private (object, storage, scanner);
}
-
static void
bus_restore_finish (BseObject *object,
guint vmajor,
@@ -804,17 +754,14 @@ bus_restore_finish (BseObject *object,
NULL);
BSE_OBJECT_CLASS (bus_parent_class)->restore_finish (object, vmajor, vminor, vmicro);
}
-
static void
bus_store_private (BseObject *object,
BseStorage *storage)
{
BseBus *self = BSE_BUS (object);
-
/* chain parent class' handler */
if (BSE_OBJECT_CLASS (bus_parent_class)->store_private)
BSE_OBJECT_CLASS (bus_parent_class)->store_private (object, storage);
-
SfiRing *inputs = bse_bus_list_inputs (self);
while (inputs)
{
@@ -825,7 +772,6 @@ bus_store_private (BseObject *object,
bse_storage_printf (storage, ")");
}
}
-
static void
bse_bus_class_init (BseBusClass *klass)
{
@@ -834,28 +780,22 @@ bse_bus_class_init (BseBusClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
bus_parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_bus_set_property;
gobject_class->get_property = bse_bus_get_property;
gobject_class->dispose = bse_bus_dispose;
gobject_class->finalize = bse_bus_finalize;
-
object_class->editable_property = bse_bus_editable_property;
object_class->store_private = bus_store_private;
object_class->restore_start = bus_restore_start;
object_class->restore_private = bus_restore_private;
object_class->restore_finish = bus_restore_finish;
-
item_class->set_parent = bse_bus_set_parent;
item_class->get_candidates = bse_bus_get_candidates;
-
source_class->prepare = bse_bus_prepare;
source_class->context_create = bse_bus_context_create;
source_class->context_connect = bse_bus_context_connect;
source_class->reset = bse_bus_reset;
-
bse_object_class_add_param (object_class, _("Adjustments"), PROP_MUTE,
sfi_pspec_bool ("mute", _("Mute"), _("Mute: turn off the bus volume"), FALSE, SFI_PARAM_STANDARD ":skip-default"));
bse_object_class_add_param (object_class, _("Adjustments"), PROP_SOLO,
@@ -889,7 +829,6 @@ bse_bus_class_init (BseBusClass *klass)
PROP_MASTER_OUTPUT,
sfi_pspec_bool ("master-output", _("Master Output"), NULL,
FALSE, SFI_PARAM_STORAGE ":skip-default"));
-
channel_id = bse_source_class_add_ichannel (source_class, "left-audio-in", _("Left Audio In"), _("Left channel input"));
g_assert (channel_id == BSE_BUS_ICHANNEL_LEFT);
channel_id = bse_source_class_add_ichannel (source_class, "right-audio-in", _("Right Audio In"), _("Right channel input"));
@@ -899,7 +838,6 @@ bse_bus_class_init (BseBusClass *klass)
channel_id = bse_source_class_add_ochannel (source_class, "right-audio-out", _("Right Audio Out"), _("Right channel output"));
g_assert (channel_id == BSE_BUS_OCHANNEL_RIGHT);
}
-
BSE_BUILTIN_TYPE (BseBus)
{
static const GTypeInfo bus_info = {
diff --git a/bse/bsebus.hh b/bse/bsebus.hh
index 4993eb3..ec31893 100644
--- a/bse/bsebus.hh
+++ b/bse/bsebus.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_BUS_H__
#define __BSE_BUS_H__
-
#include <bse/bsesubsynth.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_BUS (BSE_TYPE_ID (BseBus))
#define BSE_BUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_BUS, BseBus))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_BUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_BUS))
#define BSE_IS_BUS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_BUS))
#define BSE_BUS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_BUS, BseBusClass))
-
-
/* --- BseBus source --- */
struct _BseBus
{
@@ -31,15 +26,12 @@ struct _BseBus
BseSource *bmodule; /* implicitely vout */
guint n_effects; /* # of slots */
BseSource **effects; /* slot maybe NULL */
-
SfiRing *bus_outputs; /* maintained by bsebus.[hc] */
};
struct _BseBusClass
{
BseSubSynthClass parent_class;
};
-
-
/* --- API --- */
BseErrorType bse_bus_connect (BseBus *self,
BseItem *item);
@@ -67,7 +59,6 @@ void bse_bus_or_track_list_output_candidates (BseItem *trackbus,
BseItemSeq *iseq);
void bse_bus_or_track_set_outputs (BseItem *trackbus,
BseItemSeq *iseq);
-
/* --- channels --- */
enum
{
@@ -81,8 +72,5 @@ enum
BSE_BUS_OCHANNEL_RIGHT,
BSE_BUS_N_OCHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_BUS_H__ */
diff --git a/bse/bsebus.proc b/bse/bsebus.proc
index b3f2607..5209930 100644
--- a/bse/bsebus.proc
+++ b/bse/bsebus.proc
@@ -5,12 +5,8 @@
#include <bse/bsetrack.hh>
#include <bse/bsesong.hh>
#include <bse/bseundostack.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "Copyright (C) 2004 Tim Janik";
-
-
METHOD (BseBus, connect-track) {
HELP = _("Add a track to the input list of a bus.");
IN = bse_param_spec_object ("sbus", NULL, NULL, BSE_TYPE_BUS, SFI_PARAM_STANDARD);
@@ -26,11 +22,9 @@ BODY (BseProcedureClass *proc,
BseBus *self = (BseBus*) bse_value_get_object (in_values++);
BseTrack *track = (BseTrack*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_BUS (self) || !BSE_IS_TRACK (track))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_ITEM (self)->parent || BSE_ITEM (self)->parent != BSE_ITEM (track)->parent)
error = BSE_ERROR_SOURCE_PARENT_MISMATCH;
@@ -40,13 +34,10 @@ BODY (BseProcedureClass *proc,
if (!error)
bse_item_push_undo_proc (self, "disconnect-track", track);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseBus, disconnect-track) {
HELP = _("Remove a track from the input list of a bus.");
IN = bse_param_spec_object ("sbus", NULL, NULL, BSE_TYPE_BUS, SFI_PARAM_STANDARD);
@@ -62,11 +53,9 @@ BODY (BseProcedureClass *proc,
BseBus *self = (BseBus*) bse_value_get_object (in_values++);
BseTrack *track = (BseTrack*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_BUS (self) || !BSE_IS_TRACK (track))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_ITEM (self)->parent || BSE_ITEM (self)->parent != BSE_ITEM (track)->parent)
error = BSE_ERROR_SOURCE_PARENT_MISMATCH;
@@ -76,13 +65,10 @@ BODY (BseProcedureClass *proc,
if (!error)
bse_item_push_undo_proc (self, "connect-track", track);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseBus, connect-bus) {
HELP = _("Add a bus to the input list of a bus.");
IN = bse_param_spec_object ("sbus", NULL, NULL, BSE_TYPE_BUS, SFI_PARAM_STANDARD);
@@ -98,11 +84,9 @@ BODY (BseProcedureClass *proc,
BseBus *self = (BseBus*) bse_value_get_object (in_values++);
BseBus *bus = (BseBus*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_BUS (self) || !BSE_IS_BUS (bus))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_ITEM (self)->parent || BSE_ITEM (self)->parent != BSE_ITEM (bus)->parent)
error = BSE_ERROR_SOURCE_PARENT_MISMATCH;
@@ -112,13 +96,10 @@ BODY (BseProcedureClass *proc,
if (!error)
bse_item_push_undo_proc (self, "disconnect-bus", bus);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseBus, disconnect-bus) {
HELP = _("Remove a bus from the input list of a bus.");
IN = bse_param_spec_object ("sbus", NULL, NULL, BSE_TYPE_BUS, SFI_PARAM_STANDARD);
@@ -134,11 +115,9 @@ BODY (BseProcedureClass *proc,
BseBus *self = (BseBus*) bse_value_get_object (in_values++);
BseBus *bus = (BseBus*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_BUS (self) || !BSE_IS_BUS (bus))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_ITEM (self)->parent || BSE_ITEM (self)->parent != BSE_ITEM (bus)->parent)
error = BSE_ERROR_SOURCE_PARENT_MISMATCH;
@@ -148,13 +127,10 @@ BODY (BseProcedureClass *proc,
if (!error)
bse_item_push_undo_proc (self, "connect-bus", bus);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseBus, ensure-output) {
HELP = _("Ensure that a bus has an output connection.");
IN = bse_param_spec_object ("bus", NULL, NULL, BSE_TYPE_BUS, SFI_PARAM_STANDARD);
@@ -168,11 +144,9 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseBus *self = (BseBus*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_BUS (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
BseItem *parent = BSE_ITEM (self)->parent;
if (BSE_IS_SONG (parent) && !self->bus_outputs)
@@ -186,9 +160,7 @@ BODY (BseProcedureClass *proc,
bse_item_push_undo_proc (master, "disconnect-bus", self);
}
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsebusmodule.cc b/bse/bsebusmodule.cc
index f02af7f..d6b8a0f 100644
--- a/bse/bsebusmodule.cc
+++ b/bse/bsebusmodule.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsebusmodule.genidl.hh"
-
namespace Bse {
-
class BusModule : public BusModuleBase {
/* bus-module module implementation */
class Module : public SynthesisModule {
@@ -58,8 +56,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (BusModule, Module, BusModuleProperties);
};
-
BSE_CXX_DEFINE_EXPORTS ();
BSE_CXX_REGISTER_EFFECT (BusModule);
-
} // Bse
diff --git a/bse/bsebusmodule.idl b/bse/bsebusmodule.idl
index 414a165..a5d4f30 100644
--- a/bse/bsebusmodule.idl
+++ b/bse/bsebusmodule.idl
@@ -1,11 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bsecore.idl>
-
namespace Bse { class Effect; }; // FIXME: bad workaround
-
namespace Bse {
-
class BusModule : Effect {
Info authors = "Tim Janik";
Info license = _("GNU Lesser General Public License");
@@ -21,5 +17,4 @@ class BusModule : Effect {
Real volume2 = (NULL, NULL, 1, 0, 1000, 10, STANDARD); /* volume factor */
};
};
-
};
diff --git a/bse/bsecategories.cc b/bse/bsecategories.cc
index 21f331a..471479a 100644
--- a/bse/bsecategories.cc
+++ b/bse/bsecategories.cc
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecategories.hh"
-
#include "bseutils.hh"
#include <string.h>
-
-
/* --- defines --- */
#define CATEGORIES_PRE_ALLOC (16)
-
-
/* --- structures --- */
typedef struct _CEntry CEntry;
struct _CEntry
@@ -20,36 +15,27 @@ struct _CEntry
GType type;
BseIcon *icon;
};
-
-
/* --- variables --- */
static CEntry *cat_entries = NULL;
static gboolean cats_need_sort = FALSE;
static guint global_category_id = 1;
static SfiUStore *category_ustore = NULL;
-
-
/* --- functions --- */
void
_bse_init_categories (void)
{
g_return_if_fail (category_ustore == NULL);
-
category_ustore = sfi_ustore_new ();
}
-
static inline CEntry*
centry_find (GQuark quark)
{
CEntry *centry;
-
for (centry = cat_entries; centry; centry = centry->next)
if (centry->category == quark)
return centry;
-
return NULL;
}
-
static inline guint
category_strip_toplevels (const gchar *category,
GType type)
@@ -65,11 +51,9 @@ category_strip_toplevels (const gchar *category,
{ 6, "/Proc/", },
};
guint l = strlen (category);
-
if (l > 10 && strncmp (category, "/Methods/", 8) == 0)
{
const gchar *p = category + 8;
-
if (!BSE_TYPE_IS_PROCEDURE (type))
return 0;
p = strchr (p, '/');
@@ -82,7 +66,6 @@ category_strip_toplevels (const gchar *category,
return 0;
return 9;
}
-
if (BSE_TYPE_IS_PROCEDURE (type))
{
guint i;
@@ -91,17 +74,14 @@ category_strip_toplevels (const gchar *category,
strncmp (category, scripts[i].prefix, scripts[i].length) == 0)
return scripts[i].length;
}
-
return 0;
}
-
static guint
leaf_index (const gchar *string)
{
gboolean in_quote = FALSE;
guint pos = 0;
const gchar *p;
-
for (p = string; *p; p++)
switch (*p)
{
@@ -111,7 +91,6 @@ leaf_index (const gchar *string)
}
return pos;
}
-
static inline CEntry*
centry_new (const gchar *caller,
const gchar *category,
@@ -121,7 +100,6 @@ centry_new (const gchar *caller,
CEntry *centry;
GQuark quark;
guint mindex;
-
mindex = category_strip_toplevels (category, type);
if (!mindex)
{
@@ -134,11 +112,9 @@ centry_new (const gchar *caller,
g_warning ("%s(): unable to add category duplicate `%s'", caller, category);
return NULL;
}
-
if (!g_trash_stack_peek (&free_entries))
{
CEntry *limit;
-
centry = g_new (CEntry, CATEGORIES_PRE_ALLOC);
limit = centry + CATEGORIES_PRE_ALLOC - 1;
while (centry < limit)
@@ -146,7 +122,6 @@ centry_new (const gchar *caller,
}
else
centry = (CEntry*) g_trash_stack_pop (&free_entries);
-
centry->next = cat_entries;
cat_entries = centry;
centry->category_id = global_category_id++;
@@ -154,12 +129,9 @@ centry_new (const gchar *caller,
centry->mindex = mindex - 1;
centry->lindex = leaf_index (category);
centry->category = g_quark_from_string (category);
-
cats_need_sort = TRUE;
-
return centry;
}
-
static void
check_type (GType type)
{
@@ -173,7 +145,6 @@ check_type (GType type)
g_free (x);
}
}
-
void
bse_categories_register (const gchar *category,
const gchar *i18n_category,
@@ -181,9 +152,7 @@ bse_categories_register (const gchar *category,
const guint8 *pixstream)
{
CEntry *centry;
-
g_return_if_fail (category != NULL);
-
centry = centry_new (BIRNET_PRETTY_FUNCTION, category, type);
check_type (type);
if (centry)
@@ -195,7 +164,6 @@ bse_categories_register (const gchar *category,
centry->icon = NULL;
}
}
-
void
bse_categories_register_stock_module (const gchar *untranslated_category_trunk,
GType type,
@@ -206,7 +174,6 @@ bse_categories_register_stock_module (const gchar *untranslated_category_tr
const gchar *i18n_category = sfi_category_concat ("/Modules", _(untranslated_category_trunk));
bse_categories_register (category, i18n_category, type, pixstream);
}
-
static gint
centries_strorder (gconstpointer a,
gconstpointer b)
@@ -215,19 +182,15 @@ centries_strorder (gconstpointer a,
const CEntry *e2 = (const CEntry*) b;
const char *c1 = g_quark_to_string (e1->category);
const char *c2 = g_quark_to_string (e2->category);
-
return strcmp (c2, c1);
}
-
static void
cats_sort (void)
{
GSList *slist, *clist = NULL;
CEntry *centry, *last;
-
if (!cats_need_sort)
return;
-
for (centry = cat_entries; centry; centry = centry->next)
clist = g_slist_prepend (clist, centry);
clist = g_slist_sort (clist, centries_strorder);
@@ -240,10 +203,8 @@ cats_sort (void)
}
cat_entries = centry;
g_slist_free (clist);
-
cats_need_sort = FALSE;
}
-
static inline BseCategorySeq*
categories_match (const gchar *pattern,
GType base_type,
@@ -253,16 +214,13 @@ categories_match (const gchar *pattern,
BseCategorySeq *cseq = bse_category_seq_new ();
GPatternSpec *pspec = g_pattern_spec_new (pattern);
CEntry *centry;
-
for (centry = cat_entries; centry; centry = centry->next)
{
const char *category = g_quark_to_string (centry->category);
-
if (g_pattern_match_string (pspec, category) &&
(!base_type || g_type_is_a (centry->type, base_type)))
{
BseCategory cat = { 0, };
-
cat.category = const_cast<char*> (category);
cat.category_id = centry->category_id;
cat.mindex = centry->mindex;
@@ -274,10 +232,8 @@ categories_match (const gchar *pattern,
}
}
g_pattern_spec_free (pspec);
-
return cseq;
}
-
BseCategorySeq*
bse_categories_match (const gchar *pattern,
GType base_type,
@@ -285,33 +241,25 @@ bse_categories_match (const gchar *pattern,
gpointer data)
{
g_return_val_if_fail (pattern != NULL, NULL);
-
cats_sort ();
-
return categories_match (pattern, 0, check, data);
}
-
BseCategorySeq*
bse_categories_match_typed (const gchar *pattern,
GType base_type)
{
g_return_val_if_fail (pattern != NULL, NULL);
-
cats_sort ();
-
return categories_match (pattern, base_type, NULL, NULL);
}
-
BseCategorySeq*
bse_categories_from_type (GType type)
{
BseCategorySeq *cseq = bse_category_seq_new ();
-
for (CEntry *centry = cat_entries; centry; centry = centry->next)
if (centry->type == type)
{
BseCategory cat = { 0, };
-
cat.category = const_cast<char*> (g_quark_to_string (centry->category));
cat.category_id = centry->category_id;
cat.mindex = centry->mindex;
@@ -322,14 +270,11 @@ bse_categories_from_type (GType type)
}
return cseq;
}
-
BseCategory*
bse_category_from_id (guint id)
{
CEntry *centry;
-
g_return_val_if_fail (id > 0, NULL);
-
centry = (CEntry*) sfi_ustore_lookup (category_ustore, id);
if (centry)
{
diff --git a/bse/bsecategories.hh b/bse/bsecategories.hh
index 07b0ee6..3d15ef4 100644
--- a/bse/bsecategories.hh
+++ b/bse/bsecategories.hh
@@ -1,17 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CATEGORIES_H__
#define __BSE_CATEGORIES_H__
-
#include <bse/bsetype.hh>
-
G_BEGIN_DECLS
-
-
/* --- typedefs --- */
typedef gboolean (BseCategoryCheck) (BseCategory *category,
gpointer data);
-
-
/* --- prototypes --- */
void bse_categories_register (const gchar *category,
const gchar *i18n_category,
@@ -28,11 +22,7 @@ BseCategory* bse_category_from_id (guint id);
void bse_categories_register_stock_module (const gchar *untranslated_category_trunk,
GType type,
const guint8 *pixstream);
-
-
/* --- implementation --- */
void _bse_init_categories (void);
-
G_END_DECLS
-
#endif /* __BSE_CATEGORIES_H__ */
diff --git a/bse/bsecategories.proc b/bse/bsecategories.proc
index f6429de..18d5b65 100644
--- a/bse/bsecategories.proc
+++ b/bse/bsecategories.proc
@@ -3,12 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bseplugin.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
PROCEDURE (bse-categories-match-typed, "Categories/Match Typed") {
HELP = "List BSE categories according to a pattern and type match.";
IN = sfi_pspec_string ("pattern", "Pattern", "Pattern to match category, supports '*' and '?' wildcards.",
@@ -26,22 +22,17 @@ BODY (BseProcedureClass *proc,
const char *type_name = sfi_value_get_string (in_values++);
GType type = type_name ? g_type_from_name (type_name) : 0;
BseCategorySeq *cseq = NULL;
-
/* check parameters */
if (!pattern)
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (type)
cseq = bse_categories_match_typed (pattern, type);
if (!cseq)
cseq = bse_category_seq_new ();
-
/* set output parameters */
bse_value_take_boxed (out_values++, cseq);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-categories-match, "Categories/Match") {
HELP = "List BSE categories according to a pattern match.";
IN = sfi_pspec_string ("pattern", "Pattern", "Pattern to match category, supports '*' and '?' wildcards.",
@@ -55,21 +46,16 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
const char *pattern = sfi_value_get_string (in_values++);
BseCategorySeq *cseq = NULL;
-
/* check parameters */
if (!pattern)
return BSE_ERROR_PROC_PARAM_INVAL;
-
cseq = bse_categories_match_typed (pattern, 0);
if (!cseq)
cseq = bse_category_seq_new ();
-
/* set output parameters */
bse_value_take_boxed (out_values++, cseq);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-category-from-id, "Categories/From ID") {
HELP = "Find a BSE category from it's unique ID.";
IN = sfi_pspec_int ("category_id", "Category ID", NULL,
@@ -83,15 +69,11 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
guint id = sfi_value_get_int (in_values++);
BseCategory *cat;
-
cat = bse_category_from_id (id);
-
/* set output parameters */
bse_value_take_boxed (out_values++, cat);
-
return BSE_ERROR_NONE;
}
-
static gboolean
categories_check_method (BseCategory *cat,
gpointer data)
@@ -109,7 +91,6 @@ categories_check_method (BseCategory *cat,
}
return match;
}
-
PROCEDURE (bse-categories-match-method, "Categories/Match Method") {
HELP = "List BSE categories according to a pattern, of type procedure and applying to a certain object type.";
IN = sfi_pspec_string ("pattern", "Pattern", "Pattern to match category, supports '*' and '?' wildcards.",
@@ -127,17 +108,13 @@ BODY (BseProcedureClass *proc,
const char *type_name = sfi_value_get_string (in_values++);
GType type = type_name ? g_type_from_name (type_name) : 0;
BseCategorySeq *cseq = NULL;
-
/* check parameters */
if (!pattern)
return BSE_ERROR_PROC_PARAM_INVAL;
-
cseq = bse_categories_match (pattern, BSE_TYPE_PROCEDURE, categories_check_method, &type);
if (!cseq)
cseq = bse_category_seq_new ();
-
/* set output parameters */
bse_value_take_boxed (out_values++, cseq);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsecompat.cc b/bse/bsecompat.cc
index 8e31d4f..f2bfeac 100644
--- a/bse/bsecompat.cc
+++ b/bse/bsecompat.cc
@@ -2,8 +2,6 @@
#include "bsecompat.hh"
#include "bsestorage.hh"
#include <string.h>
-
-
/* --- functions --- */
gchar*
bse_compat_rewrite_type_name (BseStorage *storage,
@@ -34,7 +32,6 @@ bse_compat_rewrite_type_name (BseStorage *storage,
return g_strdup (type_changes[i].new_type);
return NULL;
}
-
gchar*
bse_compat_rewrite_ichannel_ident (BseStorage *storage,
const gchar *type_name,
@@ -59,7 +56,6 @@ bse_compat_rewrite_ichannel_ident (BseStorage *storage,
return g_strdup (ichannel_changes[i].new_channel);
return NULL;
}
-
gchar*
bse_compat_rewrite_ochannel_ident (BseStorage *storage,
const gchar *type_name,
diff --git a/bse/bsecompat.hh b/bse/bsecompat.hh
index 72643e3..16c46d2 100644
--- a/bse/bsecompat.hh
+++ b/bse/bsecompat.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_COMPAT_H__
#define __BSE_COMPAT_H__
-
#include <bse/bseenums.hh>
-
G_BEGIN_DECLS
-
-
/* --- parameter changes --- */
#define bse_param_spec_genum(name,nick,blurb, genum_type, default_value, hints) \
bse_param_spec_enum (name,nick,blurb, default_value, genum_type, hints)
@@ -22,7 +18,6 @@ G_BEGIN_DECLS
sfi_pspec_note (name, nick, blurb, default_value, SFI_MIN_NOTE, SFI_MAX_NOTE, FALSE, hints)
#define bse_pspec_note_simple(name, nick, blurb, hints) \
bse_pspec_note (name, nick, blurb, SFI_KAMMER_NOTE, hints)
-
/* --- BSE format changes --- */
gchar* bse_compat_rewrite_type_name (BseStorage *storage,
const gchar *type_name);
@@ -32,8 +27,5 @@ gchar* bse_compat_rewrite_ichannel_ident (BseStorage *storage,
gchar* bse_compat_rewrite_ochannel_ident (BseStorage *storage,
const gchar *type_name,
const gchar *ochannel_ident);
-
-
G_END_DECLS
-
#endif /* __BSE_COMPAT_H__ */
diff --git a/bse/bseconstant.cc b/bse/bseconstant.cc
index 2569066..f641f09 100644
--- a/bse/bseconstant.cc
+++ b/bse/bseconstant.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseconstant.hh"
-
#include <bse/bsecategories.hh>
#include <bse/bseengine.hh>
-
#include <string.h>
-
#define BSE_DFL_CONSTANT_VOLUME_dB (BSE_DFL_MASTER_VOLUME_dB)
-
/* --- parameters --- */
enum
{
@@ -17,8 +13,6 @@ enum
PARAM_FREQ,
PARAM_NOTE
};
-
-
/* --- prototypes --- */
static void bse_constant_init (BseConstant *constant);
static void bse_constant_class_init (BseConstantClass *klass);
@@ -35,41 +29,32 @@ static void bse_constant_context_create (BseSource *source,
BseTrans *trans);
static void bse_constant_update_modules (BseConstant *constant,
BseTrans *trans);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseConstant)
{
static const GTypeInfo type_info = {
sizeof (BseConstantClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_constant_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseConstant),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_constant_init,
};
#include "./icons/const.c"
GType type_id;
-
type_id = bse_type_register_static (BSE_TYPE_SOURCE,
"BseConstant",
"This module provides constant signal outputs",
__FILE__, __LINE__,
&type_info);
bse_categories_register_stock_module (N_("/Other Sources/Constant"), type_id, const_pixstream);
-
return type_id;
}
-
static void
bse_constant_class_init (BseConstantClass *klass)
{
@@ -77,18 +62,13 @@ bse_constant_class_init (BseConstantClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel, i;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_constant_set_property;
gobject_class->get_property = bse_constant_get_property;
-
source_class->context_create = bse_constant_context_create;
-
for (i = 1; i <= BSE_CONSTANT_N_OUTPUTS; i++)
{
gchar *ident, *label, *blurb, *group = g_strdup_printf (_("Constant Output %u"), i);
-
ident = g_strdup_printf ("value_%u", i);
label = g_strdup_printf (_("Value [float]"));
bse_object_class_add_param (object_class, group, PARAM_VALUE + (i - 1) * 3,
@@ -127,16 +107,13 @@ bse_constant_class_init (BseConstantClass *klass)
g_free (group);
}
}
-
static void
bse_constant_init (BseConstant *constant)
{
guint i;
-
for (i = 0; i < BSE_CONSTANT_N_OUTPUTS; i++)
constant->constants[i] = 1.0;
}
-
static void
bse_constant_set_property (GObject *object,
guint param_id,
@@ -144,7 +121,6 @@ bse_constant_set_property (GObject *object,
GParamSpec *pspec)
{
BseConstant *self = BSE_CONSTANT (object);
-
switch (param_id)
{
guint indx, n;
@@ -195,7 +171,6 @@ bse_constant_set_property (GObject *object,
}
}
}
-
static void
bse_constant_get_property (GObject *object,
guint param_id,
@@ -203,7 +178,6 @@ bse_constant_get_property (GObject *object,
GParamSpec *pspec)
{
BseConstant *self = BSE_CONSTANT (object);
-
switch (param_id)
{
guint indx, n;
@@ -227,12 +201,10 @@ bse_constant_get_property (GObject *object,
}
}
}
-
typedef struct
{
gfloat constants[BSE_CONSTANT_N_OUTPUTS];
} ConstantModule;
-
static void
bse_constant_update_modules (BseConstant *constant,
BseTrans *trans)
@@ -244,25 +216,21 @@ bse_constant_update_modules (BseConstant *constant,
sizeof (constant->constants),
trans);
}
-
typedef struct {
guint index;
guint n_values;
gfloat constants[BSE_CONSTANT_N_OUTPUTS];
} FlowAccessData;
-
static void
constant_process (BseModule *module,
guint n_values)
{
ConstantModule *cmod = (ConstantModule*) module->user_data;
guint i;
-
for (i = 0; i < BSE_CONSTANT_N_OUTPUTS; i++)
if (BSE_MODULE_OSTREAM (module, i).connected)
BSE_MODULE_OSTREAM (module, i).values = bse_engine_const_values (cmod->constants[i]);
}
-
static void
bse_constant_context_create (BseSource *source,
guint context_handle,
@@ -280,18 +248,13 @@ bse_constant_context_create (BseSource *source,
};
ConstantModule *constant = g_new0 (ConstantModule, 1);
BseModule *module;
-
module = bse_module_new (&constant_class, constant);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
/* update (initialize) module data */
bse_constant_update_modules (BSE_CONSTANT (source), trans);
}
diff --git a/bse/bseconstant.hh b/bse/bseconstant.hh
index b88e4f4..1a9e27d 100644
--- a/bse/bseconstant.hh
+++ b/bse/bseconstant.hh
@@ -1,16 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CONSTANT_H__
#define __BSE_CONSTANT_H__
-
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
-
-
/* --- object type macros --- */
#define BSE_TYPE_CONSTANT (BSE_TYPE_ID (BseConstant))
#define BSE_CONSTANT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_CONSTANT, BseConstant))
@@ -18,27 +12,20 @@ extern "C" {
#define BSE_IS_CONSTANT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_CONSTANT))
#define BSE_IS_CONSTANT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_CONSTANT))
#define BSE_CONSTANT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_CONSTANT, BseConstantClass))
-
#define BSE_CONSTANT_N_OUTPUTS (4)
-
/* --- BseConstant source --- */
typedef struct _BseConstant BseConstant;
typedef struct _BseConstantClass BseConstantClass;
struct _BseConstant
{
BseSource parent_object;
-
gfloat constants[BSE_CONSTANT_N_OUTPUTS];
};
struct _BseConstantClass
{
BseSourceClass parent_class;
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_CONSTANT_H__ */
diff --git a/bse/bseconstvalues.cc b/bse/bseconstvalues.cc
index 55e8533..d6a3a6c 100644
--- a/bse/bseconstvalues.cc
+++ b/bse/bseconstvalues.cc
@@ -1,4 +1,2 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseconstvalues.hh"
-
-
diff --git a/bse/bseconstvalues.hh b/bse/bseconstvalues.hh
index aa9a1d5..b668625 100644
--- a/bse/bseconstvalues.hh
+++ b/bse/bseconstvalues.hh
@@ -1,34 +1,26 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CONST_VALUES_H__
#define __BSE_CONST_VALUES_H__
-
#include <bse/bsedefs.hh>
-
G_BEGIN_DECLS
-
/* --- frequencies --- */
/* kammer frequency, frequency of the note A of the standard piano
* octave.slightly different values are used in different countries,
* however, 440Hz is the official value for germany and much of europe.
*/
#define BSE_KAMMER_FREQUENCY (440.0)
-
/* maximum (audible) frequency represented in synthesis signals.
* this value shouldn't be changed, to maintain frequency
* representation in signals.
*/
#define BSE_MAX_FREQUENCY (24000.0)
-
/* minimum (needs to be > 0) and maximum audible frequencies supported
* by oscillators (outer limits for user supplied frequency values)
*/
#define BSE_MAX_OSC_FREQUENCY (20000.0)
#define BSE_MIN_OSC_FREQUENCY (1.0 / BSE_MAX_OSC_FREQUENCY)
-
/* epsilon used to compare audible frequencies and check for equality */
#define BSE_FREQUENCY_EPSILON (0.001)
-
-
/* --- transpose / fine tune --- */
#define BSE_MIN_TRANSPOSE (-72)
#define BSE_MAX_TRANSPOSE (+72)
@@ -37,8 +29,6 @@ G_BEGIN_DECLS
#define BSE_MIN_FINE_TUNE (-BSE_MAX_FINE_TUNE)
#define BSE_MAX_FINE_TUNE (+100)
#define BSE_FINE_TUNE_IS_VALID(n) ((n) >= BSE_MIN_FINE_TUNE && (n) <= BSE_MAX_FINE_TUNE)
-
-
/* --- signal ranges --- */
/* min..max sample value: -1.0 .. 1.0
* notes<->sample value: 0 .. 127 (BSE_VALUE_FROM_NOTE)
@@ -47,32 +37,21 @@ G_BEGIN_DECLS
#define BSE_FREQ_FROM_VALUE(value) (BSE_MAX_FREQUENCY * (value))
#define BSE_VALUE_FROM_FREQ(freq) ((1.0 / BSE_MAX_FREQUENCY) * (freq))
#define BSE_FREQUENCY_EPSILON (0.001)
-
-
/* --- volume --- */
#define BSE_MIN_VOLUME_dB (-144) /* theoretically: -96.3 */
#define BSE_MAX_VOLUME_dB (+24)
-
-
/* --- balance (left/right volume) --- */
#define BSE_MIN_BALANCE (-100.0)
#define BSE_MAX_BALANCE (+100.0)
-
/* --- bpm --- */
#define BSE_MIN_BPM (1)
#define BSE_MAX_BPM (1024)
-
-
/* --- time (unix seconds) --- */
#define BSE_MIN_TIME (631148400) /* 1990-01-01 00:00:00 */
#define BSE_MAX_TIME (2147483647) /* 2038-01-19 04:14:07 */
-
-
/* --- BseSource limits --- */
#define BSE_MAX_N_ICHANNELS (32)
#define BSE_MAX_N_OCHANNELS (32)
-
-
/* --- miscellaneous --- */
#define BSE_MAGIC (('B' << 24) | ('S' << 16) | \
/* 1112753441 0x42534521 */ ('E' << 8) | ('!' << 0))
@@ -81,7 +60,5 @@ G_BEGIN_DECLS
#define BSE_RATING_DEFAULT (50)
#define BSE_RATING_FALLBACK (1)
#define BSE_RATING_NO_AUTO (-1)
-
G_END_DECLS
-
#endif /* __BSE_CONST_VALUES_H__ */
diff --git a/bse/bsecontainer.cc b/bse/bsecontainer.cc
index 1e6fc3f..260d582 100644
--- a/bse/bsecontainer.cc
+++ b/bse/bsecontainer.cc
@@ -8,12 +8,8 @@
#include "bseengine.hh"
#include <stdlib.h>
#include <string.h>
-
-
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
enum
{
SIGNAL_ITEM_ADDED,
@@ -21,8 +17,6 @@ enum
SIGNAL_LAST
};
typedef struct _UncrossNode UncrossNode;
-
-
/* --- prototypes --- */
static void bse_container_class_init (BseContainerClass *klass);
static void bse_container_class_finalize (BseContainerClass *klass);
@@ -53,8 +47,6 @@ static gboolean container_default_check_restore (BseContainer
const gchar *child_type);
static void bse_container_uncross_descendant (BseContainer *container,
BseItem *item);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static GQuark quark_cross_links = 0;
@@ -62,32 +54,26 @@ static GSList *containers_cross_changes = NULL;
static guint containers_cross_changes_handler = 0;
static guint container_signals[SIGNAL_LAST] = { 0, };
static UncrossNode *uncross_stack = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseContainer)
{
static const GTypeInfo container_info = {
sizeof (BseContainerClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_container_class_init,
(GClassFinalizeFunc) bse_container_class_finalize,
NULL /* class_data */,
-
sizeof (BseContainer),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_container_init,
};
-
return bse_type_register_abstract (BSE_TYPE_SOURCE,
"BseContainer",
"Base type to manage BSE items",
__FILE__, __LINE__,
&container_info);
}
-
static void
bse_container_class_init (BseContainerClass *klass)
{
@@ -95,24 +81,19 @@ bse_container_class_init (BseContainerClass *klass)
BseObjectClass *object_class;
BseItemClass *item_class;
BseSourceClass *source_class;
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
object_class = BSE_OBJECT_CLASS (klass);
item_class = BSE_ITEM_CLASS (klass);
source_class = BSE_SOURCE_CLASS (klass);
-
quark_cross_links = g_quark_from_static_string ("BseContainerCrossLinks");
-
gobject_class->dispose = bse_container_dispose;
gobject_class->finalize = bse_container_finalize;
-
source_class->prepare = bse_container_prepare;
source_class->context_create = bse_container_context_create;
source_class->context_connect = bse_container_context_connect;
source_class->context_dismiss = bse_container_context_dismiss;
source_class->reset = bse_container_reset;
-
klass->add_item = bse_container_do_add_item;
klass->remove_item = bse_container_do_remove_item;
klass->forall_items = NULL;
@@ -120,62 +101,50 @@ bse_container_class_init (BseContainerClass *klass)
klass->retrieve_child = bse_container_real_retrieve_child;
klass->context_children = container_context_children;
klass->release_children = container_release_children;
-
container_signals[SIGNAL_ITEM_ADDED] = bse_object_class_add_signal (object_class, "item_added",
G_TYPE_NONE, 1, BSE_TYPE_ITEM);
container_signals[SIGNAL_ITEM_REMOVE] = bse_object_class_add_signal (object_class, "item_remove",
G_TYPE_NONE, 2, BSE_TYPE_ITEM,
SFI_TYPE_INT);
}
-
static void
bse_container_class_finalize (BseContainerClass *klass)
{
}
-
static void
bse_container_init (BseContainer *container)
{
container->n_items = 0;
}
-
static void
container_release_children (BseContainer *container)
{
/* provide function pointer for easy chaining */
}
-
static void
bse_container_dispose (GObject *gobject)
{
BseContainer *container = BSE_CONTAINER (gobject);
-
if (!BSE_ITEM (container)->use_count)
{
BSE_CONTAINER_GET_CLASS (container)->release_children (container);
-
/* remove any existing cross-links (with notification) */
g_object_set_qdata (G_OBJECT (container), quark_cross_links, NULL);
}
-
/* chain parent class' dispose handler */
G_OBJECT_CLASS (parent_class)->dispose (gobject);
}
-
static void
bse_container_finalize (GObject *gobject)
{
BseContainer *container = BSE_CONTAINER (gobject);
-
if (container->n_items)
g_warning ("%s: finalize handlers missed to remove %u items from %s",
G_STRLOC,
container->n_items,
BSE_OBJECT_TYPE_NAME (container));
-
/* chain parent class' finalize handler */
G_OBJECT_CLASS (parent_class)->finalize (gobject);
-
/* gobject->finalize() clears the datalist, which may cause this
* container to end up in the containers_cross_changes list again,
* so we make sure it is removed *after* the datalist has been
@@ -184,7 +153,6 @@ bse_container_finalize (GObject *gobject)
*/
containers_cross_changes = g_slist_remove_all (containers_cross_changes, gobject);
}
-
static void
bse_container_do_add_item (BseContainer *container,
BseItem *item)
@@ -192,16 +160,12 @@ bse_container_do_add_item (BseContainer *container,
g_object_ref (item);
container->n_items += 1;
bse_item_set_parent (item, BSE_ITEM (container));
-
if (BSE_IS_SOURCE (item) && BSE_SOURCE_PREPARED (container))
{
BseTrans *trans = bse_trans_open ();
guint *cids, n, c;
-
g_return_if_fail (BSE_SOURCE_PREPARED (item) == FALSE);
-
bse_source_prepare (BSE_SOURCE (item));
-
/* create and connect item contexts */
cids = bse_source_context_ids (BSE_SOURCE (container), &n);
for (c = 0; c < n; c++)
@@ -212,34 +176,28 @@ bse_container_do_add_item (BseContainer *container,
bse_trans_commit (trans);
}
}
-
void
bse_container_add_item (BseContainer *container,
BseItem *item)
{
BseUndoStack *ustack;
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (item->parent == NULL);
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->add_item != NULL); /* paranoid */
-
g_object_ref (container);
g_object_ref (item);
ustack = bse_item_undo_open (container, "add-child-noundo");
bse_undo_stack_ignore_steps (ustack);
g_object_freeze_notify (G_OBJECT (container));
g_object_freeze_notify (G_OBJECT (item));
-
const char *uname = BSE_OBJECT_UNAME (item);
-
/* ensure uniqueness of item unames within a container
*/
if (!uname || bse_container_lookup_item (container, uname))
{
gchar *buffer, *p;
guint i = 0, l;
-
if (!uname)
uname = (char*) g_object_get_data (G_OBJECT (container), "BseContainer-base-name");
if (!uname)
@@ -250,7 +208,6 @@ bse_container_add_item (BseContainer *container,
else if (strncmp (uname, "Bse", 3) == 0 && uname[3] >= 'A' && uname[3] <= 'Z')
uname += 3; /* strip Bse namespace for convenient naming */
}
-
l = strlen (uname);
buffer = g_new (gchar, l + 12);
strcpy (buffer, uname);
@@ -258,16 +215,13 @@ bse_container_add_item (BseContainer *container,
do
g_snprintf (p, 11, "-%u", ++i);
while (bse_container_lookup_item (container, buffer));
-
g_object_set (item, "uname", buffer, NULL); /* no undo */
g_free (buffer);
}
g_object_set_data (G_OBJECT (container), "BseContainer-base-name", NULL);
-
BSE_CONTAINER_GET_CLASS (container)->add_item (container, item);
if (item->parent != NULL)
g_signal_emit (container, container_signals[SIGNAL_ITEM_ADDED], 0, item);
-
g_object_thaw_notify (G_OBJECT (item));
g_object_thaw_notify (G_OBJECT (container));
bse_undo_stack_unignore_steps (ustack);
@@ -275,7 +229,6 @@ bse_container_add_item (BseContainer *container,
g_object_unref (item);
g_object_unref (container);
}
-
gpointer
bse_container_new_child_bname (BseContainer *container,
GType child_type,
@@ -285,11 +238,9 @@ bse_container_new_child_bname (BseContainer *container,
{
gpointer child;
va_list var_args;
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (g_type_is_a (child_type, BSE_TYPE_ITEM), NULL);
g_return_val_if_fail (!G_TYPE_IS_ABSTRACT (child_type), NULL);
-
g_object_set_data_full (G_OBJECT (container), "BseContainer-base-name", g_strdup (base_name), g_free);
va_start (var_args, first_param_name);
child = g_object_new_valist (child_type, first_param_name, var_args);
@@ -298,25 +249,20 @@ bse_container_new_child_bname (BseContainer *container,
g_object_set (child, "uname", NULL, NULL); /* no undo */
bse_container_add_item (container, BSE_ITEM (child));
g_object_unref (child);
-
return child;
}
-
static void
bse_container_do_remove_item (BseContainer *container,
BseItem *item)
{
BseItem *ancestor = BSE_ITEM (container);
-
do
{
bse_container_uncross_descendant (BSE_CONTAINER (ancestor), item);
ancestor = ancestor->parent;
}
while (ancestor);
-
container->n_items -= 1;
-
if (BSE_IS_SOURCE (item))
{
/* detach item from rest of the world */
@@ -326,19 +272,15 @@ bse_container_do_remove_item (BseContainer *container,
if (BSE_SOURCE_PREPARED (container))
{
g_return_if_fail (BSE_SOURCE_PREPARED (item) == TRUE);
-
bse_source_reset (BSE_SOURCE (item));
}
}
-
/* reset parent *after* uncrossing, so "release" notification
* on item operates on sane object trees
*/
bse_item_set_parent (item, NULL);
-
g_object_unref (item);
}
-
void
bse_container_remove_item (BseContainer *container,
BseItem *item)
@@ -346,19 +288,16 @@ bse_container_remove_item (BseContainer *container,
gboolean finalizing_container;
BseUndoStack *ustack;
guint seqid;
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (item->parent == BSE_ITEM (container));
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->remove_item != NULL); /* paranoid */
-
finalizing_container = G_OBJECT (container)->ref_count == 0;
if (!finalizing_container)
g_object_ref (container);
g_object_ref (item);
ustack = bse_item_undo_open (container, "remove-child-noundo");
bse_undo_stack_ignore_steps (ustack);
-
seqid = bse_container_get_item_seqid (container, item);
g_object_freeze_notify (G_OBJECT (container));
g_object_freeze_notify (G_OBJECT (item));
@@ -367,14 +306,12 @@ bse_container_remove_item (BseContainer *container,
BSE_CONTAINER_GET_CLASS (container)->remove_item (container, item);
g_object_thaw_notify (G_OBJECT (item));
g_object_thaw_notify (G_OBJECT (container));
-
bse_undo_stack_unignore_steps (ustack);
bse_item_undo_close (ustack);
g_object_unref (item);
if (!finalizing_container)
g_object_unref (container);
}
-
void
bse_container_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -382,53 +319,40 @@ bse_container_forall_items (BseContainer *container,
{
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (func != NULL);
-
if (container->n_items)
{
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, func, data);
}
}
-
static gboolean
list_items (BseItem *item,
gpointer data)
{
BseItemSeq *iseq = (BseItemSeq*) data;
-
bse_item_seq_append (iseq, item);
-
return TRUE;
}
-
BseItemSeq*
bse_container_list_children (BseContainer *container)
{
BseItemSeq *iseq;
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
-
iseq = bse_item_seq_new ();
if (container->n_items)
{
g_return_val_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL, NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, list_items, iseq);
}
-
return iseq;
}
-
static gboolean
count_item_seqid (BseItem *item,
gpointer data_p)
{
void **data = (void**) data_p;
-
if (G_OBJECT_TYPE (item) == (GType) data[2])
data[0] = GUINT_TO_POINTER (GPOINTER_TO_UINT (data[0]) + 1);
-
if (item == data[1])
{
data[1] = NULL;
@@ -437,7 +361,6 @@ count_item_seqid (BseItem *item,
else
return TRUE;
}
-
guint
bse_container_get_item_seqid (BseContainer *container,
BseItem *item)
@@ -445,31 +368,24 @@ bse_container_get_item_seqid (BseContainer *container,
g_return_val_if_fail (BSE_IS_CONTAINER (container), 0);
g_return_val_if_fail (BSE_IS_ITEM (item), 0);
g_return_val_if_fail (item->parent == BSE_ITEM (container), 0);
-
if (container->n_items)
{
gpointer data[3];
-
g_return_val_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL, 0); /* paranoid */
-
data[0] = GUINT_TO_POINTER (0);
data[1] = item;
data[2] = (gpointer) G_OBJECT_TYPE (item);
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, count_item_seqid, data);
-
return data[1] == NULL ? GPOINTER_TO_UINT (data[0]) : 0;
}
else
return 0;
}
-
static gboolean
find_nth_item (BseItem *item,
gpointer data_p)
{
void **data = (void**) data_p;
-
if (G_OBJECT_TYPE (item) == (GType) data[2])
{
data[0] = GUINT_TO_POINTER (GPOINTER_TO_UINT (data[0]) - 1);
@@ -481,7 +397,6 @@ find_nth_item (BseItem *item,
}
return TRUE;
}
-
BseItem*
bse_container_get_item (BseContainer *container,
GType item_type,
@@ -490,25 +405,19 @@ bse_container_get_item (BseContainer *container,
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (seqid > 0, NULL);
g_return_val_if_fail (g_type_is_a (item_type, BSE_TYPE_ITEM), NULL);
-
if (container->n_items)
{
gpointer data[3];
-
g_return_val_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL, NULL); /* paranoid */
-
data[0] = GUINT_TO_POINTER (seqid);
data[1] = NULL;
data[2] = (gpointer) item_type;
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, find_nth_item, data);
-
return BSE_ITEM (data[1]);
}
else
return NULL;
}
-
static gboolean
store_forall (BseItem *item,
gpointer data)
@@ -519,19 +428,16 @@ store_forall (BseItem *item,
bse_storage_store_child (storage, item);
return TRUE;
}
-
void
bse_container_store_children (BseContainer *container,
BseStorage *storage)
{
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_STORAGE (storage));
-
g_object_ref (container);
bse_container_forall_items (container, store_forall, storage);
g_object_unref (container);
}
-
static gboolean
container_default_check_restore (BseContainer *self,
const gchar *child_type)
@@ -539,24 +445,20 @@ container_default_check_restore (BseContainer *self,
GType type = g_type_from_name (child_type);
return g_type_is_a (type, BSE_TYPE_ITEM) && !G_TYPE_IS_ABSTRACT (type);
}
-
gboolean
bse_container_check_restore (BseContainer *self,
const gchar *child_type)
{
g_return_val_if_fail (BSE_IS_CONTAINER (self), FALSE);
g_return_val_if_fail (child_type != NULL, FALSE);
-
return BSE_CONTAINER_GET_CLASS (self)->check_restore (self, child_type);
}
-
static gboolean
find_unamed_item (BseItem *item,
gpointer data_p)
{
void **data = (void**) data_p;
gchar *uname = (char*) data[1];
-
if (bse_string_equals (BSE_OBJECT_UNAME (item), uname))
{
data[0] = item;
@@ -564,24 +466,18 @@ find_unamed_item (BseItem *item,
}
return TRUE;
}
-
BseItem*
bse_container_lookup_item (BseContainer *container,
const gchar *uname)
{
gpointer data[2] = { NULL, };
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (uname != NULL, NULL);
-
/* FIXME: better use a hashtable here */
-
data[1] = (gpointer) uname;
bse_container_forall_items (container, find_unamed_item, data);
-
return BSE_ITEM (data[0]);
}
-
static BseItem*
bse_container_real_retrieve_child (BseContainer *container,
GType child_type,
@@ -591,7 +487,6 @@ bse_container_real_retrieve_child (BseContainer *container,
uname ? "uname" : NULL, uname,
NULL);
}
-
BseItem*
bse_container_retrieve_child (BseContainer *container,
const gchar *type_uname)
@@ -599,10 +494,8 @@ bse_container_retrieve_child (BseContainer *container,
BseItem *item = NULL;
gchar *type_name, *uname;
GType type;
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (type_uname != NULL, NULL);
-
/* type_uname syntax:
* <TYPE> [ <::> <UNAME> ]
* examples:
@@ -613,7 +506,6 @@ bse_container_retrieve_child (BseContainer *container,
* to have unique names (enforced in bse_container_add_item()
* and bse_item_do_set_uname()).
*/
-
type_name = g_strdup (type_uname);
uname = strchr (type_name, ':');
if (uname)
@@ -630,27 +522,21 @@ bse_container_retrieve_child (BseContainer *container,
if (g_type_is_a (type, BSE_TYPE_ITEM))
item = BSE_CONTAINER_GET_CLASS (container)->retrieve_child (container, type, uname);
g_free (type_name);
-
return item;
}
-
BseItem*
bse_container_resolve_upath (BseContainer *container,
const gchar *upath)
{
const gchar *next_uname;
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (upath != NULL, NULL);
-
/* upaths consist of colon seperated unames from the item's ancestry */
-
next_uname = strchr (upath, ':');
if (next_uname)
{
gchar *uname = g_strndup (upath, next_uname - upath);
BseItem *item = bse_container_lookup_item (container, uname);
-
g_free (uname);
if (BSE_IS_CONTAINER (item))
return bse_container_resolve_upath (BSE_CONTAINER (item), next_uname + 1);
@@ -660,7 +546,6 @@ bse_container_resolve_upath (BseContainer *container,
else
return bse_container_lookup_item (container, upath);
}
-
gchar* /* free result */
bse_container_make_upath (BseContainer *container,
BseItem *item)
@@ -669,12 +554,10 @@ bse_container_make_upath (BseContainer *container,
GSList *slist, *ulist = NULL;
gchar *path, *p;
guint n;
-
g_return_val_if_fail (BSE_IS_CONTAINER (container), NULL);
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
self_item = BSE_ITEM (container);
g_return_val_if_fail (bse_item_has_ancestor (item, self_item), NULL); /* item != self_item */
-
n = 0;
for (; item != self_item; item = item->parent)
{
@@ -691,29 +574,22 @@ bse_container_make_upath (BseContainer *container,
*p++ = ':';
}
g_slist_free (ulist);
-
return path;
}
-
static gboolean
notify_cross_changes (gpointer data)
{
BSE_THREADS_ENTER ();
-
while (containers_cross_changes)
{
BseContainer *container = BSE_CONTAINER (containers_cross_changes->data);
-
containers_cross_changes = g_slist_remove_all (containers_cross_changes, container);
// g_signal_emit (container, container_signals[SIGNAL_CROSS_CHANGES], 0);
}
containers_cross_changes_handler = 0;
-
BSE_THREADS_LEAVE ();
-
return FALSE;
}
-
static inline void
container_queue_cross_changes (BseContainer *container)
{
@@ -721,7 +597,6 @@ container_queue_cross_changes (BseContainer *container)
containers_cross_changes_handler = bse_idle_notify (notify_cross_changes, NULL);
containers_cross_changes = g_slist_prepend (containers_cross_changes, container);
}
-
typedef struct
{
BseItem *owner;
@@ -743,7 +618,6 @@ struct _UncrossNode
BseItem *link;
BseItemUncross uncross;
};
-
static inline void
uncross_link_R (BseContainerCrossLinks *clinks,
guint n,
@@ -753,11 +627,9 @@ uncross_link_R (BseContainerCrossLinks *clinks,
unode.owner = clinks->cross_links[n].owner;
unode.link = clinks->cross_links[n].link;
unode.uncross = clinks->cross_links[n].uncross;
-
clinks->n_cross_links--;
if (n < clinks->n_cross_links)
clinks->cross_links[n] = clinks->cross_links[clinks->n_cross_links];
-
if (notify)
{
/* record recursion */
@@ -769,20 +641,16 @@ uncross_link_R (BseContainerCrossLinks *clinks,
uncross_stack = unode.next;
}
}
-
static void
destroy_clinks (gpointer data)
{
BseContainerCrossLinks *clinks = (BseContainerCrossLinks*) data;
-
if (clinks->n_cross_links)
container_queue_cross_changes (clinks->container);
-
while (clinks->n_cross_links)
uncross_link_R (clinks, clinks->n_cross_links - 1, TRUE);
g_free (clinks);
}
-
static inline void
container_set_clinks (gpointer container,
BseContainerCrossLinks *clinks)
@@ -790,13 +658,11 @@ container_set_clinks (gpointer container,
g_object_steal_qdata (G_OBJECT (container), quark_cross_links);
g_object_set_qdata_full (G_OBJECT (container), quark_cross_links, clinks, destroy_clinks);
}
-
static inline BseContainerCrossLinks*
container_get_clinks (gpointer container)
{
return (BseContainerCrossLinks*) g_object_get_qdata (G_OBJECT (container), quark_cross_links);
}
-
void
_bse_container_cross_link (BseContainer *container,
BseItem *owner,
@@ -805,18 +671,15 @@ _bse_container_cross_link (BseContainer *container,
{
BseContainerCrossLinks *clinks;
guint i;
-
/* prerequisites:
* - container == bse_item_common_ancestor (owner, link)
* - container != owner || container != link
* + implies: owner != link
*/
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
g_return_if_fail (uncross != NULL);
-
clinks = container_get_clinks (container);
if (!clinks)
{
@@ -829,7 +692,6 @@ _bse_container_cross_link (BseContainer *container,
else
{
BseContainerCrossLinks *old_loc = clinks;
-
i = clinks->n_cross_links++;
clinks = (BseContainerCrossLinks*) g_realloc (clinks, sizeof (BseContainerCrossLinks) + i * sizeof (clinks->cross_links[0]));
if (old_loc != clinks)
@@ -839,10 +701,8 @@ _bse_container_cross_link (BseContainer *container,
clinks->cross_links[i].link = link;
clinks->cross_links[i].uncross = uncross;
// clinks->cross_links[i].data = data;
-
container_queue_cross_changes (container);
}
-
void
_bse_container_cross_unlink (BseContainer *container,
BseItem *owner,
@@ -851,16 +711,13 @@ _bse_container_cross_unlink (BseContainer *container,
{
UncrossNode *unode;
gboolean found_one = FALSE;
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
g_return_if_fail (uncross != NULL);
-
g_object_ref (container);
g_object_ref (owner);
g_object_ref (link);
-
/* _first_ check whether a currently uncrossing (in recursion)
* link is to be unlinked
*/
@@ -883,7 +740,6 @@ _bse_container_cross_unlink (BseContainer *container,
if (clinks)
{
guint i = 0;
-
while (i < clinks->n_cross_links)
{
if (clinks->cross_links[i].owner == owner &&
@@ -904,27 +760,22 @@ _bse_container_cross_unlink (BseContainer *container,
G_OBJECT_TYPE_NAME (owner),
G_OBJECT_TYPE_NAME (link),
G_OBJECT_TYPE_NAME (container));
-
g_object_unref (link);
g_object_unref (owner);
g_object_unref (container);
}
-
void
_bse_container_uncross (BseContainer *container,
BseItem *owner,
BseItem *link)
{
BseContainerCrossLinks *clinks;
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
-
g_object_ref (container);
g_object_ref (owner);
g_object_ref (link);
-
clinks = container_get_clinks (container);
if (clinks)
{
@@ -942,12 +793,10 @@ _bse_container_uncross (BseContainer *container,
i++;
}
}
-
g_object_unref (link);
g_object_unref (owner);
g_object_unref (container);
}
-
/* we could in theory use bse_item_has_ancestor() here,
* but actually this test should be as fast as possible,
* and we also want to catch item == container
@@ -957,7 +806,6 @@ item_check_branch (BseItem *item,
gpointer container)
{
BseItem *ancestor = BSE_ITEM (container);
-
do
{
if (item == ancestor)
@@ -965,32 +813,25 @@ item_check_branch (BseItem *item,
item = item->parent;
}
while (item);
-
return FALSE;
}
-
static void
bse_container_uncross_descendant (BseContainer *container,
BseItem *item)
{
BseContainerCrossLinks *clinks;
gboolean found_one = FALSE;
-
/* prerequisites:
* bse_item_has_ancestor (item, container) == TRUE
*/
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (item));
-
clinks = container_get_clinks (container);
if (clinks)
{
guint i = 0;
-
g_object_ref (container);
g_object_ref (item);
-
/* suppress tree walks where possible
*/
if (!BSE_IS_CONTAINER (item) || ((BseContainer*) item)->n_items == 0)
@@ -1009,7 +850,6 @@ bse_container_uncross_descendant (BseContainer *container,
else /* need to check whether item is ancestor of any of the cross-link items here */
{
BseItem *saved_parent, *citem = BSE_ITEM (container);
-
/* we do some minor hackery here, for optimization purposes:
* since item is a child of container, we don't need to walk
* ->owner's or ->link's ancestor list any further than
@@ -1026,12 +866,10 @@ bse_container_uncross_descendant (BseContainer *container,
item_check_branch (clinks->cross_links[i].link, item))
{
citem->parent = saved_parent;
-
found_one = TRUE;
uncross_link_R (clinks, i, TRUE);
clinks = container_get_clinks (container);
i = 0;
-
saved_parent = citem->parent;
citem->parent = NULL;
}
@@ -1040,169 +878,129 @@ bse_container_uncross_descendant (BseContainer *container,
}
citem->parent = saved_parent;
}
-
if (found_one)
container_queue_cross_changes (container);
-
g_object_unref (item);
g_object_unref (container);
}
}
-
static gboolean
forall_prepare (BseItem *item,
gpointer data)
{
if (BSE_IS_SOURCE (item) && !BSE_SOURCE_PREPARED (item))
bse_source_prepare (BSE_SOURCE (item));
-
return TRUE;
}
-
static void
bse_container_prepare (BseSource *source)
{
BseContainer *container = BSE_CONTAINER (source);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
-
/* make sure all BseSource children are prepared last */
if (container->n_items)
{
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, forall_prepare, NULL);
}
}
-
static gboolean
forall_slist_prepend (BseItem *item,
gpointer data)
{
GSList **slist_p = (GSList**) data;
-
if (BSE_IS_SOURCE (item))
*slist_p = g_slist_prepend (*slist_p, item);
-
return TRUE;
}
-
static GSList*
container_context_children (BseContainer *container)
{
GSList *slist = NULL;
-
g_return_val_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL, NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, forall_slist_prepend, &slist);
-
return slist;
}
-
static void
bse_container_context_create (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseContainer *container = BSE_CONTAINER (source);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
/* handle children */
if (container->n_items)
{
GSList *node, *slist = BSE_CONTAINER_GET_CLASS (container)->context_children (container);
-
for (node = slist; node; node = node->next)
bse_source_create_context (BSE_SOURCE (node->data), context_handle, trans);
g_slist_free (slist);
}
}
-
static gboolean
forall_context_connect (BseItem *item,
gpointer _data)
{
void **data = (void**) _data;
guint cid = GPOINTER_TO_UINT (data[0]);
-
if (BSE_IS_SOURCE (item))
{
BseSource *source = BSE_SOURCE (item);
-
g_return_val_if_fail (BSE_SOURCE_PREPARED (item), TRUE);
-
if (bse_source_has_context (source, cid))
bse_source_connect_context (source, cid, (BseTrans*) data[1]);
}
-
return TRUE;
}
-
static void
bse_container_context_connect (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseContainer *container = BSE_CONTAINER (source);
-
/* handle children */
if (container->n_items)
{
gpointer data[2] = { GUINT_TO_POINTER (context_handle), trans };
-
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, forall_context_connect, data);
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static gboolean
forall_context_dismiss (BseItem *item,
gpointer _data)
{
void **data = (void**) _data;
guint cid = GPOINTER_TO_UINT (data[0]);
-
if (BSE_IS_SOURCE (item))
{
BseSource *source = BSE_SOURCE (item);
-
g_return_val_if_fail (BSE_SOURCE_PREPARED (item), TRUE);
-
if (bse_source_has_context (source, cid))
bse_source_dismiss_context (source, cid, (BseTrans*) data[1]);
}
-
return TRUE;
}
-
static void
bse_container_context_dismiss (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseContainer *container = BSE_CONTAINER (source);
-
/* handle children */
if (container->n_items)
{
gpointer data[2] = { GUINT_TO_POINTER (context_handle), trans };
-
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, forall_context_dismiss, data);
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
static gboolean
forall_reset (BseItem *item,
gpointer data)
@@ -1210,30 +1008,23 @@ forall_reset (BseItem *item,
if (BSE_IS_SOURCE (item))
{
g_return_val_if_fail (BSE_SOURCE_PREPARED (item), TRUE);
-
bse_source_reset (BSE_SOURCE (item));
}
-
return TRUE;
}
-
static void
bse_container_reset (BseSource *source)
{
BseContainer *container = BSE_CONTAINER (source);
-
/* make sure all BseSource children are reset first */
if (container->n_items)
{
g_return_if_fail (BSE_CONTAINER_GET_CLASS (container)->forall_items != NULL); /* paranoid */
-
BSE_CONTAINER_GET_CLASS (container)->forall_items (container, forall_reset, NULL);
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
-
static void
undo_remove_child (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -1244,24 +1035,20 @@ undo_remove_child (BseUndoStep *ustep,
bse_container_add_item ((BseContainer*) bse_undo_pointer_unpack ((char*) ustep->data[2].v_pointer, ustack), child);
g_object_unref (child);
}
-
static void
unde_free_remove_child (BseUndoStep *ustep)
{
g_free (ustep->data[1].v_pointer);
g_free (ustep->data[2].v_pointer);
}
-
void
bse_container_uncross_undoable (BseContainer *container,
BseItem *child)
{
BseItem *ancestor;
-
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (child));
g_return_if_fail (child->parent == (BseItem*) container);
-
/* backup source channels state */
if (BSE_IS_SOURCE (child))
{
@@ -1279,7 +1066,6 @@ bse_container_uncross_undoable (BseContainer *container,
}
while (ancestor);
}
-
void
bse_container_remove_backedup (BseContainer *container,
BseItem *child,
@@ -1288,9 +1074,7 @@ bse_container_remove_backedup (BseContainer *container,
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (BSE_IS_ITEM (child));
g_return_if_fail (child->parent == (BseItem*) container);
-
/* _no_ redo facility is queued by this function */
-
/* backup item state */
bse_item_backup_to_undo (child, ustack);
/* make sure item is recreated upon undo */
@@ -1302,7 +1086,6 @@ bse_container_remove_backedup (BseContainer *container,
ustep->data[2].v_pointer = bse_undo_pointer_pack (container, ustack);
bse_undo_stack_push (ustack, ustep);
}
-
/* check for automation properties */
BseProject *deactivate_project = NULL;
if (!BSE_UNDO_STACK_VOID (ustack) && BSE_IS_SOURCE (child) && BSE_SOURCE_PREPARED (child))
@@ -1314,19 +1097,15 @@ bse_container_remove_backedup (BseContainer *container,
deactivate_project = bse_item_get_project (child);
}
}
-
/* actual removal */
bse_undo_stack_ignore_steps (ustack);
bse_container_remove_item (container, child);
bse_undo_stack_unignore_steps (ustack);
-
/* certain things work only (can only be undone) in deactivated projects */
if (deactivate_project)
bse_project_push_undo_silent_deactivate (deactivate_project);
}
-
#include <stdio.h>
-
static gboolean
container_debug_tree_forall (BseItem *item,
gpointer data_p)
@@ -1334,19 +1113,16 @@ container_debug_tree_forall (BseItem *item,
void **data = (void**) data_p;
BseContainer *container = BSE_CONTAINER (data[0]);
FILE *file = (FILE*) data[1];
-
fprintf (file, " %s (%s)\n", bse_container_make_upath (container, item), bse_object_debug_name (item));
if (BSE_IS_CONTAINER (item))
BSE_CONTAINER_GET_CLASS (item)->forall_items (BSE_CONTAINER (item), container_debug_tree_forall, data_p);
return TRUE;
}
-
void
bse_container_debug_tree (BseContainer *container)
{
FILE *file = stderr;
gpointer data[2];
-
fprintf (file, "%s:\n", bse_object_debug_name (container));
data[0] = container;
data[1] = file;
diff --git a/bse/bsecontainer.hh b/bse/bsecontainer.hh
index 6ee23fa..8b4fe9a 100644
--- a/bse/bsecontainer.hh
+++ b/bse/bsecontainer.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CONTAINER_H__
#define __BSE_CONTAINER_H__
-
#include <bse/bsesource.hh>
#include <sfi/gbsearcharray.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_CONTAINER (BSE_TYPE_ID (BseContainer))
#define BSE_CONTAINER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_CONTAINER, BseContainer))
@@ -15,8 +12,6 @@ G_BEGIN_DECLS
#define BSE_IS_CONTAINER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_CONTAINER))
#define BSE_CONTAINER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_CONTAINER, BseContainerClass))
#define BSE_CONTAINER_FLAGS_USHIFT (BSE_SOURCE_FLAGS_USHIFT + 0)
-
-
/* --- BseContainer object --- */
typedef gboolean (*BseForallItemsFunc) (BseItem *item,
gpointer data);
@@ -26,13 +21,11 @@ typedef gboolean (*BseForallCrossFunc) (BseItem *owner,
struct _BseContainer
{
BseSource parent_instance;
-
guint n_items; /* paranoid checks */
};
struct _BseContainerClass
{
BseSourceClass parent_class;
-
void (*add_item) (BseContainer *container,
BseItem *item);
void (*remove_item) (BseContainer *container,
@@ -48,8 +41,6 @@ struct _BseContainerClass
GSList* (*context_children) (BseContainer *container);
void (*release_children) (BseContainer *container);
};
-
-
/* --- prototypes --- */
void bse_container_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -90,8 +81,6 @@ void bse_container_uncross_undoable (BseContainer *container,
void bse_container_remove_backedup (BseContainer *container,
BseItem *child,
BseUndoStack *ustack);
-
-
/* --- internal functions --- */
void _bse_container_cross_link (BseContainer *container,
BseItem *owner,
@@ -105,8 +94,5 @@ void _bse_container_uncross (BseContainer *container,
BseItem *owner,
BseItem *link);
void bse_container_debug_tree (BseContainer *container);
-
-
G_END_DECLS
-
#endif /* __BSE_CONTAINER_H__ */
diff --git a/bse/bsecontainer.proc b/bse/bsecontainer.proc
index e29b72d..5d22c6f 100644
--- a/bse/bsecontainer.proc
+++ b/bse/bsecontainer.proc
@@ -3,12 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bsecontainer.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseContainer, list-children) {
HELP = _("Retrieve all immediate children of a container");
IN = bse_param_spec_object ("container", NULL, NULL, BSE_TYPE_CONTAINER, SFI_PARAM_STANDARD);
@@ -19,17 +15,13 @@ METHOD (BseContainer, list-children) {
{
/* extract parameter values */
BseContainer *container = (BseContainer*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_CONTAINER (container))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_take_boxed (out_values++, bse_container_list_children (container));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseContainer, lookup-item) {
HELP = ("Find an immediate child of a container from its uname (the uname "
"is the name of the item, unique between all immediate children of a container).");
@@ -43,17 +35,13 @@ METHOD (BseContainer, lookup-item) {
/* extract parameter values */
BseContainer *container = (BseContainer*) bse_value_get_object (in_values++);
const char *uname = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_CONTAINER (container) || !uname)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_container_lookup_item (container, uname));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseContainer, get-item) {
HELP = "Retrieve a containers immediate child from it's sequential id.";
IN = bse_param_spec_object ("container", NULL, NULL, BSE_TYPE_CONTAINER, SFI_PARAM_STANDARD);
@@ -71,13 +59,10 @@ METHOD (BseContainer, get-item) {
const char *type_name = sfi_value_get_string (in_values++);
guint seqid = sfi_value_get_int (in_values++);
GType type = type_name ? g_type_from_name (type_name) : 0;
-
/* check parameters */
if (!BSE_IS_CONTAINER (container) || !g_type_is_a (type, BSE_TYPE_ITEM))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_container_get_item (container, type, seqid));
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsecontextmerger.cc b/bse/bsecontextmerger.cc
index 627ed7e..f73819d 100644
--- a/bse/bsecontextmerger.cc
+++ b/bse/bsecontextmerger.cc
@@ -4,10 +4,7 @@
#include "bsesnet.hh"
#include "bseserver.hh"
#include "bseengine.hh"
-
#include <string.h>
-
-
/* --- prototypes --- */
static void bse_context_merger_init (BseContextMerger *self);
static void bse_context_merger_class_init (BseContextMergerClass *klass);
@@ -17,12 +14,8 @@ static void bse_context_merger_context_create (BseSource *source,
static void bse_context_merger_context_dismiss (BseSource *source,
uint context_handle,
BseTrans *trans);
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseContextMerger)
{
@@ -37,53 +30,43 @@ BSE_BUILTIN_TYPE (BseContextMerger)
0 /* n_preallocs */,
(GInstanceInitFunc) bse_context_merger_init,
};
-
return bse_type_register_static (BSE_TYPE_SOURCE,
"BseContextMerger",
"Internal CONTEXT Voice glue object (merger)",
__FILE__, __LINE__,
&type_info);
}
-
static void
bse_context_merger_class_init (BseContextMergerClass *klass)
{
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
uint channel_id, i;
-
parent_class = g_type_class_peek_parent (klass);
-
source_class->context_create = bse_context_merger_context_create;
source_class->context_dismiss = bse_context_merger_context_dismiss;
-
for (i = 0; i < BSE_CONTEXT_MERGER_N_IOPORTS; i++)
{
char *ident;
-
ident = g_strdup_printf ("input-%u", i + 1);
channel_id = bse_source_class_add_jchannel (source_class, ident, NULL, NULL);
g_assert (channel_id == i);
g_free (ident);
-
ident = g_strdup_printf ("output-%u", i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, NULL, NULL);
g_assert (channel_id == i);
g_free (ident);
}
}
-
static void
bse_context_merger_init (BseContextMerger *self)
{
self->merge_context = 0;
}
-
void
bse_context_merger_set_merge_context (BseContextMerger *self,
uint merge_context)
{
g_return_if_fail (BSE_CONTEXT_MERGER (self));
-
if (merge_context)
{
g_return_if_fail (self->merge_context == 0);
@@ -91,26 +74,21 @@ bse_context_merger_set_merge_context (BseContextMerger *self,
}
else
g_return_if_fail (self->merge_context != 0);
-
self->merge_context = merge_context;
}
-
typedef struct {
uint real_context;
uint ref_count;
} ContextModuleData;
-
static void
context_merger_process (BseModule *module,
uint n_values)
{
uint i;
-
for (i = 0; i < BSE_CONTEXT_MERGER_N_IOPORTS; i++)
if (BSE_MODULE_OSTREAM (module, i).connected)
{
uint j, n_cons = BSE_MODULE_JSTREAM (module, i).n_connections;
-
if (!n_cons)
module->ostreams[i].values = bse_engine_const_values (0);
else if (n_cons == 1)
@@ -128,7 +106,6 @@ context_merger_process (BseModule *module,
}
}
}
-
static void
bse_context_merger_context_create (BseSource *source,
uint context_handle,
@@ -146,7 +123,6 @@ bse_context_merger_context_create (BseSource *source,
};
BseContextMerger *self = BSE_CONTEXT_MERGER (source);
BseModule *module;
-
/* merge with existing context if set */
if (self->merge_context)
{
@@ -169,21 +145,17 @@ bse_context_merger_context_create (BseSource *source,
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
}
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_context_merger_context_dismiss (BseSource *source,
uint context_handle,
BseTrans *trans)
{
BseModule *module;
-
/* if the BseModule wasn't created within context_handle, we would
* just need to disconnect it from connections within this context
* and not discard it. however, that's somewhat tedious since it
@@ -192,7 +164,6 @@ bse_context_merger_context_dismiss (BseSource *source,
* so we can simply skip the disconnection, as usually all contexts
* should be dismissed together.
*/
-
module = bse_source_get_context_imodule (source, context_handle);
if (module)
{
@@ -205,7 +176,6 @@ bse_context_merger_context_dismiss (BseSource *source,
bse_source_set_context_omodule (source, context_handle, NULL);
}
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
diff --git a/bse/bsecontextmerger.hh b/bse/bsecontextmerger.hh
index ebcaaee..468bf8d 100644
--- a/bse/bsecontextmerger.hh
+++ b/bse/bsecontextmerger.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CONTEXT_MERGER_H__
#define __BSE_CONTEXT_MERGER_H__
-
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_CONTEXT_MERGER (BSE_TYPE_ID (BseContextMerger))
#define BSE_CONTEXT_MERGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_CONTEXT_MERGER, BseContextMerger))
@@ -13,25 +10,19 @@ G_BEGIN_DECLS
#define BSE_IS_CONTEXT_MERGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_CONTEXT_MERGER))
#define BSE_IS_CONTEXT_MERGER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_CONTEXT_MERGER))
#define BSE_CONTEXT_MERGER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_CONTEXT_MERGER, BseContextMergerClass))
-
#define BSE_CONTEXT_MERGER_N_IOPORTS (8)
-
/* --- object structures --- */
struct _BseContextMerger
{
BseSource parent_instance;
-
guint merge_context;
};
struct _BseContextMergerClass
{
BseSourceClass parent_class;
};
-
/* --- API --- */
void bse_context_merger_set_merge_context (BseContextMerger *self,
guint merge_context);
-
G_END_DECLS
-
#endif /* __BSE_CONTEXT_MERGER_H__ */
diff --git a/bse/bsecore.cc b/bse/bsecore.cc
index 7580c98..41901f8 100644
--- a/bse/bsecore.cc
+++ b/bse/bsecore.cc
@@ -5,9 +5,7 @@
#include "bseengine.hh"
#include "bsesequencer.hh"
#include "bsecxxplugin.hh" /* includes bsecore.genidl.hh for us */
-
namespace Bse {
-
namespace Procedure {
ThreadTotalsHandle
collect_thread_totals::exec ()
@@ -69,15 +67,11 @@ collect_thread_totals::exec ()
g_free (t);
return tth;
}
-
} // Procedure
-
/* export definitions follow */
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ALL_TYPES_FROM_BSECORE_IDL();
-
} // Bse
-
/* compile and initialize generated C stubs */
#include "bsegencore.cc"
void
diff --git a/bse/bsecore.idl b/bse/bsecore.idl
index 1c67e06..510d6b3 100644
--- a/bse/bsecore.idl
+++ b/bse/bsecore.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
namespace Bse {
using namespace Sfi;
-
/* param options */
Const READWRITE = ":r:w:";
Const STORAGE = ":r:w:S:";
@@ -39,7 +37,6 @@ ConstIdent NOTE_A = SFI_NOTE_A;
ConstIdent NOTE_Ais = SFI_NOTE_Ais;
ConstIdent NOTE_Bes = SFI_NOTE_Bes;
ConstIdent NOTE_B = SFI_NOTE_B;
-
/* standard sequences */
sequence IntSeq {
Int ints;
@@ -47,11 +44,9 @@ sequence IntSeq {
sequence TypeSeq {
String types;
};
-
sequence StringSeq {
String strings;
};
-
/* musical tunings: http://en.wikipedia.org/wiki/Musical_tuning */
choice MusicalTuningType {
/* Equal Temperament: http://en.wikipedia.org/wiki/Equal_temperament */
@@ -128,7 +123,6 @@ choice MusicalTuningType {
"This is attempted by tuning upwards from C a sequence of six pure fourths, "
"as well as six equally imperfect fifths.")),
};
-
/* various MIDI specific definitions */
choice MidiSignalType {
/* special cased signals */
@@ -310,7 +304,6 @@ choice MidiSignalType {
MIDI_SIGNAL_CONTROL_126 = (254, _("Control 126 Monophonic Voices Mode")),
MIDI_SIGNAL_CONTROL_127 = (255, _("Control 127 Polyphonic Mode On ITrigger")),
};
-
choice MidiControlType {
/* special cased signals */
MIDI_CONTROL_NONE = (Neutral, _("None")),
@@ -479,7 +472,6 @@ choice MidiControlType {
MIDI_CONTROL_126 = (254, _("Control 126 Monophonic Voices Mode")),
MIDI_CONTROL_127 = (255, _("Control 127 Polyphonic Mode On ITrigger")),
};
-
choice MidiChannelEventType {
MIDI_EVENT_NONE = Neutral,
/* channel voice messages */
@@ -503,7 +495,6 @@ choice MidiChannelEventType {
MIDI_EVENT_ACTIVE_SENSING,
MIDI_EVENT_SYSTEM_RESET,
};
-
record MidiChannelEvent
{
MidiChannelEventType event_type;
@@ -526,18 +517,14 @@ record MidiChannelEvent
/* song select */
Int song_number = ("Song Number", "", 0, 0, 0x7f, 0x10, ":readwrite");
};
-
sequence NoteSeq {
Int notes = Note ("Note", "", KAMMER_NOTE, ":readwrite"); /* FIXME: s/notes/note/ for pspecs, but not the C API */
};
-
class Item;
-
sequence ItemSeq {
Info blurb = ("A list of BSE items or derived types.");
Item items;
};
-
record PropertyCandidates {
Info blurb = ("A strcuture describing tentative property values.");
String label;
@@ -545,7 +532,6 @@ record PropertyCandidates {
ItemSeq items;
TypeSeq partitions = ("Type Partitions", "List of types which may logically partition the list of items by type discrimination", STANDARD);
};
-
record PartNote
{
Info blurb = "Part specific note representation";
@@ -558,12 +544,10 @@ record PartNote
Real velocity = ("Velocity", "", 1, 0, 1.0, 0.1, ":readwrite");
Bool selected = ("Selected", "", FALSE, ":readwrite");
};
-
sequence PartNoteSeq {
Info blurb = "A list of part notes";
PartNote pnotes;
};
-
record PartControl
{
Info blurb = "Part specific control event representation";
@@ -573,12 +557,10 @@ record PartControl
Real value = ("Value", "", 0, -1, +1, 0.1, ":readwrite");
Bool selected = ("Selected", "", FALSE, ":readwrite");
};
-
sequence PartControlSeq {
Info blurb = "A list of part control events";
PartControl pcontrols;
};
-
record NoteDescription
{
MusicalTuningType musical_tuning;
@@ -598,13 +580,11 @@ record NoteDescription
"key values. The max_fine_tune and kammer_note fields are constants, which "
"are provided for compatibility reasons and will vanish in future APIs.";
};
-
record NoteSequence
{
Int offset = Note ("Note Offset", "Center/base note", KAMMER_NOTE, ":readwrite");
NoteSeq notes = ("Notes", "Sequence of notes", ":readwrite");
};
-
record Icon
{
Info blurb = "BSE icon representation.";
@@ -613,7 +593,6 @@ record Icon
Int height = ("Height", "Height in pixels or 0 for no icon", 0, 0, MAXINT, 1, ":readwrite");
BBlock pixels = ("Pixels", "Pixel array of width*height*bytes_per_pixel bytes", ":readwrite");
};
-
record Category
{
Int category_id = ("Category ID", NULL, 1, 1, G_MAXINT, 1, ":readwrite");
@@ -623,25 +602,20 @@ record Category
String type;
Icon icon;
};
-
sequence CategorySeq {
Category cats;
};
-
record Dot
{
Real x;
Real y;
};
-
sequence DotSeq {
Dot dots;
};
-
/* BSE Part structures */
class Part;
class Track;
-
record PartLink {
Track track;
Int tick = ("Tick", NULL, 0, 0, G_MAXINT, 384, STANDARD);
@@ -652,9 +626,7 @@ record PartLink {
sequence PartLinkSeq {
PartLink plinks;
};
-
/* BSE Track structures */
-
record TrackPart {
Int tick = ("Tick", NULL, 0, 0, G_MAXINT, 384, STANDARD);
Part part;
@@ -663,7 +635,6 @@ record TrackPart {
sequence TrackPartSeq {
TrackPart tparts;
};
-
/* BSE Song timing structure */
record SongTiming {
/* song position timing applies to */
@@ -679,7 +650,6 @@ record SongTiming {
/* playback timing */
Real stamp_ticks = ("Ticks per stamp increment (valid only during playback)", NULL, 384, 1, G_MAXINT, 12, STANDARD);
};
-
record SampleFileInfo {
String file = ("Filename", NULL, NULL, STANDARD);
Int size = ("File Size", NULL, 0, 0, G_MAXINT, 0, STANDARD);
@@ -688,9 +658,7 @@ record SampleFileInfo {
StringSeq waves = (NULL, NULL, STANDARD);
Int error = ("BseErrorType", NULL, 0, 0, G_MAXINT, 0, STANDARD); // FIXME: use BseErrorType here
};
-
class Janitor;
-
/* user messages */
choice MsgType {
MSG_NONE = Neutral,
@@ -716,7 +684,6 @@ record Message {
String process;
Int pid;
};
-
/* thread info */
choice ThreadState {
THREAD_STATE_UNKNOWN,
@@ -756,7 +723,6 @@ record ThreadTotals {
ThreadInfoSeq synthesis;
};
ThreadTotals collect_thread_totals ();
-
/* BSE Global Config */
record GConfig {
group _("Synthesis Settings") {
@@ -812,7 +778,5 @@ record GConfig {
NULL, STANDARD ":searchpath");
};
};
-
};
-
/* vim:set ts=8 sts=2 sw=2 syntax=cpp: */
diff --git a/bse/bsecsynth.cc b/bse/bsecsynth.cc
index d5531bd..30b150b 100644
--- a/bse/bsecsynth.cc
+++ b/bse/bsecsynth.cc
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecsynth.hh"
-
-
/* --- parameters --- */
enum
{
PARAM_0,
};
-
-
/* --- prototypes --- */
static void bse_csynth_class_init (BseCSynthClass *klass);
static void bse_csynth_init (BseCSynth *self);
@@ -21,12 +17,8 @@ static void bse_csynth_get_property (GObject *object,
uint param_id,
GValue *value,
GParamSpec *pspec);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseCSynth)
{
@@ -43,34 +35,27 @@ BSE_BUILTIN_TYPE (BseCSynth)
};
return bse_type_register_static (BSE_TYPE_SNET, "BseCSynth", "BSE Synthesis (Filter) Network", __FILE__, __LINE__, &type_info);
}
-
static void
bse_csynth_class_init (BseCSynthClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_csynth_set_property;
gobject_class->get_property = bse_csynth_get_property;
gobject_class->finalize = bse_csynth_finalize;
}
-
static void
bse_csynth_init (BseCSynth *self)
{
BSE_OBJECT_SET_FLAGS (self, BSE_SNET_FLAG_USER_SYNTH);
}
-
static void
bse_csynth_finalize (GObject *object)
{
// BseCSynth *csynth = BSE_CSYNTH (object);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_csynth_set_property (GObject *object,
uint param_id,
@@ -78,7 +63,6 @@ bse_csynth_set_property (GObject *object,
GParamSpec *pspec)
{
BseCSynth *self = BSE_CSYNTH (object);
-
switch (param_id)
{
default:
@@ -86,7 +70,6 @@ bse_csynth_set_property (GObject *object,
break;
}
}
-
static void
bse_csynth_get_property (GObject *object,
uint param_id,
@@ -94,7 +77,6 @@ bse_csynth_get_property (GObject *object,
GParamSpec *pspec)
{
BseCSynth *self = BSE_CSYNTH (object);
-
switch (param_id)
{
default:
diff --git a/bse/bsecsynth.hh b/bse/bsecsynth.hh
index 0f3ecaa..9293d21 100644
--- a/bse/bsecsynth.hh
+++ b/bse/bsecsynth.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CSYNTH_H__
#define __BSE_CSYNTH_H__
-
#include <bse/bsesnet.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_CSYNTH (BSE_TYPE_ID (BseCSynth))
#define BSE_CSYNTH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_CSYNTH, BseCSynth))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_CSYNTH_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_CSYNTH))
#define BSE_CSYNTH_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_CSYNTH, BseCSynthClass))
#define BSE_CSYNTH_USER_SYNTH(src) ((BSE_OBJECT_FLAGS (src) & BSE_CSYNTH_FLAG_USER_SYNTH) != 0)
-
-
/* --- BseCSynth object --- */
struct _BseCSynth
{
@@ -25,11 +20,6 @@ struct _BseCSynthClass
{
BseSNetClass parent_class;
};
-
-
/* --- prototypes --- */
-
-
G_END_DECLS
-
#endif /* __BSE_CSYNTH_H__ */
diff --git a/bse/bsecsynth.proc b/bse/bsecsynth.proc
index 47d3064..3c0f644 100644
--- a/bse/bsecsynth.proc
+++ b/bse/bsecsynth.proc
@@ -3,9 +3,5 @@
#include <bse/bseprocedure.hh>
#include <bse/bsecsynth.hh>
#include <bse/bsemain.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
diff --git a/bse/bsecxxarg.cc b/bse/bsecxxarg.cc
index 49da214..ae0fecf 100644
--- a/bse/bsecxxarg.cc
+++ b/bse/bsecxxarg.cc
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecxxarg.hh"
#include "bsecxxbase.hh"
-
namespace {
using namespace Bse;
-
} // namespace
-
-
namespace Bse {
-
const String
tokenize_gtype (GType t)
{
@@ -31,5 +26,4 @@ tokenize_gtype (GType t)
throw InvalidArgument (G_STRLOC);
}
}
-
} // Bse
diff --git a/bse/bsecxxarg.hh b/bse/bsecxxarg.hh
index 4da2291..613e355 100644
--- a/bse/bsecxxarg.hh
+++ b/bse/bsecxxarg.hh
@@ -1,17 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_ARG_H__
#define __BSE_CXX_ARG_H__
-
#include <bse/bsecxxvalue.hh>
-
/* Closure Argument implementation. For a given type, these templates
* provide a class Arg with get() and set() functions on class Value,
* and a token() function which returns a single character string to
* identify the argument type.
*/
-
namespace Bse {
-
/* default Arg type, this either supports a CxxBase* pointer or errors out */
template<typename T>
struct Arg {
@@ -44,8 +40,6 @@ private:
}
};
const String tokenize_gtype (GType t);
-
-
/* specialize Arg template for standard primitive types */
#define BSE__SPECIALIZE(TYPE, vtype, tok, GCast, SCast) \
template<> struct Arg<TYPE> { \
@@ -88,8 +82,5 @@ BSE__SPECIALIZE(BseObject*, object, "O", reinterpret_cast<BseObject*>,
BSE__SPECIALIZE(BseItem*, object, "O", reinterpret_cast<BseItem*>, reinterpret_cast<GObject*>);
BSE__SPECIALIZE(BseSource*, object, "O", reinterpret_cast<BseSource*>, reinterpret_cast<GObject*>);
#undef BSE__SPECIALIZE
-
} // Bse
-
-
#endif /* __BSE_CXX_ARG_H__ */
diff --git a/bse/bsecxxbase.cc b/bse/bsecxxbase.cc
index bd507f8..3f5d12f 100644
--- a/bse/bsecxxbase.cc
+++ b/bse/bsecxxbase.cc
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecxxbase.hh"
-
namespace Bse {
-
static void bse_cxx_base_class_base_init (gpointer g_class);
-
BSE_CXX_TYPE_REGISTER_INITIALIZED (CxxBase, "BseSource", NULL, bse_cxx_base_class_base_init, TypeRegistry::ABSTRACT);
-
static gpointer bse_cxx_base_parent_class = NULL;
-
static void
bse_cxx_base_compat_setup (BseItem *item,
guint vmajor,
@@ -16,10 +11,8 @@ bse_cxx_base_compat_setup (BseItem *item,
guint vmicro)
{
CxxBase *self = cast (item);
-
self->compat_setup (vmajor, vminor, vmicro);
}
-
static void
bse_cxx_base_restore_finish (BseObject *object,
guint vmajor,
@@ -27,72 +20,58 @@ bse_cxx_base_restore_finish (BseObject *object,
guint vmicro)
{
CxxBase *self = cast (object);
-
// chain parent class' handler
BSE_OBJECT_CLASS (bse_cxx_base_parent_class)->restore_finish (object, vmajor, vminor, vmicro);
-
// notify C++ modules about finished restoration
self->restore_finished (vmajor, vminor, vmicro);
}
-
static void
bse_cxx_base_instance_finalize (GObject *object)
{
CxxBase *self = cast (object);
-
self->~CxxBase ();
-
// chain parent class' handler
G_OBJECT_CLASS (bse_cxx_base_parent_class)->finalize (object);
}
-
static void
bse_cxx_base_class_base_init (gpointer g_class)
{
// GObjectClass *object_class = G_OBJECT_CLASS (g_class);
}
-
void
CxxBase::class_init (CxxBaseClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
BseObjectClass *bse_object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
-
bse_cxx_base_parent_class = g_type_class_peek_parent (object_class);
object_class->finalize = bse_cxx_base_instance_finalize;
bse_object_class->restore_finish = bse_cxx_base_restore_finish;
item_class->compat_setup = bse_cxx_base_compat_setup;
}
-
/*Con*/
CxxBase::CxxBase()
{}
-
void
CxxBase::set_property (guint prop_id,
const Value &value,
GParamSpec *pspec)
{}
-
void
CxxBase::get_property (guint prop_id,
Value &value,
GParamSpec *pspec)
{}
-
void
CxxBase::compat_setup (guint vmajor,
guint vminor,
guint vmicro)
{}
-
void
CxxBase::restore_finished (guint vmajor,
guint vminor,
guint vmicro)
{}
-
gulong
CxxBase::connect (const gchar *signal,
CxxClosure *closure,
@@ -110,7 +89,6 @@ CxxBase::connect (const gchar *signal,
g_closure_unref (gclosure);
return id;
}
-
#if 0
gulong
CxxBase::connect (const gchar *signal,
@@ -124,7 +102,6 @@ CxxBase::connect (const gchar *signal,
return id;
}
#endif
-
const String
CxxBase::tokenize_signal (const gchar *signal)
{
@@ -142,45 +119,38 @@ CxxBase::tokenize_signal (const gchar *signal)
s += tokenize_gtype (query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE);
return s;
}
-
GType
CxxBase::type ()
{
return G_OBJECT_TYPE (gobject());
}
-
CxxBase*
CxxBase::ref()
{
g_object_ref (gobject ());
return this;
}
-
void
CxxBase::unref()
{
g_object_unref (gobject ());
}
-
void
CxxBase::freeze_notify()
{
g_object_freeze_notify (gobject ());
}
-
void
CxxBase::notify (const gchar *property)
{
#undef g_object_notify
g_object_notify (gobject (), property);
}
-
void
CxxBase::thaw_notify()
{
g_object_thaw_notify (gobject ());
}
-
void
CxxBase::set (const gchar *first_property_name,
...)
@@ -190,7 +160,6 @@ CxxBase::set (const gchar *first_property_name,
g_object_set_valist (gobject (), first_property_name, var_args);
va_end (var_args);
}
-
void
CxxBase::get (const gchar *first_property_name,
...)
@@ -200,12 +169,10 @@ CxxBase::get (const gchar *first_property_name,
g_object_get_valist (gobject (), first_property_name, var_args);
va_end (var_args);
}
-
/*Des*/
CxxBase::~CxxBase()
{
}
-
CxxBase*
CxxBase::cast_from_gobject (void *o)
{
@@ -216,25 +183,21 @@ CxxBase::cast_from_gobject (void *o)
G_TYPE_CHECK_INSTANCE_CAST (o, BSE_TYPE_CXX_BASE, void);
return self;
}
-
void*
CxxBase::cast_to_gobject ()
{
return -BSE_CXX_INSTANCE_OFFSET + (char*) this;
}
-
GObject*
CxxBase::gobject () const
{
return (GObject*) const_cast<CxxBase*> (this)->cast_to_gobject ();
}
-
BseItem*
CxxBase::item ()
{
return (BseItem*) cast_to_gobject ();
}
-
void
CxxBaseClass::add_param (const char *group,
guint prop_id,
@@ -245,7 +208,6 @@ CxxBaseClass::add_param (const char *group,
pspec->flags = (GParamFlags) (pspec->flags | G_PARAM_CONSTRUCT);
bse_object_class_add_property ((BseObjectClass*) this, group, prop_id, pspec);
}
-
void
CxxBaseClass::add_param (guint prop_id,
GParamSpec *grouped_pspec)
@@ -255,7 +217,6 @@ CxxBaseClass::add_param (guint prop_id,
grouped_pspec->flags = (GParamFlags) (grouped_pspec->flags | G_PARAM_CONSTRUCT);
bse_object_class_add_grouped_property ((BseObjectClass*) this, prop_id, grouped_pspec);
}
-
void
CxxBaseClass::set_accessors (void (*get_property) (GObject*, guint, GValue*, GParamSpec*),
void (*set_property) (GObject*, guint, const GValue*, GParamSpec*),
@@ -273,7 +234,6 @@ CxxBaseClass::set_accessors (void (*get_property) (GObject*, guint,
BseSourceClass *source_class = BSE_SOURCE_CLASS (this);
source_class->property_updated = property_updated;
}
-
guint
CxxBaseClass::add_signal (const gchar *signal_name,
GSignalFlags flags,
@@ -282,10 +242,8 @@ CxxBaseClass::add_signal (const gchar *signal_name,
{
va_list args;
guint signal_id;
-
g_return_val_if_fail (n_params <= SFI_VMARSHAL_MAX_ARGS, 0);
g_return_val_if_fail (signal_name != NULL, 0);
-
va_start (args, n_params);
signal_id = g_signal_new_valist (signal_name,
G_TYPE_FROM_CLASS (this),
@@ -295,10 +253,8 @@ CxxBaseClass::add_signal (const gchar *signal_name,
G_TYPE_NONE,
n_params, args);
va_end (args);
-
return signal_id;
}
-
void
CxxBaseClass::add_ochannel (const char *ident,
const char *label,
@@ -309,7 +265,6 @@ CxxBaseClass::add_ochannel (const char *ident,
if (assert_id >= 0)
g_assert (assert_id == channel_id);
}
-
void
CxxBaseClass::add_ichannel (const char *ident,
const char *label,
@@ -320,7 +275,6 @@ CxxBaseClass::add_ichannel (const char *ident,
if (assert_id >= 0)
g_assert (assert_id == channel_id);
}
-
void
CxxBaseClass::add_jchannel (const char *ident,
const char *label,
@@ -331,5 +285,4 @@ CxxBaseClass::add_jchannel (const char *ident,
if (assert_id >= 0)
g_assert (assert_id == channel_id);
}
-
} // Bse
diff --git a/bse/bsecxxbase.hh b/bse/bsecxxbase.hh
index 044c63d..3831431 100644
--- a/bse/bsecxxbase.hh
+++ b/bse/bsecxxbase.hh
@@ -1,16 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_BASE_H__
#define __BSE_CXX_BASE_H__
-
#include <bse/bsesource.hh>
#include <bse/bsecxxvalue.hh>
#include <bse/bsecxxclosure.hh>
-
namespace Bse {
#define BSE_CXX_INSTANCE_OFFSET BSE_CXX_SIZEOF (BseSource)
-
#define BSE_TYPE_CXX_BASE (BSE_CXX_TYPE_GET_REGISTERED (Bse, CxxBase))
-
class CxxBaseClass : public BseSourceClass {
public:
void add_param (const char *group,
@@ -86,9 +82,7 @@ public:
guint vminor,
guint vmicro);
virtual ~CxxBase ();
-
static void class_init (CxxBaseClass *klass);
-
static inline bool instance_is_a (CxxBase *cbase,
GType iface_type)
{
@@ -100,7 +94,6 @@ public:
else
return FALSE;
}
-
template<class OType> static inline OType*
value_get_gobject (const GValue *v)
{
@@ -143,7 +136,6 @@ public:
const Casted *self = static_cast<const Casted*> (obj);
value_set_object (value, self);
}
-
class Pointer {
CxxBase *p;
public:
@@ -166,14 +158,12 @@ public:
static inline CxxBase::Pointer cast (CxxBase *c) { return CxxBase::Pointer (c); }
/* match from-GObject* casts: */
template<class T> CxxBase* cast (T *t) { return CxxBase::cast (t); }
-
/* --- trampoline templates --- */
template<class ObjectType> static void
cxx_class_init_trampoline (CxxBaseClass *klass)
{
ObjectType::class_init (klass);
}
-
template<class ObjectType> static void
cxx_instance_init_trampoline (GTypeInstance *instance,
gpointer g_class)
@@ -181,7 +171,6 @@ cxx_instance_init_trampoline (GTypeInstance *instance,
if (G_TYPE_FROM_INSTANCE (instance) == G_TYPE_FROM_CLASS (g_class))
new (BSE_CXX_INSTANCE_OFFSET + (char*) instance) ObjectType ();
}
-
template<class ObjectType, typename PropertyID> static void
cxx_get_property_trampoline (GObject *o,
guint prop_id,
@@ -195,7 +184,6 @@ cxx_get_property_trampoline (GObject *o,
(void) static_cast<void (ObjectType::*) (PropertyID, Value&, GParamSpec*)> (&ObjectType::get_property);
instance->get_property (static_cast<PropertyID> (prop_id), *v, pspec);
}
-
template<class ObjectType, typename PropertyID> static void
cxx_set_property_trampoline (GObject *o,
guint prop_id,
@@ -209,7 +197,6 @@ cxx_set_property_trampoline (GObject *o,
(void) static_cast<void (ObjectType::*) (PropertyID, const Value&, GParamSpec*)> (&ObjectType::set_property);
instance->set_property (static_cast<PropertyID> (prop_id), *v, pspec);
}
-
template<class ObjectType, typename PropertyID> static gboolean
cxx_editable_property_trampoline (BseObject *o,
guint prop_id,
@@ -221,13 +208,11 @@ cxx_editable_property_trampoline (BseObject *o,
(void) static_cast<bool (ObjectType::*) (PropertyID, GParamSpec*)> (&ObjectType::editable_property);
return instance->editable_property (static_cast<PropertyID> (prop_id), pspec);
}
-
template<class ObjectType, typename PropertyID> static void
cxx_get_candidates_trampoline (BseItem *item,
guint prop_id,
BsePropertyCandidates *pc,
GParamSpec *pspec); /* defined in bsecxxplugin.hh */
-
template<class ObjectType, typename PropertyID> static void
cxx_property_updated_trampoline (BseSource *source,
guint prop_id,
@@ -241,8 +226,5 @@ cxx_property_updated_trampoline (BseSource *source,
(void) static_cast<void (ObjectType::*) (PropertyID, guint64, double, GParamSpec*)> (&ObjectType::property_updated);
instance->property_updated (static_cast<PropertyID> (prop_id), tick_stamp, prop_value, pspec);
}
-
} // Bse
-
-
#endif /* __BSE_CXX_BASE_H__ */
diff --git a/bse/bsecxxbase.idl b/bse/bsecxxbase.idl
index ad4f626..96a5ed4 100644
--- a/bse/bsecxxbase.idl
+++ b/bse/bsecxxbase.idl
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bsecore.idl>
namespace Bse { // FIXME: bad workarounds
class Source;
}
-
namespace Bse {
-
class CxxBase : Source {
// Implementation fully manual
};
-
} // Bse
diff --git a/bse/bsecxxclosure.cc b/bse/bsecxxclosure.cc
index 90008cb..b5bf3ed 100644
--- a/bse/bsecxxclosure.cc
+++ b/bse/bsecxxclosure.cc
@@ -1,28 +1,21 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#if defined BSE_COMPILATION
#include "bsecxxclosure.hh"
-
namespace Bse {
-
CxxClosure::CxxClosure()
: glib_closure (NULL), sig_tokens ()
{
}
-
CxxClosure::~CxxClosure()
{
}
-
GClosure*
CxxClosure::gclosure()
{
return glib_closure;
}
-
} // Bse
-
#else /* !BSE_COMPILATION */ // program to generate bsegenclosures.hh
-
#include <string>
#include <stdio.h>
using namespace std;
@@ -33,7 +26,6 @@ String (long long int i)
sprintf (buf, "%lld", i);
return string (buf);
}
-
void
print_closure (bool withreturn,
int n_args)
@@ -115,7 +107,6 @@ print_closure (bool withreturn,
printf (" return new %s%uClosure<%s> (t, f);\n", rpref, n_args, tmplargs);
printf ("}\n");
}
-
int
main (int argc,
char *argv[])
diff --git a/bse/bsecxxclosure.hh b/bse/bsecxxclosure.hh
index 86e95ac..49c9f7b 100644
--- a/bse/bsecxxclosure.hh
+++ b/bse/bsecxxclosure.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_CLOSURE_H__
#define __BSE_CXX_CLOSURE_H__
-
#include <bse/bsecxxvalue.hh>
#include <bse/bsecxxarg.hh>
-
namespace Bse {
-
class CxxClosure {
GClosure *glib_closure;
CxxClosure& operator= (const CxxClosure &c);
@@ -23,10 +20,7 @@ public:
GClosure* gclosure ();
const String signature () { return sig_tokens; }
};
-
/* include generated CxxClosure* Closure (class T*, ... (T::*f) (...)); constructors */
#include <bse/bsegenclosures.hh>
-
} // Bse
-
#endif /* __BSE_CXX_CLOSURE_H__ */
diff --git a/bse/bsecxxmodule.cc b/bse/bsecxxmodule.cc
index 90b0a9a..2c768cb 100644
--- a/bse/bsecxxmodule.cc
+++ b/bse/bsecxxmodule.cc
@@ -3,31 +3,25 @@
#include "bseengine.hh"
#include "bsemidireceiver.hh"
#include "bsesnet.hh"
-
namespace Bse {
-
static const ClassInfo class_info (NULL, "BseEffect implements an abstract C++ effect base.", __FILE__, __LINE__);
BSE_CXX_TYPE_REGISTER_ABSTRACT (Effect, "BseCxxBase", &class_info);
-
Effect::Effect() :
last_module_update (0)
{
}
-
void
Effect::set_property (guint prop_id,
const Value &value,
GParamSpec *pspec)
{
}
-
void
Effect::get_property (guint prop_id,
Value &value,
GParamSpec *pspec)
{
}
-
static void
access_trampoline (BseModule *module,
gpointer data)
@@ -36,14 +30,12 @@ access_trampoline (BseModule *module,
SynthesisModule *m = static_cast<SynthesisModule*> (module->user_data);
(*clo) (m);
}
-
static void
access_data_free (gpointer data)
{
SynthesisModule::Closure *clo = static_cast<SynthesisModule::Closure*> (data);
delete clo;
}
-
void
Effect::update_modules (BseTrans *trans)
{
@@ -60,20 +52,16 @@ Effect::update_modules (BseTrans *trans)
}
}
}
-
SynthesisModule::SynthesisModule()
{
intern_module = NULL;
}
-
void
SynthesisModule::set_module (BseModule *engine_module)
{
g_return_if_fail (intern_module == NULL);
g_return_if_fail (engine_module != NULL);
-
intern_module = engine_module;
-
/* assert validity of the above casts */
BIRNET_STATIC_ASSERT (sizeof (JStream) == sizeof (BseJStream));
BIRNET_STATIC_ASSERT (offsetof (JStream, values) == offsetof (BseJStream, values));
@@ -82,20 +70,17 @@ SynthesisModule::set_module (BseModule *engine_module)
BIRNET_STATIC_ASSERT (sizeof (((JStream*)0)->n_connections) == sizeof (((BseJStream*)0)->n_connections));
BIRNET_STATIC_ASSERT (offsetof (JStream, jcount) == offsetof (BseJStream, jcount));
BIRNET_STATIC_ASSERT (sizeof (((JStream*)0)->jcount) == sizeof (((BseJStream*)0)->jcount));
-
BIRNET_STATIC_ASSERT (sizeof (IStream) == sizeof (BseIStream));
BIRNET_STATIC_ASSERT (offsetof (IStream, values) == offsetof (BseIStream, values));
BIRNET_STATIC_ASSERT (sizeof (((IStream*)0)->values) == sizeof (((BseIStream*)0)->values));
BIRNET_STATIC_ASSERT (offsetof (IStream, connected) == offsetof (BseIStream, connected));
BIRNET_STATIC_ASSERT (sizeof (((IStream*)0)->connected) == sizeof (((BseIStream*)0)->connected));
-
BIRNET_STATIC_ASSERT (sizeof (OStream) == sizeof (BseOStream));
BIRNET_STATIC_ASSERT (offsetof (OStream, values) == offsetof (BseOStream, values));
BIRNET_STATIC_ASSERT (sizeof (((OStream*)0)->values) == sizeof (((BseOStream*)0)->values));
BIRNET_STATIC_ASSERT (offsetof (OStream, connected) == offsetof (BseOStream, connected));
BIRNET_STATIC_ASSERT (sizeof (((OStream*)0)->connected) == sizeof (((BseOStream*)0)->connected));
}
-
void
SynthesisModule::ostream_set (uint ostream_index,
const float *values)
@@ -103,23 +88,19 @@ SynthesisModule::ostream_set (uint ostream_index,
BseModule *m = engine_module();
m->ostreams[ostream_index].values = const_cast<float*> (values);
}
-
const float*
SynthesisModule::const_values (float value)
{
return bse_engine_const_values (value);
}
-
SynthesisModule::~SynthesisModule()
{
}
-
const ProcessCost
SynthesisModule::cost()
{
return NORMAL;
}
-
static void
process_module (BseModule *engine_module,
guint n_values)
@@ -127,14 +108,12 @@ process_module (BseModule *engine_module,
SynthesisModule *m = static_cast<SynthesisModule*> (engine_module->user_data);
m->process (n_values);
}
-
static void
reset_module (BseModule *engine_module)
{
SynthesisModule *m = static_cast<SynthesisModule*> (engine_module->user_data);
m->reset();
}
-
static void
delete_module (gpointer data,
const BseModuleClass *klass)
@@ -142,7 +121,6 @@ delete_module (gpointer data,
SynthesisModule *m = static_cast<SynthesisModule*> (data);
delete m;
}
-
static BseCostType
module_flags_from_process_cost (ProcessCost cost)
{
@@ -154,7 +132,6 @@ module_flags_from_process_cost (ProcessCost cost)
case NORMAL: return BSE_COST_NORMAL;
}
}
-
const BseModuleClass*
Effect::create_engine_class (SynthesisModule *sample_module,
int cost,
@@ -185,7 +162,6 @@ Effect::create_engine_class (SynthesisModule *sample_module,
}
return source_class->engine_class;
}
-
struct HandlerData {
SynthesisModule::AutoUpdate auto_update;
double minimum, maximum;
@@ -206,7 +182,6 @@ struct HandlerData {
delete hd;
}
};
-
static void
auto_update_data_free (gpointer data) /* UserThread */
{
@@ -224,7 +199,6 @@ auto_update_data_free (gpointer data) /* UserThread */
}
delete adata;
}
-
static void
midi_control_handler (gpointer handler_data, /* MIDI Device Thread (and possibly others) */
guint64 tick_stamp,
@@ -257,7 +231,6 @@ midi_control_handler (gpointer handler_data, /* MIDI Device Th
adata,
i + 1 >= n_mcdatas ? auto_update_data_free : NULL));
}
-
static void
get_midi_control_range (GParamSpec *pspec,
double &minimum,
@@ -289,7 +262,6 @@ get_midi_control_range (GParamSpec *pspec,
maximum = nspec->maximum;
}
}
-
struct HandlerSetup {
Effect *effect;
bool add_handler;
@@ -305,7 +277,6 @@ struct HandlerSetup {
g_free (hs);
}
};
-
static void
handler_setup_func (BseModule *module, /* Engine Thread */
gpointer data)
@@ -343,7 +314,6 @@ handler_setup_func (BseModule *module, /* Engine Thread */
hs->aprops[i].pspec,
module);
}
-
BseModule*
Effect::integrate_engine_module (uint context_handle,
BseTrans *trans)
@@ -371,7 +341,6 @@ Effect::integrate_engine_module (uint context_handle,
}
return engine_module;
}
-
void
Effect::dismiss_engine_module (BseModule *engine_module,
guint context_handle,
@@ -399,28 +368,23 @@ Effect::dismiss_engine_module (BseModule *engine_module,
bse_trans_add (trans, bse_job_discard (engine_module));
}
}
-
uint
Effect::block_size() const
{
g_return_val_if_fail (is_prepared(), 0);
-
return bse_engine_block_size();
}
-
uint
Effect::max_block_size() const
{
return BSE_STREAM_MAX_VALUES;
}
-
BseMusicalTuningType
Effect::current_musical_tuning() const
{
BseSource *source = cast (const_cast <Effect*> (this));
return bse_item_current_musical_tuning (BSE_ITEM (source));
}
-
void
Effect::class_init (CxxBaseClass *klass)
{
@@ -435,17 +399,14 @@ Effect::class_init (CxxBaseClass *klass)
CxxBase *base = cast (source);
Effect *self = static_cast<Effect*> (base);
BseModule *engine_module = self->integrate_engine_module (context_handle, trans);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, engine_module);
-
/* reset module */
bse_trans_add (trans, bse_job_force_reset (engine_module));
/* configure module */
SynthesisModule::Closure *clo = self->make_module_config_closure();
if (clo)
bse_trans_add (trans, bse_job_access (engine_module, access_trampoline, clo, access_data_free));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (effect_parent_class)->context_create (source, context_handle, trans);
}
@@ -467,9 +428,7 @@ Effect::class_init (CxxBaseClass *klass)
engine_module = bse_source_get_context_omodule (source, context_handle);
bse_source_set_context_omodule (source, context_handle, NULL);
}
-
self->dismiss_engine_module (engine_module, context_handle, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (effect_parent_class)->context_dismiss (source, context_handle, trans);
}
@@ -477,13 +436,10 @@ Effect::class_init (CxxBaseClass *klass)
{
CxxBase *base = cast (source);
Effect *self = static_cast<Effect*> (base);
-
/* invoke code that the effect might want to execute before prepare */
self->prepare1();
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (effect_parent_class)->prepare (source);
-
/* invoke code that the effect might want to execute after prepare */
self->prepare2();
}
@@ -491,24 +447,19 @@ Effect::class_init (CxxBaseClass *klass)
{
CxxBase *base = cast (source);
Effect *self = static_cast<Effect*> (base);
-
/* invoke code that the effect might want to execute before reset */
self->reset1();
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (effect_parent_class)->reset (source);
-
/* invoke code that the effect might want to execute after reset */
self->reset2();
}
};
BseSourceClass *source_class = klass;
-
effect_parent_class = g_type_class_peek_parent (klass);
source_class->context_create = Trampoline::effect_context_create;
source_class->context_dismiss = Trampoline::effect_context_dismiss;
source_class->prepare = Trampoline::effect_prepare;
source_class->reset = Trampoline::effect_reset;
}
-
} // Bse
diff --git a/bse/bsecxxmodule.hh b/bse/bsecxxmodule.hh
index 19b37f0..2a9aecc 100644
--- a/bse/bsecxxmodule.hh
+++ b/bse/bsecxxmodule.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_MODULE_H__
#define __BSE_CXX_MODULE_H__
-
#include <bse/bsecxxbase.hh>
#include <bse/bseieee754.hh>
-
namespace Bse {
-
/* enums/structures mirrored from bseengine.hh */
enum ProcessCost {
NORMAL,
@@ -27,9 +24,7 @@ struct OStream {
float *values;
gboolean connected;
};
-
class Effect;
-
class SynthesisModule {
template<class T, typename P> class ClosureP1; /* 1-argument member function closure */
BseModule *intern_module;
@@ -86,7 +81,6 @@ protected:
static void auto_update_accessor (BseModule*, gpointer);
};
};
-
#define BSE_TYPE_EFFECT (BSE_CXX_TYPE_GET_REGISTERED (Bse, Effect))
class EffectBase : public CxxBase {};
class Effect : public EffectBase {
@@ -129,7 +123,6 @@ public:
virtual void prepare2() { /* override this to do something after parent class prepare */ }
virtual void reset1() { /* override this to do something before parent class dismiss */ }
virtual void reset2() { /* override this to do something after parent class dismiss */ }
-
static void class_init (CxxBaseClass *klass);
protected:
const BseModuleClass* create_engine_class (SynthesisModule *sample_module,
@@ -189,8 +182,6 @@ auto_update_accessor (BseModule *bmodule,
gpointer data)
{
}
-
-
/* --- implementation details --- */
namespace externC { extern "C" {
extern guint bse_engine_exvar_sample_freq;
@@ -264,7 +255,5 @@ SynthesisModule::make_closure (void (C::*method) (D*),
ClosureP1<C,D> *ac = new ClosureP1<C,D> (method, d);
return ac;
}
-
} // Bse
-
#endif /* __BSE_CXX_MODULE_H__ */
diff --git a/bse/bsecxxmodule.idl b/bse/bsecxxmodule.idl
index b3c816e..193cf9c 100644
--- a/bse/bsecxxmodule.idl
+++ b/bse/bsecxxmodule.idl
@@ -1,11 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bsecxxbase.idl>
-
namespace Bse {
-
class Effect : CxxBase {
// Implementation fully manual
};
-
} // Bse
diff --git a/bse/bsecxxplugin.cc b/bse/bsecxxplugin.cc
index 64b4656..b3b435d 100644
--- a/bse/bsecxxplugin.cc
+++ b/bse/bsecxxplugin.cc
@@ -3,9 +3,7 @@
#include "bseplugin.hh"
#include "bsemain.hh"
#include <new>
-
namespace Bse {
-
BsePlugin*
ExportTypeKeeper::plugin_export_node (const ::BseExportIdentity *plugin_identity,
::BseExportNode *enode)
@@ -20,12 +18,10 @@ ExportTypeKeeper::plugin_export_node (const ::BseExportIdentity *plugin_identity
else
return bse_exports__add_node (plugin_identity, enode);
}
-
void
ExportTypeKeeper::plugin_cleanup (BsePlugin *plugin,
::BseExportNode *enode)
{
bse_exports__del_node (plugin, enode);
}
-
} // Bse
diff --git a/bse/bsecxxplugin.hh b/bse/bsecxxplugin.hh
index a19a355..5283fa9 100644
--- a/bse/bsecxxplugin.hh
+++ b/bse/bsecxxplugin.hh
@@ -1,24 +1,19 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_PLUGIN_H__
#define __BSE_CXX_PLUGIN_H__
-
#include <bse/bsecxxmodule.hh>
#include <bse/bseexports.hh>
#include <bse/bseparam.hh>
#include <bse/bsecategories.hh>
#include <bse/bseplugin.hh>
#include <sfi/sficxx.hh>
-
namespace Bse {
-
/* --- frequently used constants --- */
const SfiInt KAMMER_NOTE = SFI_KAMMER_NOTE;
const SfiInt KAMMER_OCTAVE = SFI_KAMMER_OCTAVE;
const SfiReal KAMMER_FREQ = BSE_KAMMER_FREQUENCY;
const SfiInt MIN_FINE_TUNE = BSE_MIN_FINE_TUNE;
const SfiInt MAX_FINE_TUNE = BSE_MAX_FINE_TUNE;
-
-
/* -- export identity --- */
/* provide plugin export identity, preceeding all type exports */
#ifndef BSE_COMPILATION
@@ -32,7 +27,6 @@ extern "C" {
extern ::BseExportIdentity bse_builtin_export_identity; /* sync with bseplugin.hh */
};
#endif
-
// == Resident Type Plugin Registration ==
#define BSE_RESIDENT_TYPE_DEF(Object, func, anc, category, blurb, icon) \
static GType func##_get_type () { \
@@ -62,7 +56,6 @@ extern ::BseExportIdentity bse_builtin_export_identity; /* sync with bseplugin.h
} static Sfi::Init func##__onload_ (func##__onload);
#define BSE_RESIDENT_SOURCE_DEF(Object, func, category, blurb, icon) \
BSE_RESIDENT_TYPE_DEF(Object, func, BSE_TYPE_SOURCE, category, blurb, icon)
-
/* --- hook registration --- */
/* hook registration is based on a static ExportTypeKeeper
* object, which provides the hook's get_type() implementation and
@@ -97,7 +90,6 @@ extern ::BseExportIdentity bse_builtin_export_identity; /* sync with bseplugin.h
::Bse::ExportTypeKeeper \
bse_type_keeper__7##HookType (bse_export_node<HookType>, \
BSE_CXX_EXPORT_IDENTITY);
-
/* --- enum registration --- */
/* enum registration is based on a static ExportTypeKeeper
* object, which provides the enum's get_type() implementation and
@@ -151,7 +143,6 @@ EnumValue (int int_value,
value.value_nick = const_cast<char*> (value_nick);
return value;
}
-
/* --- record registration --- */
/* record registration is based on a static ExportTypeKeeper
* object, which provides the record's get_type() implementation and
@@ -189,8 +180,6 @@ EnumValue (int int_value,
::Bse::ExportTypeKeeper \
bse_type_keeper__1##RecordType (bse_export_node<RecordType>, \
BSE_CXX_EXPORT_IDENTITY);
-
-
/* --- sequence registration --- */
/* sequence registration works similar to record registration */
#define BSE_CXX_DECLARED_SEQUENCE_TYPE(NameSpace,SequenceType) \
@@ -225,8 +214,6 @@ EnumValue (int int_value,
::Bse::ExportTypeKeeper \
bse_type_keeper__2##SequenceType (bse_export_node<SequenceType>, \
BSE_CXX_EXPORT_IDENTITY);
-
-
/* --- procedure registration --- */
/* procedure registration works similar to enum registration. */
#define BSE_CXX_DECLARED_PROC_TYPE(NameSpace,ProcType) \
@@ -260,8 +247,6 @@ EnumValue (int int_value,
::Bse::ExportTypeKeeper \
bse_type_keeper__9##ProcType (bse_export_node<Procedure::ProcType>, \
BSE_CXX_EXPORT_IDENTITY);
-
-
/* --- class registration --- */
/* class registration works similar to enum registration.
* in addition, we need to define a couple trampoline functions to make
@@ -308,8 +293,6 @@ EnumValue (int int_value,
/* implement static_data portions used by auto-generated classes */
#define BSE_CXX_DEFINE_STATIC_DATA(ObjectType) \
ObjectType::StaticData ObjectType::static_data;
-
-
/* --- type keeper for export nodes --- */
class ExportTypeKeeper
{
@@ -334,15 +317,11 @@ public:
}
const GType get_type() { return enode->type; }
};
-
} // Bse
-
/* include generated C++ core types */
#include <bse/bsecore.genidl.hh> /* includes bsecxxplugin.hh itself */
-
/* define types dependant on bsecore.idl */
namespace Bse {
-
/* --- trampoline templates --- */
template<class ObjectType, typename PropertyID> static void
cxx_get_candidates_trampoline (BseItem *item,
@@ -362,7 +341,5 @@ cxx_get_candidates_trampoline (BseItem *item,
if (cxxpc)
pch.steal(); /* steal to avoid destruction */
}
-
} // Bse
-
#endif /* __BSE_CXX_PLUGIN_H__ */
diff --git a/bse/bsecxxutils.cc b/bse/bsecxxutils.cc
index d3d9276..85779c9 100644
--- a/bse/bsecxxutils.cc
+++ b/bse/bsecxxutils.cc
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecxxutils.hh"
-
#include "bsecxxbase.hh"
#include "bsecategories.hh"
#include <list>
using namespace std;
-
namespace Bse {
-
/* --- functions --- */
struct TypeRegistry::TypeEntry {
guint instance_size;
@@ -39,9 +36,7 @@ struct TypeRegistry::TypeEntry {
this->flags = flags;
}
};
-
static list<TypeRegistry::TypeEntry> *type_entries = NULL;
-
TypeRegistry::TypeRegistry (guint instance_size,
const gchar *name,
const gchar *parent,
@@ -56,10 +51,8 @@ TypeRegistry::TypeRegistry (guint instance_size,
(GClassInitFunc) class_init,
iinit, flags);
entry.reg = this;
-
if (!type_entries)
type_entries = new list<TypeEntry>();
-
list<TypeEntry>::iterator li;
for (li = type_entries->begin(); li != type_entries->end(); li++)
if (strcmp (li->name, parent) == 0)
@@ -69,7 +62,6 @@ TypeRegistry::TypeRegistry (guint instance_size,
else // parent not found in list
type_entries->push_front (entry);
}
-
void
TypeRegistry::init_types()
{
@@ -77,7 +69,6 @@ TypeRegistry::init_types()
{
TypeRegistry *self = li->reg;
GTypeInfo info = { 0, };
-
info.class_size = BSE_CXX_COMMON_CLASS_SIZE;
info.base_init = li->binit;
info.class_init = li->cinit;
@@ -96,7 +87,6 @@ TypeRegistry::init_types()
delete type_entries;
type_entries = NULL;
}
-
static void
bse_terminate_handler ()
{
@@ -113,7 +103,6 @@ bse_terminate_handler ()
g_error ("aborting due to uncaught exception");
}
}
-
static void
init_exception_handler ()
{
@@ -125,12 +114,10 @@ init_exception_handler ()
set_terminate (bse_terminate_handler);
#endif
}
-
extern "C" void
bse_cxx_init (void) // prototyped in bseutils.hh
{
init_exception_handler ();
Bse::TypeRegistry::init_types();
}
-
} // Bse
diff --git a/bse/bsecxxutils.hh b/bse/bsecxxutils.hh
index 6aa8d07..fbb6c2d 100644
--- a/bse/bsecxxutils.hh
+++ b/bse/bsecxxutils.hh
@@ -1,14 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_UTILS_H__
#define __BSE_CXX_UTILS_H__
-
#include <bse/bseutils.hh>
#include <sfi/sficxx.hh>
#include <vector>
#include <algorithm>
-
namespace Bse {
-
/* --- Procedure namespace work arounds --- */
namespace Procedure {
typedef SfiBool Bool;
@@ -25,11 +22,8 @@ typedef SfiSeq Seq;
typedef SfiRec Rec;
typedef SfiProxy Proxy;
};
-
/* --- type alias frequently used standard lib things --- */
typedef std::string String;
-
-
/* --- generally useful templates --- */
template<class Data> static void
delete_this (Data *d)
@@ -60,8 +54,6 @@ assert_derived_from (void)
{
EnforceDerivedFrom<Derived, Base> assertion;
}
-
-
/* --- exceptions --- */
struct Exception : std::exception {
explicit Exception (const char *_where) : loc (_where) {};
@@ -87,7 +79,6 @@ struct InvalidConnection : Exception {
InvalidConnection (const char *where) : Exception (where) {};
const char* what() const throw() { return "Function to be connected has invalid signature"; }
};
-
/* --- records & sequences --- */
class Record {
Record& operator= (const Record&);
@@ -97,14 +88,11 @@ public:
virtual SfiRec* to_rec ();
virtual ~Record ();
};
-
-
/* --- class registration --- */
#define BSE_CXX_TYPE_REGISTER(ObjectType, parent, class_info) \
BSE_CXX_TYPE_REGISTER_INITIALIZED (ObjectType, parent, class_info, NULL, TypeRegistry::NONE)
#define BSE_CXX_TYPE_REGISTER_ABSTRACT(ObjectType, parent, class_info) \
BSE_CXX_TYPE_REGISTER_INTERN (ObjectType, parent, class_info, NULL, NULL, TypeRegistry::ABSTRACT)
-
/* --- class information --- */
struct ClassInfo
{
@@ -123,8 +111,6 @@ struct ClassInfo
this->line = line;
}
};
-
-
/* --- type registration internals --- */
struct CxxBaseClass;
class TypeRegistry
@@ -152,7 +138,6 @@ public:
init_types ();
struct TypeEntry;
};
-
template<class C> const GType
bse_type_id_wrapper (const char *type_name)
{
@@ -164,7 +149,6 @@ bse_type_id_wrapper (const char *type_name)
}
return type;
}
-
#define BSE_CXX_TYPE_GET_REGISTERED(NameSpace, ObjectType) \
(::Bse::bse_type_id_wrapper<ObjectType> (#NameSpace #ObjectType))
#define BSE_CXX_TYPE_REGISTER_INITIALIZED(ObjectType, parent, cinfo, binit, flags) \
@@ -180,7 +164,5 @@ bse_type_id_wrapper (const char *type_name)
#define BSE_CXX_UTILS_ALIGN(offset) ((offset + BSE_CXX_UTILS_ALIGNMENT - 1) & -BSE_CXX_UTILS_ALIGNMENT)
#define BSE_CXX_SIZEOF(Class) BSE_CXX_UTILS_ALIGN (sizeof (Class))
#define BSE_CXX_COMMON_CLASS_SIZE sizeof (CxxBaseClass)
-
} // Bse
-
#endif /* __BSE_CXX_UTILS_H__ */
diff --git a/bse/bsecxxvalue.cc b/bse/bsecxxvalue.cc
index e50b83d..950e03d 100644
--- a/bse/bsecxxvalue.cc
+++ b/bse/bsecxxvalue.cc
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecxxvalue.hh"
#include "bsecxxbase.hh"
-
namespace Bse {
-
SfiNum
Value::get_num () const
{
@@ -21,7 +19,6 @@ Value::get_num () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
SfiReal
Value::get_real () const
{
@@ -35,7 +32,6 @@ Value::get_real () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
const char*
Value::get_string () const
{
@@ -47,7 +43,6 @@ Value::get_string () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
gpointer
Value::get_pointer () const
{
@@ -57,7 +52,6 @@ Value::get_pointer () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
CxxBase*
Value::get_base () const
{
@@ -72,7 +66,6 @@ Value::get_base () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
GObject*
Value::get_object () const
{
@@ -82,7 +75,6 @@ Value::get_object () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
GParamSpec*
Value::get_pspec () const
{
@@ -92,7 +84,6 @@ Value::get_pspec () const
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_num (SfiNum n)
{
@@ -110,7 +101,6 @@ Value::set_num (SfiNum n)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_real (SfiReal r)
{
@@ -124,7 +114,6 @@ Value::set_real (SfiReal r)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_string (const char *s)
{
@@ -136,7 +125,6 @@ Value::set_string (const char *s)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_pointer (gpointer p)
{
@@ -146,7 +134,6 @@ Value::set_pointer (gpointer p)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_base (CxxBase *b)
{
@@ -161,7 +148,6 @@ Value::set_base (CxxBase *b)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_object (GObject *o)
{
@@ -171,7 +157,6 @@ Value::set_object (GObject *o)
else
throw WrongTypeGValue (G_STRLOC);
}
-
void
Value::set_pspec (GParamSpec *p)
{
@@ -181,5 +166,4 @@ Value::set_pspec (GParamSpec *p)
else
throw WrongTypeGValue (G_STRLOC);
}
-
} // Bse
diff --git a/bse/bsecxxvalue.hh b/bse/bsecxxvalue.hh
index 6d37093..b61ac3e 100644
--- a/bse/bsecxxvalue.hh
+++ b/bse/bsecxxvalue.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_CXX_VALUE_H__
#define __BSE_CXX_VALUE_H__
-
#include <bse/bsecxxutils.hh>
-
namespace Bse {
-
class CxxBase; // prototype CxxBase since we deal with pointers thereof
-
/* Generic Value keeping, basically a convenient wrapper around GValue */
-
struct Value : GValue {
bool get_bool () const { return get_num(); }
SfiInt get_int () const { return get_num(); }
@@ -41,8 +36,5 @@ struct Value : GValue {
void operator= (SfiReal r) { set_real (r); }
void operator= (const String &s) { set_string (s.c_str()); }
};
-
} // Bse
-
-
#endif /* __BSE_CXX_VALUE_H__ */
diff --git a/bse/bsedatahandle-fir.cc b/bse/bsedatahandle-fir.cc
index ec36e5e..15cefb8 100644
--- a/bse/bsedatahandle-fir.cc
+++ b/bse/bsedatahandle-fir.cc
@@ -8,21 +8,16 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
-
namespace Bse {
-
using std::vector;
using std::min;
typedef std::complex<double> Complex;
-
class DataHandleFir;
-
struct CDataHandleFir : public GslDataHandle
{
// back pointer to get casting right, even in presence of C++ vtable:
DataHandleFir* cxx_dh;
};
-
class DataHandleFir {
protected:
CDataHandleFir m_dhandle;
@@ -33,11 +28,9 @@ protected:
int64 m_block_size;
int64 m_history;
bool m_init_ok;
-
protected:
virtual void
design_filter_coefficients (double mix_freq) = 0;
-
public:
DataHandleFir (GslDataHandle *src_handle,
guint order) :
@@ -46,13 +39,11 @@ public:
m_init_ok (false)
{
g_return_if_fail (src_handle != NULL);
-
memset (&m_dhandle, 0, sizeof (m_dhandle));
m_init_ok = gsl_data_handle_common_init (&m_dhandle, NULL);
if (m_init_ok)
gsl_data_handle_ref (m_src_handle);
}
-
/* protected destructor: (use reference counting instead) */
virtual
~DataHandleFir()
@@ -63,38 +54,31 @@ public:
gsl_data_handle_common_free (&m_dhandle);
}
}
-
BseErrorType
open (GslDataHandleSetup *setup)
{
BseErrorType error = gsl_data_handle_open (m_src_handle);
if (error != BSE_ERROR_NONE)
return error;
-
/* !not! m_dhandle.setup; the framework magically ensures that *m_dhandle.setup
* is initialized by whatever we write into *setup if open is successful
*/
*setup = m_src_handle->setup; /* copies setup.xinfos by pointer */
setup->bit_depth = 32; /* possibly increased by filtering */
-
// since we need overlapping data for consecutive reads we buffer data locally
m_block_size = 1024 * m_src_handle->setup.n_channels;
m_history = ((m_a.size() + 1) / 2) * m_src_handle->setup.n_channels;
m_input_data.resize (m_block_size + 2 * m_history);
m_input_voffset = -2 * m_block_size;
-
design_filter_coefficients (gsl_data_handle_mix_freq (m_src_handle));
-
return BSE_ERROR_NONE;
}
-
void
close()
{
m_dhandle.setup.xinfos = NULL; /* cleanup pointer reference */
gsl_data_handle_close (m_src_handle);
}
-
void
fir_apply (guint voffset,
const guint n_samples,
@@ -103,7 +87,6 @@ public:
const guint channels = m_dhandle.setup.n_channels;
const guint iorder = m_a.size();
voffset += m_history - (iorder / 2) * channels;
-
for (guint i = 0; i < n_samples; i++)
{
gdouble accu = 0;
@@ -116,13 +99,11 @@ public:
*dest++ = accu;
}
}
-
int64
seek (int64 voffset)
{
int64 i = 0;
g_return_val_if_fail (voffset % m_block_size == 0, -1);
-
// if this is a consecutive read, the history can be built from the values
// we already read last time
if (m_input_voffset == voffset - m_block_size)
@@ -131,7 +112,6 @@ public:
Block::copy (overlap_values, &m_input_data[0], &m_input_data[m_input_data.size() - overlap_values]);
i += overlap_values;
}
-
while (i < static_cast<int64> (m_input_data.size()))
{
int64 offset = voffset + i - m_history;
@@ -158,7 +138,6 @@ public:
m_input_voffset = voffset;
return 0;
}
-
int64
read (int64 voffset,
int64 n_values,
@@ -166,38 +145,31 @@ public:
{
int64 ivoffset = voffset;
ivoffset -= ivoffset % m_block_size;
-
if (ivoffset != m_input_voffset)
{
int64 l = seek (ivoffset);
if (l < 0) // pass on errors
return l;
}
-
g_assert (ivoffset == m_input_voffset);
-
voffset -= ivoffset;
n_values = min (n_values, m_block_size - voffset);
fir_apply (voffset, n_values, values);
return n_values;
}
-
int64
get_state_length() const
{
int64 source_state_length = gsl_data_handle_get_state_length (m_src_handle);
// m_src_handle must be opened and have valid state size
g_return_val_if_fail (source_state_length >= 0, 0);
-
return source_state_length + m_history;
}
-
gdouble
compute_fir_response_db (double freq) const
{
Complex z = std::exp (Complex (0, freq * 2 * PI / gsl_data_handle_mix_freq (m_src_handle)));
Complex r = 0;
-
for (guint i = 0; i < m_a.size(); i++)
{
r /= z;
@@ -205,7 +177,6 @@ public:
}
return bse_db_from_factor (abs (r), -200);
}
-
static GslDataHandle*
dh_create (DataHandleFir *cxx_dh)
{
@@ -218,7 +189,6 @@ public:
dh_get_state_length,
dh_destroy,
};
-
if (cxx_dh->m_init_ok)
{
cxx_dh->m_dhandle.vtable = &dh_vtable;
@@ -267,12 +237,10 @@ private:
return dh_cast (dhandle)->get_state_length();
}
};
-
class DataHandleFirHighpass : public DataHandleFir
{
protected:
gdouble m_cutoff_freq;
-
public:
DataHandleFirHighpass (GslDataHandle *src_handle,
gdouble cutoff_freq,
@@ -283,37 +251,29 @@ public:
if (m_init_ok)
m_dhandle.name = g_strconcat (m_src_handle->name, "// #highpass /", NULL);
}
-
virtual void
design_filter_coefficients (double mix_freq)
{
const guint transfer_func_length = 4;
double transfer_func_freqs[transfer_func_length];
double transfer_func_values[transfer_func_length];
-
transfer_func_freqs[0] = 0;
transfer_func_values[0] = 0;
-
transfer_func_freqs[1] = m_cutoff_freq / mix_freq * 2 * M_PI;
transfer_func_values[1] = 0;
-
transfer_func_freqs[2] = m_cutoff_freq / mix_freq * 2 * M_PI;
transfer_func_values[2] = 1.0; // 0 dB
-
transfer_func_freqs[3] = PI;
transfer_func_values[3] = 1.0; // 0 dB
-
gsl_filter_fir_approx (m_a.size() - 1, &m_a[0],
transfer_func_length, transfer_func_freqs, transfer_func_values,
false); // interpolate dB
}
};
-
class DataHandleFirLowpass : public DataHandleFir
{
protected:
gdouble m_cutoff_freq;
-
public:
DataHandleFirLowpass (GslDataHandle *src_handle,
gdouble cutoff_freq,
@@ -324,36 +284,27 @@ public:
if (m_init_ok)
m_dhandle.name = g_strconcat (m_src_handle->name, "// #lowpass /", NULL);
}
-
virtual void
design_filter_coefficients (double mix_freq)
{
const guint transfer_func_length = 4;
double transfer_func_freqs[transfer_func_length];
double transfer_func_values[transfer_func_length];
-
transfer_func_freqs[0] = 1; // 0 dB
transfer_func_values[0] = 1;
-
transfer_func_freqs[1] = m_cutoff_freq / mix_freq * 2 * M_PI;
transfer_func_values[1] = 1; // 0 dB
-
transfer_func_freqs[2] = m_cutoff_freq / mix_freq * 2 * M_PI;
transfer_func_values[2] = 0;
-
transfer_func_freqs[3] = PI;
transfer_func_values[3] = 0;
-
gsl_filter_fir_approx (m_a.size() - 1, &m_a[0],
transfer_func_length, transfer_func_freqs, transfer_func_values,
false); // interpolate dB
}
};
-
}
-
using namespace Bse;
-
/**
* <pre>
* __________
@@ -375,7 +326,6 @@ bse_data_handle_new_fir_highpass (GslDataHandle *src_handle,
DataHandleFir *cxx_dh = new DataHandleFirHighpass (src_handle, cutoff_freq, order);
return DataHandleFir::dh_create (cxx_dh);
}
-
/**
* <pre>
* ______
@@ -397,7 +347,6 @@ bse_data_handle_new_fir_lowpass (GslDataHandle *src_handle,
DataHandleFir *cxx_dh = new DataHandleFirLowpass (src_handle, cutoff_freq, order);
return DataHandleFir::dh_create (cxx_dh);
}
-
extern "C" gdouble
bse_data_handle_fir_response_db (GslDataHandle *fir_handle,
gdouble freq)
diff --git a/bse/bsedatahandle-resample.cc b/bse/bsedatahandle-resample.cc
index 4d1c438..8bc92dd 100644
--- a/bse/bsedatahandle-resample.cc
+++ b/bse/bsedatahandle-resample.cc
@@ -3,19 +3,15 @@
#include "gsldatahandle.hh"
#include <sfi/sficxx.hh>
#include <vector>
-
namespace Bse {
using Resampler::Resampler2;
using std::vector;
-
class DataHandleResample2;
-
struct CDataHandleResample2 : public GslDataHandle
{
// back pointer to get casting right, even in presence of C++ vtable:
DataHandleResample2* cxx_dh;
};
-
class DataHandleResample2
{
protected:
@@ -30,7 +26,6 @@ protected:
int64 m_filter_delay_input;
int64 m_filter_order;
bool m_init_ok;
-
DataHandleResample2 (GslDataHandle *src_handle,
int precision_bits) :
m_src_handle (src_handle),
@@ -42,13 +37,11 @@ protected:
m_init_ok (false)
{
g_return_if_fail (src_handle != NULL);
-
memset (&m_dhandle, 0, sizeof (m_dhandle));
m_init_ok = gsl_data_handle_common_init (&m_dhandle, NULL);
if (m_init_ok)
gsl_data_handle_ref (m_src_handle);
}
-
/* protected destructor: (use reference counting instead) */
virtual
~DataHandleResample2()
@@ -59,14 +52,12 @@ protected:
gsl_data_handle_common_free (&m_dhandle);
}
}
-
int64
src_read (int64 voffset,
int64 n_values,
gfloat *values)
{
voffset += m_filter_delay * m_dhandle.setup.n_channels; /* compensate filter delay */
-
int64 left = n_values;
do
{
@@ -86,13 +77,11 @@ protected:
*values = 0;
l = 1;
}
-
voffset += l;
left -= l;
values += l;
}
while (left > 0);
-
return n_values;
}
void
@@ -101,7 +90,6 @@ protected:
size_t n_values)
{
const guint n_channels = m_dhandle.setup.n_channels;
-
for (guint ch = 0; ch < n_channels; ch++)
for (size_t v = ch; v < n_values; v += n_channels)
*dest++ = src[v];
@@ -112,16 +100,13 @@ protected:
size_t n_values)
{
const guint n_channels = m_dhandle.setup.n_channels;
-
for (guint ch = 0; ch < n_channels; ch++)
for (size_t v = ch; v < n_values; v += n_channels)
dest[v] = *src++;
}
-
/* implemented by upsampling and downsampling datahandle */
virtual BseResampler2Mode mode () const = 0;
virtual int64 read_frame (int64 frame) = 0;
-
public:
BseErrorType
open (GslDataHandleSetup *setup)
@@ -129,7 +114,6 @@ public:
BseErrorType error = gsl_data_handle_open (m_src_handle);
if (error != BSE_ERROR_NONE)
return error;
-
/* !not! m_dhandle.setup; the framework magically ensures that *m_dhandle.setup
* is initialized by whatever we write into *setup if open is successful
*/
@@ -144,22 +128,18 @@ public:
break;
default: g_assert_not_reached();
}
-
m_frame_size = 1024 * setup->n_channels;
m_pcm_frame = -2;
m_pcm_data.resize (m_frame_size);
-
BseResampler2Precision precision = Resampler2::find_precision_for_bits (m_precision_bits);
for (guint i = 0; i < setup->n_channels; i++)
{
Resampler2 *resampler = Resampler2::create (mode(), precision);
g_assert (resampler);
-
m_resamplers.push_back (resampler);
}
g_assert (!m_resamplers.empty()); /* n_channels is always > 0 */
m_filter_order = m_resamplers[0]->order();
-
/* Resampler2::delay() is defined in output samples, but we need to
* compensate by shifting the input samples to enable seeking, thus the
* factor 2
@@ -167,7 +147,6 @@ public:
if (mode() == BSE_RESAMPLER2_MODE_UPSAMPLE)
{
m_filter_delay = (int) round (m_resamplers[0]->delay());
-
// dividing this value may erase half a sample delay (if m_filter_delay is odd)
// this half sample delay is compensated on the input
m_filter_delay_input = m_filter_delay % 2;
@@ -185,10 +164,8 @@ public:
{
for (guint i = 0; i < m_dhandle.setup.n_channels; i++)
delete m_resamplers[i];
-
m_resamplers.clear();
m_pcm_data.clear();
-
m_dhandle.setup.xinfos = NULL; /* cleanup pointer reference */
gsl_data_handle_close (m_src_handle);
}
@@ -201,7 +178,6 @@ public:
* to the delay compensation performed in src_read())
*/
voffset += m_filter_delay_input * m_dhandle.setup.n_channels;
-
int64 frame = voffset / m_pcm_data.size();
if (frame != m_pcm_frame)
{
@@ -210,14 +186,11 @@ public:
return l;
}
g_assert (m_pcm_frame == frame);
-
voffset -= m_pcm_frame * m_frame_size;
g_assert (voffset >= 0);
-
n_values = std::min (n_values, m_frame_size - voffset);
for (int64 i = 0; i < n_values; i++)
values[i] = m_pcm_data[voffset + i];
-
return n_values;
}
int64
@@ -226,15 +199,12 @@ public:
int64 source_state_length = gsl_data_handle_get_state_length (m_src_handle);
// m_src_handle must be opened and have valid state size
g_return_val_if_fail (source_state_length >= 0, 0);
-
if (mode() == BSE_RESAMPLER2_MODE_UPSAMPLE)
source_state_length *= 2;
else
source_state_length = (source_state_length + 1) / 2;
-
// we must be opened => n_channels > 0, 1 Resampler per Channel
g_return_val_if_fail (!m_resamplers.empty(), 0);
-
/* For fractional delays, a delay of 10.5 for instance means that input[0]
* affects samples 10 and 11, and thus the state length we assume for
* that case is 11.
@@ -254,7 +224,6 @@ public:
dh_get_state_length,
dh_destroy,
};
-
if (cxx_dh->m_init_ok)
{
cxx_dh->m_dhandle.vtable = &dh_vtable;
@@ -304,7 +273,6 @@ private:
return dh_cast (dhandle)->get_state_length();
}
};
-
class DataHandleUpsample2 : public DataHandleResample2
{
public:
@@ -325,22 +293,17 @@ public:
{
const int64 n_channels = m_dhandle.setup.n_channels;
const int64 n_input_samples = m_filter_order;
-
float input_interleaved[n_input_samples * n_channels];
float input[n_input_samples * n_channels];
-
int64 l = src_read (frame * m_frame_size / 2 - n_input_samples * n_channels,
n_input_samples * n_channels, input_interleaved);
if (l < 0)
return l; /* pass on errors */
-
deinterleave (input_interleaved, input, n_input_samples * m_dhandle.setup.n_channels);
-
for (guint ch = 0; ch < m_dhandle.setup.n_channels; ch++)
{
/* we don't need the output, this is just for filling the filter history */
float output[n_input_samples * 2];
-
m_resamplers[ch]->process_block (input + ch * n_input_samples, n_input_samples, output);
}
return 1;
@@ -358,30 +321,24 @@ public:
if (l < 0)
return l; /* pass on errors */
}
-
float input_interleaved[m_frame_size / 2];
float input[m_frame_size / 2];
float output[m_frame_size];
-
int64 l = src_read (frame * m_frame_size / 2, m_frame_size / 2, input_interleaved);
if (l < 0)
return l; /* pass on errors */
-
deinterleave (input_interleaved, input, m_frame_size / 2);
for (guint ch = 0; ch < m_dhandle.setup.n_channels; ch++)
{
const int64 output_per_channel = m_frame_size / m_dhandle.setup.n_channels;
const int64 input_per_channel = output_per_channel / 2;
-
m_resamplers[ch]->process_block (input + ch * input_per_channel, input_per_channel, output + ch * output_per_channel);
}
interleave (output, &m_pcm_data[0], m_frame_size);
-
m_pcm_frame = frame;
return 1;
}
};
-
class DataHandleDownsample2 : public DataHandleResample2
{
public:
@@ -400,22 +357,17 @@ public:
{
const int64 n_channels = m_dhandle.setup.n_channels;
const int64 n_input_samples = m_filter_order * 2;
-
float input_interleaved[n_input_samples * n_channels];
float input[n_input_samples * n_channels];
-
int64 l = src_read (frame * m_frame_size * 2 - n_input_samples * n_channels,
n_input_samples * n_channels, input_interleaved);
if (l < 0)
return l; /* pass on errors */
-
deinterleave (input_interleaved, input, n_input_samples * m_dhandle.setup.n_channels);
-
for (guint ch = 0; ch < m_dhandle.setup.n_channels; ch++)
{
/* we don't need the output, this is just for filling the filter history */
float output[n_input_samples / 2];
-
m_resamplers[ch]->process_block (input + ch * n_input_samples, n_input_samples, output);
}
return 1;
@@ -433,34 +385,26 @@ public:
if (l < 0)
return l; /* pass on errors */
}
-
float input_interleaved[m_frame_size * 2];
float input[m_frame_size * 2];
float output[m_frame_size];
-
int64 l = src_read (frame * m_frame_size * 2, m_frame_size * 2, input_interleaved);
if (l < 0)
return l; /* pass on errors */
-
deinterleave (input_interleaved, input, m_frame_size * 2);
for (guint ch = 0; ch < m_dhandle.setup.n_channels; ch++)
{
const int64 output_per_channel = m_frame_size / m_dhandle.setup.n_channels;
const int64 input_per_channel = output_per_channel * 2;
-
m_resamplers[ch]->process_block (input + ch * input_per_channel, input_per_channel, output + ch * output_per_channel);
}
interleave (output, &m_pcm_data[0], m_frame_size);
-
m_pcm_frame = frame;
return 1;
}
};
-
} // Bse
-
using namespace Bse;
-
extern "C" GslDataHandle*
bse_data_handle_new_upsample2 (GslDataHandle *src_handle,
int precision_bits)
@@ -468,7 +412,6 @@ bse_data_handle_new_upsample2 (GslDataHandle *src_handle,
DataHandleResample2 *cxx_dh = new DataHandleUpsample2 (src_handle, precision_bits);
return DataHandleResample2::dh_create (cxx_dh);
}
-
extern "C" GslDataHandle*
bse_data_handle_new_downsample2 (GslDataHandle *src_handle,
int precision_bits)
diff --git a/bse/bsedatapocket.cc b/bse/bsedatapocket.cc
index fd8855a..c8bb8f6 100644
--- a/bse/bsedatapocket.cc
+++ b/bse/bsedatapocket.cc
@@ -1,17 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsedatapocket.hh"
#include "bsecxxplugin.hh"
-
#include "bsemain.hh"
#include "bsestorage.hh"
-
#include <string.h>
-
/* --- macros --- */
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
/* --- structures --- */
typedef struct _Notify Notify;
struct _Notify
@@ -20,8 +15,6 @@ struct _Notify
BseDataPocket *pocket;
uint entry_id;
};
-
-
/* --- prototypes --- */
static void bse_data_pocket_init (BseDataPocket *pocket);
static void bse_data_pocket_class_init (BseDataPocketClass *klass);
@@ -35,8 +28,6 @@ static void bse_data_pocket_do_store_private (BseObject *object,
static GTokenType bse_data_pocket_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner);
-
-
/* --- variables --- */
static void *parent_class = NULL;
static uint signal_entry_added = 0;
@@ -44,50 +35,39 @@ static uint signal_entry_removed = 0;
static uint signal_entry_changed = 0;
static Notify *changed_notify_list = NULL;
static GQuark quark_set_data = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseDataPocket)
{
static const GTypeInfo data_pocket_info = {
sizeof (BseDataPocketClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_data_pocket_class_init,
(GClassFinalizeFunc) bse_data_pocket_class_finalize,
NULL /* class_data */,
-
sizeof (BseDataPocket),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_data_pocket_init,
};
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BseDataPocket",
"Data pocket type",
__FILE__, __LINE__,
&data_pocket_info);
}
-
static void
bse_data_pocket_class_init (BseDataPocketClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
quark_set_data = g_quark_from_static_string ("set-data");
-
gobject_class->dispose = bse_data_pocket_dispose;
gobject_class->finalize = bse_data_pocket_finalize;
-
object_class->store_private = bse_data_pocket_do_store_private;
object_class->restore_private = bse_data_pocket_restore_private;
-
item_class->needs_storage = bse_data_pocket_needs_storage;
-
signal_entry_added = bse_object_class_add_signal (object_class, "entry-added",
G_TYPE_NONE, 1, G_TYPE_INT);
signal_entry_removed = bse_object_class_add_signal (object_class, "entry-removed",
@@ -95,12 +75,10 @@ bse_data_pocket_class_init (BseDataPocketClass *klass)
signal_entry_changed = bse_object_class_add_signal (object_class, "entry-changed",
G_TYPE_NONE, 1, G_TYPE_INT);
}
-
static void
bse_data_pocket_class_finalize (BseDataPocketClass *klass)
{
}
-
static void
bse_data_pocket_init (BseDataPocket *pocket)
{
@@ -110,39 +88,30 @@ bse_data_pocket_init (BseDataPocket *pocket)
pocket->need_store = 0;
pocket->cr_items = NULL;
}
-
static void
bse_data_pocket_dispose (GObject *object)
{
BseDataPocket *pocket = BSE_DATA_POCKET (object);
-
/* set disposal flag early, since we check for it internally */
BSE_OBJECT_SET_FLAGS (object, BSE_OBJECT_FLAG_DISPOSING);
-
while (pocket->n_entries)
_bse_data_pocket_delete_entry (pocket, pocket->entries[0].id);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
-
g_return_if_fail (pocket->cr_items == NULL);
}
-
static void
bse_data_pocket_finalize (GObject *object)
{
BseDataPocket *pocket = BSE_DATA_POCKET (object);
Notify *notify, *last = NULL;
-
while (pocket->n_entries)
_bse_data_pocket_delete_entry (pocket, pocket->entries[0].id);
-
for (notify = changed_notify_list; notify; )
{
if (notify->pocket == pocket)
{
Notify *tmp;
-
if (last)
last->next = notify->next;
else
@@ -157,39 +126,30 @@ bse_data_pocket_finalize (GObject *object)
notify = last->next;
}
}
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
-
g_return_if_fail (pocket->cr_items == NULL);
}
-
static gboolean
changed_notify_handler (void *data)
{
BSE_THREADS_ENTER ();
-
while (changed_notify_list)
{
Notify *notify = changed_notify_list;
-
changed_notify_list = notify->next;
if (!BSE_OBJECT_DISPOSING (notify->pocket))
g_signal_emit (notify->pocket, signal_entry_changed, 0, notify->entry_id);
g_free (notify);
}
-
BSE_THREADS_LEAVE ();
-
return FALSE;
}
-
static void
changed_notify_add (BseDataPocket *pocket,
uint entry_id)
{
Notify *notify;
-
if (!changed_notify_list)
bse_idle_notify (changed_notify_handler, NULL);
for (notify = changed_notify_list; notify; notify = notify->next)
@@ -201,19 +161,16 @@ changed_notify_add (BseDataPocket *pocket,
notify->next = changed_notify_list;
changed_notify_list = notify;
}
-
static void
pocket_uncross (BseItem *pitem,
BseItem *item)
{
BseDataPocket *pocket = BSE_DATA_POCKET (pitem);
uint i;
-
for (i = 0; i < pocket->n_entries; i++)
{
BseDataPocketEntry *entry = pocket->entries + i;
uint n, have_this_id = 0;
-
for (n = 0; n < entry->n_items; n++)
if (entry->items[n].type == BSE_DATA_POCKET_OBJECT &&
entry->items[n].value.v_object == item)
@@ -223,72 +180,57 @@ pocket_uncross (BseItem *pitem,
entry->items[n].value.v_object = NULL;
}
}
-
g_object_ref (pocket);
pocket->cr_items = g_slist_remove (pocket->cr_items, item);
g_object_unref (pocket);
}
-
static void
add_cross_ref (BseDataPocket *pocket,
BseItem *item)
{
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (bse_item_common_ancestor (BSE_ITEM (pocket), item) != NULL); // FIXME: delete
-
if (!g_slist_find (pocket->cr_items, item))
{
bse_item_cross_link (BSE_ITEM (pocket), item, pocket_uncross);
pocket->cr_items = g_slist_prepend (pocket->cr_items, item);
}
}
-
static void
remove_cross_ref (BseDataPocket *pocket,
BseItem *item)
{
uint i;
-
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (bse_item_common_ancestor (BSE_ITEM (pocket), item) != NULL); // FIXME: delete
g_return_if_fail (g_slist_find (pocket->cr_items, item) != NULL);
-
for (i = 0; i < pocket->n_entries; i++)
{
BseDataPocketEntry *entry = pocket->entries + i;
uint n;
-
for (n = 0; n < entry->n_items; n++)
if (entry->items[n].type == BSE_DATA_POCKET_OBJECT &&
entry->items[n].value.v_object == item)
return;
}
-
pocket->cr_items = g_slist_remove (pocket->cr_items, item);
bse_item_cross_unlink (BSE_ITEM (pocket), item, pocket_uncross);
}
-
uint
_bse_data_pocket_create_entry (BseDataPocket *pocket)
{
uint id, i;
-
g_return_val_if_fail (BSE_IS_DATA_POCKET (pocket), 0);
-
id = pocket->free_id++;
g_assert (id != 0);
-
i = pocket->n_entries++;
pocket->entries = g_renew (BseDataPocketEntry, pocket->entries, pocket->n_entries);
pocket->entries[i].id = id;
pocket->entries[i].n_items = 0;
pocket->entries[i].items = NULL;
-
g_signal_emit (pocket, signal_entry_added, 0, id);
-
return id;
}
-
gboolean
_bse_data_pocket_delete_entry (BseDataPocket *pocket,
uint entry_id)
@@ -296,16 +238,13 @@ _bse_data_pocket_delete_entry (BseDataPocket *pocket,
BseDataPocketEntry *entry;
GSList *cr_del = NULL;
uint i, n;
-
g_return_val_if_fail (BSE_IS_DATA_POCKET (pocket), FALSE);
g_return_val_if_fail (entry_id > 0, FALSE);
-
for (i = 0; i < pocket->n_entries; i++)
if (pocket->entries[i].id == entry_id)
break;
if (i >= pocket->n_entries)
return FALSE;
-
entry = pocket->entries + i;
for (n = 0; n < entry->n_items; n++)
{
@@ -317,29 +256,22 @@ _bse_data_pocket_delete_entry (BseDataPocket *pocket,
cr_del = g_slist_prepend (cr_del, entry->items[n].value.v_object);
}
g_free (entry->items);
-
pocket->need_store -= entry->n_items;
n = entry->id;
-
pocket->n_entries--;
if (i < pocket->n_entries)
pocket->entries[i] = pocket->entries[pocket->n_entries];
-
while (cr_del)
{
GSList *tmp = cr_del;
-
cr_del = tmp->next;
remove_cross_ref (pocket, BSE_ITEM (tmp->data));
g_slist_free_1 (tmp);
}
-
if (!BSE_OBJECT_DISPOSING (pocket))
g_signal_emit (pocket, signal_entry_removed, 0, n);
-
return TRUE;
}
-
gboolean
_bse_data_pocket_entry_set (BseDataPocket *pocket,
uint id,
@@ -350,36 +282,30 @@ _bse_data_pocket_entry_set (BseDataPocket *pocket,
BseDataPocketEntry *entry;
uint i, n;
bool delete_item;
-
g_return_val_if_fail (BSE_IS_DATA_POCKET (pocket), FALSE);
g_return_val_if_fail (id > 0, FALSE);
g_return_val_if_fail (data_quark > 0, FALSE);
if (type == BSE_DATA_POCKET_OBJECT && value.v_object)
g_return_val_if_fail (BSE_IS_ITEM (value.v_object), FALSE);
-
delete_item = ((type == BSE_DATA_POCKET_INT && value.v_int == 0) ||
(type == BSE_DATA_POCKET_INT64 && value.v_int64 == 0) ||
(type == BSE_DATA_POCKET_FLOAT && value.v_float == 0.0) ||
(type == BSE_DATA_POCKET_STRING && value.v_string == NULL) ||
(type == BSE_DATA_POCKET_OBJECT && value.v_object == NULL));
-
for (i = 0; i < pocket->n_entries; i++)
if (pocket->entries[i].id == id)
break;
if (i >= pocket->n_entries)
return FALSE;
-
entry = pocket->entries + i;
for (n = 0; n < entry->n_items; n++)
if (entry->items[n].quark == data_quark)
break;
-
/* check premature exit paths and grow as required */
if (n >= entry->n_items)
{
if (delete_item)
return TRUE;
-
n = entry->n_items++;
entry->items = (BseDataPocketEntry::Item*) g_realloc (entry->items, sizeof (entry->items[0]) * entry->n_items);
entry->items[n].type = 0;
@@ -388,7 +314,6 @@ _bse_data_pocket_entry_set (BseDataPocket *pocket,
}
else if (memcmp (&value, &entry->items[n].value, sizeof (value)) == 0)
return TRUE;
-
/* cleanup */
if (entry->items[n].type == BSE_DATA_POCKET_STRING)
g_free (entry->items[n].value.v_string);
@@ -397,7 +322,6 @@ _bse_data_pocket_entry_set (BseDataPocket *pocket,
entry->items[n].type = 0;
remove_cross_ref (pocket, value.v_object);
}
-
/* assignment */
if (delete_item)
{
@@ -415,12 +339,9 @@ _bse_data_pocket_entry_set (BseDataPocket *pocket,
else if (type == BSE_DATA_POCKET_OBJECT)
add_cross_ref (pocket, value.v_object);
}
-
changed_notify_add (pocket, entry->id);
-
return TRUE;
}
-
char
_bse_data_pocket_entry_get (BseDataPocket *pocket,
uint id,
@@ -429,31 +350,23 @@ _bse_data_pocket_entry_get (BseDataPocket *pocket,
{
BseDataPocketEntry *entry;
uint i, n;
-
g_return_val_if_fail (BSE_IS_DATA_POCKET (pocket), 0);
-
if (!data_quark)
return 0;
-
for (i = 0; i < pocket->n_entries; i++)
if (pocket->entries[i].id == id)
break;
if (i >= pocket->n_entries)
return 0;
-
entry = pocket->entries + i;
-
for (n = 0; n < entry->n_items; n++)
if (entry->items[n].quark == data_quark)
break;
if (n >= entry->n_items)
return 0;
-
*value = entry->items[n].value;
-
return entry->items[n].type;
}
-
static gboolean
bse_data_pocket_needs_storage (BseItem *item,
BseStorage *storage)
@@ -461,29 +374,23 @@ bse_data_pocket_needs_storage (BseItem *item,
BseDataPocket *self = BSE_DATA_POCKET (item);
return self->need_store > 0;
}
-
static void
bse_data_pocket_do_store_private (BseObject *object,
BseStorage *storage)
{
BseDataPocket *pocket = BSE_DATA_POCKET (object);
uint i, j;
-
/* chain parent class' handler */
if (BSE_OBJECT_CLASS (parent_class)->store_private)
BSE_OBJECT_CLASS (parent_class)->store_private (object, storage);
-
for (i = 0; i < pocket->n_entries; i++)
{
BseDataPocketEntry *entry = pocket->entries + i;
-
if (!entry->n_items)
continue;
-
bse_storage_break (storage);
bse_storage_printf (storage, "(create-entry");
bse_storage_push_level (storage);
-
for (j = 0; j < entry->n_items; j++)
{
bse_storage_break (storage);
@@ -520,12 +427,10 @@ bse_data_pocket_do_store_private (BseObject *object,
bse_storage_putc (storage, ')');
}
}
-
typedef struct {
uint id;
GQuark quark;
} ObjectEntry;
-
static void
object_entry_resolved (void *data,
BseStorage *storage,
@@ -535,19 +440,16 @@ object_entry_resolved (void *data,
{
ObjectEntry *oentry = (ObjectEntry*) data;
BseDataPocket *pocket = BSE_DATA_POCKET (from_item);
-
if (error)
bse_storage_warn (storage, "%s", error);
else if (oentry->id)
{
BseDataPocketValue value;
-
value.v_object = to_item;
_bse_data_pocket_entry_set (pocket, oentry->id, oentry->quark, BSE_DATA_POCKET_OBJECT, value);
}
g_free (oentry);
}
-
static GTokenType
parse_set_data (BseDataPocket *pocket,
uint id,
@@ -559,10 +461,8 @@ parse_set_data (BseDataPocket *pocket,
GQuark quark;
uint ttype;
gboolean char_2_token;
-
parse_or_return (scanner, G_TOKEN_STRING);
quark = g_quark_from_string (scanner->value.v_string);
-
char_2_token = scanner->config->char_2_token;
scanner->config->char_2_token = FALSE;
g_scanner_get_next_token (scanner);
@@ -570,7 +470,6 @@ parse_set_data (BseDataPocket *pocket,
if (scanner->token != G_TOKEN_CHAR)
return G_TOKEN_CHAR;
ttype = scanner->value.v_char;
-
switch (ttype)
{
GTokenType token;
@@ -619,16 +518,12 @@ parse_set_data (BseDataPocket *pocket,
g_quark_to_string (quark));
}
peek_or_return (scanner, ')');
-
/* caution, value might still point to scanner->value.v_string */
if (!oentry)
_bse_data_pocket_entry_set (pocket, id, quark, ttype, value);
-
g_scanner_get_next_token (scanner); /* eat ')' */
-
return G_TOKEN_NONE;
}
-
static GTokenType
bse_data_pocket_restore_private (BseObject *object,
BseStorage *storage,
@@ -636,15 +531,12 @@ bse_data_pocket_restore_private (BseObject *object,
{
BseDataPocket *pocket = BSE_DATA_POCKET (object);
GTokenType expected_token;
-
/* support storage commands */
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER &&
bse_string_equals ("create-entry", scanner->next_value.v_identifier))
{
uint id = _bse_data_pocket_create_entry (pocket);
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat identifier */
-
while (g_scanner_peek_next_token (scanner) != ')')
{
g_scanner_get_next_token (scanner); /* read token */
@@ -668,6 +560,5 @@ bse_data_pocket_restore_private (BseObject *object,
}
else /* chain parent class' handler */
expected_token = (GTokenType) BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
-
return expected_token;
}
diff --git a/bse/bsedatapocket.hh b/bse/bsedatapocket.hh
index 9ecfd70..ac0e75d 100644
--- a/bse/bsedatapocket.hh
+++ b/bse/bsedatapocket.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_DATA_POCKET_H__
#define __BSE_DATA_POCKET_H__
-
#include <bse/bsesuper.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_DATA_POCKET (BSE_TYPE_ID (BseDataPocket))
#define BSE_DATA_POCKET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_DATA_POCKET, BseDataPocket))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_DATA_POCKET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_DATA_POCKET))
#define BSE_IS_DATA_POCKET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_DATA_POCKET))
#define BSE_DATA_POCKET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_DATA_POCKET, BseDataPocketClass))
-
-
/* --- data types --- */
typedef enum /*< skip >*/
{
@@ -25,8 +20,6 @@ typedef enum /*< skip >*/
BSE_DATA_POCKET_STRING = 's',
BSE_DATA_POCKET_OBJECT = 'o'
} BseDataPocketType;
-
-
/* --- BseDataPocket structs --- */
typedef struct _BseDataPocket BseDataPocket;
typedef struct _BseDataPocketClass BseDataPocketClass;
@@ -50,19 +43,15 @@ typedef struct
struct _BseDataPocket
{
BseItem parent_object;
-
guint need_store; /* for BSE_ITEM_FLAG_AGGREGATE */
GSList *cr_items;
-
guint free_id;
-
guint n_entries;
BseDataPocketEntry *entries;
};
struct _BseDataPocketClass
{
BseItemClass parent_class;
-
void (*entry_added) (BseDataPocket *pocket,
guint entry_id);
void (*entry_removed) (BseDataPocket *pocket,
@@ -70,8 +59,6 @@ struct _BseDataPocketClass
void (*entry_changed) (BseDataPocket *pocket,
guint entry_id);
};
-
-
/* --- prototypes --- */
guint _bse_data_pocket_create_entry (BseDataPocket *pocket);
gboolean _bse_data_pocket_delete_entry (BseDataPocket *pocket,
@@ -85,7 +72,5 @@ gchar _bse_data_pocket_entry_get (BseDataPocket *pocket,
guint id,
GQuark data_quark,
BseDataPocketValue *value);
-
G_END_DECLS
-
#endif /* __BSE_DATA_POCKET_H__ */
diff --git a/bse/bsedatapocket.proc b/bse/bsedatapocket.proc
index 98183f2..cfc868b 100644
--- a/bse/bsedatapocket.proc
+++ b/bse/bsedatapocket.proc
@@ -2,12 +2,8 @@
#include <bse/bseplugin.hh>
#include <bse/bseprocedure.hh>
#include <bse/bsedatapocket.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseDataPocket, create-entry) {
HELP = ("Create a new entry in a data pocket. "
"Entries have a unique ID which is required to set values in a data pocket.");
@@ -22,20 +18,15 @@ METHOD (BseDataPocket, create-entry) {
/* extract parameter values */
BseDataPocket *pocket = (BseDataPocket*) bse_value_get_object (in_values++);
uint id;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
id = _bse_data_pocket_create_entry (pocket);
-
/* set output parameters */
sfi_value_set_int (out_values++, id);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, delete-entry) {
HELP = "Delete an existing entry from a data pocket";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", NULL,
@@ -53,21 +44,16 @@ METHOD (BseDataPocket, delete-entry) {
BseDataPocket *pocket = (BseDataPocket*) bse_value_get_object (in_values++);
uint id = sfi_value_get_int (in_values++);
bool fail = TRUE;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (id)
fail = _bse_data_pocket_delete_entry (pocket, id);
-
/* set output parameters */
g_value_set_enum (out_values++, fail ? BSE_ERROR_NO_ENTRY : BSE_ERROR_NONE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-n-entries) {
HELP = "Retrieve the number of entries created in a data pocket.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -80,17 +66,13 @@ METHOD (BseDataPocket, get-n-entries) {
{
/* extract parameter values */
BseDataPocket *pocket = (BseDataPocket*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, pocket->n_entries);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-nth-entry-id) {
HELP = "Retrieve the ID of an entry in the data pocket by sequential index.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -106,17 +88,13 @@ METHOD (BseDataPocket, get-nth-entry-id) {
/* extract parameter values */
BseDataPocket *pocket = (BseDataPocket*) bse_value_get_object (in_values++);
uint index = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, index < pocket->n_entries ? pocket->entries[index].id : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, set-float) {
HELP = ("Set a named floating point value in a data pocket entry. "
"Names are required to distinguish different values from each other "
@@ -143,22 +121,17 @@ METHOD (BseDataPocket, set-float) {
gfloat v_float = sfi_value_get_real (in_values++);
BseDataPocketValue value;
bool success = FALSE;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
value.v_float = v_float;
if (id)
success = _bse_data_pocket_entry_set (pocket, id, g_quark_from_string (name), BSE_DATA_POCKET_FLOAT, value);
-
/* set output parameters */
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_ENTRY);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, set-int) {
HELP = ("Set a named integer value in a data pocket entry. "
"Names are required to distinguish different values from each other "
@@ -185,22 +158,17 @@ METHOD (BseDataPocket, set-int) {
guint v_uint = sfi_value_get_int (in_values++);
BseDataPocketValue value;
bool success = FALSE;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
value.v_int = v_uint;
if (id)
success = _bse_data_pocket_entry_set (pocket, id, g_quark_from_string (name), BSE_DATA_POCKET_INT, value);
-
/* set output parameters */
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_ENTRY);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, set-object) {
HELP = ("Set a named object reference in a data pocket entry. "
"Object references stored in a data pocket must exist within the "
@@ -227,23 +195,18 @@ METHOD (BseDataPocket, set-object) {
BseItem *v_object = (BseItem*) bse_value_get_object (in_values++);
BseDataPocketValue value;
bool success = FALSE;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket) ||
(v_object && !bse_item_common_ancestor ((BseItem*) pocket, v_object)))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
value.v_object = v_object;
if (id)
success = _bse_data_pocket_entry_set (pocket, id, g_quark_from_string (name), BSE_DATA_POCKET_OBJECT, value);
-
/* set output parameters */
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_ENTRY);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, set-string) {
HELP = ("Set a named string in a data pocket entry.");
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -281,7 +244,6 @@ METHOD (BseDataPocket, set-string) {
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_ENTRY);
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-float) {
HELP = "Retrieve a previously set floating point value from a data pocket entry.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -302,20 +264,15 @@ METHOD (BseDataPocket, get-float) {
const char *name = sfi_value_get_string (in_values++);
BseDataPocketValue value = { 0, };
gchar type;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
type = _bse_data_pocket_entry_get (pocket, id, g_quark_try_string (name), &value);
-
/* set output parameters */
sfi_value_set_real (out_values++, type == BSE_DATA_POCKET_FLOAT ? value.v_float : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-int) {
HELP = "Retrieve a previously set integer value from a data pocket entry.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -336,20 +293,15 @@ METHOD (BseDataPocket, get-int) {
const char *name = sfi_value_get_string (in_values++);
BseDataPocketValue value = { 0, };
gchar type;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
type = _bse_data_pocket_entry_get (pocket, id, g_quark_try_string (name), &value);
-
/* set output parameters */
sfi_value_set_int (out_values++, type == BSE_DATA_POCKET_INT ? value.v_int : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-object) {
HELP = "Retrieve a previously set object reference from a data pocket entry.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -370,20 +322,15 @@ METHOD (BseDataPocket, get-object) {
const char *name = sfi_value_get_string (in_values++);
BseDataPocketValue value = { 0, };
gchar type;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
type = _bse_data_pocket_entry_get (pocket, id, g_quark_try_string (name), &value);
-
/* set output parameters */
bse_value_set_object (out_values++, type == BSE_DATA_POCKET_OBJECT ? value.v_object : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseDataPocket, get-string) {
HELP = "Retrieve a previously set string from a data pocket entry.";
IN = bse_param_spec_object ("data_pocket", "Data Pocket", "The data pocket storing values",
@@ -404,16 +351,12 @@ METHOD (BseDataPocket, get-string) {
const char *name = sfi_value_get_string (in_values++);
BseDataPocketValue value = { 0, };
gchar type;
-
/* check parameters */
if (!BSE_IS_DATA_POCKET (pocket))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
type = _bse_data_pocket_entry_get (pocket, id, g_quark_try_string (name), &value);
-
/* set output parameters */
sfi_value_set_string (out_values++, type == BSE_DATA_POCKET_STRING ? value.v_string : 0);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsedefs.hh b/bse/bsedefs.hh
index b50646e..d6c41fd 100644
--- a/bse/bsedefs.hh
+++ b/bse/bsedefs.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_DEFS_H__
#define __BSE_DEFS_H__
-
#undef G_DISABLE_ASSERT
#undef G_DISABLE_CHECKS
#include <libintl.h>
@@ -9,17 +8,12 @@
#include <sfi/sfistore.hh> // FIXME
#include <sfi/sficomwire.hh> // FIXME
#include <bse/bseconfig.h>
-
G_BEGIN_DECLS
-
-
/* --- some globally used macros --- */
#define BSE_VERSION_CMP(v1_major, v1_minor, v1_micro, v2_major, v2_minor, v2_micro) ( \
(v1_major != v2_major) ? (v1_major > v2_major ? +1 : -1) : \
(v1_minor != v2_minor) ? (v1_minor > v2_minor ? +1 : -1) : \
(v1_micro < v2_micro ? -1 : v1_micro > v2_micro))
-
-
/* --- BSE objects, classes & interfaces --- */
typedef struct _BseBinData BseBinData;
typedef struct _BseBinDataClass BseBinDataClass;
@@ -86,7 +80,6 @@ typedef struct _BseVoice BseVoice;
typedef struct _BseWave BseWave;
typedef struct _BseWaveRepo BseWaveRepo;
typedef struct _BseWaveRepoClass BseWaveRepoClass;
-
/* --- BseModule special handling --- */
typedef struct _BseModule BseModule;
typedef struct _BseModuleClass BseModuleClass;
@@ -98,22 +91,17 @@ typedef struct _BseOStream BseOStream;
#define BSE_MODULE_GET_ISTREAMSP(bsemodule) (((gpointer*) bsemodule)[2])
#define BSE_MODULE_GET_JSTREAMSP(bsemodule) (((gpointer*) bsemodule)[3])
#define BSE_MODULE_GET_OSTREAMSP(bsemodule) (((gpointer*) bsemodule)[4])
-
/* --- Bse Loader --- */
typedef struct _BseLoader BseLoader;
typedef struct _BseWaveFileInfo BseWaveFileInfo;
typedef struct _BseWaveDsc BseWaveDsc;
typedef struct _BseWaveChunkDsc BseWaveChunkDsc;
-
-
/* --- BSE aux structures --- */
typedef struct _BseExportNode BseExportNode;
typedef struct _BseExportNodeBoxed BseExportNodeBoxed;
typedef struct _BseGlobals BseGlobals;
typedef struct _BsePlugin BsePlugin;
typedef struct _BsePluginClass BsePluginClass;
-
-
/* --- BSE function types --- */
typedef void (*BseFunc) (void);
typedef void (*BseFreeFunc) (gpointer data);
@@ -136,14 +124,9 @@ typedef gboolean (*BseCategoryForeach) (const gchar *category_path,
gpointer user_data);
typedef void (*BseEngineAccessFunc) (BseModule *module,
gpointer data);
-
-
-
/* --- i18n and gettext helpers --- */
const gchar* bse_gettext (const gchar *text);
#define _(str) bse_gettext (str)
#define N_(str) (str)
-
G_END_DECLS
-
#endif /* __BSE_DEFS_H__ */
diff --git a/bse/bsedevice.cc b/bse/bsedevice.cc
index cb72662..031d620 100644
--- a/bse/bsedevice.cc
+++ b/bse/bsedevice.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsedevice.hh"
#include <sfi/gbsearcharray.hh>
-
/* --- functions --- */
static void
bse_device_init (BseDevice *self)
@@ -10,7 +9,6 @@ bse_device_init (BseDevice *self)
BSE_DEVICE_FLAG_READABLE |
BSE_DEVICE_FLAG_WRITABLE));
}
-
SfiRing*
bse_device_list (BseDevice *self)
{
@@ -22,7 +20,6 @@ bse_device_list (BseDevice *self)
ring = sfi_ring_append (ring, bse_device_error_new (self, g_strdup_printf ("Driver not implemented")));
return ring;
}
-
static char**
device_split_args (const char *arg_string,
uint *n)
@@ -40,7 +37,6 @@ device_split_args (const char *arg_string,
}
return strv;
}
-
static BseErrorType
device_open_args (BseDevice *self,
gboolean need_readable,
@@ -55,7 +51,6 @@ device_open_args (BseDevice *self,
need_writable != FALSE,
n, (const char**) args);
g_strfreev (args);
-
if (!error)
{
g_return_val_if_fail (BSE_DEVICE_OPEN (self), BSE_ERROR_INTERNAL);
@@ -67,17 +62,14 @@ device_open_args (BseDevice *self,
}
else
g_return_val_if_fail (!BSE_DEVICE_OPEN (self), BSE_ERROR_INTERNAL);
-
if (!error && ((need_readable && !BSE_DEVICE_READABLE (self)) ||
(need_writable && !BSE_DEVICE_WRITABLE (self))))
{
bse_device_close (self);
error = BSE_ERROR_DEVICE_NOT_AVAILABLE;
}
-
return error;
}
-
BseErrorType
bse_device_open (BseDevice *self,
gboolean need_readable,
@@ -106,7 +98,6 @@ bse_device_open (BseDevice *self,
}
return error;
}
-
void
bse_device_set_opened (BseDevice *self,
const char *device_name,
@@ -126,28 +117,22 @@ bse_device_set_opened (BseDevice *self,
g_free (self->open_device_args);
self->open_device_args = NULL;
}
-
void
bse_device_close (BseDevice *self)
{
g_return_if_fail (BSE_IS_DEVICE (self));
g_return_if_fail (BSE_DEVICE_OPEN (self));
-
if (BSE_DEVICE_GET_CLASS (self)->pre_close)
BSE_DEVICE_GET_CLASS (self)->pre_close (self);
-
BSE_DEVICE_GET_CLASS (self)->close (self);
-
g_free (self->open_device_name);
self->open_device_name = NULL;
g_free (self->open_device_args);
self->open_device_args = NULL;
-
BSE_OBJECT_UNSET_FLAGS (self, (BSE_DEVICE_FLAG_OPEN |
BSE_DEVICE_FLAG_READABLE |
BSE_DEVICE_FLAG_WRITABLE));
}
-
BseDeviceEntry*
bse_device_entry_new (BseDevice *device,
char *orphan_args,
@@ -155,7 +140,6 @@ bse_device_entry_new (BseDevice *device,
{
return bse_device_group_entry_new (device, orphan_args, NULL, orphan_blurb);
}
-
BseDeviceEntry*
bse_device_group_entry_new (BseDevice *device,
char *orphan_args,
@@ -172,7 +156,6 @@ bse_device_group_entry_new (BseDevice *device,
g_free (orphan_group);
return entry;
}
-
BseDeviceEntry*
bse_device_error_new (BseDevice *device,
char *orphan_error)
@@ -183,7 +166,6 @@ bse_device_error_new (BseDevice *device,
g_free (orphan_error);
return entry;
}
-
void
bse_device_entry_free (BseDeviceEntry *entry)
{
@@ -195,14 +177,12 @@ bse_device_entry_free (BseDeviceEntry *entry)
g_free (entry->device_error);
g_free (entry);
}
-
void
bse_device_entry_list_free (SfiRing *ring)
{
while (ring)
bse_device_entry_free ((BseDeviceEntry*) sfi_ring_pop_head (&ring));
}
-
static SfiRing*
device_class_list_entries (GType type,
void (*request_callback) (BseDevice *device,
@@ -226,7 +206,6 @@ device_class_list_entries (GType type,
g_free (children);
return ring;
}
-
static int
device_entry_prio_cmp (const void *value1,
const void *value2,
@@ -237,7 +216,6 @@ device_entry_prio_cmp (const void *value1,
return -G_BSEARCH_ARRAY_CMP (BSE_DEVICE_GET_CLASS (e1->device)->driver_rating,
BSE_DEVICE_GET_CLASS (e2->device)->driver_rating);
}
-
SfiRing*
bse_device_class_list (GType type,
void (*request_callback) (BseDevice *device,
@@ -248,7 +226,6 @@ bse_device_class_list (GType type,
ring = sfi_ring_sort (ring, device_entry_prio_cmp, NULL);
return ring;
}
-
void
bse_device_class_setup (void *klass_arg,
int rating,
@@ -263,7 +240,6 @@ bse_device_class_setup (void *klass_arg,
klass->driver_syntax = syntax;
klass->driver_blurb = blurb;
}
-
void
bse_device_dump_list (GType base_type,
const char *indent,
@@ -332,7 +308,6 @@ bse_device_dump_list (GType base_type,
bse_device_entry_list_free (ring);
g_free (indent2);
}
-
static SfiRing*
device_classes_list (GType type,
int min_rating)
@@ -350,14 +325,12 @@ device_classes_list (GType type,
g_free (children);
return ring;
}
-
static void
device_classes_free (SfiRing *ring)
{
while (ring)
g_type_class_unref (sfi_ring_pop_head (&ring));
}
-
static int
device_classes_prio_cmp (gconstpointer value1,
gconstpointer value2,
@@ -367,7 +340,6 @@ device_classes_prio_cmp (gconstpointer value1,
const BseDeviceClass *c2 = (BseDeviceClass*) value2;
return -G_BSEARCH_ARRAY_CMP (c1->driver_rating, c2->driver_rating);
}
-
BseDevice*
bse_device_open_auto (GType base_type,
gboolean need_readable,
@@ -399,7 +371,6 @@ bse_device_open_auto (GType base_type,
device_classes_free (class_list);
return device;
}
-
static SfiRing*
auto_ring (void)
{
@@ -410,7 +381,6 @@ auto_ring (void)
ring.next = ˚
return ˚
}
-
BseDevice*
bse_device_open_best (GType base_type,
gboolean need_readable,
@@ -467,7 +437,6 @@ bse_device_open_best (GType base_type,
device_classes_free (class_list);
return device;
}
-
static void
bse_device_class_init (BseDeviceClass *klass)
{
@@ -475,25 +444,20 @@ bse_device_class_init (BseDeviceClass *klass)
klass->driver_rating = -1;
klass->list_devices = NULL;
}
-
BSE_BUILTIN_TYPE (BseDevice)
{
static const GTypeInfo device_info = {
sizeof (BseDeviceClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_device_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseDevice),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_device_init,
};
-
g_assert (BSE_DEVICE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
-
return bse_type_register_abstract (BSE_TYPE_OBJECT,
"BseDevice",
"Abstract device base type",
diff --git a/bse/bsedevice.hh b/bse/bsedevice.hh
index ce03dab..b5f3911 100644
--- a/bse/bsedevice.hh
+++ b/bse/bsedevice.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_DEVICE_H__
#define __BSE_DEVICE_H__
-
#include <bse/bseobject.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_DEVICE (BSE_TYPE_ID (BseDevice))
#define BSE_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_DEVICE, BseDevice))
@@ -17,8 +14,6 @@ G_BEGIN_DECLS
#define BSE_DEVICE_OPEN(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_OPEN) != 0)
#define BSE_DEVICE_READABLE(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_READABLE) != 0)
#define BSE_DEVICE_WRITABLE(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_WRITABLE) != 0)
-
-
/* --- enums --- */
typedef enum /*< skip >*/
{
@@ -27,8 +22,6 @@ typedef enum /*< skip >*/
BSE_DEVICE_FLAG_WRITABLE = 1 << (BSE_OBJECT_FLAGS_USHIFT + 2)
} BseDeviceFlags;
#define BSE_DEVICE_FLAGS_USHIFT (BSE_OBJECT_FLAGS_USHIFT + 3)
-
-
/* --- BseDevice structs --- */
typedef struct _BseDevice BseDevice;
typedef struct _BseDeviceClass BseDeviceClass;
@@ -63,8 +56,6 @@ typedef struct {
gchar *device_group; /* usually NULL */
gchar *device_error; /* if device_name == NULL */
} BseDeviceEntry;
-
-
/* --- prototypes --- */
void bse_device_class_setup (gpointer klass,
gint rating,
@@ -117,8 +108,5 @@ BseDevice* bse_device_open_auto (GType base_type,
gpointer data),
gpointer data,
BseErrorType *errorp);
-
-
G_END_DECLS
-
#endif /* __BSE_DEVICE_H__ */
diff --git a/bse/bseeditablesample.cc b/bse/bseeditablesample.cc
index 160749b..e311109 100644
--- a/bse/bseeditablesample.cc
+++ b/bse/bseeditablesample.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseeditablesample.hh"
-
#include "bsemain.hh"
#include "bsestorage.hh"
#include "gsldatahandle.hh"
-
-
/* --- structures --- */
typedef struct _Notify Notify;
struct _Notify
@@ -13,91 +10,70 @@ struct _Notify
Notify *next;
BseEditableSample *esample;
};
-
-
/* --- prototypes --- */
static void bse_editable_sample_init (BseEditableSample *self);
static void bse_editable_sample_class_init (BseEditableSampleClass *klass);
static void bse_editable_sample_dispose (GObject *object);
static void bse_editable_sample_finalize (GObject *object);
-
-
/* --- variables --- */
static void *parent_class = NULL;
static uint signal_changed = 0;
static Notify *changed_notify_list = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseEditableSample)
{
static const GTypeInfo editable_sample_info = {
sizeof (BseEditableSampleClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_editable_sample_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_editable */,
-
sizeof (BseEditableSample),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_editable_sample_init,
};
-
g_assert (BSE_EDITABLE_SAMPLE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BseEditableSample",
"Editable sample type",
__FILE__, __LINE__,
&editable_sample_info);
}
-
static void
bse_editable_sample_class_init (BseEditableSampleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->dispose = bse_editable_sample_dispose;
gobject_class->finalize = bse_editable_sample_finalize;
-
signal_changed = bse_object_class_add_signal (object_class, "changed",
G_TYPE_NONE, 0);
}
-
static void
bse_editable_sample_init (BseEditableSample *self)
{
self->wchunk = NULL;
}
-
static void
bse_editable_sample_dispose (GObject *object)
{
BseEditableSample *self = BSE_EDITABLE_SAMPLE (object);
-
bse_editable_sample_set_wchunk (self, NULL);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_editable_sample_finalize (GObject *object)
{
BseEditableSample *self = BSE_EDITABLE_SAMPLE (object);
Notify *notify, *last = NULL;
-
for (notify = changed_notify_list; notify; )
{
if (notify->esample == self)
{
Notify *tmp;
-
if (last)
last->next = notify->next;
else
@@ -112,38 +88,29 @@ bse_editable_sample_finalize (GObject *object)
notify = last->next;
}
}
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
-
g_return_if_fail (self->wchunk == NULL);
}
-
static gboolean
changed_notify_handler (void *editable)
{
BSE_THREADS_ENTER ();
-
while (changed_notify_list)
{
Notify *notify = changed_notify_list;
-
changed_notify_list = notify->next;
if (!BSE_OBJECT_DISPOSING (notify->esample))
g_signal_emit (notify->esample, signal_changed, 0);
g_free (notify);
}
-
BSE_THREADS_LEAVE ();
-
return FALSE;
}
-
static void
changed_notify_add (BseEditableSample *self)
{
Notify *notify;
-
if (!changed_notify_list)
bse_idle_notify (changed_notify_handler, NULL);
for (notify = changed_notify_list; notify; notify = notify->next)
@@ -154,13 +121,11 @@ changed_notify_add (BseEditableSample *self)
notify->next = changed_notify_list;
changed_notify_list = notify;
}
-
void
bse_editable_sample_set_wchunk (BseEditableSample *self,
GslWaveChunk *wchunk)
{
g_return_if_fail (BSE_IS_EDITABLE_SAMPLE (self));
-
if (self->wchunk)
{
if (self->open_count)
diff --git a/bse/bseeditablesample.hh b/bse/bseeditablesample.hh
index b8d036f..aae7b64 100644
--- a/bse/bseeditablesample.hh
+++ b/bse/bseeditablesample.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_EDITABLE_SAMPLE_H__
#define __BSE_EDITABLE_SAMPLE_H__
-
#include <bse/bsesuper.hh>
#include <bse/gslwavechunk.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_EDITABLE_SAMPLE (BSE_TYPE_ID (BseEditableSample))
#define BSE_EDITABLE_SAMPLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_EDITABLE_SAMPLE, BseEditableSample))
@@ -17,35 +13,24 @@ extern "C" {
#define BSE_IS_EDITABLE_SAMPLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_EDITABLE_SAMPLE))
#define BSE_IS_EDITABLE_SAMPLE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_EDITABLE_SAMPLE))
#define BSE_EDITABLE_SAMPLE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_EDITABLE_SAMPLE, BseEditableSampleClass))
-
-
/* --- object flagss --- */
#define BSE_EDITABLE_SAMPLE_OPENED(obj) (BSE_EDITABLE_SAMPLE (obj)->open_count > 0)
#define BSE_EDITABLE_SAMPLE_FLAGS_USHIFT (BSE_ITEM_FLAGS_USHIFT + 0)
-
-
/* --- structures --- */
struct _BseEditableSample
{
BseItem parent_object;
-
guint open_count;
GslWaveChunk *wchunk;
};
struct _BseEditableSampleClass
{
BseItemClass parent_class;
-
void (*changed) (BseEditableSample *sample);
};
-
void bse_editable_sample_set_wchunk (BseEditableSample *self,
GslWaveChunk *wchunk);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_EDITABLE_SAMPLE_H__ */
diff --git a/bse/bseeditablesample.proc b/bse/bseeditablesample.proc
index 7853c5d..6313ffd 100644
--- a/bse/bseeditablesample.proc
+++ b/bse/bseeditablesample.proc
@@ -3,12 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bseeditablesample.hh>
#include <bse/gsldatahandle.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseEditableSample, open) {
HELP = ("Open the sample for reading.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -23,11 +19,9 @@ METHOD (BseEditableSample, open) {
/* extract parameter values */
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!esample->wchunk)
error = BSE_ERROR_WAVE_NOT_FOUND;
@@ -42,13 +36,10 @@ METHOD (BseEditableSample, open) {
if (!error)
esample->open_count++;
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, close) {
HELP = ("Close an opened sample.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -59,19 +50,15 @@ METHOD (BseEditableSample, close) {
{
/* extract parameter values */
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample) || !esample->wchunk || !esample->open_count)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
esample->open_count--;
if (!esample->open_count)
gsl_wave_chunk_close (esample->wchunk);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, get-length) {
HELP = ("Return the number of values in the sample.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -85,19 +72,15 @@ METHOD (BseEditableSample, get-length) {
/* extract parameter values */
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
GslDataCache *dcache = NULL;
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
dcache = esample->wchunk->dcache;
sfi_value_set_int (out_values++, dcache ? gsl_data_handle_length (dcache->dhandle) : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, get-n-channels) {
HELP = ("Return the number of channels in the sample.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -110,17 +93,13 @@ METHOD (BseEditableSample, get-n-channels) {
{
/* extract parameter values */
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, esample->wchunk ? esample->wchunk->n_channels : 1);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, get-osc-freq) {
HELP = ("Return the oscillator frequency for the sample.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -133,17 +112,13 @@ METHOD (BseEditableSample, get-osc-freq) {
{
/* extract parameter values */
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_real (out_values++, esample->wchunk ? esample->wchunk->osc_freq : BSE_KAMMER_FREQUENCY);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, read-samples) {
HELP = ("Read a set of samples from a specific offset.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -160,11 +135,9 @@ METHOD (BseEditableSample, read-samples) {
guint voffset = sfi_value_get_int (in_values++);
GslDataCache *dcache = NULL;
SfiFBlock *fblock;
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample))
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
dcache = esample->wchunk->dcache;
if (!dcache || voffset >= gsl_data_handle_length (dcache->dhandle))
@@ -173,7 +146,6 @@ METHOD (BseEditableSample, read-samples) {
{
GslDataCacheNode *dnode = (GslDataCacheNode*) gsl_data_cache_ref_node (dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
guint i, l, dnode_length = dcache->node_size;
-
l = dnode_length - (voffset - dnode->offset) + dcache->padding;
l = MIN (l, gsl_data_handle_length (dcache->dhandle) - voffset);
fblock = sfi_fblock_new_sized (l);
@@ -181,13 +153,10 @@ METHOD (BseEditableSample, read-samples) {
fblock->values[i] = dnode->data[voffset - dnode->offset + i];
gsl_data_cache_unref_node (dcache, dnode);
}
-
/* set output parameters */
sfi_value_take_fblock (out_values++, fblock);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseEditableSample, collect-stats) {
HELP = ("Collect statistics from sample blocks as (minimum, maximum) pairs.");
IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
@@ -216,11 +185,9 @@ METHOD (BseEditableSample, collect-stats) {
guint max_pairs = sfi_value_get_int (in_values++);
GslDataCache *dcache = NULL;
SfiFBlock *fblock;
-
/* check parameters */
if (!BSE_IS_EDITABLE_SAMPLE (esample) || stepping < 1)
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
dcache = esample->wchunk->dcache;
if (!dcache || voffset + block_size > gsl_data_handle_length (dcache->dhandle))
@@ -229,22 +196,18 @@ METHOD (BseEditableSample, collect-stats) {
{
GslDataCacheNode *dnode = gsl_data_cache_ref_node (dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
guint j, dnode_length = dcache->node_size;
-
fblock = sfi_fblock_new_sized (max_pairs * 2);
for (j = 0; j < max_pairs; j++)
{
guint i, cur_offset = j * offs_scale;
gfloat min = +1, max = -1;
-
/* keep alignment across offset scaling */
cur_offset /= stepping;
cur_offset = voffset + cur_offset * stepping;
-
/* collect stats for one block */
for (i = cur_offset; i < cur_offset + block_size; i += stepping)
{
guint pos;
-
if (i < dnode->offset || i >= dnode->offset + dnode_length)
{
gsl_data_cache_unref_node (dcache, dnode);
@@ -264,9 +227,7 @@ METHOD (BseEditableSample, collect-stats) {
break_loops:
sfi_fblock_resize (fblock, j * 2);
}
-
/* set output parameters */
sfi_value_take_fblock (out_values++, fblock);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bseengine.cc b/bse/bseengine.cc
index ad939af..10e37c1 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -6,11 +6,8 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-
-
static SFI_MSG_TYPE_DEFINE (debug_engine, "engine", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_engine, __VA_ARGS__)
-
/* some systems don't have ERESTART (which is what linux returns for system
* calls on pipes which are being interrupted). most probably just use EINTR,
* and maybe some can return both. so we check for both in the below code,
@@ -19,12 +16,8 @@ static SFI_MSG_TYPE_DEFINE (debug_engine, "engine", SFI_MSG_DEBUG, NULL);
#ifndef ERESTART
#define ERESTART EINTR
#endif
-
-
/* --- prototypes --- */
static void wakeup_master (void);
-
-
/* --- UserThread --- */
/**
* @param klass the BseModuleClass which determines the module's behaviour
@@ -42,7 +35,6 @@ bse_module_new (const BseModuleClass *klass,
{
EngineNode *node;
guint i;
-
g_return_val_if_fail (klass != NULL, NULL);
g_return_val_if_fail (klass->process != NULL || klass->process_defer != NULL, NULL);
if (klass->process_defer)
@@ -50,16 +42,13 @@ bse_module_new (const BseModuleClass *klass,
g_warning ("%s: Delay cycle processing not yet implemented", G_STRLOC);
return NULL;
}
-
node = sfi_new_struct0 (EngineNode, 1);
-
/* setup BseModule */
node->module.klass = klass;
node->module.user_data = user_data;
node->module.istreams = klass->n_istreams ? sfi_new_struct0 (BseIStream, ENGINE_NODE_N_ISTREAMS (node)) : NULL;
node->module.jstreams = klass->n_jstreams ? sfi_new_struct0 (BseJStream, ENGINE_NODE_N_JSTREAMS (node)) : NULL;
node->module.ostreams = _engine_alloc_ostreams (ENGINE_NODE_N_OSTREAMS (node));
-
/* setup EngineNode */
node->inputs = ENGINE_NODE_N_ISTREAMS (node) ? sfi_new_struct0 (EngineInput, ENGINE_NODE_N_ISTREAMS (node)) : NULL;
node->jinputs = ENGINE_NODE_N_JSTREAMS (node) ? sfi_new_struct0 (EngineJInput*, ENGINE_NODE_N_JSTREAMS (node)) : NULL;
@@ -73,10 +62,8 @@ bse_module_new (const BseModuleClass *klass,
node->boundary_jobs = NULL;
node->probe_jobs = NULL;
node->tjob_head = node->tjob_tail = NULL;
-
return &node->module;
}
-
/**
* @param module a BSE Engine Module
* @return the module's tick stamp, indicating its process status
@@ -91,10 +78,8 @@ guint64
bse_module_tick_stamp (BseModule *module)
{
g_return_val_if_fail (module != NULL, 0);
-
return ENGINE_NODE (module)->counter;
}
-
/**
* @param module a BSE Engine Module
* @param istream Index of input stream
@@ -115,10 +100,8 @@ bse_module_has_source (BseModule *module,
{
g_return_val_if_fail (module != NULL, FALSE);
g_return_val_if_fail (istream < module->klass->n_istreams, FALSE);
-
return ENGINE_NODE (module)->inputs[istream].src_node != NULL;
}
-
/**
* @param module a BSE Engine Module
* @return whether the module is scheduled
@@ -136,7 +119,6 @@ bse_module_is_scheduled (BseModule *module)
EngineNode *node = ENGINE_NODE (module);
return ENGINE_NODE_IS_INTEGRATED (node) && ENGINE_NODE_IS_SCHEDULED (node);
}
-
/**
* @param module The module to integrate
* @return New job suitable for bse_trans_add()
@@ -148,17 +130,13 @@ BseJob*
bse_job_integrate (BseModule *module)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_INTEGRATE;
job->data.node = ENGINE_NODE (module);
job->data.free_with_job = TRUE;
-
return job;
}
-
/**
* @param module The module to discard
* @return New job suitable for bse_trans_add()
@@ -171,16 +149,12 @@ BseJob*
bse_job_discard (BseModule *module)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_DISCARD;
job->data.node = ENGINE_NODE (module);
-
return job;
}
-
/**
* @param module Module with input streams
* @return New job suitable for bse_trans_add()
@@ -193,16 +167,12 @@ BseJob*
bse_job_kill_inputs (BseModule *module)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_KILL_INPUTS;
job->data.node = ENGINE_NODE (module);
-
return job;
}
-
/**
* @param module Module with output streams
* @return New job suitable for bse_trans_add()
@@ -215,16 +185,12 @@ BseJob*
bse_job_kill_outputs (BseModule *module)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_KILL_OUTPUTS;
job->data.node = ENGINE_NODE (module);
-
return job;
}
-
/**
* @param src_module Module with output stream
* @param src_ostream Index of output stream of @a src_module
@@ -245,22 +211,18 @@ bse_job_connect (BseModule *src_module,
guint dest_istream)
{
BseJob *job;
-
g_return_val_if_fail (src_module != NULL, NULL);
g_return_val_if_fail (src_ostream < src_module->klass->n_ostreams, NULL);
g_return_val_if_fail (dest_module != NULL, NULL);
g_return_val_if_fail (dest_istream < dest_module->klass->n_istreams, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_ICONNECT;
job->connection.dest_node = ENGINE_NODE (dest_module);
job->connection.dest_ijstream = dest_istream;
job->connection.src_node = ENGINE_NODE (src_module);
job->connection.src_ostream = src_ostream;
-
return job;
}
-
/**
* @param src_module Module with output stream
* @param src_ostream Index of output stream of @a src_module
@@ -280,22 +242,18 @@ bse_job_jconnect (BseModule *src_module,
guint dest_jstream)
{
BseJob *job;
-
g_return_val_if_fail (src_module != NULL, NULL);
g_return_val_if_fail (src_ostream < src_module->klass->n_ostreams, NULL);
g_return_val_if_fail (dest_module != NULL, NULL);
g_return_val_if_fail (dest_jstream < dest_module->klass->n_jstreams, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_JCONNECT;
job->connection.dest_node = ENGINE_NODE (dest_module);
job->connection.dest_ijstream = dest_jstream;
job->connection.src_node = ENGINE_NODE (src_module);
job->connection.src_ostream = src_ostream;
-
return job;
}
-
/**
* @param dest_module Module with connected input stream
* @param dest_istream Index of input stream of @a dest_module
@@ -311,20 +269,16 @@ bse_job_disconnect (BseModule *dest_module,
guint dest_istream)
{
BseJob *job;
-
g_return_val_if_fail (dest_module != NULL, NULL);
g_return_val_if_fail (dest_istream < dest_module->klass->n_istreams, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_IDISCONNECT;
job->connection.dest_node = ENGINE_NODE (dest_module);
job->connection.dest_ijstream = dest_istream;
job->connection.src_node = NULL;
job->connection.src_ostream = ~0;
-
return job;
}
-
/**
* @param dest_module Module with connected input stream
* @param dest_jstream Index of input stream of @a dest_module
@@ -347,38 +301,30 @@ bse_job_jdisconnect (BseModule *dest_module,
guint src_ostream)
{
BseJob *job;
-
g_return_val_if_fail (dest_module != NULL, NULL);
g_return_val_if_fail (dest_jstream < dest_module->klass->n_jstreams, NULL);
g_return_val_if_fail (src_module != NULL, NULL);
g_return_val_if_fail (src_ostream < src_module->klass->n_ostreams, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_JDISCONNECT;
job->connection.dest_node = ENGINE_NODE (dest_module);
job->connection.dest_ijstream = dest_jstream;
job->connection.src_node = ENGINE_NODE (src_module);
job->connection.src_ostream = src_ostream;
-
return job;
}
-
BseJob*
bse_job_set_consumer (BseModule *module,
gboolean is_toplevel_consumer)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (ENGINE_MODULE_IS_VIRTUAL (module) == FALSE, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = is_toplevel_consumer ? ENGINE_JOB_SET_CONSUMER : ENGINE_JOB_UNSET_CONSUMER;
job->data.node = ENGINE_NODE (module);
-
return job;
}
-
/**
* @param module The module to be reset
* @return New job suitable for bse_trans_add()
@@ -396,16 +342,12 @@ BseJob*
bse_job_force_reset (BseModule *module)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_FORCE_RESET;
job->data.node = ENGINE_NODE (module);
-
return job;
}
-
/**
* \fn BseEngineAccessFunc
* @param module Module to operate on
@@ -436,20 +378,16 @@ bse_job_access (BseModule *module,
BseFreeFunc free_func)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (access_func != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_ACCESS;
job->access.node = ENGINE_NODE (module);
job->access.access_func = access_func;
job->access.data = data;
job->access.free_func = free_func;
-
return job;
}
-
/**
* @param data Data passed in to the free_func
* @param free_func Function to free @a data (executed in user thread)
@@ -464,19 +402,16 @@ bse_engine_add_user_callback (gpointer data,
BseFreeFunc free_func)
{
g_return_if_fail (free_func != NULL);
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_ACCESS;
job->access.node = NULL;
job->access.access_func = NULL;
job->access.data = data;
job->access.free_func = free_func;
-
BseTrans *trans = bse_trans_open();
bse_trans_add (trans, job);
bse_trans_dismiss (trans);
}
-
/**
* \fn BseEngineProbeFunc
* @param data user data passed in to bse_job_probe_request()
@@ -495,7 +430,6 @@ bse_engine_add_user_callback (gpointer data,
* Note that output streams with FALSE connected flags will not contain valid
* data in their value blocks.
*/
-
/**
* @param module The module to access
* @param probe_func Function invoked with @a data in the user thread
@@ -524,7 +458,6 @@ bse_job_probe_request (BseModule *module,
g_return_val_if_fail (module != NULL, NULL);
EngineNode *node = ENGINE_NODE (module);
g_return_val_if_fail (probe_func != NULL, NULL);
-
EngineTimedJob *tjob = (EngineTimedJob*) g_malloc0 (sizeof (tjob->probe));
tjob->type = ENGINE_JOB_PROBE_JOB;
tjob->tick_stamp = 0;
@@ -532,15 +465,12 @@ bse_job_probe_request (BseModule *module,
tjob->probe.probe_func = probe_func;
tjob->probe.n_ostreams = ENGINE_NODE_N_OSTREAMS (node);
tjob->probe.ostreams = _engine_alloc_ostreams (ENGINE_NODE_N_OSTREAMS (node));
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_PROBE_JOB;
job->timed_job.node = ENGINE_NODE (module);
job->timed_job.tjob = tjob;
-
return job;
}
-
/**
* @param module The module to access
* @param tick_stamp Engine time stamp
@@ -567,27 +497,22 @@ bse_job_flow_access (BseModule *module,
BseFreeFunc free_func)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (ENGINE_MODULE_IS_VIRTUAL (module) == FALSE, NULL);
g_return_val_if_fail (tick_stamp < GSL_MAX_TICK_STAMP, NULL);
g_return_val_if_fail (access_func != NULL, NULL);
-
EngineTimedJob *tjob = (EngineTimedJob*) g_malloc0 (sizeof (tjob->access));
tjob->type = ENGINE_JOB_FLOW_JOB;
tjob->tick_stamp = tick_stamp;
tjob->access.free_func = free_func;
tjob->access.data = data;
tjob->access.access_func = access_func;
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_FLOW_JOB;
job->timed_job.node = ENGINE_NODE (module);
job->timed_job.tjob = tjob;
-
return job;
}
-
/**
* @param module The module to access
* @param tick_stamp Engine time stamp
@@ -613,27 +538,22 @@ bse_job_boundary_access (BseModule *module,
BseFreeFunc free_func)
{
BseJob *job;
-
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (ENGINE_MODULE_IS_VIRTUAL (module) == FALSE, NULL);
g_return_val_if_fail (tick_stamp < GSL_MAX_TICK_STAMP, NULL);
g_return_val_if_fail (access_func != NULL, NULL);
-
EngineTimedJob *tjob = (EngineTimedJob*) g_malloc0 (sizeof (tjob->access));
tjob->type = ENGINE_JOB_BOUNDARY_JOB;
tjob->tick_stamp = tick_stamp;
tjob->access.free_func = free_func;
tjob->access.data = data;
tjob->access.access_func = access_func;
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_BOUNDARY_JOB;
job->timed_job.node = ENGINE_NODE (module);
job->timed_job.tjob = tjob;
-
return job;
}
-
static void
bse_engine_boundary_discard (BseModule *module,
gpointer data)
@@ -642,7 +562,6 @@ bse_engine_boundary_discard (BseModule *module,
bse_trans_add (trans, bse_job_discard (module));
bse_trans_commit (trans);
}
-
/**
* @param module The module to access
* @return New job suitable for bse_trans_add()
@@ -659,22 +578,18 @@ BseJob*
bse_job_boundary_discard (BseModule *module)
{
g_return_val_if_fail (module != NULL, NULL);
-
EngineTimedJob *tjob = (EngineTimedJob*) g_malloc0 (sizeof (tjob->access));
tjob->type = ENGINE_JOB_BOUNDARY_JOB;
tjob->tick_stamp = 0;
tjob->access.free_func = NULL;
tjob->access.data = NULL;
tjob->access.access_func = bse_engine_boundary_discard;
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_BOUNDARY_JOB;
job->timed_job.node = ENGINE_NODE (module);
job->timed_job.tjob = tjob;
-
return job;
}
-
/**
* @param module Module not currently suspended
* @return New job suitable for bse_trans_add()
@@ -691,15 +606,12 @@ bse_job_suspend_now (BseModule *module)
{
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (ENGINE_MODULE_IS_VIRTUAL (module) == FALSE, NULL);
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_SUSPEND;
job->tick.node = ENGINE_NODE (module);
job->tick.stamp = GSL_MAX_TICK_STAMP;
-
return job;
}
-
/**
* @param module Module to resume
* @param tick_stamp Sample tick at which to resume @a module
@@ -722,15 +634,12 @@ bse_job_resume_at (BseModule *module,
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (ENGINE_MODULE_IS_VIRTUAL (module) == FALSE, NULL);
g_return_val_if_fail (tick_stamp < GSL_MAX_TICK_STAMP, NULL);
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_RESUME;
job->tick.node = ENGINE_NODE (module);
job->tick.stamp = tick_stamp;
-
return job;
}
-
/**
* \fn BseEnginePollFunc
* @param data Data of poll function
@@ -774,11 +683,9 @@ bse_job_add_poll (BseEnginePollFunc poll_func,
const GPollFD *fds)
{
BseJob *job;
-
g_return_val_if_fail (poll_func != NULL, NULL);
if (n_fds)
g_return_val_if_fail (fds != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_ADD_POLL;
job->poll.poll_func = poll_func;
@@ -786,10 +693,8 @@ bse_job_add_poll (BseEnginePollFunc poll_func,
job->poll.free_func = free_func;
job->poll.n_fds = n_fds;
job->poll.fds = (GPollFD*) g_memdup (fds, sizeof (fds[0]) * n_fds);
-
return job;
}
-
/**
* @param poll_func Poll function to remove
* @param data Data of poll function
@@ -804,9 +709,7 @@ bse_job_remove_poll (BseEnginePollFunc poll_func,
gpointer data)
{
BseJob *job;
-
g_return_val_if_fail (poll_func != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_REMOVE_POLL;
job->poll.poll_func = poll_func;
@@ -814,10 +717,8 @@ bse_job_remove_poll (BseEnginePollFunc poll_func,
job->poll.free_func = NULL;
job->poll.n_fds = 0;
job->poll.fds = NULL;
-
return job;
}
-
/**
* @param timer_func Timer function to add
* @param data Data of timer function
@@ -835,18 +736,14 @@ bse_job_add_timer (BseEngineTimerFunc timer_func,
BseFreeFunc free_func)
{
BseJob *job;
-
g_return_val_if_fail (timer_func != NULL, NULL);
-
job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_ADD_TIMER;
job->timer.timer_func = timer_func;
job->timer.data = data;
job->timer.free_func = free_func;
-
return job;
}
-
/**
* @param debug Debug message
* @return New job suitable for bse_trans_add()
@@ -860,13 +757,11 @@ BseJob*
bse_job_debug (const gchar *debug)
{
g_return_val_if_fail (debug != NULL, NULL);
-
BseJob *job = sfi_new_struct0 (BseJob, 1);
job->job_id = ENGINE_JOB_MESSAGE;
job->data.message = g_strdup (debug);
return job;
}
-
/**
* @return New job suitable for bse_trans_add()
*
@@ -885,7 +780,6 @@ bse_job_nop (void)
job->data.message = NULL;
return job;
}
-
/**
* @return Newly opened empty transaction
*
@@ -899,17 +793,13 @@ BseTrans*
bse_trans_open (void)
{
BseTrans *trans;
-
trans = sfi_new_struct0 (BseTrans, 1);
-
trans->jobs_head = NULL;
trans->jobs_tail = NULL;
trans->comitted = FALSE;
trans->cqt_next = NULL;
-
return trans;
}
-
/**
* @param trans Opened transaction
* @param job Job to add
@@ -925,14 +815,12 @@ bse_trans_add (BseTrans *trans,
g_return_if_fail (trans->comitted == FALSE);
g_return_if_fail (job != NULL);
g_return_if_fail (job->next == NULL);
-
if (trans->jobs_tail)
trans->jobs_tail->next = job;
else
trans->jobs_head = job;
trans->jobs_tail = job;
}
-
/**
* @param trans1 open transaction
* @param trans2 open transaction
@@ -951,7 +839,6 @@ bse_trans_merge (BseTrans *trans1,
g_return_val_if_fail (trans1->comitted == FALSE, trans2);
g_return_val_if_fail (trans2 != NULL, trans1);
g_return_val_if_fail (trans2->comitted == FALSE, trans1);
-
if (!trans1->jobs_head)
{
trans1->jobs_head = trans2->jobs_head;
@@ -969,7 +856,6 @@ bse_trans_merge (BseTrans *trans1,
bse_trans_dismiss (trans2);
return trans1;
}
-
/**
* @param trans open transaction
* @return tick stamp of job execution
@@ -987,7 +873,6 @@ bse_trans_commit (BseTrans *trans)
{
g_return_val_if_fail (trans != NULL, 0);
g_return_val_if_fail (trans->comitted == FALSE, 0);
-
guint64 exec_tick_stamp = 0;
if (trans->jobs_head)
{
@@ -999,14 +884,12 @@ bse_trans_commit (BseTrans *trans)
bse_trans_dismiss (trans);
return exec_tick_stamp;
}
-
typedef struct {
BseTrans *trans;
guint64 tick_stamp;
BirnetCond cond;
BirnetMutex mutex;
} DTrans;
-
static gboolean
dtrans_timer (gpointer timer_data,
guint64 stamp)
@@ -1031,7 +914,6 @@ dtrans_timer (gpointer timer_data,
}
return TRUE;
}
-
/**
* @param trans open transaction
* @param tick_stamp earliest stamp
@@ -1048,7 +930,6 @@ bse_trans_commit_delayed (BseTrans *trans,
{
g_return_if_fail (trans != NULL);
g_return_if_fail (trans->comitted == FALSE);
-
if (tick_stamp <= gsl_tick_stamp ())
bse_trans_commit (trans);
else
@@ -1069,7 +950,6 @@ bse_trans_commit_delayed (BseTrans *trans,
sfi_mutex_destroy (&data.mutex);
}
}
-
/**
* @param trans Opened transaction
*
@@ -1082,10 +962,8 @@ bse_trans_dismiss (BseTrans *trans)
{
g_return_if_fail (trans != NULL);
g_return_if_fail (trans->comitted == FALSE);
-
_engine_free_trans (trans);
}
-
/**
* @param job First job
* @param ... NULL terminated job list
@@ -1101,7 +979,6 @@ bse_transact (BseJob *job,
{
BseTrans *trans = bse_trans_open ();
va_list var_args;
-
va_start (var_args, job);
while (job)
{
@@ -1111,37 +988,30 @@ bse_transact (BseJob *job,
va_end (var_args);
bse_trans_commit (trans);
}
-
-
/* --- Virtual Modules --- */
static void
virtual_module_process (BseModule *module,
guint n_values)
{
guint i;
-
/* dumb pass-through task (FIXME: virtualization works without _process()) */
for (i = 0; i < BSE_MODULE_N_OSTREAMS (module); i++)
if (module->ostreams[i].connected)
module->ostreams[i].values = (gfloat*) module->istreams[i].values;
}
-
typedef struct {
BseModuleClass klass;
BseFreeFunc free_data;
} VirtualModuleClass;
-
static void
virtual_module_free (gpointer data,
const BseModuleClass *klass)
{
VirtualModuleClass *vclass = (VirtualModuleClass*) klass;
-
if (vclass->free_data)
vclass->free_data (data);
g_free (vclass);
}
-
/**
* @param n_iostreams number of input and output streams
* @param user_data user data, stored in module->user_data
@@ -1191,44 +1061,34 @@ bse_module_new_virtual (guint n_iostreams,
};
VirtualModuleClass *vclass;
BseModule *module;
-
g_return_val_if_fail (n_iostreams > 0, NULL);
-
vclass = (VirtualModuleClass*) g_memdup (&virtual_module_class, sizeof (virtual_module_class));
vclass->klass.n_istreams = n_iostreams;
vclass->klass.n_ostreams = n_iostreams;
vclass->free_data = free_data;
module = bse_module_new (&vclass->klass, user_data);
ENGINE_NODE (module)->virtual_node = TRUE;
-
return module;
}
-
-
/* --- initialization --- */
static void
slave (gpointer data)
{
gboolean run = TRUE;
-
while (run)
{
BseTrans *trans = bse_trans_open ();
gchar *str = g_strdup_printf ("SLAVE(%p): idle", g_thread_self ());
-
bse_trans_add (trans, bse_job_debug (str));
g_free (str);
bse_trans_add (trans, bse_job_debug ("string2"));
bse_trans_commit (trans);
-
trans = bse_trans_open ();
bse_trans_add (trans, bse_job_debug ("trans2"));
bse_trans_commit (trans);
-
g_usleep (1000*500);
}
}
-
/* --- setup & trigger --- */
static gboolean bse_engine_initialized = FALSE;
static gboolean bse_engine_threaded = FALSE;
@@ -1237,7 +1097,6 @@ static EngineMasterData master_data;
guint bse_engine_exvar_block_size = 0;
guint bse_engine_exvar_sample_freq = 0;
guint bse_engine_exvar_control_mask = 0;
-
/**
* @param latency_ms calculation latency in milli seconds
* @param sample_freq mixing frequency
@@ -1263,7 +1122,6 @@ bse_engine_constrain (guint latency_ms,
guint *control_raster_p)
{
g_return_if_fail (sample_freq >= 100);
-
/* depending on how stable the overall system (cpu, kernel scheduler, etc.)
* behaves, calculating a single block may take longer than expected,
* block_jitter is meant to compensate for that. for an expected worst case
@@ -1308,7 +1166,6 @@ bse_engine_constrain (guint latency_ms,
if (control_raster_p)
*control_raster_p = control_raster;
}
-
/**
* @param latency_ms calculation latency in milli seconds
* @param sample_freq mixing frequency
@@ -1331,18 +1188,15 @@ bse_engine_configure (guint latency_ms,
BseTrans *trans;
BseJob *job;
g_return_val_if_fail (bse_engine_initialized == TRUE, FALSE);
-
bse_engine_constrain (latency_ms, sample_freq, control_freq, &block_size, &control_raster);
/* optimize */
if (0 && block_size == bse_engine_block_size() && control_raster == bse_engine_control_raster())
return TRUE;
-
/* pseudo-sync first */
bse_engine_wait_on_trans();
/* paranoia checks */
if (_engine_mnl_head() || sync_lock)
return FALSE;
-
/* block master */
GSL_SPIN_LOCK (&sync_mutex);
job = sfi_new_struct0 (BseJob, 1);
@@ -1364,7 +1218,6 @@ bse_engine_configure (guint latency_ms,
while (!sync_lock)
sfi_cond_wait (&sync_cond, &sync_mutex);
GSL_SPIN_UNLOCK (&sync_mutex);
-
if (!_engine_mnl_head())
{
/* cleanup */
@@ -1379,7 +1232,6 @@ bse_engine_configure (guint latency_ms,
_gsl_tick_stamp_inc (); /* ensure stamp validity (>0 and systime mark) */
success = TRUE;
}
-
/* unblock master */
GSL_SPIN_LOCK (&sync_mutex);
sync_lock = FALSE;
@@ -1388,16 +1240,13 @@ bse_engine_configure (guint latency_ms,
/* ensure SYNC job got collected */
bse_engine_wait_on_trans();
bse_engine_user_thread_collect();
-
if (success)
DEBUG ("configured%s: mixfreq=%uHz bsize=%uvals craster=%u (cfreq=%f)",
bse_engine_threaded ? "(threaded)" : "",
bse_engine_sample_freq(), bse_engine_block_size(), bse_engine_control_raster(),
bse_engine_sample_freq() / (float) bse_engine_control_raster());
-
return success;
}
-
/**
* @param run_threaded whether the engine should be run threaded
*
@@ -1408,23 +1257,18 @@ void
bse_engine_init (gboolean run_threaded)
{
g_return_if_fail (bse_engine_initialized == FALSE);
-
bse_engine_initialized = TRUE;
-
/* assert correct implmentation of accessor macros defined in bsedefs.hh */
g_assert (&BSE_MODULE_GET_USER_DATA ((BseModule*) 42) == &((BseModule*) 42)->user_data);
g_assert (&BSE_MODULE_GET_ISTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->istreams);
g_assert (&BSE_MODULE_GET_JSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->jstreams);
g_assert (&BSE_MODULE_GET_OSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->ostreams);
-
/* initialize components */
bse_engine_reinit_utils();
/* first configure */
bse_engine_configure (50, 44100, 50);
-
/* then setup threading */
bse_engine_threaded = run_threaded;
-
if (bse_engine_threaded)
{
gint err = pipe (master_data.wakeup_pipe);
@@ -1452,7 +1296,6 @@ bse_engine_init (gboolean run_threaded)
sfi_thread_run ("DSP #2", slave, NULL);
}
}
-
static void
wakeup_master (void)
{
@@ -1465,13 +1308,11 @@ wakeup_master (void)
while (l < 0 && (errno == EINTR || errno == ERESTART));
}
}
-
gboolean
bse_engine_prepare (BseEngineLoop *loop)
{
g_return_val_if_fail (loop != NULL, FALSE);
g_return_val_if_fail (bse_engine_initialized == TRUE, FALSE);
-
if (!bse_engine_threaded)
return _engine_master_prepare (loop) || bse_engine_has_garbage ();
else
@@ -1483,20 +1324,17 @@ bse_engine_prepare (BseEngineLoop *loop)
return bse_engine_has_garbage ();
}
}
-
gboolean
bse_engine_check (const BseEngineLoop *loop)
{
g_return_val_if_fail (loop != NULL, FALSE);
if (loop->n_fds)
g_return_val_if_fail (loop->revents_filled == TRUE, FALSE);
-
if (!bse_engine_threaded)
return _engine_master_check (loop) || bse_engine_has_garbage ();
else
return bse_engine_has_garbage ();
}
-
/**
*
* Perform necessary work the engine has to handle
@@ -1511,14 +1349,11 @@ void
bse_engine_dispatch (void)
{
g_return_if_fail (bse_engine_initialized == TRUE);
-
if (!bse_engine_threaded)
_engine_master_dispatch ();
-
if (bse_engine_has_garbage ()) /* prevent extra mutex locking */
bse_engine_user_thread_collect ();
}
-
BirnetThread**
bse_engine_get_threads (guint *n_threads)
{
@@ -1533,7 +1368,6 @@ bse_engine_get_threads (guint *n_threads)
t[0] = master_thread;
return t;
}
-
/**
* @param systime System time in micro seconds.
* @return Engine tick stamp value
@@ -1548,11 +1382,9 @@ bse_engine_tick_stamp_from_systime (guint64 systime)
{
GslTickStampUpdate ustamp = gsl_tick_stamp_last ();
guint64 tick_stamp;
-
/* FIXME: we should add special guards here
* for sfi_time_system() - ustamp.system_time ~> (44100 / bse_engine_block_size ())
*/
-
if (systime > ustamp.system_time)
{
tick_stamp = systime - ustamp.system_time;
@@ -1565,7 +1397,6 @@ bse_engine_tick_stamp_from_systime (guint64 systime)
tick_stamp = tick_stamp * bse_engine_sample_freq () / 1000000;
tick_stamp = ustamp.tick_stamp - MIN (tick_stamp, ustamp.tick_stamp);
}
-
#if 0
if (tick_stamp > 158760000)
g_error ("tick_stamp conversion problem:\n"
@@ -1580,10 +1411,8 @@ bse_engine_tick_stamp_from_systime (guint64 systime)
ustamp.system_time, ustamp.tick_stamp,
bse_engine_sample_freq ());
#endif
-
return tick_stamp;
}
-
/**
*
* Wait until all pending transactions have been processed
@@ -1596,16 +1425,12 @@ void
bse_engine_wait_on_trans (void)
{
g_return_if_fail (bse_engine_initialized == TRUE);
-
/* non-threaded */
if (!bse_engine_threaded)
_engine_master_dispatch_jobs ();
-
/* threaded */
_engine_wait_on_trans ();
-
/* call all free() functions */
bse_engine_user_thread_collect ();
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseengine.hh b/bse/bseengine.hh
index 77b4fee..1254924 100644
--- a/bse/bseengine.hh
+++ b/bse/bseengine.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENGINE_H__
#define __BSE_ENGINE_H__
-
#include <bse/bsedefs.hh>
-
G_BEGIN_DECLS
-
/* --- constants --- */
#define BSE_STREAM_MAX_VALUES (1024 /* power of 2 and <= 16384 */)
#define BSE_MODULE_N_OSTREAMS(module) ((module)->klass->n_ostreams)
@@ -18,8 +15,6 @@ G_BEGIN_DECLS
#define BSE_MODULE_JBUFFER(module, stream, con) (BSE_MODULE_JSTREAM ((module), (stream)).values[con])
#define BSE_MODULE_OBUFFER(module, stream) (BSE_MODULE_OSTREAM ((module), (stream)).values)
#define BSE_ENGINE_MAX_POLLFDS (128)
-
-
/* --- typedefs --- */
typedef struct _BseJob BseJob;
/* bsedefs.hh:
@@ -48,7 +43,6 @@ typedef guint (*BseProcessDeferFunc) (BseModule *module,
typedef void (*BseModuleResetFunc) (BseModule *module);
typedef void (*BseModuleFreeFunc) (gpointer data,
const BseModuleClass *klass);
-
typedef enum /*< skip >*/
{
BSE_COST_NORMAL = 0,
@@ -94,8 +88,6 @@ struct _BseOStream
gfloat *values;
gboolean connected;
};
-
-
/* --- interface (UserThread functions) --- */
BseModule* bse_module_new (const BseModuleClass *klass,
gpointer user_data);
@@ -171,10 +163,8 @@ void bse_trans_commit_delayed (BseTrans *trans,
void bse_trans_dismiss (BseTrans *trans);
void bse_transact (BseJob *job,
...) G_GNUC_NULL_TERMINATED;
-
/* --- module utilities (EngineThread functions) --- */
gfloat* bse_engine_const_values (gfloat value);
-
/* --- initialization & main loop --- */
void bse_engine_constrain (guint latency_ms,
guint sample_freq,
@@ -185,7 +175,6 @@ void bse_engine_init (gboolean threaded);
gboolean bse_engine_configure (guint latency_ms,
guint sample_freq,
guint control_freq);
-
/* --- miscellaneous --- */
gfloat* bse_engine_const_zeros (guint smaller_than_BSE_STREAM_MAX_VALUES);
gboolean bse_engine_has_garbage (void);
@@ -201,7 +190,6 @@ guint64 bse_engine_tick_stamp_from_systime (guint64 systime);
#define bse_engine_control_raster() (1 + (const guint) bse_engine_exvar_control_mask)
#define bse_engine_control_mask() (0 + (const guint) bse_engine_exvar_control_mask)
#define BSE_CONTROL_CHECK(index) ((bse_engine_control_mask() & (index)) == 0)
-
/* --- thread handling --- */
typedef struct
{
@@ -215,13 +203,9 @@ BirnetThread** bse_engine_get_threads (guint *n_threads
gboolean bse_engine_prepare (BseEngineLoop *loop);
gboolean bse_engine_check (const BseEngineLoop *loop);
void bse_engine_dispatch (void);
-
-
/*< private >*/
extern guint bse_engine_exvar_block_size;
extern guint bse_engine_exvar_sample_freq;
extern guint bse_engine_exvar_control_mask;
-
G_END_DECLS
-
#endif /* __BSE_ENGINE_H__ */
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index 431973b..ccb76f2 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -12,15 +12,11 @@
#include <sys/poll.h>
#include <sys/time.h>
#include <errno.h>
-
static SFI_MSG_TYPE_DEFINE (debug_job, "job", SFI_MSG_DEBUG, NULL);
#define JOB_DEBUG(...) sfi_debug (debug_job, __VA_ARGS__)
static SFI_MSG_TYPE_DEFINE (debug_tjob, "tjob", SFI_MSG_DEBUG, NULL);
#define TJOB_DEBUG(...) sfi_debug (debug_tjob, __VA_ARGS__)
-
#define NODE_FLAG_RECONNECT(node) G_STMT_START { /*(node)->needs_reset = TRUE*/; } G_STMT_END
-
-
/* --- time stamping (debugging) --- */
#define ToyprofStamp struct timeval
#define toyprof_clock_name() ("Glibc gettimeofday(2)")
@@ -35,8 +31,6 @@ toyprof_elapsed (ToyprofStamp fstamp,
guint64 last = lstamp.tv_sec * toyprof_stamp_ticks () + lstamp.tv_usec;
return last - first;
}
-
-
/* --- typedefs & structures --- */
typedef struct _Poll Poll;
struct _Poll
@@ -56,12 +50,8 @@ struct _Timer
gpointer data;
BseFreeFunc free_func;
};
-
-
/* --- prototypes --- */
static void master_schedule_discard (void);
-
-
/* --- variables --- */
static gboolean master_need_reflow = FALSE;
static gboolean master_need_process = FALSE;
@@ -75,25 +65,19 @@ static EngineSchedule *master_schedule = NULL;
static SfiRing *boundary_node_list = NULL;
static gboolean master_new_boundary_jobs = FALSE;
static SfiRing *probe_node_list = NULL;
-
-
/* --- node state functions --- */
static void
add_consumer (EngineNode *node)
{
g_return_if_fail (ENGINE_NODE_IS_CONSUMER (node) && node->toplevel_next == NULL && node->integrated);
-
node->toplevel_next = master_consumer_list;
master_consumer_list = node;
}
-
static void
remove_consumer (EngineNode *node)
{
EngineNode *tmp, *last = NULL;
-
g_return_if_fail (!ENGINE_NODE_IS_CONSUMER (node) || !node->integrated);
-
for (tmp = master_consumer_list; tmp; last = tmp, tmp = last->toplevel_next)
if (tmp == node)
break;
@@ -104,7 +88,6 @@ remove_consumer (EngineNode *node)
master_consumer_list = node->toplevel_next;
node->toplevel_next = NULL;
}
-
static void
propagate_update_suspend (EngineNode *node)
{
@@ -120,7 +103,6 @@ propagate_update_suspend (EngineNode *node)
propagate_update_suspend (node->jinputs[j][i].src_node);
}
}
-
static void
master_idisconnect_node (EngineNode *node,
guint istream)
@@ -128,10 +110,8 @@ master_idisconnect_node (EngineNode *node,
EngineNode *src_node = node->inputs[istream].src_node;
guint ostream = node->inputs[istream].src_stream;
gboolean was_consumer;
-
g_assert (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
-
node->inputs[istream].src_node = NULL;
node->inputs[istream].src_stream = ~0;
node->module.istreams[istream].connected = 0; /* scheduler update */
@@ -147,7 +127,6 @@ master_idisconnect_node (EngineNode *node,
if (!was_consumer && ENGINE_NODE_IS_CONSUMER (src_node))
add_consumer (src_node);
}
-
static void
master_jdisconnect_node (EngineNode *node,
guint jstream,
@@ -156,11 +135,9 @@ master_jdisconnect_node (EngineNode *node,
EngineNode *src_node = node->jinputs[jstream][con].src_node;
guint i, ostream = node->jinputs[jstream][con].src_stream;
gboolean was_consumer;
-
g_assert (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
node->module.jstreams[jstream].jcount > 0 &&
src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
-
i = --node->module.jstreams[jstream].jcount;
node->jinputs[jstream][con] = node->jinputs[jstream][i];
node->module.jstreams[jstream].values[i] = NULL; /* float**values 0-termination */
@@ -176,7 +153,6 @@ master_jdisconnect_node (EngineNode *node,
if (!was_consumer && ENGINE_NODE_IS_CONSUMER (src_node))
add_consumer (src_node);
}
-
static void
master_disconnect_node_outputs (EngineNode *src_node, EngineNode *dest_node)
{
@@ -188,8 +164,6 @@ master_disconnect_node_outputs (EngineNode *src_node, EngineNode *dest_node)
if (dest_node->jinputs[j][i].src_node == src_node)
master_jdisconnect_node (dest_node, j, i--);
}
-
-
/* --- timed job handling --- */
static inline void
insert_trash_job (EngineNode *node,
@@ -202,7 +176,6 @@ insert_trash_job (EngineNode *node,
node->tjob_head = tjob;
node->tjob_tail = tjob;
}
-
static inline EngineTimedJob*
node_pop_flow_job (EngineNode *node,
guint64 tick_stamp)
@@ -220,7 +193,6 @@ node_pop_flow_job (EngineNode *node,
}
return tjob;
}
-
static inline EngineTimedJob*
node_pop_boundary_job (EngineNode *node,
guint64 tick_stamp,
@@ -241,7 +213,6 @@ node_pop_boundary_job (EngineNode *node,
}
return tjob;
}
-
static inline EngineTimedJob*
insert_timed_job (EngineTimedJob *head,
EngineTimedJob *tjob)
@@ -261,7 +232,6 @@ insert_timed_job (EngineTimedJob *head,
head = tjob;
return head;
}
-
static inline guint64
node_peek_flow_job_stamp (EngineNode *node)
{
@@ -270,7 +240,6 @@ node_peek_flow_job_stamp (EngineNode *node)
return tjob->tick_stamp;
return GSL_MAX_TICK_STAMP;
}
-
static inline guint64
node_peek_boundary_job_stamp (EngineNode *node)
{
@@ -279,8 +248,6 @@ node_peek_boundary_job_stamp (EngineNode *node)
return tjob->tick_stamp;
return GSL_MAX_TICK_STAMP;
}
-
-
/* --- job processing --- */
static void
master_process_job (BseJob *job)
@@ -633,14 +600,12 @@ master_process_job (BseJob *job)
}
JOB_DEBUG ("done");
}
-
static void
master_poll_check (glong *timeout_p,
gboolean check_with_revents)
{
gboolean need_processing = FALSE;
Poll *poll;
-
if (master_need_process || *timeout_p == 0)
{
master_need_process = TRUE;
@@ -649,7 +614,6 @@ master_poll_check (glong *timeout_p,
for (poll = master_poll_list; poll; poll = poll->next)
{
glong timeout = -1;
-
if (poll->poll_func (poll->data, bse_engine_block_size (), &timeout,
poll->n_fds, poll->n_fds ? poll->fds : NULL, check_with_revents)
|| timeout == 0)
@@ -663,7 +627,6 @@ master_poll_check (glong *timeout_p,
}
master_need_process = need_processing;
}
-
static void
master_tick_stamp_inc (void)
{
@@ -692,13 +655,11 @@ master_tick_stamp_inc (void)
timer = next;
}
}
-
typedef enum {
PROBE_UNSCHEDULED,
PROBE_SCHEDULED,
PROBE_VIRTUAL /* scheduled */
} ProbeType;
-
static inline void
master_take_probes (EngineNode *node,
const guint64 current_stamp,
@@ -750,7 +711,6 @@ master_take_probes (EngineNode *node,
insert_trash_job (node, tjob);
_engine_node_collect_jobs (node);
}
-
static inline guint64
master_update_node_state (EngineNode *node,
guint64 max_tick)
@@ -779,7 +739,6 @@ master_update_node_state (EngineNode *node,
while (tjob);
return node_peek_flow_job_stamp (node);
}
-
static void
master_process_locked_node (EngineNode *node,
guint n_values)
@@ -788,9 +747,7 @@ master_process_locked_node (EngineNode *node,
guint64 next_counter, new_counter, final_counter = current_stamp + n_values;
guint i, j, diff;
bool needs_probe_reset = node->probe_jobs != NULL;
-
g_return_if_fail (node->integrated && node->sched_tag);
-
while (node->counter < final_counter)
{
/* call reset() and exec flow jobs */
@@ -805,7 +762,6 @@ master_process_locked_node (EngineNode *node,
for (i = 0; i < ENGINE_NODE_N_ISTREAMS (node); i++)
{
EngineNode *inode = node->inputs[i].real_node;
-
if (inode)
{
ENGINE_NODE_LOCK (inode);
@@ -823,7 +779,6 @@ master_process_locked_node (EngineNode *node,
for (i = 0; i < node->module.jstreams[j].n_connections; i++) /* assumes scheduled node */
{
EngineNode *inode = node->jinputs[j][i].real_node;
-
ENGINE_NODE_LOCK (inode);
if (inode->counter < final_counter)
master_process_locked_node (inode, final_counter - node->counter);
@@ -861,9 +816,7 @@ master_process_locked_node (EngineNode *node,
node->counter = new_counter;
}
}
-
static gboolean gsl_profile_modules = 0; /* set to 1 in gdb to get profile output */
-
static void
master_process_flow (void)
{
@@ -873,26 +826,19 @@ master_process_flow (void)
guint64 profile_maxtime = 0;
gboolean profile_modules = gsl_profile_modules;
EngineNode *profile_node = NULL;
-
g_return_if_fail (master_need_process == TRUE);
-
g_assert (bse_fpu_okround () == TRUE);
-
if (master_schedule)
{
_engine_schedule_restart (master_schedule);
_engine_set_schedule (master_schedule);
-
EngineNode *node = _engine_pop_unprocessed_node ();
while (node)
{
ToyprofStamp profile_stamp1, profile_stamp2;
-
if (UNLIKELY (profile_modules))
toyprof_stamp (profile_stamp1);
-
master_process_locked_node (node, n_values);
-
if (UNLIKELY (profile_modules))
{
toyprof_stamp (profile_stamp2);
@@ -903,11 +849,9 @@ master_process_flow (void)
profile_node = node;
}
}
-
_engine_push_processed_node (node);
node = _engine_pop_unprocessed_node ();
}
-
/* walk unscheduled nodes with flow jobs */
node = _engine_mnl_head ();
while (node && BSE_ENGINE_MNL_UNSCHEDULED_TJOB_NODE (node))
@@ -919,10 +863,8 @@ master_process_flow (void)
_engine_mnl_node_changed (node); /* collects trash jobs and reorders node */
node = tmp;
}
-
/* nothing new to process, wait for slaves */
_engine_wait_on_unprocessed ();
-
/* take remaining probes */
SfiRing *ring = probe_node_list;
while (ring)
@@ -936,7 +878,6 @@ master_process_flow (void)
else
master_take_probes (node, current_stamp, n_values, PROBE_SCHEDULED);
}
-
if (UNLIKELY (profile_modules))
{
if (profile_node)
@@ -949,21 +890,17 @@ master_process_flow (void)
profile_node, (long long unsigned int) profile_maxtime, profile_node->module.klass->process);
}
}
-
_engine_unset_schedule (master_schedule);
master_tick_stamp_inc ();
_engine_recycle_const_values (FALSE);
}
master_need_process = FALSE;
}
-
static void
master_reschedule_flow (void)
{
EngineNode *node;
-
g_return_if_fail (master_need_reflow == TRUE);
-
if (!master_schedule)
master_schedule = _engine_schedule_new ();
else
@@ -976,12 +913,10 @@ master_reschedule_flow (void)
_engine_schedule_secure (master_schedule);
master_need_reflow = FALSE;
}
-
static void
master_schedule_discard (void)
{
g_return_if_fail (master_need_reflow == TRUE);
-
if (master_schedule)
{
_engine_schedule_unsecure (master_schedule);
@@ -989,17 +924,13 @@ master_schedule_discard (void)
master_schedule = NULL;
}
}
-
-
/* --- MasterThread main loop --- */
gboolean
_engine_master_prepare (BseEngineLoop *loop)
{
gboolean need_dispatch;
guint i;
-
g_return_val_if_fail (loop != NULL, FALSE);
-
/* setup and clear pollfds here already, so master_poll_check() gets no junk (and IRIX can't handle non-0 revents) */
loop->fds_changed = master_pollfds_changed;
master_pollfds_changed = FALSE;
@@ -1008,7 +939,6 @@ _engine_master_prepare (BseEngineLoop *loop)
for (i = 0; i < loop->n_fds; i++)
loop->fds[i].revents = 0;
loop->revents_filled = FALSE;
-
loop->timeout = -1;
/* cached checks first */
need_dispatch = master_need_reflow || master_need_process;
@@ -1023,21 +953,17 @@ _engine_master_prepare (BseEngineLoop *loop)
}
if (need_dispatch)
loop->timeout = 0;
-
return need_dispatch;
}
-
gboolean
_engine_master_check (const BseEngineLoop *loop)
{
gboolean need_dispatch;
-
g_return_val_if_fail (loop != NULL, FALSE);
g_return_val_if_fail (loop->n_fds == master_n_pollfds, FALSE);
g_return_val_if_fail (loop->fds == master_pollfds, FALSE);
if (loop->n_fds)
g_return_val_if_fail (loop->revents_filled == TRUE, FALSE);
-
/* cached checks first */
need_dispatch = master_need_reflow || master_need_process;
/* lengthy query */
@@ -1047,14 +973,11 @@ _engine_master_check (const BseEngineLoop *loop)
if (!need_dispatch)
{
glong dummy = -1;
-
master_poll_check (&dummy, TRUE);
need_dispatch = master_need_process;
}
-
return need_dispatch;
}
-
void
_engine_master_dispatch_jobs (void)
{
@@ -1102,7 +1025,6 @@ _engine_master_dispatch_jobs (void)
}
while (master_new_boundary_jobs); /* new boundary jobs arrived */
}
-
void
_engine_master_dispatch (void)
{
@@ -1118,12 +1040,10 @@ _engine_master_dispatch (void)
if (master_need_process)
master_process_flow ();
}
-
void
bse_engine_master_thread (EngineMasterData *mdata)
{
bse_message_setup_thread_handler ();
-
/* assert pollfd equality, since we're simply casting structures */
BIRNET_STATIC_ASSERT (sizeof (struct pollfd) == sizeof (GPollFD));
BIRNET_STATIC_ASSERT (G_STRUCT_OFFSET (GPollFD, fd) == G_STRUCT_OFFSET (struct pollfd, fd));
@@ -1132,7 +1052,6 @@ bse_engine_master_thread (EngineMasterData *mdata)
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events));
BIRNET_STATIC_ASSERT (G_STRUCT_OFFSET (GPollFD, revents) == G_STRUCT_OFFSET (struct pollfd, revents));
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents));
-
/* add the thread wakeup pipe to master pollfds,
* so we get woken up in time.
*/
@@ -1140,16 +1059,12 @@ bse_engine_master_thread (EngineMasterData *mdata)
master_pollfds[0].events = G_IO_IN;
master_n_pollfds = 1;
master_pollfds_changed = TRUE;
-
toyprof_stampinit ();
-
while (!sfi_thread_aborted ()) /* also updates accounting information */
{
BseEngineLoop loop;
gboolean need_dispatch;
-
need_dispatch = _engine_master_prepare (&loop);
-
if (!need_dispatch)
{
gint err = poll ((struct pollfd*) loop.fds, loop.n_fds, loop.timeout);
@@ -1157,14 +1072,11 @@ bse_engine_master_thread (EngineMasterData *mdata)
loop.revents_filled = TRUE;
else if (errno != EINTR)
g_printerr ("%s: poll() error: %s\n", G_STRFUNC, g_strerror (errno));
-
if (loop.revents_filled)
need_dispatch = _engine_master_check (&loop);
}
-
if (need_dispatch)
_engine_master_dispatch ();
-
/* clear wakeup pipe */
{
guint8 data[64];
@@ -1173,11 +1085,9 @@ bse_engine_master_thread (EngineMasterData *mdata)
l = read (mdata->wakeup_pipe[0], data, sizeof (data));
while ((l < 0 && errno == EINTR) || l == sizeof (data));
}
-
/* wakeup user thread if necessary */
if (bse_engine_has_garbage ())
sfi_thread_wakeup (mdata->user_thread);
}
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseenginemaster.hh b/bse/bseenginemaster.hh
index cd77c59..9598222 100644
--- a/bse/bseenginemaster.hh
+++ b/bse/bseenginemaster.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENGINE_MASTER_H__
#define __BSE_ENGINE_MASTER_H__
-
#include <bse/bseengine.hh>
-
G_BEGIN_DECLS
-
/* --- internal (EngineThread) --- */
gboolean _engine_master_prepare (BseEngineLoop *loop);
gboolean _engine_master_check (const BseEngineLoop *loop);
@@ -16,7 +13,5 @@ typedef struct {
gint wakeup_pipe[2]; /* read(wakeup_pipe[0]), write(wakeup_pipe[1]) */
} EngineMasterData;
void bse_engine_master_thread (EngineMasterData *mdata);
-
G_END_DECLS
-
#endif /* __BSE_ENGINE_MASTER_H__ */
diff --git a/bse/bseenginenode.hh b/bse/bseenginenode.hh
index abb1bac..dac9e2e 100644
--- a/bse/bseenginenode.hh
+++ b/bse/bseenginenode.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENGINE_NODE_H__
#define __BSE_ENGINE_NODE_H__
-
#include "bseengine.hh"
#include "gslcommon.hh"
-
G_BEGIN_DECLS
-
#define ENGINE_NODE(module) ((EngineNode*) (module))
#define ENGINE_NODE_N_OSTREAMS(node) ((node)->module.klass->n_ostreams)
#define ENGINE_NODE_N_ISTREAMS(node) ((node)->module.klass->n_istreams)
@@ -23,12 +20,9 @@ G_BEGIN_DECLS
#define ENGINE_NODE_LOCK(node) sfi_rec_mutex_lock (&(node)->rec_mutex)
#define ENGINE_NODE_UNLOCK(node) sfi_rec_mutex_unlock (&(node)->rec_mutex)
#define ENGINE_MODULE_IS_VIRTUAL(mod) (ENGINE_NODE_IS_VIRTUAL (ENGINE_NODE (mod)))
-
-
/* --- typedefs --- */
typedef struct _EngineNode EngineNode;
typedef struct _EngineSchedule EngineSchedule;
-
/* --- transactions --- */
typedef union _EngineTimedJob EngineTimedJob;
typedef enum /*< skip >*/
@@ -139,8 +133,6 @@ union _EngineTimedJob
BseEngineAccessFunc access_func;
} access;
};
-
-
/* --- module nodes --- */
typedef struct
{
@@ -166,35 +158,28 @@ typedef struct
struct _EngineNode /* fields sorted by order of processing access */
{
BseModule module;
-
BirnetRecMutex rec_mutex; /* processing lock */
guint64 counter; /* <= GSL_TICK_STAMP */
EngineInput *inputs; /* [ENGINE_NODE_N_ISTREAMS()] */
EngineJInput **jinputs; /* [ENGINE_NODE_N_JSTREAMS()][jstream->jcount] */
EngineOutput *outputs; /* [ENGINE_NODE_N_OSTREAMS()] */
-
/* timed jobs */
EngineTimedJob *flow_jobs; /* active jobs */
EngineTimedJob *probe_jobs; /* probe requests */
EngineTimedJob *boundary_jobs; /* active jobs */
EngineTimedJob *tjob_head, *tjob_tail; /* trash list */
-
/* suspend/activation time */
guint64 next_active; /* result of suspend state updates */
-
/* master-node-list */
EngineNode *mnl_next;
EngineNode *mnl_prev;
guint integrated : 1;
guint virtual_node : 1;
-
guint is_consumer : 1;
-
/* suspension */
guint update_suspend : 1; /* whether suspend state needs updating */
guint in_suspend_call : 1; /* recursion barrier during suspend state updates */
guint needs_reset : 1; /* flagged at resumption */
-
/* scheduler */
guint cleared_ostreams : 1; /* whether ostream[].connected was cleared already */
guint sched_tag : 1; /* whether this node is contained in the schedule */
@@ -204,7 +189,5 @@ struct _EngineNode /* fields sorted by order of processing access */
EngineNode *toplevel_next; /* master-consumer-list, FIXME: overkill, using a SfiRing is good enough */
SfiRing *output_nodes; /* EngineNode* ring of nodes in ->outputs[] */
};
-
G_END_DECLS
-
#endif /* __BSE_ENGINE_NODE_H__ */
diff --git a/bse/bseengineschedule.cc b/bse/bseengineschedule.cc
index 9e0be68..2e53dd0 100644
--- a/bse/bseengineschedule.cc
+++ b/bse/bseengineschedule.cc
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseengineschedule.hh"
#include "bseengineutils.hh"
-
static SFI_MSG_TYPE_DEFINE (debug_sched, "sched", SFI_MSG_DEBUG, NULL);
-
/* --- prototypes --- */
static void schedule_node (EngineSchedule *schedule,
EngineNode *node,
@@ -14,14 +12,11 @@ static void schedule_cycle (EngineSchedule *schedule,
static void subschedule_query_node (EngineSchedule *schedule,
EngineNode *node,
EngineQuery *query);
-
-
/* --- functions --- */
EngineSchedule*
_engine_schedule_new (void)
{
EngineSchedule *sched = sfi_new_struct0 (EngineSchedule, 1);
-
sched->n_items = 0;
sched->leaf_levels = 0;
sched->nodes = NULL;
@@ -32,32 +27,26 @@ _engine_schedule_new (void)
sched->cur_node = NULL;
sched->cur_cycle = NULL;
sched->vnodes = NULL;
-
return sched;
}
-
static inline void
unschedule_virtual (EngineSchedule *sched, EngineNode *vnode)
{
g_return_if_fail (ENGINE_NODE_IS_SCHEDULED (vnode) == TRUE);
g_return_if_fail (sched->n_items > 0);
-
/* SCHED_DEBUG ("unschedule_virtual(%p)", vnode); */
sched->vnodes = sfi_ring_remove (sched->vnodes, vnode);
vnode->sched_tag = FALSE;
sched->n_items--;
}
-
static inline void
unschedule_node (EngineSchedule *sched, EngineNode *node)
{
guint leaf_level;
-
g_return_if_fail (ENGINE_NODE_IS_SCHEDULED (node) == TRUE);
leaf_level = node->sched_leaf_level;
g_return_if_fail (leaf_level <= sched->leaf_levels);
g_return_if_fail (sched->n_items > 0);
-
/* SCHED_DEBUG ("unschedule_node(%p,%u)", node, leaf_level); */
sched->nodes[leaf_level] = sfi_ring_remove (sched->nodes[leaf_level], node);
node->sched_leaf_level = 0;
@@ -66,19 +55,16 @@ unschedule_node (EngineSchedule *sched, EngineNode *node)
_engine_mnl_node_changed (node);
sched->n_items--;
}
-
static inline void
unschedule_cycle (EngineSchedule *sched,
SfiRing *ring)
{
guint leaf_level;
SfiRing *walk;
-
g_return_if_fail (ENGINE_NODE_IS_SCHEDULED (ENGINE_NODE (ring->data)) == TRUE);
leaf_level = ENGINE_NODE (ring->data)->sched_leaf_level;
g_return_if_fail (leaf_level <= sched->leaf_levels);
g_return_if_fail (sched->n_items > 0);
-
/* SCHED_DEBUG ("unschedule_cycle(%p,%u,%p)", ring->data, leaf_level, ring); */
sched->nodes[leaf_level] = sfi_ring_remove (sched->nodes[leaf_level], ring);
for (walk = ring; walk; walk = sfi_ring_walk (walk, ring))
@@ -93,7 +79,6 @@ unschedule_cycle (EngineSchedule *sched,
}
sched->n_items--;
}
-
static void
_engine_schedule_debug_dump (EngineSchedule *sched)
{
@@ -101,7 +86,6 @@ _engine_schedule_debug_dump (EngineSchedule *sched)
if (sched)
{
guint i;
-
g_printerr (" n_items=%u, n_vnodes=%u, leaf_levels=%u, secured=%u,\n",
sched->n_items, sfi_ring_length (sched->vnodes), sched->leaf_levels, sched->secured);
g_printerr (" in_pqueue=%u, cur_leaf_level=%u,\n",
@@ -111,7 +95,6 @@ _engine_schedule_debug_dump (EngineSchedule *sched)
for (i = 0; i < sched->leaf_levels; i++)
{
SfiRing *ring, *head = sched->nodes[i];
-
if (!head)
continue;
g_printerr (" { leaf_level=%u:", i);
@@ -129,17 +112,13 @@ _engine_schedule_debug_dump (EngineSchedule *sched)
}
g_printerr ("};\n");
}
-
-
void
_engine_schedule_clear (EngineSchedule *sched)
{
guint i;
-
g_return_if_fail (sched != NULL);
g_return_if_fail (sched->secured == FALSE);
g_return_if_fail (sched->in_pqueue == FALSE);
-
while (sched->vnodes)
unschedule_virtual (sched, (EngineNode*) sched->vnodes->data);
for (i = 0; i < sched->leaf_levels; i++)
@@ -151,30 +130,25 @@ _engine_schedule_clear (EngineSchedule *sched)
}
g_return_if_fail (sched->n_items == 0);
}
-
void
_engine_schedule_destroy (EngineSchedule *sched)
{
g_return_if_fail (sched != NULL);
g_return_if_fail (sched->secured == FALSE);
g_return_if_fail (sched->in_pqueue == FALSE);
-
_engine_schedule_clear (sched);
g_free (sched->nodes);
g_free (sched->cycles);
sfi_delete_struct (EngineSchedule, sched);
}
-
static void
_engine_schedule_grow (EngineSchedule *sched,
guint leaf_level)
{
guint ll = 1 << g_bit_storage (leaf_level); /* power2 growth alignment, ll >= leaf_level+1 */
-
if (sched->leaf_levels < ll)
{
guint i = sched->leaf_levels;
-
sched->leaf_levels = ll;
sched->nodes = g_renew (SfiRing*, sched->nodes, sched->leaf_levels);
sched->cycles = g_renew (SfiRing*, sched->cycles, sched->leaf_levels);
@@ -185,7 +159,6 @@ _engine_schedule_grow (EngineSchedule *sched,
}
}
}
-
static void
schedule_virtual (EngineSchedule *sched,
EngineNode *vnode)
@@ -195,7 +168,6 @@ schedule_virtual (EngineSchedule *sched,
g_return_if_fail (vnode != NULL);
g_return_if_fail (ENGINE_NODE_IS_VIRTUAL (vnode));
g_return_if_fail (!ENGINE_NODE_IS_SCHEDULED (vnode));
-
/* SCHED_DEBUG ("schedule_virtual(%p)", vnode); */
vnode->sched_tag = TRUE;
vnode->cleared_ostreams = FALSE;
@@ -209,7 +181,6 @@ schedule_virtual (EngineSchedule *sched,
/* _used_ virtual inputs are filled later on */
}
}
-
static void
schedule_node (EngineSchedule *sched,
EngineNode *node,
@@ -219,7 +190,6 @@ schedule_node (EngineSchedule *sched,
g_return_if_fail (sched->secured == FALSE);
g_return_if_fail (node != NULL);
g_return_if_fail (!ENGINE_NODE_IS_SCHEDULED (node));
-
/* SCHED_DEBUG ("schedule_node(%p,%u)", node, leaf_level); */
node->sched_leaf_level = leaf_level;
node->sched_tag = TRUE;
@@ -231,7 +201,6 @@ schedule_node (EngineSchedule *sched,
sched->nodes[leaf_level] = (ENGINE_NODE_IS_EXPENSIVE (node) ? sfi_ring_prepend : sfi_ring_append) (sched->nodes[leaf_level], node);
sched->n_items++;
}
-
static void
schedule_cycle (EngineSchedule *sched,
SfiRing *cycle_nodes,
@@ -241,7 +210,6 @@ schedule_cycle (EngineSchedule *sched,
g_return_if_fail (sched != NULL);
g_return_if_fail (sched->secured == FALSE);
g_return_if_fail (cycle_nodes != NULL);
-
for (walk = cycle_nodes; walk; walk = sfi_ring_walk (walk, cycle_nodes))
{
EngineNode *node = (EngineNode*) walk->data;
@@ -256,7 +224,6 @@ schedule_cycle (EngineSchedule *sched,
sched->cycles[leaf_level] = sfi_ring_prepend (sched->cycles[leaf_level], cycle_nodes);
sched->n_items++;
}
-
void
_engine_schedule_restart (EngineSchedule *sched)
{
@@ -265,7 +232,6 @@ _engine_schedule_restart (EngineSchedule *sched)
g_return_if_fail (sched->cur_leaf_level == sched->leaf_levels);
g_return_if_fail (sched->cur_node == NULL);
g_return_if_fail (sched->cur_cycle == NULL);
-
sched->cur_leaf_level = 0;
if (sched->leaf_levels > 0)
{
@@ -273,20 +239,16 @@ _engine_schedule_restart (EngineSchedule *sched)
sched->cur_cycle = sched->cycles[0];
}
}
-
void
_engine_schedule_secure (EngineSchedule *sched)
{
g_return_if_fail (sched != NULL);
g_return_if_fail (sched->secured == FALSE);
-
sched->secured = TRUE;
sched->cur_leaf_level = sched->leaf_levels;
-
if (sfi_msg_check (debug_sched))
_engine_schedule_debug_dump (sched);
}
-
static void
schedule_advance (EngineSchedule *sched)
{
@@ -300,7 +262,6 @@ schedule_advance (EngineSchedule *sched)
}
}
}
-
EngineNode*
_engine_schedule_pop_node (EngineSchedule *sched)
{
@@ -322,7 +283,6 @@ _engine_schedule_pop_node (EngineSchedule *sched)
/* nothing to hand out, either we're empty or still have cycles pending */
return NULL;
}
-
SfiRing*
_engine_schedule_pop_cycle (EngineSchedule *sched)
{
@@ -344,7 +304,6 @@ _engine_schedule_pop_cycle (EngineSchedule *sched)
/* nothing to hand out, either we're empty or still have nodes pending */
return NULL;
}
-
void
_engine_schedule_unsecure (EngineSchedule *sched)
{
@@ -354,40 +313,32 @@ _engine_schedule_unsecure (EngineSchedule *sched)
g_return_if_fail (sched->cur_leaf_level == sched->leaf_levels);
g_return_if_fail (sched->cur_node == NULL);
g_return_if_fail (sched->cur_cycle == NULL);
-
sched->secured = FALSE;
sched->cur_leaf_level = ~0;
}
-
void
_engine_schedule_consumer_node (EngineSchedule *schedule,
EngineNode *node)
{
EngineQuery query = { 0, };
-
g_return_if_fail (schedule != NULL);
g_return_if_fail (schedule->secured == FALSE);
g_return_if_fail (node != NULL);
g_return_if_fail (ENGINE_NODE_IS_CONSUMER (node));
g_return_if_fail (ENGINE_NODE_IS_VIRTUAL (node) == FALSE);
-
subschedule_query_node (schedule, node, &query);
g_assert (query.cycles == NULL); /* paranoid */
g_assert (query.cycle_nodes == NULL); /* paranoid */
schedule_node (schedule, node, query.leaf_level);
}
-
-
/* --- depth scheduling --- */
static gboolean
determine_suspension_reset (EngineNode *node)
{
g_return_val_if_fail (node->update_suspend == FALSE, FALSE);
g_return_val_if_fail (node->in_suspend_call == FALSE, FALSE);
-
if (!ENGINE_NODE_IS_VIRTUAL (node))
return node->needs_reset;
-
SfiRing *ring;
gboolean keep_state = FALSE;
node->in_suspend_call = TRUE;
@@ -398,10 +349,8 @@ determine_suspension_reset (EngineNode *node)
keep_state |= !determine_suspension_reset (dest_node);
}
node->in_suspend_call = FALSE;
-
return !keep_state;
}
-
static guint64
determine_suspension_state (EngineNode *node,
gboolean *seen_cycle_p,
@@ -443,7 +392,6 @@ determine_suspension_state (EngineNode *node,
*seen_cycle_p = *seen_cycle_p || seen_cycle;
return stamp;
}
-
static inline void
update_suspension_state (EngineNode *node)
{
@@ -460,7 +408,6 @@ update_suspension_state (EngineNode *node)
}
}
}
-
static SfiRing*
merge_untagged_node_lists_uniq (SfiRing *ring1,
SfiRing *ring2)
@@ -500,7 +447,6 @@ merge_untagged_node_lists_uniq (SfiRing *ring1,
sfi_ring_free (ring2);
return ring1;
}
-
static gboolean
resolve_cycle (EngineCycle *cycle,
EngineNode *node,
@@ -517,7 +463,6 @@ resolve_cycle (EngineCycle *cycle,
cycle->last = NULL;
return TRUE;
}
-
static gboolean
master_resolve_cycles (EngineQuery *query,
EngineNode *node)
@@ -545,20 +490,17 @@ master_resolve_cycles (EngineQuery *query,
g_assert (query->cycles == NULL); /* paranoid */
return all_resolved;
}
-
static void
query_add_cycle (EngineQuery *query,
EngineNode *dep,
EngineNode *node)
{
EngineCycle *cycle = sfi_new_struct0 (EngineCycle, 1);
-
cycle->last = dep;
cycle->nodes = sfi_ring_prepend (NULL, node);
cycle->seen_deferred_node = ENGINE_NODE_IS_DEFERRED (node); /* dep will be checked when added to nodes */
query->cycles = sfi_ring_append (query->cycles, cycle);
}
-
static void
query_merge_cycles (EngineQuery *query,
EngineQuery *child_query,
@@ -580,20 +522,17 @@ query_merge_cycles (EngineQuery *query,
query->cycle_nodes = merge_untagged_node_lists_uniq (query->cycle_nodes, child_query->cycle_nodes);
child_query->cycle_nodes = NULL;
}
-
static inline void
clean_ostreams (EngineNode *node)
{
if (!node->cleared_ostreams && !ENGINE_NODE_IS_SCHEDULED (node))
{
guint i;
-
for (i = 0; i < ENGINE_NODE_N_OSTREAMS (node); i++)
node->module.ostreams[i].connected = FALSE;
node->cleared_ostreams = TRUE;
}
}
-
static inline void
subschedule_trace_virtual_input (EngineSchedule *schedule,
EngineNode *node,
@@ -615,7 +554,6 @@ subschedule_trace_virtual_input (EngineSchedule *schedule,
input->real_stream = input->src_stream;
}
}
-
static inline EngineNode*
subschedule_skip_virtuals (EngineSchedule *schedule,
EngineNode *node,
@@ -630,7 +568,6 @@ subschedule_skip_virtuals (EngineSchedule *schedule,
}
return node;
}
-
static inline void
subschedule_child (EngineSchedule *schedule,
EngineNode *node,
@@ -639,11 +576,9 @@ subschedule_child (EngineSchedule *schedule,
guint child_ostream)
{
g_return_if_fail (ENGINE_NODE_IS_VIRTUAL (node) == FALSE);
-
/* flag connected ostream */
clean_ostreams (child);
child->module.ostreams[child_ostream].connected = TRUE;
-
/* schedule away if necessary */
if (ENGINE_NODE_IS_SCHEDULED (child))
query->leaf_level = MAX (query->leaf_level, child->sched_leaf_level + 1);
@@ -652,7 +587,6 @@ subschedule_child (EngineSchedule *schedule,
else /* nice boy ;) */
{
EngineQuery child_query = { 0, };
-
subschedule_query_node (schedule, child, &child_query);
query->leaf_level = MAX (query->leaf_level, child_query.leaf_level + 1);
if (!child_query.cycles)
@@ -671,23 +605,19 @@ subschedule_child (EngineSchedule *schedule,
g_assert (child_query.cycles == NULL && child_query.cycle_nodes == NULL); /* paranoid */
}
}
-
static void
subschedule_query_node (EngineSchedule *schedule,
EngineNode *node,
EngineQuery *query)
{
guint i, j;
-
g_return_if_fail (ENGINE_NODE_IS_VIRTUAL (node) == FALSE);
g_return_if_fail (node->sched_recurse_tag == FALSE);
g_return_if_fail (query->leaf_level == 0);
-
/* update suspension state if necessary */
update_suspension_state (node);
/* reset ostream[].connected flags */
clean_ostreams (node);
-
/* SCHED_DEBUG ("sched_query(%p)", node); */
node->sched_recurse_tag = TRUE;
/* schedule input stream children */
@@ -713,7 +643,6 @@ subschedule_query_node (EngineSchedule *schedule,
for (j = 0; j < ENGINE_NODE_N_JSTREAMS (node); j++)
{
BseJStream *jstream = node->module.jstreams + j;
-
/* we check this jstream's connections for virtual dead-ends.
* valid connections stay at (are moved to) the array front and
* are counted in n_connections, while dead-ends are moved
@@ -756,7 +685,6 @@ subschedule_query_node (EngineSchedule *schedule,
{
EngineNode *child = node->jinputs[j][i].real_node;
guint child_ostream = node->jinputs[j][i].real_stream;
-
subschedule_child (schedule, node, query, child, child_ostream);
}
node->counter = GSL_TICK_STAMP;
diff --git a/bse/bseengineschedule.hh b/bse/bseengineschedule.hh
index 29cda98..d7c2ca4 100644
--- a/bse/bseengineschedule.hh
+++ b/bse/bseengineschedule.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENGINE_SCHEDULE_H__
#define __BSE_ENGINE_SCHEDULE_H__
-
#include <bse/bseenginenode.hh>
-
G_BEGIN_DECLS
-
typedef struct
{
EngineNode *last; /* resolve node */
@@ -32,8 +29,6 @@ struct _EngineSchedule
SfiRing *vnodes; /* virtual modules */
};
#define BSE_ENGINE_SCHEDULE_NONPOPABLE(schedule) ((schedule)->cur_leaf_level >= (schedule)->leaf_levels)
-
-
/* --- MasterThread --- */
EngineSchedule* _engine_schedule_new (void);
void _engine_schedule_clear (EngineSchedule *schedule);
@@ -45,7 +40,5 @@ EngineNode* _engine_schedule_pop_node (EngineSchedule *schedule);
SfiRing* _engine_schedule_pop_cycle (EngineSchedule *schedule);
void _engine_schedule_restart (EngineSchedule *schedule);
void _engine_schedule_unsecure (EngineSchedule *schedule);
-
G_END_DECLS
-
#endif /* __BSE_ENGINE_SCHEDULE_H__ */
diff --git a/bse/bseengineutils.cc b/bse/bseengineutils.cc
index dabba43..dd84036 100644
--- a/bse/bseengineutils.cc
+++ b/bse/bseengineutils.cc
@@ -9,13 +9,10 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-
#define LOG_INTERN SfiLogger ("internals", NULL, NULL)
-
/* --- prototypes --- */
static inline void engine_fetch_process_queue_trash_jobs_U (EngineTimedJob **trash_tjobs_head,
EngineTimedJob **trash_tjobs_tail);
-
/* --- UserThread --- */
BseOStream*
_engine_alloc_ostreams (guint n)
@@ -35,7 +32,6 @@ _engine_alloc_ostreams (guint n)
else
return NULL;
}
-
static void
bse_engine_free_timed_job (EngineTimedJob *tjob)
{
@@ -62,7 +58,6 @@ bse_engine_free_timed_job (EngineTimedJob *tjob)
break;
}
}
-
void
bse_engine_free_ostreams (guint n_ostreams,
BseOStream *ostreams)
@@ -71,14 +66,12 @@ bse_engine_free_ostreams (guint n_ostreams,
/* bse_engine_block_size() may have changed since allocation */
g_free (ostreams);
}
-
static void
bse_engine_free_node (EngineNode *node)
{
const BseModuleClass *klass;
gpointer user_data;
guint j;
-
g_return_if_fail (node != NULL);
g_return_if_fail (node->output_nodes == NULL);
g_return_if_fail (node->integrated == FALSE);
@@ -88,7 +81,6 @@ bse_engine_free_node (EngineNode *node)
g_return_if_fail (node->boundary_jobs == NULL);
g_return_if_fail (node->tjob_head == NULL);
g_return_if_fail (node->probe_jobs == NULL);
-
sfi_rec_mutex_destroy (&node->rec_mutex);
if (node->module.ostreams)
{
@@ -114,17 +106,14 @@ bse_engine_free_node (EngineNode *node)
klass = node->module.klass;
user_data = node->module.user_data;
sfi_delete_struct (EngineNode, node);
-
/* allow the free function to free the klass as well */
if (klass->free)
klass->free (user_data, klass);
}
-
static void
bse_engine_free_job (BseJob *job)
{
g_return_if_fail (job != NULL);
-
switch (job->job_id)
{
case ENGINE_JOB_INTEGRATE:
@@ -158,29 +147,23 @@ bse_engine_free_job (BseJob *job)
}
sfi_delete_struct (BseJob, job);
}
-
static void
bse_engine_free_transaction (BseTrans *trans)
{
BseJob *job;
-
g_return_if_fail (trans != NULL);
g_return_if_fail (trans->comitted == FALSE);
if (trans->jobs_tail)
g_return_if_fail (trans->jobs_tail->next == NULL); /* paranoid */
-
job = trans->jobs_head;
while (job)
{
BseJob *tmp = job->next;
-
bse_engine_free_job (job);
job = tmp;
}
sfi_delete_struct (BseTrans, trans);
}
-
-
/* --- job transactions --- */
static BirnetMutex cqueue_trans = { 0, };
static BseTrans *cqueue_trans_pending_head = NULL;
@@ -194,14 +177,12 @@ static BseJob *cqueue_trans_job = NULL;
static EngineTimedJob *cqueue_tjobs_trash_head = NULL;
static EngineTimedJob *cqueue_tjobs_trash_tail = NULL;
static guint64 cqueue_commit_base_stamp = 1;
-
guint64
_engine_enqueue_trans (BseTrans *trans)
{
g_return_val_if_fail (trans != NULL, 0);
g_return_val_if_fail (trans->comitted == TRUE, 0);
g_return_val_if_fail (trans->jobs_head != NULL, 0);
-
GSL_SPIN_LOCK (&cqueue_trans);
if (cqueue_trans_pending_tail)
{
@@ -216,7 +197,6 @@ _engine_enqueue_trans (BseTrans *trans)
sfi_cond_broadcast (&cqueue_trans_cond);
return base_stamp + bse_engine_block_size(); /* returns tick_stamp of when this transaction takes effect */
}
-
void
_engine_wait_on_trans (void)
{
@@ -225,12 +205,10 @@ _engine_wait_on_trans (void)
sfi_cond_wait (&cqueue_trans_cond, &cqueue_trans);
GSL_SPIN_UNLOCK (&cqueue_trans);
}
-
gboolean
_engine_job_pending (void)
{
gboolean pending = cqueue_trans_job != NULL;
-
if (!pending)
{
GSL_SPIN_LOCK (&cqueue_trans);
@@ -239,7 +217,6 @@ _engine_job_pending (void)
}
return pending;
}
-
void
_engine_free_trans (BseTrans *trans)
{
@@ -247,7 +224,6 @@ _engine_free_trans (BseTrans *trans)
g_return_if_fail (trans->comitted == FALSE);
if (trans->jobs_tail)
g_return_if_fail (trans->jobs_tail->next == NULL); /* paranoid */
-
GSL_SPIN_LOCK (&cqueue_trans);
trans->cqt_next = NULL;
if (cqueue_trans_trash_tail)
@@ -257,7 +233,6 @@ _engine_free_trans (BseTrans *trans)
cqueue_trans_trash_tail = trans;
GSL_SPIN_UNLOCK (&cqueue_trans);
}
-
BseJob*
_engine_pop_job (gboolean update_commit_stamp)
{
@@ -330,7 +305,6 @@ _engine_pop_job (gboolean update_commit_stamp)
GSL_SPIN_UNLOCK (&cqueue_trans);
}
}
-
/* pick new job and out of here */
if (cqueue_trans_job)
{
@@ -338,12 +312,9 @@ _engine_pop_job (gboolean update_commit_stamp)
cqueue_trans_job = job->next;
return job;
}
-
/* no pending jobs... */
return NULL;
}
-
-
/* --- user thread garbage collection --- */
/**
* BSE Engine user thread function. Collects processed jobs
@@ -360,14 +331,12 @@ bse_engine_user_thread_collect (void)
{
BseTrans *trans;
EngineTimedJob *tjobs;
-
GSL_SPIN_LOCK (&cqueue_trans);
tjobs = cqueue_tjobs_trash_head;
cqueue_tjobs_trash_head = cqueue_tjobs_trash_tail = NULL;
trans = cqueue_trans_trash_head;
cqueue_trans_trash_head = cqueue_trans_trash_tail = NULL;
GSL_SPIN_UNLOCK (&cqueue_trans);
-
while (tjobs)
{
EngineTimedJob *tjob = tjobs;
@@ -375,7 +344,6 @@ bse_engine_user_thread_collect (void)
tjob->next = NULL;
bse_engine_free_timed_job (tjob);
}
-
while (trans)
{
BseTrans *t = trans;
@@ -387,14 +355,11 @@ bse_engine_user_thread_collect (void)
bse_engine_free_transaction (t);
}
}
-
gboolean
bse_engine_has_garbage (void)
{
return cqueue_tjobs_trash_head || cqueue_trans_trash_head;
}
-
-
/* --- node processing queue --- */
static BirnetMutex pqueue_mutex = { 0, };
static EngineSchedule *pqueue_schedule = NULL;
@@ -403,7 +368,6 @@ static guint pqueue_n_cycles = 0;
static BirnetCond pqueue_done_cond = { 0, };
static EngineTimedJob *pqueue_trash_tjobs_head = NULL;
static EngineTimedJob *pqueue_trash_tjobs_tail = NULL;
-
static inline void
engine_fetch_process_queue_trash_jobs_U (EngineTimedJob **trash_tjobs_head,
EngineTimedJob **trash_tjobs_tail)
@@ -425,13 +389,11 @@ engine_fetch_process_queue_trash_jobs_U (EngineTimedJob **trash_tjobs_head,
else
*trash_tjobs_head = *trash_tjobs_tail = NULL;
}
-
void
_engine_set_schedule (EngineSchedule *sched)
{
g_return_if_fail (sched != NULL);
g_return_if_fail (sched->secured == TRUE);
-
GSL_SPIN_LOCK (&pqueue_mutex);
if (UNLIKELY (pqueue_schedule != NULL))
{
@@ -443,14 +405,11 @@ _engine_set_schedule (EngineSchedule *sched)
sched->in_pqueue = TRUE;
GSL_SPIN_UNLOCK (&pqueue_mutex);
}
-
void
_engine_unset_schedule (EngineSchedule *sched)
{
EngineTimedJob *trash_tjobs_head, *trash_tjobs_tail;
-
g_return_if_fail (sched != NULL);
-
GSL_SPIN_LOCK (&pqueue_mutex);
if (UNLIKELY (pqueue_schedule != sched))
{
@@ -467,7 +426,6 @@ _engine_unset_schedule (EngineSchedule *sched)
trash_tjobs_tail = pqueue_trash_tjobs_tail;
pqueue_trash_tjobs_head = pqueue_trash_tjobs_tail = NULL;
GSL_SPIN_UNLOCK (&pqueue_mutex);
-
if (trash_tjobs_head) /* move trash user jobs */
{
GSL_SPIN_LOCK (&cqueue_trans);
@@ -480,24 +438,19 @@ _engine_unset_schedule (EngineSchedule *sched)
GSL_SPIN_UNLOCK (&cqueue_trans);
}
}
-
EngineNode*
_engine_pop_unprocessed_node (void)
{
EngineNode *node;
-
GSL_SPIN_LOCK (&pqueue_mutex);
node = pqueue_schedule ? _engine_schedule_pop_node (pqueue_schedule) : NULL;
if (node)
pqueue_n_nodes += 1;
GSL_SPIN_UNLOCK (&pqueue_mutex);
-
if (node)
ENGINE_NODE_LOCK (node);
-
return node;
}
-
static inline void
collect_user_jobs_L (EngineNode *node)
{
@@ -513,24 +466,20 @@ collect_user_jobs_L (EngineNode *node)
node->tjob_head = node->tjob_tail = NULL;
}
}
-
void
_engine_node_collect_jobs (EngineNode *node)
{
g_return_if_fail (node != NULL);
-
GSL_SPIN_LOCK (&pqueue_mutex);
collect_user_jobs_L (node);
GSL_SPIN_UNLOCK (&pqueue_mutex);
}
-
void
_engine_push_processed_node (EngineNode *node)
{
g_return_if_fail (node != NULL);
g_return_if_fail (pqueue_n_nodes > 0);
g_return_if_fail (ENGINE_NODE_IS_SCHEDULED (node));
-
GSL_SPIN_LOCK (&pqueue_mutex);
g_assert (pqueue_n_nodes > 0); /* paranoid */
collect_user_jobs_L (node);
@@ -540,13 +489,11 @@ _engine_push_processed_node (EngineNode *node)
sfi_cond_signal (&pqueue_done_cond);
GSL_SPIN_UNLOCK (&pqueue_mutex);
}
-
SfiRing*
_engine_pop_unprocessed_cycle (void)
{
return NULL;
}
-
void
_engine_push_processed_cycle (SfiRing *cycle)
{
@@ -554,7 +501,6 @@ _engine_push_processed_cycle (SfiRing *cycle)
g_return_if_fail (pqueue_n_cycles > 0);
g_return_if_fail (ENGINE_NODE_IS_SCHEDULED (cycle->data));
}
-
void
_engine_wait_on_unprocessed (void)
{
@@ -563,23 +509,18 @@ _engine_wait_on_unprocessed (void)
sfi_cond_wait (&pqueue_done_cond, &pqueue_mutex);
GSL_SPIN_UNLOCK (&pqueue_mutex);
}
-
-
/* -- master node list --- */
static EngineNode *master_node_list_head = NULL;
static EngineNode *master_node_list_tail = NULL;
-
EngineNode*
_engine_mnl_head (void)
{
return master_node_list_head;
}
-
void
_engine_mnl_remove (EngineNode *node)
{
g_return_if_fail (node->integrated == TRUE);
-
node->integrated = FALSE;
/* remove */
if (node->mnl_prev)
@@ -593,14 +534,12 @@ _engine_mnl_remove (EngineNode *node)
node->mnl_prev = NULL;
node->mnl_next = NULL;
}
-
void
_engine_mnl_integrate (EngineNode *node)
{
g_return_if_fail (node->integrated == FALSE);
g_return_if_fail (node->flow_jobs == NULL);
g_return_if_fail (node->boundary_jobs == NULL);
-
node->integrated = TRUE;
/* append */
if (master_node_list_tail)
@@ -611,14 +550,11 @@ _engine_mnl_integrate (EngineNode *node)
master_node_list_head = master_node_list_tail;
g_assert (node->mnl_next == NULL);
}
-
void
_engine_mnl_node_changed (EngineNode *node)
{
EngineNode *sibling;
-
g_return_if_fail (node->integrated == TRUE);
-
/* the master node list is partially sorted. that is, all
* nodes which are not scheduled and have pending user jobs
* are agglomerated at the head.
@@ -659,8 +595,6 @@ _engine_mnl_node_changed (EngineNode *node)
GSL_SPIN_UNLOCK (&pqueue_mutex);
}
}
-
-
/* --- const value blocks --- */
float*
bse_engine_const_zeros (guint smaller_than_BSE_STREAM_MAX_VALUES)
@@ -670,33 +604,27 @@ bse_engine_const_zeros (guint smaller_than_BSE_STREAM_MAX_VALUES)
g_assert (smaller_than_BSE_STREAM_MAX_VALUES <= BSE_STREAM_MAX_VALUES);
return (float*) engine_const_zero_block;
}
-
typedef struct
{
guint n_nodes;
gfloat **nodes;
guint8 *nodes_used;
} ConstValuesArray;
-
static const guint8 CONST_VALUES_EXPIRE = 16; /* expire value after being unused for 16 times */
-
static inline gfloat**
const_values_lookup_nextmost (ConstValuesArray *array,
gfloat key_value)
{
guint n_nodes = array->n_nodes;
-
if (n_nodes > 0)
{
gfloat **nodes = array->nodes;
gfloat **check;
-
nodes -= 1;
do
{
guint i;
register gfloat cmp;
-
i = (n_nodes + 1) >> 1;
check = nodes + i;
cmp = key_value - **check;
@@ -711,19 +639,15 @@ const_values_lookup_nextmost (ConstValuesArray *array,
return check; /* matched */
}
while (n_nodes);
-
return check; /* nextmost */
}
-
return NULL;
}
-
static inline guint
upper_power2 (guint number)
{
return sfi_alloc_upper_power2 (MAX (number, 8));
}
-
static inline void
const_values_insert (ConstValuesArray *array,
guint index,
@@ -758,15 +682,12 @@ const_values_insert (ConstValuesArray *array,
array->nodes[index] = value_block;
array->nodes_used[index] = CONST_VALUES_EXPIRE;
}
-
static ConstValuesArray cvalue_array = { 0, NULL, NULL };
-
float*
bse_engine_const_values (gfloat value)
{
if (fabs (value) < BSE_SIGNAL_EPSILON)
return bse_engine_const_zeros (BSE_STREAM_MAX_VALUES);
-
float **block = const_values_lookup_nextmost (&cvalue_array, value);
/* found correct match? */
if (block && fabs (**block - value) < BSE_SIGNAL_EPSILON)
@@ -783,25 +704,21 @@ bse_engine_const_values (gfloat value)
const_values_insert (&cvalue_array, block - cvalue_array.nodes, values);
else
const_values_insert (&cvalue_array, 0, values);
-
return values;
}
}
-
void
_engine_recycle_const_values (gboolean nuke_all)
{
gfloat **nodes = cvalue_array.nodes;
guint8 *used = cvalue_array.nodes_used;
guint count = cvalue_array.n_nodes, e = 0, i;
-
for (i = 0; i < count; i++)
{
if (nuke_all)
used[i] = 0;
else
used[i]--; /* invariant: use counts are never 0 */
-
if (used[i] == 0)
g_free (nodes[i]);
else /* preserve node */
@@ -816,7 +733,6 @@ _engine_recycle_const_values (gboolean nuke_all)
}
cvalue_array.n_nodes = e;
}
-
/* --- initialization --- */
void
bse_engine_reinit_utils (void)
@@ -831,5 +747,4 @@ bse_engine_reinit_utils (void)
sfi_cond_init (&pqueue_done_cond);
}
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseengineutils.hh b/bse/bseengineutils.hh
index 033e643..6549265 100644
--- a/bse/bseengineutils.hh
+++ b/bse/bseengineutils.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENGINE_UTIL_H__
#define __BSE_ENGINE_UTIL_H__
-
#include <bse/bseenginenode.hh>
-
G_BEGIN_DECLS
-
/* --- UserThread --- */
void bse_engine_reinit_utils (void);
void _engine_free_trans (BseTrans *trans);
@@ -14,8 +11,6 @@ BseOStream* _engine_alloc_ostreams (guint n);
void bse_engine_user_thread_collect (void);
gfloat* bse_engine_const_values (gfloat value);
#endif
-
-
/* --- MasterThread --- */
void _engine_recycle_const_values (gboolean nuke_all);
void _engine_node_collect_jobs (EngineNode *node);
@@ -25,7 +20,6 @@ void _engine_mnl_node_changed (EngineNode *node);
void _engine_mnl_integrate (EngineNode *node);
#define BSE_ENGINE_MNL_UNSCHEDULED_TJOB_NODE(node) (!(node)->sched_tag && ((node)->flow_jobs || (node)->probe_jobs))
EngineNode* _engine_mnl_head (void);
-
/* communication routines for threads:
* UserThread - main application
* MasterThread - op engine control thread
@@ -33,7 +27,6 @@ EngineNode* _engine_mnl_head (void);
*
* these functions are for _internal_ use of bseengine*.cc implementations
*/
-
/* --- job transactions --- */
/* UserThread */
guint64 _engine_enqueue_trans (BseTrans *trans);
@@ -42,8 +35,6 @@ void _engine_wait_on_trans (void);
/* MasterThread */
BseJob* _engine_pop_job (gboolean update_commit_stamp);
gboolean _engine_job_pending (void);
-
-
/* --- node processing queue --- */
void _engine_set_schedule (EngineSchedule *schedule);
void _engine_unset_schedule (EngineSchedule *schedule);
@@ -52,7 +43,5 @@ void _engine_push_processed_node (EngineNode *node);
SfiRing* _engine_pop_unprocessed_cycle (void);
void _engine_push_processed_cycle (SfiRing *cycle);
void _engine_wait_on_unprocessed (void);
-
G_END_DECLS
-
#endif /* __BSE_ENGINE_UTIL_H__ */
diff --git a/bse/bseenums.cc b/bse/bseenums.cc
index f5a1e77..ff04728 100644
--- a/bse/bseenums.cc
+++ b/bse/bseenums.cc
@@ -2,10 +2,8 @@
#include "bseenums.hh"
#include "gslcommon.hh"
#include <errno.h>
-
/* include generated enum value arrays and *.h files the enums steam from */
#include "bseenum_arrays.cc"
-
/* --- functions --- */
void
bse_type_register_enums (void)
@@ -21,7 +19,6 @@ bse_type_register_enums (void)
};
uint n_enums = sizeof (enums) / sizeof (enums[0]);
uint i;
-
for (i = 0; i < n_enums; i++)
{
if (enums[i].parent_type == G_TYPE_ENUM)
@@ -36,42 +33,32 @@ bse_type_register_enums (void)
g_assert_not_reached ();
}
}
-
/* BseErrorType is a static type */
static GEnumClass *bse_error_class = NULL;
-
const char*
bse_error_name (BseErrorType error_value)
{
GEnumValue *ev;
-
if (!bse_error_class)
bse_error_class = (GEnumClass*) g_type_class_ref (BSE_TYPE_ERROR_TYPE);
-
ev = g_enum_get_value (bse_error_class, error_value);
return ev ? ev->value_name : NULL;
}
-
const char*
bse_error_nick (BseErrorType error_value)
{
GEnumValue *ev;
-
if (!bse_error_class)
bse_error_class = (GEnumClass*) g_type_class_ref (BSE_TYPE_ERROR_TYPE);
-
ev = g_enum_get_value (bse_error_class, error_value);
return ev ? ev->value_nick : NULL;
}
-
const char*
bse_error_blurb (BseErrorType error_value)
{
GEnumValue *ev;
-
if (!bse_error_class)
bse_error_class = (GEnumClass*) g_type_class_ref (BSE_TYPE_ERROR_TYPE);
-
switch (error_value)
{
case BSE_ERROR_NONE: return _("Everything went well");
@@ -151,11 +138,9 @@ bse_error_blurb (BseErrorType error_value)
case BSE_ERROR_INVALID_DURATION: return _("Invalid duration");
case BSE_ERROR_INVALID_OVERLAP: return _("Invalid overlap");
}
-
ev = g_enum_get_value (bse_error_class, error_value);
return ev ? ev->value_nick : NULL;
}
-
BseErrorType
bse_error_from_errno (int v_errno,
BseErrorType fallback)
diff --git a/bse/bseenums.hh b/bse/bseenums.hh
index 8b2fc1f..34a928d 100644
--- a/bse/bseenums.hh
+++ b/bse/bseenums.hh
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ENUMS_H__
#define __BSE_ENUMS_H__
-
#include <bse/bsetype.hh>
#include <bse/gsldefs.hh>
-
-
G_BEGIN_DECLS
-
-
/* --- enum definitions --- */
typedef enum
{
@@ -128,15 +123,12 @@ typedef enum
BSE_ERROR_INVALID_DURATION,
BSE_ERROR_INVALID_OVERLAP,
} BseErrorType;
-
-
/* --- convenience functions --- */
const gchar* bse_error_name (BseErrorType error_value);
const gchar* bse_error_nick (BseErrorType error_value);
const gchar* bse_error_blurb (BseErrorType error_value);
BseErrorType bse_error_from_errno (gint v_errno,
BseErrorType fallback);
-
#define bse_assert_ok(error) G_STMT_START{ \
if G_UNLIKELY (error) \
{ \
@@ -145,8 +137,5 @@ BseErrorType bse_error_from_errno (gint v_errno,
__FILE__, __LINE__, bse_error_blurb (error)); \
} \
}G_STMT_END
-
G_END_DECLS
-
-
#endif /* __BSE_ENUMS_H__ */
diff --git a/bse/bseenums.proc b/bse/bseenums.proc
index ae43d3e..98446a2 100644
--- a/bse/bseenums.proc
+++ b/bse/bseenums.proc
@@ -2,12 +2,8 @@
#include <bse/bseplugin.hh>
#include <bse/bseprocedure.hh>
#include <bse/bseenums.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
PROCEDURE (bse-error-name, "Error Name") {
HELP = "Retrieve the name of an error value";
IN = bse_param_spec_genum ("error", "Error", NULL,
@@ -21,17 +17,12 @@ PROCEDURE (bse-error-name, "Error Name") {
{
/* extract parameter values */
BseErrorType error = (BseErrorType) g_value_get_enum (in_values++);
-
/* check parameters */
-
/* action */
-
/* set output parameters */
g_value_set_string (out_values++, bse_error_name (error));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-error-blurb, "Error Blurb") {
HELP = "Retrieve the description of an error value";
IN = bse_param_spec_genum ("error", "Error", NULL,
@@ -45,13 +36,9 @@ PROCEDURE (bse-error-blurb, "Error Blurb") {
{
/* extract parameter values */
BseErrorType error = (BseErrorType) g_value_get_enum (in_values++);
-
/* check parameters */
-
/* action */
-
/* set output parameters */
g_value_set_string (out_values++, bse_error_blurb (error));
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bseexports.hh b/bse/bseexports.hh
index 23db382..99a8536 100644
--- a/bse/bseexports.hh
+++ b/bse/bseexports.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_EXPORTS_H__
#define __BSE_EXPORTS_H__
-
#include <bse/bseprocedure.hh>
-
G_BEGIN_DECLS
-
/* --- export node types --- */
typedef enum {
BSE_EXPORT_NODE_NONE,
@@ -17,7 +14,6 @@ typedef enum {
BSE_EXPORT_NODE_CLASS,
BSE_EXPORT_NODE_PROC
} BseExportNodeType;
-
/* --- common export node data --- */
typedef struct {
/* strings which need to be looked up from catalogs after
@@ -32,7 +28,6 @@ typedef struct {
guint line;
} BseExportStrings;
typedef void (*BseExportStringsFunc) (BseExportStrings *strings);
-
/* --- basic export node --- */
struct _BseExportNode {
BseExportNode *next;
@@ -44,7 +39,6 @@ struct _BseExportNode {
BseExportStringsFunc fill_strings;
GType type;
};
-
/* --- hook export node --- */
typedef void (*BseExportHook) (void *data);
typedef struct {
@@ -53,7 +47,6 @@ typedef struct {
BseExportHook hook;
void *data;
} BseExportNodeHook;
-
/* --- enum export node --- */
typedef GEnumValue* (*BseExportGetEnumValues) (void);
typedef SfiChoiceValues (*BseExportGetChoiceValues) (void);
@@ -62,7 +55,6 @@ typedef struct {
BseExportGetEnumValues get_enum_values;
BseExportGetChoiceValues get_choice_values;
} BseExportNodeEnum;
-
/* --- boxed export node --- */
typedef SfiRecFields (*BseExportGetRecordFields) (void);
typedef GParamSpec* (*BseExportGetSequenceElement) (void);
@@ -77,7 +69,6 @@ struct _BseExportNodeBoxed {
BseExportGetSequenceElement get_element;
} func;
};
-
/* --- class export node --- */
typedef struct {
BseExportNode node;
@@ -89,7 +80,6 @@ typedef struct {
guint16 instance_size;
GInstanceInitFunc instance_init;
} BseExportNodeClass;
-
/* --- procedure export node --- */
typedef struct {
BseExportNode node;
@@ -97,7 +87,6 @@ typedef struct {
BseProcedureInit init;
BseProcedureExec exec;
} BseExportNodeProc;
-
/* --- plugin identity export --- */
/* plugin export identity (name, bse-version and actual types) */
#define BSE_EXPORT_IDENTITY_SYMBOL bse_export__identity
@@ -113,7 +102,6 @@ typedef struct {
{ BSE_MAJOR_VERSION, BSE_MINOR_VERSION, BSE_MICRO_VERSION, \
BSE_BINARY_AGE, BSE_INTERFACE_AGE, 0, 0, 0, \
BSE_EXPORT_CONFIG, &HEAD }
-
#define BSE_EXPORT_FLAG_MMX (0x1ull << 0)
#define BSE_EXPORT_FLAG_MMXEXT (0x1ull << 1)
#define BSE_EXPORT_FLAG_3DNOW (0x1ull << 2)
@@ -122,22 +110,16 @@ typedef struct {
#define BSE_EXPORT_FLAG_SSE2 (0x1ull << 5)
#define BSE_EXPORT_FLAG_SSE3 (0x1ull << 6)
#define BSE_EXPORT_FLAG_SSE4 (0x1ull << 7)
-
#define BSE_EXPORT_CONFIG (BSE_EXPORT_CONFIG__MMX | BSE_EXPORT_CONFIG__3DNOW | \
BSE_EXPORT_CONFIG__SSE | BSE_EXPORT_CONFIG__SSE2 | \
BSE_EXPORT_CONFIG__SSE3)
-
-
-
BsePlugin* bse_exports__add_node (const BseExportIdentity *identity, // bseplugin.cc
BseExportNode *enode);
void bse_exports__del_node (BsePlugin *plugin, // bseplugin.cc
BseExportNode *enode);
-
/* implementation prototype */
void bse_procedure_complete_info (const BseExportNodeProc *pnode,
GTypeInfo *info);
-
/* --- export config --- */
#ifdef __MMX__
#define BSE_EXPORT_CONFIG__MMX BSE_EXPORT_FLAG_MMX
@@ -164,7 +146,5 @@ void bse_procedure_complete_info (const BseExportNodeProc *pnode,
#else
#define BSE_EXPORT_CONFIG__SSE3 0
#endif
-
G_END_DECLS
-
#endif /* __BSE_EXPORTS_H__ */
diff --git a/bse/bsefilter-ellf.cc b/bse/bsefilter-ellf.cc
index 3e28841..5c2c0e2 100644
--- a/bse/bsefilter-ellf.cc
+++ b/bse/bsefilter-ellf.cc
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "bsefilter.hh"
-
typedef struct {
int n_poles;
int n_zeros;
@@ -41,11 +40,9 @@ typedef struct {
double zn[BSE_IIR_CARRAY_SIZE]; /* numerator coefficients [order+1] */
double zd[BSE_IIR_CARRAY_SIZE]; /* denominator coefficients [order+1] */
} EllfDesignState;
-
#define MACHEP (BSE_DOUBLE_EPSILON) /* the machine roundoff error */
#define PIO2 (BSE_PI_DIV_2) /* pi/2 */
#define MAXNUM (BSE_DOUBLE_MAX_NORMAL) /* 2**1024*(1-MACHEP) */
-
#if 0
#define error_printf(...) fprintf (stderr, __VA_ARGS__)
#define ellf_debugf(...) fprintf (stderr, __VA_ARGS__)
@@ -57,10 +54,8 @@ typedef struct {
#define ellf_outputf(...) while (0) { printf (__VA_ARGS__); }
#define ellf_inputf(...) while (0) { printf (__VA_ARGS__); }
#endif
-
static const char* ellf_filter_design (const BseIIRFilterRequest *ifr,
EllfDesignState *ds);
-
bool
_bse_filter_design_ellf (const BseIIRFilterRequest *ifr,
BseIIRFilterDesign *fid)
@@ -102,7 +97,6 @@ _bse_filter_design_ellf (const BseIIRFilterRequest *ifr,
fid->center_frequency = 0.5 * fid->sampling_frequency / PI * (PIO2 - asin (ds.cgam));
return true;
}
-
/* This code calculates design coefficients for
* digital filters of the Butterworth, Chebyshev, or
* elliptic varieties.
@@ -161,13 +155,11 @@ _bse_filter_design_ellf (const BseIIRFilterRequest *ifr,
* Functions, National Bureau of Standards AMS 55, 1964,
* Chapters 16 and 17
*/
-
/* --- prototypes --- */
static double ellik (double phi, double m); // incomplete elliptic integral of the first kind
static double ellpk (double x); // complete elliptic integral of the first kind
static int ellpj (double u, double m, double *sn, double *cn, double *dn, double *ph); // Jacobian Elliptic Functions
static int math_set_error (char *name, int code);
-
/* --- math errors --- */
static int math_global_error = 0;
#define MATH_ERROR_DOMAIN 1 /* argument domain error */
@@ -176,7 +168,6 @@ static int math_global_error = 0;
#define MATH_ERROR_UNDERFLOW 4 /* underflow range error */
#define MATH_ERROR_TOTAL_LOSS 5 /* total loss of precision */
#define MATH_ERROR_PARTIAL_LOSS 6 /* partial loss of precision */
-
/* Common error handling routine
*
* SYNOPSIS:
@@ -225,29 +216,24 @@ math_set_error (char *name, int code)
"total loss of precision",
"partial loss of precision"
};
-
/* Display string passed by calling program,
* which is supposed to be the name of the
* function in which the error occurred:
*/
error_printf ("\n%s ", name);
-
/* Set global error message word */
math_global_error = code;
-
/* Display error message defined
* by the code argument.
*/
if ((code <= 0) || (code >= 7))
code = 0;
error_printf ("%s error\n", ermsg[code]);
-
/* Return to calling
* program
*/
return 0;
}
-
/* --- elliptic functions --- */
/* ellik.c - Incomplete elliptic integral of the first kind
*
@@ -280,7 +266,6 @@ ellik (double phi, double m)
{
double a, b, c, e, temp, t, K;
int d, mod, sign, npio2;
-
if (m == 0.0)
return phi;
a = 1.0 - m;
@@ -330,7 +315,6 @@ ellik (double phi, double m)
c = sqrt (m);
d = 1;
mod = 0;
-
while (fabs (c/a) > MACHEP)
{
temp = b/a;
@@ -343,16 +327,13 @@ ellik (double phi, double m)
b = temp;
d += d;
}
-
temp = (atan (t) + mod * PI)/(d * a);
-
done:
if (sign < 0)
temp = -temp;
temp += npio2 * K;
return temp;
}
-
/* ellpj - Jacobian Elliptic Functions
*
* SYNOPSIS:
@@ -422,7 +403,6 @@ ellpj (double u, double m,
*dn = 1.0 - 0.5*m*t*t;
return 0;
}
-
if (m >= 0.9999999999)
{
ai = 0.25 * (1.0-m);
@@ -443,7 +423,6 @@ ellpj (double u, double m,
c[0] = sqrt (m);
twon = 1.0;
i = 0;
-
while (fabs (c[i]/a[i]) > MACHEP)
{
if (i > 7)
@@ -459,7 +438,6 @@ ellpj (double u, double m,
b = t;
twon *= 2.0;
}
-
done:
/* backward recurrence */
phi = twon * a[i] * u;
@@ -470,7 +448,6 @@ ellpj (double u, double m,
phi = (asin (t) + phi)/2.0;
}
while (--i);
-
*sn = sin (phi);
t = cos (phi);
*cn = t;
@@ -478,7 +455,6 @@ ellpj (double u, double m,
*ph = phi;
return 0;
}
-
/* polevl - Evaluate polynomial
*
* SYNOPSIS:
@@ -508,18 +484,14 @@ polevl (double x, const double coef[], int N)
double ans;
int i;
const double *p;
-
p = coef;
ans = *p++;
i = N;
-
do
ans = ans * x + *p++;
while (--i);
-
return ans;
}
-
/* ellpk - Complete elliptic integral of the first kind
*
* SYNOPSIS:
@@ -583,13 +555,11 @@ ellpk (double x)
1.24999999999870820058E-1,
4.99999999999999999821E-1
};
-
if ((x < 0.0) || (x > 1.0))
{
math_set_error ("ellpk", MATH_ERROR_DOMAIN);
return 0.0;
}
-
if (x > MACHEP)
{
return polevl (x,P_ellpk,10) - log (x) * polevl (x,Q_ellpk,10);
@@ -608,7 +578,6 @@ ellpk (double x)
}
}
}
-
/* jacobi_theta_by_nome():
* Find parameter corresponding to given nome by expansion
* in theta functions:
@@ -639,7 +608,6 @@ jacobi_theta_by_nome (double q)
r *= p;
a += 2.0 * r;
t1 = fabs (r / a);
-
r *= p;
b += r;
p *= q;
@@ -652,7 +620,6 @@ jacobi_theta_by_nome (double q)
a = 4.0 * sqrt (q) * a * a; /* see above formulas, solved for m */
return a;
}
-
/* --- filter design functions --- */
static int
find_elliptic_locations_in_lambda_plane (const BseIIRFilterRequest *ifr,
@@ -698,7 +665,6 @@ find_elliptic_locations_in_lambda_plane (const BseIIRFilterRequest *ifr,
ds->elliptic_m = m;
return 0;
}
-
/* calculate s plane poles and zeros, normalized to wc = 1 */
static int
find_s_plane_poles_and_zeros (const BseIIRFilterRequest *ifr,
@@ -878,7 +844,6 @@ find_s_plane_poles_and_zeros (const BseIIRFilterRequest *ifr,
}
return 0;
}
-
/* convert s plane poles and zeros to the z plane. */
static int
convert_s_plane_to_z_plane (const BseIIRFilterRequest *ifr,
@@ -886,19 +851,16 @@ convert_s_plane_to_z_plane (const BseIIRFilterRequest *ifr,
{
BseComplex r, cnum, cden, cwc, ca, cb, b4ac;
double C;
-
if (ifr->kind == BSE_IIR_FILTER_ELLIPTIC)
C = ds->tan_angle_frequency;
else
C = ds->wc;
-
int i;
for (i = 0; i < BSE_IIR_CARRAY_SIZE; i++)
{
ds->zcpz[i].re = 0.0;
ds->zcpz[i].im = 0.0;
}
-
int nc = ds->n_poles;
ds->z_counter = -1;
int icnt, ii = -1;
@@ -912,7 +874,6 @@ convert_s_plane_to_z_plane (const BseIIRFilterRequest *ifr,
ii = ir + 1;
r.re = ds->spz[ir];
r.im = ds->spz[ii];
-
switch (ifr->type)
{
case BSE_IIR_FILTER_LOW_PASS:
@@ -1000,7 +961,6 @@ convert_s_plane_to_z_plane (const BseIIRFilterRequest *ifr,
} /* end switch */
}
while (--nc > 0);
-
if (icnt == 0)
{
ds->n_solved_poles = ds->z_counter + 1;
@@ -1016,16 +976,13 @@ convert_s_plane_to_z_plane (const BseIIRFilterRequest *ifr,
} /* end for() loop */
return 0;
}
-
static int
z_plane_zeros_poles_to_numerator_denomerator (const BseIIRFilterRequest *ifr,
EllfDesignState *ds)
{
BseComplex lin[2];
-
lin[1].re = 1.0;
lin[1].im = 0.0;
-
if (ifr->kind == BSE_IIR_FILTER_BUTTERWORTH || ifr->kind == BSE_IIR_FILTER_CHEBYSHEV1)
{ /* Butterworth or Chebyshev */
/* generate the remaining zeros */
@@ -1063,7 +1020,6 @@ z_plane_zeros_poles_to_numerator_denomerator (const BseIIRFilterRequest *ifr,
}
}
ellf_outputf ("order = %d\n", ds->n_solved_poles);
-
/* Expand the poles and zeros into numerator and
* denominator polynomials
*/
@@ -1172,7 +1128,6 @@ z_plane_zeros_poles_to_numerator_denomerator (const BseIIRFilterRequest *ifr,
ds->numerator_accu / ds->denominator_accu * ds->gain_scale);
return 0;
}
-
/* display quadratic factors */
static int
print_quadratic_factors (const BseIIRFilterRequest *ifr,
@@ -1181,7 +1136,6 @@ print_quadratic_factors (const BseIIRFilterRequest *ifr,
bool is_pole) /* 1 if poles, 0 if zeros */
{
double a, b, r, f, g, g0;
-
if (y > 1.0e-16) /* check for imaginary pole/zero */
{
a = -2.0 * x;
@@ -1214,7 +1168,6 @@ print_quadratic_factors (const BseIIRFilterRequest *ifr,
g = 1.0 - a;
g0 = 1.0 + a;
}
-
if (is_pole)
{
if (g != 0.0)
@@ -1229,7 +1182,6 @@ print_quadratic_factors (const BseIIRFilterRequest *ifr,
ellf_outputf ("f0 %16.8E gain %12.4E DC gain %12.4E\n\n", f, g, g0);
return 0;
}
-
static int
gainscale_and_print_deno_nume_zeros2_poles2 (const BseIIRFilterRequest *ifr, /* zplnc */
EllfDesignState *ds)
@@ -1241,13 +1193,11 @@ gainscale_and_print_deno_nume_zeros2_poles2 (const BseIIRFilterRequest *ifr, /*
ellf_outputf ("constant gain factor %23.13E\n", ds->gain);
for (j = 0; j <= ds->n_solved_poles; j++)
ds->zn[j] = ds->gain * ds->zn[j];
-
ellf_outputf ("z plane Denominator Numerator\n");
for (j = 0; j <= ds->n_solved_poles; j++)
{
ellf_outputf ("%2d %17.9E %17.9E\n", j, ds->zd[j], ds->zn[j]);
}
-
/* I /think/ at this point the polynomial is factorized in 2nd order filters,
* so that it can be implemented without stability problems -- stw
*/
@@ -1271,7 +1221,6 @@ gainscale_and_print_deno_nume_zeros2_poles2 (const BseIIRFilterRequest *ifr, /*
}
return 0;
}
-
/* Calculate frequency response at f Hz mulitplied by amp */
static double
response (const BseIIRFilterRequest *ifr,
@@ -1281,12 +1230,10 @@ response (const BseIIRFilterRequest *ifr,
BseComplex x, num, den, w;
double u;
int j;
-
/* exp(j omega T) */
u = 2.0 * PI * f /ifr->sampling_frequency;
x.re = cos (u);
x.im = sin (u);
-
num.re = 1.0;
num.im = 0.0;
den.re = 1.0;
@@ -1304,14 +1251,12 @@ response (const BseIIRFilterRequest *ifr,
u = bse_complex_abs (w);
return u;
}
-
/* Print table of filter frequency response */
static void
print_filter_table (const BseIIRFilterRequest *ifr,
EllfDesignState *ds)
{
double f, limit = 0.05 * ds->nyquist_frequency * 21;
-
for (f=0; f < limit; f += limit / 21.)
{
double r = response (ifr, ds, f, ds->gain);
@@ -1323,7 +1268,6 @@ print_filter_table (const BseIIRFilterRequest *ifr,
// f = f + 0.05 * ds->nyquist_frequency;
}
}
-
/* --- main IIR filter design function --- */
static const char*
ellf_filter_design (const BseIIRFilterRequest *ifr,
@@ -1331,7 +1275,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
{
double passband_edge1 = ifr->passband_edge;
double passband_edge0 = ifr->passband_edge2;
-
if (ifr->kind != BSE_IIR_FILTER_BUTTERWORTH &&
ifr->kind != BSE_IIR_FILTER_CHEBYSHEV1 &&
ifr->kind != BSE_IIR_FILTER_ELLIPTIC)
@@ -1343,7 +1286,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
return "unknown type";
if (ifr->order <= 0)
return "order too small";
-
if (ifr->kind == BSE_IIR_FILTER_CHEBYSHEV1 || ifr->kind == BSE_IIR_FILTER_ELLIPTIC)
{
if (ifr->passband_ripple_db <= 0.0)
@@ -1352,7 +1294,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
{
/* For Chebyshev filter, ripples go from 1.0 to 1/sqrt(1+ds->ripple_epsilon^2) */
ds->chebyshev_phi = exp (ifr->passband_ripple_db / BSE_DECIBEL20_FACTOR);
-
if ((ifr->order & 1) == 0)
ds->gain_scale = ds->chebyshev_phi;
else
@@ -1367,17 +1308,13 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
ds->ripple_epsilon = sqrt (ds->ripple_epsilon - 1.0);
}
}
-
if (ifr->sampling_frequency <= 0.0)
return "sampling_frequency too small";
-
ds->nyquist_frequency = 0.5 * ifr->sampling_frequency;
-
if (passband_edge1 <= 0.0)
return "passband_edge1 too small";
if (passband_edge1 >= ds->nyquist_frequency)
return "passband_edge1 too high";
-
if (ifr->type == BSE_IIR_FILTER_BAND_PASS || ifr->type == BSE_IIR_FILTER_BAND_STOP)
{
if (passband_edge0 <= 0.0)
@@ -1420,7 +1357,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
ds->wc = ds->tan_angle_frequency;
/*ellf_debugf("cos(1/2 (Whigh-Wlow) T) = %.5e, wc = %.5e\n", cang, ds->wc);*/
}
-
if (ifr->kind == BSE_IIR_FILTER_ELLIPTIC)
{ /* elliptic */
double tmp_cgam = cos ((high_edge + passband_edge0) * PI / ifr->sampling_frequency) / cang;
@@ -1480,7 +1416,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
ang = ds->stopband_edge * PI / ifr->sampling_frequency;
cang = cos (ang);
double sang = sin (ang);
-
if (ifr->type == BSE_IIR_FILTER_LOW_PASS || ifr->type == BSE_IIR_FILTER_HIGH_PASS)
{
ds->wr = sang / (cang * ds->tan_angle_frequency);
@@ -1492,12 +1427,10 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
cang = q;
ds->wr = (tmp_cgam - cang) / (sang * ds->tan_angle_frequency);
}
-
if (ifr->type == BSE_IIR_FILTER_HIGH_PASS || ifr->type == BSE_IIR_FILTER_BAND_STOP)
ds->wr = 1.0 / ds->wr;
if (ds->wr < 0.0)
ds->wr = -ds->wr;
-
const double tmp_y0 = 1.0;
double tmp_y1 = ds->wr;
/* ds->chebyshev_band_cbp = ds->wr; */
@@ -1535,7 +1468,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
if ((2 * ifr->order + 2) > BSE_IIR_CARRAY_SIZE)
goto toosml;
} /* elliptic */
-
/* Transformation from low-pass to band-pass critical frequencies
*
* Center frequency
@@ -1549,7 +1481,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
* Wanalog = -----------------------------------
* sin(Wdigital T)
*/
-
if (ifr->kind == BSE_IIR_FILTER_CHEBYSHEV1)
{ /* Chebyshev */
double a = PI * (high_edge + passband_edge0) / ifr->sampling_frequency ;
@@ -1565,17 +1496,13 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
/* ds->chebyshev_band_cbp = (ds->cgam - cos (a)) / sin (a); */
ds->gain_scale = 1.0;
}
-
ellf_debugf ("State: gain_scale=%.20g ripple_epsilon=%.20g nyquist_frequency=%.20g " // BSE info
"tan_angle_frequency=%.20g stopband_edge=%.20g wc=%.20g wr=%.20g cgam=%.20g\n",
ds->gain_scale, ds->ripple_epsilon, ds->nyquist_frequency,
ds->tan_angle_frequency, ds->stopband_edge, ds->wc, ds->wr, ds->cgam);
-
find_s_plane_poles_and_zeros (ifr, ds); /* find s plane poles and zeros */
-
if ((ifr->type == BSE_IIR_FILTER_BAND_PASS || ifr->type == BSE_IIR_FILTER_BAND_STOP) && 4 * ifr->order + 2 > BSE_IIR_CARRAY_SIZE)
goto toosml;
-
convert_s_plane_to_z_plane (ifr, ds); /* convert s plane to z plane */
// volatile_sink ("x");
z_plane_zeros_poles_to_numerator_denomerator (ifr, ds);
@@ -1583,7 +1510,6 @@ ellf_filter_design (const BseIIRFilterRequest *ifr,
gainscale_and_print_deno_nume_zeros2_poles2 (ifr, ds);
print_filter_table (ifr, ds); /* tabulate transfer function */
return NULL;
-
toosml:
return "storage arrays too small";
}
diff --git a/bse/bsefilter.cc b/bse/bsefilter.cc
index 85beacd..7501eae 100644
--- a/bse/bsefilter.cc
+++ b/bse/bsefilter.cc
@@ -1,11 +1,8 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
#include "bsefilter.hh"
#include <birnet/birnet.hh>
-
using namespace Birnet;
-
extern "C" {
-
const gchar*
bse_iir_filter_kind_string (BseIIRFilterKind fkind)
{
@@ -19,7 +16,6 @@ bse_iir_filter_kind_string (BseIIRFilterKind fkind)
default: return "?unknown?";
}
}
-
const gchar*
bse_iir_filter_type_string (BseIIRFilterType ftype)
{
@@ -32,7 +28,6 @@ bse_iir_filter_type_string (BseIIRFilterType ftype)
default: return "?unknown?";
}
}
-
gchar*
bse_iir_filter_request_string (const BseIIRFilterRequest *ifr)
{
@@ -53,7 +48,6 @@ bse_iir_filter_request_string (const BseIIRFilterRequest *ifr)
s += " stopband-edge=" + string_from_float (ifr->stopband_edge);
return g_strdup (s.c_str());
}
-
gchar*
bse_iir_filter_design_string (const BseIIRFilterDesign *fid)
{
@@ -93,7 +87,6 @@ bse_iir_filter_design_string (const BseIIRFilterDesign *fid)
#endif
return g_strdup (s.c_str());
}
-
bool
bse_iir_filter_design (const BseIIRFilterRequest *filter_request,
BseIIRFilterDesign *filter_design)
@@ -104,5 +97,4 @@ bse_iir_filter_design (const BseIIRFilterRequest *filter_request,
return _bse_filter_design_ellf (filter_request, filter_design);
return false;
}
-
} // C
diff --git a/bse/bsefilter.hh b/bse/bsefilter.hh
index 34b7ba1..af87b5d 100644
--- a/bse/bsefilter.hh
+++ b/bse/bsefilter.hh
@@ -1,11 +1,8 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
#ifndef BSE_FILTER_H__
#define BSE_FILTER_H__
-
#include <bse/bsemath.hh>
-
BIRNET_EXTERN_C_BEGIN();
-
typedef enum /*< skip >*/
{
BSE_IIR_FILTER_BUTTERWORTH = 1,
@@ -14,7 +11,6 @@ typedef enum /*< skip >*/
BSE_IIR_FILTER_CHEBYSHEV2 = 4,
BSE_IIR_FILTER_ELLIPTIC = 5,
} BseIIRFilterKind;
-
typedef enum /*< skip >*/
{
BSE_IIR_FILTER_LOW_PASS = 1,
@@ -22,7 +18,6 @@ typedef enum /*< skip >*/
BSE_IIR_FILTER_HIGH_PASS = 3,
BSE_IIR_FILTER_BAND_STOP = 4,
} BseIIRFilterType;
-
typedef struct {
BseIIRFilterKind kind;
BseIIRFilterType type;
@@ -34,10 +29,8 @@ typedef struct {
double stopband_edge; /* Hz, > 0.0, replaces stopband_db, elliptic only */
double stopband_db; /* dB, < 0.0, elliptic only */
} BseIIRFilterRequest;
-
#define BSE_IIR_MAX_ORDER (64)
#define BSE_IIR_CARRAY_SIZE (4 * BSE_IIR_MAX_ORDER + 2) /* size of arrays used to store coefficients */
-
typedef struct {
double sampling_frequency; /* same as BseIIRFilterRequest.sampling_frequency */
uint order;
@@ -52,21 +45,17 @@ typedef struct {
// double zn[BSE_IIR_CARRAY_SIZE]; /* numerator coefficients [order+1] */
// double zd[BSE_IIR_CARRAY_SIZE]; /* denominator coefficients [order+1] */
} BseIIRFilterDesign;
-
typedef struct {
double xz2; // x[i-2] coefficient
double xz1; // x[i-1] coefficient
double yz2; // y[i-2] coefficient
double yz1; // y[i-1] coefficient
} BseIIRStage;
-
typedef struct {
uint order;
BseIIRStage *stages;
double *states; /* [0..2*order] */
} BseIIRFilter;
-
-
bool bse_iir_filter_design (const BseIIRFilterRequest *filter_request,
BseIIRFilterDesign *filter_design);
BseIIRFilter* bse_iir_filter_new (const BseIIRFilterDesign *filter_design);
@@ -82,12 +71,8 @@ const gchar* bse_iir_filter_type_string (BseIIRFilterType ftype);
gchar* bse_iir_filter_request_string (const BseIIRFilterRequest *filter_request);
gchar* bse_iir_filter_design_string (const BseIIRFilterDesign *filter_design);
gchar* bse_iir_filter_string (const BseIIRFilter *filter);
-
-
/* --- internal prototypes --- */
bool _bse_filter_design_ellf (const BseIIRFilterRequest *ifr,
BseIIRFilterDesign *fid);
-
BIRNET_EXTERN_C_END();
-
#endif /* BSE_FILTER_H__ */ /* vim:set ts=8 sw=2 sts=2: */
diff --git a/bse/bsegconfig.cc b/bse/bsegconfig.cc
index d5a77ef..99f4fd0 100644
--- a/bse/bsegconfig.cc
+++ b/bse/bsegconfig.cc
@@ -2,15 +2,10 @@
#include "bsegconfig.hh"
#include "bseserver.hh"
#include "bsepcmdevice.hh" /* for frequency alignment */
-
-
-
/* --- variables --- */
BseGConfig *bse_global_config = NULL;
static GParamSpec *pspec_global_config = NULL;
static uint gconfig_lock_count = 0;
-
-
/* --- functions --- */
void
_bse_gconfig_init (void)
@@ -18,9 +13,7 @@ _bse_gconfig_init (void)
BseGConfig *gconfig;
GValue *value;
SfiRec *rec;
-
g_return_if_fail (bse_global_config == NULL);
-
/* global config record description */
pspec_global_config = sfi_pspec_rec ("bse-preferences", NULL, NULL,
bse_gconfig_get_fields (), SFI_PARAM_STANDARD);
@@ -38,7 +31,6 @@ _bse_gconfig_init (void)
sfi_value_free (value);
sfi_rec_unref (rec);
}
-
static void
set_gconfig (BseGConfig *gconfig)
{
@@ -57,12 +49,10 @@ set_gconfig (BseGConfig *gconfig)
sfi_rec_unref (prec);
}
}
-
void
bse_gconfig_apply (SfiRec *rec)
{
g_return_if_fail (rec != NULL);
-
if (!bse_gconfig_locked ())
{
BseGConfig *gconfig;
@@ -73,13 +63,11 @@ bse_gconfig_apply (SfiRec *rec)
set_gconfig (gconfig);
}
}
-
GParamSpec*
bse_gconfig_pspec (void)
{
return pspec_global_config;
}
-
void
bse_gconfig_lock (void)
{
@@ -87,7 +75,6 @@ bse_gconfig_lock (void)
if (gconfig_lock_count == 1)
bse_server_notify_gconfig (bse_server_get ());
}
-
void
bse_gconfig_unlock (void)
{
@@ -99,13 +86,11 @@ bse_gconfig_unlock (void)
bse_server_notify_gconfig (bse_server_get ());
}
}
-
gboolean
bse_gconfig_locked (void)
{
return gconfig_lock_count != 0;
}
-
void
bse_gconfig_merge_args (const BseMainArgs *margs)
{
diff --git a/bse/bsegconfig.hh b/bse/bsegconfig.hh
index 4fa1750..a4c2951 100644
--- a/bse/bsegconfig.hh
+++ b/bse/bsegconfig.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_GCONFIG_H__
#define __BSE_GCONFIG_H__
-
#include <bse/bseobject.hh>
#include <bse/bsemain.hh>
-
G_BEGIN_DECLS
-
/* --- Global Config --- */
/* extern BseGConfig *bse_global_config; bsetype.hh */
void _bse_gconfig_init (void);
@@ -16,7 +13,5 @@ void bse_gconfig_lock (void);
void bse_gconfig_unlock (void);
gboolean bse_gconfig_locked (void);
void bse_gconfig_merge_args (const BseMainArgs *margs);
-
G_END_DECLS
-
#endif /* __BSE_GCONFIG_H__ */
diff --git a/bse/bsegenclosures.hh b/bse/bsegenclosures.hh
index f7b120e..6ba5efb 100644
--- a/bse/bsegenclosures.hh
+++ b/bse/bsegenclosures.hh
@@ -1,4 +1,3 @@
-
/* Void0Closure */
template<class T>
class Void0Closure : public CxxClosure {
@@ -20,7 +19,6 @@ template<class T>
Void0Closure<T>* Closure (T *t, void (T::*f) ()) {
return new Void0Closure<T> (t, f);
}
-
/* Void1Closure */
template<class T, typename A1>
class Void1Closure : public CxxClosure {
@@ -43,7 +41,6 @@ template<class T, typename A1>
Void1Closure<T, A1>* Closure (T *t, void (T::*f) (A1)) {
return new Void1Closure<T, A1> (t, f);
}
-
/* Void2Closure */
template<class T, typename A1, typename A2>
class Void2Closure : public CxxClosure {
@@ -66,7 +63,6 @@ template<class T, typename A1, typename A2>
Void2Closure<T, A1, A2>* Closure (T *t, void (T::*f) (A1, A2)) {
return new Void2Closure<T, A1, A2> (t, f);
}
-
/* Void3Closure */
template<class T, typename A1, typename A2, typename A3>
class Void3Closure : public CxxClosure {
@@ -89,7 +85,6 @@ template<class T, typename A1, typename A2, typename A3>
Void3Closure<T, A1, A2, A3>* Closure (T *t, void (T::*f) (A1, A2, A3)) {
return new Void3Closure<T, A1, A2, A3> (t, f);
}
-
/* Void4Closure */
template<class T, typename A1, typename A2, typename A3, typename A4>
class Void4Closure : public CxxClosure {
@@ -112,7 +107,6 @@ template<class T, typename A1, typename A2, typename A3, typename A4>
Void4Closure<T, A1, A2, A3, A4>* Closure (T *t, void (T::*f) (A1, A2, A3, A4)) {
return new Void4Closure<T, A1, A2, A3, A4> (t, f);
}
-
/* Void5Closure */
template<class T, typename A1, typename A2, typename A3, typename A4, typename A5>
class Void5Closure : public CxxClosure {
@@ -135,7 +129,6 @@ template<class T, typename A1, typename A2, typename A3, typename A4, typename A
Void5Closure<T, A1, A2, A3, A4, A5>* Closure (T *t, void (T::*f) (A1, A2, A3, A4, A5)) {
return new Void5Closure<T, A1, A2, A3, A4, A5> (t, f);
}
-
/* Void6Closure */
template<class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
class Void6Closure : public CxxClosure {
@@ -158,7 +151,6 @@ template<class T, typename A1, typename A2, typename A3, typename A4, typename A
Void6Closure<T, A1, A2, A3, A4, A5, A6>* Closure (T *t, void (T::*f) (A1, A2, A3, A4, A5, A6)) {
return new Void6Closure<T, A1, A2, A3, A4, A5, A6> (t, f);
}
-
/* Void7Closure */
template<class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
class Void7Closure : public CxxClosure {
@@ -181,7 +173,6 @@ template<class T, typename A1, typename A2, typename A3, typename A4, typename A
Void7Closure<T, A1, A2, A3, A4, A5, A6, A7>* Closure (T *t, void (T::*f) (A1, A2, A3, A4, A5, A6, A7)) {
return new Void7Closure<T, A1, A2, A3, A4, A5, A6, A7> (t, f);
}
-
/* Void8Closure */
template<class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
class Void8Closure : public CxxClosure {
@@ -204,7 +195,6 @@ template<class T, typename A1, typename A2, typename A3, typename A4, typename A
Void8Closure<T, A1, A2, A3, A4, A5, A6, A7, A8>* Closure (T *t, void (T::*f) (A1, A2, A3, A4, A5, A6, A7, A8)) {
return new Void8Closure<T, A1, A2, A3, A4, A5, A6, A7, A8> (t, f);
}
-
/* Ret0Closure */
template<typename R, class T>
class Ret0Closure : public CxxClosure {
@@ -227,7 +217,6 @@ template<typename R, class T>
Ret0Closure<R, T>* Closure (T *t, R (T::*f) ()) {
return new Ret0Closure<R, T> (t, f);
}
-
/* Ret1Closure */
template<typename R, class T, typename A1>
class Ret1Closure : public CxxClosure {
@@ -251,7 +240,6 @@ template<typename R, class T, typename A1>
Ret1Closure<R, T, A1>* Closure (T *t, R (T::*f) (A1)) {
return new Ret1Closure<R, T, A1> (t, f);
}
-
/* Ret2Closure */
template<typename R, class T, typename A1, typename A2>
class Ret2Closure : public CxxClosure {
@@ -275,7 +263,6 @@ template<typename R, class T, typename A1, typename A2>
Ret2Closure<R, T, A1, A2>* Closure (T *t, R (T::*f) (A1, A2)) {
return new Ret2Closure<R, T, A1, A2> (t, f);
}
-
/* Ret3Closure */
template<typename R, class T, typename A1, typename A2, typename A3>
class Ret3Closure : public CxxClosure {
@@ -299,7 +286,6 @@ template<typename R, class T, typename A1, typename A2, typename A3>
Ret3Closure<R, T, A1, A2, A3>* Closure (T *t, R (T::*f) (A1, A2, A3)) {
return new Ret3Closure<R, T, A1, A2, A3> (t, f);
}
-
/* Ret4Closure */
template<typename R, class T, typename A1, typename A2, typename A3, typename A4>
class Ret4Closure : public CxxClosure {
@@ -323,7 +309,6 @@ template<typename R, class T, typename A1, typename A2, typename A3, typename A4
Ret4Closure<R, T, A1, A2, A3, A4>* Closure (T *t, R (T::*f) (A1, A2, A3, A4)) {
return new Ret4Closure<R, T, A1, A2, A3, A4> (t, f);
}
-
/* Ret5Closure */
template<typename R, class T, typename A1, typename A2, typename A3, typename A4, typename A5>
class Ret5Closure : public CxxClosure {
@@ -347,7 +332,6 @@ template<typename R, class T, typename A1, typename A2, typename A3, typename A4
Ret5Closure<R, T, A1, A2, A3, A4, A5>* Closure (T *t, R (T::*f) (A1, A2, A3, A4, A5)) {
return new Ret5Closure<R, T, A1, A2, A3, A4, A5> (t, f);
}
-
/* Ret6Closure */
template<typename R, class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
class Ret6Closure : public CxxClosure {
@@ -371,7 +355,6 @@ template<typename R, class T, typename A1, typename A2, typename A3, typename A4
Ret6Closure<R, T, A1, A2, A3, A4, A5, A6>* Closure (T *t, R (T::*f) (A1, A2, A3, A4, A5, A6)) {
return new Ret6Closure<R, T, A1, A2, A3, A4, A5, A6> (t, f);
}
-
/* Ret7Closure */
template<typename R, class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
class Ret7Closure : public CxxClosure {
@@ -395,7 +378,6 @@ template<typename R, class T, typename A1, typename A2, typename A3, typename A4
Ret7Closure<R, T, A1, A2, A3, A4, A5, A6, A7>* Closure (T *t, R (T::*f) (A1, A2, A3, A4, A5, A6, A7)) {
return new Ret7Closure<R, T, A1, A2, A3, A4, A5, A6, A7> (t, f);
}
-
/* Ret8Closure */
template<typename R, class T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
class Ret8Closure : public CxxClosure {
diff --git a/bse/bseglobals.cc b/bse/bseglobals.cc
index 61bc128..231ad5a 100644
--- a/bse/bseglobals.cc
+++ b/bse/bseglobals.cc
@@ -1,19 +1,15 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseglobals.hh"
#include "bsemain.hh"
-
-
/* --- functions --- */
void
bse_globals_init (void) { /* FIXME: remove */ }
-
double
bse_db_to_factor (double dB)
{
double factor = dB / 20; /* Bell */
return pow (10, factor);
}
-
double
bse_db_from_factor (double factor,
double min_dB)
@@ -27,13 +23,11 @@ bse_db_from_factor (double factor,
else
return min_dB;
}
-
long
bse_time_range_to_ms (BseTimeRangeType time_range)
{
g_return_val_if_fail (time_range >= BSE_TIME_RANGE_SHORT, 0);
g_return_val_if_fail (time_range <= BSE_TIME_RANGE_LONG, 0);
-
switch (time_range)
{
case BSE_TIME_RANGE_SHORT: return BSE_TIME_RANGE_SHORT_ms;
@@ -42,8 +36,6 @@ bse_time_range_to_ms (BseTimeRangeType time_range)
}
return 0; /* can't be triggered */
}
-
-
/* --- idle handlers --- */
/* important ordering constrains:
* BSE_PRIORITY_NOW = -G_MAXINT / 2
@@ -62,7 +54,6 @@ bse_time_range_to_ms (BseTimeRangeType time_range)
* G_PRIORITY_LOW (300)
* BSE_PRIORITY_BACKGROUND = G_PRIORITY_LOW + 500
*/
-
/**
* @param function user function
* @param data user data
@@ -85,7 +76,6 @@ bse_idle_now (GSourceFunc function,
g_source_unref (source);
return id;
}
-
/**
* @param function user function
* @param data user data
@@ -107,7 +97,6 @@ bse_idle_next (GSourceFunc function,
g_source_unref (source);
return id;
}
-
/**
* @param function user function
* @param data user data
@@ -130,7 +119,6 @@ bse_idle_notify (GSourceFunc function,
g_source_unref (source);
return id;
}
-
uint
bse_idle_normal (GSourceFunc function,
void *data)
@@ -143,7 +131,6 @@ bse_idle_normal (GSourceFunc function,
g_source_unref (source);
return id;
}
-
uint
bse_idle_update (GSourceFunc function,
void *data)
@@ -156,7 +143,6 @@ bse_idle_update (GSourceFunc function,
g_source_unref (source);
return id;
}
-
uint
bse_idle_background (GSourceFunc function,
void *data)
@@ -169,7 +155,6 @@ bse_idle_background (GSourceFunc function,
g_source_unref (source);
return id;
}
-
/**
* @param usec_delay microsecond delay
* @param function user function
@@ -192,7 +177,6 @@ bse_idle_timed (guint64 usec_delay,
g_source_unref (source);
return id;
}
-
/**
* @param id idle handler id
* Remove or unqueue an idle handler queued by bse_idle_now()
@@ -203,9 +187,7 @@ gboolean
bse_idle_remove (uint id)
{
GSource *source;
-
g_return_val_if_fail (id > 0, FALSE);
-
source = g_main_context_find_source_by_id (bse_main_context, id);
if (source)
g_source_destroy (source);
diff --git a/bse/bseglobals.hh b/bse/bseglobals.hh
index da7534b..8934bb4 100644
--- a/bse/bseglobals.hh
+++ b/bse/bseglobals.hh
@@ -1,14 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_GLOBALS_H__
#define __BSE_GLOBALS_H__
-
#include <bse/bsedefs.hh>
#include <bse/bsemath.hh>
#include <bse/bsenote.hh>
#include <bse/bseconstvalues.hh>
-
G_BEGIN_DECLS
-
/* --- time ranges --- */ // FIXME: BSE_TIME_RANGE is deprecated
typedef enum
{
@@ -20,8 +17,6 @@ typedef enum
#define BSE_TIME_RANGE_MEDIUM_ms (1000.0 * 10.0)
#define BSE_TIME_RANGE_LONG_ms (1000.0 * 200.0)
glong bse_time_range_to_ms (BseTimeRangeType time_range);
-
-
/* --- async handlers --- */
/* most important, used for immediate async execution */
#define BSE_PRIORITY_NOW (-G_MAXINT / 2)
@@ -54,8 +49,6 @@ gboolean bse_idle_remove (guint id);
guint bse_idle_timed (guint64 usec_delay,
GSourceFunc function,
gpointer data);
-
-
/* semitone factorization tables, i.e.
* Index Factor
* (SFI_KAMMER_NOTE - 12) -> 0.5
@@ -64,17 +57,12 @@ guint bse_idle_timed (guint64 usec_delay,
* etc...
*/
#define BSE_TRANSPOSE_FACTOR(st) (bse_transpose_factor (CLAMP (st, -132, +132))) /* BSE_MAX_TRANSPOSE */
-
-
/* --- prototypes --- */
void bse_globals_init (void);
-
/* --- decibel conversion --- */
gdouble bse_db_to_factor (gdouble dB);
gdouble bse_db_from_factor (gdouble factor,
gdouble min_dB);
#define BSE_MINDB (-96) /* 32bit:-192 24bit:-144 16bit:-96 */
-
G_END_DECLS
-
#endif /* __BSE_GLOBALS_H__ */
diff --git a/bse/bseglue.cc b/bse/bseglue.cc
index 5f27cc0..4390805 100644
--- a/bse/bseglue.cc
+++ b/bse/bseglue.cc
@@ -6,8 +6,6 @@
#include "bsecategories.hh"
#include "bsemain.hh"
#include <string.h>
-
-
/* --- structures --- */
typedef struct {
uint id;
@@ -39,8 +37,6 @@ typedef struct {
GSource source;
SfiGlueDecoder *decoder;
} BSource;
-
-
/* --- prototypes --- */
static SfiGlueIFace* bglue_describe_iface (SfiGlueContext *context,
const char *iface);
@@ -91,14 +87,10 @@ static GValue* bglue_client_msg (SfiGlueContext *context
static SfiRing* bglue_fetch_events (SfiGlueContext *context);
static SfiRing* bglue_list_poll_fds (SfiGlueContext *context);
static void bglue_destroy (SfiGlueContext *context);
-
-
/* --- variables --- */
static GQuark quark_original_enum = 0;
static GQuark quark_property_notify = 0;
static GQuark quark_notify = 0;
-
-
/* --- functions --- */
SfiGlueContext*
bse_glue_context_intern (const char *user)
@@ -127,7 +119,6 @@ bse_glue_context_intern (const char *user)
bglue_destroy,
};
BContext *bcontext;
-
g_return_val_if_fail (user != NULL, NULL);
if (!quark_original_enum)
{
@@ -135,7 +126,6 @@ bse_glue_context_intern (const char *user)
quark_property_notify = g_quark_from_static_string ("property-notify");
quark_notify = g_quark_from_static_string ("notify");
}
-
/* create server-side glue context */
bcontext = g_new0 (BContext, 1);
sfi_glue_context_common_init (&bcontext->context, &bse_glue_table);
@@ -145,10 +135,8 @@ bse_glue_context_intern (const char *user)
bcontext->n_nrefs = 0;
bcontext->nrefs = NULL;
bcontext->free_nref = 0;
-
return &bcontext->context;
}
-
static uint
bcontext_new_notify_ref (BContext *bcontext)
{
@@ -169,7 +157,6 @@ bcontext_new_notify_ref (BContext *bcontext)
bcontext->nrefs[i].data.list = NULL;
return bcontext->nrefs[i].id;
}
-
static void
bcontext_notify_ref_add_item (BContext *bcontext,
uint id,
@@ -180,7 +167,6 @@ bcontext_notify_ref_add_item (BContext *bcontext,
bcontext->nrefs[i].data.list = g_slist_prepend (bcontext->nrefs[i].data.list,
bse_item_use (item));
}
-
static gboolean
bcontext_release_notify_ref (BContext *bcontext,
uint id)
@@ -204,7 +190,6 @@ bcontext_release_notify_ref (BContext *bcontext,
else
return FALSE; /* no such nref */
}
-
static void
bcontext_queue_release (BContext *bcontext,
SfiProxy proxy)
@@ -214,7 +199,6 @@ bcontext_queue_release (BContext *bcontext,
sfi_seq_append_proxy (seq, proxy);
bcontext->events = sfi_ring_append (bcontext->events, seq);
}
-
static void
bcontext_queue_signal (BContext *bcontext,
uint nref_id,
@@ -222,9 +206,7 @@ bcontext_queue_signal (BContext *bcontext,
SfiSeq *args)
{
SfiSeq *seq;
-
g_return_if_fail (args != NULL && args->n_elements > 0 && SFI_VALUE_HOLDS_PROXY (args->elements));
-
seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_EVENT_NOTIFY);
sfi_seq_append_string (seq, signal);
@@ -232,7 +214,6 @@ bcontext_queue_signal (BContext *bcontext,
sfi_seq_append_seq (seq, args);
bcontext->events = sfi_ring_append (bcontext->events, seq);
}
-
static GParamSpec*
bglue_pspec_to_serializable (GParamSpec *pspec)
{
@@ -248,7 +229,6 @@ bglue_pspec_to_serializable (GParamSpec *pspec)
g_param_spec_sink (pspec);
return pspec;
}
-
static GValue*
bglue_value_from_serializable (const GValue *svalue,
GParamSpec *pspec)
@@ -294,20 +274,16 @@ bglue_value_from_serializable (const GValue *svalue,
}
return value;
}
-
GValue*
bse_value_from_sfi (const GValue *value,
GParamSpec *pspec)
{
GValue *rvalue;
-
g_return_val_if_fail (SFI_IS_VALUE (value), NULL);
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
-
rvalue = bglue_value_from_serializable (value, pspec);
return rvalue ? rvalue : sfi_value_clone_shallow (value);
}
-
static GValue*
bglue_value_to_serializable (const GValue *svalue)
{
@@ -316,7 +292,6 @@ bglue_value_to_serializable (const GValue *svalue)
/* this corresponds with the conversions in sfi_pspec_to_serializable() */
if (sfi_categorize_type (vtype))
return sfi_value_clone_shallow (svalue);
-
switch (G_TYPE_FUNDAMENTAL (vtype))
{
BseObject *object;
@@ -353,15 +328,12 @@ bglue_value_to_serializable (const GValue *svalue)
g_type_name (vtype), g_type_name (dtype));
return value;
}
-
GValue*
bse_value_to_sfi (const GValue *value)
{
g_return_val_if_fail (G_IS_VALUE (value), NULL);
-
return bglue_value_to_serializable (value);
}
-
GValue*
bse_glue_boxed_to_value (GType boxed_type,
void * boxed)
@@ -369,15 +341,12 @@ bse_glue_boxed_to_value (GType boxed_type,
BseGlueBoxedToRec b2rec;
BseGlueBoxedToSeq b2seq;
GValue *value;
-
/* Convert a boxed value into a #SfiGlueValue (usually holding
* either a sequence or a record). The returned value is owned
* by the GC.
*/
-
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type) && G_TYPE_IS_DERIVED (boxed_type), NULL);
g_return_val_if_fail (boxed != NULL, NULL);
-
b2rec = (BseGlueBoxedToRec) g_type_get_qdata (boxed_type, g_quark_from_string ("BseGlueBoxedToRec"));
b2seq = (BseGlueBoxedToSeq) g_type_get_qdata (boxed_type, g_quark_from_string ("BseGlueBoxedToSeq"));
if (b2rec)
@@ -399,14 +368,12 @@ bse_glue_boxed_to_value (GType boxed_type,
}
return value;
}
-
GType
bse_glue_pspec_get_original_enum (GParamSpec *pspec)
{
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), 0);
return (GType) g_param_spec_get_qdata (pspec, quark_original_enum);
}
-
static SfiGlueIFace*
bglue_describe_iface (SfiGlueContext *context,
const char *iface)
@@ -417,10 +384,8 @@ bglue_describe_iface (SfiGlueContext *context,
GParamSpec **pspecs;
GSList *plist = NULL;
uint i, n;
-
if (!G_TYPE_IS_OBJECT (type) || !g_type_is_a (type, BSE_TYPE_ITEM))
return NULL;
-
f = sfi_glue_iface_new (g_type_name (type));
f->n_ifaces = g_type_depth (type) - g_type_depth (BSE_TYPE_ITEM) + 1;
f->ifaces = g_new (char*, f->n_ifaces + 1);
@@ -431,7 +396,6 @@ bglue_describe_iface (SfiGlueContext *context,
xtype = g_type_parent (xtype);
}
f->ifaces[i] = NULL;
-
oclass = (GObjectClass*) g_type_class_ref (type);
xtype = BSE_TYPE_ITEM;
pspecs = g_object_class_list_properties (oclass, &n);
@@ -439,7 +403,6 @@ bglue_describe_iface (SfiGlueContext *context,
for (i = 0; i < n; i++)
{
GParamSpec *pspec = pspecs[i];
-
if (g_type_is_a (pspec->owner_type, xtype))
{
plist = g_slist_prepend (plist, g_strdup (pspec->name));
@@ -448,22 +411,18 @@ bglue_describe_iface (SfiGlueContext *context,
}
g_free (pspecs);
g_type_class_unref (oclass);
-
i = f->n_props;
f->props = g_new (char*, i + 1);
f->props[i] = NULL;
while (i--)
{
GSList *tmp = plist->next;
-
f->props[i] = (char*) plist->data;
g_slist_free_1 (plist);
plist = tmp;
}
-
return f;
}
-
uint
bse_glue_enum_index (GType enum_type,
int enum_value)
@@ -471,20 +430,16 @@ bse_glue_enum_index (GType enum_type,
GEnumClass *eclass;
GEnumValue *ev;
uint index;
-
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), G_MAXINT);
g_return_val_if_fail (G_TYPE_IS_DERIVED (enum_type), G_MAXINT);
-
eclass = (GEnumClass*) g_type_class_ref (enum_type);
ev = g_enum_get_value (eclass, enum_value);
if (!ev)
sfi_diag ("%s: enum \"%s\" has no value %u", G_STRLOC, g_type_name (enum_type), enum_value);
index = ev ? ev - eclass->values : G_MAXINT;
g_type_class_unref (eclass);
-
return index;
}
-
static SfiGlueProc*
bglue_describe_proc (SfiGlueContext *context,
const char *proc_name)
@@ -492,15 +447,12 @@ bglue_describe_proc (SfiGlueContext *context,
GType type = g_type_from_name (proc_name);
BseProcedureClass *proc;
SfiGlueProc *p = NULL;
-
if (!BSE_TYPE_IS_PROCEDURE (type))
return NULL;
-
proc = (BseProcedureClass*) g_type_class_ref (type);
if (proc->n_out_pspecs < 2)
{
uint i;
-
p = sfi_glue_proc_new (g_type_name (type));
p->help = g_strdup (bse_type_get_blurb (type));
p->authors = g_strdup (bse_type_get_authors (type));
@@ -519,26 +471,21 @@ bglue_describe_proc (SfiGlueContext *context,
}
}
g_type_class_unref (proc);
-
return p;
}
-
static char**
bglue_list_proc_names (SfiGlueContext *context)
{
BseCategorySeq *cseq = bse_categories_match_typed ("/Proc/""*", BSE_TYPE_PROCEDURE);
char **p;
uint i;
-
p = g_new (char*, cseq->n_cats + 1);
for (i = 0; i < cseq->n_cats; i++)
p[i] = g_strdup (cseq->cats[i]->type);
p[i] = NULL;
bse_category_seq_free (cseq);
-
return p;
}
-
static char**
bglue_list_method_names (SfiGlueContext *context,
const char *iface_name)
@@ -547,13 +494,10 @@ bglue_list_method_names (SfiGlueContext *context,
BseCategorySeq *cseq;
char **p, *prefix;
uint i, l, n_procs;
-
if (!g_type_is_a (type, BSE_TYPE_ITEM))
return NULL;
-
prefix = g_strdup_printf ("%s+", g_type_name (type));
l = strlen (prefix);
-
cseq = bse_categories_match_typed ("/Methods/" "*", BSE_TYPE_PROCEDURE);
p = g_new (char*, cseq->n_cats + 1);
n_procs = 0;
@@ -563,28 +507,23 @@ bglue_list_method_names (SfiGlueContext *context,
p[n_procs] = NULL;
bse_category_seq_free (cseq);
g_free (prefix);
-
return p;
}
-
static char*
bglue_base_iface (SfiGlueContext *context)
{
return g_strdup ("BseItem");
}
-
static char**
bglue_iface_children (SfiGlueContext *context,
const char *iface_name)
{
GType type = g_type_from_name (iface_name);
char **childnames = NULL;
-
if (g_type_is_a (type, BSE_TYPE_ITEM))
{
GType *children;
uint n;
-
children = g_type_children (type, &n);
childnames = g_new (char*, n + 1);
childnames[n] = NULL;
@@ -594,7 +533,6 @@ bglue_iface_children (SfiGlueContext *context,
}
return childnames;
}
-
static BseErrorType
bglue_marshal_proc (void *marshal_data,
BseProcedureClass *proc,
@@ -603,7 +541,6 @@ bglue_marshal_proc (void *marshal_data,
{
return proc->execute (proc, ivalues, ovalues);
}
-
static GValue*
bglue_exec_proc (SfiGlueContext *context,
const char *proc_name,
@@ -611,7 +548,6 @@ bglue_exec_proc (SfiGlueContext *context,
{
GValue *retval = NULL;
GType ptype = bse_procedure_lookup (proc_name);
-
if (BSE_TYPE_IS_PROCEDURE (ptype) && G_TYPE_IS_DERIVED (ptype))
{
BseProcedureClass *proc = (BseProcedureClass*) g_type_class_ref (ptype);
@@ -619,7 +555,6 @@ bglue_exec_proc (SfiGlueContext *context,
GSList *ilist = NULL, *olist = NULL, *clearlist = NULL;
uint i, sl = sfi_seq_length (params);
BseErrorType error;
-
for (i = 0; i < proc->n_in_pspecs; i++)
{
GParamSpec *pspec = proc->in_pspecs[i];
@@ -645,7 +580,6 @@ bglue_exec_proc (SfiGlueContext *context,
g_value_init (ovalues + i, G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[i]));
olist = g_slist_prepend (olist, ovalues + i);
}
-
ilist = g_slist_reverse (ilist);
olist = g_slist_reverse (olist);
error = bse_procedure_execvl (proc, ilist, olist, bglue_marshal_proc, NULL);
@@ -654,7 +588,6 @@ bglue_exec_proc (SfiGlueContext *context,
for (ilist = clearlist; ilist; ilist = ilist->next)
sfi_value_free ((GValue*) ilist->data);
g_slist_free (clearlist);
-
if (error)
g_warning ("while executing \"%s\": %s", BSE_PROCEDURE_NAME (proc), bse_error_blurb (error));
if (proc->n_out_pspecs)
@@ -666,22 +599,18 @@ bglue_exec_proc (SfiGlueContext *context,
}
else
sfi_diag ("failed to execute \"%s\": no such procedure", proc_name);
-
return retval;
}
-
static char*
bglue_proxy_iface (SfiGlueContext *context,
SfiProxy proxy)
{
BseObject *object = (BseObject*) bse_object_from_id (proxy);
-
if (BSE_IS_ITEM (object))
return g_strdup (G_OBJECT_TYPE_NAME (object));
else
return NULL;
}
-
static gboolean
bglue_proxy_is_a (SfiGlueContext *context,
SfiProxy proxy,
@@ -689,10 +618,8 @@ bglue_proxy_is_a (SfiGlueContext *context,
{
BseObject *object = (BseObject*) bse_object_from_id (proxy);
GType itype = iface ? g_type_from_name (iface) : 0;
-
return object && itype && g_type_is_a (G_OBJECT_TYPE (object), itype);
}
-
static char**
bglue_proxy_list_properties (SfiGlueContext *context,
SfiProxy proxy,
@@ -701,7 +628,6 @@ bglue_proxy_list_properties (SfiGlueContext *context,
{
BseObject *object = (BseObject*) bse_object_from_id (proxy);
char **names = NULL;
-
if (BSE_IS_ITEM (object))
{
GType first_base_type = first_ancestor ? g_type_from_name (first_ancestor) : 0;
@@ -713,7 +639,6 @@ bglue_proxy_list_properties (SfiGlueContext *context,
for (i = 0; i < n; i++)
{
GParamSpec *pspec = pspecs[i];
-
if ((!first_base_type || g_type_is_a (pspec->owner_type, first_base_type)) &&
(!last_base_type || g_type_is_a (last_base_type, pspec->owner_type)))
*p++ = g_strdup (pspec->name);
@@ -724,7 +649,6 @@ bglue_proxy_list_properties (SfiGlueContext *context,
}
return names;
}
-
static GParamSpec*
bglue_proxy_get_pspec (SfiGlueContext *context,
SfiProxy proxy,
@@ -732,7 +656,6 @@ bglue_proxy_get_pspec (SfiGlueContext *context,
{
BseObject *object = (BseObject*) bse_object_from_id (proxy);
GParamSpec *pspec;
-
if (!BSE_IS_ITEM (object))
{
sfi_diag ("property lookup: no such object (proxy=%lu)", proxy);
@@ -741,12 +664,9 @@ bglue_proxy_get_pspec (SfiGlueContext *context,
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop_name);
if (!pspec)
return NULL;
-
pspec = bglue_pspec_to_serializable (pspec);
-
return pspec;
}
-
static SfiSCategory
bglue_proxy_get_pspec_scategory (SfiGlueContext *context,
SfiProxy proxy,
@@ -761,7 +681,6 @@ bglue_proxy_get_pspec_scategory (SfiGlueContext *context,
}
return scat;
}
-
static void
bglue_proxy_set_property (SfiGlueContext *context,
SfiProxy proxy,
@@ -769,7 +688,6 @@ bglue_proxy_set_property (SfiGlueContext *context,
const GValue *value)
{
void *object = bse_object_from_id (proxy);
-
if (BSE_IS_OBJECT (object) && G_IS_VALUE (value))
{
GParamSpec *pspec = prop ? g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop) : NULL;
@@ -807,7 +725,6 @@ bglue_proxy_set_property (SfiGlueContext *context,
bse_object_debug_name (object), prop ? prop : "<NULL>");
}
}
-
static GValue*
bglue_proxy_get_property (SfiGlueContext *context,
SfiProxy proxy,
@@ -815,11 +732,9 @@ bglue_proxy_get_property (SfiGlueContext *context,
{
GObject *object = (GObject*) bse_object_from_id (proxy);
GValue *rvalue = NULL;
-
if (BSE_IS_OBJECT (object) && prop)
{
GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop);
-
if (pspec)
{
GValue *value = sfi_value_empty ();
@@ -833,7 +748,6 @@ bglue_proxy_get_property (SfiGlueContext *context,
}
return rvalue;
}
-
static void
bcontext_destroy_bproxy (BContext *bcontext,
BProxy *p,
@@ -855,7 +769,6 @@ bcontext_destroy_bproxy (BContext *bcontext,
g_signal_handler_disconnect (item, p->release_id);
g_free (p);
}
-
static void
bglue_bproxy_release (BseItem *item,
BContext *bcontext)
@@ -870,14 +783,12 @@ bglue_bproxy_release (BseItem *item,
}
bcontext_destroy_bproxy (bcontext, p, proxy, item);
}
-
static BProxy*
bglue_fetch_bproxy (BContext *bcontext,
SfiProxy proxy,
BseItem *item)
{
BProxy *p;
-
p = (BProxy*) sfi_ustore_lookup (bcontext->bproxies, proxy);
if (!p && (item->use_count > 0 || item->parent))
{
@@ -888,7 +799,6 @@ bglue_fetch_bproxy (BContext *bcontext,
}
return p;
}
-
static gboolean
bglue_proxy_watch_release (SfiGlueContext *context,
SfiProxy proxy)
@@ -896,7 +806,6 @@ bglue_proxy_watch_release (SfiGlueContext *context,
BContext *bcontext = (BContext*) context;
BseItem *item = (BseItem*) bse_object_from_id (proxy);
BProxy *p;
-
if (!BSE_IS_ITEM (item))
return FALSE;
p = bglue_fetch_bproxy (bcontext, proxy, item);
@@ -907,7 +816,6 @@ bglue_proxy_watch_release (SfiGlueContext *context,
p->remote_watch = TRUE;
return TRUE;
}
-
static void
bclosure_marshal (GClosure *closure,
GValue *return_value,
@@ -921,7 +829,6 @@ bclosure_marshal (GClosure *closure,
const char *signal = g_quark_to_string (bclosure->qsignal);
SfiSeq *args = sfi_seq_new ();
uint i, nref_id = bcontext_new_notify_ref (bcontext);
-
for (i = 0; i < n_param_values; i++)
{
GValue *value = bglue_value_to_serializable (param_values + i);
@@ -933,7 +840,6 @@ bclosure_marshal (GClosure *closure,
bcontext_queue_signal (bcontext, nref_id, signal, args);
sfi_seq_unref (args);
}
-
static void
bclosure_notify_marshal (GClosure *closure,
GValue *return_value,
@@ -949,7 +855,6 @@ bclosure_notify_marshal (GClosure *closure,
BseItem *item;
uint nref_id = bcontext_new_notify_ref (bcontext);
GParamSpec *pspec;
-
/* here we handle aliasing of ::notify to ::property_notify,
* and provide pspec->name instead of pspec as signal argument
*/
@@ -963,7 +868,6 @@ bclosure_notify_marshal (GClosure *closure,
g_free (signal);
sfi_seq_unref (args);
}
-
static gboolean
bglue_proxy_request_notify (SfiGlueContext *context,
SfiProxy proxy,
@@ -981,16 +885,13 @@ bglue_proxy_request_notify (SfiGlueContext *context,
char *sig_name, *c;
uint sig_id;
gboolean connected;
-
if (!BSE_IS_ITEM (item) || !signal)
return FALSE;
p = bglue_fetch_bproxy (bcontext, proxy, item);
if (!p)
return FALSE;
-
/* get canonified signal name quark */
qsignal = sfi_glue_proxy_get_signal_quark (signal);
-
/* special case ::notify, which we don't export through the glue layer */
if (qsignal == quark_notify || strncmp (signal, "notify:", 7) == 0)
return FALSE;
@@ -1005,10 +906,8 @@ bglue_proxy_request_notify (SfiGlueContext *context,
}
else
sig_closure_marshal = bclosure_marshal;
-
/* canonify signal name */
signal = g_quark_to_string (qsignal);
-
for (slist = p->closures; slist; last = slist, slist = last->next)
{
bclosure = (BClosure*) slist->data;
@@ -1039,7 +938,6 @@ bglue_proxy_request_notify (SfiGlueContext *context,
#endif
return FALSE;
}
-
/* abort early if the signal is unknown */
sig_name = g_strdup (signal);
c = strchr (sig_name, ':');
@@ -1049,7 +947,6 @@ bglue_proxy_request_notify (SfiGlueContext *context,
g_free (sig_name);
if (!sig_id)
return FALSE;
-
closure = g_closure_new_simple (sizeof (BClosure), bcontext);
g_closure_set_marshal (closure, sig_closure_marshal);
bclosure = (BClosure*) closure;
@@ -1069,7 +966,6 @@ bglue_proxy_request_notify (SfiGlueContext *context,
}
return connected;
}
-
static void
bglue_proxy_processed_notify (SfiGlueContext *context,
uint notify_id)
@@ -1078,14 +974,12 @@ bglue_proxy_processed_notify (SfiGlueContext *context,
if (!bcontext_release_notify_ref (bcontext, notify_id))
sfi_diag ("got invalid event receipt (%u)", notify_id);
}
-
static GValue*
bglue_client_msg (SfiGlueContext *context,
const char *msg,
GValue *value)
{
GValue *retval = NULL;
-
if (!msg)
;
else
@@ -1093,10 +987,8 @@ bglue_client_msg (SfiGlueContext *context,
sfi_diag ("unhandled client message: %s", msg);
retval = sfi_value_string ("Unknown client msg");
}
-
return retval;
}
-
static SfiRing*
bglue_fetch_events (SfiGlueContext *context)
{
@@ -1105,13 +997,11 @@ bglue_fetch_events (SfiGlueContext *context)
bcontext->events = NULL;
return events;
}
-
static SfiRing*
bglue_list_poll_fds (SfiGlueContext *context)
{
return NULL;
}
-
static gboolean
bproxy_foreach_slist (void *data,
unsigned long unique_id,
@@ -1121,7 +1011,6 @@ bproxy_foreach_slist (void *data,
*slist_p = g_slist_prepend (*slist_p, (void *) unique_id);
return TRUE;
}
-
static void
bglue_destroy (SfiGlueContext *context)
{
@@ -1158,5 +1047,4 @@ bglue_destroy (SfiGlueContext *context)
g_free (bcontext->nrefs);
g_free (bcontext);
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseglue.hh b/bse/bseglue.hh
index 20bd46c..48cc708 100644
--- a/bse/bseglue.hh
+++ b/bse/bseglue.hh
@@ -1,35 +1,25 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_GLUE_H__
#define __BSE_GLUE_H__
-
#include <bse/bsetype.hh>
-
G_BEGIN_DECLS
-
/* FIXME: creation of a new context source should be done
* by a janitor constructor
*/
-
SfiGlueContext* bse_glue_context_intern (const gchar *user);
-
/* Construct a new #SfiRec from a boxed value. */
typedef SfiRec* (*BseGlueBoxedToRec) (gpointer boxed);
/* Construct a new #SfiSeq from a boxed value. */
typedef SfiSeq* (*BseGlueBoxedToSeq) (gpointer boxed);
-
GType bse_glue_pspec_get_original_enum (GParamSpec *pspec);
guint bse_glue_enum_index (GType enum_type,
gint enum_value);
GValue* bse_glue_boxed_to_value (GType boxed_type,
gpointer boxed);
-
/* convert value sto/from SFI serializable types */
GValue* bse_value_to_sfi (const GValue *value);
GValue* bse_value_from_sfi (const GValue *value,
GParamSpec *pspec);
-
G_END_DECLS
-
#endif /* __BSE_GLUE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseieee754.hh b/bse/bseieee754.hh
index fe531c1..b9b5cfa 100644
--- a/bse/bseieee754.hh
+++ b/bse/bseieee754.hh
@@ -1,16 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_IEEE754_H__
#define __BSE_IEEE754_H__
-
#include <bse/bsedefs.hh>
#include <math.h> /* signbit */
-
/* override math.h definition of PI */
#undef PI
#define PI (3.141592653589793238462643383279502884197) // pi
-
G_BEGIN_DECLS
-
/* IEEE 754 single precision floating point layout:
* 31 30 23 22 0
* +--------+---------------+---------------+
@@ -25,7 +21,6 @@ G_BEGIN_DECLS
* +--------+----------------+----------------+ +---------------+
* B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7->
*/
-
/* floating point type related constants */
#define BSE_FLOAT_BIAS (127)
#define BSE_FLOAT_MAX_NORMAL (3.40282347e+38) /* 7f7fffff, 2^128 * (1 - BSE_FLOAT_EPSILON) */
@@ -43,14 +38,11 @@ G_BEGIN_DECLS
#define BSE_DOUBLE_NAN (_bse_dnan_union.d)
#define BSE_FLOAT_INF (_bse_finf_union.f)
#define BSE_FLOAT_NAN (_bse_fnan_union.f)
-
/* multiply with base2 exponent to get base10 exponent (for nomal numbers) */
#define BSE_LOG_2_BASE_10 (0.30102999566398119521)
-
/* the following macros work only on variables
* and evaluate arguments multiple times
*/
-
/* single precision value checks */
#define BSE_FLOAT_IS_ZERO(f) ((f) == 0.0) /* compiler knows this one */
#define BSE_FLOAT_IS_NORMAL(f) (BSE_FLOAT_PARTS (f).mpn.biased_exponent > 0 && \
@@ -67,7 +59,6 @@ G_BEGIN_DECLS
#else
#define BSE_FLOAT_SIGN(f) (BSE_FLOAT_PARTS (f).mpn.sign)
#endif
-
/* double precision value checks */
#define BSE_DOUBLE_IS_ZERO(d) ((d) == 0.0) /* compiler knows this one */
#define BSE_DOUBLE_IS_NORMAL(d) (BSE_DOUBLE_PARTS (d).mpn.biased_exponent > 0 && \
@@ -89,11 +80,9 @@ G_BEGIN_DECLS
#else
#define BSE_DOUBLE_SIGN(d) (BSE_DOUBLE_PARTS (d).mpn.sign)
#endif
-
/* --- denormal float handling --- */
static inline float bse_float_zap_denormal (register float fval); /* slow */
static inline double bse_double_zap_denormal (register double dval); /* slow */
-
/* --- coarse but fast variants to eliminate denormalized floats --- */
/* pure arithmetic flushing, fastest with -ffast-math */
#define BSE_FLOAT_FLUSH(mutable_float) BSE_FLOAT_FLUSH_with_threshold (mutable_float)
@@ -106,7 +95,6 @@ static inline double bse_double_zap_denormal (register double dval); /* slow */
#define BSE_FLOAT_FLUSH(mutable_float) BSE_FLOAT_FLUSH_with_if (mutable_float)
#define BSE_DOUBLE_FLUSH(mutable_double) BSE_DOUBLE_FLUSH_with_if (mutable_double)
#endif
-
/* --- rounding --- */
typedef unsigned short int BseFpuState;
#if defined (__i386__) && defined (__GNUC__)
@@ -123,7 +111,6 @@ static inline int bse_dtoi /* nearest */ (register double f) G_GNUC_CONST;
#endif
static inline guint64 bse_dtoull (const double v);
static inline gint64 bse_dtoll (const double v);
-
/* --- implementation bits --- */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
typedef union
@@ -176,12 +163,10 @@ typedef union
#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
#error unknown ENDIAN type
#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
-
static const union { unsigned char c[8]; double d; } _bse_dnan_union = { _BSE_DOUBLE_NAN_BYTES };
static const union { unsigned char c[8]; double d; } _bse_dinf_union = { _BSE_DOUBLE_INF_BYTES };
static const union { unsigned char c[4]; float f; } _bse_fnan_union = { _BSE_FLOAT_NAN_BYTES };
static const union { unsigned char c[4]; float f; } _bse_finf_union = { _BSE_FLOAT_INF_BYTES };
-
/* get structured parts of floating point numbers */
#if __cplusplus
extern inline BseFloatIEEE754 BSE_FLOAT_PARTS (register float fvalue) { BseFloatIEEE754 fret = { fvalue }; return fret; }
@@ -190,7 +175,6 @@ extern inline BseDoubleIEEE754 BSE_DOUBLE_PARTS (register double dvalue) { BseDo
#define BSE_FLOAT_PARTS(f) (((BseFloatIEEE754) (f)))
#define BSE_DOUBLE_PARTS(d) (((BseDoubleIEEE754) (d)))
#endif
-
/* --- implementation details --- */
static inline float
bse_float_zap_denormal (register float fval)
@@ -200,7 +184,6 @@ bse_float_zap_denormal (register float fval)
else
return fval;
}
-
static inline double
bse_double_zap_denormal (register double dval)
{
@@ -209,7 +192,6 @@ bse_double_zap_denormal (register double dval)
else
return dval;
}
-
/* use float arithmetic cancellation to eliminate denormals */
#define BSE_FLOAT_FLUSH_with_threshold(mutable_float) do { \
volatile float __forced_float = 1e-29 + mutable_float; \
@@ -235,13 +217,11 @@ bse_double_zap_denormal (register double dval)
if (G_UNLIKELY (fabs (mutable_double) < 1e-290)) \
mutable_double = 0; \
} while (0)
-
#if defined (__i386__) && defined (__GNUC__)
static inline void
bse_fpu_setround (BseFpuState *cw)
{
BseFpuState cv;
-
__asm__ ("fnstcw %0"
: "=m" (*&cv));
*cw = cv;
@@ -254,7 +234,6 @@ static inline int
bse_fpu_okround (void)
{
BseFpuState cv;
-
__asm__ ("fnstcw %0"
: "=m" (*&cv));
return !(cv & 0x0c00);
@@ -270,7 +249,6 @@ static inline int G_GNUC_CONST
bse_ftoi (register float f)
{
int r;
-
__asm__ ("fistl %0"
: "=m" (r)
: "t" (f));
@@ -280,7 +258,6 @@ static inline int G_GNUC_CONST
bse_dtoi (register double f)
{
int r;
-
__asm__ ("fistl %0"
: "=m" (r)
: "t" (f));
@@ -311,7 +288,5 @@ bse_dtoll (const double v)
{
return v < -0.0 ? (gint64) (v - 0.5) : (gint64) (v + 0.5);
}
-
G_END_DECLS
-
#endif /* __BSE_IEEE754_H__ */ /* vim: set ts=8 sw=2 sts=2: */
diff --git a/bse/bseincluder.hh b/bse/bseincluder.hh
index 615871b..16aed75 100644
--- a/bse/bseincluder.hh
+++ b/bse/bseincluder.hh
@@ -1,5 +1,4 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
/* use this file to implement:
* int i;
* foo<i> ();
@@ -13,13 +12,11 @@
* #include "bseincluder.hh"
* }
*/
-
/* file contents created with:
* for i in `seq 0 4096` ; do z=`printf '%4u' $i`; echo -e "#if BSE_INCLUDER_MATCH ($z)\n " \
* "BSE_INCLUDER_CASE ($z) BSE_INCLUDER_FUNC ($z) BSE_INCLUDER_ARGS ($z) " \
* "BSE_INCLUDER_DONE ($z)\n#endif" ; done
*/
-
#ifndef BSE_INCLUDER_CASE
# define BSE_INCLUDER_CASE(n) case n:
#endif
@@ -27,7 +24,6 @@
# define BSE_INCLUDER_DONE(n) ; break;
#endif
/* all macros are auto-undefined at file end */
-
#if BSE_INCLUDER_MATCH ( 0)
BSE_INCLUDER_CASE ( 0) BSE_INCLUDER_FUNC ( 0) BSE_INCLUDER_ARGS ( 0) BSE_INCLUDER_DONE ( 0)
#endif
@@ -12319,7 +12315,6 @@
#if BSE_INCLUDER_MATCH (4096)
BSE_INCLUDER_CASE (4096) BSE_INCLUDER_FUNC (4096) BSE_INCLUDER_ARGS (4096) BSE_INCLUDER_DONE (4096)
#endif
-
#undef BSE_INCLUDER_MATCH
#undef BSE_INCLUDER_CASE
#undef BSE_INCLUDER_FUNC
diff --git a/bse/bseinfo.cc b/bse/bseinfo.cc
index 0434075..b8510b3 100644
--- a/bse/bseinfo.cc
+++ b/bse/bseinfo.cc
@@ -2,23 +2,19 @@
#include "bseutils.hh"
#include "bsemain.hh"
#include "bsemathsignal.hh"
-
#define PREC_SHIFT 16
#define FLF "26.20"
-
static void
print_int (const char *name,
int integer)
{
g_print ("%s =%-4d\n", name, integer);
}
-
static void
print_note (const char *note_name,
int note)
{
char *string;
-
string = bse_note_to_string (note);
g_print ("%s =%-4d \tfactor=%"FLF"f [%-5s] (freq=%"FLF"f)\n",
note_name, note,
@@ -26,7 +22,6 @@ print_note (const char *note_name,
string, bse_note_to_freq (BSE_MUSICAL_TUNING_12_TET, note));
g_free (string);
}
-
static void
print_fine_tune (const char *tune_name,
int tune)
@@ -35,16 +30,13 @@ print_fine_tune (const char *tune_name,
tune_name, tune,
bse_cent_tune_fast (tune));
}
-
int
main (int argc,
char *argv[])
{
int j, k;
-
g_thread_init (NULL);
bse_init_inprocess (&argc, &argv, "BseInfo", NULL);
-
g_print ("Rate relevant limits:\n");
print_int ("BSE_MIN_OCTAVE ", BSE_MIN_OCTAVE);
print_int ("BSE_MAX_OCTAVE ", BSE_MAX_OCTAVE);
@@ -56,14 +48,12 @@ main (int argc,
print_fine_tune ("bse-mid-fine-tune", (BSE_MIN_FINE_TUNE + BSE_MAX_FINE_TUNE) / 2);
print_fine_tune ("BSE_MAX_FINE_TUNE", BSE_MAX_FINE_TUNE);
print_note ("BSE_KAMMER_NOTE+1", BSE_KAMMER_NOTE + 1);
-
if (0)
for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 3)
print_note (":", j);
if (0)
for (j = BSE_MIN_FINE_TUNE; j <= BSE_MAX_FINE_TUNE; j += 10)
print_fine_tune (":", j);
-
if (0)
for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 3)
for (k = BSE_MIN_FINE_TUNE / 2; k <= BSE_MAX_FINE_TUNE / 2; k += 10)
@@ -84,12 +74,10 @@ main (int argc,
int semitone = SFI_NOTE_SEMITONE (j);
int note = BSE_NOTE_GENERIC (octave, semitone);
char *name = bse_note_to_string (j);
-
g_print ("note[%3d]: name=%-8s octave=%3d semitone=%3d note=%3d match=%u\n",
j, name, octave, semitone, note, j == note);
g_free (name);
}
-
if (argc == 2)
{
SfiRing *ring;
@@ -102,6 +90,5 @@ main (int argc,
g_print ("%s\n", name);
}
}
-
return 0;
}
diff --git a/bse/bseinstrument.hh b/bse/bseinstrument.hh
index 03441c7..a32ed11 100644
--- a/bse/bseinstrument.hh
+++ b/bse/bseinstrument.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_INSTRUMENT_H__
#define __BSE_INSTRUMENT_H__
-
#include <bse/bseitem.hh>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- BSE type macros --- */
#define BSE_TYPE_INSTRUMENT (BSE_TYPE_ID (BseInstrument))
#define BSE_INSTRUMENT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_INSTRUMENT, BseInstrument))
@@ -17,8 +12,6 @@ extern "C" {
#define BSE_IS_INSTRUMENT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_INSTRUMENT))
#define BSE_IS_INSTRUMENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_INSTRUMENT))
#define BSE_INSTRUMENT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_INSTRUMENT, BseInstrumentClass))
-
-
/* --- BseInstrument --- */
typedef struct _BseEnvelope BseEnvelope;
typedef enum
@@ -43,31 +36,22 @@ struct _BseEnvelope
struct _BseInstrument
{
BseItem parent_instance;
-
BseInstrumentType type;
BseWave *wave;
BseSNet *user_snet;
BseSNet *seq_snet; /* sequencer snet */
-
gfloat volume_factor;
gint balance;
gint transpose;
gint fine_tune;
-
BseEnvelope env;
};
struct _BseInstrumentClass
{
BseItemClass parent_class;
};
-
-
/* --- prototypes -- */
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_INSTRUMENT_H__ */
diff --git a/bse/bseinstrumentinput.cc b/bse/bseinstrumentinput.cc
index ff6d332..86280f2 100644
--- a/bse/bseinstrumentinput.cc
+++ b/bse/bseinstrumentinput.cc
@@ -1,24 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseinstrumentinput.hh"
-
#include "bsecategories.hh"
#include "bsesnet.hh"
#include "bseengine.hh"
-
#include <string.h>
-
/* --- parameters --- */
enum
{
PROP_0,
PROP_IPORT_NAME
};
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_instrument_input_reset_names (BseInstrumentInput *self)
@@ -27,7 +20,6 @@ bse_instrument_input_reset_names (BseInstrumentInput *self)
BseItem *item = BSE_ITEM (self);
BseSNet *snet = item->parent ? BSE_SNET (item->parent) : NULL;
const char *name;
-
g_object_freeze_notify (G_OBJECT (self));
name = BSE_SOURCE_OCHANNEL_IDENT (self, 0);
if (strcmp (iport->input_ports[0], name) != 0 &&
@@ -51,32 +43,26 @@ bse_instrument_input_reset_names (BseInstrumentInput *self)
"BseSubIPort::in_port_4", name, NULL);
g_object_thaw_notify (G_OBJECT (self));
}
-
static void
bse_instrument_input_init (BseInstrumentInput *self)
{
bse_instrument_input_reset_names (self);
}
-
static void
bse_instrument_input_set_parent (BseItem *item,
BseItem *parent)
{
BseInstrumentInput *self = BSE_INSTRUMENT_INPUT (item);
-
if (item->parent)
g_signal_handlers_disconnect_by_func (item->parent, (void*) bse_instrument_input_reset_names, self);
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
-
if (item->parent)
g_signal_connect_swapped (item->parent, "port_unregistered",
G_CALLBACK (bse_instrument_input_reset_names), self);
else
bse_instrument_input_reset_names (self);
}
-
static void
bse_instrument_input_get_property (GObject *object, uint param_id, GValue *value, GParamSpec *pspec)
{
@@ -87,7 +73,6 @@ bse_instrument_input_get_property (GObject *object, uint param_id, GValue *value
break;
}
}
-
static void
bse_instrument_input_class_init (BseInstrumentInputClass *klass)
{
@@ -96,12 +81,9 @@ bse_instrument_input_class_init (BseInstrumentInputClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
uint i, ochannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->get_property = bse_instrument_input_get_property;
item_class->set_parent = bse_instrument_input_set_parent;
-
/* assert parent class introduced enough ports */
g_assert (BSE_SUB_IPORT_N_PORTS >= 4);
/* override parent properties with NOP properties */
@@ -113,7 +95,6 @@ bse_instrument_input_class_init (BseInstrumentInputClass *klass)
/* override parent property: 0 */ "r"));
g_free (string);
}
-
ochannel_id = bse_source_class_add_ochannel (source_class, "frequency", _("Frequency"), _("Note Frequency"));
g_assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_FREQUENCY);
ochannel_id = bse_source_class_add_ochannel (source_class, "gate", _("Gate"), _("High if the note is currently being pressed"));
@@ -123,18 +104,15 @@ bse_instrument_input_class_init (BseInstrumentInputClass *klass)
ochannel_id = bse_source_class_add_ochannel (source_class, "aftertouch", _("Aftertouch"), _("Velocity while the note is pressed"));
g_assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_AFTERTOUCH);
}
-
BSE_BUILTIN_TYPE (BseInstrumentInput)
{
static const GTypeInfo type_info = {
sizeof (BseInstrumentInputClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_instrument_input_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseInstrumentInput),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_instrument_input_init,
diff --git a/bse/bseinstrumentinput.hh b/bse/bseinstrumentinput.hh
index 21212fd..1f0d15a 100644
--- a/bse/bseinstrumentinput.hh
+++ b/bse/bseinstrumentinput.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_INSTRUMENT_INPUT_H__
#define __BSE_INSTRUMENT_INPUT_H__
-
#include <bse/bsesubiport.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_INSTRUMENT_INPUT (BSE_TYPE_ID (BseInstrumentInput))
#define BSE_INSTRUMENT_INPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_INSTRUMENT_INPUT, BseInstrumentInput))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_INPUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_INSTRUMENT_INPUT))
#define BSE_IS_INPUT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_INSTRUMENT_INPUT))
#define BSE_INSTRUMENT_INPUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_INSTRUMENT_INPUT, BseInstrumentInputClass))
-
-
/* --- BseInstrumentInput source --- */
typedef struct _BseInstrumentInput BseInstrumentInput;
typedef struct _BseInstrumentInputClass BseInstrumentInputClass;
@@ -26,8 +21,6 @@ struct _BseInstrumentInputClass
{
BseSubIPortClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -36,8 +29,5 @@ enum
BSE_INSTRUMENT_INPUT_OCHANNEL_VELOCITY,
BSE_INSTRUMENT_INPUT_OCHANNEL_AFTERTOUCH
};
-
-
G_END_DECLS
-
#endif /* __BSE_INSTRUMENT_INPUT_H__ */
diff --git a/bse/bseinstrumentoutput.cc b/bse/bseinstrumentoutput.cc
index 1d081b9..50bc9f2 100644
--- a/bse/bseinstrumentoutput.cc
+++ b/bse/bseinstrumentoutput.cc
@@ -1,24 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseinstrumentoutput.hh"
-
#include "bsecategories.hh"
#include "bsesnet.hh"
#include "bseengine.hh"
-
#include <string.h>
-
/* --- parameters --- */
enum
{
PROP_0,
PROP_OPORT_NAME
};
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_instrument_output_reset_names (BseInstrumentOutput *self)
@@ -27,7 +20,6 @@ bse_instrument_output_reset_names (BseInstrumentOutput *self)
BseItem *item = BSE_ITEM (self);
BseSNet *snet = item->parent ? BSE_SNET (item->parent) : NULL;
const char *name;
-
g_object_freeze_notify (G_OBJECT (self));
name = BSE_SOURCE_ICHANNEL_IDENT (self, 0);
if (strcmp (oport->output_ports[0], name) != 0 &&
@@ -51,32 +43,26 @@ bse_instrument_output_reset_names (BseInstrumentOutput *self)
"BseSubOPort::out_port_4", name, NULL);
g_object_thaw_notify (G_OBJECT (self));
}
-
static void
bse_instrument_output_init (BseInstrumentOutput *self)
{
bse_instrument_output_reset_names (self);
}
-
static void
bse_instrument_output_set_parent (BseItem *item,
BseItem *parent)
{
BseInstrumentOutput *self = BSE_INSTRUMENT_OUTPUT (item);
-
if (item->parent)
g_signal_handlers_disconnect_by_func (item->parent, (void*) bse_instrument_output_reset_names, self);
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
-
if (item->parent)
g_signal_connect_swapped (item->parent, "port_unregistered",
G_CALLBACK (bse_instrument_output_reset_names), self);
else
bse_instrument_output_reset_names (self);
}
-
static void
bse_instrument_output_get_property (GObject *object, uint param_id, GValue *value, GParamSpec *pspec)
{
@@ -87,7 +73,6 @@ bse_instrument_output_get_property (GObject *object, uint param_id, GValue *valu
break;
}
}
-
static void
bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
{
@@ -96,12 +81,9 @@ bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
uint i, ichannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->get_property = bse_instrument_output_get_property;
item_class->set_parent = bse_instrument_output_set_parent;
-
/* assert parent class introduced enough ports */
g_assert (BSE_SUB_OPORT_N_PORTS >= 4);
/* override parent properties with NOP properties */
@@ -113,7 +95,6 @@ bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
/* override parent property: 0 */ "r"));
g_free (string);
}
-
ichannel_id = bse_source_class_add_ichannel (source_class, "left-audio", _("Left Audio"), _("Left Channel Output"));
g_assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_LEFT);
ichannel_id = bse_source_class_add_ichannel (source_class, "right-audio", _("Right Audio"), _("Right Channel Output"));
@@ -123,18 +104,15 @@ bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
ichannel_id = bse_source_class_add_ichannel (source_class, "synth-done", _("Synth Done"), _("High indicates the instrument is done synthesizing"));
g_assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_DONE);
}
-
BSE_BUILTIN_TYPE (BseInstrumentOutput)
{
static const GTypeInfo type_info = {
sizeof (BseInstrumentOutputClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_instrument_output_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseInstrumentOutput),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_instrument_output_init,
diff --git a/bse/bseinstrumentoutput.hh b/bse/bseinstrumentoutput.hh
index 508befb..62d8fb0 100644
--- a/bse/bseinstrumentoutput.hh
+++ b/bse/bseinstrumentoutput.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_INSTRUMENT_OUTPUT_H__
#define __BSE_INSTRUMENT_OUTPUT_H__
-
#include <bse/bsesuboport.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_INSTRUMENT_OUTPUT (BSE_TYPE_ID (BseInstrumentOutput))
#define BSE_INSTRUMENT_OUTPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_INSTRUMENT_OUTPUT, BseInstrumentOutput))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_OUTPUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_INSTRUMENT_OUTPUT))
#define BSE_IS_OUTPUT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_INSTRUMENT_OUTPUT))
#define BSE_INSTRUMENT_OUTPUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_INSTRUMENT_OUTPUT, BseInstrumentOutputClass))
-
-
/* --- BseInstrumentOutput source --- */
typedef struct _BseInstrumentOutput BseInstrumentOutput;
typedef struct _BseInstrumentOutputClass BseInstrumentOutputClass;
@@ -26,8 +21,6 @@ struct _BseInstrumentOutputClass
{
BseSubOPortClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -36,7 +29,5 @@ enum
BSE_INSTRUMENT_OUTPUT_ICHANNEL_UNUSED,
BSE_INSTRUMENT_OUTPUT_ICHANNEL_DONE
};
-
G_END_DECLS
-
#endif /* __BSE_INSTRUMENT_OUTPUT_H__ */
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 87c16ca..4976aa5 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -11,13 +11,10 @@
#include "bseundostack.hh"
#include <gobject/gvaluecollector.h>
#include <string.h>
-
enum {
PROP_0,
PROP_SEQID,
};
-
-
/* --- prototypes --- */
static void bse_item_class_init_base (BseItemClass *klass);
static void bse_item_class_finalize_base (BseItemClass *klass);
@@ -42,83 +39,65 @@ static uint bse_item_do_get_seqid (BseItem
static void bse_item_do_set_parent (BseItem *item,
BseItem *parent);
static BseUndoStack* bse_item_default_get_undo (BseItem *self);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static GSList *item_seqid_changed_queue = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseItem)
{
static const GTypeInfo item_info = {
sizeof (BseItemClass),
-
(GBaseInitFunc) bse_item_class_init_base,
(GBaseFinalizeFunc) bse_item_class_finalize_base,
(GClassInitFunc) bse_item_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseItem),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_item_init,
};
-
g_assert (BSE_ITEM_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
-
return bse_type_register_abstract (BSE_TYPE_OBJECT,
"BseItem",
"Base type for objects managed by a container",
__FILE__, __LINE__,
&item_info);
}
-
static void
bse_item_class_init_base (BseItemClass *klass)
{
klass->get_candidates = NULL;
}
-
static void
bse_item_class_finalize_base (BseItemClass *klass)
{
}
-
static void
bse_item_class_init (BseItemClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->get_property = bse_item_get_property_internal;
gobject_class->set_property = bse_item_set_property_internal;
gobject_class->dispose = bse_item_do_dispose;
gobject_class->finalize = bse_item_do_finalize;
-
object_class->set_uname = bse_item_do_set_uname;
-
klass->set_parent = bse_item_do_set_parent;
klass->get_seqid = bse_item_do_get_seqid;
klass->get_undo = bse_item_default_get_undo;
klass->needs_storage = bse_item_real_needs_storage;
-
bse_object_class_add_param (object_class, NULL,
PROP_SEQID,
sfi_pspec_int ("seqid", "Sequential ID", NULL,
0, 0, SFI_MAXINT, 1, "r"));
bse_item_class_add_parasite_signals (klass);
}
-
static void
bse_item_init (BseItem *item)
{
item->parent = NULL;
}
-
static void
bse_item_set_property_internal (GObject *object,
uint param_id,
@@ -133,7 +112,6 @@ bse_item_set_property_internal (GObject *object,
break;
}
}
-
static void
bse_item_get_property_internal (GObject *object,
uint param_id,
@@ -151,42 +129,32 @@ bse_item_get_property_internal (GObject *object,
break;
}
}
-
static void
bse_item_do_dispose (GObject *gobject)
{
BseItem *item = BSE_ITEM (gobject);
-
/* force removal from parent */
if (item->parent)
bse_container_remove_item (BSE_CONTAINER (item->parent), item);
-
bse_item_delete_parasites (item);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (gobject);
}
-
static void
bse_item_do_finalize (GObject *object)
{
BseItem *item = BSE_ITEM (object);
-
bse_item_delete_parasites (item);
item_seqid_changed_queue = g_slist_remove (item_seqid_changed_queue, item);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
-
g_return_if_fail (item->use_count == 0);
}
-
static void
bse_item_do_set_uname (BseObject *object,
const char *uname)
{
BseItem *item = BSE_ITEM (object);
-
/* ensure that item names within their container are unique,
* and that we don't end up with a NULL uname
*/
@@ -197,7 +165,6 @@ bse_item_do_set_uname (BseObject *object,
BSE_OBJECT_CLASS (parent_class)->set_uname (object, uname);
}
}
-
static void
bse_item_do_set_parent (BseItem *self,
BseItem *parent)
@@ -205,7 +172,6 @@ bse_item_do_set_parent (BseItem *self,
self->parent = parent;
bse_item_update_state (self);
}
-
static gboolean
recurse_update_state (BseItem *self,
void *data)
@@ -213,25 +179,21 @@ recurse_update_state (BseItem *self,
bse_item_update_state (self);
return TRUE;
}
-
static void
bse_item_update_state (BseItem *self)
{
/* save original state */
gboolean old_internal = BSE_ITEM_INTERNAL (self);
-
/* update state */
if ((BSE_OBJECT_FLAGS (self) & BSE_ITEM_FLAG_INTERN) ||
(self->parent && BSE_ITEM_INTERNAL (self->parent)))
BSE_OBJECT_SET_FLAGS (self, BSE_ITEM_FLAG_INTERN_BRANCH);
else
BSE_OBJECT_UNSET_FLAGS (self, BSE_ITEM_FLAG_INTERN_BRANCH);
-
/* compare state and recurse if necessary */
if (BSE_IS_CONTAINER (self) && (old_internal != BSE_ITEM_INTERNAL (self)))
bse_container_forall_items ((BseContainer*) self, recurse_update_state, NULL);
}
-
/**
* @param item valid BseItem
* @param internal TRUE or FALSE
@@ -249,33 +211,27 @@ bse_item_set_internal (void *item,
gboolean internal)
{
BseItem *self = BSE_ITEM (item);
-
g_return_if_fail (BSE_IS_ITEM (self));
-
if (internal)
BSE_OBJECT_SET_FLAGS (self, BSE_ITEM_FLAG_INTERN);
else
BSE_OBJECT_UNSET_FLAGS (self, BSE_ITEM_FLAG_INTERN);
bse_item_update_state (self);
}
-
static gboolean
bse_item_real_needs_storage (BseItem *self,
BseStorage *storage)
{
return TRUE;
}
-
gboolean
bse_item_needs_storage (BseItem *self,
BseStorage *storage)
{
g_return_val_if_fail (BSE_IS_ITEM (self), FALSE);
g_return_val_if_fail (BSE_IS_STORAGE (storage), FALSE);
-
return BSE_ITEM_GET_CLASS (self)->needs_storage (self, storage);
}
-
void
bse_item_compat_setup (BseItem *self,
uint vmajor,
@@ -283,11 +239,9 @@ bse_item_compat_setup (BseItem *self,
uint vmicro)
{
g_return_if_fail (BSE_IS_ITEM (self));
-
if (BSE_ITEM_GET_CLASS (self)->compat_setup)
BSE_ITEM_GET_CLASS (self)->compat_setup (self, vmajor, vminor, vmicro);
}
-
typedef struct {
BseItem *item;
void *data;
@@ -296,20 +250,17 @@ typedef struct {
BseItemCheckContainer ccheck;
BseItemCheckProxy pcheck;
} GatherData;
-
static gboolean
gather_child (BseItem *child,
void *data)
{
GatherData *gdata = (GatherData*) data;
-
if (child != gdata->item && !BSE_ITEM_INTERNAL (child) &&
g_type_is_a (G_OBJECT_TYPE (child), gdata->base_type) &&
(!gdata->pcheck || gdata->pcheck (child, gdata->item, gdata->data)))
bse_item_seq_append (gdata->iseq, child);
return TRUE;
}
-
/**
* @param item valid BseItem from which to start gathering
* @param items sequence of items to append to
@@ -332,18 +283,15 @@ bse_item_gather_items (BseItem *item,
void *data)
{
GatherData gdata;
-
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
g_return_val_if_fail (iseq != NULL, NULL);
g_return_val_if_fail (g_type_is_a (base_type, BSE_TYPE_ITEM), NULL);
-
gdata.item = item;
gdata.data = data;
gdata.iseq = iseq;
gdata.base_type = base_type;
gdata.ccheck = ccheck;
gdata.pcheck = pcheck;
-
item = BSE_IS_CONTAINER (item) ? item : item->parent;
while (item)
{
@@ -354,7 +302,6 @@ bse_item_gather_items (BseItem *item,
}
return iseq;
}
-
static gboolean
gather_typed_ccheck (BseContainer *container,
BseItem *item,
@@ -363,7 +310,6 @@ gather_typed_ccheck (BseContainer *container,
GType type = (GType) data;
return g_type_is_a (G_OBJECT_TYPE (container), type);
}
-
static gboolean
gather_typed_acheck (BseItem *proxy,
BseItem *item,
@@ -371,7 +317,6 @@ gather_typed_acheck (BseItem *proxy,
{
return proxy != item && !bse_item_has_ancestor (item, proxy);
}
-
/**
* @param item valid BseItem from which to start gathering
* @param items sequence of items to append to
@@ -398,7 +343,6 @@ bse_item_gather_items_typed (BseItem *item,
return bse_item_gather_items (item, iseq, proxy_type,
gather_typed_ccheck, gather_typed_acheck, (void*) container_type);
}
-
gboolean
bse_item_get_candidates (BseItem *item,
const char *property,
@@ -406,11 +350,9 @@ bse_item_get_candidates (BseItem *item,
{
BseItemClass *klass;
GParamSpec *pspec;
-
g_return_val_if_fail (BSE_IS_ITEM (item), FALSE);
g_return_val_if_fail (property != NULL, FALSE);
g_return_val_if_fail (pc != NULL, FALSE);
-
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (item), property);
if (!pspec)
return FALSE;
@@ -423,25 +365,21 @@ bse_item_get_candidates (BseItem *item,
klass->get_candidates (item, pspec->param_id, pc, pspec);
return TRUE;
}
-
BseItem*
bse_item_use (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
g_return_val_if_fail (G_OBJECT (item)->ref_count > 0, NULL);
-
if (!item->use_count)
g_object_ref (item);
item->use_count++;
return item;
}
-
void
bse_item_unuse (BseItem *item)
{
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (item->use_count > 0);
-
item->use_count--;
if (!item->use_count)
{
@@ -450,7 +388,6 @@ bse_item_unuse (BseItem *item)
g_object_unref (item);
}
}
-
void
bse_item_set_parent (BseItem *item,
BseItem *parent)
@@ -464,21 +401,16 @@ bse_item_set_parent (BseItem *item,
else
g_return_if_fail (item->parent != NULL);
g_return_if_fail (BSE_ITEM_GET_CLASS (item)->set_parent != NULL); /* paranoid */
-
g_object_ref (item);
if (parent)
g_object_ref (parent);
-
BSE_ITEM_GET_CLASS (item)->set_parent (item, parent);
-
if (parent)
g_object_unref (parent);
else
g_object_run_dispose (G_OBJECT (item));
-
g_object_unref (item);
}
-
static uint
bse_item_do_get_seqid (BseItem *item)
{
@@ -487,56 +419,44 @@ bse_item_do_get_seqid (BseItem *item)
else
return 0;
}
-
static gboolean
idle_handler_seqid_changed (void *data)
{
BSE_THREADS_ENTER ();
-
while (item_seqid_changed_queue)
{
BseItem *item = (BseItem*) g_slist_pop_head (&item_seqid_changed_queue);
g_object_notify (G_OBJECT (item), "seqid");
}
-
BSE_THREADS_LEAVE ();
-
return FALSE;
}
-
void
bse_item_queue_seqid_changed (BseItem *item)
{
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (BSE_ITEM (item)->parent != NULL);
-
if (!item_seqid_changed_queue)
bse_idle_notify (idle_handler_seqid_changed, NULL);
-
if (!g_slist_find (item_seqid_changed_queue, item))
item_seqid_changed_queue = g_slist_prepend (item_seqid_changed_queue, item);
}
-
uint
bse_item_get_seqid (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), 0);
g_return_val_if_fail (BSE_ITEM_GET_CLASS (item)->get_seqid != NULL, 0); /* paranoid */
-
return BSE_ITEM_GET_CLASS (item)->get_seqid (item);
}
-
BseItem*
bse_item_common_ancestor (BseItem *item1,
BseItem *item2)
{
g_return_val_if_fail (BSE_IS_ITEM (item1), NULL);
g_return_val_if_fail (BSE_IS_ITEM (item2), NULL);
-
do
{
BseItem *item = item2;
-
do
{
if (item == item1)
@@ -547,10 +467,8 @@ bse_item_common_ancestor (BseItem *item1,
item1 = item1->parent;
}
while (item1);
-
return NULL;
}
-
/**
* @param owner reference owner
* @param link item to be referenced by @a owner
@@ -568,13 +486,10 @@ bse_item_cross_link (BseItem *owner,
BseItemUncross uncross_func)
{
BseItem *container;
-
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
g_return_if_fail (uncross_func != NULL);
-
container = bse_item_common_ancestor (owner, link);
-
if (container)
_bse_container_cross_link (BSE_CONTAINER (container), owner, link, uncross_func);
else
@@ -582,7 +497,6 @@ bse_item_cross_link (BseItem *owner,
bse_object_debug_name (owner),
bse_object_debug_name (link));
}
-
/**
* @param owner reference owner
* @param link item referenced by @a owner
@@ -597,13 +511,10 @@ bse_item_cross_unlink (BseItem *owner,
BseItemUncross uncross_func)
{
BseItem *container;
-
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
g_return_if_fail (uncross_func != NULL);
-
container = bse_item_common_ancestor (owner, link);
-
if (container)
_bse_container_cross_unlink (BSE_CONTAINER (container), owner, link, uncross_func);
else
@@ -611,7 +522,6 @@ bse_item_cross_unlink (BseItem *owner,
BSE_OBJECT_TYPE_NAME (owner),
BSE_OBJECT_TYPE_NAME (link));
}
-
/**
* @param owner reference owner
* @param link item referenced by @a owner
@@ -624,77 +534,58 @@ bse_item_uncross_links (BseItem *owner,
BseItem *link)
{
BseItem *container;
-
g_return_if_fail (BSE_IS_ITEM (owner));
g_return_if_fail (BSE_IS_ITEM (link));
-
container = bse_item_common_ancestor (owner, link);
-
if (container)
_bse_container_uncross (BSE_CONTAINER (container), owner, link);
}
-
BseSuper*
bse_item_get_super (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
-
while (!BSE_IS_SUPER (item) && item)
item = item->parent;
-
return item ? BSE_SUPER (item) : NULL;
}
-
BseSNet*
bse_item_get_snet (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
-
while (!BSE_IS_SNET (item) && item)
item = item->parent;
-
return item ? BSE_SNET (item) : NULL;
}
-
BseItem*
bse_item_get_toplevel (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
-
while (item->parent)
item = item->parent;
-
return item;
}
-
BseProject*
bse_item_get_project (BseItem *item)
{
g_return_val_if_fail (BSE_IS_ITEM (item), NULL);
-
while (item->parent)
item = item->parent;
-
return BSE_IS_PROJECT (item) ? (BseProject*) item : NULL;
}
-
gboolean
bse_item_has_ancestor (BseItem *item,
BseItem *ancestor)
{
g_return_val_if_fail (BSE_IS_ITEM (item), FALSE);
g_return_val_if_fail (BSE_IS_ITEM (ancestor), FALSE);
-
while (item->parent)
{
item = item->parent;
if (item == ancestor)
return TRUE;
}
-
return FALSE;
}
-
/**
* @param self a valid Item
* @return the current BseMusicalTuningType, defaulting to BSE_MUSICAL_TUNING_12_TET
@@ -721,7 +612,6 @@ bse_item_current_musical_tuning (BseItem *self)
}
return BSE_MUSICAL_TUNING_12_TET;
}
-
static inline GType
find_method_procedure (GType object_type,
const char *method_name)
@@ -732,13 +622,11 @@ find_method_procedure (GType object_type,
{
const char *type_name = g_type_name (type);
uint l1 = strlen (type_name);
-
char *name = g_new (char, l1 + 1 + l2 + 1);
memcpy (name, type_name, l1);
name[l1] = '+';
memcpy (name + l1 + 1, method_name, l2);
name[l1 + 1 + l2] = 0;
-
proc_type = bse_procedure_lookup (name);
g_free (name);
if (proc_type)
@@ -748,7 +636,6 @@ find_method_procedure (GType object_type,
while (type != BSE_TYPE_ITEM); /* type will become BSE_TYPE_ITEM eventually */
return proc_type;
}
-
static inline BseErrorType
bse_item_execva_i (BseItem *item,
const char *procedure,
@@ -758,14 +645,12 @@ bse_item_execva_i (BseItem *item,
BseErrorType error;
GType proc_type = find_method_procedure (BSE_OBJECT_TYPE (item), procedure);
GValue obj_value;
-
if (!proc_type)
{
g_warning ("no such method \"%s\" of item %s",
procedure, bse_object_debug_name (item));
return BSE_ERROR_INTERNAL;
}
-
/* setup first arg (the object) */
obj_value.g_type = 0;
g_value_init (&obj_value, BSE_TYPE_ITEM);
@@ -775,7 +660,6 @@ bse_item_execva_i (BseItem *item,
g_value_unset (&obj_value);
return error;
}
-
BseErrorType
bse_item_exec (void *_item,
const char *procedure,
@@ -784,17 +668,13 @@ bse_item_exec (void *_item,
BseItem *item = (BseItem*) _item;
va_list var_args;
BseErrorType error;
-
g_return_val_if_fail (BSE_IS_ITEM (item), BSE_ERROR_INTERNAL);
g_return_val_if_fail (procedure != NULL, BSE_ERROR_INTERNAL);
-
va_start (var_args, procedure);
error = bse_item_execva_i (item, procedure, var_args, FALSE);
va_end (var_args);
-
return error;
}
-
BseErrorType
bse_item_exec_void (void *_item,
const char *procedure,
@@ -803,17 +683,13 @@ bse_item_exec_void (void *_item,
BseItem *item = (BseItem*) _item;
va_list var_args;
BseErrorType error;
-
g_return_val_if_fail (BSE_IS_ITEM (item), BSE_ERROR_INTERNAL);
g_return_val_if_fail (procedure != NULL, BSE_ERROR_INTERNAL);
-
va_start (var_args, procedure);
error = bse_item_execva_i (item, procedure, var_args, TRUE);
va_end (var_args);
-
return error;
}
-
static GValue*
pack_value_for_undo (GValue *value,
BseUndoStack *ustack)
@@ -828,7 +704,6 @@ pack_value_for_undo (GValue *value,
}
return value;
}
-
static GValue*
unpack_value_from_undo (GValue *value,
BseUndoStack *ustack)
@@ -843,7 +718,6 @@ unpack_value_from_undo (GValue *value,
}
return value;
}
-
static void
unde_free_proc (BseUndoStep *ustep)
{
@@ -858,7 +732,6 @@ unde_free_proc (BseUndoStep *ustep)
g_type_class_unref (proc);
}
}
-
static void
undo_call_proc (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -909,7 +782,6 @@ undo_call_proc (BseUndoStep *ustep,
bse_object_debug_name (g_value_get_object (ivalues + 0)), bse_error_blurb (error));
}
}
-
static void
bse_item_push_undo_proc_valist (void *item,
const char *procedure,
@@ -935,7 +807,6 @@ bse_item_push_undo_proc_valist (void *item,
bse_item_undo_close (ustack);
return;
}
-
proc = (BseProcedureClass*) g_type_class_ref (proc_type);
/* we allow one return value */
if (proc->n_out_pspecs > 1)
@@ -946,13 +817,11 @@ bse_item_push_undo_proc_valist (void *item,
bse_item_undo_close (ustack);
return;
}
-
ivalues = g_new (GValue, proc->n_in_pspecs);
/* setup first arg (the object) */
ivalues[0].g_type = 0;
g_value_init (ivalues + 0, BSE_TYPE_ITEM);
g_value_set_object (ivalues + 0, item);
-
/* collect procedure args */
error = bse_procedure_collect_input_args (proc, ivalues + 0, var_args, ivalues);
if (!error)
@@ -977,51 +846,41 @@ bse_item_push_undo_proc_valist (void *item,
}
bse_item_undo_close (ustack);
}
-
void
bse_item_push_undo_proc (void *item,
const char *procedure,
...)
{
va_list var_args;
-
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (procedure != NULL);
-
va_start (var_args, procedure);
bse_item_push_undo_proc_valist (item, procedure, FALSE, var_args);
va_end (var_args);
}
-
void
bse_item_push_redo_proc (void *item,
const char *procedure,
...)
{
va_list var_args;
-
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (procedure != NULL);
-
va_start (var_args, procedure);
bse_item_push_undo_proc_valist (item, procedure, TRUE, var_args);
va_end (var_args);
}
-
void
bse_item_set_undoable (void *object,
const char *first_property_name,
...)
{
va_list var_args;
-
g_return_if_fail (BSE_IS_ITEM (object));
-
va_start (var_args, first_property_name);
bse_item_set_valist_undoable (object, first_property_name, var_args);
va_end (var_args);
}
-
void
bse_item_set_valist_undoable (void *object,
const char *first_property_name,
@@ -1029,19 +888,15 @@ bse_item_set_valist_undoable (void *object,
{
BseItem *self = BSE_ITEM (object);
const char *name;
-
g_return_if_fail (BSE_IS_ITEM (self));
-
g_object_ref (object);
g_object_freeze_notify (G_OBJECT (object));
-
name = first_property_name;
while (name)
{
GValue value = { 0, };
GParamSpec *pspec;
char *error = NULL;
-
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), name);
if (!pspec)
{
@@ -1066,7 +921,6 @@ bse_item_set_valist_undoable (void *object,
g_object_thaw_notify (G_OBJECT (object));
g_object_unref (object);
}
-
static BseUndoStack*
bse_item_default_get_undo (BseItem *self)
{
@@ -1075,7 +929,6 @@ bse_item_default_get_undo (BseItem *self)
else
return NULL;
}
-
static gboolean
values_equal_for_undo (const GValue *v1,
const GValue *v2)
@@ -1099,7 +952,6 @@ values_equal_for_undo (const GValue *v1,
}
return FALSE;
}
-
static void
undo_set_property (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -1108,7 +960,6 @@ undo_set_property (BseUndoStep *ustep,
(const char*) ustep->data[1].v_pointer,
unpack_value_from_undo ((GValue*) ustep->data[2].v_pointer, ustack));
}
-
static void
unde_free_property (BseUndoStep *ustep)
{
@@ -1117,7 +968,6 @@ unde_free_property (BseUndoStep *ustep)
g_value_unset ((GValue*) ustep->data[2].v_pointer); /* may or may not be unpacked */
g_free (ustep->data[2].v_pointer);
}
-
static inline gboolean
item_property_check_skip_undo (BseItem *self,
const char *name)
@@ -1125,7 +975,6 @@ item_property_check_skip_undo (BseItem *self,
GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), name);
return pspec && sfi_pspec_check_option (pspec, "skip-undo");
}
-
void
bse_item_set_property_undoable (BseItem *self,
const char *name,
@@ -1158,7 +1007,6 @@ bse_item_set_property_undoable (BseItem *self,
bse_undo_stack_push (ustack, ustep);
bse_item_undo_close (ustack);
}
-
BseUndoStack*
bse_item_undo_open (void *item,
const char *format,
@@ -1168,9 +1016,7 @@ bse_item_undo_open (void *item,
BseUndoStack *ustack;
char *buffer;
va_list args;
-
g_return_val_if_fail (format != NULL, NULL);
-
ustack = BSE_ITEM_GET_CLASS (self)->get_undo (self);
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
@@ -1187,14 +1033,12 @@ bse_item_undo_open (void *item,
g_free (buffer);
return ustack;
}
-
void
bse_item_undo_close (BseUndoStack *ustack)
{
if (ustack)
bse_undo_group_close (ustack);
}
-
static void
undo_restore_item (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -1202,14 +1046,11 @@ undo_restore_item (BseUndoStep *ustep,
BseItem *item = (BseItem*) bse_undo_pointer_unpack ((const char*) ustep->data[0].v_pointer, ustack);
BseStorage *storage = BSE_STORAGE (ustep->data[1].v_pointer);
GTokenType expected_token = G_TOKEN_NONE;
-
expected_token = bse_storage_restore_item (storage, item);
if (expected_token != G_TOKEN_NONE)
bse_storage_unexp_token (storage, expected_token);
-
bse_storage_finish_parsing (storage);
}
-
static void
unde_free_item (BseUndoStep *ustep)
{
@@ -1218,7 +1059,6 @@ unde_free_item (BseUndoStep *ustep)
bse_storage_reset (storage);
g_object_unref (storage);
}
-
void
bse_item_push_undo_storage (BseItem *self,
BseUndoStack *ustack,
@@ -1235,7 +1075,6 @@ bse_item_push_undo_storage (BseItem *self,
else
bse_storage_reset (storage);
}
-
void
bse_item_backup_to_undo (BseItem *self,
BseUndoStack *ustack)
@@ -1246,7 +1085,6 @@ bse_item_backup_to_undo (BseItem *self,
bse_storage_prepare_write (storage, BseStorageMode (BSE_STORAGE_DBLOCK_CONTAINED |
BSE_STORAGE_SELF_CONTAINED));
bse_storage_store_item (storage, self);
-
bse_item_push_undo_storage (self, ustack, storage);
g_object_unref (storage);
}
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index bf7cd75..bb7f76b 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ITEM_H__
#define __BSE_ITEM_H__
-
#include <bse/bseobject.hh>
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_ITEM (BSE_TYPE_ID (BseItem))
#define BSE_ITEM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_ITEM, BseItem))
@@ -14,13 +10,9 @@ G_BEGIN_DECLS
#define BSE_IS_ITEM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_ITEM))
#define BSE_IS_ITEM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_ITEM))
#define BSE_ITEM_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_ITEM, BseItemClass))
-
-
/* --- BseItem member macros --- */
#define BSE_ITEM_SINGLETON(object) ((BSE_OBJECT_FLAGS (object) & BSE_ITEM_FLAG_SINGLETON) != 0)
#define BSE_ITEM_INTERNAL(item) ((BSE_OBJECT_FLAGS (item) & BSE_ITEM_FLAG_INTERN_BRANCH) != 0)
-
-
/* --- bse item flags --- */
typedef enum /*< skip >*/
{
@@ -29,13 +21,10 @@ typedef enum /*< skip >*/
BSE_ITEM_FLAG_INTERN_BRANCH = 1 << (BSE_OBJECT_FLAGS_USHIFT + 2)
} BseItemFlags;
#define BSE_ITEM_FLAGS_USHIFT (BSE_OBJECT_FLAGS_USHIFT + 3)
-
-
/* --- BseItem object --- */
struct _BseItem
{
BseObject parent_object;
-
guint use_count;
BseItem *parent;
BseParasite *parasite;
@@ -43,7 +32,6 @@ struct _BseItem
struct _BseItemClass
{
BseObjectClass parent_class;
-
void (*get_candidates) (BseItem *item,
guint param_id,
BsePropertyCandidates *pc,
@@ -59,7 +47,6 @@ struct _BseItemClass
guint (*get_seqid) (BseItem *item);
BseUndoStack* (*get_undo) (BseItem *item);
};
-
typedef void (*BseItemUncross) (BseItem *owner,
BseItem *link);
typedef gboolean (*BseItemCheckContainer) (BseContainer *container,
@@ -68,8 +55,6 @@ typedef gboolean (*BseItemCheckContainer) (BseContainer *container,
typedef gboolean (*BseItemCheckProxy) (BseItem *proxy,
BseItem *item,
gpointer data);
-
-
/* --- prototypes --- */
BseItemSeq* bse_item_gather_items (BseItem *item,
BseItemSeq *iseq,
@@ -152,7 +137,5 @@ void bse_item_push_undo_storage (BseItem *self,
#define bse_item_set bse_item_set_undoable
#define bse_item_get g_object_get
BseMusicalTuningType bse_item_current_musical_tuning (BseItem *self);
-
G_END_DECLS
-
#endif /* __BSE_ITEM_H__ */
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index c408ca7..b2a6e58 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -6,12 +6,8 @@
#include <bse/bseundostack.hh>
#include <bse/bseparasite.hh> // FIXME
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseItem, get-type) {
HELP = "Retrieve an item's type name.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -24,17 +20,13 @@ METHOD (BseItem, get-type) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_static_string (out_values++, g_type_name (G_OBJECT_TYPE (item)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-type-name) {
HELP = "Retrieve an item's type name.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -48,17 +40,13 @@ METHOD (BseItem, get-type-name) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, g_type_name (G_OBJECT_TYPE (item)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-type-blurb) {
HELP = "Retrieve an item's type description.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -72,17 +60,13 @@ METHOD (BseItem, get-type-blurb) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, bse_type_get_blurb (G_OBJECT_TYPE (item)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-type-authors) {
HELP = "Retrieve authors of an item's type implementation.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -96,17 +80,13 @@ METHOD (BseItem, get-type-authors) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, bse_type_get_authors (G_OBJECT_TYPE (item)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-type-license) {
HELP = "Retrieve the license for an item's type implementation.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -120,17 +100,13 @@ METHOD (BseItem, get-type-license) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, bse_type_get_license (G_OBJECT_TYPE (item)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-parent) {
HELP = "Retrieve an item's parent.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -143,17 +119,13 @@ METHOD (BseItem, get-parent) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, item->parent);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-project) {
HELP = "Retrieve an item's project.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -166,17 +138,13 @@ METHOD (BseItem, get-project) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_item_get_project (item));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-uname-path) {
HELP = "Retrieve the project relative uname path for this item.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -190,20 +158,15 @@ METHOD (BseItem, get-uname-path) {
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (item);
-
/* set output parameters */
sfi_value_take_string (out_values++,
project ? bse_container_make_upath (BSE_CONTAINER (project), item) : NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, internal) {
HELP = "Check whether an item is internal, i.e. owned by another non-internal item.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -216,17 +179,13 @@ METHOD (BseItem, internal) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, BSE_ITEM_INTERNAL (item));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, use) {
HELP = "Increment use count to keep an item alive.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -239,20 +198,15 @@ METHOD (BseItem, use) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item) || (!item->parent && !item->use_count))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_item_use (item);
-
/* set output parameters */
bse_value_set_object (out_values++, item);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, unuse) {
HELP = "Decrement use count for when an item is not needed anymore.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -263,20 +217,15 @@ METHOD (BseItem, unuse) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (item->use_count < 1)
return BSE_ERROR_NOT_OWNER;
-
bse_item_unuse (item);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, set-name) {
HELP = "Set an item's name.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -290,19 +239,14 @@ METHOD (BseItem, set-name) {
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
const gchar *name = g_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!bse_string_equals (name, BSE_OBJECT_UNAME (item)))
bse_item_set (item, "uname", name, NULL);
-
return BSE_ERROR_NONE;
}
-
-
METHOD (BseItem, get-name) {
HELP = "Retrieve an item's name.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -315,17 +259,13 @@ METHOD (BseItem, get-name) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_OBJECT_UNAME (item));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-name-or-type) {
HELP = "Retrieve an item's name or type if it has no name.";
IN = bse_param_spec_object ("item", "Item", NULL,
@@ -339,21 +279,17 @@ METHOD (BseItem, get-name-or-type) {
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
gchar *name = NULL;
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
name = BSE_OBJECT_UNAME (item);
if (name)
sfi_value_set_string (out_values++, name);
else
sfi_value_set_string (out_values++, BSE_OBJECT_TYPE_NAME (item));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, common-ancestor) {
HELP = "Retrieve the common ancestor of two items if there's any.";
IN = bse_param_spec_object ("item", "Item", "First item",
@@ -369,17 +305,13 @@ METHOD (BseItem, common-ancestor) {
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
BseItem *item2 = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item) || !BSE_IS_ITEM (item2))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_item_common_ancestor (item, item2));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-seqid) {
HELP = ("Retrieve an item's sequential ID. The sequential ID depends "
"on the item's type an it's position inbetween siblings "
@@ -394,17 +326,13 @@ METHOD (BseItem, get-seqid) {
{
/* extract parameter values */
BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (item))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, bse_item_get_seqid (item));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, check-is-a) {
HELP = "Check whether an item has a certain type.";
IN = bse_param_spec_object ("item", "Item", "The Item",
@@ -422,21 +350,16 @@ METHOD (BseItem, check-is-a) {
const char *type_name = sfi_value_get_string (in_values++);
GType type;
gboolean is_a;
-
/* check parameters */
if (!type_name)
type_name = "";
-
/* action */
type = g_type_from_name (type_name);
is_a = item && g_type_is_a (G_OBJECT_TYPE (item), type);
-
/* set output parameters */
sfi_value_set_bool (out_values++, is_a);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-property-candidates) {
HELP = "Retrieve tentative values for an item or item sequence property.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -451,11 +374,9 @@ METHOD (BseItem, get-property-candidates) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
const char *property = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (self) || !property)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
BsePropertyCandidates *pc = bse_property_candidates_new();
if (!bse_item_get_candidates (self, property, pc))
@@ -464,10 +385,8 @@ METHOD (BseItem, get-property-candidates) {
pc = NULL;
}
bse_value_take_boxed (out_values++, pc);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, editable-property) {
HELP = "Test whether a property is editable according to object state and property options.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -482,17 +401,13 @@ METHOD (BseItem, editable-property) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
const char *property = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (self) || !property)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, bse_object_editable_property (self, property));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-icon) {
HELP = "Get the current icon of an item.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -505,17 +420,13 @@ METHOD (BseItem, get-icon) {
{
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_boxed (out_values++, bse_object_get_icon (BSE_OBJECT (self)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, group-undo) {
HELP = "Request multiple modifying actions on an item to be grouped together as single undo operation.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -530,18 +441,14 @@ METHOD (BseItem, group-undo) {
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
const char *name = sfi_value_get_string (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_ITEM (self) || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
ustack = bse_item_undo_open (self, "item-group-undo");
bse_undo_stack_add_merger (ustack, name);
bse_item_undo_close (ustack);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, ungroup-undo) {
HELP = "Ends the undo grouping opened up by a previous group-undo() call.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -553,18 +460,14 @@ METHOD (BseItem, ungroup-undo) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
ustack = bse_item_undo_open (self, "item-ungroup-undo");
bse_undo_stack_remove_merger (ustack);
bse_item_undo_close (ustack);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, undo) {
HELP = "Call the undo function of the project corresponding to this item if any.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -576,18 +479,14 @@ METHOD (BseItem, undo) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (self);
if (project)
bse_item_exec_void (project, "undo");
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, redo) {
HELP = "Call the redo function of the project corresponding to this item if any.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -599,18 +498,14 @@ METHOD (BseItem, redo) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (self);
if (project)
bse_item_exec_void (project, "redo");
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, clear-undo) {
HELP = "Call the clear-undo function of the project corresponding to this item if any.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -622,18 +517,14 @@ METHOD (BseItem, clear-undo) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (self);
if (project)
bse_item_exec_void (project, "clear-undo");
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, undo-depth) {
HELP = "Call the undo-depth function of the project corresponding to this item if any.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -648,21 +539,16 @@ METHOD (BseItem, undo-depth) {
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
gint depth = 0;
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (self);
if (project)
bse_item_exec (project, "undo-depth", &depth);
-
/* set output parameters */
sfi_value_set_int (out_values++, depth);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, redo-depth) {
HELP = "Call the redo-depth function of the project corresponding to this item if any.";
IN = bse_param_spec_object ("item", NULL, NULL,
@@ -677,21 +563,16 @@ METHOD (BseItem, redo-depth) {
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
gint depth = 0;
BseProject *project;
-
/* check parameters */
if (!BSE_IS_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
project = bse_item_get_project (self);
if (project)
bse_item_exec (project, "redo-depth", &depth);
-
/* set output parameters */
sfi_value_set_int (out_values++, depth);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, fixme-set-parasite) {
IN = bse_param_spec_object ("item", NULL, NULL,
BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
@@ -705,17 +586,13 @@ METHOD (BseItem, fixme-set-parasite) {
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
const gchar *name = sfi_value_get_string (in_values++);
SfiFBlock *fblock = sfi_value_get_fblock (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (self) || !name || !fblock)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_parasite_set_floats (BSE_OBJECT (self), name, fblock->n_values, fblock->values);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, fixme-get-parasite) {
IN = bse_param_spec_object ("item", NULL, NULL,
BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
@@ -728,13 +605,10 @@ METHOD (BseItem, fixme-get-parasite) {
/* extract parameter values */
BseItem *self = (BseItem*) bse_value_get_object (in_values++);
const gchar *name = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_ITEM (self) || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_take_fblock (out_values++, bse_parasite_get_floats (BSE_OBJECT (self), name));
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsejanitor.cc b/bse/bsejanitor.cc
index 69cc5bd..17c4abe 100644
--- a/bse/bsejanitor.cc
+++ b/bse/bsejanitor.cc
@@ -6,8 +6,6 @@
#include "bsecontainer.hh"
#include "bseprocedure.hh"
#include "bsescripthelper.hh"
-
-
enum
{
PROP_0,
@@ -17,8 +15,6 @@ enum
PROP_EXIT_CODE,
PROP_EXIT_REASON,
};
-
-
/* --- prototypes --- */
static void bse_janitor_class_init (BseJanitorClass *klass);
static void bse_janitor_init (BseJanitor *janitor);
@@ -41,8 +37,6 @@ static GValue* janitor_client_msg (SfiGlueDecoder *decoder,
void *user_data,
const char *message,
const GValue *value);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static GSList *janitor_stack = NULL;
@@ -50,47 +44,37 @@ static uint signal_action = 0;
static uint signal_action_changed = 0;
static uint signal_shutdown = 0;
static uint signal_progress = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseJanitor)
{
static const GTypeInfo janitor_info = {
sizeof (BseJanitorClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_janitor_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseJanitor),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_janitor_init,
};
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BseJanitor",
"BSE connection interface object",
__FILE__, __LINE__,
&janitor_info);
}
-
static void
bse_janitor_class_init (BseJanitorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_janitor_set_property;
gobject_class->get_property = bse_janitor_get_property;
gobject_class->finalize = bse_janitor_finalize;
-
item_class->set_parent = bse_janitor_set_parent;
-
bse_object_class_add_param (object_class, NULL, PROP_IDENT,
sfi_pspec_string ("ident", "Script Identifier", NULL, NULL, SFI_PARAM_GUI));
bse_object_class_add_param (object_class, NULL, PROP_CONNECTED,
@@ -101,7 +85,6 @@ bse_janitor_class_init (BseJanitorClass *klass)
sfi_pspec_int ("exit-code", "Exit Code", NULL, 0, -256, 256, 0, "G:r"));
bse_object_class_add_param (object_class, NULL, PROP_EXIT_REASON,
sfi_pspec_string ("exit-reason", "Exit Reason", NULL, NULL, "G:r"));
-
signal_progress = bse_object_class_add_signal (object_class, "progress",
G_TYPE_NONE, 1, G_TYPE_FLOAT);
signal_action_changed = bse_object_class_add_dsignal (object_class, "action-changed",
@@ -112,7 +95,6 @@ bse_janitor_class_init (BseJanitorClass *klass)
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, G_TYPE_INT);
signal_shutdown = bse_object_class_add_signal (object_class, "shutdown", G_TYPE_NONE, 0);
}
-
static void
bse_janitor_init (BseJanitor *self)
{
@@ -130,7 +112,6 @@ bse_janitor_init (BseJanitor *self)
self->exit_code = 0;
self->exit_reason = NULL;
}
-
static void
bse_janitor_set_property (GObject *object,
uint param_id,
@@ -138,7 +119,6 @@ bse_janitor_set_property (GObject *object,
GParamSpec *pspec)
{
BseJanitor *self = BSE_JANITOR (object);
-
switch (param_id)
{
case PROP_STATUS_MESSAGE:
@@ -150,7 +130,6 @@ bse_janitor_set_property (GObject *object,
break;
}
}
-
static void
bse_janitor_get_property (GObject *object,
uint param_id,
@@ -158,7 +137,6 @@ bse_janitor_get_property (GObject *object,
GParamSpec *pspec)
{
BseJanitor *self = BSE_JANITOR (object);
-
switch (param_id)
{
case PROP_IDENT:
@@ -181,40 +159,31 @@ bse_janitor_get_property (GObject *object,
break;
}
}
-
static void
bse_janitor_finalize (GObject *object)
{
BseJanitor *self = BSE_JANITOR (object);
-
g_return_if_fail (self->port == NULL);
g_return_if_fail (self->source == NULL);
-
while (self->actions)
{
BseJanitorAction *a = (BseJanitorAction*) self->actions->data;
bse_janitor_remove_action (self, g_quark_to_string (a->action));
}
-
g_free (self->status_message);
g_free (self->script_name);
g_free (self->proc_name);
g_free (self->exit_reason);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
BseJanitor*
bse_janitor_new (SfiComPort *port)
{
BseJanitor *self;
-
g_return_val_if_fail (port != NULL, NULL);
-
self = (BseJanitor*) bse_container_new_child ((BseContainer*) bse_server_get (), BSE_TYPE_JANITOR, NULL);
g_object_ref (self);
-
/* store the port */
self->port = sfi_com_port_ref (port);
sfi_com_port_set_close_func (self->port, janitor_port_closed, self);
@@ -225,32 +194,26 @@ bse_janitor_new (SfiComPort *port)
sfi_glue_decoder_add_handler (self->decoder, janitor_client_msg, self);
/* main loop integration */
janitor_install_jsource (self);
-
return self;
}
-
void
bse_janitor_set_procedure (BseJanitor *self,
const char *script_name,
const char *proc_name)
{
g_return_if_fail (BSE_IS_JANITOR (self));
-
g_free (self->proc_name);
self->proc_name = g_strdup (proc_name);
g_free (self->script_name);
self->script_name = g_strdup (script_name);
g_object_notify (G_OBJECT (self), "status-message");
}
-
const char*
bse_janitor_get_ident (BseJanitor *self)
{
g_return_val_if_fail (BSE_IS_JANITOR (self), NULL);
-
return self->port ? self->port->ident : NULL;
}
-
/**
* @param self janitor object
* @param progress progress value
@@ -264,14 +227,12 @@ bse_janitor_progress (BseJanitor *self,
float progress)
{
g_return_if_fail (BSE_IS_JANITOR (self));
-
if (progress < 0)
progress = -1;
else
progress = CLAMP (progress, 0, 1.0);
g_signal_emit (self, signal_progress, 0, progress);
}
-
static BseJanitorAction*
find_action (BseJanitor *self,
GQuark aquark)
@@ -285,7 +246,6 @@ find_action (BseJanitor *self,
}
return NULL;
}
-
void
bse_janitor_add_action (BseJanitor *self,
const char *action,
@@ -293,12 +253,10 @@ bse_janitor_add_action (BseJanitor *self,
const char *blurb)
{
BseJanitorAction *a;
-
g_return_if_fail (BSE_IS_JANITOR (self));
g_return_if_fail (action != NULL);
g_return_if_fail (name != NULL);
g_return_if_fail (!BSE_OBJECT_DISPOSING (self));
-
a = find_action (self, g_quark_try_string (action));
if (!a)
{
@@ -310,21 +268,17 @@ bse_janitor_add_action (BseJanitor *self,
a->blurb = g_strdup (blurb);
g_signal_emit (self, signal_action_changed, a->action, g_quark_to_string (a->action), g_slist_index (self->actions, a));
}
-
void
bse_janitor_remove_action (BseJanitor *self,
const char *action)
{
BseJanitorAction *a;
-
g_return_if_fail (BSE_IS_JANITOR (self));
g_return_if_fail (action != NULL);
-
a = find_action (self, g_quark_try_string (action));
if (a)
{
GQuark aquark;
-
self->actions = g_slist_remove (self->actions, a);
aquark = a->action;
g_free (a->name);
@@ -334,27 +288,22 @@ bse_janitor_remove_action (BseJanitor *self,
g_signal_emit (self, signal_action_changed, aquark, g_quark_to_string (aquark), g_slist_length (self->actions));
}
}
-
void
bse_janitor_trigger_action (BseJanitor *self,
const char *action)
{
BseJanitorAction *a;
-
g_return_if_fail (BSE_IS_JANITOR (self));
g_return_if_fail (action != NULL);
-
a = find_action (self, g_quark_try_string (action));
if (a && !BSE_OBJECT_DISPOSING (self))
g_signal_emit (self, signal_action, a->action, g_quark_to_string (a->action), g_slist_index (self->actions, a));
}
-
BseJanitor*
bse_janitor_get_current (void)
{
return janitor_stack ? (BseJanitor*) janitor_stack->data : NULL;
}
-
static void
janitor_shutdown (BseJanitor *self)
{
@@ -366,7 +315,6 @@ janitor_shutdown (BseJanitor *self)
bse_idle_timed (n_seconds * SFI_USEC_FACTOR, janitor_idle_clean_jsource, g_object_ref (self));
g_signal_emit (self, signal_shutdown, 0);
}
-
void
bse_janitor_close (BseJanitor *self)
{
@@ -374,33 +322,27 @@ bse_janitor_close (BseJanitor *self)
if (self->port && !self->port_closed)
janitor_shutdown (self);
}
-
void
bse_janitor_kill (BseJanitor *self)
{
g_return_if_fail (BSE_IS_JANITOR (self));
-
if (!self->port_closed)
{
self->force_kill = TRUE;
bse_janitor_close (self);
}
}
-
static void
bse_janitor_set_parent (BseItem *item,
BseItem *parent)
{
BseJanitor *self = BSE_JANITOR (item);
-
if (!parent && /* removal */
!self->port_closed)
janitor_shutdown (self);
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
}
-
static GValue*
janitor_client_msg (SfiGlueDecoder *decoder,
void *user_data,
@@ -414,14 +356,11 @@ janitor_client_msg (SfiGlueDecoder *decoder,
return rvalue;
return NULL;
}
-
-
/* --- main loop intergration --- */
typedef struct {
GSource source;
BseJanitor *janitor;
} JSource;
-
static gboolean
janitor_prepare (GSource *source,
int *timeout_p)
@@ -429,14 +368,12 @@ janitor_prepare (GSource *source,
BseJanitor *self = ((JSource*) source)->janitor;
return sfi_glue_decoder_pending (self->decoder);
}
-
static gboolean
janitor_check (GSource *source)
{
BseJanitor *self = ((JSource*) source)->janitor;
return sfi_glue_decoder_pending (self->decoder);
}
-
static gboolean
janitor_dispatch (GSource *source,
GSourceFunc callback,
@@ -444,14 +381,11 @@ janitor_dispatch (GSource *source,
{
BseJanitor *self = ((JSource*) source)->janitor;
SfiComPort *port = self->port;
-
if (!port)
return TRUE; /* keep source alive */
-
janitor_stack = g_slist_prepend (janitor_stack, self);
sfi_glue_decoder_dispatch (self->decoder);
janitor_stack = g_slist_remove (janitor_stack, self);
-
#if 0
if (port->gstring_stdout->len)
{
@@ -468,7 +402,6 @@ janitor_dispatch (GSource *source,
bse_janitor_close (self);
return TRUE;
}
-
static void
janitor_install_jsource (BseJanitor *self)
{
@@ -481,9 +414,7 @@ janitor_install_jsource (BseJanitor *self)
JSource *jsource = (JSource*) source;
SfiRing *ring;
GPollFD *pfd;
-
g_return_if_fail (self->source == NULL);
-
jsource->janitor = self;
self->source = source;
g_source_set_priority (source, BSE_PRIORITY_GLUE);
@@ -496,15 +427,12 @@ janitor_install_jsource (BseJanitor *self)
}
g_source_attach (source, bse_main_context);
}
-
static gboolean
janitor_idle_clean_jsource (void *data)
{
BseJanitor *self = BSE_JANITOR (data);
SfiComPort *port = self->port;
-
g_return_val_if_fail (self->source != NULL, FALSE);
-
g_source_destroy (self->source);
self->source = NULL;
sfi_glue_decoder_destroy (self->decoder);
@@ -555,7 +483,6 @@ janitor_idle_clean_jsource (void *data)
g_object_unref (self);
return FALSE;
}
-
static void
janitor_port_closed (SfiComPort *port,
void *close_data)
diff --git a/bse/bsejanitor.hh b/bse/bsejanitor.hh
index 036277e..ab6b0b9 100644
--- a/bse/bsejanitor.hh
+++ b/bse/bsejanitor.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_JANITOR_H__
#define __BSE_JANITOR_H__
-
#include <bse/bseitem.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_JANITOR (BSE_TYPE_ID (BseJanitor))
#define BSE_JANITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_JANITOR, BseJanitor))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_JANITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_JANITOR))
#define BSE_IS_JANITOR_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_JANITOR))
#define BSE_JANITOR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_JANITOR, BseJanitorClass))
-
-
/* --- object structures --- */
struct _BseJanitor
{
@@ -43,8 +38,6 @@ typedef struct {
gchar *name;
gchar *blurb;
} BseJanitorAction;
-
-
/* --- prototypes --- */
BseJanitor* bse_janitor_new (SfiComPort *port);
void bse_janitor_kill (BseJanitor *self);
@@ -64,9 +57,6 @@ void bse_janitor_remove_action (BseJanitor *self,
const gchar *action);
void bse_janitor_trigger_action (BseJanitor *self,
const gchar *action);
-
G_END_DECLS
-
#endif /* __BSE_JANITOR_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bsejanitor.proc b/bse/bsejanitor.proc
index 084c8b1..cfd81e2 100644
--- a/bse/bsejanitor.proc
+++ b/bse/bsejanitor.proc
@@ -4,12 +4,8 @@
#include <bse/bsejanitor.hh>
#include <bse/bseserver.hh>
#include <string.h>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseJanitor, trigger-action) {
HELP = "Trigger an installed user action of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -24,17 +20,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
const gchar *action = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self) || !action)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_janitor_trigger_action (self, action);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, get-script-name) {
HELP = "Retrieve the script name of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -48,17 +40,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, self->script_name);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, get-proc-name) {
HELP = "Retrieve the procedure name of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -72,17 +60,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, self->proc_name);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, n-actions) {
HELP = "Retrieve number of user actions of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -96,17 +80,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, g_slist_length (self->actions));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, get-action) {
HELP = "Retrieve an action of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -123,18 +103,14 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
guint nth = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
BseJanitorAction *a = (BseJanitorAction*) g_slist_nth_data (self->actions, nth);
/* set output parameters */
sfi_value_set_string (out_values++, a ? g_quark_to_string (a->action) : NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, get-action-name) {
HELP = "Retrieve the name of an action of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -151,19 +127,14 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
guint nth = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
BseJanitorAction *a = (BseJanitorAction*) g_slist_nth_data (self->actions, nth);
-
/* set output parameters */
sfi_value_set_string (out_values++, a ? a->name : NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, get-action-blurb) {
HELP = "Retrieve the help string of an action of this janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -180,18 +151,14 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
guint nth = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
BseJanitorAction *a = (BseJanitorAction*) g_slist_nth_data (self->actions, nth);
-
/* set output parameters */
sfi_value_set_string (out_values++, a ? a->blurb : NULL);
return BSE_ERROR_NONE;
}
-
METHOD (BseJanitor, kill) {
HELP = "Kill a currently running janitor.";
IN = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -203,17 +170,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseJanitor *self = (BseJanitor*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_janitor_kill (self);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-janitor, "Script/Get Janitor") {
HELP = "Retrieve the connection dependant janitor object.";
OUT = bse_param_spec_object ("janitor", "Janitor", NULL,
@@ -224,17 +187,13 @@ BODY (BseProcedureClass *proc,
GValue *out_values)
{
BseJanitor *self = bse_janitor_get_current ();
-
/* check execution context */
if (!self || !self->port || self->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* set output parameters */
bse_value_set_object (out_values++, self);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-add-action, "Script/Add Action") {
HELP = "Install a user action for script control.";
IN = sfi_pspec_string ("action", "Action", NULL,
@@ -253,21 +212,16 @@ BODY (BseProcedureClass *proc,
const gchar *action = sfi_value_get_string (in_values++);
const gchar *name = sfi_value_get_string (in_values++);
const gchar *blurb = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self) || !action || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* check execution context */
if (!self->port || self->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* action */
bse_janitor_add_action (self, action, name, blurb);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-remove-action, "Script/Remove Action") {
HELP = "Remove a previously installed user action from script control.";
IN = sfi_pspec_string ("action", "Action", NULL,
@@ -280,21 +234,16 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseJanitor *self = bse_janitor_get_current ();
const gchar *action = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self) || !action)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* check execution context */
if (!self->port || self->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* action */
bse_janitor_remove_action (self, action);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-set-status, "Script/Set Status") {
HELP = "Alter script status message.";
IN = sfi_pspec_string ("message", "Message", NULL,
@@ -306,23 +255,18 @@ PROCEDURE (bse-script-set-status, "Script/Set Status") {
/* extract parameter values */
BseJanitor *self = bse_janitor_get_current ();
const gchar *message = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* check execution context */
if (!self->port || self->port_closed)
return BSE_ERROR_PROC_EXECUTION;
if (!message)
message = "";
-
/* action */
bse_item_set (self, "status-message", message, NULL);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-progress, "Script/Progress") {
HELP = "Indicate progress (from 0.0 to 1.0 or -1 for unknown amount).";
IN = sfi_pspec_real ("progress", "Progress", NULL,
@@ -335,21 +279,16 @@ PROCEDURE (bse-script-progress, "Script/Progress") {
/* extract parameter values */
BseJanitor *self = bse_janitor_get_current ();
gfloat progress = sfi_value_get_real (in_values++);
-
/* check parameters */
if (!BSE_IS_JANITOR (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* check execution context */
if (!self->port || self->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* action */
bse_janitor_progress (self, progress);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-send-message, "Script/Message") {
HELP = "Send a message from a script.";
/* keep arguments in sync with bsescminterp.c */
@@ -374,21 +313,16 @@ PROCEDURE (bse-script-send-message, "Script/Message") {
const gchar *text3 = sfi_value_get_string (in_values++);
const gchar *check = sfi_value_get_string (in_values++);
SfiMsgType type = mtype ? sfi_msg_lookup_type (mtype) : SfiMsgType (0);
-
/* check parameters */
if (!mtype || !(text1 || text2))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* check execution context */
if (!BSE_IS_JANITOR (janitor) || !janitor->port || janitor->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* action */
bse_server_message (bse_server_get (), domain, BseMsgType (type), text0, text1, text2, text3, check, janitor, NULL, janitor->port->remote_pid);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-script-quit, "Script/Quit") {
HELP = "Exit a script succesfully (server side).";
} BODY (BseProcedureClass *proc,
@@ -397,14 +331,11 @@ PROCEDURE (bse-script-quit, "Script/Quit") {
{
/* extract parameter values */
BseJanitor *janitor = bse_janitor_get_current();
-
/* check execution context */
if (!BSE_IS_JANITOR (janitor) || !janitor->port || janitor->port_closed)
return BSE_ERROR_PROC_EXECUTION;
-
/* action */
janitor->force_normal_exit = TRUE;
bse_janitor_close (janitor);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bseladspa.cc b/bse/bseladspa.cc
index dd489f6..43b7863 100644
--- a/bse/bseladspa.cc
+++ b/bse/bseladspa.cc
@@ -4,18 +4,11 @@
#include "bsecategories.hh"
#include <birnet/birnet.hh>
#include <string.h>
-
#include "ladspa.hh"
-
using namespace Birnet;
-
static Msg::CustomType debug_ladspa ("ladspa", Msg::DEBUG);
-
#define DEBUG_REGISTRATION 0
-
#define LADSPA_TYPE_NAME "BseLadspaModule_"
-
-
/* --- prototypes --- */
static void ladspa_plugin_iface_init (GTypePluginClass *iface);
static void ladspa_plugin_use (GTypePlugin *gplugin);
@@ -26,24 +19,18 @@ static void ladspa_plugin_complete_info (GTypePlugin *gplugin,
GTypeValueTable *value_vtable);
static const gchar* ladspa_plugin_reinit_type_ids (BseLadspaPlugin *self,
LADSPA_Descriptor_Function ldf);
-
-
/* --- variables --- */
static GSList *ladspa_plugins = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseLadspaPlugin)
{
static const GTypeInfo type_info = {
sizeof (BseLadspaPluginClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) NULL,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseLadspaPlugin),
0 /* n_preallocs */,
(GInstanceInitFunc) NULL,
@@ -54,17 +41,14 @@ BSE_BUILTIN_TYPE (BseLadspaPlugin)
NULL, /* interface_data */
};
GType type;
-
type = bse_type_register_static (G_TYPE_OBJECT,
"BseLadspaPlugin",
"LADSPA Plugin Loader",
__FILE__, __LINE__,
&type_info);
g_type_add_interface_static (type, G_TYPE_TYPE_PLUGIN, &iface_info);
-
return type;
}
-
static void
ladspa_plugin_iface_init (GTypePluginClass *iface)
{
@@ -72,22 +56,18 @@ ladspa_plugin_iface_init (GTypePluginClass *iface)
iface->unuse_plugin = ladspa_plugin_unuse;
iface->complete_type_info = ladspa_plugin_complete_info;
}
-
static void
ladspa_plugin_use (GTypePlugin *gplugin)
{
BseLadspaPlugin *self = BSE_LADSPA_PLUGIN (gplugin);
-
g_object_ref (self);
if (!self->use_count)
{
BIRNET_MAY_ALIAS LADSPA_Descriptor_Function ldf = NULL;
const gchar *error = NULL;
self->use_count++;
-
if (DEBUG_REGISTRATION)
Msg::display (debug_ladspa, "%s: reloading plugin", self->fname);
-
self->gmodule = g_module_open (self->fname, G_MODULE_BIND_LOCAL); /* reopen non-lazy for actual use */
if (!self->gmodule)
error = g_module_error ();
@@ -103,48 +83,38 @@ ladspa_plugin_use (GTypePlugin *gplugin)
}
if (!error)
error = ladspa_plugin_reinit_type_ids (self, ldf);
-
if (error)
g_error ("Fatal: failed to reinitialize plugin \"%s\": %s", self->fname, error);
}
else
self->use_count++;
}
-
static void
ladspa_plugin_unload (BseLadspaPlugin *self)
{
guint i;
-
g_return_if_fail (self->gmodule != NULL);
-
g_module_close (self->gmodule);
self->gmodule = NULL;
-
for (i = 0; i < self->n_types; i++)
if (self->types[i].info)
{
bse_ladspa_info_free (self->types[i].info);
self->types[i].info = NULL;
}
-
if (DEBUG_REGISTRATION)
Msg::display (debug_ladspa, "%s: plugin unloaded", self->fname);
}
-
static void
ladspa_plugin_unuse (GTypePlugin *gplugin)
{
BseLadspaPlugin *self = BSE_LADSPA_PLUGIN (gplugin);
-
g_return_if_fail (self->use_count > 0);
-
self->use_count--;
if (!self->use_count)
ladspa_plugin_unload (self);
g_object_unref (self);
}
-
static void
ladspa_plugin_complete_info (GTypePlugin *gplugin,
GType type,
@@ -160,10 +130,8 @@ ladspa_plugin_complete_info (GTypePlugin *gplugin,
break;
}
}
-
#define to_upper(c) ((c) >='a' && (c) <='z' ? (c) - 'a' + 'A' : (c))
#define is_alnum(c) (((c) >='A' && (c) <='Z') || ((c) >='a' && (c) <='z') || ((c) >='0' && (c) <='9'))
-
static inline gint
strcmp_alnum (const gchar *s1,
const gchar *s2)
@@ -177,7 +145,6 @@ strcmp_alnum (const gchar *s1,
}
return *s1 - *s2;
}
-
static const gchar*
ladspa_plugin_reinit_type_ids (BseLadspaPlugin *self,
LADSPA_Descriptor_Function ldf)
@@ -204,7 +171,6 @@ ladspa_plugin_reinit_type_ids (BseLadspaPlugin *self,
}
return NULL;
}
-
static const gchar*
ladspa_plugin_init_type_ids (BseLadspaPlugin *self,
LADSPA_Descriptor_Function ldf)
@@ -283,7 +249,6 @@ ladspa_plugin_init_type_ids (BseLadspaPlugin *self,
g_free (prefix);
return error;
}
-
typedef struct {
guint index;
guint audio_input;
@@ -291,7 +256,6 @@ typedef struct {
guint control_input;
guint control_output;
} PortCounter;
-
static gboolean
bse_ladspa_info_add_port (BseLadspaInfo *bli,
const gchar *port_name,
@@ -418,7 +382,6 @@ bse_ladspa_info_add_port (BseLadspaInfo *bli,
}
return TRUE;
}
-
extern "C" gchar*
bse_ladspa_info_port_2str (BseLadspaPort *port)
{
@@ -445,7 +408,6 @@ bse_ladspa_info_port_2str (BseLadspaPort *port)
port->minimum, port->default_value, port->maximum,
flags);
}
-
extern "C" BseLadspaInfo*
bse_ladspa_info_assemble (const gchar *file_path,
gconstpointer ladspa_descriptor)
@@ -454,13 +416,10 @@ bse_ladspa_info_assemble (const gchar *file_path,
BseLadspaInfo *bli = g_new0 (BseLadspaInfo, 1);
PortCounter pcounter = { 0, 1, 1, 1, 1 };
bool seen_control_output = false, seen_audio_output = false;
-
g_return_val_if_fail (cld != NULL, NULL);
-
bli->file_path = g_strdup (file_path);
if (!file_path)
file_path = ""; /* ensure !=NULL for messages below */
-
bli->plugin_id = cld->UniqueID;
if (bli->plugin_id < 1 || bli->plugin_id >= 0x1000000)
Msg::display (debug_ladspa, "%s: plugin with suspicious ID: %u", file_path, bli->plugin_id);
@@ -481,7 +440,6 @@ bse_ladspa_info_assemble (const gchar *file_path,
bli->copyright = cld->Copyright;
bli->interactive = (cld->Properties & LADSPA_PROPERTY_REALTIME) != 0;
bli->rt_capable = (cld->Properties & LADSPA_PROPERTY_HARD_RT_CAPABLE) != 0;
-
if (!cld->PortCount)
{
Msg::display (debug_ladspa, "%s: ignoring plugin without ports", bli->ident);
@@ -537,7 +495,6 @@ bse_ladspa_info_assemble (const gchar *file_path,
Msg::display (debug_ladspa, "%s: ignoring plugin without audio output channels", bli->ident);
goto bail_broken;
}
-
if (!cld->instantiate)
{
Msg::display (debug_ladspa, "%s: ignoring plugin without instantiate() function", bli->ident);
@@ -568,19 +525,15 @@ bse_ladspa_info_assemble (const gchar *file_path,
bli->activate = cld->activate;
bli->deactivate = cld->deactivate;
return bli;
-
bail_broken:
bli->broken = TRUE;
return bli;
}
-
extern "C" void
bse_ladspa_info_free (BseLadspaInfo *bli)
{
guint i;
-
g_return_if_fail (bli != NULL);
-
for (i = 0; i < bli->n_cports; i++)
{
BseLadspaPort *port = bli->cports + i;
@@ -597,7 +550,6 @@ bse_ladspa_info_free (BseLadspaInfo *bli)
g_free (bli->file_path);
g_free (bli);
}
-
static BseLadspaPlugin*
ladspa_plugin_find (const gchar *fname)
{
@@ -610,19 +562,15 @@ ladspa_plugin_find (const gchar *fname)
}
return NULL;
}
-
extern "C" const gchar*
bse_ladspa_plugin_check_load (const gchar *file_name)
{
BseLadspaPlugin *self;
const gchar *error;
GModule *gmodule;
-
g_return_val_if_fail (file_name != NULL, "Internal Error");
-
if (ladspa_plugin_find (file_name))
return "Plugin already registered";
-
/* load module once */
gmodule = g_module_open (file_name, GModuleFlags (G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY));
if (!gmodule)
@@ -634,13 +582,11 @@ bse_ladspa_plugin_check_load (const gchar *file_name)
g_module_close (gmodule);
return "Plugin without ladspa_descriptor";
}
-
/* create plugin and register types */
self = (BseLadspaPlugin*) g_object_new (BSE_TYPE_LADSPA_PLUGIN, NULL);
self->fname = g_strdup (file_name);
self->gmodule = gmodule;
error = ladspa_plugin_init_type_ids (self, ldf);
-
/* keep plugin if types were successfully registered */
ladspa_plugin_unload (self);
if (self->n_types)
@@ -650,36 +596,27 @@ bse_ladspa_plugin_check_load (const gchar *file_name)
}
else
g_object_unref (self);
-
return error;
}
-
#include "topconfig.h"
-
extern "C" SfiRing*
bse_ladspa_plugin_path_list_files (void)
{
SfiRing *ring1, *ring2 = NULL, *ring3 = NULL;
const gchar *paths;
-
ring1 = sfi_file_crawler_list_files (BSE_PATH_LADSPA, "*.so", GFileTest (0));
ring1 = sfi_ring_sort (ring1, (SfiCompareFunc) strcmp, NULL);
-
paths = g_getenv ("LADSPA_PATH");
if (paths && paths[0])
ring2 = sfi_file_crawler_list_files (paths, "*.so", GFileTest (0));
ring2 = sfi_ring_sort (ring2, (SfiCompareFunc) strcmp, NULL);
-
paths = BSE_GCONFIG (ladspa_path);
if (paths && paths[0])
ring3 = sfi_file_crawler_list_files (paths, "*.so", GFileTest (0));
ring3 = sfi_ring_sort (ring3, (SfiCompareFunc) strcmp, NULL);
-
ring2 = sfi_ring_concat (ring2, ring3);
-
return sfi_ring_concat (ring1, ring2);
}
-
#if 0
static void
ladspa_test_load (const gchar *file)
@@ -687,7 +624,6 @@ ladspa_test_load (const gchar *file)
LADSPA_Descriptor_Function ldf = NULL;
const gchar *error;
GModule *gmodule;
-
gmodule = g_module_open (file, 0);
error = g_module_error ();
if (!error && gmodule)
diff --git a/bse/bseladspa.hh b/bse/bseladspa.hh
index 80c9489..2839e81 100644
--- a/bse/bseladspa.hh
+++ b/bse/bseladspa.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_LADSPA_H__
#define __BSE_LADSPA_H__
-
#include <bse/bseutils.hh>
#include <gmodule.h>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_LADSPA_PLUGIN (BSE_TYPE_ID (BseLadspaPlugin))
#define BSE_LADSPA_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_LADSPA_PLUGIN, BseLadspaPlugin))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_LADSPA_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_LADSPA_PLUGIN))
#define BSE_IS_LADSPA_PLUGIN_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_LADSPA_PLUGIN))
#define BSE_LADSPA_PLUGIN_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_LADSPA_PLUGIN, BseLadspaPluginClass))
-
-
/* --- BseLadspaPlugin --- */
typedef struct _BseLadspaInfo BseLadspaInfo;
typedef struct {
@@ -77,8 +72,6 @@ struct _BseLadspaInfo
void (*deactivate) (gpointer instance);
void (*cleanup) (gpointer instance);
};
-
-
/* --- public API --- */
BseLadspaInfo* bse_ladspa_info_assemble (const gchar *file_path,
gconstpointer ladspa_descriptor);
@@ -86,7 +79,5 @@ void bse_ladspa_info_free (BseLadspaInfo *bli);
SfiRing* bse_ladspa_plugin_path_list_files (void);
const gchar* bse_ladspa_plugin_check_load (const gchar *file_name);
gchar* bse_ladspa_info_port_2str (BseLadspaPort *port);
-
G_END_DECLS
-
#endif /* __BSE_LADSPA_H__ */
diff --git a/bse/bseladspamodule.cc b/bse/bseladspamodule.cc
index 8885536..5371005 100644
--- a/bse/bseladspamodule.cc
+++ b/bse/bseladspamodule.cc
@@ -5,8 +5,6 @@
#include "bseengine.hh"
#include "bsemathsignal.hh"
#include <string.h>
-
-
/* --- prototypes --- */
static void bse_ladspa_module_class_init (BseLadspaModuleClass *klass);
static void ladspa_derived_init (BseLadspaModule *self);
@@ -23,32 +21,25 @@ static void ladspa_derived_context_create (BseSource *source,
uint context_handle,
BseTrans *trans);
static void bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_class);
-
-
/* --- variables --- */
static void *derived_parent_class = NULL;
static GQuark quark_value_index = 0;
static GQuark quark_notify_sibling = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseLadspaModule)
{
static const GTypeInfo type_info = {
sizeof (BseLadspaModuleClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_ladspa_module_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseLadspaModule),
0 /* n_preallocs */,
(GInstanceInitFunc) NULL,
};
GType type;
-
type = bse_type_register_static (BSE_TYPE_SOURCE,
"BseLadspaModule",
"LADSPA Module base type",
@@ -56,42 +47,32 @@ BSE_BUILTIN_TYPE (BseLadspaModule)
&type_info);
return type;
}
-
static void
bse_ladspa_module_class_init (BseLadspaModuleClass *klass)
{
quark_value_index = g_quark_from_static_string ("BseLadspaValueIndex");
quark_notify_sibling = g_quark_from_static_string ("BseLadspaNotifySibling");
-
klass->bli = NULL;
}
-
static void
ladspa_derived_class_init (BseLadspaModuleClass *klass,
void *class_data)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
-
derived_parent_class = g_type_class_peek_parent (klass);
-
g_assert (class_data != NULL);
klass->bli = (BseLadspaInfo*) class_data;
-
gobject_class->finalize = ladspa_derived_finalize;
-
source_class->context_create = ladspa_derived_context_create;
-
bse_ladspa_module_class_init_from_info (klass);
}
-
static void
ladspa_derived_class_finalize (BseLadspaModuleClass *klass,
void *class_data)
{
g_free (klass->gsl_class);
}
-
void
bse_ladspa_module_derived_type_info (GType type,
BseLadspaInfo *bli,
@@ -105,7 +86,6 @@ bse_ladspa_module_derived_type_info (GType type,
type_info->instance_size = sizeof (BseLadspaModule);
type_info->instance_init = (GInstanceInitFunc) ladspa_derived_init;
}
-
static void
bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_class)
{
@@ -114,14 +94,11 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
BseSourceClass *source_class = BSE_SOURCE_CLASS (ladspa_module_class);
BseLadspaInfo *bli = ladspa_module_class->bli;
uint ochannel, ichannel, i;
-
g_assert (ladspa_module_class->bli != NULL &&
gobject_class->set_property == NULL &&
gobject_class->get_property == NULL);
-
gobject_class->set_property = ladspa_derived_set_property;
gobject_class->get_property = ladspa_derived_get_property;
-
for (i = 0; i < bli->n_cports; i++)
{
BseLadspaPort *port = bli->cports + i;
@@ -214,7 +191,6 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
bse_object_class_add_param (object_class, group, bli->n_cports + i + 1, pspec2);
}
}
-
for (i = 0; i < bli->n_aports; i++)
{
BseLadspaPort *port = bli->aports + i;
@@ -224,7 +200,6 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
ochannel = bse_source_class_add_ochannel (source_class, port->ident, port->name, NULL);
}
}
-
static float
ladspa_value_get_float (BseLadspaModule *self,
const GValue *value,
@@ -246,7 +221,6 @@ ladspa_value_get_float (BseLadspaModule *self,
return 0;
}
}
-
static void
ladspa_value_set_float (BseLadspaModule *self,
GValue *value,
@@ -271,7 +245,6 @@ ladspa_value_set_float (BseLadspaModule *self,
g_assert_not_reached ();
}
}
-
static void
ladspa_derived_init (BseLadspaModule *self)
{
@@ -289,7 +262,6 @@ ladspa_derived_init (BseLadspaModule *self)
g_value_unset (&tmp);
}
}
-
static void
ladspa_derived_finalize (GObject *object)
{
@@ -297,7 +269,6 @@ ladspa_derived_finalize (GObject *object)
g_free (self->cvalues);
G_OBJECT_CLASS (derived_parent_class)->finalize (object);
}
-
static void
ladspa_derived_get_property (GObject *object,
uint param_id,
@@ -311,7 +282,6 @@ ladspa_derived_get_property (GObject *object,
i = (ptrdiff_t) g_param_spec_get_qdata (pspec, quark_value_index);
ladspa_value_set_float (self, value, klass->bli->cports + i, self->cvalues[i]);
}
-
typedef struct
{
BseLadspaInfo *bli;
@@ -322,7 +292,6 @@ typedef struct
} LadspaData;
#define LADSPA_DATA_SIZE(bli) (sizeof (LadspaData) + (MAX (bli->n_cports, 1) - 1) * sizeof (float))
#define LADSPA_CVALUES_COUNT(bli) (bli->n_cports /* * sizeof (float) */)
-
static void
ladspa_module_access (BseModule *module, /* EngineThread */
void *data)
@@ -332,7 +301,6 @@ ladspa_module_access (BseModule *module, /* EngineThread */
/* this runs in the Gsl Engine threads */
bse_block_copy_float (LADSPA_CVALUES_COUNT (ldata->bli), ldata->cvalues, cdata->cvalues);
}
-
static void
ladspa_derived_set_property (GObject *object,
uint param_id,
@@ -360,7 +328,6 @@ ladspa_derived_set_property (GObject *object,
NULL);
}
}
-
static void
ladspa_module_reset (BseModule *module)
{
@@ -374,7 +341,6 @@ ladspa_module_reset (BseModule *module)
ldata->activated = TRUE;
}
}
-
static void
ladspa_module_process (BseModule *module,
uint n_values)
@@ -414,7 +380,6 @@ ladspa_module_process (BseModule *module,
nos++;
}
}
-
static void
ladspa_module_free_data (void *data,
const BseModuleClass *klass)
@@ -428,7 +393,6 @@ ladspa_module_free_data (void *data,
ldata->handle = NULL;
g_free (ldata->ibuffers);
}
-
static void
ladspa_derived_context_create (BseSource *source,
uint context_handle,
@@ -450,7 +414,6 @@ ladspa_derived_context_create (BseSource *source,
LadspaData *ldata = (LadspaData*) g_malloc0 (LADSPA_DATA_SIZE (bli));
BseModule *module;
uint i, nis;
-
ldata->bli = bli;
/* setup audio streams */
if (!klass->gsl_class)
@@ -478,11 +441,9 @@ ladspa_derived_context_create (BseSource *source,
for (i = 0, nis = 0; i < bli->n_aports; i++)
if (bli->aports[i].input)
bli->connect_port (ldata->handle, bli->aports[i].port_index, ldata->ibuffers + nis++ * bse_engine_block_size ());
-
module = bse_module_new (klass->gsl_class, ldata);
bse_source_set_context_module (source, context_handle, module);
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (derived_parent_class)->context_create (source, context_handle, trans);
}
diff --git a/bse/bseladspamodule.hh b/bse/bseladspamodule.hh
index 7a402a8..e8cec96 100644
--- a/bse/bseladspamodule.hh
+++ b/bse/bseladspamodule.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_LADSPA_MODULE_H__
#define __BSE_LADSPA_MODULE_H__
-
#include <bse/bsesource.hh>
#include <bse/bseladspa.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_LADSPA_MODULE (BSE_TYPE_ID (BseLadspaModule))
#define BSE_LADSPA_MODULE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_LADSPA_MODULE, BseLadspaModule))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_LADSPA_MODULE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_LADSPA_MODULE))
#define BSE_IS_LADSPA_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_LADSPA_MODULE))
#define BSE_LADSPA_MODULE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_LADSPA_MODULE, BseLadspaModuleClass))
-
-
/* --- BseLadspaModule --- */
typedef struct _BseLadspaModule BseLadspaModule;
typedef struct _BseLadspaModuleClass BseLadspaModuleClass;
@@ -30,11 +25,8 @@ struct _BseLadspaModuleClass
BseLadspaInfo *bli;
BseModuleClass *gsl_class;
};
-
void bse_ladspa_module_derived_type_info (GType type,
BseLadspaInfo *bli,
GTypeInfo *type_info);
-
G_END_DECLS
-
#endif /* __BSE_LADSPA_MODULE_H__ */
diff --git a/bse/bseloader-aiff.cc b/bse/bseloader-aiff.cc
index 87aa8d6..dcb3112 100644
--- a/bse/bseloader-aiff.cc
+++ b/bse/bseloader-aiff.cc
@@ -9,19 +9,14 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
-
/* audio file loader for the FORM/AIFF sample format, according to:
* "Audio Interchange File Format AIFF, A Standard for Sampled Sound Files, Version 1.3"
*/
-
/* --- macros --- */
static SFI_MSG_TYPE_DEFINE (debug_aiff, "aiff", SFI_MSG_DEBUG, NULL);
#define AIFF_DEBUG(...) sfi_debug (debug_aiff, __VA_ARGS__)
#define AIFF_ULONG(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
#define AIFF_ID(str4) AIFF_ULONG (str4[0], str4[1], str4[2], str4[3])
-
-
/* --- structures & typedefs --- */
typedef struct
{
@@ -53,8 +48,6 @@ typedef struct
uint data_start; /* file position */
uint data_size; /* in bytes */
} AiffFile;
-
-
/* --- functions --- */
static inline int
aiff_read_u32 (int fd,
@@ -67,7 +60,6 @@ aiff_read_u32 (int fd,
*data = GUINT32_FROM_BE (*data);
return r;
}
-
static inline int
aiff_read_s16 (int fd,
gint16 *data)
@@ -79,7 +71,6 @@ aiff_read_s16 (int fd,
*data = GINT16_FROM_BE (*data);
return r;
}
-
static inline int
aiff_read_u16 (int fd,
guint16 *data)
@@ -91,7 +82,6 @@ aiff_read_u16 (int fd,
*data = GUINT16_FROM_BE (*data);
return r;
}
-
static inline int
aiff_read_f80 (int fd,
double *data)
@@ -120,7 +110,6 @@ aiff_read_f80 (int fd,
*data = d;
return r;
}
-
static inline int
aiff_read_pstring (int fd,
char **pstring)
@@ -146,7 +135,6 @@ aiff_read_pstring (int fd,
*pstring = string;
return r;
}
-
static BseErrorType
aiff_read_comm (int fd,
AiffFile *afile,
@@ -172,7 +160,6 @@ aiff_read_comm (int fd,
afile->mix_freq = sample_rate;
return BSE_ERROR_NONE;
}
-
static BseErrorType
aiff_read_mark (int fd,
AiffFile *afile,
@@ -202,7 +189,6 @@ aiff_read_mark (int fd,
}
return BSE_ERROR_NONE;
}
-
static BseErrorType
aiff_read_inst (int fd,
AiffFile *afile,
@@ -231,7 +217,6 @@ aiff_read_inst (int fd,
afile->instrument.release_loop_mode, afile->instrument.release_begin_id, afile->instrument.release_end_id);
return BSE_ERROR_NONE;
}
-
static BseErrorType
aiff_read_ssnd (int fd,
AiffFile *afile,
@@ -256,7 +241,6 @@ aiff_read_ssnd (int fd,
AIFF_DEBUG ("SSND: pos:>%u< n_bytes:%u", afile->data_start, afile->data_size);
return BSE_ERROR_NONE;
}
-
static BseErrorType
aiff_append_string (int fd,
AiffFile *afile,
@@ -278,7 +262,6 @@ aiff_append_string (int fd,
g_free (string);
return BSE_ERROR_NONE;
}
-
static BseErrorType
aiff_file_load (int fd,
AiffFile *afile)
@@ -292,7 +275,6 @@ aiff_file_load (int fd,
return gsl_error_from_errno (errno, BSE_ERROR_FILE_READ_FAILED);
if (form_id != AIFF_ID ("FORM") || form_size < 4 || form_type != AIFF_ID ("AIFF"))
return BSE_ERROR_FORMAT_UNKNOWN;
-
afile->form_type = form_type;
seek_pos = 12; /* we've read up 12 bytes so far */
while (seek_pos < 8 + form_size)
@@ -327,7 +309,6 @@ aiff_file_load (int fd,
}
return BSE_ERROR_NONE;
}
-
static void
aiff_file_free (AiffFile *afile)
{
@@ -341,13 +322,11 @@ aiff_file_free (AiffFile *afile)
g_free (afile->annotation);
g_free (afile);
}
-
typedef struct
{
BseWaveFileInfo wfi;
AiffFile *afile;
} FileInfo;
-
static BseWaveFileInfo*
aiff_load_file_info (void *data,
const char *file_name,
@@ -398,22 +377,18 @@ aiff_load_file_info (void *data,
fi->wfi.waves[0].name = g_strdup (afile->name ? afile->name : str);
g_free (str);
fi->afile = afile;
-
return &fi->wfi;
}
-
static void
aiff_free_file_info (void *data,
BseWaveFileInfo *file_info)
{
FileInfo *fi = (FileInfo*) file_info;
-
aiff_file_free (fi->afile);
g_free (fi->wfi.waves[0].name);
g_free (fi->wfi.waves);
sfi_delete_struct (FileInfo, fi);
}
-
typedef struct
{
BseWaveDsc wdsc;
@@ -421,7 +396,6 @@ typedef struct
GslLong n_values;
GslWaveFormatType format;
} WaveDsc;
-
static BseWaveDsc*
aiff_load_wave_dsc (void *data,
BseWaveFileInfo *file_info,
@@ -431,9 +405,7 @@ aiff_load_wave_dsc (void *data,
FileInfo *fi = (FileInfo*) file_info;
AiffFile *afile = fi->afile;
WaveDsc *dsc;
-
g_return_val_if_fail (nth_wave == 0, NULL);
-
dsc = sfi_new_struct0 (WaveDsc, 1);
dsc->wdsc.name = fi->wfi.waves[0].name;
dsc->wdsc.n_channels = afile->n_channels;
@@ -478,23 +450,19 @@ aiff_load_wave_dsc (void *data,
dsc->n_values = afile->n_values;
/* in aiff, data is left shifted up to byte boundary */
dsc->format = afile->bit_depth > 8 ? GSL_WAVE_FORMAT_SIGNED_16 : GSL_WAVE_FORMAT_SIGNED_8;
-
return &dsc->wdsc;
}
-
static void
aiff_free_wave_dsc (void *data,
BseWaveDsc *wave_dsc)
{
WaveDsc *dsc = (WaveDsc*) wave_dsc;
-
uint i;
for (i = 0; i < dsc->wdsc.n_chunks; i++)
g_strfreev (dsc->wdsc.chunks[i].xinfos);
g_free (dsc->wdsc.chunks);
sfi_delete_struct (WaveDsc, dsc);
}
-
static GslDataHandle*
aiff_create_chunk_handle (void *data,
BseWaveDsc *wave_dsc,
@@ -504,9 +472,7 @@ aiff_create_chunk_handle (void *data,
WaveDsc *dsc = (WaveDsc*) wave_dsc;
FileInfo *fi = (FileInfo*) dsc->wdsc.file_info;
GslDataHandle *dhandle;
-
g_return_val_if_fail (nth_chunk == 0, NULL);
-
dhandle = gsl_wave_handle_new (fi->wfi.file_name,
dsc->wdsc.n_channels,
dsc->format, G_BIG_ENDIAN,
@@ -516,7 +482,6 @@ aiff_create_chunk_handle (void *data,
dsc->wdsc.chunks[nth_chunk].xinfos);
return dhandle;
}
-
void
_gsl_init_loader_aiff (void)
{
@@ -544,9 +509,7 @@ _gsl_init_loader_aiff (void)
aiff_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
bse_loader_register (&loader);
}
diff --git a/bse/bseloader-bsewave.cc b/bse/bseloader-bsewave.cc
index 99bca5a..938590e 100644
--- a/bse/bseloader-bsewave.cc
+++ b/bse/bseloader-bsewave.cc
@@ -9,16 +9,12 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
-
#define parse_or_return(scanner, token) { GslWaveTokenType _t = GslWaveTokenType (token); \
if (GslWaveTokenType (g_scanner_get_next_token (scanner)) != _t) \
return _t; \
}
static SFI_MSG_TYPE_DEFINE (debug_bsewave, "bsewave", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_bsewave, __VA_ARGS__)
-
-
/* --- token types --- */
typedef enum
{
@@ -59,8 +55,6 @@ typedef enum
BSEWAVE_TOKEN_PINGPONG,
BSEWAVE_TOKEN_LAST,
} GslWaveTokenType;
-
-
/* --- tokens --- */
static const char *bsewave_tokens[] = {
/* keyword tokens */
@@ -76,15 +70,12 @@ static const char *bsewave_tokens[] = {
"alaw", "ulaw", "float",
"none", "jump", "pingpong",
};
-
-
/* --- structures --- */
typedef struct
{
BseWaveFileInfo wfi;
char *cwd;
} FileInfo;
-
typedef struct
{
BseWaveDsc wdsc;
@@ -92,7 +83,6 @@ typedef struct
uint dfl_byte_order;
float dfl_mix_freq;
} WaveDsc;
-
/* BseWaveChunkDsc accessors */
#define LOADER_TYPE(wcd) ((wcd)->loader_data[0].uint)
#define LOADER_FILE(wcd) ((wcd)->loader_data[1].ptr)
@@ -106,14 +96,12 @@ typedef struct
#define RAW_FILE_MAGIC (('R' << 24) | ('a' << 16) | ('w' << 8) | 'F')
#define RAW_LINK_MAGIC (('R' << 24) | ('a' << 16) | ('w' << 8) | 'L')
#define VORBIS_LINK_MAGIC (('O' << 24) | ('/' << 16) | ('V' << 8) | '1')
-
/* --- functions --- */
static GTokenType
bsewave_skip_rest_statement (GScanner *scanner,
uint level)
{
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
-
while (level)
{
g_scanner_get_next_token (scanner);
@@ -125,10 +113,8 @@ bsewave_skip_rest_statement (GScanner *scanner,
default: break;
}
}
-
return G_TOKEN_NONE;
}
-
static BseWaveFileInfo*
bsewave_load_file_info (void *data,
const char *_file_name,
@@ -141,11 +127,9 @@ bsewave_load_file_info (void *data,
char *cwd, *file_name;
int fd;
uint i;
-
if (g_path_is_absolute (_file_name))
{
const char *p = strrchr (_file_name, G_DIR_SEPARATOR);
-
g_assert (p != NULL);
cwd = g_strndup (_file_name, p - _file_name + 1);
file_name = g_strdup (_file_name);
@@ -155,7 +139,6 @@ bsewave_load_file_info (void *data,
cwd = g_get_current_dir ();
file_name = g_strdup_printf ("%s%c%s", cwd, G_DIR_SEPARATOR, _file_name);
}
-
fd = open (file_name, O_RDONLY);
if (fd < 0)
{
@@ -164,7 +147,6 @@ bsewave_load_file_info (void *data,
g_free (file_name);
return NULL;
}
-
scanner = g_scanner_new64 (sfi_storage_scanner_config);
scanner->config->cpair_comment_single = (char*) "#\n";
g_scanner_scope_add_symbol (scanner, 0, "wave", GUINT_TO_POINTER (BSEWAVE_TOKEN_WAVE));
@@ -193,7 +175,6 @@ bsewave_load_file_info (void *data,
if (g_scanner_peek_next_token (scanner) == G_TOKEN_STRING)
{
char *wave_name;
-
g_scanner_get_next_token (scanner); /* eat string */
wave_name = g_strdup (scanner->value.v_string);
if (bsewave_skip_rest_statement (scanner, 1) == G_TOKEN_NONE)
@@ -217,11 +198,9 @@ bsewave_load_file_info (void *data,
}
g_scanner_destroy (scanner);
close (fd);
-
if (wave_names)
{
SfiRing *ring;
-
fi = sfi_new_struct0 (FileInfo, 1);
fi->wfi.n_waves = sfi_ring_length (wave_names);
fi->wfi.waves = (BseWaveFileInfo::Wave*) g_malloc0 (sizeof (fi->wfi.waves[0]) * fi->wfi.n_waves);
@@ -233,24 +212,20 @@ bsewave_load_file_info (void *data,
else
g_free (cwd);
g_free (file_name);
-
return fi ? &fi->wfi : NULL;
}
-
static void
bsewave_free_file_info (void *data,
BseWaveFileInfo *file_info)
{
FileInfo *fi = (FileInfo*) file_info;
uint i;
-
for (i = 0; i < fi->wfi.n_waves; i++)
g_free (fi->wfi.waves[i].name);
g_free (fi->wfi.waves);
g_free (fi->cwd);
sfi_delete_struct (FileInfo, fi);
}
-
static uint
bsewave_parse_chunk_dsc (GScanner *scanner,
BseWaveChunkDsc *chunk)
@@ -398,7 +373,6 @@ bsewave_parse_chunk_dsc (GScanner *scanner,
}
while (TRUE);
}
-
static uint
bsewave_parse_wave_dsc (GScanner *scanner,
WaveDsc *dsc,
@@ -533,7 +507,6 @@ bsewave_parse_wave_dsc (GScanner *scanner,
}
while (TRUE);
}
-
static void
bsewave_wave_dsc_free (WaveDsc *dsc)
{
@@ -548,7 +521,6 @@ bsewave_wave_dsc_free (WaveDsc *dsc)
g_free (dsc->wdsc.name);
sfi_delete_struct (WaveDsc, dsc);
}
-
static BseWaveDsc*
bsewave_load_wave_dsc (void *data,
BseWaveFileInfo *file_info,
@@ -556,21 +528,18 @@ bsewave_load_wave_dsc (void *data,
BseErrorType *error_p)
{
uint token, i;
-
int fd = open (file_info->file_name, O_RDONLY);
if (fd < 0)
{
*error_p = gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
return NULL;
}
-
GScanner *scanner = g_scanner_new64 (sfi_storage_scanner_config);
scanner->config->cpair_comment_single = (char*) "#\n";
scanner->input_name = file_info->file_name;
g_scanner_input_file (scanner, fd);
for (i = BSEWAVE_TOKEN_WAVE; i < BSEWAVE_TOKEN_LAST; i++)
g_scanner_scope_add_symbol (scanner, 0, bsewave_tokens[i - BSEWAVE_TOKEN_WAVE], GUINT_TO_POINTER (i));
-
WaveDsc *dsc = sfi_new_struct0 (WaveDsc, 1);
dsc->wdsc.name = NULL;
dsc->wdsc.n_chunks = 0;
@@ -611,19 +580,15 @@ bsewave_load_wave_dsc (void *data,
}
g_scanner_destroy (scanner);
close (fd);
-
return dsc ? &dsc->wdsc : NULL;
}
-
static void
bsewave_free_wave_dsc (void *data,
BseWaveDsc *wave_dsc)
{
WaveDsc *dsc = (WaveDsc*) wave_dsc;
-
bsewave_wave_dsc_free (dsc);
}
-
static GslDataHandle*
bsewave_load_singlechunk_wave (BseWaveFileInfo *fi,
const char *wave_name,
@@ -633,7 +598,6 @@ bsewave_load_singlechunk_wave (BseWaveFileInfo *fi,
{
BseWaveDsc *wdsc;
uint i;
-
if (fi->n_waves == 1 && !wave_name)
i = 0;
else if (!wave_name)
@@ -651,11 +615,9 @@ bsewave_load_singlechunk_wave (BseWaveFileInfo *fi,
*error_p = BSE_ERROR_WAVE_NOT_FOUND;
return NULL;
}
-
wdsc = bse_wave_dsc_load (fi, i, FALSE, error_p);
if (!wdsc)
return NULL;
-
if (wdsc->n_chunks == 1)
{
*n_channelsp = wdsc->n_channels;
@@ -672,7 +634,6 @@ bsewave_load_singlechunk_wave (BseWaveFileInfo *fi,
bse_wave_dsc_free (wdsc);
return dhandle;
}
-
/* this is ridiculous, letting the chunk of a wave
* point to a wave with multiple chunks...
*/
@@ -680,7 +641,6 @@ bsewave_load_singlechunk_wave (BseWaveFileInfo *fi,
*error_p = BSE_ERROR_FORMAT_INVALID;
return NULL;
}
-
static GslDataHandle*
bsewave_create_chunk_handle (void *data,
BseWaveDsc *wave_dsc,
@@ -690,7 +650,6 @@ bsewave_create_chunk_handle (void *data,
WaveDsc *dsc = (WaveDsc*) wave_dsc;
FileInfo *fi = (FileInfo*) dsc->wdsc.file_info;
BseWaveChunkDsc *chunk = wave_dsc->chunks + nth_chunk;
-
GslDataHandle *dhandle = NULL;
switch (LOADER_TYPE (chunk))
{
@@ -800,7 +759,6 @@ bsewave_create_chunk_handle (void *data,
*error_p = BSE_ERROR_NONE;
return dhandle;
}
-
void
_gsl_init_loader_gslwave (void)
{
@@ -822,9 +780,7 @@ _gsl_init_loader_gslwave (void)
bsewave_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
bse_loader_register (&loader);
}
diff --git a/bse/bseloader-guspatch.cc b/bse/bseloader-guspatch.cc
index 5ff69d9..6c8fbd7 100644
--- a/bse/bseloader-guspatch.cc
+++ b/bse/bseloader-guspatch.cc
@@ -5,14 +5,11 @@
#include <string.h>
#include <vector>
#include <string>
-
#undef WITH_GUSPATCH_XINFOS
static SFI_MSG_TYPE_DEFINE (debug_guspatch, "guspatch", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_guspatch, __VA_ARGS__)
-
using std::vector;
using std::string;
-
/*
* generic patch loading code from aRts
*/
@@ -24,13 +21,11 @@ typedef uint dword;
typedef char sbyte;
typedef short int sword;
typedef int sdword;
-
/*
* executes read_me (which should be a function call to read something from the file),
* and returns from the calling function if that fails
*/
#define read_or_return_error(read_me) G_STMT_START{ BseErrorType _error = read_me; if (_error) return _error; }G_STMT_END
-
static inline BseErrorType
fread_block (FILE *file,
int len,
@@ -41,10 +36,8 @@ fread_block (FILE *file,
return BSE_ERROR_FILE_EOF;
else
return gsl_error_from_errno (errno, BSE_ERROR_FILE_READ_FAILED);
-
return BSE_ERROR_NONE;
}
-
static inline BseErrorType
skip (FILE *file,
int len)
@@ -57,7 +50,6 @@ skip (FILE *file,
}
return BSE_ERROR_NONE;
}
-
static inline BseErrorType
fread_bytes (FILE *file,
unsigned char *bytes,
@@ -65,7 +57,6 @@ fread_bytes (FILE *file,
{
return fread_block (file, len, bytes);
}
-
static inline BseErrorType
fread_string (FILE *file,
char *str,
@@ -73,7 +64,6 @@ fread_string (FILE *file,
{
return fread_block (file, len, str);
}
-
/* readXXX with sizeof(xxx) == 1 */
static inline BseErrorType
fread_byte (FILE *file,
@@ -81,48 +71,38 @@ fread_byte (FILE *file,
{
return fread_block (file, 1, &b);
}
-
/* readXXX with sizeof(xxx) == 2 */
static inline BseErrorType
fread_word (FILE *file,
word &w)
{
byte h, l;
-
read_or_return_error (fread_block (file, 1, &l));
read_or_return_error (fread_block (file, 1, &h));
w = (h << 8) + l;
-
return BSE_ERROR_NONE;
}
-
static inline BseErrorType
fread_short_word (FILE *file,
sword &sw)
{
word w;
-
read_or_return_error (fread_word (file, w));
sw = (sword) w;
-
return BSE_ERROR_NONE;
}
-
/* readXXX with sizeof(xxx) == 4 */
static inline BseErrorType
fread_dword (FILE *file, dword& dw)
{
byte h, l, hh, hl;
-
read_or_return_error (fread_block (file, 1, &l));
read_or_return_error (fread_block (file, 1, &h));
read_or_return_error (fread_block (file, 1, &hl));
read_or_return_error (fread_block (file, 1, &hh));
dw = (hh << 24) + (hl << 16) + (h << 8) + l;
-
return BSE_ERROR_NONE;
}
-
struct PatHeader
{
char id[12]; /* ID='GF1PATCH110' */
@@ -137,11 +117,9 @@ struct PatHeader
word mastervolume; /* Master volume for all samples */
dword size; /* Size of the following data */
char reserved[36]; /* reserved */
-
PatHeader()
{
}
-
BseErrorType
load (FILE *file)
{
@@ -149,21 +127,16 @@ struct PatHeader
read_or_return_error (fread_string (file, manufacturer_id, 10));
read_or_return_error (fread_string (file, description, 60));
/* skip(file, 2);*/
-
read_or_return_error (fread_byte (file, instruments));
read_or_return_error (fread_byte (file, voices));
read_or_return_error (fread_byte (file, channels));
-
read_or_return_error (fread_word (file, waveforms));
read_or_return_error (fread_word (file, mastervolume));
read_or_return_error (fread_dword (file, size));
-
read_or_return_error (fread_string (file, reserved, 36));
-
return BSE_ERROR_NONE;
}
};
-
struct PatInstrument
{
word number;
@@ -171,17 +144,14 @@ struct PatInstrument
dword size; /* Size of the whole instrument in bytes. */
byte layers;
char reserved[40];
-
/* layer? */
word layerUnknown;
dword layerSize;
byte sampleCount; /* number of samples in this layer (?) */
char layerReserved[40];
-
PatInstrument()
{
}
-
BseErrorType
load (FILE *file)
{
@@ -190,17 +160,14 @@ struct PatInstrument
read_or_return_error (fread_dword (file, size));
read_or_return_error (fread_byte (file, layers));
read_or_return_error (fread_string (file, reserved, 40));
-
/* layer: (?) */
read_or_return_error (fread_word (file, layerUnknown));
read_or_return_error (fread_dword (file, layerSize));
read_or_return_error (fread_byte (file, sampleCount));
read_or_return_error (fread_string (file, reserved, 40));
-
return BSE_ERROR_NONE;
}
};
-
enum
{
PAT_FORMAT_16BIT = (1 << 0),
@@ -212,7 +179,6 @@ enum
PAT_FORMAT_ENVELOPE = (1 << 6),
PAT_FORMAT_CLAMPED = (1 << 7) // timidity source says: ? (for last envelope??)
};
-
struct PatPatch
{
char filename[7]; /* Wave file name */
@@ -238,11 +204,9 @@ struct PatPatch
sword freqScale;
word freqScaleFactor;
char reserved[36];
-
PatPatch()
{
}
-
BseErrorType
load (FILE *file)
{
@@ -269,15 +233,12 @@ struct PatPatch
read_or_return_error (fread_short_word (file, freqScale));
read_or_return_error (fread_word (file, freqScaleFactor));
read_or_return_error (fread_string (file, reserved, 36));
-
return BSE_ERROR_NONE;
}
};
#undef read_or_return_error
};
-
namespace {
-
/*
* adaptation to GSL API
*/
@@ -285,11 +246,9 @@ struct FileInfo
{
BseWaveFileInfo wfi;
BseWaveDsc wdsc;
-
PatHeader *header;
PatInstrument *instrument;
vector<PatPatch *> patches;
-
GslWaveLoopType
loop_type (int wave_format)
{
@@ -326,13 +285,11 @@ struct FileInfo
return GSL_WAVE_LOOP_NONE;
}
}
-
guint&
data_offset (int chunk_number)
{
return wdsc.chunks[chunk_number].loader_data[0].uint;
}
-
GslWaveFormatType
wave_format (int wave_format)
{
@@ -345,13 +302,11 @@ struct FileInfo
}
BIRNET_ASSERT_NOT_REACHED();
}
-
int
bytes_per_frame (int wave_format)
{
return ((wave_format & PAT_FORMAT_16BIT) ? 2 : 1);
}
-
string
envelope_point_to_string (guint value)
{
@@ -360,30 +315,24 @@ struct FileInfo
g_free (tmp_str);
return str;
}
-
string
envelope_array_to_string (byte *envelope_array)
{
string envelope_str;
-
for (int i = 0; i < 6; i++)
{
if (i)
envelope_str += ",";
envelope_str += envelope_point_to_string (envelope_array[i]);
}
-
return envelope_str;
}
-
-
FileInfo (const gchar *file_name,
BseErrorType *error_p)
{
/* initialize C structures with zeros */
memset (&wfi, 0, sizeof (wfi));
memset (&wdsc, 0, sizeof (wdsc));
-
/* open patch file */
FILE *patfile = fopen (file_name, "r");
if (!patfile)
@@ -391,44 +340,34 @@ struct FileInfo
*error_p = gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
return;
}
-
/* parse contents of patfile into Pat* data structurs */
header = new PatHeader();
-
*error_p = header->load (patfile);
if (*error_p)
{
fclose (patfile);
return;
}
-
if (header->channels == 0) /* fixup channels setting */
header->channels = 1;
-
instrument = new PatInstrument();
-
*error_p = instrument->load (patfile);
if (*error_p)
{
fclose (patfile);
return;
}
-
/* allocate BseWaveDsc */
wdsc.n_chunks = instrument->sampleCount;
wdsc.chunks = (typeof (wdsc.chunks)) g_malloc0 (sizeof (wdsc.chunks[0]) * wdsc.n_chunks);
-
for (int i = 0; i<instrument->sampleCount; i++)
{
PatPatch *patch = new PatPatch();
patches.push_back (patch);
-
*error_p = patch->load (patfile);
if (*error_p)
return;
-
data_offset (i) = (guint) ftell (patfile);
-
*error_p = skip (patfile, patch->wavesize);
if (*error_p)
{
@@ -438,12 +377,10 @@ struct FileInfo
DEBUG (" - read patch, srate = %d (%d bytes)", patch->sampleRate, patch->wavesize);
}
fclose (patfile);
-
/* allocate and fill BseWaveFileInfo */
wfi.n_waves = 1;
wfi.waves = (typeof (wfi.waves)) g_malloc0 (sizeof (wfi.waves[0]) * wfi.n_waves);
wfi.waves[0].name = g_strdup (file_name);
-
/* fill BseWaveDsc */
wdsc.name = g_strdup (file_name);
/* header->channels means output channels, GUS Patches are mono only */
@@ -451,23 +388,19 @@ struct FileInfo
#ifdef WITH_GUSPATCH_XINFOS
wdsc.xinfos = bse_xinfos_add_value (wdsc.xinfos, "play-type", "gus-patch");
#endif
-
for (guint i = 0; i < wdsc.n_chunks; i++)
{
/* fill GslWaveChunk */
wdsc.chunks[i].mix_freq = patches[i]->sampleRate;
wdsc.chunks[i].osc_freq = patches[i]->origFreq / 1000.0;
-
DEBUG ("orig_freq = %f (%d)", patches[i]->origFreq / 1000.0, patches[i]->origFreq);
DEBUG ("min_freq = %f", patches[i]->minFreq / 1000.0);
DEBUG ("max_freq = %f", patches[i]->maxFreq / 1000.0);
DEBUG ("fine_tune = %d", patches[i]->fineTune);
DEBUG ("scale_freq = %d", patches[i]->freqScale);
DEBUG ("scale_factor = %d", patches[i]->freqScaleFactor);
-
/* fill xinfos */
char**& xinfos = wdsc.chunks[i].xinfos;
-
int frame_size = bytes_per_frame (patches[i]->waveFormat);
if (loop_type (patches[i]->waveFormat))
{
@@ -475,7 +408,6 @@ struct FileInfo
xinfos = bse_xinfos_add_num (xinfos, "loop-count", 1000000);
xinfos = bse_xinfos_add_num (xinfos, "loop-start", patches[i]->loopStart / frame_size);
xinfos = bse_xinfos_add_num (xinfos, "loop-end", patches[i]->loopEnd / frame_size);
-
#ifdef WITH_GUSPATCH_XINFOS
xinfos = bse_xinfos_add_value (xinfos, "gus-patch-envelope-rates",
envelope_array_to_string (patches[i]->filterRate).c_str());
@@ -483,7 +415,6 @@ struct FileInfo
envelope_array_to_string (patches[i]->filterOffset).c_str());
#endif
}
-
#ifdef WITH_GUSPATCH_XINFOS
xinfos = bse_xinfos_add_num (xinfos, "gus-patch-loop-fractions", patches[i]->fractions);
xinfos = bse_xinfos_add_float (xinfos, "gus-patch-min-freq", patches[i]->minFreq / 1000.0);
@@ -503,7 +434,6 @@ struct FileInfo
#endif
}
}
-
~FileInfo()
{
/* free patch data loaded from file */
@@ -512,15 +442,12 @@ struct FileInfo
delete *pi;
delete instrument;
delete header;
-
/* free BseWaveDsc */
for (guint i = 0; i < wdsc.n_chunks; i++)
g_strfreev (wdsc.chunks[i].xinfos);
-
g_strfreev (wdsc.xinfos);
g_free (wdsc.name);
g_free (wdsc.chunks);
-
/* free BseWaveFileInfo */
if (wfi.waves)
{
@@ -529,7 +456,6 @@ struct FileInfo
}
}
};
-
static BseWaveFileInfo*
pat_load_file_info (gpointer data,
const gchar *file_name,
@@ -541,10 +467,8 @@ pat_load_file_info (gpointer data,
delete file_info;
return NULL;
}
-
return &file_info->wfi;
}
-
static void
pat_free_file_info (gpointer data,
BseWaveFileInfo *wave_file_info)
@@ -552,7 +476,6 @@ pat_free_file_info (gpointer data,
FileInfo *file_info = reinterpret_cast<FileInfo*> (wave_file_info);
delete file_info;
}
-
static BseWaveDsc*
pat_load_wave_dsc (gpointer data,
BseWaveFileInfo *wave_file_info,
@@ -562,13 +485,11 @@ pat_load_wave_dsc (gpointer data,
FileInfo *file_info = reinterpret_cast<FileInfo*> (wave_file_info);
return &file_info->wdsc;
}
-
static void
pat_free_wave_dsc (gpointer data,
BseWaveDsc *wave_dsc)
{
}
-
static GslDataHandle*
pat_create_chunk_handle (gpointer data,
BseWaveDsc *wave_dsc,
@@ -576,11 +497,9 @@ pat_create_chunk_handle (gpointer data,
BseErrorType *error_p)
{
g_return_val_if_fail (nth_chunk < wave_dsc->n_chunks, NULL);
-
FileInfo *file_info = reinterpret_cast<FileInfo*> (wave_dsc->file_info);
const PatPatch *patch = file_info->patches[nth_chunk];
const BseWaveChunkDsc *chunk = &wave_dsc->chunks[nth_chunk];
-
DEBUG ("pat loader chunk %d: gsl_wave_handle_new %s %d %d %d %f %f %u %d",
nth_chunk,
file_info->wfi.file_name,
@@ -591,7 +510,6 @@ pat_create_chunk_handle (gpointer data,
chunk->osc_freq,
file_info->data_offset (nth_chunk),
patch->wavesize / file_info->bytes_per_frame (patch->waveFormat));
-
GslDataHandle *dhandle;
dhandle = gsl_wave_handle_new (file_info->wfi.file_name,
wave_dsc->n_channels,
@@ -604,9 +522,7 @@ pat_create_chunk_handle (gpointer data,
chunk->xinfos);
return dhandle;
}
-
} // namespace
-
extern "C" void
bse_init_loader_gus_patch (void)
{
@@ -632,9 +548,7 @@ bse_init_loader_gus_patch (void)
pat_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
bse_loader_register (&loader);
}
diff --git a/bse/bseloader-mad.cc b/bse/bseloader-mad.cc
index d6fd6ad..32df126 100644
--- a/bse/bseloader-mad.cc
+++ b/bse/bseloader-mad.cc
@@ -2,11 +2,8 @@
#include "topconfig.h"
#include "bse/bseloader.hh"
#include "gsldatahandle-mad.hh"
-
#include <unistd.h>
#include <string.h>
-
-
/* --- structures --- */
typedef struct
{
@@ -15,8 +12,6 @@ typedef struct
float mix_freq;
float osc_freq;
} FileInfo;
-
-
/* --- functions --- */
static BseWaveFileInfo*
mad_load_file_info (void *data,
@@ -27,14 +22,12 @@ mad_load_file_info (void *data,
uint n_channels;
float mix_freq;
BseErrorType error;
-
error = gsl_data_handle_mad_testopen (file_name, &n_channels, &mix_freq);
if (error)
{
*error_p = error;
return NULL;
}
-
fi = sfi_new_struct0 (FileInfo, 1);
fi->wfi.n_waves = 1; /* we support only a single MPEG stream */
fi->wfi.waves = (BseWaveFileInfo::Wave*) g_malloc0 (sizeof (fi->wfi.waves[0]) * fi->wfi.n_waves);
@@ -43,23 +36,19 @@ mad_load_file_info (void *data,
fi->n_channels = n_channels;
fi->mix_freq = mix_freq;
fi->osc_freq = 440.0; /* FIXME */
-
return &fi->wfi;
}
-
static void
mad_free_file_info (void *data,
BseWaveFileInfo *file_info)
{
FileInfo *fi = (FileInfo*) file_info;
uint i;
-
for (i = 0; i < fi->wfi.n_waves; i++)
g_free (fi->wfi.waves[i].name);
g_free (fi->wfi.waves);
sfi_delete_struct (FileInfo, fi);
}
-
static BseWaveDsc*
mad_load_wave_dsc (void *data,
BseWaveFileInfo *file_info,
@@ -68,17 +57,14 @@ mad_load_wave_dsc (void *data,
{
FileInfo *fi = (FileInfo*) file_info;
BseWaveDsc *wdsc = sfi_new_struct0 (BseWaveDsc, 1);
-
wdsc->name = g_strdup (fi->wfi.waves[0].name);
wdsc->n_channels = fi->n_channels;
wdsc->n_chunks = 1;
wdsc->chunks = g_new0 (BseWaveChunkDsc, 1);
wdsc->chunks[0].osc_freq = fi->osc_freq;
wdsc->chunks[0].mix_freq = fi->mix_freq;
-
return wdsc;
}
-
static void
mad_free_wave_dsc (void *data,
BseWaveDsc *wdsc)
@@ -90,7 +76,6 @@ mad_free_wave_dsc (void *data,
g_free (wdsc->name);
sfi_delete_struct (BseWaveDsc, wdsc);
}
-
static GslDataHandle*
mad_create_chunk_handle (void *data,
BseWaveDsc *wdsc,
@@ -99,9 +84,7 @@ mad_create_chunk_handle (void *data,
{
FileInfo *fi = (FileInfo*) wdsc->file_info;
GslDataHandle *dhandle;
-
g_return_val_if_fail (nth_chunk == 0, NULL);
-
dhandle = gsl_data_handle_new_mad_err (fi->wfi.file_name, wdsc->chunks[0].osc_freq, error_p);
if (dhandle && wdsc->chunks[0].xinfos)
{
@@ -113,8 +96,6 @@ mad_create_chunk_handle (void *data,
*error_p = BSE_ERROR_FILE_OPEN_FAILED;
return dhandle;
}
-
-
#define MAGIC_MPEG_HEADER "0 beshort &0xffe0\n" /* MPEG */ \
"2 ubyte&0x0c <0x0c\n" /* valid samplefreq */ \
"2 ubyte&0xf0 <0xf0\n" /* valid bitrate */
@@ -156,7 +137,6 @@ mad_create_chunk_handle (void *data,
#define MAGIC_MPEG_ID3 ("0 string ID3\n" /* ID3v2 tag for mp3 */ \
"3 ubyte <0xff\n" /* major version */ \
"4 ubyte <0xff\n" /* revision */)
-
void
_gsl_init_loader_mad (void)
{
@@ -194,10 +174,8 @@ _gsl_init_loader_mad (void)
mad_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
if (BSE_HAVE_LIBMAD)
bse_loader_register (&loader);
}
diff --git a/bse/bseloader-oggvorbis.cc b/bse/bseloader-oggvorbis.cc
index 6939edc..fb93abb 100644
--- a/bse/bseloader-oggvorbis.cc
+++ b/bse/bseloader-oggvorbis.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bse/bseloader.hh"
-
#include <bse/gsldatahandle.hh>
#include "gsldatahandle-vorbis.hh"
-
#include <vorbis/vorbisfile.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
-
/* --- structures --- */
typedef struct
{
@@ -17,7 +13,6 @@ typedef struct
OggVorbis_File ofile;
} FileInfo;
#define LOADER_LOGICAL_BIT_STREAM(chunk) ((chunk).loader_data[0].uint)
-
/* --- functions --- */
static BseWaveFileInfo*
oggv_load_file_info (void *data,
@@ -27,14 +22,12 @@ oggv_load_file_info (void *data,
FileInfo *fi = sfi_new_struct0 (FileInfo, 1);
FILE *file;
int err, i;
-
file = fopen (file_name, "r");
if (!file)
{
*error_p = gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
return NULL;
}
-
fi = sfi_new_struct0 (FileInfo, 1);
err = ov_open (file, &fi->ofile, NULL, 0);
if (err)
@@ -44,14 +37,12 @@ oggv_load_file_info (void *data,
*error_p = BSE_ERROR_CODEC_FAILURE;
return NULL;
}
-
fi->wfi.n_waves = ov_streams (&fi->ofile);
fi->wfi.waves = (BseWaveFileInfo::Wave*) g_malloc0 (sizeof (fi->wfi.waves[0]) * fi->wfi.n_waves);
for (i = 0; i < fi->wfi.n_waves; i++)
{
vorbis_comment *vc = ov_comment (&fi->ofile, i);
uint n;
-
for (n = 0; n < vc->comments; n++)
if (strcmp (vc->user_comments[n], "title=") == 0)
break;
@@ -60,24 +51,20 @@ oggv_load_file_info (void *data,
else
fi->wfi.waves[i].name = g_strdup_printf ("Unnamed-%u", i);
}
-
return &fi->wfi;
}
-
static void
oggv_free_file_info (void *data,
BseWaveFileInfo *file_info)
{
FileInfo *fi = (FileInfo*) file_info;
uint i;
-
for (i = 0; i < fi->wfi.n_waves; i++)
g_free (fi->wfi.waves[i].name);
g_free (fi->wfi.waves);
ov_clear (&fi->ofile);
sfi_delete_struct (FileInfo, fi);
}
-
static BseWaveDsc*
oggv_load_wave_dsc (void *data,
BseWaveFileInfo *file_info,
@@ -87,7 +74,6 @@ oggv_load_wave_dsc (void *data,
FileInfo *fi = (FileInfo*) file_info;
BseWaveDsc *wdsc = sfi_new_struct0 (BseWaveDsc, 1);
vorbis_info *vi = ov_info (&fi->ofile, nth_wave);
-
wdsc->name = g_strdup (fi->wfi.waves[nth_wave].name);
wdsc->n_channels = vi->channels;
wdsc->n_chunks = 1;
@@ -95,10 +81,8 @@ oggv_load_wave_dsc (void *data,
wdsc->chunks[0].osc_freq = 440.0; /* FIXME */
wdsc->chunks[0].mix_freq = vi->rate;
LOADER_LOGICAL_BIT_STREAM (wdsc->chunks[0]) = nth_wave;
-
return wdsc;
}
-
static void
oggv_free_wave_dsc (void *data,
BseWaveDsc *wdsc)
@@ -110,7 +94,6 @@ oggv_free_wave_dsc (void *data,
g_free (wdsc->name);
sfi_delete_struct (BseWaveDsc, wdsc);
}
-
static GslDataHandle*
oggv_create_chunk_handle (void *data,
BseWaveDsc *wdsc,
@@ -119,9 +102,7 @@ oggv_create_chunk_handle (void *data,
{
FileInfo *fi = (FileInfo*) wdsc->file_info;
GslDataHandle *dhandle;
-
g_return_val_if_fail (nth_chunk == 0, NULL);
-
dhandle = gsl_data_handle_new_ogg_vorbis_muxed (fi->wfi.file_name,
LOADER_LOGICAL_BIT_STREAM (wdsc->chunks[0]),
wdsc->chunks[0].osc_freq);
@@ -135,7 +116,6 @@ oggv_create_chunk_handle (void *data,
*error_p = BSE_ERROR_FILE_OPEN_FAILED;
return dhandle;
}
-
void
_gsl_init_loader_oggvorbis (void)
{
@@ -157,9 +137,7 @@ _gsl_init_loader_oggvorbis (void)
oggv_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
bse_loader_register (&loader);
}
diff --git a/bse/bseloader-wav.cc b/bse/bseloader-wav.cc
index b2cff12..6f12b21 100644
--- a/bse/bseloader-wav.cc
+++ b/bse/bseloader-wav.cc
@@ -1,38 +1,27 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseloader.hh"
-
#include "gsldatahandle.hh"
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
-
#define FORMAT_IS_ALAW(f) ((f) == 0x0006 /* Microsoft ALAW */ || \
(f) == 0x0102) /* IBM ALAW */
#define FORMAT_IS_ULAW(f) ((f) == 0x0007 /* Microsoft MULAW */ || \
(f) == 0x0101) /* IBM MULAW */
-
-
/* load routine for the RIFF/WAVE sample format
* ref.: C't 01/1993 pp. 213
*/
-
typedef guint32 DWord;
typedef guint16 Word;
#define DWORD_FROM_BE GUINT32_FROM_BE
#define DWORD_FROM_LE GUINT32_FROM_LE
#define WORD_FROM_LE GUINT16_FROM_LE
-
-
/* --- debugging and errors --- */
static SFI_MSG_TYPE_DEFINE (debug_wav, "wav", SFI_MSG_DEBUG, NULL);
#define WAV_DEBUG(...) sfi_debug (debug_wav, __VA_ARGS__)
-
-
/* --- functions --- */
typedef struct
{
@@ -45,9 +34,7 @@ wav_read_header (int fd,
WavHeader *header)
{
uint n_bytes;
-
memset (header, 0, sizeof (*header));
-
/* read header contents */
n_bytes = 4 + 4 + 4;
g_assert (n_bytes == sizeof (*header));
@@ -56,12 +43,10 @@ wav_read_header (int fd,
WAV_DEBUG ("failed to read WavHeader: %s", g_strerror (errno));
return gsl_error_from_errno (errno, BSE_ERROR_IO);
}
-
/* endianess corrections */
header->main_chunk = DWORD_FROM_BE (header->main_chunk);
header->file_length = DWORD_FROM_LE (header->file_length);
header->chunk_type = DWORD_FROM_BE (header->chunk_type);
-
/* validation */
if (header->main_chunk != ('R' << 24 | 'I' << 16 | 'F' << 8 | 'F'))
{
@@ -78,10 +63,8 @@ wav_read_header (int fd,
WAV_DEBUG ("unmatched token 'WAVE'");
return BSE_ERROR_FORMAT_INVALID;
}
-
return BSE_ERROR_NONE;
}
-
typedef struct
{
DWord sub_chunk; /* 'fmt ', big endian as int */
@@ -98,9 +81,7 @@ wav_read_fmt_header (int fd,
FmtHeader *header)
{
uint n_bytes;
-
memset (header, 0, sizeof (*header));
-
/* read header contents */
n_bytes = 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2;
g_assert (n_bytes == sizeof (*header));
@@ -109,7 +90,6 @@ wav_read_fmt_header (int fd,
WAV_DEBUG ("failed to read FmtHeader");
return gsl_error_from_errno (errno, BSE_ERROR_IO);
}
-
/* endianess corrections */
header->sub_chunk = DWORD_FROM_BE (header->sub_chunk);
header->length = DWORD_FROM_LE (header->length);
@@ -119,7 +99,6 @@ wav_read_fmt_header (int fd,
header->byte_per_second = DWORD_FROM_LE (header->byte_per_second);
header->byte_per_sample = WORD_FROM_LE (header->byte_per_sample);
header->bit_per_sample = WORD_FROM_LE (header->bit_per_sample);
-
/* validation */
if (header->sub_chunk != ('f' << 24 | 'm' << 16 | 't' << 8 | ' '))
{
@@ -170,15 +149,12 @@ wav_read_fmt_header (int fd,
if (header->length > 16)
{
uint n;
-
WAV_DEBUG ("skipping %u bytes of overlong WAVE header", header->length - 16);
-
n = header->length - 16;
while (n)
{
guint8 junk[64];
uint l = MIN (n, 64);
-
l = read (fd, junk, l);
if (l < 1 || l > n)
{
@@ -188,10 +164,8 @@ wav_read_fmt_header (int fd,
n -= l;
}
}
-
return BSE_ERROR_NONE;
}
-
typedef struct
{
DWord data_chunk; /* 'data', big endian as int */
@@ -203,9 +177,7 @@ wav_read_data_header (int fd,
uint byte_alignment)
{
uint n_bytes;
-
memset (header, 0, sizeof (*header));
-
/* read header contents */
n_bytes = 4 + 4;
g_assert (n_bytes == sizeof (*header));
@@ -214,24 +186,20 @@ wav_read_data_header (int fd,
WAV_DEBUG ("failed to read DataHeader");
return gsl_error_from_errno (errno, BSE_ERROR_IO);
}
-
/* endianess corrections */
header->data_chunk = DWORD_FROM_BE (header->data_chunk);
header->data_length = DWORD_FROM_LE (header->data_length);
-
/* validation */
if (header->data_chunk != ('d' << 24 | 'a' << 16 | 't' << 8 | 'a'))
{
uint8 chunk[5];
char *esc;
-
chunk[0] = header->data_chunk >> 24;
chunk[1] = (header->data_chunk >> 16) & 0xff;
chunk[2] = (header->data_chunk >> 8) & 0xff;
chunk[3] = header->data_chunk & 0xff;
chunk[4] = 0;
esc = g_strescape ((char*) chunk, NULL);
-
/* skip chunk and retry */
WAV_DEBUG ("ignoring sub-chunk '%s'", esc);
g_free (esc);
@@ -248,16 +216,13 @@ wav_read_data_header (int fd,
header->data_length, header->data_length % byte_alignment);
return BSE_ERROR_FORMAT_INVALID;
}
-
return BSE_ERROR_NONE;
}
-
typedef struct
{
BseWaveFileInfo wfi;
int fd;
} FileInfo;
-
static BseWaveFileInfo*
wav_load_file_info (void *data,
const char *file_name,
@@ -266,43 +231,36 @@ wav_load_file_info (void *data,
WavHeader wav_header;
FileInfo *fi;
int fd;
-
fd = open (file_name, O_RDONLY);
if (fd < 0)
{
*error_p = gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
return NULL;
}
-
*error_p = wav_read_header (fd, &wav_header);
if (*error_p)
{
close (fd);
return NULL;
}
-
fi = sfi_new_struct0 (FileInfo, 1);
fi->wfi.n_waves = 1;
fi->wfi.waves = (BseWaveFileInfo::Wave*) g_malloc0 (sizeof (fi->wfi.waves[0]) * fi->wfi.n_waves);
const char *dsep = strrchr (file_name, G_DIR_SEPARATOR);
fi->wfi.waves[0].name = g_strdup (dsep ? dsep + 1 : file_name);
fi->fd = fd;
-
return &fi->wfi;
}
-
static void
wav_free_file_info (void *data,
BseWaveFileInfo *file_info)
{
FileInfo *fi = (FileInfo*) file_info;
-
g_free (fi->wfi.waves[0].name);
g_free (fi->wfi.waves);
close (fi->fd);
sfi_delete_struct (FileInfo, fi);
}
-
typedef struct
{
BseWaveDsc wdsc;
@@ -310,7 +268,6 @@ typedef struct
GslLong n_values;
GslWaveFormatType format;
} WaveDsc;
-
static BseWaveDsc*
wav_load_wave_dsc (void *data,
BseWaveFileInfo *file_info,
@@ -323,20 +280,16 @@ wav_load_wave_dsc (void *data,
WaveDsc *dsc;
GslWaveFormatType format;
GslLong data_offset, data_width;
-
g_return_val_if_fail (nth_wave == 0, NULL);
-
if (lseek (fi->fd, sizeof (WavHeader), SEEK_SET) != sizeof (WavHeader))
{
WAV_DEBUG ("failed to seek to end of WavHeader");
*error_p = gsl_error_from_errno (errno, BSE_ERROR_IO);
return NULL;
}
-
*error_p = wav_read_fmt_header (fi->fd, &fmt_header);
if (*error_p)
return NULL;
-
data_width = (fmt_header.bit_per_sample + 7) / 8;
*error_p = wav_read_data_header (fi->fd, &data_header, data_width * fmt_header.n_channels);
data_offset = lseek (fi->fd, 0, SEEK_CUR);
@@ -347,7 +300,6 @@ wav_load_wave_dsc (void *data,
}
if (*error_p)
return NULL;
-
if (fmt_header.bit_per_sample == 8 && FORMAT_IS_ALAW (fmt_header.format))
format = GSL_WAVE_FORMAT_ALAW;
else if (fmt_header.bit_per_sample == 8 && FORMAT_IS_ULAW (fmt_header.format))
@@ -378,7 +330,6 @@ wav_load_wave_dsc (void *data,
if (0)
WAV_DEBUG ("n_channels: %d sample_freq: %d bit_width: %u",
fmt_header.n_channels, fmt_header.sample_freq, fmt_header.bit_per_sample);
-
dsc = sfi_new_struct0 (WaveDsc, 1);
dsc->wdsc.name = g_strdup (fi->wfi.waves[0].name);
dsc->wdsc.n_channels = fmt_header.n_channels;
@@ -389,10 +340,8 @@ wav_load_wave_dsc (void *data,
dsc->data_offset = data_offset;
dsc->n_values = data_header.data_length / data_width;
dsc->format = format;
-
return &dsc->wdsc;
}
-
static void
wav_free_wave_dsc (void *data,
BseWaveDsc *wave_dsc)
@@ -405,7 +354,6 @@ wav_free_wave_dsc (void *data,
g_free (dsc->wdsc.name);
sfi_delete_struct (WaveDsc, dsc);
}
-
static GslDataHandle*
wav_create_chunk_handle (void *data,
BseWaveDsc *wave_dsc,
@@ -414,9 +362,7 @@ wav_create_chunk_handle (void *data,
{
WaveDsc *dsc = (WaveDsc*) wave_dsc;
GslDataHandle *dhandle;
-
g_return_val_if_fail (nth_chunk == 0, NULL);
-
dhandle = gsl_wave_handle_new (dsc->wdsc.file_info->file_name,
dsc->wdsc.n_channels,
dsc->format, G_LITTLE_ENDIAN,
@@ -426,7 +372,6 @@ wav_create_chunk_handle (void *data,
dsc->wdsc.chunks[nth_chunk].xinfos);
return dhandle;
}
-
void
_gsl_init_loader_wav (void)
{
@@ -473,9 +418,7 @@ _gsl_init_loader_wav (void)
wav_create_chunk_handle,
};
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized = TRUE;
-
bse_loader_register (&loader);
}
diff --git a/bse/bseloader.cc b/bse/bseloader.cc
index 80af7a8..06c65ed 100644
--- a/bse/bseloader.cc
+++ b/bse/bseloader.cc
@@ -6,26 +6,20 @@
#include "gslmagic.hh"
#include "gslfilehash.hh"
#include <string.h>
-
-
/* --- variables --- */
static BseLoader *bse_loader_list = NULL;
static SfiRing *gsl_magic_list1 = NULL;
static SfiRing *gsl_magic_list2 = NULL;
-
-
/* --- functions --- */
static BseLoader*
loader_find_by_name (const char *name)
{
BseLoader *loader;
-
for (loader = bse_loader_list; loader != NULL; loader = loader->next)
if (strcmp (name, loader->name) == 0)
return loader;
return NULL;
}
-
void
bse_loader_register (BseLoader *loader)
{
@@ -39,15 +33,12 @@ bse_loader_register (BseLoader *loader)
g_return_if_fail (loader->load_wave_dsc != NULL);
g_return_if_fail (loader->free_wave_dsc != NULL);
g_return_if_fail (loader->create_chunk_handle != NULL);
-
loader->next = bse_loader_list;
bse_loader_list = loader;
-
if (loader->magic_specs)
{
GslMagic *magic;
uint i, j;
-
for (i = 0; loader->magic_specs[i]; i++)
{
if (loader->extensions)
@@ -70,30 +61,24 @@ bse_loader_register (BseLoader *loader)
}
}
}
-
static uint8*
skipchr (const uint8 *mem,
char byte,
uint maxlen)
{
const uint8 *p = mem, *bound = p + maxlen;
-
while (p < bound)
if (UNLIKELY (*p++ != byte))
return (uint8*) p - 1;
return NULL;
}
-
BseLoader*
bse_loader_match (const char *file_name)
{
GslMagic *magic = NULL;
-
g_return_val_if_fail (file_name != NULL, NULL);
-
/* normal magic check */
magic = gsl_magic_list_match_file (gsl_magic_list1, file_name);
-
/* in a sort-of fallback attempt,
* work around files that have preceeding nulls
*/
@@ -125,10 +110,8 @@ bse_loader_match (const char *file_name)
if (pos > 0)
magic = gsl_magic_list_match_file_skip (gsl_magic_list2, file_name, pos);
}
-
return magic ? (BseLoader*) magic->data : NULL;
}
-
BseWaveFileInfo*
bse_wave_file_info_load (const char *file_name,
BseErrorType *error_p)
@@ -136,11 +119,9 @@ bse_wave_file_info_load (const char *file_name,
BseWaveFileInfo *finfo = NULL;
BseErrorType error = BSE_ERROR_NONE;
BseLoader *loader;
-
if (error_p)
*error_p = BSE_ERROR_INTERNAL;
g_return_val_if_fail (file_name != NULL, NULL);
-
loader = bse_loader_match (file_name);
if (loader)
{
@@ -158,13 +139,10 @@ bse_wave_file_info_load (const char *file_name,
if (finfo->n_waves > 0)
{
uint i;
-
g_return_val_if_fail (finfo->loader == NULL, NULL);
g_return_val_if_fail (finfo->file_name == NULL, NULL);
-
for (i = 0; i < finfo->n_waves; i++)
g_return_val_if_fail (finfo->waves[i].name != NULL, NULL);
-
finfo->file_name = g_strdup (file_name);
finfo->loader = loader;
finfo->ref_count = 1;
@@ -184,53 +162,41 @@ bse_wave_file_info_load (const char *file_name,
if (!error)
error = BSE_ERROR_FORMAT_UNKNOWN;
}
-
if (error_p)
*error_p = error;
-
return finfo;
}
-
void
bse_wave_file_info_unref (BseWaveFileInfo *wave_file_info)
{
g_return_if_fail (wave_file_info != NULL);
g_return_if_fail (wave_file_info->ref_count > 0);
-
wave_file_info->ref_count--;
if (!wave_file_info->ref_count)
{
BseLoader *loader = wave_file_info->loader;
-
g_free (wave_file_info->file_name);
wave_file_info->file_name = NULL;
wave_file_info->loader = NULL;
g_strfreev (wave_file_info->comments);
wave_file_info->comments = NULL;
-
loader->free_file_info (loader->data, wave_file_info);
}
}
-
BseWaveFileInfo*
bse_wave_file_info_ref (BseWaveFileInfo *wave_file_info)
{
g_return_val_if_fail (wave_file_info != NULL, NULL);
g_return_val_if_fail (wave_file_info->ref_count > 0, NULL);
-
wave_file_info->ref_count++;
-
return wave_file_info;
}
-
const char*
bse_wave_file_info_loader (BseWaveFileInfo *fi)
{
g_return_val_if_fail (fi != NULL, NULL);
-
return fi->loader->name;
}
-
BseWaveDsc*
bse_wave_dsc_load (BseWaveFileInfo *wave_file_info,
uint nth_wave,
@@ -240,16 +206,13 @@ bse_wave_dsc_load (BseWaveFileInfo *wave_file_info,
BseErrorType error = BSE_ERROR_NONE;
BseWaveDsc *wdsc;
BseLoader *loader;
-
if (error_p)
*error_p = BSE_ERROR_INTERNAL;
g_return_val_if_fail (wave_file_info != NULL, NULL);
g_return_val_if_fail (wave_file_info->loader != NULL, NULL);
g_return_val_if_fail (nth_wave < wave_file_info->n_waves, NULL);
-
loader = wave_file_info->loader;
wdsc = loader->load_wave_dsc (loader->data, wave_file_info, nth_wave,&error);
-
if (error && wdsc)
{
/* loaders shouldn't do this */
@@ -264,7 +227,6 @@ bse_wave_dsc_load (BseWaveFileInfo *wave_file_info,
{
g_return_val_if_fail (wdsc->file_info == NULL, NULL);
g_return_val_if_fail (wdsc->name && strcmp (wdsc->name, wave_file_info->waves[nth_wave].name) == 0, NULL);
-
wdsc->file_info = wave_file_info;
bse_wave_file_info_ref (wave_file_info);
}
@@ -275,26 +237,19 @@ bse_wave_dsc_load (BseWaveFileInfo *wave_file_info,
error = BSE_ERROR_FILE_EMPTY;
}
}
-
if (error_p)
*error_p = error;
-
return wdsc;
}
-
void
bse_wave_dsc_free (BseWaveDsc *wave_dsc)
{
g_return_if_fail (wave_dsc != NULL);
g_return_if_fail (wave_dsc->file_info != NULL);
-
BseWaveFileInfo *file_info = wave_dsc->file_info;
-
file_info->loader->free_wave_dsc (file_info->loader->data, wave_dsc);
-
bse_wave_file_info_unref (file_info);
}
-
GslDataHandle*
bse_wave_handle_create (BseWaveDsc *wave_dsc,
uint nth_chunk,
@@ -303,15 +258,12 @@ bse_wave_handle_create (BseWaveDsc *wave_dsc,
BseErrorType error = BSE_ERROR_NONE;
GslDataHandle *dhandle;
BseLoader *loader;
-
if (error_p)
*error_p = BSE_ERROR_INTERNAL;
g_return_val_if_fail (wave_dsc != NULL, NULL);
g_return_val_if_fail (wave_dsc->file_info != NULL, NULL);
g_return_val_if_fail (nth_chunk < wave_dsc->n_chunks, NULL);
-
loader = wave_dsc->file_info->loader;
-
dhandle = loader->create_chunk_handle (loader->data,
wave_dsc,
nth_chunk,
@@ -324,13 +276,10 @@ bse_wave_handle_create (BseWaveDsc *wave_dsc,
}
if (!dhandle && !error)
error = BSE_ERROR_FORMAT_INVALID;
-
if (error_p)
*error_p = error;
-
return dhandle;
}
-
GslWaveChunk*
bse_wave_chunk_create (BseWaveDsc *wave_dsc,
uint nth_chunk,
@@ -339,29 +288,22 @@ bse_wave_chunk_create (BseWaveDsc *wave_dsc,
GslDataHandle *dhandle;
GslDataCache *dcache;
GslWaveChunk *wchunk;
-
if (error_p)
*error_p = BSE_ERROR_INTERNAL;
g_return_val_if_fail (wave_dsc != NULL, NULL);
g_return_val_if_fail (nth_chunk < wave_dsc->n_chunks, NULL);
-
dhandle = bse_wave_handle_create (wave_dsc, nth_chunk, error_p);
if (!dhandle)
return NULL;
-
BseWaveChunkDsc *chunk = wave_dsc->chunks + nth_chunk;
-
if (error_p)
*error_p = BSE_ERROR_IO;
-
/* FIXME: we essentially create a dcache for each wchunk here ;( */
-
dcache = gsl_data_cache_from_dhandle (dhandle, BSE_CONFIG (wave_chunk_padding) * wave_dsc->n_channels);
gsl_data_handle_unref (dhandle);
if (!dcache)
return NULL;
/* dcache keeps dhandle alive */
-
const char *ltype = bse_xinfos_get_value (chunk->xinfos, "loop-type");
GslWaveLoopType loop_type = ltype ? gsl_wave_loop_type_from_string (ltype) : GSL_WAVE_LOOP_NONE;
SfiNum loop_start = bse_xinfos_get_num (chunk->xinfos, "loop-start");
@@ -375,13 +317,10 @@ bse_wave_chunk_create (BseWaveDsc *wave_dsc,
loop_type = GSL_WAVE_LOOP_NONE;
loop_count = 0;
}
-
wchunk = gsl_wave_chunk_new (dcache, chunk->mix_freq, chunk->osc_freq,
loop_type, loop_start, loop_end, loop_count);
gsl_data_cache_unref (dcache);
-
if (error_p && wchunk)
*error_p = BSE_ERROR_NONE;
-
return wchunk;
}
diff --git a/bse/bseloader.hh b/bse/bseloader.hh
index e2515c4..1032b0d 100644
--- a/bse/bseloader.hh
+++ b/bse/bseloader.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_LOADER_H__
#define __BSE_LOADER_H__
-
#include <bse/bseutils.hh>
#include <bse/gslwavechunk.hh>
-
G_BEGIN_DECLS
-
/* --- structures --- */
struct _BseWaveFileInfo
{
@@ -14,9 +11,7 @@ struct _BseWaveFileInfo
struct Wave {
gchar *name;
} *waves;
-
gchar **comments;
-
/*< private >*/
gchar *file_name;
BseLoader *loader;
@@ -44,8 +39,6 @@ struct _BseWaveChunkDsc
gfloat vfloat;
} loader_data[8];
};
-
-
/* --- functions --- */
BseWaveFileInfo* bse_wave_file_info_load (const gchar *file_name,
BseErrorType *error);
@@ -63,8 +56,6 @@ GslDataHandle* bse_wave_handle_create (BseWaveDsc *wave_dsc,
GslWaveChunk* bse_wave_chunk_create (BseWaveDsc *wave_dsc,
guint nth_chunk,
BseErrorType *error);
-
-
/* --- loader impl --- */
typedef enum /*< skip >*/
{
@@ -74,7 +65,6 @@ typedef enum /*< skip >*/
struct _BseLoader
{
const gchar *name; /* format/loader name, e.g. "BseWave" or "WAVE audio, RIFF (little-endian)" */
-
/* at least one of the
* following three must
* be non-NULL
@@ -83,9 +73,7 @@ struct _BseLoader
const gchar **mime_types; /* e.g.: "audio/x-mpg3" or "audio/x-wav" */
BseLoaderFlags flags;
const gchar **magic_specs; /* e.g.: "0 string RIFF\n8 string WAVE\n" or "0 string #BseWave1\n" */
-
gint priority; /* -100=high, +100=low, 0=default */
-
/*< private >*/
gpointer data;
BseWaveFileInfo* (*load_file_info) (gpointer data,
@@ -105,10 +93,7 @@ struct _BseLoader
BseErrorType *error);
BseLoader *next; /* must be NULL */
};
-
void bse_loader_register (BseLoader *loader);
BseLoader* bse_loader_match (const gchar *file_name);
-
G_END_DECLS
-
#endif /* __BSE_LOADER_H__ */
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 9eeb0ae..16e1e74 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -18,17 +18,13 @@
#include <sys/types.h>
#include <unistd.h>
#include <sfi/sfitests.hh> /* sfti_test_init() */
-
using namespace Birnet;
-
/* --- prototypes --- */
static void bse_main_loop (gpointer data);
static void bse_async_parse_args (gint *argc_p,
gchar ***argv_p,
BseMainArgs *margs,
SfiInitValue values[]);
-
-
/* --- variables --- */
/* from bse.hh */
const guint bse_major_version = BSE_MAJOR_VERSION;
@@ -61,7 +57,6 @@ static BseMainArgs default_main_args = {
};
BseMainArgs *bse_main_args = NULL;
BseTraceArgs bse_trace_args = { NULL, };
-
/* --- functions --- */
void
bse_init_textdomain_only (void)
@@ -70,14 +65,12 @@ bse_init_textdomain_only (void)
bind_textdomain_codeset (BSE_GETTEXT_DOMAIN, "UTF-8");
textdomain_setup = TRUE;
}
-
const gchar*
bse_gettext (const gchar *text)
{
g_assert (textdomain_setup == TRUE);
return dgettext (BSE_GETTEXT_DOMAIN, text);
}
-
void
bse_init_async (gint *argc,
gchar ***argv,
@@ -85,25 +78,19 @@ bse_init_async (gint *argc,
SfiInitValue values[])
{
BirnetThread *thread;
-
bse_init_textdomain_only();
-
if (bse_initialization_stage != 0)
g_error ("%s() may only be called once", "bse_init_async");
bse_initialization_stage++;
if (bse_initialization_stage != 1)
g_error ("%s() may only be called once", "bse_init_async");
-
/* this function is running in the user program and needs to start the main BSE thread */
-
/* paranoid assertions */
g_assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
-
/* initialize submodules */
sfi_init (argc, argv, app_name, values);
bse_main_args = &default_main_args;
bse_main_args->birnet = sfi_init_settings();
-
/* handle argument early*/
if (argc && argv)
{
@@ -111,17 +98,14 @@ bse_init_async (gint *argc,
g_set_prgname (**argv);
bse_async_parse_args (argc, argv, bse_main_args, values);
}
-
/* start main BSE thread */
thread = sfi_thread_run ("BSE Core", bse_main_loop, sfi_thread_self ());
if (!thread)
g_error ("failed to start seperate thread for BSE core");
-
/* wait for initialization completion of the core thread */
while (bse_initialization_stage < 2)
sfi_thread_sleep (-1);
}
-
const char*
bse_check_version (guint required_major,
guint required_minor,
@@ -141,45 +125,35 @@ bse_check_version (guint required_major,
return "BSE version too old (micro mismatch)";
return NULL;
}
-
typedef struct {
SfiGlueContext *context;
const gchar *client;
BirnetThread *thread;
} AsyncData;
-
static gboolean
async_create_context (gpointer data)
{
AsyncData *adata = (AsyncData*) data;
SfiComPort *port1, *port2;
-
sfi_com_port_create_linked ("Client", adata->thread, &port1,
"Server", sfi_thread_self (), &port2);
adata->context = sfi_glue_encoder_context (port1);
bse_janitor_new (port2);
-
/* wakeup client */
sfi_thread_wakeup (adata->thread);
-
return FALSE; /* single-shot */
}
-
SfiGlueContext*
bse_init_glue_context (const gchar *client)
{
AsyncData adata = { 0, };
GSource *source;
-
g_return_val_if_fail (client != NULL, NULL);
-
/* function runs in user threads and queues handler in BSE thread to create context */
-
if (bse_initialization_stage < 2)
g_error ("%s() called without prior %s()",
"bse_init_glue_context",
"bse_init_async");
-
/* queue handler to create context */
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_HIGH);
@@ -190,15 +164,12 @@ bse_init_glue_context (const gchar *client)
g_source_unref (source);
/* wake up BSE thread */
g_main_context_wakeup (bse_main_context);
-
/* wait til context creation */
do
sfi_thread_sleep (-1);
while (!adata.context);
-
return adata.context;
}
-
static void
bse_init_core (void)
{
@@ -208,33 +179,27 @@ bse_init_core (void)
sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup,
bse_main_context, NULL);
bse_message_setup_thread_handler();
-
/* initialize basic components */
bse_globals_init ();
_bse_init_signal();
_bse_init_categories ();
bse_type_init ();
bse_cxx_init ();
-
/* FIXME: global spawn dir is evil */
{
gchar *dir = g_get_current_dir ();
sfi_com_set_spawn_dir (dir);
g_free (dir);
}
-
/* initialize GSL components */
gsl_init ();
-
/* remaining BSE components */
_bse_midi_init ();
bse_plugin_init_builtins ();
/* initialize C wrappers around C++ generated types */
_bse_init_c_wrappers ();
-
/* make sure the server is alive */
bse_server_get ();
-
/* load drivers early */
if (bse_main_args->load_drivers_early)
{
@@ -248,7 +213,6 @@ bse_init_core (void)
g_free (name);
}
}
-
/* dump device list */
if (bse_main_args->dump_driver_list)
{
@@ -258,9 +222,7 @@ bse_init_core (void)
bse_device_dump_list (BSE_TYPE_MIDI_DEVICE, " ", TRUE, NULL, NULL);
}
}
-
static gboolean single_thread_registration_done = FALSE;
-
static void
server_registration (SfiProxy server,
BseRegistrationType rtype,
@@ -279,7 +241,6 @@ server_registration (SfiProxy server,
sfi_diag ("failed to register \"%s\": %s", what, error);
}
}
-
static void
bse_init_intern (gint *argc,
gchar ***argv,
@@ -288,16 +249,13 @@ bse_init_intern (gint *argc,
bool as_test)
{
bse_init_textdomain_only();
-
if (bse_initialization_stage != 0)
g_error ("%s() may only be called once", "bse_init_intern");
bse_initialization_stage++;
if (bse_initialization_stage != 1)
g_error ("%s() may only be called once", "bse_init_intern");
-
/* paranoid assertions */
g_assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
-
/* initialize submodules */
if (as_test)
sfi_init_test (argc, argv, values);
@@ -305,7 +263,6 @@ bse_init_intern (gint *argc,
sfi_init (argc, argv, app_name, values);
bse_main_args = &default_main_args;
bse_main_args->birnet = sfi_init_settings();
-
/* early argument handling */
if (argc && argv)
{
@@ -313,9 +270,7 @@ bse_init_intern (gint *argc,
g_set_prgname (**argv);
bse_async_parse_args (argc, argv, bse_main_args, values);
}
-
bse_init_core ();
-
/* initialize core plugins & scripts */
if (bse_main_args->load_core_plugins || bse_main_args->load_core_scripts)
g_object_connect (bse_server_get(), "signal::registration", server_registration, NULL, NULL);
@@ -352,7 +307,6 @@ bse_init_intern (gint *argc,
}
// sfi_glue_gc_run ();
}
-
void
bse_init_inprocess (gint *argc,
gchar ***argv,
@@ -361,7 +315,6 @@ bse_init_inprocess (gint *argc,
{
bse_init_intern (argc, argv, app_name, values, false);
}
-
void
bse_init_test (gint *argc,
gchar ***argv,
@@ -369,23 +322,17 @@ bse_init_test (gint *argc,
{
bse_init_intern (argc, argv, NULL, values, true);
}
-
static void
bse_main_loop (gpointer data)
{
BirnetThread *client = (BirnetThread*) data;
-
bse_main_thread = sfi_thread_self ();
-
bse_init_core ();
-
/* start other threads */
bse_sequencer_init_thread ();
-
/* notify client about completion */
bse_initialization_stage++; /* =2 */
sfi_thread_wakeup (client);
-
/* and away into the main loop */
do
{
@@ -394,7 +341,6 @@ bse_main_loop (gpointer data)
}
while (!sfi_thread_aborted ());
}
-
guint
bse_main_getpid (void)
{
@@ -403,7 +349,6 @@ bse_main_getpid (void)
else
return 0;
}
-
static gboolean
core_thread_send_message_async (gpointer data)
{
@@ -412,7 +357,6 @@ core_thread_send_message_async (gpointer data)
bse_message_free (umsg);
return FALSE;
}
-
/**
* BSE log handler, suitable for sfi_msg_set_thread_handler().
* This function is MT-safe and may be called from any thread.
@@ -464,13 +408,11 @@ bse_msg_handler (const char *domain,
/* queue an idle handler in the BSE Core thread */
bse_idle_next (core_thread_send_message_async, umsg);
}
-
void
bse_message_setup_thread_handler (void)
{
Birnet::Msg::set_thread_handler (bse_msg_handler);
}
-
void
bse_message_to_default_handler (const BseMessage *msg)
{
@@ -487,7 +429,6 @@ bse_message_to_default_handler (const BseMessage *msg)
parts.push_back (Msg::Check (String (msg->config_check)));
Msg::default_handler (msg->log_domain, Msg::Type (msg->type), parts);
}
-
static guint
get_n_processors (void)
{
@@ -498,7 +439,6 @@ get_n_processors (void)
#endif
return 1;
}
-
static void
bse_async_parse_args (gint *argc_p,
gchar ***argv_p,
@@ -507,18 +447,15 @@ bse_async_parse_args (gint *argc_p,
{
guint argc = *argc_p;
gchar **argv = *argv_p;
-
/* this function is called before the main BSE thread is started,
* so we can't use any BSE functions yet.
*/
-
gchar *envar = getenv ("BSE_DEBUG");
if (envar)
sfi_msg_allow (envar);
envar = getenv ("BSE_NO_DEBUG");
if (envar)
sfi_msg_deny (envar);
-
guint i;
for (i = 1; i < argc; i++)
{
@@ -683,10 +620,8 @@ bse_async_parse_args (gint *argc_p,
argv[i] = NULL;
}
}
-
if (!margs->bse_rcfile)
margs->bse_rcfile = g_strconcat (g_get_home_dir (), "/.bserc", NULL);
-
guint e = 1;
for (i = 1; i < argc; i++)
if (argv[i])
@@ -696,7 +631,6 @@ bse_async_parse_args (gint *argc_p,
argv[i] = NULL;
}
*argc_p = e;
-
if (values)
{
SfiInitValue *value = values;
@@ -727,14 +661,12 @@ bse_async_parse_args (gint *argc_p,
value++;
}
}
-
/* constrain (user) config */
margs->wave_chunk_padding = MAX (1, margs->wave_chunk_padding);
margs->wave_chunk_big_pad = MAX (2 * margs->wave_chunk_padding, margs->wave_chunk_big_pad);
margs->dcache_block_size = MAX (2 * margs->wave_chunk_big_pad + sizeof (((GslDataCacheNode*) NULL)->data[0]), margs->dcache_block_size);
margs->dcache_block_size = sfi_alloc_upper_power2 (margs->dcache_block_size - 1);
/* margs->dcache_cache_memory = sfi_alloc_upper_power2 (margs->dcache_cache_memory); */
-
/* non-configurable config updates */
margs->n_processors = get_n_processors ();
}
diff --git a/bse/bsemain.hh b/bse/bsemain.hh
index 1ef978f..c77db5a 100644
--- a/bse/bsemain.hh
+++ b/bse/bsemain.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MAIN_H__
#define __BSE_MAIN_H__
-
#include <bse/bse.hh> /* initialization */
#include <bse/bsetype.hh>
-
G_BEGIN_DECLS
-
-
/* --- initialization --- */
void bse_init_textdomain_only (void);
#if 0 // prototyped in bse.hh */
@@ -28,14 +24,11 @@ void bse_init_inprocess (gint *argc,
void bse_init_test (gint *argc,
gchar ***argv,
SfiInitValue values[]);
-
/* BSE thread pid (or 0) */
guint bse_main_getpid (void);
-
/* messaging */
void bse_message_setup_thread_handler (void);
void bse_message_to_default_handler (const BseMessage *msg);
-
/* --- global macros --- */
#define BSE_THREADS_ENTER() // bse_main_global_lock ()
#define BSE_THREADS_LEAVE() // bse_main_global_unlock ()
@@ -43,7 +36,6 @@ void bse_message_to_default_handler (const BseMessage *msg);
#define BSE_SEQUENCER_UNLOCK() sfi_mutex_unlock (&bse_main_sequencer_mutex)
#define BSE_DBG_EXT (bse_main_args->debug_extensions != FALSE)
#define BSE_CONFIG(field) (bse_main_args->field)
-
/* --- argc/argv overide settings --- */
typedef struct {
BirnetInitSettings birnet;
@@ -76,12 +68,10 @@ typedef struct {
SfiRing *pcm_drivers;
SfiRing *midi_drivers;
} BseMainArgs;
-
/* --- debuging channels --- */
typedef struct {
SfiDebugChannel *sequencer; /* --bse-trace-sequencer */
} BseTraceArgs;
-
/* --- internal --- */
void _bse_init_c_wrappers ();
extern BseMainArgs *bse_main_args;
@@ -89,8 +79,5 @@ extern BseTraceArgs bse_trace_args;
extern GMainContext *bse_main_context;
extern BirnetMutex bse_main_sequencer_mutex;
extern BirnetThread *bse_main_thread;
-
-
G_END_DECLS
-
#endif /* __BSE_MAIN_H__ */
diff --git a/bse/bsemath.cc b/bse/bsemath.cc
index 7c5e52d..8097f90 100644
--- a/bse/bsemath.cc
+++ b/bse/bsemath.cc
@@ -6,14 +6,12 @@
#define RING_BUFFER_LENGTH (256) // FIXME: simlpy dup strings in the API
#define PRINTF_DIGITS "1270"
#define FLOAT_STRING_SIZE (2048)
-
/* --- functions --- */
static inline char*
pretty_print_double (char *str,
double d)
{
char *s= str;
-
sprintf (s, "%."PRINTF_DIGITS"f", d);
while (*s)
s++;
@@ -22,7 +20,6 @@ pretty_print_double (char *str,
*s = 0;
return s;
}
-
char*
bse_complex_list (uint n_points,
BseComplex *points,
@@ -32,7 +29,6 @@ bse_complex_list (uint n_points,
static char* rbuffer[RING_BUFFER_LENGTH] = { NULL, };
char *s, *tbuffer = g_newa (char, (FLOAT_STRING_SIZE * 2 * n_points));
uint i;
-
rbi = (rbi + 1) % RING_BUFFER_LENGTH;
if (rbuffer[rbi] != NULL)
g_free (rbuffer[rbi]);
@@ -52,14 +48,12 @@ bse_complex_list (uint n_points,
rbuffer[rbi] = g_strdup (tbuffer);
return rbuffer[rbi];
}
-
char*
bse_complex_str (BseComplex c)
{
static uint rbi = 0;
static char* rbuffer[RING_BUFFER_LENGTH] = { NULL, };
char *s, tbuffer[FLOAT_STRING_SIZE * 2];
-
rbi = (rbi + 1) % RING_BUFFER_LENGTH;
if (rbuffer[rbi] != NULL)
g_free (rbuffer[rbi]);
@@ -74,7 +68,6 @@ bse_complex_str (BseComplex c)
rbuffer[rbi] = g_strdup (tbuffer);
return rbuffer[rbi];
}
-
char*
bse_poly_str (uint degree,
double *a,
@@ -84,7 +77,6 @@ bse_poly_str (uint degree,
static char* rbuffer[RING_BUFFER_LENGTH] = { NULL, };
char *s, *tbuffer = g_newa (char, degree * FLOAT_STRING_SIZE);
uint i;
-
if (!var)
var = "x";
rbi = (rbi + 1) % RING_BUFFER_LENGTH;
@@ -107,7 +99,6 @@ bse_poly_str (uint degree,
rbuffer[rbi] = g_strdup (tbuffer);
return rbuffer[rbi];
}
-
char*
bse_poly_str1 (uint degree,
double *a,
@@ -117,7 +108,6 @@ bse_poly_str1 (uint degree,
static char* rbuffer[RING_BUFFER_LENGTH] = { NULL, };
char *s, *tbuffer = g_newa (char, degree * FLOAT_STRING_SIZE);
uint i, need_plus = 0;
-
if (!var)
var = "x";
rbi = (rbi + 1) % RING_BUFFER_LENGTH;
@@ -162,18 +152,15 @@ bse_poly_str1 (uint degree,
rbuffer[rbi] = g_strdup (tbuffer);
return rbuffer[rbi];
}
-
void
bse_complex_gnuplot (const char *file_name,
uint n_points,
BseComplex *points)
{
FILE *fout = fopen (file_name, "w");
-
fputs (bse_complex_list (n_points, points, ""), fout);
fclose (fout);
}
-
void
bse_float_gnuplot (const char *file_name,
double xstart,
@@ -192,25 +179,20 @@ bse_float_gnuplot (const char *file_name,
}
fclose (fout);
}
-
double
bse_temp_freq (double kammer_freq,
int semitone_delta)
{
double factor;
-
factor = pow (BSE_2_POW_1_DIV_12, semitone_delta);
-
return kammer_freq * factor;
}
-
void
bse_poly_from_re_roots (uint degree,
double *a,
BseComplex *roots)
{
uint i;
-
/* initialize polynomial */
a[1] = 1;
a[0] = -roots[0].re;
@@ -218,21 +200,18 @@ bse_poly_from_re_roots (uint degree,
for (i = 1; i < degree; i++)
{
uint j;
-
a[i + 1] = a[i];
for (j = i; j >= 1; j--)
a[j] = a[j - 1] - a[j] * roots[i].re;
a[0] *= -roots[i].re;
}
}
-
void
bse_cpoly_from_roots (uint degree,
BseComplex *c,
BseComplex *roots)
{
uint i;
-
/* initialize polynomial */
c[1].re = 1;
c[1].im = 0;
@@ -243,14 +222,12 @@ bse_cpoly_from_roots (uint degree,
{
BseComplex r = bse_complex (-roots[i].re, -roots[i].im);
uint j;
-
c[i + 1] = c[i];
for (j = i; j >= 1; j--)
c[j] = bse_complex_add (c[j - 1], bse_complex_mul (c[j], r));
c[0] = bse_complex_mul (c[0], r);
}
}
-
gboolean
bse_poly2_droots (double roots[2],
double a,
@@ -259,21 +236,16 @@ bse_poly2_droots (double roots[2],
{
double square = b * b - 4.0 * a * c;
double tmp;
-
if (square < 0)
return FALSE;
-
if (b > 0)
tmp = -b - sqrt (square);
else
tmp = -b + sqrt (square);
-
roots[0] = tmp / (a + a);
roots[1] = (c + c) / tmp;
-
return TRUE;
}
-
double
bse_bit_depth_epsilon (uint n_bits)
{
@@ -315,10 +287,8 @@ bse_bit_depth_epsilon (uint n_bits)
.0000000004656612873077392578124900000000,
.0000000002328306436538696289062490000000,
};
-
return bit_epsilons[CLAMP (n_bits, 1, 32) - 1];
}
-
int
bse_rand_bool (void)
{
diff --git a/bse/bsemath.hh b/bse/bsemath.hh
index 401094b..232511b 100644
--- a/bse/bsemath.hh
+++ b/bse/bsemath.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MATH_H__
#define __BSE_MATH_H__
-
#include <bse/bsedefs.hh>
#include <bse/bseieee754.hh> /* provides math.h */
-
G_BEGIN_DECLS
-
/* --- constants --- */
/* PI is defined in bseieee754.hh */
#define BSE_1_DIV_PI (0.3183098861837906715377675267450287240689) // 1/pi
@@ -34,13 +31,11 @@ G_BEGIN_DECLS
#define BSE_DECIBEL10_FACTOR (4.34294481903251827651128918916605082294397) // 10.0 / ln (10.0)
#define BSE_1_DIV_DECIBEL20_FACTOR (0.1151292546497022842008995727342182103801) // ln (10) / 20
#define BSE_COMPLEX_ONE (bse_complex (1, 0))
-
/* --- structures --- */
typedef struct {
double re;
double im;
} BseComplex;
-
/* --- complex numbers --- */
static inline BseComplex bse_complex (double re,
double im);
@@ -85,7 +80,6 @@ char* bse_complex_list (uint n_points,
void bse_complex_gnuplot (const char *file_name,
uint n_points,
BseComplex *points);
-
/* --- polynomials --- */
/* example, degree=2: 5+2x+7x^2 => a[0..degree] = { 5, 2, 7 } */
static inline void bse_poly_add (uint degree,
@@ -138,11 +132,9 @@ char* bse_poly_str (uint degree,
char* bse_poly_str1 (uint degree,
double *a,
const char *var);
-
/* --- transformations --- */
double bse_temp_freq (double kammer_freq,
int semitone_delta);
-
/* --- miscellaneous --- */
double bse_bit_depth_epsilon (guint n_bits); /* 1..32 */
gint bse_rand_int (void); /* +-G_MAXINT */
@@ -153,8 +145,6 @@ void bse_float_gnuplot (const char *file_name,
double xstep,
uint n_ypoints,
const float *ypoints);
-
-
/* --- implementations --- */
static inline BseComplex
bse_complex (double re,
@@ -222,7 +212,6 @@ bse_complex_mul3 (BseComplex c1,
double bce = c1.im * c2.re * c3.re;
double acf = c1.re * c2.re * c3.im;
double bdf = c1.im * c2.im * c3.im;
-
return bse_complex (aec - bde - adf - bcf, ade + bce + acf - bdf);
}
static inline BseComplex
@@ -363,7 +352,6 @@ bse_poly_add (uint degree,
double *b)
{
uint i;
-
for (i = 0; i <= degree; i++)
a[i] += b[i];
}
@@ -373,7 +361,6 @@ bse_poly_sub (uint degree,
double *b)
{
uint i;
-
for (i = 0; i <= degree; i++)
a[i] -= b[i];
}
@@ -385,12 +372,10 @@ bse_poly_mul (double *p, /* out:[0..aorder+border] */
const double *b) /* in:[0..border] */
{
uint i;
-
for (i = aorder + border; i > 0; i--)
{
uint j;
double t = 0;
-
for (j = i - MIN (border, i); j <= MIN (aorder, i); j++)
t += a[j] * b[i - j];
p[i] = t;
@@ -403,7 +388,6 @@ bse_cpoly_mul_monomial (uint degree,
BseComplex root)
{
uint j;
-
c[degree] = c[degree - 1];
for (j = degree - 1; j >= 1; j--)
c[j] = bse_complex_sub (c[j - 1], bse_complex_mul (c[j], root));
@@ -415,7 +399,6 @@ bse_cpoly_mul_reciprocal (uint degree,
BseComplex root)
{
uint j;
-
c[degree] = bse_complex_mul (c[degree - 1], bse_complex_inv (root));
for (j = degree - 1; j >= 1; j--)
c[j] = bse_complex_sub (c[j], bse_complex_mul (c[j - 1], root));
@@ -429,12 +412,10 @@ bse_cpoly_mul (BseComplex *p, /* [0..aorder+border] */
BseComplex *b)
{
uint i;
-
for (i = aorder + border; i > 0; i--)
{
BseComplex t;
uint j;
-
t = bse_complex (0, 0);
for (j = i - MIN (i, border); j <= MIN (aorder, i); j++)
t = bse_complex_add (t, bse_complex_mul (a[j], b[i - j]));
@@ -448,7 +429,6 @@ bse_poly_scale (uint degree,
double scale)
{
uint i;
-
for (i = 0; i <= degree; i++)
a[i] *= scale;
}
@@ -459,7 +439,6 @@ bse_poly_xscale (uint degree,
{
double scale = xscale;
uint i;
-
for (i = 1; i <= degree; i++)
{
a[i] *= scale;
@@ -472,12 +451,9 @@ bse_poly_eval (uint degree,
double x)
{
double sum = a[degree];
-
while (degree--)
sum = sum * x + a[degree];
return sum;
}
-
G_END_DECLS
-
#endif /* __BSE_MATH_H__ */ /* vim: set ts=8 sw=2 sts=2: */
diff --git a/bse/bsemathsignal.cc b/bse/bsemathsignal.cc
index 3174f4f..1f40cf3 100644
--- a/bse/bsemathsignal.cc
+++ b/bse/bsemathsignal.cc
@@ -1,7 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemathsignal.hh"
-
-
/* --- frequency modulation --- */
void
bse_frequency_modulator (const BseFrequencyModulator *fm,
@@ -12,11 +10,9 @@ bse_frequency_modulator (const BseFrequencyModulator *fm,
{
float *bound, fine_tune, fm_strength;
gboolean with_fine_tune;
-
fine_tune = bse_cent_tune_fast (fm->fine_tune);
with_fine_tune = fm->fine_tune != 0;
fm_strength = fm->fm_strength;
-
bound = fm_buffer + n_values;
if (ifreq && ifmod)
{
@@ -46,7 +42,6 @@ bse_frequency_modulator (const BseFrequencyModulator *fm,
else if (ifmod)
{
float signal_freq = fm->signal_freq * fine_tune;
-
if (fm->exponential_fm)
do {
*fm_buffer++ = signal_freq * bse_approx5_exp2 (fm_strength * *ifmod++);
@@ -70,51 +65,40 @@ bse_frequency_modulator (const BseFrequencyModulator *fm,
else
{
float signal_freq = fm->signal_freq * fine_tune;
-
do {
*fm_buffer++ = signal_freq;
} while (fm_buffer < bound);
}
}
-
-
/* --- windows --- */
double
bse_window_bartlett (double x) /* triangle */
{
if (fabs (x) > 1)
return 0;
-
return 1.0 - fabs (x);
}
-
double
bse_window_blackman (double x)
{
if (fabs (x) > 1)
return 0;
-
return 0.42 + 0.5 * cos (PI * x) + 0.08 * cos (2.0 * PI * x);
}
-
double
bse_window_cos (double x) /* von Hann window */
{
if (fabs (x) > 1)
return 0;
-
return 0.5 * cos (x * PI) + 0.5;
}
-
double
bse_window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
{
if (fabs (x) > 1)
return 0;
-
return 0.54 + 0.46 * cos (PI * x);
}
-
double
bse_window_sinc (double x) /* noramlied C. Lanczos window */
{
@@ -126,7 +110,6 @@ bse_window_sinc (double x) /* noramlied C. Lanczos window */
else
return sin (x) / x;
}
-
double
bse_window_rect (double x) /* a square */
{
@@ -134,12 +117,9 @@ bse_window_rect (double x) /* a square */
return 0;
return 1.0;
}
-
/*
cos_roll_off(x)= x>fh?0:x<fl?1:cos(pi/2.*((fl-x)/(fh-fl)))
*/
-
-
/* --- fine tune factors for -100..+100 cent --- */
static const double cent_table201[100 + 1 + 100] = {
/* 2^(1/1200*-100) .. 2^(1/1200*0) .. 2^(1/1200*+100) */
@@ -196,7 +176,6 @@ static const double cent_table201[100 + 1 + 100] = {
1.05762877449345591872, 1.05823986130118871317, 1.05885130118846660974, 1.05946309435929526456, /* 2^(1/1200*100) */
};
const double * const bse_cent_table = cent_table201 + 100;
-
/**
* @param fine_tune fine tuning in cent
* @return a factor corresponding to this
@@ -211,12 +190,10 @@ bse_cent_tune (double fine_tune)
{
return exp (fine_tune * BSE_LN_2_POW_1_DIV_1200_d);
}
-
/* --- musical tuning systems --- */
#define SCALED_INTERVAL(scale, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12) \
scale * (F1), scale * (F2), scale * (F3), scale * (F4), scale * (F5), scale * (F6), \
scale * (F7), scale * (F8), scale * (F9), scale * (F10), scale * (F11), scale * (F12)
-
// http://en.wikipedia.org/wiki/Equal_temperament
static const double semitone_table265_equal_temperament_12_tet[132 + 1 + 132] = {
#define EQTEMP_12_TET(scale) \
@@ -236,7 +213,6 @@ static const double semitone_table265_equal_temperament_12_tet[132 + 1 + 132] =
EQTEMP_12_TET (1024.0), 2048.0, /* 2^11 */
#undef EQTEMP_12_TET
};
-
// http://en.wikipedia.org/wiki/Equal_temperament
static const double semitone_table265_equal_temperament_7_tet[132 + 1 + 132] = {
#define EQTEMP_7_TET(scale) \
@@ -264,7 +240,6 @@ static const double semitone_table265_equal_temperament_7_tet[132 + 1 + 132] = {
EQTEMP_7_TET (1024.0), 2048.0, /* 2^11 */
#undef EQTEMP_7_TET
};
-
// http://en.wikipedia.org/wiki/Equal_temperament
static const double semitone_table265_equal_temperament_5_tet[132 + 1 + 132] = {
#define EQTEMP_5_TET(scale) \
@@ -292,7 +267,6 @@ static const double semitone_table265_equal_temperament_5_tet[132 + 1 + 132] = {
EQTEMP_5_TET (1024.0), 2048.0, /* 2^11 */
#undef EQTEMP_5_TET
};
-
// http://en.wikipedia.org/wiki/Diatonic_scale
static const double semitone_table265_diatonic_scale[132 + 1 + 132] = {
#define DIATONIC_SCALE(scale) \
@@ -310,7 +284,6 @@ static const double semitone_table265_diatonic_scale[132 + 1 + 132] = {
DIATONIC_SCALE (1024.0), 2048.0, /* 2^11 */
#undef DIATONIC_SCALE
};
-
// http://en.wikipedia.org/wiki/Just_intonation#Indian_scales
static const double semitone_table265_indian_scale[132 + 1 + 132] = {
#define INDIAN_SCALE(scale) \
@@ -328,7 +301,6 @@ static const double semitone_table265_indian_scale[132 + 1 + 132] = {
INDIAN_SCALE (1024.0), 2048.0, /* 2^11 */
#undef INDIAN_SCALE
};
-
// http://en.wikipedia.org/wiki/Pythagorean_tuning
static const double semitone_table265_pythagorean_tuning[132 + 1 + 132] = {
#define PYTHAGOREAN_TUNING(scale) \
@@ -346,7 +318,6 @@ static const double semitone_table265_pythagorean_tuning[132 + 1 + 132] = {
PYTHAGOREAN_TUNING (1024.0), 2048.0, /* 2^11 */
#undef PYTHAGOREAN_TUNING
};
-
// http://en.wikipedia.org/wiki/Pentatonic_scale
static const double semitone_table265_pentatonic_5_limit[132 + 1 + 132] = {
#define PENTATONIC_5_LIMIT(scale) \
@@ -364,7 +335,6 @@ static const double semitone_table265_pentatonic_5_limit[132 + 1 + 132] = {
PENTATONIC_5_LIMIT (1024.0), 2048.0, /* 2^11 */
#undef PENTATONIC_5_LIMIT
};
-
// http://en.wikipedia.org/wiki/Pentatonic_scale
static const double semitone_table265_pentatonic_blues[132 + 1 + 132] = {
#define PENTATONIC_BLUES(scale) \
@@ -382,7 +352,6 @@ static const double semitone_table265_pentatonic_blues[132 + 1 + 132] = {
PENTATONIC_BLUES (1024.0), 2048.0, /* 2^11 */
#undef PENTATONIC_BLUES
};
-
// http://en.wikipedia.org/wiki/Pentatonic_scale
static const double semitone_table265_pentatonic_gogo[132 + 1 + 132] = {
#define PENTATONIC_GOGO(scale) \
@@ -400,7 +369,6 @@ static const double semitone_table265_pentatonic_gogo[132 + 1 + 132] = {
PENTATONIC_GOGO (1024.0), 2048.0, /* 2^11 */
#undef PENTATONIC_GOGO
};
-
// http://en.wikipedia.org/wiki/Quarter-comma_meantone
static const double semitone_table265_quarter_comma_meantone[132 + 1 + 132] = {
#define QCOMMA_MEANTONE(scale) \
@@ -427,7 +395,6 @@ static const double semitone_table265_quarter_comma_meantone[132 + 1 + 132] = {
QCOMMA_MEANTONE (1024.0), 2048.0, /* 2^11 */
#undef QCOMMA_MEANTONE
};
-
// http://de.wikipedia.org/wiki/Silbermann-Sorge-Temperatur
static const double semitone_table265_silbermann_sorge_temperament[132 + 1 + 132] = {
#define SILBERMANN_SORGE(scale) \
@@ -454,11 +421,9 @@ static const double semitone_table265_silbermann_sorge_temperament[132 + 1 + 132
SILBERMANN_SORGE (1024.0), 2048.0, /* 2^11 */
#undef SILBERMANN_SORGE
};
-
#define SQRT2_2 1.4142135623730950488016887242097 /* 2^0.5 */
#define SQRT4_2 1.1892071150027210667174999705605 /* 2^0.25 */
#define SQRT4_8 1.6817928305074290860622509524664 /* 8^0.25 */
-
// http://en.wikipedia.org/wiki/Werckmeister_temperament
static const double semitone_table265_werckmeister3_temperament[132 + 1 + 132] = {
#define WMEISTER3_TEMPERAMENT(scale) \
@@ -478,10 +443,8 @@ static const double semitone_table265_werckmeister3_temperament[132 + 1 + 132] =
WMEISTER3_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef WMEISTER3_TEMPERAMENT
};
-
#define SQRT3_2 1.2599210498948731647672106072782 /* 2^(1/3) */
#define SQRT3_4 1.5874010519681994747517056392723 /* 4^(1/3) */
-
// http://en.wikipedia.org/wiki/Werckmeister_temperament
static const double semitone_table265_werckmeister4_temperament[132 + 1 + 132] = {
#define WMEISTER4_TEMPERAMENT(scale) \
@@ -501,7 +464,6 @@ static const double semitone_table265_werckmeister4_temperament[132 + 1 + 132] =
WMEISTER4_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef WMEISTER4_TEMPERAMENT
};
-
// http://en.wikipedia.org/wiki/Werckmeister_temperament
static const double semitone_table265_werckmeister5_temperament[132 + 1 + 132] = {
#define WMEISTER5_TEMPERAMENT(scale) \
@@ -520,7 +482,6 @@ static const double semitone_table265_werckmeister5_temperament[132 + 1 + 132] =
WMEISTER5_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef WMEISTER5_TEMPERAMENT
};
-
// http://en.wikipedia.org/wiki/Werckmeister_temperament
static const double semitone_table265_werckmeister6_temperament[132 + 1 + 132] = {
#define WMEISTER6_TEMPERAMENT(scale) \
@@ -539,7 +500,6 @@ static const double semitone_table265_werckmeister6_temperament[132 + 1 + 132] =
WMEISTER6_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef WMEISTER6_TEMPERAMENT
};
-
// http://en.wikipedia.org/wiki/Johann_Philipp_Kirnberger_temperament
static const double semitone_table265_kirnberger_temperament[132 + 1 + 132] = {
#define KBERGER3_TEMPERAMENT(scale) \
@@ -558,7 +518,6 @@ static const double semitone_table265_kirnberger_temperament[132 + 1 + 132] = {
KBERGER3_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef KBERGER3_TEMPERAMENT
};
-
// http://en.wikipedia.org/wiki/Young_temperament
static const double semitone_table265_young_temperament[132 + 1 + 132] = {
#define YOUNG_TEMPERAMENT(scale) \
@@ -585,7 +544,6 @@ static const double semitone_table265_young_temperament[132 + 1 + 132] = {
YOUNG_TEMPERAMENT (1024.0), 2048.0, /* 2^11 */
#undef YOUNG_TEMPERAMENT
};
-
const double*
bse_semitone_table_from_tuning (BseMusicalTuningType musical_tuning)
{
@@ -632,7 +590,6 @@ bse_semitone_table_from_tuning (BseMusicalTuningType musical_tuning)
return 132 + semitone_table265_young_temperament;
}
}
-
double
bse_transpose_factor (BseMusicalTuningType musical_tuning,
int index /* [-132..+132] */)
@@ -640,11 +597,9 @@ bse_transpose_factor (BseMusicalTuningType musical_tuning,
const double *table = bse_semitone_table_from_tuning (musical_tuning);
return table[CLAMP (index, -132, +132)];
}
-
/* --- cents & init --- */
void
_bse_init_signal (void) { /* FIXME: remove */ }
-
/* --- bse_approx_atan1() --- */
double
bse_approx_atan1_prescale (double boost_amount)
@@ -652,21 +607,14 @@ bse_approx_atan1_prescale (double boost_amount)
double max_boost_factor = 100; /* atan1(x*100) gets pretty close to 1 for x=1 */
double recip_tan_1_div_0_75 = 0.24202942695518667705824990442766; /* 1/tan(1/0.75) */
double scale;
-
g_return_val_if_fail (boost_amount >= 0 && boost_amount <= 1.0, 1.0);
-
/* scale boost_amount from [0..1] to -1..1 */
boost_amount = boost_amount * 2 - 1.0;
-
/* prescale factor for atan1(x*prescale), ranges from 1/max_boost_factor..max_boost_factor */
scale = pow (max_boost_factor, tan (boost_amount / 0.75) * recip_tan_1_div_0_75);
-
/* atan1_prescale(ba)=100 ** (tan ((ba*2-1) / 0.75) * 0.24202942695518667705824990442766) */
-
return scale;
}
-
-
/* --- exp2f() approximation taylor coefficients finder --- */
#if 0
#include <stdio.h>
@@ -675,7 +623,6 @@ exp2coeff (int n)
{
double r = 1;
int i;
-
for (i = 1; i <= n; i++)
{
r *= BSE_LN2;
@@ -689,10 +636,8 @@ main (int argc,
char *argv[])
{
int i;
-
for (i = 0; i < 20; i++)
printf ("#define EXP2_TAYLOR_COEFF_%u\t(%.40f)\n", i, exp2coeff (i));
-
return 0;
}
/* test/bench program */
@@ -703,7 +648,6 @@ main (int argc,
char *argv[])
{
double x, dummy = 0, l = 4;
-
if (1) /* print errors */
for (x = -3; x < 3.01; x += 0.1)
{
@@ -711,17 +655,13 @@ main (int argc,
x, exp (x * BSE_LN2) - bse_approx5_exp2 (x),
exp (x * BSE_LN2), bse_approx5_exp2 (x));
}
-
if (0) /* bench test */
for (x = -l; x < l; x += 0.000001)
{
dummy += bse_approx5_exp2 (x);
// dummy += exp2f (x);
}
-
g_print ("%f\r \n", dummy);
-
return 0;
}
#endif /* coeff generation */
-
diff --git a/bse/bsemathsignal.hh b/bse/bsemathsignal.hh
index aef1574..d8c04a7 100644
--- a/bse/bsemathsignal.hh
+++ b/bse/bsemathsignal.hh
@@ -1,23 +1,18 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SIGNAL_H__
#define __BSE_SIGNAL_H__
-
#include <bse/bsemath.hh>
#include <bse/bseglobals.hh>
#include <bse/bsetype.hh> // for BseMusicalTuningType
-
G_BEGIN_DECLS
-
/**
* smallest value of a signal sample, greater than zero
*/
#define BSE_SIGNAL_EPSILON (1.15e-14) /* 1.16415321826934814453125e-9 ~= 1/2^33 */
-
/**
* maximum value of a signal sample
*/
#define BSE_SIGNAL_KAPPA (1.5)
-
/**
* Catch edges in sync signals.
* sync signals should be constant, do comparing against
@@ -28,7 +23,6 @@ G_BEGIN_DECLS
* Inverse variant of BSE_SIGNAL_RAISING_EDGE().
*/
#define BSE_SIGNAL_FALLING_EDGE(v1,v2) ((v1) > (v2))
-
/**
* Value changes in signals which represent frequencies.
*/
@@ -37,17 +31,14 @@ G_BEGIN_DECLS
* Inverse variant of BSE_SIGNAL_FREQ_CHANGED().
*/
#define BSE_SIGNAL_FREQ_EQUALS(v1,v2) (!BSE_SIGNAL_FREQ_CHANGED (v1, v2))
-
/**
* Value changes in signals which represent modulation.
*/
#define BSE_SIGNAL_MOD_CHANGED(v1,v2) (fabs ((v1) - (v2)) > 1e-8)
-
/**
* Value changes in signals which represent dB ranges.
*/
#define BSE_SIGNAL_GAIN_CHANGED(v1,v2) (fabs ((v1) - (v2)) > 1e-8)
-
/**
* Convert between literal frequencies and signal values.
*/
@@ -55,9 +46,7 @@ G_BEGIN_DECLS
#define BSE_SIGNAL_FROM_FREQ_FACTOR (1.0 / BSE_MAX_FREQUENCY)
#define BSE_SIGNAL_TO_FREQ(value) (BSE_FREQ_FROM_VALUE (value))
#define BSE_SIGNAL_FROM_FREQ(freq) (BSE_VALUE_FROM_FREQ (freq))
-
#define BSE_SIGNAL_CLIP(v) bse_signal_value_clip (v)
-
static inline double bse_signal_value_clip (register double x) G_GNUC_CONST;
static inline double G_GNUC_CONST
bse_signal_value_clip (register double x)
@@ -68,8 +57,6 @@ bse_signal_value_clip (register double x)
return -1.0;
return x;
}
-
-
/* --- frequency modulation --- */
typedef struct {
gfloat fm_strength; /* linear: 0..1, exponential: n_octaves */
@@ -77,14 +64,11 @@ typedef struct {
gfloat signal_freq; /* for ifreq == NULL (as BSE_SIGNAL_FROM_FREQ) */
gint fine_tune; /* -100..+100 */
} BseFrequencyModulator;
-
void bse_frequency_modulator (const BseFrequencyModulator *fm,
guint n_values,
const gfloat *ifreq,
const gfloat *ifmod,
gfloat *fm_buffer);
-
-
/* --- windows --- */
double bse_window_bartlett (double x); /* narrowest */
double bse_window_blackman (double x);
@@ -92,10 +76,7 @@ double bse_window_cos (double x);
double bse_window_hamming (double x);
double bse_window_sinc (double x);
double bse_window_rect (double x); /* widest */
-
-
/* --- function approximations --- */
-
/**
* @param x x as in atan(x)
*
@@ -108,7 +89,6 @@ double bse_window_rect (double x); /* widest */
* positive_atan1(x) = 1 + (n1 * x + n2) / ((1 + d1 * x) * x + d2);
*/
static inline double bse_approx_atan1 (register double x) G_GNUC_CONST;
-
/**
* @param boost_amount boost amount between [0..1]
* @return prescale factor for bse_approx_atan1()
@@ -118,7 +98,6 @@ static inline double bse_approx_atan1 (register double x) G_GNUC_CONST;
* in maximum boost and 0.0 results in maximum attenuation.
*/
double bse_approx_atan1_prescale (double boost_amount);
-
/**
* @param x x within [0..1]
* @return y for circle approximation within [0..1]
@@ -129,7 +108,6 @@ double bse_approx_atan1_prescale (double boost_amount);
* quarter circle. The maximum error is below 0.092.
*/
static inline double bse_approx_qcircle1 (register double x) G_GNUC_CONST;
-
/**
* @param x x within [0..1]
* @return y for circle approximation within [0..1]
@@ -140,7 +118,6 @@ static inline double bse_approx_qcircle1 (register double x) G_GNUC_CONST;
* quarter circle. The maximum error is below 0.092.
*/
static inline double bse_approx_qcircle2 (register double x) G_GNUC_CONST;
-
/**
* @param x x within [0..1]
* @return y for circle approximation within [0..1]
@@ -151,7 +128,6 @@ static inline double bse_approx_qcircle2 (register double x) G_GNUC_CONST;
* quarter circle. The maximum error is below 0.092.
*/
static inline double bse_approx_qcircle3 (register double x) G_GNUC_CONST;
-
/**
* @param x x within [0..1]
* @return y for circle approximation within [0..1]
@@ -162,7 +138,6 @@ static inline double bse_approx_qcircle3 (register double x) G_GNUC_CONST;
* quarter circle. The maximum error is below 0.092.
*/
static inline double bse_approx_qcircle4 (register double x) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -174,7 +149,6 @@ static inline double bse_approx_qcircle4 (register double x) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 12.81 ns.
*/
static inline double bse_approx2_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -186,7 +160,6 @@ static inline double bse_approx2_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 13.74 ns.
*/
static inline double bse_approx3_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -198,7 +171,6 @@ static inline double bse_approx3_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 16.46 ns.
*/
static inline double bse_approx4_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -210,7 +182,6 @@ static inline double bse_approx4_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 18.51 ns.
*/
static inline double bse_approx5_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -222,7 +193,6 @@ static inline double bse_approx5_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 21.84 ns.
*/
static inline double bse_approx6_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -234,7 +204,6 @@ static inline double bse_approx6_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 23.79 ns.
*/
static inline double bse_approx7_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -247,7 +216,6 @@ static inline double bse_approx7_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 26.59 ns.
*/
static inline double bse_approx8_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param ex exponent within [-127..+127]
* @return y approximating 2^ex
@@ -260,7 +228,6 @@ static inline double bse_approx8_exp2 (float ex) G_GNUC_CONST;
* approaches zero. On a 2GHz machine, execution takes roughly 29.40 ns.
*/
static inline double bse_approx9_exp2 (float ex) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -271,7 +238,6 @@ static inline double bse_approx9_exp2 (float ex) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 24.48 ns.
*/
static inline double bse_approx2_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -282,7 +248,6 @@ static inline double bse_approx2_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 25.78 ns.
*/
static inline double bse_approx3_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -293,7 +258,6 @@ static inline double bse_approx3_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 28.41 ns.
*/
static inline double bse_approx4_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -304,7 +268,6 @@ static inline double bse_approx4_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 30.35 ns.
*/
static inline double bse_approx5_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -315,7 +278,6 @@ static inline double bse_approx5_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 34.29 ns.
*/
static inline double bse_approx6_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -326,7 +288,6 @@ static inline double bse_approx6_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 36.86 ns.
*/
static inline double bse_approx7_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -338,7 +299,6 @@ static inline double bse_approx7_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 42.03 ns.
*/
static inline double bse_approx8_tanh (float x) G_GNUC_CONST;
-
/**
* @param x exponent within [-127..+127]
* @return y approximating tanh(x)
@@ -350,7 +310,6 @@ static inline double bse_approx8_tanh (float x) G_GNUC_CONST;
* On a 2GHz machine, execution takes roughly 43.83 ns.
*/
static inline double bse_approx9_tanh (float x) G_GNUC_CONST;
-
/**
* @param value value to saturate
* @param limit limit not to be exceeded by value
@@ -363,7 +322,6 @@ static inline double bse_approx9_tanh (float x) G_GNUC_CONST;
*/
static inline double bse_saturate_hard (double value,
double limit) G_GNUC_CONST;
-
/**
* @param value value to saturate
* @param limit limit not to be exceeded by value
@@ -376,16 +334,12 @@ static inline double bse_saturate_hard (double value,
*/
static inline double bse_saturate_branching (double value,
double limit) G_GNUC_CONST;
-
/* --- semitone factors (for +-11 octaves) --- */
const double* bse_semitone_table_from_tuning (BseMusicalTuningType musical_tuning); /* returns [-132..+132] */
double bse_transpose_factor (BseMusicalTuningType musical_tuning,
int index /* [-132..+132] */);
-
/* --- cents (1/100th of a semitone) --- */
-
double bse_cent_tune (double fine_tune);
-
/**
* @param fine_tune fine tuning in cent between -100 and 100
* @return a factor corresponding to this
@@ -397,7 +351,6 @@ double bse_cent_tune (double fine_tune);
* that it lies in this range.
*/
static inline double bse_cent_tune_fast (int fine_tune /* -100..+100 */) G_GNUC_CONST;
-
/* --- implementation details --- */
static inline double G_GNUC_CONST
bse_approx_atan1 (register double x)
@@ -405,32 +358,27 @@ bse_approx_atan1 (register double x)
if (x < 0) /* make use of -atan(-x)==atan(x) */
{
register double numerator, denominator = -1.0;
-
denominator += x * 0.81901156857081841441890603235599; /* d1 */
numerator = x * 0.41156875521951602506487246309908; /* -n1 */
denominator *= x;
numerator += -1.0091272542790025586079663559158; /* n2 */
denominator += 1.0091272542790025586079663559158; /* d2 */
-
return -1.0 - numerator / denominator;
}
else
{
register double numerator, denominator = 1.0;
-
denominator += x * 0.81901156857081841441890603235599; /* d1 */
numerator = x * -0.41156875521951602506487246309908; /* n1 */
denominator *= x;
numerator += -1.0091272542790025586079663559158; /* n2 */
denominator += 1.0091272542790025586079663559158; /* d2 */
-
return 1.0 + numerator / denominator;
}
/* atan1_positive(x)=1+(x*-0.411568755219516-1.009127254279)/((1+x*0.81901156857)*x+1.009127254279)
* atan1(x)=x<0 ? -atan1_positive(-x) : atan1_positive(x)
*/
}
-
static inline double G_GNUC_CONST
bse_approx_qcircle1 (register double x)
{
@@ -439,7 +387,6 @@ bse_approx_qcircle1 (register double x)
/* R1(x)=(1.2046012479036946898771563 * x - 1.2046012479036946898771563) / (x - 1.2046012479036946898771563) */
return numerator / denominator;
}
-
static inline double G_GNUC_CONST
bse_approx_qcircle2 (register double x)
{
@@ -448,7 +395,6 @@ bse_approx_qcircle2 (register double x)
/* R2(x)=1.2046012479036946898771563*x/(x + 0.2046012479036946898771563) */
return numerator / denominator;
}
-
static inline double G_GNUC_CONST
bse_approx_qcircle3 (register double x)
{
@@ -457,7 +403,6 @@ bse_approx_qcircle3 (register double x)
/* R3(x)=(0.2046012479036946898771563 - 0.2046012479036946898771563 * x) / (x + 0.2046012479036946898771563) */
return numerator / denominator;
}
-
static inline double G_GNUC_CONST
bse_approx_qcircle4 (register double x)
{
@@ -466,7 +411,6 @@ bse_approx_qcircle4 (register double x)
/* R4(x)=-0.2046012479036946898771563 * x / (x - 1.2046012479036946898771563) */
return numerator / denominator;
}
-
static inline double G_GNUC_CONST
bse_approx2_exp2 (float ex)
{
@@ -477,7 +421,6 @@ bse_approx2_exp2 (float ex)
return fp.v_float * (1.0 + x * (0.69314718055994530941723212145818 +
x * (0.24022650695910071233355126316333)));
}
-
static inline double G_GNUC_CONST
bse_approx3_exp2 (float ex)
{
@@ -492,7 +435,6 @@ bse_approx3_exp2 (float ex)
* exp2a3(x)=2**ftoi(x)*(1+exp2frac(x)*(0.6931471805599453+exp2frac(x)*(0.2402265069591+exp2frac(x)*0.0555041086648)))
*/
}
-
static inline double G_GNUC_CONST
bse_approx4_exp2 (float ex)
{
@@ -509,7 +451,6 @@ bse_approx4_exp2 (float ex)
* exp2a4(x)=2**ftoi(x)*(1+exp2frac(x)*(0.6931471805599453+exp2frac(x)*(0.2402265069591+exp2frac(x)*(0.0555041086648+exp2frac(x)*0.009618129107628477))))
*/
}
-
static inline double G_GNUC_CONST
bse_approx5_exp2 (float ex)
{
@@ -523,7 +464,6 @@ bse_approx5_exp2 (float ex)
x * (0.0096181291076284771619790715736589 +
x * (0.0013333558146428443423412221987996))))));
}
-
static inline double G_GNUC_CONST
bse_approx6_exp2 (float ex)
{
@@ -538,7 +478,6 @@ bse_approx6_exp2 (float ex)
x * (0.0013333558146428443423412221987996 +
x * (0.00015403530393381609954437097332742)))))));
}
-
static inline double G_GNUC_CONST
bse_approx7_exp2 (float ex)
{
@@ -554,7 +493,6 @@ bse_approx7_exp2 (float ex)
x * (0.00015403530393381609954437097332742 +
x * (0.00001525273380405984028002543901201))))))));
}
-
static inline double G_GNUC_CONST
bse_approx8_exp2 (float ex)
{
@@ -571,7 +509,6 @@ bse_approx8_exp2 (float ex)
x * (0.00001525273380405984028002543901201 +
x * (0.0000013215486790144309488403758228288)))))))));
}
-
static inline double G_GNUC_CONST
bse_approx9_exp2 (float ex)
{
@@ -589,7 +526,6 @@ bse_approx9_exp2 (float ex)
x * (0.0000013215486790144309488403758228288 +
x * 0.00000010178086009239699727490007597745)))))))));
}
-
static inline double G_GNUC_CONST
bse_approx2_tanh (float x)
{
@@ -600,7 +536,6 @@ bse_approx2_tanh (float x)
register double bpot = bse_approx2_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx3_tanh (float x)
{
@@ -611,7 +546,6 @@ bse_approx3_tanh (float x)
register double bpot = bse_approx3_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx4_tanh (float x)
{
@@ -623,7 +557,6 @@ bse_approx4_tanh (float x)
return (bpot - 1) / (bpot + 1);
/* tanha4(x)=x<-20 ? -1 : x>20 ? 1 : (exp2a4(x*2.885390081777926814719849362)-1) / (exp2a4(x*2.885390081777926814719849362)+1) */
}
-
static inline double G_GNUC_CONST
bse_approx5_tanh (float x)
{
@@ -634,7 +567,6 @@ bse_approx5_tanh (float x)
register double bpot = bse_approx5_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx6_tanh (float x)
{
@@ -645,7 +577,6 @@ bse_approx6_tanh (float x)
register double bpot = bse_approx6_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx7_tanh (float x)
{
@@ -656,7 +587,6 @@ bse_approx7_tanh (float x)
register double bpot = bse_approx7_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx8_tanh (float x)
{
@@ -667,7 +597,6 @@ bse_approx8_tanh (float x)
register double bpot = bse_approx8_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_approx9_tanh (float x)
{
@@ -678,7 +607,6 @@ bse_approx9_tanh (float x)
register double bpot = bse_approx9_exp2 (x * BSE_2_DIV_LN2);
return (bpot - 1) / (bpot + 1);
}
-
static inline double G_GNUC_CONST
bse_saturate_hard (double value,
double limit)
@@ -687,7 +615,6 @@ bse_saturate_hard (double value,
register double v2 = fabsf (value - limit);
return 0.5 * (v1 - v2); /* CLAMP() without branching */
}
-
static inline double G_GNUC_CONST
bse_saturate_branching (double value,
double limit)
@@ -698,17 +625,12 @@ bse_saturate_branching (double value,
return -limit;
return value;
}
-
void _bse_init_signal (void);
-
extern const double * const bse_cent_table;
-
static inline double G_GNUC_CONST
bse_cent_tune_fast (int fine_tune)
{
return bse_cent_table[CLAMP (fine_tune, -100, 100)];
}
-
G_END_DECLS
-
#endif /* __BSE_SIGNAL_H__ */
diff --git a/bse/bsemidicontroller.cc b/bse/bsemidicontroller.cc
index 8eed767..e8bab01 100644
--- a/bse/bsemidicontroller.cc
+++ b/bse/bsemidicontroller.cc
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidicontroller.hh"
-
#include "bsecategories.hh"
#include "bsemidireceiver.hh"
#include "bsesnet.hh"
#include "bseengine.hh"
#include "bsecxxplugin.hh"
-
-
-
/* --- properties --- */
enum
{
@@ -19,8 +15,6 @@ enum
PROP_CONTROL_3,
PROP_CONTROL_4
};
-
-
/* --- prototypes --- */
static void bse_midi_controller_init (BseMidiController *self);
static void bse_midi_controller_class_init (BseMidiControllerClass *klass);
@@ -39,24 +33,18 @@ static void bse_midi_controller_context_connect (BseSource *source,
uint instance_id,
BseTrans *trans);
static void bse_midi_controller_update_modules (BseMidiController *self);
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseMidiController)
{
static const GTypeInfo midi_controller_info = {
sizeof (BseMidiControllerClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_controller_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiController),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_controller_init,
@@ -71,7 +59,6 @@ BSE_BUILTIN_TYPE (BseMidiController)
bse_categories_register_stock_module (N_("/Input & Output/MIDI Control Input"), type, midi_ctrl_input_pixstream);
return type;
}
-
static void
bse_midi_controller_class_init (BseMidiControllerClass *klass)
{
@@ -79,15 +66,11 @@ bse_midi_controller_class_init (BseMidiControllerClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
uint ochannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_midi_controller_set_property;
gobject_class->get_property = bse_midi_controller_get_property;
-
source_class->context_create = bse_midi_controller_context_create;
source_class->context_connect = bse_midi_controller_context_connect;
-
bse_object_class_add_param (object_class, "MIDI Controls",
PROP_MIDI_CHANNEL,
sfi_pspec_int ("midi_channel", "MIDI Channel",
@@ -118,7 +101,6 @@ bse_midi_controller_class_init (BseMidiControllerClass *klass)
BSE_TYPE_MIDI_SIGNAL_TYPE,
BSE_MIDI_SIGNAL_PRESSURE,
SFI_PARAM_STANDARD));
-
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out1", _("Ctrl Out1"), _("MIDI Signal 1"));
g_assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL1);
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out2", _("Ctrl Out2"), _("MIDI Signal 2"));
@@ -128,7 +110,6 @@ bse_midi_controller_class_init (BseMidiControllerClass *klass)
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out4", _("Ctrl Out4"), _("MIDI Signal 4"));
g_assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL4);
}
-
static void
bse_midi_controller_init (BseMidiController *self)
{
@@ -138,7 +119,6 @@ bse_midi_controller_init (BseMidiController *self)
self->controls[2] = BSE_MIDI_SIGNAL_CONTINUOUS_7;
self->controls[3] = BSE_MIDI_SIGNAL_PRESSURE;
}
-
static void
bse_midi_controller_set_property (GObject *object,
uint param_id,
@@ -146,7 +126,6 @@ bse_midi_controller_set_property (GObject *object,
GParamSpec *pspec)
{
BseMidiController *self = BSE_MIDI_CONTROLLER (object);
-
switch (param_id)
{
case PROP_MIDI_CHANNEL:
@@ -174,7 +153,6 @@ bse_midi_controller_set_property (GObject *object,
break;
}
}
-
static void
bse_midi_controller_get_property (GObject *object,
uint param_id,
@@ -182,7 +160,6 @@ bse_midi_controller_get_property (GObject *object,
GParamSpec *pspec)
{
BseMidiController *self = BSE_MIDI_CONTROLLER (object);
-
switch (param_id)
{
case PROP_MIDI_CHANNEL:
@@ -205,25 +182,21 @@ bse_midi_controller_get_property (GObject *object,
break;
}
}
-
typedef struct {
BseMidiReceiver *midi_receiver;
uint midi_channel;
uint default_channel;
BseModule *control_module;
} ModuleData;
-
static void
module_data_free (void *data)
{
ModuleData *mdata = (ModuleData*) data;
BseTrans *trans = bse_trans_open ();
-
bse_midi_receiver_discard_control_module (mdata->midi_receiver, mdata->control_module, trans);
bse_trans_commit (trans);
g_free (mdata);
}
-
static void
bse_midi_controller_context_create (BseSource *source,
uint context_handle,
@@ -234,7 +207,6 @@ bse_midi_controller_context_create (BseSource *source,
BseModule *module = bse_module_new_virtual (BSE_MIDI_CONTROLLER_N_OCHANNELS, mdata, module_data_free);
BseItem *parent = BSE_ITEM (self)->parent;
BseMidiContext mcontext = bse_snet_get_midi_context (BSE_SNET (parent), context_handle);
-
/* setup module data */
mdata->midi_receiver = mcontext.midi_receiver;
mdata->default_channel = mcontext.midi_channel;
@@ -243,17 +215,13 @@ bse_midi_controller_context_create (BseSource *source,
mdata->midi_channel,
self->controls,
trans);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_omodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_midi_controller_context_connect (BseSource *source,
uint context_handle,
@@ -261,17 +229,14 @@ bse_midi_controller_context_connect (BseSource *source,
{
BseModule *module = bse_source_get_context_omodule (source, context_handle);
ModuleData *mdata = (ModuleData*) module->user_data;
-
/* connect module to midi control uplink */
bse_trans_add (trans, bse_job_connect (mdata->control_module, 0, module, 0));
bse_trans_add (trans, bse_job_connect (mdata->control_module, 1, module, 1));
bse_trans_add (trans, bse_job_connect (mdata->control_module, 2, module, 2));
bse_trans_add (trans, bse_job_connect (mdata->control_module, 3, module, 3));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_midi_controller_update_modules (BseMidiController *self)
{
@@ -280,28 +245,22 @@ bse_midi_controller_update_modules (BseMidiController *self)
BseSource *source = BSE_SOURCE (self);
BseTrans *trans = bse_trans_open ();
uint *cids, n, i;
-
/* forall contexts */
cids = bse_source_context_ids (source, &n);
-
/* reconnect modules */
for (i = 0; i < n; i++)
{
BseModule *module = bse_source_get_context_omodule (source, cids[i]);
ModuleData *mdata = (ModuleData*) module->user_data;
-
/* disconnect from old module */
bse_trans_add (trans, bse_job_disconnect (module, 0));
bse_trans_add (trans, bse_job_disconnect (module, 1));
bse_trans_add (trans, bse_job_disconnect (module, 2));
bse_trans_add (trans, bse_job_disconnect (module, 3));
-
/* discard old module */
bse_midi_receiver_discard_control_module (mdata->midi_receiver, mdata->control_module, trans);
-
/* update midi channel */
mdata->midi_channel = self->midi_channel > 0 ? self->midi_channel : mdata->default_channel;
-
/* fetch new module */
mdata->control_module = bse_midi_receiver_retrieve_control_module (mdata->midi_receiver,
mdata->midi_channel,
@@ -313,7 +272,6 @@ bse_midi_controller_update_modules (BseMidiController *self)
bse_trans_add (trans, bse_job_connect (mdata->control_module, 2, module, 2));
bse_trans_add (trans, bse_job_connect (mdata->control_module, 3, module, 3));
}
-
/* commit and cleanup */
g_free (cids);
bse_trans_commit (trans);
diff --git a/bse/bsemidicontroller.hh b/bse/bsemidicontroller.hh
index 418ff3b..9c033c8 100644
--- a/bse/bsemidicontroller.hh
+++ b/bse/bsemidicontroller.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_CONTROLLER_H__
#define __BSE_MIDI_CONTROLLER_H__
-
#include <bse/bsesource.hh>
#include <bse/bsemidievent.hh>
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_CONTROLLER (BSE_TYPE_ID (BseMidiController))
#define BSE_MIDI_CONTROLLER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_CONTROLLER, BseMidiController))
@@ -15,15 +11,12 @@ G_BEGIN_DECLS
#define BSE_IS_CONTROLLER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_CONTROLLER))
#define BSE_IS_CONTROLLER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_CONTROLLER))
#define BSE_MIDI_CONTROLLER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_CONTROLLER, BseMidiControllerClassOut))
-
-
/* --- BseMidiController source --- */
typedef struct _BseMidiController BseMidiController;
typedef struct _BseMidiControllerClass BseMidiControllerClass;
struct _BseMidiController
{
BseSource parent_object;
-
guint midi_channel;
BseMidiSignalType controls[4];
};
@@ -31,8 +24,6 @@ struct _BseMidiControllerClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -42,8 +33,5 @@ enum
BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL4,
BSE_MIDI_CONTROLLER_N_OCHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_MIDI_CONTROLLER_H__ */
diff --git a/bse/bsemididecoder.cc b/bse/bsemididecoder.cc
index d514069..8a3316a 100644
--- a/bse/bsemididecoder.cc
+++ b/bse/bsemididecoder.cc
@@ -3,14 +3,10 @@
#include "bsemidireceiver.hh"
#include "bseengine.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_midi_decoder, "midi-decoder", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_midi_decoder, __VA_ARGS__)
-
/* --- prototypes --- */
static void bse_midi_decoder_construct_event (BseMidiDecoder *self);
-
-
/* --- function --- */
BseMidiDecoder*
bse_midi_decoder_new (gboolean auto_queue,
@@ -18,7 +14,6 @@ bse_midi_decoder_new (gboolean auto_queue,
BseMusicalTuningType musical_tuning)
{
BseMidiDecoder *self;
-
self = g_new0 (BseMidiDecoder, 1);
self->musical_tuning = musical_tuning;
self->auto_queue = auto_queue != FALSE;
@@ -32,15 +27,12 @@ bse_midi_decoder_new (gboolean auto_queue,
self->left_bytes = 0;
self->n_bytes = 0;
self->bytes = NULL;
-
return self;
}
-
void
bse_midi_decoder_destroy (BseMidiDecoder *self)
{
g_return_if_fail (self != NULL);
-
while (self->events)
{
BseMidiEvent *event = (BseMidiEvent*) sfi_ring_pop_head (&self->events);
@@ -49,15 +41,12 @@ bse_midi_decoder_destroy (BseMidiDecoder *self)
g_free (self->bytes);
g_free (self);
}
-
BseMidiEvent*
bse_midi_decoder_pop_event (BseMidiDecoder *self)
{
g_return_val_if_fail (self != NULL, NULL);
-
return (BseMidiEvent*) sfi_ring_pop_head (&self->events);
}
-
SfiRing*
bse_midi_decoder_pop_event_list (BseMidiDecoder *self)
{
@@ -67,7 +56,6 @@ bse_midi_decoder_pop_event_list (BseMidiDecoder *self)
self->events = NULL;
return events;
}
-
static inline const char*
decoder_state_to_string (BseMidiDecoderState state)
{
@@ -82,7 +70,6 @@ decoder_state_to_string (BseMidiDecoderState state)
}
return "unknown";
}
-
static void
midi_decoder_advance_state (BseMidiDecoder *self)
{
@@ -102,7 +89,6 @@ midi_decoder_advance_state (BseMidiDecoder *self)
self->state = next_state;
self->state_changed = TRUE;
}
-
static inline void
midi_decoder_next_state (BseMidiDecoder *self,
BseMidiDecoderState next_state)
@@ -111,13 +97,11 @@ midi_decoder_next_state (BseMidiDecoder *self,
while (self->state != next_state)
midi_decoder_advance_state (self);
}
-
typedef struct {
uint8 *bytes;
uint8 *bound;
uint64 delta_time;
} Data;
-
static inline void
midi_decoder_parse_data (BseMidiDecoder *self,
Data *d)
@@ -287,7 +271,6 @@ midi_decoder_parse_data (BseMidiDecoder *self,
break;
}
}
-
void
bse_midi_decoder_push_data (BseMidiDecoder *self,
uint n_bytes,
@@ -295,11 +278,9 @@ bse_midi_decoder_push_data (BseMidiDecoder *self,
uint64 usec_systime)
{
Data data;
-
g_return_if_fail (self != NULL);
if (n_bytes)
g_return_if_fail (bytes != NULL);
-
data.delta_time = bse_engine_tick_stamp_from_systime (usec_systime);
data.bytes = bytes;
data.bound = bytes + n_bytes;
@@ -308,7 +289,6 @@ bse_midi_decoder_push_data (BseMidiDecoder *self,
self->state_changed = FALSE;
midi_decoder_parse_data (self, &data);
}
-
if (self->auto_queue)
{
while (self->events)
@@ -320,7 +300,6 @@ bse_midi_decoder_push_data (BseMidiDecoder *self,
bse_midi_receiver_farm_process_events (data.delta_time);
}
}
-
void
bse_midi_decoder_push_smf_data (BseMidiDecoder *self,
uint n_bytes,
@@ -332,7 +311,6 @@ bse_midi_decoder_push_smf_data (BseMidiDecoder *self,
g_return_if_fail (self->smf_support == TRUE);
bse_midi_decoder_push_data (self, n_bytes, bytes, 0);
}
-
static inline gboolean
midi_decoder_extract_specific (BseMidiDecoder *self,
BseMidiEvent *event)
@@ -508,14 +486,12 @@ midi_decoder_extract_specific (BseMidiDecoder *self,
}
return TRUE;
}
-
static void
bse_midi_decoder_construct_event (BseMidiDecoder *self)
{
BseMidiEvent *event = bse_midi_alloc_event ();
g_return_if_fail (self->event_type >= 0x080);
g_return_if_fail (self->left_bytes == 0);
-
/* try to collapse multi packet sys-ex to normal sys-ex */
if (self->event_type == BSE_MIDI_MULTI_SYS_EX_START &&
self->n_bytes > 0 &&
diff --git a/bse/bsemididecoder.hh b/bse/bsemididecoder.hh
index 5a7ffb1..22e00fe 100644
--- a/bse/bsemididecoder.hh
+++ b/bse/bsemididecoder.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_DECODER_H__
#define __BSE_MIDI_DECODER_H__
-
#include <bse/bsemidievent.hh>
-
G_BEGIN_DECLS
-
-
/* --- BSE MIDI structs --- */
typedef enum {
BSE_MIDI_DECODER_ZERO = 0,
@@ -22,12 +18,10 @@ typedef enum {
struct _BseMidiDecoder
{
SfiRing *events; /* BseMidiEvent* */
-
/* configuration */
BseMusicalTuningType musical_tuning;
uint auto_queue : 1;
uint smf_support : 1;
-
/*< private >*/
uint state_changed : 1;
BseMidiDecoderState state;
@@ -40,8 +34,6 @@ struct _BseMidiDecoder
uint n_bytes;
uint8 *bytes;
};
-
-
/* --- API --- */
BseMidiDecoder* bse_midi_decoder_new (gboolean auto_queue,
gboolean smf_support,
@@ -56,7 +48,5 @@ void bse_midi_decoder_push_smf_data (BseMidiDecoder
uint8 *bytes);
BseMidiEvent* bse_midi_decoder_pop_event (BseMidiDecoder *self);
SfiRing* bse_midi_decoder_pop_event_list (BseMidiDecoder *self);
-
G_END_DECLS
-
#endif /* __BSE_MIDI_DECODER_H__ */
diff --git a/bse/bsemididevice-null.cc b/bse/bsemididevice-null.cc
index f12bdf7..c895ad3 100644
--- a/bse/bsemididevice-null.cc
+++ b/bse/bsemididevice-null.cc
@@ -1,24 +1,18 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemididevice-null.hh"
-
#include "bseserver.hh"
-
static SFI_MSG_TYPE_DEFINE (debug_midi, "midi", SFI_MSG_DEBUG, NULL);
#define MIDI_DEBUG(...) sfi_debug (debug_midi, __VA_ARGS__)
-
/* --- structs --- */
typedef struct
{
BseMidiHandle handle;
} NULLHandle;
-
-
/* --- functions --- */
static void
bse_midi_device_null_init (BseMidiDeviceNULL *null)
{
}
-
static SfiRing*
bse_midi_device_null_list_devices (BseDevice *device)
{
@@ -26,7 +20,6 @@ bse_midi_device_null_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_entry_new (device, g_strdup_printf ("default"), NULL));
return ring;
}
-
static BseErrorType
bse_midi_device_null_open (BseDevice *device,
gboolean require_readable,
@@ -36,35 +29,28 @@ bse_midi_device_null_open (BseDevice *device,
{
NULLHandle *null = g_new0 (NULLHandle, 1);
BseMidiHandle *handle = &null->handle;
-
/* setup request */
handle->readable = require_readable;
handle->writable = require_writable;
-
bse_device_set_opened (device, "null", handle->readable, handle->writable);
BSE_MIDI_DEVICE (device)->handle = handle;
MIDI_DEBUG ("NULL: opening MIDI readable=%d writable=%d: %s", require_readable, require_writable, bse_error_blurb (BSE_ERROR_NONE));
return BSE_ERROR_NONE;
}
-
static void
bse_midi_device_null_close (BseDevice *device)
{
NULLHandle *null = (NULLHandle*) BSE_MIDI_DEVICE (device)->handle;
BseMidiHandle *handle = &null->handle;
BSE_MIDI_DEVICE (device)->handle = NULL;
-
g_assert (handle->running_thread == FALSE);
/* midi_handle_abort_wait (handle); */
-
g_free (null);
}
-
static void
bse_midi_device_null_class_init (BseMidiDeviceNULLClass *klass)
{
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
device_class->list_devices = bse_midi_device_null_list_devices;
bse_device_class_setup (klass,
-1,
@@ -75,25 +61,20 @@ bse_midi_device_null_class_init (BseMidiDeviceNULLClass *klass)
device_class->open = bse_midi_device_null_open;
device_class->close = bse_midi_device_null_close;
}
-
BSE_BUILTIN_TYPE (BseMidiDeviceNULL)
{
GType type;
-
static const GTypeInfo type_info = {
sizeof (BseMidiDeviceNULLClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_device_null_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiDeviceNULL),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_device_null_init,
};
-
type = bse_type_register_static (BSE_TYPE_MIDI_DEVICE,
"BseMidiDeviceNULL",
"MIDI device implementation that does nothing",
diff --git a/bse/bsemididevice-null.hh b/bse/bsemididevice-null.hh
index 746124f..6f8ec4e 100644
--- a/bse/bsemididevice-null.hh
+++ b/bse/bsemididevice-null.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_DEVICE_NULL_H__
#define __BSE_MIDI_DEVICE_NULL_H__
-
#include <bse/bsemididevice.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_DEVICE_NULL (BSE_TYPE_ID (BseMidiDeviceNULL))
#define BSE_MIDI_DEVICE_NULL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_DEVICE_NULL, BseMidiDeviceNULL))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_DEVICE_NULL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_DEVICE_NULL))
#define BSE_IS_MIDI_DEVICE_NULL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_DEVICE_NULL))
#define BSE_MIDI_DEVICE_NULL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_DEVICE_NULL, BseMidiDeviceNULLClass))
-
/* --- BseMidiDeviceNULL object --- */
typedef struct _BseMidiDeviceNULL BseMidiDeviceNULL;
typedef struct _BseMidiDeviceNULLClass BseMidiDeviceNULLClass;
@@ -25,7 +21,5 @@ struct _BseMidiDeviceNULLClass
{
BseMidiDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_MIDI_DEVICE_NULL_H__ */
diff --git a/bse/bsemididevice-oss.cc b/bse/bsemididevice-oss.cc
index 4ec2252..c178d9c 100644
--- a/bse/bsemididevice-oss.cc
+++ b/bse/bsemididevice-oss.cc
@@ -5,11 +5,9 @@
#include "gslcommon.hh" // FIXME: remove
#include "bsesequencer.hh"
#include "topconfig.h"
-
#ifndef BSE_MIDI_DEVICE_CONF_OSS
BSE_DUMMY_TYPE (BseMidiDeviceOSS);
#else /* BSE_MIDI_DEVICE_CONF_OSS */
-
#if HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#elif HAVE_SOUNDCARD_H
@@ -22,35 +20,26 @@ BSE_DUMMY_TYPE (BseMidiDeviceOSS);
#include <errno.h>
#include <string.h>
#include <fcntl.h>
-
static SFI_MSG_TYPE_DEFINE (debug_midi, "midi", SFI_MSG_DEBUG, NULL);
#define MIDI_DEBUG(...) sfi_debug (debug_midi, __VA_ARGS__)
-
-
/* --- structs --- */
typedef struct
{
BseMidiHandle handle;
int fd;
} OSSHandle;
-
-
/* --- prototypes --- */
static gboolean oss_midi_io_handler (void *data,
uint n_pfds,
GPollFD *pfds);
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_midi_device_oss_init (BseMidiDeviceOSS *oss)
{
oss->device_name = g_strdup (BSE_MIDI_DEVICE_CONF_OSS);
}
-
static BseErrorType
check_device_usage (const char *name,
const char *check_mode)
@@ -71,7 +60,6 @@ check_device_usage (const char *name,
}
return error;
}
-
static SfiRing*
bse_midi_device_oss_list_devices (BseDevice *device)
{
@@ -108,7 +96,6 @@ bse_midi_device_oss_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_error_new (device, g_strdup_printf ("No devices found")));
return ring;
}
-
static BseErrorType
bse_midi_device_oss_open (BseDevice *device,
gboolean require_readable,
@@ -131,10 +118,8 @@ bse_midi_device_oss_open (BseDevice *device,
}
OSSHandle *oss = g_new0 (OSSHandle, 1);
BseMidiHandle *handle = &oss->handle;
-
/* setup request */
oss->fd = -1;
-
/* try open */
BseErrorType error;
int fd = -1;
@@ -159,7 +144,6 @@ bse_midi_device_oss_open (BseDevice *device,
}
else
error = bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
-
/* setup MIDI handle or shutdown */
if (!error)
{
@@ -177,37 +161,29 @@ bse_midi_device_oss_open (BseDevice *device,
g_free (oss);
}
MIDI_DEBUG ("OSS: opening \"%s\" readable=%d writable=%d: %s", dname, require_readable, require_writable, bse_error_blurb (error));
-
return error;
}
-
static void
bse_midi_device_oss_close (BseDevice *device)
{
OSSHandle *oss = (OSSHandle*) BSE_MIDI_DEVICE (device)->handle;
BseMidiHandle *handle = &oss->handle;
BSE_MIDI_DEVICE (device)->handle = NULL;
-
g_assert (handle->running_thread == FALSE);
/* midi_handle_abort_wait (handle); */
-
bse_sequencer_remove_io_watch (oss_midi_io_handler, oss);
(void) close (oss->fd);
g_free (oss);
}
-
static void
bse_midi_device_oss_finalize (GObject *object)
{
BseMidiDeviceOSS *mdev_oss = BSE_MIDI_DEVICE_OSS (object);
-
g_free (mdev_oss->device_name);
mdev_oss->device_name = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gboolean
oss_midi_io_handler (void *data, /* Sequencer Thread */
uint n_pfds,
@@ -219,30 +195,23 @@ oss_midi_io_handler (void *data, /* Sequencer Thread */
uint8 buffer[buf_size];
uint64 systime;
gssize l;
-
/* this should spawn its own thread someday */
g_assert (handle->running_thread == FALSE);
-
systime = sfi_time_system ();
do
l = read (oss->fd, buffer, buf_size);
while (l < 0 && errno == EINTR); /* don't mind signals */
-
if (l > 0)
bse_midi_decoder_push_data (handle->midi_decoder, l, buffer, systime);
return TRUE; /* keep alive */
}
-
static void
bse_midi_device_oss_class_init (BseMidiDeviceOSSClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_midi_device_oss_finalize;
-
device_class->list_devices = bse_midi_device_oss_list_devices;
bse_device_class_setup (klass,
BSE_RATING_DEFAULT,
@@ -255,25 +224,20 @@ bse_midi_device_oss_class_init (BseMidiDeviceOSSClass *klass)
device_class->open = bse_midi_device_oss_open;
device_class->close = bse_midi_device_oss_close;
}
-
BSE_BUILTIN_TYPE (BseMidiDeviceOSS)
{
GType midi_device_oss_type;
-
static const GTypeInfo midi_device_oss_info = {
sizeof (BseMidiDeviceOSSClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_device_oss_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiDeviceOSS),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_device_oss_init,
};
-
midi_device_oss_type = bse_type_register_static (BSE_TYPE_MIDI_DEVICE,
"BseMidiDeviceOSS",
"MIDI device implementation for OSS Lite /dev/midi*",
@@ -281,5 +245,4 @@ BSE_BUILTIN_TYPE (BseMidiDeviceOSS)
&midi_device_oss_info);
return midi_device_oss_type;
}
-
#endif /* BSE_MIDI_DEVICE_CONF_OSS */
diff --git a/bse/bsemididevice-oss.hh b/bse/bsemididevice-oss.hh
index c33c3c0..0899708 100644
--- a/bse/bsemididevice-oss.hh
+++ b/bse/bsemididevice-oss.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_DEVICE_OSS_H__
#define __BSE_MIDI_DEVICE_OSS_H__
-
#include <bse/bsemididevice.hh>
-
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_DEVICE_OSS (BSE_TYPE_ID (BseMidiDeviceOSS))
#define BSE_MIDI_DEVICE_OSS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_DEVICE_OSS, BseMidiDeviceOSS))
@@ -14,22 +10,17 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_DEVICE_OSS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_DEVICE_OSS))
#define BSE_IS_MIDI_DEVICE_OSS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_DEVICE_OSS))
#define BSE_MIDI_DEVICE_OSS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_DEVICE_OSS, BseMidiDeviceOSSClass))
-
-
/* --- BseMidiDeviceOSS object --- */
typedef struct _BseMidiDeviceOSS BseMidiDeviceOSS;
typedef struct _BseMidiDeviceOSSClass BseMidiDeviceOSSClass;
struct _BseMidiDeviceOSS
{
BseMidiDevice parent_object;
-
gchar *device_name;
};
struct _BseMidiDeviceOSSClass
{
BseMidiDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_MIDI_DEVICE_OSS_H__ */
diff --git a/bse/bsemididevice.cc b/bse/bsemididevice.cc
index 43b6ad8..1f64470 100644
--- a/bse/bsemididevice.cc
+++ b/bse/bsemididevice.cc
@@ -1,15 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemididevice.hh"
-
#include "bsemididecoder.hh"
-
#include <errno.h>
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_midi_device_init (BseMidiDevice *self)
@@ -17,12 +11,10 @@ bse_midi_device_init (BseMidiDevice *self)
self->midi_decoder = bse_midi_decoder_new (TRUE, FALSE, BSE_MUSICAL_TUNING_12_TET);
self->handle = NULL;
}
-
static void
bse_midi_device_dispose (GObject *object)
{
BseMidiDevice *self = BSE_MIDI_DEVICE (object);
-
if (BSE_DEVICE_OPEN (self))
{
g_warning ("%s: midi device still opened", G_STRLOC);
@@ -30,50 +22,39 @@ bse_midi_device_dispose (GObject *object)
}
if (self->handle)
g_warning (G_STRLOC ": midi device with stale midi handle");
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_midi_device_finalize (GObject *object)
{
BseMidiDevice *self = BSE_MIDI_DEVICE (object);
-
bse_midi_decoder_destroy (self->midi_decoder);
self->midi_decoder = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_midi_device_class_init (BseMidiDeviceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->dispose = bse_midi_device_dispose;
gobject_class->finalize = bse_midi_device_finalize;
}
-
BSE_BUILTIN_TYPE (BseMidiDevice)
{
static const GTypeInfo midi_device_info = {
sizeof (BseMidiDeviceClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_device_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiDevice),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_device_init,
};
-
return bse_type_register_abstract (BSE_TYPE_DEVICE,
"BseMidiDevice",
"MIDI device base type",
diff --git a/bse/bsemididevice.hh b/bse/bsemididevice.hh
index c5d0c7c..4c8f1bd 100644
--- a/bse/bsemididevice.hh
+++ b/bse/bsemididevice.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_DEVICE_H__
#define __BSE_MIDI_DEVICE_H__
-
#include <bse/bsedevice.hh>
#include <bse/bsemidievent.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_DEVICE (BSE_TYPE_ID (BseMidiDevice))
#define BSE_MIDI_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_DEVICE, BseMidiDevice))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_DEVICE))
#define BSE_IS_MIDI_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_DEVICE))
#define BSE_MIDI_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_DEVICE, BseMidiDeviceClass))
-
-
/* --- BseMidiDevice structs --- */
typedef struct _BseMidiHandle BseMidiHandle;
typedef struct _BseMidiDevice BseMidiDevice;
@@ -30,9 +25,7 @@ struct _BseMidiHandle /* this should be nuked, it's useless */
struct _BseMidiDevice
{
BseDevice parent_object;
-
BseMidiDecoder *midi_decoder;
-
/* operational handle */
BseMidiHandle *handle;
};
@@ -40,12 +33,7 @@ struct _BseMidiDeviceClass
{
BseDeviceClass parent_class;
};
-
-
/* --- internal utils --- */
void bse_midi_handle_init (BseMidiHandle *handle);
-
-
G_END_DECLS
-
#endif /* __BSE_MIDI_DEVICE_H__ */
diff --git a/bse/bsemidievent.cc b/bse/bsemidievent.cc
index cb016e7..9418cc4 100644
--- a/bse/bsemidievent.cc
+++ b/bse/bsemidievent.cc
@@ -1,18 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidievent.hh"
-
#include "bseglue.hh"
#include "gslcommon.hh"
#include "bseieee754.hh"
#include "bsecxxplugin.hh"
-
#include <errno.h>
-
-
/* --- variables --- */
static GEnumClass *bse_midi_signal_class = NULL;
-
-
/* --- functions --- */
/**
* @param type BseMidiSignalType type
@@ -50,32 +44,24 @@ bse_midi_signal_default (BseMidiSignalType type)
default: return 0.0;
}
}
-
const char*
bse_midi_signal_name (BseMidiSignalType signal)
{
GEnumValue *ev;
-
if (!bse_midi_signal_class)
bse_midi_signal_class = (GEnumClass*) g_type_class_ref (BSE_TYPE_MIDI_SIGNAL_TYPE);
-
ev = g_enum_get_value (bse_midi_signal_class, signal);
return ev ? ev->value_name : NULL;
}
-
const char*
bse_midi_signal_nick (BseMidiSignalType signal)
{
GEnumValue *ev;
-
if (!bse_midi_signal_class)
bse_midi_signal_class = (GEnumClass*) g_type_class_ref (BSE_TYPE_MIDI_SIGNAL_TYPE);
-
ev = g_enum_get_value (bse_midi_signal_class, signal);
return ev ? ev->value_nick : NULL;
}
-
-
/* --- BseMidiEvents --- */
/**
* @param event BseMidiEvent structure
@@ -88,7 +74,6 @@ bse_midi_free_event (BseMidiEvent *event)
{
g_return_if_fail (event != NULL);
g_return_if_fail (event->status != 0);
-
switch (event->status)
{
case BSE_MIDI_MULTI_SYS_EX_START:
@@ -118,27 +103,22 @@ bse_midi_free_event (BseMidiEvent *event)
}
sfi_delete_struct (BseMidiEvent, event);
}
-
BseMidiEvent*
bse_midi_copy_event (const BseMidiEvent *src)
{
BseMidiEvent *event;
-
g_return_val_if_fail (src != NULL, NULL);
-
event = bse_midi_alloc_event ();
*event = *src;
if (src->status == BSE_MIDI_SYS_EX)
event->data.sys_ex.bytes = (uint8*) g_memdup (src->data.sys_ex.bytes, src->data.sys_ex.n_bytes);
return event;
}
-
BseMidiEvent*
bse_midi_alloc_event (void)
{
return sfi_new_struct0 (BseMidiEvent, 1);
}
-
BseMidiEvent*
bse_midi_event_note_on (uint midi_channel,
uint64 delta_time,
@@ -146,41 +126,33 @@ bse_midi_event_note_on (uint midi_channel,
float velocity)
{
BseMidiEvent *event;
-
g_return_val_if_fail (frequency > 0 && frequency < BSE_MAX_FREQUENCY, NULL);
g_return_val_if_fail (velocity >= 0 && velocity <= 1, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
-
event = bse_midi_alloc_event ();
event->status = BSE_MIDI_NOTE_ON;
event->channel = midi_channel;
event->delta_time = delta_time;
event->data.note.frequency = frequency;
event->data.note.velocity = velocity;
-
return event;
}
-
BseMidiEvent*
bse_midi_event_note_off (uint midi_channel,
uint64 delta_time,
float frequency)
{
BseMidiEvent *event;
-
g_return_val_if_fail (frequency > 0 && frequency < BSE_MAX_FREQUENCY, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
-
event = bse_midi_alloc_event ();
event->status = BSE_MIDI_NOTE_OFF;
event->channel = midi_channel;
event->delta_time = delta_time;
event->data.note.frequency = frequency;
event->data.note.velocity = 0.0;
-
return event;
}
-
BseMidiEvent*
bse_midi_event_signal (uint midi_channel,
uint64 delta_time,
@@ -188,10 +160,8 @@ bse_midi_event_signal (uint midi_channel,
float value)
{
BseMidiEvent *event;
-
g_return_val_if_fail (value >= -1 && value <= +1, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
-
event = bse_midi_alloc_event ();
switch (signal_type)
{
@@ -236,7 +206,6 @@ bse_midi_event_signal (uint midi_channel,
event->delta_time = delta_time;
return event;
}
-
static void *
boxed_copy_midi_event (void *boxed)
{
@@ -244,14 +213,12 @@ boxed_copy_midi_event (void *boxed)
BseMidiEvent *dest = bse_midi_copy_event (src);
return dest;
}
-
static void
boxed_free_midi_event (void *boxed)
{
BseMidiEvent *event = (BseMidiEvent*) boxed;
bse_midi_free_event (event);
}
-
GType
bse_midi_event_get_type (void)
{
diff --git a/bse/bsemidievent.hh b/bse/bsemidievent.hh
index 08acd0f..4b8f932 100644
--- a/bse/bsemidievent.hh
+++ b/bse/bsemidievent.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_EVENT_H__
#define __BSE_MIDI_EVENT_H__
-
#include <bse/bseobject.hh>
-
G_BEGIN_DECLS
-
/* --- MIDI constants --- */
#define BSE_MIDI_MAX_CHANNELS (99)
-
-
/* --- MIDI event types --- */
#define BSE_MIDI_CHANNEL_VOICE_MESSAGE(s) ((s) < 0x0F0)
#define BSE_MIDI_SYSTEM_COMMON_MESSAGE(s) (((s) & 0x0F8) == 0x0F0)
@@ -67,8 +62,6 @@ typedef enum
/* BSE specific extra events */
BSE_MIDI_X_CONTINUOUS_CHANGE = 0x400
} BseMidiEventType;
-
-
/* --- BSE MIDI Event --- */
#define BSE_TYPE_MIDI_EVENT (bse_midi_event_get_type ())
typedef struct
@@ -118,8 +111,6 @@ typedef struct
guint zprefix;
} data;
} BseMidiEvent;
-
-
/* --- API --- */
GType bse_midi_event_get_type (void); /* boxed */
BseMidiEvent* bse_midi_alloc_event (void);
@@ -136,8 +127,6 @@ BseMidiEvent* bse_midi_event_signal (uint midi_channel,
uint64 delta_time,
BseMidiSignalType signal_type,
float value);
-
-
/* --- MIDI Signals --- */
#if 0
typeNOTdef enum /*< prefix=BSE_MIDI_SIGNAL >*/ /* FIXME: sync to bserecords.sfidl */
@@ -322,11 +311,8 @@ typeNOTdef enum /*< prefix=BSE_MIDI_SIGNAL >*/ /* FIXME: sync to bserecords.sfi
BSE_MIDI_SIGNAL_CONTROL_127 /*< nick=Control 127 Polyphonic Mode On ITrigger >*/
} BseMidiSignalType;
#endif
-
gfloat bse_midi_signal_default (BseMidiSignalType signal);
const gchar* bse_midi_signal_name (BseMidiSignalType signal);
const gchar* bse_midi_signal_nick (BseMidiSignalType signal);
-
G_END_DECLS
-
#endif /* __BSE_MIDI_EVENT_H__ */
diff --git a/bse/bsemidifile.cc b/bse/bsemidifile.cc
index 30da661..68ad497 100644
--- a/bse/bsemidifile.cc
+++ b/bse/bsemidifile.cc
@@ -9,15 +9,12 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
static SFI_MSG_TYPE_DEFINE (debug_midi_file, "midi-file", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_midi_file, __VA_ARGS__)
-
typedef struct {
uint32 type; /* four letter chunk identifier */
uint32 length; /* length of data to follow, big-endian */
} ChunkHeader;
-
typedef struct {
ChunkHeader chunk; /* 'MThd' */
/* data section */
@@ -25,8 +22,6 @@ typedef struct {
uint16 n_tracks; /* always 1 for single-track */
uint16 division; /* if 0x8000 is set => SMPTE, ticks-per-quarter-note otherwise */
} SMFHeader;
-
-
/* --- functions --- */
static uint
dummy_read (int fd,
@@ -43,7 +38,6 @@ dummy_read (int fd,
}
return total;
}
-
static BseErrorType
smf_read_header (int fd,
SMFHeader *header)
@@ -101,7 +95,6 @@ smf_read_header (int fd,
}
return BSE_ERROR_NONE;
}
-
static BseErrorType
smf_read_track (BseMidiFile *smf,
int fd,
@@ -141,7 +134,6 @@ smf_read_track (BseMidiFile *smf,
}
return BSE_ERROR_NONE;
}
-
BseMidiFile*
bse_midi_file_load (const char *file_name,
BseErrorType *error_p)
@@ -157,14 +149,12 @@ bse_midi_file_load (const char *file_name,
*error_p = gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
return NULL;
}
-
*error_p = smf_read_header (fd, &header);
if (*error_p)
{
close (fd);
return NULL;
}
-
smf = (BseMidiFile*) g_malloc0 (sizeof (BseMidiFile) + header.n_tracks * sizeof (smf->tracks[0]));
smf->musical_tuning = BSE_MUSICAL_TUNING_12_TET;
#if 0
@@ -214,7 +204,6 @@ bse_midi_file_load (const char *file_name,
*error_p = BSE_ERROR_NONE;
return smf;
}
-
void
bse_midi_file_free (BseMidiFile *smf)
{
@@ -226,7 +215,6 @@ bse_midi_file_free (BseMidiFile *smf)
g_free (smf->tracks[i].events);
g_free (smf);
}
-
void
bse_midi_file_add_part_events (BseMidiFile *smf,
uint nth_track,
@@ -313,7 +301,6 @@ bse_midi_file_add_part_events (BseMidiFile *smf,
}
}
}
-
void
bse_midi_file_setup_song (BseMidiFile *smf,
BseSong *song)
diff --git a/bse/bsemidifile.hh b/bse/bsemidifile.hh
index a5015b9..a7ef1fc 100644
--- a/bse/bsemidifile.hh
+++ b/bse/bsemidifile.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_FILE_H__
#define __BSE_MIDI_FILE_H__
-
#include <bse/bsemidievent.hh>
-
G_BEGIN_DECLS
-
typedef struct {
guint n_events;
BseMidiEvent **events;
@@ -21,7 +18,6 @@ typedef struct {
guint n_tracks;
BseMidiFileTrack tracks[1]; /* flexible array */
} BseMidiFile;
-
BseMidiFile* bse_midi_file_load (const gchar *file_name,
BseErrorType *error_p);
void bse_midi_file_free (BseMidiFile *smf);
@@ -31,7 +27,5 @@ void bse_midi_file_add_part_events (BseMidiFile *smf,
BseTrack *ptrack);
void bse_midi_file_setup_song (BseMidiFile *smf,
BseSong *song);
-
G_END_DECLS
-
#endif /* __BSE_MIDI_FILE_H__ */
diff --git a/bse/bsemidiinput.cc b/bse/bsemidiinput.cc
index 13d6d4a..29af387 100644
--- a/bse/bsemidiinput.cc
+++ b/bse/bsemidiinput.cc
@@ -1,21 +1,15 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidiinput.hh"
-
#include "bsecategories.hh"
#include "bsemidireceiver.hh"
#include "bsesnet.hh"
#include "bseengine.hh"
-
-
-
/* --- properties --- */
enum
{
PROP_0,
PROP_MIDI_CHANNEL,
};
-
-
/* --- prototypes --- */
static void bse_midi_input_init (BseMidiInput *self);
static void bse_midi_input_class_init (BseMidiInputClass *klass);
@@ -34,24 +28,18 @@ static void bse_midi_input_context_connect (BseSource *source,
uint instance_id,
BseTrans *trans);
static void bse_midi_input_update_modules (BseMidiInput *self);
-
-
/* --- variables --- */
static void *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseMidiInput)
{
static const GTypeInfo midi_input_info = {
sizeof (BseMidiInputClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_input_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiInput),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_input_init,
@@ -66,7 +54,6 @@ BSE_BUILTIN_TYPE (BseMidiInput)
bse_categories_register_stock_module (N_("/Input & Output/MIDI Voice Input"), type, mono_synth_pixstream);
return type;
}
-
static void
bse_midi_input_class_init (BseMidiInputClass *klass)
{
@@ -74,22 +61,17 @@ bse_midi_input_class_init (BseMidiInputClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
uint ochannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_midi_input_set_property;
gobject_class->get_property = bse_midi_input_get_property;
-
source_class->context_create = bse_midi_input_context_create;
source_class->context_connect = bse_midi_input_context_connect;
-
bse_object_class_add_param (object_class, "MIDI",
PROP_MIDI_CHANNEL,
sfi_pspec_int ("midi_channel", "MIDI Channel",
"Input MIDI channel, 0 uses network's default channel",
0, 0, BSE_MIDI_MAX_CHANNELS, 1,
SFI_PARAM_GUI SFI_PARAM_STORAGE ":scale:skip-default"));
-
ochannel_id = bse_source_class_add_ochannel (source_class, "frequency", _("Frequency"), _("Note Frequency"));
g_assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_FREQUENCY);
ochannel_id = bse_source_class_add_ochannel (source_class, "gate", _("Gate"), _("High if the note is currently being pressed"));
@@ -99,13 +81,11 @@ bse_midi_input_class_init (BseMidiInputClass *klass)
ochannel_id = bse_source_class_add_ochannel (source_class, "aftertouch", _("Aftertouch"), _("Velocity while the note is pressed"));
g_assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_AFTERTOUCH);
}
-
static void
bse_midi_input_init (BseMidiInput *self)
{
self->midi_channel = 0;
}
-
static void
bse_midi_input_set_property (GObject *object,
uint param_id,
@@ -113,7 +93,6 @@ bse_midi_input_set_property (GObject *object,
GParamSpec *pspec)
{
BseMidiInput *self = BSE_MIDI_INPUT (object);
-
switch (param_id)
{
case PROP_MIDI_CHANNEL:
@@ -125,7 +104,6 @@ bse_midi_input_set_property (GObject *object,
break;
}
}
-
static void
bse_midi_input_get_property (GObject *object,
uint param_id,
@@ -133,7 +111,6 @@ bse_midi_input_get_property (GObject *object,
GParamSpec *pspec)
{
BseMidiInput *self = BSE_MIDI_INPUT (object);
-
switch (param_id)
{
case PROP_MIDI_CHANNEL:
@@ -144,25 +121,21 @@ bse_midi_input_get_property (GObject *object,
break;
}
}
-
typedef struct {
BseMidiReceiver *midi_receiver;
uint midi_channel;
uint default_channel;
BseModule *mvoice_module;
} ModuleData;
-
static void
module_data_free (void *data)
{
ModuleData *mdata = (ModuleData*) data;
BseTrans *trans = bse_trans_open ();
-
bse_midi_receiver_discard_mono_voice (mdata->midi_receiver, mdata->midi_channel, mdata->mvoice_module, trans);
bse_trans_commit (trans);
g_free (mdata);
}
-
static void
bse_midi_input_context_create (BseSource *source,
uint context_handle,
@@ -173,7 +146,6 @@ bse_midi_input_context_create (BseSource *source,
BseModule *module = bse_module_new_virtual (BSE_MIDI_INPUT_N_OCHANNELS, mdata, module_data_free);
BseItem *parent = BSE_ITEM (self)->parent;
BseMidiContext mcontext = bse_snet_get_midi_context (BSE_SNET (parent), context_handle);
-
/* setup module data */
mdata->midi_receiver = mcontext.midi_receiver;
mdata->default_channel = mcontext.midi_channel;
@@ -181,17 +153,13 @@ bse_midi_input_context_create (BseSource *source,
mdata->mvoice_module = bse_midi_receiver_retrieve_mono_voice (mdata->midi_receiver,
mdata->midi_channel,
trans);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_omodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_midi_input_context_connect (BseSource *source,
uint context_handle,
@@ -199,17 +167,14 @@ bse_midi_input_context_connect (BseSource *source,
{
BseModule *module = bse_source_get_context_omodule (source, context_handle);
ModuleData *mdata = (ModuleData*) module->user_data;
-
/* connect module to mono control uplink */
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 0, module, 0));
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 1, module, 1));
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 2, module, 2));
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 3, module, 3));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_midi_input_update_modules (BseMidiInput *self)
{
@@ -218,28 +183,22 @@ bse_midi_input_update_modules (BseMidiInput *self)
BseSource *source = BSE_SOURCE (self);
BseTrans *trans = bse_trans_open ();
uint *cids, n, i;
-
/* forall contexts */
cids = bse_source_context_ids (source, &n);
-
/* reconnect modules */
for (i = 0; i < n; i++)
{
BseModule *module = bse_source_get_context_omodule (source, cids[i]);
ModuleData *mdata = (ModuleData*) module->user_data;
-
/* disconnect from old module */
bse_trans_add (trans, bse_job_disconnect (module, 0));
bse_trans_add (trans, bse_job_disconnect (module, 1));
bse_trans_add (trans, bse_job_disconnect (module, 2));
bse_trans_add (trans, bse_job_disconnect (module, 3));
-
/* discard old module */
bse_midi_receiver_discard_mono_voice (mdata->midi_receiver, mdata->midi_channel, mdata->mvoice_module, trans);
-
/* update midi channel */
mdata->midi_channel = self->midi_channel > 0 ? self->midi_channel : mdata->default_channel;
-
/* fetch new module */
mdata->mvoice_module = bse_midi_receiver_retrieve_mono_voice (mdata->midi_receiver,
mdata->midi_channel,
@@ -250,7 +209,6 @@ bse_midi_input_update_modules (BseMidiInput *self)
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 2, module, 2));
bse_trans_add (trans, bse_job_connect (mdata->mvoice_module, 3, module, 3));
}
-
/* commit and cleanup */
g_free (cids);
bse_trans_commit (trans);
diff --git a/bse/bsemidiinput.hh b/bse/bsemidiinput.hh
index 33a528d..6932af1 100644
--- a/bse/bsemidiinput.hh
+++ b/bse/bsemidiinput.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_INPUT_H__
#define __BSE_MIDI_INPUT_H__
-
#include <bse/bsesource.hh>
#include <bse/bsemidievent.hh>
-
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_INPUT (BSE_TYPE_ID (BseMidiInput))
#define BSE_MIDI_INPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_INPUT, BseMidiInput))
@@ -15,23 +11,18 @@ G_BEGIN_DECLS
#define BSE_IS_INPUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_INPUT))
#define BSE_IS_INPUT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_INPUT))
#define BSE_MIDI_INPUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_INPUT, BseMidiInputClassOut))
-
-
/* --- BseMidiInput source --- */
typedef struct _BseMidiInput BseMidiInput;
typedef struct _BseMidiInputClass BseMidiInputClass;
struct _BseMidiInput
{
BseSource parent_object;
-
guint midi_channel;
};
struct _BseMidiInputClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -41,8 +32,5 @@ enum
BSE_MIDI_INPUT_OCHANNEL_AFTERTOUCH,
BSE_MIDI_INPUT_N_OCHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_MIDI_INPUT_H__ */
diff --git a/bse/bsemidinotifier.cc b/bse/bsemidinotifier.cc
index 31edb9d..c4326e4 100644
--- a/bse/bsemidinotifier.cc
+++ b/bse/bsemidinotifier.cc
@@ -3,83 +3,66 @@
#include "bsemain.hh"
#include "gslcommon.hh"
#include "bsecxxplugin.hh"
-
-
/* --- prototypes --- */
static void bse_midi_notifier_class_init (BseMidiNotifierClass *klass);
static void bse_midi_notifier_init (BseMidiNotifier *self);
static void bse_midi_notifier_finalize (GObject *object);
-
/* --- variables --- */
static gpointer parent_class = NULL;
static guint signal_midi_event = 0;
static GQuark number_quarks[BSE_MIDI_MAX_CHANNELS] = { 0, };
static SfiRing *midi_notifier_list = NULL;
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseMidiNotifier)
{
static const GTypeInfo midi_notifier_info = {
sizeof (BseMidiNotifierClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_notifier_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiNotifier),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_notifier_init,
};
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BseMidiNotifier",
"MIDI Event Notifier",
__FILE__, __LINE__,
&midi_notifier_info);
}
-
static void
bse_midi_notifier_class_init (BseMidiNotifierClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
guint i;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_midi_notifier_finalize;
-
for (i = 0; i < BSE_MIDI_MAX_CHANNELS; i++)
{
gchar buffer[32];
-
g_snprintf (buffer, 32, "%u", i);
number_quarks[i] = g_quark_from_string (buffer);
}
-
signal_midi_event = bse_object_class_add_dsignal (object_class, "midi-event",
G_TYPE_NONE, 1,
BSE_TYPE_MIDI_CHANNEL_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
}
-
static void
bse_midi_notifier_init (BseMidiNotifier *self)
{
midi_notifier_list = sfi_ring_append (midi_notifier_list, self);
}
-
static void
bse_midi_notifier_finalize (GObject *object)
{
BseMidiNotifier *self = BSE_MIDI_NOTIFIER (object);
midi_notifier_list = sfi_ring_remove (midi_notifier_list, self);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
void
bse_midi_notifier_set_receiver (BseMidiNotifier *self,
BseMidiReceiver *midi_receiver)
@@ -94,7 +77,6 @@ bse_midi_notifier_set_receiver (BseMidiNotifier *self,
if (old)
bse_midi_receiver_unref (old);
}
-
static inline void
bse_midi_notifier_notify_event (BseMidiNotifier *self,
BseMidiEvent *event)
@@ -183,7 +165,6 @@ bse_midi_notifier_notify_event (BseMidiNotifier *self,
if (cev.event_type)
g_signal_emit (self, signal_midi_event, number_quarks[event->channel], &cev);
}
-
void
bse_midi_notifier_dispatch (BseMidiNotifier *self)
{
@@ -204,7 +185,6 @@ bse_midi_notifier_dispatch (BseMidiNotifier *self)
bse_midi_free_event (event);
}
}
-
static gboolean
midi_notifiers_need_dispatch (void)
{
@@ -217,7 +197,6 @@ midi_notifiers_need_dispatch (void)
}
return FALSE;
}
-
static gboolean
midi_notifiers_source_prepare (GSource *source,
gint *timeout_p)
@@ -227,7 +206,6 @@ midi_notifiers_source_prepare (GSource *source,
BSE_THREADS_LEAVE ();
return need_dispatch;
}
-
static gboolean
midi_notifiers_source_check (GSource *source)
{
@@ -236,7 +214,6 @@ midi_notifiers_source_check (GSource *source)
BSE_THREADS_LEAVE ();
return need_dispatch;
}
-
static gboolean
midi_notifiers_source_dispatch (GSource *source,
GSourceFunc callback,
@@ -253,7 +230,6 @@ midi_notifiers_source_dispatch (GSource *source,
BSE_THREADS_LEAVE ();
return TRUE;
}
-
void
bse_midi_notifiers_attach_source (void)
{
@@ -266,7 +242,6 @@ bse_midi_notifiers_attach_source (void)
g_source_set_priority (source, BSE_PRIORITY_NORMAL);
g_source_attach (source, bse_main_context);
}
-
void
bse_midi_notifiers_wakeup (void)
{
diff --git a/bse/bsemidinotifier.hh b/bse/bsemidinotifier.hh
index 7f26d8c..593fe8b 100644
--- a/bse/bsemidinotifier.hh
+++ b/bse/bsemidinotifier.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_NOTIFIER_H__
#define __BSE_MIDI_NOTIFIER_H__
-
#include <bse/bseitem.hh>
#include <bse/bsemidireceiver.hh>
-
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_NOTIFIER (BSE_TYPE_ID (BseMidiNotifier))
#define BSE_MIDI_NOTIFIER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_NOTIFIER, BseMidiNotifier))
@@ -15,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_NOTIFIER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_NOTIFIER))
#define BSE_IS_MIDI_NOTIFIER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_NOTIFIER))
#define BSE_MIDI_NOTIFIER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_NOTIFIER, BseMidiNotifierClass))
-
-
/* --- BseMidiNotifier structs --- */
struct _BseMidiNotifier
{
@@ -26,19 +20,14 @@ struct _BseMidiNotifier
struct _BseMidiNotifierClass
{
BseItemClass parent_class;
-
void (*midi_event) (BseMidiNotifier *self,
BseMidiEvent *event);
};
-
-
/* --- prototypes --- */
void bse_midi_notifier_set_receiver (BseMidiNotifier *self,
BseMidiReceiver *midi_receiver);
void bse_midi_notifier_dispatch (BseMidiNotifier *self);
void bse_midi_notifiers_attach_source (void);
void bse_midi_notifiers_wakeup (void);
-
G_END_DECLS
-
#endif /* __BSE_MIDI_NOTIFIER_H__ */
diff --git a/bse/bsemidinotifier.proc b/bse/bsemidinotifier.proc
index 1ade4cc..4b8667e 100644
--- a/bse/bsemidinotifier.proc
+++ b/bse/bsemidinotifier.proc
@@ -3,11 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bsemidinotifier.hh>
#include <sys/time.h>
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseMidiNotifier, current-time) {
HELP = "Test";
IN = bse_param_spec_object ("midi_notifier", "Midi Notifier", NULL,
@@ -23,17 +20,13 @@ BODY (BseProcedureClass *proc,
BseMidiNotifier *self = (BseMidiNotifier*) bse_value_get_object (in_values++);
struct timeval tv;
guint64 stamp;
-
/* check parameters */
if (!BSE_IS_MIDI_NOTIFIER (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
gettimeofday (&tv, NULL);
stamp = tv.tv_sec;
stamp = stamp * 1000000 + tv.tv_usec;
-
/* set output parameters */
sfi_value_set_int (out_values++, stamp / 1000);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsemidireceiver.cc b/bse/bsemidireceiver.cc
index 7c62103..3c3c90d 100644
--- a/bse/bsemidireceiver.cc
+++ b/bse/bsemidireceiver.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidireceiver.hh"
-
#include "bsemain.hh"
#include "gslcommon.hh"
#include "bseengine.hh"
@@ -11,23 +10,18 @@
#include <sfi/gbsearcharray.hh>
#include <map>
#include <set>
-
namespace {
using namespace Bse;
using namespace Birnet;
using namespace std;
-
static SFI_MSG_TYPE_DEFINE (debug_midi_receiver, "midi-receiver", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_midi_receiver, __VA_ARGS__)
static SFI_MSG_TYPE_DEFINE (debug_midi_events, "midi-events", SFI_MSG_DEBUG, NULL);
#define DEBUG_EVENTS(...) sfi_debug (debug_midi_events, __VA_ARGS__)
-
/* --- variables --- */
static BirnetMutex global_midi_mutex = { 0, };
#define BSE_MIDI_RECEIVER_LOCK() GSL_SPIN_LOCK (&global_midi_mutex)
#define BSE_MIDI_RECEIVER_UNLOCK() GSL_SPIN_UNLOCK (&global_midi_mutex)
-
-
/********************************************************************************
*
* Busy/idle states of a voice input and correspondance with table entries:
@@ -68,8 +62,6 @@ static BirnetMutex global_midi_mutex = { 0, };
* *only* disconnect upon Done=1. Thus a Done=const(0) mesh can block voices
* forever.
*******************************************************************************/
-
-
/* --- midi controls --- */
struct ControlKey {
guint midi_channel;
@@ -215,14 +207,10 @@ struct ControlValue {
g_return_if_fail (cmodules == NULL);
}
};
-
-
/* --- voice prototypes --- */
typedef struct VoiceSwitch VoiceSwitch;
typedef struct VoiceInput VoiceInput;
typedef std::map<float,VoiceInput*> VoiceInputTable;
-
-
/* --- midi channel --- */
struct MidiChannel {
guint midi_channel;
@@ -283,8 +271,6 @@ midi_channel_compare (const guint midi_channel,
{
return midi_channel < c2->midi_channel ? -1 : midi_channel > c2->midi_channel;
}
-
-
/* --- midi receiver --- */
struct MidiReceiver
{
@@ -430,8 +416,6 @@ public:
cv->remove_handler (handler_func, handler_data, module);
}
};
-
-
/* --- MIDI Control Module --- */
typedef struct
{
@@ -440,19 +424,16 @@ typedef struct
BseMidiSignalType signals[BSE_MIDI_CONTROL_MODULE_N_CHANNELS];
guint ref_count;
} MidiCModuleData;
-
static void
midi_control_module_process_U (BseModule *module, /* vswitch->smodule */
guint n_values)
{
MidiCModuleData *cdata = (MidiCModuleData *) module->user_data;
guint i;
-
for (i = 0; i < BSE_MODULE_N_OSTREAMS (module); i++)
if (module->ostreams[i].connected)
module->ostreams[i].values = bse_engine_const_values (cdata->values[i]);
}
-
static BseModule*
create_midi_control_module_L (MidiReceiver *self,
guint midi_channel,
@@ -471,9 +452,7 @@ create_midi_control_module_L (MidiReceiver *self,
MidiCModuleData *cdata;
BseModule *module;
guint i;
-
g_return_val_if_fail (signals != NULL, NULL);
-
cdata = g_new0 (MidiCModuleData, 1);
cdata->midi_channel = midi_channel;
for (i = 0; i < BSE_MIDI_CONTROL_MODULE_N_CHANNELS; i++)
@@ -483,15 +462,12 @@ create_midi_control_module_L (MidiReceiver *self,
}
cdata->ref_count = 1;
module = bse_module_new (&midi_cmodule_class, cdata);
-
return module;
}
-
typedef struct {
BseMidiSignalType signal;
gfloat value;
} MidiCModuleAccessData;
-
static void
midi_control_module_access_U (BseModule *module,
gpointer data)
@@ -499,12 +475,10 @@ midi_control_module_access_U (BseModule *module,
MidiCModuleData *cdata = (MidiCModuleData *) module->user_data;
MidiCModuleAccessData *adata = (MidiCModuleAccessData *) data;
guint i;
-
for (i = 0; i < BSE_MIDI_CONTROL_MODULE_N_CHANNELS; i++)
if (cdata->signals[i] == adata->signal)
cdata->values[i] = adata->value;
}
-
static void
change_midi_control_modules_L (GSList *modules,
guint64 tick_stamp,
@@ -514,7 +488,6 @@ change_midi_control_modules_L (GSList *modules,
{
MidiCModuleAccessData *adata;
GSList *slist = modules;
-
if (!modules)
return;
adata = g_new0 (MidiCModuleAccessData, 1);
@@ -527,7 +500,6 @@ change_midi_control_modules_L (GSList *modules,
adata,
slist->next ? NULL : g_free));
}
-
static gboolean
match_midi_control_module_L (BseModule *cmodule,
guint midi_channel,
@@ -536,15 +508,11 @@ match_midi_control_module_L (BseModule *cmodule,
MidiCModuleData *cdata = (MidiCModuleData *) cmodule->user_data;
gboolean match = TRUE;
guint i;
-
for (i = 0; i < BSE_MIDI_CONTROL_MODULE_N_CHANNELS; i++)
match &= cdata->signals[i] == signals[i];
match &= cdata->midi_channel == midi_channel;
-
return match;
}
-
-
/* --- VoiceInput module --- */
typedef enum {
VOICE_ON = 1,
@@ -568,7 +536,6 @@ voice_change_to_string (VoiceChangeType t)
}
return "<invalid>";
}
-
typedef enum {
VSTATE_IDLE,
VSTATE_BUSY, /* got note-on, waiting for note-off */
@@ -585,7 +552,6 @@ voice_state_to_string (VoiceState s)
}
return "<invalid>";
}
-
struct VoiceInput
{
/* module state */
@@ -603,13 +569,11 @@ struct VoiceInput
VoiceInput *next;
VoiceInputTable::iterator iter;
};
-
static void
voice_input_module_process_U (BseModule *module,
guint n_values)
{
VoiceInput *vinput = (VoiceInput*) module->user_data;
-
if (BSE_MODULE_OSTREAM (module, 0).connected)
BSE_MODULE_OSTREAM (module, 0).values = bse_engine_const_values (vinput->freq_value);
if (BSE_MODULE_OSTREAM (module, 1).connected)
@@ -619,13 +583,11 @@ voice_input_module_process_U (BseModule *module,
if (BSE_MODULE_OSTREAM (module, 3).connected)
BSE_MODULE_OSTREAM (module, 3).values = bse_engine_const_values (vinput->aftertouch);
}
-
typedef struct {
VoiceChangeType vtype;
gfloat freq_value;
gfloat velocity;
} VoiceInputData;
-
static void
voice_input_module_reset_U (BseModule *module)
{
@@ -635,7 +597,6 @@ voice_input_module_reset_U (BseModule *module)
vinput->velocity = 0.5;
vinput->aftertouch = 0.5;
}
-
static void
voice_input_remove_from_table_L (VoiceInput *vinput) /* UserThread */
{
@@ -658,7 +619,6 @@ voice_input_remove_from_table_L (VoiceInput *vinput) /* UserThread */
g_assert_not_reached ();
}
}
-
static void
voice_input_enter_sustain_U (gpointer data) /* UserThread */
{
@@ -668,7 +628,6 @@ voice_input_enter_sustain_U (gpointer data) /* UserThread */
vinput->queue_state = VSTATE_SUSTAINED;
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
static void
voice_input_enter_idle_U (gpointer data) /* UserThread */
{
@@ -678,14 +637,12 @@ voice_input_enter_idle_U (gpointer data) /* UserThread */
vinput->queue_state = VSTATE_IDLE;
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
static void
voice_input_module_access_U (BseModule *module,
gpointer data)
{
VoiceInput *vinput = (VoiceInput*) module->user_data;
VoiceInputData *mdata = (VoiceInputData *) data;
-
DEBUG ("Synth<%p:%08llx>: ProcessEvent=%s Freq=%.2fHz",
vinput, bse_module_tick_stamp (module),
voice_change_to_string (mdata->vtype),
@@ -731,7 +688,6 @@ voice_input_module_access_U (BseModule *module,
break;
}
}
-
static void
change_voice_input_L (VoiceInput *vinput,
guint64 tick_stamp,
@@ -784,13 +740,11 @@ change_voice_input_L (VoiceInput *vinput,
mdata.velocity = velocity;
bse_trans_add (trans, bse_job_flow_access (vinput->fmodule, tick_stamp, voice_input_module_access_U, g_memdup (&mdata, sizeof (mdata)), g_free));
vinput->tick_stamp = tick_stamp;
-
DEBUG ("Synth<%p:%08llx>: QueueEvent=%s Freq=%.2fHz",
vinput, tick_stamp,
voice_change_to_string (vtype),
BSE_FREQ_FROM_VALUE (freq_value));
}
-
static void
voice_input_module_free_U (gpointer data,
const BseModuleClass *klass)
@@ -799,7 +753,6 @@ voice_input_module_free_U (gpointer data,
g_assert (vinput->next == NULL);
delete vinput;
}
-
static VoiceInput*
create_voice_input_L (VoiceInputTable *table,
gboolean ismono,
@@ -816,7 +769,6 @@ create_voice_input_L (VoiceInputTable *table,
BSE_COST_CHEAP
};
VoiceInput *vinput = new VoiceInput;
-
vinput->fmodule = bse_module_new (&mono_synth_module_class, vinput);
vinput->freq_value = 0;
vinput->gate = 0;
@@ -830,22 +782,17 @@ create_voice_input_L (VoiceInputTable *table,
vinput->next = NULL;
vinput->iter = table->end();
bse_trans_add (trans, bse_job_integrate (vinput->fmodule));
-
return vinput;
}
-
static void
destroy_voice_input_L (VoiceInput *vinput,
BseTrans *trans)
{
g_return_if_fail (vinput->ref_count == 0);
-
if (vinput->table && vinput->iter != vinput->table->end())
voice_input_remove_from_table_L (vinput);
bse_trans_add (trans, bse_job_boundary_discard (vinput->fmodule));
}
-
-
/* --- VoiceSwitch module --- */
struct VoiceSwitch
{
@@ -858,7 +805,6 @@ struct VoiceSwitch
BseModule *smodule; /* input module (switches and suspends) */
BseModule *vmodule; /* output module (virtual) */
};
-
static void
voice_switch_module_reuse_U (gpointer data) /* UserThread */
{
@@ -867,19 +813,16 @@ voice_switch_module_reuse_U (gpointer data) /* UserThread */
vswitch->disconnected = TRUE; /* reuse possible */
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
static void
voice_switch_module_process_U (BseModule *module,
guint n_values)
{
VoiceSwitch *vswitch = (VoiceSwitch*) module->user_data;
guint i;
-
/* dumb pass-through task */
for (i = 0; i < BSE_MODULE_N_OSTREAMS (module); i++)
if (BSE_MODULE_OSTREAM (module, i).connected)
BSE_MODULE_OSTREAM (module, i).values = (gfloat*) BSE_MODULE_IBUFFER (module, i);
-
/* check Done state on last stream */
if (BSE_MODULE_IBUFFER (module, BSE_MODULE_N_ISTREAMS (module) - 1)[n_values - 1] >= 1.0)
{
@@ -897,7 +840,6 @@ voice_switch_module_process_U (BseModule *module,
bse_engine_add_user_callback (vswitch, voice_switch_module_reuse_U);
}
}
-
static void
voice_switch_module_boundary_check_U (BseModule *module,
gpointer data)
@@ -914,7 +856,6 @@ voice_switch_module_boundary_check_U (BseModule *module,
vswitch->disconnected = FALSE; /* reset hint */
}
}
-
static void
activate_voice_switch_L (VoiceSwitch *vswitch,
guint64 tick_stamp,
@@ -927,7 +868,6 @@ activate_voice_switch_L (VoiceSwitch *vswitch,
bse_trans_add (trans, bse_job_resume_at (vswitch->smodule, tick_stamp));
vswitch->disconnected = FALSE; /* reset hint ahead of time */
}
-
static void
voice_switch_module_free_U (gpointer data,
const BseModuleClass *klass)
@@ -936,7 +876,6 @@ voice_switch_module_free_U (gpointer data,
g_free (vswitch->vinputs);
g_free (vswitch);
}
-
static VoiceSwitch*
create_voice_switch_module_L (BseTrans *trans)
{
@@ -951,7 +890,6 @@ create_voice_switch_module_L (BseTrans *trans)
BSE_COST_CHEAP
};
VoiceSwitch *vswitch = g_new0 (VoiceSwitch, 1);
-
vswitch->disconnected = TRUE;
vswitch->ref_count = 1;
vswitch->smodule = bse_module_new (&switch_module_class, vswitch);
@@ -959,16 +897,13 @@ create_voice_switch_module_L (BseTrans *trans)
bse_trans_add (trans, bse_job_integrate (vswitch->smodule));
bse_trans_add (trans, bse_job_integrate (vswitch->vmodule));
bse_trans_add (trans, bse_job_suspend_now (vswitch->smodule));
-
return vswitch;
}
-
static inline gboolean
check_voice_switch_available_L (VoiceSwitch *vswitch)
{
return vswitch->disconnected;
}
-
static void
voice_switch_module_commit_accessor_U (BseModule *module,
gpointer data)
@@ -976,16 +911,13 @@ voice_switch_module_commit_accessor_U (BseModule *module,
BseTrans *trans = (BseTrans*) data;
bse_trans_commit (trans);
}
-
static void
destroy_voice_switch_L (VoiceSwitch *vswitch,
BseTrans *trans)
{
BseTrans *tmp_trans;
-
g_return_if_fail (vswitch->ref_count == 0);
g_return_if_fail (vswitch->n_vinputs == 0);
-
tmp_trans = bse_trans_open ();
bse_trans_add (tmp_trans, bse_job_boundary_discard (vswitch->smodule));
bse_trans_add (tmp_trans, bse_job_boundary_discard (vswitch->vmodule));
@@ -997,8 +929,6 @@ destroy_voice_switch_L (VoiceSwitch *vswitch,
*/
bse_trans_add (trans, bse_job_access (vswitch->smodule, voice_switch_module_commit_accessor_U, tmp_trans, NULL));
}
-
-
/* --- MidiChannel --- */
static inline gboolean
check_voice_input_improvement_L (VoiceInput *vinput1, /* vinput1 better than vinput2? */
@@ -1012,7 +942,6 @@ check_voice_input_improvement_L (VoiceInput *vinput1, /* vinput1 better than vin
return vinput2->queue_state == VSTATE_IDLE ? FALSE : TRUE;
return FALSE; /* vinput1->queue_state == VSTATE_BUSY && vinput1->queue_state != vinput2->queue_state */
}
-
void
MidiChannel::no_poly_voice (const gchar *event_name,
gfloat freq)
@@ -1027,7 +956,6 @@ MidiChannel::no_poly_voice (const gchar *event_name,
sfi_diag ("MidiChannel(%u): no voice available for %s (%fHz)",
mchannel->midi_channel, event_name, freq);
}
-
void
MidiChannel::start_note (guint64 tick_stamp,
gfloat freq,
@@ -1038,16 +966,12 @@ MidiChannel::start_note (guint64 tick_stamp,
gfloat freq_val = BSE_VALUE_FROM_FREQ (freq);
VoiceSwitch *vswitch, *override_candidate = NULL;
guint i;
-
g_return_if_fail (freq > 0);
-
/* adjust channel global mono synth */
if (mchannel->vinput)
change_voice_input_L (mchannel->vinput, tick_stamp, VOICE_ON, freq_val, velocity, trans);
-
if (!mchannel->poly_enabled)
return;
-
/* figure voice from event */
vswitch = NULL; // voice numbers on events not currently supported
/* find free poly voice */
@@ -1065,7 +989,6 @@ MidiChannel::start_note (guint64 tick_stamp,
/* grab voice to override */
if (!vswitch)
; // FIXME: voice = override_candidate;
-
if (vswitch && vswitch->n_vinputs)
{
/* start note */
@@ -1081,7 +1004,6 @@ MidiChannel::start_note (guint64 tick_stamp,
else
no_poly_voice ("note-on", freq);
}
-
void
MidiChannel::adjust_note (guint64 tick_stamp,
gfloat freq,
@@ -1094,28 +1016,22 @@ MidiChannel::adjust_note (guint64 tick_stamp,
VoiceChangeType vctype = etype == BSE_MIDI_KEY_PRESSURE ? VOICE_PRESSURE : (sustain_note ? VOICE_SUSTAIN : VOICE_OFF);
gfloat freq_val = BSE_VALUE_FROM_FREQ (freq);
VoiceInput *vinput = NULL;
-
g_return_if_fail (freq > 0 && velocity >= 0);
-
/* adjust channel global mono synth */
if (mchannel->vinput)
change_voice_input_L (mchannel->vinput, tick_stamp, vctype, freq_val, velocity, trans);
-
if (!mchannel->poly_enabled)
return;
-
/* find corresponding vinput */
vinput = mchannel->voice_input_table[freq_val];
while (vinput && vinput->queue_state != VSTATE_BUSY)
vinput = vinput->next;
-
/* adjust note */
if (vinput)
change_voice_input_L (vinput, tick_stamp, vctype, freq_val, velocity, trans);
else
no_poly_voice (etype == BSE_MIDI_NOTE_OFF ? "note-off" : "velocity", freq);
}
-
void
MidiChannel::kill_notes (guint64 tick_stamp,
gboolean sustained_only,
@@ -1123,13 +1039,11 @@ MidiChannel::kill_notes (guint64 tick_stamp,
{
MidiChannel *mchannel = this;
guint i, j;
-
/* adjust channel global voice inputs */
if (mchannel->vinput && sustained_only && mchannel->vinput->queue_state == VSTATE_SUSTAINED)
change_voice_input_L (mchannel->vinput, tick_stamp, VOICE_KILL_SUSTAIN, 0, 0, trans);
else if (mchannel->vinput && !sustained_only && mchannel->vinput->queue_state != VSTATE_IDLE)
change_voice_input_L (mchannel->vinput, tick_stamp, VOICE_KILL, 0, 0, trans);
-
/* adjust poly voice inputs */
for (i = 0; i < mchannel->n_voices; i++)
{
@@ -1142,7 +1056,6 @@ MidiChannel::kill_notes (guint64 tick_stamp,
change_voice_input_L (vswitch->vinputs[j], tick_stamp, VOICE_KILL, 0, 0, trans);
}
}
-
void
MidiChannel::debug_notes (guint64 tick_stamp,
BseTrans *trans)
@@ -1162,39 +1075,26 @@ MidiChannel::debug_notes (guint64 tick_stamp,
BSE_FREQ_FROM_VALUE (vswitch->vinputs[j]->freq_value));
}
}
-
} // namespace anon
-
-
/* --- BseMidiReceiver C API --- */
extern "C" {
-
struct _BseMidiReceiver : public MidiReceiver {
explicit _BseMidiReceiver () :
MidiReceiver () {}
};
-
-
/* --- prototypes --- */
static gint midi_receiver_process_event_L (BseMidiReceiver *self,
guint64 max_tick_stamp);
-
-
/* --- variables --- */
static vector<BseMidiReceiver*> farm_residents;
-
-
/* --- function --- */
void
_bse_midi_init (void)
{
static gboolean initialized = FALSE;
-
g_assert (initialized++ == FALSE);
-
sfi_mutex_init (&global_midi_mutex);
}
-
static gint
events_cmp (gconstpointer a,
gconstpointer b,
@@ -1202,32 +1102,26 @@ events_cmp (gconstpointer a,
{
const BseMidiEvent *e1 = (const BseMidiEvent *) a;
const BseMidiEvent *e2 = (const BseMidiEvent *) b;
-
return e1->delta_time < e2->delta_time ? -1 : e1->delta_time != e2->delta_time;
}
-
void
bse_midi_receiver_enter_farm (BseMidiReceiver *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (find (farm_residents.begin(), farm_residents.end(), self) == farm_residents.end());
-
BSE_MIDI_RECEIVER_LOCK ();
farm_residents.push_back (self);
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_farm_distribute_event (BseMidiEvent *event)
{
g_return_if_fail (event != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
for (vector<BseMidiReceiver*>::iterator it = farm_residents.begin(); it != farm_residents.end(); it++)
(*it)->events = sfi_ring_insert_sorted ((*it)->events, bse_midi_copy_event (event), events_cmp, NULL);
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_farm_process_events (guint64 max_tick_stamp)
{
@@ -1242,38 +1136,31 @@ bse_midi_receiver_farm_process_events (guint64 max_tick_stamp)
}
while (seen_event);
}
-
void
bse_midi_receiver_leave_farm (BseMidiReceiver *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (find (farm_residents.begin(), farm_residents.end(), self) != farm_residents.end());
-
BSE_MIDI_RECEIVER_LOCK ();
farm_residents.erase (find (farm_residents.begin(), farm_residents.end(), self));
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_push_event (BseMidiReceiver *self,
BseMidiEvent *event)
{
g_return_if_fail (self != NULL);
g_return_if_fail (event != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
self->events = sfi_ring_insert_sorted (self->events, event, events_cmp, NULL);
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_process_events (BseMidiReceiver *self,
guint64 max_tick_stamp)
{
gboolean seen_event;
-
g_return_if_fail (self != NULL);
-
do
{
BSE_MIDI_RECEIVER_LOCK ();
@@ -1282,46 +1169,35 @@ bse_midi_receiver_process_events (BseMidiReceiver *self,
}
while (seen_event);
}
-
-
BseMidiReceiver*
bse_midi_receiver_new (const gchar *receiver_name) // FIXME
{
BseMidiReceiver *self;
-
self = new BseMidiReceiver ();
-
return self;
}
-
BseMidiReceiver*
bse_midi_receiver_ref (BseMidiReceiver *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count > 0, NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
self->ref_count++;
BSE_MIDI_RECEIVER_UNLOCK ();
-
return self;
}
-
void
bse_midi_receiver_unref (BseMidiReceiver *self)
{
gboolean need_destroy, leave_farm;
-
g_return_if_fail (self != NULL);
g_return_if_fail (self->ref_count > 0);
-
BSE_MIDI_RECEIVER_LOCK ();
self->ref_count--;
need_destroy = self->ref_count == 0;
leave_farm = need_destroy && find (farm_residents.begin(),
farm_residents.end(), self) != farm_residents.end();
BSE_MIDI_RECEIVER_UNLOCK ();
-
if (need_destroy)
{
if (leave_farm)
@@ -1329,15 +1205,12 @@ bse_midi_receiver_unref (BseMidiReceiver *self)
delete self;
}
}
-
void
bse_midi_receiver_set_notifier (BseMidiReceiver *self,
BseMidiNotifier *notifier)
{
BseMidiNotifier *old_notifier;
-
g_return_if_fail (self != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
old_notifier = self->notifier;
self->notifier = notifier;
@@ -1353,29 +1226,23 @@ bse_midi_receiver_set_notifier (BseMidiReceiver *self,
}
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
gboolean
bse_midi_receiver_has_notify_events (BseMidiReceiver *self)
{
/* prolly don't need a lock */
return self->notifier && self->notifier_events;
}
-
SfiRing*
bse_midi_receiver_fetch_notify_events (BseMidiReceiver *self)
{
SfiRing *ring;
-
g_return_val_if_fail (self != NULL, NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
ring = self->notifier_events;
self->notifier_events = NULL;
BSE_MIDI_RECEIVER_UNLOCK ();
-
return ring;
}
-
BseModule*
bse_midi_receiver_retrieve_control_module (BseMidiReceiver *self,
guint midi_channel,
@@ -1384,11 +1251,9 @@ bse_midi_receiver_retrieve_control_module (BseMidiReceiver *self,
{
BseModule *cmodule;
guint i;
-
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
g_return_val_if_fail (signals != NULL, NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
for (i = 0; i < self->n_cmodules; i++)
{
@@ -1416,17 +1281,14 @@ bse_midi_receiver_retrieve_control_module (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
return cmodule;
}
-
void
bse_midi_receiver_discard_control_module (BseMidiReceiver *self,
BseModule *module,
BseTrans *trans)
{
guint i;
-
g_return_if_fail (self != NULL);
g_return_if_fail (module != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
for (i = 0; i < self->n_cmodules; i++)
{
@@ -1458,7 +1320,6 @@ bse_midi_receiver_discard_control_module (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
g_warning ("no such control module: %p", module);
}
-
gboolean
bse_midi_receiver_add_control_handler (BseMidiReceiver *self,
guint midi_channel,
@@ -1471,13 +1332,11 @@ bse_midi_receiver_add_control_handler (BseMidiReceiver *self,
g_return_val_if_fail (midi_channel > 0, FALSE);
g_return_val_if_fail (handler_func != NULL, FALSE);
g_return_val_if_fail (module != NULL, FALSE);
-
BSE_MIDI_RECEIVER_LOCK ();
gboolean has_data = self->add_control_handler (midi_channel, signal_type, handler_func, handler_data, module);
BSE_MIDI_RECEIVER_UNLOCK ();
return has_data;
}
-
void
bse_midi_receiver_set_control_handler_data (BseMidiReceiver *self,
guint midi_channel,
@@ -1490,12 +1349,10 @@ bse_midi_receiver_set_control_handler_data (BseMidiReceiver *self,
g_return_if_fail (self != NULL);
g_return_if_fail (midi_channel > 0);
g_return_if_fail (handler_func != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
self->set_control_handler_data (midi_channel, signal_type, handler_func, handler_data, extra_data, extra_free);
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_remove_control_handler (BseMidiReceiver *self,
guint midi_channel,
@@ -1508,48 +1365,40 @@ bse_midi_receiver_remove_control_handler (BseMidiReceiver *self,
g_return_if_fail (midi_channel > 0);
g_return_if_fail (handler_func != NULL);
g_return_if_fail (module != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
self->remove_control_handler (midi_channel, signal_type, handler_func, handler_data, module);
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_channel_enable_poly (BseMidiReceiver *self,
guint midi_channel)
{
g_return_if_fail (self != NULL);
g_return_if_fail (midi_channel > 0);
-
BSE_MIDI_RECEIVER_LOCK ();
MidiChannel *mchannel = self->get_channel (midi_channel);
mchannel->enable_poly();
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
void
bse_midi_receiver_channel_disable_poly (BseMidiReceiver *self,
guint midi_channel)
{
g_return_if_fail (self != NULL);
g_return_if_fail (midi_channel > 0);
-
BSE_MIDI_RECEIVER_LOCK ();
MidiChannel *mchannel = self->get_channel (midi_channel);
mchannel->disable_poly();
BSE_MIDI_RECEIVER_UNLOCK ();
}
-
BseModule*
bse_midi_receiver_retrieve_mono_voice (BseMidiReceiver *self,
guint midi_channel,
BseTrans *trans)
{
MidiChannel *mchannel;
-
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
if (mchannel->vinput)
@@ -1559,7 +1408,6 @@ bse_midi_receiver_retrieve_mono_voice (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
return mchannel->vinput->fmodule;
}
-
void
bse_midi_receiver_discard_mono_voice (BseMidiReceiver *self,
guint midi_channel,
@@ -1567,10 +1415,8 @@ bse_midi_receiver_discard_mono_voice (BseMidiReceiver *self,
BseTrans *trans)
{
MidiChannel *mchannel;
-
g_return_if_fail (self != NULL);
g_return_if_fail (fmodule != NULL);
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
if (mchannel->vinput && mchannel->vinput->fmodule == fmodule)
@@ -1587,7 +1433,6 @@ bse_midi_receiver_discard_mono_voice (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
g_warning ("no such mono synth module: %p", fmodule);
}
-
guint
bse_midi_receiver_create_poly_voice (BseMidiReceiver *self,
guint midi_channel,
@@ -1595,10 +1440,8 @@ bse_midi_receiver_create_poly_voice (BseMidiReceiver *self,
{
MidiChannel *mchannel;
guint i;
-
g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (midi_channel > 0, 0);
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
/* find free voice slot */
@@ -1613,10 +1456,8 @@ bse_midi_receiver_create_poly_voice (BseMidiReceiver *self,
}
mchannel->voices[i] = create_voice_switch_module_L (trans);
BSE_MIDI_RECEIVER_UNLOCK ();
-
return i + 1;
}
-
void
bse_midi_receiver_discard_poly_voice (BseMidiReceiver *self,
guint midi_channel,
@@ -1625,12 +1466,10 @@ bse_midi_receiver_discard_poly_voice (BseMidiReceiver *self,
{
MidiChannel *mchannel;
VoiceSwitch *vswitch;
-
g_return_if_fail (self != NULL);
g_return_if_fail (midi_channel > 0);
g_return_if_fail (voice_id > 0);
voice_id -= 1;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
vswitch = voice_id < mchannel->n_voices ? mchannel->voices[voice_id] : NULL;
@@ -1648,7 +1487,6 @@ bse_midi_receiver_discard_poly_voice (BseMidiReceiver *self,
if (!vswitch)
g_warning ("MIDI channel %u has no voice %u", midi_channel, voice_id + 1);
}
-
BseModule*
bse_midi_receiver_get_poly_voice_input (BseMidiReceiver *self,
guint midi_channel,
@@ -1657,12 +1495,10 @@ bse_midi_receiver_get_poly_voice_input (BseMidiReceiver *self,
MidiChannel *mchannel;
VoiceSwitch *vswitch;
BseModule *module;
-
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
g_return_val_if_fail (voice_id > 0, NULL);
voice_id -= 1;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
vswitch = voice_id < mchannel->n_voices ? mchannel->voices[voice_id] : NULL;
@@ -1670,7 +1506,6 @@ bse_midi_receiver_get_poly_voice_input (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
return module;
}
-
BseModule*
bse_midi_receiver_get_poly_voice_output (BseMidiReceiver *self,
guint midi_channel,
@@ -1679,12 +1514,10 @@ bse_midi_receiver_get_poly_voice_output (BseMidiReceiver *self,
MidiChannel *mchannel;
VoiceSwitch *vswitch;
BseModule *module;
-
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
g_return_val_if_fail (voice_id > 0, NULL);
voice_id -= 1;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
vswitch = voice_id < mchannel->n_voices ? mchannel->voices[voice_id] : NULL;
@@ -1692,7 +1525,6 @@ bse_midi_receiver_get_poly_voice_output (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
return module;
}
-
BseModule*
bse_midi_receiver_create_sub_voice (BseMidiReceiver *self,
guint midi_channel,
@@ -1702,12 +1534,10 @@ bse_midi_receiver_create_sub_voice (BseMidiReceiver *self,
MidiChannel *mchannel;
VoiceSwitch *vswitch;
BseModule *module = NULL;
-
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (midi_channel > 0, NULL);
g_return_val_if_fail (voice_id > 0, NULL);
voice_id -= 1;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
vswitch = voice_id < mchannel->n_voices ? mchannel->voices[voice_id] : NULL;
@@ -1722,7 +1552,6 @@ bse_midi_receiver_create_sub_voice (BseMidiReceiver *self,
BSE_MIDI_RECEIVER_UNLOCK ();
return module;
}
-
void
bse_midi_receiver_discard_sub_voice (BseMidiReceiver *self,
guint midi_channel,
@@ -1733,13 +1562,11 @@ bse_midi_receiver_discard_sub_voice (BseMidiReceiver *self,
MidiChannel *mchannel;
VoiceSwitch *vswitch;
guint i, need_unref = FALSE;
-
g_return_if_fail (self != NULL);
g_return_if_fail (midi_channel > 0);
g_return_if_fail (fmodule != NULL);
g_return_if_fail (voice_id > 0);
voice_id -= 1;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
vswitch = voice_id < mchannel->n_voices ? mchannel->voices[voice_id] : NULL;
@@ -1770,7 +1597,6 @@ bse_midi_receiver_discard_sub_voice (BseMidiReceiver *self,
if (fmodule)
g_warning ("MIDI channel %u, poly voice %u, no such sub voice: %p", midi_channel, voice_id, fmodule);
}
-
gboolean
bse_midi_receiver_voices_pending (BseMidiReceiver *self,
guint midi_channel)
@@ -1778,13 +1604,10 @@ bse_midi_receiver_voices_pending (BseMidiReceiver *self,
MidiChannel *mchannel;
SfiRing *ring = NULL;
guint i, active = 0;
-
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (midi_channel > 0, FALSE);
-
if (self->events)
return TRUE;
-
BSE_MIDI_RECEIVER_LOCK ();
mchannel = self->get_channel (midi_channel);
if (mchannel)
@@ -1802,11 +1625,8 @@ bse_midi_receiver_voices_pending (BseMidiReceiver *self,
active += event->channel == midi_channel;
}
BSE_MIDI_RECEIVER_UNLOCK ();
-
return active > 0;
}
-
-
/* --- event processing --- */
static inline void
update_midi_signal_L (BseMidiReceiver *self,
@@ -1817,7 +1637,6 @@ update_midi_signal_L (BseMidiReceiver *self,
BseTrans *trans)
{
GSList *signal_modules;
-
signal_modules = self->set_control (channel, tick_stamp, signal, value, trans);
change_midi_control_modules_L (signal_modules, tick_stamp,
signal, value, trans);
@@ -1826,7 +1645,6 @@ update_midi_signal_L (BseMidiReceiver *self,
signal, value, bse_midi_signal_name (signal));
#endif
}
-
static inline void
update_midi_signal_continuous_msb_L (BseMidiReceiver *self,
guint channel,
@@ -1845,7 +1663,6 @@ update_midi_signal_continuous_msb_L (BseMidiReceiver *self,
value = ival / (gfloat) 0x3fff;
update_midi_signal_L (self, channel, tick_stamp, continuous_signal, value, trans);
}
-
static inline void
update_midi_signal_continuous_lsb_L (BseMidiReceiver *self,
guint channel,
@@ -1863,7 +1680,6 @@ update_midi_signal_continuous_lsb_L (BseMidiReceiver *self,
value = ival / (gfloat) 0x3fff;
update_midi_signal_L (self, channel, tick_stamp, continuous_signal, value, trans);
}
-
static inline void
process_midi_control_L (BseMidiReceiver *self,
guint channel,
@@ -1878,17 +1694,14 @@ process_midi_control_L (BseMidiReceiver *self,
* multiple MIDI signals. extra_continuous are used
* internally to update only continuous signals.
*/
-
if (extra_continuous)
{
/* internal BSE_MIDI_SIGNAL_CONTINUOUS_* change */
update_midi_signal_L (self, channel, tick_stamp, static_cast<BseMidiSignalType> (64 + control), value, trans);
return;
}
-
/* all MIDI controls are passed literally as BSE_MIDI_SIGNAL_CONTROL_* */
update_midi_signal_L (self, channel, tick_stamp, static_cast<BseMidiSignalType> (128 + control), value, trans);
-
if (control < 32) /* MSB part of continuous 14bit signal */
update_midi_signal_continuous_msb_L (self, channel, tick_stamp,
static_cast<BseMidiSignalType> (control + 64), /* continuous signal */
@@ -1950,17 +1763,14 @@ process_midi_control_L (BseMidiReceiver *self,
break;
}
}
-
static gint
midi_receiver_process_event_L (BseMidiReceiver *self,
guint64 max_tick_stamp)
{
BseMidiEvent *event;
gboolean need_wakeup = FALSE;
-
if (!self->events)
return FALSE;
-
event = (BseMidiEvent *) self->events->data;
if (event->delta_time <= max_tick_stamp)
{
@@ -2050,11 +1860,8 @@ midi_receiver_process_event_L (BseMidiReceiver *self,
}
else
return FALSE;
-
if (need_wakeup)
bse_midi_notifiers_wakeup();
-
return TRUE;
}
-
} // "C"
diff --git a/bse/bsemidireceiver.hh b/bse/bsemidireceiver.hh
index ea22edc..3c834c7 100644
--- a/bse/bsemidireceiver.hh
+++ b/bse/bsemidireceiver.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_RECEIVER_H__
#define __BSE_MIDI_RECEIVER_H__
-
#include <bse/bseobject.hh>
#include <bse/bsemidievent.hh>
-
G_BEGIN_DECLS
-
-
/* --- API --- */
#define BSE_MIDI_CONTROL_MODULE_N_CHANNELS (4)
#define BSE_MIDI_VOICE_MODULE_N_CHANNELS (4)
@@ -96,12 +92,7 @@ void bse_midi_receiver_enter_farm (BseMidiReceiver *s
void bse_midi_receiver_farm_distribute_event (BseMidiEvent *event);
void bse_midi_receiver_farm_process_events (guint64 max_tick_stamp);
void bse_midi_receiver_leave_farm (BseMidiReceiver *self);
-
-
/* --- internal --- */
void _bse_midi_init (void);
-
-
G_END_DECLS
-
#endif /* __BSE_MIDI_RECEIVER_H__ */
diff --git a/bse/bsemidisynth.cc b/bse/bsemidisynth.cc
index b67530c..00efc9c 100644
--- a/bse/bsemidisynth.cc
+++ b/bse/bsemidisynth.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidisynth.hh"
-
#include "bsemidievent.hh" /* BSE_MIDI_MAX_CHANNELS */
#include "bsemidivoice.hh"
#include "bsemidireceiver.hh"
@@ -13,8 +12,6 @@
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
-
-
/* --- parameters --- */
enum
{
@@ -28,8 +25,6 @@ enum
PROP_VOLUME_PERC,
PROP_AUTO_ACTIVATE
};
-
-
/* --- prototypes --- */
static void bse_midi_synth_class_init (BseMidiSynthClass *klass);
static void bse_midi_synth_init (BseMidiSynth *msynth);
@@ -46,90 +41,70 @@ static void bse_midi_synth_context_create (BseSource *sourc
guint context_handle,
BseTrans *trans);
static void bse_misi_synth_update_midi_channel (BseMidiSynth *self);
-
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseMidiSynth)
{
GType midi_synth_type;
-
static const GTypeInfo snet_info = {
sizeof (BseMidiSynthClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_midi_synth_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseMidiSynth),
0,
(GInstanceInitFunc) bse_midi_synth_init,
};
-
midi_synth_type = bse_type_register_static (BSE_TYPE_SNET,
"BseMidiSynth",
"BSE Midi Synthesizer",
__FILE__, __LINE__,
&snet_info);
-
return midi_synth_type;
}
-
static void
bse_midi_synth_init (BseMidiSynth *self)
{
BseSNet *snet = BSE_SNET (self);
-
BSE_OBJECT_UNSET_FLAGS (self, BSE_SNET_FLAG_USER_SYNTH);
BSE_OBJECT_SET_FLAGS (self, BSE_SUPER_FLAG_NEEDS_CONTEXT);
self->midi_channel_id = 1;
self->n_voices = 16;
self->volume_factor = bse_db_to_factor (0);
-
/* midi voice modules */
self->voice_input = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_MIDI_VOICE_INPUT, NULL);
bse_snet_intern_child (snet, self->voice_input);
self->voice_switch = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_MIDI_VOICE_SWITCH, NULL);
bse_snet_intern_child (snet, self->voice_switch);
bse_midi_voice_input_set_voice_switch (BSE_MIDI_VOICE_INPUT (self->voice_input), BSE_MIDI_VOICE_SWITCH (self->voice_switch));
-
/* context merger */
self->context_merger = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_CONTEXT_MERGER, NULL);
bse_snet_intern_child (snet, self->context_merger);
-
/* midi voice switch <-> context merger */
bse_source_must_set_input (self->context_merger, 0,
self->voice_switch, BSE_MIDI_VOICE_SWITCH_OCHANNEL_LEFT);
bse_source_must_set_input (self->context_merger, 1,
self->voice_switch, BSE_MIDI_VOICE_SWITCH_OCHANNEL_RIGHT);
-
/* post processing slot */
self->postprocess = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_SUB_SYNTH, "uname", "Postprocess", NULL);
bse_snet_intern_child (snet, self->postprocess);
bse_sub_synth_set_null_shortcut (BSE_SUB_SYNTH (self->postprocess), TRUE);
-
/* context merger <-> postprocess */
bse_source_must_set_input (self->postprocess, 0,
self->context_merger, 0);
bse_source_must_set_input (self->postprocess, 1,
self->context_merger, 1);
-
/* output */
self->output = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_PCM_OUTPUT, NULL);
bse_snet_intern_child (snet, self->output);
-
/* postprocess <-> output */
bse_source_must_set_input (self->output, BSE_PCM_OUTPUT_ICHANNEL_LEFT,
self->postprocess, 0);
bse_source_must_set_input (self->output, BSE_PCM_OUTPUT_ICHANNEL_RIGHT,
self->postprocess, 1);
-
/* sub synth */
self->sub_synth = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_SUB_SYNTH,
"in_port_1", "frequency",
@@ -142,7 +117,6 @@ bse_midi_synth_init (BseMidiSynth *self)
"out_port_4", "synth-done",
NULL);
bse_snet_intern_child (snet, self->sub_synth);
-
/* voice input <-> sub-synth */
bse_source_must_set_input (self->sub_synth, 0,
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_FREQUENCY);
@@ -152,7 +126,6 @@ bse_midi_synth_init (BseMidiSynth *self)
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_VELOCITY);
bse_source_must_set_input (self->sub_synth, 3,
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_AFTERTOUCH);
-
/* sub-synth <-> voice switch */
bse_source_must_set_input (self->voice_switch, BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT,
self->sub_synth, 0);
@@ -160,10 +133,8 @@ bse_midi_synth_init (BseMidiSynth *self)
self->sub_synth, 1);
bse_source_must_set_input (self->voice_switch, BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT,
self->sub_synth, 3);
-
bse_misi_synth_update_midi_channel (self);
}
-
static void
bse_misi_synth_update_midi_channel (BseMidiSynth *self)
{
@@ -174,12 +145,10 @@ bse_misi_synth_update_midi_channel (BseMidiSynth *self)
bse_midi_voice_switch_set_midi_channel (BSE_MIDI_VOICE_SWITCH (self->voice_switch), self->midi_channel_id);
}
}
-
static void
bse_midi_synth_finalize (GObject *object)
{
BseMidiSynth *self = BSE_MIDI_SYNTH (object);
-
bse_container_remove_item (BSE_CONTAINER (self), BSE_ITEM (self->voice_input));
self->voice_input = NULL;
bse_container_remove_item (BSE_CONTAINER (self), BSE_ITEM (self->voice_switch));
@@ -192,11 +161,9 @@ bse_midi_synth_finalize (GObject *object)
self->output = NULL;
bse_container_remove_item (BSE_CONTAINER (self), BSE_ITEM (self->sub_synth));
self->sub_synth = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_midi_synth_get_candidates (BseItem *item,
guint param_id,
@@ -219,7 +186,6 @@ bse_midi_synth_get_candidates (BseItem *item,
break;
}
}
-
static void
midi_synth_uncross_snet (BseItem *owner,
BseItem *ref_item)
@@ -227,7 +193,6 @@ midi_synth_uncross_snet (BseItem *owner,
BseMidiSynth *self = BSE_MIDI_SYNTH (owner);
bse_item_set (self, "snet", NULL, NULL);
}
-
static void
midi_synth_uncross_pnet (BseItem *owner,
BseItem *ref_item)
@@ -235,7 +200,6 @@ midi_synth_uncross_pnet (BseItem *owner,
BseMidiSynth *self = BSE_MIDI_SYNTH (owner);
bse_item_set (self, "pnet", NULL, NULL);
}
-
static void
bse_midi_synth_set_property (GObject *object,
guint param_id,
@@ -326,7 +290,6 @@ bse_midi_synth_set_property (GObject *object,
break;
}
}
-
static void
bse_midi_synth_get_property (GObject *object,
guint param_id,
@@ -362,7 +325,6 @@ bse_midi_synth_get_property (GObject *object,
break;
}
}
-
static void
bse_midi_synth_context_create (BseSource *source,
guint context_handle,
@@ -370,21 +332,17 @@ bse_midi_synth_context_create (BseSource *source,
{
BseMidiSynth *self = BSE_MIDI_SYNTH (source);
BseSNet *snet = BSE_SNET (self);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
if (!bse_snet_context_is_branch (snet, context_handle)) /* catch recursion */
{
BseMidiContext mcontext = bse_snet_get_midi_context (snet, context_handle);
guint i;
for (i = 0; i < self->n_voices; i++)
bse_snet_context_clone_branch (snet, context_handle, self->context_merger, mcontext, trans);
-
bse_midi_receiver_channel_enable_poly (mcontext.midi_receiver, mcontext.midi_channel);
}
}
-
static void
bse_midi_synth_context_dismiss (BseSource *source,
guint context_handle,
@@ -392,17 +350,14 @@ bse_midi_synth_context_dismiss (BseSource *source,
{
BseMidiSynth *self = BSE_MIDI_SYNTH (source);
BseSNet *snet = BSE_SNET (self);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
-
if (!bse_snet_context_is_branch (snet, context_handle))
{
BseMidiContext mcontext = bse_snet_get_midi_context (snet, context_handle);
bse_midi_receiver_channel_disable_poly (mcontext.midi_receiver, mcontext.midi_channel);
}
}
-
static void
bse_midi_synth_class_init (BseMidiSynthClass *klass)
{
@@ -410,16 +365,13 @@ bse_midi_synth_class_init (BseMidiSynthClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
gobject_class->set_property = bse_midi_synth_set_property;
gobject_class->get_property = bse_midi_synth_get_property;
gobject_class->finalize = bse_midi_synth_finalize;
item_class->get_candidates = bse_midi_synth_get_candidates;
-
source_class->context_create = bse_midi_synth_context_create;
source_class->context_dismiss = bse_midi_synth_context_dismiss;
-
bse_object_class_add_param (object_class, _("MIDI Instrument"),
PROP_MIDI_CHANNEL,
sfi_pspec_int ("midi_channel", _("MIDI Channel"), NULL,
diff --git a/bse/bsemidisynth.hh b/bse/bsemidisynth.hh
index fa0d3f7..8585471 100644
--- a/bse/bsemidisynth.hh
+++ b/bse/bsemidisynth.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_SYNTH_H__
#define __BSE_MIDI_SYNTH_H__
-
#include <bse/bsesnet.hh>
#include <bse/bsesubsynth.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_SYNTH (BSE_TYPE_ID (BseMidiSynth))
#define BSE_MIDI_SYNTH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_SYNTH, BseMidiSynth))
@@ -14,20 +11,15 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_SYNTH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_SYNTH))
#define BSE_IS_MIDI_SYNTH_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_SYNTH))
#define BSE_MIDI_SYNTH_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_SYNTH, BseMidiSynthClass))
-
-
/* --- BseMidiSynth object --- */
struct _BseMidiSynth
{
BseSNet parent_object;
-
guint midi_channel_id;
guint n_voices;
gfloat volume_factor; /* 1-based factor */
-
BseSNet *snet;
BseSNet *pnet;
-
BseSource *voice_input;
BseSource *voice_switch;
BseSource *context_merger;
@@ -39,8 +31,5 @@ struct _BseMidiSynthClass
{
BseSNetClass parent_class;
};
-
-
G_END_DECLS
-
#endif /* __BSE_MIDI_SYNTH_H__ */
diff --git a/bse/bsemidivoice.cc b/bse/bsemidivoice.cc
index 3c29ea7..2dccf00 100644
--- a/bse/bsemidivoice.cc
+++ b/bse/bsemidivoice.cc
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemidivoice.hh"
-
#include "bseserver.hh"
#include "bsemidireceiver.hh"
#include "bseengine.hh"
#include "gslcommon.hh"
#include "bsesnet.hh"
-
-
/* --- prototypes --- */
static void bse_midi_voice_input_init (BseMidiVoiceInput *self);
static void bse_midi_voice_input_class_init (BseMidiVoiceInputClass *klass);
@@ -27,13 +24,9 @@ static void bse_midi_voice_switch_context_create (BseSource *sou
static void bse_midi_voice_switch_context_dismiss (BseSource *source,
guint context_handle,
BseTrans *trans);
-
-
/* --- variables --- */
static gpointer voice_input_parent_class = NULL;
static gpointer voice_switch_parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseMidiVoiceInput)
{
@@ -48,14 +41,12 @@ BSE_BUILTIN_TYPE (BseMidiVoiceInput)
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_voice_input_init,
};
-
return bse_type_register_static (BSE_TYPE_SOURCE,
"BseMidiVoiceInput",
"Internal MIDI Voice glue object (input)",
__FILE__, __LINE__,
&type_info);
}
-
BSE_BUILTIN_TYPE (BseMidiVoiceSwitch)
{
static const GTypeInfo type_info = {
@@ -69,28 +60,22 @@ BSE_BUILTIN_TYPE (BseMidiVoiceSwitch)
0 /* n_preallocs */,
(GInstanceInitFunc) bse_midi_voice_switch_init,
};
-
return bse_type_register_static (BSE_TYPE_SOURCE,
"BseMidiVoiceSwitch",
"Internal MIDI Voice glue object (switch)",
__FILE__, __LINE__,
&type_info);
}
-
static void
bse_midi_voice_input_class_init (BseMidiVoiceInputClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
voice_input_parent_class = g_type_class_peek_parent (klass);
-
gobject_class->dispose = bse_midi_voice_input_dispose;
-
source_class->context_create = bse_midi_voice_input_context_create;
source_class->context_dismiss = bse_midi_voice_input_context_dismiss;
-
channel_id = bse_source_class_add_ochannel (source_class, "freq-out", _("Freq Out"), NULL);
g_assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_FREQUENCY);
channel_id = bse_source_class_add_ochannel (source_class, "gate-out", _("Gate Out"), NULL);
@@ -100,21 +85,16 @@ bse_midi_voice_input_class_init (BseMidiVoiceInputClass *klass)
channel_id = bse_source_class_add_ochannel (source_class, "aftertouch-out", _("Aftertouch Out"), NULL);
g_assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_AFTERTOUCH);
}
-
static void
bse_midi_voice_switch_class_init (BseMidiVoiceSwitchClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
voice_switch_parent_class = g_type_class_peek_parent (klass);
-
gobject_class->dispose = bse_midi_voice_switch_dispose;
-
source_class->context_create = bse_midi_voice_switch_context_create;
source_class->context_dismiss = bse_midi_voice_switch_context_dismiss;
-
channel_id = bse_source_class_add_ichannel (source_class, "left-in", _("Left In"), NULL);
g_assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT);
channel_id = bse_source_class_add_ichannel (source_class, "right-in", _("Right In"), NULL);
@@ -128,17 +108,14 @@ bse_midi_voice_switch_class_init (BseMidiVoiceSwitchClass *klass)
channel_id = bse_source_class_add_ochannel (source_class, "disconnect-out", _("Disconnect Out"), NULL);
g_assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT);
}
-
static void
bse_midi_voice_input_init (BseMidiVoiceInput *self)
{
}
-
static void
bse_midi_voice_switch_init (BseMidiVoiceSwitch *self)
{
}
-
void
bse_midi_voice_input_set_voice_switch (BseMidiVoiceInput *self,
BseMidiVoiceSwitch *voice_switch)
@@ -147,37 +124,29 @@ bse_midi_voice_input_set_voice_switch (BseMidiVoiceInput *self,
g_return_if_fail (!BSE_SOURCE_PREPARED (self));
if (voice_switch)
g_return_if_fail (BSE_IS_MIDI_VOICE_SWITCH (voice_switch));
-
if (self->voice_switch)
g_object_unref (self->voice_switch);
self->voice_switch = voice_switch;
if (self->voice_switch)
g_object_ref (self->voice_switch);
}
-
static void
bse_midi_voice_input_dispose (GObject *object)
{
BseMidiVoiceInput *self = BSE_MIDI_VOICE_INPUT (object);
-
bse_midi_voice_input_set_voice_switch (self, NULL);
-
/* chain parent class' handler */
G_OBJECT_CLASS (voice_input_parent_class)->dispose (object);
}
-
static void
bse_midi_voice_switch_dispose (GObject *object)
{
BseMidiVoiceSwitch *self = BSE_MIDI_VOICE_SWITCH (object);
-
if (self->midi_voices)
g_warning ("disposing voice-switch with active midi voices");
-
/* chain parent class' handler */
G_OBJECT_CLASS (voice_switch_parent_class)->dispose (object);
}
-
static void
bse_midi_voice_input_context_create (BseSource *source,
guint context_handle,
@@ -186,17 +155,14 @@ bse_midi_voice_input_context_create (BseSource *source,
BseMidiVoiceInput *self = BSE_MIDI_VOICE_INPUT (source);
BseMidiContext mcontext = bse_midi_voice_switch_ref_poly_voice (self->voice_switch, context_handle, trans);
// FIXME: handle no voice-switch
-
/* we simply wrap the module from BseMidiReceiver */
bse_source_set_context_omodule (source, context_handle,
bse_midi_receiver_create_sub_voice (mcontext.midi_receiver,
mcontext.midi_channel,
mcontext.voice_id, trans));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (voice_input_parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_midi_voice_input_context_dismiss (BseSource *source,
guint context_handle,
@@ -205,24 +171,19 @@ bse_midi_voice_input_context_dismiss (BseSource *source,
BseMidiVoiceInput *self = BSE_MIDI_VOICE_INPUT (source);
BseMidiContext mcontext = bse_midi_voice_switch_peek_poly_voice (self->voice_switch, context_handle);
BseModule *module;
-
/* the BseModule isn't ours, so theoretically we would just need
* to disconnect and not discard it.
* but since connecting/disconnecting src to dest modules is handled by
* the dest modules, we actually have to do nothing besides preventing
* BseSource to discard the foreign module.
*/
-
module = bse_source_get_context_omodule (source, context_handle);
bse_midi_receiver_discard_sub_voice (mcontext.midi_receiver, mcontext.midi_channel, mcontext.voice_id, module, trans);
bse_source_set_context_omodule (source, context_handle, NULL);
-
bse_midi_voice_switch_unref_poly_voice (self->voice_switch, context_handle, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (voice_input_parent_class)->context_dismiss (source, context_handle, trans);
}
-
static void
bse_midi_voice_switch_context_create (BseSource *source,
guint context_handle,
@@ -230,7 +191,6 @@ bse_midi_voice_switch_context_create (BseSource *source,
{
BseMidiVoiceSwitch *self = BSE_MIDI_VOICE_SWITCH (source);
BseMidiContext mcontext = bse_midi_voice_switch_ref_poly_voice (self, context_handle, trans);
-
/* we simply wrap the modules from BseMidiReceiver */
bse_source_set_context_imodule (source, context_handle,
bse_midi_receiver_get_poly_voice_input (mcontext.midi_receiver,
@@ -238,48 +198,38 @@ bse_midi_voice_switch_context_create (BseSource *source,
bse_source_set_context_omodule (source, context_handle,
bse_midi_receiver_get_poly_voice_output (mcontext.midi_receiver,
mcontext.midi_channel, mcontext.voice_id));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (voice_switch_parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_midi_voice_switch_context_dismiss (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseMidiVoiceSwitch *self = BSE_MIDI_VOICE_SWITCH (source);
-
/* the BseModules aren't ours, so we need to disconnect the input module
* and prevent discarding the modules.
*/
-
bse_trans_add (trans, bse_job_kill_inputs (bse_source_get_context_imodule (source, context_handle)));
bse_source_set_context_imodule (source, context_handle, NULL);
bse_source_set_context_omodule (source, context_handle, NULL);
-
bse_midi_voice_switch_unref_poly_voice (self, context_handle, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (voice_switch_parent_class)->context_dismiss (source, context_handle, trans);
}
-
void
bse_midi_voice_switch_set_midi_channel (BseMidiVoiceSwitch *self,
guint midi_channel)
{
g_return_if_fail (BSE_IS_MIDI_VOICE_SWITCH (self));
g_return_if_fail (!BSE_SOURCE_PREPARED (self));
-
self->midi_channel = midi_channel;
}
-
typedef struct {
guint context_handle;
guint ref_count;
guint voice_id;
} MidiVoice;
-
BseMidiContext
bse_midi_voice_switch_ref_poly_voice (BseMidiVoiceSwitch *self,
guint context_handle,
@@ -288,11 +238,9 @@ bse_midi_voice_switch_ref_poly_voice (BseMidiVoiceSwitch *self,
BseMidiContext mcontext = { 0, };
MidiVoice *mvoice;
GSList *slist;
-
g_return_val_if_fail (BSE_IS_MIDI_VOICE_SWITCH (self), mcontext);
g_return_val_if_fail (BSE_SOURCE_PREPARED (self), mcontext);
g_return_val_if_fail (trans != NULL, mcontext);
-
mcontext = bse_snet_get_midi_context (BSE_SNET (BSE_ITEM (self)->parent), context_handle);
mcontext.midi_channel = self->midi_channel;
for (slist = self->midi_voices; slist; slist = slist->next)
@@ -314,7 +262,6 @@ bse_midi_voice_switch_ref_poly_voice (BseMidiVoiceSwitch *self,
mcontext.voice_id = mvoice->voice_id;
return mcontext;
}
-
BseMidiContext
bse_midi_voice_switch_peek_poly_voice (BseMidiVoiceSwitch *self,
guint context_handle)
@@ -322,10 +269,8 @@ bse_midi_voice_switch_peek_poly_voice (BseMidiVoiceSwitch *self,
BseMidiContext mcontext = { 0, };
MidiVoice *mvoice;
GSList *slist;
-
g_return_val_if_fail (BSE_IS_MIDI_VOICE_SWITCH (self), mcontext);
g_return_val_if_fail (BSE_SOURCE_PREPARED (self), mcontext);
-
for (slist = self->midi_voices; slist; slist = slist->next)
{
mvoice = (MidiVoice*) slist->data;
@@ -340,7 +285,6 @@ bse_midi_voice_switch_peek_poly_voice (BseMidiVoiceSwitch *self,
}
return mcontext;
}
-
void
bse_midi_voice_switch_unref_poly_voice (BseMidiVoiceSwitch *self,
guint context_handle,
@@ -349,11 +293,9 @@ bse_midi_voice_switch_unref_poly_voice (BseMidiVoiceSwitch *self,
BseMidiContext mcontext;
MidiVoice *mvoice;
GSList *slist;
-
g_return_if_fail (BSE_IS_MIDI_VOICE_SWITCH (self));
g_return_if_fail (BSE_SOURCE_PREPARED (self));
g_return_if_fail (trans != NULL);
-
mcontext = bse_snet_get_midi_context (BSE_SNET (BSE_ITEM (self)->parent), context_handle);
mcontext.midi_channel = self->midi_channel;
for (slist = self->midi_voices; slist; slist = slist->next)
diff --git a/bse/bsemidivoice.hh b/bse/bsemidivoice.hh
index de9d063..f919eee 100644
--- a/bse/bsemidivoice.hh
+++ b/bse/bsemidivoice.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_VOICE_H__
#define __BSE_MIDI_VOICE_H__
-
#include <bse/bsesource.hh>
#include <bse/bsesnet.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_VOICE_INPUT (BSE_TYPE_ID (BseMidiVoiceInput))
#define BSE_MIDI_VOICE_INPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_VOICE_INPUT, BseMidiVoiceInput))
@@ -20,8 +17,6 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_VOICE_SWITCH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_VOICE_SWITCH))
#define BSE_IS_MIDI_VOICE_SWITCH_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_VOICE_SWITCH))
#define BSE_MIDI_VOICE_SWITCH_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_VOICE_SWITCH, BseMidiVoiceSwitchClass))
-
-
/* --- object structures --- */
typedef struct _BseMidiVoiceInput BseMidiVoiceInput;
typedef struct _BseMidiVoiceSwitch BseMidiVoiceSwitch;
@@ -30,7 +25,6 @@ typedef struct _BseSourceClass BseMidiVoiceSwitchClass;
struct _BseMidiVoiceInput
{
BseSource parent_object;
-
BseMidiVoiceSwitch *voice_switch;
};
struct _BseMidiVoiceSwitch
@@ -39,8 +33,6 @@ struct _BseMidiVoiceSwitch
guint midi_channel;
GSList *midi_voices;
};
-
-
/* --- prototypes --- */
void bse_midi_voice_switch_set_midi_channel (BseMidiVoiceSwitch *self,
guint midi_channel);
@@ -54,8 +46,6 @@ void bse_midi_voice_switch_unref_poly_voice (BseMidiVoiceSwitch *self,
BseTrans *trans);
void bse_midi_voice_input_set_voice_switch (BseMidiVoiceInput *self,
BseMidiVoiceSwitch *voice_switch);
-
-
/* --- channels --- */
enum
{
@@ -76,7 +66,5 @@ enum
BSE_MIDI_VOICE_SWITCH_OCHANNEL_RIGHT,
BSE_MIDI_VOICE_SWITCH_OCHANNEL_DISCONNECT
};
-
G_END_DECLS
-
#endif /* __BSE_MIDI_VOICE_H__ */
diff --git a/bse/bsenote.cc b/bse/bsenote.cc
index 1e1a952..5b66ae0 100644
--- a/bse/bsenote.cc
+++ b/bse/bsenote.cc
@@ -5,8 +5,6 @@
#include "bsemathsignal.hh"
#include <string.h>
#include <birnet/birnet.hh>
-
-
/* --- functions --- */
namespace {
struct FreqCmp {
@@ -18,7 +16,6 @@ struct FreqCmp {
}
};
} // Anon
-
int
bse_note_from_freq (BseMusicalTuningType musical_tuning,
double freq)
@@ -52,7 +49,6 @@ bse_note_from_freq (BseMusicalTuningType musical_tuning,
return BSE_NOTE_VOID;
return CLAMP (note, BSE_MIN_NOTE, BSE_MAX_NOTE);
}
-
int
bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
double freq)
@@ -63,7 +59,6 @@ bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
else
return freq > BSE_KAMMER_FREQUENCY ? BSE_MAX_NOTE : BSE_MIN_NOTE;
}
-
int
bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
int note,
@@ -73,10 +68,8 @@ bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
freq /= BSE_KAMMER_FREQUENCY * semitone_factor;
double d = log (freq) / BSE_LN_2_POW_1_DIV_1200_d;
int fine_tune = bse_ftoi (d);
-
return CLAMP (fine_tune, BSE_MIN_FINE_TUNE, BSE_MAX_FINE_TUNE);
}
-
double
bse_note_to_freq (BseMusicalTuningType musical_tuning,
int note)
@@ -86,7 +79,6 @@ bse_note_to_freq (BseMusicalTuningType musical_tuning,
double semitone_factor = bse_transpose_factor (musical_tuning, note - SFI_KAMMER_NOTE);
return BSE_KAMMER_FREQUENCY * semitone_factor;
}
-
double
bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
int note,
@@ -97,63 +89,49 @@ bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
double semitone_factor = bse_transpose_factor (musical_tuning, note - SFI_KAMMER_NOTE);
return BSE_KAMMER_FREQUENCY * semitone_factor * bse_cent_tune_fast (fine_tune);
}
-
-
/* --- freq array --- */
struct BseFreqArray {
guint n_values;
guint n_prealloced;
gdouble *values;
};
-
BseFreqArray*
bse_freq_array_new (guint prealloc)
{
BseFreqArray *farray = g_new0 (BseFreqArray, 1);
-
farray->n_prealloced = prealloc;
farray->values = g_new0 (gdouble, farray->n_prealloced);
-
return farray;
}
-
void
bse_freq_array_free (BseFreqArray *farray)
{
g_return_if_fail (farray != NULL);
-
g_free (farray->values);
g_free (farray);
}
-
guint
bse_freq_array_n_values (BseFreqArray *farray)
{
g_return_val_if_fail (farray != NULL, 0);
-
return farray->n_values;
}
-
gdouble
bse_freq_array_get (BseFreqArray *farray,
guint index)
{
g_return_val_if_fail (farray != NULL, 0);
g_return_val_if_fail (index < farray->n_values, 0);
-
return farray->values[index];
}
-
void
bse_freq_array_insert (BseFreqArray *farray,
guint index,
gdouble value)
{
guint i;
-
g_return_if_fail (farray != NULL);
g_return_if_fail (index <= farray->n_values);
-
i = farray->n_values;
i = farray->n_values += 1;
if (farray->n_values > farray->n_prealloced)
@@ -166,14 +144,12 @@ bse_freq_array_insert (BseFreqArray *farray,
i - index);
farray->values[index] = value;
}
-
void
bse_freq_array_append (BseFreqArray *farray,
gdouble value)
{
bse_freq_array_insert (farray, farray->n_values, value);
}
-
void
bse_freq_array_set (BseFreqArray *farray,
guint index,
@@ -181,33 +157,26 @@ bse_freq_array_set (BseFreqArray *farray,
{
g_return_if_fail (farray != NULL);
g_return_if_fail (index < farray->n_values);
-
farray->values[index] = value;
}
-
gboolean
bse_freq_arrays_match_freq (gfloat match_freq,
BseFreqArray *inclusive_set,
BseFreqArray *exclusive_set)
{
guint i;
-
if (exclusive_set)
for (i = 0; i < exclusive_set->n_values; i++)
{
gdouble *value = exclusive_set->values + i;
-
if (fabs (*value - match_freq) < BSE_FREQUENCY_EPSILON)
return FALSE;
}
-
if (!inclusive_set)
return TRUE;
-
for (i = 0; i < inclusive_set->n_values; i++)
{
gdouble *value = inclusive_set->values + i;
-
if (fabs (*value - match_freq) < BSE_FREQUENCY_EPSILON)
return TRUE;
}
diff --git a/bse/bsenote.hh b/bse/bsenote.hh
index 66ade20..3772442 100644
--- a/bse/bsenote.hh
+++ b/bse/bsenote.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_NOTE_H__
#define __BSE_NOTE_H__
-
#include <bse/bseglobals.hh>
#include <bse/bsetype.hh>
-
G_BEGIN_DECLS
-
/* --- import Sfi macros --- */
#define BSE_MIN_NOTE SFI_MIN_NOTE
#define BSE_MAX_NOTE SFI_MAX_NOTE
@@ -22,8 +19,6 @@ G_BEGIN_DECLS
#define bse_note_from_string sfi_note_from_string
#define bse_note_to_string sfi_note_to_string
#define bse_note_examine sfi_note_examine
-
-
/* --- construct notes --- */
#define BSE_NOTE_OCTAVE(n) SFI_NOTE_OCTAVE (n)
#define BSE_NOTE_SEMITONE(n) SFI_NOTE_SEMITONE (n)
@@ -48,8 +43,6 @@ G_BEGIN_DECLS
#define BSE_NOTE_SHIFT(n,ht_i) SFI_NOTE_SHIFT (n, ht_i)
#define BSE_NOTE_OCTAVE_UP(n) (BSE_NOTE_SHIFT ((n), +12))
#define BSE_NOTE_OCTAVE_DOWN(n) (BSE_NOTE_SHIFT ((n), -12))
-
-
/* --- functions --- */
int bse_note_from_freq (BseMusicalTuningType musical_tuning,
double freq);
@@ -63,8 +56,6 @@ double bse_note_to_freq (BseMusicalTuningType
double bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
int note,
int fine_tune);
-
-
/* --- freq array --- */
typedef struct BseFreqArray BseFreqArray;
BseFreqArray* bse_freq_array_new (guint prealloc);
@@ -87,7 +78,5 @@ void bse_freq_array_set (BseFreqArray *farray,
gboolean bse_freq_arrays_match_freq (gfloat match_freq,
BseFreqArray *inclusive_set,
BseFreqArray *exclusive_set);
-
G_END_DECLS
-
#endif /* __BSE_NOTE_H__ */
diff --git a/bse/bseobject.cc b/bse/bseobject.cc
index 3321cd7..47e968a 100644
--- a/bse/bseobject.cc
+++ b/bse/bseobject.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseobject.hh"
-
#include "bseexports.hh"
#include "bsestorage.hh"
#include "bseparasite.hh"
@@ -8,10 +7,8 @@
#include "bsegconfig.hh"
#include "bsesource.hh" /* debug hack */
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_leaks, "leaks", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_leaks, __VA_ARGS__)
-
enum
{
PROP_0,
@@ -24,14 +21,10 @@ enum
SIGNAL_ICON_CHANGED,
SIGNAL_LAST
};
-
-
/* --- prototypes --- */
static guint eclosure_hash (gconstpointer c);
static gint eclosure_equals (gconstpointer c1,
gconstpointer c2);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
GQuark bse_quark_uname = 0;
@@ -42,8 +35,6 @@ static GHashTable *eclosures_ht = NULL;
static SfiUStore *object_id_ustore = NULL;
static GQuark quark_property_changed_queue = 0;
static guint object_signals[SIGNAL_LAST] = { 0, };
-
-
/* --- functions --- */
void
bse_object_debug_leaks (void)
@@ -51,11 +42,9 @@ bse_object_debug_leaks (void)
if (sfi_msg_check (debug_leaks))
{
GList *list, *objects = bse_objects_list (BSE_TYPE_OBJECT);
-
for (list = objects; list; list = list->next)
{
BseObject *object = (BseObject*) list->data;
-
DEBUG ("stale %s:\t prepared=%u locked=%u ref_count=%u id=%u ((BseObject*)%p)",
G_OBJECT_TYPE_NAME (object),
BSE_IS_SOURCE (object) && BSE_SOURCE_PREPARED (object),
@@ -67,7 +56,6 @@ bse_object_debug_leaks (void)
g_list_free (objects);
}
}
-
/**
* @param object supposedly valid #GObject pointer
* @return newly allocated string
@@ -90,13 +78,11 @@ bse_object_strdup_debug_handle (gpointer object)
/* we may not access GObject.data (includes BSE_OBJECT_UNAME()) */
return g_strdup_printf ("%s(%p)\"", G_OBJECT_TYPE_NAME (instance), object);
}
-
const gchar*
bse_object_debug_name (gpointer object)
{
GTypeInstance *instance = (GTypeInstance*) object;
gchar *debug_name;
-
if (!instance)
return "<NULL>";
if (!instance->g_class)
@@ -112,7 +98,6 @@ bse_object_debug_name (gpointer object)
}
return debug_name;
}
-
static inline void
object_unames_ht_insert (BseObject *object)
{
@@ -122,7 +107,6 @@ object_unames_ht_insert (BseObject *object)
object_slist = g_slist_prepend (object_slist, object);
g_hash_table_insert (object_unames_ht, BSE_OBJECT_UNAME (object_slist->data), object_slist);
}
-
static void
bse_object_init (BseObject *object)
{
@@ -130,10 +114,8 @@ bse_object_init (BseObject *object)
object->lock_count = 0;
object->unique_id = bse_id_alloc ();
sfi_ustore_insert (object_id_ustore, object->unique_id, object);
-
object_unames_ht_insert (object);
}
-
static inline void
object_unames_ht_remove (BseObject *object)
{
@@ -147,51 +129,39 @@ object_unames_ht_remove (BseObject *object)
g_hash_table_insert (object_unames_ht, BSE_OBJECT_UNAME (object_slist->data), object_slist);
}
}
-
static void
bse_object_do_dispose (GObject *gobject)
{
BseObject *object = BSE_OBJECT (gobject);
-
BSE_OBJECT_SET_FLAGS (object, BSE_OBJECT_FLAG_DISPOSING);
-
if (BSE_OBJECT_IN_RESTORE (object))
g_warning ("%s: object in restore state while disposing: %s", G_STRLOC, bse_object_debug_name (object));
-
/* perform release notification */
g_signal_emit (object, object_signals[SIGNAL_RELEASE], 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (gobject);
-
BSE_OBJECT_UNSET_FLAGS (object, BSE_OBJECT_FLAG_DISPOSING);
}
-
static void
bse_object_do_finalize (GObject *gobject)
{
BseObject *object = BSE_OBJECT (gobject);
-
bse_id_free (object->unique_id);
sfi_ustore_remove (object_id_ustore, object->unique_id);
object->unique_id = 0;
-
/* remove object from hash list *before* clearing data list,
* since the object uname is kept in the datalist!
*/
object_unames_ht_remove (object);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
-
static void
bse_object_do_set_uname (BseObject *object,
const gchar *uname)
{
g_object_set_qdata_full ((GObject*) object, bse_quark_uname, g_strdup (uname), uname ? g_free : NULL);
}
-
static void
bse_object_do_set_property (GObject *gobject,
guint property_id,
@@ -202,7 +172,6 @@ bse_object_do_set_property (GObject *gobject,
switch (property_id)
{
gchar *string;
-
case PROP_UNAME:
if (!(object->flags & BSE_OBJECT_FLAG_FIXED_UNAME))
{
@@ -241,7 +210,6 @@ bse_object_do_set_property (GObject *gobject,
break;
}
}
-
static void
bse_object_do_get_property (GObject *gobject,
guint property_id,
@@ -264,7 +232,6 @@ bse_object_do_get_property (GObject *gobject,
break;
}
}
-
void
bse_object_class_add_grouped_property (BseObjectClass *klass,
guint property_id,
@@ -273,10 +240,8 @@ bse_object_class_add_grouped_property (BseObjectClass *klass,
g_return_if_fail (BSE_IS_OBJECT_CLASS (klass));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_return_if_fail (property_id > 0);
-
g_object_class_install_property (G_OBJECT_CLASS (klass), property_id, pspec);
}
-
void
bse_object_class_add_property (BseObjectClass *klass,
const gchar *property_group,
@@ -286,11 +251,9 @@ bse_object_class_add_property (BseObjectClass *klass,
g_return_if_fail (BSE_IS_OBJECT_CLASS (klass));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_return_if_fail (sfi_pspec_get_group (pspec) == NULL);
-
sfi_pspec_set_group (pspec, property_group);
bse_object_class_add_grouped_property (klass, property_id, pspec);
}
-
void
bse_object_marshal_signal (GClosure *closure,
GValue /*out*/ *return_value,
@@ -300,11 +263,9 @@ bse_object_marshal_signal (GClosure *closure,
gpointer marshal_data)
{
gpointer arg0, argN;
-
g_return_if_fail (return_value == NULL);
g_return_if_fail (n_param_values >= 1 && n_param_values <= 1 + SFI_VMARSHAL_MAX_ARGS);
g_return_if_fail (G_VALUE_HOLDS_OBJECT (param_values));
-
arg0 = g_value_get_object (param_values);
if (G_CCLOSURE_SWAP_DATA (closure))
{
@@ -319,7 +280,6 @@ bse_object_marshal_signal (GClosure *closure,
param_values + 1,
argN);
}
-
guint
bse_object_class_add_signal (BseObjectClass *oclass,
const gchar *signal_name,
@@ -329,11 +289,9 @@ bse_object_class_add_signal (BseObjectClass *oclass,
{
va_list args;
guint signal_id;
-
g_return_val_if_fail (BSE_IS_OBJECT_CLASS (oclass), 0);
g_return_val_if_fail (n_params <= SFI_VMARSHAL_MAX_ARGS, 0);
g_return_val_if_fail (signal_name != NULL, 0);
-
va_start (args, n_params);
signal_id = g_signal_new_valist (signal_name,
G_TYPE_FROM_CLASS (oclass),
@@ -343,10 +301,8 @@ bse_object_class_add_signal (BseObjectClass *oclass,
return_type,
n_params, args);
va_end (args);
-
return signal_id;
}
-
guint
bse_object_class_add_asignal (BseObjectClass *oclass,
const gchar *signal_name,
@@ -356,11 +312,9 @@ bse_object_class_add_asignal (BseObjectClass *oclass,
{
va_list args;
guint signal_id;
-
g_return_val_if_fail (BSE_IS_OBJECT_CLASS (oclass), 0);
g_return_val_if_fail (n_params <= SFI_VMARSHAL_MAX_ARGS, 0);
g_return_val_if_fail (signal_name != NULL, 0);
-
va_start (args, n_params);
signal_id = g_signal_new_valist (signal_name,
G_TYPE_FROM_CLASS (oclass),
@@ -370,10 +324,8 @@ bse_object_class_add_asignal (BseObjectClass *oclass,
return_type,
n_params, args);
va_end (args);
-
return signal_id;
}
-
guint
bse_object_class_add_dsignal (BseObjectClass *oclass,
const gchar *signal_name,
@@ -383,11 +335,9 @@ bse_object_class_add_dsignal (BseObjectClass *oclass,
{
va_list args;
guint signal_id;
-
g_return_val_if_fail (BSE_IS_OBJECT_CLASS (oclass), 0);
g_return_val_if_fail (n_params <= SFI_VMARSHAL_MAX_ARGS, 0);
g_return_val_if_fail (signal_name != NULL, 0);
-
va_start (args, n_params);
signal_id = g_signal_new_valist (signal_name,
G_TYPE_FROM_CLASS (oclass),
@@ -397,94 +347,72 @@ bse_object_class_add_dsignal (BseObjectClass *oclass,
return_type,
n_params, args);
va_end (args);
-
return signal_id;
}
-
void
bse_object_lock (gpointer _object)
{
BseObject *object = (BseObject*) _object;
GObject *gobject = (GObject*) _object;
-
g_return_if_fail (BSE_IS_OBJECT (object));
g_return_if_fail (gobject->ref_count > 0);
-
g_assert (object->lock_count < 65535); // if this breaks, we need to fix the guint16
-
if (!object->lock_count)
{
g_object_ref (object);
-
/* we also keep the globals locked so we don't need to duplicate
* this all over the place
*/
bse_gconfig_lock ();
}
-
object->lock_count += 1;
}
-
void
bse_object_unlock (gpointer _object)
{
BseObject *object = (BseObject*) _object;
-
g_return_if_fail (BSE_IS_OBJECT (object));
g_return_if_fail (object->lock_count > 0);
-
object->lock_count -= 1;
-
if (!object->lock_count)
{
/* release global lock */
bse_gconfig_unlock ();
-
if (BSE_OBJECT_GET_CLASS (object)->unlocked)
BSE_OBJECT_GET_CLASS (object)->unlocked (object);
-
g_object_unref (object);
}
}
-
gpointer
bse_object_from_id (guint unique_id)
{
return sfi_ustore_lookup (object_id_ustore, unique_id);
}
-
GList*
bse_objects_list_by_uname (GType type,
const gchar *uname)
{
GList *object_list = NULL;
-
g_return_val_if_fail (BSE_TYPE_IS_OBJECT (type) == TRUE, NULL);
-
if (object_unames_ht)
{
GSList *slist, *object_slist = (GSList*) g_hash_table_lookup (object_unames_ht, uname);
-
for (slist = object_slist; slist; slist = slist->next)
if (g_type_is_a (BSE_OBJECT_TYPE (slist->data), type))
object_list = g_list_prepend (object_list, slist->data);
}
-
return object_list;
}
-
static void
list_objects (gpointer key,
gpointer value,
gpointer user_data)
{
gpointer *data = (void**) user_data;
-
for (GSList *slist = (GSList*) value; slist; slist = slist->next)
if (g_type_is_a (BSE_OBJECT_TYPE (slist->data), GType (data[1])))
data[0] = g_list_prepend ((GList*) data[0], slist->data);
}
-
GList* /* list_free result */
bse_objects_list (GType type)
{
@@ -497,7 +425,6 @@ bse_objects_list (GType type)
}
return NULL;
}
-
static gboolean
object_check_pspec_editable (BseObject *object,
GParamSpec *pspec)
@@ -510,7 +437,6 @@ object_check_pspec_editable (BseObject *object,
else
return TRUE;
}
-
gboolean
bse_object_editable_property (gpointer object,
const gchar *property)
@@ -520,44 +446,32 @@ bse_object_editable_property (gpointer object,
return FALSE;
return BSE_OBJECT_GET_CLASS (object)->check_pspec_editable ((BseObject*) object, pspec);
}
-
void
bse_object_notify_icon_changed (BseObject *object)
{
g_return_if_fail (BSE_IS_OBJECT (object));
-
g_signal_emit (object, object_signals[SIGNAL_ICON_CHANGED], 0);
}
-
BseIcon*
bse_object_get_icon (BseObject *object)
{
BseIcon *icon;
-
g_return_val_if_fail (BSE_IS_OBJECT (object), NULL);
-
g_object_ref (object);
-
icon = BSE_OBJECT_GET_CLASS (object)->get_icon (object);
-
g_object_unref (object);
-
return icon;
}
-
static BseIcon*
bse_object_do_get_icon (BseObject *object)
{
BseIcon *icon;
-
g_return_val_if_fail (BSE_IS_OBJECT (object), NULL);
-
icon = (BseIcon*) g_object_get_qdata (G_OBJECT (object), bse_quark_icon);
if (!icon)
{
BseCategorySeq *cseq;
guint i;
-
/* FIXME: this is a bit of a hack, we could store the first per-type
* category icon as static type-data and fetch that from here
*/
@@ -573,13 +487,11 @@ bse_object_do_get_icon (BseObject *object)
}
return icon;
}
-
static void
bse_object_store_private (BseObject *object,
BseStorage *storage)
{
}
-
void
bse_object_restore_start (BseObject *object,
BseStorage *storage)
@@ -592,13 +504,11 @@ bse_object_restore_start (BseObject *object,
BSE_OBJECT_GET_CLASS (object)->restore_start (object, storage);
}
}
-
static void
object_restore_start (BseObject *object,
BseStorage *storage)
{
}
-
static GTokenType
object_restore_private (BseObject *object,
BseStorage *storage,
@@ -606,7 +516,6 @@ object_restore_private (BseObject *object,
{
return SFI_TOKEN_UNMATCHED;
}
-
static void
object_restore_finish (BseObject *object,
guint vmajor,
@@ -614,7 +523,6 @@ object_restore_finish (BseObject *object,
guint vmicro)
{
}
-
void
bse_object_restore_finish (BseObject *object,
guint vmajor,
@@ -627,7 +535,6 @@ bse_object_restore_finish (BseObject *object,
BSE_OBJECT_UNSET_FLAGS (object, BSE_OBJECT_FLAG_IN_RESTORE);
}
}
-
typedef struct {
GClosure closure;
guint dest_signal;
@@ -638,7 +545,6 @@ typedef struct {
guint src_signal;
guint src_detail;
} EClosure;
-
static guint
eclosure_hash (gconstpointer c)
{
@@ -651,7 +557,6 @@ eclosure_hash (gconstpointer c)
h += e->dest_signal << 13;
return h;
}
-
static gint
eclosure_equals (gconstpointer c1,
gconstpointer c2)
@@ -664,7 +569,6 @@ eclosure_equals (gconstpointer c1,
e1->src_signal == e2->src_signal &&
e1->dest_signal == e2->dest_signal);
}
-
static void
eclosure_marshal (GClosure *closure,
GValue /*out*/ *return_value,
@@ -679,7 +583,6 @@ eclosure_marshal (GClosure *closure,
else
g_object_notify ((GObject*) e->closure.data, g_quark_to_string (e->dest_detail));
}
-
void
bse_object_reemit_signal (gpointer src_object,
const gchar *src_signal,
@@ -732,7 +635,6 @@ bse_object_reemit_signal (gpointer src_object,
g_warning ("%s: invalid signal specs: \"%s\", \"%s\"",
G_STRLOC, src_signal, dest_signal);
}
-
void
bse_object_remove_reemit (gpointer src_object,
const gchar *src_signal,
@@ -752,7 +654,6 @@ bse_object_remove_reemit (gpointer src_object,
if (e)
{
g_return_if_fail (e->erefs > 0);
-
e->erefs--;
if (!e->erefs)
{
@@ -775,25 +676,20 @@ bse_object_remove_reemit (gpointer src_object,
g_warning ("%s: invalid signal specs: \"%s\", \"%s\"",
G_STRLOC, src_signal, dest_signal);
}
-
static void
bse_object_class_base_init (BseObjectClass *klass)
{
klass->editable_property = NULL;
}
-
static void
bse_object_class_base_finalize (BseObjectClass *klass)
{
}
-
static void
bse_object_class_init (BseObjectClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
bse_quark_uname = g_quark_from_static_string ("bse-object-uname");
bse_quark_icon = g_quark_from_static_string ("bse-object-icon");
quark_property_changed_queue = g_quark_from_static_string ("bse-property-changed-queue");
@@ -801,12 +697,10 @@ bse_object_class_init (BseObjectClass *klass)
object_unames_ht = g_hash_table_new (bse_string_hash, bse_string_equals);
eclosures_ht = g_hash_table_new (eclosure_hash, eclosure_equals);
object_id_ustore = sfi_ustore_new ();
-
gobject_class->set_property = bse_object_do_set_property;
gobject_class->get_property = bse_object_do_get_property;
gobject_class->dispose = bse_object_do_dispose;
gobject_class->finalize = bse_object_do_finalize;
-
klass->check_pspec_editable = object_check_pspec_editable;
klass->set_uname = bse_object_do_set_uname;
klass->store_private = bse_object_store_private;
@@ -815,7 +709,6 @@ bse_object_class_init (BseObjectClass *klass)
klass->restore_finish = object_restore_finish;
klass->unlocked = NULL;
klass->get_icon = bse_object_do_get_icon;
-
bse_object_class_add_param (klass, NULL,
PROP_UNAME,
sfi_pspec_string ("uname", _("Name"), _("Unique name of this object"),
@@ -831,29 +724,24 @@ bse_object_class_init (BseObjectClass *klass)
sfi_pspec_string ("blurb", _("Comment"), _("Free form comment or description"),
"",
SFI_PARAM_STANDARD ":skip-default"));
-
object_signals[SIGNAL_RELEASE] = bse_object_class_add_signal (klass, "release",
G_TYPE_NONE, 0);
object_signals[SIGNAL_ICON_CHANGED] = bse_object_class_add_signal (klass, "icon_changed",
G_TYPE_NONE, 0);
}
-
BSE_BUILTIN_TYPE (BseObject)
{
static const GTypeInfo object_info = {
sizeof (BseObjectClass),
-
(GBaseInitFunc) bse_object_class_base_init,
(GBaseFinalizeFunc) bse_object_class_base_finalize,
(GClassInitFunc) bse_object_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseObject),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_object_init,
};
-
return bse_type_register_abstract (G_TYPE_OBJECT,
"BseObject",
"BSE Object Hierarchy base type",
diff --git a/bse/bseobject.hh b/bse/bseobject.hh
index 5581d1a..928fea8 100644
--- a/bse/bseobject.hh
+++ b/bse/bseobject.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_OBJECT_H__
#define __BSE_OBJECT_H__
-
#include <bse/bseparam.hh>
-
G_BEGIN_DECLS
-
/* --- BSE type macros --- */
#define BSE_TYPE_OBJECT (BSE_TYPE_ID (BseObject))
#define BSE_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_OBJECT, BseObject))
@@ -13,7 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_OBJECT))
#define BSE_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_OBJECT))
#define BSE_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_OBJECT, BseObjectClass))
-
/* --- object member/convenience macros --- */
#define BSE_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
#define BSE_OBJECT_TYPE_NAME(object) (g_type_name (BSE_OBJECT_TYPE (object)))
@@ -25,7 +21,6 @@ G_BEGIN_DECLS
#define BSE_OBJECT_DISPOSING(object) ((BSE_OBJECT_FLAGS (object) & BSE_OBJECT_FLAG_DISPOSING) > 0)
#define BSE_OBJECT_IN_RESTORE(object) ((BSE_OBJECT_FLAGS (object) & BSE_OBJECT_FLAG_IN_RESTORE) > 0)
#define BSE_OBJECT_ID(object) (((BseObject*) (object))->unique_id)
-
/* --- object flags --- */
typedef enum /*< skip >*/
{
@@ -35,12 +30,10 @@ typedef enum /*< skip >*/
} BseObjectFlags;
#define BSE_OBJECT_FLAGS_USHIFT (3)
#define BSE_OBJECT_FLAGS_MAX_SHIFT (16)
-
/* --- typedefs & structures --- */
struct _BseObject
{
GObject parent_instance;
-
/* pack into one guint */
guint16 flags;
guint16 lock_count;
@@ -49,7 +42,6 @@ struct _BseObject
struct _BseObjectClass
{
GObjectClass parent_class;
-
gboolean (*editable_property) (BseObject *object, /* for set_property/get_property implementations */
guint param_id,
GParamSpec *pspec);
@@ -72,7 +64,6 @@ struct _BseObjectClass
void (*unlocked) (BseObject *object);
BseIcon* (*get_icon) (BseObject *object);
};
-
/* --- object class API ---*/
void bse_object_class_add_property (BseObjectClass *oclass,
const gchar *property_group,
@@ -97,8 +88,6 @@ guint bse_object_class_add_dsignal (BseObjectClass *oclass,
GType return_type,
guint n_params,
...);
-
-
/* --- object API --- */
void bse_object_lock (gpointer object);
void bse_object_unlock (gpointer object);
@@ -143,8 +132,6 @@ bse_object_unproxy_notifies (gpointer src_object,
bse_object_remove_reemit (src_object, "notify::uname", dest_object, dest_signal);
bse_object_remove_reemit (src_object, "icon-changed", dest_object, dest_signal);
}
-
-
/* --- implementation details --- */
extern GQuark bse_quark_uname;
void bse_object_marshal_signal (GClosure *closure,
@@ -153,7 +140,5 @@ void bse_object_marshal_signal (GClosure *closure,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
-
G_END_DECLS
-
#endif /* __BSE_OBJECT_H__ */
diff --git a/bse/bseparam.cc b/bse/bseparam.cc
index 36d0140..29e9a3f 100644
--- a/bse/bseparam.cc
+++ b/bse/bseparam.cc
@@ -1,21 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseparam.hh"
#include "bseobject.hh"
-
-
#define NULL_CHECKED(x) ((x) && (x)[0] ? x : NULL)
-
/* --- prototypes --- */
extern void bse_param_types_init (void); /* sync with btype.cc */
-
-
/* --- type initialization --- */
void
bse_param_types_init (void) /* sync with btype.cc */
{
}
-
-
/* --- object param specs --- */
GParamSpec*
bse_param_spec_object (const gchar *name,
@@ -25,16 +18,12 @@ bse_param_spec_object (const gchar *name,
const gchar *hints)
{
GParamSpec *pspec;
-
g_return_val_if_fail (g_type_is_a (object_type, BSE_TYPE_OBJECT), NULL);
-
pspec = g_param_spec_object (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), object_type, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
sfi_pspec_add_option (pspec, "skip-default", "+");
-
return pspec;
}
-
GValue*
bse_value_object (gpointer vobject)
{
@@ -43,8 +32,6 @@ bse_value_object (gpointer vobject)
bse_value_set_object (value, vobject);
return value;
}
-
-
/* --- convenience pspec constructors --- */
GParamSpec*
bse_param_spec_freq (const gchar *name,
@@ -67,13 +54,11 @@ bse_param_spec_freq (const gchar *name,
gdouble center = 2 * BSE_KAMMER_FREQUENCY, base = 2, n_steps = 4;
g_return_val_if_fail (max_freq >= 15053, NULL); /* Ais+6 with A+1=444Hz */
g_return_val_if_fail (min_freq <= 51.9, NULL); /* As-1 with A+1=440Hz */
-
GParamSpec *pspec = sfi_pspec_log_scale (name, nick, blurb,
default_freq, min_freq, max_freq, 10.0,
center, base, n_steps, hints);
return pspec;
}
-
GParamSpec*
bse_param_spec_boxed (const gchar *name,
const gchar *nick,
@@ -82,9 +67,7 @@ bse_param_spec_boxed (const gchar *name,
const gchar *hints)
{
GParamSpec *pspec = NULL;
-
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
-
if (sfi_boxed_type_get_rec_fields (boxed_type).n_fields ||
sfi_boxed_type_get_seq_element (boxed_type))
{
diff --git a/bse/bseparam.hh b/bse/bseparam.hh
index 7ddb459..769dd99 100644
--- a/bse/bseparam.hh
+++ b/bse/bseparam.hh
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PARAM_H__
#define __BSE_PARAM_H__
-
#include <bse/bsetype.hh>
#include <bse/bseutils.hh>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object param specs --- */
#define BSE_TYPE_PARAM_OBJECT (G_TYPE_PARAM_OBJECT)
#define BSE_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), BSE_TYPE_PARAM_OBJECT))
@@ -21,14 +16,11 @@ GParamSpec* bse_param_spec_object (const gchar *name,
const gchar *blurb,
GType object_type,
const gchar *hints);
-
#define BSE_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), BSE_TYPE_OBJECT))
#define bse_value_get_object g_value_get_object
#define bse_value_set_object g_value_set_object
#define bse_value_take_object g_value_take_object
GValue* bse_value_object (gpointer vobject);
-
-
/* --- boxed parameters --- */
typedef GParamSpecBoxed BseParamSpecBoxed;
#define BSE_TYPE_PARAM_BOXED (G_TYPE_PARAM_BOXED)
@@ -44,8 +36,6 @@ GParamSpec* bse_param_spec_boxed (const gchar *name,
#define bse_value_set_boxed g_value_set_boxed
#define bse_value_dup_boxed g_value_dup_boxed
#define bse_value_take_boxed g_value_take_boxed
-
-
/* --- convenience pspec constructors --- */
GParamSpec* bse_param_spec_freq (const gchar *name,
const gchar *nick,
@@ -54,10 +44,7 @@ GParamSpec* bse_param_spec_freq (const gchar *name,
SfiReal min_freq,
SfiReal max_freq,
const gchar *hints);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_PARAM_H__ */
diff --git a/bse/bseparasite.cc b/bse/bseparasite.cc
index 00a3a2f..8cb2f53 100644
--- a/bse/bseparasite.cc
+++ b/bse/bseparasite.cc
@@ -4,7 +4,6 @@
#include "bsestorage.hh"
#include <sfi/gbsearcharray.hh>
#include <string.h>
-
typedef struct {
const gchar *path;
SfiRec *rec;
@@ -17,8 +16,6 @@ struct _BseParasite {
GBSearchArray *nodes;
GBSearchArray *crefs;
};
-
-
/* --- prototypes --- */
static gint parasite_node_cmp (gconstpointer bsn1,
gconstpointer bsn2);
@@ -36,8 +33,6 @@ static void parasite_ref_seq (BseItem *item,
static void parasite_unref_seq (BseItem *item,
const gchar *path,
SfiSeq *seq);
-
-
/* --- variables --- */
static guint signal_parasites_added = 0;
static guint signal_parasite_changed = 0;
@@ -51,8 +46,6 @@ static const GBSearchConfig bconfig_crefs = {
parasite_cref_cmp,
G_BSEARCH_ARRAY_AUTO_SHRINK
};
-
-
/* --- functions --- */
void
bse_item_class_add_parasite_signals (BseItemClass *klass)
@@ -63,7 +56,6 @@ bse_item_class_add_parasite_signals (BseItemClass *klass)
signal_parasite_changed = bse_object_class_add_dsignal (object_class, "parasite-changed",
G_TYPE_NONE, 1, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
}
-
static gint
parasite_node_cmp (gconstpointer bsn1,
gconstpointer bsn2)
@@ -72,7 +64,6 @@ parasite_node_cmp (gconstpointer bsn1,
const Node *n2 = (const Node*) bsn2;
return strcmp (n1->path, n2->path);
}
-
static void
parasite_init (BseItem *item)
{
@@ -81,7 +72,6 @@ parasite_init (BseItem *item)
item->parasite->nodes = g_bsearch_array_create (&bconfig_nodes);
item->parasite->crefs = g_bsearch_array_create (&bconfig_crefs);
}
-
static gint
parasite_cref_cmp (gconstpointer bsn1,
gconstpointer bsn2)
@@ -90,7 +80,6 @@ parasite_cref_cmp (gconstpointer bsn1,
const CRef *r2 = (const CRef*) bsn2;
return G_BSEARCH_ARRAY_CMP (r1->link, r2->link);
}
-
static void
parasite_uncross_object (BseItem *item,
BseItem *link)
@@ -106,7 +95,6 @@ parasite_uncross_object (BseItem *item,
cref = (CRef*) g_bsearch_array_lookup (item->parasite->crefs, &bconfig_crefs, &key);
}
}
-
static void
parasite_ref_object (BseItem *item,
const gchar *path,
@@ -123,7 +111,6 @@ parasite_ref_object (BseItem *item,
}
cref->paths = g_slist_prepend (cref->paths, (gchar*) g_intern_string (path));
}
-
static void
parasite_unref_object (BseItem *item,
const gchar *path,
@@ -143,7 +130,6 @@ parasite_unref_object (BseItem *item,
bse_item_cross_unlink (item, link, parasite_uncross_object);
}
}
-
static inline void
parasite_ref_value (BseItem *item,
const gchar *path,
@@ -168,7 +154,6 @@ parasite_ref_value (BseItem *item,
parasite_ref_seq (item, path, cseq);
}
}
-
static inline void
parasite_unref_value (BseItem *item,
const gchar *path,
@@ -193,7 +178,6 @@ parasite_unref_value (BseItem *item,
parasite_unref_seq (item, path, cseq);
}
}
-
static void
parasite_ref_seq (BseItem *item,
const gchar *path,
@@ -203,7 +187,6 @@ parasite_ref_seq (BseItem *item,
for (i = 0; i < seq->n_elements; i++)
parasite_ref_value (item, path, seq->elements + i);
}
-
static void
parasite_unref_seq (BseItem *item,
const gchar *path,
@@ -213,7 +196,6 @@ parasite_unref_seq (BseItem *item,
for (i = 0; i < seq->n_elements; i++)
parasite_unref_value (item, path, seq->elements + i);
}
-
static void
parasite_ref_rec (BseItem *item,
const gchar *path,
@@ -223,7 +205,6 @@ parasite_ref_rec (BseItem *item,
for (i = 0; i < rec->n_fields; i++)
parasite_ref_value (item, path, rec->fields + i);
}
-
static void
parasite_unref_rec (BseItem *item,
const gchar *path,
@@ -233,7 +214,6 @@ parasite_unref_rec (BseItem *item,
for (i = 0; i < rec->n_fields; i++)
parasite_unref_value (item, path, rec->fields + i);
}
-
void
bse_item_set_parasite (BseItem *item,
const gchar *parasite_path,
@@ -291,7 +271,6 @@ bse_item_set_parasite (BseItem *item,
if (((GObject*) item)->ref_count)
g_signal_emit (item, signal_parasite_changed, g_quark_from_string (parasite_path), parasite_path);
}
-
SfiRec*
bse_item_get_parasite (BseItem *item,
const gchar *parasite_path)
@@ -306,7 +285,6 @@ bse_item_get_parasite (BseItem *item,
}
return NULL;
}
-
static void
undo_set_parasite (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -316,7 +294,6 @@ undo_set_parasite (BseUndoStep *ustep,
SfiRec *rec = (SfiRec*) ustep->data[2].v_pointer;
bse_item_set_parasite (item, path, rec);
}
-
static void
unde_free_parasite (BseUndoStep *ustep)
{
@@ -325,7 +302,6 @@ unde_free_parasite (BseUndoStep *ustep)
if (rec)
sfi_rec_unref (rec);
}
-
void
bse_item_backup_parasite (BseItem *item,
const gchar *parasite_path,
@@ -343,7 +319,6 @@ bse_item_backup_parasite (BseItem *item,
bse_undo_stack_push (ustack, ustep);
bse_item_undo_close (ustack);
}
-
void
bse_item_delete_parasites (BseItem *item)
{
@@ -362,7 +337,6 @@ bse_item_delete_parasites (BseItem *item)
item->parasite = NULL;
}
}
-
SfiRing*
bse_item_list_parasites (BseItem *item,
const gchar *parent_path)
@@ -392,7 +366,6 @@ bse_item_list_parasites (BseItem *item,
}
return ring;
}
-
const gchar*
bse_item_create_parasite_name (BseItem *item,
const gchar *path_prefix)
@@ -419,21 +392,15 @@ bse_item_create_parasite_name (BseItem *item,
}
return NULL;
}
-
-
/* --- old parasites --- */
#define MAX_PARASITE_VALUES (1024) /* (2 << 24) */
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
/* --- types --- */
enum
{
PARASITE_FLOAT = 'f',
};
-
-
/* --- structures --- */
typedef struct _ParasiteList ParasiteList;
typedef struct _Parasite Parasite;
@@ -449,12 +416,8 @@ struct _ParasiteList
guint n_parasites;
Parasite parasites[1];
};
-
-
/* --- variables --- */
static GQuark quark_parasite_list = 0;
-
-
/* --- functions --- */
void
bse_parasite_store (BseObject *object,
@@ -467,10 +430,8 @@ bse_parasite_store (BseObject *object,
{
Parasite *parasite = list->parasites + n;
gchar *name;
-
if (!parasite->n_values)
continue;
-
bse_storage_break (storage);
name = g_strescape (g_quark_to_string (parasite->quark), NULL);
bse_storage_printf (storage, "(parasite %c \"%s\"",
@@ -501,19 +462,16 @@ bse_parasite_store (BseObject *object,
bse_storage_putc (storage, ')');
}
}
-
static void
parasite_list_free (gpointer data)
{
ParasiteList *list = (ParasiteList*) data;
guint i;
-
for (i = 0; i < list->n_parasites; i++)
if (list->parasites[i].n_values)
g_free (list->parasites[i].data);
g_free (list);
}
-
static Parasite*
fetch_parasite (BseObject *object,
GQuark quark,
@@ -536,23 +494,18 @@ fetch_parasite (BseObject *object,
{
if (!quark_parasite_list)
quark_parasite_list = g_quark_from_static_string ("BseParasiteList");
-
if (olist)
g_object_steal_qdata ((GObject*) object, quark_parasite_list);
g_object_set_qdata_full ((GObject*) object, quark_parasite_list, list, parasite_list_free);
}
-
list->parasites[i].quark = quark;
list->parasites[i].type = type;
list->parasites[i].n_values = 0;
list->parasites[i].data = NULL;
-
return list->parasites + i;
}
-
return NULL;
}
-
static void
delete_parasite (BseObject *object,
GQuark quark,
@@ -577,7 +530,6 @@ delete_parasite (BseObject *object,
else if (list->n_parasites == 0)
g_object_set_qdata ((GObject*) object, quark_parasite_list, NULL);
}
-
GTokenType
bse_parasite_restore (BseObject *object,
BseStorage *storage)
@@ -587,31 +539,25 @@ bse_parasite_restore (BseObject *object,
GTokenType ttype;
guint n_values;
gpointer data;
-
/* check identifier */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER ||
!bse_string_equals ("parasite", scanner->next_value.v_identifier))
return SFI_TOKEN_UNMATCHED;
-
/* eat "parasite" identifier */
g_scanner_get_next_token (scanner);
-
/* parse parasite type */
g_scanner_get_next_token (scanner);
if (!(scanner->token >= 'a' && scanner->token <= 'z'))
return G_TOKEN_CHAR;
ttype = scanner->token;
-
/* parse parasite name */
if (g_scanner_get_next_token (scanner) != G_TOKEN_STRING)
return G_TOKEN_STRING;
quark = g_quark_from_string (scanner->value.v_string);
-
switch ((uint) ttype)
{
guint i;
gfloat *floats;
-
case PARASITE_FLOAT:
if (g_scanner_get_next_token (scanner) != G_TOKEN_INT)
return G_TOKEN_INT;
@@ -623,7 +569,6 @@ bse_parasite_restore (BseObject *object,
{
gboolean negate = FALSE;
gfloat vfloat;
-
if (g_scanner_get_next_token (scanner) == '-')
{
g_scanner_get_next_token (scanner);
@@ -662,7 +607,6 @@ bse_parasite_restore (BseObject *object,
/* read closing brace */
return g_scanner_get_next_token (scanner) == ')' ? G_TOKEN_NONE : GTokenType (')');
}
-
void
bse_parasite_set_floats (BseObject *object,
const gchar *name,
@@ -674,7 +618,6 @@ bse_parasite_set_floats (BseObject *object,
g_return_if_fail (n_values < MAX_PARASITE_VALUES);
if (n_values)
g_return_if_fail (float_values != NULL);
-
if (!n_values)
delete_parasite (object, g_quark_try_string (name), PARASITE_FLOAT);
else
@@ -683,7 +626,6 @@ bse_parasite_set_floats (BseObject *object,
g_quark_from_string (name),
PARASITE_FLOAT,
TRUE);
-
if (parasite->n_values != n_values)
{
if (parasite->n_values)
@@ -694,7 +636,6 @@ bse_parasite_set_floats (BseObject *object,
memcpy (parasite->data, float_values, n_values * sizeof (gfloat));
}
}
-
SfiFBlock*
bse_parasite_get_floats (BseObject *object,
const gchar *name)
diff --git a/bse/bseparasite.hh b/bse/bseparasite.hh
index a73a48c..8b9d8ae 100644
--- a/bse/bseparasite.hh
+++ b/bse/bseparasite.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PARASITE_H__
#define __BSE_PARASITE_H__
-
#include <bse/bseitem.hh>
-
G_BEGIN_DECLS
-
/* --- parasite records --- */
void bse_item_set_parasite (BseItem *item, /* undoable */
const gchar *parasite_path,
@@ -27,8 +24,6 @@ const gchar* bse_item_create_parasite_name (BseItem *item,
* const gchar *parasite_path);
*/
void bse_item_class_add_parasite_signals (BseItemClass *);
-
-
/* --- old prototypes --- */
void bse_parasite_set_floats (BseObject *object,
const gchar *name,
@@ -40,7 +35,5 @@ void bse_parasite_store (BseObject *object,
BseStorage *storage);
GTokenType bse_parasite_restore (BseObject *object,
BseStorage *storage);
-
G_END_DECLS
-
#endif /* __BSE_PARASITE_H__ */
diff --git a/bse/bseparasite.proc b/bse/bseparasite.proc
index 8a156cd..2214227 100644
--- a/bse/bseparasite.proc
+++ b/bse/bseparasite.proc
@@ -3,10 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bseexports.hh>
#include "bsecxxplugin.hh"
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
METHOD (BseItem, list-parasites) {
HELP = "List parasites within a parasite path segment.";
IN = bse_param_spec_object ("item", _("Item"), NULL, BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
@@ -29,7 +27,6 @@ METHOD (BseItem, list-parasites) {
bse_value_take_boxed (out_values++, sseq);
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, get-parasite) {
SfiRecFields zero_fields = { 0, };
HELP = "Retrieve a parasite from an item.";
@@ -47,7 +44,6 @@ METHOD (BseItem, get-parasite) {
sfi_value_set_rec (out_values++, bse_item_get_parasite (item, path));
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, set-parasite) {
SfiRecFields zero_fields = { 0, };
HELP = "Set or change a parasite on an item.";
@@ -66,7 +62,6 @@ METHOD (BseItem, set-parasite) {
bse_item_set_parasite (item, path, rec);
return BSE_ERROR_NONE;
}
-
METHOD (BseItem, add-parasite) {
SfiRecFields zero_fields = { 0, };
HELP = "Add a new parasite to an item.";
diff --git a/bse/bsepart.cc b/bse/bsepart.cc
index 89816be..d6951be 100644
--- a/bse/bsepart.cc
+++ b/bse/bsepart.cc
@@ -10,13 +10,10 @@
#include "bseieee754.hh"
#include <stdlib.h>
#include <string.h>
-
/* --- macros --- */
#define upper_power2(uint_n) sfi_alloc_upper_power2 (MAX ((uint_n), 4))
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
/* --- properties --- */
enum
{
@@ -24,8 +21,6 @@ enum
PROP_N_CHANNELS,
PROP_LAST_TICK,
};
-
-
/* --- prototypes --- */
static void bse_part_class_init (BsePartClass *klass);
static void bse_part_init (BsePart *self);
@@ -44,8 +39,6 @@ static void bse_part_store_private (BseObject *object,
static GTokenType bse_part_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static guint signal_range_changed = 0;
@@ -58,54 +51,43 @@ static GQuark quark_insert_note = 0;
static GQuark quark_insert_notes = 0;
static GQuark quark_insert_control = 0;
static GQuark quark_insert_controls = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BsePart)
{
static const GTypeInfo info = {
sizeof (BsePartClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_part_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BsePart),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_part_init,
};
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BsePart",
"BSE part type",
__FILE__, __LINE__,
&info);
}
-
static void
bse_part_class_init (BsePartClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
// BseItemClass *item_class = BSE_ITEM_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_part_set_property;
gobject_class->get_property = bse_part_get_property;
gobject_class->dispose = bse_part_dispose;
gobject_class->finalize = bse_part_finalize;
-
object_class->store_private = bse_part_store_private;
object_class->restore_private = bse_part_restore_private;
-
quark_insert_note = g_quark_from_static_string ("insert-note");
quark_insert_notes = g_quark_from_static_string ("insert-notes");
quark_insert_control = g_quark_from_static_string ("insert-control");
quark_insert_controls = g_quark_from_static_string ("insert-controls");
-
bse_object_class_add_param (object_class, "Limits",
PROP_N_CHANNELS,
sfi_pspec_int ("n_channels", "Channels", NULL,
@@ -116,14 +98,12 @@ bse_part_class_init (BsePartClass *klass)
sfi_pspec_int ("last_tick", "Last Tick", NULL,
0, 0, BSE_PART_MAX_TICK, 384,
SFI_PARAM_GUI_READABLE));
-
signal_range_changed = bse_object_class_add_signal (object_class, "range-changed",
G_TYPE_NONE, 4,
G_TYPE_INT, G_TYPE_INT,
G_TYPE_INT, G_TYPE_INT);
signal_links_changed = bse_object_class_add_signal (object_class, "links-changed", G_TYPE_NONE, 0);
}
-
static void
bse_part_init (BsePart *self)
{
@@ -143,7 +123,6 @@ bse_part_init (BsePart *self)
self->channels = g_renew (BsePartNoteChannel, self->channels, self->n_channels);
bse_part_note_channel_init (&self->channels[0]);
}
-
static void
part_add_channel (BsePart *self,
gboolean notify)
@@ -153,7 +132,6 @@ part_add_channel (BsePart *self,
bse_part_note_channel_init (&self->channels[i]);
g_object_notify ((GObject*) self, "n_channels");
}
-
static void
bse_part_set_property (GObject *object,
guint param_id,
@@ -179,7 +157,6 @@ bse_part_set_property (GObject *object,
break;
}
}
-
static void
bse_part_get_property (GObject *object,
guint param_id,
@@ -200,12 +177,10 @@ bse_part_get_property (GObject *object,
break;
}
}
-
static void
bse_part_dispose (GObject *object)
{
BsePart *self = BSE_PART (object);
-
plist_links_changed = sfi_ring_remove (plist_links_changed, self);
self->links_queued = FALSE;
plist_range_changed = sfi_ring_remove (plist_range_changed, self);
@@ -214,38 +189,30 @@ bse_part_dispose (GObject *object)
self->range_bound = 0;
self->range_min_note = BSE_MAX_NOTE;
self->range_max_note = 0;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_part_finalize (GObject *object)
{
BsePart *self = BSE_PART (object);
guint i;
-
self->links_queued = TRUE;
plist_links_changed = sfi_ring_remove (plist_links_changed, self);
self->range_queued = TRUE;
plist_range_changed = sfi_ring_remove (plist_range_changed, self);
-
self->n_ids = 0;
g_free (self->ids);
self->ids = NULL;
self->last_id = 0;
-
bse_part_controls_destroy (&self->controls);
-
for (i = 0; i < self->n_channels; i++)
bse_part_note_channel_destroy (&self->channels[i]);
g_free (self->channels);
self->channels = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
void
bse_part_set_semitone_table (BsePart *self,
const double *semitone_table)
@@ -254,15 +221,12 @@ bse_part_set_semitone_table (BsePart *self,
g_return_if_fail (semitone_table != NULL);
self->semitone_table = semitone_table;
}
-
static guint
bse_part_alloc_id (BsePart *self,
guint tick)
{
guint id;
-
g_return_val_if_fail (tick <= BSE_PART_MAX_TICK, 0);
-
/* we keep an array of ids to implement a fast lookup
* from id to tick of the event containing id. ticks
* >= BSE_PART_INVAL_TICK_FLAG indicate non-allocated
@@ -271,13 +235,10 @@ bse_part_alloc_id (BsePart *self,
* were freed in, to provide deterministic id assignment
* for state rollbacks as required by undo.
*/
-
if (self->last_id)
{
guint i = self->last_id - 1;
-
g_assert (self->ids[i] >= BSE_PART_INVAL_TICK_FLAG);
-
self->last_id = self->ids[i] - BSE_PART_INVAL_TICK_FLAG;
id = i + 1;
}
@@ -290,7 +251,6 @@ bse_part_alloc_id (BsePart *self,
self->ids[id - 1] = tick;
return id;
}
-
static void
bse_part_move_id (BsePart *self,
guint id,
@@ -299,31 +259,25 @@ bse_part_move_id (BsePart *self,
g_return_if_fail (tick <= BSE_PART_MAX_TICK);
g_return_if_fail (id > 0 && id <= self->n_ids);
g_return_if_fail (self->ids[id - 1] < BSE_PART_INVAL_TICK_FLAG); /* check !freed id */
-
self->ids[id - 1] = tick;
}
-
static void
bse_part_free_id (BsePart *self,
guint id)
{
guint i;
-
g_return_if_fail (id > 0 && id <= self->n_ids);
g_return_if_fail (self->ids[id - 1] < BSE_PART_INVAL_TICK_FLAG); /* check !freed id */
-
i = id - 1;
self->ids[i] = self->last_id + BSE_PART_INVAL_TICK_FLAG;
self->last_id = id;
}
-
static guint /* returns tick (<= BSE_PART_MAX_TICK) if id is valid */
bse_part_tick_from_id (BsePart *self,
guint id)
{
return id > 0 && id <= self->n_ids ? self->ids[id - 1] : BSE_PART_INVAL_TICK_FLAG;
}
-
static void
part_update_last_tick (BsePart *self)
{
@@ -340,7 +294,6 @@ part_update_last_tick (BsePart *self)
g_object_notify ((GObject*) self, "last-tick");
bse_part_links_changed (self);
}
-
static gboolean
range_changed_notify_handler (gpointer data)
{
@@ -350,7 +303,6 @@ range_changed_notify_handler (gpointer data)
self->range_queued = FALSE;
guint tick = self->range_tick, duration = self->range_bound - tick;
gint min_note = self->range_min_note, max_note = self->range_max_note;
-
self->range_tick = BSE_PART_MAX_TICK;
self->range_bound = 0;
self->range_min_note = BSE_MAX_NOTE;
@@ -359,10 +311,8 @@ range_changed_notify_handler (gpointer data)
g_signal_emit (self, signal_range_changed, 0, tick, duration, min_note, max_note);
}
handler_id_range_changed = 0;
-
return FALSE;
}
-
static void
queue_update (BsePart *self,
guint tick,
@@ -370,9 +320,7 @@ queue_update (BsePart *self,
gint note)
{
guint bound = tick + duration;
-
g_return_if_fail (duration > 0);
-
if (!BSE_OBJECT_DISPOSING (self))
{
if (self->range_tick >= self->range_bound && !self->range_queued)
@@ -388,20 +336,17 @@ queue_update (BsePart *self,
self->range_max_note = MAX (self->range_max_note, note);
}
}
-
static void
queue_note_update (BsePart *self,
BsePartEventNote *note)
{
queue_update (self, note->tick, note->duration, note->note);
}
-
static void
queue_control_update (BsePart *self,
guint tick)
{
guint bound = tick + 1;
-
if (!BSE_OBJECT_DISPOSING (self))
{
if (self->range_tick >= self->range_bound && !self->range_queued)
@@ -417,7 +362,6 @@ queue_control_update (BsePart *self,
self->range_max_note = BSE_MAX_NOTE;
}
}
-
static gboolean
links_changed_notify_handler (gpointer data)
{
@@ -428,10 +372,8 @@ links_changed_notify_handler (gpointer data)
g_signal_emit (self, signal_links_changed, 0);
}
handler_id_links_changed = 0;
-
return FALSE;
}
-
void
bse_part_links_changed (BsePart *self)
{
@@ -444,7 +386,6 @@ bse_part_links_changed (BsePart *self)
handler_id_links_changed = bse_idle_update (links_changed_notify_handler, NULL);
}
}
-
static int
part_link_compare (const void *p1,
const void *p2)
@@ -463,7 +404,6 @@ part_link_compare (const void *p1,
else
return l1->tick < l2->tick ? -1 : 1;
}
-
BsePartLinkSeq*
bse_part_list_links (BsePart *self)
{
@@ -493,7 +433,6 @@ bse_part_list_links (BsePart *self)
}
return pls;
}
-
void
bse_part_select_notes (BsePart *self,
guint match_channel,
@@ -506,7 +445,6 @@ bse_part_select_notes (BsePart *self,
guint channel;
g_return_if_fail (BSE_IS_PART (self));
selected = selected != FALSE;
-
min_note = BSE_NOTE_CLAMP (min_note);
max_note = BSE_NOTE_CLAMP (max_note);
for (channel = 0; channel < self->n_channels; channel++)
@@ -530,7 +468,6 @@ bse_part_select_notes (BsePart *self,
}
}
}
-
void
bse_part_select_controls (BsePart *self,
guint tick,
@@ -540,13 +477,11 @@ bse_part_select_controls (BsePart *self,
{
g_return_if_fail (BSE_IS_PART (self));
selected = selected != FALSE;
-
if (BSE_PART_NOTE_CONTROL (ctype))
{
bse_part_select_notes (self, ~0, tick, duration, BSE_MIN_NOTE, BSE_MAX_NOTE, selected);
return;
}
-
BsePartTickNode *node = bse_part_controls_lookup_ge (&self->controls, tick);
if (!node)
return;
@@ -563,7 +498,6 @@ bse_part_select_controls (BsePart *self,
node++;
}
}
-
void
bse_part_select_notes_exclusive (BsePart *self,
guint match_channel,
@@ -575,7 +509,6 @@ bse_part_select_notes_exclusive (BsePart *self,
BsePartTickNode *node, *cbound;
guint channel;
g_return_if_fail (BSE_IS_PART (self));
-
min_note = BSE_NOTE_CLAMP (min_note);
max_note = BSE_NOTE_CLAMP (max_note);
for (channel = 0; channel < self->n_channels; channel++)
@@ -596,7 +529,6 @@ bse_part_select_notes_exclusive (BsePart *self,
note++;
}
}
-
/* deselect all control events */
node = bse_part_controls_lookup_ge (&self->controls, tick);
if (!node)
@@ -614,7 +546,6 @@ bse_part_select_notes_exclusive (BsePart *self,
node++;
}
}
-
void
bse_part_select_controls_exclusive (BsePart *self,
guint tick,
@@ -622,17 +553,13 @@ bse_part_select_controls_exclusive (BsePart *self,
BseMidiSignalType ctype)
{
BsePartTickNode *node, *bound;
-
g_return_if_fail (BSE_IS_PART (self));
-
if (BSE_PART_NOTE_CONTROL (ctype))
{
bse_part_select_notes_exclusive (self, ~0, tick, duration, BSE_MIN_NOTE, BSE_MAX_NOTE);
return;
}
-
bse_part_select_notes (self, ~0, 0, BSE_PART_MAX_TICK, BSE_MIN_NOTE, BSE_MAX_NOTE, FALSE);
-
node = bse_part_controls_lookup_ge (&self->controls, 0);
if (!node)
return;
@@ -655,7 +582,6 @@ bse_part_select_controls_exclusive (BsePart *self,
node++;
}
}
-
gboolean
bse_part_set_note_selected (BsePart *self,
guint id,
@@ -666,21 +592,17 @@ bse_part_set_note_selected (BsePart *self,
guint tick;
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
g_return_val_if_fail (channel < self->n_channels, FALSE);
-
tick = bse_part_tick_from_id (self, id);
if (tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
note = bse_part_note_channel_lookup (&self->channels[channel], tick);
if (!note || note->id != id)
return FALSE; /* invalid id or channel */
-
bse_part_note_channel_change_note (&self->channels[channel], note, note->id, selected,
note->note, note->fine_tune, note->velocity);
queue_note_update (self, note);
return TRUE;
}
-
gboolean
bse_part_set_control_selected (BsePart *self,
guint id,
@@ -690,11 +612,9 @@ bse_part_set_control_selected (BsePart *self,
guint tick;
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
selected = selected != FALSE;
-
tick = bse_part_tick_from_id (self, id);
if (tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
cev = bse_part_controls_lookup_event (&self->controls, tick, id);
if (cev)
{
@@ -708,7 +628,6 @@ bse_part_set_control_selected (BsePart *self,
else
return FALSE;
}
-
gboolean
bse_part_delete_note (BsePart *self,
guint id,
@@ -718,15 +637,12 @@ bse_part_delete_note (BsePart *self,
guint tick;
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
g_return_val_if_fail (channel < self->n_channels, FALSE);
-
tick = bse_part_tick_from_id (self, id);
if (tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
note = bse_part_note_channel_lookup (&self->channels[channel], tick);
if (!note || note->id != id)
return FALSE; /* invalid id or channel */
-
/* remove note */
queue_note_update (self, note);
tick = note->tick + note->duration;
@@ -736,7 +652,6 @@ bse_part_delete_note (BsePart *self,
part_update_last_tick (self);
return TRUE;
}
-
gboolean
bse_part_delete_control (BsePart *self,
guint id)
@@ -744,11 +659,9 @@ bse_part_delete_control (BsePart *self,
BsePartEventControl *cev;
guint tick;
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
-
tick = bse_part_tick_from_id (self, id);
if (tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
cev = bse_part_controls_lookup_event (&self->controls, tick, id);
if (cev)
{
@@ -762,7 +675,6 @@ bse_part_delete_control (BsePart *self,
else
return FALSE;
}
-
guint
bse_part_insert_note (BsePart *self,
guint channel,
@@ -779,7 +691,6 @@ bse_part_insert_note (BsePart *self,
channel = 0;
else if (channel >= self->n_channels)
g_object_set (self, "n_channels", channel + 1, NULL);
-
if (!(BSE_NOTE_IS_VALID (note) &&
BSE_FINE_TUNE_IS_VALID (fine_tune) &&
tick < BSE_PART_MAX_TICK &&
@@ -787,7 +698,6 @@ bse_part_insert_note (BsePart *self,
duration < BSE_PART_MAX_TICK &&
tick + duration <= BSE_PART_MAX_TICK))
return 0;
-
key.tick = tick;
key.id = bse_part_alloc_id (self, tick);
key.duration = duration;
@@ -811,10 +721,8 @@ bse_part_insert_note (BsePart *self,
queue_note_update (self, &key);
if (key.tick + key.duration >= self->last_tick_SL)
part_update_last_tick (self);
-
return key.id;
}
-
static gboolean
check_valid_control_type (BseMidiSignalType ctype)
{
@@ -828,7 +736,6 @@ check_valid_control_type (BseMidiSignalType ctype)
return TRUE;
return FALSE;
}
-
guint
bse_part_insert_control (BsePart *self,
guint tick,
@@ -839,13 +746,11 @@ bse_part_insert_control (BsePart *self,
BsePartEventControl *cev;
guint id;
g_return_val_if_fail (BSE_IS_PART (self), BSE_ERROR_INTERNAL);
-
if (!(value >= -1 && value <= +1 &&
tick < BSE_PART_MAX_TICK &&
check_valid_control_type (ctype) &&
!BSE_PART_NOTE_CONTROL (ctype)))
return 0;
-
node = bse_part_controls_ensure_tick (&self->controls, tick);
/* coalesce multiple inserts */
for (cev = node->events; cev; cev = cev->next)
@@ -862,10 +767,8 @@ bse_part_insert_control (BsePart *self,
queue_control_update (self, tick);
if (tick >= self->last_tick_SL)
part_update_last_tick (self);
-
return id;
}
-
gboolean
bse_part_change_note (BsePart *self,
guint id,
@@ -879,12 +782,10 @@ bse_part_change_note (BsePart *self,
BsePartEventNote key = { 0 }, *note;
const bool use_any_channel = channel == ~uint (0);
guint i, old_tick;
-
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
if (use_any_channel)
channel = 0;
g_return_val_if_fail (channel < self->n_channels, FALSE);
-
if (!(BSE_NOTE_IS_VALID (vnote) && channel < self->n_channels &&
BSE_FINE_TUNE_IS_VALID (fine_tune) &&
tick < BSE_PART_MAX_TICK &&
@@ -892,11 +793,9 @@ bse_part_change_note (BsePart *self,
duration < BSE_PART_MAX_TICK &&
tick + duration <= BSE_PART_MAX_TICK))
return FALSE;
-
old_tick = bse_part_tick_from_id (self, id);
if (old_tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
/* ensure (target) tick is valid */
note = bse_part_note_channel_lookup (&self->channels[channel], tick);
if (note && note->id != id)
@@ -911,7 +810,6 @@ bse_part_change_note (BsePart *self,
part_add_channel (self, TRUE);
note = NULL;
}
-
/* find note */
if (!note)
{
@@ -926,7 +824,6 @@ bse_part_change_note (BsePart *self,
}
else
i = channel;
-
/* move note */
queue_note_update (self, note);
key.tick = tick;
@@ -949,10 +846,8 @@ bse_part_change_note (BsePart *self,
bse_part_note_channel_change_note (&self->channels[channel], note, key.id, key.selected,
key.note, key.fine_tune, key.velocity);
queue_note_update (self, &key);
-
return TRUE;
}
-
gboolean
bse_part_change_control (BsePart *self,
guint id,
@@ -962,16 +857,13 @@ bse_part_change_control (BsePart *self,
{
guint old_tick;
g_return_val_if_fail (BSE_IS_PART (self), FALSE);
-
if (!(tick < BSE_PART_MAX_TICK &&
check_valid_control_type (ctype) &&
value >= -1 && value <= +1))
return FALSE;
-
old_tick = bse_part_tick_from_id (self, id);
if (old_tick > BSE_PART_MAX_TICK)
return FALSE; /* invalid id */
-
if (!BSE_PART_NOTE_CONTROL (ctype))
{
BsePartEventControl *cev = NULL;
@@ -1037,7 +929,6 @@ bse_part_change_control (BsePart *self,
return FALSE;
}
}
-
static inline gfloat
note_get_control_value (BsePartEventNote *note,
BseMidiSignalType ctype)
@@ -1052,7 +943,6 @@ note_get_control_value (BsePartEventNote *note,
return 0;
}
}
-
BsePartEventType
bse_part_query_event (BsePart *self,
guint id,
@@ -1061,13 +951,10 @@ bse_part_query_event (BsePart *self,
BsePartEventNote *note = NULL;
BsePartEventControl *cev;
guint tick, channel;
-
g_return_val_if_fail (BSE_IS_PART (self), BSE_PART_EVENT_NONE);
-
tick = bse_part_tick_from_id (self, id);
if (tick > BSE_PART_MAX_TICK)
return BSE_PART_EVENT_NONE; /* invalid id */
-
/* lookup control */
cev = bse_part_controls_lookup_event (&self->controls, tick, id);
if (cev)
@@ -1090,7 +977,6 @@ bse_part_query_event (BsePart *self,
}
return BSE_PART_EVENT_CONTROL;
}
-
/* find note */
for (channel = 0; channel < self->n_channels; channel++)
{
@@ -1118,10 +1004,8 @@ bse_part_query_event (BsePart *self,
}
return BSE_PART_EVENT_NOTE;
}
-
return BSE_PART_EVENT_NONE;
}
-
static void
part_note_seq_append (BsePartNoteSeq *pseq,
guint channel,
@@ -1137,7 +1021,6 @@ part_note_seq_append (BsePartNoteSeq *pseq,
note->selected);
bse_part_note_seq_take_append (pseq, pnote);
}
-
static void
part_control_seq_append_note (BsePartControlSeq *cseq,
BsePartEventNote *note,
@@ -1150,7 +1033,6 @@ part_control_seq_append_note (BsePartControlSeq *cseq,
note->selected);
bse_part_control_seq_take_append (cseq, ctrl);
}
-
BsePartNoteSeq*
bse_part_list_notes (BsePart *self,
guint match_channel,
@@ -1164,11 +1046,9 @@ bse_part_list_notes (BsePart *self,
BsePartNoteSeq *pseq;
guint n, j, channel;
gulong *ids;
-
g_return_val_if_fail (BSE_IS_PART (self), NULL);
g_return_val_if_fail (tick < BSE_PART_MAX_TICK, NULL);
g_return_val_if_fail (duration > 0 && duration <= BSE_PART_MAX_TICK, NULL);
-
pseq = bse_part_note_seq_new ();
for (channel = 0; channel < self->n_channels; channel++)
{
@@ -1211,7 +1091,6 @@ bse_part_list_notes (BsePart *self,
}
return pseq;
}
-
BsePartControlSeq*
bse_part_list_controls (BsePart *self,
guint match_channel, /* for note events */
@@ -1220,11 +1099,9 @@ bse_part_list_controls (BsePart *self,
BseMidiSignalType ctype)
{
BsePartControlSeq *cseq;
-
g_return_val_if_fail (BSE_IS_PART (self), NULL);
g_return_val_if_fail (tick < BSE_PART_MAX_TICK, NULL);
g_return_val_if_fail (duration > 0 && duration <= BSE_PART_MAX_TICK, NULL);
-
cseq = bse_part_control_seq_new ();
if (BSE_PART_NOTE_CONTROL (ctype))
{
@@ -1266,7 +1143,6 @@ bse_part_list_controls (BsePart *self,
}
return cseq;
}
-
void
bse_part_queue_notes_within (BsePart *self,
guint tick,
@@ -1278,11 +1154,9 @@ bse_part_queue_notes_within (BsePart *self,
g_return_if_fail (BSE_IS_PART (self));
g_return_if_fail (tick < BSE_PART_MAX_TICK);
g_return_if_fail (duration > 0 && duration <= BSE_PART_MAX_TICK);
-
min_note = BSE_NOTE_CLAMP (min_note);
max_note = BSE_NOTE_CLAMP (max_note);
end_tick = tick + MAX (duration, 1);
-
/* widen area to right if notes span across right boundary */
for (channel = 0; channel < self->n_channels; channel++)
{
@@ -1301,19 +1175,15 @@ bse_part_queue_notes_within (BsePart *self,
end_tick = MAX (end_tick, note->tick + note->duration);
}
}
-
queue_update (self, tick, end_tick - tick, min_note);
queue_update (self, tick, end_tick - tick, max_note);
}
-
BsePartNoteSeq*
bse_part_list_selected_notes (BsePart *self)
{
BsePartNoteSeq *pseq;
guint channel;
-
g_return_val_if_fail (BSE_IS_PART (self), NULL);
-
pseq = bse_part_note_seq_new ();
for (channel = 0; channel < self->n_channels; channel++)
{
@@ -1326,17 +1196,14 @@ bse_part_list_selected_notes (BsePart *self)
note++;
}
}
-
return pseq;
}
-
BsePartControlSeq*
bse_part_list_selected_controls (BsePart *self,
BseMidiSignalType ctype)
{
BsePartControlSeq *cseq;
g_return_val_if_fail (BSE_IS_PART (self), NULL);
-
cseq = bse_part_control_seq_new ();
if (BSE_PART_NOTE_CONTROL (ctype))
{
@@ -1373,7 +1240,6 @@ bse_part_list_selected_controls (BsePart *self,
}
return cseq;
}
-
static void
bse_part_store_private (BseObject *object,
BseStorage *storage)
@@ -1382,11 +1248,9 @@ bse_part_store_private (BseObject *object,
BsePartTickNode *node, *bound;
gboolean statement_started = FALSE;
guint channel;
-
/* chain parent class' handler */
if (BSE_OBJECT_CLASS (parent_class)->store_private)
BSE_OBJECT_CLASS (parent_class)->store_private (object, storage);
-
for (channel = 0; channel < self->n_channels; channel++)
{
BsePartEventNote *note = bse_part_note_channel_lookup_ge (&self->channels[channel], 0);
@@ -1423,7 +1287,6 @@ bse_part_store_private (BseObject *object,
statement_started = FALSE;
}
}
-
node = bse_part_controls_lookup_ge (&self->controls, 0);
bound = bse_part_controls_get_bound (&self->controls);
while (node < bound)
@@ -1454,7 +1317,6 @@ bse_part_store_private (BseObject *object,
bse_storage_putc (storage, ')');
}
}
-
static GTokenType
bse_part_restore_private (BseObject *object,
BseStorage *storage,
@@ -1462,11 +1324,9 @@ bse_part_restore_private (BseObject *object,
{
BsePart *self = BSE_PART (object);
GQuark quark;
-
/* chain parent class' handler */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
-
/* parse storage commands */
quark = g_quark_try_string (scanner->next_value.v_identifier);
if (quark == quark_insert_notes)
@@ -1568,7 +1428,6 @@ bse_part_restore_private (BseObject *object,
gint fine_tune = 0;
gfloat velocity = 1.0;
gboolean negate;
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat identifier */
parse_or_return (scanner, G_TOKEN_INT);
tick = scanner->value.v_int64;
@@ -1591,7 +1450,6 @@ bse_part_restore_private (BseObject *object,
}
}
parse_or_return (scanner, ')');
-
if (!bse_part_insert_note (self, ~0, tick, duration, note, fine_tune, velocity))
bse_storage_warn (storage, "note insertion (note=%d tick=%u duration=%u) failed",
note, tick, duration);
@@ -1602,7 +1460,6 @@ bse_part_restore_private (BseObject *object,
guint tick, ctype;
gfloat value;
gboolean negate;
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat identifier */
parse_or_return (scanner, G_TOKEN_INT);
tick = scanner->value.v_int64;
@@ -1624,7 +1481,6 @@ bse_part_restore_private (BseObject *object,
else
return G_TOKEN_FLOAT;
parse_or_return (scanner, ')');
-
if (!bse_part_insert_control (self, tick, BseMidiSignalType (ctype), CLAMP (value, -1, +1)))
bse_storage_warn (storage, "skipping control event of invalid type: %d", ctype);
return G_TOKEN_NONE;
@@ -1632,8 +1488,6 @@ bse_part_restore_private (BseObject *object,
else /* chain parent class' handler */
return BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
}
-
-
/* --- BsePartControls --- */
static gint
part_controls_cmp_tick_nodes (gconstpointer bsearch_node1, /* key */
@@ -1643,19 +1497,16 @@ part_controls_cmp_tick_nodes (gconstpointer bsearch_node1, /* key */
const BsePartTickNode *n2 = (const BsePartTickNode*) bsearch_node2;
return G_BSEARCH_ARRAY_CMP (n1->tick, n2->tick);
}
-
static const GBSearchConfig controls_bsc = {
sizeof (BsePartTickNode),
part_controls_cmp_tick_nodes,
G_BSEARCH_ARRAY_ALIGN_POWER2,
};
-
void
bse_part_controls_init (BsePartControls *self)
{
self->bsa = g_bsearch_array_create (&controls_bsc);
}
-
BsePartTickNode*
bse_part_controls_lookup (BsePartControls *self,
guint tick)
@@ -1665,7 +1516,6 @@ bse_part_controls_lookup (BsePartControls *self,
node = (BsePartTickNode*) g_bsearch_array_lookup (self->bsa, &controls_bsc, &key);
return node;
}
-
BsePartEventControl*
bse_part_controls_lookup_event (BsePartControls *self,
guint tick,
@@ -1683,7 +1533,6 @@ bse_part_controls_lookup_event (BsePartControls *self,
}
return NULL;
}
-
BsePartTickNode*
bse_part_controls_lookup_ge (BsePartControls *self,
guint tick)
@@ -1699,7 +1548,6 @@ bse_part_controls_lookup_ge (BsePartControls *self,
}
return node;
}
-
BsePartTickNode*
bse_part_controls_lookup_le (BsePartControls *self,
guint tick)
@@ -1714,14 +1562,12 @@ bse_part_controls_lookup_le (BsePartControls *self,
}
return node;
}
-
BsePartTickNode*
bse_part_controls_lookup_lt (BsePartControls *self,
guint tick)
{
return tick ? bse_part_controls_lookup_le (self, tick - 1) : NULL;
}
-
BsePartTickNode*
bse_part_controls_get_bound (BsePartControls *self)
{
@@ -1729,7 +1575,6 @@ bse_part_controls_get_bound (BsePartControls *self)
BsePartTickNode *first = (BsePartTickNode*) g_bsearch_array_get_nth (self->bsa, &controls_bsc, 0);
return first ? first + nn : NULL;
}
-
guint
bse_part_controls_get_last_tick (BsePartControls *self)
{
@@ -1741,7 +1586,6 @@ bse_part_controls_get_last_tick (BsePartControls *self)
}
return 0;
}
-
BsePartTickNode*
bse_part_controls_ensure_tick (BsePartControls *self,
guint tick)
@@ -1758,7 +1602,6 @@ bse_part_controls_ensure_tick (BsePartControls *self,
}
return node;
}
-
void
bse_part_controls_insert (BsePartControls *self,
BsePartTickNode *node,
@@ -1777,7 +1620,6 @@ bse_part_controls_insert (BsePartControls *self,
node->events = cev;
BSE_SEQUENCER_UNLOCK ();
}
-
void
bse_part_controls_change (BsePartControls *self,
BsePartTickNode *node,
@@ -1798,7 +1640,6 @@ bse_part_controls_change (BsePartControls *self,
BSE_SEQUENCER_UNLOCK ();
}
}
-
void
bse_part_controls_change_selected (BsePartEventControl *cev,
guint selected)
@@ -1806,7 +1647,6 @@ bse_part_controls_change_selected (BsePartEventControl *cev,
/* carefull with sequencer lock here */
cev->selected = selected != FALSE;
}
-
void
bse_part_controls_remove (BsePartControls *self,
guint tick,
@@ -1837,7 +1677,6 @@ bse_part_controls_remove (BsePartControls *self,
BSE_SEQUENCER_UNLOCK ();
}
}
-
void
bse_part_controls_destroy (BsePartControls *self)
{
@@ -1855,8 +1694,6 @@ bse_part_controls_destroy (BsePartControls *self)
g_bsearch_array_free (self->bsa, &controls_bsc);
self->bsa = NULL;
}
-
-
/* --- BsePartNoteChannel --- */
static gint
part_note_channel_cmp_notes (gconstpointer bsearch_node1, /* key */
@@ -1866,19 +1703,16 @@ part_note_channel_cmp_notes (gconstpointer bsearch_node1, /* key */
const BsePartEventNote *n2 = (const BsePartEventNote*) bsearch_node2;
return G_BSEARCH_ARRAY_CMP (n1->tick, n2->tick);
}
-
static const GBSearchConfig note_channel_bsc = {
sizeof (BsePartEventNote),
part_note_channel_cmp_notes,
G_BSEARCH_ARRAY_ALIGN_POWER2,
};
-
void
bse_part_note_channel_init (BsePartNoteChannel *self)
{
self->bsa = g_bsearch_array_create (¬e_channel_bsc);
}
-
BsePartEventNote*
bse_part_note_channel_lookup (BsePartNoteChannel *self,
guint tick)
@@ -1888,7 +1722,6 @@ bse_part_note_channel_lookup (BsePartNoteChannel *self,
note = (BsePartEventNote*) g_bsearch_array_lookup (self->bsa, ¬e_channel_bsc, &key);
return note;
}
-
BsePartEventNote*
bse_part_note_channel_get_bound (BsePartNoteChannel *self)
{
@@ -1896,7 +1729,6 @@ bse_part_note_channel_get_bound (BsePartNoteChannel *self)
BsePartEventNote *first = (BsePartEventNote*) g_bsearch_array_get_nth (self->bsa, ¬e_channel_bsc, 0);
return first ? first + nn : NULL;
}
-
BsePartEventNote*
bse_part_note_channel_lookup_le (BsePartNoteChannel *self,
guint tick)
@@ -1911,14 +1743,12 @@ bse_part_note_channel_lookup_le (BsePartNoteChannel *self,
}
return note;
}
-
BsePartEventNote*
bse_part_note_channel_lookup_lt (BsePartNoteChannel *self,
guint tick)
{
return tick ? bse_part_note_channel_lookup_le (self, tick - 1) : NULL;
}
-
BsePartEventNote*
bse_part_note_channel_lookup_ge (BsePartNoteChannel *self,
guint tick)
@@ -1934,7 +1764,6 @@ bse_part_note_channel_lookup_ge (BsePartNoteChannel *self,
}
return note;
}
-
guint
bse_part_note_channel_get_last_tick (BsePartNoteChannel *self)
{
@@ -1955,7 +1784,6 @@ bse_part_note_channel_get_last_tick (BsePartNoteChannel *self)
}
return last_tick;
}
-
static inline gboolean
part_note_channel_check_crossing (BsePartNoteChannel *self,
guint note_tick,
@@ -1967,7 +1795,6 @@ part_note_channel_check_crossing (BsePartNoteChannel *self,
g_assert (note);
return note->tick + note->duration > tick_mark;
}
-
static inline guint*
part_note_channel_crossings_add (guint *crossings,
guint tick)
@@ -1979,7 +1806,6 @@ part_note_channel_crossings_add (guint *crossings,
crossings[n_crossings] = tick;
return crossings;
}
-
static inline guint*
part_note_channel_crossings_remove (guint *crossings,
guint tick)
@@ -2002,7 +1828,6 @@ part_note_channel_crossings_remove (guint *crossings,
}
return crossings;
}
-
BsePartEventNote*
bse_part_note_channel_insert (BsePartNoteChannel *self,
BsePartEventNote key)
@@ -2046,7 +1871,6 @@ bse_part_note_channel_insert (BsePartNoteChannel *self,
}
return note;
}
-
void
bse_part_note_channel_change_note (BsePartNoteChannel *self,
BsePartEventNote *note,
@@ -2068,7 +1892,6 @@ bse_part_note_channel_change_note (BsePartNoteChannel *self,
BSE_SEQUENCER_UNLOCK ();
}
}
-
void
bse_part_note_channel_remove (BsePartNoteChannel *self,
guint tick)
@@ -2094,7 +1917,6 @@ bse_part_note_channel_remove (BsePartNoteChannel *self,
/* free predecessor crossings */
g_free (key.crossings);
}
-
void
bse_part_note_channel_destroy (BsePartNoteChannel *self)
{
diff --git a/bse/bsepart.hh b/bse/bsepart.hh
index 88c0ba7..df5cc05 100644
--- a/bse/bsepart.hh
+++ b/bse/bsepart.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PART_H__
#define __BSE_PART_H__
-
#include <bse/bseitem.hh>
#include <sfi/gbsearcharray.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PART (BSE_TYPE_ID (BsePart))
#define BSE_PART(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PART, BsePart))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_PART(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PART))
#define BSE_IS_PART_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PART))
#define BSE_PART_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PART, BsePartClass))
-
-
/* --- typedefs & structures --- */
typedef struct {
GBSearchArray *bsa;
@@ -26,23 +21,18 @@ typedef struct {
struct _BsePart
{
BseItem parent_instance;
-
const double *semitone_table; // [-132..+132] only updated when not playing
-
/* id -> tick lookups */
guint n_ids;
guint *ids;
guint last_id; /* head of free id list */
-
/* control events */
BsePartControls controls;
/* notes */
guint n_channels;
BsePartNoteChannel *channels;
-
/* one after any tick used by controls or notes */
guint last_tick_SL;
-
/* queued updates */
guint links_queued : 1;
guint range_queued : 1;
@@ -54,7 +44,6 @@ struct _BsePart
struct _BsePartClass
{
BseItemClass parent_class;
-
void (*range_changed) (BsePart *part,
guint tick,
guint duration,
@@ -67,8 +56,6 @@ typedef enum /*< skip >*/
BSE_PART_EVENT_CONTROL,
BSE_PART_EVENT_NOTE
} BsePartEventType;
-
-
/* --- functions --- */
#define bse_part_transpose_factor( part, index /* -132..+132*/) ((part)->semitone_table[index])
void bse_part_set_semitone_table (BsePart *self,
@@ -175,15 +162,12 @@ typedef struct {
BsePartEventType bse_part_query_event (BsePart *self,
guint id,
BsePartQueryEvent *equery);
-
-
/* --- implementation details --- */
#define BSE_PART_MAX_CHANNELS (0x1024)
#define BSE_PART_MAX_TICK (0x7fffffff)
#define BSE_PART_INVAL_TICK_FLAG (0x80000000)
#define BSE_PART_NOTE_CONTROL(ctype) ((ctype) == BSE_MIDI_SIGNAL_VELOCITY || \
(ctype) == BSE_MIDI_SIGNAL_FINE_TUNE)
-
/* --- BsePartControlChannel --- */
typedef struct _BsePartEventControl BsePartEventControl;
typedef struct
@@ -199,7 +183,6 @@ struct _BsePartEventControl
guint ctype; /* BseMidiSignalType */
gfloat value; /* -1 .. 1 */
};
-
void bse_part_controls_init (BsePartControls *self);
BsePartTickNode* bse_part_controls_lookup (BsePartControls *self,
guint tick);
@@ -235,8 +218,6 @@ void bse_part_controls_remove (BsePartControls *sel
guint tick,
BsePartEventControl *cev);
void bse_part_controls_destroy (BsePartControls *self);
-
-
/* --- BsePartNoteChannel --- */
typedef struct _BsePartEventNote BsePartEventNote;
struct _BsePartEventNote
@@ -250,14 +231,12 @@ struct _BsePartEventNote
gint fine_tune;
gfloat velocity; /* 0 .. 1 */
};
-
#define BSE_PART_NOTE_N_CROSSINGS(note) ((note)->crossings ? (note)->crossings[0] : 0)
#define BSE_PART_NOTE_CROSSING(note,j) ((note)->crossings[1 + (j)])
#define BSE_PART_SEMITONE_FACTOR(part,noteval) (bse_part_transpose_factor ((part), CLAMP ((noteval), SFI_MIN_NOTE, SFI_MAX_NOTE) - SFI_KAMMER_NOTE))
#define BSE_PART_NOTE_FREQ(part,note) (BSE_KAMMER_FREQUENCY * \
BSE_PART_SEMITONE_FACTOR ((part), (note)->note) * \
bse_cent_tune_fast ((note)->fine_tune))
-
void bse_part_note_channel_init (BsePartNoteChannel *self);
BsePartEventNote* bse_part_note_channel_lookup (BsePartNoteChannel *self,
guint tick);
@@ -281,7 +260,5 @@ void bse_part_note_channel_change_note (BsePartNoteChannel *self,
void bse_part_note_channel_remove (BsePartNoteChannel *self,
guint tick);
void bse_part_note_channel_destroy (BsePartNoteChannel *self);
-
G_END_DECLS
-
#endif /* __BSE_PART_H__ */
diff --git a/bse/bsepart.proc b/bse/bsepart.proc
index 04bfab2..d1e7e4e 100644
--- a/bse/bsepart.proc
+++ b/bse/bsepart.proc
@@ -4,12 +4,8 @@
#include <bse/bsepart.hh>
#include <bse/bsesong.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BsePart, insert-note-auto) {
HELP = "Insert a new note into a part with automatic channel selection.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -40,24 +36,19 @@ BODY (BseProcedureClass *proc,
gfloat velocity = sfi_value_get_real (in_values++);
BseUndoStack *ustack;
guint id;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "insert-note-auto");
id = bse_part_insert_note (self, ~0, tick, duration, note, fine_tune, velocity);
if (id)
bse_item_push_undo_proc (self, "delete-event", id);
bse_item_undo_close (ustack);
-
/* set output parameters */
sfi_value_set_int (out_values++, id);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, insert-note) {
HELP = "Insert a new note into a part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -91,24 +82,19 @@ BODY (BseProcedureClass *proc,
gfloat velocity = sfi_value_get_real (in_values++);
BseUndoStack *ustack;
guint id;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "insert-note");
id = bse_part_insert_note (self, channel, tick, duration, note, fine_tune, velocity);
if (id)
bse_item_push_undo_proc (self, "delete-event", id);
bse_item_undo_close (ustack);
-
/* set output parameters */
sfi_value_set_int (out_values++, id);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, insert-control) {
HELP = "Insert a new control event into a part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -135,24 +121,19 @@ BODY (BseProcedureClass *proc,
gfloat value = sfi_value_get_real (in_values++);
BseUndoStack *ustack;
guint id;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "insert-event");
id = bse_part_insert_control (self, tick, BseMidiSignalType (ctype), value);
if (id)
bse_item_push_undo_proc (self, "delete-event", id);
bse_item_undo_close (ustack);
-
/* set output parameters */
sfi_value_set_int (out_values++, id);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, change-note) {
HELP = "Change an existing note within a part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -187,11 +168,9 @@ BODY (BseProcedureClass *proc,
gfloat velocity = sfi_value_get_real (in_values++);
gboolean success = FALSE;
BsePartQueryEvent equery;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (bse_part_query_event (self, id, &equery) == BSE_PART_EVENT_NOTE)
{
@@ -209,13 +188,10 @@ BODY (BseProcedureClass *proc,
success = TRUE;
bse_item_undo_close (ustack);
}
-
/* set output parameters */
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_EVENT);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, change-control) {
HELP = "Change an existing control event within a part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -246,11 +222,9 @@ BODY (BseProcedureClass *proc,
gfloat value = sfi_value_get_real (in_values++);
BsePartQueryEvent equery;
gboolean success = FALSE;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_query_event (self, id, &equery);
if (equery.event_type == BSE_PART_EVENT_CONTROL && !BSE_PART_NOTE_CONTROL (ctype))
@@ -286,13 +260,10 @@ BODY (BseProcedureClass *proc,
}
bse_item_undo_close (ustack);
}
-
/* set output parameters */
g_value_set_enum (out_values++, success ? BSE_ERROR_NONE : BSE_ERROR_NO_EVENT);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, delete-event) {
HELP = "Delete an existing event from a part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -312,11 +283,9 @@ BODY (BseProcedureClass *proc,
guint id = sfi_value_get_int (in_values++);
BsePartQueryEvent equery;
gboolean deleted = FALSE;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_query_event (self, id, &equery);
if (equery.event_type == BSE_PART_EVENT_NOTE)
@@ -336,13 +305,10 @@ BODY (BseProcedureClass *proc,
bse_item_push_undo_proc (self, "insert-control", equery.tick, equery.control_type, equery.control_value);
bse_item_undo_close (ustack);
}
-
/* set output parameters */
g_value_set_enum (out_values++, deleted ? BSE_ERROR_NONE : BSE_ERROR_NO_EVENT);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, is-event-selected) {
HELP = "Check whether an event is selected.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -361,21 +327,16 @@ BODY (BseProcedureClass *proc,
guint id = sfi_value_get_int (in_values++);
gboolean selected = FALSE;
BsePartQueryEvent equery;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (bse_part_query_event (self, id, &equery) != BSE_PART_EVENT_NONE)
selected = equery.selected;
-
/* set output parameters */
sfi_value_set_bool (out_values++, selected);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-notes-crossing) {
HELP = "List all notes within or crossing a tick range.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -395,17 +356,13 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_notes (self, ~0, tick, duration, BSE_MIN_NOTE, BSE_MAX_NOTE, TRUE));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-notes-within) {
HELP = "List all notes within a tick range.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -428,17 +385,13 @@ BODY (BseProcedureClass *proc,
guint channel = sfi_value_get_int (in_values++);
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_notes (self, channel, tick, duration, BSE_MIN_NOTE, BSE_MAX_NOTE, FALSE));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-controls) {
HELP = "List all control events within a tick range.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -462,17 +415,13 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_controls (self, ~0, tick, duration, BseMidiSignalType (ctype)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, queue-notes) {
HELP = "Queue updates for all notes starting within the given rectangle.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -496,17 +445,13 @@ BODY (BseProcedureClass *proc,
guint duration = sfi_value_get_int (in_values++);
gint min_note = sfi_value_get_note (in_values++);
gint max_note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_queue_notes_within (self, tick, duration, min_note, max_note);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, queue-controls) {
HELP = "Queue updates for all control events and notes starting within the given range.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -524,17 +469,13 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_queue_controls (self, tick, duration);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-selected-notes) {
HELP = "List all currently selected notes.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -548,17 +489,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_selected_notes (self));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-selected-controls) {
HELP = "List all currently selected control events of a specific type.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -576,17 +513,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_selected_controls (self, BseMidiSignalType (ctype)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, check-overlap) {
HELP = "Check whether a note would overlap with neighbours.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -608,17 +541,13 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
gint note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_notes (self, ~0, tick, duration, note, note, TRUE));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-notes) {
HELP = "Retrieve all notes of specific frequency at or crossing a specific tick.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -638,17 +567,13 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
gint note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_notes (self, ~0, tick, 1, note, note, TRUE));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-controls) {
HELP = "Retrieve all control events of a specific type at specified tick.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -669,17 +594,13 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_controls (self, ~0, tick, 1, BseMidiSignalType (ctype)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-channel-controls) {
HELP = "Retrieve all control events of a specific type within range of a channel.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -706,17 +627,13 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_controls (self, channel, tick, duration, BseMidiSignalType (ctype)));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-min-note) {
HELP = "Retrieve the minimum note supported in this part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -730,17 +647,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* it doesn't currently make sense to restrict the standard note range */
sfi_value_set_int (out_values++, BSE_MIN_NOTE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-max-note) {
HELP = "Retrieve the maximum note supported in this part.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -754,17 +667,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* it doesn't currently make sense to restrict the standard note range */
sfi_value_set_int (out_values++, BSE_MAX_NOTE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, select-notes-exclusive) {
HELP = "Select all notes within rectangle and deselect all others.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -788,16 +697,12 @@ BODY (BseProcedureClass *proc,
guint duration = sfi_value_get_int (in_values++);
gint min_note = sfi_value_get_note (in_values++);
gint max_note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_notes_exclusive (self, ~0, tick, duration, min_note, max_note);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, select-controls-exclusive) {
HELP = "Select all control events within range and deselect all others.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -819,16 +724,12 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_controls_exclusive (self, tick, duration, BseMidiSignalType (ctype));
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, select-controls) {
HELP = "Select all control events within range.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -850,16 +751,12 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_controls (self, tick, duration, BseMidiSignalType (ctype), TRUE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, select-notes) {
HELP = "Select all notes within rectangle.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -883,16 +780,12 @@ BODY (BseProcedureClass *proc,
guint duration = sfi_value_get_int (in_values++);
gint min_note = sfi_value_get_note (in_values++);
gint max_note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_notes (self, ~0, tick, duration, min_note, max_note, TRUE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, deselect-notes) {
HELP = "Deselect all notes within rectangle.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -916,16 +809,12 @@ BODY (BseProcedureClass *proc,
guint duration = sfi_value_get_int (in_values++);
gint min_note = sfi_value_get_note (in_values++);
gint max_note = sfi_value_get_note (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_notes (self, ~0, tick, duration, min_note, max_note, FALSE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, deselect-controls) {
HELP = "Deselect all controls within given range.";
IN = bse_param_spec_object ("part", "Part", "Part",
@@ -947,16 +836,12 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
guint duration = sfi_value_get_int (in_values++);
guint ctype = g_value_get_enum (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_part_select_controls (self, tick, duration, BseMidiSignalType (ctype), FALSE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, select-event) {
HELP = "Select an existing event.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -972,11 +857,9 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint id = sfi_value_get_int (in_values++);
BsePartQueryEvent equery;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_query_event (self, id, &equery);
if (equery.event_type == BSE_PART_EVENT_CONTROL)
@@ -987,7 +870,6 @@ BODY (BseProcedureClass *proc,
return BSE_ERROR_PROC_PARAM_INVAL;
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, deselect-event) {
HELP = "Deselect an existing event.";
IN = bse_param_spec_object ("part", "Part", NULL,
@@ -1003,11 +885,9 @@ BODY (BseProcedureClass *proc,
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
guint id = sfi_value_get_int (in_values++);
BsePartQueryEvent equery;
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_part_query_event (self, id, &equery);
if (equery.event_type == BSE_PART_EVENT_CONTROL)
@@ -1018,7 +898,6 @@ BODY (BseProcedureClass *proc,
return BSE_ERROR_PROC_PARAM_INVAL;
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, get-timing) {
HELP = "Retrieve song timing information at a specific tick.";
IN = bse_param_spec_object ("part", "Part", NULL, BSE_TYPE_PART, SFI_PARAM_STANDARD);
@@ -1033,24 +912,19 @@ METHOD (BsePart, get-timing) {
SfiInt tick = sfi_value_get_int (in_values++);
BseItem *parent;
BseSongTiming timing = { 0, };
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
parent = BSE_ITEM (self)->parent;
if (BSE_IS_SONG (parent))
bse_song_get_timing (BSE_SONG (parent), tick, &timing);
else
bse_song_timing_get_default (&timing);
-
/* set output parameters */
bse_value_set_boxed (out_values++, &timing);
-
return BSE_ERROR_NONE;
}
-
METHOD (BsePart, list-links) {
HELP = "List all places where parts are used (linked) from tracks, sorted by tick.";
IN = bse_param_spec_object ("part", "Part", NULL, BSE_TYPE_PART, SFI_PARAM_STANDARD);
@@ -1063,13 +937,10 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BsePart *self = (BsePart*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PART (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_part_list_links (self));
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsepattern.hh b/bse/bsepattern.hh
index afaf2f5..6bdf54b 100644
--- a/bse/bsepattern.hh
+++ b/bse/bsepattern.hh
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PATTERN_H__
#define __BSE_PATTERN_H__
-
#include <bse/bseitem.hh>
#include <bse/bseeffect.h>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_PATTERN (BSE_TYPE_ID (BsePattern))
#define BSE_PATTERN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PATTERN, BsePattern))
@@ -18,13 +13,9 @@ extern "C" {
#define BSE_IS_PATTERN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PATTERN))
#define BSE_IS_PATTERN_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PATTERN))
#define BSE_PATTERN_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PATTERN, BsePatternClass))
-
-
/* --- accessors --- */
#define BSE_PATTERN_N_CHANNELS(pattern) (((BsePattern*) (pattern))->n_channels)
#define BSE_PATTERN_N_ROWS(pattern) (((BsePattern*) (pattern))->n_rows)
-
-
/* --- BsePattern object --- */
struct _BsePatternNote
{
@@ -37,12 +28,9 @@ struct _BsePatternNote
struct _BsePattern
{
BseItem parent_object;
-
guint n_channels /* mirrored from BseSong */;
guint n_rows /* mirrored from BseSong.pattern_length */;
-
BsePatternNote *notes /* ->notes [ row * n_channels + channel] */;
-
/* only used during parsing phase */
guint current_channel;
guint current_row;
@@ -51,8 +39,6 @@ struct _BsePatternClass
{
BseItemClass parent_class;
};
-
-
/* --- prototypes --- */
/* returns a pointer to relocatable data, make sure to lock the
* pattern to maintain validity.
@@ -86,8 +72,6 @@ void bse_pattern_note_drop_effect (BsePattern *pattern,
guint channel,
guint row,
GType effect_type);
-
-
/* --- convenience --- */
void bse_pattern_set_note (BsePattern *pattern,
guint channel,
@@ -97,8 +81,6 @@ void bse_pattern_set_instrument (BsePattern *pattern,
guint channel,
guint row,
BseInstrument *instrument);
-
-
/* --- internal --- */
void bse_pattern_set_n_channels (BsePattern *pattern,
guint n_channels);
@@ -110,8 +92,6 @@ void bse_pattern_select_note (BsePattern *pattern,
void bse_pattern_unselect_note (BsePattern *pattern,
guint channel,
guint row);
-
-
/* --- selections --- */
/* selections within a BsePattern are supplied for procedure invocation
* from a pattern editor only, they don't actually affect core BSE
@@ -137,8 +117,6 @@ void bse_pattern_selection_fill (guint32 *selection,
_bse_pattern_selection_unmark ((selection), (channel), (row))
#define BSE_PATTERN_SELECTION_TEST(selection, channel, row) \
_bse_pattern_selection_test ((selection), (channel), (row))
-
-
/* --- implementation details --- */
static inline gboolean
_bse_pattern_selection_test (guint32 *selection,
@@ -146,7 +124,6 @@ _bse_pattern_selection_test (guint32 *selection,
guint row)
{
guint n = BSE_PATTERN_SELECTION_N_CHANNELS (selection) * row + channel;
-
/* return (selection[n / 32 + 2] & (1 << n % 32)) != 0; */
return (selection[(n >> 5) + 2] & (1 << (n & 0x1f))) != 0;
}
@@ -156,7 +133,6 @@ _bse_pattern_selection_mark (guint32 *selection,
guint row)
{
guint n = BSE_PATTERN_SELECTION_N_CHANNELS (selection) * row + channel;
-
selection[(n >> 5) + 2] |= 1 << (n & 0x1f);
}
static inline void
@@ -165,13 +141,9 @@ _bse_pattern_selection_unmark (guint32 *selection,
guint row)
{
guint n = BSE_PATTERN_SELECTION_N_CHANNELS (selection) * row + channel;
-
selection[(n >> 5) + 2] &= ~(1 << (n & 0x1f));
}
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_PATTERN_H__ */
diff --git a/bse/bsepatterngroup.hh b/bse/bsepatterngroup.hh
index 2485541..be0ccfb 100644
--- a/bse/bsepatterngroup.hh
+++ b/bse/bsepatterngroup.hh
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PATTERN_GROUP_H__
#define __BSE_PATTERN_GROUP_H__
-
#include <bse/bsepattern.hh>
-
-
/* --- object type macros --- */
#define BSE_TYPE_PATTERN_GROUP (BSE_TYPE_ID (BsePatternGroup))
#define BSE_PATTERN_GROUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PATTERN_GROUP, BsePatternGroup))
@@ -12,14 +9,11 @@
#define BSE_IS_PATTERN_GROUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PATTERN_GROUP))
#define BSE_IS_PATTERN_GROUP_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PATTERN_GROUP))
#define BSE_PATTERN_GROUP_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PATTERN_GROUP, BsePatternGroupClass))
-
-
/* --- BsePatternGroup object --- */
typedef struct _BsePatternGroupEntry BsePatternGroupEntry;
struct _BsePatternGroup
{
BseItem parent_object;
-
guint pattern_count;
guint n_entries;
BsePatternGroupEntry *entries;
@@ -32,8 +26,6 @@ struct _BsePatternGroupEntry
{
BsePattern *pattern;
};
-
-
/* --- prototypes --- */
void bse_pattern_group_insert_pattern (BsePatternGroup *pgroup,
BsePattern *pattern,
@@ -46,14 +38,7 @@ void bse_pattern_group_clone_contents (BsePatternGroup *pgroup,
BsePatternGroup *src_pgroup);
BsePattern* bse_pattern_group_get_nth_pattern (BsePatternGroup *pgroup,
gint index);
-
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_PATTERN_GROUP_H__ */
diff --git a/bse/bsepcmdevice-null.cc b/bse/bsepcmdevice-null.cc
index 3aed88a..7bc5f40 100644
--- a/bse/bsepcmdevice-null.cc
+++ b/bse/bsepcmdevice-null.cc
@@ -3,17 +3,14 @@
#include "bsesequencer.hh"
#include "bseengine.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_pcm, "pcm", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_pcm, __VA_ARGS__)
-
typedef struct
{
BsePcmHandle handle;
guint busy_us;
guint sleep_us;
} NullHandle;
-
/* --- prototypes --- */
static gsize null_device_read (BsePcmHandle *handle,
gfloat *values);
@@ -22,14 +19,11 @@ static void null_device_write (BsePcmHandle *handle,
static gboolean null_device_check_io (BsePcmHandle *handle,
glong *timeoutp);
static guint null_device_latency (BsePcmHandle *handle);
-
-
/* --- functions --- */
static void
bse_pcm_device_null_init (BsePcmDeviceNull *null)
{
}
-
static SfiRing*
bse_pcm_device_null_list_devices (BseDevice *device)
{
@@ -37,7 +31,6 @@ bse_pcm_device_null_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_entry_new (device, g_strdup_printf ("default"), NULL));
return ring;
}
-
static BseErrorType
bse_pcm_device_null_open (BseDevice *device,
gboolean require_readable,
@@ -47,7 +40,6 @@ bse_pcm_device_null_open (BseDevice *device,
{
NullHandle *null = g_new0 (NullHandle, 1);
BsePcmHandle *handle = &null->handle;
-
/* setup request */
handle->readable = require_readable;
handle->writable = require_writable;
@@ -67,7 +59,6 @@ bse_pcm_device_null_open (BseDevice *device,
DEBUG ("NULL: opening PCM readable=%d writable=%d: %s", require_readable, require_writable, bse_error_blurb (BSE_ERROR_NONE));
return BSE_ERROR_NONE;
}
-
static void
bse_pcm_device_null_close (BseDevice *device)
{
@@ -75,7 +66,6 @@ bse_pcm_device_null_close (BseDevice *device)
BSE_PCM_DEVICE (device)->handle = NULL;
g_free (null);
}
-
static gboolean
null_device_check_io (BsePcmHandle *handle,
glong *timeoutp)
@@ -86,14 +76,12 @@ null_device_check_io (BsePcmHandle *handle,
/* ensure sequencer fairness */
return !bse_sequencer_thread_lagging (2);
}
-
static guint
null_device_latency (BsePcmHandle *handle)
{
/* total latency in frames */
return handle->mix_freq / 10;
}
-
static gsize
null_device_read (BsePcmHandle *handle,
gfloat *values)
@@ -102,7 +90,6 @@ null_device_read (BsePcmHandle *handle,
memset (values, 0, sizeof (values[0]) * n_values);
return n_values;
}
-
static void
null_device_write (BsePcmHandle *handle,
const gfloat *values)
@@ -117,12 +104,10 @@ null_device_write (BsePcmHandle *handle,
g_usleep (null->sleep_us);
}
}
-
static void
bse_pcm_device_null_class_init (BsePcmDeviceNullClass *klass)
{
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
device_class->list_devices = bse_pcm_device_null_list_devices;
bse_device_class_setup (device_class,
-1,
@@ -137,19 +122,16 @@ bse_pcm_device_null_class_init (BsePcmDeviceNullClass *klass)
device_class->open = bse_pcm_device_null_open;
device_class->close = bse_pcm_device_null_close;
}
-
BSE_BUILTIN_TYPE (BsePcmDeviceNull)
{
GType pcm_device_null_type;
static const GTypeInfo pcm_device_null_info = {
sizeof (BsePcmDeviceNullClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_device_null_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BsePcmDeviceNull),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_device_null_init,
diff --git a/bse/bsepcmdevice-null.hh b/bse/bsepcmdevice-null.hh
index 2b58078..6302685 100644
--- a/bse/bsepcmdevice-null.hh
+++ b/bse/bsepcmdevice-null.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_DEVICE_NULL_H__
#define __BSE_PCM_DEVICE_NULL_H__
-
#include <bse/bsepcmdevice.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_DEVICE_NULL (BSE_TYPE_ID (BsePcmDeviceNull))
#define BSE_PCM_DEVICE_NULL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE_NULL, BsePcmDeviceNull))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_DEVICE_NULL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE_NULL))
#define BSE_IS_PCM_DEVICE_NULL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE_NULL))
#define BSE_PCM_DEVICE_NULL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE_NULL, BsePcmDeviceNullClass))
-
-
/* --- BsePcmDeviceNull object --- */
typedef struct _BsePcmDeviceNull BsePcmDeviceNull;
typedef struct _BsePcmDeviceNullClass BsePcmDeviceNullClass;
@@ -26,7 +21,5 @@ struct _BsePcmDeviceNullClass
{
BsePcmDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_PCM_DEVICE_NULL_H__ */
diff --git a/bse/bsepcmdevice-oss.cc b/bse/bsepcmdevice-oss.cc
index 1e529cd..ad60164 100644
--- a/bse/bsepcmdevice-oss.cc
+++ b/bse/bsepcmdevice-oss.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsepcmdevice-oss.hh"
-
#include "topconfig.h"
-
#include "gsldatautils.hh"
#include "gslcommon.hh" // FIXME: remove
-
#ifndef BSE_PCM_DEVICE_CONF_OSS
BSE_DUMMY_TYPE (BsePcmDeviceOSS);
#else /* BSE_PCM_DEVICE_CONF_OSS */
-
#if HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#elif HAVE_SOUNDCARD_H
@@ -22,7 +18,6 @@ BSE_DUMMY_TYPE (BsePcmDeviceOSS);
#include <string.h>
#include <errno.h>
#include <fcntl.h>
-
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define AFMT_S16_HE AFMT_S16_LE
#elif G_BYTE_ORDER == G_BIG_ENDIAN
@@ -30,11 +25,8 @@ BSE_DUMMY_TYPE (BsePcmDeviceOSS);
#else
#error unsupported byte order in G_BYTE_ORDER
#endif
-
static SFI_MSG_TYPE_DEFINE (debug_pcm, "pcm", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_pcm, __VA_ARGS__)
-
-
/* --- OSS PCM handle --- */
typedef struct
{
@@ -50,8 +42,6 @@ typedef struct
gboolean hard_sync;
} OSSHandle;
#define FRAG_BUF_SIZE(oss) ((oss)->frag_size * 4)
-
-
/* --- prototypes --- */
static BseErrorType oss_device_setup (OSSHandle *oss,
guint req_queue_length);
@@ -63,19 +53,14 @@ static void oss_device_write (BsePcmHandle *handle,
static gboolean oss_device_check_io (BsePcmHandle *handle,
glong *timeoutp);
static guint oss_device_latency (BsePcmHandle *handle);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_pcm_device_oss_init (BsePcmDeviceOSS *oss)
{
oss->device_name = g_strdup (BSE_PCM_DEVICE_CONF_OSS);
}
-
static BseErrorType
check_device_usage (const gchar *name,
const gchar *check_mode)
@@ -96,7 +81,6 @@ check_device_usage (const gchar *name,
}
return error;
}
-
static SfiRing*
bse_pcm_device_oss_list_devices (BseDevice *device)
{
@@ -128,7 +112,6 @@ bse_pcm_device_oss_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_error_new (device, g_strdup_printf ("No devices found")));
return ring;
}
-
static BseErrorType
bse_pcm_device_oss_open (BseDevice *device,
gboolean require_readable,
@@ -159,7 +142,6 @@ bse_pcm_device_oss_open (BseDevice *device,
omode = require_readable && require_writable ? O_RDWR : require_readable ? O_RDONLY : O_WRONLY;
OSSHandle *oss = g_new0 (OSSHandle, 1);
BsePcmHandle *handle = &oss->handle;
-
/* setup request */
handle->n_channels = BSE_PCM_DEVICE (device)->req_n_channels;
handle->mix_freq = BSE_PCM_DEVICE (device)->req_mix_freq;
@@ -168,7 +150,6 @@ bse_pcm_device_oss_open (BseDevice *device,
oss->fd = -1;
oss->needs_trigger = TRUE;
oss->hard_sync = hard_sync;
-
/* try open */
BseErrorType error;
gint fd = -1;
@@ -188,7 +169,6 @@ bse_pcm_device_oss_open (BseDevice *device,
}
else
error = bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
-
/* setup PCM handle or shutdown */
if (!error)
{
@@ -211,34 +191,27 @@ bse_pcm_device_oss_open (BseDevice *device,
g_free (oss);
}
DEBUG ("OSS: opening \"%s\" readable=%d writable=%d: %s", dname, require_readable, require_writable, bse_error_blurb (error));
-
return error;
}
-
static void
bse_pcm_device_oss_close (BseDevice *device)
{
OSSHandle *oss = (OSSHandle*) BSE_PCM_DEVICE (device)->handle;
BSE_PCM_DEVICE (device)->handle = NULL;
-
(void) ioctl (oss->fd, SNDCTL_DSP_RESET, NULL);
(void) close (oss->fd);
g_free (oss->frag_buf);
g_free (oss);
}
-
static void
bse_pcm_device_oss_finalize (GObject *object)
{
BsePcmDeviceOSS *pdev_oss = BSE_PCM_DEVICE_OSS (object);
-
g_free (pdev_oss->device_name);
pdev_oss->device_name = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static BseErrorType
oss_device_setup (OSSHandle *oss,
guint req_queue_length)
@@ -247,7 +220,6 @@ oss_device_setup (OSSHandle *oss,
gint fd = oss->fd;
glong d_long;
gint d_int;
-
/* to get usable low-latency behaviour with OSS, we
* make the device blocking, choose small fragments
* and read() the first fragment once available.
@@ -256,7 +228,6 @@ oss_device_setup (OSSHandle *oss,
d_long &= ~O_NONBLOCK;
if (fcntl (fd, F_SETFL, d_long))
return BSE_ERROR_DEVICE_ASYNC;
-
d_int = 0;
if (ioctl (fd, SNDCTL_DSP_GETFMTS, &d_int) < 0)
return BSE_ERROR_DEVICE_FORMAT;
@@ -267,21 +238,18 @@ oss_device_setup (OSSHandle *oss,
d_int != AFMT_S16_HE)
return BSE_ERROR_DEVICE_FORMAT;
guint bytes_per_value = 2;
-
d_int = handle->n_channels - 1;
if (ioctl (fd, SNDCTL_DSP_STEREO, &d_int) < 0)
return BSE_ERROR_DEVICE_CHANNELS;
if (int (handle->n_channels) != d_int + 1)
return BSE_ERROR_DEVICE_CHANNELS;
oss->frame_size = handle->n_channels * bytes_per_value;
-
d_int = handle->mix_freq;
if (ioctl (fd, SNDCTL_DSP_SPEED, &d_int) < 0)
return BSE_ERROR_DEVICE_FREQUENCY;
handle->mix_freq = d_int;
if (MAX (d_int, handle->mix_freq) - MIN (d_int, handle->mix_freq) > handle->mix_freq / 100)
return BSE_ERROR_DEVICE_FREQUENCY;
-
/* Note: fragment = n_fragments << 16;
* fragment |= g_bit_storage (fragment_size - 1);
*/
@@ -297,12 +265,10 @@ oss_device_setup (OSSHandle *oss,
d_int = (oss->n_frags << 16) | g_bit_storage (oss->frag_size - 1);
if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &d_int) < 0)
return BSE_ERROR_DEVICE_LATENCY;
-
d_int = 0;
if (ioctl (fd, SNDCTL_DSP_GETBLKSIZE, &d_int) < 0 ||
d_int < 128 || d_int > 131072 || (d_int & 1))
return BSE_ERROR_DEVICE_BUFFER;
-
audio_buf_info info = { 0, };
if (handle->writable && ioctl (fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
return BSE_ERROR_DEVICE_BUFFER;
@@ -317,7 +283,6 @@ oss_device_setup (OSSHandle *oss,
sfi_diag ("OSS: buffer size (%d) differs from fragment space (%d)", info.bytes, info.fragstotal * info.fragsize);
oss->queue_length = oss->n_frags * oss->frag_size / oss->frame_size;
}
-
if (handle->readable)
{
req_queue_length = MAX (req_queue_length, 3 * info.fragsize / oss->frame_size); /* can't get better than 3 fragments */
@@ -333,7 +298,6 @@ oss_device_setup (OSSHandle *oss,
req_queue_length = MIN (req_queue_length, oss->queue_length);
oss->queue_length = CLAMP (25 * handle->mix_freq / 1000, req_queue_length, oss->queue_length);
}
-
DEBUG ("OSS: setup: w=%d r=%d n_channels=%d mix_freq=%u queue=%u nfrags=%u fsize=%u bufsz=%u",
handle->writable,
handle->readable,
@@ -343,18 +307,14 @@ oss_device_setup (OSSHandle *oss,
oss->n_frags,
oss->frag_size / oss->frame_size,
info.bytes / oss->frame_size);
-
return BSE_ERROR_NONE;
}
-
static void
oss_device_retrigger (OSSHandle *oss)
{
BsePcmHandle *handle = &oss->handle;
-
/* first, clear io buffers */
(void) ioctl (oss->fd, SNDCTL_DSP_RESET, NULL);
-
/* it should be enough to select() on the fd to trigger
* capture/playback, but with some new OSS drivers
* (clones) this is not the case anymore, so we also
@@ -366,7 +326,6 @@ oss_device_retrigger (OSSHandle *oss)
if (oss->handle.writable)
d_int |= PCM_ENABLE_OUTPUT;
(void) ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &d_int);
-
/* Jaroslav Kysela <perex jcu cz>:
* Important sequence:
* 1) turn on capture
@@ -388,7 +347,6 @@ oss_device_retrigger (OSSHandle *oss)
FD_SET (oss->fd, &out_fds);
select (oss->fd + 1, &in_fds, &out_fds, NULL, &tv);
}
-
/* provide latency buffering */
gint size = oss->queue_length * oss->frame_size, n;
guint8 *silence = (guint8*) g_malloc0 (size);
@@ -396,19 +354,15 @@ oss_device_retrigger (OSSHandle *oss)
n = write (oss->fd, silence, size);
while (n < 0 && errno == EAGAIN); /* retry on signals */
g_free (silence);
-
glong d_long = fcntl (oss->fd, F_GETFL);
DEBUG ("OSS: retriggering device (blocking=%u, r=%d, w=%d)...", (int) !(d_long & O_NONBLOCK), handle->readable, handle->writable);
-
oss->needs_trigger = FALSE;
}
-
static gboolean
oss_device_check_io (BsePcmHandle *handle,
glong *timeoutp)
{
OSSHandle *oss = (OSSHandle*) handle;
-
/* query device status and handle underruns */
gboolean checked_underrun = FALSE;
handle_underrun:
@@ -473,16 +427,13 @@ oss_device_check_io (BsePcmHandle *handle,
goto handle_underrun;
}
}
-
/* check whether processing is possible */
if (n_capture_avail >= handle->block_length)
return TRUE; /* can process */
-
/* check immediate processing need */
guint fill_frames = n_total_playback - n_playback_avail;
if (fill_frames <= oss->queue_length)
return TRUE; /* need process */
-
/* calculate timeout until processing is possible/needed */
guint diff_frames;
if (handle->readable)
@@ -493,10 +444,8 @@ oss_device_check_io (BsePcmHandle *handle,
/* OSS workaround for low latency */
if (handle->readable)
*timeoutp = 0; /* prevent waiting in poll(), to force blocking read() */
-
return *timeoutp == 0;
}
-
static guint
oss_device_latency (BsePcmHandle *handle)
{
@@ -534,7 +483,6 @@ oss_device_latency (BsePcmHandle *handle)
/* return total latency in frames */
return n_capture_avail + n_playback_filled;
}
-
static gsize
oss_device_read (BsePcmHandle *handle,
gfloat *values)
@@ -546,15 +494,12 @@ oss_device_read (BsePcmHandle *handle,
gpointer buf = oss->frag_buf;
gfloat *dest = values;
gsize n_left = n_values;
-
g_return_val_if_fail (oss->frame_size == 4, 0);
-
do
{
gsize n = MIN (buf_size, n_left << 1);
gint16 *b, *s = (gint16*) buf;
gssize l;
-
do
l = read (fd, buf, n);
while (l < 0 && errno == EINTR); /* don't mind signals */
@@ -571,10 +516,8 @@ oss_device_read (BsePcmHandle *handle,
}
while (n_left);
oss->read_write_count += 1;
-
return n_values;
}
-
static void
oss_device_write (BsePcmHandle *handle,
const gfloat *values)
@@ -585,18 +528,14 @@ oss_device_write (BsePcmHandle *handle,
gsize buf_size = FRAG_BUF_SIZE (oss);
gpointer buf = oss->frag_buf;
const gfloat *s = values;
-
if (handle->readable)
while (oss->read_write_count < 1)
oss_device_read (handle, NULL); /* dummy read to sync device */
-
g_return_if_fail (oss->frame_size == 4);
-
do
{
gsize n = MIN (buf_size, n_values << 1);
gssize l;
-
gsl_conv_from_float_clip (GSL_WAVE_FORMAT_SIGNED_16,
G_BYTE_ORDER,
s,
@@ -613,17 +552,13 @@ oss_device_write (BsePcmHandle *handle,
while (n_values);
oss->read_write_count -= 1;
}
-
static void
bse_pcm_device_oss_class_init (BsePcmDeviceOSSClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_pcm_device_oss_finalize;
-
device_class->list_devices = bse_pcm_device_oss_list_devices;
bse_device_class_setup (klass,
BSE_RATING_DEFAULT,
@@ -638,25 +573,20 @@ bse_pcm_device_oss_class_init (BsePcmDeviceOSSClass *klass)
device_class->open = bse_pcm_device_oss_open;
device_class->close = bse_pcm_device_oss_close;
}
-
BSE_BUILTIN_TYPE (BsePcmDeviceOSS)
{
GType pcm_device_oss_type;
-
static const GTypeInfo pcm_device_oss_info = {
sizeof (BsePcmDeviceOSSClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_device_oss_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BsePcmDeviceOSS),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_device_oss_init,
};
-
pcm_device_oss_type = bse_type_register_static (BSE_TYPE_PCM_DEVICE,
"BsePcmDeviceOSS",
"PCM device implementation for OSS Lite /dev/dsp",
@@ -664,5 +594,4 @@ BSE_BUILTIN_TYPE (BsePcmDeviceOSS)
&pcm_device_oss_info);
return pcm_device_oss_type;
}
-
#endif /* BSE_PCM_DEVICE_CONF_OSS */
diff --git a/bse/bsepcmdevice-oss.hh b/bse/bsepcmdevice-oss.hh
index d7e6ad4..97b20c9 100644
--- a/bse/bsepcmdevice-oss.hh
+++ b/bse/bsepcmdevice-oss.hh
@@ -1,13 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_DEVICE_OSS_H__
#define __BSE_PCM_DEVICE_OSS_H__
-
#include <bse/bsepcmdevice.hh>
-
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_DEVICE_OSS (BSE_TYPE_ID (BsePcmDeviceOSS))
#define BSE_PCM_DEVICE_OSS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE_OSS, BsePcmDeviceOSS))
@@ -15,24 +10,17 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_DEVICE_OSS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE_OSS))
#define BSE_IS_PCM_DEVICE_OSS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE_OSS))
#define BSE_PCM_DEVICE_OSS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE_OSS, BsePcmDeviceOSSClass))
-
-
/* --- BsePcmDeviceOSS object --- */
typedef struct _BsePcmDeviceOSS BsePcmDeviceOSS;
typedef struct _BsePcmDeviceOSSClass BsePcmDeviceOSSClass;
struct _BsePcmDeviceOSS
{
BsePcmDevice parent_object;
-
gchar *device_name;
};
struct _BsePcmDeviceOSSClass
{
BsePcmDeviceClass parent_class;
};
-
-
-
G_END_DECLS
-
#endif /* __BSE_PCM_DEVICE_OSS_H__ */
diff --git a/bse/bsepcmdevice.cc b/bse/bsepcmdevice.cc
index 4fdcb86..6e3e543 100644
--- a/bse/bsepcmdevice.cc
+++ b/bse/bsepcmdevice.cc
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsepcmdevice.hh"
-
#include "gslcommon.hh"
#include <errno.h>
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_pcm_device_init (BsePcmDevice *pdev)
@@ -19,7 +14,6 @@ bse_pcm_device_init (BsePcmDevice *pdev)
pdev->req_block_length = 1024;
pdev->handle = NULL;
}
-
void
bse_pcm_device_request (BsePcmDevice *self,
guint n_channels,
@@ -31,18 +25,15 @@ bse_pcm_device_request (BsePcmDevice *self,
g_return_if_fail (!BSE_DEVICE_OPEN (self));
g_return_if_fail (n_channels >= 1 && n_channels <= 128);
g_return_if_fail (mix_freq >= 1000 && mix_freq <= 192000);
-
self->req_n_channels = n_channels;
self->req_mix_freq = mix_freq;
self->req_block_length = MAX (block_length, 2);
self->req_latency_ms = latency_ms;
}
-
static void
bse_pcm_device_dispose (GObject *object)
{
BsePcmDevice *pdev = BSE_PCM_DEVICE (object);
-
if (BSE_DEVICE_OPEN (pdev))
{
g_warning (G_STRLOC ": pcm device still opened");
@@ -50,11 +41,9 @@ bse_pcm_device_dispose (GObject *object)
}
if (pdev->handle)
g_warning (G_STRLOC ": pcm device with stale pcm handle");
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
pcm_device_post_open (BseDevice *device)
{
@@ -63,14 +52,12 @@ pcm_device_post_open (BseDevice *device)
g_return_if_fail (BSE_DEVICE_OPEN (self) && self->handle->block_length == 0);
sfi_mutex_init (&self->handle->mutex);
}
-
static void
pcm_device_pre_close (BseDevice *device)
{
BsePcmDevice *self = BSE_PCM_DEVICE (device);
sfi_mutex_destroy (&self->handle->mutex);
}
-
guint
bse_pcm_device_get_mix_freq (BsePcmDevice *pdev)
{
@@ -80,7 +67,6 @@ bse_pcm_device_get_mix_freq (BsePcmDevice *pdev)
else
return 0;
}
-
BsePcmHandle*
bse_pcm_device_get_handle (BsePcmDevice *pdev,
guint block_length)
@@ -88,37 +74,30 @@ bse_pcm_device_get_handle (BsePcmDevice *pdev,
g_return_val_if_fail (BSE_IS_PCM_DEVICE (pdev), NULL);
g_return_val_if_fail (BSE_DEVICE_OPEN (pdev), NULL);
g_return_val_if_fail (block_length > 0, NULL);
-
GSL_SPIN_LOCK (&pdev->handle->mutex);
if (!pdev->handle->block_length)
pdev->handle->block_length = block_length;
GSL_SPIN_UNLOCK (&pdev->handle->mutex);
-
if (pdev->handle->block_length == block_length)
return pdev->handle;
else
return NULL;
}
-
gsize
bse_pcm_handle_read (BsePcmHandle *handle,
gsize n_values,
gfloat *values)
{
gsize n;
-
g_return_val_if_fail (handle != NULL, 0);
g_return_val_if_fail (handle->readable, 0);
g_return_val_if_fail (n_values == handle->block_length * handle->n_channels, 0);
-
GSL_SPIN_LOCK (&handle->mutex);
n = handle->read (handle, values);
GSL_SPIN_UNLOCK (&handle->mutex);
-
g_return_val_if_fail (n == handle->block_length * handle->n_channels, n);
return n;
}
-
void
bse_pcm_handle_write (BsePcmHandle *handle,
gsize n_values,
@@ -128,18 +107,15 @@ bse_pcm_handle_write (BsePcmHandle *handle,
g_return_if_fail (handle->writable);
g_return_if_fail (values != NULL);
g_return_if_fail (n_values == handle->block_length * handle->n_channels);
-
GSL_SPIN_LOCK (&handle->mutex);
handle->write (handle, values);
GSL_SPIN_UNLOCK (&handle->mutex);
}
-
gboolean
bse_pcm_handle_check_io (BsePcmHandle *handle,
glong *timeoutp)
{
g_return_val_if_fail (handle != NULL, 0);
-
glong dummy;
if (!timeoutp)
timeoutp = &dummy;
@@ -148,7 +124,6 @@ bse_pcm_handle_check_io (BsePcmHandle *handle,
GSL_SPIN_UNLOCK (&handle->mutex);
return can_read_write;
}
-
guint
bse_pcm_handle_latency (BsePcmHandle *handle)
{
@@ -158,8 +133,6 @@ bse_pcm_handle_latency (BsePcmHandle *handle)
GSL_SPIN_UNLOCK (&handle->mutex);
return n_frames;
}
-
-
/* --- frequency utilities --- */
guint
bse_pcm_device_frequency_align (gint mix_freq)
@@ -180,37 +153,29 @@ bse_pcm_device_frequency_align (gint mix_freq)
}
return best;
}
-
static void
bse_pcm_device_class_init (BsePcmDeviceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->dispose = bse_pcm_device_dispose;
-
device_class->post_open = pcm_device_post_open;
device_class->pre_close = pcm_device_pre_close;
}
-
BSE_BUILTIN_TYPE (BsePcmDevice)
{
static const GTypeInfo pcm_device_info = {
sizeof (BsePcmDeviceClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_device_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BsePcmDevice),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_device_init,
};
-
return bse_type_register_abstract (BSE_TYPE_DEVICE,
"BsePcmDevice",
"PCM device base type",
diff --git a/bse/bsepcmdevice.hh b/bse/bsepcmdevice.hh
index 4568b1f..4a4604c 100644
--- a/bse/bsepcmdevice.hh
+++ b/bse/bsepcmdevice.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_DEVICE_H__
#define __BSE_PCM_DEVICE_H__
-
#include <bse/bsedevice.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_DEVICE (BSE_TYPE_ID (BsePcmDevice))
#define BSE_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE, BsePcmDevice))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE))
#define BSE_IS_PCM_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE))
#define BSE_PCM_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE, BsePcmDeviceClass))
-
-
/* --- capabilities --- */
#define BSE_PCM_FREQ_MIN BSE_PCM_FREQ_8000
#define BSE_PCM_FREQ_MAX BSE_PCM_FREQ_192000
@@ -23,8 +18,6 @@ typedef enum /*< skip >*/
BSE_PCM_CMODE_MONO = 1,
BSE_PCM_CMODE_STEREO
} BsePcmChannelMode;
-
-
/* --- BsePcmDevice structs --- */
typedef struct _BsePcmStatus BsePcmStatus;
typedef struct _BsePcmHandle BsePcmHandle;
@@ -49,13 +42,11 @@ struct _BsePcmHandle
struct _BsePcmDevice
{
BseDevice parent_instance;
-
/* requested caps */
guint req_n_channels;
guint req_mix_freq;
guint req_latency_ms; /* latency in milliseconds */
guint req_block_length; /* in frames, a guess at block_length after open() */
-
/* operational handle */
BsePcmHandle *handle;
};
@@ -63,8 +54,6 @@ struct _BsePcmDeviceClass
{
BseDeviceClass parent_class;
};
-
-
/* --- prototypes --- */
void bse_pcm_device_request (BsePcmDevice *pdev,
guint n_channels,
@@ -83,12 +72,7 @@ void bse_pcm_handle_write (BsePcmHandle *handle,
gboolean bse_pcm_handle_check_io (BsePcmHandle *handle,
glong *timeoutp);
guint bse_pcm_handle_latency (BsePcmHandle *handle);
-
-
/* --- misc utils --- */
guint bse_pcm_device_frequency_align (gint mix_freq);
-
-
G_END_DECLS
-
#endif /* __BSE_PCM_DEVICE_H__ */
diff --git a/bse/bsepcminput.cc b/bse/bsepcminput.cc
index 2a524c8..addad12 100644
--- a/bse/bsepcminput.cc
+++ b/bse/bsepcminput.cc
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsepcminput.hh"
-
#include "bsecategories.hh"
#include "bseserver.hh"
#include "bseengine.hh"
-
-
-
/* --- parameters --- */
enum
{
@@ -15,8 +11,6 @@ enum
PARAM_MVOLUME_dB,
PARAM_MVOLUME_PERC
};
-
-
/* --- prototypes --- */
static void bse_pcm_input_init (BsePcmInput *scard);
static void bse_pcm_input_class_init (BsePcmInputClass *klass);
@@ -37,24 +31,18 @@ static void bse_pcm_input_context_connect (BseSource *source,
guint instance_id,
BseTrans *trans);
static void bse_pcm_input_reset (BseSource *source);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BsePcmInput)
{
static const GTypeInfo pcm_input_info = {
sizeof (BsePcmInputClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_input_class_init,
(GClassFinalizeFunc) bse_pcm_input_class_finalize,
NULL /* class_data */,
-
sizeof (BsePcmInput),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_input_init,
@@ -69,7 +57,6 @@ BSE_BUILTIN_TYPE (BsePcmInput)
bse_categories_register_stock_module (N_("/Input & Output/PCM Input"), type, mic_pixstream);
return type;
}
-
static void
bse_pcm_input_class_init (BsePcmInputClass *klass)
{
@@ -77,17 +64,13 @@ bse_pcm_input_class_init (BsePcmInputClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_pcm_input_set_property;
gobject_class->get_property = bse_pcm_input_get_property;
-
source_class->prepare = bse_pcm_input_prepare;
source_class->context_create = bse_pcm_input_context_create;
source_class->context_connect = bse_pcm_input_context_connect;
source_class->reset = bse_pcm_input_reset;
-
bse_object_class_add_param (object_class, "Adjustments",
PARAM_MVOLUME_f,
sfi_pspec_real ("gain_volume_f", "Input Gain [float]", NULL,
@@ -108,24 +91,20 @@ bse_pcm_input_class_init (BsePcmInputClass *klass)
bse_db_to_factor (0) * 100,
0, bse_db_to_factor (BSE_MAX_VOLUME_dB) * 100,
1, SFI_PARAM_GUI ":dial"));
-
ochannel_id = bse_source_class_add_ochannel (source_class, "left-audio-out", _("Left Audio Out"), _("Left channel output"));
g_assert (ochannel_id == BSE_PCM_INPUT_OCHANNEL_LEFT);
ochannel_id = bse_source_class_add_ochannel (source_class, "right-audio-out", _("Right Audio Out"), _("Right channel output"));
g_assert (ochannel_id == BSE_PCM_INPUT_OCHANNEL_RIGHT);
}
-
static void
bse_pcm_input_class_finalize (BsePcmInputClass *klass)
{
}
-
static void
bse_pcm_input_init (BsePcmInput *iput)
{
iput->volume_factor = bse_db_to_factor (0);
}
-
static void
bse_pcm_input_set_property (GObject *object,
guint param_id,
@@ -155,7 +134,6 @@ bse_pcm_input_set_property (GObject *object,
break;
}
}
-
static void
bse_pcm_input_get_property (GObject *object,
guint param_id,
@@ -179,23 +157,18 @@ bse_pcm_input_get_property (GObject *object,
break;
}
}
-
static void
bse_pcm_input_prepare (BseSource *source)
{
BsePcmInput *iput = BSE_PCM_INPUT (source);
-
iput->uplink = bse_server_retrieve_pcm_input_module (bse_server_get (), source, "MasterIn");
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
typedef struct {
gfloat volume;
gboolean volume_set;
} ModData;
-
static void
pcm_input_process (BseModule *module,
guint n_values)
@@ -206,7 +179,6 @@ pcm_input_process (BseModule *module,
gfloat *ld = BSE_MODULE_OBUFFER (module, BSE_PCM_INPUT_OCHANNEL_LEFT);
gfloat *rd = BSE_MODULE_OBUFFER (module, BSE_PCM_INPUT_OCHANNEL_RIGHT);
gfloat v = mdata->volume;
-
if (mdata->volume_set)
while (n_values--)
{
@@ -219,7 +191,6 @@ pcm_input_process (BseModule *module,
BSE_MODULE_OBUFFER (module, BSE_PCM_INPUT_OCHANNEL_RIGHT) = (gfloat*) BSE_MODULE_IBUFFER (module, BSE_PCM_INPUT_OCHANNEL_RIGHT);
}
}
-
static void
bse_pcm_input_context_create (BseSource *source,
guint context_handle,
@@ -237,20 +208,15 @@ bse_pcm_input_context_create (BseSource *source,
};
ModData *mdata = g_new0 (ModData, 1);
BseModule *module = bse_module_new (&pcm_input_mclass, mdata);
-
mdata->volume = 1.0;
mdata->volume_set = mdata->volume != 1.0;
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_omodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_pcm_input_context_connect (BseSource *source,
guint context_handle,
@@ -258,26 +224,20 @@ bse_pcm_input_context_connect (BseSource *source,
{
BsePcmInput *iput = BSE_PCM_INPUT (source);
BseModule *module;
-
/* get context specific module */
module = bse_source_get_context_omodule (source, context_handle);
-
/* connect module to server uplink */
bse_trans_add (trans, bse_job_connect (iput->uplink, 0, module, 0));
bse_trans_add (trans, bse_job_connect (iput->uplink, 1, module, 1));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_pcm_input_reset (BseSource *source)
{
BsePcmInput *iput = BSE_PCM_INPUT (source);
-
bse_server_discard_pcm_input_module (bse_server_get (), iput->uplink);
iput->uplink = NULL;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
diff --git a/bse/bsepcminput.hh b/bse/bsepcminput.hh
index 9accc27..1aa8304 100644
--- a/bse/bsepcminput.hh
+++ b/bse/bsepcminput.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_INPUT_H__
#define __BSE_PCM_INPUT_H__
-
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_INPUT (BSE_TYPE_ID (BsePcmInput))
#define BSE_PCM_INPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_INPUT, BsePcmInput))
@@ -13,17 +10,13 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_INPUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_INPUT))
#define BSE_IS_PCM_INPUT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_INPUT))
#define BSE_PCM_INPUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_INPUT, BsePcmInputClass))
-
-
/* --- BsePcmInput source --- */
typedef struct _BsePcmInput BsePcmInput;
typedef struct _BsePcmInputClass BsePcmInputClass;
struct _BsePcmInput
{
BseSource parent_object;
-
gfloat volume_factor;
-
/* PREPARED */
BseModule *uplink;
};
@@ -31,8 +24,6 @@ struct _BsePcmInputClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -40,8 +31,5 @@ enum
BSE_PCM_INPUT_OCHANNEL_RIGHT,
BSE_PCM_INPUT_N_OCHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_PCM_INPUT_H__ */
diff --git a/bse/bsepcmmodule.cc b/bse/bsepcmmodule.cc
index 5ed17c2..a041723 100644
--- a/bse/bsepcmmodule.cc
+++ b/bse/bsepcmmodule.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseengine.hh"
#include "bsepcmdevice.hh"
-
-
/* --- typedefs & structures --- */
typedef struct
{
@@ -25,8 +23,6 @@ enum
BSE_PCM_MODULE_OSTREAM_RIGHT,
BSE_PCM_MODULE_N_OSTREAMS
};
-
-
/* --- prototypes --- */
static BseModule* bse_pcm_omodule_insert (BsePcmHandle *handle,
BsePcmWriter *writer,
@@ -37,8 +33,6 @@ static BseModule* bse_pcm_imodule_insert (BsePcmHandle *handle,
BseTrans *trans);
static void bse_pcm_imodule_remove (BseModule *pcm_module,
BseTrans *trans);
-
-
/* --- functions --- */
static gboolean
bse_pcm_module_poll (gpointer data,
@@ -52,7 +46,6 @@ bse_pcm_module_poll (gpointer data,
BsePcmHandle *handle = mdata->handle;
return bse_pcm_handle_check_io (handle, timeout_p);
}
-
static void
bse_pcm_omodule_process (BseModule *module,
guint n_values)
@@ -62,9 +55,7 @@ bse_pcm_omodule_process (BseModule *module,
gfloat *b = mdata->bound;
const gfloat *src;
guint i;
-
g_return_if_fail (n_values == mdata->n_values / BSE_PCM_MODULE_N_JSTREAMS);
-
if (BSE_MODULE_JSTREAM (module, BSE_PCM_MODULE_JSTREAM_LEFT).n_connections)
src = BSE_MODULE_JBUFFER (module, BSE_PCM_MODULE_JSTREAM_LEFT, 0);
else
@@ -77,7 +68,6 @@ bse_pcm_omodule_process (BseModule *module,
d = mdata->buffer;
do { *d += *src++; d += 2; } while (d < b);
}
-
if (BSE_MODULE_JSTREAM (module, BSE_PCM_MODULE_JSTREAM_RIGHT).n_connections)
src = BSE_MODULE_JBUFFER (module, BSE_PCM_MODULE_JSTREAM_RIGHT, 0);
else
@@ -90,22 +80,18 @@ bse_pcm_omodule_process (BseModule *module,
d = mdata->buffer + 1;
do { *d += *src++; d += 2; } while (d < b);
}
-
bse_pcm_handle_write (mdata->handle, mdata->n_values, mdata->buffer);
if (mdata->pcm_writer)
bse_pcm_writer_write (mdata->pcm_writer, mdata->n_values, mdata->buffer);
}
-
static void
bse_pcm_module_data_free (gpointer data,
const BseModuleClass *klass)
{
BsePCMModuleData *mdata = (BsePCMModuleData*) data;
-
g_free (mdata->buffer);
g_free (mdata);
}
-
static BseModule*
bse_pcm_omodule_insert (BsePcmHandle *handle,
BsePcmWriter *writer,
@@ -123,11 +109,9 @@ bse_pcm_omodule_insert (BsePcmHandle *handle,
};
BsePCMModuleData *mdata;
BseModule *module;
-
g_return_val_if_fail (handle != NULL, NULL);
g_return_val_if_fail (handle->write != NULL, NULL);
g_return_val_if_fail (trans != NULL, NULL);
-
mdata = g_new0 (BsePCMModuleData, 1);
mdata->n_values = bse_engine_block_size () * BSE_PCM_MODULE_N_JSTREAMS;
mdata->buffer = g_new0 (gfloat, mdata->n_values);
@@ -135,38 +119,32 @@ bse_pcm_omodule_insert (BsePcmHandle *handle,
mdata->handle = handle;
mdata->pcm_writer = writer;
module = bse_module_new (&pcm_omodule_class, mdata);
-
bse_trans_add (trans,
bse_job_integrate (module));
bse_trans_add (trans,
bse_job_set_consumer (module, TRUE));
bse_trans_add (trans,
bse_job_add_poll (bse_pcm_module_poll, mdata, NULL, 0, NULL));
-
return module;
}
-
static void
bse_pcm_omodule_remove (BseModule *pcm_module,
BseTrans *trans)
{
g_return_if_fail (pcm_module != NULL);
g_return_if_fail (trans != NULL);
-
BsePCMModuleData *mdata = (BsePCMModuleData*) pcm_module->user_data;
bse_trans_add (trans,
bse_job_remove_poll (bse_pcm_module_poll, mdata));
bse_trans_add (trans,
bse_job_discard (pcm_module));
}
-
static gboolean
pcm_imodule_check_input (gpointer data) /* UserThread */
{
bse_server_require_pcm_input (bse_server_get());
return FALSE;
}
-
static void
bse_pcm_imodule_reset (BseModule *module) /* EngineThread */
{
@@ -178,7 +156,6 @@ bse_pcm_imodule_reset (BseModule *module) /* EngineThread */
bse_idle_now (pcm_imodule_check_input, NULL);
}
}
-
static void
bse_pcm_imodule_process (BseModule *module, /* EngineThread */
guint n_values)
@@ -187,9 +164,7 @@ bse_pcm_imodule_process (BseModule *module, /* EngineThread */
gfloat *left = BSE_MODULE_OBUFFER (module, BSE_PCM_MODULE_OSTREAM_LEFT);
gfloat *right = BSE_MODULE_OBUFFER (module, BSE_PCM_MODULE_OSTREAM_RIGHT);
gsize l;
-
g_return_if_fail (n_values <= mdata->n_values / BSE_PCM_MODULE_N_OSTREAMS);
-
if (mdata->handle->readable)
{
l = bse_pcm_handle_read (mdata->handle, mdata->n_values, mdata->buffer);
@@ -197,7 +172,6 @@ bse_pcm_imodule_process (BseModule *module, /* EngineThread */
}
else
memset (mdata->buffer, 0, mdata->n_values * sizeof (gfloat));
-
/* due to suspend/resume, we may be called with partial read requests */
const gfloat *s = mdata->buffer + mdata->n_values - (n_values * BSE_PCM_MODULE_N_OSTREAMS);
const gfloat *b = mdata->bound;
@@ -208,7 +182,6 @@ bse_pcm_imodule_process (BseModule *module, /* EngineThread */
}
while (s < b);
}
-
static BseModule*
bse_pcm_imodule_insert (BsePcmHandle *handle,
BseTrans *trans)
@@ -225,11 +198,9 @@ bse_pcm_imodule_insert (BsePcmHandle *handle,
};
BsePCMModuleData *mdata;
BseModule *module;
-
g_return_val_if_fail (handle != NULL, NULL);
g_return_val_if_fail (handle->write != NULL, NULL);
g_return_val_if_fail (trans != NULL, NULL);
-
mdata = g_new0 (BsePCMModuleData, 1);
mdata->n_values = bse_engine_block_size () * BSE_PCM_MODULE_N_OSTREAMS;
mdata->buffer = g_new0 (gfloat, mdata->n_values);
@@ -237,20 +208,16 @@ bse_pcm_imodule_insert (BsePcmHandle *handle,
mdata->handle = handle;
mdata->pcm_writer = NULL;
module = bse_module_new (&pcm_imodule_class, mdata);
-
bse_trans_add (trans,
bse_job_integrate (module));
-
return module;
}
-
static void
bse_pcm_imodule_remove (BseModule *pcm_module,
BseTrans *trans)
{
g_return_if_fail (pcm_module != NULL);
g_return_if_fail (trans != NULL);
-
bse_trans_add (trans,
bse_job_discard (pcm_module));
}
diff --git a/bse/bsepcmoutput.cc b/bse/bsepcmoutput.cc
index 9ff937b..bff5dad 100644
--- a/bse/bsepcmoutput.cc
+++ b/bse/bsepcmoutput.cc
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsepcmoutput.hh"
-
#include "bsecategories.hh"
#include "bseserver.hh"
#include "bseengine.hh"
-
-
-
/* --- parameters --- */
enum
{
@@ -15,8 +11,6 @@ enum
PARAM_MVOLUME_dB,
PARAM_MVOLUME_PERC
};
-
-
/* --- prototypes --- */
static void bse_pcm_output_init (BsePcmOutput *scard);
static void bse_pcm_output_class_init (BsePcmOutputClass *klass);
@@ -37,24 +31,18 @@ static void bse_pcm_output_context_connect (BseSource *source,
guint instance_id,
BseTrans *trans);
static void bse_pcm_output_reset (BseSource *source);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BsePcmOutput)
{
static const GTypeInfo pcm_output_info = {
sizeof (BsePcmOutputClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_output_class_init,
(GClassFinalizeFunc) bse_pcm_output_class_finalize,
NULL /* class_data */,
-
sizeof (BsePcmOutput),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_output_init,
@@ -69,7 +57,6 @@ BSE_BUILTIN_TYPE (BsePcmOutput)
bse_categories_register_stock_module (N_("/Input & Output/PCM Output"), type, speaker_pixstream);
return type;
}
-
static void
bse_pcm_output_class_init (BsePcmOutputClass *klass)
{
@@ -77,17 +64,13 @@ bse_pcm_output_class_init (BsePcmOutputClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ichannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_pcm_output_set_property;
gobject_class->get_property = bse_pcm_output_get_property;
-
source_class->prepare = bse_pcm_output_prepare;
source_class->context_create = bse_pcm_output_context_create;
source_class->context_connect = bse_pcm_output_context_connect;
source_class->reset = bse_pcm_output_reset;
-
bse_object_class_add_param (object_class, "Adjustments",
PARAM_MVOLUME_f,
sfi_pspec_real ("master_volume_f", "Master [float]", NULL,
@@ -108,24 +91,20 @@ bse_pcm_output_class_init (BsePcmOutputClass *klass)
bse_db_to_factor (0) * 100,
0, bse_db_to_factor (BSE_MAX_VOLUME_dB) * 100,
1, SFI_PARAM_GUI ":dial"));
-
ichannel_id = bse_source_class_add_ichannel (source_class, "left-audio-in", _("Left Audio In"), _("Left channel input"));
g_assert (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_LEFT);
ichannel_id = bse_source_class_add_ichannel (source_class, "right-audio-in", _("Right Audio In"), _("Right channel Input"));
g_assert (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_RIGHT);
}
-
static void
bse_pcm_output_class_finalize (BsePcmOutputClass *klass)
{
}
-
static void
bse_pcm_output_init (BsePcmOutput *oput)
{
oput->volume_factor = bse_db_to_factor (0);
}
-
static void
bse_pcm_output_set_property (GObject *object,
guint param_id,
@@ -155,7 +134,6 @@ bse_pcm_output_set_property (GObject *object,
break;
}
}
-
static void
bse_pcm_output_get_property (GObject *object,
guint param_id,
@@ -179,23 +157,18 @@ bse_pcm_output_get_property (GObject *object,
break;
}
}
-
static void
bse_pcm_output_prepare (BseSource *source)
{
BsePcmOutput *oput = BSE_PCM_OUTPUT (source);
-
oput->uplink = bse_server_retrieve_pcm_output_module (bse_server_get (), source, "MasterOut");
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
typedef struct {
gfloat volume;
gboolean volume_set;
} ModData;
-
static void
pcm_output_process (BseModule *module,
guint n_values)
@@ -206,7 +179,6 @@ pcm_output_process (BseModule *module,
gfloat *ld = BSE_MODULE_OBUFFER (module, BSE_PCM_OUTPUT_ICHANNEL_LEFT);
gfloat *rd = BSE_MODULE_OBUFFER (module, BSE_PCM_OUTPUT_ICHANNEL_RIGHT);
gfloat v = mdata->volume;
-
if (mdata->volume_set)
while (n_values--)
{
@@ -219,7 +191,6 @@ pcm_output_process (BseModule *module,
BSE_MODULE_OBUFFER (module, BSE_PCM_OUTPUT_ICHANNEL_RIGHT) = (gfloat*) BSE_MODULE_IBUFFER (module, BSE_PCM_OUTPUT_ICHANNEL_RIGHT);
}
}
-
static void
bse_pcm_output_context_create (BseSource *source,
guint context_handle,
@@ -237,20 +208,15 @@ bse_pcm_output_context_create (BseSource *source,
};
ModData *mdata = g_new0 (ModData, 1);
BseModule *module = bse_module_new (&pcm_output_mclass, mdata);
-
mdata->volume = 1.0;
mdata->volume_set = mdata->volume != 1.0;
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_imodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_pcm_output_context_connect (BseSource *source,
guint context_handle,
@@ -258,26 +224,20 @@ bse_pcm_output_context_connect (BseSource *source,
{
BsePcmOutput *oput = BSE_PCM_OUTPUT (source);
BseModule *module;
-
/* get context specific module */
module = bse_source_get_context_imodule (source, context_handle);
-
/* connect module to server uplink */
bse_trans_add (trans, bse_job_jconnect (module, 0, oput->uplink, 0));
bse_trans_add (trans, bse_job_jconnect (module, 1, oput->uplink, 1));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_pcm_output_reset (BseSource *source)
{
BsePcmOutput *oput = BSE_PCM_OUTPUT (source);
-
bse_server_discard_pcm_output_module (bse_server_get (), oput->uplink);
oput->uplink = NULL;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
diff --git a/bse/bsepcmoutput.hh b/bse/bsepcmoutput.hh
index b4db205..114b33f 100644
--- a/bse/bsepcmoutput.hh
+++ b/bse/bsepcmoutput.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_OUTPUT_H__
#define __BSE_PCM_OUTPUT_H__
-
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_OUTPUT (BSE_TYPE_ID (BsePcmOutput))
#define BSE_PCM_OUTPUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_OUTPUT, BsePcmOutput))
@@ -16,17 +12,13 @@ extern "C" {
#define BSE_IS_PCM_OUTPUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_OUTPUT))
#define BSE_IS_PCM_OUTPUT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_OUTPUT))
#define BSE_PCM_OUTPUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_OUTPUT, BsePcmOutputClass))
-
-
/* --- BsePcmOutput source --- */
typedef struct _BsePcmOutput BsePcmOutput;
typedef struct _BsePcmOutputClass BsePcmOutputClass;
struct _BsePcmOutput
{
BseSource parent_object;
-
gfloat volume_factor;
-
/* PREPARED */
BseModule *uplink;
};
@@ -34,8 +26,6 @@ struct _BsePcmOutputClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -43,13 +33,7 @@ enum
BSE_PCM_OUTPUT_ICHANNEL_RIGHT,
BSE_PCM_OUTPUT_N_ICHANNELS
};
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_PCM_OUTPUT_H__ */
diff --git a/bse/bsepcmwriter.cc b/bse/bsepcmwriter.cc
index 08bd307..5004acb 100644
--- a/bse/bsepcmwriter.cc
+++ b/bse/bsepcmwriter.cc
@@ -2,80 +2,62 @@
#include "bsepcmwriter.hh"
#include "bseserver.hh"
#include "gsldatautils.hh"
-
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-
-
/* --- prototypes --- */
static void bse_pcm_writer_init (BsePcmWriter *pdev);
static void bse_pcm_writer_class_init (BsePcmWriterClass *klass);
static void bse_pcm_writer_finalize (GObject *object);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BsePcmWriter)
{
static const GTypeInfo pcm_writer_info = {
sizeof (BsePcmWriterClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_pcm_writer_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BsePcmWriter),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_pcm_writer_init,
};
-
return bse_type_register_static (BSE_TYPE_ITEM,
"BsePcmWriter",
"PCM writer",
__FILE__, __LINE__,
&pcm_writer_info);
}
-
static void
bse_pcm_writer_class_init (BsePcmWriterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_pcm_writer_finalize;
}
-
static void
bse_pcm_writer_init (BsePcmWriter *self)
{
sfi_mutex_init (&self->mutex);
}
-
static void
bse_pcm_writer_finalize (GObject *object)
{
BsePcmWriter *self = BSE_PCM_WRITER (object);
-
if (self->open)
{
g_warning ("%s: pcm writer still opened", G_STRLOC);
bse_pcm_writer_close (self);
}
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
sfi_mutex_destroy (&self->mutex);
}
-
BseErrorType
bse_pcm_writer_open (BsePcmWriter *self,
const gchar *file,
@@ -84,15 +66,12 @@ bse_pcm_writer_open (BsePcmWriter *self,
uint64 recorded_maximum)
{
gint fd;
-
g_return_val_if_fail (BSE_IS_PCM_WRITER (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (!self->open, BSE_ERROR_INTERNAL);
g_return_val_if_fail (file != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (n_channels > 0, BSE_ERROR_INTERNAL);
g_return_val_if_fail (sample_freq >= 1000, BSE_ERROR_INTERNAL);
-
sfi_mutex_lock (&self->mutex);
-
self->n_bytes = 0;
self->recorded_maximum = recorded_maximum;
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -101,7 +80,6 @@ bse_pcm_writer_open (BsePcmWriter *self,
sfi_mutex_unlock (&self->mutex);
return bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
}
-
errno = bse_wave_file_dump_header (fd, 0x7fff0000, 16, n_channels, sample_freq);
if (errno)
{
@@ -112,17 +90,14 @@ bse_pcm_writer_open (BsePcmWriter *self,
self->fd = fd;
self->open = TRUE;
self->broken = FALSE;
-
sfi_mutex_unlock (&self->mutex);
return BSE_ERROR_NONE;
}
-
void
bse_pcm_writer_close (BsePcmWriter *self)
{
g_return_if_fail (BSE_IS_PCM_WRITER (self));
g_return_if_fail (self->open);
-
sfi_mutex_lock (&self->mutex);
bse_wave_file_patch_length (self->fd, self->n_bytes);
close (self->fd);
@@ -131,14 +106,12 @@ bse_pcm_writer_close (BsePcmWriter *self)
sfi_mutex_unlock (&self->mutex);
errno = 0;
}
-
static gboolean
bsethread_halt_recording (gpointer data)
{
bse_server_stop_recording (bse_server_get());
return false;
}
-
void
bse_pcm_writer_write (BsePcmWriter *self,
gsize n_values,
@@ -150,7 +123,6 @@ bse_pcm_writer_write (BsePcmWriter *self,
g_return_if_fail (values != NULL);
else
return;
-
sfi_mutex_lock (&self->mutex);
const uint bw = 2; /* 16bit */
if (!self->broken && (!self->recorded_maximum || self->n_bytes < bw * self->recorded_maximum))
diff --git a/bse/bsepcmwriter.hh b/bse/bsepcmwriter.hh
index 49f1269..12525e4 100644
--- a/bse/bsepcmwriter.hh
+++ b/bse/bsepcmwriter.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_WRITER_H__
#define __BSE_PCM_WRITER_H__
-
#include <bse/bseitem.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_WRITER (BSE_TYPE_ID (BsePcmWriter))
#define BSE_PCM_WRITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_WRITER, BsePcmWriter))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_WRITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_WRITER))
#define BSE_IS_PCM_WRITER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_WRITER))
#define BSE_PCM_WRITER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_WRITER, BsePcmWriterClass))
-
-
/* --- BsePcmWriter --- */
struct _BsePcmWriter
{
@@ -30,8 +25,6 @@ struct _BsePcmWriterClass
{
BseItemClass parent_class;
};
-
-
/* --- prototypes --- */
BseErrorType bse_pcm_writer_open (BsePcmWriter *pdev,
const gchar *file,
@@ -43,10 +36,7 @@ void bse_pcm_writer_close (BsePcmWriter *pdev);
void bse_pcm_writer_write (BsePcmWriter *pdev,
gsize n_values,
const gfloat *values);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_PCM_WRITER_H__ */
diff --git a/bse/bseplugin.cc b/bse/bseplugin.cc
index d4e28c0..efbd679 100644
--- a/bse/bseplugin.cc
+++ b/bse/bseplugin.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseplugin.hh"
-
#include "bsecategories.hh"
#include "bseprocedure.hh"
#include "bseobject.hh"
@@ -11,12 +10,8 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-
-
static SFI_MSG_TYPE_DEFINE (debug_plugins, "plugins", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_plugins, __VA_ARGS__)
-
-
/* --- prototypes --- */
static void bse_plugin_init (BsePlugin *plugin);
static void bse_plugin_class_init (BsePluginClass *klass);
@@ -30,13 +25,10 @@ static void bse_plugin_init_types (BsePlugin *plugin);
static void bse_plugin_reinit_types (BsePlugin *plugin);
static void bse_plugin_uninit_types (BsePlugin *plugin);
static void type_plugin_iface_init (GTypePluginClass *iface);
-
/* --- variables --- */
static GSList *bse_plugins = NULL;
static BseExportNode builtin_export_chain_head = { NULL, BSE_EXPORT_NODE_LINK, };
BseExportIdentity bse_builtin_export_identity = BSE_EXPORT_IDENTITY (builtin_export_chain_head);
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BsePlugin)
{
@@ -60,7 +52,6 @@ BSE_BUILTIN_TYPE (BsePlugin)
g_type_add_interface_static (plugin_type, G_TYPE_TYPE_PLUGIN, &iface_info);
return plugin_type;
}
-
static void
type_plugin_iface_init (GTypePluginClass *iface)
{
@@ -68,43 +59,33 @@ type_plugin_iface_init (GTypePluginClass *iface)
iface->unuse_plugin = bse_plugin_unuse;
iface->complete_type_info = bse_plugin_complete_info;
}
-
static void
bse_plugin_dispose (GObject *object)
{
BsePlugin *plugin = BSE_PLUGIN (object);
-
if (plugin->gmodule || plugin->use_count || plugin->n_types)
g_warning ("%s: plugin partially initialized during destruciton", G_STRFUNC);
-
/* chain parent class handler */
G_OBJECT_CLASS (g_type_class_peek_parent (BSE_PLUGIN_GET_CLASS (plugin)))->dispose (object);
}
-
static void
bse_plugin_finalize (GObject *object)
{
BsePlugin *plugin = BSE_PLUGIN (object);
-
if (plugin->gmodule || plugin->use_count || plugin->n_types)
g_warning ("%s: plugin partially initialized during destruciton", G_STRFUNC);
-
/* chain parent class handler */
G_OBJECT_CLASS (g_type_class_peek_parent (BSE_PLUGIN_GET_CLASS (plugin)))->finalize (object);
-
g_free (plugin->fname);
g_free (plugin->types);
}
-
static void
bse_plugin_class_init (BsePluginClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
gobject_class->dispose = bse_plugin_dispose;
gobject_class->finalize = bse_plugin_finalize;
}
-
static void
bse_plugin_init (BsePlugin *plugin)
{
@@ -118,9 +99,7 @@ bse_plugin_init (BsePlugin *plugin)
plugin->n_types = 0;
plugin->types = NULL;
}
-
#include "bsebuiltin_externs.cc" // include extern declarations of builtin init functions
-
void
bse_plugin_init_builtins (void)
{
@@ -132,7 +111,6 @@ bse_plugin_init_builtins (void)
};
static const guint n_builtin_inits = G_N_ELEMENTS (builtin_inits);
guint i;
-
/* initialize builtin types via pseudo plugin handle */
for (i = 0; i < n_builtin_inits; i++)
{
@@ -163,7 +141,6 @@ bse_plugin_init_builtins (void)
}
}
}
-
static guint64
runtime_export_config (void)
{
@@ -187,16 +164,13 @@ runtime_export_config (void)
emask |= BSE_EXPORT_FLAG_SSE4;
return emask;
}
-
static BsePlugin *startup_plugin = NULL;
-
void
bse_plugin_make_resident()
{
g_assert (startup_plugin != NULL);
startup_plugin->resident_types = TRUE;
}
-
BsePlugin*
bse_exports__add_node (const BseExportIdentity *identity,
BseExportNode *enode)
@@ -217,7 +191,6 @@ bse_exports__add_node (const BseExportIdentity *identity,
}
return startup_plugin;
}
-
static const char*
plugin_check_identity (BsePlugin *plugin, GModule *gmodule)
{
@@ -237,15 +210,12 @@ plugin_check_identity (BsePlugin *plugin, GModule *gmodule)
plugin->force_clean = true;
}
}
-
if (!plugin->version_match)
return "Invalid BSE Plugin Version";
if (plugin->missing_export_flags)
return "Incompatible CPU requirements";
-
return NULL;
}
-
static void
bse_plugin_use (GTypePlugin *gplugin)
{
@@ -266,13 +236,11 @@ bse_plugin_use (GTypePlugin *gplugin)
g_error ("failed to reinitialize plugin \"%s\": %s", plugin->fname, cerror);
if (!plugin->chain)
g_error ("failed to reinitialize plugin \"%s\": %s", plugin->fname, "empty plugin");
-
bse_plugin_reinit_types (plugin);
}
else
plugin->use_count++;
}
-
void
bse_exports__del_node (BsePlugin *plugin,
BseExportNode *enode)
@@ -294,32 +262,25 @@ bse_exports__del_node (BsePlugin *plugin,
}
g_warning ("%s: plugin attempt to unregister invalid export node: %s", plugin->fname, enode->name);
}
-
static void
bse_plugin_unload (BsePlugin *plugin)
{
g_return_if_fail (plugin->gmodule != NULL && plugin->fname != NULL);
g_return_if_fail (plugin->use_count == 0);
g_return_if_fail (plugin->resident_types == 0);
-
bse_plugin_uninit_types (plugin);
g_module_close ((GModule*) plugin->gmodule);
plugin->gmodule = NULL;
-
/* reset plugin local pointers */
if (plugin->force_clean)
plugin->chain = NULL;
-
DEBUG ("unloaded-plugin: %s", plugin->fname);
}
-
static void
bse_plugin_unuse (GTypePlugin *gplugin)
{
BsePlugin *plugin = BSE_PLUGIN (gplugin);
-
g_return_if_fail (plugin->use_count > 0);
-
plugin->use_count--;
if (!plugin->use_count)
{
@@ -333,7 +294,6 @@ bse_plugin_unuse (GTypePlugin *gplugin)
}
g_object_unref (G_OBJECT (plugin));
}
-
static void
bse_plugin_uninit_types (BsePlugin *plugin)
{
@@ -351,7 +311,6 @@ bse_plugin_uninit_types (BsePlugin *plugin)
}
}
}
-
static void
bse_plugin_complete_info (GTypePlugin *gplugin,
GType type,
@@ -360,10 +319,8 @@ bse_plugin_complete_info (GTypePlugin *gplugin,
{
BsePlugin *plugin = BSE_PLUGIN (gplugin);
BseExportNode *node;
-
g_return_if_fail (plugin != NULL);
g_return_if_fail (plugin->use_count > 0);
-
for (node = plugin->chain; node && node->ntype; node = node->next)
if (node->type == type)
{
@@ -402,14 +359,12 @@ bse_plugin_complete_info (GTypePlugin *gplugin,
if (!node || node->type != type)
g_error ("%s: unable to complete type from plugin: %s", plugin->fname, g_type_name (type));
}
-
static void
bse_plugin_reinit_types (BsePlugin *plugin)
{
guint n = plugin->n_types;
GType *types = (GType*) g_memdup (plugin->types, sizeof (plugin->types[0]) * n);
BseExportNode *node;
-
for (node = plugin->chain; node && node->ntype; node = node->next)
{
GType type = node->name ? g_type_from_name (node->name) : 0;
@@ -442,12 +397,10 @@ bse_plugin_reinit_types (BsePlugin *plugin)
g_warning ("%s: plugin failed to reregister type: %s", plugin->fname, g_type_name (types[n]));
g_free (types);
}
-
static void
bse_plugin_init_types (BsePlugin *plugin)
{
BseExportNode *node;
-
/* check type uniqueness */
for (node = plugin->chain; node && node->ntype; node = node->next)
switch (node->ntype)
@@ -486,7 +439,6 @@ bse_plugin_init_types (BsePlugin *plugin)
break;
default: ;
}
-
/* register BSE module types */
for (node = plugin->chain; node && node->ntype; node = node->next)
{
@@ -563,7 +515,6 @@ bse_plugin_init_types (BsePlugin *plugin)
}
}
}
-
static inline BsePlugin*
bse_plugin_find (GModule *gmodule)
{
@@ -575,7 +526,6 @@ bse_plugin_find (GModule *gmodule)
}
return NULL;
}
-
const gchar*
bse_plugin_check_load (const gchar *const_file_name)
{
@@ -583,9 +533,7 @@ bse_plugin_check_load (const gchar *const_file_name)
GModule *gmodule;
gchar *error = NULL;
const gchar *cerror = NULL;
-
g_return_val_if_fail (const_file_name != NULL, NULL);
-
if (0) /* want to read .la files? */
{
const gint TOKEN_DLNAME = G_TOKEN_LAST + 1;
@@ -596,18 +544,15 @@ bse_plugin_check_load (const gchar *const_file_name)
return (errno == ENOENT || errno == ENOTDIR || errno == ELOOP ?
bse_error_blurb (BSE_ERROR_FILE_NOT_FOUND) :
"Unable to access plugin");
-
/* and search libtool's dlname specification */
scanner = g_scanner_new64 (NULL);
g_scanner_input_file (scanner, fd);
scanner->config->symbol_2_token = TRUE;
g_scanner_add_symbol (scanner, "dlname", GUINT_TO_POINTER (TOKEN_DLNAME));
-
/* skip ahead */
while (!g_scanner_eof (scanner) &&
g_scanner_peek_next_token (scanner) != TOKEN_DLNAME)
g_scanner_get_next_token (scanner);
-
/* parse dlname */
if (g_scanner_get_next_token (scanner) != TOKEN_DLNAME ||
g_scanner_get_next_token (scanner) != '=' ||
@@ -615,10 +560,8 @@ bse_plugin_check_load (const gchar *const_file_name)
{
g_scanner_destroy (scanner);
close (fd);
-
return "Plugin's dlname broken";
}
-
/* construct real module name */
if (g_path_is_absolute (scanner->value.v_string))
file_name = g_strdup (scanner->value.v_string);
@@ -633,9 +576,7 @@ bse_plugin_check_load (const gchar *const_file_name)
}
else
file_name = g_strdup (const_file_name);
-
DEBUG ("register: %s", file_name);
-
/* load module */
BsePlugin *plugin = (BsePlugin*) g_object_new (BSE_TYPE_PLUGIN, NULL);
plugin->fname = g_strdup (file_name);
@@ -659,7 +600,6 @@ bse_plugin_check_load (const gchar *const_file_name)
g_object_unref (plugin);
return cerror;
}
-
/* verify plugin identity (BSE + version) */
cerror = plugin_check_identity (plugin, gmodule);
if (cerror)
@@ -670,16 +610,13 @@ bse_plugin_check_load (const gchar *const_file_name)
g_object_unref (plugin);
return cerror;
}
-
/* create plugin if this is a BSE plugin with valid type chain */
if (plugin->chain)
{
plugin->fname = file_name;
plugin->gmodule = gmodule;
-
/* register BSE module types */
bse_plugin_init_types (plugin);
-
bse_plugins = g_slist_prepend (bse_plugins, plugin);
if (plugin->use_count == 0)
bse_plugin_unload (plugin);
@@ -699,12 +636,9 @@ bse_plugin_check_load (const gchar *const_file_name)
g_free (file_name);
g_object_unref (plugin);
}
-
return error;
}
-
#include "topconfig.h"
-
static bool
plugin_extension_filter (const char *fname,
guint n,
@@ -722,13 +656,11 @@ plugin_extension_filter (const char *fname,
return true;
return false;
}
-
#ifdef WIN32
#define PLUGIN_EXTENSION ".dll"
#else
#define PLUGIN_EXTENSION ".so"
#endif
-
SfiRing*
bse_plugin_path_list_files (gboolean include_drivers,
gboolean include_plugins)
diff --git a/bse/bseplugin.hh b/bse/bseplugin.hh
index 344ff23..a042fc1 100644
--- a/bse/bseplugin.hh
+++ b/bse/bseplugin.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PLUGIN_H__
#define __BSE_PLUGIN_H__
-
#include <bse/bse.hh> /* for bse_check_version() */
#include <bse/bseexports.hh>
-
G_BEGIN_DECLS
-
-
/* --- BSE type macros --- */
#define BSE_TYPE_PLUGIN (BSE_TYPE_ID (BsePlugin))
#define BSE_PLUGIN(plugin) (G_TYPE_CHECK_INSTANCE_CAST ((plugin), BSE_TYPE_PLUGIN, BsePlugin))
@@ -15,13 +11,10 @@ G_BEGIN_DECLS
#define BSE_IS_PLUGIN(plugin) (G_TYPE_CHECK_INSTANCE_TYPE ((plugin), BSE_TYPE_PLUGIN))
#define BSE_IS_PLUGIN_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PLUGIN))
#define BSE_PLUGIN_GET_CLASS(plugin) (G_TYPE_INSTANCE_GET_CLASS ((plugin), BSE_TYPE_PLUGIN, BsePluginClass))
-
-
/* --- BsePlugin --- */
struct _BsePlugin
{
GObject parent_instance;
-
gchar *fname;
gpointer gmodule;
guint64 missing_export_flags;
@@ -29,7 +22,6 @@ struct _BsePlugin
guint version_match : 1;
guint force_clean : 1;
guint resident_types : 1;
-
BseExportNode *chain;
guint n_types;
GType *types;
@@ -38,18 +30,13 @@ struct _BsePluginClass
{
GObjectClass parent_class;
};
-
-
/* --- prototypes --- */
SfiRing* bse_plugin_path_list_files (gboolean include_drivers,
gboolean include_plugins);
const gchar* bse_plugin_check_load (const gchar *file_name);
void bse_plugin_make_resident ();
-
/* --- implementation details --- */
void bse_plugin_init_builtins (void);
extern BseExportIdentity bse_builtin_export_identity; /* sync with bsecxxplugin.hh */
-
G_END_DECLS
-
#endif /* __BSE_PLUGIN_H__ */
diff --git a/bse/bseprobe.cc b/bse/bseprobe.cc
index 5421e27..63a9983 100644
--- a/bse/bseprobe.cc
+++ b/bse/bseprobe.cc
@@ -8,14 +8,11 @@
#include <set>
using namespace std;
using namespace Sfi;
-
namespace { // Anon
using namespace Bse;
-
/* --- variables --- */
static guint MAX_QUEUE_LENGTH = 3; // or, for 20ms: (int) (bse_engine_sample_freq() * 0.020 / bse_engine_block_size() + 0.5)
static guint bse_source_signal_probes = 0;
-
/* --- functions --- */
static inline double
blackman_window (double x)
@@ -27,8 +24,6 @@ blackman_window (double x)
return 0;
return 0.42 - 0.5 * cos (PI * x * 2) + 0.08 * cos (4 * PI * x);
}
-
-
/* --- ProbeQueue --- */
class SourceProbes;
class ProbeQueue {
@@ -315,8 +310,6 @@ public:
private:
BIRNET_PRIVATE_CLASS_COPY (ProbeQueue);
};
-
-
/* --- SourceProbes --- */
class SourceProbes {
typedef std::set<ProbeQueue*, ProbeQueue::KeyLesser> ProbeQueueSet;
@@ -561,17 +554,14 @@ public:
};
SfiRing *SourceProbes::bse_probe_sources = NULL;
guint SourceProbes::bse_idle_handler_id = 0;
-
void
ProbeQueue::queue_probes_update (uint probe_queue_length)
{
probes.queue_probes_update (probe_queue_length);
}
-
/* --- unprepared probing --- */
static SfiRing *bse_dummy_sources = NULL;
static guint bse_dummy_prober_id = 0;
-
static gboolean
bse_dummy_prober (gpointer data)
{
@@ -586,7 +576,6 @@ bse_dummy_prober (gpointer data)
bse_dummy_prober_id = 0;
return FALSE;
}
-
void
SourceProbes::queue_probe_request (guint n_channels,
const ProbeFeatures **channel_features,
@@ -611,12 +600,9 @@ SourceProbes::queue_probe_request (guint n_channels,
pqueue->queue_probe_request (*channel_features[i]);
}
}
-
} // Anon
-
namespace Bse {
namespace Procedure {
-
void
source_request_probes::exec (BseSource *source,
Int ochannel_id,
@@ -631,14 +617,12 @@ source_request_probes::exec (BseSource *source,
prs += rq;
source_mass_request::exec (prs);
}
-
static guint
fft_align (guint bsize)
{
bsize = 1 << (g_bit_storage (bsize) - 1);
return CLAMP (bsize, 4, 65536);
}
-
void
source_mass_request::exec (const ProbeRequestSeq &cprseq)
{
@@ -695,13 +679,11 @@ source_mass_request::exec (const ProbeRequestSeq &cprseq)
channel_features = NULL;
}
}
-
Num
source_get_tick_stamp::exec (BseSource *self)
{
return gsl_tick_stamp ();
}
-
Int
source_get_mix_freq::exec (BseSource *self)
{
@@ -709,19 +691,14 @@ source_get_mix_freq::exec (BseSource *self)
throw std::runtime_error ("invalid arguments");
return BSE_SOURCE_PREPARED (self) ? bse_engine_sample_freq() : 0;
}
-
} // Procedure
-
/* export definitions follow */
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ALL_TYPES_FROM_BSEPROBE_IDL();
-
} // Bse
-
/* --- bsesource.hh bits --- */
extern "C" { // from bsesource.hh
using namespace Bse;
-
void
bse_source_clear_probes (BseSource *source)
{
@@ -730,7 +707,6 @@ bse_source_clear_probes (BseSource *source)
source->probes = NULL;
delete probes;
}
-
void
bse_source_probes_modules_changed (BseSource *source)
{
@@ -738,7 +714,6 @@ bse_source_probes_modules_changed (BseSource *source)
probes->reset_omodules();
// FIXME: remove: probes->queue_probes_update (1);
}
-
void
bse_source_class_add_probe_signals (BseSourceClass *klass)
{
@@ -746,5 +721,4 @@ bse_source_class_add_probe_signals (BseSourceClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
bse_source_signal_probes = bse_object_class_add_signal (object_class, "probes", G_TYPE_NONE, 1, BSE_TYPE_PROBE_SEQ);
}
-
};
diff --git a/bse/bseprobe.idl b/bse/bseprobe.idl
index f72cf63..eae5d53 100644
--- a/bse/bseprobe.idl
+++ b/bse/bseprobe.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsecxxmodule.idl>
-
namespace Bse {
-
record ProbeFeatures {
Bool probe_range;
Bool probe_energie;
@@ -23,7 +21,6 @@ record Probe {
sequence ProbeSeq {
Probe probes;
};
-
record ProbeRequest {
Source source;
Int channel_id;
@@ -33,12 +30,10 @@ record ProbeRequest {
sequence ProbeRequestSeq {
ProbeRequest probe_requests;
};
-
void source_request_probes (Source source,
Int ochannel_id,
ProbeFeatures probe_features);
void source_mass_request (ProbeRequestSeq prseq);
Num source_get_tick_stamp (Source obj);
Int source_get_mix_freq (Source obj);
-
};
diff --git a/bse/bseprocedure.cc b/bse/bseprocedure.cc
index 2ac1eb8..c5c7f68 100644
--- a/bse/bseprocedure.cc
+++ b/bse/bseprocedure.cc
@@ -7,24 +7,18 @@
#include "bsestorage.hh"
#include "bseexports.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_procs, "procs", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_procs, __VA_ARGS__)
-
/* --- macros --- */
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
#define HACK_DEBUG /* very slow and leaks memory */ while (0) g_printerr
-
-
/* --- prototypes --- */
static void bse_procedure_base_init (BseProcedureClass *proc);
static void bse_procedure_base_finalize (BseProcedureClass *proc);
static void bse_procedure_init (BseProcedureClass *proc,
const BseExportNodeProc *pnode);
static void procedure_class_unref (BseProcedureClass *proc);
-
-
/* --- functions --- */
static void
bse_procedure_base_init (BseProcedureClass *proc)
@@ -37,28 +31,23 @@ bse_procedure_base_init (BseProcedureClass *proc)
proc->cache_stamp = 0;
proc->execute = NULL;
}
-
static void
bse_procedure_base_finalize (BseProcedureClass *proc)
{
guint i;
-
/* give up type references */
for (i = 0; proc->class_refs[i]; i++)
g_type_class_unref (proc->class_refs[i]);
g_free (proc->class_refs);
proc->class_refs = NULL;
-
for (i = 0; i < proc->n_in_pspecs; i++)
g_param_spec_unref (proc->in_pspecs[i]);
g_free (proc->in_pspecs);
for (i = 0; i < proc->n_out_pspecs; i++)
g_param_spec_unref (proc->out_pspecs[i]);
g_free (proc->out_pspecs);
-
proc->execute = NULL;
}
-
static void
bse_procedure_init (BseProcedureClass *proc,
const BseExportNodeProc *pnode)
@@ -66,12 +55,9 @@ bse_procedure_init (BseProcedureClass *proc,
GParamSpec *in_pspecs[BSE_PROCEDURE_MAX_IN_PARAMS + 8];
GParamSpec *out_pspecs[BSE_PROCEDURE_MAX_OUT_PARAMS + 8];
guint i, j;
-
memset (in_pspecs, 0, sizeof (in_pspecs));
memset (out_pspecs, 0, sizeof (out_pspecs));
-
proc->private_id = pnode->private_id;
-
/* init procedure class from plugin,
* paranoia check certain class members
*/
@@ -87,7 +73,6 @@ bse_procedure_init (BseProcedureClass *proc,
proc->execute = NULL;
g_warning ("procedure \"%s\" messes with reserved class members", BSE_PROCEDURE_NAME (proc));
}
-
/* check input parameters and setup specifications */
for (i = 0; i < BSE_PROCEDURE_MAX_IN_PARAMS; i++)
if (in_pspecs[i])
@@ -107,7 +92,6 @@ bse_procedure_init (BseProcedureClass *proc,
proc->in_pspecs = g_new (GParamSpec*, proc->n_in_pspecs + 1);
memcpy (proc->in_pspecs, in_pspecs, sizeof (in_pspecs[0]) * proc->n_in_pspecs);
proc->in_pspecs[proc->n_in_pspecs] = NULL;
-
/* check output parameters and setup specifications */
for (i = 0; i < BSE_PROCEDURE_MAX_OUT_PARAMS; i++)
if (out_pspecs[i])
@@ -127,7 +111,6 @@ bse_procedure_init (BseProcedureClass *proc,
proc->out_pspecs = g_new (GParamSpec*, proc->n_out_pspecs + 1);
memcpy (proc->out_pspecs, out_pspecs, sizeof (out_pspecs[0]) * proc->n_out_pspecs);
proc->out_pspecs[proc->n_out_pspecs] = NULL;
-
/* keep type references */
proc->class_refs = g_new (GTypeClass*, proc->n_in_pspecs + proc->n_out_pspecs + 1);
j = 0;
@@ -138,11 +121,9 @@ bse_procedure_init (BseProcedureClass *proc,
if (G_TYPE_IS_CLASSED ((G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[i]))))
proc->class_refs[j++] = (GTypeClass*) g_type_class_ref (G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[i]));
proc->class_refs[j++] = NULL;
-
/* hookup execute method */
proc->execute = pnode->exec;
}
-
void
bse_procedure_complete_info (const BseExportNodeProc *pnode,
GTypeInfo *info)
@@ -152,7 +133,6 @@ bse_procedure_complete_info (const BseExportNodeProc *pnode,
info->class_finalize = (GClassFinalizeFunc) NULL;
info->class_data = pnode;
}
-
const gchar*
bse_procedure_type_register (const gchar *name,
BsePlugin *plugin,
@@ -178,25 +158,18 @@ bse_procedure_type_register (const gchar *name,
if (!g_type_is_a (base_type, BSE_TYPE_OBJECT))
return "Procedure base type invalid";
}
-
type = bse_type_register_dynamic (BSE_TYPE_PROCEDURE, name, G_TYPE_PLUGIN (plugin));
-
*ret_type = type;
-
return NULL;
}
-
GType
bse_procedure_lookup (const gchar *proc_name)
{
GType type;
-
g_return_val_if_fail (proc_name != NULL, 0);
-
type = g_type_from_name (proc_name);
return BSE_TYPE_IS_PROCEDURE (type) ? type : 0;
}
-
static void
signal_exec_status (BseErrorType error,
BseProcedureClass *proc,
@@ -209,14 +182,12 @@ signal_exec_status (BseErrorType error,
g_type_is_a (G_VALUE_TYPE (first_ovalue), BSE_TYPE_ERROR_TYPE))
{
BseErrorType verror = g_value_get_enum (first_ovalue);
-
bse_server_exec_status (bse_server_get (), BSE_EXEC_STATUS_DONE, BSE_PROCEDURE_NAME (proc), verror ? 0 : 1, verror);
}
else
bse_server_exec_status (bse_server_get (), BSE_EXEC_STATUS_DONE, BSE_PROCEDURE_NAME (proc), error ? 0 : 1, error);
#endif
}
-
static BseErrorType
bse_procedure_call (BseProcedureClass *proc,
GValue *ivalues,
@@ -226,11 +197,9 @@ bse_procedure_call (BseProcedureClass *proc,
{
guint i, bail_out = FALSE;
BseErrorType error;
-
for (i = 0; i < proc->n_in_pspecs; i++)
{
GParamSpec *pspec = proc->in_pspecs[i];
-
if (g_param_value_validate (pspec, ivalues + i) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
{
g_warning ("%s: input arg `%s' contains invalid value",
@@ -239,7 +208,6 @@ bse_procedure_call (BseProcedureClass *proc,
bail_out = TRUE;
}
}
-
if (bail_out)
error = BSE_ERROR_PROC_PARAM_INVAL;
else
@@ -257,20 +225,16 @@ bse_procedure_call (BseProcedureClass *proc,
else
error = proc->execute (proc, ivalues, ovalues);
}
-
for (i = 0; i < proc->n_out_pspecs; i++)
{
GParamSpec *pspec = proc->out_pspecs[i];
-
if (g_param_value_validate (pspec, ovalues + i) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
g_warning ("%s: internal procedure error: output arg `%s' had invalid value",
BSE_PROCEDURE_NAME (proc),
pspec->name);
}
-
return error;
}
-
BseErrorType
bse_procedure_marshal (GType proc_type,
const GValue *ivalues,
@@ -303,19 +267,16 @@ bse_procedure_marshal (GType proc_type,
tmp_ovalues[i].g_type = 0;
g_value_init (tmp_ovalues + i, G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[i]));
}
-
if (bail_out)
error = BSE_ERROR_PROC_PARAM_INVAL;
else
error = bse_procedure_call (proc, tmp_ivalues, tmp_ovalues, marshal, marshal_data);
signal_exec_status (error, proc, tmp_ovalues);
-
for (i = 0; i < proc->n_in_pspecs; i++)
g_value_unset (tmp_ivalues + i);
for (i = 0; i < proc->n_out_pspecs; i++)
{
GParamSpec *pspec = proc->out_pspecs[i];
-
if (!sfi_value_transform (tmp_ovalues + i, ovalues + i))
g_warning ("%s: output arg `%s' of type `%s' cannot be converted into `%s'",
BSE_PROCEDURE_NAME (proc),
@@ -325,10 +286,8 @@ bse_procedure_marshal (GType proc_type,
g_value_unset (tmp_ovalues + i);
}
procedure_class_unref (proc);
-
return error;
}
-
static inline BseErrorType
bse_procedure_call_collect (BseProcedureClass *proc,
const GValue *first_value,
@@ -342,9 +301,7 @@ bse_procedure_call_collect (BseProcedureClass *proc,
{
guint i, bail_out = FALSE;
BseErrorType error = BSE_ERROR_NONE;
-
HACK_DEBUG ("call %s: ", BSE_PROCEDURE_NAME (proc));
-
/* collect first arg */
if (first_value && first_value != ivalues) /* may skip this since bse_procedure_call() does extra validation */
{
@@ -374,7 +331,6 @@ bse_procedure_call_collect (BseProcedureClass *proc,
{
GParamSpec *pspec = proc->in_pspecs[i];
gchar *error_msg = NULL;
-
ivalues[i].g_type = 0;
g_value_init (ivalues + i, G_PARAM_SPEC_VALUE_TYPE (pspec));
if (!bail_out)
@@ -391,7 +347,6 @@ bse_procedure_call_collect (BseProcedureClass *proc,
}
HACK_DEBUG (" arg[%u]<%s>: %s", i, g_type_name (ivalues[i].g_type), g_strdup_value_contents (ivalues + i) /* memleak */);
}
-
if (!skip_call)
{
/* initialize return values */
@@ -400,7 +355,6 @@ bse_procedure_call_collect (BseProcedureClass *proc,
ovalues[i].g_type = 0;
g_value_init (ovalues + i, G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[i]));
}
-
/* execute procedure */
if (bail_out)
error = BSE_ERROR_PROC_PARAM_INVAL;
@@ -408,17 +362,14 @@ bse_procedure_call_collect (BseProcedureClass *proc,
error = bse_procedure_call (proc, ivalues, ovalues, marshal, marshal_data);
HACK_DEBUG (" call result: %s", bse_error_blurb (error));
signal_exec_status (error, proc, ovalues);
-
/* free input arguments */
for (i = 0; i < proc->n_in_pspecs; i++)
g_value_unset (ivalues + i);
-
/* copy return values into locations */
for (i = 0; i < proc->n_out_pspecs; i++)
{
GParamSpec *pspec = proc->out_pspecs[i];
gchar *error_msg = NULL;
-
if (!skip_ovalues)
G_VALUE_LCOPY (ovalues + i, var_args, 0, &error_msg);
if (error_msg)
@@ -436,10 +387,8 @@ bse_procedure_call_collect (BseProcedureClass *proc,
}
else
HACK_DEBUG (" call skipped");
-
return error;
}
-
/**
* @param proc_type a type derived from BSE_TYPE_PROCEDURE
* @param first_value the first input argument if not to be collected
@@ -470,7 +419,6 @@ bse_procedure_marshal_valist (GType proc_type,
procedure_class_unref (proc);
return error;
}
-
/**
* @param proc valid BseProcedureClass
* @param first_value the first input argument if not to be collected
@@ -494,7 +442,6 @@ bse_procedure_collect_input_args (BseProcedureClass *proc,
{
BseErrorType error;
g_return_val_if_fail (BSE_IS_PROCEDURE_CLASS (proc), BSE_ERROR_INTERNAL);
-
/* add an extra reference count to the class */
proc = (BseProcedureClass*) g_type_class_ref (BSE_PROCEDURE_TYPE (proc));
error = bse_procedure_call_collect (proc, first_value, NULL, NULL,
@@ -503,15 +450,12 @@ bse_procedure_collect_input_args (BseProcedureClass *proc,
procedure_class_unref (proc);
return error;
}
-
BseErrorType
bse_procedure_exec (const gchar *proc_name,
...)
{
GType proc_type;
-
g_return_val_if_fail (proc_name != NULL, BSE_ERROR_INTERNAL);
-
proc_type = bse_procedure_lookup (proc_name);
if (!proc_type)
{
@@ -522,22 +466,18 @@ bse_procedure_exec (const gchar *proc_name,
{
BseErrorType error;
va_list var_args;
-
va_start (var_args, proc_name);
error = bse_procedure_marshal_valist (proc_type, NULL, NULL, NULL, FALSE, var_args);
va_end (var_args);
return error;
}
}
-
BseErrorType
bse_procedure_exec_void (const gchar *proc_name,
...)
{
GType proc_type;
-
g_return_val_if_fail (proc_name != NULL, BSE_ERROR_INTERNAL);
-
proc_type = bse_procedure_lookup (proc_name);
if (!proc_type)
{
@@ -548,14 +488,12 @@ bse_procedure_exec_void (const gchar *proc_name,
{
BseErrorType error;
va_list var_args;
-
va_start (var_args, proc_name);
error = bse_procedure_marshal_valist (proc_type, NULL, NULL, NULL, TRUE, var_args);
va_end (var_args);
return error;
}
}
-
BseErrorType
bse_procedure_execvl (BseProcedureClass *proc,
GSList *in_value_list,
@@ -568,9 +506,7 @@ bse_procedure_execvl (BseProcedureClass *proc,
BseErrorType error;
GSList *slist;
guint i;
-
/* FIXME: bad, bad compat: bse_procedure_execvl() */
-
for (i = 0, slist = in_value_list; slist && i < proc->n_in_pspecs; i++, slist = slist->next)
memcpy (tmp_ivalues + i, slist->data, sizeof (tmp_ivalues[0]));
if (slist || i != proc->n_in_pspecs)
@@ -590,10 +526,8 @@ bse_procedure_execvl (BseProcedureClass *proc,
memcpy (slist->data, tmp_ovalues + i, sizeof (tmp_ivalues[0]));
return error;
}
-
static BseProcedureClass *proc_cache = NULL;
static guint64 cache_time = 0;
-
static gboolean
proc_cache_prepare (GSource *source,
gint *timeout_p)
@@ -620,13 +554,11 @@ proc_cache_prepare (GSource *source,
}
return need_dispatch;
}
-
static gboolean
proc_cache_check (GSource *source)
{
return proc_cache_prepare (source, NULL);
}
-
static gboolean
proc_cache_dispatch (GSource *source,
GSourceFunc callback,
@@ -634,7 +566,6 @@ proc_cache_dispatch (GSource *source,
{
BseProcedureClass *ulist = NULL, *proc, *last = NULL;
GTimeVal current_time;
-
BSE_THREADS_ENTER ();
proc = proc_cache;
while (proc)
@@ -672,7 +603,6 @@ proc_cache_dispatch (GSource *source,
BSE_THREADS_LEAVE ();
return TRUE;
}
-
static void
procedure_class_unref (BseProcedureClass *proc)
{
@@ -693,19 +623,16 @@ procedure_class_unref (BseProcedureClass *proc)
g_type_class_unref (proc);
}
}
-
void
bse_type_register_procedure_info (GTypeInfo *info)
{
static const GTypeInfo proc_info = {
sizeof (BseProcedureClass),
-
(GBaseInitFunc) bse_procedure_base_init,
(GBaseFinalizeFunc) bse_procedure_base_finalize,
(GClassInitFunc) NULL,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
/* non classed type stuff */
0, 0, NULL,
};
@@ -718,6 +645,5 @@ bse_type_register_procedure_info (GTypeInfo *info)
GSource *source = g_source_new (&proc_cache_source_funcs, sizeof (*source));
g_source_set_priority (source, BSE_PRIORITY_BACKGROUND);
g_source_attach (source, bse_main_context);
-
*info = proc_info;
}
diff --git a/bse/bseprocedure.hh b/bse/bseprocedure.hh
index 5040144..b425102 100644
--- a/bse/bseprocedure.hh
+++ b/bse/bseprocedure.hh
@@ -1,22 +1,15 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PROCEDURE_H__
#define __BSE_PROCEDURE_H__
-
#include <bse/bseparam.hh>
-
G_BEGIN_DECLS
-
/* --- BSE type macros --- */
#define BSE_PROCEDURE_TYPE(proc) (G_TYPE_FROM_CLASS (proc))
#define BSE_IS_PROCEDURE_CLASS(proc) (G_TYPE_CHECK_CLASS_TYPE ((proc), BSE_TYPE_PROCEDURE))
#define BSE_PROCEDURE_NAME(proc) (g_type_name (BSE_PROCEDURE_TYPE (proc)))
-
-
/* --- limits --- */
#define BSE_PROCEDURE_MAX_IN_PARAMS (16)
#define BSE_PROCEDURE_MAX_OUT_PARAMS (16)
-
-
/* --- BseProcedureClass --- */
typedef void (*BseProcedureInit) (BseProcedureClass *proc,
GParamSpec **in_pspecs,
@@ -27,10 +20,8 @@ typedef BseErrorType (*BseProcedureExec) (BseProcedureClass *procedure,
struct _BseProcedureClass
{
GTypeClass bse_class;
-
/* implementation hint */
guint private_id;
-
/* in/out parameters */
guint n_in_pspecs;
GParamSpec **in_pspecs;
@@ -40,11 +31,8 @@ struct _BseProcedureClass
GTypeClass **class_refs;
guint cache_stamp;
gpointer cache_next;
-
BseProcedureExec execute;
};
-
-
/* --- notifiers --- */
typedef gboolean (*BseProcedureNotify) (gpointer func_data,
const gchar *proc_name,
@@ -53,8 +41,6 @@ typedef BseErrorType (*BseProcedureMarshal) (gpointer marshal_data,
BseProcedureClass *proc,
const GValue *ivalues,
GValue *ovalues);
-
-
/* --- prototypes --- */
/* execute procedure, passing n_in_pspecs param values for in
* values and n_out_pspecs param value locations for out values
@@ -84,13 +70,9 @@ BseErrorType bse_procedure_execvl (BseProcedureClass *proc,
GSList *out_value_list,
BseProcedureMarshal marshal,
gpointer marshal_data);
-
-
/* --- internal --- */
const gchar* bse_procedure_type_register (const gchar *name,
BsePlugin *plugin,
GType *ret_type);
-
G_END_DECLS
-
#endif /* __BSE_PROCEDURE_H__ */
diff --git a/bse/bseprocedure.proc b/bse/bseprocedure.proc
index f656edb..ff27a63 100644
--- a/bse/bseprocedure.proc
+++ b/bse/bseprocedure.proc
@@ -8,11 +8,8 @@
#include "bsecxxplugin.hh"
#include <string.h> /* strchr */
#include <stdlib.h> /* strtol */
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
PROCEDURE (bse-note-to-freq, "Note to Freq") {
HELP = "Retrieve the frequency of a certain note.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -32,7 +29,6 @@ PROCEDURE (bse-note-to-freq, "Note to Freq") {
int fine_tune = sfi_value_get_int (in_values++);
BseNoteDescription *info;
gfloat freq;
-
/* action */
info = bse_note_description (musical_tuning, note, fine_tune);
if (!info->name)
@@ -40,13 +36,10 @@ PROCEDURE (bse-note-to-freq, "Note to Freq") {
else
freq = info->freq;
bse_note_description_free (info);
-
/* set out params */
sfi_value_set_real (out_values++, freq);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-note-from-freq, "Note from Freq") {
HELP = "Retrieve the note of a certain frequency.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -62,13 +55,10 @@ PROCEDURE (bse-note-from-freq, "Note from Freq") {
/* extract parameter values */
BseMusicalTuningType musical_tuning = (BseMusicalTuningType) g_value_get_enum (in_values++);
float frequency = sfi_value_get_real (in_values++);
-
/* set out params */
sfi_value_set_int (out_values++, bse_note_from_freq (musical_tuning, frequency));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-note-describe, "Describe Note") {
HELP = "Describe a note, providing information about its octave, semitone, frequency, etc.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -86,13 +76,10 @@ BODY (BseProcedureClass *proc,
BseMusicalTuningType musical_tuning = (BseMusicalTuningType) g_value_get_enum (in_values++);
int note = sfi_value_get_int (in_values++);
int fine_tune = sfi_value_get_int (in_values++);
-
/* describe note */
bse_value_take_boxed (out_values++, bse_note_description (musical_tuning, note, fine_tune));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-note-describe-from-freq, "Describe Note From Freq") {
HELP = "Describe a note, given its frequency.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -112,14 +99,11 @@ BODY (BseProcedureClass *proc,
BseMusicalTuningType musical_tuning = (BseMusicalTuningType) g_value_get_enum (in_values++);
float freq = sfi_value_get_real (in_values++);
gint note;
-
/* describe note */
note = bse_note_from_freq (musical_tuning, freq);
bse_value_take_boxed (out_values++, bse_note_description (musical_tuning, note, 0));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-note-from-string, "Note From String") {
HELP = "Describe a note, given its name and octave offset.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -137,14 +121,11 @@ BODY (BseProcedureClass *proc,
BseMusicalTuningType musical_tuning = (BseMusicalTuningType) g_value_get_enum (in_values++);
const char *name = sfi_value_get_string (in_values++);
gint note;
-
/* describe note */
note = bse_note_from_string (name);
bse_value_take_boxed (out_values++, bse_note_description (musical_tuning, note, 0));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-note-construct, "Note Construction") {
HELP = "Describe a note, given its semitone, octave and fine tune.";
IN = bse_param_spec_enum ("musical_tuning", "Musical Tuning", NULL,
@@ -167,14 +148,11 @@ BODY (BseProcedureClass *proc,
int octave = sfi_value_get_int (in_values++);
int fine_tune = sfi_value_get_int (in_values++);
int note;
-
/* describe note */
note = BSE_NOTE_GENERIC (octave, semitone);
bse_value_take_boxed (out_values++, bse_note_description (musical_tuning, note, fine_tune));
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-type-options, "Type Options") {
HELP = "Retrieve the options of a specific type.";
IN = sfi_pspec_string ("type", NULL, NULL, NULL, SFI_PARAM_STANDARD);
@@ -186,19 +164,14 @@ PROCEDURE (bse-type-options, "Type Options") {
/* extract parameter values */
const char *stype = sfi_value_get_string (in_values++);
GType type;
-
/* check parameters */
if (!stype)
return BSE_ERROR_PROC_PARAM_INVAL;
-
type = g_type_from_name (stype);
-
/* set out params */
sfi_value_set_string (out_values++, type ? bse_type_get_options (type) : NULL);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-type-blurb, "Type Blurb") {
HELP = "Retrieve the description of a specific type.";
IN = sfi_pspec_string ("type", NULL, NULL, NULL, SFI_PARAM_STANDARD);
@@ -210,19 +183,14 @@ PROCEDURE (bse-type-blurb, "Type Blurb") {
/* extract parameter values */
const char *stype = sfi_value_get_string (in_values++);
GType type;
-
/* check parameters */
if (!stype)
return BSE_ERROR_PROC_PARAM_INVAL;
-
type = g_type_from_name (stype);
-
/* set out params */
sfi_value_set_string (out_values++, type ? bse_type_get_blurb (type) : NULL);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-type-authors, "Type Authors") {
HELP = "Retrieve the authors who implemented a specific type.";
IN = sfi_pspec_string ("type", NULL, NULL, NULL, SFI_PARAM_STANDARD);
@@ -234,19 +202,14 @@ PROCEDURE (bse-type-authors, "Type Authors") {
/* extract parameter values */
const char *stype = sfi_value_get_string (in_values++);
GType type;
-
/* check parameters */
if (!stype)
return BSE_ERROR_PROC_PARAM_INVAL;
-
type = g_type_from_name (stype);
-
/* set out params */
sfi_value_set_string (out_values++, type ? bse_type_get_authors (type) : NULL);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-type-license, "Type License") {
HELP = "Retrieve the license of a type impementation.";
IN = sfi_pspec_string ("type", NULL, NULL, NULL, SFI_PARAM_STANDARD);
@@ -258,19 +221,14 @@ PROCEDURE (bse-type-license, "Type License") {
/* extract parameter values */
const char *stype = sfi_value_get_string (in_values++);
GType type;
-
/* check parameters */
if (!stype)
return BSE_ERROR_PROC_PARAM_INVAL;
-
type = g_type_from_name (stype);
-
/* set out params */
sfi_value_set_string (out_values++, type ? bse_type_get_license (type) : NULL);
-
return BSE_ERROR_NONE;
}
-
static gdouble
str2num (const gchar *str,
guint nth)
@@ -293,7 +251,6 @@ str2num (const gchar *str,
return g_strtod (str, NULL);
return 0; /* no number */
}
-
PROCEDURE (bse-string-extract-number, "String Extract Number") {
HELP = "Retrieve numbers from a string.";
IN = sfi_pspec_string ("string", NULL, NULL, NULL, SFI_PARAM_STANDARD);
@@ -311,7 +268,6 @@ PROCEDURE (bse-string-extract-number, "String Extract Number") {
SfiReal aux_base = sfi_value_get_real (in_values++);
SfiReal dflt = sfi_value_get_real (in_values++);
SfiReal number = dflt;
-
if (string)
{
if (format)
diff --git a/bse/bseprocidl.cc b/bse/bseprocidl.cc
index e527b61..286421e 100644
--- a/bse/bseprocidl.cc
+++ b/bse/bseprocidl.cc
@@ -8,23 +8,17 @@
#include <string.h>
#include <string>
#include <set>
-
std::set<std::string> needTypes;
std::set<std::string> needClasses;
std::set<std::string> excludeTypes;
-
bool silent = false;
-
void print(const gchar *format, ...)
{
va_list args;
-
va_start (args, format);
if (!silent) vfprintf (stdout, format, args);
va_end (args);
}
-
-
std::string removeBse (const std::string& name)
{
if (strncmp (name.c_str(), "Bse", 3) == 0)
@@ -34,33 +28,27 @@ std::string removeBse (const std::string& name)
else
return name;
}
-
std::string getInterface (const std::string& name)
{
int i = name.find ("+", 0);
-
if(i >= 0)
{
std::string result = name.substr (0, i);
if (strncmp (result.c_str(), "Bse", 3) == 0)
result = name.substr (3, i-3);
-
return result;
}
return "";
}
-
std::string getMethod (const std::string& name)
{
std::string result;
std::string::const_iterator ni = name.begin ();
-
int pos = name.find ("+", 0);
if (pos >= 0)
ni += pos + 1;
else if (name.size () > 4)
ni += 4; /* assume & skip bse prefix */
-
while (ni != name.end ())
{
if (*ni == '-')
@@ -71,13 +59,11 @@ std::string getMethod (const std::string& name)
}
return result;
}
-
std::string
signalName (const std::string& signal)
{
std::string result;
std::string::const_iterator si = signal.begin ();
-
while (si != signal.end ())
{
if (*si == '-')
@@ -88,7 +74,6 @@ signalName (const std::string& signal)
}
return result;
}
-
std::string paramName (const std::string& name)
{
std::string result;
@@ -103,16 +88,13 @@ std::string paramName (const std::string& name)
}
return result;
}
-
std::string activeInterface = "";
int indent = 0;
-
void printIndent ()
{
for (int i = 0; i < indent; i++)
print(" ");
}
-
void setActiveInterface (const std::string& x, const std::string& parent)
{
if (activeInterface != x)
@@ -123,9 +105,7 @@ void setActiveInterface (const std::string& x, const std::string& parent)
printIndent ();
print ("};\n\n");
}
-
activeInterface = x;
-
if (activeInterface != "")
{
printIndent ();
@@ -139,11 +119,9 @@ void setActiveInterface (const std::string& x, const std::string& parent)
}
}
}
-
std::string idlType (GType g)
{
std::string s = g_type_name (g);
-
if (s[0] == 'B' && s[1] == 's' && s[2] == 'e')
{
needTypes.insert (s);
@@ -168,22 +146,18 @@ std::string idlType (GType g)
return "*ERROR*";
}
}
-
std::string symbolForInt (int i)
{
if (i == SFI_MAXINT) return "SFI_MAXINT";
if (i == SFI_MININT) return "SFI_MININT";
-
char *x = g_strdup_printf ("%d", i);
std::string result = x;
g_free(x);
return result;
}
-
void printPSpec (const char *dir, GParamSpec *pspec)
{
std::string pname = paramName (pspec->name);
-
printIndent ();
print ("%-4s%-20s= (\"%s\", \"%s\", ",
dir,
@@ -191,14 +165,11 @@ void printPSpec (const char *dir, GParamSpec *pspec)
g_param_spec_get_nick (pspec) ? g_param_spec_get_nick (pspec) : "",
g_param_spec_get_blurb (pspec) ? g_param_spec_get_blurb (pspec) : ""
);
-
if (SFI_IS_PSPEC_INT (pspec))
{
int default_value, minimum, maximum, stepping_rate;
-
default_value = sfi_pspec_get_int_default (pspec);
sfi_pspec_get_int_range (pspec, &minimum, &maximum, &stepping_rate);
-
print("%s, %s, %s, %s, ", symbolForInt (default_value).c_str(),
symbolForInt (minimum).c_str(), symbolForInt (maximum).c_str(),
symbolForInt (stepping_rate).c_str());
@@ -206,36 +177,30 @@ void printPSpec (const char *dir, GParamSpec *pspec)
if (SFI_IS_PSPEC_BOOL (pspec))
{
GParamSpecBoolean *bspec = G_PARAM_SPEC_BOOLEAN (pspec);
-
print("%s, ", bspec->default_value ? "TRUE" : "FALSE");
}
print("\":flagstodo\");\n");
}
-
void printMethods (const std::string& iface)
{
BseCategorySeq *cseq;
guint i;
-
cseq = bse_categories_match_typed ("*", BSE_TYPE_PROCEDURE);
for (i = 0; i < cseq->n_cats; i++)
{
GType type_id = g_type_from_name (cseq->cats[i]->type);
const gchar *blurb = bse_type_get_blurb (type_id);
BseProcedureClass *klass = (BseProcedureClass *)g_type_class_ref (type_id);
-
/* procedures */
std::string t = cseq->cats[i]->type;
std::string iname = getInterface (t);
std::string mname = getMethod (t);
std::string rtype = klass->n_out_pspecs ?
idlType (klass->out_pspecs[0]->value_type) : "void";
-
if (iname == iface)
{
/* for methods, the first argument is implicit: the object itself */
guint first_p = iface == "" ? 0 : 1;
-
printIndent ();
print ("%s %s (", rtype.c_str(), mname.c_str ());
for (guint p = first_p; p < klass->n_in_pspecs; p++)
@@ -248,7 +213,6 @@ void printMethods (const std::string& iface)
}
print(") {\n");
indent++;
-
if (blurb)
{
char *ehelp = g_strescape (blurb, 0);
@@ -256,13 +220,10 @@ void printMethods (const std::string& iface)
print ("Info help = \"%s\";\n", ehelp);
g_free (ehelp);
}
-
for (guint p = first_p; p < klass->n_in_pspecs; p++)
printPSpec ("In", klass->in_pspecs[p]);
-
for (guint p = 0; p < klass->n_out_pspecs; p++)
printPSpec ("Out", klass->out_pspecs[p]);
-
indent--;
printIndent ();
print ("}\n");
@@ -271,18 +232,14 @@ void printMethods (const std::string& iface)
}
bse_category_seq_free (cseq);
}
-
/* FIXME: we might want to have a sfi_glue_iface_parent () method */
void printInterface (const std::string& iface, const std::string& parent = "")
{
std::string idliface = removeBse (iface);
-
if (excludeTypes.count (iface))
return;
-
setActiveInterface (idliface, parent);
printMethods (idliface);
-
if (iface != "")
{
/* signals */
@@ -295,17 +252,14 @@ void printInterface (const std::string& iface, const std::string& parent = "")
{
GSignalQuery query;
g_signal_query (sids[s], &query);
-
// FIXME: some core types are implemented as plugins, and thus have
// class destructors that are executed right after type registration.
// that's why we can't query their signals here
if (!query.signal_id)
continue;
-
// FIXME: how to deal with Bse::MidiEvent?
if (signalName (query.signal_name) == "midi_event")
continue;
-
printIndent();
print ("signal %s (", signalName (query.signal_name).c_str());
for (guint p = 0; p < query.n_params; p++)
@@ -323,14 +277,12 @@ void printInterface (const std::string& iface, const std::string& parent = "")
{
print("/* type %s (%s) is not instantiatable */\n", g_type_name (type_id), iface.c_str());
}
-
/* properties */
GObjectClass *klass = (GObjectClass *)g_type_class_ref (type_id);
if (klass)
{
guint n_properties = 0;
GParamSpec **properties = g_object_class_list_properties (klass, &n_properties);
-
for (guint i = 0; i < n_properties; i++)
{
if (properties[i]->owner_type == type_id)
@@ -339,19 +291,16 @@ void printInterface (const std::string& iface, const std::string& parent = "")
g_free (properties);
g_type_class_unref (klass);
}
-
const gchar **children = sfi_glue_iface_children (iface.c_str());
while (*children)
printInterface (*children++, idliface);
}
}
-
static void
printChoices (void)
{
GType *children;
guint n, i;
-
children = g_type_children (G_TYPE_ENUM, &n);
for (i = 0; i < n; i++)
{
@@ -359,7 +308,6 @@ printChoices (void)
GEnumClass *eclass = (GEnumClass *)g_type_class_ref (children[i]);
gboolean regular_choice = strcmp (name, "BseErrorType") != 0;
GEnumValue *val;
-
if (needTypes.count (name) && !excludeTypes.count (name))
{
/* enum definition */
@@ -386,19 +334,16 @@ printChoices (void)
}
g_free (children);
}
-
void
printForwardDecls ()
{
std::set<std::string>::iterator ci;
-
for (ci = needClasses.begin(); ci != needClasses.end(); ci++)
{
printIndent();
print ("class %s;\n", ci->c_str());
}
}
-
int
main (int argc, char **argv)
{
@@ -421,17 +366,14 @@ main (int argc, char **argv)
}
g_thread_init (NULL);
bse_init_inprocess (&argc, &argv, "BseProcIDL", NULL);
-
sfi_glue_context_push (bse_glue_context_intern ("BseProcIdl"));
std::string s = sfi_glue_base_iface ();
-
/* small hackery to collect all enum types that need to be printed */
silent = true;
// needTypes.insert (g_type_name (BSE_TYPE_MIDI_SIGNAL_TYPE));
printInterface (s);
printInterface ("");
silent = false;
-
print ("namespace Bse {\n");
indent++;
printChoices ();
@@ -440,9 +382,6 @@ main (int argc, char **argv)
printInterface (""); /* prints procedures without interface */
indent--;
print ("};\n");
-
-
sfi_glue_context_pop ();
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bseproject.cc b/bse/bseproject.cc
index f96755f..ba4c04e 100644
--- a/bse/bseproject.cc
+++ b/bse/bseproject.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseproject.hh"
-
#include "bsesuper.hh"
#include "bsestorage.hh"
#include "bsesong.hh"
@@ -21,25 +20,19 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-
-
typedef struct {
GType base_type;
gboolean intern_children;
guint max_items;
GSList *items;
} StorageTrap;
-
/* --- macros --- */
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
enum {
PARAM_0,
PARAM_DIRTY
};
-
-
/* --- prototypes --- */
static void bse_project_class_init (BseProjectClass *klass);
static void bse_project_class_finalize (BseProjectClass *klass);
@@ -70,38 +63,30 @@ static void bse_project_prepare (BseSource *source);
static gboolean project_check_restore (BseContainer *container,
const gchar *child_type);
static BseUndoStack* bse_project_get_undo (BseItem *item);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_state_changed = 0;
static GQuark quark_storage_trap = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseProject)
{
static const GTypeInfo project_info = {
sizeof (BseProjectClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_project_class_init,
(GClassFinalizeFunc) bse_project_class_finalize,
NULL /* class_data */,
-
sizeof (BseProject),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_project_init,
};
-
return bse_type_register_static (BSE_TYPE_CONTAINER,
"BseProject",
"BSE Super container type",
__FILE__, __LINE__,
&project_info);
}
-
static void
bse_project_class_init (BseProjectClass *klass)
{
@@ -110,41 +95,32 @@ bse_project_class_init (BseProjectClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
quark_storage_trap = g_quark_from_static_string ("bse-project-storage-trap");
-
gobject_class->set_property = bse_project_set_property;
gobject_class->get_property = bse_project_get_property;
gobject_class->dispose = bse_project_dispose;
gobject_class->finalize = bse_project_finalize;
-
item_class->get_undo = bse_project_get_undo;
-
source_class->prepare = bse_project_prepare;
-
container_class->add_item = bse_project_add_item;
container_class->remove_item = bse_project_remove_item;
container_class->forall_items = bse_project_forall_items;
container_class->check_restore = project_check_restore;
container_class->retrieve_child = bse_project_retrieve_child;
container_class->release_children = bse_project_release_children;
-
bse_object_class_add_param (object_class, "State",
PARAM_DIRTY,
sfi_pspec_bool ("dirty", NULL, "Whether project needs saving",
FALSE, "r"));
-
signal_state_changed = bse_object_class_add_signal (object_class, "state-changed",
G_TYPE_NONE,
1, BSE_TYPE_PROJECT_STATE);
}
-
static void
bse_project_class_finalize (BseProjectClass *klass)
{
}
-
static void
undo_notify (BseProject *project,
BseUndoStack *ustack,
@@ -157,7 +133,6 @@ undo_notify (BseProject *project,
bse_undo_stack_clear (project->redo_stack);
}
}
-
static void
redo_notify (BseProject *project,
BseUndoStack *ustack,
@@ -165,13 +140,11 @@ redo_notify (BseProject *project,
{
g_object_notify ((GObject*) project, "dirty");
}
-
static void
bse_project_init (BseProject *self,
gpointer rclass)
{
BseWaveRepo *wrepo;
-
self->state = BSE_PROJECT_INACTIVE;
self->supers = NULL;
self->items = NULL;
@@ -182,13 +155,11 @@ bse_project_init (BseProject *self,
self->deactivate_usecs = 3 * 1000000;
self->midi_receiver = bse_midi_receiver_new ("BseProjectReceiver");
bse_midi_receiver_enter_farm (self->midi_receiver);
-
/* we always have a wave-repo */
wrepo = (BseWaveRepo*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_WAVE_REPO, "uname", "Wave-Repository", NULL);
/* with fixed uname */
BSE_OBJECT_SET_FLAGS (wrepo, BSE_OBJECT_FLAG_FIXED_UNAME);
}
-
static void
bse_project_set_property (GObject *object,
guint param_id,
@@ -196,7 +167,6 @@ bse_project_set_property (GObject *object,
GParamSpec *pspec)
{
BseProject *self = BSE_PROJECT (object);
-
switch (param_id)
{
case PARAM_DIRTY:
@@ -206,7 +176,6 @@ bse_project_set_property (GObject *object,
break;
}
}
-
static void
bse_project_get_property (GObject *object,
guint param_id,
@@ -214,7 +183,6 @@ bse_project_get_property (GObject *object,
GParamSpec *pspec)
{
BseProject *self = BSE_PROJECT (object);
-
switch (param_id)
{
case PARAM_DIRTY:
@@ -225,57 +193,44 @@ bse_project_get_property (GObject *object,
break;
}
}
-
static void
bse_project_release_children (BseContainer *container)
{
BseProject *project = BSE_PROJECT (container);
-
while (project->items)
bse_container_remove_item (BSE_CONTAINER (project), (BseItem*) project->items->data);
while (project->supers)
bse_container_remove_item (BSE_CONTAINER (project), (BseItem*) project->supers->data);
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
static void
bse_project_dispose (GObject *object)
{
BseProject *self = BSE_PROJECT (object);
-
bse_project_deactivate (self);
-
bse_undo_stack_limit (self->undo_stack, 0);
bse_undo_stack_limit (self->redo_stack, 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_project_finalize (GObject *object)
{
BseProject *self = BSE_PROJECT (object);
-
bse_midi_receiver_unref (self->midi_receiver);
self->midi_receiver = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
-
bse_undo_stack_destroy (self->undo_stack);
bse_undo_stack_destroy (self->redo_stack);
}
-
static BseUndoStack*
bse_project_get_undo (BseItem *item)
{
BseProject *self = BSE_PROJECT (item);
return self->in_undo ? self->redo_stack : self->undo_stack;
}
-
void
bse_project_clear_undo (BseProject *self)
{
@@ -287,7 +242,6 @@ bse_project_clear_undo (BseProject *self)
g_object_notify ((GObject*) self, "dirty");
}
}
-
void
bse_project_clean_dirty (BseProject *self)
{
@@ -296,7 +250,6 @@ bse_project_clean_dirty (BseProject *self)
bse_undo_stack_clean_dirty (self->redo_stack);
g_object_notify ((GObject*) self, "dirty");
}
-
static void
project_undo_do_deactivate (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -304,18 +257,15 @@ project_undo_do_deactivate (BseUndoStep *ustep,
BseProject *self = (BseProject*) bse_undo_pointer_unpack ((const char*) ustep->data[0].v_pointer, ustack);
bse_project_deactivate (self);
}
-
static void
project_undo_do_deactivate_free (BseUndoStep *ustep)
{
g_free (ustep->data[0].v_pointer);
}
-
void
bse_project_push_undo_silent_deactivate (BseProject *self)
{
g_return_if_fail (BSE_IS_PROJECT (self));
-
/* certain things work only (can only be undone/redone) in deactivated projects,
* so we need to push an undo step here. this step isn't required however
* if there're no undo steps pushed so far, and it shouldn't be visible
@@ -330,7 +280,6 @@ bse_project_push_undo_silent_deactivate (BseProject *self)
ustep->data[0].v_pointer = bse_undo_pointer_pack (self, ustack);
bse_undo_stack_push_add_on (ustack, ustep);
bse_item_undo_close (ustack);
-
gboolean in_undo = self->in_undo;
self->in_undo = !in_undo; /* swap undo<=>redo */
ustack = bse_item_undo_open (self, "deactivate-project");
@@ -341,37 +290,30 @@ bse_project_push_undo_silent_deactivate (BseProject *self)
self->in_undo = in_undo; /* swap undo<=>redo */
}
}
-
static void
bse_project_add_item (BseContainer *container,
BseItem *item)
{
BseProject *self = BSE_PROJECT (container);
-
if (BSE_IS_SUPER (item))
self->supers = g_slist_append (self->supers, item);
else
self->items = g_slist_append (self->items, item);
-
/* chain parent class' add_item handler */
BSE_CONTAINER_CLASS (parent_class)->add_item (container, item);
}
-
static void
bse_project_remove_item (BseContainer *container,
BseItem *item)
{
BseProject *self = BSE_PROJECT (container);
-
/* chain parent class' remove_item handler */
BSE_CONTAINER_CLASS (parent_class)->remove_item (container, item);
-
if (BSE_IS_SUPER (item))
self->supers = g_slist_remove (self->supers, item);
else
self->items = g_slist_remove (self->items, item);
}
-
static void
bse_project_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -379,7 +321,6 @@ bse_project_forall_items (BseContainer *container,
{
BseProject *self = BSE_PROJECT (container);
GSList *slist;
-
slist = self->supers;
while (slist)
{
@@ -388,7 +329,6 @@ bse_project_forall_items (BseContainer *container,
if (!func (item, data))
return;
}
-
slist = self->items;
while (slist)
{
@@ -398,19 +338,16 @@ bse_project_forall_items (BseContainer *container,
return;
}
}
-
static BseItem*
bse_project_retrieve_child (BseContainer *container,
GType child_type,
const gchar *uname)
{
BseProject *self = BSE_PROJECT (container);
-
/* always hand out the same wave repo */
if (g_type_is_a (child_type, BSE_TYPE_WAVE_REPO))
{
GSList *slist;
-
for (slist = self->supers; slist; slist = slist->next)
if (g_type_is_a (G_OBJECT_TYPE (slist->data), BSE_TYPE_WAVE_REPO))
return (BseItem*) slist->data;
@@ -431,7 +368,6 @@ bse_project_retrieve_child (BseContainer *container,
return item;
}
}
-
static gboolean
add_item_upaths (BseItem *item,
gpointer data_p)
@@ -440,7 +376,6 @@ add_item_upaths (BseItem *item,
BseStringSeq *sseq = (BseStringSeq*) data[0];
GType item_type = (GType) data[1];
BseContainer *container = (BseContainer*) data[2];
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), item_type))
{
gchar *upath = bse_container_make_upath (container, item);
@@ -449,29 +384,23 @@ add_item_upaths (BseItem *item,
}
if (BSE_IS_CONTAINER (item))
bse_container_forall_items (BSE_CONTAINER (item), add_item_upaths, data);
-
return TRUE;
}
-
BseStringSeq*
bse_project_list_upaths (BseProject *self,
GType item_type)
{
gpointer data[3];
BseStringSeq *sseq;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), NULL);
g_return_val_if_fail (g_type_is_a (item_type, BSE_TYPE_ITEM), NULL);
-
sseq = bse_string_seq_new ();
data[0] = sseq;
data[1] = (gpointer) item_type;
data[2] = self;
bse_container_forall_items (BSE_CONTAINER (self), add_item_upaths, data);
-
return sseq;
}
-
static GSList*
compute_missing_supers (BseProject *self,
BseStorage *storage)
@@ -488,7 +417,6 @@ compute_missing_supers (BseProject *self,
}
return targets;
}
-
BseErrorType
bse_project_store_bse (BseProject *self,
BseSuper *super,
@@ -500,7 +428,6 @@ bse_project_store_bse (BseProject *self,
gchar *string;
guint l, flags;
gint fd;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), BSE_ERROR_INTERNAL);
if (super)
{
@@ -508,17 +435,14 @@ bse_project_store_bse (BseProject *self,
g_return_val_if_fail (BSE_ITEM (super)->parent == BSE_ITEM (self), BSE_ERROR_INTERNAL);
}
g_return_val_if_fail (bse_file != NULL, BSE_ERROR_INTERNAL);
-
fd = open (bse_file, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0)
return bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
-
storage = (BseStorage*) g_object_new (BSE_TYPE_STORAGE, NULL);
flags = 0;
if (self_contained)
flags |= BSE_STORAGE_SELF_CONTAINED;
bse_storage_prepare_write (storage, BseStorageMode (flags));
-
slist = g_slist_prepend (slist, super ? (void*) super : (void*) self);
while (slist)
{
@@ -529,43 +453,33 @@ bse_project_store_bse (BseProject *self,
bse_storage_store_child (storage, item);
slist = g_slist_concat (compute_missing_supers (self, storage), slist);
}
-
string = g_strdup_printf ("; BseProject\n\n"); /* %010o mflags */
do
l = write (fd, string, strlen (string));
while (l < 0 && errno == EINTR);
g_free (string);
-
BseErrorType error = bse_storage_flush_fd (storage, fd);
if (close (fd) < 0 && error == BSE_ERROR_NONE)
error = bse_error_from_errno (errno, BSE_ERROR_FILE_WRITE_FAILED);
bse_storage_reset (storage);
g_object_unref (storage);
-
return error;
}
-
BseErrorType
bse_project_restore (BseProject *self,
BseStorage *storage)
{
GScanner *scanner;
GTokenType expected_token = G_TOKEN_NONE;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (BSE_IS_STORAGE (storage), BSE_ERROR_INTERNAL);
-
scanner = bse_storage_get_scanner (storage);
g_return_val_if_fail (scanner != NULL, BSE_ERROR_INTERNAL);
-
g_object_ref (self);
-
expected_token = bse_storage_restore_item (storage, BSE_ITEM (self));
if (expected_token != G_TOKEN_NONE)
bse_storage_unexp_token (storage, expected_token);
-
bse_storage_finish_parsing (storage);
-
GSList *slist = self->supers;
while (slist)
{
@@ -574,16 +488,12 @@ bse_project_restore (BseProject *self,
BseSuperClass *super_class = BSE_SUPER_GET_CLASS (super);
super_class->compat_finish (super, storage->major_version, storage->minor_version, storage->micro_version);
}
-
bse_undo_stack_force_dirty (self->undo_stack);
-
g_object_unref (self);
-
return (scanner->parse_errors >= scanner->max_parse_errors ?
BSE_ERROR_PARSE_ERROR :
BSE_ERROR_NONE);
}
-
BseObject*
bse_project_upath_resolver (gpointer func_data,
GType required_type,
@@ -592,39 +502,30 @@ bse_project_upath_resolver (gpointer func_data,
{
BseProject *self = (BseProject*) func_data;
gpointer item = NULL;
-
if (error_p)
*error_p = NULL;
g_return_val_if_fail (BSE_IS_PROJECT (self), NULL);
g_return_val_if_fail (upath != NULL, NULL);
-
/* FIXME: need error handling, warnings.... */
-
if (g_type_is_a (required_type, BSE_TYPE_ITEM))
item = bse_container_resolve_upath (BSE_CONTAINER (self), upath);
else if (error_p)
*error_p = g_strdup_printf ("unable to resolve object of type `%s' from upath: %s", g_type_name (required_type), upath);
-
return (BseObject*) item;
}
-
BseItem*
bse_project_lookup_typed_item (BseProject *self,
GType item_type,
const gchar *uname)
{
BseItem *item;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), NULL);
g_return_val_if_fail (uname != NULL, NULL);
-
item = bse_container_lookup_item (BSE_CONTAINER (self), uname);
if (item && G_OBJECT_TYPE (item) == item_type)
return item;
-
return NULL;
}
-
BseWaveRepo*
bse_project_get_wave_repo (BseProject *self)
{
@@ -635,7 +536,6 @@ bse_project_get_wave_repo (BseProject *self)
return (BseWaveRepo*) slist->data;
return NULL;
}
-
BseSong*
bse_project_get_song (BseProject *self)
{
@@ -646,7 +546,6 @@ bse_project_get_song (BseProject *self)
return (BseSong*) slist->data;
return NULL;
}
-
static gboolean
project_check_restore (BseContainer *container,
const gchar *child_type)
@@ -665,7 +564,6 @@ project_check_restore (BseContainer *container,
else
return FALSE;
}
-
BseSNet*
bse_project_create_intern_synth (BseProject *self,
const gchar *synth_name,
@@ -673,10 +571,8 @@ bse_project_create_intern_synth (BseProject *self,
{
BseItem *synth = NULL;
gchar *bse_synth;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), NULL);
g_return_val_if_fail (synth_name != NULL, NULL);
-
bse_synth = bse_standard_synth_inflate (synth_name, NULL);
if (bse_synth)
{
@@ -703,7 +599,6 @@ bse_project_create_intern_synth (BseProject *self,
}
return BSE_SNET (synth);
}
-
BseCSynth*
bse_project_create_intern_csynth (BseProject *self,
const char *base_name)
@@ -712,7 +607,6 @@ bse_project_create_intern_csynth (BseProject *self,
bse_item_set_internal (BSE_ITEM (csynth), TRUE);
return csynth;
}
-
BseMidiNotifier*
bse_project_get_midi_notifier (BseProject *self)
{
@@ -720,29 +614,24 @@ bse_project_get_midi_notifier (BseProject *self)
for (slist = self->items; slist; slist = slist->next)
if (BSE_IS_MIDI_NOTIFIER (slist->data))
return (BseMidiNotifier*) slist->data;
-
BseMidiNotifier *mnot = (BseMidiNotifier*) bse_container_new_child_bname (BSE_CONTAINER (self), BSE_TYPE_MIDI_NOTIFIER,
"%bse-intern-midi-notifier", NULL);
bse_midi_notifier_set_receiver (mnot, self->midi_receiver);
bse_item_set_internal (BSE_ITEM (mnot), TRUE);
return mnot;
}
-
static void
bse_project_prepare (BseSource *source)
{
BseProject *self = BSE_PROJECT (source);
GSList *slist;
-
/* make sure Wave repositories are prepared first */
for (slist = self->supers; slist; slist = slist->next)
if (BSE_IS_WAVE_REPO (slist->data))
bse_source_prepare ((BseSource*) slist->data);
-
/* chain parent class' handler to prepare the rest */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static gboolean
auto_deactivate (gpointer data)
{
@@ -752,13 +641,11 @@ auto_deactivate (gpointer data)
bse_project_deactivate (self);
return FALSE;
}
-
void
bse_project_state_changed (BseProject *self,
BseProjectState state)
{
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (self->deactivate_timer)
{
bse_idle_remove (self->deactivate_timer);
@@ -775,13 +662,11 @@ bse_project_state_changed (BseProject *self,
}
g_signal_emit (self, signal_state_changed, 0, state);
}
-
void
bse_project_keep_activated (BseProject *self,
guint64 min_tick)
{
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (min_tick > self->deactivate_min_tick)
{
self->deactivate_min_tick = min_tick;
@@ -789,28 +674,21 @@ bse_project_keep_activated (BseProject *self,
bse_project_state_changed (self, self->state);
}
}
-
BseErrorType
bse_project_activate (BseProject *self)
{
BseErrorType error;
BseTrans *trans;
GSList *slist;
-
g_return_val_if_fail (BSE_IS_PROJECT (self), BSE_ERROR_INTERNAL);
-
if (self->state != BSE_PROJECT_INACTIVE)
return BSE_ERROR_NONE;
-
g_return_val_if_fail (BSE_SOURCE_PREPARED (self) == FALSE, BSE_ERROR_INTERNAL);
-
error = bse_server_open_devices (bse_server_get ());
if (error)
return error;
-
bse_source_prepare (BSE_SOURCE (self));
self->deactivate_min_tick = 0;
-
trans = bse_trans_open ();
for (slist = self->supers; slist; slist = slist->next)
{
@@ -831,20 +709,16 @@ bse_project_activate (BseProject *self)
bse_project_state_changed (self, BSE_PROJECT_ACTIVE);
return BSE_ERROR_NONE;
}
-
void
bse_project_start_playback (BseProject *self)
{
BseTrans *trans;
GSList *slist;
guint seen_synth = 0;
-
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (self->state != BSE_PROJECT_ACTIVE)
return;
g_return_if_fail (BSE_SOURCE_PREPARED (self) == TRUE);
-
SfiRing *songs = NULL;
trans = bse_trans_open ();
for (slist = self->supers; slist; slist = slist->next)
@@ -877,19 +751,15 @@ bse_project_start_playback (BseProject *self)
while (songs)
bse_sequencer_start_song ((BseSong*) sfi_ring_pop_head (&songs), 0);
}
-
void
bse_project_stop_playback (BseProject *self)
{
BseTrans *trans;
GSList *slist;
-
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (self->state != BSE_PROJECT_PLAYING)
return;
g_return_if_fail (BSE_SOURCE_PREPARED (self) == TRUE);
-
trans = bse_trans_open ();
for (slist = self->supers; slist; slist = slist->next)
{
@@ -911,12 +781,10 @@ bse_project_stop_playback (BseProject *self)
/* update state */
bse_project_state_changed (self, BSE_PROJECT_ACTIVE);
}
-
void
bse_project_check_auto_stop (BseProject *self)
{
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (self->state == BSE_PROJECT_PLAYING)
{
GSList *slist;
@@ -932,21 +800,16 @@ bse_project_check_auto_stop (BseProject *self)
bse_project_stop_playback (self);
}
}
-
void
bse_project_deactivate (BseProject *self)
{
BseTrans *trans;
GSList *slist;
-
g_return_if_fail (BSE_IS_PROJECT (self));
-
if (self->state == BSE_PROJECT_INACTIVE)
return;
g_return_if_fail (BSE_SOURCE_PREPARED (self) == TRUE);
-
bse_project_stop_playback (self);
-
trans = bse_trans_open ();
for (slist = self->supers; slist; slist = slist->next)
{
@@ -963,6 +826,5 @@ bse_project_deactivate (BseProject *self)
bse_engine_wait_on_trans ();
bse_source_reset (BSE_SOURCE (self));
bse_project_state_changed (self, BSE_PROJECT_INACTIVE);
-
bse_server_close_devices (bse_server_get ());
}
diff --git a/bse/bseproject.hh b/bse/bseproject.hh
index 62b1210..f0e9af7 100644
--- a/bse/bseproject.hh
+++ b/bse/bseproject.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PROJECT_H__
#define __BSE_PROJECT_H__
-
#include <bse/bsecontainer.hh>
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_PROJECT (BSE_TYPE_ID (BseProject))
#define BSE_PROJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PROJECT, BseProject))
@@ -14,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_PROJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PROJECT))
#define BSE_IS_PROJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PROJECT))
#define BSE_PROJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PROJECT, BseProjectClass))
-
-
/* --- BseProject object --- */
typedef enum {
BSE_PROJECT_INACTIVE,
@@ -25,28 +19,22 @@ typedef enum {
struct _BseProject
{
BseContainer parent_object;
-
GSList *supers;
GSList *items;
-
guint in_undo : 1;
guint in_redo : 1;
BseUndoStack *undo_stack;
BseUndoStack *redo_stack;
-
BseProjectState state;
guint deactivate_timer;
gint64 deactivate_usecs;
guint64 deactivate_min_tick;
-
BseMidiReceiver *midi_receiver;
};
struct _BseProjectClass
{
BseContainerClass parent_class;
};
-
-
/* --- prototypes --- */
BseErrorType bse_project_activate (BseProject *project);
void bse_project_start_playback (BseProject *project);
@@ -85,8 +73,5 @@ BseMidiNotifier*bse_project_get_midi_notifier (BseProject *project);
void bse_project_clear_undo (BseProject *project);
void bse_project_clean_dirty (BseProject *project);
void bse_project_push_undo_silent_deactivate (BseProject *self);
-
-
G_END_DECLS
-
#endif /* __BSE_PROJECT_H__ */
diff --git a/bse/bseproject.proc b/bse/bseproject.proc
index 9597f34..6a7fce8 100644
--- a/bse/bseproject.proc
+++ b/bse/bseproject.proc
@@ -14,12 +14,8 @@
#include <bse/bsemidinotifier.hh>
#include <bse/bseengine.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseProject, is-playing) {
HELP = "Check whether a project is currently playing";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -32,19 +28,14 @@ METHOD (BseProject, is-playing) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
-
/* set output parameters */
sfi_value_set_bool (out_values++, project->state == BSE_PROJECT_PLAYING);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, is-active) {
HELP = "Check whether a project is active";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -57,19 +48,14 @@ METHOD (BseProject, is-active) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
-
/* set output parameters */
sfi_value_set_bool (out_values++, project->state != BSE_PROJECT_INACTIVE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, get-midi-notifier) {
HELP = "Retrieve the project's midi notifier object.";
IN = bse_param_spec_object ("project", "Project", NULL, BSE_TYPE_PROJECT, SFI_PARAM_STANDARD);
@@ -80,19 +66,14 @@ METHOD (BseProject, get-midi-notifier) {
{
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
BseMidiNotifier *notifier = bse_project_get_midi_notifier (self);
-
/* set output parameters */
bse_value_set_object (out_values++, G_OBJECT (notifier));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, import-midi-file, "File/Import MIDI") {
HELP = "Import a song from a MIDI file.";
IN = bse_param_spec_object ("project", "Project", "The project", BSE_TYPE_PROJECT, SFI_PARAM_STANDARD);
@@ -110,11 +91,9 @@ METHOD (BseProject, import-midi-file, "File/Import MIDI") {
const char *file_name = sfi_value_get_string (in_values++);
BseMidiFile *smf;
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !file_name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
smf = bse_midi_file_load (file_name, &error);
if (!error)
@@ -133,13 +112,10 @@ METHOD (BseProject, import-midi-file, "File/Import MIDI") {
}
if (smf)
bse_midi_file_free (smf);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, restore-from-file, "File/Restore") {
HELP = "Load a project from file";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -157,11 +133,9 @@ METHOD (BseProject, restore-from-file, "File/Restore") {
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
const char *file_name = sfi_value_get_string (in_values++);
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !file_name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!project->in_undo && !project->in_redo)
{
@@ -175,13 +149,10 @@ METHOD (BseProject, restore-from-file, "File/Restore") {
}
else
error = BSE_ERROR_PROC_BUSY;
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, store-bse, "File/Store") {
HELP = "Save supers of a project into a BSE file. "
"If no super is specified, the project itself is stored.";
@@ -208,21 +179,16 @@ METHOD (BseProject, store-bse, "File/Store") {
const char *file_name = sfi_value_get_string (in_values++);
gboolean self_contained = sfi_value_get_bool (in_values++);
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !file_name)
return BSE_ERROR_PROC_PARAM_INVAL;
if (super && BSE_ITEM (super)->parent != BSE_ITEM (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
error = bse_project_store_bse (project, super, file_name, self_contained);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, create-song) {
HELP = "Create a song for this project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -240,11 +206,9 @@ METHOD (BseProject, create-song) {
const char *name = sfi_value_get_string (in_values++);
BseUndoStack *ustack;
BseItem *child;
-
/* check parameters */
if (!BSE_IS_PROJECT (container))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (container, "create-song");
child = (BseItem*) bse_container_new_child (container, BSE_TYPE_SONG, NULL);
@@ -252,13 +216,10 @@ METHOD (BseProject, create-song) {
bse_item_set (child, "uname", name, NULL);
bse_item_push_undo_proc (container, "remove-snet", child);
bse_item_undo_close (ustack);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, get-wave-repo) {
HELP = "Ensure the project has a wave repository";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -272,20 +233,15 @@ METHOD (BseProject, get-wave-repo) {
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
BseWaveRepo *wrepo = NULL;
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
wrepo = bse_project_get_wave_repo (project);
-
/* set output parameters */
bse_value_set_object (out_values++, wrepo);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, get-data-pocket) {
HELP = "Retrieve a specifically named data pocket for this project";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -302,22 +258,17 @@ METHOD (BseProject, get-data-pocket) {
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
const char *name = sfi_value_get_string (in_values++);
BseItem *item;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
item = bse_project_lookup_typed_item (project, BSE_TYPE_DATA_POCKET, name);
if (!item)
item = (BseItem*) bse_container_new_child (BSE_CONTAINER (project), BSE_TYPE_DATA_POCKET, "uname", name, NULL);
-
/* set output parameters */
bse_value_set_object (out_values++, item);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, create-csynth) {
HELP = "Create a synthsizer network for this project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -335,11 +286,9 @@ METHOD (BseProject, create-csynth) {
const char *name = sfi_value_get_string (in_values++);
BseUndoStack *ustack;
BseItem *child;
-
/* check parameters */
if (!BSE_IS_PROJECT (container))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (container, "create-csynth");
child = (BseItem*) bse_container_new_child (container, BSE_TYPE_CSYNTH, NULL);
@@ -347,13 +296,10 @@ METHOD (BseProject, create-csynth) {
bse_item_set (child, "uname", name, NULL);
bse_item_push_undo_proc (container, "remove-snet", child);
bse_item_undo_close (ustack);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, create-midi-synth) {
HELP = "Create a MIDI synthesizer network for this project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -371,11 +317,9 @@ METHOD (BseProject, create-midi-synth) {
const char *name = sfi_value_get_string (in_values++);
BseUndoStack *ustack;
BseItem *child;
-
/* check parameters */
if (!BSE_IS_PROJECT (container))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (container, "create-midi-synth");
child = (BseItem*) bse_container_new_child (container, BSE_TYPE_MIDI_SYNTH, NULL);
@@ -383,13 +327,10 @@ METHOD (BseProject, create-midi-synth) {
bse_item_set (child, "uname", name, NULL);
bse_item_push_undo_proc (container, "remove-snet", child);
bse_item_undo_close (ustack);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, remove-snet) {
HELP = "Remove an existing synthesizer network from this project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -404,11 +345,9 @@ METHOD (BseProject, remove-snet) {
BseContainer *self = (BseContainer*) bse_value_get_object (in_values++);
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_PROJECT (self) || !BSE_IS_SNET (child) || child->parent != (BseItem*) self)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_SOURCE_PREPARED (self))
{
@@ -422,10 +361,8 @@ METHOD (BseProject, remove-snet) {
/* done */
bse_item_undo_close (ustack);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, list-uname-paths) {
HELP = ("List uname paths for all items of a specified type within this project. "
"By their uname paths, items are uniquely identifyable within a project.");
@@ -442,17 +379,13 @@ METHOD (BseProject, list-uname-paths) {
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
const gchar *tname = sfi_value_get_string (in_values++);
GType type = tname ? g_type_from_name (tname) : 0;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !g_type_is_a (type, BSE_TYPE_ITEM))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_take_boxed (out_values++, bse_project_list_upaths (project, type));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, find-item) {
HELP = "Find an item within a project, given its uname path.";
IN = bse_param_spec_object ("project", NULL, NULL,
@@ -468,17 +401,13 @@ METHOD (BseProject, find-item) {
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
const gchar *string = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !string)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_container_resolve_upath (BSE_CONTAINER (project), string));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, match-items-by-uname) {
HELP = "Retrieve all items of a specific type within a project with matching uname";
IN = bse_param_spec_object ("project", NULL, NULL,
@@ -499,11 +428,9 @@ METHOD (BseProject, match-items-by-uname) {
GType type = tname ? g_type_from_name (tname) : 0;
GList *list, *free_list;
BseItemSeq *iseq;
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !string || !g_type_is_a (type, BSE_TYPE_ITEM))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
iseq = bse_item_seq_new ();
free_list = bse_objects_list_by_uname (type, string);
@@ -514,13 +441,10 @@ METHOD (BseProject, match-items-by-uname) {
break;
}
g_list_free (free_list);
-
/* set output parameters */
bse_value_take_boxed (out_values++, iseq);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, get-supers) {
HELP = "Retrieve all supers of this project.";
IN = bse_param_spec_object ("project", NULL, NULL,
@@ -534,22 +458,17 @@ METHOD (BseProject, get-supers) {
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
BseItemSeq *iseq;
GSList *slist;
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
iseq = bse_item_seq_new ();
for (slist = project->supers; slist; slist = slist->next)
bse_item_seq_append (iseq, (BseItem*) slist->data);
-
/* set output parameters */
bse_value_take_boxed (out_values++, iseq);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, can-play) {
HELP = "Check whether project playback would makes sense.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -563,18 +482,14 @@ METHOD (BseProject, can-play) {
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
gpointer wrepo;
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* playback works if we have supers other than wave repo */
wrepo = bse_project_get_wave_repo (project);
sfi_value_set_bool (out_values++, project->supers->data != wrepo || project->supers->next);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, get-state) {
HELP = "Retrieve the current project state.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -587,17 +502,13 @@ METHOD (BseProject, get-state) {
{
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
g_value_set_enum (out_values++, self->state);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, activate) {
HELP = "Activate a project, precondition to start playback.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -613,11 +524,9 @@ METHOD (BseProject, activate) {
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
BseProjectState state_before;
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
state_before = self->state;
error = bse_project_activate (self);
if (state_before == BSE_PROJECT_INACTIVE && self->state != BSE_PROJECT_INACTIVE)
@@ -625,12 +534,9 @@ METHOD (BseProject, activate) {
/* certain things work only (can only be undone) in deactivated projects */
bse_project_push_undo_silent_deactivate (self);
}
-
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, start-playback) {
HELP = "Start playback in an activated project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -642,11 +548,9 @@ METHOD (BseProject, start-playback) {
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
BseProjectState state_before;
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
state_before = self->state;
bse_project_start_playback (self);
if (state_before == BSE_PROJECT_INACTIVE && self->state != BSE_PROJECT_INACTIVE)
@@ -654,10 +558,8 @@ METHOD (BseProject, start-playback) {
/* certain things work only (can only be undone) in deactivated projects */
bse_project_push_undo_silent_deactivate (self);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, play) {
HELP = "Activate a project and start project playback (and already playing project is first halted).";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -673,11 +575,9 @@ METHOD (BseProject, play) {
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
BseErrorType error;
BseProjectState state_before;
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
state_before = self->state;
error = bse_project_activate (self);
if (!error)
@@ -691,12 +591,9 @@ METHOD (BseProject, play) {
/* certain things work only (can only be undone) in deactivated projects */
bse_project_push_undo_silent_deactivate (self);
}
-
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, deactivate) {
HELP = "Deactivate the project, automatically stop playback.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -707,16 +604,12 @@ METHOD (BseProject, deactivate) {
{
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_project_deactivate (self);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, stop-playback) {
HELP = "Stop project playback.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -727,16 +620,12 @@ METHOD (BseProject, stop-playback) {
{
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_project_stop_playback (self);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, stop) {
HELP = "Stop project playback and deactivate project.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -747,16 +636,12 @@ METHOD (BseProject, stop) {
{
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_project_deactivate (self);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, auto-deactivate) {
HELP = "Automatically deactivate a project once playback stopped.";
IN = bse_param_spec_object ("project", NULL, "The project",
@@ -770,16 +655,12 @@ METHOD (BseProject, auto-deactivate) {
/* extract parameter values */
BseProject *self = (BseProject*) bse_value_get_object (in_values++);
gint64 msecs = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
self->deactivate_usecs = msecs < 0 ? -1 : msecs * 1000;
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, inject-midi-control) {
HELP = "Inject a MIDI control event into the project's MIDI receiver.";
IN = bse_param_spec_object ("project", NULL, NULL, BSE_TYPE_PROJECT, SFI_PARAM_STANDARD);
@@ -795,11 +676,9 @@ METHOD (BseProject, inject-midi-control) {
int midi_channel = g_value_get_int (in_values++);
int midi_control = g_value_get_int (in_values++);
SfiReal control_value = sfi_value_get_real (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (BSE_SOURCE_PREPARED (project))
{
/* construct event */
@@ -814,10 +693,8 @@ METHOD (BseProject, inject-midi-control) {
bse_midi_receiver_push_event (project->midi_receiver, event);
bse_midi_receiver_process_events (project->midi_receiver, event->delta_time);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, change-name) {
HELP = "Change a project name without recording undo steps.";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -830,17 +707,13 @@ METHOD (BseProject, change-name) {
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
const char *name = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project) || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
g_object_set (project, "uname", name, NULL); /* no undo */
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, undo-depth) {
HELP = "Check whether a project can perform undo steps";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -853,17 +726,13 @@ METHOD (BseProject, undo-depth) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, bse_undo_stack_depth (project->undo_stack));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, undo) {
HELP = "Undo a previous operation in a project";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -874,11 +743,9 @@ METHOD (BseProject, undo) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!project->in_undo && !project->in_redo)
{
@@ -892,10 +759,8 @@ METHOD (BseProject, undo) {
project->in_undo = FALSE; /* swap undo<=>redo */
}
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, redo-depth) {
HELP = "Check whether a project can perform redo steps";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -908,17 +773,13 @@ METHOD (BseProject, redo-depth) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, bse_undo_stack_depth (project->redo_stack));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, redo) {
HELP = "Redo a previously undone operaiton in a project";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -929,11 +790,9 @@ METHOD (BseProject, redo) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!project->in_undo && !project->in_redo)
{
@@ -947,10 +806,8 @@ METHOD (BseProject, redo) {
project->in_redo = FALSE; /* enable redo-stack clearing */
}
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, clear-undo) {
HELP = "Delete all recorded undo or redo steps.";
IN = bse_param_spec_object ("project", "Project", NULL,
@@ -961,17 +818,13 @@ METHOD (BseProject, clear-undo) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_project_clear_undo (project);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, clean-dirty) {
HELP = "Clear a projects dirty flags.";
IN = bse_param_spec_object ("project", "Project", NULL,
@@ -982,17 +835,13 @@ METHOD (BseProject, clean-dirty) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_project_clean_dirty (project);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseProject, is-dirty) {
HELP = "Check whether a project is dirty (needs saving).";
IN = bse_param_spec_object ("project", "Project", "The project",
@@ -1004,15 +853,12 @@ METHOD (BseProject, is-dirty) {
{
/* extract parameter values */
BseProject *project = (BseProject*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_PROJECT (project))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
gboolean dirty = FALSE;
g_object_get (project, "dirty", &dirty, NULL);
sfi_value_set_bool (out_values++, dirty);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsequery.cc b/bse/bsequery.cc
index 92e8026..2f8d8af 100644
--- a/bse/bsequery.cc
+++ b/bse/bsequery.cc
@@ -11,7 +11,6 @@
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
-
static gchar *indent_inc = NULL;
static guint spacing = 1;
static FILE *f_out = NULL;
@@ -19,7 +18,6 @@ static GType root = 0;
static gboolean recursion = TRUE;
static gboolean feature_blurb = FALSE;
static gboolean feature_channels = FALSE;
-
/*
#define O_SPACE "\\as"
#define O_ESPACE " "
@@ -28,14 +26,12 @@ static gboolean feature_channels = FALSE;
#define O_LLEAF "\\aL"
#define O_KEY_FILL "_"
*/
-
#define O_SPACE " "
#define O_ESPACE ""
#define O_BRANCH "+"
#define O_VLINE "|"
#define O_LLEAF "`"
#define O_KEY_FILL "_"
-
static void
show_nodes (GType type,
GType sibling,
@@ -43,40 +39,31 @@ show_nodes (GType type,
{
GType *children;
guint i;
-
if (!type)
return;
-
children = g_type_children (type, NULL);
-
if (type != root)
for (i = 0; i < spacing; i++)
fprintf (f_out, "%s%s\n", indent, O_VLINE);
-
fprintf (f_out, "%s%s%s%s",
indent,
sibling ? O_BRANCH : (type != root ? O_LLEAF : O_SPACE),
O_ESPACE,
g_type_name (type));
-
for (i = strlen (g_type_name (type)); i <= strlen (indent_inc); i++)
fputs (O_KEY_FILL, f_out);
-
if (feature_blurb && bse_type_get_blurb (type))
{
fputs ("\t[", f_out);
fputs (bse_type_get_blurb (type), f_out);
fputs ("]", f_out);
}
-
if (G_TYPE_IS_ABSTRACT (type))
fputs ("\t(abstract)", f_out);
-
if (feature_channels && g_type_is_a (type, BSE_TYPE_SOURCE))
{
BseSourceClass *klass = (BseSourceClass*) g_type_class_ref (type);
gchar buffer[1024];
-
sprintf (buffer,
"\t(ichannels %u) (ochannels %u)",
klass->channel_defs.n_ichannels,
@@ -84,34 +71,26 @@ show_nodes (GType type,
fputs (buffer, f_out);
g_type_class_unref (klass);
}
-
fputc ('\n', f_out);
-
if (children && recursion)
{
gchar *new_indent;
GType *child;
-
if (sibling)
new_indent = g_strconcat (indent, O_VLINE, indent_inc, NULL);
else
new_indent = g_strconcat (indent, O_SPACE, indent_inc, NULL);
-
for (child = children; *child; child++)
show_nodes (child[0], child[1], new_indent);
-
g_free (new_indent);
}
-
g_free (children);
}
-
static void
show_cats (void)
{
BseCategorySeq *cseq;
guint i;
-
cseq = bse_categories_match_typed ("*", 0);
for (i = 0; i < cseq->n_cats; i++)
fprintf (f_out, "%s\t(%s)\n",
@@ -119,14 +98,12 @@ show_cats (void)
cseq->cats[i]->type);
bse_category_seq_free (cseq);
}
-
static void
show_procdoc (void)
{
BseCategorySeq *cseq;
guint i;
const gchar *nullstr = ""; // "???";
-
cseq = bse_categories_match_typed ("*", BSE_TYPE_PROCEDURE);
for (i = 0; i < cseq->n_cats; i++)
{
@@ -135,12 +112,10 @@ show_procdoc (void)
gchar *pname = g_type_name_to_sname (cseq->cats[i]->type);
const gchar *blurb = bse_type_get_blurb (type);
guint j;
-
fprintf (f_out, "/**\n * %s\n", pname);
for (j = 0; j < klass->n_in_pspecs; j++)
{
GParamSpec *pspec = G_PARAM_SPEC (klass->in_pspecs[j]);
-
fprintf (f_out, " * @%s: %s\n",
pspec->name,
g_param_spec_get_blurb (pspec) ? g_param_spec_get_blurb (pspec) : nullstr);
@@ -148,7 +123,6 @@ show_procdoc (void)
for (j = 0; j < klass->n_out_pspecs; j++)
{
GParamSpec *pspec = G_PARAM_SPEC (klass->out_pspecs[j]);
-
fprintf (f_out, " * @Returns: %s: %s\n",
pspec->name,
g_param_spec_get_blurb (pspec) ? g_param_spec_get_blurb (pspec) : nullstr);
@@ -161,7 +135,6 @@ show_procdoc (void)
}
bse_category_seq_free (cseq);
}
-
static gint
help (gchar *arg)
{
@@ -183,10 +156,8 @@ help (gchar *arg)
fprintf (stderr, " procdoc print procedure documentation\n");
fprintf (stderr, " synthlist list standard synths\n");
fprintf (stderr, " synth <x> dump standard synth <x> definition\n");
-
return arg != NULL;
}
-
int
main (gint argc,
gchar *argv[])
@@ -206,13 +177,9 @@ main (gint argc,
{ "load-core-scripts", scriptbool },
{ NULL },
};
-
f_out = stdout;
-
g_thread_init (NULL);
-
sfi_init (&argc, &argv, "BseQuery", NULL);
-
int i;
for (i = 1; i < argc; i++)
{
@@ -229,7 +196,6 @@ main (gint argc,
{
char *p;
guint n;
-
p = argv[i];
while (*p)
p++;
@@ -309,17 +275,13 @@ main (gint argc,
else
return help (argv[i]);
}
-
bse_init_inprocess (&argc, &argv, "BseQuery", config);
-
if (root_name)
root = g_type_from_name (root_name);
else
root = BSE_TYPE_OBJECT;
-
if (!gen_froots && !gen_tree && !gen_cats && !gen_procdoc && !list_synths && !show_synth)
return help (argv[i-1]);
-
if (!indent_inc)
{
indent_inc = g_new (gchar, strlen (O_SPACE) + 1);
@@ -328,7 +290,6 @@ main (gint argc,
strcpy (indent_inc, O_SPACE);
strcpy (indent_inc, O_SPACE);
}
-
if (gen_tree)
show_nodes (root, 0, iindent);
if (gen_froots)
@@ -357,6 +318,5 @@ main (gint argc,
g_print ("%s", text);
g_free (text);
}
-
return 0;
}
diff --git a/bse/bseresampler.cc b/bse/bseresampler.cc
index ade9ea3..1dcbf8a 100644
--- a/bse/bseresampler.cc
+++ b/bse/bseresampler.cc
@@ -1,10 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseresampler.hh"
#include "bseblockutils.hh"
-
namespace Bse {
namespace Resampler {
-
/* --- Resampler2 methods --- */
Resampler2*
Resampler2::create (BseResampler2Mode mode,
@@ -12,10 +10,8 @@ Resampler2::create (BseResampler2Mode mode,
{
return Block::create_resampler2 (mode, precision);
}
-
Resampler2::~Resampler2()
{}
-
BseResampler2Precision
Resampler2::find_precision_for_bits (guint bits)
{
@@ -29,13 +25,11 @@ Resampler2::find_precision_for_bits (guint bits)
return BSE_RESAMPLER2_PREC_96DB;
if (bits <= 20)
return BSE_RESAMPLER2_PREC_120DB;
-
/* thats the best precision we can deliver (and by the way also close to
* the best precision possible with floats anyway)
*/
return BSE_RESAMPLER2_PREC_144DB;
}
-
const char *
Resampler2::precision_name (BseResampler2Precision precision)
{
@@ -50,7 +44,6 @@ Resampler2::precision_name (BseResampler2Precision precision)
default: return "unknown precision enum value";
}
}
-
/* --- coefficient sets for Resampler2 --- */
/* halfband FIR filter for factor 2 resampling, created with octave
*
@@ -76,7 +69,6 @@ Resampler2::precision_name (BseResampler2Precision precision)
* does only "almost" fulfill the spec, but its really really close
* (no stopband ripple > -95 dB)
*/
-
const double Resampler2::halfband_fir_96db_coeffs[32] =
{
-3.48616530828033e-05,
@@ -113,7 +105,6 @@ const double Resampler2::halfband_fir_96db_coeffs[32] =
0.000112877490936177,
-3.48616530827983e-05
};
-
/* coefficients = 16
* x0 = 1.013
* alpha = 0.2
@@ -138,7 +129,6 @@ const double Resampler2::halfband_fir_48db_coeffs[16] =
0.00566964586625899,
-0.00270578824181638
};
-
/* coefficients = 24
* x0 = 1.0105
* alpha = 0.93
@@ -171,7 +161,6 @@ const double Resampler2::halfband_fir_72db_coeffs[24] =
0.000738054970125897,
-0.0002622341634290046,
};
-
/* coefficients = 42
* x0 = 1.0106
* alpha = 0.8
@@ -221,7 +210,6 @@ const double Resampler2::halfband_fir_120db_coeffs[42] = {
-9.506281154917077e-06,
2.359361930409472e-06
};
-
/* coefficients = 52
* x0 = 1.0104
* alpha = 0.8
@@ -281,7 +269,6 @@ const double Resampler2::halfband_fir_144db_coeffs[52] = {
8.762360674786308e-07,
-1.841826652067372e-07,
};
-
/* linear interpolation coefficients; barely useful for actual audio use,
* but useful for testing
*/
@@ -290,11 +277,8 @@ const double Resampler2::halfband_fir_linear_coeffs[2] = {
/* here, a 0.5 coefficient will be used */
0.25,
};
-
-
} // Resampler
} // Bse
-
/* --- Resampler2 C API --- */
BseResampler2*
bse_resampler2_create (BseResampler2Mode mode,
@@ -302,13 +286,11 @@ bse_resampler2_create (BseResampler2Mode mode,
{
return reinterpret_cast<BseResampler2 *> (Bse::Resampler::Resampler2::create (mode, precision));
}
-
void
bse_resampler2_destroy (BseResampler2 *resampler)
{
delete reinterpret_cast<Bse::Resampler::Resampler2 *> (resampler);
}
-
void
bse_resampler2_process_block (BseResampler2 *resampler,
const float *input,
@@ -317,25 +299,21 @@ bse_resampler2_process_block (BseResampler2 *resampler,
{
reinterpret_cast<Bse::Resampler::Resampler2 *> (resampler)->process_block (input, n_input_samples, output);
}
-
guint
bse_resampler2_order (BseResampler2 *resampler)
{
return reinterpret_cast<Bse::Resampler::Resampler2 *> (resampler)->order();
}
-
double
bse_resampler2_delay (BseResampler2 *resampler)
{
return reinterpret_cast<Bse::Resampler::Resampler2 *> (resampler)->delay();
}
-
BseResampler2Precision
bse_resampler2_find_precision_for_bits (guint bits)
{
return Bse::Resampler::Resampler2::find_precision_for_bits (bits);
}
-
const char*
bse_resampler2_precision_name (BseResampler2Precision precision)
{
diff --git a/bse/bseresampler.hh b/bse/bseresampler.hh
index be691bc..23dcb02 100644
--- a/bse/bseresampler.hh
+++ b/bse/bseresampler.hh
@@ -1,19 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_RESAMPLER_HH__
#define __BSE_RESAMPLER_HH__
-
#include <bse/bsecxxutils.hh>
-
G_BEGIN_DECLS
-
typedef struct BseResampler2 BseResampler2;
-
typedef enum /*< skip >*/
{
BSE_RESAMPLER2_MODE_UPSAMPLE,
BSE_RESAMPLER2_MODE_DOWNSAMPLE
} BseResampler2Mode;
-
typedef enum /*< skip >*/
{
BSE_RESAMPLER2_PREC_LINEAR = 1, /* linear interpolation */
@@ -23,7 +18,6 @@ typedef enum /*< skip >*/
BSE_RESAMPLER2_PREC_120DB = 20,
BSE_RESAMPLER2_PREC_144DB = 24
} BseResampler2Precision;
-
BseResampler2* bse_resampler2_create (BseResampler2Mode mode,
BseResampler2Precision precision);
void bse_resampler2_destroy (BseResampler2 *resampler);
@@ -33,19 +27,14 @@ void bse_resampler2_process_block (BseResampler2 *resampler,
float *output);
guint bse_resampler2_order (BseResampler2 *resampler);
double bse_resampler2_delay (BseResampler2 *resampler);
-
/* precision <-> bits conversion */
BseResampler2Precision bse_resampler2_find_precision_for_bits (guint bits);
const char* bse_resampler2_precision_name (BseResampler2Precision precision);
-
G_END_DECLS
-
#ifdef __cplusplus
#include <vector>
-
namespace Bse {
namespace Resampler {
-
/**
* Interface for factor 2 resampling classes
*/
@@ -96,7 +85,6 @@ protected:
static const double halfband_fir_96db_coeffs[32];
static const double halfband_fir_120db_coeffs[42];
static const double halfband_fir_144db_coeffs[52];
-
/* Creates implementation from filter coefficients and Filter implementation class
*
* Since up- and downsamplers use different (scaled) coefficients, its possible
@@ -110,7 +98,6 @@ protected:
float taps[order];
for (guint i = 0; i < order; i++)
taps[i] = d[i] * scaling;
-
Resampler2 *filter = new Filter (taps);
g_assert (order == filter->order());
return filter;
@@ -125,11 +112,7 @@ protected:
create_impl (BseResampler2Mode mode,
BseResampler2Precision precision);
};
-
} /* namespace Resampler */
-
} /* namespace Bse */
-
#endif /* __cplusplus */
-
#endif /* __BSE_RESAMPLER_HH__ */
diff --git a/bse/bseresamplerimpl.hh b/bse/bseresamplerimpl.hh
index 94b93bf..5e8c886 100644
--- a/bse/bseresamplerimpl.hh
+++ b/bse/bseresamplerimpl.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_RESAMPLER_TCC__
#define __BSE_RESAMPLER_TCC__
-
#include <vector>
#include <bse/bseresampler.hh>
#include <birnet/birnet.hh>
@@ -12,7 +11,6 @@
#ifdef __SSE__
#include <xmmintrin.h>
#endif
-
namespace Bse {
namespace Resampler {
using std::vector;
@@ -20,7 +18,6 @@ using std::min;
using std::max;
using std::copy;
using Birnet::AlignedArray;
-
/* see: http://ds9a.nl/gcc-simd/ */
union F4Vector
{
@@ -29,7 +26,6 @@ union F4Vector
__m128 v; // vector of four single floats
#endif
};
-
/**
* FIR filter routine
*
@@ -55,7 +51,6 @@ fir_process_one_sample (const float *input,
out += input[i] * taps[i];
return out;
}
-
/**
* FIR filter routine for 4 samples simultaneously
*
@@ -80,12 +75,10 @@ fir_process_4samples_sse (const float *input,
const F4Vector *input_v = reinterpret_cast<const F4Vector *> (input);
const F4Vector *sse_taps_v = reinterpret_cast<const F4Vector *> (sse_taps);
F4Vector out0_v, out1_v, out2_v, out3_v;
-
out0_v.v = _mm_mul_ps (input_v[0].v, sse_taps_v[0].v);
out1_v.v = _mm_mul_ps (input_v[0].v, sse_taps_v[1].v);
out2_v.v = _mm_mul_ps (input_v[0].v, sse_taps_v[2].v);
out3_v.v = _mm_mul_ps (input_v[0].v, sse_taps_v[3].v);
-
for (guint i = 1; i < (order + 6) / 4; i++)
{
out0_v.v = _mm_add_ps (out0_v.v, _mm_mul_ps (input_v[i].v, sse_taps_v[i * 4 + 0].v));
@@ -93,7 +86,6 @@ fir_process_4samples_sse (const float *input,
out2_v.v = _mm_add_ps (out2_v.v, _mm_mul_ps (input_v[i].v, sse_taps_v[i * 4 + 2].v));
out3_v.v = _mm_add_ps (out3_v.v, _mm_mul_ps (input_v[i].v, sse_taps_v[i * 4 + 3].v));
}
-
*out0 = out0_v.f[0] + out0_v.f[1] + out0_v.f[2] + out0_v.f[3];
*out1 = out1_v.f[0] + out1_v.f[1] + out1_v.f[2] + out1_v.f[3];
*out2 = out2_v.f[0] + out2_v.f[1] + out2_v.f[2] + out2_v.f[3];
@@ -102,8 +94,6 @@ fir_process_4samples_sse (const float *input,
g_assert_not_reached();
#endif
}
-
-
/**
* fir_compute_sse_taps takes a normal vector of FIR taps as argument and
* computes a specially scrambled version of these taps, ready to be used
@@ -127,17 +117,14 @@ fir_compute_sse_taps (const vector<float>& taps)
{
const int order = taps.size();
vector<float> sse_taps ((order + 6) / 4 * 16);
-
for (int j = 0; j < 4; j++)
for (int i = 0; i < order; i++)
{
int k = i + j;
sse_taps[(k / 4) * 16 + (k % 4) + j * 4] = taps[i];
}
-
return sse_taps;
}
-
/**
* This function tests the SSEified FIR filter code (that is, the reordering
* done by fir_compute_sse_taps and the actual computation implemented in
@@ -154,13 +141,11 @@ fir_test_filter_sse (bool verbose,
int errors = 0;
if (verbose)
printf ("testing SSE filter implementation:\n\n");
-
for (guint order = 0; order < max_order; order++)
{
vector<float> taps (order);
for (guint i = 0; i < order; i++)
taps[i] = i + 1;
-
AlignedArray<float,16> sse_taps (fir_compute_sse_taps (taps));
if (verbose)
{
@@ -174,18 +159,15 @@ fir_test_filter_sse (bool verbose,
}
printf ("\n\n");
}
-
AlignedArray<float,16> random_mem (order + 4);
for (guint i = 0; i < order + 4; i++)
random_mem[i] = 1.0 - rand() / (0.5 * RAND_MAX);
-
/* FIXME: the problem with this test is that we explicitely test SSE code
* here, but the test case is not compiled with -msse within the BEAST tree
*/
float out[4];
fir_process_4samples_sse (&random_mem[0], &sse_taps[0], order,
&out[0], &out[1], &out[2], &out[3]);
-
double avg_diff = 0.0;
for (int i = 0; i < 4; i++)
{
@@ -203,10 +185,8 @@ fir_test_filter_sse (bool verbose,
printf ("*** %d errors detected\n", errors);
else
printf ("filter implementation ok.\n");
-
return (errors == 0);
}
-
/**
* Factor 2 upsampling of a data stream
*
@@ -226,12 +206,10 @@ protected:
float *output)
{
const guint H = (ORDER / 2); /* half the filter length */
-
output[1] = input[H];
output[3] = input[H + 1];
output[5] = input[H + 2];
output[7] = input[H + 3];
-
fir_process_4samples_sse (input, &sse_taps[0], ORDER, &output[0], &output[2], &output[4], &output[6]);
}
/* slow convolution */
@@ -302,13 +280,11 @@ public:
float *output)
{
const uint history_todo = min (n_input_samples, ORDER - 1);
-
copy (input, input + history_todo, &history[ORDER - 1]);
process_block_aligned (&history[0], history_todo, output);
if (n_input_samples > history_todo)
{
process_block_unaligned (input, n_input_samples - history_todo, &output [2 * history_todo]);
-
// build new history from new input
copy (input + n_input_samples - history_todo, input + n_input_samples, &history[0]);
}
@@ -333,7 +309,6 @@ public:
return order() - 1;
}
};
-
/**
* Factor 2 downsampling of a data stream
*
@@ -354,9 +329,7 @@ class Downsampler2 : public Resampler2 {
float *output)
{
const guint H = (ORDER / 2) - 1; /* half the filter length */
-
fir_process_4samples_sse (input_even, &sse_taps[0], ORDER, &output[0], &output[1], &output[2], &output[3]);
-
output[0] += 0.5 * input_odd[H * ODD_STEPPING];
output[1] += 0.5 * input_odd[(H + 1) * ODD_STEPPING];
output[2] += 0.5 * input_odd[(H + 2) * ODD_STEPPING];
@@ -368,7 +341,6 @@ class Downsampler2 : public Resampler2 {
const float *input_odd)
{
const guint H = (ORDER / 2) - 1; /* half the filter length */
-
return fir_process_one_sample<float> (&input_even[0], &taps[0], ORDER) + 0.5 * input_odd[H * ODD_STEPPING];
}
template<int ODD_STEPPING> void
@@ -441,16 +413,12 @@ public:
float *output)
{
g_assert ((n_input_samples & 1) == 0);
-
const uint BLOCKSIZE = 1024;
-
F4Vector block[BLOCKSIZE / 4]; /* using F4Vector ensures 16-byte alignment */
float *input_even = &block[0].f[0];
-
while (n_input_samples)
{
uint n_input_todo = min (n_input_samples, BLOCKSIZE * 2);
-
/* since the halfband filter contains zeros every other sample
* and since we're using SSE instructions, which expect the
* data to be consecutively represented in memory, we prepare
@@ -465,20 +433,15 @@ public:
* is only required for SSE instructions
*/
deinterleave2 (input, n_input_todo, input_even);
-
const float *input_odd = input + 1; /* we process this one with a stepping of 2 */
-
const uint n_output_todo = n_input_todo / 2;
const uint history_todo = min (n_output_todo, ORDER - 1);
-
copy (input_even, input_even + history_todo, &history_even[ORDER - 1]);
deinterleave2 (input_odd, history_todo * 2, &history_odd[ORDER - 1]);
-
process_block_aligned <1> (&history_even[0], &history_odd[0], output, history_todo);
if (n_output_todo > history_todo)
{
process_block_unaligned<2> (input_even, input_odd, &output[history_todo], n_output_todo - history_todo);
-
// build new history from new input (here: history_todo == ORDER - 1)
copy (input_even + n_output_todo - history_todo, input_even + n_output_todo, &history_even[0]);
deinterleave2 (input_odd + n_input_todo - history_todo * 2, history_todo * 2, &history_odd[0]); /* FIXME: can be optimized */
@@ -490,7 +453,6 @@ public:
g_memmove (&history_even[0], &history_even[n_output_todo], sizeof (history_even[0]) * (ORDER - 1));
g_memmove (&history_odd[0], &history_odd[n_output_todo], sizeof (history_odd[0]) * (ORDER - 1));
}
-
n_input_samples -= n_input_todo;
input += n_input_todo;
output += n_output_todo;
@@ -510,7 +472,6 @@ public:
return order() / 2 - 0.5;
}
};
-
template<bool USE_SSE> Resampler2*
Resampler2::create_impl (BseResampler2Mode mode,
BseResampler2Precision precision)
@@ -541,8 +502,6 @@ Resampler2::create_impl (BseResampler2Mode mode,
}
return 0;
}
-
} // Resampler
} // Bse
-
#endif /* __BSE_RESAMPLER_TCC__ */
diff --git a/bse/bsescripthelper.cc b/bse/bsescripthelper.cc
index 108965e..cd1e65e 100644
--- a/bse/bsescripthelper.cc
+++ b/bse/bsescripthelper.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsescripthelper.hh"
-
#include "topconfig.h"
#include "bsecategories.hh"
#include "bsejanitor.hh"
@@ -9,8 +8,6 @@
#include "bsemain.hh"
#include <string.h>
#include <stdlib.h>
-
-
/* --- prototypes --- */
static void bse_script_procedure_init (BseScriptProcedureClass *klass,
BseScriptData *sdata);
@@ -22,12 +19,8 @@ static GParamSpec* bse_script_param_spec (gchar *pspec_desc,
const gchar *func_name,
gchar **free1,
gchar **free2);
-
-
/* --- variables --- */
static GQuark quark_script_args = 0;
-
-
/* --- functions --- */
static void
bse_script_procedure_init (BseScriptProcedureClass *klass,
@@ -36,10 +29,8 @@ bse_script_procedure_init (BseScriptProcedureClass *klass,
BseProcedureClass *proc = (BseProcedureClass*) klass;
SfiRing *ring;
guint n;
-
klass->sdata = sdata;
proc->execute = bse_script_procedure_exec;
-
/* we support a limited parameter set for scripts */
n = sfi_ring_length (sdata->params);
proc->in_pspecs = g_new (GParamSpec*, n + 1);
@@ -60,7 +51,6 @@ bse_script_procedure_init (BseScriptProcedureClass *klass,
}
proc->in_pspecs[proc->n_in_pspecs] = NULL;
}
-
GType
bse_script_proc_register (const gchar *script_file,
const gchar *name,
@@ -75,20 +65,17 @@ bse_script_proc_register (const gchar *script_file,
{
GTypeInfo script_info = {
sizeof (BseScriptProcedureClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_script_procedure_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
/* non classed type stuff */
0, 0, NULL,
};
BseScriptData *sdata;
gchar *tname;
GType type;
-
g_return_val_if_fail (script_file != NULL, 0);
g_return_val_if_fail (name != NULL, 0);
if (sfi_ring_length (params) > BSE_PROCEDURE_MAX_IN_PARAMS)
@@ -97,14 +84,11 @@ bse_script_proc_register (const gchar *script_file,
name, BSE_PROCEDURE_MAX_IN_PARAMS);
return 0;
}
-
sdata = g_new0 (BseScriptData, 1);
sdata->script_file = g_strdup (script_file);
sdata->name = g_strdup (name);
sdata->params = sfi_ring_copy_deep (params, (SfiRingDataFunc) g_strdup, NULL);
-
script_info.class_data = sdata;
-
tname = g_strconcat ("bse-script-", name, NULL);
type = g_type_register_static (BSE_TYPE_PROCEDURE, tname, &script_info, GTypeFlags (0));
g_free (tname);
@@ -123,7 +107,6 @@ bse_script_proc_register (const gchar *script_file,
}
return type;
}
-
static BseErrorType
bse_script_procedure_exec (BseProcedureClass *proc,
const GValue *in_values,
@@ -137,7 +120,6 @@ bse_script_procedure_exec (BseProcedureClass *proc,
BseErrorType error;
gchar *shellpath;
guint i;
-
params = sfi_ring_append (params, g_strdup_printf ("--bse-eval"));
params = sfi_ring_append (params, g_strdup_printf ("(load \"%s\")"
"(apply %s (bse-script-fetch-args))",
@@ -148,7 +130,6 @@ bse_script_procedure_exec (BseProcedureClass *proc,
params, sdata->script_file, BSE_PROCEDURE_NAME (proc), &janitor);
g_free (shellpath);
sfi_ring_free_deep (params, g_free);
-
if (error)
g_message ("failed to start script \"%s::%s\": %s",
sdata->script_file, BSE_PROCEDURE_NAME (proc), bse_error_blurb (error));
@@ -166,10 +147,8 @@ bse_script_procedure_exec (BseProcedureClass *proc,
g_object_set_qdata_full ((GObject*) janitor, quark_script_args, sfi_seq_copy_deep (seq), GDestroyNotify (sfi_seq_unref));
sfi_seq_unref (seq);
}
-
return error;
}
-
GValue*
bse_script_check_client_msg (SfiGlueDecoder *decoder,
BseJanitor *janitor,
@@ -183,7 +162,6 @@ bse_script_check_client_msg (SfiGlueDecoder *decoder,
SfiSeq *seq = sfi_value_get_seq (value);
GValue *retval;
const guint vargs_pos = 8;
-
if (!seq || seq->n_elements < vargs_pos || !sfi_seq_check (seq, SFI_TYPE_STRING))
retval = sfi_value_string ("invalid arguments supplied");
else
@@ -191,7 +169,6 @@ bse_script_check_client_msg (SfiGlueDecoder *decoder,
SfiRing *params = NULL;
GType type;
guint i;
-
for (i = vargs_pos; i < seq->n_elements; i++)
params = sfi_ring_append (params, (void*) sfi_value_get_string (sfi_seq_get (seq, i)));
type = bse_script_proc_register (janitor->script_name,
@@ -219,7 +196,6 @@ bse_script_check_client_msg (SfiGlueDecoder *decoder,
}
return NULL;
}
-
SfiRing*
bse_script_path_list_files (void)
{
@@ -242,7 +218,6 @@ bse_script_path_list_files (void)
}
return ring;
}
-
BseErrorType
bse_script_file_register (const gchar *file_name,
BseJanitor **janitor_p)
@@ -251,7 +226,6 @@ bse_script_file_register (const gchar *file_name,
SfiRing *params = NULL;
const char *proc_name = "registration hook";
BseErrorType error;
-
params = sfi_ring_append (params, g_strdup ("--bse-enable-register"));
params = sfi_ring_append (params, g_strdup ("--bse-eval"));
params = sfi_ring_append (params, g_strdup_printf ("(load \"%s\")", file_name));
@@ -261,15 +235,12 @@ bse_script_file_register (const gchar *file_name,
params, file_name, proc_name, janitor_p);
g_free (shellpath);
sfi_ring_free_deep (params, g_free);
-
return error;
}
-
static gchar*
make_sname (const gchar *string)
{
gchar *p, *cname = g_strdup (string);
-
for (p = cname; *p; p++)
{
if ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'z'))
@@ -281,9 +252,7 @@ make_sname (const gchar *string)
}
return cname;
}
-
#define PARAM_HINTS SFI_PARAM_STANDARD ":lax-validation:"
-
static GParamSpec*
bse_script_param_spec (gchar *pspec_desc,
const gchar *script_name,
@@ -293,7 +262,6 @@ bse_script_param_spec (gchar *pspec_desc,
{
gchar *pstring = strchr (pspec_desc, ':');
gchar *dflt, *cname;
-
if (!pstring)
return NULL;
*pstring++ = 0;
@@ -355,7 +323,6 @@ bse_script_param_spec (gchar *pspec_desc,
else if (strncmp (pspec_desc, "BseParamProxy", 13) == 0) /* "BseParamProxyBseProject:Project:0" */
{
GType type = g_type_from_name (pspec_desc + 13);
-
if (!g_type_is_a (type, BSE_TYPE_ITEM))
{
g_message ("unknown proxy type: %s", pspec_desc + 13);
diff --git a/bse/bsescripthelper.hh b/bse/bsescripthelper.hh
index f5b78f1..3da8b9b 100644
--- a/bse/bsescripthelper.hh
+++ b/bse/bsescripthelper.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SCRIPT_HELPER_H__
#define __BSE_SCRIPT_HELPER_H__
-
#include <bse/bseprocedure.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- typedefs & structures --- */
typedef struct
{
@@ -21,8 +17,6 @@ typedef struct
BseProcedureClass parent_class;
BseScriptData *sdata;
} BseScriptProcedureClass;
-
-
/* --- API --- */
GType bse_script_proc_register (const gchar *script_file,
const gchar *name,
@@ -41,9 +35,7 @@ GValue* bse_script_check_client_msg (SfiGlueDecoder *decoder,
BseJanitor *janitor,
const gchar *message,
const GValue *value);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_SCRIPT_HELPER_H__ */
diff --git a/bse/bsescripthelper.proc b/bse/bsescripthelper.proc
index 55aa031..044841d 100644
--- a/bse/bsescripthelper.proc
+++ b/bse/bsescripthelper.proc
@@ -2,12 +2,8 @@
#include <bse/bseplugin.hh>
#include <bse/bseprocedure.hh>
#include <bse/bsecontainer.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
PROCEDURE (bse-proxy-check, "Proxy Check") {
HELP = "Check whether a proxy has a certain type.";
IN = bse_param_spec_object ("item", "Item", "The Item",
@@ -25,17 +21,13 @@ PROCEDURE (bse-proxy-check, "Proxy Check") {
const char *type_name = sfi_value_get_string (in_values++);
GType type;
gboolean is_a;
-
/* check parameters */
if (!type_name)
type_name = "";
-
/* action */
type = g_type_from_name (type_name);
is_a = item && g_type_is_a (G_OBJECT_TYPE (item), type);
-
/* set output parameters */
sfi_value_set_bool (out_values++, is_a);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index 7c6231c..293da74 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -15,57 +15,44 @@
#include <errno.h>
#include <string.h>
#include <vector>
-
/* due to a linker/compiler bug on SuSE 9.2, we need to
* define extern "C" symbols outside of any C++ namespace,
* in order for C code to link against it.
*/
extern "C" { BirnetThread *bse_sequencer_thread = NULL; }
-
using namespace std;
-
#define CHECKTRACE() UNLIKELY (bse_trace_args.sequencer)
#define SEQTRACE(...) do { if (CHECKTRACE()) sfi_debug_channel_printf (bse_trace_args.sequencer, NULL, __VA_ARGS__); } while (0)
-
#define BSE_SEQUENCER_FUTURE_BLOCKS (7)
-
/* --- prototypes --- */
static void bse_sequencer_thread_main (gpointer data);
static void bse_sequencer_process_song_SL (BseSong *song,
guint n_ticks);
-
-
/* --- variables --- */
static BseSequencer *global_sequencer = NULL;
static BirnetCond current_watch_cond = { 0, };
static gint sequencer_wake_up_pipe[2] = { -1, -1 };
-
/* --- functions --- */
extern "C" void
bse_sequencer_init_thread (void)
{
g_assert (bse_sequencer_thread == NULL);
-
sfi_cond_init (¤t_watch_cond);
-
if (pipe (sequencer_wake_up_pipe) < 0)
g_error ("failed to create sequencer wake-up pipe: %s", strerror (errno));
glong flags = fcntl (sequencer_wake_up_pipe[0], F_GETFL, 0);
fcntl (sequencer_wake_up_pipe[0], F_SETFL, O_NONBLOCK | flags);
flags = fcntl (sequencer_wake_up_pipe[1], F_GETFL, 0);
fcntl (sequencer_wake_up_pipe[1], F_SETFL, O_NONBLOCK | flags);
-
/* initialize BseSequencer */
static BseSequencer sseq = { 0, };
sseq.stamp = gsl_tick_stamp ();
g_assert (sseq.stamp > 0);
global_sequencer = &sseq;
-
bse_sequencer_thread = sfi_thread_run ("Sequencer", bse_sequencer_thread_main, NULL);
if (!bse_sequencer_thread)
g_error ("failed to create sequencer thread");
}
-
static void
sequencer_wake_up (gpointer wake_up_data)
{
@@ -75,7 +62,6 @@ sequencer_wake_up (gpointer wake_up_data)
err = write (sequencer_wake_up_pipe[1], &wake_up_message, 1);
while (err < 0 && errno == EINTR);
}
-
namespace { // Anon
class PollPool {
public:
@@ -170,7 +156,6 @@ public:
watches.erase (watches.begin() + i);
return true;
}
-
BIRNET_STATIC_ASSERT (sizeof (GPollFD) == sizeof (struct pollfd));
BIRNET_STATIC_ASSERT (offsetof (GPollFD, fd) == offsetof (struct pollfd, fd));
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd));
@@ -180,9 +165,7 @@ public:
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents));
};
} // Anon
-
static PollPool sequencer_poll_pool;
-
extern "C" void
bse_sequencer_add_io_watch (guint n_pfds,
const GPollFD *pfds,
@@ -194,12 +177,10 @@ bse_sequencer_add_io_watch (guint n_pfds,
sequencer_poll_pool.add_watch (n_pfds, pfds, watch_func, data);
BSE_SEQUENCER_UNLOCK ();
}
-
static BseIOWatch current_watch_func = NULL;
static gpointer current_watch_data = NULL;
static bool current_watch_needs_remove1 = false;
static bool current_watch_needs_remove2 = false;
-
extern "C" void
bse_sequencer_remove_io_watch (BseIOWatch watch_func,
gpointer watch_data)
@@ -246,7 +227,6 @@ bse_sequencer_remove_io_watch (BseIOWatch watch_func,
if (!removal_success)
g_warning ("%s: failed to remove %p(%p)", G_STRFUNC, watch_func, watch_data);
}
-
static bool
bse_sequencer_poll_Lm (gint timeout_ms)
{
@@ -291,7 +271,6 @@ bse_sequencer_poll_Lm (gint timeout_ms)
}
return !sfi_thread_aborted();
}
-
extern "C" void
bse_sequencer_start_song (BseSong *song,
guint64 start_stamp)
@@ -302,7 +281,6 @@ bse_sequencer_start_song (BseSong *song,
g_return_if_fail (song->sequencer_start_request_SL == 0);
g_assert (song->sequencer_owns_refcount_SL == FALSE);
start_stamp = MAX (start_stamp, 1);
-
g_object_ref (song);
BSE_SEQUENCER_LOCK ();
song->sequencer_owns_refcount_SL = TRUE;
@@ -321,7 +299,6 @@ bse_sequencer_start_song (BseSong *song,
BSE_SEQUENCER_UNLOCK ();
sfi_thread_wakeup (bse_sequencer_thread);
}
-
extern "C" void
bse_sequencer_remove_song (BseSong *song)
{
@@ -332,7 +309,6 @@ bse_sequencer_remove_song (BseSong *song)
g_assert (song->sequencer_owns_refcount_SL == FALSE);
return; /* uncontained */
}
-
BSE_SEQUENCER_LOCK ();
SfiRing *ring = sfi_ring_find (global_sequencer->songs, song);
global_sequencer->songs = sfi_ring_remove_node (global_sequencer->songs, ring);
@@ -349,7 +325,6 @@ bse_sequencer_remove_song (BseSong *song)
if (need_unref)
g_object_unref (song);
}
-
static gboolean
bse_sequencer_remove_song_async (gpointer data) /* UserThread */
{
@@ -364,7 +339,6 @@ bse_sequencer_remove_song_async (gpointer data) /* UserThread */
g_object_unref (song); /* sequencer_owns_refcount_SL = FALSE from bse_sequencer_queue_remove_song_SL() */
return FALSE;
}
-
static void
bse_sequencer_queue_remove_song_SL (BseSong *song)
{
@@ -373,7 +347,6 @@ bse_sequencer_queue_remove_song_SL (BseSong *song)
/* queue a job into the BSE core for immediate execution */
bse_idle_now (bse_sequencer_remove_song_async, song);
}
-
extern "C" gboolean
bse_sequencer_thread_lagging (guint n_blocks)
{
@@ -385,7 +358,6 @@ bse_sequencer_thread_lagging (guint n_blocks)
BSE_SEQUENCER_UNLOCK ();
return lagging;
}
-
static void
bse_sequencer_thread_main (gpointer data)
{
@@ -398,7 +370,6 @@ bse_sequencer_thread_main (gpointer data)
const guint64 cur_stamp = gsl_tick_stamp ();
guint64 next_stamp = cur_stamp + BSE_SEQUENCER_FUTURE_BLOCKS * bse_engine_block_size();
SfiRing *ring;
-
for (ring = global_sequencer->songs; ring; ring = sfi_ring_walk (ring, global_sequencer->songs))
{
BseSong *song = BSE_SONG (ring->data);
@@ -441,14 +412,12 @@ bse_sequencer_thread_main (gpointer data)
}
}
global_sequencer->stamp = next_stamp;
-
sfi_thread_awake_after (cur_stamp + bse_engine_block_size ());
}
while (bse_sequencer_poll_Lm (-1));
BSE_SEQUENCER_UNLOCK ();
SEQTRACE ("SEQ:thrdstop: now=%llu", gsl_tick_stamp());
}
-
static void
bse_sequencer_process_track_SL (BseTrack *track,
gdouble start_stamp,
@@ -456,7 +425,6 @@ bse_sequencer_process_track_SL (BseTrack *track,
guint n_ticks,
gdouble stamps_per_tick,
BseMidiReceiver *midi_receiver);
-
static gboolean
bse_sequencer_process_song_unlooped_SL (BseSong *song,
guint n_ticks,
@@ -489,7 +457,6 @@ bse_sequencer_process_song_unlooped_SL (BseSong *song,
song->delta_stamp_SL += n_ticks * stamps_per_tick;
return n_done_tracks != n_tracks;
}
-
static void
bse_sequencer_process_song_SL (BseSong *song,
guint n_ticks)
@@ -517,7 +484,6 @@ bse_sequencer_process_song_SL (BseSong *song,
bse_sequencer_queue_remove_song_SL (song);
}
}
-
static void
bse_sequencer_process_part_SL (BsePart *part,
gdouble start_stamp,
@@ -567,7 +533,6 @@ bse_sequencer_process_track_SL (BseTrack *track,
part = next ? bse_track_get_part_SL (track, next, &start, &next) : NULL;
}
}
-
static void
bse_sequencer_process_part_SL (BsePart *part,
gdouble start_stamp,
@@ -579,7 +544,6 @@ bse_sequencer_process_part_SL (BsePart *part,
{
BsePartTickNode *node, *last;
guint channel;
-
for (channel = 0; channel < part->n_channels; channel++)
{
BsePartEventNote *note = bse_part_note_channel_lookup_ge (&part->channels[channel], start_tick);
@@ -606,7 +570,6 @@ bse_sequencer_process_part_SL (BsePart *part,
note++;
}
}
-
node = bse_part_controls_lookup_ge (&part->controls, start_tick);
last = bse_part_controls_lookup_lt (&part->controls, tick_bound);
if (node) while (node <= last)
diff --git a/bse/bsesequencer.hh b/bse/bsesequencer.hh
index 536138d..5a4c289 100644
--- a/bse/bsesequencer.hh
+++ b/bse/bsesequencer.hh
@@ -1,18 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SSEQUENCER_H__
#define __BSE_SSEQUENCER_H__
-
#include <bse/bsesong.hh>
-
G_BEGIN_DECLS
-
typedef struct {
guint64 stamp; /* sequencer time (ahead of real time) */
SfiRing *songs;
} BseSequencer;
-
extern BirnetThread *bse_sequencer_thread;
-
void bse_sequencer_init_thread (void);
void bse_sequencer_add_io_watch (guint n_pfds,
const GPollFD *pfds,
@@ -24,7 +19,5 @@ void bse_sequencer_start_song (BseSong *song,
guint64 start_stamp);
void bse_sequencer_remove_song (BseSong *song);
gboolean bse_sequencer_thread_lagging (guint n_blocks);
-
G_END_DECLS
-
#endif /* __BSE_SSEQUENCER_H__ */
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index 9b614d0..426bb56 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -16,12 +16,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
-
-
/* --- PCM BseModule implementations ---*/
#include "bsepcmmodule.cc"
-
-
/* --- parameters --- */
enum
{
@@ -30,8 +26,6 @@ enum
PROP_WAVE_FILE,
PROP_LOG_MESSAGES
};
-
-
/* --- prototypes --- */
static void bse_server_class_init (BseServerClass *klass);
static void bse_server_init (BseServer *server);
@@ -66,40 +60,32 @@ static void main_thread_source_setup (BseServer *self);
static void engine_init (BseServer *server,
gfloat mix_freq);
static void engine_shutdown (BseServer *server);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_registration = 0;
static guint signal_message = 0;
static guint signal_script_start = 0;
static guint signal_script_error = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseServer)
{
static const GTypeInfo server_info = {
sizeof (BseServerClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_server_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseServer),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_server_init,
};
-
return bse_type_register_static (BSE_TYPE_CONTAINER,
"BseServer",
"BSE Server type",
__FILE__, __LINE__,
&server_info);
}
-
static void
bse_server_class_init (BseServerClass *klass)
{
@@ -107,20 +93,15 @@ bse_server_class_init (BseServerClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_server_set_property;
gobject_class->get_property = bse_server_get_property;
gobject_class->finalize = bse_server_finalize;
-
item_class->set_parent = bse_server_set_parent;
-
container_class->add_item = bse_server_add_item;
container_class->remove_item = bse_server_remove_item;
container_class->forall_items = bse_server_forall_items;
container_class->release_children = bse_server_release_children;
-
_bse_gconfig_init ();
bse_object_class_add_param (object_class, "BSE Configuration",
PROP_GCONFIG,
@@ -133,7 +114,6 @@ bse_server_class_init (BseServerClass *klass)
bse_object_class_add_param (object_class, "Misc",
PROP_LOG_MESSAGES,
sfi_pspec_bool ("log-messages", "Log Messages", "Log messages through the log system", TRUE, SFI_PARAM_GUI));
-
signal_registration = bse_object_class_add_signal (object_class, "registration",
G_TYPE_NONE, 3,
BSE_TYPE_REGISTRATION_TYPE,
@@ -148,7 +128,6 @@ bse_server_class_init (BseServerClass *klass)
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
-
static GTokenType
rc_file_try_statement (gpointer context_data,
SfiRStore *rstore,
@@ -175,13 +154,11 @@ rc_file_try_statement (gpointer context_data,
else
return SFI_TOKEN_UNMATCHED;
}
-
static void
bse_server_init (BseServer *self)
{
g_assert (BSE_OBJECT_ID (self) == 1); /* assert being the first object */
BSE_OBJECT_SET_FLAGS (self, BSE_ITEM_FLAG_SINGLETON);
-
self->engine_source = NULL;
self->projects = NULL;
self->dev_use_count = 0;
@@ -191,13 +168,10 @@ bse_server_init (BseServer *self)
self->pcm_omodule = NULL;
self->pcm_writer = NULL;
self->midi_device = NULL;
-
/* keep the server singleton alive */
bse_item_use (BSE_ITEM (self));
-
/* start dispatching main thread stuff */
main_thread_source_setup (self);
-
/* read rc file */
int fd = -1;
if (!bse_main_args->birnet.stand_alone &&
@@ -212,24 +186,18 @@ bse_server_init (BseServer *self)
sfi_rstore_destroy (rstore);
close (fd);
}
-
/* integrate argv overides */
bse_gconfig_merge_args (bse_main_args);
-
/* dispatch midi notifiers */
bse_midi_notifiers_attach_source();
}
-
static void
bse_server_finalize (GObject *object)
{
g_error ("Fatal attempt to destroy singleton BseServer");
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
-
static void
bse_server_set_property (GObject *object,
guint param_id,
@@ -256,7 +224,6 @@ bse_server_set_property (GObject *object,
break;
}
}
-
static void
bse_server_get_property (GObject *object,
guint param_id,
@@ -283,34 +250,27 @@ bse_server_get_property (GObject *object,
break;
}
}
-
void
bse_server_notify_gconfig (BseServer *server)
{
g_return_if_fail (BSE_IS_SERVER (server));
-
g_object_notify ((GObject*) server, bse_gconfig_pspec ()->name);
}
-
static void
bse_server_set_parent (BseItem *item,
BseItem *parent)
{
g_warning ("%s: BseServer is a global singleton that cannot be added to a container", G_STRLOC);
}
-
static void
bse_server_add_item (BseContainer *container,
BseItem *item)
{
BseServer *self = BSE_SERVER (container);
-
self->children = g_slist_prepend (self->children, item);
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->add_item (container, item);
}
-
static void
bse_server_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -318,40 +278,31 @@ bse_server_forall_items (BseContainer *container,
{
BseServer *self = BSE_SERVER (container);
GSList *slist = self->children;
-
while (slist)
{
BseItem *item = (BseItem*) slist->data;
-
slist = slist->next;
if (!func (item, data))
return;
}
}
-
static void
bse_server_remove_item (BseContainer *container,
BseItem *item)
{
BseServer *self = BSE_SERVER (container);
-
self->children = g_slist_remove (self->children, item);
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->remove_item (container, item);
}
-
static void
bse_server_release_children (BseContainer *container)
{
// BseServer *self = BSE_SERVER (container);
-
g_warning ("release_children() should never be triggered on BseServer singleton");
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
/**
* @returns Global BSE Server
*
@@ -361,62 +312,50 @@ BseServer*
bse_server_get (void)
{
static BseServer *server = NULL;
-
if (!server)
{
server = (BseServer*) g_object_new (BSE_TYPE_SERVER, NULL);
g_object_ref (server);
}
-
return server;
}
-
static void
destroy_project (BseProject *project,
BseServer *server)
{
server->projects = g_list_remove (server->projects, project);
}
-
BseProject*
bse_server_create_project (BseServer *server,
const gchar *name)
{
BseProject *project;
-
g_return_val_if_fail (BSE_IS_SERVER (server), NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (bse_server_find_project (server, name) == NULL, NULL);
-
project = (BseProject*) g_object_new (BSE_TYPE_PROJECT, "uname", name, NULL);
server->projects = g_list_prepend (server->projects, project);
g_object_connect (project,
"signal::release", destroy_project, server,
NULL);
-
return project;
}
-
BseProject*
bse_server_find_project (BseServer *server,
const gchar *name)
{
GList *node;
-
g_return_val_if_fail (BSE_IS_SERVER (server), NULL);
g_return_val_if_fail (name != NULL, NULL);
-
for (node = server->projects; node; node = node->next)
{
BseProject *project = (BseProject*) node->data;
gchar *uname = BSE_OBJECT_UNAME (project);
-
if (uname && strcmp (name, uname) == 0)
return project;
}
return NULL;
}
-
void
bse_server_stop_recording (BseServer *self)
{
@@ -431,7 +370,6 @@ bse_server_stop_recording (BseServer *self)
self->wave_file = NULL;
g_object_notify ((GObject*) self, "wave-file");
}
-
void
bse_server_start_recording (BseServer *self,
const char *wave_file,
@@ -449,7 +387,6 @@ bse_server_start_recording (BseServer *self,
g_object_notify ((GObject*) self, "wave-file");
}
}
-
void
bse_server_require_pcm_input (BseServer *server)
{
@@ -472,14 +409,12 @@ bse_server_require_pcm_input (BseServer *server)
SFI_MSG_CHECK (_("Show messages about audio input problems")));
}
}
-
typedef struct {
guint n_channels;
guint mix_freq;
guint latency;
guint block_size;
} PcmRequest;
-
static void
pcm_request_callback (BseDevice *device,
gpointer data)
@@ -487,7 +422,6 @@ pcm_request_callback (BseDevice *device,
PcmRequest *pr = (PcmRequest*) data;
bse_pcm_device_request (BSE_PCM_DEVICE (device), pr->n_channels, pr->mix_freq, pr->latency, pr->block_size);
}
-
static BseErrorType
server_open_pcm_device (BseServer *server,
guint mix_freq,
@@ -495,7 +429,6 @@ server_open_pcm_device (BseServer *server,
guint block_size)
{
g_return_val_if_fail (server->pcm_device == NULL, BSE_ERROR_INTERNAL);
-
BseErrorType error = BSE_ERROR_NONE;
PcmRequest pr;
pr.n_channels = 2;
@@ -520,12 +453,10 @@ server_open_pcm_device (BseServer *server,
server->pcm_input_checked = FALSE;
return server->pcm_device ? BSE_ERROR_NONE : error;
}
-
static BseErrorType
server_open_midi_device (BseServer *server)
{
g_return_val_if_fail (server->midi_device == NULL, BSE_ERROR_INTERNAL);
-
BseErrorType error;
server->midi_device = (BseMidiDevice*) bse_device_open_best (BSE_TYPE_MIDI_DEVICE, TRUE, FALSE, bse_main_args->midi_drivers, NULL, NULL, &error);
if (!server->midi_device)
@@ -544,21 +475,17 @@ server_open_midi_device (BseServer *server)
}
return server->midi_device ? BSE_ERROR_NONE : error;
}
-
BseErrorType
bse_server_open_devices (BseServer *self)
{
BseErrorType error = BSE_ERROR_NONE;
-
g_return_val_if_fail (BSE_IS_SERVER (self), BSE_ERROR_INTERNAL);
-
/* check whether devices are already opened */
if (self->dev_use_count)
{
self->dev_use_count++;
return BSE_ERROR_NONE;
}
-
/* lock playback/capture/latency settings */
bse_gconfig_lock ();
/* calculate block_size for pcm setup */
@@ -626,13 +553,11 @@ bse_server_open_devices (BseServer *self)
bse_gconfig_unlock (); /* engine_init() holds another lock count on success */
return error;
}
-
void
bse_server_close_devices (BseServer *self)
{
g_return_if_fail (BSE_IS_SERVER (self));
g_return_if_fail (self->dev_use_count > 0);
-
self->dev_use_count--;
if (!self->dev_use_count)
{
@@ -660,7 +585,6 @@ bse_server_close_devices (BseServer *self)
self->midi_device = NULL;
}
}
-
BseModule*
bse_server_retrieve_pcm_output_module (BseServer *self,
BseSource *source,
@@ -670,12 +594,9 @@ bse_server_retrieve_pcm_output_module (BseServer *self,
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
g_return_val_if_fail (uplink_name != NULL, NULL);
g_return_val_if_fail (self->dev_use_count > 0, NULL);
-
self->dev_use_count += 1;
-
return self->pcm_omodule;
}
-
void
bse_server_discard_pcm_output_module (BseServer *self,
BseModule *module)
@@ -683,11 +604,9 @@ bse_server_discard_pcm_output_module (BseServer *self,
g_return_if_fail (BSE_IS_SERVER (self));
g_return_if_fail (module != NULL);
g_return_if_fail (self->dev_use_count > 0);
-
/* decrement dev_use_count */
bse_server_close_devices (self);
}
-
BseModule*
bse_server_retrieve_pcm_input_module (BseServer *self,
BseSource *source,
@@ -697,12 +616,9 @@ bse_server_retrieve_pcm_input_module (BseServer *self,
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
g_return_val_if_fail (uplink_name != NULL, NULL);
g_return_val_if_fail (self->dev_use_count > 0, NULL);
-
self->dev_use_count += 1;
-
return self->pcm_imodule;
}
-
void
bse_server_discard_pcm_input_module (BseServer *self,
BseModule *module)
@@ -710,11 +626,9 @@ bse_server_discard_pcm_input_module (BseServer *self,
g_return_if_fail (BSE_IS_SERVER (self));
g_return_if_fail (module != NULL);
g_return_if_fail (self->dev_use_count > 0);
-
/* decrement dev_use_count */
bse_server_close_devices (self);
}
-
/**
* @param script_control associated script control object
*
@@ -726,10 +640,8 @@ bse_server_script_start (BseServer *server,
{
g_return_if_fail (BSE_IS_SERVER (server));
g_return_if_fail (BSE_IS_JANITOR (janitor));
-
g_signal_emit (server, signal_script_start, 0, janitor);
}
-
void
bse_server_registration (BseServer *server,
BseRegistrationType rtype,
@@ -737,10 +649,8 @@ bse_server_registration (BseServer *server,
const gchar *error)
{
g_return_if_fail (BSE_IS_SERVER (server));
-
g_signal_emit (server, signal_registration, 0, rtype, what, error);
}
-
/**
* @param script_name name of the executed script
* @param proc_name procedure name to execute
@@ -758,11 +668,9 @@ bse_server_script_error (BseServer *server,
g_return_if_fail (script_name != NULL);
g_return_if_fail (proc_name != NULL);
g_return_if_fail (reason != NULL);
-
g_signal_emit (server, signal_script_error, 0,
script_name, proc_name, reason);
}
-
void
bse_server_send_message (BseServer *self,
const BseMessage *umsg)
@@ -773,7 +681,6 @@ bse_server_send_message (BseServer *self,
if (self->log_messages)
bse_message_to_default_handler (umsg);
}
-
void
bse_server_message (BseServer *server,
const gchar *log_domain,
@@ -789,7 +696,6 @@ bse_server_message (BseServer *server,
{
g_return_if_fail (BSE_IS_SERVER (server));
g_return_if_fail (primary != NULL);
-
BseMessage umsg = { 0, };
umsg.log_domain = (char*) log_domain;
umsg.type = msg_type;
@@ -805,7 +711,6 @@ bse_server_message (BseServer *server,
umsg.pid = pid;
bse_server_send_message (server, &umsg);
}
-
void
bse_server_add_io_watch (BseServer *server,
gint fd,
@@ -816,10 +721,8 @@ bse_server_add_io_watch (BseServer *server,
g_return_if_fail (BSE_IS_SERVER (server));
g_return_if_fail (watch_func != NULL);
g_return_if_fail (fd >= 0);
-
iowatch_add (server, fd, events, watch_func, data);
}
-
void
bse_server_remove_io_watch (BseServer *server,
BseIOWatch watch_func,
@@ -827,11 +730,9 @@ bse_server_remove_io_watch (BseServer *server,
{
g_return_if_fail (BSE_IS_SERVER (server));
g_return_if_fail (watch_func != NULL);
-
if (!iowatch_remove (server, watch_func, data))
g_warning (G_STRLOC ": no such io watch installed %p(%p)", watch_func, data);
}
-
BseErrorType
bse_server_run_remote (BseServer *server,
const gchar *process_name,
@@ -842,12 +743,10 @@ bse_server_run_remote (BseServer *server,
{
gint child_pid, command_input, command_output;
BseJanitor *janitor = NULL;
-
g_return_val_if_fail (BSE_IS_SERVER (server), BSE_ERROR_INTERNAL);
g_return_val_if_fail (process_name != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (script_name != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (proc_name != NULL, BSE_ERROR_INTERNAL);
-
child_pid = command_input = command_output = -1;
const char *reason = sfi_com_spawn_async (process_name,
&child_pid,
@@ -893,55 +792,43 @@ bse_server_run_remote (BseServer *server,
bse_server_script_start (server, janitor);
return BSE_ERROR_NONE;
}
-
-
/* --- GSL Main Thread Source --- */
typedef struct {
GSource source;
BseServer *server;
GPollFD pfd;
} MainSource;
-
static gboolean
main_source_prepare (GSource *source,
gint *timeout_p)
{
// MainSource *xsource = (MainSource*) source;
gboolean need_dispatch;
-
BSE_THREADS_ENTER ();
need_dispatch = FALSE;
BSE_THREADS_LEAVE ();
-
return need_dispatch;
}
-
static gboolean
main_source_check (GSource *source)
{
MainSource *xsource = (MainSource*) source;
gboolean need_dispatch;
-
BSE_THREADS_ENTER ();
need_dispatch = xsource->pfd.events & xsource->pfd.revents;
BSE_THREADS_LEAVE ();
-
return need_dispatch;
}
-
static gboolean
main_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
// MainSource *xsource = (MainSource*) source;
-
BSE_THREADS_ENTER ();
BSE_THREADS_LEAVE ();
-
return TRUE;
}
-
static void
main_thread_source_setup (BseServer *self)
{
@@ -953,15 +840,11 @@ main_thread_source_setup (BseServer *self)
GSource *source = g_source_new (&main_source_funcs, sizeof (MainSource));
MainSource *xsource = (MainSource*) source;
static gboolean single_call = 0;
-
g_assert (single_call++ == 0);
-
xsource->server = self;
g_source_set_priority (source, BSE_PRIORITY_NORMAL);
g_source_attach (source, bse_main_context);
}
-
-
/* --- GPollFD IO watch source --- */
typedef struct {
GSource source;
@@ -969,48 +852,38 @@ typedef struct {
BseIOWatch watch_func;
gpointer data;
} WSource;
-
static gboolean
iowatch_prepare (GSource *source,
gint *timeout_p)
{
/* WSource *wsource = (WSource*) source; */
gboolean need_dispatch;
-
/* BSE_THREADS_ENTER (); */
need_dispatch = FALSE;
/* BSE_THREADS_LEAVE (); */
-
return need_dispatch;
}
-
static gboolean
iowatch_check (GSource *source)
{
WSource *wsource = (WSource*) source;
guint need_dispatch;
-
/* BSE_THREADS_ENTER (); */
need_dispatch = wsource->pfd.events & wsource->pfd.revents;
/* BSE_THREADS_LEAVE (); */
-
return need_dispatch > 0;
}
-
static gboolean
iowatch_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
WSource *wsource = (WSource*) source;
-
BSE_THREADS_ENTER ();
wsource->watch_func (wsource->data, 1, &wsource->pfd);
BSE_THREADS_LEAVE ();
-
return TRUE;
}
-
static void
iowatch_add (BseServer *server,
gint fd,
@@ -1026,7 +899,6 @@ iowatch_add (BseServer *server,
};
GSource *source = g_source_new (&iowatch_gsource_funcs, sizeof (WSource));
WSource *wsource = (WSource*) source;
-
server->watch_list = g_slist_prepend (server->watch_list, wsource);
wsource->pfd.fd = fd;
wsource->pfd.events = events;
@@ -1036,18 +908,15 @@ iowatch_add (BseServer *server,
g_source_add_poll (source, &wsource->pfd);
g_source_attach (source, bse_main_context);
}
-
static gboolean
iowatch_remove (BseServer *server,
BseIOWatch watch_func,
gpointer data)
{
GSList *slist;
-
for (slist = server->watch_list; slist; slist = slist->next)
{
WSource *wsource = (WSource*) slist->data;
-
if (wsource->watch_func == watch_func && wsource->data == data)
{
g_source_destroy (&wsource->source);
@@ -1057,8 +926,6 @@ iowatch_remove (BseServer *server,
}
return FALSE;
}
-
-
/* --- GSL engine main loop --- */
typedef struct {
GSource source;
@@ -1066,27 +933,23 @@ typedef struct {
GPollFD fds[BSE_ENGINE_MAX_POLLFDS];
BseEngineLoop loop;
} PSource;
-
static gboolean
engine_prepare (GSource *source,
gint *timeout_p)
{
PSource *psource = (PSource*) source;
gboolean need_dispatch;
-
BSE_THREADS_ENTER ();
need_dispatch = bse_engine_prepare (&psource->loop);
if (psource->loop.fds_changed)
{
guint i;
-
for (i = 0; i < psource->n_fds; i++)
g_source_remove_poll (source, psource->fds + i);
psource->n_fds = psource->loop.n_fds;
for (i = 0; i < psource->n_fds; i++)
{
GPollFD *pfd = psource->fds + i;
-
pfd->fd = psource->loop.fds[i].fd;
pfd->events = psource->loop.fds[i].events;
g_source_add_poll (source, pfd);
@@ -1094,27 +957,22 @@ engine_prepare (GSource *source,
}
*timeout_p = psource->loop.timeout;
BSE_THREADS_LEAVE ();
-
return need_dispatch;
}
-
static gboolean
engine_check (GSource *source)
{
PSource *psource = (PSource*) source;
gboolean need_dispatch;
guint i;
-
BSE_THREADS_ENTER ();
for (i = 0; i < psource->n_fds; i++)
psource->loop.fds[i].revents = psource->fds[i].revents;
psource->loop.revents_filled = TRUE;
need_dispatch = bse_engine_check (&psource->loop);
BSE_THREADS_LEAVE ();
-
return need_dispatch;
}
-
static gboolean
engine_dispatch (GSource *source,
GSourceFunc callback,
@@ -1123,10 +981,8 @@ engine_dispatch (GSource *source,
BSE_THREADS_ENTER ();
bse_engine_dispatch ();
BSE_THREADS_LEAVE ();
-
return TRUE;
}
-
static void
engine_init (BseServer *server,
gfloat mix_freq)
@@ -1138,13 +994,10 @@ engine_init (BseServer *server,
NULL
};
static gboolean engine_is_initialized = FALSE;
-
g_return_if_fail (server->engine_source == NULL);
-
bse_gconfig_lock ();
server->engine_source = g_source_new (&engine_gsource_funcs, sizeof (PSource));
g_source_set_priority (server->engine_source, BSE_PRIORITY_HIGH);
-
if (!engine_is_initialized)
{
guint mypid = bse_main_getpid();
@@ -1157,15 +1010,12 @@ engine_init (BseServer *server,
setpriority (PRIO_PROCESS, mypid, current_priority + 1);
}
bse_engine_configure (BSE_GCONFIG (synth_latency), mix_freq, BSE_GCONFIG (synth_control_freq));
-
g_source_attach (server->engine_source, bse_main_context);
}
-
static void
engine_shutdown (BseServer *server)
{
g_return_if_fail (server->engine_source != NULL);
-
g_source_destroy (server->engine_source);
server->engine_source = NULL;
bse_engine_user_thread_collect ();
diff --git a/bse/bseserver.hh b/bse/bseserver.hh
index 15534fb..ed3eabb 100644
--- a/bse/bseserver.hh
+++ b/bse/bseserver.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SERVER_H__
#define __BSE_SERVER_H__
-
#include <bse/bsesuper.hh>
#include <bse/bsepcmdevice.hh>
#include <bse/bsemididevice.hh>
-
G_BEGIN_DECLS
-
/* --- BSE type macros --- */
#define BSE_TYPE_SERVER (BSE_TYPE_ID (BseServer))
#define BSE_SERVER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SERVER, BseServer))
@@ -15,21 +12,15 @@ G_BEGIN_DECLS
#define BSE_IS_SERVER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SERVER))
#define BSE_IS_SERVER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SERVER))
#define BSE_SERVER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SERVER, BseServerClass))
-
-
/* --- BseServer object --- */
struct _BseServer
{
BseContainer parent_object;
-
GSource *engine_source;
-
GList *projects;
GSList *children;
-
gchar *wave_file;
double wave_seconds;
-
guint dev_use_count;
guint log_messages : 1;
guint pcm_input_checked : 1;
@@ -38,15 +29,12 @@ struct _BseServer
BseModule *pcm_omodule;
BsePcmWriter *pcm_writer;
BseMidiDevice *midi_device;
-
GSList *watch_list;
};
struct _BseServerClass
{
BseContainerClass parent_class;
};
-
-
/* --- prototypes --- */
BseServer* bse_server_get (void);
BseProject* bse_server_create_project (BseServer *server,
@@ -85,7 +73,6 @@ void bse_server_add_io_watch (BseServer *server,
void bse_server_remove_io_watch (BseServer *server,
BseIOWatch watch_func,
gpointer data);
-
/* --- internal --- */
void bse_server_registration (BseServer *server,
BseRegistrationType rtype,
@@ -119,7 +106,5 @@ BseErrorType bse_server_run_remote (BseServer *server,
void bse_server_queue_kill_wire (BseServer *server,
SfiComWire *wire);
void bse_server_notify_gconfig (BseServer *server);
-
G_END_DECLS
-
#endif /* __BSE_SERVER_H__ */
diff --git a/bse/bseserver.proc b/bse/bseserver.proc
index e2af058..b135fc9 100644
--- a/bse/bseserver.proc
+++ b/bse/bseserver.proc
@@ -12,12 +12,8 @@
#include <bse/bseladspa.hh>
#include "topconfig.h"
#include <string.h>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseServer, use-new-project) {
HELP = "Create a new project, owned by the caller (name is modified to be unique if necessary)";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -37,11 +33,9 @@ BODY (BseProcedureClass *proc,
gchar *uname;
guint num = 1;
BseProject *project;
-
/* check parameters */
if (!BSE_IS_SERVER (server) || !name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* enforce unique name */
uname = g_strdup (name);
while (bse_server_find_project (server, uname))
@@ -49,19 +43,15 @@ BODY (BseProcedureClass *proc,
g_free (uname);
uname = g_strdup_printf ("%s-%u", name, num++);
}
-
/* create project */
project = bse_server_create_project (server, uname);
g_free (uname);
bse_item_use (BSE_ITEM (project));
g_object_unref (project);
-
/* set output parameters */
bse_value_set_object (out_values++, G_OBJECT (project));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, can-load) {
HELP = "Check whether a loader can be found for a wave file";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -79,20 +69,16 @@ BODY (BseProcedureClass *proc,
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
const char *file_name = sfi_value_get_string (in_values++);
BseWaveFileInfo *finfo;
-
/* check parameters */
if (!BSE_IS_SERVER (server) || !file_name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* find a loader */
finfo = bse_wave_file_info_load (file_name, NULL);
sfi_value_set_bool (out_values++, finfo != NULL);
if (finfo)
bse_wave_file_info_unref (finfo);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, n-scripts) {
HELP = "Return the number of scripts currently running on this server.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -109,22 +95,17 @@ BODY (BseProcedureClass *proc,
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
GSList *slist;
guint n_scripts = 0;
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* count script controls */
for (slist = server->children; slist; slist = slist->next)
if (BSE_IS_JANITOR (slist->data))
n_scripts++;
-
/* set output parameters */
sfi_value_set_int (out_values++, n_scripts);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, preferences-locked) {
HELP = "Returns whether the bse-preferences property is currently locked against modifications or not.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -138,17 +119,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, bse_gconfig_locked ());
-
return BSE_ERROR_NONE;
}
-
typedef struct _ScriptRegistration ScriptRegistration;
struct _ScriptRegistration
{
@@ -157,9 +134,7 @@ struct _ScriptRegistration
BseJanitor **janitor_p);
ScriptRegistration *next;
};
-
static gboolean register_scripts (gpointer data);
-
static void
script_janitor_closed (BseJanitor *janitor,
BseServer *server)
@@ -167,7 +142,6 @@ script_janitor_closed (BseJanitor *janitor,
bse_server_registration (server, BSE_REGISTER_SCRIPT, janitor->script_name, NULL);
bse_idle_normal (register_scripts, server);
}
-
static gboolean
register_scripts (gpointer data)
{
@@ -175,14 +149,12 @@ register_scripts (gpointer data)
ScriptRegistration *scr = (ScriptRegistration*) g_object_get_data ((GObject*) server, "script-registration-queue");
BseJanitor *janitor = NULL;
BseErrorType error;
-
if (!scr)
{
bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
return FALSE;
}
g_object_set_data ((GObject*) server, "script-registration-queue", scr->next);
-
error = scr->register_func (scr->script, &janitor);
if (!janitor)
bse_server_registration (server, BSE_REGISTER_SCRIPT, scr->script, bse_error_blurb (error));
@@ -192,7 +164,6 @@ register_scripts (gpointer data)
g_free (scr);
return !janitor;
}
-
METHOD (BseServer, register-scripts) {
HELP = "Register external scripts.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -207,18 +178,15 @@ BODY (BseProcedureClass *proc,
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
ScriptRegistration *scr_list = NULL;
SfiRing *ring;
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (registration_done)
{
bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
return BSE_ERROR_NONE;
}
registration_done = TRUE;
-
ring = bse_script_path_list_files ();
while (ring)
{
@@ -228,20 +196,16 @@ BODY (BseProcedureClass *proc,
scr->next = scr_list;
scr_list = scr;
}
-
g_object_set_data ((GObject*) server, "script-registration-queue", scr_list);
bse_idle_normal (register_scripts, server);
-
return BSE_ERROR_NONE;
}
-
static gboolean
register_core_plugins (gpointer data)
{
BseServer *server = (BseServer*) data;
SfiRing *plugins = (SfiRing*) g_object_get_data ((GObject*) server, "plugin-registration-queue");
const gchar *error;
-
if (plugins)
{
char *name = (char*) sfi_ring_pop_head (&plugins);
@@ -257,7 +221,6 @@ register_core_plugins (gpointer data)
}
return TRUE;
}
-
METHOD (BseServer, register-core-plugins) {
HELP = "Register core plugins.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -271,39 +234,31 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
SfiRing *ring;
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (registration_done)
{
bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
return BSE_ERROR_NONE;
}
registration_done = TRUE;
-
ring = bse_plugin_path_list_files (!bse_main_args->load_drivers_early, TRUE);
g_object_set_data ((GObject*) server, "plugin-registration-queue", ring);
-
bse_idle_normal (register_core_plugins, server);
-
return BSE_ERROR_NONE;
}
-
static gboolean
register_ladspa_plugins (gpointer data)
{
BseServer *server = (BseServer*) data;
SfiRing *lplugins = (SfiRing*) g_object_get_data ((GObject*) server, "ladspa-registration-queue");
const gchar *error;
-
if (g_object_get_data ((GObject*) server, "plugin-registration-queue"))
{
/* give precedence to core plugins until they're done registering */
return TRUE;
}
-
if (lplugins)
{
char *name = (char*) sfi_ring_pop_head (&lplugins);
@@ -319,7 +274,6 @@ register_ladspa_plugins (gpointer data)
}
return TRUE;
}
-
METHOD (BseServer, register-ladspa-plugins) {
HELP = "Register LADSPA (Linux Audio Developer's Simple Plugin API) plugins.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -333,31 +287,24 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
SfiRing *ring;
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
if (registration_done)
{
bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
return BSE_ERROR_NONE;
}
registration_done = TRUE;
-
ring = bse_ladspa_plugin_path_list_files ();
g_object_set_data ((GObject*) server, "ladspa-registration-queue", ring);
-
bse_idle_normal (register_ladspa_plugins, server);
-
return BSE_ERROR_NONE;
}
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-
METHOD (BseServer, save-preferences) {
HELP = "Request the bse-preferences property to be saved into BSE's configuration file.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -374,11 +321,9 @@ BODY (BseProcedureClass *proc,
GValue *value;
SfiRec *rec;
gint fd;
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
file_name = g_strconcat (g_get_home_dir (), "/.bserc", NULL);
fd = open (file_name,
O_WRONLY | O_CREAT | O_TRUNC, /* O_EXCL, */
@@ -386,10 +331,8 @@ BODY (BseProcedureClass *proc,
g_free (file_name);
if (fd < 0)
return BSE_ERROR_NONE;
-
wstore = sfi_wstore_new ();
sfi_wstore_printf (wstore, "; rc-file for BSE v%s\n", BSE_VERSION);
-
/* store BseGConfig */
sfi_wstore_puts (wstore, "\n; BseGConfig Dump\n");
rec = bse_gconfig_to_rec (bse_global_config);
@@ -398,15 +341,12 @@ BODY (BseProcedureClass *proc,
sfi_value_free (value);
sfi_rec_unref (rec);
sfi_wstore_puts (wstore, "\n");
-
/* flush stuff to rc file */
sfi_wstore_flush_fd (wstore, fd);
sfi_wstore_destroy (wstore);
close (fd);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, start-recording) {
HELP = "Start recording to a WAV file.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -423,15 +363,12 @@ BODY (BseProcedureClass *proc,
BseServer *server = (BseServer*) bse_value_get_object (in_values++);
const char *wave_file = g_value_get_string (in_values++);
double n_seconds = g_value_get_double (in_values++);
-
/* check parameters */
if (!BSE_IS_SERVER (server))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_server_start_recording (server, wave_file, n_seconds);
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-version) {
HELP = "Retrieve BSE version.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -445,7 +382,6 @@ BODY (BseProcedureClass *proc,
sfi_value_set_string (out_values++, BSE_VERSION);
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-demo-path) {
HELP = "Retrieve demo search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -459,7 +395,6 @@ BODY (BseProcedureClass *proc,
sfi_value_set_string (out_values++, BSE_PATH_DEMOS);
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-sample-path) {
HELP = "Retrieve sample search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -473,7 +408,6 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_SAMPLES, BSE_GCONFIG (sample_path), NULL));
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-custom-effect-dir) {
HELP = "Retrieve user specific effects directory.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -489,7 +423,6 @@ BODY (BseProcedureClass *proc,
g_strfreev (dirs);
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-effect-path) {
HELP = "Retrieve effect search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -503,7 +436,6 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_EFFECTS, BSE_GCONFIG (effect_path), NULL));
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-custom-instrument-dir) {
HELP = "Retrieve user specific instruments directory.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -519,7 +451,6 @@ BODY (BseProcedureClass *proc,
g_strfreev (dirs);
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-instrument-path) {
HELP = "Retrieve instrument search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -533,7 +464,6 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_INSTRUMENTS, BSE_GCONFIG (instrument_path), NULL));
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-script-path) {
HELP = "Retrieve script search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -547,7 +477,6 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_SCRIPTS, BSE_GCONFIG (script_path), NULL));
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-plugin-path) {
HELP = "Retrieve plugin search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -561,7 +490,6 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_PLUGINS, BSE_GCONFIG (plugin_path), NULL));
return BSE_ERROR_NONE;
}
-
METHOD (BseServer, get-ladspa-path) {
HELP = "Retrieve ladspa search path.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -575,9 +503,7 @@ BODY (BseProcedureClass *proc,
sfi_value_take_string (out_values++, g_path_concat (BSE_PATH_LADSPA, BSE_GCONFIG (ladspa_path), NULL));
return BSE_ERROR_NONE;
}
-
#include "gslvorbis-enc.hh"
-
METHOD (BseServer, get-vorbis-version) {
HELP = "Retrieve BSE Vorbis handler version.";
IN = bse_param_spec_object ("server", "Server", NULL,
@@ -598,9 +524,7 @@ BODY (BseProcedureClass *proc,
g_free (v);
return BSE_ERROR_NONE;
}
-
#include "gsldatahandle-mad.hh"
-
METHOD (BseServer, get-mp3-version) {
HELP = "Retrieve BSE MP3 handler version.";
IN = bse_param_spec_object ("server", "Server", NULL,
diff --git a/bse/bsesnet.cc b/bse/bsesnet.cc
index 5fd169b..f259698 100644
--- a/bse/bsesnet.cc
+++ b/bse/bsesnet.cc
@@ -7,15 +7,12 @@
#include <bse/bseengine.hh>
#include <bse/gslcommon.hh>
#include "bsesnet.hh"
-
#include "bseproject.hh"
#include "bsecategories.hh"
#include "bsestorage.hh"
#include "bsemain.hh"
#include "bsecontextmerger.hh"
#include "bsemidireceiver.hh"
-
-
typedef struct
{
guint context_id;
@@ -25,15 +22,12 @@ typedef struct
guint *branches;
guint parent_context;
} ContextData;
-
/* --- parameters --- */
enum
{
PARAM_0,
PARAM_AUTO_ACTIVATE
};
-
-
/* --- prototypes --- */
static void bse_snet_add_item (BseContainer *container,
BseItem *item);
@@ -57,8 +51,6 @@ static void bse_snet_context_dismiss (BseSource *source,
guint context_handle,
BseTrans *trans);
static GSList* snet_context_children (BseContainer *container);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_port_unregistered = 0;
@@ -67,8 +59,6 @@ static const GBSearchConfig port_array_config = {
snet_ports_compare,
0, /* G_BSEARCH_ARRAY_ALIGN_POWER2 */
};
-
-
/* --- functions --- */
static void
bse_snet_init (BseSNet *snet)
@@ -81,7 +71,6 @@ bse_snet_init (BseSNet *snet)
snet->port_array = NULL;
snet->port_unregistered_id = 0;
}
-
/**
* @param self valid BseSNet
* @param child valid BseItem, which is a child of @a self
@@ -95,42 +84,34 @@ bse_snet_intern_child (BseSNet *self,
gpointer child)
{
BseItem *item = (BseItem*) child;
-
g_return_if_fail (BSE_IS_SNET (self));
g_return_if_fail (BSE_IS_ITEM (item));
g_return_if_fail (item->parent == (BseItem*) self);
g_return_if_fail (sfi_ring_find (self->sources, child) != NULL);
-
self->sources = sfi_ring_remove (self->sources, child);
self->isources = sfi_ring_append (self->isources, child);
bse_item_set_internal (child, TRUE);
}
-
static void
bse_snet_release_children (BseContainer *container)
{
BseSNet *snet = BSE_SNET (container);
-
while (snet->sources)
bse_container_remove_item (container, (BseItem*) sfi_ring_pop_head (&snet->sources));
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
static void
bse_snet_dispose (GObject *object)
{
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_snet_finalize (GObject *object)
{
BseSNet *snet = BSE_SNET (object);
BseContainer *container = BSE_CONTAINER (object);
-
while (snet->sources)
bse_container_remove_item (container, (BseItem*) sfi_ring_pop_head (&snet->sources));
while (snet->isources)
@@ -144,33 +125,26 @@ bse_snet_finalize (GObject *object)
g_warning ("%s: %s: leaking %cport \"%s\"", G_STRLOC, G_OBJECT_TYPE_NAME (snet), 'i', (gchar*) snet->iport_names->data);
if (snet->oport_names)
g_warning ("%s: %s: leaking %cport \"%s\"", G_STRLOC, G_OBJECT_TYPE_NAME (snet), 'o', (gchar*) snet->oport_names->data);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
-
g_return_if_fail (snet->port_unregistered_id == 0);
}
-
static gboolean
snet_notify_port_unregistered (gpointer data)
{
BseSNet *snet = BSE_SNET (data);
-
BSE_THREADS_ENTER ();
snet->port_unregistered_id = 0;
g_signal_emit (snet, signal_port_unregistered, 0);
BSE_THREADS_LEAVE ();
-
return FALSE;
}
-
static void
bse_snet_queue_port_unregistered (BseSNet *snet)
{
if (!snet->port_unregistered_id)
snet->port_unregistered_id = bse_idle_notify (snet_notify_port_unregistered, snet);
}
-
static void
bse_snet_set_property (GObject *object,
guint param_id,
@@ -178,7 +152,6 @@ bse_snet_set_property (GObject *object,
GParamSpec *pspec)
{
BseSNet *self = BSE_SNET (object);
-
switch (param_id)
{
case PARAM_AUTO_ACTIVATE:
@@ -192,7 +165,6 @@ bse_snet_set_property (GObject *object,
break;
}
}
-
static void
bse_snet_get_property (GObject *object,
guint param_id,
@@ -200,7 +172,6 @@ bse_snet_get_property (GObject *object,
GParamSpec *pspec)
{
BseSNet *self = BSE_SNET (object);
-
switch (param_id)
{
case PARAM_AUTO_ACTIVATE:
@@ -211,23 +182,19 @@ bse_snet_get_property (GObject *object,
break;
}
}
-
static void
bse_snet_add_item (BseContainer *container,
BseItem *item)
{
BseSNet *snet = BSE_SNET (container);
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_SOURCE))
snet->sources = sfi_ring_append (snet->sources, item);
else if (BSE_SNET_USER_SYNTH (snet))
g_warning ("BseSNet: cannot hold non-source item type `%s'",
BSE_OBJECT_TYPE_NAME (item));
-
/* chain parent class' add_item handler */
BSE_CONTAINER_CLASS (parent_class)->add_item (container, item);
}
-
static void
bse_snet_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -235,7 +202,6 @@ bse_snet_forall_items (BseContainer *container,
{
BseSNet *snet = BSE_SNET (container);
SfiRing *node;
-
node = snet->sources;
while (node)
{
@@ -244,7 +210,6 @@ bse_snet_forall_items (BseContainer *container,
if (!func (item, data))
return;
}
-
node = snet->isources;
while (node)
{
@@ -254,13 +219,11 @@ bse_snet_forall_items (BseContainer *container,
return;
}
}
-
static void
bse_snet_remove_item (BseContainer *container,
BseItem *item)
{
BseSNet *self = BSE_SNET (container);
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_SOURCE))
{
SfiRing *node = sfi_ring_find (self->isources, item);
@@ -272,24 +235,20 @@ bse_snet_remove_item (BseContainer *container,
else if (BSE_SNET_USER_SYNTH (self))
g_warning ("BseSNet: cannot hold non-source item type `%s'",
BSE_OBJECT_TYPE_NAME (item));
-
/* chain parent class' remove_item handler */
BSE_CONTAINER_CLASS (parent_class)->remove_item (container, item);
}
-
static GSList*
snet_find_port_name (BseSNet *snet,
const gchar *name,
gboolean in_port)
{
GSList *slist;
-
for (slist = in_port ? snet->iport_names : snet->oport_names; slist; slist = slist->next)
if (strcmp (name, (const char*) slist->data) == 0)
return slist;
return NULL;
}
-
const gchar*
bse_snet_iport_name_register (BseSNet *snet,
const gchar *tmpl_name)
@@ -297,10 +256,8 @@ bse_snet_iport_name_register (BseSNet *snet,
GSList *slist;
gchar *name;
guint i;
-
g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
g_return_val_if_fail (tmpl_name != NULL, NULL);
-
slist = snet_find_port_name (snet, tmpl_name, TRUE);
name = NULL;
i = 1;
@@ -313,41 +270,31 @@ bse_snet_iport_name_register (BseSNet *snet,
if (!name)
name = g_strdup (tmpl_name);
snet->iport_names = g_slist_prepend (snet->iport_names, name);
-
return name;
}
-
gboolean
bse_snet_iport_name_registered (BseSNet *snet,
const gchar *name)
{
GSList *slist;
-
g_return_val_if_fail (BSE_IS_SNET (snet), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
-
slist = snet_find_port_name (snet, name, TRUE);
-
return slist != NULL;
}
-
void
bse_snet_iport_name_unregister (BseSNet *snet,
const gchar *name)
{
GSList *slist;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
-
slist = snet_find_port_name (snet, name, TRUE);
g_return_if_fail (slist != NULL);
-
g_free (slist->data);
snet->iport_names = g_slist_delete_link (snet->iport_names, slist);
bse_snet_queue_port_unregistered (snet);
}
-
const gchar*
bse_snet_oport_name_register (BseSNet *snet,
const gchar *tmpl_name)
@@ -355,10 +302,8 @@ bse_snet_oport_name_register (BseSNet *snet,
GSList *slist;
gchar *name;
guint i;
-
g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
g_return_val_if_fail (tmpl_name != NULL, NULL);
-
slist = snet_find_port_name (snet, tmpl_name, FALSE);
name = NULL;
i = 1;
@@ -371,41 +316,31 @@ bse_snet_oport_name_register (BseSNet *snet,
if (!name)
name = g_strdup (tmpl_name);
snet->oport_names = g_slist_prepend (snet->oport_names, name);
-
return name;
}
-
gboolean
bse_snet_oport_name_registered (BseSNet *snet,
const gchar *name)
{
GSList *slist;
-
g_return_val_if_fail (BSE_IS_SNET (snet), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
-
slist = snet_find_port_name (snet, name, FALSE);
-
return slist != NULL;
}
-
void
bse_snet_oport_name_unregister (BseSNet *snet,
const gchar *name)
{
GSList *slist;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
-
slist = snet_find_port_name (snet, name, FALSE);
g_return_if_fail (slist != NULL);
-
g_free (slist->data);
snet->oport_names = g_slist_delete_link (snet->oport_names, slist);
bse_snet_queue_port_unregistered (snet);
}
-
static gint
snet_ports_compare (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
@@ -413,16 +348,13 @@ snet_ports_compare (gconstpointer bsearch_node1, /* key */
const BseSNetPort *p1 = (const BseSNetPort*) bsearch_node1;
const BseSNetPort *p2 = (const BseSNetPort*) bsearch_node2;
gint cmp;
-
cmp = G_BSEARCH_ARRAY_CMP (p1->context, p2->context);
if (!cmp)
cmp = G_BSEARCH_ARRAY_CMP (p1->input, p2->input);
if (!cmp)
cmp = strcmp (p1->name, p2->name);
-
return cmp;
}
-
static BseSNetPort*
port_lookup (BseSNet *snet,
const gchar *name,
@@ -435,7 +367,6 @@ port_lookup (BseSNet *snet,
key.input = is_input != FALSE;
return (BseSNetPort*) g_bsearch_array_lookup (snet->port_array, &port_array_config, &key);
}
-
static BseSNetPort*
port_insert (BseSNet *snet,
const gchar *name,
@@ -446,10 +377,8 @@ port_insert (BseSNet *snet,
key.name = (gchar*) name;
key.context = snet_context;
key.input = is_input != FALSE;
-
port = (BseSNetPort*) g_bsearch_array_lookup (snet->port_array, &port_array_config, &key);
g_return_val_if_fail (port == NULL, port); /* shouldn't fail */
-
key.name = g_strdup (key.name);
key.src_omodule = NULL;
key.src_ostream = G_MAXUINT;
@@ -458,20 +387,16 @@ port_insert (BseSNet *snet,
snet->port_array = g_bsearch_array_insert (snet->port_array, &port_array_config, &key);
return (BseSNetPort*) g_bsearch_array_lookup (snet->port_array, &port_array_config, &key);
}
-
static void
port_delete (BseSNet *snet,
BseSNetPort *port)
{
guint index = g_bsearch_array_get_index (snet->port_array, &port_array_config, port);
-
g_return_if_fail (index < g_bsearch_array_get_n_nodes (snet->port_array));
g_return_if_fail (port->src_omodule == NULL && port->dest_imodule == NULL);
-
g_free (port->name);
g_bsearch_array_remove (snet->port_array, &port_array_config, index);
}
-
void
bse_snet_set_iport_src (BseSNet *snet,
const gchar *name,
@@ -481,14 +406,12 @@ bse_snet_set_iport_src (BseSNet *snet,
BseTrans *trans)
{
BseSNetPort *port;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
g_return_if_fail (bse_source_has_context (BSE_SOURCE (snet), snet_context));
if (omodule)
g_return_if_fail (ostream < BSE_MODULE_N_OSTREAMS (omodule));
g_return_if_fail (trans != NULL);
-
port = port_lookup (snet, name, snet_context, TRUE);
if (!port && !omodule)
return;
@@ -496,7 +419,6 @@ bse_snet_set_iport_src (BseSNet *snet,
port = port_insert (snet, name, snet_context, TRUE);
else if (!omodule)
ostream = G_MAXUINT;
-
if (port->src_omodule && port->dest_imodule)
bse_trans_add (trans, bse_job_disconnect (port->dest_imodule, port->dest_istream));
port->src_omodule = omodule;
@@ -507,7 +429,6 @@ bse_snet_set_iport_src (BseSNet *snet,
if (!port->dest_imodule && !port->src_omodule)
port_delete (snet, port);
}
-
void
bse_snet_set_iport_dest (BseSNet *snet,
const gchar *name,
@@ -517,14 +438,12 @@ bse_snet_set_iport_dest (BseSNet *snet,
BseTrans *trans)
{
BseSNetPort *port;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
g_return_if_fail (bse_source_has_context (BSE_SOURCE (snet), snet_context));
if (imodule)
g_return_if_fail (istream < BSE_MODULE_N_ISTREAMS (imodule));
g_return_if_fail (trans != NULL);
-
port = port_lookup (snet, name, snet_context, TRUE);
if (!port && !imodule)
return;
@@ -532,7 +451,6 @@ bse_snet_set_iport_dest (BseSNet *snet,
port = port_insert (snet, name, snet_context, TRUE);
else if (!imodule)
istream = G_MAXUINT;
-
if (port->src_omodule && port->dest_imodule)
bse_trans_add (trans, bse_job_disconnect (port->dest_imodule, port->dest_istream));
port->dest_imodule = imodule;
@@ -543,7 +461,6 @@ bse_snet_set_iport_dest (BseSNet *snet,
if (!port->dest_imodule && !port->src_omodule)
port_delete (snet, port);
}
-
void
bse_snet_set_oport_src (BseSNet *snet,
const gchar *name,
@@ -553,14 +470,12 @@ bse_snet_set_oport_src (BseSNet *snet,
BseTrans *trans)
{
BseSNetPort *port;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
g_return_if_fail (bse_source_has_context (BSE_SOURCE (snet), snet_context));
if (omodule)
g_return_if_fail (ostream < BSE_MODULE_N_OSTREAMS (omodule));
g_return_if_fail (trans != NULL);
-
port = port_lookup (snet, name, snet_context, FALSE);
if (!port && !omodule)
return;
@@ -568,7 +483,6 @@ bse_snet_set_oport_src (BseSNet *snet,
port = port_insert (snet, name, snet_context, FALSE);
else if (!omodule)
ostream = G_MAXUINT;
-
if (port->src_omodule && port->dest_imodule)
bse_trans_add (trans, bse_job_disconnect (port->dest_imodule, port->dest_istream));
port->src_omodule = omodule;
@@ -579,7 +493,6 @@ bse_snet_set_oport_src (BseSNet *snet,
if (!port->dest_imodule && !port->src_omodule)
port_delete (snet, port);
}
-
void
bse_snet_set_oport_dest (BseSNet *snet,
const gchar *name,
@@ -589,14 +502,12 @@ bse_snet_set_oport_dest (BseSNet *snet,
BseTrans *trans)
{
BseSNetPort *port;
-
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (name != NULL);
g_return_if_fail (bse_source_has_context (BSE_SOURCE (snet), snet_context));
if (imodule)
g_return_if_fail (istream < BSE_MODULE_N_ISTREAMS (imodule));
g_return_if_fail (trans != NULL);
-
port = port_lookup (snet, name, snet_context, FALSE);
if (!port && !imodule)
return;
@@ -604,7 +515,6 @@ bse_snet_set_oport_dest (BseSNet *snet,
port = port_insert (snet, name, snet_context, FALSE);
else if (!imodule)
istream = G_MAXUINT;
-
if (port->src_omodule && port->dest_imodule)
bse_trans_add (trans, bse_job_disconnect (port->dest_imodule, port->dest_istream));
port->dest_imodule = imodule;
@@ -615,14 +525,12 @@ bse_snet_set_oport_dest (BseSNet *snet,
if (!port->dest_imodule && !port->src_omodule)
port_delete (snet, port);
}
-
static inline ContextData*
find_context_data (BseSNet *self,
guint context_id)
{
return (ContextData*) bse_source_get_context_data (BSE_SOURCE (self), context_id);
}
-
static ContextData*
create_context_data (BseSNet *self,
guint context_id,
@@ -631,7 +539,6 @@ create_context_data (BseSNet *self,
guint midi_channel)
{
ContextData *cdata = g_new0 (ContextData, 1);
-
cdata->context_id = context_id;
cdata->midi_receiver = bse_midi_receiver_ref (midi_receiver);
cdata->midi_channel = midi_channel;
@@ -641,7 +548,6 @@ create_context_data (BseSNet *self,
{
ContextData *pdata = find_context_data (self, parent_context);
guint i;
-
i = pdata->n_branches++;
pdata->branches = g_renew (guint, pdata->branches, pdata->n_branches);
pdata->branches[i] = context_id;
@@ -649,10 +555,8 @@ create_context_data (BseSNet *self,
}
else
cdata->parent_context = 0;
-
return cdata;
}
-
static void
free_context_data (BseSource *source,
gpointer data,
@@ -660,18 +564,14 @@ free_context_data (BseSource *source,
{
BseSNet *self = BSE_SNET (source);
ContextData *cdata = (ContextData*) data;
-
g_return_if_fail (cdata->n_branches == 0);
-
bse_midi_receiver_unref (cdata->midi_receiver);
bse_id_free (cdata->context_id);
if (cdata->parent_context)
{
ContextData *pdata = find_context_data (self, cdata->parent_context);
guint i, swap_context;
-
g_return_if_fail (pdata->n_branches > 0);
-
pdata->n_branches--;
swap_context = pdata->branches[pdata->n_branches];
for (i = 0; i < pdata->n_branches; i++)
@@ -684,7 +584,6 @@ free_context_data (BseSource *source,
g_free (cdata->branches);
g_free (cdata);
}
-
guint
bse_snet_create_context (BseSNet *self,
BseMidiContext mcontext,
@@ -692,21 +591,16 @@ bse_snet_create_context (BseSNet *self,
{
ContextData *cdata;
guint cid;
-
g_return_val_if_fail (BSE_IS_SNET (self), 0);
g_return_val_if_fail (BSE_SOURCE_PREPARED (self), 0);
g_return_val_if_fail (mcontext.midi_receiver != NULL, 0);
g_return_val_if_fail (trans != NULL, 0);
-
cid = bse_id_alloc ();
g_return_val_if_fail (bse_source_has_context (BSE_SOURCE (self), cid) == FALSE, 0);
-
cdata = create_context_data (self, cid, 0, mcontext.midi_receiver, mcontext.midi_channel);
bse_source_create_context_with_data (BSE_SOURCE (self), cid, cdata, free_context_data, trans);
-
return cid;
}
-
guint
bse_snet_context_clone_branch (BseSNet *self,
guint context,
@@ -716,7 +610,6 @@ bse_snet_context_clone_branch (BseSNet *self,
{
SfiRing *ring;
guint bcid = 0;
-
g_return_val_if_fail (BSE_IS_SNET (self), 0);
g_return_val_if_fail (BSE_SOURCE_PREPARED (self), 0);
g_return_val_if_fail (bse_source_has_context (BSE_SOURCE (self), context), 0);
@@ -725,13 +618,11 @@ bse_snet_context_clone_branch (BseSNet *self,
g_return_val_if_fail (BSE_ITEM (context_merger)->parent == BSE_ITEM (self), 0);
g_return_val_if_fail (mcontext.midi_receiver != NULL, 0);
g_return_val_if_fail (trans != NULL, 0);
-
ring = bse_source_collect_inputs_recursive (context_merger);
if (!BSE_SOURCE_COLLECTED (context_merger))
{
ContextData *cdata;
SfiRing *node;
-
g_assert (self->tmp_context_children == NULL);
for (node = ring; node; node = sfi_ring_walk (node, ring))
self->tmp_context_children = g_slist_prepend (self->tmp_context_children, node->data);
@@ -747,31 +638,24 @@ bse_snet_context_clone_branch (BseSNet *self,
g_warning ("%s: context merger forms a cycle with it's inputs", G_STRLOC);
bse_source_free_collection (ring);
}
-
-
return bcid;
}
-
gboolean
bse_snet_context_is_branch (BseSNet *self,
guint context_id)
{
ContextData *cdata;
-
g_return_val_if_fail (BSE_IS_SNET (self), FALSE);
g_return_val_if_fail (BSE_SOURCE_PREPARED (self), FALSE);
g_return_val_if_fail (context_id > 0, FALSE);
-
cdata = find_context_data (self, context_id);
return cdata ? cdata->parent_context > 0 : FALSE;
}
-
static GSList*
snet_context_children (BseContainer *container)
{
BseSNet *self = BSE_SNET (container);
GSList *slist;
-
if (self->tmp_context_children)
{
slist = self->tmp_context_children;
@@ -779,19 +663,15 @@ snet_context_children (BseContainer *container)
}
else
slist = BSE_CONTAINER_CLASS (parent_class)->context_children (container);
-
return slist;
}
-
BseMidiContext
bse_snet_get_midi_context (BseSNet *self,
guint context_handle)
{
BseMidiContext mcontext = { 0, };
ContextData *cdata;
-
g_return_val_if_fail (BSE_IS_SNET (self), mcontext);
-
cdata = find_context_data (self, context_handle);
if (cdata)
{
@@ -800,59 +680,45 @@ bse_snet_get_midi_context (BseSNet *self,
}
return mcontext;
}
-
static void
bse_snet_prepare (BseSource *source)
{
BseSNet *snet = BSE_SNET (source);
-
g_return_if_fail (snet->port_array == NULL);
-
bse_object_lock (BSE_OBJECT (snet));
snet->port_array = g_bsearch_array_create (&port_array_config);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static void
bse_snet_reset (BseSource *source)
{
BseSNet *self = BSE_SNET (source);
-
g_return_if_fail (self->port_array != NULL);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
-
if (g_bsearch_array_get_n_nodes (self->port_array))
{
BseSNetPort *port = (BseSNetPort*) g_bsearch_array_get_nth (self->port_array, &port_array_config, 0);
-
g_warning ("%s: %cport \"%s\" still active: context=%u src=%p dest=%p",
G_STRLOC, port->input ? 'i' : 'o', port->name,
port->context, port->src_omodule, port->dest_imodule);
}
g_bsearch_array_free (self->port_array, &port_array_config);
self->port_array = NULL;
-
bse_object_unlock (BSE_OBJECT (self));
}
-
static void
bse_snet_context_create (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSNet *self = BSE_SNET (source);
-
if (self->tmp_context_children)
{
BseContextMerger *context_merger = (BseContextMerger*) self->tmp_context_children->data;
ContextData *cdata = find_context_data (self, context_handle);
-
g_assert (BSE_IS_CONTEXT_MERGER (context_merger));
-
bse_context_merger_set_merge_context (context_merger, cdata->parent_context);
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
@@ -864,7 +730,6 @@ bse_snet_context_create (BseSource *source,
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
}
-
static void
bse_snet_context_connect (BseSource *source,
guint context_handle,
@@ -873,14 +738,11 @@ bse_snet_context_connect (BseSource *source,
BseSNet *self = BSE_SNET (source);
ContextData *cdata = find_context_data (self, context_handle);
guint i;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
-
for (i = 0; i < cdata->n_branches; i++)
bse_source_connect_context (source, cdata->branches[i], trans);
}
-
static void
bse_snet_context_dismiss (BseSource *source,
guint context_handle,
@@ -888,14 +750,11 @@ bse_snet_context_dismiss (BseSource *source,
{
BseSNet *self = BSE_SNET (source);
ContextData *cdata = find_context_data (self, context_handle);
-
while (cdata->n_branches)
bse_source_dismiss_context (source, cdata->branches[cdata->n_branches - 1], trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
static void
bse_snet_class_init (BseSNetClass *klass)
{
@@ -903,26 +762,21 @@ bse_snet_class_init (BseSNetClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_snet_set_property;
gobject_class->get_property = bse_snet_get_property;
gobject_class->dispose = bse_snet_dispose;
gobject_class->finalize = bse_snet_finalize;
-
source_class->prepare = bse_snet_prepare;
source_class->context_create = bse_snet_context_create;
source_class->context_connect = bse_snet_context_connect;
source_class->context_dismiss = bse_snet_context_dismiss;
source_class->reset = bse_snet_reset;
-
container_class->add_item = bse_snet_add_item;
container_class->remove_item = bse_snet_remove_item;
container_class->forall_items = bse_snet_forall_items;
container_class->context_children = snet_context_children;
container_class->release_children = bse_snet_release_children;
-
bse_object_class_add_param (object_class, "Playback Settings",
PARAM_AUTO_ACTIVATE,
sfi_pspec_bool ("auto_activate", "Auto Activate",
@@ -932,7 +786,6 @@ bse_snet_class_init (BseSNetClass *klass)
signal_port_unregistered = bse_object_class_add_signal (object_class, "port_unregistered",
G_TYPE_NONE, 0);
}
-
BSE_BUILTIN_TYPE (BseSNet)
{
static const GTypeInfo type_info = {
diff --git a/bse/bsesnet.hh b/bse/bsesnet.hh
index b10246e..deb5a3f 100644
--- a/bse/bsesnet.hh
+++ b/bse/bsesnet.hh
@@ -1,14 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SNET_H__
#define __BSE_SNET_H__
-
#include <bse/bsesuper.hh>
#include <bse/bseglobals.hh> /* FIXME */
-
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_SNET (BSE_TYPE_ID (BseSNet))
#define BSE_SNET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SNET, BseSNet))
@@ -17,16 +12,12 @@ G_BEGIN_DECLS
#define BSE_IS_SNET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SNET))
#define BSE_SNET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SNET, BseSNetClass))
#define BSE_SNET_USER_SYNTH(src) ((BSE_OBJECT_FLAGS (src) & BSE_SNET_FLAG_USER_SYNTH) != 0)
-
-
/* --- BseSNet flags --- */
typedef enum /*< skip >*/
{
BSE_SNET_FLAG_USER_SYNTH = 1 << (BSE_SUPER_FLAGS_USHIFT + 0)
} BseSNetFlags;
#define BSE_SNET_FLAGS_USHIFT (BSE_SUPER_FLAGS_USHIFT + 1)
-
-
/* --- BseSNet object --- */
typedef struct
{
@@ -41,15 +32,12 @@ typedef struct
struct _BseSNet
{
BseSuper parent_object;
-
SfiRing *sources; /* of type BseSource* */
SfiRing *isources; /* internal (protected) sources */
GSList *iport_names;
GSList *oport_names;
GBSearchArray *port_array; /* of type BseSNetPort* */
-
GSList *tmp_context_children;
-
guint port_unregistered_id;
};
struct _BseSNetClass
@@ -61,8 +49,6 @@ struct _BseMidiContext {
guint midi_channel;
guint voice_id;
};
-
-
/* --- prototypes --- */
guint bse_snet_create_context (BseSNet *snet,
BseMidiContext mcontext,
@@ -114,8 +100,5 @@ void bse_snet_set_oport_dest (BseSNet *snet,
BseModule *imodule,
guint istream,
BseTrans *trans);
-
-
G_END_DECLS
-
#endif /* __BSE_SNET_H__ */
diff --git a/bse/bsesnet.proc b/bse/bsesnet.proc
index 3973c7a..16c65a7 100644
--- a/bse/bsesnet.proc
+++ b/bse/bsesnet.proc
@@ -3,12 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bsesnet.hh>
#include <bse/bsemain.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseSNet, supports-user-synths) {
HELP = "Check whether users may edit synthesis modules of this network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
@@ -21,17 +17,13 @@ METHOD (BseSNet, supports-user-synths) {
{
/* extract parameter values */
BseSNet *snet = (BseSNet*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SNET (snet))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, BSE_SNET_USER_SYNTH (snet));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSNet, can-create-source) {
HELP = "Check whether inserting a new module into a synthesis network is possible";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
@@ -50,24 +42,19 @@ METHOD (BseSNet, can-create-source) {
const gchar *type_name = sfi_value_get_string (in_values++);
GType type = g_type_from_name (type_name);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SNET (snet))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (!BSE_SNET_USER_SYNTH (snet) && !BSE_DBG_EXT)
error = BSE_ERROR_NOT_OWNER;
else if (!g_type_is_a (type, BSE_TYPE_SOURCE) ||
g_type_is_a (type, BSE_TYPE_CONTAINER))
error = BSE_ERROR_SOURCE_TYPE_INVALID;
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSNet, create-source) {
HELP = "Insert a new module into a synthesis network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
@@ -86,26 +73,21 @@ METHOD (BseSNet, create-source) {
BseItem *child;
BseUndoStack *ustack;
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_SNET (container))
return BSE_ERROR_PROC_PARAM_INVAL;
if (bse_item_exec (container, "can-create-source", type_name, &error) != 0 ||
error != 0)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (container, "create-source");
child = (BseItem*) bse_container_new_child (container, g_type_from_name (type_name), NULL);
bse_item_push_undo_proc (container, "remove-source", child);
bse_item_undo_close (ustack);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSNet, remove-source) {
HELP = "Remove an existing module from its synthesis network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
@@ -124,12 +106,10 @@ METHOD (BseSNet, remove-source) {
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_SNET (self) || !BSE_IS_SOURCE (child) || child->parent != (BseItem*) self ||
(!BSE_SNET_USER_SYNTH (self) && !BSE_DBG_EXT))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "remove-child %s", bse_object_debug_name (child));
/* remove object references */
@@ -140,9 +120,7 @@ METHOD (BseSNet, remove-source) {
bse_container_remove_backedup (BSE_CONTAINER (self), child, ustack);
/* done */
bse_item_undo_close (ustack);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsesnooper.cc b/bse/bsesnooper.cc
index 2623fc0..20c8665 100644
--- a/bse/bsesnooper.cc
+++ b/bse/bsesnooper.cc
@@ -1,17 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesnooper.hh"
-
#include <bse/bseengine.hh>
#include <bse/bseieee754.hh>
#include <bse/bsecategories.hh>
-
-
enum {
PARAM_0,
PARAM_CONTEXT_ID
};
-
-
/* --- prototypes --- */
static void bse_snooper_init (BseSnooper *snooper);
static void bse_snooper_class_init (BseSnooperClass *klass);
@@ -28,41 +23,32 @@ static gboolean bse_snooper_needs_storage (BseItem *item,
static void bse_snooper_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseSnooper)
{
static const GTypeInfo type_info = {
sizeof (BseSnooperClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_snooper_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSnooper),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_snooper_init,
};
#include "./icons/snooper.c"
GType type_id;
-
type_id = bse_type_register_static (BSE_TYPE_SOURCE,
"BseSnooper",
"The Snooper module prints statistics about the incoming signal",
__FILE__, __LINE__,
&type_info);
bse_categories_register_stock_module (N_("/Misc/Snooper"), type_id, snooper_pixstream);
-
return type_id;
}
-
static void
bse_snooper_class_init (BseSnooperClass *klass)
{
@@ -71,16 +57,11 @@ bse_snooper_class_init (BseSnooperClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ichannel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_snooper_set_property;
gobject_class->get_property = bse_snooper_get_property;
-
item_class->needs_storage = bse_snooper_needs_storage;
-
source_class->context_create = bse_snooper_context_create;
-
bse_object_class_add_param (object_class, "Context",
PARAM_CONTEXT_ID,
sfi_pspec_int ("context_id", "Context",
@@ -88,17 +69,14 @@ bse_snooper_class_init (BseSnooperClass *klass)
"the context id, which is used to actually snoop data.",
0, 0, 65535, 1,
SFI_PARAM_STANDARD));
-
ichannel = bse_source_class_add_ichannel (source_class, "signal-in", _("Signal In"), _("Snoop Signal"));
g_assert (ichannel == BSE_SNOOPER_ICHANNEL_MONO);
}
-
static void
bse_snooper_init (BseSnooper *snooper)
{
snooper->active_context_id = 0;
}
-
static void
bse_snooper_set_property (GObject *object,
guint param_id,
@@ -116,7 +94,6 @@ bse_snooper_set_property (GObject *object,
break;
}
}
-
static void
bse_snooper_get_property (GObject *object,
guint param_id,
@@ -134,7 +111,6 @@ bse_snooper_get_property (GObject *object,
break;
}
}
-
static gboolean
bse_snooper_needs_storage (BseItem *item,
BseStorage *storage)
@@ -142,26 +118,22 @@ bse_snooper_needs_storage (BseItem *item,
// BseSnooper *self = BSE_SNOOPER (item);
return FALSE;
}
-
typedef struct {
guint context_id;
volatile guint *active_context_id;
} SnoopData;
-
static void
snooper_process (BseModule *module,
guint n_values)
{
const gfloat *wave_in = BSE_MODULE_IBUFFER (module, 0);
SnoopData *data = (SnoopData*) module->user_data;
-
if (data->context_id == *data->active_context_id &&
module->istreams[0].connected)
{
gfloat min = wave_in[0], max = wave_in[0];
gfloat avg = wave_in[0], first = wave_in[0], last = wave_in[n_values - 1];
gboolean seen_nan = FALSE, seen_pinf = FALSE, seen_ninf = FALSE, seen_subn = FALSE;
-
for (uint i = 1; i < n_values; i++)
{
float v = wave_in[i];
@@ -191,7 +163,6 @@ snooper_process (BseModule *module,
seen_subn ? " +SUBNORM" : "");
}
}
-
static void
bse_snooper_context_create (BseSource *source,
guint context_handle,
@@ -210,18 +181,14 @@ bse_snooper_context_create (BseSource *source,
BseSnooper *snooper = BSE_SNOOPER (source);
SnoopData *data = g_new0 (SnoopData, 1);
BseModule *module;
-
data->context_id = context_handle;
data->active_context_id = &snooper->active_context_id;
module = bse_module_new (&snooper_class, data);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
bse_trans_add (trans, bse_job_set_consumer (module, TRUE));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/bse/bsesnooper.hh b/bse/bsesnooper.hh
index 68c5bbd..b2737b9 100644
--- a/bse/bsesnooper.hh
+++ b/bse/bsesnooper.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SNOOPER_H__
#define __BSE_SNOOPER_H__
-
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SNOOPER (BSE_TYPE_ID (BseSnooper))
#define BSE_SNOOPER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SNOOPER, BseSnooper))
@@ -13,27 +10,19 @@ G_BEGIN_DECLS
#define BSE_IS_SNOOPER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SNOOPER))
#define BSE_IS_SNOOPER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SNOOPER))
#define BSE_SNOOPER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SNOOPER, BseSnooperClass))
-
-
/* --- BseSnooper source --- */
typedef struct _BseSnooper BseSnooper;
typedef struct _BseSourceClass BseSnooperClass;
struct _BseSnooper
{
BseSource parent_object;
-
volatile guint active_context_id;
};
-
-
/* --- channels --- */
enum
{
BSE_SNOOPER_ICHANNEL_MONO,
BSE_SNOOPER_N_ICHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_SNOOPER_H__ */
diff --git a/bse/bsesong.cc b/bse/bsesong.cc
index 1cbc52b..d10f9ae 100644
--- a/bse/bsesong.cc
+++ b/bse/bsesong.cc
@@ -15,8 +15,6 @@
#include "bseengine.hh" // FIXME: for bse_engine_sample_freq()
#include "bsecxxplugin.hh"
#include <string.h>
-
-
enum
{
PROP_0,
@@ -32,48 +30,37 @@ enum
PROP_LOOP_RIGHT,
PROP_TICK_POINTER,
};
-
-
/* --- prototypes --- */
static void bse_song_update_tpsi_SL (BseSong *song);
static void bse_song_class_init (BseSongClass *klass);
static void bse_song_init (BseSong *song);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_pointer_changed = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseSong)
{
static const GTypeInfo song_info = {
sizeof (BseSongClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_song_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSong),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_song_init,
};
-
return bse_type_register_static (BSE_TYPE_SNET,
"BseSong",
"BSE Song type",
__FILE__, __LINE__,
&song_info);
}
-
void
bse_song_timing_get_default (BseSongTiming *timing)
{
g_return_if_fail (timing != NULL);
-
timing->tick = 0;
timing->bpm = 120;
timing->numerator = 4;
@@ -82,37 +69,30 @@ bse_song_timing_get_default (BseSongTiming *timing)
timing->tpt = timing->tpqn * 4 * timing->numerator / timing->denominator;
timing->stamp_ticks = 0;
}
-
static void
bse_song_release_children (BseContainer *container)
{
BseSong *self = BSE_SONG (container);
-
while (self->busses)
bse_container_remove_item (container, (BseItem*) self->busses->data);
while (self->parts)
bse_container_remove_item (container, (BseItem*) self->parts->data);
while (self->tracks_SL)
bse_container_remove_item (container, (BseItem*) self->tracks_SL->data);
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
static void
bse_song_finalize (GObject *object)
{
BseSong *self = BSE_SONG (object);
-
bse_container_remove_item (BSE_CONTAINER (self), BSE_ITEM (self->postprocess));
self->postprocess = NULL;
bse_container_remove_item (BSE_CONTAINER (self), BSE_ITEM (self->output));
self->output = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_song_get_candidates (BseItem *item,
guint param_id,
@@ -131,7 +111,6 @@ bse_song_get_candidates (BseItem *item,
break;
}
}
-
static void
song_uncross_pnet (BseItem *owner,
BseItem *ref_item)
@@ -139,7 +118,6 @@ song_uncross_pnet (BseItem *owner,
BseSong *self = BSE_SONG (owner);
bse_item_set (self, "pnet", NULL, NULL);
}
-
static void
bse_song_set_property (GObject *object,
guint param_id,
@@ -258,7 +236,6 @@ bse_song_set_property (GObject *object,
break;
}
}
-
static void
bse_song_get_property (GObject *object,
guint param_id,
@@ -303,7 +280,6 @@ bse_song_get_property (GObject *object,
break;
}
}
-
void
bse_song_get_timing (BseSong *self,
guint tick,
@@ -311,7 +287,6 @@ bse_song_get_timing (BseSong *self,
{
g_return_if_fail (BSE_IS_SONG (self));
g_return_if_fail (timing != NULL);
-
timing->tick = 0;
timing->bpm = self->bpm;
timing->numerator = self->numerator;
@@ -323,51 +298,40 @@ bse_song_get_timing (BseSong *self,
else /* see update_tpsi */
timing->stamp_ticks = timing->tpqn * timing->bpm / (60.0 * bse_engine_sample_freq());
}
-
BseSong*
bse_song_lookup (BseProject *project,
const gchar *name)
{
BseItem *item;
-
g_return_val_if_fail (BSE_IS_PROJECT (project), NULL);
g_return_val_if_fail (name != NULL, NULL);
-
item = bse_container_lookup_item (BSE_CONTAINER (project), name);
-
return BSE_IS_SONG (item) ? BSE_SONG (item) : NULL;
}
-
static void
bse_song_set_parent (BseItem *item,
BseItem *parent)
{
BseSong *self = BSE_SONG (item);
-
if (self->midi_receiver_SL)
{
bse_midi_receiver_unref (self->midi_receiver_SL);
self->midi_receiver_SL = NULL;
}
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
-
if (parent)
{
BseProject *project = BSE_PROJECT (parent);
self->midi_receiver_SL = bse_midi_receiver_ref (project->midi_receiver);
}
}
-
static void
bse_song_add_item (BseContainer *container,
BseItem *item)
{
BseSong *self = BSE_SONG (container);
-
BSE_SEQUENCER_LOCK ();
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_TRACK))
self->tracks_SL = sfi_ring_append (self->tracks_SL, item);
else if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_PART))
@@ -376,12 +340,9 @@ bse_song_add_item (BseContainer *container,
self->busses = sfi_ring_append (self->busses, item);
else
/* parent class manages other BseSources */ ;
-
/* chain parent class' add_item handler */
BSE_CONTAINER_CLASS (parent_class)->add_item (container, item);
-
BSE_SEQUENCER_UNLOCK ();
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_TRACK))
bse_track_add_modules (BSE_TRACK (item), container, self->midi_receiver_SL);
else if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_BUS))
@@ -390,7 +351,6 @@ bse_song_add_item (BseContainer *container,
bse_bus_create_stack (bus);
}
}
-
static void
bse_song_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -398,7 +358,6 @@ bse_song_forall_items (BseContainer *container,
{
BseSong *self = BSE_SONG (container);
SfiRing *ring;
-
/* iterate over non-source children */
ring = self->parts;
while (ring)
@@ -408,17 +367,14 @@ bse_song_forall_items (BseContainer *container,
if (!func (item, data))
return;
}
-
/* parent class iterates over BseSources children */
BSE_CONTAINER_CLASS (parent_class)->forall_items (container, func, data);
}
-
static void
bse_song_remove_item (BseContainer *container,
BseItem *item)
{
BseSong *self = BSE_SONG (container);
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_TRACK))
{
SfiRing *ring, *tmp;
@@ -448,16 +404,13 @@ bse_song_remove_item (BseContainer *container,
}
else
/* parent class manages BseSources */;
-
/* chain parent class' remove_item handler */
BSE_CONTAINER_CLASS (parent_class)->remove_item (container, item);
}
-
static gboolean
song_position_handler (gpointer data)
{
BseSong *self = BSE_SONG (data);
-
if (uint (self->last_position) != self->tick_SL)
{
BSE_SEQUENCER_LOCK ();
@@ -467,7 +420,6 @@ song_position_handler (gpointer data)
}
return TRUE;
}
-
static void
bse_song_update_tpsi_SL (BseSong *self)
{
@@ -480,24 +432,18 @@ bse_song_update_tpsi_SL (BseSong *self)
self->tpsi_SL = tpsi;
BSE_SEQUENCER_UNLOCK ();
}
-
static void
bse_song_prepare (BseSource *source)
{
BseSong *self = BSE_SONG (source);
-
bse_object_lock (BSE_OBJECT (self));
self->sequencer_underrun_detected_SL = FALSE;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
-
bse_song_update_tpsi_SL (self);
-
if (!self->position_handler)
self->position_handler = bse_idle_timed (50000, song_position_handler, self);
}
-
static void
bse_song_context_create (BseSource *source,
guint context_handle,
@@ -507,41 +453,31 @@ bse_song_context_create (BseSource *source,
BseSNet *snet = BSE_SNET (self);
BseMidiContext mcontext = bse_snet_get_midi_context (snet, context_handle);
SfiRing *ring;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
if (!bse_snet_context_is_branch (snet, context_handle)) /* catch recursion */
for (ring = self->tracks_SL; ring; ring = sfi_ring_walk (ring, self->tracks_SL))
bse_track_clone_voices ((BseTrack*) ring->data, snet, context_handle, mcontext, trans);
}
-
static void
bse_song_reset (BseSource *source)
{
BseSong *self = BSE_SONG (source);
-
bse_sequencer_remove_song (self),
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
-
g_assert (self->sequencer_start_request_SL == 0);
/* outside of sequencer reach, so no locks needed */
self->sequencer_start_SL = 0;
self->sequencer_done_SL = 0;
-
if (self->position_handler)
{
bse_idle_remove (self->position_handler);
self->position_handler = 0;
}
-
bse_object_unlock (BSE_OBJECT (self));
-
g_object_notify ((GObject*) self, "tick-pointer");
}
-
BseSource*
bse_song_create_summation (BseSong *self)
{
@@ -553,7 +489,6 @@ bse_song_create_summation (BseSong *self)
bse_snet_intern_child (BSE_SNET (self), summation);
return summation;
}
-
BseBus*
bse_song_find_master (BseSong *self)
{
@@ -565,7 +500,6 @@ bse_song_find_master (BseSong *self)
return BSE_BUS (osource);
return NULL;
}
-
void
bse_song_set_solo_bus (BseSong *self,
BseBus *bus)
@@ -578,61 +512,47 @@ bse_song_set_solo_bus (BseSong *self,
for (ring = self->busses; ring; ring = sfi_ring_walk (ring, self->busses))
bse_bus_change_solo ((BseBus*) ring->data, self->solo_bus && ring->data != self->solo_bus && ring->data != master);
}
-
static void
bse_song_init (BseSong *self)
{
BseSNet *snet = BSE_SNET (self);
BseSongTiming timing;
-
bse_song_timing_get_default (&timing);
-
BSE_OBJECT_UNSET_FLAGS (self, BSE_SNET_FLAG_USER_SYNTH);
BSE_OBJECT_SET_FLAGS (self, BSE_SUPER_FLAG_NEEDS_CONTEXT);
-
self->musical_tuning = BSE_MUSICAL_TUNING_12_TET;
-
self->tpqn = timing.tpqn;
self->numerator = timing.numerator;
self->denominator = timing.denominator;
self->bpm = timing.bpm;
-
self->parts = NULL;
self->busses = NULL;
-
self->pnet = NULL;
-
self->last_position = -1;
self->position_handler = 0;
-
self->tracks_SL = NULL;
self->loop_enabled_SL = 0;
self->loop_left_SL = -1;
self->loop_right_SL = -1;
-
/* post processing slot */
self->postprocess = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_SUB_SYNTH, "uname", "Postprocess", NULL);
bse_snet_intern_child (snet, self->postprocess);
bse_sub_synth_set_null_shortcut (BSE_SUB_SYNTH (self->postprocess), TRUE);
-
/* output */
self->output = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_PCM_OUTPUT, NULL);
bse_snet_intern_child (snet, self->output);
-
/* postprocess <-> output */
bse_source_must_set_input (self->output, BSE_PCM_OUTPUT_ICHANNEL_LEFT,
self->postprocess, 0);
bse_source_must_set_input (self->output, BSE_PCM_OUTPUT_ICHANNEL_RIGHT,
self->postprocess, 1);
}
-
static const gchar*
master_bus_name (void)
{
/* TRANSLATORS: this is the name of the master mixer bus. i.e. the final audio output bus. */
return _("Master");
}
-
BseSource*
bse_song_ensure_master (BseSong *self)
{
@@ -647,7 +567,6 @@ bse_song_ensure_master (BseSong *self)
}
return child;
}
-
static void
bse_song_compat_finish (BseSuper *super,
guint vmajor,
@@ -655,10 +574,8 @@ bse_song_compat_finish (BseSuper *super,
guint vmicro)
{
BseSong *self = BSE_SONG (super);
-
/* chain parent class' handler */
BSE_SUPER_CLASS (parent_class)->compat_finish (super, vmajor, vminor, vmicro);
-
/* fixup old non-mixer songs */
if (BSE_VERSION_CMP (vmajor, vminor, vmicro, 0, 6, 2) <= 0)
{
@@ -693,7 +610,6 @@ bse_song_compat_finish (BseSuper *super,
}
}
}
-
static void
bse_song_class_init (BseSongClass *klass)
{
@@ -704,29 +620,21 @@ bse_song_class_init (BseSongClass *klass)
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
BseSuperClass *super_class = BSE_SUPER_CLASS (klass);
BseSongTiming timing;
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_song_set_property;
gobject_class->get_property = bse_song_get_property;
gobject_class->finalize = bse_song_finalize;
-
item_class->set_parent = bse_song_set_parent;
item_class->get_candidates = bse_song_get_candidates;
-
source_class->prepare = bse_song_prepare;
source_class->context_create = bse_song_context_create;
source_class->reset = bse_song_reset;
-
container_class->add_item = bse_song_add_item;
container_class->remove_item = bse_song_remove_item;
container_class->forall_items = bse_song_forall_items;
container_class->release_children = bse_song_release_children;
-
super_class->compat_finish = bse_song_compat_finish;
-
bse_song_timing_get_default (&timing);
-
bse_object_class_add_param (object_class, _("Tuning"),
PROP_MUSICAL_TUNING,
bse_param_spec_enum ("musical_tuning", _("Musical Tuning"),
@@ -736,7 +644,6 @@ bse_song_class_init (BseSongClass *klass)
"tuning system defines the number and spacing of frequency values applied."),
BSE_MUSICAL_TUNING_12_TET, BSE_TYPE_MUSICAL_TUNING_TYPE,
SFI_PARAM_STANDARD ":unprepared:skip-default"));
-
bse_object_class_add_param (object_class, _("Timing"),
PROP_TPQN,
sfi_pspec_int ("tpqn", _("Ticks"), _("Number of ticks per quarter note"),
@@ -784,7 +691,6 @@ bse_song_class_init (BseSongClass *klass)
sfi_pspec_int ("tick_pointer", NULL, NULL,
-1, -1, G_MAXINT, 384,
SFI_PARAM_READWRITE ":skip-undo"));
-
signal_pointer_changed = bse_object_class_add_signal (object_class, "pointer-changed",
G_TYPE_NONE, 1, SFI_TYPE_INT);
}
diff --git a/bse/bsesong.hh b/bse/bsesong.hh
index 39c7db6..eb1d83b 100644
--- a/bse/bsesong.hh
+++ b/bse/bsesong.hh
@@ -1,13 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SONG_H__
#define __BSE_SONG_H__
-
#include <bse/bsesnet.hh>
-
-
G_BEGIN_DECLS
-
-
/* --- BSE type macros --- */
#define BSE_TYPE_SONG (BSE_TYPE_ID (BseSong))
#define BSE_SONG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SONG, BseSong))
@@ -15,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_SONG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SONG))
#define BSE_IS_SONG_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SONG))
#define BSE_SONG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SONG, BseSongClass))
-
-
/* --- BseSong object --- */
typedef struct {
BseSource *constant;
@@ -25,29 +18,21 @@ typedef struct {
struct _BseSong
{
BseSNet parent_instance;
-
guint tpqn; /* ticks per querter note */
guint numerator;
guint denominator;
gfloat bpm;
-
BseMusicalTuningType musical_tuning;
-
SfiRing *parts; /* of type BsePart* */
SfiRing *busses; /* of type BseBus* */
BseBus *solo_bus;
-
BseSource *postprocess;
BseSource *output;
-
BseSNet *pnet;
-
/* song position pointer */
SfiInt last_position;
guint position_handler;
-
BseMidiReceiver *midi_receiver_SL;
-
/* fields protected by sequencer mutex */
gdouble tpsi_SL; /* ticks per stamp increment (sample) */
SfiRing *tracks_SL; /* of type BseTrack* */
@@ -67,8 +52,6 @@ struct _BseSongClass
{
BseSNetClass parent_class;
};
-
-
/* --- prototypes --- */
BseSong* bse_song_lookup (BseProject *project,
const gchar *name);
@@ -82,7 +65,5 @@ BseBus* bse_song_find_master (BseSong *self);
BseSource* bse_song_ensure_master (BseSong *self);
void bse_song_set_solo_bus (BseSong *self,
BseBus *bus);
-
G_END_DECLS
-
#endif /* __BSE_SONG_H__ */
diff --git a/bse/bsesong.proc b/bse/bsesong.proc
index 7b64b56..16da96b 100644
--- a/bse/bsesong.proc
+++ b/bse/bsesong.proc
@@ -13,10 +13,8 @@
#include "bseengine.hh"
#include "bsecxxplugin.hh"
#include <string.h>
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
METHOD (BseSong, create-bus) {
HELP = _("Create a new mixer bus for a Song.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -32,11 +30,9 @@ METHOD (BseSong, create-bus) {
BseErrorType error = BSE_ERROR_NONE;
BseUndoStack *ustack;
BseItem *child = NULL;
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self))
error = BSE_ERROR_SOURCE_BUSY;
@@ -47,13 +43,10 @@ METHOD (BseSong, create-bus) {
bse_item_push_undo_proc (self, "remove-bus", child);
bse_item_undo_close (ustack);
}
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return error;
}
-
METHOD (BseSong, remove-bus) {
HELP = _("Delete a mixer bus from a Song.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -68,11 +61,9 @@ METHOD (BseSong, remove-bus) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_BUS (child) || BSE_ITEM (child)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self))
error = BSE_ERROR_SOURCE_BUSY;
@@ -90,10 +81,8 @@ METHOD (BseSong, remove-bus) {
/* done */
bse_item_undo_close (ustack);
}
-
return error;
}
-
METHOD (BseSong, ensure-master-bus) {
HELP = _("Retrieve master output bus of a song, will create one if it doesn't exist.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -107,20 +96,15 @@ METHOD (BseSong, ensure-master-bus) {
/* extract parameter values */
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseSource *child;
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
child = bse_song_ensure_master (self);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, get-master-bus) {
HELP = _("Retrieve master output bus of a song if it exists.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -133,20 +117,15 @@ METHOD (BseSong, get-master-bus) {
{
/* extract parameter values */
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
BseBus *bus = bse_song_find_master (self);
-
/* set output parameters */
bse_value_set_object (out_values++, bus);
-
return BSE_ERROR_NONE;
}
-
static const gchar*
orphans_track_name (void)
{
@@ -155,7 +134,6 @@ orphans_track_name (void)
*/
return _("Orphan Parts");
}
-
static BseTrack*
bse_song_ensure_orphans_track_noundo (BseSong *self)
{
@@ -172,7 +150,6 @@ bse_song_ensure_orphans_track_noundo (BseSong *self)
g_object_set_data ((GObject*) child, "BseSong-orphan-track", (void*) bse_song_ensure_orphans_track_noundo); /* mark orphan-parts track */
return child;
}
-
static BseTrack*
bse_song_find_first_track (BseSong *self,
BsePart *part)
@@ -188,7 +165,6 @@ bse_song_find_first_track (BseSong *self,
}
return NULL;
}
-
METHOD (BseSong, ensure-track-links) {
HELP = _("Ensure that each part in a song is inserted into at least one track.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -199,11 +175,9 @@ METHOD (BseSong, ensure-track-links) {
{
/* extract parameter values */
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
gboolean clear_undo = FALSE;
SfiRing *ring;
@@ -220,10 +194,8 @@ METHOD (BseSong, ensure-track-links) {
if (project)
bse_project_clear_undo (project);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, create-part) {
HELP = _("Create a new Part in a Song.");
IN = bse_param_spec_object ("song", NULL, NULL,
@@ -238,23 +210,18 @@ METHOD (BseSong, create-part) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
BseItem *child;
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "create-part");
child = (BseItem*) bse_container_new_child (BSE_CONTAINER (self), BSE_TYPE_PART, NULL);
bse_item_push_undo_proc (self, "remove-part", child);
bse_item_undo_close (ustack);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, remove-part) {
HELP = _("Delete a Part from a Song.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -269,11 +236,9 @@ METHOD (BseSong, remove-part) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_PART (child) || BSE_ITEM (child)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self))
error = BSE_ERROR_SOURCE_BUSY;
@@ -289,10 +254,8 @@ METHOD (BseSong, remove-part) {
/* done */
bse_item_undo_close (ustack);
}
-
return error;
}
-
METHOD (BseSong, create-track) {
HELP = _("Create a new Track for a Song.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -307,11 +270,9 @@ METHOD (BseSong, create-track) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
BseItem *child = NULL;
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self))
error = BSE_ERROR_SOURCE_BUSY;
@@ -322,13 +283,10 @@ METHOD (BseSong, create-track) {
bse_item_push_undo_proc (self, "remove-track", child);
bse_item_undo_close (ustack);
}
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return error;
}
-
METHOD (BseSong, remove-track) {
HELP = _("Delete a Track from a Song.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -343,12 +301,10 @@ METHOD (BseSong, remove-track) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_TRACK (child) ||
BSE_ITEM (child)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self))
error = BSE_ERROR_SOURCE_BUSY;
@@ -364,10 +320,8 @@ METHOD (BseSong, remove-track) {
/* done */
bse_item_undo_close (ustack);
}
-
return error;
}
-
METHOD (BseSong, find-track-for-part) {
HELP = _("Find a track suitable for playing notes of a given part.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -386,12 +340,10 @@ METHOD (BseSong, find-track-for-part) {
BseTrack *track = NULL;
guint tick = 0;
SfiRing *ring;
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_PART (part) ||
BSE_ITEM (part)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
for (ring = self->tracks_SL; ring; ring = sfi_ring_walk (ring, self->tracks_SL))
{
@@ -404,13 +356,10 @@ METHOD (BseSong, find-track-for-part) {
tick = start;
}
}
-
/* set output parameters */
bse_value_set_object (out_values++, track);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, find-any-track-for-part) {
HELP = _("Find the first track that contains part, suitable to check for orphan parts.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -426,18 +375,14 @@ METHOD (BseSong, find-any-track-for-part) {
/* extract parameter values */
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
BsePart *part = (BsePart*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_PART (part) ||
BSE_ITEM (part)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
bse_value_set_object (out_values++, bse_song_find_first_track (self, part));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, synthesize-note) {
HELP = _("Synthesize a note on a song of an active project.");
IN = bse_param_spec_object ("song", "Song", NULL,
@@ -463,12 +408,10 @@ METHOD (BseSong, synthesize-note) {
gint note = sfi_value_get_note (in_values++);
gint fine_tune = sfi_value_get_int (in_values++);
gfloat velocity = sfi_value_get_real (in_values++);
-
/* check parameters */
if (!BSE_IS_SONG (self) || !BSE_IS_TRACK (track) ||
BSE_ITEM (track)->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (BSE_SOURCE_PREPARED (self) && self->midi_receiver_SL)
{
@@ -483,10 +426,8 @@ METHOD (BseSong, synthesize-note) {
bse_midi_receiver_process_events (self->midi_receiver_SL, tstamp + duration);
bse_project_keep_activated (BSE_PROJECT (BSE_ITEM (self)->parent), tstamp + duration);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSong, get-timing) {
HELP = _("Retrieve song timing information at a specific tick.");
IN = bse_param_spec_object ("song", "Song", NULL, BSE_TYPE_SONG, SFI_PARAM_STANDARD);
@@ -500,16 +441,12 @@ METHOD (BseSong, get-timing) {
BseSong *self = (BseSong*) bse_value_get_object (in_values++);
SfiInt tick = sfi_value_get_int (in_values++);
BseSongTiming timing = { 0, };
-
/* check parameters */
if (!BSE_IS_SONG (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_song_get_timing (self, tick, &timing);
-
/* set output parameters */
bse_value_set_boxed (out_values++, &timing);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index fec90f8..71fc3be 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -1,18 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <string.h>
#include "bsesource.hh"
-
#include "bsecontainer.hh"
#include "bsestorage.hh"
#include "gslcommon.hh"
#include "bseengine.hh"
-
-
/* --- macros --- */
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
/* --- typedefs & enums --- */
enum {
PROP_0,
@@ -33,15 +28,10 @@ typedef struct
} data;
} u;
} BseSourceContext;
-
#define BSE_SOURCE_N_CONTEXTS(source) (g_bsearch_array_get_n_nodes ((source)->contexts))
-
-
/* --- prototypes --- */
static gint contexts_compare (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_io_changed = 0;
@@ -50,8 +40,6 @@ static const GBSearchConfig context_config = {
contexts_compare,
G_BSEARCH_ARRAY_ALIGN_POWER2,
};
-
-
/* --- functions --- */
static void
bse_source_init (BseSource *source,
@@ -65,7 +53,6 @@ bse_source_init (BseSource *source,
source->pos_y = 0;
source->probes = NULL;
}
-
static gboolean
source_check_pspec_editable (BseObject *object,
GParamSpec *pspec)
@@ -77,7 +64,6 @@ source_check_pspec_editable (BseObject *object,
else
return TRUE;
}
-
static void
bse_source_set_property (GObject *object,
guint param_id,
@@ -98,7 +84,6 @@ bse_source_set_property (GObject *object,
break;
}
}
-
static void
bse_source_get_property (GObject *object,
guint param_id,
@@ -119,12 +104,10 @@ bse_source_get_property (GObject *object,
break;
}
}
-
static void
bse_source_dispose (GObject *object)
{
BseSource *source = BSE_SOURCE (object);
-
if (source->probes)
bse_source_clear_probes (source);
bse_source_clear_ochannels (source);
@@ -133,19 +116,15 @@ bse_source_dispose (GObject *object)
g_warning (G_STRLOC ": source still prepared during destruction");
bse_source_reset (source);
}
-
bse_source_clear_ichannels (source);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_source_finalize (GObject *object)
{
BseSource *source = BSE_SOURCE (object);
guint i;
-
if (source->probes)
bse_source_clear_probes (source);
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
@@ -153,11 +132,9 @@ bse_source_finalize (GObject *object)
g_free (BSE_SOURCE_INPUT (source, i)->jdata.joints);
g_free (source->inputs);
source->inputs = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gboolean
bse_source_class_has_channel (BseSourceClass *klass,
const gchar *channel_ident)
@@ -171,14 +148,12 @@ bse_source_class_has_channel (BseSourceClass *klass,
return TRUE;
return FALSE;
}
-
static gchar*
channel_dup_canonify (const gchar *name)
{
gchar *cname = g_new (gchar, strlen (name) + 1);
const gchar *s;
gchar *c = cname;
-
for (s = name; *s; s++)
if ((*s >= '0' && *s <= '9') ||
(*s >= 'a' && *s <= 'z'))
@@ -190,7 +165,6 @@ channel_dup_canonify (const gchar *name)
*c++ = 0;
return cname;
}
-
static guint
bse_source_class_add_ijchannel (BseSourceClass *source_class,
const gchar *ident,
@@ -201,12 +175,10 @@ bse_source_class_add_ijchannel (BseSourceClass *source_class,
BseSourceChannelDefs *defs;
guint i;
gchar *cname;
-
g_return_val_if_fail (BSE_IS_SOURCE_CLASS (source_class), 0);
g_return_val_if_fail (ident != NULL, 0);
if (!label)
label = ident;
-
cname = channel_dup_canonify (ident);
if (bse_source_class_has_channel (source_class, cname))
{
@@ -231,10 +203,8 @@ bse_source_class_add_ijchannel (BseSourceClass *source_class,
}
else
defs->ijstreams[i] = i - defs->n_jstreams;
-
return i;
}
-
guint
bse_source_class_add_ichannel (BseSourceClass *source_class,
const gchar *ident,
@@ -243,7 +213,6 @@ bse_source_class_add_ichannel (BseSourceClass *source_class,
{
return bse_source_class_add_ijchannel (source_class, ident, label, blurb, FALSE);
}
-
guint
bse_source_class_add_jchannel (BseSourceClass *source_class,
const gchar *ident,
@@ -252,22 +221,18 @@ bse_source_class_add_jchannel (BseSourceClass *source_class,
{
return bse_source_class_add_ijchannel (source_class, ident, label, blurb, TRUE);
}
-
guint
bse_source_find_ichannel (BseSource *source,
const gchar *ichannel_cname)
{
guint i;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), ~0);
g_return_val_if_fail (ichannel_cname != NULL, ~0);
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
if (strcmp (BSE_SOURCE_ICHANNEL_IDENT (source, i), ichannel_cname) == 0)
return i;
return ~0;
}
-
guint
bse_source_class_add_ochannel (BseSourceClass *source_class,
const gchar *ident,
@@ -277,12 +242,10 @@ bse_source_class_add_ochannel (BseSourceClass *source_class,
BseSourceChannelDefs *defs;
guint i;
gchar *cname;
-
g_return_val_if_fail (BSE_IS_SOURCE_CLASS (source_class), 0);
g_return_val_if_fail (ident != NULL, 0);
if (!label)
label = ident;
-
cname = channel_dup_canonify (ident);
if (bse_source_class_has_channel (source_class, cname))
{
@@ -299,35 +262,28 @@ bse_source_class_add_ochannel (BseSourceClass *source_class,
defs->ochannel_idents[i] = cname;
defs->ochannel_labels[i] = g_strdup (label);
defs->ochannel_blurbs[i] = g_strdup (blurb);
-
return i;
}
-
void
bse_source_class_cache_engine_class (BseSourceClass *source_class,
const BseModuleClass *engine_class)
{
g_return_if_fail (source_class->engine_class == NULL);
g_return_if_fail (engine_class != NULL);
-
source_class->engine_class = (BseModuleClass*) g_memdup (engine_class, sizeof (*engine_class));
}
-
guint
bse_source_find_ochannel (BseSource *source,
const gchar *ochannel_cname)
{
guint i;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), ~0);
g_return_val_if_fail (ochannel_cname != NULL, ~0);
-
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (source); i++)
if (strcmp (BSE_SOURCE_OCHANNEL_IDENT (source, i), ochannel_cname) == 0)
return i;
return ~0;
}
-
static void
source_class_collect_properties (BseSourceClass *klass)
{
@@ -363,7 +319,6 @@ source_class_collect_properties (BseSourceClass *klass)
klass->filtered_properties = TRUE;
}
}
-
static void
source_notify_properties (BseSource *self)
{
@@ -373,29 +328,24 @@ source_notify_properties (BseSource *self)
for (ring = klass->unprepared_properties; ring; ring = sfi_ring_walk (ring, klass->unprepared_properties))
g_object_notify ((GObject*) self, G_PARAM_SPEC (ring->data)->name);
}
-
static gint
contexts_compare (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
{
const BseSourceContext *c1 = (const BseSourceContext*) bsearch_node1;
const BseSourceContext *c2 = (const BseSourceContext*) bsearch_node2;
-
return G_BSEARCH_ARRAY_CMP (c1->id, c2->id);
}
-
static void
bse_source_real_prepare (BseSource *source)
{
}
-
void
bse_source_prepare (BseSource *source)
{
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (!BSE_SOURCE_PREPARED (source));
g_return_if_fail (source->contexts == NULL);
-
g_object_ref (source);
g_object_freeze_notify (G_OBJECT (source));
source_class_collect_properties (BSE_SOURCE_GET_CLASS (source));
@@ -406,21 +356,17 @@ bse_source_prepare (BseSource *source)
g_object_thaw_notify (G_OBJECT (source));
g_object_unref (source);
}
-
static void
bse_source_real_reset (BseSource *source)
{
}
-
void
bse_source_reset (BseSource *source)
{
guint n_contexts;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (source->contexts != NULL);
-
g_object_ref (source);
g_object_freeze_notify (G_OBJECT (source));
n_contexts = BSE_SOURCE_N_CONTEXTS (source);
@@ -444,7 +390,6 @@ bse_source_reset (BseSource *source)
g_object_thaw_notify (G_OBJECT (source));
g_object_unref (source);
}
-
static gint
automation_properties_cmp (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
@@ -453,16 +398,13 @@ automation_properties_cmp (gconstpointer bsearch_node1, /* key */
const BseAutomationProperty *ap2 = (const BseAutomationProperty*) bsearch_node2;
return G_BSEARCH_ARRAY_CMP (ap1->pspec, ap2->pspec);
}
-
static const GBSearchConfig aprop_bconfig = { sizeof (BseAutomationProperty), automation_properties_cmp, 0 };
-
static void
aprop_array_free (gpointer data)
{
GBSearchArray *aparray = (GBSearchArray*) data;
g_bsearch_array_free (aparray, &aprop_bconfig);
}
-
BseErrorType
bse_source_set_automation_property (BseSource *source,
const gchar *prop_name,
@@ -513,7 +455,6 @@ bse_source_set_automation_property (BseSource *source,
}
return BSE_ERROR_NONE;
}
-
void
bse_source_get_automation_property (BseSource *source,
const gchar *prop_name,
@@ -541,7 +482,6 @@ bse_source_get_automation_property (BseSource *source,
}
return;
}
-
BseAutomationProperty* /* g_free() result */
bse_source_get_automation_properties (BseSource *source,
guint *n_props)
@@ -560,82 +500,64 @@ bse_source_get_automation_properties (BseSource *source,
}
return NULL;
}
-
static void
bse_source_real_context_create (BseSource *source,
guint context_handle,
BseTrans *trans)
{
}
-
static inline BseSourceContext*
context_nth (BseSource *source,
guint index)
{
g_return_val_if_fail (index < BSE_SOURCE_N_CONTEXTS (source), NULL);
-
return (BseSourceContext*) g_bsearch_array_get_nth (source->contexts, &context_config, index);
}
-
static inline BseSourceContext*
context_lookup (BseSource *source,
guint context_handle)
{
BseSourceContext key;
-
key.id = context_handle;
return (BseSourceContext*) g_bsearch_array_lookup (source->contexts, &context_config, &key);
}
-
gboolean
bse_source_has_context (BseSource *source,
guint context_handle)
{
BseSourceContext *context;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), FALSE);
-
context = context_lookup (source, context_handle);
-
return context != NULL;
}
-
guint*
bse_source_context_ids (BseSource *source,
guint *n_ids)
{
guint *cids, i;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), FALSE);
g_return_val_if_fail (n_ids != NULL, FALSE);
-
cids = g_new (guint, BSE_SOURCE_N_CONTEXTS (source));
for (i = 0; i < BSE_SOURCE_N_CONTEXTS (source); i++)
{
BseSourceContext *context = context_nth (source, i);
-
cids[i] = context->id;
}
*n_ids = BSE_SOURCE_N_CONTEXTS (source);
-
return cids;
}
-
gpointer
bse_source_get_context_data (BseSource *source,
guint context_handle)
{
BseSourceContext *context;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
g_return_val_if_fail (BSE_SOURCE_PREPARED (source), NULL);
g_return_val_if_fail (!BSE_SOURCE_N_ICHANNELS (source) && !BSE_SOURCE_N_OCHANNELS (source), NULL);
g_return_val_if_fail (context_handle > 0, NULL);
-
context = context_lookup (source, context_handle);
return context ? context->u.data.d2 : NULL;
}
-
static void
source_create_context (BseSource *source,
guint context_handle,
@@ -645,14 +567,12 @@ source_create_context (BseSource *source,
BseTrans *trans)
{
BseSourceContext *context, key = { 0, };
-
context = context_lookup (source, context_handle);
if (context)
{
g_warning ("%s: context %u on %p exists already", str_loc, context->id, source);
return;
}
-
g_object_ref (source);
key.id = context_handle;
key.u.data.d1 = (void*) free_data;
@@ -671,7 +591,6 @@ source_create_context (BseSource *source,
G_OBJECT_TYPE_NAME (source), "output");
g_object_unref (source);
}
-
void
bse_source_create_context_with_data (BseSource *source,
guint context_handle,
@@ -684,10 +603,8 @@ bse_source_create_context_with_data (BseSource *source,
g_return_if_fail (!BSE_SOURCE_N_ICHANNELS (source) && !BSE_SOURCE_N_OCHANNELS (source));
g_return_if_fail (context_handle > 0);
g_return_if_fail (trans != NULL);
-
source_create_context (source, context_handle, data, free_data, G_STRLOC, trans);
}
-
void
bse_source_create_context (BseSource *source,
guint context_handle,
@@ -697,10 +614,8 @@ bse_source_create_context (BseSource *source,
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (context_handle > 0);
g_return_if_fail (trans != NULL);
-
source_create_context (source, context_handle, NULL, NULL, G_STRLOC, trans);
}
-
static void
bse_source_context_connect_ichannel (BseSource *source,
BseSourceContext *context,
@@ -709,15 +624,12 @@ bse_source_context_connect_ichannel (BseSource *source,
guint first_joint)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, ichannel);
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
{
guint i;
-
for (i = first_joint; i < input->jdata.n_joints; i++)
{
BseSourceOutput *output = input->jdata.joints + i;
-
if (output->osource)
{
BseModule *omodule = bse_source_get_context_omodule (output->osource,
@@ -746,34 +658,28 @@ bse_source_context_connect_ichannel (BseSource *source,
}
}
}
-
static void
bse_source_real_context_connect (BseSource *source,
guint context_handle,
BseTrans *trans)
{
guint i;
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
{
BseSourceContext *context = context_lookup (source, context_handle);
-
bse_source_context_connect_ichannel (source, context, i, trans, 0);
}
}
-
void
bse_source_connect_context (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSourceContext *context;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (context_handle > 0);
g_return_if_fail (trans != NULL);
-
context = context_lookup (source, context_handle);
if (context)
{
@@ -784,14 +690,12 @@ bse_source_connect_context (BseSource *source,
else
g_warning ("%s: no such context %u", G_STRLOC, context_handle);
}
-
static void
bse_source_real_context_dismiss (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSourceContext *context = context_lookup (source, context_handle);
-
if (BSE_SOURCE_N_ICHANNELS (source) || BSE_SOURCE_N_OCHANNELS (source))
{
if (context->u.mods.imodule)
@@ -804,19 +708,16 @@ bse_source_real_context_dismiss (BseSource *source,
bse_source_probes_modules_changed (source);
}
}
-
void
bse_source_dismiss_context (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSourceContext *context;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (context_handle > 0);
g_return_if_fail (trans != NULL);
-
context = context_lookup (source, context_handle);
if (context)
{
@@ -851,14 +752,12 @@ bse_source_dismiss_context (BseSource *source,
else
g_warning ("%s: no such context %u", G_STRLOC, context_handle);
}
-
void
bse_source_set_context_imodule (BseSource *source,
guint context_handle,
BseModule *imodule)
{
BseSourceContext *context;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (context_handle > 0);
@@ -874,7 +773,6 @@ bse_source_set_context_imodule (BseSource *source,
else
g_return_if_fail (BSE_MODULE_N_ISTREAMS (imodule) >= BSE_SOURCE_N_ICHANNELS (source));
}
-
context = context_lookup (source, context_handle);
if (!context)
{
@@ -885,20 +783,16 @@ bse_source_set_context_imodule (BseSource *source,
g_return_if_fail (context->u.mods.imodule == NULL);
else
g_return_if_fail (context->u.mods.imodule != NULL);
-
context->u.mods.imodule = imodule;
}
-
BseModule*
bse_source_get_context_imodule (BseSource *source,
guint context_handle)
{
BseSourceContext *context;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
g_return_val_if_fail (BSE_SOURCE_PREPARED (source), NULL);
g_return_val_if_fail (BSE_SOURCE_N_ICHANNELS (source) > 0, NULL);
-
context = context_lookup (source, context_handle);
if (!context)
{
@@ -907,21 +801,18 @@ bse_source_get_context_imodule (BseSource *source,
}
return context->u.mods.imodule;
}
-
void
bse_source_set_context_omodule (BseSource *source,
guint context_handle,
BseModule *omodule)
{
BseSourceContext *context;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (context_handle > 0);
g_return_if_fail (BSE_SOURCE_N_OCHANNELS (source) > 0);
if (omodule)
g_return_if_fail (BSE_MODULE_N_OSTREAMS (omodule) >= BSE_SOURCE_N_OCHANNELS (source));
-
context = context_lookup (source, context_handle);
if (!context)
{
@@ -932,12 +823,10 @@ bse_source_set_context_omodule (BseSource *source,
g_return_if_fail (context->u.mods.omodule == NULL);
else
g_return_if_fail (context->u.mods.omodule != NULL);
-
context->u.mods.omodule = omodule;
if (source->probes)
bse_source_probes_modules_changed (source);
}
-
SfiRing*
bse_source_list_omodules (BseSource *source)
{
@@ -952,17 +841,14 @@ bse_source_list_omodules (BseSource *source)
}
return ring;
}
-
BseModule*
bse_source_get_context_omodule (BseSource *source,
guint context_handle)
{
BseSourceContext *context;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
g_return_val_if_fail (BSE_SOURCE_PREPARED (source), NULL);
g_return_val_if_fail (BSE_SOURCE_N_OCHANNELS (source) > 0, NULL);
-
context = context_lookup (source, context_handle);
if (!context)
{
@@ -971,7 +857,6 @@ bse_source_get_context_omodule (BseSource *source,
}
return context->u.mods.omodule;
}
-
void
bse_source_set_context_module (BseSource *source,
guint context_handle,
@@ -982,13 +867,11 @@ bse_source_set_context_module (BseSource *source,
g_return_if_fail (module != NULL);
g_return_if_fail (BSE_MODULE_N_OSTREAMS (module) >= BSE_SOURCE_N_OCHANNELS (source));
g_return_if_fail (BSE_MODULE_N_ISTREAMS (module) + BSE_MODULE_N_JSTREAMS (module) >= BSE_SOURCE_N_ICHANNELS (source));
-
if (BSE_SOURCE_N_ICHANNELS (source))
bse_source_set_context_imodule (source, context_handle, module);
if (BSE_SOURCE_N_OCHANNELS (source))
bse_source_set_context_omodule (source, context_handle, module);
}
-
void
bse_source_flow_access_module (BseSource *source,
guint context_handle,
@@ -1000,13 +883,11 @@ bse_source_flow_access_module (BseSource *source,
{
BseSourceContext *context;
BseModule *m1, *m2;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (access_func != NULL);
g_return_if_fail (context_handle > 0);
g_return_if_fail (BSE_SOURCE_N_ICHANNELS (source) || BSE_SOURCE_N_OCHANNELS (source));
-
context = context_lookup (source, context_handle);
if (!context)
{
@@ -1017,11 +898,9 @@ bse_source_flow_access_module (BseSource *source,
m2 = context->u.mods.omodule;
if (m1 == m2)
m1 = NULL;
-
if (m1 || m2)
{
BseTrans *my_trans = trans ? trans : bse_trans_open ();
-
if (m1)
bse_trans_add (my_trans, bse_job_flow_access (m1, tick_stamp, access_func, data,
m2 ? NULL : data_free_func));
@@ -1034,7 +913,6 @@ bse_source_flow_access_module (BseSource *source,
else if (data_free_func)
data_free_func (data);
}
-
void
bse_source_flow_access_modules (BseSource *source,
guint64 tick_stamp,
@@ -1045,26 +923,21 @@ bse_source_flow_access_modules (BseSource *source,
{
GSList *modules = NULL;
guint i;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (access_func != NULL);
g_return_if_fail (BSE_SOURCE_N_ICHANNELS (source) || BSE_SOURCE_N_OCHANNELS (source));
-
for (i = 0; i < BSE_SOURCE_N_CONTEXTS (source); i++)
{
BseSourceContext *context = context_nth (source, i);
-
if (context->u.mods.imodule)
modules = g_slist_prepend (modules, context->u.mods.imodule);
else if (context->u.mods.omodule && context->u.mods.omodule != context->u.mods.imodule)
modules = g_slist_prepend (modules, context->u.mods.omodule);
}
-
if (modules)
{
BseTrans *my_trans = trans ? trans : bse_trans_open ();
-
for (GSList *slist = modules; slist; slist = slist->next)
bse_trans_add (my_trans, bse_job_flow_access ((BseModule*) slist->data, tick_stamp, access_func, data,
slist->next ? NULL : data_free_func));
@@ -1075,7 +948,6 @@ bse_source_flow_access_modules (BseSource *source,
else if (data_free_func)
data_free_func (data);
}
-
void
bse_source_access_modules (BseSource *source,
BseEngineAccessFunc access_func,
@@ -1085,27 +957,22 @@ bse_source_access_modules (BseSource *source,
{
GSList *modules = NULL;
guint i;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (access_func != NULL);
g_return_if_fail (BSE_SOURCE_N_ICHANNELS (source) || BSE_SOURCE_N_OCHANNELS (source));
-
for (i = 0; i < BSE_SOURCE_N_CONTEXTS (source); i++)
{
BseSourceContext *context = context_nth (source, i);
-
if (context->u.mods.imodule)
modules = g_slist_prepend (modules, context->u.mods.imodule);
else if (context->u.mods.omodule && context->u.mods.omodule != context->u.mods.imodule)
modules = g_slist_prepend (modules, context->u.mods.omodule);
}
-
if (modules)
{
BseTrans *my_trans = trans ? trans : bse_trans_open ();
GSList *slist;
-
for (slist = modules; slist; slist = slist->next)
bse_trans_add (my_trans, bse_job_access ((BseModule*) slist->data, access_func, data,
slist->next ? NULL : data_free_func));
@@ -1116,22 +983,18 @@ bse_source_access_modules (BseSource *source,
else if (data_free_func)
data_free_func (data);
}
-
typedef struct {
guint member_offset;
guint member_size;
} AccessData;
-
static void
op_access_update (BseModule *module,
gpointer data)
{
AccessData *adata = (AccessData*) data;
guint8 *m = (guint8*) module->user_data;
-
memcpy (m + adata->member_offset, adata + 1, adata->member_size);
}
-
void
bse_source_update_modules (BseSource *source,
guint member_offset,
@@ -1140,19 +1003,16 @@ bse_source_update_modules (BseSource *source,
BseTrans *trans)
{
AccessData *adata;
-
g_return_if_fail (BSE_IS_SOURCE (source));
g_return_if_fail (BSE_SOURCE_PREPARED (source));
g_return_if_fail (member_data != NULL);
g_return_if_fail (member_size > 0);
-
adata = (AccessData*) g_malloc (sizeof (AccessData) + member_size);
adata->member_offset = member_offset;
adata->member_size = member_size;
memcpy (adata + 1, member_data, member_size);
bse_source_access_modules (source, op_access_update, adata, g_free, trans);
}
-
static void
bse_source_real_add_input (BseSource *source,
guint ichannel,
@@ -1161,7 +1021,6 @@ bse_source_real_add_input (BseSource *source,
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, ichannel);
guint j = 0;
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
{
j = input->jdata.n_joints++;
@@ -1172,27 +1031,22 @@ bse_source_real_add_input (BseSource *source,
else
{
g_return_if_fail (input->idata.osource == NULL);
-
input->idata.osource = osource;
input->idata.ochannel = ochannel;
}
osource->outputs = g_slist_prepend (osource->outputs, source);
-
if (BSE_SOURCE_PREPARED (source) && BSE_SOURCE_N_CONTEXTS (source))
{
BseTrans *trans = bse_trans_open ();
guint c;
-
for (c = 0; c < BSE_SOURCE_N_CONTEXTS (source); c++)
{
BseSourceContext *context = context_nth (source, c);
-
bse_source_context_connect_ichannel (source, context, ichannel, trans, j);
}
bse_trans_commit (trans);
}
}
-
static gint
check_jchannel_connection (BseSource *source,
guint ichannel,
@@ -1200,11 +1054,9 @@ check_jchannel_connection (BseSource *source,
guint ochannel)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, ichannel);
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
{
guint j;
-
for (j = 0; j < input->jdata.n_joints; j++)
if (input->jdata.joints[j].osource == osource &&
input->jdata.joints[j].ochannel == ochannel)
@@ -1214,7 +1066,6 @@ check_jchannel_connection (BseSource *source,
else
return ochannel == input->idata.ochannel && osource == input->idata.osource ? 0 : -1;
}
-
BseErrorType
bse_source_set_input (BseSource *source,
guint ichannel,
@@ -1231,7 +1082,6 @@ bse_source_set_input (BseSource *source,
}
else
g_return_val_if_fail (!BSE_SOURCE_PREPARED (osource), BSE_ERROR_INTERNAL);
-
if (ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_SOURCE_NO_SUCH_ICHANNEL;
if (ochannel >= BSE_SOURCE_N_OCHANNELS (osource))
@@ -1245,7 +1095,6 @@ bse_source_set_input (BseSource *source,
return BSE_ERROR_SOURCE_ICHANNEL_IN_USE;
if (bse_source_test_input_recursive (osource, source))
return BSE_ERROR_SOURCE_BAD_LOOPBACK;
-
g_object_ref (source);
g_object_ref (osource);
BSE_SOURCE_GET_CLASS (source)->add_input (source, ichannel, osource, ochannel);
@@ -1253,10 +1102,8 @@ bse_source_set_input (BseSource *source,
g_signal_emit (osource, signal_io_changed, 0);
g_object_unref (source);
g_object_unref (osource);
-
return BSE_ERROR_NONE;
}
-
static void
bse_source_real_remove_input (BseSource *source,
guint ichannel,
@@ -1266,7 +1113,6 @@ bse_source_real_remove_input (BseSource *source,
BseSourceInput *input = BSE_SOURCE_INPUT (source, ichannel);
BseTrans *trans = NULL;
gint j = -1;
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
{
j = check_jchannel_connection (source, ichannel, osource, ochannel);
@@ -1274,7 +1120,6 @@ bse_source_real_remove_input (BseSource *source,
}
else
g_return_if_fail (osource == BSE_SOURCE_INPUT (source, ichannel)->idata.osource);
-
if (BSE_SOURCE_PREPARED (source) && BSE_SOURCE_N_CONTEXTS (source))
{
guint c;
@@ -1295,18 +1140,15 @@ bse_source_real_remove_input (BseSource *source,
for (c = 0; c < BSE_SOURCE_N_CONTEXTS (source); c++)
{
BseSourceContext *context = context_nth (source, c);
-
bse_trans_add (trans, bse_job_disconnect (context->u.mods.imodule,
BSE_SOURCE_ICHANNEL_ISTREAM (source, ichannel)));
}
}
}
}
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
{
guint k = --input->jdata.n_joints;
-
input->jdata.joints[j].osource = input->jdata.joints[k].osource;
input->jdata.joints[j].ochannel = input->jdata.joints[k].ochannel;
}
@@ -1316,11 +1158,9 @@ bse_source_real_remove_input (BseSource *source,
input->idata.ochannel = 0;
}
osource->outputs = g_slist_remove (osource->outputs, source);
-
if (trans)
bse_trans_commit (trans);
}
-
BseErrorType
bse_source_check_input (BseSource *source,
guint ichannel,
@@ -1329,7 +1169,6 @@ bse_source_check_input (BseSource *source,
{
g_return_val_if_fail (BSE_IS_SOURCE (source), BSE_ERROR_INTERNAL);
g_return_val_if_fail (BSE_IS_SOURCE (osource), BSE_ERROR_INTERNAL);
-
if (BSE_ITEM (source)->parent != BSE_ITEM (osource)->parent)
return BSE_ERROR_SOURCE_PARENT_MISMATCH;
if (BSE_SOURCE_PREPARED (source)) /* FIXME: check context sets */
@@ -1339,17 +1178,14 @@ bse_source_check_input (BseSource *source,
}
else
g_return_val_if_fail (!BSE_SOURCE_PREPARED (osource), BSE_ERROR_INTERNAL);
-
if (ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_SOURCE_NO_SUCH_ICHANNEL;
if (ochannel >= BSE_SOURCE_N_OCHANNELS (osource))
return BSE_ERROR_SOURCE_NO_SUCH_OCHANNEL;
if (check_jchannel_connection (source, ichannel, osource, ochannel) < 0)
return BSE_ERROR_SOURCE_NO_SUCH_CONNECTION;
-
return BSE_ERROR_NONE;
}
-
BseErrorType
bse_source_unset_input (BseSource *source,
guint ichannel,
@@ -1359,7 +1195,6 @@ bse_source_unset_input (BseSource *source,
BseErrorType error = bse_source_check_input (source, ichannel, osource, ochannel);
if (error != BSE_ERROR_NONE)
return error;
-
g_object_ref (source);
g_object_ref (osource);
BSE_SOURCE_GET_CLASS (source)->remove_input (source, ichannel, osource, ochannel);
@@ -1367,10 +1202,8 @@ bse_source_unset_input (BseSource *source,
g_signal_emit (osource, signal_io_changed, 0);
g_object_unref (osource);
g_object_unref (source);
-
return BSE_ERROR_NONE;
}
-
gboolean
bse_source_get_input (BseSource *source,
guint ichannel,
@@ -1390,7 +1223,6 @@ bse_source_get_input (BseSource *source,
}
return FALSE;
}
-
gboolean
bse_source_has_output (BseSource *source,
guint ochannel)
@@ -1419,7 +1251,6 @@ bse_source_has_output (BseSource *source,
}
return FALSE;
}
-
void
bse_source_must_set_input_loc (BseSource *source,
guint ichannel,
@@ -1434,16 +1265,13 @@ bse_source_must_set_input_loc (BseSource *source,
bse_object_debug_name (osource), ochannel,
bse_error_blurb (error));
}
-
static SfiRing*
collect_inputs_flat (SfiRing *ring, BseSource *source)
{
guint i, j;
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, i);
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, i))
for (j = 0; j < input->jdata.n_joints; j++)
{
@@ -1466,32 +1294,26 @@ collect_inputs_flat (SfiRing *ring, BseSource *source)
}
return ring;
}
-
SfiRing*
bse_source_collect_inputs_flat (BseSource *source)
{
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
return collect_inputs_flat (NULL, source);
}
-
SfiRing*
bse_source_collect_inputs_recursive (BseSource *source)
{
SfiRing *node, *ring = NULL;
-
g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
-
ring = collect_inputs_flat (ring, source);
for (node = ring; node; node = sfi_ring_walk (node, ring))
ring = collect_inputs_flat (ring, (BseSource*) node->data);
return ring;
}
-
void
bse_source_free_collection (SfiRing *ring)
{
SfiRing *node;
-
for (node = ring; node; node = sfi_ring_walk (node, ring))
{
BseSource *source = BSE_SOURCE (node->data);
@@ -1499,7 +1321,6 @@ bse_source_free_collection (SfiRing *ring)
}
sfi_ring_free (ring);
}
-
static gboolean
ring_search_backwards (SfiRing *ring,
SfiRing *bound,
@@ -1512,15 +1333,12 @@ ring_search_backwards (SfiRing *ring,
ring = ring->prev;
return FALSE;
}
-
gboolean
bse_source_test_input_recursive (BseSource *source,
BseSource *test)
{
SfiRing *node, *last, *ring = NULL;
-
g_return_val_if_fail (BSE_IS_SOURCE (source) && BSE_IS_SOURCE (test), FALSE);
-
BSE_OBJECT_SET_FLAGS (source, BSE_SOURCE_FLAG_COLLECTED);
last = ring = sfi_ring_append (NULL, source);
gboolean match = last->data == test;
@@ -1533,30 +1351,24 @@ bse_source_test_input_recursive (BseSource *source,
bse_source_free_collection (ring);
return match;
}
-
void
bse_source_clear_ichannels (BseSource *source)
{
gboolean io_changed = FALSE;
guint i;
-
g_return_if_fail (BSE_IS_SOURCE (source));
-
g_object_ref (source);
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, i);
BseSource *osource;
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, i))
{
guint ochannel;
-
while (input->jdata.n_joints)
{
osource = input->jdata.joints[0].osource;
ochannel = input->jdata.joints[0].ochannel;
-
io_changed = TRUE;
g_object_ref (osource);
BSE_SOURCE_GET_CLASS (source)->remove_input (source, i, osource, ochannel);
@@ -1567,7 +1379,6 @@ bse_source_clear_ichannels (BseSource *source)
else if (input->idata.osource)
{
osource = input->idata.osource;
-
io_changed = TRUE;
g_object_ref (osource);
BSE_SOURCE_GET_CLASS (source)->remove_input (source, i, osource, input->idata.ochannel);
@@ -1579,14 +1390,11 @@ bse_source_clear_ichannels (BseSource *source)
g_signal_emit (source, signal_io_changed, 0);
g_object_unref (source);
}
-
void
bse_source_backup_ichannels_to_undo (BseSource *source)
{
BseUndoStack *ustack;
-
g_return_if_fail (BSE_IS_SOURCE (source));
-
ustack = bse_item_undo_open (source, "unset-input %s", bse_object_debug_name (source));
if (ustack)
{
@@ -1594,7 +1402,6 @@ bse_source_backup_ichannels_to_undo (BseSource *source)
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, i);
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, i))
for (j = 0; j < input->jdata.n_joints; j++)
bse_source_input_backup_to_undo (source, i,
@@ -1608,29 +1415,23 @@ bse_source_backup_ichannels_to_undo (BseSource *source)
}
bse_item_undo_close (ustack);
}
-
void
bse_source_clear_ochannels (BseSource *source)
{
gboolean io_changed = FALSE;
-
g_return_if_fail (BSE_IS_SOURCE (source));
-
g_object_ref (source);
while (source->outputs)
{
BseSource *isource = (BseSource*) source->outputs->data;
guint i;
-
g_object_ref (isource);
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (isource); i++)
{
BseSourceInput *input = BSE_SOURCE_INPUT (isource, i);
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (isource, i))
{
guint j;
-
for (j = 0; j < input->jdata.n_joints; j++)
if (input->jdata.joints[j].osource == source)
break;
@@ -1658,23 +1459,18 @@ bse_source_clear_ochannels (BseSource *source)
g_signal_emit (source, signal_io_changed, 0);
g_object_unref (source);
}
-
void
bse_source_backup_ochannels_to_undo (BseSource *source)
{
BseUndoStack *ustack;
-
g_return_if_fail (BSE_IS_SOURCE (source));
-
ustack = bse_item_undo_open (source, "unset-input %s", bse_object_debug_name (source));
if (ustack)
{
GSList *slist, *uniq_outputs = NULL;
-
for (slist = source->outputs; slist; slist = slist->next)
if (!g_slist_find (uniq_outputs, slist->data))
uniq_outputs = g_slist_prepend (uniq_outputs, slist->data);
-
for (slist = uniq_outputs; slist; slist = slist->next)
{
BseSource *isource = (BseSource*) slist->data;
@@ -1699,36 +1495,29 @@ bse_source_backup_ochannels_to_undo (BseSource *source)
}
bse_item_undo_close (ustack);
}
-
static void
bse_source_real_store_private (BseObject *object,
BseStorage *storage)
{
BseSource *source = BSE_SOURCE (object);
guint i, j;
-
/* chain parent class' handler */
if (BSE_OBJECT_CLASS (parent_class)->store_private)
BSE_OBJECT_CLASS (parent_class)->store_private (object, storage);
-
if (BSE_SOURCE_PRIVATE_INPUTS (source))
return;
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (source); i++)
{
BseSourceInput *input = BSE_SOURCE_INPUT (source, i);
GSList *slist, *outputs = NULL;
-
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, i))
for (j = 0; j < input->jdata.n_joints; j++)
outputs = g_slist_append (outputs, input->jdata.joints + j);
else if (input->idata.osource)
outputs = g_slist_append (outputs, &input->idata);
-
for (slist = outputs; slist; slist = slist->next)
{
BseSourceOutput *output = (BseSourceOutput*) slist->data;
-
bse_storage_break (storage);
bse_storage_printf (storage,
"(source-input \"%s\" ",
@@ -1739,7 +1528,6 @@ bse_source_real_store_private (BseObject *object,
g_slist_free (outputs);
}
}
-
void
bse_source_input_backup_to_undo (BseSource *source,
guint ichannel,
@@ -1749,30 +1537,22 @@ bse_source_input_backup_to_undo (BseSource *source,
BseErrorType error = bse_source_check_input (source, ichannel, osource, ochannel);
BseUndoStack *ustack;
BseStorage *storage;
-
g_return_if_fail (error == BSE_ERROR_NONE);
-
if (BSE_SOURCE_PRIVATE_INPUTS (source))
return;
-
ustack = bse_item_undo_open (source, "unset-input %s", bse_object_debug_name (source));
-
storage = (BseStorage*) g_object_new (BSE_TYPE_STORAGE, NULL);
bse_storage_prepare_write (storage, BSE_STORAGE_DBLOCK_CONTAINED);
-
bse_storage_break (storage);
bse_storage_printf (storage,
"(source-input \"%s\" ",
BSE_SOURCE_ICHANNEL_IDENT (source, ichannel));
bse_storage_put_item_link (storage, BSE_ITEM (source), BSE_ITEM (osource));
bse_storage_printf (storage, " \"%s\")", BSE_SOURCE_OCHANNEL_IDENT (osource, ochannel));
-
bse_item_push_undo_storage (BSE_ITEM (source), ustack, storage);
g_object_unref (storage);
-
bse_item_undo_close (ustack);
}
-
typedef struct _DeferredInput DeferredInput;
struct _DeferredInput
{
@@ -1781,8 +1561,6 @@ struct _DeferredInput
gchar *osource_path;
gchar *ochannel_ident;
};
-
-
static void
resolve_osource_input (gpointer data,
BseStorage *storage,
@@ -1793,7 +1571,6 @@ resolve_osource_input (gpointer data,
DeferredInput *dinput = (DeferredInput*) data;
BseSource *source = BSE_SOURCE (from_item);
BseSource *osource = to_item ? BSE_SOURCE (to_item) : NULL;
-
if (error)
bse_storage_warn (storage,
"failed to connect input \"%s\" of `%s' to output \"%s\" of unresolved object: %s",
@@ -1804,7 +1581,6 @@ resolve_osource_input (gpointer data,
else
{
BseErrorType cerror;
-
if (!osource)
cerror = BSE_ERROR_SOURCE_NO_SUCH_MODULE;
else if (!dinput->ichannel_ident)
@@ -1834,32 +1610,26 @@ resolve_osource_input (gpointer data,
osource ? BSE_OBJECT_UNAME (osource) : ":<NULL>:",
bse_error_blurb (cerror));
}
-
g_free (dinput->ichannel_ident);
g_free (dinput->osource_path);
g_free (dinput->ochannel_ident);
g_free (dinput);
}
-
static GTokenType
bse_source_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner)
{
BseSource *source = BSE_SOURCE (object);
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER &&
bse_string_equals ("source-input", scanner->next_value.v_identifier))
{
DeferredInput *dinput;
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat identifier */
-
/* parse ichannel name */
parse_or_return (scanner, G_TOKEN_STRING);
dinput = g_new0 (DeferredInput, 1);
dinput->ichannel_ident = g_strdup (scanner->value.v_string);
-
/* parse osource upath and queue handler */
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER) /* bad, bad, hack */
{
@@ -1873,12 +1643,10 @@ bse_source_restore_private (BseObject *object,
if (token != G_TOKEN_NONE)
return token;
}
-
/* parse ochannel name */
parse_or_return (scanner, G_TOKEN_STRING);
peek_or_return (scanner, ')');
dinput->ochannel_ident = g_strdup (scanner->value.v_string);
-
/* close statement */
parse_or_return (scanner, ')');
return G_TOKEN_NONE;
@@ -1886,7 +1654,6 @@ bse_source_restore_private (BseObject *object,
else /* chain parent class' handler */
return BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
}
-
static void
bse_source_class_base_init (BseSourceClass *klass)
{
@@ -1908,7 +1675,6 @@ bse_source_class_base_init (BseSourceClass *klass)
klass->unprepared_properties = NULL;
klass->automation_properties = NULL;
}
-
BseMusicalTuningType
bse_source_prepared_musical_tuning (BseSource *source)
{
@@ -1916,7 +1682,6 @@ bse_source_prepared_musical_tuning (BseSource *source)
g_return_val_if_fail (BSE_SOURCE_PREPARED (source), BSE_MUSICAL_TUNING_12_TET);
return bse_item_current_musical_tuning (BSE_ITEM (source)); // FIXME: cache this, once we have source->SynthesisContext
}
-
void
bse_source_class_inherit_channels (BseSourceClass *source_class)
{
@@ -1957,12 +1722,10 @@ bse_source_class_inherit_channels (BseSourceClass *source_class)
source_class->channel_defs.ochannel_blurbs[i] = g_strdup (defs->ochannel_blurbs[i]);
}
}
-
static void
bse_source_class_base_finalize (BseSourceClass *klass)
{
guint i;
-
for (i = 0; i < klass->channel_defs.n_ichannels; i++)
{
g_free (klass->channel_defs.ichannel_idents[i]);
@@ -1997,23 +1760,19 @@ bse_source_class_base_finalize (BseSourceClass *klass)
sfi_ring_free (klass->unprepared_properties);
sfi_ring_free (klass->automation_properties);
}
-
static void
bse_source_class_init (BseSourceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
gobject_class->set_property = bse_source_set_property;
gobject_class->get_property = bse_source_get_property;
gobject_class->dispose = bse_source_dispose;
gobject_class->finalize = bse_source_finalize;
-
object_class->check_pspec_editable = source_check_pspec_editable;
object_class->store_private = bse_source_real_store_private;
object_class->restore_private = bse_source_restore_private;
-
klass->prepare = bse_source_real_prepare;
klass->context_create = bse_source_real_context_create;
klass->context_connect = bse_source_real_context_connect;
@@ -2021,7 +1780,6 @@ bse_source_class_init (BseSourceClass *klass)
klass->reset = bse_source_real_reset;
klass->add_input = bse_source_real_add_input;
klass->remove_input = bse_source_real_remove_input;
-
bse_object_class_add_param (object_class, "Position",
PROP_POS_X,
sfi_pspec_real ("pos_x", "Position X", NULL,
@@ -2032,29 +1790,23 @@ bse_source_class_init (BseSourceClass *klass)
sfi_pspec_real ("pos_y", "Position Y", NULL,
0, -SFI_MAXREAL, SFI_MAXREAL, 10,
SFI_PARAM_STORAGE ":skip-default:f:"));
-
signal_io_changed = bse_object_class_add_signal (object_class, "io-changed", G_TYPE_NONE, 0);
bse_source_class_add_probe_signals (klass);
}
-
BSE_BUILTIN_TYPE (BseSource)
{
static const GTypeInfo source_info = {
sizeof (BseSourceClass),
-
(GBaseInitFunc) bse_source_class_base_init,
(GBaseFinalizeFunc) bse_source_class_base_finalize,
(GClassInitFunc) bse_source_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSource),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_source_init,
};
-
g_assert (BSE_SOURCE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
-
return bse_type_register_abstract (BSE_TYPE_ITEM,
"BseSource",
"Base type for sound sources",
diff --git a/bse/bsesource.hh b/bse/bsesource.hh
index b8ecb91..527314f 100644
--- a/bse/bsesource.hh
+++ b/bse/bsesource.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SOURCE_H__
#define __BSE_SOURCE_H__
-
#include <bse/bseitem.hh>
#include <bse/gsldefs.hh>
#include <sfi/gbsearcharray.hh>
-
G_BEGIN_DECLS
-
-
/* --- BseSource type macros --- */
#define BSE_TYPE_SOURCE (BSE_TYPE_ID (BseSource))
#define BSE_SOURCE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SOURCE, BseSource))
@@ -16,8 +12,6 @@ G_BEGIN_DECLS
#define BSE_IS_SOURCE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SOURCE))
#define BSE_IS_SOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SOURCE))
#define BSE_SOURCE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SOURCE, BseSourceClass))
-
-
/* --- BseSource member macros --- */
#define BSE_SOURCE_PREPARED(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_PREPARED) != 0)
#define BSE_SOURCE_COLLECTED(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_COLLECTED) != 0)
@@ -47,7 +41,6 @@ G_BEGIN_DECLS
0xffffffff)
#define BSE_SOURCE_JSTREAM_FLAG ((guint) 1 << 31)
#define BSE_SOURCE_PRIVATE_INPUTS(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_PRIVATE_INPUTS) != 0)
-
/* --- BseSource flags --- */
typedef enum /*< skip >*/
{
@@ -56,8 +49,6 @@ typedef enum /*< skip >*/
BSE_SOURCE_FLAG_COLLECTED = 1 << (BSE_ITEM_FLAGS_USHIFT + 2)
} BseSourceFlags;
#define BSE_SOURCE_FLAGS_USHIFT (BSE_ITEM_FLAGS_USHIFT + 3)
-
-
/* --- typedefs & structures --- */
typedef union _BseSourceInput BseSourceInput;
typedef struct _BseSourceOutput BseSourceOutput;
@@ -82,7 +73,6 @@ union _BseSourceInput
struct _BseSource
{
BseItem parent_object;
-
BseSourceChannelDefs *channel_defs;
BseSourceInput *inputs; /* [n_ichannels] */
GSList *outputs;
@@ -106,9 +96,7 @@ struct _BseSourceChannelDefs
struct _BseSourceClass
{
BseItemClass parent_class;
-
BseSourceChannelDefs channel_defs;
-
void (*property_updated) (BseSource *source, /* overridable method */
guint property_id,
guint64 tick_stamp,
@@ -125,7 +113,6 @@ struct _BseSourceClass
guint context_handle,
BseTrans *trans);
void (*reset) (BseSource *source);
-
/*< private >*/
void (*add_input) (BseSource *source,
guint ichannel,
@@ -140,7 +127,6 @@ struct _BseSourceClass
SfiRing *unprepared_properties;
SfiRing *automation_properties;
};
-
/* --- prototypes -- */
guint bse_source_find_ichannel (BseSource *source,
const gchar *ichannel_ident);
@@ -165,8 +151,6 @@ void bse_source_must_set_input_loc (BseSource *source,
const gchar *strloc);
#define bse_source_must_set_input(is,ic,os,oc) \
bse_source_must_set_input_loc (is, ic, os, oc, G_STRLOC)
-
-
/* --- source implementations --- */
guint bse_source_class_add_ichannel (BseSourceClass *source_class,
const gchar *ident,
@@ -235,7 +219,6 @@ void bse_source_update_modules (BseSource *source,
void bse_source_clear_ichannels (BseSource *source);
void bse_source_clear_ochannels (BseSource *source);
BseMusicalTuningType bse_source_prepared_musical_tuning (BseSource *source);
-
/* automation */
typedef struct {
GParamSpec *pspec;
@@ -252,7 +235,6 @@ void bse_source_get_automation_property (BseSource
BseMidiSignalType *psignal_type);
BseAutomationProperty* bse_source_get_automation_properties (BseSource *source,
guint *n_props);
-
/* --- internal --- */
SfiRing* bse_source_collect_inputs_flat (BseSource *source); /* sets mark */
SfiRing* bse_source_collect_inputs_recursive (BseSource *source); /* sets mark */
@@ -289,7 +271,5 @@ SfiRing* bse_source_list_omodules (BseSource *source);
void bse_source_clear_probes (BseSource *source);
void bse_source_class_add_probe_signals (BseSourceClass *klass);
void bse_source_probes_modules_changed (BseSource *source);
-
G_END_DECLS
-
#endif /* __BSE_SOURCE_H__ */
diff --git a/bse/bsesource.proc b/bse/bsesource.proc
index 9e676d6..c294505 100644
--- a/bse/bsesource.proc
+++ b/bse/bsesource.proc
@@ -6,11 +6,8 @@
#include <bse/bseieee754.hh>
#include <bse/bsemidievent.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
METHOD (BseSource, set-input-by-id) {
HELP = "Connect a module input to another module's output.";
IN = bse_param_spec_object ("imodule", "Input Module", NULL,
@@ -35,23 +32,18 @@ BODY (BseProcedureClass *proc,
BseSource *osource = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
BSE_ITEM (isource)->parent != BSE_ITEM (osource)->parent)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* connect */
error = bse_source_set_input (isource, ichannel, osource, ochannel);
if (error == BSE_ERROR_NONE)
bse_item_push_undo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, set-input) {
HELP = "Connect a module input to another module's output.";
IN = bse_param_spec_object ("imodule", "Input Module", NULL,
@@ -77,26 +69,21 @@ BODY (BseProcedureClass *proc,
const char *ochannel_ident = sfi_value_get_string (in_values++);
guint ichannel, ochannel;
BseErrorType error;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
BSE_ITEM (isource)->parent != BSE_ITEM (osource)->parent ||
!ichannel_ident || !ochannel_ident)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* connect */
ichannel = bse_source_find_ichannel (isource, ichannel_ident);
ochannel = bse_source_find_ochannel (osource, ochannel_ident);
error = bse_source_set_input (isource, ichannel, osource, ochannel);
if (error == BSE_ERROR_NONE)
bse_item_push_undo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, unset-input-by-id) {
HELP = "Disconnect a module input.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -121,11 +108,9 @@ BODY (BseProcedureClass *proc,
BseSource *osource = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* disconnect */
error = bse_source_check_input (isource, ichannel, osource, ochannel);
if (error == BSE_ERROR_NONE)
@@ -136,13 +121,10 @@ BODY (BseProcedureClass *proc,
bse_item_undo_close (ustack);
error = bse_source_unset_input (isource, ichannel, osource, ochannel);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, unset-input) {
HELP = "Disconnect a module input.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -168,12 +150,10 @@ BODY (BseProcedureClass *proc,
const char *ochannel_ident = sfi_value_get_string (in_values++);
guint ichannel, ochannel;
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
!ichannel_ident || !ochannel_ident)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* disconnect */
ichannel = bse_source_find_ichannel (isource, ichannel_ident);
ochannel = bse_source_find_ochannel (osource, ochannel_ident);
@@ -186,13 +166,10 @@ BODY (BseProcedureClass *proc,
bse_item_undo_close (ustack);
error = bse_source_unset_input (isource, ichannel, osource, ochannel);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, clear-inputs) {
HELP = "Disconnect all module inputs.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -205,21 +182,17 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *isource = (BseSource*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* disconnect */
ustack = bse_item_undo_open (isource, "clear-inputs %s", bse_object_debug_name (isource));
bse_source_backup_ichannels_to_undo (isource);
bse_item_push_redo_proc (isource, "clear-inputs");
bse_item_undo_close (ustack);
bse_source_clear_ichannels (isource);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, clear-outputs) {
HELP = "Disconnect all module outputs.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -232,21 +205,17 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *isource = (BseSource*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_SOURCE (isource))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* disconnect */
ustack = bse_item_undo_open (isource, "clear-outputs %s", bse_object_debug_name (isource));
bse_source_backup_ochannels_to_undo (isource);
bse_item_push_redo_proc (isource, "clear-outputs");
bse_item_undo_close (ustack);
bse_source_clear_ochannels (isource);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, has-output) {
HELP = "Check whether a module's output channel is connected.";
IN = bse_param_spec_object ("module", NULL, NULL, BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
@@ -260,17 +229,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, bse_source_has_output (source, ochannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, has-outputs) {
HELP = "Check whether a module has output channel connections.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -284,17 +249,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, source->outputs != NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, n-ichannels) {
HELP = "Get the number of input channels of a module.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -308,17 +269,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, BSE_SOURCE_N_ICHANNELS (source));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-label) {
HELP = "Get input channel name.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -335,17 +292,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ichannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_LABEL (source, ichannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-ident) {
HELP = "Get canonical input channel name.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -362,17 +315,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ichannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_IDENT (source, ichannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-blurb) {
HELP = "Get input channel description.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -389,17 +338,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ichannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_BLURB (source, ichannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, is-joint-ichannel-by-id) {
HELP = "Check if an input channel is a joint (multi-connect) channel.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -416,17 +361,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ichannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, is-joint-ichannel) {
HELP = "Check if an input channel is a joint (multi-connect) channel.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -444,19 +385,15 @@ BODY (BseProcedureClass *proc,
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
const char *ichannel = sfi_value_get_string (in_values++);
guint id;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || !ichannel)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
id = bse_source_find_ichannel (source, ichannel);
sfi_value_set_bool (out_values++,
id < BSE_SOURCE_N_ICHANNELS (source) ? BSE_SOURCE_IS_JOINT_ICHANNEL (source, id) : FALSE);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-get-n-joints) {
HELP = "Retrieve the number of inputs connected to an input channel.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -474,21 +411,17 @@ BODY (BseProcedureClass *proc,
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ichannel = sfi_value_get_int (in_values++);
BseSourceInput *input;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
input = BSE_SOURCE_INPUT (source, ichannel);
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
sfi_value_set_int (out_values++, input->jdata.n_joints);
else
sfi_value_set_int (out_values++, input->idata.osource ? 1 : 0);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-get-osource) {
HELP = "Retrieve output module connected to a specific joint of an input channel";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -509,11 +442,9 @@ BODY (BseProcedureClass *proc,
guint ichannel = sfi_value_get_int (in_values++);
guint joint = sfi_value_get_int (in_values++);
BseSourceInput *input;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
input = BSE_SOURCE_INPUT (source, ichannel);
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel) && joint < input->jdata.n_joints)
@@ -522,10 +453,8 @@ BODY (BseProcedureClass *proc,
bse_value_set_object (out_values++, input->idata.osource);
else
bse_value_set_object (out_values++, NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ichannel-get-ochannel) {
HELP = "Retrieve output channel of the module connected to a specific joint of an input channel.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -546,11 +475,9 @@ BODY (BseProcedureClass *proc,
guint ichannel = sfi_value_get_int (in_values++);
guint joint = sfi_value_get_int (in_values++);
BseSourceInput *input;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
input = BSE_SOURCE_INPUT (source, ichannel);
if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel) && joint < input->jdata.n_joints)
@@ -559,10 +486,8 @@ BODY (BseProcedureClass *proc,
sfi_value_set_int (out_values++, input->idata.ochannel);
else
sfi_value_set_int (out_values++, G_MAXINT);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, n-ochannels) {
HELP = "Get the number of output channels of a module.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -576,17 +501,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, BSE_SOURCE_N_OCHANNELS (source));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ochannel-label) {
HELP = "Get output channel name.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -603,17 +524,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_LABEL (source, ochannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ochannel-ident) {
HELP = "Get canonical output channel name.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -630,17 +547,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_IDENT (source, ochannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, ochannel-blurb) {
HELP = "Get output channel description.";
IN = bse_param_spec_object ("module", "Module", NULL,
@@ -657,17 +570,13 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
guint ochannel = sfi_value_get_int (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_BLURB (source, ochannel));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, set-pos) {
HELP = "Set the x and y position of a module. In contrast to setting the position "
"through ordinary object property setters, this function will not update "
@@ -691,11 +600,9 @@ BODY (BseProcedureClass *proc,
SfiReal xpos = sfi_value_get_real (in_values++);
SfiReal ypos = sfi_value_get_real (in_values++);
SfiReal epsilon = 1e-5;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || BSE_DOUBLE_IS_NANINF (xpos) || BSE_DOUBLE_IS_NANINF (ypos))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
if (fabs (xpos - source->pos_x) > epsilon ||
fabs (ypos - source->pos_y) > epsilon)
@@ -707,10 +614,8 @@ BODY (BseProcedureClass *proc,
NULL);
bse_item_undo_close (ustack);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, set-automation) {
HELP = "Setup automation parameters for a property.";
IN = bse_param_spec_object ("source", NULL, NULL,
@@ -733,11 +638,9 @@ BODY (BseProcedureClass *proc,
guint midi_channel = sfi_value_get_int (in_values++);
BseMidiSignalType control_type = (BseMidiSignalType) g_value_get_enum (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || !property)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* connect */
guint old_midi_channel = 0;
BseMidiSignalType old_control_type = BseMidiSignalType (0);
@@ -748,13 +651,10 @@ BODY (BseProcedureClass *proc,
if (error == BSE_ERROR_NONE)
bse_item_push_undo_proc (source, "set-automation", property, old_midi_channel, old_control_type);
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, get-automation-channel) {
HELP = "Get MIDI channel from an automation property.";
IN = bse_param_spec_object ("source", NULL, NULL,
@@ -770,20 +670,16 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
const char *property = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || !property)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* connect */
guint midi_channel = 0;
bse_source_get_automation_property (source, property, &midi_channel, NULL);
/* set output parameters */
g_value_set_int (out_values++, midi_channel);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, get-automation-control) {
HELP = "Get control type from an automation property.";
IN = bse_param_spec_object ("source", NULL, NULL,
@@ -799,20 +695,16 @@ BODY (BseProcedureClass *proc,
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
const char *property = sfi_value_get_string (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source) || !property)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* connect */
BseMidiSignalType control_type = BseMidiSignalType (0);
bse_source_get_automation_property (source, property, NULL, &control_type);
/* set output parameters */
g_value_set_enum (out_values++, control_type);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseSource, is-prepared) {
HELP = "Check whether a source is prepared for synthesis processing.";
IN = bse_param_spec_object ("source", NULL, NULL,
@@ -824,13 +716,10 @@ METHOD (BseSource, is-prepared) {
{
/* extract parameter values */
BseSource *source = (BseSource*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_SOURCE (source))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_bool (out_values++, BSE_SOURCE_PREPARED (source));
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsestandardosc.cc b/bse/bsestandardosc.cc
index 1253f18..13507d5 100644
--- a/bse/bsestandardosc.cc
+++ b/bse/bsestandardosc.cc
@@ -3,13 +3,9 @@
#include "bsecategories.hh"
#include "bseengine.hh"
#include "bsemathsignal.hh"
-
-
#define FRAC_N_BITS (19)
#define FRAC_BIT_MASK ((1 << FRAC_N_BITS) - 1)
#define TABLE_SIZE (1 << (32 - FRAC_N_BITS))
-
-
/* --- parameters --- */
enum
{
@@ -27,8 +23,6 @@ enum
PROP_PULSE_WIDTH,
PROP_PULSE_MOD_PERC
};
-
-
/* --- prototypes --- */
static void bse_standard_osc_init (BseStandardOsc *standard_osc);
static void bse_standard_osc_class_init (BseStandardOscClass *klass);
@@ -49,8 +43,6 @@ static void bse_standard_osc_reset (BseSource *source);
static void bse_standard_osc_update_modules (BseStandardOsc *standard_osc,
gboolean recreate_table,
BseTrans *trans);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static const gfloat osc_table_freqs[] = {
@@ -65,27 +57,22 @@ static const gfloat osc_table_freqs[] = {
BSE_KAMMER_FREQUENCY * 8.0,
BSE_KAMMER_FREQUENCY * 16.0
};
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseStandardOsc)
{
static const GTypeInfo type_info = {
sizeof (BseStandardOscClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_standard_osc_class_init,
(GClassFinalizeFunc) bse_standard_osc_class_finalize,
NULL /* class_data */,
-
sizeof (BseStandardOsc),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_standard_osc_init,
};
#include "./icons/osc.c"
GType type;
-
type = bse_type_register_static (BSE_TYPE_SOURCE,
"BseStandardOsc",
_("StandardOsc is the BSE basis oscillator which supports various types "
@@ -95,7 +82,6 @@ BSE_BUILTIN_TYPE (BseStandardOsc)
bse_categories_register_stock_module (N_("/Audio Sources/Standard Oscillator"), type, osc_pixstream);
return type;
}
-
static void
bse_standard_osc_class_init (BseStandardOscClass *klass)
{
@@ -103,16 +89,12 @@ bse_standard_osc_class_init (BseStandardOscClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel, ichannel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_standard_osc_set_property;
gobject_class->get_property = bse_standard_osc_get_property;
-
source_class->prepare = bse_standard_osc_prepare;
source_class->context_create = bse_standard_osc_context_create;
source_class->reset = bse_standard_osc_reset;
-
bse_object_class_add_param (object_class, _("Wave Form"),
PROP_WAVE_FORM,
bse_param_spec_genum ("wave_form", _("Wave"), _("Oscillator wave form"),
@@ -178,7 +160,6 @@ bse_standard_osc_class_init (BseStandardOscClass *klass)
"(Pulse has to be selected as wave form for this to take effect)"),
0.0, 0.0, 100.0, 5.0,
SFI_PARAM_STANDARD ":f:dial"));
-
ichannel = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Oscillating Frequency Input"));
g_assert (ichannel == BSE_STANDARD_OSC_ICHANNEL_FREQ);
ichannel = bse_source_class_add_ichannel (source_class, "freq-mod-in", _("Freq Mod In"), _("Frequency Modulation Input"));
@@ -192,12 +173,10 @@ bse_standard_osc_class_init (BseStandardOscClass *klass)
ochannel = bse_source_class_add_ochannel (source_class, "sync-out", _("Sync Out"), _("Syncronization Output"));
g_assert (ochannel == BSE_STANDARD_OSC_OCHANNEL_SYNC);
}
-
static void
bse_standard_osc_class_finalize (BseStandardOscClass *klass)
{
}
-
static void
bse_standard_osc_init (BseStandardOsc *self)
{
@@ -212,7 +191,6 @@ bse_standard_osc_init (BseStandardOsc *self)
self->fm_strength = 0;
self->n_octaves = 1;
}
-
static void
bse_standard_osc_set_property (GObject *object,
guint param_id,
@@ -220,7 +198,6 @@ bse_standard_osc_set_property (GObject *object,
GParamSpec *pspec)
{
BseStandardOsc *self = BSE_STANDARD_OSC (object);
-
switch (param_id)
{
case PROP_WAVE_FORM:
@@ -281,7 +258,6 @@ bse_standard_osc_set_property (GObject *object,
break;
}
}
-
static void
bse_standard_osc_get_property (GObject *object,
guint param_id,
@@ -289,7 +265,6 @@ bse_standard_osc_get_property (GObject *object,
GParamSpec *pspec)
{
BseStandardOsc *self = BSE_STANDARD_OSC (object);
-
switch (param_id)
{
case PROP_WAVE_FORM:
@@ -333,63 +308,51 @@ bse_standard_osc_get_property (GObject *object,
break;
}
}
-
static void
bse_standard_osc_prepare (BseSource *source)
{
BseStandardOsc *self = BSE_STANDARD_OSC (source);
-
self->config.table = gsl_osc_table_create (bse_engine_sample_freq (),
GslOscWaveForm (self->wave),
bse_window_blackman,
G_N_ELEMENTS (osc_table_freqs),
osc_table_freqs);
self->config.transpose_factor = bse_transpose_factor (bse_source_prepared_musical_tuning (BSE_SOURCE (self)), self->transpose);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
typedef struct
{
GslOscConfig config;
GslOscTable *old_osc_table;
} OscConfigData;
-
static void
standard_osc_access (BseModule *module,
gpointer data)
{
GslOscData *osc = (GslOscData*) module->user_data;
OscConfigData *cdata = (OscConfigData*) data;
-
/* this runs in the Gsl Engine threads */
-
gsl_osc_config (osc, &cdata->config);
}
-
static void
standard_osc_access_free (gpointer data)
{
OscConfigData *cdata = (OscConfigData*) data;
-
if (cdata->old_osc_table)
gsl_osc_table_free (cdata->old_osc_table);
g_free (cdata);
}
-
static void
bse_standard_osc_update_modules (BseStandardOsc *self,
gboolean recreate_table,
BseTrans *trans)
{
self->config.fm_strength = self->config.exponential_fm ? self->n_octaves : self->fm_strength;
-
/* update modules in all contexts with the new vars */
if (BSE_SOURCE_PREPARED (self))
{
OscConfigData cdata;
-
self->config.transpose_factor = bse_transpose_factor (bse_source_prepared_musical_tuning (BSE_SOURCE (self)), self->transpose);
cdata.config = self->config;
if (recreate_table)
@@ -411,15 +374,12 @@ bse_standard_osc_update_modules (BseStandardOsc *self,
trans);
}
}
-
static void
standard_osc_reset (BseModule *module)
{
GslOscData *osc = (GslOscData*) module->user_data;
-
gsl_osc_reset (osc);
}
-
static void
standard_osc_process (BseModule *module,
guint n_values)
@@ -431,14 +391,12 @@ standard_osc_process (BseModule *module,
const gfloat *pwm_in = NULL;
gfloat *osc_out = NULL;
gfloat *sync_out = NULL;
-
if (BSE_MODULE_OSTREAM (module, BSE_STANDARD_OSC_OCHANNEL_SYNC).connected)
sync_out = BSE_MODULE_OBUFFER (module, BSE_STANDARD_OSC_OCHANNEL_SYNC);
osc_out = BSE_MODULE_OBUFFER (module, BSE_STANDARD_OSC_OCHANNEL_OSC);
if (!BSE_MODULE_OSTREAM (module, BSE_STANDARD_OSC_OCHANNEL_OSC).connected &&
!sync_out)
return; /* nothing to process */
-
if (BSE_MODULE_ISTREAM (module, BSE_STANDARD_OSC_ICHANNEL_FREQ).connected)
freq_in = BSE_MODULE_IBUFFER (module, BSE_STANDARD_OSC_ICHANNEL_FREQ);
if (BSE_MODULE_ISTREAM (module, BSE_STANDARD_OSC_ICHANNEL_FREQ_MOD).connected)
@@ -447,13 +405,11 @@ standard_osc_process (BseModule *module,
sync_in = BSE_MODULE_IBUFFER (module, BSE_STANDARD_OSC_ICHANNEL_SYNC);
if (BSE_MODULE_ISTREAM (module, BSE_STANDARD_OSC_ICHANNEL_PWM).connected)
pwm_in = BSE_MODULE_IBUFFER (module, BSE_STANDARD_OSC_ICHANNEL_PWM);
-
if (osc->config.table->wave_form == GSL_OSC_WAVE_PULSE_SAW)
gsl_osc_process_pulse (osc, n_values, freq_in, mod_in, sync_in, pwm_in, osc_out, sync_out);
else
gsl_osc_process (osc, n_values, freq_in, mod_in, sync_in, osc_out, sync_out);
}
-
static void
bse_standard_osc_context_create (BseSource *source,
guint context_handle,
@@ -472,29 +428,22 @@ bse_standard_osc_context_create (BseSource *source,
BseStandardOsc *self = BSE_STANDARD_OSC (source);
GslOscData *osc = g_new0 (GslOscData, 1);
BseModule *module;
-
gsl_osc_reset (osc);
gsl_osc_config (osc, &self->config);
module = bse_module_new (&sosc_class, osc);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_standard_osc_reset (BseSource *source)
{
BseStandardOsc *self = BSE_STANDARD_OSC (source);
-
gsl_osc_table_free (self->config.table);
self->config.table = NULL;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
diff --git a/bse/bsestandardosc.hh b/bse/bsestandardosc.hh
index 6738d3f..eb230ba 100644
--- a/bse/bsestandardosc.hh
+++ b/bse/bsestandardosc.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_STANDARD_OSC_H__
#define __BSE_STANDARD_OSC_H__
-
#include <bse/bsesource.hh>
#include <bse/gsloscillator.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_STANDARD_OSC (BSE_TYPE_ID (BseStandardOsc))
#define BSE_STANDARD_OSC(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_STANDARD_OSC, BseStandardOsc))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_STANDARD_OSC(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_STANDARD_OSC))
#define BSE_IS_STANDARD_OSC_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_STANDARD_OSC))
#define BSE_STANDARD_OSC_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_STANDARD_OSC, BseStandardOscClass))
-
-
/* --- wave forms --- */
typedef enum
{
@@ -29,15 +24,12 @@ typedef enum
BSE_STANDARD_OSC_SQUARE = GSL_OSC_WAVE_SQUARE, /*< nick=Square >*/
BSE_STANDARD_OSC_PULSE = GSL_OSC_WAVE_PULSE_SAW /*< nick=Pulse >*/
} BseStandardOscWaveType;
-
-
/* --- BseStandardOsc source --- */
typedef struct _BseStandardOsc BseStandardOsc;
typedef struct _BseStandardOscClass BseStandardOscClass;
struct _BseStandardOsc
{
BseSource parent_object;
-
BseStandardOscWaveType wave;
GslOscConfig config;
int transpose;
@@ -48,8 +40,6 @@ struct _BseStandardOscClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -65,7 +55,5 @@ enum
BSE_STANDARD_OSC_OCHANNEL_SYNC,
BSE_STANDARD_OSC_N_OCHANNELS
};
-
G_END_DECLS
-
#endif /* __BSE_STANDARD_OSC_H__ */
diff --git a/bse/bsestandardsynths.cc b/bse/bsestandardsynths.cc
index 71631ba..30aa6fd 100644
--- a/bse/bsestandardsynths.cc
+++ b/bse/bsestandardsynths.cc
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsestandardsynths.hh"
-
#include "bsesnet.hh"
#include "bsestandardosc.hh"
#include <zlib.h>
#include <string.h>
-
-
/* --- typedef & structures --- */
typedef struct {
const gchar *name;
@@ -14,16 +11,10 @@ typedef struct {
const guint8 *cdata;
guint clength;
} BseZFile;
-
-
/* --- generated ZFiles --- */
#include "bse/zintern/bse-zfile.cc" /* bse_zfiles */
-
-
/* --- variables --- */
static GSList *zfile_names = NULL;
-
-
/* --- functions --- */
static gchar*
bse_zfile_uncompress (const BseZFile *zfile,
@@ -34,7 +25,6 @@ bse_zfile_uncompress (const BseZFile *zfile,
guint8 *text = (guint8*) g_malloc (len);
gint result;
const gchar *err;
-
if (zfile->clength) /* indicates compresssion */
result = uncompress (text, &dlen, zfile->cdata, zfile->clength);
else
@@ -66,28 +56,23 @@ bse_zfile_uncompress (const BseZFile *zfile,
}
if (err)
g_error ("while decompressing \"%s\": %s", zfile->name, err);
-
text[dlen] = 0;
if (text_len)
*text_len = dlen;
return (char*) text;
}
-
gchar*
bse_standard_synth_inflate (const gchar *synth_name,
guint *text_len)
{
guint i;
-
g_return_val_if_fail (synth_name != NULL, NULL);
-
for (i = 0; i < G_N_ELEMENTS (bse_zfiles); i++)
if (strcmp (synth_name, bse_zfiles[i].name) == 0)
return bse_zfile_uncompress (bse_zfiles + i, text_len);
g_warning ("unknown standard synth: %s", synth_name);
return NULL;
}
-
GSList*
bse_standard_synth_get_list (void)
{
diff --git a/bse/bsestandardsynths.hh b/bse/bsestandardsynths.hh
index ee599aa..2e4d283 100644
--- a/bse/bsestandardsynths.hh
+++ b/bse/bsestandardsynths.hh
@@ -1,18 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_STANDARD_SYNTHS_H__
#define __BSE_STANDARD_SYNTHS_H__
-
#include <bse/bseproject.hh>
-
G_BEGIN_DECLS
-
-
GSList* bse_standard_synth_get_list (void);
gchar* bse_standard_synth_inflate (const gchar *synth_name,
guint *text_len);
-
-
G_END_DECLS
-
-
#endif /* __BSE_STANDARD_SYNTHS_H__ */
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index 5088847..6b9e80e 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -13,14 +13,10 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-
-
/* --- macros --- */
#define DEBUG sfi_nodebug
#define parse_or_return sfi_scanner_parse_or_return
#define peek_or_return sfi_scanner_peek_or_return
-
-
/* --- typedefs --- */
struct _BseStorageDBlock
{
@@ -41,8 +37,6 @@ struct _BseStorageItemLink
BseItem *to_item;
gchar *error;
};
-
-
/* --- prototypes --- */
static void bse_storage_init (BseStorage *self);
static void bse_storage_class_init (BseStorageClass *klass);
@@ -63,16 +57,12 @@ static GTokenType compat_parse_data_handle (BseStorage *self,
guint *n_channels_p,
gfloat *mix_freq_p,
gfloat *osc_freq_p);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static GQuark quark_raw_data_handle = 0;
static GQuark quark_vorbis_data_handle = 0;
static GQuark quark_dblock_data_handle = 0;
static GQuark quark_bse_storage_binary_v0 = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseStorage)
{
@@ -87,30 +77,23 @@ BSE_BUILTIN_TYPE (BseStorage)
0 /* n_preallocs */,
(GInstanceInitFunc) bse_storage_init,
};
-
g_assert (BSE_STORAGE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
-
return bse_type_register_static (BSE_TYPE_OBJECT, "BseStorage",
"Storage object for item serialization",
__FILE__, __LINE__,
&storage_info);
}
-
static void
bse_storage_class_init (BseStorageClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
quark_raw_data_handle = g_quark_from_static_string ("raw-data-handle");
quark_vorbis_data_handle = g_quark_from_static_string ("vorbis-data-handle");
quark_dblock_data_handle = g_quark_from_static_string ("dblock-data-handle");
quark_bse_storage_binary_v0 = g_quark_from_static_string ("BseStorageBinaryV0");
-
gobject_class->finalize = bse_storage_finalize;
}
-
static void
bse_storage_init (BseStorage *self)
{
@@ -127,21 +110,16 @@ bse_storage_init (BseStorage *self)
self->dblocks = NULL;
self->n_dblocks = 0;
self->free_me = NULL;
-
bse_storage_reset (self);
}
-
static void
bse_storage_finalize (GObject *object)
{
BseStorage *self = BSE_STORAGE (object);
-
bse_storage_reset (self);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
void
bse_storage_turn_readable (BseStorage *self,
const gchar *storage_name)
@@ -150,37 +128,30 @@ bse_storage_turn_readable (BseStorage *self,
const gchar *cmem;
gchar *text;
guint n_dblocks, l;
-
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (BSE_STORAGE_DBLOCK_CONTAINED (self));
g_return_if_fail (self->wstore);
g_return_if_fail (self->wstore->flushed == FALSE);
g_return_if_fail (self->wstore->bblocks == NULL);
g_return_if_fail (self->free_me == NULL);
-
bse_storage_break (self);
-
cmem = sfi_wstore_peek_text (self->wstore, &l);
text = (char*) g_memdup (cmem, l + 1);
dblocks = self->dblocks;
n_dblocks = self->n_dblocks;
self->dblocks = NULL;
self->n_dblocks = 0;
-
bse_storage_input_text (self, text, storage_name);
self->free_me = text;
self->dblocks = dblocks;
self->n_dblocks = n_dblocks;
BSE_OBJECT_SET_FLAGS (self, BSE_STORAGE_DBLOCK_CONTAINED);
}
-
void
bse_storage_reset (BseStorage *self)
{
guint i;
-
g_return_if_fail (BSE_IS_STORAGE (self));
-
if (self->rstore)
{
bse_storage_finish_parsing (self);
@@ -192,7 +163,6 @@ bse_storage_reset (BseStorage *self)
sfi_ppool_destroy (self->restorable_objects);
self->restorable_objects = NULL;
}
-
if (self->wstore)
sfi_wstore_destroy (self->wstore);
self->wstore = NULL;
@@ -202,11 +172,9 @@ bse_storage_reset (BseStorage *self)
if (self->referenced_items)
sfi_ppool_destroy (self->referenced_items);
self->referenced_items = NULL;
-
self->major_version = BSE_MAJOR_VERSION;
self->minor_version = BSE_MINOR_VERSION;
self->micro_version = BSE_MICRO_VERSION;
-
for (i = 0; i < self->n_dblocks; i++)
{
bse_id_free (self->dblocks[i].id);
@@ -217,13 +185,10 @@ bse_storage_reset (BseStorage *self)
g_free (self->dblocks);
self->dblocks = NULL;
self->n_dblocks = 0;
-
g_free (self->free_me);
self->free_me = NULL;
-
BSE_OBJECT_UNSET_FLAGS (self, BSE_STORAGE_MODE_MASK);
}
-
static gulong
bse_storage_add_dblock (BseStorage *self,
GslDataHandle *dhandle)
@@ -245,7 +210,6 @@ bse_storage_add_dblock (BseStorage *self,
self->dblocks[i].osc_freq = gsl_data_handle_osc_freq (dhandle);
return self->dblocks[i].id;
}
-
static BseStorageDBlock*
bse_storage_get_dblock (BseStorage *self,
gulong id)
@@ -256,13 +220,11 @@ bse_storage_get_dblock (BseStorage *self,
return self->dblocks + i;
return NULL;
}
-
void
bse_storage_prepare_write (BseStorage *self,
BseStorageMode mode)
{
g_return_if_fail (BSE_IS_STORAGE (self));
-
bse_storage_reset (self);
self->wstore = sfi_wstore_new ();
self->stored_items = sfi_ppool_new ();
@@ -274,17 +236,14 @@ bse_storage_prepare_write (BseStorage *self,
bse_storage_break (self);
bse_storage_printf (self, "(bse-version \"%u.%u.%u\")\n\n", BSE_MAJOR_VERSION, BSE_MINOR_VERSION, BSE_MICRO_VERSION);
}
-
void
bse_storage_input_text (BseStorage *self,
const gchar *text,
const gchar *text_name)
{
g_return_if_fail (BSE_IS_STORAGE (self));
-
if (!text)
text = "";
-
bse_storage_reset (self);
self->rstore = sfi_rstore_new ();
self->rstore->parser_this = self;
@@ -292,14 +251,12 @@ bse_storage_input_text (BseStorage *self,
self->path_table = g_hash_table_new_full (uname_child_hash, uname_child_equals, NULL, uname_child_free);
self->restorable_objects = sfi_ppool_new ();
}
-
BseErrorType
bse_storage_input_file (BseStorage *self,
const gchar *file_name)
{
g_return_val_if_fail (BSE_IS_STORAGE (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
bse_storage_reset (self);
self->rstore = sfi_rstore_new_open (file_name);
if (!self->rstore)
@@ -307,10 +264,8 @@ bse_storage_input_file (BseStorage *self,
self->rstore->parser_this = self;
self->path_table = g_hash_table_new_full (uname_child_hash, uname_child_equals, NULL, uname_child_free);
self->restorable_objects = sfi_ppool_new ();
-
return BSE_ERROR_NONE;
}
-
static GTokenType
storage_parse_bse_version (BseStorage *self)
{
@@ -358,7 +313,6 @@ storage_parse_bse_version (BseStorage *self)
BSE_STORAGE_COMPAT (self, BSE_MAJOR_VERSION, BSE_MINOR_VERSION, BSE_MICRO_VERSION - 1));
return G_TOKEN_NONE;
}
-
static BseStorageItemLink*
storage_add_item_link (BseStorage *self,
BseItem *from_item,
@@ -372,10 +326,8 @@ storage_add_item_link (BseStorage *self,
ilink->restore_link = restore_link;
ilink->data = data;
ilink->error = error;
-
return ilink;
}
-
void
bse_storage_add_restorable (BseStorage *self,
BseObject *object)
@@ -385,10 +337,8 @@ bse_storage_add_restorable (BseStorage *self,
g_return_if_fail (self->restorable_objects);
g_return_if_fail (BSE_IS_OBJECT (object));
g_return_if_fail (BSE_OBJECT_IN_RESTORE (object));
-
sfi_ppool_set (self->restorable_objects, object);
}
-
static gboolean
storage_restorable_objects_foreach (gpointer data,
gpointer pointer)
@@ -398,17 +348,14 @@ storage_restorable_objects_foreach (gpointer data,
bse_object_restore_finish (object, self->major_version, self->minor_version, self->micro_version);
return TRUE;
}
-
void
bse_storage_finish_parsing (BseStorage *self)
{
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->rstore != NULL);
-
while (self->item_links)
{
BseStorageItemLink *ilink = (BseStorageItemLink*) sfi_ring_pop_head (&self->item_links);
-
if (ilink->error)
{
gchar *error = g_strdup_printf ("unable to resolve link path for item `%s': %s",
@@ -434,7 +381,6 @@ bse_storage_finish_parsing (BseStorage *self)
BseItem *child = NULL, *parent = ilink->from_item;
guint pbackup = ilink->pbackup;
gchar *error = NULL;
-
while (pbackup && parent)
{
pbackup--;
@@ -462,14 +408,12 @@ bse_storage_finish_parsing (BseStorage *self)
g_free (ilink->upath);
g_free (ilink);
}
-
/* finish restorables */
sfi_ppool_foreach (self->restorable_objects, storage_restorable_objects_foreach, self);
/* clear pool */
sfi_ppool_destroy (self->restorable_objects);
self->restorable_objects = sfi_ppool_new();
}
-
const gchar*
bse_storage_item_get_compat_type (BseItem *item)
{
@@ -478,13 +422,11 @@ bse_storage_item_get_compat_type (BseItem *item)
type = G_OBJECT_TYPE_NAME (item);
return type;
}
-
typedef struct {
BseContainer *container;
gchar *uname;
BseItem *item;
} UNameChild;
-
static guint
uname_child_hash (gconstpointer uc)
{
@@ -493,7 +435,6 @@ uname_child_hash (gconstpointer uc)
h ^= G_HASH_LONG ((long) uchild->container);
return h;
}
-
static gint
uname_child_equals (gconstpointer uc1,
gconstpointer uc2)
@@ -503,7 +444,6 @@ uname_child_equals (gconstpointer uc1,
return (bse_string_equals (uchild1->uname, uchild2->uname) &&
uchild1->container == uchild2->container);
}
-
static void
uname_child_free (gpointer uc)
{
@@ -513,7 +453,6 @@ uname_child_free (gpointer uc)
g_object_unref (uchild->item);
g_free (uchild);
}
-
static void
storage_path_table_insert (BseStorage *self,
BseContainer *container,
@@ -537,7 +476,6 @@ storage_path_table_insert (BseStorage *self,
uchild->item = (BseItem*) g_object_ref (item);
DEBUG ("INSERT: (%p,%s) => %p", container, uname, item);
}
-
static inline BseItem*
storage_path_table_lookup (BseStorage *self,
BseContainer *container,
@@ -556,7 +494,6 @@ storage_path_table_lookup (BseStorage *self,
*/
return bse_container_lookup_item (container, uname);
}
-
static BseItem*
storage_path_table_resolve_upath (BseStorage *self,
BseContainer *container,
@@ -578,7 +515,6 @@ storage_path_table_resolve_upath (BseStorage *self,
else
return storage_path_table_lookup (self, container, upath);
}
-
static void
item_link_resolved (gpointer data,
BseStorage *self,
@@ -592,7 +528,6 @@ item_link_resolved (gpointer data,
{
GParamSpec *pspec = (GParamSpec*) data;
GValue value = { 0, };
-
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_value_set_object (&value, dest_item);
g_object_set_property (G_OBJECT (item), /* no undo */
@@ -600,9 +535,7 @@ item_link_resolved (gpointer data,
g_value_unset (&value);
}
}
-
static GTokenType item_restore_try_statement (gpointer item, BseStorage *self, GScanner *scanner, gpointer user_data);
-
static GTokenType
restore_item_property (BseItem *item,
BseStorage *self)
@@ -611,11 +544,9 @@ restore_item_property (BseItem *item,
GTokenType expected_token;
GParamSpec *pspec;
GValue value = { 0, };
-
/* check identifier */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return SFI_TOKEN_UNMATCHED;
-
/* in theory, we should only find SFI_PARAM_SERVE_STORAGE
* properties here, but due to version changes or even
* users editing their files, we will simply parse all
@@ -627,7 +558,6 @@ restore_item_property (BseItem *item,
if (!pspec)
return SFI_TOKEN_UNMATCHED;
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat pspec name */
-
/* parse value, special casing object references */
if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (pspec), BSE_TYPE_ITEM))
{
@@ -653,7 +583,6 @@ restore_item_property (BseItem *item,
return expected_token;
}
}
-
/* set property value while preserving the object uname */
if ((pspec->flags & G_PARAM_WRITABLE) && !(pspec->flags & G_PARAM_CONSTRUCT_ONLY))
g_object_set_property (G_OBJECT (item), /* no undo */
@@ -662,10 +591,8 @@ restore_item_property (BseItem *item,
bse_storage_warn (self, "ignoring non-writable object property \"%s\" of type `%s'",
pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_value_unset (&value);
-
return G_TOKEN_NONE;
}
-
static GTokenType
restore_source_automation (BseItem *item,
BseStorage *self)
@@ -699,7 +626,6 @@ restore_source_automation (BseItem *item,
bse_storage_warn (self, "failed to automate property \"%s\": %s", pspec->name, bse_error_blurb (error));
return G_TOKEN_NONE;
}
-
static GTokenType
restore_container_child (BseContainer *container,
BseStorage *self)
@@ -709,13 +635,11 @@ restore_container_child (BseContainer *container,
BseItem *item;
const gchar *uname;
gchar *type_name, *tmp, *compat_type = NULL;
-
/* check identifier */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER ||
!bse_string_equals ("container-child", scanner->next_value.v_identifier))
return SFI_TOKEN_UNMATCHED;
parse_or_return (scanner, G_TOKEN_IDENTIFIER); /* eat identifier */
-
/* parse and validate type::uname argument */
parse_or_return (scanner, G_TOKEN_STRING);
uname = strchr (scanner->value.v_string, ':');
@@ -726,7 +650,6 @@ restore_container_child (BseContainer *container,
}
type_name = g_strndup (scanner->value.v_string, uname - scanner->value.v_string);
uname += 2;
-
/* handle different versions */
tmp = bse_compat_rewrite_type_name (self, type_name);
if (tmp)
@@ -734,7 +657,6 @@ restore_container_child (BseContainer *container,
compat_type = type_name;
type_name = tmp;
}
-
/* check container's storage filter */
if (!bse_container_check_restore (container, type_name))
{
@@ -742,7 +664,6 @@ restore_container_child (BseContainer *container,
g_free (compat_type);
return bse_storage_warn_skip (self, "ignoring child: \"%s\"", scanner->value.v_string);
}
-
/* create container child */
tmp = g_strconcat (type_name, "::", uname, NULL);
g_free (type_name);
@@ -755,20 +676,15 @@ restore_container_child (BseContainer *container,
if (!item)
return bse_storage_warn_skip (self, "failed to create object from (invalid?) handle: \"%s\"",
scanner->value.v_string);
-
/* provide compatibility setup (e.g. property defaults) */
bse_item_compat_setup (item, self->major_version, self->minor_version, self->micro_version);
-
storage_path_table_insert (self, container, uname, item);
-
/* restore_item reads out closing parenthesis */
g_object_ref (item);
expected_token = bse_storage_parse_rest (self, item, item_restore_try_statement, NULL);
g_object_unref (item);
-
return expected_token;
}
-
static GTokenType
item_restore_try_statement (gpointer _item,
BseStorage *self,
@@ -777,65 +693,48 @@ item_restore_try_statement (gpointer _item,
{
BseItem *item = BSE_ITEM (_item);
GTokenType expected_token = SFI_TOKEN_UNMATCHED;
-
/* ensure that the statement starts out with an identifier */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
{
g_scanner_get_next_token (scanner);
return G_TOKEN_IDENTIFIER;
}
-
/* this is pretty much the *only* place where something else than
* G_TOKEN_NONE may be returned without erroring out. return values:
* G_TOKEN_NONE - statement got parsed, advance to next statement
* SFI_TOKEN_UNMATCHED - statement not recognized, try further
* anything else - encountered (syntax/semantic) error during parsing
*/
-
bse_object_restore_start (BSE_OBJECT (item), self);
-
if (expected_token == SFI_TOKEN_UNMATCHED)
expected_token = restore_item_property (item, self);
-
if (expected_token == SFI_TOKEN_UNMATCHED)
expected_token = restore_source_automation (item, self);
-
if (expected_token == SFI_TOKEN_UNMATCHED)
expected_token = BSE_OBJECT_GET_CLASS (item)->restore_private ((BseObject*) item, self, scanner);
-
if (expected_token == SFI_TOKEN_UNMATCHED)
expected_token = bse_parasite_restore ((BseObject*) item, self);
-
if (expected_token == SFI_TOKEN_UNMATCHED && BSE_IS_CONTAINER (item))
expected_token = restore_container_child ((BseContainer*) item, self);
-
if (expected_token == SFI_TOKEN_UNMATCHED && strcmp (scanner->next_value.v_identifier, "bse-version") == 0)
expected_token = storage_parse_bse_version (self);
-
return expected_token;
}
-
GTokenType
bse_storage_restore_item (BseStorage *self,
gpointer item)
{
GTokenType expected_token;
-
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (BSE_IS_ITEM (item), G_TOKEN_ERROR);
-
g_object_ref (self);
g_object_ref (item);
-
expected_token = sfi_rstore_parse_until (self->rstore, G_TOKEN_EOF, item,
(SfiStoreParser) item_restore_try_statement, NULL);
-
g_object_unref (item);
g_object_unref (self);
-
return expected_token;
}
-
GTokenType
bse_storage_parse_rest (BseStorage *self,
gpointer context_data,
@@ -844,15 +743,12 @@ bse_storage_parse_rest (BseStorage *self,
{
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore != NULL, G_TOKEN_ERROR);
-
return sfi_rstore_parse_until (self->rstore, GTokenType (')'), context_data, (SfiStoreParser) try_statement, user_data);
}
-
gboolean
bse_storage_check_parse_negate (BseStorage *self)
{
g_return_val_if_fail (BSE_IS_STORAGE (self), FALSE);
-
if (g_scanner_peek_next_token (bse_storage_get_scanner (self)) == '-')
{
g_scanner_get_next_token (bse_storage_get_scanner (self));
@@ -861,7 +757,6 @@ bse_storage_check_parse_negate (BseStorage *self)
else
return FALSE;
}
-
void
bse_storage_put_param (BseStorage *self,
const GValue *value,
@@ -871,10 +766,8 @@ bse_storage_put_param (BseStorage *self,
g_return_if_fail (self->wstore);
g_return_if_fail (G_IS_VALUE (value));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
-
sfi_wstore_put_param (self->wstore, value, pspec);
}
-
GTokenType
bse_storage_parse_param_value (BseStorage *self,
GValue *value,
@@ -882,10 +775,8 @@ bse_storage_parse_param_value (BseStorage *self,
{
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore, G_TOKEN_ERROR);
-
return sfi_rstore_parse_param (self->rstore, value, pspec);
}
-
void
bse_storage_put_item_link (BseStorage *self,
BseItem *from_item,
@@ -895,7 +786,6 @@ bse_storage_put_item_link (BseStorage *self,
g_return_if_fail (self->wstore);
g_return_if_fail (BSE_IS_ITEM (from_item));
g_return_if_fail (BSE_IS_ITEM (to_item));
-
if (!to_item) /* special case (1) */
{
bse_storage_puts (self, SFI_SERIAL_NULL_TOKEN);
@@ -905,20 +795,15 @@ bse_storage_put_item_link (BseStorage *self,
BseItem *tmp, *common_ancestor;
guint pbackup = 0;
gchar *upath, *epath;
-
g_return_if_fail (BSE_IS_ITEM (to_item));
common_ancestor = bse_item_common_ancestor (from_item, to_item);
g_return_if_fail (BSE_IS_CONTAINER (common_ancestor));
-
sfi_ppool_set (self->referenced_items, to_item);
-
/* figure number of parent backup levels to reach common ancestor */
for (tmp = from_item; tmp != common_ancestor; tmp = tmp->parent)
pbackup++;
-
/* path to reach to_item */
upath = bse_container_make_upath (BSE_CONTAINER (common_ancestor), to_item);
-
/* store path reference */
epath = g_strescape (upath, NULL);
bse_storage_printf (self, "(link %u \"%s\")", pbackup, epath);
@@ -926,7 +811,6 @@ bse_storage_put_item_link (BseStorage *self,
g_free (upath);
}
}
-
#ifdef DOXER
/**
* @param data user data
@@ -946,7 +830,6 @@ typedef void (*BseStorageRestoreLink) (gpointer data,
BseItem *to_item,
const gchar *error);
#endif
-
/**
* @param self valid BseStorage
* @param from_item link owner
@@ -968,22 +851,17 @@ bse_storage_parse_item_link (BseStorage *self,
GScanner *scanner;
BseStorageItemLink *ilink;
GTokenType expected_token;
-
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore, G_TOKEN_ERROR);
g_return_val_if_fail (BSE_IS_ITEM (from_item), G_TOKEN_ERROR);
g_return_val_if_fail (restore_link != NULL, G_TOKEN_ERROR);
-
scanner = bse_storage_get_scanner (self);
-
#define parse_or_goto(etoken,label) \
{ expected_token = (etoken); if (g_scanner_get_next_token (scanner) != expected_token) goto label; }
#define peek_or_goto(etoken,label) \
{ expected_token = (etoken); if (g_scanner_peek_next_token (scanner) != expected_token) \
{ g_scanner_get_next_token (scanner); goto label; } }
-
g_scanner_get_next_token (scanner);
-
bse_object_restore_start (BSE_OBJECT (from_item), self);
if (sfi_serial_check_parse_null_token (scanner))
{
@@ -992,20 +870,16 @@ bse_storage_parse_item_link (BseStorage *self,
else if (scanner->token == '(')
{
parse_or_goto (G_TOKEN_IDENTIFIER, error_parse_link);
-
if (strcmp (scanner->value.v_identifier, "link") == 0)
{
guint pbackup = 0;
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_INT)
{
g_scanner_get_next_token (scanner); /* eat int */
pbackup = scanner->value.v_int64;
}
-
parse_or_goto (G_TOKEN_STRING, error_parse_link);
peek_or_goto (GTokenType (')'), error_parse_link);
-
ilink = storage_add_item_link (self, from_item, restore_link, data, NULL);
ilink->upath = g_strdup (scanner->value.v_string);
ilink->pbackup = pbackup;
@@ -1022,17 +896,13 @@ bse_storage_parse_item_link (BseStorage *self,
expected_token = GTokenType ('(');
goto error_parse_link;
}
-
return G_TOKEN_NONE;
-
#undef parse_or_goto
#undef peek_or_goto
-
error_parse_link:
ilink = storage_add_item_link (self, from_item, restore_link, data, g_strdup ("failed to parse link path"));
return expected_token;
}
-
void
bse_storage_warn (BseStorage *self,
const gchar *format,
@@ -1040,21 +910,16 @@ bse_storage_warn (BseStorage *self,
{
va_list args;
gchar *string;
-
g_return_if_fail (BSE_IS_STORAGE (self));
-
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
-
if (self->rstore)
sfi_rstore_warn (self->rstore, "%s", string);
else
g_printerr ("BseStorage: while storing: %s", string);
-
g_free (string);
}
-
GTokenType
bse_storage_warn_skip (BseStorage *self,
const gchar *format,
@@ -1063,10 +928,8 @@ bse_storage_warn_skip (BseStorage *self,
va_list args;
gchar *string;
GTokenType token;
-
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore != NULL, G_TOKEN_ERROR);
-
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
@@ -1074,7 +937,6 @@ bse_storage_warn_skip (BseStorage *self,
g_free (string);
return token;
}
-
void
bse_storage_error (BseStorage *self,
const gchar *format,
@@ -1082,9 +944,7 @@ bse_storage_error (BseStorage *self,
{
va_list args;
gchar *string;
-
g_return_if_fail (BSE_IS_STORAGE (self));
-
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
@@ -1094,7 +954,6 @@ bse_storage_error (BseStorage *self,
g_printerr ("BseStorage: ERROR: while storing: %s\n", string);
g_free (string);
}
-
static void
bse_item_store_property (BseItem *item,
BseStorage *storage,
@@ -1116,7 +975,6 @@ bse_item_store_property (BseItem *item,
else
bse_storage_put_param (storage, value, pspec);
}
-
static void
bse_source_store_automation (BseSource *source,
BseStorage *storage,
@@ -1133,24 +991,20 @@ bse_source_store_automation (BseSource *source,
midi_channel, sfi_enum2choice (control_type, BSE_TYPE_MIDI_CONTROL_TYPE));
}
}
-
static void
store_item_properties (BseItem *item,
BseStorage *storage)
{
GParamSpec **pspecs;
guint n;
-
/* dump the object properties, starting out at the base class */
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (item), &n);
while (n--)
{
GParamSpec *pspec = pspecs[n];
-
if (sfi_pspec_check_option (pspec, "S")) /* check serializable */
{
GValue value = { 0, };
-
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (G_OBJECT (item), pspec->name, &value);
if (!g_param_value_defaults (pspec, &value) ||
@@ -1163,73 +1017,55 @@ store_item_properties (BseItem *item,
}
g_free (pspecs);
}
-
void
bse_storage_store_item (BseStorage *self, BseItem *item)
{
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
g_return_if_fail (BSE_IS_ITEM (item));
-
g_object_ref (self);
g_object_ref (item);
-
sfi_ppool_set (self->stored_items, item);
-
store_item_properties (item, self);
-
BSE_OBJECT_GET_CLASS (item)->store_private (BSE_OBJECT (item), self);
-
bse_parasite_store (BSE_OBJECT (item), self);
-
if (BSE_IS_CONTAINER (item))
bse_container_store_children ((BseContainer*) item, self);
-
g_object_unref (item);
g_object_unref (self);
}
-
void
bse_storage_store_child (BseStorage *self, BseItem *item)
{
gchar *uname;
-
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
g_return_if_fail (BSE_IS_ITEM (item));
-
uname = g_strescape (BSE_OBJECT_UNAME (item), NULL);
bse_storage_break (self);
bse_storage_printf (self, "(%s \"%s::%s\"", "container-child", G_OBJECT_TYPE_NAME (item), uname);
g_free (uname);
-
bse_storage_push_level (self);
bse_storage_store_item (self, item);
bse_storage_pop_level (self);
-
bse_storage_putc (self, ')');
}
-
void
bse_storage_putf (BseStorage *self,
gfloat vfloat)
{
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
-
sfi_wstore_putf (self->wstore, vfloat);
}
-
void
bse_storage_putd (BseStorage *self,
gdouble vdouble)
{
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
-
sfi_wstore_putd (self->wstore, vdouble);
}
-
void
bse_storage_putr (BseStorage *self,
SfiReal vreal,
@@ -1237,13 +1073,11 @@ bse_storage_putr (BseStorage *self,
{
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
-
if (hints && g_option_check (hints, "f")) /* check float option */
bse_storage_putf (self, vreal);
else
bse_storage_putd (self, vreal);
}
-
void
bse_storage_printf (BseStorage *self,
const gchar *format,
@@ -1251,24 +1085,18 @@ bse_storage_printf (BseStorage *self,
{
gchar *buffer;
va_list args;
-
g_return_if_fail (BSE_IS_STORAGE (self));
g_return_if_fail (self->wstore);
g_return_if_fail (format != NULL);
-
const gchar *ldir = g_printf_find_localised_directive (format);
if (ldir)
g_warning ("%s: encountered localised directive \"%s\" in format string: \"%s\"", G_STRFUNC, ldir, format);
-
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
va_end (args);
-
bse_storage_puts (self, buffer);
-
g_free (buffer);
}
-
void
bse_storage_put_xinfos (BseStorage *self,
gchar **xinfos)
@@ -1296,7 +1124,6 @@ bse_storage_put_xinfos (BseStorage *self,
bse_storage_printf (self, "#f");
g_strfreev (xinfos);
}
-
GTokenType
bse_storage_parse_xinfos (BseStorage *self,
gchar ***xinfosp)
@@ -1331,7 +1158,6 @@ bse_storage_parse_xinfos (BseStorage *self,
else
return GTokenType ('(');
}
-
static GTokenType
parse_dblock_data_handle (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1342,19 +1168,15 @@ parse_dblock_data_handle (BseStorage *self,
GScanner *scanner = bse_storage_get_scanner (self);
BseStorageDBlock *dblock;
gulong id;
-
parse_or_return (scanner, G_TOKEN_INT);
id = scanner->value.v_int64;
-
parse_or_return (scanner, ')');
-
dblock = bse_storage_get_dblock (self, id);
if (!dblock)
{
bse_storage_error (self, "failed to lookup internal data handle with id: %lu", id);
return G_TOKEN_ERROR;
}
-
*data_handle_p = gsl_data_handle_ref (dblock->dhandle); /* fake "creating" a data handle */
if (n_channels_p)
*n_channels_p = dblock->n_channels;
@@ -1362,10 +1184,8 @@ parse_dblock_data_handle (BseStorage *self,
*mix_freq_p = dblock->mix_freq;
if (osc_freq_p)
*osc_freq_p = dblock->osc_freq;
-
return G_TOKEN_NONE;
}
-
typedef struct {
GslDataHandle *dhandle;
guint opened : 1;
@@ -1373,7 +1193,6 @@ typedef struct {
BseStorage *storage;
guint length;
} WStoreDHandle;
-
static void
wstore_data_handle_destroy (gpointer data)
{
@@ -1383,7 +1202,6 @@ wstore_data_handle_destroy (gpointer data)
gsl_data_handle_unref (wh->dhandle);
g_free (wh);
}
-
static gint /* -errno || length */
wstore_data_handle_reader (gpointer data,
void *buffer,
@@ -1391,7 +1209,6 @@ wstore_data_handle_reader (gpointer data,
{
WStoreDHandle *wh = (WStoreDHandle*) data;
GslLong n;
-
if (!wh->opened)
{
BseErrorType error = gsl_data_handle_open (wh->dhandle);
@@ -1402,11 +1219,9 @@ wstore_data_handle_reader (gpointer data,
}
wh->opened = TRUE;
}
-
/* catch end */
if (wh->length >= gsl_data_handle_length (wh->dhandle))
return 0;
-
do
n = gsl_data_handle_read (wh->dhandle, wh->length, blength / sizeof (gfloat), (float*) buffer);
while (n < 0 && errno == EINTR);
@@ -1416,10 +1231,8 @@ wstore_data_handle_reader (gpointer data,
return -EIO;
}
wh->length += n;
-
return gsl_conv_from_float_clip (GslWaveFormatType (wh->format), wh->byte_order, (const float*) buffer, buffer, n);
}
-
void
bse_storage_put_data_handle (BseStorage *self,
guint significant_bits,
@@ -1429,7 +1242,6 @@ bse_storage_put_data_handle (BseStorage *self,
g_return_if_fail (self->wstore);
g_return_if_fail (dhandle != NULL);
g_return_if_fail (GSL_DATA_HANDLE_OPENED (dhandle));
-
if (BSE_STORAGE_DBLOCK_CONTAINED (self))
{
/* stored as binary data block in memory for undo storage */
@@ -1438,7 +1250,6 @@ bse_storage_put_data_handle (BseStorage *self,
bse_storage_printf (self, "(%s %lu)", g_quark_to_string (quark_dblock_data_handle), id);
return;
}
-
GslDataHandle *test_handle, *tmp_handle = dhandle;
do /* skip comment or cache handles */
{
@@ -1471,7 +1282,6 @@ bse_storage_put_data_handle (BseStorage *self,
format = GSL_WAVE_FORMAT_SIGNED_8;
else
format = GSL_WAVE_FORMAT_SIGNED_16;
-
bse_storage_break (self);
bse_storage_printf (self,
"(%s %u %s %s",
@@ -1485,7 +1295,6 @@ bse_storage_put_data_handle (BseStorage *self,
bse_storage_putf (self, gsl_data_handle_osc_freq (dhandle));
bse_storage_push_level (self);
bse_storage_break (self);
-
WStoreDHandle *wh = g_new0 (WStoreDHandle, 1);
wh->dhandle = gsl_data_handle_ref (dhandle);
wh->format = format;
@@ -1494,11 +1303,9 @@ bse_storage_put_data_handle (BseStorage *self,
wh->storage = self;
sfi_wstore_put_binary (self->wstore, wstore_data_handle_reader, wh, wstore_data_handle_destroy);
bse_storage_pop_level (self);
-
bse_storage_putc (self, ')');
}
}
-
static GTokenType
parse_raw_data_handle (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1511,22 +1318,18 @@ parse_raw_data_handle (BseStorage *self,
gfloat mix_freq, osc_freq;
SfiNum offset, length;
GTokenType token;
-
parse_or_return (scanner, G_TOKEN_INT);
n_channels = scanner->value.v_int64;
if (n_channels <= 0 || n_channels > 256)
return bse_storage_warn_skip (self, "invalid number of channels: %u", n_channels);
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER);
GslWaveFormatType format = gsl_wave_format_from_string (scanner->value.v_identifier);
if (format == GSL_WAVE_FORMAT_NONE)
return bse_storage_warn_skip (self, "unknown format for data handle: %s", scanner->value.v_identifier);
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER);
byte_order = gsl_byte_order_from_string (scanner->value.v_identifier);
if (!byte_order)
return bse_storage_warn_skip (self, "unknown byte-order for data handle: %s", scanner->value.v_identifier);
-
g_scanner_get_next_token (scanner);
if (scanner->token == G_TOKEN_INT)
mix_freq = scanner->value.v_int64;
@@ -1534,7 +1337,6 @@ parse_raw_data_handle (BseStorage *self,
mix_freq = scanner->value.v_float;
else
return G_TOKEN_FLOAT;
-
g_scanner_get_next_token (scanner);
if (scanner->token == G_TOKEN_INT)
osc_freq = scanner->value.v_int64;
@@ -1542,17 +1344,13 @@ parse_raw_data_handle (BseStorage *self,
osc_freq = scanner->value.v_float;
else
return G_TOKEN_FLOAT;
-
if (osc_freq <= 0 || mix_freq < 4000 || osc_freq >= mix_freq / 2)
return bse_storage_warn_skip (self, "invalid oscillating/mixing frequencies: %.7g/%.7g", osc_freq, mix_freq);
-
token = sfi_rstore_parse_binary (self->rstore, &offset, &length);
if (token != G_TOKEN_NONE)
return token;
length /= gsl_wave_format_byte_width (format);
-
parse_or_return (scanner, ')');
-
if (length < 1)
{
bse_storage_warn (self, "encountered empty data handle");
@@ -1571,7 +1369,6 @@ parse_raw_data_handle (BseStorage *self,
*osc_freq_p = osc_freq;
return G_TOKEN_NONE;
}
-
static GTokenType
parse_vorbis_data_handle (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1581,7 +1378,6 @@ parse_vorbis_data_handle (BseStorage *self,
{
GScanner *scanner = bse_storage_get_scanner (self);
GTokenType token;
-
gfloat osc_freq;
g_scanner_get_next_token (scanner);
if (scanner->token == G_TOKEN_INT)
@@ -1594,14 +1390,11 @@ parse_vorbis_data_handle (BseStorage *self,
return bse_storage_warn_skip (self, "invalid oscillating frequency: %.7g", osc_freq);
if (osc_freq_p)
*osc_freq_p = osc_freq;
-
SfiNum offset, length;
token = sfi_rstore_parse_zbinary (self->rstore, &offset, &length);
if (token != G_TOKEN_NONE)
return token;
-
parse_or_return (scanner, ')');
-
if (length < 1)
{
bse_storage_warn (self, "encountered empty data handle");
@@ -1619,7 +1412,6 @@ parse_vorbis_data_handle (BseStorage *self,
}
return G_TOKEN_NONE;
}
-
gboolean
bse_storage_match_data_handle (BseStorage *self,
GQuark quark)
@@ -1632,7 +1424,6 @@ bse_storage_match_data_handle (BseStorage *self,
return TRUE;
return FALSE;
}
-
static GTokenType
parse_data_handle_trampoline (BseStorage *self,
gboolean statement_opened,
@@ -1643,7 +1434,6 @@ parse_data_handle_trampoline (BseStorage *self,
{
GScanner *scanner = bse_storage_get_scanner (self);
GQuark quark;
-
*data_handle_p = NULL;
if (n_channels_p)
*n_channels_p = 0;
@@ -1651,28 +1441,21 @@ parse_data_handle_trampoline (BseStorage *self,
*mix_freq_p = 0;
if (osc_freq_p)
*osc_freq_p = 0;
-
if (!statement_opened)
parse_or_return (scanner, '(');
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER);
-
quark = g_quark_try_string (scanner->value.v_identifier);
if (BSE_STORAGE_DBLOCK_CONTAINED (self) && quark == quark_dblock_data_handle)
return parse_dblock_data_handle (self, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
-
if (quark == quark_raw_data_handle)
return parse_raw_data_handle (self, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
else if (quark == quark_vorbis_data_handle)
return parse_vorbis_data_handle (self, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
-
if (BSE_STORAGE_COMPAT (self, 0, 5, 1) && quark == quark_bse_storage_binary_v0)
return compat_parse_data_handle (self, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
-
bse_storage_error (self, "unknown data handle keyword: %s", scanner->value.v_identifier);
return G_TOKEN_ERROR;
}
-
GTokenType
bse_storage_parse_data_handle (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1683,10 +1466,8 @@ bse_storage_parse_data_handle (BseStorage *self,
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore, G_TOKEN_ERROR);
g_return_val_if_fail (data_handle_p != NULL, G_TOKEN_ERROR);
-
return parse_data_handle_trampoline (self, FALSE, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
}
-
GTokenType
bse_storage_parse_data_handle_rest (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1697,10 +1478,8 @@ bse_storage_parse_data_handle_rest (BseStorage *self,
g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
g_return_val_if_fail (self->rstore, G_TOKEN_ERROR);
g_return_val_if_fail (data_handle_p != NULL, G_TOKEN_ERROR);
-
return parse_data_handle_trampoline (self, TRUE, data_handle_p, n_channels_p, mix_freq_p, osc_freq_p);
}
-
BseErrorType
bse_storage_flush_fd (BseStorage *self,
gint fd)
@@ -1708,14 +1487,10 @@ bse_storage_flush_fd (BseStorage *self,
g_return_val_if_fail (BSE_IS_STORAGE (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (self->wstore, BSE_ERROR_INTERNAL);
g_return_val_if_fail (fd >= 0, BSE_ERROR_INTERNAL);
-
bse_storage_break (self);
-
gint nerrno = sfi_wstore_flush_fd (self->wstore, fd);
-
return bse_error_from_errno (-nerrno, BSE_ERROR_FILE_WRITE_FAILED);
}
-
void
bse_storage_compat_dhreset (BseStorage *self)
{
@@ -1723,28 +1498,24 @@ bse_storage_compat_dhreset (BseStorage *self)
self->mix_freq = 44100;
self->osc_freq = 440;
}
-
void
bse_storage_compat_dhmixf (BseStorage *self,
gfloat mix_freq)
{
self->mix_freq = mix_freq;
}
-
void
bse_storage_compat_dhoscf (BseStorage *self,
gfloat osc_freq)
{
self->osc_freq = osc_freq;
}
-
void
bse_storage_compat_dhchannels (BseStorage *self,
guint n_channels)
{
self->n_channels = n_channels;
}
-
static GTokenType
compat_parse_data_handle (BseStorage *self,
GslDataHandle **data_handle_p,
@@ -1756,10 +1527,8 @@ compat_parse_data_handle (BseStorage *self,
GScanner *scanner = bse_storage_get_scanner (self);
GTokenType token;
gchar *string;
-
parse_or_return (scanner, G_TOKEN_INT);
offset = scanner->value.v_int64;
-
parse_or_return (scanner, G_TOKEN_IDENTIFIER);
string = scanner->value.v_identifier;
if (string[0] == 'L' || string[0] == 'l')
@@ -1773,7 +1542,6 @@ compat_parse_data_handle (BseStorage *self,
if (string)
{
gchar *f = NULL;
-
bytes_per_value = strtol (string + 2, &f, 10);
if ((bytes_per_value != 1 && bytes_per_value != 2 && bytes_per_value != 4) ||
(f && *f != 0))
@@ -1783,12 +1551,10 @@ compat_parse_data_handle (BseStorage *self,
return bse_storage_warn_skip (self,
"unknown value type `%s' in binary data definition",
scanner->value.v_identifier);
-
parse_or_return (scanner, G_TOKEN_INT);
length = scanner->value.v_int64;
if (length < bytes_per_value)
return G_TOKEN_INT;
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_INT)
{
g_scanner_get_next_token (scanner);
@@ -1798,13 +1564,10 @@ compat_parse_data_handle (BseStorage *self,
}
else
vlength = length / bytes_per_value;
-
parse_or_return (scanner, ')');
-
token = sfi_rstore_ensure_bin_offset (self->rstore);
if (token != G_TOKEN_NONE)
return token;
-
if (n_channels_p)
*n_channels_p = self->n_channels;
if (mix_freq_p)
diff --git a/bse/bsestorage.hh b/bse/bsestorage.hh
index 504eb42..7714667 100644
--- a/bse/bsestorage.hh
+++ b/bse/bsestorage.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_STORAGE_H__
#define __BSE_STORAGE_H__
-
#include <bse/bseobject.hh>
#include <bse/gsldefs.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_STORAGE (BSE_TYPE_ID (BseStorage))
#define BSE_STORAGE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_STORAGE, BseStorage))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_STORAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_STORAGE))
#define BSE_IS_STORAGE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_STORAGE))
#define BSE_STORAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_STORAGE, BseStorageClass))
-
-
/* --- macros --- */
#define BSE_STORAGE_VERSION(self, vmaj, min, vmic) ( /* whether file uses >=vARGS features */ \
BSE_VERSION_CMP (self->major_version, self->minor_version, self->micro_version, vmaj, min, vmic) >= 0)
@@ -31,13 +26,9 @@ typedef enum /*< skip >*/
} BseStorageMode;
#define BSE_STORAGE_FLAGS_USHIFT (BSE_OBJECT_FLAGS_USHIFT + 2)
#define BSE_STORAGE_MODE_MASK (BSE_STORAGE_SELF_CONTAINED | BSE_STORAGE_DBLOCK_CONTAINED)
-
-
/* --- compatibility --- */
#define bse_storage_scanner_parse_or_return sfi_scanner_parse_or_return
#define bse_storage_scanner_peek_or_return sfi_scanner_peek_or_return
-
-
/* --- BseStorage --- */
typedef struct _BseStorageDBlock BseStorageDBlock;
typedef struct _BseStorageItemLink BseStorageItemLink;
@@ -74,8 +65,6 @@ struct _BseStorageClass
{
BseObjectClass parent_class;
};
-
-
/* --- compatibility file parsing --- */
void bse_storage_compat_dhreset (BseStorage *self);
void bse_storage_compat_dhmixf (BseStorage *self,
@@ -84,8 +73,6 @@ void bse_storage_compat_dhoscf (BseStorage *self,
gfloat osc_freq);
void bse_storage_compat_dhchannels (BseStorage *self,
guint n_channels);
-
-
/* --- prototypes -- */
void bse_storage_reset (BseStorage *self);
void bse_storage_prepare_write (BseStorage *self,
@@ -104,8 +91,6 @@ void bse_storage_store_item (BseStorage *self,
void bse_storage_store_child (BseStorage *self,
BseItem *item);
const gchar* bse_storage_item_get_compat_type (BseItem *item);
-
-
/* --- writing --- */
void bse_storage_putf (BseStorage *self,
gfloat vfloat);
@@ -130,8 +115,6 @@ void bse_storage_put_xinfos (BseStorage *self,
gchar **xinfos);
BseErrorType bse_storage_flush_fd (BseStorage *self,
gint fd);
-
-
/* --- reading --- */
void bse_storage_error (BseStorage *self,
const gchar *format,
@@ -171,8 +154,6 @@ GTokenType bse_storage_parse_rest (BseStorage *self,
BseTryStatement try_statement,
gpointer user_data);
gboolean bse_storage_check_parse_negate (BseStorage *self);
-
-
/* --- short-hands --- */
#define bse_storage_get_scanner(s) ((s)->rstore->scanner)
#define bse_storage_unexp_token(s,et) sfi_rstore_unexp_token ((s)->rstore, et)
@@ -181,8 +162,5 @@ gboolean bse_storage_check_parse_negate (BseStorage *self);
#define bse_storage_break(s) sfi_wstore_break ((s)->wstore)
#define bse_storage_putc(s,c) sfi_wstore_putc ((s)->wstore, c)
#define bse_storage_puts(s,b) sfi_wstore_puts ((s)->wstore, b)
-
-
G_END_DECLS
-
#endif /* __BSE_STORAGE_H__ */
diff --git a/bse/bsesubiport.cc b/bse/bsesubiport.cc
index 014eab1..d156d7f 100644
--- a/bse/bsesubiport.cc
+++ b/bse/bsesubiport.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesubiport.hh"
-
#include "bsecategories.hh"
#include "bsesnet.hh"
-
#include <string.h>
-
/* --- parameters --- */
enum
{
@@ -13,19 +10,13 @@ enum
/* don't add properties after here */
PROP_IPORT_NAME
};
-
-
/* --- prototypes --- */
static void bse_sub_iport_update_modules (BseSubIPort *self,
const gchar *old_name,
const gchar *new_name,
guint port);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_sub_iport_init (BseSubIPort *self)
@@ -35,7 +26,6 @@ bse_sub_iport_init (BseSubIPort *self)
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
self->input_ports[i] = g_strdup_printf ("synth_in_%u", i + 1);
}
-
static void
bse_sub_iport_finalize (GObject *object)
{
@@ -48,7 +38,6 @@ bse_sub_iport_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_sub_iport_set_property (GObject *object,
guint param_id,
@@ -57,7 +46,6 @@ bse_sub_iport_set_property (GObject *object,
{
BseSubIPort *self = BSE_SUB_IPORT (object);
BseItem *item = BSE_ITEM (self);
-
switch (param_id)
{
guint indx, n;
@@ -87,7 +75,6 @@ bse_sub_iport_set_property (GObject *object,
}
}
}
-
static void
bse_sub_iport_get_property (GObject *object,
guint param_id,
@@ -95,7 +82,6 @@ bse_sub_iport_get_property (GObject *object,
GParamSpec *pspec)
{
BseSubIPort *self = BSE_SUB_IPORT (object);
-
switch (param_id)
{
guint indx, n;
@@ -115,22 +101,18 @@ bse_sub_iport_get_property (GObject *object,
break;
}
}
-
static void
bse_sub_iport_set_parent (BseItem *item,
BseItem *parent)
{
BseSubIPort *self = BSE_SUB_IPORT (item);
guint i;
-
/* remove port name from old parent */
if (item->parent)
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
bse_snet_iport_name_unregister (BSE_SNET (item->parent), self->input_ports[i]);
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
-
/* add port name to new parent */
if (item->parent)
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
@@ -146,24 +128,20 @@ bse_sub_iport_set_parent (BseItem *item,
}
}
}
-
static void
sub_iport_process (BseModule *module,
guint n_values)
{
guint i, n = BSE_MODULE_N_OSTREAMS (module);
-
for (i = 0; i < n; i++)
BSE_MODULE_OBUFFER (module, i) = (gfloat*) BSE_MODULE_IBUFFER (module, i);
}
-
static void
bse_sub_iport_context_create (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSubIPort *self = BSE_SUB_IPORT (source);
-
if (!BSE_SOURCE_GET_CLASS (self)->engine_class)
{
BseModuleClass module_class = {
@@ -179,17 +157,13 @@ bse_sub_iport_context_create (BseSource *source,
bse_source_class_cache_engine_class (BSE_SOURCE_GET_CLASS (self), &module_class);
}
BseModule *module = bse_module_new (BSE_SOURCE_GET_CLASS (self)->engine_class, NULL);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_omodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_sub_iport_context_connect (BseSource *source,
guint context_handle,
@@ -200,14 +174,11 @@ bse_sub_iport_context_connect (BseSource *source,
BseSNet *snet = BSE_SNET (item->parent);
BseModule *module = bse_source_get_context_omodule (source, context_handle);
guint i;
-
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
bse_snet_set_iport_dest (snet, self->input_ports[i], context_handle, module, i, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_sub_iport_context_dismiss (BseSource *source,
guint context_handle,
@@ -217,14 +188,11 @@ bse_sub_iport_context_dismiss (BseSource *source,
BseItem *item = BSE_ITEM (self);
BseSNet *snet = BSE_SNET (item->parent);
guint i;
-
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
bse_snet_set_iport_dest (snet, self->input_ports[i], context_handle, NULL, i, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
static void
bse_sub_iport_update_modules (BseSubIPort *self,
const gchar *old_name,
@@ -236,9 +204,7 @@ bse_sub_iport_update_modules (BseSubIPort *self,
BseSource *source = BSE_SOURCE (self);
BseTrans *trans = bse_trans_open ();
guint *cids, n, i;
-
g_return_if_fail (BSE_SOURCE_PREPARED (self));
-
cids = bse_source_context_ids (source, &n);
for (i = 0; i < n; i++)
{
@@ -249,7 +215,6 @@ bse_sub_iport_update_modules (BseSubIPort *self,
g_free (cids);
bse_trans_commit (trans);
}
-
static void
bse_sub_iport_class_init (BseSubIPortClass *klass)
{
@@ -258,30 +223,23 @@ bse_sub_iport_class_init (BseSubIPortClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint i, channel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_sub_iport_set_property;
gobject_class->get_property = bse_sub_iport_get_property;
gobject_class->finalize = bse_sub_iport_finalize;
-
item_class->set_parent = bse_sub_iport_set_parent;
-
source_class->context_create = bse_sub_iport_context_create;
source_class->context_connect = bse_sub_iport_context_connect;
source_class->context_dismiss = bse_sub_iport_context_dismiss;
-
for (i = 0; i < BSE_SUB_IPORT_N_PORTS; i++)
{
gchar *ident, *label, *value;
-
ident = g_strdup_printf ("output-%u", i + 1);
label = g_strdup_printf (_("Virtual input %u"), i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, label, NULL);
g_assert (channel_id == i);
g_free (ident);
g_free (label);
-
ident = g_strdup_printf ("in_port_%u", i + 1);
label = g_strdup_printf (_("Input Port %u"), i + 1);
value = g_strdup_printf ("synth_in_%u", i + 1);
@@ -295,18 +253,15 @@ bse_sub_iport_class_init (BseSubIPortClass *klass)
g_free (value);
}
}
-
BSE_BUILTIN_TYPE (BseSubIPort)
{
static const GTypeInfo type_info = {
sizeof (BseSubIPortClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_sub_iport_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSubIPort),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_sub_iport_init,
diff --git a/bse/bsesubiport.hh b/bse/bsesubiport.hh
index 90bbb79..c67ca67 100644
--- a/bse/bsesubiport.hh
+++ b/bse/bsesubiport.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SUB_IPORT_H__
#define __BSE_SUB_IPORT_H__
-
#include <bse/bsesource.hh>
#include <bse/bseengine.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SUB_IPORT (BSE_TYPE_ID (BseSubIPort))
#define BSE_SUB_IPORT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SUB_IPORT, BseSubIPort))
@@ -15,21 +12,17 @@ G_BEGIN_DECLS
#define BSE_IS_IPORT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SUB_IPORT))
#define BSE_SUB_IPORT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SUB_IPORT, BseSubIPortClass))
#define BSE_SUB_IPORT_N_PORTS (4)
-
/* --- BseSubIPort module --- */
typedef struct _BseSubIPort BseSubIPort;
typedef struct _BseSubIPortClass BseSubIPortClass;
struct _BseSubIPort
{
BseSource parent_object;
-
gchar **input_ports;
};
struct _BseSubIPortClass
{
BseSourceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_SUB_IPORT_H__ */
diff --git a/bse/bsesuboport.cc b/bse/bsesuboport.cc
index 3c43698..b1cafdb 100644
--- a/bse/bsesuboport.cc
+++ b/bse/bsesuboport.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesuboport.hh"
-
#include "bsecategories.hh"
#include "bsesnet.hh"
-
#include <string.h>
-
/* --- parameters --- */
enum
{
@@ -13,19 +10,13 @@ enum
/* don't add properties after here */
PROP_OPORT_NAME
};
-
-
/* --- prototypes --- */
static void bse_sub_oport_update_modules (BseSubOPort *self,
const gchar *old_name,
const gchar *new_name,
guint port);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_sub_oport_init (BseSubOPort *self)
@@ -35,7 +26,6 @@ bse_sub_oport_init (BseSubOPort *self)
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
self->output_ports[i] = g_strdup_printf ("synth_out_%u", i + 1);
}
-
static void
bse_sub_oport_finalize (GObject *object)
{
@@ -48,7 +38,6 @@ bse_sub_oport_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_sub_oport_set_property (GObject *object,
guint param_id,
@@ -57,7 +46,6 @@ bse_sub_oport_set_property (GObject *object,
{
BseSubOPort *self = BSE_SUB_OPORT (object);
BseItem *item = BSE_ITEM (self);
-
switch (param_id)
{
guint indx, n;
@@ -87,7 +75,6 @@ bse_sub_oport_set_property (GObject *object,
}
}
}
-
static void
bse_sub_oport_get_property (GObject *object,
guint param_id,
@@ -95,7 +82,6 @@ bse_sub_oport_get_property (GObject *object,
GParamSpec *pspec)
{
BseSubOPort *self = BSE_SUB_OPORT (object);
-
switch (param_id)
{
guint indx, n;
@@ -115,22 +101,18 @@ bse_sub_oport_get_property (GObject *object,
break;
}
}
-
static void
bse_sub_oport_set_parent (BseItem *item,
BseItem *parent)
{
BseSubOPort *self = BSE_SUB_OPORT (item);
guint i;
-
/* remove port name from old parent */
if (item->parent)
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
bse_snet_oport_name_unregister (BSE_SNET (item->parent), self->output_ports[i]);
-
/* chain parent class' handler */
BSE_ITEM_CLASS (parent_class)->set_parent (item, parent);
-
/* add port name to new parent */
if (item->parent)
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
@@ -139,7 +121,6 @@ bse_sub_oport_set_parent (BseItem *item,
if (strcmp (name, self->output_ports[i]) != 0)
{
gchar *string;
-
g_free (self->output_ports[i]);
self->output_ports[i] = g_strdup (name);
string = g_strdup_printf ("out_port_%u", i + 1);
@@ -148,24 +129,20 @@ bse_sub_oport_set_parent (BseItem *item,
}
}
}
-
static void
sub_oport_process (BseModule *module,
guint n_values)
{
guint i, n = BSE_MODULE_N_ISTREAMS (module);
-
for (i = 0; i < n; i++)
BSE_MODULE_OBUFFER (module, i) = (gfloat*) BSE_MODULE_IBUFFER (module, i);
}
-
static void
bse_sub_oport_context_create (BseSource *source,
guint context_handle,
BseTrans *trans)
{
BseSubOPort *self = BSE_SUB_OPORT (source);
-
if (!BSE_SOURCE_GET_CLASS (self)->engine_class)
{
BseModuleClass module_class = {
@@ -181,17 +158,13 @@ bse_sub_oport_context_create (BseSource *source,
bse_source_class_cache_engine_class (BSE_SOURCE_GET_CLASS (self), &module_class);
}
BseModule *module = bse_module_new (BSE_SOURCE_GET_CLASS (self)->engine_class, NULL);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_imodule (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_sub_oport_context_connect (BseSource *source,
guint context_handle,
@@ -202,14 +175,11 @@ bse_sub_oport_context_connect (BseSource *source,
BseSNet *snet = BSE_SNET (item->parent);
BseModule *module = bse_source_get_context_imodule (source, context_handle);
guint i;
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
bse_snet_set_oport_src (snet, self->output_ports[i], context_handle, module, i, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_sub_oport_context_dismiss (BseSource *source,
guint context_handle,
@@ -219,14 +189,11 @@ bse_sub_oport_context_dismiss (BseSource *source,
BseItem *item = BSE_ITEM (self);
BseSNet *snet = BSE_SNET (item->parent);
guint i;
-
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
bse_snet_set_oport_src (snet, self->output_ports[i], context_handle, NULL, i, trans);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
static void
bse_sub_oport_update_modules (BseSubOPort *self,
const gchar *old_name,
@@ -238,9 +205,7 @@ bse_sub_oport_update_modules (BseSubOPort *self,
BseSource *source = BSE_SOURCE (self);
BseTrans *trans = bse_trans_open ();
guint *cids, n, i;
-
g_return_if_fail (BSE_SOURCE_PREPARED (self));
-
cids = bse_source_context_ids (source, &n);
for (i = 0; i < n; i++)
{
@@ -259,30 +224,23 @@ bse_sub_oport_class_init (BseSubOPortClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint i, channel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_sub_oport_set_property;
gobject_class->get_property = bse_sub_oport_get_property;
gobject_class->finalize = bse_sub_oport_finalize;
-
item_class->set_parent = bse_sub_oport_set_parent;
-
source_class->context_create = bse_sub_oport_context_create;
source_class->context_connect = bse_sub_oport_context_connect;
source_class->context_dismiss = bse_sub_oport_context_dismiss;
-
for (i = 0; i < BSE_SUB_OPORT_N_PORTS; i++)
{
gchar *ident, *label, *value;
-
ident = g_strdup_printf ("input-%u", i + 1);
label = g_strdup_printf (_("Virtual output %u"), i + 1);
channel_id = bse_source_class_add_ichannel (source_class, ident, label, NULL);
g_assert (channel_id == i);
g_free (ident);
g_free (label);
-
ident = g_strdup_printf ("out_port_%u", i + 1);
label = g_strdup_printf (_("Output Port %u"), i + 1);
value = g_strdup_printf ("synth_out_%u", i + 1);
@@ -296,18 +254,15 @@ bse_sub_oport_class_init (BseSubOPortClass *klass)
g_free (value);
}
}
-
BSE_BUILTIN_TYPE (BseSubOPort)
{
static const GTypeInfo type_info = {
sizeof (BseSubOPortClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_sub_oport_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSubOPort),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_sub_oport_init,
diff --git a/bse/bsesuboport.hh b/bse/bsesuboport.hh
index 0820334..e3b0efc 100644
--- a/bse/bsesuboport.hh
+++ b/bse/bsesuboport.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SUB_OPORT_H__
#define __BSE_SUB_OPORT_H__
-
#include <bse/bsesource.hh>
#include <bse/bseengine.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SUB_OPORT (BSE_TYPE_ID (BseSubOPort))
#define BSE_SUB_OPORT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SUB_OPORT, BseSubOPort))
@@ -14,9 +11,7 @@ G_BEGIN_DECLS
#define BSE_IS_OPORT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SUB_OPORT))
#define BSE_IS_OPORT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SUB_OPORT))
#define BSE_SUB_OPORT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SUB_OPORT, BseSubOPortClass))
-
#define BSE_SUB_OPORT_N_PORTS (4)
-
/* --- BseSubOPort module --- */
typedef struct _BseSubOPort BseSubOPort;
typedef struct _BseSubOPortClass BseSubOPortClass;
@@ -29,7 +24,5 @@ struct _BseSubOPortClass
{
BseSourceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_SUB_OPORT_H__ */
diff --git a/bse/bsesubsynth.cc b/bse/bsesubsynth.cc
index b878fe5..4eabecc 100644
--- a/bse/bsesubsynth.cc
+++ b/bse/bsesubsynth.cc
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesubsynth.hh"
-
#include "bsecategories.hh"
#include "bsecsynth.hh"
#include "bseproject.hh"
#include "bsemidireceiver.hh"
#include "bseengine.hh"
-
#include <string.h>
-
-
/* --- parameters --- */
enum
{
@@ -19,8 +15,6 @@ enum
PARAM_IPORT_NAME,
PARAM_OPORT_NAME
};
-
-
/* --- prototypes --- */
static void bse_sub_synth_init (BseSubSynth *scard);
static void bse_sub_synth_class_init (BseSubSynthClass *klass);
@@ -48,24 +42,18 @@ static void bse_sub_synth_update_port_contexts (BseSubSynth *self,
const gchar *new_name,
gboolean is_input,
guint port);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseSubSynth)
{
static const GTypeInfo sub_synth_info = {
sizeof (BseSubSynthClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_sub_synth_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSubSynth),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_sub_synth_init,
@@ -80,39 +68,31 @@ BSE_BUILTIN_TYPE (BseSubSynth)
bse_categories_register_stock_module (N_("/Virtualization/Virtual Sub Synth"), type, virtual_synth_pixstream);
return type;
}
-
static void
bse_sub_synth_init (BseSubSynth *self)
{
guint i;
-
self->snet = NULL;
self->null_shortcut = FALSE;
-
self->input_ports = g_new (gchar*, BSE_SOURCE_N_ICHANNELS (self));
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
self->input_ports[i] = g_strdup_printf ("synth_in_%u", i + 1);
-
self->output_ports = g_new (gchar*, BSE_SOURCE_N_OCHANNELS (self));
for (i = 0; i < BSE_SOURCE_N_OCHANNELS (self); i++)
self->output_ports[i] = g_strdup_printf ("synth_out_%u", i + 1);
}
-
static void
bse_sub_synth_dispose (GObject *object)
{
BseSubSynth *self = BSE_SUB_SYNTH (object);
-
if (self->snet)
{
g_object_unref (self->snet);
self->snet = NULL;
}
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_sub_synth_finalize (GObject *object)
{
@@ -127,7 +107,6 @@ bse_sub_synth_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_sub_synth_get_candidates (BseItem *item,
guint param_id,
@@ -146,24 +125,20 @@ bse_sub_synth_get_candidates (BseItem *item,
break;
}
}
-
static gboolean
find_name (BseSubSynth *self,
const gchar *name,
gboolean is_input)
{
guint i;
-
for (i = 0; i < (is_input ? BSE_SOURCE_N_ICHANNELS (self) : BSE_SOURCE_N_OCHANNELS (self)); i++)
{
gchar *test = is_input ? self->input_ports[i] : self->output_ports[i];
-
if (test && strcmp (test, name) == 0)
return TRUE;
}
return FALSE;
}
-
static gchar*
dup_name_unique (BseSubSynth *self,
const gchar *tmpl,
@@ -171,7 +146,6 @@ dup_name_unique (BseSubSynth *self,
{
gchar *name = g_strdup (tmpl);
guint i = 1;
-
while (find_name (self, name, is_input))
{
g_free (name);
@@ -179,7 +153,6 @@ dup_name_unique (BseSubSynth *self,
}
return name;
}
-
static void
sub_synth_uncross_snet (BseItem *owner,
BseItem *ref_item)
@@ -187,7 +160,6 @@ sub_synth_uncross_snet (BseItem *owner,
BseSubSynth *self = BSE_SUB_SYNTH (owner);
bse_item_set (self, "snet", NULL, NULL);
}
-
static void
bse_sub_synth_set_property (GObject *object,
guint param_id,
@@ -195,7 +167,6 @@ bse_sub_synth_set_property (GObject *object,
GParamSpec *pspec)
{
BseSubSynth *self = BSE_SUB_SYNTH (object);
-
switch (param_id)
{
guint indx, n;
@@ -249,7 +220,6 @@ bse_sub_synth_set_property (GObject *object,
}
}
}
-
static void
bse_sub_synth_get_property (GObject *object,
guint param_id,
@@ -257,7 +227,6 @@ bse_sub_synth_get_property (GObject *object,
GParamSpec *pspec)
{
BseSubSynth *self = BSE_SUB_SYNTH (object);
-
switch (param_id)
{
guint indx, n;
@@ -288,29 +257,23 @@ bse_sub_synth_get_property (GObject *object,
break;
}
}
-
void
bse_sub_synth_set_midi_channel (BseSubSynth *self,
guint midi_channel)
{
g_return_if_fail (BSE_IS_SUB_SYNTH (self));
-
self->midi_channel = midi_channel;
}
-
void
bse_sub_synth_set_null_shortcut (BseSubSynth *self,
gboolean enabled)
{
g_return_if_fail (BSE_IS_SUB_SYNTH (self));
-
self->null_shortcut = enabled != FALSE;
}
-
typedef struct {
guint synth_context_handle;
} ModData;
-
static void
bse_sub_synth_context_create (BseSource *source,
guint context_handle,
@@ -324,7 +287,6 @@ bse_sub_synth_context_create (BseSource *source,
BseModule *imodule = bse_module_new_virtual (BSE_SOURCE_N_ICHANNELS (self), mdata_in, g_free);
BseModule *omodule = bse_module_new_virtual (BSE_SOURCE_N_OCHANNELS (self), mdata_out, g_free);
guint foreign_context_handle = 0, shortcut = FALSE;
-
/* create new context for foreign synth */
if (snet && g_slist_find (recursion_stack, source))
{
@@ -344,29 +306,23 @@ bse_sub_synth_context_create (BseSource *source,
}
else
shortcut = self->null_shortcut;
-
mdata_in->synth_context_handle = foreign_context_handle;
mdata_out->synth_context_handle = foreign_context_handle;
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_imodule (source, context_handle, imodule);
bse_source_set_context_omodule (source, context_handle, omodule);
-
/* commit modules to engine */
bse_trans_add (trans, bse_job_integrate (imodule));
bse_trans_add (trans, bse_job_integrate (omodule));
-
if (shortcut)
{
guint i;
for (i = 0; i < MIN (BSE_SOURCE_N_ICHANNELS (self), BSE_SOURCE_N_OCHANNELS (self)); i++)
bse_trans_add (trans, bse_job_connect (imodule, i, omodule, i));
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_sub_synth_context_connect (BseSource *source,
guint context_handle,
@@ -375,7 +331,6 @@ bse_sub_synth_context_connect (BseSource *source,
BseSubSynth *self = BSE_SUB_SYNTH (source);
BseSNet *snet = self->snet;
guint i;
-
/* connect module to sub synthesizer */
if (snet)
{
@@ -383,7 +338,6 @@ bse_sub_synth_context_connect (BseSource *source,
BseModule *omodule = bse_source_get_context_omodule (source, context_handle);
ModData *mdata_in = (ModData*) imodule->user_data;
guint foreign_context_handle = mdata_in->synth_context_handle;
-
if (foreign_context_handle)
{
bse_source_connect_context (BSE_SOURCE (snet), foreign_context_handle, trans);
@@ -393,11 +347,9 @@ bse_sub_synth_context_connect (BseSource *source,
bse_snet_set_oport_dest (snet, self->output_ports[i], foreign_context_handle, omodule, i, trans);
}
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_connect (source, context_handle, trans);
}
-
static void
bse_sub_synth_context_dismiss (BseSource *source,
guint context_handle,
@@ -405,13 +357,11 @@ bse_sub_synth_context_dismiss (BseSource *source,
{
BseSubSynth *self = BSE_SUB_SYNTH (source);
BseSNet *snet = self->snet;
-
if (snet)
{
BseModule *imodule = bse_source_get_context_imodule (source, context_handle);
ModData *mdata_in = (ModData*) imodule->user_data;
guint i, foreign_context_handle = mdata_in->synth_context_handle;
-
if (foreign_context_handle)
{
for (i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
@@ -421,11 +371,9 @@ bse_sub_synth_context_dismiss (BseSource *source,
bse_source_dismiss_context (BSE_SOURCE (snet), foreign_context_handle, trans);
}
}
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
static void
bse_sub_synth_update_port_contexts (BseSubSynth *self,
const gchar *old_name,
@@ -437,9 +385,7 @@ bse_sub_synth_update_port_contexts (BseSubSynth *self,
BseSource *source = BSE_SOURCE (self);
BseTrans *trans = bse_trans_open ();
guint *cids, n, i;
-
g_return_if_fail (BSE_SOURCE_PREPARED (self));
-
cids = bse_source_context_ids (source, &n);
for (i = 0; i < n; i++)
if (is_input)
@@ -447,7 +393,6 @@ bse_sub_synth_update_port_contexts (BseSubSynth *self,
BseModule *imodule = bse_source_get_context_imodule (source, cids[i]);
ModData *mdata_in = (ModData*) imodule->user_data;
guint foreign_context_handle = mdata_in->synth_context_handle;
-
if (foreign_context_handle)
{
bse_snet_set_iport_src (snet, old_name, foreign_context_handle, NULL, port, trans);
@@ -459,7 +404,6 @@ bse_sub_synth_update_port_contexts (BseSubSynth *self,
BseModule *omodule = bse_source_get_context_omodule (source, cids[i]);
ModData *mdata_in = (ModData*) omodule->user_data;
guint foreign_context_handle = mdata_in->synth_context_handle;
-
if (foreign_context_handle)
{
bse_snet_set_oport_dest (snet, old_name, foreign_context_handle, NULL, port, trans);
@@ -469,7 +413,6 @@ bse_sub_synth_update_port_contexts (BseSubSynth *self,
g_free (cids);
bse_trans_commit (trans);
}
-
static void
bse_sub_synth_class_init (BseSubSynthClass *klass)
{
@@ -478,20 +421,15 @@ bse_sub_synth_class_init (BseSubSynthClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id, i;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_sub_synth_set_property;
gobject_class->get_property = bse_sub_synth_get_property;
gobject_class->dispose = bse_sub_synth_dispose;
gobject_class->finalize = bse_sub_synth_finalize;
-
item_class->get_candidates = bse_sub_synth_get_candidates;
-
source_class->context_create = bse_sub_synth_context_create;
source_class->context_connect = bse_sub_synth_context_connect;
source_class->context_dismiss = bse_sub_synth_context_dismiss;
-
bse_object_class_add_param (object_class, _("Assignments"),
PARAM_SNET,
bse_param_spec_object ("snet", _("Synthesizer"),
@@ -500,7 +438,6 @@ bse_sub_synth_class_init (BseSubSynthClass *klass)
for (i = 0; i < 8; i++)
{
gchar *ident, *label, *value;
-
ident = g_strdup_printf ("in_port_%u", i + 1);
label = g_strdup_printf (_("Input Port %u"), i + 1);
value = g_strdup_printf ("synth_in_%u", i + 1);
@@ -510,7 +447,6 @@ bse_sub_synth_class_init (BseSubSynthClass *klass)
g_free (ident);
g_free (label);
g_free (value);
-
ident = g_strdup_printf ("out_port_%u", i + 1);
label = g_strdup_printf (_("Output Port %u"), i + 1);
value = g_strdup_printf ("synth_out_%u", i + 1);
@@ -520,14 +456,12 @@ bse_sub_synth_class_init (BseSubSynthClass *klass)
g_free (ident);
g_free (label);
g_free (value);
-
ident = g_strdup_printf ("input-%u", i + 1);
label = g_strdup_printf (_("Virtual input %u"), i + 1);
channel_id = bse_source_class_add_ichannel (source_class, ident, label, NULL);
g_assert (channel_id == i);
g_free (ident);
g_free (label);
-
ident = g_strdup_printf ("output-%u", i + 1);
label = g_strdup_printf (_("Virtual output %u"), i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, label, NULL);
diff --git a/bse/bsesubsynth.hh b/bse/bsesubsynth.hh
index d539e5b..47ab7a2 100644
--- a/bse/bsesubsynth.hh
+++ b/bse/bsesubsynth.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SUB_SYNTH_H__
#define __BSE_SUB_SYNTH_H__
-
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SUB_SYNTH (BSE_TYPE_ID (BseSubSynth))
#define BSE_SUB_SYNTH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SUB_SYNTH, BseSubSynth))
@@ -13,12 +10,10 @@ G_BEGIN_DECLS
#define BSE_IS_SUB_SYNTH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SUB_SYNTH))
#define BSE_IS_SUB_SYNTH_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SUB_SYNTH))
#define BSE_SUB_SYNTH_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SUB_SYNTH, BseSubSynthClass))
-
/* --- BseSubSynth source --- */
struct _BseSubSynth
{
BseSource parent_object;
-
BseSNet *snet;
gchar **input_ports;
gchar **output_ports;
@@ -29,8 +24,6 @@ struct _BseSubSynthClass
{
BseSourceClass parent_class;
};
-
-
/* --- prototypes --- */
/* whether to shortcut inputs with outputs for snet==NULL */
void bse_sub_synth_set_null_shortcut (BseSubSynth *self,
@@ -38,8 +31,5 @@ void bse_sub_synth_set_null_shortcut (BseSubSynth *self,
/* override midi_channel for snet, or if midi_channel==0 inherit from parent */
void bse_sub_synth_set_midi_channel (BseSubSynth *self,
guint midi_channel);
-
-
G_END_DECLS
-
#endif /* __BSE_SUB_SYNTH_H__ */
diff --git a/bse/bsesuper.cc b/bse/bsesuper.cc
index f8404f3..ffa197d 100644
--- a/bse/bsesuper.cc
+++ b/bse/bsesuper.cc
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesuper.hh"
-
#include "bseproject.hh"
#include <string.h>
-
-
enum
{
PARAM_0,
@@ -14,15 +11,11 @@ enum
PARAM_CREATION_TIME,
PARAM_MOD_TIME
};
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static GQuark quark_author = 0;
static GQuark quark_license = 0;
static GSList *bse_super_objects = NULL;
-
-
/* --- functions --- */
static void
bse_super_init (BseSuper *super,
@@ -31,9 +24,7 @@ bse_super_init (BseSuper *super,
super->creation_time = sfi_time_from_utc (sfi_time_system ());
super->mod_time = super->creation_time;
super->context_handle = ~0;
-
bse_super_objects = g_slist_prepend (bse_super_objects, super);
-
/* we want Unnamed-xxx default unames */
bse_item_set (super, "uname", "Unnamed", NULL);
/* default-fill fields */
@@ -44,18 +35,14 @@ bse_super_init (BseSuper *super,
if (value && value[0])
bse_item_set (super, "license", value, NULL);
}
-
static void
bse_super_finalize (GObject *object)
{
BseSuper *super = BSE_SUPER (object);
-
bse_super_objects = g_slist_remove (bse_super_objects, super);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_super_set_property (GObject *object,
guint param_id,
@@ -101,7 +88,6 @@ bse_super_set_property (GObject *object,
break;
}
}
-
static void
bse_super_get_property (GObject *object,
guint param_id,
@@ -128,14 +114,12 @@ bse_super_get_property (GObject *object,
break;
}
}
-
static void
super_modified (BseSuper *super,
SfiTime stamp)
{
super->mod_time = MAX (super->mod_time, stamp);
}
-
static void
super_compat_setup (BseItem *item,
guint vmajor,
@@ -148,7 +132,6 @@ super_compat_setup (BseItem *item,
"license", "",
NULL);
}
-
static void
super_compat_finish (BseSuper *super,
guint vmajor,
@@ -156,7 +139,6 @@ super_compat_finish (BseSuper *super,
guint vmicro)
{
}
-
static void
bse_super_class_init (BseSuperClass *klass)
{
@@ -164,20 +146,15 @@ bse_super_class_init (BseSuperClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
// BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
quark_author = g_quark_from_static_string ("author");
quark_license = g_quark_from_static_string ("license");
-
gobject_class->set_property = bse_super_set_property;
gobject_class->get_property = bse_super_get_property;
gobject_class->finalize = bse_super_finalize;
-
item_class->compat_setup = super_compat_setup;
-
klass->modified = super_modified;
klass->compat_finish = super_compat_finish;
-
bse_object_class_add_param (object_class, NULL,
PARAM_AUTHOR,
sfi_pspec_string ("author", _("Author"), _("Person changing or creating this object"),
@@ -200,23 +177,19 @@ bse_super_class_init (BseSuperClass *klass)
sfi_pspec_time ("modification_time", _("Last modification time"), NULL,
SFI_PARAM_STANDARD_RDONLY));
}
-
BSE_BUILTIN_TYPE (BseSuper)
{
static const GTypeInfo super_info = {
sizeof (BseSuperClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_super_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseSuper),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_super_init,
};
-
return bse_type_register_abstract (BSE_TYPE_CONTAINER,
"BseSuper",
"Base type for item managers",
diff --git a/bse/bsesuper.hh b/bse/bsesuper.hh
index bf8a398..5362496 100644
--- a/bse/bsesuper.hh
+++ b/bse/bsesuper.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SUPER_H__
#define __BSE_SUPER_H__
-
#include <bse/bsecontainer.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SUPER (BSE_TYPE_ID (BseSuper))
#define BSE_SUPER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SUPER, BseSuper))
@@ -13,35 +10,26 @@ G_BEGIN_DECLS
#define BSE_IS_SUPER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SUPER))
#define BSE_IS_SUPER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SUPER))
#define BSE_SUPER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SUPER, BseSuperClass))
-
-
/* --- BseSuper member macros --- */
#define BSE_SUPER_NEEDS_CONTEXT(object) ((BSE_OBJECT_FLAGS (object) & BSE_SUPER_FLAG_NEEDS_CONTEXT) != 0)
-
-
/* --- bse super flags --- */
typedef enum /*< skip >*/
{
BSE_SUPER_FLAG_NEEDS_CONTEXT = 1 << (BSE_CONTAINER_FLAGS_USHIFT + 0),
} BseSuperFlags;
#define BSE_SUPER_FLAGS_USHIFT (BSE_CONTAINER_FLAGS_USHIFT + 1)
-
-
/* --- BseSuper object --- */
struct _BseSuper
{
BseContainer parent_object;
-
SfiTime creation_time;
SfiTime mod_time;
-
/* for BseProject */
guint context_handle;
};
struct _BseSuperClass
{
BseContainerClass parent_class;
-
void (*modified) (BseSuper *super,
SfiTime stamp);
void (*compat_finish) (BseSuper *super,
@@ -49,8 +37,5 @@ struct _BseSuperClass
guint vminor,
guint vmicro);
};
-
-
G_END_DECLS
-
#endif /* __BSE_SUPER_H__ */
diff --git a/bse/bsetrack.cc b/bse/bsetrack.cc
index 70c2793..9238023 100644
--- a/bse/bsetrack.cc
+++ b/bse/bsetrack.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsetrack.hh"
-
#include "bseglobals.hh"
#include "bsestorage.hh"
#include "bsecsynth.hh"
@@ -17,15 +16,11 @@
#include "bsewaverepo.hh"
#include "bsecxxplugin.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_xref, "xref", SFI_MSG_DEBUG, NULL);
#define XREF_DEBUG(...) sfi_debug (debug_xref, __VA_ARGS__)
-
#define upper_power2(uint_n) sfi_alloc_upper_power2 (MAX ((uint_n), 4))
#define parse_or_return bse_storage_scanner_parse_or_return
#define peek_or_return bse_storage_scanner_peek_or_return
-
-
enum {
PROP_0,
PROP_MUTED,
@@ -36,7 +31,6 @@ enum {
PROP_PNET,
PROP_OUTPUTS
};
-
/* --- prototypes --- */
static void bse_track_class_init (BseTrackClass *klass);
static void bse_track_init (BseTrack *self);
@@ -56,37 +50,29 @@ static GTokenType bse_track_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner);
static void bse_track_update_midi_channel (BseTrack *self);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static guint signal_changed = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseTrack)
{
static const GTypeInfo track_info = {
sizeof (BseTrackClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_track_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseTrack),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_track_init,
};
-
return bse_type_register_static (BSE_TYPE_CONTEXT_MERGER,
"BseTrack",
"BSE track type",
__FILE__, __LINE__,
&track_info);
}
-
static gulong
alloc_id_above (guint n)
{
@@ -98,7 +84,6 @@ alloc_id_above (guint n)
bse_id_free (tmp);
return id;
}
-
static void
bse_track_init (BseTrack *self)
{
@@ -113,46 +98,35 @@ bse_track_init (BseTrack *self)
self->midi_channel_SL = self->channel_id;
self->track_done_SL = FALSE;
}
-
static void
bse_track_dispose (GObject *object)
{
BseTrack *self = BSE_TRACK (object);
-
/* we may assert removal here, since if these assertions fail,
* our parent (BseSong) doesn't properly implement track support
*/
g_assert (self->sub_synth == NULL);
-
/* check uncrossed references */
g_assert (self->snet == NULL);
g_assert (self->pnet == NULL);
g_assert (self->n_entries_SL == 0);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
-
g_assert (self->bus_outputs == NULL);
}
-
static void
bse_track_finalize (GObject *object)
{
BseTrack *self = BSE_TRACK (object);
-
g_assert (self->bus_outputs == NULL);
-
g_assert (self->n_entries_SL == 0);
g_free (self->entries_SL);
bse_id_free (self->channel_id);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void track_uncross_part (BseItem *owner,
BseItem *ref_item);
-
static BseTrackEntry*
track_add_entry (BseTrack *self,
guint index,
@@ -160,13 +134,11 @@ track_add_entry (BseTrack *self,
BsePart *part)
{
guint n, size;
-
g_return_val_if_fail (index <= self->n_entries_SL, NULL);
if (index > 0)
g_return_val_if_fail (self->entries_SL[index - 1].tick < tick, NULL);
if (index < self->n_entries_SL)
g_return_val_if_fail (self->entries_SL[index].tick > tick, NULL);
-
BSE_SEQUENCER_LOCK ();
n = self->n_entries_SL++;
size = upper_power2 (self->n_entries_SL);
@@ -184,13 +156,11 @@ track_add_entry (BseTrack *self,
bse_object_reemit_signal (part, "notify::last-tick", self, "changed");
return self->entries_SL + index;
}
-
static void
track_delete_entry (BseTrack *self,
guint index)
{
g_return_if_fail (index < self->n_entries_SL);
-
BsePart *part = self->entries_SL[index].part;
bse_object_remove_reemit (part, "notify::last-tick", self, "changed");
bse_object_unproxy_notifies (part, self, "changed");
@@ -202,14 +172,12 @@ track_delete_entry (BseTrack *self,
g_memmove (self->entries_SL + index, self->entries_SL + index + 1, (self->n_entries_SL - index) * sizeof (self->entries_SL[0]));
BSE_SEQUENCER_UNLOCK ();
}
-
static BseTrackEntry*
track_lookup_entry (BseTrack *self,
guint tick)
{
BseTrackEntry *nodes = self->entries_SL;
guint n = self->n_entries_SL, offs = 0, i = 0;
-
while (offs < n)
{
gint cmp;
@@ -222,7 +190,6 @@ track_lookup_entry (BseTrack *self,
else /* (cmp > 0) */
offs = i + 1;
}
-
/* return the closest entry with tick <= requested tick if possible */
if (!self->n_entries_SL)
return NULL;
@@ -231,7 +198,6 @@ track_lookup_entry (BseTrack *self,
else
return nodes + i; /* closest match */
}
-
static void
track_uncross_part (BseItem *owner,
BseItem *item)
@@ -250,7 +216,6 @@ track_uncross_part (BseItem *owner,
return;
}
}
-
static void
bse_track_get_candidates (BseItem *item,
guint param_id,
@@ -291,7 +256,6 @@ bse_track_get_candidates (BseItem *item,
break;
}
}
-
static void
track_uncross_snet (BseItem *owner,
BseItem *ref_item)
@@ -299,7 +263,6 @@ track_uncross_snet (BseItem *owner,
BseTrack *self = BSE_TRACK (owner);
bse_item_set (self, "snet", NULL, NULL);
}
-
static void
track_uncross_pnet (BseItem *owner,
BseItem *ref_item)
@@ -307,7 +270,6 @@ track_uncross_pnet (BseItem *owner,
BseTrack *self = BSE_TRACK (owner);
bse_item_set (self, "pnet", NULL, NULL);
}
-
static void
track_uncross_wave (BseItem *owner,
BseItem *ref_item)
@@ -315,27 +277,21 @@ track_uncross_wave (BseItem *owner,
BseTrack *self = BSE_TRACK (owner);
bse_item_set (self, "wave", NULL, NULL);
}
-
static void
create_wnet (BseTrack *self,
BseWave *wave)
{
g_return_if_fail (self->wnet == NULL);
-
const gchar *play_type = bse_xinfos_get_value (wave->xinfos, "play-type");
const gchar *synthesis_network = play_type ? play_type : "adsr-wave-1";
-
self->wnet = bse_project_create_intern_synth (bse_item_get_project (BSE_ITEM (self)),
synthesis_network,
BSE_TYPE_SNET);
-
bse_item_cross_link (BSE_ITEM (self), BSE_ITEM (self->wnet), track_uncross_wave);
-
if (self->sub_synth)
g_object_set (self->sub_synth, /* no undo */
"snet", self->wnet,
NULL);
-
if (strcmp (synthesis_network, "adsr-wave-1") == 0 ||
strcmp (synthesis_network, "plain-wave-1") == 0)
{
@@ -367,14 +323,11 @@ create_wnet (BseTrack *self,
g_warning ("track: waves with the play-type \"%s\" are not supported by this version of beast\n",
synthesis_network);
}
-
}
-
static void
clear_snet_and_wave (BseTrack *self)
{
g_return_if_fail (!self->sub_synth || !BSE_SOURCE_PREPARED (self->sub_synth));
-
if (self->sub_synth)
g_object_set (self->sub_synth, /* no undo */
"snet", NULL,
@@ -401,7 +354,6 @@ clear_snet_and_wave (BseTrack *self)
bse_container_remove_item (BSE_CONTAINER (bse_item_get_project (BSE_ITEM (self))), BSE_ITEM (wnet));
}
}
-
static void
bse_track_set_property (GObject *object,
guint param_id,
@@ -409,7 +361,6 @@ bse_track_set_property (GObject *object,
GParamSpec *pspec)
{
BseTrack *self = BSE_TRACK (object);
-
switch (param_id)
{
guint i;
@@ -445,7 +396,6 @@ bse_track_set_property (GObject *object,
if (wave || self->wave)
{
clear_snet_and_wave (self);
-
self->wave = wave;
if (self->wave)
{
@@ -497,7 +447,6 @@ bse_track_set_property (GObject *object,
break;
}
}
-
static void
bse_track_get_property (GObject *object,
guint param_id,
@@ -505,7 +454,6 @@ bse_track_get_property (GObject *object,
GParamSpec *pspec)
{
BseTrack *self = BSE_TRACK (object);
-
switch (param_id)
{
BseItemSeq *iseq;
@@ -539,17 +487,14 @@ bse_track_get_property (GObject *object,
break;
}
}
-
guint
bse_track_insert_part (BseTrack *self,
guint tick,
BsePart *part)
{
BseTrackEntry *entry;
-
g_return_val_if_fail (BSE_IS_TRACK (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (BSE_IS_PART (part), BSE_ERROR_INTERNAL);
-
entry = track_lookup_entry (self, tick);
if (entry && entry->tick == tick)
return 0;
@@ -562,15 +507,12 @@ bse_track_insert_part (BseTrack *self,
g_signal_emit (self, signal_changed, 0);
return entry ? entry->id : 0;
}
-
void
bse_track_remove_tick (BseTrack *self,
guint tick)
{
BseTrackEntry *entry;
-
g_return_if_fail (BSE_IS_TRACK (self));
-
entry = track_lookup_entry (self, tick);
if (entry && entry->tick == tick)
{
@@ -580,7 +522,6 @@ bse_track_remove_tick (BseTrack *self,
g_signal_emit (self, signal_changed, 0);
}
}
-
static BseTrackPartSeq*
bse_track_list_parts_intern (BseTrack *self,
BsePart *part)
@@ -611,14 +552,12 @@ bse_track_list_parts_intern (BseTrack *self,
}
return tps;
}
-
BseTrackPartSeq*
bse_track_list_parts (BseTrack *self)
{
g_return_val_if_fail (BSE_IS_TRACK (self), NULL);
return bse_track_list_parts_intern (self, NULL);
}
-
BseTrackPartSeq*
bse_track_list_part (BseTrack *self,
BsePart *part)
@@ -627,17 +566,14 @@ bse_track_list_part (BseTrack *self,
g_return_val_if_fail (BSE_IS_PART (part), NULL);
return bse_track_list_parts_intern (self, part);
}
-
gboolean
bse_track_find_part (BseTrack *self,
BsePart *part,
guint *start_p)
{
guint i;
-
g_return_val_if_fail (BSE_IS_TRACK (self), FALSE);
g_return_val_if_fail (BSE_IS_PART (part), FALSE);
-
for (i = 0; i < self->n_entries_SL; i++)
if (self->entries_SL[i].part == part)
{
@@ -647,35 +583,28 @@ bse_track_find_part (BseTrack *self,
}
return FALSE;
}
-
BseTrackEntry*
bse_track_lookup_tick (BseTrack *self,
guint tick)
{
BseTrackEntry *entry;
-
g_return_val_if_fail (BSE_IS_TRACK (self), NULL);
-
entry = track_lookup_entry (self, tick);
if (entry && entry->tick == tick)
return entry;
return NULL;
}
-
BseTrackEntry*
bse_track_find_link (BseTrack *self,
guint id)
{
guint i;
-
g_return_val_if_fail (BSE_IS_TRACK (self), NULL);
-
for (i = 0; i < self->n_entries_SL; i++)
if (self->entries_SL[i].id == id)
return self->entries_SL + i;
return NULL;
}
-
BsePart*
bse_track_get_part_SL (BseTrack *self,
guint tick,
@@ -683,13 +612,10 @@ bse_track_get_part_SL (BseTrack *self,
guint *next)
{
BseTrackEntry *entry;
-
g_return_val_if_fail (BSE_IS_TRACK (self), NULL);
-
/* we return the nearest part with start <= tick and
* set *next to the start of the following part if any
*/
-
entry = track_lookup_entry (self, tick);
if (entry)
{
@@ -705,7 +631,6 @@ bse_track_get_part_SL (BseTrack *self,
*next = self->n_entries_SL ? self->entries_SL[0].tick : 0;
return NULL;
}
-
void
bse_track_add_modules (BseTrack *self,
BseContainer *container,
@@ -715,11 +640,9 @@ bse_track_add_modules (BseTrack *self,
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (self->sub_synth == NULL);
g_return_if_fail (midi_receiver != NULL);
-
/* midi voice input */
self->voice_input = (BseSource*) bse_container_new_child (container, BSE_TYPE_MIDI_VOICE_INPUT, NULL);
bse_item_set_internal (self->voice_input, TRUE);
-
/* sub synth */
self->sub_synth = (BseSource*) bse_container_new_child_bname (container, BSE_TYPE_SUB_SYNTH, "Track-Instrument",
"in_port_1", "frequency",
@@ -733,7 +656,6 @@ bse_track_add_modules (BseTrack *self,
"snet", self->snet,
NULL);
bse_item_set_internal (self->sub_synth, TRUE);
-
/* voice input <-> sub-synth */
bse_source_must_set_input (self->sub_synth, 0,
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_FREQUENCY);
@@ -743,12 +665,10 @@ bse_track_add_modules (BseTrack *self,
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_VELOCITY);
bse_source_must_set_input (self->sub_synth, 3,
self->voice_input, BSE_MIDI_VOICE_INPUT_OCHANNEL_AFTERTOUCH);
-
/* midi voice switch */
self->voice_switch = (BseSource*) bse_container_new_child (container, BSE_TYPE_MIDI_VOICE_SWITCH, NULL);
bse_item_set_internal (self->voice_switch, TRUE);
bse_midi_voice_input_set_voice_switch (BSE_MIDI_VOICE_INPUT (self->voice_input), BSE_MIDI_VOICE_SWITCH (self->voice_switch));
-
/* sub-synth <-> voice switch */
bse_source_must_set_input (self->voice_switch, BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT,
self->sub_synth, 0);
@@ -756,37 +676,30 @@ bse_track_add_modules (BseTrack *self,
self->sub_synth, 1);
bse_source_must_set_input (self->voice_switch, BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT,
self->sub_synth, 3);
-
/* midi voice switch <-> context merger */
bse_source_must_set_input (BSE_SOURCE (self), 0,
self->voice_switch, BSE_MIDI_VOICE_SWITCH_OCHANNEL_LEFT);
bse_source_must_set_input (BSE_SOURCE (self), 1,
self->voice_switch, BSE_MIDI_VOICE_SWITCH_OCHANNEL_RIGHT);
-
/* postprocess */
self->postprocess = (BseSource*) bse_container_new_child_bname (container, BSE_TYPE_SUB_SYNTH, "Track-Postprocess", NULL);
bse_item_set_internal (self->postprocess, TRUE);
bse_sub_synth_set_null_shortcut (BSE_SUB_SYNTH (self->postprocess), TRUE);
-
/* context merger <-> postprocess */
bse_source_must_set_input (self->postprocess, 0, BSE_SOURCE (self), 0);
bse_source_must_set_input (self->postprocess, 1, BSE_SOURCE (self), 1);
-
/* propagate midi channel to modules */
bse_track_update_midi_channel (self);
}
-
BseSource*
bse_track_get_output (BseTrack *self)
{
return self->postprocess;
}
-
guint
bse_track_get_last_tick (BseTrack *self)
{
int last_tick = 0;
-
/* find last part */
BsePart *part = NULL;
guint i, offset = 0;
@@ -810,10 +723,8 @@ bse_track_get_last_tick (BseTrack *self)
}
else
last_tick += 1; /* always return one after */
-
return last_tick;
}
-
static void
bse_track_update_midi_channel (BseTrack *self)
{
@@ -824,7 +735,6 @@ bse_track_update_midi_channel (BseTrack *self)
bse_midi_voice_switch_set_midi_channel (BSE_MIDI_VOICE_SWITCH (self->voice_switch), self->midi_channel_SL);
}
}
-
static void
bse_track_context_create (BseSource *source,
guint context_handle,
@@ -837,7 +747,6 @@ bse_track_context_create (BseSource *source,
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_track_context_dismiss (BseSource *source,
guint context_handle,
@@ -850,7 +759,6 @@ bse_track_context_dismiss (BseSource *source,
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
}
-
void
bse_track_remove_modules (BseTrack *self,
BseContainer *container)
@@ -858,7 +766,6 @@ bse_track_remove_modules (BseTrack *self,
g_return_if_fail (BSE_IS_TRACK (self));
g_return_if_fail (BSE_IS_CONTAINER (container));
g_return_if_fail (self->sub_synth != NULL);
-
bse_container_remove_item (container, BSE_ITEM (self->sub_synth));
self->sub_synth = NULL;
bse_container_remove_item (container, BSE_ITEM (self->voice_input));
@@ -868,7 +775,6 @@ bse_track_remove_modules (BseTrack *self,
bse_container_remove_item (container, BSE_ITEM (self->postprocess));
self->postprocess = NULL;
}
-
void
bse_track_clone_voices (BseTrack *self,
BseSNet *snet,
@@ -877,15 +783,12 @@ bse_track_clone_voices (BseTrack *self,
BseTrans *trans)
{
guint i;
-
g_return_if_fail (BSE_IS_TRACK (self));
g_return_if_fail (BSE_IS_SNET (snet));
g_return_if_fail (trans != NULL);
-
for (i = 0; i < self->max_voices - 1; i++)
bse_snet_context_clone_branch (snet, context, BSE_SOURCE (self), mcontext, trans);
}
-
static void
bse_track_store_private (BseObject *object,
BseStorage *storage)
@@ -893,11 +796,9 @@ bse_track_store_private (BseObject *object,
BseTrack *self = BSE_TRACK (object);
BseItem *item = BSE_ITEM (self);
guint i;
-
/* chain parent class' handler */
if (BSE_OBJECT_CLASS (parent_class)->store_private)
BSE_OBJECT_CLASS (parent_class)->store_private (object, storage);
-
for (i = 0; i < self->n_entries_SL; i++)
{
BseTrackEntry *e = self->entries_SL + i;
@@ -911,7 +812,6 @@ bse_track_store_private (BseObject *object,
}
}
}
-
static void
part_link_resolved (gpointer data,
BseStorage *storage,
@@ -920,7 +820,6 @@ part_link_resolved (gpointer data,
const gchar *error)
{
BseTrack *self = BSE_TRACK (from_item);
-
if (error)
bse_storage_warn (storage, "%s", error);
else if (!BSE_IS_PART (to_item))
@@ -935,22 +834,18 @@ part_link_resolved (gpointer data,
bse_object_debug_name (to_item));
}
}
-
static GTokenType
bse_track_restore_private (BseObject *object,
BseStorage *storage,
GScanner *scanner)
{
BseTrack *self = BSE_TRACK (object);
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER &&
bse_string_equals ("insert-part", scanner->next_value.v_identifier))
{
GTokenType token;
guint tick;
-
g_scanner_get_next_token (scanner); /* eat quark */
-
parse_or_return (scanner, G_TOKEN_INT);
tick = scanner->value.v_int64;
token = bse_storage_parse_item_link (storage, BSE_ITEM (self), part_link_resolved, GUINT_TO_POINTER (tick));
@@ -962,7 +857,6 @@ bse_track_restore_private (BseObject *object,
else /* chain parent class' handler */
return BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
}
-
static void
bse_track_class_init (BseTrackClass *klass)
{
@@ -970,24 +864,17 @@ bse_track_class_init (BseTrackClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_track_set_property;
gobject_class->get_property = bse_track_get_property;
gobject_class->dispose = bse_track_dispose;
gobject_class->finalize = bse_track_finalize;
-
object_class->store_private = bse_track_store_private;
object_class->restore_private = bse_track_restore_private;
-
item_class->get_candidates = bse_track_get_candidates;
-
source_class->context_create = bse_track_context_create;
source_class->context_dismiss = bse_track_context_dismiss;
-
bse_source_class_inherit_channels (BSE_SOURCE_CLASS (klass));
-
bse_object_class_add_param (object_class, _("Adjustments"),
PROP_MUTED,
sfi_pspec_bool ("muted", _("Muted"), NULL,
diff --git a/bse/bsetrack.hh b/bse/bsetrack.hh
index 9b9ec4f..df2ee8c 100644
--- a/bse/bsetrack.hh
+++ b/bse/bsetrack.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_TRACK_H__
#define __BSE_TRACK_H__
-
#include <bse/bseitem.hh>
#include <bse/bsesnet.hh>
#include <bse/bsecontextmerger.hh>
-
G_BEGIN_DECLS
-
/* --- BSE type macros --- */
#define BSE_TYPE_TRACK (BSE_TYPE_ID (BseTrack))
#define BSE_TRACK(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_TRACK, BseTrack))
@@ -15,8 +12,6 @@ G_BEGIN_DECLS
#define BSE_IS_TRACK(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_TRACK))
#define BSE_IS_TRACK_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_TRACK))
#define BSE_TRACK_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_TRACK, BseTrackClass))
-
-
/* --- BseTrack --- */
typedef struct {
guint tick;
@@ -26,24 +21,19 @@ typedef struct {
struct _BseTrack
{
BseContextMerger parent_instance;
-
guint channel_id;
guint max_voices;
BseSNet *snet;
BseSNet *pnet;
-
/* wave synthesis */
BseWave *wave;
BseSNet *wnet;
-
/* playback intergration */
BseSource *sub_synth;
BseSource *voice_input;
BseSource *voice_switch;
BseSource *postprocess;
-
SfiRing *bus_outputs; /* maintained by bsebus.[hc] */
-
/* fields protected by sequencer mutex */
guint n_entries_SL : 30;
guint muted_SL : 1;
@@ -55,8 +45,6 @@ struct _BseTrackClass
{
BseContextMergerClass parent_class;
};
-
-
/* --- prototypes -- */
void bse_track_add_modules (BseTrack *self,
BseContainer *container,
@@ -89,7 +77,5 @@ BsePart* bse_track_get_part_SL (BseTrack *self,
guint tick,
guint *start,
guint *next);
-
G_END_DECLS
-
#endif /* __BSE_TRACK_H__ */
diff --git a/bse/bsetrack.proc b/bse/bsetrack.proc
index 52ba615..5f7a12d 100644
--- a/bse/bsetrack.proc
+++ b/bse/bsetrack.proc
@@ -7,12 +7,8 @@
#include <bse/bsebus.hh>
#include <bse/bseundostack.hh>
#include "bsecxxplugin.hh"
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "Copyright (C) 2003 Tim Janik";
-
-
METHOD (BseTrack, insert-part) {
HELP = "Insert a part into a track and retrieve the corresponding link id.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -33,13 +29,11 @@ BODY (BseProcedureClass *proc,
guint tick = sfi_value_get_int (in_values++);
BsePart *part = (BsePart*) bse_value_get_object (in_values++);
guint id;
-
/* check parameters */
if (!BSE_IS_TRACK (self) || !BSE_IS_PART (part) ||
!BSE_ITEM (self)->parent ||
BSE_ITEM (self)->parent != BSE_ITEM (part)->parent)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
id = bse_track_insert_part (self, tick, part);
if (id)
@@ -47,13 +41,10 @@ BODY (BseProcedureClass *proc,
/* can't use remove-link() here, since id will have changed after undo */
bse_item_push_undo_proc (self, "remove-tick", tick);
}
-
/* set output parameters */
g_value_set_int (out_values++, id);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, remove-tick) {
HELP = "Remove a part at specified tick from a track.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -69,11 +60,9 @@ BODY (BseProcedureClass *proc,
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
BseTrackEntry *entry;
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
entry = bse_track_lookup_tick (self, tick);
if (entry)
@@ -81,10 +70,8 @@ BODY (BseProcedureClass *proc,
bse_item_push_undo_proc (self, "insert-part", entry->tick, entry->part);
bse_track_remove_tick (self, tick);
}
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, remove-link) {
HELP = "Remove a specific part link by ID from a track.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -100,21 +87,17 @@ BODY (BseProcedureClass *proc,
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
guint id = sfi_value_get_int (in_values++);
BseTrackEntry *entry;
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
entry = bse_track_find_link (self, id);
if (!entry)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_item_push_undo_proc (self, "insert-part", entry->tick, entry->part);
bse_track_remove_tick (self, entry->tick);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, list-parts) {
HELP = "List parts scheduled in a track, sorted by tick.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -128,17 +111,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
bse_value_take_boxed (out_values++, bse_track_list_parts (self));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, list-parts-uniq) {
HELP = "List all parts contained in a track.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -152,11 +131,9 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
BseTrackPartSeq *tpseq = bse_track_list_parts (self);
SfiRing *ring = NULL;
@@ -168,10 +145,8 @@ BODY (BseProcedureClass *proc,
ring = sfi_ring_uniq (ring, sfi_pointer_cmp, NULL);
bse_value_take_boxed (out_values++, bse_item_seq_from_ring (ring));
sfi_ring_free (ring);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, get-part) {
HELP = "Get the part starting at a specific tick position.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -189,18 +164,14 @@ BODY (BseProcedureClass *proc,
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
guint tick = sfi_value_get_int (in_values++);
BseTrackEntry *entry;
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
entry = bse_track_lookup_tick (self, tick);
bse_value_set_object (out_values++, entry ? entry->part : NULL);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, get-timing) {
HELP = "Retrieve song timing information at a specific tick.";
IN = bse_param_spec_object ("track", "Track", NULL, BSE_TYPE_TRACK, SFI_PARAM_STANDARD);
@@ -215,24 +186,19 @@ METHOD (BseTrack, get-timing) {
SfiInt tick = sfi_value_get_int (in_values++);
BseItem *parent;
BseSongTiming timing = { 0, };
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
parent = BSE_ITEM (self)->parent;
if (BSE_IS_SONG (parent))
bse_song_get_timing (BSE_SONG (parent), tick, &timing);
else
bse_song_timing_get_default (&timing);
-
/* set output parameters */
bse_value_set_boxed (out_values++, &timing);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, get-output-source) {
HELP = _("Get the output module for this track. The output of this module is the merged result from "
"all polyphonic voices and has all track specific alterations applied.");
@@ -247,20 +213,15 @@ METHOD (BseTrack, get-output-source) {
/* extract parameter values */
BseTrack *track = (BseTrack*) bse_value_get_object (in_values++);
BseSource *child = NULL;
-
/* check parameters */
if (!BSE_IS_TRACK (track))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
child = bse_track_get_output (track);
-
/* set output parameters */
bse_value_set_object (out_values++, child);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, get-last-tick) {
HELP = "Retrieve the last tick for this track.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -273,17 +234,13 @@ METHOD (BseTrack, get-last-tick) {
{
/* extract parameter values */
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, bse_track_get_last_tick (self));
-
return BSE_ERROR_NONE;
}
-
METHOD (BseTrack, ensure-output) {
HELP = "Ensure the track has an output connection to a bus.";
IN = bse_param_spec_object ("track", "Track", NULL,
@@ -297,11 +254,9 @@ METHOD (BseTrack, ensure-output) {
/* extract parameter values */
BseTrack *self = (BseTrack*) bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_TRACK (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
BseItem *parent = BSE_ITEM (self)->parent;
if (BSE_IS_SONG (parent) && !self->bus_outputs)
@@ -315,9 +270,7 @@ METHOD (BseTrack, ensure-output) {
bse_item_push_undo_proc (master, "disconnect-track", self);
}
}
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsetype.cc b/bse/bsetype.cc
index 2176c29..eb3117f 100644
--- a/bse/bsetype.cc
+++ b/bse/bsetype.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsetype.hh"
-
#include "bseplugin.hh"
#include <string.h>
#include <gobject/gvaluecollector.h>
-
-
/* --- variables --- */
static GQuark quark_options = 0;
static GQuark quark_blurb = 0;
@@ -15,15 +12,12 @@ static GQuark quark_authors = 0;
static GQuark quark_license = 0;
static GQuark quark_boxed_export_node = 0;
GType bse_type_id_packed_pointer = 0;
-
-
/* --- functions --- */
const char*
bse_type_get_options (GType type)
{
return (const char*) g_type_get_qdata (type, quark_options);
}
-
void
bse_type_add_options (GType type,
const gchar *options)
@@ -31,25 +25,21 @@ bse_type_add_options (GType type,
g_return_if_fail (bse_type_get_options (type) == NULL);
g_type_set_qdata (type, quark_options, g_strdup (options));
}
-
const gchar*
bse_type_get_blurb (GType type)
{
return (const char*) g_type_get_qdata (type, quark_blurb);
}
-
const gchar*
bse_type_get_file (GType type)
{
return (const char*) g_type_get_qdata (type, quark_loc_file);
}
-
guint
bse_type_get_line (GType type)
{
return (size_t) g_type_get_qdata (type, quark_loc_line);
}
-
void
bse_type_add_blurb (GType type,
const gchar *blurb,
@@ -61,13 +51,11 @@ bse_type_add_blurb (GType type,
g_type_set_qdata (type, quark_loc_file, g_strdup (file));
g_type_set_qdata (type, quark_loc_line, (void*) size_t (line));
}
-
const gchar*
bse_type_get_authors (GType type)
{
return (const char*) g_type_get_qdata (type, quark_authors);
}
-
void
bse_type_add_authors (GType type,
const gchar *authors)
@@ -75,13 +63,11 @@ bse_type_add_authors (GType type,
g_return_if_fail (bse_type_get_authors (type) == NULL);
g_type_set_qdata (type, quark_authors, g_strdup (authors));
}
-
const gchar*
bse_type_get_license (GType type)
{
return (const char*) g_type_get_qdata (type, quark_license);
}
-
void
bse_type_add_license (GType type,
const gchar *license)
@@ -89,7 +75,6 @@ bse_type_add_license (GType type,
g_return_if_fail (bse_type_get_license (type) == NULL);
g_type_set_qdata (type, quark_license, g_strdup (license));
}
-
GType
bse_type_register_static (GType parent_type,
const gchar *type_name,
@@ -99,7 +84,6 @@ bse_type_register_static (GType parent_type,
const GTypeInfo *info)
{
GTypeInfo tmp_info;
-
/* some builtin types have destructors eventhough they are registered
* statically, compensate for that
*/
@@ -109,13 +93,10 @@ bse_type_register_static (GType parent_type,
tmp_info.class_finalize = NULL;
info = &tmp_info;
}
-
const GType type = g_type_register_static (parent_type, type_name, info, GTypeFlags (0));
bse_type_add_blurb (type, type_blurb, file, line);
-
return type;
}
-
GType
bse_type_register_abstract (GType parent_type,
const gchar *type_name,
@@ -125,7 +106,6 @@ bse_type_register_abstract (GType parent_type,
const GTypeInfo *info)
{
GTypeInfo tmp_info;
-
/* some builtin types have destructors eventhough they are registered
* statically, compensate for that
*/
@@ -135,12 +115,10 @@ bse_type_register_abstract (GType parent_type,
tmp_info.class_finalize = NULL;
info = &tmp_info;
}
-
const GType type = g_type_register_static (parent_type, type_name, info, G_TYPE_FLAG_ABSTRACT);
bse_type_add_blurb (type, type_blurb, file, line);
return type;
}
-
GType
bse_type_register_dynamic (GType parent_type,
const gchar *type_name,
@@ -149,13 +127,11 @@ bse_type_register_dynamic (GType parent_type,
GType type = g_type_register_dynamic (parent_type, type_name, plugin, GTypeFlags (0));
return type;
}
-
static void
bse_boxed_value_init (GValue *value)
{
value->data[0].v_pointer = NULL;
}
-
static void
bse_boxed_value_free (GValue *value)
{
@@ -168,7 +144,6 @@ bse_boxed_value_free (GValue *value)
g_critical ("%s: %s due to missing implementation: %s", G_STRFUNC, "leaking boxed structure", g_type_name (G_VALUE_TYPE (value)));
}
}
-
static void
bse_boxed_value_copy (const GValue *src_value,
GValue *dest_value)
@@ -183,13 +158,11 @@ bse_boxed_value_copy (const GValue *src_value,
g_critical ("%s: %s due to missing implementation: %s", G_STRFUNC, "not copying boxed structure", g_type_name (G_VALUE_TYPE (src_value)));
}
}
-
static gpointer
bse_boxed_value_peek_pointer (const GValue *value)
{
return value->data[0].v_pointer;
}
-
static gchar*
bse_boxed_collect_value (GValue *value,
guint n_collect_values,
@@ -216,7 +189,6 @@ bse_boxed_collect_value (GValue *value,
}
return NULL;
}
-
static gchar*
bse_boxed_lcopy_value (const GValue *value,
guint n_collect_values,
@@ -240,7 +212,6 @@ bse_boxed_lcopy_value (const GValue *value,
}
return NULL;
}
-
static void
bse_boxed_to_record (const GValue *src_value,
GValue *dest_value)
@@ -251,7 +222,6 @@ bse_boxed_to_record (const GValue *src_value,
else
g_critical ("%s: %s due to missing implementation: %s", G_STRFUNC, "not converting boxed structure", g_type_name (G_VALUE_TYPE (src_value)));
}
-
static void
bse_boxed_from_record (const GValue *src_value,
GValue *dest_value)
@@ -262,7 +232,6 @@ bse_boxed_from_record (const GValue *src_value,
else
g_critical ("%s: %s due to missing implementation: %s", G_STRFUNC, "not converting boxed structure", g_type_name (G_VALUE_TYPE (dest_value)));
}
-
GType
bse_type_register_loadable_boxed (BseExportNodeBoxed *bnode,
GTypePlugin *plugin)
@@ -295,7 +264,6 @@ bse_type_register_loadable_boxed (BseExportNodeBoxed *bnode,
g_return_val_if_fail (bnode->free != NULL, 0);
g_return_val_if_fail (bnode->node.ntype == BSE_EXPORT_NODE_RECORD || bnode->node.ntype == BSE_EXPORT_NODE_SEQUENCE, 0);
g_return_val_if_fail (g_type_from_name (bnode->node.name) == 0, 0);
-
type = g_type_register_static (G_TYPE_BOXED, bnode->node.name, &info, GTypeFlags (0));
if (bnode->boxed2recseq)
g_value_register_transform_func (type,
@@ -309,7 +277,6 @@ bse_type_register_loadable_boxed (BseExportNodeBoxed *bnode,
bse_boxed_from_record);
return type;
}
-
void
bse_type_reinit_boxed (BseExportNodeBoxed *bnode)
{
@@ -326,7 +293,6 @@ bse_type_reinit_boxed (BseExportNodeBoxed *bnode)
default: g_assert_not_reached();
}
}
-
void
bse_type_uninit_boxed (BseExportNodeBoxed *bnode)
{
@@ -344,8 +310,6 @@ bse_type_uninit_boxed (BseExportNodeBoxed *bnode)
}
g_type_set_qdata (bnode->node.type, quark_boxed_export_node, NULL);
}
-
-
/* --- customized pspec constructors --- */
#define NULL_CHECKED(x) ((x) && (x)[0] ? x : NULL)
GParamSpec*
@@ -357,10 +321,8 @@ bse_param_spec_enum (const gchar *name,
const gchar *hints)
{
GParamSpec *pspec;
-
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
g_return_val_if_fail (enum_type != G_TYPE_ENUM, NULL);
-
/* g_param_spec_enum() validates default_value, which we allways allow
* to be 0, so we might need to adjust it to pass validation
*/
@@ -371,19 +333,13 @@ bse_param_spec_enum (const gchar *name,
default_value = enum_class->values[0].value;
g_type_class_unref (enum_class);
}
-
pspec = g_param_spec_enum (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), enum_type, default_value, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
-
return pspec;
}
-
-
/* --- SFIDL includes --- */
/* include SFIDL generations */
#include "bsegentypes.cc"
-
-
void
bse_type_init (void)
{
@@ -397,9 +353,7 @@ bse_type_init (void)
const guint n_builtin_types = sizeof (builtin_types) / sizeof (builtin_types[0]);
static GTypeFundamentalInfo finfo = { GTypeFundamentalFlags (0), };
guint i;
-
g_return_if_fail (quark_blurb == 0);
-
/* type system initialization
*/
quark_options = g_quark_from_static_string ("BseType-options");
@@ -410,13 +364,10 @@ bse_type_init (void)
quark_license = g_quark_from_static_string ("BseType-license");
quark_boxed_export_node = g_quark_from_static_string ("BseType-boxed-export-node");
g_type_init ();
-
/* initialize parameter types */
bse_param_types_init ();
-
/* initialize builtin enumerations */
bse_type_register_enums ();
-
/* BSE_TYPE_PROCEDURE
*/
memset (&finfo, 0, sizeof (finfo));
@@ -426,13 +377,11 @@ bse_type_init (void)
g_type_register_fundamental (BSE_TYPE_PROCEDURE, "BseProcedure", &info, &finfo, GTypeFlags (0));
bse_type_add_blurb (BSE_TYPE_PROCEDURE, "BSE Procedure base type", __FILE__, __LINE__);
g_assert (BSE_TYPE_PROCEDURE == g_type_from_name ("BseProcedure"));
-
/* initialize extra types */
{
static const GTypeInfo dummy = { 0, };
bse_type_id_packed_pointer = g_type_register_static (G_TYPE_STRING, "BseTypePackedPointer", &dummy, GTypeFlags (0));
}
-
/* initialize builtin class types */
for (i = 0; i < n_builtin_types; i++)
*(builtin_types[i].type_p) = builtin_types[i].register_type ();
diff --git a/bse/bsetype.hh b/bse/bsetype.hh
index 365c1bc..8873620 100644
--- a/bse/bsetype.hh
+++ b/bse/bsetype.hh
@@ -1,26 +1,19 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_TYPE_H__
#define __BSE_TYPE_H__
-
#include <bse/bsedefs.hh>
-
G_BEGIN_DECLS
-
/* --- typedefs --- */
#define BSE_TYPE_PROCEDURE G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_BSE_FIRST + 3)
-
/* type macros
*/
#define BSE_TYPE_IS_PROCEDURE(type) (G_TYPE_FUNDAMENTAL (type) == BSE_TYPE_PROCEDURE)
#define BSE_CLASS_NAME(class) (g_type_name (G_TYPE_FROM_CLASS (class)))
#define BSE_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
#define BSE_TYPE_IS_OBJECT(type) (g_type_is_a ((type), BSE_TYPE_OBJECT))
-
/* --- extra types --- */
extern GType bse_type_id_packed_pointer;
#define BSE_TYPE_PACKED_POINTER (bse_type_id_packed_pointer)
-
-
/* --- prototypes --- */
void bse_type_init (void);
void bse_type_add_options (GType type,
@@ -58,10 +51,7 @@ GType bse_type_register_loadable_boxed (BseExportNodeBoxed *bnode,
GTypePlugin *plugin);
void bse_type_reinit_boxed (BseExportNodeBoxed *bnode);
void bse_type_uninit_boxed (BseExportNodeBoxed *bnode);
-
-
/* --- implementation details --- */
-
/* magic macros to define type initialization function within
* .c files. they identify builtin type functions for magic post
* processing and help resolving runtime type id retrival.
@@ -73,8 +63,6 @@ void bse_type_uninit_boxed (BseExportNodeBoxed *bnode);
# define BSE_DUMMY_TYPE(BseTypeName) EXTERN_C BSE_BUILTIN_PROTO (BseTypeName) { return 0; } \
EXTERN_C BSE_BUILTIN_PROTO (BseTypeName)
#endif /* BSE_COMPILATION */
-
-
/* --- customized pspec constructors --- */
GParamSpec* bse_param_spec_enum (const gchar *name,
const gchar *nick,
@@ -82,22 +70,16 @@ GParamSpec* bse_param_spec_enum (const gchar *name,
gint default_value, /* can always be 0 */
GType enum_type,
const gchar *hints);
-
// == type initializers ==
void bse_type_register_enums ();
void bse_type_register_procedure_info (GTypeInfo *info);
void bse_type_register_object_info (GTypeInfo *info);
void bse_param_types_init ();
-
/* -- auto generated type ids --- */
#include <bse/bsegentypes.h>
-
-
/* --- dynamic config --- */
#define BSE_GCONFIG(cfg) (bse_global_config->cfg)
extern BseGConfig *bse_global_config; /* from bsegconfig.[hc] */
-
-
/* --- provide IDL pspec initializers --- */
#define sfidl_pspec_Bool(group, locfile, locline, name, nick, blurb, dflt, options) \
sfi_pspec_set_group (sfi_pspec_bool (name, nick, blurb, dflt, options), group)
@@ -189,8 +171,5 @@ extern BseGConfig *bse_global_config; /* from bsegconfig.[hc] */
sfi_pspec_set_group (bse_param_spec_object (name, NULL, NULL, otype, SFI_PARAM_STANDARD), group)
#define sfidl_pspec_TypedObject(group, locfile, locline, name, nick, blurb, options, otype) \
sfi_pspec_set_group (bse_param_spec_object (name, nick, blurb, otype, options), group)
-
-
G_END_DECLS
-
#endif /* __BSE_TYPE_H__ */
diff --git a/bse/bseundostack.cc b/bse/bseundostack.cc
index 431a98f..1d59bd3 100644
--- a/bse/bseundostack.cc
+++ b/bse/bseundostack.cc
@@ -3,10 +3,8 @@
#include "bseproject.hh"
#include "bsecontainer.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_undo, "undo", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_undo, __VA_ARGS__)
-
/* --- functions --- */
BseUndoStack*
bse_undo_stack_dummy (void)
@@ -20,15 +18,12 @@ bse_undo_stack_dummy (void)
return dummy_ustack;
}
#define IS_DUMMY_USTACK(ust) ((ust) == bse_undo_stack_dummy())
-
BseUndoStack*
bse_undo_stack_new (BseProject *project,
BseUndoNotify notify)
{
BseUndoStack *self;
-
g_return_val_if_fail (BSE_IS_PROJECT (project), NULL);
-
self = g_new0 (BseUndoStack, 1);
self->ignore_steps = 0; /* reset dummy specific value */
self->project = project;
@@ -36,7 +31,6 @@ bse_undo_stack_new (BseProject *project,
self->max_steps = 999;
return self;
}
-
void
bse_undo_stack_limit (BseUndoStack *self,
guint max_steps)
@@ -52,7 +46,6 @@ bse_undo_stack_limit (BseUndoStack *self,
g_free (group);
}
}
-
void
bse_undo_stack_clear (BseUndoStack *self)
{
@@ -60,19 +53,16 @@ bse_undo_stack_clear (BseUndoStack *self)
bse_undo_stack_limit (self, 0);
self->max_steps = max_steps;
}
-
gboolean
bse_undo_stack_dirty (BseUndoStack *self)
{
return self->dirt_counter || (self->group && self->group->undo_steps);
}
-
void
bse_undo_stack_clean_dirty (BseUndoStack *self)
{
self->dirt_counter = 0;
}
-
void
bse_undo_stack_force_dirty (BseUndoStack *self)
{
@@ -82,7 +72,6 @@ bse_undo_stack_force_dirty (BseUndoStack *self)
self->dirt_counter = self->n_undo_groups + 1;
}
}
-
void
bse_undo_stack_destroy (BseUndoStack *self)
{
@@ -93,13 +82,11 @@ bse_undo_stack_destroy (BseUndoStack *self)
g_free (g_slist_pop_head (&self->debug_names));
g_free (self);
}
-
void
bse_undo_group_open (BseUndoStack *self,
const gchar *name)
{
g_return_if_fail (name != NULL);
-
if (!self->n_open_groups)
{
self->group = g_new0 (BseUndoGroup, 1);
@@ -111,22 +98,18 @@ bse_undo_group_open (BseUndoStack *self,
self->n_open_groups++;
self->debug_names = g_slist_prepend (self->debug_names, g_strdup (name));
}
-
void
bse_undo_stack_ignore_steps (BseUndoStack *self)
{
self->ignore_steps++;
}
-
void
bse_undo_stack_push (BseUndoStack *self,
BseUndoStep *ustep)
{
const char *debug_name = self->debug_names ? (const char*) self->debug_names->data : "-";
-
g_return_if_fail (self->n_open_groups > 0);
g_return_if_fail (ustep != NULL);
-
if (self->ignore_steps)
{
DEBUG ("undo step: - ignored: ((BseUndoFunc) %p) (%s)", ustep->undo_func, debug_name);
@@ -139,18 +122,15 @@ bse_undo_stack_push (BseUndoStack *self,
self->group->undo_steps = sfi_ring_push_head (self->group->undo_steps, ustep);
}
}
-
void
bse_undo_stack_push_add_on (BseUndoStack *self,
BseUndoStep *ustep)
{
g_return_if_fail (ustep != NULL);
-
/* add-ons are generally used as state-guards. that is, if a an already added
* undo-steps requires the object to be in a certain state, an add-on step
* can be queued after the fact, to ensure the required object state.
*/
-
/* add this step to the last undo step if we have one */
if (self->group && self->group->undo_steps)
{
@@ -172,19 +152,16 @@ bse_undo_stack_push_add_on (BseUndoStack *self,
bse_undo_step_free (ustep);
}
}
-
void
bse_undo_stack_unignore_steps (BseUndoStack *self)
{
g_return_if_fail (self->ignore_steps > 0);
self->ignore_steps--;
}
-
void
bse_undo_group_close (BseUndoStack *self)
{
g_return_if_fail (self->n_open_groups > 0);
-
g_free (g_slist_pop_head (&self->debug_names));
self->n_open_groups--;
if (!self->n_open_groups)
@@ -227,7 +204,6 @@ bse_undo_group_close (BseUndoStack *self)
self->notify (self->project, self, TRUE);
}
}
-
const BseUndoStep*
bse_undo_group_peek_last_atom (BseUndoStack *self,
SfiTime *stamp_p)
@@ -248,18 +224,15 @@ bse_undo_group_peek_last_atom (BseUndoStack *self,
}
return NULL;
}
-
void
bse_undo_stack_add_merger (BseUndoStack *self,
const gchar *name)
{
g_return_if_fail (name != NULL);
-
self->n_merge_requests++;
if (!self->merge_name)
self->merge_name = g_strdup (name);
}
-
void
bse_undo_stack_remove_merger (BseUndoStack *self)
{
@@ -274,26 +247,22 @@ bse_undo_stack_remove_merger (BseUndoStack *self)
}
}
}
-
guint
bse_undo_stack_depth (BseUndoStack *self)
{
return self->n_undo_groups;
}
-
const gchar*
bse_undo_stack_peek (BseUndoStack *self)
{
BseUndoGroup *group = self->undo_groups ? (BseUndoGroup*) self->undo_groups->data : NULL;
return group ? group->name : NULL;
}
-
void
bse_undo_stack_undo (BseUndoStack *self)
{
if (self->group)
g_return_if_fail (self->group->undo_steps == NULL);
-
BseUndoGroup *group = (BseUndoGroup*) sfi_ring_pop_head (&self->undo_groups);
if (group)
{
@@ -320,25 +289,21 @@ bse_undo_stack_undo (BseUndoStack *self)
if (self->notify)
self->notify (self->project, self, FALSE);
}
-
if (self->group)
g_return_if_fail (self->group->undo_steps == NULL);
}
-
BseUndoStep*
bse_undo_step_new (BseUndoFunc undo_func,
BseUndoFree free_func,
guint n_data_fields)
{
g_return_val_if_fail (undo_func != NULL, NULL);
-
BseUndoStep *ustep = (BseUndoStep*) g_malloc0 (sizeof (BseUndoStep) + sizeof (ustep->data) * (MAX (n_data_fields, 1) - 1));
ustep->undo_func = undo_func;
ustep->free_func = free_func;
ustep->debug_name = NULL;
return ustep;
}
-
void
bse_undo_step_exec (BseUndoStep *ustep,
BseUndoStack *ustack)
@@ -346,7 +311,6 @@ bse_undo_step_exec (BseUndoStep *ustep,
ustep->undo_func (ustep, ustack);
ustep->undo_func = NULL;
}
-
void
bse_undo_step_free (BseUndoStep *ustep)
{
@@ -355,7 +319,6 @@ bse_undo_step_free (BseUndoStep *ustep)
g_free (ustep->debug_name);
g_free (ustep);
}
-
gchar*
bse_undo_pointer_pack (gpointer _item,
BseUndoStack *ustack)
@@ -364,40 +327,28 @@ bse_undo_pointer_pack (gpointer _item,
if (!_item)
return NULL;
BseItem *item = BSE_ITEM (_item);
-
if (IS_DUMMY_USTACK (ustack))
return NULL;
-
BseProject *project = bse_item_get_project (item);
g_return_val_if_fail (project != NULL, NULL);
-
/* upaths start out with chars >= 7 */
if (item == (BseItem*) project)
return g_strdup ("\002project\003");
-
return bse_container_make_upath (BSE_CONTAINER (project), item);
}
-
gpointer
bse_undo_pointer_unpack (const gchar *packed_pointer,
BseUndoStack *ustack)
{
gpointer item;
-
g_return_val_if_fail (ustack != NULL, NULL);
-
if (!packed_pointer)
return NULL;
-
if (IS_DUMMY_USTACK (ustack))
return NULL;
-
if (packed_pointer[0] == 002 && strcmp (packed_pointer, "\002project\003") == 0)
return ustack->project;
-
item = bse_container_resolve_upath (BSE_CONTAINER (ustack->project), packed_pointer);
-
g_return_val_if_fail (item != NULL, NULL);
-
return item;
}
diff --git a/bse/bseundostack.hh b/bse/bseundostack.hh
index b800241..eb9730c 100644
--- a/bse/bseundostack.hh
+++ b/bse/bseundostack.hh
@@ -1,15 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_UNDO_STACK_H__
#define __BSE_UNDO_STACK_H__
-
#include <bse/bseitem.hh>
-
G_BEGIN_DECLS
-
-
#define BSE_UNDO_STACK_VOID(ustack) ((ustack)->max_steps == 0)
-
-
/* --- BseUndoStack structs --- */
typedef struct {
SfiTime stamp;
@@ -49,8 +43,6 @@ struct _BseUndoStep
gulong v_ulong;
} data[1]; /* flexible array */
};
-
-
/* --- prototypes --- */
BseUndoStack* bse_undo_stack_dummy (void);
BseUndoStack* bse_undo_stack_new (BseProject *project,
@@ -87,10 +79,7 @@ gchar* bse_undo_pointer_pack (gpointer item,
BseUndoStack *ustack);
gpointer bse_undo_pointer_unpack (const gchar *packed_pointer,
BseUndoStack *ustack);
-
const BseUndoStep* bse_undo_group_peek_last_atom (BseUndoStack *self,
SfiTime *stamp_p);
-
G_END_DECLS
-
#endif /* __BSE_UNDO_STACK_H__ */
diff --git a/bse/bseutils.cc b/bse/bseutils.cc
index 3007add..280c79a 100644
--- a/bse/bseutils.cc
+++ b/bse/bseutils.cc
@@ -2,7 +2,6 @@
#include "topconfig.h"
#include "bseutils.hh"
#include "gsldatautils.hh"
-
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -11,8 +10,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-
-
/* --- record utils --- */
BseNoteDescription*
bse_note_description (BseMusicalTuningType musical_tuning,
@@ -20,7 +17,6 @@ bse_note_description (BseMusicalTuningType musical_tuning,
int fine_tune)
{
BseNoteDescription *info = bse_note_description_new ();
-
info->musical_tuning = musical_tuning;
if (note >= BSE_MIN_NOTE && note <= BSE_MAX_NOTE)
{
@@ -49,7 +45,6 @@ bse_note_description (BseMusicalTuningType musical_tuning,
}
return info;
}
-
BsePartNote*
bse_part_note (guint id,
guint channel,
@@ -61,7 +56,6 @@ bse_part_note (guint id,
gboolean selected)
{
BsePartNote *pnote = bse_part_note_new ();
-
pnote->id = id;
pnote->channel = channel;
pnote->tick = tick;
@@ -70,21 +64,17 @@ bse_part_note (guint id,
pnote->fine_tune = fine_tune;
pnote->velocity = velocity;
pnote->selected = selected != FALSE;
-
return pnote;
}
-
void
bse_part_note_seq_take_append (BsePartNoteSeq *seq,
BsePartNote *element)
{
g_return_if_fail (seq != NULL);
g_return_if_fail (element != NULL);
-
bse_part_note_seq_append (seq, element);
bse_part_note_free (element);
}
-
BsePartControl*
bse_part_control (guint id,
guint tick,
@@ -93,44 +83,36 @@ bse_part_control (guint id,
gboolean selected)
{
BsePartControl *pctrl = bse_part_control_new ();
-
pctrl->id = id;
pctrl->tick = tick;
pctrl->control_type = ctype;
pctrl->value = value;
pctrl->selected = selected != FALSE;
-
return pctrl;
}
-
void
bse_part_control_seq_take_append (BsePartControlSeq *seq,
BsePartControl *element)
{
g_return_if_fail (seq != NULL);
g_return_if_fail (element != NULL);
-
bse_part_control_seq_append (seq, element);
bse_part_control_free (element);
}
-
void
bse_note_sequence_resize (BseNoteSequence *rec,
guint length)
{
guint fill = rec->notes->n_notes;
-
bse_note_seq_resize (rec->notes, length);
while (fill < length)
rec->notes->notes[fill++] = SFI_KAMMER_NOTE;
}
-
guint
bse_note_sequence_length (BseNoteSequence *rec)
{
return rec->notes->n_notes;
}
-
void
bse_property_candidate_relabel (BsePropertyCandidates *pc,
const gchar *label,
@@ -141,7 +123,6 @@ bse_property_candidate_relabel (BsePropertyCandidates *pc,
g_free (pc->tooltip);
pc->tooltip = g_strdup (tooltip);
}
-
void
bse_item_seq_remove (BseItemSeq *iseq,
BseItem *item)
@@ -156,7 +137,6 @@ bse_item_seq_remove (BseItemSeq *iseq,
goto restart;
}
}
-
SfiRing*
bse_item_seq_to_ring (BseItemSeq *iseq)
{
@@ -167,7 +147,6 @@ bse_item_seq_to_ring (BseItemSeq *iseq)
ring = sfi_ring_append (ring, iseq->items[i]);
return ring;
}
-
BseItemSeq*
bse_item_seq_from_ring (SfiRing *ring)
{
@@ -177,7 +156,6 @@ bse_item_seq_from_ring (SfiRing *ring)
bse_item_seq_append (iseq, (BseItem*) node->data);
return iseq;
}
-
/* --- debugging --- */
static int debug_fds[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
#define MAX_DEBUG_STREAMS (G_N_ELEMENTS (debug_fds))
@@ -207,7 +185,6 @@ bse_debug_dump_floats (guint debug_stream,
g_free (dest);
}
}
-
/* --- balance calculation --- */
double
bse_balance_get (double level1,
@@ -215,7 +192,6 @@ bse_balance_get (double level1,
{
return level2 - level1;
}
-
void
bse_balance_set (double balance,
double *level1,
@@ -248,8 +224,6 @@ bse_balance_set (double balance,
*level1 = l1;
*level2 = l2;
}
-
-
/* --- icons --- */
typedef enum /*< skip >*/
{
@@ -271,9 +245,7 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
{
BseIcon *icon;
guint bpp, encoding;
-
g_return_val_if_fail (pixdata != NULL, NULL);
-
if (pixdata->width < 1 || pixdata->width > 128 ||
pixdata->height < 1 || pixdata->height > 128)
{
@@ -292,19 +264,16 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
}
if (!pixdata->encoded_pix_data)
return NULL;
-
icon = bse_icon_new ();
icon->bytes_per_pixel = bpp;
icon->width = pixdata->width;
icon->height = pixdata->height;
sfi_bblock_resize (icon->pixels, icon->width * icon->height * icon->bytes_per_pixel);
-
if (encoding == BSE_PIXDATA_1BYTE_RLE)
{
const guint8 *rle_buffer = pixdata->encoded_pix_data;
guint8 *image_buffer = icon->pixels->bytes;
guint8 *image_limit = image_buffer + icon->width * icon->height * bpp;
-
while (image_buffer < image_limit)
{
guint length = *(rle_buffer++);
@@ -347,53 +316,42 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
}
else
memcpy (icon->pixels->bytes, pixdata->encoded_pix_data, icon->width * icon->height * bpp);
-
return icon;
}
-
static inline const guint8 *
get_uint32 (const guint8 *stream, guint *result)
{
*result = (stream[0] << 24) + (stream[1] << 16) + (stream[2] << 8) + stream[3];
return stream + 4;
}
-
BseIcon*
bse_icon_from_pixstream (const guint8 *pixstream)
{
BsePixdata pixd;
const guint8 *s = pixstream;
guint len, type, rowstride, width, height;
-
g_return_val_if_fail (pixstream != NULL, NULL);
-
if (strncmp ((const char*) s, "GdkP", 4) != 0)
return NULL;
s += 4;
-
s = get_uint32 (s, &len);
if (len < 24)
return NULL;
-
s = get_uint32 (s, &type);
if (type != 0x02010002 && /* RLE/8bit/RGBA */
type != 0x01010002) /* RAW/8bit/RGBA */
return NULL;
-
s = get_uint32 (s, &rowstride);
s = get_uint32 (s, &width);
s = get_uint32 (s, &height);
if (width < 1 || height < 1)
return NULL;
-
pixd.type = BsePixdataType (BSE_PIXDATA_RGBA | (type >> 24 == 2 ? BSE_PIXDATA_1BYTE_RLE : 0));
pixd.width = width;
pixd.height = height;
pixd.encoded_pix_data = s;
return bse_icon_from_pixdata (&pixd);
}
-
-
/* --- ID allocator --- */
#define ID_WITHHOLD_BUFFER_SIZE 59
static gulong id_counter = 1;
@@ -402,12 +360,10 @@ static gulong id_buffer[ID_WITHHOLD_BUFFER_SIZE];
static gulong id_buffer_pos = 0;
static gulong n_free_ids = 0;
static gulong *free_id_buffer = NULL;
-
void
bse_id_free (gulong id)
{
g_return_if_fail (id > 0);
-
/* release oldest withheld id */
if (n_buffer_ids >= ID_WITHHOLD_BUFFER_SIZE)
{
@@ -417,14 +373,12 @@ bse_id_free (gulong id)
free_id_buffer = g_renew (gulong, free_id_buffer, size);
free_id_buffer[n] = id_buffer[id_buffer_pos];
}
-
/* release id */
id_buffer[id_buffer_pos++] = id;
n_buffer_ids = MAX (n_buffer_ids, id_buffer_pos);
if (id_buffer_pos >= ID_WITHHOLD_BUFFER_SIZE)
id_buffer_pos = 0;
}
-
gulong
bse_id_alloc (void)
{
@@ -437,8 +391,6 @@ bse_id_alloc (void)
}
return id_counter++;
}
-
-
/* --- string array manipulation --- */
static gchar*
canonify_xinfo_key (const gchar *key)
@@ -450,7 +402,6 @@ canonify_xinfo_key (const gchar *key)
ckey[0] = '.';
return ckey;
}
-
gchar**
bse_xinfos_add_value (gchar **xinfos,
const gchar *key,
@@ -486,7 +437,6 @@ bse_xinfos_add_value (gchar **xinfos,
return xinfos;
}
}
-
gchar**
bse_xinfos_parse_assignment (gchar **xinfos,
const gchar *assignment)
@@ -505,7 +455,6 @@ bse_xinfos_parse_assignment (gchar **xinfos,
xinfos = bse_xinfos_del_value (xinfos, assignment);
return xinfos;
}
-
gchar**
bse_xinfos_del_value (gchar **xinfos,
const gchar *key)
@@ -533,7 +482,6 @@ bse_xinfos_del_value (gchar **xinfos,
}
return xinfos;
}
-
gchar**
bse_xinfos_add_float (gchar **xinfos,
const gchar *key,
@@ -542,7 +490,6 @@ bse_xinfos_add_float (gchar **xinfos,
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE * 2 + 1024];
return bse_xinfos_add_value (xinfos, key, g_ascii_dtostr (buffer, sizeof (buffer), fvalue));
}
-
gchar**
bse_xinfos_add_num (gchar **xinfos,
const gchar *key,
@@ -552,7 +499,6 @@ bse_xinfos_add_num (gchar **xinfos,
g_snprintf (buffer, sizeof (buffer), "%lld", num);
return bse_xinfos_add_value (xinfos, key, buffer);
}
-
const gchar*
bse_xinfos_get_value (gchar **xinfos,
const gchar *key)
@@ -570,7 +516,6 @@ bse_xinfos_get_value (gchar **xinfos,
}
return NULL;
}
-
gfloat
bse_xinfos_get_float (gchar **xinfos,
const gchar *key)
@@ -581,7 +526,6 @@ bse_xinfos_get_float (gchar **xinfos,
else
return 0.0;
}
-
SfiNum
bse_xinfos_get_num (gchar **xinfos,
const gchar *key)
@@ -592,7 +536,6 @@ bse_xinfos_get_num (gchar **xinfos,
else
return 0.0;
}
-
gchar**
bse_xinfos_dup_consolidated (gchar **xinfos,
gboolean copy_interns)
@@ -641,7 +584,6 @@ bse_xinfos_dup_consolidated (gchar **xinfos,
}
return NULL;
}
-
gint
bse_xinfo_stub_compare (const gchar *xinfo1, /* must contain '=' */
const gchar *xinfo2) /* must contain '=' */
@@ -654,8 +596,6 @@ bse_xinfo_stub_compare (const gchar *xinfo1, /* must contain '=' */
return l1 - l2;
return strncmp (xinfo1, xinfo2, l1);
}
-
-
/* --- miscellaeous --- */
guint
bse_string_hash (gconstpointer string)
@@ -668,7 +608,6 @@ bse_string_hash (gconstpointer string)
h = (h << 5) - h + *p;
return h;
}
-
gint
bse_string_equals (gconstpointer string1,
gconstpointer string2)
@@ -678,13 +617,11 @@ bse_string_equals (gconstpointer string1,
else
return string1 == string2;
}
-
const gchar*
bse_intern_path_user_data (const gchar *dir)
{
return g_intern_strconcat (BSE_PATH_USER_DATA ("/"), dir, NULL);
}
-
const gchar*
bse_intern_default_author (void)
{
@@ -694,23 +631,19 @@ bse_intern_default_author (void)
return g_intern_string (name);
return g_intern_static_string ("");
}
-
const gchar*
bse_intern_default_license (void)
{
return g_intern_static_string ("Creative Commons Attribution 2.5 (http://creativecommons.org/licenses/by/2.5/)");
}
-
void
bse_bbuffer_puts (gchar bbuffer[BSE_BBUFFER_SIZE],
const gchar *string)
{
g_return_if_fail (bbuffer != NULL);
-
strncpy (bbuffer, string, BSE_BBUFFER_SIZE - 1);
bbuffer[BSE_BBUFFER_SIZE - 1] = 0;
}
-
guint
bse_bbuffer_printf (gchar bbuffer[BSE_BBUFFER_SIZE],
const gchar *format,
@@ -718,13 +651,10 @@ bse_bbuffer_printf (gchar bbuffer[BSE_BBUFFER_SIZE],
{
va_list args;
guint l;
-
g_return_val_if_fail (bbuffer != NULL, 0);
g_return_val_if_fail (format != NULL, 0);
-
va_start (args, format);
l = g_vsnprintf (bbuffer, BSE_BBUFFER_SIZE, format, args);
va_end (args);
-
return l;
}
diff --git a/bse/bseutils.hh b/bse/bseutils.hh
index 5ea748f..133d878 100644
--- a/bse/bseutils.hh
+++ b/bse/bseutils.hh
@@ -1,17 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_UTILS_H__
#define __BSE_UTILS_H__
-
#include <bse/bseenums.hh>
#include <bse/bseglobals.hh>
#include <bse/bsecompat.hh>
-
G_BEGIN_DECLS
-
/* --- C++ helper declaration --- */
void bse_cxx_init (void);
-
-
/* --- record utils --- */
BseNoteDescription* bse_note_description (BseMusicalTuningType musical_tuning,
int note,
@@ -43,16 +38,12 @@ void bse_item_seq_remove (BseItemSeq *ise
BseItem *item);
SfiRing* bse_item_seq_to_ring (BseItemSeq *iseq);
BseItemSeq* bse_item_seq_from_ring (SfiRing *ring);
-
-
/* --- debugging --- */
void bse_debug_dump_floats (guint debug_stream,
guint n_channels,
guint mix_freq,
guint n_values,
gfloat *values);
-
-
/* --- balance calculation --- */
/* levels are 0..100, balance is -100..+100 */
double bse_balance_get (double level1,
@@ -60,17 +51,11 @@ double bse_balance_get (double level1,
void bse_balance_set (double balance,
double *level1,
double *level2);
-
-
/* --- icons --- */
BseIcon* bse_icon_from_pixstream (const guint8 *pixstream);
-
-
/* --- ID allocator --- */
gulong bse_id_alloc (void);
void bse_id_free (gulong id);
-
-
/* --- string array manipulation --- */
gchar** bse_xinfos_add_value (gchar **xinfos,
const gchar *key,
@@ -95,8 +80,6 @@ gchar** bse_xinfos_dup_consolidated (gchar **xinfos,
gboolean copy_interns);
gint bse_xinfo_stub_compare (const gchar *xinfo1, /* must contain '=' */
const gchar *xinfo2); /* must contain '=' */
-
-
/* --- miscellaeous --- */
guint bse_string_hash (gconstpointer string);
gint bse_string_equals (gconstpointer string1,
@@ -104,8 +87,6 @@ gint bse_string_equals (gconstpointer string1,
const gchar* bse_intern_path_user_data (const gchar *dir);
const gchar* bse_intern_default_author (void);
const gchar* bse_intern_default_license (void);
-
-
/* --- bbuffer utils --- */
#define BSE_BBUFFER_SIZE (128)
void bse_bbuffer_puts (gchar bbuffer[BSE_BBUFFER_SIZE],
@@ -120,7 +101,5 @@ bse_bbuffer_putc (gchar bbuffer[BSE_BBUFFER_SIZE],
bbuffer[0] = character;
bbuffer[1] = 0;
}
-
G_END_DECLS
-
#endif /* __BSE_UTILS_H__ */
diff --git a/bse/bsewave.cc b/bse/bsewave.cc
index 4b1df97..4470b97 100644
--- a/bse/bsewave.cc
+++ b/bse/bsewave.cc
@@ -8,18 +8,14 @@
#include "bseserver.hh"
#include "bseloader.hh"
#include "topconfig.h"
-
#include <string.h>
-
#define parse_or_return bse_storage_scanner_parse_or_return
-
enum {
PARAM_0,
PARAM_LOCATOR_SET,
PARAM_FILE_NAME,
PARAM_WAVE_NAME
};
-
typedef struct
{
GslDataHandle *data_handle;
@@ -28,8 +24,6 @@ typedef struct
gfloat wh_mix_freq;
gfloat wh_osc_freq;
} ParsedWaveChunk;
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
static GQuark quark_n_channels = 0;
@@ -40,8 +34,6 @@ static GQuark quark_wave_handle = 0;
static GQuark quark_load_wave = 0;
static GQuark quark_set_locator = 0;
static GQuark quark_wave_chunk = 0;
-
-
/* --- functions --- */
static void
bse_wave_init (BseWave *wave)
@@ -57,7 +49,6 @@ bse_wave_init (BseWave *wave)
wave->index_dirty = FALSE;
wave->index_list = NULL;
}
-
static void
bse_wave_set_property (GObject *object,
guint param_id,
@@ -71,7 +62,6 @@ bse_wave_set_property (GObject *object,
break;
}
}
-
static void
bse_wave_get_property (GObject *object,
guint param_id,
@@ -95,7 +85,6 @@ bse_wave_get_property (GObject *object,
break;
}
}
-
static gboolean
bse_wave_needs_storage (BseItem *item,
BseStorage *storage)
@@ -103,29 +92,24 @@ bse_wave_needs_storage (BseItem *item,
BseWave *self = BSE_WAVE (item);
return self->n_wchunks > 0;
}
-
static void
bse_wave_dispose (GObject *object)
{
BseWave *wave = BSE_WAVE (object);
bse_wave_clear (wave);
g_return_if_fail (wave->index_list == NULL);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_wave_finalize (GObject *object)
{
BseWave *wave = BSE_WAVE (object);
bse_wave_clear (wave);
g_return_if_fail (wave->index_list == NULL);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static BseErrorType
bse_wave_add_inlined_wave_chunk (BseWave *self,
GslWaveChunk *wchunk)
@@ -136,8 +120,6 @@ bse_wave_add_inlined_wave_chunk (BseWave *self,
self->open_handles = sfi_ring_append (self->open_handles, wchunk->dcache->dhandle);
return error;
}
-
-
GslWaveChunk*
bse_wave_lookup_chunk (BseWave *wave,
gfloat mix_freq,
@@ -146,26 +128,20 @@ bse_wave_lookup_chunk (BseWave *wave,
{
BseWaveIndex *index;
GslWaveChunk *wchunk;
-
g_return_val_if_fail (BSE_IS_WAVE (wave), NULL);
-
bse_wave_request_index (wave);
index = bse_wave_get_index_for_modules (wave);
wchunk = index ? bse_wave_index_lookup_best (index, osc_freq, velocity) : NULL;
bse_wave_drop_index (wave);
-
return wchunk;
}
-
void
bse_wave_remove_chunk (BseWave *wave, GslWaveChunk *wchunk)
{
g_return_if_fail (BSE_IS_WAVE (wave));
g_return_if_fail (wchunk != NULL);
-
wave->wave_chunks = sfi_ring_remove (wave->wave_chunks, wchunk);
wave->n_wchunks--;
-
SfiRing *ring;
for (ring = wave->open_handles; ring; ring = sfi_ring_walk (ring, wave->open_handles))
if (ring->data == (void*) wchunk->dcache->dhandle)
@@ -174,11 +150,9 @@ bse_wave_remove_chunk (BseWave *wave, GslWaveChunk *wchunk)
wave->open_handles = sfi_ring_remove_node (wave->open_handles, ring);
break;
}
-
gsl_wave_chunk_unref (wchunk);
wave->index_dirty = TRUE;
}
-
static gint
wchunk_cmp (gconstpointer a,
gconstpointer b,
@@ -186,10 +160,8 @@ wchunk_cmp (gconstpointer a,
{
const GslWaveChunk *w1 = (const GslWaveChunk*) a;
const GslWaveChunk *w2 = (const GslWaveChunk*) b;
-
return w1->osc_freq < w2->osc_freq ? -1 : w1->osc_freq > w2->osc_freq;
}
-
void
bse_wave_add_chunk (BseWave *wave,
GslWaveChunk *wchunk)
@@ -197,12 +169,10 @@ bse_wave_add_chunk (BseWave *wave,
g_return_if_fail (BSE_IS_WAVE (wave));
g_return_if_fail (wchunk != NULL);
g_return_if_fail (wchunk->dcache != NULL);
-
wave->wave_chunks = sfi_ring_insert_sorted (wave->wave_chunks, gsl_wave_chunk_ref (wchunk), wchunk_cmp, NULL);
wave->n_wchunks++;
wave->index_dirty = TRUE;
}
-
static void
bse_wave_set_locator (BseWave *wave,
const gchar *file_name,
@@ -212,29 +182,24 @@ bse_wave_set_locator (BseWave *wave,
g_return_if_fail (file_name != NULL);
g_return_if_fail (wave_name != NULL);
g_return_if_fail (wave->locator_set == FALSE);
-
wave->locator_set = TRUE;
wave->file_name = g_strdup (file_name);
wave->wave_name = g_strdup (wave_name);
-
g_object_freeze_notify (G_OBJECT (wave));
g_object_notify (G_OBJECT (wave), "locator_set");
g_object_notify (G_OBJECT (wave), "file_name");
g_object_notify (G_OBJECT (wave), "wave_name");
g_object_thaw_notify (G_OBJECT (wave));
}
-
void
bse_wave_clear (BseWave *wave)
{
g_return_if_fail (BSE_IS_WAVE (wave));
-
/* delete all wave chunks */
while (wave->wave_chunks)
bse_wave_remove_chunk (wave, (GslWaveChunk*) wave->wave_chunks->data);
while (wave->open_handles)
gsl_data_handle_close ((GslDataHandle*) sfi_ring_pop_head (&wave->open_handles));
-
/* free fields */
g_free (wave->file_name);
wave->file_name = NULL;
@@ -243,7 +208,6 @@ bse_wave_clear (BseWave *wave)
g_strfreev (wave->xinfos);
wave->xinfos = NULL;
}
-
BseErrorType
bse_wave_load_wave_file (BseWave *self,
const gchar *file_name,
@@ -253,14 +217,10 @@ bse_wave_load_wave_file (BseWave *self,
gboolean rename_wave)
{
BseErrorType error = BSE_ERROR_NONE;
-
g_return_val_if_fail (BSE_IS_WAVE (self), BSE_ERROR_INTERNAL);
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
bse_wave_clear (self);
-
BseWaveFileInfo *fi = NULL;
-
if (!g_path_is_absolute (file_name)) /* resolve relative path using search dir */
{
char *sample_path;
@@ -270,7 +230,6 @@ bse_wave_load_wave_file (BseWave *self,
else
sample_path = g_path_concat (BSE_PATH_SAMPLES, BSE_GCONFIG (sample_path), NULL);
files = sfi_file_crawler_list_files (sample_path, file_name, G_FILE_TEST_IS_REGULAR);
-
for (walk = files; walk; walk = sfi_ring_walk (files, walk))
{
char *fname = (char*) walk->data;
@@ -342,7 +301,6 @@ bse_wave_load_wave_file (BseWave *self,
}
return error;
}
-
static void
bse_wave_store_private (BseObject *object,
BseStorage *storage)
@@ -350,13 +308,11 @@ bse_wave_store_private (BseObject *object,
BseWave *wave = BSE_WAVE (object);
/* chain parent class' handler */
BSE_OBJECT_CLASS (parent_class)->store_private (object, storage);
-
if (wave->locator_set && !BSE_STORAGE_SELF_CONTAINED (storage))
{
bse_storage_break (storage);
bse_storage_printf (storage, "(load-wave \"%s\" \"%s\")", wave->file_name, wave->wave_name);
}
-
if (!wave->locator_set || BSE_STORAGE_SELF_CONTAINED (storage))
{
if (wave->xinfos && wave->xinfos[0])
@@ -403,17 +359,14 @@ bse_wave_store_private (BseObject *object,
}
}
}
-
static GTokenType
parse_wave_chunk (BseWave *wave,
BseStorage *storage,
GScanner *scanner,
ParsedWaveChunk *pwchunk)
-
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return SFI_TOKEN_UNMATCHED;
-
GQuark quark = g_quark_try_string (scanner->next_value.v_string);
if (quark == quark_xinfos)
{
@@ -481,7 +434,6 @@ parse_wave_chunk (BseWave *wave,
return SFI_TOKEN_UNMATCHED;
return g_scanner_get_next_token (scanner) == ')' ? G_TOKEN_NONE : GTokenType (')');
}
-
static GTokenType
bse_wave_restore_private (BseObject *object,
BseStorage *storage,
@@ -490,11 +442,9 @@ bse_wave_restore_private (BseObject *object,
BseWave *wave = BSE_WAVE (object);
GTokenType expected_token;
GQuark quark;
-
/* chain parent class' handler */
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
-
/* parse storage commands */
quark = g_quark_try_string (scanner->next_value.v_identifier);
if (quark == quark_xinfos)
@@ -516,7 +466,6 @@ bse_wave_restore_private (BseObject *object,
BseFreqArray *skip_list, *load_list, *array;
gchar *file_name, *wave_name;
BseErrorType error;
-
g_scanner_get_next_token (scanner); /* eat quark identifier */
parse_or_return (scanner, G_TOKEN_STRING);
file_name = g_strdup (scanner->value.v_string);
@@ -601,7 +550,6 @@ bse_wave_restore_private (BseObject *object,
else if (quark == quark_wave_chunk)
{
ParsedWaveChunk parsed_wchunk = { NULL, NULL, 0, 0, 0 };
-
g_scanner_get_next_token (scanner); /* eat quark identifier */
g_scanner_peek_next_token (scanner);
bse_storage_compat_dhreset (storage); /* VERSION-FIXME: needed for <= 0.5.1 */
@@ -612,7 +560,6 @@ bse_wave_restore_private (BseObject *object,
(scanner->token == G_TOKEN_INT ?
scanner->value.v_int64 : scanner->value.v_float));
g_scanner_peek_next_token (scanner);
-
if (scanner->next_token == G_TOKEN_FLOAT || scanner->next_token == G_TOKEN_INT)
{
g_scanner_get_next_token (scanner);
@@ -621,12 +568,10 @@ bse_wave_restore_private (BseObject *object,
scanner->value.v_int64 : scanner->value.v_float));
}
}
-
expected_token = bse_storage_parse_rest (storage, wave,
(BseTryStatement) parse_wave_chunk,
&parsed_wchunk);
bse_storage_compat_dhreset (storage); /* VERSION-FIXME: needed for <= 0.5.1 */
-
if (expected_token == G_TOKEN_NONE && parsed_wchunk.data_handle)
{
if (0)
@@ -673,26 +618,21 @@ bse_wave_restore_private (BseObject *object,
}
else /* chain parent class' handler */
expected_token = (GTokenType) BSE_OBJECT_CLASS (parent_class)->restore_private (object, storage, scanner);
-
return expected_token;
}
-
void
bse_wave_request_index (BseWave *wave)
{
g_return_if_fail (BSE_IS_WAVE (wave));
-
if (!wave->request_count)
g_object_ref (wave);
wave->request_count++;
}
-
BseWaveIndex*
bse_wave_get_index_for_modules (BseWave *wave)
{
g_return_val_if_fail (BSE_IS_WAVE (wave), NULL);
g_return_val_if_fail (wave->request_count > 0, NULL);
-
if (!wave->n_wchunks)
return NULL;
if (wave->index_dirty || !wave->index_list)
@@ -717,13 +657,11 @@ bse_wave_get_index_for_modules (BseWave *wave)
}
return (BseWaveIndex*) wave->index_list->data;
}
-
void
bse_wave_drop_index (BseWave *wave)
{
g_return_if_fail (BSE_IS_WAVE (wave));
g_return_if_fail (wave->request_count > 0);
-
wave->request_count--;
if (!wave->request_count)
{
@@ -731,7 +669,6 @@ bse_wave_drop_index (BseWave *wave)
{
GSList *tmp = wave->index_list->next;
BseWaveIndex *index = (BseWaveIndex*) wave->index_list->data;
-
for (uint i = 0; i < index->n_entries; i++)
gsl_wave_chunk_close (index->entries[i].wchunk);
g_free (index);
@@ -741,7 +678,6 @@ bse_wave_drop_index (BseWave *wave)
g_object_unref (wave);
}
}
-
GslWaveChunk*
bse_wave_index_lookup_best (BseWaveIndex *windex,
gfloat osc_freq,
@@ -749,20 +685,16 @@ bse_wave_index_lookup_best (BseWaveIndex *windex,
{
gfloat best_diff = 1e+9;
const BseWaveEntry *best_chunk = NULL;
-
g_return_val_if_fail (windex != NULL, NULL);
-
if (windex->n_entries > 0)
{
const BseWaveEntry *check, *nodes = &windex->entries[0];
guint n_nodes = windex->n_entries;
-
nodes -= 1;
do
{
register gfloat cmp;
register guint i;
-
i = (n_nodes + 1) >> 1;
check = nodes + i;
cmp = osc_freq - check->wchunk->osc_freq;
@@ -793,26 +725,20 @@ bse_wave_index_lookup_best (BseWaveIndex *windex,
}
return best_chunk->wchunk;
}
-
static void
bse_wave_class_init (BseWaveClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_wave_set_property;
gobject_class->get_property = bse_wave_get_property;
gobject_class->dispose = bse_wave_dispose;
gobject_class->finalize = bse_wave_finalize;
-
object_class->store_private = bse_wave_store_private;
object_class->restore_private = bse_wave_restore_private;
-
item_class->needs_storage = bse_wave_needs_storage;
-
quark_n_channels = g_quark_from_static_string ("n-channels");
quark_xinfos = g_quark_from_static_string ("xinfos");
quark_loop = g_quark_from_static_string ("loop");
@@ -821,7 +747,6 @@ bse_wave_class_init (BseWaveClass *klass)
quark_load_wave = g_quark_from_static_string ("load-wave");
quark_set_locator = g_quark_from_static_string ("set-locator");
quark_wave_chunk = g_quark_from_static_string ("wave-chunk");
-
bse_object_class_add_param (object_class, "Locator",
PARAM_LOCATOR_SET,
sfi_pspec_bool ("locator_set", "Locator Set", NULL,
@@ -835,23 +760,19 @@ bse_wave_class_init (BseWaveClass *klass)
sfi_pspec_string ("wave_name", "Wave Name", NULL,
NULL, "G:r"));
}
-
BSE_BUILTIN_TYPE (BseWave)
{
static const GTypeInfo wave_info = {
sizeof (BseWaveClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_wave_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseWave),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_wave_init,
};
-
return bse_type_register_static (BSE_TYPE_SOURCE,
"BseWave",
"BSE wave type",
diff --git a/bse/bsewave.hh b/bse/bsewave.hh
index 05327c0..e5e1057 100644
--- a/bse/bsewave.hh
+++ b/bse/bsewave.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_WAVE_H__
#define __BSE_WAVE_H__
-
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- BSE type macros --- */
#define BSE_TYPE_WAVE (BSE_TYPE_ID (BseWave))
#define BSE_WAVE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_WAVE, BseWave))
@@ -13,8 +10,6 @@ G_BEGIN_DECLS
#define BSE_IS_WAVE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_WAVE))
#define BSE_IS_WAVE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_WAVE))
#define BSE_WAVE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_WAVE, BseWaveClass))
-
-
/* --- BseWave --- */
typedef struct _BseWaveClass BseWaveClass;
typedef struct {
@@ -29,20 +24,16 @@ typedef struct {
struct _BseWave
{
BseSource parent_object;
-
/* requested BseModule indices */
guint request_count;
GSList *index_list;
guint index_dirty : 1;
-
/* locator */
guint locator_set : 1;
gchar *file_name;
gchar *wave_name;
-
/* wave data */
gchar **xinfos;
-
/* wave chunks */
guint n_wchunks;
SfiRing *wave_chunks; /* data=GslWaveChunk* */
@@ -52,8 +43,6 @@ struct _BseWaveClass
{
BseSourceClass parent_class;
};
-
-
/* --- prototypes -- */
void bse_wave_clear (BseWave *wave);
BseErrorType bse_wave_load_wave_file (BseWave *wave,
@@ -73,12 +62,9 @@ void bse_wave_remove_chunk (BseWave *wave,
void bse_wave_request_index (BseWave *wave);
BseWaveIndex* bse_wave_get_index_for_modules (BseWave *wave);
void bse_wave_drop_index (BseWave *wave);
-
/* BseWaveIndex is safe to use from BseModules (self-contained constant structure) */
GslWaveChunk* bse_wave_index_lookup_best (BseWaveIndex *windex,
gfloat osc_freq,
gfloat velocity);
-
G_END_DECLS
-
#endif /* __BSE_WAVE_H__ */
diff --git a/bse/bsewave.proc b/bse/bsewave.proc
index 1de7338..cc83edf 100644
--- a/bse/bsewave.proc
+++ b/bse/bsewave.proc
@@ -3,12 +3,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bsewave.hh>
#include <bse/bseeditablesample.hh>
-
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseWave, load-wave) {
HELP = "Load sample chunks from a wave file";
IN = bse_param_spec_object ("wave", "Wave", "Wave object to store loaded contents",
@@ -30,19 +26,14 @@ BODY (BseProcedureClass *proc,
const char *file_name = sfi_value_get_string (in_values++);
const char *wave_name = sfi_value_get_string (in_values++);
BseErrorType error = BSE_ERROR_NONE;
-
/* check parameters */
if (!BSE_IS_WAVE (wave) || !file_name || !wave_name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
error = bse_wave_load_wave_file (wave, file_name, wave_name, NULL, NULL, TRUE);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWave, n-wave-chunks) {
HELP = "Get the number of wave chunks of a wave";
IN = bse_param_spec_object ("wave", "Wave", NULL,
@@ -56,17 +47,13 @@ BODY (BseProcedureClass *proc,
{
/* extract parameter values */
BseWave *wave = (BseWave*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_WAVE (wave))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* set output parameters */
sfi_value_set_int (out_values++, wave->n_wchunks);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWave, use-editable) {
HELP = "Retrieve an editable sample object for a wave chunk.";
IN = bse_param_spec_object ("wave", "Wave", NULL,
@@ -85,11 +72,9 @@ BODY (BseProcedureClass *proc,
guint chunk_index = sfi_value_get_int (in_values++);
BseEditableSample *esample = NULL;
GslWaveChunk *wchunk = NULL;
-
/* check parameters */
if (!BSE_IS_WAVE (wave))
return BSE_ERROR_PROC_PARAM_INVAL;
-
wchunk = (GslWaveChunk*) sfi_ring_nth_data (wave->wave_chunks, chunk_index);
if (wchunk)
{
@@ -98,13 +83,10 @@ BODY (BseProcedureClass *proc,
bse_item_use (BSE_ITEM (esample));
g_object_unref (esample);
}
-
/* set output parameters */
bse_value_set_object (out_values++, esample);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWave, chunk-get-osc-freq) {
HELP = "Retrieve oscillating frequency of a wave chunk.";
IN = bse_param_spec_object ("wave", "Wave", NULL,
@@ -123,18 +105,14 @@ BODY (BseProcedureClass *proc,
BseWave *wave = (BseWave*) bse_value_get_object (in_values++);
guint chunk_index = sfi_value_get_int (in_values++);
GslWaveChunk *wchunk = NULL;
-
/* check parameters */
if (!BSE_IS_WAVE (wave))
return BSE_ERROR_PROC_PARAM_INVAL;
-
wchunk = (GslWaveChunk*) sfi_ring_nth_data (wave->wave_chunks, chunk_index);
if (wchunk)
sfi_value_set_real (out_values++, wchunk->osc_freq);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWave, chunk-get-mix-freq) {
HELP = "Retrieve mixing frequency of a wave chunk.";
IN = bse_param_spec_object ("wave", "Wave", NULL,
@@ -153,14 +131,11 @@ BODY (BseProcedureClass *proc,
BseWave *wave = (BseWave*) bse_value_get_object (in_values++);
guint chunk_index = sfi_value_get_int (in_values++);
GslWaveChunk *wchunk = NULL;
-
/* check parameters */
if (!BSE_IS_WAVE (wave))
return BSE_ERROR_PROC_PARAM_INVAL;
-
wchunk = (GslWaveChunk*) sfi_ring_nth_data (wave->wave_chunks, chunk_index);
if (wchunk)
sfi_value_set_real (out_values++, wchunk->mix_freq);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsewaveosc.cc b/bse/bsewaveosc.cc
index b5e5e3e..d7fbf4a 100644
--- a/bse/bsewaveosc.cc
+++ b/bse/bsewaveosc.cc
@@ -8,9 +8,6 @@
#include <bse/bseengine.hh>
#include <bse/gslwavechunk.hh>
#include <bse/gslfilter.hh>
-
-
-
/* --- parameters --- */
enum
{
@@ -21,8 +18,6 @@ enum
PARAM_FM_EXP,
PARAM_FM_OCTAVES
};
-
-
/* --- prototypes --- */
static void bse_wave_osc_init (BseWaveOsc *self);
static void bse_wave_osc_class_init (BseWaveOscClass *klass);
@@ -41,32 +36,25 @@ static void bse_wave_osc_context_create (BseSource *source,
BseTrans *trans);
static void bse_wave_osc_update_config_wchunk (BseWaveOsc *self);
static void bse_wave_osc_update_modules (BseWaveOsc *self);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
static guint signal_notify_pcm_position = 0;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseWaveOsc)
{
static const GTypeInfo type_info = {
sizeof (BseWaveOscClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_wave_osc_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseWaveOsc),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_wave_osc_init,
};
#include "./icons/waveosc.c"
GType type;
-
type = bse_type_register_static (BSE_TYPE_SOURCE,
"BseWaveOsc",
"BseWaveOsc is a wave based oscillator module. "
@@ -80,7 +68,6 @@ BSE_BUILTIN_TYPE (BseWaveOsc)
bse_categories_register_stock_module(N_("/Audio Sources/Wave Oscillator"), type, waveosc_pixstream);
return type;
}
-
static void
bse_wave_osc_init (BseWaveOsc *self)
{
@@ -97,7 +84,6 @@ bse_wave_osc_init (BseWaveOsc *self)
self->config.exponential_fm = FALSE;
self->config.cfreq = 440.;
}
-
static void
bse_wave_osc_get_candidates (BseItem *item,
guint param_id,
@@ -122,7 +108,6 @@ bse_wave_osc_get_candidates (BseItem *item,
break;
}
}
-
static void
wave_osc_uncross_wave (BseItem *owner,
BseItem *ref_item)
@@ -130,7 +115,6 @@ wave_osc_uncross_wave (BseItem *owner,
BseWaveOsc *self = BSE_WAVE_OSC (owner);
bse_item_set (self, "wave", NULL, NULL);
}
-
static void
clear_wave_and_esample (BseWaveOsc *self)
{
@@ -153,7 +137,6 @@ clear_wave_and_esample (BseWaveOsc *self)
bse_wave_drop_index (wave);
g_object_notify ((GObject*) self, "wave");
}
-
if (self->esample_wchunk)
{
GslWaveChunk *esample_wchunk = self->esample_wchunk;
@@ -170,18 +153,15 @@ clear_wave_and_esample (BseWaveOsc *self)
gsl_wave_chunk_close (esample_wchunk);
}
}
-
void
bse_wave_osc_set_from_esample (BseWaveOsc *self,
BseEditableSample *esample)
{
g_return_if_fail (BSE_WAVE_OSC (self));
-
clear_wave_and_esample (self);
if (esample)
{
g_return_if_fail (BSE_EDITABLE_SAMPLE (esample));
-
if (esample->wchunk && gsl_wave_chunk_open (esample->wchunk) == BSE_ERROR_NONE)
{
self->esample_wchunk = esample->wchunk;
@@ -192,7 +172,6 @@ bse_wave_osc_set_from_esample (BseWaveOsc *self,
}
}
}
-
static void
bse_wave_osc_set_property (GObject *object,
guint param_id,
@@ -200,7 +179,6 @@ bse_wave_osc_set_property (GObject *object,
GParamSpec *pspec)
{
BseWaveOsc *self = BSE_WAVE_OSC (object);
-
switch (param_id)
{
BseWave *wave;
@@ -260,7 +238,6 @@ bse_wave_osc_set_property (GObject *object,
break;
}
}
-
static void
bse_wave_osc_get_property (GObject *object,
guint param_id,
@@ -268,7 +245,6 @@ bse_wave_osc_get_property (GObject *object,
GParamSpec *pspec)
{
BseWaveOsc *self = BSE_WAVE_OSC (object);
-
switch (param_id)
{
case PARAM_WAVE:
@@ -291,43 +267,33 @@ bse_wave_osc_get_property (GObject *object,
break;
}
}
-
static void
bse_wave_osc_dispose (GObject *object)
{
BseWaveOsc *self = BSE_WAVE_OSC (object);
-
clear_wave_and_esample (self);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_wave_osc_finalize (GObject *object)
{
BseWaveOsc *self = BSE_WAVE_OSC (object);
-
if (self->esample_wchunk)
gsl_wave_chunk_close (self->esample_wchunk);
self->esample_wchunk = NULL;
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
wosc_access (BseModule *module,
gpointer data)
{
GslWaveOscData *wosc = (GslWaveOscData*) module->user_data;
GslWaveOscConfig *config = (GslWaveOscConfig*) data;
-
/* this runs in the Gsl Engine threads */
-
gsl_wave_osc_config (wosc, config);
}
-
static GslWaveChunk*
wchunk_from_data (gpointer wchunk_data,
gfloat freq,
@@ -335,14 +301,12 @@ wchunk_from_data (gpointer wchunk_data,
{
return (GslWaveChunk*) wchunk_data;
}
-
static inline GslWaveChunk*
wave_index_lookup_best (void *data, float freq, float vel)
{
BseWaveIndex *wave = (BseWaveIndex*) data;
return bse_wave_index_lookup_best (wave, freq, vel);
}
-
static void
bse_wave_osc_update_config_wchunk (BseWaveOsc *self)
{
@@ -361,7 +325,6 @@ bse_wave_osc_update_config_wchunk (BseWaveOsc *self)
self->config.lookup_wchunk = wchunk_from_data;
}
}
-
static void
bse_wave_osc_update_modules (BseWaveOsc *self)
{
@@ -372,7 +335,6 @@ bse_wave_osc_update_modules (BseWaveOsc *self)
g_free,
NULL);
}
-
static void
wosc_free (gpointer data,
const BseModuleClass *klass)
@@ -381,14 +343,12 @@ wosc_free (gpointer data,
gsl_wave_osc_shutdown (wosc);
g_free (wosc);
}
-
static void
wosc_process (BseModule *module,
guint n_values)
{
GslWaveOscData *wosc = (GslWaveOscData*) module->user_data;
gfloat gate, done;
-
gsl_wave_osc_process (wosc,
n_values,
(BSE_MODULE_ISTREAM (module, BSE_WAVE_OSC_ICHANNEL_FREQ).connected ?
@@ -398,20 +358,17 @@ wosc_process (BseModule *module,
(BSE_MODULE_ISTREAM (module, BSE_WAVE_OSC_ICHANNEL_SYNC).connected ?
BSE_MODULE_IBUFFER (module, BSE_WAVE_OSC_ICHANNEL_SYNC) : NULL),
BSE_MODULE_OBUFFER (module, BSE_WAVE_OSC_OCHANNEL_WAVE));
-
gate = wosc->done ? 0.0 : 1.0;
done = wosc->done ? 1.0 : 0.0;
module->ostreams[BSE_WAVE_OSC_OCHANNEL_GATE].values = bse_engine_const_values (gate);
module->ostreams[BSE_WAVE_OSC_OCHANNEL_DONE].values = bse_engine_const_values (done);
}
-
static void
wosc_reset (BseModule *module)
{
GslWaveOscData *wosc = (GslWaveOscData*) module->user_data;
gsl_wave_osc_reset (wosc);
}
-
static void
bse_wave_osc_context_create (BseSource *source,
guint context_handle,
@@ -430,37 +387,28 @@ bse_wave_osc_context_create (BseSource *source,
BseWaveOsc *self = BSE_WAVE_OSC (source);
GslWaveOscData *wosc = g_new0 (GslWaveOscData, 1);
BseModule *module;
-
gsl_wave_osc_init (wosc);
gsl_wave_osc_config (wosc, &self->config);
-
module = bse_module_new (&wosc_class, wosc);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
-
typedef struct {
BseWaveOsc *wosc;
gfloat perc;
guint64 stamp;
guint module_pcm_position;
} PcmPos;
-
static void
pcm_pos_access (BseModule *module, /* EngineThread */
gpointer data)
{
GslWaveOscData *wosc = (GslWaveOscData*) module->user_data;
PcmPos *pos = (PcmPos*) data;
-
pos->stamp = GSL_TICK_STAMP;
pos->module_pcm_position = gsl_wave_osc_cur_pos (wosc);
if (pos->perc >= 0 && wosc->wchunk)
@@ -470,20 +418,16 @@ pcm_pos_access (BseModule *module, /* EngineThread */
gsl_wave_osc_config (wosc, &config);
}
}
-
static void
pcm_pos_access_free (gpointer data) /* UserThread */
{
PcmPos *pos = (PcmPos*) data;
BseWaveOsc *self = pos->wosc;
-
if (pos->perc < 0)
g_signal_emit (self, signal_notify_pcm_position, 0, pos->stamp, pos->module_pcm_position);
-
g_object_unref (self);
g_free (pos);
}
-
void
bse_wave_osc_mass_seek (guint n_woscs,
BseWaveOsc **woscs,
@@ -510,12 +454,10 @@ bse_wave_osc_mass_seek (guint n_woscs,
}
bse_trans_commit (trans);
}
-
void
bse_wave_osc_request_pcm_position (BseWaveOsc *self)
{
g_return_if_fail (BSE_IS_WAVE_OSC (self));
-
if (BSE_SOURCE_PREPARED (self))
{
PcmPos *pos = g_new (PcmPos, 1);
@@ -528,7 +470,6 @@ bse_wave_osc_request_pcm_position (BseWaveOsc *self)
NULL);
}
}
-
static void
bse_wave_osc_class_init (BseWaveOscClass *klass)
{
@@ -537,18 +478,13 @@ bse_wave_osc_class_init (BseWaveOscClass *klass)
BseItemClass *item_class = BSE_ITEM_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel, ichannel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_wave_osc_set_property;
gobject_class->get_property = bse_wave_osc_get_property;
gobject_class->finalize = bse_wave_osc_finalize;
gobject_class->dispose = bse_wave_osc_dispose;
-
item_class->get_candidates = bse_wave_osc_get_candidates;
-
source_class->context_create = bse_wave_osc_context_create;
-
bse_object_class_add_param (object_class, _("Wave"),
PARAM_WAVE,
bse_param_spec_object ("wave", _("Wave"), _("Wave used as oscillator source"),
@@ -575,12 +511,10 @@ bse_wave_osc_class_init (BseWaveOscClass *klass)
_("Number of octaves to be affected by exponential frequency modulation"),
1.0, 0, 3.0, 0.01,
SFI_PARAM_STANDARD ":scale"));
-
signal_notify_pcm_position = bse_object_class_add_signal (object_class, "notify_pcm_position",
G_TYPE_NONE, 2,
SFI_TYPE_NUM,
G_TYPE_INT);
-
ichannel = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Frequency Input"));
g_assert (ichannel == BSE_WAVE_OSC_ICHANNEL_FREQ);
ichannel = bse_source_class_add_ichannel (source_class, "sync-in", _("Sync In"), _("Syncronization Input"));
diff --git a/bse/bsewaveosc.hh b/bse/bsewaveosc.hh
index 1a71658..cf40032 100644
--- a/bse/bsewaveosc.hh
+++ b/bse/bsewaveosc.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_WAVE_OSC_H__
#define __BSE_WAVE_OSC_H__
-
#include <bse/bsesource.hh>
#include <bse/bsewave.hh>
#include <bse/gslwaveosc.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_WAVE_OSC (BSE_TYPE_ID (BseWaveOsc))
#define BSE_WAVE_OSC(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_WAVE_OSC, BseWaveOsc))
@@ -15,15 +12,12 @@ G_BEGIN_DECLS
#define BSE_IS_WAVE_OSC(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_WAVE_OSC))
#define BSE_IS_WAVE_OSC_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_WAVE_OSC))
#define BSE_WAVE_OSC_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_WAVE_OSC, BseWaveOscClass))
-
-
/* --- BseWaveOsc source --- */
typedef struct _BseWaveOsc BseWaveOsc;
typedef struct _BseWaveOscClass BseWaveOscClass;
struct _BseWaveOsc
{
BseSource parent_object;
-
BseWave *wave;
GslWaveChunk *esample_wchunk;
GslWaveOscConfig config;
@@ -34,8 +28,6 @@ struct _BseWaveOscClass
{
BseSourceClass parent_class;
};
-
-
/* --- prototypes --- */
void bse_wave_osc_request_pcm_position (BseWaveOsc *self);
void bse_wave_osc_mass_seek (guint n_woscs,
@@ -43,8 +35,6 @@ void bse_wave_osc_mass_seek (guint n_woscs,
gfloat perc);
void bse_wave_osc_set_from_esample (BseWaveOsc *self,
BseEditableSample *esample);
-
-
/* --- channels --- */
enum
{
@@ -60,7 +50,5 @@ enum
BSE_WAVE_OSC_OCHANNEL_DONE,
BSE_WAVE_OSC_N_OCHANNELS
};
-
G_END_DECLS
-
#endif /* __BSE_WAVE_OSC_H__ */
diff --git a/bse/bsewaveosc.proc b/bse/bsewaveosc.proc
index d790e58..5616197 100644
--- a/bse/bsewaveosc.proc
+++ b/bse/bsewaveosc.proc
@@ -4,11 +4,8 @@
#include <bse/bseprocedure.hh>
#include <bse/bseeditablesample.hh>
#include "bsecxxplugin.hh"
-
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseWaveOsc, request-pcm-position) {
HELP = "Request emission of the ::notify_pcm_position signal.";
IN = bse_param_spec_object ("wosc", NULL, "Wave Oscilator",
@@ -19,16 +16,12 @@ METHOD (BseWaveOsc, request-pcm-position) {
{
/* extract parameter values */
BseWaveOsc *self = (BseWaveOsc*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_WAVE_OSC (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_wave_osc_request_pcm_position (self);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-wave-osc-mass-seek-perc, "Seek Wave Oscillators") {
HELP = "Seek a list of wave oscillators to a pcm position given in percentage. The oscillators will seek to the given position syncronously.";
IN = bse_param_spec_boxed ("wosc-seq", "Wave Oscilators", NULL, BSE_TYPE_ITEM_SEQ, SFI_PARAM_STANDARD); // FIXME: using BseItemSeq because BseWaveOscSeq requires idl+C++
@@ -51,10 +44,8 @@ PROCEDURE (bse-wave-osc-mass-seek-perc, "Seek Wave Oscillators") {
woscs[i] = (BseWaveOsc*) iseq->items[i];
if (n)
bse_wave_osc_mass_seek (n, woscs, pos);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWaveOsc, set-from-editable-sample) {
HELP = "Set wave to play from editable sample, bypassing undo and storage mechanisms.";
IN = bse_param_spec_object ("wosc", NULL, "Wave Oscilator",
@@ -68,12 +59,9 @@ METHOD (BseWaveOsc, set-from-editable-sample) {
/* extract parameter values */
BseWaveOsc *self = (BseWaveOsc*) bse_value_get_object (in_values++);
BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
/* check parameters */
if (!BSE_IS_WAVE_OSC (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
bse_wave_osc_set_from_esample (self, esample);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/bsewaverepo.cc b/bse/bsewaverepo.cc
index f1ee12e..3e840b8 100644
--- a/bse/bsewaverepo.cc
+++ b/bse/bsewaverepo.cc
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsewaverepo.hh"
-
#include "bsewave.hh"
-
-
/* --- parameters --- */
enum
{
PARAM_0,
};
-
-
/* --- prototypes --- */
static void bse_wave_repo_class_init (BseWaveRepoClass *klass);
static void bse_wave_repo_init (BseWaveRepo *wrepo);
@@ -31,31 +26,23 @@ static void bse_wave_repo_forall_items (BseContainer *container,
gpointer data);
static void bse_wave_repo_remove_item (BseContainer *container,
BseItem *item);
-
-
/* --- variables --- */
static GTypeClass *parent_class = NULL;
-
-
/* --- functions --- */
BSE_BUILTIN_TYPE (BseWaveRepo)
{
GType wave_repo_type;
-
static const GTypeInfo snet_info = {
sizeof (BseWaveRepoClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_wave_repo_class_init,
(GClassFinalizeFunc) NULL,
NULL /* class_data */,
-
sizeof (BseWaveRepo),
0,
(GInstanceInitFunc) bse_wave_repo_init,
};
-
wave_repo_type = bse_type_register_static (BSE_TYPE_SUPER,
"BseWaveRepo",
"BSE Wave Repository",
@@ -63,52 +50,41 @@ BSE_BUILTIN_TYPE (BseWaveRepo)
&snet_info);
return wave_repo_type;
}
-
static void
bse_wave_repo_class_init (BseWaveRepoClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseContainerClass *container_class = BSE_CONTAINER_CLASS (klass);
-
parent_class = (GTypeClass*) g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_wave_repo_set_property;
gobject_class->get_property = bse_wave_repo_get_property;
gobject_class->dispose = bse_wave_repo_dispose;
-
container_class->add_item = bse_wave_repo_add_item;
container_class->remove_item = bse_wave_repo_remove_item;
container_class->forall_items = bse_wave_repo_forall_items;
container_class->release_children = bse_wave_repo_release_children;
}
-
static void
bse_wave_repo_init (BseWaveRepo *wrepo)
{
wrepo->waves = NULL;
}
-
static void
bse_wave_repo_release_children (BseContainer *container)
{
BseWaveRepo *wrepo = BSE_WAVE_REPO (container);
-
while (wrepo->waves)
bse_container_remove_item (container, (BseItem*) wrepo->waves->data);
-
/* chain parent class' handler */
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
static void
bse_wave_repo_dispose (GObject *object)
{
// BseWaveRepo *wrepo = BSE_WAVE_REPO (object);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-
static void
bse_wave_repo_set_property (GObject *object,
guint param_id,
@@ -123,7 +99,6 @@ bse_wave_repo_set_property (GObject *object,
break;
}
}
-
static void
bse_wave_repo_get_property (GObject *object,
guint param_id,
@@ -138,23 +113,19 @@ bse_wave_repo_get_property (GObject *object,
break;
}
}
-
static void
bse_wave_repo_add_item (BseContainer *container,
BseItem *item)
{
BseWaveRepo *wrepo = BSE_WAVE_REPO (container);
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_WAVE))
wrepo->waves = g_list_append (wrepo->waves, item);
else
g_warning ("BseWaveRepo: cannot hold non-wave item type `%s'",
BSE_OBJECT_TYPE_NAME (item));
-
/* chain parent class' add_item handler */
BSE_CONTAINER_CLASS (parent_class)->add_item (container, item);
}
-
static void
bse_wave_repo_forall_items (BseContainer *container,
BseForallItemsFunc func,
@@ -162,7 +133,6 @@ bse_wave_repo_forall_items (BseContainer *container,
{
BseWaveRepo *wrepo = BSE_WAVE_REPO (container);
GList *list;
-
list = wrepo->waves;
while (list)
{
@@ -173,19 +143,16 @@ bse_wave_repo_forall_items (BseContainer *container,
return;
}
}
-
static void
bse_wave_repo_remove_item (BseContainer *container,
BseItem *item)
{
BseWaveRepo *wrepo = BSE_WAVE_REPO (container);
-
if (g_type_is_a (BSE_OBJECT_TYPE (item), BSE_TYPE_WAVE))
wrepo->waves = g_list_remove (wrepo->waves, item);
else
g_warning ("BseWaveRepo: cannot hold non-wave item type `%s'",
BSE_OBJECT_TYPE_NAME (item));
-
/* chain parent class' remove_item handler */
BSE_CONTAINER_CLASS (parent_class)->remove_item (container, item);
}
diff --git a/bse/bsewaverepo.hh b/bse/bsewaverepo.hh
index 969e0e0..b97932e 100644
--- a/bse/bsewaverepo.hh
+++ b/bse/bsewaverepo.hh
@@ -1,13 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_WAVE_REPO_H__
#define __BSE_WAVE_REPO_H__
-
#include <bse/bsesuper.hh>
-
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define BSE_TYPE_WAVE_REPO (BSE_TYPE_ID (BseWaveRepo))
#define BSE_WAVE_REPO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_WAVE_REPO, BseWaveRepo))
@@ -15,24 +10,16 @@ G_BEGIN_DECLS
#define BSE_IS_WAVE_REPO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_WAVE_REPO))
#define BSE_IS_WAVE_REPO_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_WAVE_REPO))
#define BSE_WAVE_REPO_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_WAVE_REPO, BseWaveRepoClass))
-
-
/* --- BseWaveRepo object --- */
struct _BseWaveRepo
{
BseSuper parent_object;
-
GList *waves;
};
struct _BseWaveRepoClass
{
BseSuperClass parent_class;
};
-
-
/* --- prototypes --- */
-
-
G_END_DECLS
-
#endif /* __BSE_WAVE_REPO_H__ */
diff --git a/bse/bsewaverepo.proc b/bse/bsewaverepo.proc
index 662cfda..b64346c 100644
--- a/bse/bsewaverepo.proc
+++ b/bse/bsewaverepo.proc
@@ -5,13 +5,10 @@
#include <bse/bseloader.hh>
#include <bse/bsewave.hh>
#include "bsecxxplugin.hh"
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
-
-
/* --- auxlillary functions --- */
static BseErrorType
load_file (BseWaveRepo *wrepo,
@@ -37,13 +34,9 @@ load_file (BseWaveRepo *wrepo,
g_object_unref (wave);
return error;
}
-
-
/* --- procedures --- */
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-
-
METHOD (BseWaveRepo, load-file) {
HELP = "Load wave from file";
IN = bse_param_spec_object ("wave_repo", "Wave Repo", NULL,
@@ -64,23 +57,18 @@ BODY (BseProcedureClass *proc,
BseUndoStack *ustack;
BseErrorType error;
BseWave *wave;
-
/* check parameters */
if (!BSE_IS_WAVE_REPO (self) || !file_name)
return BSE_ERROR_PROC_PARAM_INVAL;
-
ustack = bse_item_undo_open (self, "load-wave");
error = load_file (self, file_name, &wave);
if (wave)
bse_item_push_undo_proc (self, "remove-wave", wave);
bse_item_undo_close (ustack);
-
/* set output parameters */
g_value_set_enum (out_values++, error);
-
return BSE_ERROR_NONE;
}
-
METHOD (BseWaveRepo, remove-wave) {
HELP = "Remove a wave from repository";
IN = bse_param_spec_object ("wave_repo", "Wave Repo", NULL,
@@ -95,12 +83,10 @@ METHOD (BseWaveRepo, remove-wave) {
BseWaveRepo *self = (BseWaveRepo*) bse_value_get_object (in_values++);
BseItem *child = (BseItem*) bse_value_get_object (in_values++);
BseUndoStack *ustack;
-
/* check parameters */
if (!BSE_IS_WAVE_REPO (self) || !BSE_IS_WAVE (child) ||
child->parent != BSE_ITEM (self))
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* action */
ustack = bse_item_undo_open (self, "remove-wave %s", bse_object_debug_name (child));
/* remove object references */
@@ -111,10 +97,8 @@ METHOD (BseWaveRepo, remove-wave) {
bse_container_remove_backedup (BSE_CONTAINER (self), child, ustack);
/* done */
bse_item_undo_close (ustack);
-
return BSE_ERROR_NONE;
}
-
PROCEDURE (bse-sample-file-info, "Sample File Info") {
HELP = "Load sample file info from file";
IN = sfi_pspec_string ("file_name", "File Name", "The file to load info from",
@@ -129,11 +113,9 @@ BODY (BseProcedureClass *proc,
const char *filename = sfi_value_get_string (in_values++);
BseWaveFileInfo *wfi = NULL;
struct stat sbuf = { 0, };
-
/* check parameters */
if (!filename)
return BSE_ERROR_PROC_PARAM_INVAL;
-
/* construct info */
BseSampleFileInfo info = { 0, };
info.file = (char*) filename;
@@ -153,14 +135,11 @@ BODY (BseProcedureClass *proc,
info.loader = (gchar*) bse_wave_file_info_loader (wfi);
}
}
-
/* set output parameters */
bse_value_set_boxed (out_values++, &info);
-
/* cleanup */
bse_string_seq_free (info.waves);
if (wfi)
bse_wave_file_info_unref (wfi);
-
return BSE_ERROR_NONE;
}
diff --git a/bse/gslcommon.cc b/bse/gslcommon.cc
index 7ea2aa2..ed6b80f 100644
--- a/bse/gslcommon.cc
+++ b/bse/gslcommon.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gslcommon.hh"
-
#include "gsldatacache.hh"
#include <unistd.h>
#include <sys/utsname.h>
@@ -12,14 +11,10 @@
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/time.h>
-
-
/* --- variables --- */
volatile guint64 bse_engine_exvar_tick_stamp = 0; /* initialized to 1 upon gsl_init(), so 0==invalid */
static guint64 tick_stamp_system_time = 0;
static guint global_tick_stamp_leaps = 0;
-
-
/* --- tick stamps --- */
static BirnetMutex global_tick_stamp_mutex = { 0, };
/**
@@ -43,14 +38,11 @@ guint64
gsl_tick_stamp (void)
{
guint64 stamp;
-
GSL_SPIN_LOCK (&global_tick_stamp_mutex);
stamp = bse_engine_exvar_tick_stamp;
GSL_SPIN_UNLOCK (&global_tick_stamp_mutex);
-
return stamp;
}
-
void
_gsl_tick_stamp_set_leap (guint ticks)
{
@@ -58,7 +50,6 @@ _gsl_tick_stamp_set_leap (guint ticks)
global_tick_stamp_leaps = ticks;
GSL_SPIN_UNLOCK (&global_tick_stamp_mutex);
}
-
/**
* @return Current tick stamp and system time in micro seconds
*
@@ -69,34 +60,26 @@ GslTickStampUpdate
gsl_tick_stamp_last (void)
{
GslTickStampUpdate ustamp;
-
GSL_SPIN_LOCK (&global_tick_stamp_mutex);
ustamp.tick_stamp = bse_engine_exvar_tick_stamp;
ustamp.system_time = tick_stamp_system_time;
GSL_SPIN_UNLOCK (&global_tick_stamp_mutex);
-
return ustamp;
}
-
void
_gsl_tick_stamp_inc (void)
{
volatile guint64 newstamp;
guint64 systime;
-
g_return_if_fail (global_tick_stamp_leaps > 0);
-
systime = sfi_time_system ();
newstamp = bse_engine_exvar_tick_stamp + global_tick_stamp_leaps;
-
GSL_SPIN_LOCK (&global_tick_stamp_mutex);
bse_engine_exvar_tick_stamp = newstamp;
tick_stamp_system_time = systime;
GSL_SPIN_UNLOCK (&global_tick_stamp_mutex);
-
sfi_thread_emit_wakeups (newstamp);
}
-
/**
* @param tick_stamp tick stamp update to trigger wakeup
* Wakeup the currently running thread upon the last global tick stamp
@@ -109,33 +92,26 @@ void
gsl_thread_awake_before (guint64 tick_stamp)
{
g_return_if_fail (tick_stamp > 0);
-
if (tick_stamp > global_tick_stamp_leaps)
sfi_thread_awake_after (tick_stamp - global_tick_stamp_leaps);
else
sfi_thread_awake_after (tick_stamp);
}
-
-
/* --- misc --- */
const gchar*
gsl_byte_order_to_string (guint byte_order)
{
g_return_val_if_fail (byte_order == G_LITTLE_ENDIAN || byte_order == G_BIG_ENDIAN, NULL);
-
if (byte_order == G_LITTLE_ENDIAN)
return "little-endian";
if (byte_order == G_BIG_ENDIAN)
return "big-endian";
-
return NULL;
}
-
guint
gsl_byte_order_from_string (const gchar *string)
{
g_return_val_if_fail (string != NULL, 0);
-
while (*string == ' ')
string++;
if (strncasecmp (string, "little", 6) == 0)
@@ -144,7 +120,6 @@ gsl_byte_order_from_string (const gchar *string)
return G_BIG_ENDIAN;
return 0;
}
-
BseErrorType
gsl_file_check (const gchar *file_name,
const gchar *mode)
@@ -153,7 +128,6 @@ gsl_file_check (const gchar *file_name,
return BSE_ERROR_NONE;
return gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
}
-
BseErrorType
gsl_error_from_errno (gint sys_errno,
BseErrorType fallback)
@@ -192,7 +166,6 @@ gsl_error_from_errno (gint sys_errno,
default: return fallback;
}
}
-
static guint
score_error (BseErrorType error)
{
@@ -211,7 +184,6 @@ score_error (BseErrorType error)
return i;
return i;
}
-
BseErrorType
gsl_error_select (guint n_errors,
BseErrorType first_error,
@@ -246,8 +218,6 @@ gsl_error_select (guint n_errors,
g_free (errors);
return e;
}
-
-
/* --- progress notification --- */
GslProgressState
gsl_progress_state (gpointer data,
@@ -264,7 +234,6 @@ gsl_progress_state (gpointer data,
pstate.epsilon *= 0.5;
return pstate;
}
-
void
gsl_progress_notify (GslProgressState *pstate,
gfloat pval,
@@ -272,9 +241,7 @@ gsl_progress_notify (GslProgressState *pstate,
...)
{
gboolean need_update;
-
g_return_if_fail (pstate != NULL);
-
if (pval >= 0)
{
pval = CLAMP (pval, 0, 100);
@@ -285,7 +252,6 @@ gsl_progress_notify (GslProgressState *pstate,
pval = -1;
need_update = TRUE;
}
-
if (need_update && pstate->pfunc)
{
gchar *detail = NULL;
@@ -303,12 +269,10 @@ gsl_progress_notify (GslProgressState *pstate,
g_free (detail);
}
}
-
void
gsl_progress_wipe (GslProgressState *pstate)
{
g_return_if_fail (pstate != NULL);
-
if (pstate->wipe_length)
{
char *wstr = (char*) g_malloc (pstate->wipe_length + 1 + 1);
@@ -320,7 +284,6 @@ gsl_progress_wipe (GslProgressState *pstate)
pstate->wipe_length = 0;
}
}
-
guint
gsl_progress_printerr (gpointer message,
gfloat pval,
@@ -343,14 +306,12 @@ gsl_progress_printerr (gpointer message,
g_free (str);
return l;
}
-
/* --- global initialization --- */
void
gsl_init (void)
{
g_return_if_fail (bse_engine_exvar_tick_stamp == 0); /* assert single initialization */
bse_engine_exvar_tick_stamp = 1;
-
/* initialize subsystems */
sfi_mutex_init (&global_tick_stamp_mutex);
_gsl_init_fd_pool ();
diff --git a/bse/gslcommon.hh b/bse/gslcommon.hh
index 0a8b8ed..96c53c4 100644
--- a/bse/gslcommon.hh
+++ b/bse/gslcommon.hh
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_COMMON_H__
#define __GSL_COMMON_H__
-
#include <bse/gsldefs.hh>
#include <bse/bseenums.hh>
-
G_BEGIN_DECLS
-
-
/* --- initialization --- */
void gsl_init (void);
-
/* --- tick stamps --- */
typedef struct {
guint64 tick_stamp;
@@ -26,8 +21,6 @@ void gsl_thread_awake_before (guint64 tick_stamp);
#define GSL_SPIN_UNLOCK sfi_mutex_unlock
#define GSL_SYNC_LOCK sfi_mutex_lock
#define GSL_SYNC_UNLOCK sfi_mutex_unlock
-
-
/* --- misc --- */
const gchar* gsl_byte_order_to_string (guint byte_order);
guint gsl_byte_order_from_string (const gchar *string);
@@ -38,8 +31,6 @@ BseErrorType gsl_error_select (guint n_errors,
...);
BseErrorType gsl_file_check (const gchar *file_name,
const gchar *mode);
-
-
/* --- progress notification --- */
typedef struct _GslProgressState GslProgressState;
typedef guint (*GslProgressFunc) (gpointer data,
@@ -65,8 +56,6 @@ guint gsl_progress_printerr (gpointer message,
gfloat pval,
const gchar *detail,
GslProgressState *pstate);
-
-
/* --- implementation details --- */
void _gsl_tick_stamp_inc (void);
void _gsl_tick_stamp_set_leap (guint ticks);
@@ -81,8 +70,5 @@ void bse_init_loader_gus_patch (void);
#define GSL_N_IO_RETRIES (5)
#define _GSL_TICK_STAMP_VAL() (bse_engine_exvar_tick_stamp + 0)
extern volatile guint64 bse_engine_exvar_tick_stamp;
-
-
G_END_DECLS
-
#endif /* __GSL_COMMON_H__ */
diff --git a/bse/gsldatacache.cc b/bse/gsldatacache.cc
index 790cb1c..4493cae 100644
--- a/bse/gsldatacache.cc
+++ b/bse/gsldatacache.cc
@@ -9,15 +9,12 @@
#include <string.h>
#include <errno.h>
#include <time.h>
-
-
/* --- macros --- */
#define NODEP_INDEX(dcache, node_p) ((node_p) - (dcache)->nodes)
#define UPPER_POWER2(n) (sfi_alloc_upper_power2 (MAX (n, 4)))
#define CONFIG_NODE_SIZE() (BSE_CONFIG (dcache_block_size))
#define AGE_EPSILON (3) /* must be < resident set */
#define LOW_PERSISTENCY_RESIDENT_SET (5)
-
/* we use one global lock to protect the dcache list, the list
* count (length) and the number of aged (unused) nodes.
* also, each dcache has its own mutext to protect updates in
@@ -36,51 +33,40 @@
* is considered sufficient until shown otherwise by further
* profiling/debugging measures.
*/
-
-
/* --- prototypes --- */
static void dcache_free (GslDataCache *dcache);
static GslDataCacheNode* data_cache_new_node_L (GslDataCache *dcache,
int64 offset,
guint pos,
gboolean demand_load);
-
-
/* --- variables --- */
static BirnetMutex global_dcache_mutex = { 0, };
static BirnetCond global_dcache_cond_node_filled = { 0, };
static SfiRing *global_dcache_list = NULL;
static guint global_dcache_count = 0;
static guint global_dcache_n_aged_nodes = 0;
-
-
/* --- functions --- */
void
_gsl_init_data_caches (void)
{
static gboolean initialized = FALSE;
-
g_assert (initialized == FALSE);
initialized++;
-
BIRNET_STATIC_ASSERT (AGE_EPSILON < LOW_PERSISTENCY_RESIDENT_SET);
sfi_cond_init (&global_dcache_cond_node_filled);
sfi_mutex_init (&global_dcache_mutex);
}
-
GslDataCache*
gsl_data_cache_new (GslDataHandle *dhandle,
guint padding)
{
guint node_size = CONFIG_NODE_SIZE () / sizeof (GslDataType);
GslDataCache *dcache;
-
g_return_val_if_fail (dhandle != NULL, NULL);
g_return_val_if_fail (padding > 0, NULL);
g_return_val_if_fail (dhandle->name != NULL, NULL);
g_assert (node_size == sfi_alloc_upper_power2 (node_size));
g_return_val_if_fail (padding < node_size / 2, NULL);
-
/* allocate new closed dcache if necessary */
dcache = sfi_new_struct (GslDataCache, 1);
dcache->dhandle = gsl_data_handle_ref (dhandle);
@@ -93,26 +79,21 @@ gsl_data_cache_new (GslDataHandle *dhandle,
dcache->high_persistency = FALSE;
dcache->n_nodes = 0;
dcache->nodes = g_renew (GslDataCacheNode*, NULL, UPPER_POWER2 (dcache->n_nodes));
-
GSL_SPIN_LOCK (&global_dcache_mutex);
global_dcache_list = sfi_ring_append (global_dcache_list, dcache);
global_dcache_count++;
GSL_SPIN_UNLOCK (&global_dcache_mutex);
-
return dcache;
}
-
void
gsl_data_cache_open (GslDataCache *dcache)
{
g_return_if_fail (dcache != NULL);
g_return_if_fail (dcache->ref_count > 0);
-
GSL_SPIN_LOCK (&dcache->mutex);
if (!dcache->open_count)
{
BseErrorType error;
-
error = gsl_data_handle_open (dcache->dhandle);
if (error)
{
@@ -130,16 +111,13 @@ gsl_data_cache_open (GslDataCache *dcache)
dcache->open_count++;
GSL_SPIN_UNLOCK (&dcache->mutex);
}
-
void
gsl_data_cache_close (GslDataCache *dcache)
{
gboolean need_unref;
-
g_return_if_fail (dcache != NULL);
g_return_if_fail (dcache->ref_count > 0);
g_return_if_fail (dcache->open_count > 0);
-
GSL_SPIN_LOCK (&dcache->mutex);
dcache->open_count--;
need_unref = !dcache->open_count;
@@ -152,36 +130,29 @@ gsl_data_cache_close (GslDataCache *dcache)
if (need_unref)
gsl_data_cache_unref (dcache);
}
-
GslDataCache*
gsl_data_cache_ref (GslDataCache *dcache)
{
g_return_val_if_fail (dcache != NULL, NULL);
g_return_val_if_fail (dcache->ref_count > 0, NULL);
-
/* we might get invoked with global_dcache_mutex locked */
GSL_SPIN_LOCK (&dcache->mutex);
dcache->ref_count++;
GSL_SPIN_UNLOCK (&dcache->mutex);
-
return dcache;
}
-
static void
dcache_free (GslDataCache *dcache)
{
guint i;
-
g_return_if_fail (dcache->ref_count == 0);
g_return_if_fail (dcache->open_count == 0);
-
gsl_data_handle_unref (dcache->dhandle);
sfi_mutex_destroy (&dcache->mutex);
for (i = 0; i < dcache->n_nodes; i++)
{
GslDataCacheNode *node = dcache->nodes[i];
guint size;
-
size = dcache->node_size + (dcache->padding << 1);
sfi_delete_structs (GslDataType, size, node->data - dcache->padding);
sfi_delete_struct (GslDataCacheNode, node);
@@ -189,18 +160,15 @@ dcache_free (GslDataCache *dcache)
g_free (dcache->nodes);
sfi_delete_struct (GslDataCache, dcache);
}
-
void
gsl_data_cache_unref (GslDataCache *dcache)
{
g_return_if_fail (dcache != NULL);
restart:
g_return_if_fail (dcache->ref_count > 0);
-
if (dcache->ref_count == 1) /* possible destruction, need global lock */
{
g_return_if_fail (dcache->open_count == 0);
-
GSL_SPIN_LOCK (&global_dcache_mutex);
GSL_SPIN_LOCK (&dcache->mutex);
if (dcache->ref_count != 1)
@@ -231,7 +199,6 @@ gsl_data_cache_unref (GslDataCache *dcache)
GSL_SPIN_UNLOCK (&dcache->mutex);
}
}
-
static inline GslDataCacheNode**
data_cache_lookup_nextmost_node_L (GslDataCache *dcache,
int64 offset)
@@ -240,14 +207,12 @@ data_cache_lookup_nextmost_node_L (GslDataCache *dcache,
{
GslDataCacheNode **check, **nodes = dcache->nodes;
guint n_nodes = dcache->n_nodes, node_size = dcache->node_size;
-
/* caller has to figure himself whether we return nextmost vs. exact match */
nodes -= 1;
do
{
register gint cmp;
register guint i;
-
i = (n_nodes + 1) >> 1;
check = nodes + i;
cmp = offset < (*check)->offset ? -1 : offset >= (*check)->offset + node_size;
@@ -262,12 +227,10 @@ data_cache_lookup_nextmost_node_L (GslDataCache *dcache,
n_nodes = i - 1;
}
while (n_nodes);
-
return check; /* nextmost */
}
return NULL;
}
-
static inline GslDataCacheNode*
data_cache_new_node_L (GslDataCache *dcache,
int64 offset,
@@ -280,7 +243,6 @@ data_cache_new_node_L (GslDataCache *dcache,
int64 dhandle_length;
guint i, size;
gint result;
-
i = dcache->n_nodes++;
new_node_array_size = UPPER_POWER2 (dcache->n_nodes);
if (old_node_array_size != new_node_array_size)
@@ -294,7 +256,6 @@ data_cache_new_node_L (GslDataCache *dcache,
dnode->age = 0;
dnode->data = NULL;
GSL_SPIN_UNLOCK (&dcache->mutex);
-
size = dcache->node_size + (dcache->padding << 1);
data = sfi_new_struct (GslDataType, size);
node_data = data + dcache->padding;
@@ -302,7 +263,6 @@ data_cache_new_node_L (GslDataCache *dcache,
if (dcache->padding > offset) /* pad out bytes before data start */
{
guint short_pad = dcache->padding - offset;
-
memset (data, 0, short_pad * sizeof (GslDataType));
size -= short_pad;
data += short_pad;
@@ -312,7 +272,6 @@ data_cache_new_node_L (GslDataCache *dcache,
offset -= dcache->padding;
if (!demand_load)
g_message (G_STRLOC ":FIXME: lazy data loading not yet supported");
-
/* copy over data from previous node */
GslDataCacheNode *prev_node = pos ? dcache->nodes[pos - 1] : NULL;
if (prev_node)
@@ -320,12 +279,10 @@ data_cache_new_node_L (GslDataCache *dcache,
int64 prev_node_size = dcache->node_size;
int64 prev_node_offset = prev_node->offset;
GslDataType *prev_node_data = prev_node->data;
-
/* padding around prev_node */
prev_node_size += dcache->padding << 1;
prev_node_offset -= dcache->padding;
prev_node_data -= dcache->padding;
-
/* check for overlap */
if (offset < prev_node_offset + prev_node_size)
{
@@ -336,7 +293,6 @@ data_cache_new_node_L (GslDataCache *dcache,
data += overlap;
}
}
-
/* fill from data handle */
dhandle_length = gsl_data_handle_length (dcache->dhandle);
do
@@ -359,14 +315,11 @@ data_cache_new_node_L (GslDataCache *dcache,
}
while (size && result > 0);
memset (data, 0, size * sizeof (data[0]));
-
GSL_SPIN_LOCK (&dcache->mutex);
dnode->data = node_data;
sfi_cond_broadcast (&global_dcache_cond_node_filled);
-
return dnode;
}
-
GslDataCacheNode*
gsl_data_cache_ref_node (GslDataCache *dcache,
int64 offset,
@@ -374,12 +327,10 @@ gsl_data_cache_ref_node (GslDataCache *dcache,
{
GslDataCacheNode **node_p, *node;
guint insertion_pos;
-
g_return_val_if_fail (dcache != NULL, NULL);
g_return_val_if_fail (dcache->ref_count > 0, NULL);
g_return_val_if_fail (dcache->open_count > 0, NULL);
g_return_val_if_fail (offset < gsl_data_handle_length (dcache->dhandle), NULL);
-
GSL_SPIN_LOCK (&dcache->mutex);
node_p = data_cache_lookup_nextmost_node_L (dcache, offset);
if (node_p)
@@ -388,7 +339,6 @@ gsl_data_cache_ref_node (GslDataCache *dcache,
if (offset >= node->offset && offset < node->offset + dcache->node_size)
{
gboolean rejuvenate_node = !node->ref_count;
-
if (load_request == GSL_DATA_CACHE_PEEK)
{
if (node->data)
@@ -404,21 +354,18 @@ gsl_data_cache_ref_node (GslDataCache *dcache,
}
return node;
}
-
node->ref_count++;
if (load_request == GSL_DATA_CACHE_DEMAND_LOAD)
while (!node->data)
sfi_cond_wait (&global_dcache_cond_node_filled, &dcache->mutex);
GSL_SPIN_UNLOCK (&dcache->mutex);
/* g_printerr ("hit: %d :%d: %d\n", node->offset, offset, node->offset + dcache->node_size); */
-
if (rejuvenate_node)
{
GSL_SPIN_LOCK (&global_dcache_mutex); /* different lock */
global_dcache_n_aged_nodes--;
GSL_SPIN_UNLOCK (&global_dcache_mutex);
}
-
return node; /* exact match */
}
insertion_pos = NODEP_INDEX (dcache, node_p); /* insert before neighbour */
@@ -428,17 +375,13 @@ gsl_data_cache_ref_node (GslDataCache *dcache,
}
else
insertion_pos = 0; /* insert at start */
-
if (load_request != GSL_DATA_CACHE_PEEK)
node = data_cache_new_node_L (dcache, offset, insertion_pos, load_request == GSL_DATA_CACHE_DEMAND_LOAD);
else
node = NULL;
-
GSL_SPIN_UNLOCK (&dcache->mutex);
-
return node;
}
-
static gboolean /* still locked */
data_cache_free_olders_Lunlock (GslDataCache *dcache,
guint max_lru) /* how many lru nodes to keep */
@@ -446,16 +389,13 @@ data_cache_free_olders_Lunlock (GslDataCache *dcache,
GslDataCacheNode **slot_p;
guint i, rejuvenate, size;
guint n_freed = 0;
-
g_return_val_if_fail (dcache != NULL, TRUE);
-
/* it doesn't make sense to free nodes below the jitter that
* AGE_EPSILON attempts to prevent.
*/
max_lru = MAX (AGE_EPSILON, max_lru);
if (max_lru >= dcache->max_age)
return TRUE;
-
rejuvenate = dcache->max_age - max_lru;
if (0)
g_print ("start sweep: dcache (%p) with %u nodes, max_age: %u, rejuvenate: %u (max_lru: %u)\n",
@@ -465,7 +405,6 @@ data_cache_free_olders_Lunlock (GslDataCache *dcache,
for (i = 0; i < dcache->n_nodes; i++)
{
GslDataCacheNode *node = dcache->nodes[i];
-
if (!node->ref_count && node->age <= rejuvenate)
{
sfi_delete_structs (GslDataType, size, node->data - dcache->padding);
@@ -488,7 +427,6 @@ data_cache_free_olders_Lunlock (GslDataCache *dcache,
if (slot_p)
dcache->n_nodes = NODEP_INDEX (dcache, slot_p);
GSL_SPIN_UNLOCK (&dcache->mutex);
-
if (n_freed)
{
GSL_SPIN_LOCK (&global_dcache_mutex);
@@ -502,18 +440,15 @@ data_cache_free_olders_Lunlock (GslDataCache *dcache,
dcache->n_nodes);
return FALSE;
}
-
void
gsl_data_cache_unref_node (GslDataCache *dcache,
GslDataCacheNode *node)
{
GslDataCacheNode **node_p;
gboolean check_cache;
-
g_return_if_fail (dcache != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (node->ref_count > 0);
-
GSL_SPIN_LOCK (&dcache->mutex);
node_p = data_cache_lookup_nextmost_node_L (dcache, node->offset);
g_assert (node_p && *node_p == node); /* paranoid check lookup, yeah! */
@@ -524,13 +459,11 @@ gsl_data_cache_unref_node (GslDataCache *dcache,
dcache->max_age < AGE_EPSILON))
node->age = ++dcache->max_age;
GSL_SPIN_UNLOCK (&dcache->mutex);
-
if (check_cache)
{
guint node_size = CONFIG_NODE_SIZE ();
guint cache_mem = BSE_CONFIG (dcache_cache_memory);
guint current_mem;
-
GSL_SPIN_LOCK (&global_dcache_mutex);
global_dcache_n_aged_nodes++;
current_mem = node_size * global_dcache_n_aged_nodes;
@@ -586,32 +519,26 @@ gsl_data_cache_unref_node (GslDataCache *dcache,
GSL_SPIN_UNLOCK (&global_dcache_mutex);
}
}
-
void
gsl_data_cache_free_olders (GslDataCache *dcache,
guint max_age)
{
g_return_if_fail (dcache != NULL);
-
GSL_SPIN_LOCK (&dcache->mutex);
gboolean needs_unlock = data_cache_free_olders_Lunlock (dcache, max_age);
if (needs_unlock)
GSL_SPIN_UNLOCK (&dcache->mutex);
}
-
GslDataCache*
gsl_data_cache_from_dhandle (GslDataHandle *dhandle,
guint min_padding)
{
SfiRing *ring;
-
g_return_val_if_fail (dhandle != NULL, NULL);
-
GSL_SPIN_LOCK (&global_dcache_mutex);
for (ring = global_dcache_list; ring; ring = sfi_ring_walk (ring, global_dcache_list))
{
GslDataCache *dcache = (GslDataCache*) ring->data;
-
if (dcache->dhandle == dhandle && dcache->padding >= min_padding)
{
gsl_data_cache_ref (dcache);
@@ -620,6 +547,5 @@ gsl_data_cache_from_dhandle (GslDataHandle *dhandle,
}
}
GSL_SPIN_UNLOCK (&global_dcache_mutex);
-
return gsl_data_cache_new (dhandle, min_padding);
}
diff --git a/bse/gsldatacache.hh b/bse/gsldatacache.hh
index 8973a53..d54e4f6 100644
--- a/bse/gsldatacache.hh
+++ b/bse/gsldatacache.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DATA_CACHE_H__
#define __GSL_DATA_CACHE_H__
-
#include <bse/gslcommon.hh>
-
G_BEGIN_DECLS
-
/* --- macros --- */
#define GSL_DATA_CACHE_NODE_SIZE(dcache) (((GslDataCache*) (dcache))->node_size)
-
-
/* --- typedefs & structures --- */
typedef gfloat GslDataType;
typedef struct _GslDataCacheNode GslDataCacheNode;
@@ -39,8 +34,6 @@ typedef enum
GSL_DATA_CACHE_DEMAND_LOAD = TRUE, /* blocks until node->data != NULL */
GSL_DATA_CACHE_PEEK = 2 /* may return NULL node, data != NULL otherwise */
} GslDataCacheRequest;
-
-
/* --- prototypes --- */
GslDataCache* gsl_data_cache_new (GslDataHandle *dhandle,
guint padding);
@@ -57,7 +50,5 @@ void gsl_data_cache_free_olders (GslDataCache *dcache,
guint max_age);
GslDataCache* gsl_data_cache_from_dhandle (GslDataHandle *dhandle,
guint min_padding);
-
G_END_DECLS
-
#endif /* __GSL_DATA_CACHE_H__ */
diff --git a/bse/gsldatahandle-mad.cc b/bse/gsldatahandle-mad.cc
index 1315915..807fe31 100644
--- a/bse/gsldatahandle-mad.cc
+++ b/bse/gsldatahandle-mad.cc
@@ -13,29 +13,20 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
-
BIRNET_STATIC_ASSERT (BSE_HAVE_LIBMAD + 42); // assert BSE_HAVE_LIBMAD2 is defined
-
#if BSE_HAVE_LIBMAD
#include <mad.h>
-
-
/* --- debugging and errors --- */
static SFI_MSG_TYPE_DEFINE (debug_mad, "mad", SFI_MSG_DEBUG, NULL);
#define MAD_DEBUG(...) sfi_debug (debug_mad, __VA_ARGS__)
-
-
/* --- defines --- */
#define FILE_BUFFER_SIZE (1024 * 44) /* approximately 1 second at 320 kbit */
#define SEEK_BY_READ_AHEAD(h) (((h)->sample_rate / ((h)->frame_size * 2))) /* FIXME */
#define MAX_CHANNELS (5)
-
-
/* --- typedefs & structures --- */
typedef struct
{
GslDataHandle dhandle;
-
/* setup data */
gfloat osc_freq;
guint sample_rate;
@@ -43,37 +34,28 @@ typedef struct
guint stream_options;
guint accumulate_state_frames;
guint skip_seek_table : 1;
-
/* file IO */
guint eof : 1;
GslHFile *hfile;
guint file_pos;
BseErrorType error;
-
/* seek table */
GTime seek_mtime;
guint n_seeks;
guint *seeks;
-
/* file read buffer */
guint bfill;
guint8 buffer[FILE_BUFFER_SIZE + MAD_BUFFER_GUARD];
-
/* pcm housekeeping */
GslLong pcm_pos, pcm_length, next_pcm_pos;
-
/* libmad structures */
struct mad_stream stream;
struct mad_frame frame;
struct mad_synth synth;
} MadHandle;
-
-
/* --- prototypes --- */
static GslLong dh_mad_coarse_seek (GslDataHandle *dhandle,
GslLong voffset);
-
-
/* --- functions --- */
static BseErrorType
error_from_mad_stream (struct mad_stream *mstream,
@@ -106,24 +88,20 @@ error_from_mad_stream (struct mad_stream *mstream,
default: return fallback;
}
}
-
static gboolean /* FALSE: handle->eof || errno != 0 */
stream_read (MadHandle *handle)
{
struct mad_stream *stream = &handle->stream;
guint l;
-
/* no further data to read (flag must be reset upon seeks) */
if (handle->eof)
return FALSE;
-
/* keep remaining data in buffer */
if (stream->next_frame && handle->bfill)
{
handle->bfill = handle->buffer + handle->bfill - stream->next_frame;
memmove (handle->buffer, stream->next_frame, handle->bfill);
}
-
/* fill buffer */
l = gsl_hfile_pread (handle->hfile, handle->file_pos, FILE_BUFFER_SIZE - handle->bfill, handle->buffer + handle->bfill);
if (l > 0)
@@ -138,22 +116,17 @@ stream_read (MadHandle *handle)
handle->bfill += MAD_BUFFER_GUARD;
handle->file_pos += MAD_BUFFER_GUARD; /* bogus, but doesn't matter at eof */
}
-
mad_stream_buffer (stream, handle->buffer, handle->bfill);
-
return l < 0 ? FALSE : TRUE;
}
-
static gboolean
check_frame_validity (MadHandle *handle,
struct mad_header *header)
{
guint frame_size = MAD_NSBSAMPLES (header) * 32;
const char *reason = NULL;
-
if (frame_size <= 0)
reason = "frame_size < 1";
-
if (handle->frame_size && handle->dhandle.setup.n_channels)
{
#if 0
@@ -163,7 +136,6 @@ check_frame_validity (MadHandle *handle,
if (MAD_NCHANNELS (header) != handle->dhandle.setup.n_channels)
reason = "frame with non-standard channel count";
}
-
if (reason)
{
MAD_DEBUG ("skipping frame: %s", reason);
@@ -172,12 +144,10 @@ check_frame_validity (MadHandle *handle,
else
return TRUE;
}
-
static gboolean
read_next_frame_header (MadHandle *handle)
{
gboolean succeeded = TRUE;
-
/* fetch next frame header */
if (mad_header_decode (&handle->frame.header, &handle->stream) < 0)
{
@@ -192,24 +162,18 @@ read_next_frame_header (MadHandle *handle)
}
return read_next_frame_header (handle); /* retry */
}
-
if (!check_frame_validity (handle, &handle->frame.header))
return read_next_frame_header (handle); /* retry */
-
succeeded = FALSE;
}
-
handle->error = handle->stream.error ? error_from_mad_stream (&handle->stream, BSE_ERROR_FILE_SEEK_FAILED) : BSE_ERROR_NONE;
-
return succeeded;
}
-
static gboolean /* FALSE: handle->eof || handle->error != 0 */
pcm_frame_read (MadHandle *handle,
gboolean synth)
{
gboolean succeeded = TRUE;
-
if (mad_frame_decode (&handle->frame, &handle->stream) < 0)
{
if (!MAD_RECOVERABLE (handle->stream.error) ||
@@ -219,7 +183,6 @@ pcm_frame_read (MadHandle *handle,
* MAD_RECOVERABLE()==FALSE: frame was not read, need data
* note: MAD_RECOVERABLE (MAD_ERROR_LOSTSYNC) == TRUE
*/
-
/* read on */
if (!stream_read (handle))
{
@@ -228,32 +191,26 @@ pcm_frame_read (MadHandle *handle,
}
return pcm_frame_read (handle, synth); /* retry */
}
-
succeeded = FALSE;
if (synth)
mad_frame_mute (&handle->frame);
}
-
handle->pcm_pos = handle->next_pcm_pos;
handle->pcm_length = handle->frame_size;
handle->next_pcm_pos += handle->pcm_length;
-
if (synth)
mad_synth_frame (&handle->synth, &handle->frame);
-
if (!succeeded && handle->stream.error)
handle->error = error_from_mad_stream (&handle->stream, BSE_ERROR_FILE_READ_FAILED);
else
handle->error = BSE_ERROR_NONE;
return succeeded;
}
-
static guint*
create_seek_table (MadHandle *handle,
guint *n_seeks_p)
{
uint *seeks = NULL, n_seeks = 0;
-
*n_seeks_p = 0;
mad_synth_finish (&handle->synth);
mad_frame_finish (&handle->frame);
@@ -262,29 +219,24 @@ create_seek_table (MadHandle *handle,
mad_frame_init (&handle->frame);
mad_synth_init (&handle->synth);
mad_stream_options (&handle->stream, handle->stream_options);
-
/* lseek (handle->hfile, offs, SEEK_SET) */
handle->eof = FALSE;
handle->bfill = 0;
handle->file_pos = 0;
-
do
{
while (read_next_frame_header (handle))
{
guint this_pos = handle->file_pos - handle->bfill + handle->stream.this_frame - handle->buffer;
guint i = n_seeks++;
-
if (n_seeks > 256 * 1024) /* FIXME: max_frames */
{
g_free (seeks);
return NULL; /* FIXME: ETOOBIG */
}
-
if (sfi_alloc_upper_power2 (n_seeks) > sfi_alloc_upper_power2 (i))
seeks = g_renew (guint, seeks, sfi_alloc_upper_power2 (n_seeks));
seeks[i] = this_pos;
-
if (0)
{
if (mad_frame_decode (&handle->frame, &handle->stream) < 0)
@@ -303,7 +255,6 @@ create_seek_table (MadHandle *handle,
handle->synth.phase);
}
}
-
if (!handle->eof)
{
g_free (seeks);
@@ -315,20 +266,16 @@ create_seek_table (MadHandle *handle,
}
}
while (!handle->eof);
-
/* reset file offset */
/* lseek (handle->hfile, offs, SEEK_SET) */
handle->eof = FALSE;
handle->file_pos = 0;
handle->bfill = 0;
-
/* shrink table */
seeks = g_renew (guint, seeks, n_seeks);
*n_seeks_p = n_seeks;
-
return seeks;
}
-
static BseErrorType
dh_mad_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
@@ -338,12 +285,10 @@ dh_mad_open (GslDataHandle *dhandle,
GslLong n;
gboolean seek_invalidated = FALSE;
BseErrorType error;
-
hfile = gsl_hfile_open (handle->dhandle.name);
if (!hfile)
return gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
handle->hfile = hfile;
-
seek_invalidated |= handle->seek_mtime != hfile->mtime;
handle->bfill = 0;
handle->eof = FALSE;
@@ -355,14 +300,12 @@ dh_mad_open (GslDataHandle *dhandle,
mad_frame_init (&handle->frame);
mad_synth_init (&handle->synth);
mad_stream_options (&handle->stream, handle->stream_options);
-
/* fetch first frame */
if (!read_next_frame_header (handle))
{
error = BSE_ERROR_NO_HEADER;
goto OPEN_FAILED;
}
-
/* get n_channels, frame size and sample rate */
setup->n_channels = MAD_NCHANNELS (&handle->frame.header);
n = MAD_NSBSAMPLES (&handle->frame.header) * 32;
@@ -378,10 +321,8 @@ dh_mad_open (GslDataHandle *dhandle,
error = BSE_ERROR_FORMAT_INVALID;
goto OPEN_FAILED;
}
-
/* our code already uses dhandle->setup */
dhandle->setup = *setup;
-
/* seek through the stream to collect frame positions */
if (seek_invalidated || !handle->n_seeks)
{
@@ -407,7 +348,6 @@ dh_mad_open (GslDataHandle *dhandle,
MAD_DEBUG ("frames in seektable: %u", handle->n_seeks);
}
}
-
/* validate/setup handle length */
n = handle->n_seeks * handle->frame_size * setup->n_channels;
if (n > 0)
@@ -417,22 +357,18 @@ dh_mad_open (GslDataHandle *dhandle,
error = BSE_ERROR_NO_DATA;
goto OPEN_FAILED;
}
-
/* our code already uses dhandle->setup */
dhandle->setup = *setup;
-
if (dh_mad_coarse_seek (&handle->dhandle, 0) != 0)
{
error = BSE_ERROR_FILE_SEEK_FAILED;
goto OPEN_FAILED;
}
-
setup->bit_depth = 24;
setup->mix_freq = handle->sample_rate;
setup->needs_cache = TRUE;
setup->xinfos = bse_xinfos_add_float (setup->xinfos, "osc-freq", handle->osc_freq);
return BSE_ERROR_NONE;
-
OPEN_FAILED:
if (handle->error)
error = handle->error;
@@ -451,10 +387,8 @@ dh_mad_open (GslDataHandle *dhandle,
mad_stream_finish (&handle->stream);
gsl_hfile_close (handle->hfile);
handle->hfile = NULL;
-
return error;
}
-
static GslLong
dh_mad_read (GslDataHandle *dhandle,
GslLong voffset, /* in values */
@@ -464,20 +398,16 @@ dh_mad_read (GslDataHandle *dhandle,
MadHandle *handle = (MadHandle*) dhandle;
GslLong pos = voffset / dhandle->setup.n_channels;
gboolean frame_read_ok = TRUE;
-
if (pos < handle->pcm_pos ||
pos >= handle->pcm_pos + handle->pcm_length + SEEK_BY_READ_AHEAD (handle) * handle->frame_size)
{
GslLong tmp;
-
/* suckage, need to do lengthy seek in file */
tmp = dh_mad_coarse_seek (dhandle, voffset);
g_assert (tmp <= voffset);
}
-
while (pos >= handle->pcm_pos + handle->pcm_length)
frame_read_ok = pcm_frame_read (handle, TRUE);
-
/* check if the last call to pcm_frame_read() failed */
if (!frame_read_ok)
{
@@ -492,7 +422,6 @@ dh_mad_read (GslDataHandle *dhandle,
handle->accumulate_state_frames++;
MAD_DEBUG ("retrying seek with accumulate_state_frames=%d",
handle->accumulate_state_frames);
-
/* force dh_mad_read to retry the seek */
dh_mad_coarse_seek (dhandle, 0);
return dh_mad_read (dhandle, voffset, n_values, values);
@@ -510,9 +439,7 @@ dh_mad_read (GslDataHandle *dhandle,
return -1;
}
}
-
n_values = MIN (n_values, handle->pcm_length * dhandle->setup.n_channels);
-
/* interleave into output buffer */
if (pos >= handle->pcm_pos && pos < handle->pcm_pos + handle->pcm_length)
{
@@ -522,15 +449,12 @@ dh_mad_read (GslDataHandle *dhandle,
mad_fixed_t *pcm[MAX_CHANNELS];
gfloat *bound = values + n_samples;
guint i;
-
offset /= dhandle->setup.n_channels;
for (i = 0; i < dhandle->setup.n_channels; i++)
pcm[i] = handle->synth.pcm.samples[i] + offset + (i < align);
-
for (i = align; values < bound; values++)
{
mad_fixed_t mf = *(pcm[i]++);
-
*values = CLAMP (mf, -MAD_F_ONE, MAD_F_ONE) * (1. / (double) MAD_F_ONE);
if (++i >= dhandle->setup.n_channels)
i = 0;
@@ -544,23 +468,19 @@ dh_mad_read (GslDataHandle *dhandle,
return -1;
}
}
-
static GslLong
dh_mad_coarse_seek (GslDataHandle *dhandle,
GslLong voffset)
{
MadHandle *handle = (MadHandle*) dhandle;
GslLong opos = handle->pcm_pos, pos = voffset / dhandle->setup.n_channels;
-
if (voffset < 0) /* pcm_tell() */
return handle->pcm_pos * dhandle->setup.n_channels;
-
if (pos < handle->pcm_pos ||
pos >= handle->pcm_pos + handle->pcm_length + SEEK_BY_READ_AHEAD (handle))
{
GslLong offs = pos;
guint i, file_pos;
-
/* reset decoder state */
mad_synth_finish (&handle->synth);
mad_frame_finish (&handle->frame);
@@ -569,15 +489,12 @@ dh_mad_coarse_seek (GslDataHandle *dhandle,
mad_frame_init (&handle->frame);
mad_synth_init (&handle->synth);
mad_stream_options (&handle->stream, handle->stream_options);
-
/* seek to some frames read ahead to accumulate layer III IDCMT state */
offs -= (gint) (handle->frame_size * handle->accumulate_state_frames);
offs = CLAMP (offs, 0, (gint) (handle->n_seeks * handle->frame_size));
-
/* get file position from seek table */
i = offs / handle->frame_size;
file_pos = handle->seeks[i];
-
/* perform file seek and adjust positions */
/* lseek (handle->hfile, file_pos, SEEK_SET) */
handle->eof = FALSE;
@@ -586,12 +503,10 @@ dh_mad_coarse_seek (GslDataHandle *dhandle,
handle->pcm_pos = i * handle->frame_size;
handle->pcm_length = 0;
handle->next_pcm_pos = handle->pcm_pos;
-
#if 0
/* adapt synth phase */
handle->synth.phase = ((i + 1) * (handle->frame_size / 32)) % 16;
#endif
-
/* accumulate state */
if (pos >= handle->accumulate_state_frames * handle->frame_size)
{
@@ -599,28 +514,23 @@ dh_mad_coarse_seek (GslDataHandle *dhandle,
for (i = 0; i < handle->accumulate_state_frames; i++)
{
gboolean synth = i + 1 == handle->accumulate_state_frames;
-
if (!pcm_frame_read (handle, synth) && handle->stream.error != MAD_ERROR_BADDATAPTR)
MAD_DEBUG ("failed to read frame ahead (%u) in coarse-seek: failed: %s", i,
handle->stream.error ? mad_stream_errorstr (&handle->stream) : bse_error_blurb (handle->error));
}
}
-
MAD_DEBUG ("seek-done: at %llu (f:%llu) want %llu (f:%llu) got %llu (f:%llu) diff %lld (diff-requested %lld)",
opos, opos / handle->frame_size,
pos, pos / handle->frame_size,
handle->pcm_pos, handle->pcm_pos / handle->frame_size,
handle->pcm_pos - opos, pos - opos);
}
-
return handle->pcm_pos * dhandle->setup.n_channels;
}
-
static void
dh_mad_close (GslDataHandle *dhandle)
{
MadHandle *handle = (MadHandle*) dhandle;
-
g_strfreev (dhandle->setup.xinfos);
dhandle->setup.xinfos = NULL;
handle->bfill = 0;
@@ -635,19 +545,16 @@ dh_mad_close (GslDataHandle *dhandle)
gsl_hfile_close (handle->hfile);
handle->hfile = NULL;
}
-
static void
dh_mad_destroy (GslDataHandle *dhandle)
{
MadHandle *handle = (MadHandle*) dhandle;
-
g_free (handle->seeks);
handle->seeks = NULL;
handle->n_seeks = 0;
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (MadHandle, handle);
}
-
static GslDataHandleFuncs dh_mad_vtable = {
dh_mad_open,
dh_mad_read,
@@ -656,7 +563,6 @@ static GslDataHandleFuncs dh_mad_vtable = {
NULL,
dh_mad_destroy,
};
-
static GslDataHandle*
dh_mad_new (const gchar *file_name,
gfloat osc_freq,
@@ -665,7 +571,6 @@ dh_mad_new (const gchar *file_name,
{
MadHandle *handle;
gboolean success;
-
handle = sfi_new_struct0 (MadHandle, 1);
success = gsl_data_handle_common_init (&handle->dhandle, file_name);
if (success)
@@ -685,7 +590,6 @@ dh_mad_new (const gchar *file_name,
handle->seek_mtime = -1;
handle->bfill = 0;
handle->pcm_pos = handle->pcm_length = handle->next_pcm_pos = 0;
-
/* we can only check matters upon opening
*/
handle->skip_seek_table = skip_seek_keep_open != FALSE;
@@ -710,7 +614,6 @@ dh_mad_new (const gchar *file_name,
return NULL;
}
}
-
GslDataHandle*
gsl_data_handle_new_mad_err (const gchar *file_name,
gfloat osc_freq,
@@ -718,11 +621,9 @@ gsl_data_handle_new_mad_err (const gchar *file_name,
{
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (osc_freq > 0, NULL);
-
BseErrorType error = BSE_ERROR_NONE;
return dh_mad_new (file_name, osc_freq, FALSE, errorp ? errorp : &error);
}
-
BseErrorType
gsl_data_handle_mad_testopen (const gchar *file_name,
guint *n_channels,
@@ -730,14 +631,11 @@ gsl_data_handle_mad_testopen (const gchar *file_name,
{
GslDataHandle *dhandle;
MadHandle *handle;
-
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
-
BseErrorType error = BSE_ERROR_NONE;
dhandle = dh_mad_new (file_name, 439, TRUE, &error);
if (!dhandle)
return error ? error : BSE_ERROR_FILE_OPEN_FAILED;
-
handle = (MadHandle*) dhandle;
if (n_channels)
*n_channels = handle->dhandle.setup.n_channels;
@@ -745,18 +643,14 @@ gsl_data_handle_mad_testopen (const gchar *file_name,
*mix_freq = handle->sample_rate;
gsl_data_handle_close (dhandle);
gsl_data_handle_unref (dhandle);
-
return BSE_ERROR_NONE;
}
-
const gchar*
gsl_data_handle_mad_version (void)
{
return MAD_VERSION;
}
-
#else /* !BSE_HAVE_LIBMAD */
-
GslDataHandle*
gsl_data_handle_new_mad_err (const gchar *file_name,
gfloat osc_freq,
@@ -766,7 +660,6 @@ gsl_data_handle_new_mad_err (const gchar *file_name,
*errorp = BSE_ERROR_FORMAT_UNKNOWN;
return NULL;
}
-
BseErrorType
gsl_data_handle_mad_testopen (const gchar *file_name,
guint *n_channels,
@@ -774,20 +667,16 @@ gsl_data_handle_mad_testopen (const gchar *file_name,
{
return BSE_ERROR_FORMAT_UNKNOWN;
}
-
const gchar*
gsl_data_handle_mad_version (void)
{
return NULL;
}
-
#endif /* !BSE_HAVE_LIBMAD */
-
GslDataHandle*
gsl_data_handle_new_mad (const gchar *file_name,
gfloat osc_freq)
{
return gsl_data_handle_new_mad_err (file_name, osc_freq, NULL);
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/gsldatahandle-mad.hh b/bse/gsldatahandle-mad.hh
index 521b699..efdd550 100644
--- a/bse/gsldatahandle-mad.hh
+++ b/bse/gsldatahandle-mad.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DATA_HANDLE_MAD_H__
#define __GSL_DATA_HANDLE_MAD_H__
-
#include <bse/gslcommon.hh>
#include <bse/gsldatahandle.hh>
-
G_BEGIN_DECLS
-
/* linear-read handle. needs buffering handle wrapper
*/
GslDataHandle* gsl_data_handle_new_mad (const gchar *file_name,
@@ -18,7 +15,5 @@ BseErrorType gsl_data_handle_mad_testopen (const gchar *file_name,
guint *n_channels,
gfloat *mix_freq);
const gchar* gsl_data_handle_mad_version (void);
-
G_END_DECLS
-
#endif /* __GSL_DATA_HANDLE_MAD_H__ */
diff --git a/bse/gsldatahandle-vorbis.cc b/bse/gsldatahandle-vorbis.cc
index 3158f1b..d2308b2 100644
--- a/bse/gsldatahandle-vorbis.cc
+++ b/bse/gsldatahandle-vorbis.cc
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gsldatahandle-vorbis.hh"
-
#include "gslfilehash.hh"
#include <ogg/ogg.h>
#include <vorbis/vorbisfile.h>
#include <errno.h>
-
-
/* --- defines --- */
#define MAX_CHANNELS (16) /* hard limit, eases our life somewhat */
/* number of values to decode and throw away instead of seeking. since
@@ -14,12 +11,9 @@
* of seek-ahead space
*/
#define SEEK_BY_READ_AHEAD(vhandle) (vhandle->max_block_size * 8)
-
-
/* --- structure --- */
typedef struct {
GslDataHandle dhandle;
-
guint bitstream;
guint bitstream_serialno; /* set after open() */
gfloat osc_freq;
@@ -27,19 +21,14 @@ typedef struct {
guint rfile_byte_offset : 31;
guint rfile_add_zoffset : 1;
guint rfile_byte_length;
-
/* live data */
gint64 soffset; /* our PCM start offset */
guint max_block_size;
-
/* pcm read out cache */
GslLong pcm_pos, pcm_length;
gfloat *pcm[MAX_CHANNELS];
-
OggVorbis_File ofile;
} VorbisHandle;
-
-
/* --- functions --- */
static BseErrorType
ov_errno_to_error (gint ov_errno,
@@ -64,13 +53,11 @@ ov_errno_to_error (gint ov_errno,
default: return fallback;
}
}
-
typedef struct {
GslRFile *rfile;
GslLong byte_offset;
GslLong byte_length;
} VFile;
-
static size_t
vfile_read (void *ptr,
size_t size,
@@ -82,7 +69,6 @@ vfile_read (void *ptr,
size_t bytes_to_eof = vfile->byte_length - (gsl_rfile_position (vfile->rfile) - vfile->byte_offset);
return gsl_rfile_read (vfile->rfile, MIN (bytes, bytes_to_eof), ptr);
}
-
static int
vfile_seek (void *datasource,
ogg_int64_t offset,
@@ -111,7 +97,6 @@ vfile_seek (void *datasource,
}
return l < 0 ? -1 : l - vfile->byte_offset;
}
-
static int
vfile_close (void *datasource)
{
@@ -120,21 +105,18 @@ vfile_close (void *datasource)
g_free (vfile);
return 0;
}
-
static long
vfile_tell (void *datasource)
{
VFile *vfile = (VFile*) datasource;
return gsl_rfile_position (vfile->rfile) - vfile->byte_offset;
}
-
static ov_callbacks vfile_ov_callbacks = {
vfile_read,
vfile_seek,
vfile_close,
vfile_tell,
};
-
static BseErrorType
dh_vorbis_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
@@ -144,7 +126,6 @@ dh_vorbis_open (GslDataHandle *dhandle,
vorbis_info *vi;
GslLong n, i;
gint err;
-
vfile = g_new0 (VFile, 1);
vfile->rfile = gsl_rfile_open (vhandle->dhandle.name);
if (!vfile->rfile)
@@ -179,7 +160,6 @@ dh_vorbis_open (GslDataHandle *dhandle,
vfile_close (vfile);
return ov_errno_to_error (err, BSE_ERROR_FILE_OPEN_FAILED);
}
-
n = ov_streams (&vhandle->ofile);
if (n > vhandle->bitstream)
{
@@ -193,11 +173,9 @@ dh_vorbis_open (GslDataHandle *dhandle,
ov_clear (&vhandle->ofile); /* closes file */
return BSE_ERROR_NO_DATA; /* requested bitstream not available */
}
-
vhandle->soffset = 0;
for (i = 0; i < vhandle->bitstream; i++)
vhandle->soffset += ov_pcm_total (&vhandle->ofile, i);
-
n = ov_pcm_total (&vhandle->ofile, vhandle->bitstream);
vi = ov_info (&vhandle->ofile, vhandle->bitstream);
if (n > 0 && vi && vi->channels && ov_pcm_seek (&vhandle->ofile, vhandle->soffset) >= 0)
@@ -210,35 +188,29 @@ dh_vorbis_open (GslDataHandle *dhandle,
ov_clear (&vhandle->ofile); /* closes file */
return BSE_ERROR_NO_DATA;
}
-
vhandle->max_block_size = vorbis_info_blocksize (vi, 0);
n = vorbis_info_blocksize (vi, 1);
vhandle->max_block_size = MAX (vhandle->max_block_size, n);
vhandle->pcm_pos = 0;
vhandle->pcm_length = 0;
-
setup->bit_depth = 24;
setup->mix_freq = vi->rate;
setup->needs_cache = TRUE;
setup->xinfos = bse_xinfos_add_float (setup->xinfos, "osc-freq", vhandle->osc_freq);
return BSE_ERROR_NONE;
}
-
static GslLong
dh_vorbis_coarse_seek (GslDataHandle *dhandle,
GslLong voffset)
{
VorbisHandle *vhandle = (VorbisHandle*) dhandle;
GslLong opos = vhandle->pcm_pos, pos = voffset / dhandle->setup.n_channels;
-
if (voffset < 0)
return vhandle->pcm_pos * dhandle->setup.n_channels;
-
if (pos < vhandle->pcm_pos ||
pos >= vhandle->pcm_pos + vhandle->pcm_length + SEEK_BY_READ_AHEAD (vhandle))
{
gint err = ov_pcm_seek_page (&vhandle->ofile, vhandle->soffset + pos);
-
if (err) /* eek */
err = ov_pcm_seek_page (&vhandle->ofile, vhandle->soffset);
else
@@ -250,16 +222,13 @@ dh_vorbis_coarse_seek (GslDataHandle *dhandle,
if (0)
g_printerr ("OggS-SEEK: at %llu want %llu got %llu (diff-requested %lld)\n",
opos, pos, vhandle->pcm_pos, pos - opos);
-
return vhandle->pcm_pos * dhandle->setup.n_channels;
}
-
static void
read_packet (VorbisHandle *vhandle)
{
gfloat **pcm = NULL;
gint stream_id;
-
vhandle->pcm_pos = ov_pcm_tell (&vhandle->ofile) - vhandle->soffset;
vhandle->pcm_length = ov_read_float (&vhandle->ofile, &pcm, G_MAXINT, &stream_id);
if (vhandle->pcm_pos < 0 || vhandle->pcm_length < 0 || stream_id != int (vhandle->bitstream))
@@ -271,7 +240,6 @@ read_packet (VorbisHandle *vhandle)
for (uint i = 0; i < vhandle->dhandle.setup.n_channels; i++)
vhandle->pcm[i] = pcm[i];
}
-
static GslLong
dh_vorbis_read (GslDataHandle *dhandle,
GslLong voffset, /* in values */
@@ -280,22 +248,17 @@ dh_vorbis_read (GslDataHandle *dhandle,
{
VorbisHandle *vhandle = (VorbisHandle*) dhandle;
GslLong pos = voffset / dhandle->setup.n_channels;
-
if (pos < vhandle->pcm_pos ||
pos >= vhandle->pcm_pos + vhandle->pcm_length + SEEK_BY_READ_AHEAD (vhandle))
{
GslLong tmp;
-
/* suckage, needs to seek in file, this takes ages */
tmp = dh_vorbis_coarse_seek (dhandle, voffset);
g_assert (tmp <= voffset);
}
-
while (pos >= vhandle->pcm_pos + vhandle->pcm_length)
read_packet (vhandle);
-
n_values = MIN (n_values, vhandle->pcm_length * dhandle->setup.n_channels);
-
/* interleave into output buffer */
if (pos >= vhandle->pcm_pos && pos < vhandle->pcm_pos + vhandle->pcm_length)
{
@@ -304,15 +267,12 @@ dh_vorbis_read (GslDataHandle *dhandle,
guint n_samples = MIN (n_values, vhandle->pcm_length * dhandle->setup.n_channels - offset);
gfloat *pcm[MAX_CHANNELS], *bound = values + n_samples;
guint i;
-
offset /= dhandle->setup.n_channels;
for (i = 0; i < dhandle->setup.n_channels; i++)
pcm[i] = vhandle->pcm[i] + offset + (i < align);
-
for (i = align; values < bound; values++)
{
gfloat f = *(pcm[i]++);
-
f = CLAMP (f, -1.0, 1.0);
*values = f;
if (++i >= dhandle->setup.n_channels)
@@ -323,28 +283,23 @@ dh_vorbis_read (GslDataHandle *dhandle,
else /* something went wrong here, _badly_ */
return 0;
}
-
static void
dh_vorbis_close (GslDataHandle *dhandle)
{
VorbisHandle *vhandle = (VorbisHandle*) dhandle;
-
g_strfreev (dhandle->setup.xinfos);
dhandle->setup.xinfos = NULL;
ov_clear (&vhandle->ofile);
vhandle->pcm_pos = 0;
vhandle->pcm_length = 0;
}
-
static void
dh_vorbis_destroy (GslDataHandle *dhandle)
{
VorbisHandle *vhandle = (VorbisHandle*) dhandle;
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (VorbisHandle, vhandle);
}
-
static GslDataHandleFuncs dh_vorbis_vtable = {
dh_vorbis_open,
dh_vorbis_read,
@@ -353,7 +308,6 @@ static GslDataHandleFuncs dh_vorbis_vtable = {
NULL,
dh_vorbis_destroy,
};
-
static GslDataHandle*
gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
guint lbitstream,
@@ -373,7 +327,6 @@ gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
if (success)
{
BseErrorType error;
-
vhandle->dhandle.vtable = &dh_vorbis_vtable;
vhandle->n_bitstreams = 0;
vhandle->bitstream = lbitstream;
@@ -381,7 +334,6 @@ gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
vhandle->rfile_byte_offset = byte_offset;
vhandle->rfile_add_zoffset = add_zoffset != FALSE;
vhandle->rfile_byte_length = byte_size;
-
/* we can only check matters upon opening and need
* to initialize things like the bitstream_serialno.
*/
@@ -407,17 +359,14 @@ gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
return NULL;
}
}
-
GslDataHandle*
gsl_data_handle_new_ogg_vorbis_muxed (const gchar *file_name,
guint lbitstream,
gfloat osc_freq)
{
g_return_val_if_fail (file_name != NULL, NULL);
-
return gsl_data_handle_new_ogg_vorbis_any (file_name, lbitstream, osc_freq, FALSE, 0, 0, NULL, NULL);
}
-
GslDataHandle*
gsl_data_handle_new_ogg_vorbis_zoffset (const gchar *file_name,
gfloat osc_freq,
@@ -429,13 +378,10 @@ gsl_data_handle_new_ogg_vorbis_zoffset (const gchar *file_name,
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (byte_offset >= 0, NULL);
g_return_val_if_fail (byte_size > 0, NULL);
-
return gsl_data_handle_new_ogg_vorbis_any (file_name, 0, osc_freq, TRUE, byte_offset, byte_size, n_channelsp, mix_freq_p);
}
-
/* --- writing vorbis files --- */
#include "gslvorbis-cutter.hh"
-
struct GslVorbis1Handle
{
GslDataHandle *dhandle;
@@ -449,7 +395,6 @@ struct GslVorbis1Handle
guint forced_serialno;
GslVorbisCutter *vcutter;
};
-
GslVorbis1Handle*
gsl_vorbis1_handle_new (GslDataHandle *ogg_vorbis_handle,
guint serialno)
@@ -469,7 +414,6 @@ gsl_vorbis1_handle_new (GslDataHandle *ogg_vorbis_handle,
}
return v1h;
}
-
gint
gsl_vorbis1_handle_read (GslVorbis1Handle *v1h, /* returns -errno || length */
guint blength,
@@ -499,7 +443,6 @@ gsl_vorbis1_handle_read (GslVorbis1Handle *v1h, /* returns -errno || length */
gsl_vorbis_cutter_filter_serialno (v1h->vcutter, v1h->bitstream_serialno);
gsl_vorbis_cutter_force_serialno (v1h->vcutter, v1h->forced_serialno);
}
-
while (1) /* repeats until data is available */
{
guint j, n = gsl_vorbis_cutter_read_ogg (v1h->vcutter, blength, buffer);
@@ -515,7 +458,6 @@ gsl_vorbis1_handle_read (GslVorbis1Handle *v1h, /* returns -errno || length */
gsl_vorbis_cutter_write_ogg (v1h->vcutter, j, buffer);
}
}
-
void
gsl_vorbis1_handle_destroy (GslVorbis1Handle *v1h)
{
@@ -527,7 +469,6 @@ gsl_vorbis1_handle_destroy (GslVorbis1Handle *v1h)
v1h->dhandle = NULL;
g_free (v1h);
}
-
static gint /* -errno || length */
vorbis1_handle_reader (gpointer data,
void *buffer,
@@ -536,21 +477,18 @@ vorbis1_handle_reader (gpointer data,
GslVorbis1Handle *vhandle = (GslVorbis1Handle*) data;
return gsl_vorbis1_handle_read (vhandle, blength, (guint8*) buffer);
}
-
static void
vorbis1_handle_destroy (gpointer data)
{
GslVorbis1Handle *vhandle = (GslVorbis1Handle*) data;
gsl_vorbis1_handle_destroy (vhandle);
}
-
void
gsl_vorbis1_handle_put_wstore (GslVorbis1Handle *vorbis1,
SfiWStore *wstore)
{
sfi_wstore_put_binary (wstore, vorbis1_handle_reader, vorbis1, vorbis1_handle_destroy);
}
-
guint
gsl_vorbis_make_serialno (void)
{
diff --git a/bse/gsldatahandle-vorbis.hh b/bse/gsldatahandle-vorbis.hh
index 6d21c48..9d12ce4 100644
--- a/bse/gsldatahandle-vorbis.hh
+++ b/bse/gsldatahandle-vorbis.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DATA_HANDLE_VORBIS_H__
#define __GSL_DATA_HANDLE_VORBIS_H__
-
-
#include <bse/gslcommon.hh>
#include <bse/gsldatahandle.hh>
-
G_BEGIN_DECLS
-
/* --- reading vorbis files --- */
GslDataHandle* gsl_data_handle_new_ogg_vorbis_muxed (const gchar *file_name,
guint lbitstream,
@@ -18,7 +14,6 @@ GslDataHandle* gsl_data_handle_new_ogg_vorbis_zoffset (const gchar *file_na
GslLong byte_size,
guint *n_channelsp,
gfloat *mix_freq_p);
-
/* --- writing vorbis files --- */
typedef struct GslVorbis1Handle GslVorbis1Handle;
GslVorbis1Handle* gsl_vorbis1_handle_new (GslDataHandle *ogg_vorbis_handle,
@@ -33,7 +28,5 @@ void gsl_vorbis1_handle_destroy (GslVorbis1Handle *vorbis1
void gsl_vorbis1_handle_put_wstore (GslVorbis1Handle *vorbis1,
SfiWStore *wstore);
guint gsl_vorbis_make_serialno (void);
-
G_END_DECLS
-
#endif /* __GSL_DATA_HANDLE_VORBIS_H__ */
diff --git a/bse/gsldatahandle.cc b/bse/gsldatahandle.cc
index 7b7da8a..f3e4425 100644
--- a/bse/gsldatahandle.cc
+++ b/bse/gsldatahandle.cc
@@ -1,23 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gsldatahandle.hh"
-
#include "gslcommon.hh"
#include "gsldatacache.hh"
#include "gsldatautils.hh"
#include "gslfilehash.hh"
-
#include <string.h>
#include <errno.h>
-
-
/* --- typedefs --- */
typedef struct {
GslDataHandle dhandle;
GslDataHandle *src_handle; /* structure layout mirrored by various structs */
} ChainHandle;
typedef ChainHandle ReversedHandle;
-
-
/* --- standard functions --- */
gboolean
gsl_data_handle_common_init (GslDataHandle *dhandle,
@@ -27,49 +21,39 @@ gsl_data_handle_common_init (GslDataHandle *dhandle,
g_return_val_if_fail (dhandle->vtable == NULL, FALSE);
g_return_val_if_fail (dhandle->name == NULL, FALSE);
g_return_val_if_fail (dhandle->ref_count == 0, FALSE);
-
dhandle->name = g_strdup (file_name);
sfi_mutex_init (&dhandle->mutex);
dhandle->ref_count = 1;
dhandle->open_count = 0;
memset (&dhandle->setup, 0, sizeof (dhandle->setup));
-
return TRUE;
}
-
GslDataHandle*
gsl_data_handle_ref (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, NULL);
g_return_val_if_fail (dhandle->ref_count > 0, NULL);
-
GSL_SPIN_LOCK (&dhandle->mutex);
dhandle->ref_count++;
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return dhandle;
}
-
void
gsl_data_handle_common_free (GslDataHandle *dhandle)
{
g_return_if_fail (dhandle != NULL);
g_return_if_fail (dhandle->vtable != NULL);
g_return_if_fail (dhandle->ref_count == 0);
-
g_free (dhandle->name);
dhandle->name = NULL;
sfi_mutex_destroy (&dhandle->mutex);
}
-
void
gsl_data_handle_unref (GslDataHandle *dhandle)
{
gboolean destroy;
-
g_return_if_fail (dhandle != NULL);
g_return_if_fail (dhandle->ref_count > 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
dhandle->ref_count--;
destroy = dhandle->ref_count == 0;
@@ -80,18 +64,15 @@ gsl_data_handle_unref (GslDataHandle *dhandle)
dhandle->vtable->destroy (dhandle);
}
}
-
BseErrorType
gsl_data_handle_open (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (dhandle->ref_count > 0, BSE_ERROR_INTERNAL);
-
GSL_SPIN_LOCK (&dhandle->mutex);
if (dhandle->open_count == 0)
{
GslDataHandleSetup setup = { 0, };
-
BseErrorType error = dhandle->vtable->open (dhandle, &setup);
if (!error && (setup.n_values < 0 ||
setup.n_channels < 1))
@@ -115,19 +96,15 @@ gsl_data_handle_open (GslDataHandle *dhandle)
else
dhandle->open_count++;
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return BSE_ERROR_NONE;
}
-
void
gsl_data_handle_close (GslDataHandle *dhandle)
{
gboolean need_unref;
-
g_return_if_fail (dhandle != NULL);
g_return_if_fail (dhandle->ref_count > 0);
g_return_if_fail (dhandle->open_count > 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
dhandle->open_count--;
need_unref = !dhandle->open_count;
@@ -142,7 +119,6 @@ gsl_data_handle_close (GslDataHandle *dhandle)
if (need_unref)
gsl_data_handle_unref (dhandle);
}
-
int64
gsl_data_handle_read (GslDataHandle *dhandle,
int64 value_offset,
@@ -150,7 +126,6 @@ gsl_data_handle_read (GslDataHandle *dhandle,
gfloat *values)
{
int64 l;
-
g_return_val_if_fail (dhandle != NULL, -1);
g_return_val_if_fail (dhandle->open_count > 0, -1);
g_return_val_if_fail (value_offset >= 0, -1);
@@ -158,26 +133,21 @@ gsl_data_handle_read (GslDataHandle *dhandle,
return 0;
g_return_val_if_fail (values != NULL, -1);
g_return_val_if_fail (value_offset < dhandle->setup.n_values, -1);
-
n_values = MIN (n_values, dhandle->setup.n_values - value_offset);
GSL_SPIN_LOCK (&dhandle->mutex);
l = dhandle->vtable->read (dhandle, value_offset, n_values, values);
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return l;
}
-
GslDataHandle*
gsl_data_handle_get_source (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, NULL);
-
GSL_SPIN_LOCK (&dhandle->mutex);
GslDataHandle *src_handle = dhandle->vtable->get_source ? dhandle->vtable->get_source (dhandle) : NULL;
GSL_SPIN_UNLOCK (&dhandle->mutex);
return src_handle;
}
-
/**
* @param data_handle a DataHandle
* @return the state length of the data handle
@@ -206,122 +176,94 @@ gsl_data_handle_get_state_length (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, -1);
g_return_val_if_fail (dhandle->open_count > 0, -1);
-
GSL_SPIN_LOCK (&dhandle->mutex);
int64 state_length = dhandle->vtable->get_state_length ? dhandle->vtable->get_state_length (dhandle) : 0;
GSL_SPIN_UNLOCK (&dhandle->mutex);
return state_length;
}
-
int64
gsl_data_handle_length (GslDataHandle *dhandle)
{
int64 l;
-
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
l = dhandle->open_count ? dhandle->setup.n_values : 0;
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return l;
}
-
guint
gsl_data_handle_n_channels (GslDataHandle *dhandle)
{
guint n;
-
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
n = dhandle->open_count ? dhandle->setup.n_channels : 0;
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return n;
}
-
guint
gsl_data_handle_bit_depth (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
return dhandle->setup.bit_depth;
}
-
gfloat
gsl_data_handle_mix_freq (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
return dhandle->setup.mix_freq;
}
-
gfloat
gsl_data_handle_osc_freq (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
gfloat f = bse_xinfos_get_float (dhandle->setup.xinfos, "osc-freq");
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return f;
}
-
gfloat
gsl_data_handle_volume (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
gfloat f = bse_xinfos_get_float (dhandle->setup.xinfos, "volume");
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
/* no (or invalid) volume setting means that we replay without scaling */
if (f <= 0 || f > 1.0)
f = 1.0;
return f;
}
-
gfloat
gsl_data_handle_fine_tune (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (dhandle->open_count > 0, 0);
-
GSL_SPIN_LOCK (&dhandle->mutex);
gfloat f = bse_xinfos_get_float (dhandle->setup.xinfos, "fine-tune");
GSL_SPIN_UNLOCK (&dhandle->mutex);
-
return f;
}
-
const gchar*
gsl_data_handle_name (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, NULL);
-
return dhandle->name;
}
-
gboolean
gsl_data_handle_needs_cache (GslDataHandle *dhandle)
{
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (dhandle->ref_count > 0, FALSE);
g_return_val_if_fail (dhandle->open_count > 0, FALSE);
-
return dhandle->setup.needs_cache;
}
-
-
/* --- const memory handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -333,46 +275,38 @@ typedef struct {
gfloat mix_freq;
guint bit_depth : 8;
} MemHandle;
-
static BseErrorType
mem_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
MemHandle *mhandle = (MemHandle*) dhandle;
-
setup->n_values = mhandle->n_values;
setup->n_channels = mhandle->n_channels;
setup->xinfos = mhandle->xinfos;
setup->mix_freq = mhandle->mix_freq;
setup->bit_depth = mhandle->bit_depth;
-
return BSE_ERROR_NONE;
}
-
static void
mem_handle_close (GslDataHandle *dhandle)
{
// MemHandle *mhandle = (MemHandle*) dhandle;
dhandle->setup.xinfos = NULL;
}
-
static void
mem_handle_destroy (GslDataHandle *dhandle)
{
MemHandle *mhandle = (MemHandle*) dhandle;
void (*free_values) (gpointer) = mhandle->free_values;
const gfloat *mem_values = mhandle->values;
-
g_strfreev (mhandle->xinfos);
gsl_data_handle_common_free (dhandle);
mhandle->values = NULL;
mhandle->free_values = NULL;
sfi_delete_struct (MemHandle, mhandle);
-
if (free_values)
free_values ((gpointer) mem_values);
}
-
static int64
mem_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -380,14 +314,10 @@ mem_handle_read (GslDataHandle *dhandle,
gfloat *values)
{
MemHandle *mhandle = (MemHandle*) dhandle;
-
g_return_val_if_fail (voffset + n_values <= mhandle->n_values, -1);
-
memcpy (values, mhandle->values + voffset, n_values * sizeof (values[0]));
-
return n_values;
}
-
GslDataHandle*
gsl_data_handle_new_mem (guint n_channels,
guint bit_depth,
@@ -407,7 +337,6 @@ gsl_data_handle_new_mem (guint n_channels,
};
MemHandle *mhandle;
gboolean success;
-
g_return_val_if_fail (n_channels > 0, NULL);
g_return_val_if_fail (bit_depth > 0, NULL);
g_return_val_if_fail (mix_freq >= 4000, NULL);
@@ -415,7 +344,6 @@ gsl_data_handle_new_mem (guint n_channels,
g_return_val_if_fail (n_values >= n_channels, NULL);
if (n_values)
g_return_val_if_fail (values != NULL, NULL);
-
mhandle = sfi_new_struct0 (MemHandle, 1);
success = gsl_data_handle_common_init (&mhandle->dhandle, NULL);
if (success)
@@ -438,8 +366,6 @@ gsl_data_handle_new_mem (guint n_channels,
}
return &mhandle->dhandle;
}
-
-
/* --- xinfo handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -448,7 +374,6 @@ typedef struct {
SfiRing *added_xinfos; /* list of valid xinfos */
guint clear_xinfos : 1;
} XInfoHandle;
-
static SfiRing*
ring_remove_dups (SfiRing *ring,
SfiCompareFunc cmp,
@@ -465,7 +390,6 @@ ring_remove_dups (SfiRing *ring,
sfi_ring_free (rcopy);
return ring;
}
-
static BseErrorType
xinfo_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
@@ -508,7 +432,6 @@ xinfo_handle_open (GslDataHandle *dhandle,
}
return BSE_ERROR_NONE;
}
-
static int64
xinfo_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -518,7 +441,6 @@ xinfo_handle_read (GslDataHandle *dhandle,
XInfoHandle *chandle = (XInfoHandle*) dhandle;
return gsl_data_handle_read (chandle->src_handle, voffset, n_values, values);
}
-
static void
xinfo_handle_close (GslDataHandle *dhandle)
{
@@ -527,35 +449,28 @@ xinfo_handle_close (GslDataHandle *dhandle)
dhandle->setup.xinfos = NULL;
gsl_data_handle_close (chandle->src_handle);
}
-
static void
xinfo_handle_destroy (GslDataHandle *dhandle)
{
XInfoHandle *chandle = (XInfoHandle*) dhandle;
-
sfi_ring_free_deep (chandle->remove_xinfos, g_free);
sfi_ring_free_deep (chandle->added_xinfos, g_free);
gsl_data_handle_unref (chandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (XInfoHandle, chandle);
}
-
static GslDataHandle*
xinfo_get_source_handle (GslDataHandle *dhandle)
{
XInfoHandle *chandle = (XInfoHandle*) dhandle;
return chandle->src_handle;
}
-
static int64
xinfo_get_state_length (GslDataHandle *dhandle)
{
XInfoHandle *chandle = (XInfoHandle*) dhandle;
return gsl_data_handle_get_state_length (chandle->src_handle);
}
-
-
static GslDataHandle*
xinfo_data_handle_new (GslDataHandle *src_handle,
gboolean clear_xinfos,
@@ -676,7 +591,6 @@ xinfo_data_handle_new (GslDataHandle *src_handle,
}
return &chandle->dhandle;
}
-
GslDataHandle*
gsl_data_handle_new_add_xinfos (GslDataHandle *src_handle,
gchar **xinfos)
@@ -692,7 +606,6 @@ gsl_data_handle_new_add_xinfos (GslDataHandle *src_handle,
}
return xinfo_data_handle_new (src_handle, FALSE, NULL, added_xinfos);
}
-
GslDataHandle*
gsl_data_handle_new_remove_xinfos (GslDataHandle *src_handle,
gchar **xinfos)
@@ -710,14 +623,11 @@ gsl_data_handle_new_remove_xinfos (GslDataHandle *src_handle,
}
return xinfo_data_handle_new (src_handle, FALSE, remove_xinfos, NULL);
}
-
GslDataHandle*
gsl_data_handle_new_clear_xinfos (GslDataHandle *src_handle)
{
return xinfo_data_handle_new (src_handle, TRUE, NULL, NULL);
}
-
-
/* --- chain handle --- */
static BseErrorType
chain_handle_open (GslDataHandle *dhandle,
@@ -725,44 +635,34 @@ chain_handle_open (GslDataHandle *dhandle,
{
ChainHandle *chandle = (ChainHandle*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (chandle->src_handle);
if (error != BSE_ERROR_NONE)
return error;
*setup = chandle->src_handle->setup; /* copies setup.xinfos by pointer */
-
return BSE_ERROR_NONE;
}
-
static void
chain_handle_close (GslDataHandle *dhandle)
{
ChainHandle *chandle = (ChainHandle*) dhandle;
-
dhandle->setup.xinfos = NULL; /* cleanup pointer reference */
gsl_data_handle_close (chandle->src_handle);
}
-
static int64
chain_handle_get_state_length (GslDataHandle *dhandle)
{
ChainHandle *chandle = (ChainHandle*) dhandle;
return gsl_data_handle_get_state_length (chandle->src_handle);
}
-
-
/* --- reversed handle --- */
static void
reverse_handle_destroy (GslDataHandle *dhandle)
{
ReversedHandle *rhandle = (ReversedHandle*) dhandle;
-
gsl_data_handle_unref (rhandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (ReversedHandle, rhandle);
}
-
static int64
reverse_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -772,35 +672,28 @@ reverse_handle_read (GslDataHandle *dhandle,
ReversedHandle *rhandle = (ReversedHandle*) dhandle;
int64 left, new_offset = dhandle->setup.n_values - (voffset + n_values);
gfloat *t, *p = values;
-
g_assert (new_offset >= 0);
-
left = n_values;
do
{
int64 l = gsl_data_handle_read (rhandle->src_handle, new_offset, left, p);
-
if (l < 0)
return l; /* pass on errors */
-
new_offset += l;
left -= l;
p += l;
}
while (left > 0);
-
p = values;
t = values + n_values - 1;
while (p < t)
{
gfloat v = *t;
-
*t-- = *p;
*p++ = v;
}
return n_values;
}
-
GslDataHandle*
gsl_data_handle_new_reverse (GslDataHandle *src_handle)
{
@@ -814,9 +707,7 @@ gsl_data_handle_new_reverse (GslDataHandle *src_handle)
};
ReversedHandle *rhandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
-
rhandle = sfi_new_struct0 (ReversedHandle, 1);
success = gsl_data_handle_common_init (&rhandle->dhandle, NULL);
if (success)
@@ -832,26 +723,20 @@ gsl_data_handle_new_reverse (GslDataHandle *src_handle)
}
return &rhandle->dhandle;
}
-
-
/* --- scale handle --- */
typedef struct {
GslDataHandle dhandle;
GslDataHandle *src_handle; /* mirror ChainHandle */
double factor;
} ScaledHandle;
-
static void
scale_handle_destroy (GslDataHandle *dhandle)
{
ScaledHandle *shandle = (ScaledHandle*) dhandle;
-
gsl_data_handle_unref (shandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (ScaledHandle, shandle);
}
-
static int64
scale_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -864,7 +749,6 @@ scale_handle_read (GslDataHandle *dhandle,
values[i] *= shandle->factor;
return l;
}
-
GslDataHandle*
gsl_data_handle_new_scale (GslDataHandle *src_handle,
double factor)
@@ -879,9 +763,7 @@ gsl_data_handle_new_scale (GslDataHandle *src_handle,
};
ScaledHandle *shandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
-
shandle = sfi_new_struct0 (ScaledHandle, 1);
success = gsl_data_handle_common_init (&shandle->dhandle, NULL);
if (success)
@@ -898,7 +780,6 @@ gsl_data_handle_new_scale (GslDataHandle *src_handle,
}
return &shandle->dhandle;
}
-
/* --- cut handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -907,35 +788,28 @@ typedef struct {
int64 n_cut_values;
int64 tail_cut;
} CutHandle;
-
static BseErrorType
cut_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
CutHandle *chandle = (CutHandle*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (chandle->src_handle);
if (error != BSE_ERROR_NONE)
return error;
*setup = chandle->src_handle->setup; /* copies setup.xinfos by pointer */
setup->n_values -= MIN (setup->n_values, chandle->tail_cut);
setup->n_values -= MIN (setup->n_values, chandle->n_cut_values);
-
return BSE_ERROR_NONE;
}
-
static void
cut_handle_destroy (GslDataHandle *dhandle)
{
CutHandle *chandle = (CutHandle*) dhandle;
-
gsl_data_handle_unref (chandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (CutHandle, chandle);
}
-
static int64
cut_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -944,11 +818,9 @@ cut_handle_read (GslDataHandle *dhandle,
{
CutHandle *chandle = (CutHandle*) dhandle;
int64 orig_n_values = n_values;
-
if (voffset < chandle->cut_offset)
{
int64 l = MIN (chandle->cut_offset - voffset, n_values);
-
l = gsl_data_handle_read (chandle->src_handle, voffset, l, values);
if (l < 0)
return l; /* pass on errors */
@@ -956,22 +828,17 @@ cut_handle_read (GslDataHandle *dhandle,
values += l;
voffset += l;
}
-
if (voffset >= chandle->cut_offset && n_values)
{
int64 l = gsl_data_handle_read (chandle->src_handle, voffset + chandle->n_cut_values, n_values, values);
-
if (l < 0 && orig_n_values == n_values)
return l; /* pass on errors */
else if (l < 0)
l = 0;
-
n_values -= l;
}
-
return orig_n_values - n_values;
}
-
static GslDataHandle*
gsl_data_handle_new_translate (GslDataHandle *src_handle,
int64 cut_offset,
@@ -988,10 +855,8 @@ gsl_data_handle_new_translate (GslDataHandle *src_handle,
};
CutHandle *chandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
g_return_val_if_fail (cut_offset >= 0 && n_cut_values >= 0 && tail_cut >= 0, NULL);
-
chandle = sfi_new_struct0 (CutHandle, 1);
success = gsl_data_handle_common_init (&chandle->dhandle, NULL);
if (success)
@@ -1010,7 +875,6 @@ gsl_data_handle_new_translate (GslDataHandle *src_handle,
}
return &chandle->dhandle;
}
-
/**
* @param src_handle source GslDataHandle
* @param cut_offset offset of gap into @a src_handle
@@ -1027,7 +891,6 @@ gsl_data_handle_new_cut (GslDataHandle *src_handle,
{
return gsl_data_handle_new_translate (src_handle, cut_offset, n_cut_values, 0);
}
-
/**
* @param src_handle source GslDataHandle
* @param n_head_cut number of values to cut at data handle head
@@ -1045,8 +908,6 @@ gsl_data_handle_new_crop (GslDataHandle *src_handle,
{
return gsl_data_handle_new_translate (src_handle, 0, n_head_cut, n_tail_cut);
}
-
-
/* --- insert handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -1058,14 +919,12 @@ typedef struct {
const gfloat *paste_values;
void (*free_values) (gpointer);
} InsertHandle;
-
static BseErrorType
insert_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
InsertHandle *ihandle = (InsertHandle*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (ihandle->src_handle);
if (error != BSE_ERROR_NONE)
return error;
@@ -1077,37 +936,29 @@ insert_handle_open (GslDataHandle *dhandle,
setup->n_values += ihandle->n_paste_values;
guint n = gsl_data_handle_bit_depth (ihandle->src_handle);
setup->bit_depth = MAX (n, ihandle->paste_bit_depth);
-
return BSE_ERROR_NONE;
}
-
static void
insert_handle_close (GslDataHandle *dhandle)
{
InsertHandle *ihandle = (InsertHandle*) dhandle;
-
dhandle->setup.xinfos = NULL;
gsl_data_handle_close (ihandle->src_handle);
}
-
static void
insert_handle_destroy (GslDataHandle *dhandle)
{
InsertHandle *ihandle = (InsertHandle*) dhandle;
void (*free_values) (gpointer) = ihandle->free_values;
const gfloat *paste_values = ihandle->paste_values;
-
gsl_data_handle_unref (ihandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
ihandle->paste_values = NULL;
ihandle->free_values = NULL;
sfi_delete_struct (InsertHandle, ihandle);
-
if (free_values)
free_values ((gpointer) paste_values);
}
-
static int64
insert_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -1116,7 +967,6 @@ insert_handle_read (GslDataHandle *dhandle,
{
InsertHandle *ihandle = (InsertHandle*) dhandle;
int64 l, orig_n_values = n_values;
-
if (voffset < ihandle->src_handle->setup.n_values &&
voffset < ihandle->paste_offset)
{
@@ -1124,12 +974,10 @@ insert_handle_read (GslDataHandle *dhandle,
l = gsl_data_handle_read (ihandle->src_handle, voffset, l, values);
if (l < 0)
return l; /* pass on errors */
-
voffset += l;
n_values -= l;
values += l;
}
-
if (n_values && voffset >= ihandle->src_handle->setup.n_values && voffset < ihandle->paste_offset)
{
l = MIN (n_values, ihandle->paste_offset - voffset);
@@ -1138,7 +986,6 @@ insert_handle_read (GslDataHandle *dhandle,
n_values -= l;
values += l;
}
-
if (n_values && voffset >= ihandle->paste_offset && voffset < ihandle->paste_offset + ihandle->n_paste_values)
{
l = MIN (n_values, ihandle->paste_offset + ihandle->n_paste_values - voffset);
@@ -1147,7 +994,6 @@ insert_handle_read (GslDataHandle *dhandle,
n_values -= l;
values += l;
}
-
if (n_values && voffset >= ihandle->paste_offset + ihandle->n_paste_values)
{
l = gsl_data_handle_read (ihandle->src_handle, voffset - ihandle->n_paste_values, n_values, values);
@@ -1157,18 +1003,14 @@ insert_handle_read (GslDataHandle *dhandle,
l = 0;
n_values -= l;
}
-
return orig_n_values - n_values;
}
-
static int64
insert_handle_get_state_length (GslDataHandle *dhandle)
{
InsertHandle *ihandle = (InsertHandle*) dhandle;
return gsl_data_handle_get_state_length (ihandle->src_handle);
}
-
-
GslDataHandle*
gsl_data_handle_new_insert (GslDataHandle *src_handle,
guint paste_bit_depth,
@@ -1187,12 +1029,10 @@ gsl_data_handle_new_insert (GslDataHandle *src_handle,
};
InsertHandle *ihandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
g_return_val_if_fail (n_paste_values >= 0, NULL);
if (n_paste_values)
g_return_val_if_fail (paste_values != NULL, NULL);
-
ihandle = sfi_new_struct0 (InsertHandle, 1);
success = gsl_data_handle_common_init (&ihandle->dhandle, NULL);
if (success)
@@ -1214,8 +1054,6 @@ gsl_data_handle_new_insert (GslDataHandle *src_handle,
}
return &ihandle->dhandle;
}
-
-
/* --- loop handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -1225,18 +1063,15 @@ typedef struct {
int64 loop_start;
int64 loop_width;
} LoopHandle;
-
static BseErrorType
loop_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
LoopHandle *lhandle = (LoopHandle*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (lhandle->src_handle);
if (error != BSE_ERROR_NONE)
return error;
-
*setup = lhandle->src_handle->setup; /* copies setup.xinfos by pointer */
if (setup->n_values > lhandle->requested_last)
{
@@ -1249,21 +1084,16 @@ loop_handle_open (GslDataHandle *dhandle,
lhandle->loop_start = setup->n_values;
lhandle->loop_width = 0;
}
-
return BSE_ERROR_NONE;
}
-
static void
loop_handle_destroy (GslDataHandle *dhandle)
{
LoopHandle *lhandle = (LoopHandle*) dhandle;
-
gsl_data_handle_unref (lhandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (LoopHandle, lhandle);
}
-
static int64
loop_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -1271,7 +1101,6 @@ loop_handle_read (GslDataHandle *dhandle,
gfloat *values)
{
LoopHandle *lhandle = (LoopHandle*) dhandle;
-
if (voffset < lhandle->loop_start)
return gsl_data_handle_read (lhandle->src_handle, voffset,
MIN (lhandle->loop_start - voffset, n_values),
@@ -1279,16 +1108,13 @@ loop_handle_read (GslDataHandle *dhandle,
else
{
int64 noffset = voffset - lhandle->loop_start;
-
noffset %= lhandle->loop_width;
-
return gsl_data_handle_read (lhandle->src_handle,
lhandle->loop_start + noffset,
MIN (lhandle->loop_width - noffset, n_values),
values);
}
}
-
GslDataHandle*
gsl_data_handle_new_looped (GslDataHandle *src_handle,
int64 loop_first,
@@ -1304,11 +1130,9 @@ gsl_data_handle_new_looped (GslDataHandle *src_handle,
};
LoopHandle *lhandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
g_return_val_if_fail (loop_first >= 0, NULL);
g_return_val_if_fail (loop_last >= loop_first, NULL);
-
lhandle = sfi_new_struct0 (LoopHandle, 1);
success = gsl_data_handle_common_init (&lhandle->dhandle, NULL);
if (success)
@@ -1328,52 +1152,41 @@ gsl_data_handle_new_looped (GslDataHandle *src_handle,
}
return &lhandle->dhandle;
}
-
-
/* --- dcache handle --- */
typedef struct {
GslDataHandle dhandle;
GslDataCache *dcache;
guint node_size;
} DCacheHandle;
-
static void
dcache_handle_destroy (GslDataHandle *dhandle)
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
-
gsl_data_cache_unref (chandle->dcache);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (DCacheHandle, chandle);
}
-
static BseErrorType
dcache_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (chandle->dcache->dhandle);
if (error != BSE_ERROR_NONE)
return error;
gsl_data_cache_open (chandle->dcache);
*setup = chandle->dcache->dhandle->setup; /* copies setup.xinfos by pointer */
gsl_data_handle_close (chandle->dcache->dhandle);
-
return BSE_ERROR_NONE;
}
-
static void
dcache_handle_close (GslDataHandle *dhandle)
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
-
dhandle->setup.xinfos = NULL; /* cleanup pointer reference */
gsl_data_cache_close (chandle->dcache);
}
-
static int64
dcache_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -1382,29 +1195,24 @@ dcache_handle_read (GslDataHandle *dhandle,
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
GslDataCacheNode *node;
-
node = gsl_data_cache_ref_node (chandle->dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
voffset -= node->offset;
n_values = MIN (n_values, chandle->node_size - voffset);
memcpy (values, node->data + voffset, sizeof (values[0]) * n_values);
-
return n_values;
}
-
static GslDataHandle*
dcache_handle_get_source_handle (GslDataHandle *dhandle)
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
return chandle->dcache->dhandle;
}
-
static int64
dcache_handle_get_state_length (GslDataHandle *dhandle)
{
DCacheHandle *chandle = (DCacheHandle*) dhandle;
return gsl_data_handle_get_state_length (chandle->dcache->dhandle);
}
-
GslDataHandle*
gsl_data_handle_new_dcached (GslDataCache *dcache)
{
@@ -1418,9 +1226,7 @@ gsl_data_handle_new_dcached (GslDataCache *dcache)
};
DCacheHandle *dhandle;
gboolean success;
-
g_return_val_if_fail (dcache != NULL, NULL);
-
dhandle = sfi_new_struct0 (DCacheHandle, 1);
success = gsl_data_handle_common_init (&dhandle->dhandle, NULL);
if (success)
@@ -1437,8 +1243,6 @@ gsl_data_handle_new_dcached (GslDataCache *dcache)
}
return &dhandle->dhandle;
}
-
-
/* --- wave handle --- */
typedef struct {
GslDataHandle dhandle;
@@ -1453,7 +1257,6 @@ typedef struct {
gchar **xinfos;
gfloat mix_freq;
} WaveHandle;
-
static inline guint G_GNUC_CONST
wave_format_bit_depth (const GslWaveFormatType format)
{
@@ -1482,7 +1285,6 @@ wave_format_bit_depth (const GslWaveFormatType format)
return 0;
}
}
-
static inline guint G_GNUC_CONST
wave_format_byte_width (const GslWaveFormatType format)
{
@@ -1495,35 +1297,29 @@ wave_format_byte_width (const GslWaveFormatType format)
return (wave_format_bit_depth (format) + 7) / 8;
}
}
-
guint
gsl_wave_format_bit_depth (GslWaveFormatType format)
{
return wave_format_bit_depth (format);
}
-
guint
gsl_wave_format_byte_width (GslWaveFormatType format)
{
return wave_format_byte_width (format);
}
-
static void
wave_handle_destroy (GslDataHandle *dhandle)
{
WaveHandle *whandle = (WaveHandle*) dhandle;
-
g_strfreev (whandle->xinfos);
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (WaveHandle, whandle);
}
-
static BseErrorType
wave_handle_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
WaveHandle *whandle = (WaveHandle*) dhandle;
-
whandle->hfile = gsl_hfile_open (whandle->dhandle.name);
if (!whandle->hfile)
return gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
@@ -1561,17 +1357,14 @@ wave_handle_open (GslDataHandle *dhandle,
return BSE_ERROR_NONE;
}
}
-
static void
wave_handle_close (GslDataHandle *dhandle)
{
WaveHandle *whandle = (WaveHandle*) dhandle;
-
dhandle->setup.xinfos = NULL;
gsl_hfile_close (whandle->hfile);
whandle->hfile = NULL;
}
-
static int64
wave_handle_read (GslDataHandle *dhandle,
int64 voffset,
@@ -1581,10 +1374,8 @@ wave_handle_read (GslDataHandle *dhandle,
WaveHandle *whandle = (WaveHandle*) dhandle;
gpointer buffer = values;
int64 l, byte_offset;
-
byte_offset = voffset * wave_format_byte_width (whandle->format); /* float offset into bytes */
byte_offset += whandle->byte_offset;
-
switch (whandle->format)
{
guint8 *u8; gint8 *s8; guint16 *u16; guint32 *u32; gint32 *s32;
@@ -1651,10 +1442,8 @@ wave_handle_read (GslDataHandle *dhandle,
l = -1;
g_assert_not_reached ();
}
-
return l;
}
-
GslDataHandle*
gsl_wave_handle_new (const gchar *file_name,
guint n_channels,
@@ -1675,7 +1464,6 @@ gsl_wave_handle_new (const gchar *file_name,
wave_handle_destroy,
};
WaveHandle *whandle;
-
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (format > GSL_WAVE_FORMAT_NONE && format < GSL_WAVE_FORMAT_LAST, NULL);
g_return_val_if_fail (byte_order == G_LITTLE_ENDIAN || byte_order == G_BIG_ENDIAN, NULL);
@@ -1684,7 +1472,6 @@ gsl_wave_handle_new (const gchar *file_name,
g_return_val_if_fail (byte_offset >= 0, NULL);
g_return_val_if_fail (n_channels >= 1, NULL);
g_return_val_if_fail (n_values >= 1 || n_values == -1, NULL);
-
whandle = sfi_new_struct0 (WaveHandle, 1);
if (gsl_data_handle_common_init (&whandle->dhandle, file_name))
{
@@ -1706,7 +1493,6 @@ gsl_wave_handle_new (const gchar *file_name,
return NULL;
}
}
-
GslDataHandle*
gsl_wave_handle_new_zoffset (const gchar *file_name,
guint n_channels,
@@ -1725,7 +1511,6 @@ gsl_wave_handle_new_zoffset (const gchar *file_name,
((WaveHandle*) dhandle)->add_zoffset = TRUE;
return dhandle;
}
-
const gchar*
gsl_wave_format_to_string (GslWaveFormatType format)
{
@@ -1748,14 +1533,11 @@ gsl_wave_format_to_string (GslWaveFormatType format)
return NULL;
}
}
-
GslWaveFormatType
gsl_wave_format_from_string (const gchar *string)
{
gboolean is_unsigned = FALSE;
-
g_return_val_if_fail (string != NULL, GSL_WAVE_FORMAT_NONE);
-
while (*string == ' ')
string++;
if (strncasecmp (string, "alaw", 5) == 0)
diff --git a/bse/gsldatahandle.hh b/bse/gsldatahandle.hh
index 6e9034d..c113158 100644
--- a/bse/gsldatahandle.hh
+++ b/bse/gsldatahandle.hh
@@ -1,17 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DATA_HANDLE_H__
#define __GSL_DATA_HANDLE_H__
-
#include <bse/bseutils.hh>
-
G_BEGIN_DECLS
-
-
/* --- macros --- */
#define GSL_DATA_HANDLE_OPENED(handle) (((GslDataHandle*) (handle))->open_count > 0)
#define GSL_DATA_HANDLE_READ_LINEAR(handle) (((GslDataHandle*) (handle))->vtable->coarse_seek != NULL)
-
-
/* --- typedefs & structures --- */
typedef struct {
guint n_channels;
@@ -48,9 +42,6 @@ struct _GslDataHandleFuncs
int64 (*get_state_length) (GslDataHandle *data_handle);
void (*destroy) (GslDataHandle *data_handle);
};
-
-
-
/* --- standard functions --- */
GslDataHandle* gsl_data_handle_ref (GslDataHandle *dhandle);
void gsl_data_handle_unref (GslDataHandle *dhandle);
@@ -99,13 +90,11 @@ GslDataHandle* gsl_data_handle_new_dcached (GslDataCache *dcache);
GslDataHandle* gsl_data_handle_new_looped (GslDataHandle *src_handle,
int64 loop_first,
int64 loop_last);
-
/* --- factor 2 resampling datahandles --- */
GslDataHandle* bse_data_handle_new_upsample2 (GslDataHandle *src_handle, // implemented in bsedatahandle-resample.cc
int precision_bits);
GslDataHandle* bse_data_handle_new_downsample2 (GslDataHandle *src_handle,
int precision_bits); // implemented in bsedatahandle-resample.cc
-
GslDataHandle* bse_data_handle_new_fir_highpass (GslDataHandle *src_handle, // implemented in bsedatahandle-fir.cc
gdouble cutoff_freq,
guint order);
@@ -114,17 +103,12 @@ GslDataHandle* bse_data_handle_new_fir_lowpass (GslDataHandle *src_handle,
guint order);
gdouble bse_data_handle_fir_response_db (GslDataHandle *fir_handle, // implemented in bsedatahandle-fir.cc
gdouble freq);
-
-
-
/* --- xinfo handling --- */
GslDataHandle* gsl_data_handle_new_add_xinfos (GslDataHandle *src_handle,
gchar **xinfos);
GslDataHandle* gsl_data_handle_new_remove_xinfos (GslDataHandle *src_handle,
gchar **xinfos);
GslDataHandle* gsl_data_handle_new_clear_xinfos (GslDataHandle *src_handle);
-
-
/* --- wave specific functions --- */
typedef enum /*< skip >*/
{
@@ -144,7 +128,6 @@ typedef enum /*< skip >*/
GSL_WAVE_FORMAT_LAST
} GslWaveFormatType;
#define GSL_WAVE_FORMAT_IS_LAW(f) ((f) == GSL_WAVE_FORMAT_ALAW || (f) == GSL_WAVE_FORMAT_ULAW)
-
const gchar* gsl_wave_format_to_string (GslWaveFormatType format);
GslWaveFormatType gsl_wave_format_from_string (const gchar *string);
GslDataHandle* gsl_wave_handle_new (const gchar *file_name,
@@ -167,18 +150,11 @@ GslDataHandle* gsl_wave_handle_new_zoffset (const gchar *file_name,
gchar **xinfos);
guint gsl_wave_format_bit_depth (GslWaveFormatType format);
guint gsl_wave_format_byte_width (GslWaveFormatType format);
-
-
/* --- data handle optimization jobs --- */
gboolean gsl_data_handle_needs_cache (GslDataHandle *data_handle);
-
-
/* --- auxillary functions --- */
gboolean gsl_data_handle_common_init (GslDataHandle *dhandle,
const gchar *file_name);
void gsl_data_handle_common_free (GslDataHandle *dhandle);
-
-
G_END_DECLS
-
#endif /* __GSL_DATA_HANDLE_H__ */
diff --git a/bse/gsldatautils.cc b/bse/gsldatautils.cc
index 2b646a6..e59d532 100644
--- a/bse/gsldatautils.cc
+++ b/bse/gsldatautils.cc
@@ -7,11 +7,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-
-
#define BSIZE GSL_DATA_HANDLE_PEEK_BUFFER /* FIXME: global buffer size setting */
-
-
/* --- functions --- */
gfloat
gsl_data_peek_value_f (GslDataHandle *dhandle,
@@ -22,16 +18,13 @@ gsl_data_peek_value_f (GslDataHandle *dhandle,
{
GslLong dhandle_length = dhandle->setup.n_values;
GslLong inc, k, bsize = MIN (GSL_DATA_HANDLE_PEEK_BUFFER, dhandle_length);
-
g_return_val_if_fail (pos >= 0 && pos < dhandle_length, 0);
-
peekbuf->start = peekbuf->dir > 0 ? pos : peekbuf->dir < 0 ? pos - bsize + 1: pos - bsize / 2;
peekbuf->end = MIN (peekbuf->start + bsize, dhandle_length);
peekbuf->start = MAX (peekbuf->start, 0);
for (k = peekbuf->start; k < peekbuf->end; k += inc)
{
guint n_retries = 5; /* FIXME: need global retry strategy */
-
do
inc = gsl_data_handle_read (dhandle, k, peekbuf->end - k, peekbuf->data + k - peekbuf->start);
while (inc < 1 && n_retries-- && GSL_DATA_HANDLE_OPENED (dhandle));
@@ -45,7 +38,6 @@ gsl_data_peek_value_f (GslDataHandle *dhandle,
}
return peekbuf->data[pos - peekbuf->start];
}
-
gint /* errno */
gsl_data_handle_dump (GslDataHandle *dhandle,
gint fd,
@@ -53,32 +45,26 @@ gsl_data_handle_dump (GslDataHandle *dhandle,
guint byte_order)
{
GslLong l, offs = 0;
-
g_return_val_if_fail (dhandle != NULL, EINVAL);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (dhandle), EINVAL);
g_return_val_if_fail (fd >= 0, EINVAL);
g_return_val_if_fail (format > GSL_WAVE_FORMAT_NONE && format < GSL_WAVE_FORMAT_LAST, EINVAL);
g_return_val_if_fail (!GSL_WAVE_FORMAT_IS_LAW (format), EINVAL);
g_return_val_if_fail (byte_order == G_LITTLE_ENDIAN || byte_order == G_BIG_ENDIAN, EINVAL);
-
l = dhandle->setup.n_values;
while (l)
{
GslLong retry, j, n = MIN (l, GSL_DATA_HANDLE_PEEK_BUFFER);
gfloat src[GSL_DATA_HANDLE_PEEK_BUFFER];
-
retry = GSL_N_IO_RETRIES;
do
n = gsl_data_handle_read (dhandle, offs, n, src);
while (n < 1 && retry--);
if (retry < 0)
return EIO;
-
l -= n;
offs += n;
-
n = gsl_conv_from_float_clip (format, byte_order, src, src, n);
-
do
j = write (fd, src, n);
while (j < 0 && errno == EINTR);
@@ -87,7 +73,6 @@ gsl_data_handle_dump (GslDataHandle *dhandle,
}
return 0;
}
-
static void
write_bytes (gint fd,
guint n_bytes,
@@ -95,15 +80,12 @@ write_bytes (gint fd,
{
gint errold = errno;
guint j;
-
do
j = write (fd, bytes, n_bytes);
while (j < 0 && errno == EINTR);
-
if (!errno)
errno = errold;
}
-
static void
write_uint32_le (gint fd,
guint32 val)
@@ -111,7 +93,6 @@ write_uint32_le (gint fd,
val = GUINT32_TO_LE (val);
write_bytes (fd, 4, &val);
}
-
static void
write_uint16_le (gint fd,
guint16 val)
@@ -119,7 +100,6 @@ write_uint16_le (gint fd,
val = GUINT16_TO_LE (val);
write_bytes (fd, 2, &val);
}
-
gint /* errno */
bse_wave_file_dump_header (gint fd,
guint n_data_bytes,
@@ -128,19 +108,16 @@ bse_wave_file_dump_header (gint fd,
guint sample_freq)
{
guint byte_per_sample, byte_per_second, file_length;
-
g_return_val_if_fail (fd >= 0, EINVAL);
g_return_val_if_fail (n_data_bytes < 4294967296LLU - 44, EINVAL);
g_return_val_if_fail (n_bits == 16 || n_bits == 8, EINVAL);
g_return_val_if_fail (n_channels >= 1, EINVAL);
-
file_length = 0; /* 4 + 4; */ /* 'RIFF' header is left out*/
file_length += 4 + 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2; /* 'fmt ' header */
file_length += 4 + 4; /* 'data' header */
file_length += n_data_bytes;
byte_per_sample = (n_bits == 16 ? 2 : 1) * n_channels;
byte_per_second = byte_per_sample * sample_freq;
-
errno = 0;
write_bytes (fd, 4, "RIFF"); /* main_chunk */
write_uint32_le (fd, file_length);
@@ -155,27 +132,21 @@ bse_wave_file_dump_header (gint fd,
write_uint16_le (fd, n_bits);
write_bytes (fd, 4, "data"); /* data chunk */
write_uint32_le (fd, n_data_bytes);
-
return errno;
}
-
gint /* errno */
bse_wave_file_patch_length (gint fd,
guint n_data_bytes)
{
guint file_length;
glong l;
-
g_return_val_if_fail (fd >= 0, EINVAL);
g_return_val_if_fail (n_data_bytes < 4294967296LLU - 44, EINVAL);
-
file_length = 0; /* 4 + 4; */ /* 'RIFF' header is left out*/
file_length += 4 + 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2; /* 'fmt ' header */
file_length += 4 + 4; /* 'data' header */
file_length += n_data_bytes;
-
errno = 0;
-
do
l = lseek (fd, 4, SEEK_SET);
while (l < 0 && errno == EINTR);
@@ -184,7 +155,6 @@ bse_wave_file_patch_length (gint fd,
write_uint32_le (fd, file_length);
if (errno)
return errno;
-
do
l = lseek (fd, 40, SEEK_SET);
while (l < 0 && errno == EINTR);
@@ -193,10 +163,8 @@ bse_wave_file_patch_length (gint fd,
write_uint32_le (fd, n_data_bytes);
if (errno)
return errno;
-
return errno;
}
-
gint /* errno */
bse_wave_file_dump_data (gint fd,
guint n_bits,
@@ -219,7 +187,6 @@ bse_wave_file_dump_data (gint fd,
else
return 0;
}
-
static gint /* errno */
bse_wave_file_from_bbuffer (const char *file_name,
guint n_bits,
@@ -247,7 +214,6 @@ bse_wave_file_from_bbuffer (const char *file_name,
return errno ? errno : EIO;
return 0;
}
-
gint /* errno */
bse_wave_file_from_fbuffer (const char *file_name,
guint n_bits,
@@ -264,7 +230,6 @@ bse_wave_file_from_fbuffer (const char *file_name,
g_free (buffer);
return retval;
}
-
gint /* errno */
bse_wave_file_from_dbuffer (const char *file_name,
guint n_bits,
@@ -281,7 +246,6 @@ bse_wave_file_from_dbuffer (const char *file_name,
g_free (buffer);
return retval;
}
-
gint /* errno */
gsl_data_handle_dump_wav (GslDataHandle *dhandle,
gint fd,
@@ -290,25 +254,20 @@ gsl_data_handle_dump_wav (GslDataHandle *dhandle,
guint sample_freq)
{
guint data_length;
-
g_return_val_if_fail (dhandle != NULL, EINVAL);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (dhandle), EINVAL);
g_return_val_if_fail (fd >= 0, EINVAL);
g_return_val_if_fail (n_bits == 16 || n_bits == 8, EINVAL);
g_return_val_if_fail (n_channels >= 1, EINVAL);
-
data_length = dhandle->setup.n_values * (n_bits == 16 ? 2 : 1);
-
errno = 0;
errno = bse_wave_file_dump_header (fd, data_length, n_bits, n_channels, sample_freq);
if (errno)
return errno;
-
return gsl_data_handle_dump (dhandle, fd,
n_bits > 8 ? GSL_WAVE_FORMAT_SIGNED_16 : GSL_WAVE_FORMAT_UNSIGNED_8,
G_LITTLE_ENDIAN);
}
-
typedef struct {
GslDataHandle *dhandle;
gboolean opened;
@@ -316,7 +275,6 @@ typedef struct {
guint byte_order;
guint length;
} WStoreContext;
-
static void
wstore_context_destroy (gpointer data)
{
@@ -326,7 +284,6 @@ wstore_context_destroy (gpointer data)
gsl_data_handle_unref (wc->dhandle);
g_free (wc);
}
-
static gint /* -errno || length */
wstore_context_reader (gpointer data,
void *buffer,
@@ -334,7 +291,6 @@ wstore_context_reader (gpointer data,
{
WStoreContext *wc = (WStoreContext*) data;
GslLong l;
-
if (!wc->opened)
{
BseErrorType error = gsl_data_handle_open (wc->dhandle);
@@ -342,11 +298,9 @@ wstore_context_reader (gpointer data,
return -ENOENT; /* approximation of OPEN_FAILED */
wc->opened = TRUE;
}
-
blength /= 4; /* we use buffer for floats */
if (wc->length >= gsl_data_handle_length (wc->dhandle))
return 0; /* done */
-
l = gsl_data_handle_read (wc->dhandle, wc->length, blength, (float*) buffer);
if (l < 1)
{
@@ -356,10 +310,8 @@ wstore_context_reader (gpointer data,
return -EIO; /* bail out */
}
wc->length += l;
-
return gsl_conv_from_float_clip (wc->format, wc->byte_order, (const float*) buffer, buffer, l);
}
-
void
gsl_data_handle_dump_wstore (GslDataHandle *dhandle,
SfiWStore *wstore,
@@ -367,10 +319,8 @@ gsl_data_handle_dump_wstore (GslDataHandle *dhandle,
guint byte_order)
{
WStoreContext *wc;
-
g_return_if_fail (dhandle != NULL);
g_return_if_fail (wstore);
-
wc = g_new0 (WStoreContext, 1);
wc->dhandle = gsl_data_handle_ref (dhandle);
wc->opened = FALSE;
@@ -378,7 +328,6 @@ gsl_data_handle_dump_wstore (GslDataHandle *dhandle,
wc->byte_order = byte_order;
sfi_wstore_put_binary (wstore, wstore_context_reader, wc, wstore_context_destroy);
}
-
gboolean
gsl_data_detect_signal (GslDataHandle *handle,
GslLong *sigstart_p,
@@ -388,14 +337,11 @@ gsl_data_detect_signal (GslDataHandle *handle,
gfloat signal_threshold = 16. * 16. * 16.; /* noise level threshold */
GslLong k, xcheck = -1, minsamp = -1, maxsamp = -2;
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
-
g_return_val_if_fail (handle != NULL, FALSE);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (handle), FALSE);
g_return_val_if_fail (sigstart_p || sigend_p, FALSE);
-
/* keep open */
gsl_data_handle_open (handle);
-
/* find fadein/fadeout point */
k = 0;
level_4 = gsl_data_handle_peek_value (handle, k, &peek_buffer);
@@ -404,7 +350,6 @@ gsl_data_detect_signal (GslDataHandle *handle,
for (; k < handle->setup.n_values; k++)
{
gfloat mean, needx, current;
-
current = gsl_data_handle_peek_value (handle, k, &peek_buffer) * 32768.;
if (xcheck < 0 && ABS (current) >= 16)
xcheck = k;
@@ -428,18 +373,14 @@ gsl_data_detect_signal (GslDataHandle *handle,
if (xcheck - minsamp > 0)
g_printerr("###################");
g_printerr ("active area %lld .. %lld, signal>16 at: %lld\t diff: %lld\n",minsamp,maxsamp,xcheck, xcheck-minsamp);
-
/* release open reference */
gsl_data_handle_close (handle);
-
if (sigstart_p)
*sigstart_p = minsamp;
if (sigend_p)
*sigend_p = MAX (-1, maxsamp);
-
return maxsamp >= minsamp;
}
-
double
gsl_data_find_min_max (GslDataHandle *handle,
double *dmin,
@@ -447,10 +388,8 @@ gsl_data_find_min_max (GslDataHandle *handle,
{
g_return_val_if_fail (handle != NULL, 0);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (handle), 0);
-
/* keep open */
gsl_data_handle_open (handle);
-
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
double vmin = +DBL_MAX, vmax = -DBL_MAX;
uint i;
@@ -466,7 +405,6 @@ gsl_data_find_min_max (GslDataHandle *handle,
*dmax = vmax;
return MAX (fabs (vmin), fabs (vmax));
}
-
GslLong
gsl_data_find_sample (GslDataHandle *dhandle,
gfloat min_value,
@@ -476,23 +414,18 @@ gsl_data_find_sample (GslDataHandle *dhandle,
{
GslDataPeekBuffer peekbuf = { 0, 0, 0, };
GslLong i;
-
g_return_val_if_fail (dhandle != NULL, -1);
g_return_val_if_fail (direction == -1 || direction == +1, -1);
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE ||
start_offset >= dhandle->setup.n_values)
return -1;
-
if (start_offset < 0)
start_offset = dhandle->setup.n_values - 1;
-
peekbuf.dir = direction;
if (min_value <= max_value)
for (i = start_offset; i < dhandle->setup.n_values && i >= 0; i += direction)
{
gfloat val = gsl_data_handle_peek_value (dhandle, i, &peekbuf);
-
/* g_print ("(%lu): %f <= %f <= %f\n", i, min_value, val, max_value); */
if (val >= min_value && val <= max_value)
break;
@@ -501,17 +434,13 @@ gsl_data_find_sample (GslDataHandle *dhandle,
for (i = start_offset; i < dhandle->setup.n_values && i >= 0; i += direction)
{
gfloat val = gsl_data_handle_peek_value (dhandle, i, &peekbuf);
-
/* g_print ("(%lu): %f > %f || %f < %f\n", i, val, max_value, val, min_value); */
if (val > min_value || val < max_value)
break;
}
-
gsl_data_handle_close (dhandle);
-
return i >= dhandle->setup.n_values ? -1: i;
}
-
static inline gdouble
tailmatch_score_loop (GslDataHandle *shandle,
GslDataHandle *dhandle,
@@ -521,28 +450,22 @@ tailmatch_score_loop (GslDataHandle *shandle,
GslLong l, length = MIN (shandle->setup.n_values, dhandle->setup.n_values);
gfloat v1[GSL_DATA_HANDLE_PEEK_BUFFER], v2[GSL_DATA_HANDLE_PEEK_BUFFER];
gdouble score = 0;
-
g_assert (start < length);
-
for (l = start; l < length; )
{
GslLong b = MIN (GSL_DATA_HANDLE_PEEK_BUFFER, length - l);
-
b = gsl_data_handle_read (shandle, l, b, v1);
b = gsl_data_handle_read (dhandle, l, b, v2);
g_assert (b >= 1); // FIXME
l += b;
-
while (b--)
score += (v1[b] - v2[b]) * (v1[b] - v2[b]);
-
/* for performance, prematurely abort */
if (score > worst_score)
break;
}
return score;
}
-
gboolean
gsl_data_find_tailmatch (GslDataHandle *dhandle,
const GslLoopSpec *lspec,
@@ -553,7 +476,6 @@ gsl_data_find_tailmatch (GslDataHandle *dhandle,
GslDataCache *dcache;
GslLong length, offset, l, lsize, pcount, start = 0, end = 0;
gdouble pbound, pval, best_score = GSL_MAXLONG;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (lspec != NULL, FALSE);
g_return_val_if_fail (loop_start_p != NULL, FALSE);
@@ -563,7 +485,6 @@ gsl_data_find_tailmatch (GslDataHandle *dhandle,
g_return_val_if_fail (lspec->min_loop >= 1, FALSE);
g_return_val_if_fail (lspec->max_loop >= lspec->min_loop, FALSE);
g_return_val_if_fail (lspec->tail_cut >= lspec->max_loop, FALSE);
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
length = dhandle->setup.n_values;
@@ -585,7 +506,6 @@ gsl_data_find_tailmatch (GslDataHandle *dhandle,
gsl_data_handle_close (dhandle);
return FALSE;
}
-
dcache = gsl_data_cache_new (dhandle, 1);
shandle = gsl_data_handle_new_dcached (dcache);
gsl_data_cache_unref (dcache);
@@ -593,24 +513,20 @@ gsl_data_find_tailmatch (GslDataHandle *dhandle,
gsl_data_handle_close (dhandle);
gsl_data_handle_unref (shandle);
/* at this point, we just hold one open() count on shandle */
-
pbound = (lspec->max_loop - lspec->min_loop + 1.);
pbound *= length / 100.;
pval = 0;
pcount = 100;
-
for (lsize = lspec->min_loop; lsize <= lspec->max_loop; lsize++)
{
for (l = length - lsize; l >= 0; l--)
{
GslDataHandle *lhandle = gsl_data_handle_new_looped (shandle, offset + l, offset + l + lsize - 1);
gdouble score;
-
gsl_data_handle_open (lhandle);
score = tailmatch_score_loop (shandle, lhandle, offset + l, best_score);
gsl_data_handle_close (lhandle);
gsl_data_handle_unref (lhandle);
-
if (score < best_score)
{
start = offset + l;
@@ -630,15 +546,11 @@ gsl_data_find_tailmatch (GslDataHandle *dhandle,
}
}
gsl_data_handle_close (shandle);
-
g_print ("\nhalted: %f: [0x%llx..0x%llx] (%llu)\n", best_score, start, end, end - start + 1);
-
*loop_start_p = start;
*loop_end_p = end;
-
return TRUE;
}
-
/**
* @param handle an open GslDataHandle
* @param n_values amount of values to look for
@@ -658,22 +570,17 @@ gsl_data_find_block (GslDataHandle *handle,
{
GslDataPeekBuffer pbuf = { +1 /* random access: 0 */ };
guint i;
-
g_return_val_if_fail (handle != NULL, -1);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (handle), -1);
-
if (n_values < 1)
return -1;
else
g_return_val_if_fail (values != NULL, -1);
-
for (i = 0; i < handle->setup.n_values; i++)
{
guint j;
-
if (n_values > handle->setup.n_values - i)
return -1;
-
for (j = 0; j < n_values; j++)
{
if (fabs (values[j] - gsl_data_handle_peek_value (handle, i + j, &pbuf)) >= epsilon)
@@ -684,7 +591,6 @@ gsl_data_find_block (GslDataHandle *handle,
}
return -1;
}
-
/**
* @param dhandle valid and opened GslDataHandle
* @param min_pos position within @a dhandle
@@ -705,13 +611,11 @@ gsl_data_make_fade_ramp (GslDataHandle *handle,
GslDataPeekBuffer peekbuf = { +1, 0, };
gfloat ramp, rdelta, *values;
GslLong l, i;
-
g_return_val_if_fail (handle != NULL, NULL);
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (handle), NULL);
g_return_val_if_fail (min_pos >= 0 && max_pos >= 0, NULL);
g_return_val_if_fail (min_pos < gsl_data_handle_n_values (handle), NULL);
g_return_val_if_fail (max_pos < gsl_data_handle_n_values (handle), NULL);
-
if (min_pos > max_pos)
{
l = min_pos;
@@ -727,7 +631,6 @@ gsl_data_make_fade_ramp (GslDataHandle *handle,
rdelta = +1. / (gfloat) (l + 2);
ramp = rdelta;
}
-
l += 1;
values = g_new (gfloat, l);
for (i = 0; i < l; i++)
@@ -735,13 +638,10 @@ gsl_data_make_fade_ramp (GslDataHandle *handle,
values[i] = gsl_data_handle_peek_value (handle, min_pos + i, &peekbuf) * ramp;
ramp += rdelta;
}
-
if (length_p)
*length_p = l;
-
return values;
}
-
/**
* @param dhandle valid and opened GslDataHandle
* @param cconfig clip configuration
@@ -763,7 +663,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (dhandle), BSE_ERROR_INTERNAL);
g_return_val_if_fail (cconfig != NULL, BSE_ERROR_INTERNAL);
gboolean info = cconfig->produce_info != FALSE;
-
SfiNum last_value = gsl_data_handle_n_values (dhandle);
if (last_value < 1)
{
@@ -773,7 +672,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
return result->error;
}
last_value -= 1;
-
/* signal range detection */
SfiNum head = gsl_data_find_sample (dhandle, +cconfig->threshold, -cconfig->threshold, 0, +1);
if (head < 0)
@@ -786,7 +684,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
}
SfiNum tail = gsl_data_find_sample (dhandle, +cconfig->threshold, -cconfig->threshold, -1, -1);
g_assert (tail >= 0);
-
/* verify silence detection */
if (last_value - tail < cconfig->tail_samples)
{
@@ -806,7 +703,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
result->head_detected = TRUE;
if (info)
sfi_info ("Silence detected: head_silence=%lld tail_silence=%llu", head, last_value - tail);
-
/* tail clipping protection */
if (last_value - tail < cconfig->tail_silence)
{
@@ -814,7 +710,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
sfi_info ("Tail silence too short for clipping: silence_length=%lld minimum_length=%u", last_value - tail, cconfig->tail_silence);
tail = last_value;
}
-
/* padding */
if (cconfig->pad_samples)
{
@@ -824,7 +719,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
if (info && otail != tail)
sfi_info ("Padding Tail: old_tail=%lld tail=%llu padding=%lld", otail, tail, tail - otail);
}
-
/* unclipped handles */
if (head == 0 && last_value == tail)
{
@@ -832,7 +726,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
result->error = BSE_ERROR_NONE;
return result->error;
}
-
/* clipping */
GslDataHandle *clip_handle = gsl_data_handle_new_crop (dhandle, head, last_value - tail);
gsl_data_handle_open (clip_handle);
@@ -842,14 +735,12 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
gsl_data_handle_n_values (clip_handle) - gsl_data_handle_n_values (dhandle));
result->clipped_head = head > 0;
result->clipped_tail = last_value != tail;
-
/* fading */
GslDataHandle *fade_handle;
if (cconfig->fade_samples && head)
{
GslLong l;
gfloat *ramp = gsl_data_make_fade_ramp (dhandle, MAX (head - 1 - (gint) cconfig->fade_samples, 0), head - 1, &l);
-
/* strip initial ramp silence */
gint j, bdepth = gsl_data_handle_bit_depth (dhandle);
gdouble threshold = 1.0 / (((SfiNum) 1) << (bdepth ? bdepth : 16));
@@ -861,7 +752,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
l -= j;
g_memmove (ramp, ramp + j, l * sizeof (ramp[0]));
}
-
fade_handle = gsl_data_handle_new_insert (clip_handle, gsl_data_handle_bit_depth (clip_handle), 0, l, ramp, g_free);
gsl_data_handle_open (fade_handle);
gsl_data_handle_unref (fade_handle);
@@ -873,7 +763,6 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
fade_handle = clip_handle;
gsl_data_handle_open (fade_handle);
}
-
/* prepare result and cleanup */
result->dhandle = gsl_data_handle_ref (fade_handle);
gsl_data_handle_close (fade_handle);
@@ -881,5 +770,4 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
result->error = BSE_ERROR_NONE;
return result->error;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/gsldatautils.hh b/bse/gsldatautils.hh
index 49e23e4..3576392 100644
--- a/bse/gsldatautils.hh
+++ b/bse/gsldatautils.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DATA_UTILS_H__
#define __GSL_DATA_UTILS_H__
-
#include <bse/bsemath.hh>
#include <bse/gsldatahandle.hh>
-
G_BEGIN_DECLS
-
/* --- structures --- */
#define GSL_DATA_HANDLE_PEEK_BUFFER (2048)
typedef struct
@@ -23,8 +20,6 @@ typedef struct
GslLong min_loop;
GslLong max_loop;
} GslLoopSpec; /* rename this to GslData... */
-
-
/* --- data utils --- */
gboolean gsl_data_detect_signal (GslDataHandle *handle,
GslLong *sigstart,
@@ -49,8 +44,6 @@ gfloat* gsl_data_make_fade_ramp (GslDataHandle *handle,
double gsl_data_find_min_max (GslDataHandle *handle,
double *dmin,
double *dmax);
-
-
/* --- data handle utils --- */
static inline gfloat gsl_data_handle_peek_value (GslDataHandle *dhandle,
GslLong position,
@@ -91,7 +84,6 @@ gint /* errno */ bse_wave_file_from_dbuffer (const char *file_name,
guint sample_freq,
guint n_values,
const gdouble *values);
-
/* --- conversion utils --- */
static inline guint gsl_conv_from_float (GslWaveFormatType format,
guint byte_order,
@@ -125,8 +117,6 @@ static inline void gsl_conv_to_double (GslWaveFormatType format,
guint n_values);
static inline gint16 gsl_alaw_to_pcm (gint8 alawv);
static inline gint16 gsl_ulaw_to_pcm (gint8 ulawv);
-
-
/* --- clipping --- */
typedef struct
{
@@ -148,17 +138,13 @@ typedef struct
guint clipped_tail : 1;
BseErrorType error;
} GslDataClipResult;
-
BseErrorType gsl_data_clip_sample (GslDataHandle *dhandle,
GslDataClipConfig *cconfig,
GslDataClipResult *result);
-
-
/* --- misc implementations --- */
gfloat gsl_data_peek_value_f (GslDataHandle *dhandle,
GslLong pos,
GslDataPeekBuffer *peekbuf);
-
static inline gfloat
gsl_data_handle_peek_value (GslDataHandle *dhandle,
GslLong position,
@@ -168,9 +154,7 @@ gsl_data_handle_peek_value (GslDataHandle *dhandle,
peekbuf->data[position - peekbuf->start] :
gsl_data_peek_value_f (dhandle, position, peekbuf));
}
-
#define GSL_CONV_FORMAT(format, endian_flag) (((endian_flag) << 16) | ((format) & 0xffff))
-
static inline guint /* returns number of bytes used in dest */
gsl_conv_from_float (GslWaveFormatType format,
guint byte_order,
@@ -186,10 +170,8 @@ gsl_conv_from_float (GslWaveFormatType format,
guint32 *u32dest = (guint32*) dest;
const gfloat *bound = src + n_values;
const guint32 *u32src = (guint32*) src, *u32bound = (const guint32*) bound;
-
if (!n_values)
return 0;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
BseFpuState fpu;
@@ -377,7 +359,6 @@ gsl_conv_from_float (GslWaveFormatType format,
return 0;
}
}
-
static inline guint /* returns number of bytes used in dest */
gsl_conv_from_float_clip (GslWaveFormatType format,
guint byte_order,
@@ -393,10 +374,8 @@ gsl_conv_from_float_clip (GslWaveFormatType format,
guint32 *u32dest = (guint32*) dest;
const gfloat *bound = src + n_values;
const guint32 *u32src = (const guint32*) src, *u32bound = (const guint32*) bound;
-
if (!n_values)
return 0;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
BseFpuState fpu;
@@ -608,7 +587,6 @@ gsl_conv_from_float_clip (GslWaveFormatType format,
return 0;
}
}
-
#define GSL_ALAW_MAX (0x7e00)
static inline gint16
gsl_alaw_to_pcm (gint8 alawv)
@@ -633,7 +611,6 @@ gsl_alaw_to_pcm (gint8 alawv)
};
return alawv < 0 ? alaw2pcm_table[128 + alawv] : -alaw2pcm_table[alawv];
}
-
#define GSL_ULAW_MAX (0x7d7c)
static inline gint16
gsl_ulaw_to_pcm (gint8 ulawv)
@@ -658,7 +635,6 @@ gsl_ulaw_to_pcm (gint8 ulawv)
};
return ulawv < 0 ? ulaw2pcm_table[128 + ulawv] : -ulaw2pcm_table[ulawv];
}
-
static inline void
gsl_conv_to_float (GslWaveFormatType format,
guint byte_order,
@@ -674,10 +650,8 @@ gsl_conv_to_float (GslWaveFormatType format,
const guint32 *u32src = (guint32*) src;
gfloat *bound = dest + n_values;
guint32 *u32dest = (guint32*) dest, *u32bound = (guint32*) bound;
-
if (!n_values)
return;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
gint16 vi16;
@@ -826,7 +800,6 @@ gsl_conv_to_float (GslWaveFormatType format,
g_assert_not_reached ();
}
}
-
/* same as above with s/float/double */
static inline guint /* returns number of bytes used in dest */
gsl_conv_from_double (GslWaveFormatType format,
@@ -843,10 +816,8 @@ gsl_conv_from_double (GslWaveFormatType format,
gint32 *i32 = (gint32*) dest;
const gdouble *bound = src + n_values;
const guint32 *u32src = (const guint32*) src, *u32bound = (const guint32*) bound;
-
if (!n_values)
return 0;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
BseFpuState fpu;
@@ -1034,7 +1005,6 @@ gsl_conv_from_double (GslWaveFormatType format,
return 0;
}
}
-
static inline guint /* returns number of bytes used in dest */
gsl_conv_from_double_clip (GslWaveFormatType format,
guint byte_order,
@@ -1050,10 +1020,8 @@ gsl_conv_from_double_clip (GslWaveFormatType format,
gint32 *i32 = (gint32*) dest;
const gdouble *bound = src + n_values;
const guint32 *u32src = (const guint32*) src, *u32bound = (const guint32*) bound;
-
if (!n_values)
return 0;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
BseFpuState fpu;
@@ -1265,7 +1233,6 @@ gsl_conv_from_double_clip (GslWaveFormatType format,
return 0;
}
}
-
static inline void
gsl_conv_to_double (GslWaveFormatType format,
guint byte_order,
@@ -1281,10 +1248,8 @@ gsl_conv_to_double (GslWaveFormatType format,
const gint32 *i32 = (gint32*) src;
gdouble *bound = dest + n_values;
guint32 *u32dest = (guint32*) dest, *u32bound = (guint32*) bound;
-
if (!n_values)
return;
-
switch (GSL_CONV_FORMAT (format, byte_order == G_BYTE_ORDER))
{
gint16 vi16;
@@ -1433,9 +1398,6 @@ gsl_conv_to_double (GslWaveFormatType format,
g_assert_not_reached ();
}
}
-
G_END_DECLS
-
#endif /* __GSL_DATA_UTILS_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/gsldefs.hh b/bse/gsldefs.hh
index 5046b52..3aa75f0 100644
--- a/bse/gsldefs.hh
+++ b/bse/gsldefs.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_DEFS_H__
#define __GSL_DEFS_H__
-
#include <sfi/sfi.hh>
#include <sfi/sfistore.hh>
-
-
G_BEGIN_DECLS
-
/* --- forward decls --- */
typedef struct _GslMagic GslMagic;
typedef struct _GslDataCache GslDataCache;
@@ -16,7 +12,6 @@ typedef struct _GslDataHandleFuncs GslDataHandleFuncs;
typedef struct _GslWaveChunk GslWaveChunk;
typedef struct _GslWaveChunkBlock GslWaveChunkBlock;
/* ssize_t/off_t type used within Gsl */
-
/*
* FIXME: GslLong is a temporary typedef - it should go away after all
* code that uses GslLong has been ported to use int64 (as defined in
@@ -25,12 +20,8 @@ typedef struct _GslWaveChunkBlock GslWaveChunkBlock;
typedef int64 GslLong;
#define GSL_MAXLONG G_MAXINT64;
#define GSL_MINLONG G_MININT64;
-
-
/* --- functions --- */
typedef void (*GslFreeFunc) (gpointer data);
-
-
/* --- implementation details --- */
#if __GNUC__ >= 3 && defined __OPTIMIZE__
# define GSL_GCC_PREFETCH(addr) (__builtin_prefetch (addr, 0))
@@ -41,9 +32,6 @@ typedef void (*GslFreeFunc) (gpointer data);
# define GSL_GCC_RPREFETCH(addr) /* addr */
# define GSL_GCC_WPREFETCH(addr) /* addr */
#endif
-
G_END_DECLS
-
#endif /* __GSL_DEFS_H__ */
-
/* vim:set ts=8 sw=2 sts=2: */
diff --git a/bse/gslfft.hh b/bse/gslfft.hh
index ca4cf27..61aeaa6 100644
--- a/bse/gslfft.hh
+++ b/bse/gslfft.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_FFT_H__
#define __GSL_FFT_H__
-
#include <bse/gsldefs.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/**
* @param n_values Number of complex values
* @param ri_values_in Complex sample values [0..n_values*2-1]
@@ -46,7 +42,6 @@ extern "C" {
void gsl_power2_fftac (const uint n_values,
const double *ri_values_in,
double *ri_values_out);
-
/**
* @param n_values Number of complex values
* @param ri_values_in Complex frequency values [0..n_values*2-1]
@@ -70,7 +65,6 @@ void gsl_power2_fftac (const uint n_values,
void gsl_power2_fftsc (const uint n_values,
const double *ri_values_in,
double *ri_values_out);
-
/**
* @param n_values Number of complex values
* @param ri_values_in Complex frequency values [0..n_values*2-1]
@@ -122,7 +116,6 @@ void gsl_power2_fftsc_scale (const unsigned int n_values,
void gsl_power2_fftar (const uint n_values,
const double *r_values_in,
double *ri_values_out);
-
/**
* @param n_values Number of real sample values
* @param ri_values_in Complex frequency values [0..n_values-1]
@@ -146,7 +139,6 @@ void gsl_power2_fftar (const uint n_values,
void gsl_power2_fftsr (const unsigned int n_values,
const double *ri_values_in,
double *r_values_out);
-
/**
* @param n_values Number of real sample values
* @param ri_values_in Complex frequency values [0..n_values-1]
@@ -169,8 +161,6 @@ void gsl_power2_fftsr (const unsigned int n_values,
void gsl_power2_fftsr_scale (const unsigned int n_values,
const double *ri_values_in,
double *r_values_out);
-
-
/* --- convenience wrappers --- */
void gsl_power2_fftar_simple (const uint n_values,
const float *real_values,
@@ -181,11 +171,7 @@ void gsl_power2_fftsr_simple (const uint n_values,
void gsl_power2_fftsr_scale_simple (const unsigned int n_values,
const float *complex_values,
float *real_values);
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_FFT_H__ */ /* vim:set ts=8 sw=2 sts=2: */
diff --git a/bse/gslfilehash.cc b/bse/gslfilehash.cc
index 605310b..5bc497f 100644
--- a/bse/gslfilehash.cc
+++ b/bse/gslfilehash.cc
@@ -1,69 +1,54 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gslfilehash.hh"
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
-
-
/* macros */
#if (GLIB_SIZEOF_LONG > 4)
#define HASH_LONG(l) (l + (guint64 (l) >> 32))
#else
#define HASH_LONG(l) (l)
#endif
-
-
/* --- variables --- */
static BirnetMutex fdpool_mutex = { 0, };
static GHashTable *hfile_ht = NULL;
-
-
/* --- functions --- */
static guint
hfile_hash (gconstpointer key)
{
const GslHFile *hfile = (const GslHFile*) key;
guint h;
-
h = HASH_LONG (hfile->mtime);
h ^= g_str_hash (hfile->file_name);
h ^= HASH_LONG (hfile->n_bytes);
-
return h;
}
-
static gboolean
hfile_equals (gconstpointer key1,
gconstpointer key2)
{
const GslHFile *hfile1 = (const GslHFile*) key1;
const GslHFile *hfile2 = (const GslHFile*) key2;
-
return (hfile1->mtime == hfile2->mtime &&
hfile1->n_bytes == hfile2->n_bytes &&
strcmp (hfile1->file_name, hfile2->file_name) == 0);
}
-
void
_gsl_init_fd_pool (void)
{
g_assert (hfile_ht == NULL);
-
sfi_mutex_init (&fdpool_mutex);
hfile_ht = g_hash_table_new (hfile_hash, hfile_equals);
}
-
static gboolean
stat_file (const gchar *file_name,
GTime *mtime,
GslLong *n_bytes)
{
struct stat statbuf = { 0, };
-
if (stat (file_name, &statbuf) < 0)
return FALSE; /* have errno */
if (mtime)
@@ -72,7 +57,6 @@ stat_file (const gchar *file_name,
*n_bytes = statbuf.st_size;
return TRUE;
}
-
/**
* @param file_name name of the file to open
* @returns a new opened GslHFile or NULL if an error occoured (errno set)
@@ -90,14 +74,11 @@ gsl_hfile_open (const gchar *file_name)
{
GslHFile key, *hfile;
gint ret_errno;
-
errno = EFAULT;
g_return_val_if_fail (file_name != NULL, NULL);
-
key.file_name = (gchar*) file_name;
if (!stat_file (file_name, &key.mtime, &key.n_bytes))
return NULL; /* errno from stat() */
-
sfi_mutex_lock (&fdpool_mutex);
hfile = (GslHFile*) g_hash_table_lookup (hfile_ht, &key);
if (hfile)
@@ -110,7 +91,6 @@ gsl_hfile_open (const gchar *file_name)
else
{
gint fd;
-
fd = open (file_name, O_RDONLY | O_NOCTTY, 0);
if (fd >= 0)
{
@@ -130,11 +110,9 @@ gsl_hfile_open (const gchar *file_name)
ret_errno = errno;
}
sfi_mutex_unlock (&fdpool_mutex);
-
errno = ret_errno;
return hfile;
}
-
/**
* @param hfile valid GslHFile
*
@@ -145,10 +123,8 @@ void
gsl_hfile_close (GslHFile *hfile)
{
gboolean destroy = FALSE;
-
g_return_if_fail (hfile != NULL);
g_return_if_fail (hfile->ocount > 0);
-
sfi_mutex_lock (&fdpool_mutex);
sfi_mutex_lock (&hfile->mutex);
if (hfile->ocount > 1)
@@ -166,7 +142,6 @@ gsl_hfile_close (GslHFile *hfile)
}
sfi_mutex_unlock (&hfile->mutex);
sfi_mutex_unlock (&fdpool_mutex);
-
if (destroy)
{
sfi_mutex_destroy (&hfile->mutex);
@@ -176,7 +151,6 @@ gsl_hfile_close (GslHFile *hfile)
}
errno = 0;
}
-
/**
* @param hfile valid GslHFile
* @param offset offset in bytes within 0 and file end
@@ -195,7 +169,6 @@ gsl_hfile_pread (GslHFile *hfile,
{
GslLong ret_bytes = -1;
gint ret_errno;
-
errno = EFAULT;
g_return_val_if_fail (hfile != NULL, -1);
g_return_val_if_fail (hfile->ocount > 0, -1);
@@ -206,7 +179,6 @@ gsl_hfile_pread (GslHFile *hfile,
return 0;
}
g_return_val_if_fail (bytes != NULL, -1);
-
sfi_mutex_lock (&hfile->mutex);
if (hfile->ocount)
{
@@ -250,11 +222,9 @@ gsl_hfile_pread (GslHFile *hfile,
else
ret_errno = EFAULT;
sfi_mutex_unlock (&hfile->mutex);
-
errno = ret_errno;
return ret_bytes;
}
-
/**
* @param hfile valid GslHFile
* @return offset of first zero byte or -1
@@ -268,11 +238,9 @@ gsl_hfile_zoffset (GslHFile *hfile)
GslLong zoffset, l;
guint8 sdata[1024], *p;
gboolean seen_zero = FALSE;
-
errno = EFAULT;
g_return_val_if_fail (hfile != NULL, -1);
g_return_val_if_fail (hfile->ocount > 0, -1);
-
sfi_mutex_lock (&hfile->mutex);
if (hfile->zoffset > -2) /* got valid offset already */
{
@@ -287,7 +255,6 @@ gsl_hfile_zoffset (GslHFile *hfile)
}
hfile->ocount += 1; /* keep open for a while */
sfi_mutex_unlock (&hfile->mutex);
-
/* seek to literal '\0' */
zoffset = 0;
do
@@ -300,7 +267,6 @@ gsl_hfile_zoffset (GslHFile *hfile)
gsl_hfile_close (hfile);
return -1;
}
-
p = (guint8*) memchr (sdata, 0, l);
seen_zero = p != NULL;
zoffset += seen_zero ? p - sdata : l;
@@ -308,17 +274,13 @@ gsl_hfile_zoffset (GslHFile *hfile)
while (!seen_zero && l);
if (!seen_zero)
zoffset = -1;
-
sfi_mutex_lock (&hfile->mutex);
if (hfile->zoffset < -1)
hfile->zoffset = zoffset;
sfi_mutex_unlock (&hfile->mutex);
-
gsl_hfile_close (hfile);
-
return zoffset;
}
-
/**
* @param file_name name of the file to open
* @return a new opened #GslRFile or NULL if an error occoured (errno set)
@@ -333,7 +295,6 @@ gsl_rfile_open (const gchar *file_name)
{
GslHFile *hfile = gsl_hfile_open (file_name);
GslRFile *rfile;
-
if (!hfile)
rfile = NULL;
else
@@ -344,7 +305,6 @@ gsl_rfile_open (const gchar *file_name)
}
return rfile;
}
-
/**
* @param rfile valid #GslRFile
* @return the file name used to open this file
@@ -356,11 +316,9 @@ gsl_rfile_name (GslRFile *rfile)
{
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, NULL);
-
errno = 0;
return rfile->hfile->file_name;
}
-
/**
* @param rfile valid GslRFile
* @param offset new seek position within 0 and gsl_rfile_length()+1
@@ -373,17 +331,13 @@ gsl_rfile_seek_set (GslRFile *rfile,
GslLong offset)
{
GslLong l;
-
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, 0);
-
l = rfile->hfile->n_bytes;
rfile->offset = CLAMP (offset, 0, l);
-
errno = 0;
return rfile->offset;
}
-
/**
* @param rfile valid GslRFile
* @return current position within 0 and gsl_rfile_length()
@@ -395,11 +349,9 @@ gsl_rfile_position (GslRFile *rfile)
{
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, 0);
-
errno = 0;
return rfile->offset;
}
-
/**
* @param rfile valid GslRFile
* @return total length of the GslRFile in bytes
@@ -410,16 +362,12 @@ GslLong
gsl_rfile_length (GslRFile *rfile)
{
GslLong l;
-
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, 0);
-
l = rfile->hfile->n_bytes;
-
errno = 0;
return l;
}
-
/**
* @param rfile valid GslRFile
* @param offset offset in bytes within 0 and gsl_rfile_length()
@@ -437,10 +385,8 @@ gsl_rfile_pread (GslRFile *rfile,
{
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, -1);
-
return gsl_hfile_pread (rfile->hfile, offset, n_bytes, bytes);
}
-
/**
* @param rfile valid GslRFile
* @param n_bytes number of bytes to read
@@ -456,16 +402,13 @@ gsl_rfile_read (GslRFile *rfile,
gpointer bytes)
{
GslLong l;
-
errno = EFAULT;
g_return_val_if_fail (rfile != NULL, -1);
-
l = gsl_hfile_pread (rfile->hfile, rfile->offset, n_bytes, bytes);
if (l > 0)
rfile->offset += l;
return l;
}
-
/**
* @param rfile valid GslRFile
*
@@ -476,7 +419,6 @@ gsl_rfile_close (GslRFile *rfile)
{
errno = EFAULT;
g_return_if_fail (rfile != NULL);
-
gsl_hfile_close (rfile->hfile);
sfi_delete_struct (GslRFile, rfile);
errno = 0;
diff --git a/bse/gslfilehash.hh b/bse/gslfilehash.hh
index ae7404d..fe598b0 100644
--- a/bse/gslfilehash.hh
+++ b/bse/gslfilehash.hh
@@ -1,16 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_FILE_HASH_H__
#define __GSL_FILE_HASH_H__
-
#include <bse/gsldefs.hh>
#include <bse/gslcommon.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
-
/* --- typedefs & structures --- */
typedef struct {
gchar *file_name;
@@ -27,8 +22,6 @@ typedef struct {
GslHFile *hfile;
GslLong offset;
} GslRFile;
-
-
/* --- GslHFile API --- */
GslHFile* gsl_hfile_open (const gchar *file_name);
GslLong gsl_hfile_pread (GslHFile *hfile,
@@ -37,8 +30,6 @@ GslLong gsl_hfile_pread (GslHFile *hfile,
gpointer bytes);
GslLong gsl_hfile_zoffset (GslHFile *hfile);
void gsl_hfile_close (GslHFile *hfile);
-
-
/* --- GslRFile API --- */
GslRFile* gsl_rfile_open (const gchar *file_name);
gchar* gsl_rfile_name (GslRFile *rfile);
@@ -54,10 +45,7 @@ GslLong gsl_rfile_seek_set (GslRFile *rfile,
GslLong gsl_rfile_position (GslRFile *rfile);
GslLong gsl_rfile_length (GslRFile *rfile);
void gsl_rfile_close (GslRFile *rfile);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_FILE_HASH_H__ */
diff --git a/bse/gslfilter.cc b/bse/gslfilter.cc
index 51ba0a8..060c1d5 100644
--- a/bse/gslfilter.cc
+++ b/bse/gslfilter.cc
@@ -2,24 +2,19 @@
#include "gslfilter.hh"
#include "gslfft.hh"
#include "bsemathsignal.hh"
-
#include <string.h>
-
-
/* --- common utilities --- */
static inline double
cotan (double x)
{
return - tan (x + PI * 0.5);
}
-
static double
gsl_db_invert (double x)
{
/* db = 20*log(x)/log(10); */
return exp (x * log (10) / 20.0);
}
-
static void
band_filter_common (uint iorder,
double p_freq, /* 0..pi */
@@ -37,10 +32,8 @@ band_filter_common (uint iorder,
BseComplex fpoly[2 + 1] = { { 0, }, { 0, }, { 1, 0 } };
double alpha, norm;
guint i;
-
epsilon = bse_trans_zepsilon2ss (epsilon);
alpha = cos ((s_freq + p_freq) * 0.5) / cos ((s_freq - p_freq) * 0.5);
-
fpoly[0] = bse_complex (1, 0);
fpoly[1] = bse_complex (1, 0);
for (i = 0; i < iorder2; i++)
@@ -49,16 +42,13 @@ band_filter_common (uint iorder,
fpoly[1] = bse_complex_mul (fpoly[1], bse_complex_sub (bse_complex (1, 0), bse_complex_reciprocal (poles[i])));
}
norm = bse_complex_div (fpoly[1], fpoly[0]).re;
-
if ((iorder2 & 1) == 0) /* norm is fluctuation minimum */
norm *= sqrt (1.0 / (1.0 + epsilon * epsilon));
-
/* z numerator polynomial */
poly[0] = bse_complex (norm, 0);
for (i = 0; i < iorder2; i++)
{
BseComplex t, alphac = bse_complex (alpha, 0);
-
t = band_pass ? bse_complex_inv (roots[i]) : roots[i];
fpoly[1] = bse_complex_sub (bse_complex_div (alphac, t), alphac);
fpoly[0] = bse_complex_inv (bse_complex_reciprocal (t));
@@ -66,13 +56,11 @@ band_filter_common (uint iorder,
}
for (i = 0; i <= iorder; i++)
a[i] = poly[i].re;
-
/* z denominator polynomial */
poly[0] = bse_complex (1, 0);
for (i = 0; i < iorder2; i++)
{
BseComplex t, alphac = bse_complex (alpha, 0);
-
t = band_pass ? bse_complex_inv (poles[i]) : poles[i];
fpoly[1] = bse_complex_sub (bse_complex_div (alphac, t), alphac);
fpoly[0] = bse_complex_inv (bse_complex_reciprocal (t));
@@ -83,7 +71,6 @@ band_filter_common (uint iorder,
bse_poly_scale (iorder, a, 1.0 / b[0]);
bse_poly_scale (iorder, b, 1.0 / b[0]);
}
-
static void
filter_rp_to_z (uint iorder,
BseComplex *roots, /* [0..iorder-1] */
@@ -93,14 +80,12 @@ filter_rp_to_z (uint iorder,
{
BseComplex *poly = g_newa (BseComplex, iorder + 1);
guint i;
-
/* z numerator polynomial */
poly[0] = bse_complex (1, 0);
for (i = 0; i < iorder; i++)
bse_cpoly_mul_reciprocal (i + 1, poly, roots[i]);
for (i = 0; i <= iorder; i++)
a[i] = poly[i].re;
-
/* z denominator polynomial */
poly[0] = bse_complex (1, 0);
for (i = 0; i < iorder; i++)
@@ -108,22 +93,18 @@ filter_rp_to_z (uint iorder,
for (i = 0; i <= iorder; i++)
b[i] = poly[i].re;
}
-
static void
filter_lp_invert (uint iorder,
double *a, /* [0..iorder] */
double *b)
{
guint i;
-
for (i = 1; i <= iorder; i +=2)
{
a[i] = -a[i];
b[i] = -b[i];
}
}
-
-
/* --- butterworth filter --- */
void
gsl_filter_butter_rp (uint iorder,
@@ -138,27 +119,21 @@ gsl_filter_butter_rp (uint iorder,
double kappa;
BseComplex root;
uint i;
-
epsilon = bse_trans_zepsilon2ss (epsilon);
kappa = bse_trans_freq2s (freq) * pow (epsilon, -1.0 / order);
-
/* construct poles for butterworth filter */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) + iorder - 1;
double beta = t * beta_mul;
-
root.re = kappa * cos (beta);
root.im = kappa * sin (beta);
poles[i - 1] = bse_trans_s2z (root);
}
-
/* z numerator polynomial */
for (i = 0; i < iorder; i++)
roots[i] = bse_complex (-1, 0);
}
-
-
/* --- tschebyscheff type 1 filter --- */
static double
tschebyscheff_eval (uint degree,
@@ -166,22 +141,18 @@ tschebyscheff_eval (uint degree,
{
double td = x, td_m_1 = 1;
uint d = 1;
-
/* eval polynomial for a certain x */
if (degree == 0)
return 1;
-
while (d < degree)
{
double td1 = 2 * x * td - td_m_1;
-
td_m_1 = td;
td = td1;
d++;
}
return td;
}
-
static double
tschebyscheff_inverse (uint degree,
double x)
@@ -189,7 +160,6 @@ tschebyscheff_inverse (uint degree,
/* note, that thebyscheff_eval(degree,x)=cosh(degree*acosh(x)) */
return cosh (acosh (x) / degree);
}
-
void
gsl_filter_tscheb1_rp (uint iorder,
double freq, /* 1..pi */
@@ -203,27 +173,21 @@ gsl_filter_tscheb1_rp (uint iorder,
double kappa = bse_trans_freq2s (freq);
BseComplex root;
uint i;
-
epsilon = bse_trans_zepsilon2ss (epsilon);
alpha = asinh (1.0 / epsilon) / order;
-
/* construct poles polynomial from tschebyscheff polynomial */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) + iorder - 1;
double beta = t * beta_mul;
-
root.re = kappa * sinh (alpha) * cos (beta);
root.im = kappa * cosh (alpha) * sin (beta);
poles[i - 1] = bse_trans_s2z (root);
}
-
/* z numerator polynomial */
for (i = 0; i < iorder; i++)
roots[i] = bse_complex (-1, 0);
}
-
-
/* --- tschebyscheff type 2 filter --- */
void
gsl_filter_tscheb2_rp (uint iorder,
@@ -242,7 +206,6 @@ gsl_filter_tscheb2_rp (uint iorder,
double beta_mul = pi / (2.0 * order);
BseComplex root;
uint i;
-
#if 0
/* triggers an internal compiler error with gcc-2.95.4 (and certain
* combinations of optimization options)
@@ -250,30 +213,25 @@ gsl_filter_tscheb2_rp (uint iorder,
g_return_if_fail (c_freq * steepness < PI);
#endif
g_return_if_fail (steepness > 1.0);
-
epsilon = bse_trans_zepsilon2ss (epsilon);
tepsilon = epsilon * tschebyscheff_eval (iorder, kappa_r / kappa_c);
alpha = asinh (tepsilon) / order;
-
/* construct poles polynomial from tschebyscheff polynomial */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) + iorder - 1;
double beta = t * beta_mul;
-
root.re = sinh (alpha) * cos (beta);
root.im = cosh (alpha) * sin (beta);
root = bse_complex_div (bse_complex (kappa_r, 0), root);
root = bse_trans_s2z (root);
poles[i - 1] = root;
}
-
/* construct roots polynomial from tschebyscheff polynomial */
for (i = 1; i <= iorder; i++)
{
double t = (i << 1) - 1;
BseComplex root = bse_complex (0, cos (t * beta_mul));
-
if (fabs (root.im) > 1e-14)
{
root = bse_complex_div (bse_complex (kappa_r, 0), root);
@@ -284,7 +242,6 @@ gsl_filter_tscheb2_rp (uint iorder,
roots[i - 1] = root;
}
}
-
/**
* @param iorder filter order
* @param c_freq passband cutoff frequency (0..pi)
@@ -302,7 +259,6 @@ gsl_filter_tscheb2_steepness_db (uint iorder,
{
return gsl_filter_tscheb2_steepness (iorder, c_freq, epsilon, gsl_db_invert (-stopband_db));
}
-
/**
* @param iorder filter order
* @param c_freq passband cutoff frequency (0..pi)
@@ -319,16 +275,12 @@ gsl_filter_tscheb2_steepness (uint iorder,
double residue)
{
double kappa_c, kappa_r, r_freq;
-
epsilon = bse_trans_zepsilon2ss (epsilon);
kappa_c = bse_trans_freq2s (c_freq);
kappa_r = tschebyscheff_inverse (iorder, sqrt (1.0 / (residue * residue) - 1.0) / epsilon) * kappa_c;
r_freq = bse_trans_freq2z (kappa_r);
-
return r_freq / c_freq;
}
-
-
/* --- lowpass filters --- */
/**
* @param iorder filter order
@@ -349,17 +301,13 @@ gsl_filter_butter_lp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder);
BseComplex *poles = g_newa (BseComplex, iorder);
double norm;
-
g_return_if_fail (freq > 0 && freq < PI);
-
gsl_filter_butter_rp (iorder, freq, epsilon, roots, poles);
filter_rp_to_z (iorder, roots, poles, a, b);
-
/* scale maximum to 1.0 */
norm = bse_poly_eval (iorder, b, 1) / bse_poly_eval (iorder, a, 1);
bse_poly_scale (iorder, a, norm);
}
-
/**
* @param iorder filter order
* @param freq cutoff frequency (0..pi)
@@ -379,12 +327,9 @@ gsl_filter_tscheb1_lp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder);
BseComplex *poles = g_newa (BseComplex, iorder);
double norm;
-
g_return_if_fail (freq > 0 && freq < PI);
-
gsl_filter_tscheb1_rp (iorder, freq, epsilon, roots, poles);
filter_rp_to_z (iorder, roots, poles, a, b);
-
/* scale maximum to 1.0 */
norm = bse_poly_eval (iorder, b, 1) / bse_poly_eval (iorder, a, 1);
if ((iorder & 1) == 0) /* norm is fluctuation minimum */
@@ -394,7 +339,6 @@ gsl_filter_tscheb1_lp (uint iorder,
}
bse_poly_scale (iorder, a, norm);
}
-
/**
* @param iorder filter order
* @param freq passband cutoff frequency (0..pi)
@@ -419,20 +363,15 @@ gsl_filter_tscheb2_lp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder);
BseComplex *poles = g_newa (BseComplex, iorder);
double norm;
-
g_return_if_fail (freq > 0 && freq < PI);
g_return_if_fail (freq * steepness < PI);
g_return_if_fail (steepness > 1.0);
-
gsl_filter_tscheb2_rp (iorder, freq, steepness, epsilon, roots, poles);
filter_rp_to_z (iorder, roots, poles, a, b);
-
/* scale maximum to 1.0 */
norm = bse_poly_eval (iorder, b, 1) / bse_poly_eval (iorder, a, 1); /* H(z=0):=1, e^(j*omega) for omega=0 => e^0==1 */
bse_poly_scale (iorder, a, norm);
}
-
-
/* --- highpass filters --- */
/**
* @param iorder filter order
@@ -451,12 +390,10 @@ gsl_filter_butter_hp (uint iorder,
double *b)
{
g_return_if_fail (freq > 0 && freq < PI);
-
freq = PI - freq;
gsl_filter_butter_lp (iorder, freq, epsilon, a, b);
filter_lp_invert (iorder, a, b);
}
-
/**
* @param iorder filter order
* @param freq passband frequency (0..pi)
@@ -474,12 +411,10 @@ gsl_filter_tscheb1_hp (uint iorder,
double *b)
{
g_return_if_fail (freq > 0 && freq < PI);
-
freq = PI - freq;
gsl_filter_tscheb1_lp (iorder, freq, epsilon, a, b);
filter_lp_invert (iorder, a, b);
}
-
/**
* @param iorder filter order
* @param freq stopband frequency (0..pi)
@@ -499,13 +434,10 @@ gsl_filter_tscheb2_hp (uint iorder,
double *b)
{
g_return_if_fail (freq > 0 && freq < PI);
-
freq = PI - freq;
gsl_filter_tscheb2_lp (iorder, freq, steepness, epsilon, a, b);
filter_lp_invert (iorder, a, b);
}
-
-
/* --- bandpass filters --- */
/**
* @param iorder filter order (must be even)
@@ -529,18 +461,14 @@ gsl_filter_butter_bp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., cotan ((freq2 - freq1) * 0.5));
-
gsl_filter_butter_rp (iorder2, theta, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, TRUE, FALSE);
}
-
/**
* @param iorder filter order (must be even)
* @param freq1 stopband end frequency (0..pi)
@@ -563,18 +491,14 @@ gsl_filter_tscheb1_bp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., cotan ((freq2 - freq1) * 0.5));
-
gsl_filter_tscheb1_rp (iorder2, theta, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, TRUE, TRUE);
}
-
/**
* @param iorder filter order (must be even)
* @param freq1 stopband end frequency (0..pi)
@@ -599,19 +523,14 @@ gsl_filter_tscheb2_bp (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., cotan ((freq2 - freq1) * 0.5));
-
gsl_filter_tscheb2_rp (iorder2, theta, steepness, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, TRUE, FALSE);
}
-
-
/* --- bandstop filters --- */
/**
* @param iorder filter order (must be even)
@@ -635,18 +554,14 @@ gsl_filter_butter_bs (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., tan ((freq2 - freq1) * 0.5));
-
gsl_filter_butter_rp (iorder2, theta, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, FALSE, FALSE);
}
-
/**
* @param iorder filter order (must be even)
* @param freq1 passband end frequency (0..pi)
@@ -669,18 +584,14 @@ gsl_filter_tscheb1_bs (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., tan ((freq2 - freq1) * 0.5));
-
gsl_filter_tscheb1_rp (iorder2, theta, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, FALSE, TRUE);
}
-
/**
* @param iorder filter order (must be even)
* @param freq1 passband end frequency (0..pi)
@@ -705,19 +616,14 @@ gsl_filter_tscheb2_bs (uint iorder,
BseComplex *roots = g_newa (BseComplex, iorder2);
BseComplex *poles = g_newa (BseComplex, iorder2);
double theta;
-
g_return_if_fail ((iorder & 0x01) == 0);
g_return_if_fail (freq1 > 0);
g_return_if_fail (freq1 < freq2);
g_return_if_fail (freq2 < PI);
-
theta = 2. * atan2 (1., tan ((freq2 - freq1) * 0.5));
-
gsl_filter_tscheb2_rp (iorder2, theta, steepness, epsilon, roots, poles);
band_filter_common (iorder, freq1, freq2, epsilon, roots, poles, a, b, FALSE, FALSE);
}
-
-
/* --- tschebyscheff type 1 via generic root-finding --- */
#if 0
static void
@@ -734,18 +640,14 @@ tschebyscheff_poly (uint degree,
else
{
double *u = g_newa (double, 1 + degree);
-
u[degree] = 0; u[degree - 1] = 0;
tschebyscheff_poly (degree - 2, u);
-
v[0] = 0;
tschebyscheff_poly (degree - 1, v + 1);
bse_poly_scale (degree - 1, v + 1, 2);
-
bse_poly_sub (degree, v, u);
}
}
-
static void
gsl_filter_tscheb1_test (uint iorder,
double zomega,
@@ -759,21 +661,17 @@ gsl_filter_tscheb1_test (uint iorder,
double *q = g_newa (double, 2 * (1 + iorder));
double O = bse_trans_freq2s (zomega);
uint i;
-
/* calc Vk() */
tschebyscheff_poly (iorder, vk);
-
/* calc q=1+e^2*Vk()^2 */
bse_poly_mul (q, iorder >> 1, vk, iorder >> 1, vk);
iorder *= 2;
bse_poly_scale (iorder, q, epsilon * epsilon);
q[0] += 1;
-
/* find roots, fix roots by 1/(jO) */
bse_poly_complex_roots (iorder, q, roots);
for (i = 0; i < iorder; i++)
roots[i] = bse_complex_mul (roots[i], bse_complex (0, O));
-
/* choose roots from the left half-plane */
if (0)
g_print ("zhqr-root:\n%s\n", bse_complex_list (iorder, roots, " "));
@@ -786,23 +684,19 @@ gsl_filter_tscheb1_test (uint iorder,
r++;
}
iorder /= 2;
-
/* assert roots found */
if (!(r - roots == iorder))
{
g_print ("ERROR: n_roots=%u != iorder=%u\n", r - roots, iorder);
abort ();
}
-
/* s => z */
for (i = 0; i < iorder; i++)
roots[i] = bse_trans_s2z (roots[i]);
-
/* z denominator polynomial */
bse_cpoly_from_roots (iorder, zf, roots);
for (i = 0; i <= iorder; i++)
b[i] = zf[i].re;
-
/* z numerator polynomial */
for (i = 0; i < iorder; i++)
{
@@ -812,10 +706,8 @@ gsl_filter_tscheb1_test (uint iorder,
bse_cpoly_from_roots (iorder, zf, roots);
for (i = 0; i <= iorder; i++)
a[i] = zf[i].re;
-
/* scale for b[0]==1.0 */
bse_poly_scale (iorder, b, 1.0 / b[0]);
-
/* scale maximum to 1.0 */
norm = bse_poly_eval (iorder, a, 1) / bse_poly_eval (iorder, b, 1);
if ((iorder & 0x01) == 0) /* norm is fluctuation minimum */
@@ -823,8 +715,6 @@ gsl_filter_tscheb1_test (uint iorder,
bse_poly_scale (iorder, a, 1.0 / norm);
}
#endif
-
-
/* --- windowed fir approximation --- */
/* returns a blackman window: x is supposed to be in the interval [0..1] */
static inline double
@@ -836,7 +726,6 @@ gsl_blackman_window (double x)
return 0;
return 0.42 - 0.5 * cos (PI * x * 2) + 0.08 * cos (4 * PI * x);
}
-
/**
* @param iorder order of the filter (must be oven, >= 2)
* @param freq the frequencies of the transfer function
@@ -866,22 +755,17 @@ gsl_filter_fir_approx (uint iorder,
double lfreq = -2, lval = 1.0, rfreq = -1, rval = 1.0;
double *fft_in, *fft_out;
double ffact;
-
g_return_if_fail (iorder >= 2);
g_return_if_fail ((iorder & 1) == 0);
-
while (fft_size / 2 <= iorder)
fft_size *= 2;
-
fft_in = g_newa (double, fft_size*2);
fft_out = fft_in+fft_size;
ffact = 2.0 * PI / (double)fft_size;
-
for (i = 0; i <= fft_size / 2; i++)
{
double f = (double) i * ffact;
double pos, val;
-
while (f > rfreq && point != n_points)
{
lfreq = rfreq;
@@ -890,13 +774,11 @@ gsl_filter_fir_approx (uint iorder,
rval = value[point];
point++;
}
-
pos = (f - lfreq) / (rfreq - lfreq);
if (interpolate_db)
val = bse_db_to_factor (bse_db_from_factor (lval, -96) * (1.0 - pos) + bse_db_from_factor (rval, -96) * pos);
else
val = lval * (1.0 - pos) + rval * pos;
-
if (i != fft_size / 2)
{
fft_in[2 * i] = val;
@@ -905,9 +787,7 @@ gsl_filter_fir_approx (uint iorder,
else
fft_in[1] = val;
}
-
gsl_power2_fftsr_scale (fft_size, fft_in, fft_out);
-
for (i = 0; i <= iorder / 2; i++)
{
double c = fft_out[i] * gsl_blackman_window (0.5 + (double) i / (iorder + 2.0));
@@ -915,8 +795,6 @@ gsl_filter_fir_approx (uint iorder,
a[iorder / 2 + i] = c;
}
}
-
-
/* --- filter evaluation --- */
void
gsl_iir_filter_setup (GslIIRFilter *f,
@@ -926,23 +804,18 @@ gsl_iir_filter_setup (GslIIRFilter *f,
gdouble *buffer) /* 4*(order+1) */
{
guint i;
-
g_return_if_fail (f != NULL && a != NULL && b != NULL && buffer != NULL);
g_return_if_fail (order > 0);
-
f->order = order;
f->a = buffer;
f->b = f->a + order + 1;
f->w = f->b + order + 1;
-
memcpy (f->a, a, sizeof (a[0]) * (order + 1));
for (i = 0; i <= order; i++)
f->b[i] = -b[i];
memset (f->w, 0, sizeof (f->w[0]) * (order + 1) * 2);
-
g_return_if_fail (fabs (b[0] - 1.0) < 1e-14);
}
-
void
gsl_iir_filter_change (GslIIRFilter *f,
guint order,
@@ -951,30 +824,24 @@ gsl_iir_filter_change (GslIIRFilter *f,
gdouble *buffer)
{
guint i;
-
g_return_if_fail (f != NULL && a != NULL && b != NULL && buffer != NULL);
g_return_if_fail (order > 0);
-
/* there's no point in calling this function if f wasn't setup properly
* and it's only the As and Bs that changed
*/
g_return_if_fail (f->a == buffer && f->b == f->a + f->order + 1 && f->w == f->b + f->order + 1);
-
/* if the order changed there's no chance preserving state */
if (f->order != order)
{
gsl_iir_filter_setup (f, order, a, b, buffer);
return;
}
-
memcpy (f->a, a, sizeof (a[0]) * (order + 1));
for (i = 0; i <= order; i++)
f->b[i] = -b[i];
/* leaving f->w to preserve state */
-
g_return_if_fail (fabs (b[0] - 1.0) < 1e-14);
}
-
static inline gdouble /* Y */
filter_step_direct_canon_2 (GslIIRFilter *f,
gdouble X)
@@ -982,15 +849,12 @@ filter_step_direct_canon_2 (GslIIRFilter *f,
register guint n = f->order;
gdouble *a = f->a, *b = f->b, *w = f->w;
gdouble x, y, v;
-
v = w[n];
x = b[n] * v;
y = a[n] * v;
-
while (--n)
{
gdouble t1, t2;
-
v = w[n];
t1 = v * b[n];
t2 = v * a[n];
@@ -998,15 +862,12 @@ filter_step_direct_canon_2 (GslIIRFilter *f,
x += t1;
y += t2;
}
-
x += X;
w[1] = x;
y += x * a[0];
/* w[0] unused */
-
return y;
}
-
static inline gdouble /* Y */
filter_step_direct_canon_1 (GslIIRFilter *f,
gdouble X)
@@ -1014,27 +875,21 @@ filter_step_direct_canon_1 (GslIIRFilter *f,
register guint n = f->order;
gdouble *a = f->a, *b = f->b, *w = f->w;
gdouble y, v;
-
/* w[n] unused */
y = X * a[0] + w[0];
v = X * a[n] + y * b[n];
-
while (--n)
{
gdouble t = w[n];
-
w[n] = v;
t += X * a[n];
v = y * b[n];
v += t;
}
w[0] = v;
-
return y;
}
-
#define filter_step filter_step_direct_canon_1
-
void
gsl_iir_filter_eval (GslIIRFilter *f,
guint n_values,
@@ -1042,10 +897,8 @@ gsl_iir_filter_eval (GslIIRFilter *f,
gfloat *y)
{
const gfloat *bound;
-
g_return_if_fail (f != NULL && x != NULL && y != NULL);
g_return_if_fail (f->order > 0);
-
bound = x + n_values;
while (x < bound)
{
@@ -1054,8 +907,6 @@ gsl_iir_filter_eval (GslIIRFilter *f,
y++;
}
}
-
-
/* --- biquad filters --- */
void
gsl_biquad_config_init (GslBiquadConfig *c,
@@ -1063,14 +914,12 @@ gsl_biquad_config_init (GslBiquadConfig *c,
GslBiquadNormalize normalize)
{
g_return_if_fail (c != NULL);
-
memset (c, 0, sizeof (*c));
c->type = type;
c->normalize = normalize;
gsl_biquad_config_setup (c, 0.5, 3, 1);
c->approx_values = TRUE; /* need _setup() */
}
-
void
gsl_biquad_config_setup (GslBiquadConfig *c,
gfloat f_fn,
@@ -1079,7 +928,6 @@ gsl_biquad_config_setup (GslBiquadConfig *c,
{
g_return_if_fail (c != NULL);
g_return_if_fail (f_fn >= 0 && f_fn <= 1);
-
if (c->type == GSL_BIQUAD_RESONANT_HIGHPASS)
f_fn = 1.0 - f_fn;
c->f_fn = f_fn; /* nyquist relative (0=DC, 1=nyquist) */
@@ -1090,13 +938,11 @@ gsl_biquad_config_setup (GslBiquadConfig *c,
c->dirty = TRUE;
c->approx_values = FALSE;
}
-
void
gsl_biquad_config_approx_freq (GslBiquadConfig *c,
gfloat f_fn)
{
g_return_if_fail (f_fn >= 0 && f_fn <= 1);
-
if (c->type == GSL_BIQUAD_RESONANT_HIGHPASS)
f_fn = 1.0 - f_fn;
c->f_fn = f_fn; /* nyquist relative (0=DC, 1=nyquist) */
@@ -1104,7 +950,6 @@ gsl_biquad_config_approx_freq (GslBiquadConfig *c,
c->dirty = TRUE;
c->approx_values = TRUE;
}
-
void
gsl_biquad_config_approx_gain (GslBiquadConfig *c,
gfloat gain)
@@ -1114,18 +959,15 @@ gsl_biquad_config_approx_gain (GslBiquadConfig *c,
c->dirty = TRUE;
c->approx_values = TRUE;
}
-
static void
biquad_lpreso (GslBiquadConfig *c,
GslBiquadFilter *f)
{
gdouble kk, sqrt2_reso, denominator;
gdouble r2p_norm = 0; /* resonance gain to peak gain (pole: -sqrt2_reso+-j) */
-
kk = c->k * c->k;
sqrt2_reso = 1 / c->v;
denominator = 1 + (c->k + sqrt2_reso) * c->k;
-
switch (c->normalize)
{
case GSL_BIQUAD_NORMALIZE_PASSBAND:
@@ -1145,7 +987,6 @@ biquad_lpreso (GslBiquadConfig *c,
f->yc1 = 2 * (kk - 1) / denominator;
f->yc2 = (1 + (c->k - sqrt2_reso) * c->k) / denominator;
}
-
void
gsl_biquad_filter_config (GslBiquadFilter *f,
GslBiquadConfig *c,
@@ -1153,7 +994,6 @@ gsl_biquad_filter_config (GslBiquadFilter *f,
{
g_return_if_fail (f != NULL);
g_return_if_fail (c != NULL);
-
if (c->dirty)
{
switch (c->type)
@@ -1171,11 +1011,9 @@ gsl_biquad_filter_config (GslBiquadFilter *f,
}
c->dirty = FALSE;
}
-
if (reset_state)
f->xd1 = f->xd2 = f->yd1 = f->yd2 = 0;
}
-
void
gsl_biquad_filter_eval (GslBiquadFilter *f,
guint n_values,
@@ -1184,9 +1022,7 @@ gsl_biquad_filter_eval (GslBiquadFilter *f,
{
const gfloat *bound;
gdouble xc0, xc1, xc2, yc1, yc2, xd1, xd2, yd1, yd2;
-
g_return_if_fail (f != NULL && x != NULL && y != NULL);
-
xc0 = f->xc0;
xc1 = f->xc1;
xc2 = f->xc2;
@@ -1200,7 +1036,6 @@ gsl_biquad_filter_eval (GslBiquadFilter *f,
while (x < bound)
{
gdouble k0, k1, k2;
-
k2 = xd2 * xc2;
k1 = xd1 * xc1;
xd2 = xd1;
@@ -1217,7 +1052,6 @@ gsl_biquad_filter_eval (GslBiquadFilter *f,
f->yd1 = yd1;
f->yd2 = yd2;
}
-
#if 0
void
gsl_biquad_lphp_reso (GslBiquadFilter *c,
@@ -1230,22 +1064,17 @@ gsl_biquad_lphp_reso (GslBiquadFilter *c,
double sqrt2_reso;
double denominator;
double r2p_norm = 0; /* resonance gain to peak gain (pole: -sqrt2_reso+-j) */
-
g_return_if_fail (c != NULL);
g_return_if_fail (f_fn >= 0 && f_fn <= 1);
-
if (design_highpass)
f_fn = 1.0 - f_fn;
-
v = pow (10, gain / 20.); /* v=10^(gain[dB]/20) */
k = tan (f_fn * PI / 2.);
kk = k * k;
sqrt2_reso = 1 / v;
denominator = 1 + (k + sqrt2_reso) * k;
-
if (0)
g_printerr ("BIQUAD-lp: R=%f\n", BSE_SQRT2 * sqrt2_reso);
-
switch (normalize)
{
case GSL_BIQUAD_NORMALIZE_PASSBAND:
@@ -1265,7 +1094,6 @@ gsl_biquad_lphp_reso (GslBiquadFilter *c,
c->xc2 = c->xc0;
c->yc1 = 2 * (kk - 1) / denominator;
c->yc2 = (1 + (k - sqrt2_reso) * k) / denominator;
-
if (design_highpass)
{
c->xc1 = -c->xc1;
@@ -1284,8 +1112,6 @@ gsl_biquad_lphp_reso (GslBiquadFilter *c,
*/
}
#endif
-
-
/* --- filter scanning -- */
/**
* @param order order of the iir filter
@@ -1318,28 +1144,23 @@ gsl_filter_sine_scan (guint order,
const guint block_size = MAX (256, (guint) (mix_freq / 10));
const gdouble phase_inc = freq / mix_freq * 2 * PI;
const gdouble volume_epsilon = 1e-8;
-
gfloat x_r[block_size], x_i[block_size];
gfloat y_r[block_size], y_i[block_size];
gdouble phase = 0.0;
gdouble volume = -1, last_volume = -1;
guint blocks = 0;
-
GslIIRFilter filter_r;
GslIIRFilter filter_i;
gdouble *filter_state_r;
gdouble *filter_state_i;
-
g_return_val_if_fail (order > 0, 0.0);
g_return_val_if_fail (a != NULL, 0.0);
g_return_val_if_fail (b != NULL, 0.0);
g_return_val_if_fail (freq >= 0 && freq < (mix_freq / 2), 0.0);
-
filter_state_r = g_newa (double, (order + 1) * 4);
filter_state_i = g_newa (double, (order + 1) * 4);
gsl_iir_filter_setup (&filter_r, order, a, b, filter_state_r);
gsl_iir_filter_setup (&filter_i, order, a, b, filter_state_i);
-
/* The implementation filters two phase shifted signals; by doing so, it
* actually computes the frequency response of the filter for a complex
* signal. The advantage is that for each sample the absolute value can be
@@ -1352,7 +1173,6 @@ gsl_filter_sine_scan (guint order,
do
{
guint i;
-
for (i = 0; i < block_size; i++)
{
#if HAVE_SINCOS
@@ -1373,12 +1193,9 @@ gsl_filter_sine_scan (guint order,
phase -= 2 * M_PI;
}
}
-
gsl_iir_filter_eval (&filter_r, block_size, x_r, y_r);
gsl_iir_filter_eval (&filter_i, block_size, x_i, y_i);
-
last_volume = volume;
-
volume = 0;
for (i = 0; i < block_size; i++)
volume += bse_complex_abs (bse_complex (y_r[i], y_i[i]));
@@ -1393,9 +1210,4 @@ gsl_filter_sine_scan (guint order,
*/
return volume;
}
-
-
-
-
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/gslfilter.hh b/bse/gslfilter.hh
index c216d3c..0486aff 100644
--- a/bse/gslfilter.hh
+++ b/bse/gslfilter.hh
@@ -1,20 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_FILTER_H__
#define __GSL_FILTER_H__
-
#include <bse/bsemath.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- transformations --- */
static inline BseComplex bse_trans_s2z (BseComplex s);
static inline double bse_trans_freq2s (double w);
static inline double bse_trans_zepsilon2ss (double epsilon);
-
-
/* --- filter roots and poles --- */
void gsl_filter_butter_rp (uint iorder,
double freq, /* 0..pi */
@@ -32,8 +26,6 @@ void gsl_filter_tscheb2_rp (uint iorder,
double epsilon,
BseComplex *roots, /* [0..iorder-1] */
BseComplex *poles);
-
-
/* --- tschebyscheff type II steepness --- */
double gsl_filter_tscheb2_steepness_db (uint iorder,
double c_freq,
@@ -43,8 +35,6 @@ double gsl_filter_tscheb2_steepness (uint iorder,
double c_freq,
double epsilon,
double residue);
-
-
/* --- lowpass filters --- */
void gsl_filter_butter_lp (uint iorder,
double freq, /* 0..pi */
@@ -62,8 +52,6 @@ void gsl_filter_tscheb2_lp (uint iorder,
double epsilon,
double *a, /* [0..iorder] */
double *b);
-
-
/* --- highpass filters --- */
void gsl_filter_butter_hp (uint iorder,
double freq, /* 0..pi */
@@ -81,8 +69,6 @@ void gsl_filter_tscheb2_hp (uint iorder,
double epsilon,
double *a, /* [0..iorder] */
double *b);
-
-
/* --- bandpass filters --- */
void gsl_filter_butter_bp (uint iorder,
double freq1, /* 0..pi */
@@ -103,8 +89,6 @@ void gsl_filter_tscheb2_bp (uint iorder,
double epsilon,
double *a, /* [0..iorder] */
double *b);
-
-
/* --- bandstop filters --- */
void gsl_filter_butter_bs (uint iorder,
double freq1, /* 0..pi */
@@ -125,8 +109,6 @@ void gsl_filter_tscheb2_bs (uint iorder,
double epsilon,
double *a, /* [0..iorder] */
double *b);
-
-
/* --- FIR Filters --- */
void gsl_filter_fir_approx (uint iorder,
double *a, /* [0..iorder] */
@@ -134,8 +116,6 @@ void gsl_filter_fir_approx (uint iorder,
const double *freq,
const double *value,
gboolean interpolate_db);
-
-
/* --- IIR Filter Evaluation --- */
typedef struct {
guint order;
@@ -157,8 +137,6 @@ void gsl_iir_filter_eval (GslIIRFilter *f,
guint n_values,
const gfloat *x,
gfloat *y);
-
-
/* --- Biquad Filters --- */
typedef enum /*< skip >*/
{
@@ -166,7 +144,6 @@ typedef enum /*< skip >*/
GSL_BIQUAD_NORMALIZE_RESONANCE_GAIN,
GSL_BIQUAD_NORMALIZE_PEAK_GAIN
} GslBiquadNormalize;
-
typedef enum /*< skip >*/
{
GSL_BIQUAD_RESONANT_LOWPASS = 1,
@@ -175,7 +152,6 @@ typedef enum /*< skip >*/
GSL_BIQUAD_HIGHSHELVE,
GSL_BIQUAD_PEAK
} GslBiquadType;
-
typedef struct {
GslBiquadType type;
GslBiquadNormalize normalize; /* high/low pass */
@@ -187,13 +163,11 @@ typedef struct {
/*< private >*/
gdouble k, v;
} GslBiquadConfig;
-
typedef struct {
gdouble xc0, xc1, xc2;
gdouble yc1, yc2; /* yc0==1 */
gdouble xd1, xd2, yd1, yd2; /* history */
} GslBiquadFilter;
-
void gsl_biquad_config_init (GslBiquadConfig *c,
GslBiquadType type,
GslBiquadNormalize normalize);
@@ -212,16 +186,12 @@ void gsl_biquad_filter_eval (GslBiquadFilter *f,
guint n_values,
const gfloat *x,
gfloat *y);
-
-
/* --- filter scanning -- */
gdouble gsl_filter_sine_scan (guint order,
const gdouble *a,
const gdouble *b,
gdouble freq,
gdouble mix_freq);
-
-
/* --- implementations --- */
static inline BseComplex
bse_trans_s2z (BseComplex s)
@@ -255,11 +225,7 @@ bse_trans_freq2z (double w)
{
return atan (w) * 2.;
}
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_FILTER_H__ */ /* vim:set ts=8 sw=2 sts=2: */
diff --git a/bse/gslincluder.hh b/bse/gslincluder.hh
index cd0b1ee..df7ebbe 100644
--- a/bse/gslincluder.hh
+++ b/bse/gslincluder.hh
@@ -1,5 +1,4 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
#if 0
/* script, used to create this file's contents:
*/
@@ -7,7 +6,6 @@
my $first_case = 0;
my $last_case = 1024;
my $i;
-
print "#define GSL_INCLUDER_MAKE_FUNC(name,case) GSL_INCLUDER_CONCAT3 (name, __, case)\n";
print "#define GSL_INCLUDER_CONCAT3(x,y,z) x ## y ## z\n";
print "#define GSL_INCLUDER_FUNC GSL_INCLUDER_MAKE_FUNC (GSL_INCLUDER_NAME, GSL_INCLUDER_CASE)\n";
@@ -57,15 +55,12 @@
print "#undef GSL_INCLUDER_FILE\n";
}
#endif
-
-
#define GSL_INCLUDER_MAKE_FUNC(name,case) GSL_INCLUDER_CONCAT3 (name, __, case)
#define GSL_INCLUDER_CONCAT3(x,y,z) x ## y ## z
#define GSL_INCLUDER_FUNC GSL_INCLUDER_MAKE_FUNC (GSL_INCLUDER_NAME, GSL_INCLUDER_CASE)
#ifndef GSL_INCLUDER_REJECT
#define GSL_INCLUDER_REJECT(icase) 0
#endif
-
/* check range: 0 .. 1024 */
#if (GSL_INCLUDER_FIRST_CASE < 0)
#error GSL_INCLUDER_FIRST_CASE < 0 is not supported
@@ -73,7 +68,6 @@
#if (GSL_INCLUDER_LAST_CASE > 1024)
#error GSL_INCLUDER_LAST_CASE > 1024 is not supported
#endif
-
/* 0 */
#if ((0 >= GSL_INCLUDER_FIRST_CASE) && (0 <= GSL_INCLUDER_LAST_CASE) && !(GSL_INCLUDER_REJECT (0)))
#define GSL_INCLUDER_CASE 0
@@ -6224,7 +6218,6 @@
#include GSL_INCLUDER_FILE
#undef GSL_INCLUDER_CASE
#endif
-
GSL_INCLUDER_TABLE = {
#if ((0 >= GSL_INCLUDER_FIRST_CASE) && (0 <= GSL_INCLUDER_LAST_CASE))
#if (GSL_INCLUDER_REJECT (0))
@@ -13402,7 +13395,6 @@ GSL_INCLUDER_TABLE = {
#endif
#endif
};
-
#undef GSL_INCLUDER_REJECT
#undef GSL_INCLUDER_FUNC
#undef GSL_INCLUDER_CONCAT3
diff --git a/bse/gslmagic.cc b/bse/gslmagic.cc
index 5fed756..567c7f1 100644
--- a/bse/gslmagic.cc
+++ b/bse/gslmagic.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gslmagic.hh"
-
#include "gslcommon.hh"
-
#include <string.h>
#include <unistd.h>
#include <errno.h>
@@ -10,13 +8,9 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
-
-
/* --- defines --- */
#define BFILE_BSIZE (768) /* amount of buffering */
#define MAX_MAGIC_STRING (256) /* must be < BFILE_BSIZE / 2 */
-
-
/* --- typedefs & structures --- */
typedef struct _BFile BFile;
struct _BFile
@@ -28,8 +22,6 @@ struct _BFile
guint offset;
guint8 buffer[BFILE_BSIZE];
};
-
-
/* --- prototypes --- */
static GslRealMagic* magic_create (char *magic_string, const char *original);
static gboolean magic_match_file (BFile *bfile, GslRealMagic *magics);
@@ -42,8 +34,6 @@ static gboolean bfile_read (BFile *bfile,
guint n_bytes);
static void bfile_close (BFile *bfile);
static guint bfile_get_size (BFile *bfile);
-
-
/* --- functions --- */
static gint
magic_cmp (gconstpointer p1,
@@ -55,7 +45,6 @@ magic_cmp (gconstpointer p1,
/* smaller values are higher priority */
return m2->priority - m1->priority;
}
-
void
gsl_magic_list_brute_match (SfiRing *magic_list,
const gchar *file_name,
@@ -65,27 +54,22 @@ gsl_magic_list_brute_match (SfiRing *magic_list,
SfiRing **other_matches)
{
BFile bfile = { -1, };
-
g_return_if_fail (file_name != NULL);
if (ext_matches)
g_return_if_fail (*ext_matches == NULL);
if (other_matches)
g_return_if_fail (*other_matches == NULL);
-
if (!ext_matches && !other_matches)
return;
-
if (bfile_open (&bfile, file_name, skip_bytes))
{
const char *extension = strrchr (file_name, '.');
SfiRing *node;
-
/* match by extension */
if (ext_matches && extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
GslMagic *magic = (GslMagic*) node->data;
-
if (!magic->extension || strcmp (magic->extension, extension) != 0)
continue;
if (magic != skip_magic && magic_match_file (&bfile, magic->match_list))
@@ -96,7 +80,6 @@ gsl_magic_list_brute_match (SfiRing *magic_list,
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
GslMagic *magic = (GslMagic*) node->data;
-
if (extension && magic->extension && strcmp (magic->extension, extension) == 0)
continue;
if (magic != skip_magic && magic_match_file (&bfile, magic->match_list))
@@ -109,7 +92,6 @@ gsl_magic_list_brute_match (SfiRing *magic_list,
if (other_matches)
*other_matches = sfi_ring_sort (*other_matches, magic_cmp, NULL);
}
-
GslMagic*
gsl_magic_list_match_file_skip (SfiRing *magic_list,
const gchar *file_name,
@@ -117,21 +99,17 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
{
GslMagic *rmagic = NULL;
BFile bfile = { -1, };
-
g_return_val_if_fail (file_name != NULL, NULL);
-
if (bfile_open (&bfile, file_name, skip_offset))
{
const char *extension = strrchr (file_name, '.');
gint rpriority = G_MAXINT;
SfiRing *node;
-
/* we do a quick scan by extension first */
if (!rmagic && extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
GslMagic *magic = (GslMagic*) node->data;
-
if (!magic->extension
|| strcmp (magic->extension, extension) != 0
|| rpriority < magic->priority
@@ -148,7 +126,6 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
GslMagic *magic = (GslMagic*) node->data;
-
if ((magic->extension && strcmp (magic->extension, extension) == 0)
|| rpriority < magic->priority
|| (rmagic && rpriority == magic->priority))
@@ -164,7 +141,6 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
GslMagic *magic = (GslMagic*) node->data;
-
if (rpriority < magic->priority ||
(rmagic && rpriority == magic->priority))
continue;
@@ -176,17 +152,14 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
}
bfile_close (&bfile);
}
-
return rmagic;
}
-
GslMagic*
gsl_magic_list_match_file (SfiRing *magic_list,
const gchar *file_name)
{
return gsl_magic_list_match_file_skip (magic_list, file_name, 0);
}
-
GslMagic*
gsl_magic_create (gpointer data,
gint priority,
@@ -196,25 +169,19 @@ gsl_magic_create (gpointer data,
GslMagic *magic;
GslRealMagic *match_list;
gchar *magic_string;
-
g_return_val_if_fail (magic_spec != NULL, NULL);
-
magic_string = g_strdup (magic_spec);
match_list = magic_create (magic_string, magic_spec);
g_free (magic_string);
if (!match_list)
return NULL;
-
magic = g_new (GslMagic, 1);
magic->data = data;
magic->extension = g_strdup (extension);
magic->priority = priority;
magic->match_list = match_list;
-
return magic;
}
-
-
/* --- GslRealMagic creation/checking --- */
typedef enum
{
@@ -251,14 +218,12 @@ struct _GslRealMagic
};
static const gchar *magic_field_delims = " \t,";
static const gchar *magic_string_delims = " \t\n\r";
-
static gboolean
magic_parse_test (GslRealMagic *magic, const gchar *string)
{
if (!magic->read_string)
{
gchar *f = NULL;
-
if (string[0] == '<' || string[0] == '>')
{
if (magic->cmp_unsigned)
@@ -286,14 +251,12 @@ magic_parse_test (GslRealMagic *magic, const gchar *string)
magic->value.v_int32 = strtol (string, &f, string[1] == 'x' ? 16 : 8);
else
magic->value.v_int32 = strtol (string, &f, 10);
-
return *string == 0 || !f || *f == 0;
}
else
{
gchar tmp_string[MAX_MAGIC_STRING + 1];
guint n = 0;
-
if (string[0] == '<' || string[0] == '>')
{
magic->magic_check = string[0] == '<' ? MAGIC_CHECK_STRING_SMALLER : MAGIC_CHECK_STRING_GREATER;
@@ -344,16 +307,13 @@ magic_parse_test (GslRealMagic *magic, const gchar *string)
tmp_string[n] = 0;
magic->data_size = n;
magic->value.v_string = g_strdup (tmp_string);
-
return TRUE;
}
}
-
static gboolean
magic_parse_type (GslRealMagic *magic, const gchar *string)
{
gchar *f = NULL;
-
if (string[0] == 'u')
{
string += 1;
@@ -427,23 +387,18 @@ magic_parse_type (GslRealMagic *magic, const gchar *string)
}
else
magic->data_mask = 0xffffffff;
-
return *string == 0;
}
-
static gboolean
magic_parse_offset (GslRealMagic *magic, char *string)
{
gchar *f = NULL;
-
if (string[0] == '0')
magic->offset = strtol (string, &f, string[1] == 'x' ? 16 : 8);
else
magic->offset = strtol (string, &f, 10);
-
return !f || *f == 0;
}
-
static GslRealMagic*
magic_create (char *magic_string, const char *original)
{
@@ -451,11 +406,9 @@ magic_create (char *magic_string, const char *original)
if (*s) do *(s++) = 0; while (strchr (magic_field_delims, *s)); }
GslRealMagic *magics = NULL;
gchar *p = magic_string;
-
while (p && *p)
{
gchar *next_line;
-
if (*p == '#' || *p == '\n')
{
next_line = strchr (p, '\n');
@@ -467,7 +420,6 @@ magic_create (char *magic_string, const char *original)
GslRealMagic *tmp = magics;
magics = g_new0 (GslRealMagic, 1);
magics->next = tmp;
-
magic_string = p;
SKIP_CLEAN (p);
if (!magic_parse_offset (magics, magic_string))
@@ -496,15 +448,12 @@ magic_create (char *magic_string, const char *original)
}
p = next_line;
}
-
return magics;
}
-
static gboolean
magic_check_data (GslRealMagic *magic, MagicData *data)
{
gint cmp = 0;
-
switch (magic->magic_check)
{
guint l;
@@ -552,21 +501,17 @@ magic_check_data (GslRealMagic *magic, MagicData *data)
cmp = strncmp (data->v_string, magic->value.v_string, l) < 0;
break;
}
-
return cmp > 0;
}
-
static inline gboolean
magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
{
guint file_size = bfile_get_size (bfile);
-
if (magic->read_size)
data->v_uint32 = file_size;
else if (magic->read_string)
{
guint l = magic->data_size;
-
if (l < 1 || l > MAX_MAGIC_STRING)
l = MIN (MAX_MAGIC_STRING, file_size - magic->offset);
if (!bfile_read (bfile, magic->offset, data->v_string, l))
@@ -578,7 +523,6 @@ magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
if (magic->data_size == 4)
{
guint32 uint32 = 0;
-
if (!bfile_read (bfile, magic->offset, &uint32, 4))
return FALSE;
if (magic->need_swap)
@@ -589,7 +533,6 @@ magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
else if (magic->data_size == 2)
{
guint16 uint16 = 0;
-
if (!bfile_read (bfile, magic->offset, &uint16, 2))
return FALSE;
if (magic->need_swap)
@@ -602,7 +545,6 @@ magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
else if (magic->data_size == 1)
{
guint8 uint8;
-
if (!bfile_read (bfile, magic->offset, &uint8, 1))
return FALSE;
if (magic->cmp_unsigned)
@@ -613,37 +555,29 @@ magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
else
g_assert_not_reached ();
}
-
return TRUE;
}
-
static gboolean
magic_match_file (BFile *bfile, GslRealMagic *magics)
{
g_return_val_if_fail (bfile != NULL, FALSE);
g_return_val_if_fail (magics != NULL, FALSE);
-
do
{
gchar data_string[MAX_MAGIC_STRING + 1];
MagicData data;
-
if (magics->read_string)
data.v_string = data_string;
else
data.v_uint32 = 0;
-
if (!magic_read_data (bfile, magics, &data) ||
!magic_check_data (magics, &data))
return FALSE;
magics = magics->next;
}
while (magics);
-
return TRUE;
}
-
-
/* --- buffered file, optimized for magic checks --- */
static gboolean
bfile_open (BFile *bfile,
@@ -652,15 +586,12 @@ bfile_open (BFile *bfile,
{
struct stat buf = { 0, };
gint ret;
-
g_return_val_if_fail (bfile != NULL, FALSE);
g_return_val_if_fail (bfile->fd < 0, FALSE);
g_return_val_if_fail (file_name != NULL, FALSE);
-
bfile->fd = open (file_name, O_RDONLY);
if (bfile->fd < 0)
return FALSE;
-
do
ret = fstat (bfile->fd, &buf) < 0;
while (ret < 0 && errno == EINTR);
@@ -670,7 +601,6 @@ bfile_open (BFile *bfile,
return FALSE;
}
bfile->file_size = buf.st_size;
-
/* skip skip_offset bytes */
if (skip_offset)
{
@@ -688,7 +618,6 @@ bfile_open (BFile *bfile,
}
bfile->skip_offset = skip_offset;
bfile->file_size -= bfile->skip_offset;
-
/* read header */
do
ret = read (bfile->fd, bfile->header, BFILE_BSIZE);
@@ -700,10 +629,8 @@ bfile_open (BFile *bfile,
}
bfile->offset = 0;
memcpy (bfile->buffer, bfile->header, BFILE_BSIZE);
-
return TRUE;
}
-
static gboolean
bfile_read (BFile *bfile,
guint offset,
@@ -712,13 +639,10 @@ bfile_read (BFile *bfile,
{
guint end = offset + n_bytes;
gint ret;
-
g_return_val_if_fail (bfile != NULL, FALSE);
g_return_val_if_fail (n_bytes < BFILE_BSIZE / 2, FALSE);
-
if (end > bfile->file_size || bfile->fd < 0)
return FALSE;
-
if (end < BFILE_BSIZE)
{
memcpy (mem, bfile->header + offset, n_bytes);
@@ -729,7 +653,6 @@ bfile_read (BFile *bfile,
memcpy (mem, bfile->buffer + offset - bfile->offset, n_bytes);
return TRUE;
}
-
bfile->offset = offset - BFILE_BSIZE / 8;
do
ret = lseek (bfile->fd, bfile->skip_offset + bfile->offset, SEEK_SET);
@@ -752,23 +675,18 @@ bfile_read (BFile *bfile,
memcpy (mem, bfile->buffer + offset - bfile->offset, n_bytes);
return TRUE;
}
-
return FALSE;
}
-
static guint
bfile_get_size (BFile *bfile)
{
g_return_val_if_fail (bfile != NULL, 0);
-
return bfile->fd >= 0 ? bfile->file_size : 0;
}
-
static void
bfile_close (BFile *bfile)
{
g_return_if_fail (bfile != NULL);
-
if (bfile->fd >= 0)
close (bfile->fd);
bfile->fd = -1;
diff --git a/bse/gslmagic.hh b/bse/gslmagic.hh
index 6dfa6e9..025e09f 100644
--- a/bse/gslmagic.hh
+++ b/bse/gslmagic.hh
@@ -1,29 +1,20 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_MAGIC_H__
#define __GSL_MAGIC_H__
-
#include <bse/gsldefs.hh>
-
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
-
/* --- structures --- */
typedef struct _GslRealMagic GslRealMagic;
struct _GslMagic
{
gpointer data;
gchar *extension;
-
/*< private >*/
gint priority;
GslRealMagic *match_list;
};
-
-
/* match entity with:
* prefix,
* extension,
@@ -37,8 +28,6 @@ struct _GslMagic
* need pre-parse functionality, to figure name and type of a
* file's contents.
*/
-
-
/* --- prototypes --- */
GslMagic* gsl_magic_create (gpointer data,
gint priority,
@@ -55,9 +44,7 @@ void gsl_magic_list_brute_match (SfiRing *magic_list,
GslMagic *skip_magic,
SfiRing **ext_matches,
SfiRing **other_matches);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_MAGIC_H__ */
diff --git a/bse/gsloscillator-aux.cc b/bse/gsloscillator-aux.cc
index ca70152..c121e95 100644
--- a/bse/gsloscillator-aux.cc
+++ b/bse/gsloscillator-aux.cc
@@ -1,6 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
#define OSC_FLAGS (GSL_INCLUDER_CASE | OSC_INCLUDER_FLAGS)
#define ISYNC1_OSYNC0 ((OSC_FLAGS & OSC_FLAG_ISYNC) && !(OSC_FLAGS & OSC_FLAG_OSYNC))
#define ISYNC1_OSYNC1 ((OSC_FLAGS & OSC_FLAG_ISYNC) && (OSC_FLAGS & OSC_FLAG_OSYNC))
@@ -12,8 +10,6 @@
#define WITH_EMOD (OSC_FLAGS & OSC_FLAG_EXP_MOD)
#define WITH_PWM_MOD (OSC_FLAGS & OSC_FLAG_PWM_MOD)
#define PULSE_OSC (OSC_FLAGS & OSC_FLAG_PULSE_OSC)
-
-
static void
GSL_INCLUDER_FUNC (GslOscData *osc,
guint n_values,
@@ -35,17 +31,14 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
gfloat posm_strength, self_posm_strength;
gfloat *boundary = mono_out + n_values;
GslOscWave *wave = &osc->wave;
-
pos_inc = bse_dtoi (osc->last_freq_level * transpose * fine_tune * wave->freq_to_step);
sync_pos = osc->config.phase * wave->phase_to_pos;
posm_strength = pos_inc * osc->config.fm_strength;
self_posm_strength = pos_inc * osc->config.self_fm_strength;
-
/* do the mixing */
do
{
gfloat v;
-
/* handle syncs
*/
#if (ISYNC1_OSYNC0) /* input sync only */
@@ -77,7 +70,6 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
*sync_out++ = is_sync >= 2 ? 1.0 : 0.0;
}
#endif
-
/* track frequency changes
*/
#if (WITH_FREQ)
@@ -91,7 +83,6 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
{
gdouble fcpos, flpos;
const gfloat *orig_values = wave->values;
-
fcpos = cur_pos * wave->ifrac_to_float;
flpos = last_pos * wave->ifrac_to_float;
gsl_osc_table_lookup (osc->config.table, transposed_freq, wave);
@@ -116,7 +107,6 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
}
}
#endif
-
/* track pulse witdh modulation
*/
#if (WITH_PWM_MOD)
@@ -129,7 +119,6 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
}
}
#endif
-
/* output signal calculation
*/
#if (PULSE_OSC) /* pulse width modulation oscillator */
@@ -155,7 +144,6 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
}
#endif /* v = value_out done */
*mono_out++ = v;
-
/* position increment
*/
#if (WITH_OSYNC)
@@ -179,14 +167,12 @@ GSL_INCLUDER_FUNC (GslOscData *osc,
#endif
}
while (mono_out < boundary);
-
osc->last_pos = WITH_OSYNC ? last_pos : cur_pos;
osc->cur_pos = cur_pos;
osc->last_sync_level = last_sync_level;
osc->last_freq_level = last_freq_level;
osc->last_pwm_level = last_pwm_level;
}
-
#undef ISYNC1_OSYNC0
#undef ISYNC1_OSYNC1
#undef ISYNC0_OSYNC1
diff --git a/bse/gsloscillator.cc b/bse/gsloscillator.cc
index efa232e..74a76c9 100644
--- a/bse/gsloscillator.cc
+++ b/bse/gsloscillator.cc
@@ -1,11 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "gsloscillator.hh"
-
#include "bsemathsignal.hh"
-
#define SIGNAL_LEVEL_INVAL (-2.0) /* trigger level-changed checks */
-
-
/* --- functions --- */
static inline void
osc_update_pwm_offset (GslOscData *osc,
@@ -13,19 +9,15 @@ osc_update_pwm_offset (GslOscData *osc,
{
guint32 maxp_offs, minp_offs, mpos, tpos;
gfloat min, max, foffset;
-
/* figure actual pulse width (0..1) */
foffset = osc->config.pulse_width; /* 0..1 */
foffset += pulse_mod * osc->config.pulse_mod_strength;
foffset = CLAMP (foffset, 0.0, 1.0);
-
/* calculate pulse scaling range for this offset */
osc->pwm_offset = foffset * osc->wave.n_values;
osc->pwm_offset <<= osc->wave.n_frac_bits;
-
maxp_offs = (osc->wave.min_pos + osc->wave.n_values + osc->wave.max_pos) << (osc->wave.n_frac_bits - 1);
minp_offs = (osc->wave.max_pos + osc->wave.min_pos) << (osc->wave.n_frac_bits - 1);
-
mpos = maxp_offs + (osc->pwm_offset >> 1);
tpos = mpos >> osc->wave.n_frac_bits;
max = osc->wave.values[tpos];
@@ -50,8 +42,6 @@ osc_update_pwm_offset (GslOscData *osc,
else
osc->pwm_max = 1.0 / max;
}
-
-
/* --- generate processing function variants --- */
#define OSC_FLAG_INVAL (0xffffffff)
#define OSC_FLAG_ISYNC (1)
@@ -62,7 +52,6 @@ osc_update_pwm_offset (GslOscData *osc,
#define OSC_FLAG_EXP_MOD (32)
#define OSC_FLAG_PWM_MOD (64)
#define OSC_FLAG_PULSE_OSC (128)
-
/* normal oscillator variants */
#define OSC_INCLUDER_FLAGS 0
#define GSL_INCLUDER_FIRST_CASE 0
@@ -74,7 +63,6 @@ osc_update_pwm_offset (GslOscData *osc,
#define GSL_INCLUDER_FILE "gsloscillator-aux.cc"
#include "gslincluder.hh"
#undef OSC_INCLUDER_FLAGS
-
/* pulse width modulation oscillator variants */
#define OSC_INCLUDER_FLAGS OSC_FLAG_PULSE_OSC
#define GSL_INCLUDER_FIRST_CASE 0
@@ -86,8 +74,6 @@ osc_update_pwm_offset (GslOscData *osc,
#define GSL_INCLUDER_FILE "gsloscillator-aux.cc"
#include "gslincluder.hh"
#undef OSC_INCLUDER_FLAGS
-
-
/* --- functions --- */
static inline void
osc_process (GslOscData *osc,
@@ -111,15 +97,12 @@ osc_process (GslOscData *osc,
mode |= OSC_FLAG_EXP_MOD;
else if (imod)
mode |= OSC_FLAG_LINEAR_MOD;
-
if (UNLIKELY (mode != osc->last_mode))
{
guint change_mask = osc->last_mode >= OSC_FLAG_INVAL ? OSC_FLAG_INVAL : osc->last_mode ^ mode;
-
if (change_mask & OSC_FLAG_FREQ)
{
gdouble fcpos, flpos, transposed_freq;
-
fcpos = osc->cur_pos * osc->wave.ifrac_to_float;
flpos = osc->last_pos * osc->wave.ifrac_to_float;
osc->last_freq_level = osc->config.cfreq;
@@ -137,7 +120,6 @@ osc_process (GslOscData *osc,
}
osc->last_mode = mode;
}
-
/* invoke generated function variant */
if (mode & OSC_FLAG_PULSE_OSC)
osc_process_pulse_table[mode & ~OSC_FLAG_PULSE_OSC] (osc, n_values,
@@ -148,7 +130,6 @@ osc_process (GslOscData *osc,
ifreq, imod, isync, NULL,
mono_out, sync_out);
}
-
void
gsl_osc_process (GslOscData *osc,
guint n_values,
@@ -161,14 +142,12 @@ gsl_osc_process (GslOscData *osc,
g_return_if_fail (osc != NULL);
g_return_if_fail (n_values > 0);
g_return_if_fail (mono_out != NULL);
-
if (osc->last_mode & OSC_FLAG_PULSE_OSC)
osc->last_mode = OSC_FLAG_INVAL;
osc_process (osc, n_values, 0,
ifreq, imod, isync, NULL,
mono_out, sync_out);
}
-
void
gsl_osc_process_pulse (GslOscData *osc,
guint n_values,
@@ -182,14 +161,12 @@ gsl_osc_process_pulse (GslOscData *osc,
g_return_if_fail (osc != NULL);
g_return_if_fail (n_values > 0);
g_return_if_fail (mono_out != NULL);
-
if (!(osc->last_mode & OSC_FLAG_PULSE_OSC))
osc->last_mode = OSC_FLAG_INVAL;
osc_process (osc, n_values, OSC_FLAG_PULSE_OSC,
ifreq, imod, isync, ipwm,
mono_out, sync_out);
}
-
void
gsl_osc_config (GslOscData *osc,
GslOscConfig *config)
@@ -197,16 +174,13 @@ gsl_osc_config (GslOscData *osc,
g_return_if_fail (osc != NULL);
g_return_if_fail (config != NULL);
g_return_if_fail (config->table != NULL);
-
osc->config = *config;
osc->last_mode = OSC_FLAG_INVAL;
}
-
void
gsl_osc_reset (GslOscData *osc)
{
g_return_if_fail (osc != NULL);
-
osc->cur_pos = 0;
osc->last_pos = 0;
osc->last_sync_level = 0;
diff --git a/bse/gsloscillator.hh b/bse/gsloscillator.hh
index 7ee7670..45d7929 100644
--- a/bse/gsloscillator.hh
+++ b/bse/gsloscillator.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_OSCILLATOR_H__
#define __GSL_OSCILLATOR_H__
-
#include <bse/gsldefs.hh>
#include <bse/gslosctable.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- structures --- */
typedef struct
{
@@ -37,8 +33,6 @@ typedef struct
guint32 pwm_offset;
gfloat pwm_max, pwm_center;
} GslOscData;
-
-
/* --- Oscillator --- */
void gsl_osc_config (GslOscData *osc,
GslOscConfig *config);
@@ -58,12 +52,7 @@ void gsl_osc_process_pulse (GslOscData *osc,
const gfloat *ipwm,
gfloat *mono_out,
gfloat *sync_out);
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_OSCILLATOR_H__ */
diff --git a/bse/gslosctable.cc b/bse/gslosctable.cc
index 0fb5862..249771d 100644
--- a/bse/gslosctable.cc
+++ b/bse/gslosctable.cc
@@ -4,20 +4,14 @@
#include "bsemath.hh"
#include "gslfft.hh"
#include <string.h>
-
-
static SFI_MSG_TYPE_DEFINE (debug_osc, "osc", SFI_MSG_DEBUG, NULL);
#define OSC_DEBUG(...) sfi_debug (debug_osc, __VA_ARGS__)
-
#define OSC_FREQ_EPSILON (1e-3) /* range within which frequencies are "equal" */
-
/* compare mfreqs against each other, use an arbitrary sample rate
* for which OSC_FREQ_EPSILON makes sense
*/
#define CACHE_MATCH_FREQ(usr_mfreq, cache_mfreq) \
(fabs ((cache_mfreq) * 44107 - (usr_mfreq) * 44107) < OSC_FREQ_EPSILON)
-
-
/* --- structures --- */
struct OscTableEntry
{
@@ -32,8 +26,6 @@ struct OscTableEntry
guint n_values;
float values[1]; /* flexible array */
};
-
-
/* --- prototypes --- */
static gint cache_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2);
@@ -44,8 +36,6 @@ static void osc_wave_extrema_pos (guint n_values,
guint *minp_p,
guint *maxp_p);
void gsl_osc_cache_debug_dump (void);
-
-
/* --- variables --- */
static GBSearchArray *cache_entries = NULL;
static const GBSearchConfig cache_taconfig = {
@@ -58,8 +48,6 @@ static const GBSearchConfig osc_taconfig = {
osc_table_entry_locs_cmp,
0
};
-
-
/* --- functions --- */
static gint
cache_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
@@ -69,7 +57,6 @@ cache_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
const OscTableEntry *const *ep2 = (const OscTableEntry*const*) bsearch_node2;
const OscTableEntry *e1 = *ep1;
const OscTableEntry *e2 = *ep2;
-
if (e1->wave_form == e2->wave_form)
{
if (e1->filter_func == e2->filter_func)
@@ -80,7 +67,6 @@ cache_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
else
return e1->wave_form > e2->wave_form ? 1 : -1;
}
-
static gint
osc_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
@@ -89,33 +75,27 @@ osc_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
const OscTableEntry *const *ep2 = (const OscTableEntry*const*) bsearch_node2;
const OscTableEntry *e1 = *ep1;
const OscTableEntry *e2 = *ep2;
-
return G_BSEARCH_ARRAY_CMP (e1->mfreq, e2->mfreq);
}
-
static OscTableEntry*
cache_table_entry_lookup_best (GslOscWaveForm wave_form,
guint8* filter_func,
gfloat mfreq)
{
OscTableEntry key, *k = &key, **ep1 = NULL, **ep2, **ep3 = NULL;
-
key.mfreq = mfreq;
key.wave_form = wave_form;
key.filter_func = filter_func;
-
/* get exact match or a match which is one off into either direction */
ep2 = (OscTableEntry**) g_bsearch_array_lookup_sibling (cache_entries, &cache_taconfig, &k);
if (ep2)
{
uint i = g_bsearch_array_get_index (cache_entries, &cache_taconfig, ep2);
-
/* get siblings */
if (i > 0)
ep1 = (OscTableEntry**) g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i - 1);
if (i + 1 < g_bsearch_array_get_n_nodes (cache_entries))
ep3 = (OscTableEntry**) g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i + 1);
-
/* get rid of invalid matches, i.e. ones with:
* - a different wave
* - a different filter
@@ -148,7 +128,6 @@ cache_table_entry_lookup_best (GslOscWaveForm wave_form,
ep2 = NULL; /* no valid match at all */
}
}
-
/* now figure best out of valid siblings */
if (ep2)
{
@@ -159,7 +138,6 @@ cache_table_entry_lookup_best (GslOscWaveForm wave_form,
}
return ep2 ? *ep2 : NULL;
}
-
static OscTableEntry*
osc_table_entry_lookup_best (const GslOscTable *table,
gfloat mfreq,
@@ -167,13 +145,11 @@ osc_table_entry_lookup_best (const GslOscTable *table,
{
OscTableEntry key, *k = &key, **ep;
uint i;
-
/* get exact match or a match which is one off into either direction */
key.mfreq = mfreq;
ep = (OscTableEntry**) g_bsearch_array_lookup_sibling (table->entry_array, &osc_taconfig, &k);
if (UNLIKELY (!ep))
return NULL; /* ugh, bad */
-
if (mfreq > (*ep)->mfreq) /* need better filter */
{
i = g_bsearch_array_get_index (table->entry_array, &osc_taconfig, ep);
@@ -194,7 +170,6 @@ osc_table_entry_lookup_best (const GslOscTable *table,
mfreq * table->mix_freq, (*ep)->mfreq * table->mix_freq,
table, g_bsearch_array_get_index (table->entry_array, &osc_taconfig, ep),
g_bsearch_array_get_n_nodes (table->entry_array));
-
if (min_mfreq)
{
/* fetch mfreq from previous */
@@ -202,22 +177,18 @@ osc_table_entry_lookup_best (const GslOscTable *table,
if (i > 0)
{
OscTableEntry **tp = (OscTableEntry**) g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, i - 1);
-
*min_mfreq = (*tp)->mfreq;
}
else
*min_mfreq = 0;
}
-
return *ep;
}
-
static guint
wave_table_size (GslOscWaveForm wave_form,
gfloat mfreq)
{
/* have to return power of 2, and honour 8 <= size */
-
/* FIXME: decide on other table sizes
10000: 256
5000: 512
@@ -225,13 +196,10 @@ wave_table_size (GslOscWaveForm wave_form,
1250: 2048
GSL_OSC_WAVE_SAW_FALL always huge buffers to guarantee pulse width stepping granularity
*/
-
if (wave_form == GSL_OSC_WAVE_SAW_FALL)
return 8192;
-
return 2048;
}
-
static void
fft_filter (guint n_values,
gfloat *values, /* [0..n_values], n_values/2 complex values */
@@ -239,7 +207,6 @@ fft_filter (guint n_values,
double (*window) (double))
{
guint i;
-
n_values >>= 1;
scale_window /= (gdouble) n_values;
for (i = 0; i <= n_values; i++)
@@ -249,21 +216,18 @@ fft_filter (guint n_values,
values[i * 2 + 1] *= w;
}
}
-
static OscTableEntry*
cache_table_ref_entry (GslOscWaveForm wave_form,
double (*filter_func) (double),
gfloat mfreq)
{
OscTableEntry *e = cache_table_entry_lookup_best (wave_form, (guint8*) filter_func, mfreq);
-
if (e && !CACHE_MATCH_FREQ (mfreq, e->mfreq))
e = NULL;
if (!e)
{
guint size = wave_table_size (wave_form, mfreq);
gfloat *values, *fft, step, min, max;
-
/* size:
* - OscTableEntry already contains the first float values
* - we need n_values+1 adressable floats to provide values[0] == values[n_values]
@@ -276,7 +240,6 @@ cache_table_ref_entry (GslOscWaveForm wave_form,
e->ref_count = 1;
e->n_values = size;
gsl_osc_wave_fill_buffer (e->wave_form, e->n_values, values);
-
/* filter wave accordingly */
gsl_osc_wave_extrema (e->n_values, values, &min, &max);
fft = g_new (gfloat, e->n_values + 2); /* [0..n_values] for n_values/2 complex freqs */
@@ -286,13 +249,10 @@ cache_table_ref_entry (GslOscWaveForm wave_form,
gsl_power2_fftsr_scale_simple (e->n_values, fft, values);
g_free (fft);
gsl_osc_wave_normalize (e->n_values, values, (min + max) / 2, max);
-
/* provide values[0]==values[n_values] */
values[e->n_values] = values[0];
-
/* pulse min/max pos extension */
osc_wave_extrema_pos (e->n_values, values, &e->min_pos, &e->max_pos);
-
/* insert into cache */
cache_entries = g_bsearch_array_insert (cache_entries, &cache_taconfig, &e);
}
@@ -300,12 +260,10 @@ cache_table_ref_entry (GslOscWaveForm wave_form,
e->ref_count++;
return e;
}
-
static void
cache_table_unref_entry (OscTableEntry *e)
{
g_return_if_fail (e->ref_count > 0);
-
e->ref_count -= 1;
if (e->ref_count == 0)
{
@@ -314,7 +272,6 @@ cache_table_unref_entry (OscTableEntry *e)
cache_entries = g_bsearch_array_remove (cache_entries, &cache_taconfig, i);
}
}
-
GslOscTable*
gsl_osc_table_create (gfloat mix_freq,
GslOscWaveForm wave_form,
@@ -325,14 +282,11 @@ gsl_osc_table_create (gfloat mix_freq,
GslOscTable *table;
gfloat nyquist;
guint i;
-
g_return_val_if_fail (mix_freq > 0, NULL);
g_return_val_if_fail (n_freqs > 0, NULL);
g_return_val_if_fail (freqs != NULL, NULL);
-
if (!cache_entries)
cache_entries = g_bsearch_array_create (&cache_taconfig);
-
table = sfi_new_struct (GslOscTable, 1);
table->mix_freq = mix_freq;
table->wave_form = wave_form;
@@ -344,7 +298,6 @@ gsl_osc_table_create (gfloat mix_freq,
{
OscTableEntry *e;
gdouble mfreq = MIN (nyquist, freqs[i]);
-
mfreq /= table->mix_freq;
e = osc_table_entry_lookup_best (table, mfreq, NULL);
if (!e || fabs (e->mfreq * table->mix_freq - mfreq * table->mix_freq) > OSC_FREQ_EPSILON)
@@ -356,10 +309,8 @@ gsl_osc_table_create (gfloat mix_freq,
OSC_DEBUG ("not inserting existing entry (freq=%f) for freq %f (nyquist=%f)",
e->mfreq * table->mix_freq, mfreq * table->mix_freq, nyquist);
}
-
return table;
}
-
void
gsl_osc_table_lookup (const GslOscTable *table,
gfloat freq,
@@ -367,17 +318,14 @@ gsl_osc_table_lookup (const GslOscTable *table,
{
OscTableEntry *e;
gfloat mfreq, min_mfreq;
-
g_return_if_fail (table != NULL);
g_return_if_fail (wave != NULL);
-
mfreq = freq / table->mix_freq;
e = osc_table_entry_lookup_best (table, mfreq, &min_mfreq);
if (e)
{
guint32 int_one;
gfloat float_one;
-
wave->min_freq = min_mfreq * table->mix_freq;
wave->max_freq = e->mfreq * table->mix_freq;
wave->n_values = e->n_values;
@@ -401,14 +349,11 @@ gsl_osc_table_lookup (const GslOscTable *table,
memset (wave, 0, sizeof (*wave));
}
}
-
void
gsl_osc_table_free (GslOscTable *table)
{
guint n;
-
g_return_if_fail (table != NULL);
-
n = g_bsearch_array_get_n_nodes (table->entry_array);
while (n--)
{
@@ -419,13 +364,11 @@ gsl_osc_table_free (GslOscTable *table)
g_bsearch_array_free (table->entry_array, &osc_taconfig);
sfi_delete_struct (GslOscTable, table);
}
-
void
gsl_osc_cache_debug_dump (void)
{
OSC_DEBUG ("left in cache: %u", g_bsearch_array_get_n_nodes (cache_entries));
}
-
void
gsl_osc_wave_fill_buffer (GslOscWaveForm type,
guint n_values,
@@ -433,7 +376,6 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
{
const double max = n_values, hmax = max * 0.5, qmax = n_values * 0.25;
const uint half = n_values / 2, quarter = half / 2;
-
switch (type)
{
double frac, pos;
@@ -521,7 +463,6 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
break;
}
}
-
static void
osc_wave_extrema_pos (guint n_values,
const gfloat *values,
@@ -530,7 +471,6 @@ osc_wave_extrema_pos (guint n_values,
{
guint i, minp = 0, maxp = 0;
gfloat min = values[0], max = min;
-
for (i = 1; i < n_values; i++)
{
if (values[i] > max)
@@ -547,7 +487,6 @@ osc_wave_extrema_pos (guint n_values,
*minp_p = minp;
*maxp_p = maxp;
}
-
void
gsl_osc_wave_extrema (guint n_values,
const gfloat *values,
@@ -555,14 +494,11 @@ gsl_osc_wave_extrema (guint n_values,
gfloat *max_p)
{
guint minp, maxp;
-
g_return_if_fail (n_values > 0 && values != NULL && min_p != NULL && max_p != NULL);
-
osc_wave_extrema_pos (n_values, values, &minp, &maxp);
*min_p = values[minp];
*max_p = values[maxp];
}
-
void
gsl_osc_wave_adjust_range (guint n_values,
gfloat *values,
@@ -573,9 +509,7 @@ gsl_osc_wave_adjust_range (guint n_values,
{
gfloat center;
guint i;
-
g_return_if_fail (n_values > 0 && values != NULL);
-
center = (min + max) / 2;
center = new_center - center;
min = fabs (min + center);
@@ -589,7 +523,6 @@ gsl_osc_wave_adjust_range (guint n_values,
for (i = 0; i < n_values; i++)
values[i] = (values[i] + center) * max;
}
-
void
gsl_osc_wave_normalize (guint n_values,
gfloat *values,
@@ -598,22 +531,17 @@ gsl_osc_wave_normalize (guint n_values,
{
gfloat min, max;
guint i;
-
g_return_if_fail (n_values > 0 && values != NULL);
-
min = values[0];
max = min;
for (i = 1; i < n_values; i++)
{
register gfloat v = values[i];
-
max = MAX (max, v);
min = MIN (min, v);
}
-
gsl_osc_wave_adjust_range (n_values, values, min, max, new_center, new_max);
}
-
const gchar*
gsl_osc_wave_form_name (GslOscWaveForm wave_form)
{
diff --git a/bse/gslosctable.hh b/bse/gslosctable.hh
index 86d5b78..d1797b2 100644
--- a/bse/gslosctable.hh
+++ b/bse/gslosctable.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_OSC_TABLE_H__
#define __GSL_OSC_TABLE_H__
-
#include <bse/gsldefs.hh>
#include <sfi/gbsearcharray.hh>
-
G_BEGIN_DECLS
-
-
/* --- structures & enums --- */
typedef enum /*< skip >*/
{
@@ -22,14 +18,12 @@ typedef enum /*< skip >*/
GSL_OSC_WAVE_SQUARE,
GSL_OSC_WAVE_PULSE_SAW
} GslOscWaveForm;
-
typedef struct
{
gfloat mix_freq;
GslOscWaveForm wave_form;
GBSearchArray *entry_array;
} GslOscTable;
-
typedef struct
{
gfloat min_freq;
@@ -44,8 +38,6 @@ typedef struct
gfloat ifrac_to_float; /* frac -> 0..1 float */
guint min_pos, max_pos; /* pulse extension */
} GslOscWave;
-
-
/* --- oscillator table --- */
GslOscTable* gsl_osc_table_create (gfloat mix_freq,
GslOscWaveForm wave_form,
@@ -56,8 +48,6 @@ void gsl_osc_table_lookup (const GslOscTable *table,
gfloat freq,
GslOscWave *wave);
void gsl_osc_table_free (GslOscTable *table);
-
-
/* --- oscillator wave utils --- */
void gsl_osc_wave_fill_buffer (GslOscWaveForm type,
guint n_values,
@@ -77,8 +67,5 @@ void gsl_osc_wave_adjust_range (guint n_values,
gfloat new_center,
gfloat new_max);
const gchar* gsl_osc_wave_form_name (GslOscWaveForm wave_form);
-
-
G_END_DECLS
-
#endif /* __GSL_OSC_TABLE_H__ */
diff --git a/bse/gslvorbis-cutter.cc b/bse/gslvorbis-cutter.cc
index ef24522..b8e6dbd 100644
--- a/bse/gslvorbis-cutter.cc
+++ b/bse/gslvorbis-cutter.cc
@@ -4,12 +4,9 @@
#include <vorbis/codec.h>
#include <string.h>
#include <errno.h>
-
static SFI_MSG_TYPE_DEFINE (debug_vorbis, "vorbis", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_vorbis, __VA_ARGS__)
#define DIAG(...) sfi_diag (__VA_ARGS__)
-
-
/* --- structures --- */
typedef struct {
guint length;
@@ -42,8 +39,6 @@ struct _GslVorbisCutter
vorbis_comment vcomment;
vorbis_dsp_state vdsp;
};
-
-
/* --- miscellaneous --- */
static const gchar*
ov_error_blurb (gint ov_error)
@@ -67,7 +62,6 @@ ov_error_blurb (gint ov_error)
default: return "Unknown failure";
}
}
-
static void
enqueue_page (SfiRing **dblocks,
ogg_page *opage)
@@ -81,8 +75,6 @@ enqueue_page (SfiRing **dblocks,
memcpy (dblock->data, opage->body, dblock->length);
*dblocks = sfi_ring_append (*dblocks, dblock);
}
-
-
/* --- cutter API --- */
GslVorbisCutter*
gsl_vorbis_cutter_new (void)
@@ -104,18 +96,15 @@ gsl_vorbis_cutter_new (void)
vorbis_comment_init (&self->vcomment);
return self;
}
-
void
gsl_vorbis_cutter_set_cutpoint (GslVorbisCutter *self,
GslVorbisCutterMode cutmode,
SfiNum cutpoint)
{
g_return_if_fail (self != NULL);
-
/* cutpoint is interpreted as last_sample + 1,
* i.e. sample[cutpoint] is removed for SAMPLE_BOUNDARY
*/
-
switch (cutpoint > 0 ? cutmode : 0)
{
case GSL_VORBIS_CUTTER_SAMPLE_BOUNDARY:
@@ -130,36 +119,28 @@ gsl_vorbis_cutter_set_cutpoint (GslVorbisCutter *self,
break;
}
}
-
void
gsl_vorbis_cutter_filter_serialno (GslVorbisCutter *self,
guint serialno)
{
g_return_if_fail (self != NULL);
-
/* only read an input Ogg/Vorbis stream with serial number "serialno" */
-
self->filtered_serialno = serialno;
self->filter_serialno = TRUE;
}
-
void
gsl_vorbis_cutter_force_serialno (GslVorbisCutter *self,
guint serialno)
{
g_return_if_fail (self != NULL);
-
/* change the Ogg/Vorbis stream serial number on output to "serialno" */
-
self->forced_serialno = serialno;
self->force_serialno = TRUE;
}
-
void
gsl_vorbis_cutter_destroy (GslVorbisCutter *self)
{
g_return_if_fail (self != NULL);
-
/* cleanup codec state */
if (self->vorbis_initialized)
vorbis_dsp_clear (&self->vdsp);
@@ -175,7 +156,6 @@ gsl_vorbis_cutter_destroy (GslVorbisCutter *self)
/* cleanup self */
g_free (self);
}
-
static void
vorbis_cutter_abort (GslVorbisCutter *self)
{
@@ -184,24 +164,19 @@ vorbis_cutter_abort (GslVorbisCutter *self)
g_free (sfi_ring_pop_head (&self->dblocks));
self->eos = TRUE;
}
-
gboolean
gsl_vorbis_cutter_ogg_eos (GslVorbisCutter *self)
{
g_return_val_if_fail (self != NULL, FALSE);
-
return self->eos && !self->dblocks;
}
-
guint
gsl_vorbis_cutter_read_ogg (GslVorbisCutter *self,
guint n_bytes,
guint8 *bytes)
{
guint8 *ubytes = bytes;
-
g_return_val_if_fail (self != NULL, 0);
-
while (n_bytes && self->dblocks)
{
CDataBlock *dblock = (CDataBlock*) self->dblocks->data;
@@ -218,7 +193,6 @@ gsl_vorbis_cutter_read_ogg (GslVorbisCutter *self,
}
return bytes - ubytes;
}
-
static void
vorbis_cutter_process_paket (GslVorbisCutter *self,
ogg_packet *opacket)
@@ -352,7 +326,6 @@ vorbis_cutter_process_paket (GslVorbisCutter *self,
self->eos = opacket->e_o_s > 0;
}
}
-
void
gsl_vorbis_cutter_write_ogg (GslVorbisCutter *self,
guint n_bytes,
@@ -363,7 +336,6 @@ gsl_vorbis_cutter_write_ogg (GslVorbisCutter *self,
g_return_if_fail (bytes != NULL);
else
return;
-
if (!self->eos)
{
ogg_page opage;
diff --git a/bse/gslvorbis-cutter.hh b/bse/gslvorbis-cutter.hh
index f97f797..3911946 100644
--- a/bse/gslvorbis-cutter.hh
+++ b/bse/gslvorbis-cutter.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_VORBIS_CUTTER_H__
#define __GSL_VORBIS_CUTTER_H__
-
#include <bse/gslcommon.hh>
-
G_BEGIN_DECLS
-
/* --- typedefs & enums --- */
typedef struct _GslVorbisCutter GslVorbisCutter;
typedef enum
@@ -15,7 +12,6 @@ typedef enum
GSL_VORBIS_CUTTER_PACKET_BOUNDARY = 2,
GSL_VORBIS_CUTTER_PAGE_BOUNDARY = 3
} GslVorbisCutterMode;
-
/* --- cutter API --- */
GslVorbisCutter* gsl_vorbis_cutter_new (void);
void gsl_vorbis_cutter_set_cutpoint (GslVorbisCutter *self,
@@ -33,7 +29,5 @@ guint gsl_vorbis_cutter_read_ogg (GslVorbisCutter
guint8 *bytes);
gboolean gsl_vorbis_cutter_ogg_eos (GslVorbisCutter *self);
void gsl_vorbis_cutter_destroy (GslVorbisCutter *self);
-
G_END_DECLS
-
#endif /* __GSL_VORBIS_CUTTER_H__ */
diff --git a/bse/gslvorbis-enc.cc b/bse/gslvorbis-enc.cc
index 4ceddb7..d9e5293 100644
--- a/bse/gslvorbis-enc.cc
+++ b/bse/gslvorbis-enc.cc
@@ -6,10 +6,8 @@
#include <vorbis/vorbisenc.h>
#include <string.h>
#include <errno.h>
-
static SFI_MSG_TYPE_DEFINE (debug_vorbisenc, "vorbisenc", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_vorbisenc, __VA_ARGS__)
-
/* --- structures --- */
typedef struct {
guint length;
@@ -39,12 +37,8 @@ struct _GslVorbisEncoder
/* comment part of stream config */
vorbis_comment vcomment;
};
-
-
/* --- prototypes --- */
static void gsl_vorbis_encoder_reset (GslVorbisEncoder *self);
-
-
/* --- miscellaneous --- */
static void
gsl_vorbis_encoder_enqueue_page (GslVorbisEncoder *self,
@@ -59,40 +53,30 @@ gsl_vorbis_encoder_enqueue_page (GslVorbisEncoder *self,
memcpy (dblock->data, opage->body, dblock->length);
self->dblocks = sfi_ring_append (self->dblocks, dblock);
}
-
-
/* --- encoder API --- */
GslVorbisEncoder*
gsl_vorbis_encoder_new (void)
{
GslVorbisEncoder *self;
-
self = g_new0 (GslVorbisEncoder, 1);
self->stream_setup = FALSE;
-
vorbis_comment_init (&self->vcomment);
-
/* defaults */
gsl_vorbis_encoder_set_quality (self, 3.0);
gsl_vorbis_encoder_set_n_channels (self, 2);
gsl_vorbis_encoder_set_sample_freq (self, 44100);
-
/* init portions */
gsl_vorbis_encoder_reset (self);
-
return self;
}
-
void
gsl_vorbis_encoder_destroy (GslVorbisEncoder *self)
{
g_return_if_fail (self != NULL);
-
gsl_vorbis_encoder_reset (self);
vorbis_comment_clear (&self->vcomment);
g_free (self);
}
-
void
gsl_vorbis_encoder_add_comment (GslVorbisEncoder *self,
const gchar *comment)
@@ -100,10 +84,8 @@ gsl_vorbis_encoder_add_comment (GslVorbisEncoder *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (comment != NULL);
-
vorbis_comment_add (&self->vcomment, comment);
}
-
void
gsl_vorbis_encoder_add_named_comment (GslVorbisEncoder *self,
const gchar *tag_name,
@@ -113,10 +95,8 @@ gsl_vorbis_encoder_add_named_comment (GslVorbisEncoder *self,
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (tag_name != NULL);
g_return_if_fail (comment != NULL);
-
vorbis_comment_add_tag (&self->vcomment, tag_name, comment);
}
-
static char*
convert_latin1_to_utf8 (const char *string)
{
@@ -137,50 +117,41 @@ convert_latin1_to_utf8 (const char *string)
}
return NULL;
}
-
void
gsl_vorbis_encoder_add_lcomment (GslVorbisEncoder *self,
const gchar *comment)
{
gchar *utf8_comment;
-
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (comment != NULL);
-
utf8_comment = convert_latin1_to_utf8 (comment);
vorbis_comment_add (&self->vcomment, utf8_comment);
g_free (utf8_comment);
}
-
void
gsl_vorbis_encoder_add_named_lcomment (GslVorbisEncoder *self,
const gchar *tag_name,
const gchar *comment)
{
gchar *utf8_comment;
-
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (tag_name != NULL);
g_return_if_fail (comment != NULL);
-
utf8_comment = convert_latin1_to_utf8 (comment);
vorbis_comment_add_tag (&self->vcomment, tag_name, utf8_comment);
g_free (utf8_comment);
}
-
void
gsl_vorbis_encoder_set_quality (GslVorbisEncoder *self,
gfloat quality)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
-
self->vbr_quality = CLAMP (quality, -1.0, 10.0) * 0.1;
self->vbr_nominal = -1;
}
-
void
gsl_vorbis_encoder_set_bitrate (GslVorbisEncoder *self,
guint nominal)
@@ -188,11 +159,9 @@ gsl_vorbis_encoder_set_bitrate (GslVorbisEncoder *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (nominal >= 32 && nominal <= 1048576);
-
self->vbr_quality = -1;
self->vbr_nominal = nominal;
}
-
void
gsl_vorbis_encoder_set_n_channels (GslVorbisEncoder *self,
guint n_channels)
@@ -200,10 +169,8 @@ gsl_vorbis_encoder_set_n_channels (GslVorbisEncoder *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (n_channels >= 1 && n_channels <= 2);
-
self->n_channels = n_channels;
}
-
void
gsl_vorbis_encoder_set_sample_freq (GslVorbisEncoder *self,
guint sample_freq)
@@ -211,15 +178,12 @@ gsl_vorbis_encoder_set_sample_freq (GslVorbisEncoder *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (sample_freq >= 8000 && sample_freq <= 96000);
-
self->sample_freq = sample_freq;
}
-
static void
gsl_vorbis_encoder_reset (GslVorbisEncoder *self)
{
g_return_if_fail (self != NULL);
-
/* cleanup codec state */
if (self->stream_setup)
{
@@ -241,7 +205,6 @@ gsl_vorbis_encoder_reset (GslVorbisEncoder *self)
self->eos = FALSE;
self->have_vblock = FALSE;
}
-
BseErrorType
gsl_vorbis_encoder_setup_stream (GslVorbisEncoder *self,
guint serial)
@@ -249,10 +212,8 @@ gsl_vorbis_encoder_setup_stream (GslVorbisEncoder *self,
ogg_packet opacket1, opacket2, opacket3;
ogg_page opage;
gint result;
-
g_return_val_if_fail (self != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (self->stream_setup == FALSE, BSE_ERROR_INTERNAL);
-
self->serial = serial;
vorbis_info_init (&self->vinfo);
DEBUG ("init: channels=%u mixfreq=%u quality=%f bitrate=%d\n",
@@ -276,12 +237,10 @@ gsl_vorbis_encoder_setup_stream (GslVorbisEncoder *self,
vorbis_info_clear (&self->vinfo);
return BSE_ERROR_CODEC_FAILURE;
}
-
self->stream_setup = TRUE;
vorbis_analysis_init (&self->vdsp, &self->vinfo);
vorbis_block_init (&self->vdsp, &self->vblock);
ogg_stream_init (&self->ostream, self->serial);
-
/* flush pages with header packets (initial, comments, codebooks) */
vorbis_analysis_headerout (&self->vdsp, &self->vcomment, &opacket1, &opacket2, &opacket3);
ogg_stream_packetin (&self->ostream, &opacket1);
@@ -289,25 +248,20 @@ gsl_vorbis_encoder_setup_stream (GslVorbisEncoder *self,
ogg_stream_packetin (&self->ostream, &opacket3);
while (ogg_stream_flush (&self->ostream, &opage))
gsl_vorbis_encoder_enqueue_page (self, &opage);
-
return BSE_ERROR_NONE;
}
-
static void
vorbis_encoder_write_pcm_1k (GslVorbisEncoder *self,
guint n_values,
gfloat *values)
{
gfloat **dest;
-
/* the vorbis encoding engine has a bug that produces junk at
* certain block sizes beyond 1024
*/
g_assert (n_values <= 1024);
-
/* people passing in non-channel-aligned data get what they deserve */
n_values /= self->n_channels;
-
/* allocate required space */
dest = vorbis_analysis_buffer (&self->vdsp, n_values);
/* uninterleave incoming data */
@@ -326,7 +280,6 @@ vorbis_encoder_write_pcm_1k (GslVorbisEncoder *self,
/* let the analysis engine know how much data arrived */
vorbis_analysis_wrote (&self->vdsp, n_values);
}
-
void
gsl_vorbis_encoder_write_pcm (GslVorbisEncoder *self,
guint n_values,
@@ -338,11 +291,9 @@ gsl_vorbis_encoder_write_pcm (GslVorbisEncoder *self,
g_return_if_fail (self->n_channels * (n_values / self->n_channels) == n_values); /* check alignment */
if (n_values)
g_return_if_fail (values != NULL);
-
/* compress away remaining data so we only buffer encoded data */
while (gsl_vorbis_encoder_needs_processing (self))
gsl_vorbis_encoder_process (self);
-
/* feed analysis engine with unencoded data */
while (n_values)
{
@@ -352,20 +303,17 @@ gsl_vorbis_encoder_write_pcm (GslVorbisEncoder *self,
n_values -= l;
}
}
-
void
gsl_vorbis_encoder_pcm_done (GslVorbisEncoder *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == TRUE);
-
if (!self->pcm_done)
{
self->pcm_done = TRUE;
vorbis_analysis_wrote (&self->vdsp, 0); /* termination mark */
}
}
-
static gboolean
gsl_vorbis_encoder_blockout (GslVorbisEncoder *self)
{
@@ -373,21 +321,17 @@ gsl_vorbis_encoder_blockout (GslVorbisEncoder *self)
self->have_vblock = vorbis_analysis_blockout (&self->vdsp, &self->vblock) > 0;
return self->have_vblock;
}
-
gboolean
gsl_vorbis_encoder_needs_processing (GslVorbisEncoder *self)
{
g_return_val_if_fail (self != NULL, FALSE);
-
return self->stream_setup && !self->eos && gsl_vorbis_encoder_blockout (self);
}
-
void
gsl_vorbis_encoder_process (GslVorbisEncoder *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == TRUE);
-
/* analyse data blockwise */
if (gsl_vorbis_encoder_blockout (self))
{
@@ -416,17 +360,14 @@ gsl_vorbis_encoder_process (GslVorbisEncoder *self)
}
}
}
-
guint
gsl_vorbis_encoder_read_ogg (GslVorbisEncoder *self,
guint n_bytes,
guint8 *bytes)
{
guint8 *ubytes = bytes;
-
g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (self->stream_setup == TRUE, 0);
-
if (!self->dblocks)
gsl_vorbis_encoder_process (self);
while (n_bytes && self->dblocks)
@@ -445,16 +386,13 @@ gsl_vorbis_encoder_read_ogg (GslVorbisEncoder *self,
}
return bytes - ubytes;
}
-
gboolean
gsl_vorbis_encoder_ogg_eos (GslVorbisEncoder *self)
{
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (self->stream_setup == TRUE, FALSE);
-
return self->eos && !self->dblocks;
}
-
gchar*
gsl_vorbis_encoder_version (void)
{
diff --git a/bse/gslvorbis-enc.hh b/bse/gslvorbis-enc.hh
index 1e2e262..31cf2c0 100644
--- a/bse/gslvorbis-enc.hh
+++ b/bse/gslvorbis-enc.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_VORBIS_ENC_H__
#define __GSL_VORBIS_ENC_H__
-
#include <bse/gslcommon.hh>
-
G_BEGIN_DECLS
-
/* --- typedefs & enums --- */
typedef struct _GslVorbisEncoder GslVorbisEncoder;
/* rough quality to bitrate mappings at 44.1kHz mono:
@@ -14,7 +11,6 @@ typedef struct _GslVorbisEncoder GslVorbisEncoder;
* 1) 60kBit 4) 86kBit 7) 120kBit 10) 240kBit
* oggenc defaults to a quality setting of 3.0
*/
-
/* --- encoder API --- */
GslVorbisEncoder* gsl_vorbis_encoder_new (void);
/* pre encoding */
@@ -56,11 +52,7 @@ guint gsl_vorbis_encoder_read_ogg (GslVorbisEncoder
gboolean gsl_vorbis_encoder_ogg_eos (GslVorbisEncoder *self);
/* cleanup */
void gsl_vorbis_encoder_destroy (GslVorbisEncoder *self);
-
/* retrive vendor version string */
gchar* gsl_vorbis_encoder_version (void);
-
-
G_END_DECLS
-
#endif /* __GSL_VORBIS_ENC_H__ */
diff --git a/bse/gslwavechunk.cc b/bse/gslwavechunk.cc
index 30b34d9..b22b7a9 100644
--- a/bse/gslwavechunk.cc
+++ b/bse/gslwavechunk.cc
@@ -5,13 +5,10 @@
#include "gsldatahandle.hh"
#include "bsemathsignal.hh"
#include <string.h>
-
-
/* --- macros --- */
#define PRINT_DEBUG_INFO (0)
#define STATIC_ZERO_SIZE (4096)
#define PBLOCK_SIZE(pad, n_channels) (MAX (2 * (pad), (n_channels) * BSE_CONFIG (wave_chunk_big_pad)))
-
#define PHASE_NORM(wchunk) ((GslWaveChunkMem*) (0))
#define PHASE_NORM_BACKWARD(wchunk) ((GslWaveChunkMem*) (+1))
#define PHASE_UNDEF(wchunk) ((GslWaveChunkMem*) (+2))
@@ -21,8 +18,6 @@
#define PHASE_PPWRAP(wchunk) (&(wchunk)->ppwrap)
#define PHASE_LEAVE(wchunk) (&(wchunk)->leave)
#define PHASE_TAIL(wchunk) (&(wchunk)->tail)
-
-
/* --- typedefs & structures --- */
typedef struct {
GslLong pos; /* input */
@@ -35,12 +30,8 @@ typedef struct {
GslLong pos;
GslLong loop_count;
} WPos;
-
-
/* --- variables --- */
static gfloat static_zero_block[STATIC_ZERO_SIZE] = { 0, }; // FIXME
-
-
/* --- functions --- */
static inline void
wpos_step (GslWaveChunk *wchunk,
@@ -75,7 +66,6 @@ wpos_step (GslWaveChunk *wchunk,
}
}
}
-
static void
fill_block (GslWaveChunk *wchunk,
gfloat *block,
@@ -88,7 +78,6 @@ fill_block (GslWaveChunk *wchunk,
guint i, dnode_length = wchunk->dcache->node_size;
GslDataCacheNode *dnode;
WPos wpos;
-
wpos.one = wchunk->n_channels;
wpos.dir = 1; // wchunk->n_channels;
if (backward)
@@ -99,7 +88,6 @@ fill_block (GslWaveChunk *wchunk,
for (i = 0; i < length; i++)
{
GslLong offset = wpos.pos;
-
if (offset < 0 || offset >= dcache_length)
block[i] = 0;
else
@@ -115,7 +103,6 @@ fill_block (GslWaveChunk *wchunk,
}
gsl_data_cache_unref_node (wchunk->dcache, dnode);
}
-
static gfloat*
create_block_for_offset (GslWaveChunk *wchunk,
GslLong offset,
@@ -127,10 +114,8 @@ create_block_for_offset (GslWaveChunk *wchunk,
GslLong loop_width = wchunk->loop_last - wchunk->loop_first;
gfloat *mem;
GslLong l, j, k;
-
if (wchunk->loop_type != GSL_WAVE_LOOP_PINGPONG)
loop_width += one;
-
l = length + 2 * padding;
mem = sfi_new_struct (gfloat, l);
offset -= padding;
@@ -161,7 +146,6 @@ create_block_for_offset (GslWaveChunk *wchunk,
fill_block (wchunk, mem, wchunk->loop_last - j, l, FALSE, 0);
return mem + padding;
}
-
static void
setup_pblocks (GslWaveChunk *wchunk)
{
@@ -172,11 +156,9 @@ setup_pblocks (GslWaveChunk *wchunk)
GslLong loop_duration, wave_last = wchunk->length - one;
gfloat *mem;
guint l;
-
if (wchunk->loop_type != GSL_WAVE_LOOP_PINGPONG)
loop_width += one;
loop_duration = loop_width * wchunk->loop_count;
-
wchunk->head.first = -padding;
wchunk->head.last = big_pad;
wchunk->head.length = wchunk->head.last - wchunk->head.first + one;
@@ -236,7 +218,6 @@ setup_pblocks (GslWaveChunk *wchunk)
wchunk->leave_end_norm = 0;
wchunk->leave.length = 0;
}
-
l = wchunk->head.length + 2 * padding;
mem = sfi_new_struct (gfloat, l);
fill_block (wchunk, mem, wchunk->head.first - padding, l, FALSE, wchunk->loop_count);
@@ -263,14 +244,12 @@ setup_pblocks (GslWaveChunk *wchunk)
}
wchunk->tail.mem = create_block_for_offset (wchunk, wchunk->tail.first, wchunk->tail.length);
}
-
static inline GslWaveChunkMem*
wave_identify_offset (GslWaveChunk *wchunk,
Iter *iter)
{
GslLong pos = iter->pos;
GslLong one = wchunk->n_channels;
-
if (UNLIKELY (pos < wchunk->head.first)) /* outside wave boundaries */
{
iter->lbound = 0;
@@ -349,7 +328,6 @@ wave_identify_offset (GslWaveChunk *wchunk,
else if (wchunk->loop_type == GSL_WAVE_LOOP_PINGPONG) /* in ping-pong loop */
{
guint loop_width = wchunk->loop_last - wchunk->loop_first;
-
pos -= wchunk->loop_last + one;
pos %= 2 * loop_width;
if (pos <= wchunk->ppwrap.last)
@@ -392,7 +370,6 @@ wave_identify_offset (GslWaveChunk *wchunk,
else if (wchunk->loop_type == GSL_WAVE_LOOP_JUMP) /* in jump loop */
{
guint loop_width = wchunk->loop_last - wchunk->loop_first + one;
-
pos -= wchunk->loop_last + one;
pos %= loop_width;
if (pos >= wchunk->wrap.first)
@@ -423,7 +400,6 @@ wave_identify_offset (GslWaveChunk *wchunk,
g_print ("PHASE_NORM, noloop %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
return PHASE_NORM (wchunk);
}
-
void
gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
GslWaveChunkBlock *block)
@@ -432,28 +408,23 @@ gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
GslLong one;
Iter iter = { 0, };
gboolean reverse;
-
g_return_if_fail (wchunk != NULL);
g_return_if_fail (wchunk->open_count > 0);
g_return_if_fail (block != NULL);
g_return_if_fail (wchunk->dcache != NULL);
g_return_if_fail (block->node == NULL);
g_return_if_fail (block->play_dir == -1 || block->play_dir == +1);
-
block->offset /= wchunk->n_channels;
block->offset *= wchunk->n_channels;
-
one = wchunk->n_channels;
reverse = block->play_dir < 0;
iter.pos = block->offset;
phase = wave_identify_offset (wchunk, &iter);
-
block->is_silent = FALSE;
if (phase <= PHASE_UNDEF (wchunk))
{
GslDataCacheNode *dnode;
guint offset;
-
if (phase == PHASE_UNDEF (wchunk))
{
block->is_silent = TRUE;
@@ -466,7 +437,6 @@ gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
else
{
GslLong max_length;
-
if (phase == PHASE_NORM_BACKWARD (wchunk))
{
offset = iter.ubound - iter.rel_pos;
@@ -516,7 +486,6 @@ gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
*/
block->next_offset = block->offset + (block->play_dir > 0 ? block->length : -block->length);
}
-
void
gsl_wave_chunk_unuse_block (GslWaveChunk *wchunk,
GslWaveChunkBlock *block)
@@ -524,14 +493,12 @@ gsl_wave_chunk_unuse_block (GslWaveChunk *wchunk,
g_return_if_fail (wchunk != NULL);
g_return_if_fail (block != NULL);
g_return_if_fail (wchunk->dcache != NULL);
-
if (block->node)
{
gsl_data_cache_unref_node (wchunk->dcache, (GslDataCacheNode*) block->node);
block->node = NULL;
}
}
-
static void
wave_chunk_setup_loop (GslWaveChunk *wchunk)
{
@@ -540,17 +507,13 @@ wave_chunk_setup_loop (GslWaveChunk *wchunk)
GslLong loop_last = wchunk->requested_loop_last;
guint loop_count = wchunk->requested_loop_count;
GslLong one, padding, big_pad;
-
g_return_if_fail (wchunk->open_count > 0);
-
one = wchunk->n_channels;
padding = wchunk->n_pad_values;
big_pad = PBLOCK_SIZE (wchunk->n_pad_values, wchunk->n_channels);
-
/* check validity */
if (loop_count < 1 || loop_first < 0 || loop_last < 0 || wchunk->length < 1)
loop_type = GSL_WAVE_LOOP_NONE;
-
/* setup loop types */
switch (loop_type)
{
@@ -597,7 +560,6 @@ wave_chunk_setup_loop (GslWaveChunk *wchunk)
wchunk->pploop_ends_backwards = wchunk->loop_type == GSL_WAVE_LOOP_PINGPONG && (wchunk->loop_count & 1);
wchunk->mini_loop = wchunk->loop_type && wchunk->loop_last - wchunk->loop_first < 2 * big_pad + padding;
}
-
GslWaveChunk*
gsl_wave_chunk_new (GslDataCache *dcache,
gfloat mix_freq,
@@ -608,11 +570,9 @@ gsl_wave_chunk_new (GslDataCache *dcache,
guint loop_count)
{
GslWaveChunk *wchunk;
-
g_return_val_if_fail (dcache != NULL, NULL);
g_return_val_if_fail (osc_freq < mix_freq / 2, NULL);
g_return_val_if_fail (loop_type >= GSL_WAVE_LOOP_NONE && loop_type <= GSL_WAVE_LOOP_PINGPONG, NULL);
-
wchunk = sfi_new_struct0 (GslWaveChunk, 1);
wchunk->dcache = gsl_data_cache_ref (dcache);
wchunk->length = 0;
@@ -632,26 +592,21 @@ gsl_wave_chunk_new (GslDataCache *dcache,
wchunk->requested_loop_first = loop_first;
wchunk->requested_loop_last = loop_last;
wchunk->requested_loop_count = loop_count;
-
return wchunk;
}
-
GslWaveChunk*
gsl_wave_chunk_ref (GslWaveChunk *wchunk)
{
g_return_val_if_fail (wchunk != NULL, NULL);
g_return_val_if_fail (wchunk->ref_count > 0, NULL);
-
wchunk->ref_count++;
return wchunk;
}
-
void
gsl_wave_chunk_unref (GslWaveChunk *wchunk)
{
g_return_if_fail (wchunk != NULL);
g_return_if_fail (wchunk->ref_count > 0);
-
wchunk->ref_count--;
if (wchunk->ref_count == 0)
{
@@ -660,17 +615,14 @@ gsl_wave_chunk_unref (GslWaveChunk *wchunk)
sfi_delete_struct (GslWaveChunk, wchunk);
}
}
-
BseErrorType
gsl_wave_chunk_open (GslWaveChunk *wchunk)
{
g_return_val_if_fail (wchunk != NULL, BSE_ERROR_INTERNAL);
g_return_val_if_fail (wchunk->ref_count > 0, BSE_ERROR_INTERNAL);
-
if (wchunk->open_count == 0)
{
BseErrorType error;
-
error = gsl_data_handle_open (wchunk->dcache->dhandle);
if (error != BSE_ERROR_NONE)
return error;
@@ -699,20 +651,16 @@ gsl_wave_chunk_open (GslWaveChunk *wchunk)
wchunk->open_count++;
return BSE_ERROR_NONE;
}
-
void
gsl_wave_chunk_close (GslWaveChunk *wchunk)
{
GslLong padding;
-
g_return_if_fail (wchunk != NULL);
g_return_if_fail (wchunk->open_count > 0);
g_return_if_fail (wchunk->ref_count > 0);
-
wchunk->open_count--;
if (wchunk->open_count)
return;
-
padding = wchunk->n_pad_values;
gsl_data_cache_close (wchunk->dcache);
if (wchunk->head.mem)
@@ -744,7 +692,6 @@ gsl_wave_chunk_close (GslWaveChunk *wchunk)
wchunk->fine_tune_factor = 0.0;
gsl_wave_chunk_unref (wchunk);
}
-
void
gsl_wave_chunk_debug_block (GslWaveChunk *wchunk,
GslLong offset,
@@ -752,16 +699,13 @@ gsl_wave_chunk_debug_block (GslWaveChunk *wchunk,
gfloat *block)
{
g_return_if_fail (wchunk != NULL);
-
fill_block (wchunk, block, offset, length, FALSE, wchunk->loop_count);
}
-
GslWaveChunk*
_gsl_wave_chunk_copy (GslWaveChunk *wchunk)
{
g_return_val_if_fail (wchunk != NULL, NULL);
g_return_val_if_fail (wchunk->ref_count > 0, NULL);
-
return gsl_wave_chunk_new (wchunk->dcache,
wchunk->mix_freq,
wchunk->osc_freq,
@@ -770,12 +714,10 @@ _gsl_wave_chunk_copy (GslWaveChunk *wchunk)
wchunk->loop_last,
wchunk->loop_count);
}
-
const gchar*
gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop)
{
g_return_val_if_fail (wave_loop >= GSL_WAVE_LOOP_NONE && wave_loop <= GSL_WAVE_LOOP_PINGPONG, NULL);
-
switch (wave_loop)
{
case GSL_WAVE_LOOP_NONE: return "none";
@@ -784,12 +726,10 @@ gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop)
default: return NULL;
}
}
-
GslWaveLoopType
gsl_wave_loop_type_from_string (const gchar *string)
{
g_return_val_if_fail (string != NULL, GSL_WAVE_LOOP_NONE);
-
while (*string == ' ')
string++;
if (strncasecmp (string, "jump", 4) == 0)
diff --git a/bse/gslwavechunk.hh b/bse/gslwavechunk.hh
index d909a7e..93ca5a7 100644
--- a/bse/gslwavechunk.hh
+++ b/bse/gslwavechunk.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_WAVE_CHUNK_H__
#define __GSL_WAVE_CHUNK_H__
-
#include <bse/gsldefs.hh>
#include <bse/gsldatacache.hh>
#include <bse/gsldatahandle.hh>
-
G_BEGIN_DECLS
-
/* --- typedefs & structures --- */
typedef enum /*< skip >*/
{
@@ -25,22 +22,18 @@ struct _GslWaveChunk
/* wave chunk data residency */
GslDataCache *dcache;
GslLong length; /* number of per-channel-values * n-channels */
-
/* chunk specific parameters */
gint n_channels;
GslLong n_pad_values; /* guaranteed pad values around blocks */
GslLong wave_length; /* start + loop duration + end (single channel) */
-
/* flags */
guint pploop_ends_backwards : 1;
guint mini_loop : 1;
-
/* loop spec */
GslWaveLoopType loop_type;
GslLong loop_first;
GslLong loop_last;
guint loop_count;
-
/* preformatted blocks */
GslWaveChunkMem head;
GslWaveChunkMem enter;
@@ -50,7 +43,6 @@ struct _GslWaveChunk
GslWaveChunkMem tail;
GslLong leave_end_norm;
GslLong tail_start_norm;
-
GslWaveLoopType requested_loop_type;
GslLong requested_loop_first;
GslLong requested_loop_last;
@@ -78,8 +70,6 @@ struct _GslWaveChunkBlock
/*< private >*/
gpointer node;
};
-
-
/* --- prototypes --- */
void gsl_wave_chunk_use_block (GslWaveChunk *wave_chunk,
GslWaveChunkBlock *block);
@@ -103,8 +93,5 @@ void gsl_wave_chunk_debug_block (GslWaveChunk *wchunk,
GslWaveChunk* _gsl_wave_chunk_copy (GslWaveChunk *wchunk);
const gchar* gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop);
GslWaveLoopType gsl_wave_loop_type_from_string (const gchar *string);
-
-
G_END_DECLS
-
#endif /* __GSL_WAVE_CHUNK_H__ */
diff --git a/bse/gslwaveosc-aux.cc b/bse/gslwaveosc-aux.cc
index a2e6de4..9494edf 100644
--- a/bse/gslwaveosc-aux.cc
+++ b/bse/gslwaveosc-aux.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
-
#define CHECK_SYNC (WOSC_MIX_VARIANT & WOSC_MIX_WITH_SYNC)
#define CHECK_FREQ (WOSC_MIX_VARIANT & WOSC_MIX_WITH_FREQ)
#define CHECK_MOD (WOSC_MIX_VARIANT & WOSC_MIX_WITH_MOD)
#define EXPONENTIAL_FM (WOSC_MIX_VARIANT & WOSC_MIX_WITH_EXP_FM)
#define DIRSTRIDE(b) (b->dirstride) /* changes according to n_channels and directions */
-
-
static void
WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
guint n_values,
@@ -24,7 +20,6 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
gdouble *a = wosc->a, *b = wosc->b, *y = wosc->y;
gfloat *boundary = block->end;
guint wosc_j = wosc->j;
-
/* do the mixing */
wave_boundary = wave_out + n_values;
do
@@ -90,19 +85,16 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
wave_osc_transform_filter (wosc, BSE_SIGNAL_TO_FREQ (freq_level));
}
}
-
/* process filter while necesary */
while (wosc->cur_pos >= (FRAC_MASK + 1) << 1)
{
double c, c0, c1, c2, c3, c4, c5, c6, c7, c8;
double d, d0, d1, d2, d3, d4, d5, d6, d7;
gfloat *x;
-
if (UNLIKELY ((block->dirstride > 0 && wosc->x >= boundary) ||
(block->dirstride < 0 && wosc->x <= boundary))) /* wchunk block boundary */
{
GslLong next_offset = block->next_offset;
-
gsl_wave_chunk_unuse_block (wosc->wchunk, block);
block->play_dir = wosc->config.play_dir;
block->offset = next_offset;
@@ -110,7 +102,6 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
wosc->x = block->start + CLAMP (wosc->config.channel, 0, wosc->wchunk->n_channels - 1);
boundary = block->end;
}
-
x = wosc->x;
d0 = b[0] * y[wosc_j]; wosc_j++; wosc_j &= 0x7;
d1 = b[1] * y[wosc_j]; wosc_j++; wosc_j &= 0x7;
@@ -146,7 +137,6 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
wosc->x += DIRSTRIDE (block);
wosc->cur_pos -= (FRAC_MASK + 1) << 1;
}
-
/* interpolate filter output from current pos
* wosc->cur_pos >> FRAC_SHIFT is 1 or 0;
*/
@@ -164,7 +154,6 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
ffrac *= 1. / (FRAC_MASK + 1.);
*wave_out++ = y[k & 0x7] * (1.0 - ffrac) + y[(k + 1) & 0x7] * ffrac;
}
-
/* increment */
wosc->cur_pos += wosc->istep;
}
@@ -174,12 +163,10 @@ WOSC_MIX_VARIANT_NAME (GslWaveOscData *wosc,
wosc->last_freq_level = last_freq_level;
wosc->last_mod_level = last_mod_level;
}
-
#undef CHECK_SYNC
#undef CHECK_FREQ
#undef CHECK_MOD
#undef EXPONENTIAL_FM
#undef DIRSTRIDE
-
#undef WOSC_MIX_VARIANT
#undef WOSC_MIX_VARIANT_NAME
diff --git a/bse/gslwaveosc.cc b/bse/gslwaveosc.cc
index 41a692e..c1b713b 100644
--- a/bse/gslwaveosc.cc
+++ b/bse/gslwaveosc.cc
@@ -5,20 +5,14 @@
#include "bseengine.hh" /* for bse_engine_sample_freq() */
#include "bsemain.hh"
#include <string.h>
-
static SFI_MSG_TYPE_DEFINE (debug_waveosc, "waveosc", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_waveosc, __VA_ARGS__)
-
#define FRAC_SHIFT (16)
#define FRAC_MASK ((1 << FRAC_SHIFT) - 1)
#define SIGNAL_LEVEL_INVAL (-2.0) /* trigger level-changed checks */
-
-
/* --- prototype --- */
static void wave_osc_transform_filter (GslWaveOscData *wosc,
gfloat play_freq);
-
-
/* --- generated function variants --- */
#define WOSC_MIX_VARIANT_INVAL (0xffffffff)
#define WOSC_MIX_WITH_SYNC (1)
@@ -81,8 +75,6 @@ static void wave_osc_transform_filter (GslWaveOscData *wosc,
#define WOSC_MIX_VARIANT_NAME wosc_process_____
#define WOSC_MIX_VARIANT (0 | 0 | 0 | 0 )
#include "gslwaveosc-aux.cc"
-
-
/* --- functions --- */
gboolean
gsl_wave_osc_process (GslWaveOscData *wosc,
@@ -93,21 +85,17 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
gfloat *mono_out)
{
guint mode = 0;
-
g_return_val_if_fail (wosc != NULL, FALSE);
g_return_val_if_fail (n_values > 0, FALSE);
g_return_val_if_fail (mono_out != NULL, FALSE);
-
if (UNLIKELY (!wosc->config.lookup_wchunk))
return FALSE;
-
/* mode changes:
* freq_in: if (freq_in) last_freq=inval else set_filter()
* sync_in: last_sync=0
* mod_in: if (mod_in) last_mod=0 else if (freq_in) last_freq=inval else transform_filter()
* exp_mod: n/a
*/
-
if (sync_in)
mode |= WOSC_MIX_WITH_SYNC;
if (freq_in)
@@ -116,12 +104,10 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
mode |= WOSC_MIX_WITH_MOD;
if (wosc->config.exponential_fm)
mode |= WOSC_MIX_WITH_EXP_FM;
-
/* adapt to mode changes */
if (UNLIKELY (mode != wosc->last_mode))
{
guint mask = wosc->last_mode ^ mode;
-
if (mask & WOSC_MIX_WITH_SYNC)
wosc->last_sync_level = 0;
if (mask & WOSC_MIX_WITH_FREQ)
@@ -142,14 +128,12 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
}
wosc->last_mode = mode;
}
-
/* auto-trigger after reset */
if (!sync_in && wosc->last_sync_level < 0.5)
{
gsl_wave_osc_retrigger (wosc, freq_in ? BSE_SIGNAL_TO_FREQ (*freq_in) : wosc->config.cfreq);
wosc->last_sync_level = 1.0;
}
-
switch (mode)
{
case 0 | 0 | 0 | 0:
@@ -195,12 +179,10 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
default:
g_assert_not_reached ();
}
-
if (wosc->y[0] != 0.0 &&
!(fabs (wosc->y[0]) > BSE_SIGNAL_EPSILON && fabs (wosc->y[0]) < BSE_SIGNAL_KAPPA))
{
guint i;
-
DEBUG ("clearing filter state at:\n");
for (i = 0; i < GSL_WAVE_OSC_FILTER_ORDER; i++)
{
@@ -213,14 +195,11 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
}
g_assert (!BSE_DOUBLE_IS_NANINF (wosc->y[0]));
g_assert (!BSE_DOUBLE_IS_SUBNORMAL (wosc->y[0]));
-
wosc->done = (wosc->block.is_silent && /* FIXME, let filter state run out? */
((wosc->block.play_dir < 0 && wosc->block.offset < 0) ||
(wosc->block.play_dir > 0 && wosc->block.offset > wosc->wchunk->wave_length)));
-
return TRUE;
}
-
void
gsl_wave_osc_set_filter (GslWaveOscData *wosc,
gfloat play_freq,
@@ -229,17 +208,13 @@ gsl_wave_osc_set_filter (GslWaveOscData *wosc,
gfloat zero_padding = 2;
gfloat step;
guint i, istep;
-
g_return_if_fail (play_freq > 0);
-
if (UNLIKELY (!wosc->config.lookup_wchunk))
return;
-
wosc->step_factor = zero_padding * wosc->wchunk->mix_freq * wosc->wchunk->fine_tune_factor;
wosc->step_factor /= wosc->wchunk->osc_freq * wosc->mix_freq;
step = wosc->step_factor * play_freq;
istep = step * (FRAC_MASK + 1.) + 0.5;
-
if (istep != wosc->istep)
{
gfloat nyquist_fact = 2.0 * PI / wosc->mix_freq, cutoff_freq = 18000, stop_freq = MAX (wosc->wchunk->mix_freq / 2, 24000);
@@ -250,12 +225,9 @@ gsl_wave_osc_set_filter (GslWaveOscData *wosc,
/* the following frequencies are 2pi relative, where 2*PI=mix-freq */
gfloat freq_r = stop_freq * nyquist_fact * filt_fact;
gfloat freq_c = cutoff_freq * nyquist_fact * filt_fact;
-
/* FIXME: this should store filter roots and poles, so modulation does lp->lp transform */
-
wosc->istep = istep;
gsl_filter_tscheb2_lp (GSL_WAVE_OSC_FILTER_ORDER, freq_c, freq_r / freq_c, 0.18, wosc->a, wosc->b);
-
/* Scale to compensate for zero-padding.
* Adjust volume of the chunk according to its volume adjustment.
*/
@@ -264,13 +236,11 @@ gsl_wave_osc_set_filter (GslWaveOscData *wosc,
for (i = 0; i < (GSL_WAVE_OSC_FILTER_ORDER + 1) / 2; i++) /* reverse bs */
{
gfloat t = wosc->b[GSL_WAVE_OSC_FILTER_ORDER - i];
-
wosc->b[GSL_WAVE_OSC_FILTER_ORDER - i] = wosc->b[i];
wosc->b[i] = t;
}
DEBUG ("filter: fc=%f fr=%f st=%f is=%u\n", freq_c/PI*2, freq_r/PI*2, step, wosc->istep);
}
-
if (clear_state)
{
/* clear filter state */
@@ -279,14 +249,12 @@ gsl_wave_osc_set_filter (GslWaveOscData *wosc,
wosc->cur_pos = 0; /* might want to initialize with istep? */
}
}
-
static void
wave_osc_transform_filter (GslWaveOscData *wosc,
gfloat play_freq)
{
gfloat step;
guint istep;
-
step = wosc->step_factor * play_freq;
istep = step * (FRAC_MASK + 1.) + 0.5;
if (istep != wosc->istep)
@@ -295,27 +263,22 @@ wave_osc_transform_filter (GslWaveOscData *wosc,
/* transform filter poles and roots, normalize filter, update a[] and b[] */
}
}
-
GslLong
gsl_wave_osc_cur_pos (GslWaveOscData *wosc)
{
g_return_val_if_fail (wosc != NULL, -1);
-
if (wosc->wchunk)
return wosc->block.offset;
else
return wosc->config.start_offset;
}
-
void
gsl_wave_osc_retrigger (GslWaveOscData *wosc,
gfloat base_freq)
{
g_return_if_fail (wosc != NULL);
-
if (UNLIKELY (!wosc->config.lookup_wchunk))
return;
-
if (wosc->wchunk)
gsl_wave_chunk_unuse_block (wosc->wchunk, &wosc->block);
wosc->wchunk = wosc->config.lookup_wchunk (wosc->config.wchunk_data, base_freq, 1); // FIXME: velocity=1 hardcoded
@@ -323,22 +286,18 @@ gsl_wave_osc_retrigger (GslWaveOscData *wosc,
wosc->block.offset = wosc->config.start_offset;
gsl_wave_chunk_use_block (wosc->wchunk, &wosc->block);
wosc->x = wosc->block.start + CLAMP (wosc->config.channel, 0, wosc->wchunk->n_channels - 1);
-
DEBUG ("wave lookup: want=%f got=%f length=%llu\n",
base_freq, wosc->wchunk->osc_freq, wosc->wchunk->wave_length);
-
wosc->last_freq_level = BSE_SIGNAL_FROM_FREQ (base_freq);
wosc->last_mod_level = 0;
gsl_wave_osc_set_filter (wosc, base_freq, TRUE);
}
-
void
gsl_wave_osc_config (GslWaveOscData *wosc,
GslWaveOscConfig *config)
{
g_return_if_fail (wosc != NULL);
g_return_if_fail (config != NULL);
-
if (wosc->config.wchunk_data != config->wchunk_data ||
wosc->config.lookup_wchunk != config->lookup_wchunk ||
wosc->config.channel != config->channel)
@@ -364,12 +323,10 @@ gsl_wave_osc_config (GslWaveOscData *wosc,
}
}
}
-
void
gsl_wave_osc_reset (GslWaveOscData *wosc)
{
g_return_if_fail (wosc != NULL);
-
gsl_wave_osc_set_filter (wosc, wosc->config.cfreq, TRUE);
wosc->last_mode = 0;
wosc->last_sync_level = 0;
@@ -377,23 +334,18 @@ gsl_wave_osc_reset (GslWaveOscData *wosc)
wosc->last_mod_level = 0;
wosc->done = FALSE;
}
-
void
gsl_wave_osc_init (GslWaveOscData *wosc)
{
g_return_if_fail (wosc != NULL);
-
g_assert (GSL_WAVE_OSC_FILTER_ORDER <= BSE_CONFIG (wave_chunk_padding));
-
memset (wosc, 0, sizeof (GslWaveOscData));
wosc->mix_freq = bse_engine_sample_freq ();
}
-
void
gsl_wave_osc_shutdown (GslWaveOscData *wosc)
{
g_return_if_fail (wosc != NULL);
-
if (wosc->wchunk)
gsl_wave_chunk_unuse_block (wosc->wchunk, &wosc->block);
memset (wosc, 0xaa, sizeof (GslWaveOscData));
diff --git a/bse/gslwaveosc.hh b/bse/gslwaveosc.hh
index d8305fe..d90d5bd 100644
--- a/bse/gslwaveosc.hh
+++ b/bse/gslwaveosc.hh
@@ -1,32 +1,24 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __GSL_WAVE_OSC_H__
#define __GSL_WAVE_OSC_H__
-
#include <bse/gsldefs.hh>
#include <bse/gslwavechunk.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
#define GSL_WAVE_OSC_FILTER_ORDER (8) /* <= GslConfig.wave_chunk_padding ! */
-
typedef struct
{
GslLong start_offset;
gint play_dir, channel;
-
gpointer wchunk_data;
GslWaveChunk* (*lookup_wchunk) (gpointer wchunk_data,
gfloat freq,
gfloat velocity);
-
gfloat fm_strength; /* linear: 0..1, exponential: n_octaves */
guint exponential_fm : 1;
gfloat cfreq; /* for ifreq == NULL */
} GslWaveOscConfig;
-
typedef struct
{
GslWaveOscConfig config;
@@ -47,8 +39,6 @@ typedef struct
* (play_dir > 0 && cur_pos > wchunk.length)
*/
} GslWaveOscData;
-
-
void gsl_wave_osc_config (GslWaveOscData *wosc,
GslWaveOscConfig *config);
void gsl_wave_osc_reset (GslWaveOscData *wosc);
@@ -63,20 +53,14 @@ void gsl_wave_osc_retrigger (GslWaveOscData *wosc,
void gsl_wave_osc_set_filter (GslWaveOscData *wosc,
gfloat freq,
gboolean clear_state);
-
void gsl_wave_osc_init (GslWaveOscData *wosc);
void gsl_wave_osc_shutdown (GslWaveOscData *wosc);
GslLong gsl_wave_osc_cur_pos (GslWaveOscData *wosc);
-
/* setup:
* wosc = g_new0 (GslWaveOscData, 1);
* wosc->mix_freq = bse_engine_sample_freq ();
*/
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __GSL_WAVE_OSC_H__ */
diff --git a/bse/ladspa.hh b/bse/ladspa.hh
index cf0d3a1..1c06b8b 100644
--- a/bse/ladspa.hh
+++ b/bse/ladspa.hh
@@ -1,20 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef LADSPA_INCLUDED
#define LADSPA_INCLUDED
-
#define LADSPA_VERSION "1.1"
#define LADSPA_VERSION_MAJOR 1
#define LADSPA_VERSION_MINOR 1
-
#ifdef __cplusplus
extern "C" {
#endif
-
/*****************************************************************************/
-
/* Overview:
-
There is a large number of synthesis packages in use or development
on the Linux platform at this time. This API (`The Linux Audio
Developer's Simple Plugin API') attempts to give programmers the
@@ -22,7 +16,6 @@ extern "C" {
them dynamically (`plug') into a range of these packages (`hosts').
It should be possible for any host and any plugin to communicate
completely through this interface.
-
This API is deliberately short and simple. To achieve compatibility
with a range of promising Linux sound synthesis packages it
attempts to find the `greatest common divisor' in their logical
@@ -30,7 +23,6 @@ extern "C" {
implicit, notably the use of a fixed type (LADSPA_Data) for all
data transfer and absence of a parameterised `initialisation'
phase. See below for the LADSPA_Data typedef.
-
Plugins are expected to distinguish between control and audio
data. Plugins have `ports' that are inputs or outputs for audio or
control data and each plugin is `run' for a `block' corresponding
@@ -43,67 +35,50 @@ extern "C" {
duration. The plugin may assume that all its input and output ports
have been connected to the relevant data location (see the
`connect_port()' function below) before it is asked to run.
-
Plugins will reside in shared object files suitable for dynamic
linking by dlopen() and family. The file will provide a number of
`plugin types' that can be used to instantiate actual plugins
(sometimes known as `plugin instances') that can be connected
together to perform tasks.
-
This API contains very limited error-handling. */
-
/*****************************************************************************/
-
/* Fundamental data type passed in and out of plugin. This data type
is used to communicate audio samples and control values. It is
assumed that the plugin will work sensibly given any numeric input
value although it may have a preferred range (see hints below).
-
For audio it is generally assumed that 1.0f is the `0dB' reference
amplitude and is a `normal' signal level. */
-
typedef float LADSPA_Data;
-
/*****************************************************************************/
-
/* Special Plugin Properties:
-
Optional features of the plugin type are encapsulated in the
LADSPA_Properties type. This is assembled by ORing individual
properties together. */
-
typedef int LADSPA_Properties;
-
/* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a
real-time dependency (e.g. listens to a MIDI device) and so its
output must not be cached or subject to significant latency. */
#define LADSPA_PROPERTY_REALTIME 0x1
-
/* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin
may cease to work correctly if the host elects to use the same data
location for both input and output (see connect_port()). This
should be avoided as enabling this flag makes it impossible for
hosts to use the plugin to process audio `in-place.' */
#define LADSPA_PROPERTY_INPLACE_BROKEN 0x2
-
/* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin
is capable of running not only in a conventional host but also in a
`hard real-time' environment. To qualify for this the plugin must
satisfy all of the following:
-
(1) The plugin must not use malloc(), free() or other heap memory
management within its run() or run_adding() functions. All new
memory used in run() must be managed via the stack. These
restrictions only apply to the run() function.
-
(2) The plugin will not attempt to make use of any library
functions with the exceptions of functions in the ANSI standard C
and C maths libraries, which the host is expected to provide.
-
(3) The plugin will not access files, devices, pipes, sockets, IPC
or any other mechanism that might result in process or thread
blocking.
-
(4) The plugin will take an amount of time to execute a run() or
run_adding() call approximately of form (A+B*SampleCount) where A
and B depend on the machine and host in use. This amount of time
@@ -111,75 +86,55 @@ typedef int LADSPA_Properties;
the responsibility to perform timings to estimate upper bounds for
A and B. */
#define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4
-
#define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME)
#define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN)
#define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE)
-
/*****************************************************************************/
-
/* Plugin Ports:
-
Plugins have `ports' that are inputs or outputs for audio or
data. Ports can communicate arrays of LADSPA_Data (for audio
inputs/outputs) or single LADSPA_Data values (for control
input/outputs). This information is encapsulated in the
LADSPA_PortDescriptor type which is assembled by ORing individual
properties together.
-
Note that a port must be an input or an output port but not both
and that a port must be a control or audio port but not both. */
-
typedef int LADSPA_PortDescriptor;
-
/* Property LADSPA_PORT_INPUT indicates that the port is an input. */
#define LADSPA_PORT_INPUT 0x1
-
/* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */
#define LADSPA_PORT_OUTPUT 0x2
-
/* Property LADSPA_PORT_CONTROL indicates that the port is a control
port. */
#define LADSPA_PORT_CONTROL 0x4
-
/* Property LADSPA_PORT_AUDIO indicates that the port is a audio
port. */
#define LADSPA_PORT_AUDIO 0x8
-
#define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT)
#define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT)
#define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL)
#define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO)
-
/*****************************************************************************/
-
/* Plugin Port Range Hints:
-
The host may wish to provide a representation of data entering or
leaving a plugin (e.g. to generate a GUI automatically). To make
this more meaningful, the plugin should provide `hints' to the host
describing the usual values taken by the data.
-
Note that these are only hints. The host may ignore them and the
plugin must not assume that data supplied to it is meaningful. If
the plugin receives invalid input data it is expected to continue
to run without failure and, where possible, produce a sensible
output (e.g. a high-pass filter given a negative cutoff frequency
might switch to an all-pass mode).
-
Hints are meaningful for all input and output ports but hints for
input control ports are expected to be particularly useful.
-
More hint information is encapsulated in the
LADSPA_PortRangeHintDescriptor type which is assembled by ORing
individual hint types together. Hints may require further
LowerBound and UpperBound information.
-
All the hint information for a particular port is aggregated in the
LADSPA_PortRangeHint structure. */
-
typedef int LADSPA_PortRangeHintDescriptor;
-
/* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field
of the LADSPA_PortRangeHint should be considered meaningful. The
value in this field should be considered the (inclusive) lower
@@ -187,7 +142,6 @@ typedef int LADSPA_PortRangeHintDescriptor;
specified then the value of LowerBound should be multiplied by the
sample rate. */
#define LADSPA_HINT_BOUNDED_BELOW 0x1
-
/* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field
of the LADSPA_PortRangeHint should be considered meaningful. The
value in this field should be considered the (inclusive) upper
@@ -195,7 +149,6 @@ typedef int LADSPA_PortRangeHintDescriptor;
specified then the value of UpperBound should be multiplied by the
sample rate. */
#define LADSPA_HINT_BOUNDED_ABOVE 0x2
-
/* Hint LADSPA_HINT_TOGGLED indicates that the data item should be
considered a Boolean toggle. Data less than or equal to zero should
be considered `off' or `false,' and data above zero should be
@@ -203,7 +156,6 @@ typedef int LADSPA_PortRangeHintDescriptor;
conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or
LADSPA_HINT_DEFAULT_1. */
#define LADSPA_HINT_TOGGLED 0x4
-
/* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified
should be interpreted as multiples of the sample rate. For
instance, a frequency range from 0Hz to the Nyquist frequency (half
@@ -211,12 +163,10 @@ typedef int LADSPA_PortRangeHintDescriptor;
with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds
at all must support this hint to retain meaning. */
#define LADSPA_HINT_SAMPLE_RATE 0x8
-
/* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the
user will find it more intuitive to view values using a logarithmic
scale. This is particularly useful for frequencies and gains. */
#define LADSPA_HINT_LOGARITHMIC 0x10
-
/* Hint LADSPA_HINT_INTEGER indicates that a user interface would
probably wish to provide a stepped control taking only integer
values. Any bounds set should be slightly wider than the actual
@@ -224,7 +174,6 @@ typedef int LADSPA_PortRangeHintDescriptor;
instance, the integer set {0,1,2,3} might be described as [-0.1,
3.1]. */
#define LADSPA_HINT_INTEGER 0x20
-
/* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal'
value for the port that is sensible as a default. For instance,
this value is suitable for use as an initial value in a user
@@ -237,64 +186,52 @@ typedef int LADSPA_PortRangeHintDescriptor;
default must be rounded if LADSPA_HINT_INTEGER is present. Default
values were introduced in LADSPA v1.1. */
#define LADSPA_HINT_DEFAULT_MASK 0x3C0
-
/* This default values indicates that no default is provided. */
#define LADSPA_HINT_DEFAULT_NONE 0x0
-
/* This default hint indicates that the suggested lower bound for the
port should be used. */
#define LADSPA_HINT_DEFAULT_MINIMUM 0x40
-
/* This default hint indicates that a low value between the suggested
lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 +
log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper
* 0.25). */
#define LADSPA_HINT_DEFAULT_LOW 0x80
-
/* This default hint indicates that a middle value between the
suggested lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 +
log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper *
0.5). */
#define LADSPA_HINT_DEFAULT_MIDDLE 0xC0
-
/* This default hint indicates that a high value between the suggested
lower and upper bounds should be chosen. For ports with
LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 +
log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper
* 0.75). */
#define LADSPA_HINT_DEFAULT_HIGH 0x100
-
/* This default hint indicates that the suggested upper bound for the
port should be used. */
#define LADSPA_HINT_DEFAULT_MAXIMUM 0x140
-
/* This default hint indicates that the number 0 should be used. Note
that this default may be used in conjunction with
LADSPA_HINT_TOGGLED. */
#define LADSPA_HINT_DEFAULT_0 0x200
-
/* This default hint indicates that the number 1 should be used. Note
that this default may be used in conjunction with
LADSPA_HINT_TOGGLED. */
#define LADSPA_HINT_DEFAULT_1 0x240
-
/* This default hint indicates that the number 100 should be used. */
#define LADSPA_HINT_DEFAULT_100 0x280
-
/* This default hint indicates that the Hz frequency of `concert A'
should be used. This will be 440 unless the host uses an unusual
tuning convention, in which case it may be within a few Hz. */
#define LADSPA_HINT_DEFAULT_440 0x2C0
-
#define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW)
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE)
#define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED)
#define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE)
#define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC)
#define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER)
-
#define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK)
#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_MINIMUM)
@@ -314,110 +251,83 @@ typedef int LADSPA_PortRangeHintDescriptor;
== LADSPA_HINT_DEFAULT_100)
#define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
== LADSPA_HINT_DEFAULT_440)
-
typedef struct _LADSPA_PortRangeHint {
-
/* Hints about the port. */
LADSPA_PortRangeHintDescriptor HintDescriptor;
-
/* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When
LADSPA_HINT_SAMPLE_RATE is also active then this value should be
multiplied by the relevant sample rate. */
LADSPA_Data LowerBound;
-
/* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When
LADSPA_HINT_SAMPLE_RATE is also active then this value should be
multiplied by the relevant sample rate. */
LADSPA_Data UpperBound;
-
} LADSPA_PortRangeHint;
-
/*****************************************************************************/
-
/* Plugin Handles:
-
This plugin handle indicates a particular instance of the plugin
concerned. It is valid to compare this to NULL (0 for C++) but
otherwise the host should not attempt to interpret it. The plugin
may use it to reference internal instance data. */
-
typedef void * LADSPA_Handle;
-
/*****************************************************************************/
-
/* Descriptor for a Type of Plugin:
-
This structure is used to describe a plugin type. It provides a
number of functions to examine the type, instantiate it, link it to
buffers and workspaces and to run it. */
-
typedef struct _LADSPA_Descriptor {
-
/* This numeric identifier indicates the plugin type
uniquely. Plugin programmers may reserve ranges of IDs from a
central body to avoid clashes. Hosts may assume that IDs are
below 0x1000000. */
unsigned long UniqueID;
-
/* This identifier can be used as a unique, case-sensitive
identifier for the plugin type within the plugin file. Plugin
types should be identified by file and label rather than by index
or plugin name, which may be changed in new plugin
versions. Labels must not contain white-space characters. */
const char * Label;
-
/* This indicates a number of properties of the plugin. */
LADSPA_Properties Properties;
-
/* This member points to the null-terminated name of the plugin
(e.g. "Sine Oscillator"). */
const char * Name;
-
/* This member points to the null-terminated string indicating the
maker of the plugin. This can be an empty string but not NULL. */
const char * Maker;
-
/* This member points to the null-terminated string indicating any
copyright applying to the plugin. If no Copyright applies the
string "None" should be used. */
const char * Copyright;
-
/* This indicates the number of ports (input AND output) present on
the plugin. */
unsigned long PortCount;
-
/* This member indicates an array of port descriptors. Valid indices
vary from 0 to PortCount-1. */
const LADSPA_PortDescriptor * PortDescriptors;
-
/* This member indicates an array of null-terminated strings
describing ports (e.g. "Frequency (Hz)"). Valid indices vary from
0 to PortCount-1. */
const char * const * PortNames;
-
/* This member indicates an array of range hints for each port (see
above). Valid indices vary from 0 to PortCount-1. */
const LADSPA_PortRangeHint * PortRangeHints;
-
/* This may be used by the plugin developer to pass any custom
implementation data into an instantiate call. It must not be used
or interpreted by the host. It is expected that most plugin
writers will not use this facility as LADSPA_Handle should be
used to hold instance data. */
void * ImplementationData;
-
/* This member is a function pointer that instantiates a plugin. A
handle is returned indicating the new plugin instance. The
instantiation function accepts a sample rate as a parameter. The
plugin descriptor from which this instantiate function was found
must also be passed. This function must return NULL if
instantiation fails.
-
Note that instance initialisation should generally occur in
activate() rather than here. */
LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor,
unsigned long SampleRate);
-
/* This member is a function pointer that connects a port on an
instantiated plugin to a memory location at which a block of data
for the port will be read/written. The data location is expected
@@ -427,18 +337,15 @@ typedef struct _LADSPA_Descriptor {
locations every time run() or run_adding() is called and the data
present at the time of this connection call should not be
considered meaningful.
-
connect_port() may be called more than once for a plugin instance
to allow the host to change the buffers that the plugin is
reading or writing. These calls may be made before or after
activate() or deactivate() calls.
-
connect_port() must be called at least once for each port before
run() or run_adding() is called. When working with blocks of
LADSPA_Data the plugin should pay careful attention to the block
size passed to the run function as the block allocated may only
just be large enough to contain the block of samples.
-
Plugin writers should be aware that the host may elect to use the
same buffer for more than one port and even use the same buffer
for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN).
@@ -447,7 +354,6 @@ typedef struct _LADSPA_Descriptor {
void (*connect_port)(LADSPA_Handle Instance,
unsigned long Port,
LADSPA_Data * DataLocation);
-
/* This member is a function pointer that initialises a plugin
instance and activates it for use. This is separated from
instantiate() to aid real-time support and so that hosts can
@@ -458,7 +364,6 @@ typedef struct _LADSPA_Descriptor {
gain set by set_run_adding_gain(). If there is nothing for
activate() to do then the plugin writer may provide a NULL rather
than an empty function.
-
When present, hosts must call this function once before run() (or
run_adding()) is called for the first time. This call should be
made as close to the run() call as possible and indicates to
@@ -468,24 +373,20 @@ typedef struct _LADSPA_Descriptor {
connect_port() may be called before or after a call to
activate(). */
void (*activate)(LADSPA_Handle Instance);
-
/* This method is a function pointer that runs an instance of a
plugin for a block. Two parameters are required: the first is a
handle to the particular instance to be run and the second
indicates the block size (in samples) for which the plugin
instance may run.
-
Note that if an activate() function exists then it must be called
before run() or run_adding(). If deactivate() is called for a
plugin instance then the plugin instance may not be reused until
activate() has been called again.
-
If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE
then there are various things that the plugin should not do
within the run() or run_adding() functions (see above). */
void (*run)(LADSPA_Handle Instance,
unsigned long SampleCount);
-
/* This method is a function pointer that runs an instance of a
plugin for a block. This has identical behaviour to run() except
in the way data is output from the plugin. When run() is used,
@@ -495,55 +396,43 @@ typedef struct _LADSPA_Descriptor {
areas. Furthermore, output values written must be scaled by the
current gain set by set_run_adding_gain() (see below) before
addition.
-
run_adding() is optional. When it is not provided by a plugin,
this function pointer must be set to NULL. When it is provided,
the function set_run_adding_gain() must be provided also. */
void (*run_adding)(LADSPA_Handle Instance,
unsigned long SampleCount);
-
/* This method is a function pointer that sets the output gain for
use when run_adding() is called (see above). If this function is
never called the gain is assumed to default to 1. Gain
information should be retained when activate() or deactivate()
are called.
-
This function should be provided by the plugin if and only if the
run_adding() function is provided. When it is absent this
function pointer must be set to NULL. */
void (*set_run_adding_gain)(LADSPA_Handle Instance,
LADSPA_Data Gain);
-
/* This is the counterpart to activate() (see above). If there is
nothing for deactivate() to do then the plugin writer may provide
a NULL rather than an empty function.
-
Hosts must deactivate all activated units after they have been
run() (or run_adding()) for the last time. This call should be
made as close to the last run() call as possible and indicates to
real-time plugins that they are no longer live. Plugins should
not rely on prompt deactivation. Note that connect_port() may be
called before or after a call to deactivate().
-
Deactivation is not similar to pausing as the plugin instance
will be reinitialised when activate() is called to reuse it. */
void (*deactivate)(LADSPA_Handle Instance);
-
/* Once an instance of a plugin has been finished with it can be
deleted using the following function. The instance handle passed
ceases to be valid after this call.
-
If activate() was called for a plugin instance then a
corresponding call to deactivate() must be made before cleanup()
is called. */
void (*cleanup)(LADSPA_Handle Instance);
-
} LADSPA_Descriptor;
-
/**********************************************************************/
-
/* Accessing a Plugin: */
-
/* The exact mechanism by which plugins are loaded is host-dependent,
however all most hosts will need to know is the name of shared
object file containing the plugin types. To allow multiple hosts to
@@ -551,34 +440,25 @@ typedef struct _LADSPA_Descriptor {
variable LADSPA_PATH. If present, this should contain a
colon-separated path indicating directories that should be searched
(in order) when loading plugin types.
-
A plugin programmer must include a function called
"ladspa_descriptor" with the following function prototype within
the shared object file. This function will have C-style linkage (if
you are using C++ this is taken care of by the `extern "C"' clause
at the top of the file).
-
A host will find the plugin shared object file by one means or
another, find the ladspa_descriptor() function, call it, and
proceed from there.
-
Plugin types are accessed by index (not ID) using values from 0
upwards. Out of range indexes must result in this function
returning NULL, so the plugin count can be determined by checking
for the least index that results in NULL being returned. */
-
const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);
-
/* Datatype corresponding to the ladspa_descriptor() function. */
typedef const LADSPA_Descriptor *
(*LADSPA_Descriptor_Function)(unsigned long Index);
-
/**********************************************************************/
-
#ifdef __cplusplus
}
#endif
-
#endif /* LADSPA_INCLUDED */
-
/* EOF */
diff --git a/bse/tests/blocktests.cc b/bse/tests/blocktests.cc
index e89151d..bbad126 100644
--- a/bse/tests/blocktests.cc
+++ b/bse/tests/blocktests.cc
@@ -4,7 +4,6 @@
#include <sfi/sfitests.hh>
#include <bse/bsemain.hh>
#include "topconfig.h"
-
template<typename T> static bool
block_check (guint n,
const T *block,
@@ -18,7 +17,6 @@ block_check (guint n,
}
return true;
}
-
/**
* Shuffles a block, using the O(n) algorithm called the Knuth shuffle
* or Fisher-Yates shuffle, for instance explained on
@@ -44,7 +42,6 @@ block_shuffle (guint n_elements,
elements[i] = tmp;
}
}
-
static void
build_ascending_random_block (guint n_values,
float *fblock)
@@ -54,220 +51,166 @@ build_ascending_random_block (guint n_values,
for (guint i = 1; i < n_values; i++)
fblock[i] = fblock[i-1] + g_random_double_range (1e-10, 4.0 / n_values);
}
-
static void
test_fill (void)
{
TSTART ("BlockFill");
float fblock1[1024];
-
bse_block_fill_uint32 (1024, (uint32*) (void*) fblock1, 0);
TASSERT (block_check (1024, fblock1, 0.f) == true);
-
bse_block_fill_float (1024, fblock1, 17.786);
TASSERT (block_check (1024, fblock1, 17.786f) == true);
-
Bse::Block::fill (1024, fblock1, 17.786f);
TASSERT (block_check (1024, fblock1, 17.786f) == true);
-
Bse::Block::fill (1024, (uint32*) (void*) fblock1, 0);
TASSERT (block_check (1024, fblock1, 0.f) == true);
-
TDONE();
}
-
static void
test_copy (void)
{
TSTART ("BlockCopy");
float fblock1[1024], fblock2[1024];
-
Bse::Block::fill (1024, fblock2, -213e+3f);
TASSERT (block_check (1024, fblock2, -213e+3f) == true);
-
Bse::Block::fill (1024, fblock1, -8763e-4f);
bse_block_copy_float (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, -213e+3F) == true);
-
Bse::Block::fill (1024, fblock1, -8763e-4f);
bse_block_copy_uint32 (1024, (uint32*) (void*) fblock1, (uint32*) (void*) fblock2);
TASSERT (block_check (1024, fblock1, -213e+3F) == true);
-
Bse::Block::fill (1024, fblock1, -8763e-4f);
Bse::Block::copy (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, -213e+3F) == true);
-
Bse::Block::fill (1024, fblock1, -8763e-4f);
Bse::Block::copy (1024, (uint32*) (void*) fblock1, (uint32*) (void*) fblock2);
TASSERT (block_check (1024, fblock1, -213e+3F) == true);
-
TDONE();
}
-
static void
test_add (void)
{
TSTART ("BlockAdd");
float fblock1[1024], fblock2[1024];
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::fill (1024, fblock2, 3.f);
bse_block_add_floats (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, 5.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::add (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, 5.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
TDONE();
}
-
static void
test_sub (void)
{
TSTART ("BlockSub");
float fblock1[1024], fblock2[1024];
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::fill (1024, fblock2, 3.f);
bse_block_sub_floats (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, -1.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::sub (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, -1.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
TDONE();
}
-
static void
test_mul (void)
{
TSTART ("BlockMul");
float fblock1[1024], fblock2[1024];
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::fill (1024, fblock2, 3.f);
bse_block_mul_floats (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, 6.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
Bse::Block::fill (1024, fblock1, 2.f);
Bse::Block::mul (1024, fblock1, fblock2);
TASSERT (block_check (1024, fblock1, 6.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
TDONE();
}
-
static void
test_square_sum (void)
{
TSTART ("BlockSquareSum");
float fblock[1024];
float min_value, max_value;
-
for (int i = 0; i < 10; i++)
{
float energy, energy_db;
-
for (int i = 0; i < 1024; i++)
fblock[i] = sin (i * 2 * M_PI / 1024);
-
energy = bse_block_calc_float_square_sum (1024, fblock) / 1024.;
energy_db = 10 * log10 (energy);
-
TPRINT ("sine wave: energy = %f, energy_db = %f\n", energy, energy_db);
TASSERT (fabs (energy - 0.5) < 0.0000001);
-
energy = bse_block_calc_float_range_and_square_sum (1024, fblock, &min_value, &max_value) / 1024.;
TASSERT (fabs (energy - 0.5) < 0.0000001);
-
for (int i = 0; i < 1024; i++)
fblock[i] = i < 512 ? -1 : 1;
-
energy = bse_block_calc_float_square_sum (1024, fblock) / 1024.;
energy_db = 10 * log10 (energy);
-
TPRINT ("square wave: energy = %f, energy_db = %f\n", energy, energy_db);
TASSERT (fabs (energy - 1.0) < 0.0000001);
-
energy = bse_block_calc_float_range_and_square_sum (1024, fblock, &min_value, &max_value) / 1024.;
TASSERT (fabs (energy - 1.0) < 0.0000001);
-
/* square sum (and energy) should not depend on ordering of the elements */
block_shuffle (1024, fblock);
}
-
TDONE();
}
-
static void
test_range (void)
{
TSTART ("BlockRange");
-
float fblock[1024];
-
build_ascending_random_block (1024, fblock);
-
float correct_min_value = fblock[0];
float correct_max_value = fblock[1023];
-
for (int i = 0; i < 10; i++)
{
/* shuffle block into quasi random order */
block_shuffle (1024, fblock);
-
/* check that correct minimum and maximum is still found */
float min_value = 0, max_value = 0;
bse_block_calc_float_range (1024, fblock, &min_value, &max_value);
-
TASSERT (min_value == correct_min_value);
TASSERT (max_value == correct_max_value);
-
bse_block_calc_float_range_and_square_sum (1024, fblock, &min_value, &max_value);
-
TASSERT (min_value == correct_min_value);
TASSERT (max_value == correct_max_value);
}
TDONE();
}
-
-
static void
test_scale (void)
{
TSTART ("BlockScale");
float fblock1[1024], fblock2[1024];
-
Bse::Block::fill (1024, fblock1, 0.f);
Bse::Block::fill (1024, fblock2, 3.f);
bse_block_scale_floats (1024, fblock1, fblock2, 2.f);
TASSERT (block_check (1024, fblock1, 6.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
Bse::Block::fill (1024, fblock1, 0.f);
Bse::Block::scale (1024, fblock1, fblock2, 2.f);
TASSERT (block_check (1024, fblock1, 6.f) == true);
TASSERT (block_check (1024, fblock2, 3.f) == true);
-
TDONE();
}
-
#define RUNS 11
-
const int BLOCK_SIZE = 1024;
/*
* to make benchmarks with different blocksizes comparable,
* results will be scaled to a standard block size (1024)
*/
const double BENCH_SCALE = 1024. / BLOCK_SIZE;
-
static inline void
bench_fill (void)
{
@@ -277,7 +220,6 @@ bench_fill (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::fill (BLOCK_SIZE, fblock, 2.f));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -294,7 +236,6 @@ bench_fill (void)
g_print ("FillBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_copy (void)
{
@@ -306,7 +247,6 @@ bench_copy (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::copy (BLOCK_SIZE, dest_fblock, src_fblock));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -324,7 +264,6 @@ bench_copy (void)
g_print ("CopyBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_add (void)
{
@@ -336,7 +275,6 @@ bench_add (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::add (BLOCK_SIZE, fblock1, fblock2));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -353,7 +291,6 @@ bench_add (void)
g_print ("AddBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_sub (void)
{
@@ -365,7 +302,6 @@ bench_sub (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::sub (BLOCK_SIZE, fblock1, fblock2));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -382,7 +318,6 @@ bench_sub (void)
g_print ("SubBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_mul (void)
{
@@ -394,7 +329,6 @@ bench_mul (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::mul (BLOCK_SIZE, fblock1, fblock2));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -412,7 +346,6 @@ bench_mul (void)
g_print ("MulBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_scale (void)
{
@@ -424,7 +357,6 @@ bench_scale (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::scale (BLOCK_SIZE, fblock1, fblock2, 2.f));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -441,26 +373,21 @@ bench_scale (void)
g_print ("ScaleBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_range (void)
{
float fblock[BLOCK_SIZE];
build_ascending_random_block (BLOCK_SIZE, fblock);
-
float correct_min_value = fblock[0];
float correct_max_value = fblock[BLOCK_SIZE - 1];
float min_value, max_value;
-
/* shuffle block into quasi random order */
block_shuffle (BLOCK_SIZE, fblock);
-
GTimer *timer = g_timer_new();
g_timer_start (timer);
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::range (BLOCK_SIZE, fblock, min_value, max_value));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -479,7 +406,6 @@ bench_range (void)
g_print ("RangeBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_square_sum (void)
{
@@ -490,7 +416,6 @@ bench_square_sum (void)
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::square_sum (BLOCK_SIZE, fblock));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -507,26 +432,21 @@ bench_square_sum (void)
g_print ("SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static inline void
bench_range_and_square_sum (void)
{
float fblock[BLOCK_SIZE];
build_ascending_random_block (BLOCK_SIZE, fblock);
-
float correct_min_value = fblock[0];
float correct_max_value = fblock[BLOCK_SIZE - 1];
float min_value, max_value;
-
/* shuffle block into quasi random order */
block_shuffle (BLOCK_SIZE, fblock);
-
GTimer *timer = g_timer_new();
g_timer_start (timer);
const guint dups = TEST_CALIBRATION (50.0, Bse::Block::range_and_square_sum (BLOCK_SIZE, fblock, min_value, max_value));
g_timer_stop (timer);
double c = g_timer_elapsed (timer, NULL);
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -545,7 +465,6 @@ bench_range_and_square_sum (void)
g_print ("Range+SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
}
-
static void
run_tests()
{
@@ -558,7 +477,6 @@ run_tests()
/* the next two functions test the range_and_square_sum function, too */
test_range();
test_square_sum();
-
if (sfi_init_settings().test_perf)
{
bench_fill();
@@ -572,7 +490,6 @@ run_tests()
bench_range_and_square_sum();
}
}
-
int
main (int argc,
char *argv[])
@@ -585,29 +502,22 @@ main (int argc,
treport_cpu_name (cname);
g_free (cname);
}
-
TSTART ("Running Default Block Ops");
TASSERT (Bse::Block::default_singleton() == Bse::Block::current_singleton());
TDONE();
-
run_tests(); /* run tests on FPU */
-
/* load plugins */
SfiInitValue config[] = {
{ "load-core-plugins", "1" },
{ NULL },
};
bse_init_test (&argc, &argv, config);
-
/* check for possible specialization */
if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
return 0; /* nothing changed */
-
TSTART ("Running Intrinsic Block Ops");
TASSERT (Bse::Block::default_singleton() != Bse::Block::current_singleton());
TDONE();
-
run_tests(); /* run tests with intrinsics */
-
return 0;
}
diff --git a/bse/tests/filtertest.cc b/bse/tests/filtertest.cc
index 70c56d2..0a5957b 100644
--- a/bse/tests/filtertest.cc
+++ b/bse/tests/filtertest.cc
@@ -11,18 +11,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <complex>
-
typedef std::complex<double> Complex;
using namespace Birnet;
using std::max;
using std::min;
-
static inline double
sqr (register double a)
{
return a * a;
}
-
static inline uint
complex_find_nearest (const BseComplex *zp,
uint n_zps,
@@ -46,7 +43,6 @@ complex_find_nearest (const BseComplex *zp,
}
return j;
}
-
static double
compare_zeros (uint n_zeros,
const BseComplex *czeros,
@@ -66,13 +62,11 @@ compare_zeros (uint n_zeros,
}
return max_eps;
}
-
static double
to_db (double response)
{
return response <= 0.0 ? -999.99 : max (BSE_DECIBEL20_FACTOR * log (response), -999.99);
}
-
static double
filter_zp_response (const BseIIRFilterDesign *fdes,
double freq)
@@ -99,7 +93,6 @@ filter_zp_response (const BseIIRFilterDesign *fdes,
(void) freq_phase;
return freq_magnitude;
}
-
bool
bse_iir_filter_dump_gnuplot (const BseIIRFilterDesign *fdes,
const char *fname,
@@ -120,20 +113,17 @@ bse_iir_filter_dump_gnuplot (const BseIIRFilterDesign *fdes,
fclose (df);
return false;
}
-
const double nyquist = 0.5 * fdes->sampling_frequency;
const double delta = nyquist / scan_points;
for (double f = 0; f < nyquist; f += delta)
fprintf (df, "%.17g %.17g %.17g\n", f,
to_db (filter_zp_response (fdes, f)),
to_db (filter_zp_response (fdes, f)));
-
//gchar *nstr = bse_poly_str (fdes->order, (double*) fdes->zn, "z");
//gchar *dstr = bse_poly_str (fdes->order, (double*) fdes->zd, "z");
//fprintf (gf, "H(z)=%s/%s\n", nstr, dstr);
//g_free (nstr);
//g_free (dstr);
-
fprintf (gf, "dB(x)=20*log(abs(x))/log(10)\n");
fprintf (gf, "Z(x)=exp({0,-1}*x) # gnuplot variable x for H(z)\n");
fprintf (gf, "set samples 10000 # increase accuracy\n");
@@ -154,7 +144,6 @@ bse_iir_filter_dump_gnuplot (const BseIIRFilterDesign *fdes,
fclose (df);
return true;
}
-
static void
noexit_dump_iir_filter_gnuplot (const BseIIRFilterRequest *fireq,
const BseIIRFilterDesign *fdes,
@@ -188,7 +177,6 @@ noexit_dump_iir_filter_gnuplot (const BseIIRFilterRequest *fireq,
g_printerr ("Design: %s\n", bse_iir_filter_design_string (fdes));
g_printerr ("GnuplotDump: wrote %s.gp and %s.dat use: gnuplot %s.gp\n", fname, fname, fname);
}
-
static void
exit_with_iir_filter_gnuplot (const BseIIRFilterRequest *fireq,
const BseIIRFilterDesign *fdes,
@@ -203,7 +191,6 @@ exit_with_iir_filter_gnuplot (const BseIIRFilterRequest *fireq,
noexit_dump_iir_filter_gnuplot (fireq, fdes, fname, passband_ripple_db, passband_edge, passband_edge2, stopband_db, stopband_edge, stopband_edge2);
exit (0);
}
-
static double
max_band_damping_zp (const BseIIRFilterDesign *fdes,
double start_freq,
@@ -223,7 +210,6 @@ max_band_damping_zp (const BseIIRFilterDesign *fdes,
g_printerr ("PassBandZPDB: %f: %f\n", f, to_db (filter_zp_response (fdes, f)));
return to_db (eps);
}
-
static double
min_band_damping_zp (const BseIIRFilterDesign *fdes,
double start_freq,
@@ -243,7 +229,6 @@ min_band_damping_zp (const BseIIRFilterDesign *fdes,
g_printerr ("PassBandZPDB: %f: %f\n", f, to_db (filter_zp_response (fdes, f)));
return to_db (eps);
}
-
static double
max_band_damping (const BseIIRFilterDesign *fdes,
double start_freq,
@@ -252,7 +237,6 @@ max_band_damping (const BseIIRFilterDesign *fdes,
// double res1 = max_band_damping_ztrans (fdes, start_freq, end_freq);
return max_band_damping_zp (fdes, MIN (start_freq, end_freq), MAX (start_freq, end_freq));
}
-
static double
min_band_damping (const BseIIRFilterDesign *fdes,
double start_freq,
@@ -261,7 +245,6 @@ min_band_damping (const BseIIRFilterDesign *fdes,
// double res1 = min_band_damping_ztrans (fdes, start_freq, end_freq);
return min_band_damping_zp (fdes, MIN (start_freq, end_freq), MAX (start_freq, end_freq));
}
-
static void
print_filter_on_abort (void *data)
{
@@ -272,7 +255,6 @@ print_filter_on_abort (void *data)
-fabs(req->passband_ripple_db), req->passband_edge, req->passband_edge2,
req->stopband_db != 0 ? req->stopband_db : NAN, req->stopband_edge, NAN);
}
-
static void
butterwoth_tests ()
{
@@ -287,7 +269,6 @@ butterwoth_tests ()
abort_data[1] = &fdes;
TABORT_HANDLER (print_filter_on_abort, abort_data);
TOK();
-
{
req.type = BSE_IIR_FILTER_LOW_PASS;
req.order = 8;
@@ -306,7 +287,6 @@ butterwoth_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 2000, NAN, -68, 3500);
}
-
{
req.type = BSE_IIR_FILTER_HIGH_PASS;
req.order = 7;
@@ -320,7 +300,6 @@ butterwoth_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 2000, NAN, -80, 600);
}
-
{
req.type = BSE_IIR_FILTER_BAND_PASS;
req.order = 9;
@@ -336,7 +315,6 @@ butterwoth_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 1500, 3500, -49.5, 1000, 4000);
}
-
{
req.type = BSE_IIR_FILTER_BAND_STOP;
req.order = 14;
@@ -352,11 +330,9 @@ butterwoth_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 1000, 4000, -77, 1500, 3500);
}
-
TOK();
TDONE();
}
-
static void
chebychev1_tests ()
{
@@ -371,7 +347,6 @@ chebychev1_tests ()
TABORT_HANDLER (print_filter_on_abort, abort_data);
const double gaineps = 1e-7;
TOK();
-
{
req.type = BSE_IIR_FILTER_LOW_PASS;
req.order = 8;
@@ -386,7 +361,6 @@ chebychev1_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.55, 3000, NAN, -80, 5000);
}
-
{
req.type = BSE_IIR_FILTER_HIGH_PASS;
req.order = 7;
@@ -401,7 +375,6 @@ chebychev1_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -0.1, 600, NAN, -70, 250);
}
-
{
req.type = BSE_IIR_FILTER_BAND_PASS;
req.order = 10;
@@ -418,7 +391,6 @@ chebychev1_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.801, 3500, 9500, -55, 3000, 10200);
}
-
{
req.type = BSE_IIR_FILTER_BAND_STOP;
req.order = 13;
@@ -435,11 +407,9 @@ chebychev1_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.001, 8000, 12000, -78, 8500, 11500);
}
-
TOK();
TDONE();
}
-
typedef struct {
const BseIIRFilterRequest *filter_request;
double gain;
@@ -450,19 +420,16 @@ typedef struct {
const double *filter_coefficients;
uint n_filter_coefficients;
} FilterSetup;
-
static void generic_filter_tests (const char *test_name,
const uint n_filters,
const FilterSetup *filters,
uint tick_count = 1,
uint skip_count = 0);
-
static void
test_problem_candidates ()
{
FilterSetup filters[1000] = { { 0, } };
uint index = 0;
-
{ // ellf gain is too high
static const BseIIRFilterRequest filter_request = {
/* kind = */ BSE_IIR_FILTER_ELLIPTIC,
@@ -511,7 +478,6 @@ test_problem_candidates ()
filters[index].gain = +1.12649838606861938e-01;
index++;
}
-
if (0) { // FIXME: bse gain = 4.3037825362077964
static const BseIIRFilterRequest filter_request = {
/* kind = */ BSE_IIR_FILTER_ELLIPTIC,
@@ -528,11 +494,9 @@ test_problem_candidates ()
filters[index].gain = -3.83263619423376167e-01;
index++;
}
-
/* and test them */
generic_filter_tests ("Problem Filters", index, filters);
}
-
static void
random_filter_tests ()
{
@@ -554,10 +518,8 @@ random_filter_tests ()
double pbe1;
FilterSetup filters[100000] = { { 0, }, };
uint filter_index, skip_count = 6;
-
if (sfi_init_settings().test_quick)
n_orders = 9;
-
#define MAKE_FILTER(frequest, filter_type) do \
{ \
if (!filters[filter_index].filter_request) \
@@ -568,7 +530,6 @@ random_filter_tests ()
rqcopy->type = filter_type; \
filter_index++; \
} while (0)
-
/* generate filter requirements */
filter_index = 0;
frequest.kind = BSE_IIR_FILTER_BUTTERWORTH;
@@ -592,7 +553,6 @@ random_filter_tests ()
}
/* design and test filters */
generic_filter_tests ("Random Butterworth", filter_index, filters, skip_count);
-
/* generate filter requirements */
filter_index = 0;
frequest.kind = BSE_IIR_FILTER_CHEBYSHEV1;
@@ -620,7 +580,6 @@ random_filter_tests ()
}
/* design and test filters */
generic_filter_tests ("Random Chebyshev1", filter_index, filters, skip_count);
-
/* generate filter requirements */
filter_index = 0;
frequest.kind = BSE_IIR_FILTER_ELLIPTIC;
@@ -653,7 +612,6 @@ random_filter_tests ()
}
/* design and test filters */
generic_filter_tests ("Random Elliptic (dB)", filter_index, filters, skip_count);
-
/* generate filter requirements */
filter_index = 0;
frequest.kind = BSE_IIR_FILTER_ELLIPTIC;
@@ -688,30 +646,24 @@ random_filter_tests ()
}
/* design and test filters */
generic_filter_tests ("Random Elliptic (Hz)", filter_index, filters, skip_count);
-
#undef MAKE_FILTER
}
-
static void
test_filter_catalog ()
{
FilterSetup filters[100000] = { { 0, } };
uint index = 0;
-
/* include predesigned filters */
#include "filtercatalog.cc"
-
uint skip_count = 0, tick_count = 3;
if (sfi_init_settings().test_quick)
{
tick_count = 1;
skip_count = 17;
}
-
/* test predesigned filters */
generic_filter_tests ("Filter Catalog", index, filters, tick_count, skip_count);
}
-
static void
generic_filter_tests (const char *test_name,
const uint n_filters,
@@ -808,7 +760,6 @@ generic_filter_tests (const char *test_name,
}
TDONE();
}
-
int
main (int argc,
char **argv)
diff --git a/bse/tests/firhandle.cc b/bse/tests/firhandle.cc
index aa70993..f5013f8 100644
--- a/bse/tests/firhandle.cc
+++ b/bse/tests/firhandle.cc
@@ -10,18 +10,15 @@
#include <stdlib.h>
#include <complex>
#include <vector>
-
using std::vector;
using std::min;
using std::max;
using Birnet::string_printf;
-
static void
read_through (GslDataHandle *handle)
{
int64 n_values = gsl_data_handle_n_values (handle);
int64 offset = 0;
-
while (offset < n_values)
{
// we don't use 1024 here, because we know that it is the FIR handle internal buffer size
@@ -30,26 +27,20 @@ read_through (GslDataHandle *handle)
g_assert (values_read > 0);
offset += values_read;
}
-
g_assert (offset == n_values);
}
-
static double
phase_diff (double p1,
double p2)
{
double diff = p1 - p2;
-
// normalize to range [-pi..pi]
while (diff > M_PI)
diff -= 2 * M_PI;
-
while (diff < -M_PI)
diff += 2 * M_PI;
-
return diff;
}
-
static double
band_min (const vector<double>& scanned_freq,
const vector<double>& scanned_values,
@@ -57,7 +48,6 @@ band_min (const vector<double>& scanned_freq,
double end_freq)
{
g_assert (scanned_freq.size() == scanned_values.size());
-
bool init = false;
double min_value = 1e19;
for (size_t i = 0; i < scanned_values.size(); i++)
@@ -76,7 +66,6 @@ band_min (const vector<double>& scanned_freq,
g_assert (init);
return min_value;
}
-
static double
band_max (const vector<double>& scanned_freq,
const vector<double>& scanned_values,
@@ -84,7 +73,6 @@ band_max (const vector<double>& scanned_freq,
double end_freq)
{
g_assert (scanned_freq.size() == scanned_values.size());
-
bool init = false;
double max_value = -1e19;
for (size_t i = 0; i < scanned_values.size(); i++)
@@ -103,13 +91,11 @@ band_max (const vector<double>& scanned_freq,
g_assert (init);
return max_value;
}
-
enum FirHandleType
{
FIR_HIGHPASS,
FIR_LOWPASS
};
-
static const char*
handle_name (FirHandleType type)
{
@@ -120,7 +106,6 @@ handle_name (FirHandleType type)
default: g_assert_not_reached();
}
}
-
static void
test_with_sine_sweep (FirHandleType type)
{
@@ -128,14 +113,11 @@ test_with_sine_sweep (FirHandleType type)
vector<float> sweep_sin (50000);
vector<float> sweep_cos (50000);
vector<double> sweep_freq (50000);
-
const double start_freq = 50;
const double end_freq = 24000;
const double mix_freq = 48000;
const double octaves = log (end_freq / start_freq) / log (2);
-
double phase = 0;
-
for (size_t i = 0; i < sweep_sin.size(); i++)
{
sweep_sin[i] = sin (phase);
@@ -145,14 +127,11 @@ test_with_sine_sweep (FirHandleType type)
if (phase > 2.0 * M_PI)
phase -= 2.0 * M_PI;
}
-
GslDataHandle *ihandle_sin = gsl_data_handle_new_mem (1, 32, mix_freq, 440, sweep_sin.size(), &sweep_sin[0], NULL);
GslDataHandle *ihandle_cos = gsl_data_handle_new_mem (1, 32, mix_freq, 440, sweep_cos.size(), &sweep_cos[0], NULL);
-
const int order = 64;
GslDataHandle *fir_handle_sin = NULL;
GslDataHandle *fir_handle_cos = NULL;
-
if (type == FIR_HIGHPASS)
{
fir_handle_sin = bse_data_handle_new_fir_highpass (ihandle_sin, 9000.0, order);
@@ -163,31 +142,25 @@ test_with_sine_sweep (FirHandleType type)
fir_handle_sin = bse_data_handle_new_fir_lowpass (ihandle_sin, 6000.0, order);
fir_handle_cos = bse_data_handle_new_fir_lowpass (ihandle_cos, 6000.0, order);
}
-
BseErrorType error;
error = gsl_data_handle_open (fir_handle_sin);
TASSERT (error == 0);
error = gsl_data_handle_open (fir_handle_cos);
TASSERT (error == 0);
-
GslDataPeekBuffer peek_buffer_sin = { +1 /* incremental direction */, 0, };
GslDataPeekBuffer peek_buffer_cos = { +1 /* incremental direction */, 0, };
-
vector<double> scanned_freq, scanned_level_db, scanned_abs_phase_diff;
-
for (size_t i = ((order + 2) / 2); i < sweep_sin.size() - ((order + 2) / 2); i++)
{
double filtered_sin = gsl_data_handle_peek_value (fir_handle_sin, i, &peek_buffer_sin);
double filtered_cos = gsl_data_handle_peek_value (fir_handle_cos, i, &peek_buffer_cos);
std::complex<double> filtered (filtered_sin, filtered_cos);
-
// compute frequency response
double level = abs (filtered);
double level_db = bse_db_from_factor (level, -200);
scanned_freq.push_back (sweep_freq[i]);
scanned_level_db.push_back (level_db);
// printf ("%f %.17g\n", sweep_freq[i], scanned_level_db.back());
-
if ((i & 15) == 0)
{
// check that theoretical and scanned response match
@@ -196,30 +169,24 @@ test_with_sine_sweep (FirHandleType type)
// printf ("%g %.17g\n", sweep_freq[i], fabs (level - theoretical_level));
TCHECK_CMP (fabs (level - theoretical_level), <, 0.00035);
}
-
// compute phase response
std::complex<double> orig (sweep_sin[i], sweep_cos[i]);
scanned_abs_phase_diff.push_back (fabs (phase_diff (arg (orig), arg (filtered))));
// printf ("%f %.17g\n", sweep_freq[i], scanned_abs_phase_diff.back());
}
-
if (type == FIR_HIGHPASS)
{
// stop band
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 0, 7050), <, -75);
-
// transition band
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 7050, 9500), >, -77);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 7050, 9500), <, -2.8);
-
// passband (1)
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 9500, 11000), >, -2.82);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 9500, 11000), <, -0.002);
-
// passband (2)
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 11000, 24000), >, -0.004);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 11000, 24000), <, 0.002);
-
// zero phase in passband (2)
TASSERT_CMP (band_max (scanned_freq, scanned_abs_phase_diff, 11000, 24000), <, 0.0002);
}
@@ -228,23 +195,18 @@ test_with_sine_sweep (FirHandleType type)
// passband (2)
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 0, 5500), >, -0.002);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 0, 5500), <, 0.002);
-
// passband (1)
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 5500, 7000), >, -1.9);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 5500, 7000), <, -0.001);
-
// transition band
TASSERT_CMP (band_min (scanned_freq, scanned_level_db, 7000, 10000), >, -81);
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 7000, 10000), <, -1.8);
-
// stop band
TASSERT_CMP (band_max (scanned_freq, scanned_level_db, 10000, 24000), <, -75);
-
// zero phase in passband (2)
TASSERT_CMP (band_max (scanned_freq, scanned_abs_phase_diff, 0, 5500), <, 0.00002);
}
TDONE();
-
/* test speed */
double samples_per_second = 0;
if (sfi_init_settings().test_perf)
@@ -252,7 +214,6 @@ test_with_sine_sweep (FirHandleType type)
const guint RUNS = 10;
GTimer *timer = g_timer_new();
const guint dups = TEST_CALIBRATION (50.0, read_through (fir_handle_sin));
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -271,7 +232,6 @@ test_with_sine_sweep (FirHandleType type)
samples_per_second / 44100.0, TUNIT_STREAM);
}
}
-
static double
raised_cosine_fade (int64 pos,
int64 length,
@@ -284,7 +244,6 @@ raised_cosine_fade (int64 pos,
else
return (0.5 - cos (fade_factor * PI) * 0.5);
}
-
static void
test_multi_channel (FirHandleType type)
{
@@ -301,38 +260,30 @@ test_multi_channel (FirHandleType type)
vector<double> expected (input.size());
vector<double> freq (n_channels);
vector<double> phase (n_channels);
-
for (int c = 0; c < n_channels; c++)
freq[c] = test_freqs [g_random_int_range (0, sizeof (test_freqs) / sizeof (test_freqs[0]))];
-
for (size_t i = 0; i < input.size(); i++)
{
const int c = i % n_channels;
const double fade_factor = raised_cosine_fade (i / n_channels, input.size() / n_channels, 500);
const double invalue = sin (phase[c]) * fade_factor;
-
input[i] = invalue;
if ((freq[c] > cutoff_freq && type == FIR_HIGHPASS) || (freq[c] < cutoff_freq && type == FIR_LOWPASS))
expected[i] = invalue;
-
phase[c] += freq[c] / mix_freq * 2.0 * M_PI;
if (phase[c] > 2.0 * M_PI)
phase[c] -= 2.0 * M_PI;
}
-
GslDataHandle *ihandle = gsl_data_handle_new_mem (n_channels, 32, mix_freq, 440, input.size(), &input[0], NULL);
const int order = 116;
GslDataHandle *fir_handle = NULL;
-
if (type == FIR_HIGHPASS)
fir_handle = bse_data_handle_new_fir_highpass (ihandle, cutoff_freq, order);
else
fir_handle = bse_data_handle_new_fir_lowpass (ihandle, cutoff_freq, order);
-
BseErrorType error;
error = gsl_data_handle_open (fir_handle);
TASSERT (error == 0);
-
for (int repeat = 1; repeat <= 2; repeat++)
{
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
@@ -350,7 +301,6 @@ test_multi_channel (FirHandleType type)
}
TDONE();
}
-
static void
test_seek (FirHandleType type)
{
@@ -360,35 +310,27 @@ test_seek (FirHandleType type)
const double mix_freq = 48000;
const double cutoff_freq = 11000;
const int order = 28;
-
vector<float> input (1 * 2 * 3 * 3000); // can be divided by n_channels
vector<float> output (input.size());
-
for (size_t i = 0; i < input.size(); i++)
input[i] = g_random_int_range (-1, 1);
-
GslDataHandle *ihandle = gsl_data_handle_new_mem (n_channels, 32, mix_freq, 440, input.size(), &input[0], NULL);
GslDataHandle *fir_handle = NULL;
-
if (type == FIR_HIGHPASS)
fir_handle = bse_data_handle_new_fir_highpass (ihandle, cutoff_freq, order);
else
fir_handle = bse_data_handle_new_fir_lowpass (ihandle, cutoff_freq, order);
-
BseErrorType error;
error = gsl_data_handle_open (fir_handle);
TASSERT (error == 0);
-
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
for (size_t i = 0; i < output.size(); i++)
output[i] = gsl_data_handle_peek_value (fir_handle, i, &peek_buffer);
-
for (int t = 0; t < 400; t++)
{
int64 start = rand() % fir_handle->setup.n_values;
int64 len = rand() % 1024;
len = min (fir_handle->setup.n_values - start, len);
-
float values[1024];
int64 offset = 0;
int64 values_todo = len;
@@ -400,31 +342,24 @@ test_seek (FirHandleType type)
values_todo -= l;
offset += l;
}
-
for (size_t i = 0; i < len; i++)
TCHECK (values[i] == output[i + start]);
-
if (t % 40 == 0)
TOK();
}
}
TDONE();
}
-
-
int
main (int argc,
char **argv)
{
bse_init_test (&argc, &argv, NULL);
-
test_with_sine_sweep (FIR_HIGHPASS);
test_multi_channel (FIR_HIGHPASS);
test_seek (FIR_HIGHPASS);
-
test_with_sine_sweep (FIR_LOWPASS);
test_multi_channel (FIR_LOWPASS);
test_seek (FIR_LOWPASS);
-
return 0;
}
diff --git a/bse/tests/loophandle.cc b/bse/tests/loophandle.cc
index cfb112d..234ca0a 100644
--- a/bse/tests/loophandle.cc
+++ b/bse/tests/loophandle.cc
@@ -4,7 +4,6 @@
#include <bse/bse.hh>
#include <bse/bsemain.hh>
#include <stdlib.h>
-
/* --- loop handle: reference code --- */
typedef struct {
GslDataHandle dhandle;
@@ -14,18 +13,15 @@ typedef struct {
GslLong loop_start;
GslLong loop_width;
} LoopHandleReference;
-
static BseErrorType
loop_handle_reference_open (GslDataHandle *dhandle,
GslDataHandleSetup *setup)
{
LoopHandleReference *lhandle = (LoopHandleReference*) dhandle;
BseErrorType error;
-
error = gsl_data_handle_open (lhandle->src_handle);
if (error != BSE_ERROR_NONE)
return error;
-
*setup = lhandle->src_handle->setup; /* copies setup.xinfos by pointer */
if (setup->n_values > lhandle->requested_last)
{
@@ -38,30 +34,23 @@ loop_handle_reference_open (GslDataHandle *dhandle,
lhandle->loop_start = setup->n_values;
lhandle->loop_width = 0;
}
-
return BSE_ERROR_NONE;
}
-
static void
loop_handle_reference_close (GslDataHandle *dhandle)
{
LoopHandleReference *lhandle = (LoopHandleReference*) dhandle;
-
dhandle->setup.xinfos = NULL; /* cleanup pointer reference */
gsl_data_handle_close (lhandle->src_handle);
}
-
static void
loop_handle_reference_destroy (GslDataHandle *dhandle)
{
LoopHandleReference *lhandle = (LoopHandleReference*) dhandle;
-
gsl_data_handle_unref (lhandle->src_handle);
-
gsl_data_handle_common_free (dhandle);
sfi_delete_struct (LoopHandleReference, lhandle);
}
-
static GslLong
loop_handle_reference_read (GslDataHandle *dhandle,
GslLong voffset,
@@ -69,7 +58,6 @@ loop_handle_reference_read (GslDataHandle *dhandle,
gfloat *values)
{
LoopHandleReference *lhandle = (LoopHandleReference*) dhandle;
-
if (voffset < lhandle->loop_start)
return gsl_data_handle_read (lhandle->src_handle, voffset,
MIN (lhandle->loop_start - voffset, n_values),
@@ -77,24 +65,19 @@ loop_handle_reference_read (GslDataHandle *dhandle,
else
{
GslLong noffset = voffset - lhandle->loop_start;
-
noffset %= lhandle->loop_width;
-
return gsl_data_handle_read (lhandle->src_handle,
lhandle->loop_start + noffset,
MIN (lhandle->loop_width - noffset, n_values),
values);
}
}
-
static int64
loop_handle_reference_get_state_length (GslDataHandle *dhandle)
{
LoopHandleReference *lhandle = (LoopHandleReference*) dhandle;
return gsl_data_handle_get_state_length (lhandle->src_handle);
}
-
-
static GslDataHandle*
gsl_data_handle_new_looped_reference (GslDataHandle *src_handle,
GslLong loop_first,
@@ -110,11 +93,9 @@ gsl_data_handle_new_looped_reference (GslDataHandle *src_handle,
};
LoopHandleReference *lhandle;
gboolean success;
-
g_return_val_if_fail (src_handle != NULL, NULL);
g_return_val_if_fail (loop_first >= 0, NULL);
g_return_val_if_fail (loop_last >= loop_first, NULL);
-
lhandle = sfi_new_struct0 (LoopHandleReference, 1);
success = gsl_data_handle_common_init (&lhandle->dhandle, NULL);
if (success)
@@ -134,10 +115,8 @@ gsl_data_handle_new_looped_reference (GslDataHandle *src_handle,
}
return &lhandle->dhandle;
}
-
const guint n_channels = 2;
const guint n_values = 4096;
-
static void
check_loop (GslDataHandle *src_handle,
GslLong loop_start,
@@ -147,14 +126,11 @@ check_loop (GslDataHandle *src_handle,
g_return_if_fail (loop_start < n_values);
g_return_if_fail (loop_end > loop_start);
g_return_if_fail (loop_end < n_values);
-
GslDataHandle *loop_handle = gsl_data_handle_new_looped (src_handle, loop_start, loop_end);
GslDataHandle *loop_handle_reference = gsl_data_handle_new_looped_reference (src_handle, loop_start, loop_end);
-
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
GslDataPeekBuffer peek_buffer_reference = { +1 /* incremental direction */, 0, };
sfi_info ("check_loop<%lld,%lld>", loop_start, loop_end);
-
BseErrorType error;
error = gsl_data_handle_open (loop_handle);
if (error)
@@ -162,20 +138,17 @@ check_loop (GslDataHandle *src_handle,
sfi_error ("loop_handle open failed: %s", bse_error_blurb (error));
exit (1);
}
-
error = gsl_data_handle_open (loop_handle_reference);
if (error)
{
sfi_error ("loop_handle_reference open failed: %s", bse_error_blurb (error));
exit (1);
}
-
GslLong i;
for (i = 0; i < n_values * 10; i++)
{
gfloat a = gsl_data_handle_peek_value (loop_handle, i, &peek_buffer);
gfloat b = gsl_data_handle_peek_value (loop_handle_reference, i, &peek_buffer_reference);
-
if (a != b)
{
sfi_error ("bad read in loop<%lld,%lld> position %lld: a = %f, b = %f", loop_start, loop_end, i, a, b);
@@ -187,20 +160,16 @@ check_loop (GslDataHandle *src_handle,
gsl_data_handle_unref (loop_handle);
gsl_data_handle_unref (loop_handle_reference);
}
-
int
main (int argc, char **argv)
{
gfloat values[n_values * n_channels];
-
guint i;
for (i = 0; i < n_channels * n_values; i++)
values[i] = 1.0 - rand() / (0.5 * RAND_MAX);
-
/* init bse */
bse_init_test (&argc, &argv, NULL);
sfi_msg_allow ("misc");
-
/* test loophandle against the reference implementation */
GslDataHandle *mem_handle = gsl_data_handle_new_mem (n_channels, 32, 44100, 440, n_values, values, NULL /* don't free */);
check_loop (mem_handle, 0, n_values - 1);
diff --git a/bse/tests/misctests.cc b/bse/tests/misctests.cc
index a9ffbbf..e0d478e 100644
--- a/bse/tests/misctests.cc
+++ b/bse/tests/misctests.cc
@@ -4,9 +4,7 @@
#include <sfi/sfitests.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsecxxplugin.hh> // for generated types
-
#define FLF "26.20"
-
static void
check_cent_tune_fast (void)
{
@@ -21,7 +19,6 @@ check_cent_tune_fast (void)
}
TDONE();
}
-
static void
check_cent_tune (void)
{
@@ -37,7 +34,6 @@ check_cent_tune (void)
}
TDONE();
}
-
static void
check_equal_tempered_tuning (void)
{
@@ -53,7 +49,6 @@ check_equal_tempered_tuning (void)
}
TDONE();
}
-
static void
check_tuning_monotony (BseMusicalTuningType musical_tuning)
{
@@ -69,7 +64,6 @@ check_tuning_monotony (BseMusicalTuningType musical_tuning)
}
TDONE();
}
-
static void
check_freq_vs_notes (BseMusicalTuningType musical_tuning)
{
@@ -105,21 +99,17 @@ check_freq_vs_notes (BseMusicalTuningType musical_tuning)
}
TDONE();
}
-
int
main (gint argc,
gchar *argv[])
{
bse_init_test (&argc, &argv, NULL);
-
check_cent_tune();
check_cent_tune_fast();
check_equal_tempered_tuning();
-
BseMusicalTuningType last_tuning = BSE_MUSICAL_TUNING_YOUNG;
/* check last tuning value by asserting defaulting behavior of succeding values */
TCHECK (bse_semitone_table_from_tuning (BseMusicalTuningType (last_tuning + 1)) == bse_semitone_table_from_tuning (BseMusicalTuningType (0)));
-
/* check monotonic musical tuning systems */
for (int j = BSE_MUSICAL_TUNING_12_TET; j <= last_tuning; j++)
{
@@ -128,6 +118,5 @@ main (gint argc,
check_tuning_monotony (musical_tuning);
check_freq_vs_notes (musical_tuning);
}
-
return 0;
}
diff --git a/bse/tests/resamplehandle.cc b/bse/tests/resamplehandle.cc
index 2071690..5c4a2a7 100644
--- a/bse/tests/resamplehandle.cc
+++ b/bse/tests/resamplehandle.cc
@@ -9,19 +9,16 @@
#include <vector>
#include <string>
#include <map>
-
using std::vector;
using std::string;
using std::max;
using std::min;
using std::map;
-
static void
read_through (GslDataHandle *handle)
{
int64 n_values = gsl_data_handle_n_values (handle);
int64 offset = 0;
-
while (offset < n_values)
{
gfloat values[1024];
@@ -29,10 +26,8 @@ read_through (GslDataHandle *handle)
g_assert (values_read > 0);
offset += values_read;
}
-
g_assert (offset == n_values);
}
-
static double
check (const char *up_down,
const char *channels,
@@ -48,9 +43,7 @@ check (const char *up_down,
char *samplestr = g_strdup_printf ("ResampleHandle-%s%02d%s", up_down, bits, channels);
char *streamstr = g_strdup_printf ("CPU Resampling %s%02d%s", up_down, bits, channels);
TSTART ("%s (%s)", samplestr, cpu_type);
-
TASSERT (input.size() % n_channels == 0);
-
GslDataHandle *ihandle = gsl_data_handle_new_mem (n_channels, 32, 44100, 440, input.size(), &input[0], NULL);
GslDataHandle *rhandle;
if (resampler_mode == BSE_RESAMPLER2_MODE_UPSAMPLE)
@@ -64,12 +57,9 @@ check (const char *up_down,
rhandle = bse_data_handle_new_downsample2 (ihandle, precision_bits);
}
gsl_data_handle_unref (ihandle);
-
BseErrorType error = gsl_data_handle_open (rhandle);
TASSERT (error == 0);
-
double worst_diff, worst_diff_db;
-
/* Read through the datahandle linearily _twice_, and compare expected output
* with actual output, to determine whether the actual output is correct.
*
@@ -96,7 +86,6 @@ check (const char *up_down,
TPRINT ("linear(%dst read) read worst_diff = %f (%f dB)\n", repeat, worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
}
-
/* test seeking */
worst_diff = 0.0;
const uint count = sfi_init_settings().test_slow ? 300 : 100;
@@ -104,7 +93,6 @@ check (const char *up_down,
{
int64 start = rand() % rhandle->setup.n_values;
int64 len = rand() % 1024;
-
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
for (int64 i = start; i < std::min (start + len, rhandle->setup.n_values); i++)
{
@@ -115,9 +103,7 @@ check (const char *up_down,
worst_diff_db = bse_db_from_factor (worst_diff, -200);
TPRINT ("seek worst_diff = %f (%f dB)\n", worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
-
TDONE();
-
/* test speed */
double samples_per_second = 0;
if (sfi_init_settings().test_perf)
@@ -125,7 +111,6 @@ check (const char *up_down,
const guint RUNS = 10;
GTimer *timer = g_timer_new();
const guint dups = TEST_CALIBRATION (50.0, read_through (rhandle));
-
double m = 9e300;
for (guint i = 0; i < RUNS; i++)
{
@@ -144,16 +129,12 @@ check (const char *up_down,
//TPRINT (" which means the resampler can process %.2f 44100 Hz streams simultaneusly\n", samples_per_second / 44100.0);
//TPRINT (" or one 44100 Hz stream takes %f %% CPU usage\n", 100.0 / (samples_per_second / 44100.0));
}
-
gsl_data_handle_close (rhandle);
gsl_data_handle_unref (rhandle);
-
g_free (samplestr);
g_free (streamstr);
-
return samples_per_second / 44100.0;
}
-
template<typename Sample> static void
generate_test_signal (vector<Sample> &signal,
const size_t signal_length,
@@ -166,25 +147,21 @@ generate_test_signal (vector<Sample> &signal,
if (cached_window.empty())
{
cached_window.resize (signal_length);
-
for (size_t i = 0; i < signal_length; i++)
{
double wpos = (i * 2 - double (signal_length)) / signal_length;
cached_window[i] = bse_window_blackman (wpos);
}
}
-
string signal_cache_key = Birnet::string_printf ("%zd/%.1f/%.1f/%.1f", signal_length, sample_rate, frequency1, frequency2);
static map<string, vector<Sample> > signal_cache;
vector<Sample>& cached_signal = signal_cache[signal_cache_key];
-
if (cached_signal.empty())
{
for (size_t i = 0; i < signal_length; i++)
{
double phase1 = i * 2 * M_PI * frequency1 / sample_rate;
cached_signal.push_back (sin (phase1) * cached_window[i]);
-
if (frequency2 > 0) /* stereo */
{
double phase2 = i * 2 * M_PI * frequency2 / sample_rate;
@@ -194,7 +171,6 @@ generate_test_signal (vector<Sample> &signal,
}
signal = cached_signal;
}
-
static void
run_tests (const char *run_type)
{
@@ -213,13 +189,11 @@ run_tests (const char *run_type)
{ 24, -125, -125, -134, -131 },
{ 0, 0, 0 }
};
-
for (int p = 0; params[p].bits; p++)
{
const int LEN = 44100 / 2; /* 500ms test signal */
vector<float> input;
vector<double> expected;
-
// mono upsampling test
if (!sfi_init_settings().test_quick)
{
@@ -230,7 +204,6 @@ run_tests (const char *run_type)
params[p].bits, params[p].mono_upsample_db);
// g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
}
-
// stereo upsampling test
if (1)
{
@@ -241,7 +214,6 @@ run_tests (const char *run_type)
params[p].bits, params[p].stereo_upsample_db);
// g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
}
-
// mono downsampling test
if (!sfi_init_settings().test_quick)
{
@@ -252,7 +224,6 @@ run_tests (const char *run_type)
params[p].bits, params[p].mono_downsample_db);
// g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
}
-
// stereo downsampling test
if (1)
{
@@ -265,7 +236,6 @@ run_tests (const char *run_type)
}
}
}
-
static void
test_c_api (const char *run_type)
{
@@ -276,12 +246,9 @@ test_c_api (const char *run_type)
float out[OUTPUT_SIZE];
double error = 0;
int i;
-
for (i = 0; i < INPUT_SIZE; i++)
in[i] = sin (i * 440 * 2 * M_PI / 44100) * bse_window_blackman ((double) (i * 2 - INPUT_SIZE) / INPUT_SIZE);
-
bse_resampler2_process_block (resampler, in, INPUT_SIZE, out);
-
int delay = bse_resampler2_delay (resampler);
for (i = 0; i < 2048; i++)
{
@@ -289,16 +256,12 @@ test_c_api (const char *run_type)
* bse_window_blackman ((double) ((i - delay) * 2 - OUTPUT_SIZE) / OUTPUT_SIZE);
error = MAX (error, fabs (out[i] - expected));
}
-
double error_db = bse_db_from_factor (error, -200);
-
bse_resampler2_destroy (resampler);
-
TPRINT ("Test C API delta: %f\n", error_db);
TASSERT (error_db < -95);
TDONE();
}
-
static void
test_delay_compensation (const char *run_type)
{
@@ -320,32 +283,25 @@ test_delay_compensation (const char *run_type)
{ 134, BSE_RESAMPLER2_MODE_DOWNSAMPLE, BSE_RESAMPLER2_PREC_144DB },
{ -1, }
};
-
using Bse::Resampler::Resampler2;
TSTART ("Resampler Delay Compensation (%s)", run_type);
-
for (guint p = 0; params[p].error_db > 0; p++)
{
/* setup test signal and empty output signal space */
const int INPUT_SIZE = 44100 * 4, OUTPUT_SIZE = INPUT_SIZE * 2;
-
vector<float> in (INPUT_SIZE);
vector<float> out (OUTPUT_SIZE);
-
generate_test_signal (in, INPUT_SIZE, 44100, 440);
-
/* up/downsample test signal */
Resampler2 *resampler = Resampler2::create (params[p].mode,
params[p].precision);
resampler->process_block (&in[0], INPUT_SIZE, &out[0]);
-
/* setup increments for comparision loop */
size_t iinc = 1, jinc = 1;
if (params[p].mode == BSE_RESAMPLER2_MODE_UPSAMPLE)
jinc = 2;
else
iinc = 2;
-
/* compensate resampler delay by incrementing comparision start offset */
double delay = resampler->delay();
size_t i = 0, j = (int) round (delay * 2);
@@ -357,7 +313,6 @@ test_delay_compensation (const char *run_type)
j += 2;
}
j /= 2;
-
/* actually compare source and resampled signal (one with a stepping of 2) */
double error = 0;
while (i < in.size() && j < out.size())
@@ -365,9 +320,7 @@ test_delay_compensation (const char *run_type)
error = MAX (error, fabs (out[j] - in[i]));
i += iinc; j += jinc;
}
-
delete resampler;
-
/* check error against bound */
double error_db = bse_db_from_factor (error, -250);
TPRINT ("Resampler Delay Compensation delta: %f\n", error_db);
@@ -375,18 +328,15 @@ test_delay_compensation (const char *run_type)
}
TDONE();
}
-
static void
test_state_length (const char *run_type)
{
TSTART ("Resampler State Length Info (%s)", run_type);
-
//-----------------------------------------------------------------------------------
// usampling
//-----------------------------------------------------------------------------------
{
const guint period_size = 107;
-
/* fill input with 2 periods of a sine wave, so that while at the start and
* at the end clicks occur (because the unwindowed signal is assumed to 0 by
* the resamplehandle), in the middle 1 period can be found that is clickless
@@ -394,17 +344,14 @@ test_state_length (const char *run_type)
vector<float> input (period_size * 2);
for (size_t i = 0; i < input.size(); i++)
input[i] = sin (i * 2 * M_PI / period_size);
-
const guint precision_bits = 16;
GslDataHandle *ihandle = gsl_data_handle_new_mem (1, 32, 44100, 440, input.size(), &input[0], NULL);
GslDataHandle *rhandle = bse_data_handle_new_upsample2 (ihandle, precision_bits);
BseErrorType open_error = gsl_data_handle_open (rhandle);
TASSERT (open_error == 0);
TASSERT (gsl_data_handle_get_state_length (ihandle) == 0);
-
// determine how much of the end of the signal is "unusable" due to the resampler state:
const int64 state_length = gsl_data_handle_get_state_length (rhandle);
-
/* read resampled signal in the range unaffected by the resampler state (that
* is: not at the directly at the beginning, and not directly at the end)
*/
@@ -428,14 +375,11 @@ test_state_length (const char *run_type)
double error_db = bse_db_from_factor (error, -200);
TASSERT (error_db < -97);
}
-
//-----------------------------------------------------------------------------------
// downsampling
//-----------------------------------------------------------------------------------
-
{
const guint period_size = 190;
-
/* fill input with 2 periods of a sine wave, so that while at the start and
* at the end clicks occur (because the unwindowed signal is assumed to 0 by
* the resamplehandle), in the middle 1 period can be found that is clickless
@@ -443,17 +387,14 @@ test_state_length (const char *run_type)
vector<float> input (period_size * 2);
for (size_t i = 0; i < input.size(); i++)
input[i] = sin (i * 2 * M_PI / period_size);
-
const guint precision_bits = 16;
GslDataHandle *ihandle = gsl_data_handle_new_mem (1, 32, 44100, 440, input.size(), &input[0], NULL);
GslDataHandle *rhandle = bse_data_handle_new_downsample2 (ihandle, precision_bits);
BseErrorType open_error = gsl_data_handle_open (rhandle);
TASSERT (open_error == 0);
TASSERT (gsl_data_handle_get_state_length (ihandle) == 0);
-
// determine how much of the end of the signal is "unusable" due to the resampler state:
const int64 state_length = gsl_data_handle_get_state_length (rhandle);
-
/* read resampled signal in the range unaffected by the resampler state (that
* is: not at the directly at the beginning, and not directly at the end)
*/
@@ -479,8 +420,6 @@ test_state_length (const char *run_type)
}
TDONE();
}
-
-
int
main (int argc,
char *argv[])
@@ -492,12 +431,10 @@ main (int argc,
treport_cpu_name (cname);
g_free (cname);
}
-
test_c_api ("FPU");
test_delay_compensation ("FPU");
test_state_length ("FPU");
run_tests ("FPU");
-
/* load plugins */
SfiInitValue config[] = {
{ "load-core-plugins", "1" },
@@ -507,11 +444,9 @@ main (int argc,
/* check for possible specialization */
if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
return 0; /* nothing changed */
-
test_c_api ("SSE");
test_delay_compensation ("SSE");
test_state_length ("SSE");
run_tests ("SSE");
-
return 0;
}
diff --git a/bse/tests/subnormals-aux.cc b/bse/tests/subnormals-aux.cc
index a6eb5a3..00d1dec 100644
--- a/bse/tests/subnormals-aux.cc
+++ b/bse/tests/subnormals-aux.cc
@@ -1,33 +1,28 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.hh>
#include <bse/bseieee754.hh>
-
float
test1f (float v)
{
return v;
}
-
float
test2f (float v)
{
return bse_float_zap_denormal (v);
}
-
float
test3f (float v)
{
BSE_FLOAT_FLUSH_with_cond (v);
return v;
}
-
float
test4f (float v)
{
BSE_FLOAT_FLUSH_with_if (v);
return v;
}
-
float
test5f (float v)
{
diff --git a/bse/tests/subnormals.cc b/bse/tests/subnormals.cc
index 6ded40a..2a8bb36 100644
--- a/bse/tests/subnormals.cc
+++ b/bse/tests/subnormals.cc
@@ -8,7 +8,6 @@
#ifdef __SSE__
#include <xmmintrin.h>
#endif
-
#if 1
inline float test1f (float v) { return v; }
inline float test2f (float v) { return bse_float_zap_denormal (v); }
@@ -22,12 +21,10 @@ extern float test3f (float v);
extern float test4f (float v);
extern float test5f (float v);
#endif
-
inline double test2d (double v) { return bse_double_zap_denormal (v); }
inline double test3d (double v) { BSE_DOUBLE_FLUSH_with_cond (v); return v; }
inline double test4d (double v) { BSE_DOUBLE_FLUSH_with_if (v); return v; }
inline double test5d (double v) { BSE_DOUBLE_FLUSH_with_threshold (v); return v; }
-
template<float Func (float)> void
test_correct_subnormal_elimination (const char* algo_name)
{
@@ -37,20 +34,16 @@ test_correct_subnormal_elimination (const char* algo_name)
{
float value = BSE_FLOAT_MAX_SUBNORMAL * i / n;
g_assert (BSE_FLOAT_IS_SUBNORMAL (value));
-
float normalized_positive_value = Func (value);
g_assert (!BSE_FLOAT_IS_SUBNORMAL (normalized_positive_value));
-
float normalized_negative_value = Func (-value);
g_assert (!BSE_FLOAT_IS_SUBNORMAL (normalized_negative_value));
-
if (i % 100000 == 0)
TOK();
}
TOK();
TDONE();
}
-
template<double Func (double)> void
test_correct_subnormal_elimination (const char* algo_name)
{
@@ -60,38 +53,29 @@ test_correct_subnormal_elimination (const char* algo_name)
{
double value = BSE_DOUBLE_MAX_SUBNORMAL * i / n;
g_assert (BSE_DOUBLE_IS_SUBNORMAL (value));
-
double normalized_positive_value = Func (value);
g_assert (!BSE_DOUBLE_IS_SUBNORMAL (normalized_positive_value));
-
double normalized_negative_value = Func (-value);
g_assert (!BSE_DOUBLE_IS_SUBNORMAL (normalized_negative_value));
-
if (i % 100000 == 0)
TOK();
}
TOK();
TDONE();
}
-
static void
benchmark_subnormal_eliminations ()
{
const float max_sub = BSE_FLOAT_MAX_SUBNORMAL;
-
TSTART ("Subnormal Cancellation Benchmark");
-
float n = 10 * 1000000;
float sum;
GTimer *timer = g_timer_new();
volatile double volatile_accu = 0;
-
int j;
const int blen = 4096;
volatile float buffer[blen];
-
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -106,7 +90,6 @@ benchmark_subnormal_eliminations ()
g_timer_stop (timer);
float test1_time = g_timer_elapsed (timer, NULL);
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -121,7 +104,6 @@ benchmark_subnormal_eliminations ()
g_timer_stop (timer);
float test2_time = g_timer_elapsed (timer, NULL);
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -136,7 +118,6 @@ benchmark_subnormal_eliminations ()
g_timer_stop (timer);
float test3_time = g_timer_elapsed (timer, NULL);
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -151,7 +132,6 @@ benchmark_subnormal_eliminations ()
g_timer_stop (timer);
float test4_time = g_timer_elapsed (timer, NULL);
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -166,7 +146,6 @@ benchmark_subnormal_eliminations ()
g_timer_stop (timer);
float test5_time = g_timer_elapsed (timer, NULL);
TOK();
-
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -185,7 +164,6 @@ benchmark_subnormal_eliminations ()
float test6_time = g_timer_elapsed (timer, NULL);
TOK();
TDONE();
-
if (0)
g_print ("subnormal cancellation times: keep=%fs zap=%fs inlined-cond=%fs if-cond=%fs arithmetic=%f bse=%f\n",
test1_time, test2_time, test3_time, test4_time, test5_time, test6_time);
@@ -196,7 +174,6 @@ benchmark_subnormal_eliminations ()
treport_minimized ("Subnormals-arithmetic", test5_time, TUNIT_SECOND);
treport_minimized ("Subnormals-bse-flush", test6_time, TUNIT_SECOND);
}
-
bool
check_denormals_are_zero()
{
@@ -204,23 +181,19 @@ check_denormals_are_zero()
if (_MM_GET_FLUSH_ZERO_MODE() == _MM_FLUSH_ZERO_ON)
{
const int MM_DENORMALS_ARE_ZERO = 0x40;
-
if (_mm_getcsr() & MM_DENORMALS_ARE_ZERO)
{
return true;
}
}
#endif
-
return false;
}
-
int
main (int argc,
char *argv[])
{
bse_init_test (&argc, &argv, NULL);
-
g_printerr ("Checking if your processor is in 'denormals are zero' (DAZ) mode... ");
bool daz_mode = check_denormals_are_zero();
g_printerr (daz_mode ? "yes - skipping subnormal elimination tests.\n" : "no.\n");
@@ -230,15 +203,12 @@ main (int argc,
test_correct_subnormal_elimination<test3f> ("inlined-cond");
test_correct_subnormal_elimination<test4f> ("if-cond");
test_correct_subnormal_elimination<test5f> ("arithmetic");
-
test_correct_subnormal_elimination<test2d> ("zap-double");
test_correct_subnormal_elimination<test3d> ("inlined-cond-double");
test_correct_subnormal_elimination<test4d> ("if-cond-double");
test_correct_subnormal_elimination<test5d> ("arithmetic-double");
}
-
if (sfi_init_settings().test_perf)
benchmark_subnormal_eliminations();
-
return 0;
}
diff --git a/bse/tests/testcxx.cc b/bse/tests/testcxx.cc
index c46698d..1e1524e 100644
--- a/bse/tests/testcxx.cc
+++ b/bse/tests/testcxx.cc
@@ -2,12 +2,9 @@
#include <bse/bsecxxbase.hh>
#include <bse/bsemain.hh>
#include <bse/bsebusmodule.genidl.hh>
-
namespace {
using namespace Bse;
-
struct FooTest : public CxxBase {};
-
struct Foo {
void bar (GParamSpec *p,int,float,int,int,int,int,int)
{
@@ -19,9 +16,7 @@ struct Foo {
return 0;
}
};
-
} // namespace
-
int
main (int argc,
char *argv[])
@@ -30,11 +25,9 @@ main (int argc,
bse_init_test (&argc, &argv, NULL);
std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
// g_log_set_always_fatal ((GLogLevelFlags) (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | (int) g_log_set_always_fatal ((GLogLevelFlags) G_LOG_FATAL_MASK)));
-
/* work around known C++ binding bugs (critical warnings from GClosure) */
unsigned int flags = g_log_set_always_fatal ((GLogLevelFlags) G_LOG_FATAL_MASK);
g_log_set_always_fatal ((GLogLevelFlags) (flags & ~(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)));
-
// test closure Arg types
Arg<FooTest*> a1;
a1.token();
@@ -45,17 +38,14 @@ main (int argc,
Arg<BseSource*> a5;
a5.token();
// tokenize_gtype (0);
-
#if 0 // produce template error
Arg<int**> errorarg;
errorarg.token();
#endif
-
GObject *o = (GObject*) g_object_new (BSE_TYPE_BUS_MODULE, NULL);
CxxBase *b = cast (o);
Foo f;
b->connect ("notify", Closure (&f, &Foo::bar));
b->connect ("notify", Closure (&f, &Foo::baz));
-
return 0;
}
diff --git a/bse/tests/testfft.cc b/bse/tests/testfft.cc
index 391c7e2..ab2ec11 100644
--- a/bse/tests/testfft.cc
+++ b/bse/tests/testfft.cc
@@ -8,14 +8,11 @@
#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
-
#define MAX_FFT_SIZE (65536 * 2) // * 8 * 8
#define MAX_DFT_SIZE (1024 * 2) // * 8 * 8
#define EPSILON (4.8e-6)
-
#define REF_ANALYSIS (-1)
#define REF_SYNTHESIS (1)
-
/* --- prototypes --- */
static void reference_power2_fftc (unsigned int n_values,
const double *rivalues_in,
@@ -39,9 +36,6 @@ static void make_real (guint n,
static void extract_real (guint n,
const double *a,
double *b);
-
-
-
/* --- functions --- */
int
main (int argc,
@@ -49,14 +43,11 @@ main (int argc,
{
struct timeval tv;
guint i;
-
/* initialize */
bse_init_test (&argc, &argv, NULL);
-
/* initialize random numbers */
gettimeofday (&tv, NULL);
srand (tv.tv_sec ^ tv.tv_usec);
-
static double ref_fft_in[MAX_FFT_SIZE] = { 0, };
static double ref_fft_aout[MAX_FFT_SIZE] = { 0, };
static double ref_fft_sout[MAX_FFT_SIZE] = { 0, };
@@ -66,14 +57,11 @@ main (int argc,
static double work_fft_sout[MAX_FFT_SIZE] = { 0, };
static double work_fft_back[MAX_FFT_SIZE] = { 0, };
static double scaled_fft_back[MAX_FFT_SIZE] = { 0, };
-
/* run tests */
for (i = 8; i <= MAX_FFT_SIZE >> 1; i <<= 1)
{
double d;
-
TSTART ("Testing fft code for size %u", i);
-
/* setup reference and work fft records */
fill_rand (i << 1, ref_fft_in);
// memset (ref_fft_aout, 0, MAX_FFT_SIZE * sizeof (ref_fft_aout[0]));
@@ -87,14 +75,12 @@ main (int argc,
reference_power2_fftc (i, ref_fft_in, ref_fft_sout, REF_SYNTHESIS);
reference_power2_fftc (i, ref_fft_aout, ref_fft_back, REF_SYNTHESIS);
scale_block (i << 1, ref_fft_back, 1.0 / i);
-
/* perform fft test */
gsl_power2_fftac (i, work_fft_in, work_fft_aout);
gsl_power2_fftsc (i, work_fft_in, work_fft_sout);
gsl_power2_fftsc (i, work_fft_aout, work_fft_back);
scale_block (i << 1, work_fft_back, 1.0 / i);
gsl_power2_fftsc_scale (i, work_fft_aout, scaled_fft_back);
-
/* check differences */
d = diff (i << 1, 0, ref_fft_in, work_fft_in, "Checking input record");
if (d)
@@ -136,77 +122,60 @@ main (int argc,
TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
-
/* test with real data */
make_real (i << 1, ref_fft_in);
extract_real (i << 1, ref_fft_in, work_fft_in);
reference_power2_fftc (i, ref_fft_in, ref_fft_aout, REF_ANALYSIS);
ref_fft_aout[1] = ref_fft_aout[i]; /* special packing for purely real FFTs */
-
/* perform real fft test */
gsl_power2_fftar (i, work_fft_in, work_fft_aout);
gsl_power2_fftsr (i, work_fft_aout, work_fft_back);
scale_block (i, work_fft_back, 1.0 / i);
gsl_power2_fftsr_scale (i, work_fft_aout, scaled_fft_back);
-
d = diff (i, 0, ref_fft_aout, work_fft_aout, "Reference real analysis vs. real GSL");
if (fabs (d) > EPSILON)
TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
-
d = diff (i, 0, work_fft_in, scaled_fft_back, "Real input vs. scaled real GSL resynthesis");
if (fabs (d) > EPSILON)
TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
-
d = diff (i, 0, work_fft_in, work_fft_back, "Real input vs. real GSL resynthesis");
if (fabs (d) > EPSILON)
TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
-
TDONE();
}
-
static double dft_in[MAX_DFT_SIZE] = { 0, };
static double dft_aout[MAX_DFT_SIZE] = { 0, };
-
/* test reference fft against reference dft */
for (i = 2; i <= MAX_DFT_SIZE >> 1; i <<= 1)
{
double d;
-
TSTART ("Checking reference fft for size %u", i);
-
/* setup reference and work fft records */
fill_rand (i << 1, ref_fft_in);
memcpy (dft_in, ref_fft_in, MAX_DFT_SIZE * sizeof (dft_in[0]));
-
reference_power2_fftc (i, ref_fft_in, ref_fft_aout, REF_ANALYSIS);
reference_dftc (i, dft_in, dft_aout);
-
-
/* check differences */
d = diff (i << 1, 0, ref_fft_in, dft_in, "Checking input record");
if (d)
TERROR ("Input record was modified");
else
TOK();
-
d = diff (i << 1, 0, ref_fft_aout, dft_aout, "Reference FFT analysis against reference DFT analysis");
if (fabs (d) > EPSILON)
TERROR ("Error sum in analysis FFT exceeds epsilon: %g > %g", d, EPSILON);
else
TOK();
-
TDONE();
}
-
return 0;
}
-
static void
fill_rand (guint n,
double *a)
@@ -214,7 +183,6 @@ fill_rand (guint n,
while (n--)
a[n] = -1. + 2. * rand() / (RAND_MAX + 1.0);
}
-
static void
make_real (guint n,
double *a)
@@ -223,7 +191,6 @@ make_real (guint n,
for (x = 1; x < n; x += 2)
a[x] = 0; /* eliminate complex part */
}
-
static void
extract_real (guint n,
const double *a,
@@ -233,8 +200,6 @@ extract_real (guint n,
for (x = 0; x < n; x += 2)
*b++ = a[x]; /* extract real part */
}
-
-
static void
scale_block (guint n,
double *a,
@@ -243,7 +208,6 @@ scale_block (guint n,
while (n--)
a[n] *= factor;
}
-
static double
diff (guint m,
guint p,
@@ -253,7 +217,6 @@ diff (guint m,
{
double d = 0, max = 0, min = 1e+32;
guint n;
-
TPRINT ("%s\n", str);
for (n = 0; n < m; n++)
{
@@ -276,8 +239,6 @@ diff (guint m,
g_bit_storage (1. / max));
return d;
}
-
-
/* --- fft implementation --- */
#define BUTTERFLY_XY(X1re,X1im,X2re,X2im,Y1re,Y1im,Y2re,Y2im,Wre,Wim) { \
register double T1re, T1im, T2re, T2im; \
@@ -343,7 +304,6 @@ diff (guint m,
Wre += T1re; \
Wim += T1im; \
}
-
static inline void
reference_bitreverse_fft2analysis (const unsigned int n,
const double *X,
@@ -351,7 +311,6 @@ reference_bitreverse_fft2analysis (const unsigned int n,
{
const unsigned int n2 = n >> 1, n1 = n + n2, max = n >> 2;
unsigned int i, r;
-
BUTTERFLY_10 (X[0], X[1],
X[n], X[n + 1],
Y[0], Y[1],
@@ -369,14 +328,12 @@ reference_bitreverse_fft2analysis (const unsigned int n,
for (i = 1, r = 0; i < max; i++)
{
unsigned int k, j = n >> 1;
-
while (r >= j)
{
r -= j;
j >>= 1;
}
r |= j;
-
k = r >> 1;
j = i << 3;
BUTTERFLY_10 (X[k], X[k + 1],
@@ -393,7 +350,6 @@ reference_bitreverse_fft2analysis (const unsigned int n,
__1, __0);
}
}
-
static inline void
reference_bitreverse_fft2synthesis (const unsigned int n,
const double *X,
@@ -402,7 +358,6 @@ reference_bitreverse_fft2synthesis (const unsigned int n,
const unsigned int n2 = n >> 1, n1 = n + n2, max = n >> 2;
unsigned int i, r;
double scale = n;
-
scale = 1; /* set to 1.0 / scale to get scaled synthesis */
BUTTERFLY_10scale (X[0], X[1],
X[n], X[n + 1],
@@ -421,14 +376,12 @@ reference_bitreverse_fft2synthesis (const unsigned int n,
for (i = 1, r = 0; i < max; i++)
{
unsigned int k, j = n >> 1;
-
while (r >= j)
{
r -= j;
j >>= 1;
}
r |= j;
-
k = r >> 1;
j = i << 3;
BUTTERFLY_10scale (X[k], X[k + 1],
@@ -445,7 +398,6 @@ reference_bitreverse_fft2synthesis (const unsigned int n,
scale);
}
}
-
static void
reference_power2_fftc (unsigned int n_values,
const double *rivalues_in,
@@ -456,33 +408,27 @@ reference_power2_fftc (unsigned int n_values,
double theta = esign < 0 ? -3.1415926535897932384626433832795029 : 3.1415926535897932384626433832795029;
unsigned int block_size = 2 << 1;
double last_sin;
-
if (esign > 0)
reference_bitreverse_fft2analysis (n_values, rivalues_in, rivalues);
else
reference_bitreverse_fft2synthesis (n_values, rivalues_in, rivalues);
theta *= (double) 1.0 / 2.;
last_sin = sin (theta);
-
if (n_values < 4)
return;
-
do
{
double Dre, Dim, Wre, Wim;
unsigned int k, i, half_block = block_size >> 1;
unsigned int block_size2 = block_size << 1;
-
theta *= 0.5;
Dim = last_sin;
last_sin = sin (theta);
Dre = last_sin * last_sin * -2.;
-
/* loop over first coefficient in each block ==> w == {1,0} */
for (i = 0; i < n_values2; i += block_size2)
{
unsigned int v1 = i, v2 = i + block_size;
-
BUTTERFLY_10 (rivalues[v1], rivalues[v1 + 1],
rivalues[v2], rivalues[v2 + 1],
rivalues[v1], rivalues[v1 + 1],
@@ -498,7 +444,6 @@ reference_power2_fftc (unsigned int n_values,
for (i = k; i < n_values2; i += block_size2)
{
unsigned int v1 = i, v2 = i + block_size;
-
BUTTERFLY_XY (rivalues[v1], rivalues[v1 + 1],
rivalues[v2], rivalues[v2 + 1],
rivalues[v1], rivalues[v1 + 1],
@@ -515,7 +460,6 @@ reference_power2_fftc (unsigned int n_values,
for (i = k; i < n_values2; i += block_size2)
{
unsigned int v1 = i, v2 = i + block_size;
-
BUTTERFLY_01 (rivalues[v1], rivalues[v1 + 1],
rivalues[v2], rivalues[v2 + 1],
rivalues[v1], rivalues[v1 + 1],
@@ -526,7 +470,6 @@ reference_power2_fftc (unsigned int n_values,
for (i = k; i < n_values2; i += block_size2)
{
unsigned int v1 = i, v2 = i + block_size;
-
BUTTERFLY_0m (rivalues[v1], rivalues[v1 + 1],
rivalues[v2], rivalues[v2 + 1],
rivalues[v1], rivalues[v1 + 1],
@@ -553,7 +496,6 @@ reference_power2_fftc (unsigned int n_values,
for (i = k; i < n_values2; i += block_size2)
{
unsigned int v1 = i, v2 = i + block_size;
-
BUTTERFLY_XY (rivalues[v1], rivalues[v1 + 1],
rivalues[v2], rivalues[v2 + 1],
rivalues[v1], rivalues[v1 + 1],
@@ -566,16 +508,13 @@ reference_power2_fftc (unsigned int n_values,
}
while (block_size <= n_values);
}
-
/*--------------- reference DFT -----------------*/
-
static BseComplex
complex_exp (BseComplex z)
{
/* also found in g++-4.2 C++ complex numbers */
return bse_complex_polar (exp(z.re), z.im);
}
-
void
reference_dftc (unsigned int n_values,
const double *rivalues_in,
@@ -589,12 +528,10 @@ reference_dftc (unsigned int n_values,
for (k = 0; k < n_values; k++)
{
BseComplex result = { 0, 0 };
-
for (n = 0; n < n_values; n++)
result = bse_complex_add (result,
bse_complex_mul (bse_complex (rivalues_in[n * 2], rivalues_in[n * 2 + 1]),
complex_exp (bse_complex (0, -2 * PI / n_values * ((k * n) % n_values)))));
-
rivalues_out[k * 2] = result.re;
rivalues_out[k * 2 + 1] = result.im;
}
diff --git a/drivers/bse-portaudio/bsepcmdevice-portaudio.cc b/drivers/bse-portaudio/bsepcmdevice-portaudio.cc
index 587bccf..c4d81de 100644
--- a/drivers/bse-portaudio/bsepcmdevice-portaudio.cc
+++ b/drivers/bse-portaudio/bsepcmdevice-portaudio.cc
@@ -8,22 +8,17 @@
#include <string>
#include <vector>
#include <algorithm>
-
using std::string;
using std::vector;
using std::max;
-
static SFI_MSG_TYPE_DEFINE (debug_pcm, "pcm", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_pcm, __VA_ARGS__)
-
-
/* --- PortAudio PCM handle --- */
typedef struct
{
BsePcmHandle handle;
PaStream *stream;
} PortAudioPcmHandle;
-
/* --- prototypes --- */
static void bse_pcm_device_port_audio_class_init (BsePcmDevicePortAudioClass *klass);
static void bse_pcm_device_port_audio_init (BsePcmDevicePortAudio *self);
@@ -34,22 +29,18 @@ static void port_audio_device_write (BsePcmHandle
static gboolean port_audio_device_check_io (BsePcmHandle *handle,
glong *timeoutp);
static guint port_audio_device_latency (BsePcmHandle *handle);
-
/* --- define object type and export to BSE --- */
static const char type_blurb[] = ("PCM driver implementation using PortAudio (http://www.portaudio.com)");
BSE_REGISTER_OBJECT (BsePcmDevicePortAudio, BsePcmDevice, NULL, "", type_blurb, NULL, bse_pcm_device_port_audio_class_init, NULL, bse_pcm_device_port_audio_init);
BSE_DEFINE_EXPORTS();
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
/* --- functions --- */
static void
bse_pcm_device_port_audio_init (BsePcmDevicePortAudio *self)
{
Pa_Initialize();
}
-
static BseErrorType
bse_error_from_pa_error (PaError pa_error,
BseErrorType fallback)
@@ -88,12 +79,10 @@ bse_error_from_pa_error (PaError pa_error,
}
return fallback;
}
-
static std::string
port_audio_host_api_name (PaHostApiIndex host_api_index)
{
const PaHostApiInfo *host_api_info = Pa_GetHostApiInfo (host_api_index);
-
switch (host_api_info->type)
{
case paOSS: return "oss";
@@ -101,13 +90,11 @@ port_audio_host_api_name (PaHostApiIndex host_api_index)
case paALSA: return "alsa";
default: ;
}
-
char *api_str = g_strdup_printf ("pa%02d", host_api_info->type);
string name = api_str;
g_free (api_str);
return name;
}
-
/* we build a per-host-api device index, since we hope that this
* will be a bit more reliable than the global index, so that
* specifiying a device like alsa:0 results in (more or less)
@@ -117,12 +104,10 @@ static vector<string>
port_audio_devices()
{
vector<string> devices (Pa_GetDeviceCount());
-
for (PaHostApiIndex host_api_index = 0; host_api_index < Pa_GetHostApiCount(); host_api_index++)
{
int host_api_device_index = 0; /* host api specific index */
string host_api_name = port_audio_host_api_name (host_api_index);
-
for (PaDeviceIndex device_index = 0; device_index < Pa_GetDeviceCount(); device_index++)
{
const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device_index);
@@ -134,24 +119,19 @@ port_audio_devices()
}
}
}
-
return devices;
}
-
static SfiRing*
bse_pcm_device_port_audio_list_devices (BseDevice *device)
{
vector<string> devices = port_audio_devices();
SfiRing *ring = NULL;
-
int default_device_index = Pa_GetDefaultOutputDevice();
-
for (PaDeviceIndex device_index = 0; device_index < Pa_GetDeviceCount(); device_index++)
{
const PaDeviceInfo *device_info = Pa_GetDeviceInfo (device_index);
const PaHostApiInfo *host_api_info = Pa_GetHostApiInfo (device_info->hostApi);
char *device_args = g_strdup (devices[device_index].c_str());
-
BseDeviceEntry *entry = bse_device_group_entry_new (device, device_args,
g_strdup (host_api_info->name),
g_strdup_printf ("%-10s%s%s", device_args, device_info->name,
@@ -162,7 +142,6 @@ bse_pcm_device_port_audio_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_error_new (device, g_strdup_printf ("No devices found")));
return ring;
}
-
static BseErrorType
bse_pcm_device_port_audio_open (BseDevice *device,
gboolean require_readable,
@@ -173,7 +152,6 @@ bse_pcm_device_port_audio_open (BseDevice *device,
PortAudioPcmHandle *portaudio = g_new0 (PortAudioPcmHandle, 1);
BsePcmHandle *handle = &portaudio->handle;
BsePcmDevice *pdev = BSE_PCM_DEVICE (device);
-
handle->readable = require_readable;
handle->writable = require_writable;
handle->n_channels = 2; /* TODO: mono */
@@ -196,9 +174,7 @@ bse_pcm_device_port_audio_open (BseDevice *device,
handle->writable = TRUE;
}
}
-
BseErrorType error = BSE_ERROR_NONE;
-
PaStreamParameters inputParameters = { 0, };
inputParameters.device = Pa_GetDefaultInputDevice();
PaStreamParameters outputParameters = { 0, };
@@ -249,7 +225,6 @@ bse_pcm_device_port_audio_open (BseDevice *device,
portaudio->stream = NULL;
}
}
-
if (!error)
{
bse_device_set_opened (device, device_name.c_str(), handle->readable, handle->writable);
@@ -270,16 +245,13 @@ bse_pcm_device_port_audio_open (BseDevice *device,
DEBUG ("PortAudio: opening PCM \"%s\" readable=%d writable=%d: %s", device_name.c_str(), require_readable, require_writable, bse_error_blurb (error));
if (!error)
DEBUG ("PortAudio: input-latency=%fms output-latency=%fms", Pa_GetStreamInfo (portaudio->stream)->inputLatency, Pa_GetStreamInfo (portaudio->stream)->outputLatency);
-
return error;
}
-
static void
bse_pcm_device_port_audio_close (BseDevice *device)
{
PortAudioPcmHandle *portaudio = (PortAudioPcmHandle*) BSE_PCM_DEVICE (device)->handle;
BSE_PCM_DEVICE (device)->handle = NULL;
-
if (portaudio->stream)
{
Pa_StopStream (portaudio->stream);
@@ -287,7 +259,6 @@ bse_pcm_device_port_audio_close (BseDevice *device)
}
g_free (portaudio);
}
-
static void
bse_pcm_device_port_audio_finalize (GObject *object)
{
@@ -296,14 +267,12 @@ bse_pcm_device_port_audio_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
port_audio_device_retrigger (PortAudioPcmHandle *portaudio)
{
/* silence fill output, to resynchronize output and input streams to the desired latency */
guint write_frames_avail = Pa_GetStreamWriteAvailable (portaudio->stream);
float *silence = (float*) g_malloc0 (portaudio->handle.block_length * sizeof (float) * portaudio->handle.n_channels);
-
while (write_frames_avail >= portaudio->handle.block_length)
{
Pa_WriteStream (portaudio->stream, silence, portaudio->handle.block_length);
@@ -311,7 +280,6 @@ port_audio_device_retrigger (PortAudioPcmHandle *portaudio)
}
g_free (silence);
}
-
static gboolean
port_audio_device_check_io (BsePcmHandle *handle,
glong *timeoutp)
@@ -320,7 +288,6 @@ port_audio_device_check_io (BsePcmHandle *handle,
guint read_frames_avail = handle->readable ? Pa_GetStreamReadAvailable (portaudio->stream) : 0;
guint write_frames_avail = handle->writable ? Pa_GetStreamWriteAvailable (portaudio->stream) : 0;
guint n_frames_avail = handle->readable ? read_frames_avail : write_frames_avail;
-
if (handle->readable && handle->writable && write_frames_avail >= (2 * handle->block_length) && read_frames_avail == 0)
{
/* underrun occured (or stream just initialized) */
@@ -329,24 +296,19 @@ port_audio_device_check_io (BsePcmHandle *handle,
/* check whether data can be processed */
if (n_frames_avail >= handle->block_length)
return TRUE; /* need processing */
-
/* calculate timeout until processing is possible or needed */
guint diff_frames = handle->block_length - n_frames_avail;
*timeoutp = diff_frames * 1000 / handle->mix_freq;
-
return FALSE;
}
-
static guint
port_audio_device_latency (BsePcmHandle *handle)
{
PortAudioPcmHandle *portaudio = (PortAudioPcmHandle*) handle;
-
/* return total latency in frames */
/* -> this is probably an estimate, as I don't think the PortAudio API exports a precise value at any place */
return guint (max (Pa_GetStreamInfo (portaudio->stream)->inputLatency, Pa_GetStreamInfo (portaudio->stream)->outputLatency) * handle->mix_freq);
}
-
static gsize
port_audio_device_read (BsePcmHandle *handle,
gfloat *values)
@@ -355,31 +317,24 @@ port_audio_device_read (BsePcmHandle *handle,
Pa_ReadStream (portaudio->stream, values, handle->block_length);
return handle->block_length * handle->n_channels;
}
-
static void
port_audio_device_write (BsePcmHandle *handle,
const gfloat *values)
{
PortAudioPcmHandle *portaudio = (PortAudioPcmHandle*) handle;
-
/* FIXME: should PortAudio clip? */
float clipped_values[handle->block_length * handle->n_channels];
for (guint i = 0; i < handle->block_length * handle->n_channels; i++)
clipped_values[i] = CLAMP (values[i], -1.0, 1.0);
-
Pa_WriteStream (portaudio->stream, clipped_values, handle->block_length);
}
-
static void
bse_pcm_device_port_audio_class_init (BsePcmDevicePortAudioClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_pcm_device_port_audio_finalize;
-
device_class->list_devices = bse_pcm_device_port_audio_list_devices;
const gchar *name = "portaudio";
const gchar *syntax = _("DEVICE,MODE");
diff --git a/drivers/bse-portaudio/bsepcmdevice-portaudio.hh b/drivers/bse-portaudio/bsepcmdevice-portaudio.hh
index bb62130..04d1ec2 100644
--- a/drivers/bse-portaudio/bsepcmdevice-portaudio.hh
+++ b/drivers/bse-portaudio/bsepcmdevice-portaudio.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_DEVICE_PORTAUDIO_H__
#define __BSE_PCM_DEVICE_PORTAUDIO_H__
-
#include <bse/bsepcmdevice.hh>
#include <bse/bseplugin.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_DEVICE_PORT_AUDIO (BSE_EXPORT_TYPE_ID (BsePcmDevicePortAudio))
#define BSE_PCM_DEVICE_PORT_AUDIO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE_PORT_AUDIO, BsePcmDevicePortAudio))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_DEVICE_PORT_AUDIO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE_PORT_AUDIO))
#define BSE_IS_PCM_DEVICE_PORT_AUDIO_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE_PORT_AUDIO))
#define BSE_PCM_DEVICE_PORT_AUDIO_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE_PORT_AUDIO, BsePcmDevicePortAudioClass))
-
/* --- BsePcmDevicePortAudio object --- */
typedef struct _BsePcmDevicePortAudio BsePcmDevicePortAudio;
typedef struct _BsePcmDevicePortAudioClass BsePcmDevicePortAudioClass;
@@ -26,7 +22,5 @@ struct _BsePcmDevicePortAudioClass
{
BsePcmDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_PCM_DEVICE_PORTAUDIO_H__ */
diff --git a/drivers/bsemididevice-alsa.cc b/drivers/bsemididevice-alsa.cc
index 23adfb6..179e1f1 100644
--- a/drivers/bsemididevice-alsa.cc
+++ b/drivers/bsemididevice-alsa.cc
@@ -7,11 +7,8 @@
#include <alsa/asoundlib.h>
#include <string.h>
#include <errno.h>
-
static SFI_MSG_TYPE_DEFINE (debug_pcm, "midi", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_pcm, __VA_ARGS__)
-
-
/* --- structs --- */
typedef struct
{
@@ -20,30 +17,24 @@ typedef struct
snd_rawmidi_t *write_handle;
guint total_pfds;
} AlsaMidiHandle;
-
/* --- prototypes --- */
static void bse_midi_device_alsa_class_init (BseMidiDeviceALSAClass *klass);
static void bse_midi_device_alsa_init (BseMidiDeviceALSA *self);
static gboolean alsa_midi_io_handler (gpointer data,
guint n_pfds,
GPollFD *pfds);
-
// == Type Registration ==
BSE_RESIDENT_TYPE_DEF (BseMidiDeviceALSA, bse_midi_device_alsa, BSE_TYPE_MIDI_DEVICE, NULL,
"MIDI driver implementation for the Advanced Linux Sound Architecture "
"(http://alsa-project.org/alsa-doc/alsa-lib/midi.html)", NULL);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
/* --- functions --- */
static void
bse_midi_device_alsa_init (BseMidiDeviceALSA *self)
{
}
-
#define alsa_alloca0(struc) ({ struc##_t *ptr = (struc##_t*) alloca (struc##_sizeof()); memset (ptr, 0, struc##_sizeof()); ptr; })
-
static SfiRing*
bse_midi_device_alsa_list_devices (BseDevice *device)
{
@@ -51,7 +42,6 @@ bse_midi_device_alsa_list_devices (BseDevice *device)
snd_ctl_card_info_t *cinfo = alsa_alloca0 (snd_ctl_card_info);
snd_rawmidi_info_t *winfo = alsa_alloca0 (snd_rawmidi_info);
snd_rawmidi_info_t *rinfo = alsa_alloca0 (snd_rawmidi_info);
-
int cindex = -1;
snd_card_next (&cindex);
while (cindex >= 0)
@@ -67,9 +57,7 @@ bse_midi_device_alsa_list_devices (BseDevice *device)
snd_ctl_close (chandle);
continue;
}
-
gchar *device_group = g_strdup_printf ("%s - %s", snd_ctl_card_info_get_id (cinfo), snd_ctl_card_info_get_longname (cinfo));
-
int pindex = -1;
snd_ctl_rawmidi_next_device (chandle, &pindex);
while (pindex >= 0)
@@ -122,7 +110,6 @@ bse_midi_device_alsa_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_error_new (device, g_strdup_printf ("No devices found")));
return ring;
}
-
static void
silent_error_handler (const char *file,
int line,
@@ -132,7 +119,6 @@ silent_error_handler (const char *file,
...)
{
}
-
static BseErrorType
bse_midi_device_alsa_open (BseDevice *device,
gboolean require_readable,
@@ -157,7 +143,6 @@ bse_midi_device_alsa_open (BseDevice *device,
dname, SND_RAWMIDI_NONBLOCK);
snd_lib_error_set_handler (NULL);
}
-
/* try setup */
BseErrorType error = !aerror ? BSE_ERROR_NONE : bse_error_from_errno (-aerror, BSE_ERROR_FILE_OPEN_FAILED);
snd_rawmidi_params_t *mparams = alsa_alloca0 (snd_rawmidi_params);
@@ -183,7 +168,6 @@ bse_midi_device_alsa_open (BseDevice *device,
}
if (!error && alsa->read_handle && snd_rawmidi_poll_descriptors_count (alsa->read_handle) <= 0)
error = BSE_ERROR_FILE_OPEN_FAILED;
-
/* setup MIDI handle or shutdown */
if (!error)
{
@@ -222,19 +206,15 @@ bse_midi_device_alsa_open (BseDevice *device,
}
DEBUG ("ALSA: opening MIDI \"%s\" readable=%d writable=%d: %s", dname, require_readable, require_writable, bse_error_blurb (error));
g_free (dname);
-
return error;
}
-
static void
bse_midi_device_alsa_close (BseDevice *device)
{
AlsaMidiHandle *alsa = (AlsaMidiHandle*) BSE_MIDI_DEVICE (device)->handle;
BSE_MIDI_DEVICE (device)->handle = NULL;
-
if (alsa->total_pfds)
bse_sequencer_remove_io_watch (alsa_midi_io_handler, alsa);
-
if (alsa->read_handle)
snd_rawmidi_close (alsa->read_handle);
if (alsa->write_handle)
@@ -245,7 +225,6 @@ bse_midi_device_alsa_close (BseDevice *device)
}
g_free (alsa);
}
-
static void
bse_midi_device_alsa_finalize (GObject *object)
{
@@ -253,7 +232,6 @@ bse_midi_device_alsa_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static gboolean
alsa_midi_io_handler (gpointer data, /* Sequencer Thread */
guint n_pfds,
@@ -264,27 +242,21 @@ alsa_midi_io_handler (gpointer data, /* Sequencer Thread */
const gsize buf_size = 8192;
guint8 buffer[buf_size];
gssize l;
-
guint64 systime = sfi_time_system ();
do
l = snd_rawmidi_read (alsa->read_handle, buffer, buf_size);
while (l < 0 && errno == EINTR); /* don't mind signals */
-
if (l > 0)
bse_midi_decoder_push_data (handle->midi_decoder, l, buffer, systime);
return TRUE;
}
-
static void
bse_midi_device_alsa_class_init (BseMidiDeviceALSAClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_midi_device_alsa_finalize;
-
device_class->list_devices = bse_midi_device_alsa_list_devices;
const gchar *name = "alsa";
const gchar *syntax = _("PLUGIN:CARD,DEV,SUBDEV");
diff --git a/drivers/bsemididevice-alsa.hh b/drivers/bsemididevice-alsa.hh
index e93e03a..cb08823 100644
--- a/drivers/bsemididevice-alsa.hh
+++ b/drivers/bsemididevice-alsa.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIDI_DEVICE_ALSA_H__
#define __BSE_MIDI_DEVICE_ALSA_H__
-
#include <bse/bsemididevice.hh>
#include <bse/bseplugin.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_MIDI_DEVICE_ALSA (bse_midi_device_alsa_get_type())
#define BSE_MIDI_DEVICE_ALSA(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIDI_DEVICE_ALSA, BseMidiDeviceALSA))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_MIDI_DEVICE_ALSA(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIDI_DEVICE_ALSA))
#define BSE_IS_MIDI_DEVICE_ALSA_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIDI_DEVICE_ALSA))
#define BSE_MIDI_DEVICE_ALSA_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIDI_DEVICE_ALSA, BseMidiDeviceALSAClass))
-
/* --- BseMidiDeviceALSA object --- */
typedef struct _BseMidiDeviceALSA BseMidiDeviceALSA;
typedef struct _BseMidiDeviceALSAClass BseMidiDeviceALSAClass;
@@ -26,7 +22,5 @@ struct _BseMidiDeviceALSAClass
{
BseMidiDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_MIDI_DEVICE_ALSA_H__ */
diff --git a/drivers/bsepcmdevice-alsa.cc b/drivers/bsepcmdevice-alsa.cc
index 4e2cc04..5f4453b 100644
--- a/drivers/bsepcmdevice-alsa.cc
+++ b/drivers/bsepcmdevice-alsa.cc
@@ -6,7 +6,6 @@
#include <alsa/asoundlib.h>
#include <string.h>
#include <errno.h>
-
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define SND_PCM_FORMAT_S16_HE SND_PCM_FORMAT_S16_LE
#elif G_BYTE_ORDER == G_BIG_ENDIAN
@@ -14,12 +13,9 @@
#else
#error unsupported byte order in G_BYTE_ORDER
#endif
-
static SFI_MSG_TYPE_DEFINE (debug_pcm, "pcm", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_pcm, __VA_ARGS__)
-
static snd_output_t *snd_output = NULL; // only for debugging
-
/* --- ALSA PCM handle --- */
typedef struct
{
@@ -32,8 +28,6 @@ typedef struct
gint16 *period_buffer;
guint read_write_count;
} AlsaPcmHandle;
-
-
/* --- prototypes --- */
static void bse_pcm_device_alsa_class_init (BsePcmDeviceALSAClass *klass);
static void bse_pcm_device_alsa_init (BsePcmDeviceALSA *self);
@@ -50,25 +44,20 @@ static void alsa_device_write (BsePcmHandle
static gboolean alsa_device_check_io (BsePcmHandle *handle,
glong *tiumeoutp);
static guint alsa_device_latency (BsePcmHandle *handle);
-
// == Type Registration ==
BSE_RESIDENT_TYPE_DEF (BsePcmDeviceALSA, bse_pcm_device_alsa, BSE_TYPE_PCM_DEVICE, NULL,
"PCM driver implementation for the Advanced Linux Sound Architecture "
"(http://alsa-project.org/alsa-doc/alsa-lib/pcm.html)", NULL);
-
/* --- variables --- */
static gpointer parent_class = NULL;
static guint const_pcm_status_sizeof = 0;
-
/* --- functions --- */
static void
bse_pcm_device_alsa_init (BsePcmDeviceALSA *self)
{
const_pcm_status_sizeof = snd_pcm_status_sizeof();
}
-
#define alsa_alloca0(struc) ({ struc##_t *ptr = (struc##_t*) alloca (struc##_sizeof()); memset (ptr, 0, struc##_sizeof()); ptr; })
-
static SfiRing*
bse_pcm_device_alsa_list_devices (BseDevice *device)
{
@@ -76,7 +65,6 @@ bse_pcm_device_alsa_list_devices (BseDevice *device)
snd_ctl_card_info_t *cinfo = alsa_alloca0 (snd_ctl_card_info);
snd_pcm_info_t *pinfo = alsa_alloca0 (snd_pcm_info);
snd_pcm_info_t *rinfo = alsa_alloca0 (snd_pcm_info);
-
int cindex = -1;
snd_card_next (&cindex);
while (cindex >= 0)
@@ -92,9 +80,7 @@ bse_pcm_device_alsa_list_devices (BseDevice *device)
snd_ctl_close (chandle);
continue;
}
-
gchar *device_group = g_strdup_printf ("%s - %s", snd_ctl_card_info_get_id (cinfo), snd_ctl_card_info_get_longname (cinfo));
-
int pindex = -1;
snd_ctl_pcm_next_device (chandle, &pindex);
while (pindex >= 0)
@@ -147,7 +133,6 @@ bse_pcm_device_alsa_list_devices (BseDevice *device)
ring = sfi_ring_append (ring, bse_device_error_new (device, g_strdup_printf ("No devices found")));
return ring;
}
-
static void
silent_error_handler (const char *file,
int line,
@@ -157,7 +142,6 @@ silent_error_handler (const char *file,
...)
{
}
-
static BseErrorType
bse_pcm_device_alsa_open (BseDevice *device,
gboolean require_readable,
@@ -205,7 +189,6 @@ bse_pcm_device_alsa_open (BseDevice *device,
error = BSE_ERROR_DEVICES_MISMATCH;
if (!error && snd_pcm_prepare (alsa->read_handle ? alsa->read_handle : alsa->write_handle) < 0)
error = BSE_ERROR_FILE_OPEN_FAILED;
-
/* setup PCM handle or shutdown */
if (!error)
{
@@ -230,16 +213,13 @@ bse_pcm_device_alsa_open (BseDevice *device,
}
DEBUG ("ALSA: opening PCM \"%s\" readable=%d writable=%d: %s", dname, require_readable, require_writable, bse_error_blurb (error));
g_free (dname);
-
return error;
}
-
static void
bse_pcm_device_alsa_close (BseDevice *device)
{
AlsaPcmHandle *alsa = (AlsaPcmHandle*) BSE_PCM_DEVICE (device)->handle;
BSE_PCM_DEVICE (device)->handle = NULL;
-
if (alsa->read_handle)
{
snd_pcm_drop (alsa->read_handle);
@@ -254,7 +234,6 @@ bse_pcm_device_alsa_close (BseDevice *device)
g_free (alsa->period_buffer);
g_free (alsa);
}
-
static void
bse_pcm_device_alsa_finalize (GObject *object)
{
@@ -262,7 +241,6 @@ bse_pcm_device_alsa_finalize (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static BseErrorType
alsa_device_setup (AlsaPcmHandle *alsa,
snd_pcm_t *phandle,
@@ -344,28 +322,23 @@ alsa_device_setup (AlsaPcmHandle *alsa,
// snd_pcm_dump (phandle, snd_output);
return BSE_ERROR_NONE;
}
-
static void
alsa_device_retrigger (AlsaPcmHandle *alsa)
{
snd_lib_error_set_handler (silent_error_handler);
-
DEBUG ("ALSA: retriggering device (r=%s w=%s)...",
!alsa->read_handle ? "<CLOSED>" : snd_pcm_state_name (snd_pcm_state (alsa->read_handle)),
!alsa->write_handle ? "<CLOSED>" : snd_pcm_state_name (snd_pcm_state (alsa->write_handle)));
snd_pcm_prepare (alsa->read_handle ? alsa->read_handle : alsa->write_handle);
-
/* first, clear io buffers */
if (alsa->read_handle)
snd_pcm_drop (alsa->read_handle);
if (alsa->write_handle)
snd_pcm_drain (alsa->write_handle); /* write_handle must be blocking */
-
/* prepare for playback/capture */
gint aerror = snd_pcm_prepare (alsa->read_handle ? alsa->read_handle : alsa->write_handle);
if (aerror) /* this really shouldn't fail */
sfi_diag ("ALSA: failed to prepare for io: %s\n", snd_strerror (aerror));
-
/* fill playback buffer with silence */
if (alsa->write_handle)
{
@@ -376,16 +349,13 @@ alsa_device_retrigger (AlsaPcmHandle *alsa)
while (n == -EAGAIN); /* retry on signals */
g_free (silence);
}
-
snd_lib_error_set_handler (NULL);
}
-
static gboolean
alsa_device_check_io (BsePcmHandle *handle,
glong *timeoutp)
{
AlsaPcmHandle *alsa = (AlsaPcmHandle*) handle;
-
if (0)
{
snd_pcm_state_t ws = SND_PCM_STATE_DISCONNECTED, rs = SND_PCM_STATE_DISCONNECTED;
@@ -408,7 +378,6 @@ alsa_device_check_io (BsePcmHandle *handle,
handle->block_length,
rn >= handle->block_length ? "TRUE" : "FALSE");
}
-
/* quick check for data availability */
gint n_frames_avail = snd_pcm_avail_update (alsa->read_handle ? alsa->read_handle : alsa->write_handle);
if (n_frames_avail < 0 || /* error condition, probably an underrun (-EPIPE) */
@@ -422,18 +391,14 @@ alsa_device_check_io (BsePcmHandle *handle,
n_frames_avail = snd_pcm_avail_update (alsa->read_handle ? alsa->read_handle : alsa->write_handle);
n_frames_avail = MAX (n_frames_avail, 0);
}
-
/* check whether data can be processed */
if (n_frames_avail >= ssize_t (handle->block_length))
return TRUE; /* need processing */
-
/* calculate timeout until processing is possible or needed */
guint diff_frames = handle->block_length - n_frames_avail;
*timeoutp = diff_frames * 1000 / handle->mix_freq;
-
return FALSE;
}
-
static guint
alsa_device_latency (BsePcmHandle *handle)
{
@@ -447,7 +412,6 @@ alsa_device_latency (BsePcmHandle *handle)
/* return total latency in frames */
return CLAMP (rdelay, 0, buffer_length) + CLAMP (wdelay, 0, buffer_length);
}
-
static gsize
alsa_device_read (BsePcmHandle *handle,
gfloat *values)
@@ -457,7 +421,6 @@ alsa_device_read (BsePcmHandle *handle,
gfloat *dest = values;
gsize n_left = handle->block_length;
const gsize n_values = n_left * handle->n_channels;
-
alsa->read_write_count += 1;
do
{
@@ -481,10 +444,8 @@ alsa_device_read (BsePcmHandle *handle,
n_left -= n_frames;
}
while (n_left);
-
return n_values;
}
-
static void
alsa_device_write (BsePcmHandle *handle,
const gfloat *values)
@@ -493,7 +454,6 @@ alsa_device_write (BsePcmHandle *handle,
gpointer buf = alsa->period_buffer; /* size in bytes = n_values * 2 */
const gfloat *floats = values;
gsize n_left = handle->block_length;
-
if (alsa->read_handle && alsa->read_write_count < 1)
{
snd_lib_error_set_handler (silent_error_handler); /* silence libALSA about -EPIPE */
@@ -501,7 +461,6 @@ alsa_device_write (BsePcmHandle *handle,
alsa->read_write_count += 1;
snd_lib_error_set_handler (NULL);
}
-
alsa->read_write_count -= 1;
do
{
@@ -528,17 +487,13 @@ alsa_device_write (BsePcmHandle *handle,
}
while (n_left);
}
-
static void
bse_pcm_device_alsa_class_init (BsePcmDeviceALSAClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
BseDeviceClass *device_class = BSE_DEVICE_CLASS (klass);
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = bse_pcm_device_alsa_finalize;
-
device_class->list_devices = bse_pcm_device_alsa_list_devices;
const gchar *name = "alsa";
const gchar *syntax = _("PLUGIN:CARD,DEV,SUBDEV");
diff --git a/drivers/bsepcmdevice-alsa.hh b/drivers/bsepcmdevice-alsa.hh
index 8dc56d7..39218b0 100644
--- a/drivers/bsepcmdevice-alsa.hh
+++ b/drivers/bsepcmdevice-alsa.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_PCM_DEVICE_ALSA_H__
#define __BSE_PCM_DEVICE_ALSA_H__
-
#include <bse/bsepcmdevice.hh>
#include <bse/bseplugin.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_PCM_DEVICE_ALSA (bse_pcm_device_alsa_get_type())
#define BSE_PCM_DEVICE_ALSA(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_PCM_DEVICE_ALSA, BsePcmDeviceALSA))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_PCM_DEVICE_ALSA(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_PCM_DEVICE_ALSA))
#define BSE_IS_PCM_DEVICE_ALSA_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_PCM_DEVICE_ALSA))
#define BSE_PCM_DEVICE_ALSA_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_PCM_DEVICE_ALSA, BsePcmDeviceALSAClass))
-
/* --- BsePcmDeviceALSA object --- */
typedef struct _BsePcmDeviceALSA BsePcmDeviceALSA;
typedef struct _BsePcmDeviceALSAClass BsePcmDeviceALSAClass;
@@ -26,7 +22,5 @@ struct _BsePcmDeviceALSAClass
{
BsePcmDeviceClass parent_class;
};
-
G_END_DECLS
-
#endif /* __BSE_PCM_DEVICE_ALSA_H__ */
diff --git a/launchers/beaststart.c b/launchers/beaststart.c
index b99cf65..46d367a 100644
--- a/launchers/beaststart.c
+++ b/launchers/beaststart.c
@@ -4,7 +4,6 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-
const char*
custom_find_executable (int *argc_p,
char ***argv_p)
@@ -27,7 +26,6 @@ custom_find_executable (int *argc_p,
strcat (string, version);
return string;
}
-
int
custom_check_arg_stopper (const char *argument)
{
diff --git a/launchers/bseshstart.c b/launchers/bseshstart.c
index 8232586..b567bf8 100644
--- a/launchers/bseshstart.c
+++ b/launchers/bseshstart.c
@@ -4,7 +4,6 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-
const char*
custom_find_executable (int *argc_p,
char ***argv_p)
@@ -27,7 +26,6 @@ custom_find_executable (int *argc_p,
strcat (string, version);
return string;
}
-
int
custom_check_arg_stopper (const char *argument)
{
diff --git a/launchers/suidmain.c b/launchers/suidmain.c
index 6ca6881..76531f9 100644
--- a/launchers/suidmain.c
+++ b/launchers/suidmain.c
@@ -8,9 +8,7 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
-
static int original_priority = 0;
-
static int /* returns 0 for success */
adjust_priority (void)
{
@@ -22,7 +20,6 @@ adjust_priority (void)
/* not really fatal */
original_priority = 0;
}
-
/* improve priority */
if (original_priority > -10)
{
@@ -35,10 +32,8 @@ adjust_priority (void)
}
if (errno != 0)
return errno; /* failed */
-
return 0;
}
-
int
main (int argc,
char **argv)
@@ -46,10 +41,8 @@ main (int argc,
const char *executable = NULL;
int euid = geteuid ();
int uid = getuid ();
-
/* call privileged code */
int priority_error = adjust_priority (); /* sets original_priority */
-
/* drop root privileges if running setuid root as soon as possible */
if (euid != uid)
{
@@ -67,17 +60,13 @@ main (int argc,
_exit (255);
}
}
-
/* non-priviledged code */
-
/* make sure we have a program name */
if (argc < 1)
return -1;
-
/* give notice about errors */
if (euid == 0 && priority_error)
fprintf (stderr, "%s: failed to renice process: %s\n", argv[0], strerror (priority_error));
-
/* parse -N and -n options */
int i, dropped_priority = -2147483647;
for (i = 1; i < argc; i++)
@@ -106,14 +95,11 @@ main (int argc,
dropped_priority = original_priority;
else if (custom_check_arg_stopper (argv[i])) /* check for "--" and similar args */
break;
-
/* handle -N and -n options */
if (dropped_priority != -2147483647)
setpriority (PRIO_PROCESS, getpid(), dropped_priority);
-
/* find executable */
executable = custom_find_executable (&argc, &argv);
-
/* exec */
argv[0] = (char*) executable;
execv (executable, argv);
diff --git a/launchers/suidmain.h b/launchers/suidmain.h
index 9ff53b1..a91a819 100644
--- a/launchers/suidmain.h
+++ b/launchers/suidmain.h
@@ -1,19 +1,15 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
#ifndef __SUIDMAIN_H__
#define __SUIDMAIN_H__
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
/* custom program name finder */
const char* custom_find_executable (int *argc,
char ***argv);
/* check for "--" and similar arguments */
int custom_check_arg_stopper (const char *argument);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __SUIDMAIN_H__ */
diff --git a/library/scripts/mixer-splitup-by-track.scm b/library/scripts/mixer-splitup-by-track.scm
index f4e9e96..5dbec0b 100644
--- a/library/scripts/mixer-splitup-by-track.scm
+++ b/library/scripts/mixer-splitup-by-track.scm
@@ -1,9 +1,7 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
;;
;; (bse-script-register <func> <options> <category> <blurb> <author> <license> ARGS...)
;;
-
(bse-script-register 'mixer-splitup-by-track
""
(N_ "/Song/Assign Tracks to individual Mixer Busses")
@@ -12,11 +10,9 @@
"Stefan Westerfeld"
"Provided \"as is\", WITHOUT ANY WARRANTY"
(bse-param-song (N_ "Song")))
-
;; function to get song for a track (improves readability)
(define (track-get-song track)
(bse-item-get-parent track))
-
;; check whether the track is connected (only) to the Master Bus
(define (track-uses-master-bus? track)
;; compare the the list of output names with the list containing the name of the master bus
@@ -25,7 +21,6 @@
(lambda (bus) (bse-item-get bus "uname"))
(bse-item-get track "outputs"))
(cons (bse-item-get (bse-song-get-master-bus (track-get-song track)) "uname") '())))
-
;; create new bus and assign track output to it, removing all other outputs
(define (assign-track-to-new-bus track)
(let* ((new-bus (bse-song-create-bus (track-get-song track))))
@@ -34,7 +29,6 @@
(bse-item-get track "outputs"))
(bse-bus-connect-track new-bus track)
(bse-bus-connect-bus (bse-song-get-master-bus (track-get-song track)) new-bus)))
-
;; create a new mixer channel for each track assigned (only) to the master bus
(define (mixer-splitup-by-track song)
(if (not (bse-is-song song))
@@ -48,5 +42,4 @@
(assign-track-to-new-bus track)))
(bse-container-list-children song))
(bse-item-ungroup-undo song))
-
;; vim:set sw=2 sts=2 ts=8:
diff --git a/library/scripts/modules2grid.scm b/library/scripts/modules2grid.scm
index 139e93f..08d4a3e 100644
--- a/library/scripts/modules2grid.scm
+++ b/library/scripts/modules2grid.scm
@@ -1,5 +1,4 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
;; (bse-script-register <func> <options> <category> <blurb> <author> <license> ARGS...)
(bse-script-register 'modules2grid
""
@@ -9,7 +8,6 @@
"Tim Janik"
"Provided \"as is\", WITHOUT ANY WARRANTY;"
(bse-param-snet (N_ "Synth Net")))
-
(define (modules2grid snet)
(if (not (bse-is-snet snet))
(bse-exit-error 'text1 (_"No valid synthesis network supplied")))
diff --git a/library/scripts/part-harmonic-transposer.scm b/library/scripts/part-harmonic-transposer.scm
index ccf36ec..ec4022d 100644
--- a/library/scripts/part-harmonic-transposer.scm
+++ b/library/scripts/part-harmonic-transposer.scm
@@ -1,9 +1,7 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
;;
;; (bse-script-register <func> <options> <category> <blurb> <author> <license> ARGS...)
;;
-
(bse-script-register 'part-harmonic-transposer
""
(N_ "/Part/Harmonic Transposer")
@@ -34,9 +32,7 @@
(bse-param-part (N_ "Part"))
(bse-param-string (N_ "Harmony Sequence") "C,Amin,F,G")
(bse-param-string (N_ "Transpose down starting at") "F"))
-
;; ------------------- parser for harmony strings ------------------------
-
;; parses a constant string (terminal symbols)
(define (parse-constant input match)
(and
@@ -48,7 +44,6 @@
(<= matchlen strlen)
(string=? (substring str 0 matchlen) match)
(cons (substring str matchlen strlen) (cdr input))))))
-
;; FIXME: should return the shortest string
(define (parse-multiple input . alternatives)
(if (null? alternatives)
@@ -56,17 +51,14 @@
(if (car alternatives)
(car alternatives)
(apply parse-multiple input (cdr alternatives)))))
-
;; for generating parse results: adds a new element into the parse result list
(define (parse-result input result)
(and input
(cons (car input) (cons result (cdr input)))))
-
;; change the first element in the parse result list by applying function to it
(define (parse-change-result input function)
(and input
(cons (car input) (cons (function (cadr input)) (cddr input)))))
-
;; BaseNote := C D E F G A B H
(define (parse-basenote input)
(parse-multiple input
@@ -78,7 +70,6 @@
(parse-result (parse-constant input "A") 9)
(parse-result (parse-constant input "B") 11)
(parse-result (parse-constant input "H") 11)))
-
;; FullNote := # <BaseNote> | <BaseNote> # | <BaseNote> is | <BaseNote>
(define (parse-fullnote input)
(parse-multiple input
@@ -86,7 +77,6 @@
(parse-change-result (parse-constant (parse-basenote input) "#") 1+)
(parse-change-result (parse-constant (parse-basenote input) "is") 1+)
(parse-basenote input)))
-
;; Harmony := <FullNote> maj | <FullNote> min | <FullNote> m | <FullNote>
(define (parse-harmony input)
(let ((scale (lambda (shift) (lambda (note) (cons note shift))))
@@ -107,7 +97,6 @@
(parse-change-result (parse-constant (parse-fullnote input) "min") minor)
(parse-change-result (parse-constant (parse-fullnote input) "m") minor)
(parse-change-result (parse-fullnote input) major))))
-
;; HarmonySeq := <Harmony> , <HarmonySeq> | <Harmony>
(define (parse-harmony-seq input)
(if input
@@ -115,19 +104,15 @@
(parse-harmony-seq (parse-constant (parse-harmony input) ","))
(parse-harmony input))
#f))
-
;; generate a list of harmonies from a string
(define (harmony-list-from-string str)
(let* ((parse-result (parse-harmony-seq (cons str '()))))
(if (and parse-result (= 0 (string-length (car parse-result))))
(reverse (cdr parse-result))
#f)))
-
;;---------------- harmonic transform functions ---------------------
-
;; white keys (starting at C) of a keyboard
(define harmony-scale '(0 2 4 5 7 9 11))
-
;; compute rotated version of white keys (starting at shift, where shift
;; is the number of the white key (i.e. 5 = fifth key = A)
(define (harmony-shift-scale shift)
@@ -142,10 +127,8 @@
(length harmony-scale))))
12))
harmony-scale))
-
;; all semitones
(define harmony-maj-maj '(0 1 2 3 4 5 6 7 8 9 10 11))
-
;; computes what to do with each semitone when transposing from
;; harmony srcscale to destscale
(define (harmony-shift srcscale destscale input)
@@ -162,7 +145,6 @@
12)))
delta))
input))
-
;; prints a list of things, writing out strings, and displaying other values
;; concludes with a newline
(define (myprint . l)
@@ -173,7 +155,6 @@
(map write-char (string->list (car l)))
(display (car l)))
(apply myprint (cdr l)))))
-
;; transposes one midi note (integer) from one harmony in another
;; down indicates whether to go down rather than up
(define (harmony-transpose note from to down)
@@ -186,7 +167,6 @@
(modulo (- (car to) (car from)) 12)
(if down -12 0))))
(+ note delta)))
-
;; harmonic transposer: implementation
(define (part-harmonic-transposer part harmony-string down-string)
(if (not (bse-is-part part))
@@ -233,6 +213,4 @@
(process-harmonies note harmony-list len))
notes)
(bse-item-ungroup-undo part)))))
-
-
;; vim:set sw=2 sts=2 ts=8:
diff --git a/library/scripts/progressor-example.scm b/library/scripts/progressor-example.scm
index 9145a38..4b8fe40 100644
--- a/library/scripts/progressor-example.scm
+++ b/library/scripts/progressor-example.scm
@@ -1,5 +1,4 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
;; (bse-script-register 'script-function
;; "unstable" ; Options
;; (N_ "/Project/Toys/My Script")
@@ -11,7 +10,6 @@
;; (bse-param-irange (N_ "IntNum") '(16 -100 +100 5))
;; (bse-param-frange (N_ "FloatNum") '(42 0 1000 10))
;; (bse-param-note (_ "Note") "C-7"))
-
(bse-script-register 'progressor
""
(N_ "/Project/Toys/Progressor...")
@@ -23,7 +21,6 @@
(bse-param-irange (N_ "N Iterations") '(512 0 65536 128))
(bse-param-irange (N_ "N Wait Spins") '(256 0 65536 64))
(bse-param-bool (N_ "Update Percentage") #t))
-
(define (progressor niter nwait uperc)
(do ((i niter (- i 1)))
((<= i 0))
diff --git a/library/scripts/record-midi.scm b/library/scripts/record-midi.scm
index d12784e..9b315a2 100644
--- a/library/scripts/record-midi.scm
+++ b/library/scripts/record-midi.scm
@@ -1,5 +1,4 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
(bse-script-register 'record-midi
""
(N_ "/Part/Record Midi...")
@@ -9,7 +8,6 @@
"Provided \"as is\", WITHOUT ANY WARRANTY;"
(bse-param-part (N_ "Part"))
(bse-param-bool (N_ "Start Now") #t))
-
(define (record-midi part start-now)
(define do-recording #f)
(define (record-note start duration note freq fine-tune velocity)
diff --git a/library/scripts/song-parts-operations.scm b/library/scripts/song-parts-operations.scm
index e4b3c1a..c1b8e73 100644
--- a/library/scripts/song-parts-operations.scm
+++ b/library/scripts/song-parts-operations.scm
@@ -1,9 +1,7 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
-
;;
;; (bse-script-register <func> <options> <category> <blurb> <author> <license> ARGS...)
;;
-
(bse-script-register 'song-parts-crop
""
(N_ "/Song/Crop parts (loop range)")
@@ -12,7 +10,6 @@
"Stefan Westerfeld"
"Provided \"as is\", WITHOUT ANY WARRANTY"
(bse-param-song (N_ "Song")))
-
(bse-script-register 'song-parts-duplicate
""
(N_ "/Song/Duplicate parts (loop range)")
@@ -21,7 +18,6 @@
"Stefan Westerfeld"
"Provided \"as is\", WITHOUT ANY WARRANTY"
(bse-param-song (N_ "Song")))
-
;; common code for duplicate & crop:
;; error checking, computing boundaries, undo, applying algorithm to each track
(define (song-parts-operation song errtitle operation)
@@ -46,7 +42,6 @@
'text2 (_ "The loop range of the specified song contains no parts "
"or is unset, so no parts can be identified to operate on.")
'check (_ "Show messages about empty part range")))))
-
;; algorithm for cropping parts
(define (song-parts-crop song)
(song-parts-operation song (_ "Failed to crop part range.")
@@ -58,7 +53,6 @@
(bse-track-remove-tick track tick))
((>= tick start) (bse-track-remove-tick track tick)))))
(bse-track-list-parts track)))))
-
;; algorithm for duplication of parts
(define (song-parts-duplicate song)
(song-parts-operation song (_ "Failed to duplicate part range.")
@@ -70,5 +64,4 @@
(bse-track-remove-tick track tick))
((>= tick start) (bse-track-insert-part track (+ tick len) part)))))
(reverse (bse-track-list-parts track))))))
-
;; vim:set sw=2 sts=2 ts=8:
diff --git a/plugins/artscompressor.cc b/plugins/artscompressor.cc
index f586bd8..3295175 100644
--- a/plugins/artscompressor.cc
+++ b/plugins/artscompressor.cc
@@ -1,21 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "artscompressor.genidl.hh"
-
#include <bse/bsemath.hh>
#include <string.h>
-
-
namespace Bse {
namespace Arts {
using namespace std;
-
/*
* constants
*/
#define LN2 (BSE_LN2) /* ln(2) */
static const double MUG_CORR_FACT = 0.4; /* makeup gain correction factor (from jamin-0.9.0 source)
* dampens the makeup gain correction to stop it over correcting */
-
class Compressor : public CompressorBase
{
/*
@@ -42,7 +37,6 @@ class Compressor : public CompressorBase
threshold = comp_db2linear (threshold_db);
ratio = 1 / params->ratio_to_one;
output = comp_db2linear (params->output_db);
-
/* compute half-life times: using max ensures that computing the attack- and releasefactor will
* (a) not result in division by zero
* (b) result in a value <= 1.0, where 1.0 means: adapt volume immediately, without half-life time
@@ -70,17 +64,14 @@ class Compressor : public CompressorBase
{
double volume_db = comp_linear2db (volume);
double output_signal = comp_db2linear ((volume_db - threshold_db) * ratio + threshold_db) / volume * input_signal * output;
-
return output_signal;
}
-
static const int CHANNEL_A1 = 1;
static const int CHANNEL_A2 = 2;
static const int CHANNELS_A1n_A2n = 0;
static const int CHANNELS_A1y_A2n = CHANNEL_A1;
static const int CHANNELS_A1n_A2y = CHANNEL_A2;
static const int CHANNELS_A1y_A2y = CHANNEL_A1 + CHANNEL_A2;
-
template<int channels> void
process_loop (unsigned int samples)
{
@@ -88,7 +79,6 @@ class Compressor : public CompressorBase
const float *invalue2 = istream (ICHANNEL_AUDIO_IN2).values;
float *outvalue1 = ostream (OCHANNEL_AUDIO_OUT1).values;
float *outvalue2 = ostream (OCHANNEL_AUDIO_OUT2).values;
-
for( unsigned int i = 0; i < samples; i++ ) {
double delta = 0.0;
switch (channels)
@@ -102,12 +92,10 @@ class Compressor : public CompressorBase
case CHANNELS_A1y_A2y: delta = max (fabs (invalue1[i]), fabs (invalue2[i])) - volume;
break;
}
-
if( delta > 0.0 )
volume += attackfactor * delta;
else
volume += releasefactor * delta;
-
if (volume > threshold)
{
if (channels & CHANNEL_A1)
@@ -198,18 +186,13 @@ public:
{
if (prop_id == PROP_OUTPUT_DB && auto_output)
return false;
-
return true;
}
BSE_EFFECT_INTEGRATE_MODULE (Compressor, Module, CompressorProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Compressor);
-
// printf ("input: %f dB (%f), output: %f dB (%f)\n", comp_linear2db (volume), volume, comp_linear2db (compress (volume)), compress (volume));
-
} // Arts
} // Bse
-
/* vim:set ts=8 sw=2 sts=2: */
diff --git a/plugins/artscompressor.idl b/plugins/artscompressor.idl
index c3d20fd..9ed1606 100644
--- a/plugins/artscompressor.idl
+++ b/plugins/artscompressor.idl
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
namespace Arts {
-
class Compressor : Effect {
Info icon = "icons/compressor.png";
Info authors = "Matthias Kretz, Stefan Westerfeld";
@@ -33,7 +31,6 @@ class Compressor : Effect {
IStream audio_in2 = (_("Audio In2"), _("Audio input 2"));
OStream audio_out1 = (_("Audio Out1"), _("Compressed audio output 1"));
OStream audio_out2 = (_("Audio Out2"), _("Compressed audio output 2"));
-
group _("Parameters") {
Real attack = Real (_("Attack [ms]"), _("Set the attack time in milliseconds"), 10.0, 0.1, 250.0, 10.0, STANDARD ":scale");
Real release = Real (_("Release [ms]"), _("Set the release time in milliseconds"), 10.0, 0.1, 250.0, 10.0, STANDARD ":scale");
@@ -48,8 +45,6 @@ class Compressor : Effect {
Real output = Real (NULL, NULL, 1, 0.1, 10.0, 1, "w");
};
};
-
}; // Arts
}; // Bse
-
/* vim:set ts=8 sw=2 sts=2 syntax=cpp: */
diff --git a/plugins/bseadder.cc b/plugins/bseadder.cc
index 4da2766..6b39525 100644
--- a/plugins/bseadder.cc
+++ b/plugins/bseadder.cc
@@ -1,20 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseadder.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
#include <string.h>
-
-
/* --- parameters --- */
enum
{
PARAM_0,
PARAM_SUBTRACT,
};
-
-
/* --- prototypes --- */
static void bse_adder_init (BseAdder *self);
static void bse_adder_class_init (BseAdderClass *klass);
@@ -32,19 +26,14 @@ static void bse_adder_context_create (BseSource *source,
BseTrans *trans);
static void bse_adder_update_modules (BseAdder *self,
BseTrans *trans);
-
-
/* --- Export to BSE --- */
#include "./icons/sum.c"
BSE_RESIDENT_SOURCE_DEF (BseAdder, bse_adder, N_("Routing/Adder"),
"The Adder is a very simplisitic prototype mixer that just sums up "
"incoming signals (it does allow for switching to subtract mode though)",
sum_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_adder_class_init (BseAdderClass *klass)
@@ -54,18 +43,12 @@ bse_adder_class_init (BseAdderClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel;
-
parent_class = g_type_class_peek (BSE_TYPE_SOURCE);
-
gobject_class->set_property = bse_adder_set_property;
gobject_class->get_property = bse_adder_get_property;
-
object_class->get_icon = bse_adder_do_get_icon;
-
source_class->context_create = bse_adder_context_create;
-
klass->sub_icon = bse_icon_from_pixstream (sub_pixstream);
-
bse_object_class_add_param (object_class, "Features",
PARAM_SUBTRACT,
sfi_pspec_bool ("subtract", "Subtract instead",
@@ -73,7 +56,6 @@ bse_adder_class_init (BseAdderClass *klass)
"values (instead of addition)",
FALSE,
SFI_PARAM_STANDARD ":skip-default"));
-
channel = bse_source_class_add_jchannel (source_class, "audio-in1", _("Audio In1"), _("Audio Input 1"));
g_assert (channel == BSE_ADDER_JCHANNEL_AUDIO1);
channel = bse_source_class_add_jchannel (source_class, "audio-in2", _("Audio In2"), _("Audio Input 2"));
@@ -81,24 +63,20 @@ bse_adder_class_init (BseAdderClass *klass)
channel = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Audio Output"));
g_assert (channel == BSE_ADDER_OCHANNEL_AUDIO_OUT);
}
-
static void
bse_adder_init (BseAdder *self)
{
self->subtract = FALSE;
}
-
static BseIcon*
bse_adder_do_get_icon (BseObject *object)
{
BseAdder *self = BSE_ADDER (object);
-
if (self->subtract)
return BSE_ADDER_GET_CLASS (self)->sub_icon;
else /* chain parent class' handler */
return BSE_OBJECT_CLASS (parent_class)->get_icon (object);
}
-
static void
bse_adder_set_property (GObject *object,
guint param_id,
@@ -106,7 +84,6 @@ bse_adder_set_property (GObject *object,
GParamSpec *pspec)
{
BseAdder *self = BSE_ADDER (object);
-
switch (param_id)
{
case PARAM_SUBTRACT:
@@ -119,7 +96,6 @@ bse_adder_set_property (GObject *object,
break;
}
}
-
static void
bse_adder_get_property (GObject *object,
guint param_id,
@@ -127,7 +103,6 @@ bse_adder_get_property (GObject *object,
GParamSpec *pspec)
{
BseAdder *self = BSE_ADDER (object);
-
switch (param_id)
{
case PARAM_SUBTRACT:
@@ -138,12 +113,10 @@ bse_adder_get_property (GObject *object,
break;
}
}
-
typedef struct
{
gboolean subtract;
} Adder;
-
static void
bse_adder_update_modules (BseAdder *self,
BseTrans *trans)
@@ -155,7 +128,6 @@ bse_adder_update_modules (BseAdder *self,
sizeof (self->subtract),
trans);
}
-
static void
adder_process (BseModule *module,
guint n_values)
@@ -167,7 +139,6 @@ adder_process (BseModule *module,
gfloat *bound = audio_out + n_values;
const gfloat *auin;
guint i;
-
if (!n_au1 && !n_au2)
{
module->ostreams[BSE_ADDER_OCHANNEL_AUDIO_OUT].values = bse_engine_const_values (0);
@@ -191,7 +162,6 @@ adder_process (BseModule *module,
}
else
memset (audio_out, 0, n_values * sizeof (audio_out[0]));
-
if (n_au2 && !adder->subtract) /* sum up audio2 inputs */
for (i = 0; i < n_au2; i++)
{
@@ -211,7 +181,6 @@ adder_process (BseModule *module,
while (out < bound);
}
}
-
static void
bse_adder_context_create (BseSource *source,
guint context_handle,
@@ -230,18 +199,13 @@ bse_adder_context_create (BseSource *source,
BseAdder *adder = BSE_ADDER (source);
Adder *add = g_new0 (Adder, 1);
BseModule *module;
-
module = bse_module_new (&add_class, add);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
/* update module data */
bse_adder_update_modules (adder, trans);
}
diff --git a/plugins/bseadder.hh b/plugins/bseadder.hh
index 919833e..1bfa3a2 100644
--- a/plugins/bseadder.hh
+++ b/plugins/bseadder.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ADDER_H__
#define __BSE_ADDER_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_ADDER (bse_adder_get_type())
#define BSE_ADDER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_ADDER, BseAdder))
@@ -17,25 +13,19 @@ extern "C" {
#define BSE_IS_ADDER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_ADDER))
#define BSE_IS_ADDER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_ADDER))
#define BSE_ADDER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_ADDER, BseAdderClass))
-
-
/* --- BseAdder source --- */
typedef struct _BseAdder BseAdder;
typedef struct _BseAdderClass BseAdderClass;
struct _BseAdder
{
BseSource parent_object;
-
gboolean subtract;
};
struct _BseAdderClass
{
BseSourceClass parent_class;
-
BseIcon *sub_icon;
};
-
-
/* --- channels --- */
enum
{
@@ -48,11 +38,7 @@ enum
BSE_ADDER_OCHANNEL_AUDIO_OUT,
BSE_ADDER_N_OCHANNELS
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_ADDER_H__ */
diff --git a/plugins/bseamplifier.cc b/plugins/bseamplifier.cc
index 25fbf9e..cf395e4 100644
--- a/plugins/bseamplifier.cc
+++ b/plugins/bseamplifier.cc
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseamplifier.genidl.hh"
#include <bse/bsemathsignal.hh>
-
namespace Bse {
-
class Amplifier : public AmplifierBase {
/* amplifier module implementation */
class Module : public SynthesisModule {
@@ -74,7 +72,6 @@ class Amplifier : public AmplifierBase {
cv_sum = cl1 * *cv1in++;
else if (CCASE == CCASE_C1n_C2y)
cv_sum = cl2 * *cv2in++;
-
if (G_UNLIKELY (cv_sum < 0))
cv_sum = 0;
else
@@ -85,7 +82,6 @@ class Amplifier : public AmplifierBase {
if (G_UNLIKELY (cv_sum > 1.0))
cv_sum = 1.0;
}
-
double au_out; // never unused
if (ACASE == ACASE_A1b_A2b) /* audio input, au1 and/or au2 */
au_out = al1 * *au1in++ + al2 * *au2in++;
@@ -93,7 +89,6 @@ class Amplifier : public AmplifierBase {
au_out = al1 * *au1in++;
else if (ACASE == ACASE_A1n_A2y)
au_out = al2 * *au2in++;
-
au_out *= cv_sum;
*audio_out++ = au_out;
}
@@ -127,7 +122,6 @@ class Amplifier : public AmplifierBase {
simple_control = true;
if (!simple_control && ctrl_exp)
mode |= WITH_EXP_CONTROLS;
-
if (simple_control)
switch (mode)
{
@@ -234,9 +228,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Amplifier, Module, AmplifierProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Amplifier);
-
} // Bse
-
diff --git a/plugins/bseamplifier.idl b/plugins/bseamplifier.idl
index 65ae8a2..f83d125 100644
--- a/plugins/bseamplifier.idl
+++ b/plugins/bseamplifier.idl
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bsecore.idl>
namespace Bse { // FIXME: bad workaround
class Effect;
};
-
namespace Bse {
-
class Amplifier : Effect {
Info icon = "icons/ampctrl.png";
Info authors = "Tim Janik";
@@ -59,5 +56,4 @@ class Amplifier : Effect {
Real olevel = Perc (NULL, NULL, 100, "w"); /* -> master_volume (v0.6.2) */
};
};
-
};
diff --git a/plugins/bseatandistort.cc b/plugins/bseatandistort.cc
index fbf0e84..17ede85 100644
--- a/plugins/bseatandistort.cc
+++ b/plugins/bseatandistort.cc
@@ -3,16 +3,12 @@
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsecxxplugin.hh>
-
-
/* --- parameters --- */
enum
{
PARAM_0,
PARAM_BOOST_AMOUNT
};
-
-
/* --- prototypes --- */
static void bse_atan_distort_init (BseAtanDistort *self);
static void bse_atan_distort_class_init (BseAtanDistortClass *klass);
@@ -28,8 +24,6 @@ static void bse_atan_distort_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
static void bse_atan_distort_update_modules (BseAtanDistort *comp);
-
-
/* --- Export to BSE --- */
#include "./icons/atan.c"
BSE_RESIDENT_SOURCE_DEF (BseAtanDistort, bse_atan_distort, "Distortion/Atan Distort",
@@ -37,11 +31,8 @@ BSE_RESIDENT_SOURCE_DEF (BseAtanDistort, bse_atan_distort, "Distortion/Atan Dist
"(in a manner similar to the atan(3) mathematical function, thus it's name). "
"The strength with which the input signal is treated is adjustable from "
"maximum attenuation to maximum boost.", atan_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_atan_distort_class_init (BseAtanDistortClass *klass)
@@ -50,14 +41,10 @@ bse_atan_distort_class_init (BseAtanDistortClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_atan_distort_set_property;
gobject_class->get_property = bse_atan_distort_get_property;
-
source_class->context_create = bse_atan_distort_context_create;
-
bse_object_class_add_param (object_class, "Adjustments",
PARAM_BOOST_AMOUNT,
sfi_pspec_real ("boost_amount", "Boost Amount [%]",
@@ -65,20 +52,17 @@ bse_atan_distort_class_init (BseAtanDistortClass *klass)
"from maximum attenuation (0%) to maximum boost (100%).",
50, 0, 100.0, 5,
SFI_PARAM_STANDARD ":f:scale"));
-
channel_id = bse_source_class_add_ichannel (source_class, "audio-in", _("Audio In"), _("Audio Input Signal"));
g_assert (channel_id == BSE_ATAN_DISTORT_ICHANNEL_MONO1);
channel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Distorted Audio Output"));
g_assert (channel_id == BSE_ATAN_DISTORT_OCHANNEL_MONO1);
}
-
static void
bse_atan_distort_init (BseAtanDistort *self)
{
self->boost_amount = 0.5;
self->prescale = bse_approx_atan1_prescale (self->boost_amount);
}
-
static void
bse_atan_distort_set_property (GObject *object,
guint param_id,
@@ -86,7 +70,6 @@ bse_atan_distort_set_property (GObject *object,
GParamSpec *pspec)
{
BseAtanDistort *self = BSE_ATAN_DISTORT (object);
-
switch (param_id)
{
case PARAM_BOOST_AMOUNT:
@@ -99,7 +82,6 @@ bse_atan_distort_set_property (GObject *object,
}
bse_atan_distort_update_modules (self);
}
-
static void
bse_atan_distort_get_property (GObject *object,
guint param_id,
@@ -107,7 +89,6 @@ bse_atan_distort_get_property (GObject *object,
GParamSpec *pspec)
{
BseAtanDistort *self = BSE_ATAN_DISTORT (object);
-
switch (param_id)
{
case PARAM_BOOST_AMOUNT:
@@ -118,12 +99,10 @@ bse_atan_distort_get_property (GObject *object,
break;
}
}
-
typedef struct
{
gdouble prescale;
} AtanDistortModule;
-
static void
bse_atan_distort_update_modules (BseAtanDistort *self)
{
@@ -148,7 +127,6 @@ bse_atan_distort_update_modules (BseAtanDistort *self)
NULL);
}
}
-
static void
atan_distort_process (BseModule *module,
guint n_values)
@@ -158,7 +136,6 @@ atan_distort_process (BseModule *module,
gfloat *sig_out = module->ostreams[BSE_ATAN_DISTORT_OCHANNEL_MONO1].values;
gfloat *bound = sig_out + n_values;
gdouble prescale = admod->prescale;
-
/* we don't need to process any data if our input or
* output stream isn't connected
*/
@@ -171,13 +148,11 @@ atan_distort_process (BseModule *module,
module->ostreams[BSE_ATAN_DISTORT_OCHANNEL_MONO1].values = bse_engine_const_values (0);
return;
}
-
/* do the mixing */
do
*sig_out++ = bse_approx_atan1 (prescale * *sig_in++);
while (sig_out < bound);
}
-
static void
bse_atan_distort_context_create (BseSource *source,
guint context_handle,
@@ -196,19 +171,15 @@ bse_atan_distort_context_create (BseSource *source,
BseAtanDistort *self = BSE_ATAN_DISTORT (source);
AtanDistortModule *admod;
BseModule *module;
-
/* for each context that BseAtanDistort is used in, we create
* a BseModule with data portion AtanDistortModule, that runs
* in the synthesis engine.
*/
admod = g_new0 (AtanDistortModule, 1);
-
/* initial setup of module parameters */
admod->prescale = self->prescale;
-
/* create a BseModule with AtanDistortModule as user_data */
module = bse_module_new (&admod_class, admod);
-
/* the istreams and ostreams of our BseModule map 1:1 to
* BseAtanDistort's input/output channels, so we can call
* bse_source_set_context_module() which does all the internal
@@ -216,10 +187,8 @@ bse_atan_distort_context_create (BseSource *source,
* input/output channels of BseAtanDistort
*/
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/plugins/bseatandistort.hh b/plugins/bseatandistort.hh
index 56388d6..a08ea11 100644
--- a/plugins/bseatandistort.hh
+++ b/plugins/bseatandistort.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_ATAN_DISTORT_H__
#define __BSE_ATAN_DISTORT_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_ATAN_DISTORT (bse_atan_distort_get_type())
#define BSE_ATAN_DISTORT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_ATAN_DISTORT, BseAtanDistort))
@@ -17,15 +13,12 @@ extern "C" {
#define BSE_IS_ATAN_DISTORT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_ATAN_DISTORT))
#define BSE_IS_ATAN_DISTORT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_ATAN_DISTORT))
#define BSE_ATAN_DISTORT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_ATAN_DISTORT, BseAtanDistortClass))
-
-
/* --- BseAtanDistort source --- */
typedef struct _BseAtanDistort BseAtanDistort;
typedef struct _BseAtanDistortClass BseAtanDistortClass;
struct _BseAtanDistort
{
BseSource parent_object;
-
gfloat boost_amount;
gdouble prescale;
};
@@ -33,8 +26,6 @@ struct _BseAtanDistortClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -46,11 +37,7 @@ enum
BSE_ATAN_DISTORT_OCHANNEL_MONO1,
BSE_ATAN_DISTORT_N_OCHANNELS
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_ATAN_DISTORT_H__ */
diff --git a/plugins/bsebalance.cc b/plugins/bsebalance.cc
index c762fd2..3c2bf37 100644
--- a/plugins/bsebalance.cc
+++ b/plugins/bsebalance.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsebalance.genidl.hh"
-
namespace Bse {
-
class Balance : public BalanceBase {
/* balance module implementation */
class Module : public SynthesisModule {
@@ -97,8 +95,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Balance, Module, BalanceProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Balance);
-
} // Bse
diff --git a/plugins/bsebalance.idl b/plugins/bsebalance.idl
index 82f45b3..f799686 100644
--- a/plugins/bsebalance.idl
+++ b/plugins/bsebalance.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
-
class Balance : Effect {
Info icon = "icons/balance.png";
Info authors = "Tim Janik";
@@ -39,5 +37,4 @@ class Balance : Effect {
Real obalance = Balance (_("Output Balance"), _("Adjust output balance between left and right"), 0, STANDARD);
};
};
-
};
diff --git a/plugins/bseblockutils.cc b/plugins/bseblockutils.cc
index 6911241..65a228c 100644
--- a/plugins/bseblockutils.cc
+++ b/plugins/bseblockutils.cc
@@ -7,18 +7,14 @@
#error SSE support is required for this plugin.
#endif
#include <xmmintrin.h>
-
#define ALIGNMENT16(pointer) (0xf & (ptrdiff_t) (pointer))
#define ALIGNED16(pointer) (!ALIGNMENT16 (pointer))
#ifndef _mm_extract_ss
#define _mm_extract_ss(_M128) ({ float result; _mm_store_ss (&result, _M128); result; })
#endif
-
namespace {
-
using std::max;
using std::min;
-
class BlockImpl : virtual public Bse::Block::Impl {
virtual const char*
impl_name ()
@@ -147,7 +143,6 @@ class BlockImpl : virtual public Bse::Block::Impl {
if (LIKELY (n_values))
{
minv = maxv = ivalues[0];
-
guint upos = 0, n_vectors = 0;
if (LIKELY (n_values > 8))
{
@@ -241,7 +236,6 @@ class BlockImpl : virtual public Bse::Block::Impl {
if (LIKELY (n_values))
{
minv = maxv = ivalues[0];
-
guint upos = 0, n_vectors = 0;
if (LIKELY (n_values > 8))
{
@@ -334,9 +328,7 @@ public:
};
static BlockImpl sse_block_impl;
} // Anon
-
namespace Bse {
-
class CoreHook {
public:
void
@@ -345,8 +337,6 @@ public:
sse_block_impl.hookup();
}
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_STATIC_HOOK (CoreHook);
-
} // Bse
diff --git a/plugins/bsecontribsampleandhold.cc b/plugins/bsecontribsampleandhold.cc
index c682933..8fc70fc 100644
--- a/plugins/bsecontribsampleandhold.cc
+++ b/plugins/bsecontribsampleandhold.cc
@@ -1,27 +1,22 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsecontribsampleandhold.genidl.hh"
#include <bse/bseengine.hh>
-
namespace Bse { namespace Contrib {
-
class SampleAndHold: public SampleAndHoldBase {
class Module: public SynthesisModule {
gfloat value;
gboolean negative;
-
public:
void
config (SampleAndHoldProperties *params)
{
}
-
void
reset ()
{
value = 0;
negative = true;
}
-
void
process (unsigned int n_values)
{
@@ -29,7 +24,6 @@ class SampleAndHold: public SampleAndHoldBase {
const float *trigger = istream (ICHANNEL_TRIGGER_IN).values;
float *output = ostream (OCHANNEL_AUDIO_OUT).values;
float *bound = output + n_values;
-
while (output < bound)
{
float t = *trigger++;
@@ -47,12 +41,9 @@ class SampleAndHold: public SampleAndHoldBase {
}
}
};
-
public:
BSE_EFFECT_INTEGRATE_MODULE (SampleAndHold, Module, SampleAndHoldProperties);
};
-
BSE_CXX_DEFINE_EXPORTS ();
BSE_CXX_REGISTER_EFFECT (SampleAndHold);
-
} } // Bse::Contrib
diff --git a/plugins/bsecontribsampleandhold.idl b/plugins/bsecontribsampleandhold.idl
index 021246a..181064c 100644
--- a/plugins/bsecontribsampleandhold.idl
+++ b/plugins/bsecontribsampleandhold.idl
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse { namespace Contrib {
class SampleAndHold: Effect {
Info icon = "icons/sample+hold.png";
diff --git a/plugins/bsefirfilter.c b/plugins/bsefirfilter.c
index 62b6a98..fedce8b 100644
--- a/plugins/bsefirfilter.c
+++ b/plugins/bsefirfilter.c
@@ -1,8 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsefirfilter.hh"
-
-
-
/* --- parameters --- */
enum
{
@@ -16,8 +13,6 @@ enum
PARAM_CUT_OFF_FREQ,
PARAM_CUT_OFF_NOTE
};
-
-
/* --- prototypes --- */
static void bse_fir_filter_init (BseFIRFilter *fir_filter);
static void bse_fir_filter_class_init (BseFIRFilterClass *class);
@@ -37,26 +32,20 @@ static BseChunk* bse_fir_filter_calc_chunk (BseSource *source,
guint ochannel_id);
static void bse_fir_filter_reset (BseSource *source);
static inline void bse_fir_filter_update_locals (BseFIRFilter *filter);
-
-
/* --- variables --- */
static GType type_id_fir_filter = 0;
static gpointer parent_class = NULL;
static const GTypeInfo type_info_fir_filter = {
sizeof (BseFIRFilterClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) bse_fir_filter_class_init,
(GClassFinalizeFunc) bse_fir_filter_class_finalize,
NULL /* class_data */,
-
sizeof (BseFIRFilter),
0 /* n_preallocs */,
(GInstanceInitFunc) bse_fir_filter_init,
};
-
-
/* --- functions --- */
static void
bse_fir_filter_class_init (BseFIRFilterClass *class)
@@ -65,18 +54,13 @@ bse_fir_filter_class_init (BseFIRFilterClass *class)
BseObjectClass *object_class = BSE_OBJECT_CLASS (class);
BseSourceClass *source_class = BSE_SOURCE_CLASS (class);
guint ochannel_id, ichannel_id;
-
parent_class = g_type_class_peek (BSE_TYPE_SOURCE);
-
gobject_class->set_property = bse_fir_filter_set_property;
gobject_class->get_property = bse_fir_filter_get_property;
-
object_class->destroy = bse_fir_filter_do_destroy;
-
source_class->prepare = bse_fir_filter_prepare;
source_class->calc_chunk = bse_fir_filter_calc_chunk;
source_class->reset = bse_fir_filter_reset;
-
bse_object_class_add_param (object_class, "Filter Type",
PARAM_ALLPASS,
sfi_pspec_bool ("allpass", "AllPass", NULL,
@@ -122,19 +106,16 @@ bse_fir_filter_class_init (BseFIRFilterClass *class)
bse_note_from_freq (BSE_KAMMER_FREQ / 2), 1,
TRUE,
BSE_PARAM_GUI));
-
ochannel_id = bse_source_class_add_ochannel (source_class, "mono_out", _("Mono Out"), _("Mono Filtered Output"), 1);
g_assert (ochannel_id == BSE_FIR_FILTER_OCHANNEL_MONO);
ichannel_id = bse_source_class_add_ichannel (source_class, "mono_in", _("Mono In"), _("Mono Signal Input"), 1, 1);
g_assert (ichannel_id == BSE_FIR_FILTER_ICHANNEL_MONO);
// BSE_SOURCE_CLASS_ICHANNEL_DEF (class, BSE_FIR_FILTER_ICHANNEL_MONO)->history = 2;
}
-
static void
bse_fir_filter_class_finalize (BseFIRFilterClass *class)
{
}
-
static void
bse_fir_filter_init (BseFIRFilter *filter)
{
@@ -148,35 +129,28 @@ bse_fir_filter_init (BseFIRFilter *filter)
filter->history_pos = 0;
filter->history = NULL;
}
-
static void
bse_fir_filter_do_destroy (BseObject *object)
{
BseFIRFilter *fir_filter;
-
fir_filter = BSE_FIR_FILTER (object);
-
/* chain parent class' destroy handler */
BSE_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static inline void
bse_fir_filter_update_locals (BseFIRFilter *filter)
{
gint i;
-
if (BSE_SOURCE_PREPARED (filter))
{
gdouble d, c;
gint z = filter->n_coeffs;
-
filter->n_coeffs = MIN (filter->degree, BSE_TRACK_LENGTH) * 2 + 1;
filter->history = g_renew (BseSampleValue, filter->history, filter->n_coeffs);
for (i = z; i < filter->n_coeffs; i++)
filter->history[i] = 0;
z = filter->n_coeffs / 2;
filter->history_pos %= filter->n_coeffs;
-
/* setup allpass
*/
g_free (filter->coeffs);
@@ -184,7 +158,6 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
for (i = 0; i < filter->n_coeffs; i++)
filter->coeffs[i] = 0;
filter->coeffs[z] = 1;
-
/* setup lowpass (precalculate highpass)
*/
if (filter->filter_type == BSE_FIR_FILTER_LOWPASS ||
@@ -200,12 +173,10 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
else
{
gdouble k = i - z;
-
filter->coeffs[i] = d * sin (c * k) / (c * k);
}
}
}
-
if (filter->lanczos_smoothing)
{
c = z;
@@ -213,12 +184,10 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
for (i = 0; i < filter->n_coeffs; i++)
{
gdouble k = (i - z);
-
if (k)
filter->coeffs[i] *= sin (c * k) / (c * k);
}
}
-
if (filter->hann_smoothing)
{
c = z;
@@ -226,11 +195,9 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
for (i = 0; i < filter->n_coeffs; i++)
{
gdouble k = (i - z);
-
filter->coeffs[i] *= 0.5 * (1.0 + cos (c * k));
}
}
-
/* setup highpass (from lowpass)
*/
if (filter->filter_type == BSE_FIR_FILTER_HIGHPASS)
@@ -241,7 +208,6 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
else
filter->coeffs[i] = - filter->coeffs[i];
}
-
#if 0
for (i = 0; i < filter->n_coeffs; i++)
g_print ("a[%d]=%f ", i - z, filter->coeffs[i]);
@@ -249,7 +215,6 @@ bse_fir_filter_update_locals (BseFIRFilter *filter)
#endif
}
}
-
static void
bse_fir_filter_set_property (BseFIRFilter *filter,
guint param_id,
@@ -257,7 +222,6 @@ bse_fir_filter_set_property (BseFIRFilter *filter,
GParamSpec *pspec)
{
BseFIRFilterType filter_type = BSE_FIR_FILTER_ALLPASS;
-
switch (param_id)
{
guint v_uint;
@@ -308,7 +272,6 @@ bse_fir_filter_set_property (BseFIRFilter *filter,
break;
}
}
-
static void
bse_fir_filter_get_property (BseFIRFilter *filter,
guint param_id,
@@ -346,19 +309,15 @@ bse_fir_filter_get_property (BseFIRFilter *filter,
break;
}
}
-
static void
bse_fir_filter_prepare (BseSource *source,
BseIndex index)
{
BseFIRFilter *filter = BSE_FIR_FILTER (source);
-
bse_fir_filter_update_locals (filter);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source, index);
}
-
static BseChunk*
bse_fir_filter_calc_chunk (BseSource *source,
guint ochannel_id)
@@ -369,22 +328,16 @@ bse_fir_filter_calc_chunk (BseSource *source,
BseSampleValue *hunk, *ihunk, *hvals;
gfloat *coeffs;
guint i, n_coeffs, history_pos;
-
g_return_val_if_fail (ochannel_id == BSE_FIR_FILTER_OCHANNEL_MONO, NULL);
-
input = bse_source_get_input (source, BSE_FIR_FILTER_ICHANNEL_MONO); /* mono */
if (!input) /* silence */
return bse_chunk_new_static_zero (1);
-
ichunk = bse_source_ref_chunk (input->osource, input->ochannel_id, source->index);
bse_chunk_complete_hunk (ichunk);
ihunk = ichunk->hunk;
-
if (filter->filter_type == BSE_FIR_FILTER_ALLPASS)
return ichunk;
-
hunk = bse_hunk_alloc (1);
-
n_coeffs = filter->n_coeffs;
coeffs = filter->coeffs;
history_pos = filter->history_pos;
@@ -393,42 +346,33 @@ bse_fir_filter_calc_chunk (BseSource *source,
{
gfloat *a;
guint n;
-
a = coeffs;
hunk[i] = 0;
for (n = history_pos; n < n_coeffs; n++)
hunk[i] += (BseSampleValue) (*(a++) * hvals[n]);
for (n = 0; n < history_pos; n++)
hunk[i] += (BseSampleValue) (*(a++) * hvals[n]);
-
hvals[history_pos++] = ihunk[i];
if (history_pos >= n_coeffs)
history_pos -= n_coeffs;
}
filter->history_pos = history_pos;
-
bse_chunk_unref (ichunk);
-
return bse_chunk_new_orphan (1, hunk);
}
-
static void
bse_fir_filter_reset (BseSource *source)
{
BseFIRFilter *filter = BSE_FIR_FILTER (source);
-
filter->n_coeffs = 0;
g_free (filter->coeffs);
filter->coeffs = NULL;
filter->history_pos = 0;
g_free (filter->history);
filter->history = NULL;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
-
-
/* --- Export to BSE --- */
#include "./icons/filter.c"
BSE_EXPORTS_BEGIN ();
diff --git a/plugins/bsefirfilter.hh b/plugins/bsefirfilter.hh
index 3edf460..01c0785 100644
--- a/plugins/bsefirfilter.hh
+++ b/plugins/bsefirfilter.hh
@@ -1,18 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_FIR_FILTER_H__
#define __BSE_FIR_FILTER_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
-
-
-
/* --- object type macros --- */
#define BSE_TYPE_FIR_FILTER (type_id_fir_filter)
#define BSE_FIR_FILTER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_FIR_FILTER, BseFIRFilter))
@@ -20,21 +13,17 @@ extern "C" {
#define BSE_IS_FIR_FILTER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_FIR_FILTER))
#define BSE_IS_FIR_FILTER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_FIR_FILTER))
#define BSE_FIR_FILTER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_FIR_FILTER, BseFIRFilterClass))
-
-
/* --- BseFIRFilter source --- */
typedef struct _BseFIRFilter BseFIRFilter;
typedef struct _BseFIRFilterClass BseFIRFilterClass;
struct _BseFIRFilter
{
BseSource parent_object;
-
guint16 degree;
guint filter_type : 8;
guint lanczos_smoothing : 1;
guint hann_smoothing : 1;
gfloat cut_off_freq;
-
guint n_coeffs;
gfloat *coeffs;
guint history_pos;
@@ -44,8 +33,6 @@ struct _BseFIRFilterClass
{
BseSourceClass parent_class;
};
-
-
/* --- enums --- */
typedef enum
{
@@ -53,8 +40,6 @@ typedef enum
BSE_FIR_FILTER_LOWPASS,
BSE_FIR_FILTER_HIGHPASS
} BseFIRFilterType;
-
-
/* --- channels --- */
enum
{
@@ -66,12 +51,7 @@ enum
BSE_FIR_FILTER_ICHANNEL_NONE,
BSE_FIR_FILTER_ICHANNEL_MONO
};
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_FIR_FILTER_H__ */
diff --git a/plugins/bseiirfilter.cc b/plugins/bseiirfilter.cc
index 7738d3d..885f5e4 100644
--- a/plugins/bseiirfilter.cc
+++ b/plugins/bseiirfilter.cc
@@ -3,11 +3,8 @@
#include <bse/bseengine.hh>
#include <bse/gslfilter.hh>
#include <bse/bsecxxplugin.hh>
-
#include <string.h>
-
#define FREQ_DELTA 0.1
-
/* --- parameters --- */
enum
{
@@ -21,8 +18,6 @@ enum
PARAM_CUT_OFF_FREQ2,
PARAM_CUT_OFF_NOTE2
};
-
-
/* --- prototypes --- */
static void bse_iir_filter_init (BseIIRFilter *iir_filter);
static void bse_iir_filter_class_init (BseIIRFilterClass *klass);
@@ -39,18 +34,13 @@ static void bse_iir_filter_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
static void bse_iir_filter_update_modules (BseIIRFilter *filt);
-
-
/* --- Export to BSE --- */
#include "./icons/filter.c"
BSE_RESIDENT_SOURCE_DEF (BseIIRFilter, bse_iir_filter, N_("Filters/IIR Filter"),
"BseIIRFilter is an infinite impulse response filter of variable order",
filter_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_iir_filter_class_init (BseIIRFilterClass *klass)
@@ -59,15 +49,11 @@ bse_iir_filter_class_init (BseIIRFilterClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel_id, ichannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_iir_filter_set_property;
gobject_class->get_property = bse_iir_filter_get_property;
-
source_class->prepare = bse_iir_filter_prepare;
source_class->context_create = bse_iir_filter_context_create;
-
bse_object_class_add_param (object_class, _("Filter Choice"),
PARAM_FILTER_ALGO,
bse_param_spec_genum ("filter_algorithm", _("Filter Algorithm"), _("The filter design type"),
@@ -112,13 +98,11 @@ bse_iir_filter_class_init (BseIIRFilterClass *klass)
_("Filter cutoff frequency as note, converted to Hertz according to the current musical tuning"),
bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET, BSE_KAMMER_FREQUENCY / 2 + FREQ_DELTA),
SFI_PARAM_GUI));
-
ichannel_id = bse_source_class_add_ichannel (source_class, "audio-in", _("Audio In"), _("Unfiltered Input"));
g_assert (ichannel_id == BSE_IIR_FILTER_ICHANNEL_MONO);
ochannel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Filtered Output"));
g_assert (ochannel_id == BSE_IIR_FILTER_OCHANNEL_MONO);
}
-
static void
bse_iir_filter_init (BseIIRFilter *filt)
{
@@ -130,7 +114,6 @@ bse_iir_filter_init (BseIIRFilter *filt)
filt->cut_off_freq2 = filt->cut_off_freq1 + FREQ_DELTA;
bse_iir_filter_update_modules (filt);
}
-
static void
bse_iir_filter_set_property (GObject *object,
guint param_id,
@@ -138,7 +121,6 @@ bse_iir_filter_set_property (GObject *object,
GParamSpec *pspec)
{
BseIIRFilter *self = BSE_IIR_FILTER (object);
-
switch (param_id)
{
case PARAM_FILTER_ALGO:
@@ -210,7 +192,6 @@ bse_iir_filter_set_property (GObject *object,
break;
}
}
-
static void
bse_iir_filter_get_property (GObject *object,
guint param_id,
@@ -218,7 +199,6 @@ bse_iir_filter_get_property (GObject *object,
GParamSpec *pspec)
{
BseIIRFilter *self = BSE_IIR_FILTER (object);
-
switch (param_id)
{
case PARAM_FILTER_ALGO:
@@ -250,41 +230,33 @@ bse_iir_filter_get_property (GObject *object,
break;
}
}
-
static void
bse_iir_filter_prepare (BseSource *source)
{
BseIIRFilter *filt = BSE_IIR_FILTER (source);
-
/* need to call update_modules() because we only now have bse_engine_sample_freq() */
bse_iir_filter_update_modules (filt);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
typedef struct {
GslIIRFilter iir;
gdouble dummy[(BSE_IIR_FILTER_MAX_ORDER + 1) * 4];
} FilterModule;
-
static void
iir_filter_access (BseModule *module,
gpointer data)
{
FilterModule *fmod = (FilterModule*) module->user_data;
FilterModule *src = (FilterModule*) data;
-
if (src->iir.w) /* algo_type_change */
gsl_iir_filter_setup (&fmod->iir, src->iir.order, src->iir.a, src->iir.b, fmod->dummy);
else
gsl_iir_filter_change (&fmod->iir, src->iir.order, src->iir.a, src->iir.b, fmod->dummy);
}
-
static void
bse_iir_filter_update_modules (BseIIRFilter *filt)
{
-
if (BSE_SOURCE_PREPARED (filt))
{
FilterModule *fmod = g_new0 (FilterModule, 1);
@@ -292,10 +264,8 @@ bse_iir_filter_update_modules (BseIIRFilter *filt)
gfloat freq1 = MIN (filt->cut_off_freq1, 0.5 * bse_engine_sample_freq ());
gfloat freq2 = MIN (filt->cut_off_freq2, 0.5 * bse_engine_sample_freq ());
gfloat steepness = 1.1;
-
freq1 *= nyquist_fact;
freq2 *= nyquist_fact;
-
switch (filt->filter_algo << 16 | filt->filter_type)
{
case BSE_IIR_FILTER_BUTTERWORTH << 16 | BSE_IIR_FILTER_LOW_PASS:
@@ -337,23 +307,19 @@ bse_iir_filter_update_modules (BseIIRFilter *filt)
default:
g_assert_not_reached ();
}
-
fmod->iir.order = filt->order;
fmod->iir.a = fmod->dummy;
fmod->iir.b = fmod->iir.a + filt->order + 1;
memcpy (fmod->iir.a, filt->a, sizeof (filt->a[0]) * (filt->order + 1));
memcpy (fmod->iir.b, filt->b, sizeof (filt->b[0]) * (filt->order + 1));
-
/* abusing f->w as simple flag for algo_type_change */
fmod->iir.w = filt->algo_type_change ? fmod->dummy : NULL;
filt->algo_type_change = FALSE;
-
bse_source_access_modules (BSE_SOURCE (filt),
iir_filter_access, fmod, g_free,
NULL);
}
}
-
static void
iir_filter_process (BseModule *module,
guint n_values)
@@ -361,10 +327,8 @@ iir_filter_process (BseModule *module,
FilterModule *fmod = (FilterModule*) module->user_data;
const gfloat *sig_in = BSE_MODULE_IBUFFER (module, BSE_IIR_FILTER_ICHANNEL_MONO);
gfloat *sig_out = BSE_MODULE_OBUFFER (module, BSE_IIR_FILTER_OCHANNEL_MONO);
-
gsl_iir_filter_eval (&fmod->iir, n_values, sig_in, sig_out);
}
-
static void
bse_iir_filter_context_create (BseSource *source,
guint context_handle,
@@ -383,17 +347,12 @@ bse_iir_filter_context_create (BseSource *source,
BseIIRFilter *filt = BSE_IIR_FILTER (source);
FilterModule *fmod = g_new0 (FilterModule, 1);
BseModule *module;
-
gsl_iir_filter_setup (&fmod->iir, filt->order, filt->a, filt->b, fmod->dummy);
-
module = bse_module_new (&iir_filter_class, fmod);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/plugins/bseiirfilter.hh b/plugins/bseiirfilter.hh
index 668a4d7..c9aa844 100644
--- a/plugins/bseiirfilter.hh
+++ b/plugins/bseiirfilter.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_IIR_FILTER_H__
#define __BSE_IIR_FILTER_H__
-
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- type macros --- */
#define BSE_TYPE_IIR_FILTER (bse_iir_filter_get_type())
#define BSE_IIR_FILTER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_IIR_FILTER, BseIIRFilter))
@@ -17,8 +13,6 @@ extern "C" {
#define BSE_IS_IIR_FILTER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_IIR_FILTER))
#define BSE_IIR_FILTER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_IIR_FILTER, BseIIRFilterClass))
#define BSE_IIR_FILTER_MAX_ORDER (18)
-
-
/* --- BseIIRFilter source --- */
typedef struct _BseIIRFilter BseIIRFilter;
typedef struct _BseIIRFilterClass BseIIRFilterClass;
@@ -30,16 +24,13 @@ typedef struct
struct _BseIIRFilter
{
BseSource parent_object;
-
BseIIRFilterAlgorithm filter_algo;
BseIIRFilterType filter_type;
guint algo_type_change : 1;
-
guint order;
gdouble epsilon;
gfloat cut_off_freq1;
gfloat cut_off_freq2; /* band pass/stop */
-
gdouble a[BSE_IIR_FILTER_MAX_ORDER + 1];
gdouble b[BSE_IIR_FILTER_MAX_ORDER + 1];
};
@@ -47,8 +38,6 @@ struct _BseIIRFilterClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -60,10 +49,7 @@ enum
BSE_IIR_FILTER_OCHANNEL_MONO,
BSE_IIR_FILTER_N_OCHANNELS
};
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_IIR_FILTER_H__ */
diff --git a/plugins/bsemixer.cc b/plugins/bsemixer.cc
index 6c02171..78a06e7 100644
--- a/plugins/bsemixer.cc
+++ b/plugins/bsemixer.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemixer.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
#include <string.h>
-
#define DEFAULT_DB_VOLUME (0)
-
/* --- parameters --- */
enum
{
@@ -20,8 +16,6 @@ enum
PROP_NTH_VOLUME_dB,
PROP_NTH_VOLUME_PERC
};
-
-
/* --- prototypes --- */
static void bse_mixer_init (BseMixer *self);
static void bse_mixer_class_init (BseMixerClass *klass);
@@ -38,20 +32,14 @@ static void bse_mixer_context_create (BseSource *source,
BseTrans *trans);
static void bse_mixer_update_modules (BseMixer *self,
BseTrans *trans);
-
-
// == Type Registration ==
#include "./icons/mixer.c"
BSE_RESIDENT_SOURCE_DEF (BseMixer, bse_mixer, N_("Routing/Mixer"),
"The Mixer module sums up incomming signals, and allowes for fine "
"adjusted weighting (volume setting) of the input sources",
mixer_icon);
-
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_mixer_class_init (BseMixerClass *klass)
@@ -61,14 +49,10 @@ bse_mixer_class_init (BseMixerClass *klass)
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ichannel, ochannel;
guint i;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_mixer_set_property;
gobject_class->get_property = bse_mixer_get_property;
-
source_class->context_create = bse_mixer_context_create;
-
bse_object_class_add_param (object_class, "Adjustments",
PROP_MVOLUME_f,
sfi_pspec_real ("master_volume_f", "Master [float]", NULL,
@@ -93,7 +77,6 @@ bse_mixer_class_init (BseMixerClass *klass)
for (i = 1; i <= BSE_MIXER_N_INPUTS; i++)
{
gchar *group, *ident, *label, *blurb;
-
group = g_strdup_printf (_("Channel%u"), i);
ident = g_strdup_printf ("volume_f%u", i);
label = g_strdup_printf (_("Channel%u [float]"), i);
@@ -137,17 +120,14 @@ bse_mixer_class_init (BseMixerClass *klass)
g_free (ident);
}
}
-
static void
bse_mixer_init (BseMixer *self)
{
guint i;
-
self->master_volume_factor = bse_db_to_factor (DEFAULT_DB_VOLUME);
for (i = 0; i < BSE_MIXER_N_INPUTS; i++)
self->volume_factors[i] = bse_db_to_factor (DEFAULT_DB_VOLUME);
}
-
static void
bse_mixer_set_property (GObject *object,
guint param_id,
@@ -155,7 +135,6 @@ bse_mixer_set_property (GObject *object,
GParamSpec *pspec)
{
BseMixer *self = BSE_MIXER (object);
-
switch (param_id)
{
guint indx, n;
@@ -219,7 +198,6 @@ bse_mixer_set_property (GObject *object,
}
}
}
-
static void
bse_mixer_get_property (GObject *object,
guint param_id,
@@ -227,7 +205,6 @@ bse_mixer_get_property (GObject *object,
GParamSpec *pspec)
{
BseMixer *self = BSE_MIXER (object);
-
switch (param_id)
{
guint indx, n;
@@ -260,19 +237,16 @@ bse_mixer_get_property (GObject *object,
}
}
}
-
typedef struct
{
gfloat volumes[BSE_MIXER_N_INPUTS];
} Mixer;
-
static void
bse_mixer_update_modules (BseMixer *self,
BseTrans *trans)
{
gfloat volumes[BSE_MIXER_N_INPUTS];
guint i;
-
for (i = 0; i < BSE_MIXER_N_INPUTS; i++)
volumes[i] = self->volume_factors[i] * self->master_volume_factor;
if (BSE_SOURCE_PREPARED (self))
@@ -282,7 +256,6 @@ bse_mixer_update_modules (BseMixer *self,
sizeof (volumes),
trans);
}
-
static void
mixer_process (BseModule *module,
guint n_values)
@@ -290,18 +263,15 @@ mixer_process (BseModule *module,
Mixer *mixer = (Mixer*) module->user_data;
gfloat *wave_out = BSE_MODULE_OBUFFER (module, 0);
gfloat *wave_bound = wave_out + n_values;
-
if (module->ostreams[0].connected)
{
guint n;
-
for (n = 0; n < BSE_MODULE_N_ISTREAMS (module); n++)
if (module->istreams[n].connected)
{
const gfloat *wave_in = BSE_MODULE_IBUFFER (module, n);
gfloat *w = wave_out;
gfloat volume = mixer->volumes[n];
-
if (volume != 1.0)
do { *w++ = volume * *wave_in++; } while (w < wave_bound);
else
@@ -316,7 +286,6 @@ mixer_process (BseModule *module,
const gfloat *wave_in = BSE_MODULE_IBUFFER (module, n);
gfloat *w = wave_out;
gfloat volume = mixer->volumes[n];
-
if (volume != 1.0)
do { *w++ += volume * *wave_in++; } while (w < wave_bound);
else
@@ -324,7 +293,6 @@ mixer_process (BseModule *module,
}
}
}
-
static void
bse_mixer_context_create (BseSource *source,
guint context_handle,
@@ -342,18 +310,13 @@ bse_mixer_context_create (BseSource *source,
};
Mixer *mixer = g_new0 (Mixer, 1);
BseModule *module;
-
module = bse_module_new (&mixer_class, mixer);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
/* update module data */
bse_mixer_update_modules (BSE_MIXER (source), trans);
}
diff --git a/plugins/bsemixer.hh b/plugins/bsemixer.hh
index 7883496..8066633 100644
--- a/plugins/bsemixer.hh
+++ b/plugins/bsemixer.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MIXER_H__
#define __BSE_MIXER_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_MIXER (bse_mixer_get_type())
#define BSE_MIXER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MIXER, BseMixer))
@@ -17,17 +13,13 @@ extern "C" {
#define BSE_IS_MIXER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MIXER))
#define BSE_IS_MIXER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MIXER))
#define BSE_MIXER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MIXER, BseMixerClass))
-
#define BSE_MIXER_N_INPUTS (4)
-
-
/* --- BseMixer source --- */
typedef struct _BseMixer BseMixer;
typedef struct _BseMixerClass BseMixerClass;
struct _BseMixer
{
BseSource parent_object;
-
gfloat master_volume_factor;
gfloat volume_factors[BSE_MIXER_N_INPUTS];
};
@@ -35,20 +27,12 @@ struct _BseMixerClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
BSE_MIXER_OCHANNEL_MONO
};
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_MIXER_H__ */
diff --git a/plugins/bsemult.cc b/plugins/bsemult.cc
index 7a56f0e..f838154 100644
--- a/plugins/bsemult.cc
+++ b/plugins/bsemult.cc
@@ -1,39 +1,30 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemult.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
#include <string.h>
-
/* --- prototypes --- */
static void bse_mult_init (BseMult *mult);
static void bse_mult_class_init (BseMultClass *klass);
static void bse_mult_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
-
// == Type Registration ==
#include "./icons/multiply.c"
BSE_RESIDENT_SOURCE_DEF (BseMult, bse_mult, N_("Routing/Multiply"),
"Mult is a channel multiplier for ring-modulating incoming signals",
multiply_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_mult_class_init (BseMultClass *klass)
{
BseSourceClass *source_class;
guint ichannel, ochannel;
-
parent_class = g_type_class_peek (BSE_TYPE_SOURCE);
source_class = BSE_SOURCE_CLASS (klass);
source_class->context_create = bse_mult_context_create;
-
ichannel = bse_source_class_add_ichannel (source_class, "audio-in1", _("Audio In1"), _("Audio Input 1"));
g_assert (ichannel == BSE_MULT_ICHANNEL_MONO1);
ichannel = bse_source_class_add_ichannel (source_class, "audio-in2", _("Audio In2"), _("Audio Input 2"));
@@ -45,12 +36,10 @@ bse_mult_class_init (BseMultClass *klass)
ochannel = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Audio Output"));
g_assert (ochannel == BSE_MULT_OCHANNEL_MONO);
}
-
static void
bse_mult_init (BseMult *mult)
{
}
-
static void
multiply_process (BseModule *module,
guint n_values)
@@ -59,7 +48,6 @@ multiply_process (BseModule *module,
gfloat *wave_out = BSE_MODULE_OBUFFER (module, 0);
gfloat *bound = wave_out + n_values;
guint i;
-
if (!module->ostreams[0].connected)
return; /* nothing to process */
for (i = 0; i < BSE_MODULE_N_ISTREAMS (module); i++)
@@ -79,14 +67,12 @@ multiply_process (BseModule *module,
{
const gfloat *in = BSE_MODULE_IBUFFER (module, i);
gfloat *out = wave_out;
-
/* found 1+nth channel to multiply with */
do
*out++ *= *in++;
while (out < bound);
}
}
-
static void
bse_mult_context_create (BseSource *source,
guint context_handle,
@@ -104,15 +90,11 @@ bse_mult_context_create (BseSource *source,
};
// BseMult *mult = BSE_MULT (source);
BseModule *module;
-
module = bse_module_new (&multiply_class, NULL);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/plugins/bsemult.hh b/plugins/bsemult.hh
index 32054ba..43f596e 100644
--- a/plugins/bsemult.hh
+++ b/plugins/bsemult.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_MULT_H__
#define __BSE_MULT_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_MULT (bse_mult_get_type())
#define BSE_MULT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_MULT, BseMult))
@@ -17,8 +13,6 @@ extern "C" {
#define BSE_IS_MULT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_MULT))
#define BSE_IS_MULT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_MULT))
#define BSE_MULT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_MULT, BseMultClass))
-
-
/* --- BseMult source --- */
typedef struct _BseMult BseMult;
typedef struct _BseMultClass BseMultClass;
@@ -30,8 +24,6 @@ struct _BseMultClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -44,13 +36,7 @@ enum
{
BSE_MULT_OCHANNEL_MONO
};
-
-
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_MULT_H__ */
diff --git a/plugins/bsenoise.cc b/plugins/bsenoise.cc
index 298a873..03e3510 100644
--- a/plugins/bsenoise.cc
+++ b/plugins/bsenoise.cc
@@ -2,12 +2,9 @@
#include "bsenoise.genidl.hh"
#include <bse/bsemain.hh>
#include <vector>
-
using namespace std;
using namespace Sfi;
-
namespace Bse {
-
class Noise : public NoiseBase {
/* mini random number generator (adapted from rapicorn), to generate
* deterministic random numbers when --bse-disable-randomization was used
@@ -37,7 +34,6 @@ class Noise : public NoiseBase {
/* properties (used to pass "global" noise data into the modules) */
struct Properties : public NoiseProperties {
const vector<float> *noise_data;
-
Properties (Noise *noise) : NoiseProperties (noise), noise_data (noise->noise_data)
{
}
@@ -48,7 +44,6 @@ class Noise : public NoiseBase {
const vector<float> *noise_data;
DetRandomGenerator det_random_generator;
bool allow_randomization;
-
void
config (Properties *properties)
{
@@ -64,7 +59,6 @@ class Noise : public NoiseBase {
process (unsigned int n_values)
{
g_return_if_fail (n_values <= block_size()); /* paranoid */
-
if (allow_randomization) /* fast */
{
ostream_set (OCHANNEL_NOISE_OUT, &(*noise_data)[rand() % (noise_data->size() - n_values)]);
@@ -81,7 +75,6 @@ public:
/* preparation of a long block of random data */
static vector<float> *noise_data;
static uint noise_data_ref_count;
-
void
prepare1()
{
@@ -89,7 +82,6 @@ public:
{
const int N_NOISE_BLOCKS = 20;
noise_data = new vector<float> (max_block_size() * N_NOISE_BLOCKS);
-
for (vector<float>::iterator ni = noise_data->begin(); ni != noise_data->end(); ni++)
*ni = 1.0 - rand() / (0.5 * RAND_MAX);
}
@@ -99,7 +91,6 @@ public:
reset1()
{
g_return_if_fail (noise_data_ref_count > 0);
-
noise_data_ref_count--;
if (noise_data_ref_count == 0)
{
@@ -107,16 +98,11 @@ public:
noise_data = 0;
}
}
-
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Noise, Module, Properties);
};
-
vector<float> *Noise::noise_data = 0;
uint Noise::noise_data_ref_count = 0;
-
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Noise);
-
} // Bse
diff --git a/plugins/bsenoise.idl b/plugins/bsenoise.idl
index 8072a84..5abc8db 100644
--- a/plugins/bsenoise.idl
+++ b/plugins/bsenoise.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsecxxmodule.idl>
-
namespace Bse {
-
class Noise : Effect {
Info icon = "icons/noise.png";
Info authors = "Tim Janik";
@@ -11,5 +9,4 @@ class Noise : Effect {
Info blurb = _("Noise is a generator of (supposedly) white noise");
OStream noise_out = (_("Noise Out"), _("Noise Output"));
};
-
} // Bse
diff --git a/plugins/bsequantizer.cc b/plugins/bsequantizer.cc
index 9865740..427af9d 100644
--- a/plugins/bsequantizer.cc
+++ b/plugins/bsequantizer.cc
@@ -2,10 +2,8 @@
#include "bsequantizer.genidl.hh"
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
-
namespace Bse { namespace Standard {
using namespace Birnet;
-
class Quantizer : public QuantizerBase {
class Module: public SynthesisModule {
/* params */
@@ -73,8 +71,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Quantizer, Module, QuantizerProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ALL_TYPES_FROM_BSEQUANTIZER_IDL();
-
} } // Bse::Standard
diff --git a/plugins/bsequantizer.idl b/plugins/bsequantizer.idl
index 649e8d5..6915a48 100644
--- a/plugins/bsequantizer.idl
+++ b/plugins/bsequantizer.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse { namespace Standard {
-
class Quantizer : Bse::Effect {
Info category = "/Distortion/Quantizer";
Info icon = "icons/quantizer.png";
@@ -18,5 +16,4 @@ class Quantizer : Bse::Effect {
OStream audio_out1 = ("Audio Out1", "Audio Output 1");
OStream audio_out2 = ("Audio Out2", "Audio Output 2");
};
-
} } // Bse::Standard
diff --git a/plugins/bsesequencer.cc b/plugins/bsesequencer.cc
index 778f67f..e89e4f3 100644
--- a/plugins/bsesequencer.cc
+++ b/plugins/bsesequencer.cc
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesequencer.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
-
enum {
PARAM_0,
PARAM_NOTES,
@@ -12,8 +9,6 @@ enum {
PARAM_TRANSPOSE,
PARAM_COUNTER
};
-
-
/* --- prototypes --- */
static void bse_sequencer_init (BseSequencer *sequencer);
static void bse_sequencer_class_init (BseSequencerClass *klass);
@@ -32,17 +27,13 @@ static void bse_sequencer_context_create (BseSource *source,
BseTrans *trans);
static void bse_sequencer_reset (BseSource *source);
static void bse_sequencer_update_modules (BseSequencer *seq);
-
// == Type Registration ==
#include "./icons/sequencer.c"
BSE_RESIDENT_SOURCE_DEF (BseSequencer, bse_sequencer, N_("Other Sources/Sequencer"),
"The Sequencer produces a frequency signal according to a sequence of notes",
sequencer_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_sequencer_class_init (BseSequencerClass *klass)
@@ -51,17 +42,13 @@ bse_sequencer_class_init (BseSequencerClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = (GObjectSetPropertyFunc) bse_sequencer_set_property;
gobject_class->get_property = (GObjectGetPropertyFunc) bse_sequencer_get_property;
gobject_class->finalize = bse_sequencer_finalize;
-
source_class->prepare = bse_sequencer_prepare;
source_class->context_create = bse_sequencer_context_create;
source_class->reset = bse_sequencer_reset;
-
bse_object_class_add_param (object_class, "Sequence",
PARAM_LENGTH,
sfi_pspec_int ("length", "Length", NULL,
@@ -82,13 +69,11 @@ bse_sequencer_class_init (BseSequencerClass *klass)
sfi_pspec_real ("counter", "Timing [ms]", NULL,
100, 0, 1000, 5,
SFI_PARAM_STANDARD ":f:scale"));
-
ochannel = bse_source_class_add_ochannel (source_class, "freq-out", _("Freq Out"), _("Frequency Signal"));
g_assert (ochannel == BSE_SEQUENCER_OCHANNEL_FREQ);
ochannel = bse_source_class_add_ochannel (source_class, "note-sync", _("Note Sync"), _("Note Sync Signal"));
g_assert (ochannel == BSE_SEQUENCER_OCHANNEL_NOTE_SYNC);
}
-
static void
bse_sequencer_init (BseSequencer *seq)
{
@@ -99,18 +84,14 @@ bse_sequencer_init (BseSequencer *seq)
seq->freq_values = NULL;
seq->transpose = 0;
}
-
static void
bse_sequencer_finalize (GObject *object)
{
BseSequencer *seq = BSE_SEQUENCER (object);
-
bse_note_sequence_free (seq->sdata);
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
bse_sequencer_set_property (BseSequencer *seq,
guint param_id,
@@ -166,7 +147,6 @@ bse_sequencer_set_property (BseSequencer *seq,
break;
}
}
-
static void
bse_sequencer_get_property (BseSequencer *seq,
guint param_id,
@@ -192,7 +172,6 @@ bse_sequencer_get_property (BseSequencer *seq,
break;
}
}
-
static gfloat*
freq_values_from_seq (BseMusicalTuningType musical_tuning,
BseNoteSequence *sdata,
@@ -200,20 +179,16 @@ freq_values_from_seq (BseMusicalTuningType musical_tuning,
{
gfloat *v = g_new (gfloat, bse_note_sequence_length (sdata));
guint i;
-
for (i = 0; i < bse_note_sequence_length (sdata); i++)
{
gint note = sdata->notes->notes[i];
-
if (note == SFI_NOTE_VOID)
v[i] = 0;
else
v[i] = BSE_VALUE_FROM_FREQ (bse_note_to_freq (musical_tuning, CLAMP (note + transpose, SFI_MIN_NOTE, SFI_MAX_NOTE)));
}
-
return v;
}
-
typedef struct {
guint n_values;
gfloat *values; /* notes */
@@ -227,14 +202,12 @@ typedef struct {
guint counter;
gfloat *old_values;
} AccessData;
-
static void
seq_access (BseModule *module,
gpointer data)
{
SeqModule *smod = (SeqModule*) module->user_data;
AccessData *d = (AccessData*) data;
-
smod->n_values = d->n_values;
smod->values = d->new_values;
smod->counter = d->counter;
@@ -243,39 +216,31 @@ seq_access (BseModule *module,
if (smod->c < 1)
smod->c = smod->counter;
}
-
static void
seq_access_free (gpointer data)
{
AccessData *d = (AccessData*) data;
-
g_free (d->old_values);
g_free (d);
}
-
static void
bse_sequencer_update_modules (BseSequencer *seq)
{
if (BSE_SOURCE_PREPARED (seq))
{
AccessData *d = g_new (AccessData, 1);
-
d->old_values = seq->freq_values;
-
seq->n_freq_values = bse_note_sequence_length (seq->sdata);
seq->freq_values = freq_values_from_seq (bse_source_prepared_musical_tuning (BSE_SOURCE (seq)), seq->sdata, seq->transpose);
-
d->n_values = seq->n_freq_values;
d->new_values = seq->freq_values;
d->counter = seq->counter / 1000.0 * bse_engine_sample_freq ();
d->counter = MAX (d->counter, 1);
-
bse_source_access_modules (BSE_SOURCE (seq),
seq_access, d, seq_access_free,
NULL);
}
}
-
static void
sequencer_process (BseModule *module,
guint n_values)
@@ -284,11 +249,9 @@ sequencer_process (BseModule *module,
gfloat *freq_out = BSE_MODULE_OBUFFER (module, BSE_SEQUENCER_OCHANNEL_FREQ);
gfloat *nsync_out = BSE_MODULE_OBUFFER (module, BSE_SEQUENCER_OCHANNEL_NOTE_SYNC);
gfloat *bound = freq_out + n_values;
-
while (freq_out < bound)
{
gfloat nval = smod->values[smod->index];
-
if (smod->c == 0)
{
smod->c = smod->counter;
@@ -304,19 +267,15 @@ sequencer_process (BseModule *module,
smod->c--;
}
}
-
static void
bse_sequencer_prepare (BseSource *source)
{
BseSequencer *seq = BSE_SEQUENCER (source);
-
seq->n_freq_values = bse_note_sequence_length (seq->sdata);
seq->freq_values = freq_values_from_seq (bse_source_prepared_musical_tuning (source), seq->sdata, seq->transpose);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static void
bse_sequencer_context_create (BseSource *source,
guint context_handle,
@@ -335,35 +294,27 @@ bse_sequencer_context_create (BseSource *source,
BseSequencer *seq = BSE_SEQUENCER (source);
SeqModule *smod = g_new0 (SeqModule, 1);
BseModule *module;
-
smod->n_values = seq->n_freq_values;
smod->values = seq->freq_values;
smod->counter = seq->counter / 1000.0 * bse_engine_sample_freq ();
smod->counter = MAX (smod->counter, 1);
smod->index = 0;
smod->c = smod->counter;
-
module = bse_module_new (&sequencer_class, smod);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
static void
bse_sequencer_reset (BseSource *source)
{
BseSequencer *seq = BSE_SEQUENCER (source);
-
g_free (seq->freq_values);
seq->freq_values = NULL;
seq->n_freq_values = 0;
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
diff --git a/plugins/bsesequencer.hh b/plugins/bsesequencer.hh
index 2f337d3..2866a99 100644
--- a/plugins/bsesequencer.hh
+++ b/plugins/bsesequencer.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SEQUENCER_H__
#define __BSE_SEQUENCER_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- object type macros --- */
#define BSE_TYPE_SEQUENCER (bse_sequencer_get_type())
#define BSE_SEQUENCER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SEQUENCER, BseSequencer))
@@ -17,23 +13,18 @@ extern "C" {
#define BSE_IS_SEQUENCER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SEQUENCER))
#define BSE_IS_SEQUENCER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SEQUENCER))
#define BSE_SEQUENCER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SEQUENCER, BseSequencerClass))
-
-
/* --- BseSequencer source --- */
typedef struct _BseSequencer BseSequencer;
typedef struct _BseSourceClass BseSequencerClass;
struct _BseSequencer
{
BseSource parent_object;
-
gfloat counter;
gint transpose;
BseNoteSequence *sdata;
guint n_freq_values;
gfloat *freq_values;
};
-
-
/* --- channels --- */
enum
{
@@ -41,11 +32,7 @@ enum
BSE_SEQUENCER_OCHANNEL_NOTE_SYNC,
BSE_SEQUENCER_N_OCHANNELS
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __BSE_SEQUENCER_H__ */
diff --git a/plugins/bsesimpleadsr-aux.cc b/plugins/bsesimpleadsr-aux.cc
index 182a7a6..a670365 100644
--- a/plugins/bsesimpleadsr-aux.cc
+++ b/plugins/bsesimpleadsr-aux.cc
@@ -26,15 +26,12 @@ typedef struct
#define BSE_MIX_RAMP_WITH_DEC (16)
#define BSE_MIX_EPSILON (1e-8 /* threshold, coined for 24 bit */)
#endif /* __BSE_MIX_RAMP_AUX__ */
-
-
#define CHECK_GATE (BSE_MIX_VARIANT & (BSE_MIX_RAMP_WITH_GATE | BSE_MIX_RAMP_WITH_IGATE))
#define CHECK_TRIG (BSE_MIX_VARIANT & BSE_MIX_RAMP_WITH_TRIG)
#define STEP_UP (BSE_MIX_VARIANT & BSE_MIX_RAMP_WITH_INC)
#define STEP_DOWN (BSE_MIX_VARIANT & BSE_MIX_RAMP_WITH_DEC)
#define GATE_CHECK(v) ((BSE_MIX_VARIANT & BSE_MIX_RAMP_WITH_IGATE) ? (v) >= 0.5 : (v) < 0.5)
#define RAISING_EDGE(v1,v2) ((v1) < (v2))
-
static inline BseMixRampState
BSE_MIX_VARIANT_NAME (BseMixRampLinear *ramp)
{
@@ -48,7 +45,6 @@ BSE_MIX_VARIANT_NAME (BseMixRampLinear *ramp)
register gfloat value = ramp->level;
gfloat level_step = ramp->level_step;
gfloat eps = STEP_DOWN ? ramp->level_border + BSE_MIX_EPSILON : ramp->level_border - BSE_MIX_EPSILON;
-
if (wave_out >= bound)
return BSE_MIX_RAMP_REACHED_BOUND;
do
@@ -58,7 +54,6 @@ BSE_MIX_VARIANT_NAME (BseMixRampLinear *ramp)
if (CHECK_TRIG)
{
gfloat trig_val = *ramp->trig_in;
-
if (RAISING_EDGE (ramp->last_trigger, trig_val))
{
ramp->last_trigger = trig_val;
@@ -86,7 +81,6 @@ BSE_MIX_VARIANT_NAME (BseMixRampLinear *ramp)
RETURN (BSE_MIX_RAMP_REACHED_BOUND);
#undef RETURN
}
-
#undef CHECK_GATE
#undef CHECK_TRIG
#undef STEP_UP
diff --git a/plugins/bsesimpleadsr.cc b/plugins/bsesimpleadsr.cc
index 7005f34..4df0520 100644
--- a/plugins/bsesimpleadsr.cc
+++ b/plugins/bsesimpleadsr.cc
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsesimpleadsr.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
#define TIME_EPSILON (0.00001)
-
/* --- parameters --- */
enum
{
@@ -16,8 +13,6 @@ enum
PARAM_RELEASE_TIME,
PARAM_TIME_RANGE
};
-
-
/* --- prototypes --- */
static void bse_simple_adsr_init (BseSimpleADSR *senv);
static void bse_simple_adsr_class_init (BseSimpleADSRClass *klass);
@@ -39,11 +34,8 @@ static void bse_simple_adsr_update_modules (BseSimpleADSR *simple_adsr,
BSE_RESIDENT_SOURCE_DEF (BseSimpleADSR, bse_simple_adsr, N_("Other Sources/Simple ADSR"),
"Simple ADSR envelope generator",
adsr_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_simple_adsr_class_init (BseSimpleADSRClass *klass)
@@ -53,14 +45,10 @@ bse_simple_adsr_class_init (BseSimpleADSRClass *klass)
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel, ichannel;
gchar *desc;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_simple_adsr_set_property;
gobject_class->get_property = bse_simple_adsr_get_property;
-
source_class->context_create = bse_simple_adsr_context_create;
-
bse_object_class_add_param (object_class, "Envelope",
PARAM_ATTACK_TIME,
sfi_pspec_real ("attack_time", "Attack Time [%]", NULL,
@@ -92,7 +80,6 @@ bse_simple_adsr_class_init (BseSimpleADSRClass *klass)
BSE_TIME_RANGE_SHORT,
SFI_PARAM_STANDARD));
g_free (desc);
-
ichannel = bse_source_class_add_ichannel (source_class, "gate-in", _("Gate In"), _("Gate input (activates/deactivates envelope)"));
g_assert (ichannel == BSE_SIMPLE_ADSR_ICHANNEL_GATE);
ichannel = bse_source_class_add_ichannel (source_class, "retrigger-in", _("Retrigger In"), _("Retrigger input (raising edge retriggers envelope)"));
@@ -102,7 +89,6 @@ bse_simple_adsr_class_init (BseSimpleADSRClass *klass)
ochannel = bse_source_class_add_ochannel (source_class, "done-out", _("Done Out"), _("This signal goes high after the release phase has completed"));
g_assert (ochannel == BSE_SIMPLE_ADSR_OCHANNEL_DONE);
}
-
static void
bse_simple_adsr_init (BseSimpleADSR *adsr)
{
@@ -112,7 +98,6 @@ bse_simple_adsr_init (BseSimpleADSR *adsr)
adsr->release_time = 0.4;
adsr->time_range = BSE_TIME_RANGE_SHORT;
}
-
static void
bse_simple_adsr_set_property (GObject *object,
guint param_id,
@@ -147,7 +132,6 @@ bse_simple_adsr_set_property (GObject *object,
break;
}
}
-
static void
bse_simple_adsr_get_property (GObject *object,
guint param_id,
@@ -177,43 +161,33 @@ bse_simple_adsr_get_property (GObject *object,
break;
}
}
-
#define BSE_MIX_VARIANT_NAME ramp_mix_gate_inc
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_GATE | BSE_MIX_RAMP_WITH_INC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME ramp_mix_inc
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_INC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME ramp_mix_gate_trig_dec
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_GATE | BSE_MIX_RAMP_WITH_TRIG | BSE_MIX_RAMP_WITH_DEC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME const_mix_gate_trig
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_GATE | BSE_MIX_RAMP_WITH_TRIG)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME ramp_mix_gate_dec
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_GATE | BSE_MIX_RAMP_WITH_DEC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME ramp_mix_trig_dec
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_TRIG | BSE_MIX_RAMP_WITH_DEC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME ramp_mix_invgate_dec
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_IGATE | BSE_MIX_RAMP_WITH_DEC)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME const_mix_invgate
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_IGATE)
#include "bsesimpleadsr-aux.cc"
-
#define BSE_MIX_VARIANT_NAME const_mix_trig
#define BSE_MIX_VARIANT (BSE_MIX_RAMP_WITH_TRIG)
#include "bsesimpleadsr-aux.cc"
-
enum {
ATTACK,
DECAY,
@@ -221,14 +195,12 @@ enum {
RELEASE,
POST_RELEASE
};
-
typedef struct
{
BseMixRampLinear ramp;
BseSimpleADSRVars vars;
guint phase;
} SimpleADSR;
-
static void
simple_adsr_process (BseModule *module,
guint n_values)
@@ -241,11 +213,9 @@ simple_adsr_process (BseModule *module,
gfloat *wave_out = BSE_MODULE_OBUFFER (module, BSE_SIMPLE_ADSR_OCHANNEL_OUT);
gboolean have_gate = BSE_MODULE_ISTREAM (module, BSE_SIMPLE_ADSR_ICHANNEL_GATE).connected;
guint state = 0;
-
if (!BSE_MODULE_OSTREAM (module, BSE_SIMPLE_ADSR_OCHANNEL_OUT).connected &&
!BSE_MODULE_OSTREAM (module, BSE_SIMPLE_ADSR_OCHANNEL_DONE).connected)
return; /* no output */
-
if (env->phase == POST_RELEASE &&
!BSE_MODULE_ISTREAM (module, BSE_SIMPLE_ADSR_ICHANNEL_GATE).connected &&
!BSE_MODULE_ISTREAM (module, BSE_SIMPLE_ADSR_ICHANNEL_RETRIGGER).connected)
@@ -258,7 +228,6 @@ simple_adsr_process (BseModule *module,
BSE_MODULE_OSTREAM (module, BSE_SIMPLE_ADSR_OCHANNEL_DONE).values = bse_engine_const_values (0.0);
return;
}
-
ramp->wave_out = wave_out;
ramp->bound = wave_out + n_values;
do
@@ -342,13 +311,11 @@ simple_adsr_process (BseModule *module,
}
}
while (state != BSE_MIX_RAMP_REACHED_BOUND);
-
if (env->phase == POST_RELEASE)
BSE_MODULE_OSTREAM (module, BSE_SIMPLE_ADSR_OCHANNEL_DONE).values = bse_engine_const_values (1.0);
else
BSE_MODULE_OSTREAM (module, BSE_SIMPLE_ADSR_OCHANNEL_DONE).values = bse_engine_const_values (0.0);
}
-
static void
simple_adsr_reset (BseModule *module)
{
@@ -357,7 +324,6 @@ simple_adsr_reset (BseModule *module)
env->ramp.level = 0;
env->phase = ATTACK;
}
-
static void
bse_simple_adsr_update_modules (BseSimpleADSR *adsr,
BseTrans *trans)
@@ -388,7 +354,6 @@ bse_simple_adsr_update_modules (BseSimpleADSR *adsr,
trans);
}
}
-
static void
bse_simple_adsr_context_create (BseSource *source,
guint context_handle,
@@ -407,18 +372,13 @@ bse_simple_adsr_context_create (BseSource *source,
BseSimpleADSR *simple_adsr = BSE_SIMPLE_ADSR (source);
SimpleADSR *env = g_new0 (SimpleADSR, 1);
BseModule *module;
-
module = bse_module_new (&env_class, env);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
-
/* update module data */
bse_simple_adsr_update_modules (simple_adsr, trans);
}
diff --git a/plugins/bsesimpleadsr.hh b/plugins/bsesimpleadsr.hh
index 9a29adc..b4e707b 100644
--- a/plugins/bsesimpleadsr.hh
+++ b/plugins/bsesimpleadsr.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SIMPLE_ADSR_H__
#define __BSE_SIMPLE_ADSR_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define BSE_TYPE_SIMPLE_ADSR (bse_simple_adsr_get_type())
#define BSE_SIMPLE_ADSR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SIMPLE_ADSR, BseSimpleADSR))
@@ -14,8 +11,6 @@ G_BEGIN_DECLS
#define BSE_IS_SIMPLE_ADSR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SIMPLE_ADSR))
#define BSE_IS_SIMPLE_ADSR_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SIMPLE_ADSR))
#define BSE_SIMPLE_ADSR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SIMPLE_ADSR, BseSimpleADSRClass))
-
-
/* --- BseSimpleADSR source --- */
typedef struct _BseSimpleADSR BseSimpleADSR;
typedef struct _BseSimpleADSRClass BseSimpleADSRClass;
@@ -29,7 +24,6 @@ typedef struct {
struct _BseSimpleADSR
{
BseSource parent_object;
-
gfloat attack_time;
gfloat decay_time;
gfloat sustain_level;
@@ -40,8 +34,6 @@ struct _BseSimpleADSRClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -55,7 +47,5 @@ enum
BSE_SIMPLE_ADSR_OCHANNEL_DONE,
BSE_SIMPLE_ADSR_N_OCHANNELS
};
-
G_END_DECLS
-
#endif /* __BSE_SIMPLE_ADSR_H__ */
diff --git a/plugins/bsesummation.cc b/plugins/bsesummation.cc
index f2e5b27..f6b3063 100644
--- a/plugins/bsesummation.cc
+++ b/plugins/bsesummation.cc
@@ -2,9 +2,7 @@
#include "bsesummation.genidl.hh"
using namespace std;
using namespace Sfi;
-
namespace Bse {
-
class Summation : public SummationBase {
class Summer : public SynthesisModule {
public:
@@ -71,8 +69,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Summation, Summer, SummationProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Summation);
-
} // Bse
diff --git a/plugins/bsesummation.idl b/plugins/bsesummation.idl
index 3f99f5f..7d8dc6c 100644
--- a/plugins/bsesummation.idl
+++ b/plugins/bsesummation.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsecxxmodule.idl>
-
namespace Bse {
-
class Summation : Effect {
Info icon = "icons/summation.png";
Info authors = "Tim Janik";
@@ -19,5 +17,4 @@ class Summation : Effect {
OStream audio_diff = (_("Audio Diff"), _("Difference between audio outputs 1 and 2"));
OStream audio_out2 = (_("Audio Sum2"), _("Accumulated audio output 2"));
};
-
} // Bse
diff --git a/plugins/davbassfilter.cc b/plugins/davbassfilter.cc
index d8989bb..ec92f7a 100644
--- a/plugins/davbassfilter.cc
+++ b/plugins/davbassfilter.cc
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "davbassfilter.genidl.hh"
-
namespace Bse {
namespace Dav {
-
class BassFilter : public BassFilterBase {
class Module : public SynthesisModule {
/* proeprties */
@@ -67,12 +65,10 @@ class BassFilter : public BassFilterBase {
filt_reso = props->reso_perc * 0.01;
env_mod = props->env_mod * 0.01;
env_decay = props->env_decay * 0.01;
-
recalc_resonance();
recalc_filter();
recalc_decay();
recalc_a_b();
-
if (props->trigger)
{
/* Reset filter delta freq. */
@@ -159,9 +155,7 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (BassFilter, Module, BassFilterProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (BassFilter);
-
} // Dav
} // Bse
diff --git a/plugins/davbassfilter.idl b/plugins/davbassfilter.idl
index 523a524..7719f9f 100644
--- a/plugins/davbassfilter.idl
+++ b/plugins/davbassfilter.idl
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
namespace Dav {
-
class BassFilter : Effect {
Info icon = "icons/davbassfilter.png";
Info authors = "David A. Bartold, Tim Janik";
@@ -24,8 +22,6 @@ class BassFilter : Effect {
Bool trigger = Trigger (_("Trigger filter"), NULL, GUI);
};
};
-
} // Dav
} // Bse
-
/* vim:set ts=8 sw=2 sts=2 syntax=cpp: */
diff --git a/plugins/davcanyondelay.cc b/plugins/davcanyondelay.cc
index 00e2be2..803a764 100644
--- a/plugins/davcanyondelay.cc
+++ b/plugins/davcanyondelay.cc
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "davcanyondelay.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
#include <bse/bsemathsignal.hh>
#include <string.h>
-
-
/* --- parameters --- */
enum
{
@@ -18,8 +15,6 @@ enum
PROP_FILTER_FREQ,
PROP_FILTER_NOTE
};
-
-
/* --- prototypes --- */
static void dav_canyon_delay_init (DavCanyonDelay *self);
static void dav_canyon_delay_class_init (DavCanyonDelayClass *klass);
@@ -36,17 +31,13 @@ static void dav_canyon_delay_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
static void dav_canyon_delay_update_modules (DavCanyonDelay *self);
-
// == Type Registration ==
#include "./icons/canyon.c"
BSE_RESIDENT_SOURCE_DEF (DavCanyonDelay, dav_canyon_delay, N_("Enhance/CanyonDelay"),
"DavCanyonDelay adds deep and long canyon-alike echos to stereo signals.",
canyon_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
@@ -55,15 +46,11 @@ dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = dav_canyon_delay_set_property;
gobject_class->get_property = dav_canyon_delay_get_property;
-
source_class->prepare = dav_canyon_delay_prepare;
source_class->context_create = dav_canyon_delay_context_create;
-
bse_object_class_add_param (object_class, _("Left to Right"), PROP_LEFT_TO_RIGHT_TIME,
sfi_pspec_real ("left_to_right_time", _("Delay (seconds)"),
_("The time for the left to right delay"),
@@ -84,7 +71,6 @@ dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
_("Set the feedback amount; a negative feedback inverts the signal"),
-70.0, -100.0, 100.0, 0.01,
SFI_PARAM_STANDARD ":scale"));
-
bse_object_class_add_param (object_class, _("IIR Low-Pass Filter"), PROP_FILTER_FREQ,
bse_param_spec_freq ("filter_freq", _("Frequency"),
_("Reflection cutoff frequency"),
@@ -95,7 +81,6 @@ dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
bse_pspec_note_simple ("filter_note", _("Note"),
_("Filter cutoff frequency as note, converted to Hertz according to the current musical tuning"),
SFI_PARAM_GUI));
-
channel = bse_source_class_add_ichannel (source_class, "left-in", _("Left In"), _("Left Audio Input"));
g_assert (channel == DAV_CANYON_DELAY_ICHANNEL_LEFT);
channel = bse_source_class_add_ichannel (source_class, "right-in", _("Right In"), _("Right Audio Input"));
@@ -105,7 +90,6 @@ dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
channel = bse_source_class_add_ochannel (source_class, "right-out", _("Right Out"), _("Right Audio Output"));
g_assert (channel == DAV_CANYON_DELAY_OCHANNEL_RIGHT);
}
-
static void
dav_canyon_delay_init (DavCanyonDelay *self)
{
@@ -115,7 +99,6 @@ dav_canyon_delay_init (DavCanyonDelay *self)
self->r_to_l_feedback = -70.0;
self->filter_freq = bse_note_to_freq (bse_item_current_musical_tuning (BSE_ITEM (self)), SFI_NOTE_C (+3));
}
-
static void
dav_canyon_delay_set_property (GObject *object,
guint param_id,
@@ -151,7 +134,6 @@ dav_canyon_delay_set_property (GObject *object,
}
dav_canyon_delay_update_modules (self);
}
-
static void
dav_canyon_delay_get_property (GObject *object,
guint param_id,
@@ -184,19 +166,15 @@ dav_canyon_delay_get_property (GObject *object,
break;
}
}
-
static void
dav_canyon_delay_prepare (BseSource *source)
{
DavCanyonDelay *self = DAV_CANYON_DELAY (source);
-
/* initialize calculated params (mix-freq dependant) */
dav_canyon_delay_update_modules (self);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static void
canyon_delay_process (BseModule *module,
guint n_values)
@@ -207,49 +185,39 @@ canyon_delay_process (BseModule *module,
gfloat *left_out = BSE_MODULE_OBUFFER (module, DAV_CANYON_DELAY_OCHANNEL_LEFT);
gfloat *right_out = BSE_MODULE_OBUFFER (module, DAV_CANYON_DELAY_OCHANNEL_RIGHT);
guint i;
-
for (i = 0; i < n_values; i++)
{
gint32 pos1, pos2;
gdouble accum_l = left_in[i];
gdouble accum_r = right_in[i];
-
pos1 = cmod->pos - cmod->params.r_to_l_pos + cmod->datasize;
while (pos1 >= cmod->datasize)
pos1 -= cmod->datasize;
-
pos2 = cmod->pos - cmod->params.l_to_r_pos + cmod->datasize;
while (pos2 >= cmod->datasize)
pos2 -= cmod->datasize;
-
/* Mix channels with past samples. */
accum_l = accum_l * cmod->params.r_to_l_invmag + cmod->data_r[pos1] * cmod->params.r_to_l_mag;
accum_r = accum_r * cmod->params.l_to_r_invmag + cmod->data_l[pos2] * cmod->params.l_to_r_mag;
-
/* Low-pass filter output. */
accum_l = cmod->accum_l * cmod->params.filter_invmag + accum_l * cmod->params.filter_mag;
accum_l = BSE_SIGNAL_CLIP (accum_l);
accum_r = cmod->accum_r * cmod->params.filter_invmag + accum_r * cmod->params.filter_mag;
accum_r = BSE_SIGNAL_CLIP (accum_r);
-
/* Store IIR samples. */
cmod->accum_l = accum_l;
cmod->accum_r = accum_r;
-
/* Store samples in arrays. */
cmod->data_l[cmod->pos] = accum_l;
cmod->data_r[cmod->pos] = accum_r;
-
/* Write output. */
left_out[i] = accum_l;
right_out[i] = accum_r;
-
cmod->pos++;
if (cmod->pos >= cmod->datasize)
cmod->pos -= cmod->datasize;
}
}
-
static void
canyon_delay_reset (BseModule *module)
{
@@ -260,7 +228,6 @@ canyon_delay_reset (BseModule *module)
memset (cmod->data_l, 0, sizeof (cmod->data_l[0]) * cmod->datasize);
memset (cmod->data_r, 0, sizeof (cmod->data_r[0]) * cmod->datasize);
}
-
static void
canyon_delay_free (gpointer data,
const BseModuleClass *klass)
@@ -270,7 +237,6 @@ canyon_delay_free (gpointer data,
g_free (cmod->data_l);
g_free (cmod->data_r);
}
-
static void
dav_canyon_delay_context_create (BseSource *source,
guint context_handle,
@@ -289,24 +255,19 @@ dav_canyon_delay_context_create (BseSource *source,
DavCanyonDelay *self = DAV_CANYON_DELAY (source);
DavCanyonDelayModule *cmod = g_new0 (DavCanyonDelayModule, 1);
BseModule *module;
-
module = bse_module_new (&cmod_class, cmod);
cmod->datasize = bse_engine_sample_freq();
cmod->data_l = g_new0 (gdouble, cmod->datasize);
cmod->data_r = g_new0 (gdouble, cmod->datasize);
cmod->params = self->params;
canyon_delay_reset (module);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
/* update module configuration from new parameter set */
static void
canyon_delay_access (BseModule *module,
@@ -314,10 +275,8 @@ canyon_delay_access (BseModule *module,
{
DavCanyonDelayModule *cmod = (DavCanyonDelayModule*) module->user_data;
DavCanyonDelayParams *params = (DavCanyonDelayParams*) data;
-
cmod->params = *params;
}
-
static void
dav_canyon_delay_update_modules (DavCanyonDelay *self)
{
@@ -329,13 +288,11 @@ dav_canyon_delay_update_modules (DavCanyonDelay *self)
self->params.r_to_l_invmag = 1.0 - ABS (self->params.r_to_l_mag);
self->params.l_to_r_pos = self->l_to_r_seconds * bse_engine_sample_freq();
self->params.r_to_l_pos = self->r_to_l_seconds * bse_engine_sample_freq();
-
/* The following stuff (except the multiplicative inverse)
* is a guesstimate. The calculations seem to be right, tho.
* Compare to the FIR filter for a reference.
*/
gdouble half = 1.0 / (4.0 * PI * self->filter_freq);
-
/* Calculate the half life rate given:
* half - the length of the half life
* sample_freq - time divisor (usually the # calcs per second)
@@ -344,7 +301,6 @@ dav_canyon_delay_update_modules (DavCanyonDelay *self)
*/
self->params.filter_invmag = exp (-BSE_LN2 / (half * bse_engine_sample_freq()));
self->params.filter_mag = 1.0 - self->params.filter_invmag;
-
/* update all DavCanyonDelayModules. take a look at davxtalstrings.c
* to understand what this code does.
*/
diff --git a/plugins/davcanyondelay.hh b/plugins/davcanyondelay.hh
index 2678c32..e8d9967 100644
--- a/plugins/davcanyondelay.hh
+++ b/plugins/davcanyondelay.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __DAV_CANYON_DELAY_H__
#define __DAV_CANYON_DELAY_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
/* --- object type macros --- */
#define DAV_TYPE_CANYON_DELAY (dav_canyon_delay_get_type())
#define DAV_CANYON_DELAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DAV_TYPE_CANYON_DELAY, DavCanyonDelay))
@@ -14,7 +11,6 @@ G_BEGIN_DECLS
#define DAV_IS_CANYON_DELAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DAV_TYPE_CANYON_DELAY))
#define DAV_IS_CANYON_DELAY_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), DAV_TYPE_CANYON_DELAY))
#define DAV_CANYON_DELAY_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), DAV_TYPE_CANYON_DELAY, DavCanyonDelayClass))
-
/* --- DavCanyonDelay source --- */
typedef struct {
gdouble l_to_r_mag;
@@ -29,7 +25,6 @@ typedef struct {
typedef struct
{
BseSource parent_object;
-
gdouble l_to_r_seconds;
gdouble l_to_r_feedback;
gdouble r_to_l_seconds;
@@ -49,8 +44,6 @@ typedef struct {
typedef struct {
BseSourceClass parent_class;
} DavCanyonDelayClass;
-
-
/* --- channels --- */
enum
{
@@ -64,9 +57,5 @@ enum
DAV_CANYON_DELAY_OCHANNEL_RIGHT,
DAV_CANYON_DELAY_N_OCHANNELS
};
-
-
-
G_END_DECLS
-
#endif /* __DAV_CANYON_DELAY_H__ */
diff --git a/plugins/davchorus.cc b/plugins/davchorus.cc
index ff1f57a..1b496b5 100644
--- a/plugins/davchorus.cc
+++ b/plugins/davchorus.cc
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "davchorus.genidl.hh"
-
namespace Bse {
namespace Dav {
-
class Chorus : public ChorusBase {
/* synthesis module: */
class Module : public SynthesisModule {
@@ -48,32 +46,25 @@ class Chorus : public ChorusBase {
while (output < bound) // FIXME: this loop should be much more optimized
{
delay[delay_pos] = *input++;
-
int hi_pos = delay_pos;
int lo_pos = dtoi ((sin (sine_pos) + 1.0) * (delay_length - 1) * 256.0 * 0.5);
-
/* Normalize hi_pos and lo_pos counters. */
hi_pos += lo_pos >> 8;
lo_pos &= 0xff;
/* Find hi_pos modulus delay_length. */
while (hi_pos >= delay_length)
hi_pos -= delay_length;
-
/* Perform linear interpolation between hi_pos and hi_pos + 1. */
double wet = delay[hi_pos] * (256 - lo_pos);
-
hi_pos++;
if (hi_pos >= delay_length)
hi_pos -= delay_length;
wet += delay[hi_pos] * lo_pos;
wet = (wet / 256.0 + delay[delay_pos]) / 2;
-
*output++ = wet * wet_out + delay[delay_pos] * dry_out;
-
delay_pos++;
if (delay_pos >= delay_length)
delay_pos = 0;
-
sine_pos += sine_delta;
while (sine_pos >= 2.0 * M_PI)
sine_pos -= 2.0 * M_PI;
@@ -83,9 +74,7 @@ class Chorus : public ChorusBase {
public:
BSE_EFFECT_INTEGRATE_MODULE (Chorus, Module, ChorusProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Chorus);
-
} // Dav
} // Bse
diff --git a/plugins/davchorus.idl b/plugins/davchorus.idl
index cee95e3..a617bb0 100644
--- a/plugins/davchorus.idl
+++ b/plugins/davchorus.idl
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
namespace Dav {
-
class Chorus : Effect {
Info icon = "icons/chorus.png";
Info authors = "David A. Bartold";
@@ -16,6 +14,5 @@ class Chorus : Effect {
Real wet_out = Perc (_("Wet out [%]"), _("Set the amount of modified data to mix"), 50.0, STANDARD);
};
};
-
} // Dav
} // Bse
diff --git a/plugins/davguitar.c b/plugins/davguitar.c
index 2ea733a..a6fb8fb 100644
--- a/plugins/davguitar.c
+++ b/plugins/davguitar.c
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* This software uses technology under patent US 4,649,783, which has
* expired in May of 2004.
*/
-
#include <stdlib.h>
#include "davguitar.hh"
-
/* --- parameters --- */
enum
{
@@ -35,8 +32,6 @@ enum
PARAM_METALLIC_FACTOR,
PARAM_SNAP_FACTOR
};
-
-
/* --- prototypes --- */
static void dav_guitar_init (DavGuitar *guitar);
static void dav_guitar_class_init (DavGuitarClass *guitar);
@@ -56,55 +51,44 @@ static BseChunk* dav_guitar_calc_chunk (BseSource *source,
guint ochannel_id);
static void dav_guitar_reset (BseSource *source);
static inline void dav_guitar_update_locals (DavGuitar *guitar);
-
-
/* --- variables --- */
static GType type_id_guitar = 0;
static gpointer parent_class = NULL;
static const GTypeInfo type_info_guitar = {
sizeof (DavGuitarClass),
-
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) dav_guitar_class_init,
(GClassFinalizeFunc) dav_guitar_class_finalize,
NULL /* class_data */,
-
sizeof (DavGuitar),
0 /* n_preallocs */,
(GInstanceInitFunc) dav_guitar_init,
};
-
-
/* --- functions --- */
static void
wave_guide_unstop (WaveGuide *wave)
{
wave->lowpass_coeff = pow (0.5, 1.0 / (wave->freq * 0.02));
}
-
static void
wave_guide_stop (WaveGuide *wave)
{
wave->lowpass_coeff = pow (0.5, 1.0 / (wave->freq * 0.002));
}
-
static void
wave_guide_set_freq (WaveGuide *wave,
double frq)
{
guint i;
-
wave->freq = frq;
wave->pos = 0;
wave->wavelen = (int) (bse_engine_sample_freq() / frq);
wave->lowpass_data = 0.0;
wave_guide_unstop (wave);
-
for (i = 0; i < wave->wavelen; i++)
wave->data[i] = 0.0;
}
-
static void
wave_guide_pluck (WaveGuide *wave,
gfloat metallic_factor,
@@ -113,77 +97,61 @@ wave_guide_pluck (WaveGuide *wave,
{
guint i;
guint pivot;
-
wave->lowpass_data = 0.0;
wave_guide_unstop (wave);
-
/* Initialize wave guide (i.e. string) by setting it to random data. */
-
/* Create envelope. */
pivot = wave->wavelen / 5;
-
for (i = 0; i <= pivot; i++)
wave->data[i] = ((float) i) / pivot;
-
for (; i < wave->wavelen; i++)
wave->data[i] = ((float) (wave->wavelen - i - 1)) / (wave->wavelen - pivot - 1);
-
/* Add some snap. */
for (i = 0; i < wave->wavelen; i++)
wave->data[i] = pow (wave->data[i], snap_factor * 10.0F + 1.0F);
-
/* Add static to displacements. */
for (i = 0; i < wave->wavelen; i++)
wave->data[i] = wave->data[i] * (1.0F - metallic_factor) +
((rand() & 1) ? -1.0F : 1.0F) * metallic_factor;
-
/* Set velocity. */
for (i = 0; i < wave->wavelen; i++)
wave->data[i] *= trigger_vel;
}
-
static void
wave_guide_init (WaveGuide *wave, float frq)
{
wave->data = g_new0 (gfloat, (bse_engine_sample_freq() + 49) / 50);
wave_guide_set_freq (wave, frq);
}
-
static void
wave_guide_free (WaveGuide *wave)
{
g_free (wave->data);
wave->data = NULL;
}
-
static void
wave_guide_prepare (WaveGuide *wave)
{
wave_guide_free (wave);
wave_guide_init (wave, wave->freq);
}
-
static inline gint
fast_mod (gint x, gint y)
{
return (x >= y) ? x - y : x;
}
-
static inline void
wave_guide_advance (WaveGuide *wave)
{
wave->lowpass_data = wave->lowpass_data * (1.0F - wave->lowpass_coeff) + wave->data[wave->pos] * wave->lowpass_coeff;
wave->data[wave->pos] = wave->lowpass_data;
-
wave->pos = ((wave->pos + 1) == wave->wavelen) ? 0 : wave->pos + 1;
}
-
static inline int
wave_guide_get_pos (WaveGuide *wave, int x)
{
return fast_mod (wave->pos + x, wave->wavelen);
}
-
static void
add_string_param (BseObjectClass *object_class,
gchar *name,
@@ -201,23 +169,19 @@ add_string_param (BseObjectClass *object_class,
50.0, 2000.0,
freq_value, 0.1,
BSE_PARAM_DEFAULT | BSE_PARAM_HINT_DIAL));
-
bse_object_class_add_param (object_class, name, note_enum,
bse_param_spec_note (note_param, "Note", NULL,
BSE_NOTE_G (-2), BSE_NOTE_B (3),
note_value, 1, FALSE,
BSE_PARAM_GUI));
-
bse_object_class_add_param (object_class, name, trigger_enum,
sfi_pspec_bool (trigger_param, "Trigger Hit", "Pluck the string",
FALSE, BSE_PARAM_GUI));
}
-
static inline void
dav_guitar_update_locals (DavGuitar *guitar)
{
}
-
static void
dav_guitar_class_init (DavGuitarClass *class)
{
@@ -225,18 +189,13 @@ dav_guitar_class_init (DavGuitarClass *class)
BseObjectClass *object_class = BSE_OBJECT_CLASS (class);
BseSourceClass *source_class = BSE_SOURCE_CLASS (class);
guint ochannel_id;
-
parent_class = g_type_class_peek (BSE_TYPE_SOURCE);
-
gobject_class->set_property = dav_guitar_set_property;
gobject_class->get_property = dav_guitar_get_property;
-
object_class->destroy = dav_guitar_do_destroy;
-
source_class->prepare = dav_guitar_prepare;
source_class->calc_chunk = dav_guitar_calc_chunk;
source_class->reset = dav_guitar_reset;
-
add_string_param (object_class, "String 1",
"freq_1", PARAM_FREQ_1, 97.998859, "note_1", PARAM_NOTE_1, BSE_NOTE_G (-1), "trigger_1", PARAM_TRIGGER_1);
add_string_param (object_class, "String 2",
@@ -249,42 +208,34 @@ dav_guitar_class_init (DavGuitarClass *class)
"freq_5", PARAM_FREQ_5, 246.941651, "note_5", PARAM_NOTE_5, BSE_NOTE_B (0), "trigger_5", PARAM_TRIGGER_5);
add_string_param (object_class, "String 6",
"freq_6", PARAM_FREQ_6, 391.995436, "note_6", PARAM_NOTE_6, BSE_NOTE_G (1), "trigger_6", PARAM_TRIGGER_6);
-
bse_object_class_add_param (object_class, "Global Control", PARAM_TRIGGER_VEL,
bse_param_spec_float ("trigger_vel", "Trigger Velocity [%]",
"Set the velocity of the string pluck",
0.0, 100.0, 100.0, 10.0,
BSE_PARAM_GUI | BSE_PARAM_HINT_SCALE));
-
bse_object_class_add_param (object_class, "Global Control", PARAM_TRIGGER_ALL,
sfi_pspec_bool ("trigger_all", "Trigger Hit All", "Strum guitar",
FALSE, BSE_PARAM_GUI));
-
bse_object_class_add_param (object_class, "Global Control", PARAM_STOP_ALL,
sfi_pspec_bool ("stop_all", "Stop All", "Stop all the strings from vibrating",
FALSE, BSE_PARAM_GUI));
-
bse_object_class_add_param (object_class, "Flavour", PARAM_METALLIC_FACTOR,
bse_param_spec_float ("metallic_factor", "Metallic Factor [%]",
"Set the metallicness of the string",
0.0, 100.0, 16.0, 0.25,
BSE_PARAM_DEFAULT | BSE_PARAM_HINT_SCALE));
-
bse_object_class_add_param (object_class, "Flavour", PARAM_SNAP_FACTOR,
bse_param_spec_float ("snap_factor", "Snap Factor [%]",
"Set the snappiness of the string",
0.0, 100.0, 34.0, 0.25,
BSE_PARAM_DEFAULT | BSE_PARAM_HINT_SCALE));
-
ochannel_id = bse_source_class_add_ochannel (source_class, "mono-out", _("Guitar Output"));
g_assert (ochannel_id == DAV_GUITAR_OCHANNEL_MONO);
}
-
static void
dav_guitar_class_finalize (DavGuitarClass *class)
{
}
-
static void
dav_guitar_init (DavGuitar *guitar)
{
@@ -293,7 +244,6 @@ dav_guitar_init (DavGuitar *guitar)
guitar->trigger_vel = 1.0;
guitar->metallic_factor = 0.16;
guitar->snap_factor = 0.34;
-
wave_guide_init (&guitar->strings[0], 097.998859); /* G */
wave_guide_init (&guitar->strings[1], 123.470825); /* B */
wave_guide_init (&guitar->strings[2], 146.832384); /* D */
@@ -301,58 +251,43 @@ dav_guitar_init (DavGuitar *guitar)
wave_guide_init (&guitar->strings[4], 246.941651); /* B */
wave_guide_init (&guitar->strings[5], 391.995436); /* G */
wave_guide_init (&guitar->body, 50.0);
-
dav_guitar_update_locals (guitar);
}
-
static void
dav_guitar_do_destroy (BseObject *object)
{
DavGuitar *guitar;
int i;
-
guitar = DAV_GUITAR (object);
-
for (i = 0; i < 6; i++)
wave_guide_free (&guitar->strings[i]);
-
wave_guide_free (&guitar->body);
-
/* chain parent class' destroy handler */
BSE_OBJECT_CLASS (parent_class)->destroy (object);
}
-
static void
dav_guitar_trigger_string (DavGuitar *guitar, int str)
{
g_return_if_fail (DAV_IS_GUITAR (guitar));
-
wave_guide_pluck (&guitar->strings[str], guitar->metallic_factor, guitar->snap_factor, guitar->trigger_vel);
wave_guide_unstop (&guitar->body);
}
-
static void
dav_guitar_trigger (DavGuitar *guitar)
{
guint i;
-
for (i = 0; i < 6; i++)
wave_guide_pluck (&guitar->strings[i], guitar->metallic_factor, guitar->snap_factor, guitar->trigger_vel);
-
wave_guide_unstop (&guitar->body);
}
-
static void
dav_guitar_stop (DavGuitar *guitar)
{
guint i;
-
for (i = 0; i < 6; i++)
wave_guide_stop (&guitar->strings[i]);
-
wave_guide_stop (&guitar->body);
}
-
static void
dav_guitar_set_property (DavGuitar *guitar,
guint param_id,
@@ -442,13 +377,11 @@ dav_guitar_set_property (DavGuitar *guitar,
case PARAM_SNAP_FACTOR:
guitar->snap_factor = g_value_get_float (value) / 100.0;
break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (guitar, param_id, pspec);
break;
}
}
-
static void
dav_guitar_get_property (DavGuitar *guitar,
guint param_id,
@@ -526,59 +459,46 @@ dav_guitar_get_property (DavGuitar *guitar,
case PARAM_SNAP_FACTOR:
g_value_set_float (value, guitar->snap_factor * 100.0);
break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (guitar, param_id, pspec);
break;
}
}
-
static void
dav_guitar_prepare (BseSource *source,
BseIndex index)
{
DavGuitar *guitar = DAV_GUITAR (source);
int i;
-
guitar->hipass_coeff = pow (0.5, 20.0 / bse_engine_sample_freq());
guitar->hipass_data = 0.0;
-
wave_guide_prepare (&guitar->body);
-
for (i = 0; i < 6; i++)
{
wave_guide_prepare (&guitar->strings[i]);
guitar->body_taps[i] = ((i + 1) * (guitar->body.wavelen - 1)) / 7;
}
-
dav_guitar_update_locals (guitar);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source, index);
}
-
static inline void
resonate (DavGuitar *guitar, float factor, int n)
{
int body_pos;
float vel;
WaveGuide *body, *string;
-
body = &guitar->body;
string = &guitar->strings[n];
-
/* Find position on body. */
body_pos = wave_guide_get_pos (body, guitar->body_taps[n]);
-
/* Linearly approximate the force of an imaginary
spring connected between those two points. */
vel = (string->data[string->pos] - body->data[body_pos]) * factor;
-
/* Modify positions. */
string->data[string->pos] -= vel;
body->data[body_pos] += vel;
}
-
static BseChunk*
dav_guitar_calc_chunk (BseSource *source,
guint ochannel_id)
@@ -587,40 +507,31 @@ dav_guitar_calc_chunk (BseSource *source,
BseSampleValue *hunk;
gfloat sample;
guint i, j;
-
g_return_val_if_fail (ochannel_id == DAV_GUITAR_OCHANNEL_MONO, NULL);
-
hunk = bse_hunk_alloc (1);
-
for (i = 0; i < BSE_TRACK_LENGTH; i++)
{
/* Get sample from body and hipass it to remove DC offset. */
sample = guitar->body.data[guitar->body.pos] * 25.0F;
guitar->hipass_data = guitar->hipass_data * guitar->hipass_coeff + sample * (1.0F - guitar->hipass_coeff);
-
/* Store sample. */
hunk[i] = BSE_CLIP_SAMPLE_VALUE ((sample - guitar->hipass_data) * BSE_MAX_SAMPLE_VALUE_f);
-
/* Resonate strings + body and advance waves one position. */
for (j = 0; j < 6; j++)
{
resonate (guitar, 0.01, j);
wave_guide_advance (&guitar->strings[j]);
}
-
wave_guide_advance (&guitar->body);
}
-
return bse_chunk_new_orphan (1, hunk);
}
-
static void
dav_guitar_reset (BseSource *source)
{
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->reset (source);
}
-
/* --- Export to DAV --- */
BSE_EXPORTS_BEGIN ();
BSE_EXPORT_OBJECTS = {
diff --git a/plugins/davguitar.hh b/plugins/davguitar.hh
index c8de4c6..d6ff7b4 100644
--- a/plugins/davguitar.hh
+++ b/plugins/davguitar.hh
@@ -1,14 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __DAV_GUITAR_H__
#define __DAV_GUITAR_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
/* --- object type macros --- */
#define DAV_TYPE_GUITAR (type_id_guitar)
#define DAV_GUITAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DAV_TYPE_GUITAR, DavGuitar))
@@ -16,13 +13,10 @@ extern "C" {
#define DAV_IS_GUITAR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DAV_TYPE_GUITAR))
#define DAV_IS_GUITAR_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), DAV_TYPE_GUITAR))
#define DAV_GUITAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), DAV_TYPE_GUITAR, DavGuitarClass))
-
/* --- DavGuitar source --- */
typedef struct _DavGuitar DavGuitar;
typedef struct _DavGuitarClass DavGuitarClass;
-
typedef struct _WaveGuide WaveGuide;
-
struct _WaveGuide
{
gfloat freq;
@@ -31,13 +25,10 @@ struct _WaveGuide
gint pos;
gfloat *data;
};
-
struct _DavGuitar
{
BseSource parent_object;
-
gfloat hipass_data, hipass_coeff;
-
gint body_taps[6];
WaveGuide strings[6];
WaveGuide body;
@@ -45,24 +36,17 @@ struct _DavGuitar
gfloat metallic_factor;
gfloat snap_factor;
};
-
struct _DavGuitarClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
DAV_GUITAR_OCHANNEL_NONE,
DAV_GUITAR_OCHANNEL_MONO
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __DAV_GUITAR_H__ */
diff --git a/plugins/davorgan.cc b/plugins/davorgan.cc
index e4f3f80..6f5f14d 100644
--- a/plugins/davorgan.cc
+++ b/plugins/davorgan.cc
@@ -3,13 +3,10 @@
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
#include <vector>
-
namespace Bse {
namespace Dav {
-
using namespace Birnet; // FIXME: move to Bse namespace
using Birnet::uint32; // FIXME: move to Bse header
-
class Organ : public OrganBase {
/* per mix_freq() tables */
class Tables
@@ -156,20 +153,17 @@ class Organ : public OrganBase {
*paccu += freq_256;
while (*paccu >= mix_freq_256)
*paccu -= mix_freq_256;
-
return table[*paccu >> 8];
}
inline uint
dfreq_to_freq_256 (double dfreq)
{
dfreq *= m_transpose_factor * m_fine_tune_factor;
-
/* Make sure that the actual sound generation code will only see
* frequencies in the range [0, mix_freq/2]. We map negative frequencies
* (like -440 Hz) to their positive equivalents (+440 Hz).
*/
dfreq = min (fabs (dfreq), mix_freq() * 0.5);
-
/* round frequency with dtoi during conversion from floating point to our
* fixed point representation, in order to minimize the conversion error
*/
@@ -184,27 +178,22 @@ class Organ : public OrganBase {
const float *ifreq = istream (ICHANNEL_FREQ_IN).values;
float *ovalues = ostream (OCHANNEL_AUDIO_OUT).values;
uint freq_256;
-
if (istream (ICHANNEL_FREQ_IN).connected)
freq_256 = dfreq_to_freq_256 (BSE_FREQ_FROM_VALUE (ifreq[0]));
else
freq_256 = dfreq_to_freq_256 (m_base_freq);
-
uint mix_freq_256 = mix_freq() * 256;
uint freq_256_harm0 = freq_256 / 2;
uint freq_256_harm1 = freq_256;
-
if (m_brass)
{
uint freq_256_harm2 = freq_256 * 2;
uint freq_256_harm3 = freq_256_harm2 * 2;
uint freq_256_harm4 = freq_256_harm3 * 2;
uint freq_256_harm5 = freq_256_harm4 * 2;
-
for (uint i = 0; i < n_values; i++)
{
float vaccu;
-
vaccu = table_pos (sine_table, freq_256_harm0, mix_freq_256, &m_harm0_paccu) * m_harm0;
vaccu += table_pos (sine_table, freq_256_harm1, mix_freq_256, &m_harm1_paccu) * m_harm1;
vaccu += table_pos (reed_table, freq_256_harm2, mix_freq_256, &m_harm2_paccu) * m_harm2;
@@ -220,11 +209,9 @@ class Organ : public OrganBase {
uint freq_256_harm3 = freq_256 * 2;
uint freq_256_harm4 = freq_256 * 3;
uint freq_256_harm5 = freq_256_harm3 * 2;
-
for (uint i = 0; i < n_values; i++)
{
float vaccu;
-
vaccu = table_pos (sine_table, freq_256_harm0, mix_freq_256, &m_harm0_paccu) * m_harm0;
vaccu += table_pos (sine_table, freq_256_harm1, mix_freq_256, &m_harm1_paccu) * m_harm1;
vaccu += table_pos (sine_table, freq_256_harm2, mix_freq_256, &m_harm2_paccu) * m_harm2;
@@ -258,12 +245,9 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Organ, Module, Properties);
};
-
map<uint, Organ::Tables*> Organ::Tables::table_map;
Mutex Organ::Tables::table_mutex;
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Organ);
-
} // Dav
} // Bse
diff --git a/plugins/davorgan.idl b/plugins/davorgan.idl
index afcd5d4..a8ddc19 100644
--- a/plugins/davorgan.idl
+++ b/plugins/davorgan.idl
@@ -1,9 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
namespace Dav {
-
class Organ : Effect {
Info icon = "icons/organ.png";
Info authors = "David A. Bartold";
@@ -36,6 +34,5 @@ class Organ : Effect {
Bool flute = Bool (_("Flute Sounds"), _("Add flute sounds"), false, STANDARD);
};
};
-
} // Dav
} // Bse
diff --git a/plugins/davsyndrum.cc b/plugins/davsyndrum.cc
index 2104ab4..d79ef34 100644
--- a/plugins/davsyndrum.cc
+++ b/plugins/davsyndrum.cc
@@ -3,7 +3,6 @@
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsecxxplugin.hh>
-
/* --- parameters --- */
enum
{
@@ -15,8 +14,6 @@ enum
PROP_RES,
PROP_RATIO
};
-
-
/* --- prototypes --- */
static void dav_syn_drum_init (DavSynDrum *drum);
static void dav_syn_drum_class_init (DavSynDrumClass *klass);
@@ -34,7 +31,6 @@ static void dav_syn_drum_context_create (BseSource *source,
BseTrans *trans);
static void dav_syn_drum_update_modules (DavSynDrum *self,
gboolean force_trigger);
-
// == Type Registration ==
#include "./icons/drum.c"
BSE_RESIDENT_SOURCE_DEF (DavSynDrum, dav_syn_drum, N_("Audio Sources/Synthetic Drum"),
@@ -44,11 +40,8 @@ BSE_RESIDENT_SOURCE_DEF (DavSynDrum, dav_syn_drum, N_("Audio Sources/Synthetic D
"The initial frequency shift is controllable through the "
"\"Ratio In\" input channel, and adjustable through a parameter.",
drum_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
dav_syn_drum_class_init (DavSynDrumClass *klass)
@@ -57,15 +50,11 @@ dav_syn_drum_class_init (DavSynDrumClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint ochannel_id, ichannel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = dav_syn_drum_set_property;
gobject_class->get_property = dav_syn_drum_get_property;
-
source_class->prepare = dav_syn_drum_prepare;
source_class->context_create = dav_syn_drum_context_create;
-
bse_object_class_add_param (object_class, _("Frequency"), PROP_BASE_FREQ,
bse_param_spec_freq ("base_freq", _("Frequency"),
_("Drum frequency in Hertz"),
@@ -76,7 +65,6 @@ dav_syn_drum_class_init (DavSynDrumClass *klass)
bse_pspec_note_simple ("base_note", _("Note"),
_("Drum frequency as note, converted to Hertz according to the current musical tuning"),
SFI_PARAM_GUI));
-
bse_object_class_add_param (object_class, "Trigger", PROP_TRIGGER_VEL,
sfi_pspec_real ("trigger_vel", _("Trigger Velocity [%]"),
_("The velocity of the drum hit"),
@@ -95,7 +83,6 @@ dav_syn_drum_class_init (DavSynDrumClass *klass)
_("The ratio of frequency shift. (i.e. 1.0 means shift equal to the drum's base frequency)"),
1.0, 0.0, 10.0, 0.1,
SFI_PARAM_STANDARD ":scale"));
-
ichannel_id = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Drum Frequency Input"));
g_assert (ichannel_id == DAV_SYN_DRUM_ICHANNEL_FREQ);
ichannel_id = bse_source_class_add_ichannel (source_class, "ratio-in", _("Ratio In"), _("Frequency shift ratio (assumed 1.0 if not connected)"));
@@ -105,7 +92,6 @@ dav_syn_drum_class_init (DavSynDrumClass *klass)
ochannel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("SynDrum Output"));
g_assert (ochannel_id == DAV_SYN_DRUM_OCHANNEL_MONO);
}
-
static void
dav_syn_drum_init (DavSynDrum *self)
{
@@ -115,7 +101,6 @@ dav_syn_drum_init (DavSynDrum *self)
self->params.res = 0;
self->half = 50 * 0.001;
}
-
static void
dav_syn_drum_set_property (GObject *object,
guint param_id,
@@ -152,7 +137,6 @@ dav_syn_drum_set_property (GObject *object,
}
dav_syn_drum_update_modules (self, force_trigger);
}
-
static void
dav_syn_drum_get_property (GObject *object,
guint param_id,
@@ -185,19 +169,15 @@ dav_syn_drum_get_property (GObject *object,
break;
}
}
-
static void
dav_syn_drum_prepare (BseSource *source)
{
DavSynDrum *self = DAV_SYN_DRUM (source);
-
/* initialize calculated params (mix-freq dependant) */
dav_syn_drum_update_modules (self, FALSE);
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static inline void
dmod_trigger (DavSynDrumModule *dmod,
gfloat freq,
@@ -208,7 +188,6 @@ dmod_trigger (DavSynDrumModule *dmod,
dmod->freq_rad = freq * 2.0 * PI / bse_engine_sample_freq();
dmod->freq_shift = dmod->freq_rad * dmod->params.ratio * CLAMP (ratio, 0, 1.0);
}
-
static void
dmod_process (BseModule *module,
guint n_values)
@@ -226,16 +205,13 @@ dmod_process (BseModule *module,
gfloat spring_pos = dmod->spring_pos;
gfloat env = dmod->env;
guint i;
-
if (!BSE_MODULE_ISTREAM (module, DAV_SYN_DRUM_ICHANNEL_FREQ).connected)
freq_in = NULL;
if (!BSE_MODULE_ISTREAM (module, DAV_SYN_DRUM_ICHANNEL_RATIO).connected)
ratio_in = NULL;
-
for (i = 0; i < n_values; i++)
{
gfloat cur_freq;
-
/* check input triggers */
if (G_UNLIKELY (BSE_SIGNAL_RAISING_EDGE (last_trigger_level, trigger_in[i])))
{
@@ -249,22 +225,18 @@ dmod_process (BseModule *module,
freq_shift = dmod->freq_shift;
}
last_trigger_level = trigger_in[i];
-
cur_freq = freq_rad + (env * freq_shift);
spring_vel -= spring_pos * cur_freq;
spring_pos += spring_vel * cur_freq;
spring_vel *= res;
env *= res;
-
wave_out[i] = spring_pos;
}
-
dmod->env = env;
dmod->spring_pos = spring_pos;
dmod->spring_vel = spring_vel;
dmod->last_trigger_level = last_trigger_level;
}
-
static void
dmod_reset (BseModule *module)
{
@@ -277,7 +249,6 @@ dmod_reset (BseModule *module)
dmod->freq_rad = 0;
dmod->freq_shift = 0;
}
-
static void
dav_syn_drum_context_create (BseSource *source,
guint context_handle,
@@ -296,21 +267,16 @@ dav_syn_drum_context_create (BseSource *source,
DavSynDrum *self = DAV_SYN_DRUM (source);
DavSynDrumModule *dmod = g_new0 (DavSynDrumModule, 1);
BseModule *module;
-
dmod->params = self->params;
module = bse_module_new (&dmod_class, dmod);
dmod_reset (module);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
/* update module configuration from new parameter set */
static void
dmod_access (BseModule *module,
@@ -318,10 +284,8 @@ dmod_access (BseModule *module,
{
DavSynDrumModule *dmod = (DavSynDrumModule*) module->user_data;
DavSynDrumParams *params = (DavSynDrumParams*) data;
-
dmod->params = *params;
}
-
/* update module configuration from new parameter set and force trigger */
static void
dmod_access_trigger (BseModule *module,
@@ -329,11 +293,9 @@ dmod_access_trigger (BseModule *module,
{
DavSynDrumModule *dmod = (DavSynDrumModule*) module->user_data;
DavSynDrumParams *params = (DavSynDrumParams*) data;
-
dmod->params = *params;
dmod_trigger (dmod, dmod->params.freq, 1.0);
}
-
static void
dav_syn_drum_update_modules (DavSynDrum *self,
gboolean force_trigger)
@@ -349,7 +311,6 @@ dav_syn_drum_update_modules (DavSynDrum *self,
* ln(1/2) = -ln(2) = -BSE_LN2 = -0.693147...
*/
self->params.res = exp (-BSE_LN2 / (self->half * bse_engine_sample_freq()));
-
/* update all DavSynDrumModules. take a look at davxtalstrings.c
* if you don't understand what this code does.
*/
diff --git a/plugins/davsyndrum.hh b/plugins/davsyndrum.hh
index 32d3170..16b84a5 100644
--- a/plugins/davsyndrum.hh
+++ b/plugins/davsyndrum.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __DAV_SYNDRUM_H__
#define __DAV_SYNDRUM_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
G_BEGIN_DECLS
-
-
/* --- object type macros --- */
#define DAV_TYPE_SYN_DRUM (dav_syn_drum_get_type())
#define DAV_SYN_DRUM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DAV_TYPE_SYN_DRUM, DavSynDrum))
@@ -15,7 +11,6 @@ G_BEGIN_DECLS
#define DAV_IS_SYN_DRUM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DAV_TYPE_SYN_DRUM))
#define DAV_IS_SYN_DRUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), DAV_TYPE_SYN_DRUM))
#define DAV_SYN_DRUM_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), DAV_TYPE_SYN_DRUM, DavSynDrumClass))
-
/* --- DavSynDrum source --- */
typedef struct {
gfloat freq;
@@ -41,7 +36,6 @@ typedef struct {
gfloat freq_rad;
gfloat freq_shift;
} DavSynDrumModule;
-
/* --- channels --- */
enum
{
@@ -55,7 +49,5 @@ enum
DAV_SYN_DRUM_OCHANNEL_MONO,
DAV_SYN_DRUM_N_OCHANNELS
};
-
G_END_DECLS
-
#endif /* __DAV_SYNDRUM_H__ */
diff --git a/plugins/davxtalstrings.cc b/plugins/davxtalstrings.cc
index 64a959e..ed627bc 100644
--- a/plugins/davxtalstrings.cc
+++ b/plugins/davxtalstrings.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
/* Generate a string pluck sound using a modified Karplus-Strong algorithm
* and then use Brensenham's algorithm to correct the frequency.
*
@@ -11,9 +10,7 @@
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
-
#include <string.h>
-
/* --- parameters --- */
enum
{
@@ -29,8 +26,6 @@ enum
PARAM_METALLIC_FACTOR,
PARAM_SNAP_FACTOR
};
-
-
/* --- prototypes --- */
static void dav_xtal_strings_init (DavXtalStrings *self);
static void dav_xtal_strings_class_init (DavXtalStringsClass *klass);
@@ -48,7 +43,6 @@ static void dav_xtal_strings_context_create (BseSource *source,
BseTrans *trans);
static void dav_xtal_strings_update_modules (DavXtalStrings *self,
gboolean trigger_now);
-
// == Type Registration ==
#include "./icons/strings.c"
BSE_RESIDENT_SOURCE_DEF (DavXtalStrings, dav_xtal_strings, N_("Audio Sources/XtalStrings"),
@@ -56,11 +50,8 @@ BSE_RESIDENT_SOURCE_DEF (DavXtalStrings, dav_xtal_strings, N_("Audio Sources/Xta
"Karplus-Strong Algorithm. Commercial use of this module "
"until 2004 requires a license from Stanford University.",
strings_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
dav_xtal_strings_class_init (DavXtalStringsClass *klass)
@@ -69,15 +60,11 @@ dav_xtal_strings_class_init (DavXtalStringsClass *klass)
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
BseSourceClass *source_class = BSE_SOURCE_CLASS (klass);
guint channel_id;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = dav_xtal_strings_set_property;
gobject_class->get_property = dav_xtal_strings_get_property;
-
source_class->prepare = dav_xtal_prepare;
source_class->context_create = dav_xtal_strings_context_create;
-
bse_object_class_add_param (object_class, _("Frequency"),
PARAM_BASE_FREQ,
bse_param_spec_freq ("base_freq", _("Frequency"),
@@ -127,7 +114,6 @@ dav_xtal_strings_class_init (DavXtalStringsClass *klass)
_("Snappiness of the string"),
34.0, 0.0, 100.0, 1,
SFI_PARAM_STANDARD ":scale"));
-
channel_id = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Pluck frequency input"));
g_assert (channel_id == DAV_XTAL_STRINGS_ICHANNEL_FREQ);
channel_id = bse_source_class_add_ichannel (source_class, "trigger-in", _("Trigger In"), _("Pluck strings on raising edge"));
@@ -135,7 +121,6 @@ dav_xtal_strings_class_init (DavXtalStringsClass *klass)
channel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("XtalStrings Output"));
g_assert (channel_id == DAV_XTAL_STRINGS_OCHANNEL_MONO);
}
-
static void
dav_xtal_strings_init (DavXtalStrings *self)
{
@@ -151,12 +136,10 @@ dav_xtal_strings_init (DavXtalStrings *self)
self->size = 1;
self->pos = 0;
self->count = 0;
-
self->a = 0.0;
self->damping_factor = 0.0;
#endif
}
-
static void
dav_xtal_strings_set_property (GObject *object,
guint param_id,
@@ -212,7 +195,6 @@ dav_xtal_strings_set_property (GObject *object,
break;
}
}
-
static void
dav_xtal_strings_get_property (GObject *object,
guint param_id,
@@ -257,7 +239,6 @@ dav_xtal_strings_get_property (GObject *object,
break;
}
}
-
static void
dav_xtal_prepare (BseSource *source)
{
@@ -266,14 +247,12 @@ dav_xtal_prepare (BseSource *source)
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->prepare (source);
}
-
static gfloat inline
calc_factor (gfloat freq,
gfloat t)
{
return pow (0.5, 1.0 / (freq * t));
}
-
/* mini random number generator (adapted from rapicorn), to generate deterministic
* sequence of booleans when --bse-disable-randomization was used
*/
@@ -283,7 +262,6 @@ typedef struct
guint32 seed;
guint32 mask;
} DavRand;
-
static void
dav_rand_setup (DavRand *rand,
gboolean allow_randomization)
@@ -292,7 +270,6 @@ dav_rand_setup (DavRand *rand,
rand->mask = 0;
rand->allow_randomization = allow_randomization;
}
-
static gboolean
dav_rand_bool (DavRand *rand)
{
@@ -311,7 +288,6 @@ dav_rand_bool (DavRand *rand)
return ((rand->seed & rand->mask) == 0);
}
}
-
/* the GSL engine module that generates the signal, there may be many
* modules per DavXtalStrings object
*/
@@ -325,7 +301,6 @@ typedef struct {
gdouble last_transposed_trigger_freq;
DavXtalStringsParams tparams;
} XtalStringsModule;
-
/* trigger a XtalStringsModule by altering its state.
*/
static inline void
@@ -340,14 +315,11 @@ xmod_trigger (XtalStringsModule *xmod,
trigger_freq *= bse_cent_tune_fast (xmod->tparams.fine_tune);
trigger_freq = CLAMP (trigger_freq, 27.5, 4000.0);
xmod->last_transposed_trigger_freq = trigger_freq;
-
xmod->pos = 0;
xmod->count = 0;
xmod->size = (int) ((bse_engine_sample_freq() + trigger_freq - 1) / trigger_freq);
-
xmod->a = calc_factor (trigger_freq, xmod->tparams.tension_decay);
xmod->damping_factor = calc_factor (trigger_freq, xmod->tparams.note_decay);
-
/* Create envelope. */
int pivot = xmod->size / 5;
int i;
@@ -355,11 +327,9 @@ xmod_trigger (XtalStringsModule *xmod,
xmod->string[i] = ((float) i) / pivot;
for (; i < xmod->size; i++)
xmod->string[i] = ((float) (xmod->size - i - 1)) / (xmod->size - pivot - 1);
-
/* Add some snap. */
for (i = 0; i < xmod->size; i++)
xmod->string[i] = pow (xmod->string[i], xmod->tparams.snap_factor * 10.0 + 1.0);
-
/* Add static to displacements. */
DavRand rand;
dav_rand_setup (&rand, bse_main_args->allow_randomization);
@@ -370,7 +340,6 @@ xmod_trigger (XtalStringsModule *xmod,
for (i = 0; i < xmod->size; i++)
xmod->string[i] *= xmod->tparams.trigger_vel;
}
-
static void
xmod_process (BseModule *module,
guint n_values)
@@ -382,10 +351,8 @@ xmod_process (BseModule *module,
gfloat sample, last_trigger_level;
guint real_freq_256, actual_freq_256;
guint i;
-
real_freq_256 = (int) (xmod->last_transposed_trigger_freq * 256);
actual_freq_256 = (int) (bse_engine_sample_freq() * 256. / xmod->size);
-
if (BSE_MODULE_ISTREAM (module, DAV_XTAL_STRINGS_ICHANNEL_FREQ).connected)
freq_in = BSE_MODULE_IBUFFER (module, DAV_XTAL_STRINGS_ICHANNEL_FREQ);
else
@@ -401,45 +368,36 @@ xmod_process (BseModule *module,
actual_freq_256 = (int) (bse_engine_sample_freq() * 256. / xmod->size);
}
last_trigger_level = trigger_in[i];
-
/* Get next position. */
pos2 = xmod->pos + 1;
if (pos2 >= xmod->size)
pos2 = 0;
-
/* Linearly interpolate sample. */
sample = xmod->string[xmod->pos] * (1.0 - (((float) xmod->count) / actual_freq_256));
sample += xmod->string[pos2] * (((float) xmod->count) / actual_freq_256);
-
/* store sample, clipping is required as the algorithm generates
* overshoot on purpose
*/
wave_out[i] = CLAMP (sample, -1.0, +1.0);
-
/* Use Bresenham's algorithm to advance to the next position. */
xmod->count += real_freq_256;
while (xmod->count >= actual_freq_256)
{
xmod->d = ((xmod->d * (1.0 - xmod->a)) + (xmod->string[xmod->pos] * xmod->a)) * xmod->damping_factor;
xmod->string[xmod->pos] = xmod->d;
-
xmod->pos++;
if (xmod->pos >= xmod->size)
xmod->pos = 0;
-
xmod->count -= actual_freq_256;
}
}
xmod->last_trigger_level = last_trigger_level;
}
-
#define STRING_LENGTH() ((bse_engine_sample_freq() + 19) / 20)
-
static void
xmod_reset (BseModule *module)
{
XtalStringsModule *xmod = (XtalStringsModule*) module->user_data;
-
/* this function is called whenever we need to start from scratch */
memset (xmod->string, 0, STRING_LENGTH () * sizeof (xmod->string[0]));
xmod->size = 1;
@@ -450,17 +408,14 @@ xmod_reset (BseModule *module)
xmod->last_transposed_trigger_freq = 440.0; /* just _some_ valid freq for the stepping */
xmod->last_trigger_level = 0;
}
-
static void
xmod_free (gpointer data,
const BseModuleClass *klass)
{
XtalStringsModule *xmod = (XtalStringsModule*) data;
-
g_free (xmod->string);
g_free (xmod);
}
-
static void
dav_xtal_strings_context_create (BseSource *source,
guint context_handle,
@@ -479,22 +434,17 @@ dav_xtal_strings_context_create (BseSource *source,
DavXtalStrings *self = DAV_XTAL_STRINGS (source);
XtalStringsModule *xmod = g_new0 (XtalStringsModule, 1);
BseModule *module;
-
xmod->string = g_new0 (gfloat, STRING_LENGTH ());
xmod->tparams = self->params;
module = bse_module_new (&xmod_class, xmod);
xmod_reset (module); /* value initialization */
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
-
/* update module configuration from a new set of DavXtalStringsParams
*/
static void
@@ -503,12 +453,10 @@ xmod_access (BseModule *module,
{
XtalStringsModule *xmod = (XtalStringsModule*) module->user_data;
DavXtalStringsParams *params = (DavXtalStringsParams*) data;
-
xmod->tparams = *params;
if (params->trigger_now)
xmod_trigger (xmod, params->freq);
}
-
static void
dav_xtal_strings_update_modules (DavXtalStrings *self,
gboolean trigger_now)
diff --git a/plugins/davxtalstrings.hh b/plugins/davxtalstrings.hh
index 4faa38d..f86647d 100644
--- a/plugins/davxtalstrings.hh
+++ b/plugins/davxtalstrings.hh
@@ -1,14 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __DAV_XTAL_STRINGS_H__
#define __DAV_XTAL_STRINGS_H__
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
/* --- object type macros --- */
#define DAV_TYPE_XTAL_STRINGS (dav_xtal_strings_get_type())
#define DAV_XTAL_STRINGS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DAV_TYPE_XTAL_STRINGS, DavXtalStrings))
@@ -16,8 +13,6 @@ extern "C" {
#define DAV_IS_XTAL_STRINGS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DAV_TYPE_XTAL_STRINGS))
#define DAV_IS_XTAL_STRINGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), DAV_TYPE_XTAL_STRINGS))
#define DAV_XTAL_STRINGS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), DAV_TYPE_XTAL_STRINGS, DavXtalStringsClass))
-
-
/* --- DavXtalStrings source --- */
typedef struct _DavXtalStrings DavXtalStrings;
typedef struct _DavXtalStringsClass DavXtalStringsClass;
@@ -35,17 +30,13 @@ typedef struct {
struct _DavXtalStrings
{
BseSource parent_object;
-
DavXtalStringsParams params;
int transpose;
};
-
struct _DavXtalStringsClass
{
BseSourceClass parent_class;
};
-
-
/* --- channels --- */
enum
{
@@ -58,11 +49,7 @@ enum
DAV_XTAL_STRINGS_OCHANNEL_MONO,
DAV_XTAL_STRINGS_N_OCHANNELS
};
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __DAV_XTAL_STRINGS_H__ */
diff --git a/plugins/evaluator/bseevaluator.cc b/plugins/evaluator/bseevaluator.cc
index 8c7cf0f..0f15b52 100644
--- a/plugins/evaluator/bseevaluator.cc
+++ b/plugins/evaluator/bseevaluator.cc
@@ -4,23 +4,18 @@
#include "instruction.hh"
#include "cpu.hh"
#include "compiler.hh"
-
#include <math.h>
#include <string.h>
-
namespace Bse {
using namespace std;
using namespace EvaluatorUtils;
-
class Evaluator : public EvaluatorBase
{
int input_reg, output_reg;
vector<Instruction> instructions;
-
struct Properties : public EvaluatorProperties {
vector<Instruction> instructions;
int input_reg, output_reg;
-
explicit Properties (Evaluator *e) : EvaluatorProperties (e)
{
instructions = e->instructions;
@@ -28,7 +23,6 @@ class Evaluator : public EvaluatorBase
output_reg = e->output_reg;
}
};
-
class Module : public SynthesisModule {
CPU cpu;
int input_reg, output_reg;
@@ -49,7 +43,6 @@ class Evaluator : public EvaluatorBase
{
const float *input = istream (ICHANNEL_INPUT).values;
float *output = ostream (OCHANNEL_OUTPUT).values;
-
cpu.execute_1_1_block (input_reg, output_reg, input, output, samples);
}
};
@@ -72,30 +65,24 @@ public:
vector<Instruction> new_instructions;
Symbols symbols;
string error;
-
input_reg = symbols.alloc("input");
output_reg = symbols.alloc("output");
-
error = Compiler::tokenize (symbols, source_vec, tokens);
if (error != "")
{
set_status("ERROR: " + error);
break;
}
-
error = Compiler::compile (symbols, tokens, new_instructions);
if (error != "")
{
set_status("ERROR: " + error);
break;
}
-
instructions = new_instructions;
-
CPU cpu;
cpu.set_program(instructions);
cpu.print_program(symbols);
-
set_status("compile ok.");
}
break;
@@ -104,12 +91,8 @@ public:
return false;
}
BSE_EFFECT_INTEGRATE_MODULE (Evaluator, Module, Properties);
-
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (Evaluator);
-
} // Bse
-
/* vim:set ts=8 sw=2 sts=2: */
diff --git a/plugins/evaluator/bseevaluator.idl b/plugins/evaluator/bseevaluator.idl
index 5070047..79fe3ab 100644
--- a/plugins/evaluator/bseevaluator.idl
+++ b/plugins/evaluator/bseevaluator.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse {
-
class Evaluator : Bse::Effect {
/*Info icon = "icons/bseevaluator.png";*/
Info options = "unstable";
@@ -19,7 +17,5 @@ class Evaluator : Bse::Effect {
String status = String (_("Status"), _("Status used to output error messages"), "", GUI_RDONLY);
};
};
-
}; // Bse
-
/* vim:set ts=8 sw=2 sts=2 syntax=cpp: */
diff --git a/plugins/evaluator/compiler.cc b/plugins/evaluator/compiler.cc
index ac2f45c..cdc5125 100644
--- a/plugins/evaluator/compiler.cc
+++ b/plugins/evaluator/compiler.cc
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include "compiler.hh"
#include <assert.h>
#include <ctype.h>
-
using std::vector;
using std::string;
using namespace Bse::EvaluatorUtils;
-
string Compiler::tokenize(Symbols& symbols, const vector<char>& code_without_nl, vector<Token>& tokens)
{
enum {
@@ -15,12 +12,9 @@ string Compiler::tokenize(Symbols& symbols, const vector<char>& code_without_nl,
stNumber,
stVariable
} state = stNeutral;
-
string currentToken;
-
vector<char> code = code_without_nl;
code.push_back('\n');
-
vector<char>::const_iterator ci = code.begin();
while (ci != code.end())
{
@@ -67,7 +61,6 @@ string Compiler::tokenize(Symbols& symbols, const vector<char>& code_without_nl,
else
{
char s[2] = { *ci, 0 };
-
return "can't interpret '" + string(s) + "'";
}
ci++;
@@ -103,26 +96,22 @@ string Compiler::tokenize(Symbols& symbols, const vector<char>& code_without_nl,
}
return "";
}
-
Compiler::Compiler(Symbols& symbols, const vector<Token>& tokens)
: symbols(symbols), tokens(tokens)
{
for(unsigned int i = 0; i < tokens.size(); i++)
done.push_back(false);
}
-
int Compiler::compile(int begin, int size, vector<Instruction>& instructions)
{
int reg = -1;
int end = begin+size;
-
printf("compiling [%d:%d] : ", begin, end);
for(int i=begin;i<end;i++)
{
printf("<%s> ",tokens[i].str().c_str());
}
printf("\n");
-
if (size == 1)
{
if (tokens[begin].type == Token::NUMBER)
@@ -162,11 +151,9 @@ int Compiler::compile(int begin, int size, vector<Instruction>& instructions)
if (tokens[i].type == Token::LEFT_PAREN)
plevel++;
}
-
printf("best is %d\n", best);
if (best == -1)
break;
-
if (size >= 2 && tokens[best].type == Token::LEFT_PAREN && tokens[end-1].type == Token::RIGHT_PAREN)
{
if (best == begin) /* (expr) */
@@ -215,7 +202,6 @@ int Compiler::compile(int begin, int size, vector<Instruction>& instructions)
{
compile(begin,best-begin,instructions);
reg = compile(best+1,end-best-1,instructions);
-
done[best] = true;
}
else
@@ -226,34 +212,28 @@ int Compiler::compile(int begin, int size, vector<Instruction>& instructions)
}
assert(reg != -1 || size == 0);
return reg;
-
/*
// evaluate expression:
// 1. treeify
// 2. evaluate LHS => tmp1
// 3. evaluate RHS => tmp2
// 4. result = OP tmp1 tmp2
-
if (tokens[0].type == Token::NUMBER
&& tokens[1].type == Token::PLUS
&& tokens[2].type == Token::NUMBER)
{
int reg1 = symbols.alloc();
int reg2 = symbols.alloc();
-
instructions.push_back (Instruction::rv(Instruction::SET, reg1, tokens[0].value));
instructions.push_back (Instruction::rv(Instruction::SET, reg2, tokens[2].value));
instructions.push_back (Instruction::rr(Instruction::ADD, reg1, reg2));
-
// result in reg1
}
*/
}
-
string Compiler::compile(Symbols& symbols, const vector<Token>& tokens, vector<Instruction>& instructions)
{
Compiler c(symbols, tokens);
c.compile(0, tokens.size(), instructions);
-
return "";
}
diff --git a/plugins/evaluator/compiler.hh b/plugins/evaluator/compiler.hh
index f883c21..7ad7699 100644
--- a/plugins/evaluator/compiler.hh
+++ b/plugins/evaluator/compiler.hh
@@ -1,31 +1,23 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef BSE_EVALUATOR_COMPILER_H
#define BSE_EVALUATOR_COMPILER_H
-
#include "token.hh"
#include "instruction.hh"
#include "symbols.hh"
-
#include <vector>
#include <string>
-
namespace Bse {
namespace EvaluatorUtils {
-
struct Compiler {
Symbols& symbols;
const std::vector<Token>& tokens;
std::vector<bool> done;
-
Compiler(Symbols& symbols, const std::vector<Token>& tokens);
int compile(int begin, int size, std::vector<Instruction>& instructions);
public:
static std::string tokenize(Symbols& symbols, const std::vector<char>& source, std::vector<Token>& tokens);
static std::string compile(Symbols& sybols, const std::vector<Token>& tokens, std::vector<Instruction>& instructions);
};
-
}
}
-
#endif // BSE_EVALUATOR_COMPILER_H
diff --git a/plugins/evaluator/cpu.cc b/plugins/evaluator/cpu.cc
index cf935a0..bfe3350 100644
--- a/plugins/evaluator/cpu.cc
+++ b/plugins/evaluator/cpu.cc
@@ -1,78 +1,61 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include "cpu.hh"
-
#include <algorithm>
#include <assert.h>
-
using std::vector;
using std::max;
using namespace Bse::EvaluatorUtils;
-
CPU::CPU()
{
regs = 0;
n_registers = 0;
}
-
void CPU::set_program(const vector<Instruction>& new_instructions)
{
if (regs)
free (regs);
-
instructions = new_instructions;
/* alloc regs, initialize n_registers */
-
n_registers = 0;
vector<Instruction>::const_iterator ip;
-
for(ip = instructions.begin(); ip != instructions.end(); ip++)
{
int r[4];
ip->rw_registers(r[0],r[1],r[2],r[3]);
-
for(int k = 0; k < 4; k++)
n_registers = max(r[k]+1, n_registers);
}
-
/* FIXME: */
n_registers = max(2, n_registers);
-
regs = (double *)calloc(n_registers, sizeof(double));
}
-
CPU::~CPU()
{
if (regs)
free(regs);
}
-
void CPU::print_registers(const Symbols& symbols)
{
printf("STATE: n_registers = %d\n", n_registers);
for(int i = 0; i < n_registers; i++)
printf(" %8s = %.8g\n", symbols.name(i).c_str(), regs[i]);
}
-
void CPU::print_program(const Symbols& symbols)
{
vector<Instruction>::const_iterator ip;
for(ip = instructions.begin(); ip != instructions.end(); ip++)
ip->print(symbols);
}
-
void CPU::execute()
{
vector<Instruction>::const_iterator ip;
for(ip = instructions.begin(); ip != instructions.end(); ip++)
ip->exec(regs);
}
-
void CPU::execute_1_1_block(int sreg, int dreg, const float *sdata, float *ddata, int samples)
{
assert(sreg >= 0 && sreg <= n_registers); /* g_return_if_fail */
assert(dreg >= 0 && dreg <= n_registers); /* g_return_if_fail */
-
for(int i = 0; i < samples; i++)
{
vector<Instruction>::const_iterator ip;
@@ -82,5 +65,4 @@ void CPU::execute_1_1_block(int sreg, int dreg, const float *sdata, float *ddata
ddata[i] = regs[dreg];
}
}
-
// vim:set ts=8 sts=4 sw=4:
diff --git a/plugins/evaluator/cpu.hh b/plugins/evaluator/cpu.hh
index 40c67fe..dda6398 100644
--- a/plugins/evaluator/cpu.hh
+++ b/plugins/evaluator/cpu.hh
@@ -1,36 +1,26 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef BSE_EVALUATOR_CPU_H
#define BSE_EVALUATOR_CPU_H
-
#include "instruction.hh"
#include "symbols.hh"
-
#include <vector>
-
namespace Bse {
namespace EvaluatorUtils {
-
class CPU {
private:
int n_registers;
double *regs;
std::vector<Instruction> instructions;
-
public:
CPU();
~CPU();
-
void set_program(const std::vector<Instruction>& new_instructions);
void print_registers(const Symbols& symbols);
void print_program(const Symbols& symbols);
void execute();
void execute_1_1_block(int sreg, int dreg, const float *sdata, float *ddata, int samples);
};
-
}
}
-
#endif // BSE_EVALUATOR_CPU_H
-
// vim:set ts=8 sts=4 sw=4:
diff --git a/plugins/evaluator/evaluateexpr.cc b/plugins/evaluator/evaluateexpr.cc
index 86f4ca0..8aff67f 100644
--- a/plugins/evaluator/evaluateexpr.cc
+++ b/plugins/evaluator/evaluateexpr.cc
@@ -1,36 +1,27 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <stdio.h>
#include <vector>
#include <string>
-
#include "symbols.hh"
#include "compiler.hh"
#include "cpu.hh"
#include "instruction.hh"
-
using std::vector;
using std::string;
using namespace Bse::EvaluatorUtils;
-
int main(int argc, char **argv)
{
vector<char> source;
-
for(int i = 1; i < argc; i++)
{
const char *a = argv[i];
-
source.insert(source.end(), a, a + strlen(a));
source.push_back(' ');
}
-
Symbols symbols;
-
vector<Token> tokens;
vector<Instruction> instructions;
string error;
-
error = Compiler::tokenize(symbols, source, tokens);
if (error != "")
{
@@ -43,7 +34,6 @@ int main(int argc, char **argv)
fprintf(stderr, "compilation error: %s\n", error.c_str());
exit(1);
}
-
printf("\nPROGRAM:\n\n");
CPU cpu;
cpu.set_program(instructions);
diff --git a/plugins/evaluator/instruction.cc b/plugins/evaluator/instruction.cc
index a868854..22f3ab8 100644
--- a/plugins/evaluator/instruction.cc
+++ b/plugins/evaluator/instruction.cc
@@ -1,9 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include "instruction.hh"
-
using namespace Bse::EvaluatorUtils;
-
Instruction Instruction::rr(Instruction::Type ins, int reg1, int reg2)
{
Instruction i;
@@ -12,7 +9,6 @@ Instruction Instruction::rr(Instruction::Type ins, int reg1, int reg2)
i.p2.reg = reg2;
return i;
}
-
Instruction Instruction::rv(Instruction::Type ins, int reg, double val)
{
Instruction i;
@@ -21,7 +17,6 @@ Instruction Instruction::rv(Instruction::Type ins, int reg, double val)
i.p2.val = val;
return i;
}
-
void Instruction::rw_registers(int& read1, int& read2, int& write1, int& write2) const
{
read1 = read2 = write1 = write2 = -1;
@@ -45,7 +40,6 @@ void Instruction::rw_registers(int& read1, int& read2, int& write1, int& write2)
read1 = write1 = p1.reg;
}
}
-
void Instruction::print(const Symbols& symbols) const
{
switch(ins)
@@ -65,5 +59,4 @@ void Instruction::print(const Symbols& symbols) const
break;
}
}
-
/* vim:set ts=8 sw=4 sts=4: */
diff --git a/plugins/evaluator/instruction.hh b/plugins/evaluator/instruction.hh
index 0fab11f..8793591 100644
--- a/plugins/evaluator/instruction.hh
+++ b/plugins/evaluator/instruction.hh
@@ -1,14 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef BSE_EVALUATOR_INSTRUCTION_H
#define BSE_EVALUATOR_INSTRUCTION_H
-
#include "symbols.hh"
#include <math.h>
-
namespace Bse {
namespace EvaluatorUtils {
-
class Instruction {
private:
union {
@@ -18,7 +14,6 @@ private:
int reg;
double val;
} p2;
-
public:
enum Type {
SET, /* dest, value */
@@ -27,37 +22,28 @@ public:
MUL, /* dest, src */
SIN /* dest */
} ins;
-
inline void exec(double *regs) const
{
switch(ins)
{
case SET: regs[p1.reg] = p2.val;
break;
-
case MOVE: regs[p1.reg] = regs[p2.reg];
break;
-
case ADD: regs[p1.reg] += regs[p2.reg];
break;
-
case MUL: regs[p1.reg] *= regs[p2.reg];
break;
-
case SIN: regs[p1.reg] = sin(regs[p1.reg]);
break;
}
}
-
void print(const Symbols& symbols) const;
void rw_registers(int& read1, int& read2, int& write1, int& write2) const;
-
/* "constuctors" */
static Instruction rr(Type ins, int reg1, int reg2); // register register instruction
static Instruction rv(Type ins, int reg, double val); // register value instruction
};
-
}
}
-
#endif // BSE_EVALUATOR_INSTRUCTION_H
diff --git a/plugins/evaluator/symbols.hh b/plugins/evaluator/symbols.hh
index 94cfdd3..1ad7347 100644
--- a/plugins/evaluator/symbols.hh
+++ b/plugins/evaluator/symbols.hh
@@ -1,28 +1,21 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef BSE_EVALUATOR_SYMBOLS_H
#define BSE_EVALUATOR_SYMBOLS_H
-
#include <string>
#include <map>
-
namespace Bse {
namespace EvaluatorUtils {
-
class Symbols {
std::map<std::string,int> symbol_map;
int n_registers;
-
public:
Symbols()
{
n_registers = 0;
}
-
int alloc() {
return n_registers++;
}
-
int alloc(const std::string& name)
{
std::map<std::string,int>::iterator smi = symbol_map.find(name);
@@ -31,7 +24,6 @@ public:
else
return smi->second;
}
-
std::string name(int reg) const
{
/* sloow ;) */
@@ -41,20 +33,16 @@ public:
if (smi->second == reg)
return smi->first;
}
-
char buffer[1024];
sprintf(buffer,"R%02d", reg);
return buffer;
}
-
void clear()
{
symbol_map.clear();
n_registers = 0;
}
};
-
}
}
-
#endif // BSE_EVALUATOR_SYMBOLS_H
diff --git a/plugins/evaluator/token.hh b/plugins/evaluator/token.hh
index e3b683a..d755d63 100644
--- a/plugins/evaluator/token.hh
+++ b/plugins/evaluator/token.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef BSE_EVALUATOR_TOKEN_H
#define BSE_EVALUATOR_TOKEN_H
-
#include <string>
-
namespace Bse {
namespace EvaluatorUtils {
-
struct Token {
enum TokenType {
NONE,
@@ -20,20 +16,16 @@ struct Token {
NUMBER,
VARIABLE
} type;
-
double value;
int reg;
-
Token(TokenType type = NONE, double value = 0.0)
: type (type), value (value)
{
}
-
bool is_operator() const
{
return operator_precedence() != -1;
}
-
int operator_precedence() const
{
/* higher numbers mean higher precedence */
@@ -48,7 +40,6 @@ struct Token {
default: return -1;
}
}
-
std::string str() const
{
switch(type)
@@ -65,8 +56,6 @@ struct Token {
}
}
};
-
}
}
-
#endif
diff --git a/plugins/freeverb/bsefreeverb.cc b/plugins/freeverb/bsefreeverb.cc
index c89f542..fd7fb83 100644
--- a/plugins/freeverb/bsefreeverb.cc
+++ b/plugins/freeverb/bsefreeverb.cc
@@ -1,10 +1,7 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsefreeverb.hh"
-
#include <bse/bseengine.hh>
#include <bse/bsecxxplugin.hh>
-
-
/* --- properties --- */
enum
{
@@ -15,8 +12,6 @@ enum
PROP_DRY_LEVEL,
PROP_WIDTH
};
-
-
/* --- prototypes --- */
static void bse_free_verb_init (BseFreeVerb *self);
static void bse_free_verb_class_init (BseFreeVerbClass *klass);
@@ -32,18 +27,14 @@ static void bse_free_verb_context_create (BseSource *source,
guint context_handle,
BseTrans *trans);
static void bse_free_verb_update_modules (BseFreeVerb *self);
-
// == Type Registration ==
#include "../icons/reverb.c"
BSE_RESIDENT_SOURCE_DEF (BseFreeVerb, bse_free_verb, N_("Filters/Free Verb"),
"BseFreeVerb - Free, studio-quality reverb (SOURCE CODE in the public domain) "
"Written by Jezar at Dreampoint - http://www.dreampoint.co.uk",
reverb_icon);
-
/* --- variables --- */
static gpointer parent_class = NULL;
-
-
/* --- functions --- */
static void
bse_free_verb_class_init (BseFreeVerbClass *klass)
@@ -54,16 +45,11 @@ bse_free_verb_class_init (BseFreeVerbClass *klass)
BseFreeVerbConstants *constants = &klass->constants;
BseFreeVerbConfig defaults;
guint channel;
-
parent_class = g_type_class_peek_parent (klass);
-
gobject_class->set_property = bse_free_verb_set_property;
gobject_class->get_property = bse_free_verb_get_property;
-
source_class->context_create = bse_free_verb_context_create;
-
bse_free_verb_cpp_defaults (&defaults, constants);
-
bse_object_class_add_param (object_class, "Reverb Style",
PROP_ROOM_SIZE,
sfi_pspec_real ("room_size", "Room Size", NULL,
@@ -106,13 +92,11 @@ bse_free_verb_class_init (BseFreeVerbClass *klass)
channel = bse_source_class_add_ochannel (source_class, "right-audio-out", _("Right Audio Out"), _("Right Output"));
(void) channel;
}
-
static void
bse_free_verb_init (BseFreeVerb *self)
{
bse_free_verb_cpp_defaults (&self->config, NULL);
}
-
static void
bse_free_verb_set_property (GObject *object,
guint param_id,
@@ -121,7 +105,6 @@ bse_free_verb_set_property (GObject *object,
{
BseFreeVerb *self = BSE_FREE_VERB (object);
BseFreeVerbConstants *constants = &BSE_FREE_VERB_GET_CLASS (self)->constants;
-
switch (param_id)
{
case PROP_ROOM_SIZE:
@@ -149,7 +132,6 @@ bse_free_verb_set_property (GObject *object,
break;
}
}
-
static void
bse_free_verb_get_property (GObject *object,
guint param_id,
@@ -158,7 +140,6 @@ bse_free_verb_get_property (GObject *object,
{
BseFreeVerb *self = BSE_FREE_VERB (object);
BseFreeVerbConstants *constants = &BSE_FREE_VERB_GET_CLASS (self)->constants;
-
switch (param_id)
{
case PROP_ROOM_SIZE:
@@ -181,21 +162,17 @@ bse_free_verb_get_property (GObject *object,
break;
}
}
-
static void
free_verb_access (BseModule *module,
gpointer data)
{
BseFreeVerbCpp *cpp = (BseFreeVerbCpp*) module->user_data;
BseFreeVerbConfig *config = (BseFreeVerbConfig*) data;
-
/* this runs in the Gsl Engine threads */
bse_free_verb_cpp_configure (cpp, config);
-
/* save config for _reset() */
bse_free_verb_cpp_save_config (cpp, config);
}
-
static void
bse_free_verb_update_modules (BseFreeVerb *self)
{
@@ -206,7 +183,6 @@ bse_free_verb_update_modules (BseFreeVerb *self)
g_free,
NULL);
}
-
static void
free_verb_process (BseModule *module,
guint n_values)
@@ -216,33 +192,27 @@ free_verb_process (BseModule *module,
const gfloat *iright = BSE_MODULE_IBUFFER (module, BSE_FREE_VERB_ICHANNEL_RIGHT);
gfloat *oleft = BSE_MODULE_OBUFFER (module, BSE_FREE_VERB_OCHANNEL_LEFT);
gfloat *oright = BSE_MODULE_OBUFFER (module, BSE_FREE_VERB_OCHANNEL_RIGHT);
-
bse_free_verb_cpp_process (cpp, n_values, ileft, iright, oleft, oright);
}
-
static void
free_verb_reset (BseModule *module)
{
BseFreeVerbCpp *cpp = (BseFreeVerbCpp*) module->user_data;
BseFreeVerbConfig config;
-
bse_free_verb_cpp_restore_config (cpp, &config);
bse_free_verb_cpp_destroy (cpp);
bse_free_verb_cpp_create (cpp);
bse_free_verb_cpp_configure (cpp, &config);
bse_free_verb_cpp_save_config (cpp, &config);
}
-
static void
free_verb_destroy (gpointer data,
const BseModuleClass *klass)
{
BseFreeVerbCpp *cpp = (BseFreeVerbCpp*) data;
-
bse_free_verb_cpp_destroy (cpp);
g_free (cpp);
}
-
static void
bse_free_verb_context_create (BseSource *source,
guint context_handle,
@@ -261,19 +231,15 @@ bse_free_verb_context_create (BseSource *source,
BseFreeVerb *self = BSE_FREE_VERB (source);
BseFreeVerbCpp *cpp = g_new0 (BseFreeVerbCpp, 1);
BseModule *module;
-
/* initialize module data */
bse_free_verb_cpp_create (cpp);
bse_free_verb_cpp_configure (cpp, &self->config);
bse_free_verb_cpp_save_config (cpp, &self->config);
module = bse_module_new (&free_verb_class, cpp);
-
/* setup module i/o streams with BseSource i/o channels */
bse_source_set_context_module (source, context_handle, module);
-
/* commit module to engine */
bse_trans_add (trans, bse_job_integrate (module));
-
/* chain parent class' handler */
BSE_SOURCE_CLASS (parent_class)->context_create (source, context_handle, trans);
}
diff --git a/plugins/freeverb/bsefreeverb.hh b/plugins/freeverb/bsefreeverb.hh
index 9a2022f..0e12d67 100644
--- a/plugins/freeverb/bsefreeverb.hh
+++ b/plugins/freeverb/bsefreeverb.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_FREE_VERB_H__
#define __BSE_FREE_VERB_H__
-
#define BSE_PLUGIN_NAME "BseFreeVerb"
-
#include <bse/bseplugin.hh>
#include <bse/bsesource.hh>
#include "bsefreeverbcpp.hh"
-
G_BEGIN_DECLS
-
/* --- type macros --- */
#define BSE_TYPE_FREE_VERB (bse_free_verb_get_type())
#define BSE_FREE_VERB(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_FREE_VERB, BseFreeVerb))
@@ -17,23 +13,17 @@ G_BEGIN_DECLS
#define BSE_IS_FREE_VERB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_FREE_VERB))
#define BSE_IS_FREE_VERB_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_FREE_VERB))
#define BSE_FREE_VERB_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_FREE_VERB, BseFreeVerbClass))
-
-
/* --- BseFreeVerb --- */
typedef struct
{
BseSource parent_object;
-
BseFreeVerbConfig config;
} BseFreeVerb;
typedef struct
{
BseSourceClass parent_class;
-
BseFreeVerbConstants constants;
} BseFreeVerbClass;
-
-
/* --- channels --- */
enum /*< skip >*/
{
@@ -47,8 +37,5 @@ enum /*< skip >*/
BSE_FREE_VERB_OCHANNEL_RIGHT,
BSE_FREE_VERB_N_OCHANNELS
};
-
-
G_END_DECLS
-
#endif /* __BSE_FREE_VERB_H__ */
diff --git a/plugins/freeverb/bsefreeverbcpp.hh b/plugins/freeverb/bsefreeverbcpp.hh
index 8204693..cd7ed60 100644
--- a/plugins/freeverb/bsefreeverbcpp.hh
+++ b/plugins/freeverb/bsefreeverbcpp.hh
@@ -1,11 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_FREE_VERB_CPP_H__
#define __BSE_FREE_VERB_CPP_H__
-
#include <glib.h>
-
G_BEGIN_DECLS
-
typedef struct
{
/* runtime parameters */
@@ -30,7 +27,6 @@ typedef struct
gpointer obj;
BseFreeVerbConfig saved_config;
} BseFreeVerbCpp;
-
void bse_free_verb_cpp_create (BseFreeVerbCpp *cpp);
void bse_free_verb_cpp_configure (BseFreeVerbCpp *cpp,
BseFreeVerbConfig *config);
@@ -47,9 +43,5 @@ void bse_free_verb_cpp_save_config (BseFreeVerbCpp *cpp,
BseFreeVerbConfig *config);
void bse_free_verb_cpp_restore_config (BseFreeVerbCpp *cpp,
BseFreeVerbConfig *config);
-
-
G_END_DECLS
-
-
#endif /* __BSE_FREE_VERB_CPP_H__ */
diff --git a/plugins/freeverb/denormals.hh b/plugins/freeverb/denormals.hh
index c42cc89..39fa41b 100644
--- a/plugins/freeverb/denormals.hh
+++ b/plugins/freeverb/denormals.hh
@@ -6,13 +6,9 @@
// This code is public domain
#include <bse/bseplugin.hh>
#include <bse/bseieee754.hh>
-
#ifndef _denormals_
#define _denormals_
-
// #define undenormalise(sample) if(((*(unsigned int*)&sample)&0x7f800000)==0) sample=0.0f
#define undenormalise(sample) BSE_FLOAT_FLUSH (sample)
-
#endif//_denormals_
-
//ends
diff --git a/plugins/freeverb/tuning.hh b/plugins/freeverb/tuning.hh
index ced8925..c9880b5 100644
--- a/plugins/freeverb/tuning.hh
+++ b/plugins/freeverb/tuning.hh
@@ -3,10 +3,8 @@
// Written by Jezar at Dreampoint, June 2000
// http://www.dreampoint.co.uk
// This code is public domain
-
#ifndef _tuning_
#define _tuning_
-
const int numcombs = 8;
const int numallpasses = 4;
const float muted = 0;
@@ -24,7 +22,6 @@ const float initialwidth = 1;
const float initialmode = 0;
const float freezemode = 0.5f;
const int stereospread = 23;
-
// These values assume 44.1KHz sample rate
// they will probably be OK for 48KHz sample rate
// but would need scaling for 96KHz (or other) sample rates.
@@ -53,8 +50,5 @@ const int allpasstuningL3 = 341;
const int allpasstuningR3 = 341+stereospread;
const int allpasstuningL4 = 225;
const int allpasstuningR4 = 225+stereospread;
-
#endif//_tuning_
-
//ends
-
diff --git a/plugins/icons/adsr.c b/plugins/icons/adsr.c
index b613296..6223fd1 100644
--- a/plugins/icons/adsr.c
+++ b/plugins/icons/adsr.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 adsr_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -140,5 +139,3 @@ static const guint8 adsr_icon[] =
"\0\0\0\0\2\27-\357\300\27-\357\317\272\27-\357\300\2\27-\357\357\27-"
"\357 \202\0\0\0\0\1\27-\3570\274\27-\357@\1\27-\357\20\377\0\0\0\0\377"
"\0\0\0\0\303\0\0\0\0"};
-
-
diff --git a/plugins/icons/any.c b/plugins/icons/any.c
index 3756cc3..7b4a1f8 100644
--- a/plugins/icons/any.c
+++ b/plugins/icons/any.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (any.c) */
-
#define TEST_IMAGE_WIDTH (64)
#define TEST_IMAGE_HEIGHT (64)
#define TEST_IMAGE_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -288,4 +287,3 @@ static const guint8 TEST_IMAGE_rle_pixel_data[8305] =
"\254r\35\35\326n\31\31\376\\\23\23\357W\21\21\324[\23\23\254[\25\25c\267\0"
"\0\0\0\11\6\1\1\3K\21\21'K\22\22`J\21\21\206G\17\17\2519\13\13\233;\13\13"
"\204?\15\15`A\17\17$\377\0\0\0\0\236\0\0\0\0");
-
diff --git a/plugins/icons/atan.c b/plugins/icons/atan.c
index cb46754..65f4479 100644
--- a/plugins/icons/atan.c
+++ b/plugins/icons/atan.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 atan_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -138,5 +137,3 @@ static const guint8 atan_icon[] =
"\377\377\234\0\0\0\0\202\0\0\0\377\204\0\0\0\0\212\0\0\0\377\223\340"
"\357\377\377\237\0\0\0\377\204\0\0\0\0\1\0\0\0\377\211\340\357\377\377"
"\262\0\0\0\377\302\0\0\0\0"};
-
-
diff --git a/plugins/icons/canyon.c b/plugins/icons/canyon.c
index 7242dcf..6d1e855 100644
--- a/plugins/icons/canyon.c
+++ b/plugins/icons/canyon.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 canyon_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -407,5 +406,3 @@ static const guint8 canyon_icon[] =
"SSS\377RRR\377QQQ\377PPP\377QQQ\377222\377\210\0\0\0\0\2||{\300KKK\300"
"\203FFF\300\6GGG\300HHG\300HHH\300IIH\300JJJ\300222\300\377\0\0\0\0\326"
"\0\0\0\0"};
-
-
diff --git a/plugins/icons/drum.c b/plugins/icons/drum.c
index 48c29cd..18d6483 100644
--- a/plugins/icons/drum.c
+++ b/plugins/icons/drum.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 drum_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -493,5 +492,3 @@ static const guint8 drum_icon[] =
"&\323\244\274A\330\247\272W\336\251\271h\344\254\270t\352\256\266|\360"
"\261\265\177\364\262\264~\363\262\264x\355\257\266n\347\255\267`\341"
"\252\270M\333\250\2724\325\245\273\27\377\0\0\0\0\231\0\0\0\0"};
-
-
diff --git a/plugins/icons/filter.c b/plugins/icons/filter.c
index 7b87629..a9bf480 100644
--- a/plugins/icons/filter.c
+++ b/plugins/icons/filter.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 filter_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -357,5 +356,3 @@ static const guint8 filter_icon[] =
"\13\205\0\0\0\12\6\0\0\0\11\0\0\0\10\0\0\0\6\0\0\0\4\0\0\0\2\0\0\0\1"
"\250\0\0\0\0\202\0\0\0\1\207\0\0\0\2\204\0\0\0\3\207\0\0\0\2\202\0\0"
"\0\1\206\0\0\0\0"};
-
-
diff --git a/plugins/icons/genosc.c b/plugins/icons/genosc.c
index 34b8538..be658b0 100644
--- a/plugins/icons/genosc.c
+++ b/plugins/icons/genosc.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (genosc.c) */
-
#define GEN_OSC_IMAGE_WIDTH (64)
#define GEN_OSC_IMAGE_HEIGHT (64)
#define GEN_OSC_IMAGE_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -96,4 +95,3 @@ static const guint8 GEN_OSC_IMAGE_rle_pixel_data[2186] =
"\0\0\0\34\256\0\0\0\0\1\0\0\0\34\202\0\0\0U\205\0\0\0\252\1\0\0\0q\202\0\0"
"\0U\1\0\0\0\34\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0"
"\241\0\0\0\0");
-
diff --git a/plugins/icons/mixer.c b/plugins/icons/mixer.c
index 9000fcd..94c1398 100644
--- a/plugins/icons/mixer.c
+++ b/plugins/icons/mixer.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 mixer_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -180,5 +179,3 @@ static const guint8 mixer_icon[] =
"\377\264\0\0\0\0\214\363\0\0\377\264\0\0\0\0\214\366\0\0\377\264\0\0"
"\0\0\214\371\0\0\377\264\0\0\0\0\214\374\0\0\377\377\0\0\0\0\377\0\0"
"\0\0\377\0\0\0\0\207\0\0\0\0"};
-
-
diff --git a/plugins/icons/multiply.c b/plugins/icons/multiply.c
index 0e6678b..5036c3b 100644
--- a/plugins/icons/multiply.c
+++ b/plugins/icons/multiply.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 multiply_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -108,5 +107,3 @@ static const guint8 multiply_icon[] =
"\327\377\220\377\377\377\0\213\303\303\327\377\203\304\304\327\377\204"
"\304\304\330\377\214\377\377\377\0\204\305\305\330\377\203\305\305\331"
"\377\213\306\306\331\377\307\377\377\377\0"};
-
-
diff --git a/plugins/icons/noise.c b/plugins/icons/noise.c
index 3a16fcb..0e0e0a9 100644
--- a/plugins/icons/noise.c
+++ b/plugins/icons/noise.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 noise_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -394,5 +393,3 @@ static const guint8 noise_icon[] =
"Es\1\230\0\0\0\0\2025Dr\1\2027Fv\1\5""8Fw\2""8Gx\2""9Hy\2""9Hy\1""8F"
"w\1\2026Es\1\266\0\0\0\0\2035Dr\1\2037Fv\1\3""6Es\1""5Dr\1""6Es\1\250"
"\0\0\0\0"};
-
-
diff --git a/plugins/icons/organ.c b/plugins/icons/organ.c
index 67b15c2..d62ba9a 100644
--- a/plugins/icons/organ.c
+++ b/plugins/icons/organ.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 organ_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -515,5 +514,3 @@ static const guint8 organ_icon[] =
"9r\377\243\230\270\377\254\240\276\377~w\240\377PN\202\377}v\236\377"
"\244\232\271\377qk\227\377@@w\377\266\252\304\377~w\240\377FDz\377\215"
"\204\251\300\217\206\253\377LJ\177\377\204\0\0\0\0"};
-
-
diff --git a/plugins/icons/osc.c b/plugins/icons/osc.c
index 82afc73..8f714ac 100644
--- a/plugins/icons/osc.c
+++ b/plugins/icons/osc.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (osc.c) */
-
#define OSC_IMAGE_WIDTH (64)
#define OSC_IMAGE_HEIGHT (64)
#define OSC_IMAGE_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -67,4 +66,3 @@ static const guint8 OSC_IMAGE_rle_pixel_data[1287] =
"\0\0\0\0\10\17\2\0 \13\1\0\244\5\0\0\335\0\0\0\366\3\0\0\354\2\0\0\351\10"
"\1\0\2150\6\1\12\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0"
"\0\377\0\0\0\0\325\0\0\0\0");
-
diff --git a/plugins/icons/pipe.c b/plugins/icons/pipe.c
index 73685c7..d4dccab 100644
--- a/plugins/icons/pipe.c
+++ b/plugins/icons/pipe.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (pipe.c) */
-
#define PIPE_WIDTH (64)
#define PIPE_HEIGHT (64)
#define PIPE_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -558,4 +557,3 @@ static const guint8 PIPE_rle_pixel_data[11744] =
"\375\375\375\0\205\376\376\376\0\224\375\375\375\0\227\376\376\376\0\214\375"
"\375\375\0\214\376\376\376\0\216\375\375\375\0\377\376\376\376\0\216\376\376"
"\376\0");
-
diff --git a/plugins/icons/reverb.c b/plugins/icons/reverb.c
index 82cf3cc..9eee870 100644
--- a/plugins/icons/reverb.c
+++ b/plugins/icons/reverb.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 reverb_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -344,5 +343,3 @@ static const guint8 reverb_icon[] =
"\13\205\0\0\0\12\6\0\0\0\11\0\0\0\10\0\0\0\6\0\0\0\4\0\0\0\2\0\0\0\1"
"\250\0\0\0\0\202\0\0\0\1\207\0\0\0\2\204\0\0\0\3\207\0\0\0\2\202\0\0"
"\0\1\206\0\0\0\0"};
-
-
diff --git a/plugins/icons/sequencer.c b/plugins/icons/sequencer.c
index 2f7c48a..8c764ff 100644
--- a/plugins/icons/sequencer.c
+++ b/plugins/icons/sequencer.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 sequencer_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -353,5 +352,3 @@ static const guint8 sequencer_icon[] =
"\0&\0\0\0-\256\0\0\0.\2\0\0\0""2\0\0\0""0\202\0\0\0.\3\0\0\0""1\0\0\0"
"6\0\0\0/\202\0\0\0.\4\0\0\0,\0\0\0!\0\0\0\12\0\0\0\1\377\0\0\0\0\1\0"
"\0\0\0"};
-
-
diff --git a/plugins/icons/sine.c b/plugins/icons/sine.c
index 5db71fc..ce58cfa 100644
--- a/plugins/icons/sine.c
+++ b/plugins/icons/sine.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (sine.c) */
-
#define SINE_WIDTH (64)
#define SINE_HEIGHT (64)
#define SINE_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -46,4 +45,3 @@ static const guint8 SINE_rle_pixel_data[714] =
"\1\361!\6P\266\0\0\0\0\1\361!\6[\207\361!\6\210\1\361!\6<\270\0\0\0\0\2\361"
"!\6\34\361!\6c\203\361!\6\177\2\361!\6U\361!\6\34\377\0\0\0\0\377\0\0\0\0"
"\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\377\0\0\0\0\227\0\0\0\0");
-
diff --git a/plugins/icons/speaker.c b/plugins/icons/speaker.c
index cf2049a..6dc46f8 100644
--- a/plugins/icons/speaker.c
+++ b/plugins/icons/speaker.c
@@ -1,5 +1,4 @@
/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (speaker.c) */
-
#define SPEAKER_WIDTH (64)
#define SPEAKER_HEIGHT (64)
#define SPEAKER_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
@@ -371,4 +370,3 @@ static const guint8 SPEAKER_rle_pixel_data[10019] =
"\0\0\0\4\0\0\0\2\202\0\0\0\1\264\0\0\0\0\1\0\0\0\1\202\0\0\0\2\204\0\0\0\3"
"\2\0\0\0\2\0\0\0\1\267\0\0\0\0\1\0\0\0\1\202\0\0\0\2\204\0\0\0\3\2\0\0\0\2"
"\0\0\0\1\234\0\0\0\0");
-
diff --git a/plugins/icons/strings.c b/plugins/icons/strings.c
index 520474a..e79c920 100644
--- a/plugins/icons/strings.c
+++ b/plugins/icons/strings.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 strings_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -254,5 +253,3 @@ static const guint8 strings_icon[] =
"\377 J<\372)#\35\344\267\0\0\0\0\11\233oS\40\233oT\1\234pT\10\233oT\1"
"\0\0\0\0WA2\36QC6\227\25\23\21\250\16\16\16!\271\0\0\0\0\1\233oS\1\377"
"\0\0\0\0\243\0\0\0\0"};
-
-
diff --git a/plugins/icons/sub.c b/plugins/icons/sub.c
index 850f856..4b55b3a 100644
--- a/plugins/icons/sub.c
+++ b/plugins/icons/sub.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
#ifdef __SUNPRO_C
#pragma align 4 (sub_pixstream)
#endif
@@ -203,5 +202,3 @@ static const guint8 sub_pixstream[] =
"\377\307\253\253\377\311\256\256\377\314\262\262\377\316\265\265\377"
"\320\271\271\377\323\274\274\377\325\300\300\377\327\303\303\377\377"
"\0\0\0\0\313\0\0\0\0"};
-
-
diff --git a/plugins/icons/sum.c b/plugins/icons/sum.c
index bbb85db..bb64c65 100644
--- a/plugins/icons/sum.c
+++ b/plugins/icons/sum.c
@@ -1,5 +1,4 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
-
static const guint8 sum_icon[] =
{ ""
/* Pixbuf magic (0x47646b50) */
@@ -171,5 +170,3 @@ static const guint8 sum_icon[] =
"\377\244\244\302\377\250\250\305\377\253\253\307\377\256\256\311\377"
"\262\262\314\377\265\265\316\377\271\271\320\377\274\274\323\377\300"
"\300\325\377\303\303\327\377\377\0\0\0\0\313\0\0\0\0"};
-
-
diff --git a/plugins/standardguspatchenvelope.cc b/plugins/standardguspatchenvelope.cc
index 3e8e320..45c5038 100644
--- a/plugins/standardguspatchenvelope.cc
+++ b/plugins/standardguspatchenvelope.cc
@@ -4,18 +4,14 @@
#include "standardguspatchenvelope.genidl.hh"
#include <bse/gslwavechunk.hh>
#include <bse/bsemathsignal.hh>
-
using namespace std;
using namespace Sfi;
-
namespace Bse {
namespace Standard {
-
class GusPatchEnvelope : public GusPatchEnvelopeBase {
/* properties (used to pass "global" envelope data into the modules) */
struct Properties : public GusPatchEnvelopeProperties {
BseWaveIndex *wave_index;
-
Properties (GusPatchEnvelope *envelope)
: GusPatchEnvelopeProperties (envelope),
wave_index (envelope->wave_index)
@@ -31,38 +27,31 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
bool retrigger;
gfloat last_retrigger_level;
bool in_attack_or_sustain_phase;
-
vector<float> envelope_rates;
vector<float> envelope_offsets;
bool envelope_valid;
int envelope_phase;
float current_envelope_rate;
-
public:
Module() : wave_index (NULL), wave_chunk (NULL)
{
/* other relevant data members will be initialized in reset() */
}
-
void
config (Properties *properties)
{
wave_index = properties->wave_index;
}
-
void
reset()
{
envelope_valid = false;
retrigger = true;
wave_chunk = 0;
-
envelope_value = 0.0;
last_retrigger_level = 0.0;
}
-
enum EnvelopeConversion { CONVERT_RATE, CONVERT_OFFSET };
-
float
convert_envelope_value (EnvelopeConversion convert, guint8 byte)
{
@@ -70,26 +59,21 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
{
/* conversion code copied from Timidity++ */
gint32 r;
-
r = 3 - ((byte >> 6) & 0x3);
r *= 3;
r = (gint32)(byte & 0x3f) << r; /* 6.9 fixed point */
-
return (r * 44100.0) / (mix_freq() * 2048.0 * 1024.0);
}
return byte / 256.0;
}
-
void
parse_envelope_floats (vector<float>& values, const gchar *key, EnvelopeConversion convert)
{
values.clear();
-
const char *parse_me = bse_xinfos_get_value (wave_chunk->dcache->dhandle->setup.xinfos, key);
if (parse_me)
{
string val_string;
-
for (char c; (c = *parse_me); parse_me++)
{
if ((c >= '0' && c <= '9') || c == '.')
@@ -105,25 +89,21 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
values.push_back (convert_envelope_value (convert, atoi (val_string.c_str())));
}
}
-
void
update_envelope (gfloat frequency)
{
envelope_valid = false;
envelope_phase = 0;
in_attack_or_sustain_phase = true;
-
wave_chunk = bse_wave_index_lookup_best (wave_index, frequency, 1); // FIXME: velocity=1 hardcoded
if (wave_chunk)
{
parse_envelope_floats (envelope_rates, "gus-patch-envelope-rates", CONVERT_RATE);
parse_envelope_floats (envelope_offsets, "gus-patch-envelope-offsets", CONVERT_OFFSET);
-
if (envelope_rates.size() == 6 && envelope_offsets.size() == 6)
{
envelope_valid = true;
current_envelope_rate = envelope_rates[0];
-
/*
printf ("envelope:\n");
printf (" wave-format=%s\n", bse_xinfos_get_value (wave_chunk->dcache->dhandle->setup.xinfos, "gus-patch-wave-format"));
@@ -133,17 +113,14 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
}
}
}
-
void
increment_envelope_phase()
{
envelope_phase++;
current_envelope_rate = envelope_rates[envelope_phase];
-
if (envelope_offsets[envelope_phase] < envelope_value)
current_envelope_rate *= -1;
}
-
void
process (unsigned int n_values)
{
@@ -153,7 +130,6 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
update_envelope (frequency[0]);
retrigger = false;
}
-
/* optimize me: we need 4 cases */
if (ostream (OCHANNEL_AUDIO_OUT1).connected || ostream (OCHANNEL_AUDIO_OUT2).connected)
{
@@ -166,7 +142,6 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
gfloat *out1 = ostream (OCHANNEL_AUDIO_OUT1).values, *bound = out1 + n_values;
gfloat *out2 = ostream (OCHANNEL_AUDIO_OUT2).values;
gfloat *done = ostream (OCHANNEL_DONE_OUT).values;
-
while (out1 < bound)
{
/* handle retrigger signal (works even within blocks) */
@@ -174,24 +149,19 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
if (UNLIKELY (BSE_SIGNAL_RAISING_EDGE (last_retrigger_level, retrigger_level)))
{
guint position = out1 - (bound - n_values);
-
update_envelope (frequency[position]);
last_retrigger_level = retrigger_level;
}
-
bool gate_active = (*gate++ > 0.5);
gdouble output;
-
if (envelope_valid)
{
if (gate_active)
{
gdouble new_value = envelope_value + current_envelope_rate;
-
if ((new_value > envelope_offsets[envelope_phase]) ^ (current_envelope_rate < 0))
{
envelope_value = envelope_offsets[envelope_phase];
-
if (envelope_phase < 2)
increment_envelope_phase();
}
@@ -216,16 +186,13 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
printf ("to exponential scale which is with approx: %f\n", bse_approx3_exp2 (envelope_value*6) / 64.0);
*/
in_attack_or_sustain_phase = false;
-
if (envelope_phase < 5)
increment_envelope_phase();
}
-
gdouble new_value = envelope_value + current_envelope_rate;
if ((new_value > envelope_offsets[envelope_phase]) ^ (current_envelope_rate < 0))
{
envelope_value = envelope_offsets[envelope_phase];
-
if (envelope_phase < 5)
increment_envelope_phase();
}
@@ -242,9 +209,7 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
output = 1.0;
*done++ = *audio_gate++ < 0.5;
}
-
output *= *in++;
-
// FIXME: panning
*out1++ = output;
*out2++ = output;
@@ -258,14 +223,11 @@ class GusPatchEnvelope : public GusPatchEnvelopeBase {
}
}
};
-
public:
BseWaveIndex *wave_index;
-
GusPatchEnvelope() : wave_index (NULL)
{
}
-
bool
property_changed (GusPatchEnvelopePropertyID prop_id)
{
@@ -277,13 +239,10 @@ public:
}
return false;
}
-
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (GusPatchEnvelope, Module, Properties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (GusPatchEnvelope);
-
} // Standard
} // Bse
diff --git a/plugins/standardguspatchenvelope.idl b/plugins/standardguspatchenvelope.idl
index 80d323b..ba0a2de 100644
--- a/plugins/standardguspatchenvelope.idl
+++ b/plugins/standardguspatchenvelope.idl
@@ -1,10 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsecxxmodule.idl>
-
namespace Bse {
class Wave;
namespace Standard {
-
class GusPatchEnvelope : Effect {
// Info icon = "icons/noise.png";
Info options = "unstable";
@@ -18,23 +16,19 @@ class GusPatchEnvelope : Effect {
"of the GUS Patches; to accomplish the playing, you thus need to connect "
"one (or for stereo two) BseWaveOsc(s) and their Gate Output Signal to this "
"module.");
-
group _("Properties") {
Wave wave; // FIXME = (_("Wave"), _("GUS Patch to use for the Envelope Data"), NULL, STANDARD);
};
-
// inputs
IStream frequency = (_("Frequency"), _("Frequency Input"));
IStream gate_in = (_("Gate In"), _("Gate input (activates/deactivates envelope)"));
IStream retrigger_in = (_("Retrigger In"), _("Retrigger input (raising edge retriggers envelope)"));
IStream audio_in = (_("Audio In"), _("Audio Input of the WaveOsc playing the patch"));
IStream audio_gate = (_("Audio Gate"), _("Gate Output of the WaveOsc playing the patch"));
-
// outputs
OStream audio_out1 = (_("Audio Out1"), _("Envelope audio output 1 (left output signal)"));
OStream audio_out2 = (_("Audio Out2"), _("Envelope audio output 2 (right output signal)"));
OStream done_out = (_("Done Out"), _("This signal goes high after the release phase has completed"));
};
-
} // Standard
} // Bse
diff --git a/plugins/standardsaturator.cc b/plugins/standardsaturator.cc
index ada31cc..7009065 100644
--- a/plugins/standardsaturator.cc
+++ b/plugins/standardsaturator.cc
@@ -2,11 +2,8 @@
#include "standardsaturator.genidl.hh"
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
-
#define TEST_GNUPLOT 0
-
namespace Bse { namespace Standard {
-
class Saturator : public SaturatorBase {
class Module: public SynthesisModule {
SaturationType saturation;
@@ -240,8 +237,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (Saturator, Module, SaturatorProperties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ALL_TYPES_FROM_STANDARDSATURATOR_IDL();
-
} } // Bse::Standard
diff --git a/plugins/standardsaturator.idl b/plugins/standardsaturator.idl
index 3d464cd..21fe553 100644
--- a/plugins/standardsaturator.idl
+++ b/plugins/standardsaturator.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Bse { namespace Standard {
-
choice SaturationType {
SATURATE_TANH = (_("TANH"), _("Saturation via hyperbolic tangent function which is mostly linear for "
"small levels while providing a soft curvature for high volume signals")),
@@ -15,7 +13,6 @@ choice SaturationType {
"for small levels")),
SATURATE_HARD = (_("Hard"), _("Hard saturation via clipping (prone to clicks)")),
};
-
class Saturator : Bse::Effect {
Info category = "/Distortion/Saturate";
Info icon = "icons/saturate.png";
@@ -45,5 +42,4 @@ class Saturator : Bse::Effect {
// Bool test_dump = Trigger ("Test Dump", NULL, GUI);
};
};
-
} } // Bse::Standard
diff --git a/r+d-files/bse-ellf.c b/r+d-files/bse-ellf.c
index 79b64e6..793a475 100644
--- a/r+d-files/bse-ellf.c
+++ b/r+d-files/bse-ellf.c
@@ -53,11 +53,9 @@ double sinh(), cosh(), atan(), exp();
#else
#include <math.h>
#endif
-
#define code_printf(...) fprintf (stdout, __VA_ARGS__)
#define ellf_printf(...) fprintf (stderr, __VA_ARGS__)
#define ellf_debugf(...) fprintf (stderr, __VA_ARGS__)
-
/* === ellf.doc - start === */
/* ellf.c
* This program calculates design coefficients for
@@ -259,17 +257,14 @@ double sinh(), cosh(), atan(), exp();
* may fail on many systems. Verify that they are supposed
* to work on your computer.
*/
-
/* Constant definitions for math error conditions
*/
-
#define DOMAIN 1 /* argument domain error */
#define SING 2 /* argument singularity */
#define OVERFLOW 3 /* overflow range error */
#define UNDERFLOW 4 /* underflow range error */
#define TLOSS 5 /* total loss of precision */
#define PLOSS 6 /* partial loss of precision */
-
#define EDOM 33
#define ERANGE 34
/* Complex numeral. */
@@ -278,7 +273,6 @@ typedef struct
double r;
double i;
} cmplx;
-
/* Type of computer arithmetic is
* UNKnown arithmetic, invokes coefficients given in
* normal decimal format. Beware of range boundary
@@ -286,26 +280,19 @@ typedef struct
* roundoff problems in pow.c:
* (Sun SPARCstation, i386)
*/
-
/* Define to support tiny denormal numbers, else undefine. */
#define DENORMAL 1
-
/* Define to ask for infinity support, else undefine. */
/* #define INFINITIES 1 */
-
/* Define to ask for support of numbers that are Not-a-Number,
else undefine. This may automatically define INFINITIES in some files. */
/* #define NANS 1 */
-
/* Define to distinguish between -0.0 and +0.0. */
#define MINUSZERO 1
-
/* Define 1 for ANSI C atan2() function
See atan.c and clog.c. */
#define ANSIC 1
-
int mtherr ( char *, int );
-
/* Variable for error reporting. See mtherr.c. */
extern int merror;
/* === mconf.h - end === */
@@ -363,9 +350,7 @@ extern int merror;
*
* These lists are subject to change.
*/
-
/* const.c */
-
#if 1
double MACHEP = 1.11022302462515654042E-16; /* 2**-53 */
#else
@@ -407,8 +392,6 @@ double NEGZERO = -0.0;
#else
double NEGZERO = 0.0;
#endif
-
-
/* === const.c - end === */
/* === protos.h - start === */
/*
@@ -417,7 +400,6 @@ double NEGZERO = 0.0;
*
* Created: Sun Jan 9 15:07:08 2000
*/
-
extern double Cabs ( cmplx *z );
extern void Cadd ( cmplx *a, cmplx *b, cmplx *c );
extern double cay ( double q );
@@ -442,7 +424,6 @@ extern int spln ( void );
extern int zplna ( void );
extern int zplnb ( void );
extern int zplnc ( void );
-
/* === protos.h - end === */
/* === cmplx.c - start === */
/* cmplx.c
@@ -508,18 +489,13 @@ extern int zplnc ( void );
/* cmplx.c
* complex number arithmetic
*/
-
-
void Cdiv ( cmplx *, cmplx *, cmplx * );
void Cadd ( cmplx *, cmplx *, cmplx * );
-
extern double MAXNUM, MACHEP, PI, PIO2, INFINITY, NAN;
-
cmplx czero = {0.0, 0.0};
extern cmplx czero;
cmplx cone = {1.0, 0.0};
extern cmplx cone;
-
/* c = b + a */
void Cadd( a, b, c )
register cmplx *a, *b;
@@ -528,8 +504,6 @@ void Cadd( a, b, c )
c->r = b->r + a->r;
c->i = b->i + a->i;
}
-
-
/* c = b - a */
void Csub( a, b, c )
register cmplx *a, *b;
@@ -538,7 +512,6 @@ void Csub( a, b, c )
c->r = b->r - a->r;
c->i = b->i - a->i;
}
-
/* c = b * a */
void Cmul( a, b, c )
register cmplx *a, *b;
@@ -549,21 +522,15 @@ void Cmul( a, b, c )
c->i = b->r * a->i + b->i * a->r;
c->r = y;
}
-
-
-
/* c = b / a */
void Cdiv( a, b, c )
register cmplx *a, *b;
cmplx *c;
{
double y, p, q, w;
-
-
y = a->r * a->r + a->i * a->i;
p = b->r * a->r + b->i * a->i;
q = b->i * a->r - b->r * a->i;
-
if( y < 1.0 )
{
w = MAXNUM * y;
@@ -578,17 +545,13 @@ void Cdiv( a, b, c )
c->r = p/y;
c->i = q/y;
}
-
-
/* b = a
Caution, a `short' is assumed to be 16 bits wide. */
-
void Cmov( a, b )
void *a, *b;
{
register short *pa, *pb;
int i;
-
pa = (short *) a;
pb = (short *) b;
i = 8;
@@ -596,16 +559,12 @@ void Cmov( a, b )
*pb++ = *pa++;
while( --i );
}
-
-
void Cneg( a )
register cmplx *a;
{
-
a->r = -a->r;
a->i = -a->i;
}
-
/* Cabs()
*
* Complex absolute value
@@ -643,65 +602,51 @@ void Cneg( a )
* DEC -30,+30 30000 3.2e-17 9.2e-18
* IEEE -10,+10 100000 2.7e-16 6.9e-17
*/
-
#define PREC 27
#define MAXEXP 1024
#define MINEXP -1077
-
-
double Cabs( z )
register cmplx *z;
{
double x, y, b, re, im;
int ex, ey, e;
-
#ifdef INFINITIES
/* Note, Cabs(INFINITY,NAN) = INFINITY. */
if( z->r == INFINITY || z->i == INFINITY
|| z->r == -INFINITY || z->i == -INFINITY )
return( INFINITY );
#endif
-
#ifdef NANS
if( isnan(z->r) )
return(z->r);
if( isnan(z->i) )
return(z->i);
#endif
-
re = fabs( z->r );
im = fabs( z->i );
-
if( re == 0.0 )
return( im );
if( im == 0.0 )
return( re );
-
/* Get the exponents of the numbers */
x = frexp( re, &ex );
y = frexp( im, &ey );
-
/* Check if one number is tiny compared to the other */
e = ex - ey;
if( e > PREC )
return( re );
if( e < -PREC )
return( im );
-
/* Find approximate exponent e of the geometric mean. */
e = (ex + ey) >> 1;
-
/* Rescale so mean is about 1 */
x = ldexp( re, -e );
y = ldexp( im, -e );
-
/* Hypotenuse of the right triangle */
b = sqrt( x * x + y * y );
-
/* Compute the exponent of the answer. */
y = frexp( b, &ey );
ey = e + ey;
-
/* Check it for overflow and underflow. */
if( ey > MAXEXP )
{
@@ -710,12 +655,10 @@ double Cabs( z )
}
if( ey < MINEXP )
return(0.0);
-
/* Undo the scaling */
b = ldexp( b, e );
return( b );
}
-
/* Csqrt()
*
* Complex square root
@@ -762,16 +705,13 @@ double Cabs( z )
* Also tested by Csqrt( z ) = z, and tested by arguments
* close to the real axis.
*/
-
void Csqrt( z, w )
cmplx *z, *w;
{
cmplx q, s;
double x, y, r, t;
-
x = z->r;
y = z->i;
-
if( y == 0.0 )
{
if( x < 0.0 )
@@ -787,8 +727,6 @@ void Csqrt( z, w )
return;
}
}
-
-
if( x == 0.0 )
{
r = fabs(y);
@@ -800,7 +738,6 @@ void Csqrt( z, w )
w->i = r;
return;
}
-
/* Approximate sqrt(x^2+y^2) - x = y^2/2x - y^4/24x^3 + ... .
* The relative error in the first term is approximately y^2/12x^2 .
*/
@@ -814,7 +751,6 @@ void Csqrt( z, w )
r = Cabs(z);
t = 0.5*(r - x);
}
-
r = sqrt(t);
q.i = r;
q.r = y/(2.0*r);
@@ -824,18 +760,14 @@ void Csqrt( z, w )
w->r *= 0.5;
w->i *= 0.5;
}
-
-
double hypot( x, y )
double x, y;
{
cmplx z;
-
z.r = x;
z.i = y;
return( Cabs(&z) );
}
-
/* === cmplx.c - end === */
/* === ellik.c - start === */
/* ellik.c
@@ -884,19 +816,15 @@ double hypot( x, y )
*
*
*/
-
/* Incomplete elliptic integral of first kind */
-
extern double ellpk ( double );
double ellik ( double, double );
extern double PI, PIO2, MACHEP, MAXNUM;
-
double ellik( phi, m )
double phi, m;
{
double a, b, c, e, temp, t, K;
int d, mod, sign, npio2;
-
if( m == 0.0 )
return( phi );
a = 1.0 - m;
@@ -946,7 +874,6 @@ double ellik( phi, m )
c = sqrt(m);
d = 1;
mod = 0;
-
while( fabs(c/a) > MACHEP )
{
temp = b/a;
@@ -959,16 +886,13 @@ double ellik( phi, m )
b = temp;
d += d;
}
-
temp = (atan(t) + mod * PI)/(d * a);
-
done:
if( sign < 0 )
temp = -temp;
temp += npio2 * K;
return( temp );
}
-
/* === ellik.c - end === */
/* === ellpe.c - start === */
/* ellpe.c
@@ -1023,9 +947,7 @@ double ellik( phi, m )
*
*/
/* ellpe.c */
-
/* Elliptic integral of second kind */
-
static double P_ellpe[] = {
1.53552577301013293365E-4,
2.50888492163602060990E-3,
@@ -1051,15 +973,11 @@ static double Q_ellpe[] = {
9.37499997197644278445E-2,
2.49999999999888314361E-1
};
-
-
extern double polevl ( double, double[], int );
extern double log ( double );
-
double ellpe(x)
double x;
{
-
if( (x <= 0.0) || (x > 1.0) )
{
if( x == 0.0 )
@@ -1125,12 +1043,8 @@ double ellpe(x)
* Accuracy deteriorates when u is large.
*
*/
-
/* ellpj.c */
-
-
extern double PIO2, MACHEP;
-
int ellpj( u, m, sn, cn, dn, ph )
double u, m;
double *sn, *cn, *dn, *ph;
@@ -1138,10 +1052,7 @@ int ellpj( u, m, sn, cn, dn, ph )
double ai, b, phi, t, twon;
double a[9], c[9];
int i;
-
-
/* Check for special cases */
-
if( m < 0.0 || m > 1.0 )
{
mtherr( "ellpj", DOMAIN );
@@ -1162,7 +1073,6 @@ int ellpj( u, m, sn, cn, dn, ph )
*dn = 1.0 - 0.5*m*t*t;
return(0);
}
-
if( m >= 0.9999999999 )
{
ai = 0.25 * (1.0-m);
@@ -1177,15 +1087,12 @@ int ellpj( u, m, sn, cn, dn, ph )
*dn = phi + ai * (twon + u);
return(0);
}
-
-
/* A. G. M. scale */
a[0] = 1.0;
b = sqrt(1.0 - m);
c[0] = sqrt(m);
twon = 1.0;
i = 0;
-
while( fabs(c[i]/a[i]) > MACHEP )
{
if( i > 7 )
@@ -1201,9 +1108,7 @@ int ellpj( u, m, sn, cn, dn, ph )
b = t;
twon *= 2.0;
}
-
done:
-
/* backward recurrence */
phi = twon * a[i] * u;
do
@@ -1213,7 +1118,6 @@ int ellpj( u, m, sn, cn, dn, ph )
phi = (asin(t) + phi)/2.0;
}
while( --i );
-
*sn = sin(phi);
t = cos(phi);
*cn = t;
@@ -1276,11 +1180,7 @@ int ellpj( u, m, sn, cn, dn, ph )
* ellpk domain x<0, x>1 0.0
*
*/
-
/* ellpk.c */
-
-
-
static double P_ellpk[] =
{
1.37982864606273237150E-4,
@@ -1295,7 +1195,6 @@ static double P_ellpk[] =
9.65735902811690126535E-2,
1.38629436111989062502E0
};
-
static double Q_ellpk[] =
{
2.94078955048598507511E-5,
@@ -1311,22 +1210,18 @@ static double Q_ellpk[] =
4.99999999999999999821E-1
};
static double C1 = 1.3862943611198906188E0; /* log(4) */
-
extern double polevl ( double, double[], int );
extern double p1evl ( double, double[], int );
extern double log ( double );
extern double MACHEP, MAXNUM;
-
double ellpk(x)
double x;
{
-
if( (x < 0.0) || (x > 1.0) )
{
mtherr( "ellpk", DOMAIN );
return( 0.0 );
}
-
if( x > MACHEP )
{
return( polevl(x,P_ellpk,10) - log(x) * polevl(x,Q_ellpk,10) );
@@ -1395,12 +1290,8 @@ double ellpk(x)
* mconf.h
*
*/
-
-
#include <stdio.h>
-
int merror = 0;
-
/* Notice: the order of appearance of the following
* messages is bound to the error codes defined
* in mconf.h.
@@ -1414,29 +1305,23 @@ static char *ermsg[7] = {
"total loss of precision",
"partial loss of precision"
};
-
-
int mtherr( name, code )
char *name;
int code;
{
-
/* Display string passed by calling program,
* which is supposed to be the name of the
* function in which the error occurred:
*/
ellf_debugf ( "\n%s ", name );
-
/* Set global error message word */
merror = code;
-
/* Display error message defined
* by the code argument.
*/
if( (code <= 0) || (code >= 7) )
code = 0;
ellf_debugf ( "%s error\n", ermsg[code] );
-
/* Return to calling
* program
*/
@@ -1487,8 +1372,6 @@ int mtherr( name, code )
* program in microcode or assembly language.
*
*/
-
-
double polevl( x, coef, N )
double x;
double coef[];
@@ -1497,24 +1380,19 @@ double polevl( x, coef, N )
double ans;
int i;
double *p;
-
p = coef;
ans = *p++;
i = N;
-
do
ans = ans * x + *p++;
while( --i );
-
return( ans );
}
-
/* p1evl() */
/* N
* Evaluate polynomial when coefficient of x is 1.0.
* Otherwise same as polevl.
*/
-
double p1evl( x, coef, N )
double x;
double coef[];
@@ -1523,15 +1401,12 @@ double p1evl( x, coef, N )
double ans;
double *p;
int i;
-
p = coef;
ans = x + *p++;
i = N-1;
-
do
ans = ans * x + *p++;
while( --i );
-
return( ans );
}
/* === polevl.c - end === */
@@ -1540,20 +1415,12 @@ double p1evl( x, coef, N )
*
* Read ellf.doc before attempting to compile this program.
*/
-
-
#include <stdio.h>
#include <stdlib.h>
-
/* size of arrays: */
#define ARRSIZ 300
-
-
/* System configurations */
-
-
extern double PI, PIO2, MACHEP, MAXNUM;
-
static double aa[ARRSIZ];
static double pp[ARRSIZ];
static double y[ARRSIZ];
@@ -1626,13 +1493,10 @@ static int np = 0;
static int nz = 0;
static int type = 1;
static int kind = 1;
-
static char wkind[] =
{"Filter kind:\n1 Butterworth\n2 Chebyshev\n3 Elliptic\n"};
-
static char salut[] =
{"Filter shape:\n1 low pass\n2 band pass\n3 high pass\n4 band stop\n"};
-
enum {
BUTTERWORTH = 1,
CHEBYSHEV = 2,
@@ -1644,7 +1508,6 @@ enum {
HIGH_PASS = 3,
BAND_STOP = 4
};
-
extern double Cabs ( cmplx *z );
extern void Cadd ( cmplx *a, cmplx *b, cmplx *c );
extern void Cdiv ( cmplx *a, cmplx *b, cmplx *c );
@@ -1667,10 +1530,8 @@ int zplnb ( void );
int zplnc ( void );
int quadf ( double, double, int );
double response ( double, double );
-
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
-
static void
print_z_fraction_before_zplnc (void) /* must be called *before* zplnc() */
{
@@ -1679,7 +1540,6 @@ print_z_fraction_before_zplnc (void) /* must be called *before* zplnc() */
zgain = 1.0;
else
zgain = an / (pn * scale);
-
const char *kind_string = kind == 1 ? "BSE_IIR_FILTER_BUTTERWORTH" : kind == 2 ? "BSE_IIR_FILTER_CHEBYSHEV1" : "BSE_IIR_FILTER_ELLIPTIC";
const char *type_string = (type == 1 ? "BSE_IIR_FILTER_LOW_PASS" : type == 2 ? "BSE_IIR_FILTER_BAND_PASS" :
type == 3 ? "BSE_IIR_FILTER_HIGH_PASS" : "BSE_IIR_FILTER_BAND_STOP");
@@ -1723,7 +1583,6 @@ print_z_fraction_before_zplnc (void) /* must be called *before* zplnc() */
code_printf (" index++;\n");
code_printf (" }\n");
}
-
static inline unsigned int
quick_rand32 (void)
{
@@ -1731,7 +1590,6 @@ quick_rand32 (void)
accu = 1664525 * accu + 1013904223;
return accu + lrand48();
}
-
static inline double
quick_rand_range (double s, double e)
{
@@ -1744,7 +1602,6 @@ quick_rand_range (double s, double e)
while (rand_double1 > 1); // fix rounding errors
return s + rand_double1 * (e - s);
}
-
typedef struct {
int kind, type;
double order;
@@ -1754,9 +1611,7 @@ typedef struct {
double passband_edge2;
double stopband_edge_or_db;
} EllfInput;
-
static void main_ellf (const EllfInput *einput);
-
static void
generate_filters_brute_force (void)
{
@@ -1776,7 +1631,6 @@ generate_filters_brute_force (void)
max_order_index = filter_orders[oix] ? oix : max_order_index;
int rand_order_width = (32 - filter_orders[max_order_index]);
double pbe1;
-
#if 1
einput.kind = BUTTERWORTH;
for (oix = 0; oix < n_orders; oix++)
@@ -1798,7 +1652,6 @@ generate_filters_brute_force (void)
}
}
#endif
-
#if 1
einput.kind = CHEBYSHEV;
for (oix = 0; oix < n_orders; oix++)
@@ -1822,7 +1675,6 @@ generate_filters_brute_force (void)
}
}
#endif
-
#if 1
einput.kind = ELLIPTIC;
for (oix = 0; oix < n_orders; oix++)
@@ -1850,7 +1702,6 @@ generate_filters_brute_force (void)
}
#endif
}
-
int
main (int argc,
char *argv[])
@@ -1862,7 +1713,6 @@ main (int argc,
srand48 (tv.tv_usec + (tv.tv_sec << 16));
srand (lrand48());
}
-
if (argc >= 2 && strcmp (argv[1], "--test-code") == 0)
{
generate_filters_brute_force();
@@ -1871,7 +1721,6 @@ main (int argc,
main_ellf (NULL);
return 0;
}
-
/* Get a number from keyboard.
* Display previous value and keep it if user just hits <CR>.
*/
@@ -1879,16 +1728,13 @@ int
getnum (char *line, double *val, const double *einput)
{
char s[40];
-
ellf_debugf ( "%s = %.9E ? ", line, *val );
-
if (einput)
{
*val = *einput;
ellf_debugf ( "%.9E\n", *val );
return 0;
}
-
if (!fgets (s, sizeof (s), stdin))
exit (0);
if( s[0] != '\0' )
@@ -1898,16 +1744,12 @@ getnum (char *line, double *val, const double *einput)
}
return 0;
}
-
static void
main_ellf (const EllfInput *einput)
{
char str[80];
-
dbfac = 10.0/log(10.0);
-
top:
-
ellf_debugf ( "%s ? ", wkind ); /* ask for filter kind */
if (einput)
kind = einput->kind;
@@ -1920,7 +1762,6 @@ main_ellf (const EllfInput *einput)
ellf_debugf ( "%d\n", kind );
if( (kind <= 0) || (kind > 3) )
exit(0);
-
ellf_debugf ( "%s ? ", salut ); /* ask for filter type */
if (einput)
type = einput->type;
@@ -1933,7 +1774,6 @@ main_ellf (const EllfInput *einput)
ellf_debugf ( "%d\n", type );
if( (type <= 0) || (type > 4) )
exit(0);
-
getnum( "Order of filter", &rn, einput ? &einput->order : NULL); /* see below for getnum() */
n = rn;
if( n <= 0 )
@@ -1959,7 +1799,6 @@ main_ellf (const EllfInput *einput)
{
/* For Chebyshev filter, ripples go from 1.0 to 1/sqrt(1+eps^2) */
phi = exp( 0.5*dbr/dbfac );
-
if( (n & 1) == 0 )
scale = phi;
else
@@ -1974,16 +1813,13 @@ main_ellf (const EllfInput *einput)
eps = sqrt( eps - 1.0 );
}
}
-
getnum( "Sampling frequency", &fs, einput ? &einput->sampling_frequency : NULL);
if( fs <= 0.0 )
{
ellf_debugf ("? Need sampling-frequency > 0\n");
goto specerr;
}
-
fnyq = 0.5 * fs;
-
getnum( "Passband edge", &f2, einput ? &einput->passband_edge : NULL);
if( (f2 <= 0.0))
{
@@ -1995,7 +1831,6 @@ main_ellf (const EllfInput *einput)
ellf_debugf ("? Need passband-edge < nyquist frequency (%f)\n", fnyq);
goto specerr;
}
-
if( (type & 1) == 0 )
{
getnum( "Other passband edge", &f1, einput ? &einput->passband_edge2 : NULL);
@@ -2014,7 +1849,6 @@ main_ellf (const EllfInput *einput)
{
f1 = 0.0;
}
-
if( f2 < f1 )
{
a = f2;
@@ -2045,8 +1879,6 @@ main_ellf (const EllfInput *einput)
wc = c;
/*ellf_debugf( "cos( 1/2 (Whigh-Wlow) T ) = %.5e, wc = %.5e\n", cang, wc );*/
}
-
-
if( kind == 3 )
{ /* elliptic */
cgam = cos( (a+f1) * PI / fs ) / cang;
@@ -2089,13 +1921,11 @@ main_ellf (const EllfInput *einput)
goto specerr;
}
break;
-
case 2:
if( (f3 > f2) || (f3 < f1) )
break;
ellf_debugf ("? Need stopband_edge < passband_edge or stopband_edge > passband_edge2\n");
goto specerr;
-
case 3:
if( f3 >= f2 )
{
@@ -2103,7 +1933,6 @@ main_ellf (const EllfInput *einput)
goto specerr;
}
break;
-
case 4:
if( (f3 <= f1) || (f3 >= f2) )
{
@@ -2115,7 +1944,6 @@ main_ellf (const EllfInput *einput)
ang = f3 * PI / fs;
cang = cos(ang);
sang = sin(ang);
-
if( type & 1 )
{
wr = sang/(cang*c);
@@ -2127,7 +1955,6 @@ main_ellf (const EllfInput *einput)
cang = q;
wr = (cgam - cang)/(sang * c);
}
-
if( type >= 3 )
wr = 1.0/wr;
if( wr < 0.0 )
@@ -2135,10 +1962,8 @@ main_ellf (const EllfInput *einput)
y[0] = 1.0;
y[1] = wr;
cbp = wr;
-
if( type >= 3 )
y[1] = 1.0/y[1];
-
if( type & 1 )
{
for( i=1; i<=2; i++ )
@@ -2170,7 +1995,6 @@ main_ellf (const EllfInput *einput)
if( (2*n+2) > ARRSIZ )
goto toosml;
}
-
/* Transformation from low-pass to band-pass critical frequencies
*
* Center frequency
@@ -2184,7 +2008,6 @@ main_ellf (const EllfInput *einput)
* Wanalog = -----------------------------------
* sin( Wdigital T )
*/
-
if( kind == 2 )
{ /* Chebyshev */
a = PI * (a+f1) / fs ;
@@ -2200,17 +2023,13 @@ main_ellf (const EllfInput *einput)
cbp = (cgam - cos(a))/sin(a);
scale = 1.0;
}
-
ellf_debugf ("State: gain_scale=%.20g ripple_epsilon=%.20g nyquist_frequency=%.20g " // BSE info
"tan_angle_frequency=%.20g stopband_edge=%.20g wc=%.20g wr=%.20g cgam=%.20g\n",
scale, eps, fnyq,
c, f3, wc, wr, cgam);
-
spln(); /* find s plane poles and zeros */
-
if( ((type & 1) == 0) && ((4*n+2) > ARRSIZ) )
goto toosml;
-
zplna(); /* convert s plane to z plane */
zplnb();
ellf_debugf ("an=%.20g pn=%.20g scale=%.20g\n", an, pn, scale); // BSE info
@@ -2221,7 +2040,6 @@ main_ellf (const EllfInput *einput)
return;
else
goto top;
-
toosml:
ellf_debugf ( "Cannot continue, storage arrays too small\n" );
if (einput)
@@ -2229,10 +2047,8 @@ main_ellf (const EllfInput *einput)
else
goto top;
}
-
int lampln()
{
-
wc = 1.0;
k = wc/wr;
m = k * k;
@@ -2270,10 +2086,6 @@ int lampln()
u = u * Kk / (rn * Kk1); /* or, u = u * Kpk / Kpk1 */
return 0;
}
-
-
-
-
/* calculate s plane poles and zeros, normalized to wc = 1 */
int spln()
{
@@ -2446,12 +2258,6 @@ int spln()
}
return 0;
}
-
-
-
-
-
-
/* cay()
*
* Find parameter corresponding to given nome by expansion
@@ -2479,18 +2285,15 @@ double cay(q)
{
double a, b, p, r;
double t1, t2;
-
a = 1.0;
b = 1.0;
r = 1.0;
p = q;
-
do
{
r *= p;
a += 2.0 * r;
t1 = fabs( r/a );
-
r *= p;
b += r;
p *= q;
@@ -2499,41 +2302,30 @@ double cay(q)
t1 = t2;
}
while( t1 > MACHEP );
-
a = b/a;
a = 4.0 * sqrt(q) * a * a; /* see above formulas, solved for m */
return(a);
}
-
-
-
-
/* zpln.c
* Program to convert s plane poles and zeros to the z plane.
*/
-
extern cmplx cone;
-
int zplna()
{
cmplx r, cnum, cden, cwc, ca, cb, b4ac;
double C;
-
if( kind == 3 )
C = c;
else
C = wc;
-
for( i=0; i<ARRSIZ; i++ )
{
z[i].r = 0.0;
z[i].i = 0.0;
}
-
nc = np;
jt = -1;
ii = -1;
-
for( icnt=0; icnt<2; icnt++ )
{
/* The maps from s plane to z plane */
@@ -2543,7 +2335,6 @@ int zplna()
ii = ir + 1;
r.r = zs[ir];
r.i = zs[ii];
-
switch( type )
{
case 1:
@@ -2570,7 +2361,6 @@ int zplna()
z[jt].i = -z[jt-1 ].i;
}
break;
-
case 2:
case 4:
/* Substitute s - r => s/wc - r
@@ -2631,7 +2421,6 @@ int zplna()
} /* end switch */
}
while( --nc > 0 );
-
if( icnt == 0 )
{
zord = jt+1;
@@ -2647,17 +2436,11 @@ int zplna()
} /* end for() loop */
return 0;
}
-
-
-
-
int zplnb()
{
cmplx lin[2];
-
lin[1].r = 1.0;
lin[1].i = 0.0;
-
if( kind != 3 )
{ /* Butterworth or Chebyshev */
/* generate the remaining zeros */
@@ -2695,7 +2478,6 @@ int zplnb()
}
}
ellf_debugf ( "order = %d\n", zord );
-
/* Expand the poles and zeros into numerator and
* denominator polynomials
*/
@@ -2733,10 +2515,8 @@ int zplnb()
{
case 3:
a = -1.0;
-
case 1:
case 4:
-
pn = 1.0;
an = 1.0;
for( j=1; j<=zord; j++ )
@@ -2745,7 +2525,6 @@ int zplnb()
an = a * an + aa[j];
}
break;
-
case 2:
gam = PI/2.0 - asin( cgam ); /* = acos( cgam ) */
mh = zord/2;
@@ -2770,23 +2549,19 @@ int zplnb()
}
return 0;
}
-
int zplnc()
{
-
gain = an/(pn*scale);
if( (kind != 3) && (pn == 0) )
gain = 1.0;
ellf_printf( "constant gain factor %23.13E\n", gain );
for( j=0; j<=zord; j++ )
pp[j] = gain * pp[j];
-
ellf_printf( "z plane Denominator Numerator\n" );
for( j=0; j<=zord; j++ )
{
ellf_printf( "%2d %17.9E %17.9E\n", j, aa[j], pp[j] );
}
-
/* I /think/ at this point the polynomial is factorized in 2nd order filters,
* so that it can be implemented without stability problems -- stw
*/
@@ -2811,10 +2586,6 @@ int zplnc()
}
return 0;
}
-
-
-
-
/* display quadratic factors
*/
int quadf( x, y, pzflg )
@@ -2822,7 +2593,6 @@ int quadf( x, y, pzflg )
int pzflg; /* 1 if poles, 0 if zeros */
{
double a, b, r, f, g, g0;
-
if( y > 1.0e-16 )
{
a = -2.0 * x;
@@ -2855,7 +2625,6 @@ int quadf( x, y, pzflg )
g = 1.0 - a;
g0 = 1.0 + a;
}
-
if( pzflg )
{
if( g != 0.0 )
@@ -2870,16 +2639,12 @@ int quadf( x, y, pzflg )
ellf_printf( "f0 %16.8E gain %12.4E DC gain %12.4E\n\n", f, g, g0 );
return 0;
}
-
-
-
/* Print table of filter frequency response
*/
void
print_filter_table (void)
{
double f, limit = 0.05 * fnyq * 21;
-
for (f=0; f < limit; f += limit / 21.)
{
double r = response( f, gain );
@@ -2891,8 +2656,6 @@ print_filter_table (void)
// f = f + 0.05 * fnyq;
}
}
-
-
/* Calculate frequency response at f Hz
* mulitplied by amp
*/
@@ -2902,12 +2665,10 @@ double response( f, amp )
cmplx x, num, den, w;
double u;
int j;
-
/* exp( j omega T ) */
u = 2.0 * PI * f /fs;
x.r = cos(u);
x.i = sin(u);
-
num.r = 1.0;
num.i = 0.0;
den.r = 1.0;
@@ -2925,7 +2686,5 @@ double response( f, amp )
u = Cabs( &w );
return(u);
}
-
/* === ellf.c - end === */
-
/* compile with: gcc -Wall -O2 -g -ffloat-store bse-ellf.c -lm -o bse-ellf */
diff --git a/r+d-files/transpose_freq.scm b/r+d-files/transpose_freq.scm
index 3ed0e68..312bb5b 100644
--- a/r+d-files/transpose_freq.scm
+++ b/r+d-files/transpose_freq.scm
@@ -15,18 +15,15 @@
;; in contract, strict liability, or tort (including negligence or
;; otherwise) arising in any way out of the use of this software, even
;; if advised of the possibility of such damage.
-
;;
;; usage: bsescm -s transpose_freq.scm <freq> <semitones> <fine-tune>
;;
;; mini script to calculate the effect of 12-TET transposing a frequency
;;
-
(define (transpose-freq freq semitones fine-tune)
(let*
((total-transpose-cent (+ (* 100 (string->number semitones)) (string->number fine-tune)))
(new-freq (* (expt 2 (/ total-transpose-cent 1200)) (string->number freq))))
(display new-freq)
(newline)))
-
(apply transpose-freq (cdr (command-line)))
diff --git a/sfi/gbsearcharray.hh b/sfi/gbsearcharray.hh
index 84b3601..1144f03 100644
--- a/sfi/gbsearcharray.hh
+++ b/sfi/gbsearcharray.hh
@@ -1,22 +1,15 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
#ifndef __G_BSEARCH_ARRAY_H__
#define __G_BSEARCH_ARRAY_H__
-
#include <sfi/glib-extra.hh>
#include <string.h>
-
-
G_BEGIN_DECLS /* c++ guards */
-
/* this implementation is intended to be usable in third-party code
* simply by pasting the contents of this file. as such, the
* implementation needs to be self-contained within this file.
*/
-
/* convenience macro to avoid signed overflow for value comparisions */
#define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) > (v2) ? +1 : (v1) == (v2) ? 0 : -1)
-
-
/* --- typedefs --- */
typedef gint (*GBSearchCompareFunc) (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2);
@@ -25,8 +18,6 @@ typedef enum
G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0, /* align memory to power2 sizes */
G_BSEARCH_ARRAY_AUTO_SHRINK = 1 << 1 /* shrink array upon removal */
} GBSearchArrayFlags;
-
-
/* --- structures --- */
typedef struct
{
@@ -42,8 +33,6 @@ typedef union
glong alignment_dummy2;
gdouble alignment_dummy3;
} GBSearchArray;
-
-
/* --- public API --- */
static inline GBSearchArray* g_bsearch_array_create (const GBSearchConfig *bconfig);
static inline gpointer g_bsearch_array_get_nth (GBSearchArray *barray,
@@ -75,13 +64,11 @@ static inline GBSearchArray* g_bsearch_array_replace (GBSearchArray
static inline void g_bsearch_array_free (GBSearchArray *barray,
const GBSearchConfig *bconfig);
#define g_bsearch_array_get_n_nodes(barray) (((GBSearchArray*) (barray))->n_nodes)
-
/* g_bsearch_array_lookup():
* return NULL or exact match node
*/
#define g_bsearch_array_lookup(barray, bconfig, key_node) \
g_bsearch_array_lookup_fuzzy ((barray), (bconfig), (key_node), 0)
-
/* g_bsearch_array_lookup_sibling():
* return NULL for barray->n_nodes==0, otherwise return the
* exact match node, or, if there's no such node, return the
@@ -90,7 +77,6 @@ static inline void g_bsearch_array_free (GBSearchArray
*/
#define g_bsearch_array_lookup_sibling(barray, bconfig, key_node) \
g_bsearch_array_lookup_fuzzy ((barray), (bconfig), (key_node), 1)
-
/* g_bsearch_array_lookup_insertion():
* return NULL for barray->n_nodes==0 or exact match, otherwise
* return the node where key_node should be inserted (may be one
@@ -98,8 +84,6 @@ static inline void g_bsearch_array_free (GBSearchArray
*/
#define g_bsearch_array_lookup_insertion(barray, bconfig, key_node) \
g_bsearch_array_lookup_fuzzy ((barray), (bconfig), (key_node), 2)
-
-
/* --- implementation --- */
/* helper macro to cut down realloc()s */
#ifdef DISABLE_MEM_POOLS
@@ -113,15 +97,12 @@ g_bsearch_array_create (const GBSearchConfig *bconfig)
{
GBSearchArray *barray;
guint size;
-
g_return_val_if_fail (bconfig != NULL, NULL);
-
size = sizeof (GBSearchArray) + bconfig->sizeof_node;
if (bconfig->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
size = G_BSEARCH_UPPER_POWER2 (size);
barray = (GBSearchArray *) g_realloc (NULL, size);
memset (barray, 0, sizeof (GBSearchArray));
-
return barray;
}
static inline gpointer
@@ -140,11 +121,9 @@ g_bsearch_array_lookup_fuzzy (GBSearchArray *barray,
guint n_nodes = barray->n_nodes, offs = 0;
guint sizeof_node = bconfig->sizeof_node;
gint cmp = 0;
-
while (offs < n_nodes)
{
guint i = (offs + n_nodes) >> 1;
-
check = nodes + i * sizeof_node;
cmp = cmp_nodes (key_node, check);
if (cmp == 0)
@@ -154,7 +133,6 @@ g_bsearch_array_lookup_fuzzy (GBSearchArray *barray,
else /* (cmp > 0) */
offs = i + 1;
}
-
/* check is last mismatch, cmp > 0 indicates greater key */
return G_LIKELY (!sibling_or_after) ? NULL : (sibling_or_after > 1 && cmp > 0) ? check + sizeof_node : check;
}
@@ -171,11 +149,8 @@ g_bsearch_array_get_index (GBSearchArray *barray,
gconstpointer node_in_array)
{
guint distance = ((guint8*) node_in_array) - G_BSEARCH_ARRAY_NODES (barray);
-
g_return_val_if_fail (node_in_array != NULL, barray->n_nodes);
-
distance /= bconfig->sizeof_node;
-
return MIN (distance, barray->n_nodes + 1); /* may return one after end */
}
static inline GBSearchArray*
@@ -186,9 +161,7 @@ g_bsearch_array_grow (GBSearchArray *barray,
guint old_size = barray->n_nodes * bconfig->sizeof_node;
guint new_size = old_size + bconfig->sizeof_node;
guint8 *node;
-
g_return_val_if_fail (index <= barray->n_nodes, NULL);
-
if (G_UNLIKELY (bconfig->flags & G_BSEARCH_ARRAY_ALIGN_POWER2))
{
new_size = G_BSEARCH_UPPER_POWER2 (sizeof (GBSearchArray) + new_size);
@@ -209,7 +182,6 @@ g_bsearch_array_insert (GBSearchArray *barray,
gconstpointer key_node)
{
guint8 *node;
-
if (G_UNLIKELY (!barray->n_nodes))
{
barray = g_bsearch_array_grow (barray, bconfig, 0);
@@ -221,7 +193,6 @@ g_bsearch_array_insert (GBSearchArray *barray,
if (G_LIKELY (node))
{
guint index = g_bsearch_array_get_index (barray, bconfig, node);
-
/* grow and insert */
barray = g_bsearch_array_grow (barray, bconfig, index);
node = G_BSEARCH_ARRAY_NODES (barray) + index * bconfig->sizeof_node;
@@ -250,9 +221,7 @@ g_bsearch_array_remove (GBSearchArray *barray,
guint index)
{
guint8 *node;
-
g_return_val_if_fail (index < barray->n_nodes, NULL);
-
barray->n_nodes -= 1;
node = G_BSEARCH_ARRAY_NODES (barray) + index * bconfig->sizeof_node;
g_memmove (node, node + bconfig->sizeof_node, (barray->n_nodes - index) * bconfig->sizeof_node);
@@ -260,7 +229,6 @@ g_bsearch_array_remove (GBSearchArray *barray,
{
guint new_size = barray->n_nodes * bconfig->sizeof_node;
guint old_size = new_size + bconfig->sizeof_node;
-
if (G_UNLIKELY (bconfig->flags & G_BSEARCH_ARRAY_ALIGN_POWER2))
{
new_size = G_BSEARCH_UPPER_POWER2 (sizeof (GBSearchArray) + new_size);
@@ -285,10 +253,7 @@ g_bsearch_array_free (GBSearchArray *barray,
const GBSearchConfig *bconfig)
{
g_return_if_fail (barray != NULL);
-
g_free (barray);
}
-
G_END_DECLS /* c++ guards */
-
#endif /* !__G_BSEARCH_ARRAY_H__ */
diff --git a/sfi/glib-extra.cc b/sfi/glib-extra.cc
index edd5133..cc691c6 100644
--- a/sfi/glib-extra.cc
+++ b/sfi/glib-extra.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <string.h>
#include "glib-extra.hh"
-
-
void
g_object_disconnect_any (gpointer object,
gpointer function,
@@ -19,8 +17,6 @@ g_object_disconnect_any (gpointer object,
0, 0, 0,
function, data);
}
-
-
/* --- string functions --- */
const gchar*
g_printf_find_localised_directive (const gchar *format)
@@ -47,7 +43,6 @@ g_printf_find_localised_directive (const gchar *format)
}
return NULL;
}
-
gchar**
g_straddv (gchar **str_array,
const gchar *new_str)
@@ -63,7 +58,6 @@ g_straddv (gchar **str_array,
else
{
guint i = 0;
-
while (str_array[i])
i++;
str_array = g_renew (gchar*, str_array, i + 1 + 1);
@@ -74,28 +68,22 @@ g_straddv (gchar **str_array,
}
return str_array;
}
-
guint
g_strlenv (gchar **str_array)
{
guint i = 0;
-
if (str_array)
while (str_array[i])
i++;
-
return i;
}
-
gchar**
g_strslistv (GSList *slist)
{
gchar **str_array;
guint i;
-
if (!slist)
return NULL;
-
i = g_slist_length (slist);
str_array = g_new (gchar*, i + 1);
i = 0;
@@ -105,10 +93,8 @@ g_strslistv (GSList *slist)
slist = slist->next;
}
str_array[i] = NULL;
-
return str_array;
}
-
gchar*
g_strdup_stripped (const gchar *string)
{
@@ -116,7 +102,6 @@ g_strdup_stripped (const gchar *string)
{
const gchar *s = string;
guint l;
-
while (*s == ' ')
s++;
l = strlen (s);
@@ -126,7 +111,6 @@ g_strdup_stripped (const gchar *string)
}
return NULL;
}
-
gchar*
g_strdup_rstrip (const gchar *string)
{
@@ -139,7 +123,6 @@ g_strdup_rstrip (const gchar *string)
}
return NULL;
}
-
gchar*
g_strdup_lstrip (const gchar *string)
{
@@ -151,21 +134,18 @@ g_strdup_lstrip (const gchar *string)
}
return NULL;
}
-
#if !GLIB_CHECK_VERSION (2, 9, 0)
const gchar*
g_intern_string (const gchar *string)
{
return string ? g_quark_to_string (g_quark_from_string (string)) : NULL;
}
-
const gchar*
g_intern_static_string (const gchar *string)
{
return string ? g_quark_to_string (g_quark_from_static_string (string)) : NULL;
}
#endif
-
static gchar*
delim_concat_varargs (const gchar *first_string,
gchar delim,
@@ -173,10 +153,8 @@ delim_concat_varargs (const gchar *first_string,
{
GString *gstring;
gchar *s;
-
if (!first_string)
return NULL;
-
gstring = g_string_new (first_string);
s = va_arg (var_args, gchar*);
while (s)
@@ -190,10 +168,8 @@ delim_concat_varargs (const gchar *first_string,
}
s = va_arg (var_args, gchar*);
}
-
return g_string_free (gstring, FALSE);
}
-
const gchar*
g_intern_strconcat (const gchar *first_string,
...)
@@ -211,7 +187,6 @@ g_intern_strconcat (const gchar *first_string,
}
return c;
}
-
const gchar*
g_intern_printf (const gchar *format,
...)
@@ -230,7 +205,6 @@ g_intern_printf (const gchar *format,
else
return NULL;
}
-
gchar*
g_path_concat (const gchar *first_path,
...)
@@ -242,7 +216,6 @@ g_path_concat (const gchar *first_path,
va_end (args);
return s;
}
-
GString*
g_string_prefix_lines (GString *gstring,
const gchar *pstr)
@@ -261,8 +234,6 @@ g_string_prefix_lines (GString *gstring,
}
return gstring;
}
-
-
/* --- string options --- */
gchar*
g_option_concat (const gchar *first_option,
@@ -275,19 +246,15 @@ g_option_concat (const gchar *first_option,
va_end (args);
return s;
}
-
static const gchar*
g_option_find_value (const gchar *option_string,
const gchar *option)
{
const gchar *p, *match = NULL;
gint l = strlen (option);
-
g_return_val_if_fail (l > 0, NULL);
-
if (!option_string)
return NULL; /* option not found */
-
/* try first match */
p = strstr (option_string, option);
if (p &&
@@ -307,16 +274,13 @@ g_option_find_value (const gchar *option_string,
}
return match ? match + l : NULL;
}
-
gchar*
g_option_get (const gchar *option_string,
const gchar *option)
{
const gchar *value = NULL;
-
if (option && option[0])
value = g_option_find_value (option_string, option);
-
if (!value)
return NULL; /* option not present */
else switch (value[0])
@@ -333,16 +297,13 @@ g_option_get (const gchar *option_string,
default: return NULL; /* anything else, undefined */
}
}
-
gboolean
g_option_check (const gchar *option_string,
const gchar *option)
{
const gchar *value = NULL;
-
if (option && option[0])
value = g_option_find_value (option_string, option);
-
if (!value)
return FALSE; /* option not present */
else switch (value[0])
@@ -367,8 +328,6 @@ g_option_check (const gchar *option_string,
default: return FALSE; /* anything else, undefined */
}
}
-
-
/* --- GParamSpec options --- */
static GQuark quark_pspec_options = 0;
static guint
@@ -390,7 +349,6 @@ pspec_flags (const gchar *poptions)
}
return flags;
}
-
void
g_param_spec_set_options (GParamSpec *pspec,
const gchar *options)
@@ -403,7 +361,6 @@ g_param_spec_set_options (GParamSpec *pspec,
/* pspec->flags &= ~G_PARAM_MASK; */
pspec->flags = GParamFlags (pspec->flags | pspec_flags (options));
}
-
gboolean
g_param_spec_check_option (GParamSpec *pspec,
const gchar *option)
@@ -413,7 +370,6 @@ g_param_spec_check_option (GParamSpec *pspec,
poptions = g_param_spec_get_options (pspec);
return g_option_check (poptions, option);
}
-
void
g_param_spec_add_option (GParamSpec *pspec,
const gchar *option,
@@ -445,7 +401,6 @@ g_param_spec_add_option (GParamSpec *pspec,
g_free (s);
}
}
-
gboolean
g_param_spec_provides_options (GParamSpec *pspec,
const gchar *options)
@@ -472,7 +427,6 @@ g_param_spec_provides_options (GParamSpec *pspec,
else
return g_param_spec_check_option (pspec, options);
}
-
const gchar*
g_param_spec_get_options (GParamSpec *pspec)
{
@@ -481,10 +435,8 @@ g_param_spec_get_options (GParamSpec *pspec)
options = (const char*) g_param_spec_get_qdata (pspec, quark_pspec_options);
return options ? options : "";
}
-
static GQuark quark_pspec_istepping = 0;
static GQuark quark_pspec_istepping64 = 0;
-
void
g_param_spec_set_istepping (GParamSpec *pspec,
guint64 stepping)
@@ -508,7 +460,6 @@ g_param_spec_set_istepping (GParamSpec *pspec,
g_param_spec_set_qdata (pspec, quark_pspec_istepping, (void*) size_t (stepping));
}
}
-
guint64
g_param_spec_get_istepping (GParamSpec *pspec)
{
@@ -522,9 +473,7 @@ g_param_spec_get_istepping (GParamSpec *pspec)
}
return stepping;
}
-
static GQuark quark_pspec_fstepping = 0;
-
void
g_param_spec_set_fstepping (GParamSpec *pspec,
gdouble stepping)
@@ -541,7 +490,6 @@ g_param_spec_set_fstepping (GParamSpec *pspec,
else
g_param_spec_set_qdata (pspec, quark_pspec_fstepping, NULL);
}
-
gdouble
g_param_spec_get_fstepping (GParamSpec *pspec)
{
@@ -550,15 +498,12 @@ g_param_spec_get_fstepping (GParamSpec *pspec)
fstepping = (double*) g_param_spec_get_qdata (pspec, quark_pspec_fstepping);
return fstepping ? *fstepping : 0;
}
-
typedef struct {
gdouble center;
gdouble base;
gdouble n_steps;
} LogScale;
-
static GQuark quark_pspec_log_scale = 0;
-
void
g_param_spec_set_log_scale (GParamSpec *pspec,
gdouble center,
@@ -580,7 +525,6 @@ g_param_spec_set_log_scale (GParamSpec *pspec,
else
g_param_spec_set_qdata (pspec, quark_pspec_log_scale, NULL);
}
-
gboolean
g_param_spec_get_log_scale (GParamSpec *pspec,
gdouble *center,
@@ -602,23 +546,18 @@ g_param_spec_get_log_scale (GParamSpec *pspec,
}
return FALSE;
}
-
-
/* --- list extensions --- */
gpointer
g_slist_pop_head (GSList **slist_p)
{
gpointer data;
-
g_return_val_if_fail (slist_p != NULL, NULL);
-
if (!*slist_p)
return NULL;
data = (*slist_p)->data;
*slist_p = g_slist_delete_link (*slist_p, *slist_p);
return data;
}
-
GSList*
g_slist_append_uniq (GSList *slist,
gpointer data)
@@ -632,21 +571,17 @@ g_slist_append_uniq (GSList *slist,
last->next = g_slist_append (NULL, data);
return slist;
}
-
gpointer
g_list_pop_head (GList **list_p)
{
gpointer data;
-
g_return_val_if_fail (list_p != NULL, NULL);
-
if (!*list_p)
return NULL;
data = (*list_p)->data;
*list_p = g_list_delete_link (*list_p, *list_p);
return data;
}
-
void
g_slist_free_deep (GSList *slist,
GDestroyNotify data_destroy)
@@ -658,7 +593,6 @@ g_slist_free_deep (GSList *slist,
data = g_slist_pop_head (&slist);
}
}
-
void
g_list_free_deep (GList *list,
GDestroyNotify data_destroy)
@@ -670,21 +604,17 @@ g_list_free_deep (GList *list,
data = g_list_pop_head (&list);
}
}
-
-
/* --- name conversions --- */
static inline gchar
check_lower (gchar c)
{
return c >= 'a' && c <= 'z';
}
-
static inline gchar
check_upper (gchar c)
{
return c >= 'A' && c <= 'Z';
}
-
static inline gchar
char_convert (gchar c,
gchar fallback,
@@ -708,7 +638,6 @@ char_convert (gchar c,
}
return fallback;
}
-
static gchar*
type_name_to_cname (const gchar *type_name,
const gchar *insert,
@@ -718,9 +647,7 @@ type_name_to_cname (const gchar *type_name,
const gchar *s;
gchar *result, *p;
guint was_upper, ilen;
-
s = type_name;
-
/* special casing for GLib types */
if (strcmp (s, "GString") == 0)
s = "GGString"; /* G_TYPE_GSTRING */
@@ -751,11 +678,9 @@ type_name_to_cname (const gchar *type_name,
break;
}
}
-
ilen = strlen (insert);
result = g_new (gchar, strlen (s) * 2 + ilen + 1);
p = result;
-
*p++ = char_convert (*s++, fallback, want_upper);
while (*s && !check_upper (*s))
*p++ = char_convert (*s++, fallback, want_upper);
@@ -776,43 +701,32 @@ type_name_to_cname (const gchar *type_name,
s++;
}
*p++ = 0;
-
return result;
}
-
gchar*
g_type_name_to_cname (const gchar *type_name)
{
g_return_val_if_fail (type_name != NULL, NULL);
-
return type_name_to_cname (type_name, "", '_', FALSE);
}
-
gchar*
g_type_name_to_sname (const gchar *type_name)
{
g_return_val_if_fail (type_name != NULL, NULL);
-
return type_name_to_cname (type_name, "", '-', FALSE);
}
-
gchar*
g_type_name_to_cupper (const gchar *type_name)
{
g_return_val_if_fail (type_name != NULL, NULL);
-
return type_name_to_cname (type_name, "", '_', TRUE);
}
-
gchar*
g_type_name_to_type_macro (const gchar *type_name)
{
g_return_val_if_fail (type_name != NULL, NULL);
-
return type_name_to_cname (type_name, "_TYPE", '_', TRUE);
}
-
-
/* --- simple main loop source --- */
typedef struct {
GSource source;
@@ -822,7 +736,6 @@ typedef struct {
gpointer data;
GDestroyNotify destroy;
} SimpleSource;
-
static gboolean
simple_source_prepare (GSource *source,
gint *timeout_p)
@@ -831,7 +744,6 @@ simple_source_prepare (GSource *source,
ssource->last_pending = ssource->pending (ssource->data, timeout_p);
return ssource->last_pending;
}
-
static gboolean
simple_source_check (GSource *source)
{
@@ -841,7 +753,6 @@ simple_source_check (GSource *source)
ssource->last_pending = ssource->pending (ssource->data, &timeout);
return ssource->last_pending;
}
-
static gboolean
simple_source_dispatch (GSource *source,
GSourceFunc callback,
@@ -851,12 +762,10 @@ simple_source_dispatch (GSource *source,
ssource->dispatch (ssource->data);
return TRUE;
}
-
static void
simple_source_finalize (GSource *source)
{
SimpleSource *ssource = (SimpleSource*) source;
-
/* this finalize handler may be run due to g_source_remove() called
* from some dispatch() implementation, possibly causing reentrancy
* problems (mutexes etc.). however, there's hardly anything we could
@@ -865,7 +774,6 @@ simple_source_finalize (GSource *source)
if (ssource->destroy)
ssource->destroy (ssource->data);
}
-
GSource*
g_source_simple (gint priority,
GSourcePending pending,
@@ -885,10 +793,8 @@ g_source_simple (gint priority,
GSource *source;
va_list var_args;
GPollFD *pfd;
-
g_return_val_if_fail (pending != NULL, NULL);
g_return_val_if_fail (dispatch != NULL, NULL);
-
source = g_source_new (&simple_source_funcs, sizeof (SimpleSource));
g_source_set_priority (source, priority);
ssource = (SimpleSource*) source;
@@ -907,13 +813,11 @@ g_source_simple (gint priority,
va_end (var_args);
return source;
}
-
/* --- predicate idle --- */
typedef struct {
GSource source;
GSourceFunc predicate;
} PredicateIdle;
-
static gboolean
predicate_idle_prepare (GSource *source,
gint *timeout)
@@ -924,7 +828,6 @@ predicate_idle_prepare (GSource *source,
else
return FALSE;
}
-
static gboolean
predicate_idle_check (GSource *source)
{
@@ -934,7 +837,6 @@ predicate_idle_check (GSource *source)
else
return FALSE;
}
-
static gboolean
predicate_idle_dispatch (GSource *source,
GSourceFunc callback,
@@ -945,7 +847,6 @@ predicate_idle_dispatch (GSource *source,
else
return FALSE;
}
-
guint
g_predicate_idle_add_full (gint priority,
GSourceFunc predicate,
@@ -963,7 +864,6 @@ g_predicate_idle_add_full (gint priority,
g_source_unref (source);
return id;
}
-
guint
g_predicate_idle_add (GSourceFunc predicate,
GSourceFunc function,
@@ -971,7 +871,6 @@ g_predicate_idle_add (GSourceFunc predicate,
{
return g_predicate_idle_add_full (G_PRIORITY_DEFAULT_IDLE, predicate, function, data, NULL);
}
-
/* --- GLib main loop reentrant signal queue --- */
#if 0
typedef struct _GUSignalData GUSignalData;
@@ -981,7 +880,6 @@ struct _GUSignalData
guint8 shift;
GUSignalFunc callback;
};
-
static gboolean g_usignal_prepare (gpointer source_data,
GTimeVal *current_time,
gint *timeout,
@@ -992,7 +890,6 @@ static gboolean g_usignal_check (gpointer source_data,
static gboolean g_usignal_dispatch (gpointer source_data,
GTimeVal *dispatch_time,
gpointer user_data);
-
static GSourceFuncs usignal_funcs = {
g_usignal_prepare,
g_usignal_check,
@@ -1000,7 +897,6 @@ static GSourceFuncs usignal_funcs = {
g_free
};
static guint32 usignals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-
static gboolean
g_usignal_prepare (gpointer source_data,
GTimeVal *current_time,
@@ -1008,32 +904,25 @@ g_usignal_prepare (gpointer source_data,
gpointer user_data)
{
GUSignalData *usignal_data = source_data;
-
return usignals_notified[usignal_data->index] & (1 << usignal_data->shift);
}
-
static gboolean
g_usignal_check (gpointer source_data,
GTimeVal *current_time,
gpointer user_data)
{
GUSignalData *usignal_data = source_data;
-
return usignals_notified[usignal_data->index] & (1 << usignal_data->shift);
}
-
static gboolean
g_usignal_dispatch (gpointer source_data,
GTimeVal *dispatch_time,
gpointer user_data)
{
GUSignalData *usignal_data = source_data;
-
usignals_notified[usignal_data->index] &= ~(1 << usignal_data->shift);
-
return usignal_data->callback (-128 + usignal_data->index * 32 + usignal_data->shift, user_data);
}
-
guint
g_usignal_add (gint8 usignal,
GUSignalFunc function,
@@ -1041,7 +930,6 @@ g_usignal_add (gint8 usignal,
{
return g_usignal_add_full (G_PRIORITY_DEFAULT, usignal, function, data, NULL);
}
-
guint
g_usignal_add_full (gint priority,
gint8 usignal,
@@ -1051,30 +939,23 @@ g_usignal_add_full (gint priority,
{
GUSignalData *usignal_data;
guint s = 128 + usignal;
-
g_return_val_if_fail (function != NULL, 0);
-
usignal_data = g_new (GUSignalData, 1);
usignal_data->index = s / 32;
usignal_data->shift = s % 32;
usignal_data->callback = function;
-
return g_source_add (priority, TRUE, &usignal_funcs, usignal_data, data, destroy);
}
-
void
g_usignal_notify (gint8 usignal)
{
guint index, shift;
guint s = 128 + usignal;
-
index = s / 32;
shift = s % 32;
-
usignals_notified[index] |= 1 << shift;
}
#endif
-
GScanner*
g_scanner_new64 (const GScannerConfig *config_templ)
{
diff --git a/sfi/glib-extra.hh b/sfi/glib-extra.hh
index 7bae16d..aa3ed37 100644
--- a/sfi/glib-extra.hh
+++ b/sfi/glib-extra.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_GLIB_EXTRA_H__
#define __SFI_GLIB_EXTRA_H__
-
#include <glib.h>
#include <glib-object.h>
-
G_BEGIN_DECLS
-
#if (GLIB_SIZEOF_LONG > 4)
#define G_HASH_LONG(l) ((l) + ((l) >> 32))
#else
@@ -27,8 +24,6 @@ G_BEGIN_DECLS
# define G_STRFUNC ((const char*) ("???"))
# endif
#endif
-
-
/* --- provide (historic) aliases --- */
#define g_string_printfa g_string_append_printf
#define g_string_aprintf g_string_append_printf
@@ -38,8 +33,6 @@ G_BEGIN_DECLS
#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \
g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \
} G_STMT_END
-
-
/* --- abandon typesafety for some frequently used functions --- */
#ifndef __cplusplus
#define g_object_notify(o,s) g_object_notify ((gpointer) o, s)
@@ -55,7 +48,6 @@ G_BEGIN_DECLS
void g_object_disconnect_any (gpointer object,
gpointer function,
gpointer data); /* workaorund for g_object_disconnect() */
-
/* --- string functions --- */
const gchar* g_printf_find_localised_directive (const gchar *format);
gchar** g_straddv (gchar **str_array,
@@ -65,23 +57,18 @@ guint g_strlenv (gchar **str_array);
gchar* g_strdup_stripped (const gchar *string);
gchar* g_strdup_rstrip (const gchar *string);
gchar* g_strdup_lstrip (const gchar *string);
-
#if !GLIB_CHECK_VERSION (2, 9, 0)
const gchar* g_intern_string (const gchar *string);
const gchar* g_intern_static_string (const gchar *string);
#endif
-
const gchar* g_intern_strconcat (const gchar *first_string,
...) G_GNUC_NULL_TERMINATED;
const gchar* g_intern_printf (const gchar *format,
...) G_GNUC_PRINTF (1,2);
-
gchar* g_path_concat (const gchar *first_path,
...) G_GNUC_NULL_TERMINATED;
GString* g_string_prefix_lines (GString *gstring,
const gchar *pstr);
-
-
/* --- string options --- */
gchar* g_option_concat (const gchar *first_option,
...) G_GNUC_NULL_TERMINATED;
@@ -89,8 +76,6 @@ gboolean g_option_check (const gchar *option_string,
const gchar *option);
gchar* g_option_get (const gchar *option_string,
const gchar *option);
-
-
/* --- GParamSpec extensions --- */
void g_param_spec_set_options (GParamSpec *pspec,
const gchar *options);
@@ -116,8 +101,6 @@ gboolean g_param_spec_get_log_scale (GParamSpec *pspec,
gdouble *center,
gdouble *base,
gdouble *n_steps);
-
-
/* --- list extensions --- */
gpointer g_slist_pop_head (GSList **slist_p);
gpointer g_list_pop_head (GList **list_p);
@@ -127,15 +110,11 @@ void g_slist_free_deep (GSList *slist,
GDestroyNotify data_destroy);
void g_list_free_deep (GList *list,
GDestroyNotify data_destroy);
-
-
/* --- name conversions --- */
gchar* g_type_name_to_cname (const gchar *type_name);
gchar* g_type_name_to_sname (const gchar *type_name);
gchar* g_type_name_to_cupper (const gchar *type_name);
gchar* g_type_name_to_type_macro (const gchar *type_name);
-
-
/* --- simple main loop source --- */
typedef gboolean (*GSourcePending) (gpointer data,
gint *timeout);
@@ -147,14 +126,11 @@ GSource* g_source_simple (gint priority,
GDestroyNotify destroy,
GPollFD *first_pfd,
...);
-
-
/* --- bit matrix --- */
typedef struct {
guint32 width, height;
guint32 bits[1]; /* flexible array */
} GBitMatrix;
-
static inline GBitMatrix*
g_bit_matrix_new (guint width,
guint height)
@@ -164,7 +140,6 @@ g_bit_matrix_new (guint width,
matrix->height = height;
return matrix;
}
-
static inline void
g_bit_matrix_change (GBitMatrix *matrix,
guint x,
@@ -181,10 +156,8 @@ g_bit_matrix_change (GBitMatrix *matrix,
else
matrix->bits[index] &= ~(1 << shift);
}
-
#define g_bit_matrix_set(matrix,x,y) g_bit_matrix_change (matrix, x, y, TRUE)
#define g_bit_matrix_unset(matrix,x,y) g_bit_matrix_change (matrix, x, y, FALSE)
-
static inline guint32
g_bit_matrix_peek (GBitMatrix *matrix,
guint x,
@@ -195,7 +168,6 @@ g_bit_matrix_peek (GBitMatrix *matrix,
guint32 shift = cons & 0x1f; /* % 32 */
return matrix->bits[index] & (1 << shift);
}
-
static inline gboolean
g_bit_matrix_test (GBitMatrix *matrix,
guint x,
@@ -206,14 +178,11 @@ g_bit_matrix_test (GBitMatrix *matrix,
else
return 0;
}
-
static inline void
g_bit_matrix_free (GBitMatrix *matrix)
{
g_free (matrix);
}
-
-
/* --- predicate idle --- */
guint g_predicate_idle_add (GSourceFunc predicate,
GSourceFunc function,
@@ -223,8 +192,6 @@ guint g_predicate_idle_add_full (gint priority,
GSourceFunc function,
gpointer data,
GDestroyNotify notify);
-
-
/* --- unix signal queue --- */
#if 0
typedef gboolean (*GUSignalFunc) (gint8 usignal,
@@ -239,8 +206,6 @@ guint g_usignal_add_full (gint priority,
GDestroyNotify destroy);
void g_usignal_notify (gint8 usignal);
#endif
-
-
/* --- GType boilerplate --- */
#ifndef G_DEFINE_DATA_TYPE // GTKFIX: add this to glib?
#define G_DEFINE_DATA_TYPE(TN, t_n, T_P) G_DEFINE_DATA_TYPE_EXTENDED (TN, t_n, T_P, GTypeFlags (0), {})
@@ -286,8 +251,6 @@ type_name##_get_type (void) \
return g_define_type_id; \
}
#endif /* !G_DEFINE_DATA_TYPE */
-
-
/* --- GScanner --- */
GScanner* g_scanner_new64 (const GScannerConfig *config_templ);
#ifndef G_DISABLE_DEPRECATED
@@ -303,10 +266,7 @@ GScanner* g_scanner_new64 (const GScannerConfig *config_templ);
#define g_scanner_freeze_symbol_table(scanner) ((void)0)
#define g_scanner_thaw_symbol_table(scanner) ((void)0)
#endif /* G_DISABLE_DEPRECATED */
-
-
G_END_DECLS
-
// == Flags Enumeration Operators in C++ ==
#ifdef __cplusplus
inline GParamFlags operator& (GParamFlags s1, GParamFlags s2) { return GParamFlags (s1 & (long long unsigned) s2); }
@@ -314,24 +274,20 @@ inline GParamFlags& operator&= (GParamFlags &s1, GParamFlags s2) { s1 = s1 & s2;
inline GParamFlags operator| (GParamFlags s1, GParamFlags s2) { return GParamFlags (s1 | (long long unsigned) s2); }
inline GParamFlags& operator|= (GParamFlags &s1, GParamFlags s2) { s1 = s1 | s2; return s1; }
inline GParamFlags operator~ (GParamFlags s1) { return GParamFlags (~(long long unsigned) s1); }
-
inline GSignalMatchType operator& (GSignalMatchType s1, GSignalMatchType s2) { return GSignalMatchType (s1 & (long long unsigned) s2); }
inline GSignalMatchType& operator&= (GSignalMatchType &s1, GSignalMatchType s2) { s1 = s1 & s2; return s1; }
inline GSignalMatchType operator| (GSignalMatchType s1, GSignalMatchType s2) { return GSignalMatchType (s1 | (long long unsigned) s2); }
inline GSignalMatchType& operator|= (GSignalMatchType &s1, GSignalMatchType s2) { s1 = s1 | s2; return s1; }
inline GSignalMatchType operator~ (GSignalMatchType s1) { return GSignalMatchType (~(long long unsigned) s1); }
-
inline GSignalFlags operator& (GSignalFlags s1, GSignalFlags s2) { return GSignalFlags (s1 & (long long unsigned) s2); }
inline GSignalFlags& operator&= (GSignalFlags &s1, GSignalFlags s2) { s1 = s1 & s2; return s1; }
inline GSignalFlags operator| (GSignalFlags s1, GSignalFlags s2) { return GSignalFlags (s1 | (long long unsigned) s2); }
inline GSignalFlags& operator|= (GSignalFlags &s1, GSignalFlags s2) { s1 = s1 | s2; return s1; }
inline GSignalFlags operator~ (GSignalFlags s1) { return GSignalFlags (~(long long unsigned) s1); }
-
inline GConnectFlags operator& (GConnectFlags s1, GConnectFlags s2) { return GConnectFlags (s1 & (long long unsigned) s2); }
inline GConnectFlags& operator&= (GConnectFlags &s1, GConnectFlags s2) { s1 = s1 & s2; return s1; }
inline GConnectFlags operator| (GConnectFlags s1, GConnectFlags s2) { return GConnectFlags (s1 | (long long unsigned) s2); }
inline GConnectFlags& operator|= (GConnectFlags &s1, GConnectFlags s2) { s1 = s1 | s2; return s1; }
inline GConnectFlags operator~ (GConnectFlags s1) { return GConnectFlags (~(long long unsigned) s1); }
#endif // __cplusplus
-
#endif /* __SFI_GLIB_EXTRA_H__ */
diff --git a/sfi/sfi.hh b/sfi/sfi.hh
index 23cddfb..3103073 100644
--- a/sfi/sfi.hh
+++ b/sfi/sfi.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_H__
#define __SFI_H__
-
/* no bin-compat: #include <sfi/sficomwire.hh> */
#include <sfi/sficomport.hh>
#include <sfi/sfifilecrawler.hh>
@@ -22,7 +21,5 @@
#include <sfi/sfivalues.hh>
#include <sfi/sfivmarshal.hh>
#include <sfi/sfiwrapper.hh>
-
#endif /* __SFI_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sficomport.cc b/sfi/sficomport.cc
index 7c72a36..3cbca2e 100644
--- a/sfi/sficomport.cc
+++ b/sfi/sficomport.cc
@@ -12,17 +12,13 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
-
static SFI_MSG_TYPE_DEFINE (debug_comport, "comport", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_comport, __VA_ARGS__)
#define MASS_DEBUG(...) // DEBUG (__VA_ARGS__) // log every communicated value
-
/* define the io bottle neck (for writes) to a small value
* (e.g. 20) to trigger and test blocking IO on fast systems
*/
#define IO_BOTTLE_NECK (1024 * 1024)
-
-
/* some systems don't have ERESTART (which is what linux returns for system
* calls on pipes which are being interrupted). most probably just use EINTR,
* and maybe some can return both. so we check for both in the below code,
@@ -31,8 +27,6 @@ static SFI_MSG_TYPE_DEFINE (debug_comport, "comport", SFI_MSG_DEBUG, NULL);
#ifndef ERESTART
#define ERESTART EINTR
#endif
-
-
/* --- functions --- */
static gint
nonblock_fd (gint fd)
@@ -43,16 +37,13 @@ nonblock_fd (gint fd)
do
d_long = fcntl (fd, F_GETFL);
while (d_long < 0 && errno == EINTR);
-
d_long |= O_NONBLOCK;
-
do
r = fcntl (fd, F_SETFL, d_long);
while (r < 0 && errno == EINTR);
}
return fd;
}
-
SfiComPort*
sfi_com_port_from_child (const gchar *ident,
gint remote_input,
@@ -60,9 +51,7 @@ sfi_com_port_from_child (const gchar *ident,
gint remote_pid)
{
SfiComPort *port;
-
g_return_val_if_fail (ident != NULL, NULL);
-
port = g_new0 (SfiComPort, 1);
port->ref_count = 1;
if (remote_pid > 1)
@@ -96,20 +85,17 @@ sfi_com_port_from_child (const gchar *ident,
(remote_output < 0 || port->pfd[1].fd >= 0));
return port;
}
-
SfiComPort*
sfi_com_port_from_pipe (const gchar *ident,
gint remote_input,
gint remote_output)
{
g_return_val_if_fail (ident != NULL, NULL);
-
return sfi_com_port_from_child (ident,
remote_input,
remote_output,
-1);
}
-
void
sfi_com_port_create_linked (const gchar *ident1,
BirnetThread *thread1,
@@ -119,11 +105,9 @@ sfi_com_port_create_linked (const gchar *ident1,
SfiComPort **port2)
{
SfiComPortLink *link;
-
g_return_if_fail (thread1 && ident1);
g_return_if_fail (thread2 && ident2);
g_return_if_fail (port1 && port2);
-
link = g_new0 (SfiComPortLink, 1);
sfi_mutex_init (&link->mutex);
link->port1 = sfi_com_port_from_child (ident1, -1, -1, -1);
@@ -139,13 +123,11 @@ sfi_com_port_create_linked (const gchar *ident1,
*port2 = link->port2;
sfi_cond_init (&link->wcond);
}
-
static void
sfi_com_port_link_destroy (SfiComPortLink *link)
{
g_return_if_fail (link->ref_count == 0);
g_return_if_fail (link->port1== NULL && link->port2 == NULL);
-
while (link->p1queue)
sfi_value_free ((GValue*) sfi_ring_pop_head (&link->p1queue));
while (link->p2queue)
@@ -154,31 +136,26 @@ sfi_com_port_link_destroy (SfiComPortLink *link)
sfi_cond_destroy (&link->wcond);
g_free (link);
}
-
SfiComPort*
sfi_com_port_ref (SfiComPort *port)
{
g_return_val_if_fail (port != NULL, NULL);
g_return_val_if_fail (port->ref_count > 0, NULL);
-
port->ref_count++;
return port;
}
-
void
sfi_com_port_set_close_func (SfiComPort *port,
SfiComPortClosedFunc func,
gpointer close_data)
{
g_return_if_fail (port != NULL);
-
port->close_func = func;
port->close_data = func ? close_data : NULL;
/* provide notification right now */
if (!port->connected)
sfi_com_port_close_remote (port, FALSE);
}
-
static void
com_port_try_reap (SfiComPort *port,
gboolean mayblock)
@@ -202,13 +179,11 @@ com_port_try_reap (SfiComPort *port,
com_port_try_reap (port, mayblock);
}
}
-
void
sfi_com_port_close_remote (SfiComPort *port,
gboolean terminate_child)
{
g_return_if_fail (port != NULL);
-
port->connected = FALSE;
if (port->pfd[0].fd >= 0)
{
@@ -263,12 +238,10 @@ sfi_com_port_close_remote (SfiComPort *port,
close_func (port, close_data);
}
}
-
static void
sfi_com_port_destroy (SfiComPort *port)
{
g_return_if_fail (port != NULL);
-
sfi_com_port_close_remote (port, FALSE);
if (port->scanner)
g_scanner_destroy (port->scanner);
@@ -279,18 +252,15 @@ sfi_com_port_destroy (SfiComPort *port)
g_free (port->rbuffer.data);
g_free (port);
}
-
void
sfi_com_port_unref (SfiComPort *port)
{
g_return_if_fail (port != NULL);
g_return_if_fail (port->ref_count > 0);
-
port->ref_count--;
if (!port->ref_count)
sfi_com_port_destroy (port);
}
-
static void
com_port_grow_wbuffer (SfiComPort *port,
guint delta)
@@ -301,7 +271,6 @@ com_port_grow_wbuffer (SfiComPort *port,
port->wbuffer.data = g_renew (guint8, port->wbuffer.data, port->wbuffer.allocated);
}
}
-
static gboolean
com_port_write_queued (SfiComPort *port)
{
@@ -323,7 +292,6 @@ com_port_write_queued (SfiComPort *port)
}
return TRUE; /* connection remains valid */
}
-
static gboolean
com_port_write (SfiComPort *port,
guint n_bytes,
@@ -353,7 +321,6 @@ com_port_write (SfiComPort *port,
}
return TRUE; /* connection remains valid */
}
-
void
sfi_com_port_send_bulk (SfiComPort *port,
SfiRing *value_ring)
@@ -363,7 +330,6 @@ sfi_com_port_send_bulk (SfiComPort *port,
if (!value_ring || !port->connected)
return;
g_return_if_fail (port->link || port->pfd[1].fd >= 0);
-
if (port->link)
{
SfiComPortLink *link = port->link;
@@ -373,7 +339,6 @@ sfi_com_port_send_bulk (SfiComPort *port,
/* guard caller against receiver messing with value */
for (ring = value_ring; ring; ring = sfi_ring_next (ring, value_ring))
target = sfi_ring_append (target, sfi_value_clone_deep ((GValue*) ring->data));
-
sfi_mutex_lock (&link->mutex);
if (first)
link->p1queue = sfi_ring_concat (link->p1queue, target);
@@ -415,7 +380,6 @@ sfi_com_port_send_bulk (SfiComPort *port,
g_free (str);
}
}
-
void
sfi_com_port_send (SfiComPort *port,
const GValue *value)
@@ -427,7 +391,6 @@ sfi_com_port_send (SfiComPort *port,
sfi_com_port_send_bulk (port, ring);
sfi_ring_free (ring);
}
-
static gboolean
com_port_read_pending (SfiComPort *port)
{
@@ -505,7 +468,6 @@ com_port_read_pending (SfiComPort *port)
}
return TRUE; /* connection remains valid */
}
-
static void
com_port_scanner_msg (GScanner *scanner,
gchar *message,
@@ -514,7 +476,6 @@ com_port_scanner_msg (GScanner *scanner,
SfiComPort *port = (SfiComPort*) scanner->user_data;
g_printerr ("ComPort:%s: while processing data: %s", port->ident, message);
}
-
static void
sfi_com_port_deserialize (SfiComPort *port)
{
@@ -547,7 +508,6 @@ sfi_com_port_deserialize (SfiComPort *port)
port->rbuffer.hlen = 0;
}
}
-
static GValue*
sfi_com_port_recv_intern (SfiComPort *port,
gboolean blocking)
@@ -556,7 +516,6 @@ sfi_com_port_recv_intern (SfiComPort *port,
if (!port->rvalues && port->link)
{
SfiComPortLink *link = port->link;
-
sfi_mutex_lock (&link->mutex);
refetch:
if (port == link->port1)
@@ -578,20 +537,17 @@ sfi_com_port_recv_intern (SfiComPort *port,
if (blocking && /* flush output buffer if data is pending */
!com_port_write_queued (port))
sfi_com_port_close_remote (port, FALSE);
-
if (!port->rvalues)
{
if (!com_port_read_pending (port))
sfi_com_port_close_remote (port, FALSE);
sfi_com_port_deserialize (port);
}
-
if (blocking && !port->rvalues && port->pfd[0].fd >= 0)
{
struct timeval tv = { 60, 0, };
fd_set in_fds, out_fds, exp_fds;
gint xfd;
-
FD_ZERO (&in_fds);
FD_ZERO (&out_fds);
FD_ZERO (&exp_fds);
@@ -615,7 +571,6 @@ sfi_com_port_recv_intern (SfiComPort *port,
MASS_DEBUG ("[%s: DONE receiving]", port->ident);
return port->connected ? (GValue*) sfi_ring_pop_head (&port->rvalues) : NULL;
}
-
GValue*
sfi_com_port_recv (SfiComPort *port)
{
@@ -623,10 +578,8 @@ sfi_com_port_recv (SfiComPort *port)
if (!port->connected)
return NULL;
g_return_val_if_fail (port->link || port->pfd[0].fd >= 0, NULL);
-
return sfi_com_port_recv_intern (port, FALSE);
}
-
GValue*
sfi_com_port_recv_blocking (SfiComPort *port)
{
@@ -634,20 +587,16 @@ sfi_com_port_recv_blocking (SfiComPort *port)
if (!port->connected)
return NULL;
g_return_val_if_fail (port->link || port->pfd[0].fd >= 0, NULL);
-
return sfi_com_port_recv_intern (port, TRUE);
}
-
GPollFD*
sfi_com_port_get_poll_fds (SfiComPort *port,
guint *n_pfds)
{
GPollFD *pfds = NULL;
guint n = 0;
-
g_return_val_if_fail (port != NULL, NULL);
g_return_val_if_fail (n_pfds != NULL, NULL);
-
if (port->pfd[1].fd >= 0)
{
n++;
@@ -661,54 +610,44 @@ sfi_com_port_get_poll_fds (SfiComPort *port,
*n_pfds = n;
return n ? pfds : NULL;
}
-
gboolean
sfi_com_port_io_pending (SfiComPort *port)
{
g_return_val_if_fail (port != NULL, FALSE);
-
/* maintain poll fds */
port->pfd[0].events = port->pfd[0].fd >= 0 ? G_IO_IN : 0;
port->pfd[1].events = port->pfd[1].fd >= 0 && port->wbuffer.n ? G_IO_OUT : 0;
-
/* check link queue */
if (port->link &&
((port == port->link->port1 && port->link->p2queue) ||
(port == port->link->port2 && port->link->p1queue)))
return TRUE;
-
/* check input channel */
if (port->pfd[0].fd >= 0 &&
port->pfd[0].revents & G_IO_IN)
return TRUE;
-
/* check output channel */
if (port->pfd[1].fd >= 0 && port->wbuffer.n &&
port->pfd[1].revents & G_IO_OUT)
return TRUE;
-
/* nothing to do */
return FALSE;
}
-
void
sfi_com_port_process_io (SfiComPort *port)
{
g_return_if_fail (port != NULL);
-
if (!com_port_read_pending (port) ||
!com_port_write_queued (port))
sfi_com_port_close_remote (port, FALSE);
if (port->connected)
sfi_com_port_deserialize (port);
}
-
void
sfi_com_port_reap_child (SfiComPort *port,
gboolean kill_child)
{
g_return_if_fail (port != NULL);
-
com_port_try_reap (port, !kill_child);
if (kill_child &&
port->remote_pid > 1 &&
@@ -720,7 +659,6 @@ sfi_com_port_reap_child (SfiComPort *port,
}
com_port_try_reap (port, TRUE);
}
-
gboolean
sfi_com_port_test_reap_child (SfiComPort *port)
{
diff --git a/sfi/sficomport.hh b/sfi/sficomport.hh
index ecd7cf0..7f58589 100644
--- a/sfi/sficomport.hh
+++ b/sfi/sficomport.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_COM_PORT_H__
#define __SFI_COM_PORT_H__
-
#include <sfi/sfitypes.hh>
#include <sfi/sfiring.hh>
-
G_BEGIN_DECLS
-
-
#define SFI_COM_PORT_MAGIC (0x42534500 /* "BSE\0" */)
-
typedef struct _SfiComPortLink SfiComPortLink;
typedef struct _SfiComPort SfiComPort;
typedef void (*SfiComPortClosedFunc) (SfiComPort *port,
@@ -59,8 +54,6 @@ struct _SfiComPortLink
gboolean waiting;
BirnetCond wcond;
};
-
-
/* create ports */
SfiComPort* sfi_com_port_from_pipe (const gchar *ident,
gint remote_input,
@@ -78,7 +71,6 @@ void sfi_com_port_create_linked (const gchar *ident1,
SfiComPort **port2);
SfiComPort* sfi_com_port_ref (SfiComPort *port);
void sfi_com_port_unref (SfiComPort *port);
-
/* remote I/O */
void sfi_com_port_send (SfiComPort *port,
const GValue *value);
@@ -86,14 +78,11 @@ void sfi_com_port_send_bulk (SfiComPort *port,
SfiRing *value_ring);
GValue* sfi_com_port_recv (SfiComPort *port);
GValue* sfi_com_port_recv_blocking (SfiComPort *port);
-
/* I/O handling */
GPollFD* sfi_com_port_get_poll_fds (SfiComPort *port,
guint *n_pfds);
gboolean sfi_com_port_io_pending (SfiComPort *port);
void sfi_com_port_process_io (SfiComPort *port);
-
-
/* shutdown */
void sfi_com_port_set_close_func (SfiComPort *port,
SfiComPortClosedFunc func,
@@ -103,8 +92,5 @@ void sfi_com_port_close_remote (SfiComPort *port,
void sfi_com_port_reap_child (SfiComPort *port,
gboolean kill_child);
gboolean sfi_com_port_test_reap_child (SfiComPort *port);
-
-
G_END_DECLS
-
#endif /* __SFI_COM_PORT_H__ */
diff --git a/sfi/sficomwire.cc b/sfi/sficomwire.cc
index 18028a9..ea903ba 100644
--- a/sfi/sficomwire.cc
+++ b/sfi/sficomwire.cc
@@ -9,13 +9,9 @@
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
-
-
/* --- prototypes --- */
static GList* wire_find_link (GList *list,
guint request);
-
-
/* --- functions --- */
static void
nonblock_fd (gint fd)
@@ -26,15 +22,12 @@ nonblock_fd (gint fd)
do
d_long = fcntl (fd, F_GETFL);
while (d_long < 0 && errno == EINTR);
-
d_long |= O_NONBLOCK;
-
do
r = fcntl (fd, F_SETFL, d_long);
while (r < 0 && errno == EINTR);
}
}
-
SfiComWire*
sfi_com_wire_from_child (const gchar *ident,
gint remote_input,
@@ -45,9 +38,7 @@ sfi_com_wire_from_child (const gchar *ident,
gint remote_pid)
{
SfiComWire *wire;
-
g_return_val_if_fail (ident != NULL, NULL);
-
wire = g_new0 (SfiComWire, 1);
if (remote_pid > 1)
wire->ident = g_strdup_printf ("%s[%u]", ident, remote_pid);
@@ -72,75 +63,60 @@ sfi_com_wire_from_child (const gchar *ident,
nonblock_fd (wire->standard_input);
nonblock_fd (wire->standard_output);
nonblock_fd (wire->standard_error);
-
return wire;
}
-
SfiComWire*
sfi_com_wire_from_pipe (const gchar *ident,
gint remote_input,
gint remote_output)
{
g_return_val_if_fail (ident != NULL, NULL);
-
return sfi_com_wire_from_child (ident,
remote_input,
remote_output,
-1, -1, -1, -1);
}
-
static SfiComMsg*
alloc_msg (SfiComMsgType type)
{
SfiComMsg *msg = g_new (SfiComMsg, 1);
-
msg->magic = BSE_MAGIC_BSEm;
msg->mlength = 0;
msg->type = type;
-
return msg;
}
-
static gchar*
free_msg_skel (SfiComMsg *msg)
{
gchar *content = msg->message;
-
g_free (msg);
return content;
}
-
static void
free_msg (SfiComMsg *msg)
{
g_free (free_msg_skel (msg));
}
-
static void
wire_write_remote (SfiComWire *wire)
{
guint8 *buf = wire->obuffer;
-
if (wire->obp - buf && wire->remote_output >= 0)
{
gint n;
-
do
{
n = write (wire->remote_output, buf, wire->obp - buf);
buf += MAX (n, 0);
}
while (n < 0 && errno == EINTR);
-
if (n == 0 || (n < 0 && errno != EINTR && errno != EAGAIN))
wire->remote_output_broke = TRUE;
-
n = wire->obp - buf;
g_memmove (wire->obuffer, buf, n);
wire->obp = wire->obuffer + n;
}
}
-
static inline uint8*
put_uint32 (gpointer p,
guint32 val)
@@ -149,15 +125,12 @@ put_uint32 (gpointer p,
*ip++ = GUINT32_TO_BE (val);
return (uint8*) ip;
}
-
static void
wire_send (SfiComWire *wire,
SfiComMsg *msg)
{
guint strl;
-
g_return_if_fail (msg->mlength == 0);
-
strl = strlen (msg->message) + 1; /* include trailing 0 */
msg->mlength = (4 + /* magic */
4 + /* mlength */
@@ -179,7 +152,6 @@ wire_send (SfiComWire *wire,
wire->obp += strl;
wire_write_remote (wire);
}
-
static void
wire_read_remote (SfiComWire *wire)
{
@@ -187,7 +159,6 @@ wire_read_remote (SfiComWire *wire)
{
guint read_size = 8192;
gint n;
-
if (wire->ibound - wire->ibp < read_size)
{
guint l = wire->ibp - wire->ibuffer;
@@ -195,20 +166,17 @@ wire_read_remote (SfiComWire *wire)
wire->ibp = wire->ibuffer + l;
wire->ibound = wire->ibp + read_size;
}
-
do
{
n = read (wire->remote_input, wire->ibp, wire->ibound - wire->ibp);
wire->ibp += MAX (n, 0);
}
while (n < 0 && errno == EINTR);
-
/* n==0 on pipes/fifos means remote closed the connection (end-of-file) */
if (n == 0 || (n < 0 && errno != EINTR && errno != EAGAIN))
wire->remote_input_broke = TRUE;
}
}
-
static inline uint8*
get_uint32 (gpointer p,
guint32 *val)
@@ -218,18 +186,15 @@ get_uint32 (gpointer p,
*val = GUINT32_FROM_BE (v);
return (uint8*) ip;
}
-
static void
wire_receive (SfiComWire *wire)
{
wire_read_remote (wire);
-
if (wire->ibp >= wire->ibuffer + 4 + 4 + 4) /* magic + mlength + type */
{
guint8 *p = wire->ibuffer;
guint32 magic, mlength, type;
guint mheader_length = 4 + 4 + 4 + 4, max_mlength = 4 * 1024 * 1024;
-
p = get_uint32 (p, &magic);
p = get_uint32 (p, &mlength);
p = get_uint32 (p, &type);
@@ -249,7 +214,6 @@ wire_receive (SfiComWire *wire)
else if (mlength <= wire->ibp - wire->ibuffer)
{
guint strl = mlength - mheader_length; /* >= 1 */
-
switch (type)
{
SfiComMsg *msg;
@@ -301,7 +265,6 @@ wire_receive (SfiComWire *wire)
}
}
}
-
static inline gboolean /* returns: connection_alive */
wire_read_gstring (SfiComWire *wire,
gint fd,
@@ -310,7 +273,6 @@ wire_read_gstring (SfiComWire *wire,
uint l = gstring->len;
char *pos, *bound;
int n;
-
g_string_set_size (gstring, l + 8192);
pos = gstring->str + l;
bound = gstring->str + gstring->len;
@@ -321,11 +283,9 @@ wire_read_gstring (SfiComWire *wire,
}
while (n < 0 && errno == EINTR);
g_string_set_size (gstring, pos - gstring->str);
-
/* n==0 on pipes/fifos means remote closed the connection (end-of-file) */
return n > 0 || (n < 0 && (errno == EINTR || errno == EAGAIN));
}
-
static void
wire_capture (SfiComWire *wire)
{
@@ -336,7 +296,6 @@ wire_capture (SfiComWire *wire)
if (!wire_read_gstring (wire, wire->standard_error, wire->gstring_stderr))
wire->standard_error_broke = TRUE;
}
-
static inline void
wire_update_alive (SfiComWire *wire)
{
@@ -347,7 +306,6 @@ wire_update_alive (SfiComWire *wire)
wire->standard_error_broke)
wire->connected = FALSE;
}
-
static GList*
wire_find_link (GList *list,
guint request)
@@ -360,55 +318,42 @@ wire_find_link (GList *list,
}
return NULL;
}
-
static guint
wire_alloc_request (SfiComWire *wire)
{
guint request = (rand () << 16) ^ rand ();
-
while (request == 0 || wire_find_link (wire->orequests, request))
request++;
-
return request;
}
-
guint
sfi_com_wire_send_request (SfiComWire *wire,
const gchar *request_msg)
{
SfiComMsg *msg;
guint request;
-
g_return_val_if_fail (wire != NULL, 0);
g_return_val_if_fail (request_msg != NULL, 0);
-
request = wire_alloc_request (wire);
msg = alloc_msg (SFI_COM_MSG_REQUEST);
msg->request = request;
msg->message = g_strdup (request_msg);
-
wire->orequests = g_list_prepend (wire->orequests, msg);
wire_send (wire, msg);
-
wire_update_alive (wire);
-
return request;
}
-
gchar*
sfi_com_wire_receive_result (SfiComWire *wire,
guint request)
{
GList *out_link, *in_link;
-
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (request > 0, NULL);
out_link = wire_find_link (wire->orequests, request);
g_return_val_if_fail (out_link != NULL, NULL);
-
wire_receive (wire);
wire_update_alive (wire);
-
in_link = wire_find_link (wire->iresults, request);
if (in_link)
{
@@ -422,46 +367,37 @@ sfi_com_wire_receive_result (SfiComWire *wire,
else
return NULL;
}
-
void
sfi_com_wire_forget_request (SfiComWire *wire,
guint request)
{
GList *out_link;
-
g_return_if_fail (wire != NULL);
g_return_if_fail (request > 0);
out_link = wire_find_link (wire->orequests, request);
g_return_if_fail (out_link != NULL);
-
SfiComMsg *omsg = (SfiComMsg*) out_link->data;
wire->orequests = g_list_delete_link (wire->orequests, out_link);
free_msg (omsg);
}
-
guint
sfi_com_wire_peek_first_result (SfiComWire *wire)
{
g_return_val_if_fail (wire != NULL, 0);
-
SfiComMsg *msg = (SfiComMsg*) (wire->iresults ? wire->iresults->data : NULL);
return msg ? msg->request : 0;
}
-
const gchar*
sfi_com_wire_receive_request (SfiComWire *wire,
guint *request_p)
{
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (request_p != NULL, NULL);
-
wire_receive (wire);
wire_update_alive (wire);
-
if (wire->irequests)
{
SfiComMsg *msg = (SfiComMsg*) wire->irequests->data;
-
wire->irequests = g_list_remove (wire->irequests, msg);
if (msg->request == 0)
{
@@ -472,7 +408,6 @@ sfi_com_wire_receive_request (SfiComWire *wire,
}
wire->rrequests = g_list_prepend (wire->rrequests, msg);
*request_p = msg->request;
-
return msg->message;
}
else
@@ -481,7 +416,6 @@ sfi_com_wire_receive_request (SfiComWire *wire,
return NULL;
}
}
-
void
sfi_com_wire_send_result (SfiComWire *wire,
guint request,
@@ -489,42 +423,33 @@ sfi_com_wire_send_result (SfiComWire *wire,
{
SfiComMsg *msg;
GList *received_link;
-
g_return_if_fail (wire != NULL);
g_return_if_fail (request > 0);
g_return_if_fail (result_msg != NULL);
received_link = wire_find_link (wire->rrequests, request);
g_return_if_fail (received_link != NULL);
-
msg = alloc_msg (SFI_COM_MSG_RESULT);
msg->request = request;
msg->message = g_strdup (result_msg);
wire_send (wire, msg);
-
free_msg ((SfiComMsg*) received_link->data);
wire->rrequests = g_list_delete_link (wire->rrequests, received_link);
free_msg (msg);
-
wire_update_alive (wire);
}
-
void
sfi_com_wire_discard_request (SfiComWire *wire,
guint request)
{
GList *received_link;
-
g_return_if_fail (wire != NULL);
g_return_if_fail (request > 0);
received_link = wire_find_link (wire->rrequests, request);
g_return_if_fail (received_link != NULL);
-
free_msg ((SfiComMsg*) received_link->data);
wire->rrequests = g_list_delete_link (wire->rrequests, received_link);
-
wire_update_alive (wire);
}
-
static gboolean
wire_default_dispatch (gpointer data,
guint request,
@@ -535,7 +460,6 @@ wire_default_dispatch (gpointer data,
sfi_com_wire_discard_request (wire, request);
return TRUE;
}
-
void
sfi_com_wire_set_dispatcher (SfiComWire *wire,
SfiComDispatch dispatch_func,
@@ -543,7 +467,6 @@ sfi_com_wire_set_dispatcher (SfiComWire *wire,
GDestroyNotify destroy_data)
{
g_return_if_fail (wire != NULL);
-
if (wire->destroy_data)
wire->destroy_data (wire->dispatch_data);
if (dispatch_func)
@@ -559,47 +482,39 @@ sfi_com_wire_set_dispatcher (SfiComWire *wire,
wire->destroy_data = NULL;
}
}
-
void
sfi_com_wire_dispatch (SfiComWire *wire,
guint request)
{
GList *received_link;
gboolean handled;
-
g_return_if_fail (wire != NULL);
g_return_if_fail (request > 0);
received_link = wire_find_link (wire->rrequests, request);
g_return_if_fail (received_link != NULL);
-
SfiComMsg *msg = (SfiComMsg*) received_link->data;
handled = wire->dispatch_func (wire->dispatch_data, msg->request, msg->message, wire);
if (!handled)
wire_default_dispatch (NULL, msg->request, msg->message, wire);
}
-
gboolean
sfi_com_wire_need_dispatch (SfiComWire *wire)
{
g_return_val_if_fail (wire != NULL, FALSE);
-
return wire->iresults || wire->irequests || wire->gstring_stdout->len || wire->gstring_stderr->len;
}
-
gint*
sfi_com_wire_get_read_fds (SfiComWire *wire,
guint *n_fds_p)
{
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (n_fds_p != NULL, NULL);
-
if (wire->remote_input >= 0 ||
wire->standard_output >= 0 ||
wire->standard_error >= 0)
{
guint n_fds = 0;
gint *fds = g_new (gint, 3);
-
if (wire->remote_input >= 0)
fds[n_fds++] = wire->remote_input;
if (wire->standard_output >= 0)
@@ -615,19 +530,16 @@ sfi_com_wire_get_read_fds (SfiComWire *wire,
return NULL;
}
}
-
gint*
sfi_com_wire_get_write_fds (SfiComWire *wire,
guint *n_fds_p)
{
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (n_fds_p != NULL, NULL);
-
if (wire->obp - wire->obuffer && wire->remote_output >= 0)
{
guint n_fds = 0;
gint *fds = g_new (gint, 1);
-
fds[n_fds++] = wire->remote_output;
*n_fds_p = n_fds;
return fds;
@@ -638,14 +550,12 @@ sfi_com_wire_get_write_fds (SfiComWire *wire,
return NULL;
}
}
-
GPollFD*
sfi_com_wire_get_poll_fds (SfiComWire *wire,
guint *n_pfds_p)
{
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (n_pfds_p != NULL, NULL);
-
if (wire->remote_input >= 0 ||
wire->standard_output >= 0 ||
wire->standard_error >= 0 ||
@@ -653,7 +563,6 @@ sfi_com_wire_get_poll_fds (SfiComWire *wire,
{
guint n_pfds = 0;
GPollFD *pfds = g_new0 (GPollFD, 3 + 1);
-
if (wire->remote_input >= 0)
{
pfds[n_pfds].fd = wire->remote_input;
@@ -686,17 +595,14 @@ sfi_com_wire_get_poll_fds (SfiComWire *wire,
return NULL;
}
}
-
void
sfi_com_wire_process_io (SfiComWire *wire)
{
g_return_if_fail (wire != NULL);
-
wire_capture (wire);
wire_write_remote (wire);
wire_read_remote (wire);
wire_capture (wire);
-
if (wire->remote_input_broke)
{
if (wire->remote_input >= 0)
@@ -728,13 +634,11 @@ sfi_com_wire_process_io (SfiComWire *wire)
wire->standard_error = -1;
}
}
-
void
sfi_com_wire_close_remote (SfiComWire *wire,
gboolean terminate)
{
g_return_if_fail (wire != NULL);
-
wire->connected = FALSE;
if (wire->remote_input >= 0)
close (wire->remote_input);
@@ -755,14 +659,11 @@ sfi_com_wire_close_remote (SfiComWire *wire,
kill (wire->remote_pid, SIGTERM);
wire->remote_pid = -1;
}
-
void
sfi_com_wire_destroy (SfiComWire *wire)
{
GList *list;
-
g_return_if_fail (wire != NULL);
-
sfi_com_wire_set_dispatcher (wire, NULL, NULL, NULL);
sfi_com_wire_close_remote (wire, TRUE);
for (list = wire->orequests; list; list = list->next)
@@ -784,14 +685,11 @@ sfi_com_wire_destroy (SfiComWire *wire)
g_free (wire->ident);
g_free (wire);
}
-
gboolean
sfi_com_wire_receive_dispatch (SfiComWire *wire)
{
guint request;
-
g_return_val_if_fail (wire != NULL, FALSE);
-
if (sfi_com_wire_receive_request (wire, &request))
{
sfi_com_wire_dispatch (wire, request);
@@ -800,21 +698,17 @@ sfi_com_wire_receive_dispatch (SfiComWire *wire)
else
return FALSE;
}
-
void
sfi_com_wire_select (SfiComWire *wire,
guint timeout)
{
uint i, n;
struct timeval tv;
-
g_return_if_fail (wire != NULL);
-
fd_set rfds, wfds, efds;
FD_ZERO (&rfds);
FD_ZERO (&wfds);
FD_ZERO (&efds);
-
int max_fd = 0, *fds = sfi_com_wire_get_read_fds (wire, &n);
for (i = 0; i < n; i++)
{
@@ -823,7 +717,6 @@ sfi_com_wire_select (SfiComWire *wire,
max_fd = MAX (max_fd, fds[i]);
}
g_free (fds);
-
fds = sfi_com_wire_get_write_fds (wire, &n);
for (i = 0; i < n; i++)
{
@@ -832,12 +725,10 @@ sfi_com_wire_select (SfiComWire *wire,
max_fd = MAX (max_fd, fds[i]);
}
g_free (fds);
-
tv.tv_usec = (timeout % 1000) * 1000;
tv.tv_sec = timeout / 1000;
select (max_fd + 1, &rfds, &wfds, NULL, &tv);
}
-
gchar*
sfi_com_wire_ping_pong (SfiComWire *wire,
const gchar *ping,
@@ -845,74 +736,59 @@ sfi_com_wire_ping_pong (SfiComWire *wire,
{
guint request;
gchar *pong;
-
g_return_val_if_fail (wire != NULL, NULL);
g_return_val_if_fail (ping != NULL, NULL);
-
request = sfi_com_wire_send_request (wire, ping);
pong = sfi_com_wire_receive_result (wire, request);
if (pong)
return pong;
-
sfi_com_wire_select (wire, timeout / 4);
sfi_com_wire_process_io (wire);
pong = sfi_com_wire_receive_result (wire, request);
if (pong)
return pong;
-
sfi_com_wire_select (wire, timeout / 4);
sfi_com_wire_process_io (wire);
pong = sfi_com_wire_receive_result (wire, request);
if (pong)
return pong;
-
sfi_com_wire_select (wire, timeout / 4);
sfi_com_wire_process_io (wire);
pong = sfi_com_wire_receive_result (wire, request);
if (pong)
return pong;
-
sfi_com_wire_select (wire, timeout / 4);
sfi_com_wire_process_io (wire);
pong = sfi_com_wire_receive_result (wire, request);
if (pong)
return pong;
-
sfi_com_wire_forget_request (wire, request);
return NULL;
}
-
-
/* --- fork/exec --- */
static gchar *spawn_current_dir = NULL;
-
void
sfi_com_set_spawn_dir (const gchar *cwd)
{
g_free (spawn_current_dir);
spawn_current_dir = g_strdup (cwd);
}
-
static void
unset_cloexec (gint fd)
{
gint r;
-
do
r = fcntl (fd, F_SETFD, 0 /* FD_CLOEXEC */);
while (r < 0 && errno == EINTR);
}
-
typedef struct {
gint keepexec1;
gint keepexec2;
} ChildSetupData;
-
static void
pre_exec_child_setup (gpointer data)
{
ChildSetupData *cdata = (ChildSetupData*) data;
-
if (cdata->keepexec1)
unset_cloexec (cdata->keepexec1);
if (cdata->keepexec2)
@@ -920,7 +796,6 @@ pre_exec_child_setup (gpointer data)
/* drop scheduling priorities if we have any */
setpriority (PRIO_PROCESS, getpid(), 0);
}
-
const char*
sfi_com_spawn_async (const gchar *executable,
gint *child_pid,
@@ -940,13 +815,11 @@ sfi_com_spawn_async (const gchar *executable,
const char *reterr = NULL;
GError *error = NULL;
uint l;
-
g_return_val_if_fail (executable != NULL, NULL);
if (command_fd_option)
g_return_val_if_fail (command_fd_option && command_input && command_output, NULL);
else
g_return_val_if_fail (!command_fd_option && !command_input && !command_output, NULL);
-
if (command_fd_option)
{
if (pipe (command_output_pipe) < 0 || pipe (command_input_pipe) < 0)
@@ -968,7 +841,6 @@ sfi_com_spawn_async (const gchar *executable,
}
cargs = sfi_ring_prepend (cargs, g_strdup_printf (/*"SFI-Spawn:%s"*/"%s", executable));
cargs = sfi_ring_prepend (cargs, g_strdup (executable));
-
l = sfi_ring_length (cargs) + sfi_ring_length (args);
argv = g_new (gchar*, l + 1);
argp = argv;
@@ -977,7 +849,6 @@ sfi_com_spawn_async (const gchar *executable,
for (ring = args; ring; ring = sfi_ring_walk (ring, args))
*argp++ = (char*) ring->data;
*argp = NULL;
-
if (!g_spawn_async_with_pipes (spawn_current_dir, argv, NULL,
GSpawnFlags (G_SPAWN_DO_NOT_REAP_CHILD |
/* G_SPAWN_CHILD_INHERITS_STDIN | */
@@ -1006,7 +877,6 @@ sfi_com_spawn_async (const gchar *executable,
*standard_error = -1;
goto cleanup;
}
-
cleanup:
g_free (argv);
for (ring = cargs; ring; ring = sfi_ring_walk (ring, cargs))
@@ -1022,6 +892,5 @@ sfi_com_spawn_async (const gchar *executable,
*command_input = command_input_pipe[1];
*command_output = command_output_pipe[0];
}
-
return reterr;
}
diff --git a/sfi/sficomwire.hh b/sfi/sficomwire.hh
index efaa4cc..9b6dfab 100644
--- a/sfi/sficomwire.hh
+++ b/sfi/sficomwire.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_COM_WIRE_H__
#define __SFI_COM_WIRE_H__
-
#include <sfi/sfitypes.hh>
#include <sfi/sfiring.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
typedef struct _SfiComWire SfiComWire;
typedef gboolean (*SfiComDispatch) (gpointer data,
guint request,
@@ -25,21 +21,17 @@ struct _SfiComWire
guint standard_input_broke : 1;
guint standard_output_broke : 1;
guint standard_error_broke : 1;
-
SfiComDispatch dispatch_func;
gpointer dispatch_data;
GDestroyNotify destroy_data;
-
/* message queues */
GList *orequests; /* outgoing requests */
GList *iresults; /* incoming results */
GList *irequests; /* incoming requests */
GList *rrequests; /* received requests */
-
/* I/O channels */
gint remote_input; /* readable */
gint remote_output; /* writable */
-
/* spawned child */
gint standard_input; /* writable */
gint standard_output; /* readable */
@@ -47,18 +39,15 @@ struct _SfiComWire
gint remote_pid;
GString *gstring_stdout;
GString *gstring_stderr;
-
/* input buffer */
guint8 *ibuffer;
guint8 *ibp;
guint8 *ibound;
-
/* output buffer */
guint8 *obuffer;
guint8 *obp;
guint8 *obound;
};
-
typedef enum /*< skip >*/
{
SFI_COM_MSG_INVALID = 0,
@@ -78,8 +67,6 @@ typedef struct
guint32 request;
gchar *message;
} SfiComMsg;
-
-
/* create wires */
SfiComWire* sfi_com_wire_from_pipe (const gchar *ident,
gint remote_input,
@@ -91,7 +78,6 @@ SfiComWire* sfi_com_wire_from_child (const gchar *ident,
gint standard_output,
gint standard_error,
gint remote_pid);
-
/* handle outgoing */
guint sfi_com_wire_send_request (SfiComWire *wire,
const gchar *request_msg);
@@ -100,7 +86,6 @@ gchar* sfi_com_wire_receive_result (SfiComWire *wire,
void sfi_com_wire_forget_request (SfiComWire *wire,
guint request);
guint sfi_com_wire_peek_first_result (SfiComWire *wire);
-
/* handle incomming */
const gchar* sfi_com_wire_receive_request (SfiComWire *wire,
guint *request);
@@ -109,7 +94,6 @@ void sfi_com_wire_send_result (SfiComWire *wire,
const gchar *result_msg);
void sfi_com_wire_discard_request (SfiComWire *wire,
guint request);
-
/* dispatching */
void sfi_com_wire_set_dispatcher (SfiComWire *wire,
SfiComDispatch dispatch_func,
@@ -118,7 +102,6 @@ void sfi_com_wire_set_dispatcher (SfiComWire *wire,
void sfi_com_wire_dispatch (SfiComWire *wire,
guint request);
gboolean sfi_com_wire_need_dispatch (SfiComWire *wire);
-
/* wire I/O */
gint* sfi_com_wire_get_read_fds (SfiComWire *wire,
guint *n_fds);
@@ -131,13 +114,10 @@ gchar* sfi_com_wire_collect_stdout (SfiComWire *wire,
guint *n_chars);
gchar* sfi_com_wire_collect_stderr (SfiComWire *wire,
guint *n_chars);
-
/* shutdown */
void sfi_com_wire_close_remote (SfiComWire *wire,
gboolean terminate);
void sfi_com_wire_destroy (SfiComWire *wire);
-
-
/* convenience */
gboolean sfi_com_wire_receive_dispatch (SfiComWire *wire);
void sfi_com_wire_select (SfiComWire *wire,
@@ -145,8 +125,6 @@ void sfi_com_wire_select (SfiComWire *wire,
gchar* sfi_com_wire_ping_pong (SfiComWire *wire,
const gchar *ping,
guint timeout);
-
-
/* --- fork/exec --- */
void sfi_com_set_spawn_dir (const gchar *cwd);
const char* sfi_com_spawn_async (const gchar *executable,
@@ -158,10 +136,7 @@ const char* sfi_com_spawn_async (const gchar *executable,
gint *command_input,
gint *command_output,
SfiRing *args);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __SFI_COM_WIRE_H__ */
diff --git a/sfi/sficxx.cc b/sfi/sficxx.cc
index f132676..b7b0a44 100644
--- a/sfi/sficxx.cc
+++ b/sfi/sficxx.cc
@@ -1,23 +1,17 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "sficxx.hh"
#include "sfi.hh"
-
namespace Sfi {
-
static void
sfi_init_cxx (void)
{
g_type_init (); /* just in case this hasn't been called already */
-
_sfi_init_values ();
_sfi_init_params ();
_sfi_init_time ();
_sfi_init_glue ();
_sfi_init_file_crawler ();
}
-
static Birnet::InitHook sfi_init_hook (sfi_init_cxx);
-
} // Sfi
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sficxx.hh b/sfi/sficxx.hh
index fa2de5a..55b9645 100644
--- a/sfi/sficxx.hh
+++ b/sfi/sficxx.hh
@@ -1,20 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_CXX_H__
#define __SFI_CXX_H__
-
#include <birnet/birnet.hh>
#include <sfi/sfi.hh>
#include <string>
#include <string.h>
#include <new>
-
namespace Sfi {
-
typedef SfiBool Bool; // FIXME: use bool instead?
typedef SfiInt Int;
typedef SfiNum Num;
typedef SfiReal Real;
-
class String {
char *cstring;
int cmp (const char *ostring) const
@@ -141,7 +137,6 @@ public:
sfi_value_set_string (value, str.c_str());
}
};
-
struct GNewable {
gpointer operator new (size_t s)
{
@@ -160,13 +155,11 @@ struct GNewable {
g_free (mem);
}
};
-
typedef enum {
INIT_NULL,
INIT_EMPTY,
INIT_DEFAULT,
} InitializationType;
-
template<typename Type>
class RecordHandle {
Type *record;
@@ -323,7 +316,6 @@ public:
g_value_set_boxed (value, self.c_ptr());
}
};
-
template<typename Type>
class Sequence {
public:
@@ -519,7 +511,6 @@ cxx_value_set_boxed_sequence (GValue *value,
else
g_value_set_boxed (value, self.c_ptr());
}
-
class FBlock {
SfiFBlock *block;
public:
@@ -683,7 +674,6 @@ public:
sfi_value_set_fblock (value, self.block);
}
};
-
class BBlock {
SfiBBlock *block;
public:
@@ -815,7 +805,6 @@ public:
sfi_value_set_bblock (value, self.block);
}
};
-
class Rec {
SfiRec *crec;
public:
@@ -935,7 +924,6 @@ public:
sfi_value_set_rec (value, self.crec);
}
};
-
class ObjectHandle {
GObject *cobj;
public:
@@ -1032,7 +1020,6 @@ public:
g_value_set_object (value, self.cobj);
}
};
-
template<typename Type> void
cxx_boxed_to_rec (const GValue *src_value,
GValue *dest_value)
@@ -1046,7 +1033,6 @@ cxx_boxed_to_rec (const GValue *src_value,
}
sfi_value_take_rec (dest_value, rec);
}
-
template<typename Type> void
cxx_boxed_from_rec (const GValue *src_value,
GValue *dest_value)
@@ -1061,7 +1047,6 @@ cxx_boxed_from_rec (const GValue *src_value,
}
g_value_take_boxed (dest_value, boxed);
}
-
template<typename SeqType> void
cxx_boxed_to_seq (const GValue *src_value,
GValue *dest_value)
@@ -1078,7 +1063,6 @@ cxx_boxed_to_seq (const GValue *src_value,
}
sfi_value_take_seq (dest_value, seq);
}
-
template<typename SeqType> void
cxx_boxed_from_seq (const GValue *src_value,
GValue *dest_value)
@@ -1093,7 +1077,6 @@ cxx_boxed_from_seq (const GValue *src_value,
}
g_value_take_boxed (dest_value, boxed);
}
-
template<typename Type> RecordHandle<Type>
cxx_value_get_rec (const GValue *value)
{
@@ -1103,7 +1086,6 @@ cxx_value_get_rec (const GValue *value)
else
return INIT_NULL;
}
-
template<typename Type> void
cxx_value_set_rec (GValue *value,
const RecordHandle<Type> &self)
@@ -1113,7 +1095,6 @@ cxx_value_set_rec (GValue *value,
else
sfi_value_set_rec (value, NULL);
}
-
template<typename SeqType> SeqType
cxx_value_get_seq (const GValue *value)
{
@@ -1123,21 +1104,16 @@ cxx_value_get_seq (const GValue *value)
else
return SeqType();
}
-
template<typename SeqType> void
cxx_value_set_seq (GValue *value,
const SeqType &self)
{
sfi_value_take_seq (value, SeqType::to_seq (self));
}
-
// == C++ Auxillaries ==
struct Init { // stolen from Rapicorn
explicit Init (void (*f) ()) { f(); }
};
-
} // Sfi
-
#endif /* __SFI_CXX_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-cbase.cc b/sfi/sfidl-cbase.cc
index 195dfa5..fd51c7c 100644
--- a/sfi/sfidl-cbase.cc
+++ b/sfi/sfidl-cbase.cc
@@ -10,32 +10,26 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
using namespace Sfidl;
using std::min;
using std::max;
-
/*--- functions for "C and C++"-like languages ---*/
-
const gchar*
CodeGeneratorCBase::makeCStr (const String& str)
{
return g_intern_string (str.c_str());
}
-
String
CodeGeneratorCBase::makeGTypeName (const String& name)
{
return makeUpperName (NamespaceHelper::namespaceOf (name)
+ "::Type" + NamespaceHelper::nameOf(name));
}
-
String
CodeGeneratorCBase::makeParamSpec(const Param& pdef)
{
String pspec;
const String group = (pdef.group != "") ? pdef.group.escaped() : "NULL";
-
switch (parser.typeOf (pdef.type))
{
case CHOICE:
@@ -89,13 +83,11 @@ CodeGeneratorCBase::makeParamSpec(const Param& pdef)
}
return pspec;
}
-
String CodeGeneratorCBase::scatId (SfiSCategory c)
{
String s; s += (char) c;
return s;
}
-
// how "type" looks like when passed as argument to a function
String
CodeGeneratorCBase::typeArg (const String& type)
@@ -118,7 +110,6 @@ CodeGeneratorCBase::typeArg (const String& type)
}
return "*error*";
}
-
// how "type" looks like when stored as member in a struct or class
String
CodeGeneratorCBase::typeField (const String& type)
@@ -141,7 +132,6 @@ CodeGeneratorCBase::typeField (const String& type)
}
return "*error*";
}
-
// how the return type of a function returning "type" looks like
String
CodeGeneratorCBase::typeRet (const String& type)
@@ -164,14 +154,12 @@ CodeGeneratorCBase::typeRet (const String& type)
}
return "*error*";
}
-
// how an array of "type"s looks like ( == MODEL_MEMBER + "*" ?)
String
CodeGeneratorCBase::typeArray (const String& type)
{
return CodeGeneratorCBase::typeField (type) + "*";
}
-
// how to create a new "type" called "name" (blank return value allowed)
String
CodeGeneratorCBase::funcNew (const String& type)
@@ -194,7 +182,6 @@ CodeGeneratorCBase::funcNew (const String& type)
}
return NULL;
}
-
String
CodeGeneratorCBase::funcCopy (const String& type)
{
@@ -216,7 +203,6 @@ CodeGeneratorCBase::funcCopy (const String& type)
}
return NULL;
}
-
String
CodeGeneratorCBase::funcFree (const String& type)
{
@@ -238,12 +224,10 @@ CodeGeneratorCBase::funcFree (const String& type)
}
return NULL;
}
-
String CodeGeneratorCBase::createTypeCode (const String& type, TypeCodeModel model)
{
return createTypeCode (type, "", model);
}
-
String CodeGeneratorCBase::createTypeCode (const String& type, const String &name,
TypeCodeModel model)
{
@@ -257,7 +241,6 @@ String CodeGeneratorCBase::createTypeCode (const String& type, const String &nam
case MODEL_FROM_VALUE: g_assert (name != ""); break;
// how to convert the "type" called "name" to a GValue*
case MODEL_TO_VALUE: g_assert (name != ""); break;
-
/*
* vcall interface: the following models deal with how to perform a
* method/procedure invocation using a given data type
@@ -279,7 +262,6 @@ String CodeGeneratorCBase::createTypeCode (const String& type, const String &nam
// how to free (using GC) the result of the conversion (optional: "" if unused)
case MODEL_VCALL_RFREE: g_assert (name != ""); break;
}
-
switch (parser.typeOf (type))
{
case RECORD:
@@ -287,7 +269,6 @@ String CodeGeneratorCBase::createTypeCode (const String& type, const String &nam
{
if (model == MODEL_VCALL_RFREE)
return "if ("+name+" != NULL) sfi_glue_gc_add ("+name+", (SfiGlueGcFreeFunc) "+makeLowerName (type)+"_free)";
-
if (parser.isSequence (type))
{
if (model == MODEL_TO_VALUE)
@@ -441,9 +422,7 @@ String CodeGeneratorCBase::createTypeCode (const String& type, const String &nam
{
/* get rid of the Sfi:: (the code wasn't written for it) */
String ptype = NamespaceHelper::nameOf (type);
-
String sfi = (ptype == "void") ? "" : "Sfi"; /* there is no such thing as an SfiVoid */
-
if (model == MODEL_TO_VALUE) return "sfi_value_" + makeLowerName(ptype) + " ("+name+")";
if (model == MODEL_FROM_VALUE) return "sfi_value_get_" + makeLowerName(ptype) + " ("+name+")";
if (model == MODEL_VCALL) return "sfi_glue_vcall_" + makeLowerName(ptype);
@@ -465,9 +444,7 @@ String CodeGeneratorCBase::createTypeCode (const String& type, const String &nam
}
return "*createTypeCode*unknown*";
}
-
/*--- the C language binding ---*/
-
String CodeGeneratorCBase::makeProcName (const String& className,
const String& procName)
{
@@ -476,12 +453,10 @@ String CodeGeneratorCBase::makeProcName (const String& className,
else
return makeLowerName(className) + "_" + makeLowerName(procName);
}
-
void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const String& className)
{
vector<Param>::const_iterator pi;
String dname, mname = makeProcName (className, mdef.name);
-
if (className == "")
{
dname = makeLowerName(mdef.name, '-');
@@ -490,13 +465,11 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
{
dname = makeMixedName(className) + "+" + makeLowerName(mdef.name, '-');
}
-
bool first = true;
printf("%s%s%s (", cTypeRet (mdef.result.type), proto?" ":"\n", mname.c_str());
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
{
if (pi->name == "_object_id") continue; // C++ binding: get _object_id from class
-
if(!first) printf(", ");
first = false;
printf("%s %s", cTypeArg (pi->type), pi->name.c_str());
@@ -509,17 +482,13 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
printf(";\n");
return;
}
-
printf(" {\n");
-
String vret = createTypeCode (mdef.result.type, MODEL_VCALL_RET);
if (mdef.result.type != "void")
printf (" %s _retval;\n", vret.c_str());
-
String rfree = createTypeCode (mdef.result.type, "_retval_conv", MODEL_VCALL_RFREE);
if (rfree != "")
printf (" %s _retval_conv;\n", cTypeRet (mdef.result.type));
-
map<String, String> cname;
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
{
@@ -527,35 +496,29 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
if (conv != "")
{
cname[pi->name] = pi->name + "__c";
-
String arg = createTypeCode(pi->type, MODEL_VCALL_CARG);
printf(" %s %s__c = %s;\n", arg.c_str(), pi->name.c_str(), conv.c_str());
}
else
cname[pi->name] = pi->name;
}
-
printf(" ");
if (mdef.result.type != "void")
printf("_retval = ");
String vcall = createTypeCode(mdef.result.type, "", MODEL_VCALL);
printf("%s (\"%s\", ", vcall.c_str(), dname.c_str());
-
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
printf("%s ", createTypeCode(pi->type, cname[pi->name], MODEL_VCALL_ARG).c_str());
printf("0);\n");
-
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
{
String cfree = createTypeCode (pi->type, cname[pi->name], MODEL_VCALL_CFREE);
if (cfree != "")
printf(" %s;\n", cfree.c_str());
}
-
if (mdef.result.type != "void")
{
String rconv = createTypeCode (mdef.result.type, "_retval", MODEL_VCALL_RCONV);
-
if (rfree != "")
{
printf (" _retval_conv = %s;\n", rconv.c_str());
@@ -569,38 +532,30 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
}
printf("}\n\n");
}
-
static bool choiceReverseSort(const ChoiceValue& e1, const ChoiceValue& e2)
{
String ename1 = e1.name;
String ename2 = e2.name;
-
reverse (ename1.begin(), ename1.end());
reverse (ename2.begin(), ename2.end());
-
return ename1 < ename2;
}
-
void CodeGeneratorCBase::printChoiceConverters()
{
vector<Choice>::const_iterator ei;
-
for(ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
-
int minval = 1, maxval = 1;
vector<ChoiceValue>::iterator ci;
String name = makeLowerName (ei->name);
String arg = typeArg (ei->name);
-
/* produce reverse sorted enum array */
vector<ChoiceValue> components = ei->contents;
for (ci = components.begin(); ci != components.end(); ci++)
ci->name = makeLowerName (ci->name, '-');
sort (components.begin(), components.end(), ::choiceReverseSort);
-
printf("static const SfiConstants %s_vals[%zd] = {\n",name.c_str(), ei->contents.size());
for (ci = components.begin(); ci != components.end(); ci++)
{
@@ -610,7 +565,6 @@ void CodeGeneratorCBase::printChoiceConverters()
printf(" { \"%s\", %zd, %d },\n", ci->name.c_str(), ci->name.size(), value);
}
printf("};\n\n");
-
printf("const gchar*\n");
printf("%s_to_choice (%s value)\n", name.c_str(), arg.c_str());
printf("{\n");
@@ -618,7 +572,6 @@ void CodeGeneratorCBase::printChoiceConverters()
printf(" return sfi_constants_get_name (G_N_ELEMENTS (%s_vals), %s_vals, value);\n",
name.c_str(), name.c_str());
printf("}\n\n");
-
printf("%s\n", cTypeRet (ei->name));
printf("%s_from_choice (const gchar *choice)\n", name.c_str());
printf("{\n");
@@ -628,37 +581,30 @@ void CodeGeneratorCBase::printChoiceConverters()
printf("\n");
}
}
-
void CodeGeneratorCBase::printClientRecordPrototypes()
{
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String mname = makeMixedName (ri->name);
printf("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
-
void CodeGeneratorCBase::printClientSequencePrototypes()
{
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String mname = makeMixedName (si->name);
printf("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
-
void CodeGeneratorCBase::printClientRecordDefinitions()
{
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String mname = makeMixedName (ri->name.c_str());
-
printf("struct _%s {\n", mname.c_str());
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
@@ -668,34 +614,28 @@ void CodeGeneratorCBase::printClientRecordDefinitions()
}
printf("\n");
}
-
void CodeGeneratorCBase::printClientSequenceDefinitions()
{
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String mname = makeMixedName (si->name.c_str());
String array = typeArray (si->content.type);
String elements = si->content.name;
-
printf("struct _%s {\n", mname.c_str());
printf(" guint n_%s;\n", elements.c_str ());
printf(" %s %s;\n", array.c_str(), elements.c_str());
printf("};\n");
}
}
-
void CodeGeneratorCBase::printClientRecordMethodPrototypes (PrefixSymbolMode mode)
{
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String ret = typeRet (ri->name);
String arg = typeArg (ri->name);
String lname = makeLowerName (ri->name.c_str());
-
if (mode == generatePrefixSymbols)
{
prefix_symbols.push_back (lname + "_new");
@@ -716,18 +656,15 @@ void CodeGeneratorCBase::printClientRecordMethodPrototypes (PrefixSymbolMode mod
}
printf("\n");
}
-
void CodeGeneratorCBase::printClientSequenceMethodPrototypes (PrefixSymbolMode mode)
{
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String ret = typeRet (si->name);
String arg = typeArg (si->name);
String element = typeArg (si->content.type);
String lname = makeLowerName (si->name.c_str());
-
if (mode == generatePrefixSymbols)
{
prefix_symbols.push_back (lname + "_new");
@@ -751,20 +688,16 @@ void CodeGeneratorCBase::printClientSequenceMethodPrototypes (PrefixSymbolMode m
}
}
}
-
void CodeGeneratorCBase::printClientRecordMethodImpl()
{
vector<Param>::const_iterator pi;
-
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String ret = typeRet (ri->name);
String arg = typeArg (ri->name);
String lname = makeLowerName (ri->name.c_str());
String mname = makeMixedName (ri->name.c_str());
-
printf("%s\n", ret.c_str());
printf("%s_new (void)\n", lname.c_str());
printf("{\n");
@@ -782,7 +715,6 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
}
printf(" return rec;\n");
printf("}\n\n");
-
printf("%s\n", ret.c_str());
printf("%s_copy_shallow (%s rec)\n", lname.c_str(), arg.c_str());
printf("{\n");
@@ -801,7 +733,6 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
}
printf(" return rec_copy;\n");
printf("}\n\n");
-
printf("%s\n", ret.c_str());
printf("%s_from_rec (SfiRec *sfi_rec)\n", lname.c_str());
printf("{\n");
@@ -815,11 +746,9 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
{
String elementFromValue = createTypeCode (pi->type, "element", MODEL_FROM_VALUE);
String init = funcNew (pi->type);
-
printf(" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
printf(" if (element)\n");
printf(" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
-
if (init != "")
{
printf(" else\n");
@@ -828,7 +757,6 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
}
printf(" return rec;\n");
printf("}\n\n");
-
printf("SfiRec *\n");
printf("%s_to_rec (%s rec)\n", lname.c_str(), arg.c_str());
printf("{\n");
@@ -847,7 +775,6 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
}
printf(" return sfi_rec;\n");
printf("}\n\n");
-
printf("void\n");
printf("%s_free (%s rec)\n", lname.c_str(), arg.c_str());
printf("{\n");
@@ -867,26 +794,22 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
printf("\n");
}
}
-
void CodeGeneratorCBase::printClientSequenceMethodImpl()
{
for(vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String ret = typeRet (si->name);
String arg = typeArg (si->name);
String element = typeArg (si->content.type);
String elements = si->content.name;
String lname = makeLowerName (si->name.c_str());
String mname = makeMixedName (si->name.c_str());
-
printf("%s\n", ret.c_str());
printf("%s_new (void)\n", lname.c_str());
printf("{\n");
printf(" return g_new0 (%s, 1);\n",mname.c_str());
printf("}\n\n");
-
String elementCopy = funcCopy (si->content.type);
printf("void\n");
printf("%s_append (%s seq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
@@ -898,7 +821,6 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
printf(" seq->%s[seq->n_%s++] = %s (element);\n", elements.c_str(), elements.c_str(),
elementCopy.c_str());
printf("}\n\n");
-
printf("%s\n", ret.c_str());
printf("%s_copy_shallow (%s seq)\n", lname.c_str(), arg.c_str());
printf("{\n");
@@ -912,7 +834,6 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
printf(" %s_append (seq_copy, seq->%s[i]);\n", lname.c_str(), elements.c_str());
printf(" return seq_copy;\n");
printf("}\n\n");
-
String elementFromValue = createTypeCode (si->content.type, "element", MODEL_FROM_VALUE);
printf("%s\n", ret.c_str());
printf("%s_from_seq (SfiSeq *sfi_seq)\n", lname.c_str());
@@ -934,7 +855,6 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
printf(" }\n");
printf(" return seq;\n");
printf("}\n\n");
-
String elementToValue = createTypeCode (si->content.type, "seq->" + elements + "[i]", MODEL_TO_VALUE);
printf("SfiSeq *\n");
printf("%s_to_seq (%s seq)\n", lname.c_str(), arg.c_str());
@@ -953,7 +873,6 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
printf(" }\n");
printf(" return sfi_seq;\n");
printf("}\n\n");
-
// FIXME: we should check whether we _really_ need to deal with a seperate free_check
// function here, as it needs to be specialcased everywhere
//
@@ -996,7 +915,6 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
}
printf(" seq->n_%s = new_size;\n", elements.c_str());
printf("}\n\n");
-
printf("void\n");
printf("%s_free (%s seq)\n", lname.c_str(), arg.c_str());
printf("{\n");
@@ -1016,13 +934,11 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
printf("\n");
}
}
-
void CodeGeneratorCBase::printClientChoiceDefinitions()
{
for(vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
String mname = makeMixedName (ci->name);
String lname = makeLowerName (ci->name);
printf("\ntypedef enum {\n");
@@ -1036,16 +952,13 @@ void CodeGeneratorCBase::printClientChoiceDefinitions()
}
printf("\n");
}
-
void CodeGeneratorCBase::printClientChoiceConverterPrototypes (PrefixSymbolMode mode)
{
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
String mname = makeMixedName (ci->name);
String lname = makeLowerName (ci->name);
-
if (mode == generatePrefixSymbols)
{
prefix_symbols.push_back (lname + "_to_choice");
@@ -1059,6 +972,4 @@ void CodeGeneratorCBase::printClientChoiceConverterPrototypes (PrefixSymbolMode
}
printf("\n");
}
-
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-cbase.hh b/sfi/sfidl-cbase.hh
index cd00ed8..eda0c79 100644
--- a/sfi/sfidl-cbase.hh
+++ b/sfi/sfidl-cbase.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_CBASE_H__
#define __SFIDL_CBASE_H__
-
#include <map>
#include <iostream>
#include <algorithm>
@@ -10,107 +9,80 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfidl-generator.hh"
-
namespace Sfidl {
-
/*
* Base class for C and C++-like CodeGenerators
*/
class CodeGeneratorCBase : public CodeGenerator {
protected:
bool generateBoxedTypes;
-
enum TypeCodeModel {
MODEL_FROM_VALUE, MODEL_TO_VALUE,
MODEL_VCALL, MODEL_VCALL_ARG,
MODEL_VCALL_CARG, MODEL_VCALL_CONV, MODEL_VCALL_CFREE,
MODEL_VCALL_RET, MODEL_VCALL_RCONV, MODEL_VCALL_RFREE
};
-
enum PrefixSymbolMode { generateOutput, generatePrefixSymbols };
std::vector<String> prefix_symbols; /* symbols which should get a namespace prefix */
-
const gchar *makeCStr (const String& str);
-
String scatId (SfiSCategory c);
-
/* record/sequence binding used by --host-c and --client-c binding */
void printClientRecordPrototypes();
void printClientSequencePrototypes();
-
void printClientRecordDefinitions();
void printClientSequenceDefinitions();
-
void printClientRecordMethodPrototypes (PrefixSymbolMode mode);
void printClientSequenceMethodPrototypes (PrefixSymbolMode mode);
-
void printClientRecordMethodImpl();
void printClientSequenceMethodImpl();
-
void printClientChoiceDefinitions();
void printClientChoiceConverterPrototypes (PrefixSymbolMode mode);
-
void printProcedure (const Method& mdef, bool proto = false, const String& className = "");
void printChoiceConverters ();
-
virtual String makeProcName (const String& className, const String& procName);
-
String makeGTypeName (const String& name);
String makeParamSpec (const Param& pdef);
String createTypeCode (const String& type, TypeCodeModel model);
-
/*
* data types: the following models deal with how to represent a certain
* SFI type in the binding
*/
-
// how "type" looks like when passed as argument to a function
virtual String typeArg (const String& type);
const gchar *cTypeArg (const String& type) { return makeCStr (typeArg (type)); }
-
// how "type" looks like when stored as member in a struct or class
virtual String typeField (const String& type);
const gchar *cTypeField (const String& type) { return makeCStr (typeField (type)); }
-
// how the return type of a function returning "type" looks like
virtual String typeRet (const String& type);
const gchar *cTypeRet (const String& type) { return makeCStr (typeRet (type)); }
-
// how an array of "type"s looks like ( == MODEL_MEMBER + "*" ?)
virtual String typeArray (const String& type);
const gchar *cTypeArray (const String& type) { return makeCStr (typeArray (type)); }
-
/*
* function required to create a new "type" (blank return value allowed)
* example: funcNew ("FBlock") => "sfi_fblock_new" (in C)
*/
virtual String funcNew (const String& type);
const gchar *cFuncNew (const String& type) { return makeCStr (funcNew (type)); }
-
/*
* function required to copy a "type" (blank return value allowed)
* example: funcCopy ("FBlock") => "sfi_fblock_ref" (in C)
*/
virtual String funcCopy (const String& type);
const gchar *cFuncCopy (const String& type) { return makeCStr (funcNew (type)); }
-
/*
* function required to free a "type" (blank return value allowed)
* example: funcFree ("FBlock") => "sfi_fblock_unref" (in C)
*/
virtual String funcFree (const String& type);
const gchar *cFuncFree (const String& type) { return makeCStr (funcNew (type)); }
-
virtual String createTypeCode (const String& type, const String& name,
TypeCodeModel model);
-
CodeGeneratorCBase (const Parser& parser) : CodeGenerator (parser) {
generateBoxedTypes = false;
}
};
-
};
-
#endif /* __SFIDL_CBASE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-clientc.cc b/sfi/sfidl-clientc.cc
index bb929e6..f1f38c8 100644
--- a/sfi/sfidl-clientc.cc
+++ b/sfi/sfidl-clientc.cc
@@ -5,52 +5,41 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include <stdio.h>
-
using namespace Sfidl;
using std::make_pair;
-
void CodeGeneratorClientC::printClassMacros()
{
for (vector<Class>::const_iterator ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
String macro = makeUpperName (NamespaceHelper::namespaceOf (ci->name)) + "_IS_" +
makeUpperName (NamespaceHelper::nameOf (ci->name));
String mname = makeMixedName (ci->name);
-
printf ("#define %s(proxy) bse_proxy_is_a ((proxy), \"%s\")\n",
macro.c_str(), mname.c_str());
}
printf("\n");
}
-
Method CodeGeneratorClientC::methodWithObject (const Class& c, const Method& method)
{
Method md;
md.name = method.name;
md.result = method.result;
-
Param class_as_param;
class_as_param.name = makeLowerName(c.name) + "_object";
class_as_param.type = c.name;
md.params.push_back (class_as_param);
-
for (vector<Param>::const_iterator pi = method.params.begin(); pi != method.params.end(); pi++)
md.params.push_back (*pi);
-
return md;
}
-
void CodeGeneratorClientC::printProcedurePrototypes (PrefixSymbolMode mode)
{
vector<Class>::const_iterator ci;
vector<Method>::const_iterator mi;
-
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
for (mi = ci->methods.begin(); mi != ci->methods.end(); mi++)
{
if (mode == generatePrefixSymbols)
@@ -62,50 +51,41 @@ void CodeGeneratorClientC::printProcedurePrototypes (PrefixSymbolMode mode)
for (mi = parser.getProcedures().begin(); mi != parser.getProcedures().end(); mi++)
{
if (parser.fromInclude (mi->name)) continue;
-
if (mode == generatePrefixSymbols)
prefix_symbols.push_back (makeLowerName (mi->name));
else
printProcedure (*mi, true);
}
}
-
void CodeGeneratorClientC::printProcedureImpl ()
{
vector<Class>::const_iterator ci;
vector<Method>::const_iterator mi;
-
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
for (mi = ci->methods.begin(); mi != ci->methods.end(); mi++)
printProcedure (methodWithObject (*ci, *mi), false, ci->name);
}
for (mi = parser.getProcedures().begin(); mi != parser.getProcedures().end(); mi++)
{
if (parser.fromInclude (mi->name)) continue;
-
printProcedure (*mi, false);
}
}
-
void
CodeGeneratorClientC::addBindingSpecificFiles (const String& binding_specific_file)
{
vector<Pragma> pragmas = parser.getPragmas ("ClientC");
-
for (vector<Pragma>::iterator pi = pragmas.begin(); pi != pragmas.end(); pi++)
{
if (pi->fromInclude) continue;
-
String filename;
if (pi->getString (binding_specific_file, filename))
{
gchar *directory = g_path_get_dirname (pi->filename.c_str());
filename = directory + String (G_DIR_SEPARATOR_S) + filename;
g_free (directory);
-
printf ("/* %s: including binding specific file \"%s\", as requested in %s:%d */\n",
options.sfidlName.c_str(), filename.c_str(), pi->filename.c_str(), pi->line);
FILE *f = fopen (filename.c_str(), "r");
@@ -125,72 +105,55 @@ CodeGeneratorClientC::addBindingSpecificFiles (const String& binding_specific_fi
}
}
}
-
bool CodeGeneratorClientC::run()
{
printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
-
if (generateHeader)
{
/* namespace prefixing for symbols defined by the client */
-
prefix_symbols.clear();
-
printClientChoiceConverterPrototypes (generatePrefixSymbols);
printClientRecordMethodPrototypes (generatePrefixSymbols);
printClientSequenceMethodPrototypes (generatePrefixSymbols);
printProcedurePrototypes (generatePrefixSymbols);
-
if (prefix != "")
{
for (vector<String>::const_iterator pi = prefix_symbols.begin(); pi != prefix_symbols.end(); pi++)
printf("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
printf("\n");
}
-
/* generate the header */
-
printClientRecordPrototypes();
printClientSequencePrototypes();
-
printClientChoiceDefinitions();
printClientRecordDefinitions();
printClientSequenceDefinitions();
-
printClientRecordMethodPrototypes (generateOutput);
printClientSequenceMethodPrototypes (generateOutput);
printClientChoiceConverterPrototypes (generateOutput);
printProcedurePrototypes (generateOutput);
-
printClassMacros();
addBindingSpecificFiles ("binding_specific_c_header");
}
-
if (generateSource)
{
printf("#include <string.h>\n");
-
printClientRecordMethodImpl();
printClientSequenceMethodImpl();
printChoiceConverters();
printProcedureImpl();
addBindingSpecificFiles ("binding_specific_c_source");
}
-
printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
-
OptionVector
CodeGeneratorClientC::getOptions()
{
OptionVector opts = CodeGeneratorCBase::getOptions();
-
opts.push_back (make_pair ("--prefix", true));
-
return opts;
}
-
void
CodeGeneratorClientC::setOption (const String& option, const String& value)
{
@@ -203,27 +166,21 @@ CodeGeneratorClientC::setOption (const String& option, const String& value)
CodeGeneratorCBase::setOption (option, value);
}
}
-
void
CodeGeneratorClientC::help ()
{
CodeGeneratorCBase::help();
fprintf (stderr, " --prefix <prefix> set the prefix for C functions\n");
}
-
namespace {
-
class ClientCFactory : public Factory {
public:
String option() const { return "--client-c"; }
String description() const { return "generate client C language binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new CodeGeneratorClientC (parser);
}
} client_c_factory;
-
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-clientc.hh b/sfi/sfidl-clientc.hh
index 119ecce..2fba238 100644
--- a/sfi/sfidl-clientc.hh
+++ b/sfi/sfidl-clientc.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_CLIENTC_H__
#define __SFIDL_CLIENTC_H__
-
#include <map>
#include <iostream>
#include <algorithm>
@@ -11,31 +10,23 @@
#include "sfidl-parser.hh"
#include "sfidl-cbase.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
namespace Sfidl {
-
class CodeGeneratorClientC : public CodeGeneratorCBase {
protected:
String prefix;
-
Method methodWithObject (const Class& cd, const Method& md);
void printProcedurePrototypes (PrefixSymbolMode mode);
void printClassMacros();
void printProcedureImpl ();
void addBindingSpecificFiles (const String& binding_specific_files);
-
public:
CodeGeneratorClientC(const Parser& parser) : CodeGeneratorCBase (parser) {
}
void help ();
bool run ();
-
OptionVector getOptions();
void setOption (const String& option, const String& value);
};
-
};
-
#endif /* __SFIDL_CLIENTC_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-clientcxx.cc b/sfi/sfidl-clientcxx.cc
index 0facef6..fd6f143 100644
--- a/sfi/sfidl-clientcxx.cc
+++ b/sfi/sfidl-clientcxx.cc
@@ -10,10 +10,8 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
using namespace Sfidl;
using std::make_pair;
-
String
CodeGeneratorClientCxx::typeArg (const String& type)
{
@@ -27,7 +25,6 @@ CodeGeneratorClientCxx::typeArg (const String& type)
default: return CodeGeneratorCBase::typeArg (type);
}
}
-
String
CodeGeneratorClientCxx::typeField (const String& type)
{
@@ -41,7 +38,6 @@ CodeGeneratorClientCxx::typeField (const String& type)
default: return CodeGeneratorCBase::typeArg (type);
}
}
-
String
CodeGeneratorClientCxx::typeRet (const String& type)
{
@@ -55,7 +51,6 @@ CodeGeneratorClientCxx::typeRet (const String& type)
default: return CodeGeneratorCBase::typeArg (type);
}
}
-
String
CodeGeneratorClientCxx::funcNew (const String& type)
{
@@ -65,7 +60,6 @@ CodeGeneratorClientCxx::funcNew (const String& type)
default: return CodeGeneratorCBase::funcNew (type);
}
}
-
String
CodeGeneratorClientCxx::funcCopy (const String& type)
{
@@ -75,7 +69,6 @@ CodeGeneratorClientCxx::funcCopy (const String& type)
default: return CodeGeneratorCBase::funcCopy (type);
}
}
-
String
CodeGeneratorClientCxx::funcFree (const String& type)
{
@@ -85,7 +78,6 @@ CodeGeneratorClientCxx::funcFree (const String& type)
default: return CodeGeneratorCBase::funcFree (type);
}
}
-
String CodeGeneratorClientCxx::createTypeCode (const String& type, const String& name,
TypeCodeModel model)
{
@@ -146,13 +138,11 @@ String CodeGeneratorClientCxx::createTypeCode (const String& type, const String&
}
return CodeGeneratorCBase::createTypeCode (type, name, model);
}
-
static const char*
cUC_NAME (const String &cstr) // FIXME: need mammut renaming function
{
return g_intern_string (cstr.c_str());
}
-
void
CodeGeneratorClientCxx::printChoicePrototype (NamespaceHelper& nspace)
{
@@ -167,7 +157,6 @@ CodeGeneratorClientCxx::printChoicePrototype (NamespaceHelper& nspace)
printf ("static inline SfiChoiceValues %s_choice_values();\n", name.c_str());
}
}
-
void
CodeGeneratorClientCxx::printChoiceImpl (NamespaceHelper& nspace)
{
@@ -193,60 +182,45 @@ CodeGeneratorClientCxx::printChoiceImpl (NamespaceHelper& nspace)
printf ("}\n\n");
}
}
-
void
CodeGeneratorClientCxx::printRecSeqForwardDecl (NamespaceHelper& nspace)
{
vector<Sequence>::const_iterator si;
vector<Record>::const_iterator ri;
-
printf ("\n/* record/sequence prototypes */\n");
-
/* forward declarations for records */
for (ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
-
nspace.setFromSymbol(ri->name);
String name = nspace.printableForm (ri->name);
-
printf("\n");
printf("class %s;\n", name.c_str());
printf("typedef Sfi::RecordHandle<%s> %sHandle;\n", name.c_str(), name.c_str());
}
-
/* forward declarations for sequences */
for (si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
nspace.setFromSymbol(si->name);
String name = nspace.printableForm (si->name);
-
printf("\n");
printf("class %s;\n", name.c_str());
}
}
-
void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
{
vector<Param>::const_iterator pi;
-
printf ("\n/* record/sequence definitions */\n");
-
/* sequences */
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
nspace.setFromSymbol(si->name);
-
/* FIXME: need optimized refcounted copy-on-write sequences as base types */
-
String name = nspace.printableForm (si->name);
String content = typeField (si->content.type);
-
printf ("\n");
printf ("class %s : public Sfi::Sequence<%s> {\n", name.c_str(), content.c_str());
printf ("public:\n");
@@ -259,16 +233,13 @@ void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
printf("};\n");
printf ("\n");
}
-
/* records */
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
nspace.setFromSymbol(ri->name);
String name = nspace.printableForm (ri->name);
String type_name = makeMixedName (ri->name).c_str();
-
printf ("\n");
printf ("class %s : public ::Sfi::GNewable {\n", name.c_str());
printf ("public:\n");
@@ -286,11 +257,9 @@ void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
printf ("\n");
}
}
-
void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
{
printf ("\n/* record/sequence implementations */\n");
-
/* sequence members */
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
@@ -300,7 +269,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
String name = nspace.printableForm (si->name);
String nname = si->name;
String type_name = makeMixedName (si->name).c_str();
-
String elementFromValue = createTypeCode (si->content.type, "element", MODEL_FROM_VALUE);
printf("%s\n", cTypeRet (si->name));
printf("%s::from_seq (SfiSeq *sfi_seq)\n", nname.c_str());
@@ -319,7 +287,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
printf(" }\n");
printf(" return seq;\n");
printf("}\n\n");
-
String elementToValue = createTypeCode (si->content.type, "seq[i]", MODEL_TO_VALUE);
printf("SfiSeq *\n");
printf("%s::to_seq (%s seq)\n", nname.c_str(), cTypeArg (si->name));
@@ -333,7 +300,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
printf(" }\n");
printf(" return sfi_seq;\n");
printf("}\n\n");
-
printf ("%s\n", cTypeRet (si->name));
printf ("%s::value_get_seq (const GValue *value)\n", nname.c_str());
printf ("{\n");
@@ -345,7 +311,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
printf (" ::Sfi::cxx_value_set_seq< %s> (value, self);\n", nname.c_str());
printf ("}\n\n");
}
-
/* record members */
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
@@ -355,7 +320,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
String name = nspace.printableForm (ri->name);
String nname = ri->name;
String type_name = makeMixedName (ri->name).c_str();
-
printf("%s\n", cTypeRet (ri->name));
printf("%s::from_rec (SfiRec *sfi_rec)\n", nname.c_str());
printf("{\n");
@@ -368,14 +332,12 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
String elementFromValue = createTypeCode (pi->type, "element", MODEL_FROM_VALUE);
-
printf(" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
printf(" if (element)\n");
printf(" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
}
printf(" return rec;\n");
printf("}\n\n");
-
printf("SfiRec *\n");
printf("%s::to_rec (%s rec)\n", nname.c_str(), cTypeArg (ri->name));
printf("{\n");
@@ -395,7 +357,6 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
}
printf(" return sfi_rec;\n");
printf("}\n\n");
-
printf ("%s\n", cTypeRet(ri->name));
printf ("%s::value_get_rec (const GValue *value)\n", nname.c_str());
printf ("{\n");
@@ -408,25 +369,20 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
printf ("}\n\n");
}
}
-
bool CodeGeneratorClientCxx::run ()
{
vector<Choice>::const_iterator ei;
vector<Param>::const_iterator pi;
vector<Class>::const_iterator ci;
vector<Method>::const_iterator mi;
-
printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
-
if (generateHeader)
{
/* choices */
for(ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name)) continue;
-
nspace.setFromSymbol (ei->name);
-
printf("\nenum %s {\n", nspace.printableForm (ei->name).c_str());
for (vector<ChoiceValue>::const_iterator ci = ei->contents.begin(); ci != ei->contents.end(); ci++)
{
@@ -437,39 +393,30 @@ bool CodeGeneratorClientCxx::run ()
printf("};\n");
}
nspace.leaveAll();
-
/* choice converters */
for(ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
String name = nspace.printableForm (ei->name);
String lname = makeLowerName (ei->name);
-
printf("const gchar* %s_to_choice (%s value);\n", lname.c_str(), name.c_str());
printf("%s %s_from_choice (const gchar *choice);\n", name.c_str(), lname.c_str());
}
-
printf("\n");
/* prototypes for classes */
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
nspace.setFromSymbol (ci->name);
String name = nspace.printableForm (ci->name);
-
printf("class %s;\n", name.c_str());
}
-
printRecSeqForwardDecl (nspace);
-
/* classes */
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name)) continue;
-
nspace.setFromSymbol (ci->name);
String name = nspace.printableForm (ci->name);
-
String init;
printf("\n");
if (ci->inherits == "")
@@ -498,13 +445,11 @@ bool CodeGeneratorClientCxx::run ()
printRecSeqDefinition (nspace);
printRecSeqImpl (nspace);
}
-
if (generateSource)
{
/* choice utils */
printChoiceConverters();
printf("\n");
-
/* methods */
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
@@ -513,12 +458,10 @@ bool CodeGeneratorClientCxx::run ()
printProperties(*ci);
}
}
-
printf("\n");
for (mi = parser.getProcedures().begin(); mi != parser.getProcedures().end(); mi++)
{
if (parser.fromInclude (mi->name)) continue;
-
if (generateHeader)
nspace.setFromSymbol (mi->name);
printProcedure (*mi, generateHeader);
@@ -526,10 +469,8 @@ bool CodeGeneratorClientCxx::run ()
printf("\n");
nspace.leaveAll();
printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
-
return 1;
}
-
String CodeGeneratorClientCxx::makeProcName (const String& className, const String& procName)
{
if (className == "")
@@ -545,37 +486,30 @@ String CodeGeneratorClientCxx::makeProcName (const String& className, const Stri
return className + "::" + makeStyleName (procName);
}
}
-
void CodeGeneratorClientCxx::printMethods (const Class& cdef)
{
vector<Method>::const_iterator mi;
vector<Param>::const_iterator pi;
bool proto = generateHeader;
-
for (mi = cdef.methods.begin(); mi != cdef.methods.end(); mi++)
{
Method md;
md.name = mi->name;
md.result = mi->result;
-
Param class_as_param;
class_as_param.name = "_object_id";
class_as_param.type = cdef.name;
md.params.push_back (class_as_param);
-
for(pi = mi->params.begin(); pi != mi->params.end(); pi++)
md.params.push_back (*pi);
-
if (proto) printf (" ");
printProcedure (md, proto, cdef.name);
}
}
-
void CodeGeneratorClientCxx::printProperties (const Class& cdef)
{
vector<Param>::const_iterator pi;
bool proto = generateHeader;
-
for (pi = cdef.properties.begin(); pi != cdef.properties.end(); pi++)
{
String setProperty = makeStyleName ("set_" + pi->name);
@@ -586,7 +520,6 @@ void CodeGeneratorClientCxx::printProperties (const Class& cdef)
if (proto) {
/* property getter */
printf (" %s %s ();\n", ret.c_str(), getProperty.c_str());
-
/* property setter */
printf (" void %s (%s %s);\n", setProperty.c_str(), cTypeArg (pi->type), newName.c_str());
}
@@ -614,18 +547,14 @@ void CodeGeneratorClientCxx::printProperties (const Class& cdef)
}
}
}
-
OptionVector
CodeGeneratorClientCxx::getOptions()
{
OptionVector opts = CodeGeneratorCxxBase::getOptions();
-
opts.push_back (make_pair ("--lower", false));
opts.push_back (make_pair ("--mixed", false));
-
return opts;
}
-
void
CodeGeneratorClientCxx::setOption (const String& option, const String& value)
{
@@ -642,7 +571,6 @@ CodeGeneratorClientCxx::setOption (const String& option, const String& value)
CodeGeneratorCxxBase::setOption (option, value);
}
}
-
void
CodeGeneratorClientCxx::help()
{
@@ -653,27 +581,21 @@ CodeGeneratorClientCxx::help()
fprintf (stderr, " --namespace <namespace> set the namespace to use for the code\n");
*/
}
-
String CodeGeneratorClientCxx::makeStyleName (const String& name)
{
if (style == STYLE_MIXED)
return makeLMixedName (name);
return makeLowerName (name);
}
-
-
namespace {
-
class ClientCxxFactory : public Factory {
public:
String option() const { return "--client-cxx"; }
String description() const { return "generate client C++ language binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new CodeGeneratorClientCxx (parser);
}
} cxx_factory;
-
}
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-clientcxx.hh b/sfi/sfidl-clientcxx.hh
index d2117a8..e418f08 100644
--- a/sfi/sfidl-clientcxx.hh
+++ b/sfi/sfidl-clientcxx.hh
@@ -1,53 +1,40 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_CLIENTCXX_H__
#define __SFIDL_CLIENTCXX_H__
-
#include "sfidl-cxxbase.hh"
#include "sfidl-namespace.hh"
-
namespace Sfidl {
-
class CodeGeneratorClientCxx : public CodeGeneratorCxxBase {
protected:
NamespaceHelper nspace;
-
using CodeGeneratorCBase::createTypeCode;
String createTypeCode (const String& type, const String& name,
TypeCodeModel model);
-
String typeArg (const String& type);
String typeField (const String& type);
String typeRet (const String& type);
String funcNew (const String& type);
String funcCopy (const String& type);
String funcFree (const String& type);
-
void printChoicePrototype (NamespaceHelper& nspace);
void printChoiceImpl (NamespaceHelper& nspace);
void printRecSeqForwardDecl (NamespaceHelper& nspace);
void printRecSeqDefinition (NamespaceHelper& nspace);
void printRecSeqImpl (NamespaceHelper& nspace);
-
enum Style { STYLE_LOWER, STYLE_MIXED };
Style style;
-
String makeStyleName (const String& name);
String makeProcName (const String& className, const String& procName);
-
void printMethods (const Class& cdef);
void printProperties (const Class& cdef);
-
public:
CodeGeneratorClientCxx (const Parser& parser) : CodeGeneratorCxxBase (parser), nspace (stdout), style (STYLE_LOWER) {
}
void help ();
bool run ();
-
OptionVector getOptions();
void setOption (const String& option, const String& value);
};
};
-
#endif /* __SFIDL_CLIENTCXX_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-corec.cc b/sfi/sfidl-corec.cc
index 81b27a7..e480758 100644
--- a/sfi/sfidl-corec.cc
+++ b/sfi/sfidl-corec.cc
@@ -7,12 +7,9 @@
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
-
namespace {
-
using namespace Sfidl;
using std::make_pair;
-
class CodeGeneratorCoreC : public CodeGenerator {
const char*
intern (const String &str)
@@ -54,15 +51,12 @@ class CodeGeneratorCoreC : public CodeGenerator {
const Map<String,IString> &infos)
{
printf ("static const gchar *%s[] = {\n", name.c_str());
-
Map<String,IString>::const_iterator ii;
for (ii = infos.begin(); ii != infos.end(); ii++)
printf (" \"%s=%s\",\n", ii->first.c_str(), ii->second.c_str());
-
printf (" NULL,\n");
printf ("};\n");
}
-
void
help()
{
@@ -73,9 +67,7 @@ class CodeGeneratorCoreC : public CodeGenerator {
getOptions()
{
OptionVector opts = CodeGenerator::getOptions();
-
opts.push_back (make_pair ("--init", true));
-
return opts;
}
void
@@ -91,7 +83,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
CodeGenerator::setOption (option, value);
}
}
-
const char*
TypeName (const String &type_name,
const String &append = "")
@@ -196,7 +187,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
pspec += " (" + group + ",\"" + pdef.name + "\"," + pdef.args + parg + ")";
return pspec;
}
-
void
generate_enum_type_id_prototypes ()
{
@@ -320,10 +310,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" }\n");
printf (" return choice_values;\n");
printf ("}\n");
-
printf ("GType %s = 0;\n", make_TYPE_MACRO (ei->name));
printf ("\n");
-
enumCount++;
}
if (enumCount)
@@ -355,9 +343,7 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String mname = makeMixedName (ri->name.c_str());
-
printf ("struct _%s {\n", mname.c_str());
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
@@ -417,11 +403,9 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String ret = TypeRet (ri->name);
String arg = TypeArg (ri->name);
String lname = makeLowerName (ri->name.c_str());
-
printf ("SfiRecFields %s_get_fields (void);\n", lname.c_str());
printf ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
printf ("%s %s_copy_shallow (%s rec);\n", ret.c_str(), lname.c_str(), arg.c_str());
@@ -441,7 +425,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
continue;
String ret = TypeRet (ri->name);
const gchar *type = make_fqtn (ri->name);
-
printf ("static inline %s\n", ret.c_str());
printf ("hack_cast (%s *cxxstruct)\n", type);
printf ("{\n");
@@ -466,22 +449,18 @@ class CodeGeneratorCoreC : public CodeGenerator {
String arg = TypeArg (ri->name);
String lname = makeLowerName (ri->name.c_str());
String mname = makeMixedName (ri->name.c_str());
-
const gchar *type = make_fqtn (ri->name);
-
printf ("SfiRecFields\n");
printf ("%s_get_fields (void)\n", lname.c_str());
printf ("{\n");
printf (" return %s::get_fields ();\n", type);
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_new (void)\n", lname.c_str());
printf ("{\n");
printf (" %sHandle rh (Sfi::INIT_DEFAULT); \n", type);
printf (" return hack_cast (rh.steal());\n");
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_copy_shallow (%s cstruct)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -489,14 +468,12 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" rh.set_boxed (hack_cast (cstruct));\n");
printf (" return hack_cast (rh.steal());\n");
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_from_rec (SfiRec *rec)\n", lname.c_str());
printf ("{\n");
printf (" %sHandle rh = %s::from_rec (rec);\n", type, type);
printf (" return hack_cast (rh.steal());\n");
printf ("}\n");
-
printf ("SfiRec*\n");
printf ("%s_to_rec (%s cstruct)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -504,7 +481,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" rh.set_boxed (hack_cast (cstruct));\n");
printf (" return %s::to_rec (rh);\n", type);
printf ("}\n");
-
printf ("void\n");
printf ("%s_free (%s cstruct)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -522,21 +498,16 @@ class CodeGeneratorCoreC : public CodeGenerator {
{
if (parser.fromInclude (ri->name))
continue;
-
String name = makeLowerName (ri->name);
-
printf ("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
printf ("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
-
String mname = makeMixedName (ri->name);
-
printf ("static void\n");
printf ("%s_boxed2rec (const GValue *src_value, GValue *dest_value)\n", name.c_str());
printf ("{\n");
printf (" gpointer boxed = g_value_get_boxed (src_value);\n");
printf (" sfi_value_take_rec (dest_value, boxed ? %s_to_rec (boxed) : NULL);\n", name.c_str());
printf ("}\n");
-
printf ("static void\n");
printf ("%s_rec2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
printf ("{\n");
@@ -544,7 +515,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" g_value_take_boxed (dest_value,\n");
printf (" rec ? %s_from_rec (rec) : NULL);\n", name.c_str());
printf ("}\n");
-
printInfoStrings (name + "_info_strings", ri->infos);
printf ("static SfiBoxedRecordInfo %s_boxed_info = {\n", name.c_str());
printf (" \"%s\",\n", mname.c_str());
@@ -575,11 +545,9 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String mname = makeMixedName (si->name.c_str());
String array = String (TypeField (si->content.type)) + "*";
String elements = si->content.name;
-
printf ("struct _%s {\n", mname.c_str());
printf (" guint n_%s;\n", elements.c_str ());
printf (" %s %s;\n", array.c_str(), elements.c_str());
@@ -637,12 +605,10 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String ret = TypeRet (si->name);
String arg = TypeArg (si->name);
String element = TypeArg (si->content.type);
String lname = makeLowerName (si->name.c_str());
-
printf ("GParamSpec* %s_get_element (void);\n", lname.c_str());
printf ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
printf ("void %s_append (%s seq, %s element);\n", lname.c_str(), arg.c_str(), element.c_str());
@@ -664,7 +630,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
continue;
String ret = TypeRet (si->name);
const gchar *type = make_fqtn (si->name);
-
/* the cast functions take an extra unused sequence argument, to distinguish
* two sequences A and B which both have the same CSeq type (e.g. SfiInt and SfiNote).
*/
@@ -693,22 +658,18 @@ class CodeGeneratorCoreC : public CodeGenerator {
String element = TypeArg (si->content.type);
String elements = si->content.name;
String lname = makeLowerName (si->name.c_str());
-
const gchar *type = make_fqtn (si->name);
-
printf ("GParamSpec*\n");
printf ("%s_get_element (void)\n", lname.c_str());
printf ("{\n");
printf (" return %s::get_element ();\n", type);
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_new (void)\n", lname.c_str());
printf ("{\n");
printf (" %s sh (0);\n", type);
printf (" return hack_cast (sh, sh.steal());\n");
printf ("}\n");
-
printf ("void\n");
printf ("%s_append (%s cseq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
printf ("{\n");
@@ -718,7 +679,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" sh += %s;\n", cxx_handle (si->content.type, "element"));
printf (" sh.steal(); /* prevent cseq deletion */\n");
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_copy_shallow (%s cseq)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -726,14 +686,12 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" sh.set_boxed (hack_cast (cseq));\n");
printf (" return hack_cast (sh, sh.steal());\n");
printf ("}\n");
-
printf ("%s\n", ret.c_str());
printf ("%s_from_seq (SfiSeq *seq)\n", lname.c_str());
printf ("{\n");
printf (" %s sh = %s::from_seq (seq);\n", type, type);
printf (" return hack_cast (sh, sh.steal());\n");
printf ("}\n");
-
printf ("SfiSeq*\n");
printf ("%s_to_seq (%s cseq)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -743,7 +701,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" sh.steal(); /* prevent cseq deletion */\n");
printf (" return seq;\n");
printf ("}\n");
-
printf ("void\n");
printf ("%s_resize (%s cseq, guint n)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -753,7 +710,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" sh.resize (n);\n");
printf (" sh.steal(); /* prevent cseq deletion */\n");
printf ("}\n");
-
printf ("void\n");
printf ("%s_free (%s cseq)\n", lname.c_str(), arg.c_str());
printf ("{\n");
@@ -770,20 +726,15 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String name = makeLowerName (si->name);
-
printf ("static GParamSpec *%s_content;\n", name.c_str());
-
String mname = makeMixedName (si->name);
-
printf ("static void\n");
printf ("%s_boxed2seq (const GValue *src_value, GValue *dest_value)\n", name.c_str());
printf ("{\n");
printf (" gpointer boxed = g_value_get_boxed (src_value);\n");
printf (" sfi_value_take_seq (dest_value, boxed ? %s_to_seq (boxed) : NULL);\n", name.c_str());
printf ("}\n");
-
printf ("static void\n");
printf ("%s_seq2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
printf ("{\n");
@@ -791,7 +742,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf (" g_value_take_boxed (dest_value,\n");
printf (" seq ? %s_from_seq (seq) : NULL);\n", name.c_str());
printf ("}\n");
-
printInfoStrings (name + "_info_strings", si->infos);
printf ("static SfiBoxedSequenceInfo %s_boxed_info = {\n", name.c_str());
printf (" \"%s\",\n", mname.c_str());
@@ -810,7 +760,6 @@ class CodeGeneratorCoreC : public CodeGenerator {
printf ("\n\n/* type initialization function */\n");
printf ("static void\n%s (void)\n", generateInitFunction.c_str());
printf ("{\n");
-
/*
* It is important to follow the declaration order of the idl file here, as for
* instance a Param inside a record might come from a sequence, and a Param
@@ -818,11 +767,9 @@ class CodeGeneratorCoreC : public CodeGenerator {
* Params, we follow the getTypes()
*/
vector<String>::const_iterator ti;
-
for(ti = parser.getTypes().begin(); ti != parser.getTypes().end(); ti++)
{
if (parser.fromInclude (*ti)) continue;
-
if (parser.isRecord (*ti) || parser.isSequence (*ti))
{
if (!first)
@@ -832,10 +779,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
if (parser.isRecord (*ti))
{
const Record& rdef = parser.findRecord (*ti);
-
String name = makeLowerName (rdef.name);
int f = 0;
-
for (vector<Param>::const_iterator pi = rdef.contents.begin(); pi != rdef.contents.end(); pi++, f++)
{
if (generateIdlLineNumbers)
@@ -846,9 +791,7 @@ class CodeGeneratorCoreC : public CodeGenerator {
if (parser.isSequence (*ti))
{
const Sequence& sdef = parser.findSequence (*ti);
-
String name = makeLowerName (sdef.name);
-
if (generateIdlLineNumbers)
printf ("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
printf (" %s_content = %s;\n", name.c_str(), construct_pspec (sdef.content).c_str());
@@ -857,11 +800,9 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name)) continue;
-
String gname = make_TYPE_MACRO (ei->name);
String name = makeLowerName(ei->name);
String mname = makeMixedName(ei->name);
-
printf (" %s = g_enum_register_static (\"%s\", %s_value);\n", gname.c_str(),
mname.c_str(), name.c_str());
printf (" g_value_register_transform_func (SFI_TYPE_CHOICE, %s, choice2enum);\n",
@@ -872,10 +813,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String gname = make_TYPE_MACRO (ri->name);
String name = makeLowerName(ri->name);
-
printf (" %s = sfi_boxed_make_record (&%s_boxed_info,\n", gname.c_str(), name.c_str());
printf (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
printf (" (GBoxedFreeFunc) %s_free);\n", name.c_str());
@@ -883,10 +822,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String gname = make_TYPE_MACRO (si->name);
String name = makeLowerName(si->name);
-
printf (" %s_boxed_info.element = %s_content;\n", name.c_str(), name.c_str());
printf (" %s = sfi_boxed_make_sequence (&%s_boxed_info,\n", gname.c_str(), name.c_str());
printf (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
@@ -894,20 +831,17 @@ class CodeGeneratorCoreC : public CodeGenerator {
}
printf ("}\n");
}
-
public:
CodeGeneratorCoreC (const Parser& parser) :
CodeGenerator (parser)
{
}
-
bool
run ()
{
printf ("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
if (generateSource)
printf ("#include <string.h>\n");
-
if (generateHeader)
{
generate_enum_definitions ();
@@ -927,7 +861,6 @@ public:
generate_sequence_type_macros ();
printf ("\n#endif\n");
}
-
if (generateSource)
{
// generate_enum_value_array ();
@@ -952,23 +885,18 @@ public:
printf ("}\n");
}
}
-
printf ("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
};
-
class CoreCFactory : public Factory {
public:
String option() const { return "--core-c"; }
String description() const { return "generate core C language binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new CodeGeneratorCoreC (parser);
}
} core_c_factory;
-
} // anon
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-corecxx.cc b/sfi/sfidl-corecxx.cc
index 0c775d3..923b39b 100644
--- a/sfi/sfidl-corecxx.cc
+++ b/sfi/sfidl-corecxx.cc
@@ -3,16 +3,13 @@
#include "sfidl-factory.hh"
#include "sfidl-utils.hh"
#include "sfidl-generator.hh"
-
#include <string.h>
#include <stdio.h>
#include <list>
#include <map>
-
namespace {
using namespace Sfidl;
using std::make_pair;
-
static const gchar*
canonify_name (const String& s,
const char replace = '-')
@@ -25,7 +22,6 @@ canonify_name (const String& s,
g_free (tmp);
return g_intern_string (d.c_str());
}
-
static const gchar*
UPPER_CASE (const String &s)
{
@@ -41,7 +37,6 @@ UPPER_CASE (const String &s)
d[i] = '_';
return g_intern_string (d.c_str());
}
-
static const char*
intern_escape (const String &s)
{
@@ -51,7 +46,6 @@ intern_escape (const String &s)
const char *result = g_intern_string (e.c_str());
return result;
}
-
static String
include_relative (String path,
String source_file)
@@ -63,7 +57,6 @@ include_relative (String path,
g_free (dir);
return apath;
}
-
static String
glue_untyped_pspec_constructor (const Parser &parser,
const Param ¶m)
@@ -92,7 +85,6 @@ glue_untyped_pspec_constructor (const Parser &parser,
}
}
}
-
class LanguageBindingCoreCxx : public CodeGenerator {
struct Image {
String file;
@@ -564,10 +556,8 @@ public:
{
if (parser.fromInclude (ri->name))
continue;
-
nspace.setFromSymbol(ri->name);
const char *name = nspace.printable_form (ri->name);
-
printf ("class %s;\n", pure_TypeName (ri->name));
printf ("typedef Sfi::RecordHandle<%s> %sHandle;\n", name, name);
printf ("#define %s\t\tBSE_CXX_DECLARED_RECORD_TYPE (%s, %s)\n",
@@ -586,7 +576,6 @@ public:
if (parser.fromInclude (ri->name))
continue;
nspace.setFromSymbol(ri->name);
-
printf ("class %s : public ::Sfi::GNewable {\n", pure_TypeName (ri->name));
printf ("public:\n");
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
@@ -616,7 +605,6 @@ public:
if (parser.fromInclude (ri->name))
continue;
nspace.setFromSymbol(ri->name);
-
printf ("BSE_CXX_DECLARE_RECORD (%s);\n", pure_TypeName (ri->name));
printf ("\n");
}
@@ -631,7 +619,6 @@ public:
continue;
nspace.setFromSymbol(ri->name);
const char *nname = nspace.printable_form (ri->name);
-
printf ("%s\n", TypeRet (ri->name));
printf ("%s::from_rec (SfiRec *sfi_rec)\n", nname);
printf ("{\n");
@@ -649,7 +636,6 @@ public:
}
printf (" return rec;\n");
printf ("}\n\n");
-
printf ("SfiRec *\n");
printf ("%s::to_rec (%s rec)\n", nname, TypeArg (ri->name));
printf ("{\n");
@@ -668,7 +654,6 @@ public:
}
printf (" return sfi_rec;\n");
printf ("}\n\n");
-
printf ("%s\n", TypeRet (ri->name));
printf ("%s::value_get_boxed (const GValue *value)\n", nname);
printf ("{\n");
@@ -679,7 +664,6 @@ public:
printf ("{\n");
printf (" %s::value_set_boxed (value, self);\n", TypeRet (ri->name));
printf ("}\n\n");
-
printf ("SfiRecFields\n");
printf ("%s::get_fields()\n", nname);
printf ("{\n");
@@ -709,7 +693,6 @@ public:
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
-
printf ("class %s;\n", pure_TypeName (si->name));
printf ("#define %s\t\tBSE_CXX_DECLARED_SEQUENCE_TYPE (%s, %s)\n",
make_TYPE_NAME (si->name),
@@ -727,7 +710,6 @@ public:
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
-
printf ("class %s : public Sfi::Sequence< %s > {\n", pure_TypeName (si->name), TypeField (si->content.type));
printf ("public:\n");
printf (" %s (unsigned int n = 0) : Sfi::Sequence< %s > (n) {}\n", pure_TypeName (si->name), TypeField (si->content.type));
@@ -754,7 +736,6 @@ public:
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
-
printf ("BSE_CXX_DECLARE_SEQUENCE (%s);\n", pure_TypeName (si->name));
printf ("\n");
}
@@ -769,7 +750,6 @@ public:
continue;
nspace.setFromSymbol(si->name);
const char *nname = nspace.printable_form (si->name);
-
printf ("%s\n", TypeRet (si->name));
printf ("%s::from_seq (SfiSeq *sfi_seq)\n", nname);
printf ("{\n");
@@ -788,7 +768,6 @@ public:
printf (" }\n");
printf (" return cseq;\n");
printf ("}\n\n");
-
printf ("SfiSeq *\n");
printf ("%s::to_seq (%s cseq)\n", nname, TypeArg (si->name));
printf ("{\n");
@@ -800,7 +779,6 @@ public:
printf (" }\n");
printf (" return sfi_seq;\n");
printf ("}\n\n");
-
printf ("%s\n", TypeRet (si->name));
printf ("%s::value_get_boxed (const GValue *value)\n", nname);
printf ("{\n");
@@ -811,7 +789,6 @@ public:
printf ("{\n");
printf (" ::Sfi::cxx_value_set_boxed_sequence< %s> (value, self);\n", nname);
printf ("}\n\n");
-
printf ("GParamSpec*\n");
printf ("%s::get_element()\n", nname);
printf ("{\n");
@@ -869,11 +846,9 @@ public:
const char *ctProperties = intern (ctName + String ("Properties"));
const char *ctPropertyID = intern (ctName + String ("PropertyID"));
vector<String> destroy_jobs;
-
/* skeleton class declaration + type macro */
printf ("BSE_CXX_DECLARE_CLASS (%s);\n", pure_TypeName (ci->name));
printf ("class %s : public %s {\n", ctNameBase, make_fqtn (ci->inherits));
-
/* class Info strings */
/* pixstream(), this is a bit of a hack, we make it a template rather than
* a normal inline method to avoid huge images in debugging code
@@ -903,7 +878,6 @@ public:
printf (" static inline const char* authors () { return %s; }\n", ci->infos.get("authors").escaped().c_str());
printf (" static inline const char* license () { return %s; }\n", ci->infos.get("license").escaped().c_str());
printf (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (ci->name));
-
/* i/j/o channel names */
if (ci->istreams.size())
{
@@ -929,7 +903,6 @@ public:
printf (" OCHANNEL_%s,\n", pure_UPPER (si->ident));
printf (" N_OCHANNELS\n };\n");
}
-
/* property IDs */
printf ("protected:\n enum %s {\n", ctPropertyID);
if (ci->properties.begin() != ci->properties.end())
@@ -940,7 +913,6 @@ public:
printf (" PROP_%s,\n", pure_UPPER (pi->name));
}
printf (" };\n");
-
/* "Properties" structure for synthesis modules */
if (ci->istreams.size() + ci->jstreams.size() + ci->ostreams.size())
{
@@ -957,11 +929,9 @@ public:
printf (" }\n");
printf (" };\n");
}
-
/* auto-update type */
printf ("protected:\n");
printf (" typedef %s AutoUpdateCategory;\n", class_has_automation_properties (*ci) ? "::Bse::SynthesisModule::NeedAutoUpdateTag" : "void");
-
/* property fields */
printf ("protected:\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
@@ -970,7 +940,6 @@ public:
if (g_option_check (pi->literal_options.c_str(), "automate"))
printf (" guint64 last__%s;\n", pi->name.c_str());
}
-
/* get_property() */
printf ("public:\n");
printf (" void get_property (%s prop_id, ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
@@ -984,7 +953,6 @@ public:
}
printf (" };\n");
printf (" }\n");
-
/* set_property() */
printf (" void set_property (%s prop_id, const ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
printf (" {\n");
@@ -1011,18 +979,15 @@ public:
printf (" default: ;\n");
printf (" };\n");
printf (" }\n");
-
/* editable_property() */
printf (" virtual bool editable_property (%s prop_id, GParamSpec *pspec)\n", ctPropertyID);
printf (" {\n");
printf (" return true;\n");
printf (" }\n");
-
/* get_candidates() */
printf (" virtual void get_candidates (%s prop_id, ::Bse::PropertyCandidatesHandle &pch, GParamSpec *pspec)\n", ctPropertyID);
printf (" {\n");
printf (" }\n");
-
/* property_updated() */
printf (" void property_updated (%s prop_id, guint64 tick_stamp, double prop_value, GParamSpec *pspec)\n", ctPropertyID);
printf (" {\n");
@@ -1047,7 +1012,6 @@ public:
printf (" property_changed (%s (prop_id)))\n", ctPropertyID);
printf (" update_modules();\n");
printf (" }\n");
-
/* static data */
printf ("private:\n");
printf (" static struct StaticData {\n");
@@ -1058,15 +1022,12 @@ public:
printf (" guint signal_%s;\n", sig_name);
}
printf (" } static_data;\n");
-
/* property-changed hooking */
printf ("protected:\n");
printf (" virtual bool property_changed (%s) { return false; }\n", ctPropertyID);
-
/* methods */
for (vector<Method>::const_iterator mi = ci->methods.begin(); mi != ci->methods.end(); mi++)
procs.push_back (&(*mi));
-
/* destructor */
printf (" virtual ~%s ()\n", ctNameBase);
printf (" {\n");
@@ -1074,7 +1035,6 @@ public:
for (vector<String>::const_iterator vi = destroy_jobs.begin(); vi != destroy_jobs.end(); vi++)
printf (" %s;\n", vi->c_str());
printf (" }\n");
-
/* signal emission methods */
printf ("public:\n");
for (vector<Method>::const_iterator si = ci->signals.begin(); si != ci->signals.end(); si++)
@@ -1103,7 +1063,6 @@ public:
printf (" g_value_unset (args + %u);\n", i);
printf (" }\n");
}
-
/* done */
printf ("};\n"); /* finish: class ... { }; */
}
@@ -1122,7 +1081,6 @@ public:
const char *ctPropertyID = intern (ctName + String ("PropertyID"));
const char *nname = nspace.printable_form (ci->name);
vector<String> destroy_jobs;
-
/* class_init */
printf ("void\n");
printf ("%sBase::class_init (::Bse::CxxBaseClass *klass)\n", nname);
@@ -1169,7 +1127,6 @@ public:
if (parser.fromInclude (mi->name))
continue;
nspace.setFromSymbol(mi->name);
-
printf ("namespace Procedure {\n");
printf ("class %s;\n", pure_lower (mi->name));
printf ("#define %s\t\tBSE_CXX_DECLARED_PROC_TYPE (%s, %s)\n",
@@ -1196,7 +1153,6 @@ public:
printf ("namespace Procedure {\n");
printf ("BSE_CXX_DECLARE_PROC (%s);\n", pure_lower (mi->name));
printf ("class %s {\n", pure_lower (mi->name));
-
/* class Info strings */
/* pixstream(), this is a bit of a hack, we make it a template rather than
* a normal inline method to avoid huge images in debugging code
@@ -1225,7 +1181,6 @@ public:
printf (" static inline const char* authors () { return %s; }\n", infos.get("authors").escaped().c_str());
printf (" static inline const char* license () { return %s; }\n", infos.get("license").escaped().c_str());
printf (" static inline const char* type_name () { return \"%s\"; }\n", make_scheme_name (mi->name));
-
/* return type */
printf (" static %s exec (", TypeRet (mi->result.type));
/* args */
@@ -1236,7 +1191,6 @@ public:
printf ("%s %s", TypeArg (ai->type), ai->name.c_str());
}
printf (");\n");
-
/* marshal */
printf (" static BseErrorType marshal (BseProcedureClass *procedure,\n"
" const GValue *in_values,\n"
@@ -1263,7 +1217,6 @@ public:
printf (" }\n");
printf (" return BSE_ERROR_NONE;\n");
printf (" }\n");
-
/* init */
printf (" static void init (BseProcedureClass *proc,\n"
" GParamSpec **in_pspecs,\n"
@@ -1274,7 +1227,6 @@ public:
if (!is_void)
printf (" *(out_pspecs++) = %s;\n", typed_pspec_constructor (mi->result).c_str());
printf (" }\n");
-
/* done */
printf ("};\n"); /* finish: class ... { }; */
printf ("} // Procedure\n\n");
@@ -1284,49 +1236,39 @@ public:
run ()
{
printf ("\n/*-------- begin %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
-
/* standard includes */
printf ("\n#include <bse/bsecxxplugin.hh>\n");
-
/* reset auxillary structures */
images.resize (0);
procs.resize (0);
-
/* setup namespace state */
NamespaceHelper nsh(stdout);
-
/* prototypes */
generate_enum_prototypes (nsh); /* adds to alltypes */
generate_choice_prototypes (nsh);
generate_record_prototypes (nsh); /* adds to alltypes */
generate_sequence_prototypes (nsh); /* adds to alltypes */
generate_class_prototypes (nsh); /* adds to alltypes */
-
/* definitions */
generate_enum_definitions (nsh);
generate_sequence_definitions (nsh);
generate_record_definitions (nsh);
-
/* (type) declarations */
generate_enum_declarations (nsh);
generate_sequence_declarations (nsh);
generate_record_declarations (nsh);
-
/* procedure handling */
for (vector<Method>::const_iterator mi = parser.getProcedures().begin(); mi != parser.getProcedures().end(); mi++)
procs.push_back (&(*mi)); /* collect procedures */
generate_procedure_prototypes (nsh);
-
/* class bodies */
generate_class_definitions (nsh); /* adds to images, procs */
-
/* implementations */
generate_choice_implementations (nsh);
generate_record_implementations (nsh);
generate_sequence_implementations (nsh);
generate_class_implementations (nsh);
generate_procedure_implementations (nsh); /* adds to images */
-
/* alltypes macro */
printf ("\n\n/* %s type registrations */\n", alltypes_macro.c_str());
if (alltypes_macro != "" && alltypes.size())
@@ -1336,12 +1278,9 @@ public:
printf (" BSE_CXX_REGISTER_%s; \\\n", si->c_str());
printf (" /* %s type registrations done */\n", alltypes_macro.c_str());
}
-
/* close namespace state */
nsh.leaveAll();
-
// printf ("\nnamespace ... {\n"); // FIXME: do images need a namespace?
-
/* image method implementations */
for (vector<Image>::const_iterator ii = images.begin(); ii != images.end(); ii++)
{
@@ -1368,37 +1307,29 @@ public:
printf (" return local_pixstream;\n");
printf ("}\n");
}
-
// printf ("\n}; // ...\n"); // FIXME: do images need a namespace?
-
/* done */
printf ("\n/*-------- end %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
return true;
}
};
-
class LanguageBindingCoreCxxFactory : public Factory {
public:
String option() const { return "--core-cxx"; }
String description() const { return "generate core C++ binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new LanguageBindingCoreCxx (parser);
}
} static_factory;
-
class LanguageBindingPluginFactory : public Factory {
public:
String option() const { return "--plugin"; }
String description() const { return "generate C++ plugin binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new LanguageBindingCoreCxx (parser);
}
} static_factory2;
-
} // anon
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-cxxbase.cc b/sfi/sfidl-cxxbase.cc
index 829dcbb..69143ce 100644
--- a/sfi/sfidl-cxxbase.cc
+++ b/sfi/sfidl-cxxbase.cc
@@ -11,9 +11,7 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
using namespace Sfidl;
-
static String
CxxNameToSymbol (const String &str) // FIXME: need mammut renaming function
{
@@ -24,7 +22,6 @@ CxxNameToSymbol (const String &str) // FIXME: need mammut renaming function
s[i] = '_';
return s;
}
-
static vector<String>
split_string (const String &ctype) // FIXME: remove once we have general renamer
{
@@ -42,7 +39,6 @@ split_string (const String &ctype) // FIXME: remove once we have general re
vs.push_back (type);
return vs;
}
-
static String
join_string (const vector<String> &vs, // FIXME: remove once we have general renamer
const String &delim)
@@ -56,7 +52,6 @@ join_string (const vector<String> &vs, // FIXME: remove once we have general re
}
return r;
}
-
static String
UC_NAME (const String &cstr) // FIXME: need mammut renaming function
{
@@ -77,7 +72,6 @@ cUC_NAME (const String &cstr) // FIXME: need mammut renaming function
{
return g_intern_string (cstr.c_str());
}
-
static String // FIXME: need mammut renaming function
UC_TYPE_NAME (const String &tname)
{
@@ -88,13 +82,11 @@ UC_TYPE_NAME (const String &tname)
String result = UC_NAME (nspace) + "_TYPE_" + UC_NAME (lname);
return result;
}
-
static const char*
cUC_TYPE_NAME (const String &cstr) // FIXME: need mammut renaming function
{
return g_intern_string (UC_TYPE_NAME (cstr).c_str());
}
-
/* produce type-system-independant pspec constructors */
String
CodeGeneratorCxxBase::untyped_pspec_constructor (const Param ¶m)
@@ -141,7 +133,6 @@ CodeGeneratorCxxBase::untyped_pspec_constructor (const Param ¶m)
default: return makeParamSpec (param);
}
}
-
/* produce type-system-dependant pspec constructors */
String
CodeGeneratorCxxBase::typed_pspec_constructor (const Param ¶m)
@@ -201,5 +192,4 @@ CodeGeneratorCxxBase::typed_pspec_constructor (const Param ¶m)
default: return makeParamSpec (param);
}
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-cxxbase.hh b/sfi/sfidl-cxxbase.hh
index 0e11b96..7f6a4d1 100644
--- a/sfi/sfidl-cxxbase.hh
+++ b/sfi/sfidl-cxxbase.hh
@@ -1,25 +1,18 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_CXXBASE_H__
#define __SFIDL_CXXBASE_H__
-
#include "sfidl-cbase.hh"
#include "sfidl-namespace.hh"
#include "sfidl-utils.hh"
-
namespace Sfidl {
-
class CodeGeneratorCxxBase : public CodeGeneratorCBase {
protected:
String untyped_pspec_constructor (const Param ¶m);
String typed_pspec_constructor (const Param ¶m);
-
public:
CodeGeneratorCxxBase (const Parser& parser) : CodeGeneratorCBase (parser) {
}
};
-
};
-
#endif /* __SFIDL_CXXBASE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-factory.cc b/sfi/sfidl-factory.cc
index 7b328a4..4ab419e 100644
--- a/sfi/sfidl-factory.cc
+++ b/sfi/sfidl-factory.cc
@@ -2,30 +2,24 @@
#include "sfidl-factory.hh"
#include "glib-extra.hh"
#include <algorithm>
-
using namespace Sfidl;
-
namespace {
list<Factory *> *factories = 0;
}
-
Factory::Factory()
{
if (!factories)
factories = new list<Factory *>();
factories->push_back (this);
}
-
Factory::~Factory()
{
list<Factory *>::iterator fi = find (factories->begin(), factories->end(), this);
g_assert (fi != factories->end());
factories->erase (fi);
}
-
list<Factory *> Factory::listFactories()
{
return *factories;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-factory.hh b/sfi/sfidl-factory.hh
index a14c897..4d86c90 100644
--- a/sfi/sfidl-factory.hh
+++ b/sfi/sfidl-factory.hh
@@ -1,44 +1,33 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef _SFIDL_FACTORY_H_
#define _SFIDL_FACTORY_H_
-
#include "sfidl-utils.hh"
-
namespace Sfidl {
-
class Options;
class Parser;
class CodeGenerator;
-
class Factory {
protected:
Factory();
virtual ~Factory();
-
public:
/*
* creation routine - should create a code generator
*/
virtual CodeGenerator *create (const Parser& parser) const = 0;
-
/*
* returns the command line option (e.g. --plugin)
*/
virtual String option () const = 0;
-
/*
* returns the full description
*/
virtual String description () const = 0;
-
/*
* lists all available factories
*/
static std::list<Factory *> listFactories ();
};
-
};
-
#endif /* _SFIDL_FACTORY_H_ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-generator.cc b/sfi/sfidl-generator.cc
index c77c7d4..a1f3eae 100644
--- a/sfi/sfidl-generator.cc
+++ b/sfi/sfidl-generator.cc
@@ -10,18 +10,14 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
using namespace Sfidl;
using std::make_pair;
-
/*--- common functions ---*/
-
vector<String> CodeGenerator::splitName (const String& name)
{
bool lastunder = true, remove_caps = false;
String::const_iterator i;
vector<String> words;
-
/*
* we try to guess here whether we need to remove caps
* or keep them
@@ -34,7 +30,6 @@ vector<String> CodeGenerator::splitName (const String& name)
if (*i == '_')
remove_caps = true;
}
-
/*
* here, we split "name" into words
*
@@ -55,7 +50,6 @@ vector<String> CodeGenerator::splitName (const String& name)
caps++;
else
caps = 0;
-
if (*i == ':' || *i == '_') /* underscore/colon indicates word boundary */
{
if (!lastunder)
@@ -68,7 +62,6 @@ vector<String> CodeGenerator::splitName (const String& name)
else
{
bool next_lower = (i + 1) != name.end() && islower (*(i + 1));
-
if ((caps == 1 && word_start != word_end) || (caps > 2 && next_lower)) /* caps indicate word boundary */
{
words.push_back (String (word_start, word_end));
@@ -78,54 +71,41 @@ vector<String> CodeGenerator::splitName (const String& name)
lastunder = false;
}
}
-
if (word_start != word_end) /* handle last word in string */
words.push_back (String (word_start, word_end));
-
if (remove_caps)
for (vector<String>::iterator wi = words.begin(); wi != words.end(); wi++)
*wi = string_tolower (*wi);
-
return words;
}
-
-
String CodeGenerator::makeLowerName (const String& name, char seperator)
{
String result;
const vector<String>& words = splitName (name);
-
for (vector<String>::const_iterator wi = words.begin(); wi != words.end(); wi++)
{
if (result != "") result += seperator;
-
for (String::const_iterator i = wi->begin(); i != wi->end(); i++)
result += tolower (*i);
}
-
return result;
}
-
String CodeGenerator::makeUpperName (const String& name)
{
String lname = makeLowerName (name);
String result;
String::const_iterator i;
-
for(i = lname.begin(); i != lname.end(); i++)
result += toupper(*i);
return result;
}
-
String CodeGenerator::makeMixedName (const String& name)
{
String result;
const vector<String>& words = splitName (name);
-
for (vector<String>::const_iterator wi = words.begin(); wi != words.end(); wi++)
{
bool first = true;
-
for (String::const_iterator i = wi->begin(); i != wi->end(); i++)
{
if (first)
@@ -135,18 +115,14 @@ String CodeGenerator::makeMixedName (const String& name)
first = false;
}
}
-
return result;
}
-
String CodeGenerator::makeLMixedName (const String& name)
{
String result = makeMixedName (name);
-
if (!result.empty()) result[0] = tolower (result[0]);
return result;
}
-
String CodeGenerator::toWordCase (const String& word, WordCase wc)
{
String result;
@@ -166,11 +142,9 @@ String CodeGenerator::toWordCase (const String& word, WordCase wc)
}
return result;
}
-
String CodeGenerator::joinName (const vector<String>& name, const String& seperator, WordCase wc)
{
String result;
-
for (vector<String>::const_iterator wi = name.begin(); wi != name.end(); wi++)
{
if (result != "")
@@ -187,7 +161,6 @@ String CodeGenerator::joinName (const vector<String>& name, const String& sepera
}
return result;
}
-
String
CodeGenerator::rename (NamespaceType namespace_type, const String& name, WordCase namespace_wc,
const String &namespace_join, const vector<String> &namespace_append,
@@ -195,7 +168,6 @@ CodeGenerator::rename (NamespaceType namespace_type, const String& name, WordCas
{
String result;
vector<String> namespace_words;
-
if (namespace_type == ABSOLUTE)
{
/*
@@ -207,19 +179,16 @@ CodeGenerator::rename (NamespaceType namespace_type, const String& name, WordCas
result = namespace_join;
namespace_words = splitName (NamespaceHelper::namespaceOf (name));
}
-
namespace_words.insert (namespace_words.end(), namespace_append.begin(), namespace_append.end());
if (!namespace_words.empty())
{
result += joinName (namespace_words, namespace_join, namespace_wc);
result += namespace_join;
}
-
vector<String> words = splitName (NamespaceHelper::nameOf (name));
result += joinName (words, typename_join, typename_wc);
return result;
}
-
String
CodeGenerator::rename (NamespaceHelper& nsh, const String& name, WordCase namespace_wc,
const String& namespace_join, const vector<String>& namespace_append,
@@ -229,18 +198,14 @@ CodeGenerator::rename (NamespaceHelper& nsh, const String& name, WordCase namesp
String pform = nsh.printableForm (name);
return pform;
}
-
OptionVector
CodeGenerator::getOptions()
{
OptionVector opts;
-
opts.push_back (make_pair ("--header", false));
opts.push_back (make_pair ("--source", false));
-
return opts;
}
-
void
CodeGenerator::setOption (const String& option, const String& value)
{
@@ -255,12 +220,10 @@ CodeGenerator::setOption (const String& option, const String& value)
generateHeader = false;
}
}
-
void
CodeGenerator::help()
{
fprintf (stderr, " --header generate header file (default)\n");
fprintf (stderr, " --source generate source file\n");
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-generator.hh b/sfi/sfidl-generator.hh
index 646b1c1..d25a7d7 100644
--- a/sfi/sfidl-generator.hh
+++ b/sfi/sfidl-generator.hh
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_GENERATOR_H__
#define __SFIDL_GENERATOR_H__
-
#include <map>
#include <iostream>
#include <algorithm>
@@ -10,44 +9,36 @@
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
#include "sfiparams.hh" /* scatId (SFI_SCAT_*) */
-
namespace Sfidl {
-
class CodeGenerator {
protected:
const Parser& parser;
const Options& options;
-
bool generateHeader;
bool generateSource;
bool generateIdlLineNumbers;
-
std::vector<String> splitName (const String& name);
String makeLowerName (const String& name, char seperator = '_');
String makeUpperName (const String& name);
String makeMixedName (const String& name);
String makeLMixedName (const String& name);
-
enum WordCase {
lower,
Capitalized,
semiCapitalized,
UPPER
};
-
/*
* translates a word into a given word case
* i.e. toWordCase ("Hello", UPPER) == "HELLO"
*/
String toWordCase (const String& word, WordCase wc);
String joinName (const std::vector<String>& name, const String& seperator, WordCase wc);
-
enum NamespaceType {
NONE, /* no namespace */
ABSOLUTE, /* in C++ means :: prefix */
/* RELATIVE indicated by NamespaceHelper instead */
};
-
/*
* rename is a function for renaming types according to rules
*
@@ -65,7 +56,6 @@ namespace Sfidl {
rename (NamespaceType namespace_type, const String& name, WordCase namespace_wc,
const String &namespace_join, const std::vector<String> &namespace_append,
WordCase typename_wc, const String &typename_join);
-
/*
* rename is a function for renaming types according to rules
*
@@ -80,14 +70,12 @@ namespace Sfidl {
rename (NamespaceHelper& nsh, const String& name, WordCase namespace_wc,
const String& namespace_join, const std::vector<String>& namespace_append,
WordCase typename_wc, const String& typename_join);
-
CodeGenerator(const Parser& parser)
: parser (parser), options (*Options::the()),
generateHeader (true), generateSource (false),
generateIdlLineNumbers (true)
{
}
-
public:
/*
* returns the options supported by this code generator (used by the option parser)
@@ -96,19 +84,16 @@ namespace Sfidl {
* user argument (as in "--prefix beast"), false otherwise (i.e. "--source")
*/
virtual OptionVector getOptions();
-
/*
* called by the option parser when an option is set
* option is the option (i.e. "--prefix")
* value is the value (i.e. "beast"), and "1" for options without user argument
*/
virtual void setOption (const String& option, const String& value);
-
/*
* prints help for the options supported by this code generator
*/
virtual void help();
-
/*
* run generates the code, and should return true if successful, false otherwise
* (for instance if inconsistent options were given to the code generator)
@@ -117,9 +102,6 @@ namespace Sfidl {
virtual ~CodeGenerator() {
}
};
-
};
-
#endif /* __SFIDL_GENERATOR_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-hostc.cc b/sfi/sfidl-hostc.cc
index 63ecd36..f6ab7fd 100644
--- a/sfi/sfidl-hostc.cc
+++ b/sfi/sfidl-hostc.cc
@@ -9,10 +9,8 @@
#include "sfidl-namespace.hh"
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
-
using namespace Sfidl;
using std::make_pair;
-
void CodeGeneratorHostC::printRecordFieldDeclarations()
{
/*
@@ -23,12 +21,10 @@ void CodeGeneratorHostC::printRecordFieldDeclarations()
for(vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
printf("extern SfiRecFields %s_fields;\n",makeLowerName (ri->name).c_str());
}
printf("\n");
}
-
void CodeGeneratorHostC::printInitFunction (const String& initFunction)
{
/*
@@ -37,9 +33,7 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
for(vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
-
String name = makeLowerName (ri->name);
-
printf("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
printf("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
printf("\n");
@@ -47,20 +41,16 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
for(vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
-
String name = makeLowerName (si->name);
-
printf("static GParamSpec *%s_content;\n", name.c_str());
printf("\n");
}
-
/*
* the init function itself
*/
bool first = true;
printf("static void\n%s (void)\n", initFunction.c_str());
printf("{\n");
-
/*
* It is important to follow the declaration order of the idl file here, as for
* instance a Param inside a record might come from a sequence, and a Param
@@ -68,11 +58,9 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
* Params, we follow the getTypes()
*/
vector<String>::const_iterator ti;
-
for(ti = parser.getTypes().begin(); ti != parser.getTypes().end(); ti++)
{
if (parser.fromInclude (*ti)) continue;
-
if (parser.isRecord (*ti) || parser.isSequence (*ti))
{
if(!first) printf("\n");
@@ -81,10 +69,8 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
if (parser.isRecord (*ti))
{
const Record& rdef = parser.findRecord (*ti);
-
String name = makeLowerName (rdef.name);
int f = 0;
-
for (vector<Param>::const_iterator pi = rdef.contents.begin(); pi != rdef.contents.end(); pi++, f++)
{
printf("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
@@ -94,29 +80,24 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
if (parser.isSequence (*ti))
{
const Sequence& sdef = parser.findSequence (*ti);
-
String name = makeLowerName (sdef.name);
-
printf("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
printf(" %s_content = %s;\n", name.c_str(), makeParamSpec (sdef.content).c_str());
}
}
printf("}\n");
}
-
void CodeGeneratorHostC::printChoiceMethodPrototypes (PrefixSymbolMode mode)
{
for(vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name)) continue;
-
if (mode == generatePrefixSymbols)
prefix_symbols.push_back (makeLowerName (ei->name) + "_get_values");
else
printf("SfiChoiceValues %s_get_values (void);\n", makeLowerName (ei->name).c_str());
}
}
-
void CodeGeneratorHostC::printChoiceMethodImpl()
{
int enumCount = 0;
@@ -124,9 +105,7 @@ void CodeGeneratorHostC::printChoiceMethodImpl()
{
if (parser.fromInclude (ei->name))
continue;
-
String name = makeLowerName (ei->name);
-
printf ("SfiChoiceValues\n");
printf ("%s_get_values (void)\n", makeLowerName (ei->name).c_str());
printf ("{\n");
@@ -147,78 +126,59 @@ void CodeGeneratorHostC::printChoiceMethodImpl()
printf (" return choice_values;\n");
printf ("}\n");
printf("\n");
-
enumCount++;
}
}
-
bool CodeGeneratorHostC::run ()
{
printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
-
if (generateHeader)
{
/* namespace prefixing */
-
prefix_symbols.clear();
-
printClientChoiceConverterPrototypes (generatePrefixSymbols);
printClientRecordMethodPrototypes (generatePrefixSymbols);
printClientSequenceMethodPrototypes (generatePrefixSymbols);
printChoiceMethodPrototypes (generatePrefixSymbols);
-
if (prefix != "")
{
for (vector<String>::const_iterator pi = prefix_symbols.begin(); pi != prefix_symbols.end(); pi++)
printf("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
printf("\n");
}
-
/* generate the header */
-
printClientRecordPrototypes();
printClientSequencePrototypes();
-
printClientChoiceDefinitions();
printClientRecordDefinitions();
printClientSequenceDefinitions();
-
printClientRecordMethodPrototypes (generateOutput);
printClientSequenceMethodPrototypes (generateOutput);
printClientChoiceConverterPrototypes (generateOutput);
printChoiceMethodPrototypes (generateOutput);
-
printRecordFieldDeclarations();
}
-
if (generateSource)
{
printf("#include <string.h>\n");
-
printClientRecordMethodImpl();
printClientSequenceMethodImpl();
printChoiceMethodImpl();
printChoiceConverters();
-
if (generateInitFunction != "")
printInitFunction (generateInitFunction);
}
-
printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
-
OptionVector
CodeGeneratorHostC::getOptions()
{
OptionVector opts = CodeGeneratorCBase::getOptions();
-
opts.push_back (make_pair ("--prefix", true));
opts.push_back (make_pair ("--init", true));
-
return opts;
}
-
void
CodeGeneratorHostC::setOption (const String& option, const String& value)
{
@@ -235,7 +195,6 @@ CodeGeneratorHostC::setOption (const String& option, const String& value)
CodeGeneratorCBase::setOption (option, value);
}
}
-
void
CodeGeneratorHostC::help()
{
@@ -243,20 +202,15 @@ CodeGeneratorHostC::help()
fprintf (stderr, " --prefix <prefix> set the prefix for C functions\n");
fprintf (stderr, " --init <name> set the name of the init function\n");
}
-
namespace {
-
class HostCFactory : public Factory {
public:
String option() const { return "--host-c"; }
String description() const { return "generate host C language binding"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new CodeGeneratorHostC (parser);
}
} host_c_factory;
-
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-hostc.hh b/sfi/sfidl-hostc.hh
index 58bc562..89ca912 100644
--- a/sfi/sfidl-hostc.hh
+++ b/sfi/sfidl-hostc.hh
@@ -1,37 +1,28 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFIDL_HOSTC_H__
#define __SFIDL_HOSTC_H__
-
#include <map>
#include <iostream>
#include <algorithm>
#include "sfidl-utils.hh"
#include "sfidl-cbase.hh"
-
namespace Sfidl {
-
class CodeGeneratorHostC : public CodeGeneratorCBase {
protected:
String prefix;
String generateInitFunction;
-
void printChoiceMethodPrototypes (PrefixSymbolMode mode);
void printChoiceMethodImpl();
void printRecordFieldDeclarations();
void printInitFunction (const String& initFunction);
-
public:
CodeGeneratorHostC (const Parser& parser) : CodeGeneratorCBase (parser) {
}
void help();
bool run();
-
OptionVector getOptions();
void setOption (const String& option, const String& value);
};
-
};
-
#endif /* __SFIDL_HOSTC_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-namespace.cc b/sfi/sfidl-namespace.cc
index ed6af3a..58a5c79 100644
--- a/sfi/sfidl-namespace.cc
+++ b/sfi/sfidl-namespace.cc
@@ -5,16 +5,12 @@
#include <algorithm>
#include "sfidl-namespace.hh"
#include <sfi/glib-extra.hh>
-
using namespace Sfidl;
-
/* generic utilities */
-
static list<String> symbolToList (String symbol)
{
list<String> result;
String current;
-
String::iterator si;
for(si = symbol.begin(); si != symbol.end(); si++)
{
@@ -26,15 +22,12 @@ static list<String> symbolToList (String symbol)
{
if(current != "")
result.push_back(current);
-
current = "";
}
}
-
result.push_back(current);
return result;
}
-
static String listToSymbol(list<String>& symlist)
{
String s;
@@ -46,23 +39,19 @@ static String listToSymbol(list<String>& symlist)
}
return s;
}
-
/* NamespaceHelper */
NamespaceHelper::NamespaceHelper(FILE *outputfile) : out(outputfile)
{
}
-
NamespaceHelper::~NamespaceHelper()
{
leaveAll();
}
-
void
NamespaceHelper::setFromSymbol(String symbol)
{
list<String> symlist = symbolToList (symbol);
symlist.pop_back();
-
/* check that the current namespace doesn't contain wrong parts at end */
list<String>::iterator ni,si;
ni = currentNamespace.begin();
@@ -78,7 +67,6 @@ NamespaceHelper::setFromSymbol(String symbol)
{
fprintf (out,"} // %s\n", (*ni++).c_str());
}
-
/* enter new components at the end */
while (si != symlist.end())
{
@@ -86,22 +74,18 @@ NamespaceHelper::setFromSymbol(String symbol)
}
currentNamespace = symlist;
}
-
void NamespaceHelper::leaveAll()
{
setFromSymbol("unqualified");
}
-
String NamespaceHelper::printableForm(String symbol)
{
list<String> symlist = symbolToList(symbol);
list<String> current = currentNamespace;
-
while(!current.empty())
{
// namespace longer than symbol?
g_assert (!symlist.empty());
-
if(*current.begin() == *symlist.begin())
{
current.pop_front();
@@ -112,7 +96,6 @@ String NamespaceHelper::printableForm(String symbol)
return "::"+symbol;
}
}
-
return listToSymbol(symlist);
}
const char*
@@ -120,22 +103,17 @@ NamespaceHelper::printable_form (String symbol)
{
return g_intern_string (printableForm (symbol).c_str());
}
-
String NamespaceHelper::nameOf(String symbol)
{
if(symbol == "") return "";
-
list<String> symlist = symbolToList(symbol);
return symlist.back();
}
-
String NamespaceHelper::namespaceOf(String symbol)
{
list<String> symlist = symbolToList(symbol);
if(symlist.size() < 2) return "";
-
symlist.pop_back();
return listToSymbol(symlist);
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-namespace.hh b/sfi/sfidl-namespace.hh
index a923671..f8963ac 100644
--- a/sfi/sfidl-namespace.hh
+++ b/sfi/sfidl-namespace.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef _SFIDL_NAMESPACE_H__
#define _SFIDL_NAMESPACE_H__
-
#include <stdio.h>
#include "sfidl-utils.hh"
-
namespace Sfidl {
-
/*
* This class is used during code generation. It generates the namespace
* opening and closing code.
@@ -15,11 +12,9 @@ class NamespaceHelper {
protected:
FILE *out;
std::list<String> currentNamespace;
-
public:
NamespaceHelper(FILE *outputfile);
~NamespaceHelper();
-
/*
* This method will cause the NamespaceHelper to enter the namespace the
* symbol is in. That means setFromSymbol("Arts::Object") will enter the
@@ -27,13 +22,11 @@ class NamespaceHelper {
* outside of class definitions.
*/
void setFromSymbol (String symbol);
-
/*
* This leaves all open namespaces which is useful if you want to include
* a file or such, or if you are at the end of a file.
*/
void leaveAll();
-
/*
* The shortest printable form of a symbol - using "Arts::Object" as
* example, this would be "Arts::Object", if you are in no namespace,
@@ -42,13 +35,11 @@ class NamespaceHelper {
*/
String printableForm (String symbol);
const char* printable_form (String symbol);
-
/*
* Returns only the last component of the symbol (the name) cutting the
* namespace components
*/
static String nameOf (String symbol);
-
/*
* Returns everything but the last component of the symbol, which is
* the namespace (e.g. namespaceOf("Arts::Object") returns Arts, and
@@ -56,9 +47,6 @@ class NamespaceHelper {
*/
static String namespaceOf (String symbol);
};
-
}
-
#endif /* _SFIDL_NAMESPACE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-options.cc b/sfi/sfidl-options.cc
index 61aae62..e3998a4 100644
--- a/sfi/sfidl-options.cc
+++ b/sfi/sfidl-options.cc
@@ -6,56 +6,41 @@
#include <sfi/glib-extra.hh>
#include <stdio.h>
#include <string.h>
-
/* FIXME: should be filled out and written into topconfig.h by configure */
#define SFIDL_VERSION BST_VERSION
#define SFIDL_PRG_NAME "sfidl"
-
using namespace Sfidl;
-
static Options *Options_the = 0;
-
Options *Options::the() {
g_return_val_if_fail (Options_the != 0, 0);
-
return Options_the;
};
-
Options::Options ()
{
doHelp = doExit = false;
sfidlName = "sfidl";
codeGenerator = 0;
-
Options_the = this;
}
-
bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
{
bool printIncludePath = false;
bool printVersion = false;
bool noStdInc = false;
-
OptionVector codeGeneratorOptions;
-
unsigned int argc;
char **argv;
unsigned int i, e;
-
g_return_val_if_fail (argc_p != NULL, false);
g_return_val_if_fail (argv_p != NULL, false);
g_return_val_if_fail (*argc_p >= 0, false);
-
argc = *argc_p;
argv = *argv_p;
-
if (argc && argv[0])
sfidlName = argv[0];
-
for (i = 1; i < argc; i++)
{
unsigned int len = 0;
-
if (strcmp ("--help", argv[i]) == 0)
{
doHelp = true;
@@ -66,7 +51,6 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
strncmp ("-I", argv[i], len) == 0))
{
char *path = argv[i] + len;
-
if (*path != 0)
includePath.push_back (path);
else if (i + 1 < argc)
@@ -97,11 +81,9 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
else if (!codeGenerator) /* only one code generator allowed */
{
list<Factory *> factories = Factory::listFactories();
-
for (list<Factory *>::const_iterator fi = factories.begin(); fi != factories.end(); fi++)
{
Factory *factory = *fi;
-
if (argv[i] && factory->option() == argv[i])
{
codeGenerator = factory->create (parser);
@@ -120,7 +102,6 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
const String& option = oi->first;
const bool& needArg = oi->second;
String optioneq = option + "=";
-
if (option == argv[i]) // --option
{
if (!needArg) // --option
@@ -139,7 +120,6 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
if (needArg)
value = argv[i] + optioneq.size();
}
-
if (value)
{
codeGenerator->setOption (option, value);
@@ -148,7 +128,6 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
}
}
}
-
/* resort argc/argv */
e = 0;
for (i = 1; i < argc; i++)
@@ -166,7 +145,6 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
}
if (e)
*argc_p = e;
-
/* add std include path */
if (!noStdInc)
{
@@ -179,12 +157,9 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
}
g_free (x);
}
-
/* option validation */
-
if (doHelp)
return true;
-
if (printIncludePath)
{
bool first = true;
@@ -199,20 +174,16 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
printf ("\n");
return true;
}
-
if (printVersion)
{
printf ("%s %s\n", SFIDL_PRG_NAME, SFIDL_VERSION);
return true;
}
-
return true;
}
-
void Options::printUsage ()
{
list<Factory *> factories = Factory::listFactories();
-
fprintf (stderr, "usage: %s <binding> [ <options> ] <idlfile>\n", sfidlName.c_str());
fprintf (stderr, "\n");
fprintf (stderr, "general options:\n");
@@ -224,7 +195,6 @@ void Options::printUsage ()
fprintf (stderr, " --help <binding> help for a specific binding\n");
fprintf (stderr, " --version print version\n");
fprintf (stderr, "\n");
-
if (!codeGenerator)
{
fprintf (stderr, "language bindings:\n");
@@ -237,6 +207,4 @@ void Options::printUsage ()
codeGenerator->help();
}
}
-
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-options.hh b/sfi/sfidl-options.hh
index 9825c61..fb177c0 100644
--- a/sfi/sfidl-options.hh
+++ b/sfi/sfidl-options.hh
@@ -1,33 +1,24 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef _SFIDL_OPTIONS_H_
#define _SFIDL_OPTIONS_H_
-
#include <utility>
#include "sfidl-utils.hh"
-
namespace Sfidl {
-
class Factory;
class Parser;
class CodeGenerator;
-
typedef std::vector< std::pair <String, bool> > OptionVector;
-
struct Options {
CodeGenerator *codeGenerator;
String codeGeneratorName;
bool doHelp;
bool doExit;
String sfidlName;
-
std::vector<String> includePath; // path to search for includes
-
Options ();
bool parse (int *argc_p, char **argv_p[], const Parser& parser);
void printUsage ();
-
static Options *the();
};
-
};
#endif /* _SFIDL_OPTIONS_H_ */
diff --git a/sfi/sfidl-parser.cc b/sfi/sfidl-parser.cc
index 6285bbe..a4ae723 100644
--- a/sfi/sfidl-parser.cc
+++ b/sfi/sfidl-parser.cc
@@ -13,13 +13,10 @@
#include <set>
#include <stack>
#include <algorithm>
-
namespace {
-
using namespace Sfidl;
using std::set;
using std::stack;
-
/* As opposed to the birnet function string_from_double, we use "%.17e"
* (instead of "%.17g"). This keeps doubles in param specs like (50.0/100.0)
* intact, because the C++ compiler will still recognize that we have doubles
@@ -36,7 +33,6 @@ string_with_exponent_from_double (double value)
g_ascii_formatd (buffer, G_ASCII_DTOSTR_BUF_SIZE, "%.17e", value);
return buffer;
}
-
/* --- variables --- */
static GScannerConfig scanner_config_template = {
const_cast<gchar *> /* FIXME: glib should use const gchar* here */
@@ -56,9 +52,7 @@ static GScannerConfig scanner_config_template = {
G_CSET_A_2_Z
) /* cset_identifier_nth */,
0 /* cpair_comment_single */,
-
TRUE /* case_sensitive */,
-
TRUE /* skip_comment_multi */,
TRUE /* skip_comment_single */,
TRUE /* scan_comment_multi */,
@@ -81,11 +75,8 @@ static GScannerConfig scanner_config_template = {
FALSE /* scope_0_fallback */,
TRUE /* store_int64 */,
};
-
/* --- defines --- */
-
#define DEBUG(x) // dprintf(2,"%s",x)
-
enum ExtraToken {
TOKEN_NAMESPACE = G_TOKEN_LAST + 1,
TOKEN_CLASS,
@@ -103,16 +94,13 @@ enum ExtraToken {
TOKEN_OSTREAM,
TOKEN_ERROR
};
-
const char *token_symbols[] = {
"namespace", "class", "choice", "record", "sequence",
"property", "group", "using",
"Const", "ConstIdent", "Info", "IStream", "JStream", "OStream",
0
};
-
bool operator== (GTokenType t, ExtraToken e) { return (int) t == (int) e; }
-
#define parse_or_return(token) G_STMT_START{ \
GTokenType _t = GTokenType(token); \
if (g_scanner_get_next_token (scanner) != _t) \
@@ -179,35 +167,28 @@ bool operator== (GTokenType t, ExtraToken e) { return (int) t == (int) e; }
return G_TOKEN_FLOAT; \
if (negate) f = -f; \
}G_STMT_END
-
} // nanespace Anon
-
/* --- methods --- */
-
bool Parser::isChoice(const String& type) const
{
map<String,int>::const_iterator i = typeMap.find (type);
return (i != typeMap.end()) && ((i->second & (~tdProto)) == tdChoice);
}
-
bool Parser::isSequence(const String& type) const
{
map<String,int>::const_iterator i = typeMap.find (type);
return (i != typeMap.end()) && ((i->second & (~tdProto)) == tdSequence);
}
-
bool Parser::isRecord(const String& type) const
{
map<String,int>::const_iterator i = typeMap.find (type);
return (i != typeMap.end()) && ((i->second & (~tdProto)) == tdRecord);
}
-
bool Parser::isClass(const String& type) const
{
map<String,int>::const_iterator i = typeMap.find (type);
return (i != typeMap.end()) && ((i->second & (~tdProto)) == tdClass);
}
-
Type Parser::typeOf (const String& type) const
{
if (type == "void") return VOID;
@@ -226,85 +207,65 @@ Type Parser::typeOf (const String& type) const
g_error (("invalid type: " + type).c_str());
return VOID;
}
-
Sequence Parser::findSequence(const String& name) const
{
vector<Sequence>::const_iterator i;
-
for (i=sequences.begin(); i != sequences.end(); i++)
if (i->name == name)
return *i;
-
return Sequence();
}
-
Record Parser::findRecord(const String& name) const
{
vector<Record>::const_iterator i;
-
for (i=records.begin(); i != records.end(); i++)
if (i->name == name)
return *i;
-
return Record();
}
-
const Class*
Parser::findClass (const String& name) const
{
for (vector<Class>::const_iterator ci = classes.begin(); ci != classes.end(); ci++)
if (ci->name == name)
return &*ci;
-
return 0;
}
-
Parser::Parser () : options (*Options::the())
{
scanner = g_scanner_new64 (&scanner_config_template);
-
for (int n = 0; token_symbols[n]; n++)
g_scanner_add_symbol (scanner, token_symbols[n], GUINT_TO_POINTER (G_TOKEN_LAST + 1 + n));
-
scanner->max_parse_errors = 10;
scanner->parse_errors = 0;
scanner->msg_handler = scannerMsgHandler;
scanner->user_data = this;
}
-
void Parser::printError (const gchar *format, ...)
{
va_list args;
gchar *string;
-
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
-
if (scanner->parse_errors < scanner->max_parse_errors)
g_scanner_error (scanner, "%s", string);
-
g_free (string);
}
-
void Parser::printWarning (const gchar *format, ...)
{
va_list args;
gchar *string;
-
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
-
g_scanner_warn (scanner, "%s", string);
g_free (string);
}
-
void Parser::scannerMsgHandler (GScanner *scanner, gchar *message, gboolean is_error)
{
g_return_if_fail (scanner != NULL);
g_return_if_fail (scanner->user_data != NULL);
-
Parser *parser = static_cast<Parser *>(scanner->user_data);
if (scanner->line > 0 && parser->scannerLineInfo.size() >= scanner->line)
{
@@ -321,19 +282,15 @@ void Parser::scannerMsgHandler (GScanner *scanner, gchar *message, gboolean is_e
fprintf (stderr, "warning: ");
fprintf (stderr, "%s\n", message);
}
-
/* --- preprocessing related functions --- */
-
template<class Iterator>
static bool match(Iterator start, const char *string)
{
/* FIXME: can we exceed the bounds of the input vector? */
while(*string && *start)
if(*string++ != *start++) return false;
-
return (*string == 0);
}
-
static bool fileExists(const String& filename)
{
FILE *test = fopen(filename.c_str(),"r");
@@ -344,7 +301,6 @@ static bool fileExists(const String& filename)
}
return false;
}
-
static void loadFile (FILE *file, vector<char>& v)
{
char buffer[1024];
@@ -352,7 +308,6 @@ static void loadFile (FILE *file, vector<char>& v)
while (!feof (file) && (l = fread(buffer,1,1024,file)) > 0)
v.insert(v.end(),buffer, buffer+l);
}
-
static void loadFile(const char *filename, vector<char>& v)
{
if (strcmp (filename, "-") == 0) /* stdin */
@@ -362,28 +317,22 @@ static void loadFile(const char *filename, vector<char>& v)
else
{
FILE *file = fopen (filename,"r");
-
if (!file)
{
fprintf(stderr,"file '%s' not found\n",filename);
exit(1);
}
-
loadFile (file, v);
fclose (file);
}
}
-
bool Parser::haveIncluded (const String& filename) const
{
vector<String>::const_iterator i;
-
for(i = includes.begin();i != includes.end();i++)
if(*i == filename) return true;
-
return false;
}
-
static void collectImplIncludes (set<String>& result,
const String& root,
map<String, set<String> >& implIncludeMap)
@@ -391,49 +340,40 @@ static void collectImplIncludes (set<String>& result,
if (result.count (root) == 0)
{
result.insert (root);
-
set<String>::const_iterator si;
for (si = implIncludeMap[root].begin(); si != implIncludeMap[root].end(); si++)
collectImplIncludes (result, *si, implIncludeMap);
}
}
-
void Parser::preprocess (const String& filename, bool includeImpl)
{
static stack<String> includeStack;
static map<String, set<String> > implIncludeMap;
-
// make a note whenever "file 1" implincludes "file 2"
if (!includeStack.empty() && includeImpl)
implIncludeMap[includeStack.top()].insert(filename);
-
// do the actual preprocessing on the file
if (!haveIncluded (filename))
{
includes.push_back (filename);
-
includeStack.push (filename);
preprocessContents (filename);
includeStack.pop ();
}
-
// on the outer level compute which code to build
if (includeStack.empty())
{
set<String> implIncludes;
collectImplIncludes (implIncludes, filename, implIncludeMap);
implIncludeMap.clear();
-
vector<LineInfo>::iterator li;
for (li = scannerLineInfo.begin(); li != scannerLineInfo.end(); li++)
li->isInclude = (implIncludes.count (li->filename) == 0);
-
vector<Pragma>::iterator pi;
for (pi = pragmas.begin(); pi != pragmas.end(); pi++)
pi->fromInclude = (implIncludes.count (pi->filename) == 0);
}
}
-
void Parser::preprocessContents (const String& input_filename)
{
Pragma pragma;
@@ -445,15 +385,12 @@ void Parser::preprocessContents (const String& input_filename)
filenameFind, filenameIn1, filenameIn2,
inString, inStringEscape, inPragma
} state = lineStart;
-
LineInfo linfo;
linfo.line = 1;
linfo.filename = input_filename;
-
vector<char> input;
loadFile (input_filename.c_str(), input);
input.push_back('\n'); // line number counting assumes files end with a newline
-
vector<char>::iterator i = input.begin();
while(i != input.end())
{
@@ -532,7 +469,6 @@ void Parser::preprocessContents (const String& input_filename)
case ' ': // skip whitespaces
case '\t':
break;
-
case '"': state = filenameIn1;
break;
case '<': state = filenameIn2;
@@ -583,7 +519,6 @@ void Parser::preprocessContents (const String& input_filename)
exit(1);
}
preprocess (location, includeImpl);
-
state = idlCode;
i++;
}
@@ -642,15 +577,12 @@ void Parser::preprocessContents (const String& input_filename)
}
}
}
-
bool Parser::insideInclude () const
{
int scanner_line = scanner->line - 1;
g_return_val_if_fail (scanner_line >= 0 && scanner_line < (gint) scannerLineInfo.size(), false);
-
return scannerLineInfo[scanner_line].isInclude;
}
-
/*
* This gets the #pragma lines, which should look like this in the input file:
*
@@ -666,11 +598,9 @@ vector<Pragma> Parser::getPragmas (const String& binding) const
{
enum { expectSfidl, expectBinding, expectColons, goodMatch, badMatch } state = expectSfidl;
Pragma p = *pi;
-
for (String::const_iterator ti = pi->text.begin(); ti != pi->text.end();)
{
unsigned int chars_left = pi->text.end() - ti;
-
if (state == goodMatch)
{
/* copy actual pragma content (stripped of SFIDL Binding::) */
@@ -709,16 +639,13 @@ vector<Pragma> Parser::getPragmas (const String& binding) const
resultPragmas.push_back (p);
}
}
-
return resultPragmas;
}
-
bool Pragma::getString (const String& key, String& value)
{
bool result = false;
GScanner *scanner = g_scanner_new64 (&scanner_config_template);
g_scanner_input_text (scanner, text.c_str(), text.size());
-
if (g_scanner_get_next_token (scanner) == G_TOKEN_IDENTIFIER)
{
if (scanner->value.v_identifier == key)
@@ -733,9 +660,7 @@ bool Pragma::getString (const String& key, String& value)
g_scanner_destroy (scanner);
return result;
}
-
namespace {
-
/*
* comparation class, used to sort classes in such an order that bases
* classes appear before derived classes
@@ -744,11 +669,9 @@ class ClassCompare {
public:
const Parser& parser;
map<String, int> inheritanceLevel;
-
ClassCompare (const Parser& parser) : parser (parser)
{
vector<Class>::const_iterator ci;
-
/*
* precompute the inheritance levels, as the classes data structure within the
* parser will be modified by sort() during sorting with ClassCompare ; besides,
@@ -757,7 +680,6 @@ public:
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
computeInheritanceLevel (*ci);
}
-
int computeInheritanceLevel (const Class& cdef)
{
int& level = inheritanceLevel[cdef.name];
@@ -771,7 +693,6 @@ public:
}
return level;
}
-
/* return true if c1 is to be placed before c2 */
bool operator()(const Class& c1, const Class& c2)
{
@@ -782,11 +703,8 @@ public:
return c1.name < c2.name;
}
};
-
} // namespace Anon
-
/* --- parsing functions --- */
-
bool Parser::parse (const String& filename)
{
/* preprocess (throws includes into contents, removes C-style comments) */
@@ -806,9 +724,7 @@ bool Parser::parse (const String& filename)
g_free (dir);
}
/* FIXME: we leak scanner->input_name later on */
-
currentNamespace = &rootNamespace;
-
/* define primitive types into the basic namespace */
enterNamespace ("Sfi");
defineSymbol ("Bool");
@@ -820,13 +736,10 @@ bool Parser::parse (const String& filename)
defineSymbol ("FBlock");
defineSymbol ("Rec");
leaveNamespace ();
-
GTokenType expected_token = G_TOKEN_NONE;
-
while (!g_scanner_eof (scanner) && expected_token == G_TOKEN_NONE)
{
g_scanner_get_next_token (scanner);
-
if (scanner->token == G_TOKEN_EOF)
break;
else if (scanner->token == TOKEN_NAMESPACE)
@@ -834,31 +747,24 @@ bool Parser::parse (const String& filename)
else
expected_token = G_TOKEN_EOF; /* '('; */
}
-
if (expected_token != G_TOKEN_NONE && expected_token != (GTokenType)TOKEN_ERROR)
{
g_scanner_unexp_token (scanner, expected_token, NULL, NULL, NULL, NULL, TRUE);
return false;
}
-
if (scanner->parse_errors > 0)
return false;
-
/* postprocessing of the data structures: */
sort (classes.begin(), classes.end(), ClassCompare (*this));
return true;
}
-
GTokenType Parser::parseNamespace()
{
DEBUG("parse namespace\n");
parse_or_return (G_TOKEN_IDENTIFIER);
-
if (!enterNamespace (scanner->value.v_identifier))
return GTokenType (TOKEN_ERROR);
-
parse_or_return (G_TOKEN_LEFT_CURLY);
-
bool ready = false;
do
{
@@ -898,7 +804,6 @@ GTokenType Parser::parseNamespace()
GTokenType expected_token = parseMethod (procedure);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
procedure.name = defineSymbol (procedure.name.c_str());
procedure.file = fileName();
addProcedureTodo (procedure);
@@ -923,10 +828,8 @@ GTokenType Parser::parseNamespace()
parse_or_return (TOKEN_USING);
parse_or_return (TOKEN_NAMESPACE);
parse_or_return (G_TOKEN_IDENTIFIER);
-
if (!usingNamespace (scanner->value.v_identifier))
return GTokenType (TOKEN_ERROR);
-
parse_or_return (';');
}
break;
@@ -943,18 +846,13 @@ GTokenType Parser::parseNamespace()
}
}
while (!ready);
-
parse_or_return (G_TOKEN_RIGHT_CURLY);
-
/* semicolon after namespaces is optional (like in C++) */
if (g_scanner_peek_next_token (scanner) == GTokenType(';'))
parse_or_return (';');
-
leaveNamespace();
-
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseTypeName (String& type)
{
parse_or_return (G_TOKEN_IDENTIFIER);
@@ -964,21 +862,16 @@ GTokenType Parser::parseTypeName (String& type)
parse_or_return (':');
parse_or_return (':');
type += "::";
-
parse_or_return (G_TOKEN_IDENTIFIER);
type += scanner->value.v_identifier;
}
-
String qtype = qualifySymbol (type.c_str());
-
if (qtype == "")
printError ("can't find prior definition for type '%s'", type.c_str());
else
type = qtype;
-
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseStringOrConst (String &s)
{
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER)
@@ -986,7 +879,6 @@ GTokenType Parser::parseStringOrConst (String &s)
GTokenType expected_token = parseTypeName (s);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
for(vector<Constant>::iterator ci = constants.begin(); ci != constants.end(); ci++)
{
if (ci->name == s &&
@@ -1012,19 +904,16 @@ GTokenType Parser::parseStringOrConst (String &s)
}
printError("undeclared constant %s used", s.c_str());
}
-
parse_or_return (G_TOKEN_STRING);
s = scanner->value.v_string;
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseConstant (bool isident)
{
/*
* constant BAR = 3;
*/
Constant cdef;
-
if (isident)
parse_or_return (TOKEN_CONST_IDENT);
else
@@ -1032,9 +921,7 @@ GTokenType Parser::parseConstant (bool isident)
parse_or_return (G_TOKEN_IDENTIFIER);
cdef.name = defineSymbol (scanner->value.v_identifier);
cdef.file = fileName();
-
parse_or_return ('=');
-
/* handle ConstIdent */
if (isident)
{
@@ -1045,9 +932,7 @@ GTokenType Parser::parseConstant (bool isident)
addConstantTodo (cdef);
return G_TOKEN_NONE;
}
-
GTokenType t = g_scanner_peek_next_token (scanner);
-
/* allow positive/negative prefixing */
bool negate = FALSE;
while (t == '+' || t == '-')
@@ -1056,11 +941,9 @@ GTokenType Parser::parseConstant (bool isident)
negate = negate ^ (t == '-');
t = g_scanner_peek_next_token (scanner);
}
-
if (t == G_TOKEN_INT)
{
parse_or_return (G_TOKEN_INT);
-
cdef.type = Constant::tInt;
cdef.i = scanner->value.v_int64;
if (negate)
@@ -1069,7 +952,6 @@ GTokenType Parser::parseConstant (bool isident)
else if (t == G_TOKEN_FLOAT)
{
parse_or_return (G_TOKEN_FLOAT);
-
cdef.type = Constant::tFloat;
cdef.f = scanner->value.v_float;
if (negate)
@@ -1078,7 +960,6 @@ GTokenType Parser::parseConstant (bool isident)
else if (!negate)
{
parse_string_or_return (cdef.str);
-
cdef.type = Constant::tString;
}
else
@@ -1086,18 +967,15 @@ GTokenType Parser::parseConstant (bool isident)
return G_TOKEN_FLOAT;
}
parse_or_return (';');
-
addConstantTodo (cdef);
return G_TOKEN_NONE;
}
-
GTokenType
Parser::parseChoice ()
{
Choice choice;
int value = 0, sequentialValue = 1;
DEBUG("parse choice\n");
-
parse_or_return (TOKEN_CHOICE);
parse_or_return (G_TOKEN_IDENTIFIER);
choice.name = defineSymbol (scanner->value.v_identifier);
@@ -1112,27 +990,22 @@ Parser::parseChoice ()
while (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER)
{
ChoiceValue comp;
-
GTokenType expected_token = parseChoiceValue (comp, value, sequentialValue);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
choice.contents.push_back(comp);
}
parse_or_return (G_TOKEN_RIGHT_CURLY);
parse_or_return (';');
-
addChoiceTodo (choice);
return G_TOKEN_NONE;
}
-
static void
skip_ascii_at (GScanner *scanner)
{
if (g_scanner_peek_next_token (scanner) == '@')
g_scanner_get_next_token (scanner);
}
-
#define to_lower(c) ( \
(guchar) ( \
( (((guchar)(c))>='A' && ((guchar)(c))<='Z') * ('a'-'A') ) | \
@@ -1141,8 +1014,6 @@ skip_ascii_at (GScanner *scanner)
((guchar)(c)) \
) \
)
-
-
GTokenType
Parser::parseChoiceValue (ChoiceValue& comp, int& value, int& sequentialValue)
{
@@ -1156,7 +1027,6 @@ Parser::parseChoiceValue (ChoiceValue& comp, int& value, int& sequentialValue)
if (comp.name[i] != ':' || comp.name[i + 1] != ':')
str += comp.name[i] == ':' ? '_' : to_lower(comp.name[i]);
comp.label = g_type_name_to_sname (str.c_str());
-
/*
YES,
YES = 1,
@@ -1235,26 +1105,21 @@ Parser::parseChoiceValue (ChoiceValue& comp, int& value, int& sequentialValue)
else
return G_TOKEN_INT;
}
-
comp.value = value++;
if (comp.neutral)
comp.sequentialValue = 0;
else
comp.sequentialValue = sequentialValue++;
-
if (g_scanner_peek_next_token (scanner) == GTokenType(','))
parse_or_return (',');
else
peek_or_return ('}');
-
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseRecord ()
{
Record record;
DEBUG("parse record\n");
-
parse_or_return (TOKEN_RECORD);
parse_or_return (G_TOKEN_IDENTIFIER);
record.name = defineSymbol (scanner->value.v_identifier);
@@ -1266,7 +1131,6 @@ GTokenType Parser::parseRecord ()
return G_TOKEN_NONE;
}
parse_or_return (G_TOKEN_LEFT_CURLY);
-
bool ready = false;
while (!ready)
{
@@ -1276,11 +1140,9 @@ GTokenType Parser::parseRecord ()
case G_TOKEN_IDENTIFIER:
{
Param def;
-
expected_token = parseRecordField (def, "");
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
if (def.type != "")
record.contents.push_back(def);
}
@@ -1316,97 +1178,75 @@ GTokenType Parser::parseRecord ()
}
parse_or_return (G_TOKEN_RIGHT_CURLY);
parse_or_return (';');
-
addRecordTodo (record);
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseRecordField (Param& def, const IString& group)
{
/* FooVolumeType volume_type; */
/* float volume_perc @= ("Volume[%]", "Set how loud something is",
50, 0.0, 100.0, 5.0,
":dial:readwrite"); */
-
GTokenType expected_token = parseTypeName (def.type);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
def.pspec = NamespaceHelper::nameOf (def.type); // FIXME: correct?
def.group = group;
def.line = scanner->line;
-
parse_or_return (G_TOKEN_IDENTIFIER);
def.name = scanner->value.v_identifier;
def.file = fileName();
-
/* the hints are optional */
skip_ascii_at (scanner);
if (g_scanner_peek_next_token (scanner) == '=')
{
g_scanner_get_next_token (scanner);
-
GTokenType expected_token = parseParamHints (def);
if (expected_token != G_TOKEN_NONE)
return expected_token;
}
-
parse_or_return (';');
return G_TOKEN_NONE;
}
-
GTokenType
Parser::parseStream (Stream& stream,
Stream::Type stype)
{
/* OStream wave_out @= ("Audio Out", "Wave Output"); */
-
stream.type = stype;
stream.line = scanner->line;
-
parse_or_return (G_TOKEN_IDENTIFIER);
stream.ident = scanner->value.v_identifier;
-
skip_ascii_at (scanner);
parse_or_return ('=');
-
parse_or_return ('(');
parse_istring_or_return (stream.label);
parse_or_return (',');
parse_istring_or_return (stream.blurb);
parse_or_return (')');
-
parse_or_return (';');
return G_TOKEN_NONE;
}
-
/* like g_scanner_get_token, but accepts ':' within identifiers */
static GTokenType
scanner_get_next_token_with_colon_identifiers (GScanner *scanner)
{
char *cset_identifier_first_orig = scanner->config->cset_identifier_first;
char *cset_identifier_nth_orig = scanner->config->cset_identifier_nth;
-
String identifier_first_with_colon = cset_identifier_first_orig + String (":");
String identifier_nth_with_colon = cset_identifier_nth_orig + String (":");
-
scanner->config->cset_identifier_first = const_cast<char *>(identifier_first_with_colon.c_str());
scanner->config->cset_identifier_nth = const_cast<char *>(identifier_nth_with_colon.c_str());
-
GTokenType token = g_scanner_get_next_token (scanner);
-
scanner->config->cset_identifier_first = cset_identifier_first_orig;
scanner->config->cset_identifier_nth = cset_identifier_nth_orig;
-
return token;
}
-
/* returns true for C++ style identifiers (Foo::BAR) - only the colons are checked, not individual chars */
static bool
isCxxTypeName (const String& str)
{
enum { valid, colon1, colon2, invalid } state = valid;
-
for (String::const_iterator i = str.begin(); i != str.end(); i++)
{
if (state == valid)
@@ -1431,13 +1271,11 @@ isCxxTypeName (const String& str)
}
return (state == valid) && (str.size() != 0);
}
-
static bool
makeLiteralOptions (const String& options, String& literal_options)
{
bool failed = false;
bool in_string = false;
-
/*
* this does handle
*
@@ -1461,7 +1299,6 @@ makeLiteralOptions (const String& options, String& literal_options)
if (*oi == '\\')
{
last_was_backslash = true;
-
if ((oi + 1) != options.end()) // unescape stuff
oi++;
else
@@ -1490,13 +1327,10 @@ makeLiteralOptions (const String& options, String& literal_options)
break;
}
}
-
if (failed)
literal_options = ""; // what we've got so far might be unusable
-
return !failed;
}
-
GTokenType Parser::parseParamHints (Param &def)
{
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER)
@@ -1504,9 +1338,7 @@ GTokenType Parser::parseParamHints (Param &def)
parse_or_return (G_TOKEN_IDENTIFIER);
def.pspec = scanner->value.v_identifier;
}
-
parse_or_return ('(');
-
int bracelevel = 1;
String args;
String current_arg;
@@ -1516,7 +1348,6 @@ GTokenType Parser::parseParamHints (Param &def)
GTokenType t = scanner_get_next_token_with_colon_identifiers (scanner);
String token_as_string;
bool current_arg_complete = false;
-
if (int (t) > 0 && int (t) <= 255)
{
token_as_string = char (t);
@@ -1548,13 +1379,11 @@ GTokenType Parser::parseParamHints (Param &def)
if (isCxxTypeName (scanner->value.v_identifier))
{
String coname = qualifySymbol (scanner->value.v_identifier);
-
/* FIXME: there should be a generic const_to_string() function */
for (ci = constants.begin(); ci != constants.end(); ci++)
if (ci->name == coname)
break;
}
-
if (ci == constants.end())
token_as_string = scanner->value.v_identifier;
else switch (ci->type)
@@ -1613,7 +1442,6 @@ GTokenType Parser::parseParamHints (Param &def)
printWarning ("can't parse option string: %s", def.options.c_str());
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseInfoOptional (Map<String,IString>& infos)
{
/*
@@ -1624,32 +1452,27 @@ GTokenType Parser::parseInfoOptional (Map<String,IString>& infos)
{
String key;
IString value;
-
parse_or_return (TOKEN_INFO);
parse_or_return (G_TOKEN_IDENTIFIER);
key = scanner->value.v_identifier;
parse_or_return ('=');
parse_istring_or_return (value);
parse_or_return (';');
-
for (guint i = 0; i < key.size(); i++)
key[i] = to_lower (key[i]);
infos[key] = value;
}
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseSequence ()
{
GTokenType expected_token;
Sequence sequence;
-
/*
* sequence IntSeq {
* Int ints @= (...);
* };
*/
-
parse_or_return (TOKEN_SEQUENCE);
parse_or_return (G_TOKEN_IDENTIFIER);
sequence.name = defineSymbol (scanner->value.v_identifier);
@@ -1661,36 +1484,28 @@ GTokenType Parser::parseSequence ()
return G_TOKEN_NONE;
}
parse_or_return ('{');
-
expected_token = parseInfoOptional (sequence.infos);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
expected_token = parseRecordField (sequence.content, "");
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
expected_token = parseInfoOptional (sequence.infos);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
parse_or_return ('}');
parse_or_return (';');
-
addSequenceTodo (sequence);
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseClass ()
{
Class cdef;
DEBUG("parse class\n");
-
parse_or_return (TOKEN_CLASS);
parse_or_return (G_TOKEN_IDENTIFIER);
cdef.name = defineSymbol (scanner->value.v_identifier);
cdef.file = fileName();
-
if (g_scanner_peek_next_token (scanner) == GTokenType(';'))
{
parse_or_return (';');
@@ -1700,12 +1515,10 @@ GTokenType Parser::parseClass ()
if (g_scanner_peek_next_token (scanner) == GTokenType(':'))
{
parse_or_return (':');
-
GTokenType expected_token = parseTypeName (cdef.inherits);
if (expected_token != G_TOKEN_NONE)
return expected_token;
}
-
parse_or_return ('{');
while (g_scanner_peek_next_token (scanner) != G_TOKEN_RIGHT_CURLY)
{
@@ -1718,7 +1531,6 @@ GTokenType Parser::parseClass ()
GTokenType expected_token = parseMethod (method);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
if (method.result.type == "signal")
cdef.signals.push_back(method);
else
@@ -1735,13 +1547,10 @@ GTokenType Parser::parseClass ()
case TOKEN_PROPERTY: /* FIXME: remove me due to deprecated syntax */
{
parse_or_return (TOKEN_PROPERTY);
-
Param property;
-
expected_token = parseRecordField (property, ""); // no i18n support, deprecated
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
cdef.properties.push_back (property);
}
break;
@@ -1777,7 +1586,6 @@ GTokenType Parser::parseClass ()
GTokenType expected_token = parseStream (stream, stype);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
switch (stream.type) {
case Stream::IStream: cdef.istreams.push_back (stream); break;
case Stream::JStream: cdef.jstreams.push_back (stream); break;
@@ -1791,11 +1599,9 @@ GTokenType Parser::parseClass ()
}
parse_or_return ('}');
parse_or_return (';');
-
addClassTodo (cdef);
return G_TOKEN_NONE;
}
-
GTokenType Parser::parseMethod (Method& method)
{
peek_or_return (G_TOKEN_IDENTIFIER);
@@ -1814,33 +1620,25 @@ GTokenType Parser::parseMethod (Method& method)
GTokenType expected_token = parseTypeName (method.result.type);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
method.result.name = "result";
method.result.file = fileName();
}
-
method.result.pspec = NamespaceHelper::nameOf (method.result.type); // FIXME: correct?
-
parse_or_return (G_TOKEN_IDENTIFIER);
method.name = scanner->value.v_identifier;
method.file = fileName();
-
parse_or_return ('(');
while (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER)
{
Param def;
-
GTokenType expected_token = parseTypeName (def.type);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
def.pspec = NamespaceHelper::nameOf (def.type); // FIXME: correct?
-
parse_or_return (G_TOKEN_IDENTIFIER);
def.name = scanner->value.v_identifier;
def.file = fileName();
method.params.push_back(def);
-
if (g_scanner_peek_next_token (scanner) != GTokenType(')'))
{
parse_or_return (',');
@@ -1848,13 +1646,11 @@ GTokenType Parser::parseMethod (Method& method)
}
}
parse_or_return (')');
-
if (g_scanner_peek_next_token (scanner) == GTokenType(';'))
{
parse_or_return (';');
return G_TOKEN_NONE;
}
-
parse_or_return ('{');
while (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER ||
g_scanner_peek_next_token (scanner) == TOKEN_INFO)
@@ -1868,10 +1664,8 @@ GTokenType Parser::parseMethod (Method& method)
else
{
Param *pd = 0;
-
parse_or_return (G_TOKEN_IDENTIFIER);
String inout = scanner->value.v_identifier;
-
if (inout == "Out")
{
parse_or_return (G_TOKEN_IDENTIFIER);
@@ -1893,34 +1687,26 @@ GTokenType Parser::parseMethod (Method& method)
printError("In or Out expected in method/procedure details");
return G_TOKEN_IDENTIFIER;
}
-
if (!pd)
{
printError("can't associate method/procedure parameter details");
return G_TOKEN_IDENTIFIER;
}
-
pd->line = scanner->line;
-
skip_ascii_at (scanner);
parse_or_return ('=');
-
GTokenType expected_token = parseParamHints (*pd);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
parse_or_return (';');
}
}
parse_or_return ('}');
-
return G_TOKEN_NONE;
}
-
void Parser::addConstantTodo(const Constant& constant)
{
constants.push_back(constant);
-
if (insideInclude ())
{
includedNames.push_back (constant.name);
@@ -1930,11 +1716,9 @@ void Parser::addConstantTodo(const Constant& constant)
types.push_back (constant.name);
}
}
-
void Parser::addChoiceTodo(const Choice& choice)
{
choices.push_back(choice);
-
if (insideInclude ())
{
includedNames.push_back (choice.name);
@@ -1945,11 +1729,9 @@ void Parser::addChoiceTodo(const Choice& choice)
}
addType (choice.name, tdChoice);
}
-
void Parser::addRecordTodo(const Record& record)
{
records.push_back(record);
-
if (insideInclude ())
{
includedNames.push_back (record.name);
@@ -1960,11 +1742,9 @@ void Parser::addRecordTodo(const Record& record)
}
addType (record.name, tdRecord);
}
-
void Parser::addSequenceTodo(const Sequence& sequence)
{
sequences.push_back(sequence);
-
if (insideInclude ())
{
includedNames.push_back (sequence.name);
@@ -1975,11 +1755,9 @@ void Parser::addSequenceTodo(const Sequence& sequence)
}
addType (sequence.name, tdSequence);
}
-
void Parser::addClassTodo(const Class& cdef)
{
classes.push_back(cdef);
-
if (insideInclude ())
{
includedNames.push_back (cdef.name);
@@ -1990,11 +1768,9 @@ void Parser::addClassTodo(const Class& cdef)
}
addType (cdef.name, tdClass);
}
-
void Parser::addProcedureTodo(const Method& pdef)
{
procedures.push_back(pdef);
-
if (insideInclude ())
{
includedNames.push_back (pdef.name);
@@ -2004,20 +1780,16 @@ void Parser::addProcedureTodo(const Method& pdef)
types.push_back (pdef.name);
}
}
-
bool Parser::fromInclude(const String& type) const
{
vector<String>::const_iterator ii;
-
for (ii = includedNames.begin(); ii != includedNames.end(); ii++)
if (*ii == type) return true;
return false;
}
-
void Parser::addType (const String& type, TypeDeclaration typeDecl)
{
int& m = typeMap[type];
-
if (m == 0)
{
m = typeDecl;
@@ -2035,11 +1807,9 @@ void Parser::addType (const String& type, TypeDeclaration typeDecl)
printError ("double definition of '%s' as different types", type.c_str());
}
}
-
void Parser::addPrototype (const String& type, TypeDeclaration typeDecl)
{
int& m = typeMap[type];
-
if (m == 0)
{
m = typeDecl | tdProto;
@@ -2057,7 +1827,6 @@ void Parser::addPrototype (const String& type, TypeDeclaration typeDecl)
printError ("double definition of '%s' as different types", type.c_str());
}
}
-
String Parser::defineSymbol (const String& name)
{
Symbol *sym = currentNamespace->find (name);
@@ -2069,15 +1838,12 @@ String Parser::defineSymbol (const String& name)
}
return sym->fullName();
}
-
static list<String>
symbolToList (const String& symbol)
{
list<String> result;
String current;
-
g_return_val_if_fail (isCxxTypeName (symbol), result);
-
for (String::const_iterator si = symbol.begin(); si != symbol.end(); si++)
{
if (*si != ':')
@@ -2088,15 +1854,12 @@ symbolToList (const String& symbol)
{
if (current != "")
result.push_back(current);
-
current = "";
}
}
-
result.push_back(current);
return result;
}
-
static Symbol*
matchSymbol (const list<String>& nlist, Namespace *ns)
{
@@ -2108,7 +1871,6 @@ matchSymbol (const list<String>& nlist, Namespace *ns)
}
return symbol;
}
-
static void
appendUnique (list<Symbol *>& symbols, Symbol *sym)
{
@@ -2117,7 +1879,6 @@ appendUnique (list<Symbol *>& symbols, Symbol *sym)
return;
symbols.push_back (sym);
}
-
static void
qualifyHelper (const String& name, Namespace *ns,
list<Symbol *>& alternatives, set<Namespace *>& done)
@@ -2125,46 +1886,36 @@ qualifyHelper (const String& name, Namespace *ns,
/* prevent searching the same namespace twice */
if (done.count (ns)) return;
done.insert (ns);
-
/* try to find the symbol in the current namespace */
list<String> nlist = symbolToList (name);
Symbol *symbol = matchSymbol (nlist, ns);
if (symbol)
appendUnique (alternatives, symbol);
-
/* try to find the symbol in the parent namespace */
Namespace *parent_ns = dynamic_cast<Namespace *> (ns->parent);
if (parent_ns)
qualifyHelper (name, parent_ns, alternatives, done);
-
/* try to find the symbol in one of the namespaces used via "using namespace" */
for (vector<Namespace *>::iterator ni = ns->used.begin(); ni != ns->used.end(); ni++)
qualifyHelper (name, *ni, alternatives, done);
}
-
Symbol *Parser::qualifyHelper (const String& name)
{
set<Namespace *> done;
list<Symbol *> alternatives;
-
::qualifyHelper (name, currentNamespace, alternatives, done);
-
/* no match? */
if (alternatives.empty())
return 0;
-
/* good match? */
if (alternatives.front()->parent == currentNamespace || alternatives.size() == 1)
return alternatives.front();
-
/* multiple equally valid candidates? */
printError ("there are multiple valid interpretations of %s in this context", name.c_str());
for (list<Symbol *>::iterator ai = alternatives.begin(); ai != alternatives.end(); ai++)
printError (" - it could be %s", (*ai)->fullName().c_str());
-
return 0;
}
-
String Parser::qualifySymbol (const String& name)
{
Symbol *sym = qualifyHelper (name);
@@ -2173,7 +1924,6 @@ String Parser::qualifySymbol (const String& name)
else
return "";
}
-
bool Parser::enterNamespace (const String& name)
{
Symbol *symbol = currentNamespace->find (name);
@@ -2195,14 +1945,12 @@ bool Parser::enterNamespace (const String& name)
}
return true;
}
-
void Parser::leaveNamespace ()
{
currentNamespace = dynamic_cast<Namespace *>(currentNamespace->parent);
if (!currentNamespace)
g_error ("fatal: leaveNamespace called without corresponding enterNamespace");
}
-
bool Parser::usingNamespace (const String& name)
{
Symbol *sym = qualifyHelper (name);
@@ -2211,7 +1959,6 @@ bool Parser::usingNamespace (const String& name)
printError ("%s is an undeclared namespace (can't be used)", name.c_str());
return false;
}
-
Namespace *ns = dynamic_cast<Namespace *> (sym);
if (!ns)
{
@@ -2221,12 +1968,10 @@ bool Parser::usingNamespace (const String& name)
currentNamespace->used.push_back (ns);
return true;
}
-
/*
* the beginnings of an alternate datastructure - currently only used for namespace
* lookups
*/
-
String Symbol::fullName ()
{
if (parent && parent->fullName() != "")
@@ -2234,7 +1979,6 @@ String Symbol::fullName ()
else
return name;
}
-
Symbol *Symbol::find (const String& name)
{
for (vector<Symbol *>::iterator ci = children.begin(); ci != children.end(); ci++)
@@ -2242,29 +1986,22 @@ Symbol *Symbol::find (const String& name)
if ((*ci)->name == name)
return (*ci);
}
-
return 0;
}
-
bool Symbol::insert (Symbol *symbol)
{
if (find (symbol->name))
return false;
-
children.push_back (symbol);
symbol->parent = this;
-
return true;
}
-
Symbol::Symbol() : parent (0)
{
}
-
Symbol::~Symbol()
{
for (vector<Symbol *>::iterator ci = children.begin(); ci != children.end(); ci++)
delete *ci;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-parser.hh b/sfi/sfidl-parser.hh
index 04bc3c3..32f2795 100644
--- a/sfi/sfidl-parser.hh
+++ b/sfi/sfidl-parser.hh
@@ -1,19 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef _SFIDL_PARSER_H_
#define _SFIDL_PARSER_H_
-
#include <map>
#include "sfidl-utils.hh"
-
namespace Sfidl {
-
/* we implement a get() function since operator[] is not const */
template<typename Key, typename Value>
class Map : public std::map<Key,Value> {
private:
Value default_value;
-
public:
const Value& get(const Key& k) const {
typename std::map<Key,Value>::const_iterator i = this->find(k);
@@ -23,7 +18,6 @@ public:
return default_value;
}
};
-
/*
* internationalized string: can store a conventional string,
* however it can also store whether the string was given in
@@ -33,13 +27,10 @@ public:
class IString : public String {
public:
bool i18n;
-
IString() : i18n (false) {
}
-
IString(const char *str) : String (str), i18n (false) {
}
-
/* produces an escaped version "foo" or _("foo") */
String escaped (const String &i18n_prefix = "_") const
{
@@ -53,12 +44,10 @@ public:
return result;
}
};
-
struct LineInfo {
bool isInclude;
int line;
String filename;
-
// Produce a human readable location (file:line, using "stdin" where appropriate)
String location() const
{
@@ -69,43 +58,35 @@ struct LineInfo {
return result;
}
};
-
struct Pragma {
String filename;
String text;
int line;
bool fromInclude; /* true for normal includes; false for implIncludes and the base file */
-
bool getString (const String& key, String& value);
};
-
struct Constant {
String name;
String file;
enum { tString = 1, tFloat = 2, tInt = 3, tIdent = 4 } type;
-
String str;
float f;
int64 i;
};
-
struct Param {
String type;
String name;
String file;
-
IString group;
String pspec;
int line;
String args;
-
String label; /* first argument of the param spec contructor */
String blurb; /* second argument of the param spec contructor */
String options; /* last argument of the param spec contructor */
String literal_options; /* the real option string; note that conversion might not work,
if building the literal option string requires things like C function calls */
};
-
struct Stream {
enum Type { IStream, JStream, OStream } type;
String ident;
@@ -114,18 +95,15 @@ struct Stream {
String file;
int line;
};
-
struct ChoiceValue {
String name;
String file;
IString label;
IString blurb;
-
int value;
int sequentialValue;
bool neutral;
};
-
struct Choice {
/*
* name if the enum, "_anonymous_" for anonymous enum - of course, when
@@ -134,47 +112,38 @@ struct Choice {
*/
String name;
String file;
-
std::vector<ChoiceValue> contents;
Map<String, IString> infos;
};
-
struct Record {
String name;
String file;
-
std::vector<Param> contents;
Map<String, IString> infos;
};
-
struct Sequence {
String name;
String file;
Param content;
Map<String, IString> infos;
};
-
struct Method {
String name;
String file;
-
std::vector<Param> params;
Param result;
Map<String, IString> infos;
};
-
struct Class {
String name;
String file;
String inherits;
-
std::vector<Method> methods;
std::vector<Method> signals;
std::vector<Param> properties;
std::vector<Stream> istreams, jstreams, ostreams;
Map<String, IString> infos;
};
-
enum TypeDeclaration {
tdChoice = 1,
tdRecord = 2,
@@ -186,7 +155,6 @@ enum TypeDeclaration {
tdSequenceProto = tdSequence | tdProto,
tdClassProto = tdClass | tdProto,
};
-
enum Type {
// primitive types
VOID,
@@ -207,42 +175,32 @@ enum Type {
RECORD,
OBJECT, /* PROXY */
};
-
class Symbol {
public:
String name;
-
Symbol *parent;
std::vector<Symbol *> children;
-
Symbol();
virtual ~Symbol();
-
String fullName ();
Symbol *find (const String& name);
bool insert (Symbol *symbol);
};
-
class Namespace : public Symbol {
public:
std::vector<Namespace *> used; /* from "using namespace Foo;" statements */
};
-
class Parser {
protected:
const class Options& options;
-
GScanner *scanner;
std::vector<char> scannerInputData;
std::vector<LineInfo> scannerLineInfo;
-
Namespace rootNamespace;
Namespace *currentNamespace;
-
std::vector<String> includedNames;
std::vector<String> types;
std::map<String,int> typeMap;
-
std::vector<String> includes; // files to include
std::vector<Pragma> pragmas;
std::vector<Constant> constants;
@@ -251,41 +209,31 @@ protected:
std::vector<Record> records;
std::vector<Class> classes;
std::vector<Method> procedures;
-
// namespace related functions
-
String defineSymbol (const String& name);
Symbol *qualifyHelper (const String& name);
String qualifySymbol (const String& name);
bool enterNamespace (const String& name);
void leaveNamespace ();
bool usingNamespace (const String& name);
-
// scanner related functions
-
static void scannerMsgHandler (GScanner *scanner, gchar *message, gboolean is_error);
void printError (const gchar *format, ...) G_GNUC_PRINTF (2, 3);
void printWarning (const gchar *format, ...) G_GNUC_PRINTF (2, 3);
-
// preprocessor
-
void preprocess (const String& filename, bool includeImpl = false);
void preprocessContents (const String& filename);
bool haveIncluded (const String& filename) const;
bool insideInclude () const;
-
// parser
-
void addConstantTodo (const Constant& cdef);
void addChoiceTodo (const Choice& cdef);
void addRecordTodo (const Record& rdef);
void addSequenceTodo (const Sequence& sdef);
void addClassTodo (const Class& cdef);
void addProcedureTodo (const Method& pdef);
-
void addPrototype (const String& type, TypeDeclaration typeDecl);
void addType (const String& type, TypeDeclaration typeDecl);
-
GTokenType parseTypeName (String& s);
GTokenType parseStringOrConst (String &s);
GTokenType parseConstant (bool isident = false);
@@ -302,9 +250,7 @@ protected:
GTokenType parseInfoOptional (Map<String,IString>& infos);
public:
Parser ();
-
bool parse (const String& fileName);
-
String fileName() const { return scanner->input_name; }
const std::vector<String>& getIncludes () const { return includes; }
const std::vector<Constant>& getConstants () const { return constants; }
@@ -314,13 +260,10 @@ public:
const std::vector<Class>& getClasses () const { return classes; }
const std::vector<Method>& getProcedures () const { return procedures; }
const std::vector<String>& getTypes () const { return types; }
-
std::vector<Pragma> getPragmas (const String& binding) const;
-
Sequence findSequence (const String& name) const;
Record findRecord (const String& name) const;
const Class* findClass (const String &name) const;
-
bool isChoice (const String& type) const;
bool isSequence (const String& type) const;
bool isRecord (const String& type) const;
@@ -328,8 +271,6 @@ public:
Type typeOf (const String& type) const;
bool fromInclude (const String& type) const;
};
-
}
#endif /* _SFIDL_PARSER_H_ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-typelist.cc b/sfi/sfidl-typelist.cc
index 326dc67..123eaa5 100644
--- a/sfi/sfidl-typelist.cc
+++ b/sfi/sfidl-typelist.cc
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include "sfidl-generator.hh"
#include "sfidl-factory.hh"
#include <list>
-
using namespace Sfidl;
-
namespace {
-
class CodeGeneratorTypeList : public CodeGenerator {
public:
CodeGeneratorTypeList (const Parser &parser) : CodeGenerator (parser) {
@@ -15,28 +11,22 @@ public:
bool run ()
{
vector<String>::const_iterator ti;
-
for(ti = parser.getTypes().begin(); ti != parser.getTypes().end(); ti++)
{
if (parser.fromInclude (*ti)) continue;
-
printf ("%s\n", makeMixedName (*ti).c_str());
}
return true;
}
};
-
class TypeListFactory : public Factory {
public:
String option() const { return "--list-types"; }
String description() const { return "print all types defined in the idlfile"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new CodeGeneratorTypeList (parser);
}
} typelist_factory;
-
} // anon
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl-utils.hh b/sfi/sfidl-utils.hh
index 4a80ea0..b52d16e 100644
--- a/sfi/sfidl-utils.hh
+++ b/sfi/sfidl-utils.hh
@@ -1,24 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#ifndef _SFIDL_UTILS_HH_
#define _SFIDL_UTILS_HH_
-
#include <sfi/glib-extra.hh>
#include <birnet/birnet.hh>
#include <list>
#include <vector>
-
namespace Sfidl {
-
/* lots of helpers like string_from_int, but also typedefs like String */
using namespace Birnet;
-
/* common data structures */
using std::list;
using std::vector;
-
}
-
#endif /* _SFIDL_UTILS_HH_ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfidl.cc b/sfi/sfidl.cc
index 0113244..bd1e0f4 100644
--- a/sfi/sfidl.cc
+++ b/sfi/sfidl.cc
@@ -2,57 +2,46 @@
#include "sfidl-generator.hh"
#include "sfidl-options.hh"
#include "sfidl-parser.hh"
-
using namespace Sfidl;
-
int main (int argc, char **argv)
{
Options options;
Parser parser;
-
if (!options.parse (&argc, &argv, parser))
{
/* invalid options */
return 1;
}
-
if (options.doExit)
{
return 0;
}
-
if (options.doHelp)
{
options.printUsage ();
return 0;
}
-
if (argc != 2)
{
options.printUsage ();
return 1;
}
-
if (!options.codeGenerator)
{
options.printUsage();
return 1;
}
-
if (!parser.parse(argv[1]))
{
/* parse error */
return 1;
}
-
if (!options.codeGenerator->run ())
{
delete options.codeGenerator;
return 1;
}
-
delete options.codeGenerator;
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfifilecrawler.cc b/sfi/sfifilecrawler.cc
index 6bc34e1..932d22b 100644
--- a/sfi/sfifilecrawler.cc
+++ b/sfi/sfifilecrawler.cc
@@ -6,19 +6,12 @@
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
-
#define INCREMENTAL_RESULTS 1
-
-
/* --- prototypes --- */
static gchar* get_user_home (const gchar *user,
gboolean use_fallbacks);
-
-
/* --- variables --- */
static char *init_cwd = NULL;
-
-
/* --- functions --- */
void
_sfi_init_file_crawler (void)
@@ -35,7 +28,6 @@ _sfi_init_file_crawler (void)
init_cwd = g_strdup (G_DIR_SEPARATOR_S);
}
}
-
/**
* Create a new file crawler. A file crawler collects all files matching
* a given search path and file test.
@@ -51,7 +43,6 @@ sfi_file_crawler_new (void)
self->ptest = G_FILE_TEST_EXISTS;
return self;
}
-
/**
* @param self valid SfiFileCrawler
* RETURNS: newly allocated string containig resulting filename
@@ -64,7 +55,6 @@ sfi_file_crawler_pop (SfiFileCrawler *self)
g_return_val_if_fail (self != NULL, NULL);
return (char*) sfi_ring_pop_head (&self->results);
}
-
/**
* @param self valid SfiFileCrawler
* @param cwd absolute path
@@ -77,11 +67,9 @@ sfi_file_crawler_set_cwd (SfiFileCrawler *self,
{
g_return_if_fail (self != NULL);
g_return_if_fail (cwd != NULL && g_path_is_absolute (cwd));
-
g_free (self->cwd);
self->cwd = g_strdup (cwd);
}
-
/**
* @param self valid SfiFileCrawler
* @param tests GFileTest test flags
@@ -95,10 +83,8 @@ sfi_file_crawler_add_tests (SfiFileCrawler *self,
GFileTest tests)
{
g_return_if_fail (self != NULL);
-
self->ptest = GFileTest (self->ptest | tests);
}
-
/**
* @param self valid SfiFileCrawler
* @param pattern_paths colon (semicolon under win32) seperated search path
@@ -146,7 +132,6 @@ sfi_file_crawler_add_search_path (SfiFileCrawler *self,
}
}
}
-
static void
file_crawler_queue_readdir (SfiFileCrawler *self,
const gchar *base_dir,
@@ -154,7 +139,6 @@ file_crawler_queue_readdir (SfiFileCrawler *self,
GFileTest file_test)
{
g_assert (self->dhandle == NULL);
-
if (strchr (file_pattern, '?') || strchr (file_pattern, '*'))
{
gchar *s = g_strconcat (base_dir, G_DIR_SEPARATOR_S, NULL);
@@ -180,13 +164,11 @@ file_crawler_queue_readdir (SfiFileCrawler *self,
self->accu = sfi_ring_prepend (self->accu, s);
}
}
-
static void /* self->accu is implicit in/out arg */
file_crawler_crawl_readdir (SfiFileCrawler *self)
{
DIR *dd = (DIR*) self->dhandle;
struct dirent *d_entry = readdir (dd);
-
if (d_entry)
{
if (!(d_entry->d_name[0] == '.' && d_entry->d_name[1] == 0) &&
@@ -211,23 +193,18 @@ file_crawler_crawl_readdir (SfiFileCrawler *self)
self->ftest = GFileTest (0);
}
}
-
static void
file_crawler_queue_abs_file_path (SfiFileCrawler *self,
const gchar *path_pattern,
GFileTest file_test)
{
gchar *sep, *p, *freeme, *tmp;
-
g_assert (self->pdqueue == NULL && self->dlist == NULL && self->accu == NULL);
-
freeme = p = g_strdup (path_pattern);
-
/* seperate root */
sep = strchr (p, G_DIR_SEPARATOR);
g_return_if_fail (sep != NULL); /* absolute paths must have a seperator */
*sep++ = 0;
-
/* check root existance */
tmp = g_strconcat (p, G_DIR_SEPARATOR_S, NULL);
if (!g_file_test_all (tmp, G_FILE_TEST_IS_DIR))
@@ -237,14 +214,11 @@ file_crawler_queue_abs_file_path (SfiFileCrawler *self,
return;
}
g_free (tmp);
-
/* add root to dir list ("" on unix) */
self->dlist = sfi_ring_prepend (self->dlist, g_strdup (p));
-
/* compress multiple dir seperators */
while (*sep == G_DIR_SEPARATOR)
sep++;
-
/* add remaining segments to queue */
p = sep;
sep = strchr (p, G_DIR_SEPARATOR);
@@ -258,18 +232,14 @@ file_crawler_queue_abs_file_path (SfiFileCrawler *self,
p = sep;
sep = strchr (p, G_DIR_SEPARATOR);
}
-
/* final segment */
if (p[0])
self->pdqueue = sfi_ring_append (self->pdqueue, g_strdup (p));
-
/* final segment test */
self->stest = file_test;
-
/* cleanup */
g_free (freeme);
}
-
static void
file_crawler_crawl_abs_path (SfiFileCrawler *self)
{
@@ -319,7 +289,6 @@ file_crawler_crawl_abs_path (SfiFileCrawler *self)
/* directory path was a dead end, we're done, no result */
}
}
-
static gchar*
path_make_absolute (const gchar *rpath,
const gchar *cwd,
@@ -343,7 +312,6 @@ path_make_absolute (const gchar *rpath,
g_free (home);
return user;
}
-
static void
file_crawler_crawl_dpatterns (SfiFileCrawler *self)
{
@@ -362,7 +330,6 @@ file_crawler_crawl_dpatterns (SfiFileCrawler *self)
g_free (dpattern);
}
}
-
/**
* @param self valid SfiFileCrawler
* RETURNS: TRUE if sfi_file_crawler_crawl() should be called
@@ -375,12 +342,10 @@ gboolean
sfi_file_crawler_needs_crawl (SfiFileCrawler *self)
{
g_return_val_if_fail (self != NULL, FALSE);
-
return (self->dpatterns ||
self->pdqueue || self->dlist ||
self->dhandle);
}
-
/**
* @param self valid SfiFileCrawler
*
@@ -408,7 +373,6 @@ sfi_file_crawler_crawl (SfiFileCrawler *self)
else if (self->dpatterns)
file_crawler_crawl_dpatterns (self);
}
-
/**
* @param self valid SfiFileCrawler
*
@@ -419,7 +383,6 @@ void
sfi_file_crawler_destroy (SfiFileCrawler *self)
{
g_return_if_fail (self != NULL);
-
g_free (self->cwd);
sfi_ring_free_deep (self->results, g_free);
sfi_ring_free_deep (self->dpatterns, g_free);
@@ -431,7 +394,6 @@ sfi_file_crawler_destroy (SfiFileCrawler *self)
sfi_ring_free_deep (self->accu, g_free);
g_free (self);
}
-
/**
* @param search_path colon (semicolon under win32) seperated search path with '?' and '*' wildcards
* @param file_pattern wildcard pattern for file names
@@ -452,7 +414,6 @@ sfi_file_crawler_list_files (const gchar *search_path,
SfiRing *results;
if (!search_path)
return NULL;
-
self = sfi_file_crawler_new ();
sfi_file_crawler_add_tests (self, file_test);
sfi_file_crawler_add_search_path (self, search_path, file_pattern);
@@ -463,19 +424,15 @@ sfi_file_crawler_list_files (const gchar *search_path,
sfi_file_crawler_destroy (self);
return results;
}
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-
void
sfi_make_dirpath (const gchar *dir)
{
gchar *str, *dirpath = NULL;
guint i;
-
g_return_if_fail (dir != NULL);
-
if (!g_path_is_absolute (dir))
{
dirpath = path_make_absolute (dir, NULL, FALSE);
@@ -483,7 +440,6 @@ sfi_make_dirpath (const gchar *dir)
return;
dir = dirpath;
}
-
i = strlen (dir);
str = g_new0 (gchar, i + 1);
for (i = 0; dir[i]; i++)
@@ -502,7 +458,6 @@ sfi_make_dirpath (const gchar *dir)
g_free (str);
g_free (dirpath);
}
-
void
sfi_make_dirname_path (const gchar *file_name)
{
@@ -514,7 +469,6 @@ sfi_make_dirname_path (const gchar *file_name)
g_free (dirname);
}
}
-
/**
* @param filename possibly relative filename
* @param parentdir possibly relative parent directory path
@@ -547,7 +501,6 @@ sfi_path_get_filename (const gchar *filename,
fname = g_strdup (filename);
return fname;
}
-
/**
* @param file a file to test
* @param test bitfield of GFileTest flags
@@ -583,9 +536,7 @@ g_file_test_all (const gchar *file,
strcat (buffer, "x");
return birnet_file_check (file, buffer);
}
-
#include <pwd.h>
-
static gchar*
get_user_home (const gchar *user,
gboolean use_fallbacks)
diff --git a/sfi/sfifilecrawler.hh b/sfi/sfifilecrawler.hh
index 588eacc..6ace1d3 100644
--- a/sfi/sfifilecrawler.hh
+++ b/sfi/sfifilecrawler.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_FILE_CRAWLER_H__
#define __SFI_FILE_CRAWLER_H__
-
#include <sfi/sfitypes.hh>
#include <sfi/sfiring.hh>
-
G_BEGIN_DECLS
-
typedef struct {
SfiRing *results; /* end user results */
/*< private >*/
@@ -24,7 +21,6 @@ typedef struct {
GFileTest ftest;
SfiRing *accu; /* readdir result */
} SfiFileCrawler;
-
SfiFileCrawler* sfi_file_crawler_new (void);
gchar* sfi_file_crawler_pop (SfiFileCrawler *self);
void sfi_file_crawler_set_cwd (SfiFileCrawler *self,
@@ -37,26 +33,18 @@ void sfi_file_crawler_add_tests (SfiFileCrawler *self,
void sfi_file_crawler_crawl (SfiFileCrawler *self);
gboolean sfi_file_crawler_needs_crawl (SfiFileCrawler *self);
void sfi_file_crawler_destroy (SfiFileCrawler *self);
-
SfiRing* sfi_file_crawler_list_files (const gchar *search_path,
const gchar *file_pattern,
GFileTest file_test);
-
gchar* sfi_path_get_filename (const gchar *filename,
const gchar *parentdir);
void sfi_make_dirpath (const gchar *dir);
void sfi_make_dirname_path (const gchar *filename);
-
/* --- file tests --- */
gboolean g_file_test_all (const gchar *filename,
GFileTest test);
-
-
/* --- implementations --- */
void _sfi_init_file_crawler (void);
-
G_END_DECLS
-
#endif /* __SFI_FILE_CRAWLER_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiglue.cc b/sfi/sfiglue.cc
index 1682031..91e0608 100644
--- a/sfi/sfiglue.cc
+++ b/sfi/sfiglue.cc
@@ -5,105 +5,83 @@
#include "sfiustore.hh"
#include <string.h>
#include <gobject/gvaluecollector.h>
-
-
/* --- prototype --- */
static GHashTable* glue_gc_hash_table_new (void);
-
-
/* --- variables --- */
static GQuark quark_context_stack = 0;
-
-
/* --- context functions --- */
void
_sfi_init_glue (void)
{
g_assert (quark_context_stack == 0);
-
quark_context_stack = g_quark_from_static_string ("sfi-glue-context-stack");
}
-
void
sfi_glue_context_common_init (SfiGlueContext *context,
const SfiGlueContextTable *vtable)
{
g_return_if_fail (context->table.base_iface == NULL);
-
context->table = *vtable;
context->seq_hook_id = 1;
context->proxies = sfi_ustore_new ();
context->pending_events = NULL;
context->gc_hash = glue_gc_hash_table_new ();
}
-
void
sfi_glue_context_push (SfiGlueContext *context)
{
g_return_if_fail (context != NULL);
g_return_if_fail (context->table.destroy != NULL);
-
sfi_thread_set_qdata_full (quark_context_stack,
sfi_ring_prepend ((SfiRing*) sfi_thread_steal_qdata (quark_context_stack),
context),
(GDestroyNotify) sfi_ring_free);
}
-
SfiGlueContext*
sfi_glue_context_current (void)
{
SfiRing *context_stack = (SfiRing*) sfi_thread_get_qdata (quark_context_stack);
return (SfiGlueContext*) (context_stack ? context_stack->data : NULL);
}
-
void
sfi_glue_context_pop (void)
{
SfiRing *context_stack = (SfiRing*) sfi_thread_steal_qdata (quark_context_stack);
-
g_return_if_fail (context_stack != NULL);
-
sfi_thread_set_qdata_full (quark_context_stack,
sfi_ring_remove_node (context_stack, context_stack),
(GDestroyNotify) sfi_ring_free);
}
-
SfiRing*
sfi_glue_context_list_poll_fds (void)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
SfiRing *ring;
-
/* pfds are owned by the context implementations, the ring is dynamic */
ring = context->table.list_poll_fds (context);
if (ring)
sfi_glue_gc_add (ring, SfiGlueGcFreeFunc (sfi_ring_free));
return ring;
}
-
static void
sfi_glue_context_fetch_all_events (SfiGlueContext *context)
{
context->pending_events = sfi_ring_concat (context->pending_events,
context->table.fetch_events (context));
}
-
gboolean
sfi_glue_context_pending (void)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
if (!context->pending_events)
sfi_glue_context_fetch_all_events (context);
return context->pending_events != NULL;
}
-
void
sfi_glue_context_process_fd (void)
{
sfi_glue_context_pending ();
}
-
void
sfi_glue_context_dispatch (void)
{
@@ -114,7 +92,6 @@ sfi_glue_context_dispatch (void)
sfi_seq_unref (seq);
}
}
-
SfiSeq*
sfi_glue_context_fetch_event (void)
{
@@ -123,7 +100,6 @@ sfi_glue_context_fetch_event (void)
SfiSeq *seq = (SfiSeq*) sfi_ring_pop_head (&context->pending_events);
return seq;
}
-
gboolean
_sfi_glue_proxy_request_notify (SfiProxy proxy,
const gchar *signal,
@@ -131,10 +107,8 @@ _sfi_glue_proxy_request_notify (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gboolean connected;
-
g_return_val_if_fail (proxy != 0, FALSE);
g_return_val_if_fail (signal != NULL, FALSE);
-
connected = context->table.proxy_request_notify (context, proxy, signal, enable_notify);
if (!enable_notify) /* filter current event queue */
{
@@ -146,14 +120,11 @@ _sfi_glue_proxy_request_notify (SfiProxy proxy,
}
return connected;
}
-
void
sfi_glue_context_destroy (SfiGlueContext *context)
{
void (*destroy) (SfiGlueContext *);
-
g_return_if_fail (context != NULL);
-
sfi_glue_context_push (context);
sfi_glue_gc_run ();
_sfi_glue_context_clear_proxies (context);
@@ -172,23 +143,18 @@ sfi_glue_context_destroy (SfiGlueContext *context)
}
destroy (context);
}
-
-
/* --- VTable API --- */
static inline gulong
upper_power2 (gulong number)
{
return number ? 1 << g_bit_storage (number - 1) : 0;
}
-
SfiGlueProc*
sfi_glue_describe_proc (const gchar *proc_name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
SfiGlueProc *proc;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
proc = context->table.describe_proc (context, proc_name);
if (proc && !proc->name)
{
@@ -199,104 +165,84 @@ sfi_glue_describe_proc (const gchar *proc_name)
sfi_glue_gc_add (proc, SfiGlueGcFreeFunc (sfi_glue_proc_unref));
return proc;
}
-
const gchar**
sfi_glue_list_proc_names (void)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar **names;
-
names = context->table.list_proc_names (context);
if (!names)
names = g_new0 (gchar*, 1);
sfi_glue_gc_add (names, SfiGlueGcFreeFunc (g_strfreev));
return (const gchar**) names;
}
-
const gchar**
sfi_glue_list_method_names (const gchar *iface_name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar **names;
-
g_return_val_if_fail (iface_name != NULL, NULL);
-
names = context->table.list_method_names (context, iface_name);
if (!names)
names = g_new0 (gchar*, 1);
sfi_glue_gc_add (names, SfiGlueGcFreeFunc (g_strfreev));
return (const gchar**) names;
}
-
gchar*
sfi_glue_base_iface (void)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar *biface = context->table.base_iface (context);
-
if (biface)
sfi_glue_gc_add (biface, g_free);
return biface;
}
-
const gchar**
sfi_glue_iface_children (const gchar *iface_name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar **names;
-
g_return_val_if_fail (iface_name != NULL, NULL);
-
names = context->table.iface_children (context, iface_name);
if (!names)
names = g_new0 (gchar*, 1);
sfi_glue_gc_add (names, SfiGlueGcFreeFunc (g_strfreev));
return (const gchar**) names;
}
-
SfiGlueIFace*
sfi_glue_describe_iface (const gchar *iface_name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_val_if_fail (iface_name != NULL, NULL);
-
SfiGlueIFace *iface = context->table.describe_iface (context, iface_name);
if (iface)
sfi_glue_gc_add (iface, SfiGlueGcFreeFunc (sfi_glue_iface_unref));
return iface;
}
-
GValue*
sfi_glue_client_msg (const gchar *msg,
GValue *value)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
GValue *rvalue;
-
rvalue = context->table.client_msg (context, msg, value);
if (rvalue)
sfi_glue_gc_add (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return rvalue;
}
-
-
/* --- procedure calls --- */
GValue*
sfi_glue_call_seq (const gchar *proc_name,
SfiSeq *params)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_val_if_fail (proc_name != NULL, NULL);
g_return_val_if_fail (params != NULL, NULL);
-
GValue *value = context->table.exec_proc (context, proc_name, params);
if (value)
sfi_glue_gc_add (value, SfiGlueGcFreeFunc (sfi_value_free));
return value;
}
-
GValue*
sfi_glue_call_valist (const gchar *proc_name,
guint8 first_arg_type,
@@ -304,9 +250,7 @@ sfi_glue_call_valist (const gchar *proc_name,
{
guint8 arg_type = first_arg_type;
SfiSeq *seq;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
seq = sfi_seq_new ();
while (arg_type)
{
@@ -336,23 +280,19 @@ sfi_glue_call_valist (const gchar *proc_name,
}
return NULL;
}
-
void
sfi_glue_vcall_void (const gchar *proc_name,
guint8 first_arg_type,
...)
{
va_list var_args;
-
g_return_if_fail (proc_name != NULL);
-
va_start (var_args, first_arg_type);
GValue *rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
if (rvalue)
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
}
-
SfiBool
sfi_glue_vcall_bool (const gchar *proc_name,
guint8 first_arg_type,
@@ -361,9 +301,7 @@ sfi_glue_vcall_bool (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiBool retv = FALSE;
-
g_return_val_if_fail (proc_name != NULL, FALSE);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -373,7 +311,6 @@ sfi_glue_vcall_bool (const gchar *proc_name,
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return retv;
}
-
SfiInt
sfi_glue_vcall_int (const gchar *proc_name,
guint8 first_arg_type,
@@ -382,9 +319,7 @@ sfi_glue_vcall_int (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiInt retv = 0;
-
g_return_val_if_fail (proc_name != NULL, 0);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -394,7 +329,6 @@ sfi_glue_vcall_int (const gchar *proc_name,
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return retv;
}
-
SfiNum
sfi_glue_vcall_num (const gchar *proc_name,
guint8 first_arg_type,
@@ -403,9 +337,7 @@ sfi_glue_vcall_num (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiNum retv = 0;
-
g_return_val_if_fail (proc_name != NULL, 0);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -415,7 +347,6 @@ sfi_glue_vcall_num (const gchar *proc_name,
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return retv;
}
-
SfiReal
sfi_glue_vcall_real (const gchar *proc_name,
guint8 first_arg_type,
@@ -424,9 +355,7 @@ sfi_glue_vcall_real (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiReal retv = 0;
-
g_return_val_if_fail (proc_name != NULL, 0);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -436,7 +365,6 @@ sfi_glue_vcall_real (const gchar *proc_name,
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return retv;
}
-
const gchar*
sfi_glue_vcall_string (const gchar *proc_name,
guint8 first_arg_type,
@@ -445,9 +373,7 @@ sfi_glue_vcall_string (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
const char *retv = NULL;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -458,7 +384,6 @@ sfi_glue_vcall_string (const gchar *proc_name,
}
return retv ? retv : "";
}
-
const gchar*
sfi_glue_vcall_choice (const gchar *proc_name,
guint8 first_arg_type,
@@ -467,9 +392,7 @@ sfi_glue_vcall_choice (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
const char *retv = NULL;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -480,7 +403,6 @@ sfi_glue_vcall_choice (const gchar *proc_name,
}
return retv ? retv : "";
}
-
SfiProxy
sfi_glue_vcall_proxy (const gchar *proc_name,
guint8 first_arg_type,
@@ -489,9 +411,7 @@ sfi_glue_vcall_proxy (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiProxy retv = 0;
-
g_return_val_if_fail (proc_name != NULL, 0);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -501,7 +421,6 @@ sfi_glue_vcall_proxy (const gchar *proc_name,
sfi_glue_gc_free_now (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
return retv;
}
-
SfiSeq*
sfi_glue_vcall_seq (const gchar *proc_name,
guint8 first_arg_type,
@@ -510,9 +429,7 @@ sfi_glue_vcall_seq (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiSeq *retv = NULL;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -528,7 +445,6 @@ sfi_glue_vcall_seq (const gchar *proc_name,
}
return retv;
}
-
SfiRec*
sfi_glue_vcall_rec (const gchar *proc_name,
guint8 first_arg_type,
@@ -537,9 +453,7 @@ sfi_glue_vcall_rec (const gchar *proc_name,
va_list var_args;
GValue *rvalue;
SfiRec *retv = NULL;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -550,7 +464,6 @@ sfi_glue_vcall_rec (const gchar *proc_name,
}
return retv;
}
-
SfiFBlock*
sfi_glue_vcall_fblock (const gchar *proc_name,
guint8 first_arg_type,
@@ -558,9 +471,7 @@ sfi_glue_vcall_fblock (const gchar *proc_name,
{
va_list var_args;
GValue *rvalue;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -571,7 +482,6 @@ sfi_glue_vcall_fblock (const gchar *proc_name,
}
return NULL;
}
-
SfiBBlock*
sfi_glue_vcall_bblock (const gchar *proc_name,
guint8 first_arg_type,
@@ -579,9 +489,7 @@ sfi_glue_vcall_bblock (const gchar *proc_name,
{
va_list var_args;
GValue *rvalue;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
va_start (var_args, first_arg_type);
rvalue = sfi_glue_call_valist (proc_name, first_arg_type, var_args);
va_end (var_args);
@@ -592,14 +500,11 @@ sfi_glue_vcall_bblock (const gchar *proc_name,
}
return NULL;
}
-
-
/* --- Glue utilities --- */
SfiGlueIFace*
sfi_glue_iface_new (const gchar *iface_name)
{
SfiGlueIFace *iface;
-
iface = g_new0 (SfiGlueIFace, 1);
iface->type_name = g_strdup (iface_name ? iface_name : "<null>");
iface->n_ifaces = 0;
@@ -607,26 +512,21 @@ sfi_glue_iface_new (const gchar *iface_name)
iface->n_props = 0;
iface->props = NULL;
iface->ref_count = 1;
-
return iface;
}
-
SfiGlueIFace*
sfi_glue_iface_ref (SfiGlueIFace *iface)
{
g_return_val_if_fail (iface != NULL, NULL);
g_return_val_if_fail (iface->ref_count > 0, NULL);
-
iface->ref_count++;
return iface;
}
-
void
sfi_glue_iface_unref (SfiGlueIFace *iface)
{
g_return_if_fail (iface != NULL);
g_return_if_fail (iface->ref_count > 0);
-
iface->ref_count--;
if (!iface->ref_count)
{
@@ -637,14 +537,11 @@ sfi_glue_iface_unref (SfiGlueIFace *iface)
g_free (iface);
}
}
-
SfiGlueProc*
sfi_glue_proc_new (const gchar *proc_name)
{
SfiGlueProc *proc;
-
g_return_val_if_fail (proc_name != NULL, NULL);
-
proc = g_new0 (SfiGlueProc, 1);
proc->name = g_strdup (proc_name);
proc->help = NULL;
@@ -656,22 +553,18 @@ sfi_glue_proc_new (const gchar *proc_name)
proc->ref_count = 1;
return proc;
}
-
void
sfi_glue_proc_add_param (SfiGlueProc *proc,
GParamSpec *param)
{
guint i;
-
g_return_if_fail (proc != NULL);
g_return_if_fail (param != NULL);
-
i = proc->n_params++;
proc->params = g_renew (GParamSpec*, proc->params, proc->n_params);
proc->params[i] = g_param_spec_ref (param);
g_param_spec_sink (param);
}
-
void
sfi_glue_proc_add_ret_param (SfiGlueProc *proc,
GParamSpec *param)
@@ -679,32 +572,26 @@ sfi_glue_proc_add_ret_param (SfiGlueProc *proc,
g_return_if_fail (proc != NULL);
g_return_if_fail (param != NULL);
g_return_if_fail (proc->ret_param == NULL);
-
proc->ret_param = g_param_spec_ref (param);
g_param_spec_sink (param);
}
-
SfiGlueProc*
sfi_glue_proc_ref (SfiGlueProc *proc)
{
g_return_val_if_fail (proc != NULL, NULL);
g_return_val_if_fail (proc->ref_count > 0, NULL);
-
proc->ref_count++;
return proc;
}
-
void
sfi_glue_proc_unref (SfiGlueProc *proc)
{
g_return_if_fail (proc != NULL);
g_return_if_fail (proc->ref_count > 0);
-
proc->ref_count--;
if (!proc->ref_count)
{
g_return_if_fail (_sfi_glue_gc_test (proc, (void*) sfi_glue_proc_unref) == FALSE);
-
if (proc->ret_param)
g_param_spec_unref (proc->ret_param);
for (uint i = 0; i < proc->n_params; i++)
@@ -717,14 +604,11 @@ sfi_glue_proc_unref (SfiGlueProc *proc)
g_free (proc);
}
}
-
-
/* --- garbage collector --- */
typedef struct {
gpointer data;
void (*free_func) (gpointer);
} GcEntry;
-
static uint
glue_gc_entry_hash (gconstpointer key)
{
@@ -735,7 +619,6 @@ glue_gc_entry_hash (gconstpointer key)
h = h + (h >> 47) - (h >> 55);
return h;
}
-
static gboolean
glue_gc_entry_equal (gconstpointer key1,
gconstpointer key2)
@@ -744,7 +627,6 @@ glue_gc_entry_equal (gconstpointer key1,
const GcEntry *e2 = (const GcEntry*) key2;
return e1->free_func == e2->free_func && e1->data == e2->data;
}
-
static void
glue_gc_entry_destroy (gpointer hvalue)
{
@@ -752,30 +634,25 @@ glue_gc_entry_destroy (gpointer hvalue)
entry->free_func (entry->data);
g_free (entry);
}
-
static GHashTable*
glue_gc_hash_table_new (void)
{
return g_hash_table_new_full (glue_gc_entry_hash, glue_gc_entry_equal, NULL, glue_gc_entry_destroy);
}
-
void
sfi_glue_gc_add (gpointer data,
SfiGlueGcFreeFunc free_func)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_if_fail (free_func != NULL);
g_return_if_fail (_sfi_glue_gc_test (data, (void*) g_free) == FALSE); /* can't catch ref counted objects */
g_return_if_fail (_sfi_glue_gc_test (data, (void*) g_strfreev) == FALSE);
g_return_if_fail (_sfi_glue_gc_test (data, (void*) sfi_value_free) == FALSE);
-
GcEntry *entry = g_new (GcEntry, 1);
entry->data = data;
entry->free_func = SfiGlueGcFreeFunc (free_func);
g_hash_table_replace (context->gc_hash, entry, entry);
}
-
gboolean
_sfi_glue_gc_test (gpointer data,
gpointer free_func)
@@ -786,16 +663,13 @@ _sfi_glue_gc_test (gpointer data,
key.free_func = SfiGlueGcFreeFunc (free_func);
return g_hash_table_lookup (context->gc_hash, &key) != NULL;
}
-
void
sfi_glue_gc_remove (gpointer data,
SfiGlueGcFreeFunc free_func)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
GcEntry key, *gc_entry;
-
g_return_if_fail (free_func != NULL);
-
key.data = data;
key.free_func = SfiGlueGcFreeFunc (free_func);
gc_entry = (GcEntry*) g_hash_table_lookup (context->gc_hash, &key);
@@ -803,16 +677,13 @@ sfi_glue_gc_remove (gpointer data,
g_hash_table_steal (context->gc_hash, gc_entry);
g_free (gc_entry);
}
-
void
sfi_glue_gc_free_now (gpointer data,
SfiGlueGcFreeFunc free_func)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
GcEntry key, *gc_entry;
-
g_return_if_fail (free_func != NULL);
-
key.data = data;
key.free_func = SfiGlueGcFreeFunc (free_func);
gc_entry = (GcEntry*) g_hash_table_lookup (context->gc_hash, &key);
@@ -821,7 +692,6 @@ sfi_glue_gc_free_now (gpointer data,
g_free (gc_entry);
key.free_func (key.data);
}
-
static gboolean
slist_entries (gpointer key,
gpointer value,
@@ -831,12 +701,10 @@ slist_entries (gpointer key,
*slist_p = g_slist_prepend (*slist_p, value);
return TRUE;
}
-
void
sfi_glue_gc_run (void)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
do
{
GSList *slist, *gclist = NULL;
@@ -851,5 +719,4 @@ sfi_glue_gc_run (void)
}
while (g_hash_table_size (context->gc_hash));
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiglue.hh b/sfi/sfiglue.hh
index 35785d7..92a8992 100644
--- a/sfi/sfiglue.hh
+++ b/sfi/sfiglue.hh
@@ -1,13 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_GLUE_H__
#define __SFI_GLUE_H__
-
#include <sfi/sfiprimitives.hh>
#include <sfi/sfiring.hh>
#include <sfi/sfiparams.hh>
-
G_BEGIN_DECLS
-
/* Glue proxy (object handle) description in terms of
* supported interfaces and property names
*/
@@ -19,15 +16,11 @@ typedef struct {
guint n_props;
gchar **props;/*NULL-term*/ /* property names */
} SfiGlueIFace;
-
gchar* sfi_glue_base_iface (void);
const gchar** sfi_glue_iface_children (const gchar *iface_name);
SfiGlueIFace* sfi_glue_describe_iface (const gchar *iface_name);
SfiGlueIFace* sfi_glue_iface_ref (SfiGlueIFace *iface);
void sfi_glue_iface_unref (SfiGlueIFace *iface);
-
-
-
/* Procedure description in terms of it's parameters
*/
typedef struct {
@@ -40,13 +33,11 @@ typedef struct {
guint n_params;
GParamSpec **params;
} SfiGlueProc;
-
SfiGlueProc* sfi_glue_describe_proc (const gchar *proc_name);
SfiGlueProc* sfi_glue_proc_ref (SfiGlueProc *proc);
void sfi_glue_proc_unref (SfiGlueProc *proc);
const gchar** sfi_glue_list_proc_names (void);
const gchar** sfi_glue_list_method_names (const gchar *iface_name);
-
GValue* sfi_glue_call_seq (const gchar *proc_name,
SfiSeq *params);
GValue* sfi_glue_call_valist (const gchar *proc_name,
@@ -90,8 +81,6 @@ SfiBBlock* sfi_glue_vcall_bblock (const gchar *proc_name,
...);
GValue* sfi_glue_client_msg (const gchar *msg,
GValue *value);
-
-
/* Glue context table, abstracts middleware implementation */
typedef struct _SfiGlueContext SfiGlueContext;
typedef struct {
@@ -149,8 +138,6 @@ typedef struct {
SfiRing* (*list_poll_fds) (SfiGlueContext *context);
void (*destroy) (SfiGlueContext *context);
} SfiGlueContextTable;
-
-
/* --- Glue Context --- */
struct _SfiGlueContext
{
@@ -170,15 +157,12 @@ gboolean sfi_glue_context_pending (void);
void sfi_glue_context_dispatch (void);
SfiSeq* sfi_glue_context_fetch_event (void);
void sfi_glue_context_destroy (SfiGlueContext *context);
-
-
/* --- Glue utilities --- */
#ifdef __cplusplus
typedef void (*SfiGlueGcFreeFunc) (void*);
#else
typedef void *SfiGlueGcFreeFunc; // FIXME: remove C-legacy
#endif
-
void sfi_glue_gc_add (gpointer data,
SfiGlueGcFreeFunc free_func);
void sfi_glue_gc_remove (gpointer data,
@@ -186,8 +170,6 @@ void sfi_glue_gc_remove (gpointer data,
void sfi_glue_gc_free_now (gpointer data,
SfiGlueGcFreeFunc free_func);
void sfi_glue_gc_run (void);
-
-
/* --- internal --- */
gboolean _sfi_glue_gc_test (gpointer data,
gpointer free_func);
@@ -200,8 +182,6 @@ void sfi_glue_proc_add_ret_param (SfiGlueProc *proc,
gboolean _sfi_glue_proxy_request_notify (SfiProxy proxy,
const gchar *signal,
gboolean enable_notify);
-
-
/* --- implementations --- */
void _sfi_init_glue (void);
void sfi_glue_context_common_init (SfiGlueContext *context,
@@ -216,9 +196,6 @@ sfi_glue_fetch_context (const gchar *floc)
g_error ("%s: SfiGlue function called without context (use sfi_glue_context_push())", floc);
return context;
}
-
G_END_DECLS
-
#endif /* __SFI_GLUE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfigluecodec.cc b/sfi/sfigluecodec.cc
index 8b0ae20..4692dd7 100644
--- a/sfi/sfigluecodec.cc
+++ b/sfi/sfigluecodec.cc
@@ -3,8 +3,6 @@
#define G_LOG_DOMAIN "SFI-GLUE"
#include "sfigluecodec.hh"
#include "sfiglueproxy.hh"
-
-
/* --- prototypes --- */
static SfiGlueIFace* encoder_describe_iface (SfiGlueContext *context,
const gchar *iface);
@@ -55,8 +53,6 @@ static GValue* encoder_client_msg (SfiGlueContext *context,
static SfiRing* encoder_fetch_events (SfiGlueContext *context);
static SfiRing* encoder_list_poll_fds (SfiGlueContext *context);
static void encoder_destroy (SfiGlueContext *context);
-
-
/* --- functions --- */
SfiGlueContext*
sfi_glue_encoder_context (SfiComPort *port)
@@ -85,18 +81,14 @@ sfi_glue_encoder_context (SfiComPort *port)
encoder_destroy,
};
SfiGlueEncoder *encoder;
-
g_return_val_if_fail (port != NULL, NULL);
-
encoder = g_new0 (SfiGlueEncoder, 1);
sfi_glue_context_common_init (&encoder->context, &encoder_vtable);
encoder->port = sfi_com_port_ref (port);
g_value_init (&encoder->svalue, SFI_TYPE_SEQ);
encoder->events = NULL;
-
return &encoder->context;
}
-
#if 0
GValue* /* needs sfi_value_free() */
sfi_glue_encode_message (guint log_level,
@@ -107,13 +99,10 @@ sfi_glue_encode_message (guint log_level,
GValue *value;
SfiSeq *seq;
va_list args;
-
g_return_val_if_fail (format != NULL, NULL);
-
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
va_end (args);
-
switch (log_level)
{
case SFI_LOG_ERROR:
@@ -124,7 +113,6 @@ sfi_glue_encode_message (guint log_level,
default:
log_level = SFI_LOG_DEBUG;
}
-
seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_ASYNC_MESSAGE);
sfi_seq_append_string (seq, G_LOG_DOMAIN);
@@ -136,7 +124,6 @@ sfi_glue_encode_message (guint log_level,
return value;
}
#endif
-
static gboolean
encoder_process_message (SfiGlueEncoder *encoder,
GValue *value,
@@ -186,23 +173,19 @@ encoder_process_message (SfiGlueEncoder *encoder,
else
sfi_diag ("ignoring message of invalid type: %s", G_VALUE_TYPE_NAME (value));
sfi_value_free (value);
-
return FALSE;
}
-
static void
encoder_exec_one_way (SfiGlueContext *context,
SfiSeq *seq)
{
SfiGlueEncoder *encoder = (SfiGlueEncoder*) context;
GValue *value;
-
/* send request off to remote */
sfi_value_set_seq (&encoder->svalue, seq);
sfi_com_port_send (encoder->port, &encoder->svalue);
sfi_value_set_seq (&encoder->svalue, NULL);
sfi_seq_unref (seq);
-
/* handle incoming messages */
do
{
@@ -212,19 +195,16 @@ encoder_exec_one_way (SfiGlueContext *context,
}
while (value);
}
-
static SfiSeq*
encoder_exec_round_trip (SfiGlueContext *context,
SfiSeq *seq)
{
SfiGlueEncoder *encoder = (SfiGlueEncoder*) context;
GValue *rvalue = NULL;
-
/* send request off to remote */
sfi_value_set_seq (&encoder->svalue, seq);
sfi_com_port_send (encoder->port, &encoder->svalue);
sfi_value_set_seq (&encoder->svalue, NULL);
-
/* spin until we receive result */
while (!rvalue)
{
@@ -232,7 +212,6 @@ encoder_exec_round_trip (SfiGlueContext *context,
if (value && encoder_process_message (encoder, value, &rvalue))
break;
}
-
sfi_seq_clear (seq);
if (rvalue)
{
@@ -241,7 +220,6 @@ encoder_exec_round_trip (SfiGlueContext *context,
}
return seq;
}
-
static SfiGlueIFace*
encoder_describe_iface (SfiGlueContext *context,
const gchar *iface_name)
@@ -251,9 +229,7 @@ encoder_describe_iface (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_DESCRIBE_IFACE);
sfi_seq_append_string (seq, iface_name);
-
seq = encoder_exec_round_trip (context, seq);
-
rec = sfi_seq_get_rec (seq, 0);
if (rec)
{
@@ -266,7 +242,6 @@ encoder_describe_iface (SfiGlueContext *context,
sfi_seq_unref (seq);
return iface;
}
-
static GValue*
decoder_describe_iface (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -290,7 +265,6 @@ decoder_describe_iface (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (iface, SfiGlueGcFreeFunc (sfi_glue_iface_unref));
return rvalue;
}
-
static SfiGlueProc*
encoder_describe_proc (SfiGlueContext *context,
const gchar *proc_name)
@@ -300,9 +274,7 @@ encoder_describe_proc (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_DESCRIBE_PROC);
sfi_seq_append_string (seq, proc_name);
-
seq = encoder_exec_round_trip (context, seq);
-
rec = sfi_seq_get_rec (seq, 0);
if (rec)
{
@@ -326,7 +298,6 @@ encoder_describe_proc (SfiGlueContext *context,
sfi_seq_unref (seq);
return proc;
}
-
static GValue*
decoder_describe_proc (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -357,7 +328,6 @@ decoder_describe_proc (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (proc, SfiGlueGcFreeFunc (sfi_glue_proc_unref));
return rvalue;
}
-
static inline GValue*
seq_value_from_strv (const gchar **strv)
{
@@ -366,21 +336,17 @@ seq_value_from_strv (const gchar **strv)
sfi_seq_unref (seq);
return rvalue;
}
-
static gchar**
encoder_list_proc_names (SfiGlueContext *context)
{
gchar **strv = NULL;
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_LIST_PROC_NAMES);
-
seq = encoder_exec_round_trip (context, seq);
-
strv = sfi_seq_to_strv (sfi_seq_get_seq (seq, 0));
sfi_seq_unref (seq);
return strv;
}
-
static GValue*
decoder_list_proc_names (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -390,7 +356,6 @@ decoder_list_proc_names (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (names, SfiGlueGcFreeFunc (g_strfreev));
return rvalue;
}
-
static gchar**
encoder_list_method_names (SfiGlueContext *context,
const gchar *iface_name)
@@ -399,14 +364,11 @@ encoder_list_method_names (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_LIST_METHOD_NAMES);
sfi_seq_append_string (seq, iface_name);
-
seq = encoder_exec_round_trip (context, seq);
-
strv = sfi_seq_to_strv (sfi_seq_get_seq (seq, 0));
sfi_seq_unref (seq);
return strv;
}
-
static GValue*
decoder_list_method_names (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -416,21 +378,17 @@ decoder_list_method_names (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (names, SfiGlueGcFreeFunc (g_strfreev));
return rvalue;
}
-
static gchar*
encoder_base_iface (SfiGlueContext *context)
{
gchar *string = NULL;
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_BASE_IFACE);
-
seq = encoder_exec_round_trip (context, seq);
-
string = g_strdup (sfi_seq_get_string (seq, 0));
sfi_seq_unref (seq);
return string;
}
-
static GValue*
decoder_base_iface (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -441,7 +399,6 @@ decoder_base_iface (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (name, SfiGlueGcFreeFunc (g_free));
return rvalue;
}
-
static gchar**
encoder_iface_children (SfiGlueContext *context,
const gchar *iface_name)
@@ -450,14 +407,11 @@ encoder_iface_children (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_IFACE_CHILDREN);
sfi_seq_append_string (seq, iface_name);
-
seq = encoder_exec_round_trip (context, seq);
-
strv = sfi_seq_to_strv (sfi_seq_get_seq (seq, 0));
sfi_seq_unref (seq);
return strv;
}
-
static GValue*
decoder_iface_children (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -467,7 +421,6 @@ decoder_iface_children (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (names, SfiGlueGcFreeFunc (g_strfreev));
return rvalue;
}
-
static GValue*
encoder_exec_proc (SfiGlueContext *context,
const gchar *proc_name,
@@ -478,15 +431,12 @@ encoder_exec_proc (SfiGlueContext *context,
sfi_seq_append_int (seq, SFI_GLUE_CODEC_EXEC_PROC);
sfi_seq_append_string (seq, proc_name);
sfi_seq_append_seq (seq, params);
-
seq = encoder_exec_round_trip (context, seq);
-
if (seq->n_elements)
rvalue = sfi_value_clone_shallow (sfi_seq_get (seq, 0));
sfi_seq_unref (seq);
return rvalue;
}
-
static GValue*
decoder_exec_proc (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -497,7 +447,6 @@ decoder_exec_proc (SfiGlueDecoder *decoder,
sfi_glue_gc_remove (pvalue, SfiGlueGcFreeFunc (sfi_value_free));
return pvalue;
}
-
static gchar*
encoder_proxy_iface (SfiGlueContext *context,
SfiProxy proxy)
@@ -506,14 +455,11 @@ encoder_proxy_iface (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_IFACE);
sfi_seq_append_proxy (seq, proxy);
-
seq = encoder_exec_round_trip (context, seq);
-
string = g_strdup (sfi_seq_get_string (seq, 0));
sfi_seq_unref (seq);
return string;
}
-
static GValue*
decoder_proxy_iface (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -524,7 +470,6 @@ decoder_proxy_iface (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now ((char*) name, SfiGlueGcFreeFunc (g_free));
return rvalue;
}
-
static gboolean
encoder_proxy_is_a (SfiGlueContext *context,
SfiProxy proxy,
@@ -535,14 +480,11 @@ encoder_proxy_is_a (SfiGlueContext *context,
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_IS_A);
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, iface);
-
seq = encoder_exec_round_trip (context, seq);
-
vbool = sfi_seq_get_bool (seq, 0);
sfi_seq_unref (seq);
return vbool;
}
-
static GValue*
decoder_proxy_is_a (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -551,7 +493,6 @@ decoder_proxy_is_a (SfiGlueDecoder *decoder,
sfi_seq_get_string (seq, 2));
return sfi_value_bool (vbool);
}
-
static gchar**
encoder_proxy_list_properties (SfiGlueContext *context,
SfiProxy proxy,
@@ -564,14 +505,11 @@ encoder_proxy_list_properties (SfiGlueContext *context,
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, first_ancestor);
sfi_seq_append_string (seq, last_ancestor);
-
seq = encoder_exec_round_trip (context, seq);
-
strv = sfi_seq_to_strv (sfi_seq_get_seq (seq, 0));
sfi_seq_unref (seq);
return strv;
}
-
static GValue*
decoder_proxy_list_properties (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -584,7 +522,6 @@ decoder_proxy_list_properties (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (names, SfiGlueGcFreeFunc (g_strfreev));
return rvalue;
}
-
static GParamSpec*
encoder_proxy_get_pspec (SfiGlueContext *context,
SfiProxy proxy,
@@ -595,16 +532,13 @@ encoder_proxy_get_pspec (SfiGlueContext *context,
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_GET_PSPEC);
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, prop_name);
-
seq = encoder_exec_round_trip (context, seq);
-
pspec = sfi_seq_get_pspec (seq, 0);
if (pspec)
g_param_spec_ref (pspec);
sfi_seq_unref (seq);
return pspec;
}
-
static GValue*
decoder_proxy_get_pspec (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -617,7 +551,6 @@ decoder_proxy_get_pspec (SfiGlueDecoder *decoder,
sfi_glue_gc_free_now (pspec, SfiGlueGcFreeFunc (g_param_spec_unref));
return rvalue;
}
-
static SfiSCategory
encoder_proxy_get_pspec_scategory (SfiGlueContext *context,
SfiProxy proxy,
@@ -627,13 +560,11 @@ encoder_proxy_get_pspec_scategory (SfiGlueContext *context,
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_GET_PSPEC_SCATEGORY);
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, prop_name);
-
seq = encoder_exec_round_trip (context, seq);
SfiSCategory scat = (SfiSCategory) sfi_seq_get_int (seq, 0);
sfi_seq_unref (seq);
return scat;
}
-
static GValue*
decoder_proxy_get_pspec_scategory (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -642,7 +573,6 @@ decoder_proxy_get_pspec_scategory (SfiGlueDecoder *decoder,
sfi_seq_get_string (seq, 2));
return sfi_value_int (scat);
}
-
static void
encoder_proxy_set_property (SfiGlueContext *context,
SfiProxy proxy,
@@ -654,10 +584,8 @@ encoder_proxy_set_property (SfiGlueContext *context,
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, prop);
sfi_seq_append (seq, value);
-
encoder_exec_one_way (context, seq);
}
-
static void
decoder_proxy_set_property (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -667,7 +595,6 @@ decoder_proxy_set_property (SfiGlueDecoder *decoder,
sfi_seq_get_string (seq, 2),
sfi_seq_get (seq, 3));
}
-
static GValue*
encoder_proxy_get_property (SfiGlueContext *context,
SfiProxy proxy,
@@ -678,15 +605,12 @@ encoder_proxy_get_property (SfiGlueContext *context,
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_GET_PROPERTY);
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, prop);
-
seq = encoder_exec_round_trip (context, seq);
-
if (seq->n_elements)
rvalue = sfi_value_clone_shallow (sfi_seq_get (seq, 0));
sfi_seq_unref (seq);
return rvalue;
}
-
static GValue*
decoder_proxy_get_property (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -697,7 +621,6 @@ decoder_proxy_get_property (SfiGlueDecoder *decoder,
sfi_glue_gc_remove (pvalue, SfiGlueGcFreeFunc (sfi_value_free));
return pvalue;
}
-
static gboolean
encoder_proxy_watch_release (SfiGlueContext *context,
SfiProxy proxy)
@@ -706,14 +629,11 @@ encoder_proxy_watch_release (SfiGlueContext *context,
SfiSeq *seq = sfi_seq_new ();
sfi_seq_append_int (seq, SFI_GLUE_CODEC_PROXY_WATCH_RELEASE);
sfi_seq_append_proxy (seq, proxy);
-
seq = encoder_exec_round_trip (context, seq);
-
vbool = sfi_seq_get_bool (seq, 0);
sfi_seq_unref (seq);
return vbool;
}
-
static GValue*
decoder_proxy_watch_release (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -722,7 +642,6 @@ decoder_proxy_watch_release (SfiGlueDecoder *decoder,
vbool = _sfi_glue_proxy_watch_release (sfi_seq_get_proxy (seq, 1));
return sfi_value_bool (vbool);
}
-
static gboolean
encoder_proxy_request_notify (SfiGlueContext *context,
SfiProxy proxy,
@@ -735,14 +654,11 @@ encoder_proxy_request_notify (SfiGlueContext *context,
sfi_seq_append_proxy (seq, proxy);
sfi_seq_append_string (seq, signal);
sfi_seq_append_bool (seq, enable_notify);
-
seq = encoder_exec_round_trip (context, seq);
-
vbool = sfi_seq_get_bool (seq, 0);
sfi_seq_unref (seq);
return vbool;
}
-
static GValue*
decoder_proxy_request_notify (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -752,7 +668,6 @@ decoder_proxy_request_notify (SfiGlueDecoder *decoder,
sfi_seq_get_bool (seq, 3));
return sfi_value_bool (vbool);
}
-
static void
encoder_proxy_processed_notify (SfiGlueContext *context,
guint notify_id)
@@ -762,7 +677,6 @@ encoder_proxy_processed_notify (SfiGlueContext *context,
sfi_seq_append_int (seq, notify_id);
encoder_exec_one_way (context, seq);
}
-
static void
decoder_proxy_processed_notify (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -772,7 +686,6 @@ decoder_proxy_processed_notify (SfiGlueDecoder *decoder,
else
sfi_diag ("ignoring invalid \"processed notify\" receipt");
}
-
static GValue*
encoder_client_msg (SfiGlueContext *context,
const gchar *msg,
@@ -784,15 +697,12 @@ encoder_client_msg (SfiGlueContext *context,
sfi_seq_append_string (seq, msg);
if (value)
sfi_seq_append (seq, value);
-
seq = encoder_exec_round_trip (context, seq);
-
if (seq->n_elements)
rvalue = sfi_value_clone_shallow (sfi_seq_get (seq, 0));
sfi_seq_unref (seq);
return rvalue;
}
-
static GValue*
decoder_client_msg (SfiGlueDecoder *decoder,
SfiSeq *seq)
@@ -801,7 +711,6 @@ decoder_client_msg (SfiGlueDecoder *decoder,
GValue dummy = { 0, }, *rvalue = NULL;
GValue *cvalue = seq->n_elements > 2 ? sfi_seq_get (seq, 2) : &dummy;
guint i;
-
/* interception handler */
for (i = 0; i < decoder->n_chandler && !rvalue; i++)
rvalue = decoder->chandler[i].client_msg (decoder,
@@ -814,10 +723,8 @@ decoder_client_msg (SfiGlueDecoder *decoder,
if (rvalue)
sfi_glue_gc_remove (rvalue, SfiGlueGcFreeFunc (sfi_value_free));
}
-
return rvalue;
}
-
static SfiRing*
encoder_fetch_events (SfiGlueContext *context)
{
@@ -833,7 +740,6 @@ encoder_fetch_events (SfiGlueContext *context)
encoder->events = NULL;
return events;
}
-
static SfiRing*
encoder_list_poll_fds (SfiGlueContext *context)
{
@@ -845,7 +751,6 @@ encoder_list_poll_fds (SfiGlueContext *context)
ring = sfi_ring_prepend (ring, &pfd[n]);
return ring;
}
-
static void
encoder_destroy (SfiGlueContext *context)
{
@@ -860,7 +765,6 @@ encoder_destroy (SfiGlueContext *context)
}
g_free (encoder);
}
-
static GValue*
decoder_process_request (SfiGlueDecoder *decoder,
const GValue *value,
@@ -868,7 +772,6 @@ decoder_process_request (SfiGlueDecoder *decoder,
{
SfiSeq *seq = SFI_VALUE_HOLDS_SEQ (value) ? sfi_value_get_seq (value) : NULL;
SfiInt cmd;
-
if (!seq || seq->n_elements < 1)
{
*one_way = FALSE;
@@ -876,14 +779,12 @@ decoder_process_request (SfiGlueDecoder *decoder,
return NULL;
}
*one_way = FALSE;
-
/* here, we are processing incoming requests from remote.
* after decoding the request, we invoke actual glue layer
* functions and encode the return values to pass them back
* to the remote client.
*/
cmd = sfi_seq_get_int (seq, 0);
-
switch (cmd)
{
case SFI_GLUE_CODEC_DESCRIBE_IFACE:
@@ -930,25 +831,20 @@ decoder_process_request (SfiGlueDecoder *decoder,
sfi_diag ("ignoring request with invalid ID: %d", cmd);
return NULL;
}
-
SfiGlueDecoder*
sfi_glue_context_decoder (SfiComPort *port,
SfiGlueContext *context)
{
SfiGlueDecoder *decoder;
-
g_return_val_if_fail (port != NULL, NULL);
g_return_val_if_fail (context != NULL, NULL);
-
decoder = g_new0 (SfiGlueDecoder, 1);
decoder->context = context;
decoder->port = sfi_com_port_ref (port);
decoder->incoming = NULL;
decoder->outgoing = NULL;
-
return decoder;
}
-
void
sfi_glue_decoder_add_handler (SfiGlueDecoder *decoder,
SfiGlueDecoderClientMsg func,
@@ -961,14 +857,11 @@ sfi_glue_decoder_add_handler (SfiGlueDecoder *decoder,
decoder->chandler[i].client_msg = func;
decoder->chandler[i].user_data = user_data;
}
-
gboolean
sfi_glue_decoder_pending (SfiGlueDecoder *decoder)
{
gboolean pending;
-
g_return_val_if_fail (decoder != NULL, FALSE);
-
pending = decoder->outgoing || decoder->incoming;
if (!pending)
{
@@ -983,19 +876,14 @@ sfi_glue_decoder_pending (SfiGlueDecoder *decoder)
pending |= sfi_glue_context_pending ();
sfi_glue_context_pop ();
}
-
return pending;
}
-
void
sfi_glue_decoder_dispatch (SfiGlueDecoder *decoder)
{
SfiSeq *seq;
-
g_return_if_fail (decoder != NULL);
-
sfi_glue_context_push (decoder->context);
-
/* queue emitted signals */
seq = sfi_glue_context_fetch_event (); /* instead of sfi_glue_context_dispatch() */
while (seq)
@@ -1008,14 +896,11 @@ sfi_glue_decoder_dispatch (SfiGlueDecoder *decoder)
sfi_seq_unref (tmp);
seq = sfi_glue_context_fetch_event ();
}
-
/* send away queued signals */
sfi_com_port_send_bulk (decoder->port, decoder->outgoing);
while (decoder->outgoing)
sfi_value_free ((GValue*) sfi_ring_pop_head (&decoder->outgoing));
-
/* FIXME: catch messages */
-
/* process incoming request */
if (!decoder->incoming)
decoder->incoming = sfi_com_port_recv (decoder->port);
@@ -1041,7 +926,6 @@ sfi_glue_decoder_dispatch (SfiGlueDecoder *decoder)
else
g_assert (rvalue == NULL);
}
-
/* queue emitted signals */
seq = sfi_glue_context_fetch_event (); /* instead of sfi_glue_context_dispatch() */
while (seq)
@@ -1054,26 +938,21 @@ sfi_glue_decoder_dispatch (SfiGlueDecoder *decoder)
sfi_seq_unref (tmp);
seq = sfi_glue_context_fetch_event ();
}
-
/* send away new signals and result */
sfi_com_port_send_bulk (decoder->port, decoder->outgoing);
while (decoder->outgoing)
sfi_value_free ((GValue*) sfi_ring_pop_head (&decoder->outgoing));
sfi_com_port_process_io (decoder->port);
-
sfi_glue_gc_run ();
sfi_glue_context_pop ();
}
-
SfiRing* /* sfi_ring_free() result */
sfi_glue_decoder_list_poll_fds (SfiGlueDecoder *decoder)
{
GPollFD *pfd;
SfiRing *ring;
guint n;
-
g_return_val_if_fail (decoder != NULL, NULL);
-
sfi_glue_context_push (decoder->context);
ring = sfi_ring_copy (sfi_glue_context_list_poll_fds ());
sfi_glue_context_pop ();
@@ -1082,14 +961,11 @@ sfi_glue_decoder_list_poll_fds (SfiGlueDecoder *decoder)
ring = sfi_ring_prepend (ring, &pfd[n]);
return ring;
}
-
void
sfi_glue_decoder_destroy (SfiGlueDecoder *decoder)
{
SfiRing *ring;
-
g_return_if_fail (decoder != NULL);
-
sfi_com_port_unref (decoder->port);
for (ring = decoder->outgoing; ring; ring = sfi_ring_walk (ring, decoder->outgoing))
sfi_value_free ((GValue*) ring->data);
@@ -1099,5 +975,4 @@ sfi_glue_decoder_destroy (SfiGlueDecoder *decoder)
g_free (decoder->chandler);
g_free (decoder);
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfigluecodec.hh b/sfi/sfigluecodec.hh
index 1a91a11..50f0c5a 100644
--- a/sfi/sfigluecodec.hh
+++ b/sfi/sfigluecodec.hh
@@ -1,15 +1,11 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_GLUE_CODEC_H__
#define __SFI_GLUE_CODEC_H__
-
#include <sfi/sfiglue.hh>
#include <sfi/sficomport.hh>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
/* --- encoder API --- */
typedef struct
{
@@ -21,15 +17,11 @@ typedef struct
} SfiGlueEncoder;
/* encode glue layer API calls and pass them on to remote server */
SfiGlueContext* sfi_glue_encoder_context (SfiComPort *port);
-
-
#if 0
GValue* sfi_glue_encode_message (guint log_level,
const gchar *format,
...) G_GNUC_PRINTF (2,3);
#endif
-
-
/* --- decoder API --- */
typedef struct _SfiGlueDecoder SfiGlueDecoder;
typedef GValue* (*SfiGlueDecoderClientMsg) (SfiGlueDecoder *decoder,
@@ -59,8 +51,6 @@ SfiRing* sfi_glue_decoder_list_poll_fds (SfiGlueDecoder *decoder);
gboolean sfi_glue_decoder_pending (SfiGlueDecoder *decoder);
void sfi_glue_decoder_dispatch (SfiGlueDecoder *decoder);
void sfi_glue_decoder_destroy (SfiGlueDecoder *decoder);
-
-
/* --- implementation details --- */
typedef enum /*< skip >*/
{
@@ -86,13 +76,8 @@ typedef enum /*< skip >*/
SFI_GLUE_CODEC_PROXY_PROCESSED_NOTIFY, /* one-way */
SFI_GLUE_CODEC_CLIENT_MSG
} SfiGlueCodecCommands;
-
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __SFI_GLUE_CODEC_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiglueproxy.cc b/sfi/sfiglueproxy.cc
index 69b2f5c..c076c88 100644
--- a/sfi/sfiglueproxy.cc
+++ b/sfi/sfiglueproxy.cc
@@ -6,14 +6,10 @@
#include "sfivmarshal.hh"
#include <gobject/gvaluecollector.h>
#include <sfi/gbsearcharray.hh>
-
-
/* --- macros --- */
static SFI_MSG_TYPE_DEFINE (debug_signals, "signals", SFI_MSG_DEBUG, NULL);
#define SIGNAL_DEBUG(...) sfi_debug (debug_signals, __VA_ARGS__)
#define sfi_proxy_warn_inval(where,proxy) sfi_diag ("%s: invalid proxy id (%lu)", (where), (proxy))
-
-
/* --- structures --- */
typedef struct {
GQuark qsignal;
@@ -24,15 +20,11 @@ typedef struct {
GData *qdata;
GBSearchArray *signals;
} Proxy;
-
-
/* --- prototypes --- */
static Proxy* fetch_proxy (SfiGlueContext *context,
SfiProxy proxy);
static gint signals_compare (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2);
-
-
/* --- variables --- */
static const GBSearchConfig signals_config = {
sizeof (GlueSignal),
@@ -40,8 +32,6 @@ static const GBSearchConfig signals_config = {
G_BSEARCH_ARRAY_AUTO_SHRINK,
};
static GQuark quark_weak_refs = 0;
-
-
/* --- functions --- */
static gint
signals_compare (gconstpointer bsearch_node1, /* key */
@@ -51,14 +41,12 @@ signals_compare (gconstpointer bsearch_node1, /* key */
const GlueSignal *s2 = (const GlueSignal*) bsearch_node2;
return s1->qsignal < s2->qsignal ? -1 : s1->qsignal != s2->qsignal;
}
-
static inline Proxy*
peek_proxy (SfiGlueContext *context,
SfiProxy proxy)
{
return (Proxy*) sfi_ustore_lookup (context->proxies, proxy);
}
-
GQuark
sfi_glue_proxy_get_signal_quark (const gchar *signal)
{
@@ -77,7 +65,6 @@ sfi_glue_proxy_get_signal_quark (const gchar *signal)
g_free (sig);
return quark;
}
-
static inline GlueSignal*
peek_signal (SfiGlueContext *context,
Proxy *p,
@@ -91,14 +78,12 @@ peek_signal (SfiGlueContext *context,
}
return NULL;
}
-
static void
free_hook_list (GHookList *hlist)
{
g_hook_list_clear (hlist);
g_free (hlist);
}
-
static void
delete_signal (SfiGlueContext *context,
Proxy *p,
@@ -113,7 +98,6 @@ delete_signal (SfiGlueContext *context,
if (notify_remote)
_sfi_glue_proxy_request_notify (p->proxy, signal, FALSE);
}
-
static GlueSignal*
fetch_signal (SfiGlueContext *context,
Proxy *p,
@@ -121,7 +105,6 @@ fetch_signal (SfiGlueContext *context,
{
GQuark quark = sfi_glue_proxy_get_signal_quark (signal);
GlueSignal key, *sig = NULL;
-
key.qsignal = quark;
sig = (GlueSignal*) g_bsearch_array_lookup (p->signals, &signals_config, &key);
if (sig)
@@ -134,13 +117,11 @@ fetch_signal (SfiGlueContext *context,
p->signals = g_bsearch_array_insert (p->signals, &signals_config, &key);
return (GlueSignal*) g_bsearch_array_lookup (p->signals, &signals_config, &key);
}
-
static Proxy*
fetch_proxy (SfiGlueContext *context,
SfiProxy proxy)
{
Proxy *p = (Proxy*) sfi_ustore_lookup (context->proxies, proxy);
-
if (!p)
{
if (!context->table.proxy_watch_release (context, proxy))
@@ -155,7 +136,6 @@ fetch_proxy (SfiGlueContext *context,
}
return p;
}
-
static void
destroy_glue_proxy (SfiGlueContext *context,
Proxy *p,
@@ -163,7 +143,6 @@ destroy_glue_proxy (SfiGlueContext *context,
{
Proxy tmp = *p;
guint i;
-
/* early unlink */
sfi_ustore_remove (context->proxies, p->proxy);
g_free (p);
@@ -179,7 +158,6 @@ destroy_glue_proxy (SfiGlueContext *context,
g_datalist_id_set_data (&p->qdata, quark_weak_refs, NULL);
g_datalist_clear (&p->qdata);
}
-
static gboolean
proxy_foreach_slist (gpointer data,
gulong unique_id,
@@ -189,16 +167,12 @@ proxy_foreach_slist (gpointer data,
*slist_p = g_slist_prepend (*slist_p, (gpointer) unique_id);
return TRUE;
}
-
void
_sfi_glue_context_clear_proxies (SfiGlueContext *context)
{
GSList *plist = NULL;
-
g_return_if_fail (context != NULL);
-
/* this is called during context destruction, so remote is probably down already */
-
sfi_ustore_foreach (context->proxies, proxy_foreach_slist, &plist);
while (plist)
{
@@ -216,21 +190,17 @@ _sfi_glue_context_clear_proxies (SfiGlueContext *context)
sfi_ustore_destroy (context->proxies);
context->proxies = NULL;
}
-
static void
sfi_glue_proxy_release (SfiGlueContext *context,
SfiProxy proxy)
{
Proxy *p = peek_proxy (context, proxy);
-
g_return_if_fail (proxy != 0);
-
if (p)
destroy_glue_proxy (context, p, TRUE);
else
sfi_proxy_warn_inval (G_STRLOC, proxy);
}
-
static void
sfi_glue_proxy_signal (SfiGlueContext *context,
SfiProxy proxy,
@@ -238,9 +208,7 @@ sfi_glue_proxy_signal (SfiGlueContext *context,
SfiSeq *args)
{
Proxy *p;
-
g_return_if_fail (proxy > 0 && signal);
-
p = peek_proxy (context, proxy);
if (p)
{
@@ -254,7 +222,6 @@ sfi_glue_proxy_signal (SfiGlueContext *context,
while (hook)
{
gboolean was_in_call = G_HOOK_IN_CALL (hook);
-
hook->flags |= G_HOOK_FLAG_IN_CALL;
g_closure_invoke ((GClosure*) hook->data, NULL, args->n_elements, args->elements, (void*) signal);
if (!was_in_call)
@@ -268,7 +235,6 @@ sfi_glue_proxy_signal (SfiGlueContext *context,
else
sfi_diag ("spurious signal \"%s\" on non existing proxy (%lu)", signal, proxy);
}
-
static void
default_glue_marshal (GClosure *closure,
GValue /*out*/ *return_value,
@@ -278,11 +244,9 @@ default_glue_marshal (GClosure *closure,
gpointer marshal_data)
{
gpointer arg0, argN;
-
g_return_if_fail (return_value == NULL);
g_return_if_fail (n_param_values >= 1 && n_param_values <= 1 + SFI_VMARSHAL_MAX_ARGS);
g_return_if_fail (SFI_VALUE_HOLDS_PROXY (param_values));
-
arg0 = (gpointer) sfi_value_get_proxy (param_values);
if (G_CCLOSURE_SWAP_DATA (closure))
{
@@ -297,7 +261,6 @@ default_glue_marshal (GClosure *closure,
param_values + 1,
argN);
}
-
gulong
sfi_glue_signal_connect_closure (SfiProxy proxy,
const gchar *signal,
@@ -306,14 +269,11 @@ sfi_glue_signal_connect_closure (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p;
-
g_return_val_if_fail (proxy > 0, 0);
g_return_val_if_fail (signal != NULL, 0);
g_return_val_if_fail (closure != NULL, 0);
-
g_closure_ref (closure);
g_closure_sink (closure);
-
p = fetch_proxy (context, proxy);
if (!p)
{
@@ -344,7 +304,6 @@ sfi_glue_signal_connect_closure (SfiProxy proxy,
}
return 0;
}
-
gulong
sfi_glue_signal_connect_data (SfiProxy proxy,
const gchar *signal,
@@ -360,17 +319,14 @@ sfi_glue_signal_connect_data (SfiProxy proxy,
closure = g_cclosure_new (GCallback (sig_func), sig_data, sig_data_destroy);
return sfi_glue_signal_connect_closure (proxy, signal, closure, sig_func);
}
-
void
sfi_glue_signal_disconnect (SfiProxy proxy,
gulong connection_id)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p;
-
g_return_if_fail (proxy > 0);
g_return_if_fail (connection_id > 0);
-
p = peek_proxy (context, proxy);
if (!p)
{
@@ -401,7 +357,6 @@ sfi_glue_signal_disconnect (SfiProxy proxy,
sfi_diag ("%s: proxy (%lu) has no signal connection (%lu) to disconnect",
G_STRLOC, proxy, connection_id);
}
-
static GSList*
_sfi_glue_signal_find_closures (SfiGlueContext *context,
SfiProxy proxy,
@@ -412,10 +367,8 @@ _sfi_glue_signal_find_closures (SfiGlueContext *context,
{
GSList *ids = NULL;
Proxy *p;
-
g_return_val_if_fail (proxy > 0, NULL);
g_return_val_if_fail (search_data != NULL, NULL);
-
p = peek_proxy (context, proxy);
if (p && signal)
{
@@ -452,22 +405,18 @@ _sfi_glue_signal_find_closures (SfiGlueContext *context,
}
return ids;
}
-
void
sfi_glue_proxy_connect (SfiProxy proxy,
const gchar *signal,
...)
{
va_list var_args;
-
g_return_if_fail (proxy > 0);
-
va_start (var_args, signal);
while (signal)
{
gpointer callback = va_arg (var_args, gpointer);
gpointer data = va_arg (var_args, gpointer);
-
if (strncmp (signal, "signal::", 8) == 0)
sfi_glue_signal_connect_closure (proxy, signal + 8,
g_cclosure_new (GCallback (callback), data, NULL), callback);
@@ -492,7 +441,6 @@ sfi_glue_proxy_connect (SfiProxy proxy,
}
va_end (var_args);
}
-
void
sfi_glue_proxy_disconnect (SfiProxy proxy,
const gchar *signal,
@@ -500,16 +448,13 @@ sfi_glue_proxy_disconnect (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
va_list var_args;
-
g_return_if_fail (proxy > 0);
-
va_start (var_args, signal);
while (signal)
{
gpointer callback = va_arg (var_args, gpointer);
gpointer data = va_arg (var_args, gpointer);
GSList *node, *slist = NULL;
-
if (strncmp (signal, "any_signal::", 12) == 0 ||
strncmp (signal, "any-signal::", 12) == 0)
{
@@ -532,14 +477,12 @@ sfi_glue_proxy_disconnect (SfiProxy proxy,
sfi_diag ("%s: invalid signal spec \"%s\"", G_STRLOC, signal);
break;
}
-
if (!slist)
SIGNAL_DEBUG ("%s: signal handler %p(%p) is not connected", G_STRLOC, callback, data);
signal = va_arg (var_args, gchar*);
}
va_end (var_args);
}
-
gboolean
sfi_glue_proxy_pending (SfiProxy proxy,
const gchar *signal,
@@ -547,59 +490,44 @@ sfi_glue_proxy_pending (SfiProxy proxy,
gpointer data)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_val_if_fail (proxy > 0, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
-
GSList *slist = _sfi_glue_signal_find_closures (context, proxy, signal, data, (void*) callback, FALSE);
g_slist_free (slist);
return slist != NULL;
}
-
gboolean
_sfi_glue_proxy_watch_release (SfiProxy proxy)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_val_if_fail (proxy != 0, FALSE);
-
return context->table.proxy_watch_release (context, proxy);
}
-
void
_sfi_glue_proxy_processed_notify (guint notify_id)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_if_fail (notify_id != 0);
-
return context->table.proxy_processed_notify (context, notify_id);
}
-
gpointer
sfi_glue_proxy_get_qdata (SfiProxy proxy,
GQuark quark)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p = peek_proxy (context, proxy);
-
g_return_val_if_fail (proxy != 0, NULL);
-
return p && quark ? g_datalist_id_get_data (&p->qdata, quark) : NULL;
}
-
gpointer
sfi_glue_proxy_steal_qdata (SfiProxy proxy,
GQuark quark)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p = peek_proxy (context, proxy);
-
g_return_val_if_fail (proxy != 0, NULL);
-
return p && quark ? g_datalist_id_remove_no_notify (&p->qdata, quark) : NULL;
}
-
void
sfi_glue_proxy_set_qdata_full (SfiProxy proxy,
GQuark quark,
@@ -608,10 +536,8 @@ sfi_glue_proxy_set_qdata_full (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p;
-
g_return_if_fail (proxy != 0);
g_return_if_fail (quark != 0);
-
p = fetch_proxy (context, proxy);
if (!p)
{
@@ -622,7 +548,6 @@ sfi_glue_proxy_set_qdata_full (SfiProxy proxy,
else
g_datalist_id_set_data_full (&p->qdata, quark, data, data ? destroy : NULL);
}
-
typedef struct {
SfiProxy proxy;
guint n_weak_refs;
@@ -631,7 +556,6 @@ typedef struct {
gpointer data;
} weak_refs[1]; /* flexible array */
} ProxyWeakRefs;
-
static void
proxy_weak_refs_notify (gpointer data)
{
@@ -641,7 +565,6 @@ proxy_weak_refs_notify (gpointer data)
wstack->weak_refs[i].notify (wstack->weak_refs[i].data, wstack->proxy);
g_free (wstack);
}
-
static void
broken_weak_ref (gpointer *wref)
{
@@ -651,7 +574,6 @@ broken_weak_ref (gpointer *wref)
weak_notify (data, proxy);
g_free (wref);
}
-
void
sfi_glue_proxy_weak_ref (SfiProxy proxy,
SfiProxyDestroy weak_notify,
@@ -659,10 +581,8 @@ sfi_glue_proxy_weak_ref (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p;
-
g_return_if_fail (proxy > 0);
g_return_if_fail (weak_notify != NULL);
-
p = fetch_proxy (context, proxy);
if (!p)
{
@@ -694,7 +614,6 @@ sfi_glue_proxy_weak_ref (SfiProxy proxy,
g_datalist_id_set_data_full (&p->qdata, quark_weak_refs, wstack, proxy_weak_refs_notify);
}
}
-
void
sfi_glue_proxy_weak_unref (SfiProxy proxy,
SfiProxyDestroy weak_notify,
@@ -702,10 +621,8 @@ sfi_glue_proxy_weak_unref (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
Proxy *p;
-
g_return_if_fail (proxy > 0);
g_return_if_fail (weak_notify != NULL);
-
p = peek_proxy (context, proxy);
if (!p)
sfi_proxy_warn_inval (G_STRLOC, proxy);
@@ -716,7 +633,6 @@ sfi_glue_proxy_weak_unref (SfiProxy proxy,
if (wstack)
{
guint i;
-
for (i = 0; i < wstack->n_weak_refs; i++)
if (wstack->weak_refs[i].notify == weak_notify &&
wstack->weak_refs[i].data == data)
@@ -735,28 +651,22 @@ sfi_glue_proxy_weak_unref (SfiProxy proxy,
sfi_diag ("%s: proxy (%lu) has no weak ref %p(%p)", G_STRLOC, proxy, weak_notify, data);
}
}
-
const gchar*
sfi_glue_proxy_iface (SfiProxy proxy)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar *iface;
-
g_return_val_if_fail (proxy != 0, NULL);
-
iface = context->table.proxy_iface (context, proxy);
-
if (iface)
sfi_glue_gc_add (iface, SfiGlueGcFreeFunc (g_free));
return iface;
}
-
gboolean
sfi_glue_proxy_is_a (SfiProxy proxy,
const gchar *type)
{
g_return_val_if_fail (type != NULL, FALSE);
-
if (proxy)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
@@ -765,35 +675,28 @@ sfi_glue_proxy_is_a (SfiProxy proxy,
else
return FALSE;
}
-
GParamSpec*
sfi_glue_proxy_get_pspec (SfiProxy proxy,
const gchar *name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
GParamSpec *pspec;
-
g_return_val_if_fail (proxy != 0, NULL);
g_return_val_if_fail (name != NULL, NULL);
-
pspec = context->table.proxy_get_pspec (context, proxy, name);
if (pspec)
sfi_glue_gc_add (pspec, SfiGlueGcFreeFunc (g_param_spec_unref));
return pspec;
}
-
SfiSCategory
sfi_glue_proxy_get_pspec_scategory (SfiProxy proxy,
const gchar *name)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_val_if_fail (proxy != 0, SfiSCategory (0));
g_return_val_if_fail (name != NULL, SfiSCategory (0));
-
return context->table.proxy_get_pspec_scategory (context, proxy, name);
}
-
const gchar**
sfi_glue_proxy_list_properties (SfiProxy proxy,
const gchar *first_ancestor,
@@ -802,14 +705,11 @@ sfi_glue_proxy_list_properties (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
gchar **props;
-
g_return_val_if_fail (proxy != 0, NULL);
-
if (first_ancestor && !first_ancestor[0])
first_ancestor = NULL;
if (last_ancestor && !last_ancestor[0])
last_ancestor = NULL;
-
props = context->table.proxy_list_properties (context, proxy, first_ancestor, last_ancestor);
if (!props)
props = g_new0 (gchar*, 1);
@@ -818,37 +718,30 @@ sfi_glue_proxy_list_properties (SfiProxy proxy,
*n_props = g_strlenv (props);
return (const gchar**) props;
}
-
void
sfi_glue_proxy_set_property (SfiProxy proxy,
const gchar *prop,
const GValue *value)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_if_fail (proxy != 0);
g_return_if_fail (prop != NULL);
g_return_if_fail (G_IS_VALUE (value));
-
context->table.proxy_set_property (context, proxy, prop, value);
}
-
const GValue*
sfi_glue_proxy_get_property (SfiProxy proxy,
const gchar *prop)
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
GValue *value;
-
g_return_val_if_fail (proxy != 0, NULL);
g_return_val_if_fail (prop != NULL, NULL);
-
value = context->table.proxy_get_property (context, proxy, prop);
if (value)
sfi_glue_gc_add (value, SfiGlueGcFreeFunc (sfi_value_free));
return value;
}
-
void
sfi_glue_proxy_set (SfiProxy proxy,
const gchar *prop,
@@ -856,9 +749,7 @@ sfi_glue_proxy_set (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
va_list var_args;
-
g_return_if_fail (proxy != 0);
-
va_start (var_args, prop);
while (prop)
{
@@ -886,7 +777,6 @@ sfi_glue_proxy_set (SfiProxy proxy,
}
va_end (var_args);
}
-
void
sfi_glue_proxy_get (SfiProxy proxy,
const gchar *prop,
@@ -894,9 +784,7 @@ sfi_glue_proxy_get (SfiProxy proxy,
{
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
va_list var_args;
-
g_return_if_fail (proxy != 0);
-
va_start (var_args, prop);
while (prop)
{
@@ -919,17 +807,13 @@ sfi_glue_proxy_get (SfiProxy proxy,
}
va_end (var_args);
}
-
void
_sfi_glue_proxy_dispatch_event (SfiSeq *event)
{
static gboolean glue_proxy_dispatching = FALSE;
SfiGlueContext *context = sfi_glue_fetch_context (G_STRLOC);
-
g_return_if_fail (glue_proxy_dispatching == FALSE);
-
glue_proxy_dispatching = TRUE;
-
SfiGlueEventType event_type = (SfiGlueEventType) sfi_seq_get_int (event, 0);
switch (event_type)
{
@@ -971,7 +855,6 @@ _sfi_glue_proxy_dispatch_event (SfiSeq *event)
}
glue_proxy_dispatching = FALSE;
}
-
void
sfi_glue_proxy_cancel_matched_event (SfiSeq *event,
SfiProxy match_proxy,
diff --git a/sfi/sfiglueproxy.hh b/sfi/sfiglueproxy.hh
index d23ec05..28113f1 100644
--- a/sfi/sfiglueproxy.hh
+++ b/sfi/sfiglueproxy.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_GLUE_PROXY_H__
#define __SFI_GLUE_PROXY_H__
-
#include <sfi/sfiglue.hh>
-
G_BEGIN_DECLS
-
-
/* --- typedefs --- */
typedef enum /*< skip >*/
{
@@ -16,8 +12,6 @@ typedef enum /*< skip >*/
} SfiGlueEventType;
typedef void (*SfiProxyDestroy) (gpointer data,
SfiProxy destroyed_proxy);
-
-
/* --- functions --- */
const gchar* sfi_glue_proxy_iface (SfiProxy proxy);
gboolean sfi_glue_proxy_is_a (SfiProxy proxy,
@@ -79,8 +73,6 @@ gulong sfi_glue_signal_connect_closure (SfiProxy proxy,
gpointer search_data);
void sfi_glue_signal_disconnect (SfiProxy proxy,
gulong connection_id);
-
-
/* --- internal --- */
gboolean _sfi_glue_proxy_watch_release (SfiProxy proxy);
void _sfi_glue_proxy_processed_notify (guint notify_id);
@@ -90,10 +82,6 @@ GQuark sfi_glue_proxy_get_signal_quark (const gchar *signal);
void sfi_glue_proxy_cancel_matched_event (SfiSeq *event,
SfiProxy proxy,
GQuark signal_quark);
-
-
G_END_DECLS
-
#endif /* __SFI_GLUE_PROXY_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfimemory.cc b/sfi/sfimemory.cc
index 012d4ac..9a111b8 100644
--- a/sfi/sfimemory.cc
+++ b/sfi/sfimemory.cc
@@ -1,27 +1,20 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "sfimemory.hh"
#include <string.h>
-
-
#define PREALLOC (8)
#define SIMPLE_CACHE_SIZE (64)
#define TS8_SIZE (MAX (sizeof (GTrashStack), 8))
#define DBG8_SIZE (MAX (sizeof (gsize), 8))
-
-
/* --- variables --- */
static BirnetMutex global_memory_mutex = { 0, };
static GTrashStack *simple_cache[SIMPLE_CACHE_SIZE] = { 0, 0, 0, /* ... */ };
static gulong memory_allocated = 0;
-
-
/* --- functions --- */
gulong
sfi_alloc_upper_power2 (const gulong number)
{
return number ? 1 << g_bit_storage (number - 1) : 0;
}
-
#if 0
static inline gpointer
low_alloc (gsize mem_size)
@@ -59,7 +52,6 @@ low_alloc (gsize mem_size)
}
return mem;
}
-
static inline void
low_free (gsize mem_size,
gpointer mem)
@@ -94,58 +86,46 @@ low_free (gsize mem_size,
g_free (mem);
}
#endif
-
gpointer
sfi_alloc_memblock (gsize block_size)
{
uint8 *cmem;
size_t *debug_size;
-
g_return_val_if_fail (block_size >= sizeof (gpointer), NULL); /* cache-link size */
-
cmem = (uint8*) low_alloc (block_size + DBG8_SIZE);
debug_size = (gsize*) cmem;
*debug_size = block_size;
cmem += DBG8_SIZE;
-
return cmem;
}
-
void
sfi_free_memblock (gsize block_size,
gpointer mem)
{
size_t *debug_size;
uint8 *cmem;
-
g_return_if_fail (mem != NULL);
-
cmem = (uint8*) mem;
cmem -= DBG8_SIZE;
debug_size = (gsize*) cmem;
if (block_size != *debug_size)
g_printerr ("%s: in memory block at (%p): block_size=%zd != *debug_size=%zd\n", G_STRLOC, mem, block_size, *debug_size);
-
low_free (block_size + DBG8_SIZE, cmem);
}
-
void
sfi_alloc_report (void)
{
guint cell, cached = 0;
-
sfi_mutex_lock (&global_memory_mutex);
for (cell = 0; cell < SIMPLE_CACHE_SIZE; cell++)
{
GTrashStack *trash = simple_cache[cell];
guint memsize, n = 0;
-
while (trash)
{
n++;
trash = trash->next;
}
-
if (n)
{
memsize = (cell + 1) << 3;
@@ -156,27 +136,21 @@ sfi_alloc_report (void)
g_message ("%lu bytes allocated from system, %u bytes unused in cache", memory_allocated, cached);
sfi_mutex_unlock (&global_memory_mutex);
}
-
gpointer
sfi_alloc_memblock0 (gsize block_size)
{
gpointer mem = sfi_alloc_memblock (block_size);
-
memset (mem, 0, block_size);
-
return mem;
}
-
void
_sfi_free_node_list (gpointer mem,
gsize node_size)
{
struct LinkedData { gpointer data; LinkedData *next; };
LinkedData *tmp, *node = (LinkedData*) mem;
-
g_return_if_fail (node != NULL);
g_return_if_fail (node_size >= 2 * sizeof (gpointer));
-
/* FIXME: this can be optimized to an O(1) operation with T-style links in mem-caches */
do
{
@@ -186,7 +160,6 @@ _sfi_free_node_list (gpointer mem,
}
while (node);
}
-
void
_sfi_init_memory (void)
{
diff --git a/sfi/sfimemory.hh b/sfi/sfimemory.hh
index 8e033c2..94d1cd9 100644
--- a/sfi/sfimemory.hh
+++ b/sfi/sfimemory.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_MEMORY_H__
#define __SFI_MEMORY_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS
-
-
/* --- macros --- */
#define sfi_new_struct(type, n) ((type*) sfi_alloc_memblock (sizeof (type) * (n)))
#define sfi_new_struct0(type, n) ((type*) sfi_alloc_memblock0 (sizeof (type) * (n)))
@@ -22,8 +18,6 @@ G_BEGIN_DECLS
#define SFI_ALIGNED_SIZE(size,align) ((align) > 0 ? _SFI_INTERN_ALIGN (((gsize) (size)), ((gsize) (align))) : (gsize) (size))
#define _SFI_INTERN_ALIGN(s, a) (((s + (a - 1)) / a) * a)
#define SFI_STD_ALIGN (MAX (MAX (sizeof (float), sizeof (int)), sizeof (void*)))
-
-
/* --- implementation --- */
gpointer sfi_alloc_memblock (gsize size);
gpointer sfi_alloc_memblock0 (gsize size);
@@ -34,11 +28,6 @@ gulong sfi_alloc_upper_power2 (const gulong number);
void _sfi_free_node_list (gpointer mem,
gsize node_size);
void _sfi_init_memory (void);
-
-
-
G_END_DECLS
-
#endif /* __SFI_MEMORY_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfinote.cc b/sfi/sfinote.cc
index 35d1247..9a67814 100644
--- a/sfi/sfinote.cc
+++ b/sfi/sfinote.cc
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include "sfinote.hh"
-
#define to_lower(c) ( \
(guchar) ( \
( (((guchar)(c))>='A' && ((guchar)(c))<='Z') * ('a'-'A') ) | \
@@ -10,8 +9,6 @@
) \
)
#define is_note_letter(c) (strchr ("cdefgabh", to_lower (c)) != NULL) /* + german alias */
-
-
/* --- variables --- */
static const struct {
const char *name;
@@ -44,15 +41,12 @@ static const gchar *sfi_note_name_table[12] = {
"C", "Cis", "D", "Dis", "E", "F",
"Fis", "G", "Gis", "A", "Ais", "B",
};
-
-
/* --- functions --- */
SfiInt
sfi_note_from_string (const gchar *note_string)
{
return sfi_note_from_string_err (note_string, NULL);
}
-
SfiInt
sfi_note_from_string_err (const gchar *note_string,
gchar **error_p)
@@ -60,21 +54,17 @@ sfi_note_from_string_err (const gchar *note_string,
char *string, *freeme;
int fits, note, sharp = 0;
uint i;
-
if (error_p)
*error_p = NULL;
g_return_val_if_fail (note_string != NULL, SFI_NOTE_VOID);
-
string = freeme = g_strdup_stripped (note_string);
g_ascii_strdown (string, -1);
-
note = SFI_NOTE_VOID;
if (strcmp (string, "void") == 0) /* *valid* SFI_NOTE_VOID path */
{
g_free (freeme);
return note;
}
-
if (string[0] == '#' && is_note_letter (string[1])) /* #C-0 */
{
sharp++;
@@ -86,7 +76,6 @@ sfi_note_from_string_err (const gchar *note_string,
string[1] = string[0];
string++;
}
-
fits = FALSE;
for (i = 0; i < G_N_ELEMENTS (sfi_note_table); i++)
{
@@ -97,13 +86,11 @@ sfi_note_from_string_err (const gchar *note_string,
if (fits)
break;
}
-
note = SFI_KAMMER_NOTE; /* *invalid* note value */
if (fits)
{
char *s;
int o;
-
if (*(string + strlen (sfi_note_table[i].name)))
{
o = strtol (string + strlen (sfi_note_table[i].name), &s, 10);
@@ -112,26 +99,20 @@ sfi_note_from_string_err (const gchar *note_string,
}
else
o = 0;
-
if (fits)
note = SFI_NOTE_CLAMP (sfi_note_table[i].note + sharp + o * 12);
}
-
g_free (freeme);
-
if (!fits && error_p)
*error_p = g_strdup_printf ("invalid note specification: %s", note_string);
-
return note;
}
-
gchar*
sfi_note_to_string (SfiInt note)
{
if (SFI_NOTE_IS_VALID (note))
{
gint ht = 0, o = 0;
-
sfi_note_examine (note, &o, &ht, NULL, NULL);
if (o)
return g_strdup_printf ("%s%+d", sfi_note_name_table[ht], o);
@@ -141,7 +122,6 @@ sfi_note_to_string (SfiInt note)
else
return g_strdup ("void");
}
-
void
sfi_note_examine (gint note,
gint *octave_p,
@@ -152,14 +132,11 @@ sfi_note_examine (gint note,
static const gint8 semitone_flags[12] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
guint semitone;
gint octave;
-
g_return_if_fail (SFI_NOTE_IS_VALID (note));
-
semitone = note % 12 + (9 - (SFI_KAMMER_NOTE % 12));
note -= semitone;
octave = note - (SFI_KAMMER_NOTE - 9);
octave = octave / 12 + SFI_KAMMER_OCTAVE;
-
if (octave_p)
*octave_p = octave;
if (semitone_p)
diff --git a/sfi/sfinote.hh b/sfi/sfinote.hh
index 761bfe2..ee2222d 100644
--- a/sfi/sfinote.hh
+++ b/sfi/sfinote.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_NOTE_H__
#define __SFI_NOTE_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS
-
-
/* --- (MIDI) notes --- */
/* notes are generally kept in signed integers. though they are zero
* bounded, they are often used within expression that shouldn't be
@@ -14,30 +10,23 @@ G_BEGIN_DECLS
*/
#define SFI_MIN_NOTE (0) /* assumed to be 0 in various places */
#define SFI_MAX_NOTE (131 /* 123 */)
-
/* special note value to represent "no value specified"
* or unparsable notes.
*/
#define SFI_NOTE_VOID (SFI_MAX_NOTE + 1)
-
/* kammer note, representing the kammer frequency's midi note value */
#define SFI_KAMMER_NOTE ((SfiInt) (69) /* A' */)
#define SFI_KAMMER_OCTAVE ((SfiInt) (+1))
-
/* resulting minimum and maximum octaves */
#define SFI_MIN_OCTAVE (SFI_NOTE_OCTAVE (SFI_MIN_NOTE))
#define SFI_MAX_OCTAVE (SFI_NOTE_OCTAVE (SFI_MAX_NOTE))
-
/* macro to retrieve a valid note. simply defaults
* to kammer note for invalid note values.
*/
#define SFI_NOTE_MAKE_VALID(n) ((n) > SFI_MAX_NOTE || (n) < SFI_MIN_NOTE ? SFI_KAMMER_NOTE : ((SfiInt) (n)))
#define SFI_NOTE_IS_VALID(n) ((n) >= SFI_MIN_NOTE && (n) <= SFI_MAX_NOTE)
-
/* clamp note against boundaries in cases of underflow or overflow */
#define SFI_NOTE_CLAMP(n) (CLAMP (((SfiInt) (n)), SFI_MIN_NOTE, SFI_MAX_NOTE))
-
-
/* macros to compose and decompose note values into semitones and octaves */
#define SFI_NOTE_OCTAVE(n) ((((SfiInt) (n)) - SFI_NOTE_SEMITONE (n) - (SFI_KAMMER_NOTE - 9)) / 12 + SFI_KAMMER_OCTAVE)
#define SFI_NOTE_SEMITONE(n) (((SfiInt) (n)) % 12 + (9 - (SFI_KAMMER_NOTE % 12)))
@@ -63,8 +52,6 @@ G_BEGIN_DECLS
#define SFI_NOTE_SHIFT(n,ht_i) (_SFI_NOTE_SHIFT_AUX ((SfiInt) (n), (gint) (ht), (SfiInt) (n)))
#define SFI_NOTE_OCTAVE_UP(n) (SFI_NOTE_SHIFT ((n), +12))
#define SFI_NOTE_OCTAVE_DOWN(n) (SFI_NOTE_SHIFT ((n), -12))
-
-
/* --- functions --- */
void sfi_note_examine (SfiInt note,
gint *octave_p,
@@ -77,10 +64,6 @@ gchar* sfi_note_to_string (SfiInt note);
SfiInt sfi_note_from_string (const gchar *note_string);
SfiInt sfi_note_from_string_err (const gchar *note_string,
gchar **error_p);
-
-
G_END_DECLS
-
#endif /* __SFI_NOTE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiparams.cc b/sfi/sfiparams.cc
index 7642337..ecebd34 100644
--- a/sfi/sfiparams.cc
+++ b/sfi/sfiparams.cc
@@ -4,10 +4,7 @@
#include "sfiprimitives.hh"
#include "sfinote.hh"
#include "sfitime.hh"
-
#define NULL_CHECKED(x) ((x) && (x)[0] ? x : NULL)
-
-
typedef struct {
gint (*values_cmp) (GParamSpec *pspec,
const GValue *value1,
@@ -16,13 +13,11 @@ typedef struct {
GValue *value);
void (*finalize) (GParamSpec *pspec);
} PSpecClassData;
-
static inline GParamSpec*
param_spec_internal (GType param_type, const char *name, const char *nick, const char *blurb, GParamFlags flags)
{
return (GParamSpec*) g_param_spec_internal (param_type, name, nick, blurb, flags);
}
-
/* --- prototypes --- */
static gint param_bblock_values_cmp (GParamSpec *pspec,
const GValue *value1,
@@ -47,8 +42,6 @@ static void param_class_init (gpointer klass,
gpointer class_data);
static void sfi_pspec_copy_commons (GParamSpec *src_pspec,
GParamSpec *dest_pspec);
-
-
/* --- variables --- */
GType *sfi__param_spec_types = NULL;
static GQuark quark_hints = 0;
@@ -58,8 +51,6 @@ static GQuark quark_enum_choice_value_getter = 0;
static GQuark quark_tmp_choice_values = 0;
static GQuark quark_tmp_record_fields = 0;
static GQuark quark_boxed_info = 0;
-
-
/* --- functions --- */
void
_sfi_init_params (void)
@@ -76,11 +67,8 @@ _sfi_init_params (void)
NULL, /* instance_init */
};
static GType pspec_types[7] = { 0, };
-
g_assert (sfi__param_spec_types == NULL);
-
sfi__param_spec_types = pspec_types;
-
quark_hints = g_quark_from_static_string ("sfi-pspec-hints");
quark_param_group = g_quark_from_static_string ("sfi-pspec-group");
quark_param_owner = g_quark_from_static_string ("sfi-pspec-owner");
@@ -88,7 +76,6 @@ _sfi_init_params (void)
quark_tmp_choice_values = g_quark_from_static_string ("sfi-tmp-choice-values");
quark_tmp_record_fields = g_quark_from_static_string ("sfi-tmp-choice-values");
quark_boxed_info = g_quark_from_static_string ("sfi-boxed-info");
-
/* pspec types */
info.instance_size = sizeof (SfiParamSpecProxy);
SFI_TYPE_PARAM_PROXY = g_type_register_static (G_TYPE_PARAM_POINTER, "SfiParamSpecProxy", &info, GTypeFlags (0));
@@ -139,7 +126,6 @@ _sfi_init_params (void)
SFI_TYPE_PARAM_NOTE = g_type_register_static (SFI_TYPE_PARAM_INT, "SfiParamSpecNote", &info, GTypeFlags (0));
}
}
-
static void
param_class_init (gpointer klass,
gpointer class_data)
@@ -156,8 +142,6 @@ param_class_init (gpointer klass,
pclass->finalize = cdata->finalize;
}
}
-
-
/* --- Sfi GParamSpec implementations --- */
static gint
param_bblock_values_cmp (GParamSpec *pspec,
@@ -167,10 +151,8 @@ param_bblock_values_cmp (GParamSpec *pspec,
// SfiParamSpecBBlock *bspec = SFI_PSPEC_BBLOCK (pspec);
SfiBBlock *bblock1 = sfi_value_get_bblock (value1);
SfiBBlock *bblock2 = sfi_value_get_bblock (value2);
-
if (!bblock1 || !bblock2)
return bblock2 ? -1 : bblock1 != bblock2;
-
if (bblock1->n_bytes != bblock2->n_bytes)
return bblock1->n_bytes < bblock2->n_bytes ? -1 : 1;
else /* bblock1->n_bytes == bblock2->n_bytes */
@@ -182,7 +164,6 @@ param_bblock_values_cmp (GParamSpec *pspec,
return 0; /* all values equal */
}
}
-
static gint
param_fblock_values_cmp (GParamSpec *pspec,
const GValue *value1,
@@ -191,10 +172,8 @@ param_fblock_values_cmp (GParamSpec *pspec,
// SfiParamSpecFBlock *fspec = SFI_PSPEC_FBLOCK (pspec);
SfiFBlock *fblock1 = sfi_value_get_fblock (value1);
SfiFBlock *fblock2 = sfi_value_get_fblock (value2);
-
if (!fblock1 || !fblock2)
return fblock2 ? -1 : fblock1 != fblock2;
-
if (fblock1->n_values != fblock2->n_values)
return fblock1->n_values < fblock2->n_values ? -1 : 1;
else /* fblock1->n_values == fblock2->n_values */
@@ -206,7 +185,6 @@ param_fblock_values_cmp (GParamSpec *pspec,
return 0; /* all values equal */
}
}
-
static gint
param_seq_values_cmp (GParamSpec *pspec,
const GValue *value1,
@@ -215,10 +193,8 @@ param_seq_values_cmp (GParamSpec *pspec,
SfiParamSpecSeq *sspec = SFI_PSPEC_SEQ (pspec);
SfiSeq *seq1 = sfi_value_get_seq (value1);
SfiSeq *seq2 = sfi_value_get_seq (value2);
-
if (!seq1 || !seq2)
return seq2 ? -1 : seq1 != seq2;
-
if (seq1->n_elements != seq2->n_elements)
return seq1->n_elements < seq2->n_elements ? -1 : 1;
else if (!sspec->element)
@@ -231,13 +207,11 @@ param_seq_values_cmp (GParamSpec *pspec,
else /* seq1->n_elements == seq2->n_elements */
{
guint i;
-
for (i = 0; i < seq1->n_elements; i++)
{
GValue *element1 = seq1->elements + i;
GValue *element2 = seq2->elements + i;
gint cmp;
-
/* need corresponding element types, provide stable result otherwise */
if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2))
return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1;
@@ -251,7 +225,6 @@ param_seq_values_cmp (GParamSpec *pspec,
return 0;
}
}
-
static gint
param_rec_values_cmp (GParamSpec *pspec,
const GValue *value1,
@@ -260,17 +233,14 @@ param_rec_values_cmp (GParamSpec *pspec,
// SfiParamSpecRec *rspec = SFI_PSPEC_REC (pspec);
SfiRec *rec1 = sfi_value_get_rec (value1);
SfiRec *rec2 = sfi_value_get_rec (value2);
-
if (!rec1 || !rec2)
return rec2 ? -1 : rec1 != rec2;
// if (rec1->n_fields) return -1;
-
if (rec1->n_fields != rec2->n_fields)
return rec1->n_fields < rec2->n_fields ? -1 : 1;
else /* rec1->n_fields == rec2->n_fields */
{
guint i;
-
sfi_rec_sort (rec1);
sfi_rec_sort (rec2);
for (i = 0; i < rec1->n_fields; i++)
@@ -281,15 +251,12 @@ param_rec_values_cmp (GParamSpec *pspec,
GValue *field2 = rec2->fields + i;
GParamSpec *fspec;
gint cmp;
-
cmp = strcmp (field_name1, field_name2);
if (cmp)
return cmp;
-
/* need corresponding field types, provide stable result otherwise */
if (G_VALUE_TYPE (field1) != G_VALUE_TYPE (field2))
return G_VALUE_TYPE (field1) < G_VALUE_TYPE (field2) ? -1 : 1;
-
fspec = sfi_pspec_get_rec_field (pspec, field_name1);
/* ignore fields without or non conforming param specs */
if (fspec && G_VALUE_HOLDS (field1, G_PARAM_SPEC_VALUE_TYPE (fspec)))
@@ -302,7 +269,6 @@ param_rec_values_cmp (GParamSpec *pspec,
return 0;
}
}
-
static gboolean
param_seq_validate (GParamSpec *pspec,
GValue *value)
@@ -310,16 +276,13 @@ param_seq_validate (GParamSpec *pspec,
SfiParamSpecSeq *sspec = SFI_PSPEC_SEQ (pspec);
SfiSeq *seq = sfi_value_get_seq (value);
guint changed = 0;
-
if (seq && sspec->element)
{
GParamSpec *element_spec = sspec->element;
guint i;
-
for (i = 0; i < seq->n_elements; i++)
{
GValue *element = seq->elements + i;
-
/* support conversion of wrongly typed elements */
if (G_VALUE_TYPE (element) != G_PARAM_SPEC_VALUE_TYPE (element_spec) &&
sfi_value_type_transformable (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
@@ -331,7 +294,6 @@ param_seq_validate (GParamSpec *pspec,
memcpy (element, &dummy, sizeof (dummy)); /* relocate value */
changed++;
}
-
/* need to fixup value type, or ensure that the element is initialized at all */
if (!sfi_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
{
@@ -341,14 +303,12 @@ param_seq_validate (GParamSpec *pspec,
g_param_value_set_default (element_spec, element);
changed++;
}
-
/* validate element against element_spec */
changed += g_param_value_validate (element_spec, element);
}
}
return changed;
}
-
static void
param_seq_finalize (GParamSpec *pspec)
{
@@ -363,24 +323,20 @@ param_seq_finalize (GParamSpec *pspec)
klass = (GParamSpecClass*) g_type_class_peek_parent (klass);
klass->finalize (pspec);
}
-
static gboolean
param_rec_validate (GParamSpec *pspec,
GValue *value)
{
SfiRec *rec = sfi_value_get_rec (value);
guint changed = 0;
-
if (rec)
{
SfiRecFields fspecs = sfi_pspec_get_rec_fields (pspec);
guint i;
-
for (i = 0; i < fspecs.n_fields; i++)
{
GParamSpec *fspec = fspecs.fields[i];
GValue *field = sfi_rec_get (rec, fspec->name);
-
/* ensure field presence */
if (!field)
{
@@ -392,7 +348,6 @@ param_rec_validate (GParamSpec *pspec,
field = sfi_rec_get (rec, fspec->name);
changed++;
}
-
/* support conversion of wrongly typed fields */
if (G_VALUE_TYPE (field) != G_PARAM_SPEC_VALUE_TYPE (fspec) &&
sfi_value_type_transformable (G_VALUE_TYPE (field), G_PARAM_SPEC_VALUE_TYPE (fspec)))
@@ -404,7 +359,6 @@ param_rec_validate (GParamSpec *pspec,
memcpy (field, &dummy, sizeof (dummy)); /* relocate value */
changed++;
}
-
/* need to fixup value type, or ensure that the field is initialized at all */
if (!sfi_value_type_compatible (G_VALUE_TYPE (field), G_PARAM_SPEC_VALUE_TYPE (fspec)))
{
@@ -414,14 +368,12 @@ param_rec_validate (GParamSpec *pspec,
g_param_value_set_default (fspec, field);
changed++;
}
-
/* validate field against field_spec */
changed += g_param_value_validate (fspec, field);
}
}
return changed;
}
-
static gboolean
param_note_validate (GParamSpec *pspec,
GValue *value)
@@ -430,7 +382,6 @@ param_note_validate (GParamSpec *pspec,
SfiInt min, max;
gboolean allow_void;
guint changed = 0;
-
sfi_pspec_get_note_range (pspec, &min, &max, NULL);
allow_void = sfi_pspec_allows_void_note (pspec);
if (allow_void && note == SFI_NOTE_VOID)
@@ -442,8 +393,6 @@ param_note_validate (GParamSpec *pspec,
}
return changed;
}
-
-
/* --- Sfi GParamSpec constructors --- */
GParamSpec*
sfi_pspec_bool (const gchar *name,
@@ -453,13 +402,10 @@ sfi_pspec_bool (const gchar *name,
const gchar *hints)
{
g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
-
GParamSpec *pspec = g_param_spec_boolean (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), default_value, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
-
return pspec;
}
-
GParamSpec*
sfi_pspec_int (const gchar *name,
const gchar *nick,
@@ -473,14 +419,11 @@ sfi_pspec_int (const gchar *name,
g_return_val_if_fail (default_value >= minimum_value && default_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value + stepping <= maximum_value, NULL);
-
GParamSpec *pspec = g_param_spec_int (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), minimum_value, maximum_value, default_value, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
g_param_spec_set_istepping (pspec, stepping);
-
return pspec;
}
-
GParamSpec*
sfi_pspec_num (const gchar *name,
const gchar *nick,
@@ -494,14 +437,11 @@ sfi_pspec_num (const gchar *name,
g_return_val_if_fail (default_value >= minimum_value && default_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value + stepping <= maximum_value, NULL);
-
GParamSpec *pspec = g_param_spec_int64 (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), minimum_value, maximum_value, default_value, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
g_param_spec_set_istepping (pspec, stepping);
-
return pspec;
}
-
GParamSpec*
sfi_pspec_real (const gchar *name,
const gchar *nick,
@@ -515,13 +455,11 @@ sfi_pspec_real (const gchar *name,
g_return_val_if_fail (default_value >= minimum_value && default_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value <= maximum_value, NULL);
g_return_val_if_fail (minimum_value + stepping <= maximum_value, NULL);
-
GParamSpec *pspec = g_param_spec_double (name, NULL_CHECKED (nick), NULL_CHECKED (blurb), minimum_value, maximum_value, default_value, GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
g_param_spec_set_fstepping (pspec, stepping);
return pspec;
}
-
GParamSpec*
sfi_pspec_log_scale (const gchar *name,
const gchar *nick,
@@ -536,16 +474,13 @@ sfi_pspec_log_scale (const gchar *name,
const gchar *hints)
{
GParamSpec *pspec;
-
g_return_val_if_fail (n_steps > 0, NULL);
g_return_val_if_fail (base > 0, NULL);
-
pspec = sfi_pspec_real (name, nick, blurb, default_value, minimum_value, maximum_value, stepping, hints);
if (pspec)
sfi_pspec_set_log_scale (pspec, center, base, n_steps);
return pspec;
}
-
GParamSpec*
sfi_pspec_string (const gchar *name,
const gchar *nick,
@@ -558,10 +493,8 @@ sfi_pspec_string (const gchar *name,
GParamSpecString *sspec = (GParamSpecString*) G_PARAM_SPEC_STRING (pspec);
g_free (sspec->default_value);
sspec->default_value = g_strdup (default_value);
-
return pspec;
}
-
GParamSpec*
sfi_pspec_choice (const gchar *name,
const gchar *nick,
@@ -571,7 +504,6 @@ sfi_pspec_choice (const gchar *name,
const gchar *hints)
{
g_return_val_if_fail (static_const_cvalues.n_values >= 1, NULL);
-
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_CHOICE, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
@@ -580,10 +512,8 @@ sfi_pspec_choice (const gchar *name,
SfiParamSpecChoice *cspec = SFI_PSPEC_CHOICE (pspec);
cspec->cvalues = static_const_cvalues;
pspec->value_type = SFI_TYPE_CHOICE;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_bblock (const gchar *name,
const gchar *nick,
@@ -594,10 +524,8 @@ sfi_pspec_bblock (const gchar *name,
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_BBLOCK, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
pspec->value_type = SFI_TYPE_BBLOCK;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_fblock (const gchar *name,
const gchar *nick,
@@ -608,10 +536,8 @@ sfi_pspec_fblock (const gchar *name,
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_FBLOCK, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
pspec->value_type = SFI_TYPE_FBLOCK;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_pspec (const gchar *name,
const gchar *nick,
@@ -622,10 +548,8 @@ sfi_pspec_pspec (const gchar *name,
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_PSPEC, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
pspec->value_type = G_TYPE_PARAM;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_seq (const gchar *name,
const gchar *nick,
@@ -635,7 +559,6 @@ sfi_pspec_seq (const gchar *name,
{
if (element_spec)
g_return_val_if_fail (G_IS_PARAM_SPEC (element_spec), NULL);
-
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_SEQ, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
if (element_spec)
@@ -645,10 +568,8 @@ sfi_pspec_seq (const gchar *name,
g_param_spec_sink (element_spec);
}
pspec->value_type = SFI_TYPE_SEQ;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_rec (const gchar *name,
const gchar *nick,
@@ -661,10 +582,8 @@ sfi_pspec_rec (const gchar *name,
SfiParamSpecRec *rspec = SFI_PSPEC_REC (pspec);
rspec->fields = static_const_fields;
pspec->value_type = SFI_TYPE_REC;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_rec_generic (const gchar *name,
const gchar *nick,
@@ -674,7 +593,6 @@ sfi_pspec_rec_generic (const gchar *name,
static const SfiRecFields empty_fields = { 0, NULL };
return sfi_pspec_rec (name, nick, blurb, empty_fields, hints);
}
-
GParamSpec*
sfi_pspec_proxy (const gchar *name,
const gchar *nick,
@@ -685,10 +603,8 @@ sfi_pspec_proxy (const gchar *name,
GParamSpec *pspec = param_spec_internal (SFI_TYPE_PARAM_PROXY, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
sfi_pspec_set_options (pspec, hints);
pspec->value_type = SFI_TYPE_PROXY;
-
return pspec;
}
-
GParamSpec*
sfi_pspec_note (const gchar *name,
const gchar *nick,
@@ -703,7 +619,6 @@ sfi_pspec_note (const gchar *name,
GParamSpecInt *ispec;
GParamSpec *pspec;
gchar *thints;
-
if (default_value == SFI_NOTE_VOID)
{
g_return_val_if_fail (min_note <= max_note, NULL);
@@ -711,7 +626,6 @@ sfi_pspec_note (const gchar *name,
}
else
g_return_val_if_fail (default_value >= min_note && default_value <= max_note, NULL);
-
pspec = param_spec_internal (SFI_TYPE_PARAM_NOTE, name, NULL_CHECKED (nick), NULL_CHECKED (blurb), GParamFlags (0));
nspec = SFI_PSPEC_NOTE (pspec);
ispec = G_PARAM_SPEC_INT (pspec);
@@ -725,8 +639,6 @@ sfi_pspec_note (const gchar *name,
g_free (thints);
return pspec;
}
-
-
/* --- conversion --- */
enum {
BOXED_RECORD = 1,
@@ -737,7 +649,6 @@ typedef struct {
guint boxed_kind : 8;
GParamSpec *fields[1]; /* variable length array */
} BoxedInfo;
-
void
sfi_boxed_type_set_rec_fields (GType boxed_type,
const SfiRecFields static_const_fields)
@@ -759,7 +670,6 @@ sfi_boxed_type_set_rec_fields (GType boxed_type,
}
g_type_set_qdata (boxed_type, quark_boxed_info, binfo);
}
-
SfiRecFields
sfi_boxed_type_get_rec_fields (GType boxed_type)
{
@@ -773,7 +683,6 @@ sfi_boxed_type_get_rec_fields (GType boxed_type)
}
return rfields;
}
-
void
sfi_boxed_type_set_seq_element (GType boxed_type,
GParamSpec *element)
@@ -799,7 +708,6 @@ sfi_boxed_type_set_seq_element (GType boxed_type,
}
g_type_set_qdata (boxed_type, quark_boxed_info, binfo);
}
-
GParamSpec*
sfi_boxed_type_get_seq_element (GType boxed_type)
{
@@ -810,7 +718,6 @@ sfi_boxed_type_get_seq_element (GType boxed_type)
pspec = binfo->fields[0];
return pspec;
}
-
void
sfi_enum_type_set_choice_value_getter (GType gtype,
SfiChoiceValueGetter cvgetter)
@@ -820,7 +727,6 @@ sfi_enum_type_set_choice_value_getter (GType gtype,
g_warning ("%s: unsetting choice value getter of type `%s' while keeping old choice value references", G_STRFUNC, g_type_name (gtype));
g_type_set_qdata (gtype, quark_enum_choice_value_getter, (void*) cvgetter);
}
-
static SfiSeq*
choice_values_to_seq (const SfiChoiceValues cvalues)
{
@@ -834,7 +740,6 @@ choice_values_to_seq (const SfiChoiceValues cvalues)
}
return seq;
}
-
static SfiSeq*
rec_fields_to_seq (SfiRecFields rfields)
{
@@ -844,18 +749,15 @@ rec_fields_to_seq (SfiRecFields rfields)
sfi_seq_append_pspec (seq, rfields.fields[i]);
return seq;
}
-
typedef struct {
guint ref_count;
SfiRecFields rfields;
} TmpRecordFields;
-
static void
tmp_record_fields_unref (TmpRecordFields *trf)
{
g_return_if_fail (trf != NULL);
g_return_if_fail (trf->ref_count > 0);
-
trf->ref_count--;
if (!trf->ref_count)
{
@@ -867,7 +769,6 @@ tmp_record_fields_unref (TmpRecordFields *trf)
g_free (trf);
}
}
-
static TmpRecordFields*
tmp_record_fields_from_seq (SfiSeq *seq)
{
@@ -900,20 +801,17 @@ tmp_record_fields_from_seq (SfiSeq *seq)
}
return NULL;
}
-
typedef struct {
guint ref_count;
guint free_values : 1;
GEnumClass *eclass; /* !eclass => free (cvalues[*].values.choice_ident) */
SfiChoiceValues cvalues;
} TmpChoiceValues;
-
static void
tmp_choice_values_unref (TmpChoiceValues *tcv)
{
g_return_if_fail (tcv != NULL);
g_return_if_fail (tcv->ref_count > 0);
-
tcv->ref_count--;
if (!tcv->ref_count)
{
@@ -936,7 +834,6 @@ tmp_choice_values_unref (TmpChoiceValues *tcv)
g_free (tcv);
}
}
-
static TmpChoiceValues*
tmp_choice_values_from_seq (SfiSeq *seq)
{
@@ -969,7 +866,6 @@ tmp_choice_values_from_seq (SfiSeq *seq)
}
return NULL;
}
-
static TmpChoiceValues*
tmp_choice_values_from_enum (GEnumClass *eclass)
{
@@ -1006,7 +902,6 @@ tmp_choice_values_from_enum (GEnumClass *eclass)
tcv->ref_count++;
return tcv;
}
-
GParamSpec*
sfi_pspec_choice_from_enum (GParamSpec *enum_pspec)
{
@@ -1014,9 +909,7 @@ sfi_pspec_choice_from_enum (GParamSpec *enum_pspec)
GParamSpecEnum *espec;
TmpChoiceValues *tcv;
GEnumValue *default_evalue;
-
g_return_val_if_fail (G_IS_PARAM_SPEC_ENUM (enum_pspec), NULL);
-
espec = G_PARAM_SPEC_ENUM (enum_pspec);
tcv = tmp_choice_values_from_enum (espec->enum_class);
default_evalue = g_enum_get_value (espec->enum_class, espec->default_value);
@@ -1029,14 +922,11 @@ sfi_pspec_choice_from_enum (GParamSpec *enum_pspec)
sfi_pspec_copy_commons (enum_pspec, pspec);
return pspec;
}
-
GParamSpec*
sfi_pspec_proxy_from_object (GParamSpec *object_pspec)
{
GParamSpec *pspec;
-
g_return_val_if_fail (G_IS_PARAM_SPEC_OBJECT (object_pspec), NULL);
-
pspec = sfi_pspec_proxy (object_pspec->name,
object_pspec->_nick,
object_pspec->_blurb,
@@ -1044,14 +934,11 @@ sfi_pspec_proxy_from_object (GParamSpec *object_pspec)
sfi_pspec_copy_commons (object_pspec, pspec);
return pspec;
}
-
GParamSpec*
sfi_pspec_to_serializable (GParamSpec *xpspec)
{
GParamSpec *pspec = NULL;
-
g_return_val_if_fail (G_IS_PARAM_SPEC (xpspec), NULL);
-
if (sfi_categorize_pspec (xpspec))
pspec = g_param_spec_ref (xpspec);
else if (G_IS_PARAM_SPEC_BOXED (xpspec))
@@ -1073,48 +960,38 @@ sfi_pspec_to_serializable (GParamSpec *xpspec)
pspec = sfi_pspec_choice_from_enum (xpspec);
else if (G_IS_PARAM_SPEC_OBJECT (xpspec))
pspec = sfi_pspec_proxy_from_object (xpspec);
-
if (!pspec)
g_warning ("%s: unable to convert non serializable pspec \"%s\" of type `%s'",
G_STRLOC, xpspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (xpspec)));
-
return pspec;
}
-
-
/* --- pspec accessors --- */
GParamSpec *
sfi_pspec_set_group (GParamSpec *pspec,
const gchar *group)
{
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), pspec);
-
g_param_spec_set_qdata_full (pspec, quark_param_group, g_strdup (group), group ? g_free : NULL);
return pspec;
}
-
const gchar*
sfi_pspec_get_group (GParamSpec *pspec)
{
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
return (const char*) g_param_spec_get_qdata (pspec, quark_param_group);
}
-
void
sfi_pspec_set_owner (GParamSpec *pspec,
const gchar *owner)
{
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_return_if_fail (owner != NULL);
-
g_param_spec_set_qdata_full (pspec, quark_param_owner, g_strdup (owner), g_free);
}
-
const gchar*
sfi_pspec_get_owner (GParamSpec *pspec)
{
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
-
const char *owner = (char*) g_param_spec_get_qdata (pspec, quark_param_owner);
if (!owner && pspec->owner_type)
{
@@ -1123,51 +1000,40 @@ sfi_pspec_get_owner (GParamSpec *pspec)
}
return owner;
}
-
#if 0
static void
sfi_pspec_set_void_note (GParamSpec *pspec,
gboolean allow_void)
{
SfiParamSpecNote *nspec;
-
g_return_if_fail (SFI_IS_PSPEC_NOTE (pspec));
-
nspec = SFI_PSPEC_NOTE (pspec);
nspec->allow_void = allow_void != FALSE;
}
#endif
-
gboolean
sfi_pspec_allows_void_note (GParamSpec *pspec)
{
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
-
return SFI_IS_PSPEC_NOTE (pspec) && SFI_PSPEC_NOTE (pspec)->allow_void;
}
-
typedef struct {
SfiReal center;
SfiReal base;
SfiReal n_steps;
} LogScale;
-
SfiBool
sfi_pspec_get_bool_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_BOOL (pspec), FALSE);
-
return SFI_PSPEC_BOOL (pspec)->default_value;
}
-
SfiInt
sfi_pspec_get_int_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_INT (pspec), 0);
-
return SFI_PSPEC_INT (pspec)->default_value;
}
-
void
sfi_pspec_get_int_range (GParamSpec *pspec,
SfiInt *minimum_value,
@@ -1175,9 +1041,7 @@ sfi_pspec_get_int_range (GParamSpec *pspec,
SfiInt *stepping)
{
SfiParamSpecInt *ispec;
-
g_return_if_fail (SFI_IS_PSPEC_INT (pspec));
-
ispec = SFI_PSPEC_INT (pspec);
if (minimum_value)
*minimum_value = ispec->minimum;
@@ -1186,15 +1050,12 @@ sfi_pspec_get_int_range (GParamSpec *pspec,
if (stepping)
*stepping = g_param_spec_get_istepping (pspec);
}
-
SfiNum
sfi_pspec_get_num_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_NUM (pspec), 0);
-
return SFI_PSPEC_NUM (pspec)->default_value;
}
-
void
sfi_pspec_get_num_range (GParamSpec *pspec,
SfiNum *minimum_value,
@@ -1202,9 +1063,7 @@ sfi_pspec_get_num_range (GParamSpec *pspec,
SfiNum *stepping)
{
SfiParamSpecNum *nspec;
-
g_return_if_fail (SFI_IS_PSPEC_NUM (pspec));
-
nspec = SFI_PSPEC_NUM (pspec);
if (minimum_value)
*minimum_value = nspec->minimum;
@@ -1213,15 +1072,12 @@ sfi_pspec_get_num_range (GParamSpec *pspec,
if (stepping)
*stepping = g_param_spec_get_istepping (pspec);
}
-
SfiReal
sfi_pspec_get_real_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_REAL (pspec), 0);
-
return SFI_PSPEC_REAL (pspec)->default_value;
}
-
void
sfi_pspec_get_real_range (GParamSpec *pspec,
SfiReal *minimum_value,
@@ -1229,9 +1085,7 @@ sfi_pspec_get_real_range (GParamSpec *pspec,
SfiReal *stepping)
{
SfiParamSpecReal *nspec;
-
g_return_if_fail (SFI_IS_PSPEC_REAL (pspec));
-
nspec = SFI_PSPEC_REAL (pspec);
if (minimum_value)
*minimum_value = nspec->minimum;
@@ -1240,35 +1094,27 @@ sfi_pspec_get_real_range (GParamSpec *pspec,
if (stepping)
*stepping = g_param_spec_get_fstepping (pspec);
}
-
const gchar*
sfi_pspec_get_string_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_STRING (pspec), NULL);
-
return SFI_PSPEC_STRING (pspec)->default_value;
}
-
const gchar*
sfi_pspec_get_choice_default (GParamSpec *pspec)
{
g_return_val_if_fail (SFI_IS_PSPEC_CHOICE (pspec), NULL);
-
return G_PARAM_SPEC_STRING (pspec)->default_value;
}
-
SfiChoiceValues
sfi_pspec_get_choice_values (GParamSpec *pspec)
{
SfiParamSpecChoice *cspec;
SfiChoiceValues dummy = { 0, };
-
g_return_val_if_fail (SFI_IS_PSPEC_CHOICE (pspec), dummy);
-
cspec = SFI_PSPEC_CHOICE (pspec);
return cspec->cvalues;
}
-
guint64
sfi_pspec_get_choice_hash (GParamSpec *pspec)
{
@@ -1287,47 +1133,36 @@ sfi_pspec_get_choice_hash (GParamSpec *pspec)
hash = (hash << 7) - hash + g_str_hash (cspec->cvalues.values[i].choice_ident);
return hash;
}
-
GParamSpec*
sfi_pspec_get_seq_element (GParamSpec *pspec)
{
SfiParamSpecSeq *sspec;
-
g_return_val_if_fail (SFI_IS_PSPEC_SEQ (pspec), NULL);
-
sspec = SFI_PSPEC_SEQ (pspec);
return sspec->element;
}
-
SfiRecFields
sfi_pspec_get_rec_fields (GParamSpec *pspec)
{
SfiParamSpecRec *rspec;
SfiRecFields dummy = { 0, };
-
g_return_val_if_fail (SFI_IS_PSPEC_REC (pspec), dummy);
-
rspec = SFI_PSPEC_REC (pspec);
return rspec->fields;
}
-
GParamSpec*
sfi_pspec_get_rec_field (GParamSpec *pspec,
const gchar *field)
{
SfiParamSpecRec *rspec;
guint i;
-
g_return_val_if_fail (SFI_IS_PSPEC_REC (pspec), NULL);
-
rspec = SFI_PSPEC_REC (pspec);
for (i = 0; i < rspec->fields.n_fields; i++)
if (strcmp (rspec->fields.fields[i]->name, field) == 0)
return rspec->fields.fields[i];
return NULL;
}
-
-
/* --- pspec categories --- */
GType
sfi_category_type (SfiSCategory cat_type)
@@ -1349,7 +1184,6 @@ sfi_category_type (SfiSCategory cat_type)
default: return 0;
}
}
-
GType
sfi_category_param_type (SfiSCategory cat_type)
{
@@ -1375,7 +1209,6 @@ sfi_category_param_type (SfiSCategory cat_type)
return 0;
}
}
-
SfiSCategory
sfi_categorize_type (GType value_type)
{
@@ -1408,23 +1241,17 @@ sfi_categorize_type (GType value_type)
/* FAILED to determine category */
return SFI_SCAT_INVAL;
}
-
SfiSCategory
sfi_categorize_pspec (GParamSpec *pspec)
{
GType value_type, pspec_type;
SfiSCategory cat;
-
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), SFI_SCAT_INVAL);
-
value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
pspec_type = G_PARAM_SPEC_TYPE (pspec);
-
cat = sfi_categorize_type (value_type);
-
if (!g_type_is_a (pspec_type, sfi_category_param_type (cat)))
return SFI_SCAT_INVAL;
-
switch (cat)
{
case SFI_SCAT_INT:
@@ -1438,11 +1265,8 @@ sfi_categorize_pspec (GParamSpec *pspec)
default:
break;
}
-
return cat;
}
-
-
/* --- convenience aliases --- */
GParamSpec*
sfi_pspec_time (const gchar *name,
@@ -1458,8 +1282,6 @@ sfi_pspec_time (const gchar *name,
g_free (thints);
return pspec;
}
-
-
/* --- Record <=> PSpec transforms --- */
SfiRec*
sfi_pspec_to_rec (GParamSpec *pspec)
@@ -1468,15 +1290,11 @@ sfi_pspec_to_rec (GParamSpec *pspec)
SfiSCategory scat;
SfiRec *prec;
const gchar *string;
-
g_return_val_if_fail (pspec != NULL, NULL);
-
scat = sfi_categorize_pspec (pspec);
if (!scat)
return NULL;
-
prec = sfi_rec_new ();
-
/* commons */
sfi_rec_set_int (prec, "sfi_scategory", scat);
sfi_rec_set_string (prec, "name", pspec->name);
@@ -1493,7 +1311,6 @@ sfi_pspec_to_rec (GParamSpec *pspec)
if (string)
sfi_rec_set_string (prec, "group", string);
sfi_rec_set_string (prec, "options", sfi_pspec_get_options (pspec));
-
/* type specifics */
switch (scat & SFI_SCAT_TYPE_MASK)
{
@@ -1566,7 +1383,6 @@ sfi_pspec_to_rec (GParamSpec *pspec)
default:
break;
}
-
/* log scales */
if (sfi_pspec_get_log_scale (pspec, &log_center, &log_base, &log_n_steps))
{
@@ -1574,10 +1390,8 @@ sfi_pspec_to_rec (GParamSpec *pspec)
sfi_rec_set_real (prec, "log_base", log_base);
sfi_rec_set_real (prec, "log_n_steps", log_n_steps);
}
-
return prec;
}
-
GParamSpec*
sfi_pspec_from_rec (SfiRec *prec)
{
@@ -1585,9 +1399,7 @@ sfi_pspec_from_rec (SfiRec *prec)
GParamSpec *pspec = NULL;
SfiRecFields zero_rfields = { 0, 0, };
GType ptype;
-
g_return_val_if_fail (prec != NULL, NULL);
-
SfiSCategory scat = (SfiSCategory) sfi_rec_get_int (prec, "sfi_scategory");
name = sfi_rec_get_string (prec, "name");
ptype = sfi_category_param_type (scat);
@@ -1596,7 +1408,6 @@ sfi_pspec_from_rec (SfiRec *prec)
nick = sfi_rec_get_string (prec, "nick");
blurb = sfi_rec_get_string (prec, "blurb");
hints = sfi_rec_get_string (prec, "options");
-
reswitch:
switch (scat)
{
@@ -1698,7 +1509,6 @@ sfi_pspec_from_rec (SfiRec *prec)
}
return NULL;
}
-
if (pspec)
{
string = sfi_rec_get_string (prec, "owner");
@@ -1707,10 +1517,8 @@ sfi_pspec_from_rec (SfiRec *prec)
sfi_pspec_set_group (pspec, sfi_rec_get_string (prec, "group"));
sfi_pspec_set_options (pspec, sfi_rec_get_string (prec, "options"));
}
-
return pspec;
}
-
static void
sfi_pspec_copy_commons (GParamSpec *src_pspec,
GParamSpec *dest_pspec)
diff --git a/sfi/sfiparams.hh b/sfi/sfiparams.hh
index d7cef76..be59f08 100644
--- a/sfi/sfiparams.hh
+++ b/sfi/sfiparams.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_PARAMS_H__
#define __SFI_PARAMS_H__
-
#include <sfi/sfivalues.hh>
#include <sfi/sfiprimitives.hh>
-
G_BEGIN_DECLS
-
-
/* --- Sfi param spec macros --- */
#define SFI_TYPE_PARAM_BOOL (G_TYPE_PARAM_BOOLEAN)
#define SFI_IS_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BOOL))
@@ -48,8 +44,6 @@ G_BEGIN_DECLS
#define SFI_TYPE_PARAM_NOTE (sfi__param_spec_types[6])
#define SFI_IS_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NOTE))
#define SFI_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NOTE, SfiParamSpecNote))
-
-
/* --- Sfi param spec aliases --- */
typedef GParamSpecBoolean SfiParamSpecBool;
typedef GParamSpecInt SfiParamSpecInt;
@@ -57,8 +51,6 @@ typedef GParamSpecInt64 SfiParamSpecNum;
typedef GParamSpecDouble SfiParamSpecReal;
typedef GParamSpecString SfiParamSpecString;
typedef GParamSpecParam SfiParamSpecPSpec;
-
-
/* --- Sfi param specs --- */
typedef struct {
const gchar *choice_ident;
@@ -94,8 +86,6 @@ typedef struct {
GParamSpecInt pspec;
gboolean allow_void;
} SfiParamSpecNote;
-
-
/* --- Sfi GParamSpec constructors --- */
GParamSpec* sfi_pspec_bool (const gchar *name,
const gchar *nick,
@@ -178,8 +168,6 @@ GParamSpec* sfi_pspec_proxy (const gchar *name,
const gchar *nick,
const gchar *blurb,
const gchar *hints);
-
-
/* --- pspec wrappers --- */
#define sfi_pspec_ref g_param_spec_ref
#define sfi_pspec_unref g_param_spec_unref
@@ -191,8 +179,6 @@ GParamSpec* sfi_pspec_proxy (const gchar *name,
#define sfi_pspec_get_name g_param_spec_get_name
#define sfi_pspec_get_nick g_param_spec_get_nick
#define sfi_pspec_get_blurb g_param_spec_get_blurb
-
-
/* --- conversion --- */
typedef SfiChoiceValues (*SfiChoiceValueGetter) (GType enum_type);
GParamSpec* sfi_pspec_to_serializable (GParamSpec *pspec);
@@ -206,8 +192,6 @@ SfiRecFields sfi_boxed_type_get_rec_fields (GType boxed
void sfi_boxed_type_set_seq_element (GType boxed_type,
GParamSpec *element);
GParamSpec* sfi_boxed_type_get_seq_element (GType boxed_type);
-
-
/* --- Sfi PSpec Options --- */
/* provide common option combinations: */
#define SFI_PARAM_READWRITE ":r:w:"
@@ -217,8 +201,6 @@ GParamSpec* sfi_boxed_type_get_seq_element (GType boxed
#define SFI_PARAM_GUI ":r:w:G:"
#define SFI_PARAM_GUI_RDONLY ":r:w:G:ro:"
#define SFI_PARAM_GUI_READABLE ":r:G:"
-
-
/* --- serializable categories --- */
typedef enum /*< skip >*/
{
@@ -239,13 +221,10 @@ typedef enum /*< skip >*/
SFI_SCAT_NOTE = 0x0100 | SFI_SCAT_INT,
SFI_SCAT_TIME = 0x0200 | SFI_SCAT_NUM,
} SfiSCategory;
-
SfiSCategory sfi_categorize_type (GType value_type);
SfiSCategory sfi_categorize_pspec (GParamSpec *pspec);
GType sfi_category_type (SfiSCategory pspec_cat);
GType sfi_category_param_type (SfiSCategory pspec_cat);
-
-
/* --- convenience aliases --- */
GParamSpec* sfi_pspec_note (const gchar *name,
const gchar *nick,
@@ -260,8 +239,6 @@ GParamSpec* sfi_pspec_time (const gchar *name,
const gchar *nick,
const gchar *blurb,
const gchar *hints);
-
-
/* --- pspec accessors --- */
GParamSpec* sfi_pspec_set_group (GParamSpec *pspec,
const gchar *group);
@@ -303,17 +280,11 @@ GParamSpec* sfi_pspec_get_seq_element (GParamSpec *pspec);
SfiRecFields sfi_pspec_get_rec_fields (GParamSpec *pspec);
GParamSpec* sfi_pspec_get_rec_field (GParamSpec *pspec,
const gchar *field_name);
-
-
/* --- internal --- */
void _sfi_init_params (void);
extern GType* sfi__param_spec_types;
SfiRec* sfi_pspec_to_rec (GParamSpec *pspec);
GParamSpec* sfi_pspec_from_rec (SfiRec *prec);
-
-
G_END_DECLS
-
#endif /* __SFI_PARAMS_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiprimitives.cc b/sfi/sfiprimitives.cc
index 68389a6..b4f61ca 100644
--- a/sfi/sfiprimitives.cc
+++ b/sfi/sfiprimitives.cc
@@ -4,20 +4,16 @@
#include "sfiprimitives.hh"
#include "sfimemory.hh"
#include "sfiparams.hh"
-
-
/* --- SfiBBlock primitive type --- */
SfiBBlock*
sfi_bblock_new (void)
{
SfiBBlock *bblock = sfi_new_struct (SfiBBlock, 1);
-
bblock->ref_count = 1;
bblock->n_bytes = 0;
bblock->bytes = NULL;
return bblock;
}
-
SfiBBlock*
sfi_bblock_new_sized (guint size)
{
@@ -25,23 +21,19 @@ sfi_bblock_new_sized (guint size)
sfi_bblock_resize (bblock, size);
return bblock;
}
-
SfiBBlock*
sfi_bblock_ref (SfiBBlock *bblock)
{
g_return_val_if_fail (bblock != NULL, NULL);
g_return_val_if_fail (bblock->ref_count > 0, NULL);
-
bblock->ref_count++;
return bblock;
}
-
void
sfi_bblock_unref (SfiBBlock *bblock)
{
g_return_if_fail (bblock != NULL);
g_return_if_fail (bblock->ref_count > 0);
-
bblock->ref_count--;
if (bblock->ref_count == 0)
{
@@ -49,84 +41,67 @@ sfi_bblock_unref (SfiBBlock *bblock)
sfi_delete_struct (SfiBBlock, bblock);
}
}
-
void
sfi_bblock_resize (SfiBBlock *bblock,
guint size)
{
guint i;
-
g_return_if_fail (bblock != NULL);
-
i = bblock->n_bytes;
bblock->n_bytes = size;
bblock->bytes = g_renew (guint8, bblock->bytes, bblock->n_bytes);
if (size > i)
memset (bblock->bytes + i, 0, sizeof (bblock->bytes[0]) * (size - i));
}
-
SfiBBlock*
sfi_bblock_copy_deep (const SfiBBlock *bblock)
{
SfiBBlock *fb;
-
g_return_val_if_fail (bblock != NULL, NULL);
g_return_val_if_fail (bblock->ref_count > 0, NULL);
-
fb = sfi_bblock_new ();
fb->n_bytes = bblock->n_bytes;
fb->bytes = (uint8*) g_memdup (bblock->bytes, bblock->n_bytes * sizeof (bblock->bytes[0]));
return fb;
}
-
void
sfi_bblock_append (SfiBBlock *bblock,
guint n_bytes,
const guint8 *bytes)
{
g_return_if_fail (bblock != NULL);
-
if (n_bytes)
{
guint i;
-
g_return_if_fail (bytes != NULL);
-
i = bblock->n_bytes;
bblock->n_bytes += n_bytes;
bblock->bytes = g_renew (guint8, bblock->bytes, bblock->n_bytes);
memcpy (bblock->bytes + i, bytes, n_bytes * sizeof (bblock->bytes[0]));
}
}
-
void
sfi_bblock_append1 (SfiBBlock *bblock,
guint8 byte0)
{
guint i;
-
g_return_if_fail (bblock != NULL);
-
i = bblock->n_bytes++;
bblock->bytes = g_renew (guint8, bblock->bytes, bblock->n_bytes);
bblock->bytes[i] = byte0;
}
-
guint
sfi_bblock_length (const SfiBBlock *bblock)
{
g_return_val_if_fail (bblock != NULL, 0);
return bblock->n_bytes;
}
-
guint8*
sfi_bblock_get (const SfiBBlock *bblock)
{
g_return_val_if_fail (bblock != NULL, NULL);
return bblock->bytes;
}
-
-
/* --- SfiFBlock primitive type --- */
SfiFBlock*
sfi_fblock_new (void)
@@ -138,7 +113,6 @@ sfi_fblock_new (void)
fblock->freefunc = g_free;
return fblock;
}
-
SfiFBlock*
sfi_fblock_new_sized (guint size)
{
@@ -146,7 +120,6 @@ sfi_fblock_new_sized (guint size)
sfi_fblock_resize (fblock, size);
return fblock;
}
-
SfiFBlock*
sfi_fblock_new_foreign (guint n_values,
gfloat *values,
@@ -159,23 +132,19 @@ sfi_fblock_new_foreign (guint n_values,
fblock->freefunc = freefunc;
return fblock;
}
-
SfiFBlock*
sfi_fblock_ref (SfiFBlock *fblock)
{
g_return_val_if_fail (fblock != NULL, NULL);
g_return_val_if_fail (fblock->ref_count > 0, NULL);
-
fblock->ref_count++;
return fblock;
}
-
void
sfi_fblock_unref (SfiFBlock *fblock)
{
g_return_if_fail (fblock != NULL);
g_return_if_fail (fblock->ref_count > 0);
-
fblock->ref_count--;
if (fblock->ref_count == 0)
{
@@ -183,7 +152,6 @@ sfi_fblock_unref (SfiFBlock *fblock)
sfi_delete_struct (SfiFBlock, fblock);
}
}
-
static void
fblock_resize (SfiFBlock *fblock,
guint size)
@@ -201,40 +169,33 @@ fblock_resize (SfiFBlock *fblock,
fblock->freefunc = g_free;
}
}
-
void
sfi_fblock_resize (SfiFBlock *fblock,
guint size)
{
g_return_if_fail (fblock != NULL);
-
guint osize = fblock->n_values;
fblock_resize (fblock, size);
if (size > osize)
memset (fblock->values + osize, 0, sizeof (fblock->values[0]) * (size - osize));
}
-
SfiFBlock*
sfi_fblock_copy_deep (const SfiFBlock *fblock)
{
SfiFBlock *fb;
-
g_return_val_if_fail (fblock != NULL, NULL);
g_return_val_if_fail (fblock->ref_count > 0, NULL);
-
fb = sfi_fblock_new ();
fb->n_values = fblock->n_values;
fb->values = (float*) g_memdup (fblock->values, fblock->n_values * sizeof (fblock->values[0]));
return fb;
}
-
void
sfi_fblock_append (SfiFBlock *fblock,
guint n_values,
const gfloat *values)
{
g_return_if_fail (fblock != NULL);
-
if (n_values)
{
g_return_if_fail (values != NULL);
@@ -243,7 +204,6 @@ sfi_fblock_append (SfiFBlock *fblock,
memcpy (fblock->values + oldsize, values, n_values * sizeof (fblock->values[0]));
}
}
-
void
sfi_fblock_append1 (SfiFBlock *fblock,
gfloat float0)
@@ -252,63 +212,52 @@ sfi_fblock_append1 (SfiFBlock *fblock,
fblock_resize (fblock, fblock->n_values + 1);
fblock->values[fblock->n_values - 1] = float0;
}
-
guint
sfi_fblock_length (const SfiFBlock *fblock)
{
g_return_val_if_fail (fblock != NULL, 0);
return fblock->n_values;
}
-
gfloat*
sfi_fblock_get (const SfiFBlock *fblock)
{
g_return_val_if_fail (fblock != NULL, NULL);
return fblock->values;
}
-
-
/* --- SfiSeq primitive type --- */
SfiSeq*
sfi_seq_new (void)
{
SfiSeq *s;
-
s = sfi_new_struct (SfiSeq, 1);
s->ref_count = 1;
s->n_elements = 0;
s->elements = NULL;
return s;
}
-
SfiSeq*
sfi_seq_ref (SfiSeq *seq)
{
g_return_val_if_fail (seq != NULL, NULL);
g_return_val_if_fail (seq->ref_count > 0, NULL);
-
seq->ref_count++;
return seq;
}
-
void
sfi_seq_clear (SfiSeq *seq)
{
g_return_if_fail (seq != NULL);
g_return_if_fail (seq->ref_count > 0);
-
while (seq->n_elements)
g_value_unset (seq->elements + --seq->n_elements);
g_free (seq->elements);
seq->elements = NULL;
}
-
void
sfi_seq_unref (SfiSeq *seq)
{
g_return_if_fail (seq != NULL);
g_return_if_fail (seq->ref_count > 0);
-
seq->ref_count--;
if (seq->ref_count == 0)
{
@@ -318,13 +267,11 @@ sfi_seq_unref (SfiSeq *seq)
sfi_delete_struct (SfiSeq, seq);
}
}
-
static inline gulong
upper_power2 (gulong number)
{
return number ? 1 << g_bit_storage (number - 1) : 0;
}
-
static void
sfi_seq_append_copy (SfiSeq *seq,
GType value_type,
@@ -332,9 +279,7 @@ sfi_seq_append_copy (SfiSeq *seq,
const GValue *value)
{
guint i, l, n;
-
g_return_if_fail (seq != NULL);
-
l = upper_power2 (seq->n_elements);
i = seq->n_elements++;
n = upper_power2 (seq->n_elements);
@@ -349,86 +294,70 @@ sfi_seq_append_copy (SfiSeq *seq,
else if (value)
g_value_copy (value, seq->elements + i);
}
-
SfiSeq*
sfi_seq_copy_deep (const SfiSeq *seq)
{
SfiSeq *s;
guint i;
-
g_return_val_if_fail (seq != NULL, NULL);
g_return_val_if_fail (seq->ref_count > 0, NULL);
-
s = sfi_seq_new ();
for (i = 0; i < seq->n_elements; i++)
sfi_seq_append_copy (s, G_VALUE_TYPE (seq->elements + i), TRUE, seq->elements + i);
return s;
}
-
void
sfi_seq_append (SfiSeq *seq,
const GValue *value)
{
g_return_if_fail (seq != NULL);
g_return_if_fail (G_IS_VALUE (value));
-
sfi_seq_append_copy (seq, G_VALUE_TYPE (value), FALSE, value);
}
-
GValue*
sfi_seq_append_empty (SfiSeq *seq,
GType value_type)
{
g_return_val_if_fail (seq != NULL, NULL);
g_return_val_if_fail (G_TYPE_IS_VALUE (value_type), NULL);
-
sfi_seq_append_copy (seq, value_type, FALSE, NULL);
return seq->elements + seq->n_elements - 1;
}
-
guint
sfi_seq_length (const SfiSeq *seq)
{
return seq ? seq->n_elements : 0;
}
-
GValue*
sfi_seq_get (const SfiSeq *seq,
guint index)
{
g_return_val_if_fail (seq != NULL, NULL);
g_return_val_if_fail (index < seq->n_elements, NULL);
-
return seq->elements + index;
}
-
gboolean
sfi_seq_check (SfiSeq *seq,
GType element_type)
{
guint i;
-
g_return_val_if_fail (seq != NULL, FALSE);
-
for (i = 0; i < seq->n_elements; i++)
if (!G_VALUE_HOLDS (seq->elements + i, element_type))
return FALSE;
return TRUE;
}
-
gboolean
sfi_seq_validate (SfiSeq *seq,
GParamSpec *pspec)
{
g_return_val_if_fail (seq != NULL, FALSE);
g_return_val_if_fail (pspec != NULL, FALSE);
-
GValue *v = sfi_value_seq (seq);
gboolean changed = g_param_value_validate (pspec, v);
sfi_value_free (v);
return changed;
}
-
void
sfi_seq_append_bool (SfiSeq *seq,
SfiBool v_bool)
@@ -436,7 +365,6 @@ sfi_seq_append_bool (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_BOOL);
sfi_value_set_bool (value, v_bool);
}
-
void
sfi_seq_append_int (SfiSeq *seq,
SfiInt v_int)
@@ -444,7 +372,6 @@ sfi_seq_append_int (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_INT);
sfi_value_set_int (value, v_int);
}
-
void
sfi_seq_append_num (SfiSeq *seq,
SfiNum v_num)
@@ -452,7 +379,6 @@ sfi_seq_append_num (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_NUM);
sfi_value_set_num (value, v_num);
}
-
void
sfi_seq_append_real (SfiSeq *seq,
SfiReal v_real)
@@ -460,7 +386,6 @@ sfi_seq_append_real (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_REAL);
sfi_value_set_real (value, v_real);
}
-
void
sfi_seq_append_string (SfiSeq *seq,
const gchar *string)
@@ -468,7 +393,6 @@ sfi_seq_append_string (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_STRING);
sfi_value_set_string (value, string);
}
-
void
sfi_seq_append_choice (SfiSeq *seq,
const gchar *choice)
@@ -476,7 +400,6 @@ sfi_seq_append_choice (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_CHOICE);
sfi_value_set_choice (value, choice);
}
-
void
sfi_seq_append_bblock (SfiSeq *seq,
SfiBBlock *bblock)
@@ -484,7 +407,6 @@ sfi_seq_append_bblock (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_BBLOCK);
sfi_value_set_bblock (value, bblock);
}
-
void
sfi_seq_append_fblock (SfiSeq *seq,
SfiFBlock *fblock)
@@ -492,7 +414,6 @@ sfi_seq_append_fblock (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_FBLOCK);
sfi_value_set_fblock (value, fblock);
}
-
void
sfi_seq_append_pspec (SfiSeq *seq,
GParamSpec *pspec)
@@ -500,7 +421,6 @@ sfi_seq_append_pspec (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_PSPEC);
sfi_value_set_pspec (value, pspec);
}
-
void
sfi_seq_append_seq (SfiSeq *seq,
SfiSeq *v_seq)
@@ -508,7 +428,6 @@ sfi_seq_append_seq (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_SEQ);
sfi_value_set_seq (value, v_seq);
}
-
void
sfi_seq_append_rec (SfiSeq *seq,
SfiRec *rec)
@@ -516,7 +435,6 @@ sfi_seq_append_rec (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_REC);
sfi_value_set_rec (value, rec);
}
-
void
sfi_seq_append_proxy (SfiSeq *seq,
SfiProxy proxy)
@@ -524,7 +442,6 @@ sfi_seq_append_proxy (SfiSeq *seq,
GValue *value = sfi_seq_append_empty (seq, SFI_TYPE_PROXY);
sfi_value_set_proxy (value, proxy);
}
-
static inline SfiNum
value_as_num (GValue *v)
{
@@ -541,7 +458,6 @@ value_as_num (GValue *v)
}
return 0;
}
-
static inline SfiReal
value_as_real (GValue *v)
{
@@ -558,7 +474,6 @@ value_as_real (GValue *v)
}
return 0;
}
-
static inline const gchar*
value_as_string (GValue *v)
{
@@ -571,49 +486,42 @@ value_as_string (GValue *v)
}
return NULL;
}
-
SfiBool
sfi_seq_get_bool (SfiSeq *seq,
guint index)
{
return value_as_num (sfi_seq_get (seq, index)) != 0;
}
-
SfiInt
sfi_seq_get_int (SfiSeq *seq,
guint index)
{
return value_as_num (sfi_seq_get (seq, index));
}
-
SfiNum
sfi_seq_get_num (SfiSeq *seq,
guint index)
{
return value_as_num (sfi_seq_get (seq, index));
}
-
SfiReal
sfi_seq_get_real (SfiSeq *seq,
guint index)
{
return value_as_real (sfi_seq_get (seq, index));
}
-
const gchar*
sfi_seq_get_string (SfiSeq *seq,
guint index)
{
return value_as_string (sfi_seq_get (seq, index));
}
-
const gchar*
sfi_seq_get_choice (SfiSeq *seq,
guint index)
{
return value_as_string (sfi_seq_get (seq, index));
}
-
SfiBBlock*
sfi_seq_get_bblock (SfiSeq *seq,
guint index)
@@ -623,7 +531,6 @@ sfi_seq_get_bblock (SfiSeq *seq,
return sfi_value_get_bblock (v);
return NULL;
}
-
SfiFBlock*
sfi_seq_get_fblock (SfiSeq *seq,
guint index)
@@ -633,7 +540,6 @@ sfi_seq_get_fblock (SfiSeq *seq,
return sfi_value_get_fblock (v);
return NULL;
}
-
GParamSpec*
sfi_seq_get_pspec (SfiSeq *seq,
guint index)
@@ -643,7 +549,6 @@ sfi_seq_get_pspec (SfiSeq *seq,
return sfi_value_get_pspec (v);
return NULL;
}
-
SfiSeq*
sfi_seq_get_seq (SfiSeq *seq,
guint index)
@@ -653,7 +558,6 @@ sfi_seq_get_seq (SfiSeq *seq,
return sfi_value_get_seq (v);
return NULL;
}
-
SfiRec*
sfi_seq_get_rec (SfiSeq *seq,
guint index)
@@ -663,7 +567,6 @@ sfi_seq_get_rec (SfiSeq *seq,
return sfi_value_get_rec (v);
return NULL;
}
-
SfiProxy
sfi_seq_get_proxy (SfiSeq *seq,
guint index)
@@ -673,16 +576,13 @@ sfi_seq_get_proxy (SfiSeq *seq,
return sfi_value_get_proxy (v);
return 0;
}
-
gchar**
sfi_seq_to_strv (SfiSeq *seq)
{
GSList *slist = NULL;
gchar **strv;
guint i;
-
g_return_val_if_fail (seq != NULL, NULL);
-
for (i = 0; i < seq->n_elements; i++)
if (G_VALUE_HOLDS_STRING (seq->elements + i))
slist = g_slist_prepend (slist, const_cast<char*> (sfi_value_get_string (seq->elements + i)));
@@ -691,7 +591,6 @@ sfi_seq_to_strv (SfiSeq *seq)
g_slist_free (slist);
return strv;
}
-
SfiSeq*
sfi_seq_from_strv (gchar **strv)
{
@@ -699,13 +598,11 @@ sfi_seq_from_strv (gchar **strv)
guint i;
if (!strv)
return NULL;
-
seq = sfi_seq_new ();
for (i = 0; strv[i]; i++)
sfi_seq_append_string (seq, strv[i]);
return seq;
}
-
SfiSeq*
sfi_seq_from_cstrv (const gchar **strv)
{
@@ -713,14 +610,11 @@ sfi_seq_from_cstrv (const gchar **strv)
guint i;
if (!strv)
return NULL;
-
seq = sfi_seq_new ();
for (i = 0; strv[i]; i++)
sfi_seq_append_string (seq, strv[i]);
return seq;
}
-
-
/* --- SfiRec primitive type --- */
SfiRec*
sfi_rec_new (void)
@@ -733,23 +627,18 @@ sfi_rec_new (void)
rec->field_names = NULL;
return rec;
}
-
SfiRec*
sfi_rec_ref (SfiRec *rec)
{
g_return_val_if_fail (rec != NULL, NULL);
g_return_val_if_fail (rec->ref_count > 0, NULL);
-
rec->ref_count++;
-
return rec;
}
-
static void
sfi_rec_empty (SfiRec *rec)
{
guint i;
-
for (i = 0; i < rec->n_fields; i++)
{
g_value_unset (rec->fields + i);
@@ -762,13 +651,11 @@ sfi_rec_empty (SfiRec *rec)
rec->fields = NULL;
rec->field_names = NULL;
}
-
void
sfi_rec_unref (SfiRec *rec)
{
g_return_if_fail (rec != NULL);
g_return_if_fail (rec->ref_count > 0);
-
rec->ref_count--;
if (rec->ref_count == 0)
{
@@ -776,33 +663,27 @@ sfi_rec_unref (SfiRec *rec)
sfi_delete_struct (SfiRec, rec);
}
}
-
void
sfi_rec_clear (SfiRec *rec)
{
g_return_if_fail (rec != NULL);
g_return_if_fail (rec->ref_count > 0);
-
sfi_rec_empty (rec);
}
-
guint
sfi_rec_n_fields (const SfiRec *rec)
{
g_return_val_if_fail (rec != NULL, 0);
return rec ? rec->n_fields : 0;
}
-
GValue*
sfi_rec_field (const SfiRec *rec,
guint index)
{
g_return_val_if_fail (rec != NULL, NULL);
g_return_val_if_fail (index < rec->n_fields, NULL);
-
return rec->fields + index;
}
-
/* valid chars for dupcanon */
static inline int
valid (char c)
@@ -811,19 +692,15 @@ valid (char c)
(c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z'));
}
-
/* returns dup'd canonified version of the string, or NULL if input was already canonified */
static inline gchar*
may_dupcanon (const gchar *field_name)
{
size_t i = 0;
-
while (valid (field_name[i]))
i++;
-
if (field_name[i] == 0) // no need for canonification, all chars valid
return NULL;
-
gchar *canon_field_name = g_strdup (field_name);
while (canon_field_name[i])
{
@@ -833,7 +710,6 @@ may_dupcanon (const gchar *field_name)
}
return canon_field_name;
}
-
static inline guint
sfi_rec_lookup (SfiRec *rec,
const gchar *field_name)
@@ -864,7 +740,6 @@ sfi_rec_lookup (SfiRec *rec,
}
return rec->n_fields; /* no match */
}
-
static void
sfi_rec_set_copy (SfiRec *rec,
const gchar *field_name,
@@ -875,7 +750,6 @@ sfi_rec_set_copy (SfiRec *rec,
const char *name;
char *dupcanon_name;
uint i;
-
dupcanon_name = may_dupcanon (field_name);
name = dupcanon_name ? dupcanon_name : field_name;
i = sfi_rec_lookup (rec, name);
@@ -900,7 +774,6 @@ sfi_rec_set_copy (SfiRec *rec,
else if (value)
g_value_copy (value, rec->fields + i);
}
-
void
sfi_rec_set (SfiRec *rec,
const gchar *field_name,
@@ -909,10 +782,8 @@ sfi_rec_set (SfiRec *rec,
g_return_if_fail (rec != NULL);
g_return_if_fail (field_name != NULL);
g_return_if_fail (SFI_IS_VALUE (value));
-
sfi_rec_set_copy (rec, field_name, G_VALUE_TYPE (value), FALSE, value);
}
-
GValue*
sfi_rec_get (SfiRec *rec,
const gchar *field_name)
@@ -920,10 +791,8 @@ sfi_rec_get (SfiRec *rec,
const gchar *name;
gchar *dupcanon_name;
guint i;
-
g_return_val_if_fail (rec != NULL, NULL);
g_return_val_if_fail (field_name != NULL, NULL);
-
if (!rec->sorted)
sfi_rec_sort (rec);
dupcanon_name = may_dupcanon (field_name);
@@ -934,7 +803,6 @@ sfi_rec_get (SfiRec *rec,
return rec->fields + i;
return NULL;
}
-
GValue*
sfi_rec_forced_get (SfiRec *rec,
const gchar *field_name,
@@ -968,16 +836,13 @@ sfi_rec_forced_get (SfiRec *rec,
g_free (dupcanon_name);
return rec->fields + i;
}
-
SfiRec*
sfi_rec_copy_deep (SfiRec *rec)
{
SfiRec *r;
guint i;
-
g_return_val_if_fail (rec != NULL, NULL);
g_return_val_if_fail (rec->ref_count > 0, NULL);
-
sfi_rec_sort (rec);
r = sfi_rec_new ();
for (i = 0; i < rec->n_fields; i++)
@@ -985,16 +850,13 @@ sfi_rec_copy_deep (SfiRec *rec)
r->sorted = TRUE;
return r;
}
-
gboolean
sfi_rec_check (SfiRec *rec,
SfiRecFields rfields)
{
guint i;
-
g_return_val_if_fail (rec != NULL, FALSE);
g_return_val_if_fail (rfields.n_fields > 0, FALSE);
-
if (!rec->sorted)
sfi_rec_sort (rec);
for (i = 0; i < rfields.n_fields; i++)
@@ -1006,7 +868,6 @@ sfi_rec_check (SfiRec *rec,
}
return TRUE;
}
-
static int
strpointercmp (const void *p1,
const void *p2)
@@ -1015,12 +876,10 @@ strpointercmp (const void *p1,
char *const *s2 = (char**) p2;
return strcmp (*s1, *s2);
}
-
void
sfi_rec_sort (SfiRec *rec)
{
g_return_if_fail (rec != NULL);
-
if (!rec->sorted && rec->n_fields > 1)
{
char **fnames = (char**) g_memdup (rec->field_names, rec->n_fields * sizeof (rec->field_names[0]));
@@ -1045,7 +904,6 @@ sfi_rec_sort (SfiRec *rec)
}
rec->sorted = TRUE;
}
-
void
sfi_rec_swap_fields (SfiRec *rec,
SfiRec *swapper)
@@ -1053,10 +911,8 @@ sfi_rec_swap_fields (SfiRec *rec,
guint n;
GValue *fields;
gchar **names;
-
g_return_if_fail (rec != NULL);
g_return_if_fail (swapper != NULL);
-
sfi_rec_sort (rec);
sfi_rec_sort (swapper);
n = rec->n_fields;
@@ -1069,7 +925,6 @@ sfi_rec_swap_fields (SfiRec *rec,
swapper->fields = fields;
swapper->field_names = names;
}
-
gboolean
sfi_rec_validate (SfiRec *rec,
SfiRecFields fields)
@@ -1077,9 +932,7 @@ sfi_rec_validate (SfiRec *rec,
GParamSpec *pspec;
GValue *v;
gboolean changed;
-
g_return_val_if_fail (rec != NULL, FALSE);
-
pspec = sfi_pspec_rec ("auto", NULL, NULL, fields, ":readwrite");
v = sfi_value_rec (rec);
changed = g_param_value_validate (pspec, v);
@@ -1087,7 +940,6 @@ sfi_rec_validate (SfiRec *rec,
g_param_spec_sink (pspec);
return changed;
}
-
void
sfi_rec_set_bool (SfiRec *rec,
const gchar *field_name,
@@ -1097,7 +949,6 @@ sfi_rec_set_bool (SfiRec *rec,
sfi_rec_set (rec, field_name, value);
sfi_value_free (value);
}
-
void
sfi_rec_set_int (SfiRec *rec,
const gchar *field_name,
@@ -1107,7 +958,6 @@ sfi_rec_set_int (SfiRec *rec,
sfi_rec_set (rec, field_name, value);
sfi_value_free (value);
}
-
void
sfi_rec_set_num (SfiRec *rec,
const gchar *field_name,
@@ -1117,7 +967,6 @@ sfi_rec_set_num (SfiRec *rec,
sfi_rec_set (rec, field_name, value);
sfi_value_free (value);
}
-
void
sfi_rec_set_real (SfiRec *rec,
const gchar *field_name,
@@ -1127,7 +976,6 @@ sfi_rec_set_real (SfiRec *rec,
sfi_rec_set (rec, field_name, value);
sfi_value_free (value);
}
-
void
sfi_rec_set_string (SfiRec *rec,
const gchar *field_name,
@@ -1139,7 +987,6 @@ sfi_rec_set_string (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_choice (SfiRec *rec,
const gchar *field_name,
@@ -1151,7 +998,6 @@ sfi_rec_set_choice (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_bblock (SfiRec *rec,
const gchar *field_name,
@@ -1163,7 +1009,6 @@ sfi_rec_set_bblock (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_fblock (SfiRec *rec,
const gchar *field_name,
@@ -1175,7 +1020,6 @@ sfi_rec_set_fblock (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_pspec (SfiRec *rec,
const gchar *field_name,
@@ -1185,7 +1029,6 @@ sfi_rec_set_pspec (SfiRec *rec,
sfi_rec_set (rec, field_name, value);
sfi_value_free (value);
}
-
void
sfi_rec_set_seq (SfiRec *rec,
const gchar *field_name,
@@ -1197,7 +1040,6 @@ sfi_rec_set_seq (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_rec (SfiRec *rec,
const gchar *field_name,
@@ -1209,7 +1051,6 @@ sfi_rec_set_rec (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
void
sfi_rec_set_proxy (SfiRec *rec,
const gchar *field_name,
@@ -1221,49 +1062,42 @@ sfi_rec_set_proxy (SfiRec *rec,
sfi_rec_set (rec, field_name, &value);
g_value_unset (&value);
}
-
SfiBool
sfi_rec_get_bool (SfiRec *rec,
const gchar *field_name)
{
return value_as_num (sfi_rec_get (rec, field_name)) != 0;
}
-
SfiInt
sfi_rec_get_int (SfiRec *rec,
const gchar *field_name)
{
return value_as_num (sfi_rec_get (rec, field_name));
}
-
SfiNum
sfi_rec_get_num (SfiRec *rec,
const gchar *field_name)
{
return value_as_num (sfi_rec_get (rec, field_name));
}
-
SfiReal
sfi_rec_get_real (SfiRec *rec,
const gchar *field_name)
{
return value_as_real (sfi_rec_get (rec, field_name));
}
-
const gchar*
sfi_rec_get_string (SfiRec *rec,
const gchar *field_name)
{
return value_as_string (sfi_rec_get (rec, field_name));
}
-
const gchar*
sfi_rec_get_choice (SfiRec *rec,
const gchar *field_name)
{
return value_as_string (sfi_rec_get (rec, field_name));
}
-
SfiBBlock*
sfi_rec_get_bblock (SfiRec *rec,
const gchar *field_name)
@@ -1273,7 +1107,6 @@ sfi_rec_get_bblock (SfiRec *rec,
return sfi_value_get_bblock (v);
return NULL;
}
-
SfiFBlock*
sfi_rec_get_fblock (SfiRec *rec,
const gchar *field_name)
@@ -1283,7 +1116,6 @@ sfi_rec_get_fblock (SfiRec *rec,
return sfi_value_get_fblock (v);
return NULL;
}
-
GParamSpec*
sfi_rec_get_pspec (SfiRec *rec,
const gchar *field_name)
@@ -1293,7 +1125,6 @@ sfi_rec_get_pspec (SfiRec *rec,
return sfi_value_get_pspec (v);
return NULL;
}
-
SfiSeq*
sfi_rec_get_seq (SfiRec *rec,
const gchar *field_name)
@@ -1303,7 +1134,6 @@ sfi_rec_get_seq (SfiRec *rec,
return sfi_value_get_seq (v);
return NULL;
}
-
SfiRec*
sfi_rec_get_rec (SfiRec *rec,
const gchar *field_name)
@@ -1313,7 +1143,6 @@ sfi_rec_get_rec (SfiRec *rec,
return sfi_value_get_rec (v);
return NULL;
}
-
SfiProxy
sfi_rec_get_proxy (SfiRec *rec,
const gchar *field_name)
diff --git a/sfi/sfiprimitives.hh b/sfi/sfiprimitives.hh
index aca6747..f7c35ea 100644
--- a/sfi/sfiprimitives.hh
+++ b/sfi/sfiprimitives.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_PRIMITIVES_H__
#define __SFI_PRIMITIVES_H__
-
#include <sfi/sfivalues.hh>
-
G_BEGIN_DECLS
-
-
/* --- SfiBBlock primitive type --- */
struct _SfiBBlock {
guint ref_count;
@@ -28,8 +24,6 @@ void sfi_bblock_append1 (SfiBBlock *bblock,
guint8 byte0);
guint sfi_bblock_length (const SfiBBlock *bblock);
guint8* sfi_bblock_get (const SfiBBlock *bblock);
-
-
/* --- SfiFBlock primitive type --- */
struct _SfiFBlock {
guint ref_count;
@@ -55,8 +49,6 @@ void sfi_fblock_append1 (SfiFBlock *fblock,
gfloat float0);
guint sfi_fblock_length (const SfiFBlock *fblock);
gfloat* sfi_fblock_get (const SfiFBlock *fblock);
-
-
/* --- SfiSeq primitive type --- */
struct _SfiSeq {
guint ref_count;
@@ -133,8 +125,6 @@ SfiProxy sfi_seq_get_proxy (SfiSeq *seq,
gchar** sfi_seq_to_strv (SfiSeq *seq);
SfiSeq* sfi_seq_from_strv (gchar **strv);
SfiSeq* sfi_seq_from_cstrv (const gchar **strv);
-
-
/* --- SfiRec primitive type --- */
struct _SfiRec {
guint ref_count;
@@ -228,9 +218,6 @@ SfiRec* sfi_rec_get_rec (SfiRec *rec,
const gchar *field_name);
SfiProxy sfi_rec_get_proxy (SfiRec *rec,
const gchar *field_name);
-
G_END_DECLS
-
#endif /* __SFI_PRIMITIVES_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiring.cc b/sfi/sfiring.cc
index f7b2d31..51ffb50 100644
--- a/sfi/sfiring.cc
+++ b/sfi/sfiring.cc
@@ -3,9 +3,7 @@
#include "sfimemory.hh"
#include <stdlib.h>
#include <string.h>
-
#define HAVE_GSLICE GLIB_CHECK_VERSION (2, 9, 7)
-
/* --- memory handling --- */
static inline SfiRing*
node_alloc (void)
@@ -16,7 +14,6 @@ node_alloc (void)
return (SfiRing*) g_list_alloc();
#endif
}
-
static inline void
node_free (SfiRing *node)
{
@@ -26,7 +23,6 @@ node_free (SfiRing *node)
g_list_free_1 ((GList*) node);
#endif
}
-
static inline void
free_node_list (SfiRing *start)
{
@@ -37,7 +33,6 @@ free_node_list (SfiRing *start)
g_list_free ((GList*) start);
#endif
}
-
/* --- basic comparisons --- */
gint
sfi_pointer_cmp (gconstpointer value1,
@@ -48,8 +43,6 @@ sfi_pointer_cmp (gconstpointer value1,
const char *p2 = (const char*) value2;
return p1 < p2 ? -1 : p1 != p2;
}
-
-
/* --- ring (circular-list) --- */
static inline SfiRing*
sfi_ring_prepend_link_i (SfiRing *head,
@@ -69,17 +62,14 @@ sfi_ring_prepend_link_i (SfiRing *head,
}
return ring;
}
-
static inline SfiRing*
sfi_ring_prepend_i (SfiRing *head,
gpointer data)
{
SfiRing *ring = node_alloc();
-
ring->data = data;
return sfi_ring_prepend_link_i (head, ring);
}
-
static inline SfiRing*
sfi_ring_append_link_i (SfiRing *head,
SfiRing *ring)
@@ -87,14 +77,12 @@ sfi_ring_append_link_i (SfiRing *head,
sfi_ring_prepend_link_i (head, ring);
return head ? head : ring;
}
-
SfiRing*
sfi_ring_prepend (SfiRing *head,
gpointer data)
{
return sfi_ring_prepend_i (head, data);
}
-
SfiRing*
sfi_ring_prepend_uniq (SfiRing *head,
gpointer data)
@@ -105,7 +93,6 @@ sfi_ring_prepend_uniq (SfiRing *head,
return head;
return sfi_ring_prepend_i (head, data);
}
-
SfiRing*
sfi_ring_append (SfiRing *head,
gpointer data)
@@ -113,7 +100,6 @@ sfi_ring_append (SfiRing *head,
SfiRing *ring = sfi_ring_prepend_i (head, data);
return head ? head : ring;
}
-
SfiRing*
sfi_ring_append_uniq (SfiRing *head,
gpointer data)
@@ -125,7 +111,6 @@ sfi_ring_append_uniq (SfiRing *head,
ring = sfi_ring_prepend_i (head, data);
return head ? head : ring;
}
-
SfiRing*
sfi_ring_insert_before (SfiRing *head,
SfiRing *sibling,
@@ -136,7 +121,6 @@ sfi_ring_insert_before (SfiRing *head,
SfiRing *node = sfi_ring_prepend (sibling, data);
return sibling == head ? node : head;
}
-
SfiRing*
sfi_ring_insert (SfiRing *head,
gpointer data,
@@ -152,7 +136,6 @@ sfi_ring_insert (SfiRing *head,
else
return sfi_ring_append (head, data);
}
-
gint
sfi_ring_position (const SfiRing *head,
const SfiRing *node)
@@ -164,7 +147,6 @@ sfi_ring_position (const SfiRing *head,
return i;
return -1;
}
-
gint
sfi_ring_index (const SfiRing *head,
gconstpointer data)
@@ -176,7 +158,6 @@ sfi_ring_index (const SfiRing *head,
return i;
return -1;
}
-
SfiRing*
sfi_ring_copy (const SfiRing *head)
{
@@ -186,7 +167,6 @@ sfi_ring_copy (const SfiRing *head)
dest = sfi_ring_append (dest, walk->data);
return dest;
}
-
SfiRing*
sfi_ring_copy_deep (const SfiRing *head,
SfiRingDataFunc copy,
@@ -198,7 +178,6 @@ sfi_ring_copy_deep (const SfiRing *head,
dest = sfi_ring_append (dest, copy (walk->data, func_data));
return dest;
}
-
SfiRing*
sfi_ring_copy_rest (const SfiRing *ring,
const SfiRing *head)
@@ -209,13 +188,11 @@ sfi_ring_copy_rest (const SfiRing *ring,
dest = sfi_ring_append (dest, walk->data);
return dest;
}
-
SfiRing*
sfi_ring_concat (SfiRing *head1,
SfiRing *head2)
{
SfiRing *tail1, *tail2;
-
if (!head1)
return head2;
if (!head2)
@@ -226,10 +203,8 @@ sfi_ring_concat (SfiRing *head1,
tail2->next = head1;
head2->prev = tail1;
tail1->next = head2;
-
return head1;
}
-
/**
* @param head1 a non-empty ring
* @param head2 a ring node different from @a head1 contained in @a head1
@@ -244,11 +219,9 @@ sfi_ring_split (SfiRing *head1,
SfiRing *head2)
{
SfiRing *tail1, *tail2;
-
g_return_val_if_fail (head1 != NULL, NULL);
g_return_val_if_fail (head2 != NULL, NULL);
g_return_val_if_fail (head1 != head2, NULL);
-
tail1 = head2->prev;
tail2 = head1->prev;
head2->prev = tail2;
@@ -257,7 +230,6 @@ sfi_ring_split (SfiRing *head1,
tail1->next = head1;
return head2;
}
-
static inline SfiRing*
sfi_ring_unlink_node_dangling (SfiRing *head,
SfiRing *node)
@@ -274,7 +246,6 @@ sfi_ring_unlink_node_dangling (SfiRing *head,
/* node->prev and node->next are dangling now */
return head;
}
-
SfiRing*
sfi_ring_remove_node (SfiRing *head,
SfiRing *node)
@@ -283,26 +254,21 @@ sfi_ring_remove_node (SfiRing *head,
g_return_val_if_fail (head == NULL && node == NULL, NULL);
if (!head || !node)
return NULL;
-
/* special case one item ring */
if (head->prev == head)
{
g_return_val_if_fail (node == head, head);
-
node_free (node);
return NULL;
}
g_return_val_if_fail (node != node->next, head); /* node can't be a one item ring here */
-
node->next->prev = node->prev;
node->prev->next = node->next;
if (head == node)
head = node->next;
node_free (node);
-
return head;
}
-
SfiRing*
sfi_ring_reverse (SfiRing *head)
{
@@ -320,56 +286,43 @@ sfi_ring_reverse (SfiRing *head)
}
return head;
}
-
SfiRing*
sfi_ring_remove (SfiRing *head,
gpointer data)
{
SfiRing *walk;
-
if (!head)
return NULL;
-
/* make tail data removal an O(1) operation */
if (head->prev->data == data)
return sfi_ring_remove_node (head, head->prev);
-
for (walk = head; walk; walk = sfi_ring_walk (walk, head))
if (walk->data == data)
return sfi_ring_remove_node (head, walk);
-
/* g_warning (G_STRLOC ": couldn't find data item (%p) to remove from ring (%p)", data, head); */
-
return head;
}
-
guint
sfi_ring_length (const SfiRing *head)
{
const SfiRing *ring;
guint i = 0;
-
for (ring = head; ring; ring = sfi_ring_walk (ring, head))
i++;
-
return i;
}
-
gint /* essentially compute length(ring) - test_length, clamped to -1..+1 */
sfi_ring_cmp_length (const SfiRing *head,
guint test_length)
{
const SfiRing *ring = head;
-
while (test_length && ring)
{
test_length--;
ring = sfi_ring_walk (ring, head);
}
-
return test_length > 0 ? -1 : ring != NULL;
}
-
SfiRing*
sfi_ring_find (const SfiRing *head,
gconstpointer data)
@@ -380,7 +333,6 @@ sfi_ring_find (const SfiRing *head,
return (SfiRing*) ring;
return NULL;
}
-
SfiRing*
sfi_ring_nth (const SfiRing *head,
guint n)
@@ -390,19 +342,15 @@ sfi_ring_nth (const SfiRing *head,
ring = sfi_ring_walk (ring, head);
return (SfiRing*) ring;
}
-
gpointer
sfi_ring_nth_data (const SfiRing *head,
guint n)
{
const SfiRing *ring = head;
-
while (n-- && ring)
ring = sfi_ring_walk (ring, head);
-
return ring ? ring->data : NULL;
}
-
void
sfi_ring_free_deep (SfiRing *head,
GDestroyNotify data_destroy)
@@ -414,7 +362,6 @@ sfi_ring_free_deep (SfiRing *head,
data = sfi_ring_pop_head (&head);
}
}
-
void
sfi_ring_free (SfiRing *head)
{
@@ -424,37 +371,28 @@ sfi_ring_free (SfiRing *head)
free_node_list (head);
}
}
-
gpointer
sfi_ring_pop_head (SfiRing **head_p)
{
gpointer data;
-
g_return_val_if_fail (head_p != NULL, NULL);
-
if (!*head_p)
return NULL;
data = (*head_p)->data;
*head_p = sfi_ring_remove_node (*head_p, *head_p);
-
return data;
}
-
gpointer
sfi_ring_pop_tail (SfiRing **head_p)
{
gpointer data;
-
g_return_val_if_fail (head_p != NULL, NULL);
-
if (!*head_p)
return NULL;
data = (*head_p)->prev->data;
*head_p = sfi_ring_remove_node (*head_p, (*head_p)->prev);
-
return data;
}
-
SfiRing*
sfi_ring_from_list (GList *list)
{
@@ -463,7 +401,6 @@ sfi_ring_from_list (GList *list)
ring = sfi_ring_append (ring, list->data);
return ring;
}
-
SfiRing*
sfi_ring_from_list_and_free (GList *list)
{
@@ -474,7 +411,6 @@ sfi_ring_from_list_and_free (GList *list)
g_list_free (free_list);
return ring;
}
-
SfiRing*
sfi_ring_from_slist (GSList *slist)
{
@@ -483,7 +419,6 @@ sfi_ring_from_slist (GSList *slist)
ring = sfi_ring_append (ring, slist->data);
return ring;
}
-
SfiRing*
sfi_ring_from_slist_and_free (GSList *slist)
{
@@ -494,7 +429,6 @@ sfi_ring_from_slist_and_free (GSList *slist)
g_slist_free (free_slist);
return ring;
}
-
SfiRing*
sfi_ring_insert_sorted (SfiRing *head,
gpointer insertion_data,
@@ -504,22 +438,17 @@ sfi_ring_insert_sorted (SfiRing *head,
g_return_val_if_fail (cmp != NULL, head);
if (!head)
return sfi_ring_prepend (head, insertion_data);
-
/* implement stable sorting by inserting insertion_data *after* equal nodes */
-
if (cmp (insertion_data, head->data, cmp_data) >= 0) /* insert after head */
{
SfiRing *tmp, *tail = head->prev;
-
/* make appending an O(1) operation */
if (head == tail || cmp (insertion_data, tail->data, cmp_data) >= 0)
return sfi_ring_append (head, insertion_data);
-
/* walk forward while data >= tmp (skipping equal nodes) */
for (tmp = head->next; tmp != tail; tmp = tmp->next)
if (cmp (insertion_data, tmp->data, cmp_data) < 0)
break;
-
/* insert before sibling which is greater than insertion_data */
sfi_ring_prepend (tmp, insertion_data); /* keep current head */
return head;
@@ -527,7 +456,6 @@ sfi_ring_insert_sorted (SfiRing *head,
else /* cmp < 0 */
return sfi_ring_prepend (head, insertion_data);
}
-
SfiRing*
sfi_ring_merge_sorted (SfiRing *head1,
SfiRing *head2,
@@ -535,7 +463,6 @@ sfi_ring_merge_sorted (SfiRing *head1,
gpointer data)
{
/* implement stable sorting by inserting head2 members *after* equal nodes from head1 */
-
if (head1 && head2)
{
SfiRing *tail1 = head1->prev;
@@ -577,16 +504,13 @@ sfi_ring_merge_sorted (SfiRing *head1,
else
return sfi_ring_concat (head1, head2);
}
-
SfiRing*
sfi_ring_sort (SfiRing *head,
SfiCompareFunc cmp,
gpointer data)
{
g_return_val_if_fail (cmp != NULL, head);
-
/* stable sorting guaranteed by sfi_ring_merge_sorted() */
-
if (head && head->next != head)
{
SfiRing *ring, *tmp, *tail = head->prev;
@@ -604,7 +528,6 @@ sfi_ring_sort (SfiRing *head,
}
return head;
}
-
SfiRing* /* eliminates duplicate nodes */
sfi_ring_uniq (SfiRing *sorted_ring1,
SfiCompareFunc cmp,
@@ -633,7 +556,6 @@ sfi_ring_uniq (SfiRing *sorted_ring1,
}
return r2;
}
-
SfiRing* /* eliminates duplicate nodes */
sfi_ring_uniq_free_deep (SfiRing *sorted_ring1,
SfiCompareFunc cmp,
@@ -668,7 +590,6 @@ sfi_ring_uniq_free_deep (SfiRing *sorted_ring1,
}
return r2;
}
-
SfiRing* /* eliminates duplicate nodes */
sfi_ring_copy_deep_uniq (const SfiRing *sorted_ring1,
SfiRingDataFunc copy,
@@ -694,7 +615,6 @@ sfi_ring_copy_deep_uniq (const SfiRing *sorted_ring1,
}
return r2;
}
-
SfiRing* /* eliminates duplicate nodes */
sfi_ring_copy_uniq (const SfiRing *sorted_ring1,
SfiCompareFunc cmp,
@@ -716,7 +636,6 @@ sfi_ring_copy_uniq (const SfiRing *sorted_ring1,
}
return r2;
}
-
/**
* @param sorted_set1 Sorted ring 1
* @param sorted_set2 Sorted ring 2
@@ -763,7 +682,6 @@ sfi_ring_union (const SfiRing *sorted_set1,
}
return sfi_ring_concat (d, sfi_ring_copy_rest (r1 ? r1 : r2, r1 ? sorted_set1 : sorted_set2));
}
-
/**
* @param sorted_set1 Sorted ring 1
* @param sorted_set2 Sorted ring 2
@@ -804,7 +722,6 @@ sfi_ring_intersection (const SfiRing *sorted_set1,
}
return d;
}
-
/**
* @param sorted_set1 Sorted ring 1
* @param sorted_set2 Sorted ring 2
@@ -843,7 +760,6 @@ sfi_ring_difference (const SfiRing *sorted_set1,
}
return sfi_ring_concat (d, sfi_ring_copy_rest (r1, sorted_set1));
}
-
/**
* @param sorted_set1 Sorted ring 1
* @param sorted_set2 Sorted ring 2
@@ -887,7 +803,6 @@ sfi_ring_symmetric_difference (const SfiRing *sorted_set1,
}
return sfi_ring_concat (d, sfi_ring_copy_rest (r1 ? r1 : r2, r1 ? sorted_set1 : sorted_set2));
}
-
static inline int
pointerloccmp (const void *pp1,
const void *pp2)
@@ -896,7 +811,6 @@ pointerloccmp (const void *pp1,
void* const * p2 = (void**) pp2;
return *p1 < *p2 ? -1 : *p1 != *p2;
}
-
static inline gboolean
ring_reorder_lookup (guint n_items,
gpointer *items,
@@ -920,7 +834,6 @@ ring_reorder_lookup (guint n_items,
}
return FALSE;
}
-
/**
* @param unordered_ring Unsorted ring
* @param new_ring_order Ring with arbitrary order
@@ -938,7 +851,6 @@ sfi_ring_reorder (SfiRing *unordered_ring,
if (!unordered_ring || !new_ring_order)
return unordered_ring;
const SfiRing *ring;
-
/* construct a sorted array for faster lookups; O(length(unordered_ring)) */
gpointer *items = NULL;
guint i, n_items = 0, n_alloced = 0;
@@ -955,7 +867,6 @@ sfi_ring_reorder (SfiRing *unordered_ring,
sfi_ring_free (unordered_ring);
unordered_ring = NULL;
qsort (items, n_items, sizeof (items[0]), pointerloccmp);
-
/* collapse duplicates; O(length(unordered_ring)) */
guint j = 0, *counts = g_new0 (guint, n_items);
for (i = 0; i < n_items; i++)
@@ -968,7 +879,6 @@ sfi_ring_reorder (SfiRing *unordered_ring,
else /* catch dups */
counts[j]++;
n_items = j + 1; /* shrink to number of different items */
-
/* pick unordered_ring members in the order given by new_ring_order;
* O(length(new_ring_order) * O(bsearch(unordered_ring)))
*/
@@ -978,17 +888,14 @@ sfi_ring_reorder (SfiRing *unordered_ring,
counts[i]--;
unordered_ring = sfi_ring_append (unordered_ring, ring->data);
}
-
/* append left-over members from sorted_ring; O(length(unordered_ring)) */
for (i = 0; i < n_items; i++)
while (counts[i]--)
unordered_ring = sfi_ring_append (unordered_ring, items[i]);
-
g_free (items);
g_free (counts);
return unordered_ring;
}
-
gboolean
sfi_ring_includes (const SfiRing *sorted_super_set,
const SfiRing *sorted_sub_set,
@@ -1008,7 +915,6 @@ sfi_ring_includes (const SfiRing *sorted_super_set,
}
return !r2;
}
-
/**
* @param sorted_ring1 Sorted ring 1
* @param sorted_ring2 Sorted ring 2
@@ -1036,7 +942,6 @@ sfi_ring_equals (const SfiRing *sorted_ring1,
}
return r1 == r2; /* both need to be NULL */
}
-
/**
* @param sorted_ring1_p Pointer to sorted ring 1
* @param sorted_ring2_p Pointer to sorted ring 2
@@ -1070,7 +975,6 @@ sfi_ring_mismatch (SfiRing **sorted_ring1_p,
*sorted_ring2_p = r2;
return TRUE;
}
-
/**
* @param head Head node of a ring or NULL for an empty ring
* @param cmp Compare function for node data
@@ -1095,7 +999,6 @@ sfi_ring_min_node (const SfiRing *head,
}
return (SfiRing*) last;
}
-
/**
* @param head Head node of a ring or NULL for an empty ring
* @param cmp Compare function for node data
@@ -1120,7 +1023,6 @@ sfi_ring_max_node (const SfiRing *head,
}
return (SfiRing*) last;
}
-
/**
* @param head Head node of a ring or NULL for an empty ring
* @param cmp Compare function for node data
@@ -1138,7 +1040,6 @@ sfi_ring_min (const SfiRing *head,
SfiRing *ring = sfi_ring_min_node (head, cmp, data);
return ring ? ring->data : NULL;
}
-
/**
* @param head Head node of a ring or NULL for an empty ring
* @param cmp Compare function for node data
diff --git a/sfi/sfiring.hh b/sfi/sfiring.hh
index 90a424a..a91c261 100644
--- a/sfi/sfiring.hh
+++ b/sfi/sfiring.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_RING_H__
#define __SFI_RING_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS;
-
-
/* --- basic comparisons --- */
typedef gint (*SfiCompareFunc) (gconstpointer value1,
gconstpointer value2,
@@ -14,8 +10,6 @@ typedef gint (*SfiCompareFunc) (gconstpointer value1,
gint sfi_pointer_cmp (gconstpointer value1,
gconstpointer value2,
gpointer dummy);
-
-
/* --- ring (circular-list) --- */
typedef gpointer (*SfiRingDataFunc) (gpointer data,
gpointer func_data);
@@ -75,7 +69,6 @@ gpointer sfi_ring_pop_tail (SfiRing **head);
void sfi_ring_free (SfiRing *head);
void sfi_ring_free_deep (SfiRing *head,
GDestroyNotify data_destroy);
-
SfiRing* sfi_ring_from_list (GList *list);
SfiRing* sfi_ring_from_list_and_free (GList *list);
SfiRing* sfi_ring_from_slist (GSList *slist);
@@ -83,8 +76,6 @@ SfiRing* sfi_ring_from_slist_and_free (GSList *slist);
#define sfi_ring_tail(head) ((head) ? (head)->prev : NULL)
#define sfi_ring_walk(node,head_bound) ((node)->next != (head_bound) ? (node)->next : NULL)
#define sfi_ring_next(node,head_bound) sfi_ring_walk (node, head_bound)
-
-
/* ring-modifying cmp-based operations */
SfiRing* sfi_ring_insert_sorted (SfiRing *head,
gpointer insertion_data,
@@ -156,9 +147,6 @@ gpointer sfi_ring_min (const SfiRing *head,
gpointer sfi_ring_max (const SfiRing *head,
SfiCompareFunc cmp,
gpointer data);
-
G_END_DECLS;
-
#endif /* __SFI_RING_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiserial.cc b/sfi/sfiserial.cc
index 7005b83..be20f7b 100644
--- a/sfi/sfiserial.cc
+++ b/sfi/sfiserial.cc
@@ -6,9 +6,7 @@
#include "sfitime.hh"
#include "sfinote.hh"
#include <stdlib.h> // FIXME: remove "free"
-
typedef std::string String; // FIXME
-
/* --- parsing aids --- */
#define MC(s) const_cast<char*> (s)
static const GScannerConfig storage_scanner_config = {
@@ -50,7 +48,6 @@ static const GScannerConfig storage_scanner_config = {
TRUE /* store_int64 */,
};
const GScannerConfig *sfi_storage_scanner_config = &storage_scanner_config;
-
#define parse_or_return(scanner, token) G_STMT_START{ \
GScanner *__s = (scanner); int _t = (token); \
if (g_scanner_get_next_token (__s) != _t) \
@@ -80,7 +77,6 @@ scanner_skip_statement (GScanner *scanner,
}
return G_TOKEN_NONE;
}
-
static String
string_vprintf (const char *format, va_list vargs) // FIXME: move
{
@@ -94,7 +90,6 @@ string_vprintf (const char *format, va_list vargs) // FIXME: move
else
return format;
}
-
static String
string_printf (const char *format, ...) // FIXME: move
{
@@ -105,7 +100,6 @@ string_printf (const char *format, ...) // FIXME: move
va_end (args);
return str;
}
-
static String
string_to_cescape (const String &str) // FIXME: move
{
@@ -124,7 +118,6 @@ string_to_cescape (const String &str) // FIXME: move
}
return buffer;
}
-
/* --- storage helpers --- */
#define gstring_puts(gstring, string) g_string_append (gstring, string)
#define gstring_putc(gstring, vchar) g_string_append_c (gstring, vchar)
@@ -142,7 +135,6 @@ gstring_break (GString *gstring,
g_free (s);
*needs_break = FALSE;
}
-
static void
gstring_check_break (GString *gstring,
gboolean *needs_break,
@@ -151,8 +143,6 @@ gstring_check_break (GString *gstring,
if (*needs_break)
gstring_break (gstring, needs_break, indent);
}
-
-
/* --- functions --- */
static GTokenType
sfi_scanner_parse_real_num (GScanner *scanner,
@@ -162,7 +152,6 @@ sfi_scanner_parse_real_num (GScanner *scanner,
gboolean negate = FALSE;
gdouble vdouble;
guint64 ui64;
-
g_scanner_get_next_token (scanner);
if (scanner->token == '-')
{
@@ -191,7 +180,6 @@ sfi_scanner_parse_real_num (GScanner *scanner,
*real_p = negate ? -vdouble : vdouble;
return G_TOKEN_NONE;
}
-
static void
sfi_serialize_rec_typed (SfiRec *rec,
GString *gstring)
@@ -213,7 +201,6 @@ sfi_serialize_rec_typed (SfiRec *rec,
gstring_putc (gstring, ')');
}
}
-
static GTokenType
sfi_parse_rec_typed (GScanner *scanner,
GValue *value)
@@ -258,7 +245,6 @@ sfi_parse_rec_typed (GScanner *scanner,
return GTokenType ('(');
return G_TOKEN_NONE;
}
-
static GTokenType
sfi_serialize_primitives (SfiSCategory scat,
GValue *value,
@@ -334,7 +320,6 @@ sfi_serialize_primitives (SfiSCategory scat,
if (gstring)
{
gchar numbuf[G_ASCII_DTOSTR_BUF_SIZE + 1] = "";
-
if (g_option_check (hints, "f")) /* float hint */
gstring_puts (gstring, g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%.7g", sfi_value_get_real (value)));
else
@@ -572,16 +557,13 @@ sfi_serialize_primitives (SfiSCategory scat,
}
return G_TOKEN_NONE;
}
-
void
sfi_value_store_typed (const GValue *value,
GString *gstring)
{
SfiSCategory scat;
-
g_return_if_fail (G_IS_VALUE (value));
g_return_if_fail (gstring != NULL);
-
scat = SfiSCategory (sfi_categorize_type (G_VALUE_TYPE (value)) & SFI_SCAT_TYPE_MASK);
switch (scat)
{
@@ -632,14 +614,12 @@ sfi_value_store_typed (const GValue *value,
g_error ("%s: unimplemented category (%u)", G_STRLOC, scat);
}
}
-
GTokenType
sfi_value_parse_typed (GValue *value,
GScanner *scanner)
{
g_return_val_if_fail (value != NULL && G_VALUE_TYPE (value) == 0, G_TOKEN_ERROR);
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
-
parse_or_return (scanner, '(');
char scat = g_scanner_get_next_token (scanner);
if (!((scat >= 'a' && scat <= 'z') ||
@@ -706,7 +686,6 @@ sfi_value_parse_typed (GValue *value,
}
return G_TOKEN_NONE;
}
-
static void
value_store_param (const GValue *value,
GString *gstring,
@@ -716,7 +695,6 @@ value_store_param (const GValue *value,
guint indent)
{
SfiSCategory scat = sfi_categorize_pspec (pspec);
-
gstring_check_break (gstring, needs_break, indent);
switch (scat)
{
@@ -807,7 +785,6 @@ value_store_param (const GValue *value,
g_error ("%s: unimplemented category (%u)", G_STRLOC, scat);
}
}
-
void
sfi_value_store_param (const GValue *value,
GString *gstring,
@@ -815,18 +792,15 @@ sfi_value_store_param (const GValue *value,
guint indent)
{
gboolean needs_break = FALSE;
-
g_return_if_fail (G_IS_VALUE (value));
g_return_if_fail (gstring != NULL);
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_return_if_fail (G_VALUE_HOLDS (value, G_PARAM_SPEC_VALUE_TYPE (pspec)));
-
gstring_check_break (gstring, &needs_break, indent);
gstring_printf (gstring, "(%s ", pspec->name);
value_store_param (value, gstring, &needs_break, TRUE, pspec, indent + 2);
gstring_putc (gstring, ')');
}
-
static GTokenType
value_parse_param (GValue *value,
GScanner *scanner,
@@ -834,7 +808,6 @@ value_parse_param (GValue *value,
gboolean close_statement)
{
SfiSCategory scat;
-
scat = sfi_categorize_pspec (pspec);
switch (scat)
{
@@ -945,7 +918,6 @@ value_parse_param (GValue *value,
parse_or_return (scanner, ')');
return G_TOKEN_NONE;
}
-
GTokenType
sfi_value_parse_param_rest (GValue *value,
GScanner *scanner,
@@ -954,21 +926,16 @@ sfi_value_parse_param_rest (GValue *value,
g_return_val_if_fail (value != NULL && G_VALUE_TYPE (value) == 0, G_TOKEN_ERROR);
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), G_TOKEN_ERROR);
-
/* the scanner better be at the pspec name */
g_return_val_if_fail (scanner->token == G_TOKEN_IDENTIFIER, G_TOKEN_ERROR);
g_return_val_if_fail (strcmp (scanner->value.v_identifier, pspec->name) == 0, G_TOKEN_ERROR);
-
g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-
return value_parse_param (value, scanner, pspec, TRUE);
}
-
gboolean
sfi_serial_check_parse_null_token (GScanner *scanner)
{
g_return_val_if_fail (scanner != NULL, FALSE);
-
if (scanner->token == '#' && g_scanner_peek_next_token (scanner) == 'f')
{
g_scanner_get_next_token (scanner);
@@ -977,7 +944,6 @@ sfi_serial_check_parse_null_token (GScanner *scanner)
else
return FALSE;
}
-
void
sfi_value_store_stderr (const GValue *value)
{
diff --git a/sfi/sfiserial.hh b/sfi/sfiserial.hh
index 1bd905c..1d15962 100644
--- a/sfi/sfiserial.hh
+++ b/sfi/sfiserial.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_SERIAL_H__
#define __SFI_SERIAL_H__
-
#include <sfi/sfivalues.hh>
-
G_BEGIN_DECLS
-
-
/* --- functions --- */
GTokenType sfi_value_parse_typed (GValue *value,
GScanner *scanner);
@@ -20,22 +16,14 @@ void sfi_value_store_param (const GValue *value,
GParamSpec *pspec,
guint indent);
void sfi_value_store_stderr (const GValue *value);
-
-
/* --- NULL (nil) token handling --- */
#define SFI_SERIAL_NULL_TOKEN "#f"
/* parse NULL token if possible and return TRUE, otherwise
* return FALSE and don't advance scanner
*/
gboolean sfi_serial_check_parse_null_token (GScanner *scanner);
-
-
/* --- GScanner config --- */
extern const GScannerConfig *sfi_storage_scanner_config;
-
-
G_END_DECLS
-
#endif /* __SFI_SERIAL_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfistore.cc b/sfi/sfistore.cc
index 15bb92d..3c11a46 100644
--- a/sfi/sfistore.cc
+++ b/sfi/sfistore.cc
@@ -9,9 +9,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-
-
-
/* --- structures --- */
typedef struct {
SfiStoreReadBin reader;
@@ -20,8 +17,6 @@ typedef struct {
off_t patch_offset;
off_t offset, length;
} BBlock;
-
-
/* --- writable store --- */
SfiWStore*
sfi_wstore_new (void)
@@ -33,12 +28,10 @@ sfi_wstore_new (void)
wstore->comment_start = ';';
return wstore;
}
-
void
sfi_wstore_destroy (SfiWStore *wstore)
{
g_return_if_fail (wstore != NULL);
-
g_string_free (wstore->text, TRUE);
wstore->text = NULL;
while (wstore->bblocks)
@@ -50,18 +43,15 @@ sfi_wstore_destroy (SfiWStore *wstore)
}
g_free (wstore);
}
-
static inline void
sfi_wstore_text_changed (SfiWStore *wstore)
{
wstore->needs_break = wstore->text->len && wstore->text->str[wstore->text->len - 1] != '\n';
}
-
void
sfi_wstore_break (SfiWStore *wstore)
{
g_return_if_fail (wstore != NULL);
-
if (wstore->needs_break)
{
guint n;
@@ -72,30 +62,24 @@ sfi_wstore_break (SfiWStore *wstore)
g_string_append (wstore->text, " ");
}
}
-
void
sfi_wstore_push_level (SfiWStore *wstore)
{
g_return_if_fail (wstore != NULL);
-
wstore->indent += 2;
}
-
void
sfi_wstore_pop_level (SfiWStore *wstore)
{
g_return_if_fail (wstore != NULL);
-
if (wstore->indent >= 2)
wstore->indent -= 2;
}
-
void
sfi_wstore_puts (SfiWStore *wstore,
const gchar *string)
{
g_return_if_fail (wstore != NULL);
-
if (string)
{
g_string_append (wstore->text, string);
@@ -103,17 +87,14 @@ sfi_wstore_puts (SfiWStore *wstore,
sfi_wstore_text_changed (wstore);
}
}
-
void
sfi_wstore_putc (SfiWStore *wstore,
gchar character)
{
g_return_if_fail (wstore != NULL);
-
g_string_append_c (wstore->text, character);
sfi_wstore_text_changed (wstore);
}
-
void
sfi_wstore_printf (SfiWStore *wstore,
const gchar *format,
@@ -121,64 +102,48 @@ sfi_wstore_printf (SfiWStore *wstore,
{
gchar *buffer;
va_list args;
-
g_return_if_fail (wstore != NULL);
-
const gchar *ldir = g_printf_find_localised_directive (format);
if (ldir)
g_warning ("%s: encountered localised directive \"%s\" in format string: \"%s\"", G_STRFUNC, ldir, format);
-
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
va_end (args);
-
g_string_append (wstore->text, buffer);
if (buffer[0])
sfi_wstore_text_changed (wstore);
g_free (buffer);
}
-
void
sfi_wstore_putf (SfiWStore *wstore,
gfloat vfloat)
{
gchar numbuf[G_ASCII_DTOSTR_BUF_SIZE + 1] = "";
-
g_return_if_fail (wstore != NULL);
-
g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%.7g", vfloat);
-
sfi_wstore_puts (wstore, numbuf);
}
-
void
sfi_wstore_putd (SfiWStore *wstore,
gdouble vdouble)
{
gchar numbuf[G_ASCII_DTOSTR_BUF_SIZE + 1] = "";
-
g_return_if_fail (wstore != NULL);
-
g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%.17g", vdouble);
-
sfi_wstore_puts (wstore, numbuf);
}
-
void
sfi_wstore_put_value (SfiWStore *wstore,
const GValue *value)
{
GString *gstring;
-
g_return_if_fail (wstore != NULL);
g_return_if_fail (G_IS_VALUE (value));
-
gstring = g_string_new (NULL);
sfi_value_store_typed (value, gstring);
sfi_wstore_puts (wstore, gstring->str);
g_string_free (gstring, TRUE);
}
-
void
sfi_wstore_put_param (SfiWStore *wstore,
const GValue *value,
@@ -186,16 +151,13 @@ sfi_wstore_put_param (SfiWStore *wstore,
{
GValue svalue = { 0, };
GParamSpec *spspec;
-
g_return_if_fail (wstore != NULL);
g_return_if_fail (G_IS_VALUE (value));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
-
spspec = sfi_pspec_to_serializable (pspec);
if (!spspec) /* we really can't do anything here */
g_error ("unable to (de-)serialize \"%s\" of type `%s'", pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
-
g_value_init (&svalue, G_PARAM_SPEC_VALUE_TYPE (spspec));
if (sfi_value_transform (value, &svalue))
{
@@ -222,7 +184,6 @@ sfi_wstore_put_param (SfiWStore *wstore,
g_value_unset (&svalue);
g_param_spec_unref (spspec);
}
-
void
sfi_wstore_put_binary (SfiWStore *wstore,
SfiStoreReadBin reader,
@@ -230,34 +191,27 @@ sfi_wstore_put_binary (SfiWStore *wstore,
GDestroyNotify destroy)
{
BBlock *bblock;
-
g_return_if_fail (wstore != NULL);
g_return_if_fail (wstore->flushed == FALSE);
g_return_if_fail (reader != NULL);
-
bblock = g_new0 (BBlock, 1);
bblock->reader = reader;
bblock->data = data;
bblock->destroy = destroy;
wstore->bblocks = sfi_ring_append (wstore->bblocks, bblock);
-
sfi_wstore_puts (wstore, "(binary-appendix ");
bblock->patch_offset = wstore->text->len;
sfi_wstore_puts (wstore, "0x00000000 0x00000000)");
}
-
const gchar*
sfi_wstore_peek_text (SfiWStore *wstore,
guint *length_p)
{
g_return_val_if_fail (wstore != NULL, NULL);
-
if (length_p)
*length_p = wstore->text->len;
-
return wstore->text->str;
}
-
gint /* -errno */
sfi_wstore_flush_fd (SfiWStore *wstore,
gint fd)
@@ -267,29 +221,23 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
SfiRing *ring;
off_t text_offset, binary_offset;
guint l;
-
g_return_val_if_fail (wstore != NULL, -EINVAL);
g_return_val_if_fail (wstore->flushed == FALSE, -EINVAL);
g_return_val_if_fail (fd >= 0, -EINVAL);
-
wstore->flushed = TRUE;
-
sfi_wstore_break (wstore);
-
/* save text offset */
do
text_offset = lseek (fd, 0, SEEK_CUR);
while (text_offset < 0 && errno == EINTR);
if (text_offset < 0 && errno)
return -errno;
-
/* dump text */
do
l = write (fd, wstore->text->str, wstore->text->len);
while (l < 0 && errno == EINTR);
if (l < 0 && errno)
return -errno;
-
/* binary data header */
if (wstore->bblocks)
{
@@ -302,7 +250,6 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
if (l < 0 && errno)
return -errno;
}
-
/* save binary offset */
do
binary_offset = lseek (fd, 0, SEEK_CUR);
@@ -310,13 +257,11 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
/* binary_offset is position of the first byte *after* \000 */
if (binary_offset < 0 && errno)
return -errno;
-
/* store binary data */
for (ring = wstore->bblocks; ring; ring = sfi_ring_walk (ring, wstore->bblocks))
{
BBlock *bblock = (BBlock*) ring->data;
int n;
-
/* save block offset */
do
bblock->offset = lseek (fd, 0, SEEK_CUR);
@@ -324,7 +269,6 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
bblock->length = 0;
if (bblock->offset < 0 && errno)
return -errno;
-
/* dump binary */
do
{
@@ -341,7 +285,6 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
}
while (n);
}
-
/* patch binary offsets and lengths */
for (ring = wstore->bblocks; ring; ring = sfi_ring_walk (ring, wstore->bblocks))
{
@@ -349,7 +292,6 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
off_t foff;
gchar ptext[2 + 8 + 1 + 2 + 8 + 1];
/* 0x *0* ' ' 0x *0* '\0' */
-
do
foff = lseek (fd, text_offset + bblock->patch_offset, SEEK_SET);
while (foff < 0 && errno == EINTR);
@@ -364,18 +306,14 @@ sfi_wstore_flush_fd (SfiWStore *wstore,
if (l < 0 && errno)
return -errno;
}
-
/* finished successfully */
return 0;
}
-
-
/* --- readable store --- */
SfiRStore*
sfi_rstore_new (void)
{
SfiRStore *rstore;
-
rstore = g_new0 (SfiRStore, 1);
rstore->scanner = g_scanner_new64 (sfi_storage_scanner_config);
rstore->scanner->max_parse_errors = 1;
@@ -383,10 +321,8 @@ sfi_rstore_new (void)
rstore->parser_this = rstore;
rstore->close_fd = -1;
rstore->bin_offset = -1;
-
return rstore;
}
-
SfiRStore*
sfi_rstore_new_open (const gchar *fname)
{
@@ -423,19 +359,16 @@ sfi_rstore_new_open (const gchar *fname)
/* preserve errno for NULL */
return rstore;
}
-
void
sfi_rstore_destroy (SfiRStore *rstore)
{
g_return_if_fail (rstore != NULL);
-
if (rstore->close_fd >= 0)
close (rstore->close_fd);
g_scanner_destroy (rstore->scanner);
g_free (rstore->fname);
g_free (rstore);
}
-
void
sfi_rstore_input_fd (SfiRStore *rstore,
gint fd,
@@ -443,14 +376,12 @@ sfi_rstore_input_fd (SfiRStore *rstore,
{
g_return_if_fail (rstore != NULL);
g_return_if_fail (fd >= 0);
-
g_free (rstore->fname);
rstore->fname = g_strdup (fname ? fname : "<anon-fd>");
rstore->scanner->input_name = rstore->fname;
rstore->scanner->parse_errors = 0;
g_scanner_input_file (rstore->scanner, fd);
}
-
void
sfi_rstore_input_text (SfiRStore *rstore,
const gchar *text,
@@ -458,36 +389,28 @@ sfi_rstore_input_text (SfiRStore *rstore,
{
g_return_if_fail (rstore != NULL);
g_return_if_fail (text != NULL);
-
g_free (rstore->fname);
rstore->fname = g_strdup (text_name ? text_name : "<memory>");
rstore->scanner->input_name = rstore->fname;
rstore->scanner->parse_errors = 0;
g_scanner_input_text (rstore->scanner, text, strlen (text));
}
-
gboolean
sfi_rstore_eof (SfiRStore *rstore)
{
GScanner *scanner;
-
g_return_val_if_fail (rstore != NULL, TRUE);
-
scanner = rstore->scanner;
-
return g_scanner_eof (scanner) || scanner->parse_errors >= scanner->max_parse_errors;
}
-
void
sfi_rstore_error (SfiRStore *rstore,
const gchar *format,
...)
{
va_list args;
-
g_return_if_fail (rstore);
g_return_if_fail (format != NULL);
-
va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
{
@@ -497,20 +420,16 @@ sfi_rstore_error (SfiRStore *rstore,
}
va_end (args);
}
-
void
sfi_rstore_unexp_token (SfiRStore *rstore,
GTokenType expected_token)
{
GScanner *scanner;
-
g_return_if_fail (rstore);
-
scanner = rstore->scanner;
if (scanner->parse_errors < scanner->max_parse_errors)
{
const char *message;
-
if (scanner->parse_errors + 1 >= scanner->max_parse_errors)
message = "aborting...";
else
@@ -518,17 +437,14 @@ sfi_rstore_unexp_token (SfiRStore *rstore,
g_scanner_unexp_token (scanner, expected_token, NULL, NULL, NULL, message, TRUE);
}
}
-
void
sfi_rstore_warn (SfiRStore *rstore,
const gchar *format,
...)
{
va_list args;
-
g_return_if_fail (rstore);
g_return_if_fail (format != NULL);
-
va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
{
@@ -538,14 +454,12 @@ sfi_rstore_warn (SfiRStore *rstore,
}
va_end (args);
}
-
static GTokenType
scanner_skip_statement (GScanner *scanner,
guint level) /* == number of closing parens left to read */
{
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (level > 0, G_TOKEN_ERROR);
-
do
{
g_scanner_get_next_token (scanner);
@@ -567,17 +481,14 @@ scanner_skip_statement (GScanner *scanner,
while (level);
return G_TOKEN_NONE;
}
-
GTokenType
sfi_rstore_warn_skip (SfiRStore *rstore,
const gchar *format,
...)
{
va_list args;
-
g_return_val_if_fail (rstore, G_TOKEN_ERROR);
g_return_val_if_fail (format != NULL, G_TOKEN_ERROR);
-
va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
{
@@ -587,10 +498,8 @@ sfi_rstore_warn_skip (SfiRStore *rstore,
g_free (string);
}
va_end (args);
-
return scanner_skip_statement (rstore->scanner, 1);
}
-
void
sfi_rstore_quick_scan (SfiRStore *rstore,
const gchar *identifier,
@@ -598,7 +507,6 @@ sfi_rstore_quick_scan (SfiRStore *rstore,
gpointer data)
{
g_return_if_fail (rstore);
-
while (g_scanner_peek_next_token (rstore->scanner) == '(')
{
g_scanner_get_next_token (rstore->scanner);
@@ -614,7 +522,6 @@ sfi_rstore_quick_scan (SfiRStore *rstore,
scanner_skip_statement (rstore->scanner, 1);
}
}
-
GTokenType
sfi_rstore_parse_param (SfiRStore *rstore,
GValue *value,
@@ -623,16 +530,13 @@ sfi_rstore_parse_param (SfiRStore *rstore,
GParamSpec *spspec;
GValue pvalue = { 0, };
GTokenType token;
-
g_return_val_if_fail (rstore != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (G_IS_VALUE (value), G_TOKEN_ERROR);
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), G_TOKEN_ERROR);
-
spspec = sfi_pspec_to_serializable (pspec);
if (!spspec) /* we really can't do anything here */
g_error ("unable to (de-)serialize \"%s\" of type `%s'", pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
-
token = sfi_value_parse_param_rest (&pvalue, rstore->scanner, spspec);
if (token == G_TOKEN_NONE)
{
@@ -661,7 +565,6 @@ sfi_rstore_parse_param (SfiRStore *rstore,
g_param_spec_unref (spspec);
return token;
}
-
static gboolean
rstore_ensure_bin_offset (SfiRStore *rstore)
{
@@ -672,7 +575,6 @@ rstore_ensure_bin_offset (SfiRStore *rstore)
ssize_t l;
gboolean seen_zero = FALSE;
gint fd = rstore->scanner->input_fd;
-
/* save current scanning offset */
g_scanner_sync_file_offset (rstore->scanner);
g_scanner_sync_file_offset (rstore->scanner);
@@ -681,7 +583,6 @@ rstore_ensure_bin_offset (SfiRStore *rstore)
while (sc_offset < 0 && errno == EINTR);
if (sc_offset < 0)
return FALSE;
-
/* seek to literal '\0' */
zero_offset = sc_offset;
do
@@ -691,7 +592,6 @@ rstore_ensure_bin_offset (SfiRStore *rstore)
while (l < 0 && errno == EINTR);
if (l < 0)
return FALSE;
-
p = (uint8*) memchr (sdata, 0, l);
seen_zero = p != NULL;
zero_offset += seen_zero ? p - sdata : l;
@@ -699,7 +599,6 @@ rstore_ensure_bin_offset (SfiRStore *rstore)
while (!seen_zero && l);
if (!seen_zero)
return FALSE;
-
/* restore scanning offset */
rstore->bin_offset = zero_offset + 1;
do
@@ -710,12 +609,10 @@ rstore_ensure_bin_offset (SfiRStore *rstore)
}
return TRUE;
}
-
GTokenType
sfi_rstore_ensure_bin_offset (SfiRStore *rstore)
{
g_return_val_if_fail (rstore != NULL, G_TOKEN_ERROR);
-
if (!rstore_ensure_bin_offset (rstore))
{
/* this is _bad_, we can't actually continue parsing after
@@ -726,16 +623,13 @@ sfi_rstore_ensure_bin_offset (SfiRStore *rstore)
}
return G_TOKEN_NONE;
}
-
guint64
sfi_rstore_get_bin_offset (SfiRStore *rstore)
{
g_return_val_if_fail (rstore != NULL, 0);
g_return_val_if_fail (rstore->bin_offset >= 0, 0); /* sfi_rstore_ensure_bin_offset() must be called before hand */
-
return rstore->bin_offset;
}
-
GTokenType
sfi_rstore_parse_zbinary (SfiRStore *rstore,
SfiNum *offset_p,
@@ -743,7 +637,6 @@ sfi_rstore_parse_zbinary (SfiRStore *rstore,
{
g_return_val_if_fail (rstore != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (offset_p && length_p, G_TOKEN_ERROR);
-
if (g_scanner_get_next_token (rstore->scanner) != '(')
return GTokenType ('(');
if (g_scanner_get_next_token (rstore->scanner) != G_TOKEN_IDENTIFIER ||
@@ -761,7 +654,6 @@ sfi_rstore_parse_zbinary (SfiRStore *rstore,
*length_p = length;
return G_TOKEN_NONE;
}
-
GTokenType
sfi_rstore_parse_binary (SfiRStore *rstore,
SfiNum *offset_p,
@@ -776,7 +668,6 @@ sfi_rstore_parse_binary (SfiRStore *rstore,
*offset_p += rstore->bin_offset;
return G_TOKEN_NONE;
}
-
GTokenType
sfi_rstore_parse_until (SfiRStore *rstore,
GTokenType closing_token,
@@ -785,13 +676,10 @@ sfi_rstore_parse_until (SfiRStore *rstore,
gpointer user_data)
{
GScanner *scanner;
-
g_return_val_if_fail (rstore != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (try_statement != NULL, G_TOKEN_ERROR);
g_return_val_if_fail (closing_token == G_TOKEN_EOF || closing_token == ')', G_TOKEN_ERROR);
-
scanner = rstore->scanner;
-
/* we catch all SFI_TOKEN_UNMATCHED at this level. it is merely
* a "magic" token value to implement the try_statement() semantics
*/
@@ -799,7 +687,6 @@ sfi_rstore_parse_until (SfiRStore *rstore,
{
GTokenType expected_token;
uint saved_line, saved_position;
-
/* it is only useful to feature statements which
* start out with an identifier (syntactically)
*/
@@ -828,10 +715,8 @@ sfi_rstore_parse_until (SfiRStore *rstore,
if (expected_token != G_TOKEN_NONE)
return expected_token;
}
-
return scanner->token == closing_token ? G_TOKEN_NONE : closing_token;
}
-
guint
sfi_rstore_parse_all (SfiRStore *rstore,
gpointer context_data,
@@ -839,16 +724,12 @@ sfi_rstore_parse_all (SfiRStore *rstore,
gpointer user_data)
{
GTokenType expected_token = G_TOKEN_NONE;
-
g_return_val_if_fail (rstore != NULL, 1);
g_return_val_if_fail (try_statement != NULL, 1);
-
/* parse all statements */
expected_token = sfi_rstore_parse_until (rstore, G_TOKEN_EOF, context_data, try_statement, user_data);
-
/* report error if any */
if (expected_token != G_TOKEN_NONE)
sfi_rstore_unexp_token (rstore, expected_token);
-
return rstore->scanner->parse_errors;
}
diff --git a/sfi/sfistore.hh b/sfi/sfistore.hh
index 6cb114c..4fd2e9c 100644
--- a/sfi/sfistore.hh
+++ b/sfi/sfistore.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_STORE_H__
#define __SFI_STORE_H__
-
#include <sfi/sfivalues.hh>
#include <sfi/sfiring.hh>
-
G_BEGIN_DECLS
-
-
/* --- typedefs and structures --- */
typedef gint /* -errno || length */ (*SfiStoreReadBin) (gpointer data,
void *buffer,
@@ -36,8 +32,6 @@ struct _SfiRStore
gpointer parser_this;
SfiNum bin_offset;
};
-
-
/* --- writable store --- */
SfiWStore* sfi_wstore_new (void);
void sfi_wstore_destroy (SfiWStore *wstore);
@@ -68,8 +62,6 @@ gint /*-errno*/ sfi_wstore_flush_fd (SfiWStore *wstore,
gint fd);
const gchar* sfi_wstore_peek_text (SfiWStore *wstore,
guint *length);
-
-
/* --- readable store --- */
SfiRStore* sfi_rstore_new (void);
SfiRStore* sfi_rstore_new_open (const gchar *fname);
@@ -118,8 +110,6 @@ void sfi_rstore_quick_scan (SfiRStore *rstore,
const gchar *identifier,
SfiRStoreQuickScan qcheck,
gpointer data);
-
-
/* --- convenience --- */
#define sfi_scanner_parse_or_return(scanner, token) G_STMT_START { \
GTokenType _t = GTokenType (token); \
@@ -135,10 +125,6 @@ void sfi_rstore_quick_scan (SfiRStore *rstore,
return _t; \
} \
} G_STMT_END
-
-
G_END_DECLS
-
#endif /* __SFI_STORE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfitests.hh b/sfi/sfitests.hh
index 2078319..1a10bcc 100644
--- a/sfi/sfitests.hh
+++ b/sfi/sfitests.hh
@@ -1,10 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_TESTS_H__
#define __SFI_TESTS_H__
-
#include <sfi/sfi.hh>
#include <birnet/birnettests.h>
-
/* --- test initialization --- */
static void BIRNET_UNUSED
sfi_init_test (int *argcp,
@@ -40,7 +38,5 @@ sfi_init_test (int *argcp,
/* check NULL definition, especially for 64bit */
BIRNET_ASSERT (sizeof (NULL) == sizeof (void*));
}
-
#endif /* __SFI_TESTS_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfitime.cc b/sfi/sfitime.cc
index 1bb238d..75cd29f 100644
--- a/sfi/sfitime.cc
+++ b/sfi/sfitime.cc
@@ -8,8 +8,6 @@
#include <time.h>
#include <errno.h>
#include <stdio.h>
-
-
#define SFI_ERROR_DOMAIN g_quark_from_static_string ("sfi-error-domain")
enum {
ERROR_DATE_INVALID = 1,
@@ -21,12 +19,8 @@ enum {
ERROR_DATE_MINUTE_BOUNDS,
ERROR_DATE_SECOND_BOUNDS,
};
-
-
/* --- variables --- */
static SfiTime gmt_diff = 0;
-
-
/* --- functions --- */
void
_sfi_init_time (void)
@@ -35,15 +29,12 @@ _sfi_init_time (void)
struct timeval tv = { 0, };
time_t t;
gint error;
-
g_assert (initialized++ == FALSE);
-
tzset ();
error = gettimeofday (&tv, NULL);
if (error)
g_error ("gettimeofday() failed: %s", g_strerror (errno));
t = tv.tv_sec + tv.tv_usec / 1000000;
-
/* we need to find out the timezone offset relative to GMT here */
#if 0
{ /* aparently FreeBSD/BSD4.3 doesn't have an extern long timezone; set by
@@ -61,10 +52,8 @@ _sfi_init_time (void)
gmt_diff = -tmdata.tm_gmtoff;
}
#endif
-
gmt_diff *= SFI_USEC_FACTOR;
}
-
/**
* @return Current system time in micro seconds
*
@@ -82,14 +71,11 @@ sfi_time_system (void)
{
struct timeval tv;
SfiTime ustime;
-
gettimeofday (&tv, NULL);
ustime = tv.tv_sec;
ustime = ustime * SFI_USEC_FACTOR + tv.tv_usec;
-
return ustime;
}
-
/**
* @param ustime local standard time in micro seconds
* @return UTC relative time in micro seconds
@@ -103,7 +89,6 @@ sfi_time_to_utc (SfiTime ustime)
{
return ustime + gmt_diff;
}
-
/**
* @param ustime UTC relative time in micro seconds
* @return local standard time in micro seconds
@@ -117,7 +102,6 @@ sfi_time_from_utc (SfiTime ustime)
{
return ustime - gmt_diff;
}
-
/**
* @param ustime time in micro seconds
* @return newly allocated string
@@ -131,9 +115,7 @@ sfi_time_to_string (SfiTime ustime)
{
time_t t = CLAMP (ustime, SFI_MIN_TIME, SFI_MAX_TIME) / SFI_USEC_FACTOR;
struct tm bt;
-
bt = *gmtime (&t); /* FIXME: not thread safe */
-
return g_strdup_printf ("%04d-%02d-%02d %02d:%02d:%02d",
bt.tm_year + 1900,
bt.tm_mon + 1,
@@ -142,7 +124,6 @@ sfi_time_to_string (SfiTime ustime)
bt.tm_min,
bt.tm_sec);
}
-
/**
* @param ustime time in micro seconds
* @param elements string identifying time elements
@@ -171,12 +152,9 @@ sfi_time_to_nice_string (SfiTime ustime,
struct tm bt;
if (!elements)
elements = "";
-
bt = *gmtime (&t); /* FIXME: not thread safe */
-
const bool wtime = strchr (elements, 'H') || strchr (elements, 'M') || strchr (elements, 'S');
const bool wdate = strchr (elements, 'd') || strchr (elements, 'm') || strchr (elements, 'y');
-
if (wdate && !wtime)
return g_strdup_printf ("%04d-%02d-%02d",
bt.tm_year + 1900,
@@ -196,7 +174,6 @@ sfi_time_to_nice_string (SfiTime ustime,
bt.tm_mon + 1,
bt.tm_mday);
}
-
/**
* @param time_string string containing human readable date and time
* @return parsed time in micro seconds or 0 on error
@@ -208,7 +185,6 @@ sfi_time_from_string (const gchar *time_string)
{
return sfi_time_from_string_err (time_string, NULL);
}
-
/**
* @param time_string string containing human readable date and time
* @param error_p location for newly allocated string containing conversion errors
@@ -237,9 +213,7 @@ sfi_time_from_string_err (const gchar *time_string,
SfiTime ustime;
SfiRing *ring, *warnings = NULL;
guint i;
-
g_return_val_if_fail (time_string != NULL, 0);
-
/* here, we support several date formats by making several attempts
* to match a string and pick the best one. if we acquire a full match
* before all match possibilities have been tryed, we skip outstanding
@@ -272,19 +246,15 @@ sfi_time_from_string_err (const gchar *time_string,
* more on time formats (ISO 8601) can be found at:
* http://www.cl.cam.ac.uk/~mgk25/iso-time.html
*/
-
string = g_strdup (time_string);
-
for (i = 0; i < n_formats; i++)
{
year[i] = month[i] = day[i] = 0;
hour[i] = minute[i] = second[i] = 0;
success[i] = garbage[i] = FALSE;
}
-
finished = FALSE;
i = 0;
-
#define DATE_CHECK(index) (year[(index)] >= 1990 && \
month[(index)] >= 1 && \
month[(index)] <= 12 && \
@@ -303,7 +273,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u-%u-%u %u:%u:%u%c",
&year[i], &month[i], &day[i],
@@ -318,7 +287,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u-%u-%u %u:%u%c",
@@ -334,7 +302,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u-%u-%u%c",
@@ -346,11 +313,9 @@ sfi_time_from_string_err (const gchar *time_string,
i++;
}
if (!finished) /* parse "mm/dd/yyyy hh:mm:ss" e.g. "04/16/1998 23:59:59" */
-
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u/%u/%u %u:%u:%u%c",
&month[i], &day[i], &year[i],
@@ -365,7 +330,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u/%u/%u %u:%u%c",
@@ -381,7 +345,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u/%u/%u%c",
@@ -396,7 +359,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u.%u.%u %u:%u:%u%c",
&day[i], &month[i], &year[i],
@@ -411,7 +373,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u.%u.%u %u:%u%c",
@@ -427,7 +388,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u.%u.%u%c",
@@ -442,7 +402,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u:%u:%u %u-%u-%u%c",
&hour[i], &minute[i], &second[i],
@@ -457,7 +416,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u:%u %u-%u-%u%c",
@@ -473,7 +431,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u:%u:%u %u/%u/%u%c",
&hour[i], &minute[i], &second[i],
@@ -488,7 +445,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u:%u %u/%u/%u%c",
@@ -504,7 +460,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
n_values = sscanf (string,
"%u:%u:%u %u.%u.%u%c",
&hour[i], &minute[i], &second[i],
@@ -519,7 +474,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
gint n_values;
gchar end_char = 0;
-
second[i] = 0;
n_values = sscanf (string,
"%u:%u %u.%u.%u%c",
@@ -532,7 +486,6 @@ sfi_time_from_string_err (const gchar *time_string,
i++;
}
#undef DATE_CHECK
-
/* try to find out the best/first match if any */
if (finished)
i--;
@@ -542,7 +495,6 @@ sfi_time_from_string_err (const gchar *time_string,
if (success[i])
break;
}
-
if (!success[i])
{
warnings = sfi_ring_append (warnings, g_strdup ("invalid date specification"));
@@ -552,7 +504,6 @@ sfi_time_from_string_err (const gchar *time_string,
{
struct tm tm_data = { 0 };
time_t ttime;
-
if (garbage[i])
warnings = sfi_ring_append (warnings, g_strdup ("junk characters at end of date"));
if (year[i] < 1990)
@@ -585,7 +536,6 @@ sfi_time_from_string_err (const gchar *time_string,
warnings = sfi_ring_append (warnings, g_strdup_printf ("%s out of bounds", "second"));
second[i] = CLAMP (second[i], 0, 61);
}
-
tm_data.tm_sec = second[i];
tm_data.tm_min = minute[i];
tm_data.tm_hour = hour[i];
@@ -595,7 +545,6 @@ sfi_time_from_string_err (const gchar *time_string,
tm_data.tm_wday = 0;
tm_data.tm_yday = 0;
tm_data.tm_isdst = 1;
-
#if HAVE_TIMEGM
ttime = timegm (&tm_data); /* returns -1 on error */
#else
@@ -612,15 +561,12 @@ sfi_time_from_string_err (const gchar *time_string,
g_free (tz);
}
#endif
-
ustime = ttime;
ustime *= SFI_USEC_FACTOR;
ustime = MAX (ustime, 0);
-
/* g_print ("mktime(): year(%u) month(%u) day(%u) hour(%u) minute(%u) second(%u)\n",
* year[i], month[i], day[i], hour[i], minute[i], second[i]);
*/
-
if (ustime < SFI_MIN_TIME) /* limit ustime to 1.1.1990 */
{
warnings = sfi_ring_append (warnings, g_strdup_printf ("invalid date specification (%lld < %lld, gmt-diff=%lld)",
@@ -628,7 +574,6 @@ sfi_time_from_string_err (const gchar *time_string,
ustime = SFI_MIN_TIME;
}
}
-
/* general cleanup and error return */
g_free (string);
if (error_p && warnings)
diff --git a/sfi/sfitime.hh b/sfi/sfitime.hh
index b6f31a4..22adf2b 100644
--- a/sfi/sfitime.hh
+++ b/sfi/sfitime.hh
@@ -1,17 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_TIME_H__
#define __SFI_TIME_H__
-
#include <sfi/sfivalues.hh>
-
G_BEGIN_DECLS
-
/* --- time (unix micro seconds) --- */
#define SFI_USEC_FACTOR ((SfiTime) 1000000) /* 64bit wide */
#define SFI_MIN_TIME (631152000 * SFI_USEC_FACTOR) /* 1990-01-01 00:00:00 UTC */
#define SFI_MAX_TIME (2147483647 * SFI_USEC_FACTOR) /* 2038-01-19 03:14:07 UTC */
-
-
/* --- functions --- */
SfiTime sfi_time_system (void); /* utc */
SfiTime sfi_time_to_utc (SfiTime ustime);
@@ -22,14 +17,8 @@ gchar* sfi_time_to_nice_string (SfiTime ustime,
SfiTime sfi_time_from_string (const gchar *time_string);
SfiTime sfi_time_from_string_err (const gchar *time_string,
gchar **error_p);
-
-
/* --- internal --- */
void _sfi_init_time (void);
-
-
G_END_DECLS
-
#endif /* __SFI_TIME_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfitypes.cc b/sfi/sfitypes.cc
index da35a5d..4d76eb2 100644
--- a/sfi/sfitypes.cc
+++ b/sfi/sfitypes.cc
@@ -7,14 +7,8 @@
#include "sfiglue.hh"
#include "sfifilecrawler.hh"
#include <string.h>
-
-
-
/* --- variables --- */
-
-
/* --- functions --- */
-
/* --- FIXME: hacks! */
void
sfi_set_error (GError **errorp,
@@ -34,7 +28,6 @@ sfi_set_error (GError **errorp,
va_end (args);
}
}
-
static inline gchar
char_canon (gchar c)
{
@@ -47,12 +40,10 @@ char_canon (gchar c)
else
return '-';
}
-
gchar*
sfi_strdup_canon (const gchar *identifier)
{
gchar *str = g_strdup (identifier);
-
if (str)
{
gchar *p;
@@ -61,7 +52,6 @@ sfi_strdup_canon (const gchar *identifier)
}
return str;
}
-
static inline gboolean
eval_match (const gchar *str1,
const gchar *str2)
@@ -75,9 +65,7 @@ eval_match (const gchar *str1,
}
return *str1 == 0 && *str2 == 0;
}
-
#define isalnum(c) ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
-
gboolean
sfi_choice_match_detailed (const gchar *choice_val1,
const gchar *choice_val2,
@@ -85,7 +73,6 @@ sfi_choice_match_detailed (const gchar *choice_val1,
{
g_return_val_if_fail (choice_val1 != NULL, FALSE);
g_return_val_if_fail (choice_val2 != NULL, FALSE);
-
guint l1 = strlen (choice_val1);
guint l2 = strlen (choice_val2);
if (l1_ge_l2 && l1 < l2)
@@ -108,14 +95,12 @@ sfi_choice_match_detailed (const gchar *choice_val1,
}
return cv2[0] && eval_match (cv1, cv2);
}
-
gboolean
sfi_choice_match (const gchar *choice_val1,
const gchar *choice_val2)
{
return sfi_choice_match_detailed (choice_val1, choice_val2, FALSE);
}
-
static inline gint
consts_rmatch (guint l1,
const gchar *str1,
@@ -131,7 +116,6 @@ consts_rmatch (guint l1,
}
return 0; /* missing out the length check here which normal strcmp() does */
}
-
guint
sfi_constants_get_index (guint n_consts,
const SfiConstants *rsorted_consts,
@@ -140,15 +124,12 @@ sfi_constants_get_index (guint n_consts,
guint l, offs, order, n_nodes = n_consts;
gchar *key;
gint i, cmp;
-
g_return_val_if_fail (constant != NULL, 0);
-
/* canonicalize key */
l = strlen (constant);
key = g_new (gchar, l);
for (offs = 0; offs < l; offs++)
key[offs] = char_canon (constant[offs]);
-
/* perform binary search with chopped tail match */
offs = 0;
while (offs < n_nodes)
@@ -165,7 +146,6 @@ sfi_constants_get_index (guint n_consts,
/* no match */
g_free (key);
return 0;
-
/* explore neighboured matches and favour early indices */
have_match:
offs = i;
@@ -185,29 +165,24 @@ sfi_constants_get_index (guint n_consts,
g_free (key);
return order;
}
-
const gchar*
sfi_constants_get_name (guint n_consts,
const SfiConstants *consts,
guint index)
{
guint i;
-
for (i = 0; i < n_consts; i++)
if (consts[i].index == index)
return consts[i].name;
return NULL;
}
-
gint
sfi_constants_rcmp (const gchar *canon_identifier1,
const gchar *canon_identifier2)
{
gint cmp, l1, l2;
-
g_return_val_if_fail (canon_identifier1 != NULL, 0);
g_return_val_if_fail (canon_identifier2 != NULL, 0);
-
l1 = strlen (canon_identifier1);
l2 = strlen (canon_identifier2);
cmp = consts_rmatch (l1, canon_identifier1, l2, canon_identifier2);
@@ -215,7 +190,6 @@ sfi_constants_rcmp (const gchar *canon_identifier1,
return l1 - l2;
return cmp;
}
-
const char*
sfi_category_concat (const char *prefix,
const char *trunk)
diff --git a/sfi/sfitypes.hh b/sfi/sfitypes.hh
index 83ef35f..ad7a89a 100644
--- a/sfi/sfitypes.hh
+++ b/sfi/sfitypes.hh
@@ -1,12 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_TYPES_H__
#define __SFI_TYPES_H__
-
#include <sfi/glib-extra.hh>
#include <sfi/sfiwrapper.hh>
-
G_BEGIN_DECLS
-
/* --- Sfi typedefs --- */
typedef bool SfiBool;
typedef gint SfiInt;
@@ -34,7 +31,6 @@ typedef struct {
typedef struct _SfiUStore SfiUStore;
typedef struct _SfiUPool SfiUPool;
typedef struct _SfiPPool SfiPPool;
-
/* --- FIXME: hacks! --- */
void sfi_set_error (GError **errorp, // do nothing if *errorp is set already
GQuark domain,
@@ -47,13 +43,11 @@ gboolean sfi_choice_match_detailed (const gchar *choice_val1,
gboolean sfi_choice_match (const gchar *choice_val1,
const gchar *choice_val2);
gchar* sfi_strdup_canon (const gchar *identifier);
-
typedef struct {
const gchar *name;
guint name_length;
guint index;
} SfiConstants;
-
guint sfi_constants_get_index (guint n_consts,
const SfiConstants *rsorted_consts,
const gchar *constant);
@@ -64,17 +58,12 @@ gint sfi_constants_rcmp (const gchar *canon_identifier1,
const gchar *canon_identifier2);
const char* sfi_category_concat (const char *prefix,
const char *trunk);
-
/* --- idl macro magic --- */
#define SFI_START_ARGS() (
#define SFI_END_ARGS() )
#define SFI_END_ARGS1(a) a)
#define SFI_END_ARGS2(a,b) a , b)
#define SFI_END_ARGS3(a,b,c) a , b , c)
-
-
G_END_DECLS
-
#endif /* __SFI_TYPES_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiustore.cc b/sfi/sfiustore.cc
index c6629af..d8e6a82 100644
--- a/sfi/sfiustore.cc
+++ b/sfi/sfiustore.cc
@@ -1,7 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "sfiustore.hh"
#include "sfimemory.hh"
-
/* --- strcutures --- */
static inline SfiUStore*
scast (register GTree *tree)
@@ -13,8 +12,6 @@ tcast (register SfiUStore *store)
{
return (GTree*) store;
}
-
-
/* --- unique ID store --- */
static gint
ustore_cmp (gconstpointer a,
@@ -24,51 +21,41 @@ ustore_cmp (gconstpointer a,
gulong u2 = (gulong) b;
return u1 < u2 ? -1 : u1 != u2;
}
-
SfiUStore*
sfi_ustore_new (void)
{
SfiUStore *store = scast (g_tree_new (ustore_cmp));
-
return store;
}
-
gpointer
sfi_ustore_lookup (SfiUStore *store,
gulong unique_id)
{
g_return_val_if_fail (store != NULL, NULL);
-
return g_tree_lookup (tcast (store), (gpointer) unique_id);
}
-
void
sfi_ustore_insert (SfiUStore *store,
gulong unique_id,
gpointer value)
{
g_return_if_fail (store != NULL);
-
if (!value)
g_tree_remove (tcast (store), (gpointer) unique_id);
else
g_tree_insert (tcast (store), (gpointer) unique_id, value);
}
-
void
sfi_ustore_remove (SfiUStore *store,
gulong unique_id)
{
g_return_if_fail (store != NULL);
-
g_tree_remove (tcast (store), (gpointer) unique_id);
}
-
typedef struct {
gpointer data;
SfiUStoreForeach foreach;
} FData;
-
static gboolean
foreach_wrapper (gpointer key,
gpointer value,
@@ -78,71 +65,58 @@ foreach_wrapper (gpointer key,
/* iterate as long as SfiUStoreForeach() returns TRUE */
return !fdata->foreach (fdata->data, (gulong) key, value);
}
-
void
sfi_ustore_foreach (SfiUStore *store,
SfiUStoreForeach foreach,
gpointer data)
{
FData fdata;
-
g_return_if_fail (store != NULL);
-
fdata.data = data;
fdata.foreach = foreach;
g_tree_foreach (tcast (store), foreach_wrapper, &fdata);
}
-
void
sfi_ustore_destroy (SfiUStore *store)
{
g_return_if_fail (store != NULL);
-
g_tree_destroy (tcast (store));
}
-
/* --- unique ID pool --- */
#define UPOOL_TAG ((gpointer) sfi_upool_new)
-
static inline SfiUPool*
upool_cast (register SfiUStore *ustore)
{
return (SfiUPool*) ustore;
}
-
static inline SfiUStore*
ustore_cast (register SfiUPool *upool)
{
return (SfiUStore*) upool;
}
-
SfiUPool*
sfi_upool_new (void)
{
return upool_cast (sfi_ustore_new ());
}
-
gboolean
sfi_upool_lookup (SfiUPool *pool,
gulong unique_id)
{
return sfi_ustore_lookup (ustore_cast (pool), unique_id) != NULL;
}
-
void
sfi_upool_set (SfiUPool *pool,
gulong unique_id)
{
sfi_ustore_insert (ustore_cast (pool), unique_id, UPOOL_TAG);
}
-
void
sfi_upool_unset (SfiUPool *pool,
gulong unique_id)
{
sfi_ustore_remove (ustore_cast (pool), unique_id);
}
-
void
sfi_upool_foreach (SfiUPool *pool,
SfiUPoolForeach foreach,
@@ -150,13 +124,11 @@ sfi_upool_foreach (SfiUPool *pool,
{
sfi_ustore_foreach (ustore_cast (pool), (SfiUStoreForeach) foreach, data);
}
-
typedef struct {
guint capacity;
guint n_ids;
gulong *ids;
} UPoolList;
-
static gboolean
upool_enlist (gpointer data,
gulong unique_id)
@@ -171,7 +143,6 @@ upool_enlist (gpointer data,
list->ids[i] = unique_id;
return TRUE;
}
-
gulong*
sfi_upool_list (SfiUPool *pool,
guint *n_ids)
@@ -182,29 +153,23 @@ sfi_upool_list (SfiUPool *pool,
*n_ids = list.n_ids;
return list.ids;
}
-
void
sfi_upool_destroy (SfiUPool *pool)
{
sfi_ustore_destroy (ustore_cast (pool));
}
-
-
/* --- pointer pool --- */
#define PPOOL_TAG ((gpointer) sfi_ppool_new)
-
static inline SfiPPool*
ppool_cast (register GTree *tree)
{
return (SfiPPool*) tree;
}
-
static inline GTree*
ppool_tree (register SfiPPool *pool)
{
return (GTree*) pool;
}
-
static gint
ppool_cmp (gconstpointer a,
gconstpointer b)
@@ -213,13 +178,11 @@ ppool_cmp (gconstpointer a,
const char *c2 = (const char*) b;
return c1 < c2 ? -1 : c1 != c2;
}
-
SfiPPool*
sfi_ppool_new (void)
{
return ppool_cast (g_tree_new (ppool_cmp));
}
-
gboolean
sfi_ppool_lookup (SfiPPool *pool,
gpointer unique_ptr)
@@ -227,7 +190,6 @@ sfi_ppool_lookup (SfiPPool *pool,
g_return_val_if_fail (pool != NULL, FALSE);
return g_tree_lookup (ppool_tree (pool), unique_ptr) != NULL;
}
-
void
sfi_ppool_set (SfiPPool *pool,
gpointer unique_ptr)
@@ -235,7 +197,6 @@ sfi_ppool_set (SfiPPool *pool,
g_return_if_fail (pool != NULL);
g_tree_insert (ppool_tree (pool), unique_ptr, PPOOL_TAG);
}
-
void
sfi_ppool_unset (SfiPPool *pool,
gpointer unique_ptr)
@@ -243,12 +204,10 @@ sfi_ppool_unset (SfiPPool *pool,
g_return_if_fail (pool != NULL);
g_tree_remove (ppool_tree (pool), unique_ptr);
}
-
typedef struct {
gpointer data;
SfiPPoolForeach foreach;
} PPoolData;
-
static gboolean
ppool_foreach_wrapper (gpointer key,
gpointer value,
@@ -258,7 +217,6 @@ ppool_foreach_wrapper (gpointer key,
/* iterate as long as SfiPPoolForeach() returns TRUE */
return !pdata->foreach (pdata->data, key);
}
-
void
sfi_ppool_foreach (SfiPPool *pool,
SfiPPoolForeach foreach,
@@ -270,7 +228,6 @@ sfi_ppool_foreach (SfiPPool *pool,
pdata.foreach = foreach;
g_tree_foreach (ppool_tree (pool), ppool_foreach_wrapper, &pdata);
}
-
static gboolean
ppool_foreach_slist (gpointer key,
gpointer value,
@@ -280,7 +237,6 @@ ppool_foreach_slist (gpointer key,
*slist_p = g_slist_prepend (*slist_p, key);
return FALSE; /* always continue */
}
-
GSList*
sfi_ppool_slist (SfiPPool *pool)
{
@@ -289,7 +245,6 @@ sfi_ppool_slist (SfiPPool *pool)
g_tree_foreach (ppool_tree (pool), ppool_foreach_slist, &slist);
return slist;
}
-
void
sfi_ppool_destroy (SfiPPool *pool)
{
diff --git a/sfi/sfiustore.hh b/sfi/sfiustore.hh
index 1aabe4d..a14d5b7 100644
--- a/sfi/sfiustore.hh
+++ b/sfi/sfiustore.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_USTORE_H__
#define __SFI_USTORE_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS
-
-
/* --- typedefs --- */
/* typedef struct _SfiUStore SfiUStore; */
/* typedef struct _SfiUPool SfiUPool; */
@@ -17,8 +13,6 @@ typedef gboolean (*SfiUPoolForeach) (gpointer data,
gulong unique_id);
typedef gboolean (*SfiPPoolForeach) (gpointer data,
gpointer pointer);
-
-
/* --- unique ID store --- */
SfiUStore* sfi_ustore_new (void);
gpointer sfi_ustore_lookup (SfiUStore *store,
@@ -32,8 +26,6 @@ void sfi_ustore_foreach (SfiUStore *store,
SfiUStoreForeach foreach,
gpointer data);
void sfi_ustore_destroy (SfiUStore *store);
-
-
/* --- unique ID pool --- */
SfiUPool* sfi_upool_new (void);
gboolean sfi_upool_lookup (SfiUPool *pool,
@@ -48,8 +40,6 @@ void sfi_upool_foreach (SfiUPool *pool,
void sfi_upool_destroy (SfiUPool *pool);
gulong* sfi_upool_list (SfiUPool *pool,
guint *n_ids);
-
-
/* --- pointer pool --- */
SfiPPool* sfi_ppool_new (void);
gboolean sfi_ppool_lookup (SfiPPool *pool,
@@ -63,11 +53,6 @@ void sfi_ppool_foreach (SfiPPool *pool,
gpointer data);
GSList* sfi_ppool_slist (SfiPPool *pool);
void sfi_ppool_destroy (SfiPPool *pool);
-
-
-
G_END_DECLS
-
#endif /* __SFI_USTORE_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfivalues.cc b/sfi/sfivalues.cc
index 42cdaf9..1b22326 100644
--- a/sfi/sfivalues.cc
+++ b/sfi/sfivalues.cc
@@ -3,12 +3,8 @@
#include "sfiprimitives.hh"
#include "sfiparams.hh"
#include "sfimemory.hh"
-
-
/* --- variables --- */
GType *sfi__value_types = NULL;
-
-
/* --- functions --- */
static gpointer
copy_seq (gpointer boxed)
@@ -16,7 +12,6 @@ copy_seq (gpointer boxed)
SfiSeq *seq = (SfiSeq*) boxed;
return seq ? sfi_seq_ref (seq) : NULL;
}
-
static void
free_seq (gpointer boxed)
{
@@ -24,14 +19,12 @@ free_seq (gpointer boxed)
if (seq)
sfi_seq_unref (seq);
}
-
static gpointer
copy_rec (gpointer boxed)
{
SfiRec *rec = (SfiRec*) boxed;
return rec ? sfi_rec_ref (rec) : NULL;
}
-
static void
free_rec (gpointer boxed)
{
@@ -39,14 +32,12 @@ free_rec (gpointer boxed)
if (rec)
sfi_rec_unref (rec);
}
-
static gpointer
copy_bblock (gpointer boxed)
{
SfiBBlock *bblock = (SfiBBlock*) boxed;
return bblock ? sfi_bblock_ref (bblock) : NULL;
}
-
static void
free_bblock (gpointer boxed)
{
@@ -54,14 +45,12 @@ free_bblock (gpointer boxed)
if (bblock)
sfi_bblock_unref (bblock);
}
-
static gpointer
copy_fblock (gpointer boxed)
{
SfiFBlock *fblock = (SfiFBlock*) boxed;
return fblock ? sfi_fblock_ref (fblock) : NULL;
}
-
static void
free_fblock (gpointer boxed)
{
@@ -69,7 +58,6 @@ free_fblock (gpointer boxed)
if (fblock)
sfi_fblock_unref (fblock);
}
-
void
_sfi_init_values (void)
{
@@ -85,11 +73,8 @@ _sfi_init_values (void)
NULL, /* instance_init */
};
static GType value_types[6] = { 0, };
-
g_assert (sfi__value_types == NULL);
-
sfi__value_types = value_types;
-
/* value types */
SFI_TYPE_CHOICE = g_type_register_static (G_TYPE_STRING, "SfiChoice", &info, GTypeFlags (0));
SFI_TYPE_BBLOCK = g_boxed_type_register_static ("SfiBBlock", copy_bblock, free_bblock);
@@ -98,8 +83,6 @@ _sfi_init_values (void)
SFI_TYPE_REC = g_boxed_type_register_static ("SfiRec", copy_rec, free_rec);
SFI_TYPE_PROXY = g_pointer_type_register_static ("SfiProxy");
}
-
-
/* --- GValue functions --- */
gboolean
sfi_check_value (const GValue *value)
@@ -134,165 +117,127 @@ sfi_check_value (const GValue *value)
else
return (vtype == SFI_TYPE_PROXY);
}
-
const char*
sfi_value_get_choice (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_CHOICE (value), NULL);
-
return g_value_get_string (value);
}
-
void
sfi_value_set_choice (GValue *value,
const gchar *choice_value)
{
g_return_if_fail (SFI_VALUE_HOLDS_CHOICE (value));
-
g_value_set_string (value, choice_value);
}
-
SfiBBlock*
sfi_value_get_bblock (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_BBLOCK (value), NULL);
-
return (SfiBBlock*) g_value_get_boxed (value);
}
-
SfiBBlock*
sfi_value_dup_bblock (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_BBLOCK (value), NULL);
-
SfiBBlock *bblock = (SfiBBlock*) g_value_get_boxed (value);
return bblock ? sfi_bblock_ref (bblock) : NULL;
}
-
void
sfi_value_set_bblock (GValue *value,
SfiBBlock *bblock)
{
g_return_if_fail (SFI_VALUE_HOLDS_BBLOCK (value));
-
g_value_set_boxed (value, bblock);
}
-
void
sfi_value_take_bblock (GValue *value,
SfiBBlock *bblock)
{
g_return_if_fail (SFI_VALUE_HOLDS_BBLOCK (value));
-
g_value_take_boxed (value, bblock);
}
-
SfiFBlock*
sfi_value_get_fblock (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_FBLOCK (value), NULL);
-
return (SfiFBlock*) g_value_get_boxed (value);
}
-
SfiFBlock*
sfi_value_dup_fblock (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_FBLOCK (value), NULL);
-
SfiFBlock *fblock = (SfiFBlock*) g_value_get_boxed (value);
return fblock ? sfi_fblock_ref (fblock) : NULL;
}
-
void
sfi_value_set_fblock (GValue *value,
SfiFBlock *fblock)
{
g_return_if_fail (SFI_VALUE_HOLDS_FBLOCK (value));
-
g_value_set_boxed (value, fblock);
}
-
void
sfi_value_take_fblock (GValue *value,
SfiFBlock *fblock)
{
g_return_if_fail (SFI_VALUE_HOLDS_FBLOCK (value));
-
g_value_take_boxed (value, fblock);
}
-
GParamSpec*
sfi_value_get_pspec (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_PSPEC (value), NULL);
-
return g_value_get_param (value);
}
-
GParamSpec*
sfi_value_dup_pspec (const GValue *value)
{
GParamSpec *pspec;
-
g_return_val_if_fail (SFI_VALUE_HOLDS_PSPEC (value), NULL);
-
pspec = g_value_get_param (value);
return pspec ? sfi_pspec_ref (pspec) : NULL;
}
-
void
sfi_value_set_pspec (GValue *value,
GParamSpec *pspec)
{
g_return_if_fail (SFI_VALUE_HOLDS_PSPEC (value));
-
g_value_set_param (value, pspec);
}
-
void
sfi_value_take_pspec (GValue *value,
GParamSpec *pspec)
{
g_return_if_fail (SFI_VALUE_HOLDS_PSPEC (value));
-
g_value_set_param_take_ownership (value, pspec);
}
-
SfiSeq*
sfi_value_get_seq (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_SEQ (value), NULL);
-
return (SfiSeq*) g_value_get_boxed (value);
}
-
void
sfi_value_set_seq (GValue *value,
SfiSeq *seq)
{
g_return_if_fail (SFI_VALUE_HOLDS_SEQ (value));
-
g_value_set_boxed (value, seq);
}
-
void
sfi_value_take_seq (GValue *value,
SfiSeq *seq)
{
g_return_if_fail (SFI_VALUE_HOLDS_SEQ (value));
-
g_value_take_boxed (value, seq);
}
-
SfiRec*
sfi_value_get_rec (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_REC (value), NULL);
-
return (SfiRec*) g_value_get_boxed (value);
}
-
SfiRec*
sfi_value_dup_rec (const GValue *value)
{
@@ -300,49 +245,39 @@ sfi_value_dup_rec (const GValue *value)
SfiRec *rec = (SfiRec*) g_value_get_boxed (value);
return rec ? sfi_rec_ref (rec) : NULL;
}
-
void
sfi_value_set_rec (GValue *value,
SfiRec *rec)
{
g_return_if_fail (SFI_VALUE_HOLDS_REC (value));
-
g_value_set_boxed (value, rec);
}
-
void
sfi_value_take_rec (GValue *value,
SfiRec *rec)
{
g_return_if_fail (SFI_VALUE_HOLDS_REC (value));
-
g_value_take_boxed (value, rec);
}
-
SfiProxy
sfi_value_get_proxy (const GValue *value)
{
g_return_val_if_fail (SFI_VALUE_HOLDS_PROXY (value), 0);
-
return (SfiProxy) g_value_get_pointer (value);
}
-
void
sfi_value_set_proxy (GValue *value,
SfiProxy proxy)
{
g_return_if_fail (SFI_VALUE_HOLDS_PROXY (value));
-
g_value_set_pointer (value, (gpointer) proxy);
}
-
void
sfi_value_copy_deep (const GValue *src_value,
GValue *dest_value)
{
g_return_if_fail (G_IS_VALUE (src_value));
g_return_if_fail (G_IS_VALUE (dest_value));
-
SfiSCategory scat = SfiSCategory (sfi_categorize_type (G_VALUE_TYPE (src_value)) & SFI_SCAT_TYPE_MASK);
switch (scat)
{
@@ -382,8 +317,6 @@ sfi_value_copy_deep (const GValue *src_value,
g_value_copy (src_value, dest_value);
}
}
-
-
/* --- Sfi value constructors --- */
static GValue*
alloc_value (GType type)
@@ -393,7 +326,6 @@ alloc_value (GType type)
g_value_init (value, type);
return value;
}
-
void
sfi_value_free (GValue *value)
{
@@ -402,21 +334,17 @@ sfi_value_free (GValue *value)
g_value_unset (value);
sfi_delete_struct (GValue, value);
}
-
GValue*
sfi_value_empty (void)
{
GValue *value = alloc_value (0);
return value;
}
-
GValue*
sfi_value_clone_deep (const GValue *value)
{
GValue *dest;
-
g_return_val_if_fail (value != NULL, NULL);
-
dest = sfi_value_empty ();
if (G_IS_VALUE (value))
{
@@ -425,14 +353,11 @@ sfi_value_clone_deep (const GValue *value)
}
return dest;
}
-
GValue*
sfi_value_clone_shallow (const GValue *value)
{
GValue *dest;
-
g_return_val_if_fail (value != NULL, NULL);
-
dest = sfi_value_empty ();
if (G_IS_VALUE (value))
{
@@ -441,7 +366,6 @@ sfi_value_clone_shallow (const GValue *value)
}
return dest;
}
-
GValue*
sfi_value_bool (SfiBool vbool)
{
@@ -449,7 +373,6 @@ sfi_value_bool (SfiBool vbool)
sfi_value_set_bool (value, vbool);
return value;
}
-
GValue*
sfi_value_int (SfiInt vint)
{
@@ -457,7 +380,6 @@ sfi_value_int (SfiInt vint)
sfi_value_set_int (value, vint);
return value;
}
-
GValue*
sfi_value_num (SfiNum vnum)
{
@@ -465,7 +387,6 @@ sfi_value_num (SfiNum vnum)
sfi_value_set_num (value, vnum);
return value;
}
-
GValue*
sfi_value_real (SfiReal vreal)
{
@@ -473,7 +394,6 @@ sfi_value_real (SfiReal vreal)
sfi_value_set_real (value, vreal);
return value;
}
-
GValue*
sfi_value_string (const gchar *vstring)
{
@@ -481,7 +401,6 @@ sfi_value_string (const gchar *vstring)
sfi_value_set_string (value, vstring);
return value;
}
-
GValue*
sfi_value_lstring (const gchar *vstring,
guint length)
@@ -490,7 +409,6 @@ sfi_value_lstring (const gchar *vstring,
sfi_value_take_string (value, g_strndup (vstring, vstring ? length : 0));
return value;
}
-
GValue*
sfi_value_choice (const gchar *vchoice)
{
@@ -498,7 +416,6 @@ sfi_value_choice (const gchar *vchoice)
sfi_value_set_choice (value, vchoice);
return value;
}
-
GValue*
sfi_value_lchoice (const gchar *vchoice,
guint length)
@@ -507,29 +424,23 @@ sfi_value_lchoice (const gchar *vchoice,
sfi_value_take_string (value, g_strndup (vchoice, vchoice ? length : 0));
return value;
}
-
GValue*
sfi_value_choice_enum (const GValue *enum_value)
{
g_return_val_if_fail (G_VALUE_HOLDS_ENUM (enum_value), NULL);
-
GEnumClass *eclass = (GEnumClass*) g_type_class_ref (G_VALUE_TYPE (enum_value));
GEnumValue *ev = g_enum_get_value (eclass, g_value_get_enum (enum_value));
GValue *value = sfi_value_choice (ev ? ev->value_name : NULL);
g_type_class_unref (eclass);
return value;
}
-
GValue*
sfi_value_choice_genum (gint enum_value, GType enum_type)
{
const gchar *choice;
-
choice = sfi_enum2choice (enum_value, enum_type);
return sfi_value_choice (choice);
}
-
-
GValue*
sfi_value_bblock (SfiBBlock *vbblock)
{
@@ -537,7 +448,6 @@ sfi_value_bblock (SfiBBlock *vbblock)
sfi_value_set_bblock (value, vbblock);
return value;
}
-
GValue*
sfi_value_fblock (SfiFBlock *vfblock)
{
@@ -545,7 +455,6 @@ sfi_value_fblock (SfiFBlock *vfblock)
sfi_value_set_fblock (value, vfblock);
return value;
}
-
GValue*
sfi_value_pspec (GParamSpec *pspec)
{
@@ -553,7 +462,6 @@ sfi_value_pspec (GParamSpec *pspec)
sfi_value_set_pspec (value, pspec);
return value;
}
-
GValue*
sfi_value_seq (SfiSeq *vseq)
{
@@ -561,7 +469,6 @@ sfi_value_seq (SfiSeq *vseq)
sfi_value_set_seq (value, vseq);
return value;
}
-
GValue*
sfi_value_new_take_seq (SfiSeq *vseq)
{
@@ -571,7 +478,6 @@ sfi_value_new_take_seq (SfiSeq *vseq)
sfi_seq_unref (vseq);
return value;
}
-
GValue*
sfi_value_rec (SfiRec *vrec)
{
@@ -579,7 +485,6 @@ sfi_value_rec (SfiRec *vrec)
sfi_value_set_rec (value, vrec);
return value;
}
-
GValue*
sfi_value_new_take_rec (SfiRec *vrec)
{
@@ -589,7 +494,6 @@ sfi_value_new_take_rec (SfiRec *vrec)
sfi_rec_unref (vrec);
return value;
}
-
GValue*
sfi_value_proxy (SfiProxy vproxy)
{
@@ -597,8 +501,6 @@ sfi_value_proxy (SfiProxy vproxy)
sfi_value_set_proxy (value, vproxy);
return value;
}
-
-
/* --- transformation --- */
void
sfi_value_choice2enum_simple (const GValue *choice_value,
@@ -606,7 +508,6 @@ sfi_value_choice2enum_simple (const GValue *choice_value,
{
return sfi_value_choice2enum (choice_value, enum_value, NULL);
}
-
void
sfi_value_choice2enum (const GValue *choice_value,
GValue *enum_value,
@@ -615,7 +516,6 @@ sfi_value_choice2enum (const GValue *choice_value,
GEnumValue *ev = NULL;
const char *eval;
uint i;
-
g_return_if_fail (SFI_VALUE_HOLDS_CHOICE (choice_value));
g_return_if_fail (G_VALUE_HOLDS_ENUM (enum_value));
if (fallback_param)
@@ -623,7 +523,6 @@ sfi_value_choice2enum (const GValue *choice_value,
g_return_if_fail (G_IS_PARAM_SPEC_ENUM (fallback_param));
g_return_if_fail (G_VALUE_HOLDS (enum_value, G_PARAM_SPEC_VALUE_TYPE (fallback_param)));
}
-
GEnumClass *eclass = (GEnumClass*) g_type_class_ref (G_VALUE_TYPE (enum_value));
eval = sfi_value_get_choice (choice_value);
if (eval)
@@ -646,7 +545,6 @@ sfi_value_choice2enum (const GValue *choice_value,
g_value_set_enum (enum_value, 0);
g_type_class_unref (eclass);
}
-
static inline gchar*
to_sname (gchar *str)
{
@@ -662,14 +560,12 @@ to_sname (gchar *str)
*s = '-';
return str;
}
-
void
sfi_value_enum2choice (const GValue *enum_value,
GValue *choice_value)
{
g_return_if_fail (SFI_VALUE_HOLDS_CHOICE (choice_value));
g_return_if_fail (G_VALUE_HOLDS_ENUM (enum_value));
-
GEnumClass *eclass = (GEnumClass*) g_type_class_ref (G_VALUE_TYPE (enum_value));
GEnumValue *ev = g_enum_get_value (eclass, g_value_get_enum (enum_value));
if (!ev)
@@ -679,7 +575,6 @@ sfi_value_enum2choice (const GValue *enum_value,
g_free (sname);
g_type_class_unref (eclass);
}
-
gint
sfi_choice2enum_checked (const gchar *choice_value,
GType enum_type,
@@ -688,7 +583,6 @@ sfi_choice2enum_checked (const gchar *choice_value,
GEnumValue *ev = NULL;
guint i;
gint enum_value;
-
GEnumClass *eclass = (GEnumClass*) g_type_class_ref (enum_type);
if (choice_value)
for (i = 0; i < eclass->n_values; i++)
@@ -704,17 +598,14 @@ sfi_choice2enum_checked (const gchar *choice_value,
g_type_name (enum_type), choice_value ? choice_value : "<NULL>");
enum_value = ev ? ev->value : 0;
g_type_class_unref (eclass);
-
return enum_value;
}
-
gint
sfi_choice2enum (const gchar *choice_value,
GType enum_type)
{
return sfi_choice2enum_checked (choice_value, enum_type, NULL);
}
-
const gchar*
sfi_enum2choice (gint enum_value,
GType enum_type)
@@ -722,7 +613,6 @@ sfi_enum2choice (gint enum_value,
GEnumValue *ev;
const gchar *choice;
gchar *cident;
-
GEnumClass *eclass = (GEnumClass*) g_type_class_ref (enum_type);
ev = g_enum_get_value (eclass, enum_value);
if (!ev)
@@ -731,10 +621,8 @@ sfi_enum2choice (gint enum_value,
choice = g_intern_string (cident);
g_free (cident);
g_type_class_unref (eclass);
-
return choice;
}
-
gint
sfi_value_get_enum_auto (GType enum_type,
const GValue *value)
@@ -744,7 +632,6 @@ sfi_value_get_enum_auto (GType enum_type,
else
return g_value_get_enum (value);
}
-
void
sfi_value_set_enum_auto (GType enum_type,
GValue *value,
@@ -755,7 +642,6 @@ sfi_value_set_enum_auto (GType enum_type,
else
g_value_set_enum (value, enum_value);
}
-
/* transform function to work around glib bugs */
gboolean
sfi_value_type_compatible (GType src_type,
@@ -763,7 +649,6 @@ sfi_value_type_compatible (GType src_type,
{
return g_value_type_compatible (src_type, dest_type);
}
-
gboolean
sfi_value_type_transformable (GType src_type,
GType dest_type)
@@ -776,7 +661,6 @@ sfi_value_type_transformable (GType src_type,
return TRUE;
return FALSE;
}
-
gboolean
sfi_value_transform (const GValue *src_value,
GValue *dest_value)
diff --git a/sfi/sfivalues.hh b/sfi/sfivalues.hh
index b3eb057..a5cba27 100644
--- a/sfi/sfivalues.hh
+++ b/sfi/sfivalues.hh
@@ -1,12 +1,8 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_VALUES_H__
#define __SFI_VALUES_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS
-
-
/* --- Sfi value type aliases --- */
#define SFI_TYPE_BOOL G_TYPE_BOOLEAN
#define SFI_TYPE_INT G_TYPE_INT
@@ -14,8 +10,6 @@ G_BEGIN_DECLS
#define SFI_TYPE_REAL G_TYPE_DOUBLE
#define SFI_TYPE_STRING G_TYPE_STRING
#define SFI_TYPE_PSPEC G_TYPE_PARAM
-
-
/* --- Sfi value types --- */
#define SFI_TYPE_CHOICE (sfi__value_types[0])
#define SFI_TYPE_BBLOCK (sfi__value_types[1])
@@ -23,8 +17,6 @@ G_BEGIN_DECLS
#define SFI_TYPE_SEQ (sfi__value_types[3])
#define SFI_TYPE_REC (sfi__value_types[4])
#define SFI_TYPE_PROXY (sfi__value_types[5])
-
-
/* --- Sfi value macros --- */
#define SFI_IS_VALUE(value) (sfi_check_value (value))
#define SFI_VALUE_HOLDS_BOOL(value) (G_TYPE_CHECK_VALUE_TYPE ((value), SFI_TYPE_BOOL))
@@ -39,8 +31,6 @@ G_BEGIN_DECLS
#define SFI_VALUE_HOLDS_SEQ(value) (G_TYPE_CHECK_VALUE_TYPE ((value), SFI_TYPE_SEQ))
#define SFI_VALUE_HOLDS_REC(value) (G_TYPE_CHECK_VALUE_TYPE ((value), SFI_TYPE_REC))
#define SFI_VALUE_HOLDS_PROXY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), SFI_TYPE_PROXY))
-
-
/* --- Sfi value accessor aliases --- */
#define sfi_value_get_bool g_value_get_boolean
#define sfi_value_set_bool g_value_set_boolean
@@ -55,8 +45,6 @@ G_BEGIN_DECLS
#define sfi_value_dup_string g_value_dup_string
#define sfi_value_set_static_string g_value_set_static_string
#define sfi_value_take_string g_value_take_string
-
-
/* --- Sfi value accessors --- */
const char* sfi_value_get_choice (const GValue *value);
void sfi_value_set_choice (GValue *value,
@@ -96,8 +84,6 @@ void sfi_value_set_proxy (GValue *value,
void sfi_value_copy_deep (const GValue *src_value,
GValue *dest_value);
#define sfi_value_copy_shallow g_value_copy
-
-
/* --- Sfi value constructors --- */
GValue* sfi_value_empty (void);
GValue* sfi_value_clone_deep (const GValue *value);
@@ -124,8 +110,6 @@ GValue* sfi_value_rec (SfiRec *vrec);
GValue* sfi_value_new_take_rec (SfiRec *vrec);
GValue* sfi_value_proxy (SfiProxy vproxy);
void sfi_value_free (GValue *value);
-
-
/* --- convenience aliases --- */
#define SFI_VALUE_HOLDS_NOTE(value) SFI_VALUE_HOLDS_INT(value)
#define sfi_value_get_note sfi_value_get_int
@@ -135,8 +119,6 @@ void sfi_value_free (GValue *value);
#define sfi_value_get_time sfi_value_get_num
#define sfi_value_set_time sfi_value_set_num
#define sfi_value_time sfi_value_num
-
-
/* --- transformation --- */
#define SFI_CHOICE_ERROR_QUARK (g_quark_from_string ("sfi-choice-error"))
void sfi_value_choice2enum (const GValue *choice_value,
@@ -165,15 +147,10 @@ gboolean sfi_value_type_compatible (GType src_type,
GType dest_type);
gboolean sfi_value_type_transformable (GType src_type,
GType dest_type);
-
-
/* --- internal --- */
void _sfi_init_values (void);
extern GType *sfi__value_types;
gboolean sfi_check_value (const GValue *value);
-
G_END_DECLS
-
#endif /* __SFI_VALUES_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfivmarshal.cc b/sfi/sfivmarshal.cc
index 4cad19d..1dd91a3 100644
--- a/sfi/sfivmarshal.cc
+++ b/sfi/sfivmarshal.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "sfivmarshal.hh"
-
#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
#define g_marshal_value_peek_char(v) g_value_get_char (v)
@@ -44,18 +43,14 @@
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */
-
typedef union {
guint64 v64; /* 2 (10) */
guint32 v32; /* 1 (01) */
double vdbl; /* 3 (11) */
void *vpt;
} Arg;
-
typedef void (*VMarshal) (void *func, void *arg0, Arg *alist);
-
static VMarshal sfi_vmarshal_switch (guint sig);
-
static inline uint
put_val (Arg *a,
const GValue *value)
@@ -98,7 +93,6 @@ put_val (Arg *a,
}
return t;
}
-
void
sfi_vmarshal_void (void *func,
void *arg0,
@@ -109,9 +103,7 @@ sfi_vmarshal_void (void *func,
Arg alist[SFI_VMARSHAL_MAX_ARGS + 1];
guint32 sig;
guint i;
-
g_return_if_fail (n_args <= SFI_VMARSHAL_MAX_ARGS);
-
sig = 0;
for (i = 0; i < n_args; i++)
{
@@ -134,10 +126,8 @@ sfi_vmarshal_void (void *func,
}
else
alist[SFI_VMARSHAL_MAX_ARGS].vpt = data;
-
sfi_vmarshal_switch (sig) (func, arg0, alist);
}
-
static void /* 1 */
sfi_vmarshal_11111 (void *func, void *arg0, Arg *alist)
{
diff --git a/sfi/sfivmarshal.hh b/sfi/sfivmarshal.hh
index 6958684..90e351d 100644
--- a/sfi/sfivmarshal.hh
+++ b/sfi/sfivmarshal.hh
@@ -1,32 +1,22 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_VMARSHAL_H__
#define __SFI_VMARSHAL_H__
-
#include <sfi/sfitypes.hh>
-
G_BEGIN_DECLS
-
/* --- hard limit --- */
#define SFI_VMARSHAL_MAX_ARGS 5
-
-
/* --- invocations --- */
void sfi_vmarshal_void (void *func,
void *arg0,
uint n_args,
const GValue *args, /* 1..n */
void *data); /* n+1 */
-
-
/* --- internal --- */
#if GLIB_SIZEOF_VOID_P == 4
#define SFI_VMARSHAL_PTR_ID 1
#else
#define SFI_VMARSHAL_PTR_ID 2
#endif
-
G_END_DECLS
-
#endif /* __SFI_VMARSHAL_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index a58c892..c586cd0 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -2,7 +2,6 @@
#include "sfiwrapper.hh"
#include <birnet/birnet.hh>
#include <errno.h>
-
/* --- initialization --- */
void
sfi_init (int *argcp,
@@ -16,44 +15,37 @@ sfi_init (int *argcp,
BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_num) == offsetof (BirnetInitValue, value_num));
Birnet::birnet_init (argcp, argvp, app_name, (BirnetInitValue*) sivalues);
}
-
bool
sfi_init_value_bool (SfiInitValue *value)
{
return Birnet::init_value_bool ((BirnetInitValue*) value);
}
-
double
sfi_init_value_double (SfiInitValue *value)
{
return Birnet::init_value_double ((BirnetInitValue*) value);
}
-
gint64
sfi_init_value_int (SfiInitValue *value)
{
return Birnet::init_value_int ((BirnetInitValue*) value);
}
-
SfiInitSettings
sfi_init_settings (void)
{
return ::Birnet::init_settings();
}
-
/* --- CPU Info --- */
SfiCPUInfo
sfi_cpu_info (void)
{
return ::Birnet::cpu_info();
}
-
gchar*
sfi_cpu_info_string (const SfiCPUInfo *cpu_info)
{
return g_strdup (::Birnet::cpu_info_string (*cpu_info).c_str());
}
-
/* --- file testing --- */
bool
birnet_file_check (const char *file,
@@ -61,14 +53,12 @@ birnet_file_check (const char *file,
{
return Birnet::Path::check (file ? file : "", mode ? mode : "");
}
-
bool
birnet_file_equals (const char *file1,
const char *file2)
{
return Birnet::Path::equals (file1 ? file1 : "", file2 ? file2 : "");
}
-
/* --- message handling --- */
SfiMsgType
sfi_msg_type_register (const gchar *ident,
@@ -85,55 +75,46 @@ sfi_msg_type_register (const gchar *ident,
BIRNET_STATIC_ASSERT (Birnet::Msg::DEBUG == (uint) SFI_MSG_DEBUG);
return (SfiMsgType) Birnet::Msg::register_type (ident, Birnet::Msg::Type (default_ouput), label);
}
-
bool
sfi_msg_check (SfiMsgType mtype)
{
return Birnet::Msg::check (Birnet::Msg::Type (mtype));
}
-
void
sfi_msg_enable (SfiMsgType mtype)
{
return Birnet::Msg::enable (Birnet::Msg::Type (mtype));
}
-
void
sfi_msg_disable (SfiMsgType mtype)
{
return Birnet::Msg::disable (Birnet::Msg::Type (mtype));
}
-
void
sfi_msg_allow (const gchar *ident_list)
{
return Birnet::Msg::allow_msgs (ident_list);
}
-
void
sfi_msg_deny (const gchar *ident_list)
{
return Birnet::Msg::deny_msgs (ident_list);
}
-
const char*
sfi_msg_type_ident (SfiMsgType mtype)
{
return Birnet::Msg::type_ident (Birnet::Msg::Type (mtype));
}
-
const char*
sfi_msg_type_label (SfiMsgType mtype)
{
return Birnet::Msg::type_label (Birnet::Msg::Type (mtype));
}
-
SfiMsgType
sfi_msg_lookup_type (const char *ident)
{
return (SfiMsgType) Birnet::Msg::lookup_type (ident);
}
-
SfiMsgPart*
sfi_msg_part_printf (uint8 msg_part_id,
const char *format,
@@ -159,7 +140,6 @@ sfi_msg_part_printf (uint8 msg_part_id,
errno = saved_errno;
return (SfiMsgPart*) part;
}
-
void
sfi_msg_display_parts (const char *log_domain,
SfiMsgType mtype,
@@ -177,7 +157,6 @@ sfi_msg_display_parts (const char *log_domain,
Birnet::Msg::display_parts (log_domain, Birnet::Msg::Type (mtype), parts);
errno = saved_errno;
}
-
/**
* @param log_domain log domain
* @param level one of SFI_MSG_ERROR, SFI_MSG_WARNING, SFI_MSG_INFO, SFI_MSG_DIAG or SFI_MSG_DEBUG
@@ -210,7 +189,6 @@ sfi_msg_display_printf (const char *log_domain,
Birnet::Msg::display_parts (log_domain, Birnet::Msg::Type (mtype), parts);
errno = saved_errno;
}
-
/* --- debug channels --- */
SfiDebugChannel*
sfi_debug_channel_from_file_async (const char *file_name)
@@ -219,7 +197,6 @@ sfi_debug_channel_from_file_async (const char *file_name)
ref_sink (self);
return (SfiDebugChannel*) self;
}
-
void
sfi_debug_channel_printf (SfiDebugChannel *debug_channel,
const char *dummy,
@@ -232,21 +209,18 @@ sfi_debug_channel_printf (SfiDebugChannel *debug_channel,
self->printf_valist (format, a);
va_end (a);
}
-
void
sfi_debug_channel_destroy (SfiDebugChannel *debug_channel)
{
Birnet::DebugChannel *self = (Birnet::DebugChannel*) debug_channel;
unref (self);
}
-
/* --- url handling --- */
void
sfi_url_show (const char *url)
{
return Birnet::url_show (url);
}
-
void
sfi_url_show_with_cookie (const char *url,
const char *url_title,
@@ -254,13 +228,11 @@ sfi_url_show_with_cookie (const char *url,
{
return Birnet::url_show_with_cookie (url, url_title, cookie);
}
-
bool
sfi_url_test_show (const char *url)
{
return Birnet::url_test_show (url);
}
-
bool
sfi_url_test_show_with_cookie (const char *url,
const char *url_title,
@@ -268,14 +240,12 @@ sfi_url_test_show_with_cookie (const char *url,
{
return Birnet::url_test_show_with_cookie (url, url_title, cookie);
}
-
/* --- cleanup handlers --- */
void
birnet_cleanup_force_handlers (void)
{
return Birnet::cleanup_force_handlers();
}
-
/* --- threading API --- */
SfiThread*
sfi_thread_run (const gchar *name,
@@ -283,7 +253,6 @@ sfi_thread_run (const gchar *name,
gpointer user_data)
{
g_return_val_if_fail (name && name[0], NULL);
-
SfiThread *thread = sfi_thread_new (name);
sfi_thread_ref_sink (thread);
if (sfi_thread_start (thread, func, user_data))
@@ -294,10 +263,8 @@ sfi_thread_run (const gchar *name,
return NULL;
}
}
-
/* for the sfi_thread_table initialization to work, Birnet::ThreadTable must not be a reference */
extern "C" const BirnetThreadTable *sfi_thread_table = &::Birnet::ThreadTable;
-
void
sfi_runtime_problem (char ewran_tag,
const char *domain,
@@ -312,5 +279,4 @@ sfi_runtime_problem (char ewran_tag,
::Birnet::birnet_runtime_problemv (ewran_tag, domain, file, line, funcname, msgformat, args);
va_end (args);
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index 1a03e6a..9e377fc 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -1,15 +1,12 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_WRAPPER_H__
#define __SFI_WRAPPER_H__
-
#include <stdbool.h>
#include <sfi/glib-extra.hh>
#include <birnet/birnetcdefs.h> /* include glib before birnet for G_LOG_DOMAIN */
-
/* sfiwrapper.h is a thin C language wrapper around C++ features
* provided by libbirnet.
*/
-
/* --- short integer types --- */
#ifdef __cplusplus
#include <birnet/birnetutils.hh>
@@ -33,9 +30,7 @@ typedef BirnetInt32 int32;
typedef BirnetInt64 int64;
typedef BirnetUnichar unichar;
#endif
-
BIRNET_EXTERN_C_BEGIN();
-
/* --- initialization --- */
typedef struct
{
@@ -50,22 +45,17 @@ void sfi_init (int *argcp,
bool sfi_init_value_bool (SfiInitValue *value);
double sfi_init_value_double (SfiInitValue *value);
gint64 sfi_init_value_int (SfiInitValue *value);
-
typedef BirnetInitSettings SfiInitSettings;
SfiInitSettings sfi_init_settings (void);
-
/* --- CPU Info --- */
typedef BirnetCPUInfo SfiCPUInfo;
-
SfiCPUInfo sfi_cpu_info (void);
gchar* sfi_cpu_info_string (const SfiCPUInfo *cpu_info);
-
/* --- file tests --- */
bool birnet_file_check (const char *file,
const char *mode);
bool birnet_file_equals (const char *file1,
const char *file2);
-
/* --- messaging --- */
typedef enum {
SFI_MSG_NONE = 0, /* always off */
@@ -111,7 +101,6 @@ SfiMsgType sfi_msg_type_register (const char *ident,
#define SFI_MSG_SECONDARY SFI_MSG_TEXT2 /* alias */
#define SFI_MSG_DETAIL SFI_MSG_TEXT3 /* alias */
#define SFI_MSG_TYPE_DEFINE(variable, ident, default_ouput, label) SFI_MSG__TYPEDEF (variable, ident, default_ouput, label)
-
/* --- messaging implementation --- */
typedef struct SfiMsgPart SfiMsgPart;
SfiMsgPart* sfi_msg_part_printf (uint8 msg_part_id,
@@ -136,7 +125,6 @@ void sfi_msg_display_printf (const char *log_domain,
static void BIRNET_CONSTRUCTOR \
BIRNET_CPP_PASTE4 (__sfi_msg_type__init, __LINE__, __, variable) (void) \
{ variable = sfi_msg_type_register (identifier, default_ouput, label); }
-
/* --- debug channels --- */
typedef struct SfiDebugChannel SfiDebugChannel;
SfiDebugChannel* sfi_debug_channel_from_file_async (const char *file_name);
@@ -145,7 +133,6 @@ void sfi_debug_channel_printf (SfiDebugChannel *debug_chann
const char *format,
...) G_GNUC_PRINTF (3, 4);
void sfi_debug_channel_destroy (SfiDebugChannel *debug_channel);
-
/* --- url handling --- */
void sfi_url_show (const char *url);
void sfi_url_show_with_cookie (const char *url,
@@ -155,10 +142,8 @@ bool sfi_url_test_show (const char *url);
bool sfi_url_test_show_with_cookie (const char *url,
const char *url_title,
const char *cookie);
-
/* --- cleanup handlers --- */
void birnet_cleanup_force_handlers (void); // FIXME: remove
-
/* --- threading API --- */
typedef BirnetThread SfiThread;
typedef void (*SfiThreadFunc) (void *user_data);
@@ -239,7 +224,6 @@ SfiThread* sfi_thread_run (const char *name, /* new + start */
#define sfi_atomic_uint_cas(atmc,oval,nval) (sfi_thread_table->atomic_uint_cas (atmc, oval, nval))
#define sfi_atomic_uint_add(atmc,diff) (sfi_thread_table->atomic_uint_add (atmc, diff))
#define sfi_atomic_uint_swap_add(atmc,diff) (sfi_thread_table->atomic_uint_swap_add (atmc, diff))
-
/* --- implementation bits --- */
extern const BirnetThreadTable *sfi_thread_table;
#define SFI_MUTEX__DECLARE_INITIALIZED(mutexname) \
@@ -268,9 +252,6 @@ void sfi_runtime_problem (char ewran_tag,
const char *funcname,
const char *msgformat,
...) BIRNET_PRINTF (6, 7);
-
BIRNET_EXTERN_C_END();
-
#endif /* __SFI_WRAPPER_H__ */
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index ccf8b49..feecbed 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -7,7 +7,6 @@
#include <string.h>
#include <signal.h> /* G_BREAKPOINT() */
#include <math.h>
-
/* provide IDL type initializers */
#define sfidl_pspec_Real(group, name, nick, blurb, dflt, min, max, step, hints) \
sfi_pspec_real (name, nick, blurb, dflt, min, max, step, hints)
@@ -15,15 +14,12 @@
sfi_pspec_rec (name, nick, blurb, fields, hints)
#define sfidl_pspec_Choice(group, name, nick, blurb, default_value, hints, choices) \
sfi_pspec_choice (name, nick, blurb, default_value, choices, hints)
-
/* FIXME: small hackery */
#define sfidl_pspec_Rec(group, name, nick, blurb, hints) \
sfi_pspec_int (name, nick, blurb, 0, 0, 0, 0, hints)
#define sfidl_pspec_PSpec(group, name, nick, blurb, hints) \
sfi_pspec_int (name, nick, blurb, 0, 0, 0, 0, hints)
-
#include "testidl.h"
-
static void
test_misc (void)
{
@@ -31,7 +27,6 @@ test_misc (void)
TASSERT (0 == 0);
TDONE ();
}
-
static void
test_messages (void)
{
@@ -50,7 +45,6 @@ test_messages (void)
SFI_MSG_SECONDARY ("Third info secondary message: %d", 42));
}
}
-
static void
test_time (void)
{
@@ -103,7 +97,6 @@ test_time (void)
}
TDONE ();
}
-
static void
test_com_ports (void)
{
@@ -150,7 +143,6 @@ test_com_ports (void)
sfi_com_port_unref (port2);
TDONE ();
}
-
static void
test_thread (gpointer data)
{
@@ -161,7 +153,6 @@ test_thread (gpointer data)
sfi_thread_sleep (-1);
TACK ();
}
-
static void
test_threads (void)
{
@@ -184,7 +175,6 @@ test_threads (void)
sfi_thread_unref (thread);
TDONE ();
}
-
#define SCANNER_ASSERT64(scanner, printout, token, text, svalue) { \
g_scanner_input_text (scanner, text, strlen (text)); \
TASSERT (g_scanner_get_next_token (scanner) == token); \
@@ -201,7 +191,6 @@ test_threads (void)
TASSERT (scanner->value.v_float == svalue); \
TASSERT (g_scanner_get_next_token (scanner) == '#'); \
}
-
static void
test_scanner64 (void)
{
@@ -229,16 +218,13 @@ test_scanner64 (void)
g_scanner_destroy (scanner);
TDONE ();
}
-
typedef enum /*< skip >*/
{
SERIAL_TEST_TYPED = 1,
SERIAL_TEST_PARAM,
SERIAL_TEST_PSPEC
} SerialTest;
-
static SerialTest serial_test_type = SerialTest (0);
-
static void
serial_pspec_check (GParamSpec *pspec,
GScanner *scanner)
@@ -266,7 +252,6 @@ serial_pspec_check (GParamSpec *pspec,
g_string_free (s1, TRUE);
g_string_free (s2, TRUE);
}
-
// serialize @a value according to @a pspec, deserialize and assert a matching result
static void
serialize_cmp (GValue *value,
@@ -336,7 +321,6 @@ serialize_cmp (GValue *value,
sfi_value_free (value);
sfi_pspec_sink (pspec);
}
-
static void
test_typed_serialization (SerialTest test_type)
{
@@ -442,7 +426,6 @@ test_typed_serialization (SerialTest test_type)
sfi_fblock_append1 (fblock, SFI_MAXNUM);
serialize_cmp (sfi_value_fblock (fblock),
sfi_pspec_fblock ("fblock", NULL, NULL, SFI_PARAM_STANDARD));
-
serialize_cmp (sfi_value_seq (NULL),
sfi_pspec_seq ("seq-nil", NULL, NULL, NULL, SFI_PARAM_STANDARD));
seq = sfi_seq_new ();
@@ -483,7 +466,6 @@ test_typed_serialization (SerialTest test_type)
sfi_pspec_int ("integer", NULL, NULL,
1500, 1000, 2000, 1, SFI_PARAM_STANDARD),
SFI_PARAM_STANDARD));
-
if (serial_test_type == SERIAL_TEST_PSPEC)
{
serialize_cmp (sfi_value_pspec (NULL),
@@ -491,7 +473,6 @@ test_typed_serialization (SerialTest test_type)
serialize_cmp (sfi_value_pspec (pspec_homo_seq),
sfi_pspec_pspec ("pspec-hseq", NULL, NULL, SFI_PARAM_STANDARD));
}
-
serialize_cmp (sfi_value_rec (NULL),
sfi_pspec_rec ("rec-nil", NULL, NULL, rec_fields, SFI_PARAM_STANDARD));
rec = sfi_rec_new ();
@@ -514,14 +495,12 @@ test_typed_serialization (SerialTest test_type)
rec_fields.fields[rec_fields.n_fields++] = pspec_homo_seq;
serialize_cmp (sfi_value_rec (rec),
sfi_pspec_rec ("rec", NULL, NULL, rec_fields, SFI_PARAM_STANDARD));
-
sfi_fblock_unref (fblock);
sfi_seq_unref (seq);
sfi_pspec_unref (pspec_homo_seq);
sfi_rec_unref (rec);
TDONE ();
}
-
static void
test_notes (void)
{
@@ -545,7 +524,6 @@ test_notes (void)
int octave, semitone;
gboolean black_semitone;
gchar letter;
-
sfi_note_examine (i, &octave, &semitone, &black_semitone, &letter);
TASSERT (octave == SFI_NOTE_OCTAVE (i));
TASSERT (semitone == SFI_NOTE_SEMITONE (i));
@@ -557,11 +535,9 @@ test_notes (void)
g_free (error);
TDONE ();
}
-
static SFI_MUTEX_DECLARE_INITIALIZED (test_mutex);
static SFI_REC_MUTEX_DECLARE_INITIALIZED (test_rec_mutex);
static SFI_COND_DECLARE_INITIALIZED (test_cond);
-
static void
check_thread_wrapper_compilation (void)
{
@@ -645,7 +621,6 @@ check_thread_wrapper_compilation (void)
sfi_atomic_uint_add (&uatmc, diff);
uval = sfi_atomic_uint_swap_add (&uatmc, diff);
}
-
static void
test_renames (void)
{
@@ -671,10 +646,8 @@ test_renames (void)
g_free (str);
TDONE ();
}
-
static gboolean vmarshal_switch = TRUE;
static guint vmarshal_count = 0;
-
static void
generate_vmarshal (guint sig)
{
@@ -711,7 +684,6 @@ generate_vmarshal (guint sig)
else
g_print (" case 0x%03x: return sfi_vmarshal_%s; /* %u */\n", sig, s, vmarshal_count);
}
-
static void
generate_vmarshal_loop (void)
{
@@ -742,13 +714,11 @@ generate_vmarshal_loop (void)
}
}
}
-
static void
generate_vmarshal_code (void)
{
vmarshal_switch = FALSE;
generate_vmarshal_loop ();
-
vmarshal_switch = TRUE;
g_print ("static VMarshal\nsfi_vmarshal_switch (guint sig)\n{\n");
g_print (" switch (sig)\n {\n");
@@ -756,11 +726,9 @@ generate_vmarshal_code (void)
g_print (" default: g_assert_not_reached (); return NULL;\n");
g_print (" }\n}\n");
}
-
static const char *pointer1 = "huhu";
static const char *pointer2 = "haha";
static const char *pointer3 = "zoot";
-
static void
test_vmarshal_func4 (gpointer o,
SfiReal r,
@@ -772,7 +740,6 @@ test_vmarshal_func4 (gpointer o,
TASSERT (n == -2598768763298128732LL);
TASSERT (data == pointer3);
}
-
static void
test_vmarshal_func7 (gpointer o,
SfiReal r,
@@ -790,7 +757,6 @@ test_vmarshal_func7 (gpointer o,
TASSERT (self == (long) test_vmarshal_func7);
TASSERT (data == pointer3);
}
-
static void
test_vmarshals (void)
{
@@ -806,7 +772,6 @@ test_vmarshals (void)
TDONE ();
sfi_seq_unref (seq);
}
-
static void
test_sfidl_seq (void)
{
@@ -816,112 +781,87 @@ test_sfidl_seq (void)
SfiRec* rec;
GValue* value;
TSTART ("Sfidl generated code");
-
/* test that types are registered properly */
// TASSERT (TEST_TYPE_POSITION != 0);
// TASSERT (TEST_TYPE_POSITION_SEQ != 0);
// TASSERT (TEST_TYPE_YES_NO_UNDECIDED != 0);
-
/* test sequences and structs generated for Position record */
pseq = test_position_seq_new ();
TASSERT (pseq != NULL);
TASSERT (pseq->n_positions == 0);
-
pos = test_position_new ();
TASSERT (pos != NULL);
pos->x = 1.0;
pos->y = -1.0;
pos->relevant = TEST_NO;
-
test_position_seq_append (pseq, pos);
TASSERT (pseq->n_positions == 1);
-
test_position_seq_resize (pseq, 4);
TASSERT (pseq->n_positions == 4);
-
test_position_seq_resize (pseq, 1);
TASSERT (pseq->n_positions == 1);
-
rec = test_position_to_rec (pos);
value = sfi_rec_get (rec, "relevant");
-
TASSERT (SFI_VALUE_HOLDS_CHOICE (value));
TASSERT (strcmp (sfi_value_get_choice (value), "test-no") == 0);
-
pos2 = test_position_from_rec (rec);
-
TASSERT (pos->x == pos2->x);
TASSERT (pos->y == pos2->y);
TASSERT (pos->relevant == pos2->relevant);
-
sfi_rec_unref (rec);
test_position_seq_free (pseq);
test_position_free (pos);
test_position_free (pos2);
-
/* test validation and defaulting */
{
GParamSpec *pspec;
GValue rec_value = { 0, };
-
/* create empty record */
g_value_init (&rec_value, SFI_TYPE_REC);
sfi_value_take_rec (&rec_value, sfi_rec_new ());
-
/* validate record against pspec */
pspec = sfi_pspec_rec ("foo", "bar", "bazz", test_position_fields, SFI_PARAM_STANDARD);
g_param_value_validate (pspec, &rec_value);
g_param_spec_unref (pspec);
-
#if 0
GValue pos_value = { 0, };
/* transform record to boxed type */
g_value_init (&pos_value, TEST_TYPE_POSITION);
TASSERT (sfi_value_type_transformable (SFI_TYPE_REC, TEST_TYPE_POSITION));
sfi_value_transform (&rec_value, &pos_value);
-
/* get boxed type */
TASSERT (G_VALUE_HOLDS (&pos_value, TEST_TYPE_POSITION));
pos = g_value_get_boxed (&pos_value);
-
/* check that values match defaults */
TASSERT (pos->x == 2.0);
TASSERT (pos->y == 3.0);
TASSERT (pos->relevant == TEST_YES);
-
/* cleanup */
g_value_unset (&rec_value);
g_value_unset (&pos_value);
#endif
}
-
/* test that correct code is generated for double constants */
TASSERT (test_real_division_fields.n_fields == 1);
SfiReal pi = sfi_pspec_get_real_default (test_real_division_fields.fields[0]);
TASSERT (fabs (3.14 - pi) < 0.01);
-
/* test constants */
// TASSERT (TEST_ANSWER_B == 42);
// TASSERT (strcmp(TEST_ULTIMATE_ANSWER, "the answer to all questions is 42") == 0);
TDONE ();
}
-
#include "testidl.c"
-
int
main (int argc,
char *argv[])
{
sfi_init_test (&argc, &argv, NULL);
-
test_types_init ();
-
if (0)
{
generate_vmarshal_code ();
return 0;
}
-
check_thread_wrapper_compilation ();
test_notes ();
test_time ();
@@ -936,11 +876,8 @@ main (int argc,
test_sfidl_seq ();
test_messages();
test_misc ();
-
return 0;
}
-
/* distcc preprocessing test */
const char *test_distcc_strings = "ÿÿÿÿ";
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/tests/ring.cc b/sfi/tests/ring.cc
index 2528a99..62f355b 100644
--- a/sfi/tests/ring.cc
+++ b/sfi/tests/ring.cc
@@ -2,7 +2,6 @@
// #define TEST_VERBOSE
#include <sfi/sfitests.hh>
#include <sfi/sfi.hh>
-
static void
print_ring_ints (SfiRing *ring)
{
@@ -12,7 +11,6 @@ print_ring_ints (SfiRing *ring)
g_print (" %zd,", (size_t) node->data);
g_print (" };");
}
-
static void
print_rings_side_by_side (SfiRing *ring1,
SfiRing *ring2)
@@ -33,15 +31,12 @@ print_rings_side_by_side (SfiRing *ring1,
r2 = sfi_ring_walk (r2, ring2);
}
}
-
static void
test_sfi_ring (void)
{
TSTART ("RingBasics");
(void) print_ring_ints;
-
SfiRing *r1 = NULL, *r2 = NULL, *d = NULL;
-
r1= sfi_ring_append (r1, (void*) 3);
r1= sfi_ring_append (r1, (void*) 7);
r1= sfi_ring_append (r1, (void*) 8);
@@ -49,7 +44,6 @@ test_sfi_ring (void)
r1= sfi_ring_append (r1, (void*) 18);
TASSERT (sfi_ring_length (r1) == 5);
TASSERT (sfi_ring_equals (r1, r1, sfi_pointer_cmp, NULL));
-
d = sfi_ring_append (d, (void*) 13);
d = sfi_ring_append (d, (void*) 7);
d = sfi_ring_append (d, (void*) 18);
@@ -58,14 +52,12 @@ test_sfi_ring (void)
TASSERT (sfi_ring_equals (d, d, sfi_pointer_cmp, NULL));
TASSERT (sfi_ring_min (d, sfi_pointer_cmp, NULL) == (void*) 3);
TASSERT (sfi_ring_max (d, sfi_pointer_cmp, NULL) == (void*) 18);
-
TASSERT (sfi_ring_equals (r1, d, sfi_pointer_cmp, NULL) == FALSE);
d = sfi_ring_sort (d, sfi_pointer_cmp, NULL);
TASSERT (sfi_ring_equals (r1, d, sfi_pointer_cmp, NULL));
TASSERT (sfi_ring_includes (r1, d, sfi_pointer_cmp, NULL));
TASSERT (sfi_ring_includes (d, r1, sfi_pointer_cmp, NULL));
sfi_ring_free (d);
-
r2 = sfi_ring_append (r2, (void*) 4);
r2 = sfi_ring_append (r2, (void*) 7);
r2 = sfi_ring_append (r2, (void*) 13);
@@ -75,23 +67,19 @@ test_sfi_ring (void)
TASSERT (sfi_ring_equals (r1, r2, sfi_pointer_cmp, NULL) == FALSE);
TASSERT (sfi_ring_includes (r1, r2, sfi_pointer_cmp, NULL) == FALSE);
sfi_ring_free (d);
-
TDONE ();
TSTART ("RingMath");
-
d = sfi_ring_difference (r1, r2, sfi_pointer_cmp, NULL);
TASSERT (sfi_ring_pop_head (&d) == (void*) 3);
TASSERT (sfi_ring_pop_head (&d) == (void*) 8);
TASSERT (sfi_ring_pop_head (&d) == (void*) 18);
TASSERT (d == NULL);
-
d = sfi_ring_symmetric_difference (r1, r2, sfi_pointer_cmp, NULL);
TASSERT (sfi_ring_pop_head (&d) == (void*) 3);
TASSERT (sfi_ring_pop_head (&d) == (void*) 4);
TASSERT (sfi_ring_pop_head (&d) == (void*) 8);
TASSERT (sfi_ring_pop_head (&d) == (void*) 18);
TASSERT (d == NULL);
-
SfiRing *t1 = sfi_ring_symmetric_difference (r1, r2, sfi_pointer_cmp, NULL);
SfiRing *t2 = sfi_ring_intersection (r1, r2, sfi_pointer_cmp, NULL);
d = sfi_ring_intersection (t1, t2, sfi_pointer_cmp, NULL);
@@ -103,7 +91,6 @@ test_sfi_ring (void)
sfi_ring_free (t2);
TASSERT (sfi_ring_includes (d, r1, sfi_pointer_cmp, NULL));
TASSERT (sfi_ring_includes (d, r2, sfi_pointer_cmp, NULL));
-
d = sfi_ring_union (r1, r2, sfi_pointer_cmp, NULL);
TASSERT (sfi_ring_length (d) == 6);
t1 = r1, t2 = d;
@@ -123,13 +110,10 @@ test_sfi_ring (void)
TASSERT (sfi_ring_equals (d, t1, sfi_pointer_cmp, NULL));
sfi_ring_free (t1);
sfi_ring_free (d);
-
sfi_ring_free (r1);
sfi_ring_free (r2);
-
TDONE ();
TSTART ("RingReorder");
-
r1 = NULL;
r1 = sfi_ring_append (r1, (void*) 5);
r1 = sfi_ring_append (r1, (void*) 7);
@@ -171,7 +155,6 @@ test_sfi_ring (void)
TASSERT (sfi_ring_pop_head (&r2) == (void*) 0x68);
TASSERT (r2 == NULL);
sfi_ring_free (r1);
-
r1 = NULL;
r1 = sfi_ring_append (r1, (void*) 0x11);
r1 = sfi_ring_append (r1, (void*) 0x16);
@@ -196,20 +179,14 @@ test_sfi_ring (void)
TASSERT (sfi_ring_equals (r1, r2, sfi_pointer_cmp, NULL));
sfi_ring_free (r1);
sfi_ring_free (r2);
-
TDONE ();
}
-
-
int
main (int argc,
char *argv[])
{
sfi_init_test (&argc, &argv, NULL);
-
test_sfi_ring();
-
return 0;
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/tests/testcxx.cc b/sfi/tests/testcxx.cc
index a9b17d0..01246d4 100644
--- a/sfi/tests/testcxx.cc
+++ b/sfi/tests/testcxx.cc
@@ -5,9 +5,7 @@
#include <birnet/birnettests.h>
#include "../sficxx.hh"
#include <stdio.h>
-
using namespace Sfi;
-
struct Bar {
int i;
};
@@ -17,7 +15,6 @@ typedef struct {
guint n_elements;
Int *elements;
} CIntSeq;
-
int
main (int argc,
char *argv[])
@@ -35,7 +32,6 @@ main (int argc,
String s3 = "huhu1";
TASSERT (s2 == s3);
TDONE();
-
TSTART ("Test RecordHandle<>");
TASSERT (sizeof (RecordHandle<Bar>) == sizeof (void*));
RecordHandle<Bar> b1;
@@ -51,7 +47,6 @@ main (int argc,
TASSERT (b4->i == 5);
TASSERT (b2[0].i == 0);
TDONE();
-
TSTART ("Test IntSeq");
TASSERT (sizeof (IntSeq) == sizeof (void*));
IntSeq is (9);
@@ -68,14 +63,12 @@ main (int argc,
for (int i = 0; i < 12; i++)
TASSERT (is[i] == 2147483600 + i);
TDONE();
-
TSTART ("Test IntSeq in C");
CIntSeq *cis = *(CIntSeq**) &is;
TASSERT (cis->n_elements == 12);
for (int i = 0; i < 12; i++)
TASSERT (cis->elements[i] == 2147483600 + i);
TDONE();
-
TSTART ("Test BarSeq");
TASSERT (sizeof (BarSeq) == sizeof (void*));
BarSeq bs (7);
@@ -93,6 +86,5 @@ main (int argc,
bs.resize (0);
TASSERT (bs.length() == 0);
TDONE();
-
return 0;
}
diff --git a/sfi/tests/testidl.idl b/sfi/tests/testidl.idl
index 75c71a9..692c4a6 100644
--- a/sfi/tests/testidl.idl
+++ b/sfi/tests/testidl.idl
@@ -6,13 +6,11 @@ namespace Test // this comment tests C++ style comments
Const ANSWER_A = "the answer to all questions";
Const ANSWER_B = 42;
Const ULTIMATE_ANSWER = (ANSWER_A " is " ANSWER_B);
-
choice YesNoUndecided {
Undecided = (Neutral, "Undecided"),
Yes = (1, "Yes"),
No = (2, "No")
};
-
choice ExcessiveChoiceTest {
V0,
V2 = 2,
@@ -23,26 +21,21 @@ choice ExcessiveChoiceTest {
V12 = (12, "l12", _("b12")),
V14 = (14, _("l14i"), _("b14i")),
};
-
record Position {
Sfi::Real x = ("X", "", 2.0, -10.0, 10.0, 1, ":readwrite");
Sfi::Real y = ("Y", "", 3.0, -10.0, 10.0, 1, ":readwrite");
YesNoUndecided relevant = ("Relevant", "", "test-yes", ":readwrite");
};
-
record SickGenericThings {
// $GROUP = "foo";
Sfi::Rec rec = ("Rec", "", ":readwrite");
};
-
record RealDivision {
// computation result should be 3.14
Sfi::Real pi = ("PI", "", 314.0 / 100.0, 3, 4, 0.1, ":readwrite");
};
-
// no more Sfi:: prefixing beyond this line
using namespace Sfi;
-
class Blub {
property Real x;
// property "X-Group" Real y;
@@ -50,15 +43,12 @@ class Blub {
Num z;
};
};
-
sequence PositionSeq {
Position positions = ("Position", "", ":readwrite");
};
-
/* test that C++ style commments are properly ignored within strings */
Const CXX_COMMENT_TEST_1 = "Foo // bar";
Const CXX_COMMENT_TEST_2 = "Foo \" // bar";
Const CXX_COMMENT_TEST_3 = "Foo \\";//bar
-
};
/* vim:set ts=8 sts=2 sw=2 syntax=cpp: */
diff --git a/sfi/tests/testsfidl.cc b/sfi/tests/testsfidl.cc
index c271954..d2db830 100644
--- a/sfi/tests/testsfidl.cc
+++ b/sfi/tests/testsfidl.cc
@@ -6,16 +6,12 @@
#include "../sfidl-generator.hh"
#include "../sfidl-factory.hh"
#include <stdio.h>
-
using namespace Sfidl;
using namespace std;
-
-
#define ASSERT_EQ(got,expectedcstr) do { \
TPRINT ("{check equality: %s == %s}", expectedcstr, got.c_str()); \
TASSERT (expectedcstr == got); \
} while (0)
-
class TestCG : public CodeGenerator
{
string one, two, done;
@@ -26,11 +22,9 @@ public:
OptionVector getOptions()
{
OptionVector opts;
-
opts.push_back (make_pair ("--one", true));
opts.push_back (make_pair ("--two", true));
opts.push_back (make_pair ("--done", false));
-
return opts;
}
void setOption (const string& option, const string& value)
@@ -46,78 +40,61 @@ public:
ASSERT_EQ (two, "2");
ASSERT_EQ (done, "1");
TDONE ();
-
TSTART ("Testing CodeGenerator::rename()");
-
vector<string> procedures;
vector<string> empty;
vector<string> type;
procedures.push_back("Procedures");
type.push_back("Type");
-
TASSERT (procedures.size() == 1);
TASSERT (type.size() == 1);
TASSERT (empty.size() == 0);
-
ASSERT_EQ (rename (ABSOLUTE, "A::B::processMessagesSlowly", Capitalized, "::",
procedures, lower, "_"),
"::A::B::Procedures::process_messages_slowly");
-
ASSERT_EQ (rename (NONE, "A::B::processMessagesSlowly", Capitalized, "::",
procedures, lower, "_"),
"Procedures::process_messages_slowly");
-
ASSERT_EQ (rename (ABSOLUTE, "Bse::SNet", Capitalized, "",
empty, Capitalized, ""),
"BseSNet");
-
ASSERT_EQ (rename (ABSOLUTE, "Bse::AlphaSynth", UPPER, "_",
type, UPPER, "_"),
"BSE_TYPE_ALPHA_SYNTH");
-
ASSERT_EQ (rename (ABSOLUTE, "Bse::FFTSize", Capitalized, "",
empty, Capitalized, ""),
"BseFFTSize");
-
ASSERT_EQ (rename (ABSOLUTE, "Bse::FFTSize", lower, "_",
empty, lower, "_"),
"bse_fft_size");
-
ASSERT_EQ (rename (ABSOLUTE, "XWindows::WMHints", Capitalized, "",
empty, Capitalized, ""),
"XWindowsWMHints");
-
ASSERT_EQ (rename (ABSOLUTE, "XWindows::WMHints", UPPER, "_",
empty, UPPER, "_"),
"XWINDOWS_WM_HINTS");
-
ASSERT_EQ (rename (ABSOLUTE, "Bse::MIDI_SIGNAL_PROGRAM", UPPER, "_",
empty, UPPER, "_"),
"BSE_MIDI_SIGNAL_PROGRAM");
-
TDONE();
return true;
}
};
-
class TestCGFactory : public Factory {
public:
string option() const { return "--test"; }
string description() const { return "test code generator"; }
-
CodeGenerator *create (const Parser& parser) const
{
return new TestCG (parser);
}
} static_factory;
-
int
main (int argc,
char *argv[])
{
Options options;
Parser parser;
-
int fake_argc = 6;
char **fake_argv = g_new0 (gchar*, fake_argc);
fake_argv[0] = (char*) "testsfidl";
@@ -127,11 +104,9 @@ main (int argc,
fake_argv[4] = (char*) "--two=2";
fake_argv[5] = (char*) "--done";
options.parse (&fake_argc, &fake_argv, parser);
-
TSTART ("Testing factory");
TASSERT (options.codeGenerator != 0);
TDONE();
-
if (options.codeGenerator->run())
{
delete options.codeGenerator;
@@ -143,5 +118,4 @@ main (int argc,
return 1;
}
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/toyprof-mem.c b/sfi/toyprof-mem.c
index 4476f44..823aaf7 100644
--- a/sfi/toyprof-mem.c
+++ b/sfi/toyprof-mem.c
@@ -2,10 +2,8 @@
// TOYPROF - Poor man's profiling toy
#define _GNU_SOURCE /* enable various glibc features we depend on */
#include "toyprof-mem.h"
-
/* --- configuration --- */
#define STACK_TRACE_DEPTH 12 /* number of callers to log */
-
/* Basic usage:
* 1) call toyprof_init_glib_memtable ("/tmp/mylogfile", SIGUSR1); in main()
* 2) start the program
@@ -13,11 +11,8 @@
* 4) kill -SIGUSR1 <program-pid> ; this dumps leaks since (3) to "/tmp/mylogfile"
* 5) cat "/tmp/mylogfile" | toyprof.pl | less -S
*/
-
/* --- extern variables --- */
volatile gulong toyprof_memtotal = 0;
-
-
#if defined __GLIBC__ && __GLIBC__ >= 2
#include <pthread.h>
#include <stdio.h>
@@ -32,12 +27,10 @@ volatile gulong toyprof_memtotal = 0;
#include <assert.h>
#include <errno.h>
#include <link.h> /* _r_debug */
-
#define standard_malloc malloc
#define standard_realloc realloc
#define standard_free free
#define standard_calloc calloc
-
typedef struct _MemHeader MemHeader;
struct _MemHeader
{
@@ -48,8 +41,6 @@ struct _MemHeader
MemHeader *next;
};
#define HEADER_SIZE (sizeof (MemHeader))
-
-
/* --- variables --- */
extern GMemVTable *toyprof_mem_table;
static gulong toyprof_n_traces;
@@ -65,8 +56,6 @@ typedef struct {
} SymEntry;
static SymEntry *toyprof_symtab = NULL;
static guint toyprof_symtab_length = 0;
-
-
/* --- functions --- */
static int
symentry_compare (const void *d1,
@@ -76,7 +65,6 @@ symentry_compare (const void *d1,
const SymEntry *e2 = d2;
return e1->sbase < e2->sbase ? -1 : e1->sbase > e2->sbase;
}
-
static void
symtab_init (void)
{
@@ -103,7 +91,6 @@ symtab_init (void)
toyprof_symtab[toyprof_symtab_length].sname = main_sname;
assert (main_sname != NULL);
}
-
static SymEntry*
symtab_lookup (void *symaddr)
{
@@ -123,7 +110,6 @@ symtab_lookup (void *symaddr)
}
return last ? last : toyprof_symtab + toyprof_symtab_length; /* fallback to main */
}
-
static void
toyprof_dump_leaks_U (guint leak_logger_stamp,
gint fd);
@@ -155,14 +141,12 @@ memleak_handle_jobs (void)
}
pthread_mutex_unlock (&profile_mutex);
}
-
static void
toyprof_memsignal (int sigid)
{
toyprof_need_dump = 1;
signal (toyprof_logger_signal, toyprof_memsignal);
}
-
void
toyprof_init_glib_memtable (const gchar *file_name,
gint logger_signal)
@@ -179,7 +163,6 @@ toyprof_init_glib_memtable (const gchar *file_name,
signal (toyprof_logger_signal, toyprof_memsignal);
}
}
-
guint
toyprof_start_leak_logger (void)
{
@@ -188,7 +171,6 @@ toyprof_start_leak_logger (void)
pthread_mutex_unlock (&profile_mutex);
return toyprof_stamp;
}
-
static void
toyprof_dump_leaks_U (guint leak_logger_stamp,
gint fd)
@@ -210,7 +192,6 @@ toyprof_dump_leaks_U (guint leak_logger_stamp,
}
}
}
-
void
toyprof_dump_leaks (guint leak_logger_stamp,
gint fd)
@@ -219,7 +200,6 @@ toyprof_dump_leaks (guint leak_logger_stamp,
toyprof_dump_leaks_U (leak_logger_stamp, fd);
pthread_mutex_unlock (&profile_mutex);
}
-
static void
memlist_add (MemHeader *h,
size_t n_bytes)
@@ -236,7 +216,6 @@ memlist_add (MemHeader *h,
toyprof_memtotal += h->n_bytes;
pthread_mutex_unlock (&profile_mutex);
}
-
static void
memlist_remove (MemHeader *h)
{
@@ -252,7 +231,6 @@ memlist_remove (MemHeader *h)
h->next = NULL;
h->prev = NULL;
}
-
static gpointer
toyprof_malloc (gsize n_bytes)
{
@@ -264,19 +242,16 @@ toyprof_malloc (gsize n_bytes)
backtrace (h->traces, STACK_TRACE_DEPTH);
return h + 1;
}
-
static void
toyprof_free (gpointer mem)
{
MemHeader *h = mem;
-
h -= 1;
memlist_remove (h);
memset (h, 0xaa, HEADER_SIZE + h->n_bytes);
standard_free (h);
memleak_handle_jobs ();
}
-
static gpointer
toyprof_realloc (gpointer mem,
gsize n_bytes)
@@ -289,7 +264,6 @@ toyprof_realloc (gpointer mem,
toyprof_free (mem);
return NULL;
}
-
h -= 1;
memlist_remove (h);
tmp = standard_realloc (h, HEADER_SIZE + n_bytes);
@@ -305,7 +279,6 @@ toyprof_realloc (gpointer mem,
backtrace (h->traces, STACK_TRACE_DEPTH);
return h + 1;
}
-
static GMemVTable mprof_table = {
toyprof_malloc,
toyprof_realloc,
@@ -315,8 +288,6 @@ static GMemVTable mprof_table = {
NULL, /* try_realloc */
};
GMemVTable *toyprof_mem_table = &mprof_table;
-
-
#else /* !__GLIBC__ || __GLIBC__ < 2 */
void
toyprof_init_glib_memtable (const gchar *file_name,
diff --git a/sfi/toyprof-mem.hh b/sfi/toyprof-mem.hh
index f1f4b5e..7cc41f3 100644
--- a/sfi/toyprof-mem.hh
+++ b/sfi/toyprof-mem.hh
@@ -2,12 +2,8 @@
// TOYPROF - Poor man's profiling toy
#ifndef __TOYPROF_MEM_H__
#define __TOYPROF_MEM_H__
-
#include <glib.h>
-
-
G_BEGIN_DECLS
-
/* causes toyprof to setup hooks via g_mem_set_vtable() */
void toyprof_init_glib_memtable (const gchar *file_name,
gint logger_signal);
@@ -16,10 +12,7 @@ guint toyprof_start_leak_logger (void);
/* report memory statistics */
void toyprof_dump_leaks (guint leak_logger_stamp,
gint fd);
-
/* total amount of memory currently allocated */
extern volatile gulong toyprof_memtotal;
-
G_END_DECLS
-
#endif /* __TOYPROF_MEM_H__ */
diff --git a/sfi/toyprof.c b/sfi/toyprof.c
index 817c296..59003bb 100644
--- a/sfi/toyprof.c
+++ b/sfi/toyprof.c
@@ -1,9 +1,7 @@
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
// TOYPROF - Poor man's profiling toy
#include "toyprof.h"
-
#ifdef TOYPROF_GNUC_NO_INSTRUMENT /* only have this if toyprof is enabled */
-
/* --- configuration --- */
/* TOYPROF_PENTIUM - define this to 1 if you're going to run the compiled
* program on an Intel Pentium(R) uni-processor machine.
@@ -27,8 +25,6 @@
#define TOYPROF_AUTOSTART 1
#define TOYPROF_DISABLE 1
#define TOYPROF_EXIT -1
-
-
/* --- implementation --- */
#define _GNU_SOURCE
#include <string.h>
@@ -43,8 +39,6 @@
#include <fcntl.h>
#include <link.h>
#include <elf.h>
-
-
/* --- common/useful macros --- */
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -69,15 +63,10 @@
#define TOYPROF_CHECK_ALLOC(mem) ({ if (!mem) TOYPROF_ABORT ("{m|re}alloc() failed"); })
#define TOYPROF_SYMBOL_ALIAS(alias_name, symbol) \
extern __typeof (symbol) alias_name __attribute__ ((alias (#symbol)))
-
-
/* --- time stamping --- */
#if defined (TOYPROF_PENTIUM) && TOYPROF_PENTIUM == 1
-
#define ToyprofStamp unsigned long long int
-
#define toyprof_clock_name() ("Pentium(R) RDTSC - CPU clock cycle counter")
-
/* capturing time stamps via rdtsc can produce inaccurate results due
* to parallel instruction execution. so we issue cpuid as serializaion
* barrier first.
@@ -94,9 +83,7 @@
(stamp) <<= 32; \
(stamp) += low; \
})
-
#define toyprof_stamp_ticks() (toyprof_stampfreq)
-
/* special case (fstamp) > (lstamp), this should never happen
* because we always stamp fstamp first, and invoke rdtsc after
* a serialization barrier (cpuid). in case this still happens
@@ -110,9 +97,7 @@
TOYPROF_ABORT ("pentium CPU clock warped backwards, running on SMP?"); \
diff = (lstamp) - (fstamp); diff; \
})
-
static unsigned long long int toyprof_stampfreq = 0;
-
static void TOYPROF_GNUC_NO_INSTRUMENT
toyprof_stampinit (void)
{ /* grep "cpu MHz : 551.256" from /proc/cpuinfo */
@@ -137,29 +122,19 @@ toyprof_stampinit (void)
}
TOYPROF_ASSERT (toyprof_stampfreq > 0);
}
-
#else /* !TOYPROF_PENTIUM */
-
#define ToyprofStamp struct timeval
-
#define toyprof_clock_name() ("Glibc gettimeofday(2)")
-
#define toyprof_stampinit() /* nothing */
-
#define toyprof_stamp(st) gettimeofday (&(st), 0)
-
#define toyprof_stamp_ticks() (1000000)
-
#define toyprof_elapsed(fstamp, lstamp) ({ \
unsigned long long int first = (fstamp).tv_sec * toyprof_stamp_ticks () + (fstamp).tv_usec; \
unsigned long long int last = (lstamp).tv_sec * toyprof_stamp_ticks () + (lstamp).tv_usec; \
last -= first; \
last; \
})
-
#endif /* !TOYPROF_PENTIUM */
-
-
/* --- profiling structures --- */
typedef struct {
void *cur_func, *call_site, *caller;
@@ -174,15 +149,11 @@ typedef struct {
unsigned int stack_length;
void **stack;
} ToyprofRoot;
-
-
/* --- prototypes --- */
static int toyprof_dladdr (const void *address,
Dl_info *info) TOYPROF_GNUC_NO_INSTRUMENT;
static char* toyprof_dlname (void *addr,
int *resolved_p) TOYPROF_GNUC_NO_INSTRUMENT;
-
-
/* --- variables --- */
static ToyprofRoot toyprof_root = { 0, NULL, 0, NULL, };
#ifdef TOYPROF_AUTOSTART
@@ -190,14 +161,11 @@ static volatile ToyprofBehaviour toyprof_behaviour = TOYPROF_PROFILE_TIMING;
#else
static volatile ToyprofBehaviour toyprof_behaviour = TOYPROF_OFF;
#endif
-
-
/* --- functions --- */
static inline unsigned long TOYPROF_GNUC_NO_INSTRUMENT
toyprof_upper_power2 (unsigned long number)
{
unsigned long n_bits = 0;
-
/* this implements: number ? 1 << g_bit_storage (number - 1) : 0 */
if (!number--)
return 0;
@@ -209,13 +177,11 @@ toyprof_upper_power2 (unsigned long number)
while (number);
return 1 << n_bits;
}
-
static inline void TOYPROF_GNUC_NO_INSTRUMENT
toyprof_push (ToyprofRoot *proot,
void *data)
{
unsigned int i, new_size;
-
i = proot->stack_length++;
new_size = toyprof_upper_power2 (proot->stack_length);
if (new_size != toyprof_upper_power2 (i))
@@ -228,14 +194,12 @@ toyprof_push (ToyprofRoot *proot,
#define toyprof_pop(proot) ({ (proot)->stack[--(proot)->stack_length]; })
#define toyprof_peek(proot) ((proot)->stack[(proot)->stack_length - 1])
#define toyprof_peekpeek(proot) ((proot)->stack[(proot)->stack_length - 2])
-
static inline ToyprofEntry* TOYPROF_GNUC_NO_INSTRUMENT
toyprof_insert (ToyprofRoot *proot,
unsigned int pos)
{
unsigned int index, new_size, old_size = proot->n_nodes;
ToyprofEntry *node;
-
index = proot->n_nodes++;
new_size = toyprof_upper_power2 (proot->n_nodes);
if (new_size != toyprof_upper_power2 (old_size))
@@ -245,10 +209,8 @@ toyprof_insert (ToyprofRoot *proot,
}
node = proot->nodes + pos;
memmove (node + 1, node, (index - pos) * sizeof (node[0]));
-
return node;
}
-
static inline ToyprofEntry* TOYPROF_GNUC_NO_INSTRUMENT
toyprof_lookup (ToyprofRoot *proot,
void *cur_func,
@@ -259,13 +221,11 @@ toyprof_lookup (ToyprofRoot *proot,
{
ToyprofEntry *check, *nodes = proot->nodes;
unsigned int n_nodes = proot->n_nodes;
-
nodes -= 1;
do
{
register unsigned int i;
register int cmp;
-
i = (n_nodes + 1) >> 1;
check = nodes + i;
cmp = (cur_func < check->cur_func ? -1 :
@@ -288,7 +248,6 @@ toyprof_lookup (ToyprofRoot *proot,
}
return NULL;
}
-
void TOYPROF_GNUC_NO_INSTRUMENT
toyprof_dump_stats (int fd)
{
@@ -296,9 +255,7 @@ toyprof_dump_stats (int fd)
double n_ticks;
unsigned int i;
ToyprofBehaviour saved_behaviour = toyprof_behaviour;
-
toyprof_behaviour = 0; /* stop profiling */
-
n_ticks = toyprof_stamp_ticks ();
dprintf (fd, "\n");
dprintf (fd, "TOYPROFMETA: device = %s\n", toyprof_clock_name ());
@@ -315,7 +272,6 @@ toyprof_dump_stats (int fd)
ToyprofEntry *e = toyprof_root.nodes + i;
char *name, *caller, *string;
int nresolved, cresolved;
-
name = toyprof_dlname (e->cur_func, &nresolved);
caller = toyprof_dlname (e->call_site, &cresolved);
asprintf (&string, " %.16f %.16f %.16f %llu",
@@ -330,16 +286,13 @@ toyprof_dump_stats (int fd)
free (name);
free (caller);
}
-
toyprof_behaviour = saved_behaviour;
}
-
static void TOYPROF_GNUC_NO_INSTRUMENT
toyprof_atexit (void)
{
toyprof_dump_stats (2);
}
-
static void TOYPROF_GNUC_NO_INSTRUMENT TOYPROF_GNUC_UNUSED
toyprof_func_enter (void *cur_func,
void *call_site)
@@ -347,11 +300,9 @@ toyprof_func_enter (void *cur_func,
ToyprofStamp stamp;
void *caller;
ToyprofEntry *e, *c;
-
toyprof_stamp (stamp); /* stop timing */
if (!toyprof_behaviour)
return;
-
if (!toyprof_root.n_nodes) /* initialization */
{
toyprof_stampinit ();
@@ -359,16 +310,13 @@ toyprof_func_enter (void *cur_func,
toyprof_push (&toyprof_root, NULL); /* make peekpeek for caller's parent work */
atexit (toyprof_atexit);
}
-
/* last function entry we recognized */
caller = toyprof_peek (&toyprof_root);
-
/* get profiling entry for this (function,caller) combination */
e = toyprof_lookup (&toyprof_root, cur_func, caller, FALSE);
if (!e || e->cur_func != cur_func || e->caller != caller) /* none or inexact match */
{
unsigned int insertion_pos;
-
/* no profiling entry found, need to insert a new one */
if (e)
{
@@ -388,23 +336,17 @@ toyprof_func_enter (void *cur_func,
if ((toyprof_behaviour & TOYPROF_TRACE_FUNCTIONS) == TOYPROF_TRACE_FUNCTIONS)
e->tmp_name = toyprof_dlname (e->cur_func, NULL);
}
-
/* update profiling stats for this function */
e->n_calls += 1;
-
/* update profiling stats for our caller (don't account child function time) */
c = toyprof_lookup (&toyprof_root, caller, toyprof_peekpeek (&toyprof_root), TRUE);
if (c) /* might not have a caller, e.g. in main() */
c->uticks += toyprof_elapsed (c->stamp, stamp);
-
if ((toyprof_behaviour & TOYPROF_TRACE_FUNCTIONS) == TOYPROF_TRACE_FUNCTIONS)
dprintf (2, "ENTER: %s\n", e->tmp_name);
-
toyprof_push (&toyprof_root, cur_func); /* preserve caller for next entry */
-
toyprof_stamp (e->stamp); /* start timing */
}
-
static void TOYPROF_GNUC_NO_INSTRUMENT TOYPROF_GNUC_UNUSED
toyprof_func_exit (void *cur_func,
void *call_site)
@@ -412,40 +354,31 @@ toyprof_func_exit (void *cur_func,
ToyprofStamp stamp;
void *caller;
ToyprofEntry *e, *c;
-
toyprof_stamp (stamp); /* stop timing */
if (!toyprof_behaviour)
return;
-
toyprof_pop (&toyprof_root); /* throw away preserved caller for entries */
-
/* last function entry we recognized */
caller = toyprof_peek (&toyprof_root);
-
/* get profiling entry for this (function,caller) combination */
e = toyprof_lookup (&toyprof_root, cur_func, caller, TRUE);
/* if we got to this pair in _exit, we must have handled it in _entry */
TOYPROF_ASSERT (e && e->cur_func == cur_func && e->caller == caller);
-
/* update profiling stats for this function */
e->uticks += toyprof_elapsed (e->stamp, stamp);
-
if ((toyprof_behaviour & TOYPROF_TRACE_FUNCTIONS) == TOYPROF_TRACE_FUNCTIONS)
dprintf (2, "EXIT: %s (n_calls:%lld)\n", e->tmp_name, e->n_calls);
-
/* update profiling stats for our caller (child exited, restart accounting) */
c = toyprof_lookup (&toyprof_root, caller, toyprof_peekpeek (&toyprof_root), TRUE);
if (c)
toyprof_stamp (c->stamp); /* start timing */
}
-
void TOYPROF_GNUC_NO_INSTRUMENT
toyprof_set_profiling (ToyprofBehaviour behav)
{
toyprof_behaviour = behav & (TOYPROF_PROFILE_TIMING |
TOYPROF_TRACE_FUNCTIONS);
}
-
static char* TOYPROF_GNUC_NO_INSTRUMENT
toyprof_dlname (void *addr,
int *resolved_p)
@@ -454,7 +387,6 @@ toyprof_dlname (void *addr,
int result = toyprof_dladdr (addr, &dlinfo);
char *name;
int resolved = TRUE;
-
if (result)
{
if (dlinfo.dli_saddr == addr && dlinfo.dli_sname)
@@ -479,10 +411,8 @@ toyprof_dlname (void *addr,
}
if (resolved_p)
*resolved_p = resolved;
-
return name;
}
-
static int TOYPROF_GNUC_NO_INSTRUMENT
toyprof_dladdr (const void *sym_address,
Dl_info *dlinfo)
@@ -493,7 +423,6 @@ toyprof_dladdr (const void *sym_address,
ElfW(Sym) *sym, *symtab, *msym = NULL;
ElfW(Addr) strtabsize;
const char *mstrtab = NULL, *strtab;
-
/* let dladdr() fill in fbase and name */
if (!dladdr (sym_address, dlinfo))
return 0;
@@ -507,7 +436,6 @@ toyprof_dladdr (const void *sym_address,
lmain = link;
if (!link) /* dladdr() returned main module */
dlinfo->dli_fbase = (void*) lmain->l_addr; /* always 0 */
-
/* now lets do our own run to find the correct module */
best = NULL;
for (link = _r_debug.r_map; link; link = link->l_next)
@@ -520,10 +448,8 @@ toyprof_dladdr (const void *sym_address,
}
if (!best)
best = lmain;
-
next_module:
link = best;
-
strtabsize = 0;
strtab = NULL;
symtab = NULL;
@@ -534,17 +460,14 @@ toyprof_dladdr (const void *sym_address,
strtab = (void*) dyn->d_un.d_ptr;
else if (dyn->d_tag == DT_STRSZ)
strtabsize = dyn->d_un.d_val;
-
if (!strtab || !symtab || !strtabsize || (void*) strtab < (void*) symtab)
return 1;
-
for (sym = symtab; (void*) sym < (void*) strtab; sym++)
{
if (0)
dprintf (2, "SYM: %5x %8x %5x %3x %3x %5x \"%s\"\n",
sym->st_name, sym->st_value, sym->st_size, sym->st_info & 15,
sym->st_other, sym->st_shndx, strtab + sym->st_name);
-
if (/* confine matches to symbol boundaries */
addr >= sym->st_value + link->l_addr &&
addr <= sym->st_value + link->l_addr + sym->st_size &&
@@ -559,18 +482,15 @@ toyprof_dladdr (const void *sym_address,
msym = sym;
mstrtab = strtab;
mlink = link;
-
// dprintf (2, "CANDIDATE(%p) \"%s\"\n", msym, msym ? mstrtab + msym->st_name : NULL);
}
}
// dprintf (2, "MATCH(%p) \"%s\"\n", msym, msym ? mstrtab + msym->st_name : NULL);
-
if (best != lmain)
{
best = lmain;
goto next_module;
}
-
if (msym)
{
if (dlinfo->dli_fbase != (void*) mlink->l_addr)
@@ -583,10 +503,8 @@ toyprof_dladdr (const void *sym_address,
}
return 1;
}
-
#if !defined (TOYPROF_DISABLE) || TOYPROF_DISABLE == 0
TOYPROF_SYMBOL_ALIAS (__cyg_profile_func_enter, toyprof_func_enter);
TOYPROF_SYMBOL_ALIAS (__cyg_profile_func_exit, toyprof_func_exit);
#endif
-
#endif /* TOYPROF_GNUC_NO_INSTRUMENT, enable toyprof check */
diff --git a/sfi/toyprof.hh b/sfi/toyprof.hh
index 8535b1d..160c0f3 100644
--- a/sfi/toyprof.hh
+++ b/sfi/toyprof.hh
@@ -2,28 +2,21 @@
// TOYPROF - Poor man's profiling toy
#ifndef __TOYPROF_H__
#define __TOYPROF_H__
-
#define _GNU_SOURCE
#include <stdlib.h> /* to define __GLIBC__ and __GLIBC_MINOR__ */
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
-
#if defined (__GNUC__) && defined (__GLIBC__) && /* have GCC && GLIBC */ \
((__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || /* GCC >= 2.95 */ \
__GNUC__ > 2) && /* GCC >= 3.0.0 */ \
((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || /* GLIBC >= 2.2 */ \
__GLIBC__ > 2) /* GLIBC > 2 */
-
/* function flagging */
#define TOYPROF_GNUC_NO_INSTRUMENT __attribute__((no_instrument_function))
#define TOYPROF_GNUC_UNUSED __attribute__((unused))
-
/* print out profiling statistics to filedescriptor */
void toyprof_dump_stats (int fd) TOYPROF_GNUC_NO_INSTRUMENT;
-
/* profiling types */
typedef enum /*< skip >*/
{
@@ -31,15 +24,10 @@ typedef enum /*< skip >*/
TOYPROF_PROFILE_TIMING = 0x1,
TOYPROF_TRACE_FUNCTIONS = 0x3
} ToyprofBehaviour;
-
/* enable/disable profiling and optionally trace functions */
void toyprof_set_profiling (ToyprofBehaviour behav) TOYPROF_GNUC_NO_INSTRUMENT;
-
#endif /* >= GCC-2.95 */
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
#endif /* __TOYPROF_H__ */
diff --git a/shell/bsescm.cc b/shell/bsescm.cc
index 12cce22..bf11ab2 100644
--- a/shell/bsescm.cc
+++ b/shell/bsescm.cc
@@ -11,20 +11,14 @@
#include <sys/resource.h>
#include "bsescminterp.hh"
#include "topconfig.h"
-
#define PRG_NAME "bsescm"
-
#define BSE_EXIT_STATUS 102
-
-
/* --- prototypes --- */
static void gh_main (gint argc,
gchar *argv[]);
static void shell_parse_args (gint *argc_p,
gchar ***argv_p);
static void shell_print_usage (void);
-
-
/* --- variables --- */
static gint bse_scm_pipe[2] = { -1, -1 };
static gchar *bse_scm_eval_expr = NULL;
@@ -34,7 +28,6 @@ static gboolean bse_scm_auto_play = TRUE;
static SfiComPort *bse_scm_port = NULL;
static SfiGlueContext *bse_scm_context = NULL;
static const gchar *boot_script_path = BSE_PATH_SCRIPTS;
-
/* --- functions --- */
static void
port_closed (SfiComPort *port,
@@ -44,40 +37,33 @@ port_closed (SfiComPort *port,
if (port)
exit (BSE_EXIT_STATUS);
}
-
static void
dummy_dispatch (void *foo)
{
// nothing to do
}
-
int
main (int argc,
char *argv[])
{
const gchar *env_str;
GSource *source;
-
sfi_init (&argc, &argv, "BSESCM", NULL);
bse_init_textdomain_only();
setlocale (LC_ALL, "");
-
env_str = g_getenv ("BSESCM_SLEEP4GDB");
if (env_str && atoi (env_str) >= 3)
{
g_message ("going into sleep mode due to debugging request (pid=%u)", getpid ());
g_usleep (2147483647);
}
-
shell_parse_args (&argc, &argv);
-
if (env_str && (atoi (env_str) >= 2 ||
(atoi (env_str) >= 1 && !bse_scm_enable_register)))
{
g_message ("going into sleep mode due to debugging request (pid=%u)", getpid ());
g_usleep (2147483647);
}
-
if (bse_scm_pipe[0] >= 0 && bse_scm_pipe[1] >= 0)
{
bse_scm_port = sfi_com_port_from_pipe (PRG_NAME, bse_scm_pipe[0], bse_scm_pipe[1]);
@@ -89,29 +75,22 @@ main (int argc,
}
bse_scm_context = sfi_glue_encoder_context (bse_scm_port);
}
-
if (!bse_scm_context)
{
/* start our own core thread */
bse_init_async (&argc, &argv, "BSESCM", NULL);
bse_scm_context = bse_init_glue_context (PRG_NAME);
}
-
/* now that the BSE thread runs, drop scheduling priorities if we have any */
setpriority (PRIO_PROCESS, getpid(), 0);
-
/* setup main context to be able to wait for events from bse in bse_scm_context_iteration */
sfi_thread_set_wakeup (BirnetThreadWakeup (g_main_context_wakeup), g_main_context_default(), NULL);
source = g_source_simple (G_PRIORITY_DEFAULT, GSourcePending (sfi_glue_context_pending), dummy_dispatch, NULL, NULL, NULL);
g_source_attach (source, NULL);
g_source_unref (source);
-
gh_enter (argc, argv, gh_main);
-
return 0;
}
-
-
static void
gh_main (int argc,
char *argv[])
@@ -122,14 +101,11 @@ gh_main (int argc,
else
bse_scm_enable_server (TRUE);
sfi_glue_context_push (bse_scm_context);
-
/* initialize interpreter */
bse_scm_interp_init ();
-
/* exec Bse Scheme bootup code */
const gchar *boot_script = g_intern_printf ("%s/%s", boot_script_path, "bse-scm-glue.boot");
gh_load (boot_script);
-
/* eval, auto-play or interactive */
if (bse_scm_eval_expr)
gh_eval_str (bse_scm_eval_expr);
@@ -165,7 +141,6 @@ gh_main (int argc,
gh_repl (argc, argv);
}
}
-
/* shutdown */
sfi_glue_context_pop ();
if (bse_scm_port)
@@ -175,7 +150,6 @@ gh_main (int argc,
}
sfi_glue_context_destroy (bse_scm_context);
}
-
static void
shell_parse_args (gint *argc_p,
gchar ***argv_p)
@@ -184,7 +158,6 @@ shell_parse_args (gint *argc_p,
gchar **argv = *argv_p;
guint i, e;
gboolean initialize_bse_and_exit = FALSE;
-
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "--") == 0 ||
@@ -194,7 +167,6 @@ shell_parse_args (gint *argc_p,
else if (strcmp (argv[i], "--g-fatal-warnings") == 0)
{
GLogLevelFlags fatal_mask;
-
fatal_mask = g_log_set_always_fatal (GLogLevelFlags (G_LOG_FATAL_MASK));
fatal_mask = GLogLevelFlags (fatal_mask | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
g_log_set_always_fatal (fatal_mask);
@@ -306,7 +278,6 @@ shell_parse_args (gint *argc_p,
exit (0);
}
}
-
e = 1;
for (i = 1; i < argc; i++)
if (argv[i])
@@ -316,14 +287,12 @@ shell_parse_args (gint *argc_p,
argv[i] = NULL;
}
*argc_p = e;
-
if (initialize_bse_and_exit)
{
bse_init_async (argc_p, argv_p, "BSESCM", NULL);
exit (0);
}
}
-
static void
shell_print_usage (void)
{
diff --git a/shell/bsescminterp.cc b/shell/bsescminterp.cc
index d7c1b9b..ec5d704 100644
--- a/shell/bsescminterp.cc
+++ b/shell/bsescminterp.cc
@@ -4,7 +4,6 @@
#include "bsescminterp.hh"
#include <sfi/sficomwire.hh>
#include <bse/bseglue.hh>
-
/* Data types:
* SCM
* Constants:
@@ -22,18 +21,14 @@
* SCM gh_catch(SCM tag, scm_t_catch_body body, void *body_data,
* scm_catch_handler_t handler, void *handler_data);
*/
-
#define BSE_SCM_NIL SCM_UNSPECIFIED
#define BSE_SCM_NILP(x) ((x) == SCM_UNSPECIFIED)
-
-
/* allow guile version special casing */
#define GUILE_CHECK_VERSION(major,minor,micro) \
(SCM_MAJOR_VERSION > (major) || \
(SCM_MAJOR_VERSION == (major) && SCM_MINOR_VERSION > (minor)) || \
(SCM_MAJOR_VERSION == (major) && SCM_MINOR_VERSION == (minor) && \
SCM_MICRO_VERSION >= (micro)))
-
#if GUILE_CHECK_VERSION (1, 8, 0)
#define BSE_SCM_DEFER_INTS() do ; while (0)
#define BSE_SCM_ALLOW_INTS() do ; while (0)
@@ -59,11 +54,9 @@
#endif
#define IS_SCM_BIG(s_scm) SCM_BIGP (s_scm)
#define IS_SCM_SFI_NUM(s_scm) (IS_SCM_INT (s_scm) || IS_SCM_BIG (s_scm))
-
/* --- prototypes --- */
static SCM bse_scm_from_value (const GValue *value);
static GValue* bse_value_from_scm (SCM sval);
-
/* --- misc utilities --- */
static inline SfiNum
num_from_scm (SCM s_num)
@@ -73,7 +66,6 @@ num_from_scm (SCM s_num)
num = SFI_NUM_FROM_SCM (s_num);
return num;
}
-
static inline gchar*
strdup_from_scm (SCM s_string)
{
@@ -87,7 +79,6 @@ strdup_from_scm (SCM s_string)
else
return NULL;
}
-
static inline GValue*
string_value_from_scm (SCM s_string)
{
@@ -101,7 +92,6 @@ string_value_from_scm (SCM s_string)
else
return sfi_value_string (NULL);
}
-
static inline GValue*
choice_value_from_scm (SCM s_string)
{
@@ -115,7 +105,6 @@ choice_value_from_scm (SCM s_string)
else
return sfi_value_choice (NULL);
}
-
/* --- SCM GC hooks --- */
static gulong tc_glue_gc_cell = 0;
#define SCM_IS_GLUE_GC_CELL(sval) (SCM_SMOB_PREDICATE (tc_glue_gc_cell, sval))
@@ -144,7 +133,6 @@ bse_scm_enter_gc (SCM *scm_gc_list,
SCM_NEWSMOB (s_cell, tc_glue_gc_cell, gc_cell);
*scm_gc_list = gh_cons (s_cell, *scm_gc_list);
}
-
static SCM
bse_scm_mark_gc_cell (SCM scm_gc_cell) /* called from any thread */
{
@@ -153,7 +141,6 @@ bse_scm_mark_gc_cell (SCM scm_gc_cell) /* called from any thread */
/* scm_gc_mark (gc_cell->something); */
return SCM_BOOL_F;
}
-
static scm_sizet
bse_scm_free_gc_cell (SCM scm_gc_cell) /* called from any thread */
{
@@ -163,8 +150,6 @@ bse_scm_free_gc_cell (SCM scm_gc_cell) /* called from any thread */
g_free (gc_cell);
return 0;
}
-
-
/* --- SCM Glue GC Plateau --- */
static gulong tc_glue_gc_plateau = 0;
#define SCM_IS_GLUE_GC_PLATEAU(sval) (SCM_SMOB_PREDICATE (tc_glue_gc_plateau, sval))
@@ -174,7 +159,6 @@ typedef struct {
guint size_hint;
gboolean active_plateau;
} GcPlateau;
-
SCM
bse_scm_make_gc_plateau (guint size_hint)
{
@@ -186,7 +170,6 @@ bse_scm_make_gc_plateau (guint size_hint)
SCM_NEWSMOB (s_gcplateau, tc_glue_gc_plateau, gp);
return s_gcplateau;
}
-
void
bse_scm_destroy_gc_plateau (SCM s_gcplateau)
{
@@ -202,7 +185,6 @@ bse_scm_destroy_gc_plateau (SCM s_gcplateau)
sfi_glue_gc_run ();
}
}
-
static scm_sizet
bse_scm_gc_plateau_free (SCM s_gcplateau) /* called from any thread */
{
@@ -211,8 +193,6 @@ bse_scm_gc_plateau_free (SCM s_gcplateau) /* called from any thread */
g_free (gp);
return 0;
}
-
-
/* --- SCM Glue Record --- */
static gulong tc_glue_rec = 0;
#define SCM_IS_GLUE_REC(sval) (SCM_SMOB_PREDICATE (tc_glue_rec, sval))
@@ -221,14 +201,11 @@ static SCM
bse_scm_from_glue_rec (SfiRec *rec)
{
SCM s_rec = 0;
-
g_return_val_if_fail (rec != NULL, SCM_UNSPECIFIED);
-
sfi_rec_ref (rec);
SCM_NEWSMOB (s_rec, tc_glue_rec, rec);
return s_rec;
}
-
static SCM
bse_scm_glue_rec_new (SCM sfields)
{
@@ -251,7 +228,6 @@ bse_scm_glue_rec_new (SCM sfields)
}
return s_rec;
}
-
static scm_sizet
bse_scm_free_glue_rec (SCM scm_rec) /* called from any thread */
{
@@ -259,23 +235,19 @@ bse_scm_free_glue_rec (SCM scm_rec) /* called from any thread */
sfi_rec_unref (rec);
return 0;
}
-
SCM
bse_scm_glue_rec_print (SCM scm_rec)
{
SCM port = scm_current_output_port ();
SfiRec *rec;
guint i;
-
SCM_ASSERT (SCM_IS_GLUE_REC (scm_rec), scm_rec, SCM_ARG1, "bse-rec-print");
-
rec = SCM_GET_GLUE_REC (scm_rec);
scm_puts ("'(", port);
for (i = 0; i < rec->n_fields; i++)
{
const gchar *name = rec->field_names[i];
GValue *value = rec->fields + i;
-
if (i)
scm_puts (" ", port);
scm_puts ("(", port);
@@ -285,10 +257,8 @@ bse_scm_glue_rec_print (SCM scm_rec)
scm_puts (")", port);
}
scm_puts (")", port);
-
return SCM_UNSPECIFIED;
}
-
SCM
bse_scm_glue_rec_get (SCM scm_rec,
SCM s_field)
@@ -298,10 +268,8 @@ bse_scm_glue_rec_get (SCM scm_rec,
SfiRec *rec;
gchar *name;
SCM s_val;
-
SCM_ASSERT (SCM_IS_GLUE_REC (scm_rec), scm_rec, SCM_ARG1, "bse-rec-get");
SCM_ASSERT (IS_SCM_SYMBOL (s_field), s_field, SCM_ARG2, "bse-rec-get");
-
rec = SCM_GET_GLUE_REC (scm_rec);
name = strdup_from_scm (s_field);
val = sfi_rec_get (rec, name);
@@ -310,11 +278,9 @@ bse_scm_glue_rec_get (SCM scm_rec,
s_val = bse_scm_from_value (val);
else
s_val = SCM_UNSPECIFIED;
-
bse_scm_destroy_gc_plateau (gcplateau);
return s_val;
}
-
SCM
bse_scm_glue_rec_set (SCM scm_rec,
SCM s_field,
@@ -324,10 +290,8 @@ bse_scm_glue_rec_set (SCM scm_rec,
GValue *val;
SfiRec *rec;
gchar *name;
-
SCM_ASSERT (SCM_IS_GLUE_REC (scm_rec), scm_rec, SCM_ARG1, "bse-rec-set");
SCM_ASSERT (IS_SCM_SYMBOL (s_field), s_field, SCM_ARG2, "bse-rec-set");
-
rec = SCM_GET_GLUE_REC (scm_rec);
val = bse_value_from_scm (s_value);
if (!val)
@@ -338,8 +302,6 @@ bse_scm_glue_rec_set (SCM scm_rec,
bse_scm_destroy_gc_plateau (gcplateau);
return SCM_UNSPECIFIED;
}
-
-
/* --- SCM Glue Proxy --- */
static gulong tc_glue_proxy = 0;
#define SCM_IS_GLUE_PROXY(sval) (SCM_SMOB_PREDICATE (tc_glue_proxy, sval))
@@ -354,17 +316,14 @@ bse_scm_make_glue_proxy (SfiProxy proxy)
SCM_NEWSMOB (s_proxy, tc_glue_proxy, proxy);
return s_proxy;
}
-
static SCM
bse_scm_proxy_equalp (SCM scm_p1,
SCM scm_p2)
{
SfiProxy p1 = SCM_GET_GLUE_PROXY (scm_p1);
SfiProxy p2 = SCM_GET_GLUE_PROXY (scm_p2);
-
return SCM_BOOL (p1 == p2);
}
-
static int
bse_scm_proxy_print (SCM scm_p1,
SCM port,
@@ -378,7 +337,6 @@ bse_scm_proxy_print (SCM scm_p1,
scm_puts (">", port);
return 1;
}
-
static SCM
bse_scm_proxy_is_null (SCM scm_proxy)
{
@@ -389,38 +347,30 @@ bse_scm_proxy_is_null (SCM scm_proxy)
}
return SCM_BOOL_F;
}
-
static SCM
bse_scm_proxy_get_null (SCM scm_proxy)
{
return glue_null_proxy;
}
-
/* --- SCM procedures --- */
static gboolean server_enabled = FALSE;
-
void
bse_scm_enable_server (gboolean enabled)
{
server_enabled = enabled != FALSE;
}
-
SCM
bse_scm_server_get (void)
{
SfiProxy server;
SCM s_retval;
-
static const int bse_server_id = 1; /* HACK */
-
BSE_SCM_DEFER_INTS ();
server = server_enabled ? bse_server_id : 0;
BSE_SCM_ALLOW_INTS ();
s_retval = bse_scm_make_glue_proxy (server);
-
return s_retval;
}
-
static GValue*
bse_value_from_scm (SCM sval)
{
@@ -464,7 +414,6 @@ bse_value_from_scm (SCM sval)
value = NULL;
return value;
}
-
static SCM
bse_scm_from_value (const GValue *value)
{
@@ -530,7 +479,6 @@ bse_scm_from_value (const GValue *value)
bse_scm_destroy_gc_plateau (gcplateau);
return sval;
}
-
SCM
bse_scm_glue_set_prop (SCM s_proxy,
SCM s_prop_name,
@@ -541,16 +489,12 @@ bse_scm_glue_set_prop (SCM s_proxy,
SfiProxy proxy;
gchar *prop_name;
GValue *value;
-
SCM_ASSERT (SCM_IS_GLUE_PROXY (s_proxy), s_proxy, SCM_ARG1, "bse-glue-set-prop");
SCM_ASSERT (IS_SCM_STRING (s_prop_name), s_prop_name, SCM_ARG2, "bse-glue-set-prop");
-
BSE_SCM_DEFER_INTS ();
-
proxy = SCM_GET_GLUE_PROXY (s_proxy);
prop_name = strdup_from_scm (s_prop_name);
bse_scm_enter_gc (&gclist, prop_name, g_free, STRING_LENGTH_FROM_SCM (s_prop_name));
-
value = bse_value_from_scm (s_value);
if (value)
{
@@ -559,13 +503,10 @@ bse_scm_glue_set_prop (SCM s_proxy,
}
else
scm_wrong_type_arg ("bse-set-prop", SCM_ARG3, s_value);
-
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
return SCM_UNSPECIFIED;
}
-
SCM
bse_scm_glue_get_prop (SCM s_proxy,
SCM s_prop_name)
@@ -576,29 +517,22 @@ bse_scm_glue_get_prop (SCM s_proxy,
SfiProxy proxy;
gchar *prop_name;
const GValue *value;
-
SCM_ASSERT (SCM_IS_GLUE_PROXY (s_proxy), s_proxy, SCM_ARG1, "bse-glue-get-prop");
SCM_ASSERT (IS_SCM_STRING (s_prop_name), s_prop_name, SCM_ARG2, "bse-glue-get-prop");
-
BSE_SCM_DEFER_INTS ();
-
proxy = SCM_GET_GLUE_PROXY (s_proxy);
prop_name = strdup_from_scm (s_prop_name);
bse_scm_enter_gc (&gclist, prop_name, g_free, STRING_LENGTH_FROM_SCM (s_prop_name));
-
value = sfi_glue_proxy_get_property (proxy, prop_name);
if (value)
{
s_retval = bse_scm_from_value (value);
sfi_glue_gc_free_now ((void*) value, BseScmFreeFunc (sfi_value_free));
}
-
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
return s_retval;
}
-
SCM
bse_scm_glue_call (SCM s_proc_name,
SCM s_arg_list)
@@ -609,28 +543,22 @@ bse_scm_glue_call (SCM s_proc_name,
gchar *proc_name;
GValue *value;
SfiSeq *seq;
-
SCM_ASSERT (IS_SCM_STRING (s_proc_name), s_proc_name, SCM_ARG1, "bse-glue-call");
SCM_ASSERT (IS_SCM_PAIR (s_arg_list) || s_arg_list == SCM_EOL, s_arg_list, SCM_ARG2, "bse-glue-call");
-
BSE_SCM_DEFER_INTS ();
-
proc_name = strdup_from_scm (s_proc_name);
bse_scm_enter_gc (&gclist, proc_name, g_free, STRING_LENGTH_FROM_SCM (s_proc_name));
-
seq = sfi_seq_new ();
bse_scm_enter_gc (&gclist, seq, BseScmFreeFunc (sfi_seq_unref), 1024); // FIXME: GC callbacks may run in any thread
for (node = s_arg_list; IS_SCM_PAIR (node); node = SCM_CDR (node))
{
SCM arg = SCM_CAR (node);
-
value = bse_value_from_scm (arg);
if (!value)
break;
sfi_seq_append (seq, value);
sfi_value_free (value);
}
-
value = sfi_glue_call_seq (proc_name, seq);
sfi_seq_clear (seq);
if (value)
@@ -638,14 +566,10 @@ bse_scm_glue_call (SCM s_proc_name,
s_retval = bse_scm_from_value (value);
sfi_glue_gc_free_now (value, BseScmFreeFunc (sfi_value_free));
}
-
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
-
return s_retval;
}
-
typedef struct {
gulong proxy;
gchar *signal;
@@ -653,7 +577,6 @@ typedef struct {
guint n_args;
const GValue *args;
} SignalData;
-
static void
signal_data_free (gpointer data,
GClosure *closure)
@@ -664,26 +587,20 @@ signal_data_free (gpointer data,
g_free (sdata);
scm_gc_unprotect_object (s_lambda);
}
-
static SCM
signal_marshal_sproc (void *data)
{
SignalData *sdata = (SignalData*) data;
SCM s_ret, args = SCM_EOL;
guint i;
-
i = sdata->n_args;
g_return_val_if_fail (sdata->n_args > 0, SCM_UNSPECIFIED);
sdata->n_args = 0;
-
while (i--)
args = gh_cons (bse_scm_from_value (sdata->args + i), args);
-
s_ret = scm_apply (sdata->s_lambda, args, SCM_EOL);
-
return SCM_UNSPECIFIED;
}
-
static void
signal_closure_marshal (GClosure *closure,
GValue *return_value,
@@ -699,7 +616,6 @@ signal_closure_marshal (GClosure *closure,
scm_internal_cwdr ((scm_t_catch_body) signal_marshal_sproc, sdata,
scm_handle_by_message_noexit, const_cast<char*> ("BSE"), &stack_item);
}
-
SCM
bse_scm_signal_connect (SCM s_proxy,
SCM s_signal,
@@ -709,15 +625,11 @@ bse_scm_signal_connect (SCM s_proxy,
gulong id;
SignalData *sdata;
GClosure *closure;
-
SCM_ASSERT (SCM_IS_GLUE_PROXY (s_proxy), s_proxy, SCM_ARG1, "bse-signal-connect");
proxy = SCM_GET_GLUE_PROXY (s_proxy);
-
SCM_ASSERT (IS_SCM_STRING (s_signal), s_signal, SCM_ARG2, "bse-signal-connect");
SCM_ASSERT (gh_procedure_p (s_lambda), s_lambda, SCM_ARG3, "bse-signal-connect");
-
scm_gc_protect_object (s_lambda);
-
BSE_SCM_DEFER_INTS ();
sdata = g_new0 (SignalData, 1);
sdata->proxy = proxy;
@@ -728,36 +640,28 @@ bse_scm_signal_connect (SCM s_proxy,
g_closure_set_marshal (closure, signal_closure_marshal);
id = sfi_glue_signal_connect_closure (proxy, sdata->signal, closure, NULL);
BSE_SCM_ALLOW_INTS ();
-
return gh_ulong2scm (id);
}
-
SCM
bse_scm_signal_disconnect (SCM s_proxy,
SCM s_handler_id)
{
SfiProxy proxy;
gulong id;
-
SCM_ASSERT (SCM_IS_GLUE_PROXY (s_proxy), s_proxy, SCM_ARG1, "bse-signal-disconnect");
proxy = SCM_GET_GLUE_PROXY (s_proxy);
-
id = scm_num2ulong (s_handler_id, SCM_ARG2, "bse-signal-disconnect");
if (id < 1)
scm_out_of_range ("bse-signal-disconnect", s_handler_id);
-
sfi_glue_signal_disconnect (proxy, id);
-
return SCM_UNSPECIFIED;
}
-
SCM
bse_scm_choice_match (SCM s_ch1,
SCM s_ch2)
{
SCM_ASSERT (IS_SCM_SYMBOL (s_ch1), s_ch1, SCM_ARG1, "bse-choice-match?");
SCM_ASSERT (IS_SCM_SYMBOL (s_ch2), s_ch2, SCM_ARG2, "bse-choice-match?");
-
gchar *ch1 = strdup_from_scm (s_ch1);
gchar *ch2 = strdup_from_scm (s_ch2);
int res = sfi_choice_match (ch1, ch2);
@@ -765,7 +669,6 @@ bse_scm_choice_match (SCM s_ch1,
g_free (ch2);
return SCM_BOOL (res);
}
-
static char*
text_concat_scm (const char *prefix,
SCM s_string)
@@ -775,7 +678,6 @@ text_concat_scm (const char *prefix,
g_free (p2);
return result;
}
-
static int
msg_bit_type_match (const gchar *string)
{
@@ -795,15 +697,12 @@ msg_bit_type_match (const gchar *string)
return 4;
return -1;
}
-
SCM
bse_scm_script_message (SCM s_type,
SCM s_bits)
{
SCM gcplateau = bse_scm_make_gc_plateau (4096);
-
SCM_ASSERT (IS_SCM_SYMBOL (s_type), s_type, SCM_ARG2, "bse-script-message");
-
/* figure message level */
BSE_SCM_DEFER_INTS();
gchar *strtype = strdup_from_scm (s_type);
@@ -812,7 +711,6 @@ bse_scm_script_message (SCM s_type,
BSE_SCM_ALLOW_INTS();
if (!mtype)
scm_wrong_type_arg ("bse-script-message", 2, s_type);
-
/* figure argument list length */
guint i = 0;
SCM node = s_bits;
@@ -820,7 +718,6 @@ bse_scm_script_message (SCM s_type,
node = SCM_CDR (node), i++;
if (i == 0)
scm_misc_error ("bse-script-message", "Wrong number of arguments", SCM_BOOL_F);
-
/* build message bit list */
char *title = NULL, *primary = NULL, *secondary = NULL, *detail = NULL, *check = NULL;
i = 2;
@@ -877,7 +774,6 @@ bse_scm_script_message (SCM s_type,
}
BSE_SCM_ALLOW_INTS();
}
-
BSE_SCM_DEFER_INTS ();
SfiSeq *args = sfi_seq_new ();
/* keep arguments in sync with bsejanitor.proc */
@@ -891,13 +787,10 @@ bse_scm_script_message (SCM s_type,
sfi_glue_call_seq ("bse-script-send-message", args);
sfi_seq_unref (args);
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
return SCM_UNSPECIFIED;
}
-
static gboolean script_register_enabled = FALSE;
-
void
bse_scm_enable_script_register (gboolean enabled)
{
@@ -911,7 +804,6 @@ bse_scm_enable_script_register (gboolean enabled)
SCM_RESET_DEBUG_MODE;
}
}
-
SCM
bse_scm_script_register (SCM s_name,
SCM s_options,
@@ -924,7 +816,6 @@ bse_scm_script_register (SCM s_name,
SCM gcplateau = bse_scm_make_gc_plateau (4096);
SCM node;
guint i;
-
SCM_ASSERT (IS_SCM_SYMBOL (s_name), s_name, SCM_ARG1, "bse-script-register");
SCM_ASSERT (IS_SCM_STRING (s_options), s_options, SCM_ARG2, "bse-script-register");
SCM_ASSERT (IS_SCM_STRING (s_category), s_category, SCM_ARG3, "bse-script-register");
@@ -937,8 +828,6 @@ bse_scm_script_register (SCM s_name,
if (!IS_SCM_STRING (arg))
scm_wrong_type_arg ("bse-script-register", i, arg);
}
-
-
// implement: (source-properties (frame-source (stack-ref (make-stack #t) 0)))
// to get at the source properties 'file and 'line of the registration caller
SCM s_stack = scm_make_stack (SCM_BOOL_T, SCM_EOL); // scm_cons (scm_int2num (4), SCM_EOL));
@@ -953,13 +842,11 @@ bse_scm_script_register (SCM s_name,
s_line = scm_source_property (s_fsrc, scm_sym_line);
}
}
-
BSE_SCM_DEFER_INTS ();
if (script_register_enabled)
{
SfiSeq *seq = sfi_seq_new ();
GValue *val, *rval;
-
sfi_seq_append (seq, val = string_value_from_scm (s_name));
sfi_value_free (val);
sfi_seq_append (seq, val = string_value_from_scm (s_options));
@@ -981,14 +868,12 @@ bse_scm_script_register (SCM s_name,
sfi_value_free (val);
sfi_seq_append (seq, val = string_value_from_scm (s_license));
sfi_value_free (val);
-
for (node = s_params; IS_SCM_PAIR (node); node = SCM_CDR (node))
{
SCM arg = SCM_CAR (node);
sfi_seq_append (seq, val = string_value_from_scm (arg));
sfi_value_free (val);
}
-
val = sfi_value_seq (seq);
rval = sfi_glue_client_msg ("bse-client-msg-script-register", val);
sfi_value_free (val);
@@ -1001,11 +886,9 @@ bse_scm_script_register (SCM s_name,
sfi_glue_gc_free_now (rval, BseScmFreeFunc (sfi_value_free));
}
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
return SCM_UNSPECIFIED;
}
-
SCM
bse_scm_gettext (SCM s_string)
{
@@ -1018,7 +901,6 @@ bse_scm_gettext (SCM s_string)
BSE_SCM_ALLOW_INTS ();
return s_ret;
}
-
SCM
bse_scm_gettext_q (SCM s_string)
{
@@ -1036,14 +918,12 @@ bse_scm_gettext_q (SCM s_string)
BSE_SCM_ALLOW_INTS ();
return s_ret;
}
-
static SCM
bse_scm_script_args (void)
{
SCM gcplateau = bse_scm_make_gc_plateau (4096);
SCM args;
GValue *rvalue;
-
BSE_SCM_DEFER_INTS ();
rvalue = sfi_glue_client_msg ("bse-client-msg-script-args", NULL);
if (SFI_VALUE_HOLDS_SEQ (rvalue))
@@ -1052,23 +932,18 @@ bse_scm_script_args (void)
args = SCM_EOL;
sfi_glue_gc_free_now (rvalue, BseScmFreeFunc (sfi_value_free));
BSE_SCM_ALLOW_INTS ();
-
bse_scm_destroy_gc_plateau (gcplateau);
return args;
}
-
SCM
bse_scm_context_pending (void)
{
gboolean pending;
-
BSE_SCM_DEFER_INTS ();
pending = sfi_glue_context_pending ();
BSE_SCM_ALLOW_INTS ();
-
return gh_bool2scm (pending);
}
-
SCM
bse_scm_context_iteration (SCM s_may_block)
{
@@ -1089,23 +964,18 @@ bse_scm_context_iteration (SCM s_may_block)
BSE_SCM_ALLOW_INTS ();
return SCM_UNSPECIFIED;
}
-
-
/* --- initialization --- */
typedef SCM (*BseScmFunc) ();
-
static void
register_types (const gchar **types)
{
SCM gcplateau = bse_scm_make_gc_plateau (2048);
-
while (*types)
{
const gchar **names = sfi_glue_list_method_names (*types);
gchar *sname = g_type_name_to_sname (*types);
gchar *s;
guint i;
-
if (strncmp (sname, "bse-", 4) == 0)
{
s = g_strdup_printf ("(define (bse-is-%s proxy) (bse-item-check-is-a proxy \"%s\"))",
@@ -1121,35 +991,28 @@ register_types (const gchar **types)
g_free (s);
}
g_free (sname);
-
names = sfi_glue_iface_children (*types);
register_types (names);
-
types++;
}
bse_scm_destroy_gc_plateau (gcplateau);
}
-
void
bse_scm_interp_init (void)
{
const gchar **procs, *procs2[2];
guint i;
-
tc_glue_gc_cell = scm_make_smob_type ("BseScmGCCell", 0);
scm_set_smob_mark (tc_glue_gc_cell, bse_scm_mark_gc_cell);
scm_set_smob_free (tc_glue_gc_cell, bse_scm_free_gc_cell);
-
tc_glue_gc_plateau = scm_make_smob_type ("BseScmGcPlateau", 0);
scm_set_smob_free (tc_glue_gc_plateau, bse_scm_gc_plateau_free);
-
tc_glue_rec = scm_make_smob_type ("BseGlueRec", 0);
scm_set_smob_free (tc_glue_rec, bse_scm_free_glue_rec);
gh_new_procedure ("bse-rec-get", BseScmFunc (bse_scm_glue_rec_get), 2, 0, 0);
gh_new_procedure ("bse-rec-set", BseScmFunc (bse_scm_glue_rec_set), 3, 0, 0);
gh_new_procedure ("bse-rec-new", BseScmFunc (bse_scm_glue_rec_new), 0, 1, 0);
gh_new_procedure ("bse-rec-print", BseScmFunc (bse_scm_glue_rec_print), 1, 0, 0);
-
tc_glue_proxy = scm_make_smob_type ("SfiProxy", 0);
SCM_NEWSMOB (glue_null_proxy, tc_glue_proxy, 0);
scm_permanent_object (glue_null_proxy);
@@ -1157,11 +1020,9 @@ bse_scm_interp_init (void)
scm_set_smob_print (tc_glue_proxy, bse_scm_proxy_print);
gh_new_procedure ("bse-proxy-is-null?", BseScmFunc (bse_scm_proxy_is_null), 1, 0, 0);
gh_new_procedure ("bse-proxy-get-null", BseScmFunc (bse_scm_proxy_get_null), 0, 1, 0);
-
gh_new_procedure ("bse-glue-call", BseScmFunc (bse_scm_glue_call), 2, 0, 0);
gh_new_procedure ("bse-glue-set-prop", BseScmFunc (bse_scm_glue_set_prop), 3, 0, 0);
gh_new_procedure ("bse-glue-get-prop", BseScmFunc (bse_scm_glue_get_prop), 2, 0, 0);
-
procs = sfi_glue_list_proc_names ();
for (i = 0; procs[i]; i++)
if (strncmp (procs[i], "bse-", 4) == 0)
@@ -1170,11 +1031,9 @@ bse_scm_interp_init (void)
gh_eval_str (s);
g_free (s);
}
-
procs2[0] = sfi_glue_base_iface ();
procs2[1] = NULL;
register_types (procs2);
-
gh_new_procedure0_0 ("bse-server-get", bse_scm_server_get);
gh_new_procedure ("bse-script-register", BseScmFunc (bse_scm_script_register), 6, 0, 1);
gh_new_procedure ("bse-script-fetch-args", BseScmFunc (bse_scm_script_args), 0, 0, 0);
diff --git a/shell/bsescminterp.hh b/shell/bsescminterp.hh
index 8706e27..b1e3bfe 100644
--- a/shell/bsescminterp.hh
+++ b/shell/bsescminterp.hh
@@ -1,15 +1,10 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_SCM_INTERP_H__
#define __BSE_SCM_INTERP_H__
-
#include <bse/bse.hh>
#include <guile/gh.h>
-
G_BEGIN_DECLS
-
typedef struct _BseSCMWire BseSCMWire;
-
-
/* --- prototypes --- */
void bse_scm_interp_init (void);
void bse_scm_interp_exec_script (const gchar *file_name,
@@ -17,8 +12,6 @@ void bse_scm_interp_exec_script (const gchar *file_name,
GValue *value);
void bse_scm_enable_script_register (gboolean enabled);
void bse_scm_enable_server (gboolean enabled);
-
-
/* --- SCM procedures --- */
SCM bse_scm_server_get (void);
SCM bse_scm_choice_match (SCM s_ev1,
@@ -56,8 +49,5 @@ SCM bse_scm_glue_rec_set (SCM scm_rec,
SCM bse_scm_glue_rec_print (SCM scm_rec);
SCM bse_scm_make_gc_plateau (guint size_hint);
void bse_scm_destroy_gc_plateau (SCM s_gcplateau);
-
G_END_DECLS
-
-
#endif /* __BSE_SCM_INTERP_H__ */
diff --git a/tests/audio/bse2wav.scm b/tests/audio/bse2wav.scm
index 1fdd097..971c030 100644
--- a/tests/audio/bse2wav.scm
+++ b/tests/audio/bse2wav.scm
@@ -15,16 +15,13 @@
;; in contract, strict liability, or tort (including negligence or
;; otherwise) arising in any way out of the use of this software, even
;; if advised of the possibility of such damage.
-
(use-modules (ice-9 getopt-long))
-
;; load all stock BSE plugins
(bse-server-register-blocking bse-server-register-core-plugins #f)
;; no script registration
;;(bse-server-register-blocking bse-server-register-scripts #f)
;; no LADSPA plugin registration
;;(bse-server-register-blocking bse-server-register-ladspa-plugins #f)
-
;; playback + recording procedure
(define (bse-2-wav bse-file wav-file seconds)
(let* ((counter 0)
@@ -63,14 +60,12 @@
(display "done.\n")
;; release the newly created project
(bse-item-unuse project)))
-
;; Program usage
(define (exit-usage exit-code)
(display "Usage: bse2wav [options...] <bse-file> <wav-file>\n")
(display " --help, -h Show this usage information\n")
(display " --seconds <seconds> Number of seconds to record\n")
(exit exit-code))
-
;; Command line synopsis
(define
command-synopsis
@@ -78,7 +73,6 @@
(help (single-char #\h) (value #f))
(seconds (value #t))
))
-
;; Parse command line and exec
(let* ((options (getopt-long (command-line) command-synopsis))
(max-seconds (option-ref options 'seconds "0"))
diff --git a/tests/bse/cxxbinding.cc b/tests/bse/cxxbinding.cc
index 6542d2c..f650278 100644
--- a/tests/bse/cxxbinding.cc
+++ b/tests/bse/cxxbinding.cc
@@ -3,12 +3,9 @@
#include <bse/bse.hh>
#include <unistd.h>
#include <stdio.h>
-
static SfiGlueContext *bse_context = NULL;
-
using namespace Bse;
using namespace std;
-
void do_sleep (int seconds)
{
/*
@@ -18,7 +15,6 @@ void do_sleep (int seconds)
while (seconds > 0)
seconds = sleep (seconds);
}
-
int
main (int argc,
char *argv[])
@@ -27,11 +23,8 @@ main (int argc,
bse_init_async (&argc, &argv, "CxxBindingTest", NULL);
sfi_msg_allow ("misc");
bse_context = bse_init_glue_context (argv[0]);
-
sfi_glue_context_push (bse_context);
-
g_print ("type_blurb(BseContainer)=%s\n", type_blurb("BseContainer").c_str());
-
const gchar *file_name = "empty.ogg";
SampleFileInfoHandle info = sample_file_info (file_name);
if (info.c_ptr())
@@ -46,38 +39,30 @@ main (int argc,
{
g_print ("sample_file_info(\"%s\"): failed\n", file_name);
}
-
g_print ("error_blurb(ERROR_DEVICE_ASYNC): %s\n", error_blurb (ERROR_DEVICE_ASYNC).c_str());
-
Server server = 1; // FIXME: users may not hardcode this
-
g_print ("server.get_custom_instrument_dir()=%s\n", server.get_custom_instrument_dir().c_str());
-
GConfigHandle prefs = GConfig::from_rec (server.bse_preferences ());
prefs->plugin_path = "./.libs/testplugin.so";
SfiRec *rec = GConfig::to_rec (prefs);
server.set_bse_preferences (rec);
sfi_rec_unref (rec);
prefs = GConfig::from_rec (server.bse_preferences());
-
printf ("server.bse_preferences().plugin_path=%s\n", prefs->plugin_path.c_str());
printf ("register core plugins...\n");
server.register_core_plugins();
printf ("waiting... (FIXME: need to connect to server signals here)\n");
do_sleep (2);
g_print ("done.\n");
-
/* ... test plugin ... */
Project test_project = server.use_new_project ("test_project");
CSynth synth = test_project.create_csynth ("synth");
-
g_print ("--- creating TestObject ---\n");
Namespace::TestObject to = synth.create_source("NamespaceTestObject")._proxy(); // FIXME: dynamic_cast me
if (to)
g_print ("success creating TestObject: %ld\n", to._proxy());
else
g_error ("failed.");
-
/* --- test procedures --- */
g_print ("--- calling procedure test_exception() ---\n");
g_print ("invoking as: result = test_exception (21, %ld, 42, \"moderately-funky\");\n", to._proxy());
@@ -102,7 +87,6 @@ main (int argc,
g_error ("failed (no result).");
result = sfi_value_get_int (rvalue);
g_print ("result=%d\n", result);
-
/* --- test playback --- */
file_name = "../test/test-song.bse";
g_print ("--- playing %s... ---\n", file_name);
@@ -111,8 +95,6 @@ main (int argc,
project.play();
sleep (3);
g_print ("done.\n");
-
sfi_glue_context_pop ();
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tests/bse/filtertest.cc b/tests/bse/filtertest.cc
index e75b038..1a89a21 100644
--- a/tests/bse/filtertest.cc
+++ b/tests/bse/filtertest.cc
@@ -13,17 +13,14 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-
using std::string;
using std::vector;
using std::set;
using std::min;
using std::max;
-
struct Options {
bool dump_gnuplot_data;
string program_name;
-
Options() :
dump_gnuplot_data (false),
program_name ("filtertest")
@@ -31,7 +28,6 @@ struct Options {
}
void parse (int *argc_p, char **argv_p[]);
} options;
-
static void
usage ()
{
@@ -52,7 +48,6 @@ usage ()
printf (" ls filtertest_*.gp\n");
printf (" gnuplot filtertest_bw8.gp\n");
}
-
static bool
check_arg (uint argc,
char *argv[],
@@ -62,11 +57,9 @@ check_arg (uint argc,
{
g_return_val_if_fail (opt != NULL, false);
g_return_val_if_fail (*nth < argc, false);
-
const char *arg = argv[*nth];
if (!arg)
return false;
-
uint opt_len = strlen (opt);
if (strcmp (arg, opt) == 0)
{
@@ -96,11 +89,9 @@ check_arg (uint argc,
}
else
return false;
-
usage();
exit (1);
}
-
void
Options::parse (int *argc_p,
char **argv_p[])
@@ -108,9 +99,7 @@ Options::parse (int *argc_p,
guint argc = *argc_p;
gchar **argv = *argv_p;
unsigned int i;
-
g_return_if_fail (argc >= 0);
-
for (i = 1; i < argc; i++)
{
//const char *opt_arg;
@@ -131,7 +120,6 @@ Options::parse (int *argc_p,
dump_gnuplot_data = true;
}
}
-
/* resort argc/argv */
guint e = 1;
for (i = 1; i < argc; i++)
@@ -143,7 +131,6 @@ Options::parse (int *argc_p,
}
*argc_p = e;
}
-
class FilterTest
{
public:
@@ -152,14 +139,12 @@ public:
TEST_COMPUTED_RESPONSE = 1,
TEST_SCANNED_RESPONSE = 2
};
-
private:
struct Band {
double freq_start;
double freq_end;
double min_resp_db;
double max_resp_db;
-
Band (double freq_start,
double freq_end,
double min_resp_db,
@@ -171,7 +156,6 @@ private:
{
}
};
-
string m_name;
guint m_order;
string m_gp_short_name;
@@ -179,17 +163,14 @@ private:
set<double> m_gp_arrows;
set<double> m_gp_lines;
vector<Band> m_spec_bands;
-
static const double FS = 10000.0;
static const double MIN_DB = -1000;
static const double DB_EPSILON = 0.01; /* for comparisions */
-
double
response (double f) const
{
double u = 2.0 * PI * f / FS;
std::complex<double> z (cos (u), sin (u)); /* exp( j omega T ) */
-
guint o = m_order;
std::complex<double> num = m_a[o], den = m_b[o];
while (o--)
@@ -200,7 +181,6 @@ private:
std::complex<double> w = num / den;
return abs (w);
}
-
double
scan_response (double f) const
{
@@ -208,7 +188,6 @@ private:
f = min (f, MAX_SCAN_FREQ);
return gsl_filter_sine_scan (m_order, &m_a[0], &m_b[0], f, FS);
}
-
void
check_response_db (double freq,
double min_resp_db,
@@ -238,13 +217,10 @@ private:
guint scan_points) const
{
const double delta_f = (FS / 2) / scan_points;
-
g_return_if_fail (band.freq_start <= band.freq_end);
g_return_if_fail (band.freq_end <= FS/2);
-
TPRINT ("checking band: response in interval [%f..%f] should be in interval [%f..%f] dB\n",
band.freq_start, band.freq_end, band.min_resp_db, band.max_resp_db);
-
int tok = 0;
int tok_dots = int ((FS / delta_f) / 50) + 1;
for (double f = band.freq_start; f < band.freq_end; f += delta_f)
@@ -253,7 +229,6 @@ private:
TOK();
check_response_db (f, band.min_resp_db, band.max_resp_db, test_mode);
}
-
if (band.freq_start != band.freq_end)
check_response_db (band.freq_end, band.min_resp_db, band.max_resp_db, test_mode);
}
@@ -266,14 +241,12 @@ public:
m_order (order),
m_gp_short_name (gp_short_name)
{
-
for (guint i = 0; i < m_order * 2 + 2; i += 2)
{
m_b.push_back (coefficients[i]);
m_a.push_back (coefficients[i+1]);
}
}
-
/* construction phase: used to add a passband to the specification */
void
add_passband (double freq_start,
@@ -285,7 +258,6 @@ public:
m_gp_lines.insert (ripple_db);
m_spec_bands.push_back (Band (freq_start, freq_end, ripple_db, 0));
}
-
/* construction phase: used to add a stopband to the specification */
void
add_stopband (double freq_start,
@@ -297,7 +269,6 @@ public:
m_gp_lines.insert (ripple_db);
m_spec_bands.push_back (Band (freq_start, freq_end, MIN_DB, ripple_db));
}
-
/* actually check filter against specification */
void
perform_checks (TestMode test_mode,
@@ -318,10 +289,8 @@ public:
guint scan_points = 1000)
{
const double delta_f = (FS / 2) / scan_points;
-
string data_filename = filename_prefix + m_gp_short_name + ".data";
string gp_filename = filename_prefix + m_gp_short_name + ".gp";
-
FILE *data_file = fopen (data_filename.c_str(), "w");
if (!data_file)
{
@@ -338,7 +307,6 @@ public:
return false;
}
g_printerr ("creating gnuplot files '%s', '%s'... ", gp_filename.c_str(), data_filename.c_str());
-
for (double f = 0; f < FS/2; f += delta_f)
{
fprintf (data_file, "%f %f %f\n", f, bse_db_from_factor (response (f), -1000),
@@ -362,15 +330,12 @@ public:
fprintf (gp_file, ", %f", *li);
fprintf (gp_file, "\n");
fprintf (gp_file, "pause -1\n");
-
fclose (gp_file);
fclose (data_file);
-
g_printerr ("ok.\n");
return 0;
}
};
-
void
setup_all_filter_tests (vector<FilterTest>& filter_tests)
{
@@ -387,7 +352,6 @@ setup_all_filter_tests (vector<FilterTest>& filter_tests)
-1.22466701861471700258E-02, +1.81747200996105646997E-02, // BSEcxxmgc
+8.61368381197359644919E-04, +2.27184001245132058747E-03, // BSEcxxmgc
}; // BSEcxxmgc
-
FilterTest bw8 ("Butterworth Lowpass 2000 Hz", 8, coeffs, "bw8");
bw8.add_passband (0, 2000, bse_db_from_factor (1/sqrt(2), -30));
bw8.add_stopband (3500, 5000, -68);
@@ -410,10 +374,8 @@ setup_all_filter_tests (vector<FilterTest>& filter_tests)
-1.85052119790466007565E+00, +1.77484258573414174429E-03, // BSEcxxmgc
+2.41243520047625281677E-01, +1.05368736204784763100E-03, // BSEcxxmgc
}; // BSEcxxmgc
-
FilterTest ell12 ("Elliptic Lowpass 2000 Hz", 12, coeffs, "ell12");
ell12.add_passband (0, 2000, -0.5);
-
/* FIXME: we should get better results (= -96 dB) if we implement this filter with cascading lowpasses */
ell12.add_stopband (2160, 5000, -96);
filter_tests.push_back (ell12);
@@ -430,7 +392,6 @@ setup_all_filter_tests (vector<FilterTest>& filter_tests)
+1.11977829190352773381E+00, +2.49374875432628329008E+00, // BSEcxxmgc
-1.17830171950224868449E-01, -3.56249822046611874793E-01, // BSEcxxmgc
}; // BSEcxxmgc
-
FilterTest chp7 ("Chebychev Highpass 600 Hz", 7, coeffs, "chp7");
chp7.add_passband (600, 5000, -0.1);
chp7.add_stopband (0, 250, -70);
@@ -459,7 +420,6 @@ setup_all_filter_tests (vector<FilterTest>& filter_tests)
-9.75781955236953990607E-19, +0.00000000000000000000E+00, // BSEcxxmgc
+3.55580604257624494427E-04, -1.06539452359780476010E-03, // BSEcxxmgc
}; // BSEcxxmgc
-
FilterTest bbp18 ("Butterworth Bandpass 1500-3500 Hz", 18, coeffs, "bbp18");
bbp18.add_passband (1500, 3500, bse_db_from_factor (1/sqrt(2), -30));
bbp18.add_stopband (0, 1000, -49.5);
@@ -482,7 +442,6 @@ setup_all_filter_tests (vector<FilterTest>& filter_tests)
filter_tests.push_back (ebsh4);
}
}
-
void
check_computed_response (const vector<FilterTest>& filter_tests)
{
@@ -490,7 +449,6 @@ check_computed_response (const vector<FilterTest>& filter_tests)
for (vector<FilterTest>::const_iterator fi = filter_tests.begin(); fi != filter_tests.end(); fi++)
fi->perform_checks (FilterTest::TEST_COMPUTED_RESPONSE, 10000);
}
-
void
check_scanned_response (const vector<FilterTest>& filter_tests)
{
@@ -498,21 +456,18 @@ check_scanned_response (const vector<FilterTest>& filter_tests)
for (vector<FilterTest>::const_iterator fi = filter_tests.begin(); fi != filter_tests.end(); fi++)
fi->perform_checks (FilterTest::TEST_SCANNED_RESPONSE, 67); /* prime number scan points */
}
-
void
dump_gnuplot_data (vector<FilterTest>& filter_tests)
{
for (vector<FilterTest>::iterator fi = filter_tests.begin(); fi != filter_tests.end(); fi++)
fi->dump_gnuplot_data ("filtertest_");
}
-
int
main (int argc,
char **argv)
{
bse_init_test (&argc, &argv, NULL);
options.parse (&argc, &argv);
-
if (argc > 1)
{
int a;
@@ -521,10 +476,8 @@ main (int argc,
g_printerr ("%s: use the --help option for help.\n", options.program_name.c_str());
return 1;
}
-
vector<FilterTest> filter_tests;
setup_all_filter_tests (filter_tests);
-
if (options.dump_gnuplot_data)
{
dump_gnuplot_data (filter_tests);
diff --git a/tests/bse/testplugin.cc b/tests/bse/testplugin.cc
index 1ce268b..494a5ec 100644
--- a/tests/bse/testplugin.cc
+++ b/tests/bse/testplugin.cc
@@ -4,16 +4,13 @@
#include <stdexcept>
#include <math.h>
#include <string.h>
-
namespace Namespace {
using namespace std;
using namespace Bse;
-
class TestObject : public TestObjectBase
{
public:
//BSE_EFFECT_INTEGRATE_MODULE (TestObject, Module, Properties);
-
#if 0
/* FIXME */
Bse::SynthesisModule* create_module(unsigned int, BseTrans*)
@@ -21,7 +18,6 @@ public:
g_assert_not_reached ();
return 0;
}
-
/* FIXME */
Bse::SynthesisModule::Accessor* module_configurator()
{
@@ -34,7 +30,6 @@ public:
void (* get_module_auto_update())(BseModule*, void*) { return 0; }
#endif
};
-
SfiInt
Procedure::test_exception::exec (SfiInt i,
TestObject* o,
@@ -49,14 +44,11 @@ Procedure::test_exception::exec (SfiInt i,
throw std::runtime_error ("object pointer is NULL");
return i + bar;
}
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ENUM (FunkynessType);
BSE_CXX_REGISTER_RECORD (TestRecord);
BSE_CXX_REGISTER_SEQUENCE (TestSequence);
BSE_CXX_REGISTER_EFFECT (TestObject);
BSE_CXX_REGISTER_PROCEDURE (test_exception);
-
} // Test
-
/* vim:set ts=8 sw=2 sts=2: */
diff --git a/tests/bse/testplugin.idl b/tests/bse/testplugin.idl
index cfbd7fd..f2100e5 100644
--- a/tests/bse/testplugin.idl
+++ b/tests/bse/testplugin.idl
@@ -1,31 +1,24 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bse.idl>
-
namespace Namespace {
-
using namespace Sfi;
-
// test enum
choice FunkynessType {
REALLY_FUNKY,
MODERATELY_FUNKY,
NON_FUNKY = (42, "No Funk At All"),
};
-
// test record
record TestRecord {
Int i;
String str;
FunkynessType funky;
};
-
sequence TestSequence {
TestRecord tr;
};
-
// adds i and str to the record given by rec
// TestRecord record_add (TestRecord rec, Int i, String str);
-
// test effect
class TestObject : Bse::Effect {
Info category = "/Test/Plugin";
@@ -39,10 +32,8 @@ class TestObject : Bse::Effect {
property Bse::Effect ef; // C++ Object
property Bse::Item it; // C Object
};
-
// test procedure
Int test_exception (Int i, TestObject o, Int bar, FunkynessType ft) {
Info category = "/Toys/Test Exception";
}
-
};
diff --git a/tests/filecheck/checkproject.scm b/tests/filecheck/checkproject.scm
index a8312c6..0162e83 100644
--- a/tests/filecheck/checkproject.scm
+++ b/tests/filecheck/checkproject.scm
@@ -1,15 +1,12 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
;; -*- scheme -*-
-
;; play argc/argv contents as bse files
-
;; load all stock BSE plugins
(bse-server-register-blocking bse-server-register-core-plugins #f)
;; no script registration
;;(bse-server-register-blocking bse-server-register-scripts #f)
;; no LADSPA plugin registration
;;(bse-server-register-blocking bse-server-register-ladspa-plugins #f)
-
;; for each file on the command line
(map (lambda (file)
(let*
diff --git a/tests/latency/bselatencytest.cc b/tests/latency/bselatencytest.cc
index 80e8faa..0397628 100644
--- a/tests/latency/bselatencytest.cc
+++ b/tests/latency/bselatencytest.cc
@@ -4,12 +4,9 @@
#include <string>
#include <errno.h>
#include <stdio.h>
-
using namespace std;
using namespace Sfi;
-
namespace Bse {
-
class LatencyTest : public LatencyTestBase {
/* properties */
struct Properties : public LatencyTestProperties {
@@ -22,24 +19,19 @@ class LatencyTest : public LatencyTestBase {
public:
FILE *midi_output_file;
FILE *logfile;
-
char note_on[3];
char note_off[3];
-
guint note_on_wait;
guint note_off_wait;
guint bpm_samples;
gfloat threshold;
-
double start_time;
double end_time;
-
double
gettime ()
{
timeval tv;
gettimeofday (&tv, 0);
-
return double(tv.tv_sec) + double(tv.tv_usec) * (1.0 / 1000000.0);
}
void
@@ -71,7 +63,6 @@ class LatencyTest : public LatencyTestBase {
reset()
{
close_devices();
-
if (birnet_file_check (midi_output_name.c_str(), "pw")) /* writable pipe */
midi_output_file = fopen (midi_output_name.c_str(), "w");
if (!midi_output_file)
@@ -92,19 +83,15 @@ class LatencyTest : public LatencyTestBase {
midi_output_name = properties->midi_output.c_str();
if (midi_output_name[0] == '$')
midi_output_name = g_getenv (midi_output_name.c_str() + 1);
-
/* send pending note-off events, close and reopen devices */
reset();
-
/* configure events */
note_on[0] = 0x90 | (properties->midi_channel - 1);
note_on[1] = properties->midi_note;
note_on[2] = 100; /* velocity */
-
note_off[0] = 0x80 | (properties->midi_channel - 1);
note_off[1] = properties->midi_note;
note_off[2] = 0; /* velocity */
-
/* setup timing */
bpm_samples = guint (mix_freq() * 60 / properties->bpm); /* quarter note duration */
note_on_wait = bpm_samples / 2;
@@ -121,14 +108,12 @@ class LatencyTest : public LatencyTestBase {
if (!note_on_wait)
{
start_time = gettime();
-
fwrite (note_on, 3, 1, midi_output_file);
fflush (midi_output_file);
note_on_wait += bpm_samples;
}
else
note_on_wait--;
-
if (!note_off_wait)
{
fwrite (note_off, 3, 1, midi_output_file);
@@ -137,12 +122,10 @@ class LatencyTest : public LatencyTestBase {
}
else
note_off_wait--;
-
if (auin[i] > threshold && start_time > 0)
{
double delta_time = double (i) / mix_freq();
double end_time = gettime();
-
if (logfile)
fprintf (stdout, "%12.6f # latency in ms between note-on and signal-start; (block-offset=%u)\n",
1000.0 * (end_time + delta_time - start_time), i);
@@ -155,8 +138,6 @@ public:
/* implement creation and config methods for synthesis Module */
BSE_EFFECT_INTEGRATE_MODULE (LatencyTest, Module, Properties);
};
-
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_EFFECT (LatencyTest);
-
} // Bse
diff --git a/tests/latency/bselatencytest.idl b/tests/latency/bselatencytest.idl
index 4dc4a4f..9196214 100644
--- a/tests/latency/bselatencytest.idl
+++ b/tests/latency/bselatencytest.idl
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include <bse/bsecxxmodule.idl>
-
namespace Bse {
-
class LatencyTest : Effect {
Info authors = "Stefan Westerfeld";
Info license = _("GNU Lesser General Public License");
@@ -15,7 +13,6 @@ class LatencyTest : Effect {
"After sending a midi event, the latency tester will count the number"
" of samples until it sees some signal on its input channel. From"
" that number a latency is computed and printed (or logged, if you specified a log file)");
-
group _("Test configuration") {
Real bpm = (_("Beats per Minute"), _("The speed at which test events (quarter notes) are generated"),
120, 10, 1000, 5, STANDARD);
@@ -36,10 +33,7 @@ class LatencyTest : Effect {
"it is interpreted as an environment variable name and expanded."),
"/tmp/midi-fifo", STANDARD);
};
-
-
IStream audio_in = (_("Audio In"), _("Test signal input, which the latency tester waits for"));
OStream audio_out = (_("Audio Out"), _("Test signal output"));
};
-
} // Bse
diff --git a/tests/latency/bseplay.scm b/tests/latency/bseplay.scm
index a118389..77c1d1c 100644
--- a/tests/latency/bseplay.scm
+++ b/tests/latency/bseplay.scm
@@ -1,6 +1,5 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
;; bseplay.scm - silently play .bse files -*- scheme -*-
-
;; play argc/argv contents as bse files
(define (bse-play)
(bse-server-register-blocking bse-server-register-core-plugins #f)
diff --git a/tests/perftest.cc b/tests/perftest.cc
index fc9c6b9..c639894 100644
--- a/tests/perftest.cc
+++ b/tests/perftest.cc
@@ -5,49 +5,36 @@
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
-
static SfiGlueContext *bse_context = NULL;
-
using namespace Bse;
using namespace std;
-
double
gettime ()
{
timeval tv;
gettimeofday (&tv, 0);
-
return double(tv.tv_sec) + double(tv.tv_usec) * (1.0 / 1000000.0);
}
-
int main(int argc, char **argv)
{
std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
bse_init_async (&argc, &argv, "Perftest", NULL);
sfi_msg_allow ("misc");
bse_context = bse_init_glue_context (argv[0]);
-
sfi_glue_context_push (bse_context);
-
printf ("%s: testing remote glue layer calls via C++ interface:\n", argv[0]);
-
const int max_calls = 30000;
const int runs = 7;
double t = 1e7;
-
for (int r = 0; r < runs; r++)
{
double start = gettime ();
-
for(int i=0; i < max_calls; i++)
note_to_freq (MUSICAL_TUNING_12_TET, 60, 0);
-
t = std::min (gettime () - start, t);
}
printf ("%f seconds for %d invocations => %f invocations/second, %f milli seconds per invocation\n",
t, max_calls, max_calls / t, t * 1000 / max_calls);
-
sfi_glue_context_pop ();
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tests/testresampler.cc b/tests/testresampler.cc
index c0d4c99..58b2f37 100644
--- a/tests/testresampler.cc
+++ b/tests/testresampler.cc
@@ -8,22 +8,18 @@
#include <bse/bsemathsignal.hh>
#include <bse/gslfft.hh>
#include "topconfig.h"
-
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
#include <time.h>
-
#include <string>
#include <vector>
-
using std::string;
using std::vector;
using std::min;
using std::max;
using std::copy;
using namespace Bse::Resampler;
-
enum TestType
{
TEST_NONE,
@@ -34,7 +30,6 @@ enum TestType
TEST_IMPULSE,
TEST_FILTER_IMPL
} test_type = TEST_NONE;
-
enum ResampleType
{
RES_DOWNSAMPLE,
@@ -42,7 +37,6 @@ enum ResampleType
RES_SUBSAMPLE,
RES_OVERSAMPLE
} resample_type = RES_UPSAMPLE;
-
struct Options {
guint block_size;
double frequency;
@@ -54,7 +48,6 @@ struct Options {
BseResampler2Precision precision;
bool filter_impl_verbose;
string program_name;
-
Options() :
block_size (128),
frequency (440.0),
@@ -70,7 +63,6 @@ struct Options {
}
void parse (int *argc_p, char **argv_p[]);
} options;
-
static void
usage ()
{
@@ -124,10 +116,7 @@ usage ()
printf (" # plot the errors occuring in this frequency scan with gnuplot, including the max threshold\n");
printf (" testresampler accuracy --precision=20 --freq-scan=50,18000,50 --freq-scan-verbose --max-threshold=110 --up > x\n");
printf (" gnuplot <(echo 'plot [0:][:0] \"x\" with lines, -110; pause -1')\n");
-
}
-
-
static bool
check_arg (uint argc,
char *argv[],
@@ -137,11 +126,9 @@ check_arg (uint argc,
{
g_return_val_if_fail (opt != NULL, false);
g_return_val_if_fail (*nth < argc, false);
-
const char *arg = argv[*nth];
if (!arg)
return false;
-
uint opt_len = strlen (opt);
if (strcmp (arg, opt) == 0)
{
@@ -171,11 +158,9 @@ check_arg (uint argc,
}
else
return false;
-
usage();
exit (1);
}
-
void
Options::parse (int *argc_p,
char **argv_p[])
@@ -183,16 +168,13 @@ Options::parse (int *argc_p,
guint argc = *argc_p;
gchar **argv = *argv_p;
unsigned int i;
-
g_return_if_fail (argc >= 0);
-
/* I am tired of seeing .libs/lt-bsefcompare all the time,
* but basically this should be done (to allow renaming the binary):
*
if (argc && argv[0])
program_name = argv[0];
*/
-
for (i = 1; i < argc; i++)
{
const char *opt_arg;
@@ -216,7 +198,6 @@ Options::parse (int *argc_p,
block_size++;
g_printerr ("testresampler: block size needs to be even (fixed: using %d as block size)\n", block_size);
}
-
if (block_size < 2)
{
block_size = 2;
@@ -248,7 +229,6 @@ Options::parse (int *argc_p,
gchar *fmin = strtok (oa, ",");
gchar *fmax = fmin ? strtok (NULL, ",") : NULL;
gchar *finc = fmax ? strtok (NULL, ",") : NULL;
-
if (finc)
{
freq_min = g_ascii_strtod (fmin, NULL);
@@ -284,7 +264,6 @@ Options::parse (int *argc_p,
else if (check_arg (argc, argv, &i, "--oversample"))
resample_type = RES_OVERSAMPLE;
}
-
/* resort argc/argv */
guint e = 1;
for (i = 1; i < argc; i++)
@@ -296,22 +275,18 @@ Options::parse (int *argc_p,
}
*argc_p = e;
}
-
int
test_filter_impl()
{
return Bse::Block::test_resampler2 (options.filter_impl_verbose) ? 0 : 1;
}
-
double
gettime ()
{
timeval tv;
gettimeofday (&tv, 0);
-
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
-
template <int TEST, int RESAMPLE> int
perform_test()
{
@@ -330,17 +305,13 @@ perform_test()
*/
Resampler2 *ups = Resampler2::create (BSE_RESAMPLER2_MODE_UPSAMPLE, options.precision);
Resampler2 *downs = Resampler2::create (BSE_RESAMPLER2_MODE_DOWNSAMPLE, options.precision);
-
F4Vector in_v[block_size / 2 + 3], out_v[block_size / 2 + 3], out2_v[block_size / 2 + 3];
float *input = &in_v[0].f[0], *output = &out_v[0].f[0], *output2 = &out2_v[0].f[0]; /* ensure aligned data */
-
if (TEST == TEST_PERFORMANCE)
{
const gdouble test_frequency = options.frequency;
-
for (unsigned int i = 0; i < block_size; i++)
input[i] = sin (i * test_frequency / 44100.0 * 2 * M_PI);
-
double start_time = gettime();
long long k = 0;
for (int i = 0; i < 500000; i++)
@@ -384,7 +355,6 @@ perform_test()
const double freq_max = freq_scanning ? options.freq_max : 1.5 * options.frequency;
const double freq_inc = freq_scanning ? options.freq_inc : options.frequency;
vector<double> error_spectrum_error;
-
if (TEST == TEST_ACCURACY)
{
if (freq_scanning)
@@ -393,9 +363,7 @@ perform_test()
else
printf ("# input frequency used to perform test = %.2f Hz (SR = 44100.0 Hz)\n", options.frequency);
}
-
double max_diff = 0;
-
/* for getting the last frequency in ranges like [ 50, 18000, 50 ] scanned,
* even in the presence of rounding errors, we add 1 Hz to the end frequency
*/
@@ -404,20 +372,16 @@ perform_test()
long long k = 0;
double phase = 0, output_phase = 0;
double test_frequency_max_diff = 0; /* for monitoring frequency scanning */
-
while (k < 20000)
{
guint misalign = rand() % 4;
if (block_size <= misalign)
continue;
-
int bs = rand() % (block_size + 1 - misalign);
if (bs < 2)
continue;
-
if (RESAMPLE == RES_DOWNSAMPLE || RESAMPLE == RES_SUBSAMPLE)
bs -= bs & 1;
-
for (int i = 0; i < bs; i++)
{
input[i+misalign] = sin (phase);
@@ -437,14 +401,12 @@ perform_test()
if (RESAMPLE == RES_OVERSAMPLE)
downs->process_block (output, bs * 2, output2);
}
-
/* validate output */
double sin_shift;
double freq_factor;
double correct_volume;
unsigned int out_bs;
float *check = output;
-
if (RESAMPLE == RES_UPSAMPLE)
{
sin_shift = ups->delay();
@@ -475,7 +437,6 @@ perform_test()
out_bs = bs;
correct_volume = (test_frequency < (44100/4)) ? 1 : 0;
}
-
for (unsigned int i = 0; i < out_bs; i++, k++)
{
if (k > (ups->order() * 4))
@@ -484,7 +445,6 @@ perform_test()
* different frequency and is phase shifted a bit.
*/
double correct_output = sin (output_phase - sin_shift * 2 * freq_factor * test_frequency / 44100.0 * M_PI);
-
/* For some frequencies the expected output signal amplitude is
* zero, because it needed to be filtered out; this fact is
* taken into account here.
@@ -532,11 +492,9 @@ perform_test()
{
double fft_error[FFT_SIZE];
double normalize = 0;
-
for (guint i = 0; i < FFT_SIZE; i++)
{
double w = bse_window_blackman (double (2 * i - FFT_SIZE) / FFT_SIZE);
-
normalize += w;
error_spectrum_error[i] *= w;
}
@@ -546,22 +504,18 @@ perform_test()
normalize /= FFT_SIZE;
gsl_power2_fftar (FFT_SIZE, &error_spectrum_error[0], fft_error);
fft_error[1] = 0; // we don't process the extra value at FS/2
-
/* Normalization 2: the FFT produces FFT_SIZE/2 complex output values.
*/
normalize *= (FFT_SIZE / 2);
-
double freq_scale = 1; /* subsample + oversample */
if (RESAMPLE == RES_UPSAMPLE)
freq_scale = 2;
else if (RESAMPLE == RES_DOWNSAMPLE)
freq_scale = 0.5;
-
for (guint i = 0; i < FFT_SIZE/2; i++)
{
double normalized_error = bse_complex_abs (bse_complex (fft_error[i * 2], fft_error[i * 2 + 1])) / normalize;
double normalized_error_db = 20 * log (normalized_error) / log (10);
-
printf ("%f %f\n", i / double (FFT_SIZE) * 44100 * freq_scale, normalized_error_db);
}
}
@@ -576,7 +530,6 @@ perform_test()
output[i] = 0;
output2[i] = 0;
}
-
if (RESAMPLE == RES_DOWNSAMPLE || RESAMPLE == RES_SUBSAMPLE)
{
downs->process_block (input, block_size, output);
@@ -589,11 +542,9 @@ perform_test()
if (RESAMPLE == RES_OVERSAMPLE)
downs->process_block (output, block_size * 2, output2);
}
-
float *check = output;
if (RESAMPLE == RES_OVERSAMPLE || RESAMPLE == RES_SUBSAMPLE)
check = output2;
-
for (unsigned int i = 0; i < block_size; i++)
printf ("%.17f\n", check[i]);
}
@@ -601,12 +552,10 @@ perform_test()
delete downs;
return 0;
}
-
template <int TEST> int
perform_test ()
{
const char *instruction_set = Bse::Block::impl_name();
-
switch (resample_type)
{
case RES_DOWNSAMPLE: printf ("for factor 2 downsampling using %s instructions\n", instruction_set);
@@ -621,7 +570,6 @@ perform_test ()
return 1;
}
}
-
int
perform_test()
{
@@ -636,7 +584,6 @@ perform_test()
default: usage(); return 1;
}
}
-
int
main (int argc, char **argv)
{
@@ -646,7 +593,6 @@ main (int argc, char **argv)
for (int i = 0; i < argc; i++)
if (strcmp (argv[i], "--fpu") == 0)
argv[i] = g_strdup ("--bse-force-fpu"); /* leak, but we don't care */
-
/* load plugins */
SfiInitValue config[] = {
{ "load-core-plugins", "1" },
@@ -654,7 +600,6 @@ main (int argc, char **argv)
};
bse_init_test (&argc, &argv, config);
options.parse (&argc, &argv);
-
if (argc == 2)
{
string command = argv[1];
diff --git a/tests/testresamplerq.cc b/tests/testresamplerq.cc
index 8d5c149..f6326dd 100644
--- a/tests/testresamplerq.cc
+++ b/tests/testresamplerq.cc
@@ -1,5 +1,4 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bseresampler.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
@@ -10,18 +9,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
-
using Bse::Resampler::Resampler2;
using Birnet::AlignedArray;
using std::vector;
using std::max;
using std::min;
-
struct Options
{
size_t test_size;
size_t rand_samples;
-
// default test parameters
Options() :
test_size (512),
@@ -29,34 +25,28 @@ struct Options
{
}
} options;
-
class ResamplerTest
{
public:
double passband_err;
double stopband_err;
double max_error;
-
void check_spectrum (const vector<float>& impulse_response, int p);
void check_resampler_up (BseResampler2Precision precision);
void check_resampler_down (BseResampler2Precision precision);
};
-
void
ResamplerTest::check_spectrum (const vector<float>& impulse_response, int p)
{
vector<double> fft_in (4096), spect (fft_in.size());
-
for (size_t i = 0; i < min (impulse_response.size(), fft_in.size()); i++)
{
fft_in[i] = impulse_response[i] / 2;
}
gsl_power2_fftar (fft_in.size(), &fft_in[0], &spect[0]);
spect[1] = 0; // special packing
-
passband_err = 0;
stopband_err = 0;
-
for (size_t i = 0; i < 4096; i += 2)
{
const double re = spect[i], im = spect[i + 1];
@@ -68,7 +58,6 @@ ResamplerTest::check_spectrum (const vector<float>& impulse_response, int p)
stopband_err = max (stopband_err, fabs (mag));
}
}
-
void
ResamplerTest::check_resampler_up (BseResampler2Precision precision)
{
@@ -76,7 +65,6 @@ ResamplerTest::check_resampler_up (BseResampler2Precision precision)
AlignedArray<float,16> input (options.test_size);
AlignedArray<float,16> output (options.test_size * 2);
vector< vector<float> > results;
-
for (size_t i = 0; i < (options.test_size / 2); i++)
{
input[i] = 1;
@@ -95,7 +83,6 @@ ResamplerTest::check_resampler_up (BseResampler2Precision precision)
for (size_t i = 0; i < options.rand_samples; i++)
input[i] = g_random_double_range (-1, 1);
ups->process_block (&input[0], input.size(), &output[0]);
-
max_error = 0;
for (size_t j = 0; j < output.size(); j++)
{
@@ -108,7 +95,6 @@ ResamplerTest::check_resampler_up (BseResampler2Precision precision)
}
check_spectrum (results[0], precision);
}
-
void
ResamplerTest::check_resampler_down (BseResampler2Precision precision)
{
@@ -116,7 +102,6 @@ ResamplerTest::check_resampler_down (BseResampler2Precision precision)
AlignedArray<float,16> input (options.test_size * 2);
AlignedArray<float,16> output (options.test_size);
vector< vector<float> > results;
-
for (size_t i = 0; i < (options.test_size / 2); i++)
{
input[i] = 1;
@@ -143,7 +128,6 @@ ResamplerTest::check_resampler_down (BseResampler2Precision precision)
}
max_error = max (fabs (output[j] - acc), max_error);
}
-
/* The downsampler convolves the input with an FIR filter to achieve a
* lowpass filter around half the sampling frequency. Since it throws
* away every second sample, we need to merge the impulse responses
@@ -158,7 +142,6 @@ ResamplerTest::check_resampler_down (BseResampler2Precision precision)
}
check_spectrum (merged_ir, precision);
}
-
static double
band_err (BseResampler2Precision p)
{
@@ -177,38 +160,30 @@ band_err (BseResampler2Precision p)
default: g_assert_not_reached();
}
}
-
static void
run_tests (const char *label)
{
BseResampler2Precision p = BSE_RESAMPLER2_PREC_96DB; // should not be equal to the first resampler precision
-
for (int i = 0; i < 32; i++)
{
BseResampler2Precision new_p = Resampler2::find_precision_for_bits (i);
if (new_p != p)
{
p = new_p;
-
TSTART ("Resampler %s Precision %d", label, p);
-
ResamplerTest rt_up;
rt_up.check_resampler_up (p);
-
TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));
-
//printf ("## UP %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_up.max_error, -200),
//bse_db_from_factor (rt_up.passband_err, -200),
//bse_db_from_factor (rt_up.stopband_err, -200));
ResamplerTest rt_down;
rt_down.check_resampler_down (p);
-
TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));
-
//printf ("## DOWN %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_down.max_error, -200),
//bse_db_from_factor (rt_down.passband_err, -200),
//bse_db_from_factor (rt_down.stopband_err, -200));
@@ -216,7 +191,6 @@ run_tests (const char *label)
}
}
}
-
int
main (int argc, char **argv)
{
@@ -234,7 +208,6 @@ main (int argc, char **argv)
g_print ("Resampler test parameters: test_size=%zd rand_samples=%zd\n",
options.test_size, options.rand_samples);
run_tests ("FPU");
-
/* load plugins */
SfiInitValue config[] = {
{ "load-core-plugins", "1" },
diff --git a/tests/testwavechunk.c b/tests/testwavechunk.c
index ae56684..5e73e91 100644
--- a/tests/testwavechunk.c
+++ b/tests/testwavechunk.c
@@ -10,7 +10,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
-
enum {
VERBOSITY_NONE,
VERBOSITY_SETUP,
@@ -20,7 +19,6 @@ enum {
VERBOSITY_CHECKS,
};
static guint verbosity = VERBOSITY_NONE;
-
static gfloat my_data[] = {
0.555555555,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
@@ -28,13 +26,10 @@ static gfloat my_data[] = {
30,31,32,33,34,35,36,
};
static guint my_data_length = sizeof (my_data) / sizeof (my_data[0]);
-
static void print_block (GslWaveChunk *wchunk,
GslWaveChunkBlock *block);
-
#define DEBUG_SIZE (1024 * 256)
#define MINI_DEBUG_SIZE (16)
-
static void
run_loop_test (GslWaveLoopType loop_type,
gint play_dir,
@@ -49,7 +44,6 @@ run_loop_test (GslWaveLoopType loop_type,
GslWaveChunkBlock block = { 0, };
GslWaveChunk *wchunk;
BseErrorType error;
-
myhandle = gsl_data_handle_new_mem (1, 32, 44100, 440, my_data_length, my_data, NULL);
dcache = gsl_data_cache_new (myhandle, 1);
gsl_data_handle_unref (myhandle);
@@ -64,17 +58,13 @@ run_loop_test (GslWaveLoopType loop_type,
g_print ("SETUP: loop_type=%u loop_first=%lld loop_last=%lld loop_count=%d playdir=%+d\n",
wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count, play_dir);
gsl_wave_chunk_debug_block (wchunk, - DEBUG_SIZE / 2, DEBUG_SIZE, cmpblock - DEBUG_SIZE / 2);
-
block.play_dir = play_dir;
-
block.offset = block.play_dir < 0 ? wchunk->wave_length + MINI_DEBUG_SIZE/2 : -MINI_DEBUG_SIZE/2;
while (block.offset < wchunk->wave_length + MINI_DEBUG_SIZE &&
block.offset > -MINI_DEBUG_SIZE)
{
gint i, start, end, abort;
-
gsl_wave_chunk_use_block (wchunk, &block);
-
print_block (wchunk, &block);
if (block.play_dir > 0)
{
@@ -90,7 +80,6 @@ run_loop_test (GslWaveLoopType loop_type,
for (i = start; i != end; i += block.play_dir)
{
gfloat v = (block.play_dir < 0) ^ (block.dirstride > 0) ? block.start[i - block.offset] : block.start[block.offset - i];
-
if (fabs (cmpblock[i] - v) > 1e-15)
{
abort = TRUE;
@@ -107,25 +96,20 @@ run_loop_test (GslWaveLoopType loop_type,
wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count,
gsl_data_handle_length (wchunk->dcache->dhandle));
}
-
gsl_wave_chunk_unuse_block (wchunk, &block);
-
block.offset = block.next_offset;
/* block.offset += block.play_dir; */
}
gsl_wave_chunk_close (wchunk);
gsl_data_cache_unref (dcache);
-
g_free (tmpstorage);
}
-
static void
print_block (GslWaveChunk *wchunk,
GslWaveChunkBlock *block)
{
gfloat *p = NULL;
guint i;
-
if (verbosity >= VERBOSITY_BLOCKS)
{
g_print ("BLOCK:");
@@ -133,7 +117,6 @@ print_block (GslWaveChunk *wchunk,
g_print (" length=%lld", block->length);
g_print (" dirstride=%d", block->dirstride);
}
-
if (verbosity >= VERBOSITY_PADDING)
{
g_print (" {prepad:");
@@ -146,7 +129,6 @@ print_block (GslWaveChunk *wchunk,
}
g_print ("}");
}
-
if (verbosity >= VERBOSITY_DATA)
{
g_print (" {data:");
@@ -158,7 +140,6 @@ print_block (GslWaveChunk *wchunk,
}
g_print ("}");
}
-
if (verbosity >= VERBOSITY_PADDING)
{
i = wchunk->n_pad_values;
@@ -170,11 +151,9 @@ print_block (GslWaveChunk *wchunk,
}
g_print ("}");
}
-
if (verbosity >= VERBOSITY_BLOCKS)
g_print ("\n");
}
-
static void
reversed_datahandle_test (void)
{
@@ -182,9 +161,7 @@ reversed_datahandle_test (void)
GslDataHandle *rhandle1, *rhandle2;
GslLong o, l, i, e;
BseErrorType error;
-
TSTART ("reversed datahandle");
-
myhandle = gsl_data_handle_new_mem (1, 32, 44100, 440, my_data_length, my_data, NULL);
rhandle1 = gsl_data_handle_new_reverse (myhandle);
gsl_data_handle_unref (myhandle);
@@ -194,9 +171,7 @@ reversed_datahandle_test (void)
if (error)
g_error ("failed to open rhandle2: %s", bse_error_blurb (error));
gsl_data_handle_unref (rhandle2);
-
TASSERT (gsl_data_handle_length (rhandle2) == gsl_data_handle_length (myhandle));
-
for (i = 1; i < 8; i++)
{
o = 0;
@@ -204,7 +179,6 @@ reversed_datahandle_test (void)
while (l)
{
gfloat d1[8], d2[8];
-
e = gsl_data_handle_read (myhandle, o, MIN (i, l), d1);
TCHECK (e == MIN (i, l));
e = gsl_data_handle_read (rhandle2, o, MIN (i, l), d2);
@@ -216,10 +190,8 @@ reversed_datahandle_test (void)
TOK();
}
gsl_data_handle_close (rhandle2);
-
TDONE();
}
-
static void
simple_loop_tests (void)
{
@@ -240,7 +212,6 @@ simple_loop_tests (void)
TOK();
TDONE();
}
-
static void
brute_force_loop_tests (void)
{
@@ -262,7 +233,6 @@ brute_force_loop_tests (void)
TDONE();
}
}
-
static float *
gen_expect (float *out,
int begin,
@@ -271,7 +241,6 @@ gen_expect (float *out,
{
int frame;
int delta = (begin < end) ? 1 : -1;
-
for (frame = begin; frame != end; frame += delta)
{
int ch;
@@ -282,7 +251,6 @@ gen_expect (float *out,
}
return out;
}
-
static void
multi_channel_test_one (int pingpong,
int channels,
@@ -294,17 +262,14 @@ multi_channel_test_one (int pingpong,
GslDataCache *dcache;
GslWaveChunk *wchunk;
BseErrorType error;
-
const int LOOP_COUNT = 20;
const int LOOP_TYPE = pingpong ? GSL_WAVE_LOOP_PINGPONG : GSL_WAVE_LOOP_JUMP;
size_t my_data_length = channels * frames;
float *my_data = malloc (my_data_length * sizeof (float));
-
int p, c;
for (p = 0; p < frames; p++)
for (c = 0; c < channels; c++)
my_data[p * channels + c] = p + (c + 1.0) / (channels + 1.0);
-
myhandle = gsl_data_handle_new_mem (channels, 32, 44100, 440, my_data_length, my_data, NULL);
dcache = gsl_data_cache_new (myhandle, channels);
gsl_data_handle_unref (myhandle);
@@ -315,7 +280,6 @@ multi_channel_test_one (int pingpong,
if (error)
g_error ("failed to open wave chunk: %s", bse_error_blurb (error));
gsl_wave_chunk_unref (wchunk);
-
float *expect = malloc (my_data_length * sizeof (float) * (LOOP_COUNT + 1));
float *ep = expect;
int l;
@@ -328,16 +292,13 @@ multi_channel_test_one (int pingpong,
}
ep = gen_expect (ep, loop_start, loop_end + 1, channels);
ep = gen_expect (ep, loop_end + 1, frames, channels);
-
GslWaveChunkBlock block = { 0, };
block.play_dir = 1;
block.offset = 0;
-
GslLong pos = 0;
while (block.offset < wchunk->wave_length)
{
gsl_wave_chunk_use_block (wchunk, &block);
-
float *f;
double max_diff = 0;
int step;
@@ -345,7 +306,6 @@ multi_channel_test_one (int pingpong,
step = -1;
else
step = 1;
-
for (f = block.start; f != block.end; f += step)
{
if (pos < wchunk->wave_length)
@@ -359,7 +319,6 @@ multi_channel_test_one (int pingpong,
free (expect);
free (my_data);
}
-
static void
multi_channel_tests()
{
@@ -371,7 +330,6 @@ multi_channel_tests()
for (channels = 1; channels <= 32; channels++)
{
bool skip = false;
-
if (pingpong && (channels > 1)) // FIXME: ping pong multichannel loops are broken
{
skip = true;
@@ -389,7 +347,6 @@ multi_channel_tests()
multi_channel_test_one (pingpong, channels, 4028, 1001, 3977);
}
}
-
if (!skip)
TOK();
else
@@ -398,7 +355,6 @@ multi_channel_tests()
}
TDONE();
}
-
int
main (gint argc,
gchar *argv[])
@@ -412,12 +368,10 @@ main (gint argc,
{ NULL }
};
bse_init_test (&argc, &argv, ivalues);
-
reversed_datahandle_test();
simple_loop_tests();
multi_channel_tests();
if (sfi_init_settings().test_slow)
brute_force_loop_tests();
-
return 0;
}
diff --git a/tools/bsefcompare.cc b/tools/bsefcompare.cc
index 3fc7717..001d453 100644
--- a/tools/bsefcompare.cc
+++ b/tools/bsefcompare.cc
@@ -1,8 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-
#include <bse/bseengine.hh>
#include <bse/bsemathsignal.hh>
-
#include <bse/gsldatautils.hh>
#include <bse/gslfft.hh>
#include <stdio.h>
@@ -12,28 +10,22 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
-
#include "topconfig.h"
-
#include <map>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
-
using namespace std;
-
struct Options {
string program_name;
double threshold;
bool compact;
bool strict;
-
Options ();
void parse (int *argc_p, char **argv_p[]);
static void print_usage ();
} options;
-
Options::Options ()
{
program_name = "bsefcompare";
@@ -41,7 +33,6 @@ Options::Options ()
compact = false;
strict = false;
}
-
static bool
check_arg (uint argc,
char *argv[],
@@ -51,11 +42,9 @@ check_arg (uint argc,
{
g_return_val_if_fail (opt != NULL, false);
g_return_val_if_fail (*nth < argc, false);
-
const char *arg = argv[*nth];
if (!arg)
return false;
-
uint opt_len = strlen (opt);
if (strcmp (arg, opt) == 0)
{
@@ -85,11 +74,9 @@ check_arg (uint argc,
}
else
return false;
-
Options::print_usage();
exit (1);
}
-
void
Options::parse (int *argc_p,
char **argv_p[])
@@ -97,16 +84,13 @@ Options::parse (int *argc_p,
guint argc = *argc_p;
gchar **argv = *argv_p;
unsigned int i;
-
g_return_if_fail (argc >= 0);
-
/* I am tired of seeing .libs/lt-bsefcompare all the time,
* but basically this should be done (to allow renaming the binary):
*
if (argc && argv[0])
program_name = argv[0];
*/
-
for (i = 1; i < argc; i++)
{
const char *opt_arg;
@@ -131,7 +115,6 @@ Options::parse (int *argc_p,
else if (check_arg (argc, argv, &i, "--threshold", &opt_arg))
threshold = g_ascii_strtod (opt_arg, NULL);
}
-
/* resort argc/argv */
guint e = 1;
for (i = 1; i < argc; i++)
@@ -143,7 +126,6 @@ Options::parse (int *argc_p,
}
*argc_p = e;
}
-
void
Options::print_usage ()
{
@@ -158,17 +140,14 @@ Options::print_usage ()
fprintf (stderr, " --help help for %s\n", program_name.c_str());
fprintf (stderr, " --version print version\n");
}
-
static double
vector_len (const vector<double>& v)
{
double sqrlen = 0.0;
for (size_t i = 0; i < v.size(); i++)
sqrlen += v[i] * v[i];
-
return sqrt (sqrlen);
}
-
static double
number_similarity (double a, double b)
{
@@ -182,10 +161,8 @@ number_similarity (double a, double b)
double base = 1;
base = max (base, fabs (a));
base = max (base, fabs (b));
-
return (1.0 - fabs (a - b) / base);
}
-
static double
vector_similarity (const vector<double>& f1, const vector<double>& f2)
{
@@ -194,37 +171,28 @@ vector_similarity (const vector<double>& f1, const vector<double>& f2)
{
if (options.strict)
return -1;
-
uint min_size = min (f1.size(), f2.size());
vector<double> common_f1 (f1.begin(), f1.begin() + min_size);
vector<double> common_f2 (f2.begin(), f2.begin() + min_size);
return vector_similarity (common_f1, common_f2);
}
-
double f1len = vector_len (f1);
double f2len = vector_len (f2);
-
bool f1null = f1len < BSE_DOUBLE_MIN_NORMAL;
bool f2null = f2len < BSE_DOUBLE_MIN_NORMAL;
-
if (f1null && f2null)
return 1.0;
-
if (f1null || f2null)
return 0.0; /* FIXME: is this a good result in that case? */
-
/*
* this computes the angle between the two vectors in n-dimensional space
*/
double diff = 0.0;
for (size_t i = 0; i < f1.size(); i++)
diff += f1[i] * f2[i];
-
return diff / f1len / f2len;
}
-
static string string_printf (const char *format, ...) G_GNUC_PRINTF (1, 2);
-
static string
string_printf (const char *format, ...)
{
@@ -236,8 +204,6 @@ string_printf (const char *format, ...)
g_free (c_str);
return str;
}
-
-
static GScannerConfig scanner_config_template = {
const_cast<gchar *> /* FIXME: glib should use const gchar* here */
(
@@ -257,9 +223,7 @@ static GScannerConfig scanner_config_template = {
) /* cset_identifier_nth */,
const_cast<gchar *>
( "#\n" ) /* cpair_comment_single */,
-
TRUE /* case_sensitive */,
-
TRUE /* skip_comment_multi */,
TRUE /* skip_comment_single */,
TRUE /* scan_comment_multi */,
@@ -282,7 +246,6 @@ static GScannerConfig scanner_config_template = {
FALSE /* scope_0_fallback */,
TRUE /* store_int64 */,
};
-
#define parse_or_return(token) G_STMT_START{ \
GTokenType _t = GTokenType(token); \
if (g_scanner_get_next_token (scanner) != _t) \
@@ -313,7 +276,6 @@ static GScannerConfig scanner_config_template = {
i = scanner->value.v_int64; \
if (negate) i = -i; \
}G_STMT_END
-
struct FeatureValue {
string name;
enum Type {
@@ -321,7 +283,6 @@ struct FeatureValue {
TYPE_VECTOR,
TYPE_MATRIX
} type;
-
FeatureValue (string name, Type type) : name (name), type (type)
{
}
@@ -342,61 +303,47 @@ struct FeatureValue {
*/
virtual double similarity (const FeatureValue *value) const = 0;
};
-
struct FeatureValueNumber : FeatureValue {
double number;
-
FeatureValueNumber (const string& name) : FeatureValue (name, TYPE_NUMBER)
{
number = 0.0; /* hopefully never used, but initialized by parse */
}
-
GTokenType parse (GScanner *scanner);
string printable_type() const;
double similarity (const FeatureValue *value) const;
};
-
struct FeatureValueVector : FeatureValue {
int n;
vector<double> data; /* well, can't call it vector */
-
FeatureValueVector (const string& name, int n) : FeatureValue (name, TYPE_VECTOR), n (n)
{
}
-
GTokenType parse (GScanner *scanner);
string printable_type() const;
double similarity (const FeatureValue *value) const;
};
-
struct FeatureValueMatrix : FeatureValue {
int m, n;
vector< vector<double> > matrix;
-
FeatureValueMatrix (const string& name, int m, int n) : FeatureValue (name, TYPE_MATRIX), m (m), n (n)
{
}
-
GTokenType parse (GScanner *scanner);
string printable_type() const;
double similarity (const FeatureValue *value) const;
};
-
struct FeatureValueFile {
string filename;
vector<FeatureValue*> feature_values;
-
GTokenType parseFeatureValue (GScanner *scanner);
void parse (const string& filename);
-
~FeatureValueFile();
};
-
class ComparisionStrategy
{
FeatureValue::Type m_type;
static map<string, ComparisionStrategy*> m_strategies;
-
public:
ComparisionStrategy (FeatureValue::Type type) :
m_type (type)
@@ -415,7 +362,6 @@ public:
register_strategy (const string& feature_name)
{
g_return_if_fail (!m_strategies[feature_name]);
-
m_strategies[feature_name] = this;
}
static ComparisionStrategy*
@@ -423,7 +369,6 @@ public:
FeatureValue::Type type)
{
ComparisionStrategy* s = m_strategies[feature_name];
-
// produce a warning for a strategy with the right feature name but a wrong type
if (s)
{
@@ -435,43 +380,33 @@ public:
similarity (const FeatureValue *value1,
const FeatureValue *value2) const = 0;
};
-
map<string, ComparisionStrategy*> ComparisionStrategy::m_strategies;
-
//------- FeatureValueNumber implementation --------
-
GTokenType
FeatureValueNumber::parse (GScanner *scanner)
{
parse_float_or_return (number);
-
return G_TOKEN_NONE;
}
-
string
FeatureValueNumber::printable_type() const
{
return "number";
}
-
double
FeatureValueNumber::similarity (const FeatureValue *value) const
{
if (value->type != type || value->name != name)
return -1;
-
// custom strategy?
const ComparisionStrategy *strategy = ComparisionStrategy::find_strategy (name, type);
if (strategy)
return strategy->similarity (this, value);
-
// no? -> default strategy
const FeatureValueNumber *v = static_cast<const FeatureValueNumber *> (value);
return number_similarity (number, v->number);
}
-
//------- FeatureValueVector implementation --------
-
GTokenType
FeatureValueVector::parse (GScanner *scanner)
{
@@ -483,34 +418,27 @@ FeatureValueVector::parse (GScanner *scanner)
data.push_back (d);
}
parse_or_return ('}');
-
return G_TOKEN_NONE;
}
-
string
FeatureValueVector::printable_type() const
{
return string_printf ("%d element vector", n);
}
-
double
FeatureValueVector::similarity (const FeatureValue *value) const
{
if (value->type != type || value->name != name)
return -1;
-
// custom strategy?
const ComparisionStrategy *strategy = ComparisionStrategy::find_strategy (name, type);
if (strategy)
return strategy->similarity (this, value);
-
// no? -> default strategy
const FeatureValueVector *v = static_cast<const FeatureValueVector *> (value);
return vector_similarity (data, v->data); // can return -1 on size mismatch when --strict is set
}
-
//------- FeatureValueMatrix implementation --------
-
GTokenType
FeatureValueMatrix::parse (GScanner *scanner)
{
@@ -528,7 +456,6 @@ FeatureValueMatrix::parse (GScanner *scanner)
for (int i = 0; i < m; i++)
{
parse_or_return ('{');
-
vector<double> line;
for (int j = 0; j < n; j++)
{
@@ -540,34 +467,27 @@ FeatureValueMatrix::parse (GScanner *scanner)
parse_or_return ('}');
}
parse_or_return ('}');
-
return G_TOKEN_NONE;
}
-
string
FeatureValueMatrix::printable_type() const
{
return string_printf ("%d x %d matrix", m, n);
}
-
double
FeatureValueMatrix::similarity (const FeatureValue *value) const
{
if (value->type != type || value->name != name)
return -1;
-
// custom strategy?
const ComparisionStrategy *strategy = ComparisionStrategy::find_strategy (name, type);
if (strategy)
return strategy->similarity (this, value);
-
// no? -> default strategy
const FeatureValueMatrix *v = static_cast<const FeatureValueMatrix *> (value);
-
/* matrix dimensions must match for strict comparision */
if (options.strict && (m != v->m || n != v->n))
return -1;
-
double s = 0;
uint min_m = min (m, v->m);
if (min_m)
@@ -581,32 +501,24 @@ FeatureValueMatrix::similarity (const FeatureValue *value) const
return 0; /* FIXME: or return 1, or return 1 IFF permissive? */
}
}
-
//------- FeatureValueFile implementation --------
-
GTokenType
FeatureValueFile::parseFeatureValue (GScanner *scanner)
{
FeatureValue *value = NULL;
-
string name = scanner->value.v_identifier;
-
if (g_scanner_peek_next_token (scanner) == G_TOKEN_LEFT_BRACE)
{
int a;
-
parse_or_return (G_TOKEN_LEFT_BRACE);
parse_int_or_return (a);
-
if (g_scanner_peek_next_token (scanner) == ',')
{
int b;
-
parse_or_return (',');
parse_int_or_return (b);
parse_or_return (G_TOKEN_RIGHT_BRACE);
parse_or_return ('=');
-
/* a x b matrix */
value = new FeatureValueMatrix (name, a, b);
}
@@ -614,7 +526,6 @@ FeatureValueFile::parseFeatureValue (GScanner *scanner)
{
parse_or_return (G_TOKEN_RIGHT_BRACE);
parse_or_return ('=');
-
/* a elements vector */
value = new FeatureValueVector (name, a);
}
@@ -624,23 +535,19 @@ FeatureValueFile::parseFeatureValue (GScanner *scanner)
parse_or_return ('=');
value = new FeatureValueNumber (name);
}
-
/* parse the actual value */
GTokenType expected_token = value->parse (scanner);
if (expected_token != G_TOKEN_NONE)
return expected_token;
-
parse_or_return (';');
feature_values.push_back (value);
return G_TOKEN_NONE;
}
-
void
FeatureValueFile::parse (const string& filename)
{
g_return_if_fail (this->filename == "");
this->filename = filename;
-
GScanner *scanner = g_scanner_new64 (&scanner_config_template);
int fd = open (filename.c_str(), O_RDONLY);
if (fd < 0)
@@ -651,12 +558,10 @@ FeatureValueFile::parse (const string& filename)
}
g_scanner_input_file (scanner, fd);
scanner->input_name = this->filename.c_str();
-
GTokenType expected_token = G_TOKEN_NONE;
while (!g_scanner_eof (scanner) && expected_token == G_TOKEN_NONE)
{
g_scanner_get_next_token (scanner);
-
if (scanner->token == G_TOKEN_EOF)
break;
else if (scanner->token == G_TOKEN_IDENTIFIER)
@@ -664,36 +569,30 @@ FeatureValueFile::parse (const string& filename)
else
expected_token = G_TOKEN_EOF; /* '('; */
}
-
if (expected_token != G_TOKEN_NONE)
{
g_scanner_unexp_token (scanner, expected_token, NULL, NULL, NULL, NULL, TRUE);
exit (1);
}
}
-
FeatureValueFile::~FeatureValueFile()
{
for (vector<FeatureValue *>::iterator fvi = feature_values.begin(); fvi != feature_values.end(); fvi++)
delete *fvi;
}
-
int
main (int argc, char **argv)
{
/* parse options */
options.parse (&argc, &argv);
-
if (argc != 3)
{
options.print_usage ();
return 1;
}
-
FeatureValueFile file1, file2;
file1.parse (argv[1]);
file2.parse (argv[2]);
-
if (file1.feature_values.size() != file2.feature_values.size())
{
g_printerr ("%s: can't compare files\n", options.program_name.c_str());
@@ -701,7 +600,6 @@ main (int argc, char **argv)
g_printerr (" * file \"%s\" contains %zd feature values\n", file2.filename.c_str(), file2.feature_values.size());
exit (1);
}
-
vector<double> similarity;
for (uint i = 0; i < file1.feature_values.size(); i++)
{
@@ -719,11 +617,9 @@ main (int argc, char **argv)
}
similarity.push_back (s);
}
-
double s = 0.0;
double min_s = similarity.empty() ? 0.0 : similarity[0];
double max_s = min_s;
-
printf ("similarities: ");
for (size_t i = 0; i < similarity.size(); i++)
{
@@ -740,7 +636,6 @@ main (int argc, char **argv)
if (options.compact)
printf ("minimum=%.2f%% maximum=%.2f%%", min_s * 100.0, max_s * 100.0);
printf ("\n");
-
double average_similarity = s / similarity.size() * 100.0; /* percent */
/* We check this first, because we explicitely allow setting the threshold
* to a value > 100%, which will make bsefcompare always fail.
@@ -762,9 +657,7 @@ main (int argc, char **argv)
printf ("average similarity rating (%s): %.3f%%\n", rating.c_str(), average_similarity);
return result;
}
-
// extra comparision strategies
-
class TimingComparisionStrategy : public ComparisionStrategy
{
public:
@@ -779,13 +672,10 @@ public:
{
const FeatureValueVector *vec1 = static_cast<const FeatureValueVector *> (value1);
const FeatureValueVector *vec2 = static_cast<const FeatureValueVector *> (value2);
-
g_printerr ("using custom TimingComparisionStrategy\n");
-
// the sizes of the two vectors can be different
uint size = min (vec1->data.size(), vec2->data.size());
double match = 0.0;
-
for (uint i = 0; i < size; i++)
{
// this is a really stupid epsilon diff
@@ -796,5 +686,4 @@ public:
return size ? match / size : 1;
}
} timingComparisionStrategy;
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tools/bsefextract.cc b/tools/bsefextract.cc
index e25909e..ad5d4e1 100644
--- a/tools/bsefextract.cc
+++ b/tools/bsefextract.cc
@@ -12,14 +12,12 @@
#include <errno.h>
#include <assert.h>
#include "topconfig.h"
-
#include <map>
#include <string>
#include <vector>
#include <utility>
#include <list>
#include <complex>
-
// using namespace std;
using std::string;
using std::map;
@@ -27,7 +25,6 @@ using std::list;
using std::vector;
using std::min;
using std::max;
-
struct Options {
string program_name; /* FIXME: what to do with that */
guint channel;
@@ -41,16 +38,13 @@ struct Options {
guint join_spectrum_slices;
guint timing_window_stepping_ms;
guint timing_window_size_ms;
-
FILE *output_file;
-
Options ();
void parse (int *argc_p, char **argv_p[]);
static void print_usage ();
void validate_percent (const string& option, gdouble value);
void validate_int (const string& option, int value, int vmin, int vmax);
} options;
-
class Signal
{
vector<float> m_samples;
@@ -58,27 +52,22 @@ class Signal
guint m_n_channels;
GslLong m_length;
GslLong m_offset;
-
/* check if the first sample is silent on all channels */
bool head_is_silent()
{
for (guint i = 0; i < m_n_channels; i++)
if (fabs ((*this)[i]) > options.silence_threshold)
return false;
-
return true;
}
-
/* check if the last sample is silent on all channels */
bool tail_is_silent()
{
for (guint i = 0; i < m_n_channels; i++)
if (fabs ((*this)[m_length - m_n_channels + i]) > options.silence_threshold)
return false;
-
return true;
}
-
public:
Signal (GslDataHandle *data_handle) :
m_data_handle (data_handle)
@@ -86,7 +75,6 @@ public:
m_n_channels = gsl_data_handle_n_channels (data_handle);
m_length = gsl_data_handle_length (data_handle);
m_offset = 0;
-
m_samples.resize (m_length);
size_t have_samples = 0;
while (have_samples < m_length)
@@ -100,7 +88,6 @@ public:
}
have_samples += r;
}
-
if (options.cut_zeros_head)
{
/* cut_zeros head */
@@ -118,65 +105,50 @@ public:
m_length -= m_n_channels;
}
}
-
// calculate focus - first: make sure focus region is inside the signal
if (options.focus_center - (options.focus_width / 2.0) < 0.0)
options.focus_center = (options.focus_width / 2.0);
-
if (options.focus_center + (options.focus_width / 2.0) > 100.0)
options.focus_center = 100.0 - (options.focus_width / 2.0);
-
// cut samples which are outside the focus region
double start = options.focus_center - (options.focus_width / 2.0);
double end = options.focus_center + (options.focus_width / 2.0);
-
GslLong istart = GslLong (start / 100.0 * m_length + 0.5);
GslLong iend = GslLong (end / 100.0 * m_length + 0.5);
-
istart -= istart % m_n_channels;
iend -= iend % m_n_channels;
-
m_offset += istart;
m_length = iend - istart;
}
-
GslLong length() const
{
return m_length;
}
-
guint n_channels() const
{
return m_n_channels;
}
-
double operator[] (GslLong k) const
{
return m_samples[k + m_offset];
}
-
double mix_freq() const
{
return gsl_data_handle_mix_freq (m_data_handle);
}
-
double time_ms (GslLong k) const
{
GslLong n_frames = k / n_channels();
return n_frames * 1000.0 / mix_freq();
}
};
-
struct Feature;
-
list<Feature *> feature_list;
-
struct Feature
{
const char *option;
const char *description;
bool extract_feature; /* did the user enable this feature with --feature? */
-
string
double_to_string (double value,
bool align = false) const
@@ -185,14 +157,12 @@ struct Feature
g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, align ? "%-15.9g" : "%.9g", value);
return numbuf;
}
-
void
print_value (const string &value_name,
double data) const
{
fprintf (options.output_file, "%s = %s;\n", value_name.c_str(), double_to_string (data).c_str());
}
-
void
print_vector (const string &vector_name,
const vector<double> &data) const
@@ -202,7 +172,6 @@ struct Feature
fprintf (options.output_file, " %s", double_to_string (*di, true).c_str());
fprintf (options.output_file, " };\n");
}
-
void
print_matrix (const string &matrix_name,
const vector< vector<double> > &matrix) const
@@ -219,19 +188,16 @@ struct Feature
*/
fprintf (options.output_file, "%s[%zd,%zd] = {\n",
matrix_name.c_str(), matrix.size(), matrix.size() ? matrix[0].size() : 0);
-
for (vector< vector<double> >::const_iterator mi = matrix.begin(); mi != matrix.end(); mi++)
{
fprintf (options.output_file, " {");
const vector<double>& line = *mi;
-
for (vector<double>::const_iterator li = line.begin(); li != line.end(); li++)
fprintf (options.output_file, " %s", double_to_string (*li, true).c_str());
fprintf (options.output_file, " }\n");
}
fprintf (options.output_file, "};\n");
}
-
Feature (const char *option,
const char *description) :
option (option),
@@ -239,14 +205,12 @@ struct Feature
extract_feature (false)
{
}
-
virtual void compute (const Signal &signal) = 0;
virtual void print_results() const = 0;
virtual ~Feature()
{
}
};
-
struct StartTimeFeature : public Feature
{
double start_time;
@@ -273,7 +237,6 @@ struct StartTimeFeature : public Feature
print_value ("start_time", start_time);
}
};
-
struct EndTimeFeature : public Feature
{
double end_time;
@@ -294,45 +257,36 @@ struct EndTimeFeature : public Feature
print_value ("end_time", end_time);
}
};
-
struct SpectrumFeature : public Feature
{
vector< vector<double> > spectrum;
vector< vector<double> > joined_spectrum;
vector< double > window;
-
SpectrumFeature() :
Feature ("--spectrum", "generate 30ms sliced frequency spectrums")
{
}
-
void
init_window (size_t size)
{
window.resize (size);
-
for (size_t i = 0; i < size; i++)
window[i] = bse_window_blackman (2.0 * i / size - 1.0); /* the bse blackman window is defined in range [-1, 1] */
}
-
vector<double>
build_frequency_vector (double *samples)
{
const size_t size = window.size();
assert (size > 0);
-
vector<double> fvector;
double in[size], c[size + 2], *im;
-
for (size_t i = 0; i < size; i++)
in[i] = window[i] * samples[i];
-
gsl_power2_fftar (size, in, c);
c[size] = c[1];
c[size + 1] = 0;
c[1] = 0;
im = c + 1;
-
for (size_t i = 0; i <= size >> 1; i++)
{
double abs = sqrt (c[i << 1] * c[i << 1] + im[i << 1] * im[i << 1]);
@@ -341,7 +295,6 @@ struct SpectrumFeature : public Feature
}
return fvector;
}
-
vector<double>
collapse_frequency_vector (const vector<double> &fvector,
double mix_freq,
@@ -351,7 +304,6 @@ struct SpectrumFeature : public Feature
vector<double> result;
double value = 0;
int count = 0;
-
for (size_t j = 0; j < fvector.size(); j++)
{
double freq = (j * mix_freq) / (fvector.size() - 1) / 2;
@@ -363,17 +315,13 @@ struct SpectrumFeature : public Feature
value = 0;
first_freq *= factor;
}
-
value += fvector[j];
count++;
}
-
if (count)
result.push_back (value);
-
return result;
}
-
vector<double>
static join_slices (vector< vector<double> >::const_iterator start,
vector< vector<double> >::const_iterator end,
@@ -381,40 +329,30 @@ struct SpectrumFeature : public Feature
{
const vector < double > empty_return; // this can't be inlined in g_return* due to a bug in g++-3.3
g_return_val_if_fail (end - start > 0, empty_return);
-
vector<double> result (start->size());
-
for (vector< vector<double> >::const_iterator spect_it = start; spect_it != end; spect_it++)
{
g_return_val_if_fail (spect_it->size() == result.size(), result);
-
for (size_t i = 0; i < result.size(); i++)
result[i] += (*spect_it)[i];
}
for (size_t i = 0; i < result.size(); i++)
result[i] /= normalize;
-
return result;
}
-
void
compute (const Signal &signal)
{
if (spectrum.size()) /* don't compute the same feature twice */
return;
-
init_window (4096);
-
double file_size_ms = signal.time_ms (signal.length());
-
for (double offset_ms = 0; offset_ms < file_size_ms; offset_ms += 30) /* extract a feature vector every 30 ms */
{
GslLong extract_frame = GslLong (offset_ms / file_size_ms * signal.length() / signal.n_channels());
-
double samples[4096];
bool skip = false;
GslLong k = extract_frame * signal.n_channels() + options.channel;
-
for (int j = 0; j < 4096; j++)
{
if (k < signal.length())
@@ -424,19 +362,16 @@ struct SpectrumFeature : public Feature
however this results in click features being extracted at eof */
k += signal.n_channels();
}
-
if (!skip)
{
vector<double> fvector = build_frequency_vector (samples);
spectrum.push_back (collapse_frequency_vector (fvector, signal.mix_freq(), 50, 1.6));
}
}
-
if (options.join_spectrum_slices > 1)
{
typedef vector< vector<double> >::const_iterator SpectrumConstIterator;
const guint jslices = options.join_spectrum_slices;
-
/* for N-fold joining, we "truncate" the spectrum so that we only
* have complete sets of N 30ms spectrum buckets to join
*/
@@ -448,7 +383,6 @@ struct SpectrumFeature : public Feature
}
}
}
-
void print_results() const
{
if (options.join_spectrum_slices > 1)
@@ -462,25 +396,21 @@ struct SpectrumFeature : public Feature
print_matrix ("spectrum", spectrum);
}
};
-
struct AvgSpectrumFeature : public Feature
{
SpectrumFeature *spectrum_feature;
vector<double> avg_spectrum;
-
AvgSpectrumFeature (SpectrumFeature *spectrum_feature) :
Feature ("--avg-spectrum", "average frequency spectrum"),
spectrum_feature (spectrum_feature)
{
}
-
void compute (const Signal &signal)
{
/*
* dependancy: we need the spectrum to compute the average spectrum
*/
spectrum_feature->compute (signal);
-
for (vector< vector<double> >::const_iterator si = spectrum_feature->spectrum.begin(); si != spectrum_feature->spectrum.end(); si++)
{
avg_spectrum.resize (si->size());
@@ -493,51 +423,41 @@ struct AvgSpectrumFeature : public Feature
print_vector ("avg_spectrum", avg_spectrum);
}
};
-
struct AvgEnergyFeature : public Feature
{
double avg_energy;
-
AvgEnergyFeature() : Feature ("--avg-energy", "average signal energy in dB")
{
avg_energy = 0;
}
-
void compute (const Signal &signal)
{
GslLong avg_energy_count = 0;
for (GslLong l = options.channel; l < signal.length(); l += signal.n_channels())
{
double sample = signal[l];
-
avg_energy += sample * sample;
avg_energy_count++;
}
-
if (avg_energy_count)
avg_energy /= avg_energy_count;
-
avg_energy = 10 * log (avg_energy) / log (10);
}
-
void print_results() const
{
print_value ("avg_energy", avg_energy);
}
};
-
struct MinMaxPeakFeature : public Feature
{
double min_peak;
double max_peak;
-
MinMaxPeakFeature() :
Feature ("--min-max-peak", "minimum and maximum signal peak")
{
min_peak = 0;
max_peak = 0;
}
-
void compute (const Signal &signal)
{
for (GslLong l = options.channel; l < signal.length(); l += signal.n_channels())
@@ -546,58 +466,47 @@ struct MinMaxPeakFeature : public Feature
max_peak = max (signal[l], max_peak);
}
}
-
void print_results() const
{
print_value ("min_peak", min_peak);
print_value ("max_peak", max_peak);
}
};
-
struct DCOffsetFeature : public Feature
{
double dc_offset;
-
DCOffsetFeature() :
Feature ("--dc-offset-db", "computes the DC offset in dB")
{
dc_offset = 0;
}
-
void compute (const Signal &signal)
{
double dc_offset_div = 0.0;
-
for (GslLong l = options.channel; l < signal.length(); l += signal.n_channels())
{
dc_offset += signal[l];
dc_offset_div += 1.0;
}
-
if (dc_offset_div > 0.5)
dc_offset /= dc_offset_div;
}
-
void print_results() const
{
print_value ("dc_offset_db", bse_db_from_factor (dc_offset, -200));
}
};
-
struct RawSignalFeature : public Feature
{
vector<double> raw_signal;
-
RawSignalFeature() : Feature ("--raw-signal", "extract raw signal")
{
}
-
void compute (const Signal &signal)
{
for (GslLong l = options.channel; l < signal.length(); l += signal.n_channels())
raw_signal.push_back (signal[l]);
}
-
void print_results() const
{
/* This is more or less a debugging feature (for gnuplot or so),
@@ -608,14 +517,11 @@ struct RawSignalFeature : public Feature
fprintf (options.output_file, "%s\n", double_to_string (raw_signal[i]).c_str());
}
};
-
struct ComplexSignalFeature : public Feature
{
static const int HSIZE = 256;
-
vector< std::complex<double> > complex_signal;
double hilbert[2*HSIZE+1];
-
/*
* Evaluates the FIR frequency response of the hilbert filter.
*
@@ -625,7 +531,6 @@ struct ComplexSignalFeature : public Feature
evaluate_hilbert_response (gdouble freq)
{
std::complex<double> response = hilbert[HSIZE];
-
for (int i = 1; i <= HSIZE; i++)
{
response += std::exp (std::complex<double> (0, -i * freq)) * hilbert[HSIZE-i];
@@ -633,7 +538,6 @@ struct ComplexSignalFeature : public Feature
}
return response;
}
-
/* returns a blackman window: x is supposed to be in the interval [0..1] */
static float blackman_window (float x)
{
@@ -641,13 +545,11 @@ struct ComplexSignalFeature : public Feature
if(x > 1) return 0;
return 0.42-0.5*cos(M_PI*x*2)+0.08*cos(4*M_PI*x);
}
-
/* blackman window with x in [-1 .. 1] */
static float bwindow (float x)
{
return blackman_window ((x + 1.0) / 2.0);
}
-
ComplexSignalFeature() :
Feature ("--complex-signal", "extract complex signal (hilbert filtered)")
{
@@ -662,7 +564,6 @@ struct ComplexSignalFeature : public Feature
hilbert[HSIZE+i] = x;
hilbert[HSIZE-i] = -x;
}
-
/* normalize the filter coefficients */
double gain = std::abs (evaluate_hilbert_response (M_PI/2.0));
for (int i = 0; i <= HSIZE; i++)
@@ -671,12 +572,10 @@ struct ComplexSignalFeature : public Feature
hilbert[HSIZE-i] /= gain;
}
}
-
void compute (const Signal &signal)
{
if (complex_signal.size()) /* already finished? */
return;
-
/*
* performance: this loop could be rewritten to be faster, especially by
*
@@ -689,19 +588,16 @@ struct ComplexSignalFeature : public Feature
{
double re = signal[i];
double im = 0;
-
int pos = i - HSIZE * signal.n_channels();
for (int k = -HSIZE; k <= HSIZE; k++)
{
if (pos >= 0 && pos < signal.length())
im += signal[pos] * hilbert[k + HSIZE];
-
pos += signal.n_channels();
}
complex_signal.push_back (std::complex<double> (re, im));
}
}
-
void
print_results() const
{
@@ -714,16 +610,13 @@ struct ComplexSignalFeature : public Feature
double_to_string (complex_signal[i].imag()).c_str());
}
};
-
struct BaseFreqFeature : public Feature
{
ComplexSignalFeature *complex_signal_feature;
vector<double> freq;
-
double base_freq;
double base_freq_smear;
double base_freq_wobble;
-
BaseFreqFeature (ComplexSignalFeature *complex_signal_feature) :
Feature ("--base-freq", "try to detect pitch of a signal"),
complex_signal_feature (complex_signal_feature)
@@ -732,18 +625,15 @@ struct BaseFreqFeature : public Feature
base_freq_smear = 0;
base_freq_wobble = 0;
}
-
void
compute (const Signal &signal)
{
if (freq.size()) /* already finished? */
return;
-
/*
* dependancy: we need the complex signal to compute the base frequency
*/
complex_signal_feature->compute (signal);
-
/*
* if the user specified a base frequency hint, we search especially in
* a +/- 10% range around that hint; to do so, we use a 2nd order
@@ -752,7 +642,6 @@ struct BaseFreqFeature : public Feature
const int BANDPASS_ORDER = 2;
double a[BANDPASS_ORDER + 1] = { 0, };
double b[BANDPASS_ORDER + 1] = { 0, };
-
if (options.base_freq_hint > 0)
{
gsl_filter_butter_bp (BANDPASS_ORDER,
@@ -760,12 +649,9 @@ struct BaseFreqFeature : public Feature
options.base_freq_hint / signal.mix_freq() * 2 * M_PI * 1.10, /* +10 % */
0.1, a, b);
}
-
std::complex<double> x0, x1, x2, y0, y1, y2;
-
double last_phase = 0.0;
double base_freq_div = 0.01; /* avoid division by zero */
-
#if 0 // test filter
for (double i = 1.0; i < 10000; i = i * 11 / 10)
{
@@ -774,19 +660,16 @@ struct BaseFreqFeature : public Feature
for (s = 0; s < 10000; s++)
{
std::complex<double> sig = std::complex<double> (sin (s * i / 44100.0 * 2 * M_PI), cos (s * i / 44100.0 * 2 * M_PI));
-
/* evaluate butterworth filter */
x0 = sig;
y0 = x0 * a[0] + x1 * a[1] + x2 * a[2] - y1 * b[1] - y2 * b[2];
x2 = x1; x1 = x0; y2 = y1; y1 = y0;
-
vol += std::abs (y0);
}
printf ("%f %f\n", i, vol / s);
}
exit (1);
#endif
-
for (vector< std::complex<double> >::const_iterator si = complex_signal_feature->complex_signal.begin();
si != complex_signal_feature->complex_signal.end(); si++)
{
@@ -800,21 +683,16 @@ struct BaseFreqFeature : public Feature
{
y0 = *si;
}
-
/* determine frequency value from phase difference */
double phase = std::arg (y0);
double phase_diff = last_phase - phase;
-
if (phase_diff > M_PI)
phase_diff -= 2.0*M_PI;
else if(phase_diff < -M_PI)
phase_diff += 2.0*M_PI;
-
last_phase = phase;
-
double current_freq = fabs (phase_diff / 2.0 / M_PI) * signal.mix_freq();
freq.push_back (current_freq);
-
/*
* The following if-statement does something similar like --cut-zeros: (FIXME?)
*
@@ -827,28 +705,21 @@ struct BaseFreqFeature : public Feature
base_freq_div += 1.0;
}
}
-
base_freq /= base_freq_div;
-
compute_smear_and_wobble (signal);
}
-
void
compute_smear_and_wobble (const Signal &signal)
{
const int window_size = int (signal.mix_freq() / base_freq + 0.5);
const int window_step = max (window_size / 3, 30);
-
double last_avg_base_freq = 0.0;
-
double smear_sum = 0.0, wobble_sum = 0.0;
double window_count = 0.0;
-
for (size_t offset = 0; (offset + 2 * window_step) < freq.size(); offset += window_step)
{
// compute average value of the base frequency of window_size samples
double avg_base_freq = 0.0, avg_base_freq_div = 0.0;
-
for (int i = 0; i < window_size; i++)
{
if (offset + i < freq.size())
@@ -859,16 +730,12 @@ struct BaseFreqFeature : public Feature
}
if (avg_base_freq_div > 0.0)
avg_base_freq /= avg_base_freq_div;
-
// --base-freq-smear computation
smear_sum += fabs (avg_base_freq - base_freq);
wobble_sum += fabs (last_avg_base_freq - avg_base_freq);
-
window_count += 1.0;
-
last_avg_base_freq = avg_base_freq;
}
-
if (window_count > 0.0)
{
base_freq_smear = smear_sum / window_count;
@@ -880,23 +747,19 @@ struct BaseFreqFeature : public Feature
base_freq_wobble = 0.0;
}
}
-
void print_results() const
{
print_value ("base_freq", base_freq);
}
};
-
struct BaseFreqSmear : public Feature
{
BaseFreqFeature *base_freq_feature;
-
BaseFreqSmear (BaseFreqFeature *base_freq_feature) :
Feature ("--base-freq-smear", "inaccuracy of pitch detection"),
base_freq_feature (base_freq_feature)
{
}
-
void compute (const Signal& signal)
{
/*
@@ -904,23 +767,19 @@ struct BaseFreqSmear : public Feature
*/
base_freq_feature->compute (signal);
}
-
void print_results() const
{
print_value ("base_freq_smear", base_freq_feature->base_freq_smear);
}
};
-
struct BaseFreqWobble : public Feature
{
BaseFreqFeature *base_freq_feature;
-
BaseFreqWobble (BaseFreqFeature *base_freq_feature)
: Feature ("--base-freq-wobble", "rate of changes in the pitch over time"),
base_freq_feature (base_freq_feature)
{
}
-
void compute (const Signal &signal)
{
/*
@@ -928,22 +787,18 @@ struct BaseFreqWobble : public Feature
*/
base_freq_feature->compute (signal);
}
-
void print_results() const
{
print_value ("base_freq_wobble", base_freq_feature->base_freq_wobble);
}
};
-
struct VolumeFeature : public Feature
{
ComplexSignalFeature *complex_signal_feature;
vector<double> vol;
-
double volume;
double volume_smear;
double volume_wobble;
-
VolumeFeature (ComplexSignalFeature *complex_signal_feature)
: Feature ("--volume", "determine average signal volume"),
complex_signal_feature (complex_signal_feature)
@@ -952,51 +807,39 @@ struct VolumeFeature : public Feature
volume_smear = 0;
volume_wobble = 0;
}
-
void compute (const Signal &signal)
{
if (vol.size()) /* already finished? */
return;
-
/*
* dependancy: we need the complex signal to compute the base frequency
*/
complex_signal_feature->compute (signal);
-
volume = 0.0;
-
for (vector< std::complex<double> >::const_iterator si = complex_signal_feature->complex_signal.begin();
si != complex_signal_feature->complex_signal.end(); si++)
{
double v = std::abs (*si); //sqrt (si->real() * si->real() + si->imag() * si->imag()); //std::abs (*si);
-
vol.push_back (v);
volume += v;
}
-
if (vol.size())
volume /= vol.size();
-
compute_smear_and_wobble (signal);
}
-
void compute_smear_and_wobble (const Signal &signal)
{
const double window_size_ms = 30; /* window size in milliseconds */
const int window_size = int (signal.mix_freq() * window_size_ms / 1000.0 + 0.5);
const int window_step = max (window_size / 3, 30);
-
double last_avg_volume = 0.0;
double window_count = 0.0;
-
volume_smear = 0.0;
volume_wobble = 0.0;
-
for (size_t offset = 0; (offset + 2 * window_step) < vol.size(); offset += window_step)
{
// compute average value of the base frequency of window_size samples
double avg_volume = 0.0, avg_volume_div = 0.0;
-
for (int i = 0; i < window_size; i++)
{
if (offset + i < vol.size())
@@ -1007,73 +850,58 @@ struct VolumeFeature : public Feature
}
if (avg_volume_div > 0.0)
avg_volume /= avg_volume_div;
-
volume_smear += fabs (avg_volume - volume);
volume_wobble += fabs (last_avg_volume - avg_volume);
-
window_count += 1.0;
-
last_avg_volume = avg_volume;
}
-
if (window_count > 0.0)
{
volume_smear /= window_count;
volume_wobble /= window_count;
}
}
-
void print_results() const
{
print_value ("volume", volume);
}
};
-
struct VolumeSmear : public Feature
{
VolumeFeature *volume_feature;
-
VolumeSmear (VolumeFeature *volume_feature) :
Feature ("--volume-smear", "variation of signal volume"),
volume_feature (volume_feature)
{
}
-
void compute (const Signal &signal)
{
// dependancy: we need the volume feature to compute the volume smear
volume_feature->compute (signal);
}
-
void print_results() const
{
print_value ("volume_smear", volume_feature->volume_smear);
}
};
-
struct VolumeWobble : public Feature
{
VolumeFeature *volume_feature;
-
-
VolumeWobble (VolumeFeature *volume_feature) :
Feature ("--volume-wobble", "rate of changes in signal volume over time"),
volume_feature (volume_feature)
{
}
-
void compute (const Signal &signal)
{
// dependancy: we need the volume feature to compute the volume wobble
volume_feature->compute (signal);
}
-
void print_results() const
{
print_value ("volume_wobble", volume_feature->volume_wobble);
}
};
-
struct TimingSlices
{
enum SpectralFluxType
@@ -1082,7 +910,6 @@ struct TimingSlices
SPECTRAL_FLUX_NEGATIVE
};
vector< vector<double> > slices;
-
vector<double>
build_frequency_vector (GslLong size,
double *samples)
@@ -1090,16 +917,13 @@ struct TimingSlices
vector<double> fvector;
double in[size], c[size + 2], *im;
gint i;
-
for (i = 0; i < size; i++)
in[i] = bse_window_blackman (2.0 * i / size - 1.0) * samples[i]; /* the bse blackman window is defined in range [-1, 1] */
-
gsl_power2_fftar (size, in, c);
c[size] = c[1];
c[size + 1] = 0;
c[1] = 0;
im = c + 1;
-
for (i = 0; i <= size >> 1; i++)
{
double abs = sqrt (c[i << 1] * c[i << 1] + im[i << 1] * im[i << 1]);
@@ -1108,19 +932,15 @@ struct TimingSlices
}
return fvector;
}
-
void
compute (const Signal& signal)
{
if (slices.size()) /* don't compute the same feature twice */
return;
-
double file_size_ms = signal.time_ms (signal.length());
uint fft_size_samples = 2;
-
while (fft_size_samples / signal.mix_freq() * 1000 < options.timing_window_size_ms)
fft_size_samples *= 2;
-
if (options.verbose)
{
g_printerr ("timing window (for attack and release detection):\n");
@@ -1131,15 +951,12 @@ struct TimingSlices
float (options.timing_window_stepping_ms),
uint (options.timing_window_stepping_ms * signal.mix_freq() / 1000));
}
-
for (double offset_ms = 0; offset_ms < file_size_ms; offset_ms += options.timing_window_stepping_ms)
{
GslLong extract_frame = GslLong (offset_ms / file_size_ms * signal.length() / signal.n_channels());
-
double samples[fft_size_samples];
bool skip = false;
GslLong k = extract_frame * signal.n_channels() + options.channel;
-
for (uint j = 0; j < fft_size_samples; j++)
{
if (k < signal.length())
@@ -1149,18 +966,15 @@ struct TimingSlices
however this results in click features being extracted at eof */
k += signal.n_channels();
}
-
if (!skip)
slices.push_back (build_frequency_vector (fft_size_samples, samples));
}
}
-
int
n_slices()
{
return slices.size();
}
-
double
spectral_flux (int slice1,
int slice2,
@@ -1173,7 +987,6 @@ struct TimingSlices
vector<double>& s1 = (slice1 >= 0 && slice1 < slices.size()) ? slices[slice1] : null_slice;
vector<double>& s2 = (slice2 >= 0 && slice2 < slices.size()) ? slices[slice2] : null_slice;
null_slice.resize (max (s1.size(), s2.size()));
-
double sf = 0;
for (size_t i = 0; i < s1.size(); i++)
{
@@ -1183,27 +996,22 @@ struct TimingSlices
return sf;
}
};
-
struct AttackTimes : public Feature
{
TimingSlices *timing_slices;
vector<double> attack_times;
-
AttackTimes (TimingSlices *timing_slices) :
Feature ("--attack-times", "compute timestamps for possible note attacks"),
timing_slices (timing_slices)
{
}
-
void
compute (const Signal &signal)
{
timing_slices->compute (signal);
-
for (int i = 0; i < timing_slices->n_slices(); i++)
attack_times.push_back (timing_slices->spectral_flux (i - 1, i, TimingSlices::SPECTRAL_FLUX_POSITIVE));
}
-
void
print_results() const
{
@@ -1212,27 +1020,22 @@ struct AttackTimes : public Feature
// printf ("%g\n", attack_times[i]);
}
};
-
struct ReleaseTimes : public Feature
{
TimingSlices *timing_slices;
vector<double> release_times;
-
ReleaseTimes (TimingSlices *timing_slices) :
Feature ("--release-times", "compute timestamps for possible note releases"),
timing_slices (timing_slices)
{
}
-
void
compute (const Signal &signal)
{
timing_slices->compute (signal);
-
for (int i = 0; i < timing_slices->n_slices(); i++)
release_times.push_back (timing_slices->spectral_flux (i - 1, i, TimingSlices::SPECTRAL_FLUX_NEGATIVE));
}
-
void
print_results() const
{
@@ -1241,7 +1044,6 @@ struct ReleaseTimes : public Feature
// printf ("%g\n", release_times[i]);
}
};
-
Options::Options () :
join_spectrum_slices (1)
{
@@ -1258,7 +1060,6 @@ Options::Options () :
timing_window_size_ms = 50;
output_file = stdout;
}
-
void
Options::validate_percent (const string &option,
gdouble value)
@@ -1271,7 +1072,6 @@ Options::validate_percent (const string &option,
exit (1);
}
}
-
void
Options::validate_int (const string &option,
int value,
@@ -1286,7 +1086,6 @@ Options::validate_int (const string &option,
exit (1);
}
}
-
static bool
check_arg (uint argc,
char *argv[],
@@ -1296,11 +1095,9 @@ check_arg (uint argc,
{
g_return_val_if_fail (opt != NULL, false);
g_return_val_if_fail (*nth < argc, false);
-
const char *arg = argv[*nth];
if (!arg)
return false;
-
uint opt_len = strlen (opt);
if (strcmp (arg, opt) == 0)
{
@@ -1330,11 +1127,9 @@ check_arg (uint argc,
}
else
return false;
-
Options::print_usage();
exit (1);
}
-
void
Options::parse (int *argc_p,
char **argv_p[])
@@ -1342,16 +1137,13 @@ Options::parse (int *argc_p,
guint argc = *argc_p;
gchar **argv = *argv_p;
unsigned int i, e;
-
g_return_if_fail (argc >= 0);
-
/* I am tired of seeing .libs/lt-bsefextract all the time,
* but basically this should be done (to allow renaming the binary):
*
if (argc && argv[0])
program_name = argv[0];
*/
-
for (i = 1; i < argc; i++)
{
const char *opt_arg;
@@ -1432,7 +1224,6 @@ Options::parse (int *argc_p,
break;
}
}
-
/* resort argc/argv */
e = 1;
for (i = 1; i < argc; i++)
@@ -1444,7 +1235,6 @@ Options::parse (int *argc_p,
}
*argc_p = e;
}
-
void
Options::print_usage ()
{
@@ -1473,7 +1263,6 @@ Options::print_usage ()
fprintf (stderr, "\n");
fprintf (stderr, "(example: %s --start-time --end-time t.wav).\n", options.program_name.c_str());
}
-
static void
print_header (const char *src)
{
@@ -1481,7 +1270,6 @@ print_header (const char *src)
options.program_name.c_str(), BST_VERSION, options.channel, src);
fprintf (options.output_file, "#\n");
}
-
int
main (int argc,
char **argv)
@@ -1495,14 +1283,12 @@ main (int argc,
{ NULL }
};
bse_init_inprocess (&argc, &argv, NULL, values);
-
/* supported features */
SpectrumFeature *spectrum_feature = new SpectrumFeature;
ComplexSignalFeature *complex_signal_feature = new ComplexSignalFeature;
BaseFreqFeature *base_freq_feature = new BaseFreqFeature (complex_signal_feature);
VolumeFeature *volume_feature = new VolumeFeature (complex_signal_feature);
TimingSlices *timing_slices = new TimingSlices; // not user visible
-
feature_list.push_back (new StartTimeFeature());
feature_list.push_back (new EndTimeFeature());
feature_list.push_back (spectrum_feature);
@@ -1520,7 +1306,6 @@ main (int argc,
feature_list.push_back (new VolumeWobble (volume_feature));
feature_list.push_back (new AttackTimes (timing_slices));
feature_list.push_back (new ReleaseTimes (timing_slices));
-
/* parse options */
options.parse (&argc, &argv);
if (argc != 2)
@@ -1528,52 +1313,43 @@ main (int argc,
options.print_usage ();
return 1;
}
-
/* open input */
BseErrorType error;
-
BseWaveFileInfo *wave_file_info = bse_wave_file_info_load (argv[1], &error);
if (!wave_file_info)
{
fprintf (stderr, "%s: can't open the input file %s: %s\n", options.program_name.c_str(), argv[1], bse_error_blurb (error));
exit (1);
}
-
BseWaveDsc *waveDsc = bse_wave_dsc_load (wave_file_info, 0, FALSE, &error);
if (!waveDsc)
{
fprintf (stderr, "%s: can't open the input file %s: %s\n", options.program_name.c_str(), argv[1], bse_error_blurb (error));
exit (1);
}
-
GslDataHandle *dhandle = bse_wave_handle_create (waveDsc, 0, &error);
if (!dhandle)
{
fprintf (stderr, "%s: can't open the input file %s: %s\n", options.program_name.c_str(), argv[1], bse_error_blurb (error));
exit (1);
}
-
error = gsl_data_handle_open (dhandle);
if (error)
{
fprintf (stderr, "%s: can't open the input file %s: %s\n", options.program_name.c_str(), argv[1], bse_error_blurb (error));
exit (1);
}
-
/* extract features */
Signal signal (dhandle);
-
if (options.channel >= signal.n_channels())
{
fprintf (stderr, "%s: bad channel %d, input file %s has %d channels\n",
options.program_name.c_str(), options.channel, argv[1], signal.n_channels());
exit (1);
}
-
for (list<Feature*>::const_iterator fi = feature_list.begin(); fi != feature_list.end(); fi++)
if ((*fi)->extract_feature)
(*fi)->compute (signal);
-
/* print results */
print_header (argv[1]);
for (list<Feature*>::const_iterator fi = feature_list.begin(); fi != feature_list.end(); fi++)
@@ -1586,5 +1362,4 @@ main (int argc,
}
}
}
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tools/bseloopfuncs.cc b/tools/bseloopfuncs.cc
index 56aece5..68f072f 100644
--- a/tools/bseloopfuncs.cc
+++ b/tools/bseloopfuncs.cc
@@ -5,7 +5,6 @@
#include <signal.h> /* G_BREAKPOINT() */
#include <stdio.h>
#include <math.h>
-
typedef struct {
gdouble score;
GslLong loop_start;
@@ -17,7 +16,6 @@ typedef struct {
gdouble worst_score;
LoopEntry entries[1]; /* flexible array */
} LoopStack;
-
static gdouble
score_headloop (GslDataHandle *dhandle,
const gfloat *ls, /* loop start */
@@ -30,12 +28,10 @@ score_headloop (GslDataHandle *dhandle,
const gfloat *c = ls + ll; /* compare area start */
const gfloat *p, *le = ls + ll;
gdouble score = 0;
-
/* compute score for loop repeated over comparison area
* .......|##########|-------------------------|......
* ls c c+cl
*/
-
while (nl--)
{
p = ls;
@@ -60,7 +56,6 @@ score_headloop (GslDataHandle *dhandle,
}
return score;
}
-
static gdouble
score_tailloop (GslDataHandle *dhandle,
const gfloat *cs, /* compare area start */
@@ -74,12 +69,10 @@ score_tailloop (GslDataHandle *dhandle,
const gfloat *le = ls + ll;
const gfloat *p, *c = cs;
gdouble score = 0;
-
/* compute score for loop repeated over comparison area
* .......|-------------------------|##########|......
* c ls le
*/
-
p = ls + ll - rl;
while (p < le)
{
@@ -103,7 +96,6 @@ score_tailloop (GslDataHandle *dhandle,
}
return score;
}
-
gboolean
gsl_data_find_loop5 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
@@ -118,17 +110,14 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
guint apoints;
gfloat *block;
gboolean found_loop = FALSE;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
g_return_val_if_fail (frame <= config->block_start, FALSE);
config->n_details = 0;
-
/* check out data handle */
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
-
/* confine parameters */
bstart = CLAMP (config->block_start, 0, dhandle_n_values - 1);
if (config->block_length < 0)
@@ -137,7 +126,6 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
blength = MIN (dhandle_n_values - bstart - frame, config->block_length);
if (blength < 4)
return FALSE;
-
/* determine boundaries */
max_llength = blength / CLAMP (config->repetitions, 2, blength);
min_llength = MAX (frame + 1, config->min_loop);
@@ -148,17 +136,14 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
bfrac = blength / (apoints + 1.0);
/* length of comparison area */
clength = blength / 2;
-
/* provide fully cached area for comparisons */
block = g_new (gfloat, dhandle_n_values);
for (i = 0; i < dhandle_n_values; i++)
block[i] = gsl_data_handle_peek_value (dhandle, i, &pbuf);
-
/* upper boundary for amount of comparisons */
pdist = apoints * (max_llength + 1 - min_llength);
pcount = 0;
config->score = G_MAXDOUBLE;
-
/* loop over the centers of all loops */
for (fcenter = bstart + bfrac; fcenter + 1.0 < bstart + blength; fcenter += bfrac)
{
@@ -206,7 +191,6 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
double human_size = 1e6;
double score1_weight = human_size / (2.0 * frame);
double score2_weight = human_size / (1.0 * tlength + hlength);
-
/* compute proximity score */
score1 = score_tailloop (dhandle, block + lstart - frame, frame, llength,
(config->score - score) / score1_weight);
@@ -221,7 +205,6 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
score2 += score_tailloop (dhandle, block + hstart, hlength, llength,
(config->score - score) / score2_weight);
score = score1 * score1_weight + score2 * score2_weight;
-
/* apply score */
if (score < config->score)
{
@@ -245,14 +228,11 @@ gsl_data_find_loop5 (GslDataHandle *dhandle,
config->loop_start, config->loop_start + config->loop_length, config->loop_length,
bstart, bstart + blength, blength,
config->score, score_pcount * 100.0 / pdist);
-
/* cleanups */
g_free (block);
gsl_data_handle_close (dhandle);
-
return found_loop;
}
-
gboolean
gsl_data_find_loop4 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
@@ -266,16 +246,13 @@ gsl_data_find_loop4 (GslDataHandle *dhandle,
gfloat *bstart_block;
const gfloat *block;
gboolean found_loop = FALSE;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
config->n_details = 0;
-
/* check out data handle */
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
-
/* confine parameters */
bstart = CLAMP (config->block_start, 0, dhandle_n_values - 1);
if (config->block_length < 0)
@@ -284,7 +261,6 @@ gsl_data_find_loop4 (GslDataHandle *dhandle,
blength = MIN (dhandle_n_values - bstart, config->block_length);
if (blength < 4)
return FALSE;
-
/* determine boundaries */
max_llength = blength / CLAMP (config->repetitions, 2, blength);
min_llength = MAX (1, config->min_loop);
@@ -294,18 +270,15 @@ gsl_data_find_loop4 (GslDataHandle *dhandle,
bfrac = blength / (CLAMP (config->analysis_points, 1, blength / 2 - 1) + 1.0);
/* length of comparison area */
clength = blength / 2;
-
/* provide fully cached area for comparisons */
bstart_block = g_new (gfloat, blength);
for (i = 0; i < blength; i++)
bstart_block[i] = gsl_data_handle_peek_value (dhandle, bstart + i, &pbuf);
block = bstart_block - bstart;
-
/* upper boundary for amount of comparisons */
pdist = (blength / bfrac + 0.5) * (max_llength + 1 - min_llength);
pcount = 0;
config->score = G_MAXDOUBLE;
-
/* loop over the centers of all loops */
for (fcenter = bstart + bfrac; fcenter + 1.0 < bstart + blength; fcenter += bfrac)
/* loop over all loop lengths */
@@ -362,14 +335,11 @@ gsl_data_find_loop4 (GslDataHandle *dhandle,
config->loop_start, config->loop_start + config->loop_length, config->loop_length,
bstart, bstart + blength, blength,
config->score, score_pcount * 100.0 / pdist);
-
/* cleanups */
g_free (bstart_block);
gsl_data_handle_close (dhandle);
-
return found_loop;
}
-
gboolean
gsl_data_find_loop3 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
@@ -382,11 +352,9 @@ gsl_data_find_loop3 (GslDataHandle *dhandle,
gfloat *sp, *ep, *cstart, *block;
gdouble pdist;
gboolean found_loop = FALSE;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
config->n_details = 0;
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
@@ -401,12 +369,10 @@ gsl_data_find_loop3 (GslDataHandle *dhandle,
return FALSE;
/* current implementation supports just repetitions == 2 */
g_return_val_if_fail (config->repetitions == 2, FALSE);
-
/* provide fully cached area for comparisons */
block = g_new (gfloat, config->block_length);
for (i = 0; i < config->block_length; i++)
block[i] = gsl_data_handle_peek_value (dhandle, config->block_start + i, &pbuf);
-
/* test every possible loop size at every possible position */
maxll = config->block_length / 2;
minll = maxll * 0.91;
@@ -429,12 +395,10 @@ gsl_data_find_loop3 (GslDataHandle *dhandle,
gsl_progress_notify (&pstate, ++pcount * 100.0 / pdist, "score:%+g (pos:%6lu)", config->score, sp - block);
// g_printerr ("processed: %7.3f (score:%+g) \r", ++pcount * 100.0 / pdist, config->score);
}
-
g_free (block);
gsl_data_handle_close (dhandle);
return found_loop;
}
-
gboolean
gsl_data_find_loop2 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
@@ -447,11 +411,9 @@ gsl_data_find_loop2 (GslDataHandle *dhandle,
gfloat *sp, *ep, *cstart, *block;
gdouble pdist;
gboolean found_loop = FALSE;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
config->n_details = 0;
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
@@ -466,14 +428,11 @@ gsl_data_find_loop2 (GslDataHandle *dhandle,
return FALSE;
/* current implementation supports just repetitions == 2 */
g_return_val_if_fail (config->repetitions == 2, FALSE);
-
/* provide fully cached area for comparisons */
block = g_new (gfloat, config->block_length);
for (i = 0; i < config->block_length; i++)
block[i] = gsl_data_handle_peek_value (dhandle, config->block_start + i, &pbuf);
-
goto print_sizes;
-
/* find best loop size at one position */
maxll = config->block_length / 2;
minll = 1;
@@ -497,7 +456,6 @@ gsl_data_find_loop2 (GslDataHandle *dhandle,
gsl_progress_wipe (&pstate);
ll = config->loop_length;
g_printerr ("loop size: %llu\n", ll);
-
/* test every possible position */
minll = ll;
maxll = ll + 1;
@@ -523,10 +481,8 @@ gsl_data_find_loop2 (GslDataHandle *dhandle,
gsl_progress_notify (&pstate, ++pcount * 100.0 / pdist, "score:%+g (pos:%6lu)", config->score, sp - block);
}
}
-
G_BREAKPOINT ();
print_sizes:
-
/* test every possible loop size */
maxll = config->block_length / 2;
minll = 1;
@@ -553,12 +509,10 @@ gsl_data_find_loop2 (GslDataHandle *dhandle,
}
G_BREAKPOINT ();
}
-
g_free (block);
gsl_data_handle_close (dhandle);
return found_loop;
}
-
static inline gdouble
dcache_headloop_score (GslDataCache *dcache,
GslLong lstart, /* loop start (reaches till bstart) */
@@ -573,12 +527,10 @@ dcache_headloop_score (GslDataCache *dcache,
GslDataCacheNode *lnode = *lnp, *cnode = *cnp;
gdouble wmax = clength, score = 0.0;
GslLong i = 0, loop_length = cstart - lstart;
-
/* compute score for loop repeated over comparison area
* .......|##########|-------------------------|......
* loopstart cstart (cstart+clength)
*/
-
while (i < clength)
{
GslLong cdiff, ldiff, clen, llen, k, l = i % loop_length;
@@ -614,10 +566,8 @@ dcache_headloop_score (GslDataCache *dcache,
if (score > max_score)
break;
}
-
return score;
}
-
gboolean
gsl_data_find_loop1 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
@@ -631,11 +581,9 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
GslDataCacheNode *dnode1, *dnode2;
gdouble pdist;
gboolean found_loop = FALSE;
-
g_return_val_if_fail (dhandle != NULL, FALSE);
g_return_val_if_fail (config != NULL, FALSE);
config->n_details = 0;
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return FALSE;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
@@ -648,20 +596,16 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
return FALSE;
if (config->repetitions != CLAMP (config->repetitions, 2, config->block_length))
return FALSE;
-
dcache = gsl_data_cache_new (dhandle, 1);
gsl_data_cache_open (dcache);
gsl_data_handle_close (dhandle);
gsl_data_cache_unref (dcache);
-
dnode1 = gsl_data_cache_ref_node (dcache, config->block_start, GSL_DATA_CACHE_DEMAND_LOAD);
dnode2 = gsl_data_cache_ref_node (dcache, config->block_start, GSL_DATA_CACHE_DEMAND_LOAD);
-
/* widen loop, keeping it end-aligned to cstart
* |------------##########|--------------------|......
* block_start loopstart cstart (cstart+clength)
*/
-
/* find a good loop length */
config->score = G_MAXDOUBLE;
cstart = config->block_start + config->block_length / config->repetitions;
@@ -687,7 +631,6 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
config->loop_start, config->loop_start + config->loop_length, config->loop_length,
config->block_start, config->block_start + config->block_length, config->block_length,
config->score);
-
/* find best loop position */
ll = config->loop_length;
minll = ll;
@@ -715,7 +658,6 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
config->loop_start, config->loop_start + config->loop_length, config->loop_length,
config->block_start, config->block_start + config->block_length, config->block_length,
config->score);
-
/* find best loop length */
frame = MIN (config->loop_length / 5, 4410 * 7);
while (frame >= 32) // FIXME
@@ -727,7 +669,6 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
maxll = MIN (config->block_start + config->block_length - frame,
config->loop_start + maxll) -
config->loop_start;
-
/* find best loop length */
config->score = G_MAXDOUBLE;
ls = config->loop_start;
@@ -751,16 +692,12 @@ gsl_data_find_loop1 (GslDataHandle *dhandle,
frame, config->score);
frame /= 2;
}
-
seek_loop_done:
-
gsl_data_cache_unref_node (dcache, dnode1);
gsl_data_cache_unref_node (dcache, dnode2);
-
gsl_data_cache_close (dcache);
return found_loop;
}
-
static inline float
tailloop_score (GslDataCache *dcache,
const GslDataTailLoop *cfg,
@@ -772,23 +709,19 @@ tailloop_score (GslDataCache *dcache,
GslLong looppos, i, compare = cfg->pre_loop_compare;
gfloat score = 0.0;
GslDataCacheNode *snode, *lnode;
-
/* compute score for loopsize with compare samples before loop */
/* -----|-------------------------|-----------------
* loopstart-compare loopstart
*/
-
looppos = loopstart - compare;
while (looppos < loopstart)
looppos += loopsize;
-
snode = gsl_data_cache_ref_node (dcache, loopstart - compare, GSL_DATA_CACHE_DEMAND_LOAD);
lnode = gsl_data_cache_ref_node (dcache, looppos, GSL_DATA_CACHE_DEMAND_LOAD);
for (i = loopstart - compare; i < loopstart;)
{
GslLong sdiff, ldiff, slen, llen, loop_len, compare_len, j;
gfloat *sb, *lb;
-
if (snode->offset > i || i >= snode->offset + node_size)
{
gsl_data_cache_unref_node (dcache, snode);
@@ -807,11 +740,9 @@ tailloop_score (GslDataCache *dcache,
lb = lnode->data + ldiff;
compare_len = loopstart - i;
loop_len = loopsize - (looppos - loopstart);
-
slen = MIN (slen, compare_len);
llen = MIN (llen, loop_len);
slen = MIN (slen, llen);
-
j = slen;
if (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION)
{
@@ -828,7 +759,6 @@ tailloop_score (GslDataCache *dcache,
if (score > worstscore)
break;
}
-
i += slen;
looppos += slen;
if (looppos >= loopstart + loopsize)
@@ -836,10 +766,8 @@ tailloop_score (GslDataCache *dcache,
}
gsl_data_cache_unref_node (dcache, snode);
gsl_data_cache_unref_node (dcache, lnode);
-
return score;
}
-
gdouble
gsl_data_find_loop0 (GslDataHandle *dhandle,
const GslDataTailLoop *cfg,
@@ -851,43 +779,35 @@ gsl_data_find_loop0 (GslDataHandle *dhandle,
GslLong perc_count = 0, perc_val = 0;
GslLong loopsize, bestloopsize = 0;
gdouble bestscore;
-
g_return_val_if_fail (dhandle != NULL, 0);
g_return_val_if_fail (cfg != NULL, 0);
g_return_val_if_fail (loop_start_p != NULL, 0);
g_return_val_if_fail (loop_end_p != NULL, 0);
g_return_val_if_fail (cfg->min_loop >= 1, 0);
-
if (gsl_data_handle_open (dhandle) != BSE_ERROR_NONE)
return 0;
dhandle_n_values = gsl_data_handle_n_values (dhandle);
-
g_return_val_if_fail (cfg->pre_loop_compare < dhandle_n_values - 1, 0);
cfg_max_loop = cfg->max_loop < 0 ? dhandle_n_values - 1 - cfg->pre_loop_compare : cfg->max_loop;
g_return_val_if_fail (cfg_max_loop >= cfg->min_loop, 0);
g_return_val_if_fail (cfg->pre_loop_compare + cfg_max_loop < dhandle_n_values, 0);
g_return_val_if_fail (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE ||
cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION, 0);
-
dcache = gsl_data_cache_new (dhandle, 1);
gsl_data_cache_open (dcache);
gsl_data_handle_close (dhandle);
gsl_data_cache_unref (dcache);
-
perc_bound = (cfg_max_loop - cfg->min_loop) / 100.0;
-
/* we try to maximize correlation, but to minimize the error */
if (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION)
bestscore = 0.0;
else
bestscore = 1e+14;
-
for (loopsize = cfg->min_loop; loopsize < cfg_max_loop; loopsize++)
{
gdouble score = tailloop_score (dcache, cfg,
dhandle_n_values - loopsize, loopsize,
bestscore);
-
/* we try to maximize correlation, but to minimize the error */
if ((cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION && score > bestscore) ||
(cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE && score < bestscore))
@@ -905,15 +825,11 @@ gsl_data_find_loop0 (GslDataHandle *dhandle,
g_printerr ("\nbest match (%s): len in samples=%lld, len=%lld, score=%f\n",
(cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION) ? "correlation" : "least squares",
bestloopsize, bestloopsize, bestscore);
-
*loop_start_p = dhandle_n_values - bestloopsize;
*loop_end_p = dhandle_n_values - 1;
-
gsl_data_cache_close (dcache);
-
/* FIXME: statistics: scan for other extreme points in
* score[cfg->min_loop..cfg_max_loop]
*/
-
return bestscore;
}
diff --git a/tools/bseloopfuncs.hh b/tools/bseloopfuncs.hh
index 6b01f8d..8acea56 100644
--- a/tools/bseloopfuncs.hh
+++ b/tools/bseloopfuncs.hh
@@ -1,13 +1,9 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_LOOPFUNCS_H__
#define __BSE_LOOPFUNCS_H__
-
#include <bse/gsldatautils.hh>
#include <bse/gslcommon.hh>
-
G_BEGIN_DECLS
-
-
typedef struct {
/* block containing loop */
GslLong block_start;
@@ -26,7 +22,6 @@ typedef struct {
const char *detail_names[64];
double detail_scores[64];
} GslDataLoopConfig;
-
/* mem-cached loop position and size finder. tests through all possible
* loop sizes around center points determined by block/(analysis_points+1).
* uses full-block comparisons (centering comparison area around the
@@ -78,8 +73,6 @@ gboolean gsl_data_find_loop1 (GslDataHandle *dhandle,
GslDataLoopConfig *config,
gpointer pdata,
GslProgressFunc pfunc);
-
-
typedef enum
{
GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE,
@@ -109,7 +102,5 @@ gdouble gsl_data_find_loop0 (GslDataHandle *dhandle,
* # n_samples compare area size (ahead of loop start) [8820]
* TL_CFG="--loop=5000:-1:5000"
*/
-
G_END_DECLS
-
#endif /* __BSE_LOOPFUNCS_H__ */
diff --git a/tools/bsewavetool.cc b/tools/bsewavetool.cc
index bd3118e..8d71bdf 100644
--- a/tools/bsewavetool.cc
+++ b/tools/bsewavetool.cc
@@ -18,20 +18,14 @@
#include <vector>
#include <map>
#include <algorithm>
-
-
namespace BseWaveTool {
-
using namespace Birnet;
-
#define PRG_NAME ("bsewavetool")
#define IROUND(dbl) ((int) (floor (dbl + 0.5)))
-
/* --- prototypes --- */
static void wavetool_parse_args (int *argc_p,
char ***argv_p);
static void wavetool_print_blurb (bool bshort);
-
/* --- variables --- */
static bool skip_errors = false;
static bool silent_infos = false;
@@ -40,14 +34,12 @@ static string input_file;
static string output_file;
list<Command*> Command::registry;
list<string> unlink_file_list;
-
/* --- Command --- */
Command::Command (const char *command_name) :
name (command_name)
{
registry.push_back (this);
}
-
void
Command::blurb (bool bshort)
{
@@ -55,7 +47,6 @@ Command::blurb (bool bshort)
if (bshort)
return;
}
-
/* --- main program --- */
static void
wavetool_message_handler (const char *domain,
@@ -87,13 +78,11 @@ wavetool_message_handler (const char *domain,
else
Msg::default_handler (domain, mtype, parts);
}
-
extern "C" int
main (int argc,
char *argv[])
{
std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
-
/* initialization */
int orig_argc = argc;
SfiInitValue values[] = {
@@ -107,10 +96,8 @@ main (int argc,
Msg::allow_msgs ("main"); // FIXME
Msg::set_thread_handler (wavetool_message_handler);
Msg::configure (Msg::INFO, Msg::LOG_TO_HANDLER, "");
-
/* pre-parse argument list to decide command */
wavetool_parse_args (&argc, &argv);
-
/* check args */
if (command_name == "")
{
@@ -137,7 +124,6 @@ main (int argc,
sfi_error ("missing input file name\n");
exit (1);
}
-
/* parse and check command args */
guint missing = command->parse_args (argc, argv);
int e = 1; /* collapse NULL args */
@@ -159,7 +145,6 @@ main (int argc,
sfi_error ("extra argument given to command \"%s\": %s\n", command->name.c_str(), argv[1]);
exit (1);
}
-
/* load wave file */
g_printerr ("LOAD: %s\n", input_file.c_str());
Wave *wave = command->create ();
@@ -214,11 +199,9 @@ main (int argc,
sfi_error ("problems encountered loading bsewave file \"%s\": %s", input_file.c_str(), bse_error_blurb (error));
exit (1);
}
-
/* process */
g_printerr ("EXEC: %s\n", command_name.c_str());
bool needs_saving = command->exec (wave);
-
/* save */
if (needs_saving)
{
@@ -231,15 +214,12 @@ main (int argc,
exit (1);
}
}
-
/* cleanup */
delete wave;
for (list<string>::iterator it = unlink_file_list.begin(); it != unlink_file_list.end(); it++)
unlink (it->c_str());
-
return 0;
}
-
static void
wavetool_print_version (void)
{
@@ -251,7 +231,6 @@ wavetool_print_version (void)
g_print ("the BEAST source package. Sources, examples and contact\n");
g_print ("information are available at http://beast.testbit.eu/.\n");
}
-
static void
wavetool_print_blurb (bool bshort)
{
@@ -280,7 +259,6 @@ wavetool_print_blurb (bool bshort)
cmd->blurb (bshort);
}
}
-
static bool
parse_str_option (char **argv,
guint &i,
@@ -307,7 +285,6 @@ parse_str_option (char **argv,
}
return false;
}
-
static bool
parse_bool_option (char **argv,
guint &i,
@@ -321,7 +298,6 @@ parse_bool_option (char **argv,
}
return false;
}
-
/* Since the function g_str_hash has changed between glib 2.26 and glib 2.28,
* we include the original code here to make chunk keys behave the same with
* both glib versions, so the unit tests pass with any glib version.
@@ -332,15 +308,11 @@ old_g_str_hash (gconstpointer v)
/* 31 bit hash function */
const signed char *p = static_cast<const signed char *> (v);
guint32 h = *p;
-
if (h)
for (p += 1; *p != '\0'; p++)
h = (h << 5) - h + *p;
-
return h;
}
-
-
/* wave chunk keys for shell iteration */
class WaveChunkKey {
BseFloatIEEE754 m_osc_freq;
@@ -351,7 +323,6 @@ public:
m_osc_freq.v_float = -1;
if (key_string.size() != 7)
return; // invalid key
-
uint64 key_uint = 0;
for (string::const_reverse_iterator si = key_string.rbegin(); si != key_string.rend(); si++)
{
@@ -365,14 +336,12 @@ public:
else
return; // invalid key
}
-
const uint64 key_checksum = key_uint & 0x1ff;
key_uint ^= key_checksum << 32LL; // deobfuscate high bits with checksum
const uint64 checksum = old_g_str_hash (string_printf ("%lld", key_uint - key_checksum).c_str()) % 509;
if (key_checksum != checksum)
return; // invalid key
key_uint >>= 9;
-
// decode float components in byte order independent way
m_osc_freq.mpn.mantissa = key_uint;
key_uint >>= 23;
@@ -388,7 +357,6 @@ public:
as_string() const
{
uint64 key_uint = 0;
-
// put float components to key in byte order independent way
key_uint |= m_osc_freq.mpn.sign; // 1 bit
key_uint <<= 8;
@@ -399,7 +367,6 @@ public:
const uint64 checksum = old_g_str_hash (string_printf ("%lld", key_uint).c_str()) % 509;
key_uint |= checksum;
key_uint ^= checksum << 32LL; // obfuscate high bits with checksum
-
string key_string;
for (int i = 0; i < 7; i++) /* encode in custom base-62 format; 7 digits <=> 2^41 < 62^7 */
{
@@ -413,7 +380,6 @@ public:
key_uint /= 62;
}
g_assert (key_uint == 0);
-
return key_string;
}
bool
@@ -516,17 +482,14 @@ public:
TDONE();
}
};
-
static bool
parse_chunk_selection (char **argv,
uint &i,
uint argc,
bool &all_chunks,
vector<float> &freq_list)
-
{
const gchar *str = NULL;
-
if (parse_bool_option (argv, i, "--all-chunks"))
{
all_chunks = true;
@@ -560,7 +523,6 @@ parse_chunk_selection (char **argv,
}
return false;
}
-
static void
verify_chunk_selection (const vector<float> &freq_list,
Wave *wave)
@@ -576,7 +538,6 @@ verify_chunk_selection (const vector<float> &freq_list,
}
}
}
-
static void
wavetool_parse_args (int *argc_p,
char ***argv_p)
@@ -585,14 +546,12 @@ wavetool_parse_args (int *argc_p,
gchar **argv = *argv_p;
gchar *envar;
guint i;
-
envar = getenv ("BSEWAVETOOL_DEBUG");
if (envar)
Msg::allow_msgs (envar);
envar = getenv ("BSEWAVETOOL_NO_DEBUG");
if (envar)
Msg::deny_msgs (envar);
-
for (i = 1; i < argc; i++)
{
const gchar *str = NULL;
@@ -652,7 +611,6 @@ wavetool_parse_args (int *argc_p,
; /* preserve remaining options */
}
}
-
guint e = 1;
for (i = 1; i < argc; i++)
if (argv[i])
@@ -663,7 +621,6 @@ wavetool_parse_args (int *argc_p,
}
*argc_p = e;
}
-
/* --- command implementations --- */
class Store : public Command {
public:
@@ -690,7 +647,6 @@ public:
/* "**********1*********2*********3*********4*********5*********6*********7*********" */
}
} cmd_store ("store");
-
class Create : public Command {
bool force_creation;
public:
@@ -766,7 +722,6 @@ public:
return true;
}
} cmd_create ("create");
-
class Oggenc : public Command {
public:
float quality;
@@ -929,7 +884,6 @@ public:
return true;
}
} cmd_oggenc ("oggenc");
-
class AddChunk : public Command {
struct OptChunk {
const gchar *midi_note;
@@ -1229,7 +1183,6 @@ public:
return true;
}
} cmd_add_chunk ("add-chunk"), cmd_add_raw_chunk ("add-raw-chunk", AddChunk::RAW);
-
class DelChunkCmd : public Command {
vector<gfloat> m_freq_list;
bool m_all_chunks;
@@ -1270,13 +1223,11 @@ public:
{
list<WaveChunk>::iterator next_it = it;
next_it++;
-
if (m_all_chunks || wave->match (*it, m_freq_list))
{
GslDataHandle *dhandle = it->dhandle;
double osc_freq = gsl_data_handle_osc_freq (dhandle);
sfi_info ("DELETE: osc-freq=%g", osc_freq);
-
wave->remove (it);
}
it = next_it;
@@ -1289,7 +1240,6 @@ public:
{
}
} cmd ("del-chunk");
-
class XInfoCmd : public Command {
vector<char*> args;
public:
@@ -1457,7 +1407,6 @@ public:
return true;
}
} cmd_xinfo ("xinfo");
-
class InfoCmd : public Command {
vector<gfloat> m_freq_list;
vector<String> m_fields;
@@ -1529,7 +1478,6 @@ public:
string_tokenize (const String& str)
{
vector<String> words;
-
String::const_iterator word_start = str.begin();
for (String::const_iterator si = str.begin(); si != str.end(); si++)
{
@@ -1539,10 +1487,8 @@ public:
word_start = si + 1;
}
}
-
if (!str.empty()) /* handle last word in string */
words.push_back (String (word_start, str.end()));
-
return words;
}
guint
@@ -1550,7 +1496,6 @@ public:
char **argv)
{
bool seen_selection = false;
-
for (guint i = 1; i < argc; i++)
{
const char *str = NULL;
@@ -1607,7 +1552,6 @@ public:
int64 n_values = gsl_data_handle_length (dhandle);
int64 n_channels = gsl_data_handle_n_channels (dhandle);
int64 n_frames = n_values / n_channels;
-
g_return_val_if_fail (n_values % n_channels == 0, n_frames); /* a datahandle cannot contain half frames */
return n_frames;
}
@@ -1617,7 +1561,6 @@ public:
{
const double min_db = -200;
g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (dhandle), min_db);
-
/* We do not take into account that a data handle can contain many separate
* channels, so we're effectively averaging over all channels here.
*/
@@ -1630,7 +1573,6 @@ public:
}
avg_energy /= MAX (dhandle->setup.n_values, 1);
avg_energy *= volume_adjustment * volume_adjustment;
-
if (avg_energy > 0)
return 10 * log (avg_energy) / log (10);
else
@@ -1668,14 +1610,12 @@ public:
{
sort (m_freq_list.begin(), m_freq_list.end());
verify_chunk_selection (m_freq_list, wave);
-
if (m_output_format == SCRIPT && m_location_wave)
{
for (vector<string>::const_iterator fi = m_fields.begin(); fi != m_fields.end(); fi++)
{
if (fi != m_fields.begin()) // not first field
g_print (" ");
-
if (*fi == "channels")
g_print ("%d", wave->n_channels);
else if (*fi == "label")
@@ -1700,7 +1640,6 @@ public:
{
g_print ("\n");
g_print ("Wave\n");
-
if (wave->name != "")
g_print (" Label %s\n", wave->name.c_str());
const char *blurb = bse_xinfos_get_value (wave->wave_xinfos, "blurb");
@@ -1712,11 +1651,9 @@ public:
const char *license = bse_xinfos_get_value (wave->wave_xinfos, "license");
if (license)
g_print (" License %s\n", license);
-
g_print (" Channels %7d\n", wave->n_channels);
g_print ("\n");
}
-
/* get the wave into storage order */
wave->sort();
for (list<WaveChunk>::iterator it = wave->chunks.begin(); it != wave->chunks.end(); it++)
@@ -1724,14 +1661,12 @@ public:
{
WaveChunk *chunk = &*it;
GslDataHandle *dhandle = chunk->dhandle;
-
if (m_output_format == SCRIPT)
{
for (vector<string>::const_iterator fi = m_fields.begin(); fi != m_fields.end(); fi++)
{
if (fi != m_fields.begin()) // not first field
g_print (" ");
-
if (*fi == "channels")
g_print ("%d", wave->n_channels);
else if (*fi == "length")
@@ -1781,7 +1716,6 @@ public:
const char *blurb = bse_xinfos_get_value (dhandle->setup.xinfos, "blurb");
if (blurb)
g_print (" Comment %s\n", blurb);
-
g_print (" Osc Freq %13.2f Hz\n", gsl_data_handle_osc_freq (dhandle));
g_print (" Mix Freq %13.2f Hz\n", gsl_data_handle_mix_freq (dhandle));
if (bse_xinfos_get_value (dhandle->setup.xinfos, "midi-note"))
@@ -1818,7 +1752,6 @@ public:
SfiNum loop_start = bse_xinfos_get_num (dhandle->setup.xinfos, "loop-start");
SfiNum loop_end = bse_xinfos_get_num (dhandle->setup.xinfos, "loop-end");
g_print (" (start: %lld, end: %lld, ", loop_start, loop_end);
-
SfiNum loop_count = bse_xinfos_get_num (dhandle->setup.xinfos, "loop-count");
if (!loop_count)
g_print ("forever)\n");
@@ -1831,7 +1764,6 @@ public:
return false; /* bsewave didn't change */
}
} cmd_info ("info");
-
class ClipCmd : public Command {
gfloat threshold;
guint head_samples, tail_samples, fade_samples, pad_samples, tail_silence;
@@ -1913,7 +1845,6 @@ public:
{
sort (freq_list.begin(), freq_list.end());
verify_chunk_selection (freq_list, wave);
-
vector<list<WaveChunk>::iterator> deleted;
/* level clipping */
for (list<WaveChunk>::iterator it = wave->chunks.begin(); it != wave->chunks.end(); it++)
@@ -1973,7 +1904,6 @@ public:
return true;
}
} cmd_clip ("clip");
-
class NormalizeCmd : public Command {
bool all_chunks;
vector<gfloat> freq_list;
@@ -2014,7 +1944,6 @@ public:
{
sort (freq_list.begin(), freq_list.end());
verify_chunk_selection (freq_list, wave);
-
/* normalization */
for (list<WaveChunk>::iterator it = wave->chunks.begin(); it != wave->chunks.end(); it++)
if (all_chunks || wave->match (*it, freq_list))
@@ -2039,7 +1968,6 @@ public:
return true;
}
} cmd_normalize ("normalize");
-
class LoopCmd : public Command {
bool all_chunks;
vector<gfloat> freq_list;
@@ -2085,7 +2013,6 @@ public:
{
sort (freq_list.begin(), freq_list.end());
verify_chunk_selection (freq_list, wave);
-
vector<list<WaveChunk>::iterator> deleted;
/* level clipping */
for (list<WaveChunk>::reverse_iterator it = wave->chunks.rbegin(); it != wave->chunks.rend(); it++)
@@ -2102,7 +2029,6 @@ public:
lconfig.repetitions = 2;
lconfig.min_loop = (GslLong) MAX (mix_freq / 10, /* at least 100ms */
8820 /* FIXME: hardcoded values in gsl_data_loop*() -> 200ms */);
-
gboolean found_loop = gsl_data_find_loop5 (dhandle, &lconfig, NULL, gsl_progress_printerr);
const char *loop_algorithm = "loop5";
if (found_loop)
@@ -2119,7 +2045,6 @@ public:
if (lconfig.n_details > 1)
xinfos = bse_xinfos_add_float (xinfos, "loop-score-detail2", lconfig.detail_scores[1]);
xinfos = bse_xinfos_add_value (xinfos, "loop-algorithm", loop_algorithm);
-
gsl_data_handle_ref (dhandle);
BseErrorType error = chunk->change_dhandle (dhandle, gsl_data_handle_osc_freq (dhandle), xinfos);
if (error)
@@ -2130,7 +2055,6 @@ public:
return true;
}
} cmd_loop ("loop");
-
#if 0
class ThinOutCmd : public Command {
GslLong max_total_size;
@@ -2213,21 +2137,18 @@ public:
}
return 0; /* # args missing */
}
-
struct ChunkData
{
vector<GslLong> sizes;
vector<gdouble> errors;
vector<gdouble> freqs;
vector<list<WaveChunk>::iterator> iterators;
-
int
n_chunks() const
{
return sizes.size();
}
};
-
struct ChunkSet
{
/*
@@ -2236,12 +2157,10 @@ public:
error (s.error)
{
}
-
ChunkSet ()
{
error = -1;
}
-
const ChunkSet& operator =(const ChunkSet& s)
{
chunks = s.chunks;
@@ -2249,10 +2168,8 @@ public:
return *this;
}
*/
-
vector<guint8> chunks; /* which chunks should be used */
double error; /* total_error (chunk_data, chunks) <- to be minimized */
-
/* syntactic sugar */
guint8& operator[] (size_t n)
{
@@ -2267,36 +2184,28 @@ public:
exec (Wave *wave)
{
ChunkData chunk_data;
-
/* level clipping */
for (list<WaveChunk>::iterator it = wave->chunks.begin(); it != wave->chunks.end(); it++)
{
WaveChunk *chunk = &*it;
GslDataHandle *dhandle = chunk->dhandle;
-
gfloat error = bse_xinfos_get_float (dhandle->setup.xinfos, "loop-score");
GslLong size = 1;
gdouble freq = gsl_data_handle_osc_freq (chunk->dhandle);
-
sfi_info ("THINOUT: chunk %f: error %f, size %lld", freq, error, size);
-
chunk_data.sizes.push_back (size);
chunk_data.errors.push_back (error);
chunk_data.freqs.push_back (freq);
chunk_data.iterators.push_back (it);
}
-
g_assert (chunk_data.sizes.size() > 0);
g_assert (chunk_data.sizes.size() == chunk_data.errors.size());
-
ChunkSet chunk_set;
init_empty_set (chunk_data, chunk_set);
-
if (gal_iterations)
gal_optimize (chunk_data, chunk_set);
else
optimize (chunk_data, chunk_set);
-
/* really delete chunks */
for (int i = 0; i < chunk_data.n_chunks(); i++)
{
@@ -2311,7 +2220,6 @@ public:
chunk_set.chunks.resize (chunk_data.n_chunks());
chunk_set.error = total_error (chunk_data, chunk_set);
}
-
void gal_create_child (const ChunkSet& father, const ChunkSet& mother, ChunkSet& child)
{
if (rand() % 2)
@@ -2328,7 +2236,6 @@ public:
child.chunks[i] = mother.chunks[i];
}
}
-
int mutations = (rand() % 7) + 1;
for (int i = 0; i < mutations; i++)
{
@@ -2336,7 +2243,6 @@ public:
child.chunks[k] = !child.chunks[k];
}
}
-
struct GalErrorSort
{
bool operator () (const ChunkSet& set1, const ChunkSet& set2) const
@@ -2344,15 +2250,12 @@ public:
return set1.error < set2.error;
}
};
-
void gal_optimize (const ChunkData& chunk_data, ChunkSet& chunk_set)
{
const int POPULATION_SIZE = 64;
vector<ChunkSet> population;
-
for (int i = 0; i < POPULATION_SIZE; i++)
population.push_back (chunk_set);
-
for (uint64 giteration = 0; giteration < gal_iterations; giteration++)
{
/*
@@ -2363,13 +2266,10 @@ public:
{
int father = rand() % (POPULATION_SIZE / 2);
int mother = rand() % (POPULATION_SIZE / 2);
-
gal_create_child (population[father], population[mother], population[i]);
population[i].error = total_error (chunk_data, population[i]);
}
-
sort (population.begin(), population.end(), GalErrorSort());
-
/*
* if one individuum is present more than once in the population
* replace it with "less fit" individuums
@@ -2386,26 +2286,21 @@ public:
}
#if 0
printf ("k = %d, p = %d\n", k, p);
-
printf ("giteration %lld error %.5f (middle: %.5f, worst: %.5f)\n -> %s\n", giteration,
population[0].error, population[POPULATION_SIZE/2-1].error, population.back().error,
set_to_string (chunk_data, population[0]).c_str());
#endif
}
-
/*
* better individuums are at the beginning of the population after sort
*/
chunk_set = population[0];
-
sfi_info ("THINOUT: error %.5f %s", chunk_set.error, set_to_string (chunk_data, chunk_set).c_str());
}
-
double
total_error (const ChunkData& chunk_data, const ChunkSet& chunk_set)
{
double error = 0;
-
/*
* approximation error (created by replacing S original chunks with R looped and
* resampled chunks, where S is often a lot smaller than R)
@@ -2414,7 +2309,6 @@ public:
{
double best_fdiff = 44100;
double best_fdiff_error = 1000; /* should be a lot more than conventional loop scores */
-
/* FIXME: speed! */
for (int replacement_chunk = 0; replacement_chunk < chunk_data.n_chunks(); replacement_chunk++)
{
@@ -2431,7 +2325,6 @@ public:
}
error += best_fdiff_error;
}
-
/*
* user constraint: maximal total size
*/
@@ -2441,11 +2334,9 @@ public:
for (int i = 0; i < chunk_data.n_chunks(); i++)
if (chunk_set[i])
total_size += chunk_data.sizes[i];
-
if (total_size > max_total_size)
error += (total_size - max_total_size) * 1000.0;
}
-
/*
* user constraint: maximum chunk error
*/
@@ -2457,7 +2348,6 @@ public:
}
return error;
}
-
string
set_to_string (const ChunkData& chunk_data, const ChunkSet& chunk_set)
{
@@ -2472,29 +2362,24 @@ public:
}
}
result += "]";
-
return result;
}
-
void
optimize (const ChunkData& chunk_data, ChunkSet& chunk_set)
{
double best_error = total_error (chunk_data, chunk_set);
int toggle = -1;
-
for (int i = 0; i < chunk_data.n_chunks(); i++)
{
chunk_set[i] = !chunk_set[i];
double error = total_error (chunk_data, chunk_set);
chunk_set[i] = !chunk_set[i];
-
if (error < best_error)
{
best_error = error;
toggle = i;
}
}
-
if (toggle >= 0)
{
chunk_set[toggle] = !chunk_set[toggle];
@@ -2505,12 +2390,10 @@ public:
}
} cmd_thinout ("thinout");
#endif
-
class FirCommand : public Command {
protected:
gdouble m_cutoff_freq;
guint m_order;
-
virtual GslDataHandle* create_fir_handle (GslDataHandle* dhandle) = 0;
public:
FirCommand (const char *command_name) :
@@ -2554,7 +2437,6 @@ public:
BseErrorType error = gsl_data_handle_open (fir_handle);
if (error)
return error;
-
Birnet::int64 freq_inc = 5; // FIXME
while (freq_inc * 1000 < gsl_data_handle_mix_freq (fir_handle))
freq_inc *= 2;
@@ -2572,7 +2454,6 @@ public:
sfi_info ("%s: => %.2f dB at %lld Hz", string_toupper (name).c_str(),
bse_data_handle_fir_response_db (fir_handle, best_freq), best_freq);
gsl_data_handle_close (fir_handle);
-
return BSE_ERROR_NONE;
}
bool
@@ -2586,7 +2467,6 @@ public:
GslDataHandle *dhandle = chunk->dhandle;
sfi_info ("%s: chunk %f: cutoff_freq=%f order=%d", string_toupper (name).c_str(),
gsl_data_handle_osc_freq (chunk->dhandle), m_cutoff_freq, m_order);
-
if (m_cutoff_freq >= gsl_data_handle_mix_freq (dhandle) / 2.0)
{
sfi_error ("chunk % 7.2f/%.0f: IGNORED - can't filter this chunk, cutoff frequency (%f) too high\n",
@@ -2595,11 +2475,9 @@ public:
else
{
GslDataHandle *fir_handle = create_fir_handle (dhandle);
-
BseErrorType error = print_effective_stopband_start (fir_handle);
if (!error)
error = chunk->change_dhandle (fir_handle, 0, 0);
-
if (error)
{
sfi_error ("chunk % 7.2f/%.0f: %s",
@@ -2612,7 +2490,6 @@ public:
return true;
}
};
-
class Highpass : public FirCommand {
protected:
GslDataHandle*
@@ -2626,7 +2503,6 @@ public:
{
}
} cmd_highpass ("highpass");
-
class Lowpass : public FirCommand {
protected:
GslDataHandle*
@@ -2640,7 +2516,6 @@ public:
{
}
} cmd_lowpass ("lowpass");
-
class Upsample2 : public Command {
private:
vector<gfloat> m_freq_list;
@@ -2674,7 +2549,6 @@ public:
char **argv)
{
bool seen_selection = false;
-
for (guint i = 1; i < argc; i++)
{
const gchar *str = NULL;
@@ -2703,7 +2577,6 @@ public:
gsl_data_handle_mix_freq (chunk->dhandle) * 2);
sfi_info (" using resampler precision: %s\n",
bse_resampler2_precision_name (bse_resampler2_find_precision_for_bits (m_precision_bits)));
-
BseErrorType error = chunk->change_dhandle (bse_data_handle_new_upsample2 (dhandle, m_precision_bits), 0, 0);
if (error)
{
@@ -2716,7 +2589,6 @@ public:
return true;
}
} cmd_upsample2 ("upsample2");
-
class Downsample2 : public Command {
private:
vector<gfloat> m_freq_list;
@@ -2750,7 +2622,6 @@ public:
char **argv)
{
bool seen_selection = false;
-
for (guint i = 1; i < argc; i++)
{
const gchar *str = NULL;
@@ -2779,7 +2650,6 @@ public:
gsl_data_handle_mix_freq (chunk->dhandle) / 2);
sfi_info (" using resampler precision: %s\n",
bse_resampler2_precision_name (bse_resampler2_find_precision_for_bits (m_precision_bits)));
-
BseErrorType error = chunk->change_dhandle (bse_data_handle_new_downsample2 (dhandle, 24), 0, 0);
if (error)
{
@@ -2792,13 +2662,11 @@ public:
return true;
}
} cmd_downsample2 ("downsample2");
-
class Export : public Command {
public:
vector<gfloat> freq_list;
bool all_chunks;
string export_filename;
-
Export (const char *command_name) :
Command (command_name)
{
@@ -2829,7 +2697,6 @@ public:
{
bool seen_selection = false;
bool seen_export_filename = false;
-
for (guint i = 1; i < argc; i++)
{
const gchar *str = NULL;
@@ -2859,7 +2726,6 @@ public:
{
string result;
bool need_subst = false;
-
for (size_t i = 0; i < pattern.size(); i++)
{
if (need_subst)
@@ -2886,7 +2752,6 @@ public:
exec (Wave *wave)
{
map<string,bool> used_filenames;
-
/* validate format */
bool have_export_pattern = false;
for (int i = 0; i < int(export_filename.size()) - 1; i++)
@@ -2902,7 +2767,6 @@ public:
exit (1);
}
}
-
/* validate that we have a pattern if more than one chunk gets exported */
if ((all_chunks && wave->chunks.size() > 1) || (freq_list.size() > 1))
{
@@ -2912,11 +2776,9 @@ public:
exit (1);
}
}
-
/* validate freq list */
sort (freq_list.begin(), freq_list.end());
verify_chunk_selection (freq_list, wave);
-
/* get the wave into storage order */
wave->sort();
for (list<WaveChunk>::iterator it = wave->chunks.begin(); it != wave->chunks.end(); it++)
@@ -2924,35 +2786,28 @@ public:
{
WaveChunk *chunk = &*it;
GslDataHandle *dhandle = chunk->dhandle;
-
gchar *name_addon = NULL;
string filename = export_filename;
int note = bse_xinfos_get_num (dhandle->setup.xinfos, "midi-note");
int cent = 0;
-
if (!note)
{
note = bse_note_from_freq_bounded (BSE_MUSICAL_TUNING_12_TET, gsl_data_handle_osc_freq (dhandle));
cent = bse_note_fine_tune_from_note_freq (BSE_MUSICAL_TUNING_12_TET, note, gsl_data_handle_osc_freq (dhandle));
}
-
name_addon = g_strdup_printf ("%d", note);
substitute (filename, 'N', name_addon);
g_free (name_addon);
-
name_addon = g_strdup_printf ("%.2f", gsl_data_handle_osc_freq (dhandle));
substitute (filename, 'F', name_addon);
g_free (name_addon);
-
if (cent >= 0)
name_addon = g_strdup_printf ("u%03d", cent); /* up */
else
name_addon = g_strdup_printf ("d%03d", cent); /* down */
substitute (filename, 'C', name_addon);
g_free (name_addon);
-
sfi_info ("EXPORTING: chunk %f to %s", gsl_data_handle_osc_freq (dhandle), filename.c_str());
-
if (used_filenames[filename])
{
sfi_warning ("another chunk was already exported to %s. skipping this chunk export.", filename.c_str());
@@ -2962,14 +2817,12 @@ public:
{
used_filenames[filename] = true;
}
-
int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
{
BseErrorType error = bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
sfi_error ("export to file %s failed: %s", filename.c_str(), bse_error_blurb (error));
}
-
int xerrno = gsl_data_handle_dump_wav (dhandle, fd, 16, dhandle->setup.n_channels, (guint) dhandle->setup.mix_freq);
if (xerrno)
{
@@ -2981,7 +2834,6 @@ public:
return true;
}
} cmd_export ("export");
-
class ListChunks : public Command {
public:
ListChunks (const char *command_name) :
@@ -3019,13 +2871,11 @@ public:
{
WaveChunk *chunk = &*it;
WaveChunkKey chunk_key (gsl_data_handle_osc_freq (chunk->dhandle));
-
g_print ("%s\n", chunk_key.as_string().c_str());
}
return true;
}
} cmd_list_chunks ("list-chunks");
-
/* TODO commands:
* bsewavetool.1 # need manual page
* bsewavetool merge <file.bsewave> <second.bsewave>
@@ -3043,7 +2893,5 @@ public:
* --tremolo=<s,r,d> tremolo, s.., r..., d...
* --vibrato=<s,r,d> vibrato, s.., r..., d...
*/
-
} // BseWaveTool
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tools/bsewavetool.hh b/tools/bsewavetool.hh
index c76e464..3570c83 100644
--- a/tools/bsewavetool.hh
+++ b/tools/bsewavetool.hh
@@ -6,10 +6,8 @@
#include <unistd.h>
#include <typeinfo>
#include <string>
-
namespace BseWaveTool {
using namespace std;
-
/* --- command + registry --- */
class Command {
public:
@@ -23,5 +21,4 @@ public:
virtual ~Command () {}
static list<Command*> registry;
};
-
} // BseWaveTool
diff --git a/tools/bwtwave.cc b/tools/bwtwave.cc
index 8649303..a19529e 100644
--- a/tools/bwtwave.cc
+++ b/tools/bwtwave.cc
@@ -13,15 +13,11 @@
#include <algorithm>
#include <vector>
#include <map>
-
-
namespace BseWaveTool {
-
WaveChunk::WaveChunk ()
{
dhandle = NULL;
}
-
WaveChunk&
WaveChunk::operator= (const WaveChunk &rhs)
{
@@ -30,14 +26,12 @@ WaveChunk::operator= (const WaveChunk &rhs)
gsl_data_handle_open (dhandle);
return *this;
}
-
WaveChunk::WaveChunk (const WaveChunk &rhs)
{
*this = rhs;
if (dhandle)
gsl_data_handle_open (dhandle);
}
-
BseErrorType
WaveChunk::change_dhandle (GslDataHandle *xhandle,
gdouble osc_freq,
@@ -65,7 +59,6 @@ WaveChunk::change_dhandle (GslDataHandle *xhandle,
else
return error;
}
-
BseErrorType
WaveChunk::set_dhandle_from_file (const string &fname,
gdouble osc_freq,
@@ -89,13 +82,11 @@ WaveChunk::set_dhandle_from_file (const string &fname,
else
return error;
}
-
WaveChunk::~WaveChunk ()
{
if (dhandle)
gsl_data_handle_close (dhandle);
}
-
Wave::Wave (const gchar *wave_name,
guint n_ch,
gchar **xinfos) :
@@ -104,13 +95,11 @@ Wave::Wave (const gchar *wave_name,
wave_xinfos (bse_xinfos_dup_consolidated (xinfos, FALSE))
{
}
-
BseErrorType
Wave::add_chunk (GslDataHandle *dhandle,
gchar **xinfos)
{
g_return_val_if_fail (dhandle != NULL, BSE_ERROR_INTERNAL);
-
if (xinfos)
{
GslDataHandle *tmp_handle = gsl_data_handle_new_add_xinfos (dhandle, xinfos);
@@ -119,7 +108,6 @@ Wave::add_chunk (GslDataHandle *dhandle,
}
else
gsl_data_handle_ref (dhandle);
-
BseErrorType error = gsl_data_handle_open (dhandle);
if (!error)
{
@@ -130,7 +118,6 @@ Wave::add_chunk (GslDataHandle *dhandle,
gsl_data_handle_unref (dhandle);
return error;
}
-
void
Wave::set_xinfo (const gchar *key,
const gchar *value)
@@ -140,7 +127,6 @@ Wave::set_xinfo (const gchar *key,
else
wave_xinfos = bse_xinfos_del_value (wave_xinfos, key);
}
-
void
Wave::set_chunks_xinfo (const gchar *key,
const gchar *value,
@@ -169,7 +155,6 @@ Wave::set_chunks_xinfo (const gchar *key,
wchunk.dhandle = tmp_handle;
}
}
-
GslDataHandle*
Wave::lookup (gfloat osc_freq)
{
@@ -178,14 +163,12 @@ Wave::lookup (gfloat osc_freq)
return it->dhandle;
return NULL;
}
-
static int
compare_floats (float f1,
float f2)
{
return f1 < f2 ? -1 : f1 > f2;
}
-
bool
Wave::match (const WaveChunk &wchunk,
vector<float> &sorted_freqs)
@@ -202,13 +185,11 @@ Wave::match (const WaveChunk &wchunk,
return true;
return false;
}
-
void
Wave::remove (list<WaveChunk>::iterator it)
{
chunks.erase (it);
}
-
void
Wave::sort ()
{
@@ -230,12 +211,10 @@ Wave::sort ()
chunks.assign (vwc.begin(), vwc.end());
#endif
}
-
BseErrorType
Wave::store (const string file_name)
{
g_return_val_if_fail (file_name.c_str() != NULL, BSE_ERROR_INTERNAL);
-
/* save to temporary file */
gint fd;
gchar *temp_file = NULL;
@@ -252,7 +231,6 @@ Wave::store (const string file_name)
g_free (temp_file);
return bse_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
}
-
/* figure default mix_freq */
guint n_raw_handles = 0;
map<float, guint> mf_counters;
@@ -283,7 +261,6 @@ Wave::store (const string file_name)
max_count = it->second;
dfl_mix_freq = it->first;
}
-
/* dump wave header */
SfiWStore *wstore = sfi_wstore_new ();
wstore->comment_start = '#';
@@ -316,7 +293,6 @@ Wave::store (const string file_name)
g_free (ckey);
}
g_strfreev (xinfos);
-
/* dump chunks */
for (list<WaveChunk>::iterator it = chunks.begin(); it != chunks.end(); it++)
{
@@ -331,7 +307,6 @@ Wave::store (const string file_name)
sfi_wstore_putf (wstore, gsl_data_handle_osc_freq (chunk->dhandle));
sfi_wstore_puts (wstore, "\n");
}
-
GslDataHandle *dhandle, *tmp_handle = chunk->dhandle;
do /* skip comment or cache handles */
{
@@ -359,7 +334,6 @@ Wave::store (const string file_name)
sfi_wstore_puts (wstore, "\n");
}
}
-
if (chunk->dhandle->setup.xinfos)
for (guint i = 0; chunk->dhandle->setup.xinfos[i]; i++)
if (chunk->dhandle->setup.xinfos[i][0] != '.')
@@ -382,17 +356,14 @@ Wave::store (const string file_name)
}
g_free (ckey);
}
-
sfi_wstore_puts (wstore, " }\n");
}
-
sfi_wstore_puts (wstore, "}\n");
gint nerrno = sfi_wstore_flush_fd (wstore, fd);
BseErrorType error = bse_error_from_errno (-nerrno, BSE_ERROR_FILE_WRITE_FAILED);
if (close (fd) < 0 && error == BSE_ERROR_NONE)
error = bse_error_from_errno (errno, BSE_ERROR_FILE_WRITE_FAILED);
sfi_wstore_destroy (wstore);
-
/* replace output file by temporary file */
if (error != BSE_ERROR_NONE)
{
@@ -404,13 +375,10 @@ Wave::store (const string file_name)
unlink (temp_file);
}
g_free (temp_file);
-
return error;
}
-
Wave::~Wave ()
{
g_strfreev (wave_xinfos);
}
-
} // BseWaveTool
diff --git a/tools/bwtwave.hh b/tools/bwtwave.hh
index 318d0dd..752f3f4 100644
--- a/tools/bwtwave.hh
+++ b/tools/bwtwave.hh
@@ -1,17 +1,14 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BWT_WAVE_H__
#define __BWT_WAVE_H__
-
#include <bse/gsldatahandle.hh>
#include <bse/gslwavechunk.hh>
#include <bse/bseenums.hh>
#include <string>
#include <list>
#include <vector>
-
namespace BseWaveTool {
using namespace std;
-
class WaveChunk {
public:
GslDataHandle *dhandle; /* always open */
@@ -26,7 +23,6 @@ public:
gchar **xinfos);
/*Des*/ ~WaveChunk();
};
-
struct Wave {
guint n_channels;
string name;
@@ -63,7 +59,5 @@ public:
BseErrorType store (const string file_name);
/*Des*/ ~Wave ();
};
-
} // BseWaveTool
-
#endif /* __BWT_WAVE_H__ */
diff --git a/tools/cutvorbis.cc b/tools/cutvorbis.cc
index 105c6d2..85d8eaa 100644
--- a/tools/cutvorbis.cc
+++ b/tools/cutvorbis.cc
@@ -8,12 +8,10 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-
static GslVorbisCutterMode cutmode = GSL_VORBIS_CUTTER_NONE;
static SfiNum cutpoint = 0;
static guint filtered_serialno = 0;
static gboolean filter_serialno = FALSE;
-
static void
parse_args (int *argc_p,
char ***argv_p)
@@ -62,7 +60,6 @@ parse_args (int *argc_p,
}
*argc_p = e;
}
-
int
main (int argc,
char *argv[])
@@ -70,7 +67,6 @@ main (int argc,
const gchar *ifile, *ofile;
GslVorbisCutter *cutter;
gint ifd, ofd;
-
/* initialization */
SfiInitValue values[] = {
{ "stand-alone", "true" }, /* no rcfiles etc. */
@@ -80,7 +76,6 @@ main (int argc,
{ NULL }
};
bse_init_inprocess (&argc, &argv, "BseCutVorbis", values);
-
/* arguments */
parse_args (&argc, &argv);
if (argc != 3)
@@ -94,12 +89,10 @@ main (int argc,
}
ifile = argv[1];
ofile = argv[2];
-
cutter = gsl_vorbis_cutter_new ();
gsl_vorbis_cutter_set_cutpoint (cutter, cutmode, cutpoint);
if (filter_serialno)
gsl_vorbis_cutter_filter_serialno (cutter, filtered_serialno);
-
ifd = open (ifile, O_RDONLY);
if (ifd < 0)
{
@@ -112,7 +105,6 @@ main (int argc,
g_printerr ("Error: failed to open \"%s\": %s\n", ofile, g_strerror (errno));
exit (1);
}
-
while (!gsl_vorbis_cutter_ogg_eos (cutter))
{
guint blength = 8192, n, j;
@@ -139,7 +131,6 @@ main (int argc,
exit (1);
}
}
-
close (ifd);
if (close (ofd) < 0)
{
@@ -147,6 +138,5 @@ main (int argc,
exit (1);
}
g_print ("done\n");
-
return 0;
}
diff --git a/tools/magictest.cc b/tools/magictest.cc
index d55fc7d..593a5d2 100644
--- a/tools/magictest.cc
+++ b/tools/magictest.cc
@@ -7,7 +7,6 @@
#include <bse/gsldatahandle.hh>
#include <stdio.h>
#include <string.h>
-
static gint
help (gchar *arg)
{
@@ -15,10 +14,8 @@ help (gchar *arg)
fprintf (stderr, " -p include plugins\n");
fprintf (stderr, " -t test loading file info\n");
fprintf (stderr, " -h guess what ;)\n");
-
return arg != NULL;
}
-
int
main (gint argc,
gchar *argv[])
@@ -43,21 +40,18 @@ main (gint argc,
guint i;
SfiRing *magic_list = NULL;
gboolean test_open = FALSE;
-
/* initialization */
SfiInitValue values[] = {
{ "stand-alone", "true" }, /* no rcfiles etc. */
{ NULL }
};
bse_init_inprocess (&argc, &argv, "BseMagicTest", values);
-
for (i = 0; i < n_magic_presets; i++)
magic_list = sfi_ring_append (magic_list,
gsl_magic_create ((void*) magic_presets[i][0],
0,
0,
magic_presets[i][1]));
-
for (i = 1; i < uint (argc); i++)
{
if (strcmp ("-p", argv[i]) == 0)
@@ -74,7 +68,6 @@ main (gint argc,
GslMagic *magic = gsl_magic_list_match_file (magic_list, argv[i]);
guint l = strlen (argv[i]);
gchar *pad;
-
g_print ("%s:", argv[i]);
pad = g_strnfill (MAX (40, l) - l, ' ');
g_print ("%s", pad);
@@ -104,6 +97,5 @@ main (gint argc,
g_print ("\n");
}
}
-
return 0;
}
diff --git a/tools/mathtool.cc b/tools/mathtool.cc
index 95d997a..879e5f3 100644
--- a/tools/mathtool.cc
+++ b/tools/mathtool.cc
@@ -8,22 +8,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#define PREC "15"
-
-
static void usage (void) G_GNUC_NORETURN;
-
static void ring_test (void);
-
static guint shift_argc = 0;
static const gchar **shift_argv = NULL;
-
static const gchar*
shift (void)
{
const gchar *arg;
-
if (shift_argc > 1)
{
shift_argc--;
@@ -39,10 +32,8 @@ static const gchar*
pshift (void)
{
const gchar *arg = shift ();
-
return arg ? arg : "";
}
-
int
main (int argc,
char *argv[])
@@ -53,10 +44,8 @@ main (int argc,
const gchar *filter_label = 0;
gdouble *a, *b;
guint i, order = 0;
-
shift_argc = argc;
shift_argv = (const gchar**) argv;
-
/* init */
SfiInitValue values[] = {
{ "stand-alone", "true" }, /* no rcfiles etc. */
@@ -66,14 +55,11 @@ main (int argc,
{ NULL }
};
bse_init_inprocess (&argc, &argv, NULL, values);
-
arg = shift ();
if (!arg)
usage ();
-
restart:
a = b = 0;
-
if (strcmp (arg, "approx5-exp2-run") == 0)
{
gfloat f;
@@ -95,17 +81,14 @@ main (int argc,
else if (strcmp (arg, "wave-scan") == 0)
{
const gchar *file = pshift ();
-
while (file)
{
BseWaveFileInfo *fi;
BseErrorType error;
-
fi = bse_wave_file_info_load (file, &error);
if (fi)
{
guint i;
-
g_print ("Loader \"%s\" found %u waves in \"%s\":\n", fi->loader->name, fi->n_waves, file);
for (i = 0; i < fi->n_waves; i++)
g_print ("%u) %s\n", i + 1, fi->waves[i].name);
@@ -121,7 +104,6 @@ main (int argc,
else if (strcmp (arg, "file-test") == 0)
{
const gchar *file = pshift ();
-
g_print ("file test for \"%s\":\n", file);
g_print (" is readable : %s\n", bse_error_blurb (gsl_file_check (file, "r")));
g_print (" is writable : %s\n", bse_error_blurb (gsl_file_check (file, "w")));
@@ -141,7 +123,6 @@ main (int argc,
x = atof (pshift ());
y = atof (pshift ());
z = atof (pshift ());
-
g_print ("rf(%f, %f, %f) = %."PREC"f\n", x, y, z, gsl_ellip_rf (x, y, z));
}
else if (strcmp (arg, "F") == 0)
@@ -149,7 +130,6 @@ main (int argc,
double phi, ak;
phi = atof (pshift ());
ak = atof (pshift ());
-
g_print ("F(%f, %f) = %."PREC"f\n", phi, ak, gsl_ellip_F (phi, ak));
}
else if (strcmp (arg, "sn") == 0)
@@ -157,7 +137,6 @@ main (int argc,
double u, emmc;
u = atof (pshift ());
emmc = atof (pshift ());
-
g_print ("sn(%f, %f) = %."PREC"f\n", u, emmc, gsl_ellip_sn (u, emmc));
}
else if (strcmp (arg, "snc") == 0)
@@ -167,7 +146,6 @@ main (int argc,
u.im = atof (pshift ());
emmc.re = atof (pshift ());
emmc.im = atof (pshift ());
-
g_print ("snc(%s, %s) = %s\n",
bse_complex_str (u),
bse_complex_str (emmc),
@@ -180,7 +158,6 @@ main (int argc,
u.im = atof (pshift ());
k2.re = atof (pshift ());
k2.im = atof (pshift ());
-
g_print ("sci_snc(%s, %s) = %s\n",
bse_complex_str (u),
bse_complex_str (k2),
@@ -191,7 +168,6 @@ main (int argc,
double y, emmc;
y = atof (pshift ());
emmc = atof (pshift ());
-
g_print ("asn(%f, %f) = %."PREC"f\n", y, emmc, gsl_ellip_asn (y, emmc));
}
else if (strcmp (arg, "asnc") == 0)
@@ -201,7 +177,6 @@ main (int argc,
y.im = atof (pshift ());
emmc.re = atof (pshift ());
emmc.im = atof (pshift ());
-
g_print ("asnc(%s, %s) = %s\n",
bse_complex_str (y), bse_complex_str (emmc),
bse_complex_str (bse_complex_ellip_asn (y, emmc)));
@@ -252,7 +227,6 @@ main (int argc,
{
BseComplex root, roots[100];
guint i;
-
if (*arg == 'r')
{
g_print ("#roots:\n");
@@ -364,7 +338,6 @@ main (int argc,
f *= PI / 2.;
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_butter_hp (order, f, e, a, b);
g_print ("# Highpass Butterworth filter order=%u freq=%f epsilon(s^2)=%f norm0=%f:\n",
order, f, e,
@@ -382,7 +355,6 @@ main (int argc,
f2 *= PI / 2.;
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_butter_bp (order, f1, f2, e, a, b);
g_print ("# Bandpass Butterworth filter order=%u freq1=%f freq2=%f epsilon(s^2)=%f norm0=%f:\n",
order, f1, f2, e,
@@ -400,7 +372,6 @@ main (int argc,
f2 *= PI / 2.;
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_butter_bs (order, f1, f2, e, a, b);
g_print ("# Bandstop Butterworth filter order=%u freq1=%f freq2=%f epsilon(s^2)=%f norm0=%f:\n",
order, f1, f2, e,
@@ -416,7 +387,6 @@ main (int argc,
f *= PI / 2.;
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb1_lp (order, f, e, a, b);
g_print ("# Lowpass Tschebyscheff Type1 order=%u freq=%f epsilon(s^2)=%f norm0=%f:\n",
order, f, e,
@@ -430,10 +400,8 @@ main (int argc,
f = atof (pshift ());
e = atof (pshift ());
f *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb1_hp (order, f, e, a, b);
g_print ("# Highpass Tschebyscheff Type1 order=%u freq=%f epsilon(s^2)=%f norm0=%f:\n",
order, f, e,
@@ -449,10 +417,8 @@ main (int argc,
e = atof (pshift ());
fc *= PI / 2.;
fr *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb1_bs (order, fc, fr, e, a, b);
g_print ("# Bandstop Tschebyscheff Type1 order=%u freq_c=%f freq_r=%f epsilon(s^2)=%f norm=%f:\n",
order, fc, fr, e,
@@ -468,10 +434,8 @@ main (int argc,
e = atof (pshift ());
fc *= PI / 2.;
fr *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb1_bp (order, fc, fr, e, a, b);
g_print ("# Bandpass Tschebyscheff Type1 order=%u freq_c=%f freq_r=%f epsilon(s^2)=%f norm=%f:\n",
order, fc, fr, e,
@@ -486,10 +450,8 @@ main (int argc,
st = atof (pshift ());
e = atof (pshift ());
f *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb2_lp (order, f, st, e, a, b);
g_print ("# Lowpass Tschebyscheff Type2 order=%u freq=%f steepness=%f (%f) epsilon(s^2)=%f norm=%f:\n",
order, f, st, f * (1.+st), e,
@@ -504,10 +466,8 @@ main (int argc,
st = atof (pshift ());
e = atof (pshift ());
f *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb2_hp (order, f, st, e, a, b);
g_print ("# Highpass Tschebyscheff Type2 order=%u freq=%f steepness=%f (%f, %f) epsilon(s^2)=%f norm=%f:\n",
order, f, st, PI - f, (PI - f) * (1.+st), e,
@@ -524,10 +484,8 @@ main (int argc,
e = atof (pshift ());
f1 *= PI / 2.;
f2 *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb2_bp (order, f1, f2, st, e, a, b);
g_print ("# Bandpass Tschebyscheff Type2 order=%u freq1=%f freq2=%f steepness=%f epsilon(s^2)=%f norm=%f:\n",
order, f1, f2, st, e,
@@ -544,10 +502,8 @@ main (int argc,
e = atof (pshift ());
f1 *= PI / 2.;
f2 *= PI / 2.;
-
a = g_new (gdouble, order + 1);
b = g_new (gdouble, order + 1);
-
gsl_filter_tscheb2_bs (order, f1, f2, st, e, a, b);
g_print ("# Bandstop Tschebyscheff Type2 order=%u freq1=%f freq2=%f steepness=%f epsilon(s^2)=%f norm=%f:\n",
order, f1, f2, st, e,
@@ -562,17 +518,14 @@ main (int argc,
{
unsigned int iorder = atoi (pshift ());
unsigned int n_points = 0;
-
double *freq = g_newa (double, argc / 2 + 1);
double *value = g_newa (double, argc / 2 + 1);
double *a = g_newa (double, iorder);
const char *f, *v;
-
do
{
f = pshift ();
v = pshift ();
-
if (f[0] && v[0])
{
freq[n_points] = atof (f) * PI;
@@ -581,17 +534,14 @@ main (int argc,
}
}
while (f[0] && v[0]);
-
gsl_filter_fir_approx (iorder, a, n_points, freq, value, FALSE);
g_print ("FIR%u(z)=%s\n", iorder, bse_poly_str (iorder, a, "z"));
}
else
usage ();
-
if (a && b)
{
gdouble freq;
-
if (filter_mode == FILTER_SCAN)
{
freq = 0.001;
@@ -612,14 +562,11 @@ main (int argc,
g_free (a);
g_free (b);
}
-
arg = shift ();
if (arg)
goto restart;
-
return 0;
}
-
static void
usage (void)
{
@@ -659,7 +606,6 @@ usage (void)
g_print (" poly | polyr | polyp polynom test (+roots or +poles)\n");
exit (1);
}
-
static void
print_int_ring (SfiRing *ring)
{
@@ -669,7 +615,6 @@ print_int_ring (SfiRing *ring)
g_print ("%c", char (size_t (node->data)));
g_print ("}");
}
-
static gint
ints_cmp (gconstpointer d1,
gconstpointer d2,
@@ -679,7 +624,6 @@ ints_cmp (gconstpointer d1,
size_t i2 = size_t (d2);
return i1 < i2 ? -1 : i1 > i2;
}
-
static void
ring_test (void)
{
@@ -702,7 +646,6 @@ ring_test (void)
{ 26, 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm'
, 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', },
};
-
for (uint n = 0; n < G_N_ELEMENTS (data_array); n++)
{
uint l = data_array[n][0];
@@ -718,6 +661,4 @@ ring_test (void)
sfi_ring_free (ring);
}
}
-
-
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/tools/scripts/noteplaytest.scm b/tools/scripts/noteplaytest.scm
index 9a3bf43..5df2fec 100644
--- a/tools/scripts/noteplaytest.scm
+++ b/tools/scripts/noteplaytest.scm
@@ -1,11 +1,9 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0
-
;;
;; usage: bsescm -s noteplaytest.scm <instrument> <note> <time_ms>
;;
;; plays instrument at the specified frequency for the specified amount of time in ms
;;
-
(define (load-wave wave-repo wave-file)
(let*
((error (bse-wave-repo-load-file wave-repo wave-file)))
@@ -15,7 +13,6 @@
(string-append "FAILED: " wave-file ": " (bse-error-blurb error))
(string-append "OK: " wave-file)))
(newline)))
-
(define (play-project project)
(begin
(display "playing project: ")
@@ -38,7 +35,6 @@
(display "done.")
(newline)
)))
-
(define (test-play-note instrument note time_ms)
(let*
((project (bse-server-use-new-project bse-server "testproject"))
@@ -53,5 +49,4 @@
(bse-track-ensure-output track)
(bse-item-set track "wave" (car (bse-container-list-children wave-repo)))
(play-project project)))
-
(apply test-play-note (cdr (command-line)))
diff --git a/tools/scripts/waveloadtest.scm b/tools/scripts/waveloadtest.scm
index dc990f6..b410d0f 100644
--- a/tools/scripts/waveloadtest.scm
+++ b/tools/scripts/waveloadtest.scm
@@ -1,15 +1,12 @@
;; CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0
-
;;
;; usage: bsescm -s waveloadtest.scm <wav-files>
;; checks whether wave files load properly with BSE
;;
-
(define (clear-wave-repo wave-repo)
(map
(lambda (arg) (bse-wave-repo-remove-wave wave-repo arg))
(bse-container-list-children wave-repo)))
-
(define (test-load-wave wave-repo wave-file)
(let*
((error (bse-wave-repo-load-file wave-repo wave-file)))
@@ -21,7 +18,6 @@
(newline)
(flush-all-ports) ;; allows 'bsescm -s waveloadtest.scm * |tee ...' constructions work properly
(clear-wave-repo wave-repo)))
-
(define test-load-waves
(lambda wave-files
(let*
@@ -30,5 +26,4 @@
(map
(lambda (wave-file) (test-load-wave wave-repo wave-file))
wave-files))))
-
(apply test-load-waves (cdr (command-line)))
diff --git a/tools/sfiutils.cc b/tools/sfiutils.cc
index 4a177cd..eeccfd7 100644
--- a/tools/sfiutils.cc
+++ b/tools/sfiutils.cc
@@ -8,7 +8,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-
/* --- option parser (YES!) --- */
static SfiRing*
parse_arguments (gint *argc_p,
@@ -23,18 +22,14 @@ parse_arguments (gint *argc_p,
guint *lengths = alloca (sizeof (guint) * n_arguments);
guint i, k, l, missing = n_arguments, extraneous = n_arguments;
SfiRing *ring = NULL;
-
for (i = 0; i < n_arguments; i++)
{
g_return_val_if_fail (arguments[i].value_p != NULL, NULL);
-
lengths[i] = arguments[i].long_opt ? strlen (arguments[i].long_opt) : 0;
}
-
for (i = 1; i < argc; i++)
{
gchar *opt = argv[i];
-
l = strlen (opt);
if (l > 2 && opt[0] == '-' && opt[1] == '-')
{
@@ -78,7 +73,6 @@ parse_arguments (gint *argc_p,
if (opt[0] == '-')
{
gboolean found_short = FALSE;
-
if (opt[1] == '-' && !opt[2]) /* abort on "--" */
break;
opt += 1;
@@ -144,7 +138,6 @@ parse_arguments (gint *argc_p,
}
argv[i] = NULL;
}
-
/* handle errors */
if (unknown_short || missing < n_arguments || extraneous < n_arguments || extraneous_arg)
{
@@ -163,12 +156,9 @@ parse_arguments (gint *argc_p,
g_printerr ("extraneous argument: \"%s\"\n", extraneous_arg);
exit (127);
}
-
sfi_arguments_collapse (argc_p, argv_p);
-
return ring;
}
-
void
sfi_arguments_parse (gint *argc_p,
gchar ***argv_p,
@@ -177,7 +167,6 @@ sfi_arguments_parse (gint *argc_p,
{
parse_arguments (argc_p, argv_p, n_arguments, arguments, FALSE);
}
-
SfiRing*
sfi_arguments_parse_list (gint *argc_p,
gchar ***argv_p,
@@ -186,14 +175,12 @@ sfi_arguments_parse_list (gint *argc_p,
{
return parse_arguments (argc_p, argv_p, n_arguments, arguments, TRUE);
}
-
void
sfi_arguments_collapse (gint *argc_p,
gchar ***argv_p)
{
gchar **argv = *argv_p;
guint argc = *argc_p, e, i;
-
e = 1;
for (i = 1; i < argc; i++)
if (argv[i])
@@ -204,17 +191,13 @@ sfi_arguments_collapse (gint *argc_p,
}
*argc_p = e;
}
-
-
gchar*
sfi_util_file_name_subst_ext (const gchar *file_name,
const gchar *new_extension)
{
gchar *p, *name;
-
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (new_extension != NULL, NULL);
-
name = g_strdup (file_name);
p = strrchr (name, '.');
if (p && p > name)
@@ -222,23 +205,18 @@ sfi_util_file_name_subst_ext (const gchar *file_name,
p = g_strconcat (name, new_extension, NULL);
g_free (name);
name = p;
-
return name;
}
-
-
/* --- word splitter --- */
static guint
upper_power2 (guint number)
{
return number ? 1 << g_bit_storage (number - 1) : 0;
}
-
static void
free_entry (SfiUtilFileList *flist)
{
guint i, j;
-
for (i = 0; i < flist->n_entries; i++)
{
for (j = 0; j < flist->entries[i].n_fields; j++)
@@ -247,7 +225,6 @@ free_entry (SfiUtilFileList *flist)
}
g_free (flist->entries);
}
-
void
sfi_util_file_list_free (SfiUtilFileList *flist)
{
@@ -257,7 +234,6 @@ sfi_util_file_list_free (SfiUtilFileList *flist)
g_free (flist->free2);
g_free (flist);
}
-
SfiUtilFileList*
sfi_util_file_list_read (gint fd)
{
@@ -267,7 +243,6 @@ sfi_util_file_list_read (gint fd)
gboolean line_start = TRUE;
gchar *cset_identifier;
guint i;
-
scanner = g_scanner_new64 (NULL);
scanner->config->cset_skip_characters = " \t\r"; /* parse "\n" */
scanner->config->scan_identifier_1char = TRUE;
@@ -297,7 +272,6 @@ sfi_util_file_list_read (gint fd)
{
guint old_size = upper_power2 (flist.n_entries);
guint new_size = upper_power2 (++flist.n_entries);
-
if (new_size >= old_size)
flist.entries = g_renew (SfiUtilFileEntry, flist.entries, new_size);
entry = flist.entries + flist.n_entries - 1;
@@ -309,7 +283,6 @@ sfi_util_file_list_read (gint fd)
{
guint old_size = upper_power2 (entry->n_fields);
guint new_size = upper_power2 (++entry->n_fields);
-
if (new_size >= old_size)
entry->fields = g_renew (gchar*, entry->fields, entry->n_fields);
entry->fields[entry->n_fields - 1] = g_strdup (scanner->value.v_string);
@@ -325,10 +298,8 @@ sfi_util_file_list_read (gint fd)
}
g_scanner_destroy (scanner);
g_free (cset_identifier);
-
return g_memdup (&flist, sizeof (flist));
}
-
SfiUtilFileList*
sfi_util_file_list_read_simple (const gchar *file_name,
guint n_formats,
@@ -338,10 +309,8 @@ sfi_util_file_list_read_simple (const gchar *file_name,
gchar *s;
guint i;
gint fd;
-
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (n_formats < 1000, NULL);
-
fd = open (file_name, O_RDONLY);
if (fd < 0)
return NULL;
@@ -349,7 +318,6 @@ sfi_util_file_list_read_simple (const gchar *file_name,
close (fd);
if (!flist)
return NULL;
-
flist->n_formats = n_formats;
flist->formats = g_new (gchar*, flist->n_formats);
s = g_new (gchar, flist->n_formats * 4);
@@ -368,7 +336,6 @@ sfi_util_file_list_read_simple (const gchar *file_name,
for (i = 0; s && *s && i < flist->n_formats; i++)
{
gchar *next = strchr (s, ':');
-
if (next)
*next++ = 0;
flist->formats[i] = s;
@@ -376,15 +343,12 @@ sfi_util_file_list_read_simple (const gchar *file_name,
}
return flist;
}
-
-
/* --- formatted field extraction --- */
static gdouble
str2num (const gchar *str,
guint nth)
{
gchar *num_any = ".0123456789", *num_first = num_any + 1;
-
while (nth--)
{
/* skip number */
@@ -402,7 +366,6 @@ str2num (const gchar *str,
return atof (str);
return BSE_DOUBLE_NAN;
}
-
const gchar*
sfi_util_file_entry_get_field (SfiUtilFileEntry *entry,
const gchar **format_p)
@@ -410,7 +373,6 @@ sfi_util_file_entry_get_field (SfiUtilFileEntry *entry,
const gchar *format = *format_p;
gchar *field, *ep = NULL;
glong fnum;
-
*format_p = NULL;
if (*format == '#')
return format + 1;
@@ -422,14 +384,12 @@ sfi_util_file_entry_get_field (SfiUtilFileEntry *entry,
*format_p = ep;
return field;
}
-
gchar*
sfi_util_file_entry_get_string (SfiUtilFileEntry *entry,
const gchar *format,
const gchar *dflt)
{
const gchar *field;
-
field = sfi_util_file_entry_get_field (entry, &format);
if (!field)
return g_strdup (dflt);
@@ -437,7 +397,6 @@ sfi_util_file_entry_get_string (SfiUtilFileEntry *entry,
sfi_error ("Invalid chunk format given: ...%s", format);
return g_strdup (field);
}
-
gdouble
sfi_util_file_entry_get_num (SfiUtilFileEntry *entry,
const gchar *format,
@@ -446,7 +405,6 @@ sfi_util_file_entry_get_num (SfiUtilFileEntry *entry,
const gchar *field = sfi_util_file_entry_get_field (entry, &format);
gchar *base, *ep = NULL;
gdouble d = dflt;
-
if (!field)
return d;
if (format)
@@ -479,7 +437,6 @@ sfi_util_file_entry_get_num (SfiUtilFileEntry *entry,
d = str2num (field, 0);
return d;
}
-
gdouble
sfi_arguments_extract_num (const gchar *string,
const gchar *format,
@@ -488,7 +445,6 @@ sfi_arguments_extract_num (const gchar *string,
{
gchar *base, *ep = NULL;
gdouble d = dflt;
-
if (!string)
return d;
if (format)
@@ -536,7 +492,6 @@ sfi_arguments_extract_num (const gchar *string,
*counter += 1;
return d;
}
-
gboolean
sfi_arguments_read_num (const gchar **option,
gdouble *num)
@@ -544,7 +499,6 @@ sfi_arguments_read_num (const gchar **option,
const gchar *opt, *spaces = " \t\n";
gchar *p = NULL;
gdouble d;
-
if (!option)
return FALSE;
if (!*option)
@@ -584,7 +538,6 @@ sfi_arguments_read_num (const gchar **option,
*num = d;
return TRUE; /* any, valid */
}
-
guint
sfi_arguments_read_all_nums (const gchar *option,
gdouble *first,
@@ -593,7 +546,6 @@ sfi_arguments_read_all_nums (const gchar *option,
va_list args;
gdouble *d;
guint n = 0;
-
va_start (args, first);
d = first;
while (d)
diff --git a/tools/sfiutils.hh b/tools/sfiutils.hh
index b940009..d2440de 100644
--- a/tools/sfiutils.hh
+++ b/tools/sfiutils.hh
@@ -1,20 +1,16 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __SFI_UTILS_H__
#define __SFI_UTILS_H__
-
#include <math.h>
#include <bse/gsldefs.hh>
#include <sfi/sfi.hh>
-
G_BEGIN_DECLS
-
typedef struct
{
guint line_number;
guint n_fields;
gchar **fields;
} SfiUtilFileEntry;
-
typedef struct
{
guint n_entries;
@@ -23,7 +19,6 @@ typedef struct
gchar **formats;
gpointer free1, free2;
} SfiUtilFileList;
-
/* value extraction from formats:
* # <something> -> value is <something>
* <num> -> value is <num> word of line
@@ -43,11 +38,8 @@ gchar* sfi_util_file_entry_get_string (SfiUtilFileEntry *entry,
gdouble sfi_util_file_entry_get_num (SfiUtilFileEntry *line,
const gchar *format,
gdouble dflt);
-
-
gchar* sfi_util_file_name_subst_ext (const gchar *file_name,
const gchar *new_extension);
-
typedef struct {
gchar short_opt;
gchar *long_opt;
@@ -64,7 +56,6 @@ SfiRing* sfi_arguments_parse_list (gint *argc_p,
const SfiArgument *options);
void sfi_arguments_collapse (gint *argc_p,
gchar ***argv_p);
-
/* format for value extraction:
* # <something> -> string is <something>
* n <nth> -> <nth> number found in string
@@ -81,7 +72,5 @@ gboolean sfi_arguments_read_num (const gchar **option,
guint sfi_arguments_read_all_nums (const gchar *option,
gdouble *first,
...) G_GNUC_NULL_TERMINATED;
-
G_END_DECLS
-
#endif /* __SFI_UTILS_H__ */
diff --git a/topconfig.h b/topconfig.h
index 87f9fd2..7de5e05 100644
--- a/topconfig.h
+++ b/topconfig.h
@@ -1,6 +1,4 @@
-
/* generated by configure.in */
#include "configure.h"
-
/* generated by Makefile.am */
#include "data/config-paths.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]