Commit b8cf0778 authored by sletz's avatar sletz
Browse files

Update ALSA driver in progress(5).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4203 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 14e2f368
......@@ -129,22 +129,22 @@ def build(bld):
prog.uselib_local = 'clientlib'
prog.target = 'jack_netsource'
if bld.env['IS_LINUX'] and bld.env['BUILD_EXAMPLE_ALSA_IO']:
prog = bld.new_task_gen('cc', 'program')
prog.includes = os_incdir + ['../common/jack', '../common']
prog.source = ['alsa_in.c', '../common/memops.c']
prog.env.append_value("CCFLAGS", "-DNO_JACK_ERROR")
prog.uselib = 'ALSA SAMPLERATE'
prog.uselib_local = 'clientlib'
prog.target = 'alsa_in'
prog = bld.new_task_gen('cc', 'program')
prog.includes = os_incdir + ['../common/jack', '../common']
prog.source = ['alsa_out.c', '../common/memops.c']
prog.env.append_value("CCFLAGS", "-DNO_JACK_ERROR")
prog.uselib = 'ALSA SAMPLERATE'
prog.uselib_local = 'clientlib'
prog.target = 'alsa_out'
#if bld.env['IS_LINUX'] and bld.env['BUILD_EXAMPLE_ALSA_IO']:
# prog = bld.new_task_gen('cc', 'program')
# prog.includes = os_incdir + ['../common/jack', '../common']
# prog.source = ['alsa_in.c', '../common/memops.c']
# prog.env.append_value("CCFLAGS", "-DNO_JACK_ERROR")
# prog.uselib = 'ALSA SAMPLERATE'
# prog.uselib_local = 'clientlib'
# prog.target = 'alsa_in'
# prog = bld.new_task_gen('cc', 'program')
# prog.includes = os_incdir + ['../common/jack', '../common']
# prog.source = ['alsa_out.c', '../common/memops.c']
# prog.env.append_value("CCFLAGS", "-DNO_JACK_ERROR")
# prog.uselib = 'ALSA SAMPLERATE'
# prog.uselib_local = 'clientlib'
# prog.target = 'alsa_out'
for example_lib, example_lib_source in example_libs.items():
lib = bld.new_task_gen('cc', 'shlib')
......
......@@ -893,7 +893,7 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
return 0;
}
static int
int
alsa_driver_reset_parameters (alsa_driver_t *driver,
jack_nframes_t frames_per_cycle,
jack_nframes_t user_nperiods,
......@@ -957,7 +957,7 @@ alsa_driver_get_channel_addresses (alsa_driver_t *driver,
return 0;
}
static int
int
alsa_driver_start (alsa_driver_t *driver)
{
int err;
......@@ -1082,7 +1082,7 @@ alsa_driver_start (alsa_driver_t *driver)
return 0;
}
static int
int
alsa_driver_stop (alsa_driver_t *driver)
{
int err;
......@@ -1109,11 +1109,12 @@ alsa_driver_stop (alsa_driver_t *driver)
*/
// New code
for (int i = 0; i < fPlaybackChannels; i++) {
jack_default_audio_sample_t* buf =
(jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[i], fEngineControl->fBufferSize);
memset (buf, 0, sizeof (jack_default_audio_sample_t) * fEngineControl->fBufferSize);
}
int i;
for (i = 0; i < fPlaybackChannels; i++) {
jack_default_audio_sample_t* buf =
(jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[i], fEngineControl->fBufferSize);
memset (buf, 0, sizeof (jack_default_audio_sample_t) * fEngineControl->fBufferSize);
}
if (driver->playback_handle) {
if ((err = snd_pcm_drop (driver->playback_handle)) < 0) {
......@@ -1245,7 +1246,7 @@ alsa_driver_set_clock_sync_status (alsa_driver_t *driver, channel_t chn,
static int under_gdb = FALSE;
static jack_nframes_t
jack_nframes_t
alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
*delayed_usecs)
{
......@@ -1564,15 +1565,15 @@ alsa_driver_bufsize (alsa_driver_t* driver, jack_nframes_t nframes)
driver->frame_rate);
}
static int
int
alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
{
snd_pcm_sframes_t contiguous;
snd_pcm_sframes_t nread;
snd_pcm_uframes_t offset;
jack_nframes_t orig_nframes;
// jack_default_audio_sample_t* buf;
// channel_t chn;
jack_default_audio_sample_t* buf;
channel_t chn;
// JSList *node;
// jack_port_t* port;
int err;
......@@ -1625,13 +1626,13 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
buf + nread, contiguous);
}
*/
for (int chn = 0; chn < fCaptureChannels; chn++) {
if (fGraphManager->GetConnectionsNum(fCapturePortList[chn]) > 0) {
buf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fCapturePortList[chn], orig_nframes);
alsa_driver_read_from_channel (driver, chn, buf + nread, contiguous);
}
}
int i;
for (chn = 0; chn < fCaptureChannels; chn++) {
if (fGraphManager->GetConnectionsNum(fCapturePortList[chn]) > 0) {
buf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fCapturePortList[chn], orig_nframes);
alsa_driver_read_from_channel (driver, chn, buf + nread, contiguous);
}
}
if ((err = snd_pcm_mmap_commit (driver->capture_handle,
offset, contiguous)) < 0) {
......@@ -1647,14 +1648,14 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
return 0;
}
static int
int
alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
{
// channel_t chn;
// JSList *node;
// JSList *mon_node;
// jack_default_audio_sample_t* buf;
// jack_default_audio_sample_t* monbuf;
jack_default_audio_sample_t* buf;
jack_default_audio_sample_t* monbuf;
jack_nframes_t orig_nframes;
snd_pcm_sframes_t nwritten;
snd_pcm_sframes_t contiguous;
......@@ -1698,13 +1699,13 @@ alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
}
}
*/
for (int chn = 0; chn < fCaptureChannels; chn++) {
port = fGraphManager->GetPort(fCapturePortList[chn]);
if (port->MonitoringInput()) {
driver->input_monitor_mask |= (1 << chn);
}
}
int chn;
for (chn = 0; chn < fCaptureChannels; chn++) {
port = fGraphManager->GetPort(fCapturePortList[chn]);
if (port->MonitoringInput()) {
driver->input_monitor_mask |= (1 << chn);
}
}
if (driver->hw_monitoring) {
if ((driver->hw->input_monitor_mask
......@@ -1754,19 +1755,20 @@ alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
}
*/
// Steph
for (int chn = 0; chn < fPlaybackChannels; chn++) {
// Ouput ports
if (fGraphManager->GetConnectionsNum(fPlaybackPortList[chn]) > 0) {
buf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[chn], orig_nframes);
alsa_driver_write_to_channel (driver, chn, buf + nwritten, contiguous);
// Monitor ports
if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[chn]) > 0) {
monbuf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fMonitorPortList[chn], orig_nframes);
memcpy(monbuf + nwritten, buf + nwritten, contiguous * sizeof(jack_default_audio_sample_t));
}
}
}
// Steph
int chn;
for (chn = 0; chn < fPlaybackChannels; chn++) {
// Ouput ports
if (fGraphManager->GetConnectionsNum(fPlaybackPortList[chn]) > 0) {
buf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[chn], orig_nframes);
alsa_driver_write_to_channel (driver, chn, buf + nwritten, contiguous);
// Monitor ports
if (fWithMonitorPorts && fGraphManager->GetConnectionsNum(fMonitorPortList[chn]) > 0) {
monbuf = (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fMonitorPortList[chn], orig_nframes);
memcpy(monbuf + nwritten, buf + nwritten, contiguous * sizeof(jack_default_audio_sample_t));
}
}
}
if (!bitset_empty (driver->channels_not_done)) {
alsa_driver_silence_untouched_channels (driver,
......@@ -2022,7 +2024,7 @@ alsa_driver_clock_sync_status (channel_t chn)
}
#endif
static void
void
alsa_driver_delete (alsa_driver_t *driver)
{
JSList *node;
......@@ -2088,7 +2090,7 @@ alsa_driver_delete (alsa_driver_t *driver)
free (driver);
}
static jack_driver_t *
jack_driver_t *
alsa_driver_new (char *name, char *playback_alsa_device,
char *capture_alsa_device,
jack_client_t *client,
......
......@@ -218,4 +218,50 @@ int alsa_driver_stop_listen_for_clock_sync_status (alsa_driver_t *,
void alsa_driver_clock_sync_notify (alsa_driver_t *, channel_t chn,
ClockSyncStatus);
int
alsa_driver_reset_parameters (alsa_driver_t *driver,
jack_nframes_t frames_per_cycle,
jack_nframes_t user_nperiods,
jack_nframes_t rate);
jack_driver_t *
alsa_driver_new (char *name, char *playback_alsa_device,
char *capture_alsa_device,
jack_client_t *client,
jack_nframes_t frames_per_cycle,
jack_nframes_t user_nperiods,
jack_nframes_t rate,
int hw_monitoring,
int hw_metering,
int capturing,
int playing,
DitherAlgorithm dither,
int soft_mode,
int monitor,
int user_capture_nchnls,
int user_playback_nchnls,
int shorts_first,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency,
alsa_midi_t *midi_driver
);
void
alsa_driver_delete (alsa_driver_t *driver);
int
alsa_driver_start (alsa_driver_t *driver);
int
alsa_driver_stop (alsa_driver_t *driver);
jack_nframes_t
alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
*delayed_usecs);
int
alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes);
int
alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes);
#endif /* __jack_alsa_driver_h__ */
......@@ -54,6 +54,8 @@ extern "C"
#define jack_frame_time JACK_frame_time
#define jack_last_frame_time JACK_last_frame_time
#define jack_get_microseconds GetMicroSecond
#ifdef __cplusplus
} // extern "C"
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment