Use fixed point

This commit is contained in:
Mark Hills 2014-05-30 11:18:31 +01:00
parent 0b53299941
commit e375ceef5a
3 changed files with 8 additions and 8 deletions

View File

@ -53,7 +53,7 @@ int set_alsa_hw(snd_pcm_t *pcm,
r = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED); r = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED);
CHK("snd_pcm_hw_params_set_access", r); CHK("snd_pcm_hw_params_set_access", r);
r = snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_FLOAT); r = snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_S16);
CHK("snd_pcm_hw_params_set_format", r); CHK("snd_pcm_hw_params_set_format", r);
r = snd_pcm_hw_params_set_rate(pcm, hw, rate, 0); r = snd_pcm_hw_params_set_rate(pcm, hw, rate, 0);

8
rx.c
View File

@ -70,15 +70,15 @@ static int play_one_frame(void *packet,
const unsigned int channels) const unsigned int channels)
{ {
int r; int r;
float *pcm; int16_t *pcm;
snd_pcm_sframes_t f, samples = 1920; snd_pcm_sframes_t f, samples = 1920;
pcm = alloca(sizeof(float) * samples * channels); pcm = alloca(sizeof(*pcm) * samples * channels);
if (packet == NULL) { if (packet == NULL) {
r = opus_decode_float(decoder, NULL, 0, pcm, samples, 1); r = opus_decode(decoder, NULL, 0, pcm, samples, 1);
} else { } else {
r = opus_decode_float(decoder, packet, len, pcm, samples, 0); r = opus_decode(decoder, packet, len, pcm, samples, 0);
} }
if (r < 0) { if (r < 0) {
fprintf(stderr, "opus_decode: %s\n", opus_strerror(r)); fprintf(stderr, "opus_decode: %s\n", opus_strerror(r));

6
tx.c
View File

@ -60,13 +60,13 @@ static int send_one_frame(snd_pcm_t *snd,
const unsigned int ts_per_frame, const unsigned int ts_per_frame,
RtpSession *session) RtpSession *session)
{ {
float *pcm; int16_t *pcm;
void *packet; void *packet;
ssize_t z; ssize_t z;
snd_pcm_sframes_t f; snd_pcm_sframes_t f;
static unsigned int ts = 0; static unsigned int ts = 0;
pcm = alloca(sizeof(float) * samples * channels); pcm = alloca(sizeof(*pcm) * samples * channels);
packet = alloca(bytes_per_frame); packet = alloca(bytes_per_frame);
f = snd_pcm_readi(snd, pcm, samples); f = snd_pcm_readi(snd, pcm, samples);
@ -91,7 +91,7 @@ static int send_one_frame(snd_pcm_t *snd,
return 0; return 0;
} }
z = opus_encode_float(encoder, pcm, samples, packet, bytes_per_frame); z = opus_encode(encoder, pcm, samples, packet, bytes_per_frame);
if (z < 0) { if (z < 0) {
fprintf(stderr, "opus_encode_float: %s\n", opus_strerror(z)); fprintf(stderr, "opus_encode_float: %s\n", opus_strerror(z));
return -1; return -1;