You are on page 1of 25

12/10/2013

David Henningsson A better sounding world

Canonical
AboutCanonical AboutUbuntu Enterpriseservices Engineeringservices Consumerservices
Typetosearch

go

Abettersoundingworld
AuthorArchive
OlderEntries DavidHenningsson

UbuntuTouchaudiostackfor13.10release
August27th,2013byDavidHenningsson Categories:PulseAudio NoComments Upuntilnow,wevebeenusingAndroidsAudioFlingerforplayingbackandrecordingaudio. Startingwithtomorrowsimage,thatisnolongertrue.InsteadweretalkingdirectlyfromPulseAudio toALSA,ortheAndroidaudioHALwhennecessary. Inshort,hereshowPulseAudionowworks: Fornormalplaybackandrecording,PulseAudiotalksdirectlytoalsalib,justasonthedesktop. Fordetectingwhetheraheadphone/headsetispluggedinornot,PulseAudionowhascodefor readingthatfromtheAndroidkernel,throughtheswitchinterface. Fornormalmixersetup,weuseALSAUCMmixerfiles. Forsettingupvoicecalls,wetalktotheAndroidAudioHALthroughaPulseAudiomodule. Thisprovidessomewhatofacompromisebetweenfeaturesandportingeffort:ByusingtheALSA librarywheneverwecan,wecanaccessPulseAudiostimerschedulinganddynamiclatencyfeatures. Havingthestraightestpathpossibleforplayingbackmusicshouldhelpefficiency(andinextension, batterylife).Atleastintheorywehaventactuallydonemeasurements. UsingtheAudioHALforeverythingmixerrelatedwouldhavebeenoptimal,butitturnsoutthatthe audioHAListoosmart:itrefusestosetupthemixer,unlessPCMdataisalsosenttoit,whichis whatwewantedtoavoid.Sothenwehadtosetupthemixermanuallytoo.However,westillcould notavoidusingtheAudioHALaltogether:whenstartingandstoppingvoicecalls,theAudioHAL talkstothemodemandothercomponentsinthekerneltoroutethevoicecallbetweenthemodemand thesoundcard.Henceweendedupwiththiscompromiseapproach. Currentstatus Atthetimeofthiswriting,thisisworkingbestonNexus4.TheGalaxyNexusworksforthemost part,exceptforbug1217072.IintendtoaddNexus7supportshortly.Ifanyonewantstohelptesting Nexus10,letmeknow. Forporters:ifyouneedtodothesame
http://voices.canonical.com/david.henningsson/author/diwic/ 1/25

12/10/2013

David Henningsson A better sounding world

Unfortunately,thismeanssomeadditionalworkforporters,becauseyouneedtowriteUCMmixer files.Whatsworse,UCMislackinggooddocumentation.Forthatreason,Ihesitatedsomewhat beforedecidingtoactuallyuseUCMatall,butitstheclosestwehavetoastandardforsettingup mixersonembeddeddevicesrightnow. ButtogiveyouatwominutecrashcourseinUCMandhowitsusedinUbuntuTouchstartby havingalookin/usr/share/alsa/ucm/apq8064tablasndcard/directory.Youllneedtocreateasimilar directoryforyourdevice.Youllfindtherightdirectorynameifyoulookin/proc/asound/cards. Second,lookatapq8064tablasndcard.conf.RenameandcopyintoyourownUCMdirectory.If youremakingatabletimage(thatcantmakevoicecalls),youcanremovetheVoiceCallpart(and thecorrespondingfile). Third,lookattheHiFifile.Thisiswhereallfunhappens.Noticethedevicenames,whichare hardcodedintotelepathyofonoandneedtomatch:Speaker,EarpieceandHeadphonefor playback,plusHandsetandHeadsetforrecording. Fourth,ifyouneedvoicecalls,alsolookattheVoiceCallfile.Btw,theverbnamesHiFiand VoiceCallalsoneedtomatch.)Thisislargelyempty,becausethemixersetupishandledbythe AudioHAL,butthereisatwistherethattookawhiletogetright:ForPulseAudiosUCMtowork,it needstoopenaPCMdevice.However,atthetimewhereUCMteststhis,thevoicecallisnotyetset up.So,youmightneedtosetupthemixerjustalittle,sothatthePCMcanopen.(Ondesktops,PCM canalwaysopen,regardlessofmixerstate.Thisisnotalwaystrueonembeddeddevices,thatare usingASoC.)ItsabonusifyoucanfindaPCMthatactuallyplaysbackaudio,becausethenyoucan getnotificationsoundswhileonthephone. Andthisconcludesthetwominutecrashcoursehappyporting! (Sidenote:Sorryifthepermalinkorcommentpagesetctothisblogleadsyoutoablankpage. IvereportedthebugtotherelevantteaminCanonical,butatthetimeofthisposting,theyare lookingintoitbuthavenotyetfixedit.) DavidHenningsson

IportedmygametoUbuntu
April14th,2013byDavidHenningsson Categories:Uncategorized 8Comments Ifyoujustwanttoplaythegame,hereswhereyoufindit.Or,inaterminalwindowwrite:
s u d oa d d a p t r e p o s i t o r yp p a : d i w i c / t h e b l o b g a m e s u d oa p t g e tu p d a t e s u d oa p t g e ti n s t a l lt h e b l o b g a m e

ThenjustsearchforblobintheDash. Therestofthisblogpostismostlydirectedtowardsgamedevelopers.

http://voices.canonical.com/david.henningsson/author/diwic/

2/25

12/10/2013

David Henningsson A better sounding world

Backgroundandmotivation TenyearsagoIfinishedagamecalledTheBlobGame.Itwasa2Dplatformstylegame,morecute thanviolent.Mycousinhadmadethegraphics,aleveleditor,andpartofthegameengine.Imade sevenlevels,music,andcompletedthecode.Backthen,Iwasstillworkingforacompanydoing closedsourcesoftwareforWindows,sonaturallythisgamewasaWindowsgame. AwhileagoIdecidedtotrytoportthisgametoUbuntu.Mymainmotivationswere: Toseehoweasy(orhard)itwas,givenmycurrentlevelofexperience.Alsobecausewe currentlyhavesomeundergoingeffortstomakeUbuntuabettergamingplatform,andwhat betterwaytodothat,thantobecomeagamedeveloperyourself? PeoplecomplainthattherearenotenoughgamesavailableinUbuntuIwantedtomakemy smallcontributiontohelpeventhatout. Nostalgiapurposesafterall,mostoftheworkwiththegamewastomakethelevelsandthe artwork,ratherthanactualcode.Allofthiscanbereused,anditwouldbeniceifthisgame couldentertainanewaudience. Overall,theexperiencehasbeengood.Sure,therehasbeensomeworktodoandnewthingstolearn andconquer,buttherehasbeenverylittleoffrustration.Afunsideproject! OneofthestrengthandweaknessesoftheLinuxecosystemisallthechoicesyoucan,andhaveto, make.Whatcomponentsdoyouchoosetobuildyoursoftwareon?Thatcanbebewildering, especiallyifyourenewtoLinuxandunfamiliarwhatcomponentsaresuboptimalforonereasonor another.IwouldthereforeliketotalkyouthroughthechoicesImadeandwhyImadethem.As usual,thesearemyownopinions,notmyemployers. Language:C Togivesomebackground,mycousinandIstartedprogrammingtwentyyearsago.Backthen,my fatherintroducedmetoTurboPascal,whichwasmorepowerfulthantheQBasicthatcamewith DOS5.0.Tenyearslater,IwasusingDelphi(theWindowscontinuationofPascal)atmywork.So thegamewaswritteninDelphi,mixedwithsomehandwrittenassemblycode(!). Wasitpossibletoreusethecodewritten?Ilookedattheavailablecompilers: GNUPascal.Thisprojectseemsmostlyabandoned,sonotastablechoiceforthefuture. FreePascal.Thiswasthemainalternative,butithasitsowncodegenerator(notintegratedwith GCCorLLVM),sochancesareitwontkeepupinthefuture.Also,ifyouneedtolinktoa library,chancesareyouhavetotranslateheadersyourself. Sorewritethecode.Inwhatlanguage?MychoicefellonC,forthefollowingreasons: Itisaverypopularlanguage,maybeeventhemostpopularone.Itislikelytobearoundfora longtime,andhavesupportfornewprocessorsandarchitecturesastheycometomarket. Itiscompatiblewitheverything.Infact,itswhateveryotherlanguagetriestobecompatible with(JavahasJNI,PythonhasCextensions,etc).

http://voices.canonical.com/david.henningsson/author/diwic/

3/25

12/10/2013

David Henningsson A better sounding world

with(JavahasJNI,PythonhasCextensions,etc). ItiswhatIuseatwork,soIknowthelanguageverywell.(BothLinuxandPulseAudioare writteninC.) IlikethelowmemoryfootprintandpredictabilityofCyouwantagametorunfluently,the audiotorunatareasonablylowlatency,andsoon.Withtheexceptionofcallingfunctionsyou dontknowabout,youcanalmostseehowquickyourcodeexecutes.Imnotsurehowwell Java,Python,andtheothergarbagecollectinglanguagesdointhisareasomyfearmightbe unfounded,butatleastIknowCdoeswell. Gaminglibrary:libSDL Fortunately,thecrossplatformtoolkitlibSDLisverywellsupportedunderLinux.Ihavealmostonly positiveexperiencesofthislibrary:itseemsverystable.Ithandlesgraphics(windowsetup,fullscreen etc),inputevents(keyboard,mouse,gamepadsjustwork),audio,andmore.Thedocumentationis extensiveandthereareplentyofexamplesoutthere.AndbecauselibSDLisalreadyusedbysomany gamesalready,mostdistributionsmakesurelibSDLworksontheirsoftwareandhardware. WhataboutOpenGL?Well,thisisa2Dgame,soIdontneed3D.ItispossibleIcouldusesome hardwareaccelerationforthescaling(theframeisrenderedin320200,thenupscaledtothescreens resolution),butmyverysimplescalerseemstoperformwellenough.Assuch,therewasnorealneed tobringinadependencyonOpenGL. Musiclibrary:FluidSynth FirstImamorethanabitbiasedonthisdependency,asImoneoftheFluidSynthdevelopers. However,thereasonIfirstgotinvolvedwithFluidSynthwasthatIwantedtouseitinagame,and neededtofixsomethinginthelibrary FluidSynthisasoftsynthittakesMIDIdataandasoundfont,andgivesyourenderedaudioasa result.Thishasthedrawbackthatyouneedtodownloadasoundfonttoo,andtheonlyoneavailable intheUbuntuarchiveis>100MB.ThegoodthingisthatFluidSynthisveryembeddableintomany differentkindsofapplications,sotakingtheaudiooutput,mixingitwithsoundeffects,andthensend ittothesoundcard(withlibSDL)waseasy.ItisalsoeasytomanipulatetheMIDIinrealtimein thisgameIveusedittopitchdowntheaudiowhenyoudie. GUItoolkitlibrary:glibandGTK3 LetsfirstadmititintheLinuxworldwedonthaveanythingasstableastheWin32APIforcreating windows.Thetwomaincontesters,GTKandQT,arebothrewritteneveryfiveyearsorso.SoifI, tenyearsfromnow,needtorunthisgameagain,chancesarethatIhavetorewritethispart.TheGUI isjustusedinthebeginningthough(tosetupthegame),soitshouldntbetoomuchwork. IchoseGTKoverQTherebecause IhadpreviousexperiencewithGTK QTaddscomplexitiestoyourbuildsystem,asyouneednotonlyaC++compiler,butalsoa specialpreprocessortoturnsomespecialQTconstructsintovalidC++code. Buildsystem:simpleMakefile Inmycase,myapplicationtakesafewsecondstocompile.Forreallysimpleapplicationslikethis one,IfindbuildsystemssuchasautotoolsorCMaketobemoretroublethanwhattheysolve.Inboth cases,youllhavetolearnanadditionallanguagejusttospecifyyourbuilddependencies.(Autotools alsohasafewnuisances,suchasrequiringsomeextrafilestobepresent,andinalluppercase,such asAUTHORSorNEWS.) Forlargerprojects,theymakemoresensethoughastheymighthelpyoucreatelibrariesfordifferent platforms,giveniceerrormessageswhenbuilddependenciescannotbefound,etc. Licensing:LGPL2+CCBYSA
http://voices.canonical.com/david.henningsson/author/diwic/ 4/25

12/10/2013

David Henningsson A better sounding world

Thisisalwaysatrickyandcontroversialsubject,andIdliketoreiteratethatthisalaymansthoughts onthetopicandnothingelse. GPListhestrongestlicensewhenitcomestofreesoftware.Butthatalsomakesitavery incompatiblelicense,itisessentiallyimpossibletolinkGPLcodewitheverythingthatsnot extremelyweak(egBSD)orexplicitlymadetofitwithGPL(egLGPL).Oneexampleofan incompatiblelicenseisMPL1.1thiswasaquitepopularlicenseintheDelphicommunity, andtheincompatibilitywithGPLwasarealpain. ItisnotobviouswheretheboundariesbetweenGPLandnonGPLcodecanbe,causing confusionincourtfromtimetotime.FSFmightoffersomeadviceonhowtointerpretthe licensebuttheyrenotaneutralparty.Inthiscase,IfindtheLGPL,thesecondstrongest license,moreclear. SoLGPL2,LGPL3orLGPL2+?Well,tome,anyatyouroption,anylaterversionclause isoutofthequestionforme,thatsessentiallythesameasgivingyourcodeawaytotheFSF astheycanrelicenseyourcodeanywaytheywish.AndLGPL2isshorterthanLGPL3 becauseLGPL3includesthefullGPL3licensecode,too. LGPL2issuitableforcode,butnotfordata.Somusic,graphicsandlevelsarelicensedunder CCBYSA.Iwasconsideringaddingnoncommercialbuttheborderbetweencommercial andnoncommercialcanbefluid,andmightalsobeaproblemwiththeDFSG,soIskipped thatpart. Update:SeemsIdidntreadcloselyenoughLGPL2hasaGPL2+clause,nowmakingitpossible fortheFSFtorelicensemycodebymakinganewGPLversion. Ialsodownloadednewsoundeffects(whichistheonlypartnotcompletelymadebymyselformy cousin),tomakesuretherewasnolicensingproblemswiththose. GettingitintotheUbuntuSoftwareCenter Unfortunately,thisdoesnotcurrentlyworkforfreeapplications.Whileadaptingmypackagingtofit therequirementswasrelativelystraightforward,andalsowalkingthroughthedialogsforapp submission,whenallthisworkwasdone,Iwasmetbythefollowingmessage:
T h a n ky o uf o rs u b m i t t i n gag r a t i sF r e eS o f t w a r ea p p l i c a t i o nt h r o u g hM y A p p s .A t t h i st i m ew ea r eu n a b l et op r o c e s st h i sr e q u e s t ,a sw ea r ew o r k i n go nt h e i m p l e m e n t a t i o no fan e wa p pu p l o a dp r o c e s s .

Bummer. Apackagingtip Whilewereonthetopicofpackaging,letmejustshareaquicktip.IfyourenewtoDebian packaging(thesystemusedinUbuntu),andjustwanttopackageyourownapp,onethingtothink aboutisthatthepackagingsystemwasdesignedforhavingcodersandpackagersbelongtoseparate organisations.Sothatmeans,thatifyouduringpackagingfindabuginyourcode,youremeantto makeatemporarypatch,sendthatthecoder,whowillthenmakeanotherreleaseofthenonpackaged software,whichyouwillthenpackage.Inpractice,thisisabitheavyweightifyourejustoneperson anddontkeeppackagingandcodeapart,soIusedthefollowingshortcut:


http://voices.canonical.com/david.henningsson/author/diwic/

t a rc j ft h e b l o b g a m e _ 0 . 2 0 1 3 0 2 0 2 . o r i g . t a r . b z 2e x c l u d e = d e b i a nt h e b l o b g a m e -

5/25

12/10/2013

David Henningsson A better sounding world

t a rc j ft h e b l o b g a m e _ 0 . 2 0 1 3 0 2 0 2 . o r i g . t a r . b z 2e x c l u d e = d e b i a nt h e b l o b g a m e 0 . 2 0 1 3 0 2 0 2

Ifyoufixedsomethinginthecodeandwanttoworkonthepackaging,thecommandabovewill createanewcodereleasefromthepackagingsystemspointofview. andfinally,itsfreesoftware! Thismeansyoureallowednotonlydownloadandrunthisgame,butalsolookatthecode,copy pastepartsintoyourowngame(underthetermsoftheLGPL2!)orjustuseforinspiration.Youcan fixabugorafeatureandsendmepatches(orpublishthemodifiedcodeyourself),etc.Enjoy! Update:Someoneaskedmehowtogetthesource,soheresaquickhowto: Ifyouhaveexecutedthelinesinthetopofthisblogpost,justchangeintoasuitabledirectoryand executeaptgetsourcetheblobgame.Beforeyoubuild,youcanusesudoaptgetbuilddep theblobgametoautomaticallyinstallallbuilddependencies.Buildingcanbedonewithdpkg buildpackageb(fromthesourcecodedirectory).Theninstalltheresulting.debpackage(sudo dpkgitheblobgame_version.deb)totest. IfyourenotrunningUbuntu/Debian,youcangetthesourcefromgoingtothePPApage,click Viewpackagedetails,clickoneofthearrowsontheleftsideinthetable,anddownloadthefile endingwithorig.tar.bz2. Disclaimer:Thisdoesnotmeanthatthesourceiswrittenbythebook,withlotsofhelpfulcomments, etc.Thegameengineismostlyaquicktranslationofthecodeasitlookedliketenyearsago,with newgluecodeaddedforinterfacingwiththelibrariesInowdependon. DavidHenningsson

UpcomingchangestotheIntelHDAdrivers
January18th,2013byDavidHenningsson Categories:Uncategorized 25Comments TakashiIwai,theLinuxsoundmaintainer,isabouttomergeapatchsetofabout150patchesinto linuxnext.Thesechanges,inshort,unifythedifferentHDAcodecdrivers. Introductionandbackground First,thebasics:HDAIntelisthecurrentstandardprotocolforaccessingyourbuiltinsoundcard,as wellasHDMI/DisplayPortaudio,andisusedinalmostalldesktopandlaptopcomputerssinceabout 2005.IntheHDAIntelworld,therearecontrollersandcodecs.Thecodecsalsohaveaconfiguration, whichtellswhichpinsofthecodecsthatareconnectedtowhatinputoroutput(thisissetby BIOS/UEFI). Hardwareisverydiverse:TheHDAInteldriversupportsatleast50differentcontrollers,andabout 300differentcodecs.Ontopofthat,everycodecusuallysupportmanydifferentconfigurations. Thecodecscomefrom1012differentvendors,andwithinthesamevendor,itismorelikelythatthe codeclayoutissomewhatlikeothercodecsfromthesamevendor.Asaresult,theHDAcodecdriver issplitupin1012codecdriverfiles,onepervendor.Thesefilesaretosomedegreecopiesofeach other,butalsocontainseveryvendorsspecials. Whatchanges? Takashispatchesaresolvingalongtermmaintenanceproblem:aswewanttoaddnewfeaturesto thekerneldrivers,wewouldpreviouslyhavetodothisoncepercodecwhereaswiththeunification ofcodecdrivers,wewouldjusthavetoaddthiscodeonce.Orpossiblytwice,astheHDMIcodecs willstillhaveitsowncodecdriver.Inaddition,newcodechardwareismorelikelytojustwork,or atleastpartiallywork,withoutexplicitsupportinthekernel.Thepotentialdownside,ofcourse,isthat asyouimprovethedrivertosolvesomeedgecase,youremorelikelytoscrewsomeotheredgecase
http://voices.canonical.com/david.henningsson/author/diwic/ 6/25

12/10/2013

David Henningsson A better sounding world asyouimprovethedrivertosolvesomeedgecase,youremorelikelytoscrewsomeotheredgecase up.

Theresnotmuchofnewfeaturesaddedinthisnew,genericdriveratthispoint.However,ifyou haveanunusualcodecchipvendor,youmightseeminorimprovementsasthesearebroughtupto featureparitywiththemorecommoncodecs. Whendoesitchange? Asusual,youcantknowuntilitsinthere.Takashislatestplanistomakethemovefor3.9forat leastsomeofthecodecs,and3.10fortherestofthem. Update:Someblog,referencingthisone,saidthisfeaturewouldcometoUbuntu13.04.Ubuntu 13.04useskernel3.8,sothisfeaturewontbeinUbuntuuntil13.10. Update2:Asof20130123,thenewcodehasbeenmerged,forallcodecs,forlinuxnext(kernel 3.9)! Regressionsandtesting Judgingfromthedatabaseyoumighthavecontributedtobyyourselfbysubmittingyouralsainfo, thereareabout6000differentmachinesoutthere,andthereisnotenoughmanpowertotestthemall. Soweneedadifferentapproach.Conveniently,Takashihaswrittenanemulatorcalledhdaemuto testthecodecdrivercode,andIveimprovedthatemulatorwithsomescripting,sothathdaemu effectivelybecomesanautomatedtestsuite.Thetestsuiteisstillveryincomplete,butitatleastrunsa fewdifferenttestssuchasfakedplayback,S3,andmanipulatingofvolumecontrols,andchecksif hdaemucrashesorreportsanerror.Andsureenough,whenrunningthistestsuiteoverallthealsa infosinthedatabase,afewregressionswerediscoveredthatIwasabletofix. Sofar,sogood.Ifitwerentforthefactthathardwareoftendoesnotworkexactlyasadvertised.The parseralgorithmforreadingthecodeclayoutandcreatingaworkingkerneldriveroutofit,mustnow takeallcodecsfromallvendorsintoaccount.Theoldvendorspecificparsermighthavedonethings inonewayandthenewparsermightdothingsadifferentway,causingtheaudiotoberouted differently. Asanexample,assumethecodecisbrokeninsuchawaythatitadvertisestwoaudiopaths,butin practiceonlyoneofthepathsactuallyworks.Thenewparsermightthenroutetheaudiodifferently fromtheoldoneandasaresultitwilllooklikeaudioshouldreallywork,intheory.Inpractice, thereisnothingbutsilence.Anotherexamplecouldbethatmaybethenewdriverwillpowerdown differentpartsofthecodecindifferentorderthantheolddriverdid,causingyourspeakerstoclick. HowcanIhelp? Rightnow,whatsneededismoretestingonrealhardware.Takashihascalledfortestingofhishda migratebranchofthesoundunstabletree. IfyourerunningUbuntu,Ihavemadepackagesfor12.04,12.10and13.04justdownload,installit (youmightneedtoinstalldkmsandkernelheaderstoo).Thenrebootandtest.Simplyuninstallthe packageandrebootwhenyouvefinishedtesting. Update:Iwillprobablyclosethecommentssoonduetotheamountofspamcominginthatway. Pleasereportbackespeciallyifyoudidseearegressiontothealsadevelmailinglist.Thanks! Update2:Asthecodeisnowmergedintolinuxnext,pleaseusetheseinstructionstotryitouton Ubuntu.Thanks! DavidHenningsson

UCADay:AppreciationforUbuntuWomen!
November20th,2012byDavidHenningsson Categories:Uncategorized http://voices.canonical.com/david.henningsson/author/diwic/

7/25

12/10/2013

David Henningsson A better sounding world

Categories:Uncategorized 1Comment AspartoftheUbuntuCommunityAppreciationDayinitiative,Idliketowriteanappreciationfor femalesofallagesthatwehavewithinUbuntuandupstreamcommunities,andwhyIdliketo seemoreofthesame.Todothis,Ivetakenthelibertyofgeneralisingabitbasedonmyown personalexperiences. Firstoff,manywomenhaveexcellentcommunicationandconflictresolutionskills.Ienvisionthis couldcometoverygooduse,includingupstream.Yousee,wesoftwaredeveloperscanbereally pickywhichisagoodthing,aslongasthishelpsuspreventbugs.Butwealsotendtosetuprules forourselvesandourprocesses,andweneedacounterweighttothatinordernottobecomerule followingrobots,whichisnofun.Acontroversialpatchcaneasilyleadtoheated,discouraging debatesandsomebodyrunningoff,makingaforkoftheproject,togetherwithhalfofthesquad.Seen fromanUbuntuperspective,bettercommunicationandconflictresolutionskillsmighthelpusto maintainfewerremixesandderivativesbuttheremainingoneswouldbemorepolishedandwork better. Second,amixedcompanyworkingplaceisgoodforeveryone.BeforeworkingatCanonical,Ihad beenworkingatbothofficeswithonlymen,andwithbothmenandwomen.Myexperiencewasthat atthemaleonlyoffice,discussionstendedtobemorematchocoffeebreakchatswereoftenabout sportsorwomen,ifIremembercorrectly.Andevenifbackgroundimagesofwomeninbikiniand jokestowardsthevulgardidntoffendme,Ididntparticularlyenjoyiteither. Atthemixedcompanyworkingplace,discussionsingeneralhadafriendliertone,andincludeda widerareaoftopics.Itwasjustbetter. (Sidenote:whilediscussingthiswithafemalecolleaguealongtimeago,shetoldmeshehadbeen workingatawomenonlyplace,whichwasplaguedbygossipingtotheextentthatshewasafraidto becomeillbecauseonthedayshewouldnotbeatwork,theywouldgossipabouther.Judging fromthat,mixedcompanyislikelygoodforeveryone,notjustmen.) Third,womenknowwhatwomenwant.Or,atleast,areslightlymorelikelytoknow.Softwareis morelikelytogetnewfeatures,bugfixes,packaging,support,advertisingblogpostsandsoon,if therearepeoplewithsufficientskillandinterestinthatparticularsoftware.Whenmorewomenget involvedinsoftwaredevelopment,theendresultwillbemoreusefulforwomen.IfUbuntusever goingtoreach200millionusers:ifitworksgreatfortwiceasmanypeople,thatwouldcertainlyhelp! So,Iwouldliketosaythankyoutoallwomeninvolvedinopensourcecommunities,bothUbuntu andupstream.Thatincludesathankyoufornotquittingwhentimesgetrough. Andfinally,ifImayextendmyappreciationtoaninvitation:youdonthavetobeasfantasticasthe opensourcewomenIvemet,tobecontributingtoUbuntu,Debian,orupstream.Ifyoualreadyhave skills,thathelps,butforthemostpart,youlllearnasyougo.Committorespectingeachotherfirst, andthenyoucanstarthelpingoutwitheverythingfromwritingcodetoorganizingevents.Welcome! Disclaimer:Asusual,thesearemyownviewsratherthanthoseofmyemployer,myfamily,or anyoneelse.Also,justtomakethepointclear,thisisnotscientificresearchanddoesnotclaimthat womenareingeneraldifferentfrommenweallaresomuchdifferentfrom,andsomuchmore than,whatanaveragepersonofthesamegenderwouldbe.Itisjustmythankyoupost,basedon myownpersonalexperiences. [ThankstoLeannOgasawaraforprovidingsomeusefulfeedbackwhenwritingthisblogpost.] DavidHenningsson

Pulseaudioconferencelessthanamonthaway!
October4th,2012byDavidHenningsson Categories:PulseAudio 2Comments

http://voices.canonical.com/david.henningsson/author/diwic/

8/25

12/10/2013

David Henningsson A better sounding world

2Comments ThefirstPulseAudioconferenceisapproachingquickly.Thisisashoutoutforpeoplewhomightbe interested,butmissedthemailinglistannouncement. TheconferencewillbeFriday2ndNovember2012,andcolocatedwithUbuntuDeveloperSummit andLinaroConnect,inBellaCenter,Copenhagen. Thereisnoattendancefee,butyoullneedaUDSorLCregistration(whicharealsofree)tobeable togetintotheconferencearea.(Note:LCmightbethesaferbethereasUDSendsonThursday) Therehadbeenafewtopicsbroughtuponthemailinglist,butwewelcomeanyonewhowouldlike tocontributetoconstructivediscussionsandhelptoshapethefutureofPulseAudio! Ifyouwouldliketoattend,howaboutyouwriteanemailtothepulseaudiodiscussmailinglistwith thetopic(s)youwanttobringup,andmaybeasmallpresentationwithyourbackgroundand interests?Ofcourse,ifyoumostlywanttolisteninratherthanbringyourowntopics,thatsokaytoo! DavidHenningsson

Topfivewrongwaystofixyouraudio
July13th,2012byDavidHenningsson Categories:PulseAudio,Uncategorized 17Comments TheaudiostackinLinux/Ubuntuevolvesovertime.Whatusedtobegoodadviceisnotnecessarily goodadviceanymore.(Thatalsomeans,thatifyouhappentoreadthisblogpostin2019or something,donttrustit!) Herearesomethingsthatpeopletry,andsometimestheyevenfixtheproblem,butareoftenbadin onewayortheother.Oratleast,theyhavesideeffectsoneneedstobeawareof.Sowhilethereare validexceptions,asaruleofthumb,dontdothefollowing:

5.Dontaddyourusertotheaudiogroup
AuserhasaccesstotheaudiocardifthatpersoniseitherloggedinbothVTandGUIlogincounts, butnotSSHlogins,orifthatuserisintheaudiogroup.However,onthelevelofaccesswere talkingabouthere,onlyoneuserhasaccessatatime.Sothetypicalproblemscenariogoeslike: UserHomerhasanaudioissue,andtriestofixitbyaddinghimselftotheaudiogroup.This doesnthelptoresolvetheproblem. Homerdiscovershisaudioismuted,andunmutesit.Happytohavehisaudioissueresolved,he forgetshesstillintheaudiogroup,ordoesntrealiseitleadstoproblems. UserMargecomesandwantstoborrowthecomputer.Homerdoesafastuserswitchingso Margecanlogin. BecauseHomerisintheaudiogroup,hehasstillaccesstotheaudiodevice.Ifsomesoftware, egPulseAudio,hastheaudiodeviceopened,itblocksaccesstoothersoftwaretryingtouseit. NowMargehasanaudioissue! Ivewrittenalongerarticleabouttheaudiogrouphere.Inshort,therearesomeusagesforit, includingthatitisalsothestandardgroupnameforassigningrealtimeprioritieswhenusedtogether withJACK.Butdontleaveauserintheaudiogroupunlessyouhaveagoodreason.

4.Donttrydifferentmodelstrings
AcommonwaytotrytogetHDAIntelsoundcardstoworkistoedit/etc/modprobe.d/alsabase.conf andaddthefollowingline:
o p t i o n ss n d h d a i n t e lm o d e l = [ s o m e t h i n g ]
http://voices.canonical.com/david.henningsson/author/diwic/ 9/25

12/10/2013

o p t i o n ss n d h d a i n t e lm o d e l = [ s o m e t h i n g ]

David Henningsson A better sounding world

where[something]arevaluesyoufindinsomefile.Contrarytoofficialdocumentation,thisisin mostcasesobsolete.Inparticular,avoidmodel=genericthatisalmostguaranteedtogiveyou trouble.Inmanycases,whentryingdifferentmodels,youwillfindthatyoumightfixonethingbut breakanother. Infact,thereisonlyonemodeltotry,andthatismodel=auto.Ifyourmachinehappentobeoneof thosequirkedtouseanoldermodelparser,changingtomodel=autocanimprovethesituation. Insteaddo: ItstillhappensthatBIOS/UEFIassignsthewrongvaluestopinnodes,whichcausesanoutputor inputnottoworkcorrectly.Ifso,Irecommendtryingtotweakthiswithhdajackretask. Insomecases,tryingdifferentmodulescanactuallybeokaysometimes,thesemodelspointto lightweightfixupsinsteadoftheearlier,moreheavyweightcodethatwasusedinpreviouskernels.(In thiscontext,IhavetomentionthatTakashiIwaihasdoneafantasticjobofconvertingtheolder modelstothenewerautoparser.)

3.DontupgradeALSAdriversbyfollowingrandomblogposts
IveseenfartoomanypeoplereportingbugsonLaunchpadwheretheyvebeenfollowingsome randomblogpostthattellsyouhowtoupgradeALSA,andarehavingaudioissuesasaresult.These guidesareofvaryingqualityandoftencomewithoutgooduninstallinstructions,soyouhavenoway torevertincasetheupgradedidnotsolveyourproblem,orbrokesomethingelse. First,somethingnoteverybodyisawareof:95%ofALSAcodeisinthekernel,andfollowsthe kernelsreleasecycle.Thatmeansthatevenif/proc/asound/versionsayssomethingthatwas releasedayearortwoago,dontpanic.Itsthekernelreleasethattellsyouhownewyoursound driversare,soifyouhaveanewkernel,andyouseeanALSAreleasecomingout,youareunlikely togainfromanupgrade. Insteaddo: Insomecaseyoudohaveanoldkernel,andnewersounddriverscanbeworthatry.TheUbuntu AudioDevelopersteamprovidesdailysnapshotdriversforHDAIntelcards.Guideisavailablehere anditalsocomeswithproperuninstallinstructions. Inthepastwehavealsoprovideddriversforothercards,butduetothemaintenancerequiredtokeep thisuptodate,incombinationwiththatthevastmajorityofpeoplesbugsconcernHDAIntel anyway,thissupporthasbeendiscontinued.

2.DontpurgePulseAudio
First,PulseAudioitselfisntperfect,someofthebindingstoPulseAudioarentperfect,andsomeof thedriversarenotperfectinthewayPulseAudiowantstouseiteither.Sotheremightbevalid reasonstotemporarilymoveitoutofyourway,evenifitwouldbebettertoactuallyfixtheproblem andsubmitabugfixpatch(ifyourecapableofdoingso). ButdonttryuninstallingthePulseAudiopackage,asithasfartoomanydependencies. Insteaddo: Ifyoujustneeddirectaccesstoyoursoundcard,youcanrunthepasuspendercommand.Youcan eitherrunpasuspender(inaterminal)tomakePulseAudiostayawayforthedurationofthe application.Orifyouthinkthatssimpler,justrunpasuspenderbash(inaterminal),startyour applicationthroughthemenu/dash/whateveryouprefer,andwhenyouredone,writeexitinthe terminal. IfyouneedtostopthePulseAudioprocesscompletely,executethesecommands:
e c h oa u t o s p a w n = n o>~ / . p u l s e / c l i e n t . c o n f p u l s e a u d i ok

IfyouneedPulseAudiobackagain,remove~/.pulse/client.conf,thentrytostartanapplicationthat usesPulseAudio,anditshouldstartautomatically. Unexpectedsideeffects: http://voices.canonical.com/david.henningsson/author/diwic/


10/25

12/10/2013

David Henningsson A better sounding world

Unexpectedsideeffects: TheGnomesoundsettings,thesoundindicatorandthevolumeup/downkeysrelieson PulseAudio,sotheywontworkwhenPulseAudioisoff. PulseAudiomixesaudio,sothatmeansthatonlyoneapplicationatatimecanoutputaudioif PulseAudioisdisabled(andyouarentusingsomeothersoundserver). SeveralapplicationshavePulseAudiobackends.Someofthemwillneedreconfigurationtouse ALSAdirectly,somewilljustautomaticallyredirectthemselves,andsomewontworkatall. BluetoothaudiomightnotworkwithoutPulseAudio.

1.DontreplaceALSAwithOSS
OSSwasthestandardusedbeforeALSAcamealong.Thesedays,ALSAismuchbetter,bothwhen itcomestohardwaresupport,andwhenitcomestohowmuchsoftwarethatsupportsoutputting soundtoeithersoundsystem.OSSisalsoentirelyunsupported,atleastbyUbuntu.Inaddition,Im notsureexactlyhowtogetbacktoaworkingsystemafteryouvetriedOSS! Insteaddo: IfyouknowyourproblemisinALSA,eitherdriversoruserspace,trytotrackdownand/orfixthe bug,andtalktousaboutit.IfyourerunningUbuntu,fileabugagainstthealsadriverpackage.You canalsocontactthealsadevelmailinglist.Whilewewontguaranteeresponsesduetothehigh volumeofbugs/traffic,weareoftenabletohelpout.

Finalnotes
Note1.HDAIntelcardsarethebuiltinaudioinputsandoutputsonyourmotherboard(atleastifyou boughtyourcomputerafter~2006orso).HDMIandDisplayPortaudioarealsoHDAIntelcards,but theyarecoveredinmoredetailhere. Note2.Ihavehadsomeproblemswithspammerspostingspamcommentstomyblogpost.Idont wanttospendtoomuchtimejustreadingspamandmarkingitassuch,soImightcloseforcomments inarelativelyshortperiod.Sorryfortheinconvenience. DavidHenningsson

Threeaudiobugsthatneedyourhardwareinfo
May22nd,2012byDavidHenningsson Categories:PulseAudio,Uncategorized 3Comments Areyou: Missingspeakersorinternalmicinsoundsettings? SeeingaS/PDIFdeviceshowupforyourUSBdevice? Havingnoorextremelylowsoundfromyourinternalmicrophone? Ifso,Imightneedyourhelptobeabletofixitforyou! InUbuntu12.04andverylikely,otherrecentdistributionreleasesaswellthereareatleastthese threeaudiobugsthatneedmanualquirkingforeverymachine.Thismeansthatyousubmityour hardwareinfointhemetabug,IwilllookinthatinfoforsomeIDnumbersandincludetheminalist ofdevicesforwhichaspecificworkaroundhastobeapplied.Wecantapplytheworkaroundfor everydevice,asthatcouldpotentiallycauseproblemsforotherdevices. SoifyouresufferingfromoneofthebugsImdescribingbelow,Icoulduseyourhelptomakesure theyarefixedforfuturereleasesofUbuntuandALSA/PulseAudio.

Missingspeakersorinternalmicinsoundsettings
http://voices.canonical.com/david.henningsson/author/diwic/ 11/25

12/10/2013

David Henningsson A better sounding world Missingspeakersorinternalmicinsoundsettings

Ifyouresufferingfromoneofthefollowingproblems: 1)Inthesoundsettingsdialog,whenyouplugyourheadphonesintothedesignated3.5mmjack, thereisaHeadphonesdevicecorrectlyshown,butwhenyouunplugit,thereisnoSpeaker deviceshown,eventhoughyouhaveinternalspeakersonyourcomputer. 2)Inthesoundsettingsdialog,whenyouplugyourexternalmicrophoneintothedesignated3.5mm jack,thereisaMicrophone(orsimilar)devicecorrectlyshown,butwhenyouunplugit,thereisno InternalMicdeviceshown,eventhoughyouhaveaninternalmiconyourcomputer. Thenyoumightbesufferingfrombug946232.Pleaselookinthatbugforyourdeviceinthatlist,and ifitisnotthere,trytheworkaroundandifitsworking,addyouralsainfoassuggestedinthebug. Thanks!

S/PDIFdeviceshowingupforyourUSBdevice
IfyouhaveaUSBheadset,oranotherUSBdevicethatdoesnothaveanyS/PDIFoutput,butyet sometimesthereisanextradevicecalledDigitalOutput(S/PDIF)forthatdeviceinSound Preferences.Ifso,yourelikelysufferingfrombug1002952.Atthetimeofthiswritingtherearealso afewdevicesthatareontheirwaytobecomingfixed,ifyouhaveoneofthese,pleasehelpoutwith testingtheproposedrepository.Thereismoreinformationinbug1002952aboutthat.

InvertedInternalMic
Inthiscase,youhaveaninternalmicshowingup,butitseemsnottowork:itseithercompletely silent,oryoucanpossiblypickaverysmallsound,withmuchbackgroundnoise,eventhoughyou havesetgaintomaximum. Thereissomethingyoucouldtry.Installthepavucontrolapplication,startitandgototheInput Devicestab.Unlockthechannels(clickthekeylockicon),thenmutetherightchannelwhilekeeping theleftchannelatthevolumeyouwant. Iftheinternalmicisnowworkingcorrectly,youhaveaninvertedinternalmic,sothatyourright channelcancelsouttheleftone.(Whythehardwareisconstructedthatwayisbeyondme.) ThisseemstobemostcommononAcerAspirelaptops,butIveseenthemonotherlaptopsaswell, andfixingthesearemoreofalongtermprojectastheyarenontrivialkernelpatches.SofarIve createdapatchforThinkpadU300s.Anyway,Iwouldliketotracktheremainingonesinbug 1002978,sopleaseaddyoursystemthereaccordingtotheinstructions. LastbutnotleastthanksinadvanceforhelpingUbuntu,aswellasthegreaterLinuxecosystem(Ill makesurethatthepatchespushedintoUbuntugetsupstreamaswell)! DavidHenningsson

Pages
About

Archives
August2013 April2013 January2013 November 2012 October2012 July2012 May2012 April2012 December 2011 November 2011 September 2011

AudiooverHDMIandDisplayPortinUbuntu12.04
April14th,2012byDavidHenningsson Categories:PulseAudio,Uncategorized 5Comments Ok,forthoseofyouwhojustwantitupandworking,Imincludingaquickstartsectionbeforewe diveintothedetails:

Quickstart
1)IfyouhaveanATI/AMDorNVidiacard,youneedproprietarydrivers. 2)Youneedtoactivateyoursecondaryscreen.ForIntel,thisisdoneintheregularScreensdialog, andonNVidiathisisdoneinthenvidiasettingsdialog.(Ihaventtestedfglrx.) 3)YouneedtoselecttheHDMI/DisplayPortoutputinthesoundsettingsdialog,whichisquickest
http://voices.canonical.com/david.henningsson/author/diwic/

Labels
12/25

12/10/2013

3)YouneedtoselecttheHDMI/DisplayPortoutputinthesoundsettingsdialog,whichisquickest reachablefromthesoundindicator.

David Henningsson A better sounding world

Labels
PulseAudio (8) Uncategorized (8)

Cantweswitchaudiooutputautomatically?
ChoosingwhethertoautomaticallyswitchtoHDMI/DisplayPortessentially,switchingsoundtouse theHDMI/DisplayPortwheneverthatscreenisactivatedisnottrivial.Itisnotobvioustome whethertheuserwantstodothat,ornot.Andinfact,inUbuntu11.10,wedidswitch,butonlyfor somecards.Andwedidnotswitchbackwhenthescreenwasdeactivated.Afteradiscussionwhere differentopinionswerevoiced,Ireachedtheconclusionthatgiventhecurrentpiecesofinfrastructure inplace,thebestoptionwouldbetodisableautomaticHDMI/DisplayPortswitchingforUbuntu 12.04.

Theproblemoffourdevices
Asmentionedinanearlierpost,muchHDMI/DisplayPorthardwarehavephantomoutputs,andthere isnowayweknowwhatoutputsarerealuntilsomethingispluggedin.Withthenewsoundsettings UIinUbuntu12.04,wefinallyhaveagooduserexperienceinthisscenario:Onlytheoutputsthatare actuallypluggedinandpossibletoactivatewillbeshown.

SoundsettingsinUbuntu12.04

Videodrivers
MostofthecodetoactivateHDMI/DisplayPortaudioisinthevideodriver,ratherthantheaudio driver.Therefore,ifthisisnotworking,itismorelikelythattheproblemiswithinthevideodriver. ItisalsonotablethattheopensourcedriverforATI/AMD(calledradeon),hasexperimentalsupport forHDMI/DisplayPortaudio,atleastforsomecards.Itisdisabledbydefault,butyoucanactivateit byaddingradeon.audio=1asakernelbootparameter.

Upstreamingnotes
PulseAudio2.0issoontobereleased(hopefully).PulseAudio2.0andUbuntu12.04havethesame featuresetwhenitcomestoHDMI/DisplayPortaudiosupport. ThenewsoundsettingsUIinUbuntu12.04hasnotyetbeenupstreamed. DavidHenningsson

Audiodebuggingtechniques
December8th,2011byDavidHenningsson Categories:PulseAudio,Uncategorized
http://voices.canonical.com/david.henningsson/author/diwic/ 13/25

12/10/2013

Categories:PulseAudio,Uncategorized 6Comments

David Henningsson A better sounding world

AsapartoftheUbuntuHardwareSummit,Iheldapresentationonthetopicaudiodebugging techniques,focusedonHDAIntelcards.Ialsowrotedownsomenotesforsomeofthoseslides.I sharetheslidesandthenoteswiththehopethatyouwillfindtheinformationusefulifyouruninto troubleswithyouraudiohardware.

Audiostackoverview

Theaudiostackcanseemabitcomplex,butfirstlookatthelineallthewayfromtheapplicationsto thehardware.Thisistheoptimalaudiopath.Iftheaudiopathisdifferent,complexitywillincrease andyoumightrunintoundesiredbehaviour,suchasoneapplicationblockinganotherfromplaying audio.Therearevalidexceptionsthoughwehaveaseparatesoundserverforprofessional,low latencyaudio.Butthatsoutsidethescopeofthispresentation. Letsstartfromthetop.Onthetopwehavedifferentkindsofaudioapplications,whichtalkto PulseAudio.GStreamerisalibrarytohelpmediaplayback,itcanforexampledecodeoggandmp3 files.PulseAudiomixestheseaudiostreamsandsendthemdowntothekernel.TheALSAlibrary andtheALSAkernelcoredonotdomuchherebutsendtheaudiopointersthrough.TheHDA controllerdriverisresponsiblefortalkingdirectlytothehardware,andsoitsetsupallnecessary DMAstreamsbetweentheHDAcontrollerandmemory.TheHDAcontrollerdriveralsotalkstothe HDAcodecdriver,whichisdifferentforeverycodecvendor. Assomeofyouprobablyknow,betweentheHDAcontrollerwhichisapartofthesouthbridgein mostcomputersandtheHDAcodec,aspecialHDAbusisused.Thismeansthattheonlywaywe cantalktothecodecisthroughthecontroller. Controllingaudiovolumegoesthesamepath.Whenyouuseyourvolumecontrolapplication,it controlsPulseAudiosvolume.PulseAudiointurnmodifiesthevolumecontrolsbeingexposedbythe kernel,andthekernelinturntalkstothehardwaretosetvolumecontrolregistersonthecodec.There aretwolevelsofabstractionhere:first,thekernelmightchoosenottoexposeallofthehardwares volumecontrols,andsecond,PulseAudioexposesonlyonebigvolumecontrolwhichisthesumof someofthevolumecontrolsthekernelexposes.Sothereisfilteringontwolevels.
http://voices.canonical.com/david.henningsson/author/diwic/ 14/25

12/10/2013

David Henningsson A better sounding world

Audiostackoverviewcodec

LetushavealookattheHDAcodecchipandhowitsinternalsarerepresentedtothedriver.The codecisconstructedasagraph,andonthisslideoneofthemoresimpleHDAcodecgraphsisshown (justbecauseitwouldfitthescreen).Awhileagoupstreammadeasmallprogramtoextractthis graphfromthecodecandmakeapictureofit.ThankstoKengY,whoworksforCanonicalin Taipei,thistoolisavailableasapackageinUbuntu11.10.Justinstallthecodecgraphpackage. InthisgraphwehavenodescorrespondingstoDACs,ADCs,mixers,andpins.Inthisexamplewe canseewhatpinsareconnectedtowhichDACsbyfollowingthesolidline.Thedottedlineshowsa


http://voices.canonical.com/david.henningsson/author/diwic/ 15/25

12/10/2013

David Henningsson A better sounding world

connectionthatispossiblebutnotcurrentlyactive. AstheLinuxcodecdrivercodegrowsmoreintelligent,wedependmoreandmoreonthis informationtobeaccurate.Thiswaywedonothardcodeasmuchinthedriver,sowecanadaptto futurecodecswithouthavingtorewritemuchcode. Theinformationcomingfromthecodecisusuallycorrect.Oneproblemwehavefromtimetotimeis though,isthatsometimeschipvendorsaddfeatureswhichtheychoosenottodocumentinthisgraph (andnotinanyotherwayeither).Thereisamechanismcalledprocessingcoefficientsinthe specification,wherethevendorcanadditsownfunctionalitywithouttellinganyone.Whenthat happens,anditisrequiredtousetheseundocumentedprocessingcoefficientstoenableallinputs andoutputs,weusuallyrunintodifficultproblemsthatrequirevendorsupporttoresolve. Also,insomecasesthegraphcannotdescribethefunctionalityneeded,egifsomehardwareis dependingonspecialpinsonthecodec.Weneedtoknowaboutthiswhenithappens,sowecan supportitinthedriver.Soifyouareahardwaredesigner,mymessageis:Trytousethestandardway ofdoingthingsasmuchaspossible.DothisanditwillworkoutoftheboxonLinux,andlikelyother operatingsystemsaswell.Ifyoudoanythingspecial,yourecausingheadachefordriverwriters, possiblycausingaslowertimetomarket. Anexampleofthiswouldbehowyoucontrolexternalamplifiers:youcanusetheEAPDpins,which isthestandardway,andyoucanuseGPIOpins,ACPI,oranythingelse,thatwillbemore problematicandrequirespecialdriversupport.

Pinconfigurationdefault

WealsodependoninformationfromthewritersofBIOS/UEFI,iethecomputersfirmware.Asa hardwaredesigner,youhavethefreedomtochoosewhichpinsofthecodecthatgotowhatphysical jack.Youmightdecidethatyouwantadigitalout,oryoudecidethatthismachineshouldnothave thatfunctionality,andthenyouleavethatpinunconnected. Thenthefirmwareengineerneedstoknowthis,andprogramthisintothecodecwhenthecomputer boots.ThisisdonebysettingthePinConfigurationDefaultregister.Thisregistertellsusnotonly thedevicetype(headphone,mic,etc),butalsothelocation(Internal,External,DockingStation),the color,andthechannelmapping(touseforsurroundfunctionality). Severalyearsago,wedidnotreadthisregistermuch,butthesedays,wedependonthatforallnew


http://voices.canonical.com/david.henningsson/author/diwic/ 16/25

12/10/2013

Severalyearsago,wedidnotreadthisregistermuch,butthesedays,wedependonthatforallnew computersforsettingupthecodeccorrectly.Sowhatdowedoifthisregisteriswrong?Well,ifwe workwithhardwareprerelease,theremightbeachancewecanfeedthisinformationbacktothe firmwarewriterssotheycancorrecttheproblem.Ifthehardwareisalreadyreleased,wehaveto createaquirk.Thismeansthatthedriveroverridesthefirmwarespinvalue(s)andinsteadusesits ownvalue. Becausethisvalueissoimportant,Ivewrittenanapplicationwhereyoucantryoutdifferent combinationsofthisregister.

David Henningsson A better sounding world

Mixerproblems

OneofthemostcommonproblemswithgettingaudioupandrunningonLinuxistomakesurethe mixeriscorrect.Typicalsymptomsofthiswouldbethatsomeoutputsareworkingwhereothersare not,orthatthereissomethingwrongwiththevolumecontrol. Herearesomeinitialchecksoftheseproblems.Wedothisatthetwolevelsofmixerabstraction. First,letshavealookatthePulseAudiovolumecontrol.YoucandothatinGnomesvolumecontrol application. Also,PulseAudiocontrolsthevolumeofmixersattheALSAlevel.Youcanseehowthisworksby startingthealsamixerprogram.Inthisprogram,youcanalsoseeadditionalsliders,whichyoucan alsousetoverifythattheyareinthecorrecttoenablesound.Youstartalsamixerfromaterminal(in UbuntuthequickestwaytolaunchaterminalistheCtrlAltTshortcut).

Mixercontrolnames

http://voices.canonical.com/david.henningsson/author/diwic/

17/25

12/10/2013

David Henningsson A better sounding world

Soletslookatthesetwoabstractionlevelsinmoredetailandhowyoucaninspectwhatisactually goingon.First,letslookatthecodeclevel.Ifyouarefamiliarwiththecodecsnodesandhowthey areconnected,egbyrunningcodecgraph,youcanalsofindoutwhichALSAlevelcontrolsthat areconnectedtowhichnodesonthecodec.Thisisdonebyinspectingthecodecprocfile.Every codecinthesystemhasthisfile,anditsnameismadeupofthesoundcardname,andthecodecs addressontheHDAbus.Inthisfile,youcanalsoseealotofotherinformationaboutthecodec. Sonext,wewillalsotakealookatPulseAudiosabstractionofthesecontrols.Thisisdoneby lookingatthefilesin/usr/share/pulseaudio/alsamixer.Inthiscase,ifwelookat /usr/share/pulseaudio/alsamixer/paths/analogoutputheadphones.conf,youcanegfindthesections [ElementMaster]and[ElementHeadphones].ThatmeansthattheALSAlevelcontrolsMasterand HeadphonesarebeingmergedinPulseAudiosvolumecontrolwhentheHeadphonesporthas beenselected. Sothesetwoplacesarethekeystounderstandingwhatisgoingonwhenyouhavemixerproblems.

PCM/Streamingproblems

http://voices.canonical.com/david.henningsson/author/diwic/

18/25

12/10/2013

David Henningsson A better sounding world

Soupnextiswhenyouhaveproblemswiththestreaming.Thatisusuallyshownastheaudiois breakingup,cracklingorglitching.Unfortunatelytheseproblemsaretypicallyquitehardtoresolve. SometimesthiscanbeabuginPulseAudio,orinthedriver.Butmoreoftentheproblemisoneither theapplicationsideorthehardwareside. IfanapplicationisnotsubmittingdatatoPulseAudiointime,thePulseAudiohasnoaudiotoplay back,sothereforeplaybackbreaksup.OncesomemoredatahasreachedPulseAudio,itstarts playbackagain,andsoplaybackisstartedandstoppedrepeatedly. Theotherproblemcouldbewithbadpositionreportsfromthehardware.PulseAudiodependson beingabletoaskthehardwareforitscurrentpositionatalltimes,andthisshouldbesampleaccurate. YoucantestthisbytryingtorunPulseAudiowithtimerschedulingdisabled,inthiscasePulseAudio willrelymoreonDMAinterruptsandlessonpositionreports.However,thiswillalsomake PulseAudiodrawmorepowerthannecessaryfromthemachine,sopleaseavoidthisifyoucan. WhenItrytodebugtheseproblemsIusuallystartwithmakingaPulseAudioverboselog.Itoften takessomeknowledgeandexperiencetobeabletoanalyzethislogthough.

Jacksensing

http://voices.canonical.com/david.henningsson/author/diwic/

19/25

12/10/2013

David Henningsson A better sounding world

Overthelastsixmonthsorso,oneofthethingsIvebeenworkingwithistryingtogetbetterjack detectionhandling,throughouttheaudiostack. Jacksensinginthiscontextmeanswhattodowhensomethinghasbeenpluggedin,orunplugged. Whenthishappens,aninterrupt(IRQ)istriggeredandcontrolispassedtotheHDAcodecdriver. Thedrivertakesthefirstactionitself.Now,thisisanarea,unfortunately,whenthingsdifferalot betweendifferentdrivers,mostlybetweendifferentvendors,butalsobetweendifferentchipsofthe samevendor,orevenbetweenconfigurationsofthesamechip. Butasageneralrule,andforthemostcommonvendorsthatmeansRealtek,IDTandConexant theserulesaretheonesthatarefollowed: Forheadphoneswhenyouplugthemin,theInternalSpeakersaremuted.Remember,thisis stillallatthekernellevel. ForwhatweredoingwithLineOutsitsnotcompletelystandardisedeverywhereyet,butit seemsupstreamisleaningonhavingHeadphonesmuteLineOutsandhavingLineOutsmute InternalSpeakersbydefault.Somedriversalsohaveaspecialcontrolwheretheautomute behaviourcanbechanged. ForMicrophonestheonlyrulehereisthatifwehaveonlyoneinternalmicrophoneandone externalmicrophone,theexternalmicrophonetakesoverwhenyouplugitin,andtheinternal microphoneregainscontrolwhenyouunplug.Shouldtherebeanyotherinputs,egtwo externalmicjacks,oralineinjack,noautoswitchingisdoneatthekernellevel. Afterthishasbeendone,asignalissenttouserspace.Hopefullythisalsovariesbetweenvendors. Wellgetbacktothat.WhatsnewinUbuntu11.10,isthatthissignalisbeingpickedupby PulseAudio.Thisisimportant,becauseitenablesPulseAudio,toswitchportforvolumecontrol.So thismeans,whenyoupressyourmediakeys(orusethesoundmenu)tocontrolyourvolume,you controlyourheadphonesvolumewhenyouhaveheadphonespluggedin,andyourspeakersvolume whenyourheadphonesareunplugged. Sothisnotworkingproperly,isoneofthemorecommonproblems.Ihavewrittenasmalltoolthat helpsyoutodebugwhetherthisissueisinhardwareorsoftware.Thistooliscalledhdajacksense test.Thisprogramsendsthegetpinsensecommandtoeachcodecandoutputstheresults.I actuallyhaduseforitearlierthisweek,andconfirmedthatitwasahardwareissue:althoughthe headphoneswereunplugged,thegetpinsensecommandreturnedthattheheadphoneswerebeing pluggedinandunpluggedallthetime. Ifyoucanconfirmthatthingsareworkingatthislevel,youcanalsolookinSoundsettingstoseeif theport(thisisknownasaconnector)isautomaticallyswitchedwheneverheadphonesor microphoneispluggedin.Ifitisnot,themostcommoncauseisthatkerneldriverdoesnotnotify userspacecorrectlyaboutthatchange.

HDMI/DisplayPortAudio

http://voices.canonical.com/david.henningsson/author/diwic/

20/25

12/10/2013

David Henningsson A better sounding world

OneofthemostcommonproblemwithHDMIthesedaysarewithnewerchipssupportingmorethan oneoutput.TheseoutputscouldbeHDMI,DisplayPortorDVI(withaudiosupportedthroughaDVI toHDMIadapter).NVidiahassupportedfouroutputsforquitesometimeandIntelhassupported three.Butusually,notalloftheseareactuallyconnectedontheboard. Now,theproblemis:Howdoweknowwhatpintooutputto?Andtheansweris,thatthereisno goodwaytofigurethatoutuntilsomethingisactuallypluggedin. Ifyouremembermetalkingaboutthepinconfigdefaultearlier,youwouldsaythatmaybethe graphicschipcouldmarkthepinsnotconnectedtoanything.Ifthiswasdone,itwouldbeagreatstart (andiftheyare,wemakeuseofittohidetheoutputsthataremarkedasnotconnected),but unfortunately,moreoftenthannot,thesepinsaresetupasallpinsconnectedandpresent.Soifyou writefirmwareforinternalorexternalgraphicscards,pleasedosetupthesepins. Soifwedontknow,whatdowedo?Well,heresalsoworkinprogressattheuserspacelevel.First, PulseAudiohastoprobehowmanyportsthereare.Thenwecanusethenewjackdetectionfeature, todeterminewhathasactuallybeenpluggedin.Imcurrentlyworkingonredesigningthesound settingsdialogsothattheportsthatarenotpluggedinwillbeactuallyhiddenfromthedialog,andI hopethiswilllandinUbuntu12.04whichwillbereleasedinAprilnextyear. Andafinalnote,justsoyoudontforgetit:ForNVidiaandATI,theybothrequireproprietaryvideo driverstoenableHDMIandDisplayPortaudio.TheATIdriverusedtohavesupportforsomeofthe cardsinitsopensourcedriver,butthisfeaturewasrecentlyremovedbecausetheyhadsomeproblems withit. Intelhasnoproprietarydriversatall,sothereitworkswiththestandardopensourcedriver.

http://voices.canonical.com/david.henningsson/author/diwic/

21/25

12/10/2013

David Henningsson A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/

22/25

12/10/2013

David Henningsson A better sounding world

DavidHenningsson

Turnyourmicjackintoaheadphonejack!
November29th,2011byDavidHenningsson Categories:Uncategorized 18Comments Mostoftodaysbuiltinsoundcardsaretosomedegreeretaskable,whichmeansthattheycanbe usedformorethanonething.ThatmeansyoucanturnyourMicjackintoanextraHeadphonejack, orwhynotmakethembothlineouts,andconnectthemtoyoursurroundreceiver? Iveknownforawhilethatthekernelexposesaninterfacethatmakesitpossibletoretaskyourjacks, butalmostnooneseemstouseit,orevenknowaboutit.SooverthepastfewweeksIvebeen working(fromtimetotime)withHDAJackRetask,asmallapplicationthatmakesthisinterfaceeasy touse. Althoughprimarilymeantforpowerusers,itfocusesonsimplicity:Justselectyourcodec,thenselect whichpinsyouwanttooverrideandwhatyouwantthemtooverrideto:Headphones,LineOut,Mic, LineIn,andsoon.Therearebuttonsfortryingitoutrightaway,andformakingyouroverridethe boottimedefault.Andofcourse,abuttonforremovingalloverridesincasethingsdidnotgoas planned. Consideritbetaqualityfornow,anditsoneofthosewontworkforeveryoneprograms,butthats mostlyduetohardwareanddriverlimitations. ItsavailableforUbuntu11.10,andyoucaninstallitbyaddingppa:diwic/hdaandtheninstallingthe hdajackretaskpackage.Startitbyrunninghdajackretaskinaterminal.Enjoy!

http://voices.canonical.com/david.henningsson/author/diwic/

23/25

12/10/2013

David Henningsson A better sounding world

OlderEntries AboutCanonical Whatwedo Canonicalandopensource Careers Partnerships Newsandevents Contact AboutUbuntu Ubuntuforbusiness Ubuntuforyou Ubuntuandeducation Casestudies Enterpriseservices UbuntuAdvantage Training Consultancy Engineeringservices OEMservices Certification Coreengineering Consumerservices UbuntuOne Support Training

http://voices.canonical.com/david.henningsson/author/diwic/

24/25

12/10/2013

David Henningsson A better sounding world

Furtherinformation Newsandevents Careers Legal Newsfeed 2010CanonicalLtd.UbuntuandCanonicalareregisteredtrademarksofCanonicalLtd.

http://voices.canonical.com/david.henningsson/author/diwic/

25/25

You might also like