[Previous] [Next] [Contents]

CHAPTER 4. DEVELOPING APPLICATIONS

 

4.16 Sound Environment of MIZI Prizm 2.0

First of all, follow next Notification.

[Note]

Please do not access /dev/dsp directly for audio output, instead use esd(esound).
http://developer.gnome.org/doc/whitepapers/esd

  • Using esound API


  • 1. How to play "wave sound file"?
    Wave file in $LINUETTEDIR/sound directory can be played by the following instruction. Sample code is as follow;

    #include <mzaudio.h> 
    {
    MzAudioManager::instance ()->play ("play");
    }

     

    If you need to play repeatedly, handle it by taking "stopped (const QString &) signal" of MzAudioManager.

  • Using /dev/dsp directly (Not recommended)
  •  

    Unavoidably, if you need to access /dev/dsp directly, follow the following restrictions.
    The case of using esound API doesn’t correspond to here; esd of system processes the case.

    1. Volume
    The range of volume controlling should be restricted as follow; don’t use other volume value. (It just corresponds to SCH-i519.)

    Audio Out
    SOUND_MIXER_PCM - 0, 43, 50, 56, 62, 68, 75, 81, 87

    Audio In
    SOUND_MIXER_IGAIN - 0, 75, 81, 87, 93, 100

     

    2. Esound
    Following two functions should be called certainly; those make /dev/dsp not crash with esd of system.

    #include <esd.h>
    
    int esd_standby( int esd ); // When program is started. 
    int esd_resume( int esd ); // When program is quitted.
    

     

    3. Manner mode
    As additional recommendation, please add following codes for the process of manner mode.

    #include <esd.h>
    if (esd_get_priority (esd, NULL) == -2)
    manner_mode = true;
    else
    manner_mode = false;

     

    1) In case of manner mode, audio output is disabled.
    2) In case that earphone is inserted, though in manner mode, audio output is enabled.
    3) In case that earphone is removed in manner mode, audio output is immediately disabled.

     

    A. Sound policy of MIZI Prizm 2.0

  • Sound server

  • Sound server is certainly needed for various programs to share only one sound device in system.

    MIZI Prizm 2.0 has used esound v0.2.29 for sound server, which is open source sound server. (ftp://ftp.gnome.org/pub/GNOME/sources/esound/0.2/)

    Basic operation of Esound is that esound mixes all the sounds and then it outputs the sound.

    But there are various additional requirements to esound. So MIZI Research expands the functions. Functions related to audio path, priority, and etc. are added.

  • Audio path

  • SCH-i519 terminal has three output devices, which are speaker, receiver, and earphone. And those have to be set differently according to phone mode and PDA mode.

    Phone mode and PDA mode are distinguished by phone state.

    Among those, the case of earphone is that earphone is inserted at ear jack. This case is processed by Kernel, sound leaking can be occurred during changing audio path.

    MIZI Prizm 2.0 defines five states at advance and uses those.

    PDA_MODE
    It is not during call but during PDA operating normally. All sounds are outputted through speaker.

    PHONE_MODE
    It is during call. The sound inputted through mic is directly transmitted to phone and the sound outputted through phone is outputted to receiver.

    SPEAKERPHONE_MODE
    It is same with PHONE_MODE, but the sound is outputted through speaker.

    PDAPHONE_MODE
    It is the state that all sounds are outputted through PDA during call. To make recording possible during call, terminal should be set to this mode.

    SPEAKERWITHEAR_MODE
    It forces to output sound through speaker. At this case, it doesn’t matter whether terminal is during call or not and also whether earphone is inserted or not. This mode is mostly used to play system alarm sound. Ring, alarm, shutter sound are typical.

     

  • Manner mode

  • Basic aim of manner mode is to prevent sound from outputting through speaker. But, differently with mixer mute, it has following specificities and requirement.

    - Cancel manner mode when phone on/off
    - Cancel manner mode when earphone mode
    - It must operate separately with volume control.

    At the first, we implement manner mode as mixer mute. But, various situations are occurred which control volume, and the situations make manner mode cancel, we modify manner mode can be controlled separately.

    Current implementation state is that priority of sound server is leveled up to –2, so output of other sounds are blocked. Only when camera shutter sound is played, the sound is forced to up priority to –2, so the sound can be played without regard to manner mode.


  • Audio priority

  • Audio priority is derived to set audio policy in various situations.

    Audio policy which is adopted by SCH-i519 is as following.

    1. Sounds that follow Priority
    The priority of the sound is as following.

    Camera shutter sound (priority: 0) > Ring sound (priority: 1) > SMS alarm sound (priority: 2) > System alarm sound (priority: 3) > normal sound (priority: 5)

    And, there is requirement that the sound excluding normal sound should be outputted through speaker without regard to earphone mode.

    So, in case that priority isn’t same with normal sounds’, audio path is always set to SPEAKERWITHEAR_MODE.

    2. Sounds that are always played regardless of Priority
    Various kinds of hardware button, touch, wakeup, etc and various system effects correspond to here.

    In actual implementation, priority is set to –1, so the sound always can be played regardless of priority of general sounds.

    3. Sounds that are always played regardless of situation such as Priority, audio device, etc.
    The sound like camera shutter sound is always played regardless of manner mode, mixer mute, and priority.

    In implementation, camera shutter sound is specially controlled separately. The reason is that the sound has to be played in various situations.



    [Previous] [Next] [Contents] MIZI Prizm 2.0.0