mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
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.
This commit is contained in:
parent
2a7f35347b
commit
b3c3e355d9
2 changed files with 114 additions and 30 deletions
|
|
@ -82,7 +82,7 @@ int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SND_PCM_DIRECT_MAGIC 0xa15ad319
|
#define SND_PCM_DIRECT_MAGIC (0xa15ad300 + sizeof(snd_pcm_direct_share_t))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global shared memory area
|
* global shared memory area
|
||||||
|
|
@ -800,6 +800,44 @@ int snd_pcm_direct_resume(snd_pcm_t *pcm)
|
||||||
return err;
|
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
|
* this function initializes hardware and starts playback operation with
|
||||||
* no stop threshold (it operates all time without xrun checking)
|
* 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);
|
snd_pcm_poll_descriptors(spcm, &fd, 1);
|
||||||
dmix->hw_fd = fd.fd;
|
dmix->hw_fd = fd.fd;
|
||||||
|
|
||||||
dmix->shmptr->s.boundary = spcm->boundary;
|
save_slave_setting(dmix, spcm);
|
||||||
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;
|
|
||||||
|
|
||||||
/* Currently, we assume that each dmix client has the same
|
/* Currently, we assume that each dmix client has the same
|
||||||
* hw_params setting.
|
* 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;
|
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)
|
* 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 = *spcmp;
|
||||||
spcm->donot_close = 1;
|
spcm->donot_close = 1;
|
||||||
spcm->setup = 1;
|
spcm->setup = 1;
|
||||||
/* we copy the slave setting */
|
|
||||||
spcm->buffer_size = dmix->shmptr->s.buffer_size;
|
copy_slave_setting(dmix, spcm);
|
||||||
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;
|
|
||||||
|
|
||||||
/* Use the slave setting as SPCM, so far */
|
/* Use the slave setting as SPCM, so far */
|
||||||
dmix->slave_buffer_size = spcm->buffer_size;
|
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->donot_close = 1;
|
||||||
spcm->setup = 1;
|
spcm->setup = 1;
|
||||||
/* we copy the slave setting */
|
|
||||||
spcm->buffer_size = dmix->shmptr->s.buffer_size;
|
copy_slave_setting(dmix, spcm);
|
||||||
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;
|
|
||||||
|
|
||||||
/* Use the slave setting as SPCM, so far */
|
/* Use the slave setting as SPCM, so far */
|
||||||
dmix->slave_buffer_size = spcm->buffer_size;
|
dmix->slave_buffer_size = spcm->buffer_size;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ struct slave_params {
|
||||||
unsigned int periods;
|
unsigned int periods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* shared among direct plugin clients - be careful to be 32/64bit compatible! */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int magic; /* magic number */
|
unsigned int magic; /* magic number */
|
||||||
char socket_name[256]; /* name of communication socket */
|
char socket_name[256]; /* name of communication socket */
|
||||||
|
|
@ -65,15 +66,36 @@ typedef struct {
|
||||||
snd_interval_t periods;
|
snd_interval_t periods;
|
||||||
} hw;
|
} hw;
|
||||||
struct {
|
struct {
|
||||||
unsigned int buffer_size;
|
/* copied to slave PCMs */
|
||||||
unsigned int period_size;
|
snd_pcm_access_t access;
|
||||||
unsigned long long boundary;
|
|
||||||
unsigned int channels;
|
|
||||||
unsigned int sample_bits;
|
|
||||||
unsigned int rate;
|
|
||||||
snd_pcm_format_t format;
|
snd_pcm_format_t format;
|
||||||
|
snd_pcm_subformat_t subformat;
|
||||||
|
unsigned int channels;
|
||||||
|
unsigned int rate;
|
||||||
|
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 info;
|
||||||
unsigned int msbits;
|
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;
|
} s;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue