Ejemplo n.º 1
0
static void copy_sample_data(running_machine &machine, const INT16 *data, int bytes_to_copy)
{
	void *buffer1, *buffer2 = (void *)NULL;
	long length1, length2;
	int cur_bytes;

	// attempt to lock the stream buffer
	if (lock_buffer(machine, stream_buffer_in, bytes_to_copy, &buffer1, &length1, &buffer2, &length2) < 0)
	{
		buffer_underflows++;
		return;
	}

	// adjust the input pointer
	stream_buffer_in += bytes_to_copy;
	if (stream_buffer_in >= stream_buffer_size)
	{
		stream_buffer_in -= stream_buffer_size;
		stream_loop = 1;

		if (LOG_SOUND)
			fprintf(sound_log, "stream_loop set to 1 (stream_buffer_in looped)\n");
	}

	// copy the first chunk
	cur_bytes = (bytes_to_copy > length1) ? length1 : bytes_to_copy;
	att_memcpy(buffer1, data, cur_bytes);

	// adjust for the number of bytes
	bytes_to_copy -= cur_bytes;
	data = (INT16 *)((UINT8 *)data + cur_bytes);

	// copy the second chunk
	if (bytes_to_copy != 0)
	{
		cur_bytes = (bytes_to_copy > length2) ? length2 : bytes_to_copy;
		att_memcpy(buffer2, data, cur_bytes);
	}

	// unlock
	unlock_buffer();
}
Ejemplo n.º 2
0
void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame)
{
	static unsigned char bufferatt[882*2*2*10];

	if (machine->sample_rate != 0 )
	{
		if(attenuation!=0)
		{
		    att_memcpy(bufferatt, buffer, samples_this_frame * sizeof(INT16) * 2);
		    myosd_sound_play(bufferatt,samples_this_frame * sizeof(INT16) * 2);
		}
		else
		{
			myosd_sound_play(buffer,samples_this_frame * sizeof(INT16) * 2);
		}
	}
}