AudioHardwareWrapper* AudioHardwareWrapper::create() { LOGV("AudioHardwareWrapper::create()"); /* * FIXME: This code needs to instantiate the correct audio device * interface. For now - we use compile-time switches. */ AudioHardwareWrapper* intf = new AudioHardwareWrapper; char value[PROPERTY_VALUE_MAX]; #ifdef GENERIC_AUDIO intf->mHardware = new AudioHardwareGeneric(); #else // if running in emulation - use the emulator driver if (property_get("ro.kernel.qemu", value, 0)) { LOGV("Running in emulation - using generic audio driver"); intf->mHardware = new AudioHardwareGeneric(); } else { LOGV("Creating Vendor Specific AudioHardware"); intf->mHardware = createAudioHardware(); } #endif if (intf->mHardware->initCheck() != NO_ERROR) { LOGV("Using stubbed audio hardware. No sound will be produced."); delete intf->mHardware; intf->mHardware = new AudioHardwareStub(); } #ifdef DUMP_FLINGER_OUT // This code adds a record of buffers in a file to write calls made by AudioFlinger. // It replaces the current AudioHardwareInterface object by an intermediate one which // will record buffers in a file (after sending them to hardware) for testing purpose. // This feature is enabled by defining symbol DUMP_FLINGER_OUT. // The output file is FLINGER_DUMP_NAME. Pause are not recorded in the file. // replace interface intf->mHardware = new AudioDumpInterface(intf->mHardware); #endif return intf; }
static int legacy_adev_open(const hw_module_t* module, const char* name, hw_device_t** device) { LOGD("legacy_adev_open"); struct legacy_audio_device *ladev; int ret; if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL; ladev = (struct legacy_audio_device *)calloc(1, sizeof(*ladev)); if (!ladev) return -ENOMEM; ladev->device.common.tag = HARDWARE_DEVICE_TAG; ladev->device.common.version = 0; ladev->device.common.module = const_cast<hw_module_t*>(module); ladev->device.common.close = legacy_adev_close; ladev->device.get_supported_devices = adev_get_supported_devices; ladev->device.init_check = adev_init_check; ladev->device.set_voice_volume = adev_set_voice_volume; ladev->device.set_master_volume = adev_set_master_volume; ladev->device.set_mode = adev_set_mode; ladev->device.set_mic_mute = adev_set_mic_mute; ladev->device.get_mic_mute = adev_get_mic_mute; ladev->device.set_parameters = adev_set_parameters; ladev->device.get_parameters = adev_get_parameters; ladev->device.get_input_buffer_size = adev_get_input_buffer_size; ladev->device.open_output_stream = adev_open_output_stream; ladev->device.close_output_stream = adev_close_output_stream; ladev->device.open_input_stream = adev_open_input_stream; ladev->device.close_input_stream = adev_close_input_stream; ladev->device.dump = adev_dump; // add by chipeng ladev->device.SetEMParameter = adev_set_emparameter; ladev->device.GetEMParameter = adev_get_emparameter; ladev->device.SetAudioCommand = adev_set_audiocommand; ladev->device.GetAudioCommand = adev_get_audiocommand; ladev->device.SetAudioData = adev_set_audiodata; ladev->device.GetAudioData = adev_get_audiodata; ladev->device.SetACFPreviewParameter = adev_set_acf_previewparameter; ladev->device.SetHCFPreviewParameter = adev_set_hcf_previewparameter; ladev->device.xWayPlay_Start = adev_xway_play_start; ladev->device.xWayPlay_Stop = adev_xway_play_stop; ladev->device.xWayPlay_Write = adev_xway_play_write; ladev->device.xWayPlay_GetFreeBufferCount = adev_xway_getfreebuffercount; ladev->device.xWayRec_Start = adev_xway_rec_start; ladev->device.xWayRec_Stop = adev_xway_rec_stop; ladev->device.xWayRec_Read = adev_xway_rec_read; ladev->hwif = createAudioHardware(); if (!ladev->hwif) { ret = -EIO; goto err_create_audio_hw; } *device = &ladev->device.common; return 0; err_create_audio_hw: LOGD("err_create_audio_hw"); free(ladev); return ret; }
uint32_t *sampleRate=0, status_t *status=0) = 0; virtual void closeOutputStream(AudioStreamOut* out) = 0; /** This method creates and opens the audio hardware input stream */ virtual AudioStreamIn* openInputStream( uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status, AudioSystem::audio_in_acoustics acoustics) = 0; virtual void closeInputStream(AudioStreamIn* in) = 0; static AudioHardwareInterface* create(); AudioHardwareInterface* AudioHardwareInterface::create() #ifdef GENERIC_AUDIO hw = new AudioHardwareGeneric(); #else // creating vendor specific audiohardware hw = createAudioHardware(); #endif #ifdef WITH_A2DP hw = new A2dpAudioInterface(hw); #endif return hw;