[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/engine AudioDevice.cpp defines.h P...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/engine AudioDevice.cpp defines.h P... |
Date: |
Tue, 24 Apr 2007 14:45:55 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/04/24 14:45:55
Modified files:
src/engine : AudioDevice.cpp defines.h PADriver.cpp
Log message:
* do not use PA cpu usage info, seems not to work on windows
Use our own implementation!
* check if PA has an in/output device available!
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/AudioDevice.cpp?cvsroot=traverso&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/defines.h?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/PADriver.cpp?cvsroot=traverso&r1=1.3&r2=1.4
Patches:
Index: AudioDevice.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/engine/AudioDevice.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- AudioDevice.cpp 22 Mar 2007 15:59:23 -0000 1.26
+++ AudioDevice.cpp 24 Apr 2007 14:45:55 -0000 1.27
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: AudioDevice.cpp,v 1.26 2007/03/22 15:59:23 r_sijrier Exp $
+$Id: AudioDevice.cpp,v 1.27 2007/04/24 14:45:55 r_sijrier Exp $
*/
#include "AudioDevice.h"
@@ -625,8 +625,8 @@
#endif
#if defined (PORTAUDIO_SUPPORT)
- if (driver && m_driverType == "PortAudio")
- return ((PADriver*)driver)->get_cpu_load();
+/* if (driver && m_driverType == "PortAudio")
+ return ((PADriver*)driver)->get_cpu_load();*/
#endif
Index: defines.h
===================================================================
RCS file: /sources/traverso/traverso/src/engine/defines.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- defines.h 18 Apr 2007 00:08:01 -0000 1.5
+++ defines.h 24 Apr 2007 14:45:55 -0000 1.6
@@ -117,12 +117,12 @@
#if defined(_MSC_VER) || defined(__MINGW32__)
-#include <windows.h>
+#include <Windows.h>
static inline int gettimeofday(struct timeval* tp, void* tzp) {
DWORD t;
-// t = timeGetTime();
- t = 0;
+ t = timeGetTime();
+// t = 0;
tp->tv_sec = t / 1000;
tp->tv_usec = t % 1000;
/* 0 indicates that the call succeeded. */
Index: PADriver.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/engine/PADriver.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PADriver.cpp 2 Apr 2007 09:52:31 -0000 1.3
+++ PADriver.cpp 24 Apr 2007 14:45:55 -0000 1.4
@@ -50,13 +50,33 @@
}
-int PADriver::_read( nframes_t nframes )
+int PADriver::_read(nframes_t nframes)
{
- // See the JackDriver for an example, but remember that you have to do
de-interleaving here!!
+ float* in = (float*) paInputBuffer;
+
+ if (!captureChannels.size()) {
+ return 0;
+ }
+
+ if (!captureChannels.at(0)->has_data()) {
+ return 0;
+ }
+
+ float* datachan0 = captureChannels.at(0)->get_data();
+ float* datachan1 = captureChannels.at(1)->get_data();
+
+ int j=0;
+
+ for (uint i=0; i<nframes*2; i++) {
+ datachan0[j] = in[i++];
+ datachan1[j] = in[i];
+ j++;
+ }
+
return 1;
}
-int PADriver::_write( nframes_t nframes )
+int PADriver::_write(nframes_t nframes)
{
// TODO use the found maxchannel count instead of assuming 2 !! ( ==
playbackChannels.size() )
// Properly iterate over all channel buffers to mixdown the audio
@@ -67,6 +87,10 @@
// least, turn the volume of your speakers down, if you want them and
your ears
// to last a little longer :D
+ if (!playbackChannels.size()) {
+ return 0;
+ }
+
float* out = (float*) paOutputBuffer;
float* datachan0 = playbackChannels.at(0)->get_data();
float* datachan1 = playbackChannels.at(1)->get_data();
@@ -117,7 +141,7 @@
for (int i=0; i<Pa_GetHostApiCount(); ++i) {
const PaHostApiInfo* inf = Pa_GetHostApiInfo(i);
- info().warning(tr("hostapi name is %1, deviceCount is
%2").arg(inf->name).arg(inf->deviceCount));
+// info().warning(tr("hostapi name is %1, deviceCount is
%2").arg(inf->name).arg(inf->deviceCount));
if (hostapi == "alsa" && inf->type == paALSA) {
printf("PADriver:: Found alsa host api, using device
%d\n", i);
@@ -156,20 +180,25 @@
// Configure output parameters.
// TODO get the max channel count, and use that instead, of assuming 2
- outputParameters.device = Pa_GetDefaultOutputDevice();
+ PaDeviceIndex result = Pa_GetDefaultOutputDevice();
+ if( result != paNoDevice) {
+ outputParameters.device = result;
outputParameters.channelCount = 2;
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point
output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo(
outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
+ }
- inputParameters.device = deviceindex;
+ result = Pa_GetDefaultInputDevice();
+ if( result != paNoDevice) {
+ inputParameters.device = result;
inputParameters.channelCount = 2;
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point
output */
inputParameters.suggestedLatency = Pa_GetDeviceInfo(
inputParameters.device )->defaultLowInputLatency;
inputParameters.hostApiSpecificStreamInfo = NULL;
+ }
/* Open an audio I/O stream. */
- // TODO configure the inputParameters, and give as argument instead of
0 (&inputParameters)
err = Pa_OpenStream(
&m_paStream,
&inputParameters, // The input parameter
@@ -203,7 +232,7 @@
}
// TODO use the found maxchannel count for the capture stream, instead
of assuming 0 !!
- for (int chn = 0; chn < 0; chn++) {
+ for (int chn = 0; chn < 2; chn++) {
snprintf (buf, sizeof(buf) - 1, "capture_%d", chn+1);
@@ -297,11 +326,15 @@
PADriver* driver = static_cast<PADriver *> (arg);
+ driver->device->transport_cycle_start(get_microseconds());
+
driver->paInputBuffer = inputBuffer;
driver->paOutputBuffer = outputBuffer;
driver->process_callback (framesPerBuffer);
+ driver->device->transport_cycle_end(get_microseconds());
+
return 0;
}
- [Traverso-commit] traverso/src/engine AudioDevice.cpp defines.h P...,
Remon Sijrier <=