mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Transformed PAGE_SIZE in sysconf(_SC_PAGE_SIZE)
This commit is contained in:
parent
1dfd70d11e
commit
c663f4f4f7
4 changed files with 26 additions and 18 deletions
|
|
@ -68,4 +68,7 @@ typedef enum _snd_set_mode snd_set_mode_t;
|
|||
#define SND_TRY ((snd_set_mode_t) SND_TRY)
|
||||
#define SND_TEST ((snd_set_mode_t) SND_TEST)
|
||||
|
||||
size_t page_align(size_t size);
|
||||
size_t page_size(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
#include <asm/page.h>
|
||||
#include "pcm_local.h"
|
||||
#include "../control/control_local.h"
|
||||
|
||||
|
|
@ -36,10 +35,6 @@
|
|||
#define F_SETSIG 10
|
||||
#endif
|
||||
|
||||
#ifndef PAGE_ALIGN
|
||||
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
int card, device, subdevice;
|
||||
|
|
@ -366,7 +361,7 @@ static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
|
|||
{
|
||||
snd_pcm_hw_t *hw = pcm->private_data;
|
||||
void *ptr;
|
||||
ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_status)), PROT_READ, MAP_FILE|MAP_SHARED,
|
||||
ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_status)), PROT_READ, MAP_FILE|MAP_SHARED,
|
||||
hw->fd, SND_PCM_MMAP_OFFSET_STATUS);
|
||||
if (ptr == MAP_FAILED || ptr == NULL) {
|
||||
SYSERR("status mmap failed");
|
||||
|
|
@ -381,7 +376,7 @@ static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
|
|||
{
|
||||
snd_pcm_hw_t *hw = pcm->private_data;
|
||||
void *ptr;
|
||||
ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_control)), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
|
||||
ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_control)), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
|
||||
hw->fd, SND_PCM_MMAP_OFFSET_CONTROL);
|
||||
if (ptr == MAP_FAILED || ptr == NULL) {
|
||||
SYSERR("control mmap failed");
|
||||
|
|
@ -395,7 +390,7 @@ static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
|
|||
static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_hw_t *hw = pcm->private_data;
|
||||
if (munmap((void*)hw->mmap_status, PAGE_ALIGN(sizeof(*hw->mmap_status))) < 0) {
|
||||
if (munmap((void*)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) {
|
||||
SYSERR("status munmap failed");
|
||||
return -errno;
|
||||
}
|
||||
|
|
@ -405,7 +400,7 @@ static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
|
|||
static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_hw_t *hw = pcm->private_data;
|
||||
if (munmap(hw->mmap_control, PAGE_ALIGN(sizeof(*hw->mmap_control))) < 0) {
|
||||
if (munmap(hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) {
|
||||
SYSERR("control munmap failed");
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,25 @@
|
|||
#include <sys/poll.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
#include <asm/page.h>
|
||||
#include "pcm_local.h"
|
||||
|
||||
size_t page_size(void)
|
||||
{
|
||||
long s = sysconf(_SC_PAGE_SIZE);
|
||||
assert(s > 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifndef PAGE_ALIGN
|
||||
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|
||||
#endif
|
||||
|
||||
size_t page_align(size_t size)
|
||||
{
|
||||
size_t r;
|
||||
long psz = sysconf(_SC_PAGE_SIZE);
|
||||
assert(psz > 0);
|
||||
r = size % psz;
|
||||
if (r)
|
||||
return size + psz - r;
|
||||
return size;
|
||||
}
|
||||
|
||||
const snd_pcm_channel_area_t *snd_pcm_mmap_running_areas(snd_pcm_t *pcm)
|
||||
{
|
||||
|
|
@ -304,7 +315,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
|
|||
size = s;
|
||||
}
|
||||
size = (size + 7) / 8;
|
||||
size = PAGE_ALIGN(size);
|
||||
size = page_align(size);
|
||||
switch (i->type) {
|
||||
case SND_PCM_AREA_MMAP:
|
||||
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, i->u.mmap.fd, i->u.mmap.offset);
|
||||
|
|
@ -384,7 +395,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm)
|
|||
size = s;
|
||||
}
|
||||
size = (size + 7) / 8;
|
||||
size = PAGE_ALIGN(size);
|
||||
size = page_align(size);
|
||||
switch (i->type) {
|
||||
case SND_PCM_AREA_MMAP:
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include <asm/page.h>
|
||||
#include "rawmidi_local.h"
|
||||
|
||||
const char *snd_rawmidi_name(snd_rawmidi_t *rawmidi)
|
||||
|
|
@ -160,7 +159,7 @@ int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *param
|
|||
{
|
||||
assert(rmidi);
|
||||
assert(params);
|
||||
params->buffer_size = PAGE_SIZE;
|
||||
params->buffer_size = page_size();
|
||||
params->avail_min = 1;
|
||||
params->no_active_sensing = 0;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue