예제 #1
0
        /**
         * Assigns active input and output devices from among those available.
         * Notifies user regarding the name of the selected devices or whether the request failed.
         * <em>Both</em> devices must exist for the request to succeed.
         *
         * @param micIdx
         *  Index into the array of available recording devices of the requested input device.
         * @param spkrIdx
         *  Index into the array of available playback devices of the requested output device.
         *
         * @return
         * <ul>
         *   <li>true: success</li>
         *   <li>false: failure</li>
         * </ul>
         *
         * @see com.skype.api.Skype#getAvailableRecordingDevices()
         * @see com.skype.api.Skype#getAvailableOutputDevices()
         *
         * @since 2.0
         */
        public bool setupAudioDevices(int micIdx, int spkrIdx)
        {
            bool passFail = true;       // Ever the optimist, assume success!

            Skype.GetAvailableRecordingDevicesResponse inputDevices  = mySkype.getAvailableRecordingDevices();
            Skype.GetAvailableOutputDevicesResponse    outputDevices = mySkype.getAvailableOutputDevices();

            if (micIdx > (inputDevices.handleList.Length + 1))
            {
                MySession.myConsole.printf("%s: Invalid mic device no. (%d) passed!%n", myTutorialTag, micIdx);
                passFail = false;
            }

            if (spkrIdx > (outputDevices.handleList.Length + 1))
            {
                MySession.myConsole.printf("%s: Invalid speaker device no. (%d) passed!%n", myTutorialTag, spkrIdx);
                passFail = false;
            }

            if (passFail)
            {
                MySession.myConsole.printf("%s: Setting mic to %s (%s)%n",
                                           myTutorialTag, inputDevices.nameList[micIdx], inputDevices.productIdList[micIdx]);
                MySession.myConsole.printf("%s: Setting speakers to %s  (%s)%n",
                                           myTutorialTag, outputDevices.nameList[spkrIdx], outputDevices.productIdList[spkrIdx]);
                mySkype.selectSoundDevices(inputDevices.handleList[micIdx],
                                           outputDevices.handleList[spkrIdx], outputDevices.handleList[spkrIdx]);
                mySkype.setSpeakerVolume(100);
            }

            return(passFail);
        }