How to edit audio_policy.conf in Android Lollipop

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

How to edit audio_policy.conf in Android Lollipop

#1 Post by nubc »

EDIT: I neglected to mention my mission here. I want to edit audio_policy.conf to output mono audio to the earbud jack.

First off, why can't I see my Motorola Lollipop smartphone's system files when I mount the device through MTP? I can understand why I might not be able to edit the system files, but shouldn't I at least be able to view the files? Since I can't edit the system files from my Slacko box, I am trying to edit audio_policy.conf with ES File Manager on the smartphone. I wish there were an easier way to work on this file, but I guess I will painstakingly transfer it to this thread, just to get a better view of it:

Code: Select all

#Global configuration section: lists input and output devices always
present on the device as well as the output device selected by default. 
Devices are designated by a string that corresponds to the enum in 
audio.h

global_configuration {
  attached_output_devices AUDIO_DEVICE_OUT_EARPIECE|
AUDIO_DEVICE_OUT_SPEAKER
  default_output_device AUDIO_DEVICE_OUT_SPEAKER
  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|
AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|
AUDIO_DEVICE_IN_FM_RX|AUDIO_DEVICE_IN_FM_RX_A2DP
}

# audio hardware module section: contains descriptors for all audio hw 
modules present on the device. Each hw module node is named after the 
corresponding hw module library base name.
For instance, "primary" corresponds to audio primary.<device>.so.
The "primary" mmodule is mandatory and must include at least one 
output with AUDIO_OUTPUT_FLAG_PRIMARY flag.
Each module descriptor contains one or more output profile descriptors 
and zero or more input profile descriptors. Each profile lists all the 
parameters supported by a given output or input stream category. 
The "channel masks", "formats", "devices" and "flags" are specified using
 strings corresponding to enums in audio.h and audio policy.h. They are
 concatenated by use of "|" without space or "\n".

audio_hw_modules {
  primary {
    outputs {
      primary {
        sampling_rates 44100|48000
        channel_masks AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|
AUDIO_DEVICE_OUT_LINE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_FM
        flags AUDIO_OUTPUT_FLAG_PRIMARY
      }
      low_latency {
         sampling_rates 44100/48000
         channel_masks AUDIO_CHANNEL_OUT_STEREO
         formats AUDIO_FORMAT_PCM_16_BIT
         devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_WIRED_HEADPHONE|
AUDIO_DEVICE_OUT_LINE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_FM
         flags AUDIO_OUTPUT_FLAG_FAST
      }
      compress_offload {
        sampling rates 8000|11025|16000|22050|24000|32000|44100|48000
        channel_masks AUDIO_CHANNEL_OUT_MONO|
AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AAC_LC
AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2
        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_
HEADPHONE|AUDIO_DEVICE_OUT_LINE|AUDIO_DEVICE_OUT_ALL_SCO
        flags AUDIO_OUTPUT_FLAG_DIRECT|
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|
AUDIO_OUTPUT_FLAG_NON_BLOCKING
      }
    }
    inputs {
      primary {
        sampling_rates 8000|11025|12000|16000|22050|24000|32000|44100|48000
        channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL
_IN_FRONT_BACK
        formats AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|
AUDIO_FORMAT_AMR_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|
AUDIO_FORMAT_EVRCB|AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW
        devices AUDIO_DEVICE_IN_BUILTIN_MIC| 
AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_BLUETOOTH_SCO_
HEADSET|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_ANLG_DOCK
_HEADSET|AUDIO_DEVICE_IN_FM_RX|AUDIO_DEVICE_IN_FM_RX_A2DP|
AUDIO_DEVICE_IN_VOICE_CALL
    }
   }
  }
  a2dp {
    outputs {
      a2dp {
        sampling_rates 44100
        channel_masks AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_OUT_ALL_A2DP
     }
    }
   }
   usb {
     outputs {
       usb_accessory {
         sampling_rates 44100
         channel_masks AUDIO_CHANNEL_OUT_STEREO
         formats AUDIO_FORMAT_[C,_16_BIT
         devices AUDIO_DEVICE_OUT_ALL_A2DP    
      }
     }
    }
    usb {
      outputs {
        usb_accessory {
          sampling_rates 44100
          channel_masks AUDIO_CHANNEL_OUT_STEREO
          formats AUDIO_FORMAT_PCM_16_BIT
          devices AUDIO_DEVICE_OUT_USB_ACCESSORY
        }
        usb_device {
          sampling_rates dynamic
          channel_masks dynamic
          formats dynamic
          devices AUDIO_DEVICE_OUT_USB_DEVICE
        }
       }
       inputs {
         usb_device {
           sampling_rates dynamic
           channel_masks AUDIO_CHANNEL_IN_STEREO
           formats AUDIO_FORMAT_PCM_16_BIT
           devices AUDIO_DEVICE_IN_USB_DEVICE
         }
        }
       }
       r_submix {
         outputs {
           submix {
             sampling_rates 48000
             channel_masks AUDIO_CHANNEL_IN_STEREO
             formats AUDIO_FORMAT_PCM_16_BIT
             devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
        }
       }
       inputs {
         submix {
           sampling_rates 48000
           channel_masks AUDIO_CHANNEL_IN_STEREO
           formats AUDIO_FORMAT_PCM_16_BIT
           devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
         }
        }
       }
      }
I read a hint about getting mono audio output on an Android phone from a post on a Google Code thread. A positive note that I learned from reading this thread is that mono audio is there already because Android uses ALSA, it just needs to be called into play correctly. Towit:
An update, I have found a way to solve this issue at
least on the HTC One m8, and I suspect the m9 as well.
It is possible to edit the audio_policy.conf file found
in /system/etc and change every AUDIO_CHANNEL_OUT_STEREO
entry to AUDIO_CHANNEL_OUT_MONO, making sure to remove
duplicates. This properly mixes mono audio as long as
boomsound is turned on. As for mixing without boomsound,
I don't know.
Why can't I see this system file from my Slacko box when I mount the smartphone as MTP device? I notice that all instances of MONO in audio_policy.conf have a pipe after the word, as in MONO|.

Would anyone care to venture an opinion about whether I will be able to edit this system file when I don't have root access? Thank you.

For purposes of comparison, here is my LG KitKat smartphone's audio_policy.conf file with the Stereo-Mono switch set to Mono

Code: Select all

global configuration section: lists input and output devices always
present on the device as well as the output device selected by default.
Devices are designated by a string that corresponds to the enum in audio.h

global configuration {
  attached_output_devices
AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER
  default_output_device
AUDIO_DEVICE_OUT_SPEAKER
  attached_input_devices
AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE
_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_VOICE_CALL
}

#audio hardware module section: contains descriptors for all audio hw 
modules present on the device. Each hw module node is named after the 
corresponding hw module library base name.
For instance, "primary" corresponds to audio primary.<device>.so.
The "primary" mmodule is mandatory and must include at least one 
output with AUDIO_OUTPUT_FLAG_PRIMARY flag.
Each module descriptor contains one or more output profile descriptors
and zero or more input profile descriptors. Each profile lists all the 
parameters supported by a given output or input stream category. 
The "channel masks", "formats", "devices" and "flags" are specified using
strings corresponding to enums in audio.h and audio policy.h. They are 
concatenated by use of "|" without space or "\n".

audio_hw_modules {
  primary {
    outputs {
      primary {
        sampling_rates 44100|48000
        channel_masks AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_
HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_
PROXY|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_
OUT_FM|AUDIO_DEVICE_OUT_FM_TX
         flags AUDIO_OUTPUT_FLAG_PRIMARY
      }
      low_latency {
         sampling_rates 44100/48000
         channel_masks AUDIO_CHANNEL_OUT_STEREO
         formats AUDIO_FORMAT_PCM_16_BIT
         devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_WIRED_HEADPHONE|
AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE
_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_FM|AUDIO_DEVICE_OUT_
FM_TX
         flags AUDIO_OUTPUT_FLAG_FAST
      }
  compress_offload {
        sampling rates 8000|11025|16000|22050|24000|32000|44100|48000
        channel_masks 
AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_AAC
        devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|
AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_
HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_
PROXY|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE
_OUT_FM_TX
        flags AUDIO_OUTPUT_FLAG_DIRECT|
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|
AUDIO_OUTPUT_FLAG_NON_BLOCKING
     }
     incall_music
        sampling_rates 8000|16000|48000
        channel masks
AUDIO_CHANNEL_OUT_MONO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices
AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE
_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_
DEVICE_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_ALL_USB|AUDIO_
DEVICE_OUT_ALL_SCO
        flags
AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_INCALL_MUSIC      
     }
     voip_rx {
       sampling_rates 8000|16000
       channel_masks
AUDIO_CHANNEL_OUT_MONO
       formats
AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR
_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|
AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW
       devices
AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_
OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO
_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_ALL_SCO
       flags
AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_VOIP_RX
    }
    irrc {
       sampling_rates 48000
       channel_masks
AUDIO_CHANNEL_OUT_STEREO
       formats AUDIO_FORMAT_PCM_16_BIT
       devices AUDIO_DEVICE_OUT_IRRC
       flags 
AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_IRRC
    }

   }
   inputs {
      primary {
         sampling_rates
8000|11025|12000|16000|22050|24000|32000|44100|48000
         channel_masks
AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL
_IN_FRONT_BACK|AUDIO_CHANNEL_IN_5POINT1|AUDIO_CHANNEL_IN_VOICE_
CALL_MONO|AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO|AUDIO_CHANNEL_
IN_VOICE_UPLINK_MONO
         formats
AUDIO_FORMAT_PCM_16_BIT|AUDIO_FORMAT_AMR_NB|AUDIO_FORMAT_AMR
_WB|AUDIO_FORMAT_QCELP|AUDIO_FORMAT_EVRC|AUDIO_FORMAT_EVRCB|
AUDIO_FORMAT_EVRCWB|AUDIO_FORMAT_EVRCNW
        devices
AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO
_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_BACK_MIC| AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET|AUDIO_DEVICE_IN_FM_RX|AUDIO_
DEVICE_IN_FM_RX_A2DP|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_
IN_PROXY|AUDIO_DEVICE_IN_COMMUNICATION
      }
    }
  }
  a2dp {
    outputs {
      a2dp {
        sampling_rates 44100
        channel_masks AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_OUT_ALL_A2DP
     }
    }
   }
   usb {
     outputs {
       usb_accessory {
         sampling_rates 44100
         channel_masks AUDIO_CHANNEL_OUT_STEREO
         formats AUDIO_FORMAT_[C,_16_BIT
         devices AUDIO_DEVICE_OUT_ALL_A2DP    
      }
     }
    }
    usb {
      outputs {
        usb_accessory {
          sampling_rates 44100
          channel_masks AUDIO_CHANNEL_OUT_STEREO
          formats AUDIO_FORMAT_PCM_16_BIT
          devices AUDIO_DEVICE_OUT_USB_ACCESSORY
        }
        usb_device {
          sampling_rates dynamic
          channel_masks dynamic
          formats dynamic
          devices AUDIO_DEVICE_OUT_USB_DEVICE
        }
       }
       inputs {
         usb_device {
           sampling_rates dynamic
           channel_masks AUDIO_CHANNEL_IN_STEREO
           formats AUDIO_FORMAT_PCM_16_BIT
           devices AUDIO_DEVICE_IN_USB_DEVICE
         }
        }
       }
       r_submix {
         outputs {
           submix {
             sampling_rates 48000
             channel_masks AUDIO_CHANNEL_IN_STEREO
             formats AUDIO_FORMAT_PCM_16_BIT
             devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
        }
       }
       inputs {
         submix {
           sampling_rates 48000
           channel_masks AUDIO_CHANNEL_IN_STEREO
           formats AUDIO_FORMAT_PCM_16_BIT
           devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
         }
        }
       }
      }
Last edited by nubc on Tue 10 Nov 2015, 03:51, edited 22 times in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

mtp only shows the files on the real removable SD card -not the system partitions or internal storage. In order to get the internal storage to be used and seen from outside, you have to edit the fstab and switch the two devices (sdcard0 and sdcard1).

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#3 Post by nubc »

Here is fstab on the Slacko box with the smartphone mounted

Code: Select all

/dev/sda1     /            ext3     defaults               0 1
none          /proc        proc     defaults               0 0
none          /sys         sysfs    defaults               0 0
none          /dev/pts     devpts   gid=2,mode=620         0 0
/dev/fd0      /mnt/floppy  auto     noauto,rw              0 0
Is this the fstab that I edit? Where is the fstab to which you refer?

Here is vold.fstab from the smartphone

Code: Select all

# MTP
# dev_mount sdcard2 /mnt/sdcard/external_sd auto /devices/platform/
msm_sdcc.3/mmc_host

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Your Android device is an older version 2.x , that uses normal mount as your vold.fstab shows .

/etc/fstab is useless, except for `mount -a' and `umount -a' code .

Puppy does not use fstab much, except for shutdown , where in rc.shutdown it executes umount -ar at the very end .

Woof-CE may mount -a at boot, I am not sure . I do not use mount -a .

Android v2 does only give access to the external storage .

Android v4 gives access to the external storage partition and the internal storage partition .

Android refuses SD-Cards that have more than one partition .
I wanted to add some SWAP partition once and it got refused .

Android has up to 15 internal partitions . Cache is a partition for example .
There are also two boot partitions . One for normal boot and one for Recovery Boot .
And a few other partitions .

I have an Huawei x3 with Android v2.3.x that i fetched a custom BOOT ROM on the net for that allowed me to root it .

https://www.clockworkmod.com/

The same ROM bricked my Motorola Fire XT311 , I guess since it has an other internal partition layout .

Such Boot Recovery Images are apparently made while creating CUSTOM OS ROMS for Android .

Here is the git repo of such a SDK :
url = https://github.com/CyanogenMod/android.git

It depends on the whole Android SDK from Git , which is a very huge download .
And such a Custom ROM involves compiling a new linux kernel for it .
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#5 Post by nubc »

Motorola is known to be a bit behind when it comes to leading edge technology, but this Moto G 2015 is running Lollipop 5.1.1, and will soon be able to upgrade to Marshmallow (v6.0). It may very well be using an antequated fstab setup, I have no idea. I certainly wish that Android did not have such a zany file system tree, with all the emulations. From what you describe, it seems that installing a ROM is like Russian Roulette. You say it was the non-compliant file structure that deep-sixed your phone? Maybe if I used a liveCD of Android-x86 4.0 I could see something. Thing about that old version, now certainly deprecated, is that it was rooted.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#6 Post by dancytron »

I've rooted 4 different phones and installed cyanogenmod on each of them. I haven't had any problem.

What I've always done is find my phone on the cyanogen wiki or http://forum.xda-developers.com/ and followed the instructions exactly.

If you download clockwork mod (or safestrap or twrp) and try to wing it, you are begging to brick your device. Find a set of instructions, read them carefully and follow them exactly and you won't have any trouble.

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#7 Post by nubc »

I bought this phone a week ago, so I'm not in a rush to void the warranty, especially before the return period is up. Right now I am deciding on whether to buy a $10 case for it. What Android version is cyanogenmod based on? You know, I saw a hack for Mono Audio Out on XDA-developers site, written by a user (not a dev), but I can't find it now. I think I bookmarked it using one of my frugal installs. I am going to post the code here when I find it again, it was only about 10 lines. Basically, IIRC the code mixed stereo down to mono.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

I think, that without root access , one is out of luck .

The Android SDK has in android-sdk-linux/platform-tools

adb

program .

Android v4 apparently does not get detected by older adb version 1.0.31 and earlier .

bash-3.00# ./adb version
Android Debug Bridge version 1.0.32

bash-3.00# ./adb devices -l
List of devices attached
0123456789ABCDEF device usb:1-4 product:BARM865FD model:Endeavour_785 device:BARM865FD

bash-3.00# ./adb shell
shell@BARM865FD:/ $

shell@BARM865FD:/ $ ls -l

Other has almost no permissions .

cat /proc/mtd /proc/mounts
works, as
dmesg
command .

But that is it.

One could use adb push and pull to copy files ,
but even copying write protected files into the PC does not work, when read permissions are not set .

I can not even do a cat /dev/block/mtdblock0 to make a backup image of a partition .
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#9 Post by nubc »

I have neglected the fact that I have an LG KitKat phone with the Stereo/Mono switch. All I have to do is find this code on the phone. At first glance the audio_policy.conf file on the LG phone looks very similar to the one on Motorola Lollipop phone. Only way to tell for sure is to copy the file to this thread, the hard way.

By the way, is there some way to disable ES Cleaner? When did ES File Manager put this junkware on the app?

Even if I put cyanogenmod on this phone, there would still be no Mono audio output. I see threads on the XDA website, people begging for a fix for cyanogenmod to get mono audio out, without much luck.

Please have a look at the LG KitKat's audio_policy.conf file in the first post, and let me know if you see a stereo-mono switch, or some provision for mono audio output.

convert stereo to mono, using avconvert

Code: Select all

avconv -i input.mp4 -c:v copy -c:a libmp3lame -ac 1 out.avi
avconv -i input.mp3 -c:a libmp3lame -ac 1 out.avi

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#10 Post by nubc »

Boeffla Sound Control
https://play.google.com/store/apps/deta ... efflasound
requires Root and Busybox
feature: Mono Downmix
drawbacks: no L-R channel sound balance, last update 2013, based on Android 4.3

Can someone determine whether this app will output media audio in mono:
SoundAbout
https://play.google.com/store/apps/deta ... gfix&hl=en
[I couldn't do anything with it. Uninstalled it.]

What is the analog dock?

I have an LG phone here. It has an OEM specific, custom setting to downmix stereo to mono. Where would the code for this setting be located in Android? mixer_paths.xml ? Of course the downmixing might not be anywhere because mono is actually available from ALSA, which is integrated into the kernel. How come when I search the file system for ALSA, I get no result?

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#11 Post by nubc »

If Google/Android coders ever needed a good reason to implement Mono Audio Output, they just got one. California just made it illegal to drive with both earbuds inserted. Only a single inserted earbud is permissible while driving a motor vehicle or riding a bicycle. For reasons of safety, one ear must be left open to hear the external environment.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#12 Post by amigo »

Maybe under Accessibility settings? Which LG model is it?
You are wanting a non-root(ed) solution?

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#13 Post by nubc »

It's an LG Optimus L90 aka LG-D415. The setting is in Accessibility. I have heard this setting referred to as a "widget". I seek the location of the code that downmixes stereo to mono, or, alternatively, the code that pulls mono out of ALSA or OSS.

One observation that has me puzzled about LG's implementation of Mono Audio Output is that some mp3 files still play in stereo even when the audio output is set to Mono. While I have not encountered an mp4 that outputs in stereo when audio is set to Mono, there are some moments when I think I am hearing two different audio tracks in either ear. So while I can't complain about mp4 performance in Mono, there are stereo mp3 files that seem unaffected by the Stereo-Mono switch. The puzzlement is how exactly LG implements Mono Audio Output that would account for these discrepancies. Why do some mp3s still play in stereo (ugh), and why am I occasionally hearing mp4 audio in two different tracks? The implication being that the Mono Audio is not coming from kernel component ALSA, but rather from HAL or some software layer in user space, like a playback library that most music players utilize.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#14 Post by amigo »

I see something about an called poweramp which may help. As for the location of the code used by the LG, it's anyone's guess -if you mean the source code. Some makes/models are good about making their sources available. Others don't 'get it' and try to hide their proprietary stuff.

And I see that the android native audio library is called AudioFlinger, if that helps and applies to lollipop.

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#15 Post by nubc »

I'm hoping this is not my problem anymore. How can Android devs ignore that 39 million people cannot legally use both earbuds in a common mobile circumstance, driving a car? I mean, Google could probably buy the California legislature and have the law rescinded, but that is unlikely. We're not talking about several thousand hearing impaired users, or geriatrics with uneven hearing loss/ability. We're talking about 39 million people, the population size of a country, who are restricted to a single earbud while driving. (Canada's population is 35.5 million. Australia's population is 24 million.) Google headquarters is in Mountain View, California.

The simplest solution is to implement mono audio output, and to provide Left-Right channel balance, a solution which gives the most users the most choices. Just like Apple did 6 years ago, and LG and Samsung did as well. Duh. Which doesn't mean that Google will do it that way. Oh no, Google is special. Google will come up with some convoluted beta solution that nobody likes or wants. Like what Android just did with SD cards in Marshmallow, making the SD card part of the internal memory, making users go through the inconvenience of wiping their SD card and starting over. Inconveniencing users is no problem for Google. It's all one grand experiment to Google. No perspective, no foresight = a management problem.

perspective - the capacity to discern what is fundamentally important
foresight - the ability to anticipate and solve problems before implementation
Last edited by nubc on Fri 08 Jan 2016, 19:28, edited 1 time in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#16 Post by amigo »

Still, there very well may be a way to make it do what you want through configuration files. Yeah, you'll need root to do that, if going around the official UI's, but you can also unroot it after making changes. That about Marshmallow and the sdcard can probably also be changed by editing one of the fstab files. Although I prefer my older versions of android as they are more malleable.

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#17 Post by nubc »

Attachments
Android audio architecture.png
(75.31 KiB) Downloaded 418 times

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#18 Post by Semme »

So Nubc, gonna "root" or not?

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#19 Post by nubc »

If rooting was just a trick to get into the Admin account, I would likely do this. But rooting is actually installing another ROM, all of which, by the way, do not implement Mono Audio Output. As stated on the preceding page, Android devs have the unavoidable task of providing mono audio to a single earbud because of the new traffic law in California applying to 38.5 million residents. That sounds like the implementation of Mono Audio is forthcoming, in which case the fix would be distributed in legitimate updates or upgrades to Android. I investigated what I can do with admin privileges, and frankly it ain't much, since there is very little demand for Mono Audio in the geek community.
Last edited by nubc on Tue 29 Mar 2016, 18:36, edited 2 times in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#20 Post by amigo »

"rooting is actually installing another ROM" This not true at all. Most modified ROM's are pre-rooted. But rooting simply means having the 'su' program installed and there are several ways to accomplish that without any further changes to your ROM.

su can be installed by using any one of several one-click root apps, like framaroot, kingoroot or towelroot. These apps try to take advantage of known kernel vulnerabilities in order to escalate privileges and then use the privilege to install su.

Another way is to install a root app by applying an update while booted into the recovery system. I prefer this method as it is less intrusive(potentially). It is alos safer because if something is wrong with the package, recovery will abort the process.

You can also boot to recovery and then adb to sideload the update from your computer.

In order to install any ROM, your device must already be rooted. Installing one of the alternate ROM's like CWM or TWRP makes future mods much easier as they contain extra functionality, like letting you install unsigned updates and more.

The update-from-recovery method can be very useful -you can even have an update which doesn't really install anything, but the update-binary includes extra functionality -like a file manager -in the case of the AROMA installer.

The recovery system is like a small initrd which can contain anything you want. The recovery images use only C programs, so there is no java or dalvik present.

Be brave, be root!

Post Reply