1#!/bin/bash
2# Use SED to convert the Oboe API to the AAudio API
3
4echo "Convert Oboe names to AAudio names"
5
6echo "Top is ${ANDROID_BUILD_TOP}"
7LIBOBOE_DIR=${ANDROID_BUILD_TOP}/frameworks/av/media/liboboe
8echo "LIBOBOE_DIR is ${LIBOBOE_DIR}"
9OBOESERVICE_DIR=${ANDROID_BUILD_TOP}/frameworks/av/services/oboeservice
10echo "OBOESERVICE_DIR is ${OBOESERVICE_DIR}"
11OBOETEST_DIR=${ANDROID_BUILD_TOP}/cts/tests/tests/nativemedia/aaudio/src/
12echo "OBOETEST_DIR is ${OBOETEST_DIR}"
13
14function convertPathPattern {
15    path=$1
16    pattern=$2
17    find $path -type f  -name $pattern -exec sed -i -f ${LIBOBOE_DIR}/scripts/oboe_to_aaudio.sed {} \;
18}
19
20function convertPath {
21    path=$1
22    convertPathPattern $1 '*.cpp'
23    convertPathPattern $1 '*.h'
24    # the mk match does not work!
25    convertPathPattern $1 '*.mk'
26    convertPathPattern $1 '*.md'
27    convertPathPattern $1 '*.bp'
28}
29
30#convertPath ${LIBOBOE_DIR}/examples
31#convertPath ${LIBOBOE_DIR}/include
32#convertPath ${LIBOBOE_DIR}/src
33#convertPath ${LIBOBOE_DIR}/tests
34convertPath ${LIBOBOE_DIR}
35convertPathPattern ${LIBOBOE_DIR} Android.mk
36convertPathPattern ${LIBOBOE_DIR} liboboe.map.txt
37
38convertPath ${OBOESERVICE_DIR}
39convertPathPattern ${OBOESERVICE_DIR} Android.mk
40
41convertPathPattern ${OBOETEST_DIR} test_aaudio.cpp
42
43mv ${LIBOBOE_DIR}/include/oboe ${LIBOBOE_DIR}/include/aaudio
44mv ${LIBOBOE_DIR}/include/aaudio/OboeAudio.h ${LIBOBOE_DIR}/include/aaudio/AAudio.h
45mv ${OBOESERVICE_DIR}/OboeService.h ${OBOESERVICE_DIR}/AAudioServiceDefinitions.h
46mv ${LIBOBOE_DIR}/tests/test_oboe_api.cpp ${LIBOBOE_DIR}/tests/test_aaudio_api.cpp
47
48# Rename files with Oboe in the name.
49find -name "*OboeAudioService*.cpp"      | rename -v "s/OboeAudioService/AAudioService/g"
50find -name "*OboeAudioService*.h"      | rename -v "s/OboeAudioService/AAudioService/g"
51find -name "*Oboe*.cpp"      | rename -v "s/Oboe/AAudio/g"
52find -name "*Oboe*.h"        | rename -v "s/Oboe/AAudio/g"
53