我正在尝试向 ac 文件添加一个新函数“pa_context_set_sink_input_paused”。这个 c 文件是 pulseaudio 的一部分。我也能够成功地编译pulseaudio。
我添加到 c 文件中的代码(其中定义了许多其他函数,并且这些函数被声明为全局函数)。
pa_operation* pa_context_set_sink_input_paused(pa_context *c, uint32_t idx, int pause, pa_context_success_cb_t cb, void *userdata)
{
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
//PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_PAUSE, &tag); // ADD A NEW COMMAND
pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
pa_tagstruct_put_boolean(t, pause);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
return o;
}
在头文件中,函数声明如下
/** Set the pause of a sink input stream specified by its index */
pa_operation* pa_context_set_sink_input_paused(pa_context *c, uint32_t idx, int pause, pa_context_success_cb_t cb, void *userdata); //ADDED BY SATHISH
像这样编译:
$ gcc pa_listclients_pause.c -o pa_listclients_pause -L /home/sathish/Desktop/pulseaudio-4.0/build/src/.libs/ -lpulse
/tmp/ccueP47b.o: In function `pa_get_devicelist':
pa_listclients_pause.c.text+0x6cb): undefined reference to `pa_context_set_sink_input_paused'
collect2: error: ld returned 1 exit status
但是当我尝试使用这个新函数运行一个程序时,它会返回“未定义的引用”。
我尝试运行 nm 命令并检查 libpulse.so 中是否存在新函数
该函数返回给我它找到了它..
$ nm -A *.so | grep "pa_context_set_sink_input_paused"
libpulse.so:0001d4a0 **t** pa_context_set_sink_input_paused
它被标识为带有字母“t”的本地符号。
我无法理解正在发生的事情。你能帮我解决这个问题吗??
谢谢, 萨西什
更新:-
多谢你们,
Your pointers helped me to narrow down close to a solution.. I edited my Makefile process to expose my new function as a "GLOBAL SYMBOL".
In explanation, there was a file named "map-file" which holding which functions become as global and local. I added my function into the global part of the file.. These seems to have temporarily solved the issue..
I have added the new error I am facing as a seperate question.
http://stackoverflow.com/questions/20702888/relocation-error-while-running-binary
Any pointers on the new issue ??
谢谢, 萨西什