Пример #1
0
static void oss_write_audio(gpointer data, int length)
{
	audio_buf_info abuf_info;
	AFormat new_format;
	int new_frequency, new_channels;
	EffectPlugin *ep;
	
	new_format = input.format.xmms;
	new_frequency = input.frequency;
	new_channels = input.channels;
	
	ep = get_current_effect_plugin();
	if(effects_enabled() && ep && ep->query_format)
	{
		ep->query_format(&new_format,&new_frequency,&new_channels);
	}
	
	if (new_format != effect.format.xmms ||
	    new_frequency != effect.frequency ||
	    new_channels != effect.channels)
	{
		output_time_offset += (output_bytes * 1000) / output.bps;
		output_bytes = 0;
		close(fd);
		fd = open(device_name,O_WRONLY);
		oss_setup_format(new_format, new_frequency, new_channels);
	}
	if (effects_enabled() && ep && ep->mod_samples)
		length = ep->mod_samples(&data, length,
					 input.format.xmms,
					 input.frequency,
					 input.channels);
	if (realtime && !ioctl(fd, SNDCTL_DSP_GETOSPACE, &abuf_info))
	{
		while (abuf_info.bytes < length)
		{
			xmms_usleep(10000);
			if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &abuf_info))
				break;
		}
	}

	if (oss_convert_func != NULL)
		length = oss_convert_func(&data, length);

	if (oss_stereo_convert_func != NULL)
		length = oss_stereo_convert_func(&data, length,
						 output.format.oss);

	if (effect.frequency == output.frequency)
		output_bytes += write_all(fd, data, length);
	else
		output_bytes += oss_downsample(data, length,
					       effect.frequency,
					       output.frequency);
}
Пример #2
0
static void
op_write (void *ptr, int len)
{
	EffectPlugin *ep;

	if (paused)
		return;

	/* This sucks but XMMS totally broke the effect plugin code when
	   they added support for multiple enabled effects.  Complain to
	   the non-existent XMMS team if a plugin does not work, however
	   this does not seem to affect any plugins in our ports tree. */
	ep = get_current_effect_plugin ();
	ep->mod_samples (&ptr, len, afmt, par.rate, par.pchan);

	/* Do not lock sio_write as this will cause the GUI thread
	   to block waiting for a blocked sio_write to return. */
	len = sio_write (hdl, ptr, len);

	pthread_mutex_lock (&mutex);
	wrpos += len;
	pthread_mutex_unlock (&mutex);
}