Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
Posts: 4
Registered: ‎10-29-2013
My Device: q10
My Carrier: airtel
Accepted Solution

programmatically enable loud speaker

[ Edited ]

Hi,

       I am working on bb10 platform. I need to enable the speaker functionality through programatically. I am developing voip application. in audio library something  mention like this.

 

 unsigned int audioman_handle;

 

    // Acquire an audioman handle. Start it "unsuspended", which means that its

    // ducking and routing rules take effect immediately.

    if (audio_manager_get_handle(AUDIO_TYPE_DEFAULT, // Type default

                                0,                  // This pid

                                false,              // Start "unsuspended"

                                &audioman_handle) == EOK) {

 

        // Use audio_manager_set_handle_type to also override the routing paths

        if (audio_manager_set_handle_type(audioman_handle, // audioman handle

                  AUDIO_TYPE_DEFAULT,              // Use the same type

                  AUDIO_DEVICE_SPEAKER,            // Force routing to loud speaker for output

                  AUDIO_DEVICE_DEFAULT ) == EOK) { // No preference for the input routing.

 

            // Do what you would normally do here with libasound...

            // ...

 

        }

    }

 

what I will insert in this code or any other way need to implement loud speaker functionality. Please any one guide to me.

 

 

Regards,

Mallikarjuna Reddy. G

 

New Contributor
Posts: 4
Registered: ‎10-29-2013
My Device: q10
My Carrier: airtel

Re: programmatically enable loud speaker

Hi all,

       Finally myself resoved this problem.

BlackBerry Development Advisor
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: programmatically enable loud speaker

Hi Mallikarjunreddy,

 

It would be awesome if you can provide your resolution for the benifit of others visiting your post :smileyhappy:

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
New Contributor
Posts: 4
Registered: ‎10-29-2013
My Device: q10
My Carrier: airtel

Re: programmatically enable loud speaker

Hi All,

      put the first argument as  AUDIO_TYPE_VOICE Instead of   AUDIO_DEVICE_DEFAULT

 

audio_manager_set_handle_type(audioman_handle, // audioman handle

                  AUDIO_TYPE_VOICE,              // Use the same type

                  AUDIO_DEVICE_SPEAKER,            // Force routing to loud speaker for output

                  AUDIO_DEVICE_DEFAULT );

 

Developer
Posts: 1,543
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: programmatically enable loud speaker


Mallikarjunreddy wrote:

Hi All,

      put the first argument as  AUDIO_TYPE_VOICE Instead of   AUDIO_DEVICE_DEFAULT

 

audio_manager_set_handle_type(audioman_handle, // audioman handle

                  AUDIO_TYPE_VOICE,              // Use the same type

                  AUDIO_DEVICE_SPEAKER,            // Force routing to loud speaker for output

                  AUDIO_DEVICE_DEFAULT );

 


Your solution works but other apps can't play sound until the app quits.

 

So how do you put the audio device back to handset? by changing AUDIO_DEVICE_SPEAKER to AUDIO_DEVICE_HANDSET doesn't work.

 

New Contributor
Posts: 4
Registered: ‎10-29-2013
My Device: q10
My Carrier: airtel

Re: programmatically enable loud speaker

Hi,

       make sure the audioman_handle variable  as globle variable. 

 

audio_manager_set_handle_type(audioman_handle, // audioman handle

                  AUDIO_TYPE_VOICE,              // Use the same type

                  AUDIO_DEVICE_HANDSET,            // Force routing to loud speaker for output

                  AUDIO_DEVICE_DEFAULT )