Add support boot sound c++ - MTCB Android Head Units Q&A

Hi all
I build module for play audio on bootanimation starting and i test the sound very be late while start show launcher the sound work , this problem on mtc only i test this module on another devices like samsung working fine
the code:
Code:
#include <media/AudioSystem.h>
#include <media/mediaplayer.h>
#include <binder/ProcessState.h>
using namespace android;
int main ()
{
ProcessState::self()->startThreadPool();
audio_devices_t device = AudioSystem::getDevicesForStream(AUDIO_STREAM_SYSTEM);
AudioSystem::initStreamVolume(AUDIO_STREAM_SYSTEM,0,5);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_SYSTEM,5,device);
sp<MediaPlayer> mp = new MediaPlayer();
mp->setDataSource("/system/media/boot.ogg",NULL);
mp->setLooping(false);
mp->setAudioStreamType(AUDIO_STREAM_SYSTEM);
mp->setVolume(5,5);
mp->prepare();
mp->start();
while (mp->isPlaying()) {
sleep(2);
}
mp->disconnect();
return 0;
}
and in init.rc
Code:
service bootsound /system/bin/bootsound
class main
user media
oneshot
also the stock bootanimation play audio the path is (/system/media/audio/boot.ogg) but not working
any idea dor solveing this problem..

Related

[DEV] Compiling mplayer

Hi @all,
i want to compile the mplayer for Android.
The only "How-To" i found is this.
Maybe someone with more experience in cross-compiling can give me some more hint.
thanks
peter
Take a look at that, can probaly be helpful
http://forum.xda-developers.com/showthread.php?t=431329
compile finished
@mopodo
thanks, i think i have done
sandmen said:
@mopodo
thanks, i think i have done
Click to expand...
Click to collapse
Did you get it to run?
mplayer run's.
But i have some trouble to set VSCREENINFO.
Maybe wrong video fromat.
So I have to check some different video's.
what about audio? looking at some posts in the MPLAYER discussion VSCREENINFO issues appear to be something to do with framebuffer of the kernel.
I've been trying to get audio working, although in a Magic 32B, but I have failed so far.
Do you Hero owners see /dev/dsp or /dev/snd0 ?
Do you get any audio at all? If so, using what device?
From the very limited information I've managed to get so far, Dream owners do get sound, though I have no idea how and why.
I've used the how-to mentioned in the first post, no success so far.
Perhaps this helps: read-write access for /dev/msm_pcm_out
So chmod this device file and use it as audio out?
I'm actually curious about how a native linux app would render video on android. There is no X so framebuffer would be the only way. But then, how do you get user in/output?
status mplayer crosscompilation
@all
follow things i have tryed:
- Crosscompiling svn-version mplayer, there i have some segmentation fault's.
doesn't work
- Crosscompiling Mplayer1.02 (old version) there i have trouble to set VSCREENINFO.
So it takes time
If anybody have some hints, about crosscompiling, feel free.
sandmen said:
@all
follow things i have tryed:
- Crosscompiling svn-version mplayer, there i have some segmentation fault's.
doesn't work
- Crosscompiling Mplayer1.02 (old version) there i have trouble to set VSCREENINFO.
So it takes time
If anybody have some hints, about crosscompiling, feel free.
Click to expand...
Click to collapse
I managed to compile a working (by working I mean no segfault ) version of SVN-r29796 with the following config:
./configure --enable-fbdev --host-cc=gcc --target=arm --cc=arm-none-linux-gnueabi-gcc --as=arm-none-linux-gnueabi --ar=arm-none-linux-gnueabi-ar --ranlib=arm-none-linux-gnueabi-ranlib --enable-static
The resulting binary can be found here:
http://www.megaupload.com/?d=142QK29B
Together we can solve this, sandmen
What we need now is a Dream user to confirm that audio works on that hardware...
@Djhg2000
you can play a video without sound?
sandmen said:
@Djhg2000
you can play a video without sound?
Click to expand...
Click to collapse
No, I get the VSCREENINFO error. It does decode video though if I use "-vo null -ao null", but what probably won't get us anywhere...
I've heard the VSCREENINFO problem is a kernel bug, can anyone confirm this?
I don't have the time to look into it now, but maybe we can make a patch to workaround the problem?
Edit:
It seems like this piece of code in libvo/vo_fbdev.c is causing the problem:
Code:
if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
mp_msg(MSGT_VO, MSGL_ERR, "Can't get VSCREENINFO: %s\n", strerror(errno));
goto err_out;
}
These lines can be found at 685-688 in r29796.
The problem is that my C skills are very limited and I have no idea what "&fb_vinfo" should be... C coders please help?
Typing "ioctl FBIOGET_VSCREENINFO" returns "ioctl: too few arguments".
Typing "ioctl FBIOGET_VSCREENINFO 0" returns "cannot open FBIOGET_VSCREENINFO"
From the information I can gather, ioctl seems to be a tool to pass instructions directly to drivers?
Yeah, it finally seems like we're getting somewhere
us1111 said:
Perhaps this helps: read-write access for /dev/msm_pcm_out
So chmod this device file and use it as audio out?
I'm actually curious about how a native linux app would render video on android. There is no X so framebuffer would be the only way. But then, how do you get user in/output?
Click to expand...
Click to collapse
I've tried this, "-ao oss:/dev/msm_pcm_out" gives "Can't set audio device /dev/msm_pcm_out to s16le output, trying s16le...".
"-ao pcm:file=/dev/msm_pcm_out" hangs MPlayer at the "Starting playback..." message.
"-ao pcm:file=/dev/msm_pcm_out -v" hangs MPlayer with the line "Increasing filtered audio buffer size from 0 to 65536".
So yes, it might be the right device, but I can't get it to work.
Perhaps you could download the binary and see if you get different results on a Hero?
@Djhg2000
Did you get the "get VSCREENINFO" error or the "put VSCREENINFO"
sandmen said:
@Djhg2000
Did you get the "get VSCREENINFO" error or the "put VSCREENINFO"
Click to expand...
Click to collapse
Wow, do I feel stupid
Of course it's the put VSCREEN error, here is the correct code from libvo/vo_fbdev.c:
Code:
if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
mp_msg(MSGT_VO, MSGL_ERR, "Can't put VSCREENINFO: %s\n", strerror(errno));
if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) {
mp_msg(MSGT_VO, MSGL_ERR, "Can't restore text mode: %s\n", strerror(errno));
}
return 1;
}
This is at lines 814-820 in r29796.
It seems like the problem mostly remains the same.
However, I can't debug it properly (yet!) due to my lack of skills in C .
I'm making slow progress in understanding the real problem, but at least I'm learning some C while I'm doing it
Edit:
I've looked through the sources and I just can't figure it out:
Code:
static struct fb_var_screeninfo fb_vinfo;
means that fb_vinfo should look like fb_var_screeninfo, right?
But fb_var_screeninfo itself (defined in linux/fb.h) looks like this (copied directly form android kernel git tree):
Code:
struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
__u32 xres_virtual; /* virtual resolution */
__u32 yres_virtual;
__u32 xoffset; /* offset from virtual to visible */
__u32 yoffset; /* resolution */
__u32 bits_per_pixel; /* guess what */
__u32 grayscale; /* != 0 Graylevels instead of colors */
struct fb_bitfield red; /* bitfield in fb mem if true color, */
struct fb_bitfield green; /* else only length is significant */
struct fb_bitfield blue;
struct fb_bitfield transp; /* transparency */
__u32 nonstd; /* != 0 Non standard pixel format */
__u32 activate; /* see FB_ACTIVATE_* */
__u32 height; /* height of picture in mm */
__u32 width; /* width of picture in mm */
__u32 accel_flags; /* (OBSOLETE) see fb_info.flags */
/* Timing: All values in pixclocks, except pixclock (of course) */
__u32 pixclock; /* pixel clock in ps (pico seconds) */
__u32 left_margin; /* time from sync to picture */
__u32 right_margin; /* time from picture to sync */
__u32 upper_margin; /* time from sync to picture */
__u32 lower_margin;
__u32 hsync_len; /* length of horizontal sync */
__u32 vsync_len; /* length of vertical sync */
__u32 sync; /* see FB_SYNC_* */
__u32 vmode; /* see FB_VMODE_* */
__u32 rotate; /* angle we rotate counter clockwise */
__u32 reserved[5]; /* Reserved for future compatibility */
};
Which is identical to the same struct in Ubuntu's kernel tree?
My conclusion so far is that one of these parameters are unsupported by the HTC Magic's graphics driver, but not the HTC Dream graphics driver?
I have no idea why the driver would even differ between them; they both use the same graphics chip, don't they?
Djhg2000 said:
I've tried this, "-ao oss:/dev/msm_pcm_out" gives "Can't set audio device /dev/msm_pcm_out to s16le output, trying s16le...".
"-ao pcm:file=/dev/msm_pcm_out" hangs MPlayer at the "Starting playback..." message.
"-ao pcm:file=/dev/msm_pcm_out -v" hangs MPlayer with the line "Increasing filtered audio buffer size from 0 to 65536".
So yes, it might be the right device, but I can't get it to work.
Perhaps you could download the binary and see if you get different results on a Hero?
Click to expand...
Click to collapse
I assume you have root ?
try
chmod o+rw /dev/msm_pcm_out
Jesterz said:
I assume you have root ?
try
chmod o+rw /dev/msm_pcm_out
Click to expand...
Click to collapse
Already tried that, I usually use root when debugging inside of Android, but not even "chmod 777 /dev/msm_pcm_out" helps.
I noticed there might be some relevant libraries in android:
/lib//libaudio.so
/lib/libhardware.so
/lib/libhtc_acoustics.so
/lib/libmedia.so
/lib/libmm-adspsvc.so
/lib/libopencore_player.so
/lib/libsoundpool.so
/lib/bluez-plugin/audio.so
Surely at least one of these libraries can provide a way to output audio?
Except maybe that bluez thing
I want to be a beta tester. My device is HTC Dream (g1).
1: pcm is the way to go. If you run mplayer -ao help, does it list pcm?
2: you can try compiling mplayer along with support for a sound server like pulseaudio, which would mean that you would need to add that package too...
Krasimir said:
I want to be a beta tester. My device is HTC Dream (g1).
Click to expand...
Click to collapse
Great, finally a Dream user (maybe thread should be moved to the Dream Development sub forum, as that's where people look for general android discussions).
Anyway, it's publicly available here:
http://www.megaupload.com/?d=142QK29B
Version SVN-r29796 for now, will probably upgrade later and post link here.
Save it to a SD card and use 'sh mplayer mediafilegoeshere.example -ao oss:/dev/msm_pcm_out' and post the results here.
Since you have a HTC Dream, it would be great if you could confirm it working/broken without the '-ao oss:/dev/msm_pcm/out' part.
Thanks for your help

[Q] root_plug

Not sure if this means anything, just throwing it out there, but i was going through file for froyo on the evo, original file name "supersonic-2.6.32.15-g746f4f0.tar" and found a file named root_plug-notepad, now i'm only guessing, but is this how they are blocking us from being able to root our device, or am i just guessing outta my arse.
on the notepad the full content is:
/*
* Root Plug sample LSM module
*
* Originally written for a Linux Journal.
*
* Copyright (C) 2002 Greg Kroah-Hartman
*
* Prevents any programs running with egid == 0 if a specific USB device
* is not present in the system. Yes, it can be gotten around, but is a
* nice starting point for people to play with, and learn the LSM
* interface.
*
* If you want to turn this into something with a semblance of security,
* you need to hook the task_* functions also.
*
* See for more information
* about this code.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2 of the
* License.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/security.h>
#include <linux/usb.h>
#include <linux/moduleparam.h>
/* default is a generic type of usb to serial converter */
static int vendor_id = 0x0557;
static int product_id = 0x2008;
module_param(vendor_id, uint, 0400);
module_param(product_id, uint, 0400);
/* should we print out debug messages */
static int debug = 0;
module_param(debug, bool, 0600);
#define MY_NAME "root_plug"
#define root_dbg(fmt, arg...) \
do { \
if (debug) \
printk(KERN_DEBUG "%s: %s: " fmt , \
MY_NAME , __func__ , \
## arg); \
} while (0)
static int rootplug_bprm_check_security (struct linux_binprm *bprm)
{
struct usb_device *dev;
root_dbg("file %s, e_uid = %d, e_gid = %d\n",
bprm->filename, bprm->cred->euid, bprm->cred->egid);
if (bprm->cred->egid == 0) {
dev = usb_find_device(vendor_id, product_id);
if (!dev) {
root_dbg("e_gid = 0, and device not found, "
"task not allowed to run...\n");
return -EPERM;
}
usb_put_dev(dev);
}
return 0;
}
static struct security_operations rootplug_security_ops = {
.bprm_check_security = rootplug_bprm_check_security,
};
static int __init rootplug_init (void)
{
/* register ourselves with the security framework */
if (register_security (&rootplug_security_ops)) {
printk (KERN_INFO
"Failure registering Root Plug module with the kernel\n");
return -EINVAL;
}
printk (KERN_INFO "Root Plug module initialized, "
"vendor_id = %4.4x, product id = %4.4x\n", vendor_id, product_id);
return 0;
}
security_initcall (rootplug_init);
nobody, nothing, someone has to have some sort of input, lol.
pubbs.net/200910/kernel/36760-patchrfc-security-remove-rootplug.html
Uncle jimmy says hello

Solved .[eVC++] How to use "srand" function?

Hello.
I want to ask some skilled developers,how to use "srand" function?
I found in help this:
Code:
/* RAND.C: This program seeds the random-number generator
* with the time, then displays 10 random integers.
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void main( void )
{
int i;
/* Seed the random-number generator with current time so that
the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
/* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( “ %6d\n”, rand() );
}
Problem is,when I use this example,I get errormessages:
CNS.obj : error LNK2019: unresolved external symbol time referenced in function "void __cdecl PrepareWheel(struct HDC__ *)" ([email protected]@[email protected]@@Z)
ARMV4Dbg/CNS.exe : fatal error LNK1120: 1 unresolved externals
Without this function,function "rand" returns all the time same sequence(as we know).
I am using Embedded Visual C++ 4.0 for PocketPC app development.
That's for now,thanks,Tomas.

[Q] How do I build binary compatible system apks for JRO03C?

Please note that this question is purely academic in nature. My phone is not broken, and all the features I need are enabled. I just want to know how to make similar changes myself (see below).
Forgive me if this is in the wrong forum. I was going to post this in the Verizon Samsung Galaxy Nexus Development forum, but the site warned me that asking questions in that forum was against the rules (OK, I won't post my question there)!
I have a "toro" (Samsung Galaxy Nexus for VzW with LTE/CDMA).
Yesterday, I repo synced my AOSP source to bring it up to date. My phone is running an almost stock "maguro" (rooted) JRO03O from https://dl.google.com/dl/android/aosp/mysid-jro03o-factory-f17426e6.tgz .
Then I sourced build/envsetup.sh and selected full_toro-user (yes, "user", not "userdebug" ) with the lunch menu.
I then made what I thought was a clever patch to packages/apps/Settings/src/com/android/settings/TetherSettings.java where I added a few constants and a boolean function called isProvisioningAllowed() that is called by a now modified boolean function isProvisioningNeeded(). Essentially, isProvisioningNeeded() now checks to see if the Android owner allows his carrier to limit tethering to provisioned users (before checking to see if the carrier requires provisioning). As you may have guessed, using my patch, the default setting is now that the carrier is not allowed by the Android owner to require provisioning from the user.
For anyone curious, here is the .diff for my patch for TetherSettings.java (Java is not a programming language that I "know", but I can figure out most of the syntax from the existing code - so I may have crappy code) :
Code:
project packages/apps/Settings/
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index 4a79eca..63f1526 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -106,6 +106,11 @@ public class TetherSettings extends SettingsPreferenceFragment
private String[] mProvisionApp;
private static final int PROVISION_REQUEST = 0;
+ /* Is carrier allowed to require provisioning for tethering */
+ private static final int CARRIER_TETHERING_PROVISIONING_ALLOWED = 0;
+ private static final int CARRIER_TETHERING_PROVISIONING_PROHIBITED = -1;
+ private int mCarrierTetheringProvisioning = CARRIER_TETHERING_PROVISIONING_PROHIBITED;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -424,6 +429,36 @@ public class TetherSettings extends SettingsPreferenceFragment
return false;
}
+ boolean isProvisioningAllowed() {
+ /* returns whether Android owner allows carrier to restrict tethering to provisioned users */
+ if (mCarrierTetheringProvisioning == CARRIER_TETHERING_PROVISIONING_PROHIBITED) {
+ return false;
+ }
+ if (mCarrierTetheringProvisioning == CARRIER_TETHERING_PROVISIONING_ALLOWED) {
+ return true;
+ }
+ /* If neither of the above values match mCarrierTetheringProvisioning then assume it is prohibited by Android owner */
+ return false;
+ }
+
+ boolean isProvisioningNeeded() {
+ /* first check to see if provisioning is allowed before checking to see if it is needed */
+ if (isProvisioningAllowed()) {
+ /* provisioning is allowed, check to see if needed */
+ if (SystemProperties.getBoolean("net.tethering.noprovisioning", false)) {
+ /* provisioning is allowed, but not needed */
+ return false;
+ }
+ /* provisioning is allowed (and needed if mProvisionApp array has two values) */
+ return mProvisionApp.length == 2;
+ } else {
+ /* provisioning is not allowed, therefore it is not needed */
+ return false;
+ }
+
+/* Original (unaltered) isProvisioningNeeded() function
+
boolean isProvisioningNeeded() {
if (SystemProperties.getBoolean("net.tethering.noprovisioning", false)) {
return false;
@@ -431,6 +466,8 @@ public class TetherSettings extends SettingsPreferenceFragment
return mProvisionApp.length == 2;
}
+*/
+
private void startProvisioningIfNecessary(int choice) {
mTetherChoice = choice;
if (isProvisioningNeeded()) {
Then I built the entire tree. Next, I backed up "Settings.apk" and "Settings.odex" from my /system/app directory on my phone. Also, I remounted /system as r/w. I then dropped in the new "Settings.apk" and "Settings.odex" from my custom build, and set the owner.group to root.root (on both) and permissions to 644 (on both). I remounted /system as r/o again.
Even with a cold boot, the "Settings" menu crashes when launched (with my "Settings.apk" and "Settings.odex" in place).
I restored my backups for those two system files, and rebooted again (which fixed my Settings menu/app). I then downloaded somebody else's fixed "framework-res.apk" and deleted "SPG.apk". While this accomplishes one goal (no carrier restrictions on Google Android native tethering), it does not help me learn how to do this myself.
I want to be able to tweak the AOSP source on the fly, and produce binaries that are compatible with my ROM.
So my problem basically breaks down to the following 4 sub-questions:
1) Can anyone tell me why my customized "Settings.apk" and "Settings.odex" crash when "Settings" is launched?
2) Did I make a change that would break binary compatibility (I tried not to)?
3) Or is it because the current version of AOSP builds binaries for 4.1.2 (JZO54K) instead of for 4.1.1 (JRO03O)?
4) How do I build AOSP for an older tag anyway (like 4.1.1_r1)?

Fix Lollipop Charging

Hi i have a posible fix for charging off mode on lolliopop we need to integrate this in kernel:
" androidboot.mode=charger"
In the file board-tuna-power.c but i dont know how to
werty100 said:
Hi i have a posible fix for charging off mode on lolliopop we need to integrate this in kernel:
" androidboot.mode=charger"
In the file board-tuna-power.c but i dont know how to
Click to expand...
Click to collapse
MWisBest's tuna kernel repository has the file board-tuna-power.c with this function
Code:
static int __init tuna_charger_mode_setup(char *str)
{
if (!str) /* No mode string */
return 0;
is_charging_mode = !strcmp(str, "charger");
pr_debug("Charge mode string = \"%s\" charger mode = %d\n", str,
is_charging_mode);
return 1;
}
__setup("androidboot.mode=", tuna_charger_mode_setup);
it looks good to me

Categories

Resources