In an audio module: 1) removed a commented out block of code; 2) uint8_t -> unsigned char; 3) size_t -> int; 4) make audio_read() return a number of encoded bytes or -1 on an error.
This commit is contained in:
parent
0c7995d5fc
commit
b5d92489b8
13
src/audio.c
13
src/audio.c
@ -74,14 +74,7 @@ int audio_destroy(audio_t *aud) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int encLen = opus_encode_float(aud->opus_enc, (float *)input, frameCount, aud->opusBuf, aud->opusBufSz);
|
||||
(void)encLen;
|
||||
int frame_size = opus_decode_float(aud->opus_dec, aud->opusBuf, aud->opusBufSz, (float *)output, frameCount, 0);
|
||||
(void)frame_size;
|
||||
*/
|
||||
|
||||
int audio_read(audio_t *aud, uint8_t *output, size_t output_len) {
|
||||
int audio_read(audio_t *aud, unsigned char *output, int output_len) {
|
||||
PaError pa_err;
|
||||
|
||||
if ((pa_err = Pa_ReadStream(aud->stream, aud->buffer, aud->buffer_size)) != paNoError) {
|
||||
@ -95,10 +88,10 @@ int audio_read(audio_t *aud, uint8_t *output, size_t output_len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return encodedLen;
|
||||
}
|
||||
|
||||
int audio_write(audio_t *aud, const uint8_t *input, size_t input_len) {
|
||||
int audio_write(audio_t *aud, const unsigned char *input, int input_len) {
|
||||
PaError pa_err;
|
||||
|
||||
int frame_size = opus_decode_float(aud->opus_dec, input, input_len, aud->buffer, aud->buffer_size, 0);
|
||||
|
@ -16,13 +16,13 @@ typedef struct audio_t {
|
||||
OpusDecoder *opus_dec;
|
||||
|
||||
audio_sample_t *buffer;
|
||||
size_t buffer_size;
|
||||
int buffer_size;
|
||||
} audio_t;
|
||||
|
||||
int audio_init(audio_t *aud, int channels, int sample_rate, int frame_size);
|
||||
int audio_destroy(audio_t *aud);
|
||||
|
||||
int audio_read(audio_t *aud, uint8_t *output, size_t output_len);
|
||||
int audio_write(audio_t *aud, const uint8_t *input, size_t input_len);
|
||||
int audio_read(audio_t *aud, unsigned char *output, int output_len);
|
||||
int audio_write(audio_t *aud, const unsigned char *input, int input_len);
|
||||
|
||||
#endif /* _AUDIO_H_ */
|
Loading…
Reference in New Issue
Block a user