!2 tinyalsa adapter rk3568

Merge pull request !2 from zhao_haipeng/master
This commit is contained in:
Robert
2021-11-16 09:30:38 +00:00
committed by Gitee
4 changed files with 92 additions and 13 deletions
+50
View File
@@ -0,0 +1,50 @@
#Copyright (C) 2021 HiHope Open Source Organization .
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import("//build/ohos.gni")
import("//build/ohos/ndk/ndk.gni")
config("libtinyalsa_config") {
include_dirs = [
"include",
"include/tinyalsa",
]
cflags = [
"-Wno-incompatible-pointer-types",
"-Werror",
"-Wimplicit-function-declaration",
"-Wno-error=unused-variable",
"-Wno-macro-redefined",
]
}
ohos_shared_library("libtinyalsa") {
sources = [
"src/mixer.c",
"src/mixer_hw.c",
"src/mixer_plugin.c",
"src/pcm.c",
"src/pcm_hw.c",
"src/pcm_plugin.c",
"src/snd_card_plugin.c",
]
install_images = [
"system",
"updater",
]
install_enable = true
configs = [ ":libtinyalsa_config" ]
subsystem_name = "hdf"
}
+4 -4
View File
@@ -327,13 +327,13 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, struct timespec *ts
unsigned int pcm_get_subdevice(const struct pcm *pcm);
int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count);
int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count);
int pcm_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
int pcm_write(struct pcm *pcm, const void *data, unsigned int count);
int pcm_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
int pcm_read(struct pcm *pcm, void *data, unsigned int count);
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
+12
View File
@@ -62,6 +62,18 @@
#include "mixer_io.h"
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef UINT_MAX
#define UINT_MAX 4294967295UL
#endif
#ifndef ULONG_MAX
#define ULONG_MAX 4294967295UL
#endif
/** A mixer control.
* @ingroup libtinyalsa-mixer
*/
+26 -9
View File
@@ -82,6 +82,18 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef UINT_MAX
#define UINT_MAX 4294967295UL
#endif
#ifndef ULONG_MAX
#define ULONG_MAX 4294967295UL
#endif
/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */
static const char * const access_lookup[] = {
"MMAP_INTERLEAVED",
@@ -616,6 +628,16 @@ static int pcm_sync_ptr(struct pcm *pcm, int flags)
return 0;
}
int pcm_state(struct pcm *pcm)
{
// Update the state only. Do not sync HW sync.
int err = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN);
if (err < 0)
return err;
return pcm->mmap_status->state;
}
static int pcm_hw_mmap_status(struct pcm *pcm)
{
if (pcm->sync_ptr)
@@ -1189,6 +1211,10 @@ int pcm_prepare(struct pcm *pcm)
*/
int pcm_start(struct pcm *pcm)
{
if (pcm_state(pcm) == PCM_STATE_SETUP && pcm_prepare(pcm) != 0) {
return -1;
}
/* set appl_ptr and avail_min in kernel */
if (pcm_sync_ptr(pcm, 0) < 0)
return -1;
@@ -1402,15 +1428,6 @@ again:
return 0;
}
int pcm_state(struct pcm *pcm)
{
int err = pcm_sync_ptr(pcm, 0);
if (err < 0)
return err;
return pcm->mmap_status->state;
}
/** Waits for frames to be available for read or write operations.
* @param pcm A PCM handle.
* @param timeout The maximum amount of time to wait for, in terms of milliseconds.