2 #include "playbackconfig.h"
3 #include "device1394input.h"
4 #include "device1394output.h"
5 #include "iec61883input.h"
6 #include "iec61883output.h"
7 #include "preferences.h"
8 #include "recordconfig.h"
9 #include "videoconfig.h"
10 #include "videodevice.h"
12 #define SAMPLES_PER_FRAME 2048
14 Audio1394::Audio1394(AudioDevice *device)
15 : AudioLowLevel(device)
21 Audio1394::~Audio1394()
26 int Audio1394::initialize()
34 int Audio1394::open_input()
37 if(!input_thread && !input_iec)
39 // Lock the channels for the DV format
40 device->in_channels = 2;
42 bytes_per_sample = device->in_channels * device->in_bits / 8;
45 if(device->driver == AUDIO_DV1394 ||
46 device->driver == AUDIO_1394)
48 input_thread = new Device1394Input;
49 result = input_thread->open(device->in_config->firewire_path,
50 device->in_config->firewire_port,
51 device->in_config->firewire_channel,
54 device->in_samplerate,
61 input_iec = new IEC61883Input;
62 result = input_iec->open(device->in_config->firewire_port,
63 device->in_config->firewire_channel,
66 device->in_samplerate,
87 int Audio1394::open_output()
89 if(!output_thread && !output_iec)
91 // Lock the channels for the DV format
92 device->out_channels = 2;
93 device->out_bits = 16;
94 bytes_per_sample = device->out_channels * device->out_bits / 8;
97 if(device->driver == AUDIO_DV1394)
99 output_thread = new Device1394Output(device);
100 output_thread->open(device->out_config->dv1394_path,
101 device->out_config->dv1394_port,
102 device->out_config->dv1394_channel,
104 device->out_channels,
106 device->out_samplerate,
107 device->out_config->dv1394_syt);
110 if(device->driver == AUDIO_1394)
112 output_thread = new Device1394Output(device);
113 output_thread->open(device->out_config->firewire_path,
114 device->out_config->firewire_port,
115 device->out_config->firewire_channel,
117 device->out_channels,
119 device->out_samplerate,
120 device->out_config->firewire_syt);
124 output_iec = new IEC61883Output(device);
125 output_iec->open(device->out_config->firewire_port,
126 device->out_config->firewire_channel,
128 device->out_channels,
130 device->out_samplerate,
131 device->out_config->firewire_syt);
137 int Audio1394::close_all()
146 delete output_thread;
156 int Audio1394::read_buffer(char *buffer, int bytes)
160 input_thread->read_audio(buffer, bytes / bytes_per_sample);
165 input_iec->read_audio(buffer, bytes / bytes_per_sample);
171 int Audio1394::write_buffer(char *buffer, int bytes)
174 output_thread->write_samples(buffer, bytes / bytes_per_sample);
177 output_iec->write_samples(buffer, bytes / bytes_per_sample);
181 int64_t Audio1394::device_position()
184 return output_thread->get_audio_position();
187 return output_iec->get_audio_position();
193 int Audio1394::flush_device()
196 output_thread->flush();
203 int Audio1394::interrupt_playback()
206 output_thread->interrupt();
209 output_iec->interrupt();