00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "JackAudioAdapter.h"
00021 #include "JackConstants.h"
00022 #include <stdio.h>
00023
00024 namespace Jack
00025 {
00026
00027 #ifdef JACK_MONITOR
00028
00029 void MeasureTable::Write(int time1, int time2, float r1, float r2, int pos1, int pos2)
00030 {
00031 int pos = (++fCount) % TABLE_MAX;
00032 fTable[pos].time1 = time1;
00033 fTable[pos].time2 = time2;
00034 fTable[pos].r1 = r1;
00035 fTable[pos].r2 = r2;
00036 fTable[pos].pos1 = pos1;
00037 fTable[pos].pos2 = pos2;
00038 }
00039
00040 void MeasureTable::Save()
00041 {
00042 char buffer[1024];
00043 FILE* file = fopen("JackAudioAdapter.log", "w");
00044
00045 int max = (fCount) % TABLE_MAX - 1;
00046 for (int i = 1; i < max; i++)
00047 {
00048 fprintf(file, "%d \t %d \t %d \t %f \t %f \t %d \t %d \n",
00049 fTable[i].delta, fTable[i+1].time1 - fTable[i].time1,
00050 fTable[i+1].time2 - fTable[i].time2,
00051 fTable[i].r1, fTable[i].r2, fTable[i].pos1, fTable[i].pos2);
00052 }
00053 fclose(file);
00054
00055
00056 file = fopen("AdapterTiming1.plot", "w");
00057 fprintf(file, "set multiplot\n");
00058 fprintf(file, "set grid\n");
00059 fprintf(file, "set title \"Audio adapter timing\"\n");
00060 fprintf(file, "set xlabel \"audio cycles\"\n");
00061 fprintf(file, "set ylabel \"frames\"\n");
00062 fprintf(file, "plot ");
00063 sprintf(buffer, "\"JackAudioAdapter.log\" using 2 title \"Consumer interrupt period\" with lines,");
00064 fprintf(file, buffer);
00065 sprintf(buffer, "\"JackAudioAdapter.log\" using 3 title \"Producer interrupt period\" with lines");
00066 fprintf(file, buffer);
00067 fclose(file);
00068
00069
00070 file = fopen("AdapterTiming2.plot", "w");
00071 fprintf(file, "set multiplot\n");
00072 fprintf(file, "set grid\n");
00073 fprintf(file, "set title \"Audio adapter timing\"\n");
00074 fprintf(file, "set xlabel \"audio cycles\"\n");
00075 fprintf(file, "set ylabel \"resampling ratio\"\n");
00076 fprintf(file, "plot ");
00077 sprintf(buffer, "\"JackAudioAdapter.log\" using 4 title \"Ratio 1\" with lines,");
00078 fprintf(file, buffer);
00079 sprintf(buffer, "\"JackAudioAdapter.log\" using 5 title \"Ratio 2\" with lines");
00080 fprintf(file, buffer);
00081 fclose(file);
00082
00083
00084 file = fopen("AdapterTiming3.plot", "w");
00085 fprintf(file, "set multiplot\n");
00086 fprintf(file, "set grid\n");
00087 fprintf(file, "set title \"Audio adapter timing\"\n");
00088 fprintf(file, "set xlabel \"audio cycles\"\n");
00089 fprintf(file, "set ylabel \"frames\"\n");
00090 fprintf(file, "plot ");
00091 sprintf(buffer, "\"JackAudioAdapter.log\" using 6 title \"Frames position in consumer ringbuffer\" with lines,");
00092 fprintf(file, buffer);
00093 sprintf(buffer, "\"JackAudioAdapter.log\" using 7 title \"Frames position in producer ringbuffer\" with lines");
00094 fprintf(file, buffer);
00095 fclose(file);
00096 }
00097
00098 #endif
00099
00100 void JackAudioAdapterInterface::ResetRingBuffers()
00101 {
00102 int i;
00103 for (i = 0; i < fCaptureChannels; i++)
00104 fCaptureRingBuffer[i]->Reset();
00105 for (i = 0; i < fPlaybackChannels; i++)
00106 fPlaybackRingBuffer[i]->Reset();
00107 }
00108
00109 void JackAudioAdapterInterface::ResampleFactor ( jack_nframes_t& frame1, jack_nframes_t& frame2 )
00110 {
00111 jack_time_t time = jack_get_time();
00112
00113 if ( !fRunning )
00114 {
00115
00116 fRunning = true;
00117 fHostDLL.Init ( time );
00118 fAdaptedDLL.Init ( time );
00119 frame1 = 1;
00120 frame2 = 1;
00121 }
00122 else
00123 {
00124
00125 fAdaptedDLL.IncFrame(time);
00126 jack_nframes_t time1 = fHostDLL.Time2Frames(time);
00127 jack_nframes_t time2 = fAdaptedDLL.Time2Frames(time);
00128 frame1 = time1;
00129 frame2 = time2;
00130 jack_log("JackAudioAdapterInterface::ResampleFactor time1 = %ld time2 = %ld src_ratio_input = %f src_ratio_output = %f",
00131 long(time1), long(time2), double(time1) / double(time2), double(time2) / double(time1));
00132 }
00133 }
00134
00135 int JackAudioAdapterInterface::Open()
00136 {
00137 return 0;
00138 }
00139
00140 int JackAudioAdapterInterface::Close()
00141 {
00142 return 0;
00143 }
00144
00145 }