Hi All,
In my A20 board i have 3 sound cards. Now i want to play one song in two
sound card at a time.
IS it possible in android by changing the audio_hw.c file (out_write
function which is opening the sound card and writing data).
Here i am attaching out_write function from audio_hw.c , i did some
modification to play same song in two sound cards.
but it is not working. If any one knows how to implement this one , kindly
tell me.
Regards
Punith
--
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
---
You received this message because you are subscribed to the Google Groups
"android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
size_t bytes)
{
struct sunxi_stream_out *out = (struct sunxi_stream_out *)stream;
struct sunxi_stream_out *fd = (struct sunxi_stream_out *)stream;
struct sunxi_audio_device *adev = out->dev;
struct sunxi_audio_device *adev1 = fd->dev;
bool force_input_standby = false;
size_t frame_size = audio_stream_frame_size(&out->stream.common);
size_t frame_size_fd = audio_stream_frame_size(&fd->stream.common);
size_t in_frames = bytes / frame_size;
size_t out_frames = RESAMPLER_BUFFER_SIZE / frame_size;
struct sunxi_stream_in *in;
unsigned int card = CARD_A1X_DEFAULT;
unsigned int port = PORT_CODEC;
void *buf;
int ret;
int device = adev->devices;
int device1 = adev1->devices;
char prop_value[512];
//FILE *fd *fp;
//char C, D;
if (adev->raw_flag)
{
return 0;
}
pthread_mutex_lock(&adev->lock);
pthread_mutex_lock(&out->lock);
pthread_mutex_lock(&adev1->lock);
pthread_mutex_lock(&fd->lock);
if (out->standby )
{
adev->devices = device;
adev->active_output = out;
adev1->devices = device1;
adev1->active_output = fd;
/* a change in output device may change the microphone selection */
if (adev->active_input &&
adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION)
force_input_standby = true;
out->config.channels = 2;//cda_dec->pDev.AudioBsInfo.chan;
out->config.rate = 44100;//cda_dec->pDev.AudioBsInfo.Samplerate;
out->config.period_size = 1024;
out->config.period_count = 4;
out->config.format = PCM_FORMAT_S16_LE;
out->config.start_threshold = 0;
out->config.stop_threshold = 0;
out->config.silence_threshold = 0;
fd->config.channels = 2;//cda_dec->pDev.AudioBsInfo.chan;
fd->config.rate = 44100;//cda_dec->pDev.AudioBsInfo.Samplerate;
fd->config.period_size = 1024;
fd->config.period_count = 4;
fd->config.format = PCM_FORMAT_S16_LE;
fd->config.start_threshold = 0;
fd->config.stop_threshold = 0;
fd->config.silence_threshold = 0;
out->pcm = pcm_open(2, port, PCM_OUT, &(out->config));
fd->pcm = pcm_open(0, port, PCM_OUT, &(fd->config));
if (!out->pcm || !pcm_is_ready(out->pcm) ) { //added by punith
ALOGW("Unable to open PCM device %u (%s)\n",
port, pcm_get_error(out->pcm));
pthread_mutex_unlock(&adev->lock);
goto exit;
}
out->standby = 0; //comeented by Punith
}
1237,8-15 45%
pthread_mutex_unlock(&adev->lock);
pthread_mutex_unlock(&adev1->lock);
out_frames = in_frames;
buf = (void *)buffer;
ret = pcm_write(out->pcm, (void *)buf, out_frames * frame_size);
ret = pcm_write(fd->pcm, (void *)buf, out_frames * frame_size);
if (ret != 0)
{
do_output_standby(out);
}
exit:
if (ret != 0) {
usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
out_get_sample_rate(&stream->common));
}
pthread_mutex_unlock(&out->lock);
pthread_mutex_unlock(&fd->lock);
if (force_input_standby) {
pthread_mutex_lock(&adev->lock);
if (adev->active_input) {
in = adev->active_input;
pthread_mutex_lock(&in->lock);
do_input_standby(in);
pthread_mutex_unlock(&in->lock);
}
pthread_mutex_unlock(&adev->lock);
}
return bytes;
}