diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-06-16 18:52:12 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2006-06-16 18:52:12 +0200 |
commit | b3c3e355d93446ea312296eb6a83591518fe5c24 (patch) | |
tree | 20a156d223d23a3cef65ce6c7c6d2c556ee90598 | |
parent | 2a7f35347b3ef8e67154fc03a9df488f01d790f5 (diff) | |
download | alsa-lib-b3c3e355d93446ea312296eb6a83591518fe5c24.tar.gz |
Initialize all fields of slave PCM instance of direct plugins
Initialize all fields of slave PCM instance of direct plugins.
Some fields were not initialized properly.
-rw-r--r-- | src/pcm/pcm_direct.c | 110 | ||||
-rw-r--r-- | src/pcm/pcm_direct.h | 32 |
2 files changed, 113 insertions, 29 deletions
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 4e2f36cd..c67ae8b9 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -82,7 +82,7 @@ int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix) return 0; } -#define SND_PCM_DIRECT_MAGIC 0xa15ad319 +#define SND_PCM_DIRECT_MAGIC (0xa15ad300 + sizeof(snd_pcm_direct_share_t)) /* * global shared memory area @@ -800,6 +800,44 @@ int snd_pcm_direct_resume(snd_pcm_t *pcm) return err; } +#define COPY_SLAVE(field) (dmix->shmptr->s.field = spcm->field) + +/* copy the slave setting */ +static void save_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm) +{ + COPY_SLAVE(access); + COPY_SLAVE(format); + COPY_SLAVE(subformat); + COPY_SLAVE(channels); + COPY_SLAVE(rate); + COPY_SLAVE(period_size); + COPY_SLAVE(period_time); + COPY_SLAVE(periods); + COPY_SLAVE(tick_time); + COPY_SLAVE(tstamp_mode); + COPY_SLAVE(period_step); + COPY_SLAVE(sleep_min); + COPY_SLAVE(avail_min); + COPY_SLAVE(start_threshold); + COPY_SLAVE(stop_threshold); + COPY_SLAVE(silence_threshold); + COPY_SLAVE(silence_size); + COPY_SLAVE(xfer_align); + COPY_SLAVE(boundary); + COPY_SLAVE(info); + COPY_SLAVE(msbits); + COPY_SLAVE(rate_num); + COPY_SLAVE(rate_den); + COPY_SLAVE(hw_flags); + COPY_SLAVE(fifo_size); + COPY_SLAVE(buffer_size); + COPY_SLAVE(buffer_time); + COPY_SLAVE(sample_bits); + COPY_SLAVE(frame_bits); +} + +#undef COPY_SLAVE + /* * this function initializes hardware and starts playback operation with * no stop threshold (it operates all time without xrun checking) @@ -1014,15 +1052,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str snd_pcm_poll_descriptors(spcm, &fd, 1); dmix->hw_fd = fd.fd; - dmix->shmptr->s.boundary = spcm->boundary; - dmix->shmptr->s.buffer_size = spcm->buffer_size; - dmix->shmptr->s.period_size = spcm->period_size; - dmix->shmptr->s.sample_bits = spcm->sample_bits; - dmix->shmptr->s.channels = spcm->channels; - dmix->shmptr->s.rate = spcm->rate; - dmix->shmptr->s.format = spcm->format; - dmix->shmptr->s.info = spcm->info & ~SND_PCM_INFO_PAUSE; - dmix->shmptr->s.msbits = spcm->msbits; + save_slave_setting(dmix, spcm); /* Currently, we assume that each dmix client has the same * hw_params setting. @@ -1126,6 +1156,48 @@ static snd_pcm_uframes_t recalc_boundary_size(unsigned long long bsize, snd_pcm_ return (snd_pcm_uframes_t)bsize; } +#define COPY_SLAVE(field) (spcm->field = dmix->shmptr->s.field) + +/* copy the slave setting */ +static void copy_slave_setting(snd_pcm_direct_t *dmix, snd_pcm_t *spcm) +{ + COPY_SLAVE(access); + COPY_SLAVE(format); + COPY_SLAVE(subformat); + COPY_SLAVE(channels); + COPY_SLAVE(rate); + COPY_SLAVE(period_size); + COPY_SLAVE(period_time); + COPY_SLAVE(periods); + COPY_SLAVE(tick_time); + COPY_SLAVE(tstamp_mode); + COPY_SLAVE(period_step); + COPY_SLAVE(sleep_min); + COPY_SLAVE(avail_min); + COPY_SLAVE(start_threshold); + COPY_SLAVE(stop_threshold); + COPY_SLAVE(silence_threshold); + COPY_SLAVE(silence_size); + COPY_SLAVE(xfer_align); + COPY_SLAVE(boundary); + COPY_SLAVE(info); + COPY_SLAVE(msbits); + COPY_SLAVE(rate_num); + COPY_SLAVE(rate_den); + COPY_SLAVE(hw_flags); + COPY_SLAVE(fifo_size); + COPY_SLAVE(buffer_size); + COPY_SLAVE(buffer_time); + COPY_SLAVE(sample_bits); + COPY_SLAVE(frame_bits); + + spcm->info &= ~SND_PCM_INFO_PAUSE; + spcm->boundary = recalc_boundary_size(dmix->shmptr->s.boundary, spcm->buffer_size); +} + +#undef COPY_SLAVE + + /* * open a slave PCM as secondary client (dup'ed fd) */ @@ -1143,13 +1215,8 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm spcm = *spcmp; spcm->donot_close = 1; spcm->setup = 1; - /* we copy the slave setting */ - spcm->buffer_size = dmix->shmptr->s.buffer_size; - spcm->sample_bits = dmix->shmptr->s.sample_bits; - spcm->channels = dmix->shmptr->s.channels; - spcm->format = dmix->shmptr->s.format; - spcm->boundary = recalc_boundary_size(dmix->shmptr->s.boundary, spcm->buffer_size); - spcm->info = dmix->shmptr->s.info; + + copy_slave_setting(dmix, spcm); /* Use the slave setting as SPCM, so far */ dmix->slave_buffer_size = spcm->buffer_size; @@ -1173,13 +1240,8 @@ int snd_pcm_direct_initialize_secondary_slave(snd_pcm_direct_t *dmix, snd_pcm_t spcm->donot_close = 1; spcm->setup = 1; - /* we copy the slave setting */ - spcm->buffer_size = dmix->shmptr->s.buffer_size; - spcm->sample_bits = dmix->shmptr->s.sample_bits; - spcm->channels = dmix->shmptr->s.channels; - spcm->format = dmix->shmptr->s.format; - spcm->boundary = recalc_boundary_size(dmix->shmptr->s.boundary, spcm->buffer_size); - spcm->info = dmix->shmptr->s.info; + + copy_slave_setting(dmix, spcm); /* Use the slave setting as SPCM, so far */ dmix->slave_buffer_size = spcm->buffer_size; diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h index 7cf4b9d5..e8d1a0bd 100644 --- a/src/pcm/pcm_direct.h +++ b/src/pcm/pcm_direct.h @@ -50,6 +50,7 @@ struct slave_params { unsigned int periods; }; +/* shared among direct plugin clients - be careful to be 32/64bit compatible! */ typedef struct { unsigned int magic; /* magic number */ char socket_name[256]; /* name of communication socket */ @@ -65,15 +66,36 @@ typedef struct { snd_interval_t periods; } hw; struct { - unsigned int buffer_size; - unsigned int period_size; - unsigned long long boundary; + /* copied to slave PCMs */ + snd_pcm_access_t access; + snd_pcm_format_t format; + snd_pcm_subformat_t subformat; unsigned int channels; - unsigned int sample_bits; unsigned int rate; - snd_pcm_format_t format; + unsigned int period_size; + unsigned int period_time; + snd_interval_t periods; + unsigned int tick_time; + snd_pcm_tstamp_t tstamp_mode; + unsigned int period_step; + unsigned int sleep_min; + unsigned int avail_min; + unsigned int start_threshold; + unsigned int stop_threshold; + unsigned int silence_threshold; + unsigned int silence_size; + unsigned int xfer_align; + unsigned long long boundary; unsigned int info; unsigned int msbits; + unsigned int rate_num; + unsigned int rate_den; + unsigned int hw_flags; + unsigned int fifo_size; + unsigned int buffer_size; + snd_interval_t buffer_time; + unsigned int sample_bits; + unsigned int frame_bits; } s; union { struct { |