corrected libfaad + added test_open back

This commit is contained in:
philippe44
2019-05-27 13:19:11 -07:00
parent ac322454ba
commit 881aead42f
7 changed files with 39 additions and 55 deletions

Binary file not shown.

View File

@@ -750,7 +750,7 @@ int main(int argc, char **argv) {
stream_init(log_stream, stream_buf_size);
#if DACAUDIO
output_init_dac(log_output, output_buf_size, output_params, rates, rate_delay, idle);
output_init_dac(log_output, output_device, output_buf_size, output_params, rates, rate_delay, idle);
#else
if (!strcmp(output_device, "-")) {
output_init_stdout(log_output, output_buf_size, output_params, rates, rate_delay);

View File

@@ -386,14 +386,12 @@ void output_init_common(log_level level, const char *device, unsigned output_buf
output.supported_rates[i] = rates[i];
}
}
#ifndef DACAUDIO
else {
if (!test_open(output.device, output.supported_rates, user_rates)) {
LOG_ERROR("unable to open output device: %s", output.device);
exit(0);
}
}
#endif
if (user_rates) {
for (i = 0; i < MAX_SUPPORTED_SAMPLERATES; ++i) {

View File

@@ -122,7 +122,7 @@ static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
}
void output_init_dac(log_level level, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle) {
void output_init_dac(log_level level, char *device, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle) {
loglevel = level;
LOG_INFO("init output BT");
@@ -188,8 +188,8 @@ void output_init_dac(log_level level, unsigned output_buf_size, char *params, un
/*
* Bluetooth audio source init Start
*/
output_init_common(level, "-", output_buf_size, rates, idle);
device = "BT";
output_init_common(level, device, output_buf_size, rates, idle);
//#if LINUX || OSX || FREEBSD || POSIX
// pthread_attr_t attr;
@@ -531,6 +531,17 @@ static int32_t bt_app_a2d_data_cb(uint8_t *data, int32_t len)
return frames * 4;
}
bool test_open(const char *device, unsigned rates[], bool userdef_rates) {
memset(rates, 0, MAX_SUPPORTED_SAMPLERATES * sizeof(unsigned));
if (!strcmp(device, "BT")) {
rates[0] = 44100;
} else {
unsigned _rates[] = { 96000, 88200, 48000, 44100, 32000, 0 };
memcpy(rates, _rates, sizeof(_rates));
}
return true;
}
static void a2d_app_heart_beat(void *arg)
{
bt_app_work_dispatch(bt_app_av_sm_hdlr, BT_APP_HEART_BEAT_EVT, NULL, 0, NULL);

View File

@@ -37,7 +37,7 @@ void set_volume(unsigned left, unsigned right) {
UNLOCK;
}
void output_init_dac(log_level level, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle) {
void output_init_dac(log_level level, char *device, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle) {
loglevel = level;
LOG_INFO("init output DAC");
@@ -58,13 +58,13 @@ void output_init_dac(log_level level, unsigned output_buf_size, char *params, un
if (!strcmp(params, "24")) output.format = S24_3LE;
if (!strcmp(params, "16")) output.format = S16_LE;
}
// ensure output rate is specified to avoid test open
if (!rates[0]) {
rates[0] = 44100;
}
output_init_common(level, "-", output_buf_size, rates, idle);
output_init_common(level, device, output_buf_size, rates, idle);
#if LINUX || OSX || FREEBSD || POSIX
pthread_attr_t attr;
@@ -119,7 +119,7 @@ static int _dac_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32
#endif
} else {
obuf = silencebuf;
#if !REPACK
IF_DSD(
@@ -143,7 +143,7 @@ static int _dac_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32
static void *output_thread() {
// buffer to hold output data so we can block on writing outside of output lock, allocated on init
u8_t *obuf = malloc(FRAME_BLOCK * BYTES_PER_FRAME);
unsigned frames = 0;
int frames = 0;
#if REPACK
LOCK;
@@ -161,7 +161,9 @@ static void *output_thread() {
}
UNLOCK;
#endif
#else
bytes_per_frame = BYTES_PER_FRAME;
#endif
while (running) {
@@ -183,8 +185,13 @@ static void *output_thread() {
UNLOCK;
if (frames) {
// do something with some of these frames...
usleep((frames * 1000 * 1000) / output.current_sample_rate);
if (output.device[0] == '-' && memcmp(optr, silencebuf, frames * bytes_per_frame)) {
fwrite(obuf, bytes_per_frame, frames, stdout);
LOG_INFO("writing frames %d", frames);
} else {
// do something with some of these frames...
usleep((frames * 1000 * 1000) / output.current_sample_rate);
}
frames = 0;
} else {
usleep((FRAME_BLOCK * 1000 * 1000) / output.current_sample_rate);
@@ -195,3 +202,10 @@ static void *output_thread() {
return 0;
}
bool test_open(const char *device, unsigned rates[], bool userdef_rates) {
unsigned _rates[] = { 96000, 88200, 48000, 44100, 32000, 0 };
memcpy(rates, _rates, sizeof(_rates));
return true;
}

View File

@@ -1,40 +0,0 @@
# Override some defaults so BT stack is enabled and
# Classic BT is enabled
CONFIG_BT_ENABLED=y
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CONTROLLER_MODE_BTDM=
CONFIG_BLUEDROID_ENABLED=y
CONFIG_CLASSIC_BT_ENABLED=y
CONFIG_A2DP_ENABLE=y
CONFIG_BT_SPP_ENABLED=n
CONFIG_GATTS_ENABLE=n
CONFIG_GATTC_ENABLE=n
CONFIG_BLE_SMP_ENABLE=n
SW_COEXIST_PREFERENCE_BALANCE=y
#enable SPIRAM
CONFIG_SPIRAM_SUPPORT=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_TYPE_AUTO=y
CONFIG_SPIRAM_SIZE=-1
CONFIG_SPIRAM_SPEED_40M=y
CONFIG_SPIRAM_MEMTEST=y
CONFIG_SPIRAM_CACHE_WORKAROUND=y
CONFIG_SPIRAM_BANKSWITCH_ENABLE=y
CONFIG_SPIRAM_BANKSWITCH_RESERVE=8
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=2048
CONFIG_PICO_PSRAM_CS_IO=10
CONFIG_MAIN_TASK_STACK_SIZE=8000
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
# CPU & threads options
ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0=
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1=y
CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=1

View File

@@ -723,7 +723,8 @@ void _pa_open(void);
// output_dac.c
#if DACAUDIO
void set_volume(unsigned left, unsigned right);
void output_init_dac(log_level level, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle);
bool test_open(const char *device, unsigned rates[], bool userdef_rates);
void output_init_dac(log_level level, char *device, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle);
void output_close_dac(void);
#endif