void MusicWidget::mute_on_off()
{
    int value;
    value= volume->value();
    mixer_fd=open("/dev/mixer",O_RDWR);
    if(mute_state==0)
    {
        value=0;
        mute_state=1;
        ioctl(mixer_fd,MIXER_WRITE(0),&value);
        mute->setIcon(QPixmap("image/Mute_2.png"));
        mute->setIconSize(QPixmap("image/Mute_2.png").size());
        mute->setAutoRaise(TRUE);
        mute->setGeometry(QRect(7,171,QPixmap("image/Mute_2.png").width(),QPixmap("image/Mute_2.png").height()));
        volstatus->setText(tr("静音"));
    }
  else if(mute_state==1)
  {
    mute_state=0;
    ioctl(mixer_fd,MIXER_WRITE(0),&value);
    mute->setIcon(QPixmap("image/Mute.png"));
    mute->setIconSize(QPixmap("image/Mute.png").size());
    mute->setAutoRaise(TRUE);
    mute->setGeometry(QRect(7,171,QPixmap("image/Mute.png").width(),QPixmap("image/Mute.png").height()));
    volstatus->setText(tr("立体声"));
  }
}
//_______________________________________________
//
//
//_______________________________________________
uint8_t  ossAudioDevice::setVolume(int volume) 
{
        int fd;
	int ret;
	uint32_t which_vol = 0;

	//prefs->get(FEATURE_AUDIOBAR_USES_MASTER,&which_vol);
        fd=open(device_mixer,O_RDONLY);
        if(!fd)
        {
                printf("[OSSS]: cannot open mixer\n");
                return 0;
        }
        printf("[OSSS]: New %s volume %d\n",(which_vol?"master":"pcm"),volume);
        // Assuming stereo
        volume=volume+(volume<<8);
	if( which_vol ){
        	ret = ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &volume);
	}else{
        	ret = ioctl(fd, MIXER_WRITE(SOUND_MIXER_PCM   ), &volume);
	}
        close(fd);

	if( ret ){
		if( errno == EBADF ){
			printf("[OSSS]set mixer failed: %u (possible access issue)\n",errno);
		}else{
			printf("[OSSS]set mixer failed: %u\n",errno);
		}
	}
        return 1;

}
void EzxVolumeService::adjustVolume(int leftChannel, int rightChannel, AdjustType adjust)
{
    int mixerFd = open("/dev/mixer", O_RDWR);
    if (mixerFd >= 0) {
        int leftright, left, right;

        if (adjust == Relative) {
            ioctl(mixerFd, MIXER_READ(SOUND_MIXER_OGAIN), &leftright);

            left = leftright; 
            right = leftright; 

            left = qBound(0, left + leftChannel, 100);
            right = qBound(0, right + rightChannel, 100);

        } else {
            left = leftChannel;
            right = rightChannel;
        }

        leftright = (left + right) >> 1;
        int input = leftright;
        m_d->currVolume = leftright;
        ioctl(mixerFd, MIXER_WRITE(SOUND_MIXER_OGAIN), &leftright);       
        ioctl(mixerFd, MIXER_WRITE(SOUND_MIXER_IGAIN), &input);
        close(mixerFd);
    }
Beispiel #4
0
void
wave_out_volume(uint16 left, uint16 right)
{
	static BOOL use_dev_mixer = False;
	uint32 volume;
	int fd_mix = -1;

	volume = left / (65536 / 100);
	volume |= right / (65536 / 100) << 8;

	if (use_dev_mixer)
	{
		if ((fd_mix = open("/dev/mixer", O_RDWR | O_NONBLOCK)) == -1)
		{
			perror("open /dev/mixer");
			return;
		}

		if (ioctl(fd_mix, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
		{
			perror("MIXER_WRITE(SOUND_MIXER_PCM)");
			return;
		}

		close(fd_mix);
	}

	if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
	{
		perror("MIXER_WRITE(SOUND_MIXER_PCM)");
		use_dev_mixer = True;
		return;
	}
}
Beispiel #5
0
int main(int argc,char *argv[])
{
   int mixer_fd=0;
   char names[SOUND_MIXER_NRDEVICES][128]=SOUND_DEVICE_LABELS;
   int value,i;
   printf("\nusage:%s dev_no.[0..24] value[0..100]\n\n",argv[0]);
   printf("eg. %s 0 100\n",argv[0]);
   printf("will change the volume to MAX volume.\n\n");
   printf("The dev_no. are as below:\n");
   for (i=0;i<SOUND_MIXER_NRDEVICES;i++)
     {
        if (i%3==0) printf("\n");
        printf("%s:%d\t\t",names[i],i);
     }
   printf("\n\n");
   if (argc<3)  exit(1);
   if ((mixer_fd = open("/dev/mixer",O_RDWR)))
     {
         printf("Mixer opened successfully,working...\n");
         value=BASE_VALUE*atoi(argv[2]);
         if (ioctl(mixer_fd,MIXER_WRITE(atoi(argv[1])),&value)==0)
            printf("successfully.....");
         else
            printf("unsuccessfully.....");
       
         printf("done.\n");
     }
   else
      printf("can't open /dev/mixer error....\n");
exit(0);
}
Beispiel #6
0
/* mixer_set_control */
static int _mixer_set_control(Mixer * mixer, MixerControl2 * control)
{
#ifdef AUDIO_MIXER_DEVINFO
	mixer_ctrl_t p;
	int i;

	p.dev = control->index;
	p.type = control->type;
	p.un.value.num_channels = control->un.level.channels_cnt;
	for(i = 0; i < p.un.value.num_channels; i++)
		p.un.value.level[i] = control->un.level.channels[i];
	if(ioctl(mixer->fd, AUDIO_MIXER_WRITE, &p) != 0)
		return -_mixer_error(mixer, "AUDIO_MIXER_WRITE", 1);
#else
	int level;

	level = (control->un.level.channels[1] << 8)
		| control->un.level.channels[0];
# ifdef DEBUG
	fprintf(stderr, "DEBUG: %s() level=0x%04x\n", __func__, level);
# endif
	if(ioctl(mixer->fd, MIXER_WRITE(control->index), &level) != 0)
		return -_mixer_error(mixer, "MIXER_WRITE", 1);
#endif
	return 0;
}
Beispiel #7
0
static PyObject *
oss_mixer_set(oss_mixer_t *self, PyObject *args)
{
    int channel, volume, leftVol, rightVol;

    if (!_is_fd_valid(self->fd))
        return NULL;

    /* Can't use _do_ioctl_1 because of encoded arg thingy. */
    if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol))
        return NULL;

    if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) {
        PyErr_SetString(OSSAudioError, "Invalid mixer channel specified.");
        return NULL;
    }

    if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) {
        PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100.");
        return NULL;
    }

    volume = (rightVol << 8) | leftVol;

    if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1)
        return PyErr_SetFromErrno(PyExc_IOError);

    return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8);
}
Beispiel #8
0
static void oss_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent)
{
	OssData *d=(OssData*)card->data;
	int p,mix_fd;
	int osscmd;
	if (d->mixdev==NULL) return;
	switch(e){
		case MS_SND_CARD_MASTER:
			osscmd=SOUND_MIXER_VOLUME;
		break;
		case MS_SND_CARD_CAPTURE:
			osscmd=SOUND_MIXER_IGAIN;
		break;
		case MS_SND_CARD_PLAYBACK:
			osscmd=SOUND_MIXER_PCM;
		break;
		default:
			ms_warning("oss_card_set_level: unsupported command.");
			return;
	}
	p=(((int)percent)<<8 | (int)percent);
	mix_fd = open(d->mixdev, O_WRONLY);
	ioctl(mix_fd,MIXER_WRITE(osscmd), &p);
	close(mix_fd);
}
int cAudio::setVolume(unsigned int left, unsigned int right)
{
//	int avsfd;
	int ret;
	int vl = map_volume(left);
	int vr = map_volume(right);
	volume = (left + right) / 2;
	int v = map_volume(volume);
	if (clipfd != -1 && mixer_fd != -1) {
		int tmp = 0;
		/* not sure if left / right is correct here, but it is always the same anyways ;-) */
		if (! Muted)
			tmp = left << 8 | right;
		ret = ioctl(mixer_fd, MIXER_WRITE(mixer_num), &tmp);
		if (ret == -1)
			lt_info("%s: MIXER_WRITE(%d),%04x: %m\n", __func__, mixer_num, tmp);
		return ret;
	}
//	if (settings.volume_type == CControld::TYPE_OST || forcetype == (int)CControld::TYPE_OST)
	{
		AUDVOL vol;
		vol.frontleft  = vl;
		vol.frontright = vr;
		vol.rearleft   = vl;
		vol.rearright  = vr;
		vol.center     = v;
		vol.lfe        = v;
		ret = ioctl(fd, MPEG_AUD_SET_VOL, &vol);
		if (ret < 0)
			lt_info("setVolume MPEG_AUD_SET_VOL failed (%m)\n");
		return ret;
	}
#if 0
	else if (settings.volume_type == CControld::TYPE_AVS || forcetype == (int)CControld::TYPE_AVS)
Beispiel #10
0
void set_device(int mixer_fd, int device, Fl_Slider *device_sl, Fl_Slider *balance)
{
    int l = (unsigned int) ((1.0-(balance->value()) ) * device_sl->value() );	
    int r = (unsigned int) ( (balance->value()) * device_sl->value());
    int v = (r << 8) | l;
    if (ioctl (mixer_fd, MIXER_WRITE (device), &v) < 0)    
	fl_alert(_("Cannot setup device, sorry."));
}
void MusicWidget::volume_change(int value)
{
    volumelabel2->setNum(value);
    mixer_fd=open("/dev/mixer",O_RDWR);
    ioctl(mixer_fd,MIXER_WRITE(0),&value);
    volumelabel1->show();
    volumelabel2->show();
}
Beispiel #12
0
int start_sound_thread(char *sdev, char *mdev, int *handle)
{
	if (NULL == sdev) return -1;

	struct play_para *para = calloc(1, sizeof(struct play_para));
	if (NULL == para) return -1;

	if ((para->snd = open(sdev, O_RDWR)) < 0)
	{
		DBG_ERR("Can't open sound device: %s.", sdev);
		goto err;
	}
	para->mix = -1;
	if (NULL != mdev)
		if ((para->mix = open(mdev, O_RDWR)) < 0)
		{
			DBG_ERR("Can't open mixer device: %s.", mdev);
			goto errsound;
		}

	int data = 0x5050;
	if (ioctl(para->mix, MIXER_WRITE(SOUND_MIXER_PCM), &data))
	{
		DBG_ERR("Set mixer pcm fail!");
		goto errmix;
	}

	pthread_mutex_init(&para->play_mutex, NULL);
	pthread_mutex_init(&para->start_play_mutex, NULL);
	pthread_mutex_init(&para->end_play_mutex, NULL);
	pthread_cond_init(&para->start_play_cond, NULL);
	pthread_cond_init(&para->end_play_cond, NULL);

	if ((errno = pthread_mutex_lock(&para->start_play_mutex)))
	{
		DBG_ERR("Can't lock start_play_mutex!");
		goto errmix;
	}

	//start thread
	pthread_t tid;
	if (errno = pthread_create(&tid, NULL, sound_thread, para))
	{
		DBG_ERR("Create sound thread fail!");
		goto errmix;
	}

	*handle = (int)para;
	return 0;

errmix:
	if (para->mix != -1) close(para->mix);
errsound:
	close(para->snd);
err:
	free(para);
	return -1;
}
Beispiel #13
0
static void
oss_set_volume(volume_priv *c, int volume)
{
    ENTER;
    DBG("volume=%d\n", volume);
    volume = (volume << 8) | volume;
    ioctl(c->fd, MIXER_WRITE(c->chan), &volume);
    RET();
}
Beispiel #14
0
// to set/get/query special features/parameters
static int control(int cmd,void *arg){
    switch(cmd){
	case AOCONTROL_SET_DEVICE:
	    dsp=(char*)arg;
	    return CONTROL_OK;
	case AOCONTROL_GET_DEVICE:
	    *(char**)arg=dsp;
	    return CONTROL_OK;
#ifdef SNDCTL_DSP_GETFMTS
	case AOCONTROL_QUERY_FORMAT:
	{
	    int format;
	    if (!ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &format))
		if ((unsigned int)format & (unsigned long)arg)
	    	    return CONTROL_TRUE;
	    return CONTROL_FALSE;
	}
#endif
	case AOCONTROL_GET_VOLUME:
	case AOCONTROL_SET_VOLUME:
	{
	    ao_control_vol_t *vol = (ao_control_vol_t *)arg;
	    int fd, v, devs;

	    if(AF_FORMAT_IS_AC3(ao_data.format))
		return CONTROL_TRUE;

	    if ((fd = open(oss_mixer_device, O_RDONLY)) != -1)
	    {
		if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs) == -1)
		    return CONTROL_ERROR;
		if (devs & (1 << oss_mixer_channel))
		{
		    if (cmd == AOCONTROL_GET_VOLUME)
		    {
		        if (ioctl(fd, MIXER_READ(oss_mixer_channel), &v) == -1)
			    return CONTROL_ERROR;
			vol->right = (v & 0xFF00) >> 8;
			vol->left = v & 0x00FF;
		    }
		    else
		    {
		        v = ((int)vol->right << 8) | (int)vol->left;
			if (ioctl(fd, MIXER_WRITE(oss_mixer_channel), &v) == -1)
			    return CONTROL_ERROR;
		    }
		}
		else
		{
		    close(fd);
		    return CONTROL_ERROR;
		}
		close(fd);
		return CONTROL_OK;
	    }
	}
Beispiel #15
0
static gboolean
on_vscale1_button_release_event (GtkWidget *widget,
		 		 GdkEventButton *event,
		                 gpointer user_data)
{
	vol.left = vol.right = 
		(int) gtk_adjustment_get_value(GTK_ADJUSTMENT(user_data));
	ioctl(mixer_fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &vol);
	return FALSE;
}
Beispiel #16
0
void
oss_audio_loopback(audio_desc_t ad, int gain)
{
        UNUSED(ad); assert(devices[ad].audio_rfd > 0);

        gain = gain << 8 | gain;
        if (ioctl(devices[ad].mixer_rfd, MIXER_WRITE(SOUND_MIXER_IMIX), &gain) == -1) {
#if defined(DEBUG) && !defined(HAVE_ALSA_AUDIO)
                perror("audio loopback");
#endif
        }
}
Beispiel #17
0
void set_mute(int mixer_fd, int device, Fl_Slider *device_sl, Fl_Slider *balance, Fl_Check_Button *check_button)
{
    int vol = 0;
    
    if ( check_button->value() ) 
    {
	if (ioctl(mixer_fd, MIXER_WRITE(device), &vol) < 0 ) 
	 fprintf(stderr, "Cannot set mute.\n");  
    }
    else {
	volume real_volume;
        double old_volume = device_sl->value();
        double old_balance = balance->value();
        real_volume.left  = (unsigned char) ( (1.0 - (old_balance)) * old_volume );	
        real_volume.right = (unsigned char) ( (old_balance) * old_volume);
        if ( ioctl(mixer_fd, MIXER_WRITE(device), &real_volume) < 0 )
        {
    	    fprintf(stderr, "Cannot setup volume, sorry.\n");
	}
    }
}
Beispiel #18
0
void VolumeControl::set_volume(int vol)
{ 
   if ((vol > MAX_VOLUME) || (vol < MIN_VOLUME))
      return;
      
   volume.left = vol;
   volume.right = vol;
   
   if ( ioctl(mixer_fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &volume) < 0 ) {
      fprintf(stderr, "Can't set current volume settings \n");
   } 
}
Beispiel #19
0
static gboolean 
on_spinbutton1_button_release_event (GtkWidget *widget, 
		                     GdkEventButton *event,
				     gpointer user_data)
{
	GtkSpinButton *spin;
	extern GtkWidget *spinbutton1;
	spin = GTK_SPIN_BUTTON (spinbutton1);
	vol.left = vol.right = (int) gtk_spin_button_get_value_as_int (spin);
	ioctl(mixer_fd,MIXER_WRITE(SOUND_MIXER_VOLUME), &vol);

	return FALSE;
}
Beispiel #20
0
/*! This function sets the input/output volume and selects 
 *  the input.
 */
int kb_snd_setVolume( snd_t * snd , 
		   unsigned int line , 
		   unsigned int vol_left ,
		   unsigned int vol_right )
{
  int rc = -1;
  int arg = ((vol_left<<8)|vol_right);
  
  if ( snd->mix_fd >= 0 ) {
    rc = ioctl( snd->mix_fd , MIXER_WRITE(line) , &arg ); 
  }
  return rc;
}
Beispiel #21
0
void onVolume(int dev, int bIncrease){
	
	int mixernum=open("/dev/mixer", O_RDWR);
	//first get the volume 
	int vol;
	ioctl(mixernum, MIXER_READ(dev), &vol);
	vol=vol & 0xff;
	bIncrease?vol++:vol--;
	
	int i = vol | vol << 8 ;
	ioctl(mixernum, MIXER_WRITE(dev), &i);
	
	close(mixernum);	
}
Beispiel #22
0
void V4LRadioControl::setVol(int v)
{
    int fd = ::open( "/dev/mixer", O_RDWR, 0 );
    if ( fd < 0 )
        return;
    int volume = v;
    if ( volume < 0 )
        volume = 0;
    else if ( volume > 100 )
        volume = 100;
    vol = volume;
    volume += volume << 8;
    ::ioctl( fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &volume );
    ::close( fd );
}
static void
oss_volume(uint16 left, uint16 right)
{
	uint32 volume;

	volume = left / (65536 / 100);
	volume |= right / (65536 / 100) << 8;

	if (ioctl(dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
	{
		warning("hardware volume control unavailable, falling back to software volume control!\n");
		oss_driver.wave_out_volume = rdpsnd_dsp_softvol_set;
		rdpsnd_dsp_softvol_set(left, right);
		return;
	}
}
Beispiel #24
0
ERRCODE
OSS_PlaySetVolume(
	uint32_t 		u32Volume			// [in] Set volume 0 ~ 0x3F
) {
	if ((int32_t)u32Volume < OSS_VOLUME_MIN)
		u32Volume = OSS_VOLUME_MIN;

	if (u32Volume > OSS_VOLUME_MAX)
		u32Volume = OSS_VOLUME_MAX;

	if (u32Volume == g_u32NMPlayer_Volume)
		return ERR_OSS_NONE;

	FUN_MUTEX_LOCK(&s_sOSSFunMutex);

	if (s_i32DSPFD < 0) {
		FUN_MUTEX_UNLOCK(&s_sOSSFunMutex);
		return ERR_OSS_DEV;
	}

	if (s_i32MixerFD < 0) {
		s_i32MixerFD = open("/dev/mixer", O_RDWR);

		if (s_i32MixerFD < 0) {
			ERRPRINT("open(/dev/mixer) failed");
			close(s_i32DSPFD);
			FUN_MUTEX_UNLOCK(&s_sOSSFunMutex);
			return ERR_OSS_DEV;
		} // if
	}

	if (s_i32MixerFD >= 0) {
		const int	i32Volume = (u32Volume << 8) | u32Volume;	// H/L: Right/Left

		if (ioctl(s_i32MixerFD, MIXER_WRITE(SOUND_MIXER_PCM), &i32Volume) < 0) {
			perror("ioctl(/dev/mixer, MIXER_WRITE(SOUND_MIXER_PCM)) failed");
			return ERR_OSS_VOLUME;
		} // if

		g_u32NMPlayer_Volume = u32Volume;
		close(s_i32MixerFD);
		s_i32MixerFD = -1;
	} // if

	FUN_MUTEX_UNLOCK(&s_sOSSFunMutex);
	return ERR_OSS_NONE;
}
Beispiel #25
0
Datei: Emix.c Projekt: Limsik/e17
void
set_volume(void *data)
{
   unsigned char       lrvl[4];
   MIX_CHANNEL        *dev = (MIX_CHANNEL *) data;

   if (mute_status)
     {
	mute_status = 0;
	toggle_mute(&channels[0]);
	Epplet_gadget_data_changed(b_mute);
     }
   lrvl[0] = (20 - (unsigned char)dev->value) * 5;
   lrvl[1] = lrvl[0];
   lrvl[2] = lrvl[3] = 0;
   ioctl(fd_mixer, MIXER_WRITE(dev->id), lrvl);
}
Beispiel #26
0
HX_RESULT CAudioOutLinux::_SetVolume(UINT16 unVolume)
{
    HX_RESULT retCode = RA_AOE_NOERR;
    
    int nNewVolume=0;

    //Set both left and right volumes.
    nNewVolume = (unVolume & 0xff) | ((unVolume &0xff) << 8);
    
    if (::ioctl( m_nMixerID, MIXER_WRITE(HX_VOLUME), &nNewVolume) < 0)
    {
        retCode = RA_AOE_NOTSUPPORTED;
    }

    m_wLastError = retCode;
    return m_wLastError;
}
Beispiel #27
0
Datei: Emix.c Projekt: Limsik/e17
static void
toggle_mute(void *data)
{
   unsigned char       lrvl[4];
   MIX_CHANNEL        *dev = (MIX_CHANNEL *) data;

   if (mute_status)
     {
	lrvl[0] = lrvl[1] = 0;
     }
   else
     {
	lrvl[0] = (20 - (unsigned char)dev->value) * 5;
	lrvl[1] = lrvl[0];
     }
   lrvl[2] = lrvl[3] = 0;
   ioctl(fd_mixer, MIXER_WRITE(dev->id), lrvl);
}
Beispiel #28
0
void
oss_audio_iport_set(audio_desc_t ad, audio_port_t port)
{
	int portmask;
	int recsrc;
	int gain;

        UNUSED(ad); assert(devices[ad].mixer_rfd > 0);

        switch (port) {
		case AUDIO_MICROPHONE: 
			debug_msg("Trying to select microphone input...\n");
			recsrc = SOUND_MASK_MIC;  
			break;
		case AUDIO_LINE_IN:    
			debug_msg("Trying to select line input...\n");
			recsrc = SOUND_MASK_LINE; 
			break;
		case AUDIO_CD:         
			debug_msg("Trying to select CD input...\n");
			recsrc = SOUND_MASK_CD;   
			break;
		default:
			debug_msg("Port not recognized\n");
			return;
        }

        /* Can we select chosen port ? */
        if (devices[ad].rec_mask & recsrc) {
                portmask = recsrc;
                if ((ioctl(devices[ad].mixer_rfd, MIXER_WRITE(SOUND_MIXER_RECSRC), &recsrc) == -1) && !(recsrc & portmask)) {
                        debug_msg("WARNING: Unable to select recording source!\n");
                        return;
                }
                gain = oss_audio_get_igain(ad);
                iport = port;
                oss_audio_set_igain(ad, gain);
		debug_msg("...okay\n");
        } else {
                debug_msg("Audio device doesn't support recording from port %d (%s)\n", port, oss_mixer_channels[port]);
        }
}
Beispiel #29
0
int ioctl_test(int dsp, int mixer)
{
	int data;
	mixer_info info;
	char tmpBuf[40];

	printf("***IOCTL Test ***\n");

	ioctl(dsp, OSS_GETVERSION, &data);
	if(data != SOUND_VERSION) {
		printf("Get OSS_GETVERSION error, %d\n", data);
		return -1;
	}

	ioctl(mixer, OSS_GETVERSION, &data);
	if(data != SOUND_VERSION) {
		printf("Get OSS_GETVERSION error, %d\n", data);
		return -1;
	}

	ioctl(dsp, SNDCTL_DSP_GETCAPS, &data);

	/* set volume to 100 */
	data = 0x6464;
	ioctl(mixer, MIXER_WRITE(SOUND_MIXER_VOLUME), &data);

	ioctl(mixer, SOUND_MIXER_INFO, &info);
	memset(tmpBuf, 0, sizeof(tmpBuf));
	strncpy(tmpBuf, info.name, 32);
	printf("Device Information : %s\n", tmpBuf);

	/* get internel data block size */
	ioctl(dsp, SNDCTL_DSP_GETBLKSIZE, &data);
	printf("Internal Fragment Size : %d\n", data);
	block_size = data;


	return 0;
}
Beispiel #30
0
int mixer_test(int dsp, int mixer)
{
	int fd, samplerate = 8000, channel = 2;
	int status, volume[] = {0x2121, 0x4242, 0x6464}, i;

	printf("***Mixer Volume test***\n");

	fd = open("8k.pcm", O_RDONLY);
	if ( fd < 0 ) {
		close(mixer);
		printf("Open 44.1k.pcm error\n");
		return -1;
	}

	ioctl(dsp, SNDCTL_DSP_SPEED, &samplerate);
	ioctl(dsp, SNDCTL_DSP_CHANNELS, &channel);

	for(i = 0; i < 3; i++){
		printf("Set Volume to %d%% and press ENTER to play ...\n",
				volume[i]&0xff);
		ioctl(mixer, MIXER_WRITE(SOUND_MIXER_VOLUME), &volume[i]);
		getchar();

		while(read(fd, buffer, block_size))
			write(dsp, buffer, block_size);

		/* wait the last block play off */
		ioctl(dsp, SNDCTL_DSP_SYNC);

		
		lseek(fd, 0, SEEK_SET);
	}

	close(fd);
	close(mixer);

	return 0;	
	
}