{"id":93,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=93"},"modified":"2015-07-19T08:20:40","modified_gmt":"2015-07-19T15:20:40","slug":"android-native-audio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/native-audio\/","title":{"rendered":"Debugging the native-audio project with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to build and debug the <strong> Native-activity<\/strong> sample provided with Android NDK.<\/p>\n<p>Before you begin, please install <a href=\"\/download\"> VisualGDB 2.0<\/a> or later (ensure that &#8220;Android Edition&#8221; is checked in the installer). If you are not familiar with VisualGDB, please first go through the <a href=\"\/tutorials\/android\">Android Quickstart tutorial<\/a>.<\/p>\n<ol>\n<li>Start Visual Studio. Select File-&gt;New project-&gt;VisualGDB-&gt;Android Project Wizard.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/01-newprj.png\" alt=\"01-newprj\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>Specify the path for the new project and an arbitrary project name (e.g. <strong>NativeAudioTest<\/strong>) and press OK.<\/li>\n<li>In VisualGDB wizard select <strong>Clone a Sample from NDK<\/strong>.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/02-clone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/02-clone.png\" alt=\"02-clone\" width=\"699\" height=\"616\" \/><\/a><\/li>\n<li>On the next page select <strong>native-audio<\/strong> from the sample list.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/03-native-audio.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/03-native-audio.png\" alt=\"03-native-audio\" width=\"700\" height=\"543\" \/><\/a><\/li>\n<li>On the last wizard page select a platform that supports Native Audio API (e.g. Android 2.3.3).<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/04-platform.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/04-platform.png\" alt=\"04-platform\" width=\"700\" height=\"543\" \/><\/a><\/li>\n<li>Press <strong>Finish<\/strong> to create the project. Build it by selecting <strong>Build-&gt;Build Solution<\/strong>.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/05-assert.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/05-assert.png\" alt=\"05-assert\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>If you see build errors related to <strong> bqRecorderBufferQueue<\/strong> variable, double-click at the error message in Error list so that Visual Studio will navigate to the problem. Then comment out the line causing it. Build the solution again.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/06-builddone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/06-builddone.png\" alt=\"06-builddone\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>If you want to use a physical device, <a href=\"http:\/\/visualgdb.com\/tutorials\/android\/native-audio\/..\/usbdebug\">prepare it for debugging<\/a> and connect it. If you want to use Android Emulator, select <strong>Android-&gt;AVD Manager<\/strong> in Visual Studio. When the AVD Manager opens, create a virtual device based on Android 2.3.3 or later and start it. Wait till the device starts up completely.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/07-avd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/07-avd.png\" alt=\"07-avd\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>To test debugging functionality, we&#8217;ll set\u00a0 a<br \/>\nbreakpoint inside the function selecting a buffer to play<br \/>\nwith native audio API (<strong>Java_com_example_nativeaudio_NativeAudio_selectClip()<\/strong> ). Please put the breakpoint after the line with the CLIP_HELLO comment. Then select <strong>Android-&gt;Debug Android App<\/strong>.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/08-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/08-bkpt.png\" alt=\"08-bkpt\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>If you are using the emulator, installing the APK file and loading it might take some time. Wait until the &#8220;Debug Initializing&#8221; window disappears.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/09-start.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/09-start.png\" alt=\"09-start\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>Go to Android emulator and press the &#8220;Hello&#8221; button in the app.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/10-hello.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/10-hello.png\" alt=\"10-hello\" width=\"646\" height=\"605\" \/><\/a><\/li>\n<li>The breakpoint will trigger. Normally, this should result in playing the &#8220;hello&#8221; sample. However, we&#8217;ll test the debugger by forcing it to play the sawtooth sample instead. Right-click at the line with the <strong> CLIP_SAWTOOTH<\/strong> comment and select <strong>Set Next Statement<\/strong>.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/11-setnext.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/11-setnext.png\" alt=\"11-setnext\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>Notice that your the line selecting <strong> sawtoothBuffer<\/strong> became active.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/12-jump.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-audio\/12-jump.png\" alt=\"12-jump\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>Press F5 to continue running the program. The emulator will play the sawtooth sample.<\/li>\n<li>To finish debugging, press Shift+F5.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to build and debug the Native-activity sample provided with Android NDK. Before you begin, please install<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87],"tags":[31,45],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/93"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":174,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/93\/revisions\/174"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}