Skip to content

Commit

Permalink
Updated the extension name
Browse files Browse the repository at this point in the history
  • Loading branch information
devsdmf committed Nov 8, 2015
1 parent 7b9d016 commit 29216b8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 78 deletions.
14 changes: 7 additions & 7 deletions config.m4
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
LDFLAGS=`libmikmod-config --libs`

PHP_ARG_WITH(mod_player, for module audio files support,
[ --with-mod-player[=DIR] include cli audio support])
PHP_ARG_WITH(modplayer, for module audio files support,
[ --with-modplayer[=DIR] include module player support])

if test "$PHP_MOD_PLAYER" != "no"; then
for i in $PHP_MOD_PLAYER /usr/local /usr; do
if test "$PHP_MODPLAYER" != "no"; then
for i in $PHP_MODPLAYER /usr/local /usr; do
test -f $i/include/mikmod.h && MIKMOD_DIR=$i && break
done

if test -z "$PHP_MOD_PLAYER"; then
if test -z "$PHP_MODPLAYER"; then
AC_MSG_ERROR(mikmod.h not found. Please reinstall libmikmod.)
fi

PHP_ADD_LIBRARY_WITH_PATH(mod_player, $MIKMOD_DIR/$PHP_LIBDIR)
PHP_ADD_LIBRARY_WITH_PATH(modplayer, $MIKMOD_DIR/$PHP_LIBDIR)
PHP_ADD_INCLUDE($MIKMOD_DIR/include)

PHP_NEW_EXTENSION(mod_player, mod_player.c, $ext_shared,,)
PHP_NEW_EXTENSION(modplayer, modplayer.c, $ext_shared, cli,)
fi
58 changes: 29 additions & 29 deletions mod_player.c → modplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,60 @@

#include "php.h"
#include "php_ini.h"
#include "php_mod_player.h"
#include "php_modplayer.h"
#include "mikmod.h"

ZEND_DECLARE_MODULE_GLOBALS(mod_player)
ZEND_DECLARE_MODULE_GLOBALS(modplayer)

static zend_function_entry mod_player_functions[] = {
static zend_function_entry modplayer_functions[] = {
PHP_FE(play_module_file, NULL)
PHP_FE(mod_player_getpid, NULL)
PHP_FE(stop_module_file, NULL)
{NULL, NULL, NULL}
};

zend_module_entry mod_player_module_entry = {
zend_module_entry modplayer_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_MOD_PLAYER_EXTNAME,
mod_player_functions,
PHP_MINIT(mod_player),
PHP_MSHUTDOWN(mod_player),
PHP_MODPLAYER_EXTNAME,
modplayer_functions,
PHP_MINIT(modplayer),
PHP_MSHUTDOWN(modplayer),
NULL,
NULL,
NULL,
#if ZEND_MODULE_API_NO >= 20010901
PHP_MOD_PLAYER_VERSION,
PHP_MODPLAYER_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_MOD_PLAYER
ZEND_GET_MODULE(mod_player)
#ifdef COMPILE_DL_MODPLAYER
ZEND_GET_MODULE(modplayer)
#endif

PHP_INI_BEGIN()
PHP_INI_ENTRY("mod_player.maxchan","64",PHP_INI_ALL,NULL)
PHP_INI_ENTRY("mod_player.curious","0",PHP_INI_ALL,NULL)
PHP_INI_ENTRY("modplayer.maxchan","64",PHP_INI_ALL,NULL)
PHP_INI_ENTRY("modplayer.curious","0",PHP_INI_ALL,NULL)
PHP_INI_END()

static void php_mod_player_init_globals(zend_mod_player_globals *mod_player_globals)
static void php_modplayer_init_globals(zend_modplayer_globals *modplayer_globals)
{
mod_player_globals->pid = 0;
modplayer_globals->pid = 0;
}

PHP_MINIT_FUNCTION(mod_player)
PHP_MINIT_FUNCTION(modplayer)
{
ZEND_INIT_MODULE_GLOBALS(mod_player, php_mod_player_init_globals, NULL);
ZEND_INIT_MODULE_GLOBALS(modplayer, php_modplayer_init_globals, NULL);
REGISTER_INI_ENTRIES();
return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(mod_player)
PHP_MSHUTDOWN_FUNCTION(modplayer)
{
if (MOD_PLAYER_G(pid) > 0) {
kill(MOD_PLAYER_G(pid), SIGKILL);
if (MODPLAYER_G(pid) > 0) {
kill(MODPLAYER_G(pid), SIGKILL);
}

UNREGISTER_INI_ENTRIES();
Expand All @@ -89,7 +89,7 @@ PHP_FUNCTION(play_module_file)
RETURN_NULL();
}

if (MOD_PLAYER_G(pid) > 0) {
if (MODPLAYER_G(pid) > 0) {
zend_error(E_ERROR, "You've already started the module player");
RETURN_NULL();
}
Expand All @@ -101,25 +101,25 @@ PHP_FUNCTION(play_module_file)
RETURN_NULL();
}

s_pid = stream_audio(fptr, INI_INT("mod_player.maxchan"), INI_INT("mod_player.curious"));
s_pid = stream_audio(fptr, INI_INT("modplayer.maxchan"), INI_INT("modplayer.curious"));

if (s_pid > 0) {
MOD_PLAYER_G(pid) = s_pid;
MODPLAYER_G(pid) = s_pid;
}

RETURN_LONG(s_pid);
}

PHP_FUNCTION(mod_player_getpid)
{
RETURN_LONG(MOD_PLAYER_G(pid));
RETURN_LONG(MODPLAYER_G(pid));
}

PHP_FUNCTION(stop_module_file)
{
if (MOD_PLAYER_G(pid) > 0) {
kill(MOD_PLAYER_G(pid), SIGKILL);
MOD_PLAYER_G(pid) = 0;
if (MODPLAYER_G(pid) > 0) {
kill(MODPLAYER_G(pid), SIGKILL);
MODPLAYER_G(pid) = 0;
}

RETURN_NULL();
Expand Down Expand Up @@ -152,7 +152,7 @@ int stream_audio(FILE *fptr, int maxchan, int curious)
Player_Start(module);

s_pid = getpid();
MOD_PLAYER_G(pid) = s_pid;
MODPLAYER_G(pid) = s_pid;

while (Player_Active()) {
usleep(10000);
Expand All @@ -166,7 +166,7 @@ int stream_audio(FILE *fptr, int maxchan, int curious)
fclose(fptr);
MikMod_Exit();
} else if (m_pid < 0) {
zend_error(E_ERROR, "Failed to fork CLI Audio Stream process");
zend_error(E_ERROR, "Failed to fork CLI audio stream process");
return -1;
}

Expand Down
42 changes: 0 additions & 42 deletions php_mod_player.h

This file was deleted.

42 changes: 42 additions & 0 deletions php_modplayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* PHP CLI AUDIO STREAMMER
*
* This is a extension to provide a stream of module audio files under
* the CLI SAPI. This library is licensed under the MIT license.
*
* Developed by: devSDMF <devsdmf@gmail.com>
*
*/
#ifndef PHP_MODPLAYER_H
#define PHP_MODPLAYER_H 1

#ifdef ZTS
#include "TSRM.h"
#endif

ZEND_BEGIN_MODULE_GLOBALS(modplayer)
long pid;
ZEND_END_MODULE_GLOBALS(modplayer)

#ifdef ZTS
#define MODPLAYER_G(v) TSRM(modplayer_globals_id, zend_modplayer_globals *, v)
#else
#define MODPLAYER_G(v) (modplayer_globals.v)
#endif

#define PHP_MODPLAYER_EXTNAME "modplayer"
#define PHP_MODPLAYER_VERSION "1.1.0"

PHP_MINIT_FUNCTION(modplayer);
PHP_MSHUTDOWN_FUNCTION(modplayer);

PHP_FUNCTION(play_module_file);
PHP_FUNCTION(mod_player_getpid);
PHP_FUNCTION(stop_module_file);

int stream_audio(FILE *fptr, int maxchan, int curious);

extern zend_module_entry modplayer_module_entry;
#define phpext_mod_player_ptr &modplayer_module_entry;

#endif

0 comments on commit 29216b8

Please sign in to comment.