Skip to content

Commit

Permalink
using pulsesrc to set blocksize, fixed bug preventing you from accept…
Browse files Browse the repository at this point in the history
…ing another call
  • Loading branch information
naxuroqa committed Jul 11, 2014
1 parent e646709 commit aa0a34c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/core/AudioManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Venom {
public static AudioManager instance {get; private set;}

public static void init() throws AudioManagerError {
instance = new AudioManager({"","--gst-debug-level=3"});
instance = new AudioManager({""/*,"--gst-debug-level=3"*/});
}

private AudioManager(string[] args) throws AudioManagerError {
Expand All @@ -96,7 +96,7 @@ namespace Venom {

// output pipeline
pipeline_out = new Gst.Pipeline(PIPELINE_OUT);
audio_source_out = Gst.ElementFactory.make("autoaudiosrc", AUDIO_SOURCE_OUT);
audio_source_out = Gst.ElementFactory.make("pulsesrc", AUDIO_SOURCE_OUT);
audio_sink_out = (Gst.AppSink)Gst.ElementFactory.make("appsink", AUDIO_SINK_OUT);
pipeline_out.add_many(audio_source_out, audio_sink_out);
audio_source_out.link(audio_sink_out);
Expand All @@ -106,11 +106,13 @@ namespace Venom {
stdout.printf("Caps is [%s]\n", caps.to_string());
audio_source_in.caps = caps;
audio_sink_out.caps = caps;

((Gst.BaseSrc)audio_source_out).blocksize = (ToxAV.DefaultCodecSettings.audio_frame_duration * ToxAV.DefaultCodecSettings.audio_sample_rate) / 1000 * 2;
}

public static void audio_receive_callback(ToxAV.ToxAV toxav, int32 call_index, int16[] frames) {
stdout.printf("Got audio frames, of size: %d\n", frames.length * 2);
//instance.buffer_in(frames, frames.length);
//stdout.printf("Got audio frames, of size: %d\n", frames.length * 2);
instance.buffer_in(frames, frames.length);
}

public static void video_receive_callback(ToxAV.ToxAV toxav, int32 call_index, Vpx.Image frame) {
Expand Down Expand Up @@ -146,15 +148,18 @@ namespace Venom {
Memory.copy(gst_buf.data, buffer, len);

audio_source_in.push_buffer(gst_buf);
stdout.printf("pushed %i bytes to IN pipeline\n", len);
//stdout.printf("pushed %i bytes to IN pipeline\n", len);
return;
}

public int buffer_out(int16[] dest) {
Gst.Buffer gst_buf = audio_sink_out.pull_buffer();
int len = int.min(gst_buf.data.length, dest.length * 2);
Memory.copy(dest, gst_buf.data, len);
stdout.printf("pulled %i bytes from OUT pipeline\n", len);
//stdout.printf("pulled %i bytes from OUT pipeline\n", len);
if(gst_buf.data.length > dest.length * 2) {
stdout.printf("Pulled more data than space in buffer! (%i bytes)\n", gst_buf.data.length);
}
return len / 2;
}

Expand Down Expand Up @@ -182,8 +187,7 @@ namespace Venom {
for(int i = 0; i < MAX_CALLS; i++) {
if(calls[i].active) {

//FIXME should be this but returns -1
prep_frame_ret = toxav.prepare_audio_frame(i, enc_buffer, buffer, buffer.length);
prep_frame_ret = toxav.prepare_audio_frame(i, enc_buffer, buffer, buffer_size);
if(prep_frame_ret <= 0) {
stdout.printf("prepare_audio_frame returned an error: %i\n", prep_frame_ret);
continue;
Expand Down Expand Up @@ -226,6 +230,7 @@ namespace Venom {
return;
}

toxav.kill_transmission(c.call_index);
calls[c.call_index].active = false;
number_of_calls--;

Expand Down

0 comments on commit aa0a34c

Please sign in to comment.