1 Star 0 Fork 971

Caoruihong / drivers_peripheral

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
README.md 12.54 KB
Copy Edit Raw Blame History
zianed authored 2021-05-20 11:53 . modify readme

audio

Introduction

This repository contains a set of HDIs that can be used to:

  • Manage loading and unloading of sound card drivers.
  • Create audio renderer and capturer.
  • Select an audio scene.
  • Set audio properties.
  • Set the audio volume and gain.
  • Start or stop audio playback and recording.

Figure 1 Logic view of modules related to this repository

Directory Structure

The source code directory structure in this repository is as follows:

drivers/peripheral/audio/
└── interfaces         # External interfaces provided by the audio driver module
    └── include        # HDIs provided by the audio driver module for application development

Available APIs

The audio driver module provides functions that can be directly called by the audio service. The APIs are used to load or unload an audio adapter, create audio renderer and capturer, start or stop audio playback and recording, and adjust the audio volume.

Table 1 describes major HDIs provided by the audio driver module.

Table 1 Audio HDIs

Header File

API

Description

audio_manager.h

int32_t (*GetAllAdapters)(struct AudioManager *manager, struct AudioAdapterDescriptor **descs, int32_t *size);

Obtains the list of all adapters supported by an audio driver.

int32_t (*LoadAdapter)(struct AudioManager *manager, const struct AudioAdapterDescriptor *desc, struct AudioAdapter **adapter);

Loads the driver for an audio adapter.

void (*UnloadAdapter)(struct AudioManager *manager, struct AudioAdapter *adapter);

Unloads the driver for an audio adapter.

audio_adapter.h

int32_t (*InitAllPorts)(struct AudioAdapter *adapter);

Initializes all ports of an audio adapter.

int32_t (*CreateRender)(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs, struct AudioRender **render);

Creates an AudioRender object.

int32_t (*DestroyRender)(struct AudioAdapter *adapter, struct AudioRender *render);

Destroys an AudioCapture object.

int32_t (*GetPortCapability)(struct AudioAdapter *adapter, const struct AudioPort *port, struct AudioPortCapability *capability);

Obtains the capability set of the port driver for the audio adapter.

int32_t (*SetPassthroughMode)(struct AudioAdapter *adapter, const struct AudioPort *port, enum AudioPortPassthroughMode mode);

Sets the passthrough data transmission mode of the audio port driver.

int32_t (*GetPassthroughMode)(struct AudioAdapter *adapter, const struct AudioPort *port, enum AudioPortPassthroughMode *mode);

Obtains the passthrough data transmission mode of the audio port driver.

audio_render.h

int32_t (*RenderFrame)(struct AudioRender *render, const void *frame, uint64_t requestBytes, uint64_t *replyBytes);

Writes a frame of output data (downlink data) into the audio driver for rendering.

int32_t (*GetRenderPosition)(struct AudioRender *render, uint64_t *frames, struct AudioTimeStamp *time);

Obtains the last number of output audio frames.

int32_t (*SetRenderSpeed)(struct AudioRender *render, float speed);

Sets the audio playback speed.

int32_t (*GetRenderSpeed)(struct AudioRender *render, float *speed);

Obtains the current playback speed.

int32_t (*SetChannelMode)(struct AudioRender *render, enum AudioChannelMode mode);

Sets the channel mode for audio rendering.

int32_t (*GetChannelMode)(struct AudioRender *render, enum AudioChannelMode *mode);

Obtains the current channel mode for audio rendering.

Usage Guidelines

The core functionalities of this repository are as follows:

  1. Provides audio HDIs for audio services to implement basic audio features on applications.
  2. Provides standard interfaces for device developers to ensure that the OEM vendor can comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem.

For details about the invocation and implementation, see the API reference.

Repositories Involved

Driver subsystem

drivers_framework

drivers_adapter

drivers_adapter_khdf_linux

drivers_peripheral

1
https://gitee.com/caoruihong/drivers_peripheral.git
git@gitee.com:caoruihong/drivers_peripheral.git
caoruihong
drivers_peripheral
drivers_peripheral
master

Search