Mercurial > hg > svapp
comparison audioio/AudioPortAudioTarget.cpp @ 96:e177e6ee7c12 sv1-v1.2pre5
* PortAudio playback fixes
author | Chris Cannam |
---|---|
date | Wed, 13 Feb 2008 15:49:26 +0000 |
parents | dd6d0bc05030 |
children | ccdc5b30e54c |
comparison
equal
deleted
inserted
replaced
95:dd6d0bc05030 | 96:e177e6ee7c12 |
---|---|
62 err = Pa_OpenDefaultStream(&m_stream, 0, 2, paFloat32, | 62 err = Pa_OpenDefaultStream(&m_stream, 0, 2, paFloat32, |
63 m_sampleRate, m_bufferSize, 0, | 63 m_sampleRate, m_bufferSize, 0, |
64 processStatic, this); | 64 processStatic, this); |
65 #else | 65 #else |
66 PaStreamParameters op; | 66 PaStreamParameters op; |
67 op.device = 0; | 67 op.device = Pa_GetDefaultOutputDevice(); |
68 op.channelCount = 2; | 68 op.channelCount = 2; |
69 op.sampleFormat = paFloat32; | 69 op.sampleFormat = paFloat32; |
70 op.suggestedLatency = 0.2; | 70 op.suggestedLatency = 0.2; |
71 op.hostApiSpecificStreamInfo = 0; | 71 op.hostApiSpecificStreamInfo = 0; |
72 err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate, | 72 err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate, |
80 std::cerr << "WARNING: AudioPortAudioTarget: Failed to open PortAudio stream with default frames per buffer, trying again with fixed frames per buffer..." << std::endl; | 80 std::cerr << "WARNING: AudioPortAudioTarget: Failed to open PortAudio stream with default frames per buffer, trying again with fixed frames per buffer..." << std::endl; |
81 | 81 |
82 err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate, | 82 err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate, |
83 1024, | 83 1024, |
84 paNoFlag, processStatic, this); | 84 paNoFlag, processStatic, this); |
85 m_bufferSize = 1024; | |
85 } | 86 } |
86 #endif | 87 #endif |
87 | 88 |
88 if (err != paNoError) { | 89 if (err != paNoError) { |
89 std::cerr << "ERROR: AudioPortAudioTarget: Failed to open PortAudio stream: " << Pa_GetErrorText(err) << std::endl; | 90 std::cerr << "ERROR: AudioPortAudioTarget: Failed to open PortAudio stream: " << Pa_GetErrorText(err) << std::endl; |
93 } | 94 } |
94 | 95 |
95 #ifndef HAVE_PORTAUDIO_V18 | 96 #ifndef HAVE_PORTAUDIO_V18 |
96 const PaStreamInfo *info = Pa_GetStreamInfo(m_stream); | 97 const PaStreamInfo *info = Pa_GetStreamInfo(m_stream); |
97 m_latency = int(info->outputLatency * m_sampleRate + 0.001); | 98 m_latency = int(info->outputLatency * m_sampleRate + 0.001); |
98 m_bufferSize = m_latency; | 99 if (m_bufferSize < m_latency) m_bufferSize = m_latency; |
99 #endif | 100 #endif |
100 | 101 |
101 std::cerr << "PortAudio latency = " << m_latency << " frames" << std::endl; | 102 std::cerr << "PortAudio latency = " << m_latency << " frames" << std::endl; |
102 | 103 |
103 err = Pa_StartStream(m_stream); | 104 err = Pa_StartStream(m_stream); |