symba (779893), страница 48
Текст из файла (страница 48)
If you stick to two or three active Convert() operations,lack of chunks should not give you problems.MMF is, potentially, another matter. The problem is that each openclient utility normally uses a separate heap with MMF – not just when theyare playing or recording. If you open too many clients, you might hit thechunk limit – even if you just open several clips with different clients anddon’t actually play them! The best solution is to limit the number of clientsthat can be opened concurrently (as suggested above, to two or three) butthere are some scenarios where this is difficult. As an alternative, you cangive the UseSharedHeap() call to the various client utilities – note thatthe CMidiClientUtility is slightly different, as there is an additionalNewL() overload that supplies aUseSharedHeap as a parameter.
Anexample of usage is:player = CMdaAudioPlayerUtility::NewL(*this);player->UseSharedHeap();player->OpenFileL(iFileName);The key thing to watch is that UseSharedHeap() is called beforeyou call OpenFileL() as that is where a new heap is normally created.All the clients concurrently invoked from a given client thread with thissetting use the same heap. By default, if Player1 and Player2 are invokedat the same time, they each have their own heap; assuming a single clientheap, there are three heaps overall. However, if UseSharedHeap() is226BEST PRACTICEClient heapClientthreadPlayer1threadPlayer1heapPlayer2threadPlayer2heapStandard scenarioClient heapClientthreadPlayer1threadSharedheapPlayer2threadUseSharedHeap() scenarioFigure 8.1 Using shared heapscalled in both Player1 and Player2, a single ‘MMF controller heap’ isused for both MMF client utilities – so there are only two heaps overall.This is illustrated in Figure 8.1.In the normal scenario, each player utility has an associated controllerthread and a controller heap, in addition to the thread and heaps ofthe client.
Using UseSharedHeap(), each player still has its ownthread, but they share a heap – although the heap is still separate fromthe client’s heap. This is more useful when many player, recorder orconverter utilities are created and UseSharedHeap() is called on allof them! Nevertheless, it can be useful in some scenarios. As a rule ofthumb, make this call if there are four or more MMF utility clients calledfrom the same program simultaneously.You may be asking, ‘Why not always do this?’ Well there are somedisadvantages to using shared heaps for the controllers.
Some latenciesmay increase, as, although the heaps are thread-safe, it does requiresemaphore waits. Probably the biggest issue is what happens if thecontroller should panic and die abruptly. In the normal scenario, theheap is deleted and the memory is recovered – ‘resource’ links, such ashandles to other servers, to drivers, etc. are recovered by a kernel walkercalled the ‘undertaker’ that looks for and cleans up dead links.In the shared heap scenario, the heap is only deleted when there areno clients left that use it – it is reference-counted by the client code.By implication, this relies on the normal destruction of the controllerto recover memory; where this fails, the associated memory is notimmediately recovered but appears as a memory leak.
A controllerpanicking will fall into this scenario, as would memory leaks in thecontroller code. In general, it is probably only worth using this feature inproblem scenarios.UNDERSTAND THE MULTI-HEAP PROBLEM227Note the problem manifests itself by KErrNoMemory leaves or returns,even when free memory is available. In 99% of cases, KErrNoMemorymeans exactly that, but occasionally it implies lack of virtual memory orother such things, as in this case. If you appear to have memory issuesbut seem to have free memory, this scenario is worth considering.References and ResourcesOnline ResourcesSymbian Developer NetworkSymbian Developer Network (developer.symbian.com) is a good resourcefor accessing the technical and commercial information and resourcesyou need to succeed in the wireless space.
Symbian Developer Networkprovides technical information and news, and gives you access to the toolsand documentation you need for developing on Symbian OS platforms.You can also find discussion and feedback forums, example code andtutorials, a searchable list of FAQs and a developer wiki.The wiki page for this book can be found at developer.symbian.com/multimediabook wikipage. We’ll post additional links that are of interestto multimedia developers working on Symbian OS on the wiki site – dostop by and add your own favorites to the wiki page. We’ll also use thepage to keep an errata list for this book, and to provide additional samplecode, news and useful information.The main Symbian Press site for this book, from which you candownload a full set of sample code, is developer.symbian.com/multimediabook .There is also a good set of multimedia example projects that were delivered with Symbian OS C++ for Mobile Phones, Volume 3 (see the list ofSymbian Press Books).
The sample code is available from that book’s Symbian Press site at developer.symbian.com/main/documentation/books/books files/scmp v3.230REFERENCES AND RESOURCESSymbian OS Developer SitesThese websites are also of interest for those developing mobile multimediaapplications on Symbian OS.Forum Nokia: www.forum.nokia.comThe SDK for working on the S60 platform can be downloaded from ForumNokia, as can the Carbide.c++ IDE, and other tools and utilities.
ForumNokia provides a number of documents on general S60 development,as well as a multimedia documentation section which can be foundat www.forum.nokia.com/main/resources/technologies/multimedia. Adiscussion forum about creating multimedia on S60 can be found atdiscussion.forum.nokia.com/forum.There is also an extensive developer wiki that contains a number ofarticles about the multimedia support on S60, as well as a range of codeexamples.
The wiki can be found at wiki.forum.nokia.com.UIQ Developer Community: developer.uiq.comThe UIQ Developer Community site has many resources invaluable todevelopers creating applications, content and services for UIQ 3 smartphones. There is a wiki version of UIQ 3: The Complete Guide availableat books.uiq.com.
(The book is also available in conventional formfrom the publisher, at eu.wiley.com/WileyCDA/WileyTitle/productCd047069436X.html .)About Symbian, Symbian OS and UI PlatformsCompany overview: www.symbian.com/aboutFast facts: www.symbian.com/about/fastfacts.htmlMOAP user interface for the FOMA 3G network: www.nttdocomo.comS60: www.s60.comUIQ: www.uiq.comStandardsThe Khronos Group: www.khronos.orgMPEG: www.chiariglione.org/mpegJPEG: www.jpeg.orgGIF: www.w3.org/Graphics/GIF/spec-gif89a.txtPNG and MNG: www.libpng.orgRTP: tools.ietf.org/html/rfc3550RTSP: tools.ietf.org/html/rfc2326SIP: tools.ietf.org/html/rfc3261REFERENCES AND RESOURCES231Symbian Press BooksFurther information about Symbian Press books can be found at developer.symbian.com/books .If you are new to C++ development on Symbian OS and wish to findout more about the idioms, toolchain and application framework, werecommend these books to get you started:• Developing Software for Symbian OS 2nd Edition, Babin.
John Wiley& Sons.• Quick Recipes on Symbian OS: Mastering C++ Smartphone Development, Aubert et al. John Wiley & Sons.The following book is a more detailed reference book for creating C++applications on S60 3rd Edition and UIQ 3:• Symbian OS C++ for Mobile Phones, Volume 3, Harrison, Shackmanet al. John Wiley & Sons.These advanced-level books are useful for learning about Symbian OStechnologies and idioms:• The Accredited Symbian Developer Primer, Stichbury and Jacobs.John Wiley & Sons.• Smartphone Operating System Concepts with Symbian OS, Jipping.John Wiley & Sons.• Symbian OS C++ Architecture, Morris. John Wiley & Sons.• Symbian OS Explained, Stichbury.
John Wiley & Sons.• Symbian OS Internals, Sales et al. John Wiley & Sons.• Symbian OS Platform Security, Heath et al. John Wiley & Sons.Index2.5G networks 23D. . . 333G networks 7, 13, 34, 833GP 56, 211–12µ-Law 11A3F 33A920, Motorola 7AAC 11, 56, 107–17,214aCameraHandle 90–3active objects 9–10,108–10, 130–5,200–1, 209–10, 218,223active scheduler 9–10,108–10, 209–10,218, 223Adaptive Multi-Rate (AMR)26–7, 56, 91–3, 221AddDisplayWindowL()65–6, 71–6‘additional’ sounds 138AddMetaDataEntryL()100–1aDecoderUid 147–8, 168ADPCM 124–7aDuration 118–20aFileName 186–9aFrameNumber 148–9aFs& 147–8aImageSubType 147–8aImageType 147–8A-Law 11AllFiles 19–20AllocL() 171–4AMR see AdaptiveMulti-RateaNewMainImageSize186–9animation 182–5aOptions 147–8aOriginalSize 153–7APPARC 210–12AppendDataL() 173–4appending operations, audio126–7, 129AppleiPhone 2iPod 7AppUi::HandleCommandL() 210aPref 84–7, 90, 97, 137–8aPriority 84–7, 90, 97,137–8aReducedSize 153–7ASCII 163aSourceFilename 147–8ASSERT 111–17, 128–35asynchronous operations48–9, 61, 66,110–17, 130–7,175–81, 189–93,200, 209–10ATMs 132aTransformOpt 186–9AU 11audio 2–5, 9–12, 15–34,55–61, 62–5,66–88, 97–100,102–3, 105–39,199–205, 210–27see also DevSound;MultimediaFrameworkAPPARC 210–12appending operations126–7, 129balance 86–7, 122best practice 210–27bit rates 87, 97–8, 102–3channels range 99classes 105–39client APIs 105–39,223–4concurrency policy135–9, 223–4234audio (continued)controllers 97–100,106–7, 216–17duration 118–22, 127enabling audio playback87, 98enabling audio recording98examples 102–3, 108–22file conversions 127–9files 26–7, 106–7,117–29, 133–5,210–11, 221–2gain support 99input/output streams107–17Media Server 9–10, 214MIDI 11–12, 139,215–16, 225–6mixing considerations218playback of audio 9,11–12, 15–16,24–7, 55–61, 62–5,67–88, 106–10,114–22, 129–39,199–205, 210–12,214–16, 220–1player utility 26–7,106–7, 117–22playing named files118–22, 221–2policy server/resourcemanager 136–7position-setting operations119–22, 126–7pre-emptionconsiderations 135–9priority settings 85–7, 97,137–9, 217–18recorder utility 26–7,106–7, 122–7recording of audio 9,11–12, 15–16,23–31, 97–100,106–7, 108–17,122–7, 136–9,199–205, 215–16,220–1INDEXrecording to named files122–6repeated clips 121–2,215–16sample rates 99–100sequence files 133–5sound types 138statistics 4–5stop/pause sequences119–22, 126storage formats 56, 87,107–8, 116–17,124–7, 211–13,219–20, 230streaming 26–7, 106–39,206, 213–14synchronization issues 59tone utility 26–7, 129–35Tuner API 24, 30,197–207types 87, 98variations of input/outputstreamimplementations116–17variations of player utility119–22variations of recorderutility 126–7video 55, 59, 84–7,97–100, 210–12volume 86, 122, 131–5,222Audio Stream APIs 106–7AudioBitRateL() 87, 98AudioChannelsL() 99AudioEnabledL() 87, 98AudioSampleRateL()100aUseSharedHeap 225–6AVI 56, 59–60balance 86–7, 122bar-code readers 54BeginDecodingL()145–6BeginEncode() 176–81BeginScalingL() 190BeginTransformL()186–9best practice 209–27bit rates 83, 87, 94, 97–8,102–3bitmap-based viewfinder45–6bitmaps 28–9, 45–9, 70,141–96, 213, 224see also decoding.