Загрузка данных


    {
        unsigned ptime;

        status = pjmedia_clock_create(pool,
                                      snd_port->clock_rate,
                                      snd_port->channel_count,
                                      snd_port->samples_per_frame,
                                      0,
                                      &clock_callback,
                                      snd_port,
                                      &snd_port->clock);
        if (status != PJ_SUCCESS)
            goto on_error;

        ptime = snd_port->samples_per_frame * 1000 / snd_port->clock_rate /
                snd_port->channel_count;
        status = pjmedia_delay_buf_create(pool, "playdbuf",
                                          snd_port->clock_rate,
                                          snd_port->samples_per_frame,
                                          snd_port->channel_count,
                                          PJMEDIA_SOUND_BUFFER_COUNT * ptime,
                                          0, /* options */
                                          &snd_port->play_dbuf);
        if (status != PJ_SUCCESS)
            goto on_error;

        status = pjmedia_delay_buf_create(pool, "capdbuf",
                                          snd_port->clock_rate,
                                          snd_port->samples_per_frame,
                                          snd_port->channel_count,
                                          PJMEDIA_SOUND_BUFFER_COUNT * ptime,
                                          0, /* options */
                                          &snd_port->cap_dbuf);
        if (status != PJ_SUCCESS)
            goto on_error;

        snd_port->frame_buf = (pj_int16_t*)
                              pj_pool_zalloc(pool,
                                             snd_port->samples_per_frame * 2);
        if (!snd_port->frame_buf) {
            status = PJ_ENOMEM;
            goto on_error;
        }

        status = pjmedia_clock_start(snd_port->clock);
        if (status != PJ_SUCCESS)
            goto on_error;

        PJ_LOG(4,(THIS_FILE, "Sound port uses internal (or software) clock"));
    }