Fix bytes-written calculation.
This commit is contained in:
parent
5886074bc0
commit
cf16398927
@ -182,7 +182,6 @@ void guac_rdpsnd_process_message_wave_info(guac_rdpsndPlugin* rdpsnd, audio_stre
|
|||||||
rdpsnd->expectingWave = true;
|
rdpsnd->expectingWave = true;
|
||||||
|
|
||||||
audio_stream_begin(audio, 22050, 2, 16); /* FIXME: Hard-coding rates */
|
audio_stream_begin(audio, 22050, 2, 16); /* FIXME: Hard-coding rates */
|
||||||
audio_stream_write_pcm(audio, rdpsnd->waveData, 4);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,20 +193,13 @@ void rdpsnd_process_message_wave(guac_rdpsndPlugin* rdpsnd,
|
|||||||
|
|
||||||
STREAM* output_stream;
|
STREAM* output_stream;
|
||||||
|
|
||||||
int size;
|
unsigned char* buffer = stream_get_head(input_stream);
|
||||||
unsigned char* buffer;
|
|
||||||
|
|
||||||
rdpsnd->expectingWave = 0;
|
rdpsnd->expectingWave = 0;
|
||||||
memcpy(stream_get_head(input_stream), rdpsnd->waveData, 4);
|
memcpy(buffer, rdpsnd->waveData, 4);
|
||||||
if (stream_get_size(input_stream) != rdpsnd->waveDataSize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = stream_get_head(input_stream);
|
|
||||||
size = stream_get_size(input_stream);
|
|
||||||
|
|
||||||
/* Write rest of audio packet */
|
/* Write rest of audio packet */
|
||||||
audio_stream_write_pcm(audio, buffer, size);
|
audio_stream_write_pcm(audio, buffer, rdpsnd->waveDataSize);
|
||||||
audio_stream_end(audio);
|
audio_stream_end(audio);
|
||||||
|
|
||||||
output_stream = stream_new(8);
|
output_stream = stream_new(8);
|
||||||
|
@ -84,15 +84,17 @@ void audio_stream_begin(audio_stream* audio, int rate, int channels, int bps) {
|
|||||||
|
|
||||||
void audio_stream_end(audio_stream* audio) {
|
void audio_stream_end(audio_stream* audio) {
|
||||||
|
|
||||||
/* Calculate duration of PCM data */
|
int duration;
|
||||||
int duration =
|
|
||||||
audio->pcm_bytes_written * 1000 * 8 / audio->rate
|
|
||||||
/ audio->channels / audio->bps;
|
|
||||||
|
|
||||||
/* Flush stream and finish encoding */
|
/* Flush stream and finish encoding */
|
||||||
audio_stream_flush(audio);
|
audio_stream_flush(audio);
|
||||||
audio->encoder->end_handler(audio);
|
audio->encoder->end_handler(audio);
|
||||||
|
|
||||||
|
/* Calculate duration of PCM data */
|
||||||
|
duration =
|
||||||
|
audio->pcm_bytes_written * 1000 * 8 / audio->rate
|
||||||
|
/ audio->channels / audio->bps;
|
||||||
|
|
||||||
/* Send audio */
|
/* Send audio */
|
||||||
guac_protocol_send_audio(audio->stream->socket,
|
guac_protocol_send_audio(audio->stream->socket,
|
||||||
0, "audio/ogg" /* FIXME: Hard-coded mimetype */,
|
0, "audio/ogg" /* FIXME: Hard-coded mimetype */,
|
||||||
|
Loading…
Reference in New Issue
Block a user