질문이요!!!!

boss0327의 이미지

안녕하세요~!!!
오디오 데이터 소켓전송 프로그래밍도중에 궁금한 점이 있어 질문 올립니다!~!!
일단 원 소스입니다.

void* audio_audio(void*arg)
{
unsigned char *sPtr, *sPtr1, *sPtr2;
unsigned char out_buff1[4];
unsigned short out_buff[NUM_OF_AUDIOIN_CHANNEL];
unsigned int count;
int ret;

while(1)
{
usleep(1000);

if(play_start)
{
read(raudio, (char *)audiobuf, abuf_size);
sPtr = audiobuf;

sPtr1 = (unsigned char *)&out_buff;
count = (abuf_size/sizeof(out_buff));

while(count)
{

memcpy(sPtr1, sPtr, sizeof(out_buff));
sPtr += sizeof(out_buff);
count--;

send(client[0], (char *)&out_buff[0], 2, 0);

}
}
}
}
raudio 는 오디오디바이스(/dev/dsp) 오픈한 변수이구요 audiobuf가 데이터를 가져옵니다.
가져온 데이터는 4채널 데이터가 믹스된 데이터입니다.
두번째 while 문에서 채널별로 분리를 하는데요 send 함수의 2번째 인자인 (char *)&out_buff[0] 가 1번채널 데이터를 뜻합니다.
그런데 소켓 연결 테스트를 하는 도중에 프로그램 자체가 죽는 현상이 발생 하네요.
여기서 두번째 while문을 사용하지 않고 아래와 같이 audiobuf 값을 보내고 소켓 연결 테스트를 하면 프로그램은 죽지 않지만 2,3,4번채널의 데이터로 인해서 잡음이 생기구요.

void* audio_audio(void*arg)
{
unsigned char *sPtr, *sPtr1, *sPtr2;
unsigned char out_buff1[4];
unsigned short out_buff[NUM_OF_AUDIOIN_CHANNEL];
unsigned int count;
int ret;

while(1)
{
usleep(1000);

if(play_start)
{
read(raudio, (char *)audiobuf, abuf_size);
sPtr = audiobuf;

sPtr1 = (unsigned char *)&out_buff;
count = (abuf_size/sizeof(out_buff));
send(client[0], audiobuf, abuf_size, 0);
}

}
}

while문 하나를 이용해서 구현 하는 방법은 없을까요??ㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.