Compare commits

...

1 Commits

Author SHA1 Message Date
Hoan Luu Huu 5fd58ba6e5 fixed different voice quality while using playht (#111) 2024-09-16 15:56:10 -04:00
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -451,12 +451,12 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
return 0; return 0;
} }
/* cache file will stay in the mp3 format for size (smaller) and simplicity */
if (conn->file) fwrite(data, sizeof(uint8_t), bytes_received, conn->file);
pcm_data = convert_mp3_to_linear(conn, data, bytes_received); pcm_data = convert_mp3_to_linear(conn, data, bytes_received);
size_t bytesResampled = pcm_data.size() * sizeof(uint16_t); size_t bytesResampled = pcm_data.size() * sizeof(uint16_t);
/* cache same data to avoid streaming and cached audio quality is different*/
if (conn->file) fwrite(pcm_data.data(), sizeof(uint8_t), bytesResampled, conn->file);
// Resize the buffer if necessary // Resize the buffer if necessary
if (cBuffer->capacity() - cBuffer->size() < (bytesResampled / sizeof(uint16_t))) { if (cBuffer->capacity() - cBuffer->size() < (bytesResampled / sizeof(uint16_t))) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "write_cb growing buffer\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "write_cb growing buffer\n");
+3 -3
View File
@@ -452,12 +452,12 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
return 0; return 0;
} }
/* cache file will stay in the mp3 format for size (smaller) and simplicity */
if (conn->file) fwrite(data, sizeof(uint8_t), bytes_received, conn->file);
pcm_data = convert_mp3_to_linear(conn, data, bytes_received); pcm_data = convert_mp3_to_linear(conn, data, bytes_received);
size_t bytesResampled = pcm_data.size() * sizeof(uint16_t); size_t bytesResampled = pcm_data.size() * sizeof(uint16_t);
/* cache same data to avoid streaming and cached audio quality is different*/
if (conn->file) fwrite(pcm_data.data(), sizeof(uint8_t), bytesResampled, conn->file);
// Resize the buffer if necessary // Resize the buffer if necessary
if (cBuffer->capacity() - cBuffer->size() < (bytesResampled / sizeof(uint16_t))) { if (cBuffer->capacity() - cBuffer->size() < (bytesResampled / sizeof(uint16_t))) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "write_cb growing buffer\n"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "write_cb growing buffer\n");