void setup_audio( ) { /* FIXME hard coded default */ n_channels = 2; audio_in_pipe = new Pipe<AudioPacket *>(OUT_PIPE_SIZE); /* FIXME magic 29.97 related number */ /* Set up empty audio packet for prerolling */ current_audio_pkt = new AudioPacket(48000, n_channels, 2, 25626); samples_written_from_current_audio_pkt = 0; assert(deckLinkOutput != NULL); if (deckLinkOutput->SetAudioCallback(this) != S_OK) { throw std::runtime_error( "Failed to set DeckLink audio callback" ); } if (deckLinkOutput->EnableAudioOutput( bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, n_channels, bmdAudioOutputStreamContinuous) != S_OK) { throw std::runtime_error( "Failed to enable DeckLink audio output" ); } audio_preroll_done = 0; if (deckLinkOutput->BeginAudioPreroll( ) != S_OK) { throw std::runtime_error( "Failed to begin DeckLink audio preroll" ); } while (audio_preroll_done == 0) { /* FIXME: busy wait */ } if (deckLinkOutput->EndAudioPreroll( ) != S_OK) { throw std::runtime_error( "Failed to end DeckLink audio preroll" ); } }
void setup_audio( ) { IOAudioPacket preroll_audio(8008, n_channels); preroll_audio.zero( ); audio_in_pipe = new Pipe<IOAudioPacket *>(OUT_PIPE_SIZE); audio_fifo = new AudioFIFO<int16_t>(n_channels); audio_fifo->add_packet(&preroll_audio); assert(deckLinkOutput != NULL); if (deckLinkOutput->SetAudioCallback(this) != S_OK) { throw std::runtime_error( "Failed to set DeckLink audio callback" ); } if (deckLinkOutput->EnableAudioOutput( bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, n_channels, bmdAudioOutputStreamContinuous) != S_OK) { throw std::runtime_error( "Failed to enable DeckLink audio output" ); } audio_preroll_done = 0; if (deckLinkOutput->BeginAudioPreroll( ) != S_OK) { throw std::runtime_error( "Failed to begin DeckLink audio preroll" ); } while (audio_preroll_done == 0) { /* FIXME: busy wait */ } if (deckLinkOutput->EndAudioPreroll( ) != S_OK) { throw std::runtime_error( "Failed to end DeckLink audio preroll" ); } }
bool start( unsigned preroll ) { m_displayMode = getDisplayMode(); if ( !m_displayMode ) { mlt_log_error( &m_consumer, "Profile is not compatible with decklink.\n" ); return false; } // Set the video output mode if ( S_OK != m_deckLinkOutput->EnableVideoOutput( m_displayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) ) { mlt_log_error( &m_consumer, "Failed to enable video output\n" ); return false; } // Set the audio output mode m_channels = 2; if ( S_OK != m_deckLinkOutput->EnableAudioOutput( bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, m_channels, bmdAudioOutputStreamContinuous ) ) { mlt_log_error( &m_consumer, "Failed to enable audio output\n" ); stop(); return false; } m_fifo = sample_fifo_init(); // Preroll m_isPrerolling = true; m_prerollCounter = 0; m_preroll = preroll < PREROLL_MINIMUM ? PREROLL_MINIMUM : preroll; m_count = 0; m_deckLinkOutput->BeginAudioPreroll(); return true; }