Skip to content
Permalink
Browse files

Increment sample_no on muxed audio stream

  • Loading branch information
bear101 committed Jan 12, 2020
1 parent 9e550d4 commit f6cd11359410b5b1d02c4a6f0b52fd7710c7f30f
@@ -126,12 +126,13 @@ namespace media
timestamp = GETTIMESTAMP();
}

AudioFrame(const AudioFormat& infmt, short* input_buf, int insamples)
AudioFrame(const AudioFormat& infmt, short* input_buf, int insamples, ACE_UINT32 sampleindex = 0)
: AudioFrame()
{
inputfmt = infmt;
input_buffer = input_buf;
input_samples = insamples;
sample_no = sampleindex;
}

AudioFrame(ACE_Message_Block* mb)
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2005-2018, BearWare.dk
*
*
* Contact Information:
*
* Bjoern D. Rasmussen
@@ -55,6 +55,9 @@ bool AudioContainer::AddAudio(int userid, int stream_type,
if(m_active_srcs.find(entry.entryid) == m_active_srcs.end())
return false;

// MYTRACE(ACE_TEXT("Add audio from #%d to container %p. Offset %u. Samples: %u. Timestamp: %u\n"),
// userid, this, frame.sample_no, frame.input_samples, frame.timestamp);

// MYTRACE(ACE_TEXT("Adding audio #%d of channels %d\n"), userid, channels);
ACE_Message_Block* mb = AudioFrameToMsgBlock(frame);

@@ -81,7 +84,7 @@ bool AudioContainer::AddAudio(int userid, int stream_type,
mb->release();
return false;
}

q->high_water_mark(1024*128);
q->low_water_mark(1024*128);

@@ -126,7 +129,7 @@ ACE_Message_Block* AudioContainer::AcquireAudioFrame(int userid, int stream_type
void AudioContainer::ReleaseAllAudio()
{
std::lock_guard<std::recursive_mutex> g(m_store_mtx);

audiostore_t::iterator ii = m_container.begin();
while(ii != m_container.end())
{
@@ -68,10 +68,14 @@ bool AudioMuxer::StartThread(const teamtalk::AudioCodec& codec)
if(samples <= 0)
return false;

MYTRACE(ACE_TEXT("Starting AudioMuxer with sample rate %d and callback %d\n"),
GetAudioCodecSampleRate(codec), GetAudioCodecCbSamples(codec));

m_muxed_audio.resize(samples);

m_codec = codec;

m_sample_no = 0;
m_last_flush_time = GETTIMESTAMP();

m_thread.reset(new std::thread(&AudioMuxer::Run, this));
@@ -292,6 +296,9 @@ void AudioMuxer::QueueUserAudio(int userid, const short* rawAudio,

std::unique_lock<std::recursive_mutex> g(m_mutex);

// MYTRACE(ACE_TEXT("Add audio from #%d to audiomuxer %p. Offset %u. Samples %d\n"),
// userid, this, sample_no, n_samples);

ACE_Message_Queue<ACE_MT_SYNCH>* q;
user_audio_queue_t::iterator ii = m_audio_queue.find(userid);
if(ii == m_audio_queue.end())
@@ -602,7 +609,8 @@ void AudioMuxer::WriteAudio(int cb_samples)
TTASSERT(cb_samples == GetAudioCodecFramesPerPacket(m_codec)*framesize);

media::AudioFrame frame(media::AudioFormat(samplerate, channels),
&m_muxed_audio[0], cb_samples);
&m_muxed_audio[0], cb_samples, m_sample_no);

if (m_muxcallback)
{
m_muxcallback(frame);
@@ -637,4 +645,6 @@ void AudioMuxer::WriteAudio(int cb_samples)

if(m_wavefile)
m_wavefile->AppendSamples(&m_muxed_audio[0], cb_samples);

m_sample_no += cb_samples;
}
@@ -97,7 +97,8 @@ class AudioMuxer : private TimerListener
std::recursive_mutex m_mutex;
std::shared_ptr< std::thread > m_thread;

ACE_UINT32 m_last_flush_time;
ACE_UINT32 m_sample_no = 0;
ACE_UINT32 m_last_flush_time = 0;
teamtalk::AudioCodec m_codec;

wavepcmfile_t m_wavefile;

0 comments on commit f6cd113

Please sign in to comment.
You can’t perform that action at this time.